@ckeditor/ckeditor5-export-pdf 39.0.2 → 40.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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={861:(t,e,n)=>{"use strict";n.d(e,{Z:()=>i});var r=n(758),o=n.n(r)()((function(t){return t[1]}));o.push([t.id,":root{--ck-toolbar-spinner-size:18px}.ck-exportpdf_status-pending{position:relative}.ck.ck-exportpdf__spinner-container{display:none}.ck.ck-exportpdf__spinner{border:2px solid var(--ck-color-text);border-radius:50%;border-top:2px solid transparent;left:0;margin:0 auto;right:0;top:50%;transform:translateY(-50%);z-index:1}.ck-exportpdf_status-pending .ck.ck-exportpdf__spinner-container,.ck.ck-exportpdf__spinner{height:var(--ck-toolbar-spinner-size);position:absolute;width:var(--ck-toolbar-spinner-size)}.ck-exportpdf_status-pending .ck.ck-exportpdf__spinner-container{animation:rotate 1.5s linear infinite;display:block}.ck-exportpdf_status-pending .ck.ck-button__icon{color:transparent}@keyframes rotate{to{transform:rotate(1turn)}}",""]);const i=o},758:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n=t(e);return e[2]?"@media ".concat(e[2]," {").concat(n,"}"):n})).join("")},e.i=function(t,n,r){"string"==typeof t&&(t=[[null,t,""]]);var o={};if(r)for(var i=0;i<this.length;i++){var s=this[i][0];null!=s&&(o[s]=!0)}for(var a=0;a<t.length;a++){var c=[].concat(t[a]);r&&o[c[0]]||(n&&(c[2]?c[2]="".concat(n," and ").concat(c[2]):c[2]=n),e.push(c))}},e}},278:(t,e,n)=>{"use strict";var r,o=function(){return void 0===r&&(r=Boolean(window&&document&&document.all&&!window.atob)),r},i=function(){var t={};return function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}t[e]=n}return t[e]}}(),s=[];function a(t){for(var e=-1,n=0;n<s.length;n++)if(s[n].identifier===t){e=n;break}return e}function c(t,e){for(var n={},r=[],o=0;o<t.length;o++){var i=t[o],c=e.base?i[0]+e.base:i[0],d=n[c]||0,l="".concat(c," ").concat(d);n[c]=d+1;var u=a(l),p={css:i[1],media:i[2],sourceMap:i[3]};-1!==u?(s[u].references++,s[u].updater(p)):s.push({identifier:l,updater:x(p,e),references:1}),r.push(l)}return r}function d(t){var e=document.createElement("style"),r=t.attributes||{};if(void 0===r.nonce){var o=n.nc;o&&(r.nonce=o)}if(Object.keys(r).forEach((function(t){e.setAttribute(t,r[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 l,u=(l=[],function(t,e){return l[t]=e,l.filter(Boolean).join("\n")});function p(t,e,n,r){var o=n?"":r.media?"@media ".concat(r.media," {").concat(r.css,"}"):r.css;if(t.styleSheet)t.styleSheet.cssText=u(e,o);else{var i=document.createTextNode(o),s=t.childNodes;s[e]&&t.removeChild(s[e]),s.length?t.insertBefore(i,s[e]):t.appendChild(i)}}function f(t,e,n){var r=n.css,o=n.media,i=n.sourceMap;if(o?t.setAttribute("media",o):t.removeAttribute("media"),i&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),t.styleSheet)t.styleSheet.cssText=r;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(r))}}var h=null,v=0;function x(t,e){var n,r,o;if(e.singleton){var i=v++;n=h||(h=d(e)),r=p.bind(null,n,i,!1),o=p.bind(null,n,i,!0)}else n=d(e),r=f.bind(null,n,e),o=function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(n)};return r(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;r(t=e)}else o()}}t.exports=function(t,e){(e=e||{}).singleton||"boolean"==typeof e.singleton||(e.singleton=o());var n=c(t=t||[],e);return function(t){if(t=t||[],"[object Array]"===Object.prototype.toString.call(t)){for(var r=0;r<n.length;r++){var o=a(n[r]);s[o].references--}for(var i=c(t,e),d=0;d<n.length;d++){var l=a(n[d]);0===s[l].references&&(s[l].updater(),s.splice(l,1))}n=i}}}},704:(t,e,n)=>{t.exports=n(79)("./src/core.js")},273:(t,e,n)=>{t.exports=n(79)("./src/ui.js")},79:t=>{"use strict";t.exports=CKEditor5.dll}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={id:r,exports:{}};return t[r](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.nc=void 0;var r={};(()=>{"use strict";n.r(r),n.d(r,{ExportPdf:()=>h});var t=n(704),e=n(273);const o=["data-cke","all","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.","indexOf",".ck-content","join","warn","hasAttribute","cssText","trim","ownerNode","text","push","length","EDITOR_STYLES","from","then","styleSheets",":root","cssRules"];var i,s;i=o,s=427,function(t){for(;--t;)i.push(i.shift())}(++s);const a=function(t,e){return o[t-=0]};function c(){const t=[],e=[];for(const n of Array[a("0x8")](document[a("0xa")]))if(n[a("0x3")][a("0x0")](a("0xd")))for(const r of Array[a("0x8")](n[a("0xc")]))-1!==r[a("0x1")][a("0x10")](a("0x11"))?t[a("0x5")](r[a("0x1")]):-1!==r.cssText[a("0x10")](a("0xb"))&&e[a("0x5")](r[a("0x1")]);return t[a("0x6")]||console[a("0x13")](a("0xf")),[...e,...t][a("0x12")](" ")[a("0x2")]()}class d 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,n=e.t,r=t.converterUrl||"https://pdf-converter.cke-cs.com/v1/convert/",o=t.dataCallback||(t=>t.data.get()),i=e.plugins.get("ExportPdf"),s=t.token||i._token;return this.isBusy=!0,this.refresh(),function(t){if(!t)return new Promise((t=>t("")));const e=[];for(const n of t)a("0x7")!==n?e.push(window.fetch(n)[a("0x9")]((t=>t[a("0x4")]()))):e[a("0x5")](c());return Promise[a("0xe")](e).then((t=>t[a("0x12")](" ")[a("0x2")]()))}(t.stylesheets||["EDITOR_STYLES"]).then((async n=>{const i={html:'<html>\n\t\t\t\t\t\t<head>\n\t\t\t\t\t\t\t<title>CKEditor 5 PDF document</title>\n\t\t\t\t\t\t\t<meta charset="utf-8">\n\t\t\t\t\t\t</head>\n\t\t\t\t\t\t<body>\n\t\t\t\t\t\t\t<div class="ck-content" dir="'+e.locale.contentLanguageDirection+'">\n\t\t\t\t\t\t\t\t'+await o(e)+"\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</body>\n\t\t\t\t\t</html>",css:n,options:t.converterOptions},a={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/pdf",...s?{Authorization:s.value}:null,"x-cs-app-id":t.appID||"cke5"},body:JSON.stringify(i)};return window.fetch(r,a).then((t=>{if(200!==t.status)throw t;return t.blob()})).then((e=>{const n="function"==typeof t.fileName?t.fileName():t.fileName;this._downloadFile(e,n||"document.pdf")}))})).catch((t=>{throw e.plugins.get("Notification").showWarning(n("An error occurred while generating the PDF.")),t})).finally((()=>{this.isBusy=!1,this.refresh()}))}_downloadFile(t,e){const n=document.createElement("a");n.href=window.URL.createObjectURL(t),n.download=e,n.click(),n.remove()}}var l=n(278),u=n.n(l),p=n(861),f={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};u()(p.Z,f);p.Z.locals;class h extends t.Plugin{static get pluginName(){return"ExportPdf"}static get requires(){return["CloudServices",e.Notification]}init(){const t=this.editor,n=t.t,r=t.config.get("exportPdf")||{};t.commands.add("exportPdf",new d(t)),t.ui.componentFactory.add("exportPdf",(o=>{const i=t.commands.get("exportPdf"),s=new e.ButtonView(o);s.set({label:n("Export to PDF"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M19 4.5 14 0H3v6.5h1.5v-5h8v5h5V11H19V4.5ZM14 2l3.3 3H14V2Z"/><path d="m12.452 18.5 1.25 1.5H3v-3h1.5v1.5h7.952Z"/><path d="M19.826 16.843a.75.75 0 1 0-1.152-.96L17.5 17.29V13H16v4.29l-1.174-1.408a.75.75 0 1 0-1.152.96l2.346 2.816a.95.95 0 0 0 1.46 0l2.346-2.815Z"/><path d="M1.63 14.24V12.3h.88c.66 0 1.14-.15 1.46-.45.32-.3.48-.71.48-1.24 0-.52-.15-.91-.44-1.2C3.7 9.15 3.28 9 2.69 9H0v5.24h1.63Zm.4-3h-.4v-1.17h.46c.3 0 .5.05.62.17.1.11.16.25.16.42 0 .16-.06.3-.19.41-.13.11-.34.16-.66.16l.01.01Zm5.7 3c.28 0 .6-.05.96-.14.26-.07.5-.21.73-.42.22-.2.4-.47.53-.77.12-.31.19-.75.19-1.3 0-.37-.04-.7-.13-1.02a2.3 2.3 0 0 0-.42-.84c-.19-.24-.43-.43-.72-.56C8.57 9.06 8.2 9 7.72 9h-2.4v5.24H7.73Zm-.4-1.19h-.4v-2.86h.4c.43 0 .73.1.91.3.18.2.27.59.27 1.14 0 .42-.04.73-.12.91a.76.76 0 0 1-.34.4c-.14.07-.38.11-.72.11Zm5.3 1.2V12.1h2.02v-1.06h-2.03v-.91H15V9h-4v5.24h1.62l.01.01Z"/></svg>\n',tooltip:!0}),s.bind("isOn","isEnabled").to(i,"isBusy","isEnabled"),s.extendTemplate({attributes:{class:[s.bindTemplate.if("isOn","ck-exportpdf_status-pending")]}});const a=new e.View;return a.setTemplate({tag:"span",attributes:{class:["ck","ck-exportpdf__spinner-container"]},children:[{tag:"span",attributes:{class:["ck","ck-exportpdf__spinner"]}}]}),s.children.add(a),this.listenTo(s,"execute",(()=>{t.execute("exportPdf",r),t.editing.view.focus()})),s}));const o=t.plugins.get("CloudServices");!1===r.tokenUrl?this._token=null:r.tokenUrl?o.registerTokenUrl(r.tokenUrl).then((t=>{this._token=t})):this._token=o.token}}})(),(window.CKEditor5=window.CKEditor5||{}).exportPdf=r})();
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,{ExportPdf:()=>l});var t=o(704),e=o(273);const r=["indexOf","all","cssText",".ck-content","hasAttribute","fetch","from","join","push","cssRules","data-cke","then","length","warn","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","trim"];var i,s;i=r,s=418,function(t){for(;--t;)i.push(i.shift())}(++s);const c=function(t,e){return r[t-=0]};function d(){const t=[],e=[];for(const o of Array[c("0xd")](document[c("0x5")]))if(o.ownerNode[c("0xb")](c("0x0")))for(const n of Array[c("0xd")](o[c("0x10")]))-1!==n.cssText[c("0x7")](c("0xa"))?t.push(n[c("0x9")]):-1!==n[c("0x9")][c("0x7")](":root")&&e[c("0xf")](n.cssText);return t[c("0x2")]||console[c("0x3")](c("0x4")),[...e,...t][c("0xe")](" ")[c("0x6")]()}class a 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://pdf-converter.cke-cs.com/v1/convert/",r=t.dataCallback||(t=>t.data.get()),i=e.plugins.get("ExportPdf"),s=t.token||i._token;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("0xf")](window[c("0xc")](o)[c("0x1")]((t=>t.text()))):e[c("0xf")](d());return Promise[c("0x8")](e)[c("0x1")]((t=>t[c("0xe")](" ")[c("0x6")]()))}(t.stylesheets||["EDITOR_STYLES"]).then((async o=>{const i={html:'<html>\n\t\t\t\t\t\t<head>\n\t\t\t\t\t\t\t<title>CKEditor 5 PDF document</title>\n\t\t\t\t\t\t\t<meta charset="utf-8">\n\t\t\t\t\t\t</head>\n\t\t\t\t\t\t<body>\n\t\t\t\t\t\t\t<div class="ck-content" dir="'+e.locale.contentLanguageDirection+'">\n\t\t\t\t\t\t\t\t'+await r(e)+"\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</body>\n\t\t\t\t\t</html>",css:o,options:t.converterOptions},c={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/pdf",...s?{Authorization:s.value}:null,"x-cs-app-id":t.appID||"cke5"},body:JSON.stringify(i)};return window.fetch(n,c).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.pdf")}))})).catch((t=>{throw e.plugins.get("Notification").showWarning(o("An error occurred while generating the PDF.")),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 l extends t.Plugin{static get pluginName(){return"ExportPdf"}static get requires(){return["CloudServices",e.Notification]}init(){const t=this.editor,o=t.t,n=t.config.get("exportPdf")||{};t.commands.add("exportPdf",new a(t)),t.ui.componentFactory.add("exportPdf",(r=>{const i=t.commands.get("exportPdf"),s=new e.ButtonView(r),c=new e.SpinnerView;return s.set({label:o("Export to PDF"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M19 4.5 14 0H3v6.5h1.5v-5h8v5h5V11H19V4.5ZM14 2l3.3 3H14V2Z"/><path d="m12.452 18.5 1.25 1.5H3v-3h1.5v1.5h7.952Z"/><path d="M19.826 16.843a.75.75 0 1 0-1.152-.96L17.5 17.29V13H16v4.29l-1.174-1.408a.75.75 0 1 0-1.152.96l2.346 2.816a.95.95 0 0 0 1.46 0l2.346-2.815Z"/><path d="M1.63 14.24V12.3h.88c.66 0 1.14-.15 1.46-.45.32-.3.48-.71.48-1.24 0-.52-.15-.91-.44-1.2C3.7 9.15 3.28 9 2.69 9H0v5.24h1.63Zm.4-3h-.4v-1.17h.46c.3 0 .5.05.62.17.1.11.16.25.16.42 0 .16-.06.3-.19.41-.13.11-.34.16-.66.16l.01.01Zm5.7 3c.28 0 .6-.05.96-.14.26-.07.5-.21.73-.42.22-.2.4-.47.53-.77.12-.31.19-.75.19-1.3 0-.37-.04-.7-.13-1.02a2.3 2.3 0 0 0-.42-.84c-.19-.24-.43-.43-.72-.56C8.57 9.06 8.2 9 7.72 9h-2.4v5.24H7.73Zm-.4-1.19h-.4v-2.86h.4c.43 0 .73.1.91.3.18.2.27.59.27 1.14 0 .42-.04.73-.12.91a.76.76 0 0 1-.34.4c-.14.07-.38.11-.72.11Zm5.3 1.2V12.1h2.02v-1.06h-2.03v-.91H15V9h-4v5.24h1.62l.01.01Z"/></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("exportPdf",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||{}).exportPdf=n})();
@@ -1 +1 @@
1
- !function(r){const o=r["pt-br"]=r["pt-br"]||{};o.dictionary=Object.assign(o.dictionary||{},{"An error occurred while generating the PDF.":"Um erro ocorreu enquanto gerava o arquivo PDF.","Export to PDF":"Exportar para PDF"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
1
+ !function(r){const o=r["pt-br"]=r["pt-br"]||{};o.dictionary=Object.assign(o.dictionary||{},{"An error occurred while generating the PDF.":"Um erro ocorreu ao gerar o arquivo PDF.","Export to PDF":"Exportar para PDF"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));
@@ -23,4 +23,4 @@ msgstr "Exportar para PDF"
23
23
 
24
24
  msgctxt "An error message shown to the user when an error occurred during the generation of the PDF file."
25
25
  msgid "An error occurred while generating the PDF."
26
- msgstr "Um erro ocorreu enquanto gerava o arquivo PDF."
26
+ msgstr "Um erro ocorreu ao gerar o arquivo PDF."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-export-pdf",
3
- "version": "39.0.2",
3
+ "version": "40.0.0",
4
4
  "description": "Export to PDF 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": "39.0.2"
32
+ "ckeditor5": "40.0.0"
33
33
  },
34
34
  "license": "SEE LICENSE IN LICENSE.md",
35
35
  "author": "CKSource (http://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 { ExportPdfConfig, ExportPdf, ExportPdfCommand } from './index';
6
- declare module '@ckeditor/ckeditor5-core' {
7
- interface EditorConfig {
8
- /**
9
- * The configuration of the {@link module:export-pdf/exportpdf~ExportPdf export to PDF feature}.
10
- *
11
- * Read more in {@link module:export-pdf/exportpdf~ExportPdfConfig}.
12
- */
13
- exportPdf?: ExportPdfConfig;
14
- }
15
- interface PluginsMap {
16
- [ExportPdf.pluginName]: ExportPdf;
17
- }
18
- interface CommandsMap {
19
- exportPdf: ExportPdfCommand;
20
- }
21
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ import type { ExportPdfConfig, ExportPdf, ExportPdfCommand } from './index';
6
+ declare module '@ckeditor/ckeditor5-core' {
7
+ interface EditorConfig {
8
+ /**
9
+ * The configuration of the {@link module:export-pdf/exportpdf~ExportPdf export to PDF feature}.
10
+ *
11
+ * Read more in {@link module:export-pdf/exportpdf~ExportPdfConfig}.
12
+ */
13
+ exportPdf?: ExportPdfConfig;
14
+ }
15
+ interface PluginsMap {
16
+ [ExportPdf.pluginName]: ExportPdf;
17
+ }
18
+ interface CommandsMap {
19
+ exportPdf: ExportPdfCommand;
20
+ }
21
+ }
@@ -1,221 +1,220 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module export-pdf/exportpdf
7
- * @publicApi
8
- */
9
- import { Plugin, type Editor } from 'ckeditor5/src/core';
10
- import { Notification } from 'ckeditor5/src/ui';
11
- import type { InitializedToken, TokenUrl } from '@ckeditor/ckeditor5-cloud-services';
12
- import '../theme/exportpdf.css';
13
- /**
14
- * The export to PDF feature.
15
- *
16
- * It allows you to generate a PDF file directly from the editor content.
17
- *
18
- * For a detailed overview, check the {@glink features/converters/export-pdf export to PDF} feature documentation.
19
- */
20
- export default class ExportPdf extends Plugin {
21
- /**
22
- * @inheritDoc
23
- */
24
- static get pluginName(): "ExportPdf";
25
- /**
26
- * @inheritDoc
27
- */
28
- static get requires(): readonly ["CloudServices", typeof Notification];
29
- /**
30
- * @inheritDoc
31
- */
32
- init(): void;
33
- }
34
- /**
35
- * The configuration of the export to PDF feature. It is used by the PDF export features from the `@ckeditor/ckeditor5-export-pdf` package.
36
- *
37
- * ```ts
38
- * ClassicEditor
39
- * .create( editorElement, {
40
- * exportPdf: ... // Export to PDF feature options.
41
- * } )
42
- * .then( ... )
43
- * .catch( ... );
44
- * ```
45
- *
46
- * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
47
- */
48
- export interface ExportPdfConfig {
49
- /**
50
- * Paths to the `.css` files containing additional styling for the editor's content (**the order of provided items matters**).
51
- *
52
- * ```ts
53
- * const exportPdfConfig = {
54
- * stylesheets: [ './path/to/custom-style.css' ]
55
- * }
56
- * ```
57
- *
58
- * **NOTE:** If `stylesheets` are not provided, the plugin will sent only
59
- * {@glink installation/advanced/content-styles#the-full-list-of-content-styles the default editor content styles} to the converter.
60
- *
61
- * **Default editor's content styles**:
62
- * {@glink installation/advanced/content-styles#the-full-list-of-content-styles The default editor content styles}
63
- * are applied to the generated PDF thanks to the 'EDITOR_STYLES' token, which is provided to the `stylesheets` by default.
64
- * If you don't want them to be applied, you have to omit the token:
65
- *
66
- * ```ts
67
- * const exportPdfConfig = {
68
- * stylesheets: [ './path/to/custom-editor-styles.css' ]
69
- * }
70
- * ```
71
- *
72
- * **Web fonts:** If you want to {@glink features/converters/export-pdf#providing-web-font-styles use web fonts} in your PDF document,
73
- * you should provide a path to the file containing the web font declaration before the `'EDITOR_STYLES'` token:
74
- *
75
- * ```ts
76
- * const exportPdfConfig = {
77
- * stylesheets: [
78
- * './path/to/fonts.css',
79
- * 'EDITOR_STYLES'
80
- * ]
81
- * }
82
- * ```
83
- *
84
- * **Web fonts and custom styling:** For more advanced styling, your configuration should look like this:
85
- *
86
- * ```ts
87
- * const exportPdfConfig = {
88
- * stylesheets: [
89
- * './path/to/fonts.css',
90
- * 'EDITOR_STYLES',
91
- * './path/to/custom-styles.css'
92
- * ]
93
- * }
94
- * ```
95
- *
96
- * @default `[ 'EDITOR_STYLES' ]`
97
- */
98
- stylesheets?: Array<string>;
99
- /**
100
- * The name of the generated PDF file.
101
- *
102
- * ```ts
103
- * // Static file name.
104
- * const exportPdfConfig = {
105
- * fileName: 'my-document.pdf'
106
- * }
107
- *
108
- * // Dynamic file name.
109
- * const exportPdfConfig = {
110
- * fileName: () => {
111
- * const articleTitle = document.querySelector( '#title' );
112
- *
113
- * return `${ articleTitle.value }.pdf`;
114
- * }
115
- * }
116
- * ```
117
- *
118
- * **NOTE:** The file name must contain the `.pdf` extension.
119
- * Otherwise your operating system or device may have trouble identifying the file type.
120
- *
121
- * @default 'document.pdf'
122
- */
123
- fileName?: string | (() => string);
124
- /**
125
- * A URL to the HTML to PDF converter.
126
- *
127
- * ```ts
128
- * const exportPdfConfig = {
129
- * converterUrl: 'https://myconverter.com/v1/'
130
- * }
131
- * ```
132
- *
133
- * **NOTE:** The plugin uses the default HTML to PDF converter delivered by CKEditor Cloud Services.
134
- * You can provide a URL to an on-premises converter instead.
135
- *
136
- * @default 'https://pdf-converter.cke-cs.com/v1/convert'
137
- */
138
- converterUrl?: string;
139
- /**
140
- * The HTML to PDF converter options.
141
- *
142
- * **NOTE:** Configuring the plugin is not mandatory but it is highly recommended,
143
- * especially if you want to get the most accurate results when generating the PDF file.
144
- * To learn more, please check the [HTML to PDF converter configuration](https://pdf-converter.cke-cs.com/docs).
145
- *
146
- * ```ts
147
- * const exportPdfConfig = {
148
- * converterOptions: {
149
- * ...
150
- * }
151
- * }
152
- * ```
153
- *
154
- * @default `{
155
- * format: 'A4',
156
- * margin_top: '0',
157
- * margin_bottom: '0',
158
- * margin_right: '0',
159
- * margin_left: '0',
160
- * page_orientation: 'portrait',
161
- * header_html: undefined,
162
- * footer_html: undefined,
163
- * header_and_footer_css: undefined,
164
- * wait_for_network: true,
165
- * wait_time: 0
166
- * }`
167
- */
168
- converterOptions?: ExportPdfConverterOptions;
169
- /**
170
- * A function to gather the HTML to be converted to PDF.
171
- *
172
- * **NOTE:** This option may be useful when the editor does not have `getData()` method,
173
- * or if the HTML to be converted should be different than the edited one.
174
- *
175
- * ```ts
176
- * const exportPdfConfig = {
177
- * dataCallback: ( editor: Editor ) => {
178
- * return `
179
- * <header id="header">${ editor.data.get( { rootName: 'header' } ) }</header>
180
- * <div id="content">${ editor.data.get( { rootName: 'content' } ) }</div>
181
- * `;
182
- * }
183
- * }
184
- * ```
185
- *
186
- * @default `( editor: Editor ) => editor.getData()`
187
- */
188
- dataCallback?: (editor: Editor) => string;
189
- /**
190
- * A token URL or a token request function. This field is optional and should be used only when a different `tokenUrl` is required for
191
- * the export to PDF feature.
192
- *
193
- * **Note:** The token can be disabled with the `false` value provided.
194
- *
195
- * See: {@link module:cloud-services/cloudservicesconfig~CloudServicesConfig#tokenUrl}
196
- */
197
- tokenUrl?: TokenUrl | false;
198
- /**
199
- * The authentication token.
200
- *
201
- * See: {@link module:cloud-services/cloudservices~CloudServices#token}
202
- */
203
- token?: InitializedToken;
204
- /**
205
- * The application unique identifier.
206
- */
207
- appID?: string;
208
- }
209
- export type ExportPdfConverterOptions = {
210
- format?: 'Letter' | 'Legal' | 'Tabloid' | 'Ledger' | 'A0' | 'A1' | 'A2' | 'A3' | 'A4' | 'A5' | 'A6';
211
- margin_top?: string;
212
- margin_bottom?: string;
213
- margin_right?: string;
214
- margin_left?: string;
215
- header_html?: string;
216
- footer_html?: string;
217
- header_and_footer_css?: string;
218
- page_orientation?: 'portrait' | 'landscape';
219
- wait_for_network?: boolean;
220
- wait_time?: number;
221
- };
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module export-pdf/exportpdf
7
+ * @publicApi
8
+ */
9
+ import { Plugin, type Editor } from 'ckeditor5/src/core';
10
+ import { Notification } from 'ckeditor5/src/ui';
11
+ import type { InitializedToken, TokenUrl } from '@ckeditor/ckeditor5-cloud-services';
12
+ /**
13
+ * The export to PDF feature.
14
+ *
15
+ * It allows you to generate a PDF file directly from the editor content.
16
+ *
17
+ * For a detailed overview, check the {@glink features/converters/export-pdf export to PDF} feature documentation.
18
+ */
19
+ export default class ExportPdf extends Plugin {
20
+ /**
21
+ * @inheritDoc
22
+ */
23
+ static get pluginName(): "ExportPdf";
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ static get requires(): readonly ["CloudServices", typeof Notification];
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ init(): void;
32
+ }
33
+ /**
34
+ * The configuration of the export to PDF feature. It is used by the PDF export features from the `@ckeditor/ckeditor5-export-pdf` package.
35
+ *
36
+ * ```ts
37
+ * ClassicEditor
38
+ * .create( editorElement, {
39
+ * exportPdf: ... // Export to PDF feature options.
40
+ * } )
41
+ * .then( ... )
42
+ * .catch( ... );
43
+ * ```
44
+ *
45
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
46
+ */
47
+ export interface ExportPdfConfig {
48
+ /**
49
+ * Paths to the `.css` files containing additional styling for the editor's content (**the order of provided items matters**).
50
+ *
51
+ * ```ts
52
+ * const exportPdfConfig = {
53
+ * stylesheets: [ './path/to/custom-style.css' ]
54
+ * }
55
+ * ```
56
+ *
57
+ * **NOTE:** If `stylesheets` are not provided, the plugin will sent only
58
+ * {@glink installation/advanced/content-styles#the-full-list-of-content-styles the default editor content styles} to the converter.
59
+ *
60
+ * **Default editor's content styles**:
61
+ * {@glink installation/advanced/content-styles#the-full-list-of-content-styles The default editor content styles}
62
+ * are applied to the generated PDF thanks to the 'EDITOR_STYLES' token, which is provided to the `stylesheets` by default.
63
+ * If you don't want them to be applied, you have to omit the token:
64
+ *
65
+ * ```ts
66
+ * const exportPdfConfig = {
67
+ * stylesheets: [ './path/to/custom-editor-styles.css' ]
68
+ * }
69
+ * ```
70
+ *
71
+ * **Web fonts:** If you want to {@glink features/converters/export-pdf#providing-web-font-styles use web fonts} in your PDF document,
72
+ * you should provide a path to the file containing the web font declaration before the `'EDITOR_STYLES'` token:
73
+ *
74
+ * ```ts
75
+ * const exportPdfConfig = {
76
+ * stylesheets: [
77
+ * './path/to/fonts.css',
78
+ * 'EDITOR_STYLES'
79
+ * ]
80
+ * }
81
+ * ```
82
+ *
83
+ * **Web fonts and custom styling:** For more advanced styling, your configuration should look like this:
84
+ *
85
+ * ```ts
86
+ * const exportPdfConfig = {
87
+ * stylesheets: [
88
+ * './path/to/fonts.css',
89
+ * 'EDITOR_STYLES',
90
+ * './path/to/custom-styles.css'
91
+ * ]
92
+ * }
93
+ * ```
94
+ *
95
+ * @default `[ 'EDITOR_STYLES' ]`
96
+ */
97
+ stylesheets?: Array<string>;
98
+ /**
99
+ * The name of the generated PDF file.
100
+ *
101
+ * ```ts
102
+ * // Static file name.
103
+ * const exportPdfConfig = {
104
+ * fileName: 'my-document.pdf'
105
+ * }
106
+ *
107
+ * // Dynamic file name.
108
+ * const exportPdfConfig = {
109
+ * fileName: () => {
110
+ * const articleTitle = document.querySelector( '#title' );
111
+ *
112
+ * return `${ articleTitle.value }.pdf`;
113
+ * }
114
+ * }
115
+ * ```
116
+ *
117
+ * **NOTE:** The file name must contain the `.pdf` extension.
118
+ * Otherwise your operating system or device may have trouble identifying the file type.
119
+ *
120
+ * @default 'document.pdf'
121
+ */
122
+ fileName?: string | (() => string);
123
+ /**
124
+ * A URL to the HTML to PDF converter.
125
+ *
126
+ * ```ts
127
+ * const exportPdfConfig = {
128
+ * converterUrl: 'https://myconverter.com/v1/'
129
+ * }
130
+ * ```
131
+ *
132
+ * **NOTE:** The plugin uses the default HTML to PDF converter delivered by CKEditor Cloud Services.
133
+ * You can provide a URL to an on-premises converter instead.
134
+ *
135
+ * @default 'https://pdf-converter.cke-cs.com/v1/convert'
136
+ */
137
+ converterUrl?: string;
138
+ /**
139
+ * The HTML to PDF converter options.
140
+ *
141
+ * **NOTE:** Configuring the plugin is not mandatory but it is highly recommended,
142
+ * especially if you want to get the most accurate results when generating the PDF file.
143
+ * To learn more, please check the [HTML to PDF converter configuration](https://pdf-converter.cke-cs.com/docs).
144
+ *
145
+ * ```ts
146
+ * const exportPdfConfig = {
147
+ * converterOptions: {
148
+ * ...
149
+ * }
150
+ * }
151
+ * ```
152
+ *
153
+ * @default `{
154
+ * format: 'A4',
155
+ * margin_top: '0',
156
+ * margin_bottom: '0',
157
+ * margin_right: '0',
158
+ * margin_left: '0',
159
+ * page_orientation: 'portrait',
160
+ * header_html: undefined,
161
+ * footer_html: undefined,
162
+ * header_and_footer_css: undefined,
163
+ * wait_for_network: true,
164
+ * wait_time: 0
165
+ * }`
166
+ */
167
+ converterOptions?: ExportPdfConverterOptions;
168
+ /**
169
+ * A function to gather the HTML to be converted to PDF.
170
+ *
171
+ * **NOTE:** This option may be useful when the editor does not have `getData()` method,
172
+ * or if the HTML to be converted should be different than the edited one.
173
+ *
174
+ * ```ts
175
+ * const exportPdfConfig = {
176
+ * dataCallback: ( editor: Editor ) => {
177
+ * return `
178
+ * <header id="header">${ editor.data.get( { rootName: 'header' } ) }</header>
179
+ * <div id="content">${ editor.data.get( { rootName: 'content' } ) }</div>
180
+ * `;
181
+ * }
182
+ * }
183
+ * ```
184
+ *
185
+ * @default `( editor: Editor ) => editor.getData()`
186
+ */
187
+ dataCallback?: (editor: Editor) => string;
188
+ /**
189
+ * A token URL or a token request function. This field is optional and should be used only when a different `tokenUrl` is required for
190
+ * the export to PDF feature.
191
+ *
192
+ * **Note:** The token can be disabled with the `false` value provided.
193
+ *
194
+ * See: {@link module:cloud-services/cloudservicesconfig~CloudServicesConfig#tokenUrl}
195
+ */
196
+ tokenUrl?: TokenUrl | false;
197
+ /**
198
+ * The authentication token.
199
+ *
200
+ * See: {@link module:cloud-services/cloudservices~CloudServices#token}
201
+ */
202
+ token?: InitializedToken;
203
+ /**
204
+ * The application unique identifier.
205
+ */
206
+ appID?: string;
207
+ }
208
+ export type ExportPdfConverterOptions = {
209
+ format?: 'Letter' | 'Legal' | 'Tabloid' | 'Ledger' | 'A0' | 'A1' | 'A2' | 'A3' | 'A4' | 'A5' | 'A6';
210
+ margin_top?: string;
211
+ margin_bottom?: string;
212
+ margin_right?: string;
213
+ margin_left?: string;
214
+ header_html?: string;
215
+ footer_html?: string;
216
+ header_and_footer_css?: string;
217
+ page_orientation?: 'portrait' | 'landscape';
218
+ wait_for_network?: boolean;
219
+ wait_time?: number;
220
+ };
package/src/exportpdf.js CHANGED
@@ -20,4 +20,4 @@
20
20
  *
21
21
  *
22
22
  */
23
- import{Plugin as _0x1787ba}from'ckeditor5/src/core';import{ButtonView as _0x2a8802,View as _0x1df1bc,Notification as _0x42daf0}from'ckeditor5/src/ui';import _0x41b983 from'./exportpdfcommand';import _0x522516 from'../theme/icons/exportpdf.svg';import'../theme/exportpdf.css';export default class p extends _0x1787ba{static get['pluginName'](){return'ExportPdf';}static get['requires'](){return['CloudServices',_0x42daf0];}['init'](){const _0x27b875=this['editor'],t=_0x27b875['t'],_0x2a6a82=_0x27b875['config']['get']('exportPdf')||{};_0x27b875['commands']['add']('exportPdf',new _0x41b983(_0x27b875)),_0x27b875['ui']['componentFactory']['add']('exportPdf',_0x455a33=>{const _0x56b609=_0x27b875['commands']['get']('exportPdf'),_0x3ec710=new _0x2a8802(_0x455a33);_0x3ec710['set']({'label':t('Export\x20to\x20PDF'),'icon':_0x522516,'tooltip':!0x0}),_0x3ec710['bind']('isOn','isEnabled')['to'](_0x56b609,'isBusy','isEnabled'),_0x3ec710['extendTemplate']({'attributes':{'class':[_0x3ec710['bindTemplate']['if']('isOn','ck-exportpdf_status-pending')]}});const _0x5ad637=new _0x1df1bc();return _0x5ad637['setTemplate']({'tag':'span','attributes':{'class':['ck','ck-exportpdf__spinner-container']},'children':[{'tag':'span','attributes':{'class':['ck','ck-exportpdf__spinner']}}]}),_0x3ec710['children']['add'](_0x5ad637),this['listenTo'](_0x3ec710,'execute',()=>{_0x27b875['execute']('exportPdf',_0x2a6a82),_0x27b875['editing']['view']['focus']();}),_0x3ec710;});const _0x2a65f3=_0x27b875['plugins']['get']('CloudServices');!0x1===_0x2a6a82['tokenUrl']?this['_token']=null:_0x2a6a82['tokenUrl']?_0x2a65f3['registerTokenUrl'](_0x2a6a82['tokenUrl'])['then'](_0x385a24=>{this['_token']=_0x385a24;}):this['_token']=_0x2a65f3['token'];}}
23
+ import{Plugin as _0x4045cb}from'ckeditor5/src/core';import{ButtonView as _0xce2224,Notification as _0x49a1fa,SpinnerView as _0xad3e32}from'ckeditor5/src/ui';import _0x46266d from'./exportpdfcommand';import _0x1e7b2d from'../theme/icons/exportpdf.svg';export default class p extends _0x4045cb{static get['pluginName'](){return'ExportPdf';}static get['requires'](){return['CloudServices',_0x49a1fa];}['init'](){const _0x46ad9d=this['editor'],t=_0x46ad9d['t'],_0x1a0d18=_0x46ad9d['config']['get']('exportPdf')||{};_0x46ad9d['commands']['add']('exportPdf',new _0x46266d(_0x46ad9d)),_0x46ad9d['ui']['componentFactory']['add']('exportPdf',_0x3cfb18=>{const _0x5cfb58=_0x46ad9d['commands']['get']('exportPdf'),_0x21cc56=new _0xce2224(_0x3cfb18),_0x25fbaa=new _0xad3e32();return _0x21cc56['set']({'label':t('Export\x20to\x20PDF'),'icon':_0x1e7b2d,'tooltip':!0x0}),_0x21cc56['children']['add'](_0x25fbaa),_0x21cc56['bind']('isOn','isEnabled')['to'](_0x5cfb58,'isBusy','isEnabled'),_0x25fbaa['bind']('isVisible')['to'](_0x5cfb58,'isBusy'),_0x21cc56['iconView']['bind']('isVisible')['to'](_0x5cfb58,'isBusy',_0xd4cee7=>!_0xd4cee7),this['listenTo'](_0x21cc56,'execute',()=>{_0x46ad9d['execute']('exportPdf',_0x1a0d18),_0x46ad9d['editing']['view']['focus']();}),_0x21cc56;});const _0x52b493=_0x46ad9d['plugins']['get']('CloudServices');!0x1===_0x1a0d18['tokenUrl']?this['_token']=null:_0x1a0d18['tokenUrl']?_0x52b493['registerTokenUrl'](_0x1a0d18['tokenUrl'])['then'](_0x5b3386=>{this['_token']=_0x5b3386;}):this['_token']=_0x52b493['token'];}}
@@ -1,39 +1,39 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module export-pdf/exportpdfcommand
7
- * @publicApi
8
- */
9
- import { Command, type Editor } from 'ckeditor5/src/core';
10
- import { type ExportPdfConfig } from './exportpdf';
11
- /**
12
- * The export to PDF command.
13
- *
14
- * It takes the editor's HTML and CSS rules from the document and sends them to the HTML to PDF converter.
15
- * After processing, the converter will send back a PDF file for download.
16
- */
17
- export default class ExportPdfCommand extends Command {
18
- /**
19
- * A command state that indicates if the command is currently executing.
20
- *
21
- * @observable
22
- */
23
- isBusy: boolean;
24
- /**
25
- * @inheritDoc
26
- */
27
- constructor(editor: Editor);
28
- /**
29
- * @inheritDoc
30
- */
31
- refresh(): void;
32
- /**
33
- * Executes the command.
34
- *
35
- * @fires execute
36
- * @param options Options for the executed command.
37
- */
38
- execute(options?: ExportPdfConfig): Promise<void>;
39
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module export-pdf/exportpdfcommand
7
+ * @publicApi
8
+ */
9
+ import { Command, type Editor } from 'ckeditor5/src/core';
10
+ import { type ExportPdfConfig } from './exportpdf';
11
+ /**
12
+ * The export to PDF command.
13
+ *
14
+ * It takes the editor's HTML and CSS rules from the document and sends them to the HTML to PDF converter.
15
+ * After processing, the converter will send back a PDF file for download.
16
+ */
17
+ export default class ExportPdfCommand extends Command {
18
+ /**
19
+ * A command state that indicates if the command is currently executing.
20
+ *
21
+ * @observable
22
+ */
23
+ isBusy: boolean;
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ constructor(editor: Editor);
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ refresh(): void;
32
+ /**
33
+ * Executes the command.
34
+ *
35
+ * @fires execute
36
+ * @param options Options for the executed command.
37
+ */
38
+ execute(options?: ExportPdfConfig): Promise<void>;
39
+ }
@@ -20,4 +20,4 @@
20
20
  *
21
21
  *
22
22
  */
23
- import{Command as _0xaea7b9}from'ckeditor5/src/core';import{getStyles as _0x419c41}from'./utils';export default class i extends _0xaea7b9{constructor(_0x1a4abc){super(_0x1a4abc),this['set']('isBusy',!0x1),this['affectsData']=!0x1;}['refresh'](){this['isEnabled']=!this['isBusy'],this['value']=this['isBusy']?'pending':void 0x0;}['execute'](_0xe654c2={}){const _0x141d1a=this['editor'],t=_0x141d1a['t'],_0x3b9c80=_0xe654c2['converterUrl']||'https://pdf-converter.cke-cs.com/v1/convert/',_0x119c86=_0xe654c2['dataCallback']||(_0x5b8c60=>_0x5b8c60['data']['get']()),_0xc1fed0=_0x141d1a['plugins']['get']('ExportPdf'),_0xa9f7a9=_0xe654c2['token']||_0xc1fed0['_token'];return this['isBusy']=!0x0,this['refresh'](),_0x419c41(_0xe654c2['stylesheets']||['EDITOR_STYLES'])['then'](async _0x459b3e=>{const _0xc81978={'html':'<html>\x0a\x09\x09\x09\x09\x09\x09<head>\x0a\x09\x09\x09\x09\x09\x09\x09<title>CKEditor\x205\x20PDF\x20document</title>\x0a\x09\x09\x09\x09\x09\x09\x09<meta\x20charset=\x22utf-8\x22>\x0a\x09\x09\x09\x09\x09\x09</head>\x0a\x09\x09\x09\x09\x09\x09<body>\x0a\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22ck-content\x22\x20dir=\x22'+_0x141d1a['locale']['contentLanguageDirection']+'\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09'+await _0x119c86(_0x141d1a)+'\x0a\x09\x09\x09\x09\x09\x09\x09</div>\x0a\x09\x09\x09\x09\x09\x09</body>\x0a\x09\x09\x09\x09\x09</html>','css':_0x459b3e,'options':_0xe654c2['converterOptions']},_0x4a2af6={'method':'POST','headers':{'Content-Type':'application/json','Accept':'application/pdf',..._0xa9f7a9?{'Authorization':_0xa9f7a9['value']}:null,'x-cs-app-id':_0xe654c2['appID']||'cke5'},'body':JSON['stringify'](_0xc81978)};return window['fetch'](_0x3b9c80,_0x4a2af6)['then'](_0x347ac3=>{if(0xc8!==_0x347ac3['status'])throw _0x347ac3;return _0x347ac3['blob']();})['then'](_0x3792b0=>{const _0x5439ad='function'==typeof _0xe654c2['fileName']?_0xe654c2['fileName']():_0xe654c2['fileName'];this['_downloadFile'](_0x3792b0,_0x5439ad||'document.pdf');});})['catch'](_0x58838e=>{throw _0x141d1a['plugins']['get']('Notification')['showWarning'](t('An\x20error\x20occurred\x20while\x20generating\x20the\x20PDF.')),_0x58838e;})['finally'](()=>{this['isBusy']=!0x1,this['refresh']();});}['_downloadFile'](_0x20162b,_0x33693c){const _0x475bd3=document['createElement']('a');_0x475bd3['href']=window['URL']['createObjectURL'](_0x20162b),_0x475bd3['download']=_0x33693c,_0x475bd3['click'](),_0x475bd3['remove']();}}
23
+ import{Command as _0x3b6731}from'ckeditor5/src/core';import{getStyles as _0x28cc0d}from'./utils';export default class o extends _0x3b6731{constructor(_0x62a028){super(_0x62a028),this['set']('isBusy',!0x1),this['affectsData']=!0x1;}['refresh'](){this['isEnabled']=!this['isBusy'],this['value']=this['isBusy']?'pending':void 0x0;}['execute'](_0x5783a6={}){const _0x20e59b=this['editor'],t=_0x20e59b['t'],_0x3ba475=_0x5783a6['converterUrl']||'https://pdf-converter.cke-cs.com/v1/convert/',_0x3d247f=_0x5783a6['dataCallback']||(_0x5d484c=>_0x5d484c['data']['get']()),_0xdba8dc=_0x20e59b['plugins']['get']('ExportPdf'),_0x572e72=_0x5783a6['token']||_0xdba8dc['_token'];return this['isBusy']=!0x0,this['refresh'](),_0x28cc0d(_0x5783a6['stylesheets']||['EDITOR_STYLES'])['then'](async _0x54dabb=>{const _0xe1522d={'html':'<html>\x0a\x09\x09\x09\x09\x09\x09<head>\x0a\x09\x09\x09\x09\x09\x09\x09<title>CKEditor\x205\x20PDF\x20document</title>\x0a\x09\x09\x09\x09\x09\x09\x09<meta\x20charset=\x22utf-8\x22>\x0a\x09\x09\x09\x09\x09\x09</head>\x0a\x09\x09\x09\x09\x09\x09<body>\x0a\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22ck-content\x22\x20dir=\x22'+_0x20e59b['locale']['contentLanguageDirection']+'\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09'+await _0x3d247f(_0x20e59b)+'\x0a\x09\x09\x09\x09\x09\x09\x09</div>\x0a\x09\x09\x09\x09\x09\x09</body>\x0a\x09\x09\x09\x09\x09</html>','css':_0x54dabb,'options':_0x5783a6['converterOptions']},_0x5256d3={'method':'POST','headers':{'Content-Type':'application/json','Accept':'application/pdf',..._0x572e72?{'Authorization':_0x572e72['value']}:null,'x-cs-app-id':_0x5783a6['appID']||'cke5'},'body':JSON['stringify'](_0xe1522d)};return window['fetch'](_0x3ba475,_0x5256d3)['then'](_0x42ab66=>{if(0xc8!==_0x42ab66['status'])throw _0x42ab66;return _0x42ab66['blob']();})['then'](_0x314efc=>{const _0x1b9ee9='function'==typeof _0x5783a6['fileName']?_0x5783a6['fileName']():_0x5783a6['fileName'];this['_downloadFile'](_0x314efc,_0x1b9ee9||'document.pdf');});})['catch'](_0x39acf8=>{throw _0x20e59b['plugins']['get']('Notification')['showWarning'](t('An\x20error\x20occurred\x20while\x20generating\x20the\x20PDF.')),_0x39acf8;})['finally'](()=>{this['isBusy']=!0x1,this['refresh']();});}['_downloadFile'](_0x22ce7b,_0x214d66){const _0x49fb72=document['createElement']('a');_0x49fb72['href']=window['URL']['createObjectURL'](_0x22ce7b),_0x49fb72['download']=_0x214d66,_0x49fb72['click'](),_0x49fb72['remove']();}}
package/src/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module export-pdf
7
- */
8
- export { default as ExportPdf, type ExportPdfConfig } from './exportpdf';
9
- export type { default as ExportPdfCommand } from './exportpdfcommand';
10
- import './augmentation';
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module export-pdf
7
+ */
8
+ export { default as ExportPdf, type ExportPdfConfig } from './exportpdf';
9
+ export type { default as ExportPdfCommand } from './exportpdfcommand';
10
+ import './augmentation';
package/src/utils.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
- * A helper function for getting concatenated CSS rules from external stylesheets and the editor.
7
- *
8
- * @param stylesheets An array of stylesheet paths delivered by the user through the plugin configuration.
9
- */
10
- export declare function getStyles(stylesheets?: Array<string>): Promise<string>;
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
+ * A helper function for getting concatenated CSS rules from external stylesheets and the editor.
7
+ *
8
+ * @param stylesheets An array of stylesheet paths delivered by the user through the plugin configuration.
9
+ */
10
+ export declare function getStyles(stylesheets?: Array<string>): Promise<string>;
package/src/utils.js CHANGED
@@ -20,4 +20,4 @@
20
20
  *
21
21
  *
22
22
  */
23
- const _0xcebd=['data-cke','all','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.','indexOf','.ck-content','join','warn','hasAttribute','cssText','trim','ownerNode','text','push','length','EDITOR_STYLES','from','then','styleSheets',':root','cssRules'];(function(_0x4dcfc5,_0xcebd6){const _0x2e0ae4=function(_0x4c9219){while(--_0x4c9219){_0x4dcfc5['push'](_0x4dcfc5['shift']());}};_0x2e0ae4(++_0xcebd6);}(_0xcebd,0x1ab));const _0x2e0a=function(_0x4dcfc5,_0xcebd6){_0x4dcfc5=_0x4dcfc5-0x0;let _0x2e0ae4=_0xcebd[_0x4dcfc5];return _0x2e0ae4;};export function getStyles(_0x397030){if(!_0x397030)return new Promise(_0x5b7094=>_0x5b7094(''));const _0x29be18=[];for(const _0x5046b0 of _0x397030)_0x2e0a('0x7')!==_0x5046b0?_0x29be18['push'](window['fetch'](_0x5046b0)[_0x2e0a('0x9')](_0x4095b9=>_0x4095b9[_0x2e0a('0x4')]())):_0x29be18[_0x2e0a('0x5')](u());return Promise[_0x2e0a('0xe')](_0x29be18)['then'](_0x14d648=>_0x14d648[_0x2e0a('0x12')]('\x20')[_0x2e0a('0x2')]());}function u(){const _0x584745=[],_0x23c21a=[];for(const _0x3796b3 of Array[_0x2e0a('0x8')](document[_0x2e0a('0xa')])){if(_0x3796b3[_0x2e0a('0x3')][_0x2e0a('0x0')](_0x2e0a('0xd')))for(const _0x45d383 of Array[_0x2e0a('0x8')](_0x3796b3[_0x2e0a('0xc')]))-0x1!==_0x45d383[_0x2e0a('0x1')][_0x2e0a('0x10')](_0x2e0a('0x11'))?_0x584745[_0x2e0a('0x5')](_0x45d383[_0x2e0a('0x1')]):-0x1!==_0x45d383['cssText'][_0x2e0a('0x10')](_0x2e0a('0xb'))&&_0x23c21a[_0x2e0a('0x5')](_0x45d383[_0x2e0a('0x1')]);}return _0x584745[_0x2e0a('0x6')]||console[_0x2e0a('0x13')](_0x2e0a('0xf')),[..._0x23c21a,..._0x584745][_0x2e0a('0x12')]('\x20')[_0x2e0a('0x2')]();}
23
+ const _0x3651=['indexOf','all','cssText','.ck-content','hasAttribute','fetch','from','join','push','cssRules','data-cke','then','length','warn','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','trim'];(function(_0x4bdb82,_0x365175){const _0x9394a3=function(_0x623a12){while(--_0x623a12){_0x4bdb82['push'](_0x4bdb82['shift']());}};_0x9394a3(++_0x365175);}(_0x3651,0x1a2));const _0x9394=function(_0x4bdb82,_0x365175){_0x4bdb82=_0x4bdb82-0x0;let _0x9394a3=_0x3651[_0x4bdb82];return _0x9394a3;};export function getStyles(_0x34a1b7){if(!_0x34a1b7)return new Promise(_0x596192=>_0x596192(''));const _0x2b8774=[];for(const _0x58d164 of _0x34a1b7)'EDITOR_STYLES'!==_0x58d164?_0x2b8774[_0x9394('0xf')](window[_0x9394('0xc')](_0x58d164)[_0x9394('0x1')](_0x32b28d=>_0x32b28d['text']())):_0x2b8774[_0x9394('0xf')](u());return Promise[_0x9394('0x8')](_0x2b8774)[_0x9394('0x1')](_0xf41b01=>_0xf41b01[_0x9394('0xe')]('\x20')[_0x9394('0x6')]());}function u(){const _0x58dd6c=[],_0x36e2cb=[];for(const _0x32ef38 of Array[_0x9394('0xd')](document[_0x9394('0x5')])){if(_0x32ef38['ownerNode'][_0x9394('0xb')](_0x9394('0x0')))for(const _0x17f817 of Array[_0x9394('0xd')](_0x32ef38[_0x9394('0x10')]))-0x1!==_0x17f817['cssText'][_0x9394('0x7')](_0x9394('0xa'))?_0x58dd6c['push'](_0x17f817[_0x9394('0x9')]):-0x1!==_0x17f817[_0x9394('0x9')][_0x9394('0x7')](':root')&&_0x36e2cb[_0x9394('0xf')](_0x17f817['cssText']);}return _0x58dd6c[_0x9394('0x2')]||console[_0x9394('0x3')](_0x9394('0x4')),[..._0x36e2cb,..._0x58dd6c][_0x9394('0xe')]('\x20')[_0x9394('0x6')]();}
@@ -1,53 +0,0 @@
1
- /*
2
- * 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
- /* TODO
7
- Extract theme-lark styles before public release.
8
- */
9
-
10
- :root {
11
- --ck-toolbar-spinner-size: 18px;
12
- }
13
-
14
- .ck-exportpdf_status-pending {
15
- position: relative;
16
- }
17
-
18
- .ck.ck-exportpdf__spinner-container {
19
- display: none;
20
- }
21
-
22
- .ck.ck-exportpdf__spinner {
23
- position: absolute;
24
- top: 50%;
25
- left: 0;
26
- right: 0;
27
- margin: 0 auto;
28
- width: var(--ck-toolbar-spinner-size);
29
- height: var(--ck-toolbar-spinner-size);
30
- border-radius: 50%;
31
- border: 2px solid var(--ck-color-text);
32
- border-top-color: transparent;
33
- transform: translateY(-50%);
34
- z-index: 1;
35
- }
36
-
37
- .ck-exportpdf_status-pending .ck.ck-exportpdf__spinner-container {
38
- display: block;
39
- position: absolute;
40
- width: var(--ck-toolbar-spinner-size);
41
- height: var(--ck-toolbar-spinner-size);
42
- animation: 1.5s infinite rotate linear;
43
- }
44
-
45
- .ck-exportpdf_status-pending .ck.ck-button__icon {
46
- color: transparent;
47
- }
48
-
49
- @keyframes rotate {
50
- to {
51
- transform: rotate(360deg)
52
- }
53
- }