@ckeditor/ckeditor5-import-word 38.0.1 → 38.1.1
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/import-word.js +1 -1
- package/package.json +7 -7
- package/src/augmentation.d.ts +23 -23
- package/src/importword.d.ts +99 -99
- package/src/importword.js +1 -1
- package/src/importwordcommand.d.ts +54 -54
- package/src/importwordcommand.js +1 -1
- package/src/importwordediting.d.ts +39 -39
- package/src/importwordediting.js +1 -1
- package/src/importwordui.d.ts +23 -23
- package/src/importwordui.js +1 -1
- package/src/index.d.ts +12 -12
- package/theme/icons/importword.svg +1 -1
package/build/import-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 t={847:(t,e,r)=>{"use strict";r.d(e,{Z:()=>i});var o=r(758),n=r.n(o)()((function(t){return t[1]}));n.push([t.id,":root{--ck-toolbar-spinner-size:18px}.ck-importword_status-pending{position:relative}.ck.ck-importword__spinner-container{display:none}.ck.ck-importword__spinner{border:2px solid var(--ck-color-text);border-radius:50%;border-top:2px solid transparent;height:var(--ck-toolbar-spinner-size);left:0;margin:0 auto;position:absolute;right:0;top:50%;transform:translateY(-50%);width:var(--ck-toolbar-spinner-size);z-index:1}.ck-importword_status-pending .ck.ck-importword__spinner-container{animation:rotate 1.5s linear infinite;display:block;height:var(--ck-toolbar-spinner-size);position:absolute;width:var(--ck-toolbar-spinner-size)}.ck-importword_status-pending .ck.ck-button__icon{color:transparent}@keyframes rotate{to{transform:rotate(1turn)}}",""]);const i=n},758:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var r=t(e);return e[2]?"@media ".concat(e[2]," {").concat(r,"}"):r})).join("")},e.i=function(t,r,o){"string"==typeof t&&(t=[[null,t,""]]);var n={};if(o)for(var i=0;i<this.length;i++){var s=this[i][0];null!=s&&(n[s]=!0)}for(var a=0;a<t.length;a++){var c=[].concat(t[a]);o&&n[c[0]]||(r&&(c[2]?c[2]="".concat(r," and ").concat(c[2]):c[2]=r),e.push(c))}},e}},278:(t,e,r)=>{"use strict";var o,n=function(){return void 0===o&&(o=Boolean(window&&document&&document.all&&!window.atob)),o},i=function(){var t={};return function(e){if(void 0===t[e]){var r=document.querySelector(e);if(window.HTMLIFrameElement&&r instanceof window.HTMLIFrameElement)try{r=r.contentDocument.head}catch(t){r=null}t[e]=r}return t[e]}}(),s=[];function a(t){for(var e=-1,r=0;r<s.length;r++)if(s[r].identifier===t){e=r;break}return e}function c(t,e){for(var r={},o=[],n=0;n<t.length;n++){var i=t[n],c=e.base?i[0]+e.base:i[0],l=r[c]||0,d="".concat(c," ").concat(l);r[c]=l+1;var p=a(d),u={css:i[1],media:i[2],sourceMap:i[3]};-1!==p?(s[p].references++,s[p].updater(u)):s.push({identifier:d,updater:g(u,e),references:1}),o.push(d)}return o}function l(t){var e=document.createElement("style"),o=t.attributes||{};if(void 0===o.nonce){var n=r.nc;n&&(o.nonce=n)}if(Object.keys(o).forEach((function(t){e.setAttribute(t,o[t])})),"function"==typeof t.insert)t.insert(e);else{var s=i(t.insert||"head");if(!s)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");s.appendChild(e)}return e}var d,p=(d=[],function(t,e){return d[t]=e,d.filter(Boolean).join("\n")});function u(t,e,r,o){var n=r?"":o.media?"@media ".concat(o.media," {").concat(o.css,"}"):o.css;if(t.styleSheet)t.styleSheet.cssText=p(e,n);else{var i=document.createTextNode(n),s=t.childNodes;s[e]&&t.removeChild(s[e]),s.length?t.insertBefore(i,s[e]):t.appendChild(i)}}function h(t,e,r){var o=r.css,n=r.media,i=r.sourceMap;if(n?t.setAttribute("media",n):t.removeAttribute("media"),i&&"undefined"!=typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),t.styleSheet)t.styleSheet.cssText=o;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(o))}}var m=null,f=0;function g(t,e){var r,o,n;if(e.singleton){var i=f++;r=m||(m=l(e)),o=u.bind(null,r,i,!1),n=u.bind(null,r,i,!0)}else r=l(e),o=h.bind(null,r,e),n=function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(r)};return o(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;o(t=e)}else n()}}t.exports=function(t,e){(e=e||{}).singleton||"boolean"==typeof e.singleton||(e.singleton=n());var r=c(t=t||[],e);return function(t){if(t=t||[],"[object Array]"===Object.prototype.toString.call(t)){for(var o=0;o<r.length;o++){var n=a(r[o]);s[n].references--}for(var i=c(t,e),l=0;l<r.length;l++){var d=a(r[l]);0===s[d].references&&(s[d].updater(),s.splice(d,1))}r=i}}}},945:(t,e,r)=>{t.exports=r(79)("./src/clipboard.js")},704:(t,e,r)=>{t.exports=r(79)("./src/core.js")},492:(t,e,r)=>{t.exports=r(79)("./src/engine.js")},273:(t,e,r)=>{t.exports=r(79)("./src/ui.js")},448:(t,e,r)=>{t.exports=r(79)("./src/upload.js")},209:(t,e,r)=>{t.exports=r(79)("./src/utils.js")},79:t=>{"use strict";t.exports=CKEditor5.dll}},e={};function r(o){var n=e[o];if(void 0!==n)return n.exports;var i=e[o]={id:o,exports:{}};return t[o](i,i.exports,r),i.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var o in e)r.o(e,o)&&!r.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.nc=void 0;var o={};(()=>{"use strict";r.r(o),r.d(o,{ImportWord:()=>y,ImportWordEditing:()=>b,ImportWordUI:()=>l});var t=r(704),e=r(273),n=r(448);var i=r(278),s=r.n(i),a=r(847),c={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};s()(a.Z,c);a.Z.locals;class l extends t.Plugin{static get pluginName(){return"ImportWordUI"}init(){const t=this.editor,r=t.t;t.ui.componentFactory.add("importWord",(o=>{const i=t.commands.get("importWord"),s=new n.FileDialogButtonView(o);s.set({acceptedType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.wordprocessingml.template"}),s.buttonView.set({label:r("Import from Word"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#a)"><path clip-rule="evenodd" d="m14 0 5 4.5v8.892l-1.5-1.8V6.5h-5v-5h-8v3H3V0h11Zm0 2v3h3.3L14 2Z"/><path d="M10.74 18a2.76 2.76 0 0 1-.469-.5H3V19h9.25v-.374A2.737 2.737 0 0 1 10.74 18Z"/><path clip-rule="evenodd" 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.602.602 0 0 0 1.032 0l.043-.09 1.554-4 .028-.093a.6.6 0 0 0-1.104-.43v.001ZM11.674 15.407a.75.75 0 1 0 1.152.96L14 14.96V20h1.5v-5.04l1.174 1.408a.75.75 0 1 0 1.152-.96l-2.346-2.816a.95.95 0 0 0-1.46 0l-2.346 2.815Z"/></g><defs><clipPath id="a"><path d="M0 0h20v20H0z"/></clipPath></defs></svg>',tooltip:!0}),s.buttonView.bind("isOn","isEnabled").to(i,"isBusy","isEnabled"),s.buttonView.extendTemplate({attributes:{class:[s.buttonView.bindTemplate.if("isOn","ck-importword_status-pending")]}});const a=new e.View;return a.setTemplate({tag:"span",attributes:{class:["ck","ck-importword__spinner-container"]},children:[{tag:"span",attributes:{class:["ck","ck-importword__spinner"]}}]}),s.buttonView.children.add(a),s.on("done",((e,r)=>{t.execute("importWord",r[0],{}),t.editing.view.focus()})),s}))}}var d=r(945),p=r(492),u=r(209);class h extends t.Command{constructor(t){super(t),this.set("isBusy",!1),this._importMarker=null,this._undoStepBatch=null,this._abortController=null,this.on("dataInsert",((e,r)=>{const o=new DataTransfer;o.setData("text/html",r.html);const n=this._importMarker.getRange();this.editor.model.enqueueChange(this._undoStepBatch,(e=>{this._importMarker.stopListening(),e.setSelection(n),t.editing.view.document.fire("clipboardInput",{dataTransfer:o})}))}),{priority:"low"})}refresh(){this.isEnabled=this._checkEnabled()}execute(t,e={}){if(this.isBusy)return Promise.resolve();const r=this.editor.config.get("importWord"),o={url:r.converterUrl,file:t,serviceConfig:{...e,default_styles:r.defaultStyles}};return this._prepareForImport(),this._sendImportRequest(o).then(this._handleImportResponse.bind(this)).catch(this._handleImportFailure.bind(this)).finally(this._cleanUpAfterImport.bind(this))}_checkEnabled(){if(this.isBusy)return!1;const t=this.editor.model,e=t.schema,r=t.document.selection,o=(0,u.first)(r.getSelectedBlocks());return!!o&&e.checkChild(o.parent,"paragraph")}_prepareForImport(){const t=this.editor,e=t.model,r=e.document.selection;this._abortController=new AbortController,this._undoStepBatch=t.model.createBatch({isUndoable:!0}),e.enqueueChange(this._undoStepBatch,(t=>{r.isCollapsed||e.deleteContent(r,{leaveUnmerged:!0});const o=r.getFirstPosition(),n=(0,u.first)(r.getSelectedBlocks());let i;i=n.is("element","paragraph")&&n.isEmpty?o:o.isAtStart?e.createPositionBefore(n):o.isAtEnd?e.createPositionAfter(n):t.split(o).position,this._importMarker=t.addMarker("importWord:"+(0,u.uid)(),{usingOperation:!1,affectsData:!1,range:new p.Range(i)}),this._importMarker.on("change:range",(()=>{"$graveyard"===this._importMarker.getRange().root.rootName&&this._abortController.abort()}))})),this.isBusy=!0,this.refresh()}_cleanUpAfterImport(){const t=this.editor.model;t.markers.has(this._importMarker)&&t.enqueueChange(this._undoStepBatch,(t=>{t.removeMarker(this._importMarker)})),this._importMarker=null,this._undoStepBatch=null,this._abortController=null,this.isBusy=!1,this.refresh()}_sendImportRequest({url:t,file:e,serviceConfig:r}){const o=this.editor.plugins.get("ImportWordEditing").getToken(),n=new FormData;n.set("config",JSON.stringify(r)),n.set("file",e);const i={method:"POST",headers:{},body:n,signal:this._abortController.signal};return o&&(i.headers.Authorization=o.value),fetch(t,i)}_handleImportResponse(t){return t.ok?t.json().then((t=>{this.editor.model.markers.has(this._importMarker)&&"$graveyard"!==this._importMarker.getRange().root.rootName&&this.fire("dataInsert",t)})):Promise.reject()}_handleImportFailure(){if(this._abortController.signal.aborted)return void(0,u.logWarning)("import-word-plugin-import-cancelled");const t=this.editor,e=(0,t.t)("An error occurred while importing the Word file.");t.plugins.get("Notification").showWarning(e),(0,u.logError)("import-word-plugin-conversion-failed")}}const m=["get","define","pluginName","requires","importWord","cloudServices","token","commands","plugins","https://docx-converter.cke-cs.com/v2/convert/docx-html","init","config","add","CloudServices","_token","ImportWordEditing","getToken"];var f,g;f=m,g=122,function(t){for(;--t;)f.push(f.shift())}(++g);const v=function(t,e){return m[t-=0]};class b extends t.Plugin{static get[v("0x10")](){return v("0xc")}static get[v("0x0")](){return[e.Notification,d.ClipboardPipeline,v("0xa")]}constructor(t){super(t),this[v("0xb")]=null}async[v("0x7")](){const t=this.editor;t[v("0x8")][v("0xf")](v("0x1"),{converterUrl:v("0x6"),tokenUrl:(t[v("0x8")].get(v("0x2"))||{}).tokenUrl,defaultStyles:!1}),t[v("0x4")][v("0x9")](v("0x1"),new h(t));const{tokenUrl:e}=t.config[v("0xe")]("importWord");if(e){const{tokenUrl:r}=t[v("0x8")][v("0xe")](v("0x2"))||{};this[v("0xb")]=e===r?t[v("0x5")][v("0xe")](v("0xa"))[v("0x3")]:await t[v("0x5")].get(v("0xa")).registerTokenUrl(e)}}[v("0xd")](){return this[v("0xb")]}}var x,w,_=["ImportWord","requires"];x=_,w=208,function(t){for(;--t;)x.push(x.shift())}(++w);var k=function(t,e){return _[t-=0]};class y extends t.Plugin{static get pluginName(){return k("0x0")}static get[k("0x1")](){return[b,l]}}})(),(window.CKEditor5=window.CKEditor5||{}).importWord=o})();
|
|
5
|
+
*/(()=>{var t={722:(t,e,r)=>{"use strict";r.d(e,{Z:()=>i});var o=r(758),n=r.n(o)()((function(t){return t[1]}));n.push([t.id,":root{--ck-toolbar-spinner-size:18px}.ck-importword_status-pending{position:relative}.ck.ck-importword__spinner-container{display:none}.ck.ck-importword__spinner{border:2px solid var(--ck-color-text);border-radius:50%;border-top:2px solid transparent;height:var(--ck-toolbar-spinner-size);left:0;margin:0 auto;position:absolute;right:0;top:50%;transform:translateY(-50%);width:var(--ck-toolbar-spinner-size);z-index:1}.ck-importword_status-pending .ck.ck-importword__spinner-container{animation:rotate 1.5s linear infinite;display:block;height:var(--ck-toolbar-spinner-size);position:absolute;width:var(--ck-toolbar-spinner-size)}.ck-importword_status-pending .ck.ck-button__icon{color:transparent}@keyframes rotate{to{transform:rotate(1turn)}}",""]);const i=n},758:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var r=t(e);return e[2]?"@media ".concat(e[2]," {").concat(r,"}"):r})).join("")},e.i=function(t,r,o){"string"==typeof t&&(t=[[null,t,""]]);var n={};if(o)for(var i=0;i<this.length;i++){var s=this[i][0];null!=s&&(n[s]=!0)}for(var a=0;a<t.length;a++){var c=[].concat(t[a]);o&&n[c[0]]||(r&&(c[2]?c[2]="".concat(r," and ").concat(c[2]):c[2]=r),e.push(c))}},e}},278:(t,e,r)=>{"use strict";var o,n=function(){return void 0===o&&(o=Boolean(window&&document&&document.all&&!window.atob)),o},i=function(){var t={};return function(e){if(void 0===t[e]){var r=document.querySelector(e);if(window.HTMLIFrameElement&&r instanceof window.HTMLIFrameElement)try{r=r.contentDocument.head}catch(t){r=null}t[e]=r}return t[e]}}(),s=[];function a(t){for(var e=-1,r=0;r<s.length;r++)if(s[r].identifier===t){e=r;break}return e}function c(t,e){for(var r={},o=[],n=0;n<t.length;n++){var i=t[n],c=e.base?i[0]+e.base:i[0],l=r[c]||0,d="".concat(c," ").concat(l);r[c]=l+1;var u=a(d),p={css:i[1],media:i[2],sourceMap:i[3]};-1!==u?(s[u].references++,s[u].updater(p)):s.push({identifier:d,updater:g(p,e),references:1}),o.push(d)}return o}function l(t){var e=document.createElement("style"),o=t.attributes||{};if(void 0===o.nonce){var n=r.nc;n&&(o.nonce=n)}if(Object.keys(o).forEach((function(t){e.setAttribute(t,o[t])})),"function"==typeof t.insert)t.insert(e);else{var s=i(t.insert||"head");if(!s)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");s.appendChild(e)}return e}var d,u=(d=[],function(t,e){return d[t]=e,d.filter(Boolean).join("\n")});function p(t,e,r,o){var n=r?"":o.media?"@media ".concat(o.media," {").concat(o.css,"}"):o.css;if(t.styleSheet)t.styleSheet.cssText=u(e,n);else{var i=document.createTextNode(n),s=t.childNodes;s[e]&&t.removeChild(s[e]),s.length?t.insertBefore(i,s[e]):t.appendChild(i)}}function h(t,e,r){var o=r.css,n=r.media,i=r.sourceMap;if(n?t.setAttribute("media",n):t.removeAttribute("media"),i&&"undefined"!=typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),t.styleSheet)t.styleSheet.cssText=o;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(o))}}var m=null,f=0;function g(t,e){var r,o,n;if(e.singleton){var i=f++;r=m||(m=l(e)),o=p.bind(null,r,i,!1),n=p.bind(null,r,i,!0)}else r=l(e),o=h.bind(null,r,e),n=function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(r)};return o(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;o(t=e)}else n()}}t.exports=function(t,e){(e=e||{}).singleton||"boolean"==typeof e.singleton||(e.singleton=n());var r=c(t=t||[],e);return function(t){if(t=t||[],"[object Array]"===Object.prototype.toString.call(t)){for(var o=0;o<r.length;o++){var n=a(r[o]);s[n].references--}for(var i=c(t,e),l=0;l<r.length;l++){var d=a(r[l]);0===s[d].references&&(s[d].updater(),s.splice(d,1))}r=i}}}},945:(t,e,r)=>{t.exports=r(79)("./src/clipboard.js")},704:(t,e,r)=>{t.exports=r(79)("./src/core.js")},492:(t,e,r)=>{t.exports=r(79)("./src/engine.js")},273:(t,e,r)=>{t.exports=r(79)("./src/ui.js")},448:(t,e,r)=>{t.exports=r(79)("./src/upload.js")},209:(t,e,r)=>{t.exports=r(79)("./src/utils.js")},79:t=>{"use strict";t.exports=CKEditor5.dll}},e={};function r(o){var n=e[o];if(void 0!==n)return n.exports;var i=e[o]={id:o,exports:{}};return t[o](i,i.exports,r),i.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var o in e)r.o(e,o)&&!r.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.nc=void 0;var o={};(()=>{"use strict";r.r(o),r.d(o,{ImportWord:()=>y,ImportWordEditing:()=>b,ImportWordUI:()=>l});var t=r(704),e=r(273),n=r(448);var i=r(278),s=r.n(i),a=r(722),c={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};s()(a.Z,c);a.Z.locals;class l extends t.Plugin{static get pluginName(){return"ImportWordUI"}init(){const t=this.editor,r=t.t;t.ui.componentFactory.add("importWord",(o=>{const i=t.commands.get("importWord"),s=new n.FileDialogButtonView(o);s.set({acceptedType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.wordprocessingml.template"}),s.buttonView.set({label:r("Import from Word"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m14 0 5 4.5v8.892l-1.5-1.8V6.5h-5v-5h-8v3H3V0h11Zm0 2v3h3.3L14 2Z"/><path d="M10.74 18a2.76 2.76 0 0 1-.469-.5H3V19h9.25v-.374A2.737 2.737 0 0 1 10.74 18Z"/><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.602.602 0 0 0 1.032 0l.043-.09 1.554-4 .028-.093a.6.6 0 0 0-1.104-.43v.001ZM11.674 15.407a.75.75 0 1 0 1.152.96L14 14.96V20h1.5v-5.04l1.174 1.408a.75.75 0 1 0 1.152-.96l-2.346-2.816a.95.95 0 0 0-1.46 0l-2.346 2.815Z"/></svg>\n',tooltip:!0}),s.buttonView.bind("isOn","isEnabled").to(i,"isBusy","isEnabled"),s.buttonView.extendTemplate({attributes:{class:[s.buttonView.bindTemplate.if("isOn","ck-importword_status-pending")]}});const a=new e.View;return a.setTemplate({tag:"span",attributes:{class:["ck","ck-importword__spinner-container"]},children:[{tag:"span",attributes:{class:["ck","ck-importword__spinner"]}}]}),s.buttonView.children.add(a),s.on("done",((e,r)=>{t.execute("importWord",r[0],{}),t.editing.view.focus()})),s}))}}var d=r(945),u=r(492),p=r(209);class h extends t.Command{constructor(t){super(t),this.set("isBusy",!1),this._importMarker=null,this._undoStepBatch=null,this._abortController=null,this.on("dataInsert",((e,r)=>{const o=new DataTransfer;o.setData("text/html",r.html);const n=this._importMarker.getRange();this.editor.model.enqueueChange(this._undoStepBatch,(e=>{this._importMarker.stopListening(),e.setSelection(n),t.editing.view.document.fire("clipboardInput",{dataTransfer:o})}))}),{priority:"low"})}refresh(){this.isEnabled=this._checkEnabled()}execute(t,e={}){if(this.isBusy)return Promise.resolve();const r=this.editor.config.get("importWord"),o={url:r.converterUrl,file:t,serviceConfig:{...e,default_styles:r.defaultStyles}};return this._prepareForImport(),this._sendImportRequest(o).then(this._handleImportResponse.bind(this)).catch(this._handleImportFailure.bind(this)).finally(this._cleanUpAfterImport.bind(this))}_checkEnabled(){if(this.isBusy)return!1;const t=this.editor.model,e=t.schema,r=t.document.selection,o=(0,p.first)(r.getSelectedBlocks());return!!o&&e.checkChild(o.parent,"paragraph")}_prepareForImport(){const t=this.editor,e=t.model,r=e.document.selection;this._abortController=new AbortController,this._undoStepBatch=t.model.createBatch({isUndoable:!0}),e.enqueueChange(this._undoStepBatch,(t=>{r.isCollapsed||e.deleteContent(r,{leaveUnmerged:!0});const o=r.getFirstPosition(),n=(0,p.first)(r.getSelectedBlocks());let i;i=n.is("element","paragraph")&&n.isEmpty?o:o.isAtStart?e.createPositionBefore(n):o.isAtEnd?e.createPositionAfter(n):t.split(o).position,this._importMarker=t.addMarker("importWord:"+(0,p.uid)(),{usingOperation:!1,affectsData:!1,range:new u.Range(i)}),this._importMarker.on("change:range",(()=>{"$graveyard"===this._importMarker.getRange().root.rootName&&this._abortController.abort()}))})),this.isBusy=!0,this.refresh()}_cleanUpAfterImport(){const t=this.editor.model;t.markers.has(this._importMarker)&&t.enqueueChange(this._undoStepBatch,(t=>{t.removeMarker(this._importMarker)})),this._importMarker=null,this._undoStepBatch=null,this._abortController=null,this.isBusy=!1,this.refresh()}_sendImportRequest({url:t,file:e,serviceConfig:r}){const o=this.editor.plugins.get("ImportWordEditing").getToken(),n=new FormData;n.set("config",JSON.stringify(r)),n.set("file",e);const i={method:"POST",headers:{},body:n,signal:this._abortController.signal};return o&&(i.headers.Authorization=o.value),fetch(t,i)}_handleImportResponse(t){return t.ok?t.json().then((t=>{this.editor.model.markers.has(this._importMarker)&&"$graveyard"!==this._importMarker.getRange().root.rootName&&this.fire("dataInsert",t)})):Promise.reject()}_handleImportFailure(){if(this._abortController.signal.aborted)return void(0,p.logWarning)("import-word-plugin-import-cancelled");const t=this.editor,e=(0,t.t)("An error occurred while importing the Word file.");t.plugins.get("Notification").showWarning(e),(0,p.logError)("import-word-plugin-conversion-failed")}}const m=["_token","CloudServices","token","define","cloudServices","plugins","init","get","tokenUrl","registerTokenUrl","editor","importWord","https://docx-converter.cke-cs.com/v2/convert/docx-html","pluginName","config","commands","ImportWordEditing"];var f,g;f=m,g=400,function(t){for(;--t;)f.push(f.shift())}(++g);const v=function(t,e){return m[t-=0]};class b extends t.Plugin{static get[v("0x4")](){return v("0x7")}static get requires(){return[e.Notification,d.ClipboardPipeline,v("0x9")]}constructor(t){super(t),this[v("0x8")]=null}async[v("0xe")](){const t=this[v("0x1")];t[v("0x5")][v("0xb")](v("0x2"),{converterUrl:v("0x3"),tokenUrl:(t.config.get(v("0xc"))||{})[v("0x10")],defaultStyles:!1}),t[v("0x6")].add(v("0x2"),new h(t));const{tokenUrl:e}=t[v("0x5")][v("0xf")](v("0x2"));if(e){const{tokenUrl:r}=t.config[v("0xf")](v("0xc"))||{};this[v("0x8")]=e===r?t.plugins[v("0xf")]("CloudServices")[v("0xa")]:await t[v("0xd")][v("0xf")](v("0x9"))[v("0x0")](e)}}getToken(){return this[v("0x8")]}}var x,w,_=["requires","ImportWord"];x=_,w=374,function(t){for(;--t;)x.push(x.shift())}(++w);var k=function(t,e){return _[t-=0]};class y extends t.Plugin{static get pluginName(){return k("0x1")}static get[k("0x0")](){return[b,l]}}})(),(window.CKEditor5=window.CKEditor5||{}).importWord=o})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-import-word",
|
|
3
|
-
"version": "38.
|
|
3
|
+
"version": "38.1.1",
|
|
4
4
|
"description": "Import from Word feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -29,11 +29,16 @@
|
|
|
29
29
|
],
|
|
30
30
|
"main": "src/index.js",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"ckeditor5": "
|
|
32
|
+
"ckeditor5": "38.1.1"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=16.0.0",
|
|
36
|
+
"npm": ">=5.7.1"
|
|
33
37
|
},
|
|
34
38
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
35
39
|
"author": "CKSource (https://cksource.com/)",
|
|
36
40
|
"homepage": "https://ckeditor.com/ckeditor-5",
|
|
41
|
+
"bugs": "https://support.ckeditor.com/hc/en-us/requests/new",
|
|
37
42
|
"files": [
|
|
38
43
|
"lang",
|
|
39
44
|
"src/**/*.js",
|
|
@@ -43,11 +48,6 @@
|
|
|
43
48
|
"ckeditor5-metadata.json",
|
|
44
49
|
"CHANGELOG.md"
|
|
45
50
|
],
|
|
46
|
-
"scripts": {
|
|
47
|
-
"dll:build": "webpack",
|
|
48
|
-
"build": "tsc -p ./tsconfig.json",
|
|
49
|
-
"postversion": "npm run build"
|
|
50
|
-
},
|
|
51
51
|
"types": "src/index.d.ts",
|
|
52
52
|
"obfuscated": true
|
|
53
53
|
}
|
package/src/augmentation.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
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 { ImportWordConfig, ImportWord, ImportWordEditing, ImportWordUI, ImportWordCommand } from './index';
|
|
6
|
-
declare module '@ckeditor/ckeditor5-core' {
|
|
7
|
-
interface EditorConfig {
|
|
8
|
-
/**
|
|
9
|
-
* The configuration of the {@link module:import-word/importword~ImportWord import from Word feature}.
|
|
10
|
-
*
|
|
11
|
-
* Read more in {@link module:import-word/importword~ImportWordConfig}.
|
|
12
|
-
*/
|
|
13
|
-
importWord?: ImportWordConfig;
|
|
14
|
-
}
|
|
15
|
-
interface PluginsMap {
|
|
16
|
-
[ImportWord.pluginName]: ImportWord;
|
|
17
|
-
[ImportWordEditing.pluginName]: ImportWordEditing;
|
|
18
|
-
[ImportWordUI.pluginName]: ImportWordUI;
|
|
19
|
-
}
|
|
20
|
-
interface CommandsMap {
|
|
21
|
-
importWord: ImportWordCommand;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
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 { ImportWordConfig, ImportWord, ImportWordEditing, ImportWordUI, ImportWordCommand } from './index';
|
|
6
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
7
|
+
interface EditorConfig {
|
|
8
|
+
/**
|
|
9
|
+
* The configuration of the {@link module:import-word/importword~ImportWord import from Word feature}.
|
|
10
|
+
*
|
|
11
|
+
* Read more in {@link module:import-word/importword~ImportWordConfig}.
|
|
12
|
+
*/
|
|
13
|
+
importWord?: ImportWordConfig;
|
|
14
|
+
}
|
|
15
|
+
interface PluginsMap {
|
|
16
|
+
[ImportWord.pluginName]: ImportWord;
|
|
17
|
+
[ImportWordEditing.pluginName]: ImportWordEditing;
|
|
18
|
+
[ImportWordUI.pluginName]: ImportWordUI;
|
|
19
|
+
}
|
|
20
|
+
interface CommandsMap {
|
|
21
|
+
importWord: ImportWordCommand;
|
|
22
|
+
}
|
|
23
|
+
}
|
package/src/importword.d.ts
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
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 import-word/importword
|
|
7
|
-
* @publicApi
|
|
8
|
-
*/
|
|
9
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
10
|
-
import type { TokenUrl } from '@ckeditor/ckeditor5-cloud-services';
|
|
11
|
-
import ImportWordUI from './importwordui';
|
|
12
|
-
import ImportWordEditing from './importwordediting';
|
|
13
|
-
/**
|
|
14
|
-
* The import from Word feature.
|
|
15
|
-
*
|
|
16
|
-
* It allows importing content from a Word file directly into CKEditor 5.
|
|
17
|
-
*
|
|
18
|
-
* This is a "glue" plugin which enables:
|
|
19
|
-
*
|
|
20
|
-
* * {@link module:import-word/importwordediting~ImportWordEditing},
|
|
21
|
-
* * {@link module:import-word/importwordui~ImportWordUI},
|
|
22
|
-
*
|
|
23
|
-
* For a detailed overview, check the {@glink features/converters/import-word/import-word import from Word} feature documentation.
|
|
24
|
-
*/
|
|
25
|
-
export default class ImportWord extends Plugin {
|
|
26
|
-
/**
|
|
27
|
-
* @inheritDoc
|
|
28
|
-
*/
|
|
29
|
-
static get pluginName():
|
|
30
|
-
/**
|
|
31
|
-
* @inheritDoc
|
|
32
|
-
*/
|
|
33
|
-
static get requires():
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* The configuration of the {@link module:import-word/importword~ImportWord import from Word feature}.
|
|
37
|
-
*
|
|
38
|
-
* The configuration for the import from Word feature requires providing the
|
|
39
|
-
* {@link module:import-word/importword~ImportWordConfig#tokenUrl `config.importWord.tokenUrl`}:
|
|
40
|
-
*
|
|
41
|
-
* ```ts
|
|
42
|
-
* ClassicEditor
|
|
43
|
-
* .create( editorElement, {
|
|
44
|
-
* importWord: {
|
|
45
|
-
* tokenUrl: 'https://example.com/cs-token-endpoint'
|
|
46
|
-
* }
|
|
47
|
-
* } )
|
|
48
|
-
* .then( ... )
|
|
49
|
-
* .catch( ... );
|
|
50
|
-
* ```
|
|
51
|
-
*
|
|
52
|
-
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
|
53
|
-
*/
|
|
54
|
-
export interface ImportWordConfig {
|
|
55
|
-
/**
|
|
56
|
-
* A URL to the Docx converter.
|
|
57
|
-
*
|
|
58
|
-
* ```ts
|
|
59
|
-
* const importWordConfig = {
|
|
60
|
-
* converterUrl: 'https://myconverter.com/v1/'
|
|
61
|
-
* }
|
|
62
|
-
* ```
|
|
63
|
-
*
|
|
64
|
-
* **Note:** The plugin uses the default Word to HTML converter delivered by CKEditor Cloud Services.
|
|
65
|
-
* You can provide a URL to an on-premises converter instead.
|
|
66
|
-
*
|
|
67
|
-
* @default 'https://docx-converter.cke-cs.com/v2/convert/docx-html'
|
|
68
|
-
*/
|
|
69
|
-
converterUrl?: string;
|
|
70
|
-
/**
|
|
71
|
-
* A token URL or a token request function. This field is optional and should be used only when a different `tokenUrl`
|
|
72
|
-
* is required for the Import from Word feature.
|
|
73
|
-
*
|
|
74
|
-
* **Note:** The token can be disabled with the `false` value provided.
|
|
75
|
-
*
|
|
76
|
-
* See: {@link module:cloud-services/cloudservicesconfig~CloudServicesConfig#tokenUrl}
|
|
77
|
-
*/
|
|
78
|
-
tokenUrl?: TokenUrl;
|
|
79
|
-
/**
|
|
80
|
-
* If `true`, the converter service preserves the default styles and formatting of the imported Word document.
|
|
81
|
-
*
|
|
82
|
-
* @default false
|
|
83
|
-
*/
|
|
84
|
-
defaultStyles?: boolean;
|
|
85
|
-
/**
|
|
86
|
-
* Defines which formatting styles should be kept for the imported comments text.
|
|
87
|
-
*
|
|
88
|
-
* Possible values are:
|
|
89
|
-
*
|
|
90
|
-
* * `'basic'` - basic styles are kept (bold, italic, underline, strikethrough and links),
|
|
91
|
-
* * `'none'` - comment text is imported without any styling,
|
|
92
|
-
* * `'full'` - all styles are kept (not recommended).
|
|
93
|
-
*
|
|
94
|
-
* **Note:** Please remember that importing comments requires installing the {@link module:comments/comments~Comments} feature.
|
|
95
|
-
*
|
|
96
|
-
* @default 'basic'
|
|
97
|
-
*/
|
|
98
|
-
commentsStyles?: 'basic' | 'none' | 'full';
|
|
99
|
-
}
|
|
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 import-word/importword
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
10
|
+
import type { TokenUrl } from '@ckeditor/ckeditor5-cloud-services';
|
|
11
|
+
import ImportWordUI from './importwordui';
|
|
12
|
+
import ImportWordEditing from './importwordediting';
|
|
13
|
+
/**
|
|
14
|
+
* The import from Word feature.
|
|
15
|
+
*
|
|
16
|
+
* It allows importing content from a Word file directly into CKEditor 5.
|
|
17
|
+
*
|
|
18
|
+
* This is a "glue" plugin which enables:
|
|
19
|
+
*
|
|
20
|
+
* * {@link module:import-word/importwordediting~ImportWordEditing},
|
|
21
|
+
* * {@link module:import-word/importwordui~ImportWordUI},
|
|
22
|
+
*
|
|
23
|
+
* For a detailed overview, check the {@glink features/converters/import-word/import-word import from Word} feature documentation.
|
|
24
|
+
*/
|
|
25
|
+
export default class ImportWord extends Plugin {
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
static get pluginName(): "ImportWord";
|
|
30
|
+
/**
|
|
31
|
+
* @inheritDoc
|
|
32
|
+
*/
|
|
33
|
+
static get requires(): readonly [typeof ImportWordEditing, typeof ImportWordUI];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The configuration of the {@link module:import-word/importword~ImportWord import from Word feature}.
|
|
37
|
+
*
|
|
38
|
+
* The configuration for the import from Word feature requires providing the
|
|
39
|
+
* {@link module:import-word/importword~ImportWordConfig#tokenUrl `config.importWord.tokenUrl`}:
|
|
40
|
+
*
|
|
41
|
+
* ```ts
|
|
42
|
+
* ClassicEditor
|
|
43
|
+
* .create( editorElement, {
|
|
44
|
+
* importWord: {
|
|
45
|
+
* tokenUrl: 'https://example.com/cs-token-endpoint'
|
|
46
|
+
* }
|
|
47
|
+
* } )
|
|
48
|
+
* .then( ... )
|
|
49
|
+
* .catch( ... );
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
|
53
|
+
*/
|
|
54
|
+
export interface ImportWordConfig {
|
|
55
|
+
/**
|
|
56
|
+
* A URL to the Docx converter.
|
|
57
|
+
*
|
|
58
|
+
* ```ts
|
|
59
|
+
* const importWordConfig = {
|
|
60
|
+
* converterUrl: 'https://myconverter.com/v1/'
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* **Note:** The plugin uses the default Word to HTML converter delivered by CKEditor Cloud Services.
|
|
65
|
+
* You can provide a URL to an on-premises converter instead.
|
|
66
|
+
*
|
|
67
|
+
* @default 'https://docx-converter.cke-cs.com/v2/convert/docx-html'
|
|
68
|
+
*/
|
|
69
|
+
converterUrl?: string;
|
|
70
|
+
/**
|
|
71
|
+
* A token URL or a token request function. This field is optional and should be used only when a different `tokenUrl`
|
|
72
|
+
* is required for the Import from Word feature.
|
|
73
|
+
*
|
|
74
|
+
* **Note:** The token can be disabled with the `false` value provided.
|
|
75
|
+
*
|
|
76
|
+
* See: {@link module:cloud-services/cloudservicesconfig~CloudServicesConfig#tokenUrl}
|
|
77
|
+
*/
|
|
78
|
+
tokenUrl?: TokenUrl;
|
|
79
|
+
/**
|
|
80
|
+
* If `true`, the converter service preserves the default styles and formatting of the imported Word document.
|
|
81
|
+
*
|
|
82
|
+
* @default false
|
|
83
|
+
*/
|
|
84
|
+
defaultStyles?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Defines which formatting styles should be kept for the imported comments text.
|
|
87
|
+
*
|
|
88
|
+
* Possible values are:
|
|
89
|
+
*
|
|
90
|
+
* * `'basic'` - basic styles are kept (bold, italic, underline, strikethrough and links),
|
|
91
|
+
* * `'none'` - comment text is imported without any styling,
|
|
92
|
+
* * `'full'` - all styles are kept (not recommended).
|
|
93
|
+
*
|
|
94
|
+
* **Note:** Please remember that importing comments requires installing the {@link module:comments/comments~Comments} feature.
|
|
95
|
+
*
|
|
96
|
+
* @default 'basic'
|
|
97
|
+
*/
|
|
98
|
+
commentsStyles?: 'basic' | 'none' | 'full';
|
|
99
|
+
}
|
package/src/importword.js
CHANGED
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
var
|
|
23
|
+
var _0x57ba=['requires','ImportWord'];(function(_0x41309e,_0x57bab6){var _0x4a9018=function(_0x44589e){while(--_0x44589e){_0x41309e['push'](_0x41309e['shift']());}};_0x4a9018(++_0x57bab6);}(_0x57ba,0x176));var _0x4a90=function(_0x41309e,_0x57bab6){_0x41309e=_0x41309e-0x0;var _0x4a9018=_0x57ba[_0x41309e];return _0x4a9018;};import{Plugin as _0x274dd4}from'ckeditor5/src/core';import _0x11d3b5 from'./importwordui';import _0x4092db from'./importwordediting';export default class i extends _0x274dd4{static get['pluginName'](){return _0x4a90('0x1');}static get[_0x4a90('0x0')](){return[_0x4092db,_0x11d3b5];}}
|
|
@@ -1,54 +1,54 @@
|
|
|
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 import-word/importwordcommand
|
|
7
|
-
* @publicApi
|
|
8
|
-
*/
|
|
9
|
-
import { Command, type Editor } from 'ckeditor5/src/core';
|
|
10
|
-
/**
|
|
11
|
-
* The import from Word command.
|
|
12
|
-
*
|
|
13
|
-
* It sends the Word file to the converter endpoint and inserts its content into the editor.
|
|
14
|
-
*/
|
|
15
|
-
export default class ImportWordCommand extends Command {
|
|
16
|
-
/**
|
|
17
|
-
* A command state that indicates if the command is currently executing.
|
|
18
|
-
*
|
|
19
|
-
* @observable
|
|
20
|
-
*/
|
|
21
|
-
isBusy: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* @inheritDoc
|
|
24
|
-
*/
|
|
25
|
-
constructor(editor: Editor);
|
|
26
|
-
/**
|
|
27
|
-
* @inheritDoc
|
|
28
|
-
*/
|
|
29
|
-
refresh(): void;
|
|
30
|
-
/**
|
|
31
|
-
* Executes the command. Sends the provided file instance to the converter service endpoint and inserts the result into the model.
|
|
32
|
-
*
|
|
33
|
-
* @fires execute
|
|
34
|
-
* @param file The Word file instance to be uploaded for conversion.
|
|
35
|
-
* @param [serviceConfig] Additional options to pass to the converter service.
|
|
36
|
-
*/
|
|
37
|
-
execute(file: File, serviceConfig?: Record<string, unknown>): Promise<unknown>;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Fired when the converter service returned the HTML content that will be inserted into the editor.
|
|
41
|
-
*
|
|
42
|
-
* @eventName ~ImportWordCommand#dataInsert
|
|
43
|
-
*/
|
|
44
|
-
export type DataInsertEvent = {
|
|
45
|
-
name: 'dataInsert';
|
|
46
|
-
args: [data: DataInsertEventData];
|
|
47
|
-
};
|
|
48
|
-
interface DataInsertEventData {
|
|
49
|
-
/**
|
|
50
|
-
* The HTML content to insertion.
|
|
51
|
-
*/
|
|
52
|
-
html: string;
|
|
53
|
-
}
|
|
54
|
-
export {};
|
|
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 import-word/importwordcommand
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
import { Command, type Editor } from 'ckeditor5/src/core';
|
|
10
|
+
/**
|
|
11
|
+
* The import from Word command.
|
|
12
|
+
*
|
|
13
|
+
* It sends the Word file to the converter endpoint and inserts its content into the editor.
|
|
14
|
+
*/
|
|
15
|
+
export default class ImportWordCommand extends Command {
|
|
16
|
+
/**
|
|
17
|
+
* A command state that indicates if the command is currently executing.
|
|
18
|
+
*
|
|
19
|
+
* @observable
|
|
20
|
+
*/
|
|
21
|
+
isBusy: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
constructor(editor: Editor);
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
refresh(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Executes the command. Sends the provided file instance to the converter service endpoint and inserts the result into the model.
|
|
32
|
+
*
|
|
33
|
+
* @fires execute
|
|
34
|
+
* @param file The Word file instance to be uploaded for conversion.
|
|
35
|
+
* @param [serviceConfig] Additional options to pass to the converter service.
|
|
36
|
+
*/
|
|
37
|
+
execute(file: File, serviceConfig?: Record<string, unknown>): Promise<unknown>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Fired when the converter service returned the HTML content that will be inserted into the editor.
|
|
41
|
+
*
|
|
42
|
+
* @eventName ~ImportWordCommand#dataInsert
|
|
43
|
+
*/
|
|
44
|
+
export type DataInsertEvent = {
|
|
45
|
+
name: 'dataInsert';
|
|
46
|
+
args: [data: DataInsertEventData];
|
|
47
|
+
};
|
|
48
|
+
interface DataInsertEventData {
|
|
49
|
+
/**
|
|
50
|
+
* The HTML content to insertion.
|
|
51
|
+
*/
|
|
52
|
+
html: string;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
package/src/importwordcommand.js
CHANGED
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
import{Command as
|
|
23
|
+
import{Command as _0x495c43}from'ckeditor5/src/core';import{Range as _0x1ef87e}from'ckeditor5/src/engine';import{logWarning as _0x138458,logError as _0x500d7c,first as _0xb552ec,uid as _0x2166c}from'ckeditor5/src/utils';export default class d extends _0x495c43{constructor(_0x518603){super(_0x518603),this['set']('isBusy',!0x1),this['_importMarker']=null,this['_undoStepBatch']=null,this['_abortController']=null,this['on']('dataInsert',(_0x39289a,_0x190c2d)=>{const _0x22c462=new DataTransfer();_0x22c462['setData']('text/html',_0x190c2d['html']);const _0x4dea98=this['_importMarker']['getRange']();this['editor']['model']['enqueueChange'](this['_undoStepBatch'],_0x147755=>{this['_importMarker']['stopListening'](),_0x147755['setSelection'](_0x4dea98),_0x518603['editing']['view']['document']['fire']('clipboardInput',{'dataTransfer':_0x22c462});});},{'priority':'low'});}['refresh'](){this['isEnabled']=this['_checkEnabled']();}['execute'](_0x55e62e,_0x7941e9={}){if(this['isBusy'])return Promise['resolve']();const _0x5d32f6=this['editor']['config']['get']('importWord'),_0x2a58f7={'url':_0x5d32f6['converterUrl'],'file':_0x55e62e,'serviceConfig':{..._0x7941e9,'default_styles':_0x5d32f6['defaultStyles']}};return this['_prepareForImport'](),this['_sendImportRequest'](_0x2a58f7)['then'](this['_handleImportResponse']['bind'](this))['catch'](this['_handleImportFailure']['bind'](this))['finally'](this['_cleanUpAfterImport']['bind'](this));}['_checkEnabled'](){if(this['isBusy'])return!0x1;const _0x40e477=this['editor']['model'],_0x59b207=_0x40e477['schema'],_0x2890ee=_0x40e477['document']['selection'],_0x4d42d8=_0xb552ec(_0x2890ee['getSelectedBlocks']());return!!_0x4d42d8&&_0x59b207['checkChild'](_0x4d42d8['parent'],'paragraph');}['_prepareForImport'](){const _0x4136c1=this['editor'],_0x381e16=_0x4136c1['model'],_0x57a125=_0x381e16['document']['selection'];this['_abortController']=new AbortController(),this['_undoStepBatch']=_0x4136c1['model']['createBatch']({'isUndoable':!0x0}),_0x381e16['enqueueChange'](this['_undoStepBatch'],_0x3fac04=>{_0x57a125['isCollapsed']||_0x381e16['deleteContent'](_0x57a125,{'leaveUnmerged':!0x0});const _0x3e5f19=_0x57a125['getFirstPosition'](),_0x5ba18a=_0xb552ec(_0x57a125['getSelectedBlocks']());let _0x28b973;_0x28b973=_0x5ba18a['is']('element','paragraph')&&_0x5ba18a['isEmpty']?_0x3e5f19:_0x3e5f19['isAtStart']?_0x381e16['createPositionBefore'](_0x5ba18a):_0x3e5f19['isAtEnd']?_0x381e16['createPositionAfter'](_0x5ba18a):_0x3fac04['split'](_0x3e5f19)['position'],this['_importMarker']=_0x3fac04['addMarker']('importWord:'+_0x2166c(),{'usingOperation':!0x1,'affectsData':!0x1,'range':new _0x1ef87e(_0x28b973)}),this['_importMarker']['on']('change:range',()=>{'$graveyard'===this['_importMarker']['getRange']()['root']['rootName']&&this['_abortController']['abort']();});}),this['isBusy']=!0x0,this['refresh']();}['_cleanUpAfterImport'](){const _0x1e37c2=this['editor']['model'];_0x1e37c2['markers']['has'](this['_importMarker'])&&_0x1e37c2['enqueueChange'](this['_undoStepBatch'],_0x13a5a5=>{_0x13a5a5['removeMarker'](this['_importMarker']);}),this['_importMarker']=null,this['_undoStepBatch']=null,this['_abortController']=null,this['isBusy']=!0x1,this['refresh']();}['_sendImportRequest']({url:_0x12a377,file:_0x52c828,serviceConfig:_0x20bed5}){const _0x2cfb25=this['editor']['plugins']['get']('ImportWordEditing')['getToken'](),_0xd4456e=new FormData();_0xd4456e['set']('config',JSON['stringify'](_0x20bed5)),_0xd4456e['set']('file',_0x52c828);const _0x39d96d={'method':'POST','headers':{},'body':_0xd4456e,'signal':this['_abortController']['signal']};return _0x2cfb25&&(_0x39d96d['headers']['Authorization']=_0x2cfb25['value']),fetch(_0x12a377,_0x39d96d);}['_handleImportResponse'](_0x3bb0c1){return _0x3bb0c1['ok']?_0x3bb0c1['json']()['then'](_0x382692=>{if(!this['editor']['model']['markers']['has'](this['_importMarker']))return;'$graveyard'!==this['_importMarker']['getRange']()['root']['rootName']&&this['fire']('dataInsert',_0x382692);}):Promise['reject']();}['_handleImportFailure'](){if(this['_abortController']['signal']['aborted'])return void _0x138458('import-word-plugin-import-cancelled');const _0x531977=this['editor'],_0x3c097b=(0x0,_0x531977['t'])('An\x20error\x20occurred\x20while\x20importing\x20the\x20Word\x20file.');_0x531977['plugins']['get']('Notification')['showWarning'](_0x3c097b),_0x500d7c('import-word-plugin-conversion-failed');}}
|
|
@@ -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 import-word/importwordediting
|
|
7
|
-
* @publicApi
|
|
8
|
-
*/
|
|
9
|
-
import { Plugin, type Editor } from 'ckeditor5/src/core';
|
|
10
|
-
import { Notification } from 'ckeditor5/src/ui';
|
|
11
|
-
import { ClipboardPipeline } from 'ckeditor5/src/clipboard';
|
|
12
|
-
import type { InitializedToken } from '@ckeditor/ckeditor5-cloud-services';
|
|
13
|
-
/**
|
|
14
|
-
* The editing part of the import from Word feature.
|
|
15
|
-
*
|
|
16
|
-
* It registers the {@link module:import-word/importwordcommand~ImportWordCommand `'importWord'` command}.
|
|
17
|
-
*/
|
|
18
|
-
export default class ImportWordEditing extends Plugin {
|
|
19
|
-
/**
|
|
20
|
-
* @inheritDoc
|
|
21
|
-
*/
|
|
22
|
-
static get pluginName():
|
|
23
|
-
/**
|
|
24
|
-
* @inheritDoc
|
|
25
|
-
*/
|
|
26
|
-
static get requires():
|
|
27
|
-
/**
|
|
28
|
-
* @inheritDoc
|
|
29
|
-
*/
|
|
30
|
-
constructor(editor: Editor);
|
|
31
|
-
/**
|
|
32
|
-
* @inheritDoc
|
|
33
|
-
*/
|
|
34
|
-
init(): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* Returns a token used by the import from Word plugin for communication with the Cloud Services.
|
|
37
|
-
*/
|
|
38
|
-
getToken(): InitializedToken | null;
|
|
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 import-word/importwordediting
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
import { Plugin, type Editor } from 'ckeditor5/src/core';
|
|
10
|
+
import { Notification } from 'ckeditor5/src/ui';
|
|
11
|
+
import { ClipboardPipeline } from 'ckeditor5/src/clipboard';
|
|
12
|
+
import type { InitializedToken } from '@ckeditor/ckeditor5-cloud-services';
|
|
13
|
+
/**
|
|
14
|
+
* The editing part of the import from Word feature.
|
|
15
|
+
*
|
|
16
|
+
* It registers the {@link module:import-word/importwordcommand~ImportWordCommand `'importWord'` command}.
|
|
17
|
+
*/
|
|
18
|
+
export default class ImportWordEditing extends Plugin {
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
static get pluginName(): "ImportWordEditing";
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
static get requires(): readonly [typeof Notification, typeof ClipboardPipeline, "CloudServices"];
|
|
27
|
+
/**
|
|
28
|
+
* @inheritDoc
|
|
29
|
+
*/
|
|
30
|
+
constructor(editor: Editor);
|
|
31
|
+
/**
|
|
32
|
+
* @inheritDoc
|
|
33
|
+
*/
|
|
34
|
+
init(): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Returns a token used by the import from Word plugin for communication with the Cloud Services.
|
|
37
|
+
*/
|
|
38
|
+
getToken(): InitializedToken | null;
|
|
39
|
+
}
|
package/src/importwordediting.js
CHANGED
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
const
|
|
23
|
+
const _0x5c8a=['_token','CloudServices','token','define','cloudServices','plugins','init','get','tokenUrl','registerTokenUrl','editor','importWord','https://docx-converter.cke-cs.com/v2/convert/docx-html','pluginName','config','commands','ImportWordEditing'];(function(_0x477a54,_0x5c8af5){const _0x20de5c=function(_0x5171c6){while(--_0x5171c6){_0x477a54['push'](_0x477a54['shift']());}};_0x20de5c(++_0x5c8af5);}(_0x5c8a,0x190));const _0x20de=function(_0x477a54,_0x5c8af5){_0x477a54=_0x477a54-0x0;let _0x20de5c=_0x5c8a[_0x477a54];return _0x20de5c;};import{Plugin as _0x4ed8e3}from'ckeditor5/src/core';import{Notification as _0x3e5868}from'ckeditor5/src/ui';import{ClipboardPipeline as _0x4261e2}from'ckeditor5/src/clipboard';import _0x107311 from'./importwordcommand';export default class e extends _0x4ed8e3{static get[_0x20de('0x4')](){return _0x20de('0x7');}static get['requires'](){return[_0x3e5868,_0x4261e2,_0x20de('0x9')];}constructor(_0x2f1d87){super(_0x2f1d87),this[_0x20de('0x8')]=null;}async[_0x20de('0xe')](){const _0x1c5e77=this[_0x20de('0x1')];_0x1c5e77[_0x20de('0x5')][_0x20de('0xb')](_0x20de('0x2'),{'converterUrl':_0x20de('0x3'),'tokenUrl':(_0x1c5e77['config']['get'](_0x20de('0xc'))||{})[_0x20de('0x10')],'defaultStyles':!0x1}),_0x1c5e77[_0x20de('0x6')]['add'](_0x20de('0x2'),new _0x107311(_0x1c5e77));const {tokenUrl:_0x296d10}=_0x1c5e77[_0x20de('0x5')][_0x20de('0xf')](_0x20de('0x2'));if(_0x296d10){const {tokenUrl:_0x1a747a}=_0x1c5e77['config'][_0x20de('0xf')](_0x20de('0xc'))||{};this[_0x20de('0x8')]=_0x296d10===_0x1a747a?_0x1c5e77['plugins'][_0x20de('0xf')]('CloudServices')[_0x20de('0xa')]:await _0x1c5e77[_0x20de('0xd')][_0x20de('0xf')](_0x20de('0x9'))[_0x20de('0x0')](_0x296d10);}}['getToken'](){return this[_0x20de('0x8')];}}
|
package/src/importwordui.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
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 import-word/importwordui
|
|
7
|
-
* @publicApi
|
|
8
|
-
*/
|
|
9
|
-
import { Plugin } from 'ckeditor5/src/core';
|
|
10
|
-
import '../theme/importword.css';
|
|
11
|
-
/**
|
|
12
|
-
* The ImportWordUI plugin. It introduces the `'importWord'` toolbar button.
|
|
13
|
-
*/
|
|
14
|
-
export default class ImportWordUI extends Plugin {
|
|
15
|
-
/**
|
|
16
|
-
* @inheritDoc
|
|
17
|
-
*/
|
|
18
|
-
static get pluginName():
|
|
19
|
-
/**
|
|
20
|
-
* @inheritDoc
|
|
21
|
-
*/
|
|
22
|
-
init(): void;
|
|
23
|
-
}
|
|
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 import-word/importwordui
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
10
|
+
import '../theme/importword.css';
|
|
11
|
+
/**
|
|
12
|
+
* The ImportWordUI plugin. It introduces the `'importWord'` toolbar button.
|
|
13
|
+
*/
|
|
14
|
+
export default class ImportWordUI extends Plugin {
|
|
15
|
+
/**
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
18
|
+
static get pluginName(): "ImportWordUI";
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
init(): void;
|
|
23
|
+
}
|
package/src/importwordui.js
CHANGED
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
import{Plugin as
|
|
23
|
+
import{Plugin as _0x5ea9da}from'ckeditor5/src/core';import{View as _0x19da1c}from'ckeditor5/src/ui';import{FileDialogButtonView as _0x4a9a28}from'ckeditor5/src/upload';import _0x1eeaa3 from'../theme/icons/importword.svg';import'../theme/importword.css';export default class o extends _0x5ea9da{static get['pluginName'](){return'ImportWordUI';}['init'](){const _0x57094d=this['editor'],t=_0x57094d['t'];_0x57094d['ui']['componentFactory']['add']('importWord',_0x2075ef=>{const _0x1ee81d=_0x57094d['commands']['get']('importWord'),_0x4147e0=new _0x4a9a28(_0x2075ef);_0x4147e0['set']({'acceptedType':'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.wordprocessingml.template'}),_0x4147e0['buttonView']['set']({'label':t('Import\x20from\x20Word'),'icon':_0x1eeaa3,'tooltip':!0x0}),_0x4147e0['buttonView']['bind']('isOn','isEnabled')['to'](_0x1ee81d,'isBusy','isEnabled'),_0x4147e0['buttonView']['extendTemplate']({'attributes':{'class':[_0x4147e0['buttonView']['bindTemplate']['if']('isOn','ck-importword_status-pending')]}});const _0x7153e0=new _0x19da1c();return _0x7153e0['setTemplate']({'tag':'span','attributes':{'class':['ck','ck-importword__spinner-container']},'children':[{'tag':'span','attributes':{'class':['ck','ck-importword__spinner']}}]}),_0x4147e0['buttonView']['children']['add'](_0x7153e0),_0x4147e0['on']('done',(_0x507e2d,_0x45ba23)=>{_0x57094d['execute']('importWord',_0x45ba23[0x0],{}),_0x57094d['editing']['view']['focus']();}),_0x4147e0;});}}
|
package/src/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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 import-word
|
|
7
|
-
*/
|
|
8
|
-
export { default as ImportWord, type ImportWordConfig } from './importword';
|
|
9
|
-
export { default as ImportWordEditing } from './importwordediting';
|
|
10
|
-
export { default as ImportWordUI } from './importwordui';
|
|
11
|
-
export type { default as ImportWordCommand } from './importwordcommand';
|
|
12
|
-
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 import-word
|
|
7
|
+
*/
|
|
8
|
+
export { default as ImportWord, type ImportWordConfig } from './importword';
|
|
9
|
+
export { default as ImportWordEditing } from './importwordediting';
|
|
10
|
+
export { default as ImportWordUI } from './importwordui';
|
|
11
|
+
export type { default as ImportWordCommand } from './importwordcommand';
|
|
12
|
+
import './augmentation';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><
|
|
1
|
+
<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m14 0 5 4.5v8.892l-1.5-1.8V6.5h-5v-5h-8v3H3V0h11Zm0 2v3h3.3L14 2Z"/><path d="M10.74 18a2.76 2.76 0 0 1-.469-.5H3V19h9.25v-.374A2.737 2.737 0 0 1 10.74 18Z"/><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.602.602 0 0 0 1.032 0l.043-.09 1.554-4 .028-.093a.6.6 0 0 0-1.104-.43v.001ZM11.674 15.407a.75.75 0 1 0 1.152.96L14 14.96V20h1.5v-5.04l1.174 1.408a.75.75 0 1 0 1.152-.96l-2.346-2.816a.95.95 0 0 0-1.46 0l-2.346 2.815Z"/></svg>
|