jodit-pro
Version:
PRO Version of Jodit Editor
215 lines (184 loc) • 9.31 kB
JavaScript
/*!
* jodit-pro - PRO Version of Jodit Editor
* Author: Chupurnov Valerii <chupurnov@gmail.com>
* Version: v4.9.27
* Url: https://xdsoft.net/jodit/pro/
* License(s): SEE LICENSE IN LICENSE.md
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else {
var a = factory();
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
}
})(self, function() {
return (self["webpackChunkjodit_pro"] = self["webpackChunkjodit_pro"] || []).push([[210],{
/***/ 11886:
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
;
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ _: function() { return /* binding */ _object_spread_props; }
/* harmony export */ });
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) {
symbols = symbols.filter(function(sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
}
keys.push.apply(keys, symbols);
}
return keys;
}
function _object_spread_props(target, source) {
source = source != null ? source : {};
if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
else {
ownKeys(Object(source)).forEach(function(key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
/***/ }),
/***/ 53121:
/***/ (function(module) {
module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"> <path d=\"M19,21H5a2,2,0,0,1-2-2V17a1,1,0,0,1,2,0v2H19V17a1,1,0,0,1,2,0v2A2,2,0,0,1,19,21Z\"/> <path d=\"M18,5H6A1,1,0,0,1,6,3H18a1,1,0,0,1,0,2Z\"/> <path d=\"M15.71,10.29l-3-3a1,1,0,0,0-.33-.21,1,1,0,0,0-.76,0,1,1,0,0,0-.33.21l-3,3a1,1,0,0,0-.21,1.09A1,1,0,0,0,9,12h2v3a1,1,0,0,0,2,0V12h2a1,1,0,0,0,.92-.62A1,1,0,0,0,15.71,10.29Z\"/> </svg>"
/***/ }),
/***/ 90832:
/***/ (function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) {
;
/* harmony import */ var _assets_export_svg__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(53121);
/* harmony import */ var _assets_export_svg__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_assets_export_svg__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var jodit_esm_config__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6441);
/* harmony import */ var jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2748);
/*!
* Jodit Editor PRO (https://xdsoft.net/jodit/)
* See LICENSE.md in the project root for license information.
* Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net/jodit/pro/
*/
jodit_esm_config__WEBPACK_IMPORTED_MODULE_1__.Config.prototype.exportDocs = {
css: '',
pdf: {
externalFonts: [],
allow: true,
options: {
defaultFont: 'courier',
format: 'A4',
page_orientation: 'portrait'
}
}
};
jodit_esm_config__WEBPACK_IMPORTED_MODULE_1__.Config.prototype.controls.exportDocs = {
tooltip: 'Export',
isDisabled: (editor)=>jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isEmptyContent(editor.editor),
icon: (_assets_export_svg__WEBPACK_IMPORTED_MODULE_0___default()),
list: {
exportToPdf: 'Export to PDF'
},
command: 'exportToPDF'
};
/***/ }),
/***/ 90882:
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
;
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ ExportDocs: function() { return /* binding */ ExportDocs; }
/* harmony export */ });
/* harmony import */ var _swc_helpers_async_to_generator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(77688);
/* harmony import */ var _swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(82749);
/* harmony import */ var _swc_helpers_object_spread__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(56075);
/* harmony import */ var _swc_helpers_object_spread_props__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(11886);
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(90832);
/* harmony import */ var jodit_esm_core_dom__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(22732);
/* harmony import */ var jodit_esm_core_helpers_utils_config_proto__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(68934);
/* harmony import */ var jodit_esm_core_helpers_utils_print__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(11628);
/* harmony import */ var jodit_esm_core_plugin__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(50911);
/* harmony import */ var jodit_esm_core_request_ajax__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(54079);
/* harmony import */ var jodit_esm_plugins_print_lib_generate_critical_css__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(14625);
/* harmony import */ var jodit_pro_jodit_pro__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(2692);
/*!
* Jodit Editor PRO (https://xdsoft.net/jodit/)
* See LICENSE.md in the project root for license information.
* Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net/jodit/pro/
*/
class ExportDocs extends jodit_esm_core_plugin__WEBPACK_IMPORTED_MODULE_8__.Plugin {
afterInit(jodit) {
jodit.registerCommand('exportToPDF', ()=>(0,_swc_helpers_async_to_generator__WEBPACK_IMPORTED_MODULE_0__._)(function*() {
var _jodit_o_exportDocs_ajax;
const ajax = new jodit_esm_core_request_ajax__WEBPACK_IMPORTED_MODULE_9__.Ajax((0,_swc_helpers_object_spread_props__WEBPACK_IMPORTED_MODULE_3__._)((0,_swc_helpers_object_spread__WEBPACK_IMPORTED_MODULE_2__._)({}, (_jodit_o_exportDocs_ajax = jodit.o.exportDocs.ajax) !== null && _jodit_o_exportDocs_ajax !== void 0 ? _jodit_o_exportDocs_ajax : jodit.o.filebrowser.ajax), {
method: 'POST',
responseType: 'blob',
onProgress (percent) {
jodit.progressbar.show().progress(percent);
},
data: {
action: 'generatePdf',
html: ExportDocs.getValue(jodit),
options: (0,jodit_esm_core_helpers_utils_config_proto__WEBPACK_IMPORTED_MODULE_6__.ConfigDeepFlatten)(jodit.o.exportDocs.pdf).options
}
}));
jodit.e.on('beforeDestruct', ajax.destruct);
try {
const resp = yield ajax.send();
const buffer = yield resp.blob();
const link = this.j.create.a();
const filename = 'document.pdf';
link.href = URL.createObjectURL(buffer);
link.download = filename;
link.click();
jodit_esm_core_dom__WEBPACK_IMPORTED_MODULE_5__.Dom.safeRemove(link);
URL.revokeObjectURL(link.href);
} catch (e) {
e.message && jodit.alert(e.message);
} finally{
jodit.progressbar.progress(100);
yield jodit.async.delay(200);
jodit.progressbar.hide();
}
}).call(this));
}
static getValue(jodit) {
const [div] = (0,jodit_esm_core_helpers_utils_print__WEBPACK_IMPORTED_MODULE_7__.previewBox)(jodit);
const html = [];
jodit.o.exportDocs.pdf.externalFonts.forEach((font)=>{
if (/^</.test(font)) {
html.push(font);
} else {
html.push(`<link rel="stylesheet" href="${font}">`);
}
});
html.push(`<style>${(0,jodit_esm_plugins_print_lib_generate_critical_css__WEBPACK_IMPORTED_MODULE_10__.generateCriticalCSS)(jodit)}</style>`);
html.push(`<style>${jodit.o.exportDocs.css}</style>`);
html.push(div.innerHTML);
return html.join('\n');
}
beforeDestruct() {}
constructor(...args){
super(...args), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_1__._)(this, "buttons", [
{
name: 'exportDocs',
group: 'media'
}
]);
}
}
(0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_1__._)(ExportDocs, "requires", [
'license'
]);
jodit_pro_jodit_pro__WEBPACK_IMPORTED_MODULE_11__.JoditPro.plugins.add('exportDocs', ExportDocs);
/***/ })
},
/******/ function(__webpack_require__) { // webpackRuntimeModules
/******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
/******/ var __webpack_exports__ = (__webpack_exec__(90882));
/******/ return __webpack_exports__;
/******/ }
]);
});