@ckeditor/ckeditor5-track-changes 39.0.1 → 40.0.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/CHANGELOG.md +2 -2
- package/LICENSE.md +6 -6
- package/README.md +14 -14
- package/build/track-changes.js +1 -1
- package/lang/translations/ar.po +1 -0
- package/lang/translations/az.po +1 -0
- package/lang/translations/bg.po +1 -0
- package/lang/translations/bn.po +1 -0
- package/lang/translations/ca.po +1 -0
- package/lang/translations/cs.po +1 -0
- package/lang/translations/da.po +1 -0
- package/lang/translations/de.po +1 -0
- package/lang/translations/el.po +1 -0
- package/lang/translations/en-au.po +1 -0
- package/lang/translations/en.po +1 -0
- package/lang/translations/es.po +1 -0
- package/lang/translations/et.po +1 -0
- package/lang/translations/fi.po +1 -0
- package/lang/translations/fr.po +1 -0
- package/lang/translations/gl.po +1 -0
- package/lang/translations/he.po +1 -0
- package/lang/translations/hi.po +1 -0
- package/lang/translations/hr.po +1 -0
- package/lang/translations/hu.po +1 -0
- package/lang/translations/id.po +1 -0
- package/lang/translations/it.po +1 -0
- package/lang/translations/ja.po +1 -0
- package/lang/translations/ko.po +1 -0
- package/lang/translations/lt.po +1 -0
- package/lang/translations/lv.po +1 -0
- package/lang/translations/ms.po +1 -0
- package/lang/translations/nl.po +1 -0
- package/lang/translations/no.po +1 -0
- package/lang/translations/pl.po +1 -0
- package/lang/translations/pt-br.po +1 -0
- package/lang/translations/pt.po +1 -0
- package/lang/translations/ro.po +1 -0
- package/lang/translations/ru.po +1 -0
- package/lang/translations/sk.po +1 -0
- package/lang/translations/sq.po +1 -0
- package/lang/translations/sr-latn.po +1 -0
- package/lang/translations/sr.po +1 -0
- package/lang/translations/sv.po +1 -0
- package/lang/translations/th.po +1 -0
- package/lang/translations/tk.po +1 -0
- package/lang/translations/tr.po +1 -0
- package/lang/translations/tt.po +1 -0
- package/lang/translations/uk.po +1 -0
- package/lang/translations/ur.po +1 -0
- package/lang/translations/vi.po +1 -0
- package/lang/translations/zh-cn.po +1 -0
- package/lang/translations/zh.po +1 -0
- package/package.json +3 -7
- package/src/augmentation.d.ts +40 -40
- package/src/commands/acceptsuggestioncommand.d.ts +24 -24
- package/src/commands/acceptsuggestioncommand.js +1 -1
- package/src/commands/discardsuggestioncommand.d.ts +24 -24
- package/src/commands/discardsuggestioncommand.js +1 -1
- package/src/commands/executeonallsuggestionscommand.d.ts +24 -24
- package/src/commands/executeonallsuggestionscommand.js +1 -1
- package/src/commands/executeonselectedsuggestionscommand.d.ts +24 -24
- package/src/commands/executeonselectedsuggestionscommand.js +1 -1
- package/src/commands/trackchangescommand.d.ts +26 -26
- package/src/commands/trackchangescommand.js +1 -1
- package/src/index.d.ts +16 -16
- package/src/integrations/aiassistant.d.ts +17 -0
- package/src/integrations/aiassistant.js +23 -0
- package/src/integrations/alignment.d.ts +17 -17
- package/src/integrations/alignment.js +1 -1
- package/src/integrations/basicstyles.d.ts +17 -17
- package/src/integrations/basicstyles.js +1 -1
- package/src/integrations/blockquote.d.ts +17 -17
- package/src/integrations/blockquote.js +1 -1
- package/src/integrations/ckbox.d.ts +17 -17
- package/src/integrations/ckbox.js +1 -1
- package/src/integrations/codeblock.d.ts +17 -17
- package/src/integrations/codeblock.js +1 -1
- package/src/integrations/comments.d.ts +14 -14
- package/src/integrations/comments.js +1 -1
- package/src/integrations/deletecommand.d.ts +17 -17
- package/src/integrations/deletecommand.js +1 -1
- package/src/integrations/documentlist.d.ts +17 -17
- package/src/integrations/documentlist.js +1 -1
- package/src/integrations/documentlistproperties.d.ts +29 -29
- package/src/integrations/documentlistproperties.js +1 -1
- package/src/integrations/entercommand.d.ts +16 -16
- package/src/integrations/entercommand.js +1 -1
- package/src/integrations/findandreplace.d.ts +21 -21
- package/src/integrations/findandreplace.js +1 -1
- package/src/integrations/font.d.ts +17 -17
- package/src/integrations/font.js +1 -1
- package/src/integrations/formatpainter.d.ts +17 -17
- package/src/integrations/formatpainter.js +1 -1
- package/src/integrations/heading.d.ts +17 -17
- package/src/integrations/heading.js +1 -1
- package/src/integrations/highlight.d.ts +17 -17
- package/src/integrations/highlight.js +1 -1
- package/src/integrations/horizontalline.d.ts +17 -17
- package/src/integrations/horizontalline.js +1 -1
- package/src/integrations/htmlembed.d.ts +17 -17
- package/src/integrations/htmlembed.js +1 -1
- package/src/integrations/image.d.ts +17 -17
- package/src/integrations/image.js +1 -1
- package/src/integrations/imagereplace.d.ts +23 -23
- package/src/integrations/imagereplace.js +1 -1
- package/src/integrations/importword.d.ts +18 -18
- package/src/integrations/importword.js +1 -1
- package/src/integrations/indent.d.ts +17 -17
- package/src/integrations/indent.js +1 -1
- package/src/integrations/inputcommand.d.ts +16 -16
- package/src/integrations/inputcommand.js +1 -1
- package/src/integrations/link.d.ts +17 -17
- package/src/integrations/link.js +1 -1
- package/src/integrations/list.d.ts +17 -17
- package/src/integrations/list.js +1 -1
- package/src/integrations/listproperties.d.ts +29 -29
- package/src/integrations/listproperties.js +1 -1
- package/src/integrations/mediaembed.d.ts +17 -17
- package/src/integrations/mediaembed.js +1 -1
- package/src/integrations/mention.d.ts +17 -17
- package/src/integrations/mention.js +1 -1
- package/src/integrations/pagebreak.d.ts +17 -17
- package/src/integrations/pagebreak.js +1 -1
- package/src/integrations/paragraph.d.ts +17 -17
- package/src/integrations/paragraph.js +1 -1
- package/src/integrations/removeformat.d.ts +17 -17
- package/src/integrations/removeformat.js +1 -1
- package/src/integrations/restrictededitingmode.d.ts +17 -17
- package/src/integrations/restrictededitingmode.js +1 -1
- package/src/integrations/shiftentercommand.d.ts +16 -16
- package/src/integrations/shiftentercommand.js +1 -1
- package/src/integrations/standardeditingmode.d.ts +17 -17
- package/src/integrations/standardeditingmode.js +1 -1
- package/src/integrations/style.d.ts +18 -18
- package/src/integrations/style.js +1 -1
- package/src/integrations/table.d.ts +42 -42
- package/src/integrations/table.js +1 -1
- package/src/integrations/tablecaption.d.ts +22 -22
- package/src/integrations/tablecaption.js +1 -1
- package/src/integrations/tableclipboard.d.ts +19 -19
- package/src/integrations/tableclipboard.js +1 -1
- package/src/integrations/tablecolumnresize.d.ts +26 -26
- package/src/integrations/tablecolumnresize.js +1 -1
- package/src/integrations/tableheadings.d.ts +22 -22
- package/src/integrations/tableheadings.js +1 -1
- package/src/integrations/tablemergesplit.d.ts +22 -22
- package/src/integrations/tablemergesplit.js +1 -1
- package/src/integrations/tableofcontents.d.ts +17 -17
- package/src/integrations/tableofcontents.js +1 -1
- package/src/integrations/tableproperties.d.ts +27 -27
- package/src/integrations/tableproperties.js +1 -1
- package/src/integrations/template.d.ts +17 -17
- package/src/integrations/template.js +1 -1
- package/src/integrations/title.d.ts +17 -17
- package/src/integrations/title.js +1 -1
- package/src/integrations/undo.d.ts +17 -17
- package/src/integrations/undo.js +1 -1
- package/src/integrations/utils.d.ts +21 -21
- package/src/integrations/utils.js +1 -1
- package/src/suggestion.d.ts +276 -276
- package/src/suggestion.js +1 -1
- package/src/suggestiondescriptionfactory.d.ts +163 -163
- package/src/suggestiondescriptionfactory.js +1 -1
- package/src/trackchanges.d.ts +244 -244
- package/src/trackchanges.js +1 -1
- package/src/trackchangesconfig.d.ts +75 -75
- package/src/trackchangesdata.d.ts +41 -41
- package/src/trackchangesdata.js +1 -1
- package/src/trackchangesediting.d.ts +468 -439
- package/src/trackchangesediting.js +1 -1
- package/src/trackchangesui.d.ts +38 -38
- package/src/trackchangesui.js +1 -1
- package/src/ui/suggestioncontroller.d.ts +37 -37
- package/src/ui/suggestioncontroller.js +1 -1
- package/src/ui/view/basesuggestionthreadview.d.ts +170 -170
- package/src/ui/view/basesuggestionthreadview.js +1 -1
- package/src/ui/view/suggestionthreadview.d.ts +182 -182
- package/src/ui/view/suggestionthreadview.js +1 -1
- package/src/utils/common-translations.d.ts +9 -9
- package/src/utils/common-translations.js +1 -1
- package/src/utils/utils.d.ts +30 -30
- package/src/utils/utils.js +1 -1
- package/theme/icons/track-changes-accept.svg +1 -1
- package/theme/icons/track-changes-discard.svg +1 -1
- package/theme/icons/track-changes.svg +1 -1
package/src/suggestion.js
CHANGED
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
const
|
|
23
|
+
const _0x2fe3=['hasComments','isExternal','addMarkerName','commentThread','end','toJSON','suggestion:','getMarkers','attributes','_saved','start','authoredAt','getMarkerNames','delete','substr','data','createdAt','head','clear','accept','getRange','onAttributesChange','type','from','decorate','addRange','change','getRanges','removeMarker','reduce','_isDataLoaded','previous','markers','setAttribute','add','_onAttributesChange','next','_onAccept','subType','removeMarkers','nodeBefore','isInContent','size','discard','length','isIntersecting','getMultiRangeId','creator','_onDiscard','@external','get','_markerNames','removeAttribute','set','getFirstRange','_model','map','getItems','getFirstMarker','onDiscard','author'];(function(_0x26f5d3,_0x2fe393){const _0x4885cd=function(_0x368919){while(--_0x368919){_0x26f5d3['push'](_0x26f5d3['shift']());}};_0x4885cd(++_0x2fe393);}(_0x2fe3,0x107));const _0x4885=function(_0x26f5d3,_0x2fe393){_0x26f5d3=_0x26f5d3-0x0;let _0x4885cd=_0x2fe3[_0x26f5d3];return _0x4885cd;};import{Element as _0x257e7c}from'ckeditor5/src/engine';import{ObservableMixin as _0x284ad1,uid as _0x4ecbcc}from'ckeditor5/src/utils';import{cloneDeep as _0x53905a,isEqual as _0x74b05f,set as _0x1142c2,unset as _0x5580dd}from'lodash-es';export default class u extends _0x284ad1(){constructor(_0x43c8c2,_0x513ed7){super(),this[_0x4885('0xb')]=!0x1,this['id']=_0x513ed7['id'],this['type']=_0x513ed7[_0x4885('0x3')],this[_0x4885('0x13')]=_0x513ed7['subType']||null,this[_0x4885('0x29')]=_0x513ed7[_0x4885('0x29')],this['creator']=_0x513ed7[_0x4885('0x1c')]||_0x513ed7[_0x4885('0x29')],this[_0x4885('0x2b')]=Boolean(_0x513ed7[_0x4885('0x32')]&&_0x513ed7[_0x4885('0x32')][_0x4885('0x1e')]),this[_0x4885('0x39')]=null,this['_model']=_0x43c8c2,this[_0x4885('0x12')]=_0x513ed7['onAccept'],this['_onDiscard']=_0x513ed7[_0x4885('0x28')],this[_0x4885('0x10')]=_0x513ed7[_0x4885('0x2')],this[_0x4885('0x20')]=new Set(),this[_0x4885('0x3a')]=null,this[_0x4885('0x22')](_0x4885('0x35'),null),this[_0x4885('0x22')](_0x4885('0x32'),_0x513ed7['attributes']||{}),this[_0x4885('0x22')](_0x4885('0xc'),null),this[_0x4885('0x22')](_0x4885('0x11'),null),this[_0x4885('0x22')](_0x4885('0x2d'),null),this[_0x4885('0x22')](_0x4885('0x33'),!0x1),this[_0x4885('0x5')]('accept'),this[_0x4885('0x5')](_0x4885('0x18'));}get['head'](){let _0xdaeb14=this;for(;_0xdaeb14['previous'];)_0xdaeb14=_0xdaeb14[_0x4885('0xc')];return _0xdaeb14;}get[_0x4885('0x2a')](){return!!this[_0x4885('0x2d')]&&this[_0x4885('0x2d')][_0x4885('0x19')]>0x0;}get['isMultiRange'](){if(0x0==this[_0x4885('0x20')][_0x4885('0x17')])return!0x1;return 0x6==Array[_0x4885('0x4')](this[_0x4885('0x20')])[0x0]['split'](':')['length'];}get[_0x4885('0x16')](){return null!==this[_0x4885('0x27')]();}[_0x4885('0x2c')](_0x1bc994){this[_0x4885('0x20')][_0x4885('0xf')](_0x1bc994);}[_0x4885('0x36')](){return Array[_0x4885('0x4')](this[_0x4885('0x20')]);}[_0x4885('0x31')](){return this[_0x4885('0x36')]()[_0x4885('0x25')](_0x1ab597=>this[_0x4885('0x24')][_0x4885('0xd')][_0x4885('0x1f')](_0x1ab597))['filter'](_0xb33cc1=>_0xb33cc1);}['getFirstMarker'](){return this[_0x4885('0x31')]()[0x0]||null;}[_0x4885('0x14')](){this[_0x4885('0x24')][_0x4885('0x7')](_0x47e935=>{for(const _0x5bb3b9 of this[_0x4885('0x31')]())_0x47e935[_0x4885('0x9')](_0x5bb3b9);}),this[_0x4885('0x20')][_0x4885('0x3c')]();}[_0x4885('0x9')](_0x421a8a){this[_0x4885('0x24')][_0x4885('0x7')](_0x35d133=>{_0x35d133[_0x4885('0x9')](_0x421a8a);}),this[_0x4885('0x20')][_0x4885('0x37')](_0x421a8a);}[_0x4885('0x6')](_0x230ecb){const _0x19e827=_0x4885('0x30')+this[_0x4885('0x3')]+':'+this[_0x4885('0x13')]+':'+this['id']+':'+this[_0x4885('0x1c')]['id']+':'+u[_0x4885('0x1b')]();this[_0x4885('0x2c')](_0x19e827),this['_model']['change'](_0x3d6000=>{_0x3d6000['addMarker'](_0x19e827,{'range':_0x230ecb,'usingOperation':!0x0,'affectsData':!0x0});});}['isIntersectingWithRange'](_0x1a0ed0){for(const _0x797ee of this[_0x4885('0x8')]())if(_0x797ee[_0x4885('0x1a')](_0x1a0ed0))return!0x0;return!0x1;}[_0x4885('0x8')](){return this[_0x4885('0x31')]()[_0x4885('0x25')](_0x24803d=>_0x24803d[_0x4885('0x1')]());}[_0x4885('0x26')](){return this[_0x4885('0x8')]()[_0x4885('0xa')]((_0x1a9264,_0xb5b328)=>[..._0x1a9264,..._0xb5b328['getItems']()],[]);}[_0x4885('0x23')](){var _0x3582d1;return(null===(_0x3582d1=this['getFirstMarker']())||void 0x0===_0x3582d1?void 0x0:_0x3582d1[_0x4885('0x1')]())||null;}['getContainedElement'](){const _0x4992fb=this[_0x4885('0x8')]();if(0x1!=_0x4992fb['length'])return null;const _0x509631=_0x4992fb[0x0],_0x37faf4=_0x509631[_0x4885('0x34')]['nodeAfter'],_0x441b1b=_0x509631[_0x4885('0x2e')][_0x4885('0x15')];return _0x37faf4 instanceof _0x257e7c?_0x37faf4!=_0x441b1b?null:_0x37faf4:null;}[_0x4885('0x0')](){this[_0x4885('0x12')](this[_0x4885('0x8')](),this['data'],this[_0x4885('0x32')]),this[_0x4885('0x14')]();}[_0x4885('0x18')](){this[_0x4885('0x1d')](this['getRanges'](),this[_0x4885('0x39')],this[_0x4885('0x32')]),this['removeMarkers']();}['getAllAdjacentSuggestions'](){const _0x3fc832=[];let _0x16a4fb=this[_0x4885('0x3b')];for(;_0x16a4fb;)_0x3fc832['push'](_0x16a4fb),_0x16a4fb=_0x16a4fb['next'];return _0x3fc832;}[_0x4885('0xe')](_0x5e58a2,_0x122759){const _0x40a839=_0x53905a(this[_0x4885('0x32')]);_0x1142c2(_0x40a839,_0x5e58a2,_0x122759),_0x74b05f(_0x40a839,this[_0x4885('0x32')])||(this[_0x4885('0x32')]=_0x40a839,this[_0x4885('0x10')](_0x40a839));}[_0x4885('0x21')](_0x54dfbc){const _0xcd3631=_0x53905a(this[_0x4885('0x32')]);_0x5580dd(_0xcd3631,_0x54dfbc),_0x74b05f(_0xcd3631,this[_0x4885('0x32')])||(this['attributes']=_0xcd3631,this[_0x4885('0x10')](this[_0x4885('0x32')]));}[_0x4885('0x2f')](){return{'id':this['id'],'type':this[_0x4885('0x13')]?this[_0x4885('0x3')]+':'+this[_0x4885('0x13')]:this[_0x4885('0x3')],'authorId':this[_0x4885('0x1c')]['id'],'createdAt':this['createdAt'],'hasComments':this[_0x4885('0x2a')],'data':this['data'],'attributes':this[_0x4885('0x32')]};}static['getMultiRangeId'](){return _0x4ecbcc()[_0x4885('0x38')](0x1,0x5);}}
|
|
@@ -1,163 +1,163 @@
|
|
|
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 Locale, type PriorityString } from 'ckeditor5/src/utils';
|
|
6
|
-
import type { Schema, Element } from 'ckeditor5/src/engine';
|
|
7
|
-
import type Suggestion from './suggestion';
|
|
8
|
-
/**
|
|
9
|
-
* Creates descriptions for suggestion chains.
|
|
10
|
-
*
|
|
11
|
-
* One or more suggestions that are next to each other create "suggestion chain". In such chain one suggestion may
|
|
12
|
-
* impact other suggestion when it comes to the description of the whole chain. For example, insertion next to deletion
|
|
13
|
-
* results in "Replaced" description.
|
|
14
|
-
*/
|
|
15
|
-
export default class SuggestionDescriptionFactory {
|
|
16
|
-
constructor(schema: Schema, locale: Locale);
|
|
17
|
-
/**
|
|
18
|
-
* Returns descriptions for given suggestion chain.
|
|
19
|
-
*
|
|
20
|
-
* The structure of the descriptions array is as follows (explained on an example):
|
|
21
|
-
*
|
|
22
|
-
* ```ts
|
|
23
|
-
* [
|
|
24
|
-
* { type: 'insertion', content: '*Insert:* 2 paragraphs' },
|
|
25
|
-
* { type: 'insertion', content: '*Insert:* image },
|
|
26
|
-
* { type: 'replace', content: '*Replace:* "Foo" *with* "Bar"' }
|
|
27
|
-
* ]
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* In above example there are three description instances (or lines). Two new (empty) paragraphs were added,
|
|
31
|
-
* an image was added and then "Foo" text was removed and "Bar" text was added. For example, above structure could be rendered as:
|
|
32
|
-
*
|
|
33
|
-
* ```html
|
|
34
|
-
* <p><strong>Insert:</strong> 2 paragraphs</p>
|
|
35
|
-
* <p><strong>Insert:</strong> image</p>
|
|
36
|
-
* <p><strong>Replace:</strong> "Foo" <strong>with</strong> "Bar"</p>
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
getDescriptions(suggestions: Array<Suggestion>): Array<Description>;
|
|
40
|
-
/**
|
|
41
|
-
* Registers a callback function that returns a custom description for a suggestion.
|
|
42
|
-
*
|
|
43
|
-
* Registered callback is fired for a suggestion whenever there is a need to generate a description for that suggestion.
|
|
44
|
-
*
|
|
45
|
-
* The callback takes the suggestion instance as a parameter and should return
|
|
46
|
-
* {@link module:track-changes/suggestiondescriptionfactory~Description description object} or a falsy value
|
|
47
|
-
* if the suggestion was not handled by the callback.
|
|
48
|
-
*
|
|
49
|
-
* Example of a description callback for the bold style:
|
|
50
|
-
*
|
|
51
|
-
* ```ts
|
|
52
|
-
* suggestionDescriptionFactory.registerDescriptionCallback( suggestion => {
|
|
53
|
-
* const { data } = suggestion;
|
|
54
|
-
*
|
|
55
|
-
* // Omit suggestions that are not bold style suggestions.
|
|
56
|
-
* if ( !data || data.commandName !== 'bold' ) {
|
|
57
|
-
* return;
|
|
58
|
-
* }
|
|
59
|
-
*
|
|
60
|
-
* const isSet = !!data.commandParams[ 0 ].forceValue;
|
|
61
|
-
* const content = isSet ? '*Set format:* bold' : '*Remove format:* bold';
|
|
62
|
-
*
|
|
63
|
-
* return {
|
|
64
|
-
* type: 'format',
|
|
65
|
-
* content
|
|
66
|
-
* };
|
|
67
|
-
* } );
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
registerDescriptionCallback(callback: DescriptionCallback): void;
|
|
71
|
-
/**
|
|
72
|
-
* For given `elementName` registers how this element will be labeled in a description (for example when it is added
|
|
73
|
-
* or removed).
|
|
74
|
-
*
|
|
75
|
-
* Instead of a string name you may provide a matching function that takes item {@link module:engine/model/item~Item} as an input
|
|
76
|
-
* and should return boolean value.
|
|
77
|
-
*
|
|
78
|
-
* Provided label callback takes one parameter, `quantity`, and is expected to return the label for the element as a string.
|
|
79
|
-
*
|
|
80
|
-
* A simple use case without using internationalization:
|
|
81
|
-
*
|
|
82
|
-
* ```ts
|
|
83
|
-
* suggestionDescriptionFactory.registerElementLabel(
|
|
84
|
-
* 'paragraph',
|
|
85
|
-
* quantity => quantity == 1 ? 'paragraph' : quantity + ' paragraphs'
|
|
86
|
-
* );
|
|
87
|
-
* ```
|
|
88
|
-
*
|
|
89
|
-
* If you want your feature to be localized to other languages, use localization service:
|
|
90
|
-
*
|
|
91
|
-
* ```ts
|
|
92
|
-
* const t = editor.locale.t; // Remember that you have to use function named `t`.
|
|
93
|
-
*
|
|
94
|
-
* suggestionDescriptionFactory.registerElementLabel(
|
|
95
|
-
* 'paragraph',
|
|
96
|
-
* quantity => t( { string: 'paragraph', plural: '%0 paragraphs', id: 'ELEMENT_PARAGRAPH' }, quantity )
|
|
97
|
-
* );
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
registerElementLabel(elementNameOrCallback: string | Function, labelCallback: LabelCallback, priority?: PriorityString): void;
|
|
101
|
-
/**
|
|
102
|
-
* Returns label registered for given element or the element name if there is no label registered for it.
|
|
103
|
-
*/
|
|
104
|
-
getItemLabel(element: Element, quantity?: number): string;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* A description for the suggestion.
|
|
108
|
-
*
|
|
109
|
-
* ```ts
|
|
110
|
-
* {
|
|
111
|
-
* type: 'format',
|
|
112
|
-
* label: '*Set format:* bold'
|
|
113
|
-
* }
|
|
114
|
-
* ```
|
|
115
|
-
*
|
|
116
|
-
* A description for the color-related suggestions like font color may specify the `color` property that will provide a better UX
|
|
117
|
-
* by displaying a color box next to the suggestion.
|
|
118
|
-
*
|
|
119
|
-
* ```ts
|
|
120
|
-
* {
|
|
121
|
-
* type: 'format',
|
|
122
|
-
* label: '*Set font color:*',
|
|
123
|
-
* color: {
|
|
124
|
-
* value: 'hsl( 60, 60%, 60% )',
|
|
125
|
-
* title: 'yellow'
|
|
126
|
-
* }
|
|
127
|
-
* }
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
export interface Description {
|
|
131
|
-
type: 'insertion' | 'deletion' | 'replace' | 'format';
|
|
132
|
-
/**
|
|
133
|
-
* Description label. You may use `*` to bold part of the label.
|
|
134
|
-
*/
|
|
135
|
-
content: string;
|
|
136
|
-
/**
|
|
137
|
-
* The optional `color` property used for color-related suggestions.
|
|
138
|
-
* The object should provide the `value` (for displaying the color) and `title` (for describing the color) fields.
|
|
139
|
-
*/
|
|
140
|
-
color?: {
|
|
141
|
-
value: string;
|
|
142
|
-
title: string;
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
export type DescriptionCallback = (suggestion: Suggestion) => Description | DescriptionItem | undefined;
|
|
146
|
-
export type LabelCallback = (quantity: number) => string;
|
|
147
|
-
export interface LabelCallbackObject {
|
|
148
|
-
matchingCallback: (element: Element) => boolean;
|
|
149
|
-
label: LabelCallback;
|
|
150
|
-
priority: PriorityString;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* An intermediate state which is easier to operate on when consecutive suggestion
|
|
154
|
-
* ranges are traversed.
|
|
155
|
-
*/
|
|
156
|
-
interface DescriptionItem {
|
|
157
|
-
type: 'text' | 'addEmptyContainer' | 'addObject' | 'removeEmptyContainer' | 'removeObject' | 'addContainer' | 'removeContainer';
|
|
158
|
-
add?: string;
|
|
159
|
-
remove?: string;
|
|
160
|
-
element?: Element;
|
|
161
|
-
quantity?: number;
|
|
162
|
-
}
|
|
163
|
-
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
|
+
import { type Locale, type PriorityString } from 'ckeditor5/src/utils';
|
|
6
|
+
import type { Schema, Element } from 'ckeditor5/src/engine';
|
|
7
|
+
import type Suggestion from './suggestion';
|
|
8
|
+
/**
|
|
9
|
+
* Creates descriptions for suggestion chains.
|
|
10
|
+
*
|
|
11
|
+
* One or more suggestions that are next to each other create "suggestion chain". In such chain one suggestion may
|
|
12
|
+
* impact other suggestion when it comes to the description of the whole chain. For example, insertion next to deletion
|
|
13
|
+
* results in "Replaced" description.
|
|
14
|
+
*/
|
|
15
|
+
export default class SuggestionDescriptionFactory {
|
|
16
|
+
constructor(schema: Schema, locale: Locale);
|
|
17
|
+
/**
|
|
18
|
+
* Returns descriptions for given suggestion chain.
|
|
19
|
+
*
|
|
20
|
+
* The structure of the descriptions array is as follows (explained on an example):
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* [
|
|
24
|
+
* { type: 'insertion', content: '*Insert:* 2 paragraphs' },
|
|
25
|
+
* { type: 'insertion', content: '*Insert:* image },
|
|
26
|
+
* { type: 'replace', content: '*Replace:* "Foo" *with* "Bar"' }
|
|
27
|
+
* ]
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* In above example there are three description instances (or lines). Two new (empty) paragraphs were added,
|
|
31
|
+
* an image was added and then "Foo" text was removed and "Bar" text was added. For example, above structure could be rendered as:
|
|
32
|
+
*
|
|
33
|
+
* ```html
|
|
34
|
+
* <p><strong>Insert:</strong> 2 paragraphs</p>
|
|
35
|
+
* <p><strong>Insert:</strong> image</p>
|
|
36
|
+
* <p><strong>Replace:</strong> "Foo" <strong>with</strong> "Bar"</p>
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
getDescriptions(suggestions: Array<Suggestion>): Array<Description>;
|
|
40
|
+
/**
|
|
41
|
+
* Registers a callback function that returns a custom description for a suggestion.
|
|
42
|
+
*
|
|
43
|
+
* Registered callback is fired for a suggestion whenever there is a need to generate a description for that suggestion.
|
|
44
|
+
*
|
|
45
|
+
* The callback takes the suggestion instance as a parameter and should return
|
|
46
|
+
* {@link module:track-changes/suggestiondescriptionfactory~Description description object} or a falsy value
|
|
47
|
+
* if the suggestion was not handled by the callback.
|
|
48
|
+
*
|
|
49
|
+
* Example of a description callback for the bold style:
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* suggestionDescriptionFactory.registerDescriptionCallback( suggestion => {
|
|
53
|
+
* const { data } = suggestion;
|
|
54
|
+
*
|
|
55
|
+
* // Omit suggestions that are not bold style suggestions.
|
|
56
|
+
* if ( !data || data.commandName !== 'bold' ) {
|
|
57
|
+
* return;
|
|
58
|
+
* }
|
|
59
|
+
*
|
|
60
|
+
* const isSet = !!data.commandParams[ 0 ].forceValue;
|
|
61
|
+
* const content = isSet ? '*Set format:* bold' : '*Remove format:* bold';
|
|
62
|
+
*
|
|
63
|
+
* return {
|
|
64
|
+
* type: 'format',
|
|
65
|
+
* content
|
|
66
|
+
* };
|
|
67
|
+
* } );
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
registerDescriptionCallback(callback: DescriptionCallback): void;
|
|
71
|
+
/**
|
|
72
|
+
* For given `elementName` registers how this element will be labeled in a description (for example when it is added
|
|
73
|
+
* or removed).
|
|
74
|
+
*
|
|
75
|
+
* Instead of a string name you may provide a matching function that takes item {@link module:engine/model/item~Item} as an input
|
|
76
|
+
* and should return boolean value.
|
|
77
|
+
*
|
|
78
|
+
* Provided label callback takes one parameter, `quantity`, and is expected to return the label for the element as a string.
|
|
79
|
+
*
|
|
80
|
+
* A simple use case without using internationalization:
|
|
81
|
+
*
|
|
82
|
+
* ```ts
|
|
83
|
+
* suggestionDescriptionFactory.registerElementLabel(
|
|
84
|
+
* 'paragraph',
|
|
85
|
+
* quantity => quantity == 1 ? 'paragraph' : quantity + ' paragraphs'
|
|
86
|
+
* );
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* If you want your feature to be localized to other languages, use localization service:
|
|
90
|
+
*
|
|
91
|
+
* ```ts
|
|
92
|
+
* const t = editor.locale.t; // Remember that you have to use function named `t`.
|
|
93
|
+
*
|
|
94
|
+
* suggestionDescriptionFactory.registerElementLabel(
|
|
95
|
+
* 'paragraph',
|
|
96
|
+
* quantity => t( { string: 'paragraph', plural: '%0 paragraphs', id: 'ELEMENT_PARAGRAPH' }, quantity )
|
|
97
|
+
* );
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
registerElementLabel(elementNameOrCallback: string | Function, labelCallback: LabelCallback, priority?: PriorityString): void;
|
|
101
|
+
/**
|
|
102
|
+
* Returns label registered for given element or the element name if there is no label registered for it.
|
|
103
|
+
*/
|
|
104
|
+
getItemLabel(element: Element, quantity?: number): string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A description for the suggestion.
|
|
108
|
+
*
|
|
109
|
+
* ```ts
|
|
110
|
+
* {
|
|
111
|
+
* type: 'format',
|
|
112
|
+
* label: '*Set format:* bold'
|
|
113
|
+
* }
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
116
|
+
* A description for the color-related suggestions like font color may specify the `color` property that will provide a better UX
|
|
117
|
+
* by displaying a color box next to the suggestion.
|
|
118
|
+
*
|
|
119
|
+
* ```ts
|
|
120
|
+
* {
|
|
121
|
+
* type: 'format',
|
|
122
|
+
* label: '*Set font color:*',
|
|
123
|
+
* color: {
|
|
124
|
+
* value: 'hsl( 60, 60%, 60% )',
|
|
125
|
+
* title: 'yellow'
|
|
126
|
+
* }
|
|
127
|
+
* }
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export interface Description {
|
|
131
|
+
type: 'insertion' | 'deletion' | 'replace' | 'format';
|
|
132
|
+
/**
|
|
133
|
+
* Description label. You may use `*` to bold part of the label.
|
|
134
|
+
*/
|
|
135
|
+
content: string;
|
|
136
|
+
/**
|
|
137
|
+
* The optional `color` property used for color-related suggestions.
|
|
138
|
+
* The object should provide the `value` (for displaying the color) and `title` (for describing the color) fields.
|
|
139
|
+
*/
|
|
140
|
+
color?: {
|
|
141
|
+
value: string;
|
|
142
|
+
title: string;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
export type DescriptionCallback = (suggestion: Suggestion) => Description | DescriptionItem | undefined;
|
|
146
|
+
export type LabelCallback = (quantity: number) => string;
|
|
147
|
+
export interface LabelCallbackObject {
|
|
148
|
+
matchingCallback: (element: Element) => boolean;
|
|
149
|
+
label: LabelCallback;
|
|
150
|
+
priority: PriorityString;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* An intermediate state which is easier to operate on when consecutive suggestion
|
|
154
|
+
* ranges are traversed.
|
|
155
|
+
*/
|
|
156
|
+
interface DescriptionItem {
|
|
157
|
+
type: 'text' | 'addEmptyContainer' | 'addObject' | 'removeEmptyContainer' | 'removeObject' | 'addContainer' | 'removeContainer';
|
|
158
|
+
add?: string;
|
|
159
|
+
remove?: string;
|
|
160
|
+
element?: Element;
|
|
161
|
+
quantity?: number;
|
|
162
|
+
}
|
|
163
|
+
export {};
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
const
|
|
23
|
+
const _0x52cf=['skip','isEmpty','push','REPLACE_TEXT','deletion','insertion','get','getWalker','$textProxy','_customCallbacks','getDescriptions','*Split:*\x20%0','_resolveDescriptionItems','replace','getItemLabel','*Merge:*\x20%0','data','getFirstRange','_itemLabels','isEqual','element','*Insert:*\x20%0','nextSibling','pop','function','match','_locale','length','EmptyContainer','*Remove:*\x20%0','isInContent','matchingCallback','registerElementLabel','_addDescriptionItems','$1\x20$2','ELEMENT_SPACE','label','Object','remove','_schema','indexOf','name','Container','addEmptyContainer','quantity','addObject','add','addContainer','item','removeContainer','isObject','_itemLabelsCallbacks','elementEnd','type','text'];(function(_0xbd38bd,_0x52cf7b){const _0x451aa5=function(_0xa212c7){while(--_0xa212c7){_0xbd38bd['push'](_0xbd38bd['shift']());}};_0x451aa5(++_0x52cf7b);}(_0x52cf,0x95));const _0x451a=function(_0xbd38bd,_0x52cf7b){_0xbd38bd=_0xbd38bd-0x0;let _0x451aa5=_0x52cf[_0xbd38bd];return _0x451aa5;};import{getTranslation as _0x5cc6c9}from'./utils/common-translations';import{priorities as _0x4d1b72,insertToPriorityArray as _0x420501}from'ckeditor5/src/utils';export default class m{constructor(_0x487cea,_0x1534c7){this[_0x451a('0x19')]=[],this[_0x451a('0x22')]=new Map(),this[_0x451a('0xc')]=[],this[_0x451a('0x0')]=_0x487cea,this[_0x451a('0x2a')]=_0x1534c7;}[_0x451a('0x1a')](_0x582db9){const _0x39f847=[];for(let _0x46decc=0x0;_0x46decc<_0x582db9[_0x451a('0x2b')];_0x46decc++){const _0x2837ce=_0x582db9[_0x46decc];if(!_0x2837ce[_0x451a('0x2e')])continue;let _0x2e3021=!0x1;for(const _0xd83e8d of this['_customCallbacks']){const _0x3dccad=_0xd83e8d(_0x2837ce);if(_0x3dccad){_0x451a('0xe')in _0x3dccad&&_0x39f847[_0x451a('0x12')](_0x3dccad),_0x2e3021=!0x0;break;}}if(!_0x2e3021){this[_0x451a('0x31')](_0x39f847,_0x2837ce);const _0x3bfcf7=_0x582db9[_0x46decc+0x1];if(_0x3bfcf7&&!_0x2837ce['getFirstRange']()['end'][_0x451a('0x23')](_0x3bfcf7[_0x451a('0x21')]()['start'])){const _0x1b6bd1=_0x39f847[_0x39f847[_0x451a('0x2b')]-0x1],_0x1dbbe5=_0x451a('0x15')==_0x2837ce[_0x451a('0xe')]?'add':'remove';_0x1b6bd1&&'text'==_0x1b6bd1[_0x451a('0xe')]&&(_0x1b6bd1[_0x1dbbe5]+='\x0a');}}}return this['_resolveDescriptionItems'](_0x39f847);}['registerDescriptionCallback'](_0x554655){this['_customCallbacks']['push'](_0x554655);}[_0x451a('0x30')](_0x571229,_0x4b1067,_0x4cd2a3=_0x4d1b72['normal']){_0x451a('0x28')==typeof _0x571229?_0x420501(this['_itemLabelsCallbacks'],{'matchingCallback':_0x571229,'label':_0x4b1067,'priority':_0x4cd2a3}):this[_0x451a('0x22')]['set'](_0x571229,_0x4b1067);}[_0x451a('0x1e')](_0x49065e,_0x33641b=0x1){let _0x1545ea;for(const _0xdc1da5 of this[_0x451a('0xc')])if(_0xdc1da5[_0x451a('0x2f')](_0x49065e)){_0x1545ea=_0xdc1da5[_0x451a('0x34')];break;}return _0x1545ea||(_0x1545ea=this[_0x451a('0x22')][_0x451a('0x16')](_0x49065e[_0x451a('0x2')])),_0x1545ea?_0x1545ea(_0x33641b):0x1!==_0x33641b?_0x33641b+'\x20'+_0x49065e[_0x451a('0x2')]+'s':''+_0x49065e[_0x451a('0x2')];}[_0x451a('0x31')](_0x3f41ad,_0x52f81f){const _0x4e0ee8=_0x52f81f['getFirstRange']()[_0x451a('0x17')](),_0x189ece='insertion'==_0x52f81f[_0x451a('0xe')]?'add':'remove';for(const _0x1c86d3 of _0x4e0ee8){const _0x1f496d=_0x1c86d3[_0x451a('0x9')],_0x2d6a59=_0x3f41ad[_0x3f41ad[_0x451a('0x2b')]-0x1];if(_0x1f496d['is'](_0x451a('0x18')))_0x2d6a59&&_0x2d6a59[_0x451a('0xe')][_0x451a('0x1')](_0x451a('0x3'))>-0x1&&_0x3f41ad[_0x451a('0x27')](),_0x2d6a59&&_0x451a('0xf')==_0x2d6a59[_0x451a('0xe')]?_0x2d6a59[_0x189ece]+=_0x1f496d[_0x451a('0x20')]:_0x3f41ad[_0x451a('0x12')]({'type':_0x451a('0xf'),'add':_0x451a('0x7')==_0x189ece?_0x1f496d[_0x451a('0x20')]:'','remove':'remove'==_0x189ece?_0x1f496d[_0x451a('0x20')]:''});else{if(this[_0x451a('0x0')][_0x451a('0xb')](_0x1f496d)){const _0x11357b=_0x1f496d;if(_0x2d6a59&&_0x2d6a59[_0x451a('0xe')][_0x451a('0x1')]('Container')>-0x1&&_0x3f41ad[_0x451a('0x27')](),_0x451a('0xd')==_0x1c86d3['type'])continue;_0x2d6a59&&_0x2d6a59[_0x451a('0xe')]==_0x189ece+_0x451a('0x35')&&_0x2d6a59[_0x451a('0x24')][_0x451a('0x2')]==_0x11357b['name']?_0x2d6a59[_0x451a('0x5')]++:_0x3f41ad[_0x451a('0x12')]({'type':_0x189ece+_0x451a('0x35'),'element':_0x11357b,'quantity':0x1}),_0x4e0ee8[_0x451a('0x10')](_0x2962a4=>!(_0x451a('0xd')==_0x2962a4[_0x451a('0xe')]&&_0x2962a4[_0x451a('0x9')]==_0x1f496d));}else{if(this[_0x451a('0x0')]['checkChild'](_0x1f496d,'$text')||_0x1f496d['is']('element','softBreak')){const _0x556edc=_0x1f496d;if(_0x451a('0x7')==_0x189ece&&'elementStart'==_0x1c86d3[_0x451a('0xe')]||'remove'==_0x189ece&&_0x451a('0xd')==_0x1c86d3[_0x451a('0xe')])continue;if(_0x2d6a59&&-0x1==_0x2d6a59['type'][_0x451a('0x1')](_0x451a('0x3'))){_0x451a('0xf')==_0x2d6a59[_0x451a('0xe')]&&(_0x2d6a59[_0x189ece]+='\x0a');continue;}let _0x10c473;if(_0x10c473=_0x451a('0x7')==_0x189ece?_0x556edc[_0x451a('0x26')]&&!this['_schema']['isObject'](_0x556edc[_0x451a('0x26')])?_0x556edc['nextSibling']:null:_0x556edc['previousSibling']&&!this['_schema'][_0x451a('0xb')](_0x556edc['previousSibling'])?_0x556edc['previousSibling']:null,_0x556edc[_0x451a('0x11')]||_0x10c473&&_0x10c473[_0x451a('0x11')]){const _0x5d6900=_0x10c473&&_0x10c473[_0x451a('0x11')]?_0x10c473:_0x556edc;_0x2d6a59&&_0x2d6a59['type']==_0x189ece+_0x451a('0x2c')&&_0x2d6a59[_0x451a('0x24')][_0x451a('0x2')]==_0x5d6900['name']?_0x2d6a59['quantity']++:_0x3f41ad[_0x451a('0x12')]({'type':_0x189ece+_0x451a('0x2c'),'element':_0x5d6900,'quantity':0x1});}else _0x3f41ad[_0x451a('0x12')]({'type':_0x189ece+_0x451a('0x3'),'element':_0x556edc});}}}}}[_0x451a('0x1c')](_0x49a9d7){const _0x1401e0=this[_0x451a('0x2a')],_0xeeea81=[];for(const _0x31cfbf of _0x49a9d7){switch(_0x31cfbf[_0x451a('0xe')]){case _0x451a('0xf'):if(_0x31cfbf[_0x451a('0x7')]=_0x31cfbf['add']['replace'](/(\S)\u000A+(\S)/g,_0x451a('0x32'))[_0x451a('0x1d')](/\u000A/g,''),_0x31cfbf[_0x451a('0x36')]=_0x31cfbf[_0x451a('0x36')][_0x451a('0x1d')](/(\S)\u000A+(\S)/g,_0x451a('0x32'))[_0x451a('0x1d')](/\u000A/g,''),''!=_0x31cfbf['add']&&''!=_0x31cfbf[_0x451a('0x36')]){_0xeeea81['push']({'type':'replace','content':_0x5cc6c9(_0x1401e0,_0x451a('0x13'),['\x22'+_0x31cfbf[_0x451a('0x36')]+'\x22','\x22'+_0x31cfbf[_0x451a('0x7')]+'\x22'])});continue;}if(null!=_0x31cfbf[_0x451a('0x7')]['match'](/^ +$/)){_0xeeea81[_0x451a('0x12')]({'type':_0x451a('0x15'),'content':_0x5cc6c9(_0x1401e0,_0x451a('0x25'),_0x5cc6c9(_0x1401e0,_0x451a('0x33'),_0x31cfbf[_0x451a('0x7')][_0x451a('0x2b')]))});continue;}if(null!=_0x31cfbf[_0x451a('0x36')][_0x451a('0x29')](/^ +$/)){_0xeeea81[_0x451a('0x12')]({'type':'deletion','content':_0x5cc6c9(_0x1401e0,_0x451a('0x2d'),_0x5cc6c9(_0x1401e0,'ELEMENT_SPACE',_0x31cfbf[_0x451a('0x36')][_0x451a('0x2b')]))});continue;}if(''!=_0x31cfbf['add']){_0xeeea81[_0x451a('0x12')]({'type':_0x451a('0x15'),'content':_0x5cc6c9(_0x1401e0,'*Insert:*\x20%0','\x22'+_0x31cfbf[_0x451a('0x7')]+'\x22')});continue;}_0xeeea81[_0x451a('0x12')]({'type':_0x451a('0x14'),'content':_0x5cc6c9(_0x1401e0,_0x451a('0x2d'),'\x22'+_0x31cfbf[_0x451a('0x36')]+'\x22')});continue;case _0x451a('0x4'):case _0x451a('0x6'):_0xeeea81[_0x451a('0x12')]({'type':_0x451a('0x15'),'content':_0x5cc6c9(_0x1401e0,'*Insert:*\x20%0',this['getItemLabel'](_0x31cfbf[_0x451a('0x24')],_0x31cfbf[_0x451a('0x5')]))});continue;case'removeEmptyContainer':case'removeObject':_0xeeea81[_0x451a('0x12')]({'type':_0x451a('0x14'),'content':_0x5cc6c9(_0x1401e0,_0x451a('0x2d'),this[_0x451a('0x1e')](_0x31cfbf['element'],_0x31cfbf['quantity']))});continue;case _0x451a('0x8'):_0xeeea81[_0x451a('0x12')]({'type':_0x451a('0x15'),'content':_0x5cc6c9(_0x1401e0,_0x451a('0x1b'),this[_0x451a('0x1e')](_0x31cfbf[_0x451a('0x24')],_0x31cfbf[_0x451a('0x5')]))});continue;case _0x451a('0xa'):_0xeeea81[_0x451a('0x12')]({'type':_0x451a('0x14'),'content':_0x5cc6c9(_0x1401e0,_0x451a('0x1f'),this['getItemLabel'](_0x31cfbf['element'],_0x31cfbf[_0x451a('0x5')]))});continue;}_0xeeea81[_0x451a('0x12')](_0x31cfbf);}return _0xeeea81;}}
|