@ckeditor/ckeditor5-remove-format 48.8.1-alpha.4 → 49.0.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.
Files changed (159) hide show
  1. package/dist/augmentation.d.ts +13 -13
  2. package/dist/index-content.css +3 -0
  3. package/dist/index-content.css.map +1 -0
  4. package/dist/index-editor.css +3 -0
  5. package/dist/index-editor.css.map +1 -0
  6. package/dist/index.d.ts +10 -10
  7. package/dist/index.js +245 -232
  8. package/dist/index.js.map +1 -1
  9. package/dist/removeformat.d.ts +27 -27
  10. package/dist/removeformatcommand.d.ts +60 -60
  11. package/dist/removeformatediting.d.ts +31 -31
  12. package/dist/removeformatui.d.ts +25 -25
  13. package/dist/translations/af.js +1 -1
  14. package/dist/translations/af.umd.js +5 -3
  15. package/dist/translations/ar.js +1 -1
  16. package/dist/translations/ar.umd.js +5 -3
  17. package/dist/translations/ast.js +1 -1
  18. package/dist/translations/ast.umd.js +5 -3
  19. package/dist/translations/az.js +1 -1
  20. package/dist/translations/az.umd.js +5 -3
  21. package/dist/translations/be.js +1 -1
  22. package/dist/translations/be.umd.js +5 -3
  23. package/dist/translations/bg.js +1 -1
  24. package/dist/translations/bg.umd.js +5 -3
  25. package/dist/translations/bn.js +1 -1
  26. package/dist/translations/bn.umd.js +5 -3
  27. package/dist/translations/bs.js +1 -1
  28. package/dist/translations/bs.umd.js +5 -3
  29. package/dist/translations/ca.js +1 -1
  30. package/dist/translations/ca.umd.js +5 -3
  31. package/dist/translations/cs.js +1 -1
  32. package/dist/translations/cs.umd.js +5 -3
  33. package/dist/translations/da.js +1 -1
  34. package/dist/translations/da.umd.js +5 -3
  35. package/dist/translations/de-ch.js +1 -1
  36. package/dist/translations/de-ch.umd.js +5 -3
  37. package/dist/translations/de.js +1 -1
  38. package/dist/translations/de.umd.js +5 -3
  39. package/dist/translations/el.js +1 -1
  40. package/dist/translations/el.umd.js +5 -3
  41. package/dist/translations/en-au.js +1 -1
  42. package/dist/translations/en-au.umd.js +5 -3
  43. package/dist/translations/en-gb.js +1 -1
  44. package/dist/translations/en-gb.umd.js +5 -3
  45. package/dist/translations/en.js +1 -1
  46. package/dist/translations/en.umd.js +5 -3
  47. package/dist/translations/eo.js +1 -1
  48. package/dist/translations/eo.umd.js +5 -3
  49. package/dist/translations/es-co.js +1 -1
  50. package/dist/translations/es-co.umd.js +5 -3
  51. package/dist/translations/es.js +1 -1
  52. package/dist/translations/es.umd.js +5 -3
  53. package/dist/translations/et.js +1 -1
  54. package/dist/translations/et.umd.js +5 -3
  55. package/dist/translations/eu.js +1 -1
  56. package/dist/translations/eu.umd.js +5 -3
  57. package/dist/translations/fa.js +1 -1
  58. package/dist/translations/fa.umd.js +5 -3
  59. package/dist/translations/fi.js +1 -1
  60. package/dist/translations/fi.umd.js +5 -3
  61. package/dist/translations/fr.js +1 -1
  62. package/dist/translations/fr.umd.js +5 -3
  63. package/dist/translations/gl.js +1 -1
  64. package/dist/translations/gl.umd.js +5 -3
  65. package/dist/translations/gu.js +1 -1
  66. package/dist/translations/gu.umd.js +5 -3
  67. package/dist/translations/he.js +1 -1
  68. package/dist/translations/he.umd.js +5 -3
  69. package/dist/translations/hi.js +1 -1
  70. package/dist/translations/hi.umd.js +5 -3
  71. package/dist/translations/hr.js +1 -1
  72. package/dist/translations/hr.umd.js +5 -3
  73. package/dist/translations/hu.js +1 -1
  74. package/dist/translations/hu.umd.js +5 -3
  75. package/dist/translations/hy.js +1 -1
  76. package/dist/translations/hy.umd.js +5 -3
  77. package/dist/translations/id.js +1 -1
  78. package/dist/translations/id.umd.js +5 -3
  79. package/dist/translations/it.js +1 -1
  80. package/dist/translations/it.umd.js +5 -3
  81. package/dist/translations/ja.js +1 -1
  82. package/dist/translations/ja.umd.js +5 -3
  83. package/dist/translations/jv.js +1 -1
  84. package/dist/translations/jv.umd.js +5 -3
  85. package/dist/translations/kk.js +1 -1
  86. package/dist/translations/kk.umd.js +5 -3
  87. package/dist/translations/km.js +1 -1
  88. package/dist/translations/km.umd.js +5 -3
  89. package/dist/translations/kn.js +1 -1
  90. package/dist/translations/kn.umd.js +5 -3
  91. package/dist/translations/ko.js +1 -1
  92. package/dist/translations/ko.umd.js +5 -3
  93. package/dist/translations/ku.js +1 -1
  94. package/dist/translations/ku.umd.js +5 -3
  95. package/dist/translations/lt.js +1 -1
  96. package/dist/translations/lt.umd.js +5 -3
  97. package/dist/translations/lv.js +1 -1
  98. package/dist/translations/lv.umd.js +5 -3
  99. package/dist/translations/ms.js +1 -1
  100. package/dist/translations/ms.umd.js +5 -3
  101. package/dist/translations/nb.js +1 -1
  102. package/dist/translations/nb.umd.js +5 -3
  103. package/dist/translations/ne.js +1 -1
  104. package/dist/translations/ne.umd.js +5 -3
  105. package/dist/translations/nl.js +1 -1
  106. package/dist/translations/nl.umd.js +5 -3
  107. package/dist/translations/no.js +1 -1
  108. package/dist/translations/no.umd.js +5 -3
  109. package/dist/translations/oc.js +1 -1
  110. package/dist/translations/oc.umd.js +5 -3
  111. package/dist/translations/pl.js +1 -1
  112. package/dist/translations/pl.umd.js +5 -3
  113. package/dist/translations/pt-br.js +1 -1
  114. package/dist/translations/pt-br.umd.js +5 -3
  115. package/dist/translations/pt.js +1 -1
  116. package/dist/translations/pt.umd.js +5 -3
  117. package/dist/translations/ro.js +1 -1
  118. package/dist/translations/ro.umd.js +5 -3
  119. package/dist/translations/ru.js +1 -1
  120. package/dist/translations/ru.umd.js +5 -3
  121. package/dist/translations/si.js +1 -1
  122. package/dist/translations/si.umd.js +5 -3
  123. package/dist/translations/sk.js +1 -1
  124. package/dist/translations/sk.umd.js +5 -3
  125. package/dist/translations/sl.js +1 -1
  126. package/dist/translations/sl.umd.js +5 -3
  127. package/dist/translations/sq.js +1 -1
  128. package/dist/translations/sq.umd.js +5 -3
  129. package/dist/translations/sr-latn.js +1 -1
  130. package/dist/translations/sr-latn.umd.js +5 -3
  131. package/dist/translations/sr.js +1 -1
  132. package/dist/translations/sr.umd.js +5 -3
  133. package/dist/translations/sv.js +1 -1
  134. package/dist/translations/sv.umd.js +5 -3
  135. package/dist/translations/th.js +1 -1
  136. package/dist/translations/th.umd.js +5 -3
  137. package/dist/translations/ti.js +1 -1
  138. package/dist/translations/ti.umd.js +5 -3
  139. package/dist/translations/tk.js +1 -1
  140. package/dist/translations/tk.umd.js +5 -3
  141. package/dist/translations/tr.js +1 -1
  142. package/dist/translations/tr.umd.js +5 -3
  143. package/dist/translations/tt.js +1 -1
  144. package/dist/translations/tt.umd.js +5 -3
  145. package/dist/translations/ug.js +1 -1
  146. package/dist/translations/ug.umd.js +5 -3
  147. package/dist/translations/uk.js +1 -1
  148. package/dist/translations/uk.umd.js +5 -3
  149. package/dist/translations/ur.js +1 -1
  150. package/dist/translations/ur.umd.js +5 -3
  151. package/dist/translations/uz.js +1 -1
  152. package/dist/translations/uz.umd.js +5 -3
  153. package/dist/translations/vi.js +1 -1
  154. package/dist/translations/vi.umd.js +5 -3
  155. package/dist/translations/zh-cn.js +1 -1
  156. package/dist/translations/zh-cn.umd.js +5 -3
  157. package/dist/translations/zh.js +1 -1
  158. package/dist/translations/zh.umd.js +5 -3
  159. package/package.json +6 -6
@@ -1,15 +1,15 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- import type { RemoveFormat, RemoveFormatEditing, RemoveFormatUI, RemoveFormatCommand } from './index.js';
6
- declare module '@ckeditor/ckeditor5-core' {
7
- interface PluginsMap {
8
- [RemoveFormat.pluginName]: RemoveFormat;
9
- [RemoveFormatUI.pluginName]: RemoveFormatUI;
10
- [RemoveFormatEditing.pluginName]: RemoveFormatEditing;
11
- }
12
- interface CommandsMap {
13
- removeFormat: RemoveFormatCommand;
14
- }
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
+ import type { RemoveFormat, RemoveFormatEditing, RemoveFormatUI, RemoveFormatCommand } from "./index.js";
6
+ declare module "@ckeditor/ckeditor5-core" {
7
+ interface PluginsMap {
8
+ [RemoveFormat.pluginName]: RemoveFormat;
9
+ [RemoveFormatUI.pluginName]: RemoveFormatUI;
10
+ [RemoveFormatEditing.pluginName]: RemoveFormatEditing;
11
+ }
12
+ interface CommandsMap {
13
+ removeFormat: RemoveFormatCommand;
14
+ }
15
15
  }
@@ -2,3 +2,6 @@
2
2
  * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
+
6
+
7
+ /*# sourceMappingURL=index-content.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index-content.css"],"names":[],"mappings":";;;;;;AAEA,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC","file":"index-content.css.map","sourcesContent":["\n\n/*# sourceMappingURL=index-content.css.map */"]}
@@ -2,3 +2,6 @@
2
2
  * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
+
6
+
7
+ /*# sourceMappingURL=index-editor.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index-editor.css"],"names":[],"mappings":";;;;;;AAEA,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC","file":"index-editor.css.map","sourcesContent":["\n\n/*# sourceMappingURL=index-editor.css.map */"]}
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
5
  /**
6
- * @module remove-format
7
- */
8
- export { RemoveFormat } from './removeformat.js';
9
- export { RemoveFormatEditing } from './removeformatediting.js';
10
- export { RemoveFormatUI } from './removeformatui.js';
11
- export { RemoveFormatCommand, type IsFormattingCallback, type RemoveFormattingCallback } from './removeformatcommand.js';
12
- import './augmentation.js';
6
+ * @module remove-format
7
+ */
8
+ export { RemoveFormat } from "./removeformat.js";
9
+ export { RemoveFormatEditing } from "./removeformatediting.js";
10
+ export { RemoveFormatUI } from "./removeformatui.js";
11
+ export { RemoveFormatCommand, type IsFormattingCallback, type RemoveFormattingCallback } from "./removeformatcommand.js";
12
+ import "./augmentation.js";
package/dist/index.js CHANGED
@@ -2,247 +2,260 @@
2
2
  * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
- import { Plugin, Command } from '@ckeditor/ckeditor5-core/dist/index.js';
6
- import { IconRemoveFormat } from '@ckeditor/ckeditor5-icons/dist/index.js';
7
- import { ButtonView, MenuBarMenuListItemButtonView } from '@ckeditor/ckeditor5-ui/dist/index.js';
8
- import { first } from '@ckeditor/ckeditor5-utils/dist/index.js';
5
+ import { Command, Plugin } from "@ckeditor/ckeditor5-core";
6
+ import { IconRemoveFormat } from "@ckeditor/ckeditor5-icons";
7
+ import { ButtonView, MenuBarMenuListItemButtonView } from "@ckeditor/ckeditor5-ui";
8
+ import { first } from "@ckeditor/ckeditor5-utils";
9
9
 
10
- const REMOVE_FORMAT = 'removeFormat';
11
10
  /**
12
- * The remove format UI plugin. It registers the `'removeFormat'` button which can be
13
- * used in the toolbar.
14
- */ class RemoveFormatUI extends Plugin {
15
- /**
16
- * @inheritDoc
17
- */ static get pluginName() {
18
- return 'RemoveFormatUI';
19
- }
20
- /**
21
- * @inheritDoc
22
- */ static get isOfficialPlugin() {
23
- return true;
24
- }
25
- /**
26
- * @inheritDoc
27
- */ init() {
28
- const editor = this.editor;
29
- editor.ui.componentFactory.add(REMOVE_FORMAT, ()=>{
30
- const view = this._createButton(ButtonView);
31
- view.set({
32
- tooltip: true
33
- });
34
- return view;
35
- });
36
- editor.ui.componentFactory.add(`menuBar:${REMOVE_FORMAT}`, ()=>this._createButton(MenuBarMenuListItemButtonView));
37
- }
38
- /**
39
- * Creates a button for remove format command to use either in toolbar or in menu bar.
40
- */ _createButton(ButtonClass) {
41
- const editor = this.editor;
42
- const locale = editor.locale;
43
- const command = editor.commands.get(REMOVE_FORMAT);
44
- const view = new ButtonClass(editor.locale);
45
- const t = locale.t;
46
- view.set({
47
- label: t('Remove Format'),
48
- icon: IconRemoveFormat
49
- });
50
- view.bind('isEnabled').to(command, 'isEnabled');
51
- // Execute the command.
52
- this.listenTo(view, 'execute', ()=>{
53
- editor.execute(REMOVE_FORMAT);
54
- editor.editing.view.focus();
55
- });
56
- return view;
57
- }
58
- }
11
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
12
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
13
+ */
14
+ /**
15
+ * @module remove-format/removeformatui
16
+ */
17
+ const REMOVE_FORMAT = "removeFormat";
18
+ /**
19
+ * The remove format UI plugin. It registers the `'removeFormat'` button which can be
20
+ * used in the toolbar.
21
+ */
22
+ var RemoveFormatUI = class extends Plugin {
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get pluginName() {
27
+ return "RemoveFormatUI";
28
+ }
29
+ /**
30
+ * @inheritDoc
31
+ */
32
+ static get isOfficialPlugin() {
33
+ return true;
34
+ }
35
+ /**
36
+ * @inheritDoc
37
+ */
38
+ init() {
39
+ const editor = this.editor;
40
+ editor.ui.componentFactory.add(REMOVE_FORMAT, () => {
41
+ const view = this._createButton(ButtonView);
42
+ view.set({ tooltip: true });
43
+ return view;
44
+ });
45
+ editor.ui.componentFactory.add(`menuBar:${REMOVE_FORMAT}`, () => this._createButton(MenuBarMenuListItemButtonView));
46
+ }
47
+ /**
48
+ * Creates a button for remove format command to use either in toolbar or in menu bar.
49
+ */
50
+ _createButton(ButtonClass) {
51
+ const editor = this.editor;
52
+ const locale = editor.locale;
53
+ const command = editor.commands.get(REMOVE_FORMAT);
54
+ const view = new ButtonClass(editor.locale);
55
+ const t = locale.t;
56
+ view.set({
57
+ label: t("Remove Format"),
58
+ icon: IconRemoveFormat
59
+ });
60
+ view.bind("isEnabled").to(command, "isEnabled");
61
+ this.listenTo(view, "execute", () => {
62
+ editor.execute(REMOVE_FORMAT);
63
+ editor.editing.view.focus();
64
+ });
65
+ return view;
66
+ }
67
+ };
59
68
 
60
69
  /**
61
- * The remove format command.
62
- *
63
- * It is used by the {@link module:remove-format/removeformat~RemoveFormat remove format feature}
64
- * to clear the formatting in the selection.
65
- *
66
- * ```ts
67
- * editor.execute( 'removeFormat' );
68
- * ```
69
- */ class RemoveFormatCommand extends Command {
70
- /**
71
- * List of all registered custom attribute handlers.
72
- */ _customAttributesHandlers = [];
73
- /**
74
- * @inheritDoc
75
- */ refresh() {
76
- const model = this.editor.model;
77
- this.isEnabled = !!first(this._getFormattingItems(model.document.selection));
78
- }
79
- /**
80
- * @inheritDoc
81
- */ execute() {
82
- const model = this.editor.model;
83
- model.change((writer)=>{
84
- for (const item of this._getFormattingItems(model.document.selection)){
85
- if (item.is('selection')) {
86
- for (const attributeName of this._getFormattingAttributes(item)){
87
- writer.removeSelectionAttribute(attributeName);
88
- }
89
- } else {
90
- // Workaround for items with multiple removable attributes. See
91
- // https://github.com/ckeditor/ckeditor5-remove-format/pull/1#pullrequestreview-220515609
92
- const itemRange = writer.createRangeOn(item);
93
- for (const attributeName of this._getFormattingAttributes(item)){
94
- this._removeFormatting(attributeName, item, itemRange, writer);
95
- }
96
- }
97
- }
98
- });
99
- }
100
- /**
101
- * Registers a custom attribute handler that will be used to determine if an attribute is formatting and how to remove it.
102
- *
103
- * @internal
104
- */ registerCustomAttribute(isFormatting, removeFormatting) {
105
- this._customAttributesHandlers.push({
106
- isFormatting,
107
- removeFormatting
108
- });
109
- }
110
- /**
111
- * Helper method that removes a formatting attribute from an item either using custom callbacks or writer remove attribute.
112
- */ _removeFormatting(attributeName, item, itemRange, writer) {
113
- let customHandled = false;
114
- const nonSelectionAttributeName = toNonSelectionAttribute(attributeName);
115
- for (const { isFormatting, removeFormatting } of this._customAttributesHandlers){
116
- if (isFormatting(nonSelectionAttributeName, item)) {
117
- removeFormatting(attributeName, itemRange, writer);
118
- customHandled = true;
119
- }
120
- }
121
- if (!customHandled) {
122
- writer.removeAttribute(attributeName, itemRange);
123
- }
124
- }
125
- /**
126
- * Returns an iterable of items in a selection (including the selection itself) that have formatting model
127
- * attributes to be removed by the feature.
128
- */ *_getFormattingItems(selection) {
129
- const model = this.editor.model;
130
- const schema = model.schema;
131
- const itemHasRemovableFormatting = (item)=>{
132
- return !!first(this._getFormattingAttributes(item));
133
- };
134
- // Check formatting on selected items.
135
- for (const curRange of selection.getRanges()){
136
- for (const item of curRange.getItems()){
137
- // Ignore last block if range ends at the beginning of it.
138
- if (schema.isBlock(item) && curRange.end.isTouching(model.createPositionAt(item, 0))) {
139
- continue;
140
- }
141
- if (itemHasRemovableFormatting(item)) {
142
- yield item;
143
- }
144
- }
145
- }
146
- // Check formatting from selected blocks (to include partly selected blocks).
147
- for (const block of selection.getSelectedBlocks()){
148
- if (itemHasRemovableFormatting(block)) {
149
- yield block;
150
- }
151
- }
152
- // Finally the selection might be formatted as well, so make sure to check it.
153
- if (itemHasRemovableFormatting(selection)) {
154
- yield selection;
155
- }
156
- }
157
- /**
158
- * Returns an iterable of formatting attributes of a given model item.
159
- *
160
- * **Note:** Formatting items have the `isFormatting` property set to `true`.
161
- *
162
- * @returns The names of formatting attributes found in a given item.
163
- */ *_getFormattingAttributes(item) {
164
- const { schema } = this.editor.model;
165
- for (const [attributeName] of item.getAttributes()){
166
- const nonSelectionAttributeName = toNonSelectionAttribute(attributeName);
167
- for (const { isFormatting } of this._customAttributesHandlers){
168
- if (isFormatting(nonSelectionAttributeName, item)) {
169
- yield attributeName;
170
- }
171
- }
172
- const attributeProperties = schema.getAttributeProperties(nonSelectionAttributeName);
173
- if (attributeProperties && attributeProperties.isFormatting) {
174
- yield attributeName;
175
- }
176
- }
177
- }
178
- }
70
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
71
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
72
+ */
179
73
  /**
180
- * Helper function that converts a selection attribute name to a non-selection one. E.g. `selection:bold` to `bold`.
181
- */ function toNonSelectionAttribute(attributeName) {
182
- return attributeName.replace(/^selection:/, '');
74
+ * The remove format command.
75
+ *
76
+ * It is used by the {@link module:remove-format/removeformat~RemoveFormat remove format feature}
77
+ * to clear the formatting in the selection.
78
+ *
79
+ * ```ts
80
+ * editor.execute( 'removeFormat' );
81
+ * ```
82
+ */
83
+ var RemoveFormatCommand = class extends Command {
84
+ /**
85
+ * List of all registered custom attribute handlers.
86
+ */
87
+ _customAttributesHandlers = [];
88
+ /**
89
+ * @inheritDoc
90
+ */
91
+ refresh() {
92
+ const model = this.editor.model;
93
+ this.isEnabled = !!first(this._getFormattingItems(model.document.selection));
94
+ }
95
+ /**
96
+ * @inheritDoc
97
+ */
98
+ execute() {
99
+ const model = this.editor.model;
100
+ model.change((writer) => {
101
+ for (const item of this._getFormattingItems(model.document.selection)) if (item.is("selection")) for (const attributeName of this._getFormattingAttributes(item)) writer.removeSelectionAttribute(attributeName);
102
+ else {
103
+ const itemRange = writer.createRangeOn(item);
104
+ for (const attributeName of this._getFormattingAttributes(item)) this._removeFormatting(attributeName, item, itemRange, writer);
105
+ }
106
+ });
107
+ }
108
+ /**
109
+ * Registers a custom attribute handler that will be used to determine if an attribute is formatting and how to remove it.
110
+ *
111
+ * @internal
112
+ */
113
+ registerCustomAttribute(isFormatting, removeFormatting) {
114
+ this._customAttributesHandlers.push({
115
+ isFormatting,
116
+ removeFormatting
117
+ });
118
+ }
119
+ /**
120
+ * Helper method that removes a formatting attribute from an item either using custom callbacks or writer remove attribute.
121
+ */
122
+ _removeFormatting(attributeName, item, itemRange, writer) {
123
+ let customHandled = false;
124
+ const nonSelectionAttributeName = toNonSelectionAttribute(attributeName);
125
+ for (const { isFormatting, removeFormatting } of this._customAttributesHandlers) if (isFormatting(nonSelectionAttributeName, item)) {
126
+ removeFormatting(attributeName, itemRange, writer);
127
+ customHandled = true;
128
+ }
129
+ if (!customHandled) writer.removeAttribute(attributeName, itemRange);
130
+ }
131
+ /**
132
+ * Returns an iterable of items in a selection (including the selection itself) that have formatting model
133
+ * attributes to be removed by the feature.
134
+ */
135
+ *_getFormattingItems(selection) {
136
+ const model = this.editor.model;
137
+ const schema = model.schema;
138
+ const itemHasRemovableFormatting = (item) => {
139
+ return !!first(this._getFormattingAttributes(item));
140
+ };
141
+ for (const curRange of selection.getRanges()) for (const item of curRange.getItems()) {
142
+ if (schema.isBlock(item) && curRange.end.isTouching(model.createPositionAt(item, 0))) continue;
143
+ if (itemHasRemovableFormatting(item)) yield item;
144
+ }
145
+ for (const block of selection.getSelectedBlocks()) if (itemHasRemovableFormatting(block)) yield block;
146
+ if (itemHasRemovableFormatting(selection)) yield selection;
147
+ }
148
+ /**
149
+ * Returns an iterable of formatting attributes of a given model item.
150
+ *
151
+ * **Note:** Formatting items have the `isFormatting` property set to `true`.
152
+ *
153
+ * @returns The names of formatting attributes found in a given item.
154
+ */
155
+ *_getFormattingAttributes(item) {
156
+ const { schema } = this.editor.model;
157
+ for (const [attributeName] of item.getAttributes()) {
158
+ const nonSelectionAttributeName = toNonSelectionAttribute(attributeName);
159
+ for (const { isFormatting } of this._customAttributesHandlers) if (isFormatting(nonSelectionAttributeName, item)) yield attributeName;
160
+ const attributeProperties = schema.getAttributeProperties(nonSelectionAttributeName);
161
+ if (attributeProperties && attributeProperties.isFormatting) yield attributeName;
162
+ }
163
+ }
164
+ };
165
+ /**
166
+ * Helper function that converts a selection attribute name to a non-selection one. E.g. `selection:bold` to `bold`.
167
+ */
168
+ function toNonSelectionAttribute(attributeName) {
169
+ return attributeName.replace(/^selection:/, "");
183
170
  }
184
171
 
185
172
  /**
186
- * The remove format editing plugin.
187
- *
188
- * It registers the {@link module:remove-format/removeformatcommand~RemoveFormatCommand removeFormat} command.
189
- */ class RemoveFormatEditing extends Plugin {
190
- /**
191
- * @inheritDoc
192
- */ static get pluginName() {
193
- return 'RemoveFormatEditing';
194
- }
195
- /**
196
- * @inheritDoc
197
- * @internal
198
- */ static get licenseFeatureCode() {
199
- return 'RF';
200
- }
201
- /**
202
- * @inheritDoc
203
- */ static get isOfficialPlugin() {
204
- return true;
205
- }
206
- /**
207
- * @inheritDoc
208
- */ static get isPremiumPlugin() {
209
- return true;
210
- }
211
- /**
212
- * @inheritDoc
213
- */ init() {
214
- const editor = this.editor;
215
- editor.commands.add('removeFormat', new RemoveFormatCommand(editor));
216
- }
217
- }
173
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
174
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
175
+ */
176
+ /**
177
+ * @module remove-format/removeformatediting
178
+ */
179
+ /**
180
+ * The remove format editing plugin.
181
+ *
182
+ * It registers the {@link module:remove-format/removeformatcommand~RemoveFormatCommand removeFormat} command.
183
+ */
184
+ var RemoveFormatEditing = class extends Plugin {
185
+ /**
186
+ * @inheritDoc
187
+ */
188
+ static get pluginName() {
189
+ return "RemoveFormatEditing";
190
+ }
191
+ /**
192
+ * @inheritDoc
193
+ * @internal
194
+ */
195
+ static get licenseFeatureCode() {
196
+ return "RF";
197
+ }
198
+ /**
199
+ * @inheritDoc
200
+ */
201
+ static get isOfficialPlugin() {
202
+ return true;
203
+ }
204
+ /**
205
+ * @inheritDoc
206
+ */
207
+ static get isPremiumPlugin() {
208
+ return true;
209
+ }
210
+ /**
211
+ * @inheritDoc
212
+ */
213
+ init() {
214
+ const editor = this.editor;
215
+ editor.commands.add("removeFormat", new RemoveFormatCommand(editor));
216
+ }
217
+ };
218
218
 
219
219
  /**
220
- * The remove format plugin.
221
- *
222
- * This is a "glue" plugin which loads the {@link module:remove-format/removeformatediting~RemoveFormatEditing}
223
- * and {@link module:remove-format/removeformatui~RemoveFormatUI} plugins.
224
- *
225
- * For a detailed overview, check out the {@glink features/remove-format remove format} feature documentation.
226
- */ class RemoveFormat extends Plugin {
227
- /**
228
- * @inheritDoc
229
- */ static get requires() {
230
- return [
231
- RemoveFormatEditing,
232
- RemoveFormatUI
233
- ];
234
- }
235
- /**
236
- * @inheritDoc
237
- */ static get pluginName() {
238
- return 'RemoveFormat';
239
- }
240
- /**
241
- * @inheritDoc
242
- */ static get isOfficialPlugin() {
243
- return true;
244
- }
245
- }
220
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
221
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
222
+ */
223
+ /**
224
+ * @module remove-format/removeformat
225
+ */
226
+ /**
227
+ * The remove format plugin.
228
+ *
229
+ * This is a "glue" plugin which loads the {@link module:remove-format/removeformatediting~RemoveFormatEditing}
230
+ * and {@link module:remove-format/removeformatui~RemoveFormatUI} plugins.
231
+ *
232
+ * For a detailed overview, check out the {@glink features/remove-format remove format} feature documentation.
233
+ */
234
+ var RemoveFormat = class extends Plugin {
235
+ /**
236
+ * @inheritDoc
237
+ */
238
+ static get requires() {
239
+ return [RemoveFormatEditing, RemoveFormatUI];
240
+ }
241
+ /**
242
+ * @inheritDoc
243
+ */
244
+ static get pluginName() {
245
+ return "RemoveFormat";
246
+ }
247
+ /**
248
+ * @inheritDoc
249
+ */
250
+ static get isOfficialPlugin() {
251
+ return true;
252
+ }
253
+ };
254
+
255
+ /**
256
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
257
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
258
+ */
246
259
 
247
260
  export { RemoveFormat, RemoveFormatCommand, RemoveFormatEditing, RemoveFormatUI };
248
- //# sourceMappingURL=index.js.map
261
+ //# sourceMappingURL=index.js.map