@ckeditor/ckeditor5-code-block 0.0.0-nightly-20250616.0 → 0.0.0-nightly-20250618.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 +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
- package/src/codeblockediting.js +2 -2
- package/src/outdentcodeblockcommand.js +2 -2
- package/src/utils.d.ts +9 -9
- package/src/utils.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-code-block",
|
|
3
|
-
"version": "0.0.0-nightly-
|
|
3
|
+
"version": "0.0.0-nightly-20250618.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": "0.0.0-nightly-
|
|
17
|
-
"@ckeditor/ckeditor5-clipboard": "0.0.0-nightly-
|
|
18
|
-
"@ckeditor/ckeditor5-engine": "0.0.0-nightly-
|
|
19
|
-
"@ckeditor/ckeditor5-enter": "0.0.0-nightly-
|
|
20
|
-
"@ckeditor/ckeditor5-icons": "0.0.0-nightly-
|
|
21
|
-
"@ckeditor/ckeditor5-ui": "0.0.0-nightly-
|
|
22
|
-
"@ckeditor/ckeditor5-utils": "0.0.0-nightly-
|
|
23
|
-
"ckeditor5": "0.0.0-nightly-
|
|
16
|
+
"@ckeditor/ckeditor5-core": "0.0.0-nightly-20250618.0",
|
|
17
|
+
"@ckeditor/ckeditor5-clipboard": "0.0.0-nightly-20250618.0",
|
|
18
|
+
"@ckeditor/ckeditor5-engine": "0.0.0-nightly-20250618.0",
|
|
19
|
+
"@ckeditor/ckeditor5-enter": "0.0.0-nightly-20250618.0",
|
|
20
|
+
"@ckeditor/ckeditor5-icons": "0.0.0-nightly-20250618.0",
|
|
21
|
+
"@ckeditor/ckeditor5-ui": "0.0.0-nightly-20250618.0",
|
|
22
|
+
"@ckeditor/ckeditor5-utils": "0.0.0-nightly-20250618.0",
|
|
23
|
+
"ckeditor5": "0.0.0-nightly-20250618.0"
|
|
24
24
|
},
|
|
25
25
|
"author": "CKSource (http://cksource.com/)",
|
|
26
26
|
"license": "SEE LICENSE IN LICENSE.md",
|
package/src/codeblockediting.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
9
|
import { ShiftEnter } from 'ckeditor5/src/enter.js';
|
|
10
|
-
import {
|
|
10
|
+
import { ViewUpcastWriter } from 'ckeditor5/src/engine.js';
|
|
11
11
|
import { ClipboardPipeline } from 'ckeditor5/src/clipboard.js';
|
|
12
12
|
import { CodeBlockCommand } from './codeblockcommand.js';
|
|
13
13
|
import { IndentCodeBlockCommand } from './indentcodeblockcommand.js';
|
|
@@ -129,7 +129,7 @@ export class CodeBlockEditing extends Plugin {
|
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
131
|
const text = data.dataTransfer.getData('text/plain');
|
|
132
|
-
const writer = new
|
|
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
|
});
|
|
@@ -100,9 +100,9 @@ export 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~
|
|
103
|
+
// @param {<module:engine/model/position~ModelPosition>} position
|
|
104
104
|
// @param {String} sequence
|
|
105
|
-
// @returns {<module:engine/model/range~
|
|
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 {
|
|
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:
|
|
@@ -68,7 +68,7 @@ export declare function getPropertyAssociation(languageDefs: Array<CodeBlockLang
|
|
|
68
68
|
*
|
|
69
69
|
* @internal
|
|
70
70
|
*/
|
|
71
|
-
export declare function getLeadingWhiteSpaces(textNode:
|
|
71
|
+
export declare function getLeadingWhiteSpaces(textNode: ModelText): string;
|
|
72
72
|
/**
|
|
73
73
|
* For plain text containing the code (a snippet), it returns a document fragment containing
|
|
74
74
|
* view text nodes separated by `<br>` elements (in place of new line characters "\n"), for instance:
|
|
@@ -93,7 +93,7 @@ export declare function getLeadingWhiteSpaces(textNode: Text): string;
|
|
|
93
93
|
* @param text The raw code text to be converted.
|
|
94
94
|
* @internal
|
|
95
95
|
*/
|
|
96
|
-
export declare function rawSnippetTextToViewDocumentFragment(writer:
|
|
96
|
+
export declare function rawSnippetTextToViewDocumentFragment(writer: ViewUpcastWriter, text: string): ViewDocumentFragment;
|
|
97
97
|
/**
|
|
98
98
|
* Returns an array of all model positions within the selection that represent code block lines.
|
|
99
99
|
*
|
|
@@ -133,28 +133,28 @@ export declare function rawSnippetTextToViewDocumentFragment(writer: UpcastWrite
|
|
|
133
133
|
*
|
|
134
134
|
* @internal
|
|
135
135
|
*/
|
|
136
|
-
export declare function getIndentOutdentPositions(model: Model): Array<
|
|
136
|
+
export declare function getIndentOutdentPositions(model: Model): Array<ModelPosition>;
|
|
137
137
|
/**
|
|
138
138
|
* Checks if any of the blocks within the model selection is a code block.
|
|
139
139
|
*
|
|
140
140
|
* @internal
|
|
141
141
|
*/
|
|
142
|
-
export declare function isModelSelectionInCodeBlock(selection:
|
|
142
|
+
export declare function isModelSelectionInCodeBlock(selection: ModelDocumentSelection): boolean;
|
|
143
143
|
/**
|
|
144
|
-
* Checks if an {@link module:engine/model/element~
|
|
144
|
+
* Checks if an {@link module:engine/model/element~ModelElement Element} can become a code block.
|
|
145
145
|
*
|
|
146
146
|
* @param schema Model's schema.
|
|
147
147
|
* @param element The element to be checked.
|
|
148
148
|
* @returns Check result.
|
|
149
149
|
* @internal
|
|
150
150
|
*/
|
|
151
|
-
export declare function canBeCodeBlock(schema:
|
|
151
|
+
export declare function canBeCodeBlock(schema: ModelSchema, element: ModelElement): boolean;
|
|
152
152
|
/**
|
|
153
153
|
* Get the translated message read by the screen reader when you enter or exit an element with your cursor.
|
|
154
154
|
*
|
|
155
155
|
* @internal
|
|
156
156
|
*/
|
|
157
|
-
export declare function getCodeBlockAriaAnnouncement(t: LocaleTranslate, languageDefs: Array<CodeBlockLanguageDefinition>, element:
|
|
157
|
+
export declare function getCodeBlockAriaAnnouncement(t: LocaleTranslate, languageDefs: Array<CodeBlockLanguageDefinition>, element: ModelElement, direction: 'enter' | 'leave'): string;
|
|
158
158
|
/**
|
|
159
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
|
|
160
160
|
* beginning of the line (or `null` if there's no text node at the beginning of a given line).
|
|
@@ -190,4 +190,4 @@ export declare function getCodeBlockAriaAnnouncement(t: LocaleTranslate, languag
|
|
|
190
190
|
*
|
|
191
191
|
* @internal
|
|
192
192
|
*/
|
|
193
|
-
export declare function getTextNodeAtLineStart(position:
|
|
193
|
+
export declare function getTextNodeAtLineStart(position: ModelPosition, model: Model): ModelText | null;
|
package/src/utils.js
CHANGED
|
@@ -212,7 +212,7 @@ export function isModelSelectionInCodeBlock(selection) {
|
|
|
212
212
|
return !!firstBlock && firstBlock.is('element', 'codeBlock');
|
|
213
213
|
}
|
|
214
214
|
/**
|
|
215
|
-
* Checks if an {@link module:engine/model/element~
|
|
215
|
+
* Checks if an {@link module:engine/model/element~ModelElement Element} can become a code block.
|
|
216
216
|
*
|
|
217
217
|
* @param schema Model's schema.
|
|
218
218
|
* @param element The element to be checked.
|