@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.
- package/CHANGELOG.md +1 -1
- package/LICENSE.md +4 -4
- package/README.md +8 -8
- package/build/export-word.js +2 -2
- package/lang/translations/ar.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/jv.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/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/tr.po +1 -0
- package/lang/translations/ug.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 +2 -6
- package/src/augmentation.d.ts +21 -21
- package/src/exportword.d.ts +231 -232
- package/src/exportword.js +1 -1
- package/src/exportwordcommand.d.ts +36 -36
- package/src/exportwordcommand.js +1 -1
- package/src/index.d.ts +10 -10
- package/src/utils.d.ts +36 -36
- package/src/utils.js +1 -1
- package/theme/exportword.css +0 -49
package/src/augmentation.d.ts
CHANGED
|
@@ -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
|
+
}
|
package/src/exportword.d.ts
CHANGED
|
@@ -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
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* .
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* '
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* <
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
export type
|
|
213
|
-
export type
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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
|
|
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
|
+
}
|
package/src/exportwordcommand.js
CHANGED
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
import{Command as
|
|
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';
|