Skip to content
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

Added keep-together paragraph style #45

Merged
merged 5 commits into from
Jun 11, 2018
Merged

Added keep-together paragraph style #45

merged 5 commits into from
Jun 11, 2018

Conversation

verheyenkoen
Copy link
Contributor

No description provided.

@connium
Copy link
Owner

connium commented Jun 9, 2018

Hello @verheyenkoen , thank you very much for your contribution!

When reading the code and comparing the output against a document created by LibreOffice I encountered two issues:

  1. Please add a possibility to revert the keep-together flag. There might be some scenarios where a document is automatically created and during the generation process a condition is met where you want to change/unset any property (happened to me with the setPageBreakBefore method, see issue Allow page break to be before or after a paragraph #31 )
    Maybe by providing a boolean flag as argument to the method (could default to true).
  2. When I configure LibreOffice to keep together a paragraph, it adds a <text:soft-page-break/> at the beginning of the respective paragraph. Do you know whether this is necessary? I wasn't able to find any information neither in the OASIS specification nor in the Relax NG Schema.

Copy link
Owner

@connium connium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good! I've left a few comments that should be addressed before this gets merged. 😃

@@ -16,6 +17,7 @@ const DEFAULT_PAGE_BREAK = false;
export class ParagraphProperties implements IParagraphProperties {
private horizontalAlignment: HorizontalAlignment;
private shouldBreakPageBefore: boolean;
private shouldKeepParagraphTogether: boolean;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename variable to shouldKeepTogether. The JSDoc of the method explains what this setting is meant for and I try to name the properties like they are named in the schema (makes it easier in the toXml method), if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in commit c107b2f

/**
* Sets the keep together attribute if paragraph marked as keep together.
*
* @param {Element} textPropertiesElement The element which will take the attribute
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the name of the attribute (the attribute actually is named paragraphPropertiesElement).

I just discovered it's wrong for the other methods in this class as well. If you don't mind, you may adjust the other JSDocs as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 3326a03

paragraphPropertiesElement.setAttribute(
OdfAttributeName.FormatKeepTogether,
"always"
);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max line length is 120, so you can put the whole in one line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's my local eslint kicking in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 8aa67a0

@verheyenkoen
Copy link
Contributor Author

verheyenkoen commented Jun 11, 2018

@connium About your main remarks:

  1. Addressed in 76f247c
  2. I tested this (without adding <text:soft-page-break/>) and it seems to work. In LibreOffice the paragraph style setting "Do not split paragraph" is checked and the paragraphs are indeed kept on the same page.

Anything else you think should be addressed for this PR?

@connium
Copy link
Owner

connium commented Jun 11, 2018

Thank you for improving the code. ✨

I'll merge your pull request this evening.

@connium connium added this to the 0.6.0 milestone Jun 11, 2018
@connium connium merged commit 50da4aa into connium:master Jun 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants