@ckeditor/ckeditor5-basic-styles 38.1.1 → 38.2.0-alpha.1

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 (50) hide show
  1. package/package.json +3 -2
  2. package/src/attributecommand.d.ts +74 -74
  3. package/src/attributecommand.js +105 -105
  4. package/src/augmentation.d.ts +40 -40
  5. package/src/augmentation.js +5 -5
  6. package/src/bold/boldediting.d.ts +24 -24
  7. package/src/bold/boldediting.js +62 -62
  8. package/src/bold/boldui.d.ts +21 -21
  9. package/src/bold/boldui.js +47 -47
  10. package/src/bold.d.ts +29 -29
  11. package/src/bold.js +33 -33
  12. package/src/code/codeediting.d.ts +29 -29
  13. package/src/code/codeediting.js +59 -59
  14. package/src/code/codeui.d.ts +22 -22
  15. package/src/code/codeui.js +48 -48
  16. package/src/code.d.ts +30 -30
  17. package/src/code.js +34 -34
  18. package/src/index.d.ts +30 -30
  19. package/src/index.js +29 -29
  20. package/src/italic/italicediting.d.ts +24 -24
  21. package/src/italic/italicediting.js +52 -52
  22. package/src/italic/italicui.d.ts +21 -21
  23. package/src/italic/italicui.js +48 -48
  24. package/src/italic.d.ts +29 -29
  25. package/src/italic.js +33 -33
  26. package/src/strikethrough/strikethroughediting.d.ts +25 -25
  27. package/src/strikethrough/strikethroughediting.js +54 -54
  28. package/src/strikethrough/strikethroughui.d.ts +21 -21
  29. package/src/strikethrough/strikethroughui.js +48 -48
  30. package/src/strikethrough.d.ts +29 -29
  31. package/src/strikethrough.js +33 -33
  32. package/src/subscript/subscriptediting.d.ts +24 -24
  33. package/src/subscript/subscriptediting.js +50 -50
  34. package/src/subscript/subscriptui.d.ts +21 -21
  35. package/src/subscript/subscriptui.js +47 -47
  36. package/src/subscript.d.ts +26 -26
  37. package/src/subscript.js +30 -30
  38. package/src/superscript/superscriptediting.d.ts +24 -24
  39. package/src/superscript/superscriptediting.js +50 -50
  40. package/src/superscript/superscriptui.d.ts +21 -21
  41. package/src/superscript/superscriptui.js +47 -47
  42. package/src/superscript.d.ts +26 -26
  43. package/src/superscript.js +30 -30
  44. package/src/underline/underlineediting.d.ts +24 -24
  45. package/src/underline/underlineediting.js +49 -49
  46. package/src/underline/underlineui.d.ts +21 -21
  47. package/src/underline/underlineui.js +48 -48
  48. package/src/underline.d.ts +29 -29
  49. package/src/underline.js +33 -33
  50. package/build/basic-styles.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-basic-styles",
3
- "version": "38.1.1",
3
+ "version": "38.2.0-alpha.1",
4
4
  "description": "Basic styles feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -11,8 +11,9 @@
11
11
  "ckeditor5-dll"
12
12
  ],
13
13
  "main": "src/index.js",
14
+ "type": "module",
14
15
  "dependencies": {
15
- "ckeditor5": "38.1.1"
16
+ "ckeditor5": "38.2.0-alpha.1"
16
17
  },
17
18
  "engines": {
18
19
  "node": ">=16.0.0",
@@ -1,74 +1,74 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module basic-styles/attributecommand
7
- */
8
- import { Command, type Editor } from 'ckeditor5/src/core';
9
- /**
10
- * An extension of the base {@link module:core/command~Command} class, which provides utilities for a command
11
- * that toggles a single attribute on a text or an element.
12
- *
13
- * `AttributeCommand` uses {@link module:engine/model/document~Document#selection}
14
- * to decide which nodes (if any) should be changed, and applies or removes the attribute from them.
15
- *
16
- * The command checks the {@link module:engine/model/model~Model#schema} to decide if it can be enabled
17
- * for the current selection and to which nodes the attribute can be applied.
18
- */
19
- export default class AttributeCommand extends Command {
20
- /**
21
- * Flag indicating whether the command is active. The command is active when the
22
- * {@link module:engine/model/selection~Selection#hasAttribute selection has the attribute} which means that:
23
- *
24
- * * If the selection is not empty – That the attribute is set on the first node in the selection that allows this attribute.
25
- * * If the selection is empty – That the selection has the attribute itself (which means that newly typed
26
- * text will have this attribute, too).
27
- *
28
- * @observable
29
- * @readonly
30
- */
31
- value: boolean;
32
- /**
33
- * The attribute that will be set by the command.
34
- */
35
- readonly attributeKey: string;
36
- /**
37
- * @param attributeKey Attribute that will be set by the command.
38
- */
39
- constructor(editor: Editor, attributeKey: string);
40
- /**
41
- * Updates the command's {@link #value} and {@link #isEnabled} based on the current selection.
42
- */
43
- refresh(): void;
44
- /**
45
- * Executes the command — applies the attribute to the selection or removes it from the selection.
46
- *
47
- * If the command is active (`value == true`), it will remove attributes. Otherwise, it will set attributes.
48
- *
49
- * The execution result differs, depending on the {@link module:engine/model/document~Document#selection}:
50
- *
51
- * * If the selection is on a range, the command applies the attribute to all nodes in that range
52
- * (if they are allowed to have this attribute by the {@link module:engine/model/schema~Schema schema}).
53
- * * If the selection is collapsed in a non-empty node, the command applies the attribute to the
54
- * {@link module:engine/model/document~Document#selection} itself (note that typed characters copy attributes from the selection).
55
- * * If the selection is collapsed in an empty node, the command applies the attribute to the parent node of the selection (note
56
- * that the selection inherits all attributes from a node if it is in an empty node).
57
- *
58
- * @fires execute
59
- * @param options Command options.
60
- * @param options.forceValue If set, it will force the command behavior. If `true`,
61
- * the command will apply the attribute, otherwise the command will remove the attribute.
62
- * If not set, the command will look for its current value to decide what it should do.
63
- */
64
- execute(options?: {
65
- forceValue?: boolean;
66
- }): void;
67
- /**
68
- * Checks the attribute value of the first node in the selection that allows the attribute.
69
- * For the collapsed selection returns the selection attribute.
70
- *
71
- * @returns The attribute value.
72
- */
73
- private _getValueFromFirstAllowedNode;
74
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module basic-styles/attributecommand
7
+ */
8
+ import { Command, type Editor } from 'ckeditor5/src/core.js';
9
+ /**
10
+ * An extension of the base {@link module:core/command~Command} class, which provides utilities for a command
11
+ * that toggles a single attribute on a text or an element.
12
+ *
13
+ * `AttributeCommand` uses {@link module:engine/model/document~Document#selection}
14
+ * to decide which nodes (if any) should be changed, and applies or removes the attribute from them.
15
+ *
16
+ * The command checks the {@link module:engine/model/model~Model#schema} to decide if it can be enabled
17
+ * for the current selection and to which nodes the attribute can be applied.
18
+ */
19
+ export default class AttributeCommand extends Command {
20
+ /**
21
+ * Flag indicating whether the command is active. The command is active when the
22
+ * {@link module:engine/model/selection~Selection#hasAttribute selection has the attribute} which means that:
23
+ *
24
+ * * If the selection is not empty – That the attribute is set on the first node in the selection that allows this attribute.
25
+ * * If the selection is empty – That the selection has the attribute itself (which means that newly typed
26
+ * text will have this attribute, too).
27
+ *
28
+ * @observable
29
+ * @readonly
30
+ */
31
+ value: boolean;
32
+ /**
33
+ * The attribute that will be set by the command.
34
+ */
35
+ readonly attributeKey: string;
36
+ /**
37
+ * @param attributeKey Attribute that will be set by the command.
38
+ */
39
+ constructor(editor: Editor, attributeKey: string);
40
+ /**
41
+ * Updates the command's {@link #value} and {@link #isEnabled} based on the current selection.
42
+ */
43
+ refresh(): void;
44
+ /**
45
+ * Executes the command — applies the attribute to the selection or removes it from the selection.
46
+ *
47
+ * If the command is active (`value == true`), it will remove attributes. Otherwise, it will set attributes.
48
+ *
49
+ * The execution result differs, depending on the {@link module:engine/model/document~Document#selection}:
50
+ *
51
+ * * If the selection is on a range, the command applies the attribute to all nodes in that range
52
+ * (if they are allowed to have this attribute by the {@link module:engine/model/schema~Schema schema}).
53
+ * * If the selection is collapsed in a non-empty node, the command applies the attribute to the
54
+ * {@link module:engine/model/document~Document#selection} itself (note that typed characters copy attributes from the selection).
55
+ * * If the selection is collapsed in an empty node, the command applies the attribute to the parent node of the selection (note
56
+ * that the selection inherits all attributes from a node if it is in an empty node).
57
+ *
58
+ * @fires execute
59
+ * @param options Command options.
60
+ * @param options.forceValue If set, it will force the command behavior. If `true`,
61
+ * the command will apply the attribute, otherwise the command will remove the attribute.
62
+ * If not set, the command will look for its current value to decide what it should do.
63
+ */
64
+ execute(options?: {
65
+ forceValue?: boolean;
66
+ }): void;
67
+ /**
68
+ * Checks the attribute value of the first node in the selection that allows the attribute.
69
+ * For the collapsed selection returns the selection attribute.
70
+ *
71
+ * @returns The attribute value.
72
+ */
73
+ private _getValueFromFirstAllowedNode;
74
+ }
@@ -1,105 +1,105 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module basic-styles/attributecommand
7
- */
8
- import { Command } from 'ckeditor5/src/core';
9
- /**
10
- * An extension of the base {@link module:core/command~Command} class, which provides utilities for a command
11
- * that toggles a single attribute on a text or an element.
12
- *
13
- * `AttributeCommand` uses {@link module:engine/model/document~Document#selection}
14
- * to decide which nodes (if any) should be changed, and applies or removes the attribute from them.
15
- *
16
- * The command checks the {@link module:engine/model/model~Model#schema} to decide if it can be enabled
17
- * for the current selection and to which nodes the attribute can be applied.
18
- */
19
- export default class AttributeCommand extends Command {
20
- /**
21
- * @param attributeKey Attribute that will be set by the command.
22
- */
23
- constructor(editor, attributeKey) {
24
- super(editor);
25
- this.attributeKey = attributeKey;
26
- }
27
- /**
28
- * Updates the command's {@link #value} and {@link #isEnabled} based on the current selection.
29
- */
30
- refresh() {
31
- const model = this.editor.model;
32
- const doc = model.document;
33
- this.value = this._getValueFromFirstAllowedNode();
34
- this.isEnabled = model.schema.checkAttributeInSelection(doc.selection, this.attributeKey);
35
- }
36
- /**
37
- * Executes the command — applies the attribute to the selection or removes it from the selection.
38
- *
39
- * If the command is active (`value == true`), it will remove attributes. Otherwise, it will set attributes.
40
- *
41
- * The execution result differs, depending on the {@link module:engine/model/document~Document#selection}:
42
- *
43
- * * If the selection is on a range, the command applies the attribute to all nodes in that range
44
- * (if they are allowed to have this attribute by the {@link module:engine/model/schema~Schema schema}).
45
- * * If the selection is collapsed in a non-empty node, the command applies the attribute to the
46
- * {@link module:engine/model/document~Document#selection} itself (note that typed characters copy attributes from the selection).
47
- * * If the selection is collapsed in an empty node, the command applies the attribute to the parent node of the selection (note
48
- * that the selection inherits all attributes from a node if it is in an empty node).
49
- *
50
- * @fires execute
51
- * @param options Command options.
52
- * @param options.forceValue If set, it will force the command behavior. If `true`,
53
- * the command will apply the attribute, otherwise the command will remove the attribute.
54
- * If not set, the command will look for its current value to decide what it should do.
55
- */
56
- execute(options = {}) {
57
- const model = this.editor.model;
58
- const doc = model.document;
59
- const selection = doc.selection;
60
- const value = (options.forceValue === undefined) ? !this.value : options.forceValue;
61
- model.change(writer => {
62
- if (selection.isCollapsed) {
63
- if (value) {
64
- writer.setSelectionAttribute(this.attributeKey, true);
65
- }
66
- else {
67
- writer.removeSelectionAttribute(this.attributeKey);
68
- }
69
- }
70
- else {
71
- const ranges = model.schema.getValidRanges(selection.getRanges(), this.attributeKey);
72
- for (const range of ranges) {
73
- if (value) {
74
- writer.setAttribute(this.attributeKey, value, range);
75
- }
76
- else {
77
- writer.removeAttribute(this.attributeKey, range);
78
- }
79
- }
80
- }
81
- });
82
- }
83
- /**
84
- * Checks the attribute value of the first node in the selection that allows the attribute.
85
- * For the collapsed selection returns the selection attribute.
86
- *
87
- * @returns The attribute value.
88
- */
89
- _getValueFromFirstAllowedNode() {
90
- const model = this.editor.model;
91
- const schema = model.schema;
92
- const selection = model.document.selection;
93
- if (selection.isCollapsed) {
94
- return selection.hasAttribute(this.attributeKey);
95
- }
96
- for (const range of selection.getRanges()) {
97
- for (const item of range.getItems()) {
98
- if (schema.checkAttribute(item, this.attributeKey)) {
99
- return item.hasAttribute(this.attributeKey);
100
- }
101
- }
102
- }
103
- return false;
104
- }
105
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module basic-styles/attributecommand
7
+ */
8
+ import { Command } from 'ckeditor5/src/core.js';
9
+ /**
10
+ * An extension of the base {@link module:core/command~Command} class, which provides utilities for a command
11
+ * that toggles a single attribute on a text or an element.
12
+ *
13
+ * `AttributeCommand` uses {@link module:engine/model/document~Document#selection}
14
+ * to decide which nodes (if any) should be changed, and applies or removes the attribute from them.
15
+ *
16
+ * The command checks the {@link module:engine/model/model~Model#schema} to decide if it can be enabled
17
+ * for the current selection and to which nodes the attribute can be applied.
18
+ */
19
+ export default class AttributeCommand extends Command {
20
+ /**
21
+ * @param attributeKey Attribute that will be set by the command.
22
+ */
23
+ constructor(editor, attributeKey) {
24
+ super(editor);
25
+ this.attributeKey = attributeKey;
26
+ }
27
+ /**
28
+ * Updates the command's {@link #value} and {@link #isEnabled} based on the current selection.
29
+ */
30
+ refresh() {
31
+ const model = this.editor.model;
32
+ const doc = model.document;
33
+ this.value = this._getValueFromFirstAllowedNode();
34
+ this.isEnabled = model.schema.checkAttributeInSelection(doc.selection, this.attributeKey);
35
+ }
36
+ /**
37
+ * Executes the command — applies the attribute to the selection or removes it from the selection.
38
+ *
39
+ * If the command is active (`value == true`), it will remove attributes. Otherwise, it will set attributes.
40
+ *
41
+ * The execution result differs, depending on the {@link module:engine/model/document~Document#selection}:
42
+ *
43
+ * * If the selection is on a range, the command applies the attribute to all nodes in that range
44
+ * (if they are allowed to have this attribute by the {@link module:engine/model/schema~Schema schema}).
45
+ * * If the selection is collapsed in a non-empty node, the command applies the attribute to the
46
+ * {@link module:engine/model/document~Document#selection} itself (note that typed characters copy attributes from the selection).
47
+ * * If the selection is collapsed in an empty node, the command applies the attribute to the parent node of the selection (note
48
+ * that the selection inherits all attributes from a node if it is in an empty node).
49
+ *
50
+ * @fires execute
51
+ * @param options Command options.
52
+ * @param options.forceValue If set, it will force the command behavior. If `true`,
53
+ * the command will apply the attribute, otherwise the command will remove the attribute.
54
+ * If not set, the command will look for its current value to decide what it should do.
55
+ */
56
+ execute(options = {}) {
57
+ const model = this.editor.model;
58
+ const doc = model.document;
59
+ const selection = doc.selection;
60
+ const value = (options.forceValue === undefined) ? !this.value : options.forceValue;
61
+ model.change(writer => {
62
+ if (selection.isCollapsed) {
63
+ if (value) {
64
+ writer.setSelectionAttribute(this.attributeKey, true);
65
+ }
66
+ else {
67
+ writer.removeSelectionAttribute(this.attributeKey);
68
+ }
69
+ }
70
+ else {
71
+ const ranges = model.schema.getValidRanges(selection.getRanges(), this.attributeKey);
72
+ for (const range of ranges) {
73
+ if (value) {
74
+ writer.setAttribute(this.attributeKey, value, range);
75
+ }
76
+ else {
77
+ writer.removeAttribute(this.attributeKey, range);
78
+ }
79
+ }
80
+ }
81
+ });
82
+ }
83
+ /**
84
+ * Checks the attribute value of the first node in the selection that allows the attribute.
85
+ * For the collapsed selection returns the selection attribute.
86
+ *
87
+ * @returns The attribute value.
88
+ */
89
+ _getValueFromFirstAllowedNode() {
90
+ const model = this.editor.model;
91
+ const schema = model.schema;
92
+ const selection = model.document.selection;
93
+ if (selection.isCollapsed) {
94
+ return selection.hasAttribute(this.attributeKey);
95
+ }
96
+ for (const range of selection.getRanges()) {
97
+ for (const item of range.getItems()) {
98
+ if (schema.checkAttribute(item, this.attributeKey)) {
99
+ return item.hasAttribute(this.attributeKey);
100
+ }
101
+ }
102
+ }
103
+ return false;
104
+ }
105
+ }
@@ -1,40 +1,40 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- import type { Superscript, Subscript, Bold, Code, AttributeCommand, BoldUI, CodeEditing, CodeUI, Italic, ItalicEditing, ItalicUI, Strikethrough, StrikethroughEditing, StrikethroughUI, SubscriptEditing, SubscriptUI, SuperscriptEditing, SuperscriptUI, Underline, UnderlineEditing, UnderlineUI } from './index';
6
- declare module '@ckeditor/ckeditor5-core' {
7
- interface PluginsMap {
8
- [Superscript.pluginName]: Superscript;
9
- [Subscript.pluginName]: Subscript;
10
- [Bold.pluginName]: Bold;
11
- [Code.pluginName]: Code;
12
- [Code.pluginName]: Code;
13
- [Code.pluginName]: Code;
14
- [BoldUI.pluginName]: BoldUI;
15
- [CodeEditing.pluginName]: CodeEditing;
16
- [CodeUI.pluginName]: CodeUI;
17
- [Italic.pluginName]: Italic;
18
- [ItalicEditing.pluginName]: ItalicEditing;
19
- [ItalicUI.pluginName]: ItalicUI;
20
- [Strikethrough.pluginName]: Strikethrough;
21
- [StrikethroughEditing.pluginName]: StrikethroughEditing;
22
- [StrikethroughUI.pluginName]: StrikethroughUI;
23
- [SubscriptEditing.pluginName]: SubscriptEditing;
24
- [SubscriptUI.pluginName]: SubscriptUI;
25
- [SuperscriptEditing.pluginName]: SuperscriptEditing;
26
- [SuperscriptUI.pluginName]: SuperscriptUI;
27
- [Underline.pluginName]: Underline;
28
- [UnderlineEditing.pluginName]: UnderlineEditing;
29
- [UnderlineUI.pluginName]: UnderlineUI;
30
- }
31
- interface CommandsMap {
32
- bold: AttributeCommand;
33
- code: AttributeCommand;
34
- italic: AttributeCommand;
35
- strikethrough: AttributeCommand;
36
- subscript: AttributeCommand;
37
- superscript: AttributeCommand;
38
- underline: AttributeCommand;
39
- }
40
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ import type { Superscript, Subscript, Bold, Code, AttributeCommand, BoldUI, CodeEditing, CodeUI, Italic, ItalicEditing, ItalicUI, Strikethrough, StrikethroughEditing, StrikethroughUI, SubscriptEditing, SubscriptUI, SuperscriptEditing, SuperscriptUI, Underline, UnderlineEditing, UnderlineUI } from './index.js';
6
+ declare module '@ckeditor/ckeditor5-core' {
7
+ interface PluginsMap {
8
+ [Superscript.pluginName]: Superscript;
9
+ [Subscript.pluginName]: Subscript;
10
+ [Bold.pluginName]: Bold;
11
+ [Code.pluginName]: Code;
12
+ [Code.pluginName]: Code;
13
+ [Code.pluginName]: Code;
14
+ [BoldUI.pluginName]: BoldUI;
15
+ [CodeEditing.pluginName]: CodeEditing;
16
+ [CodeUI.pluginName]: CodeUI;
17
+ [Italic.pluginName]: Italic;
18
+ [ItalicEditing.pluginName]: ItalicEditing;
19
+ [ItalicUI.pluginName]: ItalicUI;
20
+ [Strikethrough.pluginName]: Strikethrough;
21
+ [StrikethroughEditing.pluginName]: StrikethroughEditing;
22
+ [StrikethroughUI.pluginName]: StrikethroughUI;
23
+ [SubscriptEditing.pluginName]: SubscriptEditing;
24
+ [SubscriptUI.pluginName]: SubscriptUI;
25
+ [SuperscriptEditing.pluginName]: SuperscriptEditing;
26
+ [SuperscriptUI.pluginName]: SuperscriptUI;
27
+ [Underline.pluginName]: Underline;
28
+ [UnderlineEditing.pluginName]: UnderlineEditing;
29
+ [UnderlineUI.pluginName]: UnderlineUI;
30
+ }
31
+ interface CommandsMap {
32
+ bold: AttributeCommand;
33
+ code: AttributeCommand;
34
+ italic: AttributeCommand;
35
+ strikethrough: AttributeCommand;
36
+ subscript: AttributeCommand;
37
+ superscript: AttributeCommand;
38
+ underline: AttributeCommand;
39
+ }
40
+ }
@@ -1,5 +1,5 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- export {};
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ export {};
@@ -1,24 +1,24 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module basic-styles/bold/boldediting
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- /**
10
- * The bold editing feature.
11
- *
12
- * It registers the `'bold'` command and introduces the `bold` attribute in the model which renders to the view
13
- * as a `<strong>` element.
14
- */
15
- export default class BoldEditing extends Plugin {
16
- /**
17
- * @inheritDoc
18
- */
19
- static get pluginName(): "BoldEditing";
20
- /**
21
- * @inheritDoc
22
- */
23
- init(): void;
24
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module basic-styles/bold/boldediting
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ /**
10
+ * The bold editing feature.
11
+ *
12
+ * It registers the `'bold'` command and introduces the `bold` attribute in the model which renders to the view
13
+ * as a `<strong>` element.
14
+ */
15
+ export default class BoldEditing extends Plugin {
16
+ /**
17
+ * @inheritDoc
18
+ */
19
+ static get pluginName(): "BoldEditing";
20
+ /**
21
+ * @inheritDoc
22
+ */
23
+ init(): void;
24
+ }
@@ -1,62 +1,62 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module basic-styles/bold/boldediting
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import AttributeCommand from '../attributecommand';
10
- const BOLD = 'bold';
11
- /**
12
- * The bold editing feature.
13
- *
14
- * It registers the `'bold'` command and introduces the `bold` attribute in the model which renders to the view
15
- * as a `<strong>` element.
16
- */
17
- export default class BoldEditing extends Plugin {
18
- /**
19
- * @inheritDoc
20
- */
21
- static get pluginName() {
22
- return 'BoldEditing';
23
- }
24
- /**
25
- * @inheritDoc
26
- */
27
- init() {
28
- const editor = this.editor;
29
- // Allow bold attribute on text nodes.
30
- editor.model.schema.extend('$text', { allowAttributes: BOLD });
31
- editor.model.schema.setAttributeProperties(BOLD, {
32
- isFormatting: true,
33
- copyOnEnter: true
34
- });
35
- // Build converter from model to view for data and editing pipelines.
36
- editor.conversion.attributeToElement({
37
- model: BOLD,
38
- view: 'strong',
39
- upcastAlso: [
40
- 'b',
41
- viewElement => {
42
- const fontWeight = viewElement.getStyle('font-weight');
43
- if (!fontWeight) {
44
- return null;
45
- }
46
- // Value of the `font-weight` attribute can be defined as a string or a number.
47
- if (fontWeight == 'bold' || Number(fontWeight) >= 600) {
48
- return {
49
- name: true,
50
- styles: ['font-weight']
51
- };
52
- }
53
- return null;
54
- }
55
- ]
56
- });
57
- // Create bold command.
58
- editor.commands.add(BOLD, new AttributeCommand(editor, BOLD));
59
- // Set the Ctrl+B keystroke.
60
- editor.keystrokes.set('CTRL+B', BOLD);
61
- }
62
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module basic-styles/bold/boldediting
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import AttributeCommand from '../attributecommand.js';
10
+ const BOLD = 'bold';
11
+ /**
12
+ * The bold editing feature.
13
+ *
14
+ * It registers the `'bold'` command and introduces the `bold` attribute in the model which renders to the view
15
+ * as a `<strong>` element.
16
+ */
17
+ export default class BoldEditing extends Plugin {
18
+ /**
19
+ * @inheritDoc
20
+ */
21
+ static get pluginName() {
22
+ return 'BoldEditing';
23
+ }
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ init() {
28
+ const editor = this.editor;
29
+ // Allow bold attribute on text nodes.
30
+ editor.model.schema.extend('$text', { allowAttributes: BOLD });
31
+ editor.model.schema.setAttributeProperties(BOLD, {
32
+ isFormatting: true,
33
+ copyOnEnter: true
34
+ });
35
+ // Build converter from model to view for data and editing pipelines.
36
+ editor.conversion.attributeToElement({
37
+ model: BOLD,
38
+ view: 'strong',
39
+ upcastAlso: [
40
+ 'b',
41
+ viewElement => {
42
+ const fontWeight = viewElement.getStyle('font-weight');
43
+ if (!fontWeight) {
44
+ return null;
45
+ }
46
+ // Value of the `font-weight` attribute can be defined as a string or a number.
47
+ if (fontWeight == 'bold' || Number(fontWeight) >= 600) {
48
+ return {
49
+ name: true,
50
+ styles: ['font-weight']
51
+ };
52
+ }
53
+ return null;
54
+ }
55
+ ]
56
+ });
57
+ // Create bold command.
58
+ editor.commands.add(BOLD, new AttributeCommand(editor, BOLD));
59
+ // Set the Ctrl+B keystroke.
60
+ editor.keystrokes.set('CTRL+B', BOLD);
61
+ }
62
+ }