LaravelTest
10229 строк · 316.7 Кб
1/*!
2*
3* Super simple WYSIWYG editor v0.8.20
4* https://summernote.org
5*
6*
7* Copyright 2013- Alan Hong and contributors
8* Summernote may be freely distributed under the MIT license.
9*
10* Date: 2021-10-14T21:15Z
11*
12*/
13(function webpackUniversalModuleDefinition(root, factory) {14if(typeof exports === 'object' && typeof module === 'object')15module.exports = factory(require("jQuery"));16else if(typeof define === 'function' && define.amd)17define(["jQuery"], factory);18else {19var a = typeof exports === 'object' ? factory(require("jQuery")) : factory(root["jQuery"]);20for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];21}22})(self, function(__WEBPACK_EXTERNAL_MODULE__1145__) {23return /******/ (() => { // webpackBootstrap24/******/ "use strict";25/******/ var __webpack_modules__ = ({26
27/***/ 9770:28/***/ ((__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) => {29
30/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1145);31/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);32
33(jquery__WEBPACK_IMPORTED_MODULE_0___default().summernote) = (jquery__WEBPACK_IMPORTED_MODULE_0___default().summernote) || {34lang: {}35};36jquery__WEBPACK_IMPORTED_MODULE_0___default().extend((jquery__WEBPACK_IMPORTED_MODULE_0___default().summernote.lang), {37'en-US': {38font: {39bold: 'Bold',40italic: 'Italic',41underline: 'Underline',42clear: 'Remove Font Style',43height: 'Line Height',44name: 'Font Family',45strikethrough: 'Strikethrough',46subscript: 'Subscript',47superscript: 'Superscript',48size: 'Font Size',49sizeunit: 'Font Size Unit'50},51image: {52image: 'Picture',53insert: 'Insert Image',54resizeFull: 'Resize full',55resizeHalf: 'Resize half',56resizeQuarter: 'Resize quarter',57resizeNone: 'Original size',58floatLeft: 'Float Left',59floatRight: 'Float Right',60floatNone: 'Remove float',61shapeRounded: 'Shape: Rounded',62shapeCircle: 'Shape: Circle',63shapeThumbnail: 'Shape: Thumbnail',64shapeNone: 'Shape: None',65dragImageHere: 'Drag image or text here',66dropImage: 'Drop image or Text',67selectFromFiles: 'Select from files',68maximumFileSize: 'Maximum file size',69maximumFileSizeError: 'Maximum file size exceeded.',70url: 'Image URL',71remove: 'Remove Image',72original: 'Original'73},74video: {75video: 'Video',76videoLink: 'Video Link',77insert: 'Insert Video',78url: 'Video URL',79providers: '(YouTube, Google Drive, Vimeo, Vine, Instagram, DailyMotion, Youku, Peertube)'80},81link: {82link: 'Link',83insert: 'Insert Link',84unlink: 'Unlink',85edit: 'Edit',86textToDisplay: 'Text to display',87url: 'To what URL should this link go?',88openInNewWindow: 'Open in new window',89useProtocol: 'Use default protocol'90},91table: {92table: 'Table',93addRowAbove: 'Add row above',94addRowBelow: 'Add row below',95addColLeft: 'Add column left',96addColRight: 'Add column right',97delRow: 'Delete row',98delCol: 'Delete column',99delTable: 'Delete table'100},101hr: {102insert: 'Insert Horizontal Rule'103},104style: {105style: 'Style',106p: 'Normal',107blockquote: 'Quote',108pre: 'Code',109h1: 'Header 1',110h2: 'Header 2',111h3: 'Header 3',112h4: 'Header 4',113h5: 'Header 5',114h6: 'Header 6'115},116lists: {117unordered: 'Unordered list',118ordered: 'Ordered list'119},120options: {121help: 'Help',122fullscreen: 'Full Screen',123codeview: 'Code View'124},125paragraph: {126paragraph: 'Paragraph',127outdent: 'Outdent',128indent: 'Indent',129left: 'Align left',130center: 'Align center',131right: 'Align right',132justify: 'Justify full'133},134color: {135recent: 'Recent Color',136more: 'More Color',137background: 'Background Color',138foreground: 'Text Color',139transparent: 'Transparent',140setTransparent: 'Set transparent',141reset: 'Reset',142resetToDefault: 'Reset to default',143cpSelect: 'Select'144},145shortcut: {146shortcuts: 'Keyboard shortcuts',147close: 'Close',148textFormatting: 'Text formatting',149action: 'Action',150paragraphFormatting: 'Paragraph formatting',151documentStyle: 'Document Style',152extraKeys: 'Extra keys'153},154help: {155'escape': 'Escape',156'insertParagraph': 'Insert Paragraph',157'undo': 'Undo the last command',158'redo': 'Redo the last command',159'tab': 'Tab',160'untab': 'Untab',161'bold': 'Set a bold style',162'italic': 'Set a italic style',163'underline': 'Set a underline style',164'strikethrough': 'Set a strikethrough style',165'removeFormat': 'Clean a style',166'justifyLeft': 'Set left align',167'justifyCenter': 'Set center align',168'justifyRight': 'Set right align',169'justifyFull': 'Set full align',170'insertUnorderedList': 'Toggle unordered list',171'insertOrderedList': 'Toggle ordered list',172'outdent': 'Outdent on current paragraph',173'indent': 'Indent on current paragraph',174'formatPara': 'Change current block\'s format as a paragraph(P tag)',175'formatH1': 'Change current block\'s format as H1',176'formatH2': 'Change current block\'s format as H2',177'formatH3': 'Change current block\'s format as H3',178'formatH4': 'Change current block\'s format as H4',179'formatH5': 'Change current block\'s format as H5',180'formatH6': 'Change current block\'s format as H6',181'insertHorizontalRule': 'Insert horizontal rule',182'linkDialog.show': 'Show Link Dialog'183},184history: {185undo: 'Undo',186redo: 'Redo'187},188specialChar: {189specialChar: 'SPECIAL CHARACTERS',190select: 'Select Special characters'191},192output: {193noSelection: 'No Selection Made!'194}195}196});197
198/***/ }),199
200/***/ 1145:201/***/ ((module) => {202
203module.exports = __WEBPACK_EXTERNAL_MODULE__1145__;204
205/***/ })206
207/******/ });208/************************************************************************/
209/******/ // The module cache210/******/ var __webpack_module_cache__ = {};211/******/212/******/ // The require function213/******/ function __webpack_require__(moduleId) {214/******/ // Check if module is in cache215/******/ var cachedModule = __webpack_module_cache__[moduleId];216/******/ if (cachedModule !== undefined) {217/******/ return cachedModule.exports;218/******/ }219/******/ // Create a new module (and put it into the cache)220/******/ var module = __webpack_module_cache__[moduleId] = {221/******/ // no module.id needed222/******/ // no module.loaded needed223/******/ exports: {}224/******/ };225/******/226/******/ // Execute the module function227/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);228/******/229/******/ // Return the exports of the module230/******/ return module.exports;231/******/ }232/******/233/************************************************************************/
234/******/ /* webpack/runtime/compat get default export */235/******/ (() => {236/******/ // getDefaultExport function for compatibility with non-harmony modules237/******/ __webpack_require__.n = (module) => {238/******/ var getter = module && module.__esModule ?239/******/ () => (module['default']) :240/******/ () => (module);241/******/ __webpack_require__.d(getter, { a: getter });242/******/ return getter;243/******/ };244/******/ })();245/******/246/******/ /* webpack/runtime/define property getters */247/******/ (() => {248/******/ // define getter functions for harmony exports249/******/ __webpack_require__.d = (exports, definition) => {250/******/ for(var key in definition) {251/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {252/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });253/******/ }254/******/ }255/******/ };256/******/ })();257/******/258/******/ /* webpack/runtime/hasOwnProperty shorthand */259/******/ (() => {260/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))261/******/ })();262/******/263/******/ /* webpack/runtime/make namespace object */264/******/ (() => {265/******/ // define __esModule on exports266/******/ __webpack_require__.r = (exports) => {267/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {268/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });269/******/ }270/******/ Object.defineProperty(exports, '__esModule', { value: true });271/******/ };272/******/ })();273/******/274/************************************************************************/
275var __webpack_exports__ = {};276// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
277(() => {278// ESM COMPAT FLAG
279__webpack_require__.r(__webpack_exports__);280
281// EXTERNAL MODULE: external "jQuery"
282var external_jQuery_ = __webpack_require__(1145);283var external_jQuery_default = /*#__PURE__*/__webpack_require__.n(external_jQuery_);284// EXTERNAL MODULE: ./src/lang/summernote-en-US.js
285var summernote_en_US = __webpack_require__(9770);286;// CONCATENATED MODULE: ./src/js/core/env.js287
288/**
289* returns whether font is installed or not.
290*
291* @param {String} fontName
292* @return {Boolean}
293*/
294
295var genericFontFamilies = ['sans-serif', 'serif', 'monospace', 'cursive', 'fantasy'];296
297function validFontName(fontName) {298return external_jQuery_default().inArray(fontName.toLowerCase(), genericFontFamilies) === -1 ? "'".concat(fontName, "'") : fontName;299}
300
301function isFontInstalled(fontName) {302var testFontName = fontName === 'Comic Sans MS' ? 'Courier New' : 'Comic Sans MS';303var testText = 'mmmmmmmmmmwwwww';304var testSize = '200px';305var canvas = document.createElement('canvas');306var context = canvas.getContext('2d');307context.font = testSize + " '" + testFontName + "'";308var originalWidth = context.measureText(testText).width;309context.font = testSize + ' ' + validFontName(fontName) + ', "' + testFontName + '"';310var width = context.measureText(testText).width;311return originalWidth !== width;312}
313
314var userAgent = navigator.userAgent;315var isMSIE = /MSIE|Trident/i.test(userAgent);316var browserVersion;317
318if (isMSIE) {319var matches = /MSIE (\d+[.]\d+)/.exec(userAgent);320
321if (matches) {322browserVersion = parseFloat(matches[1]);323}324
325matches = /Trident\/.*rv:([0-9]{1,}[.0-9]{0,})/.exec(userAgent);326
327if (matches) {328browserVersion = parseFloat(matches[1]);329}330}
331
332var isEdge = /Edge\/\d+/.test(userAgent);333var isSupportTouch = 'ontouchstart' in window || navigator.MaxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; // [workaround] IE doesn't have input events for contentEditable334// - see: https://goo.gl/4bfIvA
335
336var inputEventName = isMSIE ? 'DOMCharacterDataModified DOMSubtreeModified DOMNodeInserted' : 'input';337/**
338* @class core.env
339*
340* Object which check platform and agent
341*
342* @singleton
343* @alternateClassName env
344*/
345
346/* harmony default export */ const env = ({347isMac: navigator.appVersion.indexOf('Mac') > -1,348isMSIE: isMSIE,349isEdge: isEdge,350isFF: !isEdge && /firefox/i.test(userAgent),351isPhantom: /PhantomJS/i.test(userAgent),352isWebkit: !isEdge && /webkit/i.test(userAgent),353isChrome: !isEdge && /chrome/i.test(userAgent),354isSafari: !isEdge && /safari/i.test(userAgent) && !/chrome/i.test(userAgent),355browserVersion: browserVersion,356isSupportTouch: isSupportTouch,357isFontInstalled: isFontInstalled,358isW3CRangeSupport: !!document.createRange,359inputEventName: inputEventName,360genericFontFamilies: genericFontFamilies,361validFontName: validFontName362});363;// CONCATENATED MODULE: ./src/js/core/func.js364
365/**
366* @class core.func
367*
368* func utils (for high-order func's arg)
369*
370* @singleton
371* @alternateClassName func
372*/
373
374function eq(itemA) {375return function (itemB) {376return itemA === itemB;377};378}
379
380function eq2(itemA, itemB) {381return itemA === itemB;382}
383
384function peq2(propName) {385return function (itemA, itemB) {386return itemA[propName] === itemB[propName];387};388}
389
390function ok() {391return true;392}
393
394function fail() {395return false;396}
397
398function not(f) {399return function () {400return !f.apply(f, arguments);401};402}
403
404function and(fA, fB) {405return function (item) {406return fA(item) && fB(item);407};408}
409
410function func_self(a) {411return a;412}
413
414function invoke(obj, method) {415return function () {416return obj[method].apply(obj, arguments);417};418}
419
420var idCounter = 0;421/**
422* reset globally-unique id
423*
424*/
425
426function resetUniqueId() {427idCounter = 0;428}
429/**
430* generate a globally-unique id
431*
432* @param {String} [prefix]
433*/
434
435
436function uniqueId(prefix) {437var id = ++idCounter + '';438return prefix ? prefix + id : id;439}
440/**
441* returns bnd (bounds) from rect
442*
443* - IE Compatibility Issue: http://goo.gl/sRLOAo
444* - Scroll Issue: http://goo.gl/sNjUc
445*
446* @param {Rect} rect
447* @return {Object} bounds
448* @return {Number} bounds.top
449* @return {Number} bounds.left
450* @return {Number} bounds.width
451* @return {Number} bounds.height
452*/
453
454
455function rect2bnd(rect) {456var $document = external_jQuery_default()(document);457return {458top: rect.top + $document.scrollTop(),459left: rect.left + $document.scrollLeft(),460width: rect.right - rect.left,461height: rect.bottom - rect.top462};463}
464/**
465* returns a copy of the object where the keys have become the values and the values the keys.
466* @param {Object} obj
467* @return {Object}
468*/
469
470
471function invertObject(obj) {472var inverted = {};473
474for (var key in obj) {475if (Object.prototype.hasOwnProperty.call(obj, key)) {476inverted[obj[key]] = key;477}478}479
480return inverted;481}
482/**
483* @param {String} namespace
484* @param {String} [prefix]
485* @return {String}
486*/
487
488
489function namespaceToCamel(namespace, prefix) {490prefix = prefix || '';491return prefix + namespace.split('.').map(function (name) {492return name.substring(0, 1).toUpperCase() + name.substring(1);493}).join('');494}
495/**
496* Returns a function, that, as long as it continues to be invoked, will not
497* be triggered. The function will be called after it stops being called for
498* N milliseconds. If `immediate` is passed, trigger the function on the
499* leading edge, instead of the trailing.
500* @param {Function} func
501* @param {Number} wait
502* @param {Boolean} immediate
503* @return {Function}
504*/
505
506
507function debounce(func, wait, immediate) {508var timeout;509return function () {510var context = this;511var args = arguments;512
513var later = function later() {514timeout = null;515
516if (!immediate) {517func.apply(context, args);518}519};520
521var callNow = immediate && !timeout;522clearTimeout(timeout);523timeout = setTimeout(later, wait);524
525if (callNow) {526func.apply(context, args);527}528};529}
530/**
531*
532* @param {String} url
533* @return {Boolean}
534*/
535
536
537function isValidUrl(url) {538var expression = /[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/gi;539return expression.test(url);540}
541
542/* harmony default export */ const func = ({543eq: eq,544eq2: eq2,545peq2: peq2,546ok: ok,547fail: fail,548self: func_self,549not: not,550and: and,551invoke: invoke,552resetUniqueId: resetUniqueId,553uniqueId: uniqueId,554rect2bnd: rect2bnd,555invertObject: invertObject,556namespaceToCamel: namespaceToCamel,557debounce: debounce,558isValidUrl: isValidUrl559});560;// CONCATENATED MODULE: ./src/js/core/lists.js561
562/**
563* returns the first item of an array.
564*
565* @param {Array} array
566*/
567
568function head(array) {569return array[0];570}
571/**
572* returns the last item of an array.
573*
574* @param {Array} array
575*/
576
577
578function last(array) {579return array[array.length - 1];580}
581/**
582* returns everything but the last entry of the array.
583*
584* @param {Array} array
585*/
586
587
588function initial(array) {589return array.slice(0, array.length - 1);590}
591/**
592* returns the rest of the items in an array.
593*
594* @param {Array} array
595*/
596
597
598function tail(array) {599return array.slice(1);600}
601/**
602* returns item of array
603*/
604
605
606function find(array, pred) {607for (var idx = 0, len = array.length; idx < len; idx++) {608var item = array[idx];609
610if (pred(item)) {611return item;612}613}614}
615/**
616* returns true if all of the values in the array pass the predicate truth test.
617*/
618
619
620function lists_all(array, pred) {621for (var idx = 0, len = array.length; idx < len; idx++) {622if (!pred(array[idx])) {623return false;624}625}626
627return true;628}
629/**
630* returns true if the value is present in the list.
631*/
632
633
634function contains(array, item) {635if (array && array.length && item) {636if (array.indexOf) {637return array.indexOf(item) !== -1;638} else if (array.contains) {639// `DOMTokenList` doesn't implement `.indexOf`, but it implements `.contains`640return array.contains(item);641}642}643
644return false;645}
646/**
647* get sum from a list
648*
649* @param {Array} array - array
650* @param {Function} fn - iterator
651*/
652
653
654function sum(array, fn) {655fn = fn || func.self;656return array.reduce(function (memo, v) {657return memo + fn(v);658}, 0);659}
660/**
661* returns a copy of the collection with array type.
662* @param {Collection} collection - collection eg) node.childNodes, ...
663*/
664
665
666function from(collection) {667var result = [];668var length = collection.length;669var idx = -1;670
671while (++idx < length) {672result[idx] = collection[idx];673}674
675return result;676}
677/**
678* returns whether list is empty or not
679*/
680
681
682function isEmpty(array) {683return !array || !array.length;684}
685/**
686* cluster elements by predicate function.
687*
688* @param {Array} array - array
689* @param {Function} fn - predicate function for cluster rule
690* @param {Array[]}
691*/
692
693
694function clusterBy(array, fn) {695if (!array.length) {696return [];697}698
699var aTail = tail(array);700return aTail.reduce(function (memo, v) {701var aLast = last(memo);702
703if (fn(last(aLast), v)) {704aLast[aLast.length] = v;705} else {706memo[memo.length] = [v];707}708
709return memo;710}, [[head(array)]]);711}
712/**
713* returns a copy of the array with all false values removed
714*
715* @param {Array} array - array
716* @param {Function} fn - predicate function for cluster rule
717*/
718
719
720function compact(array) {721var aResult = [];722
723for (var idx = 0, len = array.length; idx < len; idx++) {724if (array[idx]) {725aResult.push(array[idx]);726}727}728
729return aResult;730}
731/**
732* produces a duplicate-free version of the array
733*
734* @param {Array} array
735*/
736
737
738function unique(array) {739var results = [];740
741for (var idx = 0, len = array.length; idx < len; idx++) {742if (!contains(results, array[idx])) {743results.push(array[idx]);744}745}746
747return results;748}
749/**
750* returns next item.
751* @param {Array} array
752*/
753
754
755function next(array, item) {756if (array && array.length && item) {757var idx = array.indexOf(item);758return idx === -1 ? null : array[idx + 1];759}760
761return null;762}
763/**
764* returns prev item.
765* @param {Array} array
766*/
767
768
769function prev(array, item) {770if (array && array.length && item) {771var idx = array.indexOf(item);772return idx === -1 ? null : array[idx - 1];773}774
775return null;776}
777/**
778* @class core.list
779*
780* list utils
781*
782* @singleton
783* @alternateClassName list
784*/
785
786
787/* harmony default export */ const lists = ({788head: head,789last: last,790initial: initial,791tail: tail,792prev: prev,793next: next,794find: find,795contains: contains,796all: lists_all,797sum: sum,798from: from,799isEmpty: isEmpty,800clusterBy: clusterBy,801compact: compact,802unique: unique803});804;// CONCATENATED MODULE: ./src/js/core/dom.js805
806
807
808
809var NBSP_CHAR = String.fromCharCode(160);810var ZERO_WIDTH_NBSP_CHAR = "\uFEFF";811/**
812* @method isEditable
813*
814* returns whether node is `note-editable` or not.
815*
816* @param {Node} node
817* @return {Boolean}
818*/
819
820function isEditable(node) {821return node && external_jQuery_default()(node).hasClass('note-editable');822}
823/**
824* @method isControlSizing
825*
826* returns whether node is `note-control-sizing` or not.
827*
828* @param {Node} node
829* @return {Boolean}
830*/
831
832
833function isControlSizing(node) {834return node && external_jQuery_default()(node).hasClass('note-control-sizing');835}
836/**
837* @method makePredByNodeName
838*
839* returns predicate which judge whether nodeName is same
840*
841* @param {String} nodeName
842* @return {Function}
843*/
844
845
846function makePredByNodeName(nodeName) {847nodeName = nodeName.toUpperCase();848return function (node) {849return node && node.nodeName.toUpperCase() === nodeName;850};851}
852/**
853* @method isText
854*
855*
856*
857* @param {Node} node
858* @return {Boolean} true if node's type is text(3)
859*/
860
861
862function isText(node) {863return node && node.nodeType === 3;864}
865/**
866* @method isElement
867*
868*
869*
870* @param {Node} node
871* @return {Boolean} true if node's type is element(1)
872*/
873
874
875function isElement(node) {876return node && node.nodeType === 1;877}
878/**
879* ex) br, col, embed, hr, img, input, ...
880* @see http://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements
881*/
882
883
884function isVoid(node) {885return node && /^BR|^IMG|^HR|^IFRAME|^BUTTON|^INPUT|^AUDIO|^VIDEO|^EMBED/.test(node.nodeName.toUpperCase());886}
887
888function isPara(node) {889if (isEditable(node)) {890return false;891} // Chrome(v31.0), FF(v25.0.1) use DIV for paragraph892
893
894return node && /^DIV|^P|^LI|^H[1-7]/.test(node.nodeName.toUpperCase());895}
896
897function isHeading(node) {898return node && /^H[1-7]/.test(node.nodeName.toUpperCase());899}
900
901var isPre = makePredByNodeName('PRE');902var isLi = makePredByNodeName('LI');903
904function isPurePara(node) {905return isPara(node) && !isLi(node);906}
907
908var isTable = makePredByNodeName('TABLE');909var isData = makePredByNodeName('DATA');910
911function isInline(node) {912return !isBodyContainer(node) && !isList(node) && !isHr(node) && !isPara(node) && !isTable(node) && !isBlockquote(node) && !isData(node);913}
914
915function isList(node) {916return node && /^UL|^OL/.test(node.nodeName.toUpperCase());917}
918
919var isHr = makePredByNodeName('HR');920
921function isCell(node) {922return node && /^TD|^TH/.test(node.nodeName.toUpperCase());923}
924
925var isBlockquote = makePredByNodeName('BLOCKQUOTE');926
927function isBodyContainer(node) {928return isCell(node) || isBlockquote(node) || isEditable(node);929}
930
931var isAnchor = makePredByNodeName('A');932
933function isParaInline(node) {934return isInline(node) && !!ancestor(node, isPara);935}
936
937function isBodyInline(node) {938return isInline(node) && !ancestor(node, isPara);939}
940
941var isBody = makePredByNodeName('BODY');942/**
943* returns whether nodeB is closest sibling of nodeA
944*
945* @param {Node} nodeA
946* @param {Node} nodeB
947* @return {Boolean}
948*/
949
950function isClosestSibling(nodeA, nodeB) {951return nodeA.nextSibling === nodeB || nodeA.previousSibling === nodeB;952}
953/**
954* returns array of closest siblings with node
955*
956* @param {Node} node
957* @param {function} [pred] - predicate function
958* @return {Node[]}
959*/
960
961
962function withClosestSiblings(node, pred) {963pred = pred || func.ok;964var siblings = [];965
966if (node.previousSibling && pred(node.previousSibling)) {967siblings.push(node.previousSibling);968}969
970siblings.push(node);971
972if (node.nextSibling && pred(node.nextSibling)) {973siblings.push(node.nextSibling);974}975
976return siblings;977}
978/**
979* blank HTML for cursor position
980* - [workaround] old IE only works with
981* - [workaround] IE11 and other browser works with bogus br
982*/
983
984
985var blankHTML = env.isMSIE && env.browserVersion < 11 ? ' ' : '<br>';986/**
987* @method nodeLength
988*
989* returns #text's text size or element's childNodes size
990*
991* @param {Node} node
992*/
993
994function nodeLength(node) {995if (isText(node)) {996return node.nodeValue.length;997}998
999if (node) {1000return node.childNodes.length;1001}1002
1003return 0;1004}
1005/**
1006* returns whether deepest child node is empty or not.
1007*
1008* @param {Node} node
1009* @return {Boolean}
1010*/
1011
1012
1013function deepestChildIsEmpty(node) {1014do {1015if (node.firstElementChild === null || node.firstElementChild.innerHTML === '') break;1016} while (node = node.firstElementChild);1017
1018return dom_isEmpty(node);1019}
1020/**
1021* returns whether node is empty or not.
1022*
1023* @param {Node} node
1024* @return {Boolean}
1025*/
1026
1027
1028function dom_isEmpty(node) {1029var len = nodeLength(node);1030
1031if (len === 0) {1032return true;1033} else if (!isText(node) && len === 1 && node.innerHTML === blankHTML) {1034// ex) <p><br></p>, <span><br></span>1035return true;1036} else if (lists.all(node.childNodes, isText) && node.innerHTML === '') {1037// ex) <p></p>, <span></span>1038return true;1039}1040
1041return false;1042}
1043/**
1044* padding blankHTML if node is empty (for cursor position)
1045*/
1046
1047
1048function paddingBlankHTML(node) {1049if (!isVoid(node) && !nodeLength(node)) {1050node.innerHTML = blankHTML;1051}1052}
1053/**
1054* find nearest ancestor predicate hit
1055*
1056* @param {Node} node
1057* @param {Function} pred - predicate function
1058*/
1059
1060
1061function ancestor(node, pred) {1062while (node) {1063if (pred(node)) {1064return node;1065}1066
1067if (isEditable(node)) {1068break;1069}1070
1071node = node.parentNode;1072}1073
1074return null;1075}
1076/**
1077* find nearest ancestor only single child blood line and predicate hit
1078*
1079* @param {Node} node
1080* @param {Function} pred - predicate function
1081*/
1082
1083
1084function singleChildAncestor(node, pred) {1085node = node.parentNode;1086
1087while (node) {1088if (nodeLength(node) !== 1) {1089break;1090}1091
1092if (pred(node)) {1093return node;1094}1095
1096if (isEditable(node)) {1097break;1098}1099
1100node = node.parentNode;1101}1102
1103return null;1104}
1105/**
1106* returns new array of ancestor nodes (until predicate hit).
1107*
1108* @param {Node} node
1109* @param {Function} [optional] pred - predicate function
1110*/
1111
1112
1113function listAncestor(node, pred) {1114pred = pred || func.fail;1115var ancestors = [];1116ancestor(node, function (el) {1117if (!isEditable(el)) {1118ancestors.push(el);1119}1120
1121return pred(el);1122});1123return ancestors;1124}
1125/**
1126* find farthest ancestor predicate hit
1127*/
1128
1129
1130function lastAncestor(node, pred) {1131var ancestors = listAncestor(node);1132return lists.last(ancestors.filter(pred));1133}
1134/**
1135* returns common ancestor node between two nodes.
1136*
1137* @param {Node} nodeA
1138* @param {Node} nodeB
1139*/
1140
1141
1142function commonAncestor(nodeA, nodeB) {1143var ancestors = listAncestor(nodeA);1144
1145for (var n = nodeB; n; n = n.parentNode) {1146if (ancestors.indexOf(n) > -1) return n;1147}1148
1149return null; // difference document area1150}
1151/**
1152* listing all previous siblings (until predicate hit).
1153*
1154* @param {Node} node
1155* @param {Function} [optional] pred - predicate function
1156*/
1157
1158
1159function listPrev(node, pred) {1160pred = pred || func.fail;1161var nodes = [];1162
1163while (node) {1164if (pred(node)) {1165break;1166}1167
1168nodes.push(node);1169node = node.previousSibling;1170}1171
1172return nodes;1173}
1174/**
1175* listing next siblings (until predicate hit).
1176*
1177* @param {Node} node
1178* @param {Function} [pred] - predicate function
1179*/
1180
1181
1182function listNext(node, pred) {1183pred = pred || func.fail;1184var nodes = [];1185
1186while (node) {1187if (pred(node)) {1188break;1189}1190
1191nodes.push(node);1192node = node.nextSibling;1193}1194
1195return nodes;1196}
1197/**
1198* listing descendant nodes
1199*
1200* @param {Node} node
1201* @param {Function} [pred] - predicate function
1202*/
1203
1204
1205function listDescendant(node, pred) {1206var descendants = [];1207pred = pred || func.ok; // start DFS(depth first search) with node1208
1209(function fnWalk(current) {1210if (node !== current && pred(current)) {1211descendants.push(current);1212}1213
1214for (var idx = 0, len = current.childNodes.length; idx < len; idx++) {1215fnWalk(current.childNodes[idx]);1216}1217})(node);1218
1219return descendants;1220}
1221/**
1222* wrap node with new tag.
1223*
1224* @param {Node} node
1225* @param {Node} tagName of wrapper
1226* @return {Node} - wrapper
1227*/
1228
1229
1230function wrap(node, wrapperName) {1231var parent = node.parentNode;1232var wrapper = external_jQuery_default()('<' + wrapperName + '>')[0];1233parent.insertBefore(wrapper, node);1234wrapper.appendChild(node);1235return wrapper;1236}
1237/**
1238* insert node after preceding
1239*
1240* @param {Node} node
1241* @param {Node} preceding - predicate function
1242*/
1243
1244
1245function insertAfter(node, preceding) {1246var next = preceding.nextSibling;1247var parent = preceding.parentNode;1248
1249if (next) {1250parent.insertBefore(node, next);1251} else {1252parent.appendChild(node);1253}1254
1255return node;1256}
1257/**
1258* append elements.
1259*
1260* @param {Node} node
1261* @param {Collection} aChild
1262*/
1263
1264
1265function appendChildNodes(node, aChild) {1266external_jQuery_default().each(aChild, function (idx, child) {1267node.appendChild(child);1268});1269return node;1270}
1271/**
1272* returns whether boundaryPoint is left edge or not.
1273*
1274* @param {BoundaryPoint} point
1275* @return {Boolean}
1276*/
1277
1278
1279function isLeftEdgePoint(point) {1280return point.offset === 0;1281}
1282/**
1283* returns whether boundaryPoint is right edge or not.
1284*
1285* @param {BoundaryPoint} point
1286* @return {Boolean}
1287*/
1288
1289
1290function isRightEdgePoint(point) {1291return point.offset === nodeLength(point.node);1292}
1293/**
1294* returns whether boundaryPoint is edge or not.
1295*
1296* @param {BoundaryPoint} point
1297* @return {Boolean}
1298*/
1299
1300
1301function isEdgePoint(point) {1302return isLeftEdgePoint(point) || isRightEdgePoint(point);1303}
1304/**
1305* returns whether node is left edge of ancestor or not.
1306*
1307* @param {Node} node
1308* @param {Node} ancestor
1309* @return {Boolean}
1310*/
1311
1312
1313function isLeftEdgeOf(node, ancestor) {1314while (node && node !== ancestor) {1315if (position(node) !== 0) {1316return false;1317}1318
1319node = node.parentNode;1320}1321
1322return true;1323}
1324/**
1325* returns whether node is right edge of ancestor or not.
1326*
1327* @param {Node} node
1328* @param {Node} ancestor
1329* @return {Boolean}
1330*/
1331
1332
1333function isRightEdgeOf(node, ancestor) {1334if (!ancestor) {1335return false;1336}1337
1338while (node && node !== ancestor) {1339if (position(node) !== nodeLength(node.parentNode) - 1) {1340return false;1341}1342
1343node = node.parentNode;1344}1345
1346return true;1347}
1348/**
1349* returns whether point is left edge of ancestor or not.
1350* @param {BoundaryPoint} point
1351* @param {Node} ancestor
1352* @return {Boolean}
1353*/
1354
1355
1356function isLeftEdgePointOf(point, ancestor) {1357return isLeftEdgePoint(point) && isLeftEdgeOf(point.node, ancestor);1358}
1359/**
1360* returns whether point is right edge of ancestor or not.
1361* @param {BoundaryPoint} point
1362* @param {Node} ancestor
1363* @return {Boolean}
1364*/
1365
1366
1367function isRightEdgePointOf(point, ancestor) {1368return isRightEdgePoint(point) && isRightEdgeOf(point.node, ancestor);1369}
1370/**
1371* returns offset from parent.
1372*
1373* @param {Node} node
1374*/
1375
1376
1377function position(node) {1378var offset = 0;1379
1380while (node = node.previousSibling) {1381offset += 1;1382}1383
1384return offset;1385}
1386
1387function hasChildren(node) {1388return !!(node && node.childNodes && node.childNodes.length);1389}
1390/**
1391* returns previous boundaryPoint
1392*
1393* @param {BoundaryPoint} point
1394* @param {Boolean} isSkipInnerOffset
1395* @return {BoundaryPoint}
1396*/
1397
1398
1399function prevPoint(point, isSkipInnerOffset) {1400var node;1401var offset;1402
1403if (point.offset === 0) {1404if (isEditable(point.node)) {1405return null;1406}1407
1408node = point.node.parentNode;1409offset = position(point.node);1410} else if (hasChildren(point.node)) {1411node = point.node.childNodes[point.offset - 1];1412offset = nodeLength(node);1413} else {1414node = point.node;1415offset = isSkipInnerOffset ? 0 : point.offset - 1;1416}1417
1418return {1419node: node,1420offset: offset1421};1422}
1423/**
1424* returns next boundaryPoint
1425*
1426* @param {BoundaryPoint} point
1427* @param {Boolean} isSkipInnerOffset
1428* @return {BoundaryPoint}
1429*/
1430
1431
1432function nextPoint(point, isSkipInnerOffset) {1433var node, offset;1434
1435if (nodeLength(point.node) === point.offset) {1436if (isEditable(point.node)) {1437return null;1438}1439
1440var nextTextNode = getNextTextNode(point.node);1441
1442if (nextTextNode) {1443node = nextTextNode;1444offset = 0;1445} else {1446node = point.node.parentNode;1447offset = position(point.node) + 1;1448}1449} else if (hasChildren(point.node)) {1450node = point.node.childNodes[point.offset];1451offset = 0;1452} else {1453node = point.node;1454offset = isSkipInnerOffset ? nodeLength(point.node) : point.offset + 1;1455}1456
1457return {1458node: node,1459offset: offset1460};1461}
1462/**
1463* returns next boundaryPoint with empty node
1464*
1465* @param {BoundaryPoint} point
1466* @param {Boolean} isSkipInnerOffset
1467* @return {BoundaryPoint}
1468*/
1469
1470
1471function nextPointWithEmptyNode(point, isSkipInnerOffset) {1472var node,1473offset = 0; // if node is empty string node, return current node's sibling.1474
1475if (dom_isEmpty(point.node)) {1476if (point.node === null) {1477return null;1478}1479
1480node = point.node.nextSibling;1481offset = 0;1482return {1483node: node,1484offset: offset1485};1486}1487
1488if (nodeLength(point.node) === point.offset) {1489if (isEditable(point.node)) {1490return null;1491}1492
1493node = point.node.parentNode;1494offset = position(point.node) + 1; // if next node is editable , return current node's sibling node.1495
1496if (isEditable(node)) {1497node = point.node.nextSibling;1498offset = 0;1499}1500} else if (hasChildren(point.node)) {1501node = point.node.childNodes[point.offset];1502offset = 0;1503
1504if (dom_isEmpty(node)) {1505if (!dom_isEmpty(point.node.nextSibling)) {1506return {1507node: point.node.nextSibling,1508offset: offset1509};1510}1511
1512return null;1513}1514} else {1515node = point.node;1516offset = isSkipInnerOffset ? nodeLength(point.node) : point.offset + 1;1517
1518if (dom_isEmpty(node)) {1519return null;1520}1521}1522
1523return {1524node: node,1525offset: offset1526};1527}
1528/*
1529* returns the next Text node index or 0 if not found.
1530*/
1531
1532
1533function getNextTextNode(actual) {1534if (!actual.nextSibling) return undefined;1535if (actual.parent !== actual.nextSibling.parent) return undefined;1536if (isText(actual.nextSibling)) return actual.nextSibling;else return getNextTextNode(actual.nextSibling);1537}
1538/**
1539* returns whether pointA and pointB is same or not.
1540*
1541* @param {BoundaryPoint} pointA
1542* @param {BoundaryPoint} pointB
1543* @return {Boolean}
1544*/
1545
1546
1547function isSamePoint(pointA, pointB) {1548return pointA.node === pointB.node && pointA.offset === pointB.offset;1549}
1550/**
1551* returns whether point is visible (can set cursor) or not.
1552*
1553* @param {BoundaryPoint} point
1554* @return {Boolean}
1555*/
1556
1557
1558function isVisiblePoint(point) {1559if (isText(point.node) || !hasChildren(point.node) || dom_isEmpty(point.node)) {1560return true;1561}1562
1563var leftNode = point.node.childNodes[point.offset - 1];1564var rightNode = point.node.childNodes[point.offset];1565
1566if ((!leftNode || isVoid(leftNode)) && (!rightNode || isVoid(rightNode)) || isTable(rightNode)) {1567return true;1568}1569
1570return false;1571}
1572/**
1573* @method prevPointUtil
1574*
1575* @param {BoundaryPoint} point
1576* @param {Function} pred
1577* @return {BoundaryPoint}
1578*/
1579
1580
1581function prevPointUntil(point, pred) {1582while (point) {1583if (pred(point)) {1584return point;1585}1586
1587point = prevPoint(point);1588}1589
1590return null;1591}
1592/**
1593* @method nextPointUntil
1594*
1595* @param {BoundaryPoint} point
1596* @param {Function} pred
1597* @return {BoundaryPoint}
1598*/
1599
1600
1601function nextPointUntil(point, pred) {1602while (point) {1603if (pred(point)) {1604return point;1605}1606
1607point = nextPoint(point);1608}1609
1610return null;1611}
1612/**
1613* returns whether point has character or not.
1614*
1615* @param {Point} point
1616* @return {Boolean}
1617*/
1618
1619
1620function isCharPoint(point) {1621if (!isText(point.node)) {1622return false;1623}1624
1625var ch = point.node.nodeValue.charAt(point.offset - 1);1626return ch && ch !== ' ' && ch !== NBSP_CHAR;1627}
1628/**
1629* returns whether point has space or not.
1630*
1631* @param {Point} point
1632* @return {Boolean}
1633*/
1634
1635
1636function isSpacePoint(point) {1637if (!isText(point.node)) {1638return false;1639}1640
1641var ch = point.node.nodeValue.charAt(point.offset - 1);1642return ch === ' ' || ch === NBSP_CHAR;1643}
1644/**
1645* @method walkPoint
1646*
1647* @param {BoundaryPoint} startPoint
1648* @param {BoundaryPoint} endPoint
1649* @param {Function} handler
1650* @param {Boolean} isSkipInnerOffset
1651*/
1652
1653
1654function walkPoint(startPoint, endPoint, handler, isSkipInnerOffset) {1655var point = startPoint;1656
1657while (point) {1658handler(point);1659
1660if (isSamePoint(point, endPoint)) {1661break;1662}1663
1664var isSkipOffset = isSkipInnerOffset && startPoint.node !== point.node && endPoint.node !== point.node;1665point = nextPointWithEmptyNode(point, isSkipOffset);1666}1667}
1668/**
1669* @method makeOffsetPath
1670*
1671* return offsetPath(array of offset) from ancestor
1672*
1673* @param {Node} ancestor - ancestor node
1674* @param {Node} node
1675*/
1676
1677
1678function makeOffsetPath(ancestor, node) {1679var ancestors = listAncestor(node, func.eq(ancestor));1680return ancestors.map(position).reverse();1681}
1682/**
1683* @method fromOffsetPath
1684*
1685* return element from offsetPath(array of offset)
1686*
1687* @param {Node} ancestor - ancestor node
1688* @param {array} offsets - offsetPath
1689*/
1690
1691
1692function fromOffsetPath(ancestor, offsets) {1693var current = ancestor;1694
1695for (var i = 0, len = offsets.length; i < len; i++) {1696if (current.childNodes.length <= offsets[i]) {1697current = current.childNodes[current.childNodes.length - 1];1698} else {1699current = current.childNodes[offsets[i]];1700}1701}1702
1703return current;1704}
1705/**
1706* @method splitNode
1707*
1708* split element or #text
1709*
1710* @param {BoundaryPoint} point
1711* @param {Object} [options]
1712* @param {Boolean} [options.isSkipPaddingBlankHTML] - default: false
1713* @param {Boolean} [options.isNotSplitEdgePoint] - default: false
1714* @param {Boolean} [options.isDiscardEmptySplits] - default: false
1715* @return {Node} right node of boundaryPoint
1716*/
1717
1718
1719function splitNode(point, options) {1720var isSkipPaddingBlankHTML = options && options.isSkipPaddingBlankHTML;1721var isNotSplitEdgePoint = options && options.isNotSplitEdgePoint;1722var isDiscardEmptySplits = options && options.isDiscardEmptySplits;1723
1724if (isDiscardEmptySplits) {1725isSkipPaddingBlankHTML = true;1726} // edge case1727
1728
1729if (isEdgePoint(point) && (isText(point.node) || isNotSplitEdgePoint)) {1730if (isLeftEdgePoint(point)) {1731return point.node;1732} else if (isRightEdgePoint(point)) {1733return point.node.nextSibling;1734}1735} // split #text1736
1737
1738if (isText(point.node)) {1739return point.node.splitText(point.offset);1740} else {1741var childNode = point.node.childNodes[point.offset];1742var clone = insertAfter(point.node.cloneNode(false), point.node);1743appendChildNodes(clone, listNext(childNode));1744
1745if (!isSkipPaddingBlankHTML) {1746paddingBlankHTML(point.node);1747paddingBlankHTML(clone);1748}1749
1750if (isDiscardEmptySplits) {1751if (dom_isEmpty(point.node)) {1752remove(point.node);1753}1754
1755if (dom_isEmpty(clone)) {1756remove(clone);1757return point.node.nextSibling;1758}1759}1760
1761return clone;1762}1763}
1764/**
1765* @method splitTree
1766*
1767* split tree by point
1768*
1769* @param {Node} root - split root
1770* @param {BoundaryPoint} point
1771* @param {Object} [options]
1772* @param {Boolean} [options.isSkipPaddingBlankHTML] - default: false
1773* @param {Boolean} [options.isNotSplitEdgePoint] - default: false
1774* @return {Node} right node of boundaryPoint
1775*/
1776
1777
1778function splitTree(root, point, options) {1779// ex) [#text, <span>, <p>]1780var ancestors = listAncestor(point.node, func.eq(root));1781
1782if (!ancestors.length) {1783return null;1784} else if (ancestors.length === 1) {1785return splitNode(point, options);1786}1787
1788return ancestors.reduce(function (node, parent) {1789if (node === point.node) {1790node = splitNode(point, options);1791}1792
1793return splitNode({1794node: parent,1795offset: node ? position(node) : nodeLength(parent)1796}, options);1797});1798}
1799/**
1800* split point
1801*
1802* @param {Point} point
1803* @param {Boolean} isInline
1804* @return {Object}
1805*/
1806
1807
1808function splitPoint(point, isInline) {1809// find splitRoot, container1810// - inline: splitRoot is a child of paragraph1811// - block: splitRoot is a child of bodyContainer1812var pred = isInline ? isPara : isBodyContainer;1813var ancestors = listAncestor(point.node, pred);1814var topAncestor = lists.last(ancestors) || point.node;1815var splitRoot, container;1816
1817if (pred(topAncestor)) {1818splitRoot = ancestors[ancestors.length - 2];1819container = topAncestor;1820} else {1821splitRoot = topAncestor;1822container = splitRoot.parentNode;1823} // if splitRoot is exists, split with splitTree1824
1825
1826var pivot = splitRoot && splitTree(splitRoot, point, {1827isSkipPaddingBlankHTML: isInline,1828isNotSplitEdgePoint: isInline1829}); // if container is point.node, find pivot with point.offset1830
1831if (!pivot && container === point.node) {1832pivot = point.node.childNodes[point.offset];1833}1834
1835return {1836rightNode: pivot,1837container: container1838};1839}
1840
1841function create(nodeName) {1842return document.createElement(nodeName);1843}
1844
1845function createText(text) {1846return document.createTextNode(text);1847}
1848/**
1849* @method remove
1850*
1851* remove node, (isRemoveChild: remove child or not)
1852*
1853* @param {Node} node
1854* @param {Boolean} isRemoveChild
1855*/
1856
1857
1858function remove(node, isRemoveChild) {1859if (!node || !node.parentNode) {1860return;1861}1862
1863if (node.removeNode) {1864return node.removeNode(isRemoveChild);1865}1866
1867var parent = node.parentNode;1868
1869if (!isRemoveChild) {1870var nodes = [];1871
1872for (var i = 0, len = node.childNodes.length; i < len; i++) {1873nodes.push(node.childNodes[i]);1874}1875
1876for (var _i = 0, _len = nodes.length; _i < _len; _i++) {1877parent.insertBefore(nodes[_i], node);1878}1879}1880
1881parent.removeChild(node);1882}
1883/**
1884* @method removeWhile
1885*
1886* @param {Node} node
1887* @param {Function} pred
1888*/
1889
1890
1891function removeWhile(node, pred) {1892while (node) {1893if (isEditable(node) || !pred(node)) {1894break;1895}1896
1897var parent = node.parentNode;1898remove(node);1899node = parent;1900}1901}
1902/**
1903* @method replace
1904*
1905* replace node with provided nodeName
1906*
1907* @param {Node} node
1908* @param {String} nodeName
1909* @return {Node} - new node
1910*/
1911
1912
1913function replace(node, nodeName) {1914if (node.nodeName.toUpperCase() === nodeName.toUpperCase()) {1915return node;1916}1917
1918var newNode = create(nodeName);1919
1920if (node.style.cssText) {1921newNode.style.cssText = node.style.cssText;1922}1923
1924appendChildNodes(newNode, lists.from(node.childNodes));1925insertAfter(newNode, node);1926remove(node);1927return newNode;1928}
1929
1930var isTextarea = makePredByNodeName('TEXTAREA');1931/**
1932* @param {jQuery} $node
1933* @param {Boolean} [stripLinebreaks] - default: false
1934*/
1935
1936function value($node, stripLinebreaks) {1937var val = isTextarea($node[0]) ? $node.val() : $node.html();1938
1939if (stripLinebreaks) {1940return val.replace(/[\n\r]/g, '');1941}1942
1943return val;1944}
1945/**
1946* @method html
1947*
1948* get the HTML contents of node
1949*
1950* @param {jQuery} $node
1951* @param {Boolean} [isNewlineOnBlock]
1952*/
1953
1954
1955function html($node, isNewlineOnBlock) {1956var markup = value($node);1957
1958if (isNewlineOnBlock) {1959var regexTag = /<(\/?)(\b(?!!)[^>\s]*)(.*?)(\s*\/?>)/g;1960markup = markup.replace(regexTag, function (match, endSlash, name) {1961name = name.toUpperCase();1962var isEndOfInlineContainer = /^DIV|^TD|^TH|^P|^LI|^H[1-7]/.test(name) && !!endSlash;1963var isBlockNode = /^BLOCKQUOTE|^TABLE|^TBODY|^TR|^HR|^UL|^OL/.test(name);1964return match + (isEndOfInlineContainer || isBlockNode ? '\n' : '');1965});1966markup = markup.trim();1967}1968
1969return markup;1970}
1971
1972function posFromPlaceholder(placeholder) {1973var $placeholder = external_jQuery_default()(placeholder);1974var pos = $placeholder.offset();1975var height = $placeholder.outerHeight(true); // include margin1976
1977return {1978left: pos.left,1979top: pos.top + height1980};1981}
1982
1983function attachEvents($node, events) {1984Object.keys(events).forEach(function (key) {1985$node.on(key, events[key]);1986});1987}
1988
1989function detachEvents($node, events) {1990Object.keys(events).forEach(function (key) {1991$node.off(key, events[key]);1992});1993}
1994/**
1995* @method isCustomStyleTag
1996*
1997* assert if a node contains a "note-styletag" class,
1998* which implies that's a custom-made style tag node
1999*
2000* @param {Node} an HTML DOM node
2001*/
2002
2003
2004function isCustomStyleTag(node) {2005return node && !isText(node) && lists.contains(node.classList, 'note-styletag');2006}
2007
2008/* harmony default export */ const dom = ({2009/** @property {String} NBSP_CHAR */2010NBSP_CHAR: NBSP_CHAR,2011
2012/** @property {String} ZERO_WIDTH_NBSP_CHAR */2013ZERO_WIDTH_NBSP_CHAR: ZERO_WIDTH_NBSP_CHAR,2014
2015/** @property {String} blank */2016blank: blankHTML,2017
2018/** @property {String} emptyPara */2019emptyPara: "<p>".concat(blankHTML, "</p>"),2020makePredByNodeName: makePredByNodeName,2021isEditable: isEditable,2022isControlSizing: isControlSizing,2023isText: isText,2024isElement: isElement,2025isVoid: isVoid,2026isPara: isPara,2027isPurePara: isPurePara,2028isHeading: isHeading,2029isInline: isInline,2030isBlock: func.not(isInline),2031isBodyInline: isBodyInline,2032isBody: isBody,2033isParaInline: isParaInline,2034isPre: isPre,2035isList: isList,2036isTable: isTable,2037isData: isData,2038isCell: isCell,2039isBlockquote: isBlockquote,2040isBodyContainer: isBodyContainer,2041isAnchor: isAnchor,2042isDiv: makePredByNodeName('DIV'),2043isLi: isLi,2044isBR: makePredByNodeName('BR'),2045isSpan: makePredByNodeName('SPAN'),2046isB: makePredByNodeName('B'),2047isU: makePredByNodeName('U'),2048isS: makePredByNodeName('S'),2049isI: makePredByNodeName('I'),2050isImg: makePredByNodeName('IMG'),2051isTextarea: isTextarea,2052deepestChildIsEmpty: deepestChildIsEmpty,2053isEmpty: dom_isEmpty,2054isEmptyAnchor: func.and(isAnchor, dom_isEmpty),2055isClosestSibling: isClosestSibling,2056withClosestSiblings: withClosestSiblings,2057nodeLength: nodeLength,2058isLeftEdgePoint: isLeftEdgePoint,2059isRightEdgePoint: isRightEdgePoint,2060isEdgePoint: isEdgePoint,2061isLeftEdgeOf: isLeftEdgeOf,2062isRightEdgeOf: isRightEdgeOf,2063isLeftEdgePointOf: isLeftEdgePointOf,2064isRightEdgePointOf: isRightEdgePointOf,2065prevPoint: prevPoint,2066nextPoint: nextPoint,2067nextPointWithEmptyNode: nextPointWithEmptyNode,2068isSamePoint: isSamePoint,2069isVisiblePoint: isVisiblePoint,2070prevPointUntil: prevPointUntil,2071nextPointUntil: nextPointUntil,2072isCharPoint: isCharPoint,2073isSpacePoint: isSpacePoint,2074walkPoint: walkPoint,2075ancestor: ancestor,2076singleChildAncestor: singleChildAncestor,2077listAncestor: listAncestor,2078lastAncestor: lastAncestor,2079listNext: listNext,2080listPrev: listPrev,2081listDescendant: listDescendant,2082commonAncestor: commonAncestor,2083wrap: wrap,2084insertAfter: insertAfter,2085appendChildNodes: appendChildNodes,2086position: position,2087hasChildren: hasChildren,2088makeOffsetPath: makeOffsetPath,2089fromOffsetPath: fromOffsetPath,2090splitTree: splitTree,2091splitPoint: splitPoint,2092create: create,2093createText: createText,2094remove: remove,2095removeWhile: removeWhile,2096replace: replace,2097html: html,2098value: value,2099posFromPlaceholder: posFromPlaceholder,2100attachEvents: attachEvents,2101detachEvents: detachEvents,2102isCustomStyleTag: isCustomStyleTag2103});2104;// CONCATENATED MODULE: ./src/js/Context.js2105function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }2106
2107function _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); } }2108
2109function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }2110
2111
2112
2113
2114
2115
2116var Context = /*#__PURE__*/function () {2117/**2118* @param {jQuery} $note
2119* @param {Object} options
2120*/
2121function Context($note, options) {2122_classCallCheck(this, Context);2123
2124this.$note = $note;2125this.memos = {};2126this.modules = {};2127this.layoutInfo = {};2128this.options = external_jQuery_default().extend(true, {}, options); // init ui with options2129
2130(external_jQuery_default()).summernote.ui = external_jQuery_default().summernote.ui_template(this.options);2131this.ui = (external_jQuery_default()).summernote.ui;2132this.initialize();2133}2134/**2135* create layout and initialize modules and other resources
2136*/
2137
2138
2139_createClass(Context, [{2140key: "initialize",2141value: function initialize() {2142this.layoutInfo = this.ui.createLayout(this.$note);2143
2144this._initialize();2145
2146this.$note.hide();2147return this;2148}2149/**2150* destroy modules and other resources and remove layout
2151*/
2152
2153}, {2154key: "destroy",2155value: function destroy() {2156this._destroy();2157
2158this.$note.removeData('summernote');2159this.ui.removeLayout(this.$note, this.layoutInfo);2160}2161/**2162* destory modules and other resources and initialize it again
2163*/
2164
2165}, {2166key: "reset",2167value: function reset() {2168var disabled = this.isDisabled();2169this.code(dom.emptyPara);2170
2171this._destroy();2172
2173this._initialize();2174
2175if (disabled) {2176this.disable();2177}2178}2179}, {2180key: "_initialize",2181value: function _initialize() {2182var _this = this;2183
2184// set own id2185this.options.id = func.uniqueId(external_jQuery_default().now()); // set default container for tooltips, popovers, and dialogs2186
2187this.options.container = this.options.container || this.layoutInfo.editor; // add optional buttons2188
2189var buttons = external_jQuery_default().extend({}, this.options.buttons);2190Object.keys(buttons).forEach(function (key) {2191_this.memo('button.' + key, buttons[key]);2192});2193var modules = external_jQuery_default().extend({}, this.options.modules, (external_jQuery_default()).summernote.plugins || {}); // add and initialize modules2194
2195Object.keys(modules).forEach(function (key) {2196_this.module(key, modules[key], true);2197});2198Object.keys(this.modules).forEach(function (key) {2199_this.initializeModule(key);2200});2201}2202}, {2203key: "_destroy",2204value: function _destroy() {2205var _this2 = this;2206
2207// destroy modules with reversed order2208Object.keys(this.modules).reverse().forEach(function (key) {2209_this2.removeModule(key);2210});2211Object.keys(this.memos).forEach(function (key) {2212_this2.removeMemo(key);2213}); // trigger custom onDestroy callback2214
2215this.triggerEvent('destroy', this);2216}2217}, {2218key: "code",2219value: function code(html) {2220var isActivated = this.invoke('codeview.isActivated');2221
2222if (html === undefined) {2223this.invoke('codeview.sync');2224return isActivated ? this.layoutInfo.codable.val() : this.layoutInfo.editable.html();2225} else {2226if (isActivated) {2227this.invoke('codeview.sync', html);2228} else {2229this.layoutInfo.editable.html(html);2230}2231
2232this.$note.val(html);2233this.triggerEvent('change', html, this.layoutInfo.editable);2234}2235}2236}, {2237key: "isDisabled",2238value: function isDisabled() {2239return this.layoutInfo.editable.attr('contenteditable') === 'false';2240}2241}, {2242key: "enable",2243value: function enable() {2244this.layoutInfo.editable.attr('contenteditable', true);2245this.invoke('toolbar.activate', true);2246this.triggerEvent('disable', false);2247this.options.editing = true;2248}2249}, {2250key: "disable",2251value: function disable() {2252// close codeview if codeview is opend2253if (this.invoke('codeview.isActivated')) {2254this.invoke('codeview.deactivate');2255}2256
2257this.layoutInfo.editable.attr('contenteditable', false);2258this.options.editing = false;2259this.invoke('toolbar.deactivate', true);2260this.triggerEvent('disable', true);2261}2262}, {2263key: "triggerEvent",2264value: function triggerEvent() {2265var namespace = lists.head(arguments);2266var args = lists.tail(lists.from(arguments));2267var callback = this.options.callbacks[func.namespaceToCamel(namespace, 'on')];2268
2269if (callback) {2270callback.apply(this.$note[0], args);2271}2272
2273this.$note.trigger('summernote.' + namespace, args);2274}2275}, {2276key: "initializeModule",2277value: function initializeModule(key) {2278var module = this.modules[key];2279module.shouldInitialize = module.shouldInitialize || func.ok;2280
2281if (!module.shouldInitialize()) {2282return;2283} // initialize module2284
2285
2286if (module.initialize) {2287module.initialize();2288} // attach events2289
2290
2291if (module.events) {2292dom.attachEvents(this.$note, module.events);2293}2294}2295}, {2296key: "module",2297value: function module(key, ModuleClass, withoutIntialize) {2298if (arguments.length === 1) {2299return this.modules[key];2300}2301
2302this.modules[key] = new ModuleClass(this);2303
2304if (!withoutIntialize) {2305this.initializeModule(key);2306}2307}2308}, {2309key: "removeModule",2310value: function removeModule(key) {2311var module = this.modules[key];2312
2313if (module.shouldInitialize()) {2314if (module.events) {2315dom.detachEvents(this.$note, module.events);2316}2317
2318if (module.destroy) {2319module.destroy();2320}2321}2322
2323delete this.modules[key];2324}2325}, {2326key: "memo",2327value: function memo(key, obj) {2328if (arguments.length === 1) {2329return this.memos[key];2330}2331
2332this.memos[key] = obj;2333}2334}, {2335key: "removeMemo",2336value: function removeMemo(key) {2337if (this.memos[key] && this.memos[key].destroy) {2338this.memos[key].destroy();2339}2340
2341delete this.memos[key];2342}2343/**2344* Some buttons need to change their visual style immediately once they get pressed
2345*/
2346
2347}, {2348key: "createInvokeHandlerAndUpdateState",2349value: function createInvokeHandlerAndUpdateState(namespace, value) {2350var _this3 = this;2351
2352return function (event) {2353_this3.createInvokeHandler(namespace, value)(event);2354
2355_this3.invoke('buttons.updateCurrentStyle');2356};2357}2358}, {2359key: "createInvokeHandler",2360value: function createInvokeHandler(namespace, value) {2361var _this4 = this;2362
2363return function (event) {2364event.preventDefault();2365var $target = external_jQuery_default()(event.target);2366
2367_this4.invoke(namespace, value || $target.closest('[data-value]').data('value'), $target);2368};2369}2370}, {2371key: "invoke",2372value: function invoke() {2373var namespace = lists.head(arguments);2374var args = lists.tail(lists.from(arguments));2375var splits = namespace.split('.');2376var hasSeparator = splits.length > 1;2377var moduleName = hasSeparator && lists.head(splits);2378var methodName = hasSeparator ? lists.last(splits) : lists.head(splits);2379var module = this.modules[moduleName || 'editor'];2380
2381if (!moduleName && this[methodName]) {2382return this[methodName].apply(this, args);2383} else if (module && module[methodName] && module.shouldInitialize()) {2384return module[methodName].apply(module, args);2385}2386}2387}]);2388
2389return Context;2390}();2391
2392
2393;// CONCATENATED MODULE: ./src/js/summernote.js2394
2395
2396
2397
2398external_jQuery_default().fn.extend({2399/**2400* Summernote API
2401*
2402* @param {Object|String}
2403* @return {this}
2404*/
2405summernote: function summernote() {2406var type = external_jQuery_default().type(lists.head(arguments));2407var isExternalAPICalled = type === 'string';2408var hasInitOptions = type === 'object';2409var options = external_jQuery_default().extend({}, (external_jQuery_default()).summernote.options, hasInitOptions ? lists.head(arguments) : {}); // Update options2410
2411options.langInfo = external_jQuery_default().extend(true, {}, (external_jQuery_default()).summernote.lang["en-US"], (external_jQuery_default()).summernote.lang[options.lang]);2412options.icons = external_jQuery_default().extend(true, {}, (external_jQuery_default()).summernote.options.icons, options.icons);2413options.tooltip = options.tooltip === 'auto' ? !env.isSupportTouch : options.tooltip;2414this.each(function (idx, note) {2415var $note = external_jQuery_default()(note);2416
2417if (!$note.data('summernote')) {2418var context = new Context($note, options);2419$note.data('summernote', context);2420$note.data('summernote').triggerEvent('init', context.layoutInfo);2421}2422});2423var $note = this.first();2424
2425if ($note.length) {2426var context = $note.data('summernote');2427
2428if (isExternalAPICalled) {2429return context.invoke.apply(context, lists.from(arguments));2430} else if (options.focus) {2431context.invoke('editor.focus');2432}2433}2434
2435return this;2436}2437});2438;// CONCATENATED MODULE: ./src/js/core/range.js2439function range_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }2440
2441function range_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); } }2442
2443function range_createClass(Constructor, protoProps, staticProps) { if (protoProps) range_defineProperties(Constructor.prototype, protoProps); if (staticProps) range_defineProperties(Constructor, staticProps); return Constructor; }2444
2445
2446
2447
2448
2449
2450/**
2451* return boundaryPoint from TextRange, inspired by Andy Na's HuskyRange.js
2452*
2453* @param {TextRange} textRange
2454* @param {Boolean} isStart
2455* @return {BoundaryPoint}
2456*
2457* @see http://msdn.microsoft.com/en-us/library/ie/ms535872(v=vs.85).aspx
2458*/
2459
2460function textRangeToPoint(textRange, isStart) {2461var container = textRange.parentElement();2462var offset;2463var tester = document.body.createTextRange();2464var prevContainer;2465var childNodes = lists.from(container.childNodes);2466
2467for (offset = 0; offset < childNodes.length; offset++) {2468if (dom.isText(childNodes[offset])) {2469continue;2470}2471
2472tester.moveToElementText(childNodes[offset]);2473
2474if (tester.compareEndPoints('StartToStart', textRange) >= 0) {2475break;2476}2477
2478prevContainer = childNodes[offset];2479}2480
2481if (offset !== 0 && dom.isText(childNodes[offset - 1])) {2482var textRangeStart = document.body.createTextRange();2483var curTextNode = null;2484textRangeStart.moveToElementText(prevContainer || container);2485textRangeStart.collapse(!prevContainer);2486curTextNode = prevContainer ? prevContainer.nextSibling : container.firstChild;2487var pointTester = textRange.duplicate();2488pointTester.setEndPoint('StartToStart', textRangeStart);2489var textCount = pointTester.text.replace(/[\r\n]/g, '').length;2490
2491while (textCount > curTextNode.nodeValue.length && curTextNode.nextSibling) {2492textCount -= curTextNode.nodeValue.length;2493curTextNode = curTextNode.nextSibling;2494} // [workaround] enforce IE to re-reference curTextNode, hack2495
2496
2497var dummy = curTextNode.nodeValue; // eslint-disable-line2498
2499if (isStart && curTextNode.nextSibling && dom.isText(curTextNode.nextSibling) && textCount === curTextNode.nodeValue.length) {2500textCount -= curTextNode.nodeValue.length;2501curTextNode = curTextNode.nextSibling;2502}2503
2504container = curTextNode;2505offset = textCount;2506}2507
2508return {2509cont: container,2510offset: offset2511};2512}
2513/**
2514* return TextRange from boundary point (inspired by google closure-library)
2515* @param {BoundaryPoint} point
2516* @return {TextRange}
2517*/
2518
2519
2520function pointToTextRange(point) {2521var textRangeInfo = function textRangeInfo(container, offset) {2522var node, isCollapseToStart;2523
2524if (dom.isText(container)) {2525var prevTextNodes = dom.listPrev(container, func.not(dom.isText));2526var prevContainer = lists.last(prevTextNodes).previousSibling;2527node = prevContainer || container.parentNode;2528offset += lists.sum(lists.tail(prevTextNodes), dom.nodeLength);2529isCollapseToStart = !prevContainer;2530} else {2531node = container.childNodes[offset] || container;2532
2533if (dom.isText(node)) {2534return textRangeInfo(node, 0);2535}2536
2537offset = 0;2538isCollapseToStart = false;2539}2540
2541return {2542node: node,2543collapseToStart: isCollapseToStart,2544offset: offset2545};2546};2547
2548var textRange = document.body.createTextRange();2549var info = textRangeInfo(point.node, point.offset);2550textRange.moveToElementText(info.node);2551textRange.collapse(info.collapseToStart);2552textRange.moveStart('character', info.offset);2553return textRange;2554}
2555/**
2556* Wrapped Range
2557*
2558* @constructor
2559* @param {Node} sc - start container
2560* @param {Number} so - start offset
2561* @param {Node} ec - end container
2562* @param {Number} eo - end offset
2563*/
2564
2565
2566var WrappedRange = /*#__PURE__*/function () {2567function WrappedRange(sc, so, ec, eo) {2568range_classCallCheck(this, WrappedRange);2569
2570this.sc = sc;2571this.so = so;2572this.ec = ec;2573this.eo = eo; // isOnEditable: judge whether range is on editable or not2574
2575this.isOnEditable = this.makeIsOn(dom.isEditable); // isOnList: judge whether range is on list node or not2576
2577this.isOnList = this.makeIsOn(dom.isList); // isOnAnchor: judge whether range is on anchor node or not2578
2579this.isOnAnchor = this.makeIsOn(dom.isAnchor); // isOnCell: judge whether range is on cell node or not2580
2581this.isOnCell = this.makeIsOn(dom.isCell); // isOnData: judge whether range is on data node or not2582
2583this.isOnData = this.makeIsOn(dom.isData);2584} // nativeRange: get nativeRange from sc, so, ec, eo2585
2586
2587range_createClass(WrappedRange, [{2588key: "nativeRange",2589value: function nativeRange() {2590if (env.isW3CRangeSupport) {2591var w3cRange = document.createRange();2592w3cRange.setStart(this.sc, this.so);2593w3cRange.setEnd(this.ec, this.eo);2594return w3cRange;2595} else {2596var textRange = pointToTextRange({2597node: this.sc,2598offset: this.so2599});2600textRange.setEndPoint('EndToEnd', pointToTextRange({2601node: this.ec,2602offset: this.eo2603}));2604return textRange;2605}2606}2607}, {2608key: "getPoints",2609value: function getPoints() {2610return {2611sc: this.sc,2612so: this.so,2613ec: this.ec,2614eo: this.eo2615};2616}2617}, {2618key: "getStartPoint",2619value: function getStartPoint() {2620return {2621node: this.sc,2622offset: this.so2623};2624}2625}, {2626key: "getEndPoint",2627value: function getEndPoint() {2628return {2629node: this.ec,2630offset: this.eo2631};2632}2633/**2634* select update visible range
2635*/
2636
2637}, {2638key: "select",2639value: function select() {2640var nativeRng = this.nativeRange();2641
2642if (env.isW3CRangeSupport) {2643var selection = document.getSelection();2644
2645if (selection.rangeCount > 0) {2646selection.removeAllRanges();2647}2648
2649selection.addRange(nativeRng);2650} else {2651nativeRng.select();2652}2653
2654return this;2655}2656/**2657* Moves the scrollbar to start container(sc) of current range
2658*
2659* @return {WrappedRange}
2660*/
2661
2662}, {2663key: "scrollIntoView",2664value: function scrollIntoView(container) {2665var height = external_jQuery_default()(container).height();2666
2667if (container.scrollTop + height < this.sc.offsetTop) {2668container.scrollTop += Math.abs(container.scrollTop + height - this.sc.offsetTop);2669}2670
2671return this;2672}2673/**2674* @return {WrappedRange}
2675*/
2676
2677}, {2678key: "normalize",2679value: function normalize() {2680/**2681* @param {BoundaryPoint} point
2682* @param {Boolean} isLeftToRight - true: prefer to choose right node
2683* - false: prefer to choose left node
2684* @return {BoundaryPoint}
2685*/
2686var getVisiblePoint = function getVisiblePoint(point, isLeftToRight) {2687if (!point) {2688return point;2689} // Just use the given point [XXX:Adhoc]2690// - case 01. if the point is on the middle of the node2691// - case 02. if the point is on the right edge and prefer to choose left node2692// - case 03. if the point is on the left edge and prefer to choose right node2693// - case 04. if the point is on the right edge and prefer to choose right node but the node is void2694// - case 05. if the point is on the left edge and prefer to choose left node but the node is void2695// - case 06. if the point is on the block node and there is no children2696
2697
2698if (dom.isVisiblePoint(point)) {2699if (!dom.isEdgePoint(point) || dom.isRightEdgePoint(point) && !isLeftToRight || dom.isLeftEdgePoint(point) && isLeftToRight || dom.isRightEdgePoint(point) && isLeftToRight && dom.isVoid(point.node.nextSibling) || dom.isLeftEdgePoint(point) && !isLeftToRight && dom.isVoid(point.node.previousSibling) || dom.isBlock(point.node) && dom.isEmpty(point.node)) {2700return point;2701}2702} // point on block's edge2703
2704
2705var block = dom.ancestor(point.node, dom.isBlock);2706var hasRightNode = false;2707
2708if (!hasRightNode) {2709var prevPoint = dom.prevPoint(point) || {2710node: null2711};2712hasRightNode = (dom.isLeftEdgePointOf(point, block) || dom.isVoid(prevPoint.node)) && !isLeftToRight;2713}2714
2715var hasLeftNode = false;2716
2717if (!hasLeftNode) {2718var _nextPoint = dom.nextPoint(point) || {2719node: null2720};2721
2722hasLeftNode = (dom.isRightEdgePointOf(point, block) || dom.isVoid(_nextPoint.node)) && isLeftToRight;2723}2724
2725if (hasRightNode || hasLeftNode) {2726// returns point already on visible point2727if (dom.isVisiblePoint(point)) {2728return point;2729} // reverse direction2730
2731
2732isLeftToRight = !isLeftToRight;2733}2734
2735var nextPoint = isLeftToRight ? dom.nextPointUntil(dom.nextPoint(point), dom.isVisiblePoint) : dom.prevPointUntil(dom.prevPoint(point), dom.isVisiblePoint);2736return nextPoint || point;2737};2738
2739var endPoint = getVisiblePoint(this.getEndPoint(), false);2740var startPoint = this.isCollapsed() ? endPoint : getVisiblePoint(this.getStartPoint(), true);2741return new WrappedRange(startPoint.node, startPoint.offset, endPoint.node, endPoint.offset);2742}2743/**2744* returns matched nodes on range
2745*
2746* @param {Function} [pred] - predicate function
2747* @param {Object} [options]
2748* @param {Boolean} [options.includeAncestor]
2749* @param {Boolean} [options.fullyContains]
2750* @return {Node[]}
2751*/
2752
2753}, {2754key: "nodes",2755value: function nodes(pred, options) {2756pred = pred || func.ok;2757var includeAncestor = options && options.includeAncestor;2758var fullyContains = options && options.fullyContains; // TODO compare points and sort2759
2760var startPoint = this.getStartPoint();2761var endPoint = this.getEndPoint();2762var nodes = [];2763var leftEdgeNodes = [];2764dom.walkPoint(startPoint, endPoint, function (point) {2765if (dom.isEditable(point.node)) {2766return;2767}2768
2769var node;2770
2771if (fullyContains) {2772if (dom.isLeftEdgePoint(point)) {2773leftEdgeNodes.push(point.node);2774}2775
2776if (dom.isRightEdgePoint(point) && lists.contains(leftEdgeNodes, point.node)) {2777node = point.node;2778}2779} else if (includeAncestor) {2780node = dom.ancestor(point.node, pred);2781} else {2782node = point.node;2783}2784
2785if (node && pred(node)) {2786nodes.push(node);2787}2788}, true);2789return lists.unique(nodes);2790}2791/**2792* returns commonAncestor of range
2793* @return {Element} - commonAncestor
2794*/
2795
2796}, {2797key: "commonAncestor",2798value: function commonAncestor() {2799return dom.commonAncestor(this.sc, this.ec);2800}2801/**2802* returns expanded range by pred
2803*
2804* @param {Function} pred - predicate function
2805* @return {WrappedRange}
2806*/
2807
2808}, {2809key: "expand",2810value: function expand(pred) {2811var startAncestor = dom.ancestor(this.sc, pred);2812var endAncestor = dom.ancestor(this.ec, pred);2813
2814if (!startAncestor && !endAncestor) {2815return new WrappedRange(this.sc, this.so, this.ec, this.eo);2816}2817
2818var boundaryPoints = this.getPoints();2819
2820if (startAncestor) {2821boundaryPoints.sc = startAncestor;2822boundaryPoints.so = 0;2823}2824
2825if (endAncestor) {2826boundaryPoints.ec = endAncestor;2827boundaryPoints.eo = dom.nodeLength(endAncestor);2828}2829
2830return new WrappedRange(boundaryPoints.sc, boundaryPoints.so, boundaryPoints.ec, boundaryPoints.eo);2831}2832/**2833* @param {Boolean} isCollapseToStart
2834* @return {WrappedRange}
2835*/
2836
2837}, {2838key: "collapse",2839value: function collapse(isCollapseToStart) {2840if (isCollapseToStart) {2841return new WrappedRange(this.sc, this.so, this.sc, this.so);2842} else {2843return new WrappedRange(this.ec, this.eo, this.ec, this.eo);2844}2845}2846/**2847* splitText on range
2848*/
2849
2850}, {2851key: "splitText",2852value: function splitText() {2853var isSameContainer = this.sc === this.ec;2854var boundaryPoints = this.getPoints();2855
2856if (dom.isText(this.ec) && !dom.isEdgePoint(this.getEndPoint())) {2857this.ec.splitText(this.eo);2858}2859
2860if (dom.isText(this.sc) && !dom.isEdgePoint(this.getStartPoint())) {2861boundaryPoints.sc = this.sc.splitText(this.so);2862boundaryPoints.so = 0;2863
2864if (isSameContainer) {2865boundaryPoints.ec = boundaryPoints.sc;2866boundaryPoints.eo = this.eo - this.so;2867}2868}2869
2870return new WrappedRange(boundaryPoints.sc, boundaryPoints.so, boundaryPoints.ec, boundaryPoints.eo);2871}2872/**2873* delete contents on range
2874* @return {WrappedRange}
2875*/
2876
2877}, {2878key: "deleteContents",2879value: function deleteContents() {2880if (this.isCollapsed()) {2881return this;2882}2883
2884var rng = this.splitText();2885var nodes = rng.nodes(null, {2886fullyContains: true2887}); // find new cursor point2888
2889var point = dom.prevPointUntil(rng.getStartPoint(), function (point) {2890return !lists.contains(nodes, point.node);2891});2892var emptyParents = [];2893external_jQuery_default().each(nodes, function (idx, node) {2894// find empty parents2895var parent = node.parentNode;2896
2897if (point.node !== parent && dom.nodeLength(parent) === 1) {2898emptyParents.push(parent);2899}2900
2901dom.remove(node, false);2902}); // remove empty parents2903
2904external_jQuery_default().each(emptyParents, function (idx, node) {2905dom.remove(node, false);2906});2907return new WrappedRange(point.node, point.offset, point.node, point.offset).normalize();2908}2909/**2910* makeIsOn: return isOn(pred) function
2911*/
2912
2913}, {2914key: "makeIsOn",2915value: function makeIsOn(pred) {2916return function () {2917var ancestor = dom.ancestor(this.sc, pred);2918return !!ancestor && ancestor === dom.ancestor(this.ec, pred);2919};2920}2921/**2922* @param {Function} pred
2923* @return {Boolean}
2924*/
2925
2926}, {2927key: "isLeftEdgeOf",2928value: function isLeftEdgeOf(pred) {2929if (!dom.isLeftEdgePoint(this.getStartPoint())) {2930return false;2931}2932
2933var node = dom.ancestor(this.sc, pred);2934return node && dom.isLeftEdgeOf(this.sc, node);2935}2936/**2937* returns whether range was collapsed or not
2938*/
2939
2940}, {2941key: "isCollapsed",2942value: function isCollapsed() {2943return this.sc === this.ec && this.so === this.eo;2944}2945/**2946* wrap inline nodes which children of body with paragraph
2947*
2948* @return {WrappedRange}
2949*/
2950
2951}, {2952key: "wrapBodyInlineWithPara",2953value: function wrapBodyInlineWithPara() {2954if (dom.isBodyContainer(this.sc) && dom.isEmpty(this.sc)) {2955this.sc.innerHTML = dom.emptyPara;2956return new WrappedRange(this.sc.firstChild, 0, this.sc.firstChild, 0);2957}2958/**2959* [workaround] firefox often create range on not visible point. so normalize here.
2960* - firefox: |<p>text</p>|
2961* - chrome: <p>|text|</p>
2962*/
2963
2964
2965var rng = this.normalize();2966
2967if (dom.isParaInline(this.sc) || dom.isPara(this.sc)) {2968return rng;2969} // find inline top ancestor2970
2971
2972var topAncestor;2973
2974if (dom.isInline(rng.sc)) {2975var ancestors = dom.listAncestor(rng.sc, func.not(dom.isInline));2976topAncestor = lists.last(ancestors);2977
2978if (!dom.isInline(topAncestor)) {2979topAncestor = ancestors[ancestors.length - 2] || rng.sc.childNodes[rng.so];2980}2981} else {2982topAncestor = rng.sc.childNodes[rng.so > 0 ? rng.so - 1 : 0];2983}2984
2985if (topAncestor) {2986// siblings not in paragraph2987var inlineSiblings = dom.listPrev(topAncestor, dom.isParaInline).reverse();2988inlineSiblings = inlineSiblings.concat(dom.listNext(topAncestor.nextSibling, dom.isParaInline)); // wrap with paragraph2989
2990if (inlineSiblings.length) {2991var para = dom.wrap(lists.head(inlineSiblings), 'p');2992dom.appendChildNodes(para, lists.tail(inlineSiblings));2993}2994}2995
2996return this.normalize();2997}2998/**2999* insert node at current cursor
3000*
3001* @param {Node} node
3002* @return {Node}
3003*/
3004
3005}, {3006key: "insertNode",3007value: function insertNode(node) {3008var rng = this;3009
3010if (dom.isText(node) || dom.isInline(node)) {3011rng = this.wrapBodyInlineWithPara().deleteContents();3012}3013
3014var info = dom.splitPoint(rng.getStartPoint(), dom.isInline(node));3015
3016if (info.rightNode) {3017info.rightNode.parentNode.insertBefore(node, info.rightNode);3018
3019if (dom.isEmpty(info.rightNode) && dom.isPara(node)) {3020info.rightNode.parentNode.removeChild(info.rightNode);3021}3022} else {3023info.container.appendChild(node);3024}3025
3026return node;3027}3028/**3029* insert html at current cursor
3030*/
3031
3032}, {3033key: "pasteHTML",3034value: function pasteHTML(markup) {3035markup = external_jQuery_default().trim(markup);3036var contentsContainer = external_jQuery_default()('<div></div>').html(markup)[0];3037var childNodes = lists.from(contentsContainer.childNodes); // const rng = this.wrapBodyInlineWithPara().deleteContents();3038
3039var rng = this;3040var reversed = false;3041
3042if (rng.so >= 0) {3043childNodes = childNodes.reverse();3044reversed = true;3045}3046
3047childNodes = childNodes.map(function (childNode) {3048return rng.insertNode(childNode);3049});3050
3051if (reversed) {3052childNodes = childNodes.reverse();3053}3054
3055return childNodes;3056}3057/**3058* returns text in range
3059*
3060* @return {String}
3061*/
3062
3063}, {3064key: "toString",3065value: function toString() {3066var nativeRng = this.nativeRange();3067return env.isW3CRangeSupport ? nativeRng.toString() : nativeRng.text;3068}3069/**3070* returns range for word before cursor
3071*
3072* @param {Boolean} [findAfter] - find after cursor, default: false
3073* @return {WrappedRange}
3074*/
3075
3076}, {3077key: "getWordRange",3078value: function getWordRange(findAfter) {3079var endPoint = this.getEndPoint();3080
3081if (!dom.isCharPoint(endPoint)) {3082return this;3083}3084
3085var startPoint = dom.prevPointUntil(endPoint, function (point) {3086return !dom.isCharPoint(point);3087});3088
3089if (findAfter) {3090endPoint = dom.nextPointUntil(endPoint, function (point) {3091return !dom.isCharPoint(point);3092});3093}3094
3095return new WrappedRange(startPoint.node, startPoint.offset, endPoint.node, endPoint.offset);3096}3097/**3098* returns range for words before cursor
3099*
3100* @param {Boolean} [findAfter] - find after cursor, default: false
3101* @return {WrappedRange}
3102*/
3103
3104}, {3105key: "getWordsRange",3106value: function getWordsRange(findAfter) {3107var endPoint = this.getEndPoint();3108
3109var isNotTextPoint = function isNotTextPoint(point) {3110return !dom.isCharPoint(point) && !dom.isSpacePoint(point);3111};3112
3113if (isNotTextPoint(endPoint)) {3114return this;3115}3116
3117var startPoint = dom.prevPointUntil(endPoint, isNotTextPoint);3118
3119if (findAfter) {3120endPoint = dom.nextPointUntil(endPoint, isNotTextPoint);3121}3122
3123return new WrappedRange(startPoint.node, startPoint.offset, endPoint.node, endPoint.offset);3124}3125/**3126* returns range for words before cursor that match with a Regex
3127*
3128* example:
3129* range: 'hi @Peter Pan'
3130* regex: '/@[a-z ]+/i'
3131* return range: '@Peter Pan'
3132*
3133* @param {RegExp} [regex]
3134* @return {WrappedRange|null}
3135*/
3136
3137}, {3138key: "getWordsMatchRange",3139value: function getWordsMatchRange(regex) {3140var endPoint = this.getEndPoint();3141var startPoint = dom.prevPointUntil(endPoint, function (point) {3142if (!dom.isCharPoint(point) && !dom.isSpacePoint(point)) {3143return true;3144}3145
3146var rng = new WrappedRange(point.node, point.offset, endPoint.node, endPoint.offset);3147var result = regex.exec(rng.toString());3148return result && result.index === 0;3149});3150var rng = new WrappedRange(startPoint.node, startPoint.offset, endPoint.node, endPoint.offset);3151var text = rng.toString();3152var result = regex.exec(text);3153
3154if (result && result[0].length === text.length) {3155return rng;3156} else {3157return null;3158}3159}3160/**3161* create offsetPath bookmark
3162*
3163* @param {Node} editable
3164*/
3165
3166}, {3167key: "bookmark",3168value: function bookmark(editable) {3169return {3170s: {3171path: dom.makeOffsetPath(editable, this.sc),3172offset: this.so3173},3174e: {3175path: dom.makeOffsetPath(editable, this.ec),3176offset: this.eo3177}3178};3179}3180/**3181* create offsetPath bookmark base on paragraph
3182*
3183* @param {Node[]} paras
3184*/
3185
3186}, {3187key: "paraBookmark",3188value: function paraBookmark(paras) {3189return {3190s: {3191path: lists.tail(dom.makeOffsetPath(lists.head(paras), this.sc)),3192offset: this.so3193},3194e: {3195path: lists.tail(dom.makeOffsetPath(lists.last(paras), this.ec)),3196offset: this.eo3197}3198};3199}3200/**3201* getClientRects
3202* @return {Rect[]}
3203*/
3204
3205}, {3206key: "getClientRects",3207value: function getClientRects() {3208var nativeRng = this.nativeRange();3209return nativeRng.getClientRects();3210}3211}]);3212
3213return WrappedRange;3214}();3215/**
3216* Data structure
3217* * BoundaryPoint: a point of dom tree
3218* * BoundaryPoints: two boundaryPoints corresponding to the start and the end of the Range
3219*
3220* See to http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html#Level-2-Range-Position
3221*/
3222
3223
3224/* harmony default export */ const range = ({3225/**3226* create Range Object From arguments or Browser Selection
3227*
3228* @param {Node} sc - start container
3229* @param {Number} so - start offset
3230* @param {Node} ec - end container
3231* @param {Number} eo - end offset
3232* @return {WrappedRange}
3233*/
3234create: function create(sc, so, ec, eo) {3235if (arguments.length === 4) {3236return new WrappedRange(sc, so, ec, eo);3237} else if (arguments.length === 2) {3238// collapsed3239ec = sc;3240eo = so;3241return new WrappedRange(sc, so, ec, eo);3242} else {3243var wrappedRange = this.createFromSelection();3244
3245if (!wrappedRange && arguments.length === 1) {3246var bodyElement = arguments[0];3247
3248if (dom.isEditable(bodyElement)) {3249bodyElement = bodyElement.lastChild;3250}3251
3252return this.createFromBodyElement(bodyElement, dom.emptyPara === arguments[0].innerHTML);3253}3254
3255return wrappedRange;3256}3257},3258createFromBodyElement: function createFromBodyElement(bodyElement) {3259var isCollapseToStart = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;3260var wrappedRange = this.createFromNode(bodyElement);3261return wrappedRange.collapse(isCollapseToStart);3262},3263createFromSelection: function createFromSelection() {3264var sc, so, ec, eo;3265
3266if (env.isW3CRangeSupport) {3267var selection = document.getSelection();3268
3269if (!selection || selection.rangeCount === 0) {3270return null;3271} else if (dom.isBody(selection.anchorNode)) {3272// Firefox: returns entire body as range on initialization.3273// We won't never need it.3274return null;3275}3276
3277var nativeRng = selection.getRangeAt(0);3278sc = nativeRng.startContainer;3279so = nativeRng.startOffset;3280ec = nativeRng.endContainer;3281eo = nativeRng.endOffset;3282} else {3283// IE8: TextRange3284var textRange = document.selection.createRange();3285var textRangeEnd = textRange.duplicate();3286textRangeEnd.collapse(false);3287var textRangeStart = textRange;3288textRangeStart.collapse(true);3289var startPoint = textRangeToPoint(textRangeStart, true);3290var endPoint = textRangeToPoint(textRangeEnd, false); // same visible point case: range was collapsed.3291
3292if (dom.isText(startPoint.node) && dom.isLeftEdgePoint(startPoint) && dom.isTextNode(endPoint.node) && dom.isRightEdgePoint(endPoint) && endPoint.node.nextSibling === startPoint.node) {3293startPoint = endPoint;3294}3295
3296sc = startPoint.cont;3297so = startPoint.offset;3298ec = endPoint.cont;3299eo = endPoint.offset;3300}3301
3302return new WrappedRange(sc, so, ec, eo);3303},3304
3305/**3306* @method
3307*
3308* create WrappedRange from node
3309*
3310* @param {Node} node
3311* @return {WrappedRange}
3312*/
3313createFromNode: function createFromNode(node) {3314var sc = node;3315var so = 0;3316var ec = node;3317var eo = dom.nodeLength(ec); // browsers can't target a picture or void node3318
3319if (dom.isVoid(sc)) {3320so = dom.listPrev(sc).length - 1;3321sc = sc.parentNode;3322}3323
3324if (dom.isBR(ec)) {3325eo = dom.listPrev(ec).length - 1;3326ec = ec.parentNode;3327} else if (dom.isVoid(ec)) {3328eo = dom.listPrev(ec).length;3329ec = ec.parentNode;3330}3331
3332return this.create(sc, so, ec, eo);3333},3334
3335/**3336* create WrappedRange from node after position
3337*
3338* @param {Node} node
3339* @return {WrappedRange}
3340*/
3341createFromNodeBefore: function createFromNodeBefore(node) {3342return this.createFromNode(node).collapse(true);3343},3344
3345/**3346* create WrappedRange from node after position
3347*
3348* @param {Node} node
3349* @return {WrappedRange}
3350*/
3351createFromNodeAfter: function createFromNodeAfter(node) {3352return this.createFromNode(node).collapse();3353},3354
3355/**3356* @method
3357*
3358* create WrappedRange from bookmark
3359*
3360* @param {Node} editable
3361* @param {Object} bookmark
3362* @return {WrappedRange}
3363*/
3364createFromBookmark: function createFromBookmark(editable, bookmark) {3365var sc = dom.fromOffsetPath(editable, bookmark.s.path);3366var so = bookmark.s.offset;3367var ec = dom.fromOffsetPath(editable, bookmark.e.path);3368var eo = bookmark.e.offset;3369return new WrappedRange(sc, so, ec, eo);3370},3371
3372/**3373* @method
3374*
3375* create WrappedRange from paraBookmark
3376*
3377* @param {Object} bookmark
3378* @param {Node[]} paras
3379* @return {WrappedRange}
3380*/
3381createFromParaBookmark: function createFromParaBookmark(bookmark, paras) {3382var so = bookmark.s.offset;3383var eo = bookmark.e.offset;3384var sc = dom.fromOffsetPath(lists.head(paras), bookmark.s.path);3385var ec = dom.fromOffsetPath(lists.last(paras), bookmark.e.path);3386return new WrappedRange(sc, so, ec, eo);3387}3388});3389;// CONCATENATED MODULE: ./src/js/core/key.js3390
3391
3392var KEY_MAP = {3393'BACKSPACE': 8,3394'TAB': 9,3395'ENTER': 13,3396'ESCAPE': 27,3397'SPACE': 32,3398'DELETE': 46,3399// Arrow3400'LEFT': 37,3401'UP': 38,3402'RIGHT': 39,3403'DOWN': 40,3404// Number: 0-93405'NUM0': 48,3406'NUM1': 49,3407'NUM2': 50,3408'NUM3': 51,3409'NUM4': 52,3410'NUM5': 53,3411'NUM6': 54,3412'NUM7': 55,3413'NUM8': 56,3414// Alphabet: a-z3415'B': 66,3416'E': 69,3417'I': 73,3418'J': 74,3419'K': 75,3420'L': 76,3421'R': 82,3422'S': 83,3423'U': 85,3424'V': 86,3425'Y': 89,3426'Z': 90,3427'SLASH': 191,3428'LEFTBRACKET': 219,3429'BACKSLASH': 220,3430'RIGHTBRACKET': 221,3431// Navigation3432'HOME': 36,3433'END': 35,3434'PAGEUP': 33,3435'PAGEDOWN': 343436};3437/**
3438* @class core.key
3439*
3440* Object for keycodes.
3441*
3442* @singleton
3443* @alternateClassName key
3444*/
3445
3446/* harmony default export */ const key = ({3447/**3448* @method isEdit
3449*
3450* @param {Number} keyCode
3451* @return {Boolean}
3452*/
3453isEdit: function isEdit(keyCode) {3454return lists.contains([KEY_MAP.BACKSPACE, KEY_MAP.TAB, KEY_MAP.ENTER, KEY_MAP.SPACE, KEY_MAP.DELETE], keyCode);3455},3456
3457/**3458* @method isMove
3459*
3460* @param {Number} keyCode
3461* @return {Boolean}
3462*/
3463isMove: function isMove(keyCode) {3464return lists.contains([KEY_MAP.LEFT, KEY_MAP.UP, KEY_MAP.RIGHT, KEY_MAP.DOWN], keyCode);3465},3466
3467/**3468* @method isNavigation
3469*
3470* @param {Number} keyCode
3471* @return {Boolean}
3472*/
3473isNavigation: function isNavigation(keyCode) {3474return lists.contains([KEY_MAP.HOME, KEY_MAP.END, KEY_MAP.PAGEUP, KEY_MAP.PAGEDOWN], keyCode);3475},3476
3477/**3478* @property {Object} nameFromCode
3479* @property {String} nameFromCode.8 "BACKSPACE"
3480*/
3481nameFromCode: func.invertObject(KEY_MAP),3482code: KEY_MAP3483});3484;// CONCATENATED MODULE: ./src/js/core/async.js3485
3486/**
3487* @method readFileAsDataURL
3488*
3489* read contents of file as representing URL
3490*
3491* @param {File} file
3492* @return {Promise} - then: dataUrl
3493*/
3494
3495function readFileAsDataURL(file) {3496return external_jQuery_default().Deferred(function (deferred) {3497external_jQuery_default().extend(new FileReader(), {3498onload: function onload(e) {3499var dataURL = e.target.result;3500deferred.resolve(dataURL);3501},3502onerror: function onerror(err) {3503deferred.reject(err);3504}3505}).readAsDataURL(file);3506}).promise();3507}
3508/**
3509* @method createImage
3510*
3511* create `<image>` from url string
3512*
3513* @param {String} url
3514* @return {Promise} - then: $image
3515*/
3516
3517function createImage(url) {3518return external_jQuery_default().Deferred(function (deferred) {3519var $img = external_jQuery_default()('<img>');3520$img.one('load', function () {3521$img.off('error abort');3522deferred.resolve($img);3523}).one('error abort', function () {3524$img.off('load').detach();3525deferred.reject($img);3526}).css({3527display: 'none'3528}).appendTo(document.body).attr('src', url);3529}).promise();3530}
3531;// CONCATENATED MODULE: ./src/js/editing/History.js3532function History_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }3533
3534function History_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); } }3535
3536function History_createClass(Constructor, protoProps, staticProps) { if (protoProps) History_defineProperties(Constructor.prototype, protoProps); if (staticProps) History_defineProperties(Constructor, staticProps); return Constructor; }3537
3538
3539
3540var History = /*#__PURE__*/function () {3541function History(context) {3542History_classCallCheck(this, History);3543
3544this.stack = [];3545this.stackOffset = -1;3546this.context = context;3547this.$editable = context.layoutInfo.editable;3548this.editable = this.$editable[0];3549}3550
3551History_createClass(History, [{3552key: "makeSnapshot",3553value: function makeSnapshot() {3554var rng = range.create(this.editable);3555var emptyBookmark = {3556s: {3557path: [],3558offset: 03559},3560e: {3561path: [],3562offset: 03563}3564};3565return {3566contents: this.$editable.html(),3567bookmark: rng && rng.isOnEditable() ? rng.bookmark(this.editable) : emptyBookmark3568};3569}3570}, {3571key: "applySnapshot",3572value: function applySnapshot(snapshot) {3573if (snapshot.contents !== null) {3574this.$editable.html(snapshot.contents);3575}3576
3577if (snapshot.bookmark !== null) {3578range.createFromBookmark(this.editable, snapshot.bookmark).select();3579}3580}3581/**3582* @method rewind
3583* Rewinds the history stack back to the first snapshot taken.
3584* Leaves the stack intact, so that "Redo" can still be used.
3585*/
3586
3587}, {3588key: "rewind",3589value: function rewind() {3590// Create snap shot if not yet recorded3591if (this.$editable.html() !== this.stack[this.stackOffset].contents) {3592this.recordUndo();3593} // Return to the first available snapshot.3594
3595
3596this.stackOffset = 0; // Apply that snapshot.3597
3598this.applySnapshot(this.stack[this.stackOffset]);3599}3600/**3601* @method commit
3602* Resets history stack, but keeps current editor's content.
3603*/
3604
3605}, {3606key: "commit",3607value: function commit() {3608// Clear the stack.3609this.stack = []; // Restore stackOffset to its original value.3610
3611this.stackOffset = -1; // Record our first snapshot (of nothing).3612
3613this.recordUndo();3614}3615/**3616* @method reset
3617* Resets the history stack completely; reverting to an empty editor.
3618*/
3619
3620}, {3621key: "reset",3622value: function reset() {3623// Clear the stack.3624this.stack = []; // Restore stackOffset to its original value.3625
3626this.stackOffset = -1; // Clear the editable area.3627
3628this.$editable.html(''); // Record our first snapshot (of nothing).3629
3630this.recordUndo();3631}3632/**3633* undo
3634*/
3635
3636}, {3637key: "undo",3638value: function undo() {3639// Create snap shot if not yet recorded3640if (this.$editable.html() !== this.stack[this.stackOffset].contents) {3641this.recordUndo();3642}3643
3644if (this.stackOffset > 0) {3645this.stackOffset--;3646this.applySnapshot(this.stack[this.stackOffset]);3647}3648}3649/**3650* redo
3651*/
3652
3653}, {3654key: "redo",3655value: function redo() {3656if (this.stack.length - 1 > this.stackOffset) {3657this.stackOffset++;3658this.applySnapshot(this.stack[this.stackOffset]);3659}3660}3661/**3662* recorded undo
3663*/
3664
3665}, {3666key: "recordUndo",3667value: function recordUndo() {3668this.stackOffset++; // Wash out stack after stackOffset3669
3670if (this.stack.length > this.stackOffset) {3671this.stack = this.stack.slice(0, this.stackOffset);3672} // Create new snapshot and push it to the end3673
3674
3675this.stack.push(this.makeSnapshot()); // If the stack size reachs to the limit, then slice it3676
3677if (this.stack.length > this.context.options.historyLimit) {3678this.stack.shift();3679this.stackOffset -= 1;3680}3681}3682}]);3683
3684return History;3685}();3686
3687
3688;// CONCATENATED MODULE: ./src/js/editing/Style.js3689function Style_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }3690
3691function Style_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); } }3692
3693function Style_createClass(Constructor, protoProps, staticProps) { if (protoProps) Style_defineProperties(Constructor.prototype, protoProps); if (staticProps) Style_defineProperties(Constructor, staticProps); return Constructor; }3694
3695
3696
3697
3698
3699
3700var Style = /*#__PURE__*/function () {3701function Style() {3702Style_classCallCheck(this, Style);3703}3704
3705Style_createClass(Style, [{3706key: "jQueryCSS",3707value:3708/**3709* @method jQueryCSS
3710*
3711* [workaround] for old jQuery
3712* passing an array of style properties to .css()
3713* will result in an object of property-value pairs.
3714* (compability with version < 1.9)
3715*
3716* @private
3717* @param {jQuery} $obj
3718* @param {Array} propertyNames - An array of one or more CSS properties.
3719* @return {Object}
3720*/
3721function jQueryCSS($obj, propertyNames) {3722var result = {};3723external_jQuery_default().each(propertyNames, function (idx, propertyName) {3724result[propertyName] = $obj.css(propertyName);3725});3726return result;3727}3728/**3729* returns style object from node
3730*
3731* @param {jQuery} $node
3732* @return {Object}
3733*/
3734
3735}, {3736key: "fromNode",3737value: function fromNode($node) {3738var properties = ['font-family', 'font-size', 'text-align', 'list-style-type', 'line-height'];3739var styleInfo = this.jQueryCSS($node, properties) || {};3740var fontSize = $node[0].style.fontSize || styleInfo['font-size'];3741styleInfo['font-size'] = parseInt(fontSize, 10);3742styleInfo['font-size-unit'] = fontSize.match(/[a-z%]+$/);3743return styleInfo;3744}3745/**3746* paragraph level style
3747*
3748* @param {WrappedRange} rng
3749* @param {Object} styleInfo
3750*/
3751
3752}, {3753key: "stylePara",3754value: function stylePara(rng, styleInfo) {3755external_jQuery_default().each(rng.nodes(dom.isPara, {3756includeAncestor: true3757}), function (idx, para) {3758external_jQuery_default()(para).css(styleInfo);3759});3760}3761/**3762* insert and returns styleNodes on range.
3763*
3764* @param {WrappedRange} rng
3765* @param {Object} [options] - options for styleNodes
3766* @param {String} [options.nodeName] - default: `SPAN`
3767* @param {Boolean} [options.expandClosestSibling] - default: `false`
3768* @param {Boolean} [options.onlyPartialContains] - default: `false`
3769* @return {Node[]}
3770*/
3771
3772}, {3773key: "styleNodes",3774value: function styleNodes(rng, options) {3775rng = rng.splitText();3776var nodeName = options && options.nodeName || 'SPAN';3777var expandClosestSibling = !!(options && options.expandClosestSibling);3778var onlyPartialContains = !!(options && options.onlyPartialContains);3779
3780if (rng.isCollapsed()) {3781return [rng.insertNode(dom.create(nodeName))];3782}3783
3784var pred = dom.makePredByNodeName(nodeName);3785var nodes = rng.nodes(dom.isText, {3786fullyContains: true3787}).map(function (text) {3788return dom.singleChildAncestor(text, pred) || dom.wrap(text, nodeName);3789});3790
3791if (expandClosestSibling) {3792if (onlyPartialContains) {3793var nodesInRange = rng.nodes(); // compose with partial contains predication3794
3795pred = func.and(pred, function (node) {3796return lists.contains(nodesInRange, node);3797});3798}3799
3800return nodes.map(function (node) {3801var siblings = dom.withClosestSiblings(node, pred);3802var head = lists.head(siblings);3803var tails = lists.tail(siblings);3804external_jQuery_default().each(tails, function (idx, elem) {3805dom.appendChildNodes(head, elem.childNodes);3806dom.remove(elem);3807});3808return lists.head(siblings);3809});3810} else {3811return nodes;3812}3813}3814/**3815* get current style on cursor
3816*
3817* @param {WrappedRange} rng
3818* @return {Object} - object contains style properties.
3819*/
3820
3821}, {3822key: "current",3823value: function current(rng) {3824var $cont = external_jQuery_default()(!dom.isElement(rng.sc) ? rng.sc.parentNode : rng.sc);3825var styleInfo = this.fromNode($cont); // document.queryCommandState for toggle state3826// [workaround] prevent Firefox nsresult: "0x80004005 (NS_ERROR_FAILURE)"3827
3828try {3829styleInfo = external_jQuery_default().extend(styleInfo, {3830'font-bold': document.queryCommandState('bold') ? 'bold' : 'normal',3831'font-italic': document.queryCommandState('italic') ? 'italic' : 'normal',3832'font-underline': document.queryCommandState('underline') ? 'underline' : 'normal',3833'font-subscript': document.queryCommandState('subscript') ? 'subscript' : 'normal',3834'font-superscript': document.queryCommandState('superscript') ? 'superscript' : 'normal',3835'font-strikethrough': document.queryCommandState('strikethrough') ? 'strikethrough' : 'normal',3836'font-family': document.queryCommandValue('fontname') || styleInfo['font-family']3837});3838} catch (e) {// eslint-disable-next-line3839} // list-style-type to list-style(unordered, ordered)3840
3841
3842if (!rng.isOnList()) {3843styleInfo['list-style'] = 'none';3844} else {3845var orderedTypes = ['circle', 'disc', 'disc-leading-zero', 'square'];3846var isUnordered = orderedTypes.indexOf(styleInfo['list-style-type']) > -1;3847styleInfo['list-style'] = isUnordered ? 'unordered' : 'ordered';3848}3849
3850var para = dom.ancestor(rng.sc, dom.isPara);3851
3852if (para && para.style['line-height']) {3853styleInfo['line-height'] = para.style.lineHeight;3854} else {3855var lineHeight = parseInt(styleInfo['line-height'], 10) / parseInt(styleInfo['font-size'], 10);3856styleInfo['line-height'] = lineHeight.toFixed(1);3857}3858
3859styleInfo.anchor = rng.isOnAnchor() && dom.ancestor(rng.sc, dom.isAnchor);3860styleInfo.ancestors = dom.listAncestor(rng.sc, dom.isEditable);3861styleInfo.range = rng;3862return styleInfo;3863}3864}]);3865
3866return Style;3867}();3868
3869
3870;// CONCATENATED MODULE: ./src/js/editing/Bullet.js3871function Bullet_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }3872
3873function Bullet_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); } }3874
3875function Bullet_createClass(Constructor, protoProps, staticProps) { if (protoProps) Bullet_defineProperties(Constructor.prototype, protoProps); if (staticProps) Bullet_defineProperties(Constructor, staticProps); return Constructor; }3876
3877
3878
3879
3880
3881
3882
3883var Bullet = /*#__PURE__*/function () {3884function Bullet() {3885Bullet_classCallCheck(this, Bullet);3886}3887
3888Bullet_createClass(Bullet, [{3889key: "insertOrderedList",3890value:3891/**3892* toggle ordered list
3893*/
3894function insertOrderedList(editable) {3895this.toggleList('OL', editable);3896}3897/**3898* toggle unordered list
3899*/
3900
3901}, {3902key: "insertUnorderedList",3903value: function insertUnorderedList(editable) {3904this.toggleList('UL', editable);3905}3906/**3907* indent
3908*/
3909
3910}, {3911key: "indent",3912value: function indent(editable) {3913var _this = this;3914
3915var rng = range.create(editable).wrapBodyInlineWithPara();3916var paras = rng.nodes(dom.isPara, {3917includeAncestor: true3918});3919var clustereds = lists.clusterBy(paras, func.peq2('parentNode'));3920external_jQuery_default().each(clustereds, function (idx, paras) {3921var head = lists.head(paras);3922
3923if (dom.isLi(head)) {3924var previousList = _this.findList(head.previousSibling);3925
3926if (previousList) {3927paras.map(function (para) {3928return previousList.appendChild(para);3929});3930} else {3931_this.wrapList(paras, head.parentNode.nodeName);3932
3933paras.map(function (para) {3934return para.parentNode;3935}).map(function (para) {3936return _this.appendToPrevious(para);3937});3938}3939} else {3940external_jQuery_default().each(paras, function (idx, para) {3941external_jQuery_default()(para).css('marginLeft', function (idx, val) {3942return (parseInt(val, 10) || 0) + 25;3943});3944});3945}3946});3947rng.select();3948}3949/**3950* outdent
3951*/
3952
3953}, {3954key: "outdent",3955value: function outdent(editable) {3956var _this2 = this;3957
3958var rng = range.create(editable).wrapBodyInlineWithPara();3959var paras = rng.nodes(dom.isPara, {3960includeAncestor: true3961});3962var clustereds = lists.clusterBy(paras, func.peq2('parentNode'));3963external_jQuery_default().each(clustereds, function (idx, paras) {3964var head = lists.head(paras);3965
3966if (dom.isLi(head)) {3967_this2.releaseList([paras]);3968} else {3969external_jQuery_default().each(paras, function (idx, para) {3970external_jQuery_default()(para).css('marginLeft', function (idx, val) {3971val = parseInt(val, 10) || 0;3972return val > 25 ? val - 25 : '';3973});3974});3975}3976});3977rng.select();3978}3979/**3980* toggle list
3981*
3982* @param {String} listName - OL or UL
3983*/
3984
3985}, {3986key: "toggleList",3987value: function toggleList(listName, editable) {3988var _this3 = this;3989
3990var rng = range.create(editable).wrapBodyInlineWithPara();3991var paras = rng.nodes(dom.isPara, {3992includeAncestor: true3993});3994var bookmark = rng.paraBookmark(paras);3995var clustereds = lists.clusterBy(paras, func.peq2('parentNode')); // paragraph to list3996
3997if (lists.find(paras, dom.isPurePara)) {3998var wrappedParas = [];3999external_jQuery_default().each(clustereds, function (idx, paras) {4000wrappedParas = wrappedParas.concat(_this3.wrapList(paras, listName));4001});4002paras = wrappedParas; // list to paragraph or change list style4003} else {4004var diffLists = rng.nodes(dom.isList, {4005includeAncestor: true4006}).filter(function (listNode) {4007return !external_jQuery_default().nodeName(listNode, listName);4008});4009
4010if (diffLists.length) {4011external_jQuery_default().each(diffLists, function (idx, listNode) {4012dom.replace(listNode, listName);4013});4014} else {4015paras = this.releaseList(clustereds, true);4016}4017}4018
4019range.createFromParaBookmark(bookmark, paras).select();4020}4021/**4022* @param {Node[]} paras
4023* @param {String} listName
4024* @return {Node[]}
4025*/
4026
4027}, {4028key: "wrapList",4029value: function wrapList(paras, listName) {4030var head = lists.head(paras);4031var last = lists.last(paras);4032var prevList = dom.isList(head.previousSibling) && head.previousSibling;4033var nextList = dom.isList(last.nextSibling) && last.nextSibling;4034var listNode = prevList || dom.insertAfter(dom.create(listName || 'UL'), last); // P to LI4035
4036paras = paras.map(function (para) {4037return dom.isPurePara(para) ? dom.replace(para, 'LI') : para;4038}); // append to list(<ul>, <ol>)4039
4040dom.appendChildNodes(listNode, paras);4041
4042if (nextList) {4043dom.appendChildNodes(listNode, lists.from(nextList.childNodes));4044dom.remove(nextList);4045}4046
4047return paras;4048}4049/**4050* @method releaseList
4051*
4052* @param {Array[]} clustereds
4053* @param {Boolean} isEscapseToBody
4054* @return {Node[]}
4055*/
4056
4057}, {4058key: "releaseList",4059value: function releaseList(clustereds, isEscapseToBody) {4060var _this4 = this;4061
4062var releasedParas = [];4063external_jQuery_default().each(clustereds, function (idx, paras) {4064var head = lists.head(paras);4065var last = lists.last(paras);4066var headList = isEscapseToBody ? dom.lastAncestor(head, dom.isList) : head.parentNode;4067var parentItem = headList.parentNode;4068
4069if (headList.parentNode.nodeName === 'LI') {4070paras.map(function (para) {4071var newList = _this4.findNextSiblings(para);4072
4073if (parentItem.nextSibling) {4074parentItem.parentNode.insertBefore(para, parentItem.nextSibling);4075} else {4076parentItem.parentNode.appendChild(para);4077}4078
4079if (newList.length) {4080_this4.wrapList(newList, headList.nodeName);4081
4082para.appendChild(newList[0].parentNode);4083}4084});4085
4086if (headList.children.length === 0) {4087parentItem.removeChild(headList);4088}4089
4090if (parentItem.childNodes.length === 0) {4091parentItem.parentNode.removeChild(parentItem);4092}4093} else {4094var lastList = headList.childNodes.length > 1 ? dom.splitTree(headList, {4095node: last.parentNode,4096offset: dom.position(last) + 14097}, {4098isSkipPaddingBlankHTML: true4099}) : null;4100var middleList = dom.splitTree(headList, {4101node: head.parentNode,4102offset: dom.position(head)4103}, {4104isSkipPaddingBlankHTML: true4105});4106paras = isEscapseToBody ? dom.listDescendant(middleList, dom.isLi) : lists.from(middleList.childNodes).filter(dom.isLi); // LI to P4107
4108if (isEscapseToBody || !dom.isList(headList.parentNode)) {4109paras = paras.map(function (para) {4110return dom.replace(para, 'P');4111});4112}4113
4114external_jQuery_default().each(lists.from(paras).reverse(), function (idx, para) {4115dom.insertAfter(para, headList);4116}); // remove empty lists4117
4118var rootLists = lists.compact([headList, middleList, lastList]);4119external_jQuery_default().each(rootLists, function (idx, rootList) {4120var listNodes = [rootList].concat(dom.listDescendant(rootList, dom.isList));4121external_jQuery_default().each(listNodes.reverse(), function (idx, listNode) {4122if (!dom.nodeLength(listNode)) {4123dom.remove(listNode, true);4124}4125});4126});4127}4128
4129releasedParas = releasedParas.concat(paras);4130});4131return releasedParas;4132}4133/**4134* @method appendToPrevious
4135*
4136* Appends list to previous list item, if
4137* none exist it wraps the list in a new list item.
4138*
4139* @param {HTMLNode} ListItem
4140* @return {HTMLNode}
4141*/
4142
4143}, {4144key: "appendToPrevious",4145value: function appendToPrevious(node) {4146return node.previousSibling ? dom.appendChildNodes(node.previousSibling, [node]) : this.wrapList([node], 'LI');4147}4148/**4149* @method findList
4150*
4151* Finds an existing list in list item
4152*
4153* @param {HTMLNode} ListItem
4154* @return {Array[]}
4155*/
4156
4157}, {4158key: "findList",4159value: function findList(node) {4160return node ? lists.find(node.children, function (child) {4161return ['OL', 'UL'].indexOf(child.nodeName) > -1;4162}) : null;4163}4164/**4165* @method findNextSiblings
4166*
4167* Finds all list item siblings that follow it
4168*
4169* @param {HTMLNode} ListItem
4170* @return {HTMLNode}
4171*/
4172
4173}, {4174key: "findNextSiblings",4175value: function findNextSiblings(node) {4176var siblings = [];4177
4178while (node.nextSibling) {4179siblings.push(node.nextSibling);4180node = node.nextSibling;4181}4182
4183return siblings;4184}4185}]);4186
4187return Bullet;4188}();4189
4190
4191;// CONCATENATED MODULE: ./src/js/editing/Typing.js4192function Typing_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }4193
4194function Typing_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); } }4195
4196function Typing_createClass(Constructor, protoProps, staticProps) { if (protoProps) Typing_defineProperties(Constructor.prototype, protoProps); if (staticProps) Typing_defineProperties(Constructor, staticProps); return Constructor; }4197
4198
4199
4200
4201
4202/**
4203* @class editing.Typing
4204*
4205* Typing
4206*
4207*/
4208
4209var Typing = /*#__PURE__*/function () {4210function Typing(context) {4211Typing_classCallCheck(this, Typing);4212
4213// a Bullet instance to toggle lists off4214this.bullet = new Bullet();4215this.options = context.options;4216}4217/**4218* insert tab
4219*
4220* @param {WrappedRange} rng
4221* @param {Number} tabsize
4222*/
4223
4224
4225Typing_createClass(Typing, [{4226key: "insertTab",4227value: function insertTab(rng, tabsize) {4228var tab = dom.createText(new Array(tabsize + 1).join(dom.NBSP_CHAR));4229rng = rng.deleteContents();4230rng.insertNode(tab, true);4231rng = range.create(tab, tabsize);4232rng.select();4233}4234/**4235* insert paragraph
4236*
4237* @param {jQuery} $editable
4238* @param {WrappedRange} rng Can be used in unit tests to "mock" the range
4239*
4240* blockquoteBreakingLevel
4241* 0 - No break, the new paragraph remains inside the quote
4242* 1 - Break the first blockquote in the ancestors list
4243* 2 - Break all blockquotes, so that the new paragraph is not quoted (this is the default)
4244*/
4245
4246}, {4247key: "insertParagraph",4248value: function insertParagraph(editable, rng) {4249rng = rng || range.create(editable); // deleteContents on range.4250
4251rng = rng.deleteContents(); // Wrap range if it needs to be wrapped by paragraph4252
4253rng = rng.wrapBodyInlineWithPara(); // finding paragraph4254
4255var splitRoot = dom.ancestor(rng.sc, dom.isPara);4256var nextPara; // on paragraph: split paragraph4257
4258if (splitRoot) {4259// if it is an empty line with li4260if (dom.isLi(splitRoot) && (dom.isEmpty(splitRoot) || dom.deepestChildIsEmpty(splitRoot))) {4261// toggle UL/OL and escape4262this.bullet.toggleList(splitRoot.parentNode.nodeName);4263return;4264} else {4265var blockquote = null;4266
4267if (this.options.blockquoteBreakingLevel === 1) {4268blockquote = dom.ancestor(splitRoot, dom.isBlockquote);4269} else if (this.options.blockquoteBreakingLevel === 2) {4270blockquote = dom.lastAncestor(splitRoot, dom.isBlockquote);4271}4272
4273if (blockquote) {4274// We're inside a blockquote and options ask us to break it4275nextPara = external_jQuery_default()(dom.emptyPara)[0]; // If the split is right before a <br>, remove it so that there's no "empty line"4276// after the split in the new blockquote created4277
4278if (dom.isRightEdgePoint(rng.getStartPoint()) && dom.isBR(rng.sc.nextSibling)) {4279external_jQuery_default()(rng.sc.nextSibling).remove();4280}4281
4282var split = dom.splitTree(blockquote, rng.getStartPoint(), {4283isDiscardEmptySplits: true4284});4285
4286if (split) {4287split.parentNode.insertBefore(nextPara, split);4288} else {4289dom.insertAfter(nextPara, blockquote); // There's no split if we were at the end of the blockquote4290}4291} else {4292nextPara = dom.splitTree(splitRoot, rng.getStartPoint()); // not a blockquote, just insert the paragraph4293
4294var emptyAnchors = dom.listDescendant(splitRoot, dom.isEmptyAnchor);4295emptyAnchors = emptyAnchors.concat(dom.listDescendant(nextPara, dom.isEmptyAnchor));4296external_jQuery_default().each(emptyAnchors, function (idx, anchor) {4297dom.remove(anchor);4298}); // replace empty heading, pre or custom-made styleTag with P tag4299
4300if ((dom.isHeading(nextPara) || dom.isPre(nextPara) || dom.isCustomStyleTag(nextPara)) && dom.isEmpty(nextPara)) {4301nextPara = dom.replace(nextPara, 'p');4302}4303}4304} // no paragraph: insert empty paragraph4305
4306} else {4307var next = rng.sc.childNodes[rng.so];4308nextPara = external_jQuery_default()(dom.emptyPara)[0];4309
4310if (next) {4311rng.sc.insertBefore(nextPara, next);4312} else {4313rng.sc.appendChild(nextPara);4314}4315}4316
4317range.create(nextPara, 0).normalize().select().scrollIntoView(editable);4318}4319}]);4320
4321return Typing;4322}();4323
4324
4325;// CONCATENATED MODULE: ./src/js/editing/Table.js4326function Table_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }4327
4328function Table_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); } }4329
4330function Table_createClass(Constructor, protoProps, staticProps) { if (protoProps) Table_defineProperties(Constructor.prototype, protoProps); if (staticProps) Table_defineProperties(Constructor, staticProps); return Constructor; }4331
4332
4333
4334
4335
4336/**
4337* @class Create a virtual table to create what actions to do in change.
4338* @param {object} startPoint Cell selected to apply change.
4339* @param {enum} where Where change will be applied Row or Col. Use enum: TableResultAction.where
4340* @param {enum} action Action to be applied. Use enum: TableResultAction.requestAction
4341* @param {object} domTable Dom element of table to make changes.
4342*/
4343
4344var TableResultAction = function TableResultAction(startPoint, where, action, domTable) {4345var _startPoint = {4346'colPos': 0,4347'rowPos': 04348};4349var _virtualTable = [];4350var _actionCellList = []; /// ///////////////////////////////////////////4351// Private functions4352/// ///////////////////////////////////////////4353
4354/**4355* Set the startPoint of action.
4356*/
4357
4358function setStartPoint() {4359if (!startPoint || !startPoint.tagName || startPoint.tagName.toLowerCase() !== 'td' && startPoint.tagName.toLowerCase() !== 'th') {4360// Impossible to identify start Cell point4361return;4362}4363
4364_startPoint.colPos = startPoint.cellIndex;4365
4366if (!startPoint.parentElement || !startPoint.parentElement.tagName || startPoint.parentElement.tagName.toLowerCase() !== 'tr') {4367// Impossible to identify start Row point4368return;4369}4370
4371_startPoint.rowPos = startPoint.parentElement.rowIndex;4372}4373/**4374* Define virtual table position info object.
4375*
4376* @param {int} rowIndex Index position in line of virtual table.
4377* @param {int} cellIndex Index position in column of virtual table.
4378* @param {object} baseRow Row affected by this position.
4379* @param {object} baseCell Cell affected by this position.
4380* @param {bool} isSpan Inform if it is an span cell/row.
4381*/
4382
4383
4384function setVirtualTablePosition(rowIndex, cellIndex, baseRow, baseCell, isRowSpan, isColSpan, isVirtualCell) {4385var objPosition = {4386'baseRow': baseRow,4387'baseCell': baseCell,4388'isRowSpan': isRowSpan,4389'isColSpan': isColSpan,4390'isVirtual': isVirtualCell4391};4392
4393if (!_virtualTable[rowIndex]) {4394_virtualTable[rowIndex] = [];4395}4396
4397_virtualTable[rowIndex][cellIndex] = objPosition;4398}4399/**4400* Create action cell object.
4401*
4402* @param {object} virtualTableCellObj Object of specific position on virtual table.
4403* @param {enum} resultAction Action to be applied in that item.
4404*/
4405
4406
4407function getActionCell(virtualTableCellObj, resultAction, virtualRowPosition, virtualColPosition) {4408return {4409'baseCell': virtualTableCellObj.baseCell,4410'action': resultAction,4411'virtualTable': {4412'rowIndex': virtualRowPosition,4413'cellIndex': virtualColPosition4414}4415};4416}4417/**4418* Recover free index of row to append Cell.
4419*
4420* @param {int} rowIndex Index of row to find free space.
4421* @param {int} cellIndex Index of cell to find free space in table.
4422*/
4423
4424
4425function recoverCellIndex(rowIndex, cellIndex) {4426if (!_virtualTable[rowIndex]) {4427return cellIndex;4428}4429
4430if (!_virtualTable[rowIndex][cellIndex]) {4431return cellIndex;4432}4433
4434var newCellIndex = cellIndex;4435
4436while (_virtualTable[rowIndex][newCellIndex]) {4437newCellIndex++;4438
4439if (!_virtualTable[rowIndex][newCellIndex]) {4440return newCellIndex;4441}4442}4443}4444/**4445* Recover info about row and cell and add information to virtual table.
4446*
4447* @param {object} row Row to recover information.
4448* @param {object} cell Cell to recover information.
4449*/
4450
4451
4452function addCellInfoToVirtual(row, cell) {4453var cellIndex = recoverCellIndex(row.rowIndex, cell.cellIndex);4454var cellHasColspan = cell.colSpan > 1;4455var cellHasRowspan = cell.rowSpan > 1;4456var isThisSelectedCell = row.rowIndex === _startPoint.rowPos && cell.cellIndex === _startPoint.colPos;4457setVirtualTablePosition(row.rowIndex, cellIndex, row, cell, cellHasRowspan, cellHasColspan, false); // Add span rows to virtual Table.4458
4459var rowspanNumber = cell.attributes.rowSpan ? parseInt(cell.attributes.rowSpan.value, 10) : 0;4460
4461if (rowspanNumber > 1) {4462for (var rp = 1; rp < rowspanNumber; rp++) {4463var rowspanIndex = row.rowIndex + rp;4464adjustStartPoint(rowspanIndex, cellIndex, cell, isThisSelectedCell);4465setVirtualTablePosition(rowspanIndex, cellIndex, row, cell, true, cellHasColspan, true);4466}4467} // Add span cols to virtual table.4468
4469
4470var colspanNumber = cell.attributes.colSpan ? parseInt(cell.attributes.colSpan.value, 10) : 0;4471
4472if (colspanNumber > 1) {4473for (var cp = 1; cp < colspanNumber; cp++) {4474var cellspanIndex = recoverCellIndex(row.rowIndex, cellIndex + cp);4475adjustStartPoint(row.rowIndex, cellspanIndex, cell, isThisSelectedCell);4476setVirtualTablePosition(row.rowIndex, cellspanIndex, row, cell, cellHasRowspan, true, true);4477}4478}4479}4480/**4481* Process validation and adjust of start point if needed
4482*
4483* @param {int} rowIndex
4484* @param {int} cellIndex
4485* @param {object} cell
4486* @param {bool} isSelectedCell
4487*/
4488
4489
4490function adjustStartPoint(rowIndex, cellIndex, cell, isSelectedCell) {4491if (rowIndex === _startPoint.rowPos && _startPoint.colPos >= cell.cellIndex && cell.cellIndex <= cellIndex && !isSelectedCell) {4492_startPoint.colPos++;4493}4494}4495/**4496* Create virtual table of cells with all cells, including span cells.
4497*/
4498
4499
4500function createVirtualTable() {4501var rows = domTable.rows;4502
4503for (var rowIndex = 0; rowIndex < rows.length; rowIndex++) {4504var cells = rows[rowIndex].cells;4505
4506for (var cellIndex = 0; cellIndex < cells.length; cellIndex++) {4507addCellInfoToVirtual(rows[rowIndex], cells[cellIndex]);4508}4509}4510}4511/**4512* Get action to be applied on the cell.
4513*
4514* @param {object} cell virtual table cell to apply action
4515*/
4516
4517
4518function getDeleteResultActionToCell(cell) {4519switch (where) {4520case TableResultAction.where.Column:4521if (cell.isColSpan) {4522return TableResultAction.resultAction.SubtractSpanCount;4523}4524
4525break;4526
4527case TableResultAction.where.Row:4528if (!cell.isVirtual && cell.isRowSpan) {4529return TableResultAction.resultAction.AddCell;4530} else if (cell.isRowSpan) {4531return TableResultAction.resultAction.SubtractSpanCount;4532}4533
4534break;4535}4536
4537return TableResultAction.resultAction.RemoveCell;4538}4539/**4540* Get action to be applied on the cell.
4541*
4542* @param {object} cell virtual table cell to apply action
4543*/
4544
4545
4546function getAddResultActionToCell(cell) {4547switch (where) {4548case TableResultAction.where.Column:4549if (cell.isColSpan) {4550return TableResultAction.resultAction.SumSpanCount;4551} else if (cell.isRowSpan && cell.isVirtual) {4552return TableResultAction.resultAction.Ignore;4553}4554
4555break;4556
4557case TableResultAction.where.Row:4558if (cell.isRowSpan) {4559return TableResultAction.resultAction.SumSpanCount;4560} else if (cell.isColSpan && cell.isVirtual) {4561return TableResultAction.resultAction.Ignore;4562}4563
4564break;4565}4566
4567return TableResultAction.resultAction.AddCell;4568}4569
4570function init() {4571setStartPoint();4572createVirtualTable();4573} /// ///////////////////////////////////////////4574// Public functions4575/// ///////////////////////////////////////////4576
4577/**4578* Recover array os what to do in table.
4579*/
4580
4581
4582this.getActionList = function () {4583var fixedRow = where === TableResultAction.where.Row ? _startPoint.rowPos : -1;4584var fixedCol = where === TableResultAction.where.Column ? _startPoint.colPos : -1;4585var actualPosition = 0;4586var canContinue = true;4587
4588while (canContinue) {4589var rowPosition = fixedRow >= 0 ? fixedRow : actualPosition;4590var colPosition = fixedCol >= 0 ? fixedCol : actualPosition;4591var row = _virtualTable[rowPosition];4592
4593if (!row) {4594canContinue = false;4595return _actionCellList;4596}4597
4598var cell = row[colPosition];4599
4600if (!cell) {4601canContinue = false;4602return _actionCellList;4603} // Define action to be applied in this cell4604
4605
4606var resultAction = TableResultAction.resultAction.Ignore;4607
4608switch (action) {4609case TableResultAction.requestAction.Add:4610resultAction = getAddResultActionToCell(cell);4611break;4612
4613case TableResultAction.requestAction.Delete:4614resultAction = getDeleteResultActionToCell(cell);4615break;4616}4617
4618_actionCellList.push(getActionCell(cell, resultAction, rowPosition, colPosition));4619
4620actualPosition++;4621}4622
4623return _actionCellList;4624};4625
4626init();4627};4628/**
4629*
4630* Where action occours enum.
4631*/
4632
4633
4634TableResultAction.where = {4635'Row': 0,4636'Column': 14637};4638/**
4639*
4640* Requested action to apply enum.
4641*/
4642
4643TableResultAction.requestAction = {4644'Add': 0,4645'Delete': 14646};4647/**
4648*
4649* Result action to be executed enum.
4650*/
4651
4652TableResultAction.resultAction = {4653'Ignore': 0,4654'SubtractSpanCount': 1,4655'RemoveCell': 2,4656'AddCell': 3,4657'SumSpanCount': 44658};4659/**
4660*
4661* @class editing.Table
4662*
4663* Table
4664*
4665*/
4666
4667var Table = /*#__PURE__*/function () {4668function Table() {4669Table_classCallCheck(this, Table);4670}4671
4672Table_createClass(Table, [{4673key: "tab",4674value:4675/**4676* handle tab key
4677*
4678* @param {WrappedRange} rng
4679* @param {Boolean} isShift
4680*/
4681function tab(rng, isShift) {4682var cell = dom.ancestor(rng.commonAncestor(), dom.isCell);4683var table = dom.ancestor(cell, dom.isTable);4684var cells = dom.listDescendant(table, dom.isCell);4685var nextCell = lists[isShift ? 'prev' : 'next'](cells, cell);4686
4687if (nextCell) {4688range.create(nextCell, 0).select();4689}4690}4691/**4692* Add a new row
4693*
4694* @param {WrappedRange} rng
4695* @param {String} position (top/bottom)
4696* @return {Node}
4697*/
4698
4699}, {4700key: "addRow",4701value: function addRow(rng, position) {4702var cell = dom.ancestor(rng.commonAncestor(), dom.isCell);4703var currentTr = external_jQuery_default()(cell).closest('tr');4704var trAttributes = this.recoverAttributes(currentTr);4705var html = external_jQuery_default()('<tr' + trAttributes + '></tr>');4706var vTable = new TableResultAction(cell, TableResultAction.where.Row, TableResultAction.requestAction.Add, external_jQuery_default()(currentTr).closest('table')[0]);4707var actions = vTable.getActionList();4708
4709for (var idCell = 0; idCell < actions.length; idCell++) {4710var currentCell = actions[idCell];4711var tdAttributes = this.recoverAttributes(currentCell.baseCell);4712
4713switch (currentCell.action) {4714case TableResultAction.resultAction.AddCell:4715html.append('<td' + tdAttributes + '>' + dom.blank + '</td>');4716break;4717
4718case TableResultAction.resultAction.SumSpanCount:4719{4720if (position === 'top') {4721var baseCellTr = currentCell.baseCell.parent;4722var isTopFromRowSpan = (!baseCellTr ? 0 : currentCell.baseCell.closest('tr').rowIndex) <= currentTr[0].rowIndex;4723
4724if (isTopFromRowSpan) {4725var newTd = external_jQuery_default()('<div></div>').append(external_jQuery_default()('<td' + tdAttributes + '>' + dom.blank + '</td>').removeAttr('rowspan')).html();4726html.append(newTd);4727break;4728}4729}4730
4731var rowspanNumber = parseInt(currentCell.baseCell.rowSpan, 10);4732rowspanNumber++;4733currentCell.baseCell.setAttribute('rowSpan', rowspanNumber);4734}4735break;4736}4737}4738
4739if (position === 'top') {4740currentTr.before(html);4741} else {4742var cellHasRowspan = cell.rowSpan > 1;4743
4744if (cellHasRowspan) {4745var lastTrIndex = currentTr[0].rowIndex + (cell.rowSpan - 2);4746external_jQuery_default()(external_jQuery_default()(currentTr).parent().find('tr')[lastTrIndex]).after(external_jQuery_default()(html));4747return;4748}4749
4750currentTr.after(html);4751}4752}4753/**4754* Add a new col
4755*
4756* @param {WrappedRange} rng
4757* @param {String} position (left/right)
4758* @return {Node}
4759*/
4760
4761}, {4762key: "addCol",4763value: function addCol(rng, position) {4764var cell = dom.ancestor(rng.commonAncestor(), dom.isCell);4765var row = external_jQuery_default()(cell).closest('tr');4766var rowsGroup = external_jQuery_default()(row).siblings();4767rowsGroup.push(row);4768var vTable = new TableResultAction(cell, TableResultAction.where.Column, TableResultAction.requestAction.Add, external_jQuery_default()(row).closest('table')[0]);4769var actions = vTable.getActionList();4770
4771for (var actionIndex = 0; actionIndex < actions.length; actionIndex++) {4772var currentCell = actions[actionIndex];4773var tdAttributes = this.recoverAttributes(currentCell.baseCell);4774
4775switch (currentCell.action) {4776case TableResultAction.resultAction.AddCell:4777if (position === 'right') {4778external_jQuery_default()(currentCell.baseCell).after('<td' + tdAttributes + '>' + dom.blank + '</td>');4779} else {4780external_jQuery_default()(currentCell.baseCell).before('<td' + tdAttributes + '>' + dom.blank + '</td>');4781}4782
4783break;4784
4785case TableResultAction.resultAction.SumSpanCount:4786if (position === 'right') {4787var colspanNumber = parseInt(currentCell.baseCell.colSpan, 10);4788colspanNumber++;4789currentCell.baseCell.setAttribute('colSpan', colspanNumber);4790} else {4791external_jQuery_default()(currentCell.baseCell).before('<td' + tdAttributes + '>' + dom.blank + '</td>');4792}4793
4794break;4795}4796}4797}4798/*4799* Copy attributes from element.
4800*
4801* @param {object} Element to recover attributes.
4802* @return {string} Copied string elements.
4803*/
4804
4805}, {4806key: "recoverAttributes",4807value: function recoverAttributes(el) {4808var resultStr = '';4809
4810if (!el) {4811return resultStr;4812}4813
4814var attrList = el.attributes || [];4815
4816for (var i = 0; i < attrList.length; i++) {4817if (attrList[i].name.toLowerCase() === 'id') {4818continue;4819}4820
4821if (attrList[i].specified) {4822resultStr += ' ' + attrList[i].name + '=\'' + attrList[i].value + '\'';4823}4824}4825
4826return resultStr;4827}4828/**4829* Delete current row
4830*
4831* @param {WrappedRange} rng
4832* @return {Node}
4833*/
4834
4835}, {4836key: "deleteRow",4837value: function deleteRow(rng) {4838var cell = dom.ancestor(rng.commonAncestor(), dom.isCell);4839var row = external_jQuery_default()(cell).closest('tr');4840var cellPos = row.children('td, th').index(external_jQuery_default()(cell));4841var rowPos = row[0].rowIndex;4842var vTable = new TableResultAction(cell, TableResultAction.where.Row, TableResultAction.requestAction.Delete, external_jQuery_default()(row).closest('table')[0]);4843var actions = vTable.getActionList();4844
4845for (var actionIndex = 0; actionIndex < actions.length; actionIndex++) {4846if (!actions[actionIndex]) {4847continue;4848}4849
4850var baseCell = actions[actionIndex].baseCell;4851var virtualPosition = actions[actionIndex].virtualTable;4852var hasRowspan = baseCell.rowSpan && baseCell.rowSpan > 1;4853var rowspanNumber = hasRowspan ? parseInt(baseCell.rowSpan, 10) : 0;4854
4855switch (actions[actionIndex].action) {4856case TableResultAction.resultAction.Ignore:4857continue;4858
4859case TableResultAction.resultAction.AddCell:4860{4861var nextRow = row.next('tr')[0];4862
4863if (!nextRow) {4864continue;4865}4866
4867var cloneRow = row[0].cells[cellPos];4868
4869if (hasRowspan) {4870if (rowspanNumber > 2) {4871rowspanNumber--;4872nextRow.insertBefore(cloneRow, nextRow.cells[cellPos]);4873nextRow.cells[cellPos].setAttribute('rowSpan', rowspanNumber);4874nextRow.cells[cellPos].innerHTML = '';4875} else if (rowspanNumber === 2) {4876nextRow.insertBefore(cloneRow, nextRow.cells[cellPos]);4877nextRow.cells[cellPos].removeAttribute('rowSpan');4878nextRow.cells[cellPos].innerHTML = '';4879}4880}4881}4882continue;4883
4884case TableResultAction.resultAction.SubtractSpanCount:4885if (hasRowspan) {4886if (rowspanNumber > 2) {4887rowspanNumber--;4888baseCell.setAttribute('rowSpan', rowspanNumber);4889
4890if (virtualPosition.rowIndex !== rowPos && baseCell.cellIndex === cellPos) {4891baseCell.innerHTML = '';4892}4893} else if (rowspanNumber === 2) {4894baseCell.removeAttribute('rowSpan');4895
4896if (virtualPosition.rowIndex !== rowPos && baseCell.cellIndex === cellPos) {4897baseCell.innerHTML = '';4898}4899}4900}4901
4902continue;4903
4904case TableResultAction.resultAction.RemoveCell:4905// Do not need remove cell because row will be deleted.4906continue;4907}4908}4909
4910row.remove();4911}4912/**4913* Delete current col
4914*
4915* @param {WrappedRange} rng
4916* @return {Node}
4917*/
4918
4919}, {4920key: "deleteCol",4921value: function deleteCol(rng) {4922var cell = dom.ancestor(rng.commonAncestor(), dom.isCell);4923var row = external_jQuery_default()(cell).closest('tr');4924var cellPos = row.children('td, th').index(external_jQuery_default()(cell));4925var vTable = new TableResultAction(cell, TableResultAction.where.Column, TableResultAction.requestAction.Delete, external_jQuery_default()(row).closest('table')[0]);4926var actions = vTable.getActionList();4927
4928for (var actionIndex = 0; actionIndex < actions.length; actionIndex++) {4929if (!actions[actionIndex]) {4930continue;4931}4932
4933switch (actions[actionIndex].action) {4934case TableResultAction.resultAction.Ignore:4935continue;4936
4937case TableResultAction.resultAction.SubtractSpanCount:4938{4939var baseCell = actions[actionIndex].baseCell;4940var hasColspan = baseCell.colSpan && baseCell.colSpan > 1;4941
4942if (hasColspan) {4943var colspanNumber = baseCell.colSpan ? parseInt(baseCell.colSpan, 10) : 0;4944
4945if (colspanNumber > 2) {4946colspanNumber--;4947baseCell.setAttribute('colSpan', colspanNumber);4948
4949if (baseCell.cellIndex === cellPos) {4950baseCell.innerHTML = '';4951}4952} else if (colspanNumber === 2) {4953baseCell.removeAttribute('colSpan');4954
4955if (baseCell.cellIndex === cellPos) {4956baseCell.innerHTML = '';4957}4958}4959}4960}4961continue;4962
4963case TableResultAction.resultAction.RemoveCell:4964dom.remove(actions[actionIndex].baseCell, true);4965continue;4966}4967}4968}4969/**4970* create empty table element
4971*
4972* @param {Number} rowCount
4973* @param {Number} colCount
4974* @return {Node}
4975*/
4976
4977}, {4978key: "createTable",4979value: function createTable(colCount, rowCount, options) {4980var tds = [];4981var tdHTML;4982
4983for (var idxCol = 0; idxCol < colCount; idxCol++) {4984tds.push('<td>' + dom.blank + '</td>');4985}4986
4987tdHTML = tds.join('');4988var trs = [];4989var trHTML;4990
4991for (var idxRow = 0; idxRow < rowCount; idxRow++) {4992trs.push('<tr>' + tdHTML + '</tr>');4993}4994
4995trHTML = trs.join('');4996var $table = external_jQuery_default()('<table>' + trHTML + '</table>');4997
4998if (options && options.tableClassName) {4999$table.addClass(options.tableClassName);5000}5001
5002return $table[0];5003}5004/**5005* Delete current table
5006*
5007* @param {WrappedRange} rng
5008* @return {Node}
5009*/
5010
5011}, {5012key: "deleteTable",5013value: function deleteTable(rng) {5014var cell = dom.ancestor(rng.commonAncestor(), dom.isCell);5015external_jQuery_default()(cell).closest('table').remove();5016}5017}]);5018
5019return Table;5020}();5021
5022
5023;// CONCATENATED MODULE: ./src/js/module/Editor.js5024function Editor_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }5025
5026function Editor_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); } }5027
5028function Editor_createClass(Constructor, protoProps, staticProps) { if (protoProps) Editor_defineProperties(Constructor.prototype, protoProps); if (staticProps) Editor_defineProperties(Constructor, staticProps); return Constructor; }5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043var KEY_BOGUS = 'bogus';5044/**
5045* @class Editor
5046*/
5047
5048var Editor = /*#__PURE__*/function () {5049function Editor(context) {5050var _this = this;5051
5052Editor_classCallCheck(this, Editor);5053
5054this.context = context;5055this.$note = context.layoutInfo.note;5056this.$editor = context.layoutInfo.editor;5057this.$editable = context.layoutInfo.editable;5058this.options = context.options;5059this.lang = this.options.langInfo;5060this.editable = this.$editable[0];5061this.lastRange = null;5062this.snapshot = null;5063this.style = new Style();5064this.table = new Table();5065this.typing = new Typing(context);5066this.bullet = new Bullet();5067this.history = new History(context);5068this.context.memo('help.escape', this.lang.help.escape);5069this.context.memo('help.undo', this.lang.help.undo);5070this.context.memo('help.redo', this.lang.help.redo);5071this.context.memo('help.tab', this.lang.help.tab);5072this.context.memo('help.untab', this.lang.help.untab);5073this.context.memo('help.insertParagraph', this.lang.help.insertParagraph);5074this.context.memo('help.insertOrderedList', this.lang.help.insertOrderedList);5075this.context.memo('help.insertUnorderedList', this.lang.help.insertUnorderedList);5076this.context.memo('help.indent', this.lang.help.indent);5077this.context.memo('help.outdent', this.lang.help.outdent);5078this.context.memo('help.formatPara', this.lang.help.formatPara);5079this.context.memo('help.insertHorizontalRule', this.lang.help.insertHorizontalRule);5080this.context.memo('help.fontName', this.lang.help.fontName); // native commands(with execCommand), generate function for execCommand5081
5082var commands = ['bold', 'italic', 'underline', 'strikethrough', 'superscript', 'subscript', 'justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull', 'formatBlock', 'removeFormat', 'backColor'];5083
5084for (var idx = 0, len = commands.length; idx < len; idx++) {5085this[commands[idx]] = function (sCmd) {5086return function (value) {5087_this.beforeCommand();5088
5089document.execCommand(sCmd, false, value);5090
5091_this.afterCommand(true);5092};5093}(commands[idx]);5094
5095this.context.memo('help.' + commands[idx], this.lang.help[commands[idx]]);5096}5097
5098this.fontName = this.wrapCommand(function (value) {5099return _this.fontStyling('font-family', env.validFontName(value));5100});5101this.fontSize = this.wrapCommand(function (value) {5102var unit = _this.currentStyle()['font-size-unit'];5103
5104return _this.fontStyling('font-size', value + unit);5105});5106this.fontSizeUnit = this.wrapCommand(function (value) {5107var size = _this.currentStyle()['font-size'];5108
5109return _this.fontStyling('font-size', size + value);5110});5111
5112for (var _idx = 1; _idx <= 6; _idx++) {5113this['formatH' + _idx] = function (idx) {5114return function () {5115_this.formatBlock('H' + idx);5116};5117}(_idx);5118
5119this.context.memo('help.formatH' + _idx, this.lang.help['formatH' + _idx]);5120}5121
5122this.insertParagraph = this.wrapCommand(function () {5123_this.typing.insertParagraph(_this.editable);5124});5125this.insertOrderedList = this.wrapCommand(function () {5126_this.bullet.insertOrderedList(_this.editable);5127});5128this.insertUnorderedList = this.wrapCommand(function () {5129_this.bullet.insertUnorderedList(_this.editable);5130});5131this.indent = this.wrapCommand(function () {5132_this.bullet.indent(_this.editable);5133});5134this.outdent = this.wrapCommand(function () {5135_this.bullet.outdent(_this.editable);5136});5137/**5138* insertNode
5139* insert node
5140* @param {Node} node
5141*/
5142
5143this.insertNode = this.wrapCommand(function (node) {5144if (_this.isLimited(external_jQuery_default()(node).text().length)) {5145return;5146}5147
5148var rng = _this.getLastRange();5149
5150rng.insertNode(node);5151
5152_this.setLastRange(range.createFromNodeAfter(node).select());5153});5154/**5155* insert text
5156* @param {String} text
5157*/
5158
5159this.insertText = this.wrapCommand(function (text) {5160if (_this.isLimited(text.length)) {5161return;5162}5163
5164var rng = _this.getLastRange();5165
5166var textNode = rng.insertNode(dom.createText(text));5167
5168_this.setLastRange(range.create(textNode, dom.nodeLength(textNode)).select());5169});5170/**5171* paste HTML
5172* @param {String} markup
5173*/
5174
5175this.pasteHTML = this.wrapCommand(function (markup) {5176if (_this.isLimited(markup.length)) {5177return;5178}5179
5180markup = _this.context.invoke('codeview.purify', markup);5181
5182var contents = _this.getLastRange().pasteHTML(markup);5183
5184_this.setLastRange(range.createFromNodeAfter(lists.last(contents)).select());5185});5186/**5187* formatBlock
5188*
5189* @param {String} tagName
5190*/
5191
5192this.formatBlock = this.wrapCommand(function (tagName, $target) {5193var onApplyCustomStyle = _this.options.callbacks.onApplyCustomStyle;5194
5195if (onApplyCustomStyle) {5196onApplyCustomStyle.call(_this, $target, _this.context, _this.onFormatBlock);5197} else {5198_this.onFormatBlock(tagName, $target);5199}5200});5201/**5202* insert horizontal rule
5203*/
5204
5205this.insertHorizontalRule = this.wrapCommand(function () {5206var hrNode = _this.getLastRange().insertNode(dom.create('HR'));5207
5208if (hrNode.nextSibling) {5209_this.setLastRange(range.create(hrNode.nextSibling, 0).normalize().select());5210}5211});5212/**5213* lineHeight
5214* @param {String} value
5215*/
5216
5217this.lineHeight = this.wrapCommand(function (value) {5218_this.style.stylePara(_this.getLastRange(), {5219lineHeight: value5220});5221});5222/**5223* create link (command)
5224*
5225* @param {Object} linkInfo
5226*/
5227
5228this.createLink = this.wrapCommand(function (linkInfo) {5229var linkUrl = linkInfo.url;5230var linkText = linkInfo.text;5231var isNewWindow = linkInfo.isNewWindow;5232var checkProtocol = linkInfo.checkProtocol;5233
5234var rng = linkInfo.range || _this.getLastRange();5235
5236var additionalTextLength = linkText.length - rng.toString().length;5237
5238if (additionalTextLength > 0 && _this.isLimited(additionalTextLength)) {5239return;5240}5241
5242var isTextChanged = rng.toString() !== linkText; // handle spaced urls from input5243
5244if (typeof linkUrl === 'string') {5245linkUrl = linkUrl.trim();5246}5247
5248if (_this.options.onCreateLink) {5249linkUrl = _this.options.onCreateLink(linkUrl);5250} else if (checkProtocol) {5251// if url doesn't have any protocol and not even a relative or a label, use http:// as default5252linkUrl = /^([A-Za-z][A-Za-z0-9+-.]*\:|#|\/)/.test(linkUrl) ? linkUrl : _this.options.defaultProtocol + linkUrl;5253}5254
5255var anchors = [];5256
5257if (isTextChanged) {5258rng = rng.deleteContents();5259var anchor = rng.insertNode(external_jQuery_default()('<A>' + linkText + '</A>')[0]);5260anchors.push(anchor);5261} else {5262anchors = _this.style.styleNodes(rng, {5263nodeName: 'A',5264expandClosestSibling: true,5265onlyPartialContains: true5266});5267}5268
5269external_jQuery_default().each(anchors, function (idx, anchor) {5270external_jQuery_default()(anchor).attr('href', linkUrl);5271
5272if (isNewWindow) {5273external_jQuery_default()(anchor).attr('target', '_blank');5274} else {5275external_jQuery_default()(anchor).removeAttr('target');5276}5277});5278
5279_this.setLastRange(_this.createRangeFromList(anchors).select());5280});5281/**5282* setting color
5283*
5284* @param {Object} sObjColor color code
5285* @param {String} sObjColor.foreColor foreground color
5286* @param {String} sObjColor.backColor background color
5287*/
5288
5289this.color = this.wrapCommand(function (colorInfo) {5290var foreColor = colorInfo.foreColor;5291var backColor = colorInfo.backColor;5292
5293if (foreColor) {5294document.execCommand('foreColor', false, foreColor);5295}5296
5297if (backColor) {5298document.execCommand('backColor', false, backColor);5299}5300});5301/**5302* Set foreground color
5303*
5304* @param {String} colorCode foreground color code
5305*/
5306
5307this.foreColor = this.wrapCommand(function (colorInfo) {5308document.execCommand('foreColor', false, colorInfo);5309});5310/**5311* insert Table
5312*
5313* @param {String} dimension of table (ex : "5x5")
5314*/
5315
5316this.insertTable = this.wrapCommand(function (dim) {5317var dimension = dim.split('x');5318
5319var rng = _this.getLastRange().deleteContents();5320
5321rng.insertNode(_this.table.createTable(dimension[0], dimension[1], _this.options));5322});5323/**5324* remove media object and Figure Elements if media object is img with Figure.
5325*/
5326
5327this.removeMedia = this.wrapCommand(function () {5328var $target = external_jQuery_default()(_this.restoreTarget()).parent();5329
5330if ($target.closest('figure').length) {5331$target.closest('figure').remove();5332} else {5333$target = external_jQuery_default()(_this.restoreTarget()).detach();5334}5335
5336_this.context.triggerEvent('media.delete', $target, _this.$editable);5337});5338/**5339* float me
5340*
5341* @param {String} value
5342*/
5343
5344this.floatMe = this.wrapCommand(function (value) {5345var $target = external_jQuery_default()(_this.restoreTarget());5346$target.toggleClass('note-float-left', value === 'left');5347$target.toggleClass('note-float-right', value === 'right');5348$target.css('float', value === 'none' ? '' : value);5349});5350/**5351* resize overlay element
5352* @param {String} value
5353*/
5354
5355this.resize = this.wrapCommand(function (value) {5356var $target = external_jQuery_default()(_this.restoreTarget());5357value = parseFloat(value);5358
5359if (value === 0) {5360$target.css('width', '');5361} else {5362$target.css({5363width: value * 100 + '%',5364height: ''5365});5366}5367});5368}5369
5370Editor_createClass(Editor, [{5371key: "initialize",5372value: function initialize() {5373var _this2 = this;5374
5375// bind custom events5376this.$editable.on('keydown', function (event) {5377if (event.keyCode === key.code.ENTER) {5378_this2.context.triggerEvent('enter', event);5379}5380
5381_this2.context.triggerEvent('keydown', event); // keep a snapshot to limit text on input event5382
5383
5384_this2.snapshot = _this2.history.makeSnapshot();5385_this2.hasKeyShortCut = false;5386
5387if (!event.isDefaultPrevented()) {5388if (_this2.options.shortcuts) {5389_this2.hasKeyShortCut = _this2.handleKeyMap(event);5390} else {5391_this2.preventDefaultEditableShortCuts(event);5392}5393}5394
5395if (_this2.isLimited(1, event)) {5396var lastRange = _this2.getLastRange();5397
5398if (lastRange.eo - lastRange.so === 0) {5399return false;5400}5401}5402
5403_this2.setLastRange(); // record undo in the key event except keyMap.5404
5405
5406if (_this2.options.recordEveryKeystroke) {5407if (_this2.hasKeyShortCut === false) {5408_this2.history.recordUndo();5409}5410}5411}).on('keyup', function (event) {5412_this2.setLastRange();5413
5414_this2.context.triggerEvent('keyup', event);5415}).on('focus', function (event) {5416_this2.setLastRange();5417
5418_this2.context.triggerEvent('focus', event);5419}).on('blur', function (event) {5420_this2.context.triggerEvent('blur', event);5421}).on('mousedown', function (event) {5422_this2.context.triggerEvent('mousedown', event);5423}).on('mouseup', function (event) {5424_this2.setLastRange();5425
5426_this2.history.recordUndo();5427
5428_this2.context.triggerEvent('mouseup', event);5429}).on('scroll', function (event) {5430_this2.context.triggerEvent('scroll', event);5431}).on('paste', function (event) {5432_this2.setLastRange();5433
5434_this2.context.triggerEvent('paste', event);5435}).on('input', function () {5436// To limit composition characters (e.g. Korean)5437if (_this2.isLimited(0) && _this2.snapshot) {5438_this2.history.applySnapshot(_this2.snapshot);5439}5440});5441this.$editable.attr('spellcheck', this.options.spellCheck);5442this.$editable.attr('autocorrect', this.options.spellCheck);5443
5444if (this.options.disableGrammar) {5445this.$editable.attr('data-gramm', false);5446} // init content before set event5447
5448
5449this.$editable.html(dom.html(this.$note) || dom.emptyPara);5450this.$editable.on(env.inputEventName, func.debounce(function () {5451_this2.context.triggerEvent('change', _this2.$editable.html(), _this2.$editable);5452}, 10));5453this.$editable.on('focusin', function (event) {5454_this2.context.triggerEvent('focusin', event);5455}).on('focusout', function (event) {5456_this2.context.triggerEvent('focusout', event);5457});5458
5459if (this.options.airMode) {5460if (this.options.overrideContextMenu) {5461this.$editor.on('contextmenu', function (event) {5462_this2.context.triggerEvent('contextmenu', event);5463
5464return false;5465});5466}5467} else {5468if (this.options.width) {5469this.$editor.outerWidth(this.options.width);5470}5471
5472if (this.options.height) {5473this.$editable.outerHeight(this.options.height);5474}5475
5476if (this.options.maxHeight) {5477this.$editable.css('max-height', this.options.maxHeight);5478}5479
5480if (this.options.minHeight) {5481this.$editable.css('min-height', this.options.minHeight);5482}5483}5484
5485this.history.recordUndo();5486this.setLastRange();5487}5488}, {5489key: "destroy",5490value: function destroy() {5491this.$editable.off();5492}5493}, {5494key: "handleKeyMap",5495value: function handleKeyMap(event) {5496var keyMap = this.options.keyMap[env.isMac ? 'mac' : 'pc'];5497var keys = [];5498
5499if (event.metaKey) {5500keys.push('CMD');5501}5502
5503if (event.ctrlKey && !event.altKey) {5504keys.push('CTRL');5505}5506
5507if (event.shiftKey) {5508keys.push('SHIFT');5509}5510
5511var keyName = key.nameFromCode[event.keyCode];5512
5513if (keyName) {5514keys.push(keyName);5515}5516
5517var eventName = keyMap[keys.join('+')];5518
5519if (keyName === 'TAB' && !this.options.tabDisable) {5520this.afterCommand();5521} else if (eventName) {5522if (this.context.invoke(eventName) !== false) {5523event.preventDefault(); // if keyMap action was invoked5524
5525return true;5526}5527} else if (key.isEdit(event.keyCode)) {5528this.afterCommand();5529}5530
5531return false;5532}5533}, {5534key: "preventDefaultEditableShortCuts",5535value: function preventDefaultEditableShortCuts(event) {5536// B(Bold, 66) / I(Italic, 73) / U(Underline, 85)5537if ((event.ctrlKey || event.metaKey) && lists.contains([66, 73, 85], event.keyCode)) {5538event.preventDefault();5539}5540}5541}, {5542key: "isLimited",5543value: function isLimited(pad, event) {5544pad = pad || 0;5545
5546if (typeof event !== 'undefined') {5547if (key.isMove(event.keyCode) || key.isNavigation(event.keyCode) || event.ctrlKey || event.metaKey || lists.contains([key.code.BACKSPACE, key.code.DELETE], event.keyCode)) {5548return false;5549}5550}5551
5552if (this.options.maxTextLength > 0) {5553if (this.$editable.text().length + pad > this.options.maxTextLength) {5554return true;5555}5556}5557
5558return false;5559}5560/**5561* create range
5562* @return {WrappedRange}
5563*/
5564
5565}, {5566key: "createRange",5567value: function createRange() {5568this.focus();5569this.setLastRange();5570return this.getLastRange();5571}5572/**5573* create a new range from the list of elements
5574*
5575* @param {list} dom element list
5576* @return {WrappedRange}
5577*/
5578
5579}, {5580key: "createRangeFromList",5581value: function createRangeFromList(lst) {5582var startRange = range.createFromNodeBefore(lists.head(lst));5583var startPoint = startRange.getStartPoint();5584var endRange = range.createFromNodeAfter(lists.last(lst));5585var endPoint = endRange.getEndPoint();5586return range.create(startPoint.node, startPoint.offset, endPoint.node, endPoint.offset);5587}5588/**5589* set the last range
5590*
5591* if given rng is exist, set rng as the last range
5592* or create a new range at the end of the document
5593*
5594* @param {WrappedRange} rng
5595*/
5596
5597}, {5598key: "setLastRange",5599value: function setLastRange(rng) {5600if (rng) {5601this.lastRange = rng;5602} else {5603this.lastRange = range.create(this.editable);5604
5605if (external_jQuery_default()(this.lastRange.sc).closest('.note-editable').length === 0) {5606this.lastRange = range.createFromBodyElement(this.editable);5607}5608}5609}5610/**5611* get the last range
5612*
5613* if there is a saved last range, return it
5614* or create a new range and return it
5615*
5616* @return {WrappedRange}
5617*/
5618
5619}, {5620key: "getLastRange",5621value: function getLastRange() {5622if (!this.lastRange) {5623this.setLastRange();5624}5625
5626return this.lastRange;5627}5628/**5629* saveRange
5630*
5631* save current range
5632*
5633* @param {Boolean} [thenCollapse=false]
5634*/
5635
5636}, {5637key: "saveRange",5638value: function saveRange(thenCollapse) {5639if (thenCollapse) {5640this.getLastRange().collapse().select();5641}5642}5643/**5644* restoreRange
5645*
5646* restore lately range
5647*/
5648
5649}, {5650key: "restoreRange",5651value: function restoreRange() {5652if (this.lastRange) {5653this.lastRange.select();5654this.focus();5655}5656}5657}, {5658key: "saveTarget",5659value: function saveTarget(node) {5660this.$editable.data('target', node);5661}5662}, {5663key: "clearTarget",5664value: function clearTarget() {5665this.$editable.removeData('target');5666}5667}, {5668key: "restoreTarget",5669value: function restoreTarget() {5670return this.$editable.data('target');5671}5672/**5673* currentStyle
5674*
5675* current style
5676* @return {Object|Boolean} unfocus
5677*/
5678
5679}, {5680key: "currentStyle",5681value: function currentStyle() {5682var rng = range.create();5683
5684if (rng) {5685rng = rng.normalize();5686}5687
5688return rng ? this.style.current(rng) : this.style.fromNode(this.$editable);5689}5690/**5691* style from node
5692*
5693* @param {jQuery} $node
5694* @return {Object}
5695*/
5696
5697}, {5698key: "styleFromNode",5699value: function styleFromNode($node) {5700return this.style.fromNode($node);5701}5702/**5703* undo
5704*/
5705
5706}, {5707key: "undo",5708value: function undo() {5709this.context.triggerEvent('before.command', this.$editable.html());5710this.history.undo();5711this.context.triggerEvent('change', this.$editable.html(), this.$editable);5712}5713/*5714* commit
5715*/
5716
5717}, {5718key: "commit",5719value: function commit() {5720this.context.triggerEvent('before.command', this.$editable.html());5721this.history.commit();5722this.context.triggerEvent('change', this.$editable.html(), this.$editable);5723}5724/**5725* redo
5726*/
5727
5728}, {5729key: "redo",5730value: function redo() {5731this.context.triggerEvent('before.command', this.$editable.html());5732this.history.redo();5733this.context.triggerEvent('change', this.$editable.html(), this.$editable);5734}5735/**5736* before command
5737*/
5738
5739}, {5740key: "beforeCommand",5741value: function beforeCommand() {5742this.context.triggerEvent('before.command', this.$editable.html()); // Set styleWithCSS before run a command5743
5744document.execCommand('styleWithCSS', false, this.options.styleWithCSS); // keep focus on editable before command execution5745
5746this.focus();5747}5748/**5749* after command
5750* @param {Boolean} isPreventTrigger
5751*/
5752
5753}, {5754key: "afterCommand",5755value: function afterCommand(isPreventTrigger) {5756this.normalizeContent();5757this.history.recordUndo();5758
5759if (!isPreventTrigger) {5760this.context.triggerEvent('change', this.$editable.html(), this.$editable);5761}5762}5763/**5764* handle tab key
5765*/
5766
5767}, {5768key: "tab",5769value: function tab() {5770var rng = this.getLastRange();5771
5772if (rng.isCollapsed() && rng.isOnCell()) {5773this.table.tab(rng);5774} else {5775if (this.options.tabSize === 0) {5776return false;5777}5778
5779if (!this.isLimited(this.options.tabSize)) {5780this.beforeCommand();5781this.typing.insertTab(rng, this.options.tabSize);5782this.afterCommand();5783}5784}5785}5786/**5787* handle shift+tab key
5788*/
5789
5790}, {5791key: "untab",5792value: function untab() {5793var rng = this.getLastRange();5794
5795if (rng.isCollapsed() && rng.isOnCell()) {5796this.table.tab(rng, true);5797} else {5798if (this.options.tabSize === 0) {5799return false;5800}5801}5802}5803/**5804* run given function between beforeCommand and afterCommand
5805*/
5806
5807}, {5808key: "wrapCommand",5809value: function wrapCommand(fn) {5810return function () {5811this.beforeCommand();5812fn.apply(this, arguments);5813this.afterCommand();5814};5815}5816/**5817* insert image
5818*
5819* @param {String} src
5820* @param {String|Function} param
5821* @return {Promise}
5822*/
5823
5824}, {5825key: "insertImage",5826value: function insertImage(src, param) {5827var _this3 = this;5828
5829return createImage(src, param).then(function ($image) {5830_this3.beforeCommand();5831
5832if (typeof param === 'function') {5833param($image);5834} else {5835if (typeof param === 'string') {5836$image.attr('data-filename', param);5837}5838
5839$image.css('width', Math.min(_this3.$editable.width(), $image.width()));5840}5841
5842$image.show();5843
5844_this3.getLastRange().insertNode($image[0]);5845
5846_this3.setLastRange(range.createFromNodeAfter($image[0]).select());5847
5848_this3.afterCommand();5849}).fail(function (e) {5850_this3.context.triggerEvent('image.upload.error', e);5851});5852}5853/**5854* insertImages
5855* @param {File[]} files
5856*/
5857
5858}, {5859key: "insertImagesAsDataURL",5860value: function insertImagesAsDataURL(files) {5861var _this4 = this;5862
5863external_jQuery_default().each(files, function (idx, file) {5864var filename = file.name;5865
5866if (_this4.options.maximumImageFileSize && _this4.options.maximumImageFileSize < file.size) {5867_this4.context.triggerEvent('image.upload.error', _this4.lang.image.maximumFileSizeError);5868} else {5869readFileAsDataURL(file).then(function (dataURL) {5870return _this4.insertImage(dataURL, filename);5871}).fail(function () {5872_this4.context.triggerEvent('image.upload.error');5873});5874}5875});5876}5877/**5878* insertImagesOrCallback
5879* @param {File[]} files
5880*/
5881
5882}, {5883key: "insertImagesOrCallback",5884value: function insertImagesOrCallback(files) {5885var callbacks = this.options.callbacks; // If onImageUpload set,5886
5887if (callbacks.onImageUpload) {5888this.context.triggerEvent('image.upload', files); // else insert Image as dataURL5889} else {5890this.insertImagesAsDataURL(files);5891}5892}5893/**5894* return selected plain text
5895* @return {String} text
5896*/
5897
5898}, {5899key: "getSelectedText",5900value: function getSelectedText() {5901var rng = this.getLastRange(); // if range on anchor, expand range with anchor5902
5903if (rng.isOnAnchor()) {5904rng = range.createFromNode(dom.ancestor(rng.sc, dom.isAnchor));5905}5906
5907return rng.toString();5908}5909}, {5910key: "onFormatBlock",5911value: function onFormatBlock(tagName, $target) {5912// [workaround] for MSIE, IE need `<`5913document.execCommand('FormatBlock', false, env.isMSIE ? '<' + tagName + '>' : tagName); // support custom class5914
5915if ($target && $target.length) {5916// find the exact element has given tagName5917if ($target[0].tagName.toUpperCase() !== tagName.toUpperCase()) {5918$target = $target.find(tagName);5919}5920
5921if ($target && $target.length) {5922var currentRange = this.createRange();5923var $parent = external_jQuery_default()([currentRange.sc, currentRange.ec]).closest(tagName); // remove class added for current block5924
5925$parent.removeClass();5926var className = $target[0].className || '';5927
5928if (className) {5929$parent.addClass(className);5930}5931}5932}5933}5934}, {5935key: "formatPara",5936value: function formatPara() {5937this.formatBlock('P');5938}5939}, {5940key: "fontStyling",5941value: function fontStyling(target, value) {5942var rng = this.getLastRange();5943
5944if (rng !== '') {5945var spans = this.style.styleNodes(rng);5946this.$editor.find('.note-status-output').html('');5947external_jQuery_default()(spans).css(target, value); // [workaround] added styled bogus span for style5948// - also bogus character needed for cursor position5949
5950if (rng.isCollapsed()) {5951var firstSpan = lists.head(spans);5952
5953if (firstSpan && !dom.nodeLength(firstSpan)) {5954firstSpan.innerHTML = dom.ZERO_WIDTH_NBSP_CHAR;5955range.createFromNode(firstSpan.firstChild).select();5956this.setLastRange();5957this.$editable.data(KEY_BOGUS, firstSpan);5958}5959} else {5960this.setLastRange(this.createRangeFromList(spans).select());5961}5962} else {5963var noteStatusOutput = external_jQuery_default().now();5964this.$editor.find('.note-status-output').html('<div id="note-status-output-' + noteStatusOutput + '" class="alert alert-info">' + this.lang.output.noSelection + '</div>');5965setTimeout(function () {5966external_jQuery_default()('#note-status-output-' + noteStatusOutput).remove();5967}, 5000);5968}5969}5970/**5971* unlink
5972*
5973* @type command
5974*/
5975
5976}, {5977key: "unlink",5978value: function unlink() {5979var rng = this.getLastRange();5980
5981if (rng.isOnAnchor()) {5982var anchor = dom.ancestor(rng.sc, dom.isAnchor);5983rng = range.createFromNode(anchor);5984rng.select();5985this.setLastRange();5986this.beforeCommand();5987document.execCommand('unlink');5988this.afterCommand();5989}5990}5991/**5992* returns link info
5993*
5994* @return {Object}
5995* @return {WrappedRange} return.range
5996* @return {String} return.text
5997* @return {Boolean} [return.isNewWindow=true]
5998* @return {String} [return.url=""]
5999*/
6000
6001}, {6002key: "getLinkInfo",6003value: function getLinkInfo() {6004var rng = this.getLastRange().expand(dom.isAnchor); // Get the first anchor on range(for edit).6005
6006var $anchor = external_jQuery_default()(lists.head(rng.nodes(dom.isAnchor)));6007var linkInfo = {6008range: rng,6009text: rng.toString(),6010url: $anchor.length ? $anchor.attr('href') : ''6011}; // When anchor exists,6012
6013if ($anchor.length) {6014// Set isNewWindow by checking its target.6015linkInfo.isNewWindow = $anchor.attr('target') === '_blank';6016}6017
6018return linkInfo;6019}6020}, {6021key: "addRow",6022value: function addRow(position) {6023var rng = this.getLastRange(this.$editable);6024
6025if (rng.isCollapsed() && rng.isOnCell()) {6026this.beforeCommand();6027this.table.addRow(rng, position);6028this.afterCommand();6029}6030}6031}, {6032key: "addCol",6033value: function addCol(position) {6034var rng = this.getLastRange(this.$editable);6035
6036if (rng.isCollapsed() && rng.isOnCell()) {6037this.beforeCommand();6038this.table.addCol(rng, position);6039this.afterCommand();6040}6041}6042}, {6043key: "deleteRow",6044value: function deleteRow() {6045var rng = this.getLastRange(this.$editable);6046
6047if (rng.isCollapsed() && rng.isOnCell()) {6048this.beforeCommand();6049this.table.deleteRow(rng);6050this.afterCommand();6051}6052}6053}, {6054key: "deleteCol",6055value: function deleteCol() {6056var rng = this.getLastRange(this.$editable);6057
6058if (rng.isCollapsed() && rng.isOnCell()) {6059this.beforeCommand();6060this.table.deleteCol(rng);6061this.afterCommand();6062}6063}6064}, {6065key: "deleteTable",6066value: function deleteTable() {6067var rng = this.getLastRange(this.$editable);6068
6069if (rng.isCollapsed() && rng.isOnCell()) {6070this.beforeCommand();6071this.table.deleteTable(rng);6072this.afterCommand();6073}6074}6075/**6076* @param {Position} pos
6077* @param {jQuery} $target - target element
6078* @param {Boolean} [bKeepRatio] - keep ratio
6079*/
6080
6081}, {6082key: "resizeTo",6083value: function resizeTo(pos, $target, bKeepRatio) {6084var imageSize;6085
6086if (bKeepRatio) {6087var newRatio = pos.y / pos.x;6088var ratio = $target.data('ratio');6089imageSize = {6090width: ratio > newRatio ? pos.x : pos.y / ratio,6091height: ratio > newRatio ? pos.x * ratio : pos.y6092};6093} else {6094imageSize = {6095width: pos.x,6096height: pos.y6097};6098}6099
6100$target.css(imageSize);6101}6102/**6103* returns whether editable area has focus or not.
6104*/
6105
6106}, {6107key: "hasFocus",6108value: function hasFocus() {6109return this.$editable.is(':focus');6110}6111/**6112* set focus
6113*/
6114
6115}, {6116key: "focus",6117value: function focus() {6118// [workaround] Screen will move when page is scolled in IE.6119// - do focus when not focused6120if (!this.hasFocus()) {6121this.$editable.focus();6122}6123}6124/**6125* returns whether contents is empty or not.
6126* @return {Boolean}
6127*/
6128
6129}, {6130key: "isEmpty",6131value: function isEmpty() {6132return dom.isEmpty(this.$editable[0]) || dom.emptyPara === this.$editable.html();6133}6134/**6135* Removes all contents and restores the editable instance to an _emptyPara_.
6136*/
6137
6138}, {6139key: "empty",6140value: function empty() {6141this.context.invoke('code', dom.emptyPara);6142}6143/**6144* normalize content
6145*/
6146
6147}, {6148key: "normalizeContent",6149value: function normalizeContent() {6150this.$editable[0].normalize();6151}6152}]);6153
6154return Editor;6155}();6156
6157
6158;// CONCATENATED MODULE: ./src/js/module/Clipboard.js6159function Clipboard_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }6160
6161function Clipboard_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); } }6162
6163function Clipboard_createClass(Constructor, protoProps, staticProps) { if (protoProps) Clipboard_defineProperties(Constructor.prototype, protoProps); if (staticProps) Clipboard_defineProperties(Constructor, staticProps); return Constructor; }6164
6165
6166
6167var Clipboard = /*#__PURE__*/function () {6168function Clipboard(context) {6169Clipboard_classCallCheck(this, Clipboard);6170
6171this.context = context;6172this.$editable = context.layoutInfo.editable;6173}6174
6175Clipboard_createClass(Clipboard, [{6176key: "initialize",6177value: function initialize() {6178this.$editable.on('paste', this.pasteByEvent.bind(this));6179}6180/**6181* paste by clipboard event
6182*
6183* @param {Event} event
6184*/
6185
6186}, {6187key: "pasteByEvent",6188value: function pasteByEvent(event) {6189var _this = this;6190
6191var clipboardData = event.originalEvent.clipboardData;6192
6193if (clipboardData && clipboardData.items && clipboardData.items.length) {6194var item = clipboardData.items.length > 1 ? clipboardData.items[1] : lists.head(clipboardData.items);6195
6196if (item.kind === 'file' && item.type.indexOf('image/') !== -1) {6197// paste img file6198this.context.invoke('editor.insertImagesOrCallback', [item.getAsFile()]);6199event.preventDefault();6200} else if (item.kind === 'string') {6201// paste text with maxTextLength check6202if (this.context.invoke('editor.isLimited', clipboardData.getData('Text').length)) {6203event.preventDefault();6204}6205}6206} else if (window.clipboardData) {6207// for IE6208var text = window.clipboardData.getData('text');6209
6210if (this.context.invoke('editor.isLimited', text.length)) {6211event.preventDefault();6212}6213} // Call editor.afterCommand after proceeding default event handler6214
6215
6216setTimeout(function () {6217_this.context.invoke('editor.afterCommand');6218}, 10);6219}6220}]);6221
6222return Clipboard;6223}();6224
6225
6226;// CONCATENATED MODULE: ./src/js/module/Dropzone.js6227function Dropzone_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }6228
6229function Dropzone_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); } }6230
6231function Dropzone_createClass(Constructor, protoProps, staticProps) { if (protoProps) Dropzone_defineProperties(Constructor.prototype, protoProps); if (staticProps) Dropzone_defineProperties(Constructor, staticProps); return Constructor; }6232
6233
6234
6235var Dropzone = /*#__PURE__*/function () {6236function Dropzone(context) {6237Dropzone_classCallCheck(this, Dropzone);6238
6239this.context = context;6240this.$eventListener = external_jQuery_default()(document);6241this.$editor = context.layoutInfo.editor;6242this.$editable = context.layoutInfo.editable;6243this.options = context.options;6244this.lang = this.options.langInfo;6245this.documentEventHandlers = {};6246this.$dropzone = external_jQuery_default()(['<div class="note-dropzone">', '<div class="note-dropzone-message"></div>', '</div>'].join('')).prependTo(this.$editor);6247}6248/**6249* attach Drag and Drop Events
6250*/
6251
6252
6253Dropzone_createClass(Dropzone, [{6254key: "initialize",6255value: function initialize() {6256if (this.options.disableDragAndDrop) {6257// prevent default drop event6258this.documentEventHandlers.onDrop = function (e) {6259e.preventDefault();6260}; // do not consider outside of dropzone6261
6262
6263this.$eventListener = this.$dropzone;6264this.$eventListener.on('drop', this.documentEventHandlers.onDrop);6265} else {6266this.attachDragAndDropEvent();6267}6268}6269/**6270* attach Drag and Drop Events
6271*/
6272
6273}, {6274key: "attachDragAndDropEvent",6275value: function attachDragAndDropEvent() {6276var _this = this;6277
6278var collection = external_jQuery_default()();6279var $dropzoneMessage = this.$dropzone.find('.note-dropzone-message');6280
6281this.documentEventHandlers.onDragenter = function (e) {6282var isCodeview = _this.context.invoke('codeview.isActivated');6283
6284var hasEditorSize = _this.$editor.width() > 0 && _this.$editor.height() > 0;6285
6286if (!isCodeview && !collection.length && hasEditorSize) {6287_this.$editor.addClass('dragover');6288
6289_this.$dropzone.width(_this.$editor.width());6290
6291_this.$dropzone.height(_this.$editor.height());6292
6293$dropzoneMessage.text(_this.lang.image.dragImageHere);6294}6295
6296collection = collection.add(e.target);6297};6298
6299this.documentEventHandlers.onDragleave = function (e) {6300collection = collection.not(e.target); // If nodeName is BODY, then just make it over (fix for IE)6301
6302if (!collection.length || e.target.nodeName === 'BODY') {6303collection = external_jQuery_default()();6304
6305_this.$editor.removeClass('dragover');6306}6307};6308
6309this.documentEventHandlers.onDrop = function () {6310collection = external_jQuery_default()();6311
6312_this.$editor.removeClass('dragover');6313}; // show dropzone on dragenter when dragging a object to document6314// -but only if the editor is visible, i.e. has a positive width and height6315
6316
6317this.$eventListener.on('dragenter', this.documentEventHandlers.onDragenter).on('dragleave', this.documentEventHandlers.onDragleave).on('drop', this.documentEventHandlers.onDrop); // change dropzone's message on hover.6318
6319this.$dropzone.on('dragenter', function () {6320_this.$dropzone.addClass('hover');6321
6322$dropzoneMessage.text(_this.lang.image.dropImage);6323}).on('dragleave', function () {6324_this.$dropzone.removeClass('hover');6325
6326$dropzoneMessage.text(_this.lang.image.dragImageHere);6327}); // attach dropImage6328
6329this.$dropzone.on('drop', function (event) {6330var dataTransfer = event.originalEvent.dataTransfer; // stop the browser from opening the dropped content6331
6332event.preventDefault();6333
6334if (dataTransfer && dataTransfer.files && dataTransfer.files.length) {6335_this.$editable.focus();6336
6337_this.context.invoke('editor.insertImagesOrCallback', dataTransfer.files);6338} else {6339external_jQuery_default().each(dataTransfer.types, function (idx, type) {6340// skip moz-specific types6341if (type.toLowerCase().indexOf('_moz_') > -1) {6342return;6343}6344
6345var content = dataTransfer.getData(type);6346
6347if (type.toLowerCase().indexOf('text') > -1) {6348_this.context.invoke('editor.pasteHTML', content);6349} else {6350external_jQuery_default()(content).each(function (idx, item) {6351_this.context.invoke('editor.insertNode', item);6352});6353}6354});6355}6356}).on('dragover', false); // prevent default dragover event6357}6358}, {6359key: "destroy",6360value: function destroy() {6361var _this2 = this;6362
6363Object.keys(this.documentEventHandlers).forEach(function (key) {6364_this2.$eventListener.off(key.substr(2).toLowerCase(), _this2.documentEventHandlers[key]);6365});6366this.documentEventHandlers = {};6367}6368}]);6369
6370return Dropzone;6371}();6372
6373
6374;// CONCATENATED MODULE: ./src/js/module/Codeview.js6375function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }6376
6377function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }6378
6379function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }6380
6381function Codeview_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }6382
6383function Codeview_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); } }6384
6385function Codeview_createClass(Constructor, protoProps, staticProps) { if (protoProps) Codeview_defineProperties(Constructor.prototype, protoProps); if (staticProps) Codeview_defineProperties(Constructor, staticProps); return Constructor; }6386
6387
6388
6389/**
6390* @class Codeview
6391*/
6392
6393var CodeView = /*#__PURE__*/function () {6394function CodeView(context) {6395Codeview_classCallCheck(this, CodeView);6396
6397this.context = context;6398this.$editor = context.layoutInfo.editor;6399this.$editable = context.layoutInfo.editable;6400this.$codable = context.layoutInfo.codable;6401this.options = context.options;6402this.CodeMirrorConstructor = window.CodeMirror;6403
6404if (this.options.codemirror.CodeMirrorConstructor) {6405this.CodeMirrorConstructor = this.options.codemirror.CodeMirrorConstructor;6406}6407}6408
6409Codeview_createClass(CodeView, [{6410key: "sync",6411value: function sync(html) {6412var isCodeview = this.isActivated();6413var CodeMirror = this.CodeMirrorConstructor;6414
6415if (isCodeview) {6416if (html) {6417if (CodeMirror) {6418this.$codable.data('cmEditor').getDoc().setValue(html);6419} else {6420this.$codable.val(html);6421}6422} else {6423if (CodeMirror) {6424this.$codable.data('cmEditor').save();6425}6426}6427}6428}6429}, {6430key: "initialize",6431value: function initialize() {6432var _this = this;6433
6434this.$codable.on('keyup', function (event) {6435if (event.keyCode === key.code.ESCAPE) {6436_this.deactivate();6437}6438});6439}6440/**6441* @return {Boolean}
6442*/
6443
6444}, {6445key: "isActivated",6446value: function isActivated() {6447return this.$editor.hasClass('codeview');6448}6449/**6450* toggle codeview
6451*/
6452
6453}, {6454key: "toggle",6455value: function toggle() {6456if (this.isActivated()) {6457this.deactivate();6458} else {6459this.activate();6460}6461
6462this.context.triggerEvent('codeview.toggled');6463}6464/**6465* purify input value
6466* @param value
6467* @returns {*}
6468*/
6469
6470}, {6471key: "purify",6472value: function purify(value) {6473if (this.options.codeviewFilter) {6474// filter code view regex6475value = value.replace(this.options.codeviewFilterRegex, ''); // allow specific iframe tag6476
6477if (this.options.codeviewIframeFilter) {6478var whitelist = this.options.codeviewIframeWhitelistSrc.concat(this.options.codeviewIframeWhitelistSrcBase);6479value = value.replace(/(<iframe.*?>.*?(?:<\/iframe>)?)/gi, function (tag) {6480// remove if src attribute is duplicated6481if (/<.+src(?==?('|"|\s)?)[\s\S]+src(?=('|"|\s)?)[^>]*?>/i.test(tag)) {6482return '';6483}6484
6485var _iterator = _createForOfIteratorHelper(whitelist),6486_step;6487
6488try {6489for (_iterator.s(); !(_step = _iterator.n()).done;) {6490var src = _step.value;6491
6492// pass if src is trusted6493if (new RegExp('src="(https?:)?\/\/' + src.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') + '\/(.+)"').test(tag)) {6494return tag;6495}6496}6497} catch (err) {6498_iterator.e(err);6499} finally {6500_iterator.f();6501}6502
6503return '';6504});6505}6506}6507
6508return value;6509}6510/**6511* activate code view
6512*/
6513
6514}, {6515key: "activate",6516value: function activate() {6517var _this2 = this;6518
6519var CodeMirror = this.CodeMirrorConstructor;6520this.$codable.val(dom.html(this.$editable, this.options.prettifyHtml));6521this.$codable.height(this.$editable.height());6522this.context.invoke('toolbar.updateCodeview', true);6523this.context.invoke('airPopover.updateCodeview', true);6524this.$editor.addClass('codeview');6525this.$codable.focus(); // activate CodeMirror as codable6526
6527if (CodeMirror) {6528var cmEditor = CodeMirror.fromTextArea(this.$codable[0], this.options.codemirror); // CodeMirror TernServer6529
6530if (this.options.codemirror.tern) {6531var server = new CodeMirror.TernServer(this.options.codemirror.tern);6532cmEditor.ternServer = server;6533cmEditor.on('cursorActivity', function (cm) {6534server.updateArgHints(cm);6535});6536}6537
6538cmEditor.on('blur', function (event) {6539_this2.context.triggerEvent('blur.codeview', cmEditor.getValue(), event);6540});6541cmEditor.on('change', function () {6542_this2.context.triggerEvent('change.codeview', cmEditor.getValue(), cmEditor);6543}); // CodeMirror hasn't Padding.6544
6545cmEditor.setSize(null, this.$editable.outerHeight());6546this.$codable.data('cmEditor', cmEditor);6547} else {6548this.$codable.on('blur', function (event) {6549_this2.context.triggerEvent('blur.codeview', _this2.$codable.val(), event);6550});6551this.$codable.on('input', function () {6552_this2.context.triggerEvent('change.codeview', _this2.$codable.val(), _this2.$codable);6553});6554}6555}6556/**6557* deactivate code view
6558*/
6559
6560}, {6561key: "deactivate",6562value: function deactivate() {6563var CodeMirror = this.CodeMirrorConstructor; // deactivate CodeMirror as codable6564
6565if (CodeMirror) {6566var cmEditor = this.$codable.data('cmEditor');6567this.$codable.val(cmEditor.getValue());6568cmEditor.toTextArea();6569}6570
6571var value = this.purify(dom.value(this.$codable, this.options.prettifyHtml) || dom.emptyPara);6572var isChange = this.$editable.html() !== value;6573this.$editable.html(value);6574this.$editable.height(this.options.height ? this.$codable.height() : 'auto');6575this.$editor.removeClass('codeview');6576
6577if (isChange) {6578this.context.triggerEvent('change', this.$editable.html(), this.$editable);6579}6580
6581this.$editable.focus();6582this.context.invoke('toolbar.updateCodeview', false);6583this.context.invoke('airPopover.updateCodeview', false);6584}6585}, {6586key: "destroy",6587value: function destroy() {6588if (this.isActivated()) {6589this.deactivate();6590}6591}6592}]);6593
6594return CodeView;6595}();6596
6597
6598;// CONCATENATED MODULE: ./src/js/module/Statusbar.js6599function Statusbar_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }6600
6601function Statusbar_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); } }6602
6603function Statusbar_createClass(Constructor, protoProps, staticProps) { if (protoProps) Statusbar_defineProperties(Constructor.prototype, protoProps); if (staticProps) Statusbar_defineProperties(Constructor, staticProps); return Constructor; }6604
6605
6606var EDITABLE_PADDING = 24;6607
6608var Statusbar = /*#__PURE__*/function () {6609function Statusbar(context) {6610Statusbar_classCallCheck(this, Statusbar);6611
6612this.$document = external_jQuery_default()(document);6613this.$statusbar = context.layoutInfo.statusbar;6614this.$editable = context.layoutInfo.editable;6615this.$codable = context.layoutInfo.codable;6616this.options = context.options;6617}6618
6619Statusbar_createClass(Statusbar, [{6620key: "initialize",6621value: function initialize() {6622var _this = this;6623
6624if (this.options.airMode || this.options.disableResizeEditor) {6625this.destroy();6626return;6627}6628
6629this.$statusbar.on('mousedown', function (event) {6630event.preventDefault();6631event.stopPropagation();6632
6633var editableTop = _this.$editable.offset().top - _this.$document.scrollTop();6634
6635var editableCodeTop = _this.$codable.offset().top - _this.$document.scrollTop();6636
6637var onMouseMove = function onMouseMove(event) {6638var height = event.clientY - (editableTop + EDITABLE_PADDING);6639var heightCode = event.clientY - (editableCodeTop + EDITABLE_PADDING);6640height = _this.options.minheight > 0 ? Math.max(height, _this.options.minheight) : height;6641height = _this.options.maxHeight > 0 ? Math.min(height, _this.options.maxHeight) : height;6642heightCode = _this.options.minheight > 0 ? Math.max(heightCode, _this.options.minheight) : heightCode;6643heightCode = _this.options.maxHeight > 0 ? Math.min(heightCode, _this.options.maxHeight) : heightCode;6644
6645_this.$editable.height(height);6646
6647_this.$codable.height(heightCode);6648};6649
6650_this.$document.on('mousemove', onMouseMove).one('mouseup', function () {6651_this.$document.off('mousemove', onMouseMove);6652});6653});6654}6655}, {6656key: "destroy",6657value: function destroy() {6658this.$statusbar.off();6659this.$statusbar.addClass('locked');6660}6661}]);6662
6663return Statusbar;6664}();6665
6666
6667;// CONCATENATED MODULE: ./src/js/module/Fullscreen.js6668function Fullscreen_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }6669
6670function Fullscreen_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); } }6671
6672function Fullscreen_createClass(Constructor, protoProps, staticProps) { if (protoProps) Fullscreen_defineProperties(Constructor.prototype, protoProps); if (staticProps) Fullscreen_defineProperties(Constructor, staticProps); return Constructor; }6673
6674
6675
6676var Fullscreen = /*#__PURE__*/function () {6677function Fullscreen(context) {6678var _this = this;6679
6680Fullscreen_classCallCheck(this, Fullscreen);6681
6682this.context = context;6683this.$editor = context.layoutInfo.editor;6684this.$toolbar = context.layoutInfo.toolbar;6685this.$editable = context.layoutInfo.editable;6686this.$codable = context.layoutInfo.codable;6687this.$window = external_jQuery_default()(window);6688this.$scrollbar = external_jQuery_default()('html, body');6689this.scrollbarClassName = 'note-fullscreen-body';6690
6691this.onResize = function () {6692_this.resizeTo({6693h: _this.$window.height() - _this.$toolbar.outerHeight()6694});6695};6696}6697
6698Fullscreen_createClass(Fullscreen, [{6699key: "resizeTo",6700value: function resizeTo(size) {6701this.$editable.css('height', size.h);6702this.$codable.css('height', size.h);6703
6704if (this.$codable.data('cmeditor')) {6705this.$codable.data('cmeditor').setsize(null, size.h);6706}6707}6708/**6709* toggle fullscreen
6710*/
6711
6712}, {6713key: "toggle",6714value: function toggle() {6715this.$editor.toggleClass('fullscreen');6716var isFullscreen = this.isFullscreen();6717this.$scrollbar.toggleClass(this.scrollbarClassName, isFullscreen);6718
6719if (isFullscreen) {6720this.$editable.data('orgHeight', this.$editable.css('height'));6721this.$editable.data('orgMaxHeight', this.$editable.css('maxHeight'));6722this.$editable.css('maxHeight', '');6723this.$window.on('resize', this.onResize).trigger('resize');6724} else {6725this.$window.off('resize', this.onResize);6726this.resizeTo({6727h: this.$editable.data('orgHeight')6728});6729this.$editable.css('maxHeight', this.$editable.css('orgMaxHeight'));6730}6731
6732this.context.invoke('toolbar.updateFullscreen', isFullscreen);6733}6734}, {6735key: "isFullscreen",6736value: function isFullscreen() {6737return this.$editor.hasClass('fullscreen');6738}6739}, {6740key: "destroy",6741value: function destroy() {6742this.$scrollbar.removeClass(this.scrollbarClassName);6743}6744}]);6745
6746return Fullscreen;6747}();6748
6749
6750;// CONCATENATED MODULE: ./src/js/module/Handle.js6751function Handle_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }6752
6753function Handle_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); } }6754
6755function Handle_createClass(Constructor, protoProps, staticProps) { if (protoProps) Handle_defineProperties(Constructor.prototype, protoProps); if (staticProps) Handle_defineProperties(Constructor, staticProps); return Constructor; }6756
6757
6758
6759
6760var Handle = /*#__PURE__*/function () {6761function Handle(context) {6762var _this = this;6763
6764Handle_classCallCheck(this, Handle);6765
6766this.context = context;6767this.$document = external_jQuery_default()(document);6768this.$editingArea = context.layoutInfo.editingArea;6769this.options = context.options;6770this.lang = this.options.langInfo;6771this.events = {6772'summernote.mousedown': function summernoteMousedown(we, e) {6773if (_this.update(e.target, e)) {6774e.preventDefault();6775}6776},6777'summernote.keyup summernote.scroll summernote.change summernote.dialog.shown': function summernoteKeyupSummernoteScrollSummernoteChangeSummernoteDialogShown() {6778_this.update();6779},6780'summernote.disable summernote.blur': function summernoteDisableSummernoteBlur() {6781_this.hide();6782},6783'summernote.codeview.toggled': function summernoteCodeviewToggled() {6784_this.update();6785}6786};6787}6788
6789Handle_createClass(Handle, [{6790key: "initialize",6791value: function initialize() {6792var _this2 = this;6793
6794this.$handle = external_jQuery_default()(['<div class="note-handle">', '<div class="note-control-selection">', '<div class="note-control-selection-bg"></div>', '<div class="note-control-holder note-control-nw"></div>', '<div class="note-control-holder note-control-ne"></div>', '<div class="note-control-holder note-control-sw"></div>', '<div class="', this.options.disableResizeImage ? 'note-control-holder' : 'note-control-sizing', ' note-control-se"></div>', this.options.disableResizeImage ? '' : '<div class="note-control-selection-info"></div>', '</div>', '</div>'].join('')).prependTo(this.$editingArea);6795this.$handle.on('mousedown', function (event) {6796if (dom.isControlSizing(event.target)) {6797event.preventDefault();6798event.stopPropagation();6799
6800var $target = _this2.$handle.find('.note-control-selection').data('target');6801
6802var posStart = $target.offset();6803
6804var scrollTop = _this2.$document.scrollTop();6805
6806var onMouseMove = function onMouseMove(event) {6807_this2.context.invoke('editor.resizeTo', {6808x: event.clientX - posStart.left,6809y: event.clientY - (posStart.top - scrollTop)6810}, $target, !event.shiftKey);6811
6812_this2.update($target[0], event);6813};6814
6815_this2.$document.on('mousemove', onMouseMove).one('mouseup', function (e) {6816e.preventDefault();6817
6818_this2.$document.off('mousemove', onMouseMove);6819
6820_this2.context.invoke('editor.afterCommand');6821});6822
6823if (!$target.data('ratio')) {6824// original ratio.6825$target.data('ratio', $target.height() / $target.width());6826}6827}6828}); // Listen for scrolling on the handle overlay.6829
6830this.$handle.on('wheel', function (e) {6831e.preventDefault();6832
6833_this2.update();6834});6835}6836}, {6837key: "destroy",6838value: function destroy() {6839this.$handle.remove();6840}6841}, {6842key: "update",6843value: function update(target, event) {6844if (this.context.isDisabled()) {6845return false;6846}6847
6848var isImage = dom.isImg(target);6849var $selection = this.$handle.find('.note-control-selection');6850this.context.invoke('imagePopover.update', target, event);6851
6852if (isImage) {6853var $image = external_jQuery_default()(target);6854var position = $image.position();6855var pos = {6856left: position.left + parseInt($image.css('marginLeft'), 10),6857top: position.top + parseInt($image.css('marginTop'), 10)6858}; // exclude margin6859
6860var imageSize = {6861w: $image.outerWidth(false),6862h: $image.outerHeight(false)6863};6864$selection.css({6865display: 'block',6866left: pos.left,6867top: pos.top,6868width: imageSize.w,6869height: imageSize.h6870}).data('target', $image); // save current image element.6871
6872var origImageObj = new Image();6873origImageObj.src = $image.attr('src');6874var sizingText = imageSize.w + 'x' + imageSize.h + ' (' + this.lang.image.original + ': ' + origImageObj.width + 'x' + origImageObj.height + ')';6875$selection.find('.note-control-selection-info').text(sizingText);6876this.context.invoke('editor.saveTarget', target);6877} else {6878this.hide();6879}6880
6881return isImage;6882}6883/**6884* hide
6885*
6886* @param {jQuery} $handle
6887*/
6888
6889}, {6890key: "hide",6891value: function hide() {6892this.context.invoke('editor.clearTarget');6893this.$handle.children().hide();6894}6895}]);6896
6897return Handle;6898}();6899
6900
6901;// CONCATENATED MODULE: ./src/js/module/AutoLink.js6902function AutoLink_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }6903
6904function AutoLink_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); } }6905
6906function AutoLink_createClass(Constructor, protoProps, staticProps) { if (protoProps) AutoLink_defineProperties(Constructor.prototype, protoProps); if (staticProps) AutoLink_defineProperties(Constructor, staticProps); return Constructor; }6907
6908
6909
6910
6911var defaultScheme = 'http://';6912var linkPattern = /^([A-Za-z][A-Za-z0-9+-.]*\:[\/]{2}|tel:|mailto:[A-Z0-9._%+-]+@|xmpp:[A-Z0-9._%+-]+@)?(www\.)?(.+)$/i;6913
6914var AutoLink = /*#__PURE__*/function () {6915function AutoLink(context) {6916var _this = this;6917
6918AutoLink_classCallCheck(this, AutoLink);6919
6920this.context = context;6921this.options = context.options;6922this.events = {6923'summernote.keyup': function summernoteKeyup(we, e) {6924if (!e.isDefaultPrevented()) {6925_this.handleKeyup(e);6926}6927},6928'summernote.keydown': function summernoteKeydown(we, e) {6929_this.handleKeydown(e);6930}6931};6932}6933
6934AutoLink_createClass(AutoLink, [{6935key: "initialize",6936value: function initialize() {6937this.lastWordRange = null;6938}6939}, {6940key: "destroy",6941value: function destroy() {6942this.lastWordRange = null;6943}6944}, {6945key: "replace",6946value: function replace() {6947if (!this.lastWordRange) {6948return;6949}6950
6951var keyword = this.lastWordRange.toString();6952var match = keyword.match(linkPattern);6953
6954if (match && (match[1] || match[2])) {6955var link = match[1] ? keyword : defaultScheme + keyword;6956var urlText = this.options.showDomainOnlyForAutolink ? keyword.replace(/^(?:https?:\/\/)?(?:tel?:?)?(?:mailto?:?)?(?:xmpp?:?)?(?:www\.)?/i, '').split('/')[0] : keyword;6957var node = external_jQuery_default()('<a></a>').html(urlText).attr('href', link)[0];6958
6959if (this.context.options.linkTargetBlank) {6960external_jQuery_default()(node).attr('target', '_blank');6961}6962
6963this.lastWordRange.insertNode(node);6964this.lastWordRange = null;6965this.context.invoke('editor.focus');6966}6967}6968}, {6969key: "handleKeydown",6970value: function handleKeydown(e) {6971if (lists.contains([key.code.ENTER, key.code.SPACE], e.keyCode)) {6972var wordRange = this.context.invoke('editor.createRange').getWordRange();6973this.lastWordRange = wordRange;6974}6975}6976}, {6977key: "handleKeyup",6978value: function handleKeyup(e) {6979if (lists.contains([key.code.ENTER, key.code.SPACE], e.keyCode)) {6980this.replace();6981}6982}6983}]);6984
6985return AutoLink;6986}();6987
6988
6989;// CONCATENATED MODULE: ./src/js/module/AutoSync.js6990function AutoSync_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }6991
6992function AutoSync_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); } }6993
6994function AutoSync_createClass(Constructor, protoProps, staticProps) { if (protoProps) AutoSync_defineProperties(Constructor.prototype, protoProps); if (staticProps) AutoSync_defineProperties(Constructor, staticProps); return Constructor; }6995
6996
6997/**
6998* textarea auto sync.
6999*/
7000
7001var AutoSync = /*#__PURE__*/function () {7002function AutoSync(context) {7003var _this = this;7004
7005AutoSync_classCallCheck(this, AutoSync);7006
7007this.$note = context.layoutInfo.note;7008this.events = {7009'summernote.change': function summernoteChange() {7010_this.$note.val(context.invoke('code'));7011}7012};7013}7014
7015AutoSync_createClass(AutoSync, [{7016key: "shouldInitialize",7017value: function shouldInitialize() {7018return dom.isTextarea(this.$note[0]);7019}7020}]);7021
7022return AutoSync;7023}();7024
7025
7026;// CONCATENATED MODULE: ./src/js/module/AutoReplace.js7027function AutoReplace_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }7028
7029function AutoReplace_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); } }7030
7031function AutoReplace_createClass(Constructor, protoProps, staticProps) { if (protoProps) AutoReplace_defineProperties(Constructor.prototype, protoProps); if (staticProps) AutoReplace_defineProperties(Constructor, staticProps); return Constructor; }7032
7033
7034
7035
7036
7037var AutoReplace = /*#__PURE__*/function () {7038function AutoReplace(context) {7039var _this = this;7040
7041AutoReplace_classCallCheck(this, AutoReplace);7042
7043this.context = context;7044this.options = context.options.replace || {};7045this.keys = [key.code.ENTER, key.code.SPACE, key.code.PERIOD, key.code.COMMA, key.code.SEMICOLON, key.code.SLASH];7046this.previousKeydownCode = null;7047this.events = {7048'summernote.keyup': function summernoteKeyup(we, e) {7049if (!e.isDefaultPrevented()) {7050_this.handleKeyup(e);7051}7052},7053'summernote.keydown': function summernoteKeydown(we, e) {7054_this.handleKeydown(e);7055}7056};7057}7058
7059AutoReplace_createClass(AutoReplace, [{7060key: "shouldInitialize",7061value: function shouldInitialize() {7062return !!this.options.match;7063}7064}, {7065key: "initialize",7066value: function initialize() {7067this.lastWord = null;7068}7069}, {7070key: "destroy",7071value: function destroy() {7072this.lastWord = null;7073}7074}, {7075key: "replace",7076value: function replace() {7077if (!this.lastWord) {7078return;7079}7080
7081var self = this;7082var keyword = this.lastWord.toString();7083this.options.match(keyword, function (match) {7084if (match) {7085var node = '';7086
7087if (typeof match === 'string') {7088node = dom.createText(match);7089} else if (match instanceof jQuery) {7090node = match[0];7091} else if (match instanceof Node) {7092node = match;7093}7094
7095if (!node) return;7096self.lastWord.insertNode(node);7097self.lastWord = null;7098self.context.invoke('editor.focus');7099}7100});7101}7102}, {7103key: "handleKeydown",7104value: function handleKeydown(e) {7105// this forces it to remember the last whole word, even if multiple termination keys are pressed7106// before the previous key is let go.7107if (this.previousKeydownCode && lists.contains(this.keys, this.previousKeydownCode)) {7108this.previousKeydownCode = e.keyCode;7109return;7110}7111
7112if (lists.contains(this.keys, e.keyCode)) {7113var wordRange = this.context.invoke('editor.createRange').getWordRange();7114this.lastWord = wordRange;7115}7116
7117this.previousKeydownCode = e.keyCode;7118}7119}, {7120key: "handleKeyup",7121value: function handleKeyup(e) {7122if (lists.contains(this.keys, e.keyCode)) {7123this.replace();7124}7125}7126}]);7127
7128return AutoReplace;7129}();7130
7131
7132;// CONCATENATED MODULE: ./src/js/module/Placeholder.js7133function Placeholder_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }7134
7135function Placeholder_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); } }7136
7137function Placeholder_createClass(Constructor, protoProps, staticProps) { if (protoProps) Placeholder_defineProperties(Constructor.prototype, protoProps); if (staticProps) Placeholder_defineProperties(Constructor, staticProps); return Constructor; }7138
7139
7140
7141var Placeholder = /*#__PURE__*/function () {7142function Placeholder(context) {7143var _this = this;7144
7145Placeholder_classCallCheck(this, Placeholder);7146
7147this.context = context;7148this.$editingArea = context.layoutInfo.editingArea;7149this.options = context.options;7150
7151if (this.options.inheritPlaceholder === true) {7152// get placeholder value from the original element7153this.options.placeholder = this.context.$note.attr('placeholder') || this.options.placeholder;7154}7155
7156this.events = {7157'summernote.init summernote.change': function summernoteInitSummernoteChange() {7158_this.update();7159},7160'summernote.codeview.toggled': function summernoteCodeviewToggled() {7161_this.update();7162}7163};7164}7165
7166Placeholder_createClass(Placeholder, [{7167key: "shouldInitialize",7168value: function shouldInitialize() {7169return !!this.options.placeholder;7170}7171}, {7172key: "initialize",7173value: function initialize() {7174var _this2 = this;7175
7176this.$placeholder = external_jQuery_default()('<div class="note-placeholder"></div>');7177this.$placeholder.on('click', function () {7178_this2.context.invoke('focus');7179}).html(this.options.placeholder).prependTo(this.$editingArea);7180this.update();7181}7182}, {7183key: "destroy",7184value: function destroy() {7185this.$placeholder.remove();7186}7187}, {7188key: "update",7189value: function update() {7190var isShow = !this.context.invoke('codeview.isActivated') && this.context.invoke('editor.isEmpty');7191this.$placeholder.toggle(isShow);7192}7193}]);7194
7195return Placeholder;7196}();7197
7198
7199;// CONCATENATED MODULE: ./src/js/module/Buttons.js7200function Buttons_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }7201
7202function Buttons_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); } }7203
7204function Buttons_createClass(Constructor, protoProps, staticProps) { if (protoProps) Buttons_defineProperties(Constructor.prototype, protoProps); if (staticProps) Buttons_defineProperties(Constructor, staticProps); return Constructor; }7205
7206
7207
7208
7209
7210
7211var Buttons = /*#__PURE__*/function () {7212function Buttons(context) {7213Buttons_classCallCheck(this, Buttons);7214
7215this.ui = (external_jQuery_default()).summernote.ui;7216this.context = context;7217this.$toolbar = context.layoutInfo.toolbar;7218this.options = context.options;7219this.lang = this.options.langInfo;7220this.invertedKeyMap = func.invertObject(this.options.keyMap[env.isMac ? 'mac' : 'pc']);7221}7222
7223Buttons_createClass(Buttons, [{7224key: "representShortcut",7225value: function representShortcut(editorMethod) {7226var shortcut = this.invertedKeyMap[editorMethod];7227
7228if (!this.options.shortcuts || !shortcut) {7229return '';7230}7231
7232if (env.isMac) {7233shortcut = shortcut.replace('CMD', '⌘').replace('SHIFT', '⇧');7234}7235
7236shortcut = shortcut.replace('BACKSLASH', '\\').replace('SLASH', '/').replace('LEFTBRACKET', '[').replace('RIGHTBRACKET', ']');7237return ' (' + shortcut + ')';7238}7239}, {7240key: "button",7241value: function button(o) {7242if (!this.options.tooltip && o.tooltip) {7243delete o.tooltip;7244}7245
7246o.container = this.options.container;7247return this.ui.button(o);7248}7249}, {7250key: "initialize",7251value: function initialize() {7252this.addToolbarButtons();7253this.addImagePopoverButtons();7254this.addLinkPopoverButtons();7255this.addTablePopoverButtons();7256this.fontInstalledMap = {};7257}7258}, {7259key: "destroy",7260value: function destroy() {7261delete this.fontInstalledMap;7262}7263}, {7264key: "isFontInstalled",7265value: function isFontInstalled(name) {7266if (!Object.prototype.hasOwnProperty.call(this.fontInstalledMap, name)) {7267this.fontInstalledMap[name] = env.isFontInstalled(name) || lists.contains(this.options.fontNamesIgnoreCheck, name);7268}7269
7270return this.fontInstalledMap[name];7271}7272}, {7273key: "isFontDeservedToAdd",7274value: function isFontDeservedToAdd(name) {7275name = name.toLowerCase();7276return name !== '' && this.isFontInstalled(name) && env.genericFontFamilies.indexOf(name) === -1;7277}7278}, {7279key: "colorPalette",7280value: function colorPalette(className, tooltip, backColor, foreColor) {7281var _this = this;7282
7283return this.ui.buttonGroup({7284className: 'note-color ' + className,7285children: [this.button({7286className: 'note-current-color-button',7287contents: this.ui.icon(this.options.icons.font + ' note-recent-color'),7288tooltip: tooltip,7289click: function click(e) {7290var $button = external_jQuery_default()(e.currentTarget);7291
7292if (backColor && foreColor) {7293_this.context.invoke('editor.color', {7294backColor: $button.attr('data-backColor'),7295foreColor: $button.attr('data-foreColor')7296});7297} else if (backColor) {7298_this.context.invoke('editor.color', {7299backColor: $button.attr('data-backColor')7300});7301} else if (foreColor) {7302_this.context.invoke('editor.color', {7303foreColor: $button.attr('data-foreColor')7304});7305}7306},7307callback: function callback($button) {7308var $recentColor = $button.find('.note-recent-color');7309
7310if (backColor) {7311$recentColor.css('background-color', _this.options.colorButton.backColor);7312$button.attr('data-backColor', _this.options.colorButton.backColor);7313}7314
7315if (foreColor) {7316$recentColor.css('color', _this.options.colorButton.foreColor);7317$button.attr('data-foreColor', _this.options.colorButton.foreColor);7318} else {7319$recentColor.css('color', 'transparent');7320}7321}7322}), this.button({7323className: 'dropdown-toggle',7324contents: this.ui.dropdownButtonContents('', this.options),7325tooltip: this.lang.color.more,7326data: {7327toggle: 'dropdown'7328}7329}), this.ui.dropdown({7330items: (backColor ? ['<div class="note-palette">', '<div class="note-palette-title">' + this.lang.color.background + '</div>', '<div>', '<button type="button" class="note-color-reset btn btn-light btn-default" data-event="backColor" data-value="transparent">', this.lang.color.transparent, '</button>', '</div>', '<div class="note-holder" data-event="backColor"><!-- back colors --></div>', '<div>', '<button type="button" class="note-color-select btn btn-light btn-default" data-event="openPalette" data-value="backColorPicker-' + this.options.id + '">', this.lang.color.cpSelect, '</button>', '<input type="color" id="backColorPicker-' + this.options.id + '" class="note-btn note-color-select-btn" value="' + this.options.colorButton.backColor + '" data-event="backColorPalette-' + this.options.id + '">', '</div>', '<div class="note-holder-custom" id="backColorPalette-' + this.options.id + '" data-event="backColor"></div>', '</div>'].join('') : '') + (foreColor ? ['<div class="note-palette">', '<div class="note-palette-title">' + this.lang.color.foreground + '</div>', '<div>', '<button type="button" class="note-color-reset btn btn-light btn-default" data-event="removeFormat" data-value="foreColor">', this.lang.color.resetToDefault, '</button>', '</div>', '<div class="note-holder" data-event="foreColor"><!-- fore colors --></div>', '<div>', '<button type="button" class="note-color-select btn btn-light btn-default" data-event="openPalette" data-value="foreColorPicker-' + this.options.id + '">', this.lang.color.cpSelect, '</button>', '<input type="color" id="foreColorPicker-' + this.options.id + '" class="note-btn note-color-select-btn" value="' + this.options.colorButton.foreColor + '" data-event="foreColorPalette-' + this.options.id + '">', '</div>', // Fix missing Div, Commented to find easily if it's wrong7331'<div class="note-holder-custom" id="foreColorPalette-' + this.options.id + '" data-event="foreColor"></div>', '</div>'].join('') : ''),7332callback: function callback($dropdown) {7333$dropdown.find('.note-holder').each(function (idx, item) {7334var $holder = external_jQuery_default()(item);7335$holder.append(_this.ui.palette({7336colors: _this.options.colors,7337colorsName: _this.options.colorsName,7338eventName: $holder.data('event'),7339container: _this.options.container,7340tooltip: _this.options.tooltip7341}).render());7342});7343/* TODO: do we have to record recent custom colors within cookies? */7344
7345var customColors = [['#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF', '#FFFFFF']];7346$dropdown.find('.note-holder-custom').each(function (idx, item) {7347var $holder = external_jQuery_default()(item);7348$holder.append(_this.ui.palette({7349colors: customColors,7350colorsName: customColors,7351eventName: $holder.data('event'),7352container: _this.options.container,7353tooltip: _this.options.tooltip7354}).render());7355});7356$dropdown.find('input[type=color]').each(function (idx, item) {7357external_jQuery_default()(item).change(function () {7358var $chip = $dropdown.find('#' + external_jQuery_default()(this).data('event')).find('.note-color-btn').first();7359var color = this.value.toUpperCase();7360$chip.css('background-color', color).attr('aria-label', color).attr('data-value', color).attr('data-original-title', color);7361$chip.click();7362});7363});7364},7365click: function click(event) {7366event.stopPropagation();7367var $parent = external_jQuery_default()('.' + className).find('.note-dropdown-menu');7368var $button = external_jQuery_default()(event.target);7369var eventName = $button.data('event');7370var value = $button.attr('data-value');7371
7372if (eventName === 'openPalette') {7373var $picker = $parent.find('#' + value);7374var $palette = external_jQuery_default()($parent.find('#' + $picker.data('event')).find('.note-color-row')[0]); // Shift palette chips7375
7376var $chip = $palette.find('.note-color-btn').last().detach(); // Set chip attributes7377
7378var color = $picker.val();7379$chip.css('background-color', color).attr('aria-label', color).attr('data-value', color).attr('data-original-title', color);7380$palette.prepend($chip);7381$picker.click();7382} else {7383if (lists.contains(['backColor', 'foreColor'], eventName)) {7384var key = eventName === 'backColor' ? 'background-color' : 'color';7385var $color = $button.closest('.note-color').find('.note-recent-color');7386var $currentButton = $button.closest('.note-color').find('.note-current-color-button');7387$color.css(key, value);7388$currentButton.attr('data-' + eventName, value);7389}7390
7391_this.context.invoke('editor.' + eventName, value);7392}7393}7394})]7395}).render();7396}7397}, {7398key: "addToolbarButtons",7399value: function addToolbarButtons() {7400var _this2 = this;7401
7402this.context.memo('button.style', function () {7403return _this2.ui.buttonGroup([_this2.button({7404className: 'dropdown-toggle',7405contents: _this2.ui.dropdownButtonContents(_this2.ui.icon(_this2.options.icons.magic), _this2.options),7406tooltip: _this2.lang.style.style,7407data: {7408toggle: 'dropdown'7409}7410}), _this2.ui.dropdown({7411className: 'dropdown-style',7412items: _this2.options.styleTags,7413title: _this2.lang.style.style,7414template: function template(item) {7415// TBD: need to be simplified7416if (typeof item === 'string') {7417item = {7418tag: item,7419title: Object.prototype.hasOwnProperty.call(_this2.lang.style, item) ? _this2.lang.style[item] : item7420};7421}7422
7423var tag = item.tag;7424var title = item.title;7425var style = item.style ? ' style="' + item.style + '" ' : '';7426var className = item.className ? ' class="' + item.className + '"' : '';7427return '<' + tag + style + className + '>' + title + '</' + tag + '>';7428},7429click: _this2.context.createInvokeHandler('editor.formatBlock')7430})]).render();7431});7432
7433var _loop = function _loop(styleIdx, styleLen) {7434var item = _this2.options.styleTags[styleIdx];7435
7436_this2.context.memo('button.style.' + item, function () {7437return _this2.button({7438className: 'note-btn-style-' + item,7439contents: '<div data-value="' + item + '">' + item.toUpperCase() + '</div>',7440tooltip: _this2.lang.style[item],7441click: _this2.context.createInvokeHandler('editor.formatBlock')7442}).render();7443});7444};7445
7446for (var styleIdx = 0, styleLen = this.options.styleTags.length; styleIdx < styleLen; styleIdx++) {7447_loop(styleIdx, styleLen);7448}7449
7450this.context.memo('button.bold', function () {7451return _this2.button({7452className: 'note-btn-bold',7453contents: _this2.ui.icon(_this2.options.icons.bold),7454tooltip: _this2.lang.font.bold + _this2.representShortcut('bold'),7455click: _this2.context.createInvokeHandlerAndUpdateState('editor.bold')7456}).render();7457});7458this.context.memo('button.italic', function () {7459return _this2.button({7460className: 'note-btn-italic',7461contents: _this2.ui.icon(_this2.options.icons.italic),7462tooltip: _this2.lang.font.italic + _this2.representShortcut('italic'),7463click: _this2.context.createInvokeHandlerAndUpdateState('editor.italic')7464}).render();7465});7466this.context.memo('button.underline', function () {7467return _this2.button({7468className: 'note-btn-underline',7469contents: _this2.ui.icon(_this2.options.icons.underline),7470tooltip: _this2.lang.font.underline + _this2.representShortcut('underline'),7471click: _this2.context.createInvokeHandlerAndUpdateState('editor.underline')7472}).render();7473});7474this.context.memo('button.clear', function () {7475return _this2.button({7476contents: _this2.ui.icon(_this2.options.icons.eraser),7477tooltip: _this2.lang.font.clear + _this2.representShortcut('removeFormat'),7478click: _this2.context.createInvokeHandler('editor.removeFormat')7479}).render();7480});7481this.context.memo('button.strikethrough', function () {7482return _this2.button({7483className: 'note-btn-strikethrough',7484contents: _this2.ui.icon(_this2.options.icons.strikethrough),7485tooltip: _this2.lang.font.strikethrough + _this2.representShortcut('strikethrough'),7486click: _this2.context.createInvokeHandlerAndUpdateState('editor.strikethrough')7487}).render();7488});7489this.context.memo('button.superscript', function () {7490return _this2.button({7491className: 'note-btn-superscript',7492contents: _this2.ui.icon(_this2.options.icons.superscript),7493tooltip: _this2.lang.font.superscript,7494click: _this2.context.createInvokeHandlerAndUpdateState('editor.superscript')7495}).render();7496});7497this.context.memo('button.subscript', function () {7498return _this2.button({7499className: 'note-btn-subscript',7500contents: _this2.ui.icon(_this2.options.icons.subscript),7501tooltip: _this2.lang.font.subscript,7502click: _this2.context.createInvokeHandlerAndUpdateState('editor.subscript')7503}).render();7504});7505this.context.memo('button.fontname', function () {7506var styleInfo = _this2.context.invoke('editor.currentStyle');7507
7508if (_this2.options.addDefaultFonts) {7509// Add 'default' fonts into the fontnames array if not exist7510external_jQuery_default().each(styleInfo['font-family'].split(','), function (idx, fontname) {7511fontname = fontname.trim().replace(/['"]+/g, '');7512
7513if (_this2.isFontDeservedToAdd(fontname)) {7514if (_this2.options.fontNames.indexOf(fontname) === -1) {7515_this2.options.fontNames.push(fontname);7516}7517}7518});7519}7520
7521return _this2.ui.buttonGroup([_this2.button({7522className: 'dropdown-toggle',7523contents: _this2.ui.dropdownButtonContents('<span class="note-current-fontname"></span>', _this2.options),7524tooltip: _this2.lang.font.name,7525data: {7526toggle: 'dropdown'7527}7528}), _this2.ui.dropdownCheck({7529className: 'dropdown-fontname',7530checkClassName: _this2.options.icons.menuCheck,7531items: _this2.options.fontNames.filter(_this2.isFontInstalled.bind(_this2)),7532title: _this2.lang.font.name,7533template: function template(item) {7534return '<span style="font-family: ' + env.validFontName(item) + '">' + item + '</span>';7535},7536click: _this2.context.createInvokeHandlerAndUpdateState('editor.fontName')7537})]).render();7538});7539this.context.memo('button.fontsize', function () {7540return _this2.ui.buttonGroup([_this2.button({7541className: 'dropdown-toggle',7542contents: _this2.ui.dropdownButtonContents('<span class="note-current-fontsize"></span>', _this2.options),7543tooltip: _this2.lang.font.size,7544data: {7545toggle: 'dropdown'7546}7547}), _this2.ui.dropdownCheck({7548className: 'dropdown-fontsize',7549checkClassName: _this2.options.icons.menuCheck,7550items: _this2.options.fontSizes,7551title: _this2.lang.font.size,7552click: _this2.context.createInvokeHandlerAndUpdateState('editor.fontSize')7553})]).render();7554});7555this.context.memo('button.fontsizeunit', function () {7556return _this2.ui.buttonGroup([_this2.button({7557className: 'dropdown-toggle',7558contents: _this2.ui.dropdownButtonContents('<span class="note-current-fontsizeunit"></span>', _this2.options),7559tooltip: _this2.lang.font.sizeunit,7560data: {7561toggle: 'dropdown'7562}7563}), _this2.ui.dropdownCheck({7564className: 'dropdown-fontsizeunit',7565checkClassName: _this2.options.icons.menuCheck,7566items: _this2.options.fontSizeUnits,7567title: _this2.lang.font.sizeunit,7568click: _this2.context.createInvokeHandlerAndUpdateState('editor.fontSizeUnit')7569})]).render();7570});7571this.context.memo('button.color', function () {7572return _this2.colorPalette('note-color-all', _this2.lang.color.recent, true, true);7573});7574this.context.memo('button.forecolor', function () {7575return _this2.colorPalette('note-color-fore', _this2.lang.color.foreground, false, true);7576});7577this.context.memo('button.backcolor', function () {7578return _this2.colorPalette('note-color-back', _this2.lang.color.background, true, false);7579});7580this.context.memo('button.ul', function () {7581return _this2.button({7582contents: _this2.ui.icon(_this2.options.icons.unorderedlist),7583tooltip: _this2.lang.lists.unordered + _this2.representShortcut('insertUnorderedList'),7584click: _this2.context.createInvokeHandler('editor.insertUnorderedList')7585}).render();7586});7587this.context.memo('button.ol', function () {7588return _this2.button({7589contents: _this2.ui.icon(_this2.options.icons.orderedlist),7590tooltip: _this2.lang.lists.ordered + _this2.representShortcut('insertOrderedList'),7591click: _this2.context.createInvokeHandler('editor.insertOrderedList')7592}).render();7593});7594var justifyLeft = this.button({7595contents: this.ui.icon(this.options.icons.alignLeft),7596tooltip: this.lang.paragraph.left + this.representShortcut('justifyLeft'),7597click: this.context.createInvokeHandler('editor.justifyLeft')7598});7599var justifyCenter = this.button({7600contents: this.ui.icon(this.options.icons.alignCenter),7601tooltip: this.lang.paragraph.center + this.representShortcut('justifyCenter'),7602click: this.context.createInvokeHandler('editor.justifyCenter')7603});7604var justifyRight = this.button({7605contents: this.ui.icon(this.options.icons.alignRight),7606tooltip: this.lang.paragraph.right + this.representShortcut('justifyRight'),7607click: this.context.createInvokeHandler('editor.justifyRight')7608});7609var justifyFull = this.button({7610contents: this.ui.icon(this.options.icons.alignJustify),7611tooltip: this.lang.paragraph.justify + this.representShortcut('justifyFull'),7612click: this.context.createInvokeHandler('editor.justifyFull')7613});7614var outdent = this.button({7615contents: this.ui.icon(this.options.icons.outdent),7616tooltip: this.lang.paragraph.outdent + this.representShortcut('outdent'),7617click: this.context.createInvokeHandler('editor.outdent')7618});7619var indent = this.button({7620contents: this.ui.icon(this.options.icons.indent),7621tooltip: this.lang.paragraph.indent + this.representShortcut('indent'),7622click: this.context.createInvokeHandler('editor.indent')7623});7624this.context.memo('button.justifyLeft', func.invoke(justifyLeft, 'render'));7625this.context.memo('button.justifyCenter', func.invoke(justifyCenter, 'render'));7626this.context.memo('button.justifyRight', func.invoke(justifyRight, 'render'));7627this.context.memo('button.justifyFull', func.invoke(justifyFull, 'render'));7628this.context.memo('button.outdent', func.invoke(outdent, 'render'));7629this.context.memo('button.indent', func.invoke(indent, 'render'));7630this.context.memo('button.paragraph', function () {7631return _this2.ui.buttonGroup([_this2.button({7632className: 'dropdown-toggle',7633contents: _this2.ui.dropdownButtonContents(_this2.ui.icon(_this2.options.icons.alignLeft), _this2.options),7634tooltip: _this2.lang.paragraph.paragraph,7635data: {7636toggle: 'dropdown'7637}7638}), _this2.ui.dropdown([_this2.ui.buttonGroup({7639className: 'note-align',7640children: [justifyLeft, justifyCenter, justifyRight, justifyFull]7641}), _this2.ui.buttonGroup({7642className: 'note-list',7643children: [outdent, indent]7644})])]).render();7645});7646this.context.memo('button.height', function () {7647return _this2.ui.buttonGroup([_this2.button({7648className: 'dropdown-toggle',7649contents: _this2.ui.dropdownButtonContents(_this2.ui.icon(_this2.options.icons.textHeight), _this2.options),7650tooltip: _this2.lang.font.height,7651data: {7652toggle: 'dropdown'7653}7654}), _this2.ui.dropdownCheck({7655items: _this2.options.lineHeights,7656checkClassName: _this2.options.icons.menuCheck,7657className: 'dropdown-line-height',7658title: _this2.lang.font.height,7659click: _this2.context.createInvokeHandler('editor.lineHeight')7660})]).render();7661});7662this.context.memo('button.table', function () {7663return _this2.ui.buttonGroup([_this2.button({7664className: 'dropdown-toggle',7665contents: _this2.ui.dropdownButtonContents(_this2.ui.icon(_this2.options.icons.table), _this2.options),7666tooltip: _this2.lang.table.table,7667data: {7668toggle: 'dropdown'7669}7670}), _this2.ui.dropdown({7671title: _this2.lang.table.table,7672className: 'note-table',7673items: ['<div class="note-dimension-picker">', '<div class="note-dimension-picker-mousecatcher" data-event="insertTable" data-value="1x1"></div>', '<div class="note-dimension-picker-highlighted"></div>', '<div class="note-dimension-picker-unhighlighted"></div>', '</div>', '<div class="note-dimension-display">1 x 1</div>'].join('')7674})], {7675callback: function callback($node) {7676var $catcher = $node.find('.note-dimension-picker-mousecatcher');7677$catcher.css({7678width: _this2.options.insertTableMaxSize.col + 'em',7679height: _this2.options.insertTableMaxSize.row + 'em'7680}).mouseup(_this2.context.createInvokeHandler('editor.insertTable')).on('mousemove', _this2.tableMoveHandler.bind(_this2));7681}7682}).render();7683});7684this.context.memo('button.link', function () {7685return _this2.button({7686contents: _this2.ui.icon(_this2.options.icons.link),7687tooltip: _this2.lang.link.link + _this2.representShortcut('linkDialog.show'),7688click: _this2.context.createInvokeHandler('linkDialog.show')7689}).render();7690});7691this.context.memo('button.picture', function () {7692return _this2.button({7693contents: _this2.ui.icon(_this2.options.icons.picture),7694tooltip: _this2.lang.image.image,7695click: _this2.context.createInvokeHandler('imageDialog.show')7696}).render();7697});7698this.context.memo('button.video', function () {7699return _this2.button({7700contents: _this2.ui.icon(_this2.options.icons.video),7701tooltip: _this2.lang.video.video,7702click: _this2.context.createInvokeHandler('videoDialog.show')7703}).render();7704});7705this.context.memo('button.hr', function () {7706return _this2.button({7707contents: _this2.ui.icon(_this2.options.icons.minus),7708tooltip: _this2.lang.hr.insert + _this2.representShortcut('insertHorizontalRule'),7709click: _this2.context.createInvokeHandler('editor.insertHorizontalRule')7710}).render();7711});7712this.context.memo('button.fullscreen', function () {7713return _this2.button({7714className: 'btn-fullscreen note-codeview-keep',7715contents: _this2.ui.icon(_this2.options.icons.arrowsAlt),7716tooltip: _this2.lang.options.fullscreen,7717click: _this2.context.createInvokeHandler('fullscreen.toggle')7718}).render();7719});7720this.context.memo('button.codeview', function () {7721return _this2.button({7722className: 'btn-codeview note-codeview-keep',7723contents: _this2.ui.icon(_this2.options.icons.code),7724tooltip: _this2.lang.options.codeview,7725click: _this2.context.createInvokeHandler('codeview.toggle')7726}).render();7727});7728this.context.memo('button.redo', function () {7729return _this2.button({7730contents: _this2.ui.icon(_this2.options.icons.redo),7731tooltip: _this2.lang.history.redo + _this2.representShortcut('redo'),7732click: _this2.context.createInvokeHandler('editor.redo')7733}).render();7734});7735this.context.memo('button.undo', function () {7736return _this2.button({7737contents: _this2.ui.icon(_this2.options.icons.undo),7738tooltip: _this2.lang.history.undo + _this2.representShortcut('undo'),7739click: _this2.context.createInvokeHandler('editor.undo')7740}).render();7741});7742this.context.memo('button.help', function () {7743return _this2.button({7744contents: _this2.ui.icon(_this2.options.icons.question),7745tooltip: _this2.lang.options.help,7746click: _this2.context.createInvokeHandler('helpDialog.show')7747}).render();7748});7749}7750/**7751* image: [
7752* ['imageResize', ['resizeFull', 'resizeHalf', 'resizeQuarter', 'resizeNone']],
7753* ['float', ['floatLeft', 'floatRight', 'floatNone']],
7754* ['remove', ['removeMedia']],
7755* ],
7756*/
7757
7758}, {7759key: "addImagePopoverButtons",7760value: function addImagePopoverButtons() {7761var _this3 = this;7762
7763// Image Size Buttons7764this.context.memo('button.resizeFull', function () {7765return _this3.button({7766contents: '<span class="note-fontsize-10">100%</span>',7767tooltip: _this3.lang.image.resizeFull,7768click: _this3.context.createInvokeHandler('editor.resize', '1')7769}).render();7770});7771this.context.memo('button.resizeHalf', function () {7772return _this3.button({7773contents: '<span class="note-fontsize-10">50%</span>',7774tooltip: _this3.lang.image.resizeHalf,7775click: _this3.context.createInvokeHandler('editor.resize', '0.5')7776}).render();7777});7778this.context.memo('button.resizeQuarter', function () {7779return _this3.button({7780contents: '<span class="note-fontsize-10">25%</span>',7781tooltip: _this3.lang.image.resizeQuarter,7782click: _this3.context.createInvokeHandler('editor.resize', '0.25')7783}).render();7784});7785this.context.memo('button.resizeNone', function () {7786return _this3.button({7787contents: _this3.ui.icon(_this3.options.icons.rollback),7788tooltip: _this3.lang.image.resizeNone,7789click: _this3.context.createInvokeHandler('editor.resize', '0')7790}).render();7791}); // Float Buttons7792
7793this.context.memo('button.floatLeft', function () {7794return _this3.button({7795contents: _this3.ui.icon(_this3.options.icons.floatLeft),7796tooltip: _this3.lang.image.floatLeft,7797click: _this3.context.createInvokeHandler('editor.floatMe', 'left')7798}).render();7799});7800this.context.memo('button.floatRight', function () {7801return _this3.button({7802contents: _this3.ui.icon(_this3.options.icons.floatRight),7803tooltip: _this3.lang.image.floatRight,7804click: _this3.context.createInvokeHandler('editor.floatMe', 'right')7805}).render();7806});7807this.context.memo('button.floatNone', function () {7808return _this3.button({7809contents: _this3.ui.icon(_this3.options.icons.rollback),7810tooltip: _this3.lang.image.floatNone,7811click: _this3.context.createInvokeHandler('editor.floatMe', 'none')7812}).render();7813}); // Remove Buttons7814
7815this.context.memo('button.removeMedia', function () {7816return _this3.button({7817contents: _this3.ui.icon(_this3.options.icons.trash),7818tooltip: _this3.lang.image.remove,7819click: _this3.context.createInvokeHandler('editor.removeMedia')7820}).render();7821});7822}7823}, {7824key: "addLinkPopoverButtons",7825value: function addLinkPopoverButtons() {7826var _this4 = this;7827
7828this.context.memo('button.linkDialogShow', function () {7829return _this4.button({7830contents: _this4.ui.icon(_this4.options.icons.link),7831tooltip: _this4.lang.link.edit,7832click: _this4.context.createInvokeHandler('linkDialog.show')7833}).render();7834});7835this.context.memo('button.unlink', function () {7836return _this4.button({7837contents: _this4.ui.icon(_this4.options.icons.unlink),7838tooltip: _this4.lang.link.unlink,7839click: _this4.context.createInvokeHandler('editor.unlink')7840}).render();7841});7842}7843/**7844* table : [
7845* ['add', ['addRowDown', 'addRowUp', 'addColLeft', 'addColRight']],
7846* ['delete', ['deleteRow', 'deleteCol', 'deleteTable']]
7847* ],
7848*/
7849
7850}, {7851key: "addTablePopoverButtons",7852value: function addTablePopoverButtons() {7853var _this5 = this;7854
7855this.context.memo('button.addRowUp', function () {7856return _this5.button({7857className: 'btn-md',7858contents: _this5.ui.icon(_this5.options.icons.rowAbove),7859tooltip: _this5.lang.table.addRowAbove,7860click: _this5.context.createInvokeHandler('editor.addRow', 'top')7861}).render();7862});7863this.context.memo('button.addRowDown', function () {7864return _this5.button({7865className: 'btn-md',7866contents: _this5.ui.icon(_this5.options.icons.rowBelow),7867tooltip: _this5.lang.table.addRowBelow,7868click: _this5.context.createInvokeHandler('editor.addRow', 'bottom')7869}).render();7870});7871this.context.memo('button.addColLeft', function () {7872return _this5.button({7873className: 'btn-md',7874contents: _this5.ui.icon(_this5.options.icons.colBefore),7875tooltip: _this5.lang.table.addColLeft,7876click: _this5.context.createInvokeHandler('editor.addCol', 'left')7877}).render();7878});7879this.context.memo('button.addColRight', function () {7880return _this5.button({7881className: 'btn-md',7882contents: _this5.ui.icon(_this5.options.icons.colAfter),7883tooltip: _this5.lang.table.addColRight,7884click: _this5.context.createInvokeHandler('editor.addCol', 'right')7885}).render();7886});7887this.context.memo('button.deleteRow', function () {7888return _this5.button({7889className: 'btn-md',7890contents: _this5.ui.icon(_this5.options.icons.rowRemove),7891tooltip: _this5.lang.table.delRow,7892click: _this5.context.createInvokeHandler('editor.deleteRow')7893}).render();7894});7895this.context.memo('button.deleteCol', function () {7896return _this5.button({7897className: 'btn-md',7898contents: _this5.ui.icon(_this5.options.icons.colRemove),7899tooltip: _this5.lang.table.delCol,7900click: _this5.context.createInvokeHandler('editor.deleteCol')7901}).render();7902});7903this.context.memo('button.deleteTable', function () {7904return _this5.button({7905className: 'btn-md',7906contents: _this5.ui.icon(_this5.options.icons.trash),7907tooltip: _this5.lang.table.delTable,7908click: _this5.context.createInvokeHandler('editor.deleteTable')7909}).render();7910});7911}7912}, {7913key: "build",7914value: function build($container, groups) {7915for (var groupIdx = 0, groupLen = groups.length; groupIdx < groupLen; groupIdx++) {7916var group = groups[groupIdx];7917var groupName = Array.isArray(group) ? group[0] : group;7918var buttons = Array.isArray(group) ? group.length === 1 ? [group[0]] : group[1] : [group];7919var $group = this.ui.buttonGroup({7920className: 'note-' + groupName7921}).render();7922
7923for (var idx = 0, len = buttons.length; idx < len; idx++) {7924var btn = this.context.memo('button.' + buttons[idx]);7925
7926if (btn) {7927$group.append(typeof btn === 'function' ? btn(this.context) : btn);7928}7929}7930
7931$group.appendTo($container);7932}7933}7934/**7935* @param {jQuery} [$container]
7936*/
7937
7938}, {7939key: "updateCurrentStyle",7940value: function updateCurrentStyle($container) {7941var $cont = $container || this.$toolbar;7942var styleInfo = this.context.invoke('editor.currentStyle');7943this.updateBtnStates($cont, {7944'.note-btn-bold': function noteBtnBold() {7945return styleInfo['font-bold'] === 'bold';7946},7947'.note-btn-italic': function noteBtnItalic() {7948return styleInfo['font-italic'] === 'italic';7949},7950'.note-btn-underline': function noteBtnUnderline() {7951return styleInfo['font-underline'] === 'underline';7952},7953'.note-btn-subscript': function noteBtnSubscript() {7954return styleInfo['font-subscript'] === 'subscript';7955},7956'.note-btn-superscript': function noteBtnSuperscript() {7957return styleInfo['font-superscript'] === 'superscript';7958},7959'.note-btn-strikethrough': function noteBtnStrikethrough() {7960return styleInfo['font-strikethrough'] === 'strikethrough';7961}7962});7963
7964if (styleInfo['font-family']) {7965var fontNames = styleInfo['font-family'].split(',').map(function (name) {7966return name.replace(/[\'\"]/g, '').replace(/\s+$/, '').replace(/^\s+/, '');7967});7968var fontName = lists.find(fontNames, this.isFontInstalled.bind(this));7969$cont.find('.dropdown-fontname a').each(function (idx, item) {7970var $item = external_jQuery_default()(item); // always compare string to avoid creating another func.7971
7972var isChecked = $item.data('value') + '' === fontName + '';7973$item.toggleClass('checked', isChecked);7974});7975$cont.find('.note-current-fontname').text(fontName).css('font-family', fontName);7976}7977
7978if (styleInfo['font-size']) {7979var fontSize = styleInfo['font-size'];7980$cont.find('.dropdown-fontsize a').each(function (idx, item) {7981var $item = external_jQuery_default()(item); // always compare with string to avoid creating another func.7982
7983var isChecked = $item.data('value') + '' === fontSize + '';7984$item.toggleClass('checked', isChecked);7985});7986$cont.find('.note-current-fontsize').text(fontSize);7987var fontSizeUnit = styleInfo['font-size-unit'];7988$cont.find('.dropdown-fontsizeunit a').each(function (idx, item) {7989var $item = external_jQuery_default()(item);7990var isChecked = $item.data('value') + '' === fontSizeUnit + '';7991$item.toggleClass('checked', isChecked);7992});7993$cont.find('.note-current-fontsizeunit').text(fontSizeUnit);7994}7995
7996if (styleInfo['line-height']) {7997var lineHeight = styleInfo['line-height'];7998$cont.find('.dropdown-line-height a').each(function (idx, item) {7999var $item = external_jQuery_default()(item); // always compare with string to avoid creating another func.8000
8001var isChecked = external_jQuery_default()(item).data('value') + '' === lineHeight + '';8002$item.toggleClass('checked', isChecked);8003});8004$cont.find('.note-current-line-height').text(lineHeight);8005}8006}8007}, {8008key: "updateBtnStates",8009value: function updateBtnStates($container, infos) {8010var _this6 = this;8011
8012external_jQuery_default().each(infos, function (selector, pred) {8013_this6.ui.toggleBtnActive($container.find(selector), pred());8014});8015}8016}, {8017key: "tableMoveHandler",8018value: function tableMoveHandler(event) {8019var PX_PER_EM = 18;8020var $picker = external_jQuery_default()(event.target.parentNode); // target is mousecatcher8021
8022var $dimensionDisplay = $picker.next();8023var $catcher = $picker.find('.note-dimension-picker-mousecatcher');8024var $highlighted = $picker.find('.note-dimension-picker-highlighted');8025var $unhighlighted = $picker.find('.note-dimension-picker-unhighlighted');8026var posOffset; // HTML5 with jQuery - e.offsetX is undefined in Firefox8027
8028if (event.offsetX === undefined) {8029var posCatcher = external_jQuery_default()(event.target).offset();8030posOffset = {8031x: event.pageX - posCatcher.left,8032y: event.pageY - posCatcher.top8033};8034} else {8035posOffset = {8036x: event.offsetX,8037y: event.offsetY8038};8039}8040
8041var dim = {8042c: Math.ceil(posOffset.x / PX_PER_EM) || 1,8043r: Math.ceil(posOffset.y / PX_PER_EM) || 18044};8045$highlighted.css({8046width: dim.c + 'em',8047height: dim.r + 'em'8048});8049$catcher.data('value', dim.c + 'x' + dim.r);8050
8051if (dim.c > 3 && dim.c < this.options.insertTableMaxSize.col) {8052$unhighlighted.css({8053width: dim.c + 1 + 'em'8054});8055}8056
8057if (dim.r > 3 && dim.r < this.options.insertTableMaxSize.row) {8058$unhighlighted.css({8059height: dim.r + 1 + 'em'8060});8061}8062
8063$dimensionDisplay.html(dim.c + ' x ' + dim.r);8064}8065}]);8066
8067return Buttons;8068}();8069
8070
8071;// CONCATENATED MODULE: ./src/js/module/Toolbar.js8072function Toolbar_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }8073
8074function Toolbar_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); } }8075
8076function Toolbar_createClass(Constructor, protoProps, staticProps) { if (protoProps) Toolbar_defineProperties(Constructor.prototype, protoProps); if (staticProps) Toolbar_defineProperties(Constructor, staticProps); return Constructor; }8077
8078
8079
8080var Toolbar = /*#__PURE__*/function () {8081function Toolbar(context) {8082Toolbar_classCallCheck(this, Toolbar);8083
8084this.context = context;8085this.$window = external_jQuery_default()(window);8086this.$document = external_jQuery_default()(document);8087this.ui = (external_jQuery_default()).summernote.ui;8088this.$note = context.layoutInfo.note;8089this.$editor = context.layoutInfo.editor;8090this.$toolbar = context.layoutInfo.toolbar;8091this.$editable = context.layoutInfo.editable;8092this.$statusbar = context.layoutInfo.statusbar;8093this.options = context.options;8094this.isFollowing = false;8095this.followScroll = this.followScroll.bind(this);8096}8097
8098Toolbar_createClass(Toolbar, [{8099key: "shouldInitialize",8100value: function shouldInitialize() {8101return !this.options.airMode;8102}8103}, {8104key: "initialize",8105value: function initialize() {8106var _this = this;8107
8108this.options.toolbar = this.options.toolbar || [];8109
8110if (!this.options.toolbar.length) {8111this.$toolbar.hide();8112} else {8113this.context.invoke('buttons.build', this.$toolbar, this.options.toolbar);8114}8115
8116if (this.options.toolbarContainer) {8117this.$toolbar.appendTo(this.options.toolbarContainer);8118}8119
8120this.changeContainer(false);8121this.$note.on('summernote.keyup summernote.mouseup summernote.change', function () {8122_this.context.invoke('buttons.updateCurrentStyle');8123});8124this.context.invoke('buttons.updateCurrentStyle');8125
8126if (this.options.followingToolbar) {8127this.$window.on('scroll resize', this.followScroll);8128}8129}8130}, {8131key: "destroy",8132value: function destroy() {8133this.$toolbar.children().remove();8134
8135if (this.options.followingToolbar) {8136this.$window.off('scroll resize', this.followScroll);8137}8138}8139}, {8140key: "followScroll",8141value: function followScroll() {8142if (this.$editor.hasClass('fullscreen')) {8143return false;8144}8145
8146var editorHeight = this.$editor.outerHeight();8147var editorWidth = this.$editor.width();8148var toolbarHeight = this.$toolbar.height();8149var statusbarHeight = this.$statusbar.height(); // check if the web app is currently using another static bar8150
8151var otherBarHeight = 0;8152
8153if (this.options.otherStaticBar) {8154otherBarHeight = external_jQuery_default()(this.options.otherStaticBar).outerHeight();8155}8156
8157var currentOffset = this.$document.scrollTop();8158var editorOffsetTop = this.$editor.offset().top;8159var editorOffsetBottom = editorOffsetTop + editorHeight;8160var activateOffset = editorOffsetTop - otherBarHeight;8161var deactivateOffsetBottom = editorOffsetBottom - otherBarHeight - toolbarHeight - statusbarHeight;8162
8163if (!this.isFollowing && currentOffset > activateOffset && currentOffset < deactivateOffsetBottom - toolbarHeight) {8164this.isFollowing = true;8165this.$editable.css({8166marginTop: this.$toolbar.outerHeight()8167});8168this.$toolbar.css({8169position: 'fixed',8170top: otherBarHeight,8171width: editorWidth,8172zIndex: 10008173});8174} else if (this.isFollowing && (currentOffset < activateOffset || currentOffset > deactivateOffsetBottom)) {8175this.isFollowing = false;8176this.$toolbar.css({8177position: 'relative',8178top: 0,8179width: '100%',8180zIndex: 'auto'8181});8182this.$editable.css({8183marginTop: ''8184});8185}8186}8187}, {8188key: "changeContainer",8189value: function changeContainer(isFullscreen) {8190if (isFullscreen) {8191this.$toolbar.prependTo(this.$editor);8192} else {8193if (this.options.toolbarContainer) {8194this.$toolbar.appendTo(this.options.toolbarContainer);8195}8196}8197
8198if (this.options.followingToolbar) {8199this.followScroll();8200}8201}8202}, {8203key: "updateFullscreen",8204value: function updateFullscreen(isFullscreen) {8205this.ui.toggleBtnActive(this.$toolbar.find('.btn-fullscreen'), isFullscreen);8206this.changeContainer(isFullscreen);8207}8208}, {8209key: "updateCodeview",8210value: function updateCodeview(isCodeview) {8211this.ui.toggleBtnActive(this.$toolbar.find('.btn-codeview'), isCodeview);8212
8213if (isCodeview) {8214this.deactivate();8215} else {8216this.activate();8217}8218}8219}, {8220key: "activate",8221value: function activate(isIncludeCodeview) {8222var $btn = this.$toolbar.find('button');8223
8224if (!isIncludeCodeview) {8225$btn = $btn.not('.note-codeview-keep');8226}8227
8228this.ui.toggleBtn($btn, true);8229}8230}, {8231key: "deactivate",8232value: function deactivate(isIncludeCodeview) {8233var $btn = this.$toolbar.find('button');8234
8235if (!isIncludeCodeview) {8236$btn = $btn.not('.note-codeview-keep');8237}8238
8239this.ui.toggleBtn($btn, false);8240}8241}]);8242
8243return Toolbar;8244}();8245
8246
8247;// CONCATENATED MODULE: ./src/js/module/LinkDialog.js8248function LinkDialog_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }8249
8250function LinkDialog_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); } }8251
8252function LinkDialog_createClass(Constructor, protoProps, staticProps) { if (protoProps) LinkDialog_defineProperties(Constructor.prototype, protoProps); if (staticProps) LinkDialog_defineProperties(Constructor, staticProps); return Constructor; }8253
8254
8255
8256
8257
8258
8259var LinkDialog = /*#__PURE__*/function () {8260function LinkDialog(context) {8261LinkDialog_classCallCheck(this, LinkDialog);8262
8263this.context = context;8264this.ui = (external_jQuery_default()).summernote.ui;8265this.$body = external_jQuery_default()(document.body);8266this.$editor = context.layoutInfo.editor;8267this.options = context.options;8268this.lang = this.options.langInfo;8269context.memo('help.linkDialog.show', this.options.langInfo.help['linkDialog.show']);8270}8271
8272LinkDialog_createClass(LinkDialog, [{8273key: "initialize",8274value: function initialize() {8275var $container = this.options.dialogsInBody ? this.$body : this.options.container;8276var body = ['<div class="form-group note-form-group">', "<label for=\"note-dialog-link-txt-".concat(this.options.id, "\" class=\"note-form-label\">").concat(this.lang.link.textToDisplay, "</label>"), "<input id=\"note-dialog-link-txt-".concat(this.options.id, "\" class=\"note-link-text form-control note-form-control note-input\" type=\"text\"/>"), '</div>', '<div class="form-group note-form-group">', "<label for=\"note-dialog-link-url-".concat(this.options.id, "\" class=\"note-form-label\">").concat(this.lang.link.url, "</label>"), "<input id=\"note-dialog-link-url-".concat(this.options.id, "\" class=\"note-link-url form-control note-form-control note-input\" type=\"text\" value=\"http://\"/>"), '</div>', !this.options.disableLinkTarget ? external_jQuery_default()('<div></div>').append(this.ui.checkbox({8277className: 'sn-checkbox-open-in-new-window',8278text: this.lang.link.openInNewWindow,8279checked: true8280}).render()).html() : '', external_jQuery_default()('<div></div>').append(this.ui.checkbox({8281className: 'sn-checkbox-use-protocol',8282text: this.lang.link.useProtocol,8283checked: true8284}).render()).html()].join('');8285var buttonClass = 'btn btn-primary note-btn note-btn-primary note-link-btn';8286var footer = "<input type=\"button\" href=\"#\" class=\"".concat(buttonClass, "\" value=\"").concat(this.lang.link.insert, "\" disabled>");8287this.$dialog = this.ui.dialog({8288className: 'link-dialog',8289title: this.lang.link.insert,8290fade: this.options.dialogsFade,8291body: body,8292footer: footer8293}).render().appendTo($container);8294}8295}, {8296key: "destroy",8297value: function destroy() {8298this.ui.hideDialog(this.$dialog);8299this.$dialog.remove();8300}8301}, {8302key: "bindEnterKey",8303value: function bindEnterKey($input, $btn) {8304$input.on('keypress', function (event) {8305if (event.keyCode === key.code.ENTER) {8306event.preventDefault();8307$btn.trigger('click');8308}8309});8310}8311/**8312* toggle update button
8313*/
8314
8315}, {8316key: "toggleLinkBtn",8317value: function toggleLinkBtn($linkBtn, $linkText, $linkUrl) {8318this.ui.toggleBtn($linkBtn, $linkText.val() && $linkUrl.val());8319}8320/**8321* Show link dialog and set event handlers on dialog controls.
8322*
8323* @param {Object} linkInfo
8324* @return {Promise}
8325*/
8326
8327}, {8328key: "showLinkDialog",8329value: function showLinkDialog(linkInfo) {8330var _this = this;8331
8332return external_jQuery_default().Deferred(function (deferred) {8333var $linkText = _this.$dialog.find('.note-link-text');8334
8335var $linkUrl = _this.$dialog.find('.note-link-url');8336
8337var $linkBtn = _this.$dialog.find('.note-link-btn');8338
8339var $openInNewWindow = _this.$dialog.find('.sn-checkbox-open-in-new-window input[type=checkbox]');8340
8341var $useProtocol = _this.$dialog.find('.sn-checkbox-use-protocol input[type=checkbox]');8342
8343_this.ui.onDialogShown(_this.$dialog, function () {8344_this.context.triggerEvent('dialog.shown'); // If no url was given and given text is valid URL then copy that into URL Field8345
8346
8347if (!linkInfo.url && func.isValidUrl(linkInfo.text)) {8348linkInfo.url = linkInfo.text;8349}8350
8351$linkText.on('input paste propertychange', function () {8352// If linktext was modified by input events,8353// cloning text from linkUrl will be stopped.8354linkInfo.text = $linkText.val();8355
8356_this.toggleLinkBtn($linkBtn, $linkText, $linkUrl);8357}).val(linkInfo.text);8358$linkUrl.on('input paste propertychange', function () {8359// Display same text on `Text to display` as default8360// when linktext has no text8361if (!linkInfo.text) {8362$linkText.val($linkUrl.val());8363}8364
8365_this.toggleLinkBtn($linkBtn, $linkText, $linkUrl);8366}).val(linkInfo.url);8367
8368if (!env.isSupportTouch) {8369$linkUrl.trigger('focus');8370}8371
8372_this.toggleLinkBtn($linkBtn, $linkText, $linkUrl);8373
8374_this.bindEnterKey($linkUrl, $linkBtn);8375
8376_this.bindEnterKey($linkText, $linkBtn);8377
8378var isNewWindowChecked = linkInfo.isNewWindow !== undefined ? linkInfo.isNewWindow : _this.context.options.linkTargetBlank;8379$openInNewWindow.prop('checked', isNewWindowChecked);8380var useProtocolChecked = linkInfo.url ? false : _this.context.options.useProtocol;8381$useProtocol.prop('checked', useProtocolChecked);8382$linkBtn.one('click', function (event) {8383event.preventDefault();8384deferred.resolve({8385range: linkInfo.range,8386url: $linkUrl.val(),8387text: $linkText.val(),8388isNewWindow: $openInNewWindow.is(':checked'),8389checkProtocol: $useProtocol.is(':checked')8390});8391
8392_this.ui.hideDialog(_this.$dialog);8393});8394});8395
8396_this.ui.onDialogHidden(_this.$dialog, function () {8397// detach events8398$linkText.off();8399$linkUrl.off();8400$linkBtn.off();8401
8402if (deferred.state() === 'pending') {8403deferred.reject();8404}8405});8406
8407_this.ui.showDialog(_this.$dialog);8408}).promise();8409}8410/**8411* @param {Object} layoutInfo
8412*/
8413
8414}, {8415key: "show",8416value: function show() {8417var _this2 = this;8418
8419var linkInfo = this.context.invoke('editor.getLinkInfo');8420this.context.invoke('editor.saveRange');8421this.showLinkDialog(linkInfo).then(function (linkInfo) {8422_this2.context.invoke('editor.restoreRange');8423
8424_this2.context.invoke('editor.createLink', linkInfo);8425}).fail(function () {8426_this2.context.invoke('editor.restoreRange');8427});8428}8429}]);8430
8431return LinkDialog;8432}();8433
8434
8435;// CONCATENATED MODULE: ./src/js/module/LinkPopover.js8436function LinkPopover_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }8437
8438function LinkPopover_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); } }8439
8440function LinkPopover_createClass(Constructor, protoProps, staticProps) { if (protoProps) LinkPopover_defineProperties(Constructor.prototype, protoProps); if (staticProps) LinkPopover_defineProperties(Constructor, staticProps); return Constructor; }8441
8442
8443
8444
8445
8446var LinkPopover = /*#__PURE__*/function () {8447function LinkPopover(context) {8448var _this = this;8449
8450LinkPopover_classCallCheck(this, LinkPopover);8451
8452this.context = context;8453this.ui = (external_jQuery_default()).summernote.ui;8454this.options = context.options;8455this.events = {8456'summernote.keyup summernote.mouseup summernote.change summernote.scroll': function summernoteKeyupSummernoteMouseupSummernoteChangeSummernoteScroll() {8457_this.update();8458},8459'summernote.disable summernote.dialog.shown': function summernoteDisableSummernoteDialogShown() {8460_this.hide();8461},8462'summernote.blur': function summernoteBlur(we, e) {8463if (e.originalEvent && e.originalEvent.relatedTarget) {8464if (!_this.$popover[0].contains(e.originalEvent.relatedTarget)) {8465_this.hide();8466}8467} else {8468_this.hide();8469}8470}8471};8472}8473
8474LinkPopover_createClass(LinkPopover, [{8475key: "shouldInitialize",8476value: function shouldInitialize() {8477return !lists.isEmpty(this.options.popover.link);8478}8479}, {8480key: "initialize",8481value: function initialize() {8482this.$popover = this.ui.popover({8483className: 'note-link-popover',8484callback: function callback($node) {8485var $content = $node.find('.popover-content,.note-popover-content');8486$content.prepend('<span><a target="_blank"></a> </span>');8487}8488}).render().appendTo(this.options.container);8489var $content = this.$popover.find('.popover-content,.note-popover-content');8490this.context.invoke('buttons.build', $content, this.options.popover.link);8491this.$popover.on('mousedown', function (e) {8492e.preventDefault();8493});8494}8495}, {8496key: "destroy",8497value: function destroy() {8498this.$popover.remove();8499}8500}, {8501key: "update",8502value: function update() {8503// Prevent focusing on editable when invoke('code') is executed8504if (!this.context.invoke('editor.hasFocus')) {8505this.hide();8506return;8507}8508
8509var rng = this.context.invoke('editor.getLastRange');8510
8511if (rng.isCollapsed() && rng.isOnAnchor()) {8512var anchor = dom.ancestor(rng.sc, dom.isAnchor);8513var href = external_jQuery_default()(anchor).attr('href');8514this.$popover.find('a').attr('href', href).text(href);8515var pos = dom.posFromPlaceholder(anchor);8516var containerOffset = external_jQuery_default()(this.options.container).offset();8517pos.top -= containerOffset.top;8518pos.left -= containerOffset.left;8519this.$popover.css({8520display: 'block',8521left: pos.left,8522top: pos.top8523});8524} else {8525this.hide();8526}8527}8528}, {8529key: "hide",8530value: function hide() {8531this.$popover.hide();8532}8533}]);8534
8535return LinkPopover;8536}();8537
8538
8539;// CONCATENATED MODULE: ./src/js/module/ImageDialog.js8540function ImageDialog_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }8541
8542function ImageDialog_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); } }8543
8544function ImageDialog_createClass(Constructor, protoProps, staticProps) { if (protoProps) ImageDialog_defineProperties(Constructor.prototype, protoProps); if (staticProps) ImageDialog_defineProperties(Constructor, staticProps); return Constructor; }8545
8546
8547
8548
8549
8550var ImageDialog = /*#__PURE__*/function () {8551function ImageDialog(context) {8552ImageDialog_classCallCheck(this, ImageDialog);8553
8554this.context = context;8555this.ui = (external_jQuery_default()).summernote.ui;8556this.$body = external_jQuery_default()(document.body);8557this.$editor = context.layoutInfo.editor;8558this.options = context.options;8559this.lang = this.options.langInfo;8560}8561
8562ImageDialog_createClass(ImageDialog, [{8563key: "initialize",8564value: function initialize() {8565var imageLimitation = '';8566
8567if (this.options.maximumImageFileSize) {8568var unit = Math.floor(Math.log(this.options.maximumImageFileSize) / Math.log(1024));8569var readableSize = (this.options.maximumImageFileSize / Math.pow(1024, unit)).toFixed(2) * 1 + ' ' + ' KMGTP'[unit] + 'B';8570imageLimitation = "<small>".concat(this.lang.image.maximumFileSize + ' : ' + readableSize, "</small>");8571}8572
8573var $container = this.options.dialogsInBody ? this.$body : this.options.container;8574var body = ['<div class="form-group note-form-group note-group-select-from-files">', '<label for="note-dialog-image-file-' + this.options.id + '" class="note-form-label">' + this.lang.image.selectFromFiles + '</label>', '<input id="note-dialog-image-file-' + this.options.id + '" class="note-image-input form-control-file note-form-control note-input" ', ' type="file" name="files" accept="' + this.options.acceptImageFileTypes + '" multiple="multiple"/>', imageLimitation, '</div>', '<div class="form-group note-group-image-url">', '<label for="note-dialog-image-url-' + this.options.id + '" class="note-form-label">' + this.lang.image.url + '</label>', '<input id="note-dialog-image-url-' + this.options.id + '" class="note-image-url form-control note-form-control note-input" type="text"/>', '</div>'].join('');8575var buttonClass = 'btn btn-primary note-btn note-btn-primary note-image-btn';8576var footer = "<input type=\"button\" href=\"#\" class=\"".concat(buttonClass, "\" value=\"").concat(this.lang.image.insert, "\" disabled>");8577this.$dialog = this.ui.dialog({8578title: this.lang.image.insert,8579fade: this.options.dialogsFade,8580body: body,8581footer: footer8582}).render().appendTo($container);8583}8584}, {8585key: "destroy",8586value: function destroy() {8587this.ui.hideDialog(this.$dialog);8588this.$dialog.remove();8589}8590}, {8591key: "bindEnterKey",8592value: function bindEnterKey($input, $btn) {8593$input.on('keypress', function (event) {8594if (event.keyCode === key.code.ENTER) {8595event.preventDefault();8596$btn.trigger('click');8597}8598});8599}8600}, {8601key: "show",8602value: function show() {8603var _this = this;8604
8605this.context.invoke('editor.saveRange');8606this.showImageDialog().then(function (data) {8607// [workaround] hide dialog before restore range for IE range focus8608_this.ui.hideDialog(_this.$dialog);8609
8610_this.context.invoke('editor.restoreRange');8611
8612if (typeof data === 'string') {8613// image url8614// If onImageLinkInsert set,8615if (_this.options.callbacks.onImageLinkInsert) {8616_this.context.triggerEvent('image.link.insert', data);8617} else {8618_this.context.invoke('editor.insertImage', data);8619}8620} else {8621// array of files8622_this.context.invoke('editor.insertImagesOrCallback', data);8623}8624}).fail(function () {8625_this.context.invoke('editor.restoreRange');8626});8627}8628/**8629* show image dialog
8630*
8631* @param {jQuery} $dialog
8632* @return {Promise}
8633*/
8634
8635}, {8636key: "showImageDialog",8637value: function showImageDialog() {8638var _this2 = this;8639
8640return external_jQuery_default().Deferred(function (deferred) {8641var $imageInput = _this2.$dialog.find('.note-image-input');8642
8643var $imageUrl = _this2.$dialog.find('.note-image-url');8644
8645var $imageBtn = _this2.$dialog.find('.note-image-btn');8646
8647_this2.ui.onDialogShown(_this2.$dialog, function () {8648_this2.context.triggerEvent('dialog.shown'); // Cloning imageInput to clear element.8649
8650
8651$imageInput.replaceWith($imageInput.clone().on('change', function (event) {8652deferred.resolve(event.target.files || event.target.value);8653}).val(''));8654$imageUrl.on('input paste propertychange', function () {8655_this2.ui.toggleBtn($imageBtn, $imageUrl.val());8656}).val('');8657
8658if (!env.isSupportTouch) {8659$imageUrl.trigger('focus');8660}8661
8662$imageBtn.click(function (event) {8663event.preventDefault();8664deferred.resolve($imageUrl.val());8665});8666
8667_this2.bindEnterKey($imageUrl, $imageBtn);8668});8669
8670_this2.ui.onDialogHidden(_this2.$dialog, function () {8671$imageInput.off();8672$imageUrl.off();8673$imageBtn.off();8674
8675if (deferred.state() === 'pending') {8676deferred.reject();8677}8678});8679
8680_this2.ui.showDialog(_this2.$dialog);8681});8682}8683}]);8684
8685return ImageDialog;8686}();8687
8688
8689;// CONCATENATED MODULE: ./src/js/module/ImagePopover.js8690function ImagePopover_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }8691
8692function ImagePopover_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); } }8693
8694function ImagePopover_createClass(Constructor, protoProps, staticProps) { if (protoProps) ImagePopover_defineProperties(Constructor.prototype, protoProps); if (staticProps) ImagePopover_defineProperties(Constructor, staticProps); return Constructor; }8695
8696
8697
8698
8699/**
8700* Image popover module
8701* mouse events that show/hide popover will be handled by Handle.js.
8702* Handle.js will receive the events and invoke 'imagePopover.update'.
8703*/
8704
8705var ImagePopover = /*#__PURE__*/function () {8706function ImagePopover(context) {8707var _this = this;8708
8709ImagePopover_classCallCheck(this, ImagePopover);8710
8711this.context = context;8712this.ui = (external_jQuery_default()).summernote.ui;8713this.editable = context.layoutInfo.editable[0];8714this.options = context.options;8715this.events = {8716'summernote.disable summernote.dialog.shown': function summernoteDisableSummernoteDialogShown() {8717_this.hide();8718},8719'summernote.blur': function summernoteBlur(we, e) {8720if (e.originalEvent && e.originalEvent.relatedTarget) {8721if (!_this.$popover[0].contains(e.originalEvent.relatedTarget)) {8722_this.hide();8723}8724} else {8725_this.hide();8726}8727}8728};8729}8730
8731ImagePopover_createClass(ImagePopover, [{8732key: "shouldInitialize",8733value: function shouldInitialize() {8734return !lists.isEmpty(this.options.popover.image);8735}8736}, {8737key: "initialize",8738value: function initialize() {8739this.$popover = this.ui.popover({8740className: 'note-image-popover'8741}).render().appendTo(this.options.container);8742var $content = this.$popover.find('.popover-content,.note-popover-content');8743this.context.invoke('buttons.build', $content, this.options.popover.image);8744this.$popover.on('mousedown', function (e) {8745e.preventDefault();8746});8747}8748}, {8749key: "destroy",8750value: function destroy() {8751this.$popover.remove();8752}8753}, {8754key: "update",8755value: function update(target, event) {8756if (dom.isImg(target)) {8757var position = external_jQuery_default()(target).offset();8758var containerOffset = external_jQuery_default()(this.options.container).offset();8759var pos = {};8760
8761if (this.options.popatmouse) {8762pos.left = event.pageX - 20;8763pos.top = event.pageY;8764} else {8765pos = position;8766}8767
8768pos.top -= containerOffset.top;8769pos.left -= containerOffset.left;8770this.$popover.css({8771display: 'block',8772left: pos.left,8773top: pos.top8774});8775} else {8776this.hide();8777}8778}8779}, {8780key: "hide",8781value: function hide() {8782this.$popover.hide();8783}8784}]);8785
8786return ImagePopover;8787}();8788
8789
8790;// CONCATENATED MODULE: ./src/js/module/TablePopover.js8791function TablePopover_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }8792
8793function TablePopover_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); } }8794
8795function TablePopover_createClass(Constructor, protoProps, staticProps) { if (protoProps) TablePopover_defineProperties(Constructor.prototype, protoProps); if (staticProps) TablePopover_defineProperties(Constructor, staticProps); return Constructor; }8796
8797
8798
8799
8800
8801
8802var TablePopover = /*#__PURE__*/function () {8803function TablePopover(context) {8804var _this = this;8805
8806TablePopover_classCallCheck(this, TablePopover);8807
8808this.context = context;8809this.ui = (external_jQuery_default()).summernote.ui;8810this.options = context.options;8811this.events = {8812'summernote.mousedown': function summernoteMousedown(we, e) {8813_this.update(e.target);8814},8815'summernote.keyup summernote.scroll summernote.change': function summernoteKeyupSummernoteScrollSummernoteChange() {8816_this.update();8817},8818'summernote.disable summernote.dialog.shown': function summernoteDisableSummernoteDialogShown() {8819_this.hide();8820},8821'summernote.blur': function summernoteBlur(we, e) {8822if (e.originalEvent && e.originalEvent.relatedTarget) {8823if (!_this.$popover[0].contains(e.originalEvent.relatedTarget)) {8824_this.hide();8825}8826} else {8827_this.hide();8828}8829}8830};8831}8832
8833TablePopover_createClass(TablePopover, [{8834key: "shouldInitialize",8835value: function shouldInitialize() {8836return !lists.isEmpty(this.options.popover.table);8837}8838}, {8839key: "initialize",8840value: function initialize() {8841this.$popover = this.ui.popover({8842className: 'note-table-popover'8843}).render().appendTo(this.options.container);8844var $content = this.$popover.find('.popover-content,.note-popover-content');8845this.context.invoke('buttons.build', $content, this.options.popover.table); // [workaround] Disable Firefox's default table editor8846
8847if (env.isFF) {8848document.execCommand('enableInlineTableEditing', false, false);8849}8850
8851this.$popover.on('mousedown', function (e) {8852e.preventDefault();8853});8854}8855}, {8856key: "destroy",8857value: function destroy() {8858this.$popover.remove();8859}8860}, {8861key: "update",8862value: function update(target) {8863if (this.context.isDisabled()) {8864return false;8865}8866
8867var isCell = dom.isCell(target) || dom.isCell(target === null || target === void 0 ? void 0 : target.parentElement);8868
8869if (isCell) {8870var pos = dom.posFromPlaceholder(target);8871var containerOffset = external_jQuery_default()(this.options.container).offset();8872pos.top -= containerOffset.top;8873pos.left -= containerOffset.left;8874this.$popover.css({8875display: 'block',8876left: pos.left,8877top: pos.top8878});8879} else {8880this.hide();8881}8882
8883return isCell;8884}8885}, {8886key: "hide",8887value: function hide() {8888this.$popover.hide();8889}8890}]);8891
8892return TablePopover;8893}();8894
8895
8896;// CONCATENATED MODULE: ./src/js/module/VideoDialog.js8897function VideoDialog_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }8898
8899function VideoDialog_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); } }8900
8901function VideoDialog_createClass(Constructor, protoProps, staticProps) { if (protoProps) VideoDialog_defineProperties(Constructor.prototype, protoProps); if (staticProps) VideoDialog_defineProperties(Constructor, staticProps); return Constructor; }8902
8903
8904
8905
8906
8907var VideoDialog = /*#__PURE__*/function () {8908function VideoDialog(context) {8909VideoDialog_classCallCheck(this, VideoDialog);8910
8911this.context = context;8912this.ui = (external_jQuery_default()).summernote.ui;8913this.$body = external_jQuery_default()(document.body);8914this.$editor = context.layoutInfo.editor;8915this.options = context.options;8916this.lang = this.options.langInfo;8917}8918
8919VideoDialog_createClass(VideoDialog, [{8920key: "initialize",8921value: function initialize() {8922var $container = this.options.dialogsInBody ? this.$body : this.options.container;8923var body = ['<div class="form-group note-form-group row-fluid">', "<label for=\"note-dialog-video-url-".concat(this.options.id, "\" class=\"note-form-label\">").concat(this.lang.video.url, " <small class=\"text-muted\">").concat(this.lang.video.providers, "</small></label>"), "<input id=\"note-dialog-video-url-".concat(this.options.id, "\" class=\"note-video-url form-control note-form-control note-input\" type=\"text\"/>"), '</div>'].join('');8924var buttonClass = 'btn btn-primary note-btn note-btn-primary note-video-btn';8925var footer = "<input type=\"button\" href=\"#\" class=\"".concat(buttonClass, "\" value=\"").concat(this.lang.video.insert, "\" disabled>");8926this.$dialog = this.ui.dialog({8927title: this.lang.video.insert,8928fade: this.options.dialogsFade,8929body: body,8930footer: footer8931}).render().appendTo($container);8932}8933}, {8934key: "destroy",8935value: function destroy() {8936this.ui.hideDialog(this.$dialog);8937this.$dialog.remove();8938}8939}, {8940key: "bindEnterKey",8941value: function bindEnterKey($input, $btn) {8942$input.on('keypress', function (event) {8943if (event.keyCode === key.code.ENTER) {8944event.preventDefault();8945$btn.trigger('click');8946}8947});8948}8949}, {8950key: "createVideoNode",8951value: function createVideoNode(url) {8952// video url patterns(youtube, instagram, vimeo, dailymotion, youku, peertube, mp4, ogg, webm)8953var ytRegExp = /\/\/(?:(?:www|m)\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))([\w|-]{11})(?:(?:[\?&]t=)(\S+))?$/;8954var ytRegExpForStart = /^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/;8955var ytMatch = url.match(ytRegExp);8956var gdRegExp = /(?:\.|\/\/)drive\.google\.com\/file\/d\/(.[a-zA-Z0-9_-]*)\/view/;8957var gdMatch = url.match(gdRegExp);8958var igRegExp = /(?:www\.|\/\/)instagram\.com\/p\/(.[a-zA-Z0-9_-]*)/;8959var igMatch = url.match(igRegExp);8960var vRegExp = /\/\/vine\.co\/v\/([a-zA-Z0-9]+)/;8961var vMatch = url.match(vRegExp);8962var vimRegExp = /\/\/(player\.)?vimeo\.com\/([a-z]*\/)*(\d+)[?]?.*/;8963var vimMatch = url.match(vimRegExp);8964var dmRegExp = /.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/;8965var dmMatch = url.match(dmRegExp);8966var youkuRegExp = /\/\/v\.youku\.com\/v_show\/id_(\w+)=*\.html/;8967var youkuMatch = url.match(youkuRegExp);8968var peerTubeRegExp = /\/\/(.*)\/videos\/watch\/([^?]*)(?:\?(?:start=(\w*))?(?:&stop=(\w*))?(?:&loop=([10]))?(?:&autoplay=([10]))?(?:&muted=([10]))?)?/;8969var peerTubeMatch = url.match(peerTubeRegExp);8970var qqRegExp = /\/\/v\.qq\.com.*?vid=(.+)/;8971var qqMatch = url.match(qqRegExp);8972var qqRegExp2 = /\/\/v\.qq\.com\/x?\/?(page|cover).*?\/([^\/]+)\.html\??.*/;8973var qqMatch2 = url.match(qqRegExp2);8974var mp4RegExp = /^.+.(mp4|m4v)$/;8975var mp4Match = url.match(mp4RegExp);8976var oggRegExp = /^.+.(ogg|ogv)$/;8977var oggMatch = url.match(oggRegExp);8978var webmRegExp = /^.+.(webm)$/;8979var webmMatch = url.match(webmRegExp);8980var fbRegExp = /(?:www\.|\/\/)facebook\.com\/([^\/]+)\/videos\/([0-9]+)/;8981var fbMatch = url.match(fbRegExp);8982var $video;8983
8984if (ytMatch && ytMatch[1].length === 11) {8985var youtubeId = ytMatch[1];8986var start = 0;8987
8988if (typeof ytMatch[2] !== 'undefined') {8989var ytMatchForStart = ytMatch[2].match(ytRegExpForStart);8990
8991if (ytMatchForStart) {8992for (var n = [3600, 60, 1], i = 0, r = n.length; i < r; i++) {8993start += typeof ytMatchForStart[i + 1] !== 'undefined' ? n[i] * parseInt(ytMatchForStart[i + 1], 10) : 0;8994}8995}8996}8997
8998$video = external_jQuery_default()('<iframe>').attr('frameborder', 0).attr('src', '//www.youtube.com/embed/' + youtubeId + (start > 0 ? '?start=' + start : '')).attr('width', '640').attr('height', '360');8999} else if (gdMatch && gdMatch[0].length) {9000$video = external_jQuery_default()('<iframe>').attr('frameborder', 0).attr('src', 'https://drive.google.com/file/d/' + gdMatch[1] + '/preview').attr('width', '640').attr('height', '480');9001} else if (igMatch && igMatch[0].length) {9002$video = external_jQuery_default()('<iframe>').attr('frameborder', 0).attr('src', 'https://instagram.com/p/' + igMatch[1] + '/embed/').attr('width', '612').attr('height', '710').attr('scrolling', 'no').attr('allowtransparency', 'true');9003} else if (vMatch && vMatch[0].length) {9004$video = external_jQuery_default()('<iframe>').attr('frameborder', 0).attr('src', vMatch[0] + '/embed/simple').attr('width', '600').attr('height', '600').attr('class', 'vine-embed');9005} else if (vimMatch && vimMatch[3].length) {9006$video = external_jQuery_default()('<iframe webkitallowfullscreen mozallowfullscreen allowfullscreen>').attr('frameborder', 0).attr('src', '//player.vimeo.com/video/' + vimMatch[3]).attr('width', '640').attr('height', '360');9007} else if (dmMatch && dmMatch[2].length) {9008$video = external_jQuery_default()('<iframe>').attr('frameborder', 0).attr('src', '//www.dailymotion.com/embed/video/' + dmMatch[2]).attr('width', '640').attr('height', '360');9009} else if (youkuMatch && youkuMatch[1].length) {9010$video = external_jQuery_default()('<iframe webkitallowfullscreen mozallowfullscreen allowfullscreen>').attr('frameborder', 0).attr('height', '498').attr('width', '510').attr('src', '//player.youku.com/embed/' + youkuMatch[1]);9011} else if (peerTubeMatch && peerTubeMatch[0].length) {9012var begin = 0;9013if (peerTubeMatch[2] !== 'undefined') begin = peerTubeMatch[2];9014var end = 0;9015if (peerTubeMatch[3] !== 'undefined') end = peerTubeMatch[3];9016var loop = 0;9017if (peerTubeMatch[4] !== 'undefined') loop = peerTubeMatch[4];9018var autoplay = 0;9019if (peerTubeMatch[5] !== 'undefined') autoplay = peerTubeMatch[5];9020var muted = 0;9021if (peerTubeMatch[6] !== 'undefined') muted = peerTubeMatch[6];9022$video = external_jQuery_default()('<iframe allowfullscreen sandbox="allow-same-origin allow-scripts allow-popups">').attr('frameborder', 0).attr('src', '//' + peerTubeMatch[1] + '/videos/embed/' + peerTubeMatch[2] + "?loop=" + loop + "&autoplay=" + autoplay + "&muted=" + muted + (begin > 0 ? '&start=' + begin : '') + (end > 0 ? '&end=' + start : '')).attr('width', '560').attr('height', '315');9023} else if (qqMatch && qqMatch[1].length || qqMatch2 && qqMatch2[2].length) {9024var vid = qqMatch && qqMatch[1].length ? qqMatch[1] : qqMatch2[2];9025$video = external_jQuery_default()('<iframe webkitallowfullscreen mozallowfullscreen allowfullscreen>').attr('frameborder', 0).attr('height', '310').attr('width', '500').attr('src', 'https://v.qq.com/txp/iframe/player.html?vid=' + vid + '&auto=0');9026} else if (mp4Match || oggMatch || webmMatch) {9027$video = external_jQuery_default()('<video controls>').attr('src', url).attr('width', '640').attr('height', '360');9028} else if (fbMatch && fbMatch[0].length) {9029$video = external_jQuery_default()('<iframe>').attr('frameborder', 0).attr('src', 'https://www.facebook.com/plugins/video.php?href=' + encodeURIComponent(fbMatch[0]) + '&show_text=0&width=560').attr('width', '560').attr('height', '301').attr('scrolling', 'no').attr('allowtransparency', 'true');9030} else {9031// this is not a known video link. Now what, Cat? Now what?9032return false;9033}9034
9035$video.addClass('note-video-clip');9036return $video[0];9037}9038}, {9039key: "show",9040value: function show() {9041var _this = this;9042
9043var text = this.context.invoke('editor.getSelectedText');9044this.context.invoke('editor.saveRange');9045this.showVideoDialog(text).then(function (url) {9046// [workaround] hide dialog before restore range for IE range focus9047_this.ui.hideDialog(_this.$dialog);9048
9049_this.context.invoke('editor.restoreRange'); // build node9050
9051
9052var $node = _this.createVideoNode(url);9053
9054if ($node) {9055// insert video node9056_this.context.invoke('editor.insertNode', $node);9057}9058}).fail(function () {9059_this.context.invoke('editor.restoreRange');9060});9061}9062/**9063* show video dialog
9064*
9065* @param {jQuery} $dialog
9066* @return {Promise}
9067*/
9068
9069}, {9070key: "showVideoDialog",9071value: function showVideoDialog() {9072var _this2 = this;9073
9074return external_jQuery_default().Deferred(function (deferred) {9075var $videoUrl = _this2.$dialog.find('.note-video-url');9076
9077var $videoBtn = _this2.$dialog.find('.note-video-btn');9078
9079_this2.ui.onDialogShown(_this2.$dialog, function () {9080_this2.context.triggerEvent('dialog.shown');9081
9082$videoUrl.on('input paste propertychange', function () {9083_this2.ui.toggleBtn($videoBtn, $videoUrl.val());9084});9085
9086if (!env.isSupportTouch) {9087$videoUrl.trigger('focus');9088}9089
9090$videoBtn.click(function (event) {9091event.preventDefault();9092deferred.resolve($videoUrl.val());9093});9094
9095_this2.bindEnterKey($videoUrl, $videoBtn);9096});9097
9098_this2.ui.onDialogHidden(_this2.$dialog, function () {9099$videoUrl.off();9100$videoBtn.off();9101
9102if (deferred.state() === 'pending') {9103deferred.reject();9104}9105});9106
9107_this2.ui.showDialog(_this2.$dialog);9108});9109}9110}]);9111
9112return VideoDialog;9113}();9114
9115
9116;// CONCATENATED MODULE: ./src/js/module/HelpDialog.js9117function HelpDialog_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }9118
9119function HelpDialog_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); } }9120
9121function HelpDialog_createClass(Constructor, protoProps, staticProps) { if (protoProps) HelpDialog_defineProperties(Constructor.prototype, protoProps); if (staticProps) HelpDialog_defineProperties(Constructor, staticProps); return Constructor; }9122
9123
9124
9125
9126var HelpDialog = /*#__PURE__*/function () {9127function HelpDialog(context) {9128HelpDialog_classCallCheck(this, HelpDialog);9129
9130this.context = context;9131this.ui = (external_jQuery_default()).summernote.ui;9132this.$body = external_jQuery_default()(document.body);9133this.$editor = context.layoutInfo.editor;9134this.options = context.options;9135this.lang = this.options.langInfo;9136}9137
9138HelpDialog_createClass(HelpDialog, [{9139key: "initialize",9140value: function initialize() {9141var $container = this.options.dialogsInBody ? this.$body : this.options.container;9142var body = ['<p class="text-center">', '<a href="http://summernote.org/" target="_blank" rel="noopener noreferrer">Summernote 0.8.20</a> · ', '<a href="https://github.com/summernote/summernote" target="_blank" rel="noopener noreferrer">Project</a> · ', '<a href="https://github.com/summernote/summernote/issues" target="_blank" rel="noopener noreferrer">Issues</a>', '</p>'].join('');9143this.$dialog = this.ui.dialog({9144title: this.lang.options.help,9145fade: this.options.dialogsFade,9146body: this.createShortcutList(),9147footer: body,9148callback: function callback($node) {9149$node.find('.modal-body,.note-modal-body').css({9150'max-height': 300,9151'overflow': 'scroll'9152});9153}9154}).render().appendTo($container);9155}9156}, {9157key: "destroy",9158value: function destroy() {9159this.ui.hideDialog(this.$dialog);9160this.$dialog.remove();9161}9162}, {9163key: "createShortcutList",9164value: function createShortcutList() {9165var _this = this;9166
9167var keyMap = this.options.keyMap[env.isMac ? 'mac' : 'pc'];9168return Object.keys(keyMap).map(function (key) {9169var command = keyMap[key];9170var $row = external_jQuery_default()('<div><div class="help-list-item"></div></div>');9171$row.append(external_jQuery_default()('<label><kbd>' + key + '</kdb></label>').css({9172'width': 180,9173'margin-right': 109174})).append(external_jQuery_default()('<span></span>').html(_this.context.memo('help.' + command) || command));9175return $row.html();9176}).join('');9177}9178/**9179* show help dialog
9180*
9181* @return {Promise}
9182*/
9183
9184}, {9185key: "showHelpDialog",9186value: function showHelpDialog() {9187var _this2 = this;9188
9189return external_jQuery_default().Deferred(function (deferred) {9190_this2.ui.onDialogShown(_this2.$dialog, function () {9191_this2.context.triggerEvent('dialog.shown');9192
9193deferred.resolve();9194});9195
9196_this2.ui.showDialog(_this2.$dialog);9197}).promise();9198}9199}, {9200key: "show",9201value: function show() {9202var _this3 = this;9203
9204this.context.invoke('editor.saveRange');9205this.showHelpDialog().then(function () {9206_this3.context.invoke('editor.restoreRange');9207});9208}9209}]);9210
9211return HelpDialog;9212}();9213
9214
9215;// CONCATENATED MODULE: ./src/js/module/AirPopover.js9216function AirPopover_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }9217
9218function AirPopover_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); } }9219
9220function AirPopover_createClass(Constructor, protoProps, staticProps) { if (protoProps) AirPopover_defineProperties(Constructor.prototype, protoProps); if (staticProps) AirPopover_defineProperties(Constructor, staticProps); return Constructor; }9221
9222
9223
9224var AIRMODE_POPOVER_X_OFFSET = -5;9225var AIRMODE_POPOVER_Y_OFFSET = 5;9226
9227var AirPopover = /*#__PURE__*/function () {9228function AirPopover(context) {9229var _this = this;9230
9231AirPopover_classCallCheck(this, AirPopover);9232
9233this.context = context;9234this.ui = (external_jQuery_default()).summernote.ui;9235this.options = context.options;9236this.hidable = true;9237this.onContextmenu = false;9238this.pageX = null;9239this.pageY = null;9240this.events = {9241'summernote.contextmenu': function summernoteContextmenu(e) {9242if (_this.options.editing) {9243e.preventDefault();9244e.stopPropagation();9245_this.onContextmenu = true;9246
9247_this.update(true);9248}9249},9250'summernote.mousedown': function summernoteMousedown(we, e) {9251_this.pageX = e.pageX;9252_this.pageY = e.pageY;9253},9254'summernote.keyup summernote.mouseup summernote.scroll': function summernoteKeyupSummernoteMouseupSummernoteScroll(we, e) {9255if (_this.options.editing && !_this.onContextmenu) {9256_this.pageX = e.pageX;9257_this.pageY = e.pageY;9258
9259_this.update();9260}9261
9262_this.onContextmenu = false;9263},9264'summernote.disable summernote.change summernote.dialog.shown summernote.blur': function summernoteDisableSummernoteChangeSummernoteDialogShownSummernoteBlur() {9265_this.hide();9266},9267'summernote.focusout': function summernoteFocusout() {9268if (!_this.$popover.is(':active,:focus')) {9269_this.hide();9270}9271}9272};9273}9274
9275AirPopover_createClass(AirPopover, [{9276key: "shouldInitialize",9277value: function shouldInitialize() {9278return this.options.airMode && !lists.isEmpty(this.options.popover.air);9279}9280}, {9281key: "initialize",9282value: function initialize() {9283var _this2 = this;9284
9285this.$popover = this.ui.popover({9286className: 'note-air-popover'9287}).render().appendTo(this.options.container);9288var $content = this.$popover.find('.popover-content');9289this.context.invoke('buttons.build', $content, this.options.popover.air); // disable hiding this popover preemptively by 'summernote.blur' event.9290
9291this.$popover.on('mousedown', function () {9292_this2.hidable = false;9293}); // (re-)enable hiding after 'summernote.blur' has been handled (aka. ignored).9294
9295this.$popover.on('mouseup', function () {9296_this2.hidable = true;9297});9298}9299}, {9300key: "destroy",9301value: function destroy() {9302this.$popover.remove();9303}9304}, {9305key: "update",9306value: function update(forcelyOpen) {9307var styleInfo = this.context.invoke('editor.currentStyle');9308
9309if (styleInfo.range && (!styleInfo.range.isCollapsed() || forcelyOpen)) {9310var rect = {9311left: this.pageX,9312top: this.pageY9313};9314var containerOffset = external_jQuery_default()(this.options.container).offset();9315rect.top -= containerOffset.top;9316rect.left -= containerOffset.left;9317this.$popover.css({9318display: 'block',9319left: Math.max(rect.left, 0) + AIRMODE_POPOVER_X_OFFSET,9320top: rect.top + AIRMODE_POPOVER_Y_OFFSET9321});9322this.context.invoke('buttons.updateCurrentStyle', this.$popover);9323} else {9324this.hide();9325}9326}9327}, {9328key: "updateCodeview",9329value: function updateCodeview(isCodeview) {9330this.ui.toggleBtnActive(this.$popover.find('.btn-codeview'), isCodeview);9331
9332if (isCodeview) {9333this.hide();9334}9335}9336}, {9337key: "hide",9338value: function hide() {9339if (this.hidable) {9340this.$popover.hide();9341}9342}9343}]);9344
9345return AirPopover;9346}();9347
9348
9349;// CONCATENATED MODULE: ./src/js/module/HintPopover.js9350function HintPopover_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }9351
9352function HintPopover_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); } }9353
9354function HintPopover_createClass(Constructor, protoProps, staticProps) { if (protoProps) HintPopover_defineProperties(Constructor.prototype, protoProps); if (staticProps) HintPopover_defineProperties(Constructor, staticProps); return Constructor; }9355
9356
9357
9358
9359
9360
9361
9362var POPOVER_DIST = 5;9363
9364var HintPopover = /*#__PURE__*/function () {9365function HintPopover(context) {9366var _this = this;9367
9368HintPopover_classCallCheck(this, HintPopover);9369
9370this.context = context;9371this.ui = (external_jQuery_default()).summernote.ui;9372this.$editable = context.layoutInfo.editable;9373this.options = context.options;9374this.hint = this.options.hint || [];9375this.direction = this.options.hintDirection || 'bottom';9376this.hints = Array.isArray(this.hint) ? this.hint : [this.hint];9377this.events = {9378'summernote.keyup': function summernoteKeyup(we, e) {9379if (!e.isDefaultPrevented()) {9380_this.handleKeyup(e);9381}9382},9383'summernote.keydown': function summernoteKeydown(we, e) {9384_this.handleKeydown(e);9385},9386'summernote.disable summernote.dialog.shown summernote.blur': function summernoteDisableSummernoteDialogShownSummernoteBlur() {9387_this.hide();9388}9389};9390}9391
9392HintPopover_createClass(HintPopover, [{9393key: "shouldInitialize",9394value: function shouldInitialize() {9395return this.hints.length > 0;9396}9397}, {9398key: "initialize",9399value: function initialize() {9400var _this2 = this;9401
9402this.lastWordRange = null;9403this.matchingWord = null;9404this.$popover = this.ui.popover({9405className: 'note-hint-popover',9406hideArrow: true,9407direction: ''9408}).render().appendTo(this.options.container);9409this.$popover.hide();9410this.$content = this.$popover.find('.popover-content,.note-popover-content');9411this.$content.on('click', '.note-hint-item', function (e) {9412_this2.$content.find('.active').removeClass('active');9413
9414external_jQuery_default()(e.currentTarget).addClass('active');9415
9416_this2.replace();9417});9418this.$popover.on('mousedown', function (e) {9419e.preventDefault();9420});9421}9422}, {9423key: "destroy",9424value: function destroy() {9425this.$popover.remove();9426}9427}, {9428key: "selectItem",9429value: function selectItem($item) {9430this.$content.find('.active').removeClass('active');9431$item.addClass('active');9432this.$content[0].scrollTop = $item[0].offsetTop - this.$content.innerHeight() / 2;9433}9434}, {9435key: "moveDown",9436value: function moveDown() {9437var $current = this.$content.find('.note-hint-item.active');9438var $next = $current.next();9439
9440if ($next.length) {9441this.selectItem($next);9442} else {9443var $nextGroup = $current.parent().next();9444
9445if (!$nextGroup.length) {9446$nextGroup = this.$content.find('.note-hint-group').first();9447}9448
9449this.selectItem($nextGroup.find('.note-hint-item').first());9450}9451}9452}, {9453key: "moveUp",9454value: function moveUp() {9455var $current = this.$content.find('.note-hint-item.active');9456var $prev = $current.prev();9457
9458if ($prev.length) {9459this.selectItem($prev);9460} else {9461var $prevGroup = $current.parent().prev();9462
9463if (!$prevGroup.length) {9464$prevGroup = this.$content.find('.note-hint-group').last();9465}9466
9467this.selectItem($prevGroup.find('.note-hint-item').last());9468}9469}9470}, {9471key: "replace",9472value: function replace() {9473var $item = this.$content.find('.note-hint-item.active');9474
9475if ($item.length) {9476var node = this.nodeFromItem($item); // If matchingWord length = 0 -> capture OK / open hint / but as mention capture "" (\w*)9477
9478if (this.matchingWord !== null && this.matchingWord.length === 0) {9479this.lastWordRange.so = this.lastWordRange.eo; // Else si > 0 and normal case -> adjust range "before" for correct position of insertion9480} else if (this.matchingWord !== null && this.matchingWord.length > 0 && !this.lastWordRange.isCollapsed()) {9481var rangeCompute = this.lastWordRange.eo - this.lastWordRange.so - this.matchingWord.length;9482
9483if (rangeCompute > 0) {9484this.lastWordRange.so += rangeCompute;9485}9486}9487
9488this.lastWordRange.insertNode(node);9489
9490if (this.options.hintSelect === 'next') {9491var blank = document.createTextNode('');9492external_jQuery_default()(node).after(blank);9493range.createFromNodeBefore(blank).select();9494} else {9495range.createFromNodeAfter(node).select();9496}9497
9498this.lastWordRange = null;9499this.hide();9500this.context.invoke('editor.focus');9501this.context.triggerEvent('change', this.$editable.html(), this.$editable);9502}9503}9504}, {9505key: "nodeFromItem",9506value: function nodeFromItem($item) {9507var hint = this.hints[$item.data('index')];9508var item = $item.data('item');9509var node = hint.content ? hint.content(item) : item;9510
9511if (typeof node === 'string') {9512node = dom.createText(node);9513}9514
9515return node;9516}9517}, {9518key: "createItemTemplates",9519value: function createItemTemplates(hintIdx, items) {9520var hint = this.hints[hintIdx];9521return items.map(function (item9522/*, idx */9523) {9524var $item = external_jQuery_default()('<div class="note-hint-item"></div>');9525$item.append(hint.template ? hint.template(item) : item + '');9526$item.data({9527'index': hintIdx,9528'item': item9529});9530return $item;9531});9532}9533}, {9534key: "handleKeydown",9535value: function handleKeydown(e) {9536if (!this.$popover.is(':visible')) {9537return;9538}9539
9540if (e.keyCode === key.code.ENTER) {9541e.preventDefault();9542this.replace();9543} else if (e.keyCode === key.code.UP) {9544e.preventDefault();9545this.moveUp();9546} else if (e.keyCode === key.code.DOWN) {9547e.preventDefault();9548this.moveDown();9549}9550}9551}, {9552key: "searchKeyword",9553value: function searchKeyword(index, keyword, callback) {9554var hint = this.hints[index];9555
9556if (hint && hint.match.test(keyword) && hint.search) {9557var matches = hint.match.exec(keyword);9558this.matchingWord = matches[0];9559hint.search(matches[1], callback);9560} else {9561callback();9562}9563}9564}, {9565key: "createGroup",9566value: function createGroup(idx, keyword) {9567var _this3 = this;9568
9569var $group = external_jQuery_default()('<div class="note-hint-group note-hint-group-' + idx + '"></div>');9570this.searchKeyword(idx, keyword, function (items) {9571items = items || [];9572
9573if (items.length) {9574$group.html(_this3.createItemTemplates(idx, items));9575
9576_this3.show();9577}9578});9579return $group;9580}9581}, {9582key: "handleKeyup",9583value: function handleKeyup(e) {9584var _this4 = this;9585
9586if (!lists.contains([key.code.ENTER, key.code.UP, key.code.DOWN], e.keyCode)) {9587var _range = this.context.invoke('editor.getLastRange');9588
9589var wordRange, keyword;9590
9591if (this.options.hintMode === 'words') {9592wordRange = _range.getWordsRange(_range);9593keyword = wordRange.toString();9594this.hints.forEach(function (hint) {9595if (hint.match.test(keyword)) {9596wordRange = _range.getWordsMatchRange(hint.match);9597return false;9598}9599});9600
9601if (!wordRange) {9602this.hide();9603return;9604}9605
9606keyword = wordRange.toString();9607} else {9608wordRange = _range.getWordRange();9609keyword = wordRange.toString();9610}9611
9612if (this.hints.length && keyword) {9613this.$content.empty();9614var bnd = func.rect2bnd(lists.last(wordRange.getClientRects()));9615var containerOffset = external_jQuery_default()(this.options.container).offset();9616
9617if (bnd) {9618bnd.top -= containerOffset.top;9619bnd.left -= containerOffset.left;9620this.$popover.hide();9621this.lastWordRange = wordRange;9622this.hints.forEach(function (hint, idx) {9623if (hint.match.test(keyword)) {9624_this4.createGroup(idx, keyword).appendTo(_this4.$content);9625}9626}); // select first .note-hint-item9627
9628this.$content.find('.note-hint-item:first').addClass('active'); // set position for popover after group is created9629
9630if (this.direction === 'top') {9631this.$popover.css({9632left: bnd.left,9633top: bnd.top - this.$popover.outerHeight() - POPOVER_DIST9634});9635} else {9636this.$popover.css({9637left: bnd.left,9638top: bnd.top + bnd.height + POPOVER_DIST9639});9640}9641}9642} else {9643this.hide();9644}9645}9646}9647}, {9648key: "show",9649value: function show() {9650this.$popover.show();9651}9652}, {9653key: "hide",9654value: function hide() {9655this.$popover.hide();9656}9657}]);9658
9659return HintPopover;9660}();9661
9662
9663;// CONCATENATED MODULE: ./src/js/settings.js9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692(external_jQuery_default()).summernote = external_jQuery_default().extend((external_jQuery_default()).summernote, {9693version: '0.8.20',9694plugins: {},9695dom: dom,9696range: range,9697lists: lists,9698options: {9699langInfo: (external_jQuery_default()).summernote.lang["en-US"],9700editing: true,9701modules: {9702'editor': Editor,9703'clipboard': Clipboard,9704'dropzone': Dropzone,9705'codeview': CodeView,9706'statusbar': Statusbar,9707'fullscreen': Fullscreen,9708'handle': Handle,9709// FIXME: HintPopover must be front of autolink9710// - Script error about range when Enter key is pressed on hint popover9711'hintPopover': HintPopover,9712'autoLink': AutoLink,9713'autoSync': AutoSync,9714'autoReplace': AutoReplace,9715'placeholder': Placeholder,9716'buttons': Buttons,9717'toolbar': Toolbar,9718'linkDialog': LinkDialog,9719'linkPopover': LinkPopover,9720'imageDialog': ImageDialog,9721'imagePopover': ImagePopover,9722'tablePopover': TablePopover,9723'videoDialog': VideoDialog,9724'helpDialog': HelpDialog,9725'airPopover': AirPopover9726},9727buttons: {},9728lang: 'en-US',9729followingToolbar: false,9730toolbarPosition: 'top',9731otherStaticBar: '',9732// toolbar9733codeviewKeepButton: false,9734toolbar: [['style', ['style']], ['font', ['bold', 'underline', 'clear']], ['fontname', ['fontname']], ['color', ['color']], ['para', ['ul', 'ol', 'paragraph']], ['table', ['table']], ['insert', ['link', 'picture', 'video']], ['view', ['fullscreen', 'codeview', 'help']]],9735// popover9736popatmouse: true,9737popover: {9738image: [['resize', ['resizeFull', 'resizeHalf', 'resizeQuarter', 'resizeNone']], ['float', ['floatLeft', 'floatRight', 'floatNone']], ['remove', ['removeMedia']]],9739link: [['link', ['linkDialogShow', 'unlink']]],9740table: [['add', ['addRowDown', 'addRowUp', 'addColLeft', 'addColRight']], ['delete', ['deleteRow', 'deleteCol', 'deleteTable']]],9741air: [['color', ['color']], ['font', ['bold', 'underline', 'clear']], ['para', ['ul', 'paragraph']], ['table', ['table']], ['insert', ['link', 'picture']], ['view', ['fullscreen', 'codeview']]]9742},9743// air mode: inline editor9744airMode: false,9745overrideContextMenu: false,9746// TBD9747width: null,9748height: null,9749linkTargetBlank: true,9750useProtocol: true,9751defaultProtocol: 'http://',9752focus: false,9753tabDisabled: false,9754tabSize: 4,9755styleWithCSS: false,9756shortcuts: true,9757textareaAutoSync: true,9758tooltip: 'auto',9759container: null,9760maxTextLength: 0,9761blockquoteBreakingLevel: 2,9762spellCheck: true,9763disableGrammar: false,9764placeholder: null,9765inheritPlaceholder: false,9766// TODO: need to be documented9767recordEveryKeystroke: false,9768historyLimit: 200,9769// TODO: need to be documented9770showDomainOnlyForAutolink: false,9771// TODO: need to be documented9772hintMode: 'word',9773hintSelect: 'after',9774hintDirection: 'bottom',9775styleTags: ['p', 'blockquote', 'pre', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'],9776fontNames: ['Arial', 'Arial Black', 'Comic Sans MS', 'Courier New', 'Helvetica Neue', 'Helvetica', 'Impact', 'Lucida Grande', 'Tahoma', 'Times New Roman', 'Verdana'],9777fontNamesIgnoreCheck: [],9778addDefaultFonts: true,9779fontSizes: ['8', '9', '10', '11', '12', '14', '18', '24', '36'],9780fontSizeUnits: ['px', 'pt'],9781// pallete colors(n x n)9782colors: [['#000000', '#424242', '#636363', '#9C9C94', '#CEC6CE', '#EFEFEF', '#F7F7F7', '#FFFFFF'], ['#FF0000', '#FF9C00', '#FFFF00', '#00FF00', '#00FFFF', '#0000FF', '#9C00FF', '#FF00FF'], ['#F7C6CE', '#FFE7CE', '#FFEFC6', '#D6EFD6', '#CEDEE7', '#CEE7F7', '#D6D6E7', '#E7D6DE'], ['#E79C9C', '#FFC69C', '#FFE79C', '#B5D6A5', '#A5C6CE', '#9CC6EF', '#B5A5D6', '#D6A5BD'], ['#E76363', '#F7AD6B', '#FFD663', '#94BD7B', '#73A5AD', '#6BADDE', '#8C7BC6', '#C67BA5'], ['#CE0000', '#E79439', '#EFC631', '#6BA54A', '#4A7B8C', '#3984C6', '#634AA5', '#A54A7B'], ['#9C0000', '#B56308', '#BD9400', '#397B21', '#104A5A', '#085294', '#311873', '#731842'], ['#630000', '#7B3900', '#846300', '#295218', '#083139', '#003163', '#21104A', '#4A1031']],9783// http://chir.ag/projects/name-that-color/9784colorsName: [['Black', 'Tundora', 'Dove Gray', 'Star Dust', 'Pale Slate', 'Gallery', 'Alabaster', 'White'], ['Red', 'Orange Peel', 'Yellow', 'Green', 'Cyan', 'Blue', 'Electric Violet', 'Magenta'], ['Azalea', 'Karry', 'Egg White', 'Zanah', 'Botticelli', 'Tropical Blue', 'Mischka', 'Twilight'], ['Tonys Pink', 'Peach Orange', 'Cream Brulee', 'Sprout', 'Casper', 'Perano', 'Cold Purple', 'Careys Pink'], ['Mandy', 'Rajah', 'Dandelion', 'Olivine', 'Gulf Stream', 'Viking', 'Blue Marguerite', 'Puce'], ['Guardsman Red', 'Fire Bush', 'Golden Dream', 'Chelsea Cucumber', 'Smalt Blue', 'Boston Blue', 'Butterfly Bush', 'Cadillac'], ['Sangria', 'Mai Tai', 'Buddha Gold', 'Forest Green', 'Eden', 'Venice Blue', 'Meteorite', 'Claret'], ['Rosewood', 'Cinnamon', 'Olive', 'Parsley', 'Tiber', 'Midnight Blue', 'Valentino', 'Loulou']],9785colorButton: {9786foreColor: '#000000',9787backColor: '#FFFF00'9788},9789lineHeights: ['1.0', '1.2', '1.4', '1.5', '1.6', '1.8', '2.0', '3.0'],9790tableClassName: 'table table-bordered',9791insertTableMaxSize: {9792col: 10,9793row: 109794},9795// By default, dialogs are attached in container.9796dialogsInBody: false,9797dialogsFade: false,9798maximumImageFileSize: null,9799acceptImageFileTypes: "image/*",9800callbacks: {9801onBeforeCommand: null,9802onBlur: null,9803onBlurCodeview: null,9804onChange: null,9805onChangeCodeview: null,9806onDialogShown: null,9807onEnter: null,9808onFocus: null,9809onImageLinkInsert: null,9810onImageUpload: null,9811onImageUploadError: null,9812onInit: null,9813onKeydown: null,9814onKeyup: null,9815onMousedown: null,9816onMouseup: null,9817onPaste: null,9818onScroll: null9819},9820codemirror: {9821mode: 'text/html',9822htmlMode: true,9823lineNumbers: true9824},9825codeviewFilter: true,9826codeviewFilterRegex: /<\/*(?:applet|b(?:ase|gsound|link)|embed|frame(?:set)?|ilayer|l(?:ayer|ink)|meta|object|s(?:cript|tyle)|t(?:itle|extarea)|xml)[^>]*?>/gi,9827codeviewIframeFilter: true,9828codeviewIframeWhitelistSrc: [],9829codeviewIframeWhitelistSrcBase: ['www.youtube.com', 'www.youtube-nocookie.com', 'www.facebook.com', 'vine.co', 'instagram.com', 'player.vimeo.com', 'www.dailymotion.com', 'player.youku.com', 'jumpingbean.tv', 'v.qq.com'],9830keyMap: {9831pc: {9832'ESC': 'escape',9833'ENTER': 'insertParagraph',9834'CTRL+Z': 'undo',9835'CTRL+Y': 'redo',9836'TAB': 'tab',9837'SHIFT+TAB': 'untab',9838'CTRL+B': 'bold',9839'CTRL+I': 'italic',9840'CTRL+U': 'underline',9841'CTRL+SHIFT+S': 'strikethrough',9842'CTRL+BACKSLASH': 'removeFormat',9843'CTRL+SHIFT+L': 'justifyLeft',9844'CTRL+SHIFT+E': 'justifyCenter',9845'CTRL+SHIFT+R': 'justifyRight',9846'CTRL+SHIFT+J': 'justifyFull',9847'CTRL+SHIFT+NUM7': 'insertUnorderedList',9848'CTRL+SHIFT+NUM8': 'insertOrderedList',9849'CTRL+LEFTBRACKET': 'outdent',9850'CTRL+RIGHTBRACKET': 'indent',9851'CTRL+NUM0': 'formatPara',9852'CTRL+NUM1': 'formatH1',9853'CTRL+NUM2': 'formatH2',9854'CTRL+NUM3': 'formatH3',9855'CTRL+NUM4': 'formatH4',9856'CTRL+NUM5': 'formatH5',9857'CTRL+NUM6': 'formatH6',9858'CTRL+ENTER': 'insertHorizontalRule',9859'CTRL+K': 'linkDialog.show'9860},9861mac: {9862'ESC': 'escape',9863'ENTER': 'insertParagraph',9864'CMD+Z': 'undo',9865'CMD+SHIFT+Z': 'redo',9866'TAB': 'tab',9867'SHIFT+TAB': 'untab',9868'CMD+B': 'bold',9869'CMD+I': 'italic',9870'CMD+U': 'underline',9871'CMD+SHIFT+S': 'strikethrough',9872'CMD+BACKSLASH': 'removeFormat',9873'CMD+SHIFT+L': 'justifyLeft',9874'CMD+SHIFT+E': 'justifyCenter',9875'CMD+SHIFT+R': 'justifyRight',9876'CMD+SHIFT+J': 'justifyFull',9877'CMD+SHIFT+NUM7': 'insertUnorderedList',9878'CMD+SHIFT+NUM8': 'insertOrderedList',9879'CMD+LEFTBRACKET': 'outdent',9880'CMD+RIGHTBRACKET': 'indent',9881'CMD+NUM0': 'formatPara',9882'CMD+NUM1': 'formatH1',9883'CMD+NUM2': 'formatH2',9884'CMD+NUM3': 'formatH3',9885'CMD+NUM4': 'formatH4',9886'CMD+NUM5': 'formatH5',9887'CMD+NUM6': 'formatH6',9888'CMD+ENTER': 'insertHorizontalRule',9889'CMD+K': 'linkDialog.show'9890}9891},9892icons: {9893'align': 'note-icon-align',9894'alignCenter': 'note-icon-align-center',9895'alignJustify': 'note-icon-align-justify',9896'alignLeft': 'note-icon-align-left',9897'alignRight': 'note-icon-align-right',9898'rowBelow': 'note-icon-row-below',9899'colBefore': 'note-icon-col-before',9900'colAfter': 'note-icon-col-after',9901'rowAbove': 'note-icon-row-above',9902'rowRemove': 'note-icon-row-remove',9903'colRemove': 'note-icon-col-remove',9904'indent': 'note-icon-align-indent',9905'outdent': 'note-icon-align-outdent',9906'arrowsAlt': 'note-icon-arrows-alt',9907'bold': 'note-icon-bold',9908'caret': 'note-icon-caret',9909'circle': 'note-icon-circle',9910'close': 'note-icon-close',9911'code': 'note-icon-code',9912'eraser': 'note-icon-eraser',9913'floatLeft': 'note-icon-float-left',9914'floatRight': 'note-icon-float-right',9915'font': 'note-icon-font',9916'frame': 'note-icon-frame',9917'italic': 'note-icon-italic',9918'link': 'note-icon-link',9919'unlink': 'note-icon-chain-broken',9920'magic': 'note-icon-magic',9921'menuCheck': 'note-icon-menu-check',9922'minus': 'note-icon-minus',9923'orderedlist': 'note-icon-orderedlist',9924'pencil': 'note-icon-pencil',9925'picture': 'note-icon-picture',9926'question': 'note-icon-question',9927'redo': 'note-icon-redo',9928'rollback': 'note-icon-rollback',9929'square': 'note-icon-square',9930'strikethrough': 'note-icon-strikethrough',9931'subscript': 'note-icon-subscript',9932'superscript': 'note-icon-superscript',9933'table': 'note-icon-table',9934'textHeight': 'note-icon-text-height',9935'trash': 'note-icon-trash',9936'underline': 'note-icon-underline',9937'undo': 'note-icon-undo',9938'unorderedlist': 'note-icon-unorderedlist',9939'video': 'note-icon-video'9940}9941}9942});9943;// CONCATENATED MODULE: ./src/js/renderer.js9944function _typeof(obj) { "@babel/helpers - typeof"; 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); }9945
9946function renderer_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }9947
9948function renderer_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); } }9949
9950function renderer_createClass(Constructor, protoProps, staticProps) { if (protoProps) renderer_defineProperties(Constructor.prototype, protoProps); if (staticProps) renderer_defineProperties(Constructor, staticProps); return Constructor; }9951
9952
9953
9954var Renderer = /*#__PURE__*/function () {9955function Renderer(markup, children, options, callback) {9956renderer_classCallCheck(this, Renderer);9957
9958this.markup = markup;9959this.children = children;9960this.options = options;9961this.callback = callback;9962}9963
9964renderer_createClass(Renderer, [{9965key: "render",9966value: function render($parent) {9967var $node = external_jQuery_default()(this.markup);9968
9969if (this.options && this.options.contents) {9970$node.html(this.options.contents);9971}9972
9973if (this.options && this.options.className) {9974$node.addClass(this.options.className);9975}9976
9977if (this.options && this.options.data) {9978external_jQuery_default().each(this.options.data, function (k, v) {9979$node.attr('data-' + k, v);9980});9981}9982
9983if (this.options && this.options.click) {9984$node.on('click', this.options.click);9985}9986
9987if (this.children) {9988var $container = $node.find('.note-children-container');9989this.children.forEach(function (child) {9990child.render($container.length ? $container : $node);9991});9992}9993
9994if (this.callback) {9995this.callback($node, this.options);9996}9997
9998if (this.options && this.options.callback) {9999this.options.callback($node);10000}10001
10002if ($parent) {10003$parent.append($node);10004}10005
10006return $node;10007}10008}]);10009
10010return Renderer;10011}();10012
10013/* harmony default export */ const renderer = ({10014create: function create(markup, callback) {10015return function () {10016var options = _typeof(arguments[1]) === 'object' ? arguments[1] : arguments[0];10017var children = Array.isArray(arguments[0]) ? arguments[0] : [];10018
10019if (options && options.children) {10020children = options.children;10021}10022
10023return new Renderer(markup, children, options, callback);10024};10025}10026});10027;// CONCATENATED MODULE: ./src/styles/bs3/summernote-bs3.js10028function summernote_bs3_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { summernote_bs3_typeof = function _typeof(obj) { return typeof obj; }; } else { summernote_bs3_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return summernote_bs3_typeof(obj); }10029
10030
10031
10032
10033
10034var editor = renderer.create('<div class="note-editor note-frame panel panel-default"></div>');10035var toolbar = renderer.create('<div class="panel-heading note-toolbar" role="toolbar"></div>');10036var editingArea = renderer.create('<div class="note-editing-area"></div>');10037var codable = renderer.create('<textarea class="note-codable" aria-multiline="true"></textarea>');10038var editable = renderer.create('<div class="note-editable" contentEditable="true" role="textbox" aria-multiline="true"></div>');10039var statusbar = renderer.create(['<output class="note-status-output" role="status" aria-live="polite"></output>', '<div class="note-statusbar" role="status">', '<div class="note-resizebar" aria-label="Resize">', '<div class="note-icon-bar"></div>', '<div class="note-icon-bar"></div>', '<div class="note-icon-bar"></div>', '</div>', '</div>'].join(''));10040var airEditor = renderer.create('<div class="note-editor note-airframe"></div>');10041var airEditable = renderer.create(['<div class="note-editable" contentEditable="true" role="textbox" aria-multiline="true"></div>', '<output class="note-status-output" role="status" aria-live="polite"></output>'].join(''));10042var buttonGroup = renderer.create('<div class="note-btn-group btn-group"></div>');10043var dropdown = renderer.create('<ul class="note-dropdown-menu dropdown-menu"></ul>', function ($node, options) {10044var markup = Array.isArray(options.items) ? options.items.map(function (item) {10045var value = typeof item === 'string' ? item : item.value || '';10046var content = options.template ? options.template(item) : item;10047var option = summernote_bs3_typeof(item) === 'object' ? item.option : undefined;10048var dataValue = 'data-value="' + value + '"';10049var dataOption = option !== undefined ? ' data-option="' + option + '"' : '';10050return '<li aria-label="' + value + '"><a href="#" ' + (dataValue + dataOption) + '>' + content + '</a></li>';10051}).join('') : options.items;10052$node.html(markup).attr({10053'aria-label': options.title10054});10055
10056if (options && options.codeviewKeepButton) {10057$node.addClass('note-codeview-keep');10058}10059});10060
10061var dropdownButtonContents = function dropdownButtonContents(contents, options) {10062return contents + ' ' + icon(options.icons.caret, 'span');10063};10064
10065var dropdownCheck = renderer.create('<ul class="note-dropdown-menu dropdown-menu note-check"></ul>', function ($node, options) {10066var markup = Array.isArray(options.items) ? options.items.map(function (item) {10067var value = typeof item === 'string' ? item : item.value || '';10068var content = options.template ? options.template(item) : item;10069return '<li aria-label="' + item + '"><a href="#" data-value="' + value + '">' + icon(options.checkClassName) + ' ' + content + '</a></li>';10070}).join('') : options.items;10071$node.html(markup).attr({10072'aria-label': options.title10073});10074
10075if (options && options.codeviewKeepButton) {10076$node.addClass('note-codeview-keep');10077}10078});10079var dialog = renderer.create('<div class="modal note-modal" aria-hidden="false" tabindex="-1" role="dialog"></div>', function ($node, options) {10080if (options.fade) {10081$node.addClass('fade');10082}10083
10084$node.attr({10085'aria-label': options.title10086});10087$node.html(['<div class="modal-dialog">', '<div class="modal-content">', options.title ? '<div class="modal-header">' + '<button type="button" class="close" data-dismiss="modal" aria-label="Close" aria-hidden="true">×</button>' + '<h4 class="modal-title">' + options.title + '</h4>' + '</div>' : '', '<div class="modal-body">' + options.body + '</div>', options.footer ? '<div class="modal-footer">' + options.footer + '</div>' : '', '</div>', '</div>'].join(''));10088});10089var popover = renderer.create(['<div class="note-popover popover in">', '<div class="arrow"></div>', '<div class="popover-content note-children-container"></div>', '</div>'].join(''), function ($node, options) {10090var direction = typeof options.direction !== 'undefined' ? options.direction : 'bottom';10091$node.addClass(direction);10092
10093if (options.hideArrow) {10094$node.find('.arrow').hide();10095}10096});10097var summernote_bs3_checkbox = renderer.create('<div class="checkbox"></div>', function ($node, options) {10098$node.html(['<label' + (options.id ? ' for="note-' + options.id + '"' : '') + '>', '<input type="checkbox"' + (options.id ? ' id="note-' + options.id + '"' : ''), options.checked ? ' checked' : '', ' aria-checked="' + (options.checked ? 'true' : 'false') + '"/>', options.text ? options.text : '', '</label>'].join(''));10099});10100
10101var icon = function icon(iconClassName, tagName) {10102if (iconClassName.match(/^</)) {10103return iconClassName;10104}10105
10106tagName = tagName || 'i';10107return '<' + tagName + ' class="' + iconClassName + '"></' + tagName + '>';10108};10109
10110var ui = function ui(editorOptions) {10111return {10112editor: editor,10113toolbar: toolbar,10114editingArea: editingArea,10115codable: codable,10116editable: editable,10117statusbar: statusbar,10118airEditor: airEditor,10119airEditable: airEditable,10120buttonGroup: buttonGroup,10121dropdown: dropdown,10122dropdownButtonContents: dropdownButtonContents,10123dropdownCheck: dropdownCheck,10124dialog: dialog,10125popover: popover,10126checkbox: summernote_bs3_checkbox,10127icon: icon,10128options: editorOptions,10129palette: function palette($node, options) {10130return renderer.create('<div class="note-color-palette"></div>', function ($node, options) {10131var contents = [];10132
10133for (var row = 0, rowSize = options.colors.length; row < rowSize; row++) {10134var eventName = options.eventName;10135var colors = options.colors[row];10136var colorsName = options.colorsName[row];10137var buttons = [];10138
10139for (var col = 0, colSize = colors.length; col < colSize; col++) {10140var color = colors[col];10141var colorName = colorsName[col];10142buttons.push(['<button type="button" class="note-color-btn"', 'style="background-color:', color, '" ', 'data-event="', eventName, '" ', 'data-value="', color, '" ', 'title="', colorName, '" ', 'aria-label="', colorName, '" ', 'data-toggle="button" tabindex="-1"></button>'].join(''));10143}10144
10145contents.push('<div class="note-color-row">' + buttons.join('') + '</div>');10146}10147
10148$node.html(contents.join(''));10149
10150if (options.tooltip) {10151$node.find('.note-color-btn').tooltip({10152container: options.container || editorOptions.container,10153trigger: 'hover',10154placement: 'bottom'10155});10156}10157})($node, options);10158},10159button: function button($node, options) {10160return renderer.create('<button type="button" class="note-btn btn btn-default btn-sm" tabindex="-1"></button>', function ($node, options) {10161if (options && options.tooltip) {10162$node.attr({10163title: options.tooltip,10164'aria-label': options.tooltip10165}).tooltip({10166container: options.container || editorOptions.container,10167trigger: 'hover',10168placement: 'bottom'10169}).on('click', function (e) {10170external_jQuery_default()(e.currentTarget).tooltip('hide');10171});10172}10173
10174if (options && options.codeviewButton) {10175$node.addClass('note-codeview-keep');10176}10177})($node, options);10178},10179toggleBtn: function toggleBtn($btn, isEnable) {10180$btn.toggleClass('disabled', !isEnable);10181$btn.attr('disabled', !isEnable);10182},10183toggleBtnActive: function toggleBtnActive($btn, isActive) {10184$btn.toggleClass('active', isActive);10185},10186onDialogShown: function onDialogShown($dialog, handler) {10187$dialog.one('shown.bs.modal', handler);10188},10189onDialogHidden: function onDialogHidden($dialog, handler) {10190$dialog.one('hidden.bs.modal', handler);10191},10192showDialog: function showDialog($dialog) {10193$dialog.modal('show');10194},10195hideDialog: function hideDialog($dialog) {10196$dialog.modal('hide');10197},10198createLayout: function createLayout($note) {10199var $editor = (editorOptions.airMode ? airEditor([editingArea([codable(), airEditable()])]) : editorOptions.toolbarPosition === 'bottom' ? editor([editingArea([codable(), editable()]), toolbar(), statusbar()]) : editor([toolbar(), editingArea([codable(), editable()]), statusbar()])).render();10200$editor.insertAfter($note);10201return {10202note: $note,10203editor: $editor,10204toolbar: $editor.find('.note-toolbar'),10205editingArea: $editor.find('.note-editing-area'),10206editable: $editor.find('.note-editable'),10207codable: $editor.find('.note-codable'),10208statusbar: $editor.find('.note-statusbar')10209};10210},10211removeLayout: function removeLayout($note, layoutInfo) {10212$note.html(layoutInfo.editable.html());10213layoutInfo.editor.remove();10214$note.show();10215}10216};10217};10218
10219(external_jQuery_default()).summernote = external_jQuery_default().extend((external_jQuery_default()).summernote, {10220ui_template: ui,10221"interface": 'bs3'10222});10223})();10224
10225/******/ return __webpack_exports__;10226/******/ })()10227;
10228});10229//# sourceMappingURL=summernote.js.map