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

Add EmptyBlock plugin that prevents adding   in exported data. #17756

Open
wants to merge 41 commits into
base: master
Choose a base branch
from

Conversation

Mati365
Copy link
Member

@Mati365 Mati365 commented Jan 15, 2025

Suggested merge commit message (convention)

Feature (html-support): Add an experimental EmptyBlock plugin that prevents adding   to output data.

Other (engine): The whitespaces around a block filler ( ) are ignored while loading editor data.


Additional information

It's part of https://github.com/cksource/ckeditor5-commercial/pull/6942
Original issue https://github.com/cksource/ckeditor5-commercial/issues/6941

More details: Notion

@Mati365 Mati365 marked this pull request as ready for review January 15, 2025 12:44
@Mati365 Mati365 changed the title Add EmptyBlocks plugin that allows for preserving empty block elements in the editor. Add EmptyBlocks plugin that prevents adding   in exported data. Jan 15, 2025
@Mati365 Mati365 requested review from niegowski and arkflpc January 15, 2025 13:05
Copy link
Contributor

@niegowski niegowski left a comment

Choose a reason for hiding this comment

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

Apart from the comments below, the clipboard integration is missing.

packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/tests/emptyblocks.js Outdated Show resolved Hide resolved
@Mati365 Mati365 force-pushed the ck/skip-block-filler-option branch from b1e0b3b to e57d7f5 Compare January 17, 2025 06:23
@Witoso
Copy link
Member

Witoso commented Jan 17, 2025

Please link to API docs of this plugin in the table:
image

Mention from which version available.

@Mati365 Mati365 requested a review from niegowski January 17, 2025 11:15
packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/tests/emptyblocks.js Outdated Show resolved Hide resolved
packages/ckeditor5-table/src/converters/upcasttable.ts Outdated Show resolved Hide resolved
@Mati365 Mati365 requested a review from niegowski January 20, 2025 10:56
packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblocks.ts Outdated Show resolved Hide resolved
'<paragraph htmlEmptyBlock="true" listIndent="0" listType="bulleted"></paragraph>'
);

expect( editor.getData() ).to.equal( '<p>A</p><ul><li><p></p></li></ul>' );
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd expect the output would not have an empty <p> as there wasn't one in the input.

packages/ckeditor5-html-support/tests/emptyblocks.js Outdated Show resolved Hide resolved
pszczesniak
pszczesniak previously approved these changes Jan 28, 2025
Copy link
Contributor

@pszczesniak pszczesniak left a comment

Choose a reason for hiding this comment

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

Works as intended 👍

gorzelinski
gorzelinski previously approved these changes Jan 28, 2025
mmotyczynska
mmotyczynska previously approved these changes Jan 28, 2025
@Mati365
Copy link
Member Author

Mati365 commented Jan 29, 2025

@niegowski Can you check? Merging is blocked without your approval.

@gorzelinski gorzelinski self-requested a review January 30, 2025 13:58
gorzelinski
gorzelinski previously approved these changes Jan 30, 2025
packages/ckeditor5-html-support/src/emptyblockconfig.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblockconfig.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblock.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblock.ts Outdated Show resolved Hide resolved
packages/ckeditor5-html-support/src/emptyblock.ts Outdated Show resolved Hide resolved
@Mati365
Copy link
Member Author

Mati365 commented Jan 31, 2025

@niegowski CR remarks applied.

@Mati365
Copy link
Member Author

Mati365 commented Jan 31, 2025

@niegowski CR remarks applied.

@@ -80,4 +80,21 @@ export interface GeneralHtmlSupportConfig {
* ```
*/
allowEmpty?: Array<string>;

/**
* Whether a filler text (non-breaking space entity — &nbsp;) will be inserted into empty block elements in HTML output.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Whether a filler text (non-breaking space entity &nbsp;) will be inserted into empty block elements in HTML output.
* Whether a filler text (non-breaking space entity `&nbsp;`) will be inserted into empty block elements in HTML output.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Witoso could you check if this config description is clear enough? Note that the feature is enabled by including the plugin itself and this config refers to the alternative mode in the editing pipeline.

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.

7 participants