@ckeditor/ckeditor5-export-word 0.0.0-nightly-20231205.0 → 0.0.0-nightly-20231207.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/build/export-word.js +1 -1
- package/package.json +2 -2
- package/src/exportword.js +1 -1
- package/src/exportwordcommand.js +1 -1
- package/src/utils.js +1 -1
package/build/export-word.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
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 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:()=>l});var e=o(704),t=o(273);const r=["
|
|
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:()=>l});var e=o(704),t=o(273);const r=["text","cssText","DateTimeFormat","indexOf","trim","content","timeZone","then","ownerNode","length","EDITOR_STYLES","users","TrackChanges","authorId","join","get","keys","hasAttribute","all","name","from","createdAt","warn",":root","CommentsRepository","has","comments","isResolved","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.","author","push","fetch","timezone",".ck-content","suggestions","getCommentThreads","Users","plugins"];var s,i;s=r,i=275,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("0xb")](document.styleSheets))if(o[a("0x25")][a("0x8")]("data-cke"))for(const n of Array.from(o.cssRules))-1!==n[a("0x1e")][a("0x20")](a("0x18"))?e[a("0x15")](n[a("0x1e")]):-1!==n[a("0x1e")][a("0x20")](a("0xe"))&&t.push(n[a("0x1e")]);return e.length||console[a("0xd")](a("0x13")),[...t,...e][a("0x5")](" ")[a("0x21")]()}function d(e){const t=e[a("0x1c")][a("0x10")]("Users"),o=e.plugins.has(a("0xf")),n=e.plugins[a("0x10")](a("0x3")),r={};if(t&&o){const t=function(e){const t={};if(!e[a("0x0")])return t;for(const o of e)o[a("0x11")].map((e=>{void 0===t[o.id]&&(t[o.id]=[]),t[o.id][a("0x15")]({author:e[a("0x14")][a("0xa")],content:e[a("0x22")],created:e[a("0xc")],is_resolved:o[a("0x12")]})}));return t}(e[a("0x1c")].get(a("0xf"))[a("0x1a")]({skipNotAttached:!0,skipEmpty:!0}));Object[a("0x7")](t)[a("0x0")]&&(r.comments=t)}if(t&&n){const t=e[a("0x1c")][a("0x6")](a("0x3")),o=e[a("0x1c")][a("0x6")](a("0x1b")),n=function(e,t){const o={};if(!e[a("0x0")]||!t[a("0x0")])return o;for(const n of e)o[n.id]={author:t.get(n[a("0x4")])[a("0xa")],created:n[a("0xc")]};return o}(t.getSuggestions({toJSON:!0}),o[a("0x2")]);Object[a("0x7")](n)[a("0x0")]&&(r.suggestions=n)}return(r[a("0x19")]||r[a("0x11")])&&(r[a("0x17")]=(new(Intl[a("0x1f")])).resolvedOptions()[a("0x23")]),r}class u 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,u=!1!==r.auto_pagination,l=e.dataCallback||(e=>e.data.get({pagination:u}));return this.isBusy=!0,this.refresh(),function(e){if(!e)return new Promise((e=>e("")));const t=[];for(const o of e)a("0x1")!==o?t[a("0x15")](window[a("0x16")](o)[a("0x24")]((e=>e[a("0x1d")]()))):t.push(c());return Promise[a("0x9")](t)[a("0x24")]((e=>e[a("0x5")](" ")[a("0x21")]()))}(e.stylesheets||["EDITOR_STYLES"]).then((async o=>{const s=await l(t),a=this._replaceSuggestionTypes(s),c={html:'<div class="ck-content" dir="'+t.locale.contentLanguageDirection+'">'+a+"</div>",css:o,options:{...r,...d(t)}},u={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/docx",...i?{Authorization:i.value}:null},body:JSON.stringify(c)};return window.fetch(n,u).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 l 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 u(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": "0.0.0-nightly-
|
|
3
|
+
"version": "0.0.0-nightly-20231207.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": "0.0.0-nightly-
|
|
32
|
+
"ckeditor5": "0.0.0-nightly-20231207.0"
|
|
33
33
|
},
|
|
34
34
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
35
35
|
"author": "CKSource (https://cksource.com/)",
|
package/src/exportword.js
CHANGED
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
import{Plugin as
|
|
23
|
+
import{Plugin as _0x423007}from'ckeditor5/src/core';import{ButtonView as _0x32c3fb,Notification as _0x14c31a,SpinnerView as _0xae0ada}from'ckeditor5/src/ui';import _0x2864d1 from'./exportwordcommand';import _0xd5b7eb from'../theme/icons/exportword.svg';export default class d extends _0x423007{static get['pluginName'](){return'ExportWord';}static get['requires'](){return['CloudServices',_0x14c31a];}['init'](){const _0x2b3d1f=this['editor'],t=_0x2b3d1f['t'],_0x2e9a9b=_0x2b3d1f['config']['get']('exportWord')||{};_0x2b3d1f['commands']['add']('exportWord',new _0x2864d1(_0x2b3d1f)),_0x2b3d1f['ui']['componentFactory']['add']('exportWord',_0x1b6ea5=>{const _0x548348=_0x2b3d1f['commands']['get']('exportWord'),_0x55f803=new _0x32c3fb(_0x1b6ea5),_0x36f386=new _0xae0ada();return _0x55f803['set']({'label':t('Export\x20to\x20Word'),'icon':_0xd5b7eb,'tooltip':!0x0}),_0x55f803['children']['add'](_0x36f386),_0x55f803['bind']('isOn','isEnabled')['to'](_0x548348,'isBusy','isEnabled'),_0x36f386['bind']('isVisible')['to'](_0x548348,'isBusy'),_0x55f803['iconView']['bind']('isVisible')['to'](_0x548348,'isBusy',_0x154555=>!_0x154555),this['listenTo'](_0x55f803,'execute',()=>{_0x2b3d1f['execute']('exportWord',_0x2e9a9b),_0x2b3d1f['editing']['view']['focus']();}),_0x55f803;});const _0xba9255=_0x2b3d1f['plugins']['get']('CloudServices');!0x1===_0x2e9a9b['tokenUrl']?this['_token']=null:_0x2e9a9b['tokenUrl']?_0xba9255['registerTokenUrl'](_0x2e9a9b['tokenUrl'])['then'](_0x460c8a=>{this['_token']=_0x460c8a;}):this['_token']=_0xba9255['token'];}}
|
package/src/exportwordcommand.js
CHANGED
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
import{Command as
|
|
23
|
+
import{Command as _0x3410ed}from'ckeditor5/src/core';import{getConverterOptions as _0x4cf62b,getStyles as _0x21cfba}from'./utils';export default class s extends _0x3410ed{constructor(_0x5e2a07){super(_0x5e2a07),this['set']('isBusy',!0x1),this['affectsData']=!0x1;}['refresh'](){this['isEnabled']=!this['isBusy'],this['value']=this['isBusy']?'pending':void 0x0;}['execute'](_0x3da18e={}){const _0x33d968=this['editor'],t=_0x33d968['t'],_0x1dd99b=_0x3da18e['converterUrl']||'https://docx-converter.cke-cs.com/v1/convert',_0x558457=_0x3da18e['converterOptions']||{},_0xeb6db2=_0x33d968['plugins']['get']('ExportWord'),_0x8b7284=_0x3da18e['token']||_0xeb6db2['_token'],_0x201604=!0x1!==_0x558457['auto_pagination'],_0x19a0c9=_0x3da18e['dataCallback']||(_0x159d1f=>_0x159d1f['data']['get']({'pagination':_0x201604}));return this['isBusy']=!0x0,this['refresh'](),_0x21cfba(_0x3da18e['stylesheets']||['EDITOR_STYLES'])['then'](async _0x5f2477=>{const _0x59ba16=await _0x19a0c9(_0x33d968),_0x3c1381=this['_replaceSuggestionTypes'](_0x59ba16),_0x5815d6={'html':'<div\x20class=\x22ck-content\x22\x20dir=\x22'+_0x33d968['locale']['contentLanguageDirection']+'\x22>'+_0x3c1381+'</div>','css':_0x5f2477,'options':{..._0x558457,..._0x4cf62b(_0x33d968)}},_0x32c916={'method':'POST','headers':{'Content-Type':'application/json','Accept':'application/docx',..._0x8b7284?{'Authorization':_0x8b7284['value']}:null},'body':JSON['stringify'](_0x5815d6)};return window['fetch'](_0x1dd99b,_0x32c916)['then'](_0x53dafc=>{if(0xc8!==_0x53dafc['status'])throw _0x53dafc;return _0x53dafc['blob']();})['then'](_0x502ff4=>{const _0x51b17b='function'==typeof _0x3da18e['fileName']?_0x3da18e['fileName']():_0x3da18e['fileName'];this['_downloadFile'](_0x502ff4,_0x51b17b||'document.docx');});})['catch'](_0x2f0ee9=>{throw _0x33d968['plugins']['get']('Notification')['showWarning'](t('An\x20error\x20occurred\x20while\x20generating\x20the\x20Word\x20file.')),_0x2f0ee9;})['finally'](()=>{this['isBusy']=!0x1,this['refresh']();});}['_replaceSuggestionTypes'](_0x46c74c){if(!_0x46c74c)return _0x46c74c;const _0x462602=(_0x214062,_0x4f90b3,_0x6eca7b)=>'attribute'===_0x6eca7b?_0x4f90b3+'formatInline:':_0x214062;return _0x46c74c['replace'](/<suggestion-(start|end) name="(.*?):/g,(_0x31bc7c,_0x57a1ad,_0x2b74db)=>_0x462602(_0x31bc7c,'<suggestion-'+_0x57a1ad+'\x20name=\x22',_0x2b74db))['replace'](/data-suggestion-(start|end)-(before|after)="(.*?):/g,(_0x4cb825,_0xb5e0ae,_0x2269b2,_0x5eeda8)=>_0x462602(_0x4cb825,'data-suggestion-'+_0xb5e0ae+'-'+_0x2269b2+'=\x22',_0x5eeda8));}['_downloadFile'](_0x5e6e75,_0x4465c6){const _0x5d810d=document['createElement']('a');_0x5d810d['href']=window['URL']['createObjectURL'](_0x5e6e75),_0x5d810d['download']=_0x4465c6,_0x5d810d['click'](),_0x5d810d['remove']();}}
|
package/src/utils.js
CHANGED
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
const
|
|
23
|
+
const _0x2a08=['text','cssText','DateTimeFormat','indexOf','trim','content','timeZone','then','ownerNode','length','EDITOR_STYLES','users','TrackChanges','authorId','join','get','keys','hasAttribute','all','name','from','createdAt','warn',':root','CommentsRepository','has','comments','isResolved','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.','author','push','fetch','timezone','.ck-content','suggestions','getCommentThreads','Users','plugins'];(function(_0x29bd29,_0x2a08c3){const _0x11cc3a=function(_0x35ef9f){while(--_0x35ef9f){_0x29bd29['push'](_0x29bd29['shift']());}};_0x11cc3a(++_0x2a08c3);}(_0x2a08,0x113));const _0x11cc=function(_0x29bd29,_0x2a08c3){_0x29bd29=_0x29bd29-0x0;let _0x11cc3a=_0x2a08[_0x29bd29];return _0x11cc3a;};export function getStyles(_0x5f1cfb){if(!_0x5f1cfb)return new Promise(_0x52d656=>_0x52d656(''));const _0x5bea67=[];for(const _0x541812 of _0x5f1cfb)_0x11cc('0x1')!==_0x541812?_0x5bea67[_0x11cc('0x15')](window[_0x11cc('0x16')](_0x541812)[_0x11cc('0x24')](_0xbf1c16=>_0xbf1c16[_0x11cc('0x1d')]())):_0x5bea67['push'](u());return Promise[_0x11cc('0x9')](_0x5bea67)[_0x11cc('0x24')](_0x486772=>_0x486772[_0x11cc('0x5')]('\x20')[_0x11cc('0x21')]());}function u(){const _0x71e44f=[],_0x487fd4=[];for(const _0xc77608 of Array[_0x11cc('0xb')](document['styleSheets'])){if(_0xc77608[_0x11cc('0x25')][_0x11cc('0x8')]('data-cke'))for(const _0x2a25a0 of Array['from'](_0xc77608['cssRules']))-0x1!==_0x2a25a0[_0x11cc('0x1e')][_0x11cc('0x20')](_0x11cc('0x18'))?_0x71e44f[_0x11cc('0x15')](_0x2a25a0[_0x11cc('0x1e')]):-0x1!==_0x2a25a0[_0x11cc('0x1e')][_0x11cc('0x20')](_0x11cc('0xe'))&&_0x487fd4['push'](_0x2a25a0[_0x11cc('0x1e')]);}return _0x71e44f['length']||console[_0x11cc('0xd')](_0x11cc('0x13')),[..._0x487fd4,..._0x71e44f][_0x11cc('0x5')]('\x20')[_0x11cc('0x21')]();}export function getConverterOptions(_0xffdaea){const _0x3cf7ec=_0xffdaea[_0x11cc('0x1c')][_0x11cc('0x10')]('Users'),_0x5cc274=_0xffdaea['plugins']['has'](_0x11cc('0xf')),_0x162a89=_0xffdaea['plugins'][_0x11cc('0x10')](_0x11cc('0x3')),_0x12e818={};if(_0x3cf7ec&&_0x5cc274){const _0x5147f8=getComments(_0xffdaea[_0x11cc('0x1c')]['get'](_0x11cc('0xf'))[_0x11cc('0x1a')]({'skipNotAttached':!0x0,'skipEmpty':!0x0}));Object[_0x11cc('0x7')](_0x5147f8)[_0x11cc('0x0')]&&(_0x12e818['comments']=_0x5147f8);}if(_0x3cf7ec&&_0x162a89){const _0x575ca6=_0xffdaea[_0x11cc('0x1c')][_0x11cc('0x6')](_0x11cc('0x3')),_0x2f4d10=_0xffdaea[_0x11cc('0x1c')][_0x11cc('0x6')](_0x11cc('0x1b')),_0x4a6913=getSuggestions(_0x575ca6['getSuggestions']({'toJSON':!0x0}),_0x2f4d10[_0x11cc('0x2')]);Object[_0x11cc('0x7')](_0x4a6913)[_0x11cc('0x0')]&&(_0x12e818['suggestions']=_0x4a6913);}return(_0x12e818[_0x11cc('0x19')]||_0x12e818[_0x11cc('0x11')])&&(_0x12e818[_0x11cc('0x17')]=new Intl[(_0x11cc('0x1f'))]()['resolvedOptions']()[_0x11cc('0x23')]),_0x12e818;}export function getComments(_0x310499){const _0x2728e9={};if(!_0x310499[_0x11cc('0x0')])return _0x2728e9;for(const _0x2df373 of _0x310499)_0x2df373[_0x11cc('0x11')]['map'](_0x191b93=>{void 0x0===_0x2728e9[_0x2df373['id']]&&(_0x2728e9[_0x2df373['id']]=[]),_0x2728e9[_0x2df373['id']][_0x11cc('0x15')]({'author':_0x191b93[_0x11cc('0x14')][_0x11cc('0xa')],'content':_0x191b93[_0x11cc('0x22')],'created':_0x191b93[_0x11cc('0xc')],'is_resolved':_0x2df373[_0x11cc('0x12')]});});return _0x2728e9;}export function getSuggestions(_0xa92726,_0xe126c5){const _0x28e344={};if(!_0xa92726[_0x11cc('0x0')]||!_0xe126c5[_0x11cc('0x0')])return _0x28e344;for(const _0x2bf3bf of _0xa92726)_0x28e344[_0x2bf3bf['id']]={'author':_0xe126c5['get'](_0x2bf3bf[_0x11cc('0x4')])[_0x11cc('0xa')],'created':_0x2bf3bf[_0x11cc('0xc')]};return _0x28e344;}
|