-
Multiple EditorsI would like to have pages in my editor, similar to Microsoft Word or Google Docs where each page has a blank space between them. I've tried doing the hacks other people have described via content-editable but they don't really work because you can delete the page break. My use case is that I want to make a WYSIWYG editor for PDF / docx, but I can't seem to find a way to put that heard break in there. I may just resort to adding "page indicators" that tell you where a page ends based on height by drawing a line.
The above works, but Perhaps I'm going about the above wrong? Should I instead have multiple |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
On top of my head, I'd probably approach the problem with a transform rather than via hardcoded pages. See the CharacterLimit plugin for instance (https://github.com/facebook/lexical/blob/main/packages/lexical-react/src/shared/useCharacterLimit.js#L126). What it does is to calculate how much content it can fit and otherwise wrap the rest elsewhere. For pages, it'd be rect sizes instead but the idea is similar. And you'd have to handle the special hard page break case.
To answer the question specifically, onChange does listen to all LexicalComposer EditorState changes but if Page is a DecoratorNode you'll have to propagate your (React) component changes to the Node. And I would use a single LexicalEditor instance, so a single LexicalComposer |
Beta Was this translation helpful? Give feedback.
On top of my head, I'd probably approach the problem with a transform rather than via hardcoded pages. See the CharacterLimit plugin for instance (https://github.com/facebook/lexical/blob/main/packages/lexical-react/src/shared/useCharacterLimit.js#L126). What it does is to calculate how much content it can fit and otherwise wrap the rest elsewhere.
For pages, it'd be rect sizes instead but the idea is similar. And you'd have to handle the special hard page break case.
To answer the question specifically, onChange does listen to all LexicalComposer EditorState changes but if Page is a DecoratorNode you'll have to propagate…