@ckeditor/ckeditor5-export-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 +8 -8
  4. package/build/export-word.js +2 -2
  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/jv.po +1 -0
  28. package/lang/translations/ko.po +1 -0
  29. package/lang/translations/lt.po +1 -0
  30. package/lang/translations/lv.po +1 -0
  31. package/lang/translations/ms.po +1 -0
  32. package/lang/translations/nl.po +1 -0
  33. package/lang/translations/no.po +1 -0
  34. package/lang/translations/pl.po +1 -0
  35. package/lang/translations/pt-br.po +1 -0
  36. package/lang/translations/pt.po +1 -0
  37. package/lang/translations/ro.po +1 -0
  38. package/lang/translations/ru.po +1 -0
  39. package/lang/translations/sk.po +1 -0
  40. package/lang/translations/sr-latn.po +1 -0
  41. package/lang/translations/sr.po +1 -0
  42. package/lang/translations/sv.po +1 -0
  43. package/lang/translations/th.po +1 -0
  44. package/lang/translations/tr.po +1 -0
  45. package/lang/translations/ug.po +1 -0
  46. package/lang/translations/uk.po +1 -0
  47. package/lang/translations/ur.po +1 -0
  48. package/lang/translations/vi.po +1 -0
  49. package/lang/translations/zh-cn.po +1 -0
  50. package/lang/translations/zh.po +1 -0
  51. package/package.json +2 -6
  52. package/src/augmentation.d.ts +21 -21
  53. package/src/exportword.d.ts +231 -232
  54. package/src/exportword.js +1 -1
  55. package/src/exportwordcommand.d.ts +36 -36
  56. package/src/exportwordcommand.js +1 -1
  57. package/src/index.d.ts +10 -10
  58. package/src/utils.d.ts +36 -36
  59. package/src/utils.js +1 -1
  60. package/theme/exportword.css +0 -49
@@ -1,21 +1,21 @@
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 { ExportWordConfig, ExportWord, ExportWordCommand } from './index';
6
- declare module '@ckeditor/ckeditor5-core' {
7
- interface EditorConfig {
8
- /**
9
- * The configuration of the {@link module:export-word/exportword~ExportWord export to Word feature}.
10
- *
11
- * Read more in {@link module:export-word/exportword~ExportWordConfig}.
12
- */
13
- exportWord?: ExportWordConfig;
14
- }
15
- interface PluginsMap {
16
- [ExportWord.pluginName]: ExportWord;
17
- }
18
- interface CommandsMap {
19
- exportWord: ExportWordCommand;
20
- }
21
- }
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 { ExportWordConfig, ExportWord, ExportWordCommand } from './index';
6
+ declare module '@ckeditor/ckeditor5-core' {
7
+ interface EditorConfig {
8
+ /**
9
+ * The configuration of the {@link module:export-word/exportword~ExportWord export to Word feature}.
10
+ *
11
+ * Read more in {@link module:export-word/exportword~ExportWordConfig}.
12
+ */
13
+ exportWord?: ExportWordConfig;
14
+ }
15
+ interface PluginsMap {
16
+ [ExportWord.pluginName]: ExportWord;
17
+ }
18
+ interface CommandsMap {
19
+ exportWord: ExportWordCommand;
20
+ }
21
+ }
@@ -1,232 +1,231 @@
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 export-word/exportword
7
- * @publicApi
8
- */
9
- import { Plugin, type Editor } from 'ckeditor5/src/core';
10
- import { Notification } from 'ckeditor5/src/ui';
11
- import type { InitializedToken, TokenUrl } from '@ckeditor/ckeditor5-cloud-services';
12
- import '../theme/exportword.css';
13
- /**
14
- * The export to Word feature.
15
- *
16
- * It allows you to generate a Word file directly from the editor content.
17
- *
18
- * For a detailed overview, check the {@glink features/converters/export-word export to Word} feature documentation.
19
- */
20
- export default class ExportWord extends Plugin {
21
- /**
22
- * @inheritDoc
23
- */
24
- static get pluginName(): "ExportWord";
25
- /**
26
- * @inheritDoc
27
- */
28
- static get requires(): readonly ["CloudServices", typeof Notification];
29
- /**
30
- * @inheritDoc
31
- */
32
- init(): void;
33
- }
34
- /**
35
- * The configuration of the export to Word feature. It is used by the Word export features from
36
- * the `@ckeditor/ckeditor5-export-word` package.
37
- *
38
- * ```ts
39
- * ClassicEditor
40
- * .create( editorElement, {
41
- * exportWord: ... // Export to Word feature options.
42
- * } )
43
- * .then( ... )
44
- * .catch( ... );
45
- * ```
46
- *
47
- * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
48
- */
49
- export interface ExportWordConfig {
50
- /**
51
- * Paths to the `.css` files containing additional styling for the editor's content (**the order of provided items matters**).
52
- *
53
- * ```ts
54
- * const exportWordConfig = {
55
- * stylesheets: [ './path/to/custom-style.css' ]
56
- * }
57
- * ```
58
- *
59
- * **NOTE:** If `stylesheets` are not provided, the plugin will sent only
60
- * {@glink installation/advanced/content-styles#the-full-list-of-content-styles the default editor content styles} to the converter.
61
- *
62
- * **Default editor's content styles**:
63
- * {@glink installation/advanced/content-styles#the-full-list-of-content-styles The default editor content styles}
64
- * are applied to the generated Word file thanks to the 'EDITOR_STYLES' token, which is provided to the `stylesheets` by default.
65
- * If you don't want them to be applied, you have to omit the token:
66
- *
67
- * ```ts
68
- * const exportWordConfig = {
69
- * stylesheets: [ './path/to/custom-editor-styles.css' ]
70
- * }
71
- * ```
72
- *
73
- * **Custom styling:** For more advanced styling, your configuration should look like this:
74
- *
75
- * ```ts
76
- * const exportWordConfig = {
77
- * stylesheets: [
78
- * 'EDITOR_STYLES',
79
- * './path/to/custom-styles.css'
80
- * ]
81
- * }
82
- * ```
83
- *
84
- * @default `[ 'EDITOR_STYLES' ]`
85
- */
86
- stylesheets?: Array<string>;
87
- /**
88
- * The name of the generated Word file.
89
- *
90
- * ```ts
91
- * // Static file name.
92
- * const exportWordConfig = {
93
- * fileName: 'my-document.docx'
94
- * }
95
- *
96
- *
97
- * // Dynamic file name.
98
- * const exportWordConfig = {
99
- * fileName: () => {
100
- * const articleTitle = document.querySelector( '#title' );
101
- *
102
- * return `${ articleTitle.value }.docx`;
103
- * }
104
- * }
105
- * ```
106
- *
107
- * **NOTE:** The file name must contain the `.docx` extension.
108
- * Otherwise your operating system or device may have trouble identifying the file type.
109
- *
110
- * @default 'document.docx'
111
- */
112
- fileName?: string | (() => string);
113
- /**
114
- * A URL to the Docx converter.
115
- *
116
- * ```ts
117
- * const exportWordConfig = {
118
- * converterUrl: 'https://myconverter.com/v1/'
119
- * }
120
- * ```
121
- *
122
- * **NOTE:** The plugin uses the default HTML to Word converter delivered by CKEditor Cloud Services.
123
- * You can provide a URL to an on-premises converter instead.
124
- *
125
- * @default 'https://docx-converter.cke-cs.com/v1/convert'
126
- */
127
- converterUrl?: string;
128
- /**
129
- * The CKEditor Cloud Services HTML to DOCX Converter [configuration options](https://docx-converter.cke-cs.com/docs#section/Options).
130
- *
131
- * **NOTE:** Configuring the plugin is not mandatory.
132
- *
133
- * ```ts
134
- * const exportWordConfig = {
135
- * converterOptions: {
136
- * ...
137
- * }
138
- * }
139
- * ```
140
- *
141
- * @default `{
142
- * format: 'A4',
143
- * margin_top: '1in',
144
- * margin_bottom: '1in',
145
- * margin_right: '1in',
146
- * margin_left: '1in',
147
- * header: undefined,
148
- * footer: undefined,
149
- * comments: undefined,
150
- * suggestions: undefined,
151
- * orientation: 'portrait',
152
- * auto_pagination: true,
153
- * base_url: undefined,
154
- * timezone: 'UTC'
155
- * }`
156
- */
157
- converterOptions?: ExportWordConverterOptions;
158
- /**
159
- * A function to gather the HTML to be converted to Word.
160
- *
161
- * **NOTE:** This option may be useful when the editor does not have a `getData()` method,
162
- * or if the HTML to be converted should be different than the edited one.
163
- *
164
- * ```ts
165
- * const exportWordConfig = {
166
- * dataCallback: ( editor ) => {
167
- * return `
168
- * <header id="header">${ editor.data.get( { rootName: 'header' } ) }</header>
169
- * <div id="content">${ editor.data.get( { rootName: 'content' } ) }</div>
170
- * `;
171
- * }
172
- * }
173
- * ```
174
- *
175
- * @default `( editor ) => editor.getData( { pagination: true } )
176
- *
177
- * If using the {@glink features/pagination/pagination pagination} feature, the `pagination:true` option inserts additional markers into
178
- * editor's data. Thanks to that, the Docx converter creates a Word document similar to what is displayed in the editor.
179
- */
180
- dataCallback?: (editor: Editor) => string;
181
- /**
182
- * A token URL or a token request function. This field is optional and should be used only when a different `tokenUrl` is required for
183
- * the export to Word feature.
184
- *
185
- * **Note:** The token can be disabled with the `false` value provided.
186
- *
187
- * See: {@link module:cloud-services/cloudservicesconfig~CloudServicesConfig#tokenUrl}
188
- */
189
- tokenUrl?: TokenUrl | false;
190
- /**
191
- * The authentication token.
192
- *
193
- * See: {@link module:cloud-services/cloudservices~CloudServices#token}
194
- */
195
- token?: InitializedToken;
196
- }
197
- export type ExportWordConverterOptions = {
198
- format?: ExportWordConverterFormatOption;
199
- margin_top?: string;
200
- margin_bottom?: string;
201
- margin_right?: string;
202
- margin_left?: string;
203
- header?: ExportWordConverterHeaderFooterOption;
204
- footer?: ExportWordConverterHeaderFooterOption;
205
- comments?: ExportWordConverterCommentsOption;
206
- suggestions?: ExportWordConverterSuggestionsOption;
207
- orientation?: ExportWordConverterOrientationOption;
208
- auto_pagination?: boolean;
209
- base_url?: string;
210
- timezone?: string;
211
- };
212
- export type ExportWordConverterFormatOption = 'Letter' | 'Legal' | 'Tabloid' | 'Statement' | 'Executive' | 'A3' | 'A4' | 'A5' | 'A6' | 'B4' | 'B5';
213
- export type ExportWordConverterOrientationOption = 'portrait' | 'landscape';
214
- export type ExportWordConverterHeaderFooterOption = Array<{
215
- html?: string;
216
- css?: string;
217
- type?: 'default' | 'even' | 'odd' | 'first';
218
- }>;
219
- export type ExportWordConverterCommentsOption = {
220
- [id: string]: Array<{
221
- author: string;
222
- created: Date;
223
- content?: string;
224
- is_resolved: boolean;
225
- }>;
226
- };
227
- export type ExportWordConverterSuggestionsOption = {
228
- [id: string]: {
229
- author: string;
230
- created: Date | null;
231
- };
232
- };
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 export-word/exportword
7
+ * @publicApi
8
+ */
9
+ import { Plugin, type Editor } from 'ckeditor5/src/core';
10
+ import { Notification } from 'ckeditor5/src/ui';
11
+ import type { InitializedToken, TokenUrl } from '@ckeditor/ckeditor5-cloud-services';
12
+ /**
13
+ * The export to Word feature.
14
+ *
15
+ * It allows you to generate a Word file directly from the editor content.
16
+ *
17
+ * For a detailed overview, check the {@glink features/converters/export-word export to Word} feature documentation.
18
+ */
19
+ export default class ExportWord extends Plugin {
20
+ /**
21
+ * @inheritDoc
22
+ */
23
+ static get pluginName(): "ExportWord";
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ static get requires(): readonly ["CloudServices", typeof Notification];
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ init(): void;
32
+ }
33
+ /**
34
+ * The configuration of the export to Word feature. It is used by the Word export features from
35
+ * the `@ckeditor/ckeditor5-export-word` package.
36
+ *
37
+ * ```ts
38
+ * ClassicEditor
39
+ * .create( editorElement, {
40
+ * exportWord: ... // Export to Word feature options.
41
+ * } )
42
+ * .then( ... )
43
+ * .catch( ... );
44
+ * ```
45
+ *
46
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
47
+ */
48
+ export interface ExportWordConfig {
49
+ /**
50
+ * Paths to the `.css` files containing additional styling for the editor's content (**the order of provided items matters**).
51
+ *
52
+ * ```ts
53
+ * const exportWordConfig = {
54
+ * stylesheets: [ './path/to/custom-style.css' ]
55
+ * }
56
+ * ```
57
+ *
58
+ * **NOTE:** If `stylesheets` are not provided, the plugin will sent only
59
+ * {@glink installation/advanced/content-styles#the-full-list-of-content-styles the default editor content styles} to the converter.
60
+ *
61
+ * **Default editor's content styles**:
62
+ * {@glink installation/advanced/content-styles#the-full-list-of-content-styles The default editor content styles}
63
+ * are applied to the generated Word file thanks to the 'EDITOR_STYLES' token, which is provided to the `stylesheets` by default.
64
+ * If you don't want them to be applied, you have to omit the token:
65
+ *
66
+ * ```ts
67
+ * const exportWordConfig = {
68
+ * stylesheets: [ './path/to/custom-editor-styles.css' ]
69
+ * }
70
+ * ```
71
+ *
72
+ * **Custom styling:** For more advanced styling, your configuration should look like this:
73
+ *
74
+ * ```ts
75
+ * const exportWordConfig = {
76
+ * stylesheets: [
77
+ * 'EDITOR_STYLES',
78
+ * './path/to/custom-styles.css'
79
+ * ]
80
+ * }
81
+ * ```
82
+ *
83
+ * @default `[ 'EDITOR_STYLES' ]`
84
+ */
85
+ stylesheets?: Array<string>;
86
+ /**
87
+ * The name of the generated Word file.
88
+ *
89
+ * ```ts
90
+ * // Static file name.
91
+ * const exportWordConfig = {
92
+ * fileName: 'my-document.docx'
93
+ * }
94
+ *
95
+ *
96
+ * // Dynamic file name.
97
+ * const exportWordConfig = {
98
+ * fileName: () => {
99
+ * const articleTitle = document.querySelector( '#title' );
100
+ *
101
+ * return `${ articleTitle.value }.docx`;
102
+ * }
103
+ * }
104
+ * ```
105
+ *
106
+ * **NOTE:** The file name must contain the `.docx` extension.
107
+ * Otherwise your operating system or device may have trouble identifying the file type.
108
+ *
109
+ * @default 'document.docx'
110
+ */
111
+ fileName?: string | (() => string);
112
+ /**
113
+ * A URL to the Docx converter.
114
+ *
115
+ * ```ts
116
+ * const exportWordConfig = {
117
+ * converterUrl: 'https://myconverter.com/v1/'
118
+ * }
119
+ * ```
120
+ *
121
+ * **NOTE:** The plugin uses the default HTML to Word converter delivered by CKEditor Cloud Services.
122
+ * You can provide a URL to an on-premises converter instead.
123
+ *
124
+ * @default 'https://docx-converter.cke-cs.com/v1/convert'
125
+ */
126
+ converterUrl?: string;
127
+ /**
128
+ * The CKEditor Cloud Services HTML to DOCX Converter [configuration options](https://docx-converter.cke-cs.com/docs#section/Options).
129
+ *
130
+ * **NOTE:** Configuring the plugin is not mandatory.
131
+ *
132
+ * ```ts
133
+ * const exportWordConfig = {
134
+ * converterOptions: {
135
+ * ...
136
+ * }
137
+ * }
138
+ * ```
139
+ *
140
+ * @default `{
141
+ * format: 'A4',
142
+ * margin_top: '1in',
143
+ * margin_bottom: '1in',
144
+ * margin_right: '1in',
145
+ * margin_left: '1in',
146
+ * header: undefined,
147
+ * footer: undefined,
148
+ * comments: undefined,
149
+ * suggestions: undefined,
150
+ * orientation: 'portrait',
151
+ * auto_pagination: true,
152
+ * base_url: undefined,
153
+ * timezone: 'UTC'
154
+ * }`
155
+ */
156
+ converterOptions?: ExportWordConverterOptions;
157
+ /**
158
+ * A function to gather the HTML to be converted to Word.
159
+ *
160
+ * **NOTE:** This option may be useful when the editor does not have a `getData()` method,
161
+ * or if the HTML to be converted should be different than the edited one.
162
+ *
163
+ * ```ts
164
+ * const exportWordConfig = {
165
+ * dataCallback: ( editor ) => {
166
+ * return `
167
+ * <header id="header">${ editor.data.get( { rootName: 'header' } ) }</header>
168
+ * <div id="content">${ editor.data.get( { rootName: 'content' } ) }</div>
169
+ * `;
170
+ * }
171
+ * }
172
+ * ```
173
+ *
174
+ * @default `( editor ) => editor.getData( { pagination: true } )
175
+ *
176
+ * If using the {@glink features/pagination/pagination pagination} feature, the `pagination:true` option inserts additional markers into
177
+ * editor's data. Thanks to that, the Docx converter creates a Word document similar to what is displayed in the editor.
178
+ */
179
+ dataCallback?: (editor: Editor) => string;
180
+ /**
181
+ * A token URL or a token request function. This field is optional and should be used only when a different `tokenUrl` is required for
182
+ * the export to Word feature.
183
+ *
184
+ * **Note:** The token can be disabled with the `false` value provided.
185
+ *
186
+ * See: {@link module:cloud-services/cloudservicesconfig~CloudServicesConfig#tokenUrl}
187
+ */
188
+ tokenUrl?: TokenUrl | false;
189
+ /**
190
+ * The authentication token.
191
+ *
192
+ * See: {@link module:cloud-services/cloudservices~CloudServices#token}
193
+ */
194
+ token?: InitializedToken;
195
+ }
196
+ export type ExportWordConverterOptions = {
197
+ format?: ExportWordConverterFormatOption;
198
+ margin_top?: string;
199
+ margin_bottom?: string;
200
+ margin_right?: string;
201
+ margin_left?: string;
202
+ header?: ExportWordConverterHeaderFooterOption;
203
+ footer?: ExportWordConverterHeaderFooterOption;
204
+ comments?: ExportWordConverterCommentsOption;
205
+ suggestions?: ExportWordConverterSuggestionsOption;
206
+ orientation?: ExportWordConverterOrientationOption;
207
+ auto_pagination?: boolean;
208
+ base_url?: string;
209
+ timezone?: string;
210
+ };
211
+ export type ExportWordConverterFormatOption = 'Letter' | 'Legal' | 'Tabloid' | 'Statement' | 'Executive' | 'A3' | 'A4' | 'A5' | 'A6' | 'B4' | 'B5';
212
+ export type ExportWordConverterOrientationOption = 'portrait' | 'landscape';
213
+ export type ExportWordConverterHeaderFooterOption = Array<{
214
+ html?: string;
215
+ css?: string;
216
+ type?: 'default' | 'even' | 'odd' | 'first';
217
+ }>;
218
+ export type ExportWordConverterCommentsOption = {
219
+ [id: string]: Array<{
220
+ author: string;
221
+ created: Date;
222
+ content?: string;
223
+ is_resolved: boolean;
224
+ }>;
225
+ };
226
+ export type ExportWordConverterSuggestionsOption = {
227
+ [id: string]: {
228
+ author: string;
229
+ created: Date | null;
230
+ };
231
+ };
package/src/exportword.js CHANGED
@@ -20,4 +20,4 @@
20
20
  *
21
21
  *
22
22
  */
23
- import{Plugin as _0x367ff2}from'ckeditor5/src/core';import{ButtonView as _0x243d91,View as _0x3fd3fa,Notification as _0x3d4d1a}from'ckeditor5/src/ui';import _0x1b351 from'./exportwordcommand';import _0x84e6b7 from'../theme/icons/exportword.svg';import'../theme/exportword.css';export default class c extends _0x367ff2{static get['pluginName'](){return'ExportWord';}static get['requires'](){return['CloudServices',_0x3d4d1a];}['init'](){const _0x4f9ddf=this['editor'],t=_0x4f9ddf['t'],_0x565036=_0x4f9ddf['config']['get']('exportWord')||{};_0x4f9ddf['commands']['add']('exportWord',new _0x1b351(_0x4f9ddf)),_0x4f9ddf['ui']['componentFactory']['add']('exportWord',_0x4888a8=>{const _0x42e400=_0x4f9ddf['commands']['get']('exportWord'),_0x30b53f=new _0x243d91(_0x4888a8);_0x30b53f['set']({'label':t('Export\x20to\x20Word'),'icon':_0x84e6b7,'tooltip':!0x0}),_0x30b53f['bind']('isOn','isEnabled')['to'](_0x42e400,'isBusy','isEnabled'),_0x30b53f['extendTemplate']({'attributes':{'class':[_0x30b53f['bindTemplate']['if']('isOn','ck-exportword_status-pending')]}});const _0xc109f3=new _0x3fd3fa();return _0xc109f3['setTemplate']({'tag':'span','attributes':{'class':['ck','ck-exportword__spinner-container']},'children':[{'tag':'span','attributes':{'class':['ck','ck-exportword__spinner']}}]}),_0x30b53f['children']['add'](_0xc109f3),this['listenTo'](_0x30b53f,'execute',()=>{_0x4f9ddf['execute']('exportWord',_0x565036),_0x4f9ddf['editing']['view']['focus']();}),_0x30b53f;});const _0x57a2e1=_0x4f9ddf['plugins']['get']('CloudServices');!0x1===_0x565036['tokenUrl']?this['_token']=null:_0x565036['tokenUrl']?_0x57a2e1['registerTokenUrl'](_0x565036['tokenUrl'])['then'](_0x42e87d=>{this['_token']=_0x42e87d;}):this['_token']=_0x57a2e1['token'];}}
23
+ import{Plugin as _0x2e046d}from'ckeditor5/src/core';import{ButtonView as _0x3a24c8,Notification as _0x4b922e,SpinnerView as _0x10313d}from'ckeditor5/src/ui';import _0x354b10 from'./exportwordcommand';import _0x3a371a from'../theme/icons/exportword.svg';export default class d extends _0x2e046d{static get['pluginName'](){return'ExportWord';}static get['requires'](){return['CloudServices',_0x4b922e];}['init'](){const _0x4dfd3b=this['editor'],t=_0x4dfd3b['t'],_0x238757=_0x4dfd3b['config']['get']('exportWord')||{};_0x4dfd3b['commands']['add']('exportWord',new _0x354b10(_0x4dfd3b)),_0x4dfd3b['ui']['componentFactory']['add']('exportWord',_0x51b8b5=>{const _0x1413b7=_0x4dfd3b['commands']['get']('exportWord'),_0x300ca2=new _0x3a24c8(_0x51b8b5),_0x33bfad=new _0x10313d();return _0x300ca2['set']({'label':t('Export\x20to\x20Word'),'icon':_0x3a371a,'tooltip':!0x0}),_0x300ca2['children']['add'](_0x33bfad),_0x300ca2['bind']('isOn','isEnabled')['to'](_0x1413b7,'isBusy','isEnabled'),_0x33bfad['bind']('isVisible')['to'](_0x1413b7,'isBusy'),_0x300ca2['iconView']['bind']('isVisible')['to'](_0x1413b7,'isBusy',_0x71fa3c=>!_0x71fa3c),this['listenTo'](_0x300ca2,'execute',()=>{_0x4dfd3b['execute']('exportWord',_0x238757),_0x4dfd3b['editing']['view']['focus']();}),_0x300ca2;});const _0xc2337d=_0x4dfd3b['plugins']['get']('CloudServices');!0x1===_0x238757['tokenUrl']?this['_token']=null:_0x238757['tokenUrl']?_0xc2337d['registerTokenUrl'](_0x238757['tokenUrl'])['then'](_0x31c77a=>{this['_token']=_0x31c77a;}):this['_token']=_0xc2337d['token'];}}
@@ -1,36 +1,36 @@
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 export-word/exportwordcommand
7
- * @publicApi
8
- */
9
- import { Command, type Editor } from 'ckeditor5/src/core';
10
- import { type ExportWordConfig } from './exportword';
11
- /**
12
- * The export to Word command.
13
- *
14
- * It takes the editor's HTML and CSS rules from the document and sends them to the HTML to Word converter.
15
- * After processing, the converter will send back a Word file for download.
16
- */
17
- export default class ExportWordCommand extends Command {
18
- /**
19
- * A command state that indicates if the command is currently executing.
20
- *
21
- * @observable
22
- */
23
- isBusy: boolean;
24
- /**
25
- * @inheritDoc
26
- */
27
- constructor(editor: Editor);
28
- /**
29
- * @inheritDoc
30
- */
31
- refresh(): void;
32
- /**
33
- * @inheritDoc
34
- */
35
- execute(options?: ExportWordConfig): Promise<void>;
36
- }
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 export-word/exportwordcommand
7
+ * @publicApi
8
+ */
9
+ import { Command, type Editor } from 'ckeditor5/src/core';
10
+ import { type ExportWordConfig } from './exportword';
11
+ /**
12
+ * The export to Word command.
13
+ *
14
+ * It takes the editor's HTML and CSS rules from the document and sends them to the HTML to Word converter.
15
+ * After processing, the converter will send back a Word file for download.
16
+ */
17
+ export default class ExportWordCommand extends Command {
18
+ /**
19
+ * A command state that indicates if the command is currently executing.
20
+ *
21
+ * @observable
22
+ */
23
+ isBusy: boolean;
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ constructor(editor: Editor);
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ refresh(): void;
32
+ /**
33
+ * @inheritDoc
34
+ */
35
+ execute(options?: ExportWordConfig): Promise<void>;
36
+ }
@@ -20,4 +20,4 @@
20
20
  *
21
21
  *
22
22
  */
23
- import{Command as _0x4e3cec}from'ckeditor5/src/core';import{getStyles as _0x1b8c33,getConverterOptions as _0x2467d1}from'./utils';export default class i extends _0x4e3cec{constructor(_0x2f0f8f){super(_0x2f0f8f),this['set']('isBusy',!0x1),this['affectsData']=!0x1;}['refresh'](){this['isEnabled']=!this['isBusy'],this['value']=this['isBusy']?'pending':void 0x0;}['execute'](_0x51eff2={}){const _0x29b81d=this['editor'],t=_0x29b81d['t'],_0x286ec3=_0x51eff2['converterUrl']||'https://docx-converter.cke-cs.com/v1/convert',_0x4fc401=_0x51eff2['converterOptions']||{},_0x1a4f6e=_0x29b81d['plugins']['get']('ExportWord'),_0x126001=_0x51eff2['token']||_0x1a4f6e['_token'],_0xd450e5=!0x1!==_0x4fc401['auto_pagination'],_0xa2af10=_0x51eff2['dataCallback']||(_0x105385=>_0x105385['data']['get']({'pagination':_0xd450e5}));return this['isBusy']=!0x0,this['refresh'](),_0x1b8c33(_0x51eff2['stylesheets']||['EDITOR_STYLES'])['then'](async _0x398051=>{const _0x71fadb=await _0xa2af10(_0x29b81d),_0x389199={'html':'<div\x20class=\x22ck-content\x22\x20dir=\x22'+_0x29b81d['locale']['contentLanguageDirection']+'\x22>'+_0x71fadb+'</div>','css':_0x398051,'options':{..._0x4fc401,..._0x2467d1(_0x29b81d)}},_0x14e0b1={'method':'POST','headers':{'Content-Type':'application/json','Accept':'application/docx',..._0x126001?{'Authorization':_0x126001['value']}:null},'body':JSON['stringify'](_0x389199)};return window['fetch'](_0x286ec3,_0x14e0b1)['then'](_0x24b713=>{if(0xc8!==_0x24b713['status'])throw _0x24b713;return _0x24b713['blob']();})['then'](_0x2997db=>{const _0x56897b='function'==typeof _0x51eff2['fileName']?_0x51eff2['fileName']():_0x51eff2['fileName'];this['_downloadFile'](_0x2997db,_0x56897b||'document.docx');});})['catch'](_0x1acc8c=>{throw _0x29b81d['plugins']['get']('Notification')['showWarning'](t('An\x20error\x20occurred\x20while\x20generating\x20the\x20Word\x20file.')),_0x1acc8c;})['finally'](()=>{this['isBusy']=!0x1,this['refresh']();});}['_downloadFile'](_0x3c0500,_0x2288c9){const _0x3adc2f=document['createElement']('a');_0x3adc2f['href']=window['URL']['createObjectURL'](_0x3c0500),_0x3adc2f['download']=_0x2288c9,_0x3adc2f['click'](),_0x3adc2f['remove']();}}
23
+ import{Command as _0x3af1ed}from'ckeditor5/src/core';import{getStyles as _0x2860ef,getConverterOptions as _0x1667e6}from'./utils';export default class s extends _0x3af1ed{constructor(_0x56f3fc){super(_0x56f3fc),this['set']('isBusy',!0x1),this['affectsData']=!0x1;}['refresh'](){this['isEnabled']=!this['isBusy'],this['value']=this['isBusy']?'pending':void 0x0;}['execute'](_0x1bde4e={}){const _0x293be3=this['editor'],t=_0x293be3['t'],_0x4619a5=_0x1bde4e['converterUrl']||'https://docx-converter.cke-cs.com/v1/convert',_0x3d190a=_0x1bde4e['converterOptions']||{},_0x25dae4=_0x293be3['plugins']['get']('ExportWord'),_0x381bdb=_0x1bde4e['token']||_0x25dae4['_token'],_0xa41d1c=!0x1!==_0x3d190a['auto_pagination'],_0x2a097a=_0x1bde4e['dataCallback']||(_0x5c599c=>_0x5c599c['data']['get']({'pagination':_0xa41d1c}));return this['isBusy']=!0x0,this['refresh'](),_0x2860ef(_0x1bde4e['stylesheets']||['EDITOR_STYLES'])['then'](async _0x10b38a=>{const _0x43ff7a=await _0x2a097a(_0x293be3),_0x247761={'html':'<div\x20class=\x22ck-content\x22\x20dir=\x22'+_0x293be3['locale']['contentLanguageDirection']+'\x22>'+_0x43ff7a+'</div>','css':_0x10b38a,'options':{..._0x3d190a,..._0x1667e6(_0x293be3)}},_0x446f3a={'method':'POST','headers':{'Content-Type':'application/json','Accept':'application/docx',..._0x381bdb?{'Authorization':_0x381bdb['value']}:null},'body':JSON['stringify'](_0x247761)};return window['fetch'](_0x4619a5,_0x446f3a)['then'](_0xe7acfd=>{if(0xc8!==_0xe7acfd['status'])throw _0xe7acfd;return _0xe7acfd['blob']();})['then'](_0x14bfeb=>{const _0x38b4ef='function'==typeof _0x1bde4e['fileName']?_0x1bde4e['fileName']():_0x1bde4e['fileName'];this['_downloadFile'](_0x14bfeb,_0x38b4ef||'document.docx');});})['catch'](_0x395a82=>{throw _0x293be3['plugins']['get']('Notification')['showWarning'](t('An\x20error\x20occurred\x20while\x20generating\x20the\x20Word\x20file.')),_0x395a82;})['finally'](()=>{this['isBusy']=!0x1,this['refresh']();});}['_downloadFile'](_0x5cf6fc,_0x8f2803){const _0x15c761=document['createElement']('a');_0x15c761['href']=window['URL']['createObjectURL'](_0x5cf6fc),_0x15c761['download']=_0x8f2803,_0x15c761['click'](),_0x15c761['remove']();}}
package/src/index.d.ts CHANGED
@@ -1,10 +1,10 @@
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 export-word
7
- */
8
- export { default as ExportWord, ExportWordConfig } from './exportword';
9
- export type { default as ExportWordCommand } from './exportwordcommand';
10
- 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 export-word
7
+ */
8
+ export { default as ExportWord, type ExportWordConfig } from './exportword';
9
+ export type { default as ExportWordCommand } from './exportwordcommand';
10
+ import './augmentation';