lib-pajakio-v2 1.0.17 → 1.0.18
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/dist/lib-pajakio-v2.common.js +959 -0
- package/dist/lib-pajakio-v2.common.js.map +1 -1
- package/dist/lib-pajakio-v2.css +1 -1
- package/dist/lib-pajakio-v2.umd.js +959 -0
- package/dist/lib-pajakio-v2.umd.js.map +1 -1
- package/dist/lib-pajakio-v2.umd.min.js +1 -1
- package/dist/lib-pajakio-v2.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ComponentsLayout/NavigationMenu.vue +2 -1
- package/src/components/Form/FormWysiwyg.vue +1172 -0
- package/src/components/index.js +2 -0
- package/src/router/index.js +6 -0
- package/src/views/Wysiwyg.vue +166 -0
|
@@ -2040,6 +2040,13 @@ module.exports = function (name) {
|
|
|
2040
2040
|
/* unused harmony reexport * */
|
|
2041
2041
|
|
|
2042
2042
|
|
|
2043
|
+
/***/ }),
|
|
2044
|
+
|
|
2045
|
+
/***/ "c028":
|
|
2046
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
2047
|
+
|
|
2048
|
+
// extracted by mini-css-extract-plugin
|
|
2049
|
+
|
|
2043
2050
|
/***/ }),
|
|
2044
2051
|
|
|
2045
2052
|
/***/ "c04e":
|
|
@@ -2404,6 +2411,17 @@ exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
|
|
|
2404
2411
|
} : $propertyIsEnumerable;
|
|
2405
2412
|
|
|
2406
2413
|
|
|
2414
|
+
/***/ }),
|
|
2415
|
+
|
|
2416
|
+
/***/ "d831":
|
|
2417
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
2418
|
+
|
|
2419
|
+
"use strict";
|
|
2420
|
+
/* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_9_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_9_oneOf_1_1_node_modules_vue_loader_v16_dist_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_9_oneOf_1_2_node_modules_sass_loader_dist_cjs_js_ref_9_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_v16_dist_index_js_ref_1_1_FormWysiwyg_vue_vue_type_style_index_0_id_52b4ebd4_lang_scss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("c028");
|
|
2421
|
+
/* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_9_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_9_oneOf_1_1_node_modules_vue_loader_v16_dist_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_9_oneOf_1_2_node_modules_sass_loader_dist_cjs_js_ref_9_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_v16_dist_index_js_ref_1_1_FormWysiwyg_vue_vue_type_style_index_0_id_52b4ebd4_lang_scss__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_mini_css_extract_plugin_dist_loader_js_ref_9_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_9_oneOf_1_1_node_modules_vue_loader_v16_dist_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_9_oneOf_1_2_node_modules_sass_loader_dist_cjs_js_ref_9_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_v16_dist_index_js_ref_1_1_FormWysiwyg_vue_vue_type_style_index_0_id_52b4ebd4_lang_scss__WEBPACK_IMPORTED_MODULE_0__);
|
|
2422
|
+
/* unused harmony reexport * */
|
|
2423
|
+
|
|
2424
|
+
|
|
2407
2425
|
/***/ }),
|
|
2408
2426
|
|
|
2409
2427
|
/***/ "d9b5":
|
|
@@ -2686,6 +2704,7 @@ __webpack_require__.d(__webpack_exports__, "DropdownCompany", function() { retur
|
|
|
2686
2704
|
__webpack_require__.d(__webpack_exports__, "ModalDialog", function() { return /* reexport */ ModalDialog; });
|
|
2687
2705
|
__webpack_require__.d(__webpack_exports__, "FormInputTag", function() { return /* reexport */ FormInputTag; });
|
|
2688
2706
|
__webpack_require__.d(__webpack_exports__, "FormTextarea", function() { return /* reexport */ FormTextarea; });
|
|
2707
|
+
__webpack_require__.d(__webpack_exports__, "FormWysiwyg", function() { return /* reexport */ FormWysiwyg; });
|
|
2689
2708
|
__webpack_require__.d(__webpack_exports__, "ExpansionPanel", function() { return /* reexport */ ExpansionPanel; });
|
|
2690
2709
|
__webpack_require__.d(__webpack_exports__, "AnimatedIconLogo", function() { return /* reexport */ AnimatedIconLogo; });
|
|
2691
2710
|
|
|
@@ -42072,6 +42091,945 @@ var FormTextareavue_type_style_index_0_id_4b6a6dc5_lang_scss = __webpack_require
|
|
|
42072
42091
|
const FormTextarea_exports_ = /*#__PURE__*/exportHelper_default()(FormTextareavue_type_script_lang_js, [['render',FormTextareavue_type_template_id_4b6a6dc5_render]])
|
|
42073
42092
|
|
|
42074
42093
|
/* harmony default export */ var FormTextarea = (FormTextarea_exports_);
|
|
42094
|
+
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader-v16/dist??ref--1-1!./src/components/Form/FormWysiwyg.vue?vue&type=template&id=52b4ebd4
|
|
42095
|
+
|
|
42096
|
+
const FormWysiwygvue_type_template_id_52b4ebd4_hoisted_1 = {
|
|
42097
|
+
class: "form-wysiwyg flex flex-col"
|
|
42098
|
+
};
|
|
42099
|
+
const FormWysiwygvue_type_template_id_52b4ebd4_hoisted_2 = {
|
|
42100
|
+
class: "w-full"
|
|
42101
|
+
};
|
|
42102
|
+
const FormWysiwygvue_type_template_id_52b4ebd4_hoisted_3 = {
|
|
42103
|
+
key: 0,
|
|
42104
|
+
class: "toolbar"
|
|
42105
|
+
};
|
|
42106
|
+
const FormWysiwygvue_type_template_id_52b4ebd4_hoisted_4 = {
|
|
42107
|
+
key: 0,
|
|
42108
|
+
class: "toolbar-divider"
|
|
42109
|
+
};
|
|
42110
|
+
const FormWysiwygvue_type_template_id_52b4ebd4_hoisted_5 = ["disabled", "title", "onClick"];
|
|
42111
|
+
const FormWysiwygvue_type_template_id_52b4ebd4_hoisted_6 = {
|
|
42112
|
+
key: 1,
|
|
42113
|
+
class: "toolbar-text"
|
|
42114
|
+
};
|
|
42115
|
+
const FormWysiwygvue_type_template_id_52b4ebd4_hoisted_7 = ["contenteditable", "data-placeholder"];
|
|
42116
|
+
const FormWysiwygvue_type_template_id_52b4ebd4_hoisted_8 = ["innerHTML"];
|
|
42117
|
+
function FormWysiwygvue_type_template_id_52b4ebd4_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
42118
|
+
const _component_base_icon = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("base-icon");
|
|
42119
|
+
return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", FormWysiwygvue_type_template_id_52b4ebd4_hoisted_1, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", {
|
|
42120
|
+
class: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["normalizeClass"])(`label-${$props.labelPosition}`)
|
|
42121
|
+
}, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "label"), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", FormWysiwygvue_type_template_id_52b4ebd4_hoisted_2, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", {
|
|
42122
|
+
class: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["normalizeClass"])(["editor-group", {
|
|
42123
|
+
error: $props.error,
|
|
42124
|
+
disabled: $props.disabled,
|
|
42125
|
+
readonly: $props.readonly && !$props.disabled
|
|
42126
|
+
}])
|
|
42127
|
+
}, [$props.showToolbar ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", FormWysiwygvue_type_template_id_52b4ebd4_hoisted_3, [(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderList"])($options.resolvedToolbar, (item, index) => {
|
|
42128
|
+
return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], {
|
|
42129
|
+
key: `${item.action}-${index}`
|
|
42130
|
+
}, [item.action === 'divider' ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", FormWysiwygvue_type_template_id_52b4ebd4_hoisted_4)) : (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("button", {
|
|
42131
|
+
key: 1,
|
|
42132
|
+
type: "button",
|
|
42133
|
+
class: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["normalizeClass"])(["toolbar-button", {
|
|
42134
|
+
active: $options.isActionActive(item)
|
|
42135
|
+
}]),
|
|
42136
|
+
disabled: $options.isActionDisabled(item),
|
|
42137
|
+
title: item.title || item.label,
|
|
42138
|
+
onMousedown: _cache[0] || (_cache[0] = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withModifiers"])(() => {}, ["prevent"])),
|
|
42139
|
+
onClick: $event => $options.handleToolbarAction(item)
|
|
42140
|
+
}, [item.icon ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])(_component_base_icon, {
|
|
42141
|
+
key: 0,
|
|
42142
|
+
iconName: item.icon,
|
|
42143
|
+
width: "18",
|
|
42144
|
+
height: "18",
|
|
42145
|
+
color: $options.isActionActive(item) ? '#3e7dc0' : '#59636E'
|
|
42146
|
+
}, null, 8, ["iconName", "color"])) : (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("span", FormWysiwygvue_type_template_id_52b4ebd4_hoisted_6, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(item.label), 1))], 42, FormWysiwygvue_type_template_id_52b4ebd4_hoisted_5))], 64);
|
|
42147
|
+
}), 128))])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("input", {
|
|
42148
|
+
ref: "imageInputRef",
|
|
42149
|
+
type: "file",
|
|
42150
|
+
class: "image-input",
|
|
42151
|
+
accept: "image/*",
|
|
42152
|
+
onChange: _cache[1] || (_cache[1] = (...args) => $options.handleImageSelected && $options.handleImageSelected(...args))
|
|
42153
|
+
}, null, 544), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", {
|
|
42154
|
+
class: "editor-wrapper",
|
|
42155
|
+
style: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["normalizeStyle"])($options.editorStyle)
|
|
42156
|
+
}, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", {
|
|
42157
|
+
ref: "editorRef",
|
|
42158
|
+
class: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["normalizeClass"])(["editor-area", {
|
|
42159
|
+
'is-empty': $data.isEmpty
|
|
42160
|
+
}]),
|
|
42161
|
+
contenteditable: $options.isEditable,
|
|
42162
|
+
"data-placeholder": $props.placeholder,
|
|
42163
|
+
onInput: _cache[2] || (_cache[2] = (...args) => $options.handleInput && $options.handleInput(...args)),
|
|
42164
|
+
onFocus: _cache[3] || (_cache[3] = (...args) => $options.handleFocus && $options.handleFocus(...args)),
|
|
42165
|
+
onBlur: _cache[4] || (_cache[4] = (...args) => $options.handleBlur && $options.handleBlur(...args)),
|
|
42166
|
+
onPaste: _cache[5] || (_cache[5] = (...args) => $options.handlePaste && $options.handlePaste(...args)),
|
|
42167
|
+
onMouseup: _cache[6] || (_cache[6] = (...args) => $options.refreshToolbarState && $options.refreshToolbarState(...args)),
|
|
42168
|
+
onKeyup: _cache[7] || (_cache[7] = (...args) => $options.refreshToolbarState && $options.refreshToolbarState(...args)),
|
|
42169
|
+
onMousedown: _cache[8] || (_cache[8] = (...args) => $options.handleEditorMouseDown && $options.handleEditorMouseDown(...args)),
|
|
42170
|
+
onMousemove: _cache[9] || (_cache[9] = (...args) => $options.handleEditorMouseMove && $options.handleEditorMouseMove(...args)),
|
|
42171
|
+
onMouseleave: _cache[10] || (_cache[10] = (...args) => $options.handleEditorMouseLeave && $options.handleEditorMouseLeave(...args))
|
|
42172
|
+
}, null, 42, FormWysiwygvue_type_template_id_52b4ebd4_hoisted_7)], 4)], 2), $props.message ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", {
|
|
42173
|
+
key: 0,
|
|
42174
|
+
class: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["normalizeClass"])(["helper-text", {
|
|
42175
|
+
'error-helper': $props.error
|
|
42176
|
+
}])
|
|
42177
|
+
}, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", {
|
|
42178
|
+
innerHTML: $props.message
|
|
42179
|
+
}, null, 8, FormWysiwygvue_type_template_id_52b4ebd4_hoisted_8)], 2)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)])], 2)]);
|
|
42180
|
+
}
|
|
42181
|
+
// CONCATENATED MODULE: ./src/components/Form/FormWysiwyg.vue?vue&type=template&id=52b4ebd4
|
|
42182
|
+
|
|
42183
|
+
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader-v16/dist??ref--1-1!./src/components/Form/FormWysiwyg.vue?vue&type=script&lang=js
|
|
42184
|
+
|
|
42185
|
+
const TOOLBAR_ITEMS = {
|
|
42186
|
+
paragraph: {
|
|
42187
|
+
action: "paragraph",
|
|
42188
|
+
label: "P",
|
|
42189
|
+
title: "Paragraph"
|
|
42190
|
+
},
|
|
42191
|
+
heading1: {
|
|
42192
|
+
action: "heading1",
|
|
42193
|
+
label: "H1",
|
|
42194
|
+
title: "Heading 1"
|
|
42195
|
+
},
|
|
42196
|
+
heading2: {
|
|
42197
|
+
action: "heading2",
|
|
42198
|
+
label: "H2",
|
|
42199
|
+
title: "Heading 2"
|
|
42200
|
+
},
|
|
42201
|
+
bold: {
|
|
42202
|
+
action: "bold",
|
|
42203
|
+
icon: "format_bold",
|
|
42204
|
+
title: "Bold"
|
|
42205
|
+
},
|
|
42206
|
+
italic: {
|
|
42207
|
+
action: "italic",
|
|
42208
|
+
icon: "format_italic",
|
|
42209
|
+
title: "Italic"
|
|
42210
|
+
},
|
|
42211
|
+
underline: {
|
|
42212
|
+
action: "underline",
|
|
42213
|
+
icon: "format_underlined",
|
|
42214
|
+
title: "Underline"
|
|
42215
|
+
},
|
|
42216
|
+
strikeThrough: {
|
|
42217
|
+
action: "strikeThrough",
|
|
42218
|
+
icon: "strikethrough_s",
|
|
42219
|
+
title: "Strikethrough"
|
|
42220
|
+
},
|
|
42221
|
+
unorderedList: {
|
|
42222
|
+
action: "unorderedList",
|
|
42223
|
+
icon: "format_list_bulleted",
|
|
42224
|
+
title: "Bullet List"
|
|
42225
|
+
},
|
|
42226
|
+
orderedList: {
|
|
42227
|
+
action: "orderedList",
|
|
42228
|
+
icon: "format_list_numbered",
|
|
42229
|
+
title: "Numbered List"
|
|
42230
|
+
},
|
|
42231
|
+
blockquote: {
|
|
42232
|
+
action: "blockquote",
|
|
42233
|
+
icon: "format_quote",
|
|
42234
|
+
title: "Quote"
|
|
42235
|
+
},
|
|
42236
|
+
alignLeft: {
|
|
42237
|
+
action: "alignLeft",
|
|
42238
|
+
icon: "format_align_left",
|
|
42239
|
+
title: "Align Left"
|
|
42240
|
+
},
|
|
42241
|
+
alignCenter: {
|
|
42242
|
+
action: "alignCenter",
|
|
42243
|
+
icon: "format_align_center",
|
|
42244
|
+
title: "Align Center"
|
|
42245
|
+
},
|
|
42246
|
+
alignRight: {
|
|
42247
|
+
action: "alignRight",
|
|
42248
|
+
icon: "format_align_right",
|
|
42249
|
+
title: "Align Right"
|
|
42250
|
+
},
|
|
42251
|
+
alignJustify: {
|
|
42252
|
+
action: "alignJustify",
|
|
42253
|
+
icon: "format_align_justify",
|
|
42254
|
+
title: "Justify"
|
|
42255
|
+
},
|
|
42256
|
+
link: {
|
|
42257
|
+
action: "link",
|
|
42258
|
+
icon: "insert_link",
|
|
42259
|
+
title: "Insert Link"
|
|
42260
|
+
},
|
|
42261
|
+
insertImage: {
|
|
42262
|
+
action: "insertImage",
|
|
42263
|
+
icon: "insert_photo",
|
|
42264
|
+
title: "Insert Image"
|
|
42265
|
+
},
|
|
42266
|
+
unlink: {
|
|
42267
|
+
action: "unlink",
|
|
42268
|
+
icon: "link_off",
|
|
42269
|
+
title: "Remove Link"
|
|
42270
|
+
},
|
|
42271
|
+
undo: {
|
|
42272
|
+
action: "undo",
|
|
42273
|
+
icon: "undo",
|
|
42274
|
+
title: "Undo"
|
|
42275
|
+
},
|
|
42276
|
+
redo: {
|
|
42277
|
+
action: "redo",
|
|
42278
|
+
icon: "redo",
|
|
42279
|
+
title: "Redo"
|
|
42280
|
+
},
|
|
42281
|
+
clear: {
|
|
42282
|
+
action: "clear",
|
|
42283
|
+
icon: "format_clear",
|
|
42284
|
+
title: "Clear Format"
|
|
42285
|
+
},
|
|
42286
|
+
divider: {
|
|
42287
|
+
action: "divider"
|
|
42288
|
+
}
|
|
42289
|
+
};
|
|
42290
|
+
const DEFAULT_TOOLBAR = ["paragraph", "heading1", "heading2", "divider", "bold", "italic", "underline", "strikeThrough", "divider", "unorderedList", "orderedList", "blockquote", "divider", "alignLeft", "alignCenter", "alignRight", "alignJustify", "divider", "link", "insertImage", "unlink", "divider", "undo", "redo", "clear"];
|
|
42291
|
+
const ALIGNABLE_TAGS = ["P", "DIV", "H1", "H2", "H3", "BLOCKQUOTE", "LI", "PRE"];
|
|
42292
|
+
const SAFE_PROTOCOLS = ["http://", "https://", "mailto:", "tel:"];
|
|
42293
|
+
const SAFE_IMAGE_PROTOCOLS = ["http://", "https://", "data:image/", "blob:", "/"];
|
|
42294
|
+
const IMAGE_MIN_WIDTH = 40;
|
|
42295
|
+
const IMAGE_RESIZE_HANDLE_GAP = 16;
|
|
42296
|
+
const ALLOWED_TAGS = ["A", "B", "BLOCKQUOTE", "BR", "CODE", "DIV", "EM", "H1", "H2", "H3", "I", "IMG", "LI", "OL", "P", "PRE", "S", "SPAN", "STRIKE", "STRONG", "U", "UL"];
|
|
42297
|
+
/* harmony default export */ var FormWysiwygvue_type_script_lang_js = ({
|
|
42298
|
+
components: {
|
|
42299
|
+
BaseIcon: BaseIcon
|
|
42300
|
+
},
|
|
42301
|
+
props: {
|
|
42302
|
+
modelValue: {
|
|
42303
|
+
type: [String, Number],
|
|
42304
|
+
default: ""
|
|
42305
|
+
},
|
|
42306
|
+
placeholder: {
|
|
42307
|
+
type: String,
|
|
42308
|
+
default: "Write your content here"
|
|
42309
|
+
},
|
|
42310
|
+
message: {
|
|
42311
|
+
type: String,
|
|
42312
|
+
default: ""
|
|
42313
|
+
},
|
|
42314
|
+
error: {
|
|
42315
|
+
type: Boolean,
|
|
42316
|
+
default: false
|
|
42317
|
+
},
|
|
42318
|
+
disabled: {
|
|
42319
|
+
type: Boolean,
|
|
42320
|
+
default: false
|
|
42321
|
+
},
|
|
42322
|
+
readonly: {
|
|
42323
|
+
type: Boolean,
|
|
42324
|
+
default: false
|
|
42325
|
+
},
|
|
42326
|
+
labelPosition: {
|
|
42327
|
+
type: String,
|
|
42328
|
+
default: "top",
|
|
42329
|
+
validator(value) {
|
|
42330
|
+
return ["left", "top"].includes(value);
|
|
42331
|
+
}
|
|
42332
|
+
},
|
|
42333
|
+
minHeight: {
|
|
42334
|
+
type: [Number, String],
|
|
42335
|
+
default: 180
|
|
42336
|
+
},
|
|
42337
|
+
maxHeight: {
|
|
42338
|
+
type: [Number, String],
|
|
42339
|
+
default: ""
|
|
42340
|
+
},
|
|
42341
|
+
toolbar: {
|
|
42342
|
+
type: Array,
|
|
42343
|
+
default: () => []
|
|
42344
|
+
},
|
|
42345
|
+
showToolbar: {
|
|
42346
|
+
type: Boolean,
|
|
42347
|
+
default: true
|
|
42348
|
+
},
|
|
42349
|
+
sanitizeOnPaste: {
|
|
42350
|
+
type: Boolean,
|
|
42351
|
+
default: true
|
|
42352
|
+
},
|
|
42353
|
+
sanitizeOnBlur: {
|
|
42354
|
+
type: Boolean,
|
|
42355
|
+
default: true
|
|
42356
|
+
}
|
|
42357
|
+
},
|
|
42358
|
+
emits: ["update:modelValue", "update:text", "input", "change", "focus", "blur"],
|
|
42359
|
+
data() {
|
|
42360
|
+
return {
|
|
42361
|
+
isEmpty: true,
|
|
42362
|
+
isFocused: false,
|
|
42363
|
+
isEmitting: false,
|
|
42364
|
+
savedRange: null,
|
|
42365
|
+
imageResize: {
|
|
42366
|
+
active: false,
|
|
42367
|
+
target: null,
|
|
42368
|
+
startX: 0,
|
|
42369
|
+
startWidth: 0,
|
|
42370
|
+
maxWidth: 0
|
|
42371
|
+
},
|
|
42372
|
+
toolbarState: {
|
|
42373
|
+
bold: false,
|
|
42374
|
+
italic: false,
|
|
42375
|
+
underline: false,
|
|
42376
|
+
strikeThrough: false,
|
|
42377
|
+
unorderedList: false,
|
|
42378
|
+
orderedList: false,
|
|
42379
|
+
blockquote: false,
|
|
42380
|
+
align: "justifyLeft",
|
|
42381
|
+
formatBlock: "P"
|
|
42382
|
+
}
|
|
42383
|
+
};
|
|
42384
|
+
},
|
|
42385
|
+
computed: {
|
|
42386
|
+
resolvedToolbar() {
|
|
42387
|
+
const source = this.toolbar.length ? this.toolbar : DEFAULT_TOOLBAR;
|
|
42388
|
+
return source.map(item => {
|
|
42389
|
+
if (typeof item === "string") {
|
|
42390
|
+
return TOOLBAR_ITEMS[item] || null;
|
|
42391
|
+
}
|
|
42392
|
+
if (!item || !item.action) {
|
|
42393
|
+
return null;
|
|
42394
|
+
}
|
|
42395
|
+
return item;
|
|
42396
|
+
}).filter(item => item);
|
|
42397
|
+
},
|
|
42398
|
+
editorStyle() {
|
|
42399
|
+
const maxHeight = this.maxHeight ? this.normalizeSize(this.maxHeight) : "none";
|
|
42400
|
+
return {
|
|
42401
|
+
minHeight: this.normalizeSize(this.minHeight),
|
|
42402
|
+
maxHeight: maxHeight
|
|
42403
|
+
};
|
|
42404
|
+
},
|
|
42405
|
+
isEditable() {
|
|
42406
|
+
return !this.disabled && !this.readonly;
|
|
42407
|
+
}
|
|
42408
|
+
},
|
|
42409
|
+
watch: {
|
|
42410
|
+
modelValue(newValue) {
|
|
42411
|
+
if (this.isEmitting) {
|
|
42412
|
+
return;
|
|
42413
|
+
}
|
|
42414
|
+
this.setEditorValue(newValue);
|
|
42415
|
+
}
|
|
42416
|
+
},
|
|
42417
|
+
mounted() {
|
|
42418
|
+
this.setEditorValue(this.modelValue);
|
|
42419
|
+
this.refreshToolbarState();
|
|
42420
|
+
document.addEventListener("selectionchange", this.handleSelectionChange);
|
|
42421
|
+
},
|
|
42422
|
+
beforeUnmount() {
|
|
42423
|
+
document.removeEventListener("selectionchange", this.handleSelectionChange);
|
|
42424
|
+
this.stopImageResize();
|
|
42425
|
+
},
|
|
42426
|
+
methods: {
|
|
42427
|
+
normalizeSize(value) {
|
|
42428
|
+
return Number.isFinite(Number(value)) ? `${Number(value)}px` : String(value);
|
|
42429
|
+
},
|
|
42430
|
+
setEditorValue(value) {
|
|
42431
|
+
const editor = this.$refs.editorRef;
|
|
42432
|
+
if (!editor) {
|
|
42433
|
+
return;
|
|
42434
|
+
}
|
|
42435
|
+
let nextValue = value == null ? "" : String(value);
|
|
42436
|
+
if (this.sanitizeOnBlur && nextValue) {
|
|
42437
|
+
nextValue = this.sanitizeHtml(nextValue);
|
|
42438
|
+
}
|
|
42439
|
+
if (this.isHtmlEmpty(nextValue)) {
|
|
42440
|
+
nextValue = "";
|
|
42441
|
+
}
|
|
42442
|
+
if (editor.innerHTML !== nextValue) {
|
|
42443
|
+
editor.innerHTML = nextValue;
|
|
42444
|
+
}
|
|
42445
|
+
this.updateEmptyState();
|
|
42446
|
+
},
|
|
42447
|
+
handleInput() {
|
|
42448
|
+
this.emitModelValue();
|
|
42449
|
+
this.refreshToolbarState();
|
|
42450
|
+
},
|
|
42451
|
+
handleFocus() {
|
|
42452
|
+
this.isFocused = true;
|
|
42453
|
+
this.$emit("focus");
|
|
42454
|
+
this.refreshToolbarState();
|
|
42455
|
+
},
|
|
42456
|
+
handleBlur() {
|
|
42457
|
+
this.isFocused = false;
|
|
42458
|
+
if (this.sanitizeOnBlur) {
|
|
42459
|
+
const editor = this.$refs.editorRef;
|
|
42460
|
+
const sanitizedValue = this.sanitizeHtml(editor.innerHTML);
|
|
42461
|
+
if (editor.innerHTML !== sanitizedValue) {
|
|
42462
|
+
editor.innerHTML = sanitizedValue;
|
|
42463
|
+
}
|
|
42464
|
+
}
|
|
42465
|
+
const htmlValue = this.emitModelValue();
|
|
42466
|
+
this.$emit("change", htmlValue);
|
|
42467
|
+
this.$emit("blur", htmlValue);
|
|
42468
|
+
this.refreshToolbarState();
|
|
42469
|
+
},
|
|
42470
|
+
handlePaste(event) {
|
|
42471
|
+
if (!this.sanitizeOnPaste || !this.isEditable) {
|
|
42472
|
+
return;
|
|
42473
|
+
}
|
|
42474
|
+
event.preventDefault();
|
|
42475
|
+
const clipboardData = event.clipboardData || window.clipboardData;
|
|
42476
|
+
const htmlPayload = clipboardData.getData("text/html");
|
|
42477
|
+
const textPayload = clipboardData.getData("text/plain");
|
|
42478
|
+
let contentToInsert = "";
|
|
42479
|
+
if (htmlPayload) {
|
|
42480
|
+
contentToInsert = this.sanitizeHtml(htmlPayload);
|
|
42481
|
+
} else {
|
|
42482
|
+
contentToInsert = this.escapeHtml(textPayload).replace(/\n/g, "<br>");
|
|
42483
|
+
}
|
|
42484
|
+
this.focusEditor();
|
|
42485
|
+
document.execCommand("insertHTML", false, contentToInsert);
|
|
42486
|
+
this.handleInput();
|
|
42487
|
+
},
|
|
42488
|
+
handleSelectionChange() {
|
|
42489
|
+
if (this.isFocused) {
|
|
42490
|
+
this.refreshToolbarState();
|
|
42491
|
+
}
|
|
42492
|
+
},
|
|
42493
|
+
handleEditorMouseDown(event) {
|
|
42494
|
+
if (!this.isEditable) {
|
|
42495
|
+
return;
|
|
42496
|
+
}
|
|
42497
|
+
const targetImage = event.target;
|
|
42498
|
+
if (!targetImage || targetImage.tagName !== "IMG") {
|
|
42499
|
+
return;
|
|
42500
|
+
}
|
|
42501
|
+
if (!this.isOnImageResizeHandle(event, targetImage)) {
|
|
42502
|
+
return;
|
|
42503
|
+
}
|
|
42504
|
+
event.preventDefault();
|
|
42505
|
+
this.startImageResize(event, targetImage);
|
|
42506
|
+
},
|
|
42507
|
+
handleEditorMouseMove(event) {
|
|
42508
|
+
if (this.imageResize.active) {
|
|
42509
|
+
return;
|
|
42510
|
+
}
|
|
42511
|
+
const editor = this.$refs.editorRef;
|
|
42512
|
+
if (!editor) {
|
|
42513
|
+
return;
|
|
42514
|
+
}
|
|
42515
|
+
const targetImage = event.target;
|
|
42516
|
+
if (!targetImage || targetImage.tagName !== "IMG") {
|
|
42517
|
+
editor.style.cursor = "";
|
|
42518
|
+
return;
|
|
42519
|
+
}
|
|
42520
|
+
editor.style.cursor = this.isOnImageResizeHandle(event, targetImage) ? "nwse-resize" : "";
|
|
42521
|
+
},
|
|
42522
|
+
handleEditorMouseLeave() {
|
|
42523
|
+
if (this.imageResize.active) {
|
|
42524
|
+
return;
|
|
42525
|
+
}
|
|
42526
|
+
const editor = this.$refs.editorRef;
|
|
42527
|
+
if (editor) {
|
|
42528
|
+
editor.style.cursor = "";
|
|
42529
|
+
}
|
|
42530
|
+
},
|
|
42531
|
+
startImageResize(event, imageNode) {
|
|
42532
|
+
this.imageResize = {
|
|
42533
|
+
active: true,
|
|
42534
|
+
target: imageNode,
|
|
42535
|
+
startX: event.clientX,
|
|
42536
|
+
startWidth: this.getImageWidth(imageNode),
|
|
42537
|
+
maxWidth: this.getImageResizeMaxWidth()
|
|
42538
|
+
};
|
|
42539
|
+
imageNode.classList.add("resizing-image");
|
|
42540
|
+
document.body.style.userSelect = "none";
|
|
42541
|
+
window.addEventListener("mousemove", this.onImageResizeMove);
|
|
42542
|
+
window.addEventListener("mouseup", this.stopImageResize);
|
|
42543
|
+
},
|
|
42544
|
+
onImageResizeMove(event) {
|
|
42545
|
+
if (!this.imageResize.active || !this.imageResize.target) {
|
|
42546
|
+
return;
|
|
42547
|
+
}
|
|
42548
|
+
const deltaX = event.clientX - this.imageResize.startX;
|
|
42549
|
+
const nextWidth = Math.max(IMAGE_MIN_WIDTH, Math.min(this.imageResize.startWidth + deltaX, this.imageResize.maxWidth));
|
|
42550
|
+
this.imageResize.target.style.width = `${nextWidth}px`;
|
|
42551
|
+
this.imageResize.target.setAttribute("width", `${Math.round(nextWidth)}`);
|
|
42552
|
+
this.imageResize.target.style.height = "auto";
|
|
42553
|
+
},
|
|
42554
|
+
stopImageResize() {
|
|
42555
|
+
if (!this.imageResize.active) {
|
|
42556
|
+
return;
|
|
42557
|
+
}
|
|
42558
|
+
const resizedTarget = this.imageResize.target;
|
|
42559
|
+
if (resizedTarget) {
|
|
42560
|
+
resizedTarget.classList.remove("resizing-image");
|
|
42561
|
+
}
|
|
42562
|
+
this.imageResize = {
|
|
42563
|
+
active: false,
|
|
42564
|
+
target: null,
|
|
42565
|
+
startX: 0,
|
|
42566
|
+
startWidth: 0,
|
|
42567
|
+
maxWidth: 0
|
|
42568
|
+
};
|
|
42569
|
+
document.body.style.userSelect = "";
|
|
42570
|
+
window.removeEventListener("mousemove", this.onImageResizeMove);
|
|
42571
|
+
window.removeEventListener("mouseup", this.stopImageResize);
|
|
42572
|
+
const editor = this.$refs.editorRef;
|
|
42573
|
+
if (editor) {
|
|
42574
|
+
editor.style.cursor = "";
|
|
42575
|
+
}
|
|
42576
|
+
this.emitModelValue();
|
|
42577
|
+
},
|
|
42578
|
+
getImageWidth(imageNode) {
|
|
42579
|
+
const widthFromAttribute = Number(imageNode.getAttribute("width"));
|
|
42580
|
+
if (Number.isFinite(widthFromAttribute) && widthFromAttribute > 0) {
|
|
42581
|
+
return widthFromAttribute;
|
|
42582
|
+
}
|
|
42583
|
+
const rect = imageNode.getBoundingClientRect();
|
|
42584
|
+
if (rect.width > 0) {
|
|
42585
|
+
return rect.width;
|
|
42586
|
+
}
|
|
42587
|
+
return IMAGE_MIN_WIDTH;
|
|
42588
|
+
},
|
|
42589
|
+
getImageResizeMaxWidth() {
|
|
42590
|
+
const editor = this.$refs.editorRef;
|
|
42591
|
+
if (!editor) {
|
|
42592
|
+
return 1200;
|
|
42593
|
+
}
|
|
42594
|
+
const editorWidth = editor.clientWidth || 1200;
|
|
42595
|
+
return Math.max(editorWidth, IMAGE_MIN_WIDTH);
|
|
42596
|
+
},
|
|
42597
|
+
isOnImageResizeHandle(event, imageNode) {
|
|
42598
|
+
const imageRect = imageNode.getBoundingClientRect();
|
|
42599
|
+
const isInsideX = event.clientX >= imageRect.right - IMAGE_RESIZE_HANDLE_GAP;
|
|
42600
|
+
const isInsideY = event.clientY >= imageRect.bottom - IMAGE_RESIZE_HANDLE_GAP;
|
|
42601
|
+
return isInsideX && isInsideY;
|
|
42602
|
+
},
|
|
42603
|
+
emitModelValue() {
|
|
42604
|
+
const editor = this.$refs.editorRef;
|
|
42605
|
+
if (!editor) {
|
|
42606
|
+
return "";
|
|
42607
|
+
}
|
|
42608
|
+
let htmlValue = editor.innerHTML;
|
|
42609
|
+
if (this.isHtmlEmpty(htmlValue)) {
|
|
42610
|
+
htmlValue = "";
|
|
42611
|
+
if (editor.innerHTML !== "") {
|
|
42612
|
+
editor.innerHTML = "";
|
|
42613
|
+
}
|
|
42614
|
+
}
|
|
42615
|
+
this.updateEmptyState();
|
|
42616
|
+
this.isEmitting = true;
|
|
42617
|
+
this.$emit("update:modelValue", htmlValue);
|
|
42618
|
+
this.$emit("input", htmlValue);
|
|
42619
|
+
this.$emit("update:text", this.getPlainText());
|
|
42620
|
+
this.$nextTick(() => {
|
|
42621
|
+
this.isEmitting = false;
|
|
42622
|
+
});
|
|
42623
|
+
return htmlValue;
|
|
42624
|
+
},
|
|
42625
|
+
refreshToolbarState() {
|
|
42626
|
+
if (!this.selectionInsideEditor()) {
|
|
42627
|
+
this.toolbarState = {
|
|
42628
|
+
bold: false,
|
|
42629
|
+
italic: false,
|
|
42630
|
+
underline: false,
|
|
42631
|
+
strikeThrough: false,
|
|
42632
|
+
unorderedList: false,
|
|
42633
|
+
orderedList: false,
|
|
42634
|
+
blockquote: false,
|
|
42635
|
+
align: "justifyLeft",
|
|
42636
|
+
formatBlock: "P"
|
|
42637
|
+
};
|
|
42638
|
+
return;
|
|
42639
|
+
}
|
|
42640
|
+
const activeAlign = ["justifyLeft", "justifyCenter", "justifyRight", "justifyFull"].find(command => document.queryCommandState(command));
|
|
42641
|
+
const blockValue = (document.queryCommandValue("formatBlock") || "").replace(/[<>]/g, "").toUpperCase();
|
|
42642
|
+
this.toolbarState = {
|
|
42643
|
+
bold: document.queryCommandState("bold"),
|
|
42644
|
+
italic: document.queryCommandState("italic"),
|
|
42645
|
+
underline: document.queryCommandState("underline"),
|
|
42646
|
+
strikeThrough: document.queryCommandState("strikeThrough"),
|
|
42647
|
+
unorderedList: document.queryCommandState("insertUnorderedList"),
|
|
42648
|
+
orderedList: document.queryCommandState("insertOrderedList"),
|
|
42649
|
+
blockquote: blockValue === "BLOCKQUOTE",
|
|
42650
|
+
align: activeAlign || "justifyLeft",
|
|
42651
|
+
formatBlock: blockValue || "P"
|
|
42652
|
+
};
|
|
42653
|
+
},
|
|
42654
|
+
selectionInsideEditor() {
|
|
42655
|
+
const editor = this.$refs.editorRef;
|
|
42656
|
+
const selection = window.getSelection();
|
|
42657
|
+
if (!editor || !selection || !selection.rangeCount) {
|
|
42658
|
+
return false;
|
|
42659
|
+
}
|
|
42660
|
+
const range = selection.getRangeAt(0);
|
|
42661
|
+
return editor.contains(range.commonAncestorContainer);
|
|
42662
|
+
},
|
|
42663
|
+
focusEditor() {
|
|
42664
|
+
const editor = this.$refs.editorRef;
|
|
42665
|
+
if (!editor) {
|
|
42666
|
+
return;
|
|
42667
|
+
}
|
|
42668
|
+
editor.focus();
|
|
42669
|
+
if (!this.selectionInsideEditor()) {
|
|
42670
|
+
const range = document.createRange();
|
|
42671
|
+
range.selectNodeContents(editor);
|
|
42672
|
+
range.collapse(false);
|
|
42673
|
+
const selection = window.getSelection();
|
|
42674
|
+
selection.removeAllRanges();
|
|
42675
|
+
selection.addRange(range);
|
|
42676
|
+
}
|
|
42677
|
+
},
|
|
42678
|
+
handleToolbarAction(item) {
|
|
42679
|
+
if (this.isActionDisabled(item)) {
|
|
42680
|
+
return;
|
|
42681
|
+
}
|
|
42682
|
+
this.focusEditor();
|
|
42683
|
+
this.saveRange();
|
|
42684
|
+
switch (item.action) {
|
|
42685
|
+
case "paragraph":
|
|
42686
|
+
this.executeCommand("formatBlock", "P");
|
|
42687
|
+
break;
|
|
42688
|
+
case "heading1":
|
|
42689
|
+
this.executeCommand("formatBlock", "H1");
|
|
42690
|
+
break;
|
|
42691
|
+
case "heading2":
|
|
42692
|
+
this.executeCommand("formatBlock", "H2");
|
|
42693
|
+
break;
|
|
42694
|
+
case "bold":
|
|
42695
|
+
this.executeCommand("bold");
|
|
42696
|
+
break;
|
|
42697
|
+
case "italic":
|
|
42698
|
+
this.executeCommand("italic");
|
|
42699
|
+
break;
|
|
42700
|
+
case "underline":
|
|
42701
|
+
this.executeCommand("underline");
|
|
42702
|
+
break;
|
|
42703
|
+
case "strikeThrough":
|
|
42704
|
+
this.executeCommand("strikeThrough");
|
|
42705
|
+
break;
|
|
42706
|
+
case "unorderedList":
|
|
42707
|
+
this.executeCommand("insertUnorderedList");
|
|
42708
|
+
break;
|
|
42709
|
+
case "orderedList":
|
|
42710
|
+
this.executeCommand("insertOrderedList");
|
|
42711
|
+
break;
|
|
42712
|
+
case "blockquote":
|
|
42713
|
+
if (this.toolbarState.blockquote) {
|
|
42714
|
+
this.executeCommand("formatBlock", "P");
|
|
42715
|
+
} else {
|
|
42716
|
+
this.executeCommand("formatBlock", "BLOCKQUOTE");
|
|
42717
|
+
}
|
|
42718
|
+
break;
|
|
42719
|
+
case "alignLeft":
|
|
42720
|
+
this.executeCommand("justifyLeft");
|
|
42721
|
+
break;
|
|
42722
|
+
case "alignCenter":
|
|
42723
|
+
this.executeCommand("justifyCenter");
|
|
42724
|
+
break;
|
|
42725
|
+
case "alignRight":
|
|
42726
|
+
this.executeCommand("justifyRight");
|
|
42727
|
+
break;
|
|
42728
|
+
case "alignJustify":
|
|
42729
|
+
this.executeCommand("justifyFull");
|
|
42730
|
+
break;
|
|
42731
|
+
case "link":
|
|
42732
|
+
this.createLink();
|
|
42733
|
+
break;
|
|
42734
|
+
case "insertImage":
|
|
42735
|
+
this.triggerImagePicker();
|
|
42736
|
+
break;
|
|
42737
|
+
case "unlink":
|
|
42738
|
+
this.executeCommand("unlink");
|
|
42739
|
+
break;
|
|
42740
|
+
case "undo":
|
|
42741
|
+
this.executeCommand("undo");
|
|
42742
|
+
break;
|
|
42743
|
+
case "redo":
|
|
42744
|
+
this.executeCommand("redo");
|
|
42745
|
+
break;
|
|
42746
|
+
case "clear":
|
|
42747
|
+
this.executeCommand("removeFormat");
|
|
42748
|
+
this.executeCommand("unlink");
|
|
42749
|
+
this.executeCommand("formatBlock", "P");
|
|
42750
|
+
break;
|
|
42751
|
+
default:
|
|
42752
|
+
break;
|
|
42753
|
+
}
|
|
42754
|
+
},
|
|
42755
|
+
executeCommand(command, value = null) {
|
|
42756
|
+
this.focusEditor();
|
|
42757
|
+
this.restoreRange();
|
|
42758
|
+
document.execCommand(command, false, value);
|
|
42759
|
+
this.handleInput();
|
|
42760
|
+
},
|
|
42761
|
+
triggerImagePicker() {
|
|
42762
|
+
const imageInput = this.$refs.imageInputRef;
|
|
42763
|
+
if (!imageInput) {
|
|
42764
|
+
return;
|
|
42765
|
+
}
|
|
42766
|
+
imageInput.value = "";
|
|
42767
|
+
imageInput.click();
|
|
42768
|
+
},
|
|
42769
|
+
handleImageSelected(event) {
|
|
42770
|
+
var _event$target;
|
|
42771
|
+
const file = (_event$target = event.target) === null || _event$target === void 0 || (_event$target = _event$target.files) === null || _event$target === void 0 ? void 0 : _event$target[0];
|
|
42772
|
+
if (!file || !String(file.type).startsWith("image/")) {
|
|
42773
|
+
return;
|
|
42774
|
+
}
|
|
42775
|
+
const fileReader = new FileReader();
|
|
42776
|
+
fileReader.onload = () => {
|
|
42777
|
+
this.insertImage(String(fileReader.result || ""));
|
|
42778
|
+
};
|
|
42779
|
+
fileReader.readAsDataURL(file);
|
|
42780
|
+
},
|
|
42781
|
+
insertImage(rawImageSrc) {
|
|
42782
|
+
const imageSrc = this.normalizeImageSrc(rawImageSrc);
|
|
42783
|
+
if (!this.isSafeImageSrc(imageSrc)) {
|
|
42784
|
+
return;
|
|
42785
|
+
}
|
|
42786
|
+
this.focusEditor();
|
|
42787
|
+
this.restoreRange();
|
|
42788
|
+
const safeSrc = this.escapeHtml(imageSrc);
|
|
42789
|
+
document.execCommand("insertHTML", false, `<img src="${safeSrc}" alt="image">`);
|
|
42790
|
+
this.handleInput();
|
|
42791
|
+
},
|
|
42792
|
+
createLink() {
|
|
42793
|
+
this.restoreRange();
|
|
42794
|
+
const selection = window.getSelection();
|
|
42795
|
+
const selectedText = selection ? selection.toString() : "";
|
|
42796
|
+
const defaultUrl = selectedText && this.isSafeUrl(selectedText) ? selectedText : "https://";
|
|
42797
|
+
const rawUrl = window.prompt("Input URL", defaultUrl);
|
|
42798
|
+
if (!rawUrl) {
|
|
42799
|
+
return;
|
|
42800
|
+
}
|
|
42801
|
+
const normalizedUrl = this.normalizeUrl(rawUrl);
|
|
42802
|
+
if (!this.isSafeUrl(normalizedUrl)) {
|
|
42803
|
+
return;
|
|
42804
|
+
}
|
|
42805
|
+
this.focusEditor();
|
|
42806
|
+
this.restoreRange();
|
|
42807
|
+
const selectedRange = window.getSelection();
|
|
42808
|
+
if (selectedRange && selectedRange.toString()) {
|
|
42809
|
+
document.execCommand("createLink", false, normalizedUrl);
|
|
42810
|
+
} else {
|
|
42811
|
+
const safeUrl = this.escapeHtml(normalizedUrl);
|
|
42812
|
+
document.execCommand("insertHTML", false, `<a href="${safeUrl}" target="_blank" rel="noopener noreferrer">${safeUrl}</a>`);
|
|
42813
|
+
}
|
|
42814
|
+
this.handleInput();
|
|
42815
|
+
},
|
|
42816
|
+
normalizeUrl(rawUrl) {
|
|
42817
|
+
const trimmedUrl = String(rawUrl).trim();
|
|
42818
|
+
if (!trimmedUrl) {
|
|
42819
|
+
return "";
|
|
42820
|
+
}
|
|
42821
|
+
if (SAFE_PROTOCOLS.some(protocol => trimmedUrl.toLowerCase().startsWith(protocol))) {
|
|
42822
|
+
return trimmedUrl;
|
|
42823
|
+
}
|
|
42824
|
+
return `https://${trimmedUrl}`;
|
|
42825
|
+
},
|
|
42826
|
+
isSafeUrl(url) {
|
|
42827
|
+
if (!url) {
|
|
42828
|
+
return false;
|
|
42829
|
+
}
|
|
42830
|
+
return SAFE_PROTOCOLS.some(protocol => url.toLowerCase().startsWith(protocol));
|
|
42831
|
+
},
|
|
42832
|
+
normalizeImageSrc(rawSrc) {
|
|
42833
|
+
const cleanedSrc = String(rawSrc || "").trim();
|
|
42834
|
+
if (!cleanedSrc) {
|
|
42835
|
+
return "";
|
|
42836
|
+
}
|
|
42837
|
+
const normalizedSrc = cleanedSrc.toLowerCase();
|
|
42838
|
+
if (SAFE_IMAGE_PROTOCOLS.some(protocol => normalizedSrc.startsWith(protocol))) {
|
|
42839
|
+
return cleanedSrc;
|
|
42840
|
+
}
|
|
42841
|
+
return `https://${cleanedSrc}`;
|
|
42842
|
+
},
|
|
42843
|
+
isSafeImageSrc(src) {
|
|
42844
|
+
if (!src) {
|
|
42845
|
+
return false;
|
|
42846
|
+
}
|
|
42847
|
+
const normalizedSrc = src.toLowerCase();
|
|
42848
|
+
return SAFE_IMAGE_PROTOCOLS.some(protocol => normalizedSrc.startsWith(protocol));
|
|
42849
|
+
},
|
|
42850
|
+
saveRange() {
|
|
42851
|
+
const selection = window.getSelection();
|
|
42852
|
+
if (selection && selection.rangeCount) {
|
|
42853
|
+
this.savedRange = selection.getRangeAt(0).cloneRange();
|
|
42854
|
+
}
|
|
42855
|
+
},
|
|
42856
|
+
restoreRange() {
|
|
42857
|
+
if (!this.savedRange) {
|
|
42858
|
+
return;
|
|
42859
|
+
}
|
|
42860
|
+
const selection = window.getSelection();
|
|
42861
|
+
selection.removeAllRanges();
|
|
42862
|
+
selection.addRange(this.savedRange);
|
|
42863
|
+
},
|
|
42864
|
+
sanitizeHtml(htmlValue) {
|
|
42865
|
+
const source = document.createElement("div");
|
|
42866
|
+
source.innerHTML = htmlValue || "";
|
|
42867
|
+
const target = document.createElement("div");
|
|
42868
|
+
Array.from(source.childNodes).forEach(node => {
|
|
42869
|
+
const sanitizedNode = this.createSanitizedNode(node, document);
|
|
42870
|
+
if (sanitizedNode) {
|
|
42871
|
+
target.appendChild(sanitizedNode);
|
|
42872
|
+
}
|
|
42873
|
+
});
|
|
42874
|
+
return target.innerHTML;
|
|
42875
|
+
},
|
|
42876
|
+
createSanitizedNode(node, doc) {
|
|
42877
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
42878
|
+
return doc.createTextNode(node.textContent || "");
|
|
42879
|
+
}
|
|
42880
|
+
if (node.nodeType !== Node.ELEMENT_NODE) {
|
|
42881
|
+
return null;
|
|
42882
|
+
}
|
|
42883
|
+
const tagName = node.tagName.toUpperCase();
|
|
42884
|
+
if (!ALLOWED_TAGS.includes(tagName)) {
|
|
42885
|
+
const fragment = doc.createDocumentFragment();
|
|
42886
|
+
Array.from(node.childNodes).forEach(child => {
|
|
42887
|
+
const childNode = this.createSanitizedNode(child, doc);
|
|
42888
|
+
if (childNode) {
|
|
42889
|
+
fragment.appendChild(childNode);
|
|
42890
|
+
}
|
|
42891
|
+
});
|
|
42892
|
+
return fragment;
|
|
42893
|
+
}
|
|
42894
|
+
const element = doc.createElement(tagName.toLowerCase());
|
|
42895
|
+
if (tagName === "A") {
|
|
42896
|
+
const href = this.normalizeUrl(node.getAttribute("href") || "");
|
|
42897
|
+
if (this.isSafeUrl(href)) {
|
|
42898
|
+
element.setAttribute("href", href);
|
|
42899
|
+
element.setAttribute("target", "_blank");
|
|
42900
|
+
element.setAttribute("rel", "noopener noreferrer");
|
|
42901
|
+
}
|
|
42902
|
+
}
|
|
42903
|
+
if (tagName === "IMG") {
|
|
42904
|
+
const imageSrc = this.normalizeImageSrc(node.getAttribute("src") || "");
|
|
42905
|
+
if (!this.isSafeImageSrc(imageSrc)) {
|
|
42906
|
+
return null;
|
|
42907
|
+
}
|
|
42908
|
+
element.setAttribute("src", imageSrc);
|
|
42909
|
+
element.setAttribute("alt", node.getAttribute("alt") || "image");
|
|
42910
|
+
const imageWidth = Number(node.getAttribute("width"));
|
|
42911
|
+
if (Number.isFinite(imageWidth) && imageWidth > 0) {
|
|
42912
|
+
element.setAttribute("width", `${Math.max(IMAGE_MIN_WIDTH, Math.round(imageWidth))}`);
|
|
42913
|
+
}
|
|
42914
|
+
}
|
|
42915
|
+
const textAlign = this.extractAllowedTextAlign(node.getAttribute("style"));
|
|
42916
|
+
if (textAlign && ALIGNABLE_TAGS.includes(tagName)) {
|
|
42917
|
+
element.setAttribute("style", `text-align:${textAlign};`);
|
|
42918
|
+
}
|
|
42919
|
+
Array.from(node.childNodes).forEach(child => {
|
|
42920
|
+
const childNode = this.createSanitizedNode(child, doc);
|
|
42921
|
+
if (childNode) {
|
|
42922
|
+
element.appendChild(childNode);
|
|
42923
|
+
}
|
|
42924
|
+
});
|
|
42925
|
+
return element;
|
|
42926
|
+
},
|
|
42927
|
+
extractAllowedTextAlign(styleValue) {
|
|
42928
|
+
if (!styleValue) {
|
|
42929
|
+
return "";
|
|
42930
|
+
}
|
|
42931
|
+
const rules = styleValue.split(";").map(style => style.trim());
|
|
42932
|
+
const textAlignRule = rules.find(style => style.toLowerCase().startsWith("text-align"));
|
|
42933
|
+
if (!textAlignRule) {
|
|
42934
|
+
return "";
|
|
42935
|
+
}
|
|
42936
|
+
const parsed = textAlignRule.split(":");
|
|
42937
|
+
if (parsed.length < 2) {
|
|
42938
|
+
return "";
|
|
42939
|
+
}
|
|
42940
|
+
const alignValue = parsed[1].trim().toLowerCase();
|
|
42941
|
+
return ["left", "center", "right", "justify"].includes(alignValue) ? alignValue : "";
|
|
42942
|
+
},
|
|
42943
|
+
isActionActive(item) {
|
|
42944
|
+
switch (item.action) {
|
|
42945
|
+
case "paragraph":
|
|
42946
|
+
return this.toolbarState.formatBlock === "P" || this.toolbarState.formatBlock === "DIV";
|
|
42947
|
+
case "heading1":
|
|
42948
|
+
return this.toolbarState.formatBlock === "H1";
|
|
42949
|
+
case "heading2":
|
|
42950
|
+
return this.toolbarState.formatBlock === "H2";
|
|
42951
|
+
case "bold":
|
|
42952
|
+
return this.toolbarState.bold;
|
|
42953
|
+
case "italic":
|
|
42954
|
+
return this.toolbarState.italic;
|
|
42955
|
+
case "underline":
|
|
42956
|
+
return this.toolbarState.underline;
|
|
42957
|
+
case "strikeThrough":
|
|
42958
|
+
return this.toolbarState.strikeThrough;
|
|
42959
|
+
case "unorderedList":
|
|
42960
|
+
return this.toolbarState.unorderedList;
|
|
42961
|
+
case "orderedList":
|
|
42962
|
+
return this.toolbarState.orderedList;
|
|
42963
|
+
case "blockquote":
|
|
42964
|
+
return this.toolbarState.blockquote;
|
|
42965
|
+
case "alignLeft":
|
|
42966
|
+
return this.toolbarState.align === "justifyLeft";
|
|
42967
|
+
case "alignCenter":
|
|
42968
|
+
return this.toolbarState.align === "justifyCenter";
|
|
42969
|
+
case "alignRight":
|
|
42970
|
+
return this.toolbarState.align === "justifyRight";
|
|
42971
|
+
case "alignJustify":
|
|
42972
|
+
return this.toolbarState.align === "justifyFull";
|
|
42973
|
+
default:
|
|
42974
|
+
return false;
|
|
42975
|
+
}
|
|
42976
|
+
},
|
|
42977
|
+
isActionDisabled(item) {
|
|
42978
|
+
return item.action === "divider" || !this.isEditable;
|
|
42979
|
+
},
|
|
42980
|
+
updateEmptyState() {
|
|
42981
|
+
const editor = this.$refs.editorRef;
|
|
42982
|
+
if (!editor) {
|
|
42983
|
+
this.isEmpty = true;
|
|
42984
|
+
return;
|
|
42985
|
+
}
|
|
42986
|
+
this.isEmpty = this.isHtmlEmpty(editor.innerHTML);
|
|
42987
|
+
},
|
|
42988
|
+
isHtmlEmpty(htmlValue) {
|
|
42989
|
+
if (!htmlValue) {
|
|
42990
|
+
return true;
|
|
42991
|
+
}
|
|
42992
|
+
const cleaned = String(htmlValue).replace(/ /gi, "").replace(/<br\s*\/?>/gi, "").replace(/\s+/g, "");
|
|
42993
|
+
if (!cleaned) {
|
|
42994
|
+
return true;
|
|
42995
|
+
}
|
|
42996
|
+
const inspector = document.createElement("div");
|
|
42997
|
+
inspector.innerHTML = htmlValue;
|
|
42998
|
+
const textContent = (inspector.textContent || "").replace(/\u200B/g, "").trim();
|
|
42999
|
+
const hasImage = Boolean(inspector.querySelector("img"));
|
|
43000
|
+
if (hasImage) {
|
|
43001
|
+
return false;
|
|
43002
|
+
}
|
|
43003
|
+
return textContent.length === 0;
|
|
43004
|
+
},
|
|
43005
|
+
getPlainText() {
|
|
43006
|
+
const editor = this.$refs.editorRef;
|
|
43007
|
+
if (!editor) {
|
|
43008
|
+
return "";
|
|
43009
|
+
}
|
|
43010
|
+
return (editor.innerText || "").replace(/\u200B/g, "").trim();
|
|
43011
|
+
},
|
|
43012
|
+
escapeHtml(value) {
|
|
43013
|
+
return String(value || "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
43014
|
+
}
|
|
43015
|
+
}
|
|
43016
|
+
});
|
|
43017
|
+
// CONCATENATED MODULE: ./src/components/Form/FormWysiwyg.vue?vue&type=script&lang=js
|
|
43018
|
+
|
|
43019
|
+
// EXTERNAL MODULE: ./src/components/Form/FormWysiwyg.vue?vue&type=style&index=0&id=52b4ebd4&lang=scss
|
|
43020
|
+
var FormWysiwygvue_type_style_index_0_id_52b4ebd4_lang_scss = __webpack_require__("d831");
|
|
43021
|
+
|
|
43022
|
+
// CONCATENATED MODULE: ./src/components/Form/FormWysiwyg.vue
|
|
43023
|
+
|
|
43024
|
+
|
|
43025
|
+
|
|
43026
|
+
|
|
43027
|
+
|
|
43028
|
+
|
|
43029
|
+
|
|
43030
|
+
const FormWysiwyg_exports_ = /*#__PURE__*/exportHelper_default()(FormWysiwygvue_type_script_lang_js, [['render',FormWysiwygvue_type_template_id_52b4ebd4_render]])
|
|
43031
|
+
|
|
43032
|
+
/* harmony default export */ var FormWysiwyg = (FormWysiwyg_exports_);
|
|
42075
43033
|
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader-v16/dist??ref--1-1!./src/components/ExpansionPanel/index.vue?vue&type=template&id=01544323
|
|
42076
43034
|
|
|
42077
43035
|
const ExpansionPanelvue_type_template_id_01544323_hoisted_1 = {
|
|
@@ -42281,6 +43239,7 @@ const AnimatedIconLogo_exports_ = AnimatedIconLogovue_type_script_setup_true_lan
|
|
|
42281
43239
|
|
|
42282
43240
|
|
|
42283
43241
|
|
|
43242
|
+
|
|
42284
43243
|
|
|
42285
43244
|
|
|
42286
43245
|
// CONCATENATED MODULE: ./src/install.js
|