@ckeditor/ckeditor5-restricted-editing 47.6.1-alpha.1 → 48.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 (184) hide show
  1. package/ckeditor5-metadata.json +6 -6
  2. package/dist/index-editor.css +59 -0
  3. package/dist/index.css +61 -0
  4. package/dist/index.css.map +1 -0
  5. package/dist/index.js.map +1 -1
  6. package/{src → dist}/restrictededitingexceptionautocommand.d.ts +1 -1
  7. package/{src → dist}/restrictededitingexceptionblockcommand.d.ts +1 -1
  8. package/{src → dist}/restrictededitingexceptioncommand.d.ts +1 -1
  9. package/{src → dist}/restrictededitingmode/converters.d.ts +2 -2
  10. package/{src → dist}/restrictededitingmode/utils.d.ts +2 -2
  11. package/{src → dist}/restrictededitingmode.d.ts +1 -1
  12. package/{src → dist}/restrictededitingmodeediting.d.ts +1 -1
  13. package/{src → dist}/restrictededitingmodenavigationcommand.d.ts +1 -1
  14. package/{src → dist}/restrictededitingmodeui.d.ts +1 -1
  15. package/{src → dist}/standardeditingmode.d.ts +1 -1
  16. package/{src → dist}/standardeditingmodeediting.d.ts +1 -1
  17. package/{src → dist}/standardeditingmodeui.d.ts +1 -1
  18. package/package.json +25 -47
  19. package/build/restricted-editing.js +0 -5
  20. package/build/translations/af.js +0 -1
  21. package/build/translations/ar.js +0 -1
  22. package/build/translations/ast.js +0 -1
  23. package/build/translations/az.js +0 -1
  24. package/build/translations/be.js +0 -1
  25. package/build/translations/bg.js +0 -1
  26. package/build/translations/bn.js +0 -1
  27. package/build/translations/bs.js +0 -1
  28. package/build/translations/ca.js +0 -1
  29. package/build/translations/cs.js +0 -1
  30. package/build/translations/da.js +0 -1
  31. package/build/translations/de-ch.js +0 -1
  32. package/build/translations/de.js +0 -1
  33. package/build/translations/el.js +0 -1
  34. package/build/translations/en-au.js +0 -1
  35. package/build/translations/en-gb.js +0 -1
  36. package/build/translations/eo.js +0 -1
  37. package/build/translations/es-co.js +0 -1
  38. package/build/translations/es.js +0 -1
  39. package/build/translations/et.js +0 -1
  40. package/build/translations/eu.js +0 -1
  41. package/build/translations/fa.js +0 -1
  42. package/build/translations/fi.js +0 -1
  43. package/build/translations/fr.js +0 -1
  44. package/build/translations/gl.js +0 -1
  45. package/build/translations/gu.js +0 -1
  46. package/build/translations/he.js +0 -1
  47. package/build/translations/hi.js +0 -1
  48. package/build/translations/hr.js +0 -1
  49. package/build/translations/hu.js +0 -1
  50. package/build/translations/hy.js +0 -1
  51. package/build/translations/id.js +0 -1
  52. package/build/translations/it.js +0 -1
  53. package/build/translations/ja.js +0 -1
  54. package/build/translations/jv.js +0 -1
  55. package/build/translations/kk.js +0 -1
  56. package/build/translations/km.js +0 -1
  57. package/build/translations/kn.js +0 -1
  58. package/build/translations/ko.js +0 -1
  59. package/build/translations/ku.js +0 -1
  60. package/build/translations/lt.js +0 -1
  61. package/build/translations/lv.js +0 -1
  62. package/build/translations/ms.js +0 -1
  63. package/build/translations/nb.js +0 -1
  64. package/build/translations/ne.js +0 -1
  65. package/build/translations/nl.js +0 -1
  66. package/build/translations/no.js +0 -1
  67. package/build/translations/oc.js +0 -1
  68. package/build/translations/pl.js +0 -1
  69. package/build/translations/pt-br.js +0 -1
  70. package/build/translations/pt.js +0 -1
  71. package/build/translations/ro.js +0 -1
  72. package/build/translations/ru.js +0 -1
  73. package/build/translations/si.js +0 -1
  74. package/build/translations/sk.js +0 -1
  75. package/build/translations/sl.js +0 -1
  76. package/build/translations/sq.js +0 -1
  77. package/build/translations/sr-latn.js +0 -1
  78. package/build/translations/sr.js +0 -1
  79. package/build/translations/sv.js +0 -1
  80. package/build/translations/th.js +0 -1
  81. package/build/translations/ti.js +0 -1
  82. package/build/translations/tk.js +0 -1
  83. package/build/translations/tr.js +0 -1
  84. package/build/translations/tt.js +0 -1
  85. package/build/translations/ug.js +0 -1
  86. package/build/translations/uk.js +0 -1
  87. package/build/translations/ur.js +0 -1
  88. package/build/translations/uz.js +0 -1
  89. package/build/translations/vi.js +0 -1
  90. package/build/translations/zh-cn.js +0 -1
  91. package/build/translations/zh.js +0 -1
  92. package/lang/contexts.json +0 -11
  93. package/lang/translations/af.po +0 -48
  94. package/lang/translations/ar.po +0 -48
  95. package/lang/translations/ast.po +0 -48
  96. package/lang/translations/az.po +0 -48
  97. package/lang/translations/be.po +0 -48
  98. package/lang/translations/bg.po +0 -48
  99. package/lang/translations/bn.po +0 -48
  100. package/lang/translations/bs.po +0 -48
  101. package/lang/translations/ca.po +0 -48
  102. package/lang/translations/cs.po +0 -48
  103. package/lang/translations/da.po +0 -48
  104. package/lang/translations/de-ch.po +0 -48
  105. package/lang/translations/de.po +0 -48
  106. package/lang/translations/el.po +0 -48
  107. package/lang/translations/en-au.po +0 -48
  108. package/lang/translations/en-gb.po +0 -48
  109. package/lang/translations/en.po +0 -48
  110. package/lang/translations/eo.po +0 -48
  111. package/lang/translations/es-co.po +0 -48
  112. package/lang/translations/es.po +0 -48
  113. package/lang/translations/et.po +0 -48
  114. package/lang/translations/eu.po +0 -48
  115. package/lang/translations/fa.po +0 -48
  116. package/lang/translations/fi.po +0 -48
  117. package/lang/translations/fr.po +0 -48
  118. package/lang/translations/gl.po +0 -48
  119. package/lang/translations/gu.po +0 -48
  120. package/lang/translations/he.po +0 -48
  121. package/lang/translations/hi.po +0 -48
  122. package/lang/translations/hr.po +0 -48
  123. package/lang/translations/hu.po +0 -48
  124. package/lang/translations/hy.po +0 -48
  125. package/lang/translations/id.po +0 -48
  126. package/lang/translations/it.po +0 -48
  127. package/lang/translations/ja.po +0 -48
  128. package/lang/translations/jv.po +0 -48
  129. package/lang/translations/kk.po +0 -48
  130. package/lang/translations/km.po +0 -48
  131. package/lang/translations/kn.po +0 -48
  132. package/lang/translations/ko.po +0 -48
  133. package/lang/translations/ku.po +0 -48
  134. package/lang/translations/lt.po +0 -48
  135. package/lang/translations/lv.po +0 -48
  136. package/lang/translations/ms.po +0 -48
  137. package/lang/translations/nb.po +0 -48
  138. package/lang/translations/ne.po +0 -48
  139. package/lang/translations/nl.po +0 -48
  140. package/lang/translations/no.po +0 -48
  141. package/lang/translations/oc.po +0 -48
  142. package/lang/translations/pl.po +0 -48
  143. package/lang/translations/pt-br.po +0 -48
  144. package/lang/translations/pt.po +0 -48
  145. package/lang/translations/ro.po +0 -48
  146. package/lang/translations/ru.po +0 -48
  147. package/lang/translations/si.po +0 -48
  148. package/lang/translations/sk.po +0 -48
  149. package/lang/translations/sl.po +0 -48
  150. package/lang/translations/sq.po +0 -48
  151. package/lang/translations/sr-latn.po +0 -48
  152. package/lang/translations/sr.po +0 -48
  153. package/lang/translations/sv.po +0 -48
  154. package/lang/translations/th.po +0 -48
  155. package/lang/translations/ti.po +0 -48
  156. package/lang/translations/tk.po +0 -48
  157. package/lang/translations/tr.po +0 -48
  158. package/lang/translations/tt.po +0 -48
  159. package/lang/translations/ug.po +0 -48
  160. package/lang/translations/uk.po +0 -48
  161. package/lang/translations/ur.po +0 -48
  162. package/lang/translations/uz.po +0 -48
  163. package/lang/translations/vi.po +0 -48
  164. package/lang/translations/zh-cn.po +0 -48
  165. package/lang/translations/zh.po +0 -48
  166. package/src/augmentation.js +0 -5
  167. package/src/index.js +0 -20
  168. package/src/restrictededitingconfig.js +0 -5
  169. package/src/restrictededitingexceptionautocommand.js +0 -73
  170. package/src/restrictededitingexceptionblockcommand.js +0 -203
  171. package/src/restrictededitingexceptioncommand.js +0 -61
  172. package/src/restrictededitingmode/converters.js +0 -177
  173. package/src/restrictededitingmode/utils.js +0 -69
  174. package/src/restrictededitingmode.js +0 -39
  175. package/src/restrictededitingmodeediting.js +0 -512
  176. package/src/restrictededitingmodenavigationcommand.js +0 -99
  177. package/src/restrictededitingmodeui.js +0 -139
  178. package/src/standardeditingmode.js +0 -36
  179. package/src/standardeditingmodeediting.js +0 -193
  180. package/src/standardeditingmodeui.js +0 -150
  181. package/theme/restrictedediting.css +0 -10
  182. /package/{src → dist}/augmentation.d.ts +0 -0
  183. /package/{src → dist}/index.d.ts +0 -0
  184. /package/{src → dist}/restrictededitingconfig.d.ts +0 -0
@@ -1,139 +0,0 @@
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
- /**
6
- * @module restricted-editing/restrictededitingmodeui
7
- */
8
- import { Plugin } from 'ckeditor5/src/core.js';
9
- import { IconContentLock } from 'ckeditor5/src/icons.js';
10
- import { UIModel, createDropdown, addListToDropdown, MenuBarMenuListItemButtonView, MenuBarMenuView, MenuBarMenuListView, MenuBarMenuListItemView } from 'ckeditor5/src/ui.js';
11
- import { Collection } from 'ckeditor5/src/utils.js';
12
- /**
13
- * The restricted editing mode UI feature.
14
- *
15
- * It introduces the `'restrictedEditing'` dropdown that offers tools to navigate between exceptions across
16
- * the document.
17
- */
18
- export class RestrictedEditingModeUI extends Plugin {
19
- /**
20
- * @inheritDoc
21
- */
22
- static get pluginName() {
23
- return 'RestrictedEditingModeUI';
24
- }
25
- /**
26
- * @inheritDoc
27
- */
28
- static get isOfficialPlugin() {
29
- return true;
30
- }
31
- /**
32
- * @inheritDoc
33
- */
34
- init() {
35
- const editor = this.editor;
36
- const t = editor.t;
37
- editor.ui.componentFactory.add('restrictedEditing', locale => {
38
- const dropdownView = createDropdown(locale);
39
- const listItems = new Collection();
40
- this._getButtonDefinitions().forEach(({ commandName, label, keystroke }) => {
41
- listItems.add(this._getButtonDefinition(commandName, label, keystroke));
42
- });
43
- addListToDropdown(dropdownView, listItems, {
44
- role: 'menu'
45
- });
46
- dropdownView.buttonView.set({
47
- label: t('Navigate editable regions'),
48
- icon: IconContentLock,
49
- tooltip: true,
50
- isEnabled: true,
51
- isOn: false
52
- });
53
- this.listenTo(dropdownView, 'execute', evt => {
54
- const { _commandName } = evt.source;
55
- editor.execute(_commandName);
56
- editor.editing.view.focus();
57
- });
58
- return dropdownView;
59
- });
60
- editor.ui.componentFactory.add('menuBar:restrictedEditing', locale => {
61
- const menuView = new MenuBarMenuView(locale);
62
- const listView = new MenuBarMenuListView(locale);
63
- listView.set({
64
- ariaLabel: t('Navigate editable regions'),
65
- role: 'menu'
66
- });
67
- menuView.buttonView.set({
68
- label: t('Navigate editable regions'),
69
- icon: IconContentLock
70
- });
71
- menuView.panelView.children.add(listView);
72
- this._getButtonDefinitions().forEach(({ commandName, label, keystroke }) => {
73
- const listItemView = new MenuBarMenuListItemView(locale, menuView);
74
- const buttonView = this._createMenuBarButton(label, commandName, keystroke);
75
- buttonView.delegate('execute').to(menuView);
76
- listItemView.children.add(buttonView);
77
- listView.items.add(listItemView);
78
- });
79
- return menuView;
80
- });
81
- }
82
- /**
83
- * Creates a button for restricted editing command to use in menu bar.
84
- */
85
- _createMenuBarButton(label, commandName, keystroke) {
86
- const editor = this.editor;
87
- const command = editor.commands.get(commandName);
88
- const view = new MenuBarMenuListItemButtonView(editor.locale);
89
- view.set({
90
- label,
91
- keystroke,
92
- isEnabled: true,
93
- isOn: false
94
- });
95
- view.bind('isEnabled').to(command);
96
- // Execute the command.
97
- this.listenTo(view, 'execute', () => {
98
- editor.execute(commandName);
99
- editor.editing.view.focus();
100
- });
101
- return view;
102
- }
103
- /**
104
- * Returns a definition of the navigation button to be used in the dropdown.
105
- *
106
- * @param commandName The name of the command that the button represents.
107
- * @param label The translated label of the button.
108
- * @param keystroke The button keystroke.
109
- */
110
- _getButtonDefinition(commandName, label, keystroke) {
111
- const editor = this.editor;
112
- const command = editor.commands.get(commandName);
113
- const definition = {
114
- type: 'button',
115
- model: new UIModel({
116
- label,
117
- withText: true,
118
- keystroke,
119
- withKeystroke: true,
120
- role: 'menuitem',
121
- _commandName: commandName
122
- })
123
- };
124
- definition.model.bind('isEnabled').to(command, 'isEnabled');
125
- return definition;
126
- }
127
- /**
128
- * Returns definitions for UI buttons.
129
- *
130
- * @internal
131
- */
132
- _getButtonDefinitions() {
133
- const t = this.editor.locale.t;
134
- return [
135
- { commandName: 'goToPreviousRestrictedEditingException', label: t('Previous editable region'), keystroke: 'Shift+Tab' },
136
- { commandName: 'goToNextRestrictedEditingException', label: t('Next editable region'), keystroke: 'Tab' }
137
- ];
138
- }
139
- }
@@ -1,36 +0,0 @@
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
- /**
6
- * @module restricted-editing/standardeditingmode
7
- */
8
- import { Plugin } from 'ckeditor5/src/core.js';
9
- import { StandardEditingModeEditing } from './standardeditingmodeediting.js';
10
- import { StandardEditingModeUI } from './standardeditingmodeui.js';
11
- import '../theme/restrictedediting.css';
12
- /**
13
- * The standard editing mode plugin.
14
- *
15
- * This is a "glue" plugin that loads the following plugins:
16
- *
17
- * * The {@link module:restricted-editing/standardeditingmodeediting~StandardEditingModeEditing standard mode editing feature}.
18
- * * The {@link module:restricted-editing/standardeditingmodeui~StandardEditingModeUI standard mode UI feature}.
19
- */
20
- export class StandardEditingMode extends Plugin {
21
- /**
22
- * @inheritDoc
23
- */
24
- static get pluginName() {
25
- return 'StandardEditingMode';
26
- }
27
- /**
28
- * @inheritDoc
29
- */
30
- static get isOfficialPlugin() {
31
- return true;
32
- }
33
- static get requires() {
34
- return [StandardEditingModeEditing, StandardEditingModeUI];
35
- }
36
- }
@@ -1,193 +0,0 @@
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
- /**
6
- * @module restricted-editing/standardeditingmodeediting
7
- */
8
- import { Plugin } from 'ckeditor5/src/core.js';
9
- import { Matcher } from 'ckeditor5/src/engine.js';
10
- import { RestrictedEditingExceptionCommand } from './restrictededitingexceptioncommand.js';
11
- import { RestrictedEditingExceptionBlockCommand } from './restrictededitingexceptionblockcommand.js';
12
- import { RestrictedEditingExceptionAutoCommand } from './restrictededitingexceptionautocommand.js';
13
- /**
14
- * The standard editing mode editing feature.
15
- *
16
- * * It introduces the `restrictedEditingException` text attribute that is rendered as
17
- * a `<span>` element with the `restricted-editing-exception` CSS class.
18
- * * It registers the `'restrictedEditingException'` command.
19
- */
20
- export class StandardEditingModeEditing extends Plugin {
21
- /**
22
- * @inheritDoc
23
- */
24
- static get pluginName() {
25
- return 'StandardEditingModeEditing';
26
- }
27
- /**
28
- * @inheritDoc
29
- */
30
- static get isOfficialPlugin() {
31
- return true;
32
- }
33
- /**
34
- * @inheritDoc
35
- */
36
- init() {
37
- const editor = this.editor;
38
- const schema = editor.model.schema;
39
- schema.extend('$text', { allowAttributes: ['restrictedEditingException'] });
40
- schema.register('restrictedEditingException', {
41
- allowWhere: '$container',
42
- allowContentOf: '$container'
43
- });
44
- // Don't allow nesting of block exceptions.
45
- schema.addChildCheck(context => {
46
- for (const item of context) {
47
- if (item.name == 'restrictedEditingException') {
48
- return false;
49
- }
50
- }
51
- }, 'restrictedEditingException');
52
- // Don't allow nesting inline exceptions inside block exceptions.
53
- schema.addAttributeCheck(context => {
54
- for (const item of context) {
55
- if (item.name == 'restrictedEditingException') {
56
- return false;
57
- }
58
- }
59
- }, 'restrictedEditingException');
60
- // Post-fixer to ensure proper structure.
61
- editor.model.document.registerPostFixer(writer => {
62
- const changes = editor.model.document.differ.getChanges();
63
- const unwrap = new Set();
64
- const remove = new Set();
65
- const merge = new Set();
66
- let changed = false;
67
- for (const entry of changes) {
68
- if (entry.type == 'insert') {
69
- const range = writer.createRange(entry.position, entry.position.getShiftedBy(entry.length));
70
- for (const child of range.getItems()) {
71
- if (child.is('element', 'restrictedEditingException')) {
72
- // Make sure that block exception is not nested or added in invalid place.
73
- if (!schema.checkChild(writer.createPositionBefore(child), child)) {
74
- unwrap.add(child);
75
- }
76
- else if (child.isEmpty) {
77
- remove.add(child);
78
- }
79
- else {
80
- merge.add(child);
81
- }
82
- }
83
- else if (child.is('$textProxy') &&
84
- child.hasAttribute('restrictedEditingException') &&
85
- !schema.checkAttribute(child, 'restrictedEditingException')) {
86
- writer.removeAttribute('restrictedEditingException', child);
87
- changed = true;
88
- }
89
- }
90
- }
91
- else if (entry.type == 'remove') {
92
- const parent = entry.position.parent;
93
- if (parent.is('element', 'restrictedEditingException') && parent.isEmpty) {
94
- remove.add(parent);
95
- }
96
- // Verify if some block exceptions are siblings now after element removed between.
97
- for (const child of parent.getChildren()) {
98
- if (child.is('element', 'restrictedEditingException')) {
99
- merge.add(child);
100
- }
101
- }
102
- }
103
- }
104
- for (const child of unwrap) {
105
- writer.unwrap(child);
106
- changed = true;
107
- }
108
- for (const child of remove) {
109
- writer.remove(child);
110
- changed = true;
111
- }
112
- for (const child of merge) {
113
- if (child.root.rootName == '$graveyard') {
114
- continue;
115
- }
116
- const nodeBefore = child.previousSibling;
117
- const nodeAfter = child.nextSibling;
118
- if (nodeBefore && nodeBefore.is('element', 'restrictedEditingException')) {
119
- writer.merge(writer.createPositionBefore(child));
120
- }
121
- if (nodeAfter && nodeAfter.is('element', 'restrictedEditingException')) {
122
- writer.merge(writer.createPositionAfter(child));
123
- }
124
- }
125
- return changed;
126
- });
127
- editor.conversion.for('upcast')
128
- .elementToAttribute({
129
- model: 'restrictedEditingException',
130
- view: {
131
- name: 'span',
132
- classes: 'restricted-editing-exception'
133
- }
134
- })
135
- .elementToElement({
136
- model: 'restrictedEditingException',
137
- view: {
138
- name: 'div',
139
- classes: 'restricted-editing-exception'
140
- }
141
- });
142
- registerFallbackUpcastConverter(editor);
143
- editor.conversion.for('downcast')
144
- .attributeToElement({
145
- model: 'restrictedEditingException',
146
- view: (modelAttributeValue, { writer }) => {
147
- if (modelAttributeValue) {
148
- // Make the restricted editing <span> outer-most in the view.
149
- return writer.createAttributeElement('span', { class: 'restricted-editing-exception' }, { priority: -10 });
150
- }
151
- }
152
- })
153
- .elementToElement({
154
- model: 'restrictedEditingException',
155
- view: {
156
- name: 'div',
157
- classes: 'restricted-editing-exception'
158
- }
159
- });
160
- editor.commands.add('restrictedEditingException', new RestrictedEditingExceptionCommand(editor));
161
- editor.commands.add('restrictedEditingExceptionBlock', new RestrictedEditingExceptionBlockCommand(editor));
162
- editor.commands.add('restrictedEditingExceptionAuto', new RestrictedEditingExceptionAutoCommand(editor));
163
- editor.editing.view.change(writer => {
164
- for (const root of editor.editing.view.document.roots) {
165
- writer.addClass('ck-restricted-editing_mode_standard', root);
166
- }
167
- });
168
- }
169
- }
170
- /**
171
- * Fallback upcast converter for empty exception span inside a table cell.
172
- */
173
- function registerFallbackUpcastConverter(editor) {
174
- const matcher = new Matcher({ name: 'span', classes: 'restricted-editing-exception' });
175
- // See: https://github.com/ckeditor/ckeditor5/issues/16376.
176
- editor.conversion.for('upcast').add(dispatcher => dispatcher.on('element:span', (evt, data, conversionApi) => {
177
- const matcherResult = matcher.match(data.viewItem);
178
- if (!matcherResult) {
179
- return;
180
- }
181
- const match = matcherResult.match;
182
- if (!conversionApi.consumable.test(data.viewItem, match)) {
183
- return;
184
- }
185
- const modelText = conversionApi.writer.createText(' ', { restrictedEditingException: true });
186
- if (!conversionApi.safeInsert(modelText, data.modelCursor)) {
187
- return;
188
- }
189
- conversionApi.consumable.consume(data.viewItem, match);
190
- data.modelRange = conversionApi.writer.createRange(data.modelCursor, data.modelCursor.getShiftedBy(modelText.offsetSize));
191
- data.modelCursor = data.modelRange.end;
192
- }, { priority: 'low' }));
193
- }
@@ -1,150 +0,0 @@
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
- /**
6
- * @module restricted-editing/standardeditingmodeui
7
- */
8
- import { Plugin } from 'ckeditor5/src/core.js';
9
- import { IconContentUnlock } from 'ckeditor5/src/icons.js';
10
- import { ButtonView, MenuBarMenuListItemButtonView, createDropdown, addToolbarToDropdown } from 'ckeditor5/src/ui.js';
11
- /**
12
- * The standard editing mode UI feature.
13
- *
14
- * It introduces the `'restrictedEditingException'` button that marks text as unrestricted for editing.
15
- */
16
- export class StandardEditingModeUI extends Plugin {
17
- /**
18
- * @inheritDoc
19
- */
20
- static get pluginName() {
21
- return 'StandardEditingModeUI';
22
- }
23
- /**
24
- * @inheritDoc
25
- */
26
- static get isOfficialPlugin() {
27
- return true;
28
- }
29
- /**
30
- * @inheritDoc
31
- */
32
- init() {
33
- const editor = this.editor;
34
- const componentFactory = editor.ui.componentFactory;
35
- // Dropdown button with inline/block buttons.
36
- componentFactory.add('restrictedEditingException:dropdown', locale => {
37
- const dropdownView = createDropdown(locale);
38
- const t = locale.t;
39
- const buttons = [
40
- componentFactory.create('restrictedEditingException:inline'),
41
- componentFactory.create('restrictedEditingException:block')
42
- ];
43
- for (const button of buttons) {
44
- button.set({
45
- withText: true,
46
- tooltip: false
47
- });
48
- }
49
- addToolbarToDropdown(dropdownView, buttons, {
50
- enableActiveItemFocusOnDropdownOpen: true,
51
- isVertical: true,
52
- ariaLabel: t('Enable editing')
53
- });
54
- dropdownView.buttonView.set({
55
- label: t('Enable editing'),
56
- icon: IconContentUnlock,
57
- tooltip: true
58
- });
59
- dropdownView.extendTemplate({
60
- attributes: {
61
- class: 'ck-restricted-editing-dropdown'
62
- }
63
- });
64
- // Enable button if any of the buttons is enabled.
65
- dropdownView.bind('isEnabled').toMany(buttons, 'isEnabled', (...areEnabled) => {
66
- return areEnabled.some(isEnabled => isEnabled);
67
- });
68
- // Focus the editable after executing the command.
69
- this.listenTo(dropdownView, 'execute', () => {
70
- editor.editing.view.focus();
71
- });
72
- return dropdownView;
73
- });
74
- // Inline exception button.
75
- componentFactory.add('restrictedEditingException:inline', () => {
76
- const button = this._createButton('restrictedEditingException', ButtonView);
77
- button.set({
78
- tooltip: true
79
- });
80
- return button;
81
- });
82
- // Block exception button.
83
- componentFactory.add('restrictedEditingException:block', () => {
84
- const button = this._createButton('restrictedEditingExceptionBlock', ButtonView);
85
- button.set({
86
- tooltip: true
87
- });
88
- return button;
89
- });
90
- // Menu bar inline/block buttons.
91
- componentFactory.add('menuBar:restrictedEditingException:inline', () => {
92
- return this._createButton('restrictedEditingException', MenuBarMenuListItemButtonView);
93
- });
94
- componentFactory.add('menuBar:restrictedEditingException:block', () => {
95
- return this._createButton('restrictedEditingExceptionBlock', MenuBarMenuListItemButtonView);
96
- });
97
- // Auto button - triggers inline or block exception command.
98
- componentFactory.add('restrictedEditingException:auto', () => {
99
- const button = this._createButton('restrictedEditingExceptionAuto', ButtonView);
100
- button.set({
101
- tooltip: true
102
- });
103
- return button;
104
- });
105
- componentFactory.add('menuBar:restrictedEditingException:auto', () => {
106
- return this._createButton('restrictedEditingExceptionAuto', MenuBarMenuListItemButtonView);
107
- });
108
- // Aliases for backward compatibility.
109
- componentFactory.add('restrictedEditingException', () => {
110
- return componentFactory.create('restrictedEditingException:inline');
111
- });
112
- componentFactory.add('menuBar:restrictedEditingException', () => {
113
- return componentFactory.create('menuBar:restrictedEditingException:inline');
114
- });
115
- }
116
- /**
117
- * Creates a button for restricted editing exception command to use either in toolbar or in menu bar.
118
- */
119
- _createButton(commandName, ButtonClass) {
120
- const editor = this.editor;
121
- const locale = editor.locale;
122
- const command = this.editor.commands.get(commandName);
123
- const view = new ButtonClass(locale);
124
- const t = locale.t;
125
- view.icon = IconContentUnlock;
126
- view.isToggleable = true;
127
- view.bind('isOn', 'isEnabled').to(command, 'value', 'isEnabled');
128
- if (commandName == 'restrictedEditingExceptionAuto') {
129
- view.bind('label').to(command, 'value', value => {
130
- return value ? t('Disable editing') : t('Enable editing');
131
- });
132
- }
133
- else if (commandName == 'restrictedEditingExceptionBlock') {
134
- view.bind('label').to(command, 'value', value => {
135
- return value ? t('Disable block editing') : t('Enable block editing');
136
- });
137
- }
138
- else {
139
- view.bind('label').to(command, 'value', value => {
140
- return value ? t('Disable inline editing') : t('Enable inline editing');
141
- });
142
- }
143
- // Execute the command.
144
- this.listenTo(view, 'execute', () => {
145
- editor.execute(commandName);
146
- editor.editing.view.focus();
147
- });
148
- return view;
149
- }
150
- }
@@ -1,10 +0,0 @@
1
- /*
2
- * 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
-
6
- /*
7
- * Note: This file should contain the wireframe styles only. But since there are no such styles,
8
- * it acts as a message to the builder telling that it should look for the corresponding styles
9
- * **in the theme** when compiling the editor.
10
- */
File without changes
File without changes
File without changes