@ckeditor/ckeditor5-typing 35.2.1 → 35.3.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.
@@ -2,445 +2,235 @@
2
2
  * @license Copyright (c) 2003-2022, 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
-
6
5
  /**
7
6
  * @module typing/texttransformation
8
7
  */
9
-
10
8
  import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
11
9
  import TextWatcher from './textwatcher';
12
10
  import { escapeRegExp } from 'lodash-es';
13
-
14
11
  // All named transformations.
15
12
  const TRANSFORMATIONS = {
16
- // Common symbols:
17
- copyright: { from: '(c)', to: '©' },
18
- registeredTrademark: { from: '(r)', to: '®' },
19
- trademark: { from: '(tm)', to: '™' },
20
-
21
- // Mathematical:
22
- oneHalf: { from: /(^|[^/a-z0-9])(1\/2)([^/a-z0-9])$/i, to: [ null, '½', null ] },
23
- oneThird: { from: /(^|[^/a-z0-9])(1\/3)([^/a-z0-9])$/i, to: [ null, '', null ] },
24
- twoThirds: { from: /(^|[^/a-z0-9])(2\/3)([^/a-z0-9])$/i, to: [ null, '', null ] },
25
- oneForth: { from: /(^|[^/a-z0-9])(1\/4)([^/a-z0-9])$/i, to: [ null, '¼', null ] },
26
- threeQuarters: { from: /(^|[^/a-z0-9])(3\/4)([^/a-z0-9])$/i, to: [ null, '¾', null ] },
27
- lessThanOrEqual: { from: '<=', to: '' },
28
- greaterThanOrEqual: { from: '>=', to: '' },
29
- notEqual: { from: '!=', to: '' },
30
- arrowLeft: { from: '<-', to: '' },
31
- arrowRight: { from: '->', to: '→' },
32
-
33
- // Typography:
34
- horizontalEllipsis: { from: '...', to: '' },
35
- enDash: { from: /(^| )(--)( )$/, to: [ null, '–', null ] },
36
- emDash: { from: /(^| )(---)( )$/, to: [ null, '—', null ] },
37
- // Quotations:
38
- // English, US
39
- quotesPrimary: { from: buildQuotesRegExp( '"' ), to: [ null, '“', null, '”' ] },
40
- quotesSecondary: { from: buildQuotesRegExp( '\'' ), to: [ null, '‘', null, '’' ] },
41
-
42
- // English, UK
43
- quotesPrimaryEnGb: { from: buildQuotesRegExp( '\'' ), to: [ null, '', null, '' ] },
44
- quotesSecondaryEnGb: { from: buildQuotesRegExp( '"' ), to: [ null, '', null, '' ] },
45
-
46
- // Polish
47
- quotesPrimaryPl: { from: buildQuotesRegExp( '"' ), to: [ null, '„', null, '”' ] },
48
- quotesSecondaryPl: { from: buildQuotesRegExp( '\'' ), to: [ null, '‚', null, '’' ] }
13
+ // Common symbols:
14
+ copyright: { from: '(c)', to: '©' },
15
+ registeredTrademark: { from: '(r)', to: '®' },
16
+ trademark: { from: '(tm)', to: '™' },
17
+ // Mathematical:
18
+ oneHalf: { from: /(^|[^/a-z0-9])(1\/2)([^/a-z0-9])$/i, to: [null, '½', null] },
19
+ oneThird: { from: /(^|[^/a-z0-9])(1\/3)([^/a-z0-9])$/i, to: [null, '', null] },
20
+ twoThirds: { from: /(^|[^/a-z0-9])(2\/3)([^/a-z0-9])$/i, to: [null, '', null] },
21
+ oneForth: { from: /(^|[^/a-z0-9])(1\/4)([^/a-z0-9])$/i, to: [null, '¼', null] },
22
+ threeQuarters: { from: /(^|[^/a-z0-9])(3\/4)([^/a-z0-9])$/i, to: [null, '¾', null] },
23
+ lessThanOrEqual: { from: '<=', to: '' },
24
+ greaterThanOrEqual: { from: '>=', to: '' },
25
+ notEqual: { from: '!=', to: '' },
26
+ arrowLeft: { from: '<-', to: '' },
27
+ arrowRight: { from: '->', to: '' },
28
+ // Typography:
29
+ horizontalEllipsis: { from: '...', to: '…' },
30
+ enDash: { from: /(^| )(--)( )$/, to: [null, '–', null] },
31
+ emDash: { from: /(^| )(---)( )$/, to: [null, '', null] },
32
+ // Quotations:
33
+ // English, US
34
+ quotesPrimary: { from: buildQuotesRegExp('"'), to: [null, '“', null, '”'] },
35
+ quotesSecondary: { from: buildQuotesRegExp('\''), to: [null, '‘', null, '’'] },
36
+ // English, UK
37
+ quotesPrimaryEnGb: { from: buildQuotesRegExp('\''), to: [null, '‘', null, '’'] },
38
+ quotesSecondaryEnGb: { from: buildQuotesRegExp('"'), to: [null, '“', null, '”'] },
39
+ // Polish
40
+ quotesPrimaryPl: { from: buildQuotesRegExp('"'), to: [null, '', null, ''] },
41
+ quotesSecondaryPl: { from: buildQuotesRegExp('\''), to: [null, '', null, ''] }
49
42
  };
50
-
51
43
  // Transformation groups.
52
44
  const TRANSFORMATION_GROUPS = {
53
- symbols: [ 'copyright', 'registeredTrademark', 'trademark' ],
54
- mathematical: [
55
- 'oneHalf', 'oneThird', 'twoThirds', 'oneForth', 'threeQuarters',
56
- 'lessThanOrEqual', 'greaterThanOrEqual', 'notEqual',
57
- 'arrowLeft', 'arrowRight'
58
- ],
59
- typography: [ 'horizontalEllipsis', 'enDash', 'emDash' ],
60
- quotes: [ 'quotesPrimary', 'quotesSecondary' ]
45
+ symbols: ['copyright', 'registeredTrademark', 'trademark'],
46
+ mathematical: [
47
+ 'oneHalf', 'oneThird', 'twoThirds', 'oneForth', 'threeQuarters',
48
+ 'lessThanOrEqual', 'greaterThanOrEqual', 'notEqual',
49
+ 'arrowLeft', 'arrowRight'
50
+ ],
51
+ typography: ['horizontalEllipsis', 'enDash', 'emDash'],
52
+ quotes: ['quotesPrimary', 'quotesSecondary']
61
53
  };
62
-
63
54
  // A set of default transformations provided by the feature.
64
55
  const DEFAULT_TRANSFORMATIONS = [
65
- 'symbols',
66
- 'mathematical',
67
- 'typography',
68
- 'quotes'
56
+ 'symbols',
57
+ 'mathematical',
58
+ 'typography',
59
+ 'quotes'
69
60
  ];
70
-
71
61
  /**
72
62
  * The text transformation plugin.
73
63
  *
74
64
  * @extends module:core/plugin~Plugin
75
65
  */
76
66
  export default class TextTransformation extends Plugin {
77
- /**
78
- * @inheritDoc
79
- */
80
- static get requires() {
81
- return [ 'Delete', 'Input' ];
82
- }
83
-
84
- /**
85
- * @inheritDoc
86
- */
87
- static get pluginName() {
88
- return 'TextTransformation';
89
- }
90
-
91
- /**
92
- * @inheritDoc
93
- */
94
- constructor( editor ) {
95
- super( editor );
96
-
97
- editor.config.define( 'typing', {
98
- transformations: {
99
- include: DEFAULT_TRANSFORMATIONS
100
- }
101
- } );
102
- }
103
-
104
- /**
105
- * @inheritDoc
106
- */
107
- init() {
108
- const model = this.editor.model;
109
- const modelSelection = model.document.selection;
110
-
111
- modelSelection.on( 'change:range', () => {
112
- // Disable plugin when selection is inside a code block.
113
- this.isEnabled = !modelSelection.anchor.parent.is( 'element', 'codeBlock' );
114
- } );
115
-
116
- this._enableTransformationWatchers();
117
- }
118
-
119
- /**
120
- * Create new TextWatcher listening to the editor for typing and selection events.
121
- *
122
- * @private
123
- */
124
- _enableTransformationWatchers() {
125
- const editor = this.editor;
126
- const model = editor.model;
127
- const deletePlugin = editor.plugins.get( 'Delete' );
128
- const normalizedTransformations = normalizeTransformations( editor.config.get( 'typing.transformations' ) );
129
-
130
- const testCallback = text => {
131
- for ( const normalizedTransformation of normalizedTransformations ) {
132
- const from = normalizedTransformation.from;
133
- const match = from.test( text );
134
-
135
- if ( match ) {
136
- return { normalizedTransformation };
137
- }
138
- }
139
- };
140
-
141
- const watcherCallback = ( evt, data ) => {
142
- if ( !data.batch.isTyping ) {
143
- return;
144
- }
145
-
146
- const { from, to } = data.normalizedTransformation;
147
-
148
- const matches = from.exec( data.text );
149
- const replaces = to( matches.slice( 1 ) );
150
-
151
- const matchedRange = data.range;
152
-
153
- let changeIndex = matches.index;
154
-
155
- model.enqueueChange( writer => {
156
- for ( let i = 1; i < matches.length; i++ ) {
157
- const match = matches[ i ];
158
- const replaceWith = replaces[ i - 1 ];
159
-
160
- if ( replaceWith == null ) {
161
- changeIndex += match.length;
162
-
163
- continue;
164
- }
165
-
166
- const replacePosition = matchedRange.start.getShiftedBy( changeIndex );
167
- const replaceRange = model.createRange( replacePosition, replacePosition.getShiftedBy( match.length ) );
168
- const attributes = getTextAttributesAfterPosition( replacePosition );
169
-
170
- model.insertContent( writer.createText( replaceWith, attributes ), replaceRange );
171
-
172
- changeIndex += replaceWith.length;
173
- }
174
-
175
- model.enqueueChange( () => {
176
- deletePlugin.requestUndoOnBackspace();
177
- } );
178
- } );
179
- };
180
-
181
- const watcher = new TextWatcher( editor.model, testCallback );
182
-
183
- watcher.on( 'matched:data', watcherCallback );
184
- watcher.bind( 'isEnabled' ).to( this );
185
- }
67
+ /**
68
+ * @inheritDoc
69
+ */
70
+ static get requires() {
71
+ return ['Delete', 'Input'];
72
+ }
73
+ /**
74
+ * @inheritDoc
75
+ */
76
+ static get pluginName() {
77
+ return 'TextTransformation';
78
+ }
79
+ /**
80
+ * @inheritDoc
81
+ */
82
+ constructor(editor) {
83
+ super(editor);
84
+ editor.config.define('typing', {
85
+ transformations: {
86
+ include: DEFAULT_TRANSFORMATIONS
87
+ }
88
+ });
89
+ }
90
+ /**
91
+ * @inheritDoc
92
+ */
93
+ init() {
94
+ const model = this.editor.model;
95
+ const modelSelection = model.document.selection;
96
+ modelSelection.on('change:range', () => {
97
+ // Disable plugin when selection is inside a code block.
98
+ this.isEnabled = !modelSelection.anchor.parent.is('element', 'codeBlock');
99
+ });
100
+ this._enableTransformationWatchers();
101
+ }
102
+ /**
103
+ * Create new TextWatcher listening to the editor for typing and selection events.
104
+ *
105
+ * @private
106
+ */
107
+ _enableTransformationWatchers() {
108
+ const editor = this.editor;
109
+ const model = editor.model;
110
+ const deletePlugin = editor.plugins.get('Delete');
111
+ const normalizedTransformations = normalizeTransformations(editor.config.get('typing.transformations'));
112
+ const testCallback = (text) => {
113
+ for (const normalizedTransformation of normalizedTransformations) {
114
+ const from = normalizedTransformation.from;
115
+ const match = from.test(text);
116
+ if (match) {
117
+ return { normalizedTransformation };
118
+ }
119
+ }
120
+ };
121
+ const watcher = new TextWatcher(editor.model, testCallback);
122
+ watcher.on('matched:data', (evt, data) => {
123
+ if (!data.batch.isTyping) {
124
+ return;
125
+ }
126
+ const { from, to } = data.normalizedTransformation;
127
+ const matches = from.exec(data.text);
128
+ const replaces = to(matches.slice(1));
129
+ const matchedRange = data.range;
130
+ let changeIndex = matches.index;
131
+ model.enqueueChange(writer => {
132
+ for (let i = 1; i < matches.length; i++) {
133
+ const match = matches[i];
134
+ const replaceWith = replaces[i - 1];
135
+ if (replaceWith == null) {
136
+ changeIndex += match.length;
137
+ continue;
138
+ }
139
+ const replacePosition = matchedRange.start.getShiftedBy(changeIndex);
140
+ const replaceRange = model.createRange(replacePosition, replacePosition.getShiftedBy(match.length));
141
+ const attributes = getTextAttributesAfterPosition(replacePosition);
142
+ model.insertContent(writer.createText(replaceWith, attributes), replaceRange);
143
+ changeIndex += replaceWith.length;
144
+ }
145
+ model.enqueueChange(() => {
146
+ deletePlugin.requestUndoOnBackspace();
147
+ });
148
+ });
149
+ });
150
+ watcher.bind('isEnabled').to(this);
151
+ }
186
152
  }
187
-
188
153
  // Normalizes the configuration `from` parameter value.
189
154
  // The normalized value for the `from` parameter is a RegExp instance. If the passed `from` is already a RegExp instance,
190
155
  // it is returned unchanged.
191
156
  //
192
157
  // @param {String|RegExp} from
193
158
  // @returns {RegExp}
194
- function normalizeFrom( from ) {
195
- if ( typeof from == 'string' ) {
196
- return new RegExp( `(${ escapeRegExp( from ) })$` );
197
- }
198
-
199
- // `from` is already a regular expression.
200
- return from;
159
+ function normalizeFrom(from) {
160
+ if (typeof from == 'string') {
161
+ return new RegExp(`(${escapeRegExp(from)})$`);
162
+ }
163
+ // `from` is already a regular expression.
164
+ return from;
201
165
  }
202
-
203
166
  // Normalizes the configuration `to` parameter value.
204
167
  // The normalized value for the `to` parameter is a function that takes an array and returns an array. See more in the
205
168
  // configuration description. If the passed `to` is already a function, it is returned unchanged.
206
169
  //
207
170
  // @param {String|Array.<null|String>|Function} to
208
171
  // @returns {Function}
209
- function normalizeTo( to ) {
210
- if ( typeof to == 'string' ) {
211
- return () => [ to ];
212
- } else if ( to instanceof Array ) {
213
- return () => to;
214
- }
215
-
216
- // `to` is already a function.
217
- return to;
172
+ function normalizeTo(to) {
173
+ if (typeof to == 'string') {
174
+ return () => [to];
175
+ }
176
+ else if (to instanceof Array) {
177
+ return () => to;
178
+ }
179
+ // `to` is already a function.
180
+ return to;
218
181
  }
219
-
220
182
  // For given `position` returns attributes for the text that is after that position.
221
183
  // The text can be in the same text node as the position (`foo[]bar`) or in the next text node (`foo[]<$text bold="true">bar</$text>`).
222
184
  //
223
185
  // @param {module:engine/model/position~Position} position
224
186
  // @returns {Iterable.<*>}
225
- function getTextAttributesAfterPosition( position ) {
226
- const textNode = position.textNode ? position.textNode : position.nodeAfter;
227
-
228
- return textNode.getAttributes();
187
+ function getTextAttributesAfterPosition(position) {
188
+ const textNode = position.textNode ? position.textNode : position.nodeAfter;
189
+ return textNode.getAttributes();
229
190
  }
230
-
231
191
  // Returns a RegExp pattern string that detects a sentence inside a quote.
232
192
  //
233
193
  // @param {String} quoteCharacter The character to create a pattern for.
234
194
  // @returns {String}
235
- function buildQuotesRegExp( quoteCharacter ) {
236
- return new RegExp( `(^|\\s)(${ quoteCharacter })([^${ quoteCharacter }]*)(${ quoteCharacter })$` );
195
+ function buildQuotesRegExp(quoteCharacter) {
196
+ return new RegExp(`(^|\\s)(${quoteCharacter})([^${quoteCharacter}]*)(${quoteCharacter})$`);
237
197
  }
238
-
239
198
  // Reads text transformation config and returns normalized array of transformations objects.
240
199
  //
241
200
  // @param {module:typing/texttransformation~TextTransformationDescription} config
242
201
  // @returns {Array.<{from:String,to:Function}>}
243
- function normalizeTransformations( config ) {
244
- const extra = config.extra || [];
245
- const remove = config.remove || [];
246
- const isNotRemoved = transformation => !remove.includes( transformation );
247
-
248
- const configured = config.include.concat( extra ).filter( isNotRemoved );
249
-
250
- return expandGroupsAndRemoveDuplicates( configured )
251
- .filter( isNotRemoved ) // Filter out 'remove' transformations as they might be set in group.
252
- .map( transformation => TRANSFORMATIONS[ transformation ] || transformation )
253
- .filter( transformation => typeof transformation === 'object' ) // Filter out transformations set as string that has not been found.
254
- .map( transformation => ( {
255
- from: normalizeFrom( transformation.from ),
256
- to: normalizeTo( transformation.to )
257
- } ) );
202
+ function normalizeTransformations(config) {
203
+ const extra = config.extra || [];
204
+ const remove = config.remove || [];
205
+ const isNotRemoved = (transformation) => !remove.includes(transformation);
206
+ const configured = config.include.concat(extra).filter(isNotRemoved);
207
+ return expandGroupsAndRemoveDuplicates(configured)
208
+ .filter(isNotRemoved) // Filter out 'remove' transformations as they might be set in group.
209
+ .map(transformation => (typeof transformation == 'string' && TRANSFORMATIONS[transformation] ? TRANSFORMATIONS[transformation] : transformation))
210
+ // Filter out transformations set as string that has not been found.
211
+ .filter((transformation) => typeof transformation === 'object')
212
+ .map(transformation => ({
213
+ from: normalizeFrom(transformation.from),
214
+ to: normalizeTo(transformation.to)
215
+ }));
258
216
  }
259
-
260
217
  // Reads definitions and expands named groups if needed to transformation names.
261
218
  // This method also removes duplicated named transformations if any.
262
219
  //
263
220
  // @param {Array.<String|Object>} definitions
264
221
  // @returns {Array.<String|Object>}
265
- function expandGroupsAndRemoveDuplicates( definitions ) {
266
- // Set is using to make sure that transformation names are not duplicated.
267
- const definedTransformations = new Set();
268
-
269
- for ( const transformationOrGroup of definitions ) {
270
- if ( TRANSFORMATION_GROUPS[ transformationOrGroup ] ) {
271
- for ( const transformation of TRANSFORMATION_GROUPS[ transformationOrGroup ] ) {
272
- definedTransformations.add( transformation );
273
- }
274
- } else {
275
- definedTransformations.add( transformationOrGroup );
276
- }
277
- }
278
-
279
- return Array.from( definedTransformations );
222
+ function expandGroupsAndRemoveDuplicates(definitions) {
223
+ // Set is using to make sure that transformation names are not duplicated.
224
+ const definedTransformations = new Set();
225
+ for (const transformationOrGroup of definitions) {
226
+ if (typeof transformationOrGroup == 'string' && TRANSFORMATION_GROUPS[transformationOrGroup]) {
227
+ for (const transformation of TRANSFORMATION_GROUPS[transformationOrGroup]) {
228
+ definedTransformations.add(transformation);
229
+ }
230
+ }
231
+ else {
232
+ definedTransformations.add(transformationOrGroup);
233
+ }
234
+ }
235
+ return Array.from(definedTransformations);
280
236
  }
281
-
282
- /**
283
- * The text transformation definition object. It describes what should be replaced with what.
284
- *
285
- * The input value (`from`) can be passed either as a string or as a regular expression.
286
- *
287
- * * If a string is passed, it will be simply checked if the end of the input matches it.
288
- * * If a regular expression is passed, its entire length must be covered with capturing groups (e.g. `/(foo)(bar)$/`).
289
- * Also, since it is compared against the end of the input, it has to end with `$` to be correctly matched.
290
- * See examples below.
291
- *
292
- * The output value (`to`) can be passed as a string, as an array or as a function.
293
- *
294
- * * 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
295
- * the input value is a string, too.
296
- * * 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.
297
- * Each capture group will be replaced with a corresponding string from the passed array. If a given capturing group should not be replaced,
298
- * use `null` instead of passing a string.
299
- * * If a function is used, it should return an array as described above. The function is passed one parameter &mdash; an array with matches
300
- * by the regular expression. See the examples below.
301
- *
302
- * A simple string-to-string replacement:
303
- *
304
- * { from: '(c)', to: '©' }
305
- *
306
- * Change quote styles using a regular expression. Note how all the parts are in separate capturing groups and the space at the beginning
307
- * and the text inside quotes are not replaced (`null` passed as the first and the third value in the `to` parameter):
308
- *
309
- * {
310
- * from: /(^|\s)(")([^"]*)(")$/,
311
- * to: [ null, '“', null, '”' ]
312
- * }
313
- *
314
- * Automatic uppercase after a dot using a callback:
315
- *
316
- * {
317
- * from: /(\. )([a-z])$/,
318
- * to: matches => [ null, matches[ 1 ].toUpperCase() ]
319
- * }
320
- *
321
- * @typedef {Object} module:typing/texttransformation~TextTransformationDescription
322
- * @property {String|RegExp} from The string or regular expression to transform.
323
- * @property {String} to The text to transform compatible with `String.replace()`.
324
- */
325
-
326
- /**
327
- * The configuration of the {@link module:typing/texttransformation~TextTransformation} feature.
328
- *
329
- * Read more in {@link module:typing/texttransformation~TextTransformationConfig}.
330
- *
331
- * @member {module:typing/texttransformation~TextTransformationConfig} module:typing/typing~TypingConfig#transformations
332
- */
333
-
334
- /**
335
- * The configuration of the text transformation feature.
336
- *
337
- * ClassicEditor
338
- * .create( editorElement, {
339
- * typing: {
340
- * transformations: ... // Text transformation feature options.
341
- * }
342
- * } )
343
- * .then( ... )
344
- * .catch( ... );
345
- *
346
- * By default, the feature comes pre-configured
347
- * (via {@link module:typing/texttransformation~TextTransformationConfig#include `config.typing.transformations.include`}) with the
348
- * following groups of transformations:
349
- *
350
- * * Typography (group name: `typography`)
351
- * - `ellipsis`: transforms `...` to `…`
352
- * - `enDash`: transforms ` -- ` to ` – `
353
- * - `emDash`: transforms ` --- ` to ` — `
354
- * * Quotations (group name: `quotes`)
355
- * - `quotesPrimary`: transforms `"Foo bar"` to `“Foo bar”`
356
- * - `quotesSecondary`: transforms `'Foo bar'` to `‘Foo bar’`
357
- * * Symbols (group name: `symbols`)
358
- * - `trademark`: transforms `(tm)` to `™`
359
- * - `registeredTrademark`: transforms `(r)` to `®`
360
- * - `copyright`: transforms `(c)` to `©`
361
- * * Mathematical (group name: `mathematical`)
362
- * - `oneHalf`: transforms `1/2` to: `½`
363
- * - `oneThird`: transforms `1/3` to: `⅓`
364
- * - `twoThirds`: transforms `2/3` to: `⅔`
365
- * - `oneForth`: transforms `1/4` to: `¼`
366
- * - `threeQuarters`: transforms `3/4` to: `¾`
367
- * - `lessThanOrEqual`: transforms `<=` to: `≤`
368
- * - `greaterThanOrEqual`: transforms `>=` to: `≥`
369
- * - `notEqual`: transforms `!=` to: `≠`
370
- * - `arrowLeft`: transforms `<-` to: `←`
371
- * - `arrowRight`: transforms `->` to: `→`
372
- * * Misc:
373
- * - `quotesPrimaryEnGb`: transforms `'Foo bar'` to `‘Foo bar’`
374
- * - `quotesSecondaryEnGb`: transforms `"Foo bar"` to `“Foo bar”`
375
- * - `quotesPrimaryPl`: transforms `"Foo bar"` to `„Foo bar”`
376
- * - `quotesSecondaryPl`: transforms `'Foo bar'` to `‚Foo bar’`
377
- *
378
- * In order to load additional transformations, use the
379
- * {@link module:typing/texttransformation~TextTransformationConfig#extra `transformations.extra` option}.
380
- *
381
- * In order to narrow down the list of transformations, use the
382
- * {@link module:typing/texttransformation~TextTransformationConfig#remove `transformations.remove` option}.
383
- *
384
- * In order to completely override the supported transformations, use the
385
- * {@link module:typing/texttransformation~TextTransformationConfig#include `transformations.include` option}.
386
- *
387
- * Examples:
388
- *
389
- * const transformationsConfig = {
390
- * include: [
391
- * // Use only the 'quotes' and 'typography' groups.
392
- * 'quotes',
393
- * 'typography',
394
- *
395
- * // Plus, some custom transformation.
396
- * { from: 'CKE', to: 'CKEditor' }
397
- * ]
398
- * };
399
- *
400
- * const transformationsConfig = {
401
- * // Remove the 'ellipsis' transformation loaded by the 'typography' group.
402
- * remove: [ 'ellipsis' ]
403
- * }
404
- *
405
- * @interface TextTransformationConfig
406
- */
407
-
408
- /* eslint-disable max-len */
409
- /**
410
- * The standard list of text transformations supported by the editor. By default it comes pre-configured with a couple dozen of them
411
- * (see {@link module:typing/texttransformation~TextTransformationConfig} for the full list). You can override this list completely
412
- * by setting this option or use the other two options
413
- * ({@link module:typing/texttransformation~TextTransformationConfig#extra `transformations.extra`},
414
- * {@link module:typing/texttransformation~TextTransformationConfig#remove `transformations.remove`}) to fine-tune the default list.
415
- *
416
- * @member {Array.<module:typing/texttransformation~TextTransformationDescription>} module:typing/texttransformation~TextTransformationConfig#include
417
- */
418
-
419
- /**
420
- * Additional text transformations that are added to the transformations defined in
421
- * {@link module:typing/texttransformation~TextTransformationConfig#include `transformations.include`}.
422
- *
423
- * const transformationsConfig = {
424
- * extra: [
425
- * { from: 'CKE', to: 'CKEditor' }
426
- * ]
427
- * };
428
- *
429
- * @member {Array.<module:typing/texttransformation~TextTransformationDescription>} module:typing/texttransformation~TextTransformationConfig#extra
430
- */
431
-
432
- /**
433
- * The text transformation names that are removed from transformations defined in
434
- * {@link module:typing/texttransformation~TextTransformationConfig#include `transformations.include`} or
435
- * {@link module:typing/texttransformation~TextTransformationConfig#extra `transformations.extra`}.
436
- *
437
- * const transformationsConfig = {
438
- * remove: [
439
- * 'ellipsis', // Remove only 'ellipsis' from the 'typography' group.
440
- * 'mathematical' // Remove all transformations from the 'mathematical' group.
441
- * ]
442
- * }
443
- *
444
- * @member {Array.<module:typing/texttransformation~TextTransformationDescription>} module:typing/texttransformation~TextTransformationConfig#remove
445
- */
446
- /* eslint-enable max-len */