striven-editor

Maintained and contributed to an open source WYSIWYG editor as an internship project that made it to production and was adopted by the company I was working at.
git clone https://unitehenry.com/git/striven-editor.git
Log | Files | Refs | README | LICENSE

commit ed00f11cafde8386df04ab8c298b1f2dd6bad474
parent e4149de024f8eb4afc9bb41cb30c67ce49a93add
Author: unitehenry <unitehenry@gmail.com>
Date:   Tue, 22 Oct 2019 09:16:28 -0400

2.0.0

Diffstat:
MCHANGELOG.md | 10++++++++++
MREADME.md | 58+++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Mdemo/src/App.vue | 202++++++++++++-------------------------------------------------------------------
Mdist/index.js | 2169++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Mdist/ko-striveneditor.js | 10++++++++--
Mdist/ko-striveneditor.js.LICENSE | 10+++++-----
Mdist/striveneditor.js | 10++++++++--
Mdist/striveneditor.js.LICENSE | 10+++++-----
Mdist/vue-striveneditor.js | 10++++++++--
Mdist/vue-striveneditor.js.LICENSE | 10+++++-----
Mpackage-lock.json | 313++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Mpackage.json | 7+++++--
Msrc/index.js | 13++++---------
Asrc/ko-striveneditor.js | 15+++++++++++++++
Asrc/striveneditor.css | 221+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/striveneditor.js | 337++++++++++++++++++++++++++++++++++++-------------------------------------------
Asrc/vue-striveneditor.vue | 37+++++++++++++++++++++++++++++++++++++
Mwebpack.config.js | 24++++++++++++++++++++++--
18 files changed, 3058 insertions(+), 408 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md @@ -11,6 +11,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Submit on enter - Clear files +- Submit to enter option +- Supports Firefox, Chrome, Safari, Edge +- Added Close button to close image and link popup +- Image and link popup can be closed using Esc key + +### Changed +- Extracted styles to css +- Toolbar slide animation timeout is reduced +- Fixed vertical spacing on the toolbar icons +- Toolbar does not auto hide when any popups are open inside ## [Unreleased] diff --git a/README.md b/README.md @@ -11,6 +11,12 @@ <img src="https://img.shields.io/github/size/striven-erp/striven-editor/dist/striveneditor.js" alt="GitHub file size in bytes"> </p> +<p align="center"> + <strong>Supports Firefox, Edge, Safari, and Chrome</strong> + <br /> + ✌ <a href="#vue-component">Vue</a> | 🥋 <a href="#knockout-binding">Knockout</a> +</p> + ## Getting Started ### Install Package @@ -35,6 +41,56 @@ import StrivenEditor from 'striven-editor'; const editor = new StrivenEditor(editorEl, { toolbarHide: true, toolbarBottom: true }); ``` +## Vue Component + +```js +<template> + <striven-editor ref="editor" :minimal="true" /> +</template> + +<script> +import { VueStrivenEditor as StrivenEditor } from '@striven-erp/striven-editor'; + +export default { + components: { StrivenEditor } +} +</script> +``` + +### Using Vue Component Methods + +```js +<template> + <striven-editor ref="editor" :minimal="true" /> +</template> + +<script> +import { VueStrivenEditor as StrivenEditor } from '@striven-erp/striven-editor'; + +export default { + components: { StrivenEditor }, + mounted () { + const editor = this.$refs.editor.editor; + + console.log(editor.getContent()); + } +} +</script> +``` + +## Knockout Binding + +```js +import ko from 'knockout'; +import { KoStrivenEditor } from '@striven-erp/striven-editor'; + +new KoStrivenEditor(ko); +``` + +```html +<div data-bind="striveneditor: editorConfig" /> +``` + ## Fetching Meta Data on Link Insertions To fetch meta data from links that are pasted or inserted into the editor, you must set up a back end utility to fetch the data and send it back to your client. For a node server, we recommend using [metascraper](https://metascraper.js.org/#/) on your server. See the example below for setting this up with express. @@ -207,7 +263,7 @@ Then take the SVG element's ```viewBox``` attribute data and the path element's |imageUrl|```String```|```null```|An endpoint to make a ```POST``` request for writing encoded images to the server. <br /> See [Referencing Encoded Images](#writing-encoded-images-to-a-server)| |customToolbarButton|```Object```|```null```|Configuration properties for adding a custom toolbar button. <br /> See [Custom Toolbar Button Properties](#custom-toolbar-button-properties)| |activeOptionColor|```String```|```#ddd```|Fill color for the toolbar action to change to when active.| -|submitOnEnter|```Function```|```null```|Handler function that clears the editor on enter and returns the contents submitted. <br /> *Shift + Enter still inserts a break* <br /> ```submitOnEnter({ content, files })``` <br /> **Nothing will return if the editor is empty or no files are attached**| +|submitOnEnter|```Function```|```null```|Handler function that clears the editor on enter and returns the contents submitted. <br /> *Shift + Enter still inserts a break* <br /> ```submitOnEnter({ content, files })``` <br /> **Nothing will return if the editor is empty and no files are attached**| ## Editor Methods diff --git a/demo/src/App.vue b/demo/src/App.vue @@ -3,209 +3,67 @@ id="app" style="font-family: Segoe UI; color: #2c3e50; margin-top: 20vh; display: flex; justify-content: center; align-items: center; flex-direction: column; padding: 0 1rem;" > - <!-- <h1>Striven Editor</h1> --> <div style="display: flex; padding: 1rem; width: 100%; justify-content: center;"> <div ref="editor" class="editor" - style="margin-top: 20px; background-color: #fff; height: 300px; width: 600px;" + style="margin-top: 20px; background-color: #fff; min-height: 300px; width: 600px;" ></div> - <button - ref="sendButton" - style=" - color: #fff; - border: none; - cursor: pointer; - align-self: flex-end; - height: 3rem; - width: 4rem; - border-radius: 4%; - background-color: #5cb85c; - margin: 0 5px; - outline: none;" - > - <!-- <i style="color: #fff; font-size: 25px;" class="fas fa-paper-plane" /> --> - </button> </div> - <!-- <div id="footer"> --> - <!-- <a style="color: inherit; text-decoration: none;" href="https://github.com/business-by-miles/striven-editor">Find this on GitHub</a> --> - <!-- </div> --> </div> </template> <script> /* eslint-disable */ -// import Tribute from 'tributejs'; -// import { faPaperPlane } from "@fortawesome/free-solid-svg-icons/faPaperPlane"; -// import { dom } from '@fortawesome/fontawesome-svg-core'; -// import { library as faLib } from "@fortawesome/fontawesome-svg-core"; -// import USERS from './users'; - -// faLib.add(faPaperPlane); -// dom.watch(); - import { StrivenEditor } from "@striven-erp/striven-editor"; export default { name: "app", mounted() { - // const that = this; const editorOptions = { - // metaUrl: "http://localhost:4200/meta", - // imageUrl: "http://localhost:4200/image", - minimal: false, + // metaUrl: "http://localhost:4200/meta", // metaserver.js + // imageUrl: "http://localhost:4200/image", // imageserver.js + minimal: true, uploadOnPaste: false, toolbarBottom: true, toolbarHide: true, sanitizePaste: true, placeholder: "Begin typing in this editor...", submitOnEnter: ({ content, files }) => { - if(content || files) { + if (content || files.length ) { console.log({ content, files }); } this.editor.body.blur(); + }, + customToolbarButton: { + svgData: { + viewBox: "0 0 1792 1792", + d: + "M1764 11q33 24 27 64l-256 1536q-5 29-32 45-14 8-31 8-11 0-24-5l-453-185-242 295q-18 23-49 23-13 0-22-4-19-7-30.5-23.5t-11.5-36.5v-349l864-1059-1069 925-395-162q-37-14-40-55-2-40 32-59l1664-960q15-9 32-9 20 0 36 11z" + }, + borderColor: "rgb(76, 174, 76)", + hoverBorderColor: "rgb(76, 174, 76)", + backgroundColor: "rgb(92, 184, 92)", + hoverBackgroundColor: "rgb(76, 174, 76)", + color: "#fff", + hoverColor: "#fff", + handler: () => { + const content = this.editor.getContent(); + const files = this.editor.getFiles(); + + if (content || files.length) { + console.log({ content, files }); + } + + this.editor.clearContent(); + this.editor.body.blur(); + } } - // customToolbarButton: { - // svgData: { - // viewBox: "0 0 1792 1792", - // d: "M1764 11q33 24 27 64l-256 1536q-5 29-32 45-14 8-31 8-11 0-24-5l-453-185-242 295q-18 23-49 23-13 0-22-4-19-7-30.5-23.5t-11.5-36.5v-349l864-1059-1069 925-395-162q-37-14-40-55-2-40 32-59l1664-960q15-9 32-9 20 0 36 11z" - // }, - // borderColor: "rgb(76, 174, 76)", - // hoverBorderColor: "rgb(76, 174, 76)", - // backgroundColor: "rgb(92, 184, 92)", - // hoverBackgroundColor: "rgb(76, 174, 76)", - // color: "#fff", - // hoverColor: "#fff", - // handler: () => console.log(this.editor.getContent()) - // } }; this.editor = new StrivenEditor(this.$refs.editor, editorOptions); - - // eslint-disable-next-line - this.$refs.sendButton.onclick = () => console.log(this.editor.getContent()); - - // paperPlane.innerHTML = "<svg width=\"25\" height=\"25\" viewBox=\"0 0 1792 1792\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"#fff\" d=\"M1764 11q33 24 27 64l-256 1536q-5 29-32 45-14 8-31 8-11 0-24-5l-453-185-242 295q-18 23-49 23-13 0-22-4-19-7-30.5-23.5t-11.5-36.5v-349l864-1059-1069 925-395-162q-37-14-40-55-2-40 32-59l1664-960q15-9 32-9 20 0 36 11z\"/></svg>"; - - const paperPlane = document.createElement("span"); - const svg = - '<svg width="50%" height="50%" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg">'; - const path = - '<path fill="#fff" d="M1764 11q33 24 27 64l-256 1536q-5 29-32 45-14 8-31 8-11 0-24-5l-453-185-242 295q-18 23-49 23-13 0-22-4-19-7-30.5-23.5t-11.5-36.5v-349l864-1059-1069 925-395-162q-37-14-40-55-2-40 32-59l1664-960q15-9 32-9 20 0 36 11z"/>'; - paperPlane.innerHTML = `${svg}${path}</svg>`; - - this.$refs.sendButton.append(paperPlane); - this.$refs.sendButton.onmouseenter = () => - (this.$refs.sendButton.style.backgroundColor = "#4cae4c"); - this.$refs.sendButton.onmouseleave = () => - (this.$refs.sendButton.style.backgroundColor = "#5cb85c"); - - // const tributeOptions = { - // trigger: "@", - // values: (text, cb) => cb(USERS), - // selectTemplate: function(item) { - // const { value } = item.original; - // return `@${value.replace(" ", "").toLowerCase()}`; - // }, - // menuItemTemplate: function(item) { - // const { avatar, value } = item.original; - // return `<span class="menu-item">${ - // avatar ? `<img src="${avatar}" />` : "" - // }<p>${value}</p></span>`; - // }, - // lookup: "value", - // fillAttr: "value", - // allowSpaces: true - // }; - // const tribute = new Tribute(tributeOptions); - // tribute.attach(this.editor.body); - - // this.editor.body.addEventListener("tribute-replaced", function(e) { - // const { value } = e.detail.item.original; - // let content = that.editor.getContent(); - // const mention = `<span class="striven-mention new-mention" contenteditable="false" data-mention="${value}">${value}</span>`; - // content = content.replace( - // "@" + value.replace(" ", "").toLowerCase(), - // mention - // ); - // that.editor.body.innerHTML = content; - // const newMention = that.editor.body.querySelector(".new-mention"); - // const range = that.editor.getRange(); - // range.selectNode(newMention); - // range.collapse(); - // newMention.classList.remove("new-mention"); - // }); } }; </script> -<style> -* { - margin: 0; - padding: 0; - box-align: border-box; -} - -#app { - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - color: #2c3e50; - margin-top: 20vh; - display: flex; - justify-content: center; - align-items: center; - flex-direction: column; - padding: 0 1rem; -} - -#footer { - margin: 25px 0; -} - -#footer a { - color: inherit; - text-decoration: none; -} - -.tribute-container ul { - list-style: none; -} - -.highlight > .menu-item { - display: flex; - justify-content: space-between; - font-family: "Montserrat", sans-serif; - border: 1px solid grey; - padding: 5px; - background-color: #f6f6f6; - width: 15rem; -} - -.menu-item { - display: flex; - justify-content: space-between; - font-family: "Montserrat", sans-serif; - border: 1px solid grey; - padding: 5px; - background-color: #fff; - width: 15rem; -} - -.menu-item img { - border-radius: 1rem; - height: 2rem; - width: 2rem; -} - -.menu-item p { - margin: 0 1rem; - text-align: center; -} - -.striven-mention { - background-color: lightblue; - color: blue; - padding: 1px 5px; - border-radius: 5%; -} -</style> +<style></style> diff --git a/dist/index.js b/dist/index.js @@ -91,32 +91,2169 @@ return /******/ (function(modules) { // webpackBootstrap /******/ /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = "./src/index.js"); +/******/ return __webpack_require__(__webpack_require__.s = 7); /******/ }) /************************************************************************/ -/******/ ({ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + +var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { + if (true) { + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), + __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? + (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else { var mod; } +})(this, function (_exports) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports["default"] = void 0; + + function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + + function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } + + function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } + + function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } + + function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + + function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + + /* + @license/i + * Font Awesome Free 5.11.2 by @fontawesome - https://fontawesome.com + * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) + */ + var EXTENSIONS = [".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".tif", ".jpeg", ".jpg", ".gif", ".bmp", ".txt", ".csv", ".png", ".msg", ".wav", ".mp3", ".mp4", ".zip", ".rtf", ".eps", ".ai", ".psd", ".avi", ".mov", ".wmv", ".cfg", ".wss", ".vsd", ".vsdx", ".tsd", ".lic"]; + var FONTPACK = "fas"; + var OPTIONGROUPS = { + textDecoration: { + menu: { + viewBox: "0 0 1792 1792", + d: "M789 559l-170 450q33 0 136.5 2t160.5 2q19 0 57-2-87-253-184-452zm-725 1105l2-79q23-7 56-12.5t57-10.5 49.5-14.5 44.5-29 31-50.5l237-616 280-724h128q8 14 11 21l205 480q33 78 106 257.5t114 274.5q15 34 58 144.5t72 168.5q20 45 35 57 19 15 88 29.5t84 20.5q6 38 6 57 0 5-.5 13.5t-.5 12.5q-63 0-190-8t-191-8q-76 0-215 7t-178 8q0-43 4-78l131-28q1 0 12.5-2.5t15.5-3.5 14.5-4.5 15-6.5 11-8 9-11 2.5-14q0-16-31-96.5t-72-177.5-42-100l-450-2q-26 58-76.5 195.5t-50.5 162.5q0 22 14 37.5t43.5 24.5 48.5 13.5 57 8.5 41 4q1 19 1 58 0 9-2 27-58 0-174.5-10t-174.5-10q-8 0-26.5 4t-21.5 4q-80 14-188 14z" + }, + group: [{ + bold: { + viewBox: "0 0 1792 1792", + d: "M747 1521q74 32 140 32 376 0 376-335 0-114-41-180-27-44-61.5-74t-67.5-46.5-80.5-25-84-10.5-94.5-2q-73 0-101 10 0 53-.5 159t-.5 158q0 8-1 67.5t-.5 96.5 4.5 83.5 12 66.5zm-14-746q42 7 109 7 82 0 143-13t110-44.5 74.5-89.5 25.5-142q0-70-29-122.5t-79-82-108-43.5-124-14q-50 0-130 13 0 50 4 151t4 152q0 27-.5 80t-.5 79q0 46 1 69zm-541 889l2-94q15-4 85-16t106-27q7-12 12.5-27t8.5-33.5 5.5-32.5 3-37.5.5-34v-65.5q0-982-22-1025-4-8-22-14.5t-44.5-11-49.5-7-48.5-4.5-30.5-3l-4-83q98-2 340-11.5t373-9.5q23 0 68 .5t68 .5q70 0 136.5 13t128.5 42 108 71 74 104.5 28 137.5q0 52-16.5 95.5t-39 72-64.5 57.5-73 45-84 40q154 35 256.5 134t102.5 248q0 100-35 179.5t-93.5 130.5-138 85.5-163.5 48.5-176 14q-44 0-132-3t-132-3q-106 0-307 11t-231 12z" + } + }, { + italic: { + viewBox: "0 0 1792 1792", + d: "M384 1662l17-85q22-7 61.5-16.5t72-19 59.5-23.5q28-35 41-101 1-7 62-289t114-543.5 52-296.5v-25q-24-13-54.5-18.5t-69.5-8-58-5.5l19-103q33 2 120 6.5t149.5 7 120.5 2.5q48 0 98.5-2.5t121-7 98.5-6.5q-5 39-19 89-30 10-101.5 28.5t-108.5 33.5q-8 19-14 42.5t-9 40-7.5 45.5-6.5 42q-27 148-87.5 419.5t-77.5 355.5q-2 9-13 58t-20 90-16 83.5-6 57.5l1 18q17 4 185 31-3 44-16 99-11 0-32.5 1.5t-32.5 1.5q-29 0-87-10t-86-10q-138-2-206-2-51 0-143 9t-121 11z" + } + }, { + underline: { + viewBox: "0 0 1792 1792", + d: "M176 223q-37-2-45-4l-3-88q13-1 40-1 60 0 112 4 132 7 166 7 86 0 168-3 116-4 146-5 56 0 86-2l-1 14 2 64v9q-60 9-124 9-60 0-79 25-13 14-13 132 0 13 .5 32.5t.5 25.5l1 229 14 280q6 124 51 202 35 59 96 92 88 47 177 47 104 0 191-28 56-18 99-51 48-36 65-64 36-56 53-114 21-73 21-229 0-79-3.5-128t-11-122.5-13.5-159.5l-4-59q-5-67-24-88-34-35-77-34l-100 2-14-3 2-86h84l205 10q76 3 196-10l18 2q6 38 6 51 0 7-4 31-45 12-84 13-73 11-79 17-15 15-15 41 0 7 1.5 27t1.5 31q8 19 22 396 6 195-15 304-15 76-41 122-38 65-112 123-75 57-182 89-109 33-255 33-167 0-284-46-119-47-179-122-61-76-83-195-16-80-16-237v-333q0-188-17-213-25-36-147-39zm1488 1409v-64q0-14-9-23t-23-9h-1472q-14 0-23 9t-9 23v64q0 14 9 23t23 9h1472q14 0 23-9t9-23z" + } + }, { + strikethrough: { + viewBox: "0 0 1792 1792", + d: "M1760 896q14 0 23 9t9 23v64q0 14-9 23t-23 9h-1728q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h1728zm-1277-64q-28-35-51-80-48-98-48-188 0-181 134-309 133-127 393-127 50 0 167 19 66 12 177 48 10 38 21 118 14 123 14 183 0 18-5 45l-12 3-84-6-14-2q-50-149-103-205-88-91-210-91-114 0-182 59-67 58-67 146 0 73 66 140t279 129q69 20 173 66 58 28 95 52h-743zm507 256h411q7 39 7 92 0 111-41 212-23 56-71 104-37 35-109 81-80 48-153 66-80 21-203 21-114 0-195-23l-140-40q-57-16-72-28-8-8-8-22v-13q0-108-2-156-1-30 0-68l2-37v-44l102-2q15 34 30 71t22.5 56 12.5 27q35 57 80 94 43 36 105 57 59 22 132 22 64 0 139-27 77-26 122-86 47-61 47-129 0-84-81-157-34-29-137-71z" + } + }, { + removeFormat: { + viewBox: "0 0 640 512", + d: "M336 416h-11.17l9.26-27.77L267 336.4 240.49 416H208a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h128a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm297.82 42.1L377 259.59 426.17 112H544v32a16 16 0 0 0 16 16h32a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16H176a16 16 0 0 0-16 16v43.9L45.46 3.38A16 16 0 0 0 23 6.19L3.37 31.46a16 16 0 0 0 2.81 22.45l588.36 454.72a16 16 0 0 0 22.46-2.81l19.64-25.27a16 16 0 0 0-2.82-22.45zM309.91 207.76L224 141.36V112h117.83z" + } + }] + }, + listOptions: { + menu: { + viewBox: "0 0 1792 1792", + d: "M256 1312v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm1536 768v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5zm-1536-1152v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm1536 768v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5z" + }, + group: [{ + insertOrderedList: { + viewBox: "0 0 1792 1792", + d: "M381 1620q0 80-54.5 126t-135.5 46q-106 0-172-66l57-88q49 45 106 45 29 0 50.5-14.5t21.5-42.5q0-64-105-56l-26-56q8-10 32.5-43.5t42.5-54 37-38.5v-1q-16 0-48.5 1t-48.5 1v53h-106v-152h333v88l-95 115q51 12 81 49t30 88zm2-627v159h-362q-6-36-6-54 0-51 23.5-93t56.5-68 66-47.5 56.5-43.5 23.5-45q0-25-14.5-38.5t-39.5-13.5q-46 0-81 58l-85-59q24-51 71.5-79.5t105.5-28.5q73 0 123 41.5t50 112.5q0 50-34 91.5t-75 64.5-75.5 50.5-35.5 52.5h127v-60h105zm1409 319v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-14 9-23t23-9h1216q13 0 22.5 9.5t9.5 22.5zm-1408-899v99h-335v-99h107q0-41 .5-121.5t.5-121.5v-12h-2q-8 17-50 54l-71-76 136-127h106v404h108zm1408 387v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-14 9-23t23-9h1216q13 0 22.5 9.5t9.5 22.5zm0-512v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5z" + } + }, { + insertUnorderedList: { + viewBox: "0 0 1792 1792", + d: "M384 1408q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm0-512q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm1408 416v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5zm-1408-928q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm1408 416v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5zm0-512v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5" + } + }] + }, + textAlign: { + menu: { + viewBox: "0 0 1792 1792", + d: "M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45z" + }, + group: [{ + indent: { + viewBox: "0 0 1792 1792", + d: "M352 832q0 14-9 23l-288 288q-9 9-23 9-13 0-22.5-9.5t-9.5-22.5v-576q0-13 9.5-22.5t22.5-9.5q14 0 23 9l288 288q9 9 9 23zm1440 480v192q0 13-9.5 22.5t-22.5 9.5h-1728q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1728q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1088q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1088q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1088q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1088q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1728q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1728q13 0 22.5 9.5t9.5 22.5z" + } + }, { + justifyLeft: { + viewBox: "0 0 1792 1792", + d: "M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-1280q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1280q26 0 45 19t19 45zm256-384v128q0 26-19 45t-45 19h-1536q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1536q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-1152q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1152q26 0 45 19t19 45z" + } + }, { + justifyCenter: { + viewBox: "0 0 1792 1792", + d: "M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-896q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h896q26 0 45 19t19 45zm256-384v128q0 26-19 45t-45 19h-1408q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1408q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-640q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h640q26 0 45 19t19 45z" + } + }, { + justifyRight: { + viewBox: "0 0 1792 1792", + d: "M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1280q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1280q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1536q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1536q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1152q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1152q26 0 45 19t19 45z" + } + }] + }, + attachments: { + menu: { + viewBox: "0 0 1792 1792", + d: "M1596 1385q0 117-79 196t-196 79q-135 0-235-100l-777-776q-113-115-113-271 0-159 110-270t269-111q158 0 273 113l605 606q10 10 10 22 0 16-30.5 46.5t-46.5 30.5q-13 0-23-10l-606-607q-79-77-181-77-106 0-179 75t-73 181q0 105 76 181l776 777q63 63 145 63 64 0 106-42t42-106q0-82-63-145l-581-581q-26-24-60-24-29 0-48 19t-19 48q0 32 25 59l410 410q10 10 10 22 0 16-31 47t-47 31q-12 0-22-10l-410-410q-63-61-63-149 0-82 57-139t139-57q88 0 149 63l581 581q100 98 100 235z" + }, + group: [{ + attachment: { + viewBox: "0 0 1792 1792", + d: "M1596 1385q0 117-79 196t-196 79q-135 0-235-100l-777-776q-113-115-113-271 0-159 110-270t269-111q158 0 273 113l605 606q10 10 10 22 0 16-30.5 46.5t-46.5 30.5q-13 0-23-10l-606-607q-79-77-181-77-106 0-179 75t-73 181q0 105 76 181l776 777q63 63 145 63 64 0 106-42t42-106q0-82-63-145l-581-581q-26-24-60-24-29 0-48 19t-19 48q0 32 25 59l410 410q10 10 10 22 0 16-31 47t-47 31q-12 0-22-10l-410-410q-63-61-63-149 0-82 57-139t139-57q88 0 149 63l581 581q100 98 100 235z" + } + }, { + link: { + viewBox: "0 0 1792 1792", + d: "M1520 1216q0-40-28-68l-208-208q-28-28-68-28-42 0-72 32 3 3 19 18.5t21.5 21.5 15 19 13 25.5 3.5 27.5q0 40-28 68t-68 28q-15 0-27.5-3.5t-25.5-13-19-15-21.5-21.5-18.5-19q-33 31-33 73 0 40 28 68l206 207q27 27 68 27 40 0 68-26l147-146q28-28 28-67zm-703-705q0-40-28-68l-206-207q-28-28-68-28-39 0-68 27l-147 146q-28 28-28 67 0 40 28 68l208 208q27 27 68 27 42 0 72-31-3-3-19-18.5t-21.5-21.5-15-19-13-25.5-3.5-27.5q0-40 28-68t68-28q15 0 27.5 3.5t25.5 13 19 15 21.5 21.5 18.5 19q33-31 33-73zm895 705q0 120-85 203l-147 146q-83 83-203 83-121 0-204-85l-206-207q-83-83-83-203 0-123 88-209l-88-88q-86 88-208 88-120 0-204-84l-208-208q-84-84-84-204t85-203l147-146q83-83 203-83 121 0 204 85l206 207q83 83 83 203 0 123-88 209l88 88q86-88 208-88 120 0 204 84l208 208q84 84 84 204z" + } + }, { + image: { + viewBox: "0 0 2048 1792", + d: "M704 576q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm1024 384v448h-1408v-192l320-320 160 160 512-512zm96-704h-1600q-13 0-22.5 9.5t-9.5 22.5v1216q0 13 9.5 22.5t22.5 9.5h1600q13 0 22.5-9.5t9.5-22.5v-1216q0-13-9.5-22.5t-22.5-9.5zm160 32v1216q0 66-47 113t-113 47h-1600q-66 0-113-47t-47-113v-1216q0-66 47-113t113-47h1600q66 0 113 47t47 113z" + } + }] + } + }; + var DEFAULTOPTIONS = ["bold", "italic", "underline", "strikethrough", "removeFormat", "insertOrderedList", "insertUnorderedList", "indent", "justifyLeft", "justifyCenter", "justifyRight", "attachment", "link", "image"]; + var ACTIVEOPTIONCOLOR = "#777777"; + + var StrivenEditor = + /*#__PURE__*/ + function () { + function StrivenEditor(el, options) { + var _this = this; + + _classCallCheck(this, StrivenEditor); + + this.establishBrowser(); + this.range = new Range(); + this.files = []; + this.optionGroups = OPTIONGROUPS; + + if (options) { + this.options = options; + options.fontPack || (this.options.fontPack = FONTPACK); + options.extensions || (this.options.extensions = EXTENSIONS); + options.toolbarOptions || (this.options.toolbarOptions = DEFAULTOPTIONS); + options.activeOptionColor || (this.options.activeOptionColor = ACTIVEOPTIONCOLOR); + } else { + this.options = { + fontPack: FONTPACK, + extensions: EXTENSIONS, + toolbarOptions: DEFAULTOPTIONS, + activeOptionColor: ACTIVEOPTIONCOLOR + }; + } + + this.initEditor(el); + this.initResponsive(); + this.initOverflow(); + + el.StrivenEditor = function () { + return _this; + }; //bind handler functions to scope + + + this.bound_popupEscapeHandler = this.popupEscapeHandler.bind(this); + } + + _createClass(StrivenEditor, [{ + key: "initEditor", + value: function initEditor(el) { + var _this2 = this; + + this.editor = el; + this.toolbar = this.initToolbar(); + this.body = this.initBody(); + this.linkMenu = this.initLinkMenu(); + this.imageMenu = this.initImageMenu(); + this.metaDataSection = this.initMetaDataSection(); + this.filesSection = this.initFilesSection(); + this.editor.classList.add("editor", "Striven-Editor"); // Toolbar Hide + + if (this.options.toolbarHide) { + this.customToolbarButton && (this.customToolbarButton.style.display = "none"); + this.toolbarOptionsGroup.style.display = "none"; + var bodyFocus = this.body.onfocus; + + this.body.onfocus = function () { + bodyFocus && bodyFocus(); + + _this2.overflow(); + + _this2.toolbarSlideUp(); + }; + + var bodyBlur = this.body.onblur; + + this.body.onblur = function () { + bodyBlur && bodyBlur(); + + _this2.overflow(); + + setTimeout(function () { + if (_this2.linkMenu.dataset.active !== "true" && _this2.imageMenu.dataset.active !== "true" && !_this2.isEditorInFocus()) { + _this2.toolbarSlideDown(); + } + }, 500); + }; + } // Toolbar Options + + + this.toolbarOptions.forEach(function (optionEl) { + // Assign Styles + // optionEl.style.padding = "0 10px"; + optionEl.style.cursor = "pointer"; + optionEl.style.userSelect = "none"; // Execute Toolbar Commands + + var optionElClick = optionEl.onclick; + + optionEl.onclick = function (e) { + var indents = function indents() { + var indents = _this2.body.querySelectorAll('blockquote'); + + _toConsumableArray(indents).forEach(function (indent) { + return indent.style.margin = "0 0 0 40px"; + }); // make the margin an option + + }; + + _this2.body.focus(); + + window.getSelection().removeAllRanges(); + window.getSelection().addRange(_this2.range); + var command = optionEl.id.split("-")[1]; + + switch (command) { + case "insertOrderedList": + if (_this2.isFirefox) { + document.execCommand("indent"); + document.execCommand(command); + indents(); + } else if (_this2.isEdge) { + document.execCommand(command); + + _toConsumableArray(document.querySelectorAll('ol')).forEach(function (ol) { + return ol.style.marginLeft = "40px"; + }); + } else { + document.execCommand("indent", true); + document.execCommand(command, true); + } + + break; + + case "insertUnorderedList": + if (_this2.isFirefox) { + document.execCommand("indent"); + document.execCommand(command); + indents(); + } else if (_this2.isEdge) { + document.execCommand(command); + + _toConsumableArray(document.querySelectorAll('ul')).forEach(function (ul) { + return ul.style.marginLeft = "40px"; + }); + } else { + document.execCommand("indent", true); + document.execCommand(command, true); + } + + break; + + case "attachment": + var attachmentInput = document.createElement("input"); + attachmentInput.style.display = "none"; + attachmentInput.type = "file"; + + attachmentInput.onchange = function (e) { + return _this2.attachFile(attachmentInput.files[0]); + }; + + attachmentInput.click(); + break; + + case "link": + if (_this2.linkMenu.dataset.active === "true") { + _this2.closeLinkMenu(); + } else { + _this2.linkMenuSlideIn(); + + _this2.linkMenu.querySelector('input').focus(); + } + + break; + + case "image": + if (_this2.imageMenu.dataset.active === "true") { + _this2.closeImageMenu(); + } else { + _this2.imageMenuSlideIn(); + + _this2.range = _this2.getRange(); + + _this2.imageMenu.querySelector('input').focus(); + } + + break; + + default: + if (_this2.isFirefox || _this2.isEdge) { + document.execCommand(command); + command === 'indent' && indents(); + } else { + document.execCommand(command, true); + } + + _this2.toolbarState(); + + break; + } + + optionElClick && optionElClick(); + }; + }); + this.editor.appendChild(this.toolbar); + this.editor.appendChild(this.body); + this.editor.appendChild(this.linkMenu); + this.editor.appendChild(this.imageMenu); + this.editor.appendChild(this.metaDataSection); + this.editor.appendChild(this.filesSection); // Reposition Toolbar + + if (this.options.toolbarBottom) { + this.editor.removeChild(this.toolbar); + this.editor.append(this.toolbar); + } + } + }, { + key: "imageMenuSlideIn", + value: function imageMenuSlideIn() { + var that = this; + this.openImageMenu(); + var opacity = 0; + var right = this.editor.offsetWidth / 4; + var id = setInterval(frame, 5); + this.imageMenu.style.opacity = opacity; + + function frame() { + if (right <= 10) { + clearInterval(id); + that.imageMenu.style.opacity = 1; + } else { + right -= 2.5; + opacity += .01; + that.imageMenu.style.opacity = "".concat(opacity); + that.imageMenu.style.right = "".concat(right, "px"); + } + } + } + }, { + key: "linkMenuSlideIn", + value: function linkMenuSlideIn() { + var that = this; + this.openLinkMenu(); + var opacity = 0; + var right = this.editor.offsetWidth / 4; + var id = setInterval(frame, 5); + this.linkMenu.style.opacity = opacity; + + function frame() { + if (right <= 10) { + clearInterval(id); + that.linkMenu.style.opacity = 1; + } else { + right -= 2.5; + opacity += .01; + that.linkMenu.style.opacity = "".concat(opacity); + that.linkMenu.style.right = "".concat(right, "px"); + } + } + } + }, { + key: "toolbarSlideUp", + value: function toolbarSlideUp() { + var that = this; + var height = this.toolbar.offsetHeight; + var id = setInterval(frame, 5); + + function frame() { + if (height >= 40) { + that.customToolbarButton && (that.customToolbarButton.style.display = "flex"); + that.toolbarOptionsGroup.style.display = "flex"; + clearInterval(id); + } else { + height++; + that.toolbar.style.minHeight = "".concat(height, "px"); + } + } + } + }, { + key: "toolbarSlideDown", + value: function toolbarSlideDown() { + var that = this; + this.customToolbarButton && (this.customToolbarButton.style.display = "none"); + this.toolbarOptionsGroup.style.display = "none"; + var height = 40; + var id = setInterval(frame, 5); + + function frame() { + if (height === 0) { + clearInterval(id); + } else { + height--; + that.toolbar.style.minHeight = "".concat(height, "px"); + } + } + } + }, { + key: "initToolbar", + value: function initToolbar() { + var _this3 = this; + + var toolbar = document.createElement("div"); + this.toolbarOptionsGroup = document.createElement("div"); + var groups = Object.keys(this.optionGroups); + toolbar.classList.add("toolbar"); + toolbar.style.minHeight = this.options.toolbarHide ? "0" : "40px"; + this.toolbarOptionsGroup.classList.add("toolbar-options"); + this.toolbarOptionsGroup.style.display = this.options.toolbarHide ? "none" : "flex"; + + toolbar.onclick = function () { + return _this3.body.focus(); + }; //iterate groups + + + groups.forEach(function (group) { + // add menu to toolbarOptions + var toolbarMenu = document.createElement("div"); // const toolbarMenuIcon = document.createElement("i"); + + toolbarMenu.classList.add("toolbar-menu"); + toolbarMenu.id = "menu-".concat(group); // toolbarMenuIcon.classList.add(this.options.fontPack); + // toolbarMenuIcon.classList.add(this.optionGroups[group].menu); + + toolbarMenu.appendChild(_this3.constructSVG(_this3.optionGroups[group].menu)); + + _this3.toolbarOptionsGroup.appendChild(toolbarMenu); // add group to toolbarOptions + + + var toolbarGroup = document.createElement("div"); + toolbarGroup.classList.add("toolbar-group"); + toolbarGroup.id = "group-".concat(group); + + _this3.options.toolbarOptions.forEach(function (option) { + var toolbarOption = _this3.optionGroups[group].group.filter(function (group) { + return group[option]; + })[0]; + + if (toolbarOption) { + var svgData = toolbarOption[option]; + + var optionSpan = _this3.constructSVG(svgData); + + optionSpan.classList.add('toolbar-option'); + optionSpan.id = "toolbar-".concat(option); + toolbarGroup.appendChild(optionSpan); + } + }); + + _this3.toolbarOptionsGroup.appendChild(toolbarGroup); // FONT AWESOME IMPORTED ICONS + // this.optionGroups[group].group.forEach((option) => { + // const toolbarCommand = Object.keys(option)[0]; + // if(this.options.toolbarOptions.includes(toolbarCommand)){ + // const optionSpan = this.constructSVG(option[toolbarCommand]); + // // const optionIcon = document.createElement("i"); + // optionSpan.id = `toolbar-${toolbarCommand}`; + // optionSpan.style.margin = "0 10px"; + // // optionIcon.classList.add(this.options.fontPack); + // // optionIcon.classList.add(option[toolbarCommand]); + // // optionSpan.appendChild(optionIcon); + // toolbarGroup.appendChild(optionSpan); + // } + // }) + // this.toolbarOptionsGroup.appendChild(toolbarGroup); + + }); // toolbar group for custom options + + var customOptions = this.options.toolbarOptions.filter(function (option) { + return _typeof(option) === "object"; + }); + + if (customOptions.length > 0) { + this.customToolbarMenu = document.createElement("div"); + this.customToolbarMenu.classList.add("toolbar-menu"); + this.customToolbarMenu.id = "menu-custom"; + var customSVGViewBox = "0 0 1792 1792"; + var customSVGD = "M1088 1248v192q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h192q40 0 68 28t28 68zm0-512v192q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h192q40 0 68 28t28 68zm0-512v192q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h192q40 0 68 28t28 68z"; + this.customToolbarMenu.appendChild(this.constructSVG({ + viewBox: customSVGViewBox, + d: customSVGD + })); + this.toolbarOptionsGroup.appendChild(this.customToolbarMenu); + this.customToolbarGroup = document.createElement("div"); + this.customToolbarGroup.classList.add("toolbar-group"); + this.customToolbarGroup.id = "group-custom"; + customOptions.forEach(function (customOption) { + var icon = customOption.icon, + handler = customOption.handler; + + var optionSpan = _this3.constructSVG(icon); + + optionSpan.id = "toolbar-customOption"; + optionSpan.style.margin = "0 10px"; + + optionSpan.onclick = function () { + return handler(); + }; + + _this3.customToolbarGroup.appendChild(optionSpan); + }); + this.toolbarOptionsGroup.appendChild(this.customToolbarGroup); + } + + toolbar.appendChild(this.toolbarOptionsGroup); //add toolbar-send + + if (this.options.customToolbarButton) { + var customToolbarButton = document.createElement("div"); + customToolbarButton.id = "custom-toolbar-button"; + customToolbarButton.classList.add('custom-toolbar-button'); + customToolbarButton.style.minHeight = this.options.toolbarHide ? "40px" : toolbar.style.minHeight; + + customToolbarButton.onclick = function () { + return _this3.options.customToolbarButton.handler(); + }; + + !this.options.toolbarHide && (customToolbarButton.style.display = "flex"); + + customToolbarButton.onmouseenter = function () { + customToolbarButton.style.borderColor = _this3.options.customToolbarButton.hoverBorderColor; + customToolbarButton.style.backgroundColor = _this3.options.customToolbarButton.hoverBackgroundColor; + customToolbarButton.style.color = _this3.options.customToolbarButton.hoverColor; + }; + + customToolbarButton.onmouseleave = function () { + customToolbarButton.style.borderColor = _this3.options.customToolbarButton.borderColor; + customToolbarButton.style.backgroundColor = _this3.options.customToolbarButton.backgroundColor; + customToolbarButton.style.color = _this3.options.customToolbarButton.color; + }; + + var customToolbarButtonSVG = this.constructSVG(this.options.customToolbarButton.svgData); + customToolbarButtonSVG.querySelector('path').setAttribute("fill", this.options.customToolbarButton.color); + customToolbarButton.appendChild(customToolbarButtonSVG); + toolbar.appendChild(customToolbarButton); + } + + this.toolbarOptions = toolbar.querySelectorAll("span"); + this.toolbarGroups = _toConsumableArray(toolbar.getElementsByClassName("toolbar-group")); + this.toolbarMenus = _toConsumableArray(toolbar.getElementsByClassName("toolbar-menu")); + this.customToolbarButton = toolbar.querySelector("#custom-toolbar-button"); + this.toolbarMenus.push(this.customToolbarMenu); + this.toolbarGroups.push(this.customToolbarGroup); // Remove menu that has no options enabled + + this.toolbarGroups.forEach(function (group) { + if (group && group.children.length < 1) { + var groupName = group.id.split("-")[1]; + + var menu = _this3.toolbarMenus.filter(function (menu) { + return menu.id.split("-")[1] === groupName; + })[0]; + + menu.remove(); + } + }); + return toolbar; + } + }, { + key: "initBody", + value: function initBody() { + var _this4 = this; + + var body = document.createElement("div"); + body.classList.add("body"); + body.contentEditable = "true"; + body.style.height = this.editor.style.height; + body.style.minHeight = this.editor.style.minHeight; + body.style.maxHeight = this.editor.style.maxHeight; + this.editor.style.height = 'auto'; + this.editor.style.minHeight = 'auto'; + this.editor.style.maxHeight = 'auto'; // Placeholder logic + + if (this.options.placeholder) { + var placeholderNode = document.createElement("p"); + placeholderNode.id = "placeholder-node"; + placeholderNode.style.color = "#5f6368"; + placeholderNode.style.margin = "0"; + placeholderNode.textContent = this.options.placeholder; + body.append(placeholderNode); + var bodyFocus = body.onfocus; + + body.onfocus = function () { + bodyFocus && bodyFocus(); + body.querySelector("#placeholder-node") === placeholderNode && _this4.clearContent(); + }; + + var bodyBlur = body.onblur; + + body.onblur = function () { + bodyBlur && bodyBlur(); + _this4.getContent().trim() === "" && body.append(placeholderNode); + }; + } // Paste Handler + + + body.onpaste = function (e) { + function dataURLtoFile(dataurl, filename) { + var arr = dataurl.split(','), + mime = arr[0].match(/:(.*?);/)[1], + bstr = atob(arr[1]), + n = bstr.length, + u8arr = new Uint8Array(n); + + while (n--) { + u8arr[n] = bstr.charCodeAt(n); + } + + var file = new File([u8arr], filename, { + type: mime + }); + return new File([u8arr], "".concat(file.name, ".").concat(file.type.split('/').pop()), { + type: file.type + }); + } + + var convertImage = function convertImage(file) { + return new Promise(function (resolve, reject) { + var reader = new FileReader(); + reader.readAsDataURL(file); + + reader.onload = function () { + return resolve(reader.result); + }; + + reader.onerror = function (error) { + return reject(error); + }; + }); + }; + + if (e.clipboardData.files.length > 0 && e.clipboardData.files[0].type.includes("image")) { + convertImage(e.clipboardData.files[0]).then(function (res) { + if (_this4.options.imageUrl) { + _this4.getImage(res).then(function (data) { + document.execCommand("insertImage", true, data.imageRef); + })["catch"](function (err) { + document.execCommand("insertImage", true, res); + }); + } else { + document.execCommand("insertImage", true, res); + _this4.options.uploadOnPaste && _this4.attachFile(dataURLtoFile(res, "pastedimage")); + } + + _this4.overflow(); + }); + } // sanitize of html + + + if (_this4.options.sanitizePaste && e.clipboardData.types.includes("text/html")) { + e.preventDefault(); + var pastedHtmlItem; + + for (var i = 0; i < e.clipboardData.items.length; i++) { + var item = e.clipboardData.items[i]; + item.type === "text/html" && (pastedHtmlItem = item); + } + + if (pastedHtmlItem) { + pastedHtmlItem.getAsString(function (htmlString) { + var range = _this4.getRange(); + + range.insertNode(_this4.scrubHTML(htmlString)); + range.collapse(); + }); + } + } // meta extraction on paste + + + if (e.clipboardData.items.length > 0 && e.clipboardData.items[0].type === "text/plain") { + e.clipboardData.items[0].getAsString(function (string) { + if (_this4.options.metaUrl && _this4.validURL(string)) { + _this4.getMeta(string).then(function (res) { + var url = res.url, + title = res.title, + image = res.image, + description = res.description; + url && title && image && _this4.createMetaDataElement(url, image, title, description); + }); + } + }); + } + + _this4.overflow(); + }; // State of the editor + + + var bodyKeyup = body.onkeyup; + + body.onkeyup = function (e) { + bodyKeyup && bodyKeyup(); + _this4.range = _this4.getRange(); + + if (_this4.options.submitOnEnter && e.keyCode === 13 && !e.shiftKey) { + if (!document.queryCommandState('insertOrderedList') && !document.queryCommandState('insertUnorderedList')) { + var hasText = !!_this4.getTextContent(); + var hasImage = !!body.querySelector('img'); // remove break from enter + + if (hasText || hasImage) { + var breaks = body.querySelectorAll('div'); + var divBreak = breaks[breaks.length ? breaks.length - 1 : 0]; + divBreak && divBreak.remove(); + } + + var content = _this4.getContent(); + + var files = _this4.getFiles(); + + _this4.clearContent(); + + _this4.clearFiles(); + + if (files.length || hasText || hasImage) { + _this4.options.submitOnEnter({ + content: (hasText || hasImage) && content, + files: files + }); + } + } + } + + _this4.toolbarState(); + }; + + var bodyMouseUp = body.onmouseup; + + body.onmouseup = function (e) { + bodyMouseUp && bodyMouseUp(); + _this4.range = _this4.getRange(); + }; + + return body; + } + }, { + key: "initLinkMenu", + value: function initLinkMenu() { + var _this5 = this; + + var linkMenu = document.createElement("div"); + var linkMenuForm = document.createElement("div"); + var linkMenuButtons = document.createElement("div"); + var linkMenuButton = document.createElement("button"); + var linkMenuCloseButton = document.createElement("button"); + var linkMenuFormLabel = document.createElement("p"); + var linkMenuFormInput = document.createElement("input"); + linkMenu.id = "link-menu"; + linkMenu.classList.add('popup'); + linkMenu.dataset.active = "false"; + linkMenuForm.classList.add('popup-form'); + linkMenuFormLabel.classList.add('form-label'); + linkMenuFormLabel.textContent = "Web Address"; + linkMenuFormInput.classList.add('form-input'); + linkMenuFormInput.type = "text"; + linkMenuFormInput.placeholder = "Insert a Link"; + linkMenuButtons.classList.add('popup-button-container'); + linkMenuButton.classList.add('popup-button'); + linkMenuButton.classList.add('button-primary'); + linkMenuButton.textContent = "Insert Link"; + linkMenuCloseButton.classList.add('popup-button'); + linkMenuCloseButton.classList.add('button-secondary'); + linkMenuCloseButton.textContent = "Close"; + + linkMenuButton.onclick = function (e) { + var linkValue = linkMenuFormInput.value; + + if (linkValue) { + window.getSelection().removeAllRanges(); + window.getSelection().addRange(_this5.range); + + if (_this5.isFirefox || _this5.isEdge) { + document.execCommand("createLink", false, linkValue); + } else { + document.execCommand("createLink", true, linkValue); + } + + if (_this5.options.metaUrl && _this5.validURL(linkValue)) { + _this5.getMeta(linkValue).then(function (res) { + var url = res.url, + image = res.image, + title = res.title, + description = res.description; + url && image && title && _this5.createMetaDataElement(url, image, title, description); + }); + } + + var bodyLinks = _this5.body.querySelectorAll("a"); + + _toConsumableArray(bodyLinks).forEach(function (link) { + return !_this5.isFirefox && (link.contentEditable = 'false'); + }); + + linkMenuFormInput.value = ""; + + _this5.closeLinkMenu(); + } else { + _this5.body.focus(); + + _this5.closeLinkMenu(); + } + }; + + linkMenuCloseButton.onclick = function (e) { + _this5.body.focus(); + + _this5.closeLinkMenu(); + }; + + linkMenuForm.appendChild(linkMenuFormLabel); + linkMenuForm.appendChild(linkMenuFormInput); + linkMenu.appendChild(linkMenuForm); + linkMenuButtons.appendChild(linkMenuButton); + linkMenuButtons.appendChild(linkMenuCloseButton); + linkMenu.appendChild(linkMenuButtons); + return linkMenu; + } + }, { + key: "initImageMenu", + value: function initImageMenu() { + var _this6 = this; + + var imageMenu = document.createElement("div"); + var imageMenuForm = document.createElement("div"); + var imageMenuButtons = document.createElement("div"); + var imageMenuButton = document.createElement("button"); + var imageMenuCloseButton = document.createElement("button"); + var imageMenuFormLabel = document.createElement("p"); + var imageMenuFormSourceInput = document.createElement("input"); + imageMenu.id = "image-menu"; + imageMenu.classList.add('popup'); + imageMenu.dataset.active = "false"; + imageMenuForm.classList.add('popup-form'); + imageMenuFormLabel.classList.add('form-label'); + imageMenuFormLabel.textContent = "Image URL"; + imageMenuFormSourceInput.classList.add('form-input'); + imageMenuFormSourceInput.type = "text"; + imageMenuFormSourceInput.placeholder = "Insert a Link"; + imageMenuButtons.classList.add('popup-button-container'); + imageMenuButton.classList.add('popup-button'); + imageMenuButton.classList.add('button-primary'); + imageMenuButton.textContent = "Insert Image"; + imageMenuCloseButton.classList.add('popup-button'); + imageMenuCloseButton.classList.add('button-secondary'); + imageMenuCloseButton.textContent = "Close"; + imageMenuForm.appendChild(imageMenuFormLabel); + imageMenuForm.appendChild(imageMenuFormSourceInput); // Height Input Form + + var imageMenuHeightForm = imageMenuForm.cloneNode(true); + var imageMenuHeightFormInput = imageMenuHeightForm.querySelector('input'); + var imageMenuHeightFormLabel = imageMenuHeightForm.querySelector('p'); + imageMenuHeightFormInput.placeholder = "Image Height"; + imageMenuHeightFormLabel.textContent = "Height"; // Width Input Form + + var imageMenuWidthForm = imageMenuForm.cloneNode(true); + var imageMenuWidthFormInput = imageMenuWidthForm.querySelector('input'); + var imageMenuWidthFormLabel = imageMenuWidthForm.querySelector('p'); + imageMenuWidthFormInput.placeholder = "Image Width"; + imageMenuWidthFormLabel.textContent = "Width"; + + imageMenuButton.onclick = function (e) { + var linkValue = imageMenuFormSourceInput.value; + var heightValue = imageMenuHeightFormInput.value; + var widthValue = imageMenuWidthFormInput.value; + + if (linkValue) { + window.getSelection().removeAllRanges(); + window.getSelection().addRange(_this6.range); + + if (_this6.isFirefox || _this6.isEdge) { + document.execCommand("insertImage", false, linkValue); + } else { + document.execCommand("insertImage", true, linkValue); + } + + var insertedImage = _toConsumableArray(_this6.body.querySelectorAll("img")).filter(function (img) { + return img.src === linkValue; + }); + + insertedImage = insertedImage[insertedImage.length - 1]; + insertedImage && (insertedImage.style.height = "".concat(heightValue, "px")); + insertedImage && (insertedImage.style.width = "".concat(widthValue, "px")); + imageMenuHeightFormInput.value = ""; + imageMenuWidthFormInput.value = ""; + imageMenuFormSourceInput.value = ""; + + _this6.closeImageMenu(); + } else { + _this6.body.focus(); + + _this6.closeImageMenu(); + } + }; + + imageMenuCloseButton.onclick = function (e) { + _this6.body.focus(); + + _this6.closeImageMenu(); + }; + + imageMenu.appendChild(imageMenuHeightForm); + imageMenu.appendChild(imageMenuWidthForm); + imageMenu.appendChild(imageMenuForm); + imageMenuButtons.appendChild(imageMenuButton); + imageMenuButtons.appendChild(imageMenuCloseButton); + imageMenu.appendChild(imageMenuButtons); + return imageMenu; + } + }, { + key: "initMetaDataSection", + value: function initMetaDataSection() { + var metaDataSection = document.createElement("div"); + metaDataSection.classList.add("metadata-section"); + return metaDataSection; + } + }, { + key: "initFilesSection", + value: function initFilesSection() { + var _this7 = this; + + var filesSection = document.createElement("div"); + filesSection.classList.add("files-section"); + + this.body.ondragenter = function (e) { + _this7.body.style.backgroundColor = "#ddd"; + }; + + this.body.ondragleave = function (e) { + _this7.body.style.backgroundColor = "inherit"; + }; + + this.body.ondrop = function (e) { + _this7.body.style.backgroundColor = "inherit"; + e.preventDefault(); + var file = e.dataTransfer.files && e.dataTransfer.files[0]; + + _this7.attachFile(file); + }; + + this.isEdge && (this.body.ondragover = function (e) { + return e.preventDefault(); + }); + return filesSection; + } + }, { + key: "createFileElement", + value: function createFileElement(name, size) { + var _this8 = this; + + var fileEl = document.createElement("div"); + var fileNameEl = document.createElement("h4"); + var fileSizeEl = document.createElement("p"); + var removeFileEl = document.createElement("p"); + fileNameEl.textContent = name; + fileSizeEl.textContent = size; + removeFileEl.textContent = "X"; + fileEl.classList.add('file-el'); + fileEl.dataset.fileindex = this.files.length - 1; + fileNameEl.classList.add('file-name-el'); + fileSizeEl.classList.add('file-size-el'); + removeFileEl.classList.add('remove-file-el'); + + removeFileEl.onmouseenter = function () { + return removeFileEl.style.color = "#ddd"; + }; + + removeFileEl.onmouseleave = function () { + return removeFileEl.style.color = "black"; + }; + + removeFileEl.onclick = function (e) { + _this8.files.splice(e.target.parentElement.dataset.fileindex, 1); + + e.target.parentElement.remove(); + }; + + fileEl.appendChild(fileNameEl); + fileEl.appendChild(fileSizeEl); + fileEl.appendChild(removeFileEl); + this.filesSection.appendChild(fileEl); + } + }, { + key: "createMetaDataElement", + value: function createMetaDataElement(url, img, title, description) { + var metaItemEl = document.createElement("div"); + var metaLinkEl = document.createElement("a"); + var metaImageEl = document.createElement("img"); + var metaDataEl = document.createElement("div"); + var metaDataTitleEl = document.createElement("h4"); + var metaDataDescriptionEl = document.createElement("p"); + var removeMetaDataEl = document.createElement("span"); + metaLinkEl.href = url; + metaImageEl.src = img; + metaDataTitleEl.textContent = title; + metaDataDescriptionEl.textContent = description; + removeMetaDataEl.textContent = "X"; + metaLinkEl.target = "blank"; + metaItemEl.classList.add("meta-item-el"); + metaImageEl.classList.add("meta-image-el"); + metaDataTitleEl.classList.add("meta-data-title-el"); + metaDataDescriptionEl.style.margin = "0"; + removeMetaDataEl.classList.add("remove-meta-data-el"); + + removeMetaDataEl.onmouseenter = function () { + return removeMetaDataEl.style.color = "#ddd"; + }; + + removeMetaDataEl.onmouseleave = function () { + return removeMetaDataEl.style.color = "black"; + }; + + removeMetaDataEl.onclick = function (e) { + return e.target.parentElement.remove(); + }; + + metaLinkEl.appendChild(metaImageEl); + metaDataEl.appendChild(metaDataTitleEl); + metaDataEl.appendChild(metaDataDescriptionEl); + metaItemEl.appendChild(metaLinkEl); + metaItemEl.appendChild(metaDataEl); + metaItemEl.appendChild(removeMetaDataEl); + this.metaDataSection.appendChild(metaItemEl); + } + }, { + key: "constructSVG", + value: function constructSVG(svgData) { + var viewBox = svgData.viewBox, + d = svgData.d; + var fillColor = this.options.toolbarOptionFillColor ? this.options.toolbarOptionFillColor : "#333"; + var xmlns = "http://www.w3.org/2000/svg"; + var height = "14"; + var width = "16"; + var icon = document.createElement('span'); + var svg = "<svg width=\"".concat(width, "\" height=\"").concat(height, "\" viewBox=\"").concat(viewBox, "\" xmlns=\"").concat(xmlns, "\">"); + var path = "<path fill=\"".concat(fillColor, "\" d=\"").concat(d, "\"/>"); + icon.innerHTML = "".concat(svg).concat(path, "</svg>"); + return icon; + } + }, { + key: "initResponsive", + value: function initResponsive() { + var _this9 = this; + + var that = this; + + if (!this.options.minimal) { + var responsiveGroups = function responsiveGroups(isResponsive) { + that.toolbarGroups.forEach(function (group) { + if (group) { + group.dataset.open = "false"; + group.style.display = isResponsive ? "none" : "block"; + group.style.position = isResponsive ? "absolute" : "relative"; // group.style.right = isResponsive ? "10px" : "inherit"; + + !that.options.toolbarBottom && (group.style.top = isResponsive ? "50px" : "inherit"); + that.options.toolbarBottom && (group.style.bottom = isResponsive ? "50px" : "inherit"); // group.style.margin = isResponsive ? "0 2px" : "inherit"; + // group.style.backgroundColor = isResponsive ? "#fff" : "inherit"; + // group.style.border = isResponsive ? "2px solid #ddd" : "none"; + } + }); + that.toolbarMenus.forEach(function (menu) { + function toggleMenu() { + var selectedGroup = that.toolbar.querySelector("#group-".concat(menu.id.split("-")[1])); + + if (selectedGroup.dataset.open === "false") { + // close opened groups + that.toolbarGroups.forEach(function (group) { + if (group && group.dataset.open === "true") { + group.style.display = "none"; + group.dataset.open = "false"; + } + }); // open group + + selectedGroup.style.display = "block"; + selectedGroup.style.padding = "5px 5px 0 5px"; + selectedGroup.dataset.open = "true"; + } else { + selectedGroup.style.display = "none"; + selectedGroup.dataset.open = "false"; + } + } + + if (menu) { + menu.style.padding = "0 10px"; + menu.style.cursor = "pointer"; + menu.style.userSelect = "none"; + menu.style.display = isResponsive ? "block" : "none"; + + menu.onclick = function (e) { + toggleMenu(); + that.body.focus(); + }; + } + }); + }; -/***/ "./src/index.js": -/*!**********************!*\ - !*** ./src/index.js ***! - \**********************/ -/*! no static exports found */ + var setResponsive = function setResponsive() { + responsive = window.matchMedia("(max-width: 700px)").matches; + responsiveGroups(responsive); + }; + + var responsive = window.matchMedia("(max-width: 700px)").matches; + setResponsive(); + + window.onresize = function () { + _this9.toolbarGroups.forEach(function (group) { + return group && (group.style.padding = "0"); + }); + + _this9.closeLinkMenu(); + + _this9.closeImageMenu(); + + setResponsive(); + }; + } else { + this.toolbarMenus.forEach(function (menu) { + return menu && (menu.style.display = "none"); + }); + this.toolbar.querySelector("#toolbar-strikethrough").style.display = "none"; + this.toolbar.querySelector("#toolbar-image").style.display = "none"; + this.toolbar.querySelector("#toolbar-insertOrderedList").style.display = "none"; + this.toolbar.querySelector("#group-textAlign").style.display = "none"; + this.toolbar.querySelector("#toolbar-removeFormat").style.display = "none"; + } + } + }, { + key: "initOverflow", + value: function initOverflow() { + var _this10 = this; + + var onFocus = this.body.onfocus; + + this.body.onfocus = function () { + onFocus && onFocus(); + + _this10.overflow(); + }; + + var onBlur = this.body.onblur; + + this.body.onblur = function () { + onBlur && onBlur(); + + _this10.overflow(); + }; + + var bodyKeypress = this.body.onkeypress; + + this.body.onkeypress = function () { + bodyKeypress && bodyKeypress(); + + _this10.overflow(); + }; + } + }, { + key: "getFiles", + value: function getFiles() { + return this.files; + } + }, { + key: "getContent", + value: function getContent() { + if (this.body.querySelector("#placeholder-node")) { + return ""; + } else { + return this.body.innerHTML; + } + } + }, { + key: "getRange", + value: function getRange() { + return window.getSelection().getRangeAt(0); + } + }, { + key: "getMeta", + value: function getMeta(url) { + return fetch(this.options.metaUrl, { + method: "POST", + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + targetUrl: url + }) + }).then(function (res) { + return res.json(); + }); + } + }, { + key: "getImage", + value: function getImage(imageEncoding) { + return fetch(this.options.imageUrl, { + method: "POST", + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + imageEncoding: imageEncoding + }) + }).then(function (res) { + return res.json(); + }); + } + }, { + key: "validURL", + value: function validURL(str) { + var pattern = new RegExp("^(https?:\\/\\/)?" + "((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|" + "((\\d{1,3}\\.){3}\\d{1,3}))" + "(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" + "(\\?[;&a-z\\d%_.~+=-]*)?" + "(\\#[-a-z\\d_]*)?$", "i"); + return !!pattern.test(str); + } + }, { + key: "overflow", + value: function overflow() { + var body = this.body; + body.scrollHeight > body.clientHeight ? body.style.overflowY = "scroll" : body.style.overflowY = "hidden"; + body.scrollWidth > body.clientWidth ? body.style.overflowX = "scroll" : body.style.overflowX = "hidden"; + } + }, { + key: "formatBytes", + value: function formatBytes(bytes) { + var decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2; + if (bytes === 0) return '0 Bytes'; + var k = 1024; + var dm = decimals < 0 ? 0 : decimals; + var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + var i = Math.floor(Math.log(bytes) / Math.log(k)); + return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; + } + }, { + key: "validateFile", + value: function validateFile(file) { + var extension = file.type.split('/').pop(); + return this.options.extensions.includes(".".concat(extension)); + } + }, { + key: "attachFile", + value: function attachFile(file) { + if (this.validateFile(file)) { + this.files.push(file); + this.createFileElement(file.name, this.formatBytes(file.size)); + } else { + this.fileInvalid(); + } + } + }, { + key: "fileInvalid", + value: function fileInvalid() { + var _this11 = this; + + this.body.style.transition = "background-color .5s"; + this.body.style.backgroundColor = "#d9534f"; + setTimeout(function () { + _this11.body.style.backgroundColor = "inherit"; + setTimeout(function () { + return _this11.body.style.transition = "none"; + }, 500); + }, 2000); + } + }, { + key: "openLinkMenu", + value: function openLinkMenu() { + //close other open popups + this.closeImageMenu(); + this.linkMenu.dataset.active = "true"; + this.linkMenu.style.display = "block"; + this.addPopupEscapeHandler(); + } + }, { + key: "openImageMenu", + value: function openImageMenu() { + //close other open popups + this.closeLinkMenu(); + this.imageMenu.dataset.active = "true"; + this.imageMenu.style.display = "block"; + this.addPopupEscapeHandler(); + } + }, { + key: "closeLinkMenu", + value: function closeLinkMenu() { + this.linkMenu.dataset.active = "false"; + this.linkMenu.style.display = "none"; + this.removePopupEscapeHandler(); + } + }, { + key: "closeImageMenu", + value: function closeImageMenu() { + this.imageMenu.dataset.active = "false"; + this.imageMenu.style.display = "none"; + this.removePopupEscapeHandler(); + } + }, { + key: "popupEscapeHandler", + value: function popupEscapeHandler(evt) { + if (evt.which === 27) { + //close all open popups + this.closeImageMenu(); + this.closeLinkMenu(); + } + } + }, { + key: "addPopupEscapeHandler", + value: function addPopupEscapeHandler() { + this.removePopupEscapeHandler(); + this.editor.addEventListener('keyup', this.bound_popupEscapeHandler); + } + }, { + key: "removePopupEscapeHandler", + value: function removePopupEscapeHandler() { + this.editor.removeEventListener('keyup', this.bound_popupEscapeHandler); + } + }, { + key: "setContent", + value: function setContent(html) { + this.clearContent(); + this.body.innerHTML = html; + } + }, { + key: "clearContent", + value: function clearContent() { + this.body.innerHTML = ""; + } + }, { + key: "clearFiles", + value: function clearFiles() { + this.files = []; + this.filesSection.innerHTML = ''; + } + }, { + key: "getTextContent", + value: function getTextContent() { + if (this.body.querySelector("#placeholder-node")) { + return ""; + } else { + return this.body.textContent; + } + } + }, { + key: "scrubHTML", + value: function scrubHTML(html) { + var dirtyNode = document.createElement("div"); + var cleanNode = document.createElement("div"); + dirtyNode.innerHTML = html; + cleanNode.append(document.createTextNode(dirtyNode.textContent)); + return cleanNode; + } + }, { + key: "toolbarState", + value: function toolbarState() { + var _this12 = this; + + this.options.toolbarOptions.forEach(function (option) { + var toolbarOption = _this12.toolbar.querySelector("#toolbar-".concat(option)); + + if (!option.includes('justify') && !option.includes('list')) { + if (document.queryCommandState(option)) { + toolbarOption.querySelector('path').setAttribute('fill', _this12.options.activeOptionColor); + } else { + toolbarOption.querySelector('path').setAttribute('fill', '#333'); + } + } + }); + } + }, { + key: "establishBrowser", + value: function establishBrowser() { + // Change this to user agent + // Opera 8.0+ + this.isOpera = !!window.opr && !!opr.addons || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0; // Firefox 1.0+ + + this.isFirefox = typeof InstallTrigger !== 'undefined'; // Safari 3.0+ "[object HTMLElementConstructor]" + + this.isSafari = /constructor/i.test(window.HTMLElement) || function (p) { + return p.toString() === "[object SafariRemoteNotification]"; + }(!window['safari'] || typeof safari !== 'undefined' && safari.pushNotification); // Internet Explorer 6-11 + + + this.isIE = + /*@cc_on!@*/ + false || !!document.documentMode; // Edge 20+ + + this.isEdge = !this.isIE && !!window.StyleMedia; // Chrome 1 - 71 + + this.isChrome = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime); // Blink engine detection + + this.isBlink = (this.isChrome || this.isOpera) && !!window.CSS; + } + }, { + key: "isEditorInFocus", + value: function isEditorInFocus() { + var _this13 = this; + + var activeEl = document.activeElement; + + var isEditor = function isEditor(el) { + if (el === _this13.editor) { + return true; + } else if (el === document.body) { + return false; + } + + return el.parentNode && isEditor(el.parentNode); + }; + + return isEditor(activeEl); + } + }]); + + return StrivenEditor; + }(); + + _exports["default"] = StrivenEditor; +}); + +/***/ }), +/* 1 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_0_node_modules_vue_loader_lib_index_js_vue_loader_options_vue_striveneditor_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2); +/* harmony import */ var _node_modules_babel_loader_lib_index_js_ref_0_node_modules_vue_loader_lib_index_js_vue_loader_options_vue_striveneditor_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_babel_loader_lib_index_js_ref_0_node_modules_vue_loader_lib_index_js_vue_loader_options_vue_striveneditor_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__); +/* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in _node_modules_babel_loader_lib_index_js_ref_0_node_modules_vue_loader_lib_index_js_vue_loader_options_vue_striveneditor_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__) if(__WEBPACK_IMPORT_KEY__ !== 'default') (function(key) { __webpack_require__.d(__webpack_exports__, key, function() { return _node_modules_babel_loader_lib_index_js_ref_0_node_modules_vue_loader_lib_index_js_vue_loader_options_vue_striveneditor_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0__[key]; }) }(__WEBPACK_IMPORT_KEY__)); + /* harmony default export */ __webpack_exports__["default"] = (_node_modules_babel_loader_lib_index_js_ref_0_node_modules_vue_loader_lib_index_js_vue_loader_options_vue_striveneditor_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_0___default.a); + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + +var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { + if (true) { + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports, __webpack_require__(0)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), + __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? + (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else { var mod; } +})(this, function (_exports, _striveneditor) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports["default"] = void 0; + _striveneditor = _interopRequireDefault(_striveneditor); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } + + // + // + // + // + var _default = { + name: 'striven-editor', + props: { + toolbarHide: Boolean, + toolbarBotoom: Boolean, + minimal: Boolean, + metaUrl: String, + extensions: Array, + uploadOnPaste: Boolean, + toolbarOptionFillColor: String, + placeholder: String, + sanitizePaste: String, + imageUrl: String, + customToolbarOption: Object, + activeOptionColor: String, + submitOnEnter: Function + }, + mounted: function mounted() { + this.editor = new _striveneditor["default"](this.$refs.editor, this.props); + }, + data: function data() { + return { + editor: {} + }; + } + }; + _exports["default"] = _default; +}); + +/***/ }), +/* 3 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; + +// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./src/vue-striveneditor.vue?vue&type=template&id=5e858f64& +var render = function() { + var _vm = this + var _h = _vm.$createElement + var _c = _vm._self._c || _h + return _c("div", { ref: "editor" }) +} +var staticRenderFns = [] +render._withStripped = true + + +// CONCATENATED MODULE: ./src/vue-striveneditor.vue?vue&type=template&id=5e858f64& +/* concated harmony reexport render */__webpack_require__.d(__webpack_exports__, "a", function() { return render; }); +/* concated harmony reexport staticRenderFns */__webpack_require__.d(__webpack_exports__, "b", function() { return staticRenderFns; }); + + +/***/ }), +/* 4 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; }); +/* globals __VUE_SSR_CONTEXT__ */ + +// IMPORTANT: Do NOT use ES2015 features in this file (except for modules). +// This module is a runtime utility for cleaner component module output and will +// be included in the final webpack user bundle. + +function normalizeComponent ( + scriptExports, + render, + staticRenderFns, + functionalTemplate, + injectStyles, + scopeId, + moduleIdentifier, /* server only */ + shadowMode /* vue-cli only */ +) { + // Vue.extend constructor export interop + var options = typeof scriptExports === 'function' + ? scriptExports.options + : scriptExports + + // render functions + if (render) { + options.render = render + options.staticRenderFns = staticRenderFns + options._compiled = true + } + + // functional template + if (functionalTemplate) { + options.functional = true + } + + // scopedId + if (scopeId) { + options._scopeId = 'data-v-' + scopeId + } + + var hook + if (moduleIdentifier) { // server build + hook = function (context) { + // 2.3 injection + context = + context || // cached call + (this.$vnode && this.$vnode.ssrContext) || // stateful + (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional + // 2.2 with runInNewContext: true + if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') { + context = __VUE_SSR_CONTEXT__ + } + // inject component styles + if (injectStyles) { + injectStyles.call(this, context) + } + // register component module identifier for async chunk inferrence + if (context && context._registeredComponents) { + context._registeredComponents.add(moduleIdentifier) + } + } + // used by ssr in case component is cached and beforeCreate + // never gets called + options._ssrRegister = hook + } else if (injectStyles) { + hook = shadowMode + ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) } + : injectStyles + } + + if (hook) { + if (options.functional) { + // for template-only hot-reload because in that case the render fn doesn't + // go through the normalizer + options._injectStyles = hook + // register for functioal component in vue file + var originalRender = options.render + options.render = function renderWithStyleInjection (h, context) { + hook.call(context) + return originalRender(h, context) + } + } else { + // inject component registration as beforeCreate hook + var existing = options.beforeCreate + options.beforeCreate = existing + ? [].concat(existing, hook) + : [hook] + } + } + + return { + exports: scriptExports, + options: options + } +} + + +/***/ }), +/* 5 */ /***/ (function(module, exports, __webpack_require__) { -eval("var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) {\n if (true) {\n !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports, __webpack_require__(/*! ./striveneditor */ \"./src/striveneditor.js\")], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?\n\t\t\t\t(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n } else { var mod; }\n})(this, function (_exports, _striveneditor) {\n \"use strict\";\n\n Object.defineProperty(_exports, \"__esModule\", {\n value: true\n });\n Object.defineProperty(_exports, \"StrivenEditor\", {\n enumerable: true,\n get: function get() {\n return _striveneditor[\"default\"];\n }\n });\n _striveneditor = _interopRequireDefault(_striveneditor);\n\n function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { \"default\": obj }; }\n});\n\n//# sourceURL=webpack://striveneditor/./src/index.js?"); +var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { + if (true) { + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports, __webpack_require__(0)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), + __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? + (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else { var mod; } +})(this, function (_exports, _striveneditor) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports["default"] = void 0; + _striveneditor = _interopRequireDefault(_striveneditor); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + var KoStrivenEditor = function KoStrivenEditor(ko) { + _classCallCheck(this, KoStrivenEditor); + + ko.bindingHandlers.striveneditor = { + init: function init(element, valueAccessor, allBindings, viewModel, bindingContext) { + var valueOption = valueAccessor(); + var value = ko.utils.unwrapObservable(valueOption); + var editor = new _striveneditor["default"](value); + } + }; + }; + + _exports["default"] = KoStrivenEditor; +}); /***/ }), +/* 6 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _vue_striveneditor_vue_vue_type_template_id_5e858f64___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3); +/* harmony import */ var _vue_striveneditor_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1); +/* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in _vue_striveneditor_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__) if(__WEBPACK_IMPORT_KEY__ !== 'default') (function(key) { __webpack_require__.d(__webpack_exports__, key, function() { return _vue_striveneditor_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__[key]; }) }(__WEBPACK_IMPORT_KEY__)); +/* harmony import */ var _node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4); -/***/ "./src/striveneditor.js": -/*!******************************!*\ - !*** ./src/striveneditor.js ***! - \******************************/ -/*! no static exports found */ + + + + +/* normalize component */ + +var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"])( + _vue_striveneditor_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"], + _vue_striveneditor_vue_vue_type_template_id_5e858f64___WEBPACK_IMPORTED_MODULE_0__[/* render */ "a"], + _vue_striveneditor_vue_vue_type_template_id_5e858f64___WEBPACK_IMPORTED_MODULE_0__[/* staticRenderFns */ "b"], + false, + null, + null, + null + +) + +/* hot reload */ +if (false) { var api; } +component.options.__file = "src/vue-striveneditor.vue" +/* harmony default export */ __webpack_exports__["default"] = (component.exports); + +/***/ }), +/* 7 */ /***/ (function(module, exports, __webpack_require__) { -eval("var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) {\n if (true) {\n !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?\n\t\t\t\t(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n } else { var mod; }\n})(this, function (_exports) {\n \"use strict\";\n\n Object.defineProperty(_exports, \"__esModule\", {\n value: true\n });\n _exports[\"default\"] = void 0;\n\n function _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\n function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\n function _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\n function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\n function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\n function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\n function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n var EXTENSIONS = [\".doc\", \".docx\", \".xls\", \".xlsx\", \".ppt\", \".pptx\", \".pdf\", \".tif\", \".jpeg\", \".jpg\", \".gif\", \".bmp\", \".txt\", \".csv\", \".png\", \".msg\", \".wav\", \".mp3\", \".mp4\", \".zip\", \".rtf\", \".eps\", \".ai\", \".psd\", \".avi\", \".mov\", \".wmv\", \".cfg\", \".wss\", \".vsd\", \".vsdx\", \".tsd\", \".lic\"];\n var FONTPACK = \"fas\";\n var OPTIONGROUPS = {\n textDecoration: {\n menu: {\n viewBox: \"0 0 1792 1792\",\n d: \"M789 559l-170 450q33 0 136.5 2t160.5 2q19 0 57-2-87-253-184-452zm-725 1105l2-79q23-7 56-12.5t57-10.5 49.5-14.5 44.5-29 31-50.5l237-616 280-724h128q8 14 11 21l205 480q33 78 106 257.5t114 274.5q15 34 58 144.5t72 168.5q20 45 35 57 19 15 88 29.5t84 20.5q6 38 6 57 0 5-.5 13.5t-.5 12.5q-63 0-190-8t-191-8q-76 0-215 7t-178 8q0-43 4-78l131-28q1 0 12.5-2.5t15.5-3.5 14.5-4.5 15-6.5 11-8 9-11 2.5-14q0-16-31-96.5t-72-177.5-42-100l-450-2q-26 58-76.5 195.5t-50.5 162.5q0 22 14 37.5t43.5 24.5 48.5 13.5 57 8.5 41 4q1 19 1 58 0 9-2 27-58 0-174.5-10t-174.5-10q-8 0-26.5 4t-21.5 4q-80 14-188 14z\"\n },\n group: [{\n bold: {\n viewBox: \"0 0 1792 1792\",\n d: \"M747 1521q74 32 140 32 376 0 376-335 0-114-41-180-27-44-61.5-74t-67.5-46.5-80.5-25-84-10.5-94.5-2q-73 0-101 10 0 53-.5 159t-.5 158q0 8-1 67.5t-.5 96.5 4.5 83.5 12 66.5zm-14-746q42 7 109 7 82 0 143-13t110-44.5 74.5-89.5 25.5-142q0-70-29-122.5t-79-82-108-43.5-124-14q-50 0-130 13 0 50 4 151t4 152q0 27-.5 80t-.5 79q0 46 1 69zm-541 889l2-94q15-4 85-16t106-27q7-12 12.5-27t8.5-33.5 5.5-32.5 3-37.5.5-34v-65.5q0-982-22-1025-4-8-22-14.5t-44.5-11-49.5-7-48.5-4.5-30.5-3l-4-83q98-2 340-11.5t373-9.5q23 0 68 .5t68 .5q70 0 136.5 13t128.5 42 108 71 74 104.5 28 137.5q0 52-16.5 95.5t-39 72-64.5 57.5-73 45-84 40q154 35 256.5 134t102.5 248q0 100-35 179.5t-93.5 130.5-138 85.5-163.5 48.5-176 14q-44 0-132-3t-132-3q-106 0-307 11t-231 12z\"\n }\n }, {\n italic: {\n viewBox: \"0 0 1792 1792\",\n d: \"M384 1662l17-85q22-7 61.5-16.5t72-19 59.5-23.5q28-35 41-101 1-7 62-289t114-543.5 52-296.5v-25q-24-13-54.5-18.5t-69.5-8-58-5.5l19-103q33 2 120 6.5t149.5 7 120.5 2.5q48 0 98.5-2.5t121-7 98.5-6.5q-5 39-19 89-30 10-101.5 28.5t-108.5 33.5q-8 19-14 42.5t-9 40-7.5 45.5-6.5 42q-27 148-87.5 419.5t-77.5 355.5q-2 9-13 58t-20 90-16 83.5-6 57.5l1 18q17 4 185 31-3 44-16 99-11 0-32.5 1.5t-32.5 1.5q-29 0-87-10t-86-10q-138-2-206-2-51 0-143 9t-121 11z\"\n }\n }, {\n underline: {\n viewBox: \"0 0 1792 1792\",\n d: \"M176 223q-37-2-45-4l-3-88q13-1 40-1 60 0 112 4 132 7 166 7 86 0 168-3 116-4 146-5 56 0 86-2l-1 14 2 64v9q-60 9-124 9-60 0-79 25-13 14-13 132 0 13 .5 32.5t.5 25.5l1 229 14 280q6 124 51 202 35 59 96 92 88 47 177 47 104 0 191-28 56-18 99-51 48-36 65-64 36-56 53-114 21-73 21-229 0-79-3.5-128t-11-122.5-13.5-159.5l-4-59q-5-67-24-88-34-35-77-34l-100 2-14-3 2-86h84l205 10q76 3 196-10l18 2q6 38 6 51 0 7-4 31-45 12-84 13-73 11-79 17-15 15-15 41 0 7 1.5 27t1.5 31q8 19 22 396 6 195-15 304-15 76-41 122-38 65-112 123-75 57-182 89-109 33-255 33-167 0-284-46-119-47-179-122-61-76-83-195-16-80-16-237v-333q0-188-17-213-25-36-147-39zm1488 1409v-64q0-14-9-23t-23-9h-1472q-14 0-23 9t-9 23v64q0 14 9 23t23 9h1472q14 0 23-9t9-23z\"\n }\n }, {\n strikethrough: {\n viewBox: \"0 0 1792 1792\",\n d: \"M1760 896q14 0 23 9t9 23v64q0 14-9 23t-23 9h-1728q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h1728zm-1277-64q-28-35-51-80-48-98-48-188 0-181 134-309 133-127 393-127 50 0 167 19 66 12 177 48 10 38 21 118 14 123 14 183 0 18-5 45l-12 3-84-6-14-2q-50-149-103-205-88-91-210-91-114 0-182 59-67 58-67 146 0 73 66 140t279 129q69 20 173 66 58 28 95 52h-743zm507 256h411q7 39 7 92 0 111-41 212-23 56-71 104-37 35-109 81-80 48-153 66-80 21-203 21-114 0-195-23l-140-40q-57-16-72-28-8-8-8-22v-13q0-108-2-156-1-30 0-68l2-37v-44l102-2q15 34 30 71t22.5 56 12.5 27q35 57 80 94 43 36 105 57 59 22 132 22 64 0 139-27 77-26 122-86 47-61 47-129 0-84-81-157-34-29-137-71z\"\n }\n }, {\n removeFormat: {\n viewBox: \"0 0 640 512\",\n d: \"M336 416h-11.17l9.26-27.77L267 336.4 240.49 416H208a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h128a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm297.82 42.1L377 259.59 426.17 112H544v32a16 16 0 0 0 16 16h32a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16H176a16 16 0 0 0-16 16v43.9L45.46 3.38A16 16 0 0 0 23 6.19L3.37 31.46a16 16 0 0 0 2.81 22.45l588.36 454.72a16 16 0 0 0 22.46-2.81l19.64-25.27a16 16 0 0 0-2.82-22.45zM309.91 207.76L224 141.36V112h117.83z\"\n }\n }]\n },\n listOptions: {\n menu: {\n viewBox: \"0 0 1792 1792\",\n d: \"M256 1312v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm1536 768v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5zm-1536-1152v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm1536 768v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5z\"\n },\n group: [{\n insertOrderedList: {\n viewBox: \"0 0 1792 1792\",\n d: \"M381 1620q0 80-54.5 126t-135.5 46q-106 0-172-66l57-88q49 45 106 45 29 0 50.5-14.5t21.5-42.5q0-64-105-56l-26-56q8-10 32.5-43.5t42.5-54 37-38.5v-1q-16 0-48.5 1t-48.5 1v53h-106v-152h333v88l-95 115q51 12 81 49t30 88zm2-627v159h-362q-6-36-6-54 0-51 23.5-93t56.5-68 66-47.5 56.5-43.5 23.5-45q0-25-14.5-38.5t-39.5-13.5q-46 0-81 58l-85-59q24-51 71.5-79.5t105.5-28.5q73 0 123 41.5t50 112.5q0 50-34 91.5t-75 64.5-75.5 50.5-35.5 52.5h127v-60h105zm1409 319v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-14 9-23t23-9h1216q13 0 22.5 9.5t9.5 22.5zm-1408-899v99h-335v-99h107q0-41 .5-121.5t.5-121.5v-12h-2q-8 17-50 54l-71-76 136-127h106v404h108zm1408 387v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-14 9-23t23-9h1216q13 0 22.5 9.5t9.5 22.5zm0-512v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5z\"\n }\n }, {\n insertUnorderedList: {\n viewBox: \"0 0 1792 1792\",\n d: \"M384 1408q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm0-512q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm1408 416v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5zm-1408-928q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm1408 416v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5zm0-512v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5\"\n }\n }]\n },\n textAlign: {\n menu: {\n viewBox: \"0 0 1792 1792\",\n d: \"M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45z\"\n },\n group: [{\n indent: {\n viewBox: \"0 0 1792 1792\",\n d: \"M352 832q0 14-9 23l-288 288q-9 9-23 9-13 0-22.5-9.5t-9.5-22.5v-576q0-13 9.5-22.5t22.5-9.5q14 0 23 9l288 288q9 9 9 23zm1440 480v192q0 13-9.5 22.5t-22.5 9.5h-1728q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1728q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1088q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1088q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1088q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1088q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1728q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1728q13 0 22.5 9.5t9.5 22.5z\"\n }\n }, {\n justifyLeft: {\n viewBox: \"0 0 1792 1792\",\n d: \"M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-1280q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1280q26 0 45 19t19 45zm256-384v128q0 26-19 45t-45 19h-1536q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1536q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-1152q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1152q26 0 45 19t19 45z\"\n }\n }, {\n justifyCenter: {\n viewBox: \"0 0 1792 1792\",\n d: \"M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-896q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h896q26 0 45 19t19 45zm256-384v128q0 26-19 45t-45 19h-1408q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1408q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-640q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h640q26 0 45 19t19 45z\"\n }\n }, {\n justifyRight: {\n viewBox: \"0 0 1792 1792\",\n d: \"M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1280q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1280q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1536q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1536q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1152q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1152q26 0 45 19t19 45z\"\n }\n }]\n },\n attachments: {\n menu: {\n viewBox: \"0 0 1792 1792\",\n d: \"M1596 1385q0 117-79 196t-196 79q-135 0-235-100l-777-776q-113-115-113-271 0-159 110-270t269-111q158 0 273 113l605 606q10 10 10 22 0 16-30.5 46.5t-46.5 30.5q-13 0-23-10l-606-607q-79-77-181-77-106 0-179 75t-73 181q0 105 76 181l776 777q63 63 145 63 64 0 106-42t42-106q0-82-63-145l-581-581q-26-24-60-24-29 0-48 19t-19 48q0 32 25 59l410 410q10 10 10 22 0 16-31 47t-47 31q-12 0-22-10l-410-410q-63-61-63-149 0-82 57-139t139-57q88 0 149 63l581 581q100 98 100 235z\"\n },\n group: [{\n attachment: {\n viewBox: \"0 0 1792 1792\",\n d: \"M1596 1385q0 117-79 196t-196 79q-135 0-235-100l-777-776q-113-115-113-271 0-159 110-270t269-111q158 0 273 113l605 606q10 10 10 22 0 16-30.5 46.5t-46.5 30.5q-13 0-23-10l-606-607q-79-77-181-77-106 0-179 75t-73 181q0 105 76 181l776 777q63 63 145 63 64 0 106-42t42-106q0-82-63-145l-581-581q-26-24-60-24-29 0-48 19t-19 48q0 32 25 59l410 410q10 10 10 22 0 16-31 47t-47 31q-12 0-22-10l-410-410q-63-61-63-149 0-82 57-139t139-57q88 0 149 63l581 581q100 98 100 235z\"\n }\n }, {\n link: {\n viewBox: \"0 0 1792 1792\",\n d: \"M1520 1216q0-40-28-68l-208-208q-28-28-68-28-42 0-72 32 3 3 19 18.5t21.5 21.5 15 19 13 25.5 3.5 27.5q0 40-28 68t-68 28q-15 0-27.5-3.5t-25.5-13-19-15-21.5-21.5-18.5-19q-33 31-33 73 0 40 28 68l206 207q27 27 68 27 40 0 68-26l147-146q28-28 28-67zm-703-705q0-40-28-68l-206-207q-28-28-68-28-39 0-68 27l-147 146q-28 28-28 67 0 40 28 68l208 208q27 27 68 27 42 0 72-31-3-3-19-18.5t-21.5-21.5-15-19-13-25.5-3.5-27.5q0-40 28-68t68-28q15 0 27.5 3.5t25.5 13 19 15 21.5 21.5 18.5 19q33-31 33-73zm895 705q0 120-85 203l-147 146q-83 83-203 83-121 0-204-85l-206-207q-83-83-83-203 0-123 88-209l-88-88q-86 88-208 88-120 0-204-84l-208-208q-84-84-84-204t85-203l147-146q83-83 203-83 121 0 204 85l206 207q83 83 83 203 0 123-88 209l88 88q86-88 208-88 120 0 204 84l208 208q84 84 84 204z\"\n }\n }, {\n image: {\n viewBox: \"0 0 2048 1792\",\n d: \"M704 576q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm1024 384v448h-1408v-192l320-320 160 160 512-512zm96-704h-1600q-13 0-22.5 9.5t-9.5 22.5v1216q0 13 9.5 22.5t22.5 9.5h1600q13 0 22.5-9.5t9.5-22.5v-1216q0-13-9.5-22.5t-22.5-9.5zm160 32v1216q0 66-47 113t-113 47h-1600q-66 0-113-47t-47-113v-1216q0-66 47-113t113-47h1600q66 0 113 47t47 113z\"\n }\n }]\n }\n };\n var DEFAULTOPTIONS = [\"bold\", \"italic\", \"underline\", \"strikethrough\", \"removeFormat\", \"insertOrderedList\", \"insertUnorderedList\", \"indent\", \"justifyLeft\", \"justifyCenter\", \"justifyRight\", \"attachment\", \"link\", \"image\"];\n var ACTIVEOPTIONCOLOR = \"#ddd\";\n\n var StrivenEditor =\n /*#__PURE__*/\n function () {\n function StrivenEditor(el, options) {\n var _this = this;\n\n _classCallCheck(this, StrivenEditor);\n\n this.establishBrowser();\n this.range = new Range();\n this.files = [];\n this.optionGroups = OPTIONGROUPS;\n\n if (options) {\n this.options = options;\n options.fontPack || (this.options.fontPack = FONTPACK);\n options.extensions || (this.options.extensions = EXTENSIONS);\n options.toolbarOptions || (this.options.toolbarOptions = DEFAULTOPTIONS);\n options.activeOptionColor || (this.options.activeOptionColor = ACTIVEOPTIONCOLOR);\n } else {\n this.options = {\n fontPack: FONTPACK,\n extensions: EXTENSIONS,\n toolbarOptions: DEFAULTOPTIONS,\n activeOptionColor: ACTIVEOPTIONCOLOR\n };\n }\n\n this.initEditor(el);\n this.initResponsive();\n this.initOverflow(); // Safari Fix\n // const documentMouseUp = document.onmouseup;\n // document.onmouseup = e => {\n // documentMouseUp && documentMouseUp();\n // this.range = this.getRange();\n // }\n\n el.StrivenEditor = function () {\n return _this;\n };\n }\n\n _createClass(StrivenEditor, [{\n key: \"initEditor\",\n value: function initEditor(el) {\n var _this2 = this;\n\n this.editor = el;\n this.toolbar = this.initToolbar();\n this.body = this.initBody();\n this.linkMenu = this.initLinkMenu();\n this.imageMenu = this.initImageMenu();\n this.metaDataSection = this.initMetaDataSection();\n this.filesSection = this.initFilesSection();\n this.editor.style.border = \"2px solid #ddd\";\n this.editor.style.display = \"flex\";\n this.editor.style.position = \"relative\";\n this.editor.style.flexDirection = \"column\";\n this.editor.style.fontFamily = \"Arial\"; // this.editor.style.minHeight = \"auto\";\n // this.editor.style.maxHeight = \"auto\";\n\n this.editor.style.maxWidth = \"100%\"; // Toolbar Hide\n\n if (this.options.toolbarHide) {\n this.customToolbarButton && (this.customToolbarButton.style.display = \"none\");\n this.toolbarOptionsGroup.style.display = \"none\";\n var bodyFocus = this.body.onfocus;\n\n this.body.onfocus = function () {\n bodyFocus && bodyFocus();\n\n _this2.overflow();\n\n _this2.toolbarSlideUp();\n };\n\n var bodyBlur = this.body.onblur;\n\n this.body.onblur = function () {\n bodyBlur && bodyBlur();\n\n _this2.overflow();\n\n setTimeout(function () {\n if (document.activeElement !== _this2.body && document.activeElement !== _this2.linkMenu.querySelector('input') && document.activeElement !== _this2.imageMenu.querySelectorAll('input')[0] && document.activeElement !== _this2.imageMenu.querySelectorAll('input')[1] && document.activeElement !== _this2.imageMenu.querySelectorAll('input')[2]) {\n _this2.toolbarSlideDown();\n }\n }, 2000);\n };\n } // Toolbar Options\n\n\n this.toolbarOptions.forEach(function (optionEl) {\n // Assign Styles\n // optionEl.style.padding = \"0 10px\";\n optionEl.style.cursor = \"pointer\";\n optionEl.style.userSelect = \"none\"; // Execute Toolbar Commands\n\n var optionElClick = optionEl.onclick;\n\n optionEl.onclick = function (e) {\n var indents = function indents() {\n var indents = _this2.body.querySelectorAll('blockquote');\n\n _toConsumableArray(indents).forEach(function (indent) {\n return indent.style.margin = \"0 0 0 40px\";\n });\n };\n\n _this2.body.focus(); // Safari Fix\n // window.getSelection().removeAllRanges();\n // window.getSelection().addRange(this.range);\n\n\n var command = optionEl.id.split(\"-\")[1];\n\n switch (command) {\n case \"insertOrderedList\":\n if (_this2.isFirefox) {\n document.execCommand(\"indent\");\n document.execCommand(command);\n indents();\n } else if (_this2.isEdge) {\n document.execCommand(command);\n\n _toConsumableArray(document.querySelectorAll('ol')).forEach(function (ol) {\n return ol.style.marginLeft = \"40px\";\n });\n } else {\n document.execCommand(\"indent\", true);\n document.execCommand(command, true);\n }\n\n break;\n\n case \"insertUnorderedList\":\n if (_this2.isFirefox) {\n document.execCommand(\"indent\");\n document.execCommand(command);\n indents();\n } else if (_this2.isEdge) {\n document.execCommand(command);\n\n _toConsumableArray(document.querySelectorAll('ul')).forEach(function (ul) {\n return ul.style.marginLeft = \"40px\";\n });\n } else {\n document.execCommand(\"indent\", true);\n document.execCommand(command, true);\n }\n\n break;\n\n case \"attachment\":\n var attachmentInput = document.createElement(\"input\");\n attachmentInput.style.display = \"none\";\n attachmentInput.type = \"file\";\n\n attachmentInput.onchange = function (e) {\n return _this2.attachFile(attachmentInput.files[0]);\n };\n\n attachmentInput.click();\n break;\n\n case \"link\":\n // const currentRange = this.getRange();\n // currentRange.setStart(this.body, currentRange.endOffset - currentRange.commonAncestorContainer.textContent.length)\n if (_this2.linkMenu.dataset.active === \"true\") {\n _this2.closeLinkMenu();\n } else {\n _this2.linkMenuSlideIn();\n\n _this2.range = _this2.getRange();\n\n _this2.linkMenu.querySelector('input').focus();\n }\n\n break;\n\n case \"image\":\n if (_this2.imageMenu.dataset.active === \"true\") {\n _this2.closeImageMenu();\n } else {\n _this2.imageMenuSlideIn();\n\n _this2.range = _this2.getRange();\n\n _this2.imageMenu.querySelector('input').focus();\n }\n\n break;\n\n default:\n if (_this2.isFirefox || _this2.isEdge) {\n document.execCommand(command);\n command === 'indent' && indents();\n } else {\n document.execCommand(command, true);\n }\n\n _this2.toolbarState();\n\n break;\n }\n\n optionElClick && optionElClick();\n };\n });\n this.editor.appendChild(this.toolbar);\n this.editor.appendChild(this.body);\n this.editor.appendChild(this.linkMenu);\n this.editor.appendChild(this.imageMenu);\n this.editor.appendChild(this.metaDataSection);\n this.editor.appendChild(this.filesSection); // Reposition Toolbar\n\n if (this.options.toolbarBottom) {\n this.editor.removeChild(this.toolbar);\n this.editor.append(this.toolbar);\n }\n }\n }, {\n key: \"imageMenuSlideIn\",\n value: function imageMenuSlideIn() {\n var that = this;\n this.openImageMenu();\n var opacity = 0;\n var right = this.editor.offsetWidth / 4;\n var id = setInterval(frame, 5);\n this.imageMenu.style.opacity = opacity;\n\n function frame() {\n if (right <= 10) {\n clearInterval(id);\n that.imageMenu.style.opacity = 1;\n } else {\n right -= 2.5;\n opacity += .01;\n that.imageMenu.style.opacity = \"\".concat(opacity);\n that.imageMenu.style.right = \"\".concat(right, \"px\");\n }\n }\n }\n }, {\n key: \"linkMenuSlideIn\",\n value: function linkMenuSlideIn() {\n var that = this;\n this.openLinkMenu();\n var opacity = 0;\n var right = this.editor.offsetWidth / 4;\n var id = setInterval(frame, 5);\n this.linkMenu.style.opacity = opacity;\n\n function frame() {\n if (right <= 10) {\n clearInterval(id);\n that.linkMenu.style.opacity = 1;\n } else {\n right -= 2.5;\n opacity += .01;\n that.linkMenu.style.opacity = \"\".concat(opacity);\n that.linkMenu.style.right = \"\".concat(right, \"px\");\n }\n }\n }\n }, {\n key: \"toolbarSlideUp\",\n value: function toolbarSlideUp() {\n var that = this;\n var height = this.toolbar.offsetHeight;\n var id = setInterval(frame, 5);\n\n function frame() {\n if (height >= 40) {\n that.customToolbarButton && (that.customToolbarButton.style.display = \"flex\");\n that.toolbarOptionsGroup.style.display = \"flex\";\n clearInterval(id);\n } else {\n height++;\n that.toolbar.style.minHeight = \"\".concat(height, \"px\");\n }\n }\n }\n }, {\n key: \"toolbarSlideDown\",\n value: function toolbarSlideDown() {\n var that = this;\n this.customToolbarButton && (this.customToolbarButton.style.display = \"none\");\n this.toolbarOptionsGroup.style.display = \"none\";\n var height = 40;\n var id = setInterval(frame, 5);\n\n function frame() {\n if (height === 0) {\n clearInterval(id);\n } else {\n height--;\n that.toolbar.style.minHeight = \"\".concat(height, \"px\");\n }\n }\n }\n }, {\n key: \"initToolbar\",\n value: function initToolbar() {\n var _this3 = this;\n\n var toolbar = document.createElement(\"div\");\n this.toolbarOptionsGroup = document.createElement(\"div\");\n var groups = Object.keys(this.optionGroups);\n toolbar.classList.add(\"toolbar\");\n toolbar.style.display = \"flex\";\n toolbar.style.justifyContent = \"space-between\";\n toolbar.style.alignItems = \"center\";\n toolbar.style.flexWrap = \"wrap\";\n toolbar.style.minHeight = this.options.toolbarHide ? \"0\" : \"40px\";\n toolbar.style.position = \"relative\";\n this.toolbarOptionsGroup.classList.add(\"toolbar-options\");\n this.toolbarOptionsGroup.style.margin = \"0 10px\";\n this.toolbarOptionsGroup.style.display = this.options.toolbarHide ? \"none\" : \"flex\"; //iterate groups\n\n groups.forEach(function (group) {\n // add menu to toolbarOptions\n var toolbarMenu = document.createElement(\"div\"); // const toolbarMenuIcon = document.createElement(\"i\");\n\n toolbarMenu.classList.add(\"toolbar-menu\");\n toolbarMenu.id = \"menu-\".concat(group); // toolbarMenuIcon.classList.add(this.options.fontPack);\n // toolbarMenuIcon.classList.add(this.optionGroups[group].menu);\n\n toolbarMenu.appendChild(_this3.constructSVG(_this3.optionGroups[group].menu));\n\n _this3.toolbarOptionsGroup.appendChild(toolbarMenu); // add group to toolbarOptions\n\n\n var toolbarGroup = document.createElement(\"div\");\n toolbarGroup.classList.add(\"toolbar-group\");\n toolbarGroup.id = \"group-\".concat(group);\n\n _this3.options.toolbarOptions.forEach(function (option) {\n var toolbarOption = _this3.optionGroups[group].group.filter(function (group) {\n return group[option];\n })[0];\n\n if (toolbarOption) {\n var svgData = toolbarOption[option];\n\n var optionSpan = _this3.constructSVG(svgData);\n\n optionSpan.id = \"toolbar-\".concat(option);\n optionSpan.style.margin = \"0 10px\";\n toolbarGroup.appendChild(optionSpan);\n }\n });\n\n _this3.toolbarOptionsGroup.appendChild(toolbarGroup); // this.optionGroups[group].group.forEach((option) => {\n // const toolbarCommand = Object.keys(option)[0];\n // if(this.options.toolbarOptions.includes(toolbarCommand)){\n // const optionSpan = this.constructSVG(option[toolbarCommand]);\n // // const optionIcon = document.createElement(\"i\");\n // optionSpan.id = `toolbar-${toolbarCommand}`;\n // optionSpan.style.margin = \"0 10px\";\n // // optionIcon.classList.add(this.options.fontPack);\n // // optionIcon.classList.add(option[toolbarCommand]);\n // // optionSpan.appendChild(optionIcon);\n // toolbarGroup.appendChild(optionSpan);\n // }\n // })\n // this.toolbarOptionsGroup.appendChild(toolbarGroup);\n\n }); // toolbar group for custom options\n\n var customOptions = this.options.toolbarOptions.filter(function (option) {\n return _typeof(option) === \"object\";\n });\n\n if (customOptions.length > 0) {\n this.customToolbarMenu = document.createElement(\"div\");\n this.customToolbarMenu.classList.add(\"toolbar-menu\");\n this.customToolbarMenu.id = \"menu-custom\";\n var customSVGViewBox = \"0 0 1792 1792\";\n var customSVGD = \"M1088 1248v192q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h192q40 0 68 28t28 68zm0-512v192q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h192q40 0 68 28t28 68zm0-512v192q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h192q40 0 68 28t28 68z\";\n this.customToolbarMenu.appendChild(this.constructSVG({\n viewBox: customSVGViewBox,\n d: customSVGD\n }));\n this.toolbarOptionsGroup.appendChild(this.customToolbarMenu);\n this.customToolbarGroup = document.createElement(\"div\");\n this.customToolbarGroup.classList.add(\"toolbar-group\");\n this.customToolbarGroup.id = \"group-custom\";\n customOptions.forEach(function (customOption) {\n var icon = customOption.icon,\n handler = customOption.handler;\n\n var optionSpan = _this3.constructSVG(icon);\n\n optionSpan.id = \"toolbar-customOption\";\n optionSpan.style.margin = \"0 10px\";\n\n optionSpan.onclick = function () {\n return handler();\n };\n\n _this3.customToolbarGroup.appendChild(optionSpan);\n });\n this.toolbarOptionsGroup.appendChild(this.customToolbarGroup);\n }\n\n toolbar.appendChild(this.toolbarOptionsGroup); //add toolbar-send\n\n if (this.options.customToolbarButton) {\n var customToolbarButton = document.createElement(\"div\");\n customToolbarButton.id = \"custom-toolbar-button\";\n customToolbarButton.style.display = \"none\";\n customToolbarButton.style.color = \"#fff\";\n customToolbarButton.style.backgroundColor = \"#5cb85c\";\n customToolbarButton.style.minHeight = this.options.toolbarHide ? \"40px\" : this.toolbar.style.minHeight;\n customToolbarButton.style.width = \"50px\";\n customToolbarButton.style.textAlign = \"center\";\n customToolbarButton.style.justifyContent = \"center\";\n customToolbarButton.style.alignContent = \"center\";\n customToolbarButton.style.alignItems = \"center\";\n customToolbarButton.style.cursor = \"pointer\";\n customToolbarButton.style.border = \"1px solid #4cae4c\";\n customToolbarButton.style.alignSelf = \"flex-end\";\n\n customToolbarButton.onclick = function () {\n return _this3.options.customToolbarButton.handler();\n };\n\n !this.options.toolbarHide && (customToolbarButton.style.display = \"flex\");\n\n customToolbarButton.onmouseenter = function () {\n customToolbarButton.style.borderColor = _this3.options.customToolbarButton.hoverBorderColor;\n customToolbarButton.style.backgroundColor = _this3.options.customToolbarButton.hoverBackgroundColor;\n customToolbarButton.style.color = _this3.options.customToolbarButton.hoverColor;\n };\n\n customToolbarButton.onmouseleave = function () {\n customToolbarButton.style.borderColor = _this3.options.customToolbarButton.borderColor;\n customToolbarButton.style.backgroundColor = _this3.options.customToolbarButton.backgroundColor;\n customToolbarButton.style.color = _this3.options.customToolbarButton.color;\n };\n\n var customToolbarButtonSVG = this.constructSVG(this.options.customToolbarButton.svgData);\n customToolbarButtonSVG.querySelector('path').setAttribute(\"fill\", this.options.customToolbarButton.color);\n customToolbarButton.appendChild(customToolbarButtonSVG);\n toolbar.appendChild(customToolbarButton);\n }\n\n this.toolbarOptions = toolbar.querySelectorAll(\"span\");\n this.toolbarGroups = _toConsumableArray(toolbar.getElementsByClassName(\"toolbar-group\"));\n this.toolbarMenus = _toConsumableArray(toolbar.getElementsByClassName(\"toolbar-menu\"));\n this.customToolbarButton = toolbar.querySelector(\"#custom-toolbar-button\");\n this.toolbarMenus.push(this.customToolbarMenu);\n this.toolbarGroups.push(this.customToolbarGroup); // Remove menu that has no options enabled\n\n this.toolbarGroups.forEach(function (group) {\n if (group && group.children.length < 1) {\n var groupName = group.id.split(\"-\")[1];\n\n var menu = _this3.toolbarMenus.filter(function (menu) {\n return menu.id.split(\"-\")[1] === groupName;\n })[0];\n\n menu.remove();\n }\n });\n return toolbar;\n }\n }, {\n key: \"initBody\",\n value: function initBody() {\n var _this4 = this;\n\n var body = document.createElement(\"div\");\n body.classList.add(\"body\");\n body.contentEditable = \"true\";\n body.style.outline = \"none\";\n body.style.padding = \"10px 20px\";\n body.style.height = this.editor.style.height;\n body.style.minHeight = this.editor.style.minHeight;\n body.style.maxHeight = this.editor.style.maxHeight;\n this.editor.style.height = \"auto\";\n this.editor.style.minHeight = \"auto\";\n this.editor.style.maxHeight = \"auto\"; // Placeholder logic\n\n if (this.options.placeholder) {\n var placeholderNode = document.createElement(\"p\");\n placeholderNode.id = \"placeholder-node\";\n placeholderNode.style.color = \"#5f6368\";\n placeholderNode.style.margin = \"0\";\n placeholderNode.textContent = this.options.placeholder;\n body.append(placeholderNode);\n var bodyFocus = body.onfocus;\n\n body.onfocus = function () {\n bodyFocus && bodyFocus();\n body.querySelector(\"#placeholder-node\") === placeholderNode && _this4.clearContent();\n };\n\n var bodyBlur = body.onblur;\n\n body.onblur = function () {\n bodyBlur && bodyBlur();\n _this4.getContent().trim() === \"\" && body.append(placeholderNode);\n };\n } // Paste Handler\n\n\n body.onpaste = function (e) {\n function dataURLtoFile(dataurl, filename) {\n var arr = dataurl.split(','),\n mime = arr[0].match(/:(.*?);/)[1],\n bstr = atob(arr[1]),\n n = bstr.length,\n u8arr = new Uint8Array(n);\n\n while (n--) {\n u8arr[n] = bstr.charCodeAt(n);\n }\n\n var file = new File([u8arr], filename, {\n type: mime\n });\n return new File([u8arr], \"\".concat(file.name, \".\").concat(file.type.split('/').pop()), {\n type: file.type\n });\n }\n\n var convertImage = function convertImage(file) {\n return new Promise(function (resolve, reject) {\n var reader = new FileReader();\n reader.readAsDataURL(file);\n\n reader.onload = function () {\n return resolve(reader.result);\n };\n\n reader.onerror = function (error) {\n return reject(error);\n };\n });\n };\n\n if (e.clipboardData.files.length > 0 && e.clipboardData.files[0].type.includes(\"image\")) {\n convertImage(e.clipboardData.files[0]).then(function (res) {\n if (_this4.options.imageUrl) {\n _this4.getImage(res).then(function (data) {\n document.execCommand(\"insertImage\", true, data.imageRef);\n })[\"catch\"](function (err) {\n document.execCommand(\"insertImage\", true, res);\n });\n } else {\n document.execCommand(\"insertImage\", true, res);\n _this4.options.uploadOnPaste && _this4.attachFile(dataURLtoFile(res, \"pastedimage\"));\n }\n\n _this4.overflow();\n });\n } // sanitize of html\n\n\n if (_this4.options.sanitizePaste && e.clipboardData.types.includes(\"text/html\")) {\n e.preventDefault();\n var pastedHtmlItem;\n\n for (var i = 0; i < e.clipboardData.items.length; i++) {\n var item = e.clipboardData.items[i];\n item.type === \"text/html\" && (pastedHtmlItem = item);\n }\n\n if (pastedHtmlItem) {\n pastedHtmlItem.getAsString(function (htmlString) {\n var range = _this4.getRange();\n\n range.insertNode(_this4.scrubHTML(htmlString));\n range.collapse();\n });\n }\n } // meta extraction on paste\n\n\n if (e.clipboardData.items.length > 0 && e.clipboardData.items[0].type === \"text/plain\") {\n e.clipboardData.items[0].getAsString(function (string) {\n if (_this4.options.metaUrl && _this4.validURL(string)) {\n _this4.getMeta(string).then(function (res) {\n var url = res.url,\n title = res.title,\n image = res.image,\n description = res.description;\n url && title && image && _this4.createMetaDataElement(url, image, title, description);\n });\n }\n });\n }\n\n _this4.overflow();\n }; // State of the editor\n\n\n var bodyKeyup = body.onkeyup;\n\n body.onkeyup = function (e) {\n bodyKeyup && bodyKeyup();\n _this4.range = _this4.getRange();\n\n if (_this4.options.submitOnEnter && e.keyCode === 13 && !e.shiftKey) {\n if (!document.queryCommandState('insertOrderedList') && !document.queryCommandState('insertUnorderedList')) {\n var hasText = !!_this4.getTextContent();\n var hasImage = !!body.querySelector('img'); // remove break from enter\n\n if (hasText || hasImage) {\n var breaks = body.querySelectorAll('div');\n var divBreak = breaks[breaks.length ? breaks.length - 1 : 0];\n divBreak && divBreak.remove();\n }\n\n var content = _this4.getContent();\n\n var files = _this4.getFiles();\n\n _this4.clearContent();\n\n _this4.clearFiles();\n\n if (files.length || hasText || hasImage) {\n _this4.options.submitOnEnter({\n content: (hasText || hasImage) && content,\n files: files\n });\n }\n }\n }\n\n _this4.toolbarState();\n };\n\n return body;\n }\n }, {\n key: \"initLinkMenu\",\n value: function initLinkMenu() {\n var _this5 = this;\n\n var linkMenu = document.createElement(\"div\");\n var linkMenuForm = document.createElement(\"div\");\n var linkMenuButton = document.createElement(\"button\");\n var linkMenuFormLabel = document.createElement(\"p\");\n var linkMenuFormInput = document.createElement(\"input\");\n linkMenu.id = \"link-menu\";\n linkMenuButton.textContent = \"Insert Link\";\n linkMenuFormLabel.textContent = \"Web Address\";\n linkMenuFormInput.type = \"text\";\n linkMenuFormLabel.style.margin = \"8px 10px 8px 0\";\n linkMenuFormLabel.style.fontSize = \"14px\";\n linkMenuButton.style.cursor = \"pointer\";\n linkMenu.dataset.active = \"false\";\n linkMenu.style.display = \"none\";\n linkMenu.style.position = \"absolute\";\n linkMenu.style.right = \"10px\";\n linkMenu.style.bottom = \"10px\";\n linkMenu.style.backgroundColor = \"#fff\";\n linkMenu.style.border = \"2px solid #ddd\";\n linkMenu.style.padding = \"10px 20px\";\n linkMenu.style.zIndex = \"1000\";\n linkMenuFormLabel.style.width = \"100%\";\n linkMenuFormLabel.style.textAlign = \"right\";\n linkMenuFormLabel.style.marginRight = \"10px\";\n linkMenuFormInput.style.outline = \"none\";\n linkMenuFormInput.style.padding = \"0 5px\";\n linkMenuFormInput.placeholder = \"Insert a Link\";\n linkMenuForm.style.display = \"flex\";\n linkMenuForm.style.justifyContent = \"space-between\";\n linkMenuForm.style.margin = \"5px 0\";\n linkMenuButton.style[\"float\"] = \"right\";\n linkMenuButton.style.padding = \"6px 12px\";\n linkMenuButton.style.border = \"1px solid #4cae4c\";\n linkMenuButton.style.backgroundColor = \"#5cb85c\";\n linkMenuButton.style.fontSize = \"14px\";\n linkMenuButton.style.color = \"#fff\";\n linkMenuButton.style.outline = \"none\";\n\n linkMenuButton.onmouseenter = function () {\n return linkMenuButton.style.backgroundColor = \"#4cae4c\";\n };\n\n linkMenuButton.onmouseleave = function () {\n return linkMenuButton.style.backgroundColor = \"#5cb85c\";\n };\n\n linkMenuButton.onclick = function (e) {\n var linkValue = linkMenuFormInput.value;\n\n if (linkValue) {\n window.getSelection().removeAllRanges();\n window.getSelection().addRange(_this5.range);\n\n if (_this5.isFirefox || _this5.isEdge) {\n document.execCommand(\"createLink\", false, linkValue);\n } else {\n document.execCommand(\"createLink\", true, linkValue);\n }\n\n if (_this5.options.metaUrl && _this5.validURL(linkValue)) {\n _this5.getMeta(linkValue).then(function (res) {\n var url = res.url,\n image = res.image,\n title = res.title,\n description = res.description;\n url && image && title && _this5.createMetaDataElement(url, image, title, description);\n });\n }\n\n var bodyLinks = _this5.body.querySelectorAll(\"a\");\n\n _toConsumableArray(bodyLinks).forEach(function (link) {\n return !_this5.isFirefox && (link.contentEditable = 'false');\n });\n\n linkMenuFormInput.value = \"\";\n\n _this5.closeLinkMenu();\n } else {\n _this5.body.focus();\n\n _this5.closeLinkMenu();\n }\n };\n\n linkMenuForm.appendChild(linkMenuFormLabel);\n linkMenuForm.appendChild(linkMenuFormInput);\n linkMenu.appendChild(linkMenuForm);\n linkMenu.appendChild(linkMenuButton);\n return linkMenu;\n }\n }, {\n key: \"initImageMenu\",\n value: function initImageMenu() {\n var _this6 = this;\n\n var imageMenu = document.createElement(\"div\");\n var imageMenuForm = document.createElement(\"div\");\n var imageMenuButton = document.createElement(\"button\");\n var imageMenuFormLabel = document.createElement(\"p\");\n var imageMenuFormSourceInput = document.createElement(\"input\");\n imageMenu.id = \"image-menu\";\n imageMenuButton.textContent = \"Insert Image\";\n imageMenuFormLabel.textContent = \"Image URL\";\n imageMenuFormSourceInput.type = \"text\";\n imageMenuFormLabel.style.margin = \"8px 10px 8px 0\";\n imageMenuFormLabel.style.fontSize = \"14px\";\n imageMenuButton.style.cursor = \"pointer\";\n imageMenu.dataset.active = \"false\";\n imageMenu.style.display = \"none\";\n imageMenu.style.position = \"absolute\";\n imageMenu.style.right = \"10px\";\n imageMenu.style.bottom = \"10px\";\n imageMenu.style.backgroundColor = \"#fff\";\n imageMenu.style.border = \"2px solid #ddd\";\n imageMenu.style.padding = \"10px 20px\";\n imageMenu.style.zIndex = \"1000\";\n imageMenuFormLabel.style.width = \"100%\";\n imageMenuFormLabel.style.textAlign = \"right\";\n imageMenuFormLabel.style.marginRight = \"10px\";\n imageMenuFormSourceInput.style.outline = \"none\";\n imageMenuFormSourceInput.style.padding = \"0 5px\";\n imageMenuFormSourceInput.placeholder = \"Insert a Link\";\n imageMenuForm.style.display = \"flex\";\n imageMenuForm.style.justifyContent = \"space-between\";\n imageMenuForm.style.margin = \"5px 0\";\n imageMenuButton.style[\"float\"] = \"right\";\n imageMenuButton.style.padding = \"6px 12px\";\n imageMenuButton.style.border = \"1px solid #4cae4c\";\n imageMenuButton.style.backgroundColor = \"#5cb85c\";\n imageMenuButton.style.fontSize = \"14px\";\n imageMenuButton.style.color = \"#fff\";\n imageMenuButton.style.outline = \"none\";\n\n imageMenuButton.onmouseenter = function () {\n return imageMenuButton.style.backgroundColor = \"#4cae4c\";\n };\n\n imageMenuButton.onmouseleave = function () {\n return imageMenuButton.style.backgroundColor = \"#5cb85c\";\n };\n\n imageMenuForm.appendChild(imageMenuFormLabel);\n imageMenuForm.appendChild(imageMenuFormSourceInput); // Height Input Form\n\n var imageMenuHeightForm = imageMenuForm.cloneNode(true);\n var imageMenuHeightFormInput = imageMenuHeightForm.querySelector('input');\n var imageMenuHeightFormLabel = imageMenuHeightForm.querySelector('p');\n imageMenuHeightFormInput.placeholder = \"Image Height\";\n imageMenuHeightFormLabel.textContent = \"Height\"; // Width Input Form\n\n var imageMenuWidthForm = imageMenuForm.cloneNode(true);\n var imageMenuWidthFormInput = imageMenuWidthForm.querySelector('input');\n var imageMenuWidthFormLabel = imageMenuWidthForm.querySelector('p');\n imageMenuWidthFormInput.placeholder = \"Image Width\";\n imageMenuWidthFormLabel.textContent = \"Width\";\n\n imageMenuButton.onclick = function (e) {\n var linkValue = imageMenuFormSourceInput.value;\n var heightValue = imageMenuHeightFormInput.value;\n var widthValue = imageMenuWidthFormInput.value;\n\n if (linkValue) {\n window.getSelection().removeAllRanges();\n window.getSelection().addRange(_this6.range);\n\n if (_this6.isFirefox || _this6.isEdge) {\n document.execCommand(\"insertImage\", false, linkValue);\n } else {\n document.execCommand(\"insertImage\", true, linkValue);\n }\n\n var insertedImage = _toConsumableArray(_this6.body.querySelectorAll(\"img\")).filter(function (img) {\n return img.src === linkValue;\n });\n\n insertedImage = insertedImage[insertedImage.length - 1];\n insertedImage && (insertedImage.style.height = \"\".concat(heightValue, \"px\"));\n insertedImage && (insertedImage.style.width = \"\".concat(widthValue, \"px\"));\n imageMenuHeightFormInput.value = \"\";\n imageMenuWidthFormInput.value = \"\";\n imageMenuFormSourceInput.value = \"\";\n\n _this6.closeImageMenu();\n } else {\n _this6.body.focus();\n\n _this6.closeImageMenu();\n }\n };\n\n imageMenu.appendChild(imageMenuHeightForm);\n imageMenu.appendChild(imageMenuWidthForm);\n imageMenu.appendChild(imageMenuForm);\n imageMenu.appendChild(imageMenuButton);\n return imageMenu;\n }\n }, {\n key: \"initMetaDataSection\",\n value: function initMetaDataSection() {\n var metaDataSection = document.createElement(\"div\");\n metaDataSection.classList.add(\"metadata-section\");\n metaDataSection.style.display = \"flex\";\n metaDataSection.style.flexWrap = \"wrap\";\n metaDataSection.style.zIndex = \"500\";\n return metaDataSection;\n }\n }, {\n key: \"initFilesSection\",\n value: function initFilesSection() {\n var _this7 = this;\n\n var filesSection = document.createElement(\"div\");\n filesSection.classList.add(\"files-section\");\n filesSection.style.display = \"flex\";\n filesSection.style.flexWrap = \"wrap\";\n filesSection.style.zIndex = \"500\";\n\n this.body.ondragenter = function (e) {\n _this7.body.style.backgroundColor = \"#ddd\";\n };\n\n this.body.ondragleave = function (e) {\n _this7.body.style.backgroundColor = \"inherit\";\n };\n\n this.body.ondrop = function (e) {\n _this7.body.style.backgroundColor = \"inherit\";\n e.preventDefault();\n var file = e.dataTransfer.files && e.dataTransfer.files[0];\n\n _this7.attachFile(file);\n };\n\n return filesSection;\n }\n }, {\n key: \"createFileElement\",\n value: function createFileElement(name, size) {\n var _this8 = this;\n\n var fileEl = document.createElement(\"div\");\n var fileNameEl = document.createElement(\"h4\");\n var fileSizeEl = document.createElement(\"p\");\n var removeFileEl = document.createElement(\"p\");\n fileNameEl.textContent = name;\n fileSizeEl.textContent = size;\n removeFileEl.textContent = \"X\";\n fileEl.dataset.fileindex = this.files.length - 1;\n fileEl.style.width = \"100%\";\n fileEl.style.display = \"flex\";\n fileEl.style.flexDirection = \"column\";\n fileEl.style.margin = \"10px\";\n fileEl.style.position = \"relative\";\n fileNameEl.style.fontWeight = \"bold\";\n fileNameEl.style.margin = \"0\";\n fileSizeEl.style.fontSize = \"12px\";\n fileSizeEl.style.margin = \"2px 0\";\n removeFileEl.style.margin = \"0\";\n removeFileEl.style.userSelect = \"none\";\n removeFileEl.style.color = \"black\";\n removeFileEl.style.position = \"absolute\";\n removeFileEl.style.right = \"5px\";\n removeFileEl.style.top = \"-5px\";\n removeFileEl.style.cursor = \"pointer\";\n removeFileEl.style.backgroundColor = \"#fff\";\n\n removeFileEl.onmouseenter = function () {\n return removeFileEl.style.color = \"#ddd\";\n };\n\n removeFileEl.onmouseleave = function () {\n return removeFileEl.style.color = \"black\";\n };\n\n removeFileEl.onclick = function (e) {\n _this8.files.splice(e.target.parentElement.dataset.fileindex, 1);\n\n e.target.parentElement.remove();\n };\n\n fileEl.appendChild(fileNameEl);\n fileEl.appendChild(fileSizeEl);\n fileEl.appendChild(removeFileEl);\n this.filesSection.appendChild(fileEl);\n }\n }, {\n key: \"createMetaDataElement\",\n value: function createMetaDataElement(url, img, title, description) {\n var metaItemEl = document.createElement(\"div\");\n var metaLinkEl = document.createElement(\"a\");\n var metaImageEl = document.createElement(\"img\");\n var metaDataEl = document.createElement(\"div\");\n var metaDataTitleEl = document.createElement(\"h4\");\n var metaDataDescriptionEl = document.createElement(\"p\");\n var removeMetaDataEl = document.createElement(\"span\");\n metaLinkEl.href = url;\n metaImageEl.src = img;\n metaDataTitleEl.textContent = title;\n metaDataDescriptionEl.textContent = description;\n removeMetaDataEl.textContent = \"X\";\n metaLinkEl.target = \"blank\";\n metaItemEl.style.width = \"100%\";\n metaItemEl.style.display = \"flex\";\n metaItemEl.style.margin = \"10px\";\n metaItemEl.style.position = \"relative\";\n metaImageEl.style.marginRight = \"10px\";\n metaImageEl.style.height = \"50px\";\n metaImageEl.style.width = \"75px\";\n metaDataTitleEl.style.fontWeight = \"bold\";\n metaDataTitleEl.style.margin = \"0\";\n metaDataDescriptionEl.style.margin = \"0\";\n removeMetaDataEl.style.userSelect = \"none\";\n removeMetaDataEl.style.color = \"black\";\n removeMetaDataEl.style.position = \"absolute\";\n removeMetaDataEl.style.right = \"5px\";\n removeMetaDataEl.style.top = \"-5px\";\n removeMetaDataEl.style.cursor = \"pointer\";\n removeMetaDataEl.style.backgroundColor = \"#fff\";\n\n removeMetaDataEl.onmouseenter = function () {\n return removeMetaDataEl.style.color = \"#ddd\";\n };\n\n removeMetaDataEl.onmouseleave = function () {\n return removeMetaDataEl.style.color = \"black\";\n };\n\n removeMetaDataEl.onclick = function (e) {\n return e.target.parentElement.remove();\n };\n\n metaLinkEl.appendChild(metaImageEl);\n metaDataEl.appendChild(metaDataTitleEl);\n metaDataEl.appendChild(metaDataDescriptionEl);\n metaItemEl.appendChild(metaLinkEl);\n metaItemEl.appendChild(metaDataEl);\n metaItemEl.appendChild(removeMetaDataEl);\n this.metaDataSection.appendChild(metaItemEl);\n }\n }, {\n key: \"constructSVG\",\n value: function constructSVG(svgData) {\n var viewBox = svgData.viewBox,\n d = svgData.d;\n var fillColor = this.options.toolbarOptionFillColor ? this.options.toolbarOptionFillColor : \"#333\";\n var xmlns = \"http://www.w3.org/2000/svg\";\n var height = \"16\";\n var width = \"16\";\n var icon = document.createElement('span');\n var svg = \"<svg width=\\\"\".concat(width, \"\\\" height=\\\"\").concat(height, \"\\\" viewBox=\\\"\").concat(viewBox, \"\\\" xmlns=\\\"\").concat(xmlns, \"\\\">\");\n var path = \"<path fill=\\\"\".concat(fillColor, \"\\\" d=\\\"\").concat(d, \"\\\"/>\");\n icon.innerHTML = \"\".concat(svg).concat(path, \"</svg>\");\n return icon;\n }\n }, {\n key: \"initResponsive\",\n value: function initResponsive() {\n var _this9 = this;\n\n var that = this;\n\n if (!this.options.minimal) {\n var responsiveGroups = function responsiveGroups(isResponsive) {\n that.toolbarGroups.forEach(function (group) {\n if (group) {\n group.dataset.open = \"false\";\n group.style.display = isResponsive ? \"none\" : \"block\";\n group.style.position = isResponsive ? \"absolute\" : \"relative\";\n group.style.bottom = isResponsive ? \"5px\" : \"inherit\";\n group.style.right = isResponsive ? \"5px\" : \"inherit\";\n group.style.backgroundColor = isResponsive ? \"#fff\" : \"inherit\";\n group.style.border = isResponsive ? \"2px solid #ddd\" : \"none\";\n }\n });\n that.toolbarMenus.forEach(function (menu) {\n function toggleMenu() {\n var selectedGroup = that.toolbar.querySelector(\"#group-\".concat(menu.id.split(\"-\")[1]));\n\n if (selectedGroup.dataset.open === \"false\") {\n // close opened groups\n that.toolbarGroups.forEach(function (group) {\n if (group && group.dataset.open === \"true\") {\n group.style.display = \"none\";\n group.dataset.open = \"false\";\n }\n }); // open group\n\n selectedGroup.style.display = \"block\";\n selectedGroup.style.padding = \"5px 5px 0 5px\";\n selectedGroup.dataset.open = \"true\";\n } else {\n selectedGroup.style.display = \"none\";\n selectedGroup.dataset.open = \"false\";\n }\n }\n\n if (menu) {\n menu.style.padding = \"0 10px\";\n menu.style.cursor = \"pointer\";\n menu.style.userSelect = \"none\";\n menu.style.display = isResponsive ? \"block\" : \"none\";\n\n menu.onclick = function (e) {\n toggleMenu();\n that.body.focus();\n };\n }\n });\n };\n\n var setResponsive = function setResponsive() {\n responsive = window.matchMedia(\"(max-width: 700px)\").matches;\n responsiveGroups(responsive);\n };\n\n var responsive = window.matchMedia(\"(max-width: 700px)\").matches;\n setResponsive();\n\n window.onresize = function () {\n _this9.toolbarGroups.forEach(function (group) {\n return group && (group.style.padding = \"0\");\n });\n\n _this9.closeLinkMenu();\n\n _this9.closeImageMenu();\n\n setResponsive();\n };\n } else {\n this.toolbarMenus.forEach(function (menu) {\n return menu && (menu.style.display = \"none\");\n });\n this.toolbar.querySelector(\"#toolbar-strikethrough\").style.display = \"none\";\n this.toolbar.querySelector(\"#toolbar-image\").style.display = \"none\";\n this.toolbar.querySelector(\"#toolbar-insertOrderedList\").style.display = \"none\";\n this.toolbar.querySelector(\"#group-textAlign\").style.display = \"none\";\n }\n }\n }, {\n key: \"initOverflow\",\n value: function initOverflow() {\n var _this10 = this;\n\n var onFocus = this.body.onfocus;\n\n this.body.onfocus = function () {\n onFocus && onFocus();\n\n _this10.overflow();\n };\n\n var onBlur = this.body.onblur;\n\n this.body.onblur = function () {\n onBlur && onBlur();\n\n _this10.overflow();\n };\n\n var bodyKeypress = this.body.onkeypress;\n\n this.body.onkeypress = function () {\n bodyKeypress && bodyKeypress();\n\n _this10.overflow();\n };\n }\n }, {\n key: \"getFiles\",\n value: function getFiles() {\n return this.files;\n }\n }, {\n key: \"getContent\",\n value: function getContent() {\n if (this.body.querySelector(\"#placeholder-node\")) {\n return \"\";\n } else {\n return this.body.innerHTML;\n }\n }\n }, {\n key: \"getRange\",\n value: function getRange() {\n return window.getSelection().getRangeAt(0);\n }\n }, {\n key: \"getMeta\",\n value: function getMeta(url) {\n return fetch(this.options.metaUrl, {\n method: \"POST\",\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n targetUrl: url\n })\n }).then(function (res) {\n return res.json();\n });\n }\n }, {\n key: \"getImage\",\n value: function getImage(imageEncoding) {\n return fetch(this.options.imageUrl, {\n method: \"POST\",\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n imageEncoding: imageEncoding\n })\n }).then(function (res) {\n return res.json();\n });\n }\n }, {\n key: \"validURL\",\n value: function validURL(str) {\n var pattern = new RegExp(\"^(https?:\\\\/\\\\/)?\" + \"((([a-z\\\\d]([a-z\\\\d-]*[a-z\\\\d])*)\\\\.)+[a-z]{2,}|\" + \"((\\\\d{1,3}\\\\.){3}\\\\d{1,3}))\" + \"(\\\\:\\\\d+)?(\\\\/[-a-z\\\\d%_.~+]*)*\" + \"(\\\\?[;&a-z\\\\d%_.~+=-]*)?\" + \"(\\\\#[-a-z\\\\d_]*)?$\", \"i\");\n return !!pattern.test(str);\n }\n }, {\n key: \"overflow\",\n value: function overflow() {\n var body = this.body;\n body.scrollHeight > body.clientHeight ? body.style.overflowY = \"scroll\" : body.style.overflowY = \"hidden\";\n body.scrollWidth > body.clientWidth ? body.style.overflowX = \"scroll\" : body.style.overflowX = \"hidden\";\n }\n }, {\n key: \"formatBytes\",\n value: function formatBytes(bytes) {\n var decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;\n if (bytes === 0) return '0 Bytes';\n var k = 1024;\n var dm = decimals < 0 ? 0 : decimals;\n var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n var i = Math.floor(Math.log(bytes) / Math.log(k));\n return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];\n }\n }, {\n key: \"validateFile\",\n value: function validateFile(file) {\n var extension = file.type.split('/').pop();\n return this.options.extensions.includes(\".\".concat(extension));\n }\n }, {\n key: \"attachFile\",\n value: function attachFile(file) {\n if (this.validateFile(file)) {\n this.files.push(file);\n this.createFileElement(file.name, this.formatBytes(file.size));\n } else {\n this.fileInvalid();\n }\n }\n }, {\n key: \"fileInvalid\",\n value: function fileInvalid() {\n var _this11 = this;\n\n this.body.style.transition = \"background-color .5s\";\n this.body.style.backgroundColor = \"#d9534f\";\n setTimeout(function () {\n _this11.body.style.backgroundColor = \"inherit\";\n setTimeout(function () {\n return _this11.body.style.transition = \"none\";\n }, 500);\n }, 500);\n }\n }, {\n key: \"openLinkMenu\",\n value: function openLinkMenu() {\n this.closeImageMenu();\n this.linkMenu.dataset.active = \"true\";\n this.linkMenu.style.display = \"block\";\n }\n }, {\n key: \"openImageMenu\",\n value: function openImageMenu() {\n this.closeLinkMenu();\n this.imageMenu.dataset.active = \"true\";\n this.imageMenu.style.display = \"block\";\n }\n }, {\n key: \"closeLinkMenu\",\n value: function closeLinkMenu() {\n this.linkMenu.dataset.active = \"false\";\n this.linkMenu.style.display = \"none\";\n }\n }, {\n key: \"closeImageMenu\",\n value: function closeImageMenu() {\n this.imageMenu.dataset.active = \"false\";\n this.imageMenu.style.display = \"none\";\n }\n }, {\n key: \"setContent\",\n value: function setContent(html) {\n this.clearContent();\n this.body.innerHTML = html;\n }\n }, {\n key: \"clearContent\",\n value: function clearContent() {\n this.body.innerHTML = \"\";\n }\n }, {\n key: \"clearFiles\",\n value: function clearFiles() {\n this.files = [];\n this.filesSection.innerHTML = '';\n }\n }, {\n key: \"getTextContent\",\n value: function getTextContent() {\n if (this.body.querySelector(\"#placeholder-node\")) {\n return \"\";\n } else {\n return this.body.textContent;\n }\n }\n }, {\n key: \"scrubHTML\",\n value: function scrubHTML(html) {\n var dirtyNode = document.createElement(\"div\");\n var cleanNode = document.createElement(\"div\");\n dirtyNode.innerHTML = html;\n cleanNode.append(document.createTextNode(dirtyNode.textContent));\n return cleanNode;\n }\n }, {\n key: \"toolbarState\",\n value: function toolbarState() {\n var _this12 = this;\n\n this.options.toolbarOptions.forEach(function (option) {\n var toolbarOption = _this12.toolbar.querySelector(\"#toolbar-\".concat(option));\n\n if (!option.includes('justify') && !option.includes('list')) {\n if (document.queryCommandState(option)) {\n toolbarOption.querySelector('path').setAttribute('fill', _this12.options.activeOptionColor);\n } else {\n toolbarOption.querySelector('path').setAttribute('fill', '#333');\n }\n }\n });\n }\n }, {\n key: \"establishBrowser\",\n value: function establishBrowser() {\n // Change this to user agent\n // Opera 8.0+\n this.isOpera = !!window.opr && !!opr.addons || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0; // Firefox 1.0+\n\n this.isFirefox = typeof InstallTrigger !== 'undefined'; // Safari 3.0+ \"[object HTMLElementConstructor]\" \n\n this.isSafari = /constructor/i.test(window.HTMLElement) || function (p) {\n return p.toString() === \"[object SafariRemoteNotification]\";\n }(!window['safari'] || typeof safari !== 'undefined' && safari.pushNotification); // Internet Explorer 6-11\n\n\n this.isIE =\n /*@cc_on!@*/\n false || !!document.documentMode; // Edge 20+\n\n this.isEdge = !this.isIE && !!window.StyleMedia; // Chrome 1 - 71\n\n this.isChrome = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime); // Blink engine detection\n\n this.isBlink = (this.isChrome || this.isOpera) && !!window.CSS;\n }\n }]);\n\n return StrivenEditor;\n }();\n\n _exports[\"default\"] = StrivenEditor;\n});\n\n//# sourceURL=webpack://striveneditor/./src/striveneditor.js?"); +var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { + if (true) { + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports, __webpack_require__(8), __webpack_require__(0), __webpack_require__(5), __webpack_require__(6)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), + __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? + (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else { var mod; } +})(this, function (_exports, _striveneditor, _striveneditor2, _koStriveneditor, _vueStriveneditor) { + "use strict"; -/***/ }) + Object.defineProperty(_exports, "__esModule", { + value: true + }); + Object.defineProperty(_exports, "StrivenEditor", { + enumerable: true, + get: function get() { + return _striveneditor2["default"]; + } + }); + Object.defineProperty(_exports, "KoStrivenEditor", { + enumerable: true, + get: function get() { + return _koStriveneditor["default"]; + } + }); + Object.defineProperty(_exports, "VueStrivenEditor", { + enumerable: true, + get: function get() { + return _vueStriveneditor["default"]; + } + }); + _striveneditor2 = _interopRequireDefault(_striveneditor2); + _koStriveneditor = _interopRequireDefault(_koStriveneditor); + _vueStriveneditor = _interopRequireDefault(_vueStriveneditor); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } +}); + +/***/ }), +/* 8 */ +/***/ (function(module, exports, __webpack_require__) { + +var content = __webpack_require__(9); + +if (typeof content === 'string') { + content = [[module.i, content, '']]; +} + +var options = {} + +options.insert = "head"; +options.singleton = false; + +var update = __webpack_require__(11)(content, options); + +if (content.locals) { + module.exports = content.locals; +} + + +/***/ }), +/* 9 */ +/***/ (function(module, exports, __webpack_require__) { + +exports = module.exports = __webpack_require__(10)(false); +// Module +exports.push([module.i, "/**\r\n** - Editor\r\n** - Toolbar\r\n** - Image Menu\r\n** - File element\r\n** - Meta Item\r\n** - Link Menu\r\n*/\r\n\r\n/** Editor **/\r\n\r\n.Striven-Editor.editor {\r\n\tborder: 2px solid #ddd;\r\n\tdisplay: flex;\r\n\tposition: relative;\r\n\tflex-direction: column;\r\n\tfont-family: Arial;\r\n\tmax-width: 100%;\r\n}\r\n\r\n.Striven-Editor .body {\r\n\toutline: none;\r\n\tpadding: 10px 20px;\r\n\tmin-height: auto;\r\n\tmax-height: auto;\r\n\theight: auto;\r\n}\r\n\r\n\r\n/** Toolbar **/\r\n\r\n.Striven-Editor .toolbar {\r\n\tdisplay: flex;\r\n\tjustify-content: space-between;\r\n\talign-items: center;\r\n\tflex-wrap: wrap;\r\n\tposition: relative\r\n}\r\n\r\n.Striven-Editor .toolbar-options {\r\n\tmargin: 0 10px;\r\n}\r\n\r\n.Striven-Editor .toolbar-option {\r\n\tpadding: 8px;\r\n}\r\n\r\n.Striven-Editor .toolbar-group[data-open=\"true\"] .toolbar-option {\r\n\tbackground-color: #fff;\r\n\tborder: 2px solid #ddd;\r\n\tmargin: 0 2px;\t\r\n}\r\n\r\n.Striven-Editor .toolbar-group[data-open=\"true\"] .toolbar-option:hover {\r\n\tbackground-color: #ddd;\r\n}\r\n\r\n.Striven-Editor .toolbar-option >svg {\r\n\tvertical-align: middle;\r\n}\r\n\r\n.Striven-Editor .toolbar-option:hover,\r\n.Striven-Editor .toolbar-option:focus,\r\n.Striven-Editor .toolbar-option:active {\r\n\tbackground-color: #ddd;\r\n}\r\n\r\n.Striven-Editor .custom-toolbar-button {\r\n\tdisplay: none;\r\n\tcolor: #fff;\r\n\tbackground-color: #5cb85c;\r\n\twidth: 50px;\r\n\ttext-align: center;\r\n\tjustify-content: center;\r\n\talign-content: center;\r\n\talign-items: center;\r\n\tcursor: pointer;\r\n\tborder: 1px solid #4cae4c;\r\n\talign-self: flex-end\r\n}\r\n\r\n\r\n/** File Element **/\r\n\r\n.Striven-Editor .file-el {\r\n\twidth: 100%;\r\n\tdisplay: flex;\r\n\tflex-direction: column;\r\n\tmargin: 10px;\r\n\tposition: relative;\r\n}\r\n\r\n.Striven-Editor .file-name-el {\r\n\tfont-weight: bold;\r\n\tmargin: 0;\r\n}\r\n\r\n.Striven-Editor .file-size-el {\r\n\tfont-size: 12px;\r\n\tmargin: 2px 0;\r\n}\r\n\r\n.Striven-Editor .remove-file-el {\r\n\tmargin: 0;\r\n\tuser-select: none;\r\n\tcolor: black;\r\n\tposition: absolute;\r\n\tright: 5px;\r\n\ttop: -5px;\r\n\tcursor: pointer;\r\n\tbackground-color: #fff\r\n}\r\n\r\n/** Meta Item **/\r\n\r\n.Striven-Editor .meta-item-el {\r\n\twidth: 100%;\r\n\tdisplay: flex;\r\n\tmargin: 10px;\r\n\tposition: relative\r\n}\r\n\r\n.Striven-Editor .meta-image-el {\r\n\tmargin-right: 10px;\r\n\theight: 50px;\r\n\twidth: 75px;\r\n}\r\n\r\n.Striven-Editor .meta-data-title-el {\r\n\tfont-weight: bold;\r\n\tmargin: 0;\r\n}\r\n\r\n.Striven-Editor .remove-meta-data-el {\r\n\tuser-select: none;\r\n\tcolor: black;\r\n\tposition: absolute;\r\n\tright: 5px;\r\n\ttop: -5px;\r\n\tcursor: pointer;\r\n\tbackground-color: #fff;\r\n}\r\n\r\n.Striven-Editor .metadata-section, .Striven-Editor .files-section {\r\n\tdisplay: flex;\r\n\tflex-wrap: wrap;\r\n\tz-index: 500\r\n}\r\n\r\n/** Popup Menu **/\r\n\r\n.Striven-Editor .popup {\r\n\tdisplay: none;\r\n\tposition: absolute;\r\n\tright: 10px;\r\n\tbottom: 10px;\r\n\tbackground-color: #fff;\r\n\tborder: 2px solid #ddd;\r\n\tpadding: 10px 20px;\r\n\tz-index: 1000;\t\r\n}\r\n\r\n\r\n.Striven-Editor .popup > .popup-form {\r\n\tdisplay: flex;\r\n\tjustify-content: space-between;\r\n\tmargin: 5px 0;\r\n}\r\n\r\n.Striven-Editor .popup > .popup-form > .form-label {\r\n\tmargin: 8px 10px 8px 0;\r\n\tfont-size: 14px;\r\n\twidth: 100%;\r\n\ttext-align: right;\r\n\tmargin-right: 10px;\r\n}\r\n\r\n.Striven-Editor .popup > .popup-form >.form-input {\r\n\toutline: none;\r\n\tpadding: 0 5px;\r\n}\r\n\r\n\r\n.Striven-Editor .popup-button-container\r\n{\r\n\tfloat:right;\r\n}\r\n\r\n.Striven-Editor .popup-button{\r\n\tcursor: pointer;\r\n\tpadding: 6px 12px;\r\n\tborder: 1px solid transparent;\r\n\tfont-size: 14px;\r\n\toutline: none;\r\n\tcolor: #333;\r\n\tmargin:2px;\r\n}\r\n\r\n.Striven-Editor .popup-button.button-primary{\r\n\tborder-color: #4cae4c;\r\n\tbackground-color: #5cb85c;\r\n\tcolor: #fff;\r\n}\r\n.Striven-Editor .popup-button.button-secondary{\r\n\tborder-color: #ccc;\r\n\tbackground-color: #fff;\r\n\tcolor: #333;\r\n}\r\n.Striven-Editor .popup-button.button-primary:hover,\r\n.Striven-Editor .popup-button.button-primary:active,\r\n.Striven-Editor .popup-button.button-primary:focus{\r\n\tbackground-color: #4cae4c;\r\n border-color: #398439;\r\n}\r\n.Striven-Editor .popup-button.button-secondary:hover,\r\n.Striven-Editor .popup-button.button-secondary:active,\r\n.Striven-Editor .popup-button.button-secondary:focus{\r\n\tbackground-color: #d4d4d4;\r\n border-color: #8c8c8c;\r\n}\r\n\r\n", ""]); + + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +// css base code, injected by the css-loader +// eslint-disable-next-line func-names +module.exports = function (useSourceMap) { + var list = []; // return the list of modules as css string + + list.toString = function toString() { + return this.map(function (item) { + var content = cssWithMappingToString(item, useSourceMap); + + if (item[2]) { + return "@media ".concat(item[2], "{").concat(content, "}"); + } + + return content; + }).join(''); + }; // import a list of modules into the list + // eslint-disable-next-line func-names + + + list.i = function (modules, mediaQuery) { + if (typeof modules === 'string') { + // eslint-disable-next-line no-param-reassign + modules = [[null, modules, '']]; + } + + var alreadyImportedModules = {}; + + for (var i = 0; i < this.length; i++) { + // eslint-disable-next-line prefer-destructuring + var id = this[i][0]; + + if (id != null) { + alreadyImportedModules[id] = true; + } + } + + for (var _i = 0; _i < modules.length; _i++) { + var item = modules[_i]; // skip already imported module + // this implementation is not 100% perfect for weird media query combinations + // when a module is imported multiple times with different media queries. + // I hope this will never occur (Hey this way we have smaller bundles) + + if (item[0] == null || !alreadyImportedModules[item[0]]) { + if (mediaQuery && !item[2]) { + item[2] = mediaQuery; + } else if (mediaQuery) { + item[2] = "(".concat(item[2], ") and (").concat(mediaQuery, ")"); + } + + list.push(item); + } + } + }; + + return list; +}; + +function cssWithMappingToString(item, useSourceMap) { + var content = item[1] || ''; // eslint-disable-next-line prefer-destructuring + + var cssMapping = item[3]; + + if (!cssMapping) { + return content; + } + + if (useSourceMap && typeof btoa === 'function') { + var sourceMapping = toComment(cssMapping); + var sourceURLs = cssMapping.sources.map(function (source) { + return "/*# sourceURL=".concat(cssMapping.sourceRoot).concat(source, " */"); + }); + return [content].concat(sourceURLs).concat([sourceMapping]).join('\n'); + } + + return [content].join('\n'); +} // Adapted from convert-source-map (MIT) + + +function toComment(sourceMap) { + // eslint-disable-next-line no-undef + var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))); + var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64); + return "/*# ".concat(data, " */"); +} + +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var stylesInDom = {}; + +var isOldIE = function isOldIE() { + var memo; + return function memorize() { + if (typeof memo === 'undefined') { + // Test for IE <= 9 as proposed by Browserhacks + // @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805 + // Tests for existence of standard globals is to allow style-loader + // to operate correctly into non-standard environments + // @see https://github.com/webpack-contrib/style-loader/issues/177 + memo = Boolean(window && document && document.all && !window.atob); + } + + return memo; + }; +}(); + +var getTarget = function getTarget() { + var memo = {}; + return function memorize(target) { + if (typeof memo[target] === 'undefined') { + var styleTarget = document.querySelector(target); // Special case to return head of iframe instead of iframe itself + + if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) { + try { + // This will throw an exception if access to iframe is blocked + // due to cross-origin restrictions + styleTarget = styleTarget.contentDocument.head; + } catch (e) { + // istanbul ignore next + styleTarget = null; + } + } + + memo[target] = styleTarget; + } + + return memo[target]; + }; +}(); + +function listToStyles(list, options) { + var styles = []; + var newStyles = {}; + + for (var i = 0; i < list.length; i++) { + var item = list[i]; + var id = options.base ? item[0] + options.base : item[0]; + var css = item[1]; + var media = item[2]; + var sourceMap = item[3]; + var part = { + css: css, + media: media, + sourceMap: sourceMap + }; + + if (!newStyles[id]) { + styles.push(newStyles[id] = { + id: id, + parts: [part] + }); + } else { + newStyles[id].parts.push(part); + } + } + + return styles; +} + +function addStylesToDom(styles, options) { + for (var i = 0; i < styles.length; i++) { + var item = styles[i]; + var domStyle = stylesInDom[item.id]; + var j = 0; -/******/ }); + if (domStyle) { + domStyle.refs++; + + for (; j < domStyle.parts.length; j++) { + domStyle.parts[j](item.parts[j]); + } + + for (; j < item.parts.length; j++) { + domStyle.parts.push(addStyle(item.parts[j], options)); + } + } else { + var parts = []; + + for (; j < item.parts.length; j++) { + parts.push(addStyle(item.parts[j], options)); + } + + stylesInDom[item.id] = { + id: item.id, + refs: 1, + parts: parts + }; + } + } +} + +function insertStyleElement(options) { + var style = document.createElement('style'); + + if (typeof options.attributes.nonce === 'undefined') { + var nonce = true ? __webpack_require__.nc : undefined; + + if (nonce) { + options.attributes.nonce = nonce; + } + } + + Object.keys(options.attributes).forEach(function (key) { + style.setAttribute(key, options.attributes[key]); + }); + + if (typeof options.insert === 'function') { + options.insert(style); + } else { + var target = getTarget(options.insert || 'head'); + + if (!target) { + throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid."); + } + + target.appendChild(style); + } + + return style; +} + +function removeStyleElement(style) { + // istanbul ignore if + if (style.parentNode === null) { + return false; + } + + style.parentNode.removeChild(style); +} +/* istanbul ignore next */ + + +var replaceText = function replaceText() { + var textStore = []; + return function replace(index, replacement) { + textStore[index] = replacement; + return textStore.filter(Boolean).join('\n'); + }; +}(); + +function applyToSingletonTag(style, index, remove, obj) { + var css = remove ? '' : obj.css; // For old IE + + /* istanbul ignore if */ + + if (style.styleSheet) { + style.styleSheet.cssText = replaceText(index, css); + } else { + var cssNode = document.createTextNode(css); + var childNodes = style.childNodes; + + if (childNodes[index]) { + style.removeChild(childNodes[index]); + } + + if (childNodes.length) { + style.insertBefore(cssNode, childNodes[index]); + } else { + style.appendChild(cssNode); + } + } +} + +function applyToTag(style, options, obj) { + var css = obj.css; + var media = obj.media; + var sourceMap = obj.sourceMap; + + if (media) { + style.setAttribute('media', media); + } + + if (sourceMap && btoa) { + css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */"); + } // For old IE + + /* istanbul ignore if */ + + + if (style.styleSheet) { + style.styleSheet.cssText = css; + } else { + while (style.firstChild) { + style.removeChild(style.firstChild); + } + + style.appendChild(document.createTextNode(css)); + } +} + +var singleton = null; +var singletonCounter = 0; + +function addStyle(obj, options) { + var style; + var update; + var remove; + + if (options.singleton) { + var styleIndex = singletonCounter++; + style = singleton || (singleton = insertStyleElement(options)); + update = applyToSingletonTag.bind(null, style, styleIndex, false); + remove = applyToSingletonTag.bind(null, style, styleIndex, true); + } else { + style = insertStyleElement(options); + update = applyToTag.bind(null, style, options); + + remove = function remove() { + removeStyleElement(style); + }; + } + + update(obj); + return function updateStyle(newObj) { + if (newObj) { + if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap) { + return; + } + + update(obj = newObj); + } else { + remove(); + } + }; +} + +module.exports = function (list, options) { + options = options || {}; + options.attributes = typeof options.attributes === 'object' ? options.attributes : {}; // Force single-tag solution on IE6-9, which has a hard limit on the # of <style> + // tags it will allow on a page + + if (!options.singleton && typeof options.singleton !== 'boolean') { + options.singleton = isOldIE(); + } + + var styles = listToStyles(list, options); + addStylesToDom(styles, options); + return function update(newList) { + var mayRemove = []; + + for (var i = 0; i < styles.length; i++) { + var item = styles[i]; + var domStyle = stylesInDom[item.id]; + + if (domStyle) { + domStyle.refs--; + mayRemove.push(domStyle); + } + } + + if (newList) { + var newStyles = listToStyles(newList, options); + addStylesToDom(newStyles, options); + } + + for (var _i = 0; _i < mayRemove.length; _i++) { + var _domStyle = mayRemove[_i]; + + if (_domStyle.refs === 0) { + for (var j = 0; j < _domStyle.parts.length; j++) { + _domStyle.parts[j](); + } + + delete stylesInDom[_domStyle.id]; + } + } + }; +}; + +/***/ }) +/******/ ]); }); \ No newline at end of file diff --git a/dist/ko-striveneditor.js b/dist/ko-striveneditor.js @@ -1,2 +1,8 @@ /*! For license information please see ko-striveneditor.js.LICENSE */ -!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.striveneditor=r():e.striveneditor=r()}(window,(function(){return function(e){var r={};function t(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,t),n.l=!0,n.exports}return t.m=e,t.c=r,t.d=function(e,r,o){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:o})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)t.d(o,n,function(r){return e[r]}.bind(null,n));return o},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s="./src/ko-striveneditor.js")}({"./src/ko-striveneditor.js":function(module,exports){eval("throw new Error(\"Module build failed (from ./node_modules/babel-loader/lib/index.js):\\nError: ENOENT: no such file or directory, open 'C:\\\\Users\\\\hunite\\\\Projects\\\\striven-editor\\\\src\\\\ko-striveneditor.js'\");\n\n//# sourceURL=webpack://striveneditor/./src/ko-striveneditor.js?")}})})); -\ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.striveneditor=e():t.striveneditor=e()}(window,(function(){return function(t){var e={};function o(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)o.d(n,i,function(e){return t[e]}.bind(null,i));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=5)}({0:function(t,e,o){var n,i,a;i=[e],void 0===(a="function"==typeof(n=function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t){return function(t){if(Array.isArray(t)){for(var e=0,o=new Array(t.length);e<t.length;e++)o[e]=t[e];return o}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function n(t,e){for(var o=0;o<e.length;o++){var n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0; +/* + @license/i + * Font Awesome Free 5.11.2 by @fontawesome - https://fontawesome.com + * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) + */ +var i=[".doc",".docx",".xls",".xlsx",".ppt",".pptx",".pdf",".tif",".jpeg",".jpg",".gif",".bmp",".txt",".csv",".png",".msg",".wav",".mp3",".mp4",".zip",".rtf",".eps",".ai",".psd",".avi",".mov",".wmv",".cfg",".wss",".vsd",".vsdx",".tsd",".lic"],a="fas",r={textDecoration:{menu:{viewBox:"0 0 1792 1792",d:"M789 559l-170 450q33 0 136.5 2t160.5 2q19 0 57-2-87-253-184-452zm-725 1105l2-79q23-7 56-12.5t57-10.5 49.5-14.5 44.5-29 31-50.5l237-616 280-724h128q8 14 11 21l205 480q33 78 106 257.5t114 274.5q15 34 58 144.5t72 168.5q20 45 35 57 19 15 88 29.5t84 20.5q6 38 6 57 0 5-.5 13.5t-.5 12.5q-63 0-190-8t-191-8q-76 0-215 7t-178 8q0-43 4-78l131-28q1 0 12.5-2.5t15.5-3.5 14.5-4.5 15-6.5 11-8 9-11 2.5-14q0-16-31-96.5t-72-177.5-42-100l-450-2q-26 58-76.5 195.5t-50.5 162.5q0 22 14 37.5t43.5 24.5 48.5 13.5 57 8.5 41 4q1 19 1 58 0 9-2 27-58 0-174.5-10t-174.5-10q-8 0-26.5 4t-21.5 4q-80 14-188 14z"},group:[{bold:{viewBox:"0 0 1792 1792",d:"M747 1521q74 32 140 32 376 0 376-335 0-114-41-180-27-44-61.5-74t-67.5-46.5-80.5-25-84-10.5-94.5-2q-73 0-101 10 0 53-.5 159t-.5 158q0 8-1 67.5t-.5 96.5 4.5 83.5 12 66.5zm-14-746q42 7 109 7 82 0 143-13t110-44.5 74.5-89.5 25.5-142q0-70-29-122.5t-79-82-108-43.5-124-14q-50 0-130 13 0 50 4 151t4 152q0 27-.5 80t-.5 79q0 46 1 69zm-541 889l2-94q15-4 85-16t106-27q7-12 12.5-27t8.5-33.5 5.5-32.5 3-37.5.5-34v-65.5q0-982-22-1025-4-8-22-14.5t-44.5-11-49.5-7-48.5-4.5-30.5-3l-4-83q98-2 340-11.5t373-9.5q23 0 68 .5t68 .5q70 0 136.5 13t128.5 42 108 71 74 104.5 28 137.5q0 52-16.5 95.5t-39 72-64.5 57.5-73 45-84 40q154 35 256.5 134t102.5 248q0 100-35 179.5t-93.5 130.5-138 85.5-163.5 48.5-176 14q-44 0-132-3t-132-3q-106 0-307 11t-231 12z"}},{italic:{viewBox:"0 0 1792 1792",d:"M384 1662l17-85q22-7 61.5-16.5t72-19 59.5-23.5q28-35 41-101 1-7 62-289t114-543.5 52-296.5v-25q-24-13-54.5-18.5t-69.5-8-58-5.5l19-103q33 2 120 6.5t149.5 7 120.5 2.5q48 0 98.5-2.5t121-7 98.5-6.5q-5 39-19 89-30 10-101.5 28.5t-108.5 33.5q-8 19-14 42.5t-9 40-7.5 45.5-6.5 42q-27 148-87.5 419.5t-77.5 355.5q-2 9-13 58t-20 90-16 83.5-6 57.5l1 18q17 4 185 31-3 44-16 99-11 0-32.5 1.5t-32.5 1.5q-29 0-87-10t-86-10q-138-2-206-2-51 0-143 9t-121 11z"}},{underline:{viewBox:"0 0 1792 1792",d:"M176 223q-37-2-45-4l-3-88q13-1 40-1 60 0 112 4 132 7 166 7 86 0 168-3 116-4 146-5 56 0 86-2l-1 14 2 64v9q-60 9-124 9-60 0-79 25-13 14-13 132 0 13 .5 32.5t.5 25.5l1 229 14 280q6 124 51 202 35 59 96 92 88 47 177 47 104 0 191-28 56-18 99-51 48-36 65-64 36-56 53-114 21-73 21-229 0-79-3.5-128t-11-122.5-13.5-159.5l-4-59q-5-67-24-88-34-35-77-34l-100 2-14-3 2-86h84l205 10q76 3 196-10l18 2q6 38 6 51 0 7-4 31-45 12-84 13-73 11-79 17-15 15-15 41 0 7 1.5 27t1.5 31q8 19 22 396 6 195-15 304-15 76-41 122-38 65-112 123-75 57-182 89-109 33-255 33-167 0-284-46-119-47-179-122-61-76-83-195-16-80-16-237v-333q0-188-17-213-25-36-147-39zm1488 1409v-64q0-14-9-23t-23-9h-1472q-14 0-23 9t-9 23v64q0 14 9 23t23 9h1472q14 0 23-9t9-23z"}},{strikethrough:{viewBox:"0 0 1792 1792",d:"M1760 896q14 0 23 9t9 23v64q0 14-9 23t-23 9h-1728q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h1728zm-1277-64q-28-35-51-80-48-98-48-188 0-181 134-309 133-127 393-127 50 0 167 19 66 12 177 48 10 38 21 118 14 123 14 183 0 18-5 45l-12 3-84-6-14-2q-50-149-103-205-88-91-210-91-114 0-182 59-67 58-67 146 0 73 66 140t279 129q69 20 173 66 58 28 95 52h-743zm507 256h411q7 39 7 92 0 111-41 212-23 56-71 104-37 35-109 81-80 48-153 66-80 21-203 21-114 0-195-23l-140-40q-57-16-72-28-8-8-8-22v-13q0-108-2-156-1-30 0-68l2-37v-44l102-2q15 34 30 71t22.5 56 12.5 27q35 57 80 94 43 36 105 57 59 22 132 22 64 0 139-27 77-26 122-86 47-61 47-129 0-84-81-157-34-29-137-71z"}},{removeFormat:{viewBox:"0 0 640 512",d:"M336 416h-11.17l9.26-27.77L267 336.4 240.49 416H208a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h128a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm297.82 42.1L377 259.59 426.17 112H544v32a16 16 0 0 0 16 16h32a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16H176a16 16 0 0 0-16 16v43.9L45.46 3.38A16 16 0 0 0 23 6.19L3.37 31.46a16 16 0 0 0 2.81 22.45l588.36 454.72a16 16 0 0 0 22.46-2.81l19.64-25.27a16 16 0 0 0-2.82-22.45zM309.91 207.76L224 141.36V112h117.83z"}}]},listOptions:{menu:{viewBox:"0 0 1792 1792",d:"M256 1312v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm1536 768v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5zm-1536-1152v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm1536 768v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5z"},group:[{insertOrderedList:{viewBox:"0 0 1792 1792",d:"M381 1620q0 80-54.5 126t-135.5 46q-106 0-172-66l57-88q49 45 106 45 29 0 50.5-14.5t21.5-42.5q0-64-105-56l-26-56q8-10 32.5-43.5t42.5-54 37-38.5v-1q-16 0-48.5 1t-48.5 1v53h-106v-152h333v88l-95 115q51 12 81 49t30 88zm2-627v159h-362q-6-36-6-54 0-51 23.5-93t56.5-68 66-47.5 56.5-43.5 23.5-45q0-25-14.5-38.5t-39.5-13.5q-46 0-81 58l-85-59q24-51 71.5-79.5t105.5-28.5q73 0 123 41.5t50 112.5q0 50-34 91.5t-75 64.5-75.5 50.5-35.5 52.5h127v-60h105zm1409 319v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-14 9-23t23-9h1216q13 0 22.5 9.5t9.5 22.5zm-1408-899v99h-335v-99h107q0-41 .5-121.5t.5-121.5v-12h-2q-8 17-50 54l-71-76 136-127h106v404h108zm1408 387v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-14 9-23t23-9h1216q13 0 22.5 9.5t9.5 22.5zm0-512v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5z"}},{insertUnorderedList:{viewBox:"0 0 1792 1792",d:"M384 1408q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm0-512q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm1408 416v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5zm-1408-928q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm1408 416v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5zm0-512v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5"}}]},textAlign:{menu:{viewBox:"0 0 1792 1792",d:"M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45z"},group:[{indent:{viewBox:"0 0 1792 1792",d:"M352 832q0 14-9 23l-288 288q-9 9-23 9-13 0-22.5-9.5t-9.5-22.5v-576q0-13 9.5-22.5t22.5-9.5q14 0 23 9l288 288q9 9 9 23zm1440 480v192q0 13-9.5 22.5t-22.5 9.5h-1728q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1728q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1088q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1088q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1088q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1088q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1728q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1728q13 0 22.5 9.5t9.5 22.5z"}},{justifyLeft:{viewBox:"0 0 1792 1792",d:"M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-1280q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1280q26 0 45 19t19 45zm256-384v128q0 26-19 45t-45 19h-1536q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1536q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-1152q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1152q26 0 45 19t19 45z"}},{justifyCenter:{viewBox:"0 0 1792 1792",d:"M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-896q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h896q26 0 45 19t19 45zm256-384v128q0 26-19 45t-45 19h-1408q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1408q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-640q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h640q26 0 45 19t19 45z"}},{justifyRight:{viewBox:"0 0 1792 1792",d:"M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1280q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1280q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1536q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1536q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1152q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1152q26 0 45 19t19 45z"}}]},attachments:{menu:{viewBox:"0 0 1792 1792",d:"M1596 1385q0 117-79 196t-196 79q-135 0-235-100l-777-776q-113-115-113-271 0-159 110-270t269-111q158 0 273 113l605 606q10 10 10 22 0 16-30.5 46.5t-46.5 30.5q-13 0-23-10l-606-607q-79-77-181-77-106 0-179 75t-73 181q0 105 76 181l776 777q63 63 145 63 64 0 106-42t42-106q0-82-63-145l-581-581q-26-24-60-24-29 0-48 19t-19 48q0 32 25 59l410 410q10 10 10 22 0 16-31 47t-47 31q-12 0-22-10l-410-410q-63-61-63-149 0-82 57-139t139-57q88 0 149 63l581 581q100 98 100 235z"},group:[{attachment:{viewBox:"0 0 1792 1792",d:"M1596 1385q0 117-79 196t-196 79q-135 0-235-100l-777-776q-113-115-113-271 0-159 110-270t269-111q158 0 273 113l605 606q10 10 10 22 0 16-30.5 46.5t-46.5 30.5q-13 0-23-10l-606-607q-79-77-181-77-106 0-179 75t-73 181q0 105 76 181l776 777q63 63 145 63 64 0 106-42t42-106q0-82-63-145l-581-581q-26-24-60-24-29 0-48 19t-19 48q0 32 25 59l410 410q10 10 10 22 0 16-31 47t-47 31q-12 0-22-10l-410-410q-63-61-63-149 0-82 57-139t139-57q88 0 149 63l581 581q100 98 100 235z"}},{link:{viewBox:"0 0 1792 1792",d:"M1520 1216q0-40-28-68l-208-208q-28-28-68-28-42 0-72 32 3 3 19 18.5t21.5 21.5 15 19 13 25.5 3.5 27.5q0 40-28 68t-68 28q-15 0-27.5-3.5t-25.5-13-19-15-21.5-21.5-18.5-19q-33 31-33 73 0 40 28 68l206 207q27 27 68 27 40 0 68-26l147-146q28-28 28-67zm-703-705q0-40-28-68l-206-207q-28-28-68-28-39 0-68 27l-147 146q-28 28-28 67 0 40 28 68l208 208q27 27 68 27 42 0 72-31-3-3-19-18.5t-21.5-21.5-15-19-13-25.5-3.5-27.5q0-40 28-68t68-28q15 0 27.5 3.5t25.5 13 19 15 21.5 21.5 18.5 19q33-31 33-73zm895 705q0 120-85 203l-147 146q-83 83-203 83-121 0-204-85l-206-207q-83-83-83-203 0-123 88-209l-88-88q-86 88-208 88-120 0-204-84l-208-208q-84-84-84-204t85-203l147-146q83-83 203-83 121 0 204 85l206 207q83 83 83 203 0 123-88 209l88 88q86-88 208-88 120 0 204 84l208 208q84 84 84 204z"}},{image:{viewBox:"0 0 2048 1792",d:"M704 576q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm1024 384v448h-1408v-192l320-320 160 160 512-512zm96-704h-1600q-13 0-22.5 9.5t-9.5 22.5v1216q0 13 9.5 22.5t22.5 9.5h1600q13 0 22.5-9.5t9.5-22.5v-1216q0-13-9.5-22.5t-22.5-9.5zm160 32v1216q0 66-47 113t-113 47h-1600q-66 0-113-47t-47-113v-1216q0-66 47-113t113-47h1600q66 0 113 47t47 113z"}}]}},l=["bold","italic","underline","strikethrough","removeFormat","insertOrderedList","insertUnorderedList","indent","justifyLeft","justifyCenter","justifyRight","attachment","link","image"],s="#777777",c=function(){function t(e,o){var n=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.establishBrowser(),this.range=new Range,this.files=[],this.optionGroups=r,o?(this.options=o,o.fontPack||(this.options.fontPack=a),o.extensions||(this.options.extensions=i),o.toolbarOptions||(this.options.toolbarOptions=l),o.activeOptionColor||(this.options.activeOptionColor=s)):this.options={fontPack:a,extensions:i,toolbarOptions:l,activeOptionColor:s},this.initEditor(e),this.initResponsive(),this.initOverflow(),e.StrivenEditor=function(){return n},this.bound_popupEscapeHandler=this.popupEscapeHandler.bind(this)}var c,u,d;return c=t,(u=[{key:"initEditor",value:function(t){var e=this;if(this.editor=t,this.toolbar=this.initToolbar(),this.body=this.initBody(),this.linkMenu=this.initLinkMenu(),this.imageMenu=this.initImageMenu(),this.metaDataSection=this.initMetaDataSection(),this.filesSection=this.initFilesSection(),this.editor.classList.add("editor","Striven-Editor"),this.options.toolbarHide){this.customToolbarButton&&(this.customToolbarButton.style.display="none"),this.toolbarOptionsGroup.style.display="none";var n=this.body.onfocus;this.body.onfocus=function(){n&&n(),e.overflow(),e.toolbarSlideUp()};var i=this.body.onblur;this.body.onblur=function(){i&&i(),e.overflow(),setTimeout((function(){"true"===e.linkMenu.dataset.active||"true"===e.imageMenu.dataset.active||e.isEditorInFocus()||e.toolbarSlideDown()}),500)}}this.toolbarOptions.forEach((function(t){t.style.cursor="pointer",t.style.userSelect="none";var n=t.onclick;t.onclick=function(i){var a=function(){var t=e.body.querySelectorAll("blockquote");o(t).forEach((function(t){return t.style.margin="0 0 0 40px"}))};e.body.focus(),window.getSelection().removeAllRanges(),window.getSelection().addRange(e.range);var r=t.id.split("-")[1];switch(r){case"insertOrderedList":e.isFirefox?(document.execCommand("indent"),document.execCommand(r),a()):e.isEdge?(document.execCommand(r),o(document.querySelectorAll("ol")).forEach((function(t){return t.style.marginLeft="40px"}))):(document.execCommand("indent",!0),document.execCommand(r,!0));break;case"insertUnorderedList":e.isFirefox?(document.execCommand("indent"),document.execCommand(r),a()):e.isEdge?(document.execCommand(r),o(document.querySelectorAll("ul")).forEach((function(t){return t.style.marginLeft="40px"}))):(document.execCommand("indent",!0),document.execCommand(r,!0));break;case"attachment":var l=document.createElement("input");l.style.display="none",l.type="file",l.onchange=function(t){return e.attachFile(l.files[0])},l.click();break;case"link":"true"===e.linkMenu.dataset.active?e.closeLinkMenu():(e.linkMenuSlideIn(),e.linkMenu.querySelector("input").focus());break;case"image":"true"===e.imageMenu.dataset.active?e.closeImageMenu():(e.imageMenuSlideIn(),e.range=e.getRange(),e.imageMenu.querySelector("input").focus());break;default:e.isFirefox||e.isEdge?(document.execCommand(r),"indent"===r&&a()):document.execCommand(r,!0),e.toolbarState()}n&&n()}})),this.editor.appendChild(this.toolbar),this.editor.appendChild(this.body),this.editor.appendChild(this.linkMenu),this.editor.appendChild(this.imageMenu),this.editor.appendChild(this.metaDataSection),this.editor.appendChild(this.filesSection),this.options.toolbarBottom&&(this.editor.removeChild(this.toolbar),this.editor.append(this.toolbar))}},{key:"imageMenuSlideIn",value:function(){var t=this;this.openImageMenu();var e=0,o=this.editor.offsetWidth/4,n=setInterval((function(){o<=10?(clearInterval(n),t.imageMenu.style.opacity=1):(o-=2.5,e+=.01,t.imageMenu.style.opacity="".concat(e),t.imageMenu.style.right="".concat(o,"px"))}),5);this.imageMenu.style.opacity=e}},{key:"linkMenuSlideIn",value:function(){var t=this;this.openLinkMenu();var e=0,o=this.editor.offsetWidth/4,n=setInterval((function(){o<=10?(clearInterval(n),t.linkMenu.style.opacity=1):(o-=2.5,e+=.01,t.linkMenu.style.opacity="".concat(e),t.linkMenu.style.right="".concat(o,"px"))}),5);this.linkMenu.style.opacity=e}},{key:"toolbarSlideUp",value:function(){var t=this,e=this.toolbar.offsetHeight,o=setInterval((function(){e>=40?(t.customToolbarButton&&(t.customToolbarButton.style.display="flex"),t.toolbarOptionsGroup.style.display="flex",clearInterval(o)):(e++,t.toolbar.style.minHeight="".concat(e,"px"))}),5)}},{key:"toolbarSlideDown",value:function(){var t=this;this.customToolbarButton&&(this.customToolbarButton.style.display="none"),this.toolbarOptionsGroup.style.display="none";var e=40,o=setInterval((function(){0===e?clearInterval(o):(e--,t.toolbar.style.minHeight="".concat(e,"px"))}),5)}},{key:"initToolbar",value:function(){var t=this,n=document.createElement("div");this.toolbarOptionsGroup=document.createElement("div");var i=Object.keys(this.optionGroups);n.classList.add("toolbar"),n.style.minHeight=this.options.toolbarHide?"0":"40px",this.toolbarOptionsGroup.classList.add("toolbar-options"),this.toolbarOptionsGroup.style.display=this.options.toolbarHide?"none":"flex",n.onclick=function(){return t.body.focus()},i.forEach((function(e){var o=document.createElement("div");o.classList.add("toolbar-menu"),o.id="menu-".concat(e),o.appendChild(t.constructSVG(t.optionGroups[e].menu)),t.toolbarOptionsGroup.appendChild(o);var n=document.createElement("div");n.classList.add("toolbar-group"),n.id="group-".concat(e),t.options.toolbarOptions.forEach((function(o){var i=t.optionGroups[e].group.filter((function(t){return t[o]}))[0];if(i){var a=i[o],r=t.constructSVG(a);r.classList.add("toolbar-option"),r.id="toolbar-".concat(o),n.appendChild(r)}})),t.toolbarOptionsGroup.appendChild(n)}));var a=this.options.toolbarOptions.filter((function(t){return"object"===e(t)}));if(a.length>0&&(this.customToolbarMenu=document.createElement("div"),this.customToolbarMenu.classList.add("toolbar-menu"),this.customToolbarMenu.id="menu-custom",this.customToolbarMenu.appendChild(this.constructSVG({viewBox:"0 0 1792 1792",d:"M1088 1248v192q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h192q40 0 68 28t28 68zm0-512v192q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h192q40 0 68 28t28 68zm0-512v192q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h192q40 0 68 28t28 68z"})),this.toolbarOptionsGroup.appendChild(this.customToolbarMenu),this.customToolbarGroup=document.createElement("div"),this.customToolbarGroup.classList.add("toolbar-group"),this.customToolbarGroup.id="group-custom",a.forEach((function(e){var o=e.icon,n=e.handler,i=t.constructSVG(o);i.id="toolbar-customOption",i.style.margin="0 10px",i.onclick=function(){return n()},t.customToolbarGroup.appendChild(i)})),this.toolbarOptionsGroup.appendChild(this.customToolbarGroup)),n.appendChild(this.toolbarOptionsGroup),this.options.customToolbarButton){var r=document.createElement("div");r.id="custom-toolbar-button",r.classList.add("custom-toolbar-button"),r.style.minHeight=this.options.toolbarHide?"40px":n.style.minHeight,r.onclick=function(){return t.options.customToolbarButton.handler()},!this.options.toolbarHide&&(r.style.display="flex"),r.onmouseenter=function(){r.style.borderColor=t.options.customToolbarButton.hoverBorderColor,r.style.backgroundColor=t.options.customToolbarButton.hoverBackgroundColor,r.style.color=t.options.customToolbarButton.hoverColor},r.onmouseleave=function(){r.style.borderColor=t.options.customToolbarButton.borderColor,r.style.backgroundColor=t.options.customToolbarButton.backgroundColor,r.style.color=t.options.customToolbarButton.color};var l=this.constructSVG(this.options.customToolbarButton.svgData);l.querySelector("path").setAttribute("fill",this.options.customToolbarButton.color),r.appendChild(l),n.appendChild(r)}return this.toolbarOptions=n.querySelectorAll("span"),this.toolbarGroups=o(n.getElementsByClassName("toolbar-group")),this.toolbarMenus=o(n.getElementsByClassName("toolbar-menu")),this.customToolbarButton=n.querySelector("#custom-toolbar-button"),this.toolbarMenus.push(this.customToolbarMenu),this.toolbarGroups.push(this.customToolbarGroup),this.toolbarGroups.forEach((function(e){if(e&&e.children.length<1){var o=e.id.split("-")[1];t.toolbarMenus.filter((function(t){return t.id.split("-")[1]===o}))[0].remove()}})),n}},{key:"initBody",value:function(){var t=this,e=document.createElement("div");if(e.classList.add("body"),e.contentEditable="true",e.style.height=this.editor.style.height,e.style.minHeight=this.editor.style.minHeight,e.style.maxHeight=this.editor.style.maxHeight,this.editor.style.height="auto",this.editor.style.minHeight="auto",this.editor.style.maxHeight="auto",this.options.placeholder){var o=document.createElement("p");o.id="placeholder-node",o.style.color="#5f6368",o.style.margin="0",o.textContent=this.options.placeholder,e.append(o);var n=e.onfocus;e.onfocus=function(){n&&n(),e.querySelector("#placeholder-node")===o&&t.clearContent()};var i=e.onblur;e.onblur=function(){i&&i(),""===t.getContent().trim()&&e.append(o)}}e.onpaste=function(e){var o;if(e.clipboardData.files.length>0&&e.clipboardData.files[0].type.includes("image")&&(o=e.clipboardData.files[0],new Promise((function(t,e){var n=new FileReader;n.readAsDataURL(o),n.onload=function(){return t(n.result)},n.onerror=function(t){return e(t)}}))).then((function(e){t.options.imageUrl?t.getImage(e).then((function(t){document.execCommand("insertImage",!0,t.imageRef)})).catch((function(t){document.execCommand("insertImage",!0,e)})):(document.execCommand("insertImage",!0,e),t.options.uploadOnPaste&&t.attachFile(function(t,e){for(var o=t.split(","),n=o[0].match(/:(.*?);/)[1],i=atob(o[1]),a=i.length,r=new Uint8Array(a);a--;)r[a]=i.charCodeAt(a);var l=new File([r],e,{type:n});return new File([r],"".concat(l.name,".").concat(l.type.split("/").pop()),{type:l.type})}(e,"pastedimage"))),t.overflow()})),t.options.sanitizePaste&&e.clipboardData.types.includes("text/html")){var n;e.preventDefault();for(var i=0;i<e.clipboardData.items.length;i++){var a=e.clipboardData.items[i];"text/html"===a.type&&(n=a)}n&&n.getAsString((function(e){var o=t.getRange();o.insertNode(t.scrubHTML(e)),o.collapse()}))}e.clipboardData.items.length>0&&"text/plain"===e.clipboardData.items[0].type&&e.clipboardData.items[0].getAsString((function(e){t.options.metaUrl&&t.validURL(e)&&t.getMeta(e).then((function(e){var o=e.url,n=e.title,i=e.image,a=e.description;o&&n&&i&&t.createMetaDataElement(o,i,n,a)}))})),t.overflow()};var a=e.onkeyup;e.onkeyup=function(o){if(a&&a(),t.range=t.getRange(),t.options.submitOnEnter&&13===o.keyCode&&!o.shiftKey&&!document.queryCommandState("insertOrderedList")&&!document.queryCommandState("insertUnorderedList")){var n=!!t.getTextContent(),i=!!e.querySelector("img");if(n||i){var r=e.querySelectorAll("div"),l=r[r.length?r.length-1:0];l&&l.remove()}var s=t.getContent(),c=t.getFiles();t.clearContent(),t.clearFiles(),(c.length||n||i)&&t.options.submitOnEnter({content:(n||i)&&s,files:c})}t.toolbarState()};var r=e.onmouseup;return e.onmouseup=function(e){r&&r(),t.range=t.getRange()},e}},{key:"initLinkMenu",value:function(){var t=this,e=document.createElement("div"),n=document.createElement("div"),i=document.createElement("div"),a=document.createElement("button"),r=document.createElement("button"),l=document.createElement("p"),s=document.createElement("input");return e.id="link-menu",e.classList.add("popup"),e.dataset.active="false",n.classList.add("popup-form"),l.classList.add("form-label"),l.textContent="Web Address",s.classList.add("form-input"),s.type="text",s.placeholder="Insert a Link",i.classList.add("popup-button-container"),a.classList.add("popup-button"),a.classList.add("button-primary"),a.textContent="Insert Link",r.classList.add("popup-button"),r.classList.add("button-secondary"),r.textContent="Close",a.onclick=function(e){var n=s.value;n?(window.getSelection().removeAllRanges(),window.getSelection().addRange(t.range),t.isFirefox||t.isEdge?document.execCommand("createLink",!1,n):document.execCommand("createLink",!0,n),t.options.metaUrl&&t.validURL(n)&&t.getMeta(n).then((function(e){var o=e.url,n=e.image,i=e.title,a=e.description;o&&n&&i&&t.createMetaDataElement(o,n,i,a)})),o(t.body.querySelectorAll("a")).forEach((function(e){return!t.isFirefox&&(e.contentEditable="false")})),s.value="",t.closeLinkMenu()):(t.body.focus(),t.closeLinkMenu())},r.onclick=function(e){t.body.focus(),t.closeLinkMenu()},n.appendChild(l),n.appendChild(s),e.appendChild(n),i.appendChild(a),i.appendChild(r),e.appendChild(i),e}},{key:"initImageMenu",value:function(){var t=this,e=document.createElement("div"),n=document.createElement("div"),i=document.createElement("div"),a=document.createElement("button"),r=document.createElement("button"),l=document.createElement("p"),s=document.createElement("input");e.id="image-menu",e.classList.add("popup"),e.dataset.active="false",n.classList.add("popup-form"),l.classList.add("form-label"),l.textContent="Image URL",s.classList.add("form-input"),s.type="text",s.placeholder="Insert a Link",i.classList.add("popup-button-container"),a.classList.add("popup-button"),a.classList.add("button-primary"),a.textContent="Insert Image",r.classList.add("popup-button"),r.classList.add("button-secondary"),r.textContent="Close",n.appendChild(l),n.appendChild(s);var c=n.cloneNode(!0),u=c.querySelector("input"),d=c.querySelector("p");u.placeholder="Image Height",d.textContent="Height";var p=n.cloneNode(!0),h=p.querySelector("input"),m=p.querySelector("p");return h.placeholder="Image Width",m.textContent="Width",a.onclick=function(e){var n=s.value,i=u.value,a=h.value;if(n){window.getSelection().removeAllRanges(),window.getSelection().addRange(t.range),t.isFirefox||t.isEdge?document.execCommand("insertImage",!1,n):document.execCommand("insertImage",!0,n);var r=o(t.body.querySelectorAll("img")).filter((function(t){return t.src===n}));(r=r[r.length-1])&&(r.style.height="".concat(i,"px")),r&&(r.style.width="".concat(a,"px")),u.value="",h.value="",s.value="",t.closeImageMenu()}else t.body.focus(),t.closeImageMenu()},r.onclick=function(e){t.body.focus(),t.closeImageMenu()},e.appendChild(c),e.appendChild(p),e.appendChild(n),i.appendChild(a),i.appendChild(r),e.appendChild(i),e}},{key:"initMetaDataSection",value:function(){var t=document.createElement("div");return t.classList.add("metadata-section"),t}},{key:"initFilesSection",value:function(){var t=this,e=document.createElement("div");return e.classList.add("files-section"),this.body.ondragenter=function(e){t.body.style.backgroundColor="#ddd"},this.body.ondragleave=function(e){t.body.style.backgroundColor="inherit"},this.body.ondrop=function(e){t.body.style.backgroundColor="inherit",e.preventDefault();var o=e.dataTransfer.files&&e.dataTransfer.files[0];t.attachFile(o)},this.isEdge&&(this.body.ondragover=function(t){return t.preventDefault()}),e}},{key:"createFileElement",value:function(t,e){var o=this,n=document.createElement("div"),i=document.createElement("h4"),a=document.createElement("p"),r=document.createElement("p");i.textContent=t,a.textContent=e,r.textContent="X",n.classList.add("file-el"),n.dataset.fileindex=this.files.length-1,i.classList.add("file-name-el"),a.classList.add("file-size-el"),r.classList.add("remove-file-el"),r.onmouseenter=function(){return r.style.color="#ddd"},r.onmouseleave=function(){return r.style.color="black"},r.onclick=function(t){o.files.splice(t.target.parentElement.dataset.fileindex,1),t.target.parentElement.remove()},n.appendChild(i),n.appendChild(a),n.appendChild(r),this.filesSection.appendChild(n)}},{key:"createMetaDataElement",value:function(t,e,o,n){var i=document.createElement("div"),a=document.createElement("a"),r=document.createElement("img"),l=document.createElement("div"),s=document.createElement("h4"),c=document.createElement("p"),u=document.createElement("span");a.href=t,r.src=e,s.textContent=o,c.textContent=n,u.textContent="X",a.target="blank",i.classList.add("meta-item-el"),r.classList.add("meta-image-el"),s.classList.add("meta-data-title-el"),c.style.margin="0",u.classList.add("remove-meta-data-el"),u.onmouseenter=function(){return u.style.color="#ddd"},u.onmouseleave=function(){return u.style.color="black"},u.onclick=function(t){return t.target.parentElement.remove()},a.appendChild(r),l.appendChild(s),l.appendChild(c),i.appendChild(a),i.appendChild(l),i.appendChild(u),this.metaDataSection.appendChild(i)}},{key:"constructSVG",value:function(t){var e=t.viewBox,o=t.d,n=this.options.toolbarOptionFillColor?this.options.toolbarOptionFillColor:"#333",i=document.createElement("span"),a='<svg width="'.concat("16",'" height="').concat("14",'" viewBox="').concat(e,'" xmlns="').concat("http://www.w3.org/2000/svg",'">'),r='<path fill="'.concat(n,'" d="').concat(o,'"/>');return i.innerHTML="".concat(a).concat(r,"</svg>"),i}},{key:"initResponsive",value:function(){var t=this,e=this;if(this.options.minimal)this.toolbarMenus.forEach((function(t){return t&&(t.style.display="none")})),this.toolbar.querySelector("#toolbar-strikethrough").style.display="none",this.toolbar.querySelector("#toolbar-image").style.display="none",this.toolbar.querySelector("#toolbar-insertOrderedList").style.display="none",this.toolbar.querySelector("#group-textAlign").style.display="none",this.toolbar.querySelector("#toolbar-removeFormat").style.display="none";else{var o=function(t){e.toolbarGroups.forEach((function(o){o&&(o.dataset.open="false",o.style.display=t?"none":"block",o.style.position=t?"absolute":"relative",!e.options.toolbarBottom&&(o.style.top=t?"50px":"inherit"),e.options.toolbarBottom&&(o.style.bottom=t?"50px":"inherit"))})),e.toolbarMenus.forEach((function(o){o&&(o.style.padding="0 10px",o.style.cursor="pointer",o.style.userSelect="none",o.style.display=t?"block":"none",o.onclick=function(t){var n;"false"===(n=e.toolbar.querySelector("#group-".concat(o.id.split("-")[1]))).dataset.open?(e.toolbarGroups.forEach((function(t){t&&"true"===t.dataset.open&&(t.style.display="none",t.dataset.open="false")})),n.style.display="block",n.style.padding="5px 5px 0 5px",n.dataset.open="true"):(n.style.display="none",n.dataset.open="false"),e.body.focus()})}))},n=function(){i=window.matchMedia("(max-width: 700px)").matches,o(i)},i=window.matchMedia("(max-width: 700px)").matches;n(),window.onresize=function(){t.toolbarGroups.forEach((function(t){return t&&(t.style.padding="0")})),t.closeLinkMenu(),t.closeImageMenu(),n()}}}},{key:"initOverflow",value:function(){var t=this,e=this.body.onfocus;this.body.onfocus=function(){e&&e(),t.overflow()};var o=this.body.onblur;this.body.onblur=function(){o&&o(),t.overflow()};var n=this.body.onkeypress;this.body.onkeypress=function(){n&&n(),t.overflow()}}},{key:"getFiles",value:function(){return this.files}},{key:"getContent",value:function(){return this.body.querySelector("#placeholder-node")?"":this.body.innerHTML}},{key:"getRange",value:function(){return window.getSelection().getRangeAt(0)}},{key:"getMeta",value:function(t){return fetch(this.options.metaUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetUrl:t})}).then((function(t){return t.json()}))}},{key:"getImage",value:function(t){return fetch(this.options.imageUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({imageEncoding:t})}).then((function(t){return t.json()}))}},{key:"validURL",value:function(t){return!!new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$","i").test(t)}},{key:"overflow",value:function(){var t=this.body;t.scrollHeight>t.clientHeight?t.style.overflowY="scroll":t.style.overflowY="hidden",t.scrollWidth>t.clientWidth?t.style.overflowX="scroll":t.style.overflowX="hidden"}},{key:"formatBytes",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(0===t)return"0 Bytes";var o=1024,n=e<0?0:e,i=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],a=Math.floor(Math.log(t)/Math.log(o));return parseFloat((t/Math.pow(o,a)).toFixed(n))+" "+i[a]}},{key:"validateFile",value:function(t){var e=t.type.split("/").pop();return this.options.extensions.includes(".".concat(e))}},{key:"attachFile",value:function(t){this.validateFile(t)?(this.files.push(t),this.createFileElement(t.name,this.formatBytes(t.size))):this.fileInvalid()}},{key:"fileInvalid",value:function(){var t=this;this.body.style.transition="background-color .5s",this.body.style.backgroundColor="#d9534f",setTimeout((function(){t.body.style.backgroundColor="inherit",setTimeout((function(){return t.body.style.transition="none"}),500)}),2e3)}},{key:"openLinkMenu",value:function(){this.closeImageMenu(),this.linkMenu.dataset.active="true",this.linkMenu.style.display="block",this.addPopupEscapeHandler()}},{key:"openImageMenu",value:function(){this.closeLinkMenu(),this.imageMenu.dataset.active="true",this.imageMenu.style.display="block",this.addPopupEscapeHandler()}},{key:"closeLinkMenu",value:function(){this.linkMenu.dataset.active="false",this.linkMenu.style.display="none",this.removePopupEscapeHandler()}},{key:"closeImageMenu",value:function(){this.imageMenu.dataset.active="false",this.imageMenu.style.display="none",this.removePopupEscapeHandler()}},{key:"popupEscapeHandler",value:function(t){27===t.which&&(this.closeImageMenu(),this.closeLinkMenu())}},{key:"addPopupEscapeHandler",value:function(){this.removePopupEscapeHandler(),this.editor.addEventListener("keyup",this.bound_popupEscapeHandler)}},{key:"removePopupEscapeHandler",value:function(){this.editor.removeEventListener("keyup",this.bound_popupEscapeHandler)}},{key:"setContent",value:function(t){this.clearContent(),this.body.innerHTML=t}},{key:"clearContent",value:function(){this.body.innerHTML=""}},{key:"clearFiles",value:function(){this.files=[],this.filesSection.innerHTML=""}},{key:"getTextContent",value:function(){return this.body.querySelector("#placeholder-node")?"":this.body.textContent}},{key:"scrubHTML",value:function(t){var e=document.createElement("div"),o=document.createElement("div");return e.innerHTML=t,o.append(document.createTextNode(e.textContent)),o}},{key:"toolbarState",value:function(){var t=this;this.options.toolbarOptions.forEach((function(e){var o=t.toolbar.querySelector("#toolbar-".concat(e));e.includes("justify")||e.includes("list")||(document.queryCommandState(e)?o.querySelector("path").setAttribute("fill",t.options.activeOptionColor):o.querySelector("path").setAttribute("fill","#333"))}))}},{key:"establishBrowser",value:function(){this.isOpera=!!window.opr&&!!opr.addons||!!window.opera||navigator.userAgent.indexOf(" OPR/")>=0,this.isFirefox="undefined"!=typeof InstallTrigger,this.isSafari=/constructor/i.test(window.HTMLElement)||"[object SafariRemoteNotification]"===(!window.safari||"undefined"!=typeof safari&&safari.pushNotification).toString(),this.isIE=!!document.documentMode,this.isEdge=!this.isIE&&!!window.StyleMedia,this.isChrome=!(!window.chrome||!window.chrome.webstore&&!window.chrome.runtime),this.isBlink=(this.isChrome||this.isOpera)&&!!window.CSS}},{key:"isEditorInFocus",value:function(){var t=this;return function e(o){return o===t.editor||o!==document.body&&o.parentNode&&e(o.parentNode)}(document.activeElement)}}])&&n(c.prototype,u),d&&n(c,d),t}();t.default=c})?n.apply(e,i):n)||(t.exports=a)},5:function(t,e,o){var n,i,a;i=[e,o(0)],void 0===(a="function"==typeof(n=function(t,e){"use strict";var o;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(o=e)&&o.__esModule?o:{default:o},t.default=function t(o){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),o.bindingHandlers.striveneditor={init:function(t,n,i,a,r){var l=n(),s=o.utils.unwrapObservable(l);new e.default(s)}}}})?n.apply(e,i):n)||(t.exports=a)}})})); +\ No newline at end of file diff --git a/dist/ko-striveneditor.js.LICENSE b/dist/ko-striveneditor.js.LICENSE @@ -1,5 +1,5 @@ -/*!*********************************!*\ - !*** ./src/ko-striveneditor.js ***! - \*********************************/ - -/*! no static exports found */ +/* + @license/i + * Font Awesome Free 5.11.2 by @fontawesome - https://fontawesome.com + * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) + */ diff --git a/dist/striveneditor.js b/dist/striveneditor.js @@ -1,2 +1,8 @@ /*! For license information please see striveneditor.js.LICENSE */ -!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.striveneditor=t():n.striveneditor=t()}(window,(function(){return function(n){var t={};function e(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return n[o].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=n,e.c=t,e.d=function(n,t,o){e.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:o})},e.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},e.t=function(n,t){if(1&t&&(n=e(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var o=Object.create(null);if(e.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var i in n)e.d(o,i,function(t){return n[t]}.bind(null,i));return o},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.p="",e(e.s="./src/striveneditor.js")}({"./src/striveneditor.js":function(module,exports,__webpack_require__){eval('var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) {\n if (true) {\n !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === \'function\' ?\n\t\t\t\t(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n } else { var mod; }\n})(this, function (_exports) {\n "use strict";\n\n Object.defineProperty(_exports, "__esModule", {\n value: true\n });\n _exports["default"] = void 0;\n\n function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }\n\n function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\n function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }\n\n function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }\n\n function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\n function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }\n\n function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\n function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n var EXTENSIONS = [".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".tif", ".jpeg", ".jpg", ".gif", ".bmp", ".txt", ".csv", ".png", ".msg", ".wav", ".mp3", ".mp4", ".zip", ".rtf", ".eps", ".ai", ".psd", ".avi", ".mov", ".wmv", ".cfg", ".wss", ".vsd", ".vsdx", ".tsd", ".lic"];\n var FONTPACK = "fas";\n var OPTIONGROUPS = {\n textDecoration: {\n menu: {\n viewBox: "0 0 1792 1792",\n d: "M789 559l-170 450q33 0 136.5 2t160.5 2q19 0 57-2-87-253-184-452zm-725 1105l2-79q23-7 56-12.5t57-10.5 49.5-14.5 44.5-29 31-50.5l237-616 280-724h128q8 14 11 21l205 480q33 78 106 257.5t114 274.5q15 34 58 144.5t72 168.5q20 45 35 57 19 15 88 29.5t84 20.5q6 38 6 57 0 5-.5 13.5t-.5 12.5q-63 0-190-8t-191-8q-76 0-215 7t-178 8q0-43 4-78l131-28q1 0 12.5-2.5t15.5-3.5 14.5-4.5 15-6.5 11-8 9-11 2.5-14q0-16-31-96.5t-72-177.5-42-100l-450-2q-26 58-76.5 195.5t-50.5 162.5q0 22 14 37.5t43.5 24.5 48.5 13.5 57 8.5 41 4q1 19 1 58 0 9-2 27-58 0-174.5-10t-174.5-10q-8 0-26.5 4t-21.5 4q-80 14-188 14z"\n },\n group: [{\n bold: {\n viewBox: "0 0 1792 1792",\n d: "M747 1521q74 32 140 32 376 0 376-335 0-114-41-180-27-44-61.5-74t-67.5-46.5-80.5-25-84-10.5-94.5-2q-73 0-101 10 0 53-.5 159t-.5 158q0 8-1 67.5t-.5 96.5 4.5 83.5 12 66.5zm-14-746q42 7 109 7 82 0 143-13t110-44.5 74.5-89.5 25.5-142q0-70-29-122.5t-79-82-108-43.5-124-14q-50 0-130 13 0 50 4 151t4 152q0 27-.5 80t-.5 79q0 46 1 69zm-541 889l2-94q15-4 85-16t106-27q7-12 12.5-27t8.5-33.5 5.5-32.5 3-37.5.5-34v-65.5q0-982-22-1025-4-8-22-14.5t-44.5-11-49.5-7-48.5-4.5-30.5-3l-4-83q98-2 340-11.5t373-9.5q23 0 68 .5t68 .5q70 0 136.5 13t128.5 42 108 71 74 104.5 28 137.5q0 52-16.5 95.5t-39 72-64.5 57.5-73 45-84 40q154 35 256.5 134t102.5 248q0 100-35 179.5t-93.5 130.5-138 85.5-163.5 48.5-176 14q-44 0-132-3t-132-3q-106 0-307 11t-231 12z"\n }\n }, {\n italic: {\n viewBox: "0 0 1792 1792",\n d: "M384 1662l17-85q22-7 61.5-16.5t72-19 59.5-23.5q28-35 41-101 1-7 62-289t114-543.5 52-296.5v-25q-24-13-54.5-18.5t-69.5-8-58-5.5l19-103q33 2 120 6.5t149.5 7 120.5 2.5q48 0 98.5-2.5t121-7 98.5-6.5q-5 39-19 89-30 10-101.5 28.5t-108.5 33.5q-8 19-14 42.5t-9 40-7.5 45.5-6.5 42q-27 148-87.5 419.5t-77.5 355.5q-2 9-13 58t-20 90-16 83.5-6 57.5l1 18q17 4 185 31-3 44-16 99-11 0-32.5 1.5t-32.5 1.5q-29 0-87-10t-86-10q-138-2-206-2-51 0-143 9t-121 11z"\n }\n }, {\n underline: {\n viewBox: "0 0 1792 1792",\n d: "M176 223q-37-2-45-4l-3-88q13-1 40-1 60 0 112 4 132 7 166 7 86 0 168-3 116-4 146-5 56 0 86-2l-1 14 2 64v9q-60 9-124 9-60 0-79 25-13 14-13 132 0 13 .5 32.5t.5 25.5l1 229 14 280q6 124 51 202 35 59 96 92 88 47 177 47 104 0 191-28 56-18 99-51 48-36 65-64 36-56 53-114 21-73 21-229 0-79-3.5-128t-11-122.5-13.5-159.5l-4-59q-5-67-24-88-34-35-77-34l-100 2-14-3 2-86h84l205 10q76 3 196-10l18 2q6 38 6 51 0 7-4 31-45 12-84 13-73 11-79 17-15 15-15 41 0 7 1.5 27t1.5 31q8 19 22 396 6 195-15 304-15 76-41 122-38 65-112 123-75 57-182 89-109 33-255 33-167 0-284-46-119-47-179-122-61-76-83-195-16-80-16-237v-333q0-188-17-213-25-36-147-39zm1488 1409v-64q0-14-9-23t-23-9h-1472q-14 0-23 9t-9 23v64q0 14 9 23t23 9h1472q14 0 23-9t9-23z"\n }\n }, {\n strikethrough: {\n viewBox: "0 0 1792 1792",\n d: "M1760 896q14 0 23 9t9 23v64q0 14-9 23t-23 9h-1728q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h1728zm-1277-64q-28-35-51-80-48-98-48-188 0-181 134-309 133-127 393-127 50 0 167 19 66 12 177 48 10 38 21 118 14 123 14 183 0 18-5 45l-12 3-84-6-14-2q-50-149-103-205-88-91-210-91-114 0-182 59-67 58-67 146 0 73 66 140t279 129q69 20 173 66 58 28 95 52h-743zm507 256h411q7 39 7 92 0 111-41 212-23 56-71 104-37 35-109 81-80 48-153 66-80 21-203 21-114 0-195-23l-140-40q-57-16-72-28-8-8-8-22v-13q0-108-2-156-1-30 0-68l2-37v-44l102-2q15 34 30 71t22.5 56 12.5 27q35 57 80 94 43 36 105 57 59 22 132 22 64 0 139-27 77-26 122-86 47-61 47-129 0-84-81-157-34-29-137-71z"\n }\n }, {\n removeFormat: {\n viewBox: "0 0 640 512",\n d: "M336 416h-11.17l9.26-27.77L267 336.4 240.49 416H208a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h128a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm297.82 42.1L377 259.59 426.17 112H544v32a16 16 0 0 0 16 16h32a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16H176a16 16 0 0 0-16 16v43.9L45.46 3.38A16 16 0 0 0 23 6.19L3.37 31.46a16 16 0 0 0 2.81 22.45l588.36 454.72a16 16 0 0 0 22.46-2.81l19.64-25.27a16 16 0 0 0-2.82-22.45zM309.91 207.76L224 141.36V112h117.83z"\n }\n }]\n },\n listOptions: {\n menu: {\n viewBox: "0 0 1792 1792",\n d: "M256 1312v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm1536 768v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5zm-1536-1152v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm1536 768v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5z"\n },\n group: [{\n insertOrderedList: {\n viewBox: "0 0 1792 1792",\n d: "M381 1620q0 80-54.5 126t-135.5 46q-106 0-172-66l57-88q49 45 106 45 29 0 50.5-14.5t21.5-42.5q0-64-105-56l-26-56q8-10 32.5-43.5t42.5-54 37-38.5v-1q-16 0-48.5 1t-48.5 1v53h-106v-152h333v88l-95 115q51 12 81 49t30 88zm2-627v159h-362q-6-36-6-54 0-51 23.5-93t56.5-68 66-47.5 56.5-43.5 23.5-45q0-25-14.5-38.5t-39.5-13.5q-46 0-81 58l-85-59q24-51 71.5-79.5t105.5-28.5q73 0 123 41.5t50 112.5q0 50-34 91.5t-75 64.5-75.5 50.5-35.5 52.5h127v-60h105zm1409 319v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-14 9-23t23-9h1216q13 0 22.5 9.5t9.5 22.5zm-1408-899v99h-335v-99h107q0-41 .5-121.5t.5-121.5v-12h-2q-8 17-50 54l-71-76 136-127h106v404h108zm1408 387v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-14 9-23t23-9h1216q13 0 22.5 9.5t9.5 22.5zm0-512v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5z"\n }\n }, {\n insertUnorderedList: {\n viewBox: "0 0 1792 1792",\n d: "M384 1408q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm0-512q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm1408 416v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5zm-1408-928q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm1408 416v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5zm0-512v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5"\n }\n }]\n },\n textAlign: {\n menu: {\n viewBox: "0 0 1792 1792",\n d: "M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45z"\n },\n group: [{\n indent: {\n viewBox: "0 0 1792 1792",\n d: "M352 832q0 14-9 23l-288 288q-9 9-23 9-13 0-22.5-9.5t-9.5-22.5v-576q0-13 9.5-22.5t22.5-9.5q14 0 23 9l288 288q9 9 9 23zm1440 480v192q0 13-9.5 22.5t-22.5 9.5h-1728q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1728q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1088q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1088q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1088q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1088q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1728q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1728q13 0 22.5 9.5t9.5 22.5z"\n }\n }, {\n justifyLeft: {\n viewBox: "0 0 1792 1792",\n d: "M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-1280q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1280q26 0 45 19t19 45zm256-384v128q0 26-19 45t-45 19h-1536q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1536q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-1152q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1152q26 0 45 19t19 45z"\n }\n }, {\n justifyCenter: {\n viewBox: "0 0 1792 1792",\n d: "M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-896q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h896q26 0 45 19t19 45zm256-384v128q0 26-19 45t-45 19h-1408q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1408q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-640q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h640q26 0 45 19t19 45z"\n }\n }, {\n justifyRight: {\n viewBox: "0 0 1792 1792",\n d: "M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1280q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1280q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1536q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1536q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1152q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1152q26 0 45 19t19 45z"\n }\n }]\n },\n attachments: {\n menu: {\n viewBox: "0 0 1792 1792",\n d: "M1596 1385q0 117-79 196t-196 79q-135 0-235-100l-777-776q-113-115-113-271 0-159 110-270t269-111q158 0 273 113l605 606q10 10 10 22 0 16-30.5 46.5t-46.5 30.5q-13 0-23-10l-606-607q-79-77-181-77-106 0-179 75t-73 181q0 105 76 181l776 777q63 63 145 63 64 0 106-42t42-106q0-82-63-145l-581-581q-26-24-60-24-29 0-48 19t-19 48q0 32 25 59l410 410q10 10 10 22 0 16-31 47t-47 31q-12 0-22-10l-410-410q-63-61-63-149 0-82 57-139t139-57q88 0 149 63l581 581q100 98 100 235z"\n },\n group: [{\n attachment: {\n viewBox: "0 0 1792 1792",\n d: "M1596 1385q0 117-79 196t-196 79q-135 0-235-100l-777-776q-113-115-113-271 0-159 110-270t269-111q158 0 273 113l605 606q10 10 10 22 0 16-30.5 46.5t-46.5 30.5q-13 0-23-10l-606-607q-79-77-181-77-106 0-179 75t-73 181q0 105 76 181l776 777q63 63 145 63 64 0 106-42t42-106q0-82-63-145l-581-581q-26-24-60-24-29 0-48 19t-19 48q0 32 25 59l410 410q10 10 10 22 0 16-31 47t-47 31q-12 0-22-10l-410-410q-63-61-63-149 0-82 57-139t139-57q88 0 149 63l581 581q100 98 100 235z"\n }\n }, {\n link: {\n viewBox: "0 0 1792 1792",\n d: "M1520 1216q0-40-28-68l-208-208q-28-28-68-28-42 0-72 32 3 3 19 18.5t21.5 21.5 15 19 13 25.5 3.5 27.5q0 40-28 68t-68 28q-15 0-27.5-3.5t-25.5-13-19-15-21.5-21.5-18.5-19q-33 31-33 73 0 40 28 68l206 207q27 27 68 27 40 0 68-26l147-146q28-28 28-67zm-703-705q0-40-28-68l-206-207q-28-28-68-28-39 0-68 27l-147 146q-28 28-28 67 0 40 28 68l208 208q27 27 68 27 42 0 72-31-3-3-19-18.5t-21.5-21.5-15-19-13-25.5-3.5-27.5q0-40 28-68t68-28q15 0 27.5 3.5t25.5 13 19 15 21.5 21.5 18.5 19q33-31 33-73zm895 705q0 120-85 203l-147 146q-83 83-203 83-121 0-204-85l-206-207q-83-83-83-203 0-123 88-209l-88-88q-86 88-208 88-120 0-204-84l-208-208q-84-84-84-204t85-203l147-146q83-83 203-83 121 0 204 85l206 207q83 83 83 203 0 123-88 209l88 88q86-88 208-88 120 0 204 84l208 208q84 84 84 204z"\n }\n }, {\n image: {\n viewBox: "0 0 2048 1792",\n d: "M704 576q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm1024 384v448h-1408v-192l320-320 160 160 512-512zm96-704h-1600q-13 0-22.5 9.5t-9.5 22.5v1216q0 13 9.5 22.5t22.5 9.5h1600q13 0 22.5-9.5t9.5-22.5v-1216q0-13-9.5-22.5t-22.5-9.5zm160 32v1216q0 66-47 113t-113 47h-1600q-66 0-113-47t-47-113v-1216q0-66 47-113t113-47h1600q66 0 113 47t47 113z"\n }\n }]\n }\n };\n var DEFAULTOPTIONS = ["bold", "italic", "underline", "strikethrough", "removeFormat", "insertOrderedList", "insertUnorderedList", "indent", "justifyLeft", "justifyCenter", "justifyRight", "attachment", "link", "image"];\n var ACTIVEOPTIONCOLOR = "#ddd";\n\n var StrivenEditor =\n /*#__PURE__*/\n function () {\n function StrivenEditor(el, options) {\n var _this = this;\n\n _classCallCheck(this, StrivenEditor);\n\n this.establishBrowser();\n this.range = new Range();\n this.files = [];\n this.optionGroups = OPTIONGROUPS;\n\n if (options) {\n this.options = options;\n options.fontPack || (this.options.fontPack = FONTPACK);\n options.extensions || (this.options.extensions = EXTENSIONS);\n options.toolbarOptions || (this.options.toolbarOptions = DEFAULTOPTIONS);\n options.activeOptionColor || (this.options.activeOptionColor = ACTIVEOPTIONCOLOR);\n } else {\n this.options = {\n fontPack: FONTPACK,\n extensions: EXTENSIONS,\n toolbarOptions: DEFAULTOPTIONS,\n activeOptionColor: ACTIVEOPTIONCOLOR\n };\n }\n\n this.initEditor(el);\n this.initResponsive();\n this.initOverflow(); // Safari Fix\n // const documentMouseUp = document.onmouseup;\n // document.onmouseup = e => {\n // documentMouseUp && documentMouseUp();\n // this.range = this.getRange();\n // }\n\n el.StrivenEditor = function () {\n return _this;\n };\n }\n\n _createClass(StrivenEditor, [{\n key: "initEditor",\n value: function initEditor(el) {\n var _this2 = this;\n\n this.editor = el;\n this.toolbar = this.initToolbar();\n this.body = this.initBody();\n this.linkMenu = this.initLinkMenu();\n this.imageMenu = this.initImageMenu();\n this.metaDataSection = this.initMetaDataSection();\n this.filesSection = this.initFilesSection();\n this.editor.style.border = "2px solid #ddd";\n this.editor.style.display = "flex";\n this.editor.style.position = "relative";\n this.editor.style.flexDirection = "column";\n this.editor.style.fontFamily = "Arial"; // this.editor.style.minHeight = "auto";\n // this.editor.style.maxHeight = "auto";\n\n this.editor.style.maxWidth = "100%"; // Toolbar Hide\n\n if (this.options.toolbarHide) {\n this.customToolbarButton && (this.customToolbarButton.style.display = "none");\n this.toolbarOptionsGroup.style.display = "none";\n var bodyFocus = this.body.onfocus;\n\n this.body.onfocus = function () {\n bodyFocus && bodyFocus();\n\n _this2.overflow();\n\n _this2.toolbarSlideUp();\n };\n\n var bodyBlur = this.body.onblur;\n\n this.body.onblur = function () {\n bodyBlur && bodyBlur();\n\n _this2.overflow();\n\n setTimeout(function () {\n if (document.activeElement !== _this2.body && document.activeElement !== _this2.linkMenu.querySelector(\'input\') && document.activeElement !== _this2.imageMenu.querySelectorAll(\'input\')[0] && document.activeElement !== _this2.imageMenu.querySelectorAll(\'input\')[1] && document.activeElement !== _this2.imageMenu.querySelectorAll(\'input\')[2]) {\n _this2.toolbarSlideDown();\n }\n }, 2000);\n };\n } // Toolbar Options\n\n\n this.toolbarOptions.forEach(function (optionEl) {\n // Assign Styles\n // optionEl.style.padding = "0 10px";\n optionEl.style.cursor = "pointer";\n optionEl.style.userSelect = "none"; // Execute Toolbar Commands\n\n var optionElClick = optionEl.onclick;\n\n optionEl.onclick = function (e) {\n var indents = function indents() {\n var indents = _this2.body.querySelectorAll(\'blockquote\');\n\n _toConsumableArray(indents).forEach(function (indent) {\n return indent.style.margin = "0 0 0 40px";\n });\n };\n\n _this2.body.focus(); // Safari Fix\n // window.getSelection().removeAllRanges();\n // window.getSelection().addRange(this.range);\n\n\n var command = optionEl.id.split("-")[1];\n\n switch (command) {\n case "insertOrderedList":\n if (_this2.isFirefox) {\n document.execCommand("indent");\n document.execCommand(command);\n indents();\n } else if (_this2.isEdge) {\n document.execCommand(command);\n\n _toConsumableArray(document.querySelectorAll(\'ol\')).forEach(function (ol) {\n return ol.style.marginLeft = "40px";\n });\n } else {\n document.execCommand("indent", true);\n document.execCommand(command, true);\n }\n\n break;\n\n case "insertUnorderedList":\n if (_this2.isFirefox) {\n document.execCommand("indent");\n document.execCommand(command);\n indents();\n } else if (_this2.isEdge) {\n document.execCommand(command);\n\n _toConsumableArray(document.querySelectorAll(\'ul\')).forEach(function (ul) {\n return ul.style.marginLeft = "40px";\n });\n } else {\n document.execCommand("indent", true);\n document.execCommand(command, true);\n }\n\n break;\n\n case "attachment":\n var attachmentInput = document.createElement("input");\n attachmentInput.style.display = "none";\n attachmentInput.type = "file";\n\n attachmentInput.onchange = function (e) {\n return _this2.attachFile(attachmentInput.files[0]);\n };\n\n attachmentInput.click();\n break;\n\n case "link":\n // const currentRange = this.getRange();\n // currentRange.setStart(this.body, currentRange.endOffset - currentRange.commonAncestorContainer.textContent.length)\n if (_this2.linkMenu.dataset.active === "true") {\n _this2.closeLinkMenu();\n } else {\n _this2.linkMenuSlideIn();\n\n _this2.range = _this2.getRange();\n\n _this2.linkMenu.querySelector(\'input\').focus();\n }\n\n break;\n\n case "image":\n if (_this2.imageMenu.dataset.active === "true") {\n _this2.closeImageMenu();\n } else {\n _this2.imageMenuSlideIn();\n\n _this2.range = _this2.getRange();\n\n _this2.imageMenu.querySelector(\'input\').focus();\n }\n\n break;\n\n default:\n if (_this2.isFirefox || _this2.isEdge) {\n document.execCommand(command);\n command === \'indent\' && indents();\n } else {\n document.execCommand(command, true);\n }\n\n _this2.toolbarState();\n\n break;\n }\n\n optionElClick && optionElClick();\n };\n });\n this.editor.appendChild(this.toolbar);\n this.editor.appendChild(this.body);\n this.editor.appendChild(this.linkMenu);\n this.editor.appendChild(this.imageMenu);\n this.editor.appendChild(this.metaDataSection);\n this.editor.appendChild(this.filesSection); // Reposition Toolbar\n\n if (this.options.toolbarBottom) {\n this.editor.removeChild(this.toolbar);\n this.editor.append(this.toolbar);\n }\n }\n }, {\n key: "imageMenuSlideIn",\n value: function imageMenuSlideIn() {\n var that = this;\n this.openImageMenu();\n var opacity = 0;\n var right = this.editor.offsetWidth / 4;\n var id = setInterval(frame, 5);\n this.imageMenu.style.opacity = opacity;\n\n function frame() {\n if (right <= 10) {\n clearInterval(id);\n that.imageMenu.style.opacity = 1;\n } else {\n right -= 2.5;\n opacity += .01;\n that.imageMenu.style.opacity = "".concat(opacity);\n that.imageMenu.style.right = "".concat(right, "px");\n }\n }\n }\n }, {\n key: "linkMenuSlideIn",\n value: function linkMenuSlideIn() {\n var that = this;\n this.openLinkMenu();\n var opacity = 0;\n var right = this.editor.offsetWidth / 4;\n var id = setInterval(frame, 5);\n this.linkMenu.style.opacity = opacity;\n\n function frame() {\n if (right <= 10) {\n clearInterval(id);\n that.linkMenu.style.opacity = 1;\n } else {\n right -= 2.5;\n opacity += .01;\n that.linkMenu.style.opacity = "".concat(opacity);\n that.linkMenu.style.right = "".concat(right, "px");\n }\n }\n }\n }, {\n key: "toolbarSlideUp",\n value: function toolbarSlideUp() {\n var that = this;\n var height = this.toolbar.offsetHeight;\n var id = setInterval(frame, 5);\n\n function frame() {\n if (height >= 40) {\n that.customToolbarButton && (that.customToolbarButton.style.display = "flex");\n that.toolbarOptionsGroup.style.display = "flex";\n clearInterval(id);\n } else {\n height++;\n that.toolbar.style.minHeight = "".concat(height, "px");\n }\n }\n }\n }, {\n key: "toolbarSlideDown",\n value: function toolbarSlideDown() {\n var that = this;\n this.customToolbarButton && (this.customToolbarButton.style.display = "none");\n this.toolbarOptionsGroup.style.display = "none";\n var height = 40;\n var id = setInterval(frame, 5);\n\n function frame() {\n if (height === 0) {\n clearInterval(id);\n } else {\n height--;\n that.toolbar.style.minHeight = "".concat(height, "px");\n }\n }\n }\n }, {\n key: "initToolbar",\n value: function initToolbar() {\n var _this3 = this;\n\n var toolbar = document.createElement("div");\n this.toolbarOptionsGroup = document.createElement("div");\n var groups = Object.keys(this.optionGroups);\n toolbar.classList.add("toolbar");\n toolbar.style.display = "flex";\n toolbar.style.justifyContent = "space-between";\n toolbar.style.alignItems = "center";\n toolbar.style.flexWrap = "wrap";\n toolbar.style.minHeight = this.options.toolbarHide ? "0" : "40px";\n toolbar.style.position = "relative";\n this.toolbarOptionsGroup.classList.add("toolbar-options");\n this.toolbarOptionsGroup.style.margin = "0 10px";\n this.toolbarOptionsGroup.style.display = this.options.toolbarHide ? "none" : "flex"; //iterate groups\n\n groups.forEach(function (group) {\n // add menu to toolbarOptions\n var toolbarMenu = document.createElement("div"); // const toolbarMenuIcon = document.createElement("i");\n\n toolbarMenu.classList.add("toolbar-menu");\n toolbarMenu.id = "menu-".concat(group); // toolbarMenuIcon.classList.add(this.options.fontPack);\n // toolbarMenuIcon.classList.add(this.optionGroups[group].menu);\n\n toolbarMenu.appendChild(_this3.constructSVG(_this3.optionGroups[group].menu));\n\n _this3.toolbarOptionsGroup.appendChild(toolbarMenu); // add group to toolbarOptions\n\n\n var toolbarGroup = document.createElement("div");\n toolbarGroup.classList.add("toolbar-group");\n toolbarGroup.id = "group-".concat(group);\n\n _this3.options.toolbarOptions.forEach(function (option) {\n var toolbarOption = _this3.optionGroups[group].group.filter(function (group) {\n return group[option];\n })[0];\n\n if (toolbarOption) {\n var svgData = toolbarOption[option];\n\n var optionSpan = _this3.constructSVG(svgData);\n\n optionSpan.id = "toolbar-".concat(option);\n optionSpan.style.margin = "0 10px";\n toolbarGroup.appendChild(optionSpan);\n }\n });\n\n _this3.toolbarOptionsGroup.appendChild(toolbarGroup); // this.optionGroups[group].group.forEach((option) => {\n // const toolbarCommand = Object.keys(option)[0];\n // if(this.options.toolbarOptions.includes(toolbarCommand)){\n // const optionSpan = this.constructSVG(option[toolbarCommand]);\n // // const optionIcon = document.createElement("i");\n // optionSpan.id = `toolbar-${toolbarCommand}`;\n // optionSpan.style.margin = "0 10px";\n // // optionIcon.classList.add(this.options.fontPack);\n // // optionIcon.classList.add(option[toolbarCommand]);\n // // optionSpan.appendChild(optionIcon);\n // toolbarGroup.appendChild(optionSpan);\n // }\n // })\n // this.toolbarOptionsGroup.appendChild(toolbarGroup);\n\n }); // toolbar group for custom options\n\n var customOptions = this.options.toolbarOptions.filter(function (option) {\n return _typeof(option) === "object";\n });\n\n if (customOptions.length > 0) {\n this.customToolbarMenu = document.createElement("div");\n this.customToolbarMenu.classList.add("toolbar-menu");\n this.customToolbarMenu.id = "menu-custom";\n var customSVGViewBox = "0 0 1792 1792";\n var customSVGD = "M1088 1248v192q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h192q40 0 68 28t28 68zm0-512v192q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h192q40 0 68 28t28 68zm0-512v192q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h192q40 0 68 28t28 68z";\n this.customToolbarMenu.appendChild(this.constructSVG({\n viewBox: customSVGViewBox,\n d: customSVGD\n }));\n this.toolbarOptionsGroup.appendChild(this.customToolbarMenu);\n this.customToolbarGroup = document.createElement("div");\n this.customToolbarGroup.classList.add("toolbar-group");\n this.customToolbarGroup.id = "group-custom";\n customOptions.forEach(function (customOption) {\n var icon = customOption.icon,\n handler = customOption.handler;\n\n var optionSpan = _this3.constructSVG(icon);\n\n optionSpan.id = "toolbar-customOption";\n optionSpan.style.margin = "0 10px";\n\n optionSpan.onclick = function () {\n return handler();\n };\n\n _this3.customToolbarGroup.appendChild(optionSpan);\n });\n this.toolbarOptionsGroup.appendChild(this.customToolbarGroup);\n }\n\n toolbar.appendChild(this.toolbarOptionsGroup); //add toolbar-send\n\n if (this.options.customToolbarButton) {\n var customToolbarButton = document.createElement("div");\n customToolbarButton.id = "custom-toolbar-button";\n customToolbarButton.style.display = "none";\n customToolbarButton.style.color = "#fff";\n customToolbarButton.style.backgroundColor = "#5cb85c";\n customToolbarButton.style.minHeight = this.options.toolbarHide ? "40px" : this.toolbar.style.minHeight;\n customToolbarButton.style.width = "50px";\n customToolbarButton.style.textAlign = "center";\n customToolbarButton.style.justifyContent = "center";\n customToolbarButton.style.alignContent = "center";\n customToolbarButton.style.alignItems = "center";\n customToolbarButton.style.cursor = "pointer";\n customToolbarButton.style.border = "1px solid #4cae4c";\n customToolbarButton.style.alignSelf = "flex-end";\n\n customToolbarButton.onclick = function () {\n return _this3.options.customToolbarButton.handler();\n };\n\n !this.options.toolbarHide && (customToolbarButton.style.display = "flex");\n\n customToolbarButton.onmouseenter = function () {\n customToolbarButton.style.borderColor = _this3.options.customToolbarButton.hoverBorderColor;\n customToolbarButton.style.backgroundColor = _this3.options.customToolbarButton.hoverBackgroundColor;\n customToolbarButton.style.color = _this3.options.customToolbarButton.hoverColor;\n };\n\n customToolbarButton.onmouseleave = function () {\n customToolbarButton.style.borderColor = _this3.options.customToolbarButton.borderColor;\n customToolbarButton.style.backgroundColor = _this3.options.customToolbarButton.backgroundColor;\n customToolbarButton.style.color = _this3.options.customToolbarButton.color;\n };\n\n var customToolbarButtonSVG = this.constructSVG(this.options.customToolbarButton.svgData);\n customToolbarButtonSVG.querySelector(\'path\').setAttribute("fill", this.options.customToolbarButton.color);\n customToolbarButton.appendChild(customToolbarButtonSVG);\n toolbar.appendChild(customToolbarButton);\n }\n\n this.toolbarOptions = toolbar.querySelectorAll("span");\n this.toolbarGroups = _toConsumableArray(toolbar.getElementsByClassName("toolbar-group"));\n this.toolbarMenus = _toConsumableArray(toolbar.getElementsByClassName("toolbar-menu"));\n this.customToolbarButton = toolbar.querySelector("#custom-toolbar-button");\n this.toolbarMenus.push(this.customToolbarMenu);\n this.toolbarGroups.push(this.customToolbarGroup); // Remove menu that has no options enabled\n\n this.toolbarGroups.forEach(function (group) {\n if (group && group.children.length < 1) {\n var groupName = group.id.split("-")[1];\n\n var menu = _this3.toolbarMenus.filter(function (menu) {\n return menu.id.split("-")[1] === groupName;\n })[0];\n\n menu.remove();\n }\n });\n return toolbar;\n }\n }, {\n key: "initBody",\n value: function initBody() {\n var _this4 = this;\n\n var body = document.createElement("div");\n body.classList.add("body");\n body.contentEditable = "true";\n body.style.outline = "none";\n body.style.padding = "10px 20px";\n body.style.height = this.editor.style.height;\n body.style.minHeight = this.editor.style.minHeight;\n body.style.maxHeight = this.editor.style.maxHeight;\n this.editor.style.height = "auto";\n this.editor.style.minHeight = "auto";\n this.editor.style.maxHeight = "auto"; // Placeholder logic\n\n if (this.options.placeholder) {\n var placeholderNode = document.createElement("p");\n placeholderNode.id = "placeholder-node";\n placeholderNode.style.color = "#5f6368";\n placeholderNode.style.margin = "0";\n placeholderNode.textContent = this.options.placeholder;\n body.append(placeholderNode);\n var bodyFocus = body.onfocus;\n\n body.onfocus = function () {\n bodyFocus && bodyFocus();\n body.querySelector("#placeholder-node") === placeholderNode && _this4.clearContent();\n };\n\n var bodyBlur = body.onblur;\n\n body.onblur = function () {\n bodyBlur && bodyBlur();\n _this4.getContent().trim() === "" && body.append(placeholderNode);\n };\n } // Paste Handler\n\n\n body.onpaste = function (e) {\n function dataURLtoFile(dataurl, filename) {\n var arr = dataurl.split(\',\'),\n mime = arr[0].match(/:(.*?);/)[1],\n bstr = atob(arr[1]),\n n = bstr.length,\n u8arr = new Uint8Array(n);\n\n while (n--) {\n u8arr[n] = bstr.charCodeAt(n);\n }\n\n var file = new File([u8arr], filename, {\n type: mime\n });\n return new File([u8arr], "".concat(file.name, ".").concat(file.type.split(\'/\').pop()), {\n type: file.type\n });\n }\n\n var convertImage = function convertImage(file) {\n return new Promise(function (resolve, reject) {\n var reader = new FileReader();\n reader.readAsDataURL(file);\n\n reader.onload = function () {\n return resolve(reader.result);\n };\n\n reader.onerror = function (error) {\n return reject(error);\n };\n });\n };\n\n if (e.clipboardData.files.length > 0 && e.clipboardData.files[0].type.includes("image")) {\n convertImage(e.clipboardData.files[0]).then(function (res) {\n if (_this4.options.imageUrl) {\n _this4.getImage(res).then(function (data) {\n document.execCommand("insertImage", true, data.imageRef);\n })["catch"](function (err) {\n document.execCommand("insertImage", true, res);\n });\n } else {\n document.execCommand("insertImage", true, res);\n _this4.options.uploadOnPaste && _this4.attachFile(dataURLtoFile(res, "pastedimage"));\n }\n\n _this4.overflow();\n });\n } // sanitize of html\n\n\n if (_this4.options.sanitizePaste && e.clipboardData.types.includes("text/html")) {\n e.preventDefault();\n var pastedHtmlItem;\n\n for (var i = 0; i < e.clipboardData.items.length; i++) {\n var item = e.clipboardData.items[i];\n item.type === "text/html" && (pastedHtmlItem = item);\n }\n\n if (pastedHtmlItem) {\n pastedHtmlItem.getAsString(function (htmlString) {\n var range = _this4.getRange();\n\n range.insertNode(_this4.scrubHTML(htmlString));\n range.collapse();\n });\n }\n } // meta extraction on paste\n\n\n if (e.clipboardData.items.length > 0 && e.clipboardData.items[0].type === "text/plain") {\n e.clipboardData.items[0].getAsString(function (string) {\n if (_this4.options.metaUrl && _this4.validURL(string)) {\n _this4.getMeta(string).then(function (res) {\n var url = res.url,\n title = res.title,\n image = res.image,\n description = res.description;\n url && title && image && _this4.createMetaDataElement(url, image, title, description);\n });\n }\n });\n }\n\n _this4.overflow();\n }; // State of the editor\n\n\n var bodyKeyup = body.onkeyup;\n\n body.onkeyup = function (e) {\n bodyKeyup && bodyKeyup();\n _this4.range = _this4.getRange();\n\n if (_this4.options.submitOnEnter && e.keyCode === 13 && !e.shiftKey) {\n if (!document.queryCommandState(\'insertOrderedList\') && !document.queryCommandState(\'insertUnorderedList\')) {\n var hasText = !!_this4.getTextContent();\n var hasImage = !!body.querySelector(\'img\'); // remove break from enter\n\n if (hasText || hasImage) {\n var breaks = body.querySelectorAll(\'div\');\n var divBreak = breaks[breaks.length ? breaks.length - 1 : 0];\n divBreak && divBreak.remove();\n }\n\n var content = _this4.getContent();\n\n var files = _this4.getFiles();\n\n _this4.clearContent();\n\n _this4.clearFiles();\n\n if (files.length || hasText || hasImage) {\n _this4.options.submitOnEnter({\n content: (hasText || hasImage) && content,\n files: files\n });\n }\n }\n }\n\n _this4.toolbarState();\n };\n\n return body;\n }\n }, {\n key: "initLinkMenu",\n value: function initLinkMenu() {\n var _this5 = this;\n\n var linkMenu = document.createElement("div");\n var linkMenuForm = document.createElement("div");\n var linkMenuButton = document.createElement("button");\n var linkMenuFormLabel = document.createElement("p");\n var linkMenuFormInput = document.createElement("input");\n linkMenu.id = "link-menu";\n linkMenuButton.textContent = "Insert Link";\n linkMenuFormLabel.textContent = "Web Address";\n linkMenuFormInput.type = "text";\n linkMenuFormLabel.style.margin = "8px 10px 8px 0";\n linkMenuFormLabel.style.fontSize = "14px";\n linkMenuButton.style.cursor = "pointer";\n linkMenu.dataset.active = "false";\n linkMenu.style.display = "none";\n linkMenu.style.position = "absolute";\n linkMenu.style.right = "10px";\n linkMenu.style.bottom = "10px";\n linkMenu.style.backgroundColor = "#fff";\n linkMenu.style.border = "2px solid #ddd";\n linkMenu.style.padding = "10px 20px";\n linkMenu.style.zIndex = "1000";\n linkMenuFormLabel.style.width = "100%";\n linkMenuFormLabel.style.textAlign = "right";\n linkMenuFormLabel.style.marginRight = "10px";\n linkMenuFormInput.style.outline = "none";\n linkMenuFormInput.style.padding = "0 5px";\n linkMenuFormInput.placeholder = "Insert a Link";\n linkMenuForm.style.display = "flex";\n linkMenuForm.style.justifyContent = "space-between";\n linkMenuForm.style.margin = "5px 0";\n linkMenuButton.style["float"] = "right";\n linkMenuButton.style.padding = "6px 12px";\n linkMenuButton.style.border = "1px solid #4cae4c";\n linkMenuButton.style.backgroundColor = "#5cb85c";\n linkMenuButton.style.fontSize = "14px";\n linkMenuButton.style.color = "#fff";\n linkMenuButton.style.outline = "none";\n\n linkMenuButton.onmouseenter = function () {\n return linkMenuButton.style.backgroundColor = "#4cae4c";\n };\n\n linkMenuButton.onmouseleave = function () {\n return linkMenuButton.style.backgroundColor = "#5cb85c";\n };\n\n linkMenuButton.onclick = function (e) {\n var linkValue = linkMenuFormInput.value;\n\n if (linkValue) {\n window.getSelection().removeAllRanges();\n window.getSelection().addRange(_this5.range);\n\n if (_this5.isFirefox || _this5.isEdge) {\n document.execCommand("createLink", false, linkValue);\n } else {\n document.execCommand("createLink", true, linkValue);\n }\n\n if (_this5.options.metaUrl && _this5.validURL(linkValue)) {\n _this5.getMeta(linkValue).then(function (res) {\n var url = res.url,\n image = res.image,\n title = res.title,\n description = res.description;\n url && image && title && _this5.createMetaDataElement(url, image, title, description);\n });\n }\n\n var bodyLinks = _this5.body.querySelectorAll("a");\n\n _toConsumableArray(bodyLinks).forEach(function (link) {\n return !_this5.isFirefox && (link.contentEditable = \'false\');\n });\n\n linkMenuFormInput.value = "";\n\n _this5.closeLinkMenu();\n } else {\n _this5.body.focus();\n\n _this5.closeLinkMenu();\n }\n };\n\n linkMenuForm.appendChild(linkMenuFormLabel);\n linkMenuForm.appendChild(linkMenuFormInput);\n linkMenu.appendChild(linkMenuForm);\n linkMenu.appendChild(linkMenuButton);\n return linkMenu;\n }\n }, {\n key: "initImageMenu",\n value: function initImageMenu() {\n var _this6 = this;\n\n var imageMenu = document.createElement("div");\n var imageMenuForm = document.createElement("div");\n var imageMenuButton = document.createElement("button");\n var imageMenuFormLabel = document.createElement("p");\n var imageMenuFormSourceInput = document.createElement("input");\n imageMenu.id = "image-menu";\n imageMenuButton.textContent = "Insert Image";\n imageMenuFormLabel.textContent = "Image URL";\n imageMenuFormSourceInput.type = "text";\n imageMenuFormLabel.style.margin = "8px 10px 8px 0";\n imageMenuFormLabel.style.fontSize = "14px";\n imageMenuButton.style.cursor = "pointer";\n imageMenu.dataset.active = "false";\n imageMenu.style.display = "none";\n imageMenu.style.position = "absolute";\n imageMenu.style.right = "10px";\n imageMenu.style.bottom = "10px";\n imageMenu.style.backgroundColor = "#fff";\n imageMenu.style.border = "2px solid #ddd";\n imageMenu.style.padding = "10px 20px";\n imageMenu.style.zIndex = "1000";\n imageMenuFormLabel.style.width = "100%";\n imageMenuFormLabel.style.textAlign = "right";\n imageMenuFormLabel.style.marginRight = "10px";\n imageMenuFormSourceInput.style.outline = "none";\n imageMenuFormSourceInput.style.padding = "0 5px";\n imageMenuFormSourceInput.placeholder = "Insert a Link";\n imageMenuForm.style.display = "flex";\n imageMenuForm.style.justifyContent = "space-between";\n imageMenuForm.style.margin = "5px 0";\n imageMenuButton.style["float"] = "right";\n imageMenuButton.style.padding = "6px 12px";\n imageMenuButton.style.border = "1px solid #4cae4c";\n imageMenuButton.style.backgroundColor = "#5cb85c";\n imageMenuButton.style.fontSize = "14px";\n imageMenuButton.style.color = "#fff";\n imageMenuButton.style.outline = "none";\n\n imageMenuButton.onmouseenter = function () {\n return imageMenuButton.style.backgroundColor = "#4cae4c";\n };\n\n imageMenuButton.onmouseleave = function () {\n return imageMenuButton.style.backgroundColor = "#5cb85c";\n };\n\n imageMenuForm.appendChild(imageMenuFormLabel);\n imageMenuForm.appendChild(imageMenuFormSourceInput); // Height Input Form\n\n var imageMenuHeightForm = imageMenuForm.cloneNode(true);\n var imageMenuHeightFormInput = imageMenuHeightForm.querySelector(\'input\');\n var imageMenuHeightFormLabel = imageMenuHeightForm.querySelector(\'p\');\n imageMenuHeightFormInput.placeholder = "Image Height";\n imageMenuHeightFormLabel.textContent = "Height"; // Width Input Form\n\n var imageMenuWidthForm = imageMenuForm.cloneNode(true);\n var imageMenuWidthFormInput = imageMenuWidthForm.querySelector(\'input\');\n var imageMenuWidthFormLabel = imageMenuWidthForm.querySelector(\'p\');\n imageMenuWidthFormInput.placeholder = "Image Width";\n imageMenuWidthFormLabel.textContent = "Width";\n\n imageMenuButton.onclick = function (e) {\n var linkValue = imageMenuFormSourceInput.value;\n var heightValue = imageMenuHeightFormInput.value;\n var widthValue = imageMenuWidthFormInput.value;\n\n if (linkValue) {\n window.getSelection().removeAllRanges();\n window.getSelection().addRange(_this6.range);\n\n if (_this6.isFirefox || _this6.isEdge) {\n document.execCommand("insertImage", false, linkValue);\n } else {\n document.execCommand("insertImage", true, linkValue);\n }\n\n var insertedImage = _toConsumableArray(_this6.body.querySelectorAll("img")).filter(function (img) {\n return img.src === linkValue;\n });\n\n insertedImage = insertedImage[insertedImage.length - 1];\n insertedImage && (insertedImage.style.height = "".concat(heightValue, "px"));\n insertedImage && (insertedImage.style.width = "".concat(widthValue, "px"));\n imageMenuHeightFormInput.value = "";\n imageMenuWidthFormInput.value = "";\n imageMenuFormSourceInput.value = "";\n\n _this6.closeImageMenu();\n } else {\n _this6.body.focus();\n\n _this6.closeImageMenu();\n }\n };\n\n imageMenu.appendChild(imageMenuHeightForm);\n imageMenu.appendChild(imageMenuWidthForm);\n imageMenu.appendChild(imageMenuForm);\n imageMenu.appendChild(imageMenuButton);\n return imageMenu;\n }\n }, {\n key: "initMetaDataSection",\n value: function initMetaDataSection() {\n var metaDataSection = document.createElement("div");\n metaDataSection.classList.add("metadata-section");\n metaDataSection.style.display = "flex";\n metaDataSection.style.flexWrap = "wrap";\n metaDataSection.style.zIndex = "500";\n return metaDataSection;\n }\n }, {\n key: "initFilesSection",\n value: function initFilesSection() {\n var _this7 = this;\n\n var filesSection = document.createElement("div");\n filesSection.classList.add("files-section");\n filesSection.style.display = "flex";\n filesSection.style.flexWrap = "wrap";\n filesSection.style.zIndex = "500";\n\n this.body.ondragenter = function (e) {\n _this7.body.style.backgroundColor = "#ddd";\n };\n\n this.body.ondragleave = function (e) {\n _this7.body.style.backgroundColor = "inherit";\n };\n\n this.body.ondrop = function (e) {\n _this7.body.style.backgroundColor = "inherit";\n e.preventDefault();\n var file = e.dataTransfer.files && e.dataTransfer.files[0];\n\n _this7.attachFile(file);\n };\n\n return filesSection;\n }\n }, {\n key: "createFileElement",\n value: function createFileElement(name, size) {\n var _this8 = this;\n\n var fileEl = document.createElement("div");\n var fileNameEl = document.createElement("h4");\n var fileSizeEl = document.createElement("p");\n var removeFileEl = document.createElement("p");\n fileNameEl.textContent = name;\n fileSizeEl.textContent = size;\n removeFileEl.textContent = "X";\n fileEl.dataset.fileindex = this.files.length - 1;\n fileEl.style.width = "100%";\n fileEl.style.display = "flex";\n fileEl.style.flexDirection = "column";\n fileEl.style.margin = "10px";\n fileEl.style.position = "relative";\n fileNameEl.style.fontWeight = "bold";\n fileNameEl.style.margin = "0";\n fileSizeEl.style.fontSize = "12px";\n fileSizeEl.style.margin = "2px 0";\n removeFileEl.style.margin = "0";\n removeFileEl.style.userSelect = "none";\n removeFileEl.style.color = "black";\n removeFileEl.style.position = "absolute";\n removeFileEl.style.right = "5px";\n removeFileEl.style.top = "-5px";\n removeFileEl.style.cursor = "pointer";\n removeFileEl.style.backgroundColor = "#fff";\n\n removeFileEl.onmouseenter = function () {\n return removeFileEl.style.color = "#ddd";\n };\n\n removeFileEl.onmouseleave = function () {\n return removeFileEl.style.color = "black";\n };\n\n removeFileEl.onclick = function (e) {\n _this8.files.splice(e.target.parentElement.dataset.fileindex, 1);\n\n e.target.parentElement.remove();\n };\n\n fileEl.appendChild(fileNameEl);\n fileEl.appendChild(fileSizeEl);\n fileEl.appendChild(removeFileEl);\n this.filesSection.appendChild(fileEl);\n }\n }, {\n key: "createMetaDataElement",\n value: function createMetaDataElement(url, img, title, description) {\n var metaItemEl = document.createElement("div");\n var metaLinkEl = document.createElement("a");\n var metaImageEl = document.createElement("img");\n var metaDataEl = document.createElement("div");\n var metaDataTitleEl = document.createElement("h4");\n var metaDataDescriptionEl = document.createElement("p");\n var removeMetaDataEl = document.createElement("span");\n metaLinkEl.href = url;\n metaImageEl.src = img;\n metaDataTitleEl.textContent = title;\n metaDataDescriptionEl.textContent = description;\n removeMetaDataEl.textContent = "X";\n metaLinkEl.target = "blank";\n metaItemEl.style.width = "100%";\n metaItemEl.style.display = "flex";\n metaItemEl.style.margin = "10px";\n metaItemEl.style.position = "relative";\n metaImageEl.style.marginRight = "10px";\n metaImageEl.style.height = "50px";\n metaImageEl.style.width = "75px";\n metaDataTitleEl.style.fontWeight = "bold";\n metaDataTitleEl.style.margin = "0";\n metaDataDescriptionEl.style.margin = "0";\n removeMetaDataEl.style.userSelect = "none";\n removeMetaDataEl.style.color = "black";\n removeMetaDataEl.style.position = "absolute";\n removeMetaDataEl.style.right = "5px";\n removeMetaDataEl.style.top = "-5px";\n removeMetaDataEl.style.cursor = "pointer";\n removeMetaDataEl.style.backgroundColor = "#fff";\n\n removeMetaDataEl.onmouseenter = function () {\n return removeMetaDataEl.style.color = "#ddd";\n };\n\n removeMetaDataEl.onmouseleave = function () {\n return removeMetaDataEl.style.color = "black";\n };\n\n removeMetaDataEl.onclick = function (e) {\n return e.target.parentElement.remove();\n };\n\n metaLinkEl.appendChild(metaImageEl);\n metaDataEl.appendChild(metaDataTitleEl);\n metaDataEl.appendChild(metaDataDescriptionEl);\n metaItemEl.appendChild(metaLinkEl);\n metaItemEl.appendChild(metaDataEl);\n metaItemEl.appendChild(removeMetaDataEl);\n this.metaDataSection.appendChild(metaItemEl);\n }\n }, {\n key: "constructSVG",\n value: function constructSVG(svgData) {\n var viewBox = svgData.viewBox,\n d = svgData.d;\n var fillColor = this.options.toolbarOptionFillColor ? this.options.toolbarOptionFillColor : "#333";\n var xmlns = "http://www.w3.org/2000/svg";\n var height = "16";\n var width = "16";\n var icon = document.createElement(\'span\');\n var svg = "<svg width=\\"".concat(width, "\\" height=\\"").concat(height, "\\" viewBox=\\"").concat(viewBox, "\\" xmlns=\\"").concat(xmlns, "\\">");\n var path = "<path fill=\\"".concat(fillColor, "\\" d=\\"").concat(d, "\\"/>");\n icon.innerHTML = "".concat(svg).concat(path, "</svg>");\n return icon;\n }\n }, {\n key: "initResponsive",\n value: function initResponsive() {\n var _this9 = this;\n\n var that = this;\n\n if (!this.options.minimal) {\n var responsiveGroups = function responsiveGroups(isResponsive) {\n that.toolbarGroups.forEach(function (group) {\n if (group) {\n group.dataset.open = "false";\n group.style.display = isResponsive ? "none" : "block";\n group.style.position = isResponsive ? "absolute" : "relative";\n group.style.bottom = isResponsive ? "5px" : "inherit";\n group.style.right = isResponsive ? "5px" : "inherit";\n group.style.backgroundColor = isResponsive ? "#fff" : "inherit";\n group.style.border = isResponsive ? "2px solid #ddd" : "none";\n }\n });\n that.toolbarMenus.forEach(function (menu) {\n function toggleMenu() {\n var selectedGroup = that.toolbar.querySelector("#group-".concat(menu.id.split("-")[1]));\n\n if (selectedGroup.dataset.open === "false") {\n // close opened groups\n that.toolbarGroups.forEach(function (group) {\n if (group && group.dataset.open === "true") {\n group.style.display = "none";\n group.dataset.open = "false";\n }\n }); // open group\n\n selectedGroup.style.display = "block";\n selectedGroup.style.padding = "5px 5px 0 5px";\n selectedGroup.dataset.open = "true";\n } else {\n selectedGroup.style.display = "none";\n selectedGroup.dataset.open = "false";\n }\n }\n\n if (menu) {\n menu.style.padding = "0 10px";\n menu.style.cursor = "pointer";\n menu.style.userSelect = "none";\n menu.style.display = isResponsive ? "block" : "none";\n\n menu.onclick = function (e) {\n toggleMenu();\n that.body.focus();\n };\n }\n });\n };\n\n var setResponsive = function setResponsive() {\n responsive = window.matchMedia("(max-width: 700px)").matches;\n responsiveGroups(responsive);\n };\n\n var responsive = window.matchMedia("(max-width: 700px)").matches;\n setResponsive();\n\n window.onresize = function () {\n _this9.toolbarGroups.forEach(function (group) {\n return group && (group.style.padding = "0");\n });\n\n _this9.closeLinkMenu();\n\n _this9.closeImageMenu();\n\n setResponsive();\n };\n } else {\n this.toolbarMenus.forEach(function (menu) {\n return menu && (menu.style.display = "none");\n });\n this.toolbar.querySelector("#toolbar-strikethrough").style.display = "none";\n this.toolbar.querySelector("#toolbar-image").style.display = "none";\n this.toolbar.querySelector("#toolbar-insertOrderedList").style.display = "none";\n this.toolbar.querySelector("#group-textAlign").style.display = "none";\n }\n }\n }, {\n key: "initOverflow",\n value: function initOverflow() {\n var _this10 = this;\n\n var onFocus = this.body.onfocus;\n\n this.body.onfocus = function () {\n onFocus && onFocus();\n\n _this10.overflow();\n };\n\n var onBlur = this.body.onblur;\n\n this.body.onblur = function () {\n onBlur && onBlur();\n\n _this10.overflow();\n };\n\n var bodyKeypress = this.body.onkeypress;\n\n this.body.onkeypress = function () {\n bodyKeypress && bodyKeypress();\n\n _this10.overflow();\n };\n }\n }, {\n key: "getFiles",\n value: function getFiles() {\n return this.files;\n }\n }, {\n key: "getContent",\n value: function getContent() {\n if (this.body.querySelector("#placeholder-node")) {\n return "";\n } else {\n return this.body.innerHTML;\n }\n }\n }, {\n key: "getRange",\n value: function getRange() {\n return window.getSelection().getRangeAt(0);\n }\n }, {\n key: "getMeta",\n value: function getMeta(url) {\n return fetch(this.options.metaUrl, {\n method: "POST",\n headers: {\n \'Content-Type\': \'application/json\'\n },\n body: JSON.stringify({\n targetUrl: url\n })\n }).then(function (res) {\n return res.json();\n });\n }\n }, {\n key: "getImage",\n value: function getImage(imageEncoding) {\n return fetch(this.options.imageUrl, {\n method: "POST",\n headers: {\n \'Content-Type\': \'application/json\'\n },\n body: JSON.stringify({\n imageEncoding: imageEncoding\n })\n }).then(function (res) {\n return res.json();\n });\n }\n }, {\n key: "validURL",\n value: function validURL(str) {\n var pattern = new RegExp("^(https?:\\\\/\\\\/)?" + "((([a-z\\\\d]([a-z\\\\d-]*[a-z\\\\d])*)\\\\.)+[a-z]{2,}|" + "((\\\\d{1,3}\\\\.){3}\\\\d{1,3}))" + "(\\\\:\\\\d+)?(\\\\/[-a-z\\\\d%_.~+]*)*" + "(\\\\?[;&a-z\\\\d%_.~+=-]*)?" + "(\\\\#[-a-z\\\\d_]*)?$", "i");\n return !!pattern.test(str);\n }\n }, {\n key: "overflow",\n value: function overflow() {\n var body = this.body;\n body.scrollHeight > body.clientHeight ? body.style.overflowY = "scroll" : body.style.overflowY = "hidden";\n body.scrollWidth > body.clientWidth ? body.style.overflowX = "scroll" : body.style.overflowX = "hidden";\n }\n }, {\n key: "formatBytes",\n value: function formatBytes(bytes) {\n var decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;\n if (bytes === 0) return \'0 Bytes\';\n var k = 1024;\n var dm = decimals < 0 ? 0 : decimals;\n var sizes = [\'Bytes\', \'KB\', \'MB\', \'GB\', \'TB\', \'PB\', \'EB\', \'ZB\', \'YB\'];\n var i = Math.floor(Math.log(bytes) / Math.log(k));\n return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + \' \' + sizes[i];\n }\n }, {\n key: "validateFile",\n value: function validateFile(file) {\n var extension = file.type.split(\'/\').pop();\n return this.options.extensions.includes(".".concat(extension));\n }\n }, {\n key: "attachFile",\n value: function attachFile(file) {\n if (this.validateFile(file)) {\n this.files.push(file);\n this.createFileElement(file.name, this.formatBytes(file.size));\n } else {\n this.fileInvalid();\n }\n }\n }, {\n key: "fileInvalid",\n value: function fileInvalid() {\n var _this11 = this;\n\n this.body.style.transition = "background-color .5s";\n this.body.style.backgroundColor = "#d9534f";\n setTimeout(function () {\n _this11.body.style.backgroundColor = "inherit";\n setTimeout(function () {\n return _this11.body.style.transition = "none";\n }, 500);\n }, 500);\n }\n }, {\n key: "openLinkMenu",\n value: function openLinkMenu() {\n this.closeImageMenu();\n this.linkMenu.dataset.active = "true";\n this.linkMenu.style.display = "block";\n }\n }, {\n key: "openImageMenu",\n value: function openImageMenu() {\n this.closeLinkMenu();\n this.imageMenu.dataset.active = "true";\n this.imageMenu.style.display = "block";\n }\n }, {\n key: "closeLinkMenu",\n value: function closeLinkMenu() {\n this.linkMenu.dataset.active = "false";\n this.linkMenu.style.display = "none";\n }\n }, {\n key: "closeImageMenu",\n value: function closeImageMenu() {\n this.imageMenu.dataset.active = "false";\n this.imageMenu.style.display = "none";\n }\n }, {\n key: "setContent",\n value: function setContent(html) {\n this.clearContent();\n this.body.innerHTML = html;\n }\n }, {\n key: "clearContent",\n value: function clearContent() {\n this.body.innerHTML = "";\n }\n }, {\n key: "clearFiles",\n value: function clearFiles() {\n this.files = [];\n this.filesSection.innerHTML = \'\';\n }\n }, {\n key: "getTextContent",\n value: function getTextContent() {\n if (this.body.querySelector("#placeholder-node")) {\n return "";\n } else {\n return this.body.textContent;\n }\n }\n }, {\n key: "scrubHTML",\n value: function scrubHTML(html) {\n var dirtyNode = document.createElement("div");\n var cleanNode = document.createElement("div");\n dirtyNode.innerHTML = html;\n cleanNode.append(document.createTextNode(dirtyNode.textContent));\n return cleanNode;\n }\n }, {\n key: "toolbarState",\n value: function toolbarState() {\n var _this12 = this;\n\n this.options.toolbarOptions.forEach(function (option) {\n var toolbarOption = _this12.toolbar.querySelector("#toolbar-".concat(option));\n\n if (!option.includes(\'justify\') && !option.includes(\'list\')) {\n if (document.queryCommandState(option)) {\n toolbarOption.querySelector(\'path\').setAttribute(\'fill\', _this12.options.activeOptionColor);\n } else {\n toolbarOption.querySelector(\'path\').setAttribute(\'fill\', \'#333\');\n }\n }\n });\n }\n }, {\n key: "establishBrowser",\n value: function establishBrowser() {\n // Change this to user agent\n // Opera 8.0+\n this.isOpera = !!window.opr && !!opr.addons || !!window.opera || navigator.userAgent.indexOf(\' OPR/\') >= 0; // Firefox 1.0+\n\n this.isFirefox = typeof InstallTrigger !== \'undefined\'; // Safari 3.0+ "[object HTMLElementConstructor]" \n\n this.isSafari = /constructor/i.test(window.HTMLElement) || function (p) {\n return p.toString() === "[object SafariRemoteNotification]";\n }(!window[\'safari\'] || typeof safari !== \'undefined\' && safari.pushNotification); // Internet Explorer 6-11\n\n\n this.isIE =\n /*@cc_on!@*/\n false || !!document.documentMode; // Edge 20+\n\n this.isEdge = !this.isIE && !!window.StyleMedia; // Chrome 1 - 71\n\n this.isChrome = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime); // Blink engine detection\n\n this.isBlink = (this.isChrome || this.isOpera) && !!window.CSS;\n }\n }]);\n\n return StrivenEditor;\n }();\n\n _exports["default"] = StrivenEditor;\n});\n\n//# sourceURL=webpack://striveneditor/./src/striveneditor.js?')}})})); -\ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.striveneditor=e():t.striveneditor=e()}(window,(function(){return function(t){var e={};function o(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)o.d(n,i,function(e){return t[e]}.bind(null,i));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=0)}([function(t,e,o){var n,i,a;i=[e],void 0===(a="function"==typeof(n=function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t){return function(t){if(Array.isArray(t)){for(var e=0,o=new Array(t.length);e<t.length;e++)o[e]=t[e];return o}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function n(t,e){for(var o=0;o<e.length;o++){var n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0; +/* + @license/i + * Font Awesome Free 5.11.2 by @fontawesome - https://fontawesome.com + * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) + */ +var i=[".doc",".docx",".xls",".xlsx",".ppt",".pptx",".pdf",".tif",".jpeg",".jpg",".gif",".bmp",".txt",".csv",".png",".msg",".wav",".mp3",".mp4",".zip",".rtf",".eps",".ai",".psd",".avi",".mov",".wmv",".cfg",".wss",".vsd",".vsdx",".tsd",".lic"],a="fas",r={textDecoration:{menu:{viewBox:"0 0 1792 1792",d:"M789 559l-170 450q33 0 136.5 2t160.5 2q19 0 57-2-87-253-184-452zm-725 1105l2-79q23-7 56-12.5t57-10.5 49.5-14.5 44.5-29 31-50.5l237-616 280-724h128q8 14 11 21l205 480q33 78 106 257.5t114 274.5q15 34 58 144.5t72 168.5q20 45 35 57 19 15 88 29.5t84 20.5q6 38 6 57 0 5-.5 13.5t-.5 12.5q-63 0-190-8t-191-8q-76 0-215 7t-178 8q0-43 4-78l131-28q1 0 12.5-2.5t15.5-3.5 14.5-4.5 15-6.5 11-8 9-11 2.5-14q0-16-31-96.5t-72-177.5-42-100l-450-2q-26 58-76.5 195.5t-50.5 162.5q0 22 14 37.5t43.5 24.5 48.5 13.5 57 8.5 41 4q1 19 1 58 0 9-2 27-58 0-174.5-10t-174.5-10q-8 0-26.5 4t-21.5 4q-80 14-188 14z"},group:[{bold:{viewBox:"0 0 1792 1792",d:"M747 1521q74 32 140 32 376 0 376-335 0-114-41-180-27-44-61.5-74t-67.5-46.5-80.5-25-84-10.5-94.5-2q-73 0-101 10 0 53-.5 159t-.5 158q0 8-1 67.5t-.5 96.5 4.5 83.5 12 66.5zm-14-746q42 7 109 7 82 0 143-13t110-44.5 74.5-89.5 25.5-142q0-70-29-122.5t-79-82-108-43.5-124-14q-50 0-130 13 0 50 4 151t4 152q0 27-.5 80t-.5 79q0 46 1 69zm-541 889l2-94q15-4 85-16t106-27q7-12 12.5-27t8.5-33.5 5.5-32.5 3-37.5.5-34v-65.5q0-982-22-1025-4-8-22-14.5t-44.5-11-49.5-7-48.5-4.5-30.5-3l-4-83q98-2 340-11.5t373-9.5q23 0 68 .5t68 .5q70 0 136.5 13t128.5 42 108 71 74 104.5 28 137.5q0 52-16.5 95.5t-39 72-64.5 57.5-73 45-84 40q154 35 256.5 134t102.5 248q0 100-35 179.5t-93.5 130.5-138 85.5-163.5 48.5-176 14q-44 0-132-3t-132-3q-106 0-307 11t-231 12z"}},{italic:{viewBox:"0 0 1792 1792",d:"M384 1662l17-85q22-7 61.5-16.5t72-19 59.5-23.5q28-35 41-101 1-7 62-289t114-543.5 52-296.5v-25q-24-13-54.5-18.5t-69.5-8-58-5.5l19-103q33 2 120 6.5t149.5 7 120.5 2.5q48 0 98.5-2.5t121-7 98.5-6.5q-5 39-19 89-30 10-101.5 28.5t-108.5 33.5q-8 19-14 42.5t-9 40-7.5 45.5-6.5 42q-27 148-87.5 419.5t-77.5 355.5q-2 9-13 58t-20 90-16 83.5-6 57.5l1 18q17 4 185 31-3 44-16 99-11 0-32.5 1.5t-32.5 1.5q-29 0-87-10t-86-10q-138-2-206-2-51 0-143 9t-121 11z"}},{underline:{viewBox:"0 0 1792 1792",d:"M176 223q-37-2-45-4l-3-88q13-1 40-1 60 0 112 4 132 7 166 7 86 0 168-3 116-4 146-5 56 0 86-2l-1 14 2 64v9q-60 9-124 9-60 0-79 25-13 14-13 132 0 13 .5 32.5t.5 25.5l1 229 14 280q6 124 51 202 35 59 96 92 88 47 177 47 104 0 191-28 56-18 99-51 48-36 65-64 36-56 53-114 21-73 21-229 0-79-3.5-128t-11-122.5-13.5-159.5l-4-59q-5-67-24-88-34-35-77-34l-100 2-14-3 2-86h84l205 10q76 3 196-10l18 2q6 38 6 51 0 7-4 31-45 12-84 13-73 11-79 17-15 15-15 41 0 7 1.5 27t1.5 31q8 19 22 396 6 195-15 304-15 76-41 122-38 65-112 123-75 57-182 89-109 33-255 33-167 0-284-46-119-47-179-122-61-76-83-195-16-80-16-237v-333q0-188-17-213-25-36-147-39zm1488 1409v-64q0-14-9-23t-23-9h-1472q-14 0-23 9t-9 23v64q0 14 9 23t23 9h1472q14 0 23-9t9-23z"}},{strikethrough:{viewBox:"0 0 1792 1792",d:"M1760 896q14 0 23 9t9 23v64q0 14-9 23t-23 9h-1728q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h1728zm-1277-64q-28-35-51-80-48-98-48-188 0-181 134-309 133-127 393-127 50 0 167 19 66 12 177 48 10 38 21 118 14 123 14 183 0 18-5 45l-12 3-84-6-14-2q-50-149-103-205-88-91-210-91-114 0-182 59-67 58-67 146 0 73 66 140t279 129q69 20 173 66 58 28 95 52h-743zm507 256h411q7 39 7 92 0 111-41 212-23 56-71 104-37 35-109 81-80 48-153 66-80 21-203 21-114 0-195-23l-140-40q-57-16-72-28-8-8-8-22v-13q0-108-2-156-1-30 0-68l2-37v-44l102-2q15 34 30 71t22.5 56 12.5 27q35 57 80 94 43 36 105 57 59 22 132 22 64 0 139-27 77-26 122-86 47-61 47-129 0-84-81-157-34-29-137-71z"}},{removeFormat:{viewBox:"0 0 640 512",d:"M336 416h-11.17l9.26-27.77L267 336.4 240.49 416H208a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h128a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm297.82 42.1L377 259.59 426.17 112H544v32a16 16 0 0 0 16 16h32a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16H176a16 16 0 0 0-16 16v43.9L45.46 3.38A16 16 0 0 0 23 6.19L3.37 31.46a16 16 0 0 0 2.81 22.45l588.36 454.72a16 16 0 0 0 22.46-2.81l19.64-25.27a16 16 0 0 0-2.82-22.45zM309.91 207.76L224 141.36V112h117.83z"}}]},listOptions:{menu:{viewBox:"0 0 1792 1792",d:"M256 1312v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm1536 768v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5zm-1536-1152v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm1536 768v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5z"},group:[{insertOrderedList:{viewBox:"0 0 1792 1792",d:"M381 1620q0 80-54.5 126t-135.5 46q-106 0-172-66l57-88q49 45 106 45 29 0 50.5-14.5t21.5-42.5q0-64-105-56l-26-56q8-10 32.5-43.5t42.5-54 37-38.5v-1q-16 0-48.5 1t-48.5 1v53h-106v-152h333v88l-95 115q51 12 81 49t30 88zm2-627v159h-362q-6-36-6-54 0-51 23.5-93t56.5-68 66-47.5 56.5-43.5 23.5-45q0-25-14.5-38.5t-39.5-13.5q-46 0-81 58l-85-59q24-51 71.5-79.5t105.5-28.5q73 0 123 41.5t50 112.5q0 50-34 91.5t-75 64.5-75.5 50.5-35.5 52.5h127v-60h105zm1409 319v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-14 9-23t23-9h1216q13 0 22.5 9.5t9.5 22.5zm-1408-899v99h-335v-99h107q0-41 .5-121.5t.5-121.5v-12h-2q-8 17-50 54l-71-76 136-127h106v404h108zm1408 387v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-14 9-23t23-9h1216q13 0 22.5 9.5t9.5 22.5zm0-512v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5z"}},{insertUnorderedList:{viewBox:"0 0 1792 1792",d:"M384 1408q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm0-512q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm1408 416v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5zm-1408-928q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm1408 416v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5zm0-512v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5"}}]},textAlign:{menu:{viewBox:"0 0 1792 1792",d:"M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45z"},group:[{indent:{viewBox:"0 0 1792 1792",d:"M352 832q0 14-9 23l-288 288q-9 9-23 9-13 0-22.5-9.5t-9.5-22.5v-576q0-13 9.5-22.5t22.5-9.5q14 0 23 9l288 288q9 9 9 23zm1440 480v192q0 13-9.5 22.5t-22.5 9.5h-1728q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1728q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1088q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1088q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1088q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1088q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1728q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1728q13 0 22.5 9.5t9.5 22.5z"}},{justifyLeft:{viewBox:"0 0 1792 1792",d:"M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-1280q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1280q26 0 45 19t19 45zm256-384v128q0 26-19 45t-45 19h-1536q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1536q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-1152q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1152q26 0 45 19t19 45z"}},{justifyCenter:{viewBox:"0 0 1792 1792",d:"M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-896q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h896q26 0 45 19t19 45zm256-384v128q0 26-19 45t-45 19h-1408q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1408q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-640q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h640q26 0 45 19t19 45z"}},{justifyRight:{viewBox:"0 0 1792 1792",d:"M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1280q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1280q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1536q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1536q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1152q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1152q26 0 45 19t19 45z"}}]},attachments:{menu:{viewBox:"0 0 1792 1792",d:"M1596 1385q0 117-79 196t-196 79q-135 0-235-100l-777-776q-113-115-113-271 0-159 110-270t269-111q158 0 273 113l605 606q10 10 10 22 0 16-30.5 46.5t-46.5 30.5q-13 0-23-10l-606-607q-79-77-181-77-106 0-179 75t-73 181q0 105 76 181l776 777q63 63 145 63 64 0 106-42t42-106q0-82-63-145l-581-581q-26-24-60-24-29 0-48 19t-19 48q0 32 25 59l410 410q10 10 10 22 0 16-31 47t-47 31q-12 0-22-10l-410-410q-63-61-63-149 0-82 57-139t139-57q88 0 149 63l581 581q100 98 100 235z"},group:[{attachment:{viewBox:"0 0 1792 1792",d:"M1596 1385q0 117-79 196t-196 79q-135 0-235-100l-777-776q-113-115-113-271 0-159 110-270t269-111q158 0 273 113l605 606q10 10 10 22 0 16-30.5 46.5t-46.5 30.5q-13 0-23-10l-606-607q-79-77-181-77-106 0-179 75t-73 181q0 105 76 181l776 777q63 63 145 63 64 0 106-42t42-106q0-82-63-145l-581-581q-26-24-60-24-29 0-48 19t-19 48q0 32 25 59l410 410q10 10 10 22 0 16-31 47t-47 31q-12 0-22-10l-410-410q-63-61-63-149 0-82 57-139t139-57q88 0 149 63l581 581q100 98 100 235z"}},{link:{viewBox:"0 0 1792 1792",d:"M1520 1216q0-40-28-68l-208-208q-28-28-68-28-42 0-72 32 3 3 19 18.5t21.5 21.5 15 19 13 25.5 3.5 27.5q0 40-28 68t-68 28q-15 0-27.5-3.5t-25.5-13-19-15-21.5-21.5-18.5-19q-33 31-33 73 0 40 28 68l206 207q27 27 68 27 40 0 68-26l147-146q28-28 28-67zm-703-705q0-40-28-68l-206-207q-28-28-68-28-39 0-68 27l-147 146q-28 28-28 67 0 40 28 68l208 208q27 27 68 27 42 0 72-31-3-3-19-18.5t-21.5-21.5-15-19-13-25.5-3.5-27.5q0-40 28-68t68-28q15 0 27.5 3.5t25.5 13 19 15 21.5 21.5 18.5 19q33-31 33-73zm895 705q0 120-85 203l-147 146q-83 83-203 83-121 0-204-85l-206-207q-83-83-83-203 0-123 88-209l-88-88q-86 88-208 88-120 0-204-84l-208-208q-84-84-84-204t85-203l147-146q83-83 203-83 121 0 204 85l206 207q83 83 83 203 0 123-88 209l88 88q86-88 208-88 120 0 204 84l208 208q84 84 84 204z"}},{image:{viewBox:"0 0 2048 1792",d:"M704 576q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm1024 384v448h-1408v-192l320-320 160 160 512-512zm96-704h-1600q-13 0-22.5 9.5t-9.5 22.5v1216q0 13 9.5 22.5t22.5 9.5h1600q13 0 22.5-9.5t9.5-22.5v-1216q0-13-9.5-22.5t-22.5-9.5zm160 32v1216q0 66-47 113t-113 47h-1600q-66 0-113-47t-47-113v-1216q0-66 47-113t113-47h1600q66 0 113 47t47 113z"}}]}},l=["bold","italic","underline","strikethrough","removeFormat","insertOrderedList","insertUnorderedList","indent","justifyLeft","justifyCenter","justifyRight","attachment","link","image"],s="#777777",c=function(){function t(e,o){var n=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.establishBrowser(),this.range=new Range,this.files=[],this.optionGroups=r,o?(this.options=o,o.fontPack||(this.options.fontPack=a),o.extensions||(this.options.extensions=i),o.toolbarOptions||(this.options.toolbarOptions=l),o.activeOptionColor||(this.options.activeOptionColor=s)):this.options={fontPack:a,extensions:i,toolbarOptions:l,activeOptionColor:s},this.initEditor(e),this.initResponsive(),this.initOverflow(),e.StrivenEditor=function(){return n},this.bound_popupEscapeHandler=this.popupEscapeHandler.bind(this)}var c,u,d;return c=t,(u=[{key:"initEditor",value:function(t){var e=this;if(this.editor=t,this.toolbar=this.initToolbar(),this.body=this.initBody(),this.linkMenu=this.initLinkMenu(),this.imageMenu=this.initImageMenu(),this.metaDataSection=this.initMetaDataSection(),this.filesSection=this.initFilesSection(),this.editor.classList.add("editor","Striven-Editor"),this.options.toolbarHide){this.customToolbarButton&&(this.customToolbarButton.style.display="none"),this.toolbarOptionsGroup.style.display="none";var n=this.body.onfocus;this.body.onfocus=function(){n&&n(),e.overflow(),e.toolbarSlideUp()};var i=this.body.onblur;this.body.onblur=function(){i&&i(),e.overflow(),setTimeout((function(){"true"===e.linkMenu.dataset.active||"true"===e.imageMenu.dataset.active||e.isEditorInFocus()||e.toolbarSlideDown()}),500)}}this.toolbarOptions.forEach((function(t){t.style.cursor="pointer",t.style.userSelect="none";var n=t.onclick;t.onclick=function(i){var a=function(){var t=e.body.querySelectorAll("blockquote");o(t).forEach((function(t){return t.style.margin="0 0 0 40px"}))};e.body.focus(),window.getSelection().removeAllRanges(),window.getSelection().addRange(e.range);var r=t.id.split("-")[1];switch(r){case"insertOrderedList":e.isFirefox?(document.execCommand("indent"),document.execCommand(r),a()):e.isEdge?(document.execCommand(r),o(document.querySelectorAll("ol")).forEach((function(t){return t.style.marginLeft="40px"}))):(document.execCommand("indent",!0),document.execCommand(r,!0));break;case"insertUnorderedList":e.isFirefox?(document.execCommand("indent"),document.execCommand(r),a()):e.isEdge?(document.execCommand(r),o(document.querySelectorAll("ul")).forEach((function(t){return t.style.marginLeft="40px"}))):(document.execCommand("indent",!0),document.execCommand(r,!0));break;case"attachment":var l=document.createElement("input");l.style.display="none",l.type="file",l.onchange=function(t){return e.attachFile(l.files[0])},l.click();break;case"link":"true"===e.linkMenu.dataset.active?e.closeLinkMenu():(e.linkMenuSlideIn(),e.linkMenu.querySelector("input").focus());break;case"image":"true"===e.imageMenu.dataset.active?e.closeImageMenu():(e.imageMenuSlideIn(),e.range=e.getRange(),e.imageMenu.querySelector("input").focus());break;default:e.isFirefox||e.isEdge?(document.execCommand(r),"indent"===r&&a()):document.execCommand(r,!0),e.toolbarState()}n&&n()}})),this.editor.appendChild(this.toolbar),this.editor.appendChild(this.body),this.editor.appendChild(this.linkMenu),this.editor.appendChild(this.imageMenu),this.editor.appendChild(this.metaDataSection),this.editor.appendChild(this.filesSection),this.options.toolbarBottom&&(this.editor.removeChild(this.toolbar),this.editor.append(this.toolbar))}},{key:"imageMenuSlideIn",value:function(){var t=this;this.openImageMenu();var e=0,o=this.editor.offsetWidth/4,n=setInterval((function(){o<=10?(clearInterval(n),t.imageMenu.style.opacity=1):(o-=2.5,e+=.01,t.imageMenu.style.opacity="".concat(e),t.imageMenu.style.right="".concat(o,"px"))}),5);this.imageMenu.style.opacity=e}},{key:"linkMenuSlideIn",value:function(){var t=this;this.openLinkMenu();var e=0,o=this.editor.offsetWidth/4,n=setInterval((function(){o<=10?(clearInterval(n),t.linkMenu.style.opacity=1):(o-=2.5,e+=.01,t.linkMenu.style.opacity="".concat(e),t.linkMenu.style.right="".concat(o,"px"))}),5);this.linkMenu.style.opacity=e}},{key:"toolbarSlideUp",value:function(){var t=this,e=this.toolbar.offsetHeight,o=setInterval((function(){e>=40?(t.customToolbarButton&&(t.customToolbarButton.style.display="flex"),t.toolbarOptionsGroup.style.display="flex",clearInterval(o)):(e++,t.toolbar.style.minHeight="".concat(e,"px"))}),5)}},{key:"toolbarSlideDown",value:function(){var t=this;this.customToolbarButton&&(this.customToolbarButton.style.display="none"),this.toolbarOptionsGroup.style.display="none";var e=40,o=setInterval((function(){0===e?clearInterval(o):(e--,t.toolbar.style.minHeight="".concat(e,"px"))}),5)}},{key:"initToolbar",value:function(){var t=this,n=document.createElement("div");this.toolbarOptionsGroup=document.createElement("div");var i=Object.keys(this.optionGroups);n.classList.add("toolbar"),n.style.minHeight=this.options.toolbarHide?"0":"40px",this.toolbarOptionsGroup.classList.add("toolbar-options"),this.toolbarOptionsGroup.style.display=this.options.toolbarHide?"none":"flex",n.onclick=function(){return t.body.focus()},i.forEach((function(e){var o=document.createElement("div");o.classList.add("toolbar-menu"),o.id="menu-".concat(e),o.appendChild(t.constructSVG(t.optionGroups[e].menu)),t.toolbarOptionsGroup.appendChild(o);var n=document.createElement("div");n.classList.add("toolbar-group"),n.id="group-".concat(e),t.options.toolbarOptions.forEach((function(o){var i=t.optionGroups[e].group.filter((function(t){return t[o]}))[0];if(i){var a=i[o],r=t.constructSVG(a);r.classList.add("toolbar-option"),r.id="toolbar-".concat(o),n.appendChild(r)}})),t.toolbarOptionsGroup.appendChild(n)}));var a=this.options.toolbarOptions.filter((function(t){return"object"===e(t)}));if(a.length>0&&(this.customToolbarMenu=document.createElement("div"),this.customToolbarMenu.classList.add("toolbar-menu"),this.customToolbarMenu.id="menu-custom",this.customToolbarMenu.appendChild(this.constructSVG({viewBox:"0 0 1792 1792",d:"M1088 1248v192q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h192q40 0 68 28t28 68zm0-512v192q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h192q40 0 68 28t28 68zm0-512v192q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h192q40 0 68 28t28 68z"})),this.toolbarOptionsGroup.appendChild(this.customToolbarMenu),this.customToolbarGroup=document.createElement("div"),this.customToolbarGroup.classList.add("toolbar-group"),this.customToolbarGroup.id="group-custom",a.forEach((function(e){var o=e.icon,n=e.handler,i=t.constructSVG(o);i.id="toolbar-customOption",i.style.margin="0 10px",i.onclick=function(){return n()},t.customToolbarGroup.appendChild(i)})),this.toolbarOptionsGroup.appendChild(this.customToolbarGroup)),n.appendChild(this.toolbarOptionsGroup),this.options.customToolbarButton){var r=document.createElement("div");r.id="custom-toolbar-button",r.classList.add("custom-toolbar-button"),r.style.minHeight=this.options.toolbarHide?"40px":n.style.minHeight,r.onclick=function(){return t.options.customToolbarButton.handler()},!this.options.toolbarHide&&(r.style.display="flex"),r.onmouseenter=function(){r.style.borderColor=t.options.customToolbarButton.hoverBorderColor,r.style.backgroundColor=t.options.customToolbarButton.hoverBackgroundColor,r.style.color=t.options.customToolbarButton.hoverColor},r.onmouseleave=function(){r.style.borderColor=t.options.customToolbarButton.borderColor,r.style.backgroundColor=t.options.customToolbarButton.backgroundColor,r.style.color=t.options.customToolbarButton.color};var l=this.constructSVG(this.options.customToolbarButton.svgData);l.querySelector("path").setAttribute("fill",this.options.customToolbarButton.color),r.appendChild(l),n.appendChild(r)}return this.toolbarOptions=n.querySelectorAll("span"),this.toolbarGroups=o(n.getElementsByClassName("toolbar-group")),this.toolbarMenus=o(n.getElementsByClassName("toolbar-menu")),this.customToolbarButton=n.querySelector("#custom-toolbar-button"),this.toolbarMenus.push(this.customToolbarMenu),this.toolbarGroups.push(this.customToolbarGroup),this.toolbarGroups.forEach((function(e){if(e&&e.children.length<1){var o=e.id.split("-")[1];t.toolbarMenus.filter((function(t){return t.id.split("-")[1]===o}))[0].remove()}})),n}},{key:"initBody",value:function(){var t=this,e=document.createElement("div");if(e.classList.add("body"),e.contentEditable="true",e.style.height=this.editor.style.height,e.style.minHeight=this.editor.style.minHeight,e.style.maxHeight=this.editor.style.maxHeight,this.editor.style.height="auto",this.editor.style.minHeight="auto",this.editor.style.maxHeight="auto",this.options.placeholder){var o=document.createElement("p");o.id="placeholder-node",o.style.color="#5f6368",o.style.margin="0",o.textContent=this.options.placeholder,e.append(o);var n=e.onfocus;e.onfocus=function(){n&&n(),e.querySelector("#placeholder-node")===o&&t.clearContent()};var i=e.onblur;e.onblur=function(){i&&i(),""===t.getContent().trim()&&e.append(o)}}e.onpaste=function(e){var o;if(e.clipboardData.files.length>0&&e.clipboardData.files[0].type.includes("image")&&(o=e.clipboardData.files[0],new Promise((function(t,e){var n=new FileReader;n.readAsDataURL(o),n.onload=function(){return t(n.result)},n.onerror=function(t){return e(t)}}))).then((function(e){t.options.imageUrl?t.getImage(e).then((function(t){document.execCommand("insertImage",!0,t.imageRef)})).catch((function(t){document.execCommand("insertImage",!0,e)})):(document.execCommand("insertImage",!0,e),t.options.uploadOnPaste&&t.attachFile(function(t,e){for(var o=t.split(","),n=o[0].match(/:(.*?);/)[1],i=atob(o[1]),a=i.length,r=new Uint8Array(a);a--;)r[a]=i.charCodeAt(a);var l=new File([r],e,{type:n});return new File([r],"".concat(l.name,".").concat(l.type.split("/").pop()),{type:l.type})}(e,"pastedimage"))),t.overflow()})),t.options.sanitizePaste&&e.clipboardData.types.includes("text/html")){var n;e.preventDefault();for(var i=0;i<e.clipboardData.items.length;i++){var a=e.clipboardData.items[i];"text/html"===a.type&&(n=a)}n&&n.getAsString((function(e){var o=t.getRange();o.insertNode(t.scrubHTML(e)),o.collapse()}))}e.clipboardData.items.length>0&&"text/plain"===e.clipboardData.items[0].type&&e.clipboardData.items[0].getAsString((function(e){t.options.metaUrl&&t.validURL(e)&&t.getMeta(e).then((function(e){var o=e.url,n=e.title,i=e.image,a=e.description;o&&n&&i&&t.createMetaDataElement(o,i,n,a)}))})),t.overflow()};var a=e.onkeyup;e.onkeyup=function(o){if(a&&a(),t.range=t.getRange(),t.options.submitOnEnter&&13===o.keyCode&&!o.shiftKey&&!document.queryCommandState("insertOrderedList")&&!document.queryCommandState("insertUnorderedList")){var n=!!t.getTextContent(),i=!!e.querySelector("img");if(n||i){var r=e.querySelectorAll("div"),l=r[r.length?r.length-1:0];l&&l.remove()}var s=t.getContent(),c=t.getFiles();t.clearContent(),t.clearFiles(),(c.length||n||i)&&t.options.submitOnEnter({content:(n||i)&&s,files:c})}t.toolbarState()};var r=e.onmouseup;return e.onmouseup=function(e){r&&r(),t.range=t.getRange()},e}},{key:"initLinkMenu",value:function(){var t=this,e=document.createElement("div"),n=document.createElement("div"),i=document.createElement("div"),a=document.createElement("button"),r=document.createElement("button"),l=document.createElement("p"),s=document.createElement("input");return e.id="link-menu",e.classList.add("popup"),e.dataset.active="false",n.classList.add("popup-form"),l.classList.add("form-label"),l.textContent="Web Address",s.classList.add("form-input"),s.type="text",s.placeholder="Insert a Link",i.classList.add("popup-button-container"),a.classList.add("popup-button"),a.classList.add("button-primary"),a.textContent="Insert Link",r.classList.add("popup-button"),r.classList.add("button-secondary"),r.textContent="Close",a.onclick=function(e){var n=s.value;n?(window.getSelection().removeAllRanges(),window.getSelection().addRange(t.range),t.isFirefox||t.isEdge?document.execCommand("createLink",!1,n):document.execCommand("createLink",!0,n),t.options.metaUrl&&t.validURL(n)&&t.getMeta(n).then((function(e){var o=e.url,n=e.image,i=e.title,a=e.description;o&&n&&i&&t.createMetaDataElement(o,n,i,a)})),o(t.body.querySelectorAll("a")).forEach((function(e){return!t.isFirefox&&(e.contentEditable="false")})),s.value="",t.closeLinkMenu()):(t.body.focus(),t.closeLinkMenu())},r.onclick=function(e){t.body.focus(),t.closeLinkMenu()},n.appendChild(l),n.appendChild(s),e.appendChild(n),i.appendChild(a),i.appendChild(r),e.appendChild(i),e}},{key:"initImageMenu",value:function(){var t=this,e=document.createElement("div"),n=document.createElement("div"),i=document.createElement("div"),a=document.createElement("button"),r=document.createElement("button"),l=document.createElement("p"),s=document.createElement("input");e.id="image-menu",e.classList.add("popup"),e.dataset.active="false",n.classList.add("popup-form"),l.classList.add("form-label"),l.textContent="Image URL",s.classList.add("form-input"),s.type="text",s.placeholder="Insert a Link",i.classList.add("popup-button-container"),a.classList.add("popup-button"),a.classList.add("button-primary"),a.textContent="Insert Image",r.classList.add("popup-button"),r.classList.add("button-secondary"),r.textContent="Close",n.appendChild(l),n.appendChild(s);var c=n.cloneNode(!0),u=c.querySelector("input"),d=c.querySelector("p");u.placeholder="Image Height",d.textContent="Height";var p=n.cloneNode(!0),h=p.querySelector("input"),m=p.querySelector("p");return h.placeholder="Image Width",m.textContent="Width",a.onclick=function(e){var n=s.value,i=u.value,a=h.value;if(n){window.getSelection().removeAllRanges(),window.getSelection().addRange(t.range),t.isFirefox||t.isEdge?document.execCommand("insertImage",!1,n):document.execCommand("insertImage",!0,n);var r=o(t.body.querySelectorAll("img")).filter((function(t){return t.src===n}));(r=r[r.length-1])&&(r.style.height="".concat(i,"px")),r&&(r.style.width="".concat(a,"px")),u.value="",h.value="",s.value="",t.closeImageMenu()}else t.body.focus(),t.closeImageMenu()},r.onclick=function(e){t.body.focus(),t.closeImageMenu()},e.appendChild(c),e.appendChild(p),e.appendChild(n),i.appendChild(a),i.appendChild(r),e.appendChild(i),e}},{key:"initMetaDataSection",value:function(){var t=document.createElement("div");return t.classList.add("metadata-section"),t}},{key:"initFilesSection",value:function(){var t=this,e=document.createElement("div");return e.classList.add("files-section"),this.body.ondragenter=function(e){t.body.style.backgroundColor="#ddd"},this.body.ondragleave=function(e){t.body.style.backgroundColor="inherit"},this.body.ondrop=function(e){t.body.style.backgroundColor="inherit",e.preventDefault();var o=e.dataTransfer.files&&e.dataTransfer.files[0];t.attachFile(o)},this.isEdge&&(this.body.ondragover=function(t){return t.preventDefault()}),e}},{key:"createFileElement",value:function(t,e){var o=this,n=document.createElement("div"),i=document.createElement("h4"),a=document.createElement("p"),r=document.createElement("p");i.textContent=t,a.textContent=e,r.textContent="X",n.classList.add("file-el"),n.dataset.fileindex=this.files.length-1,i.classList.add("file-name-el"),a.classList.add("file-size-el"),r.classList.add("remove-file-el"),r.onmouseenter=function(){return r.style.color="#ddd"},r.onmouseleave=function(){return r.style.color="black"},r.onclick=function(t){o.files.splice(t.target.parentElement.dataset.fileindex,1),t.target.parentElement.remove()},n.appendChild(i),n.appendChild(a),n.appendChild(r),this.filesSection.appendChild(n)}},{key:"createMetaDataElement",value:function(t,e,o,n){var i=document.createElement("div"),a=document.createElement("a"),r=document.createElement("img"),l=document.createElement("div"),s=document.createElement("h4"),c=document.createElement("p"),u=document.createElement("span");a.href=t,r.src=e,s.textContent=o,c.textContent=n,u.textContent="X",a.target="blank",i.classList.add("meta-item-el"),r.classList.add("meta-image-el"),s.classList.add("meta-data-title-el"),c.style.margin="0",u.classList.add("remove-meta-data-el"),u.onmouseenter=function(){return u.style.color="#ddd"},u.onmouseleave=function(){return u.style.color="black"},u.onclick=function(t){return t.target.parentElement.remove()},a.appendChild(r),l.appendChild(s),l.appendChild(c),i.appendChild(a),i.appendChild(l),i.appendChild(u),this.metaDataSection.appendChild(i)}},{key:"constructSVG",value:function(t){var e=t.viewBox,o=t.d,n=this.options.toolbarOptionFillColor?this.options.toolbarOptionFillColor:"#333",i=document.createElement("span"),a='<svg width="'.concat("16",'" height="').concat("14",'" viewBox="').concat(e,'" xmlns="').concat("http://www.w3.org/2000/svg",'">'),r='<path fill="'.concat(n,'" d="').concat(o,'"/>');return i.innerHTML="".concat(a).concat(r,"</svg>"),i}},{key:"initResponsive",value:function(){var t=this,e=this;if(this.options.minimal)this.toolbarMenus.forEach((function(t){return t&&(t.style.display="none")})),this.toolbar.querySelector("#toolbar-strikethrough").style.display="none",this.toolbar.querySelector("#toolbar-image").style.display="none",this.toolbar.querySelector("#toolbar-insertOrderedList").style.display="none",this.toolbar.querySelector("#group-textAlign").style.display="none",this.toolbar.querySelector("#toolbar-removeFormat").style.display="none";else{var o=function(t){e.toolbarGroups.forEach((function(o){o&&(o.dataset.open="false",o.style.display=t?"none":"block",o.style.position=t?"absolute":"relative",!e.options.toolbarBottom&&(o.style.top=t?"50px":"inherit"),e.options.toolbarBottom&&(o.style.bottom=t?"50px":"inherit"))})),e.toolbarMenus.forEach((function(o){o&&(o.style.padding="0 10px",o.style.cursor="pointer",o.style.userSelect="none",o.style.display=t?"block":"none",o.onclick=function(t){var n;"false"===(n=e.toolbar.querySelector("#group-".concat(o.id.split("-")[1]))).dataset.open?(e.toolbarGroups.forEach((function(t){t&&"true"===t.dataset.open&&(t.style.display="none",t.dataset.open="false")})),n.style.display="block",n.style.padding="5px 5px 0 5px",n.dataset.open="true"):(n.style.display="none",n.dataset.open="false"),e.body.focus()})}))},n=function(){i=window.matchMedia("(max-width: 700px)").matches,o(i)},i=window.matchMedia("(max-width: 700px)").matches;n(),window.onresize=function(){t.toolbarGroups.forEach((function(t){return t&&(t.style.padding="0")})),t.closeLinkMenu(),t.closeImageMenu(),n()}}}},{key:"initOverflow",value:function(){var t=this,e=this.body.onfocus;this.body.onfocus=function(){e&&e(),t.overflow()};var o=this.body.onblur;this.body.onblur=function(){o&&o(),t.overflow()};var n=this.body.onkeypress;this.body.onkeypress=function(){n&&n(),t.overflow()}}},{key:"getFiles",value:function(){return this.files}},{key:"getContent",value:function(){return this.body.querySelector("#placeholder-node")?"":this.body.innerHTML}},{key:"getRange",value:function(){return window.getSelection().getRangeAt(0)}},{key:"getMeta",value:function(t){return fetch(this.options.metaUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetUrl:t})}).then((function(t){return t.json()}))}},{key:"getImage",value:function(t){return fetch(this.options.imageUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({imageEncoding:t})}).then((function(t){return t.json()}))}},{key:"validURL",value:function(t){return!!new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$","i").test(t)}},{key:"overflow",value:function(){var t=this.body;t.scrollHeight>t.clientHeight?t.style.overflowY="scroll":t.style.overflowY="hidden",t.scrollWidth>t.clientWidth?t.style.overflowX="scroll":t.style.overflowX="hidden"}},{key:"formatBytes",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(0===t)return"0 Bytes";var o=1024,n=e<0?0:e,i=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],a=Math.floor(Math.log(t)/Math.log(o));return parseFloat((t/Math.pow(o,a)).toFixed(n))+" "+i[a]}},{key:"validateFile",value:function(t){var e=t.type.split("/").pop();return this.options.extensions.includes(".".concat(e))}},{key:"attachFile",value:function(t){this.validateFile(t)?(this.files.push(t),this.createFileElement(t.name,this.formatBytes(t.size))):this.fileInvalid()}},{key:"fileInvalid",value:function(){var t=this;this.body.style.transition="background-color .5s",this.body.style.backgroundColor="#d9534f",setTimeout((function(){t.body.style.backgroundColor="inherit",setTimeout((function(){return t.body.style.transition="none"}),500)}),2e3)}},{key:"openLinkMenu",value:function(){this.closeImageMenu(),this.linkMenu.dataset.active="true",this.linkMenu.style.display="block",this.addPopupEscapeHandler()}},{key:"openImageMenu",value:function(){this.closeLinkMenu(),this.imageMenu.dataset.active="true",this.imageMenu.style.display="block",this.addPopupEscapeHandler()}},{key:"closeLinkMenu",value:function(){this.linkMenu.dataset.active="false",this.linkMenu.style.display="none",this.removePopupEscapeHandler()}},{key:"closeImageMenu",value:function(){this.imageMenu.dataset.active="false",this.imageMenu.style.display="none",this.removePopupEscapeHandler()}},{key:"popupEscapeHandler",value:function(t){27===t.which&&(this.closeImageMenu(),this.closeLinkMenu())}},{key:"addPopupEscapeHandler",value:function(){this.removePopupEscapeHandler(),this.editor.addEventListener("keyup",this.bound_popupEscapeHandler)}},{key:"removePopupEscapeHandler",value:function(){this.editor.removeEventListener("keyup",this.bound_popupEscapeHandler)}},{key:"setContent",value:function(t){this.clearContent(),this.body.innerHTML=t}},{key:"clearContent",value:function(){this.body.innerHTML=""}},{key:"clearFiles",value:function(){this.files=[],this.filesSection.innerHTML=""}},{key:"getTextContent",value:function(){return this.body.querySelector("#placeholder-node")?"":this.body.textContent}},{key:"scrubHTML",value:function(t){var e=document.createElement("div"),o=document.createElement("div");return e.innerHTML=t,o.append(document.createTextNode(e.textContent)),o}},{key:"toolbarState",value:function(){var t=this;this.options.toolbarOptions.forEach((function(e){var o=t.toolbar.querySelector("#toolbar-".concat(e));e.includes("justify")||e.includes("list")||(document.queryCommandState(e)?o.querySelector("path").setAttribute("fill",t.options.activeOptionColor):o.querySelector("path").setAttribute("fill","#333"))}))}},{key:"establishBrowser",value:function(){this.isOpera=!!window.opr&&!!opr.addons||!!window.opera||navigator.userAgent.indexOf(" OPR/")>=0,this.isFirefox="undefined"!=typeof InstallTrigger,this.isSafari=/constructor/i.test(window.HTMLElement)||"[object SafariRemoteNotification]"===(!window.safari||"undefined"!=typeof safari&&safari.pushNotification).toString(),this.isIE=!!document.documentMode,this.isEdge=!this.isIE&&!!window.StyleMedia,this.isChrome=!(!window.chrome||!window.chrome.webstore&&!window.chrome.runtime),this.isBlink=(this.isChrome||this.isOpera)&&!!window.CSS}},{key:"isEditorInFocus",value:function(){var t=this;return function e(o){return o===t.editor||o!==document.body&&o.parentNode&&e(o.parentNode)}(document.activeElement)}}])&&n(c.prototype,u),d&&n(c,d),t}();t.default=c})?n.apply(e,i):n)||(t.exports=a)}])})); +\ No newline at end of file diff --git a/dist/striveneditor.js.LICENSE b/dist/striveneditor.js.LICENSE @@ -1,5 +1,5 @@ -/*!******************************!*\ - !*** ./src/striveneditor.js ***! - \******************************/ - -/*! no static exports found */ +/* + @license/i + * Font Awesome Free 5.11.2 by @fontawesome - https://fontawesome.com + * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) + */ diff --git a/dist/vue-striveneditor.js b/dist/vue-striveneditor.js @@ -1,2 +1,8 @@ /*! For license information please see vue-striveneditor.js.LICENSE */ -!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.striveneditor=r():e.striveneditor=r()}(window,(function(){return function(e){var r={};function t(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,t),n.l=!0,n.exports}return t.m=e,t.c=r,t.d=function(e,r,o){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:o})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)t.d(o,n,function(r){return e[r]}.bind(null,n));return o},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s="./src/vue-striveneditor.vue")}({"./src/vue-striveneditor.vue":function(module,exports){eval("throw new Error(\"Module build failed (from ./node_modules/vue-loader/lib/index.js):\\nError: ENOENT: no such file or directory, open 'C:\\\\Users\\\\hunite\\\\Projects\\\\striven-editor\\\\src\\\\vue-striveneditor.vue'\");\n\n//# sourceURL=webpack://striveneditor/./src/vue-striveneditor.vue?")}})})); -\ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.striveneditor=e():t.striveneditor=e()}(window,(function(){return function(t){var e={};function o(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)o.d(n,i,function(e){return t[e]}.bind(null,i));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=6)}([function(t,e,o){var n,i,a;i=[e],void 0===(a="function"==typeof(n=function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t){return function(t){if(Array.isArray(t)){for(var e=0,o=new Array(t.length);e<t.length;e++)o[e]=t[e];return o}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function n(t,e){for(var o=0;o<e.length;o++){var n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0; +/* + @license/i + * Font Awesome Free 5.11.2 by @fontawesome - https://fontawesome.com + * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) + */ +var i=[".doc",".docx",".xls",".xlsx",".ppt",".pptx",".pdf",".tif",".jpeg",".jpg",".gif",".bmp",".txt",".csv",".png",".msg",".wav",".mp3",".mp4",".zip",".rtf",".eps",".ai",".psd",".avi",".mov",".wmv",".cfg",".wss",".vsd",".vsdx",".tsd",".lic"],a="fas",r={textDecoration:{menu:{viewBox:"0 0 1792 1792",d:"M789 559l-170 450q33 0 136.5 2t160.5 2q19 0 57-2-87-253-184-452zm-725 1105l2-79q23-7 56-12.5t57-10.5 49.5-14.5 44.5-29 31-50.5l237-616 280-724h128q8 14 11 21l205 480q33 78 106 257.5t114 274.5q15 34 58 144.5t72 168.5q20 45 35 57 19 15 88 29.5t84 20.5q6 38 6 57 0 5-.5 13.5t-.5 12.5q-63 0-190-8t-191-8q-76 0-215 7t-178 8q0-43 4-78l131-28q1 0 12.5-2.5t15.5-3.5 14.5-4.5 15-6.5 11-8 9-11 2.5-14q0-16-31-96.5t-72-177.5-42-100l-450-2q-26 58-76.5 195.5t-50.5 162.5q0 22 14 37.5t43.5 24.5 48.5 13.5 57 8.5 41 4q1 19 1 58 0 9-2 27-58 0-174.5-10t-174.5-10q-8 0-26.5 4t-21.5 4q-80 14-188 14z"},group:[{bold:{viewBox:"0 0 1792 1792",d:"M747 1521q74 32 140 32 376 0 376-335 0-114-41-180-27-44-61.5-74t-67.5-46.5-80.5-25-84-10.5-94.5-2q-73 0-101 10 0 53-.5 159t-.5 158q0 8-1 67.5t-.5 96.5 4.5 83.5 12 66.5zm-14-746q42 7 109 7 82 0 143-13t110-44.5 74.5-89.5 25.5-142q0-70-29-122.5t-79-82-108-43.5-124-14q-50 0-130 13 0 50 4 151t4 152q0 27-.5 80t-.5 79q0 46 1 69zm-541 889l2-94q15-4 85-16t106-27q7-12 12.5-27t8.5-33.5 5.5-32.5 3-37.5.5-34v-65.5q0-982-22-1025-4-8-22-14.5t-44.5-11-49.5-7-48.5-4.5-30.5-3l-4-83q98-2 340-11.5t373-9.5q23 0 68 .5t68 .5q70 0 136.5 13t128.5 42 108 71 74 104.5 28 137.5q0 52-16.5 95.5t-39 72-64.5 57.5-73 45-84 40q154 35 256.5 134t102.5 248q0 100-35 179.5t-93.5 130.5-138 85.5-163.5 48.5-176 14q-44 0-132-3t-132-3q-106 0-307 11t-231 12z"}},{italic:{viewBox:"0 0 1792 1792",d:"M384 1662l17-85q22-7 61.5-16.5t72-19 59.5-23.5q28-35 41-101 1-7 62-289t114-543.5 52-296.5v-25q-24-13-54.5-18.5t-69.5-8-58-5.5l19-103q33 2 120 6.5t149.5 7 120.5 2.5q48 0 98.5-2.5t121-7 98.5-6.5q-5 39-19 89-30 10-101.5 28.5t-108.5 33.5q-8 19-14 42.5t-9 40-7.5 45.5-6.5 42q-27 148-87.5 419.5t-77.5 355.5q-2 9-13 58t-20 90-16 83.5-6 57.5l1 18q17 4 185 31-3 44-16 99-11 0-32.5 1.5t-32.5 1.5q-29 0-87-10t-86-10q-138-2-206-2-51 0-143 9t-121 11z"}},{underline:{viewBox:"0 0 1792 1792",d:"M176 223q-37-2-45-4l-3-88q13-1 40-1 60 0 112 4 132 7 166 7 86 0 168-3 116-4 146-5 56 0 86-2l-1 14 2 64v9q-60 9-124 9-60 0-79 25-13 14-13 132 0 13 .5 32.5t.5 25.5l1 229 14 280q6 124 51 202 35 59 96 92 88 47 177 47 104 0 191-28 56-18 99-51 48-36 65-64 36-56 53-114 21-73 21-229 0-79-3.5-128t-11-122.5-13.5-159.5l-4-59q-5-67-24-88-34-35-77-34l-100 2-14-3 2-86h84l205 10q76 3 196-10l18 2q6 38 6 51 0 7-4 31-45 12-84 13-73 11-79 17-15 15-15 41 0 7 1.5 27t1.5 31q8 19 22 396 6 195-15 304-15 76-41 122-38 65-112 123-75 57-182 89-109 33-255 33-167 0-284-46-119-47-179-122-61-76-83-195-16-80-16-237v-333q0-188-17-213-25-36-147-39zm1488 1409v-64q0-14-9-23t-23-9h-1472q-14 0-23 9t-9 23v64q0 14 9 23t23 9h1472q14 0 23-9t9-23z"}},{strikethrough:{viewBox:"0 0 1792 1792",d:"M1760 896q14 0 23 9t9 23v64q0 14-9 23t-23 9h-1728q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h1728zm-1277-64q-28-35-51-80-48-98-48-188 0-181 134-309 133-127 393-127 50 0 167 19 66 12 177 48 10 38 21 118 14 123 14 183 0 18-5 45l-12 3-84-6-14-2q-50-149-103-205-88-91-210-91-114 0-182 59-67 58-67 146 0 73 66 140t279 129q69 20 173 66 58 28 95 52h-743zm507 256h411q7 39 7 92 0 111-41 212-23 56-71 104-37 35-109 81-80 48-153 66-80 21-203 21-114 0-195-23l-140-40q-57-16-72-28-8-8-8-22v-13q0-108-2-156-1-30 0-68l2-37v-44l102-2q15 34 30 71t22.5 56 12.5 27q35 57 80 94 43 36 105 57 59 22 132 22 64 0 139-27 77-26 122-86 47-61 47-129 0-84-81-157-34-29-137-71z"}},{removeFormat:{viewBox:"0 0 640 512",d:"M336 416h-11.17l9.26-27.77L267 336.4 240.49 416H208a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h128a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm297.82 42.1L377 259.59 426.17 112H544v32a16 16 0 0 0 16 16h32a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16H176a16 16 0 0 0-16 16v43.9L45.46 3.38A16 16 0 0 0 23 6.19L3.37 31.46a16 16 0 0 0 2.81 22.45l588.36 454.72a16 16 0 0 0 22.46-2.81l19.64-25.27a16 16 0 0 0-2.82-22.45zM309.91 207.76L224 141.36V112h117.83z"}}]},listOptions:{menu:{viewBox:"0 0 1792 1792",d:"M256 1312v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm1536 768v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5zm-1536-1152v192q0 13-9.5 22.5t-22.5 9.5h-192q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h192q13 0 22.5 9.5t9.5 22.5zm1536 768v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1344q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1344q13 0 22.5 9.5t9.5 22.5z"},group:[{insertOrderedList:{viewBox:"0 0 1792 1792",d:"M381 1620q0 80-54.5 126t-135.5 46q-106 0-172-66l57-88q49 45 106 45 29 0 50.5-14.5t21.5-42.5q0-64-105-56l-26-56q8-10 32.5-43.5t42.5-54 37-38.5v-1q-16 0-48.5 1t-48.5 1v53h-106v-152h333v88l-95 115q51 12 81 49t30 88zm2-627v159h-362q-6-36-6-54 0-51 23.5-93t56.5-68 66-47.5 56.5-43.5 23.5-45q0-25-14.5-38.5t-39.5-13.5q-46 0-81 58l-85-59q24-51 71.5-79.5t105.5-28.5q73 0 123 41.5t50 112.5q0 50-34 91.5t-75 64.5-75.5 50.5-35.5 52.5h127v-60h105zm1409 319v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-14 9-23t23-9h1216q13 0 22.5 9.5t9.5 22.5zm-1408-899v99h-335v-99h107q0-41 .5-121.5t.5-121.5v-12h-2q-8 17-50 54l-71-76 136-127h106v404h108zm1408 387v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-14 9-23t23-9h1216q13 0 22.5 9.5t9.5 22.5zm0-512v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5z"}},{insertUnorderedList:{viewBox:"0 0 1792 1792",d:"M384 1408q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm0-512q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm1408 416v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5zm-1408-928q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm1408 416v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5zm0-512v192q0 13-9.5 22.5t-22.5 9.5h-1216q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1216q13 0 22.5 9.5t9.5 22.5"}}]},textAlign:{menu:{viewBox:"0 0 1792 1792",d:"M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45z"},group:[{indent:{viewBox:"0 0 1792 1792",d:"M352 832q0 14-9 23l-288 288q-9 9-23 9-13 0-22.5-9.5t-9.5-22.5v-576q0-13 9.5-22.5t22.5-9.5q14 0 23 9l288 288q9 9 9 23zm1440 480v192q0 13-9.5 22.5t-22.5 9.5h-1728q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1728q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1088q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1088q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1088q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1088q13 0 22.5 9.5t9.5 22.5zm0-384v192q0 13-9.5 22.5t-22.5 9.5h-1728q-13 0-22.5-9.5t-9.5-22.5v-192q0-13 9.5-22.5t22.5-9.5h1728q13 0 22.5 9.5t9.5 22.5z"}},{justifyLeft:{viewBox:"0 0 1792 1792",d:"M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-1280q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1280q26 0 45 19t19 45zm256-384v128q0 26-19 45t-45 19h-1536q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1536q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-1152q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1152q26 0 45 19t19 45z"}},{justifyCenter:{viewBox:"0 0 1792 1792",d:"M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-896q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h896q26 0 45 19t19 45zm256-384v128q0 26-19 45t-45 19h-1408q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1408q26 0 45 19t19 45zm-384-384v128q0 26-19 45t-45 19h-640q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h640q26 0 45 19t19 45z"}},{justifyRight:{viewBox:"0 0 1792 1792",d:"M1792 1344v128q0 26-19 45t-45 19h-1664q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1664q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1280q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1280q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1536q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1536q26 0 45 19t19 45zm0-384v128q0 26-19 45t-45 19h-1152q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1152q26 0 45 19t19 45z"}}]},attachments:{menu:{viewBox:"0 0 1792 1792",d:"M1596 1385q0 117-79 196t-196 79q-135 0-235-100l-777-776q-113-115-113-271 0-159 110-270t269-111q158 0 273 113l605 606q10 10 10 22 0 16-30.5 46.5t-46.5 30.5q-13 0-23-10l-606-607q-79-77-181-77-106 0-179 75t-73 181q0 105 76 181l776 777q63 63 145 63 64 0 106-42t42-106q0-82-63-145l-581-581q-26-24-60-24-29 0-48 19t-19 48q0 32 25 59l410 410q10 10 10 22 0 16-31 47t-47 31q-12 0-22-10l-410-410q-63-61-63-149 0-82 57-139t139-57q88 0 149 63l581 581q100 98 100 235z"},group:[{attachment:{viewBox:"0 0 1792 1792",d:"M1596 1385q0 117-79 196t-196 79q-135 0-235-100l-777-776q-113-115-113-271 0-159 110-270t269-111q158 0 273 113l605 606q10 10 10 22 0 16-30.5 46.5t-46.5 30.5q-13 0-23-10l-606-607q-79-77-181-77-106 0-179 75t-73 181q0 105 76 181l776 777q63 63 145 63 64 0 106-42t42-106q0-82-63-145l-581-581q-26-24-60-24-29 0-48 19t-19 48q0 32 25 59l410 410q10 10 10 22 0 16-31 47t-47 31q-12 0-22-10l-410-410q-63-61-63-149 0-82 57-139t139-57q88 0 149 63l581 581q100 98 100 235z"}},{link:{viewBox:"0 0 1792 1792",d:"M1520 1216q0-40-28-68l-208-208q-28-28-68-28-42 0-72 32 3 3 19 18.5t21.5 21.5 15 19 13 25.5 3.5 27.5q0 40-28 68t-68 28q-15 0-27.5-3.5t-25.5-13-19-15-21.5-21.5-18.5-19q-33 31-33 73 0 40 28 68l206 207q27 27 68 27 40 0 68-26l147-146q28-28 28-67zm-703-705q0-40-28-68l-206-207q-28-28-68-28-39 0-68 27l-147 146q-28 28-28 67 0 40 28 68l208 208q27 27 68 27 42 0 72-31-3-3-19-18.5t-21.5-21.5-15-19-13-25.5-3.5-27.5q0-40 28-68t68-28q15 0 27.5 3.5t25.5 13 19 15 21.5 21.5 18.5 19q33-31 33-73zm895 705q0 120-85 203l-147 146q-83 83-203 83-121 0-204-85l-206-207q-83-83-83-203 0-123 88-209l-88-88q-86 88-208 88-120 0-204-84l-208-208q-84-84-84-204t85-203l147-146q83-83 203-83 121 0 204 85l206 207q83 83 83 203 0 123-88 209l88 88q86-88 208-88 120 0 204 84l208 208q84 84 84 204z"}},{image:{viewBox:"0 0 2048 1792",d:"M704 576q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm1024 384v448h-1408v-192l320-320 160 160 512-512zm96-704h-1600q-13 0-22.5 9.5t-9.5 22.5v1216q0 13 9.5 22.5t22.5 9.5h1600q13 0 22.5-9.5t9.5-22.5v-1216q0-13-9.5-22.5t-22.5-9.5zm160 32v1216q0 66-47 113t-113 47h-1600q-66 0-113-47t-47-113v-1216q0-66 47-113t113-47h1600q66 0 113 47t47 113z"}}]}},l=["bold","italic","underline","strikethrough","removeFormat","insertOrderedList","insertUnorderedList","indent","justifyLeft","justifyCenter","justifyRight","attachment","link","image"],s="#777777",c=function(){function t(e,o){var n=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.establishBrowser(),this.range=new Range,this.files=[],this.optionGroups=r,o?(this.options=o,o.fontPack||(this.options.fontPack=a),o.extensions||(this.options.extensions=i),o.toolbarOptions||(this.options.toolbarOptions=l),o.activeOptionColor||(this.options.activeOptionColor=s)):this.options={fontPack:a,extensions:i,toolbarOptions:l,activeOptionColor:s},this.initEditor(e),this.initResponsive(),this.initOverflow(),e.StrivenEditor=function(){return n},this.bound_popupEscapeHandler=this.popupEscapeHandler.bind(this)}var c,u,d;return c=t,(u=[{key:"initEditor",value:function(t){var e=this;if(this.editor=t,this.toolbar=this.initToolbar(),this.body=this.initBody(),this.linkMenu=this.initLinkMenu(),this.imageMenu=this.initImageMenu(),this.metaDataSection=this.initMetaDataSection(),this.filesSection=this.initFilesSection(),this.editor.classList.add("editor","Striven-Editor"),this.options.toolbarHide){this.customToolbarButton&&(this.customToolbarButton.style.display="none"),this.toolbarOptionsGroup.style.display="none";var n=this.body.onfocus;this.body.onfocus=function(){n&&n(),e.overflow(),e.toolbarSlideUp()};var i=this.body.onblur;this.body.onblur=function(){i&&i(),e.overflow(),setTimeout((function(){"true"===e.linkMenu.dataset.active||"true"===e.imageMenu.dataset.active||e.isEditorInFocus()||e.toolbarSlideDown()}),500)}}this.toolbarOptions.forEach((function(t){t.style.cursor="pointer",t.style.userSelect="none";var n=t.onclick;t.onclick=function(i){var a=function(){var t=e.body.querySelectorAll("blockquote");o(t).forEach((function(t){return t.style.margin="0 0 0 40px"}))};e.body.focus(),window.getSelection().removeAllRanges(),window.getSelection().addRange(e.range);var r=t.id.split("-")[1];switch(r){case"insertOrderedList":e.isFirefox?(document.execCommand("indent"),document.execCommand(r),a()):e.isEdge?(document.execCommand(r),o(document.querySelectorAll("ol")).forEach((function(t){return t.style.marginLeft="40px"}))):(document.execCommand("indent",!0),document.execCommand(r,!0));break;case"insertUnorderedList":e.isFirefox?(document.execCommand("indent"),document.execCommand(r),a()):e.isEdge?(document.execCommand(r),o(document.querySelectorAll("ul")).forEach((function(t){return t.style.marginLeft="40px"}))):(document.execCommand("indent",!0),document.execCommand(r,!0));break;case"attachment":var l=document.createElement("input");l.style.display="none",l.type="file",l.onchange=function(t){return e.attachFile(l.files[0])},l.click();break;case"link":"true"===e.linkMenu.dataset.active?e.closeLinkMenu():(e.linkMenuSlideIn(),e.linkMenu.querySelector("input").focus());break;case"image":"true"===e.imageMenu.dataset.active?e.closeImageMenu():(e.imageMenuSlideIn(),e.range=e.getRange(),e.imageMenu.querySelector("input").focus());break;default:e.isFirefox||e.isEdge?(document.execCommand(r),"indent"===r&&a()):document.execCommand(r,!0),e.toolbarState()}n&&n()}})),this.editor.appendChild(this.toolbar),this.editor.appendChild(this.body),this.editor.appendChild(this.linkMenu),this.editor.appendChild(this.imageMenu),this.editor.appendChild(this.metaDataSection),this.editor.appendChild(this.filesSection),this.options.toolbarBottom&&(this.editor.removeChild(this.toolbar),this.editor.append(this.toolbar))}},{key:"imageMenuSlideIn",value:function(){var t=this;this.openImageMenu();var e=0,o=this.editor.offsetWidth/4,n=setInterval((function(){o<=10?(clearInterval(n),t.imageMenu.style.opacity=1):(o-=2.5,e+=.01,t.imageMenu.style.opacity="".concat(e),t.imageMenu.style.right="".concat(o,"px"))}),5);this.imageMenu.style.opacity=e}},{key:"linkMenuSlideIn",value:function(){var t=this;this.openLinkMenu();var e=0,o=this.editor.offsetWidth/4,n=setInterval((function(){o<=10?(clearInterval(n),t.linkMenu.style.opacity=1):(o-=2.5,e+=.01,t.linkMenu.style.opacity="".concat(e),t.linkMenu.style.right="".concat(o,"px"))}),5);this.linkMenu.style.opacity=e}},{key:"toolbarSlideUp",value:function(){var t=this,e=this.toolbar.offsetHeight,o=setInterval((function(){e>=40?(t.customToolbarButton&&(t.customToolbarButton.style.display="flex"),t.toolbarOptionsGroup.style.display="flex",clearInterval(o)):(e++,t.toolbar.style.minHeight="".concat(e,"px"))}),5)}},{key:"toolbarSlideDown",value:function(){var t=this;this.customToolbarButton&&(this.customToolbarButton.style.display="none"),this.toolbarOptionsGroup.style.display="none";var e=40,o=setInterval((function(){0===e?clearInterval(o):(e--,t.toolbar.style.minHeight="".concat(e,"px"))}),5)}},{key:"initToolbar",value:function(){var t=this,n=document.createElement("div");this.toolbarOptionsGroup=document.createElement("div");var i=Object.keys(this.optionGroups);n.classList.add("toolbar"),n.style.minHeight=this.options.toolbarHide?"0":"40px",this.toolbarOptionsGroup.classList.add("toolbar-options"),this.toolbarOptionsGroup.style.display=this.options.toolbarHide?"none":"flex",n.onclick=function(){return t.body.focus()},i.forEach((function(e){var o=document.createElement("div");o.classList.add("toolbar-menu"),o.id="menu-".concat(e),o.appendChild(t.constructSVG(t.optionGroups[e].menu)),t.toolbarOptionsGroup.appendChild(o);var n=document.createElement("div");n.classList.add("toolbar-group"),n.id="group-".concat(e),t.options.toolbarOptions.forEach((function(o){var i=t.optionGroups[e].group.filter((function(t){return t[o]}))[0];if(i){var a=i[o],r=t.constructSVG(a);r.classList.add("toolbar-option"),r.id="toolbar-".concat(o),n.appendChild(r)}})),t.toolbarOptionsGroup.appendChild(n)}));var a=this.options.toolbarOptions.filter((function(t){return"object"===e(t)}));if(a.length>0&&(this.customToolbarMenu=document.createElement("div"),this.customToolbarMenu.classList.add("toolbar-menu"),this.customToolbarMenu.id="menu-custom",this.customToolbarMenu.appendChild(this.constructSVG({viewBox:"0 0 1792 1792",d:"M1088 1248v192q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h192q40 0 68 28t28 68zm0-512v192q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h192q40 0 68 28t28 68zm0-512v192q0 40-28 68t-68 28h-192q-40 0-68-28t-28-68v-192q0-40 28-68t68-28h192q40 0 68 28t28 68z"})),this.toolbarOptionsGroup.appendChild(this.customToolbarMenu),this.customToolbarGroup=document.createElement("div"),this.customToolbarGroup.classList.add("toolbar-group"),this.customToolbarGroup.id="group-custom",a.forEach((function(e){var o=e.icon,n=e.handler,i=t.constructSVG(o);i.id="toolbar-customOption",i.style.margin="0 10px",i.onclick=function(){return n()},t.customToolbarGroup.appendChild(i)})),this.toolbarOptionsGroup.appendChild(this.customToolbarGroup)),n.appendChild(this.toolbarOptionsGroup),this.options.customToolbarButton){var r=document.createElement("div");r.id="custom-toolbar-button",r.classList.add("custom-toolbar-button"),r.style.minHeight=this.options.toolbarHide?"40px":n.style.minHeight,r.onclick=function(){return t.options.customToolbarButton.handler()},!this.options.toolbarHide&&(r.style.display="flex"),r.onmouseenter=function(){r.style.borderColor=t.options.customToolbarButton.hoverBorderColor,r.style.backgroundColor=t.options.customToolbarButton.hoverBackgroundColor,r.style.color=t.options.customToolbarButton.hoverColor},r.onmouseleave=function(){r.style.borderColor=t.options.customToolbarButton.borderColor,r.style.backgroundColor=t.options.customToolbarButton.backgroundColor,r.style.color=t.options.customToolbarButton.color};var l=this.constructSVG(this.options.customToolbarButton.svgData);l.querySelector("path").setAttribute("fill",this.options.customToolbarButton.color),r.appendChild(l),n.appendChild(r)}return this.toolbarOptions=n.querySelectorAll("span"),this.toolbarGroups=o(n.getElementsByClassName("toolbar-group")),this.toolbarMenus=o(n.getElementsByClassName("toolbar-menu")),this.customToolbarButton=n.querySelector("#custom-toolbar-button"),this.toolbarMenus.push(this.customToolbarMenu),this.toolbarGroups.push(this.customToolbarGroup),this.toolbarGroups.forEach((function(e){if(e&&e.children.length<1){var o=e.id.split("-")[1];t.toolbarMenus.filter((function(t){return t.id.split("-")[1]===o}))[0].remove()}})),n}},{key:"initBody",value:function(){var t=this,e=document.createElement("div");if(e.classList.add("body"),e.contentEditable="true",e.style.height=this.editor.style.height,e.style.minHeight=this.editor.style.minHeight,e.style.maxHeight=this.editor.style.maxHeight,this.editor.style.height="auto",this.editor.style.minHeight="auto",this.editor.style.maxHeight="auto",this.options.placeholder){var o=document.createElement("p");o.id="placeholder-node",o.style.color="#5f6368",o.style.margin="0",o.textContent=this.options.placeholder,e.append(o);var n=e.onfocus;e.onfocus=function(){n&&n(),e.querySelector("#placeholder-node")===o&&t.clearContent()};var i=e.onblur;e.onblur=function(){i&&i(),""===t.getContent().trim()&&e.append(o)}}e.onpaste=function(e){var o;if(e.clipboardData.files.length>0&&e.clipboardData.files[0].type.includes("image")&&(o=e.clipboardData.files[0],new Promise((function(t,e){var n=new FileReader;n.readAsDataURL(o),n.onload=function(){return t(n.result)},n.onerror=function(t){return e(t)}}))).then((function(e){t.options.imageUrl?t.getImage(e).then((function(t){document.execCommand("insertImage",!0,t.imageRef)})).catch((function(t){document.execCommand("insertImage",!0,e)})):(document.execCommand("insertImage",!0,e),t.options.uploadOnPaste&&t.attachFile(function(t,e){for(var o=t.split(","),n=o[0].match(/:(.*?);/)[1],i=atob(o[1]),a=i.length,r=new Uint8Array(a);a--;)r[a]=i.charCodeAt(a);var l=new File([r],e,{type:n});return new File([r],"".concat(l.name,".").concat(l.type.split("/").pop()),{type:l.type})}(e,"pastedimage"))),t.overflow()})),t.options.sanitizePaste&&e.clipboardData.types.includes("text/html")){var n;e.preventDefault();for(var i=0;i<e.clipboardData.items.length;i++){var a=e.clipboardData.items[i];"text/html"===a.type&&(n=a)}n&&n.getAsString((function(e){var o=t.getRange();o.insertNode(t.scrubHTML(e)),o.collapse()}))}e.clipboardData.items.length>0&&"text/plain"===e.clipboardData.items[0].type&&e.clipboardData.items[0].getAsString((function(e){t.options.metaUrl&&t.validURL(e)&&t.getMeta(e).then((function(e){var o=e.url,n=e.title,i=e.image,a=e.description;o&&n&&i&&t.createMetaDataElement(o,i,n,a)}))})),t.overflow()};var a=e.onkeyup;e.onkeyup=function(o){if(a&&a(),t.range=t.getRange(),t.options.submitOnEnter&&13===o.keyCode&&!o.shiftKey&&!document.queryCommandState("insertOrderedList")&&!document.queryCommandState("insertUnorderedList")){var n=!!t.getTextContent(),i=!!e.querySelector("img");if(n||i){var r=e.querySelectorAll("div"),l=r[r.length?r.length-1:0];l&&l.remove()}var s=t.getContent(),c=t.getFiles();t.clearContent(),t.clearFiles(),(c.length||n||i)&&t.options.submitOnEnter({content:(n||i)&&s,files:c})}t.toolbarState()};var r=e.onmouseup;return e.onmouseup=function(e){r&&r(),t.range=t.getRange()},e}},{key:"initLinkMenu",value:function(){var t=this,e=document.createElement("div"),n=document.createElement("div"),i=document.createElement("div"),a=document.createElement("button"),r=document.createElement("button"),l=document.createElement("p"),s=document.createElement("input");return e.id="link-menu",e.classList.add("popup"),e.dataset.active="false",n.classList.add("popup-form"),l.classList.add("form-label"),l.textContent="Web Address",s.classList.add("form-input"),s.type="text",s.placeholder="Insert a Link",i.classList.add("popup-button-container"),a.classList.add("popup-button"),a.classList.add("button-primary"),a.textContent="Insert Link",r.classList.add("popup-button"),r.classList.add("button-secondary"),r.textContent="Close",a.onclick=function(e){var n=s.value;n?(window.getSelection().removeAllRanges(),window.getSelection().addRange(t.range),t.isFirefox||t.isEdge?document.execCommand("createLink",!1,n):document.execCommand("createLink",!0,n),t.options.metaUrl&&t.validURL(n)&&t.getMeta(n).then((function(e){var o=e.url,n=e.image,i=e.title,a=e.description;o&&n&&i&&t.createMetaDataElement(o,n,i,a)})),o(t.body.querySelectorAll("a")).forEach((function(e){return!t.isFirefox&&(e.contentEditable="false")})),s.value="",t.closeLinkMenu()):(t.body.focus(),t.closeLinkMenu())},r.onclick=function(e){t.body.focus(),t.closeLinkMenu()},n.appendChild(l),n.appendChild(s),e.appendChild(n),i.appendChild(a),i.appendChild(r),e.appendChild(i),e}},{key:"initImageMenu",value:function(){var t=this,e=document.createElement("div"),n=document.createElement("div"),i=document.createElement("div"),a=document.createElement("button"),r=document.createElement("button"),l=document.createElement("p"),s=document.createElement("input");e.id="image-menu",e.classList.add("popup"),e.dataset.active="false",n.classList.add("popup-form"),l.classList.add("form-label"),l.textContent="Image URL",s.classList.add("form-input"),s.type="text",s.placeholder="Insert a Link",i.classList.add("popup-button-container"),a.classList.add("popup-button"),a.classList.add("button-primary"),a.textContent="Insert Image",r.classList.add("popup-button"),r.classList.add("button-secondary"),r.textContent="Close",n.appendChild(l),n.appendChild(s);var c=n.cloneNode(!0),u=c.querySelector("input"),d=c.querySelector("p");u.placeholder="Image Height",d.textContent="Height";var p=n.cloneNode(!0),h=p.querySelector("input"),m=p.querySelector("p");return h.placeholder="Image Width",m.textContent="Width",a.onclick=function(e){var n=s.value,i=u.value,a=h.value;if(n){window.getSelection().removeAllRanges(),window.getSelection().addRange(t.range),t.isFirefox||t.isEdge?document.execCommand("insertImage",!1,n):document.execCommand("insertImage",!0,n);var r=o(t.body.querySelectorAll("img")).filter((function(t){return t.src===n}));(r=r[r.length-1])&&(r.style.height="".concat(i,"px")),r&&(r.style.width="".concat(a,"px")),u.value="",h.value="",s.value="",t.closeImageMenu()}else t.body.focus(),t.closeImageMenu()},r.onclick=function(e){t.body.focus(),t.closeImageMenu()},e.appendChild(c),e.appendChild(p),e.appendChild(n),i.appendChild(a),i.appendChild(r),e.appendChild(i),e}},{key:"initMetaDataSection",value:function(){var t=document.createElement("div");return t.classList.add("metadata-section"),t}},{key:"initFilesSection",value:function(){var t=this,e=document.createElement("div");return e.classList.add("files-section"),this.body.ondragenter=function(e){t.body.style.backgroundColor="#ddd"},this.body.ondragleave=function(e){t.body.style.backgroundColor="inherit"},this.body.ondrop=function(e){t.body.style.backgroundColor="inherit",e.preventDefault();var o=e.dataTransfer.files&&e.dataTransfer.files[0];t.attachFile(o)},this.isEdge&&(this.body.ondragover=function(t){return t.preventDefault()}),e}},{key:"createFileElement",value:function(t,e){var o=this,n=document.createElement("div"),i=document.createElement("h4"),a=document.createElement("p"),r=document.createElement("p");i.textContent=t,a.textContent=e,r.textContent="X",n.classList.add("file-el"),n.dataset.fileindex=this.files.length-1,i.classList.add("file-name-el"),a.classList.add("file-size-el"),r.classList.add("remove-file-el"),r.onmouseenter=function(){return r.style.color="#ddd"},r.onmouseleave=function(){return r.style.color="black"},r.onclick=function(t){o.files.splice(t.target.parentElement.dataset.fileindex,1),t.target.parentElement.remove()},n.appendChild(i),n.appendChild(a),n.appendChild(r),this.filesSection.appendChild(n)}},{key:"createMetaDataElement",value:function(t,e,o,n){var i=document.createElement("div"),a=document.createElement("a"),r=document.createElement("img"),l=document.createElement("div"),s=document.createElement("h4"),c=document.createElement("p"),u=document.createElement("span");a.href=t,r.src=e,s.textContent=o,c.textContent=n,u.textContent="X",a.target="blank",i.classList.add("meta-item-el"),r.classList.add("meta-image-el"),s.classList.add("meta-data-title-el"),c.style.margin="0",u.classList.add("remove-meta-data-el"),u.onmouseenter=function(){return u.style.color="#ddd"},u.onmouseleave=function(){return u.style.color="black"},u.onclick=function(t){return t.target.parentElement.remove()},a.appendChild(r),l.appendChild(s),l.appendChild(c),i.appendChild(a),i.appendChild(l),i.appendChild(u),this.metaDataSection.appendChild(i)}},{key:"constructSVG",value:function(t){var e=t.viewBox,o=t.d,n=this.options.toolbarOptionFillColor?this.options.toolbarOptionFillColor:"#333",i=document.createElement("span"),a='<svg width="'.concat("16",'" height="').concat("14",'" viewBox="').concat(e,'" xmlns="').concat("http://www.w3.org/2000/svg",'">'),r='<path fill="'.concat(n,'" d="').concat(o,'"/>');return i.innerHTML="".concat(a).concat(r,"</svg>"),i}},{key:"initResponsive",value:function(){var t=this,e=this;if(this.options.minimal)this.toolbarMenus.forEach((function(t){return t&&(t.style.display="none")})),this.toolbar.querySelector("#toolbar-strikethrough").style.display="none",this.toolbar.querySelector("#toolbar-image").style.display="none",this.toolbar.querySelector("#toolbar-insertOrderedList").style.display="none",this.toolbar.querySelector("#group-textAlign").style.display="none",this.toolbar.querySelector("#toolbar-removeFormat").style.display="none";else{var o=function(t){e.toolbarGroups.forEach((function(o){o&&(o.dataset.open="false",o.style.display=t?"none":"block",o.style.position=t?"absolute":"relative",!e.options.toolbarBottom&&(o.style.top=t?"50px":"inherit"),e.options.toolbarBottom&&(o.style.bottom=t?"50px":"inherit"))})),e.toolbarMenus.forEach((function(o){o&&(o.style.padding="0 10px",o.style.cursor="pointer",o.style.userSelect="none",o.style.display=t?"block":"none",o.onclick=function(t){var n;"false"===(n=e.toolbar.querySelector("#group-".concat(o.id.split("-")[1]))).dataset.open?(e.toolbarGroups.forEach((function(t){t&&"true"===t.dataset.open&&(t.style.display="none",t.dataset.open="false")})),n.style.display="block",n.style.padding="5px 5px 0 5px",n.dataset.open="true"):(n.style.display="none",n.dataset.open="false"),e.body.focus()})}))},n=function(){i=window.matchMedia("(max-width: 700px)").matches,o(i)},i=window.matchMedia("(max-width: 700px)").matches;n(),window.onresize=function(){t.toolbarGroups.forEach((function(t){return t&&(t.style.padding="0")})),t.closeLinkMenu(),t.closeImageMenu(),n()}}}},{key:"initOverflow",value:function(){var t=this,e=this.body.onfocus;this.body.onfocus=function(){e&&e(),t.overflow()};var o=this.body.onblur;this.body.onblur=function(){o&&o(),t.overflow()};var n=this.body.onkeypress;this.body.onkeypress=function(){n&&n(),t.overflow()}}},{key:"getFiles",value:function(){return this.files}},{key:"getContent",value:function(){return this.body.querySelector("#placeholder-node")?"":this.body.innerHTML}},{key:"getRange",value:function(){return window.getSelection().getRangeAt(0)}},{key:"getMeta",value:function(t){return fetch(this.options.metaUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetUrl:t})}).then((function(t){return t.json()}))}},{key:"getImage",value:function(t){return fetch(this.options.imageUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({imageEncoding:t})}).then((function(t){return t.json()}))}},{key:"validURL",value:function(t){return!!new RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$","i").test(t)}},{key:"overflow",value:function(){var t=this.body;t.scrollHeight>t.clientHeight?t.style.overflowY="scroll":t.style.overflowY="hidden",t.scrollWidth>t.clientWidth?t.style.overflowX="scroll":t.style.overflowX="hidden"}},{key:"formatBytes",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(0===t)return"0 Bytes";var o=1024,n=e<0?0:e,i=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],a=Math.floor(Math.log(t)/Math.log(o));return parseFloat((t/Math.pow(o,a)).toFixed(n))+" "+i[a]}},{key:"validateFile",value:function(t){var e=t.type.split("/").pop();return this.options.extensions.includes(".".concat(e))}},{key:"attachFile",value:function(t){this.validateFile(t)?(this.files.push(t),this.createFileElement(t.name,this.formatBytes(t.size))):this.fileInvalid()}},{key:"fileInvalid",value:function(){var t=this;this.body.style.transition="background-color .5s",this.body.style.backgroundColor="#d9534f",setTimeout((function(){t.body.style.backgroundColor="inherit",setTimeout((function(){return t.body.style.transition="none"}),500)}),2e3)}},{key:"openLinkMenu",value:function(){this.closeImageMenu(),this.linkMenu.dataset.active="true",this.linkMenu.style.display="block",this.addPopupEscapeHandler()}},{key:"openImageMenu",value:function(){this.closeLinkMenu(),this.imageMenu.dataset.active="true",this.imageMenu.style.display="block",this.addPopupEscapeHandler()}},{key:"closeLinkMenu",value:function(){this.linkMenu.dataset.active="false",this.linkMenu.style.display="none",this.removePopupEscapeHandler()}},{key:"closeImageMenu",value:function(){this.imageMenu.dataset.active="false",this.imageMenu.style.display="none",this.removePopupEscapeHandler()}},{key:"popupEscapeHandler",value:function(t){27===t.which&&(this.closeImageMenu(),this.closeLinkMenu())}},{key:"addPopupEscapeHandler",value:function(){this.removePopupEscapeHandler(),this.editor.addEventListener("keyup",this.bound_popupEscapeHandler)}},{key:"removePopupEscapeHandler",value:function(){this.editor.removeEventListener("keyup",this.bound_popupEscapeHandler)}},{key:"setContent",value:function(t){this.clearContent(),this.body.innerHTML=t}},{key:"clearContent",value:function(){this.body.innerHTML=""}},{key:"clearFiles",value:function(){this.files=[],this.filesSection.innerHTML=""}},{key:"getTextContent",value:function(){return this.body.querySelector("#placeholder-node")?"":this.body.textContent}},{key:"scrubHTML",value:function(t){var e=document.createElement("div"),o=document.createElement("div");return e.innerHTML=t,o.append(document.createTextNode(e.textContent)),o}},{key:"toolbarState",value:function(){var t=this;this.options.toolbarOptions.forEach((function(e){var o=t.toolbar.querySelector("#toolbar-".concat(e));e.includes("justify")||e.includes("list")||(document.queryCommandState(e)?o.querySelector("path").setAttribute("fill",t.options.activeOptionColor):o.querySelector("path").setAttribute("fill","#333"))}))}},{key:"establishBrowser",value:function(){this.isOpera=!!window.opr&&!!opr.addons||!!window.opera||navigator.userAgent.indexOf(" OPR/")>=0,this.isFirefox="undefined"!=typeof InstallTrigger,this.isSafari=/constructor/i.test(window.HTMLElement)||"[object SafariRemoteNotification]"===(!window.safari||"undefined"!=typeof safari&&safari.pushNotification).toString(),this.isIE=!!document.documentMode,this.isEdge=!this.isIE&&!!window.StyleMedia,this.isChrome=!(!window.chrome||!window.chrome.webstore&&!window.chrome.runtime),this.isBlink=(this.isChrome||this.isOpera)&&!!window.CSS}},{key:"isEditorInFocus",value:function(){var t=this;return function e(o){return o===t.editor||o!==document.body&&o.parentNode&&e(o.parentNode)}(document.activeElement)}}])&&n(c.prototype,u),d&&n(c,d),t}();t.default=c})?n.apply(e,i):n)||(t.exports=a)},function(t,e,o){"use strict";o.r(e);var n=o(2),i=o.n(n);for(var a in n)"default"!==a&&function(t){o.d(e,t,(function(){return n[t]}))}(a);e.default=i.a},function(t,e,o){var n,i,a;i=[e,o(0)],void 0===(a="function"==typeof(n=function(t,e){"use strict";var o;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,e=(o=e)&&o.__esModule?o:{default:o};var n={name:"striven-editor",props:{toolbarHide:Boolean,toolbarBotoom:Boolean,minimal:Boolean,metaUrl:String,extensions:Array,uploadOnPaste:Boolean,toolbarOptionFillColor:String,placeholder:String,sanitizePaste:String,imageUrl:String,customToolbarOption:Object,activeOptionColor:String,submitOnEnter:Function},mounted:function(){this.editor=new e.default(this.$refs.editor,this.props)},data:function(){return{editor:{}}}};t.default=n})?n.apply(e,i):n)||(t.exports=a)},function(t,e,o){"use strict";var n=function(){var t=this.$createElement;return(this._self._c||t)("div",{ref:"editor"})},i=[];n._withStripped=!0,o.d(e,"a",(function(){return n})),o.d(e,"b",(function(){return i}))},function(t,e,o){"use strict";function n(t,e,o,n,i,a,r,l){var s,c="function"==typeof t?t.options:t;if(e&&(c.render=e,c.staticRenderFns=o,c._compiled=!0),n&&(c.functional=!0),a&&(c._scopeId="data-v-"+a),r?(s=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),i&&i.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(r)},c._ssrRegister=s):i&&(s=l?function(){i.call(this,this.$root.$options.shadowRoot)}:i),s)if(c.functional){c._injectStyles=s;var u=c.render;c.render=function(t,e){return s.call(e),u(t,e)}}else{var d=c.beforeCreate;c.beforeCreate=d?[].concat(d,s):[s]}return{exports:t,options:c}}o.d(e,"a",(function(){return n}))},,function(t,e,o){"use strict";o.r(e);var n=o(3),i=o(1);for(var a in i)"default"!==a&&function(t){o.d(e,t,(function(){return i[t]}))}(a);var r=o(4),l=Object(r.a)(i.default,n.a,n.b,!1,null,null,null);l.options.__file="src/vue-striveneditor.vue",e.default=l.exports}])})); +\ No newline at end of file diff --git a/dist/vue-striveneditor.js.LICENSE b/dist/vue-striveneditor.js.LICENSE @@ -1,5 +1,5 @@ -/*!***********************************!*\ - !*** ./src/vue-striveneditor.vue ***! - \***********************************/ - -/*! no static exports found */ +/* + @license/i + * Font Awesome Free 5.11.2 by @fontawesome - https://fontawesome.com + * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) + */ diff --git a/package-lock.json b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@striven-erp/striven-editor", - "version": "1.3.0", + "version": "2.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -894,6 +894,64 @@ "integrity": "sha512-9fq4jZVhPNW8r+UYKnxF1e2HkDWOWKM5bC2/7c9wPV835I0aOrVbS/Hw/pWPk2uKrNXQqg9Z959Kz+IYDd5p3w==", "dev": true }, + "@vue/component-compiler-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@vue/component-compiler-utils/-/component-compiler-utils-3.0.0.tgz", + "integrity": "sha512-am+04/0UX7ektcmvhYmrf84BDVAD8afFOf4asZjN84q8xzxFclbk5x0MtxuKGfp+zjN5WWPJn3fjFAWtDdIGSw==", + "dev": true, + "requires": { + "consolidate": "^0.15.1", + "hash-sum": "^1.0.2", + "lru-cache": "^4.1.2", + "merge-source-map": "^1.1.0", + "postcss": "^7.0.14", + "postcss-selector-parser": "^5.0.0", + "prettier": "1.16.3", + "source-map": "~0.6.1", + "vue-template-es2015-compiler": "^1.9.0" + }, + "dependencies": { + "cssesc": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-2.0.0.tgz", + "integrity": "sha512-MsCAG1z9lPdoO/IUMLSBWBSVxVtJ1395VGIQ+Fc2gNdkQ1hNDnQdw3YhA71WJCBW1vdwA0cAnk/DnW6bqoEUYg==", + "dev": true + }, + "lru-cache": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", + "dev": true, + "requires": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, + "postcss-selector-parser": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-5.0.0.tgz", + "integrity": "sha512-w+zLE5Jhg6Liz8+rQOWEAwtwkyqpfnmsinXjXg6cY7YIONZZtgvE0v2O0uhQBs0peNomOJwWRKt6JBfTdTd3OQ==", + "dev": true, + "requires": { + "cssesc": "^2.0.0", + "indexes-of": "^1.0.1", + "uniq": "^1.0.1" + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "dev": true + } + } + }, "@webassemblyjs/ast": { "version": "1.8.5", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.8.5.tgz", @@ -1963,6 +2021,15 @@ "date-now": "^0.1.4" } }, + "consolidate": { + "version": "0.15.1", + "resolved": "https://registry.npmjs.org/consolidate/-/consolidate-0.15.1.tgz", + "integrity": "sha512-DW46nrsMJgy9kqAbPt5rKaCr7uFtpo4mSUvLHIUbJEjm0vo+aY5QLwBUq3FK4tRnJr/X0Psc0C4jf/h+HtXSMw==", + "dev": true, + "requires": { + "bluebird": "^3.1.1" + } + }, "constants-browserify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", @@ -2128,6 +2195,38 @@ "randomfill": "^1.0.3" } }, + "css-loader": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-3.2.0.tgz", + "integrity": "sha512-QTF3Ud5H7DaZotgdcJjGMvyDj5F3Pn1j/sC6VBEOVp94cbwqyIBdcs/quzj4MC1BKQSrTpQznegH/5giYbhnCQ==", + "dev": true, + "requires": { + "camelcase": "^5.3.1", + "cssesc": "^3.0.0", + "icss-utils": "^4.1.1", + "loader-utils": "^1.2.3", + "normalize-path": "^3.0.0", + "postcss": "^7.0.17", + "postcss-modules-extract-imports": "^2.0.0", + "postcss-modules-local-by-default": "^3.0.2", + "postcss-modules-scope": "^2.1.0", + "postcss-modules-values": "^3.0.0", + "postcss-value-parser": "^4.0.0", + "schema-utils": "^2.0.0" + }, + "dependencies": { + "schema-utils": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.5.0.tgz", + "integrity": "sha512-32ISrwW2scPXHUSusP8qMg5dLUawKkyV+/qIEV9JdXKx+rsM6mi8vZY8khg2M69Qom16rtroWXD3Ybtiws38gQ==", + "dev": true, + "requires": { + "ajv": "^6.10.2", + "ajv-keywords": "^3.4.1" + } + } + } + }, "css-select": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", @@ -2146,6 +2245,12 @@ "integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==", "dev": true }, + "cssesc": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", + "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", + "dev": true + }, "cssfilter": { "version": "0.0.10", "resolved": "https://registry.npmjs.org/cssfilter/-/cssfilter-0.0.10.tgz", @@ -2164,6 +2269,12 @@ "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", "dev": true }, + "de-indent": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/de-indent/-/de-indent-1.0.2.tgz", + "integrity": "sha1-sgOOhG3DO6pXlhKNCAS0VbjB4h0=", + "dev": true + }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -3654,6 +3765,12 @@ "safe-buffer": "^5.0.1" } }, + "hash-sum": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/hash-sum/-/hash-sum-1.0.2.tgz", + "integrity": "sha1-M7QHd3VMZDJXPBIMw4CLvRDUfwQ=", + "dev": true + }, "hash.js": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", @@ -3664,6 +3781,12 @@ "minimalistic-assert": "^1.0.1" } }, + "he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true + }, "hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", @@ -3789,6 +3912,15 @@ "safer-buffer": ">= 2.1.2 < 3" } }, + "icss-utils": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-4.1.1.tgz", + "integrity": "sha512-4aFq7wvWyMHKgxsH8QQtGpvbASCf+eM3wPRLI6R+MgAnTCZ6STYsRvttLvRWK0Nfif5piF394St3HeJDaljGPA==", + "dev": true, + "requires": { + "postcss": "^7.0.14" + } + }, "ieee754": { "version": "1.1.13", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", @@ -3823,6 +3955,12 @@ "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", "dev": true }, + "indexes-of": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/indexes-of/-/indexes-of-1.0.1.tgz", + "integrity": "sha1-8w9xbI4r00bHtn0985FVZqfAVgc=", + "dev": true + }, "infer-owner": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/infer-owner/-/infer-owner-1.0.4.tgz", @@ -4328,6 +4466,23 @@ "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=", "dev": true }, + "merge-source-map": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/merge-source-map/-/merge-source-map-1.1.0.tgz", + "integrity": "sha512-Qkcp7P2ygktpMPh2mCQZaf3jhN6D3Z/qVZHSdWvQ+2Ef5HgRAPBO57A77+ENm0CPx2+1Ce/MYKi3ymqdfuqibw==", + "dev": true, + "requires": { + "source-map": "^0.6.1" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, "merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -5004,12 +5159,95 @@ "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", "dev": true }, + "postcss": { + "version": "7.0.18", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.18.tgz", + "integrity": "sha512-/7g1QXXgegpF+9GJj4iN7ChGF40sYuGYJ8WZu8DZWnmhQ/G36hfdk3q9LBJmoK+lZ+yzZ5KYpOoxq7LF1BxE8g==", + "dev": true, + "requires": { + "chalk": "^2.4.2", + "source-map": "^0.6.1", + "supports-color": "^6.1.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, + "postcss-modules-extract-imports": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-2.0.0.tgz", + "integrity": "sha512-LaYLDNS4SG8Q5WAWqIJgdHPJrDDr/Lv775rMBFUbgjTz6j34lUznACHcdRWroPvXANP2Vj7yNK57vp9eFqzLWQ==", + "dev": true, + "requires": { + "postcss": "^7.0.5" + } + }, + "postcss-modules-local-by-default": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/postcss-modules-local-by-default/-/postcss-modules-local-by-default-3.0.2.tgz", + "integrity": "sha512-jM/V8eqM4oJ/22j0gx4jrp63GSvDH6v86OqyTHHUvk4/k1vceipZsaymiZ5PvocqZOl5SFHiFJqjs3la0wnfIQ==", + "dev": true, + "requires": { + "icss-utils": "^4.1.1", + "postcss": "^7.0.16", + "postcss-selector-parser": "^6.0.2", + "postcss-value-parser": "^4.0.0" + } + }, + "postcss-modules-scope": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/postcss-modules-scope/-/postcss-modules-scope-2.1.0.tgz", + "integrity": "sha512-91Rjps0JnmtUB0cujlc8KIKCsJXWjzuxGeT/+Q2i2HXKZ7nBUeF9YQTZZTNvHVoNYj1AthsjnGLtqDUE0Op79A==", + "dev": true, + "requires": { + "postcss": "^7.0.6", + "postcss-selector-parser": "^6.0.0" + } + }, + "postcss-modules-values": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/postcss-modules-values/-/postcss-modules-values-3.0.0.tgz", + "integrity": "sha512-1//E5jCBrZ9DmRX+zCtmQtRSV6PV42Ix7Bzj9GbwJceduuf7IqP8MgeTXuRDHOWj2m0VzZD5+roFWDuU8RQjcg==", + "dev": true, + "requires": { + "icss-utils": "^4.0.0", + "postcss": "^7.0.6" + } + }, + "postcss-selector-parser": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.2.tgz", + "integrity": "sha512-36P2QR59jDTOAiIkqEprfJDsoNrvwFei3eCqKd1Y0tUsBimsq39BLp7RD+JWny3WgB1zGhJX8XVePwm9k4wdBg==", + "dev": true, + "requires": { + "cssesc": "^3.0.0", + "indexes-of": "^1.0.1", + "uniq": "^1.0.1" + } + }, + "postcss-value-parser": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.0.2.tgz", + "integrity": "sha512-LmeoohTpp/K4UiyQCwuGWlONxXamGzCMtFxLq4W1nZVGIQLYvMCJx3yAF9qyyuFpflABI9yVdtJAqbihOsCsJQ==", + "dev": true + }, "prepend-http": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=", "dev": true }, + "prettier": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.16.3.tgz", + "integrity": "sha512-kn/GU6SMRYPxUakNXhpP0EedT/KmaPzr0H5lIsDogrykbaxOpOfAFfk5XA7DZrJyMAv1wlMV3CPcZruGXVVUZw==", + "dev": true + }, "private": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", @@ -5886,6 +6124,28 @@ "integrity": "sha1-IrD6OkE4WzO+PzMVUbu4N/oM164=", "dev": true }, + "style-loader": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/style-loader/-/style-loader-1.0.0.tgz", + "integrity": "sha512-B0dOCFwv7/eY31a5PCieNwMgMhVGFe9w+rh7s/Bx8kfFkrth9zfTZquoYvdw8URgiqxObQKcpW51Ugz1HjfdZw==", + "dev": true, + "requires": { + "loader-utils": "^1.2.3", + "schema-utils": "^2.0.1" + }, + "dependencies": { + "schema-utils": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.5.0.tgz", + "integrity": "sha512-32ISrwW2scPXHUSusP8qMg5dLUawKkyV+/qIEV9JdXKx+rsM6mi8vZY8khg2M69Qom16rtroWXD3Ybtiws38gQ==", + "dev": true, + "requires": { + "ajv": "^6.10.2", + "ajv-keywords": "^3.4.1" + } + } + } + }, "supports-color": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", @@ -6249,6 +6509,12 @@ "set-value": "^2.0.1" } }, + "uniq": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz", + "integrity": "sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=", + "dev": true + }, "unique-filename": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.1.tgz", @@ -6436,6 +6702,51 @@ "integrity": "sha512-iq+S7vZJE60yejDYM0ek6zg308+UZsdtPExWP9VZoCFCz1zkJoXFnAX7aZfd/ZwrkidzdUZL0C/ryW+JwAiIGw==", "dev": true }, + "vue-hot-reload-api": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz", + "integrity": "sha512-BXq3jwIagosjgNVae6tkHzzIk6a8MHFtzAdwhnV5VlvPTFxDCvIttgSiHWjdGoTJvXtmRu5HacExfdarRcFhog==", + "dev": true + }, + "vue-loader": { + "version": "15.7.1", + "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-15.7.1.tgz", + "integrity": "sha512-fwIKtA23Pl/rqfYP5TSGK7gkEuLhoTvRYW+TU7ER3q9GpNLt/PjG5NLv3XHRDiTg7OPM1JcckBgds+VnAc+HbA==", + "dev": true, + "requires": { + "@vue/component-compiler-utils": "^3.0.0", + "hash-sum": "^1.0.2", + "loader-utils": "^1.1.0", + "vue-hot-reload-api": "^2.3.0", + "vue-style-loader": "^4.1.0" + } + }, + "vue-style-loader": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.2.tgz", + "integrity": "sha512-0ip8ge6Gzz/Bk0iHovU9XAUQaFt/G2B61bnWa2tCcqqdgfHs1lF9xXorFbE55Gmy92okFT+8bfmySuUOu13vxQ==", + "dev": true, + "requires": { + "hash-sum": "^1.0.2", + "loader-utils": "^1.0.2" + } + }, + "vue-template-compiler": { + "version": "2.6.10", + "resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.6.10.tgz", + "integrity": "sha512-jVZkw4/I/HT5ZMvRnhv78okGusqe0+qH2A0Em0Cp8aq78+NK9TII263CDVz2QXZsIT+yyV/gZc/j/vlwa+Epyg==", + "dev": true, + "requires": { + "de-indent": "^1.0.2", + "he": "^1.1.0" + } + }, + "vue-template-es2015-compiler": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.9.1.tgz", + "integrity": "sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==", + "dev": true + }, "watchpack": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.6.0.tgz", diff --git a/package.json b/package.json @@ -1,8 +1,7 @@ { "name": "@striven-erp/striven-editor", - "sideEffects": false, "private": false, - "version": "1.3.0", + "version": "2.0.0", "description": "The lightweight Striven WYSIWYG editor built with pure JavaScript.", "main": "./dist", "scripts": { @@ -36,6 +35,7 @@ "babel-loader": "^8.0.6", "body-parser": "^1.19.0", "cors": "^2.8.5", + "css-loader": "^3.2.0", "express": "^4.17.1", "gh-pages": "^2.1.1", "got": "^9.6.0", @@ -45,7 +45,10 @@ "metascraper-title": "^5.7.4", "metascraper-url": "^5.7.4", "shortid": "^2.2.15", + "style-loader": "^1.0.0", "terser-webpack-plugin": "^2.0.1", + "vue-loader": "^15.7.1", + "vue-template-compiler": "^2.6.10", "webpack": "^4.40.2", "webpack-cli": "^3.3.9" }, diff --git a/src/index.js b/src/index.js @@ -1,10 +1,5 @@ -import StrivenEditor from './striveneditor'; - -// class Striven { - // whatIs() { - // console.log('An ERP Platform.'); - // } -// } +import './striveneditor.css'; export { default as StrivenEditor } from './striveneditor'; -// export { Striven }; -\ No newline at end of file +export { default as KoStrivenEditor } from './ko-striveneditor'; +export { default as VueStrivenEditor } from './vue-striveneditor.vue'; +\ No newline at end of file diff --git a/src/ko-striveneditor.js b/src/ko-striveneditor.js @@ -0,0 +1,14 @@ +import StrivenEditor from './striveneditor'; + +export default class KoStrivenEditor { + constructor(ko) { + ko.bindingHandlers.striveneditor = { + init: function (element, valueAccessor, allBindings, viewModel, bindingContext) { + var valueOption = valueAccessor(); + var value = ko.utils.unwrapObservable(valueOption); + + var editor = new StrivenEditor(value); + } + } + } +} +\ No newline at end of file diff --git a/src/striveneditor.css b/src/striveneditor.css @@ -0,0 +1,221 @@ +/** +** - Editor +** - Toolbar +** - Image Menu +** - File element +** - Meta Item +** - Link Menu +*/ + +/** Editor **/ + +.Striven-Editor.editor { + border: 2px solid #ddd; + display: flex; + position: relative; + flex-direction: column; + font-family: Arial; + max-width: 100%; +} + +.Striven-Editor .body { + outline: none; + padding: 10px 20px; + min-height: auto; + max-height: auto; + height: auto; +} + + +/** Toolbar **/ + +.Striven-Editor .toolbar { + display: flex; + justify-content: space-between; + align-items: center; + flex-wrap: wrap; + position: relative +} + +.Striven-Editor .toolbar-options { + margin: 0 10px; +} + +.Striven-Editor .toolbar-option { + padding: 8px; +} + +.Striven-Editor .toolbar-group[data-open="true"] .toolbar-option { + background-color: #fff; + border: 2px solid #ddd; + margin: 0 2px; +} + +.Striven-Editor .toolbar-group[data-open="true"] .toolbar-option:hover { + background-color: #ddd; +} + +.Striven-Editor .toolbar-option >svg { + vertical-align: middle; +} + +.Striven-Editor .toolbar-option:hover, +.Striven-Editor .toolbar-option:focus, +.Striven-Editor .toolbar-option:active { + background-color: #ddd; +} + +.Striven-Editor .custom-toolbar-button { + display: none; + color: #fff; + background-color: #5cb85c; + width: 50px; + text-align: center; + justify-content: center; + align-content: center; + align-items: center; + cursor: pointer; + border: 1px solid #4cae4c; + align-self: flex-end +} + + +/** File Element **/ + +.Striven-Editor .file-el { + width: 100%; + display: flex; + flex-direction: column; + margin: 10px; + position: relative; +} + +.Striven-Editor .file-name-el { + font-weight: bold; + margin: 0; +} + +.Striven-Editor .file-size-el { + font-size: 12px; + margin: 2px 0; +} + +.Striven-Editor .remove-file-el { + margin: 0; + user-select: none; + color: black; + position: absolute; + right: 5px; + top: -5px; + cursor: pointer; + background-color: #fff +} + +/** Meta Item **/ + +.Striven-Editor .meta-item-el { + width: 100%; + display: flex; + margin: 10px; + position: relative +} + +.Striven-Editor .meta-image-el { + margin-right: 10px; + height: 50px; + width: 75px; +} + +.Striven-Editor .meta-data-title-el { + font-weight: bold; + margin: 0; +} + +.Striven-Editor .remove-meta-data-el { + user-select: none; + color: black; + position: absolute; + right: 5px; + top: -5px; + cursor: pointer; + background-color: #fff; +} + +.Striven-Editor .metadata-section, .Striven-Editor .files-section { + display: flex; + flex-wrap: wrap; + z-index: 500 +} + +/** Popup Menu **/ + +.Striven-Editor .popup { + display: none; + position: absolute; + right: 10px; + bottom: 10px; + background-color: #fff; + border: 2px solid #ddd; + padding: 10px 20px; + z-index: 1000; +} + + +.Striven-Editor .popup > .popup-form { + display: flex; + justify-content: space-between; + margin: 5px 0; +} + +.Striven-Editor .popup > .popup-form > .form-label { + margin: 8px 10px 8px 0; + font-size: 14px; + width: 100%; + text-align: right; + margin-right: 10px; +} + +.Striven-Editor .popup > .popup-form >.form-input { + outline: none; + padding: 0 5px; +} + + +.Striven-Editor .popup-button-container +{ + float:right; +} + +.Striven-Editor .popup-button{ + cursor: pointer; + padding: 6px 12px; + border: 1px solid transparent; + font-size: 14px; + outline: none; + color: #333; + margin:2px; +} + +.Striven-Editor .popup-button.button-primary{ + border-color: #4cae4c; + background-color: #5cb85c; + color: #fff; +} +.Striven-Editor .popup-button.button-secondary{ + border-color: #ccc; + background-color: #fff; + color: #333; +} +.Striven-Editor .popup-button.button-primary:hover, +.Striven-Editor .popup-button.button-primary:active, +.Striven-Editor .popup-button.button-primary:focus{ + background-color: #4cae4c; + border-color: #398439; +} +.Striven-Editor .popup-button.button-secondary:hover, +.Striven-Editor .popup-button.button-secondary:active, +.Striven-Editor .popup-button.button-secondary:focus{ + background-color: #d4d4d4; + border-color: #8c8c8c; +} + diff --git a/src/striveneditor.js b/src/striveneditor.js @@ -1,3 +1,9 @@ +/* +@license/i +* Font Awesome Free 5.11.2 by @fontawesome - https://fontawesome.com +* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) +*/ + const EXTENSIONS = [ ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".tif", ".jpeg", ".jpg", ".gif", ".bmp", ".txt", ".csv", ".png", ".msg", ".wav", ".mp3", @@ -69,7 +75,7 @@ const DEFAULTOPTIONS = [ "link", "image" ]; -const ACTIVEOPTIONCOLOR = "#ddd"; +const ACTIVEOPTIONCOLOR = "#777777"; export default class StrivenEditor { constructor(el, options) { @@ -98,14 +104,10 @@ export default class StrivenEditor { this.initResponsive(); this.initOverflow(); - // Safari Fix - // const documentMouseUp = document.onmouseup; - // document.onmouseup = e => { - // documentMouseUp && documentMouseUp(); - // this.range = this.getRange(); - // } - el.StrivenEditor = () => this; + + //bind handler functions to scope + this.bound_popupEscapeHandler=this.popupEscapeHandler.bind(this); } initEditor(el) { @@ -117,15 +119,7 @@ export default class StrivenEditor { this.metaDataSection = this.initMetaDataSection(); this.filesSection = this.initFilesSection(); - this.editor.style.border = "2px solid #ddd"; - this.editor.style.display = "flex"; - this.editor.style.position = "relative"; - this.editor.style.flexDirection = "column"; - this.editor.style.fontFamily = "Arial"; - - // this.editor.style.minHeight = "auto"; - // this.editor.style.maxHeight = "auto"; - this.editor.style.maxWidth = "100%"; + this.editor.classList.add("editor", "Striven-Editor") // Toolbar Hide if (this.options.toolbarHide) { @@ -135,6 +129,7 @@ export default class StrivenEditor { const bodyFocus = this.body.onfocus; this.body.onfocus = () => { bodyFocus && bodyFocus(); + this.overflow(); this.toolbarSlideUp(); }; @@ -145,15 +140,13 @@ export default class StrivenEditor { this.overflow(); setTimeout(() => { if ( - document.activeElement !== this.body && - document.activeElement !== this.linkMenu.querySelector('input') && - document.activeElement !== this.imageMenu.querySelectorAll('input')[0] && - document.activeElement !== this.imageMenu.querySelectorAll('input')[1] && - document.activeElement !== this.imageMenu.querySelectorAll('input')[2] + this.linkMenu.dataset.active !== "true" + && this.imageMenu.dataset.active !== "true" + && !this.isEditorInFocus() ) { this.toolbarSlideDown(); } - }, 2000); + }, 500); }; } @@ -170,14 +163,13 @@ export default class StrivenEditor { const indents = () => { const indents = this.body.querySelectorAll('blockquote'); - [...indents].forEach(indent => indent.style.margin = "0 0 0 40px"); + [...indents].forEach(indent => indent.style.margin = "0 0 0 40px"); // make the margin an option } this.body.focus(); - - // Safari Fix - // window.getSelection().removeAllRanges(); - // window.getSelection().addRange(this.range); + + window.getSelection().removeAllRanges(); + window.getSelection().addRange(this.range); const command = optionEl.id.split("-")[1]; @@ -222,15 +214,11 @@ export default class StrivenEditor { attachmentInput.click(); break; case "link": - // const currentRange = this.getRange(); - // currentRange.setStart(this.body, currentRange.endOffset - currentRange.commonAncestorContainer.textContent.length) - if (this.linkMenu.dataset.active === "true") { this.closeLinkMenu(); } else { this.linkMenuSlideIn(); - this.range = this.getRange(); this.linkMenu.querySelector('input').focus(); } break; @@ -259,6 +247,7 @@ export default class StrivenEditor { optionElClick && optionElClick(); }; + }); this.editor.appendChild(this.toolbar); @@ -365,17 +354,13 @@ export default class StrivenEditor { const groups = Object.keys(this.optionGroups); toolbar.classList.add("toolbar"); - toolbar.style.display = "flex"; - toolbar.style.justifyContent = "space-between"; - toolbar.style.alignItems = "center"; - toolbar.style.flexWrap = "wrap"; toolbar.style.minHeight = this.options.toolbarHide ? "0" : "40px"; - toolbar.style.position = "relative"; this.toolbarOptionsGroup.classList.add("toolbar-options"); - this.toolbarOptionsGroup.style.margin = "0 10px"; this.toolbarOptionsGroup.style.display = this.options.toolbarHide ? "none" : "flex"; + toolbar.onclick = () => this.body.focus(); + //iterate groups groups.forEach((group) => { // add menu to toolbarOptions @@ -403,8 +388,8 @@ export default class StrivenEditor { const svgData = toolbarOption[option]; const optionSpan = this.constructSVG(svgData); + optionSpan.classList.add('toolbar-option'); optionSpan.id = `toolbar-${option}`; - optionSpan.style.margin = "0 10px"; toolbarGroup.appendChild(optionSpan); } @@ -412,6 +397,7 @@ export default class StrivenEditor { this.toolbarOptionsGroup.appendChild(toolbarGroup); + // FONT AWESOME IMPORTED ICONS // this.optionGroups[group].group.forEach((option) => { // const toolbarCommand = Object.keys(option)[0]; // if(this.options.toolbarOptions.includes(toolbarCommand)){ @@ -470,21 +456,10 @@ export default class StrivenEditor { if (this.options.customToolbarButton) { const customToolbarButton = document.createElement("div"); customToolbarButton.id = "custom-toolbar-button"; - - customToolbarButton.style.display = "none"; - customToolbarButton.style.color = "#fff"; - customToolbarButton.style.backgroundColor = "#5cb85c"; + customToolbarButton.classList.add('custom-toolbar-button') customToolbarButton.style.minHeight = this.options.toolbarHide ? "40px" - : this.toolbar.style.minHeight; - customToolbarButton.style.width = "50px"; - customToolbarButton.style.textAlign = "center"; - customToolbarButton.style.justifyContent = "center"; - customToolbarButton.style.alignContent = "center"; - customToolbarButton.style.alignItems = "center"; - customToolbarButton.style.cursor = "pointer"; - customToolbarButton.style.border = "1px solid #4cae4c"; - customToolbarButton.style.alignSelf = "flex-end"; + : toolbar.style.minHeight; customToolbarButton.onclick = () => this.options.customToolbarButton.handler(); !this.options.toolbarHide && (customToolbarButton.style.display = "flex"); @@ -528,19 +503,16 @@ export default class StrivenEditor { initBody() { const body = document.createElement("div"); - body.classList.add("body"); + body.classList.add("body"); body.contentEditable = "true"; - body.style.outline = "none"; - body.style.padding = "10px 20px"; - body.style.height = this.editor.style.height; body.style.minHeight = this.editor.style.minHeight; body.style.maxHeight = this.editor.style.maxHeight; - this.editor.style.height = "auto"; - this.editor.style.minHeight = "auto"; - this.editor.style.maxHeight = "auto"; + this.editor.style.height = 'auto'; + this.editor.style.minHeight = 'auto'; + this.editor.style.maxHeight = 'auto'; // Placeholder logic if (this.options.placeholder) { @@ -683,58 +655,47 @@ export default class StrivenEditor { this.toolbarState(); } + const bodyMouseUp = body.onmouseup; + body.onmouseup = e => { + bodyMouseUp && bodyMouseUp(); + this.range = this.getRange(); + } + return body; } initLinkMenu() { const linkMenu = document.createElement("div"); const linkMenuForm = document.createElement("div"); + const linkMenuButtons = document.createElement("div"); const linkMenuButton = document.createElement("button"); + const linkMenuCloseButton = document.createElement("button"); const linkMenuFormLabel = document.createElement("p"); const linkMenuFormInput = document.createElement("input"); linkMenu.id = "link-menu"; - linkMenuButton.textContent = "Insert Link"; + linkMenu.classList.add('popup') + linkMenu.dataset.active = "false"; + + linkMenuForm.classList.add('popup-form') + + linkMenuFormLabel.classList.add('form-label') linkMenuFormLabel.textContent = "Web Address"; - linkMenuFormInput.type = "text"; - linkMenuFormLabel.style.margin = "8px 10px 8px 0"; - linkMenuFormLabel.style.fontSize = "14px"; - linkMenuButton.style.cursor = "pointer"; - linkMenu.dataset.active = "false"; - linkMenu.style.display = "none"; - linkMenu.style.position = "absolute"; - linkMenu.style.right = "10px"; - linkMenu.style.bottom = "10px"; - linkMenu.style.backgroundColor = "#fff"; - linkMenu.style.border = "2px solid #ddd"; - linkMenu.style.padding = "10px 20px"; - linkMenu.style.zIndex = "1000"; - - linkMenuFormLabel.style.width = "100%"; - linkMenuFormLabel.style.textAlign = "right"; - linkMenuFormLabel.style.marginRight = "10px"; - - linkMenuFormInput.style.outline = "none"; - linkMenuFormInput.style.padding = "0 5px"; + linkMenuFormInput.classList.add('form-input') + linkMenuFormInput.type = "text"; linkMenuFormInput.placeholder = "Insert a Link"; - linkMenuForm.style.display = "flex"; - linkMenuForm.style.justifyContent = "space-between"; - linkMenuForm.style.margin = "5px 0"; - linkMenuButton.style.float = "right"; - linkMenuButton.style.padding = "6px 12px"; - linkMenuButton.style.border = "1px solid #4cae4c"; - linkMenuButton.style.backgroundColor = "#5cb85c"; - linkMenuButton.style.fontSize = "14px"; - linkMenuButton.style.color = "#fff"; - linkMenuButton.style.outline = "none"; + linkMenuButtons.classList.add('popup-button-container'); + + linkMenuButton.classList.add('popup-button') + linkMenuButton.classList.add('button-primary') + linkMenuButton.textContent = "Insert Link"; - linkMenuButton.onmouseenter = () => - (linkMenuButton.style.backgroundColor = "#4cae4c"); - linkMenuButton.onmouseleave = () => - (linkMenuButton.style.backgroundColor = "#5cb85c"); + linkMenuCloseButton.classList.add('popup-button') + linkMenuCloseButton.classList.add('button-secondary') + linkMenuCloseButton.textContent = "Close" linkMenuButton.onclick = e => { const linkValue = linkMenuFormInput.value; @@ -771,64 +732,54 @@ export default class StrivenEditor { } }; + linkMenuCloseButton.onclick = e => { + this.body.focus(); + this.closeLinkMenu(); + } + linkMenuForm.appendChild(linkMenuFormLabel); linkMenuForm.appendChild(linkMenuFormInput); linkMenu.appendChild(linkMenuForm); - linkMenu.appendChild(linkMenuButton); + linkMenuButtons.appendChild(linkMenuButton); + linkMenuButtons.appendChild(linkMenuCloseButton); + + linkMenu.appendChild(linkMenuButtons); return linkMenu; } initImageMenu() { const imageMenu = document.createElement("div"); const imageMenuForm = document.createElement("div"); + const imageMenuButtons = document.createElement("div"); const imageMenuButton = document.createElement("button"); + const imageMenuCloseButton = document.createElement("button"); const imageMenuFormLabel = document.createElement("p"); const imageMenuFormSourceInput = document.createElement("input"); imageMenu.id = "image-menu"; - imageMenuButton.textContent = "Insert Image"; + imageMenu.classList.add('popup'); + imageMenu.dataset.active = "false"; + + imageMenuForm.classList.add('popup-form'); + + imageMenuFormLabel.classList.add('form-label'); imageMenuFormLabel.textContent = "Image URL"; - imageMenuFormSourceInput.type = "text"; - imageMenuFormLabel.style.margin = "8px 10px 8px 0"; - imageMenuFormLabel.style.fontSize = "14px"; - imageMenuButton.style.cursor = "pointer"; - imageMenu.dataset.active = "false"; - imageMenu.style.display = "none"; - imageMenu.style.position = "absolute"; - imageMenu.style.right = "10px"; - imageMenu.style.bottom = "10px"; - imageMenu.style.backgroundColor = "#fff"; - imageMenu.style.border = "2px solid #ddd"; - imageMenu.style.padding = "10px 20px"; - imageMenu.style.zIndex = "1000"; - - imageMenuFormLabel.style.width = "100%"; - imageMenuFormLabel.style.textAlign = "right"; - imageMenuFormLabel.style.marginRight = "10px"; - - imageMenuFormSourceInput.style.outline = "none"; - imageMenuFormSourceInput.style.padding = "0 5px"; + imageMenuFormSourceInput.classList.add('form-input'); + imageMenuFormSourceInput.type = "text"; imageMenuFormSourceInput.placeholder = "Insert a Link"; - imageMenuForm.style.display = "flex"; - imageMenuForm.style.justifyContent = "space-between"; - imageMenuForm.style.margin = "5px 0"; + imageMenuButtons.classList.add('popup-button-container'); - imageMenuButton.style.float = "right"; - imageMenuButton.style.padding = "6px 12px"; - imageMenuButton.style.border = "1px solid #4cae4c"; - imageMenuButton.style.backgroundColor = "#5cb85c"; - imageMenuButton.style.fontSize = "14px"; - imageMenuButton.style.color = "#fff"; - imageMenuButton.style.outline = "none"; + imageMenuButton.classList.add('popup-button'); + imageMenuButton.classList.add('button-primary'); + imageMenuButton.textContent = "Insert Image"; - imageMenuButton.onmouseenter = () => - (imageMenuButton.style.backgroundColor = "#4cae4c"); - imageMenuButton.onmouseleave = () => - (imageMenuButton.style.backgroundColor = "#5cb85c"); + imageMenuCloseButton.classList.add('popup-button'); + imageMenuCloseButton.classList.add('button-secondary'); + imageMenuCloseButton.textContent = "Close"; imageMenuForm.appendChild(imageMenuFormLabel); imageMenuForm.appendChild(imageMenuFormSourceInput); @@ -875,11 +826,18 @@ export default class StrivenEditor { this.closeImageMenu(); } }; - + imageMenuCloseButton.onclick = e => { + this.body.focus(); + this.closeImageMenu(); + } imageMenu.appendChild(imageMenuHeightForm); imageMenu.appendChild(imageMenuWidthForm); imageMenu.appendChild(imageMenuForm); - imageMenu.appendChild(imageMenuButton); + + imageMenuButtons.appendChild(imageMenuButton); + imageMenuButtons.appendChild(imageMenuCloseButton); + + imageMenu.appendChild(imageMenuButtons); return imageMenu; } @@ -888,10 +846,6 @@ export default class StrivenEditor { const metaDataSection = document.createElement("div"); metaDataSection.classList.add("metadata-section"); - metaDataSection.style.display = "flex"; - metaDataSection.style.flexWrap = "wrap"; - metaDataSection.style.zIndex = "500"; - return metaDataSection; } @@ -899,10 +853,6 @@ export default class StrivenEditor { const filesSection = document.createElement("div"); filesSection.classList.add("files-section"); - filesSection.style.display = "flex"; - filesSection.style.flexWrap = "wrap"; - filesSection.style.zIndex = "500"; - this.body.ondragenter = e => { this.body.style.backgroundColor = "#ddd"; } @@ -919,6 +869,8 @@ export default class StrivenEditor { this.attachFile(file); } + this.isEdge && (this.body.ondragover = e => e.preventDefault()); + return filesSection; } @@ -932,26 +884,14 @@ export default class StrivenEditor { fileSizeEl.textContent = size; removeFileEl.textContent = "X"; + fileEl.classList.add('file-el') fileEl.dataset.fileindex = (this.files.length - 1); - fileEl.style.width = "100%"; - fileEl.style.display = "flex"; - fileEl.style.flexDirection = "column"; - fileEl.style.margin = "10px"; - fileEl.style.position = "relative"; - - fileNameEl.style.fontWeight = "bold"; - fileNameEl.style.margin = "0"; - fileSizeEl.style.fontSize = "12px"; - fileSizeEl.style.margin = "2px 0"; - - removeFileEl.style.margin = "0"; - removeFileEl.style.userSelect = "none"; - removeFileEl.style.color = "black"; - removeFileEl.style.position = "absolute"; - removeFileEl.style.right = "5px"; - removeFileEl.style.top = "-5px"; - removeFileEl.style.cursor = "pointer"; - removeFileEl.style.backgroundColor = "#fff"; + + fileNameEl.classList.add('file-name-el') + + fileSizeEl.classList.add('file-size-el') + + removeFileEl.classList.add('remove-file-el') removeFileEl.onmouseenter = () => removeFileEl.style.color = "#ddd"; removeFileEl.onmouseleave = () => removeFileEl.style.color = "black"; @@ -984,26 +924,15 @@ export default class StrivenEditor { metaLinkEl.target = "blank"; - metaItemEl.style.width = "100%"; - metaItemEl.style.display = "flex"; - metaItemEl.style.margin = "10px"; - metaItemEl.style.position = "relative"; + metaItemEl.classList.add("meta-item-el") - metaImageEl.style.marginRight = "10px"; - metaImageEl.style.height = "50px"; - metaImageEl.style.width = "75px"; + metaImageEl.classList.add("meta-image-el") + + metaDataTitleEl.classList.add("meta-data-title-el") - metaDataTitleEl.style.fontWeight = "bold"; - metaDataTitleEl.style.margin = "0"; metaDataDescriptionEl.style.margin = "0"; - removeMetaDataEl.style.userSelect = "none"; - removeMetaDataEl.style.color = "black"; - removeMetaDataEl.style.position = "absolute"; - removeMetaDataEl.style.right = "5px"; - removeMetaDataEl.style.top = "-5px"; - removeMetaDataEl.style.cursor = "pointer"; - removeMetaDataEl.style.backgroundColor = "#fff"; + removeMetaDataEl.classList.add("remove-meta-data-el") removeMetaDataEl.onmouseenter = () => removeMetaDataEl.style.color = "#ddd"; removeMetaDataEl.onmouseleave = () => removeMetaDataEl.style.color = "black"; @@ -1025,7 +954,7 @@ export default class StrivenEditor { const { viewBox, d } = svgData; const fillColor = (this.options.toolbarOptionFillColor ? this.options.toolbarOptionFillColor : "#333"); const xmlns = "http://www.w3.org/2000/svg"; - const height = "16"; + const height = "14"; const width = "16"; const icon = document.createElement('span'); @@ -1050,10 +979,14 @@ export default class StrivenEditor { group.dataset.open = "false"; group.style.display = isResponsive ? "none" : "block"; group.style.position = isResponsive ? "absolute" : "relative"; - group.style.bottom = isResponsive ? "5px" : "inherit"; - group.style.right = isResponsive ? `5px` : "inherit"; - group.style.backgroundColor = isResponsive ? "#fff" : "inherit"; - group.style.border = isResponsive ? "2px solid #ddd" : "none"; + // group.style.right = isResponsive ? "10px" : "inherit"; + + !that.options.toolbarBottom && (group.style.top = isResponsive ? "50px" : "inherit"); + that.options.toolbarBottom && (group.style.bottom = isResponsive ? "50px" : "inherit"); + + // group.style.margin = isResponsive ? "0 2px" : "inherit"; + // group.style.backgroundColor = isResponsive ? "#fff" : "inherit"; + // group.style.border = isResponsive ? "2px solid #ddd" : "none"; } }); @@ -1115,6 +1048,7 @@ export default class StrivenEditor { this.toolbar.querySelector("#toolbar-insertOrderedList").style.display = "none"; this.toolbar.querySelector("#group-textAlign").style.display = "none"; + this.toolbar.querySelector("#toolbar-removeFormat").style.display = "none"; } } @@ -1225,29 +1159,51 @@ export default class StrivenEditor { setTimeout(() => { this.body.style.backgroundColor = "inherit"; setTimeout(() => this.body.style.transition = "none", 500); - }, 500); + }, 2000); } openLinkMenu() { + //close other open popups this.closeImageMenu(); this.linkMenu.dataset.active = "true"; this.linkMenu.style.display = "block"; + this.addPopupEscapeHandler(); } openImageMenu() { + //close other open popups this.closeLinkMenu(); this.imageMenu.dataset.active = "true"; this.imageMenu.style.display = "block"; + this.addPopupEscapeHandler(); } - + closeLinkMenu() { this.linkMenu.dataset.active = "false"; this.linkMenu.style.display = "none"; + this.removePopupEscapeHandler(); } closeImageMenu() { this.imageMenu.dataset.active = "false"; this.imageMenu.style.display = "none"; + this.removePopupEscapeHandler(); + } + + popupEscapeHandler(evt){ + if(evt.which===27){ + //close all open popups + this.closeImageMenu(); + this.closeLinkMenu(); + } + } + + addPopupEscapeHandler(){ + this.removePopupEscapeHandler(); + this.editor.addEventListener('keyup', this.bound_popupEscapeHandler); + } + removePopupEscapeHandler(){ + this.editor.removeEventListener('keyup', this.bound_popupEscapeHandler); } setContent(html) { @@ -1319,4 +1275,18 @@ export default class StrivenEditor { // Blink engine detection this.isBlink = (this.isChrome || this.isOpera) && !!window.CSS; } -} -\ No newline at end of file + + isEditorInFocus() { + let activeEl = document.activeElement; + var isEditor = (el) => { + if (el === this.editor) { + return true; + } + else if (el === document.body) { + return false; + } + return el.parentNode && isEditor(el.parentNode); + }; + return isEditor(activeEl); + } +} diff --git a/src/vue-striveneditor.vue b/src/vue-striveneditor.vue @@ -0,0 +1,36 @@ +<template> + <div ref="editor"></div> +</template> + +<script> +import StrivenEditor from './striveneditor'; + +export default { + name: 'striven-editor', + props: { + toolbarHide: Boolean, + toolbarBotoom: Boolean, + minimal: Boolean, + metaUrl: String, + extensions: Array, + uploadOnPaste: Boolean, + toolbarOptionFillColor: String, + placeholder: String, + sanitizePaste: String, + imageUrl: String, + customToolbarOption: Object, + activeOptionColor: String, + submitOnEnter: Function + }, + mounted() { + this.editor = new StrivenEditor(this.$refs.editor, this.props) + }, + data () { + return { + editor: {} + } + } +} +</script> + +<style></style> +\ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js @@ -1,11 +1,14 @@ const path = require('path'); const TerserPlugin = require('terser-webpack-plugin'); +const VueLoaderPlugin = require('vue-loader/lib/plugin'); module.exports = { mode: 'development', entry: { index: './src/index.js', - striveneditor: './src/striveneditor.js' + striveneditor: './src/striveneditor.js', + 'ko-striveneditor': './src/ko-striveneditor.js', + 'vue-striveneditor': './src/vue-striveneditor.vue' }, output: { path: path.resolve(__dirname, "dist"), @@ -25,13 +28,30 @@ module.exports = { plugins: ['@babel/plugin-transform-modules-umd'] } } + }, + { + test: /\.css$/i, + use: ['style-loader', 'css-loader'], + }, + { + test: /\.vue$/, + loader: 'vue-loader' } ] }, + plugins: [ + new VueLoaderPlugin() + ], optimization: { minimize: true, minimizer: [new TerserPlugin({ - exclude: 'index' + exclude: 'index', + terserOptions: { + output: { + comments: /@license/i, + }, + }, + extractComments: true, })] } }; \ No newline at end of file