@ckeditor/ckeditor5-code-block 41.3.0-alpha.4 → 41.3.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/build/code-block.js +2 -2
- package/build/translations/af.js +1 -1
- package/build/translations/ar.js +1 -1
- package/build/translations/az.js +1 -1
- package/build/translations/bg.js +1 -1
- package/build/translations/bn.js +1 -1
- package/build/translations/bs.js +1 -1
- package/build/translations/ca.js +1 -1
- package/build/translations/cs.js +1 -1
- package/build/translations/da.js +1 -1
- package/build/translations/de-ch.js +1 -1
- package/build/translations/de.js +1 -1
- package/build/translations/el.js +1 -1
- package/build/translations/en-au.js +1 -1
- package/build/translations/es-co.js +1 -1
- package/build/translations/es.js +1 -1
- package/build/translations/et.js +1 -1
- package/build/translations/fa.js +1 -1
- package/build/translations/fi.js +1 -1
- package/build/translations/fr.js +1 -1
- package/build/translations/gl.js +1 -1
- package/build/translations/he.js +1 -1
- package/build/translations/hi.js +1 -1
- package/build/translations/hr.js +1 -1
- package/build/translations/hu.js +1 -1
- package/build/translations/id.js +1 -1
- package/build/translations/it.js +1 -1
- package/build/translations/ja.js +1 -1
- package/build/translations/jv.js +1 -1
- package/build/translations/ko.js +1 -1
- package/build/translations/ku.js +1 -1
- package/build/translations/lt.js +1 -1
- package/build/translations/lv.js +1 -1
- package/build/translations/ms.js +1 -1
- package/build/translations/nl.js +1 -1
- package/build/translations/no.js +1 -1
- package/build/translations/pl.js +1 -1
- package/build/translations/pt-br.js +1 -1
- package/build/translations/pt.js +1 -1
- package/build/translations/ro.js +1 -1
- package/build/translations/ru.js +1 -1
- package/build/translations/sk.js +1 -1
- package/build/translations/sq.js +1 -1
- package/build/translations/sr-latn.js +1 -1
- package/build/translations/sr.js +1 -1
- package/build/translations/sv.js +1 -1
- package/build/translations/th.js +1 -1
- package/build/translations/tk.js +1 -1
- package/build/translations/tr.js +1 -1
- package/build/translations/ug.js +1 -1
- package/build/translations/uk.js +1 -1
- package/build/translations/ur.js +1 -1
- package/build/translations/uz.js +1 -1
- package/build/translations/vi.js +1 -1
- package/build/translations/zh-cn.js +1 -1
- package/build/translations/zh.js +1 -1
- package/lang/contexts.json +2 -1
- package/lang/translations/af.po +4 -0
- package/lang/translations/ar.po +4 -0
- package/lang/translations/az.po +4 -0
- package/lang/translations/bg.po +4 -0
- package/lang/translations/bn.po +4 -0
- package/lang/translations/bs.po +4 -0
- package/lang/translations/ca.po +4 -0
- package/lang/translations/cs.po +4 -0
- package/lang/translations/da.po +4 -0
- package/lang/translations/de-ch.po +4 -0
- package/lang/translations/de.po +4 -0
- package/lang/translations/el.po +4 -0
- package/lang/translations/en-au.po +4 -0
- package/lang/translations/en.po +4 -0
- package/lang/translations/es-co.po +4 -0
- package/lang/translations/es.po +4 -0
- package/lang/translations/et.po +4 -0
- package/lang/translations/fa.po +4 -0
- package/lang/translations/fi.po +4 -0
- package/lang/translations/fr.po +4 -0
- package/lang/translations/gl.po +4 -0
- package/lang/translations/he.po +4 -0
- package/lang/translations/hi.po +4 -0
- package/lang/translations/hr.po +4 -0
- package/lang/translations/hu.po +4 -0
- package/lang/translations/id.po +4 -0
- package/lang/translations/it.po +4 -0
- package/lang/translations/ja.po +4 -0
- package/lang/translations/jv.po +4 -0
- package/lang/translations/ko.po +4 -0
- package/lang/translations/ku.po +4 -0
- package/lang/translations/lt.po +4 -0
- package/lang/translations/lv.po +4 -0
- package/lang/translations/ms.po +4 -0
- package/lang/translations/nl.po +4 -0
- package/lang/translations/no.po +4 -0
- package/lang/translations/pl.po +4 -0
- package/lang/translations/pt-br.po +4 -0
- package/lang/translations/pt.po +4 -0
- package/lang/translations/ro.po +4 -0
- package/lang/translations/ru.po +4 -0
- package/lang/translations/sk.po +4 -0
- package/lang/translations/sq.po +4 -0
- package/lang/translations/sr-latn.po +4 -0
- package/lang/translations/sr.po +4 -0
- package/lang/translations/sv.po +4 -0
- package/lang/translations/th.po +4 -0
- package/lang/translations/tk.po +4 -0
- package/lang/translations/tr.po +4 -0
- package/lang/translations/ug.po +4 -0
- package/lang/translations/uk.po +4 -0
- package/lang/translations/ur.po +4 -0
- package/lang/translations/uz.po +4 -0
- package/lang/translations/vi.po +4 -0
- package/lang/translations/zh-cn.po +4 -0
- package/lang/translations/zh.po +4 -0
- package/package.json +2 -3
- package/src/codeblockui.js +34 -3
- package/dist/content-index.css +0 -22
- package/dist/editor-index.css +0 -11
- package/dist/index.css +0 -46
- package/dist/index.css.map +0 -1
- package/dist/translations/af.d.ts +0 -8
- package/dist/translations/af.js +0 -5
- package/dist/translations/ar.d.ts +0 -8
- package/dist/translations/ar.js +0 -5
- package/dist/translations/az.d.ts +0 -8
- package/dist/translations/az.js +0 -5
- package/dist/translations/bg.d.ts +0 -8
- package/dist/translations/bg.js +0 -5
- package/dist/translations/bn.d.ts +0 -8
- package/dist/translations/bn.js +0 -5
- package/dist/translations/bs.d.ts +0 -8
- package/dist/translations/bs.js +0 -5
- package/dist/translations/ca.d.ts +0 -8
- package/dist/translations/ca.js +0 -5
- package/dist/translations/cs.d.ts +0 -8
- package/dist/translations/cs.js +0 -5
- package/dist/translations/da.d.ts +0 -8
- package/dist/translations/da.js +0 -5
- package/dist/translations/de-ch.d.ts +0 -8
- package/dist/translations/de-ch.js +0 -5
- package/dist/translations/de.d.ts +0 -8
- package/dist/translations/de.js +0 -5
- package/dist/translations/el.d.ts +0 -8
- package/dist/translations/el.js +0 -5
- package/dist/translations/en-au.d.ts +0 -8
- package/dist/translations/en-au.js +0 -5
- package/dist/translations/en.d.ts +0 -8
- package/dist/translations/en.js +0 -5
- package/dist/translations/es-co.d.ts +0 -8
- package/dist/translations/es-co.js +0 -5
- package/dist/translations/es.d.ts +0 -8
- package/dist/translations/es.js +0 -5
- package/dist/translations/et.d.ts +0 -8
- package/dist/translations/et.js +0 -5
- package/dist/translations/fa.d.ts +0 -8
- package/dist/translations/fa.js +0 -5
- package/dist/translations/fi.d.ts +0 -8
- package/dist/translations/fi.js +0 -5
- package/dist/translations/fr.d.ts +0 -8
- package/dist/translations/fr.js +0 -5
- package/dist/translations/gl.d.ts +0 -8
- package/dist/translations/gl.js +0 -5
- package/dist/translations/he.d.ts +0 -8
- package/dist/translations/he.js +0 -5
- package/dist/translations/hi.d.ts +0 -8
- package/dist/translations/hi.js +0 -5
- package/dist/translations/hr.d.ts +0 -8
- package/dist/translations/hr.js +0 -5
- package/dist/translations/hu.d.ts +0 -8
- package/dist/translations/hu.js +0 -5
- package/dist/translations/id.d.ts +0 -8
- package/dist/translations/id.js +0 -5
- package/dist/translations/it.d.ts +0 -8
- package/dist/translations/it.js +0 -5
- package/dist/translations/ja.d.ts +0 -8
- package/dist/translations/ja.js +0 -5
- package/dist/translations/jv.d.ts +0 -8
- package/dist/translations/jv.js +0 -5
- package/dist/translations/ko.d.ts +0 -8
- package/dist/translations/ko.js +0 -5
- package/dist/translations/ku.d.ts +0 -8
- package/dist/translations/ku.js +0 -5
- package/dist/translations/lt.d.ts +0 -8
- package/dist/translations/lt.js +0 -5
- package/dist/translations/lv.d.ts +0 -8
- package/dist/translations/lv.js +0 -5
- package/dist/translations/ms.d.ts +0 -8
- package/dist/translations/ms.js +0 -5
- package/dist/translations/nl.d.ts +0 -8
- package/dist/translations/nl.js +0 -5
- package/dist/translations/no.d.ts +0 -8
- package/dist/translations/no.js +0 -5
- package/dist/translations/pl.d.ts +0 -8
- package/dist/translations/pl.js +0 -5
- package/dist/translations/pt-br.d.ts +0 -8
- package/dist/translations/pt-br.js +0 -5
- package/dist/translations/pt.d.ts +0 -8
- package/dist/translations/pt.js +0 -5
- package/dist/translations/ro.d.ts +0 -8
- package/dist/translations/ro.js +0 -5
- package/dist/translations/ru.d.ts +0 -8
- package/dist/translations/ru.js +0 -5
- package/dist/translations/sk.d.ts +0 -8
- package/dist/translations/sk.js +0 -5
- package/dist/translations/sq.d.ts +0 -8
- package/dist/translations/sq.js +0 -5
- package/dist/translations/sr-latn.d.ts +0 -8
- package/dist/translations/sr-latn.js +0 -5
- package/dist/translations/sr.d.ts +0 -8
- package/dist/translations/sr.js +0 -5
- package/dist/translations/sv.d.ts +0 -8
- package/dist/translations/sv.js +0 -5
- package/dist/translations/th.d.ts +0 -8
- package/dist/translations/th.js +0 -5
- package/dist/translations/tk.d.ts +0 -8
- package/dist/translations/tk.js +0 -5
- package/dist/translations/tr.d.ts +0 -8
- package/dist/translations/tr.js +0 -5
- package/dist/translations/ug.d.ts +0 -8
- package/dist/translations/ug.js +0 -5
- package/dist/translations/uk.d.ts +0 -8
- package/dist/translations/uk.js +0 -5
- package/dist/translations/ur.d.ts +0 -8
- package/dist/translations/ur.js +0 -5
- package/dist/translations/uz.d.ts +0 -8
- package/dist/translations/uz.js +0 -5
- package/dist/translations/vi.d.ts +0 -8
- package/dist/translations/vi.js +0 -5
- package/dist/translations/zh-cn.d.ts +0 -8
- package/dist/translations/zh-cn.js +0 -5
- package/dist/translations/zh.d.ts +0 -8
- package/dist/translations/zh.js +0 -5
- package/dist/types/augmentation.d.ts +0 -29
- package/dist/types/codeblock.d.ts +0 -33
- package/dist/types/codeblockcommand.d.ts +0 -64
- package/dist/types/codeblockconfig.d.ts +0 -150
- package/dist/types/codeblockediting.d.ts +0 -40
- package/dist/types/codeblockui.d.ts +0 -33
- package/dist/types/converters.d.ts +0 -130
- package/dist/types/indentcodeblockcommand.d.ts +0 -37
- package/dist/types/index.d.ts +0 -19
- package/dist/types/outdentcodeblockcommand.d.ts +0 -37
- package/dist/types/utils.d.ts +0 -142
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2024, 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
|
-
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* @module code-block/converters
|
|
11
|
-
*/
|
|
12
|
-
import type { GetCallback } from 'ckeditor5/src/utils.js';
|
|
13
|
-
import type { DowncastInsertEvent, Model, UpcastElementEvent, UpcastTextEvent, EditingView } from 'ckeditor5/src/engine.js';
|
|
14
|
-
import type { CodeBlockLanguageDefinition } from './codeblockconfig.js';
|
|
15
|
-
/**
|
|
16
|
-
* A model-to-view (both editing and data) converter for the `codeBlock` element.
|
|
17
|
-
*
|
|
18
|
-
* Sample input:
|
|
19
|
-
*
|
|
20
|
-
* ```html
|
|
21
|
-
* <codeBlock language="javascript">foo();<softBreak></softBreak>bar();</codeBlock>
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* Sample output (editing):
|
|
25
|
-
*
|
|
26
|
-
* ```html
|
|
27
|
-
* <pre data-language="JavaScript"><code class="language-javascript">foo();<br />bar();</code></pre>
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* Sample output (data, see {@link module:code-block/converters~modelToDataViewSoftBreakInsertion}):
|
|
31
|
-
*
|
|
32
|
-
* ```html
|
|
33
|
-
* <pre><code class="language-javascript">foo();\nbar();</code></pre>
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @param languageDefs The normalized language configuration passed to the feature.
|
|
37
|
-
* @param useLabels When `true`, the `<pre>` element will get a `data-language` attribute with a
|
|
38
|
-
* human–readable label of the language. Used only in the editing.
|
|
39
|
-
* @returns Returns a conversion callback.
|
|
40
|
-
*/
|
|
41
|
-
export declare function modelToViewCodeBlockInsertion(model: Model, languageDefs: Array<CodeBlockLanguageDefinition>, useLabels?: boolean): GetCallback<DowncastInsertEvent>;
|
|
42
|
-
/**
|
|
43
|
-
* A model-to-data view converter for the new line (`softBreak`) separator.
|
|
44
|
-
*
|
|
45
|
-
* Sample input:
|
|
46
|
-
*
|
|
47
|
-
* ```html
|
|
48
|
-
* <codeBlock ...>foo();<softBreak></softBreak>bar();</codeBlock>
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* Sample output:
|
|
52
|
-
*
|
|
53
|
-
* ```html
|
|
54
|
-
* <pre><code ...>foo();\nbar();</code></pre>
|
|
55
|
-
* ```
|
|
56
|
-
*
|
|
57
|
-
* @returns Returns a conversion callback.
|
|
58
|
-
*/
|
|
59
|
-
export declare function modelToDataViewSoftBreakInsertion(model: Model): GetCallback<DowncastInsertEvent>;
|
|
60
|
-
/**
|
|
61
|
-
* A view-to-model converter for `<pre>` with the `<code>` HTML.
|
|
62
|
-
*
|
|
63
|
-
* Sample input:
|
|
64
|
-
*
|
|
65
|
-
* ```html
|
|
66
|
-
* <pre><code class="language-javascript">foo();bar();</code></pre>
|
|
67
|
-
* ```
|
|
68
|
-
*
|
|
69
|
-
* Sample output:
|
|
70
|
-
*
|
|
71
|
-
* ```html
|
|
72
|
-
* <codeBlock language="javascript">foo();bar();</codeBlock>
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* @param languageDefs The normalized language configuration passed to the feature.
|
|
76
|
-
* @returns Returns a conversion callback.
|
|
77
|
-
*/
|
|
78
|
-
export declare function dataViewToModelCodeBlockInsertion(editingView: EditingView, languageDefs: Array<CodeBlockLanguageDefinition>): GetCallback<UpcastElementEvent>;
|
|
79
|
-
/**
|
|
80
|
-
* A view-to-model converter for new line characters in `<pre>`.
|
|
81
|
-
*
|
|
82
|
-
* Sample input:
|
|
83
|
-
*
|
|
84
|
-
* ```html
|
|
85
|
-
* <pre><code class="language-javascript">foo();\nbar();</code></pre>
|
|
86
|
-
* ```
|
|
87
|
-
*
|
|
88
|
-
* Sample output:
|
|
89
|
-
*
|
|
90
|
-
* ```html
|
|
91
|
-
* <codeBlock language="javascript">foo();<softBreak></softBreak>bar();</codeBlock>
|
|
92
|
-
* ```
|
|
93
|
-
*
|
|
94
|
-
* @returns {Function} Returns a conversion callback.
|
|
95
|
-
*/
|
|
96
|
-
export declare function dataViewToModelTextNewlinesInsertion(): GetCallback<UpcastTextEvent>;
|
|
97
|
-
/**
|
|
98
|
-
* A view-to-model converter that handles orphan text nodes (white spaces, new lines, etc.)
|
|
99
|
-
* that surround `<code>` inside `<pre>`.
|
|
100
|
-
*
|
|
101
|
-
* Sample input:
|
|
102
|
-
*
|
|
103
|
-
* ```html
|
|
104
|
-
* // White spaces
|
|
105
|
-
* <pre> <code>foo()</code> </pre>
|
|
106
|
-
*
|
|
107
|
-
* // White spaces
|
|
108
|
-
* <pre> <code>foo()</code> </pre>
|
|
109
|
-
*
|
|
110
|
-
* // White spaces
|
|
111
|
-
* <pre> <code>foo()</code> </pre>
|
|
112
|
-
*
|
|
113
|
-
* // New lines
|
|
114
|
-
* <pre>
|
|
115
|
-
* <code>foo()</code>
|
|
116
|
-
* </pre>
|
|
117
|
-
*
|
|
118
|
-
* // Redundant text
|
|
119
|
-
* <pre>ABC<code>foo()</code>DEF</pre>
|
|
120
|
-
* ```
|
|
121
|
-
*
|
|
122
|
-
* Unified output for each case:
|
|
123
|
-
*
|
|
124
|
-
* ```html
|
|
125
|
-
* <codeBlock language="plaintext">foo()</codeBlock>
|
|
126
|
-
* ```
|
|
127
|
-
*
|
|
128
|
-
* @returns Returns a conversion callback.
|
|
129
|
-
*/
|
|
130
|
-
export declare function dataViewToModelOrphanNodeConsumer(): GetCallback<UpcastElementEvent>;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2024, 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
|
-
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* @module code-block/indentcodeblockcommand
|
|
11
|
-
*/
|
|
12
|
-
import { Command, type Editor } from 'ckeditor5/src/core.js';
|
|
13
|
-
/**
|
|
14
|
-
* The code block indentation increase command plugin.
|
|
15
|
-
*/
|
|
16
|
-
export default class IndentCodeBlockCommand extends Command {
|
|
17
|
-
/**
|
|
18
|
-
* A sequence of characters added to the line when the command is executed.
|
|
19
|
-
*/
|
|
20
|
-
private _indentSequence;
|
|
21
|
-
constructor(editor: Editor);
|
|
22
|
-
/**
|
|
23
|
-
* @inheritDoc
|
|
24
|
-
*/
|
|
25
|
-
refresh(): void;
|
|
26
|
-
/**
|
|
27
|
-
* Executes the command. When the command {@link #isEnabled is enabled}, the indentation of the
|
|
28
|
-
* code lines in the selection will be increased.
|
|
29
|
-
*
|
|
30
|
-
* @fires execute
|
|
31
|
-
*/
|
|
32
|
-
execute(): void;
|
|
33
|
-
/**
|
|
34
|
-
* Checks whether the command can be enabled in the current context.
|
|
35
|
-
*/
|
|
36
|
-
private _checkEnabled;
|
|
37
|
-
}
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2024, 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
|
-
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* @module code-block
|
|
11
|
-
*/
|
|
12
|
-
export { default as CodeBlock } from './codeblock.js';
|
|
13
|
-
export { default as CodeBlockEditing } from './codeblockediting.js';
|
|
14
|
-
export { default as CodeBlockUI } from './codeblockui.js';
|
|
15
|
-
export type { default as CodeBlockCommand } from './codeblockcommand.js';
|
|
16
|
-
export type { default as IndentCodeBlockCommand } from './indentcodeblockcommand.js';
|
|
17
|
-
export type { default as OutdentCodeBlockCommand } from './outdentcodeblockcommand.js';
|
|
18
|
-
export type { CodeBlockConfig } from './codeblockconfig.js';
|
|
19
|
-
import './augmentation.js';
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2024, 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
|
-
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
-
*/
|
|
9
|
-
import { Command, type Editor } from 'ckeditor5/src/core.js';
|
|
10
|
-
/**
|
|
11
|
-
* The code block indentation decrease command plugin.
|
|
12
|
-
*/
|
|
13
|
-
export default class OutdentCodeBlockCommand extends Command {
|
|
14
|
-
/**
|
|
15
|
-
* A sequence of characters removed from the line when the command is executed.
|
|
16
|
-
*/
|
|
17
|
-
private readonly _indentSequence;
|
|
18
|
-
constructor(editor: Editor);
|
|
19
|
-
/**
|
|
20
|
-
* @inheritDoc
|
|
21
|
-
*/
|
|
22
|
-
refresh(): void;
|
|
23
|
-
/**
|
|
24
|
-
* Executes the command. When the command {@link #isEnabled is enabled}, the indentation of the
|
|
25
|
-
* code lines in the selection will be decreased.
|
|
26
|
-
*
|
|
27
|
-
* @fires execute
|
|
28
|
-
*/
|
|
29
|
-
execute(): void;
|
|
30
|
-
/**
|
|
31
|
-
* Checks whether the command can be enabled in the current context.
|
|
32
|
-
*
|
|
33
|
-
* @private
|
|
34
|
-
* @returns {Boolean} Whether the command should be enabled.
|
|
35
|
-
*/
|
|
36
|
-
private _checkEnabled;
|
|
37
|
-
}
|
package/dist/types/utils.d.ts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2024, 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
|
-
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
7
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* @module code-block/utils
|
|
11
|
-
*/
|
|
12
|
-
import type { Editor } from 'ckeditor5/src/core.js';
|
|
13
|
-
import type { CodeBlockLanguageDefinition } from './codeblockconfig.js';
|
|
14
|
-
import type { DocumentSelection, Element, Model, Position, Schema, Text, UpcastWriter, ViewDocumentFragment } from 'ckeditor5/src/engine.js';
|
|
15
|
-
/**
|
|
16
|
-
* Returns code block languages as defined in `config.codeBlock.languages` but processed:
|
|
17
|
-
*
|
|
18
|
-
* * To consider the editor localization, i.e. to display {@link module:code-block/codeblockconfig~CodeBlockLanguageDefinition}
|
|
19
|
-
* in the correct language. There is no way to use {@link module:utils/locale~Locale#t} when the user
|
|
20
|
-
* configuration is defined because the editor does not exist yet.
|
|
21
|
-
* * To make sure each definition has a CSS class associated with it even if not specified
|
|
22
|
-
* in the original configuration.
|
|
23
|
-
*/
|
|
24
|
-
export declare function getNormalizedAndLocalizedLanguageDefinitions(editor: Editor): Array<CodeBlockLanguageDefinition>;
|
|
25
|
-
/**
|
|
26
|
-
* Returns an object associating certain language definition properties with others. For instance:
|
|
27
|
-
*
|
|
28
|
-
* For:
|
|
29
|
-
*
|
|
30
|
-
* ```ts
|
|
31
|
-
* const definitions = {
|
|
32
|
-
* { language: 'php', class: 'language-php', label: 'PHP' },
|
|
33
|
-
* { language: 'javascript', class: 'js', label: 'JavaScript' },
|
|
34
|
-
* };
|
|
35
|
-
*
|
|
36
|
-
* getPropertyAssociation( definitions, 'class', 'language' );
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* returns:
|
|
40
|
-
*
|
|
41
|
-
* ```ts
|
|
42
|
-
* {
|
|
43
|
-
* 'language-php': 'php',
|
|
44
|
-
* 'js': 'javascript'
|
|
45
|
-
* }
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* and
|
|
49
|
-
*
|
|
50
|
-
* ```ts
|
|
51
|
-
* getPropertyAssociation( definitions, 'language', 'label' );
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
* returns:
|
|
55
|
-
*
|
|
56
|
-
* ```ts
|
|
57
|
-
* {
|
|
58
|
-
* 'php': 'PHP',
|
|
59
|
-
* 'javascript': 'JavaScript'
|
|
60
|
-
* }
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
export declare function getPropertyAssociation(languageDefs: Array<CodeBlockLanguageDefinition>, key: keyof CodeBlockLanguageDefinition, value: keyof CodeBlockLanguageDefinition): Record<string, string>;
|
|
64
|
-
/**
|
|
65
|
-
* For a given model text node, it returns white spaces that precede other characters in that node.
|
|
66
|
-
* This corresponds to the indentation part of the code block line.
|
|
67
|
-
*/
|
|
68
|
-
export declare function getLeadingWhiteSpaces(textNode: Text): string;
|
|
69
|
-
/**
|
|
70
|
-
* For plain text containing the code (a snippet), it returns a document fragment containing
|
|
71
|
-
* view text nodes separated by `<br>` elements (in place of new line characters "\n"), for instance:
|
|
72
|
-
*
|
|
73
|
-
* Input:
|
|
74
|
-
*
|
|
75
|
-
* ```ts
|
|
76
|
-
* "foo()\n
|
|
77
|
-
* bar()"
|
|
78
|
-
* ```
|
|
79
|
-
*
|
|
80
|
-
* Output:
|
|
81
|
-
*
|
|
82
|
-
* ```html
|
|
83
|
-
* <DocumentFragment>
|
|
84
|
-
* "foo()"
|
|
85
|
-
* <br/>
|
|
86
|
-
* "bar()"
|
|
87
|
-
* </DocumentFragment>
|
|
88
|
-
* ```
|
|
89
|
-
*
|
|
90
|
-
* @param text The raw code text to be converted.
|
|
91
|
-
*/
|
|
92
|
-
export declare function rawSnippetTextToViewDocumentFragment(writer: UpcastWriter, text: string): ViewDocumentFragment;
|
|
93
|
-
/**
|
|
94
|
-
* Returns an array of all model positions within the selection that represent code block lines.
|
|
95
|
-
*
|
|
96
|
-
* If the selection is collapsed, it returns the exact selection anchor position:
|
|
97
|
-
*
|
|
98
|
-
* ```html
|
|
99
|
-
* <codeBlock>[]foo</codeBlock> -> <codeBlock>^foo</codeBlock>
|
|
100
|
-
* <codeBlock>foo[]bar</codeBlock> -> <codeBlock>foo^bar</codeBlock>
|
|
101
|
-
* ```
|
|
102
|
-
*
|
|
103
|
-
* Otherwise, it returns positions **before** each text node belonging to all code blocks contained by the selection:
|
|
104
|
-
*
|
|
105
|
-
* ```html
|
|
106
|
-
* <codeBlock> <codeBlock>
|
|
107
|
-
* foo[bar ^foobar
|
|
108
|
-
* <softBreak></softBreak> -> <softBreak></softBreak>
|
|
109
|
-
* baz]qux ^bazqux
|
|
110
|
-
* </codeBlock> </codeBlock>
|
|
111
|
-
* ```
|
|
112
|
-
*
|
|
113
|
-
* It also works across other non–code blocks:
|
|
114
|
-
*
|
|
115
|
-
* ```html
|
|
116
|
-
* <codeBlock> <codeBlock>
|
|
117
|
-
* foo[bar ^foobar
|
|
118
|
-
* </codeBlock> </codeBlock>
|
|
119
|
-
* <paragraph>text</paragraph> -> <paragraph>text</paragraph>
|
|
120
|
-
* <codeBlock> <codeBlock>
|
|
121
|
-
* baz]qux ^bazqux
|
|
122
|
-
* </codeBlock> </codeBlock>
|
|
123
|
-
* ```
|
|
124
|
-
*
|
|
125
|
-
* **Note:** The positions are in reverse order so they do not get outdated when iterating over them and
|
|
126
|
-
* the writer inserts or removes elements at the same time.
|
|
127
|
-
*
|
|
128
|
-
* **Note:** The position is located after the leading white spaces in the text node.
|
|
129
|
-
*/
|
|
130
|
-
export declare function getIndentOutdentPositions(model: Model): Array<Position>;
|
|
131
|
-
/**
|
|
132
|
-
* Checks if any of the blocks within the model selection is a code block.
|
|
133
|
-
*/
|
|
134
|
-
export declare function isModelSelectionInCodeBlock(selection: DocumentSelection): boolean;
|
|
135
|
-
/**
|
|
136
|
-
* Checks if an {@link module:engine/model/element~Element Element} can become a code block.
|
|
137
|
-
*
|
|
138
|
-
* @param schema Model's schema.
|
|
139
|
-
* @param element The element to be checked.
|
|
140
|
-
* @returns Check result.
|
|
141
|
-
*/
|
|
142
|
-
export declare function canBeCodeBlock(schema: Schema, element: Element): boolean;
|