@ckeditor/ckeditor5-import-word 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.
Files changed (60) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/LICENSE.md +4 -4
  3. package/README.md +7 -7
  4. package/build/import-word.js +1 -1
  5. package/lang/translations/ar.po +1 -0
  6. package/lang/translations/bg.po +1 -0
  7. package/lang/translations/bn.po +1 -0
  8. package/lang/translations/ca.po +1 -0
  9. package/lang/translations/cs.po +1 -0
  10. package/lang/translations/da.po +1 -0
  11. package/lang/translations/de.po +1 -0
  12. package/lang/translations/el.po +1 -0
  13. package/lang/translations/en-au.po +1 -0
  14. package/lang/translations/en.po +1 -0
  15. package/lang/translations/es.po +1 -0
  16. package/lang/translations/et.po +1 -0
  17. package/lang/translations/fi.po +1 -0
  18. package/lang/translations/fr.po +1 -0
  19. package/lang/translations/gl.po +1 -0
  20. package/lang/translations/he.po +1 -0
  21. package/lang/translations/hi.po +1 -0
  22. package/lang/translations/hr.po +1 -0
  23. package/lang/translations/hu.po +1 -0
  24. package/lang/translations/id.po +1 -0
  25. package/lang/translations/it.po +1 -0
  26. package/lang/translations/ja.po +1 -0
  27. package/lang/translations/ko.po +1 -0
  28. package/lang/translations/lt.po +1 -0
  29. package/lang/translations/lv.po +1 -0
  30. package/lang/translations/ms.po +1 -0
  31. package/lang/translations/nl.po +1 -0
  32. package/lang/translations/no.po +1 -0
  33. package/lang/translations/pl.po +1 -0
  34. package/lang/translations/pt-br.po +1 -0
  35. package/lang/translations/pt.po +1 -0
  36. package/lang/translations/ro.po +1 -0
  37. package/lang/translations/ru.po +1 -0
  38. package/lang/translations/sk.po +1 -0
  39. package/lang/translations/sr-latn.po +1 -0
  40. package/lang/translations/sr.po +1 -0
  41. package/lang/translations/sv.po +1 -0
  42. package/lang/translations/th.po +1 -0
  43. package/lang/translations/tr.po +1 -0
  44. package/lang/translations/ug.po +1 -0
  45. package/lang/translations/uk.po +1 -0
  46. package/lang/translations/vi.po +1 -0
  47. package/lang/translations/zh-cn.po +1 -0
  48. package/lang/translations/zh.po +1 -0
  49. package/package.json +2 -6
  50. package/src/augmentation.d.ts +23 -23
  51. package/src/importword.d.ts +99 -99
  52. package/src/importword.js +1 -1
  53. package/src/importwordcommand.d.ts +54 -54
  54. package/src/importwordcommand.js +1 -1
  55. package/src/importwordediting.d.ts +39 -39
  56. package/src/importwordediting.js +1 -1
  57. package/src/importwordui.d.ts +22 -23
  58. package/src/importwordui.js +1 -1
  59. package/src/index.d.ts +12 -12
  60. package/theme/importword.css +0 -49
@@ -1,99 +1,99 @@
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 import-word/importword
7
- * @publicApi
8
- */
9
- import { Plugin } from 'ckeditor5/src/core';
10
- import type { TokenUrl } from '@ckeditor/ckeditor5-cloud-services';
11
- import ImportWordUI from './importwordui';
12
- import ImportWordEditing from './importwordediting';
13
- /**
14
- * The import from Word feature.
15
- *
16
- * It allows importing content from a Word file directly into CKEditor 5.
17
- *
18
- * This is a "glue" plugin which enables:
19
- *
20
- * * {@link module:import-word/importwordediting~ImportWordEditing},
21
- * * {@link module:import-word/importwordui~ImportWordUI},
22
- *
23
- * For a detailed overview, check the {@glink features/converters/import-word/import-word import from Word} feature documentation.
24
- */
25
- export default class ImportWord extends Plugin {
26
- /**
27
- * @inheritDoc
28
- */
29
- static get pluginName(): "ImportWord";
30
- /**
31
- * @inheritDoc
32
- */
33
- static get requires(): readonly [typeof ImportWordEditing, typeof ImportWordUI];
34
- }
35
- /**
36
- * The configuration of the {@link module:import-word/importword~ImportWord import from Word feature}.
37
- *
38
- * The configuration for the import from Word feature requires providing the
39
- * {@link module:import-word/importword~ImportWordConfig#tokenUrl `config.importWord.tokenUrl`}:
40
- *
41
- * ```ts
42
- * ClassicEditor
43
- * .create( editorElement, {
44
- * importWord: {
45
- * tokenUrl: 'https://example.com/cs-token-endpoint'
46
- * }
47
- * } )
48
- * .then( ... )
49
- * .catch( ... );
50
- * ```
51
- *
52
- * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
53
- */
54
- export interface ImportWordConfig {
55
- /**
56
- * A URL to the Docx converter.
57
- *
58
- * ```ts
59
- * const importWordConfig = {
60
- * converterUrl: 'https://myconverter.com/v1/'
61
- * }
62
- * ```
63
- *
64
- * **Note:** The plugin uses the default Word to HTML converter delivered by CKEditor Cloud Services.
65
- * You can provide a URL to an on-premises converter instead.
66
- *
67
- * @default 'https://docx-converter.cke-cs.com/v2/convert/docx-html'
68
- */
69
- converterUrl?: string;
70
- /**
71
- * A token URL or a token request function. This field is optional and should be used only when a different `tokenUrl`
72
- * is required for the Import from Word feature.
73
- *
74
- * **Note:** The token can be disabled with the `false` value provided.
75
- *
76
- * See: {@link module:cloud-services/cloudservicesconfig~CloudServicesConfig#tokenUrl}
77
- */
78
- tokenUrl?: TokenUrl;
79
- /**
80
- * If `true`, the converter service preserves the default styles and formatting of the imported Word document.
81
- *
82
- * @default false
83
- */
84
- defaultStyles?: boolean;
85
- /**
86
- * Defines which formatting styles should be kept for the imported comments text.
87
- *
88
- * Possible values are:
89
- *
90
- * * `'basic'` - basic styles are kept (bold, italic, underline, strikethrough and links),
91
- * * `'none'` - comment text is imported without any styling,
92
- * * `'full'` - all styles are kept (not recommended).
93
- *
94
- * **Note:** Please remember that importing comments requires installing the {@link module:comments/comments~Comments} feature.
95
- *
96
- * @default 'basic'
97
- */
98
- commentsStyles?: 'basic' | 'none' | 'full';
99
- }
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 import-word/importword
7
+ * @publicApi
8
+ */
9
+ import { Plugin } from 'ckeditor5/src/core';
10
+ import type { TokenUrl } from '@ckeditor/ckeditor5-cloud-services';
11
+ import ImportWordUI from './importwordui';
12
+ import ImportWordEditing from './importwordediting';
13
+ /**
14
+ * The import from Word feature.
15
+ *
16
+ * It allows importing content from a Word file directly into CKEditor 5.
17
+ *
18
+ * This is a "glue" plugin which enables:
19
+ *
20
+ * * {@link module:import-word/importwordediting~ImportWordEditing},
21
+ * * {@link module:import-word/importwordui~ImportWordUI},
22
+ *
23
+ * For a detailed overview, check the {@glink features/converters/import-word/import-word import from Word} feature documentation.
24
+ */
25
+ export default class ImportWord extends Plugin {
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ static get pluginName(): "ImportWord";
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ static get requires(): readonly [typeof ImportWordEditing, typeof ImportWordUI];
34
+ }
35
+ /**
36
+ * The configuration of the {@link module:import-word/importword~ImportWord import from Word feature}.
37
+ *
38
+ * The configuration for the import from Word feature requires providing the
39
+ * {@link module:import-word/importword~ImportWordConfig#tokenUrl `config.importWord.tokenUrl`}:
40
+ *
41
+ * ```ts
42
+ * ClassicEditor
43
+ * .create( editorElement, {
44
+ * importWord: {
45
+ * tokenUrl: 'https://example.com/cs-token-endpoint'
46
+ * }
47
+ * } )
48
+ * .then( ... )
49
+ * .catch( ... );
50
+ * ```
51
+ *
52
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
53
+ */
54
+ export interface ImportWordConfig {
55
+ /**
56
+ * A URL to the Docx converter.
57
+ *
58
+ * ```ts
59
+ * const importWordConfig = {
60
+ * converterUrl: 'https://myconverter.com/v1/'
61
+ * }
62
+ * ```
63
+ *
64
+ * **Note:** The plugin uses the default Word to HTML converter delivered by CKEditor Cloud Services.
65
+ * You can provide a URL to an on-premises converter instead.
66
+ *
67
+ * @default 'https://docx-converter.cke-cs.com/v2/convert/docx-html'
68
+ */
69
+ converterUrl?: string;
70
+ /**
71
+ * A token URL or a token request function. This field is optional and should be used only when a different `tokenUrl`
72
+ * is required for the Import from Word feature.
73
+ *
74
+ * **Note:** The token can be disabled with the `false` value provided.
75
+ *
76
+ * See: {@link module:cloud-services/cloudservicesconfig~CloudServicesConfig#tokenUrl}
77
+ */
78
+ tokenUrl?: TokenUrl;
79
+ /**
80
+ * If `true`, the converter service preserves the default styles and formatting of the imported Word document.
81
+ *
82
+ * @default false
83
+ */
84
+ defaultStyles?: boolean;
85
+ /**
86
+ * Defines which formatting styles should be kept for the imported comments text.
87
+ *
88
+ * Possible values are:
89
+ *
90
+ * * `'basic'` - basic styles are kept (bold, italic, underline, strikethrough and links),
91
+ * * `'none'` - comment text is imported without any styling,
92
+ * * `'full'` - all styles are kept (not recommended).
93
+ *
94
+ * **Note:** Please remember that importing comments requires installing the {@link module:comments/comments~Comments} feature.
95
+ *
96
+ * @default 'basic'
97
+ */
98
+ commentsStyles?: 'basic' | 'none' | 'full';
99
+ }
package/src/importword.js CHANGED
@@ -20,4 +20,4 @@
20
20
  *
21
21
  *
22
22
  */
23
- var _0x54d2=['requires','ImportWord'];(function(_0x5ad6d9,_0x54d2b3){var _0x39064d=function(_0x509819){while(--_0x509819){_0x5ad6d9['push'](_0x5ad6d9['shift']());}};_0x39064d(++_0x54d2b3);}(_0x54d2,0x1e1));var _0x3906=function(_0x5ad6d9,_0x54d2b3){_0x5ad6d9=_0x5ad6d9-0x0;var _0x39064d=_0x54d2[_0x5ad6d9];return _0x39064d;};import{Plugin as _0x31250f}from'ckeditor5/src/core';import _0x51a74e from'./importwordui';import _0x390698 from'./importwordediting';export default class i extends _0x31250f{static get['pluginName'](){return _0x3906('0x0');}static get[_0x3906('0x1')](){return[_0x390698,_0x51a74e];}}
23
+ var _0xd4e6=['pluginName','requires','ImportWord'];(function(_0x2b9ce1,_0xd4e6a3){var _0x53e959=function(_0x2e9bd6){while(--_0x2e9bd6){_0x2b9ce1['push'](_0x2b9ce1['shift']());}};_0x53e959(++_0xd4e6a3);}(_0xd4e6,0x11b));var _0x53e9=function(_0x2b9ce1,_0xd4e6a3){_0x2b9ce1=_0x2b9ce1-0x0;var _0x53e959=_0xd4e6[_0x2b9ce1];return _0x53e959;};import{Plugin as _0x4cd818}from'ckeditor5/src/core';import _0x13522d from'./importwordui';import _0x20fbd2 from'./importwordediting';export default class i extends _0x4cd818{static get[_0x53e9('0x2')](){return _0x53e9('0x1');}static get[_0x53e9('0x0')](){return[_0x20fbd2,_0x13522d];}}
@@ -1,54 +1,54 @@
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 import-word/importwordcommand
7
- * @publicApi
8
- */
9
- import { Command, type Editor } from 'ckeditor5/src/core';
10
- /**
11
- * The import from Word command.
12
- *
13
- * It sends the Word file to the converter endpoint and inserts its content into the editor.
14
- */
15
- export default class ImportWordCommand extends Command {
16
- /**
17
- * A command state that indicates if the command is currently executing.
18
- *
19
- * @observable
20
- */
21
- isBusy: boolean;
22
- /**
23
- * @inheritDoc
24
- */
25
- constructor(editor: Editor);
26
- /**
27
- * @inheritDoc
28
- */
29
- refresh(): void;
30
- /**
31
- * Executes the command. Sends the provided file instance to the converter service endpoint and inserts the result into the model.
32
- *
33
- * @fires execute
34
- * @param file The Word file instance to be uploaded for conversion.
35
- * @param [serviceConfig] Additional options to pass to the converter service.
36
- */
37
- execute(file: File, serviceConfig?: Record<string, unknown>): Promise<unknown>;
38
- }
39
- /**
40
- * Fired when the converter service returned the HTML content that will be inserted into the editor.
41
- *
42
- * @eventName ~ImportWordCommand#dataInsert
43
- */
44
- export type DataInsertEvent = {
45
- name: 'dataInsert';
46
- args: [data: DataInsertEventData];
47
- };
48
- interface DataInsertEventData {
49
- /**
50
- * The HTML content to insertion.
51
- */
52
- html: string;
53
- }
54
- 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
+ /**
6
+ * @module import-word/importwordcommand
7
+ * @publicApi
8
+ */
9
+ import { Command, type Editor } from 'ckeditor5/src/core';
10
+ /**
11
+ * The import from Word command.
12
+ *
13
+ * It sends the Word file to the converter endpoint and inserts its content into the editor.
14
+ */
15
+ export default class ImportWordCommand extends Command {
16
+ /**
17
+ * A command state that indicates if the command is currently executing.
18
+ *
19
+ * @observable
20
+ */
21
+ isBusy: boolean;
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ constructor(editor: Editor);
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ refresh(): void;
30
+ /**
31
+ * Executes the command. Sends the provided file instance to the converter service endpoint and inserts the result into the model.
32
+ *
33
+ * @fires execute
34
+ * @param file The Word file instance to be uploaded for conversion.
35
+ * @param [serviceConfig] Additional options to pass to the converter service.
36
+ */
37
+ execute(file: File, serviceConfig?: Record<string, unknown>): Promise<unknown>;
38
+ }
39
+ /**
40
+ * Fired when the converter service returned the HTML content that will be inserted into the editor.
41
+ *
42
+ * @eventName ~ImportWordCommand#dataInsert
43
+ */
44
+ export type DataInsertEvent = {
45
+ name: 'dataInsert';
46
+ args: [data: DataInsertEventData];
47
+ };
48
+ interface DataInsertEventData {
49
+ /**
50
+ * The HTML content to insertion.
51
+ */
52
+ html: string;
53
+ }
54
+ export {};
@@ -20,4 +20,4 @@
20
20
  *
21
21
  *
22
22
  */
23
- import{Command as _0x323778}from'ckeditor5/src/core';import{Range as _0x37cd8b}from'ckeditor5/src/engine';import{logWarning as _0x4c384c,logError as _0x1d1e14,first as _0x57fd20,uid as _0x1900c5}from'ckeditor5/src/utils';export default class d extends _0x323778{constructor(_0x1d9950){super(_0x1d9950),this['set']('isBusy',!0x1),this['_importMarker']=null,this['_undoStepBatch']=null,this['_abortController']=null,this['on']('dataInsert',(_0x40efe5,_0x9b3a7b)=>{const _0xfb9732=new DataTransfer();_0xfb9732['setData']('text/html',_0x9b3a7b['html']);const _0x38aca4=this['_importMarker']['getRange']();this['editor']['model']['enqueueChange'](this['_undoStepBatch'],_0x501179=>{this['_importMarker']['stopListening'](),_0x501179['setSelection'](_0x38aca4),_0x1d9950['editing']['view']['document']['fire']('clipboardInput',{'dataTransfer':_0xfb9732});});},{'priority':'low'});}['refresh'](){this['isEnabled']=this['_checkEnabled']();}['execute'](_0xfedcad,_0x1a54c6={}){if(this['isBusy'])return Promise['resolve']();const _0x3472ed=this['editor']['config']['get']('importWord'),_0x2b5cad={'url':_0x3472ed['converterUrl'],'file':_0xfedcad,'serviceConfig':{..._0x1a54c6,'default_styles':_0x3472ed['defaultStyles']}};return this['_prepareForImport'](),this['_sendImportRequest'](_0x2b5cad)['then'](this['_handleImportResponse']['bind'](this))['catch'](this['_handleImportFailure']['bind'](this))['finally'](this['_cleanUpAfterImport']['bind'](this));}['_checkEnabled'](){if(this['isBusy'])return!0x1;const _0xb7092b=this['editor']['model'],_0x5d40c4=_0xb7092b['schema'],_0x432edd=_0xb7092b['document']['selection'],_0x1163b8=_0x57fd20(_0x432edd['getSelectedBlocks']());return!!_0x1163b8&&_0x5d40c4['checkChild'](_0x1163b8['parent'],'paragraph');}['_prepareForImport'](){const _0x56ba07=this['editor'],_0x20cf7b=_0x56ba07['model'],_0x11fe54=_0x20cf7b['document']['selection'];this['_abortController']=new AbortController(),this['_undoStepBatch']=_0x56ba07['model']['createBatch']({'isUndoable':!0x0}),_0x20cf7b['enqueueChange'](this['_undoStepBatch'],_0x24cd63=>{_0x11fe54['isCollapsed']||_0x20cf7b['deleteContent'](_0x11fe54,{'leaveUnmerged':!0x0});const _0x4b9cb7=_0x11fe54['getFirstPosition'](),_0x503d09=_0x57fd20(_0x11fe54['getSelectedBlocks']());let _0x11d389;_0x11d389=_0x503d09['is']('element','paragraph')&&_0x503d09['isEmpty']?_0x4b9cb7:_0x4b9cb7['isAtStart']?_0x20cf7b['createPositionBefore'](_0x503d09):_0x4b9cb7['isAtEnd']?_0x20cf7b['createPositionAfter'](_0x503d09):_0x24cd63['split'](_0x4b9cb7)['position'],this['_importMarker']=_0x24cd63['addMarker']('importWord:'+_0x1900c5(),{'usingOperation':!0x1,'affectsData':!0x1,'range':new _0x37cd8b(_0x11d389)}),this['_importMarker']['on']('change:range',()=>{'$graveyard'===this['_importMarker']['getRange']()['root']['rootName']&&this['_abortController']['abort']();});}),this['isBusy']=!0x0,this['refresh']();}['_cleanUpAfterImport'](){const _0x3a2e1b=this['editor']['model'];_0x3a2e1b['markers']['has'](this['_importMarker'])&&_0x3a2e1b['enqueueChange'](this['_undoStepBatch'],_0x2d3158=>{_0x2d3158['removeMarker'](this['_importMarker']);}),this['_importMarker']=null,this['_undoStepBatch']=null,this['_abortController']=null,this['isBusy']=!0x1,this['refresh']();}['_sendImportRequest']({url:_0x4f23c6,file:_0x50318d,serviceConfig:_0x440a63}){const _0x1e2ce2=this['editor']['plugins']['get']('ImportWordEditing')['getToken'](),_0x2440a9=new FormData();_0x2440a9['set']('config',JSON['stringify'](_0x440a63)),_0x2440a9['set']('file',_0x50318d);const _0x26ac38={'method':'POST','headers':{},'body':_0x2440a9,'signal':this['_abortController']['signal']};return _0x1e2ce2&&(_0x26ac38['headers']['Authorization']=_0x1e2ce2['value']),fetch(_0x4f23c6,_0x26ac38);}['_handleImportResponse'](_0x594b8f){return _0x594b8f['ok']?_0x594b8f['json']()['then'](_0x40b4e1=>{if(!this['editor']['model']['markers']['has'](this['_importMarker']))return;'$graveyard'!==this['_importMarker']['getRange']()['root']['rootName']&&this['fire']('dataInsert',_0x40b4e1);}):Promise['reject']();}['_handleImportFailure'](){if(this['_abortController']['signal']['aborted'])return void _0x4c384c('import-word-plugin-import-cancelled');const _0x45e8a0=this['editor'],_0x5ac614=(0x0,_0x45e8a0['t'])('An\x20error\x20occurred\x20while\x20importing\x20the\x20Word\x20file.');_0x45e8a0['plugins']['get']('Notification')['showWarning'](_0x5ac614),_0x1d1e14('import-word-plugin-conversion-failed');}}
23
+ import{Command as _0x5aa408}from'ckeditor5/src/core';import{Range as _0x4dbb0f}from'ckeditor5/src/engine';import{logWarning as _0x249d6e,logError as _0x344400,first as _0x36cb45,uid as _0x234ec1}from'ckeditor5/src/utils';export default class d extends _0x5aa408{constructor(_0x1b36c2){super(_0x1b36c2),this['set']('isBusy',!0x1),this['_importMarker']=null,this['_undoStepBatch']=null,this['_abortController']=null,this['on']('dataInsert',(_0x230c96,_0x31b19d)=>{const _0x26f210=new DataTransfer();_0x26f210['setData']('text/html',_0x31b19d['html']);const _0x5e30d7=this['_importMarker']['getRange']();this['editor']['model']['enqueueChange'](this['_undoStepBatch'],_0x935035=>{this['_importMarker']['stopListening'](),_0x935035['setSelection'](_0x5e30d7),_0x1b36c2['editing']['view']['document']['fire']('clipboardInput',{'dataTransfer':_0x26f210});});},{'priority':'low'});}['refresh'](){this['isEnabled']=this['_checkEnabled']();}['execute'](_0x4fdcdd,_0x5c588e={}){if(this['isBusy'])return Promise['resolve']();const _0x20af96=this['editor']['config']['get']('importWord'),_0x1747e6={'url':_0x20af96['converterUrl'],'file':_0x4fdcdd,'serviceConfig':{..._0x5c588e,'default_styles':_0x20af96['defaultStyles']}};return this['_prepareForImport'](),this['_sendImportRequest'](_0x1747e6)['then'](this['_handleImportResponse']['bind'](this))['catch'](this['_handleImportFailure']['bind'](this))['finally'](this['_cleanUpAfterImport']['bind'](this));}['_checkEnabled'](){if(this['isBusy'])return!0x1;const _0x52ee31=this['editor']['model'],_0x1a24ef=_0x52ee31['schema'],_0x2d59ad=_0x52ee31['document']['selection'],_0x37e871=_0x36cb45(_0x2d59ad['getSelectedBlocks']());return!!_0x37e871&&_0x1a24ef['checkChild'](_0x37e871['parent'],'paragraph');}['_prepareForImport'](){const _0x59c439=this['editor'],_0x224dcd=_0x59c439['model'],_0x19e1d4=_0x224dcd['document']['selection'];this['_abortController']=new AbortController(),this['_undoStepBatch']=_0x59c439['model']['createBatch']({'isUndoable':!0x0}),_0x224dcd['enqueueChange'](this['_undoStepBatch'],_0x34563c=>{_0x19e1d4['isCollapsed']||_0x224dcd['deleteContent'](_0x19e1d4,{'leaveUnmerged':!0x0});const _0x5eac91=_0x19e1d4['getFirstPosition'](),_0x37aa3c=_0x36cb45(_0x19e1d4['getSelectedBlocks']());let _0x3b4f01;_0x3b4f01=_0x37aa3c['is']('element','paragraph')&&_0x37aa3c['isEmpty']?_0x5eac91:_0x5eac91['isAtStart']?_0x224dcd['createPositionBefore'](_0x37aa3c):_0x5eac91['isAtEnd']?_0x224dcd['createPositionAfter'](_0x37aa3c):_0x34563c['split'](_0x5eac91)['position'],this['_importMarker']=_0x34563c['addMarker']('importWord:'+_0x234ec1(),{'usingOperation':!0x1,'affectsData':!0x1,'range':new _0x4dbb0f(_0x3b4f01)}),this['_importMarker']['on']('change:range',()=>{'$graveyard'===this['_importMarker']['getRange']()['root']['rootName']&&this['_abortController']['abort']();});}),this['isBusy']=!0x0,this['refresh']();}['_cleanUpAfterImport'](){const _0x55b1dd=this['editor']['model'];_0x55b1dd['markers']['has'](this['_importMarker'])&&_0x55b1dd['enqueueChange'](this['_undoStepBatch'],_0x889fe1=>{_0x889fe1['removeMarker'](this['_importMarker']);}),this['_importMarker']=null,this['_undoStepBatch']=null,this['_abortController']=null,this['isBusy']=!0x1,this['refresh']();}['_sendImportRequest']({url:_0x316d19,file:_0x1905eb,serviceConfig:_0x2b3e33}){const _0x43f40f=this['editor']['plugins']['get']('ImportWordEditing')['getToken'](),_0x2d4f35=new FormData();_0x2d4f35['set']('config',JSON['stringify'](_0x2b3e33)),_0x2d4f35['set']('file',_0x1905eb);const _0x12b529={'method':'POST','headers':{},'body':_0x2d4f35,'signal':this['_abortController']['signal']};return _0x43f40f&&(_0x12b529['headers']['Authorization']=_0x43f40f['value']),fetch(_0x316d19,_0x12b529);}['_handleImportResponse'](_0x32732c){return _0x32732c['ok']?_0x32732c['json']()['then'](_0x41bfe7=>{if(!this['editor']['model']['markers']['has'](this['_importMarker']))return;'$graveyard'!==this['_importMarker']['getRange']()['root']['rootName']&&this['fire']('dataInsert',_0x41bfe7);}):Promise['reject']();}['_handleImportFailure'](){if(this['_abortController']['signal']['aborted'])return void _0x249d6e('import-word-plugin-import-cancelled');const _0x50b97e=this['editor'],_0xf013aa=(0x0,_0x50b97e['t'])('An\x20error\x20occurred\x20while\x20importing\x20the\x20Word\x20file.');_0x50b97e['plugins']['get']('Notification')['showWarning'](_0xf013aa),_0x344400('import-word-plugin-conversion-failed');}}
@@ -1,39 +1,39 @@
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 import-word/importwordediting
7
- * @publicApi
8
- */
9
- import { Plugin, type Editor } from 'ckeditor5/src/core';
10
- import { Notification } from 'ckeditor5/src/ui';
11
- import { ClipboardPipeline } from 'ckeditor5/src/clipboard';
12
- import type { InitializedToken } from '@ckeditor/ckeditor5-cloud-services';
13
- /**
14
- * The editing part of the import from Word feature.
15
- *
16
- * It registers the {@link module:import-word/importwordcommand~ImportWordCommand `'importWord'` command}.
17
- */
18
- export default class ImportWordEditing extends Plugin {
19
- /**
20
- * @inheritDoc
21
- */
22
- static get pluginName(): "ImportWordEditing";
23
- /**
24
- * @inheritDoc
25
- */
26
- static get requires(): readonly [typeof Notification, typeof ClipboardPipeline, "CloudServices"];
27
- /**
28
- * @inheritDoc
29
- */
30
- constructor(editor: Editor);
31
- /**
32
- * @inheritDoc
33
- */
34
- init(): Promise<void>;
35
- /**
36
- * Returns a token used by the import from Word plugin for communication with the Cloud Services.
37
- */
38
- getToken(): InitializedToken | null;
39
- }
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 import-word/importwordediting
7
+ * @publicApi
8
+ */
9
+ import { Plugin, type Editor } from 'ckeditor5/src/core';
10
+ import { Notification } from 'ckeditor5/src/ui';
11
+ import { ClipboardPipeline } from 'ckeditor5/src/clipboard';
12
+ import type { InitializedToken } from '@ckeditor/ckeditor5-cloud-services';
13
+ /**
14
+ * The editing part of the import from Word feature.
15
+ *
16
+ * It registers the {@link module:import-word/importwordcommand~ImportWordCommand `'importWord'` command}.
17
+ */
18
+ export default class ImportWordEditing extends Plugin {
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get pluginName(): "ImportWordEditing";
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get requires(): readonly [typeof Notification, typeof ClipboardPipeline, "CloudServices"];
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ constructor(editor: Editor);
31
+ /**
32
+ * @inheritDoc
33
+ */
34
+ init(): Promise<void>;
35
+ /**
36
+ * Returns a token used by the import from Word plugin for communication with the Cloud Services.
37
+ */
38
+ getToken(): InitializedToken | null;
39
+ }
@@ -20,4 +20,4 @@
20
20
  *
21
21
  *
22
22
  */
23
- const _0x30a8=['plugins','get','CloudServices','init','editor','_token','ImportWordEditing','registerTokenUrl','config','token','importWord','pluginName','cloudServices','add','https://docx-converter.cke-cs.com/v2/convert/docx-html','define','commands'];(function(_0x18bf84,_0x30a87e){const _0x3ed05b=function(_0x1af18e){while(--_0x1af18e){_0x18bf84['push'](_0x18bf84['shift']());}};_0x3ed05b(++_0x30a87e);}(_0x30a8,0xcc));const _0x3ed0=function(_0x18bf84,_0x30a87e){_0x18bf84=_0x18bf84-0x0;let _0x3ed05b=_0x30a8[_0x18bf84];return _0x3ed05b;};import{Plugin as _0x1a2b85}from'ckeditor5/src/core';import{Notification as _0x2927bd}from'ckeditor5/src/ui';import{ClipboardPipeline as _0x1d874c}from'ckeditor5/src/clipboard';import _0x304555 from'./importwordcommand';export default class e extends _0x1a2b85{static get[_0x3ed0('0xb')](){return _0x3ed0('0x6');}static get['requires'](){return[_0x2927bd,_0x1d874c,_0x3ed0('0x2')];}constructor(_0x4e48b9){super(_0x4e48b9),this[_0x3ed0('0x5')]=null;}async[_0x3ed0('0x3')](){const _0x54f5fc=this[_0x3ed0('0x4')];_0x54f5fc[_0x3ed0('0x8')][_0x3ed0('0xf')]('importWord',{'converterUrl':_0x3ed0('0xe'),'tokenUrl':(_0x54f5fc[_0x3ed0('0x8')][_0x3ed0('0x1')]('cloudServices')||{})['tokenUrl'],'defaultStyles':!0x1}),_0x54f5fc[_0x3ed0('0x10')][_0x3ed0('0xd')](_0x3ed0('0xa'),new _0x304555(_0x54f5fc));const {tokenUrl:_0x4377c3}=_0x54f5fc[_0x3ed0('0x8')][_0x3ed0('0x1')](_0x3ed0('0xa'));if(_0x4377c3){const {tokenUrl:_0x1ddd94}=_0x54f5fc['config'][_0x3ed0('0x1')](_0x3ed0('0xc'))||{};this[_0x3ed0('0x5')]=_0x4377c3===_0x1ddd94?_0x54f5fc[_0x3ed0('0x0')][_0x3ed0('0x1')](_0x3ed0('0x2'))[_0x3ed0('0x9')]:await _0x54f5fc[_0x3ed0('0x0')][_0x3ed0('0x1')]('CloudServices')[_0x3ed0('0x7')](_0x4377c3);}}['getToken'](){return this[_0x3ed0('0x5')];}}
23
+ const _0xf7a7=['CloudServices','ImportWordEditing','registerTokenUrl','pluginName','tokenUrl','token','get','add','_token','plugins','cloudServices','importWord','getToken','config','requires','init'];(function(_0xaed653,_0xf7a7d7){const _0x37fd0f=function(_0x1b19af){while(--_0x1b19af){_0xaed653['push'](_0xaed653['shift']());}};_0x37fd0f(++_0xf7a7d7);}(_0xf7a7,0x91));const _0x37fd=function(_0xaed653,_0xf7a7d7){_0xaed653=_0xaed653-0x0;let _0x37fd0f=_0xf7a7[_0xaed653];return _0x37fd0f;};import{Plugin as _0x30fbbb}from'ckeditor5/src/core';import{Notification as _0x45f508}from'ckeditor5/src/ui';import{ClipboardPipeline as _0x46ae2f}from'ckeditor5/src/clipboard';import _0x1a8c52 from'./importwordcommand';export default class e extends _0x30fbbb{static get[_0x37fd('0x2')](){return _0x37fd('0x0');}static get[_0x37fd('0xd')](){return[_0x45f508,_0x46ae2f,_0x37fd('0xf')];}constructor(_0x1865e5){super(_0x1865e5),this[_0x37fd('0x7')]=null;}async[_0x37fd('0xe')](){const _0x4e2c49=this['editor'];_0x4e2c49[_0x37fd('0xc')]['define'](_0x37fd('0xa'),{'converterUrl':'https://docx-converter.cke-cs.com/v2/convert/docx-html','tokenUrl':(_0x4e2c49['config'][_0x37fd('0x5')]('cloudServices')||{})[_0x37fd('0x3')],'defaultStyles':!0x1}),_0x4e2c49['commands'][_0x37fd('0x6')](_0x37fd('0xa'),new _0x1a8c52(_0x4e2c49));const {tokenUrl:_0x2f8888}=_0x4e2c49[_0x37fd('0xc')][_0x37fd('0x5')](_0x37fd('0xa'));if(_0x2f8888){const {tokenUrl:_0x1ecb87}=_0x4e2c49[_0x37fd('0xc')]['get'](_0x37fd('0x9'))||{};this[_0x37fd('0x7')]=_0x2f8888===_0x1ecb87?_0x4e2c49[_0x37fd('0x8')]['get'](_0x37fd('0xf'))[_0x37fd('0x4')]:await _0x4e2c49[_0x37fd('0x8')][_0x37fd('0x5')](_0x37fd('0xf'))[_0x37fd('0x1')](_0x2f8888);}}[_0x37fd('0xb')](){return this[_0x37fd('0x7')];}}
@@ -1,23 +1,22 @@
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 import-word/importwordui
7
- * @publicApi
8
- */
9
- import { Plugin } from 'ckeditor5/src/core';
10
- import '../theme/importword.css';
11
- /**
12
- * The ImportWordUI plugin. It introduces the `'importWord'` toolbar button.
13
- */
14
- export default class ImportWordUI extends Plugin {
15
- /**
16
- * @inheritDoc
17
- */
18
- static get pluginName(): "ImportWordUI";
19
- /**
20
- * @inheritDoc
21
- */
22
- init(): void;
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 import-word/importwordui
7
+ * @publicApi
8
+ */
9
+ import { Plugin } from 'ckeditor5/src/core';
10
+ /**
11
+ * The ImportWordUI plugin. It introduces the `'importWord'` toolbar button.
12
+ */
13
+ export default class ImportWordUI extends Plugin {
14
+ /**
15
+ * @inheritDoc
16
+ */
17
+ static get pluginName(): "ImportWordUI";
18
+ /**
19
+ * @inheritDoc
20
+ */
21
+ init(): void;
22
+ }
@@ -20,4 +20,4 @@
20
20
  *
21
21
  *
22
22
  */
23
- import{Plugin as _0x4c45c9}from'ckeditor5/src/core';import{View as _0x5ef2cf}from'ckeditor5/src/ui';import{FileDialogButtonView as _0xe07650}from'ckeditor5/src/upload';import _0x52d506 from'../theme/icons/importword.svg';import'../theme/importword.css';export default class o extends _0x4c45c9{static get['pluginName'](){return'ImportWordUI';}['init'](){const _0x36a488=this['editor'],t=_0x36a488['t'];_0x36a488['ui']['componentFactory']['add']('importWord',_0x4bc133=>{const _0x4a41eb=_0x36a488['commands']['get']('importWord'),_0x30f288=new _0xe07650(_0x4bc133);_0x30f288['set']({'acceptedType':'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.wordprocessingml.template'}),_0x30f288['buttonView']['set']({'label':t('Import\x20from\x20Word'),'icon':_0x52d506,'tooltip':!0x0}),_0x30f288['buttonView']['bind']('isOn','isEnabled')['to'](_0x4a41eb,'isBusy','isEnabled'),_0x30f288['buttonView']['extendTemplate']({'attributes':{'class':[_0x30f288['buttonView']['bindTemplate']['if']('isOn','ck-importword_status-pending')]}});const _0x333c5d=new _0x5ef2cf();return _0x333c5d['setTemplate']({'tag':'span','attributes':{'class':['ck','ck-importword__spinner-container']},'children':[{'tag':'span','attributes':{'class':['ck','ck-importword__spinner']}}]}),_0x30f288['buttonView']['children']['add'](_0x333c5d),_0x30f288['on']('done',(_0x2a4fdf,_0x29f170)=>{_0x36a488['execute']('importWord',_0x29f170[0x0],{}),_0x36a488['editing']['view']['focus']();}),_0x30f288;});}}
23
+ import{Plugin as _0x5a844c}from'ckeditor5/src/core';import{SpinnerView as _0x42a443}from'ckeditor5/src/ui';import{FileDialogButtonView as _0x4f08f6}from'ckeditor5/src/upload';import _0x5f12ee from'../theme/icons/importword.svg';export default class o extends _0x5a844c{static get['pluginName'](){return'ImportWordUI';}['init'](){const _0x3f3f46=this['editor'],t=_0x3f3f46['t'];_0x3f3f46['ui']['componentFactory']['add']('importWord',_0x4bad53=>{const _0x37fbf5=_0x3f3f46['commands']['get']('importWord'),_0x5f5037=new _0x4f08f6(_0x4bad53),_0x2c31e3=new _0x42a443();return _0x5f5037['set']({'acceptedType':'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.wordprocessingml.template'}),_0x5f5037['buttonView']['set']({'label':t('Import\x20from\x20Word'),'icon':_0x5f12ee,'tooltip':!0x0}),_0x5f5037['buttonView']['bind']('isOn','isEnabled')['to'](_0x37fbf5,'isBusy','isEnabled'),_0x2c31e3['bind']('isVisible')['to'](_0x37fbf5,'isBusy'),_0x5f5037['buttonView']['iconView']['bind']('isVisible')['to'](_0x37fbf5,'isBusy',_0x49e3bc=>!_0x49e3bc),_0x5f5037['buttonView']['children']['add'](_0x2c31e3),_0x5f5037['on']('done',(_0x1df9ef,_0x7aefdf)=>{_0x3f3f46['execute']('importWord',_0x7aefdf[0x0],{}),_0x3f3f46['editing']['view']['focus']();}),_0x5f5037;});}}
package/src/index.d.ts CHANGED
@@ -1,12 +1,12 @@
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 import-word
7
- */
8
- export { default as ImportWord, type ImportWordConfig } from './importword';
9
- export { default as ImportWordEditing } from './importwordediting';
10
- export { default as ImportWordUI } from './importwordui';
11
- export type { default as ImportWordCommand } from './importwordcommand';
12
- import './augmentation';
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 import-word
7
+ */
8
+ export { default as ImportWord, type ImportWordConfig } from './importword';
9
+ export { default as ImportWordEditing } from './importwordediting';
10
+ export { default as ImportWordUI } from './importwordui';
11
+ export type { default as ImportWordCommand } from './importwordcommand';
12
+ import './augmentation';
@@ -1,49 +0,0 @@
1
- /*
2
- * 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
- :root {
7
- --ck-toolbar-spinner-size: 18px;
8
- }
9
-
10
- .ck-importword_status-pending {
11
- position: relative;
12
- }
13
-
14
- .ck.ck-importword__spinner-container {
15
- display: none;
16
- }
17
-
18
- .ck.ck-importword__spinner {
19
- position: absolute;
20
- top: 50%;
21
- left: 0;
22
- right: 0;
23
- margin: 0 auto;
24
- width: var(--ck-toolbar-spinner-size);
25
- height: var(--ck-toolbar-spinner-size);
26
- border-radius: 50%;
27
- border: 2px solid var(--ck-color-text);
28
- border-top-color: transparent;
29
- transform: translateY(-50%);
30
- z-index: 1;
31
- }
32
-
33
- .ck-importword_status-pending .ck.ck-importword__spinner-container {
34
- display: block;
35
- position: absolute;
36
- width: var(--ck-toolbar-spinner-size);
37
- height: var(--ck-toolbar-spinner-size);
38
- animation: 1.5s infinite rotate linear;
39
- }
40
-
41
- .ck-importword_status-pending .ck.ck-button__icon {
42
- color: transparent;
43
- }
44
-
45
- @keyframes rotate {
46
- to {
47
- transform: rotate(360deg)
48
- }
49
- }