@ckeditor/ckeditor5-typing 38.2.0-alpha.1 → 39.0.1
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/README.md +0 -1
- package/package.json +5 -6
- package/src/augmentation.d.ts +1 -1
- package/src/delete.js +2 -2
- package/src/deletecommand.d.ts +1 -1
- package/src/deletecommand.js +1 -1
- package/src/index.d.ts +17 -17
- package/src/index.js +11 -11
- package/src/input.js +3 -2
- package/src/inserttextcommand.d.ts +1 -1
- package/src/inserttextcommand.js +1 -1
- package/src/inserttextobserver.d.ts +6 -1
- package/src/inserttextobserver.js +5 -1
- package/src/texttransformation.js +1 -1
- package/src/textwatcher.js +1 -1
- package/src/typing.d.ts +2 -2
- package/src/typing.js +2 -2
- package/src/utils/inlinehighlight.d.ts +1 -1
- package/src/utils/inlinehighlight.js +2 -2
package/README.md
CHANGED
|
@@ -4,7 +4,6 @@ CKEditor 5 typing feature
|
|
|
4
4
|
[](https://www.npmjs.com/package/@ckeditor/ckeditor5-typing)
|
|
5
5
|
[](https://coveralls.io/github/ckeditor/ckeditor5?branch=master)
|
|
6
6
|
[](https://app.travis-ci.com/github/ckeditor/ckeditor5)
|
|
7
|
-

|
|
8
7
|
|
|
9
8
|
This package implements support for typing (inputting and deleting text) in CKEditor 5. It also includes the automatic text transformations (autocorrect) feature that lets you automatically turn predefined snippets into their improved forms.
|
|
10
9
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-typing",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "39.0.1",
|
|
4
4
|
"description": "Typing feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -11,12 +11,11 @@
|
|
|
11
11
|
"ckeditor5-dll"
|
|
12
12
|
],
|
|
13
13
|
"main": "src/index.js",
|
|
14
|
-
"type": "module",
|
|
15
14
|
"dependencies": {
|
|
16
|
-
"@ckeditor/ckeditor5-core": "
|
|
17
|
-
"@ckeditor/ckeditor5-engine": "
|
|
18
|
-
"@ckeditor/ckeditor5-utils": "
|
|
19
|
-
"lodash-es": "
|
|
15
|
+
"@ckeditor/ckeditor5-core": "39.0.1",
|
|
16
|
+
"@ckeditor/ckeditor5-engine": "39.0.1",
|
|
17
|
+
"@ckeditor/ckeditor5-utils": "39.0.1",
|
|
18
|
+
"lodash-es": "4.17.21"
|
|
20
19
|
},
|
|
21
20
|
"engines": {
|
|
22
21
|
"node": ">=16.0.0",
|
package/src/augmentation.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
import type { Delete, DeleteCommand, Input, InsertTextCommand, TextTransformation, TwoStepCaretMovement, Typing, TypingConfig } from './index
|
|
5
|
+
import type { Delete, DeleteCommand, Input, InsertTextCommand, TextTransformation, TwoStepCaretMovement, Typing, TypingConfig } from './index';
|
|
6
6
|
declare module '@ckeditor/ckeditor5-core' {
|
|
7
7
|
interface EditorConfig {
|
|
8
8
|
/**
|
package/src/delete.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* @module typing/delete
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
import DeleteCommand from './deletecommand
|
|
10
|
-
import DeleteObserver from './deleteobserver
|
|
9
|
+
import DeleteCommand from './deletecommand';
|
|
10
|
+
import DeleteObserver from './deleteobserver';
|
|
11
11
|
/**
|
|
12
12
|
* The delete and backspace feature. Handles keys such as <kbd>Delete</kbd> and <kbd>Backspace</kbd>, other
|
|
13
13
|
* keystrokes and user actions that result in deleting content in the editor.
|
package/src/deletecommand.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Command, type Editor } from '@ckeditor/ckeditor5-core';
|
|
9
9
|
import type { DocumentSelection, Selection } from '@ckeditor/ckeditor5-engine';
|
|
10
|
-
import ChangeBuffer from './utils/changebuffer
|
|
10
|
+
import ChangeBuffer from './utils/changebuffer';
|
|
11
11
|
/**
|
|
12
12
|
* The delete command. Used by the {@link module:typing/delete~Delete delete feature} to handle the <kbd>Delete</kbd> and
|
|
13
13
|
* <kbd>Backspace</kbd> keys.
|
package/src/deletecommand.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Command } from '@ckeditor/ckeditor5-core';
|
|
9
9
|
import { count } from '@ckeditor/ckeditor5-utils';
|
|
10
|
-
import ChangeBuffer from './utils/changebuffer
|
|
10
|
+
import ChangeBuffer from './utils/changebuffer';
|
|
11
11
|
/**
|
|
12
12
|
* The delete command. Used by the {@link module:typing/delete~Delete delete feature} to handle the <kbd>Delete</kbd> and
|
|
13
13
|
* <kbd>Backspace</kbd> keys.
|
package/src/index.d.ts
CHANGED
|
@@ -5,20 +5,20 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module typing
|
|
7
7
|
*/
|
|
8
|
-
export { default as Typing } from './typing
|
|
9
|
-
export { default as Input } from './input
|
|
10
|
-
export { default as Delete } from './delete
|
|
11
|
-
export { default as TextWatcher } from './textwatcher
|
|
12
|
-
export { default as TwoStepCaretMovement } from './twostepcaretmovement
|
|
13
|
-
export { default as TextTransformation } from './texttransformation
|
|
14
|
-
export { default as inlineHighlight } from './utils/inlinehighlight
|
|
15
|
-
export { default as findAttributeRange, findAttributeRangeBound } from './utils/findattributerange
|
|
16
|
-
export { default as getLastTextLine, type LastTextLineData } from './utils/getlasttextline
|
|
17
|
-
export { default as InsertTextCommand, type InsertTextCommandExecuteEvent } from './inserttextcommand
|
|
18
|
-
export type { default as DeleteCommand } from './deletecommand
|
|
19
|
-
export type { TypingConfig } from './typingconfig
|
|
20
|
-
export type { ViewDocumentDeleteEvent } from './deleteobserver
|
|
21
|
-
export type { ViewDocumentInsertTextEvent, InsertTextEventData } from './inserttextobserver
|
|
22
|
-
export type { TextWatcherMatchedEvent } from './textwatcher
|
|
23
|
-
export type { TextWatcherMatchedDataEvent } from './textwatcher
|
|
24
|
-
import './augmentation
|
|
8
|
+
export { default as Typing } from './typing';
|
|
9
|
+
export { default as Input } from './input';
|
|
10
|
+
export { default as Delete } from './delete';
|
|
11
|
+
export { default as TextWatcher } from './textwatcher';
|
|
12
|
+
export { default as TwoStepCaretMovement } from './twostepcaretmovement';
|
|
13
|
+
export { default as TextTransformation } from './texttransformation';
|
|
14
|
+
export { default as inlineHighlight } from './utils/inlinehighlight';
|
|
15
|
+
export { default as findAttributeRange, findAttributeRangeBound } from './utils/findattributerange';
|
|
16
|
+
export { default as getLastTextLine, type LastTextLineData } from './utils/getlasttextline';
|
|
17
|
+
export { default as InsertTextCommand, type InsertTextCommandExecuteEvent } from './inserttextcommand';
|
|
18
|
+
export type { default as DeleteCommand } from './deletecommand';
|
|
19
|
+
export type { TypingConfig } from './typingconfig';
|
|
20
|
+
export type { ViewDocumentDeleteEvent } from './deleteobserver';
|
|
21
|
+
export type { ViewDocumentInsertTextEvent, InsertTextEventData } from './inserttextobserver';
|
|
22
|
+
export type { TextWatcherMatchedEvent } from './textwatcher';
|
|
23
|
+
export type { TextWatcherMatchedDataEvent } from './textwatcher';
|
|
24
|
+
import './augmentation';
|
package/src/index.js
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module typing
|
|
7
7
|
*/
|
|
8
|
-
export { default as Typing } from './typing
|
|
9
|
-
export { default as Input } from './input
|
|
10
|
-
export { default as Delete } from './delete
|
|
11
|
-
export { default as TextWatcher } from './textwatcher
|
|
12
|
-
export { default as TwoStepCaretMovement } from './twostepcaretmovement
|
|
13
|
-
export { default as TextTransformation } from './texttransformation
|
|
14
|
-
export { default as inlineHighlight } from './utils/inlinehighlight
|
|
15
|
-
export { default as findAttributeRange, findAttributeRangeBound } from './utils/findattributerange
|
|
16
|
-
export { default as getLastTextLine } from './utils/getlasttextline
|
|
17
|
-
export { default as InsertTextCommand } from './inserttextcommand
|
|
18
|
-
import './augmentation
|
|
8
|
+
export { default as Typing } from './typing';
|
|
9
|
+
export { default as Input } from './input';
|
|
10
|
+
export { default as Delete } from './delete';
|
|
11
|
+
export { default as TextWatcher } from './textwatcher';
|
|
12
|
+
export { default as TwoStepCaretMovement } from './twostepcaretmovement';
|
|
13
|
+
export { default as TextTransformation } from './texttransformation';
|
|
14
|
+
export { default as inlineHighlight } from './utils/inlinehighlight';
|
|
15
|
+
export { default as findAttributeRange, findAttributeRangeBound } from './utils/findattributerange';
|
|
16
|
+
export { default as getLastTextLine } from './utils/getlasttextline';
|
|
17
|
+
export { default as InsertTextCommand } from './inserttextcommand';
|
|
18
|
+
import './augmentation';
|
package/src/input.js
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
9
|
import { env } from '@ckeditor/ckeditor5-utils';
|
|
10
|
-
import InsertTextCommand from './inserttextcommand
|
|
11
|
-
import InsertTextObserver from './inserttextobserver
|
|
10
|
+
import InsertTextCommand from './inserttextcommand';
|
|
11
|
+
import InsertTextObserver from './inserttextobserver';
|
|
12
12
|
/**
|
|
13
13
|
* Handles text input coming from the keyboard or other input methods.
|
|
14
14
|
*/
|
|
@@ -82,6 +82,7 @@ export default class Input extends Plugin {
|
|
|
82
82
|
insertTextCommandData.resultRange = editor.editing.mapper.toModelRange(viewResultRange);
|
|
83
83
|
}
|
|
84
84
|
editor.execute('insertText', insertTextCommandData);
|
|
85
|
+
view.scrollToTheSelection();
|
|
85
86
|
});
|
|
86
87
|
if (env.isAndroid) {
|
|
87
88
|
// On Android with English keyboard, the composition starts just by putting caret
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module typing/inserttextcommand
|
|
7
7
|
*/
|
|
8
8
|
import { Command, type Editor } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
import ChangeBuffer from './utils/changebuffer
|
|
9
|
+
import ChangeBuffer from './utils/changebuffer';
|
|
10
10
|
import type { DocumentSelection, Range, Selection } from '@ckeditor/ckeditor5-engine';
|
|
11
11
|
/**
|
|
12
12
|
* The insert text command. Used by the {@link module:typing/input~Input input feature} to handle typing.
|
package/src/inserttextcommand.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module typing/inserttextcommand
|
|
7
7
|
*/
|
|
8
8
|
import { Command } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
import ChangeBuffer from './utils/changebuffer
|
|
9
|
+
import ChangeBuffer from './utils/changebuffer';
|
|
10
10
|
/**
|
|
11
11
|
* The insert text command. Used by the {@link module:typing/input~Input input feature} to handle typing.
|
|
12
12
|
*/
|
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
import { DomEventData, Observer, type View, type ViewDocumentSelection, type ViewRange, type ViewSelection } from '@ckeditor/ckeditor5-engine';
|
|
5
|
+
import { DomEventData, Observer, FocusObserver, type View, type ViewDocumentSelection, type ViewRange, type ViewSelection } from '@ckeditor/ckeditor5-engine';
|
|
6
6
|
/**
|
|
7
7
|
* Text insertion observer introduces the {@link module:engine/view/document~Document#event:insertText} event.
|
|
8
8
|
*/
|
|
9
9
|
export default class InsertTextObserver extends Observer {
|
|
10
|
+
/**
|
|
11
|
+
* Instance of the focus observer. Insert text observer calls
|
|
12
|
+
* {@link module:engine/view/observer/focusobserver~FocusObserver#flush} to mark the latest focus change as complete.
|
|
13
|
+
*/
|
|
14
|
+
readonly focusObserver: FocusObserver;
|
|
10
15
|
/**
|
|
11
16
|
* @inheritDoc
|
|
12
17
|
*/
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module typing/inserttextobserver
|
|
7
7
|
*/
|
|
8
8
|
import { env, EventInfo } from '@ckeditor/ckeditor5-utils';
|
|
9
|
-
import { DomEventData, Observer } from '@ckeditor/ckeditor5-engine';
|
|
9
|
+
import { DomEventData, Observer, FocusObserver } from '@ckeditor/ckeditor5-engine';
|
|
10
10
|
const TYPING_INPUT_TYPES = [
|
|
11
11
|
// For collapsed range:
|
|
12
12
|
// - This one is a regular typing (all browsers, all systems).
|
|
@@ -28,6 +28,7 @@ export default class InsertTextObserver extends Observer {
|
|
|
28
28
|
*/
|
|
29
29
|
constructor(view) {
|
|
30
30
|
super(view);
|
|
31
|
+
this.focusObserver = view.getObserver(FocusObserver);
|
|
31
32
|
// On Android composition events should immediately be applied to the model. Rendering is not disabled.
|
|
32
33
|
// On non-Android the model is updated only on composition end.
|
|
33
34
|
// On Android we can't rely on composition start/end to update model.
|
|
@@ -43,6 +44,9 @@ export default class InsertTextObserver extends Observer {
|
|
|
43
44
|
if (!TYPING_INPUT_TYPES.includes(inputType)) {
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
47
|
+
// Mark the latest focus change as complete (we are typing in editable after the focus
|
|
48
|
+
// so the selection is in the focused element).
|
|
49
|
+
this.focusObserver.flush();
|
|
46
50
|
const eventInfo = new EventInfo(viewDocument, 'insertText');
|
|
47
51
|
viewDocument.fire(eventInfo, new DomEventData(view, domEvent, {
|
|
48
52
|
text,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module typing/texttransformation
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
import TextWatcher from './textwatcher
|
|
9
|
+
import TextWatcher from './textwatcher';
|
|
10
10
|
import { escapeRegExp } from 'lodash-es';
|
|
11
11
|
// All named transformations.
|
|
12
12
|
const TRANSFORMATIONS = {
|
package/src/textwatcher.js
CHANGED
package/src/typing.d.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* @module typing/typing
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
import Input from './input
|
|
10
|
-
import Delete from './delete
|
|
9
|
+
import Input from './input';
|
|
10
|
+
import Delete from './delete';
|
|
11
11
|
/**
|
|
12
12
|
* The typing feature. It handles typing.
|
|
13
13
|
*
|
package/src/typing.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* @module typing/typing
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from '@ckeditor/ckeditor5-core';
|
|
9
|
-
import Input from './input
|
|
10
|
-
import Delete from './delete
|
|
9
|
+
import Input from './input';
|
|
10
|
+
import Delete from './delete';
|
|
11
11
|
/**
|
|
12
12
|
* The typing feature. It handles typing.
|
|
13
13
|
*
|
|
@@ -18,7 +18,7 @@ import type { Editor } from '@ckeditor/ckeditor5-core';
|
|
|
18
18
|
* Usage:
|
|
19
19
|
*
|
|
20
20
|
* ```ts
|
|
21
|
-
* import inlineHighlight from '@ckeditor/ckeditor5-typing/src/utils/inlinehighlight
|
|
21
|
+
* import inlineHighlight from '@ckeditor/ckeditor5-typing/src/utils/inlinehighlight';
|
|
22
22
|
*
|
|
23
23
|
* // Make `ck-link_selected` class be applied on an `a` element
|
|
24
24
|
* // whenever the corresponding `linkHref` attribute element is selected.
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module typing/utils/inlinehighlight
|
|
7
7
|
*/
|
|
8
|
-
import findAttributeRange from './findattributerange
|
|
8
|
+
import findAttributeRange from './findattributerange';
|
|
9
9
|
/**
|
|
10
10
|
* Adds a visual highlight style to an attribute element in which the selection is anchored.
|
|
11
11
|
* Together with two-step caret movement, they indicate that the user is typing inside the element.
|
|
@@ -21,7 +21,7 @@ import findAttributeRange from './findattributerange.js';
|
|
|
21
21
|
* Usage:
|
|
22
22
|
*
|
|
23
23
|
* ```ts
|
|
24
|
-
* import inlineHighlight from '@ckeditor/ckeditor5-typing/src/utils/inlinehighlight
|
|
24
|
+
* import inlineHighlight from '@ckeditor/ckeditor5-typing/src/utils/inlinehighlight';
|
|
25
25
|
*
|
|
26
26
|
* // Make `ck-link_selected` class be applied on an `a` element
|
|
27
27
|
* // whenever the corresponding `linkHref` attribute element is selected.
|