@ckeditor/ckeditor5-export-word 40.0.0 → 40.1.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/LICENSE.md CHANGED
@@ -2,7 +2,7 @@ Software License Agreement
2
2
  ==========================
3
3
 
4
4
  **CKEditor&nbsp;5 export to Docs feature** (https://ckeditor.com/ckeditor-5/)<br>
5
- Copyright (c) 2003-2023, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
5
+ Copyright (c) 20032023, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
6
6
 
7
7
  CKEditor&nbsp;5 export to Word feature is licensed under a commercial license and is protected by copyright law.
8
8
  For more details about available licensing options please contact us at sales@cksource.com.
@@ -15,4 +15,4 @@ Where not otherwise indicated, all CKEditor&nbsp;5 export to Word feature conten
15
15
  Trademarks
16
16
  ----------
17
17
 
18
- **CKEditor** is a trademark of [CKSource Holding sp. z o.o.](https://cksource.com) All other brand and product names are trademarks, registered trademarks or service marks of their respective holders.
18
+ **CKEditor** is a trademark of [CKSource Holding sp. z o.o.](https://cksource.com) All other brand and product names are trademarks, registered trademarks, or service marks of their respective holders.
@@ -1,5 +1,5 @@
1
- !function(t){const e=t.en=t.en||{};e.dictionary=Object.assign(e.dictionary||{},{"An error occurred while generating the Word file.":"An error occurred while generating the Word file.","Export to Word":"Export to Word"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),
1
+ !function(e){const t=e.en=e.en||{};t.dictionary=Object.assign(t.dictionary||{},{"An error occurred while generating the Word file.":"An error occurred while generating the Word file.","Export to Word":"Export to Word"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),
2
2
  /*!
3
3
  * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
4
4
  * For licensing, see LICENSE.md.
5
- */(()=>{var t={704:(t,e,o)=>{t.exports=o(79)("./src/core.js")},273:(t,e,o)=>{t.exports=o(79)("./src/ui.js")},79:t=>{"use strict";t.exports=CKEditor5.dll}},e={};function o(n){var r=e[n];if(void 0!==r)return r.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,o),i.exports}o.d=(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{"use strict";o.r(n),o.d(n,{ExportWord:()=>u});var t=o(704),e=o(273);const r=["name","text","content",":root","all","TrackChanges","isResolved","Users","comments","styleSheets","timeZone","plugins","has","The editor stylesheet could not be found in the document. Check your webpack config – style-loader should use data-cke=true attribute for the editor stylesheet.","createdAt",".ck-content","resolvedOptions","getCommentThreads","warn","suggestions","cssText","CommentsRepository","from","push","trim","indexOf","join","DateTimeFormat","author","fetch","timezone","ownerNode","keys","length","get","then","authorId"];var i,s;i=r,s=355,function(t){for(;--t;)i.push(i.shift())}(++s);const c=function(t,e){return r[t-=0]};function a(){const t=[],e=[];for(const o of Array[c("0x0")](document[c("0x18")]))if(o[c("0x9")].hasAttribute("data-cke"))for(const n of Array.from(o.cssRules))-1!==n[c("0x23")][c("0x3")](c("0x1e"))?t[c("0x1")](n[c("0x23")]):-1!==n[c("0x23")].indexOf(c("0x12"))&&e[c("0x1")](n[c("0x23")]);return t.length||console[c("0x21")](c("0x1c")),[...e,...t][c("0x4")](" ")[c("0x2")]()}function d(t){const e=t.plugins[c("0x1b")](c("0x16")),o=t[c("0x1a")].has(c("0x24")),n=t[c("0x1a")].has(c("0x14")),r={};if(e&&o){const e=function(t){const e={};if(!t[c("0xb")])return e;for(const o of t)o[c("0x17")].map((t=>{void 0===e[o.id]&&(e[o.id]=[]),e[o.id][c("0x1")]({author:t[c("0x6")][c("0xf")],content:t[c("0x11")],created:t[c("0x1d")],is_resolved:o[c("0x15")]})}));return e}(t[c("0x1a")][c("0xc")](c("0x24"))[c("0x20")]({skipNotAttached:!0,skipEmpty:!0}));Object[c("0xa")](e)[c("0xb")]&&(r.comments=e)}if(e&&n){const e=t[c("0x1a")].get(c("0x14")),o=t[c("0x1a")].get("Users"),n=function(t,e){const o={};if(!t[c("0xb")]||!e[c("0xb")])return o;for(const n of t)o[n.id]={author:e.get(n[c("0xe")]).name,created:n.createdAt};return o}(e.getSuggestions({toJSON:!0}),o.users);Object.keys(n).length&&(r[c("0x22")]=n)}return(r[c("0x22")]||r[c("0x17")])&&(r[c("0x8")]=(new(Intl[c("0x5")]))[c("0x1f")]()[c("0x19")]),r}class l extends t.Command{constructor(t){super(t),this.set("isBusy",!1),this.affectsData=!1}refresh(){this.isEnabled=!this.isBusy,this.value=this.isBusy?"pending":void 0}execute(t={}){const e=this.editor,o=e.t,n=t.converterUrl||"https://docx-converter.cke-cs.com/v1/convert",r=t.converterOptions||{},i=e.plugins.get("ExportWord"),s=t.token||i._token,l=!1!==r.auto_pagination,u=t.dataCallback||(t=>t.data.get({pagination:l}));return this.isBusy=!0,this.refresh(),function(t){if(!t)return new Promise((t=>t("")));const e=[];for(const o of t)"EDITOR_STYLES"!==o?e[c("0x1")](window[c("0x7")](o)[c("0xd")]((t=>t[c("0x10")]()))):e[c("0x1")](a());return Promise[c("0x13")](e)[c("0xd")]((t=>t.join(" ")[c("0x2")]()))}(t.stylesheets||["EDITOR_STYLES"]).then((async o=>{const i=await u(e),c={html:'<div class="ck-content" dir="'+e.locale.contentLanguageDirection+'">'+i+"</div>",css:o,options:{...r,...d(e)}},a={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/docx",...s?{Authorization:s.value}:null},body:JSON.stringify(c)};return window.fetch(n,a).then((t=>{if(200!==t.status)throw t;return t.blob()})).then((e=>{const o="function"==typeof t.fileName?t.fileName():t.fileName;this._downloadFile(e,o||"document.docx")}))})).catch((t=>{throw e.plugins.get("Notification").showWarning(o("An error occurred while generating the Word file.")),t})).finally((()=>{this.isBusy=!1,this.refresh()}))}_downloadFile(t,e){const o=document.createElement("a");o.href=window.URL.createObjectURL(t),o.download=e,o.click(),o.remove()}}class u extends t.Plugin{static get pluginName(){return"ExportWord"}static get requires(){return["CloudServices",e.Notification]}init(){const t=this.editor,o=t.t,n=t.config.get("exportWord")||{};t.commands.add("exportWord",new l(t)),t.ui.componentFactory.add("exportWord",(r=>{const i=t.commands.get("exportWord"),s=new e.ButtonView(r),c=new e.SpinnerView;return s.set({label:o("Export to Word"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M17.826 16.843a.75.75 0 0 0-1.152-.96L15.5 17.29V12H14v5.29l-1.174-1.408a.75.75 0 0 0-1.152.96l2.346 2.816a.95.95 0 0 0 1.46 0l2.346-2.815Z"/><path d="m14 0 5 4.5v9.741a2.737 2.737 0 0 0-1.5-.617V6.5h-5v-5h-8v3H3V0h11Zm0 2v3h3.3L14 2Z"/><path d="M3 17.5h6.746c.1.22.23.429.391.623l.731.877H3v-1.5Z"/><path d="M8.5 6a1.5 1.5 0 0 1 1.493 1.356L10 7.5v7a1.5 1.5 0 0 1-1.356 1.493L8.5 16h-7a1.5 1.5 0 0 1-1.493-1.356L0 14.5v-7a1.5 1.5 0 0 1 1.356-1.493L1.5 6h7ZM7.483 8.795l-.042.088-.986 2.534-.947-2.528-.043-.092a.601.601 0 0 0-1.042.008l-.042.093-.883 2.465-.937-2.475-.042-.089a.6.6 0 0 0-1.107.42l.027.093 1.514 4 .044.092a.6.6 0 0 0 1.041-.01l.041-.092.88-2.458.925 2.467.046.096a.6.6 0 0 0 1.032 0l.043-.09 1.554-4 .028-.093a.6.6 0 0 0-1.104-.43v.001Z"/></svg>\n',tooltip:!0}),s.children.add(c),s.bind("isOn","isEnabled").to(i,"isBusy","isEnabled"),c.bind("isVisible").to(i,"isBusy"),s.iconView.bind("isVisible").to(i,"isBusy",(t=>!t)),this.listenTo(s,"execute",(()=>{t.execute("exportWord",n),t.editing.view.focus()})),s}));const r=t.plugins.get("CloudServices");!1===n.tokenUrl?this._token=null:n.tokenUrl?r.registerTokenUrl(n.tokenUrl).then((t=>{this._token=t})):this._token=r.token}}})(),(window.CKEditor5=window.CKEditor5||{}).exportWord=n})();
5
+ */(()=>{var e={704:(e,t,o)=>{e.exports=o(79)("./src/core.js")},273:(e,t,o)=>{e.exports=o(79)("./src/ui.js")},79:e=>{"use strict";e.exports=CKEditor5.dll}},t={};function o(n){var r=t[n];if(void 0!==r)return r.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,o),s.exports}o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";o.r(n),o.d(n,{ExportWord:()=>u});var e=o(704),t=o(273);const r=["indexOf","then","cssText","resolvedOptions","users","Users","fetch","timeZone","author","comments","name","keys","isResolved","createdAt","getSuggestions","DateTimeFormat","has","cssRules","hasAttribute","The editor stylesheet could not be found in the document. Check your webpack config – style-loader should use data-cke=true attribute for the editor stylesheet.","styleSheets",":root","all","CommentsRepository","TrackChanges","push","get","suggestions","plugins","content","getCommentThreads","length","join","data-cke","from","text"];var s,i;s=r,i=408,function(e){for(;--e;)s.push(s.shift())}(++i);const a=function(e,t){return r[e-=0]};function c(){const e=[],t=[];for(const o of Array[a("0x16")](document[a("0x8")]))if(o.ownerNode[a("0x6")](a("0x15")))for(const n of Array[a("0x16")](o[a("0x5")]))-1!==n[a("0x1a")].indexOf(".ck-content")?e[a("0xd")](n[a("0x1a")]):-1!==n[a("0x1a")][a("0x18")](a("0x9"))&&t.push(n[a("0x1a")]);return e.length||console.warn(a("0x7")),[...t,...e][a("0x14")](" ").trim()}function d(e){const t=e.plugins[a("0x4")]("Users"),o=e[a("0x10")][a("0x4")](a("0xb")),n=e.plugins.has(a("0xc")),r={};if(t&&o){const t=function(e){const t={};if(!e.length)return t;for(const o of e)o[a("0x21")].map((e=>{void 0===t[o.id]&&(t[o.id]=[]),t[o.id][a("0xd")]({author:e[a("0x20")][a("0x22")],content:e[a("0x11")],created:e[a("0x1")],is_resolved:o[a("0x0")]})}));return t}(e[a("0x10")].get(a("0xb"))[a("0x12")]({skipNotAttached:!0,skipEmpty:!0}));Object[a("0x23")](t)[a("0x13")]&&(r.comments=t)}if(t&&n){const t=e[a("0x10")][a("0xe")](a("0xc")),o=e[a("0x10")][a("0xe")](a("0x1d")),n=function(e,t){const o={};if(!e.length||!t[a("0x13")])return o;for(const n of e)o[n.id]={author:t[a("0xe")](n.authorId)[a("0x22")],created:n.createdAt};return o}(t[a("0x2")]({toJSON:!0}),o[a("0x1c")]);Object.keys(n).length&&(r[a("0xf")]=n)}return(r[a("0xf")]||r[a("0x21")])&&(r.timezone=(new(Intl[a("0x3")]))[a("0x1b")]()[a("0x1f")]),r}class l extends e.Command{constructor(e){super(e),this.set("isBusy",!1),this.affectsData=!1}refresh(){this.isEnabled=!this.isBusy,this.value=this.isBusy?"pending":void 0}execute(e={}){const t=this.editor,o=t.t,n=e.converterUrl||"https://docx-converter.cke-cs.com/v1/convert",r=e.converterOptions||{},s=t.plugins.get("ExportWord"),i=e.token||s._token,l=!1!==r.auto_pagination,u=e.dataCallback||(e=>e.data.get({pagination:l}));return this.isBusy=!0,this.refresh(),function(e){if(!e)return new Promise((e=>e("")));const t=[];for(const o of e)"EDITOR_STYLES"!==o?t[a("0xd")](window[a("0x1e")](o).then((e=>e[a("0x17")]()))):t.push(c());return Promise[a("0xa")](t)[a("0x19")]((e=>e[a("0x14")](" ").trim()))}(e.stylesheets||["EDITOR_STYLES"]).then((async o=>{const s=await u(t),a=this._replaceSuggestionTypes(s),c={html:'<div class="ck-content" dir="'+t.locale.contentLanguageDirection+'">'+a+"</div>",css:o,options:{...r,...d(t)}},l={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/docx",...i?{Authorization:i.value}:null},body:JSON.stringify(c)};return window.fetch(n,l).then((e=>{if(200!==e.status)throw e;return e.blob()})).then((t=>{const o="function"==typeof e.fileName?e.fileName():e.fileName;this._downloadFile(t,o||"document.docx")}))})).catch((e=>{throw t.plugins.get("Notification").showWarning(o("An error occurred while generating the Word file.")),e})).finally((()=>{this.isBusy=!1,this.refresh()}))}_replaceSuggestionTypes(e){if(!e)return e;const t=(e,t,o)=>"attribute"===o?t+"formatInline:":e;return e.replace(/<suggestion-(start|end) name="(.*?):/g,((e,o,n)=>t(e,"<suggestion-"+o+' name="',n))).replace(/data-suggestion-(start|end)-(before|after)="(.*?):/g,((e,o,n,r)=>t(e,"data-suggestion-"+o+"-"+n+'="',r)))}_downloadFile(e,t){const o=document.createElement("a");o.href=window.URL.createObjectURL(e),o.download=t,o.click(),o.remove()}}class u extends e.Plugin{static get pluginName(){return"ExportWord"}static get requires(){return["CloudServices",t.Notification]}init(){const e=this.editor,o=e.t,n=e.config.get("exportWord")||{};e.commands.add("exportWord",new l(e)),e.ui.componentFactory.add("exportWord",(r=>{const s=e.commands.get("exportWord"),i=new t.ButtonView(r),a=new t.SpinnerView;return i.set({label:o("Export to Word"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M17.826 16.843a.75.75 0 0 0-1.152-.96L15.5 17.29V12H14v5.29l-1.174-1.408a.75.75 0 0 0-1.152.96l2.346 2.816a.95.95 0 0 0 1.46 0l2.346-2.815Z"/><path d="m14 0 5 4.5v9.741a2.737 2.737 0 0 0-1.5-.617V6.5h-5v-5h-8v3H3V0h11Zm0 2v3h3.3L14 2Z"/><path d="M3 17.5h6.746c.1.22.23.429.391.623l.731.877H3v-1.5Z"/><path d="M8.5 6a1.5 1.5 0 0 1 1.493 1.356L10 7.5v7a1.5 1.5 0 0 1-1.356 1.493L8.5 16h-7a1.5 1.5 0 0 1-1.493-1.356L0 14.5v-7a1.5 1.5 0 0 1 1.356-1.493L1.5 6h7ZM7.483 8.795l-.042.088-.986 2.534-.947-2.528-.043-.092a.601.601 0 0 0-1.042.008l-.042.093-.883 2.465-.937-2.475-.042-.089a.6.6 0 0 0-1.107.42l.027.093 1.514 4 .044.092a.6.6 0 0 0 1.041-.01l.041-.092.88-2.458.925 2.467.046.096a.6.6 0 0 0 1.032 0l.043-.09 1.554-4 .028-.093a.6.6 0 0 0-1.104-.43v.001Z"/></svg>\n',tooltip:!0}),i.children.add(a),i.bind("isOn","isEnabled").to(s,"isBusy","isEnabled"),a.bind("isVisible").to(s,"isBusy"),i.iconView.bind("isVisible").to(s,"isBusy",(e=>!e)),this.listenTo(i,"execute",(()=>{e.execute("exportWord",n),e.editing.view.focus()})),i}));const r=e.plugins.get("CloudServices");!1===n.tokenUrl?this._token=null:n.tokenUrl?r.registerTokenUrl(n.tokenUrl).then((e=>{this._token=e})):this._token=r.token}}})(),(window.CKEditor5=window.CKEditor5||{}).exportWord=n})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-export-word",
3
- "version": "40.0.0",
3
+ "version": "40.1.0",
4
4
  "description": "Export to Word feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -29,7 +29,7 @@
29
29
  ],
30
30
  "main": "src/index.js",
31
31
  "dependencies": {
32
- "ckeditor5": "40.0.0"
32
+ "ckeditor5": "40.1.0"
33
33
  },
34
34
  "license": "SEE LICENSE IN LICENSE.md",
35
35
  "author": "CKSource (https://cksource.com/)",
@@ -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,231 +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
- * 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
- };
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 _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'];}}
23
+ import{Plugin as _0x36456e}from'ckeditor5/src/core';import{ButtonView as _0x2b197a,Notification as _0x20a568,SpinnerView as _0xc1871b}from'ckeditor5/src/ui';import _0x3f820d from'./exportwordcommand';import _0x3b872a from'../theme/icons/exportword.svg';export default class d extends _0x36456e{static get['pluginName'](){return'ExportWord';}static get['requires'](){return['CloudServices',_0x20a568];}['init'](){const _0x3b6c16=this['editor'],t=_0x3b6c16['t'],_0x495ddc=_0x3b6c16['config']['get']('exportWord')||{};_0x3b6c16['commands']['add']('exportWord',new _0x3f820d(_0x3b6c16)),_0x3b6c16['ui']['componentFactory']['add']('exportWord',_0x4453b8=>{const _0x1776db=_0x3b6c16['commands']['get']('exportWord'),_0x25cc02=new _0x2b197a(_0x4453b8),_0x51e114=new _0xc1871b();return _0x25cc02['set']({'label':t('Export\x20to\x20Word'),'icon':_0x3b872a,'tooltip':!0x0}),_0x25cc02['children']['add'](_0x51e114),_0x25cc02['bind']('isOn','isEnabled')['to'](_0x1776db,'isBusy','isEnabled'),_0x51e114['bind']('isVisible')['to'](_0x1776db,'isBusy'),_0x25cc02['iconView']['bind']('isVisible')['to'](_0x1776db,'isBusy',_0x3bcefc=>!_0x3bcefc),this['listenTo'](_0x25cc02,'execute',()=>{_0x3b6c16['execute']('exportWord',_0x495ddc),_0x3b6c16['editing']['view']['focus']();}),_0x25cc02;});const _0x578850=_0x3b6c16['plugins']['get']('CloudServices');!0x1===_0x495ddc['tokenUrl']?this['_token']=null:_0x495ddc['tokenUrl']?_0x578850['registerTokenUrl'](_0x495ddc['tokenUrl'])['then'](_0x233011=>{this['_token']=_0x233011;}):this['_token']=_0x578850['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 _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']();}}
23
+ import{Command as _0x53fcab}from'ckeditor5/src/core';import{getConverterOptions as _0x50bd13,getStyles as _0x2e516c}from'./utils';export default class s extends _0x53fcab{constructor(_0x28e12e){super(_0x28e12e),this['set']('isBusy',!0x1),this['affectsData']=!0x1;}['refresh'](){this['isEnabled']=!this['isBusy'],this['value']=this['isBusy']?'pending':void 0x0;}['execute'](_0x20e7d9={}){const _0xeed830=this['editor'],t=_0xeed830['t'],_0x4bc2b1=_0x20e7d9['converterUrl']||'https://docx-converter.cke-cs.com/v1/convert',_0x104dfb=_0x20e7d9['converterOptions']||{},_0x21e344=_0xeed830['plugins']['get']('ExportWord'),_0x5a7880=_0x20e7d9['token']||_0x21e344['_token'],_0x17e071=!0x1!==_0x104dfb['auto_pagination'],_0x3398d9=_0x20e7d9['dataCallback']||(_0x3b1f83=>_0x3b1f83['data']['get']({'pagination':_0x17e071}));return this['isBusy']=!0x0,this['refresh'](),_0x2e516c(_0x20e7d9['stylesheets']||['EDITOR_STYLES'])['then'](async _0x11aacc=>{const _0xa4ddc3=await _0x3398d9(_0xeed830),_0x1dd071=this['_replaceSuggestionTypes'](_0xa4ddc3),_0x2153e7={'html':'<div\x20class=\x22ck-content\x22\x20dir=\x22'+_0xeed830['locale']['contentLanguageDirection']+'\x22>'+_0x1dd071+'</div>','css':_0x11aacc,'options':{..._0x104dfb,..._0x50bd13(_0xeed830)}},_0x44be5a={'method':'POST','headers':{'Content-Type':'application/json','Accept':'application/docx',..._0x5a7880?{'Authorization':_0x5a7880['value']}:null},'body':JSON['stringify'](_0x2153e7)};return window['fetch'](_0x4bc2b1,_0x44be5a)['then'](_0x125439=>{if(0xc8!==_0x125439['status'])throw _0x125439;return _0x125439['blob']();})['then'](_0x233cd0=>{const _0x333f0e='function'==typeof _0x20e7d9['fileName']?_0x20e7d9['fileName']():_0x20e7d9['fileName'];this['_downloadFile'](_0x233cd0,_0x333f0e||'document.docx');});})['catch'](_0x1b3264=>{throw _0xeed830['plugins']['get']('Notification')['showWarning'](t('An\x20error\x20occurred\x20while\x20generating\x20the\x20Word\x20file.')),_0x1b3264;})['finally'](()=>{this['isBusy']=!0x1,this['refresh']();});}['_replaceSuggestionTypes'](_0x31ad7e){if(!_0x31ad7e)return _0x31ad7e;const _0x398330=(_0xc87d9,_0x27bfdf,_0x92fb6e)=>'attribute'===_0x92fb6e?_0x27bfdf+'formatInline:':_0xc87d9;return _0x31ad7e['replace'](/<suggestion-(start|end) name="(.*?):/g,(_0x25a351,_0x386e72,_0x540d16)=>_0x398330(_0x25a351,'<suggestion-'+_0x386e72+'\x20name=\x22',_0x540d16))['replace'](/data-suggestion-(start|end)-(before|after)="(.*?):/g,(_0x14c9e9,_0x106e83,_0x3132a4,_0x120c3f)=>_0x398330(_0x14c9e9,'data-suggestion-'+_0x106e83+'-'+_0x3132a4+'=\x22',_0x120c3f));}['_downloadFile'](_0x1a8900,_0x5cde32){const _0x1ce8c1=document['createElement']('a');_0x1ce8c1['href']=window['URL']['createObjectURL'](_0x1a8900),_0x1ce8c1['download']=_0x5cde32,_0x1ce8c1['click'](),_0x1ce8c1['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, type 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';
package/src/utils.d.ts CHANGED
@@ -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
- import type { Editor } from 'ckeditor5/src/core';
6
- import type { Collection } from 'ckeditor5/src/utils';
7
- import type { ExportWordConverterOptions, ExportWordConverterCommentsOption, ExportWordConverterSuggestionsOption } from './exportword';
8
- import type { CommentThread } from '@ckeditor/ckeditor5-comments';
9
- import type { SuggestionJSON } from '@ckeditor/ckeditor5-track-changes';
10
- import type { User } from '@ckeditor/ckeditor5-collaboration-core';
11
- /**
12
- * A helper function for getting concatenated CSS rules from external stylesheets.
13
- *
14
- * @param stylesheets An array of stylesheet paths delivered by the user through the plugin configuration.
15
- */
16
- export declare function getStyles(stylesheets?: Array<string>): Promise<string>;
17
- /**
18
- * A helper function for getting a proper options object containing
19
- * comments, suggestions and the browser's timezone for the "Export to Word" converter.
20
- *
21
- * @param editor An editor instance.
22
- */
23
- export declare function getConverterOptions(editor: Editor): ExportWordConverterOptions;
24
- /**
25
- * A helper function for getting a comments object for the converter options.
26
- *
27
- * @param threads The comment threads array.
28
- */
29
- export declare function getComments(threads: Array<CommentThread>): ExportWordConverterCommentsOption;
30
- /**
31
- * A helper function for getting a suggestions object for the converter options.
32
- *
33
- * @param suggestions The suggestions array.
34
- * @param users A list of all users in the editor.
35
- */
36
- export declare function getSuggestions(suggestions: Array<SuggestionJSON>, users: Collection<User>): ExportWordConverterSuggestionsOption;
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 { Editor } from 'ckeditor5/src/core';
6
+ import type { Collection } from 'ckeditor5/src/utils';
7
+ import type { ExportWordConverterOptions, ExportWordConverterCommentsOption, ExportWordConverterSuggestionsOption } from './exportword';
8
+ import type { CommentThread } from '@ckeditor/ckeditor5-comments';
9
+ import type { SuggestionJSON } from '@ckeditor/ckeditor5-track-changes';
10
+ import type { User } from '@ckeditor/ckeditor5-collaboration-core';
11
+ /**
12
+ * A helper function for getting concatenated CSS rules from external stylesheets.
13
+ *
14
+ * @param stylesheets An array of stylesheet paths delivered by the user through the plugin configuration.
15
+ */
16
+ export declare function getStyles(stylesheets?: Array<string>): Promise<string>;
17
+ /**
18
+ * A helper function for getting a proper options object containing
19
+ * comments, suggestions and the browser's timezone for the "Export to Word" converter.
20
+ *
21
+ * @param editor An editor instance.
22
+ */
23
+ export declare function getConverterOptions(editor: Editor): ExportWordConverterOptions;
24
+ /**
25
+ * A helper function for getting a comments object for the converter options.
26
+ *
27
+ * @param threads The comment threads array.
28
+ */
29
+ export declare function getComments(threads: Array<CommentThread>): ExportWordConverterCommentsOption;
30
+ /**
31
+ * A helper function for getting a suggestions object for the converter options.
32
+ *
33
+ * @param suggestions The suggestions array.
34
+ * @param users A list of all users in the editor.
35
+ */
36
+ export declare function getSuggestions(suggestions: Array<SuggestionJSON>, users: Collection<User>): ExportWordConverterSuggestionsOption;
package/src/utils.js CHANGED
@@ -20,4 +20,4 @@
20
20
  *
21
21
  *
22
22
  */
23
- const _0x2b94=['name','text','content',':root','all','TrackChanges','isResolved','Users','comments','styleSheets','timeZone','plugins','has','The\x20editor\x20stylesheet\x20could\x20not\x20be\x20found\x20in\x20the\x20document.\x20Check\x20your\x20webpack\x20config\x20–\x20style-loader\x20should\x20use\x20data-cke=true\x20attribute\x20for\x20the\x20editor\x20stylesheet.','createdAt','.ck-content','resolvedOptions','getCommentThreads','warn','suggestions','cssText','CommentsRepository','from','push','trim','indexOf','join','DateTimeFormat','author','fetch','timezone','ownerNode','keys','length','get','then','authorId'];(function(_0x3cca87,_0x2b94a9){const _0x1bc98b=function(_0x55eaf2){while(--_0x55eaf2){_0x3cca87['push'](_0x3cca87['shift']());}};_0x1bc98b(++_0x2b94a9);}(_0x2b94,0x163));const _0x1bc9=function(_0x3cca87,_0x2b94a9){_0x3cca87=_0x3cca87-0x0;let _0x1bc98b=_0x2b94[_0x3cca87];return _0x1bc98b;};export function getStyles(_0x2d7eda){if(!_0x2d7eda)return new Promise(_0x199e0b=>_0x199e0b(''));const _0x142bac=[];for(const _0x22dd34 of _0x2d7eda)'EDITOR_STYLES'!==_0x22dd34?_0x142bac[_0x1bc9('0x1')](window[_0x1bc9('0x7')](_0x22dd34)[_0x1bc9('0xd')](_0x40a079=>_0x40a079[_0x1bc9('0x10')]())):_0x142bac[_0x1bc9('0x1')](u());return Promise[_0x1bc9('0x13')](_0x142bac)[_0x1bc9('0xd')](_0x19f9f2=>_0x19f9f2['join']('\x20')[_0x1bc9('0x2')]());}function u(){const _0x2d4293=[],_0x4183db=[];for(const _0x39f0b2 of Array[_0x1bc9('0x0')](document[_0x1bc9('0x18')])){if(_0x39f0b2[_0x1bc9('0x9')]['hasAttribute']('data-cke'))for(const _0x1b003a of Array['from'](_0x39f0b2['cssRules']))-0x1!==_0x1b003a[_0x1bc9('0x23')][_0x1bc9('0x3')](_0x1bc9('0x1e'))?_0x2d4293[_0x1bc9('0x1')](_0x1b003a[_0x1bc9('0x23')]):-0x1!==_0x1b003a[_0x1bc9('0x23')]['indexOf'](_0x1bc9('0x12'))&&_0x4183db[_0x1bc9('0x1')](_0x1b003a[_0x1bc9('0x23')]);}return _0x2d4293['length']||console[_0x1bc9('0x21')](_0x1bc9('0x1c')),[..._0x4183db,..._0x2d4293][_0x1bc9('0x4')]('\x20')[_0x1bc9('0x2')]();}export function getConverterOptions(_0x641b41){const _0x1a9899=_0x641b41['plugins'][_0x1bc9('0x1b')](_0x1bc9('0x16')),_0x6cf138=_0x641b41[_0x1bc9('0x1a')]['has'](_0x1bc9('0x24')),_0x3f496a=_0x641b41[_0x1bc9('0x1a')]['has'](_0x1bc9('0x14')),_0x5c2ad8={};if(_0x1a9899&&_0x6cf138){const _0x56db9a=getComments(_0x641b41[_0x1bc9('0x1a')][_0x1bc9('0xc')](_0x1bc9('0x24'))[_0x1bc9('0x20')]({'skipNotAttached':!0x0,'skipEmpty':!0x0}));Object[_0x1bc9('0xa')](_0x56db9a)[_0x1bc9('0xb')]&&(_0x5c2ad8['comments']=_0x56db9a);}if(_0x1a9899&&_0x3f496a){const _0xda7387=_0x641b41[_0x1bc9('0x1a')]['get'](_0x1bc9('0x14')),_0x40b9af=_0x641b41[_0x1bc9('0x1a')]['get']('Users'),_0xc70438=getSuggestions(_0xda7387['getSuggestions']({'toJSON':!0x0}),_0x40b9af['users']);Object['keys'](_0xc70438)['length']&&(_0x5c2ad8[_0x1bc9('0x22')]=_0xc70438);}return(_0x5c2ad8[_0x1bc9('0x22')]||_0x5c2ad8[_0x1bc9('0x17')])&&(_0x5c2ad8[_0x1bc9('0x8')]=new Intl[(_0x1bc9('0x5'))]()[_0x1bc9('0x1f')]()[_0x1bc9('0x19')]),_0x5c2ad8;}export function getComments(_0x224d05){const _0x5c472a={};if(!_0x224d05[_0x1bc9('0xb')])return _0x5c472a;for(const _0x45894d of _0x224d05)_0x45894d[_0x1bc9('0x17')]['map'](_0x31d657=>{void 0x0===_0x5c472a[_0x45894d['id']]&&(_0x5c472a[_0x45894d['id']]=[]),_0x5c472a[_0x45894d['id']][_0x1bc9('0x1')]({'author':_0x31d657[_0x1bc9('0x6')][_0x1bc9('0xf')],'content':_0x31d657[_0x1bc9('0x11')],'created':_0x31d657[_0x1bc9('0x1d')],'is_resolved':_0x45894d[_0x1bc9('0x15')]});});return _0x5c472a;}export function getSuggestions(_0x3eb766,_0x1527e2){const _0x488b4d={};if(!_0x3eb766[_0x1bc9('0xb')]||!_0x1527e2[_0x1bc9('0xb')])return _0x488b4d;for(const _0x15973c of _0x3eb766)_0x488b4d[_0x15973c['id']]={'author':_0x1527e2['get'](_0x15973c[_0x1bc9('0xe')])['name'],'created':_0x15973c['createdAt']};return _0x488b4d;}
23
+ const _0xc9a2=['indexOf','then','cssText','resolvedOptions','users','Users','fetch','timeZone','author','comments','name','keys','isResolved','createdAt','getSuggestions','DateTimeFormat','has','cssRules','hasAttribute','The\x20editor\x20stylesheet\x20could\x20not\x20be\x20found\x20in\x20the\x20document.\x20Check\x20your\x20webpack\x20config\x20–\x20style-loader\x20should\x20use\x20data-cke=true\x20attribute\x20for\x20the\x20editor\x20stylesheet.','styleSheets',':root','all','CommentsRepository','TrackChanges','push','get','suggestions','plugins','content','getCommentThreads','length','join','data-cke','from','text'];(function(_0x496a18,_0xc9a24f){const _0x3991fc=function(_0x176bb0){while(--_0x176bb0){_0x496a18['push'](_0x496a18['shift']());}};_0x3991fc(++_0xc9a24f);}(_0xc9a2,0x198));const _0x3991=function(_0x496a18,_0xc9a24f){_0x496a18=_0x496a18-0x0;let _0x3991fc=_0xc9a2[_0x496a18];return _0x3991fc;};export function getStyles(_0x586edc){if(!_0x586edc)return new Promise(_0x43ba86=>_0x43ba86(''));const _0x1b4157=[];for(const _0x4b86c3 of _0x586edc)'EDITOR_STYLES'!==_0x4b86c3?_0x1b4157[_0x3991('0xd')](window[_0x3991('0x1e')](_0x4b86c3)['then'](_0x4f85cc=>_0x4f85cc[_0x3991('0x17')]())):_0x1b4157['push'](u());return Promise[_0x3991('0xa')](_0x1b4157)[_0x3991('0x19')](_0x4f0af7=>_0x4f0af7[_0x3991('0x14')]('\x20')['trim']());}function u(){const _0x3bca3b=[],_0x42160=[];for(const _0x451ec3 of Array[_0x3991('0x16')](document[_0x3991('0x8')])){if(_0x451ec3['ownerNode'][_0x3991('0x6')](_0x3991('0x15')))for(const _0x5ea3ee of Array[_0x3991('0x16')](_0x451ec3[_0x3991('0x5')]))-0x1!==_0x5ea3ee[_0x3991('0x1a')]['indexOf']('.ck-content')?_0x3bca3b[_0x3991('0xd')](_0x5ea3ee[_0x3991('0x1a')]):-0x1!==_0x5ea3ee[_0x3991('0x1a')][_0x3991('0x18')](_0x3991('0x9'))&&_0x42160['push'](_0x5ea3ee[_0x3991('0x1a')]);}return _0x3bca3b['length']||console['warn'](_0x3991('0x7')),[..._0x42160,..._0x3bca3b][_0x3991('0x14')]('\x20')['trim']();}export function getConverterOptions(_0x578b93){const _0x32595d=_0x578b93['plugins'][_0x3991('0x4')]('Users'),_0x4940ed=_0x578b93[_0x3991('0x10')][_0x3991('0x4')](_0x3991('0xb')),_0x3ed76a=_0x578b93['plugins']['has'](_0x3991('0xc')),_0xc10b72={};if(_0x32595d&&_0x4940ed){const _0x24fa9c=getComments(_0x578b93[_0x3991('0x10')]['get'](_0x3991('0xb'))[_0x3991('0x12')]({'skipNotAttached':!0x0,'skipEmpty':!0x0}));Object[_0x3991('0x23')](_0x24fa9c)[_0x3991('0x13')]&&(_0xc10b72['comments']=_0x24fa9c);}if(_0x32595d&&_0x3ed76a){const _0x5d8421=_0x578b93[_0x3991('0x10')][_0x3991('0xe')](_0x3991('0xc')),_0x591535=_0x578b93[_0x3991('0x10')][_0x3991('0xe')](_0x3991('0x1d')),_0xad58bf=getSuggestions(_0x5d8421[_0x3991('0x2')]({'toJSON':!0x0}),_0x591535[_0x3991('0x1c')]);Object['keys'](_0xad58bf)['length']&&(_0xc10b72[_0x3991('0xf')]=_0xad58bf);}return(_0xc10b72[_0x3991('0xf')]||_0xc10b72[_0x3991('0x21')])&&(_0xc10b72['timezone']=new Intl[(_0x3991('0x3'))]()[_0x3991('0x1b')]()[_0x3991('0x1f')]),_0xc10b72;}export function getComments(_0x1a317d){const _0x24eaef={};if(!_0x1a317d['length'])return _0x24eaef;for(const _0x2a1917 of _0x1a317d)_0x2a1917[_0x3991('0x21')]['map'](_0x3f579e=>{void 0x0===_0x24eaef[_0x2a1917['id']]&&(_0x24eaef[_0x2a1917['id']]=[]),_0x24eaef[_0x2a1917['id']][_0x3991('0xd')]({'author':_0x3f579e[_0x3991('0x20')][_0x3991('0x22')],'content':_0x3f579e[_0x3991('0x11')],'created':_0x3f579e[_0x3991('0x1')],'is_resolved':_0x2a1917[_0x3991('0x0')]});});return _0x24eaef;}export function getSuggestions(_0x248915,_0x1c7046){const _0x2cd862={};if(!_0x248915['length']||!_0x1c7046[_0x3991('0x13')])return _0x2cd862;for(const _0xe7458f of _0x248915)_0x2cd862[_0xe7458f['id']]={'author':_0x1c7046[_0x3991('0xe')](_0xe7458f['authorId'])[_0x3991('0x22')],'created':_0xe7458f['createdAt']};return _0x2cd862;}