@ckeditor/ckeditor5-code-block 40.0.0 → 40.1.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/LICENSE.md +3 -3
- package/package.json +2 -2
- package/src/augmentation.d.ts +25 -25
- package/src/augmentation.js +5 -5
- package/src/codeblock.d.ts +29 -29
- package/src/codeblock.js +33 -33
- package/src/codeblockcommand.d.ts +60 -60
- package/src/codeblockcommand.js +138 -138
- package/src/codeblockconfig.d.ts +146 -146
- package/src/codeblockconfig.js +5 -5
- package/src/codeblockediting.d.ts +36 -36
- package/src/codeblockediting.js +382 -382
- package/src/codeblockui.d.ts +29 -29
- package/src/codeblockui.js +93 -93
- package/src/converters.d.ts +126 -126
- package/src/converters.js +277 -277
- package/src/indentcodeblockcommand.d.ts +33 -33
- package/src/indentcodeblockcommand.js +78 -78
- package/src/index.d.ts +15 -15
- package/src/index.js +11 -11
- package/src/outdentcodeblockcommand.d.ts +33 -33
- package/src/outdentcodeblockcommand.js +148 -148
- package/src/utils.d.ts +138 -138
- package/src/utils.js +209 -209
- package/build/code-block.js.map +0 -1
package/src/codeblockui.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
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/codeblockui
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
-
import '../theme/codeblock.css';
|
|
10
|
-
/**
|
|
11
|
-
* The code block UI plugin.
|
|
12
|
-
*
|
|
13
|
-
* Introduces the `'codeBlock'` dropdown.
|
|
14
|
-
*/
|
|
15
|
-
export default class CodeBlockUI extends Plugin {
|
|
16
|
-
/**
|
|
17
|
-
* @inheritDoc
|
|
18
|
-
*/
|
|
19
|
-
static get pluginName(): "CodeBlockUI";
|
|
20
|
-
/**
|
|
21
|
-
* @inheritDoc
|
|
22
|
-
*/
|
|
23
|
-
init(): void;
|
|
24
|
-
/**
|
|
25
|
-
* A helper returning a collection of the `codeBlock` dropdown items representing languages
|
|
26
|
-
* available for the user to choose from.
|
|
27
|
-
*/
|
|
28
|
-
private _getLanguageListItemDefinitions;
|
|
29
|
-
}
|
|
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/codeblockui
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
+
import '../theme/codeblock.css';
|
|
10
|
+
/**
|
|
11
|
+
* The code block UI plugin.
|
|
12
|
+
*
|
|
13
|
+
* Introduces the `'codeBlock'` dropdown.
|
|
14
|
+
*/
|
|
15
|
+
export default class CodeBlockUI extends Plugin {
|
|
16
|
+
/**
|
|
17
|
+
* @inheritDoc
|
|
18
|
+
*/
|
|
19
|
+
static get pluginName(): "CodeBlockUI";
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
init(): void;
|
|
24
|
+
/**
|
|
25
|
+
* A helper returning a collection of the `codeBlock` dropdown items representing languages
|
|
26
|
+
* available for the user to choose from.
|
|
27
|
+
*/
|
|
28
|
+
private _getLanguageListItemDefinitions;
|
|
29
|
+
}
|
package/src/codeblockui.js
CHANGED
|
@@ -1,93 +1,93 @@
|
|
|
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/codeblockui
|
|
7
|
-
*/
|
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
-
import { Collection } from 'ckeditor5/src/utils';
|
|
10
|
-
import { Model, SplitButtonView, createDropdown, addListToDropdown } from 'ckeditor5/src/ui';
|
|
11
|
-
import { getNormalizedAndLocalizedLanguageDefinitions } from './utils';
|
|
12
|
-
import codeBlockIcon from '../theme/icons/codeblock.svg';
|
|
13
|
-
import '../theme/codeblock.css';
|
|
14
|
-
/**
|
|
15
|
-
* The code block UI plugin.
|
|
16
|
-
*
|
|
17
|
-
* Introduces the `'codeBlock'` dropdown.
|
|
18
|
-
*/
|
|
19
|
-
export default class CodeBlockUI extends Plugin {
|
|
20
|
-
/**
|
|
21
|
-
* @inheritDoc
|
|
22
|
-
*/
|
|
23
|
-
static get pluginName() {
|
|
24
|
-
return 'CodeBlockUI';
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* @inheritDoc
|
|
28
|
-
*/
|
|
29
|
-
init() {
|
|
30
|
-
const editor = this.editor;
|
|
31
|
-
const t = editor.t;
|
|
32
|
-
const componentFactory = editor.ui.componentFactory;
|
|
33
|
-
const normalizedLanguageDefs = getNormalizedAndLocalizedLanguageDefinitions(editor);
|
|
34
|
-
componentFactory.add('codeBlock', locale => {
|
|
35
|
-
const command = editor.commands.get('codeBlock');
|
|
36
|
-
const dropdownView = createDropdown(locale, SplitButtonView);
|
|
37
|
-
const splitButtonView = dropdownView.buttonView;
|
|
38
|
-
const accessibleLabel = t('Insert code block');
|
|
39
|
-
splitButtonView.set({
|
|
40
|
-
label: accessibleLabel,
|
|
41
|
-
tooltip: true,
|
|
42
|
-
icon: codeBlockIcon,
|
|
43
|
-
isToggleable: true
|
|
44
|
-
});
|
|
45
|
-
splitButtonView.bind('isOn').to(command, 'value', value => !!value);
|
|
46
|
-
splitButtonView.on('execute', () => {
|
|
47
|
-
editor.execute('codeBlock', {
|
|
48
|
-
usePreviousLanguageChoice: true
|
|
49
|
-
});
|
|
50
|
-
editor.editing.view.focus();
|
|
51
|
-
});
|
|
52
|
-
dropdownView.on('execute', evt => {
|
|
53
|
-
editor.execute('codeBlock', {
|
|
54
|
-
language: evt.source._codeBlockLanguage,
|
|
55
|
-
forceValue: true
|
|
56
|
-
});
|
|
57
|
-
editor.editing.view.focus();
|
|
58
|
-
});
|
|
59
|
-
dropdownView.class = 'ck-code-block-dropdown';
|
|
60
|
-
dropdownView.bind('isEnabled').to(command);
|
|
61
|
-
addListToDropdown(dropdownView, () => this._getLanguageListItemDefinitions(normalizedLanguageDefs), {
|
|
62
|
-
role: 'menu',
|
|
63
|
-
ariaLabel: accessibleLabel
|
|
64
|
-
});
|
|
65
|
-
return dropdownView;
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* A helper returning a collection of the `codeBlock` dropdown items representing languages
|
|
70
|
-
* available for the user to choose from.
|
|
71
|
-
*/
|
|
72
|
-
_getLanguageListItemDefinitions(normalizedLanguageDefs) {
|
|
73
|
-
const editor = this.editor;
|
|
74
|
-
const command = editor.commands.get('codeBlock');
|
|
75
|
-
const itemDefinitions = new Collection();
|
|
76
|
-
for (const languageDef of normalizedLanguageDefs) {
|
|
77
|
-
const definition = {
|
|
78
|
-
type: 'button',
|
|
79
|
-
model: new Model({
|
|
80
|
-
_codeBlockLanguage: languageDef.language,
|
|
81
|
-
label: languageDef.label,
|
|
82
|
-
role: 'menuitemradio',
|
|
83
|
-
withText: true
|
|
84
|
-
})
|
|
85
|
-
};
|
|
86
|
-
definition.model.bind('isOn').to(command, 'value', value => {
|
|
87
|
-
return value === definition.model._codeBlockLanguage;
|
|
88
|
-
});
|
|
89
|
-
itemDefinitions.add(definition);
|
|
90
|
-
}
|
|
91
|
-
return itemDefinitions;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
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/codeblockui
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
+
import { Collection } from 'ckeditor5/src/utils';
|
|
10
|
+
import { Model, SplitButtonView, createDropdown, addListToDropdown } from 'ckeditor5/src/ui';
|
|
11
|
+
import { getNormalizedAndLocalizedLanguageDefinitions } from './utils';
|
|
12
|
+
import codeBlockIcon from '../theme/icons/codeblock.svg';
|
|
13
|
+
import '../theme/codeblock.css';
|
|
14
|
+
/**
|
|
15
|
+
* The code block UI plugin.
|
|
16
|
+
*
|
|
17
|
+
* Introduces the `'codeBlock'` dropdown.
|
|
18
|
+
*/
|
|
19
|
+
export default class CodeBlockUI extends Plugin {
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
static get pluginName() {
|
|
24
|
+
return 'CodeBlockUI';
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
init() {
|
|
30
|
+
const editor = this.editor;
|
|
31
|
+
const t = editor.t;
|
|
32
|
+
const componentFactory = editor.ui.componentFactory;
|
|
33
|
+
const normalizedLanguageDefs = getNormalizedAndLocalizedLanguageDefinitions(editor);
|
|
34
|
+
componentFactory.add('codeBlock', locale => {
|
|
35
|
+
const command = editor.commands.get('codeBlock');
|
|
36
|
+
const dropdownView = createDropdown(locale, SplitButtonView);
|
|
37
|
+
const splitButtonView = dropdownView.buttonView;
|
|
38
|
+
const accessibleLabel = t('Insert code block');
|
|
39
|
+
splitButtonView.set({
|
|
40
|
+
label: accessibleLabel,
|
|
41
|
+
tooltip: true,
|
|
42
|
+
icon: codeBlockIcon,
|
|
43
|
+
isToggleable: true
|
|
44
|
+
});
|
|
45
|
+
splitButtonView.bind('isOn').to(command, 'value', value => !!value);
|
|
46
|
+
splitButtonView.on('execute', () => {
|
|
47
|
+
editor.execute('codeBlock', {
|
|
48
|
+
usePreviousLanguageChoice: true
|
|
49
|
+
});
|
|
50
|
+
editor.editing.view.focus();
|
|
51
|
+
});
|
|
52
|
+
dropdownView.on('execute', evt => {
|
|
53
|
+
editor.execute('codeBlock', {
|
|
54
|
+
language: evt.source._codeBlockLanguage,
|
|
55
|
+
forceValue: true
|
|
56
|
+
});
|
|
57
|
+
editor.editing.view.focus();
|
|
58
|
+
});
|
|
59
|
+
dropdownView.class = 'ck-code-block-dropdown';
|
|
60
|
+
dropdownView.bind('isEnabled').to(command);
|
|
61
|
+
addListToDropdown(dropdownView, () => this._getLanguageListItemDefinitions(normalizedLanguageDefs), {
|
|
62
|
+
role: 'menu',
|
|
63
|
+
ariaLabel: accessibleLabel
|
|
64
|
+
});
|
|
65
|
+
return dropdownView;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A helper returning a collection of the `codeBlock` dropdown items representing languages
|
|
70
|
+
* available for the user to choose from.
|
|
71
|
+
*/
|
|
72
|
+
_getLanguageListItemDefinitions(normalizedLanguageDefs) {
|
|
73
|
+
const editor = this.editor;
|
|
74
|
+
const command = editor.commands.get('codeBlock');
|
|
75
|
+
const itemDefinitions = new Collection();
|
|
76
|
+
for (const languageDef of normalizedLanguageDefs) {
|
|
77
|
+
const definition = {
|
|
78
|
+
type: 'button',
|
|
79
|
+
model: new Model({
|
|
80
|
+
_codeBlockLanguage: languageDef.language,
|
|
81
|
+
label: languageDef.label,
|
|
82
|
+
role: 'menuitemradio',
|
|
83
|
+
withText: true
|
|
84
|
+
})
|
|
85
|
+
};
|
|
86
|
+
definition.model.bind('isOn').to(command, 'value', value => {
|
|
87
|
+
return value === definition.model._codeBlockLanguage;
|
|
88
|
+
});
|
|
89
|
+
itemDefinitions.add(definition);
|
|
90
|
+
}
|
|
91
|
+
return itemDefinitions;
|
|
92
|
+
}
|
|
93
|
+
}
|
package/src/converters.d.ts
CHANGED
|
@@ -1,126 +1,126 @@
|
|
|
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/converters
|
|
7
|
-
*/
|
|
8
|
-
import type { GetCallback } from 'ckeditor5/src/utils';
|
|
9
|
-
import type { DowncastInsertEvent, Model, UpcastElementEvent, UpcastTextEvent, View } from 'ckeditor5/src/engine';
|
|
10
|
-
import type { CodeBlockLanguageDefinition } from './codeblockconfig';
|
|
11
|
-
/**
|
|
12
|
-
* A model-to-view (both editing and data) converter for the `codeBlock` element.
|
|
13
|
-
*
|
|
14
|
-
* Sample input:
|
|
15
|
-
*
|
|
16
|
-
* ```html
|
|
17
|
-
* <codeBlock language="javascript">foo();<softBreak></softBreak>bar();</codeBlock>
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* Sample output (editing):
|
|
21
|
-
*
|
|
22
|
-
* ```html
|
|
23
|
-
* <pre data-language="JavaScript"><code class="language-javascript">foo();<br />bar();</code></pre>
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* Sample output (data, see {@link module:code-block/converters~modelToDataViewSoftBreakInsertion}):
|
|
27
|
-
*
|
|
28
|
-
* ```html
|
|
29
|
-
* <pre><code class="language-javascript">foo();\nbar();</code></pre>
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
|
-
* @param languageDefs The normalized language configuration passed to the feature.
|
|
33
|
-
* @param useLabels When `true`, the `<pre>` element will get a `data-language` attribute with a
|
|
34
|
-
* human–readable label of the language. Used only in the editing.
|
|
35
|
-
* @returns Returns a conversion callback.
|
|
36
|
-
*/
|
|
37
|
-
export declare function modelToViewCodeBlockInsertion(model: Model, languageDefs: Array<CodeBlockLanguageDefinition>, useLabels?: boolean): GetCallback<DowncastInsertEvent>;
|
|
38
|
-
/**
|
|
39
|
-
* A model-to-data view converter for the new line (`softBreak`) separator.
|
|
40
|
-
*
|
|
41
|
-
* Sample input:
|
|
42
|
-
*
|
|
43
|
-
* ```html
|
|
44
|
-
* <codeBlock ...>foo();<softBreak></softBreak>bar();</codeBlock>
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
* Sample output:
|
|
48
|
-
*
|
|
49
|
-
* ```html
|
|
50
|
-
* <pre><code ...>foo();\nbar();</code></pre>
|
|
51
|
-
* ```
|
|
52
|
-
*
|
|
53
|
-
* @returns Returns a conversion callback.
|
|
54
|
-
*/
|
|
55
|
-
export declare function modelToDataViewSoftBreakInsertion(model: Model): GetCallback<DowncastInsertEvent>;
|
|
56
|
-
/**
|
|
57
|
-
* A view-to-model converter for `<pre>` with the `<code>` HTML.
|
|
58
|
-
*
|
|
59
|
-
* Sample input:
|
|
60
|
-
*
|
|
61
|
-
* ```html
|
|
62
|
-
* <pre><code class="language-javascript">foo();bar();</code></pre>
|
|
63
|
-
* ```
|
|
64
|
-
*
|
|
65
|
-
* Sample output:
|
|
66
|
-
*
|
|
67
|
-
* ```html
|
|
68
|
-
* <codeBlock language="javascript">foo();bar();</codeBlock>
|
|
69
|
-
* ```
|
|
70
|
-
*
|
|
71
|
-
* @param languageDefs The normalized language configuration passed to the feature.
|
|
72
|
-
* @returns Returns a conversion callback.
|
|
73
|
-
*/
|
|
74
|
-
export declare function dataViewToModelCodeBlockInsertion(editingView: View, languageDefs: Array<CodeBlockLanguageDefinition>): GetCallback<UpcastElementEvent>;
|
|
75
|
-
/**
|
|
76
|
-
* A view-to-model converter for new line characters in `<pre>`.
|
|
77
|
-
*
|
|
78
|
-
* Sample input:
|
|
79
|
-
*
|
|
80
|
-
* ```html
|
|
81
|
-
* <pre><code class="language-javascript">foo();\nbar();</code></pre>
|
|
82
|
-
* ```
|
|
83
|
-
*
|
|
84
|
-
* Sample output:
|
|
85
|
-
*
|
|
86
|
-
* ```html
|
|
87
|
-
* <codeBlock language="javascript">foo();<softBreak></softBreak>bar();</codeBlock>
|
|
88
|
-
* ```
|
|
89
|
-
*
|
|
90
|
-
* @returns {Function} Returns a conversion callback.
|
|
91
|
-
*/
|
|
92
|
-
export declare function dataViewToModelTextNewlinesInsertion(): GetCallback<UpcastTextEvent>;
|
|
93
|
-
/**
|
|
94
|
-
* A view-to-model converter that handles orphan text nodes (white spaces, new lines, etc.)
|
|
95
|
-
* that surround `<code>` inside `<pre>`.
|
|
96
|
-
*
|
|
97
|
-
* Sample input:
|
|
98
|
-
*
|
|
99
|
-
* ```html
|
|
100
|
-
* // White spaces
|
|
101
|
-
* <pre> <code>foo()</code> </pre>
|
|
102
|
-
*
|
|
103
|
-
* // White spaces
|
|
104
|
-
* <pre> <code>foo()</code> </pre>
|
|
105
|
-
*
|
|
106
|
-
* // White spaces
|
|
107
|
-
* <pre> <code>foo()</code> </pre>
|
|
108
|
-
*
|
|
109
|
-
* // New lines
|
|
110
|
-
* <pre>
|
|
111
|
-
* <code>foo()</code>
|
|
112
|
-
* </pre>
|
|
113
|
-
*
|
|
114
|
-
* // Redundant text
|
|
115
|
-
* <pre>ABC<code>foo()</code>DEF</pre>
|
|
116
|
-
* ```
|
|
117
|
-
*
|
|
118
|
-
* Unified output for each case:
|
|
119
|
-
*
|
|
120
|
-
* ```html
|
|
121
|
-
* <codeBlock language="plaintext">foo()</codeBlock>
|
|
122
|
-
* ```
|
|
123
|
-
*
|
|
124
|
-
* @returns Returns a conversion callback.
|
|
125
|
-
*/
|
|
126
|
-
export declare function dataViewToModelOrphanNodeConsumer(): GetCallback<UpcastElementEvent>;
|
|
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/converters
|
|
7
|
+
*/
|
|
8
|
+
import type { GetCallback } from 'ckeditor5/src/utils';
|
|
9
|
+
import type { DowncastInsertEvent, Model, UpcastElementEvent, UpcastTextEvent, View } from 'ckeditor5/src/engine';
|
|
10
|
+
import type { CodeBlockLanguageDefinition } from './codeblockconfig';
|
|
11
|
+
/**
|
|
12
|
+
* A model-to-view (both editing and data) converter for the `codeBlock` element.
|
|
13
|
+
*
|
|
14
|
+
* Sample input:
|
|
15
|
+
*
|
|
16
|
+
* ```html
|
|
17
|
+
* <codeBlock language="javascript">foo();<softBreak></softBreak>bar();</codeBlock>
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Sample output (editing):
|
|
21
|
+
*
|
|
22
|
+
* ```html
|
|
23
|
+
* <pre data-language="JavaScript"><code class="language-javascript">foo();<br />bar();</code></pre>
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* Sample output (data, see {@link module:code-block/converters~modelToDataViewSoftBreakInsertion}):
|
|
27
|
+
*
|
|
28
|
+
* ```html
|
|
29
|
+
* <pre><code class="language-javascript">foo();\nbar();</code></pre>
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @param languageDefs The normalized language configuration passed to the feature.
|
|
33
|
+
* @param useLabels When `true`, the `<pre>` element will get a `data-language` attribute with a
|
|
34
|
+
* human–readable label of the language. Used only in the editing.
|
|
35
|
+
* @returns Returns a conversion callback.
|
|
36
|
+
*/
|
|
37
|
+
export declare function modelToViewCodeBlockInsertion(model: Model, languageDefs: Array<CodeBlockLanguageDefinition>, useLabels?: boolean): GetCallback<DowncastInsertEvent>;
|
|
38
|
+
/**
|
|
39
|
+
* A model-to-data view converter for the new line (`softBreak`) separator.
|
|
40
|
+
*
|
|
41
|
+
* Sample input:
|
|
42
|
+
*
|
|
43
|
+
* ```html
|
|
44
|
+
* <codeBlock ...>foo();<softBreak></softBreak>bar();</codeBlock>
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* Sample output:
|
|
48
|
+
*
|
|
49
|
+
* ```html
|
|
50
|
+
* <pre><code ...>foo();\nbar();</code></pre>
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @returns Returns a conversion callback.
|
|
54
|
+
*/
|
|
55
|
+
export declare function modelToDataViewSoftBreakInsertion(model: Model): GetCallback<DowncastInsertEvent>;
|
|
56
|
+
/**
|
|
57
|
+
* A view-to-model converter for `<pre>` with the `<code>` HTML.
|
|
58
|
+
*
|
|
59
|
+
* Sample input:
|
|
60
|
+
*
|
|
61
|
+
* ```html
|
|
62
|
+
* <pre><code class="language-javascript">foo();bar();</code></pre>
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* Sample output:
|
|
66
|
+
*
|
|
67
|
+
* ```html
|
|
68
|
+
* <codeBlock language="javascript">foo();bar();</codeBlock>
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @param languageDefs The normalized language configuration passed to the feature.
|
|
72
|
+
* @returns Returns a conversion callback.
|
|
73
|
+
*/
|
|
74
|
+
export declare function dataViewToModelCodeBlockInsertion(editingView: View, languageDefs: Array<CodeBlockLanguageDefinition>): GetCallback<UpcastElementEvent>;
|
|
75
|
+
/**
|
|
76
|
+
* A view-to-model converter for new line characters in `<pre>`.
|
|
77
|
+
*
|
|
78
|
+
* Sample input:
|
|
79
|
+
*
|
|
80
|
+
* ```html
|
|
81
|
+
* <pre><code class="language-javascript">foo();\nbar();</code></pre>
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* Sample output:
|
|
85
|
+
*
|
|
86
|
+
* ```html
|
|
87
|
+
* <codeBlock language="javascript">foo();<softBreak></softBreak>bar();</codeBlock>
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @returns {Function} Returns a conversion callback.
|
|
91
|
+
*/
|
|
92
|
+
export declare function dataViewToModelTextNewlinesInsertion(): GetCallback<UpcastTextEvent>;
|
|
93
|
+
/**
|
|
94
|
+
* A view-to-model converter that handles orphan text nodes (white spaces, new lines, etc.)
|
|
95
|
+
* that surround `<code>` inside `<pre>`.
|
|
96
|
+
*
|
|
97
|
+
* Sample input:
|
|
98
|
+
*
|
|
99
|
+
* ```html
|
|
100
|
+
* // White spaces
|
|
101
|
+
* <pre> <code>foo()</code> </pre>
|
|
102
|
+
*
|
|
103
|
+
* // White spaces
|
|
104
|
+
* <pre> <code>foo()</code> </pre>
|
|
105
|
+
*
|
|
106
|
+
* // White spaces
|
|
107
|
+
* <pre> <code>foo()</code> </pre>
|
|
108
|
+
*
|
|
109
|
+
* // New lines
|
|
110
|
+
* <pre>
|
|
111
|
+
* <code>foo()</code>
|
|
112
|
+
* </pre>
|
|
113
|
+
*
|
|
114
|
+
* // Redundant text
|
|
115
|
+
* <pre>ABC<code>foo()</code>DEF</pre>
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* Unified output for each case:
|
|
119
|
+
*
|
|
120
|
+
* ```html
|
|
121
|
+
* <codeBlock language="plaintext">foo()</codeBlock>
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* @returns Returns a conversion callback.
|
|
125
|
+
*/
|
|
126
|
+
export declare function dataViewToModelOrphanNodeConsumer(): GetCallback<UpcastElementEvent>;
|