@ckeditor/ckeditor5-typing 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 CHANGED
@@ -2,7 +2,7 @@ Software License Agreement
2
2
  ==========================
3
3
 
4
4
  **CKEditor&nbsp;5 typing feature** – https://github.com/ckeditor/ckeditor5-typing <br>
5
- Copyright (c) 2003-2023, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
5
+ Copyright (c) 20032023, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
6
6
 
7
7
  Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
8
8
 
@@ -13,9 +13,9 @@ Where not otherwise indicated, all CKEditor content is authored by CKSource engi
13
13
 
14
14
  The following libraries are included in CKEditor under the [MIT license](https://opensource.org/licenses/MIT):
15
15
 
16
- * lodash - Copyright (c) JS Foundation and other contributors https://js.foundation/. Based on Underscore.js, copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors http://underscorejs.org/.
16
+ * Lodash - Copyright (c) JS Foundation and other contributors https://js.foundation/. Based on Underscore.js, copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors http://underscorejs.org/.
17
17
 
18
18
  Trademarks
19
19
  ----------
20
20
 
21
- **CKEditor** is a trademark of [CKSource Holding sp. z o.o.](https://cksource.com) All other brand and product names are trademarks, registered trademarks or service marks of their respective holders.
21
+ **CKEditor** is a trademark of [CKSource Holding sp. z o.o.](https://cksource.com) All other brand and product names are trademarks, registered trademarks, or service marks of their respective holders.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-typing",
3
- "version": "40.0.0",
3
+ "version": "40.1.0",
4
4
  "description": "Typing feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,9 +12,9 @@
12
12
  ],
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "@ckeditor/ckeditor5-core": "40.0.0",
16
- "@ckeditor/ckeditor5-engine": "40.0.0",
17
- "@ckeditor/ckeditor5-utils": "40.0.0",
15
+ "@ckeditor/ckeditor5-core": "40.1.0",
16
+ "@ckeditor/ckeditor5-engine": "40.1.0",
17
+ "@ckeditor/ckeditor5-utils": "40.1.0",
18
18
  "lodash-es": "4.17.21"
19
19
  },
20
20
  "author": "CKSource (http://cksource.com/)",
@@ -1,27 +1,27 @@
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 type { Delete, DeleteCommand, Input, InsertTextCommand, TextTransformation, TwoStepCaretMovement, Typing, TypingConfig } from './index';
6
- declare module '@ckeditor/ckeditor5-core' {
7
- interface EditorConfig {
8
- /**
9
- * The configuration of the typing features. Used by the features from the `@ckeditor/ckeditor5-typing` package.
10
- *
11
- * Read more in {@link module:typing/typingconfig~TypingConfig}.
12
- */
13
- typing?: TypingConfig;
14
- }
15
- interface CommandsMap {
16
- deleteForward: DeleteCommand;
17
- delete: DeleteCommand;
18
- insertText: InsertTextCommand;
19
- }
20
- interface PluginsMap {
21
- [Delete.pluginName]: Delete;
22
- [Input.pluginName]: Input;
23
- [TextTransformation.pluginName]: TextTransformation;
24
- [TwoStepCaretMovement.pluginName]: TwoStepCaretMovement;
25
- [Typing.pluginName]: Typing;
26
- }
27
- }
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 type { Delete, DeleteCommand, Input, InsertTextCommand, TextTransformation, TwoStepCaretMovement, Typing, TypingConfig } from './index';
6
+ declare module '@ckeditor/ckeditor5-core' {
7
+ interface EditorConfig {
8
+ /**
9
+ * The configuration of the typing features. Used by the features from the `@ckeditor/ckeditor5-typing` package.
10
+ *
11
+ * Read more in {@link module:typing/typingconfig~TypingConfig}.
12
+ */
13
+ typing?: TypingConfig;
14
+ }
15
+ interface CommandsMap {
16
+ deleteForward: DeleteCommand;
17
+ delete: DeleteCommand;
18
+ insertText: InsertTextCommand;
19
+ }
20
+ interface PluginsMap {
21
+ [Delete.pluginName]: Delete;
22
+ [Input.pluginName]: Input;
23
+ [TextTransformation.pluginName]: TextTransformation;
24
+ [TwoStepCaretMovement.pluginName]: TwoStepCaretMovement;
25
+ [Typing.pluginName]: Typing;
26
+ }
27
+ }
@@ -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 {};
package/src/delete.d.ts CHANGED
@@ -1,32 +1,32 @@
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 typing/delete
7
- */
8
- import { Plugin } from '@ckeditor/ckeditor5-core';
9
- /**
10
- * The delete and backspace feature. Handles keys such as <kbd>Delete</kbd> and <kbd>Backspace</kbd>, other
11
- * keystrokes and user actions that result in deleting content in the editor.
12
- */
13
- export default class Delete extends Plugin {
14
- /**
15
- * Whether pressing backspace should trigger undo action
16
- */
17
- private _undoOnBackspace;
18
- /**
19
- * @inheritDoc
20
- */
21
- static get pluginName(): "Delete";
22
- /**
23
- * @inheritDoc
24
- */
25
- init(): void;
26
- /**
27
- * If the next user action after calling this method is pressing backspace, it would undo the last change.
28
- *
29
- * Requires {@link module:undo/undoediting~UndoEditing} plugin. If not loaded, does nothing.
30
- */
31
- requestUndoOnBackspace(): void;
32
- }
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 typing/delete
7
+ */
8
+ import { Plugin } from '@ckeditor/ckeditor5-core';
9
+ /**
10
+ * The delete and backspace feature. Handles keys such as <kbd>Delete</kbd> and <kbd>Backspace</kbd>, other
11
+ * keystrokes and user actions that result in deleting content in the editor.
12
+ */
13
+ export default class Delete extends Plugin {
14
+ /**
15
+ * Whether pressing backspace should trigger undo action
16
+ */
17
+ private _undoOnBackspace;
18
+ /**
19
+ * @inheritDoc
20
+ */
21
+ static get pluginName(): "Delete";
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ init(): void;
26
+ /**
27
+ * If the next user action after calling this method is pressing backspace, it would undo the last change.
28
+ *
29
+ * Requires {@link module:undo/undoediting~UndoEditing} plugin. If not loaded, does nothing.
30
+ */
31
+ requestUndoOnBackspace(): void;
32
+ }
package/src/delete.js CHANGED
@@ -1,82 +1,82 @@
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 typing/delete
7
- */
8
- import { Plugin } from '@ckeditor/ckeditor5-core';
9
- import DeleteCommand from './deletecommand';
10
- import DeleteObserver from './deleteobserver';
11
- /**
12
- * The delete and backspace feature. Handles keys such as <kbd>Delete</kbd> and <kbd>Backspace</kbd>, other
13
- * keystrokes and user actions that result in deleting content in the editor.
14
- */
15
- export default class Delete extends Plugin {
16
- /**
17
- * @inheritDoc
18
- */
19
- static get pluginName() {
20
- return 'Delete';
21
- }
22
- /**
23
- * @inheritDoc
24
- */
25
- init() {
26
- const editor = this.editor;
27
- const view = editor.editing.view;
28
- const viewDocument = view.document;
29
- const modelDocument = editor.model.document;
30
- view.addObserver(DeleteObserver);
31
- this._undoOnBackspace = false;
32
- const deleteForwardCommand = new DeleteCommand(editor, 'forward');
33
- // Register `deleteForward` command and add `forwardDelete` command as an alias for backward compatibility.
34
- editor.commands.add('deleteForward', deleteForwardCommand);
35
- editor.commands.add('forwardDelete', deleteForwardCommand);
36
- editor.commands.add('delete', new DeleteCommand(editor, 'backward'));
37
- this.listenTo(viewDocument, 'delete', (evt, data) => {
38
- // When not in composition, we handle the action, so prevent the default one.
39
- // When in composition, it's the browser who modify the DOM (renderer is disabled).
40
- if (!viewDocument.isComposing) {
41
- data.preventDefault();
42
- }
43
- const { direction, sequence, selectionToRemove, unit } = data;
44
- const commandName = direction === 'forward' ? 'deleteForward' : 'delete';
45
- const commandData = { sequence };
46
- if (unit == 'selection') {
47
- const modelRanges = Array.from(selectionToRemove.getRanges()).map(viewRange => {
48
- return editor.editing.mapper.toModelRange(viewRange);
49
- });
50
- commandData.selection = editor.model.createSelection(modelRanges);
51
- }
52
- else {
53
- commandData.unit = unit;
54
- }
55
- editor.execute(commandName, commandData);
56
- view.scrollToTheSelection();
57
- }, { priority: 'low' });
58
- if (this.editor.plugins.has('UndoEditing')) {
59
- this.listenTo(viewDocument, 'delete', (evt, data) => {
60
- if (this._undoOnBackspace && data.direction == 'backward' && data.sequence == 1 && data.unit == 'codePoint') {
61
- this._undoOnBackspace = false;
62
- editor.execute('undo');
63
- data.preventDefault();
64
- evt.stop();
65
- }
66
- }, { context: '$capture' });
67
- this.listenTo(modelDocument, 'change', () => {
68
- this._undoOnBackspace = false;
69
- });
70
- }
71
- }
72
- /**
73
- * If the next user action after calling this method is pressing backspace, it would undo the last change.
74
- *
75
- * Requires {@link module:undo/undoediting~UndoEditing} plugin. If not loaded, does nothing.
76
- */
77
- requestUndoOnBackspace() {
78
- if (this.editor.plugins.has('UndoEditing')) {
79
- this._undoOnBackspace = true;
80
- }
81
- }
82
- }
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 typing/delete
7
+ */
8
+ import { Plugin } from '@ckeditor/ckeditor5-core';
9
+ import DeleteCommand from './deletecommand';
10
+ import DeleteObserver from './deleteobserver';
11
+ /**
12
+ * The delete and backspace feature. Handles keys such as <kbd>Delete</kbd> and <kbd>Backspace</kbd>, other
13
+ * keystrokes and user actions that result in deleting content in the editor.
14
+ */
15
+ export default class Delete extends Plugin {
16
+ /**
17
+ * @inheritDoc
18
+ */
19
+ static get pluginName() {
20
+ return 'Delete';
21
+ }
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ init() {
26
+ const editor = this.editor;
27
+ const view = editor.editing.view;
28
+ const viewDocument = view.document;
29
+ const modelDocument = editor.model.document;
30
+ view.addObserver(DeleteObserver);
31
+ this._undoOnBackspace = false;
32
+ const deleteForwardCommand = new DeleteCommand(editor, 'forward');
33
+ // Register `deleteForward` command and add `forwardDelete` command as an alias for backward compatibility.
34
+ editor.commands.add('deleteForward', deleteForwardCommand);
35
+ editor.commands.add('forwardDelete', deleteForwardCommand);
36
+ editor.commands.add('delete', new DeleteCommand(editor, 'backward'));
37
+ this.listenTo(viewDocument, 'delete', (evt, data) => {
38
+ // When not in composition, we handle the action, so prevent the default one.
39
+ // When in composition, it's the browser who modify the DOM (renderer is disabled).
40
+ if (!viewDocument.isComposing) {
41
+ data.preventDefault();
42
+ }
43
+ const { direction, sequence, selectionToRemove, unit } = data;
44
+ const commandName = direction === 'forward' ? 'deleteForward' : 'delete';
45
+ const commandData = { sequence };
46
+ if (unit == 'selection') {
47
+ const modelRanges = Array.from(selectionToRemove.getRanges()).map(viewRange => {
48
+ return editor.editing.mapper.toModelRange(viewRange);
49
+ });
50
+ commandData.selection = editor.model.createSelection(modelRanges);
51
+ }
52
+ else {
53
+ commandData.unit = unit;
54
+ }
55
+ editor.execute(commandName, commandData);
56
+ view.scrollToTheSelection();
57
+ }, { priority: 'low' });
58
+ if (this.editor.plugins.has('UndoEditing')) {
59
+ this.listenTo(viewDocument, 'delete', (evt, data) => {
60
+ if (this._undoOnBackspace && data.direction == 'backward' && data.sequence == 1 && data.unit == 'codePoint') {
61
+ this._undoOnBackspace = false;
62
+ editor.execute('undo');
63
+ data.preventDefault();
64
+ evt.stop();
65
+ }
66
+ }, { context: '$capture' });
67
+ this.listenTo(modelDocument, 'change', () => {
68
+ this._undoOnBackspace = false;
69
+ });
70
+ }
71
+ }
72
+ /**
73
+ * If the next user action after calling this method is pressing backspace, it would undo the last change.
74
+ *
75
+ * Requires {@link module:undo/undoediting~UndoEditing} plugin. If not loaded, does nothing.
76
+ */
77
+ requestUndoOnBackspace() {
78
+ if (this.editor.plugins.has('UndoEditing')) {
79
+ this._undoOnBackspace = true;
80
+ }
81
+ }
82
+ }
@@ -1,83 +1,83 @@
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 typing/deletecommand
7
- */
8
- import { Command, type Editor } from '@ckeditor/ckeditor5-core';
9
- import type { DocumentSelection, Selection } from '@ckeditor/ckeditor5-engine';
10
- import ChangeBuffer from './utils/changebuffer';
11
- /**
12
- * The delete command. Used by the {@link module:typing/delete~Delete delete feature} to handle the <kbd>Delete</kbd> and
13
- * <kbd>Backspace</kbd> keys.
14
- */
15
- export default class DeleteCommand extends Command {
16
- /**
17
- * The directionality of the delete describing in what direction it should
18
- * consume the content when the selection is collapsed.
19
- */
20
- readonly direction: 'forward' | 'backward';
21
- /**
22
- * Delete's change buffer used to group subsequent changes into batches.
23
- */
24
- private readonly _buffer;
25
- /**
26
- * Creates an instance of the command.
27
- *
28
- * @param direction The directionality of the delete describing in what direction it
29
- * should consume the content when the selection is collapsed.
30
- */
31
- constructor(editor: Editor, direction: 'forward' | 'backward');
32
- /**
33
- * The current change buffer.
34
- */
35
- get buffer(): ChangeBuffer;
36
- /**
37
- * Executes the delete command. Depending on whether the selection is collapsed or not, deletes its content
38
- * or a piece of content in the {@link #direction defined direction}.
39
- *
40
- * @fires execute
41
- * @param options The command options.
42
- * @param options.unit See {@link module:engine/model/utils/modifyselection~modifySelection}'s options.
43
- * @param options.sequence A number describing which subsequent delete event it is without the key being released.
44
- * See the {@link module:engine/view/document~Document#event:delete} event data.
45
- * @param options.selection Selection to remove. If not set, current model selection will be used.
46
- */
47
- execute(options?: {
48
- unit?: 'character' | 'codePoint' | 'word';
49
- sequence?: number;
50
- selection?: Selection | DocumentSelection;
51
- }): void;
52
- /**
53
- * If the user keeps <kbd>Backspace</kbd> or <kbd>Delete</kbd> key pressed, the content of the current
54
- * editable will be cleared. However, this will not yet lead to resetting the remaining block to a paragraph
55
- * (which happens e.g. when the user does <kbd>Ctrl</kbd> + <kbd>A</kbd>, <kbd>Backspace</kbd>).
56
- *
57
- * But, if the user pressed the key in an empty editable for the first time,
58
- * we want to replace the entire content with a paragraph if:
59
- *
60
- * * the current limit element is empty,
61
- * * the paragraph is allowed in the limit element,
62
- * * the limit doesn't already have a paragraph inside.
63
- *
64
- * See https://github.com/ckeditor/ckeditor5-typing/issues/61.
65
- *
66
- * @param sequence A number describing which subsequent delete event it is without the key being released.
67
- */
68
- private _shouldEntireContentBeReplacedWithParagraph;
69
- /**
70
- * The entire content is replaced with the paragraph. Selection is moved inside the paragraph.
71
- *
72
- * @param writer The model writer.
73
- */
74
- private _replaceEntireContentWithParagraph;
75
- /**
76
- * Checks if the selection is inside an empty element that is the first child of the limit element
77
- * and should be replaced with a paragraph.
78
- *
79
- * @param selection The selection.
80
- * @param sequence A number describing which subsequent delete event it is without the key being released.
81
- */
82
- private _shouldReplaceFirstBlockWithParagraph;
83
- }
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 typing/deletecommand
7
+ */
8
+ import { Command, type Editor } from '@ckeditor/ckeditor5-core';
9
+ import type { DocumentSelection, Selection } from '@ckeditor/ckeditor5-engine';
10
+ import ChangeBuffer from './utils/changebuffer';
11
+ /**
12
+ * The delete command. Used by the {@link module:typing/delete~Delete delete feature} to handle the <kbd>Delete</kbd> and
13
+ * <kbd>Backspace</kbd> keys.
14
+ */
15
+ export default class DeleteCommand extends Command {
16
+ /**
17
+ * The directionality of the delete describing in what direction it should
18
+ * consume the content when the selection is collapsed.
19
+ */
20
+ readonly direction: 'forward' | 'backward';
21
+ /**
22
+ * Delete's change buffer used to group subsequent changes into batches.
23
+ */
24
+ private readonly _buffer;
25
+ /**
26
+ * Creates an instance of the command.
27
+ *
28
+ * @param direction The directionality of the delete describing in what direction it
29
+ * should consume the content when the selection is collapsed.
30
+ */
31
+ constructor(editor: Editor, direction: 'forward' | 'backward');
32
+ /**
33
+ * The current change buffer.
34
+ */
35
+ get buffer(): ChangeBuffer;
36
+ /**
37
+ * Executes the delete command. Depending on whether the selection is collapsed or not, deletes its content
38
+ * or a piece of content in the {@link #direction defined direction}.
39
+ *
40
+ * @fires execute
41
+ * @param options The command options.
42
+ * @param options.unit See {@link module:engine/model/utils/modifyselection~modifySelection}'s options.
43
+ * @param options.sequence A number describing which subsequent delete event it is without the key being released.
44
+ * See the {@link module:engine/view/document~Document#event:delete} event data.
45
+ * @param options.selection Selection to remove. If not set, current model selection will be used.
46
+ */
47
+ execute(options?: {
48
+ unit?: 'character' | 'codePoint' | 'word';
49
+ sequence?: number;
50
+ selection?: Selection | DocumentSelection;
51
+ }): void;
52
+ /**
53
+ * If the user keeps <kbd>Backspace</kbd> or <kbd>Delete</kbd> key pressed, the content of the current
54
+ * editable will be cleared. However, this will not yet lead to resetting the remaining block to a paragraph
55
+ * (which happens e.g. when the user does <kbd>Ctrl</kbd> + <kbd>A</kbd>, <kbd>Backspace</kbd>).
56
+ *
57
+ * But, if the user pressed the key in an empty editable for the first time,
58
+ * we want to replace the entire content with a paragraph if:
59
+ *
60
+ * * the current limit element is empty,
61
+ * * the paragraph is allowed in the limit element,
62
+ * * the limit doesn't already have a paragraph inside.
63
+ *
64
+ * See https://github.com/ckeditor/ckeditor5-typing/issues/61.
65
+ *
66
+ * @param sequence A number describing which subsequent delete event it is without the key being released.
67
+ */
68
+ private _shouldEntireContentBeReplacedWithParagraph;
69
+ /**
70
+ * The entire content is replaced with the paragraph. Selection is moved inside the paragraph.
71
+ *
72
+ * @param writer The model writer.
73
+ */
74
+ private _replaceEntireContentWithParagraph;
75
+ /**
76
+ * Checks if the selection is inside an empty element that is the first child of the limit element
77
+ * and should be replaced with a paragraph.
78
+ *
79
+ * @param selection The selection.
80
+ * @param sequence A number describing which subsequent delete event it is without the key being released.
81
+ */
82
+ private _shouldReplaceFirstBlockWithParagraph;
83
+ }