@@ -16,15 +16,11 @@ const EMPTY_BLOCK_MODEL_ATTRIBUTE = 'htmlEmptyBlock';
1616 * This plugin allows for preserving empty block elements in the editor content instead of
1717 * automatically filling them with block fillers (` `).
1818 *
19- * Empty elements are detected during upcast and marked with a special attribute.
20- * During downcast, elements with this attribute have their `getFillerOffset` set to `null`
21- * which prevents adding block fillers.
22- *
2319 * This is useful when you want to:
2420 *
2521 * * Preserve empty block elements exactly as they were in the source HTML
26- * * Allow for styling empty blocks with CSS (block fillers can interfere with height/margin)
27- * * Maintain compatibility with external systems that expect empty blocks to remain empty
22+ * * Allow for styling empty blocks with CSS (block fillers can interfere with height/margin)
23+ * * Maintain compatibility with external systems that expect empty blocks to remain empty
2824 *
2925 * For example, this allows for HTML like:
3026 *
@@ -63,12 +59,12 @@ export default class EmptyBlocks extends Plugin {
6359 const editor = this . editor ;
6460 const schema = editor . model . schema ;
6561
66- // Register the attribute for block elements
62+ // Register the attribute for block elements.
6763 schema . extend ( '$block' , {
6864 allowAttributes : [ EMPTY_BLOCK_MODEL_ATTRIBUTE ]
6965 } ) ;
7066
71- // Upcast conversion - detect empty elements
67+ // Upcast conversion - detect empty elements.
7268 editor . conversion . for ( 'upcast' ) . add ( dispatcher => {
7369 dispatcher . on < UpcastElementEvent > ( 'element' , ( evt , data , conversionApi ) => {
7470 const { viewItem, modelRange } = data ;
@@ -77,15 +73,15 @@ export default class EmptyBlocks extends Plugin {
7773 return ;
7874 }
7975
80- const modelElement = modelRange ? .start . nodeAfter as Element ;
76+ const modelElement = modelRange && modelRange . start . nodeAfter as Element ;
8177
8278 if ( modelElement && schema . isBlock ( modelElement ) ) {
8379 conversionApi . writer . setAttribute ( EMPTY_BLOCK_MODEL_ATTRIBUTE , true , modelElement ) ;
8480 }
85- } , { priority : 'lowest' } ) ;
81+ } ) ;
8682 } ) ;
8783
88- // Data downcast conversion - prevent filler in empty elements
84+ // Data downcast conversion - prevent filler in empty elements.
8985 editor . conversion . for ( 'dataDowncast' ) . add ( dispatcher => {
9086 dispatcher . on ( `attribute:${ EMPTY_BLOCK_MODEL_ATTRIBUTE } ` , ( evt , data , conversionApi ) => {
9187 const { item } = data ;
@@ -94,7 +90,7 @@ export default class EmptyBlocks extends Plugin {
9490 if ( viewElement && data . attributeNewValue ) {
9591 viewElement . getFillerOffset = ( ) => null ;
9692 }
97- } , { priority : 'highest' } ) ;
93+ } ) ;
9894 } ) ;
9995 }
10096}
0 commit comments