@ckeditor/ckeditor5-typing 40.0.0 → 40.2.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/src/typing.d.ts CHANGED
@@ -1,23 +1,23 @@
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/typing
7
- */
8
- import { Plugin } from '@ckeditor/ckeditor5-core';
9
- import Input from './input';
10
- import Delete from './delete';
11
- /**
12
- * The typing feature. It handles typing.
13
- *
14
- * This is a "glue" plugin which loads the {@link module:typing/input~Input} and {@link module:typing/delete~Delete}
15
- * plugins.
16
- */
17
- export default class Typing extends Plugin {
18
- static get requires(): readonly [typeof Input, typeof Delete];
19
- /**
20
- * @inheritDoc
21
- */
22
- static get pluginName(): "Typing";
23
- }
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/typing
7
+ */
8
+ import { Plugin } from '@ckeditor/ckeditor5-core';
9
+ import Input from './input';
10
+ import Delete from './delete';
11
+ /**
12
+ * The typing feature. It handles typing.
13
+ *
14
+ * This is a "glue" plugin which loads the {@link module:typing/input~Input} and {@link module:typing/delete~Delete}
15
+ * plugins.
16
+ */
17
+ export default class Typing extends Plugin {
18
+ static get requires(): readonly [typeof Input, typeof Delete];
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get pluginName(): "Typing";
23
+ }
package/src/typing.js CHANGED
@@ -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
- /**
6
- * @module typing/typing
7
- */
8
- import { Plugin } from '@ckeditor/ckeditor5-core';
9
- import Input from './input';
10
- import Delete from './delete';
11
- /**
12
- * The typing feature. It handles typing.
13
- *
14
- * This is a "glue" plugin which loads the {@link module:typing/input~Input} and {@link module:typing/delete~Delete}
15
- * plugins.
16
- */
17
- export default class Typing extends Plugin {
18
- static get requires() {
19
- return [Input, Delete];
20
- }
21
- /**
22
- * @inheritDoc
23
- */
24
- static get pluginName() {
25
- return '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
+ /**
6
+ * @module typing/typing
7
+ */
8
+ import { Plugin } from '@ckeditor/ckeditor5-core';
9
+ import Input from './input';
10
+ import Delete from './delete';
11
+ /**
12
+ * The typing feature. It handles typing.
13
+ *
14
+ * This is a "glue" plugin which loads the {@link module:typing/input~Input} and {@link module:typing/delete~Delete}
15
+ * plugins.
16
+ */
17
+ export default class Typing extends Plugin {
18
+ static get requires() {
19
+ return [Input, Delete];
20
+ }
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ static get pluginName() {
25
+ return 'Typing';
26
+ }
27
+ }
@@ -1,204 +1,204 @@
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/typingconfig
7
- */
8
- /**
9
- * The configuration of the typing features. Used by the typing features in `@ckeditor/ckeditor5-typing` package.
10
- *
11
- * ```ts
12
- * ClassicEditor
13
- * .create( editorElement, {
14
- * typing: ... // Typing feature options.
15
- * } )
16
- * .then( ... )
17
- * .catch( ... );
18
- * ```
19
- *
20
- * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
21
- */
22
- export interface TypingConfig {
23
- /**
24
- * The granularity of undo/redo for typing and deleting. The value `20` means (more or less) that a new undo step
25
- * is created every 20 characters are inserted or deleted.
26
- *
27
- * @default 20
28
- */
29
- undoStep?: number;
30
- /**
31
- * The configuration of the {@link module:typing/texttransformation~TextTransformation} feature.
32
- *
33
- * Read more in {@link module:typing/typingconfig~TextTransformationConfig}.
34
- */
35
- transformations: TextTransformationConfig;
36
- }
37
- /**
38
- * The configuration of the text transformation feature.
39
- *
40
- * ```ts
41
- * ClassicEditor
42
- * .create( editorElement, {
43
- * typing: {
44
- * transformations: ... // Text transformation feature options.
45
- * }
46
- * } )
47
- * .then( ... )
48
- * .catch( ... );
49
- * ```
50
- *
51
- * By default, the feature comes pre-configured
52
- * (via {@link module:typing/typingconfig~TextTransformationConfig#include `config.typing.transformations.include`}) with the
53
- * following groups of transformations:
54
- *
55
- * * Typography (group name: `typography`)
56
- * - `ellipsis`: transforms `...` to `…`
57
- * - `enDash`: transforms ` -- ` to ` – `
58
- * - `emDash`: transforms ` --- ` to ` — `
59
- * * Quotations (group name: `quotes`)
60
- * - `quotesPrimary`: transforms `"Foo bar"` to `“Foo bar”`
61
- * - `quotesSecondary`: transforms `'Foo bar'` to `‘Foo bar’`
62
- * * Symbols (group name: `symbols`)
63
- * - `trademark`: transforms `(tm)` to `™`
64
- * - `registeredTrademark`: transforms `(r)` to `®`
65
- * - `copyright`: transforms `(c)` to `©`
66
- * * Mathematical (group name: `mathematical`)
67
- * - `oneHalf`: transforms `1/2` to: `½`
68
- * - `oneThird`: transforms `1/3` to: `⅓`
69
- * - `twoThirds`: transforms `2/3` to: `⅔`
70
- * - `oneForth`: transforms `1/4` to: `¼`
71
- * - `threeQuarters`: transforms `3/4` to: `¾`
72
- * - `lessThanOrEqual`: transforms `<=` to: `≤`
73
- * - `greaterThanOrEqual`: transforms `>=` to: `≥`
74
- * - `notEqual`: transforms `!=` to: `≠`
75
- * - `arrowLeft`: transforms `<-` to: `←`
76
- * - `arrowRight`: transforms `->` to: `→`
77
- * * Misc:
78
- * - `quotesPrimaryEnGb`: transforms `'Foo bar'` to `‘Foo bar’`
79
- * - `quotesSecondaryEnGb`: transforms `"Foo bar"` to `“Foo bar”`
80
- * - `quotesPrimaryPl`: transforms `"Foo bar"` to `„Foo bar”`
81
- * - `quotesSecondaryPl`: transforms `'Foo bar'` to `‚Foo bar’`
82
- *
83
- * In order to load additional transformations, use the
84
- * {@link module:typing/typingconfig~TextTransformationConfig#extra `transformations.extra` option}.
85
- *
86
- * In order to narrow down the list of transformations, use the
87
- * {@link module:typing/typingconfig~TextTransformationConfig#remove `transformations.remove` option}.
88
- *
89
- * In order to completely override the supported transformations, use the
90
- * {@link module:typing/typingconfig~TextTransformationConfig#include `transformations.include` option}.
91
- *
92
- * Examples:
93
- *
94
- * ```ts
95
- * const transformationsConfig = {
96
- * include: [
97
- * // Use only the 'quotes' and 'typography' groups.
98
- * 'quotes',
99
- * 'typography',
100
- *
101
- * // Plus, some custom transformation.
102
- * { from: 'CKE', to: 'CKEditor' }
103
- * ]
104
- * };
105
- *
106
- * const transformationsConfig = {
107
- * // Remove the 'ellipsis' transformation loaded by the 'typography' group.
108
- * remove: [ 'ellipsis' ]
109
- * }
110
- * ```
111
- */
112
- export interface TextTransformationConfig {
113
- /**
114
- * The standard list of text transformations supported by the editor. By default it comes pre-configured with a couple dozen of them
115
- * (see {@link module:typing/typingconfig~TextTransformationConfig} for the full list). You can override this list completely
116
- * by setting this option or use the other two options
117
- * ({@link module:typing/typingconfig~TextTransformationConfig#extra `transformations.extra`},
118
- * {@link module:typing/typingconfig~TextTransformationConfig#remove `transformations.remove`}) to fine-tune the default list.
119
- */
120
- include: Array<TextTransformationDescription | string>;
121
- /**
122
- * Additional text transformations that are added to the transformations defined in
123
- * {@link module:typing/typingconfig~TextTransformationConfig#include `transformations.include`}.
124
- *
125
- * ```ts
126
- * const transformationsConfig = {
127
- * extra: [
128
- * { from: 'CKE', to: 'CKEditor' }
129
- * ]
130
- * };
131
- * ```
132
- */
133
- extra?: Array<TextTransformationDescription | string>;
134
- /**
135
- * The text transformation names that are removed from transformations defined in
136
- * {@link module:typing/typingconfig~TextTransformationConfig#include `transformations.include`} or
137
- * {@link module:typing/typingconfig~TextTransformationConfig#extra `transformations.extra`}.
138
- *
139
- * ```ts
140
- * const transformationsConfig = {
141
- * remove: [
142
- * 'ellipsis', // Remove only 'ellipsis' from the 'typography' group.
143
- * 'mathematical' // Remove all transformations from the 'mathematical' group.
144
- * ]
145
- * }
146
- * ```
147
- */
148
- remove?: Array<TextTransformationDescription | string>;
149
- }
150
- /**
151
- * The text transformation definition object. It describes what should be replaced with what.
152
- *
153
- * The input value (`from`) can be passed either as a string or as a regular expression.
154
- *
155
- * * If a string is passed, it will be simply checked if the end of the input matches it.
156
- * * If a regular expression is passed, its entire length must be covered with capturing groups (e.g. `/(foo)(bar)$/`).
157
- * Also, since it is compared against the end of the input, it has to end with `$` to be correctly matched.
158
- * See examples below.
159
- *
160
- * The output value (`to`) can be passed as a string, as an array or as a function.
161
- *
162
- * * If a string is passed, it will be used as a replacement value as-is. Note that a string output value can be used only if
163
- * the input value is a string, too.
164
- * * If an array is passed, it has to have the same number of elements as there are capturing groups in the input value regular expression.
165
- * Each capture group will be replaced with a corresponding string from the passed array. If a given capturing group should not be replaced,
166
- * use `null` instead of passing a string.
167
- * * If a function is used, it should return an array as described above. The function is passed one parameter &mdash; an array with matches
168
- * by the regular expression. See the examples below.
169
- *
170
- * A simple string-to-string replacement:
171
- *
172
- * ```ts
173
- * { from: '(c)', to: '©' }
174
- * ```
175
- *
176
- * Change quote styles using a regular expression. Note how all the parts are in separate capturing groups and the space at the beginning
177
- * and the text inside quotes are not replaced (`null` passed as the first and the third value in the `to` parameter):
178
- *
179
- * ```ts
180
- * {
181
- * from: /(^|\s)(")([^"]*)(")$/,
182
- * to: [ null, '“', null, '”' ]
183
- * }
184
- * ```
185
- *
186
- * Automatic uppercase after a dot using a callback:
187
- *
188
- * ```ts
189
- * {
190
- * from: /(\. )([a-z])$/,
191
- * to: matches => [ null, matches[ 1 ].toUpperCase() ]
192
- * }
193
- * ```
194
- */
195
- export interface TextTransformationDescription {
196
- /**
197
- * The string or regular expression to transform.
198
- */
199
- from: string | RegExp;
200
- /**
201
- * The text to transform compatible with `String.replace()`.
202
- */
203
- to: string | Array<string | null> | ((matches: Array<string>) => Array<string | null>);
204
- }
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/typingconfig
7
+ */
8
+ /**
9
+ * The configuration of the typing features. Used by the typing features in `@ckeditor/ckeditor5-typing` package.
10
+ *
11
+ * ```ts
12
+ * ClassicEditor
13
+ * .create( editorElement, {
14
+ * typing: ... // Typing feature options.
15
+ * } )
16
+ * .then( ... )
17
+ * .catch( ... );
18
+ * ```
19
+ *
20
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
21
+ */
22
+ export interface TypingConfig {
23
+ /**
24
+ * The granularity of undo/redo for typing and deleting. The value `20` means (more or less) that a new undo step
25
+ * is created every 20 characters are inserted or deleted.
26
+ *
27
+ * @default 20
28
+ */
29
+ undoStep?: number;
30
+ /**
31
+ * The configuration of the {@link module:typing/texttransformation~TextTransformation} feature.
32
+ *
33
+ * Read more in {@link module:typing/typingconfig~TextTransformationConfig}.
34
+ */
35
+ transformations: TextTransformationConfig;
36
+ }
37
+ /**
38
+ * The configuration of the text transformation feature.
39
+ *
40
+ * ```ts
41
+ * ClassicEditor
42
+ * .create( editorElement, {
43
+ * typing: {
44
+ * transformations: ... // Text transformation feature options.
45
+ * }
46
+ * } )
47
+ * .then( ... )
48
+ * .catch( ... );
49
+ * ```
50
+ *
51
+ * By default, the feature comes pre-configured
52
+ * (via {@link module:typing/typingconfig~TextTransformationConfig#include `config.typing.transformations.include`}) with the
53
+ * following groups of transformations:
54
+ *
55
+ * * Typography (group name: `typography`)
56
+ * - `ellipsis`: transforms `...` to `…`
57
+ * - `enDash`: transforms ` -- ` to ` – `
58
+ * - `emDash`: transforms ` --- ` to ` — `
59
+ * * Quotations (group name: `quotes`)
60
+ * - `quotesPrimary`: transforms `"Foo bar"` to `“Foo bar”`
61
+ * - `quotesSecondary`: transforms `'Foo bar'` to `‘Foo bar’`
62
+ * * Symbols (group name: `symbols`)
63
+ * - `trademark`: transforms `(tm)` to `™`
64
+ * - `registeredTrademark`: transforms `(r)` to `®`
65
+ * - `copyright`: transforms `(c)` to `©`
66
+ * * Mathematical (group name: `mathematical`)
67
+ * - `oneHalf`: transforms `1/2` to: `½`
68
+ * - `oneThird`: transforms `1/3` to: `⅓`
69
+ * - `twoThirds`: transforms `2/3` to: `⅔`
70
+ * - `oneForth`: transforms `1/4` to: `¼`
71
+ * - `threeQuarters`: transforms `3/4` to: `¾`
72
+ * - `lessThanOrEqual`: transforms `<=` to: `≤`
73
+ * - `greaterThanOrEqual`: transforms `>=` to: `≥`
74
+ * - `notEqual`: transforms `!=` to: `≠`
75
+ * - `arrowLeft`: transforms `<-` to: `←`
76
+ * - `arrowRight`: transforms `->` to: `→`
77
+ * * Misc:
78
+ * - `quotesPrimaryEnGb`: transforms `'Foo bar'` to `‘Foo bar’`
79
+ * - `quotesSecondaryEnGb`: transforms `"Foo bar"` to `“Foo bar”`
80
+ * - `quotesPrimaryPl`: transforms `"Foo bar"` to `„Foo bar”`
81
+ * - `quotesSecondaryPl`: transforms `'Foo bar'` to `‚Foo bar’`
82
+ *
83
+ * In order to load additional transformations, use the
84
+ * {@link module:typing/typingconfig~TextTransformationConfig#extra `transformations.extra` option}.
85
+ *
86
+ * In order to narrow down the list of transformations, use the
87
+ * {@link module:typing/typingconfig~TextTransformationConfig#remove `transformations.remove` option}.
88
+ *
89
+ * In order to completely override the supported transformations, use the
90
+ * {@link module:typing/typingconfig~TextTransformationConfig#include `transformations.include` option}.
91
+ *
92
+ * Examples:
93
+ *
94
+ * ```ts
95
+ * const transformationsConfig = {
96
+ * include: [
97
+ * // Use only the 'quotes' and 'typography' groups.
98
+ * 'quotes',
99
+ * 'typography',
100
+ *
101
+ * // Plus, some custom transformation.
102
+ * { from: 'CKE', to: 'CKEditor' }
103
+ * ]
104
+ * };
105
+ *
106
+ * const transformationsConfig = {
107
+ * // Remove the 'ellipsis' transformation loaded by the 'typography' group.
108
+ * remove: [ 'ellipsis' ]
109
+ * }
110
+ * ```
111
+ */
112
+ export interface TextTransformationConfig {
113
+ /**
114
+ * The standard list of text transformations supported by the editor. By default it comes pre-configured with a couple dozen of them
115
+ * (see {@link module:typing/typingconfig~TextTransformationConfig} for the full list). You can override this list completely
116
+ * by setting this option or use the other two options
117
+ * ({@link module:typing/typingconfig~TextTransformationConfig#extra `transformations.extra`},
118
+ * {@link module:typing/typingconfig~TextTransformationConfig#remove `transformations.remove`}) to fine-tune the default list.
119
+ */
120
+ include: Array<TextTransformationDescription | string>;
121
+ /**
122
+ * Additional text transformations that are added to the transformations defined in
123
+ * {@link module:typing/typingconfig~TextTransformationConfig#include `transformations.include`}.
124
+ *
125
+ * ```ts
126
+ * const transformationsConfig = {
127
+ * extra: [
128
+ * { from: 'CKE', to: 'CKEditor' }
129
+ * ]
130
+ * };
131
+ * ```
132
+ */
133
+ extra?: Array<TextTransformationDescription | string>;
134
+ /**
135
+ * The text transformation names that are removed from transformations defined in
136
+ * {@link module:typing/typingconfig~TextTransformationConfig#include `transformations.include`} or
137
+ * {@link module:typing/typingconfig~TextTransformationConfig#extra `transformations.extra`}.
138
+ *
139
+ * ```ts
140
+ * const transformationsConfig = {
141
+ * remove: [
142
+ * 'ellipsis', // Remove only 'ellipsis' from the 'typography' group.
143
+ * 'mathematical' // Remove all transformations from the 'mathematical' group.
144
+ * ]
145
+ * }
146
+ * ```
147
+ */
148
+ remove?: Array<TextTransformationDescription | string>;
149
+ }
150
+ /**
151
+ * The text transformation definition object. It describes what should be replaced with what.
152
+ *
153
+ * The input value (`from`) can be passed either as a string or as a regular expression.
154
+ *
155
+ * * If a string is passed, it will be simply checked if the end of the input matches it.
156
+ * * If a regular expression is passed, its entire length must be covered with capturing groups (e.g. `/(foo)(bar)$/`).
157
+ * Also, since it is compared against the end of the input, it has to end with `$` to be correctly matched.
158
+ * See examples below.
159
+ *
160
+ * The output value (`to`) can be passed as a string, as an array or as a function.
161
+ *
162
+ * * If a string is passed, it will be used as a replacement value as-is. Note that a string output value can be used only if
163
+ * the input value is a string, too.
164
+ * * If an array is passed, it has to have the same number of elements as there are capturing groups in the input value regular expression.
165
+ * Each capture group will be replaced with a corresponding string from the passed array. If a given capturing group should not be replaced,
166
+ * use `null` instead of passing a string.
167
+ * * If a function is used, it should return an array as described above. The function is passed one parameter &ndash; an array with matches
168
+ * by the regular expression. See the examples below.
169
+ *
170
+ * A simple string-to-string replacement:
171
+ *
172
+ * ```ts
173
+ * { from: '(c)', to: '©' }
174
+ * ```
175
+ *
176
+ * Change quote styles using a regular expression. Note how all the parts are in separate capturing groups and the space at the beginning
177
+ * and the text inside quotes are not replaced (`null` passed as the first and the third value in the `to` parameter):
178
+ *
179
+ * ```ts
180
+ * {
181
+ * from: /(^|\s)(")([^"]*)(")$/,
182
+ * to: [ null, '“', null, '”' ]
183
+ * }
184
+ * ```
185
+ *
186
+ * Automatic uppercase after a dot using a callback:
187
+ *
188
+ * ```ts
189
+ * {
190
+ * from: /(\. )([a-z])$/,
191
+ * to: matches => [ null, matches[ 1 ].toUpperCase() ]
192
+ * }
193
+ * ```
194
+ */
195
+ export interface TextTransformationDescription {
196
+ /**
197
+ * The string or regular expression to transform.
198
+ */
199
+ from: string | RegExp;
200
+ /**
201
+ * The text to transform compatible with `String.replace()`.
202
+ */
203
+ to: string | Array<string | null> | ((matches: Array<string>) => Array<string | null>);
204
+ }
@@ -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 {};