@ckeditor/ckeditor5-html-support 45.0.0-alpha.9 → 45.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-html-support",
3
- "version": "45.0.0-alpha.9",
3
+ "version": "45.1.0-alpha.0",
4
4
  "description": "HTML Support feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -17,16 +17,16 @@
17
17
  "type": "module",
18
18
  "main": "src/index.js",
19
19
  "dependencies": {
20
- "@ckeditor/ckeditor5-core": "45.0.0-alpha.9",
21
- "@ckeditor/ckeditor5-engine": "45.0.0-alpha.9",
22
- "@ckeditor/ckeditor5-enter": "45.0.0-alpha.9",
23
- "@ckeditor/ckeditor5-heading": "45.0.0-alpha.9",
24
- "@ckeditor/ckeditor5-image": "45.0.0-alpha.9",
25
- "@ckeditor/ckeditor5-list": "45.0.0-alpha.9",
26
- "@ckeditor/ckeditor5-table": "45.0.0-alpha.9",
27
- "@ckeditor/ckeditor5-utils": "45.0.0-alpha.9",
28
- "@ckeditor/ckeditor5-widget": "45.0.0-alpha.9",
29
- "ckeditor5": "45.0.0-alpha.9",
20
+ "@ckeditor/ckeditor5-core": "45.1.0-alpha.0",
21
+ "@ckeditor/ckeditor5-engine": "45.1.0-alpha.0",
22
+ "@ckeditor/ckeditor5-enter": "45.1.0-alpha.0",
23
+ "@ckeditor/ckeditor5-heading": "45.1.0-alpha.0",
24
+ "@ckeditor/ckeditor5-image": "45.1.0-alpha.0",
25
+ "@ckeditor/ckeditor5-list": "45.1.0-alpha.0",
26
+ "@ckeditor/ckeditor5-table": "45.1.0-alpha.0",
27
+ "@ckeditor/ckeditor5-utils": "45.1.0-alpha.0",
28
+ "@ckeditor/ckeditor5-widget": "45.1.0-alpha.0",
29
+ "ckeditor5": "45.1.0-alpha.0",
30
30
  "es-toolkit": "1.32.0"
31
31
  },
32
32
  "author": "CKSource (http://cksource.com/)",
package/src/datafilter.js CHANGED
@@ -626,6 +626,43 @@ export default class DataFilter extends Plugin {
626
626
  schema.register('htmlEmptyElement', {
627
627
  inheritAllFrom: '$inlineObject'
628
628
  });
629
+ // Helper function to check if an element has any HTML attributes.
630
+ const hasHtmlAttributes = (element) => Array
631
+ .from(element.getAttributeKeys())
632
+ .some(key => key.startsWith('html'));
633
+ // Register a post-fixer that removes htmlEmptyElement when its htmlXX attribute is removed.
634
+ // See: https://github.com/ckeditor/ckeditor5/issues/18089
635
+ editor.model.document.registerPostFixer(writer => {
636
+ const changes = editor.model.document.differ.getChanges();
637
+ const elementsToRemove = new Set();
638
+ for (const change of changes) {
639
+ if (change.type === 'remove') {
640
+ continue;
641
+ }
642
+ // Look for removal of html* attributes.
643
+ if (change.type === 'attribute' && change.attributeNewValue === null) {
644
+ // Find htmlEmptyElement instances in the range that lost their html attribute.
645
+ for (const { item } of change.range) {
646
+ if (item.is('element', 'htmlEmptyElement') && !hasHtmlAttributes(item)) {
647
+ elementsToRemove.add(item);
648
+ }
649
+ }
650
+ }
651
+ // Look for insertion of htmlEmptyElement.
652
+ if (change.type === 'insert' && change.position.nodeAfter) {
653
+ const insertedElement = change.position.nodeAfter;
654
+ for (const { item } of writer.createRangeOn(insertedElement)) {
655
+ if (item.is('element', 'htmlEmptyElement') && !hasHtmlAttributes(item)) {
656
+ elementsToRemove.add(item);
657
+ }
658
+ }
659
+ }
660
+ }
661
+ for (const element of elementsToRemove) {
662
+ writer.remove(element);
663
+ }
664
+ return elementsToRemove.size > 0;
665
+ });
629
666
  }
630
667
  editor.data.htmlProcessor.domConverter.registerInlineObjectMatcher(element => {
631
668
  // Element must be empty and have any attribute.
@@ -56,7 +56,8 @@ export default class HtmlComment extends Plugin {
56
56
  *
57
57
  * By default, it includes comments at the range boundaries.
58
58
  *
59
- * @param range
59
+ * @param range The range to search for HTML comments.
60
+ * @param options Additional options.
60
61
  * @param options.skipBoundaries When set to `true` the range boundaries will be skipped.
61
62
  * @returns HTML comment IDs
62
63
  */
@@ -205,7 +205,8 @@ export default class HtmlComment extends Plugin {
205
205
  *
206
206
  * By default, it includes comments at the range boundaries.
207
207
  *
208
- * @param range
208
+ * @param range The range to search for HTML comments.
209
+ * @param options Additional options.
209
210
  * @param options.skipBoundaries When set to `true` the range boundaries will be skipped.
210
211
  * @returns HTML comment IDs
211
212
  */
@@ -44,6 +44,8 @@
44
44
  //
45
45
  // Skipped hidden elements:
46
46
  // noscript
47
+ //
48
+ // When adding elements to this list, update the feature guide listing, too.
47
49
  export default {
48
50
  block: [
49
51
  // Existing features.