Skip to content

Unwanted page break #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ggirardi1 opened this issue Apr 10, 2023 · 5 comments
Closed

Unwanted page break #27

ggirardi1 opened this issue Apr 10, 2023 · 5 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@ggirardi1
Copy link
Contributor

ggirardi1 commented Apr 10, 2023

Hi @motla

I don't want this page break to happen for my sections.

I am unable to prevent this behavior via CSS alone, as it seems that vue-document-editor does not seem to take into consideration page-break-before, page-break-after or page-break-inside. What do I need to do?

Ps.: My sections are in <section> elements.

image

@motla motla added enhancement New feature or request help wanted Extra attention is needed labels Apr 14, 2023
@motla
Copy link
Owner

motla commented Apr 14, 2023

Hi @guilhermeagirardi,
It is not implemented yet and not trivial to implement. For example we have to handle the case when the section height is higher than the page height. I can't look at it right now, but the starting point would be to detect the <section> element in this line to avoid splitting it:

// if it is a node with no content (e.g. <img>), or a header title (e.g. <h1>) we simply move it
else if(!sub_child.childNodes.length || sub_child.tagName.match(/h\d/i)) {

@ggirardi1
Copy link
Contributor Author

Hi @motla !

Thank you for the feedback and the suggestion.

What I did was add a callback at the end of the conditional test of that function.

else if (!sub_child.childNodes.length || sub_child.tagName.match(/h\d/i) || do_not_break(sub_child)) {
<vue-document-editor
    ref="editor"
    v-model:content="content"
    :do_not_break="(sub_child) => sub_child.tagName.match(/section/i)"
/>

This was enough for me at the time to define different breakage prevention situations.

@motla
Copy link
Owner

motla commented Apr 18, 2023

Well done! Great implementation 👍
I may add it to the next release but I'm afraid of edge cases, it needs some testing.

@motla
Copy link
Owner

motla commented May 27, 2023

Hi @guilhermeagirardi
For your information I just released v2.3.0 (Vue3) and v1.5.0 (Vue2) which contains your implementation. I have set you as co-author.

@ggirardi1
Copy link
Contributor Author

Hi @motla!

It was no big deal. I'm honored to know that. Thankss! 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants