@ckeditor/ckeditor5-export-pdf 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 (63) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/LICENSE.md +4 -4
  3. package/README.md +8 -8
  4. package/build/export-pdf.js +1 -1
  5. package/build/translations/pt-br.js +1 -1
  6. package/lang/translations/af.po +1 -0
  7. package/lang/translations/ar.po +1 -0
  8. package/lang/translations/bg.po +1 -0
  9. package/lang/translations/bn.po +1 -0
  10. package/lang/translations/ca.po +1 -0
  11. package/lang/translations/cs.po +1 -0
  12. package/lang/translations/da.po +1 -0
  13. package/lang/translations/de.po +1 -0
  14. package/lang/translations/el.po +1 -0
  15. package/lang/translations/en-au.po +1 -0
  16. package/lang/translations/en.po +1 -0
  17. package/lang/translations/es-co.po +1 -0
  18. package/lang/translations/es.po +1 -0
  19. package/lang/translations/et.po +1 -0
  20. package/lang/translations/fi.po +1 -0
  21. package/lang/translations/fr.po +1 -0
  22. package/lang/translations/gl.po +1 -0
  23. package/lang/translations/he.po +1 -0
  24. package/lang/translations/hi.po +1 -0
  25. package/lang/translations/hr.po +1 -0
  26. package/lang/translations/hu.po +1 -0
  27. package/lang/translations/id.po +1 -0
  28. package/lang/translations/it.po +1 -0
  29. package/lang/translations/ja.po +1 -0
  30. package/lang/translations/jv.po +1 -0
  31. package/lang/translations/ko.po +1 -0
  32. package/lang/translations/lt.po +1 -0
  33. package/lang/translations/lv.po +1 -0
  34. package/lang/translations/ms.po +1 -0
  35. package/lang/translations/nl.po +1 -0
  36. package/lang/translations/no.po +1 -0
  37. package/lang/translations/pl.po +1 -0
  38. package/lang/translations/pt-br.po +2 -1
  39. package/lang/translations/pt.po +1 -0
  40. package/lang/translations/ro.po +1 -0
  41. package/lang/translations/ru.po +1 -0
  42. package/lang/translations/sk.po +1 -0
  43. package/lang/translations/sr-latn.po +1 -0
  44. package/lang/translations/sr.po +1 -0
  45. package/lang/translations/sv.po +1 -0
  46. package/lang/translations/th.po +1 -0
  47. package/lang/translations/tr.po +1 -0
  48. package/lang/translations/ug.po +1 -0
  49. package/lang/translations/uk.po +1 -0
  50. package/lang/translations/ur.po +1 -0
  51. package/lang/translations/vi.po +1 -0
  52. package/lang/translations/zh-cn.po +1 -0
  53. package/lang/translations/zh.po +1 -0
  54. package/package.json +2 -6
  55. package/src/augmentation.d.ts +21 -21
  56. package/src/exportpdf.d.ts +220 -221
  57. package/src/exportpdf.js +1 -1
  58. package/src/exportpdfcommand.d.ts +39 -39
  59. package/src/exportpdfcommand.js +1 -1
  60. package/src/index.d.ts +10 -10
  61. package/src/utils.d.ts +10 -10
  62. package/src/utils.js +1 -1
  63. package/theme/exportpdf.css +0 -53
@@ -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 { ExportPdfConfig, ExportPdf, ExportPdfCommand } from './index';
6
- declare module '@ckeditor/ckeditor5-core' {
7
- interface EditorConfig {
8
- /**
9
- * The configuration of the {@link module:export-pdf/exportpdf~ExportPdf export to PDF feature}.
10
- *
11
- * Read more in {@link module:export-pdf/exportpdf~ExportPdfConfig}.
12
- */
13
- exportPdf?: ExportPdfConfig;
14
- }
15
- interface PluginsMap {
16
- [ExportPdf.pluginName]: ExportPdf;
17
- }
18
- interface CommandsMap {
19
- exportPdf: ExportPdfCommand;
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 { ExportPdfConfig, ExportPdf, ExportPdfCommand } from './index';
6
+ declare module '@ckeditor/ckeditor5-core' {
7
+ interface EditorConfig {
8
+ /**
9
+ * The configuration of the {@link module:export-pdf/exportpdf~ExportPdf export to PDF feature}.
10
+ *
11
+ * Read more in {@link module:export-pdf/exportpdf~ExportPdfConfig}.
12
+ */
13
+ exportPdf?: ExportPdfConfig;
14
+ }
15
+ interface PluginsMap {
16
+ [ExportPdf.pluginName]: ExportPdf;
17
+ }
18
+ interface CommandsMap {
19
+ exportPdf: ExportPdfCommand;
20
+ }
21
+ }
@@ -1,221 +1,220 @@
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-pdf/exportpdf
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/exportpdf.css';
13
- /**
14
- * The export to PDF feature.
15
- *
16
- * It allows you to generate a PDF file directly from the editor content.
17
- *
18
- * For a detailed overview, check the {@glink features/converters/export-pdf export to PDF} feature documentation.
19
- */
20
- export default class ExportPdf extends Plugin {
21
- /**
22
- * @inheritDoc
23
- */
24
- static get pluginName(): "ExportPdf";
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 PDF feature. It is used by the PDF export features from the `@ckeditor/ckeditor5-export-pdf` package.
36
- *
37
- * ```ts
38
- * ClassicEditor
39
- * .create( editorElement, {
40
- * exportPdf: ... // Export to PDF feature options.
41
- * } )
42
- * .then( ... )
43
- * .catch( ... );
44
- * ```
45
- *
46
- * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
47
- */
48
- export interface ExportPdfConfig {
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 exportPdfConfig = {
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 PDF 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 exportPdfConfig = {
68
- * stylesheets: [ './path/to/custom-editor-styles.css' ]
69
- * }
70
- * ```
71
- *
72
- * **Web fonts:** If you want to {@glink features/converters/export-pdf#providing-web-font-styles use web fonts} in your PDF document,
73
- * you should provide a path to the file containing the web font declaration before the `'EDITOR_STYLES'` token:
74
- *
75
- * ```ts
76
- * const exportPdfConfig = {
77
- * stylesheets: [
78
- * './path/to/fonts.css',
79
- * 'EDITOR_STYLES'
80
- * ]
81
- * }
82
- * ```
83
- *
84
- * **Web fonts and custom styling:** For more advanced styling, your configuration should look like this:
85
- *
86
- * ```ts
87
- * const exportPdfConfig = {
88
- * stylesheets: [
89
- * './path/to/fonts.css',
90
- * 'EDITOR_STYLES',
91
- * './path/to/custom-styles.css'
92
- * ]
93
- * }
94
- * ```
95
- *
96
- * @default `[ 'EDITOR_STYLES' ]`
97
- */
98
- stylesheets?: Array<string>;
99
- /**
100
- * The name of the generated PDF file.
101
- *
102
- * ```ts
103
- * // Static file name.
104
- * const exportPdfConfig = {
105
- * fileName: 'my-document.pdf'
106
- * }
107
- *
108
- * // Dynamic file name.
109
- * const exportPdfConfig = {
110
- * fileName: () => {
111
- * const articleTitle = document.querySelector( '#title' );
112
- *
113
- * return `${ articleTitle.value }.pdf`;
114
- * }
115
- * }
116
- * ```
117
- *
118
- * **NOTE:** The file name must contain the `.pdf` extension.
119
- * Otherwise your operating system or device may have trouble identifying the file type.
120
- *
121
- * @default 'document.pdf'
122
- */
123
- fileName?: string | (() => string);
124
- /**
125
- * A URL to the HTML to PDF converter.
126
- *
127
- * ```ts
128
- * const exportPdfConfig = {
129
- * converterUrl: 'https://myconverter.com/v1/'
130
- * }
131
- * ```
132
- *
133
- * **NOTE:** The plugin uses the default HTML to PDF converter delivered by CKEditor Cloud Services.
134
- * You can provide a URL to an on-premises converter instead.
135
- *
136
- * @default 'https://pdf-converter.cke-cs.com/v1/convert'
137
- */
138
- converterUrl?: string;
139
- /**
140
- * The HTML to PDF converter options.
141
- *
142
- * **NOTE:** Configuring the plugin is not mandatory but it is highly recommended,
143
- * especially if you want to get the most accurate results when generating the PDF file.
144
- * To learn more, please check the [HTML to PDF converter configuration](https://pdf-converter.cke-cs.com/docs).
145
- *
146
- * ```ts
147
- * const exportPdfConfig = {
148
- * converterOptions: {
149
- * ...
150
- * }
151
- * }
152
- * ```
153
- *
154
- * @default `{
155
- * format: 'A4',
156
- * margin_top: '0',
157
- * margin_bottom: '0',
158
- * margin_right: '0',
159
- * margin_left: '0',
160
- * page_orientation: 'portrait',
161
- * header_html: undefined,
162
- * footer_html: undefined,
163
- * header_and_footer_css: undefined,
164
- * wait_for_network: true,
165
- * wait_time: 0
166
- * }`
167
- */
168
- converterOptions?: ExportPdfConverterOptions;
169
- /**
170
- * A function to gather the HTML to be converted to PDF.
171
- *
172
- * **NOTE:** This option may be useful when the editor does not have `getData()` method,
173
- * or if the HTML to be converted should be different than the edited one.
174
- *
175
- * ```ts
176
- * const exportPdfConfig = {
177
- * dataCallback: ( editor: Editor ) => {
178
- * return `
179
- * <header id="header">${ editor.data.get( { rootName: 'header' } ) }</header>
180
- * <div id="content">${ editor.data.get( { rootName: 'content' } ) }</div>
181
- * `;
182
- * }
183
- * }
184
- * ```
185
- *
186
- * @default `( editor: Editor ) => editor.getData()`
187
- */
188
- dataCallback?: (editor: Editor) => string;
189
- /**
190
- * A token URL or a token request function. This field is optional and should be used only when a different `tokenUrl` is required for
191
- * the export to PDF feature.
192
- *
193
- * **Note:** The token can be disabled with the `false` value provided.
194
- *
195
- * See: {@link module:cloud-services/cloudservicesconfig~CloudServicesConfig#tokenUrl}
196
- */
197
- tokenUrl?: TokenUrl | false;
198
- /**
199
- * The authentication token.
200
- *
201
- * See: {@link module:cloud-services/cloudservices~CloudServices#token}
202
- */
203
- token?: InitializedToken;
204
- /**
205
- * The application unique identifier.
206
- */
207
- appID?: string;
208
- }
209
- export type ExportPdfConverterOptions = {
210
- format?: 'Letter' | 'Legal' | 'Tabloid' | 'Ledger' | 'A0' | 'A1' | 'A2' | 'A3' | 'A4' | 'A5' | 'A6';
211
- margin_top?: string;
212
- margin_bottom?: string;
213
- margin_right?: string;
214
- margin_left?: string;
215
- header_html?: string;
216
- footer_html?: string;
217
- header_and_footer_css?: string;
218
- page_orientation?: 'portrait' | 'landscape';
219
- wait_for_network?: boolean;
220
- wait_time?: number;
221
- };
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-pdf/exportpdf
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 PDF feature.
14
+ *
15
+ * It allows you to generate a PDF file directly from the editor content.
16
+ *
17
+ * For a detailed overview, check the {@glink features/converters/export-pdf export to PDF} feature documentation.
18
+ */
19
+ export default class ExportPdf extends Plugin {
20
+ /**
21
+ * @inheritDoc
22
+ */
23
+ static get pluginName(): "ExportPdf";
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 PDF feature. It is used by the PDF export features from the `@ckeditor/ckeditor5-export-pdf` package.
35
+ *
36
+ * ```ts
37
+ * ClassicEditor
38
+ * .create( editorElement, {
39
+ * exportPdf: ... // Export to PDF feature options.
40
+ * } )
41
+ * .then( ... )
42
+ * .catch( ... );
43
+ * ```
44
+ *
45
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
46
+ */
47
+ export interface ExportPdfConfig {
48
+ /**
49
+ * Paths to the `.css` files containing additional styling for the editor's content (**the order of provided items matters**).
50
+ *
51
+ * ```ts
52
+ * const exportPdfConfig = {
53
+ * stylesheets: [ './path/to/custom-style.css' ]
54
+ * }
55
+ * ```
56
+ *
57
+ * **NOTE:** If `stylesheets` are not provided, the plugin will sent only
58
+ * {@glink installation/advanced/content-styles#the-full-list-of-content-styles the default editor content styles} to the converter.
59
+ *
60
+ * **Default editor's content styles**:
61
+ * {@glink installation/advanced/content-styles#the-full-list-of-content-styles The default editor content styles}
62
+ * are applied to the generated PDF thanks to the 'EDITOR_STYLES' token, which is provided to the `stylesheets` by default.
63
+ * If you don't want them to be applied, you have to omit the token:
64
+ *
65
+ * ```ts
66
+ * const exportPdfConfig = {
67
+ * stylesheets: [ './path/to/custom-editor-styles.css' ]
68
+ * }
69
+ * ```
70
+ *
71
+ * **Web fonts:** If you want to {@glink features/converters/export-pdf#providing-web-font-styles use web fonts} in your PDF document,
72
+ * you should provide a path to the file containing the web font declaration before the `'EDITOR_STYLES'` token:
73
+ *
74
+ * ```ts
75
+ * const exportPdfConfig = {
76
+ * stylesheets: [
77
+ * './path/to/fonts.css',
78
+ * 'EDITOR_STYLES'
79
+ * ]
80
+ * }
81
+ * ```
82
+ *
83
+ * **Web fonts and custom styling:** For more advanced styling, your configuration should look like this:
84
+ *
85
+ * ```ts
86
+ * const exportPdfConfig = {
87
+ * stylesheets: [
88
+ * './path/to/fonts.css',
89
+ * 'EDITOR_STYLES',
90
+ * './path/to/custom-styles.css'
91
+ * ]
92
+ * }
93
+ * ```
94
+ *
95
+ * @default `[ 'EDITOR_STYLES' ]`
96
+ */
97
+ stylesheets?: Array<string>;
98
+ /**
99
+ * The name of the generated PDF file.
100
+ *
101
+ * ```ts
102
+ * // Static file name.
103
+ * const exportPdfConfig = {
104
+ * fileName: 'my-document.pdf'
105
+ * }
106
+ *
107
+ * // Dynamic file name.
108
+ * const exportPdfConfig = {
109
+ * fileName: () => {
110
+ * const articleTitle = document.querySelector( '#title' );
111
+ *
112
+ * return `${ articleTitle.value }.pdf`;
113
+ * }
114
+ * }
115
+ * ```
116
+ *
117
+ * **NOTE:** The file name must contain the `.pdf` extension.
118
+ * Otherwise your operating system or device may have trouble identifying the file type.
119
+ *
120
+ * @default 'document.pdf'
121
+ */
122
+ fileName?: string | (() => string);
123
+ /**
124
+ * A URL to the HTML to PDF converter.
125
+ *
126
+ * ```ts
127
+ * const exportPdfConfig = {
128
+ * converterUrl: 'https://myconverter.com/v1/'
129
+ * }
130
+ * ```
131
+ *
132
+ * **NOTE:** The plugin uses the default HTML to PDF converter delivered by CKEditor Cloud Services.
133
+ * You can provide a URL to an on-premises converter instead.
134
+ *
135
+ * @default 'https://pdf-converter.cke-cs.com/v1/convert'
136
+ */
137
+ converterUrl?: string;
138
+ /**
139
+ * The HTML to PDF converter options.
140
+ *
141
+ * **NOTE:** Configuring the plugin is not mandatory but it is highly recommended,
142
+ * especially if you want to get the most accurate results when generating the PDF file.
143
+ * To learn more, please check the [HTML to PDF converter configuration](https://pdf-converter.cke-cs.com/docs).
144
+ *
145
+ * ```ts
146
+ * const exportPdfConfig = {
147
+ * converterOptions: {
148
+ * ...
149
+ * }
150
+ * }
151
+ * ```
152
+ *
153
+ * @default `{
154
+ * format: 'A4',
155
+ * margin_top: '0',
156
+ * margin_bottom: '0',
157
+ * margin_right: '0',
158
+ * margin_left: '0',
159
+ * page_orientation: 'portrait',
160
+ * header_html: undefined,
161
+ * footer_html: undefined,
162
+ * header_and_footer_css: undefined,
163
+ * wait_for_network: true,
164
+ * wait_time: 0
165
+ * }`
166
+ */
167
+ converterOptions?: ExportPdfConverterOptions;
168
+ /**
169
+ * A function to gather the HTML to be converted to PDF.
170
+ *
171
+ * **NOTE:** This option may be useful when the editor does not have `getData()` method,
172
+ * or if the HTML to be converted should be different than the edited one.
173
+ *
174
+ * ```ts
175
+ * const exportPdfConfig = {
176
+ * dataCallback: ( editor: Editor ) => {
177
+ * return `
178
+ * <header id="header">${ editor.data.get( { rootName: 'header' } ) }</header>
179
+ * <div id="content">${ editor.data.get( { rootName: 'content' } ) }</div>
180
+ * `;
181
+ * }
182
+ * }
183
+ * ```
184
+ *
185
+ * @default `( editor: Editor ) => editor.getData()`
186
+ */
187
+ dataCallback?: (editor: Editor) => string;
188
+ /**
189
+ * A token URL or a token request function. This field is optional and should be used only when a different `tokenUrl` is required for
190
+ * the export to PDF feature.
191
+ *
192
+ * **Note:** The token can be disabled with the `false` value provided.
193
+ *
194
+ * See: {@link module:cloud-services/cloudservicesconfig~CloudServicesConfig#tokenUrl}
195
+ */
196
+ tokenUrl?: TokenUrl | false;
197
+ /**
198
+ * The authentication token.
199
+ *
200
+ * See: {@link module:cloud-services/cloudservices~CloudServices#token}
201
+ */
202
+ token?: InitializedToken;
203
+ /**
204
+ * The application unique identifier.
205
+ */
206
+ appID?: string;
207
+ }
208
+ export type ExportPdfConverterOptions = {
209
+ format?: 'Letter' | 'Legal' | 'Tabloid' | 'Ledger' | 'A0' | 'A1' | 'A2' | 'A3' | 'A4' | 'A5' | 'A6';
210
+ margin_top?: string;
211
+ margin_bottom?: string;
212
+ margin_right?: string;
213
+ margin_left?: string;
214
+ header_html?: string;
215
+ footer_html?: string;
216
+ header_and_footer_css?: string;
217
+ page_orientation?: 'portrait' | 'landscape';
218
+ wait_for_network?: boolean;
219
+ wait_time?: number;
220
+ };
package/src/exportpdf.js CHANGED
@@ -20,4 +20,4 @@
20
20
  *
21
21
  *
22
22
  */
23
- import{Plugin as _0x264deb}from'ckeditor5/src/core';import{ButtonView as _0xdffc9a,View as _0x5c7769,Notification as _0x7f2264}from'ckeditor5/src/ui';import _0x2dc216 from'./exportpdfcommand';import _0x2c036f from'../theme/icons/exportpdf.svg';import'../theme/exportpdf.css';export default class p extends _0x264deb{static get['pluginName'](){return'ExportPdf';}static get['requires'](){return['CloudServices',_0x7f2264];}['init'](){const _0x4c9aee=this['editor'],t=_0x4c9aee['t'],_0x320129=_0x4c9aee['config']['get']('exportPdf')||{};_0x4c9aee['commands']['add']('exportPdf',new _0x2dc216(_0x4c9aee)),_0x4c9aee['ui']['componentFactory']['add']('exportPdf',_0x377b4c=>{const _0x5cbaf7=_0x4c9aee['commands']['get']('exportPdf'),_0x1c8938=new _0xdffc9a(_0x377b4c);_0x1c8938['set']({'label':t('Export\x20to\x20PDF'),'icon':_0x2c036f,'tooltip':!0x0}),_0x1c8938['bind']('isOn','isEnabled')['to'](_0x5cbaf7,'isBusy','isEnabled'),_0x1c8938['extendTemplate']({'attributes':{'class':[_0x1c8938['bindTemplate']['if']('isOn','ck-exportpdf_status-pending')]}});const _0x103a87=new _0x5c7769();return _0x103a87['setTemplate']({'tag':'span','attributes':{'class':['ck','ck-exportpdf__spinner-container']},'children':[{'tag':'span','attributes':{'class':['ck','ck-exportpdf__spinner']}}]}),_0x1c8938['children']['add'](_0x103a87),this['listenTo'](_0x1c8938,'execute',()=>{_0x4c9aee['execute']('exportPdf',_0x320129),_0x4c9aee['editing']['view']['focus']();}),_0x1c8938;});const _0x6fde34=_0x4c9aee['plugins']['get']('CloudServices');!0x1===_0x320129['tokenUrl']?this['_token']=null:_0x320129['tokenUrl']?_0x6fde34['registerTokenUrl'](_0x320129['tokenUrl'])['then'](_0x2d54f3=>{this['_token']=_0x2d54f3;}):this['_token']=_0x6fde34['token'];}}
23
+ import{Plugin as _0x4045cb}from'ckeditor5/src/core';import{ButtonView as _0xce2224,Notification as _0x49a1fa,SpinnerView as _0xad3e32}from'ckeditor5/src/ui';import _0x46266d from'./exportpdfcommand';import _0x1e7b2d from'../theme/icons/exportpdf.svg';export default class p extends _0x4045cb{static get['pluginName'](){return'ExportPdf';}static get['requires'](){return['CloudServices',_0x49a1fa];}['init'](){const _0x46ad9d=this['editor'],t=_0x46ad9d['t'],_0x1a0d18=_0x46ad9d['config']['get']('exportPdf')||{};_0x46ad9d['commands']['add']('exportPdf',new _0x46266d(_0x46ad9d)),_0x46ad9d['ui']['componentFactory']['add']('exportPdf',_0x3cfb18=>{const _0x5cfb58=_0x46ad9d['commands']['get']('exportPdf'),_0x21cc56=new _0xce2224(_0x3cfb18),_0x25fbaa=new _0xad3e32();return _0x21cc56['set']({'label':t('Export\x20to\x20PDF'),'icon':_0x1e7b2d,'tooltip':!0x0}),_0x21cc56['children']['add'](_0x25fbaa),_0x21cc56['bind']('isOn','isEnabled')['to'](_0x5cfb58,'isBusy','isEnabled'),_0x25fbaa['bind']('isVisible')['to'](_0x5cfb58,'isBusy'),_0x21cc56['iconView']['bind']('isVisible')['to'](_0x5cfb58,'isBusy',_0xd4cee7=>!_0xd4cee7),this['listenTo'](_0x21cc56,'execute',()=>{_0x46ad9d['execute']('exportPdf',_0x1a0d18),_0x46ad9d['editing']['view']['focus']();}),_0x21cc56;});const _0x52b493=_0x46ad9d['plugins']['get']('CloudServices');!0x1===_0x1a0d18['tokenUrl']?this['_token']=null:_0x1a0d18['tokenUrl']?_0x52b493['registerTokenUrl'](_0x1a0d18['tokenUrl'])['then'](_0x5b3386=>{this['_token']=_0x5b3386;}):this['_token']=_0x52b493['token'];}}
@@ -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 export-pdf/exportpdfcommand
7
- * @publicApi
8
- */
9
- import { Command, type Editor } from 'ckeditor5/src/core';
10
- import { type ExportPdfConfig } from './exportpdf';
11
- /**
12
- * The export to PDF command.
13
- *
14
- * It takes the editor's HTML and CSS rules from the document and sends them to the HTML to PDF converter.
15
- * After processing, the converter will send back a PDF file for download.
16
- */
17
- export default class ExportPdfCommand 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
- * Executes the command.
34
- *
35
- * @fires execute
36
- * @param options Options for the executed command.
37
- */
38
- execute(options?: ExportPdfConfig): Promise<void>;
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 export-pdf/exportpdfcommand
7
+ * @publicApi
8
+ */
9
+ import { Command, type Editor } from 'ckeditor5/src/core';
10
+ import { type ExportPdfConfig } from './exportpdf';
11
+ /**
12
+ * The export to PDF command.
13
+ *
14
+ * It takes the editor's HTML and CSS rules from the document and sends them to the HTML to PDF converter.
15
+ * After processing, the converter will send back a PDF file for download.
16
+ */
17
+ export default class ExportPdfCommand 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
+ * Executes the command.
34
+ *
35
+ * @fires execute
36
+ * @param options Options for the executed command.
37
+ */
38
+ execute(options?: ExportPdfConfig): Promise<void>;
39
+ }
@@ -20,4 +20,4 @@
20
20
  *
21
21
  *
22
22
  */
23
- import{Command as _0x3ae896}from'ckeditor5/src/core';import{getStyles as _0x5b8ef1}from'./utils';export default class i extends _0x3ae896{constructor(_0x171caf){super(_0x171caf),this['set']('isBusy',!0x1),this['affectsData']=!0x1;}['refresh'](){this['isEnabled']=!this['isBusy'],this['value']=this['isBusy']?'pending':void 0x0;}['execute'](_0x3b7732={}){const _0x3c9853=this['editor'],t=_0x3c9853['t'],_0x58e7b9=_0x3b7732['converterUrl']||'https://pdf-converter.cke-cs.com/v1/convert/',_0x166b48=_0x3b7732['dataCallback']||(_0xb67f4=>_0xb67f4['data']['get']()),_0x21c883=_0x3c9853['plugins']['get']('ExportPdf'),_0x1a1f1b=_0x3b7732['token']||_0x21c883['_token'];return this['isBusy']=!0x0,this['refresh'](),_0x5b8ef1(_0x3b7732['stylesheets']||['EDITOR_STYLES'])['then'](async _0x1c9b7e=>{const _0x5373ac={'html':'<html>\x0a\x09\x09\x09\x09\x09\x09<head>\x0a\x09\x09\x09\x09\x09\x09\x09<title>CKEditor\x205\x20PDF\x20document</title>\x0a\x09\x09\x09\x09\x09\x09\x09<meta\x20charset=\x22utf-8\x22>\x0a\x09\x09\x09\x09\x09\x09</head>\x0a\x09\x09\x09\x09\x09\x09<body>\x0a\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22ck-content\x22\x20dir=\x22'+_0x3c9853['locale']['contentLanguageDirection']+'\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09'+await _0x166b48(_0x3c9853)+'\x0a\x09\x09\x09\x09\x09\x09\x09</div>\x0a\x09\x09\x09\x09\x09\x09</body>\x0a\x09\x09\x09\x09\x09</html>','css':_0x1c9b7e,'options':_0x3b7732['converterOptions']},_0x3d58d0={'method':'POST','headers':{'Content-Type':'application/json','Accept':'application/pdf',..._0x1a1f1b?{'Authorization':_0x1a1f1b['value']}:null,'x-cs-app-id':_0x3b7732['appID']||'cke5'},'body':JSON['stringify'](_0x5373ac)};return window['fetch'](_0x58e7b9,_0x3d58d0)['then'](_0x3b55ef=>{if(0xc8!==_0x3b55ef['status'])throw _0x3b55ef;return _0x3b55ef['blob']();})['then'](_0x4586d1=>{const _0x394e6c='function'==typeof _0x3b7732['fileName']?_0x3b7732['fileName']():_0x3b7732['fileName'];this['_downloadFile'](_0x4586d1,_0x394e6c||'document.pdf');});})['catch'](_0x1046a1=>{throw _0x3c9853['plugins']['get']('Notification')['showWarning'](t('An\x20error\x20occurred\x20while\x20generating\x20the\x20PDF.')),_0x1046a1;})['finally'](()=>{this['isBusy']=!0x1,this['refresh']();});}['_downloadFile'](_0x5d5b4d,_0x122f07){const _0xd7609e=document['createElement']('a');_0xd7609e['href']=window['URL']['createObjectURL'](_0x5d5b4d),_0xd7609e['download']=_0x122f07,_0xd7609e['click'](),_0xd7609e['remove']();}}
23
+ import{Command as _0x3b6731}from'ckeditor5/src/core';import{getStyles as _0x28cc0d}from'./utils';export default class o extends _0x3b6731{constructor(_0x62a028){super(_0x62a028),this['set']('isBusy',!0x1),this['affectsData']=!0x1;}['refresh'](){this['isEnabled']=!this['isBusy'],this['value']=this['isBusy']?'pending':void 0x0;}['execute'](_0x5783a6={}){const _0x20e59b=this['editor'],t=_0x20e59b['t'],_0x3ba475=_0x5783a6['converterUrl']||'https://pdf-converter.cke-cs.com/v1/convert/',_0x3d247f=_0x5783a6['dataCallback']||(_0x5d484c=>_0x5d484c['data']['get']()),_0xdba8dc=_0x20e59b['plugins']['get']('ExportPdf'),_0x572e72=_0x5783a6['token']||_0xdba8dc['_token'];return this['isBusy']=!0x0,this['refresh'](),_0x28cc0d(_0x5783a6['stylesheets']||['EDITOR_STYLES'])['then'](async _0x54dabb=>{const _0xe1522d={'html':'<html>\x0a\x09\x09\x09\x09\x09\x09<head>\x0a\x09\x09\x09\x09\x09\x09\x09<title>CKEditor\x205\x20PDF\x20document</title>\x0a\x09\x09\x09\x09\x09\x09\x09<meta\x20charset=\x22utf-8\x22>\x0a\x09\x09\x09\x09\x09\x09</head>\x0a\x09\x09\x09\x09\x09\x09<body>\x0a\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22ck-content\x22\x20dir=\x22'+_0x20e59b['locale']['contentLanguageDirection']+'\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09'+await _0x3d247f(_0x20e59b)+'\x0a\x09\x09\x09\x09\x09\x09\x09</div>\x0a\x09\x09\x09\x09\x09\x09</body>\x0a\x09\x09\x09\x09\x09</html>','css':_0x54dabb,'options':_0x5783a6['converterOptions']},_0x5256d3={'method':'POST','headers':{'Content-Type':'application/json','Accept':'application/pdf',..._0x572e72?{'Authorization':_0x572e72['value']}:null,'x-cs-app-id':_0x5783a6['appID']||'cke5'},'body':JSON['stringify'](_0xe1522d)};return window['fetch'](_0x3ba475,_0x5256d3)['then'](_0x42ab66=>{if(0xc8!==_0x42ab66['status'])throw _0x42ab66;return _0x42ab66['blob']();})['then'](_0x314efc=>{const _0x1b9ee9='function'==typeof _0x5783a6['fileName']?_0x5783a6['fileName']():_0x5783a6['fileName'];this['_downloadFile'](_0x314efc,_0x1b9ee9||'document.pdf');});})['catch'](_0x39acf8=>{throw _0x20e59b['plugins']['get']('Notification')['showWarning'](t('An\x20error\x20occurred\x20while\x20generating\x20the\x20PDF.')),_0x39acf8;})['finally'](()=>{this['isBusy']=!0x1,this['refresh']();});}['_downloadFile'](_0x22ce7b,_0x214d66){const _0x49fb72=document['createElement']('a');_0x49fb72['href']=window['URL']['createObjectURL'](_0x22ce7b),_0x49fb72['download']=_0x214d66,_0x49fb72['click'](),_0x49fb72['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-pdf
7
- */
8
- export { default as ExportPdf, type ExportPdfConfig } from './exportpdf';
9
- export type { default as ExportPdfCommand } from './exportpdfcommand';
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-pdf
7
+ */
8
+ export { default as ExportPdf, type ExportPdfConfig } from './exportpdf';
9
+ export type { default as ExportPdfCommand } from './exportpdfcommand';
10
+ import './augmentation';