@ckeditor/ckeditor5-code-block 40.0.0 → 40.2.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.
@@ -1,138 +1,138 @@
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 { Command } from 'ckeditor5/src/core';
6
- import { first } from 'ckeditor5/src/utils';
7
- import { getNormalizedAndLocalizedLanguageDefinitions, canBeCodeBlock } from './utils';
8
- /**
9
- * The code block command plugin.
10
- */
11
- export default class CodeBlockCommand extends Command {
12
- /**
13
- * @inheritDoc
14
- */
15
- constructor(editor) {
16
- super(editor);
17
- this._lastLanguage = null;
18
- }
19
- /**
20
- * @inheritDoc
21
- */
22
- refresh() {
23
- this.value = this._getValue();
24
- this.isEnabled = this._checkEnabled();
25
- }
26
- /**
27
- * Executes the command. When the command {@link #value is on}, all topmost code blocks within
28
- * the selection will be removed. If it is off, all selected blocks will be flattened and
29
- * wrapped by a code block.
30
- *
31
- * @fires execute
32
- * @param options Command options.
33
- * @param options.language The code block language.
34
- * @param options.forceValue If set, it will force the command behavior. If `true`, the command will apply a code block,
35
- * otherwise the command will remove the code block. If not set, the command will act basing on its current value.
36
- * @param options.usePreviousLanguageChoice If set on `true` and the `options.language` is not specified, the command
37
- * will apply the previous language (if the command was already executed) when inserting the `codeBlock` element.
38
- */
39
- execute(options = {}) {
40
- const editor = this.editor;
41
- const model = editor.model;
42
- const selection = model.document.selection;
43
- const normalizedLanguagesDefs = getNormalizedAndLocalizedLanguageDefinitions(editor);
44
- const firstLanguageInConfig = normalizedLanguagesDefs[0];
45
- const blocks = Array.from(selection.getSelectedBlocks());
46
- const value = options.forceValue == undefined ? !this.value : options.forceValue;
47
- const language = getLanguage(options, this._lastLanguage, firstLanguageInConfig.language);
48
- model.change(writer => {
49
- if (value) {
50
- this._applyCodeBlock(writer, blocks, language);
51
- }
52
- else {
53
- this._removeCodeBlock(writer, blocks);
54
- }
55
- });
56
- }
57
- /**
58
- * Checks the command's {@link #value}.
59
- *
60
- * @returns The current value.
61
- */
62
- _getValue() {
63
- const selection = this.editor.model.document.selection;
64
- const firstBlock = first(selection.getSelectedBlocks());
65
- const isCodeBlock = !!(firstBlock && firstBlock.is('element', 'codeBlock'));
66
- return isCodeBlock ? firstBlock.getAttribute('language') : false;
67
- }
68
- /**
69
- * Checks whether the command can be enabled in the current context.
70
- *
71
- * @returns Whether the command should be enabled.
72
- */
73
- _checkEnabled() {
74
- if (this.value) {
75
- return true;
76
- }
77
- const selection = this.editor.model.document.selection;
78
- const schema = this.editor.model.schema;
79
- const firstBlock = first(selection.getSelectedBlocks());
80
- if (!firstBlock) {
81
- return false;
82
- }
83
- return canBeCodeBlock(schema, firstBlock);
84
- }
85
- _applyCodeBlock(writer, blocks, language) {
86
- this._lastLanguage = language;
87
- const schema = this.editor.model.schema;
88
- const allowedBlocks = blocks.filter(block => canBeCodeBlock(schema, block));
89
- for (const block of allowedBlocks) {
90
- writer.rename(block, 'codeBlock');
91
- writer.setAttribute('language', language, block);
92
- schema.removeDisallowedAttributes([block], writer);
93
- // Remove children of the `codeBlock` element that are not allowed. See #9567.
94
- Array.from(block.getChildren())
95
- .filter(child => !schema.checkChild(block, child))
96
- .forEach(child => writer.remove(child));
97
- }
98
- allowedBlocks.reverse().forEach((currentBlock, i) => {
99
- const nextBlock = allowedBlocks[i + 1];
100
- if (currentBlock.previousSibling === nextBlock) {
101
- writer.appendElement('softBreak', nextBlock);
102
- writer.merge(writer.createPositionBefore(currentBlock));
103
- }
104
- });
105
- }
106
- _removeCodeBlock(writer, blocks) {
107
- const codeBlocks = blocks.filter(block => block.is('element', 'codeBlock'));
108
- for (const block of codeBlocks) {
109
- const range = writer.createRangeOn(block);
110
- for (const item of Array.from(range.getItems()).reverse()) {
111
- if (item.is('element', 'softBreak') && item.parent.is('element', 'codeBlock')) {
112
- const { position } = writer.split(writer.createPositionBefore(item));
113
- const elementAfter = position.nodeAfter;
114
- writer.rename(elementAfter, 'paragraph');
115
- writer.removeAttribute('language', elementAfter);
116
- writer.remove(item);
117
- }
118
- }
119
- writer.rename(block, 'paragraph');
120
- writer.removeAttribute('language', block);
121
- }
122
- }
123
- }
124
- /**
125
- * Picks the language for the new code block. If any language is passed as an option,
126
- * it will be returned. Else, if option usePreviousLanguageChoice is true and some
127
- * code block was already created (lastLanguage is not null) then previously used
128
- * language will be returned. If not, it will return default language.
129
- */
130
- function getLanguage(options, lastLanguage, defaultLanguage) {
131
- if (options.language) {
132
- return options.language;
133
- }
134
- if (options.usePreviousLanguageChoice && lastLanguage) {
135
- return lastLanguage;
136
- }
137
- return defaultLanguage;
138
- }
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 { Command } from 'ckeditor5/src/core';
6
+ import { first } from 'ckeditor5/src/utils';
7
+ import { getNormalizedAndLocalizedLanguageDefinitions, canBeCodeBlock } from './utils';
8
+ /**
9
+ * The code block command plugin.
10
+ */
11
+ export default class CodeBlockCommand extends Command {
12
+ /**
13
+ * @inheritDoc
14
+ */
15
+ constructor(editor) {
16
+ super(editor);
17
+ this._lastLanguage = null;
18
+ }
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ refresh() {
23
+ this.value = this._getValue();
24
+ this.isEnabled = this._checkEnabled();
25
+ }
26
+ /**
27
+ * Executes the command. When the command {@link #value is on}, all topmost code blocks within
28
+ * the selection will be removed. If it is off, all selected blocks will be flattened and
29
+ * wrapped by a code block.
30
+ *
31
+ * @fires execute
32
+ * @param options Command options.
33
+ * @param options.language The code block language.
34
+ * @param options.forceValue If set, it will force the command behavior. If `true`, the command will apply a code block,
35
+ * otherwise the command will remove the code block. If not set, the command will act basing on its current value.
36
+ * @param options.usePreviousLanguageChoice If set on `true` and the `options.language` is not specified, the command
37
+ * will apply the previous language (if the command was already executed) when inserting the `codeBlock` element.
38
+ */
39
+ execute(options = {}) {
40
+ const editor = this.editor;
41
+ const model = editor.model;
42
+ const selection = model.document.selection;
43
+ const normalizedLanguagesDefs = getNormalizedAndLocalizedLanguageDefinitions(editor);
44
+ const firstLanguageInConfig = normalizedLanguagesDefs[0];
45
+ const blocks = Array.from(selection.getSelectedBlocks());
46
+ const value = options.forceValue == undefined ? !this.value : options.forceValue;
47
+ const language = getLanguage(options, this._lastLanguage, firstLanguageInConfig.language);
48
+ model.change(writer => {
49
+ if (value) {
50
+ this._applyCodeBlock(writer, blocks, language);
51
+ }
52
+ else {
53
+ this._removeCodeBlock(writer, blocks);
54
+ }
55
+ });
56
+ }
57
+ /**
58
+ * Checks the command's {@link #value}.
59
+ *
60
+ * @returns The current value.
61
+ */
62
+ _getValue() {
63
+ const selection = this.editor.model.document.selection;
64
+ const firstBlock = first(selection.getSelectedBlocks());
65
+ const isCodeBlock = !!(firstBlock && firstBlock.is('element', 'codeBlock'));
66
+ return isCodeBlock ? firstBlock.getAttribute('language') : false;
67
+ }
68
+ /**
69
+ * Checks whether the command can be enabled in the current context.
70
+ *
71
+ * @returns Whether the command should be enabled.
72
+ */
73
+ _checkEnabled() {
74
+ if (this.value) {
75
+ return true;
76
+ }
77
+ const selection = this.editor.model.document.selection;
78
+ const schema = this.editor.model.schema;
79
+ const firstBlock = first(selection.getSelectedBlocks());
80
+ if (!firstBlock) {
81
+ return false;
82
+ }
83
+ return canBeCodeBlock(schema, firstBlock);
84
+ }
85
+ _applyCodeBlock(writer, blocks, language) {
86
+ this._lastLanguage = language;
87
+ const schema = this.editor.model.schema;
88
+ const allowedBlocks = blocks.filter(block => canBeCodeBlock(schema, block));
89
+ for (const block of allowedBlocks) {
90
+ writer.rename(block, 'codeBlock');
91
+ writer.setAttribute('language', language, block);
92
+ schema.removeDisallowedAttributes([block], writer);
93
+ // Remove children of the `codeBlock` element that are not allowed. See #9567.
94
+ Array.from(block.getChildren())
95
+ .filter(child => !schema.checkChild(block, child))
96
+ .forEach(child => writer.remove(child));
97
+ }
98
+ allowedBlocks.reverse().forEach((currentBlock, i) => {
99
+ const nextBlock = allowedBlocks[i + 1];
100
+ if (currentBlock.previousSibling === nextBlock) {
101
+ writer.appendElement('softBreak', nextBlock);
102
+ writer.merge(writer.createPositionBefore(currentBlock));
103
+ }
104
+ });
105
+ }
106
+ _removeCodeBlock(writer, blocks) {
107
+ const codeBlocks = blocks.filter(block => block.is('element', 'codeBlock'));
108
+ for (const block of codeBlocks) {
109
+ const range = writer.createRangeOn(block);
110
+ for (const item of Array.from(range.getItems()).reverse()) {
111
+ if (item.is('element', 'softBreak') && item.parent.is('element', 'codeBlock')) {
112
+ const { position } = writer.split(writer.createPositionBefore(item));
113
+ const elementAfter = position.nodeAfter;
114
+ writer.rename(elementAfter, 'paragraph');
115
+ writer.removeAttribute('language', elementAfter);
116
+ writer.remove(item);
117
+ }
118
+ }
119
+ writer.rename(block, 'paragraph');
120
+ writer.removeAttribute('language', block);
121
+ }
122
+ }
123
+ }
124
+ /**
125
+ * Picks the language for the new code block. If any language is passed as an option,
126
+ * it will be returned. Else, if option usePreviousLanguageChoice is true and some
127
+ * code block was already created (lastLanguage is not null) then previously used
128
+ * language will be returned. If not, it will return default language.
129
+ */
130
+ function getLanguage(options, lastLanguage, defaultLanguage) {
131
+ if (options.language) {
132
+ return options.language;
133
+ }
134
+ if (options.usePreviousLanguageChoice && lastLanguage) {
135
+ return lastLanguage;
136
+ }
137
+ return defaultLanguage;
138
+ }
@@ -1,146 +1,146 @@
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 code-block/codeblockconfig
7
- */
8
- /**
9
- * The configuration of the {@link module:code-block/codeblock~CodeBlock code block feature}.
10
- *
11
- * ```ts
12
- * ClassicEditor
13
- * .create( editorElement, {
14
- * codeBlock: ... // The code block feature configuration.
15
- * } )
16
- * .then( ... )
17
- * .catch( ... );
18
- * ```
19
- *
20
- * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
21
- */
22
- export interface CodeBlockConfig {
23
- /**
24
- * The list of code languages available in the user interface to choose for a particular code block.
25
- *
26
- * The language of the code block is represented as a CSS class (by default prefixed by "language-") set on the
27
- * `<code>` element, both when editing and in the editor data. The CSS class associated with the language
28
- * can be used by third–party code syntax highlighters to detect and apply the correct highlighting.
29
- *
30
- * For instance, this language configuration:
31
- *
32
- * ```ts
33
- * ClassicEditor
34
- * .create( document.querySelector( '#editor' ), {
35
- * codeBlock: {
36
- * languages: [
37
- * // ...
38
- * { language: 'javascript', label: 'JavaScript' },
39
- * // ...
40
- * ]
41
- * }
42
- * } )
43
- * .then( ... )
44
- * .catch( ... );
45
- * ```
46
- *
47
- * will result in the following structure of JavaScript code blocks in the editor editing and data:
48
- *
49
- * ```html
50
- * <pre><code class="language-javascript">window.alert( 'Hello world!' )</code></pre>
51
- * ```
52
- *
53
- * You can customize the CSS class by specifying an optional `class` property in the language definition.
54
- * You can set **multiple classes** but **only the first one** will be used as defining language class:
55
- *
56
- * ```ts
57
- * ClassicEditor
58
- * .create( document.querySelector( '#editor' ), {
59
- * codeBlock: {
60
- * languages: [
61
- * // Do not render the CSS class for the plain text code blocks.
62
- * { language: 'plaintext', label: 'Plain text', class: '' },
63
- *
64
- * // Use the "php-code" class for PHP code blocks.
65
- * { language: 'php', label: 'PHP', class: 'php-code' },
66
- *
67
- * // Use the "js" class for JavaScript code blocks.
68
- * // Note that only the first ("js") class will determine the language of the block when loading data.
69
- * { language: 'javascript', label: 'JavaScript', class: 'js javascript js-code' },
70
- *
71
- * // Python code blocks will have the default "language-python" CSS class.
72
- * { language: 'python', label: 'Python' }
73
- * ]
74
- * }
75
- * } )
76
- * .then( ... )
77
- * .catch( ... );
78
- * ```
79
- *
80
- * The default value of the language configuration is as follows:
81
- *
82
- * ```ts
83
- * languages: [
84
- * { language: 'plaintext', label: 'Plain text' }, // The default language.
85
- * { language: 'c', label: 'C' },
86
- * { language: 'cs', label: 'C#' },
87
- * { language: 'cpp', label: 'C++' },
88
- * { language: 'css', label: 'CSS' },
89
- * { language: 'diff', label: 'Diff' },
90
- * { language: 'html', label: 'HTML' },
91
- * { language: 'java', label: 'Java' },
92
- * { language: 'javascript', label: 'JavaScript' },
93
- * { language: 'php', label: 'PHP' },
94
- * { language: 'python', label: 'Python' },
95
- * { language: 'ruby', label: 'Ruby' },
96
- * { language: 'typescript', label: 'TypeScript' },
97
- * { language: 'xml', label: 'XML' }
98
- * ]
99
- * ```
100
- *
101
- * **Note**: The first language defined in the configuration is considered the default one. This means it will be
102
- * applied to code blocks loaded from the data that have no CSS `class` specified (or no matching `class` in the configuration).
103
- * It will also be used when creating new code blocks using the main UI button. By default it is "Plain text".
104
- */
105
- languages?: Array<CodeBlockLanguageDefinition>;
106
- /**
107
- * A sequence of characters inserted or removed from the code block lines when its indentation
108
- * is changed by the user, for instance, using <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> keys.
109
- *
110
- * The default value is a single tab character (" ", `\u0009` in Unicode).
111
- *
112
- * This configuration is used by `indentCodeBlock` and `outdentCodeBlock` commands (instances of
113
- * {@link module:code-block/indentcodeblockcommand~IndentCodeBlockCommand}).
114
- *
115
- * **Note**: Setting this configuration to `false` will disable the code block indentation commands
116
- * and associated keystrokes.
117
- *
118
- */
119
- indentSequence?: string;
120
- }
121
- /**
122
- * The code block language descriptor. See {@link module:code-block/codeblockconfig~CodeBlockConfig#languages} to learn more.
123
- *
124
- * ```ts
125
- * {
126
- * language: 'javascript',
127
- * label: 'JavaScript'
128
- * }
129
- * ```
130
- */
131
- export interface CodeBlockLanguageDefinition {
132
- /**
133
- * The name of the language that will be stored in the model attribute. Also, when `class`
134
- * is not specified, it will be used to create the CSS class associated with the language (prefixed by "language-").
135
- */
136
- language: string;
137
- /**
138
- * The human–readable label associated with the language and displayed in the UI.
139
- */
140
- label: string;
141
- /**
142
- * The CSS class associated with the language. When not specified the `language`
143
- * property is used to create a class prefixed by "language-".
144
- */
145
- class?: string;
146
- }
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 code-block/codeblockconfig
7
+ */
8
+ /**
9
+ * The configuration of the {@link module:code-block/codeblock~CodeBlock code block feature}.
10
+ *
11
+ * ```ts
12
+ * ClassicEditor
13
+ * .create( editorElement, {
14
+ * codeBlock: ... // The code block feature configuration.
15
+ * } )
16
+ * .then( ... )
17
+ * .catch( ... );
18
+ * ```
19
+ *
20
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
21
+ */
22
+ export interface CodeBlockConfig {
23
+ /**
24
+ * The list of code languages available in the user interface to choose for a particular code block.
25
+ *
26
+ * The language of the code block is represented as a CSS class (by default prefixed by "language-") set on the
27
+ * `<code>` element, both when editing and in the editor data. The CSS class associated with the language
28
+ * can be used by third–party code syntax highlighters to detect and apply the correct highlighting.
29
+ *
30
+ * For instance, this language configuration:
31
+ *
32
+ * ```ts
33
+ * ClassicEditor
34
+ * .create( document.querySelector( '#editor' ), {
35
+ * codeBlock: {
36
+ * languages: [
37
+ * // ...
38
+ * { language: 'javascript', label: 'JavaScript' },
39
+ * // ...
40
+ * ]
41
+ * }
42
+ * } )
43
+ * .then( ... )
44
+ * .catch( ... );
45
+ * ```
46
+ *
47
+ * will result in the following structure of JavaScript code blocks in the editor editing and data:
48
+ *
49
+ * ```html
50
+ * <pre><code class="language-javascript">window.alert( 'Hello world!' )</code></pre>
51
+ * ```
52
+ *
53
+ * You can customize the CSS class by specifying an optional `class` property in the language definition.
54
+ * You can set **multiple classes** but **only the first one** will be used as defining language class:
55
+ *
56
+ * ```ts
57
+ * ClassicEditor
58
+ * .create( document.querySelector( '#editor' ), {
59
+ * codeBlock: {
60
+ * languages: [
61
+ * // Do not render the CSS class for the plain text code blocks.
62
+ * { language: 'plaintext', label: 'Plain text', class: '' },
63
+ *
64
+ * // Use the "php-code" class for PHP code blocks.
65
+ * { language: 'php', label: 'PHP', class: 'php-code' },
66
+ *
67
+ * // Use the "js" class for JavaScript code blocks.
68
+ * // Note that only the first ("js") class will determine the language of the block when loading data.
69
+ * { language: 'javascript', label: 'JavaScript', class: 'js javascript js-code' },
70
+ *
71
+ * // Python code blocks will have the default "language-python" CSS class.
72
+ * { language: 'python', label: 'Python' }
73
+ * ]
74
+ * }
75
+ * } )
76
+ * .then( ... )
77
+ * .catch( ... );
78
+ * ```
79
+ *
80
+ * The default value of the language configuration is as follows:
81
+ *
82
+ * ```ts
83
+ * languages: [
84
+ * { language: 'plaintext', label: 'Plain text' }, // The default language.
85
+ * { language: 'c', label: 'C' },
86
+ * { language: 'cs', label: 'C#' },
87
+ * { language: 'cpp', label: 'C++' },
88
+ * { language: 'css', label: 'CSS' },
89
+ * { language: 'diff', label: 'Diff' },
90
+ * { language: 'html', label: 'HTML' },
91
+ * { language: 'java', label: 'Java' },
92
+ * { language: 'javascript', label: 'JavaScript' },
93
+ * { language: 'php', label: 'PHP' },
94
+ * { language: 'python', label: 'Python' },
95
+ * { language: 'ruby', label: 'Ruby' },
96
+ * { language: 'typescript', label: 'TypeScript' },
97
+ * { language: 'xml', label: 'XML' }
98
+ * ]
99
+ * ```
100
+ *
101
+ * **Note**: The first language defined in the configuration is considered the default one. This means it will be
102
+ * applied to code blocks loaded from the data that have no CSS `class` specified (or no matching `class` in the configuration).
103
+ * It will also be used when creating new code blocks using the main UI button. By default it is "Plain text".
104
+ */
105
+ languages?: Array<CodeBlockLanguageDefinition>;
106
+ /**
107
+ * A sequence of characters inserted or removed from the code block lines when its indentation
108
+ * is changed by the user, for instance, using <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> keys.
109
+ *
110
+ * The default value is a single tab character (" ", `\u0009` in Unicode).
111
+ *
112
+ * This configuration is used by `indentCodeBlock` and `outdentCodeBlock` commands (instances of
113
+ * {@link module:code-block/indentcodeblockcommand~IndentCodeBlockCommand}).
114
+ *
115
+ * **Note**: Setting this configuration to `false` will disable the code block indentation commands
116
+ * and associated keystrokes.
117
+ *
118
+ */
119
+ indentSequence?: string;
120
+ }
121
+ /**
122
+ * The code block language descriptor. See {@link module:code-block/codeblockconfig~CodeBlockConfig#languages} to learn more.
123
+ *
124
+ * ```ts
125
+ * {
126
+ * language: 'javascript',
127
+ * label: 'JavaScript'
128
+ * }
129
+ * ```
130
+ */
131
+ export interface CodeBlockLanguageDefinition {
132
+ /**
133
+ * The name of the language that will be stored in the model attribute. Also, when `class`
134
+ * is not specified, it will be used to create the CSS class associated with the language (prefixed by "language-").
135
+ */
136
+ language: string;
137
+ /**
138
+ * The human–readable label associated with the language and displayed in the UI.
139
+ */
140
+ label: string;
141
+ /**
142
+ * The CSS class associated with the language. When not specified the `language`
143
+ * property is used to create a class prefixed by "language-".
144
+ */
145
+ class?: string;
146
+ }
@@ -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,36 +1,36 @@
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 code-block/codeblockediting
7
- */
8
- import { Plugin, type Editor } from 'ckeditor5/src/core';
9
- import { ShiftEnter } from 'ckeditor5/src/enter';
10
- /**
11
- * The editing part of the code block feature.
12
- *
13
- * Introduces the `'codeBlock'` command and the `'codeBlock'` model element.
14
- */
15
- export default class CodeBlockEditing extends Plugin {
16
- /**
17
- * @inheritDoc
18
- */
19
- static get pluginName(): "CodeBlockEditing";
20
- /**
21
- * @inheritDoc
22
- */
23
- static get requires(): readonly [typeof ShiftEnter];
24
- /**
25
- * @inheritDoc
26
- */
27
- constructor(editor: Editor);
28
- /**
29
- * @inheritDoc
30
- */
31
- init(): void;
32
- /**
33
- * @inheritDoc
34
- */
35
- afterInit(): void;
36
- }
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 code-block/codeblockediting
7
+ */
8
+ import { Plugin, type Editor } from 'ckeditor5/src/core';
9
+ import { ShiftEnter } from 'ckeditor5/src/enter';
10
+ /**
11
+ * The editing part of the code block feature.
12
+ *
13
+ * Introduces the `'codeBlock'` command and the `'codeBlock'` model element.
14
+ */
15
+ export default class CodeBlockEditing extends Plugin {
16
+ /**
17
+ * @inheritDoc
18
+ */
19
+ static get pluginName(): "CodeBlockEditing";
20
+ /**
21
+ * @inheritDoc
22
+ */
23
+ static get requires(): readonly [typeof ShiftEnter];
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ constructor(editor: Editor);
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ init(): void;
32
+ /**
33
+ * @inheritDoc
34
+ */
35
+ afterInit(): void;
36
+ }