Replies: 9 comments
-
Hmm, I don't have any experience with pagination at all, so I'm not really sure where to begin. I guess in the absence of a reason to the contrary, I might have done the styling on the contenteditable editor div, but maybe that is just wrong. I also noticed this article which might have some useful information. I will try to poke around at it a bit, but I think this is pretty much beyond the scope of what the MarkupEditor is meant to be. Along those lines, I even wonder if it's not more practical to use the height of the document to create different MarkupWKWebViews on-demand on the Swift side and combine the separate HTML at save time. |
Beta Was this translation helpful? Give feedback.
-
It's interesting. What I see is that the caret insertion point is shown incorrectly. When you open the demo, the SelectionState reflects the position being at the beginning of the document, in
Occasionally the insertion point disappears if |
Beta Was this translation helpful? Give feedback.
-
Thanks for your suggestion. I'm wondering how to get the current height of the document? We can divide it by the content height to get the number of pages then. Then only thing is we need to calculate it in real time. I think some ePub application doing this pretty well. |
Beta Was this translation helpful? Give feedback.
-
One way you can do it is to implement If you want to determine the height from the MarkupWKWebView directly, you can use
|
Beta Was this translation helpful? Give feedback.
-
The delegate works. Then need to figure it out how to split the html into multiple pages. No idea how to do it now. Do you have any suggestion? |
Beta Was this translation helpful? Give feedback.
-
My initial thought was to keep the full doc in a non-visible MarkupWKWebView, and present a single page extracted from it (as an HTML template like cut/paste does in markup.js) that you are actually editing. Then you could push the changes to the full doc when needed. As with most initial thoughts, this ends up being complicated. It's complicated to split pages in lists, etc to get this single page to edit, and it will be complicated to recombine them when needed. I know it's complicated because I had to do a lot of that kind of thing for the special handling of Enter in the MarkupEditor, for cut/paste, undo/redo, etc, and I suspect a lot of similar work would have to be done here, too. Hmm. All this mainly makes me wish the I will think about it some more. Maybe there is a way to suppress scrolling and then use some scroll position magic that presents the document in a kind of page-at-a-time way? If so, then the height change could be used to trigger any needed changes to the scroll positions that corresponded to pages. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your reply and patience. I'm not familiar with JS part. Do you have any suggestion on this topic? If there are any document regarding with this? |
Beta Was this translation helpful? Give feedback.
-
As I said, I think my initial thought on "keep the full doc in a non-visible MarkupWKWebView, and present a single page extracted from it" would be a pretty big project. To me it resembles the work I did for special handling of Enter. This is particularly difficult for lists, where you sometimes want Enter to create a new list item and other times (when the list item is empty) to back up a level in the list. That is some of the ugliest code I wrote, which I can't say I'm very proud of, beyond the fact that it works. To try to be clearer about why it's hard, consider you are inside of bolded text in a sublist item of a bulleted list, and your typing causes the page length to go beyond the size displayable on a single screen. At that point, how do you create a new document that begins with a list whose contents is empty but is several levels deep and contains an empty editable bold element that can be selected and allows you to continue to type? I don't know exactly, but I'm sure it will be difficult, and I wouldn't embark on it lightly. I think I would pursue the following in order:
|
Beta Was this translation helpful? Give feedback.
-
I moved the original issue to Discussions in case anyone wants to pursue it further. |
Beta Was this translation helpful? Give feedback.
-
I replace the
<body>
element in html with the following code to support pagination. The pagination is working well.But there is a problem. The even page can't be edit. Please refer to my video.
demo.mov
What could be the problem? Any idea? Thanks.
Beta Was this translation helpful? Give feedback.
All reactions