@ckeditor/ckeditor5-alignment 47.6.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 (168) hide show
  1. package/ckeditor5-metadata.json +2 -2
  2. package/{src → dist}/alignment.d.ts +1 -1
  3. package/{src → dist}/alignmentcommand.d.ts +1 -1
  4. package/{src → dist}/alignmentediting.d.ts +1 -1
  5. package/{src → dist}/alignmentui.d.ts +1 -1
  6. package/dist/index.css +3 -0
  7. package/dist/index.css.map +1 -0
  8. package/dist/index.js.map +1 -1
  9. package/{src → dist}/utils.d.ts +1 -1
  10. package/package.json +23 -45
  11. package/build/alignment.js +0 -5
  12. package/build/translations/af.js +0 -1
  13. package/build/translations/ar.js +0 -1
  14. package/build/translations/ast.js +0 -1
  15. package/build/translations/az.js +0 -1
  16. package/build/translations/be.js +0 -1
  17. package/build/translations/bg.js +0 -1
  18. package/build/translations/bn.js +0 -1
  19. package/build/translations/bs.js +0 -1
  20. package/build/translations/ca.js +0 -1
  21. package/build/translations/cs.js +0 -1
  22. package/build/translations/da.js +0 -1
  23. package/build/translations/de-ch.js +0 -1
  24. package/build/translations/de.js +0 -1
  25. package/build/translations/el.js +0 -1
  26. package/build/translations/en-au.js +0 -1
  27. package/build/translations/en-gb.js +0 -1
  28. package/build/translations/eo.js +0 -1
  29. package/build/translations/es-co.js +0 -1
  30. package/build/translations/es.js +0 -1
  31. package/build/translations/et.js +0 -1
  32. package/build/translations/eu.js +0 -1
  33. package/build/translations/fa.js +0 -1
  34. package/build/translations/fi.js +0 -1
  35. package/build/translations/fr.js +0 -1
  36. package/build/translations/gl.js +0 -1
  37. package/build/translations/gu.js +0 -1
  38. package/build/translations/he.js +0 -1
  39. package/build/translations/hi.js +0 -1
  40. package/build/translations/hr.js +0 -1
  41. package/build/translations/hu.js +0 -1
  42. package/build/translations/hy.js +0 -1
  43. package/build/translations/id.js +0 -1
  44. package/build/translations/it.js +0 -1
  45. package/build/translations/ja.js +0 -1
  46. package/build/translations/jv.js +0 -1
  47. package/build/translations/kk.js +0 -1
  48. package/build/translations/km.js +0 -1
  49. package/build/translations/kn.js +0 -1
  50. package/build/translations/ko.js +0 -1
  51. package/build/translations/ku.js +0 -1
  52. package/build/translations/lt.js +0 -1
  53. package/build/translations/lv.js +0 -1
  54. package/build/translations/ms.js +0 -1
  55. package/build/translations/nb.js +0 -1
  56. package/build/translations/ne.js +0 -1
  57. package/build/translations/nl.js +0 -1
  58. package/build/translations/no.js +0 -1
  59. package/build/translations/oc.js +0 -1
  60. package/build/translations/pl.js +0 -1
  61. package/build/translations/pt-br.js +0 -1
  62. package/build/translations/pt.js +0 -1
  63. package/build/translations/ro.js +0 -1
  64. package/build/translations/ru.js +0 -1
  65. package/build/translations/si.js +0 -1
  66. package/build/translations/sk.js +0 -1
  67. package/build/translations/sl.js +0 -1
  68. package/build/translations/sq.js +0 -1
  69. package/build/translations/sr-latn.js +0 -1
  70. package/build/translations/sr.js +0 -1
  71. package/build/translations/sv.js +0 -1
  72. package/build/translations/th.js +0 -1
  73. package/build/translations/ti.js +0 -1
  74. package/build/translations/tk.js +0 -1
  75. package/build/translations/tr.js +0 -1
  76. package/build/translations/tt.js +0 -1
  77. package/build/translations/ug.js +0 -1
  78. package/build/translations/uk.js +0 -1
  79. package/build/translations/ur.js +0 -1
  80. package/build/translations/uz.js +0 -1
  81. package/build/translations/vi.js +0 -1
  82. package/build/translations/zh-cn.js +0 -1
  83. package/build/translations/zh.js +0 -1
  84. package/lang/contexts.json +0 -8
  85. package/lang/translations/af.po +0 -36
  86. package/lang/translations/ar.po +0 -36
  87. package/lang/translations/ast.po +0 -36
  88. package/lang/translations/az.po +0 -36
  89. package/lang/translations/be.po +0 -36
  90. package/lang/translations/bg.po +0 -36
  91. package/lang/translations/bn.po +0 -36
  92. package/lang/translations/bs.po +0 -36
  93. package/lang/translations/ca.po +0 -36
  94. package/lang/translations/cs.po +0 -36
  95. package/lang/translations/da.po +0 -36
  96. package/lang/translations/de-ch.po +0 -36
  97. package/lang/translations/de.po +0 -36
  98. package/lang/translations/el.po +0 -36
  99. package/lang/translations/en-au.po +0 -36
  100. package/lang/translations/en-gb.po +0 -36
  101. package/lang/translations/en.po +0 -36
  102. package/lang/translations/eo.po +0 -36
  103. package/lang/translations/es-co.po +0 -36
  104. package/lang/translations/es.po +0 -36
  105. package/lang/translations/et.po +0 -36
  106. package/lang/translations/eu.po +0 -36
  107. package/lang/translations/fa.po +0 -36
  108. package/lang/translations/fi.po +0 -36
  109. package/lang/translations/fr.po +0 -36
  110. package/lang/translations/gl.po +0 -36
  111. package/lang/translations/gu.po +0 -36
  112. package/lang/translations/he.po +0 -36
  113. package/lang/translations/hi.po +0 -36
  114. package/lang/translations/hr.po +0 -36
  115. package/lang/translations/hu.po +0 -36
  116. package/lang/translations/hy.po +0 -36
  117. package/lang/translations/id.po +0 -36
  118. package/lang/translations/it.po +0 -36
  119. package/lang/translations/ja.po +0 -36
  120. package/lang/translations/jv.po +0 -36
  121. package/lang/translations/kk.po +0 -36
  122. package/lang/translations/km.po +0 -36
  123. package/lang/translations/kn.po +0 -36
  124. package/lang/translations/ko.po +0 -36
  125. package/lang/translations/ku.po +0 -36
  126. package/lang/translations/lt.po +0 -36
  127. package/lang/translations/lv.po +0 -36
  128. package/lang/translations/ms.po +0 -36
  129. package/lang/translations/nb.po +0 -36
  130. package/lang/translations/ne.po +0 -36
  131. package/lang/translations/nl.po +0 -36
  132. package/lang/translations/no.po +0 -36
  133. package/lang/translations/oc.po +0 -36
  134. package/lang/translations/pl.po +0 -36
  135. package/lang/translations/pt-br.po +0 -36
  136. package/lang/translations/pt.po +0 -36
  137. package/lang/translations/ro.po +0 -36
  138. package/lang/translations/ru.po +0 -36
  139. package/lang/translations/si.po +0 -36
  140. package/lang/translations/sk.po +0 -36
  141. package/lang/translations/sl.po +0 -36
  142. package/lang/translations/sq.po +0 -36
  143. package/lang/translations/sr-latn.po +0 -36
  144. package/lang/translations/sr.po +0 -36
  145. package/lang/translations/sv.po +0 -36
  146. package/lang/translations/th.po +0 -36
  147. package/lang/translations/ti.po +0 -36
  148. package/lang/translations/tk.po +0 -36
  149. package/lang/translations/tr.po +0 -36
  150. package/lang/translations/tt.po +0 -36
  151. package/lang/translations/ug.po +0 -36
  152. package/lang/translations/uk.po +0 -36
  153. package/lang/translations/ur.po +0 -36
  154. package/lang/translations/uz.po +0 -36
  155. package/lang/translations/vi.po +0 -36
  156. package/lang/translations/zh-cn.po +0 -36
  157. package/lang/translations/zh.po +0 -36
  158. package/src/alignment.js +0 -39
  159. package/src/alignmentcommand.js +0 -88
  160. package/src/alignmentconfig.js +0 -5
  161. package/src/alignmentediting.js +0 -153
  162. package/src/alignmentui.js +0 -195
  163. package/src/augmentation.js +0 -5
  164. package/src/index.js +0 -13
  165. package/src/utils.js +0 -123
  166. /package/{src → dist}/alignmentconfig.d.ts +0 -0
  167. /package/{src → dist}/augmentation.d.ts +0 -0
  168. /package/{src → dist}/index.d.ts +0 -0
@@ -1,88 +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 alignment/alignmentcommand
7
- */
8
- import { Command } from 'ckeditor5/src/core.js';
9
- import { first } from 'ckeditor5/src/utils.js';
10
- import { isDefault } from './utils.js';
11
- const ALIGNMENT = 'alignment';
12
- /**
13
- * The alignment command plugin.
14
- */
15
- export class AlignmentCommand extends Command {
16
- /**
17
- * @inheritDoc
18
- */
19
- refresh() {
20
- const editor = this.editor;
21
- const locale = editor.locale;
22
- const firstBlock = first(this.editor.model.document.selection.getSelectedBlocks());
23
- // As first check whether to enable or disable the command as the value will always be false if the command cannot be enabled.
24
- this.isEnabled = Boolean(firstBlock) && this._canBeAligned(firstBlock);
25
- if (this.isEnabled && firstBlock.hasAttribute('alignment')) {
26
- this.value = firstBlock.getAttribute('alignment');
27
- }
28
- else {
29
- this.value = locale.contentLanguageDirection === 'rtl' ? 'right' : 'left';
30
- }
31
- }
32
- /**
33
- * Executes the command. Applies the alignment `value` to the selected blocks.
34
- * If no `value` is passed, the `value` is the default one or it is equal to the currently selected block's alignment attribute,
35
- * the command will remove the attribute from the selected blocks.
36
- *
37
- * @param options Options for the executed command.
38
- * @param options.value The value to apply.
39
- * @fires execute
40
- */
41
- execute(options = {}) {
42
- const editor = this.editor;
43
- const locale = editor.locale;
44
- const model = editor.model;
45
- const doc = model.document;
46
- const value = options.value;
47
- model.change(writer => {
48
- // Get only those blocks from selected that can have alignment set
49
- const blocks = Array.from(doc.selection.getSelectedBlocks()).filter(block => this._canBeAligned(block));
50
- const currentAlignment = blocks[0].getAttribute('alignment');
51
- // Remove alignment attribute if current alignment is:
52
- // - default (should not be stored in model as it will bloat model data)
53
- // - equal to currently set
54
- // - or no value is passed - denotes default alignment.
55
- const removeAlignment = isDefault(value, locale) || currentAlignment === value || !value;
56
- if (removeAlignment) {
57
- removeAlignmentFromSelection(blocks, writer);
58
- }
59
- else {
60
- setAlignmentOnSelection(blocks, writer, value);
61
- }
62
- });
63
- }
64
- /**
65
- * Checks whether a block can have alignment set.
66
- *
67
- * @param block The block to be checked.
68
- */
69
- _canBeAligned(block) {
70
- return this.editor.model.schema.checkAttribute(block, ALIGNMENT);
71
- }
72
- }
73
- /**
74
- * Removes the alignment attribute from blocks.
75
- */
76
- function removeAlignmentFromSelection(blocks, writer) {
77
- for (const block of blocks) {
78
- writer.removeAttribute(ALIGNMENT, block);
79
- }
80
- }
81
- /**
82
- * Sets the alignment attribute on blocks.
83
- */
84
- function setAlignmentOnSelection(blocks, writer, alignment) {
85
- for (const block of blocks) {
86
- writer.setAttribute(ALIGNMENT, alignment, block);
87
- }
88
- }
@@ -1,5 +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
- export {};
@@ -1,153 +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 alignment/alignmentediting
7
- */
8
- import { Plugin } from 'ckeditor5/src/core.js';
9
- import { AlignmentCommand } from './alignmentcommand.js';
10
- import { isDefault, isSupported, normalizeAlignmentOptions, supportedOptions } from './utils.js';
11
- /**
12
- * The alignment editing feature. It introduces the {@link module:alignment/alignmentcommand~AlignmentCommand command} and adds
13
- * the `alignment` attribute for block elements in the {@link module:engine/model/model~Model model}.
14
- */
15
- export class AlignmentEditing extends Plugin {
16
- /**
17
- * @inheritDoc
18
- */
19
- static get pluginName() {
20
- return 'AlignmentEditing';
21
- }
22
- /**
23
- * @inheritDoc
24
- */
25
- static get isOfficialPlugin() {
26
- return true;
27
- }
28
- /**
29
- * @inheritDoc
30
- */
31
- constructor(editor) {
32
- super(editor);
33
- editor.config.define('alignment', {
34
- options: supportedOptions.map(option => ({ name: option }))
35
- });
36
- }
37
- /**
38
- * @inheritDoc
39
- */
40
- init() {
41
- const editor = this.editor;
42
- const locale = editor.locale;
43
- const schema = editor.model.schema;
44
- const options = normalizeAlignmentOptions(editor.config.get('alignment.options'));
45
- // Filter out unsupported options and those that are redundant, e.g. `left` in LTR / `right` in RTL mode.
46
- const optionsToConvert = options.filter(option => isSupported(option.name) && !isDefault(option.name, locale));
47
- // Once there is at least one `className` defined, we switch to alignment with classes.
48
- const shouldUseClasses = optionsToConvert.some(option => !!option.className);
49
- // Allow alignment attribute on all blocks.
50
- schema.extend('$block', { allowAttributes: 'alignment' });
51
- editor.model.schema.setAttributeProperties('alignment', { isFormatting: true });
52
- if (shouldUseClasses) {
53
- editor.conversion.attributeToAttribute(buildClassDefinition(optionsToConvert));
54
- }
55
- else {
56
- // Downcast inline styles.
57
- editor.conversion.for('downcast').attributeToAttribute(buildDowncastInlineDefinition(optionsToConvert));
58
- }
59
- const upcastInlineDefinitions = buildUpcastInlineDefinitions(optionsToConvert);
60
- // Always upcast from inline styles.
61
- for (const definition of upcastInlineDefinitions) {
62
- editor.conversion.for('upcast').attributeToAttribute(definition);
63
- }
64
- const upcastCompatibilityDefinitions = buildUpcastCompatibilityDefinitions(optionsToConvert);
65
- // Always upcast from deprecated `align` attribute.
66
- for (const definition of upcastCompatibilityDefinitions) {
67
- editor.conversion.for('upcast').attributeToAttribute(definition);
68
- }
69
- editor.commands.add('alignment', new AlignmentCommand(editor));
70
- }
71
- }
72
- /**
73
- * Prepare downcast conversion definition for inline alignment styling.
74
- */
75
- function buildDowncastInlineDefinition(options) {
76
- const view = {};
77
- for (const { name } of options) {
78
- view[name] = {
79
- key: 'style',
80
- value: {
81
- 'text-align': name
82
- }
83
- };
84
- }
85
- const definition = {
86
- model: {
87
- key: 'alignment',
88
- values: options.map(option => option.name)
89
- },
90
- view
91
- };
92
- return definition;
93
- }
94
- /**
95
- * Prepare upcast definitions for inline alignment styles.
96
- */
97
- function buildUpcastInlineDefinitions(options) {
98
- const definitions = [];
99
- for (const { name } of options) {
100
- definitions.push({
101
- view: {
102
- key: 'style',
103
- value: {
104
- 'text-align': name
105
- }
106
- },
107
- model: {
108
- key: 'alignment',
109
- value: name
110
- }
111
- });
112
- }
113
- return definitions;
114
- }
115
- /**
116
- * Prepare upcast definitions for deprecated `align` attribute.
117
- */
118
- function buildUpcastCompatibilityDefinitions(options) {
119
- const definitions = [];
120
- for (const { name } of options) {
121
- definitions.push({
122
- view: {
123
- key: 'align',
124
- value: name
125
- },
126
- model: {
127
- key: 'alignment',
128
- value: name
129
- }
130
- });
131
- }
132
- return definitions;
133
- }
134
- /**
135
- * Prepare conversion definitions for upcast and downcast alignment with classes.
136
- */
137
- function buildClassDefinition(options) {
138
- const view = {};
139
- for (const option of options) {
140
- view[option.name] = {
141
- key: 'class',
142
- value: option.className
143
- };
144
- }
145
- const definition = {
146
- model: {
147
- key: 'alignment',
148
- values: options.map(option => option.name)
149
- },
150
- view
151
- };
152
- return definition;
153
- }
@@ -1,195 +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 alignment/alignmentui
7
- */
8
- import { Plugin } from 'ckeditor5/src/core.js';
9
- import { ButtonView, createDropdown, addToolbarToDropdown, MenuBarMenuListItemView, MenuBarMenuListItemButtonView, MenuBarMenuView, MenuBarMenuListView } from 'ckeditor5/src/ui.js';
10
- import { IconAlignCenter, IconAlignJustify, IconAlignLeft, IconAlignRight } from 'ckeditor5/src/icons.js';
11
- import { isSupported, normalizeAlignmentOptions } from './utils.js';
12
- const iconsMap = /* #__PURE__ */ (() => new Map([
13
- ['left', IconAlignLeft],
14
- ['right', IconAlignRight],
15
- ['center', IconAlignCenter],
16
- ['justify', IconAlignJustify]
17
- ]))();
18
- /**
19
- * The default alignment UI plugin.
20
- *
21
- * It introduces the `'alignment:left'`, `'alignment:right'`, `'alignment:center'` and `'alignment:justify'` buttons
22
- * and the `'alignment'` dropdown.
23
- */
24
- export class AlignmentUI extends Plugin {
25
- /**
26
- * Returns the localized option titles provided by the plugin.
27
- *
28
- * The following localized titles corresponding with
29
- * {@link module:alignment/alignmentconfig~AlignmentConfig#options} are available:
30
- *
31
- * * `'left'`,
32
- * * `'right'`,
33
- * * `'center'`,
34
- * * `'justify'`.
35
- *
36
- * @readonly
37
- */
38
- get localizedOptionTitles() {
39
- const t = this.editor.t;
40
- return {
41
- 'left': t('Align left'),
42
- 'right': t('Align right'),
43
- 'center': t('Align center'),
44
- 'justify': t('Justify')
45
- };
46
- }
47
- /**
48
- * @inheritDoc
49
- */
50
- static get pluginName() {
51
- return 'AlignmentUI';
52
- }
53
- /**
54
- * @inheritDoc
55
- */
56
- static get isOfficialPlugin() {
57
- return true;
58
- }
59
- /**
60
- * @inheritDoc
61
- */
62
- init() {
63
- const editor = this.editor;
64
- const options = normalizeAlignmentOptions(editor.config.get('alignment.options'));
65
- options
66
- .map(option => option.name)
67
- .filter(isSupported)
68
- .forEach(option => this._addButton(option));
69
- this._addToolbarDropdown(options);
70
- this._addMenuBarMenu(options);
71
- }
72
- /**
73
- * Helper method for initializing the button and linking it with an appropriate command.
74
- *
75
- * @param option The name of the alignment option for which the button is added.
76
- */
77
- _addButton(option) {
78
- const editor = this.editor;
79
- editor.ui.componentFactory.add(`alignment:${option}`, locale => this._createButton(locale, option));
80
- }
81
- /**
82
- * Helper method for creating the button view element.
83
- *
84
- * @param locale Editor locale.
85
- * @param option The name of the alignment option for which the button is added.
86
- * @param buttonAttrs Optional parameters passed to button view instance.
87
- */
88
- _createButton(locale, option, buttonAttrs = {}) {
89
- const editor = this.editor;
90
- const command = editor.commands.get('alignment');
91
- const buttonView = new ButtonView(locale);
92
- buttonView.set({
93
- label: this.localizedOptionTitles[option],
94
- icon: iconsMap.get(option),
95
- tooltip: true,
96
- isToggleable: true,
97
- ...buttonAttrs
98
- });
99
- // Bind button model to command.
100
- buttonView.bind('isEnabled').to(command);
101
- buttonView.bind('isOn').to(command, 'value', value => value === option);
102
- // Execute command.
103
- this.listenTo(buttonView, 'execute', () => {
104
- editor.execute('alignment', { value: option });
105
- editor.editing.view.focus();
106
- });
107
- return buttonView;
108
- }
109
- /**
110
- * Helper method for initializing the toolnar dropdown and linking it with an appropriate command.
111
- *
112
- * @param options The name of the alignment option for which the button is added.
113
- */
114
- _addToolbarDropdown(options) {
115
- const editor = this.editor;
116
- const factory = editor.ui.componentFactory;
117
- factory.add('alignment', locale => {
118
- const dropdownView = createDropdown(locale);
119
- const tooltipPosition = locale.uiLanguageDirection === 'rtl' ? 'w' : 'e';
120
- const t = locale.t;
121
- // Add existing alignment buttons to dropdown's toolbar.
122
- addToolbarToDropdown(dropdownView, () => options.map(option => this._createButton(locale, option.name, { tooltipPosition })), {
123
- enableActiveItemFocusOnDropdownOpen: true,
124
- isVertical: true,
125
- ariaLabel: t('Text alignment toolbar')
126
- });
127
- // Configure dropdown properties an behavior.
128
- dropdownView.buttonView.set({
129
- label: t('Text alignment'),
130
- tooltip: true
131
- });
132
- dropdownView.extendTemplate({
133
- attributes: {
134
- class: 'ck-alignment-dropdown'
135
- }
136
- });
137
- // The default icon depends on the direction of the content.
138
- const defaultIcon = locale.contentLanguageDirection === 'rtl' ? iconsMap.get('right') : iconsMap.get('left');
139
- const command = editor.commands.get('alignment');
140
- // Change icon to reflect current selection's alignment.
141
- dropdownView.buttonView.bind('icon').to(command, 'value', value => iconsMap.get(value) || defaultIcon);
142
- // Enable button if any of the buttons is enabled.
143
- dropdownView.bind('isEnabled').to(command, 'isEnabled');
144
- // Focus the editable after executing the command.
145
- // Overrides a default behaviour where the focus is moved to the dropdown button (#12125).
146
- this.listenTo(dropdownView, 'execute', () => {
147
- editor.editing.view.focus();
148
- });
149
- return dropdownView;
150
- });
151
- }
152
- /**
153
- * Creates a menu for all alignment options to use either in menu bar.
154
- *
155
- * @param options Normalized alignment options from config.
156
- */
157
- _addMenuBarMenu(options) {
158
- const editor = this.editor;
159
- editor.ui.componentFactory.add('menuBar:alignment', locale => {
160
- const command = editor.commands.get('alignment');
161
- const t = locale.t;
162
- const menuView = new MenuBarMenuView(locale);
163
- const listView = new MenuBarMenuListView(locale);
164
- menuView.bind('isEnabled').to(command);
165
- listView.set({
166
- ariaLabel: t('Text alignment'),
167
- role: 'menu'
168
- });
169
- menuView.buttonView.set({
170
- label: t('Text alignment')
171
- });
172
- for (const option of options) {
173
- const listItemView = new MenuBarMenuListItemView(locale, menuView);
174
- const buttonView = new MenuBarMenuListItemButtonView(locale);
175
- buttonView.delegate('execute').to(menuView);
176
- buttonView.set({
177
- label: this.localizedOptionTitles[option.name],
178
- icon: iconsMap.get(option.name),
179
- role: 'menuitemcheckbox',
180
- isToggleable: true
181
- });
182
- buttonView.on('execute', () => {
183
- editor.execute('alignment', { value: option.name });
184
- editor.editing.view.focus();
185
- });
186
- buttonView.bind('isOn').to(command, 'value', value => value === option.name);
187
- buttonView.bind('isEnabled').to(command, 'isEnabled');
188
- listItemView.children.add(buttonView);
189
- listView.items.add(listItemView);
190
- }
191
- menuView.panelView.children.add(listView);
192
- return menuView;
193
- });
194
- }
195
- }
@@ -1,5 +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
- export {};
package/src/index.js DELETED
@@ -1,13 +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 alignment
7
- */
8
- export { Alignment } from './alignment.js';
9
- export { AlignmentEditing } from './alignmentediting.js';
10
- export { AlignmentUI } from './alignmentui.js';
11
- export { AlignmentCommand } from './alignmentcommand.js';
12
- export { supportedOptions as _ALIGNMENT_SUPPORTED_OPTIONS, isSupported as _isAlignmentSupported, isDefault as _isDefaultAlignment, normalizeAlignmentOptions as _normalizeAlignmentOptions } from './utils.js';
13
- import './augmentation.js';
package/src/utils.js DELETED
@@ -1,123 +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
- import { CKEditorError, logWarning } from 'ckeditor5/src/utils.js';
6
- /**
7
- * @module alignment/utils
8
- */
9
- /**
10
- * The list of supported alignment options:
11
- *
12
- * * `'left'`,
13
- * * `'right'`,
14
- * * `'center'`,
15
- * * `'justify'`
16
- *
17
- * @internal
18
- */
19
- export const supportedOptions = ['left', 'right', 'center', 'justify'];
20
- /**
21
- * Checks whether the passed option is supported by {@link module:alignment/alignmentediting~AlignmentEditing}.
22
- *
23
- * @internal
24
- * @param option The option value to check.
25
- */
26
- export function isSupported(option) {
27
- return supportedOptions.includes(option);
28
- }
29
- /**
30
- * Checks whether alignment is the default one considering the direction
31
- * of the editor content.
32
- *
33
- * @internal
34
- * @param alignment The name of the alignment to check.
35
- * @param locale The {@link module:core/editor/editor~Editor#locale} instance.
36
- */
37
- export function isDefault(alignment, locale) {
38
- // Right now only LTR is supported so the 'left' value is always the default one.
39
- if (locale.contentLanguageDirection == 'rtl') {
40
- return alignment === 'right';
41
- }
42
- else {
43
- return alignment === 'left';
44
- }
45
- }
46
- /**
47
- * Brings the configuration to the common form, an array of objects.
48
- *
49
- * @internal
50
- * @param configuredOptions Alignment plugin configuration.
51
- * @returns Normalized object holding the configuration.
52
- */
53
- export function normalizeAlignmentOptions(configuredOptions) {
54
- const normalizedOptions = configuredOptions
55
- .map(option => {
56
- let result;
57
- if (typeof option == 'string') {
58
- result = { name: option };
59
- }
60
- else {
61
- result = option;
62
- }
63
- return result;
64
- })
65
- // Remove all unknown options.
66
- .filter(option => {
67
- const isNameValid = supportedOptions.includes(option.name);
68
- if (!isNameValid) {
69
- /**
70
- * The `name` in one of the `alignment.options` is not recognized.
71
- * The available options are: `'left'`, `'right'`, `'center'` and `'justify'`.
72
- *
73
- * @error alignment-config-name-not-recognized
74
- * @param {object} option Options with unknown value of the `name` property.
75
- */
76
- logWarning('alignment-config-name-not-recognized', { option });
77
- }
78
- return isNameValid;
79
- });
80
- const classNameCount = normalizedOptions.filter(option => Boolean(option.className)).length;
81
- // We either use classes for all styling options or for none.
82
- if (classNameCount && classNameCount < normalizedOptions.length) {
83
- /**
84
- * The `className` property has to be defined for all options once at least one option declares `className`.
85
- *
86
- * @error alignment-config-classnames-are-missing
87
- * @param {object} configuredOptions Contents of `alignment.options`.
88
- */
89
- throw new CKEditorError('alignment-config-classnames-are-missing', { configuredOptions });
90
- }
91
- // Validate resulting config.
92
- normalizedOptions.forEach((option, index, allOptions) => {
93
- const succeedingOptions = allOptions.slice(index + 1);
94
- const nameAlreadyExists = succeedingOptions.some(item => item.name == option.name);
95
- if (nameAlreadyExists) {
96
- /**
97
- * The same `name` in one of the `alignment.options` was already declared.
98
- * Each `name` representing one alignment option can be set exactly once.
99
- *
100
- * @error alignment-config-name-already-defined
101
- * @param {object} option First option that declares given `name`.
102
- * @param {object} configuredOptions Contents of `alignment.options`.
103
- */
104
- throw new CKEditorError('alignment-config-name-already-defined', { option, configuredOptions });
105
- }
106
- // The `className` property is present. Check for duplicates then.
107
- if (option.className) {
108
- const classNameAlreadyExists = succeedingOptions.some(item => item.className == option.className);
109
- if (classNameAlreadyExists) {
110
- /**
111
- * The same `className` in one of the `alignment.options` was already declared.
112
- *
113
- * @error alignment-config-classname-already-defined
114
- * @param {object} option First option that declares given `className`.
115
- * @param {object} configuredOptions
116
- * Contents of `alignment.options`.
117
- */
118
- throw new CKEditorError('alignment-config-classname-already-defined', { option, configuredOptions });
119
- }
120
- }
121
- });
122
- return normalizedOptions;
123
- }
File without changes
File without changes
File without changes