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

Merged
merged 42 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
37d57c4
Init `EmptyBlocks` plugin prototype.
Mati365 Jan 15, 2025
9efcd01
Add tests.
Mati365 Jan 15, 2025
fe051c7
Minor fixes in docs after CR.
Mati365 Jan 17, 2025
e57d7f5
Adjust checks
Mati365 Jan 17, 2025
5e61837
Add table tests.
Mati365 Jan 17, 2025
99cef94
Table autoparagraphing fixes.
Mati365 Jan 17, 2025
2e5c624
Add more tests.
Mati365 Jan 17, 2025
19c2a63
Code align improvements.
Mati365 Jan 17, 2025
e6a035e
Add consume downcasted attributes.
Mati365 Jan 20, 2025
df9a25b
Better code split.
Mati365 Jan 20, 2025
581252f
Improve priorities.
Mati365 Jan 20, 2025
182a351
Add data checks for list item tests.
Mati365 Jan 20, 2025
9a930db
Apply table CR remarks.
Mati365 Jan 20, 2025
8187cc9
Adjust docs.
Mati365 Jan 20, 2025
99f91c7
Adjust table cell downcasts after CR.
Mati365 Jan 20, 2025
dcb6876
Simplified implementation.
niegowski Jan 20, 2025
4b6b2d4
Block filler handling adjusted to be able to detect presence of it wh…
niegowski Jan 21, 2025
063f1f2
Fixed block filler handling.
niegowski Jan 21, 2025
bc6bca7
Added tests.
niegowski Jan 22, 2025
e0d570d
Added code comments.
niegowski Jan 22, 2025
b6ed3d5
Added EmptyBlock integration tests.
niegowski Jan 22, 2025
890234f
Added EmptyBlock integration tests.
niegowski Jan 22, 2025
a6c2fd6
Updated tests.
niegowski Jan 22, 2025
6326054
Typo fix.
niegowski Jan 22, 2025
2716c5d
Merge branch 'master' into ck/skip-block-filler-option
niegowski Jan 22, 2025
3a489d0
Added missing dev dependency.
niegowski Jan 23, 2025
48ff505
Fix typos.
Mati365 Jan 24, 2025
192eba5
Add clipboard integration to `EmptyBlock` plugin. (#17805)
Mati365 Jan 24, 2025
b6400a5
Assign editor in manual tests to window variables.
Mati365 Jan 27, 2025
d4b60a8
Add inspector to manual demo.
Mati365 Jan 27, 2025
aafc9b6
Add experimental warning.
Mati365 Jan 28, 2025
7834715
Add GHS empty div test.
Mati365 Jan 28, 2025
72ca176
Fix self import.
Mati365 Jan 28, 2025
4f733a6
Reorder docs.
Mati365 Jan 28, 2025
66fa312
Reorder docs.
Mati365 Jan 28, 2025
5f486b7
Fix newline.
Mati365 Jan 28, 2025
af673d0
Merge remote-tracking branch 'origin' into ck/skip-block-filler-option
Mati365 Jan 30, 2025
d8cafb7
Add configuration for preserving block filler in editing view.
Mati365 Jan 30, 2025
f72b720
Apply CR remarks.
Mati365 Jan 31, 2025
39be496
Apply CR remark.
Mati365 Jan 31, 2025
73d1dbc
Fix typo.
Mati365 Jan 31, 2025
c9f3bbf
Adjust config option name.
Mati365 Feb 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions packages/ckeditor5-html-support/src/emptyblock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default class EmptyBlock extends Plugin {
public afterInit(): void {
const { model, conversion, plugins, config } = this.editor;
const schema = model.schema;
const preserveInEditingView = config.get( 'emptyBlock.preserveInEditingView' );
const preserveInEditingView = config.get( 'htmlSupport.emptyBlock.preserveInEditingView' );

schema.extend( '$block', { allowAttributes: [ EMPTY_BLOCK_MODEL_ATTRIBUTE ] } );
schema.extend( '$container', { allowAttributes: [ EMPTY_BLOCK_MODEL_ATTRIBUTE ] } );
Expand All @@ -99,13 +99,11 @@ export default class EmptyBlock extends Plugin {
/**
* Handle clipboard paste events:
*
* * It does not affect *copying* content from the editor, only *pasting*.
* * When content is pasted from another editor instance with `<p></p>`,
* the `&nbsp;` filler is added, so the getData result is `<p>&nbsp;</p>`.
* * When content is pasted from the same editor instance with `<p></p>`,
* the `&nbsp;` filler is not added, so the getData result is `<p></p>`.
*
* @internal
* * It does not affect *copying* content from the editor, only *pasting*.
* * When content is pasted from another editor instance with `<p></p>`,
* the `&nbsp;` filler is added, so the getData result is `<p>&nbsp;</p>`.
* * When content is pasted from the same editor instance with `<p></p>`,
* the `&nbsp;` filler is not added, so the getData result is `<p></p>`.
*/
private _registerClipboardPastingHandler() {
const clipboardPipeline: ClipboardPipeline = this.editor.plugins.get( 'ClipboardPipeline' );
Expand Down
34 changes: 0 additions & 34 deletions packages/ckeditor5-html-support/src/emptyblockconfig.ts

This file was deleted.

16 changes: 16 additions & 0 deletions packages/ckeditor5-html-support/src/generalhtmlsupportconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,20 @@ export interface GeneralHtmlSupportConfig {
* ```
*/
allowEmpty?: Array<string>;

/**
* The configuration of allowed empty block elements that should not be removed.
Mati365 marked this conversation as resolved.
Show resolved Hide resolved
*
* The option is used by the {@link module:html-support/emptyblock~EmptyBlock} feature.
*/
emptyBlock?: {

/**
* When set to `true`, empty blocks will be preserved in the editing view.
* When `false` (default), empty blocks are only preserved in the data output.
*
* @default false
*/
preserveInEditingView?: boolean;
};
}
12 changes: 8 additions & 4 deletions packages/ckeditor5-html-support/tests/emptyblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,10 @@ describe( 'EmptyBlock', () => {

editor = await ClassicTestEditor.create( element, {
plugins: [ Paragraph, TableEditing, EmptyBlock, Heading, ListEditing, BlockQuote, Clipboard ],
emptyBlock: {
preserveInEditingView: true
htmlSupport: {
emptyBlock: {
preserveInEditingView: true
}
}
} );

Expand All @@ -352,8 +354,10 @@ describe( 'EmptyBlock', () => {

editor = await ClassicTestEditor.create( element, {
plugins: [ Paragraph, TableEditing, EmptyBlock, Heading, ListEditing, BlockQuote, Clipboard ],
emptyBlock: {
preserveInEditingView: false
htmlSupport: {
emptyBlock: {
preserveInEditingView: false
}
}
} );

Expand Down
6 changes: 4 additions & 2 deletions packages/ckeditor5-html-support/tests/manual/emptyblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ function createEditor1( preserveInEditingView ) {
return ClassicEditor
.create( document.getElementById( 'editor1' ), {
...config,
emptyBlock: {
preserveInEditingView
htmlSupport: {
emptyBlock: {
preserveInEditingView
}
}
} )
.then( instance => {
Expand Down