@ckeditor/ckeditor5-basic-styles 30.0.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 (158) hide show
  1. package/LICENSE.md +17 -0
  2. package/README.md +20 -0
  3. package/build/basic-styles.js +5 -0
  4. package/build/translations/af.js +1 -0
  5. package/build/translations/ar.js +1 -0
  6. package/build/translations/ast.js +1 -0
  7. package/build/translations/az.js +1 -0
  8. package/build/translations/bg.js +1 -0
  9. package/build/translations/ca.js +1 -0
  10. package/build/translations/cs.js +1 -0
  11. package/build/translations/da.js +1 -0
  12. package/build/translations/de-ch.js +1 -0
  13. package/build/translations/de.js +1 -0
  14. package/build/translations/el.js +1 -0
  15. package/build/translations/en-au.js +1 -0
  16. package/build/translations/en-gb.js +1 -0
  17. package/build/translations/eo.js +1 -0
  18. package/build/translations/es.js +1 -0
  19. package/build/translations/et.js +1 -0
  20. package/build/translations/eu.js +1 -0
  21. package/build/translations/fa.js +1 -0
  22. package/build/translations/fi.js +1 -0
  23. package/build/translations/fr.js +1 -0
  24. package/build/translations/gl.js +1 -0
  25. package/build/translations/gu.js +1 -0
  26. package/build/translations/he.js +1 -0
  27. package/build/translations/hi.js +1 -0
  28. package/build/translations/hr.js +1 -0
  29. package/build/translations/hu.js +1 -0
  30. package/build/translations/id.js +1 -0
  31. package/build/translations/it.js +1 -0
  32. package/build/translations/ja.js +1 -0
  33. package/build/translations/km.js +1 -0
  34. package/build/translations/kn.js +1 -0
  35. package/build/translations/ko.js +1 -0
  36. package/build/translations/ku.js +1 -0
  37. package/build/translations/lt.js +1 -0
  38. package/build/translations/lv.js +1 -0
  39. package/build/translations/nb.js +1 -0
  40. package/build/translations/ne.js +1 -0
  41. package/build/translations/nl.js +1 -0
  42. package/build/translations/no.js +1 -0
  43. package/build/translations/oc.js +1 -0
  44. package/build/translations/pl.js +1 -0
  45. package/build/translations/pt-br.js +1 -0
  46. package/build/translations/pt.js +1 -0
  47. package/build/translations/ro.js +1 -0
  48. package/build/translations/ru.js +1 -0
  49. package/build/translations/si.js +1 -0
  50. package/build/translations/sk.js +1 -0
  51. package/build/translations/sl.js +1 -0
  52. package/build/translations/sq.js +1 -0
  53. package/build/translations/sr-latn.js +1 -0
  54. package/build/translations/sr.js +1 -0
  55. package/build/translations/sv.js +1 -0
  56. package/build/translations/tk.js +1 -0
  57. package/build/translations/tr.js +1 -0
  58. package/build/translations/tt.js +1 -0
  59. package/build/translations/ug.js +1 -0
  60. package/build/translations/uk.js +1 -0
  61. package/build/translations/vi.js +1 -0
  62. package/build/translations/zh-cn.js +1 -0
  63. package/build/translations/zh.js +1 -0
  64. package/ckeditor5-metadata.json +137 -0
  65. package/lang/contexts.json +9 -0
  66. package/lang/translations/af.po +45 -0
  67. package/lang/translations/ar.po +45 -0
  68. package/lang/translations/ast.po +45 -0
  69. package/lang/translations/az.po +45 -0
  70. package/lang/translations/bg.po +45 -0
  71. package/lang/translations/ca.po +45 -0
  72. package/lang/translations/cs.po +45 -0
  73. package/lang/translations/da.po +45 -0
  74. package/lang/translations/de-ch.po +45 -0
  75. package/lang/translations/de.po +45 -0
  76. package/lang/translations/el.po +45 -0
  77. package/lang/translations/en-au.po +45 -0
  78. package/lang/translations/en-gb.po +45 -0
  79. package/lang/translations/en.po +45 -0
  80. package/lang/translations/eo.po +45 -0
  81. package/lang/translations/es.po +45 -0
  82. package/lang/translations/et.po +45 -0
  83. package/lang/translations/eu.po +45 -0
  84. package/lang/translations/fa.po +45 -0
  85. package/lang/translations/fi.po +45 -0
  86. package/lang/translations/fr.po +45 -0
  87. package/lang/translations/gl.po +45 -0
  88. package/lang/translations/gu.po +45 -0
  89. package/lang/translations/he.po +45 -0
  90. package/lang/translations/hi.po +45 -0
  91. package/lang/translations/hr.po +45 -0
  92. package/lang/translations/hu.po +45 -0
  93. package/lang/translations/id.po +45 -0
  94. package/lang/translations/it.po +45 -0
  95. package/lang/translations/ja.po +45 -0
  96. package/lang/translations/km.po +45 -0
  97. package/lang/translations/kn.po +45 -0
  98. package/lang/translations/ko.po +45 -0
  99. package/lang/translations/ku.po +45 -0
  100. package/lang/translations/lt.po +45 -0
  101. package/lang/translations/lv.po +45 -0
  102. package/lang/translations/nb.po +45 -0
  103. package/lang/translations/ne.po +45 -0
  104. package/lang/translations/nl.po +45 -0
  105. package/lang/translations/no.po +45 -0
  106. package/lang/translations/oc.po +45 -0
  107. package/lang/translations/pl.po +45 -0
  108. package/lang/translations/pt-br.po +45 -0
  109. package/lang/translations/pt.po +45 -0
  110. package/lang/translations/ro.po +45 -0
  111. package/lang/translations/ru.po +45 -0
  112. package/lang/translations/si.po +45 -0
  113. package/lang/translations/sk.po +45 -0
  114. package/lang/translations/sl.po +45 -0
  115. package/lang/translations/sq.po +45 -0
  116. package/lang/translations/sr-latn.po +45 -0
  117. package/lang/translations/sr.po +45 -0
  118. package/lang/translations/sv.po +45 -0
  119. package/lang/translations/tk.po +45 -0
  120. package/lang/translations/tr.po +45 -0
  121. package/lang/translations/tt.po +45 -0
  122. package/lang/translations/ug.po +45 -0
  123. package/lang/translations/uk.po +45 -0
  124. package/lang/translations/vi.po +45 -0
  125. package/lang/translations/zh-cn.po +45 -0
  126. package/lang/translations/zh.po +45 -0
  127. package/package.json +53 -0
  128. package/src/attributecommand.js +138 -0
  129. package/src/bold/boldediting.js +73 -0
  130. package/src/bold/boldui.js +61 -0
  131. package/src/bold.js +39 -0
  132. package/src/code/codeediting.js +73 -0
  133. package/src/code/codeui.js +62 -0
  134. package/src/code.js +41 -0
  135. package/src/index.js +30 -0
  136. package/src/italic/italicediting.js +63 -0
  137. package/src/italic/italicui.js +61 -0
  138. package/src/italic.js +39 -0
  139. package/src/strikethrough/strikethroughediting.js +65 -0
  140. package/src/strikethrough/strikethroughui.js +61 -0
  141. package/src/strikethrough.js +39 -0
  142. package/src/subscript/subscriptediting.js +60 -0
  143. package/src/subscript/subscriptui.js +60 -0
  144. package/src/subscript.js +36 -0
  145. package/src/superscript/superscriptediting.js +60 -0
  146. package/src/superscript/superscriptui.js +60 -0
  147. package/src/superscript.js +36 -0
  148. package/src/underline/underlineediting.js +60 -0
  149. package/src/underline/underlineui.js +61 -0
  150. package/src/underline.js +39 -0
  151. package/theme/code.css +14 -0
  152. package/theme/icons/bold.svg +1 -0
  153. package/theme/icons/code.svg +1 -0
  154. package/theme/icons/italic.svg +1 -0
  155. package/theme/icons/strikethrough.svg +1 -0
  156. package/theme/icons/subscript.svg +1 -0
  157. package/theme/icons/superscript.svg +1 -0
  158. package/theme/icons/underline.svg +1 -0
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ /**
7
+ * @module basic-styles/italic/italicediting
8
+ */
9
+
10
+ import { Plugin } from 'ckeditor5/src/core';
11
+ import AttributeCommand from '../attributecommand';
12
+
13
+ const ITALIC = 'italic';
14
+
15
+ /**
16
+ * The italic editing feature.
17
+ *
18
+ * It registers the `'italic'` command, the <kbd>Ctrl+I</kbd> keystroke and introduces the `italic` attribute in the model
19
+ * which renders to the view as an `<i>` element.
20
+ *
21
+ * @extends module:core/plugin~Plugin
22
+ */
23
+ export default class ItalicEditing extends Plugin {
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ static get pluginName() {
28
+ return 'ItalicEditing';
29
+ }
30
+
31
+ /**
32
+ * @inheritDoc
33
+ */
34
+ init() {
35
+ const editor = this.editor;
36
+
37
+ // Allow italic attribute on text nodes.
38
+ editor.model.schema.extend( '$text', { allowAttributes: ITALIC } );
39
+ editor.model.schema.setAttributeProperties( ITALIC, {
40
+ isFormatting: true,
41
+ copyOnEnter: true
42
+ } );
43
+
44
+ editor.conversion.attributeToElement( {
45
+ model: ITALIC,
46
+ view: 'i',
47
+ upcastAlso: [
48
+ 'em',
49
+ {
50
+ styles: {
51
+ 'font-style': 'italic'
52
+ }
53
+ }
54
+ ]
55
+ } );
56
+
57
+ // Create italic command.
58
+ editor.commands.add( ITALIC, new AttributeCommand( editor, ITALIC ) );
59
+
60
+ // Set the Ctrl+I keystroke.
61
+ editor.keystrokes.set( 'CTRL+I', ITALIC );
62
+ }
63
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ /**
7
+ * @module basic-styles/italic/italicui
8
+ */
9
+
10
+ import { Plugin } from 'ckeditor5/src/core';
11
+ import { ButtonView } from 'ckeditor5/src/ui';
12
+
13
+ import italicIcon from '../../theme/icons/italic.svg';
14
+
15
+ const ITALIC = 'italic';
16
+
17
+ /**
18
+ * The italic UI feature. It introduces the Italic button.
19
+ *
20
+ * @extends module:core/plugin~Plugin
21
+ */
22
+ export default class ItalicUI extends Plugin {
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get pluginName() {
27
+ return 'ItalicUI';
28
+ }
29
+
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ init() {
34
+ const editor = this.editor;
35
+ const t = editor.t;
36
+
37
+ // Add bold button to feature components.
38
+ editor.ui.componentFactory.add( ITALIC, locale => {
39
+ const command = editor.commands.get( ITALIC );
40
+ const view = new ButtonView( locale );
41
+
42
+ view.set( {
43
+ label: t( 'Italic' ),
44
+ icon: italicIcon,
45
+ keystroke: 'CTRL+I',
46
+ tooltip: true,
47
+ isToggleable: true
48
+ } );
49
+
50
+ view.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' );
51
+
52
+ // Execute command.
53
+ this.listenTo( view, 'execute', () => {
54
+ editor.execute( ITALIC );
55
+ editor.editing.view.focus();
56
+ } );
57
+
58
+ return view;
59
+ } );
60
+ }
61
+ }
package/src/italic.js ADDED
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ /**
7
+ * @module basic-styles/italic
8
+ */
9
+
10
+ import { Plugin } from 'ckeditor5/src/core';
11
+ import ItalicEditing from './italic/italicediting';
12
+ import ItalicUI from './italic/italicui';
13
+
14
+ /**
15
+ * The italic feature.
16
+ *
17
+ * For a detailed overview check the {@glink features/basic-styles Basic styles feature documentation}
18
+ * and the {@glink api/basic-styles package page}.
19
+ *
20
+ * This is a "glue" plugin which loads the {@link module:basic-styles/italic/italicediting~ItalicEditing} and
21
+ * {@link module:basic-styles/italic/italicui~ItalicUI} plugins.
22
+ *
23
+ * @extends module:core/plugin~Plugin
24
+ */
25
+ export default class Italic extends Plugin {
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ static get requires() {
30
+ return [ ItalicEditing, ItalicUI ];
31
+ }
32
+
33
+ /**
34
+ * @inheritDoc
35
+ */
36
+ static get pluginName() {
37
+ return 'Italic';
38
+ }
39
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ /**
7
+ * @module basic-styles/strikethrough/strikethroughediting
8
+ */
9
+
10
+ import { Plugin } from 'ckeditor5/src/core';
11
+ import AttributeCommand from '../attributecommand';
12
+
13
+ const STRIKETHROUGH = 'strikethrough';
14
+
15
+ /**
16
+ * The strikethrough editing feature.
17
+ *
18
+ * It registers the `'strikethrough'` command, the <kbd>Ctrl+Shift+X</kbd> keystroke and introduces the
19
+ * `strikethroughsthrough` attribute in the model which renders to the view
20
+ * as a `<s>` element.
21
+ *
22
+ * @extends module:core/plugin~Plugin
23
+ */
24
+ export default class StrikethroughEditing extends Plugin {
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ static get pluginName() {
29
+ return 'StrikethroughEditing';
30
+ }
31
+
32
+ /**
33
+ * @inheritDoc
34
+ */
35
+ init() {
36
+ const editor = this.editor;
37
+
38
+ // Allow strikethrough attribute on text nodes.
39
+ editor.model.schema.extend( '$text', { allowAttributes: STRIKETHROUGH } );
40
+ editor.model.schema.setAttributeProperties( STRIKETHROUGH, {
41
+ isFormatting: true,
42
+ copyOnEnter: true
43
+ } );
44
+
45
+ editor.conversion.attributeToElement( {
46
+ model: STRIKETHROUGH,
47
+ view: 's',
48
+ upcastAlso: [
49
+ 'del',
50
+ 'strike',
51
+ {
52
+ styles: {
53
+ 'text-decoration': 'line-through'
54
+ }
55
+ }
56
+ ]
57
+ } );
58
+
59
+ // Create strikethrough command.
60
+ editor.commands.add( STRIKETHROUGH, new AttributeCommand( editor, STRIKETHROUGH ) );
61
+
62
+ // Set the Ctrl+Shift+X keystroke.
63
+ editor.keystrokes.set( 'CTRL+SHIFT+X', 'strikethrough' );
64
+ }
65
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ /**
7
+ * @module basic-styles/strikethrough/strikethroughui
8
+ */
9
+
10
+ import { Plugin } from 'ckeditor5/src/core';
11
+ import { ButtonView } from 'ckeditor5/src/ui';
12
+
13
+ import strikethroughIcon from '../../theme/icons/strikethrough.svg';
14
+
15
+ const STRIKETHROUGH = 'strikethrough';
16
+
17
+ /**
18
+ * The strikethrough UI feature. It introduces the Strikethrough button.
19
+ *
20
+ * @extends module:core/plugin~Plugin
21
+ */
22
+ export default class StrikethroughUI extends Plugin {
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get pluginName() {
27
+ return 'StrikethroughUI';
28
+ }
29
+
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ init() {
34
+ const editor = this.editor;
35
+ const t = editor.t;
36
+
37
+ // Add strikethrough button to feature components.
38
+ editor.ui.componentFactory.add( STRIKETHROUGH, locale => {
39
+ const command = editor.commands.get( STRIKETHROUGH );
40
+ const view = new ButtonView( locale );
41
+
42
+ view.set( {
43
+ label: t( 'Strikethrough' ),
44
+ icon: strikethroughIcon,
45
+ keystroke: 'CTRL+SHIFT+X',
46
+ tooltip: true,
47
+ isToggleable: true
48
+ } );
49
+
50
+ view.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' );
51
+
52
+ // Execute command.
53
+ this.listenTo( view, 'execute', () => {
54
+ editor.execute( STRIKETHROUGH );
55
+ editor.editing.view.focus();
56
+ } );
57
+
58
+ return view;
59
+ } );
60
+ }
61
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ /**
7
+ * @module basic-styles/strikethrough
8
+ */
9
+
10
+ import { Plugin } from 'ckeditor5/src/core';
11
+ import StrikethroughEditing from './strikethrough/strikethroughediting';
12
+ import StrikethroughUI from './strikethrough/strikethroughui';
13
+
14
+ /**
15
+ * The strikethrough feature.
16
+ *
17
+ * For a detailed overview check the {@glink features/basic-styles Basic styles feature documentation}
18
+ * and the {@glink api/basic-styles package page}.
19
+ *
20
+ * This is a "glue" plugin which loads the {@link module:basic-styles/strikethrough/strikethroughediting~StrikethroughEditing} and
21
+ * {@link module:basic-styles/strikethrough/strikethroughui~StrikethroughUI} plugins.
22
+ *
23
+ * @extends module:core/plugin~Plugin
24
+ */
25
+ export default class Strikethrough extends Plugin {
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ static get requires() {
30
+ return [ StrikethroughEditing, StrikethroughUI ];
31
+ }
32
+
33
+ /**
34
+ * @inheritDoc
35
+ */
36
+ static get pluginName() {
37
+ return 'Strikethrough';
38
+ }
39
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ /**
7
+ * @module basic-styles/subscript/subscriptediting
8
+ */
9
+
10
+ import { Plugin } from 'ckeditor5/src/core';
11
+ import AttributeCommand from '../attributecommand';
12
+
13
+ const SUBSCRIPT = 'subscript';
14
+
15
+ /**
16
+ * The subscript editing feature.
17
+ *
18
+ * It registers the `sub` command and introduces the `sub` attribute in the model which renders to the view
19
+ * as a `<sub>` element.
20
+ *
21
+ * @extends module:core/plugin~Plugin
22
+ */
23
+ export default class SubscriptEditing extends Plugin {
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ static get pluginName() {
28
+ return 'SubscriptEditing';
29
+ }
30
+
31
+ /**
32
+ * @inheritDoc
33
+ */
34
+ init() {
35
+ const editor = this.editor;
36
+ // Allow sub attribute on text nodes.
37
+ editor.model.schema.extend( '$text', { allowAttributes: SUBSCRIPT } );
38
+ editor.model.schema.setAttributeProperties( SUBSCRIPT, {
39
+ isFormatting: true,
40
+ copyOnEnter: true
41
+ } );
42
+
43
+ // Build converter from model to view for data and editing pipelines.
44
+
45
+ editor.conversion.attributeToElement( {
46
+ model: SUBSCRIPT,
47
+ view: 'sub',
48
+ upcastAlso: [
49
+ {
50
+ styles: {
51
+ 'vertical-align': 'sub'
52
+ }
53
+ }
54
+ ]
55
+ } );
56
+
57
+ // Create sub command.
58
+ editor.commands.add( SUBSCRIPT, new AttributeCommand( editor, SUBSCRIPT ) );
59
+ }
60
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ /**
7
+ * @module basic-styles/subscript/subscriptui
8
+ */
9
+
10
+ import { Plugin } from 'ckeditor5/src/core';
11
+ import { ButtonView } from 'ckeditor5/src/ui';
12
+
13
+ import subscriptIcon from '../../theme/icons/subscript.svg';
14
+
15
+ const SUBSCRIPT = 'subscript';
16
+
17
+ /**
18
+ * The subscript UI feature. It introduces the Subscript button.
19
+ *
20
+ * @extends module:core/plugin~Plugin
21
+ */
22
+ export default class SubscriptUI extends Plugin {
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get pluginName() {
27
+ return 'SubscriptUI';
28
+ }
29
+
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ init() {
34
+ const editor = this.editor;
35
+ const t = editor.t;
36
+
37
+ // Add subscript button to feature components.
38
+ editor.ui.componentFactory.add( SUBSCRIPT, locale => {
39
+ const command = editor.commands.get( SUBSCRIPT );
40
+ const view = new ButtonView( locale );
41
+
42
+ view.set( {
43
+ label: t( 'Subscript' ),
44
+ icon: subscriptIcon,
45
+ tooltip: true,
46
+ isToggleable: true
47
+ } );
48
+
49
+ view.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' );
50
+
51
+ // Execute command.
52
+ this.listenTo( view, 'execute', () => {
53
+ editor.execute( SUBSCRIPT );
54
+ editor.editing.view.focus();
55
+ } );
56
+
57
+ return view;
58
+ } );
59
+ }
60
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ /**
7
+ * @module basic-styles/subscript
8
+ */
9
+
10
+ import { Plugin } from 'ckeditor5/src/core';
11
+ import SubscriptEditing from './subscript/subscriptediting';
12
+ import SubscriptUI from './subscript/subscriptui';
13
+
14
+ /**
15
+ * The subscript feature.
16
+ *
17
+ * It loads the {@link module:basic-styles/subscript/subscriptediting~SubscriptEditing} and
18
+ * {@link module:basic-styles/subscript/subscriptui~SubscriptUI} plugins.
19
+ *
20
+ * @extends module:core/plugin~Plugin
21
+ */
22
+ export default class Subscript extends Plugin {
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get requires() {
27
+ return [ SubscriptEditing, SubscriptUI ];
28
+ }
29
+
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ static get pluginName() {
34
+ return 'Subscript';
35
+ }
36
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ /**
7
+ * @module basic-styles/superscript/superscriptediting
8
+ */
9
+
10
+ import { Plugin } from 'ckeditor5/src/core';
11
+ import AttributeCommand from '../attributecommand';
12
+
13
+ const SUPERSCRIPT = 'superscript';
14
+
15
+ /**
16
+ * The superscript editing feature.
17
+ *
18
+ * It registers the `super` command and introduces the `super` attribute in the model which renders to the view
19
+ * as a `<super>` element.
20
+ *
21
+ * @extends module:core/plugin~Plugin
22
+ */
23
+ export default class SuperscriptEditing extends Plugin {
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ static get pluginName() {
28
+ return 'SuperscriptEditing';
29
+ }
30
+
31
+ /**
32
+ * @inheritDoc
33
+ */
34
+ init() {
35
+ const editor = this.editor;
36
+ // Allow super attribute on text nodes.
37
+ editor.model.schema.extend( '$text', { allowAttributes: SUPERSCRIPT } );
38
+ editor.model.schema.setAttributeProperties( SUPERSCRIPT, {
39
+ isFormatting: true,
40
+ copyOnEnter: true
41
+ } );
42
+
43
+ // Build converter from model to view for data and editing pipelines.
44
+
45
+ editor.conversion.attributeToElement( {
46
+ model: SUPERSCRIPT,
47
+ view: 'sup',
48
+ upcastAlso: [
49
+ {
50
+ styles: {
51
+ 'vertical-align': 'super'
52
+ }
53
+ }
54
+ ]
55
+ } );
56
+
57
+ // Create super command.
58
+ editor.commands.add( SUPERSCRIPT, new AttributeCommand( editor, SUPERSCRIPT ) );
59
+ }
60
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ /**
7
+ * @module basic-styles/superscript/superscriptui
8
+ */
9
+
10
+ import { Plugin } from 'ckeditor5/src/core';
11
+ import { ButtonView } from 'ckeditor5/src/ui';
12
+
13
+ import superscriptIcon from '../../theme/icons/superscript.svg';
14
+
15
+ const SUPERSCRIPT = 'superscript';
16
+
17
+ /**
18
+ * The superscript UI feature. It introduces the Superscript button.
19
+ *
20
+ * @extends module:core/plugin~Plugin
21
+ */
22
+ export default class SuperscriptUI extends Plugin {
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get pluginName() {
27
+ return 'SuperscriptUI';
28
+ }
29
+
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ init() {
34
+ const editor = this.editor;
35
+ const t = editor.t;
36
+
37
+ // Add superscript button to feature components.
38
+ editor.ui.componentFactory.add( SUPERSCRIPT, locale => {
39
+ const command = editor.commands.get( SUPERSCRIPT );
40
+ const view = new ButtonView( locale );
41
+
42
+ view.set( {
43
+ label: t( 'Superscript' ),
44
+ icon: superscriptIcon,
45
+ tooltip: true,
46
+ isToggleable: true
47
+ } );
48
+
49
+ view.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' );
50
+
51
+ // Execute command.
52
+ this.listenTo( view, 'execute', () => {
53
+ editor.execute( SUPERSCRIPT );
54
+ editor.editing.view.focus();
55
+ } );
56
+
57
+ return view;
58
+ } );
59
+ }
60
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ /**
7
+ * @module basic-styles/superscript
8
+ */
9
+
10
+ import { Plugin } from 'ckeditor5/src/core';
11
+ import SuperscriptEditing from './superscript/superscriptediting';
12
+ import SuperscriptUI from './superscript/superscriptui';
13
+
14
+ /**
15
+ * The superscript feature.
16
+ *
17
+ * It loads the {@link module:basic-styles/superscript/superscriptediting~SuperscriptEditing} and
18
+ * {@link module:basic-styles/superscript/superscriptui~SuperscriptUI} plugins.
19
+ *
20
+ * @extends module:core/plugin~Plugin
21
+ */
22
+ export default class Superscript extends Plugin {
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get requires() {
27
+ return [ SuperscriptEditing, SuperscriptUI ];
28
+ }
29
+
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ static get pluginName() {
34
+ return 'Superscript';
35
+ }
36
+ }