@ckeditor/ckeditor5-code-block 45.2.1 → 46.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-code-block",
3
- "version": "45.2.1",
3
+ "version": "46.0.0-alpha.0",
4
4
  "description": "Code block feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -13,14 +13,14 @@
13
13
  "type": "module",
14
14
  "main": "src/index.js",
15
15
  "dependencies": {
16
- "@ckeditor/ckeditor5-core": "45.2.1",
17
- "@ckeditor/ckeditor5-clipboard": "45.2.1",
18
- "@ckeditor/ckeditor5-engine": "45.2.1",
19
- "@ckeditor/ckeditor5-enter": "45.2.1",
20
- "@ckeditor/ckeditor5-icons": "45.2.1",
21
- "@ckeditor/ckeditor5-ui": "45.2.1",
22
- "@ckeditor/ckeditor5-utils": "45.2.1",
23
- "ckeditor5": "45.2.1"
16
+ "@ckeditor/ckeditor5-core": "46.0.0-alpha.0",
17
+ "@ckeditor/ckeditor5-clipboard": "46.0.0-alpha.0",
18
+ "@ckeditor/ckeditor5-engine": "46.0.0-alpha.0",
19
+ "@ckeditor/ckeditor5-enter": "46.0.0-alpha.0",
20
+ "@ckeditor/ckeditor5-icons": "46.0.0-alpha.0",
21
+ "@ckeditor/ckeditor5-ui": "46.0.0-alpha.0",
22
+ "@ckeditor/ckeditor5-utils": "46.0.0-alpha.0",
23
+ "ckeditor5": "46.0.0-alpha.0"
24
24
  },
25
25
  "author": "CKSource (http://cksource.com/)",
26
26
  "license": "SEE LICENSE IN LICENSE.md",
@@ -6,8 +6,8 @@
6
6
  * @module code-block/codeblock
7
7
  */
8
8
  import { Plugin } from 'ckeditor5/src/core.js';
9
- import CodeBlockEditing from './codeblockediting.js';
10
- import CodeBlockUI from './codeblockui.js';
9
+ import { CodeBlockEditing } from './codeblockediting.js';
10
+ import { CodeBlockUI } from './codeblockui.js';
11
11
  /**
12
12
  * The code block plugin.
13
13
  *
@@ -17,7 +17,7 @@ import CodeBlockUI from './codeblockui.js';
17
17
  * This is a "glue" plugin that loads the {@link module:code-block/codeblockediting~CodeBlockEditing code block editing feature}
18
18
  * and the {@link module:code-block/codeblockui~CodeBlockUI code block UI feature}.
19
19
  */
20
- export default class CodeBlock extends Plugin {
20
+ export declare class CodeBlock extends Plugin {
21
21
  /**
22
22
  * @inheritDoc
23
23
  */
package/src/codeblock.js CHANGED
@@ -6,8 +6,8 @@
6
6
  * @module code-block/codeblock
7
7
  */
8
8
  import { Plugin } from 'ckeditor5/src/core.js';
9
- import CodeBlockEditing from './codeblockediting.js';
10
- import CodeBlockUI from './codeblockui.js';
9
+ import { CodeBlockEditing } from './codeblockediting.js';
10
+ import { CodeBlockUI } from './codeblockui.js';
11
11
  /**
12
12
  * The code block plugin.
13
13
  *
@@ -17,7 +17,7 @@ import CodeBlockUI from './codeblockui.js';
17
17
  * This is a "glue" plugin that loads the {@link module:code-block/codeblockediting~CodeBlockEditing code block editing feature}
18
18
  * and the {@link module:code-block/codeblockui~CodeBlockUI code block UI feature}.
19
19
  */
20
- export default class CodeBlock extends Plugin {
20
+ export class CodeBlock extends Plugin {
21
21
  /**
22
22
  * @inheritDoc
23
23
  */
@@ -6,7 +6,7 @@ import { Command, type Editor } from 'ckeditor5/src/core.js';
6
6
  /**
7
7
  * The code block command plugin.
8
8
  */
9
- export default class CodeBlockCommand extends Command {
9
+ export declare class CodeBlockCommand extends Command {
10
10
  /**
11
11
  * Contains the last used language.
12
12
  */
@@ -8,7 +8,7 @@ import { getNormalizedAndLocalizedLanguageDefinitions, canBeCodeBlock } from './
8
8
  /**
9
9
  * The code block command plugin.
10
10
  */
11
- export default class CodeBlockCommand extends Command {
11
+ export class CodeBlockCommand extends Command {
12
12
  /**
13
13
  * Contains the last used language.
14
14
  */
@@ -12,7 +12,7 @@ import { ShiftEnter } from 'ckeditor5/src/enter.js';
12
12
  *
13
13
  * Introduces the `'codeBlock'` command and the `'codeBlock'` model element.
14
14
  */
15
- export default class CodeBlockEditing extends Plugin {
15
+ export declare class CodeBlockEditing extends Plugin {
16
16
  /**
17
17
  * @inheritDoc
18
18
  */
@@ -7,11 +7,11 @@
7
7
  */
8
8
  import { Plugin } from 'ckeditor5/src/core.js';
9
9
  import { ShiftEnter } from 'ckeditor5/src/enter.js';
10
- import { UpcastWriter } from 'ckeditor5/src/engine.js';
10
+ import { ViewUpcastWriter } from 'ckeditor5/src/engine.js';
11
11
  import { ClipboardPipeline } from 'ckeditor5/src/clipboard.js';
12
- import CodeBlockCommand from './codeblockcommand.js';
13
- import IndentCodeBlockCommand from './indentcodeblockcommand.js';
14
- import OutdentCodeBlockCommand from './outdentcodeblockcommand.js';
12
+ import { CodeBlockCommand } from './codeblockcommand.js';
13
+ import { IndentCodeBlockCommand } from './indentcodeblockcommand.js';
14
+ import { OutdentCodeBlockCommand } from './outdentcodeblockcommand.js';
15
15
  import { getNormalizedAndLocalizedLanguageDefinitions, getLeadingWhiteSpaces, rawSnippetTextToViewDocumentFragment, getCodeBlockAriaAnnouncement, getTextNodeAtLineStart } from './utils.js';
16
16
  import { modelToViewCodeBlockInsertion, modelToDataViewSoftBreakInsertion, dataViewToModelCodeBlockInsertion, dataViewToModelTextNewlinesInsertion, dataViewToModelOrphanNodeConsumer } from './converters.js';
17
17
  const DEFAULT_ELEMENT = 'paragraph';
@@ -20,7 +20,7 @@ const DEFAULT_ELEMENT = 'paragraph';
20
20
  *
21
21
  * Introduces the `'codeBlock'` command and the `'codeBlock'` model element.
22
22
  */
23
- export default class CodeBlockEditing extends Plugin {
23
+ export class CodeBlockEditing extends Plugin {
24
24
  /**
25
25
  * @inheritDoc
26
26
  */
@@ -129,7 +129,7 @@ export default class CodeBlockEditing extends Plugin {
129
129
  return;
130
130
  }
131
131
  const text = data.dataTransfer.getData('text/plain');
132
- const writer = new UpcastWriter(editor.editing.view.document);
132
+ const writer = new ViewUpcastWriter(editor.editing.view.document);
133
133
  // Pass the view fragment to the default clipboardInput handler.
134
134
  data.content = rawSnippetTextToViewDocumentFragment(writer, text);
135
135
  });
@@ -12,7 +12,7 @@ import '../theme/codeblock.css';
12
12
  *
13
13
  * Introduces the `'codeBlock'` dropdown.
14
14
  */
15
- export default class CodeBlockUI extends Plugin {
15
+ export declare class CodeBlockUI extends Plugin {
16
16
  /**
17
17
  * @inheritDoc
18
18
  */
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { Plugin } from 'ckeditor5/src/core.js';
9
9
  import { Collection } from 'ckeditor5/src/utils.js';
10
- import { ViewModel, SplitButtonView, createDropdown, addListToDropdown, MenuBarMenuListItemButtonView, MenuBarMenuListView, MenuBarMenuView, MenuBarMenuListItemView } from 'ckeditor5/src/ui.js';
10
+ import { UIModel, SplitButtonView, createDropdown, addListToDropdown, MenuBarMenuListItemButtonView, MenuBarMenuListView, MenuBarMenuView, MenuBarMenuListItemView } from 'ckeditor5/src/ui.js';
11
11
  import { IconCodeBlock } from 'ckeditor5/src/icons.js';
12
12
  import { getNormalizedAndLocalizedLanguageDefinitions } from './utils.js';
13
13
  import '../theme/codeblock.css';
@@ -16,7 +16,7 @@ import '../theme/codeblock.css';
16
16
  *
17
17
  * Introduces the `'codeBlock'` dropdown.
18
18
  */
19
- export default class CodeBlockUI extends Plugin {
19
+ export class CodeBlockUI extends Plugin {
20
20
  /**
21
21
  * @inheritDoc
22
22
  */
@@ -117,7 +117,7 @@ export default class CodeBlockUI extends Plugin {
117
117
  for (const languageDef of normalizedLanguageDefs) {
118
118
  const definition = {
119
119
  type: 'button',
120
- model: new ViewModel({
120
+ model: new UIModel({
121
121
  _codeBlockLanguage: languageDef.language,
122
122
  label: languageDef.label,
123
123
  role: 'menuitemradio',
@@ -33,6 +33,7 @@ import type { CodeBlockLanguageDefinition } from './codeblockconfig.js';
33
33
  * @param useLabels When `true`, the `<pre>` element will get a `data-language` attribute with a
34
34
  * human–readable label of the language. Used only in the editing.
35
35
  * @returns Returns a conversion callback.
36
+ * @internal
36
37
  */
37
38
  export declare function modelToViewCodeBlockInsertion(model: Model, languageDefs: Array<CodeBlockLanguageDefinition>, useLabels?: boolean): GetCallback<DowncastInsertEvent>;
38
39
  /**
@@ -51,6 +52,7 @@ export declare function modelToViewCodeBlockInsertion(model: Model, languageDefs
51
52
  * ```
52
53
  *
53
54
  * @returns Returns a conversion callback.
55
+ * @internal
54
56
  */
55
57
  export declare function modelToDataViewSoftBreakInsertion(model: Model): GetCallback<DowncastInsertEvent>;
56
58
  /**
@@ -70,6 +72,7 @@ export declare function modelToDataViewSoftBreakInsertion(model: Model): GetCall
70
72
  *
71
73
  * @param languageDefs The normalized language configuration passed to the feature.
72
74
  * @returns Returns a conversion callback.
75
+ * @internal
73
76
  */
74
77
  export declare function dataViewToModelCodeBlockInsertion(editingView: EditingView, languageDefs: Array<CodeBlockLanguageDefinition>): GetCallback<UpcastElementEvent>;
75
78
  /**
@@ -88,6 +91,7 @@ export declare function dataViewToModelCodeBlockInsertion(editingView: EditingVi
88
91
  * ```
89
92
  *
90
93
  * @returns {Function} Returns a conversion callback.
94
+ * @internal
91
95
  */
92
96
  export declare function dataViewToModelTextNewlinesInsertion(): GetCallback<UpcastTextEvent>;
93
97
  /**
@@ -122,5 +126,6 @@ export declare function dataViewToModelTextNewlinesInsertion(): GetCallback<Upca
122
126
  * ```
123
127
  *
124
128
  * @returns Returns a conversion callback.
129
+ * @internal
125
130
  */
126
131
  export declare function dataViewToModelOrphanNodeConsumer(): GetCallback<UpcastElementEvent>;
package/src/converters.js CHANGED
@@ -28,6 +28,7 @@ import { getPropertyAssociation } from './utils.js';
28
28
  * @param useLabels When `true`, the `<pre>` element will get a `data-language` attribute with a
29
29
  * human–readable label of the language. Used only in the editing.
30
30
  * @returns Returns a conversion callback.
31
+ * @internal
31
32
  */
32
33
  export function modelToViewCodeBlockInsertion(model, languageDefs, useLabels = false) {
33
34
  // Language CSS classes:
@@ -86,6 +87,7 @@ export function modelToViewCodeBlockInsertion(model, languageDefs, useLabels = f
86
87
  * ```
87
88
  *
88
89
  * @returns Returns a conversion callback.
90
+ * @internal
89
91
  */
90
92
  export function modelToDataViewSoftBreakInsertion(model) {
91
93
  return (evt, data, conversionApi) => {
@@ -117,6 +119,7 @@ export function modelToDataViewSoftBreakInsertion(model) {
117
119
  *
118
120
  * @param languageDefs The normalized language configuration passed to the feature.
119
121
  * @returns Returns a conversion callback.
122
+ * @internal
120
123
  */
121
124
  export function dataViewToModelCodeBlockInsertion(editingView, languageDefs) {
122
125
  // Language names associated with CSS classes:
@@ -156,6 +159,7 @@ export function dataViewToModelCodeBlockInsertion(editingView, languageDefs) {
156
159
  for (const className of viewChildClasses) {
157
160
  const language = classesToLanguages[className];
158
161
  if (language) {
162
+ consumable.consume(viewCodeElement, { classes: [className] });
159
163
  writer.setAttribute('language', language, codeBlock);
160
164
  break;
161
165
  }
@@ -191,6 +195,7 @@ export function dataViewToModelCodeBlockInsertion(editingView, languageDefs) {
191
195
  * ```
192
196
  *
193
197
  * @returns {Function} Returns a conversion callback.
198
+ * @internal
194
199
  */
195
200
  export function dataViewToModelTextNewlinesInsertion() {
196
201
  return (evt, data, { consumable, writer }) => {
@@ -252,6 +257,7 @@ export function dataViewToModelTextNewlinesInsertion() {
252
257
  * ```
253
258
  *
254
259
  * @returns Returns a conversion callback.
260
+ * @internal
255
261
  */
256
262
  export function dataViewToModelOrphanNodeConsumer() {
257
263
  return (evt, data, { consumable }) => {
@@ -9,7 +9,7 @@ import { Command, type Editor } from 'ckeditor5/src/core.js';
9
9
  /**
10
10
  * The code block indentation increase command plugin.
11
11
  */
12
- export default class IndentCodeBlockCommand extends Command {
12
+ export declare class IndentCodeBlockCommand extends Command {
13
13
  /**
14
14
  * A sequence of characters added to the line when the command is executed.
15
15
  */
@@ -10,7 +10,7 @@ import { getIndentOutdentPositions, isModelSelectionInCodeBlock } from './utils.
10
10
  /**
11
11
  * The code block indentation increase command plugin.
12
12
  */
13
- export default class IndentCodeBlockCommand extends Command {
13
+ export class IndentCodeBlockCommand extends Command {
14
14
  /**
15
15
  * A sequence of characters added to the line when the command is executed.
16
16
  */
package/src/index.d.ts CHANGED
@@ -5,11 +5,13 @@
5
5
  /**
6
6
  * @module code-block
7
7
  */
8
- export { default as CodeBlock } from './codeblock.js';
9
- export { default as CodeBlockEditing } from './codeblockediting.js';
10
- export { default as CodeBlockUI } from './codeblockui.js';
11
- export type { default as CodeBlockCommand } from './codeblockcommand.js';
12
- export type { default as IndentCodeBlockCommand } from './indentcodeblockcommand.js';
13
- export type { default as OutdentCodeBlockCommand } from './outdentcodeblockcommand.js';
14
- export type { CodeBlockConfig } from './codeblockconfig.js';
8
+ export { CodeBlock } from './codeblock.js';
9
+ export { CodeBlockEditing } from './codeblockediting.js';
10
+ export { CodeBlockUI } from './codeblockui.js';
11
+ export { CodeBlockCommand } from './codeblockcommand.js';
12
+ export { IndentCodeBlockCommand } from './indentcodeblockcommand.js';
13
+ export { OutdentCodeBlockCommand } from './outdentcodeblockcommand.js';
14
+ export type { CodeBlockConfig, CodeBlockLanguageDefinition } from './codeblockconfig.js';
15
+ export { modelToViewCodeBlockInsertion as _modelToViewCodeBlockInsertion, modelToDataViewSoftBreakInsertion as _modelToDataViewCodeBlockSoftBreakInsertion, dataViewToModelCodeBlockInsertion as _dataViewToModelCodeBlockInsertion, dataViewToModelTextNewlinesInsertion as _dataViewToModelCodeBlockTextNewlinesInsertion, dataViewToModelOrphanNodeConsumer as _dataViewToModelCodeBlockOrphanNodeConsumer } from './converters.js';
16
+ export { getNormalizedAndLocalizedLanguageDefinitions as _getNormalizedAndLocalizedCodeBlockLanguageDefinitions, getPropertyAssociation as _getCodeBlockPropertyAssociation, getLeadingWhiteSpaces as _getCodeBlockLeadingWhiteSpaces, rawSnippetTextToViewDocumentFragment as _rawCodeBlockSnippetTextToViewDocumentFragment, getIndentOutdentPositions as _getCodeBlockIndentOutdentPositions, isModelSelectionInCodeBlock as _isModelSelectionInCodeBlock, canBeCodeBlock as _canBeCodeBlock, getCodeBlockAriaAnnouncement as _getCodeBlockAriaAnnouncement, getTextNodeAtLineStart as _getCodeBlockTextNodeAtLineStart } from './utils.js';
15
17
  import './augmentation.js';
package/src/index.js CHANGED
@@ -5,7 +5,12 @@
5
5
  /**
6
6
  * @module code-block
7
7
  */
8
- export { default as CodeBlock } from './codeblock.js';
9
- export { default as CodeBlockEditing } from './codeblockediting.js';
10
- export { default as CodeBlockUI } from './codeblockui.js';
8
+ export { CodeBlock } from './codeblock.js';
9
+ export { CodeBlockEditing } from './codeblockediting.js';
10
+ export { CodeBlockUI } from './codeblockui.js';
11
+ export { CodeBlockCommand } from './codeblockcommand.js';
12
+ export { IndentCodeBlockCommand } from './indentcodeblockcommand.js';
13
+ export { OutdentCodeBlockCommand } from './outdentcodeblockcommand.js';
14
+ export { modelToViewCodeBlockInsertion as _modelToViewCodeBlockInsertion, modelToDataViewSoftBreakInsertion as _modelToDataViewCodeBlockSoftBreakInsertion, dataViewToModelCodeBlockInsertion as _dataViewToModelCodeBlockInsertion, dataViewToModelTextNewlinesInsertion as _dataViewToModelCodeBlockTextNewlinesInsertion, dataViewToModelOrphanNodeConsumer as _dataViewToModelCodeBlockOrphanNodeConsumer } from './converters.js';
15
+ export { getNormalizedAndLocalizedLanguageDefinitions as _getNormalizedAndLocalizedCodeBlockLanguageDefinitions, getPropertyAssociation as _getCodeBlockPropertyAssociation, getLeadingWhiteSpaces as _getCodeBlockLeadingWhiteSpaces, rawSnippetTextToViewDocumentFragment as _rawCodeBlockSnippetTextToViewDocumentFragment, getIndentOutdentPositions as _getCodeBlockIndentOutdentPositions, isModelSelectionInCodeBlock as _isModelSelectionInCodeBlock, canBeCodeBlock as _canBeCodeBlock, getCodeBlockAriaAnnouncement as _getCodeBlockAriaAnnouncement, getTextNodeAtLineStart as _getCodeBlockTextNodeAtLineStart } from './utils.js';
11
16
  import './augmentation.js';
@@ -6,7 +6,7 @@ import { Command, type Editor } from 'ckeditor5/src/core.js';
6
6
  /**
7
7
  * The code block indentation decrease command plugin.
8
8
  */
9
- export default class OutdentCodeBlockCommand extends Command {
9
+ export declare class OutdentCodeBlockCommand extends Command {
10
10
  /**
11
11
  * A sequence of characters removed from the line when the command is executed.
12
12
  */
@@ -7,7 +7,7 @@ import { getLeadingWhiteSpaces, getIndentOutdentPositions, isModelSelectionInCod
7
7
  /**
8
8
  * The code block indentation decrease command plugin.
9
9
  */
10
- export default class OutdentCodeBlockCommand extends Command {
10
+ export class OutdentCodeBlockCommand extends Command {
11
11
  /**
12
12
  * A sequence of characters removed from the line when the command is executed.
13
13
  */
@@ -100,9 +100,9 @@ export default class OutdentCodeBlockCommand extends Command {
100
100
  // <codeBlock> ^foo bar</codeBlock> -> <codeBlock>[ ]foo bar</codeBlock>
101
101
  //
102
102
  // @param {<module:engine/model/model~Model>} model
103
- // @param {<module:engine/model/position~Position>} position
103
+ // @param {<module:engine/model/position~ModelPosition>} position
104
104
  // @param {String} sequence
105
- // @returns {<module:engine/model/range~Range>|null}
105
+ // @returns {<module:engine/model/range~ModelRange>|null}
106
106
  function getLastOutdentableSequenceRange(model, position, sequence) {
107
107
  // Positions start before each text node (code line). Get the node corresponding to the position.
108
108
  const nodeAtPosition = getTextNodeAtLineStart(position, model);
package/src/utils.d.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import type { Editor } from 'ckeditor5/src/core.js';
9
9
  import type { CodeBlockLanguageDefinition } from './codeblockconfig.js';
10
- import type { DocumentSelection, Element, Model, Position, Schema, Text, UpcastWriter, ViewDocumentFragment } from 'ckeditor5/src/engine.js';
10
+ import type { ModelDocumentSelection, ModelElement, Model, ModelPosition, ModelSchema, ModelText, ViewUpcastWriter, ViewDocumentFragment } from 'ckeditor5/src/engine.js';
11
11
  import { type LocaleTranslate } from 'ckeditor5/src/utils.js';
12
12
  /**
13
13
  * Returns code block languages as defined in `config.codeBlock.languages` but processed:
@@ -17,6 +17,8 @@ import { type LocaleTranslate } from 'ckeditor5/src/utils.js';
17
17
  * configuration is defined because the editor does not exist yet.
18
18
  * * To make sure each definition has a CSS class associated with it even if not specified
19
19
  * in the original configuration.
20
+ *
21
+ * @internal
20
22
  */
21
23
  export declare function getNormalizedAndLocalizedLanguageDefinitions(editor: Editor): Array<CodeBlockLanguageDefinition>;
22
24
  /**
@@ -56,13 +58,17 @@ export declare function getNormalizedAndLocalizedLanguageDefinitions(editor: Edi
56
58
  * 'javascript': 'JavaScript'
57
59
  * }
58
60
  * ```
61
+ *
62
+ * @internal
59
63
  */
60
64
  export declare function getPropertyAssociation(languageDefs: Array<CodeBlockLanguageDefinition>, key: keyof CodeBlockLanguageDefinition, value: keyof CodeBlockLanguageDefinition): Record<string, string>;
61
65
  /**
62
66
  * For a given model text node, it returns white spaces that precede other characters in that node.
63
67
  * This corresponds to the indentation part of the code block line.
68
+ *
69
+ * @internal
64
70
  */
65
- export declare function getLeadingWhiteSpaces(textNode: Text): string;
71
+ export declare function getLeadingWhiteSpaces(textNode: ModelText): string;
66
72
  /**
67
73
  * For plain text containing the code (a snippet), it returns a document fragment containing
68
74
  * view text nodes separated by `<br>` elements (in place of new line characters "\n"), for instance:
@@ -85,8 +91,9 @@ export declare function getLeadingWhiteSpaces(textNode: Text): string;
85
91
  * ```
86
92
  *
87
93
  * @param text The raw code text to be converted.
94
+ * @internal
88
95
  */
89
- export declare function rawSnippetTextToViewDocumentFragment(writer: UpcastWriter, text: string): ViewDocumentFragment;
96
+ export declare function rawSnippetTextToViewDocumentFragment(writer: ViewUpcastWriter, text: string): ViewDocumentFragment;
90
97
  /**
91
98
  * Returns an array of all model positions within the selection that represent code block lines.
92
99
  *
@@ -123,24 +130,31 @@ export declare function rawSnippetTextToViewDocumentFragment(writer: UpcastWrite
123
130
  * the writer inserts or removes elements at the same time.
124
131
  *
125
132
  * **Note:** The position is located after the leading white spaces in the text node.
133
+ *
134
+ * @internal
126
135
  */
127
- export declare function getIndentOutdentPositions(model: Model): Array<Position>;
136
+ export declare function getIndentOutdentPositions(model: Model): Array<ModelPosition>;
128
137
  /**
129
138
  * Checks if any of the blocks within the model selection is a code block.
139
+ *
140
+ * @internal
130
141
  */
131
- export declare function isModelSelectionInCodeBlock(selection: DocumentSelection): boolean;
142
+ export declare function isModelSelectionInCodeBlock(selection: ModelDocumentSelection): boolean;
132
143
  /**
133
- * Checks if an {@link module:engine/model/element~Element Element} can become a code block.
144
+ * Checks if an {@link module:engine/model/element~ModelElement Element} can become a code block.
134
145
  *
135
146
  * @param schema Model's schema.
136
147
  * @param element The element to be checked.
137
148
  * @returns Check result.
149
+ * @internal
138
150
  */
139
- export declare function canBeCodeBlock(schema: Schema, element: Element): boolean;
151
+ export declare function canBeCodeBlock(schema: ModelSchema, element: ModelElement): boolean;
140
152
  /**
141
153
  * Get the translated message read by the screen reader when you enter or exit an element with your cursor.
154
+ *
155
+ * @internal
142
156
  */
143
- export declare function getCodeBlockAriaAnnouncement(t: LocaleTranslate, languageDefs: Array<CodeBlockLanguageDefinition>, element: Element, direction: 'enter' | 'leave'): string;
157
+ export declare function getCodeBlockAriaAnnouncement(t: LocaleTranslate, languageDefs: Array<CodeBlockLanguageDefinition>, element: ModelElement, direction: 'enter' | 'leave'): string;
144
158
  /**
145
159
  * For given position, finds the closest position that is at the beginning of a line of code and returns a text node that is at the
146
160
  * beginning of the line (or `null` if there's no text node at the beginning of a given line).
@@ -173,5 +187,7 @@ export declare function getCodeBlockAriaAnnouncement(t: LocaleTranslate, languag
173
187
  * <codeBlock>foo<softBreak />bar<element />^</codeBlock> -> <codeBlock>foo<softBreak />[bar]<element /></codeBlock>
174
188
  * <codeBlock>foo<softBreak /><element />ba^r</codeBlock> -> null
175
189
  * ```
190
+ *
191
+ * @internal
176
192
  */
177
- export declare function getTextNodeAtLineStart(position: Position, model: Model): Text | null;
193
+ export declare function getTextNodeAtLineStart(position: ModelPosition, model: Model): ModelText | null;
package/src/utils.js CHANGED
@@ -11,6 +11,8 @@ import { first } from 'ckeditor5/src/utils.js';
11
11
  * configuration is defined because the editor does not exist yet.
12
12
  * * To make sure each definition has a CSS class associated with it even if not specified
13
13
  * in the original configuration.
14
+ *
15
+ * @internal
14
16
  */
15
17
  export function getNormalizedAndLocalizedLanguageDefinitions(editor) {
16
18
  const t = editor.t;
@@ -62,6 +64,8 @@ export function getNormalizedAndLocalizedLanguageDefinitions(editor) {
62
64
  * 'javascript': 'JavaScript'
63
65
  * }
64
66
  * ```
67
+ *
68
+ * @internal
65
69
  */
66
70
  export function getPropertyAssociation(languageDefs, key, value) {
67
71
  const association = {};
@@ -80,6 +84,8 @@ export function getPropertyAssociation(languageDefs, key, value) {
80
84
  /**
81
85
  * For a given model text node, it returns white spaces that precede other characters in that node.
82
86
  * This corresponds to the indentation part of the code block line.
87
+ *
88
+ * @internal
83
89
  */
84
90
  export function getLeadingWhiteSpaces(textNode) {
85
91
  return textNode.data.match(/^(\s*)/)[0];
@@ -106,6 +112,7 @@ export function getLeadingWhiteSpaces(textNode) {
106
112
  * ```
107
113
  *
108
114
  * @param text The raw code text to be converted.
115
+ * @internal
109
116
  */
110
117
  export function rawSnippetTextToViewDocumentFragment(writer, text) {
111
118
  const fragment = writer.createDocumentFragment();
@@ -156,6 +163,8 @@ export function rawSnippetTextToViewDocumentFragment(writer, text) {
156
163
  * the writer inserts or removes elements at the same time.
157
164
  *
158
165
  * **Note:** The position is located after the leading white spaces in the text node.
166
+ *
167
+ * @internal
159
168
  */
160
169
  export function getIndentOutdentPositions(model) {
161
170
  const selection = model.document.selection;
@@ -195,17 +204,20 @@ export function getIndentOutdentPositions(model) {
195
204
  }
196
205
  /**
197
206
  * Checks if any of the blocks within the model selection is a code block.
207
+ *
208
+ * @internal
198
209
  */
199
210
  export function isModelSelectionInCodeBlock(selection) {
200
211
  const firstBlock = first(selection.getSelectedBlocks());
201
212
  return !!firstBlock && firstBlock.is('element', 'codeBlock');
202
213
  }
203
214
  /**
204
- * Checks if an {@link module:engine/model/element~Element Element} can become a code block.
215
+ * Checks if an {@link module:engine/model/element~ModelElement Element} can become a code block.
205
216
  *
206
217
  * @param schema Model's schema.
207
218
  * @param element The element to be checked.
208
219
  * @returns Check result.
220
+ * @internal
209
221
  */
210
222
  export function canBeCodeBlock(schema, element) {
211
223
  if (element.is('rootElement') || schema.isLimit(element)) {
@@ -215,6 +227,8 @@ export function canBeCodeBlock(schema, element) {
215
227
  }
216
228
  /**
217
229
  * Get the translated message read by the screen reader when you enter or exit an element with your cursor.
230
+ *
231
+ * @internal
218
232
  */
219
233
  export function getCodeBlockAriaAnnouncement(t, languageDefs, element, direction) {
220
234
  const languagesToLabels = getPropertyAssociation(languageDefs, 'language', 'label');
@@ -263,6 +277,8 @@ export function getCodeBlockAriaAnnouncement(t, languageDefs, element, direction
263
277
  * <codeBlock>foo<softBreak />bar<element />^</codeBlock> -> <codeBlock>foo<softBreak />[bar]<element /></codeBlock>
264
278
  * <codeBlock>foo<softBreak /><element />ba^r</codeBlock> -> null
265
279
  * ```
280
+ *
281
+ * @internal
266
282
  */
267
283
  export function getTextNodeAtLineStart(position, model) {
268
284
  // First, move position before a text node, if it is inside a text node.