/*! * tui-editor * @version 1.3.3 * @author NHN Ent. FE Development Lab (https://nhnent.github.io/tui.editor/) * @license MIT */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("jquery"), require("tui-code-snippet"), require("codemirror"), require("markdown-it"), require("to-mark"), require("highlight.js"), require("squire-rte")); else if(typeof define === 'function' && define.amd) define(["jquery", "tui-code-snippet", "codemirror", "markdown-it", "to-mark", "highlight.js", "squire-rte"], factory); else if(typeof exports === 'object') exports["Editor"] = factory(require("jquery"), require("tui-code-snippet"), require("codemirror"), require("markdown-it"), require("to-mark"), require("highlight.js"), require("squire-rte")); else root["tui"] = root["tui"] || {}, root["tui"]["Editor"] = factory(root["$"], (root["tui"] && root["tui"]["util"]), root["CodeMirror"], root["markdownit"], root["toMark"], root["hljs"], root["Squire"]); })(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_6__, __WEBPACK_EXTERNAL_MODULE_22__, __WEBPACK_EXTERNAL_MODULE_23__, __WEBPACK_EXTERNAL_MODULE_31__, __WEBPACK_EXTERNAL_MODULE_66__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = "dist/"; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 44); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE_0__; /***/ }), /* 1 */ /***/ (function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE_1__; /***/ }), /* 2 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview Implements CommandManager * @author NHN Ent. FE Development Lab */ var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _command = __webpack_require__(21); var _command2 = _interopRequireDefault(_command); var _util = __webpack_require__(14); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var KEYMAP_OS_INDEX = _util.isMac ? 1 : 0; /** * Class CommandManager */ var CommandManager = function () { /** * @param {ToastUIEditor} base nedInstance * @param {object} [options={}] - option object * @param {boolean} [options.useCommandShortcut=true] - execute command with keyMap */ function CommandManager(base) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; _classCallCheck(this, CommandManager); this._command = new _tuiCodeSnippet2.default.Map(); this._mdCommand = new _tuiCodeSnippet2.default.Map(); this._wwCommand = new _tuiCodeSnippet2.default.Map(); this._options = _jquery2.default.extend({ 'useCommandShortcut': true }, options); this.base = base; this.keyMapCommand = {}; this._initEvent(); } /** * You can change command before command addition by addCommandBefore event. * @param {object} command - command * @returns {object} * @private */ _createClass(CommandManager, [{ key: '_addCommandBefore', value: function _addCommandBefore(command) { var commandWrapper = { command: command }; this.base.eventManager.emit('addCommandBefore', commandWrapper); return commandWrapper.command || command; } /** * Add command * @memberof CommandManager * @param {Command} command Command instance * @returns {Command} Command */ }, { key: 'addCommand', value: function addCommand(command) { for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } if (args.length) { command = CommandManager.command.apply(CommandManager, [command].concat(args)); } command = this._addCommandBefore(command); var name = command.getName(); var commandBase = void 0; if (command.isMDType()) { commandBase = this._mdCommand; } else if (command.isWWType()) { commandBase = this._wwCommand; } else if (command.isGlobalType()) { commandBase = this._command; } commandBase.set(name, command); if (command.keyMap) { this.keyMapCommand[command.keyMap[KEYMAP_OS_INDEX]] = name; } return command; } /** * _initEvent * Bind event handler to eventManager * @private * @memberof CommandManager */ }, { key: '_initEvent', value: function _initEvent() { var _this = this; this.base.eventManager.listen('command', function () { _this.exec.apply(_this, arguments); }); this.base.eventManager.listen('keyMap', function (ev) { if (!_this._options.useCommandShortcut) { return; } var command = _this.keyMapCommand[ev.keyMap]; if (command) { ev.data.preventDefault(); _this.exec(command); } }); } /** * Execute command * @memberof CommandManager * @param {String} name Command name * @param {*} ...args Command argument * @returns {*} */ }, { key: 'exec', value: function exec(name) { var commandToRun = void 0, result = void 0; var context = this.base; commandToRun = this._command.get(name); if (!commandToRun) { if (this.base.isMarkdownMode()) { commandToRun = this._mdCommand.get(name); context = this.base.mdEditor; } else { commandToRun = this._wwCommand.get(name); context = this.base.wwEditor; } } if (commandToRun) { var _commandToRun; for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments[_key2]; } args.unshift(context); result = (_commandToRun = commandToRun).exec.apply(_commandToRun, args); } return result; } }]); return CommandManager; }(); /** * Create command by given editor type and property object * @memberof CommandManager * @param {string} type Command type * @param {{name: string, keyMap: Array}} props Property * @returns {*} */ CommandManager.command = function (type, props) { var command = _command2.default.factory(type, props.name, props.keyMap); _tuiCodeSnippet2.default.extend(command, props); return command; }; exports.default = CommandManager; /***/ }), /* 3 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.I18n = undefined; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview Implements i18n * @author NHN Ent. FE Development Lab */ var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var sharedInstance = void 0; var DEFAULT_CODE = 'en_US'; /** * Class I18n */ var I18n = function () { /** * Creates an instance of I18n. * @memberof I18n */ function I18n() { _classCallCheck(this, I18n); this._code = DEFAULT_CODE; this._langs = new _tuiCodeSnippet2.default.Map(); } /** * Set locale code * @param {string} code locale code */ _createClass(I18n, [{ key: 'setCode', value: function setCode(code) { this._code = code; } /** * Set language set * @param {string|string[]} codes locale code * @param {object} data language set */ }, { key: 'setLanguage', value: function setLanguage(codes, data) { var _this = this; codes = [].concat(codes); codes.forEach(function (code) { if (!_this._langs.has(code)) { _this._langs.set(code, data); } else { var langData = _this._langs.get(code); _this._langs.set(code, _tuiCodeSnippet2.default.extend(langData, data)); } }); } /** * Get text of key * @param {string} key key of text * @param {string} code locale code * @returns {string} */ }, { key: 'get', value: function get(key, code) { if (!code) { code = this._code; } var langSet = this._langs.get(code); if (!langSet) { langSet = this._langs.get(DEFAULT_CODE); } var text = langSet[key]; if (!text) { throw new Error('There is no text key "' + key + '" in ' + code); } return text; } }], [{ key: 'getSharedInstance', value: function getSharedInstance() { if (!sharedInstance) { sharedInstance = new I18n(); } return sharedInstance; } }]); return I18n; }(); exports.I18n = I18n; exports.default = new I18n(); /***/ }), /* 4 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * @fileoverview DOM Utils * @author NHN Ent. FE Development Lab */ var FIND_ZWB = /\u200B/g; /** * isTextNode * Check if node is text node * @param {Node} node node to check * @returns {boolean} result * @ignore */ var isTextNode = function isTextNode(node) { return node && node.nodeType === Node.TEXT_NODE; }; /** * isElemNode * Check if node is element node * @param {Node} node node to check * @returns {boolean} result * @ignore */ var isElemNode = function isElemNode(node) { return node && node.nodeType === Node.ELEMENT_NODE; }; /** * Check that the node is block node * @param {Node} node node * @returns {boolean} * @ignore */ var isBlockNode = function isBlockNode(node) { return (/^(ADDRESS|ARTICLE|ASIDE|BLOCKQUOTE|DETAILS|DIALOG|DD|DIV|DL|DT|FIELDSET|FIGCAPTION|FIGURE|FOOTER|FORM|H[\d]|HEADER|HGROUP|HR|LI|MAIN|NAV|OL|P|PRE|SECTION|UL)$/ig.test(this.getNodeName(node)) ); }; /** * getNodeName * Get node name of node * @param {Node} node node * @returns {string} node name * @ignore */ var getNodeName = function getNodeName(node) { if (isElemNode(node)) { return node.tagName; } return 'TEXT'; }; /** * getTextLength * Get node offset length of node(for Range API) * @param {Node} node node * @returns {number} length * @ignore */ var getTextLength = function getTextLength(node) { var len = void 0; if (isElemNode(node)) { len = node.textContent.replace(FIND_ZWB, '').length; } else if (isTextNode(node)) { len = node.nodeValue.replace(FIND_ZWB, '').length; } return len; }; /** * getOffsetLength * Get node offset length of node(for Range API) * @param {Node} node node * @returns {number} length * @ignore */ var getOffsetLength = function getOffsetLength(node) { var len = void 0; if (isElemNode(node)) { len = node.childNodes.length; } else if (isTextNode(node)) { len = node.nodeValue.replace(FIND_ZWB, '').length; } return len; }; /** * getNodeOffsetOfParent * get node offset between parent's childnodes * @param {Node} node node * @returns {number} offset(index) * @ignore */ var getNodeOffsetOfParent = function getNodeOffsetOfParent(node) { var childNodesOfParent = node.parentNode.childNodes; var i = void 0, t = void 0, found = void 0; for (i = 0, t = childNodesOfParent.length; i < t; i += 1) { if (childNodesOfParent[i] === node) { found = i; break; } } return found; }; /** * getChildNodeByOffset * get child node by offset * @param {Node} node node * @param {number} index offset index * @returns {Node} foudned node * @ignore */ var getChildNodeByOffset = function getChildNodeByOffset(node, index) { var currentNode = void 0; if (isTextNode(node)) { currentNode = node; } else if (node.childNodes.length && index >= 0) { currentNode = node.childNodes[index]; } return currentNode; }; /** * getNodeWithDirectionUntil * find next node from passed node * @param {strong} direction previous or next * @param {Node} node node * @param {string} untilNodeName parent node name to limit * @returns {Node} founded node * @ignore */ var getNodeWithDirectionUntil = function getNodeWithDirectionUntil(direction, node, untilNodeName) { var directionKey = direction + 'Sibling'; var nodeName = void 0, foundedNode = void 0; while (node && !node[directionKey]) { nodeName = getNodeName(node.parentNode); if (nodeName === untilNodeName || nodeName === 'BODY') { break; } node = node.parentNode; } if (node[directionKey]) { foundedNode = node[directionKey]; } return foundedNode; }; /** * getPrevOffsetNodeUntil * get prev node of childnode pointed with index * @param {Node} node node * @param {number} index offset index * @param {string} untilNodeName parent node name to limit * @returns {Node} founded node * @ignore */ var getPrevOffsetNodeUntil = function getPrevOffsetNodeUntil(node, index, untilNodeName) { var prevNode = void 0; if (index > 0) { prevNode = getChildNodeByOffset(node, index - 1); } else { prevNode = getNodeWithDirectionUntil('previous', node, untilNodeName); } return prevNode; }; var getParentUntilBy = function getParentUntilBy(node, matchCondition, stopCondition) { var foundedNode = void 0; while (node.parentNode && !matchCondition(node.parentNode)) { node = node.parentNode; if (stopCondition && stopCondition(node.parentNode)) { break; } } if (matchCondition(node.parentNode)) { foundedNode = node; } return foundedNode; }; /** * getParentUntil * get parent node until paseed node name * @param {Node} node node * @param {string|HTMLNode} untilNode node name or node to limit * @returns {Node} founded node * @ignore */ var getParentUntil = function getParentUntil(node, untilNode) { var foundedNode = void 0; if (_tuiCodeSnippet2.default.isString(untilNode)) { foundedNode = getParentUntilBy(node, function (targetNode) { return untilNode === getNodeName(targetNode); }); } else { foundedNode = getParentUntilBy(node, function (targetNode) { return untilNode === targetNode; }); } return foundedNode; }; /** * getNodeWithDirectionUnderParent * get node on the given direction under given parent * @param {strong} direction previous or next * @param {Node} node node * @param {string|Node} underNode parent node name to limit * @returns {Node} founded node * @ignore */ var getNodeWithDirectionUnderParent = function getNodeWithDirectionUnderParent(direction, node, underNode) { var directionKey = direction + 'Sibling'; var foundedNode = void 0; node = getParentUntil(node, underNode); if (node && node[directionKey]) { foundedNode = node[directionKey]; } return foundedNode; }; /** * getTopPrevNodeUnder * get top previous top level node under given node * @param {Node} node node * @param {Node} underNode underNode * @returns {Node} founded node * @ignore */ var getTopPrevNodeUnder = function getTopPrevNodeUnder(node, underNode) { return getNodeWithDirectionUnderParent('previous', node, underNode); }; /** * getNextTopBlockNode * get next top level block node * @param {Node} node node * @param {Node} underNode underNode * @returns {Node} founded node * @ignore */ var getTopNextNodeUnder = function getTopNextNodeUnder(node, underNode) { return getNodeWithDirectionUnderParent('next', node, underNode); }; /** * Get parent element the body element * @param {Node} node Node for start searching * @returns {Node} * @ignore */ var getTopBlockNode = function getTopBlockNode(node) { return getParentUntil(node, 'BODY'); }; /** * Get previous text node * @param {Node} node Node for start searching * @returns {Node} * @ignore */ var getPrevTextNode = function getPrevTextNode(node) { node = node.previousSibling || node.parentNode; while (!isTextNode(node) && getNodeName(node) !== 'BODY') { if (node.previousSibling) { node = node.previousSibling; while (node.lastChild) { node = node.lastChild; } } else { node = node.parentNode; } } if (getNodeName(node) === 'BODY') { node = null; } return node; }; /** * test whether root contains the given node * @param {HTMLNode} root - root node * @param {HTMLNode} node - node to test * @returns {Boolean} true if root contains node */ var containsNode = function containsNode(root, node) { var walker = document.createTreeWalker(root, 4, null, false); var found = root === node; while (!found && walker.nextNode()) { found = walker.currentNode === node; } return found; }; /** * find node by offset * @param {HTMLElement} root Root element * @param {Array.} offsetList offset list * @param {function} textNodeFilter Text node filter * @returns {Array} * @ignore */ var findOffsetNode = function findOffsetNode(root, offsetList, textNodeFilter) { var result = []; var text = ''; var walkerOffset = 0; var newWalkerOffset = void 0; if (!offsetList.length) { return result; } var offset = offsetList.shift(); var walker = document.createTreeWalker(root, 4, null, false); while (walker.nextNode()) { text = walker.currentNode.nodeValue || ''; if (textNodeFilter) { text = textNodeFilter(text); } newWalkerOffset = walkerOffset + text.length; while (newWalkerOffset >= offset) { result.push({ container: walker.currentNode, offsetInContainer: offset - walkerOffset, offset: offset }); if (!offsetList.length) { return result; } offset = offsetList.shift(); } walkerOffset = newWalkerOffset; } // there should be offset left do { result.push({ container: walker.currentNode, offsetInContainer: text.length, offset: offset }); offset = offsetList.shift(); } while (!_tuiCodeSnippet2.default.isUndefined(offset)); return result; }; var getNodeInfo = function getNodeInfo(node) { var path = {}; path.tagName = node.nodeName; if (node.id) { path.id = node.id; } var className = node.className.trim(); if (className) { path.className = className; } return path; }; var getPath = function getPath(node, root) { var paths = []; while (node && node !== root) { if (isElemNode(node)) { paths.unshift(getNodeInfo(node)); } node = node.parentNode; } return paths; }; /** * Find next, previous TD or TH element by given TE element * @param {HTMLElement} node TD element * @param {string} direction 'next' or 'previous' * @returns {HTMLElement|null} * @ignore */ var getTableCellByDirection = function getTableCellByDirection(node, direction) { var isForward = true; var targetElement = null; if (_tuiCodeSnippet2.default.isUndefined(direction) || direction !== 'next' && direction !== 'previous') { return null; } else if (direction === 'previous') { isForward = false; } if (isForward) { targetElement = node.nextElementSibling; } else { targetElement = node.previousElementSibling; } return targetElement; }; /** * Find sibling TR's TD element by given TD and direction * @param {HTMLElement} node TD element * @param {string} direction Boolean value for find first TD in next line * @param {boolean} [needEdgeCell=false] Boolean value for find first TD in next line * @returns {HTMLElement|null} * @ignore */ var getSiblingRowCellByDirection = function getSiblingRowCellByDirection(node, direction, needEdgeCell) { var isForward = true; var tableCellElement = null; var $node = void 0, index = void 0, $targetRowElement = void 0, $currentContainer = void 0, $siblingContainer = void 0, isSiblingContainerExists = void 0; if (_tuiCodeSnippet2.default.isUndefined(direction) || direction !== 'next' && direction !== 'previous') { return null; } else if (direction === 'previous') { isForward = false; } if (node) { $node = (0, _jquery2.default)(node); if (isForward) { $targetRowElement = $node.parent().next(); $currentContainer = $node.parents('thead'); $siblingContainer = $currentContainer[0] && $currentContainer.next(); isSiblingContainerExists = $siblingContainer && getNodeName($siblingContainer[0]) === 'TBODY'; index = 0; } else { $targetRowElement = $node.parent().prev(); $currentContainer = $node.parents('tbody'); $siblingContainer = $currentContainer[0] && $currentContainer.prev(); isSiblingContainerExists = $siblingContainer && getNodeName($siblingContainer[0]) === 'THEAD'; index = node.parentNode.childNodes.length - 1; } if (_tuiCodeSnippet2.default.isUndefined(needEdgeCell) || !needEdgeCell) { index = getNodeOffsetOfParent(node); } if ($targetRowElement[0]) { tableCellElement = $targetRowElement.children('td,th')[index]; } else if ($currentContainer[0] && isSiblingContainerExists) { tableCellElement = $siblingContainer.find('td,th')[index]; } return tableCellElement; } return null; }; /** * Check that the inline node is supported by markdown * @param {Node} node TD element * @returns {boolean} * @ignore */ var isMDSupportInlineNode = function isMDSupportInlineNode(node) { return (/^(A|B|BR|CODE|DEL|EM|I|IMG|S|SPAN|STRONG)$/ig.test(node.nodeName) ); }; /** * Check that node is styled node. * Styled node is a node that has text and decorates text. * @param {Node} node TD element * @returns {boolean} * @ignore */ var isStyledNode = function isStyledNode(node) { return (/^(A|ABBR|ACRONYM|B|BDI|BDO|BIG|CITE|CODE|DEL|DFN|EM|I|INS|KBD|MARK|Q|S|SAMP|SMALL|SPAN|STRONG|SUB|SUP|U|VAR)$/ig.test(node.nodeName) ); }; /** * remove node from 'start' node to 'end-1' node inside parent * if 'end' node is null, remove all child nodes after 'start' node. * @param {Node} parent - parent node * @param {Node} start - start node to remove * @param {Node} end - end node to remove * @ignore */ var removeChildFromStartToEndNode = function removeChildFromStartToEndNode(parent, start, end) { var child = start; if (!child || parent !== child.parentNode) { return; } while (child !== end) { var next = child.nextSibling; parent.removeChild(child); child = next; } }; /** * remove nodes along the direction from the node to reach targetParent node * @param {Node} targetParent - stop removing when reach target parent node * @param {Node} node - start node * @param {boolean} isForward - direction * @ignore */ var removeNodesByDirection = function removeNodesByDirection(targetParent, node, isForward) { var parent = node; while (parent !== targetParent) { var nextParent = parent.parentNode; var _parent = parent, nextSibling = _parent.nextSibling, previousSibling = _parent.previousSibling; if (!isForward && nextSibling) { removeChildFromStartToEndNode(nextParent, nextSibling, null); } else if (isForward && previousSibling) { removeChildFromStartToEndNode(nextParent, nextParent.childNodes[0], parent); } parent = nextParent; } }; var getLeafNode = function getLeafNode(node) { var result = node; while (result.childNodes && result.childNodes.length) { var _result = result, nextLeaf = _result.firstChild; // When inline tag have empty text node with other childnodes, ignore empty text node. if (isTextNode(nextLeaf) && !getTextLength(nextLeaf)) { result = nextLeaf.nextSibling || nextLeaf; } else { result = nextLeaf; } } return result; }; exports.default = { getNodeName: getNodeName, isTextNode: isTextNode, isElemNode: isElemNode, isBlockNode: isBlockNode, getTextLength: getTextLength, getOffsetLength: getOffsetLength, getPrevOffsetNodeUntil: getPrevOffsetNodeUntil, getNodeOffsetOfParent: getNodeOffsetOfParent, getChildNodeByOffset: getChildNodeByOffset, containsNode: containsNode, getTopPrevNodeUnder: getTopPrevNodeUnder, getTopNextNodeUnder: getTopNextNodeUnder, getParentUntilBy: getParentUntilBy, getParentUntil: getParentUntil, getTopBlockNode: getTopBlockNode, getPrevTextNode: getPrevTextNode, findOffsetNode: findOffsetNode, getPath: getPath, getNodeInfo: getNodeInfo, getTableCellByDirection: getTableCellByDirection, getSiblingRowCellByDirection: getSiblingRowCellByDirection, isMDSupportInlineNode: isMDSupportInlineNode, isStyledNode: isStyledNode, removeChildFromStartToEndNode: removeChildFromStartToEndNode, removeNodesByDirection: removeNodesByDirection, getLeafNode: getLeafNode }; /***/ }), /* 5 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _uicontroller = __webpack_require__(8); var _uicontroller2 = _interopRequireDefault(_uicontroller); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @fileoverview Implements LayerPopup * @author NHN Ent. FE Development Lab */ var CLASS_PREFIX = 'tui-popup-'; var CLASS_FIT_WINDOW = 'fit-window'; var LAYOUT_TEMPLATE_MODELESS = '
\n \n
\n \n
\n
\n
'; var LAYOUT_TEMPLATE_MODAL = '
\n
\n \n
\n \n
\n
\n
\n
'; /** * A number, or a string containing a number. * @typedef {Object} LayerPopupOption * @property {string[]} [openerCssQuery] - Css Query list to bind clickevent that open popup * @property {string[]} [closerCssQuery] - Css Query list to bind clickevent that close popup * @property {jQuery} $el - popup root element * @property {jQuery|string} [content] - popup content that html string or jQuery element * @property {string} [textContent] - popup text content * @property {string} title - popup title * @property {boolean} [header] - whether to draw header * @property {jQuery} [$target] - element to append popup * @property {boolean} modal - true: modal, false: modeless * @property {string} [headerButtons] - replace header(close) button */ /** * Class LayerPopup * @extends {UIController} */ var LayerPopup = function (_UIController) { _inherits(LayerPopup, _UIController); /** * Creates an instance of LayerPopup. * @param {LayerPopupOption} options - popup option * @memberof LayerPopup */ function LayerPopup(options) { _classCallCheck(this, LayerPopup); options = _tuiCodeSnippet2.default.extend({ header: true, $target: (0, _jquery2.default)('body'), textContent: '' }, options); var _this = _possibleConstructorReturn(this, (LayerPopup.__proto__ || Object.getPrototypeOf(LayerPopup)).call(this, { tagName: 'div', className: options.modal ? CLASS_PREFIX + 'modal-background' : CLASS_PREFIX + 'wrapper', rootElement: options.$el })); _this._initInstance(options); _this._initDOM(options); _this._initDOMEvent(options); _this._initEditorEvent(options); return _this; } /** * init instance. * store properties & prepare before initialize DOM * @param {LayerPopupOption} options - layer popup options * @memberof LayerPopup * @protected */ _createClass(LayerPopup, [{ key: '_initInstance', value: function _initInstance(options) { this._$target = options.$target; if (options.$el) { this.$el = options.$el; this._isExternalHtmlUse = true; } if (options.content) { this.$content = (0, _jquery2.default)(options.content); } else { this.$content = options.textContent; } this.options = options; } /** * initialize DOM, render popup * @memberof LayerPopup * @protected */ }, { key: '_initDOM', value: function _initDOM() { this._initLayout(); if (!this._isExternalHtmlUse) { if (_tuiCodeSnippet2.default.isExisty(this.options.title)) { this.setTitle(this.options.title); } this.setContent(this.$content); } var buttons = this.options.headerButtons; if (buttons) { this.$el.find('.' + CLASS_PREFIX + 'close-button').remove(); var $buttonWrapper = this.$el.find('.' + CLASS_PREFIX + 'header-buttons'); $buttonWrapper.empty(); $buttonWrapper.append((0, _jquery2.default)(buttons)); } if (this.options.css) { this.$el.css(this.options.css); } } /** * bind DOM events * @memberof LayerPopup * @protected */ }, { key: '_initDOMEvent', value: function _initDOMEvent() { var _this2 = this; var _options = this.options, openerCssQuery = _options.openerCssQuery, closerCssQuery = _options.closerCssQuery; if (openerCssQuery) { (0, _jquery2.default)(openerCssQuery).on('click.' + this._id, function () { return _this2.show(); }); } if (closerCssQuery) { (0, _jquery2.default)(closerCssQuery).on('click.' + this._id, function () { return _this2.hide(); }); } this.on('click .' + CLASS_PREFIX + 'close-button', function () { return _this2.hide(); }); } /** * bind editor events * @memberof LayerPopup * @protected * @abstract */ }, { key: '_initEditorEvent', value: function _initEditorEvent() {} }, { key: '_initLayout', value: function _initLayout() { var options = this.options; if (!this._isExternalHtmlUse) { var layout = options.modal ? LAYOUT_TEMPLATE_MODAL : LAYOUT_TEMPLATE_MODELESS; this.$el.html(layout); this.$el.addClass(options.className); this.hide(); this._$target.append(this.$el); this.$body = this.$el.find('.' + CLASS_PREFIX + 'body'); if (!options.header) { this.$el.find('.' + CLASS_PREFIX + 'header').remove(); } } else { this.hide(); this._$target.append(this.$el); } } /** * set popup content * @param {jQuery|HTMLElement|string} $content - content * @memberof LayerPopup */ }, { key: 'setContent', value: function setContent($content) { this.$body.empty(); this.$body.append($content); } /** * set title * @param {string} title - title text * @memberof LayerPopup */ }, { key: 'setTitle', value: function setTitle(title) { var $title = this.$el.find('.' + CLASS_PREFIX + 'title'); $title.empty(); $title.append(title); } /** * get title element * @memberof LayerPopup * @returns {HTMLElement} - title html element */ }, { key: 'getTitleElement', value: function getTitleElement() { return this.$el.find('.' + CLASS_PREFIX + 'title').get(0); } /** * hide popup * @memberof LayerPopup */ }, { key: 'hide', value: function hide() { this.$el.css('display', 'none'); this._isShow = false; this.trigger('hidden', this); } /** * show popup * @memberof LayerPopup */ }, { key: 'show', value: function show() { this.$el.css('display', 'block'); this._isShow = true; this.trigger('shown', this); } /** * whether this popup is visible * @returns {boolean} - true: shown, false: hidden * @memberof LayerPopup */ }, { key: 'isShow', value: function isShow() { return this._isShow; } /** * remove popup content * @memberof LayerPopup */ }, { key: 'remove', value: function remove() { var _options2 = this.options, openerCssQuery = _options2.openerCssQuery, closerCssQuery = _options2.closerCssQuery; this.trigger('remove', this); this.off(); if (openerCssQuery) { (0, _jquery2.default)(openerCssQuery).off('.' + this._id); } if (closerCssQuery) { (0, _jquery2.default)(closerCssQuery).off('.' + this._id); } this.$el.remove(); this.$el = null; } /** * make popup size fit to window * @param {boolean} fit - true to make popup fit to window * @memberof LayerPopup * @protected */ }, { key: 'setFitToWindow', value: function setFitToWindow(fit) { this.$el.toggleClass(CLASS_FIT_WINDOW, fit); } /** * make popup size fit to window * @memberof LayerPopup * @protected * @returns {boolean} - true for fit to window */ }, { key: 'isFitToWindow', value: function isFitToWindow() { return this.$el.hasClass(CLASS_FIT_WINDOW); } /** * toggle size fit to window * @memberof LayerPopup * @protected * @returns {boolean} - true for fit to window */ }, { key: 'toggleFitToWindow', value: function toggleFitToWindow() { var fitToWindow = !this.isFitToWindow(); this.setFitToWindow(fitToWindow); return fitToWindow; } }]); return LayerPopup; }(_uicontroller2.default); exports.default = LayerPopup; /***/ }), /* 6 */ /***/ (function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE_6__; /***/ }), /* 7 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CodeBlockManager = undefined; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview Implements CodeBlockManager * @author NHN Ent. FE Development Lab */ var _highlight = __webpack_require__(31); var _highlight2 = _interopRequireDefault(_highlight); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Class Code Block Manager */ var CodeBlockManager = function () { /** * Creates an instance of CodeBlockManager. * @memberof CodeBlockManager */ function CodeBlockManager() { _classCallCheck(this, CodeBlockManager); this._replacers = {}; } /** * Set replacer for code block * @param {string} language - code block language * @param {function} replacer - replacer function to code block element */ _createClass(CodeBlockManager, [{ key: 'setReplacer', value: function setReplacer(language, replacer) { this._replacers[language] = replacer; } /** * get replacer for code block * @param {string} language - code block type * @returns {function} - replacer function * @memberof CodeBlockManager */ }, { key: 'getReplacer', value: function getReplacer(language) { return this._replacers[language]; } /** * Create code block html. * @param {string} language - code block language * @param {string} codeText - code text * @returns {string} */ }, { key: 'createCodeBlockHtml', value: function createCodeBlockHtml(language, codeText) { var replacer = this.getReplacer(language); var html = void 0; if (replacer) { html = replacer(codeText, language); } else { html = _highlight2.default.getLanguage(language) ? _highlight2.default.highlight(language, codeText).value : escape(codeText, false); } return html; } /** * get supported languages by highlight-js * @returns {Array} - supported languages by highlight-js * @static */ }], [{ key: 'getHighlightJSLanguages', value: function getHighlightJSLanguages() { return _highlight2.default.listLanguages(); } }]); return CodeBlockManager; }(); /** * escape code from markdown-it * @param {string} html HTML string * @param {string} encode Boolean value of whether encode or not * @returns {string} * @ignore */ function escape(html, encode) { return html.replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, '''); } exports.CodeBlockManager = CodeBlockManager; exports.default = new CodeBlockManager(); /***/ }), /* 8 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview Implements ui controller * @author NHN Ent. FE Development Lab */ var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var _uiInstanceId = -1; /** * get ui instance id * @returns {number} - new instance id * @ignore */ function makeUIInstanceId() { _uiInstanceId += 1; return _uiInstanceId; } /** * Class UIController */ var UIController = function () { /** * Creates an instance of UIController. * @param {Object} [options] - options * @param {jQuery} [options.rootElement] - root element * @param {string} [options.tagName] - tag name * @param {string} [options.className] - class name * @memberof UIController */ /** * UI jQuery element * @type {Object} * @memberof UIController */ /** * tag name * @type {string} * @memberof UIController */ function UIController() { var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; _classCallCheck(this, UIController); options = _tuiCodeSnippet2.default.extend({ tagName: 'div' }, options); this.tagName = options.tagName; this.className = options.className; this._id = makeUIInstanceId(); this._setRootElement(options.rootElement); } /** * @param {string|object} aType - event name and selector string * @param {function} aFn - event handler * @memberof UIController */ /** * UI Id * @type {number} * @private * @memberof UIController */ /** * ui controller class name * @type {string} * @memberof UIController */ _createClass(UIController, [{ key: 'on', value: function on(aType, aFn) { var _this = this; if (_tuiCodeSnippet2.default.isObject(aType)) { _tuiCodeSnippet2.default.forEach(aType, function (fn, type) { _this._addEvent(type, fn); }); } else { this._addEvent(aType, aFn); } } /** * bind event * @param {string} type - event name and selector * @param {function} fn - handler function * @memberof UIController * @private */ }, { key: '_addEvent', value: function _addEvent(type, fn) { var _parseEventType2 = this._parseEventType(type), event = _parseEventType2.event, selector = _parseEventType2.selector; if (selector) { this.$el.on(event, selector, fn); } else { this.$el.on(event, fn); } } /** * unbind event handler * @param {string} type - event name and selector * @param {function} fn - handler function * @memberof UIController */ }, { key: 'off', value: function off(type, fn) { if (type) { var _parseEventType3 = this._parseEventType(type), event = _parseEventType3.event, selector = _parseEventType3.selector; if (selector) { this.$el.off(event, selector, fn); } else { this.$el.off(event, fn); } } else { this.$el.off(); } } /** * parse string into event name & selector * 'click td' => ['click', 'td] * @param {string} type - string to be parsed * @returns {Object} event, selector * @private */ }, { key: '_parseEventType', value: function _parseEventType(type) { var splitType = type.split(' '); var event = splitType.shift(); var selector = splitType.join(' '); return { event: event, selector: selector }; } /** * set root element * @param {jQuery} $el - root jQuery element * @private */ }, { key: '_setRootElement', value: function _setRootElement($el) { var tagName = this.tagName; var className = this.className; if (!$el) { className = className || 'uic' + this._id; $el = (0, _jquery2.default)('<' + tagName + ' class="' + className + '"/>'); } this.$el = $el; } /** * trigger event * @param {...object} args - event name & extra params * @memberof UIController */ }, { key: 'trigger', value: function trigger() { var _$el; (_$el = this.$el).trigger.apply(_$el, arguments); } }, { key: '_getEventNameWithNamespace', value: function _getEventNameWithNamespace(event) { var eventSplited = event.split(' '); eventSplited[0] += '.uicEvent' + this._id; return eventSplited.join(' '); } /** * remove * @memberof UIController */ }, { key: 'remove', value: function remove() { if (this.$el) { this.$el.remove(); } } /** * destroy * @memberof UIController */ }, { key: 'destroy', value: function destroy() { var _this2 = this; this.remove(); _tuiCodeSnippet2.default.forEachOwnProperties(this, function (value, key) { _this2[key] = null; }); } }]); return UIController; }(); exports.default = UIController; /***/ }), /* 9 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * @fileoverview Implements htmlSanitizer * @author NHN Ent. FE Development Lab */ var HTML_ATTR_LIST_RX = new RegExp('^(abbr|align|alt|axis|bgcolor|border|cellpadding|cellspacing|class|clear|' + 'color|cols|compact|coords|dir|face|headers|height|hreflang|hspace|' + 'ismap|lang|language|nohref|nowrap|rel|rev|rows|rules|' + 'scope|scrolling|shape|size|span|start|summary|tabindex|target|title|type|' + 'valign|value|vspace|width|checked|mathvariant|encoding|id|name|' + 'background|cite|href|longdesc|src|usemap|xlink:href|data-+|checked|style)', 'g'); var SVG_ATTR_LIST_RX = new RegExp('^(accent-height|accumulate|additive|alphabetic|arabic-form|ascent|' + 'baseProfile|bbox|begin|by|calcMode|cap-height|class|color|color-rendering|content|' + 'cx|cy|d|dx|dy|descent|display|dur|end|fill|fill-rule|font-family|font-size|font-stretch|' + 'font-style|font-variant|font-weight|from|fx|fy|g1|g2|glyph-name|gradientUnits|hanging|' + 'height|horiz-adv-x|horiz-origin-x|ideographic|k|keyPoints|keySplines|keyTimes|lang|' + 'marker-end|marker-mid|marker-start|markerHeight|markerUnits|markerWidth|mathematical|' + 'max|min|offset|opacity|orient|origin|overline-position|overline-thickness|panose-1|' + 'path|pathLength|points|preserveAspectRatio|r|refX|refY|repeatCount|repeatDur|' + 'requiredExtensions|requiredFeatures|restart|rotate|rx|ry|slope|stemh|stemv|stop-color|' + 'stop-opacity|strikethrough-position|strikethrough-thickness|stroke|stroke-dasharray|' + 'stroke-dashoffset|stroke-linecap|stroke-linejoin|stroke-miterlimit|stroke-opacity|' + 'stroke-width|systemLanguage|target|text-anchor|to|transform|type|u1|u2|underline-position|' + 'underline-thickness|unicode|unicode-range|units-per-em|values|version|viewBox|visibility|' + 'width|widths|x|x-height|x1|x2|xlink:actuate|xlink:arcrole|xlink:role|xlink:show|xlink:title|' + 'xlink:type|xml:base|xml:lang|xml:space|xmlns|xmlns:xlink|y|y1|y2|zoomAndPan)', 'g'); /** * htmlSanitizer * @param {string|Node} html html or Node * @param {boolean} [needHtmlText] pass true if need html text * @returns {string|DocumentFragment} result * @ignore */ function htmlSanitizer(html, needHtmlText) { var $html = (0, _jquery2.default)('
'); html = html.replace(//g, ''); $html.append(html); removeUnnecessaryTags($html); leaveOnlyWhitelistAttribute($html); return finalizeHtml($html, needHtmlText); } /** * Remove unnecessary tags * @private * @param {jQuery} $html jQuery instance */ function removeUnnecessaryTags($html) { $html.find('script, iframe, textarea, form, button, select, meta, style, link, title').remove(); } /** * Leave only white list attributes * @private * @param {jQuery} $html jQuery instance */ function leaveOnlyWhitelistAttribute($html) { $html.find('*').each(function (index, node) { var attrs = node.attributes; var blacklist = _tuiCodeSnippet2.default.toArray(attrs).filter(function (attr) { var isHTMLAttr = attr.name.match(HTML_ATTR_LIST_RX); var isSVGAttr = attr.name.match(SVG_ATTR_LIST_RX); return !isHTMLAttr && !isSVGAttr; }); _tuiCodeSnippet2.default.forEachArray(blacklist, function (attr) { // Edge svg attribute name returns uppercase bug. error guard. // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/5579311/ if (attrs.getNamedItem(attr.name)) { attrs.removeNamedItem(attr.name); } }); }); } /** * Finalize html result * @private * @param {jQuery} $html jQuery instance * @param {boolean} needHtmlText pass true if need html text * @returns {string|DocumentFragment} result */ function finalizeHtml($html, needHtmlText) { var returnValue = void 0; if (needHtmlText) { returnValue = $html[0].innerHTML; } else { var frag = document.createDocumentFragment(); var childNodes = _tuiCodeSnippet2.default.toArray($html[0].childNodes); var length = childNodes.length; for (var i = 0; i < length; i += 1) { frag.appendChild(childNodes[i]); } returnValue = frag; } return returnValue; } exports.default = htmlSanitizer; /***/ }), /* 10 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview Implement Module for managing import external data such as image * @author NHN Ent. FE Development Lab */ var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var URLRegex = /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})(\/([^\s]*))?$/g; /** * Class ImportManager */ var ImportManager = function () { /** * Creates an instance of ImportManager. * @param {EventManager} eventManager - eventManager * @memberof ImportManager */ function ImportManager(eventManager) { _classCallCheck(this, ImportManager); this.eventManager = eventManager; this._initEvent(); this._initDefaultImageImporter(); } /** * graceful decode uri component * @param {string} originalURI - string to be decoded * @returns {string} decoded string * @memberof ImportManager * @static */ _createClass(ImportManager, [{ key: '_initEvent', /** * Initialize event handler * @memberof ImportManager * @private */ value: function _initEvent() { var _this = this; this.eventManager.listen('drop', function (ev) { var items = ev.data.dataTransfer && ev.data.dataTransfer.files; _this._processBlobItems(items, ev.data); }); this.eventManager.listen('willPaste', function (ev) { // IE has no interface to handle clipboard image. #976 var fragment = ev.data.fragment; var descendant = fragment.querySelectorAll('*'); // only if paste event data has one img element and the element has base64 encoded image if (descendant.length !== 1 || descendant[0].tagName !== 'IMG' || !/^data:image/.test(descendant[0].src)) { return; } ev.data.preventDefault(); var blob = dataURItoBlob(descendant[0].src); _this._emitAddImageBlobHook(blob, 'paste'); }); this.eventManager.listen('paste', function (ev) { _this._processClipboard(ev.data); }); this.eventManager.listen('pasteBefore', function (ev) { _this._decodeURL(ev); }); } /** * Initialize default image importer * @memberof ImportManager * @private */ }, { key: '_initDefaultImageImporter', value: function _initDefaultImageImporter() { this.eventManager.listen('addImageBlobHook', function (blob, callback) { var reader = new FileReader(); reader.onload = function (event) { callback(event.target.result); }; reader.readAsDataURL(blob); }); } /** * Emit add image blob hook * @memberof ImportManager * @param {object} blob - blob or file * @param {string} type - type of an event the item belongs to. paste or drop * @private */ }, { key: '_emitAddImageBlobHook', value: function _emitAddImageBlobHook(blob, type) { var _this2 = this; this.eventManager.emit('addImageBlobHook', blob, function (imageUrl, altText) { _this2.eventManager.emit('command', 'AddImage', { imageUrl: imageUrl, altText: altText || blob.name || 'image' }); }, type); } /** * Decode url when paste link * @param {object} ev - event object * @private */ }, { key: '_decodeURL', value: function _decodeURL(ev) { var decodeURIGraceful = ImportManager.decodeURIGraceful, encodeMarkdownCharacters = ImportManager.encodeMarkdownCharacters; if (ev.source === 'markdown' && ev.data.text) { var texts = ev.data.text; var text = texts[0]; if (texts.length === 1 && text.match(URLRegex)) { text = decodeURIGraceful(text); text = encodeMarkdownCharacters(text); ev.data.update(null, null, [text]); } } else if (ev.source === 'wysiwyg') { var container = ev.$clipboardContainer.get(0); var firstChild = container.childNodes[0]; var _text = firstChild.innerText; if (container.childNodes.length === 1 && firstChild.tagName === 'A' && _text.match(URLRegex)) { firstChild.innerText = decodeURIGraceful(_text); firstChild.href = encodeMarkdownCharacters(firstChild.href); } } } /** * Get blob or excel data from clipboard * @memberof ImportManager * @param {object} evData Clipboard data * @private */ }, { key: '_processClipboard', value: function _processClipboard(evData) { var cbData = evData.clipboardData || window.clipboardData; var blobItems = cbData && cbData.items; var types = cbData.types; if (blobItems && types && types.length === 1 && _tuiCodeSnippet2.default.inArray('Files', [].slice.call(types)) !== -1) { this._processBlobItems(blobItems, evData); } } /** * Process for blob item * @memberof ImportManager * @param {Array.} items Item array * @param {object} evData Event data * @private */ }, { key: '_processBlobItems', value: function _processBlobItems(items, evData) { var _this3 = this; if (items) { _tuiCodeSnippet2.default.forEachArray(items, function (item) { if (item.type.indexOf('image') !== -1) { evData.preventDefault(); evData.stopPropagation(); evData.codemirrorIgnore = true; var blob = item.name ? item : item.getAsFile(); // Blob or File _this3._emitAddImageBlobHook(blob, evData.type); return false; } return true; }); } } }], [{ key: 'decodeURIGraceful', value: function decodeURIGraceful(originalURI) { var uris = originalURI.split(' '); var decodedURIs = []; var decodedURI = void 0; _tuiCodeSnippet2.default.forEachArray(uris, function (uri) { try { decodedURI = decodeURIComponent(uri); decodedURI = decodedURI.replace(/ /g, '%20'); } catch (e) { decodedURI = uri; } return decodedURIs.push(decodedURI); }); return decodedURIs.join(' '); } /** * encode markdown critical characters * @static * @param {string} text - string to encode * @returns {string} - markdown character encoded string * @memberof ImportManager */ }, { key: 'encodeMarkdownCharacters', value: function encodeMarkdownCharacters(text) { return text.replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\[/g, '%5B').replace(/\]/g, '%5D').replace(//g, '%3E'); } /** * escape markdown critical characters * @static * @param {string} text - string to escape * @returns {string} - markdown character escaped string * @memberof ImportManager */ }, { key: 'escapeMarkdownCharacters', value: function escapeMarkdownCharacters(text) { return text.replace(/\(/g, '\\(').replace(/\)/g, '\\)').replace(/\[/g, '\\[').replace(/\]/g, '\\]').replace(//g, '\\>'); } }]); return ImportManager; }(); /** * data URI to Blob * @param {string} dataURI - data URI string * @returns {Blob} - blob data * @ignore */ function dataURItoBlob(dataURI) { var byteString = atob(dataURI.split(',')[1]); var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; var ab = new ArrayBuffer(byteString.length); var ia = new Uint8Array(ab); for (var i = 0; i < byteString.length; i += 1) { ia[i] = byteString.charCodeAt(i); } var blob = new Blob([ab], { type: mimeString }); return blob; } exports.default = ImportManager; /***/ }), /* 11 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _uicontroller = __webpack_require__(8); var _uicontroller2 = _interopRequireDefault(_uicontroller); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @fileoverview Implements Toolbar Item * @author NHN Ent. FE Development Lab */ /** * Toolbar Item * @extends {UIController} */ var ToolbarItem = function (_UIController) { _inherits(ToolbarItem, _UIController); /** * toolbar item constructor * @memberof ToolbarItem * @param {Object} [options={name: 'toolbar-item'}] [description] */ /** * item name * @memberof ToolbarDivider * @type {String} * @static */ function ToolbarItem() { var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { name: ToolbarItem.name }; _classCallCheck(this, ToolbarItem); var _this = _possibleConstructorReturn(this, (ToolbarItem.__proto__ || Object.getPrototypeOf(ToolbarItem)).call(this, _tuiCodeSnippet2.default.extend({ className: ToolbarItem.className }, options))); _this._name = options.name; return _this; } /** * get the name of the toolbar item * @memberof ToolbarItem * @returns {string} - the name of the toolbar item */ /** * toolbar item class name * @memberof ToolbarItem * @type {String} */ _createClass(ToolbarItem, [{ key: 'getName', value: function getName() { return this._name; } }]); return ToolbarItem; }(_uicontroller2.default); Object.defineProperty(ToolbarItem, 'name', { enumerable: true, writable: true, value: 'item' }); Object.defineProperty(ToolbarItem, 'className', { enumerable: true, writable: true, value: 'tui-toolbar-item' }); exports.default = ToolbarItem; /***/ }), /* 12 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; var _preview = __webpack_require__(13); var _preview2 = _interopRequireDefault(_preview); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @fileoverview Implements markdown preview * @author NHN Ent. FE Development Lab */ /** * Class Markdown Preview * @extends {Preview} */ var MarkdownPreview = function (_Preview) { _inherits(MarkdownPreview, _Preview); /** * Creates an instance of MarkdownPreview. * @param {jQuery} $el - base jQuery element * @param {EventManager} eventManager - event manager * @param {Convertor} convertor - convertor * @param {boolean} isViewer - true for view only mode * @memberof MarkdownPreview */ function MarkdownPreview($el, eventManager, convertor, isViewer) { _classCallCheck(this, MarkdownPreview); var _this = _possibleConstructorReturn(this, (MarkdownPreview.__proto__ || Object.getPrototypeOf(MarkdownPreview)).call(this, $el, eventManager, convertor, isViewer)); _this._initEvent(); return _this; } /** * Initialize event * @private */ _createClass(MarkdownPreview, [{ key: '_initEvent', value: function _initEvent() { var _this2 = this; var latestMarkdownValue = ''; this.eventManager.listen('contentChangedFromMarkdown', function (markdownEditor) { latestMarkdownValue = markdownEditor.getValue(); if (_this2.isVisible()) { _this2.lazyRunner.run('refresh', latestMarkdownValue.replace(/
\n/g, '
')); } }); this.eventManager.listen('previewNeedsRefresh', function (value) { _this2.refresh(value || latestMarkdownValue); }); this.$el.on('scroll', function (event) { _this2.eventManager.emit('scroll', { source: 'preview', data: event }); }); } /** * render * @param {string} html - html string to render * @memberof MarkdownPreview * @override */ }, { key: 'render', value: function render(html) { _get(MarkdownPreview.prototype.__proto__ || Object.getPrototypeOf(MarkdownPreview.prototype), 'render', this).call(this, html); this.eventManager.emit('previewRenderAfter', this); } }, { key: 'remove', value: function remove() { this.$el.off('scroll'); this.$el = null; } }]); return MarkdownPreview; }(_preview2.default); exports.default = MarkdownPreview; /***/ }), /* 13 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview Implements preview * @author NHN Ent. FE Development Lab */ var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _lazyRunner = __webpack_require__(20); var _lazyRunner2 = _interopRequireDefault(_lazyRunner); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Class Preview **/ var Preview = function () { /** * Creates an instance of Preview. * @param {jQuery} $el Container element for preview * @param {EventManager} eventManager Event manager instance * @param {Convertor} convertor Convertor instance * @param {boolean} isViewer - whether viewer mode or not * @memberof Preview */ function Preview($el, eventManager, convertor, isViewer) { _classCallCheck(this, Preview); this.eventManager = eventManager; this.convertor = convertor; this.$el = $el; this.isViewer = !!isViewer; this._initContentSection(); this.lazyRunner = new _lazyRunner2.default(); this.lazyRunner.registerLazyRunFunction('refresh', this.refresh, 800, this); } /** * Initialize content selection * @private */ _createClass(Preview, [{ key: '_initContentSection', value: function _initContentSection() { this._$previewContent = (0, _jquery2.default)('
'); this.$el.append(this._$previewContent); } /** * Refresh rendering * @memberof Preview * @param {string} markdown Markdown text */ }, { key: 'refresh', value: function refresh(markdown) { this.render(this.convertor.toHTMLWithCodeHightlight(markdown)); } /** * get html string * @returns {string} - html preview string * @memberof Preview */ }, { key: 'getHTML', value: function getHTML() { return this._$previewContent.html(); } /** * set html string * @param {string} html - html preview string * @memberof Preview */ }, { key: 'setHTML', value: function setHTML(html) { this._$previewContent.html(html); } /** * Render HTML on preview * @memberof Preview * @param {string} html HTML string * @protected */ }, { key: 'render', value: function render(html) { var _$previewContent = this._$previewContent; html = this.eventManager.emit('previewBeforeHook', html) || html; _$previewContent.empty(); _$previewContent.html(html); } /** * Set preview height * @memberof Preview * @param {number} height - Height for preview container */ }, { key: 'setHeight', value: function setHeight(height) { this.$el.get(0).style.height = height + 'px'; } /** * set min height * @param {number} minHeight - min height * @memberof Preview */ }, { key: 'setMinHeight', value: function setMinHeight(minHeight) { this.$el.get(0).style.minHeight = minHeight + 'px'; } /** * Is Preview visible * @returns {boolean} result */ }, { key: 'isVisible', value: function isVisible() { return this.$el.css('display') !== 'none'; } }]); return Preview; }(); exports.default = Preview; /***/ }), /* 14 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var isMac = /Mac/.test(navigator.platform); module.exports = { isMac: isMac }; /***/ }), /* 15 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview Implements EventManager * @author NHN Ent. FE Development Lab */ var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var eventList = ['previewBeforeHook', 'previewRenderAfter', 'previewNeedsRefresh', 'addImageBlobHook', 'setMarkdownAfter', 'contentChangedFromWysiwyg', 'changeFromWysiwyg', 'contentChangedFromMarkdown', 'changeFromMarkdown', 'change', 'changeModeToWysiwyg', 'changeModeToMarkdown', 'changeModeBefore', 'changeMode', 'changePreviewStyle', 'changePreviewTabPreview', 'changePreviewTabWrite', 'openPopupAddLink', 'openPopupAddImage', 'openPopupAddTable', 'openPopupTableUtils', 'openHeadingSelect', 'openPopupCodeBlockLanguages', 'openPopupCodeBlockEditor', 'openDropdownToolbar', 'closePopupCodeBlockLanguages', 'closePopupCodeBlockEditor', 'closeAllPopup', 'command', 'addCommandBefore', 'htmlUpdate', 'markdownUpdate', 'renderedHtmlUpdated', 'removeEditor', 'convertorAfterMarkdownToHtmlConverted', 'convertorBeforeHtmlToMarkdownConverted', 'convertorAfterHtmlToMarkdownConverted', 'stateChange', 'wysiwygSetValueAfter', 'wysiwygSetValueBefore', 'wysiwygGetValueBefore', 'wysiwygProcessHTMLText', 'wysiwygRangeChangeAfter', 'wysiwygKeyEvent', 'scroll', 'click', 'mousedown', 'mouseover', 'mouseout', 'mouseup', 'contextmenu', 'keydown', 'keyup', 'keyMap', 'load', 'focus', 'blur', 'paste', 'pasteBefore', 'willPaste', 'copy', 'copyBefore', 'copyAfter', 'cut', 'cutAfter', 'drop', 'show', 'hide']; /** * Class EventManager */ var EventManager = function () { /** * Creates an instance of EventManager. * @memberof EventManager */ function EventManager() { _classCallCheck(this, EventManager); this.events = new _tuiCodeSnippet2.default.Map(); this.TYPE = new _tuiCodeSnippet2.default.Enum(eventList); } /** * Listen event and bind event handler * @memberof EventManager * @param {string} typeStr Event type string * @param {function} handler Event handler */ _createClass(EventManager, [{ key: 'listen', value: function listen(typeStr, handler) { var typeInfo = this._getTypeInfo(typeStr); var eventHandlers = this.events.get(typeInfo.type) || []; if (!this._hasEventType(typeInfo.type)) { throw new Error('There is no event type ' + typeInfo.type); } if (typeInfo.namespace) { handler.namespace = typeInfo.namespace; } eventHandlers.push(handler); this.events.set(typeInfo.type, eventHandlers); } /** * Emit event * @memberof EventManager * @param {string} eventName Event name to emit * @returns {Array} */ }, { key: 'emit', value: function emit() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var typeStr = args.shift(); var typeInfo = this._getTypeInfo(typeStr); var eventHandlers = this.events.get(typeInfo.type); var results = void 0; if (eventHandlers) { _tuiCodeSnippet2.default.forEach(eventHandlers, function (handler) { var result = handler.apply(undefined, args); if (!_tuiCodeSnippet2.default.isUndefined(result)) { results = results || []; results.push(result); } }); } return results; } /** * Emit given event and return result * @memberof EventManager * @param {string} eventName Event name to emit * @param {string} sourceText Source text to change * @returns {string} */ }, { key: 'emitReduce', value: function emitReduce() { for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } var type = args.shift(); var eventHandlers = this.events.get(type); if (eventHandlers) { _tuiCodeSnippet2.default.forEach(eventHandlers, function (handler) { var result = handler.apply(undefined, args); if (!_tuiCodeSnippet2.default.isFalsy(result)) { args[0] = result; } }); } return args[0]; } /** * Get event type and namespace * @memberof EventManager * @param {string} typeStr Event type name * @returns {{type: string, namespace: string}} * @private */ }, { key: '_getTypeInfo', value: function _getTypeInfo(typeStr) { var splited = typeStr.split('.'); return { type: splited[0], namespace: splited[1] }; } /** * Check whether event type exists or not * @param {string} type Event type name * @returns {boolean} * @private */ }, { key: '_hasEventType', value: function _hasEventType(type) { return !_tuiCodeSnippet2.default.isUndefined(this.TYPE[this._getTypeInfo(type).type]); } /** * Add event type when given event not exists * @memberof EventManager * @param {string} type Event type name */ }, { key: 'addEventType', value: function addEventType(type) { if (this._hasEventType(type)) { throw new Error('There is already have event type ' + type); } this.TYPE.set(type); } /** * Remove event handler from given event type * @memberof EventManager * @param {string} typeStr Event type name * @param {function} [handler] - registered event handler */ }, { key: 'removeEventHandler', value: function removeEventHandler(typeStr, handler) { var _this = this; var _getTypeInfo2 = this._getTypeInfo(typeStr), type = _getTypeInfo2.type, namespace = _getTypeInfo2.namespace; if (type && handler) { this._removeEventHandlerWithHandler(type, handler); } else if (type && !namespace) { // dont use dot notation cuz eslint this.events['delete'](type); } else if (!type && namespace) { this.events.forEach(function (eventHandlers, eventType) { _this._removeEventHandlerWithTypeInfo(eventType, namespace); }); } else if (type && namespace) { this._removeEventHandlerWithTypeInfo(type, namespace); } } /** * Remove event handler with event handler * @param {string} type - event type name * @param {function} handler - event handler * @memberof EventManager * @private */ }, { key: '_removeEventHandlerWithHandler', value: function _removeEventHandlerWithHandler(type, handler) { var eventHandlers = this.events.get(type) || []; var handlerIndex = eventHandlers.indexOf(handler); if (handlerIndex >= 0) { eventHandlers.splice(handlerIndex, 1); } } /** * Remove event handler with event type information * @memberof EventManager * @param {string} type Event type name * @param {string} namespace Event namespace * @private */ }, { key: '_removeEventHandlerWithTypeInfo', value: function _removeEventHandlerWithTypeInfo(type, namespace) { var handlersToSurvive = []; var eventHandlers = this.events.get(type); if (!eventHandlers) { return; } eventHandlers.map(function (handler) { if (handler.namespace !== namespace) { handlersToSurvive.push(handler); } return null; }); this.events.set(type, handlersToSurvive); } }]); return EventManager; }(); exports.default = EventManager; /***/ }), /* 16 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview extension manager * @author NHN Ent. FE Development Lab */ var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Class ExtManager */ var ExtManager = function () { /** * Creates an instance of ExtManager. * @memberof ExtManager */ function ExtManager() { _classCallCheck(this, ExtManager); this.exts = new _tuiCodeSnippet2.default.Map(); } /** * defineExtension * Defined Extension * @memberof ExtManager * @param {string} name extension name * @param {ExtManager~extension} ext extension */ _createClass(ExtManager, [{ key: 'defineExtension', value: function defineExtension(name, ext) { this.exts.set(name, ext); } /** * Apply extensions * @memberof ExtManager * @param {object} context Context * @param {Array.} options - options or names array */ }, { key: 'applyExtension', value: function applyExtension(context, options) { var _this = this; if (options) { options.forEach(function (option) { var hasOption = _tuiCodeSnippet2.default.isObject(option); var name = hasOption ? option.name : option; if (_this.exts.has(name)) { var ext = _this.exts.get(name); if (hasOption) { ext(context, option); } else { ext(context); } } }); } } }]); return ExtManager; }(); exports.default = new ExtManager(); /***/ }), /* 17 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview Convertor have responsible to convert markdown and html * @author NHN Ent. FE Development Lab */ var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _markdownIt = __webpack_require__(22); var _markdownIt2 = _interopRequireDefault(_markdownIt); var _toMark = __webpack_require__(23); var _toMark2 = _interopRequireDefault(_toMark); var _htmlSanitizer = __webpack_require__(9); var _htmlSanitizer2 = _interopRequireDefault(_htmlSanitizer); var _markdownitTaskPlugin = __webpack_require__(24); var _markdownitTaskPlugin2 = _interopRequireDefault(_markdownitTaskPlugin); var _markdownitCodeBlockPlugin = __webpack_require__(25); var _markdownitCodeBlockPlugin2 = _interopRequireDefault(_markdownitCodeBlockPlugin); var _markdownitCodeRenderer = __webpack_require__(26); var _markdownitCodeRenderer2 = _interopRequireDefault(_markdownitCodeRenderer); var _markdownitBlockQuoteRenderer = __webpack_require__(27); var _markdownitBlockQuoteRenderer2 = _interopRequireDefault(_markdownitBlockQuoteRenderer); var _markdownitTableRenderer = __webpack_require__(28); var _markdownitTableRenderer2 = _interopRequireDefault(_markdownitTableRenderer); var _markdownitHtmlBlockRenderer = __webpack_require__(29); var _markdownitHtmlBlockRenderer2 = _interopRequireDefault(_markdownitHtmlBlockRenderer); var _markdownitBackticksRenderer = __webpack_require__(30); var _markdownitBackticksRenderer2 = _interopRequireDefault(_markdownitBackticksRenderer); var _codeBlockManager = __webpack_require__(7); var _codeBlockManager2 = _interopRequireDefault(_codeBlockManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var markdownitHighlight = new _markdownIt2.default({ html: true, breaks: true, quotes: '“”‘’', langPrefix: 'lang-', highlight: function highlight(codeText, type) { return _codeBlockManager2.default.createCodeBlockHtml(type, codeText); } }); var markdownit = new _markdownIt2.default({ html: true, breaks: true, quotes: '“”‘’', langPrefix: 'lang-' }); // markdownitHighlight markdownitHighlight.block.ruler.at('code', _markdownitCodeRenderer2.default); markdownitHighlight.block.ruler.at('table', _markdownitTableRenderer2.default, { alt: ['paragraph', 'reference'] }); markdownitHighlight.block.ruler.at('blockquote', _markdownitBlockQuoteRenderer2.default, { alt: ['paragraph', 'reference', 'blockquote', 'list'] }); markdownitHighlight.block.ruler.at('html_block', _markdownitHtmlBlockRenderer2.default, { alt: ['paragraph', 'reference', 'blockquote'] }); markdownitHighlight.inline.ruler.at('backticks', _markdownitBackticksRenderer2.default); markdownitHighlight.use(_markdownitTaskPlugin2.default); markdownitHighlight.use(_markdownitCodeBlockPlugin2.default); // markdownit markdownit.block.ruler.at('code', _markdownitCodeRenderer2.default); markdownit.block.ruler.at('table', _markdownitTableRenderer2.default, { alt: ['paragraph', 'reference'] }); markdownit.block.ruler.at('blockquote', _markdownitBlockQuoteRenderer2.default, { alt: ['paragraph', 'reference', 'blockquote', 'list'] }); markdownit.block.ruler.at('html_block', _markdownitHtmlBlockRenderer2.default, { alt: ['paragraph', 'reference', 'blockquote'] }); markdownit.inline.ruler.at('backticks', _markdownitBackticksRenderer2.default); markdownit.use(_markdownitTaskPlugin2.default); markdownit.use(_markdownitCodeBlockPlugin2.default); /** * Class Convertor */ var Convertor = function () { /** * Convertor constructor * @param {EventManager} em - EventManager instance */ function Convertor(em) { _classCallCheck(this, Convertor); this.eventManager = em; } /** * _markdownToHtmlWithCodeHighlight * Convert markdown to html with Codehighlight * @private * @memberof Convertor * @param {string} markdown markdown text * @returns {string} html text */ _createClass(Convertor, [{ key: '_markdownToHtmlWithCodeHighlight', value: function _markdownToHtmlWithCodeHighlight(markdown) { markdown = markdown.replace(/
/ig, '
'); // eslint-disable-next-line var onerrorStripeRegex = /(]*)(onerror\s*=\s*[\"']?[^\"']*[\"']?)(.*)/i; while (onerrorStripeRegex.exec(markdown)) { markdown = markdown.replace(onerrorStripeRegex, '$1$3'); } var renderedHTML = markdownitHighlight.render(markdown); renderedHTML = this._removeBrToMarkPassAttributeInCode(renderedHTML); return renderedHTML; } /** * _markdownToHtml * Convert markdown to html * @private * @memberof Convertor * @param {string} markdown markdown text * @returns {string} html text */ }, { key: '_markdownToHtml', value: function _markdownToHtml(markdown) { markdown = markdown.replace(/
/ig, '
'); // eslint-disable-next-line var onerrorStripeRegex = /(]*)(onerror\s*=\s*[\"']?[^\"']*[\"']?)(.*)/i; while (onerrorStripeRegex.exec(markdown)) { markdown = markdown.replace(onerrorStripeRegex, '$1$3'); } var renderedHTML = markdownit.render(markdown); renderedHTML = this._removeBrToMarkPassAttributeInCode(renderedHTML); return renderedHTML; } /** * Remove BR's data-tomark-pass attribute text when br in code element * @param {string} renderedHTML Rendered HTML string from markdown editor * @returns {string} * @private */ }, { key: '_removeBrToMarkPassAttributeInCode', value: function _removeBrToMarkPassAttributeInCode(renderedHTML) { var $wrapperDiv = (0, _jquery2.default)('
'); $wrapperDiv.html(renderedHTML); $wrapperDiv.find('code, pre').each(function (i, codeOrPre) { var $code = (0, _jquery2.default)(codeOrPre); $code.html($code.html().replace(/<br data-tomark-pass>/, '<br>')); }); renderedHTML = $wrapperDiv.html(); return renderedHTML; } /** * toHTMLWithCodeHightlight * Convert markdown to html with Codehighlight * emit convertorAfterMarkdownToHtmlConverted * @memberof Convertor * @param {string} markdown markdown text * @returns {string} html text */ }, { key: 'toHTMLWithCodeHightlight', value: function toHTMLWithCodeHightlight(markdown) { var html = this._markdownToHtmlWithCodeHighlight(markdown); html = this.eventManager.emitReduce('convertorAfterMarkdownToHtmlConverted', html); return html; } /** * toHTML * Convert markdown to html * emit convertorAfterMarkdownToHtmlConverted * @memberof Convertor * @param {string} markdown markdown text * @returns {string} html text */ }, { key: 'toHTML', value: function toHTML(markdown) { var html = this._markdownToHtml(markdown); html = this.eventManager.emitReduce('convertorAfterMarkdownToHtmlConverted', html); return html; } }, { key: 'initHtmlSanitizer', value: function initHtmlSanitizer() { this.eventManager.listen('convertorAfterMarkdownToHtmlConverted', function (html) { return (0, _htmlSanitizer2.default)(html, true); }); } /** * toMarkdown * Convert html to markdown * emit convertorAfterHtmlToMarkdownConverted * @memberof Convertor * @param {string} html html text * @param {object | null} toMarkOptions - toMark library options * @returns {string} markdown text */ }, { key: 'toMarkdown', value: function toMarkdown(html, toMarkOptions) { var resultArray = []; html = this.eventManager.emitReduce('convertorBeforeHtmlToMarkdownConverted', html); var markdown = (0, _toMark2.default)(this._appendAttributeForBrIfNeed(html), toMarkOptions); markdown = this.eventManager.emitReduce('convertorAfterHtmlToMarkdownConverted', markdown); _tuiCodeSnippet2.default.forEach(markdown.split('\n'), function (line, index) { var FIND_TABLE_RX = /^\|[^|]*\|/ig; var FIND_CODE_RX = /`[^`]*
[^`]*`/ig; if (!FIND_CODE_RX.test(line) && !FIND_TABLE_RX.test(line)) { line = line.replace(/
/ig, '
\n'); } resultArray[index] = line; }); return resultArray.join('\n'); } }, { key: '_appendAttributeForBrIfNeed', value: function _appendAttributeForBrIfNeed(html) { var FIND_BR_RX = /
/ig; var FIND_DOUBLE_BR_RX = /

/ig; var FIND_PASSING_AND_NORMAL_BR_RX = /

(.)/ig; var FIRST_TWO_BRS_BEFORE_RX = /([^>]|<\/a>|<\/code>|<\/span>|<\/b>|<\/i>|<\/s>|]*>)/; var TWO_BRS_RX = /

/; var FIND_FIRST_TWO_BRS_RX = new RegExp(FIRST_TWO_BRS_BEFORE_RX.source + TWO_BRS_RX.source, 'g'); html = html.replace(FIND_BR_RX, '
'); html = html.replace(FIND_DOUBLE_BR_RX, '

'); var div = document.createElement('div'); var $div = (0, _jquery2.default)(div); $div.html(html); $div.find('pre br,code br').each(function (index, node) { if (node.hasAttribute('data-tomark-pass')) { node.removeAttribute('data-tomark-pass'); } }); html = $div.html().replace(/
/ig, '
'); html = html.replace(FIND_BR_RX, '
'); html = html.replace(FIND_PASSING_AND_NORMAL_BR_RX, '

$1'); html = html.replace(FIND_FIRST_TWO_BRS_RX, '$1

'); return html; } /** * get markdownit with code highlight * @returns {markdownit} - markdownit instance * @memberof Convertor * @static */ }], [{ key: 'getMarkdownitHighlightRenderer', value: function getMarkdownitHighlightRenderer() { return markdownitHighlight; } /** * get markdownit * @returns {markdownit} - markdownit instance * @memberof Convertor * @static */ }, { key: 'getMarkdownitRenderer', value: function getMarkdownitRenderer() { return markdownit; } }]); return Convertor; }(); exports.default = Convertor; /***/ }), /* 18 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _toolbarItem = __webpack_require__(11); var _toolbarItem2 = _interopRequireDefault(_toolbarItem); var _tooltip = __webpack_require__(34); var _tooltip2 = _interopRequireDefault(_tooltip); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @fileoverview Implements UI Button * @author NHN Ent. FE Development Lab */ /** * Class Button UI * @extends {ToolbarItem} * @deprecated */ var Button = function (_ToolbarItem) { _inherits(Button, _ToolbarItem); /** * Creates an instance of Button. * @param {object} options - button options * @param {jquery} $el - button rootElement * @param {string} options.className - button class name * @param {string} options.command - command name to execute on click * @param {string} options.event - event name to trigger on click * @param {string} options.text - text on button * @param {string} options.tooltip - text on tooltip * @param {string} options.style - button style * @param {string} options.state - button state * @memberof Button */ /** * item name * @memberof Button * @type {String} * @static */ function Button() { var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { tagName: 'button', name: Button.name }; _classCallCheck(this, Button); var _this = _possibleConstructorReturn(this, (Button.__proto__ || Object.getPrototypeOf(Button)).call(this, { name: options.name, tagName: 'button', className: options.className + ' ' + Button.className, rootElement: options.$el })); _this._setOptions(options); _this._render(); _this.on('click', _this._onClick.bind(_this)); if (options.tooltip) { _this.on('mouseover', _this._onOver.bind(_this)); _this.on('mouseout', _this._onOut.bind(_this)); } return _this; } /** * set tooltip text * @param {string} text - tooltip text to show * @memberof Button */ /** * ToolbarItem className * @type {String} * @memberof Button * @static */ _createClass(Button, [{ key: 'setTooltip', value: function setTooltip(text) { this._tooltip = text; } }, { key: '_setOptions', value: function _setOptions(options) { this._command = options.command; this._event = options.event; this._text = options.text; this._tooltip = options.tooltip; this._style = options.style; this._state = options.state; } }, { key: '_render', value: function _render() { this.$el.text(this._text); this.$el.attr('type', 'button'); if (this._style) { this.$el.attr('style', this._style); } } }, { key: '_onClick', value: function _onClick() { if (!this.isEnabled()) { return; } if (this._command) { this.trigger('command', this._command); } else if (this._event) { this.trigger('event', this._event); } this.trigger('clicked'); } }, { key: '_onOver', value: function _onOver() { if (!this.isEnabled()) { return; } _tooltip2.default.show(this.$el, this._tooltip); } }, { key: '_onOut', value: function _onOut() { _tooltip2.default.hide(); } /** * enable button * @memberof Button */ }, { key: 'enable', value: function enable() { this.$el.attr('disabled', false); } /** * disable button * @memberof Button */ }, { key: 'disable', value: function disable() { this.$el.attr('disabled', true); } /** * check whether this button is enabled * @returns {Boolean} - true for enabled * @memberof Button */ }, { key: 'isEnabled', value: function isEnabled() { return !this.$el.attr('disabled'); } }]); return Button; }(_toolbarItem2.default); Object.defineProperty(Button, 'name', { enumerable: true, writable: true, value: 'button' }); Object.defineProperty(Button, 'className', { enumerable: true, writable: true, value: 'tui-toolbar-icons' }); exports.default = Button; /***/ }), /* 19 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * @fileoverview Implements KeyMapper * @author NHN Ent. FE Development Lab */ /** * Constant of key mapping * @type {string[]} * @ignore */ var KEYBOARD_MAP = ['', // [0] '', // [1] '', // [2] 'CANCEL', // [3] '', // [4] '', // [5] 'HELP', // [6] '', // [7] 'BACK_SPACE', // [8] 'TAB', // [9] '', // [10] '', // [11] 'CLEAR', // [12] 'ENTER', // [13] 'ENTER_SPECIAL', // [14] '', // [15] '', // [16] SHIFT '', // [17] CONTROL '', // [18] ALT 'PAUSE', // [19] 'CAPS_LOCK', // [20] 'KANA', // [21] 'EISU', // [22] 'JUNJA', // [23] 'FINAL', // [24] 'HANJA', // [25] '', // [26] 'ESCAPE', // [27] 'CONVERT', // [28] 'NONCONVERT', // [29] 'ACCEPT', // [30] 'MODECHANGE', // [31] 'SPACE', // [32] 'PAGE_UP', // [33] 'PAGE_DOWN', // [34] 'END', // [35] 'HOME', // [36] 'LEFT', // [37] 'UP', // [38] 'RIGHT', // [39] 'DOWN', // [40] 'SELECT', // [41] 'PRINT', // [42] 'EXECUTE', // [43] 'PRINTSCREEN', // [44] 'INSERT', // [45] 'DELETE', // [46] '', // [47] '0', // [48] '1', // [49] '2', // [50] '3', // [51] '4', // [52] '5', // [53] '6', // [54] '7', // [55] '8', // [56] '9', // [57] ':', // [58] ';', // [59] '<', // [60] '=', // [61] '>', // [62] '?', // [63] 'AT', // [64] 'A', // [65] 'B', // [66] 'C', // [67] 'D', // [68] 'E', // [69] 'F', // [70] 'G', // [71] 'H', // [72] 'I', // [73] 'J', // [74] 'K', // [75] 'L', // [76] 'M', // [77] 'N', // [78] 'O', // [79] 'P', // [80] 'Q', // [81] 'R', // [82] 'S', // [83] 'T', // [84] 'U', // [85] 'V', // [86] 'W', // [87] 'X', // [88] 'Y', // [89] 'Z', // [90] '', // [91] META '', // [92] 'CONTEXT_MENU', // [93] '', // [94] 'SLEEP', // [95] 'NUMPAD0', // [96] 'NUMPAD1', // [97] 'NUMPAD2', // [98] 'NUMPAD3', // [99] 'NUMPAD4', // [100] 'NUMPAD5', // [101] 'NUMPAD6', // [102] 'NUMPAD7', // [103] 'NUMPAD8', // [104] 'NUMPAD9', // [105] 'MULTIPLY', // [106] 'ADD', // [107] 'SEPARATOR', // [108] 'SUBTRACT', // [109] 'DECIMAL', // [110] 'DIVIDE', // [111] 'F1', // [112] 'F2', // [113] 'F3', // [114] 'F4', // [115] 'F5', // [116] 'F6', // [117] 'F7', // [118] 'F8', // [119] 'F9', // [120] 'F10', // [121] 'F11', // [122] 'F12', // [123] 'F13', // [124] 'F14', // [125] 'F15', // [126] 'F16', // [127] 'F17', // [128] 'F18', // [129] 'F19', // [130] 'F20', // [131] 'F21', // [132] 'F22', // [133] 'F23', // [134] 'F24', // [135] '', // [136] '', // [137] '', // [138] '', // [139] '', // [140] '', // [141] '', // [142] '', // [143] 'NUM_LOCK', // [144] 'SCROLL_LOCK', // [145] 'WIN_OEM_FJ_JISHO', // [146] 'WIN_OEM_FJ_MASSHOU', // [147] 'WIN_OEM_FJ_TOUROKU', // [148] 'WIN_OEM_FJ_LOYA', // [149] 'WIN_OEM_FJ_ROYA', // [150] '', // [151] '', // [152] '', // [153] '', // [154] '', // [155] '', // [156] '', // [157] '', // [158] '', // [159] '@', // [160] '!', // [161] '"', // [162] '#', // [163] '$', // [164] '%', // [165] '&', // [166] '_', // [167] '(', // [168] ')', // [169] '*', // [170] '+', // [171] '|', // [172] '-', // [173] '{', // [174] '}', // [175] '~', // [176] '', // [177] '', // [178] '', // [179] '', // [180] 'VOLUME_MUTE', // [181] 'VOLUME_DOWN', // [182] 'VOLUME_UP', // [183] '', // [184] '', // [185] ';', // [186] '=', // [187] ',', // [188] '-', // [189] '.', // [190] '/', // [191] '`', // [192] '', // [193] '', // [194] '', // [195] '', // [196] '', // [197] '', // [198] '', // [199] '', // [200] '', // [201] '', // [202] '', // [203] '', // [204] '', // [205] '', // [206] '', // [207] '', // [208] '', // [209] '', // [210] '', // [211] '', // [212] '', // [213] '', // [214] '', // [215] '', // [216] '', // [217] '', // [218] '[', // [219] '\\', // [220] ']', // [221] '\'', // [222] '', // [223] 'META', // [224] 'ALTGR', // [225] '', // [226] 'WIN_ICO_HELP', // [227] 'WIN_ICO_00', // [228] '', // [229] 'WIN_ICO_CLEAR', // [230] '', // [231] '', // [232] 'WIN_OEM_RESET', // [233] 'WIN_OEM_JUMP', // [234] 'WIN_OEM_PA1', // [235] 'WIN_OEM_PA2', // [236] 'WIN_OEM_PA3', // [237] 'WIN_OEM_WSCTRL', // [238] 'WIN_OEM_CUSEL', // [239] 'WIN_OEM_ATTN', // [240] 'WIN_OEM_FINISH', // [241] 'WIN_OEM_COPY', // [242] 'WIN_OEM_AUTO', // [243] 'WIN_OEM_ENLW', // [244] 'WIN_OEM_BACKTAB', // [245] 'ATTN', // [246] 'CRSEL', // [247] 'EXSEL', // [248] 'EREOF', // [249] 'PLAY', // [250] 'ZOOM', // [251] '', // [252] 'PA1', // [253] 'WIN_OEM_CLEAR', // [254] '' // [255] ]; var sharedInstance = void 0; /** * Class KeyMapper */ var KeyMapper = function () { /** * Creates an instance of KeyMapper. * @param {object} [options] options * @param {string} options.splitter splitter string default is + * @memberof KeyMapper */ function KeyMapper(options) { _classCallCheck(this, KeyMapper); this._setSplitter(options); } /** * Set key splitter * @param {object} options Option object * @memberof KeyMapper * @private */ _createClass(KeyMapper, [{ key: '_setSplitter', value: function _setSplitter(options) { var splitter = options ? options.splitter : '+'; this._splitter = splitter; } /** * Convert event to keyMap * @memberof KeyMapper * @param {event} event Event object * @returns {string} */ }, { key: 'convert', value: function convert(event) { var keyMap = []; if (event.shiftKey) { keyMap.push('SHIFT'); } if (event.ctrlKey) { keyMap.push('CTRL'); } if (event.metaKey) { keyMap.push('META'); } if (event.altKey) { keyMap.push('ALT'); } var keyChar = this._getKeyCodeChar(event.keyCode); if (keyChar) { keyMap.push(keyChar); } return keyMap.join(this._splitter); } /** * Get character from key code * @memberof KeyMapper * @param {number} keyCode Key code * @returns {string} * @private */ }, { key: '_getKeyCodeChar', value: function _getKeyCodeChar(keyCode) { var keyCodeCharacter = KEYBOARD_MAP[keyCode]; return keyCodeCharacter; } /** * Get sharedInstance * @memberof KeyMapper * @returns {KeyMapper} */ }], [{ key: 'getSharedInstance', value: function getSharedInstance() { if (!sharedInstance) { sharedInstance = new KeyMapper(); } return sharedInstance; } /** * get key code for a character * @static * @param {string} char - a character to be converted * @returns {number} key code for the char * @memberof KeyMapper */ }, { key: 'keyCode', value: function keyCode(char) { return KEYBOARD_MAP.indexOf(char); } }]); return KeyMapper; }(); exports.default = KeyMapper; /***/ }), /* 20 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview Implements LazyRunner * @author NHN Ent. FE Development Lab */ var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Class LazyRunner */ var LazyRunner = function () { /** * Creates an instance of LazyRunner. * @memberof LazyRunner */ function LazyRunner() { _classCallCheck(this, LazyRunner); this.globalTOID = null; this.lazyRunFunctions = {}; } _createClass(LazyRunner, [{ key: 'run', value: function run(fn, params, context, delay) { var TOID = void 0; if (_tuiCodeSnippet2.default.isString(fn)) { TOID = this._runRegisteredRun(fn, params, context, delay); } else { TOID = this._runSingleRun(fn, params, context, delay, this.globalTOID); this.globalTOID = TOID; } return TOID; } }, { key: 'registerLazyRunFunction', value: function registerLazyRunFunction(name, fn, delay, context) { context = context || this; this.lazyRunFunctions[name] = { fn: fn, delay: delay, context: context, TOID: null }; } }, { key: '_runSingleRun', value: function _runSingleRun(fn, params, context, delay, TOID) { this._clearTOIDIfNeed(TOID); TOID = setTimeout(function () { fn.call(context, params); }, delay); return TOID; } }, { key: '_runRegisteredRun', value: function _runRegisteredRun(lazyRunName, params, context, delay) { var lazyRunFunction = this.lazyRunFunctions[lazyRunName]; var fn = lazyRunFunction.fn; var TOID = lazyRunFunction.TOID; delay = delay || lazyRunFunction.delay; context = context || lazyRunFunction.context; TOID = this._runSingleRun(fn, params, context, delay, TOID); lazyRunFunction.TOID = TOID; return TOID; } }, { key: '_clearTOIDIfNeed', value: function _clearTOIDIfNeed(TOID) { if (TOID) { clearTimeout(TOID); } } }]); return LazyRunner; }(); exports.default = LazyRunner; /***/ }), /* 21 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview Implements Command * @author NHN Ent. FE Development Lab */ var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Class Command */ var Command = function () { /** * @param {string} name Command name * @param {number} type Command type (Command.TYPE) * @param {Array.} [keyMap] keyMap */ function Command(name, type, keyMap) { _classCallCheck(this, Command); this.name = name; this.type = type; if (keyMap) { this.setKeyMap(keyMap); } } /** * getName * returns Name of command * @memberof Command * @returns {string} Command Name */ _createClass(Command, [{ key: 'getName', value: function getName() { return this.name; } /** * getType * returns Type of command * @memberof Command * @returns {number} Command Command type number */ }, { key: 'getType', value: function getType() { return this.type; } /** * isMDType * returns whether Command Type is Markdown or not * @memberof Command * @returns {boolean} result */ }, { key: 'isMDType', value: function isMDType() { return this.type === Command.TYPE.MD; } /** * isWWType * returns whether Command Type is Wysiwyg or not * @memberof Command * @returns {boolean} result */ }, { key: 'isWWType', value: function isWWType() { return this.type === Command.TYPE.WW; } /** * isGlobalType * returns whether Command Type is Global or not * @memberof Command * @returns {boolean} result */ }, { key: 'isGlobalType', value: function isGlobalType() { return this.type === Command.TYPE.GB; } /** * setKeyMap * Set keymap value for each os * @memberof Command * @param {string} win Windows Key(and etc) * @param {string} mac Mac osx key */ }, { key: 'setKeyMap', value: function setKeyMap(win, mac) { this.keyMap = [win, mac]; } }]); return Command; }(); /** * Command factory method * @memberof Command * @param {string} typeStr Editor type name * @param {object} props Property * @param {string} props.name Command name * @param {number} props.type Command type number * @returns {Command} */ Command.factory = function (typeStr, props) { var type = void 0; if (typeStr === 'markdown') { type = Command.TYPE.MD; } else if (typeStr === 'wysiwyg') { type = Command.TYPE.WW; } else if (typeStr === 'global') { type = Command.TYPE.GB; } var command = new Command(props.name, type); _tuiCodeSnippet2.default.extend(command, props); return command; }; /** * Command Type Constant * markdown : 0 * wysiwyg : 1 * global : 2 * @memberof Command * @type {object} */ Command.TYPE = { MD: 0, WW: 1, GB: 2 }; exports.default = Command; /***/ }), /* 22 */ /***/ (function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE_22__; /***/ }), /* 23 */ /***/ (function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE_23__; /***/ }), /* 24 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // Copyright (c) 2016, Revin Guillen. // Distributed under an MIT license: https://github.com/revin/markdown-it-task-lists/ /** * @fileoverview Implements markdownitTaskPlugin * @modifier Sungho Kim(sungho-kim@nhnent.com) FE Development Lab/NHN Ent. * @modifier Junghwan Park(junghwan.park@nhnent.com) FE Development Lab/NHN Ent. */ /* eslint-disable */ /** * Task list renderer for Markdown-it * @param {object} markdownit Markdown-it instance * @ignore */ var MarkdownitTaskRenderer = function MarkdownitTaskRenderer(markdownit) { markdownit.core.ruler.after('inline', 'tui-task-list', function (state) { var TASK_LIST_ITEM_CLASS_NAME = 'task-list-item'; var CHECKED_CLASS_NAME = 'checked'; var tokens = state.tokens; var className; var tokenIndex; // tokenIndex=0 'ul', tokenIndex=1 'li', tokenIndex=2 'p_open' for (tokenIndex = 2; tokenIndex < tokens.length; tokenIndex += 1) { if (isTaskListItemToken(tokens, tokenIndex)) { if (isChecked(tokens[tokenIndex])) { className = TASK_LIST_ITEM_CLASS_NAME + ' ' + CHECKED_CLASS_NAME; } else { className = TASK_LIST_ITEM_CLASS_NAME; } removeMarkdownTaskFormatText(tokens[tokenIndex]); setTokenAttribute(tokens[tokenIndex - 2], 'class', className); setTokenAttribute(tokens[tokenIndex - 2], 'data-te-task', ''); } } }); }; /** * Remove task format text for rendering * @param {object} token Token object * @ignore */ function removeMarkdownTaskFormatText(token) { // '[X] ' length is 4 // FIXED: we don't need first space token.content = token.content.slice(4); token.children[0].content = token.children[0].content.slice(4); } /** * Return boolean value whether task checked or not * @param {object} token Token object * @returns {boolean} * @ignore */ function isChecked(token) { var checked = false; if (token.content.indexOf('[x]') === 0 || token.content.indexOf('[X]') === 0) { checked = true; } return checked; } /** * Set attribute of passed token * @param {object} token Token object * @param {string} attributeName Attribute name for set * @param {string} attributeValue Attribute value for set * @ignore */ function setTokenAttribute(token, attributeName, attributeValue) { var index = token.attrIndex(attributeName); var attr = [attributeName, attributeValue]; if (index < 0) { token.attrPush(attr); } else { token.attrs[index] = attr; } } /** * Return boolean value whether task list item or not * @param {array} tokens Token object * @param {number} index Number of token index * @returns {boolean} * @ignore */ function isTaskListItemToken(tokens, index) { return tokens[index].type === 'inline' && tokens[index - 1].type === 'paragraph_open' && tokens[index - 2].type === 'list_item_open' && (tokens[index].content.indexOf('[ ]') === 0 || tokens[index].content.indexOf('[x]') === 0 || tokens[index].content.indexOf('[X]') === 0); } /* eslint-enable */ module.exports = MarkdownitTaskRenderer; /***/ }), /* 25 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // Copyright (c) 2016, Revin Guillen. // Distributed under an MIT license: https://github.com/revin/markdown-it-task-lists/ /* eslint-disable */ /** * @fileoverview Implements markdownitCodeBlockPlugin * @modifier NHN Ent. FE Development Lab */ /** * Code block renderer for Markdown-it * @param {object} markdownit Markdown-it instance * @ignore */ var MarkdownitCodeBlockRenderer = function MarkdownitCodeBlockRenderer(markdownit) { markdownit.core.ruler.after('block', 'tui-code-block', function (state) { var DEFAULT_NUMBER_OF_BACKTICKS = 3; var tokens = state.tokens; var currentToken, tokenIndex, numberOfBackticks; for (tokenIndex = 0; tokenIndex < tokens.length; tokenIndex += 1) { currentToken = tokens[tokenIndex]; if (isCodeFenceToken(currentToken)) { numberOfBackticks = currentToken.markup.length; if (numberOfBackticks > DEFAULT_NUMBER_OF_BACKTICKS) { setTokenAttribute(currentToken, 'data-backticks', numberOfBackticks, true); } if (currentToken.info) { setTokenAttribute(currentToken, 'data-language', escape(currentToken.info.replace(' ', ''), true)); } } } }); }; /** * Set attribute of passed token * @param {object} token Token object * @param {string} attributeName Attribute name for set * @param {string} attributeValue Attribute value for set * @ignore */ function setTokenAttribute(token, attributeName, attributeValue) { var index = token.attrIndex(attributeName); var attr = [attributeName, attributeValue]; if (index < 0) { token.attrPush(attr); } else { token.attrs[index] = attr; } } /** * Return boolean value whether passed token is code fence or not * @param {object} token Token object * @returns {boolean} * @ignore */ function isCodeFenceToken(token) { return token.block === true && token.tag === 'code' && token.type === 'fence'; } /** * escape code from markdown-it * @param {string} html HTML string * @param {string} encode Boolean value of whether encode or not * @returns {string} * @ignore */ function escape(html, encode) { return html.replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, '''); } /* eslint-enable */ module.exports = MarkdownitCodeBlockRenderer; /***/ }), /* 26 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // Copyright (c) 2014 Vitaly Puzrin, Alex Kocharin. // Distributed under an ISC license: https://github.com/markdown-it/markdown-it/ /** * @fileoverview Implements MarkdownItCodeRenderer * @modifier NHN Ent. FE Development Lab */ /* eslint-disable */ module.exports = function code(state, startLine, endLine /*, silent*/) { // Added by Junghwan Park var FIND_LIST_RX = / {0,3}(?:-|\*|\d\.) /; var lines = state.src.split('\n'); var currentLine = lines[startLine]; // Added by Junghwan Park var nextLine, last, token, emptyLines = 0; // Add condition by Junghwan Park if (currentLine.match(FIND_LIST_RX) || state.sCount[startLine] - state.blkIndent < 4) { // Add condition by Junghwan Park return false; } last = nextLine = startLine + 1; while (nextLine < endLine) { if (state.isEmpty(nextLine)) { emptyLines++; // workaround for lists: 2 blank lines should terminate indented // code block, but not fenced code block if (emptyLines >= 2 && state.parentType === 'list') { break; } nextLine++; continue; } emptyLines = 0; if (state.sCount[nextLine] - state.blkIndent >= 4) { nextLine++; last = nextLine; continue; } break; } state.line = last; token = state.push('code_block', 'code', 0); token.content = state.getLines(startLine, last, 4 + state.blkIndent, true); token.map = [startLine, state.line]; return true; }; /* eslint-enable */ /***/ }), /* 27 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // Copyright (c) 2014 Vitaly Puzrin, Alex Kocharin. // Distributed under MIT license: https://github.com/markdown-it/markdown-it/ /** * @fileoverview Implements markdownitCodeBlockQuoteRenderer * @modifier NHN Ent. FE Development Lab */ /* eslint-disable */ // Block quotes // prevent quote, pre in list #811 // ref: #989 // #811 START // var isSpace = require('../common/utils').isSpace; function isSpace(code) { switch (code) { case 0x09: case 0x20: return true; } return false; } // #811 END module.exports = function blockquote(state, startLine, endLine, silent) { var adjustTab, ch, i, initial, l, lastLineEmpty, lines, nextLine, offset, oldBMarks, oldBSCount, oldIndent, oldParentType, oldSCount, oldTShift, spaceAfterMarker, terminate, terminatorRules, token, wasOutdented, oldLineMax = state.lineMax, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine]; // #811 START var FIND_LIST_RX = /(?:-|\*|\d+\.) {1,4}(?:> {0,3})[^>]*$/; var sourceLines = state.src.split('\n'); var currentLine = sourceLines[startLine]; // #811 END // if it's indented more than 3 spaces, it should be a code block if (state.sCount[startLine] - state.blkIndent >= 4) { return false; } // check the block quote marker if (state.src.charCodeAt(pos++) !== 0x3E /* > */) { return false; } // #811 START // check block quote in list if (currentLine.match(FIND_LIST_RX) /*&& !currentLine.match(/^ {0,6}>/)*/) { return false; } // #811 END // we know that it's going to be a valid blockquote, // so no point trying to find the end of it in silent mode if (silent) { return true; } // skip spaces after ">" and re-calculate offset initial = offset = state.sCount[startLine] + pos - (state.bMarks[startLine] + state.tShift[startLine]); // skip one optional space after '>' if (state.src.charCodeAt(pos) === 0x20 /* space */) { // ' > test ' // ^ -- position start of line here: pos++; initial++; offset++; adjustTab = false; spaceAfterMarker = true; } else if (state.src.charCodeAt(pos) === 0x09 /* tab */) { spaceAfterMarker = true; if ((state.bsCount[startLine] + offset) % 4 === 3) { // ' >\t test ' // ^ -- position start of line here (tab has width===1) pos++; initial++; offset++; adjustTab = false; } else { // ' >\t test ' // ^ -- position start of line here + shift bsCount slightly // to make extra space appear adjustTab = true; } } else { spaceAfterMarker = false; } oldBMarks = [state.bMarks[startLine]]; state.bMarks[startLine] = pos; while (pos < max) { ch = state.src.charCodeAt(pos); if (isSpace(ch)) { if (ch === 0x09) { offset += 4 - (offset + state.bsCount[startLine] + (adjustTab ? 1 : 0)) % 4; } else { offset++; } } else { break; } pos++; } oldBSCount = [state.bsCount[startLine]]; state.bsCount[startLine] = state.sCount[startLine] + 1 + (spaceAfterMarker ? 1 : 0); lastLineEmpty = pos >= max; oldSCount = [state.sCount[startLine]]; state.sCount[startLine] = offset - initial; oldTShift = [state.tShift[startLine]]; state.tShift[startLine] = pos - state.bMarks[startLine]; terminatorRules = state.md.block.ruler.getRules('blockquote'); oldParentType = state.parentType; state.parentType = 'blockquote'; wasOutdented = false; // Search the end of the block // // Block ends with either: // 1. an empty line outside: // ``` // > test // // ``` // 2. an empty line inside: // ``` // > // test // ``` // 3. another tag: // ``` // > test // - - - // ``` for (nextLine = startLine + 1; nextLine < endLine; nextLine++) { // check if it's outdented, i.e. it's inside list item and indented // less than said list item: // // ``` // 1. anything // > current blockquote // 2. checking this line // ``` if (state.sCount[nextLine] < state.blkIndent) wasOutdented = true; pos = state.bMarks[nextLine] + state.tShift[nextLine]; max = state.eMarks[nextLine]; if (pos >= max) { // Case 1: line is not inside the blockquote, and this line is empty. break; } if (state.src.charCodeAt(pos++) === 0x3E /* > */ && !wasOutdented) { // This line is inside the blockquote. // skip spaces after ">" and re-calculate offset initial = offset = state.sCount[nextLine] + pos - (state.bMarks[nextLine] + state.tShift[nextLine]); // skip one optional space after '>' if (state.src.charCodeAt(pos) === 0x20 /* space */) { // ' > test ' // ^ -- position start of line here: pos++; initial++; offset++; adjustTab = false; spaceAfterMarker = true; } else if (state.src.charCodeAt(pos) === 0x09 /* tab */) { spaceAfterMarker = true; if ((state.bsCount[nextLine] + offset) % 4 === 3) { // ' >\t test ' // ^ -- position start of line here (tab has width===1) pos++; initial++; offset++; adjustTab = false; } else { // ' >\t test ' // ^ -- position start of line here + shift bsCount slightly // to make extra space appear adjustTab = true; } } else { spaceAfterMarker = false; } oldBMarks.push(state.bMarks[nextLine]); state.bMarks[nextLine] = pos; while (pos < max) { ch = state.src.charCodeAt(pos); if (isSpace(ch)) { if (ch === 0x09) { offset += 4 - (offset + state.bsCount[nextLine] + (adjustTab ? 1 : 0)) % 4; } else { offset++; } } else { break; } pos++; } lastLineEmpty = pos >= max; oldBSCount.push(state.bsCount[nextLine]); state.bsCount[nextLine] = state.sCount[nextLine] + 1 + (spaceAfterMarker ? 1 : 0); oldSCount.push(state.sCount[nextLine]); state.sCount[nextLine] = offset - initial; oldTShift.push(state.tShift[nextLine]); state.tShift[nextLine] = pos - state.bMarks[nextLine]; continue; } // Case 2: line is not inside the blockquote, and the last line was empty. if (lastLineEmpty) { break; } // Case 3: another tag found. terminate = false; for (i = 0, l = terminatorRules.length; i < l; i++) { if (terminatorRules[i](state, nextLine, endLine, true)) { terminate = true; break; } } if (terminate) { // Quirk to enforce "hard termination mode" for paragraphs; // normally if you call `tokenize(state, startLine, nextLine)`, // paragraphs will look below nextLine for paragraph continuation, // but if blockquote is terminated by another tag, they shouldn't state.lineMax = nextLine; if (state.blkIndent !== 0) { // state.blkIndent was non-zero, we now set it to zero, // so we need to re-calculate all offsets to appear as // if indent wasn't changed oldBMarks.push(state.bMarks[nextLine]); oldBSCount.push(state.bsCount[nextLine]); oldTShift.push(state.tShift[nextLine]); oldSCount.push(state.sCount[nextLine]); state.sCount[nextLine] -= state.blkIndent; } break; } oldBMarks.push(state.bMarks[nextLine]); oldBSCount.push(state.bsCount[nextLine]); oldTShift.push(state.tShift[nextLine]); oldSCount.push(state.sCount[nextLine]); // A negative indentation means that this is a paragraph continuation // state.sCount[nextLine] = -1; } oldIndent = state.blkIndent; state.blkIndent = 0; token = state.push('blockquote_open', 'blockquote', 1); token.markup = '>'; token.map = lines = [startLine, 0]; state.md.block.tokenize(state, startLine, nextLine); token = state.push('blockquote_close', 'blockquote', -1); token.markup = '>'; state.lineMax = oldLineMax; state.parentType = oldParentType; lines[1] = state.line; // Restore original tShift; this might not be necessary since the parser // has already been here, but just to make sure we can do that. for (i = 0; i < oldTShift.length; i++) { state.bMarks[i + startLine] = oldBMarks[i]; state.tShift[i + startLine] = oldTShift[i]; state.sCount[i + startLine] = oldSCount[i]; state.bsCount[i + startLine] = oldBSCount[i]; } state.blkIndent = oldIndent; return true; }; /***/ }), /* 28 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // Copyright (c) 2014 Vitaly Puzrin, Alex Kocharin. // Distributed under an ISC license: https://github.com/markdown-it/markdown-it/ /** * @fileoverview Implements markdownitTableRenderer * @modifier NHN Ent. FE Development Lab */ /*eslint-disable */ function getLine(state, line) { var pos = state.bMarks[line] + state.blkIndent, max = state.eMarks[line]; return state.src.substr(pos, max - pos); } function escapedSplit(str) { var result = [], pos = 0, max = str.length, ch, escapes = 0, lastPos = 0, backTicked = false, lastBackTick = 0; ch = str.charCodeAt(pos); while (pos < max) { if (ch === 0x60 /* ` */ && escapes % 2 === 0) { backTicked = !backTicked; lastBackTick = pos; } else if (ch === 0x7c /* | */ && escapes % 2 === 0 && !backTicked) { result.push(str.substring(lastPos, pos)); lastPos = pos + 1; } else if (ch === 0x5c /* \ */) { escapes += 1; } else { escapes = 0; } pos += 1; // If there was an un-closed backtick, go back to just after // the last backtick, but as if it was a normal character if (pos === max && backTicked) { backTicked = false; pos = lastBackTick + 1; } ch = str.charCodeAt(pos); } result.push(str.substring(lastPos)); return result; } module.exports = function table(state, startLine, endLine, silent) { var ch, lineText, pos, i, nextLine, columns, columnCount, token, aligns, alignCount, t, tableLines, tbodyLines; // should have at least three lines if (startLine + 2 > endLine) { return false; } nextLine = startLine + 1; if (state.sCount[nextLine] < state.blkIndent) { return false; } // first character of the second line should be '|' or '-' pos = state.bMarks[nextLine] + state.tShift[nextLine]; if (pos >= state.eMarks[nextLine]) { return false; } ch = state.src.charCodeAt(pos); if (ch !== 0x7C /* | */ && ch !== 0x2D /* - */ && ch !== 0x3A /* : */) { return false; } lineText = getLine(state, startLine + 1); if (!/^[-:| ]+$/.test(lineText)) { return false; } columns = lineText.split('|'); aligns = []; for (i = 0; i < columns.length; i += 1) { t = columns[i].trim(); if (!t) { // allow empty columns before and after table, but not in between columns; // e.g. allow ` |---| `, disallow ` ---||--- ` if (i === 0 || i === columns.length - 1) { continue; } else { return false; } } if (!/^:?-+:?$/.test(t)) { return false; } if (t.charCodeAt(t.length - 1) === 0x3A /* : */) { aligns.push(t.charCodeAt(0) === 0x3A /* : */ ? 'center' : 'right'); } else if (t.charCodeAt(0) === 0x3A /* : */) { aligns.push('left'); } else { aligns.push(''); } } alignCount = aligns.length; lineText = getLine(state, startLine).trim(); if (lineText.indexOf('|') === -1) { return false; } columns = escapedSplit(lineText.replace(/^\||\|$/g, '')); // header row will define an amount of columns in the entire table, // and align row shouldn't be smaller than that (the rest of the rows can) columnCount = columns.length; if (columnCount > alignCount) { return false; } else if (columnCount < alignCount) { for (i = 0; i < alignCount - columnCount; i += 1) { columns.push(''); } columnCount = columns.length; } if (silent) { return true; } token = state.push('table_open', 'table', 1); token.map = tableLines = [startLine, 0]; token = state.push('thead_open', 'thead', 1); token.map = [startLine, startLine + 1]; token = state.push('tr_open', 'tr', 1); token.map = [startLine, startLine + 1]; for (i = 0; i < columnCount; i += 1) { token = state.push('th_open', 'th', 1); token.map = [startLine, startLine + 1]; if (aligns[i]) { // FIXED: change property style to align token.attrs = [['align', aligns[i]]]; } token = state.push('inline', '', 0); token.content = columns[i].trim(); token.map = [startLine, startLine + 1]; token.children = []; token = state.push('th_close', 'th', -1); } token = state.push('tr_close', 'tr', -1); token = state.push('thead_close', 'thead', -1); token = state.push('tbody_open', 'tbody', 1); token.map = tbodyLines = [startLine + 2, 0]; for (nextLine = startLine + 2; nextLine < endLine; nextLine += 1) { if (state.sCount[nextLine] < state.blkIndent) { break; } lineText = getLine(state, nextLine); if (lineText.indexOf('|') === -1) { break; } // keep spaces at beginning of line to indicate an empty first cell, but // strip trailing whitespace columns = escapedSplit(lineText.replace(/^\||\|\s*$/g, '')); token = state.push('tr_open', 'tr', 1); for (i = 0; i < columnCount; i += 1) { token = state.push('td_open', 'td', 1); if (aligns[i]) { // FIXED: change property style to align token.attrs = [['align', aligns[i]]]; } token = state.push('inline', '', 0); token.content = columns[i] ? columns[i].trim() : ''; token.children = []; token = state.push('td_close', 'td', -1); } token = state.push('tr_close', 'tr', -1); } token = state.push('tbody_close', 'tbody', -1); token = state.push('table_close', 'table', -1); tableLines[1] = tbodyLines[1] = nextLine; state.line = nextLine; return true; }; /***/ }), /* 29 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // Copyright (c) 2014 Vitaly Puzrin, Alex Kocharin. // Distributed under an ISC license: https://github.com/markdown-it/markdown-it/ /** * @fileoverview Implements markdownitHtmlBlockRenderer * @modifier NHN Ent. FE Development Lab */ /* eslint-disable */ // HTML block // An array of opening and corresponding closing sequences for html tags, // last argument defines whether it can terminate a paragraph or not // // void tag names --- Added by Junghwan Park var voidTagNames = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']; var HTML_SEQUENCES = [[/^<(script|pre|style)(?=(\s|>|$))/i, /<\/(script|pre|style)>/i, true], [/^/, true], [/^<\?/, /\?>/, true], [/^/, true], [/^/, true], [new RegExp('^<(' + voidTagNames.join('|') + ')', 'i'), /^\/?>$/, true], [new RegExp('^|$))', 'i'), /^$/, true], [/^(?:<[A-Za-z][A-Za-z0-9\-]*(?:\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\s*=\s*(?:[^"'=<>`\x00-\x20]+|'[^']*'|"[^"]*"))?)*\s*\/?>|<\/[A-Za-z][A-Za-z0-9\-]*\s*>)\s*$/, /^$/, false]]; module.exports = function html_block(state, startLine, endLine, silent) { var i, nextLine, token, lineText, pos = state.bMarks[startLine] + state.tShift[startLine], max = state.eMarks[startLine]; if (!state.md.options.html) { return false; } if (state.src.charCodeAt(pos) !== 0x3C /* < */) { return false; } lineText = state.src.slice(pos, max); for (i = 0; i < HTML_SEQUENCES.length; i++) { if (HTML_SEQUENCES[i][0].test(lineText)) { // add condition for return when meet void element --- Added by Junghwan Park if (i === 5) { return false; } else { break; } } } if (i === HTML_SEQUENCES.length) { return false; } if (silent) { // true if this sequence can be a terminator, false otherwise return HTML_SEQUENCES[i][2]; } nextLine = startLine + 1; // If we are here - we detected HTML block. // Let's roll down till block end. if (!HTML_SEQUENCES[i][1].test(lineText)) { for (; nextLine < endLine; nextLine++) { if (state.sCount[nextLine] < state.blkIndent) { break; } pos = state.bMarks[nextLine] + state.tShift[nextLine]; max = state.eMarks[nextLine]; lineText = state.src.slice(pos, max); if (HTML_SEQUENCES[i][1].test(lineText)) { if (lineText.length !== 0) { nextLine++; } break; } } } state.line = nextLine; token = state.push('html_block', '', 0); token.map = [startLine, nextLine]; token.content = state.getLines(startLine, nextLine, state.blkIndent, true); return true; }; /* eslint-enable */ /***/ }), /* 30 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // Copyright (c) 2014 Vitaly Puzrin, Alex Kocharin. // Distributed under MIT license: https://github.com/markdown-it/markdown-it/ /** * @fileoverview Implements markdownitBackticksRenderer * @modifier NHN Ent. FE Development Lab */ /* eslint-disable */ // Parse backticks module.exports = function backtick(state, silent) { var start, max, marker, matchStart, matchEnd, token, pos = state.pos, ch = state.src.charCodeAt(pos); if (ch !== 0x60 /* ` */) { return false; } start = pos; pos++; max = state.posMax; while (pos < max && state.src.charCodeAt(pos) === 0x60 /* ` */) { pos++; } marker = state.src.slice(start, pos); matchStart = matchEnd = pos; while ((matchStart = state.src.indexOf('`', matchEnd)) !== -1) { matchEnd = matchStart + 1; while (matchEnd < max && state.src.charCodeAt(matchEnd) === 0x60 /* ` */) { matchEnd++; } if (matchEnd - matchStart === marker.length) { if (!silent) { token = state.push('code_inline', 'code', 0); token.markup = marker; token.content = state.src.slice(pos, matchStart).replace(/[ \n]+/g, ' ').trim(); // TUI.EDITOR MODIFICATION START // store number of backtick in data-backtick // https://github.nhnent.com/fe/tui.editor/pull/981 token.attrSet('data-backticks', token.markup.length); // TUI.EDITOR MODIFICATION END } state.pos = matchEnd; return true; } } if (!silent) { state.pending += marker; } state.pos += marker.length; return true; }; /***/ }), /* 31 */ /***/ (function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE_31__; /***/ }), /* 32 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview Implements editor preivew * @author NHN Ent. FE Development Lab */ var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _mdPreview = __webpack_require__(12); var _mdPreview2 = _interopRequireDefault(_mdPreview); var _eventManager = __webpack_require__(15); var _eventManager2 = _interopRequireDefault(_eventManager); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); var _extManager = __webpack_require__(16); var _extManager2 = _interopRequireDefault(_extManager); var _convertor = __webpack_require__(17); var _convertor2 = _interopRequireDefault(_convertor); var _domUtils = __webpack_require__(4); var _domUtils2 = _interopRequireDefault(_domUtils); var _codeBlockManager = __webpack_require__(7); var _codeBlockManager2 = _interopRequireDefault(_codeBlockManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var TASK_ATTR_NAME = 'data-te-task'; var TASK_CHECKED_CLASS_NAME = 'checked'; /** * Class ToastUIEditorViewer */ var ToastUIEditorViewer = function () { /** * Viewer * @param {object} options Option object * @param {HTMLElement} options.el - container element * @param {string} options.initialValue Editor's initial value * @param {object} options.events eventlist Event list * @param {function} options.events.load It would be emitted when editor fully load * @param {function} options.events.change It would be emitted when content changed * @param {function} options.events.stateChange It would be emitted when format change by cursor position * @param {function} options.events.focus It would be emitted when editor get focus * @param {function} options.events.blur It would be emitted when editor loose focus * @param {object} options.hooks Hook list * @param {function} options.hooks.previewBeforeHook Submit preview to hook URL before preview be shown * @param {string[]} [options.exts] - extensions */ function ToastUIEditorViewer(options) { var _this = this; _classCallCheck(this, ToastUIEditorViewer); this.options = _jquery2.default.extend({ useDefaultHTMLSanitizer: true, codeBlockLanguages: _codeBlockManager.CodeBlockManager.getHighlightJSLanguages(), customConvertor: null }, options); this.eventManager = new _eventManager2.default(); this.commandManager = new _commandManager2.default(this); if (this.options.customConvertor) { // eslint-disable-next-line new-cap this.convertor = new this.options.customConvertor(this.eventManager); } else { this.convertor = new _convertor2.default(this.eventManager); } this.toMarkOptions = null; if (this.options.useDefaultHTMLSanitizer) { this.convertor.initHtmlSanitizer(); } if (this.options.hooks) { _tuiCodeSnippet2.default.forEach(this.options.hooks, function (fn, key) { _this.addHook(key, fn); }); } if (this.options.events) { _tuiCodeSnippet2.default.forEach(this.options.events, function (fn, key) { _this.on(key, fn); }); } this.preview = new _mdPreview2.default((0, _jquery2.default)(this.options.el), this.eventManager, this.convertor, true); this.preview.$el.on('mousedown', _jquery2.default.proxy(this._toggleTask, this)); _extManager2.default.applyExtension(this, this.options.exts); this.setValue(this.options.initialValue); this.eventManager.emit('load', this); } /** * Toggle task by detecting mousedown event. * @param {MouseEvent} ev - event * @private */ _createClass(ToastUIEditorViewer, [{ key: '_toggleTask', value: function _toggleTask(ev) { var isBeneathTaskBox = ev.offsetX < 18 && ev.offsetY > 18; if (ev.target.hasAttribute(TASK_ATTR_NAME) && !isBeneathTaskBox) { (0, _jquery2.default)(ev.target).toggleClass(TASK_CHECKED_CLASS_NAME); this.eventManager.emit('change', { source: 'viewer', data: ev }); } } /** * Set content for preview * @memberof ToastUIEditorViewer * @param {string} markdown Markdown text */ }, { key: 'setMarkdown', value: function setMarkdown(markdown) { this.markdownValue = markdown = markdown || ''; this.preview.refresh(this.markdownValue); this.eventManager.emit('setMarkdownAfter', this.markdownValue); } /** * Set content for preview * @memberof ToastUIEditorViewer * @param {string} markdown Markdown text * @deprecated */ }, { key: 'setValue', value: function setValue(markdown) { this.setMarkdown(markdown); } /** * Bind eventHandler to event type * @memberof ToastUIEditorViewer * @param {string} type Event type * @param {function} handler Event handler */ }, { key: 'on', value: function on(type, handler) { this.eventManager.listen(type, handler); } /** * Unbind eventHandler from event type * @memberof ToastUIEditorViewer * @param {string} type Event type */ }, { key: 'off', value: function off(type) { this.eventManager.removeEventHandler(type); } /** * Remove Viewer preview from document * @memberof ToastUIEditorViewer */ }, { key: 'remove', value: function remove() { this.eventManager.emit('removeEditor'); this.preview.$el.off('mousedown', _jquery2.default.proxy(this._toggleTask, this)); this.preview.remove(); this.options = null; this.eventManager = null; this.commandManager = null; this.convertor = null; this.preview = null; } /** * Add hook to Viewer preview's event * @memberof ToastUIEditorViewer * @param {string} type Event type * @param {function} handler Event handler */ }, { key: 'addHook', value: function addHook(type, handler) { this.eventManager.removeEventHandler(type); this.eventManager.listen(type, handler); } /** * Return true * @memberof ToastUIEditorViewer * @returns {boolean} */ }, { key: 'isViewer', value: function isViewer() { return true; } /** * Return false * @memberof ToastUIEditorViewer * @returns {boolean} */ }, { key: 'isMarkdownMode', value: function isMarkdownMode() { return false; } /** * Return false * @memberof ToastUIEditorViewer * @returns {boolean} */ }, { key: 'isWysiwygMode', value: function isWysiwygMode() { return false; } /** * Define extension * @memberof ToastUIEditorViewer * @param {string} name Extension name * @param {ExtManager~extension} ext extension */ }], [{ key: 'defineExtension', value: function defineExtension(name, ext) { _extManager2.default.defineExtension(name, ext); } }]); return ToastUIEditorViewer; }(); /** * check whther is viewer * @type {boolean} */ ToastUIEditorViewer.isViewer = true; /** * domUtil instance * @type {DomUtil} */ ToastUIEditorViewer.domUtils = _domUtils2.default; /** * CodeBlockManager instance * @type {CodeBlockManager} */ ToastUIEditorViewer.codeBlockManager = _codeBlockManager2.default; /** * MarkdownIt hightlight instance * @type {MarkdownIt} */ ToastUIEditorViewer.markdownitHighlight = _convertor2.default.getMarkdownitHighlightRenderer(); /** * MarkdownIt instance * @type {MarkdownIt} */ ToastUIEditorViewer.markdownit = _convertor2.default.getMarkdownitRenderer(); /** * @ignore */ ToastUIEditorViewer.i18n = null; /** * @ignore */ ToastUIEditorViewer.Button = null; /** * @ignore */ ToastUIEditorViewer.WwCodeBlockManager = null; /** * @ignore */ ToastUIEditorViewer.WwTableManager = null; /** * @ignore */ ToastUIEditorViewer.WwTableSelectionManager = null; module.exports = ToastUIEditorViewer; /***/ }), /* 33 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * @fileoverview This file is common logic for italic, bold, strike makrdown commands. * @author NHN Ent. FE Development Lab */ /** * range expand according to expendSize * If can not expand, return null * @param {range} range - range * @param {number} expendSize - expendSize * @returns {object} expanded range or null * @ignore */ var getExpandedRange = function getExpandedRange(range, expendSize) { var start = range.start, end = range.end; var expendRange = void 0; if (start.ch >= expendSize) { var from = { line: start.line, ch: start.ch - expendSize }; var to = { line: end.line, ch: end.ch + expendSize }; expendRange = { from: from, to: to }; } return expendRange; }; /** * remove symbol in the front and back of text * @param {string} text - text * @param {string} symbol - text * @returns {string} * @ignore */ var removeSyntax = exports.removeSyntax = function removeSyntax(text, symbol) { var symbolLength = symbol.length; return text.substr(symbolLength, text.length - symbolLength * 2); }; /** * append symbol in the front and back of text * @param {string} text - text * @param {string} symbol - text * @returns {string} * @ignore */ var appendSyntax = exports.appendSyntax = function appendSyntax(text, symbol) { return '' + symbol + text + symbol; }; /** * check expanded text and replace text using replacer * @param {CodeMirror.doc} doc - doc of codemirror * @param {range} range - origin range * @param {number} expandSize - expandSize * @param {function} checker - sytax check function * @param {function} replacer - text replace function * @returns {boolean} - if replace text, return true. * @ignore */ var expandReplace = exports.expandReplace = function expandReplace(doc, range, expandSize, checker, replacer) { var expendRange = getExpandedRange(range, expandSize); var result = false; if (expendRange) { var from = expendRange.from, to = expendRange.to; var expendRangeText = doc.getRange(from, to); if (checker(expendRangeText)) { doc.setSelection(from, to); doc.replaceSelection(replacer(expendRangeText), 'around'); result = true; } } return result; }; /** * check text and replace text using replacer * @param {CodeMirror.doc} doc - doc of codemirror * @param {string} text - text * @param {function} checker - sytax check function * @param {function} replacer - text replace function * @returns {boolean} - if replace text, return true. * @ignore */ var replace = exports.replace = function replace(doc, text, checker, replacer) { var result = false; if (checker(text)) { doc.replaceSelection(replacer(text), 'around'); result = true; } return result; }; var changeSyntax = exports.changeSyntax = function changeSyntax(doc, range, symbol, syntaxRegex, contentRegex) { var _doc$getCursor = doc.getCursor(), line = _doc$getCursor.line, ch = _doc$getCursor.ch; var selectionStr = doc.getSelection(); var symbolLength = symbol.length; var isSyntax = function isSyntax(t) { return syntaxRegex.test(t); }; // 1. expand text and check syntax => remove syntax // 2. check text is syntax => remove syntax // 3. If text does not match syntax, remove syntax inside text and then append syntax if (!(expandReplace(doc, range, symbolLength, isSyntax, function (t) { return removeSyntax(t, symbol); }) || replace(doc, selectionStr, isSyntax, function (t) { return removeSyntax(t, symbol); }))) { var removeSyntaxInsideText = selectionStr.replace(contentRegex, '$1'); doc.replaceSelection(appendSyntax(removeSyntaxInsideText, symbol), 'around'); } var afterSelectStr = doc.getSelection(); var size = ch; if (!selectionStr) { // If text was not selected, after replace text, move cursor // For example **|** => | (move cusor -symbolLenth) if (isSyntax(afterSelectStr)) { size += symbolLength; } else { size -= symbolLength; } doc.setCursor(line, size); } }; /***/ }), /* 34 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview Implements tooltip * @author NHN Ent. FE Development Lab */ var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var TOOLTIP_CONTENT = '
'; /** * Class Tooltip */ var Tooltip = function () { /** * Creates an instance of Tooltip. * @memberof Tooltip */ function Tooltip() { _classCallCheck(this, Tooltip); this.$el = (0, _jquery2.default)(TOOLTIP_CONTENT); this.$el.appendTo('body'); this.hide(); } /** * show tooltop * @param {jQuery} target - target jQuery element to bind * @param {String} text - text to show */ _createClass(Tooltip, [{ key: 'show', value: function show(target, text) { this.$el.css({ 'top': target.offset().top + target.height() + 13, // below the button 'left': target.offset().left + 3 }).find('.text').html(text).end().show(); } }, { key: 'hide', value: function hide() { this.$el.hide(); } }, { key: 'remove', value: function remove() { this.$el.remove(); } }]); return Tooltip; }(); exports.default = new Tooltip(); /***/ }), /* 35 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview Implements CodeBlockExt * @author NHN Ent. FE Development Lab */ var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _codemirror = __webpack_require__(6); var _codemirror2 = _interopRequireDefault(_codemirror); __webpack_require__(47); __webpack_require__(48); __webpack_require__(49); __webpack_require__(50); __webpack_require__(51); __webpack_require__(52); __webpack_require__(53); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Class CodeMirrorExt */ var CodeMirrorExt = function () { /** * Creates an instance of CodeMirrorExt. * @param {HTMLElement} el - container jquery element * @param {Object} [options={}] - codeMirror options * @memberof CodeMirrorExt */ function CodeMirrorExt(el) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; _classCallCheck(this, CodeMirrorExt); this.editorContainerEl = el; /** * @memberof CodeMirrorExt * @protected * @member */ this.cm = null; this._init(options); } /** * init * @param {Object} options - codeMirror option * @memberof CodeMirrorExt * @private */ _createClass(CodeMirrorExt, [{ key: '_init', value: function _init(options) { var cmTextarea = document.createElement('textarea'); this.editorContainerEl.appendChild(cmTextarea); options = _jquery2.default.extend(true, { lineWrapping: true, theme: 'default', extraKeys: { 'Shift-Tab': 'indentLess', 'Alt-Up': 'replaceLineTextToUpper', 'Alt-Down': 'replaceLineTextToLower' }, indentUnit: 4, cursorScrollMargin: 12, specialCharPlaceholder: function specialCharPlaceholder() { return document.createElement('span'); } }, options); this.cm = _codemirror2.default.fromTextArea(cmTextarea, options); } /** * getCurrentRange * @memberof CodeMirrorExt * @returns {Object} - selection range */ }, { key: 'getCurrentRange', value: function getCurrentRange() { var from = this.cm.getCursor('from'); var to = this.cm.getCursor('to'); return { from: from, to: to, collapsed: from.line === to.line && from.ch === to.ch }; } /** * Set focus to current Editor * @memberof CodeMirrorExt */ }, { key: 'focus', value: function focus() { this.cm.focus(); } /** * blur focus to current Editor * @memberof CodeMirrorExt */ }, { key: 'blur', value: function blur() { this.cm.getInputField().blur(); } /** * Remove Editor from document * @memberof CodeMirrorExt */ }, { key: 'remove', value: function remove() { this.cm.toTextArea(); } /** * Set Editor value * @memberof CodeMirrorExt * @param {string} markdown - Markdown syntax text * @param {boolean} [cursorToEnd=true] - move cursor to contents end */ }, { key: 'setValue', value: function setValue(markdown) { var cursorToEnd = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; this.cm.setValue(markdown); if (cursorToEnd) { this.moveCursorToEnd(); } this.cm.refresh(); } /** * Get editor value * @memberof CodeMirrorExt * @returns {string} - codeMirror text value */ }, { key: 'getValue', value: function getValue() { return this.cm.getValue('\n'); } /** * Get CodeMirror instance * @memberof CodeMirrorExt * @returns {CodeMirror} */ }, { key: 'getEditor', value: function getEditor() { return this.cm; } /** * Reset Editor * @memberof CodeMirrorExt */ }, { key: 'reset', value: function reset() { this.setValue(''); } /** * Get current caret position * @memberof CodeMirrorExt * @returns {{from: {line: number, ch: number}, to: {line: number, ch: number}}} */ }, { key: 'getCaretPosition', value: function getCaretPosition() { return this.cm.cursorCoords(); } /** * Add widget * @memberof CodeMirrorExt * @param {object} selection - Selection object * @param {HTMLElement} node - Widget node * @param {string} style - Adding style "over" or "bottom" * @param {number} offset - Adding offset */ }, { key: 'addWidget', value: function addWidget(selection, node, style, offset) { if (offset) { selection.ch += offset; } this.cm.addWidget(selection.end, node, true, style); } /** * Replace selection with given replacement content * @memberof CodeMirrorExt * @param {string} content - Replacement content text * @param {object} selection - Selection object */ }, { key: 'replaceSelection', value: function replaceSelection(content, selection) { if (selection) { this.cm.setSelection(selection.from, selection.to); } this.cm.replaceSelection(content); this.focus(); } /** * Replace selection with replacement content and offset * @memberof CodeMirrorExt * @param {string} content - Replacement content text * @param {number} offset - Offset * @param {number} overwriteLength - Length to overwrite */ }, { key: 'replaceRelativeOffset', value: function replaceRelativeOffset(content, offset, overwriteLength) { var cursor = this.cm.getCursor(); var selection = { from: { line: cursor.line, ch: cursor.ch + offset }, to: { line: cursor.line, ch: cursor.ch + offset + overwriteLength } }; this.replaceSelection(content, selection); } /** * Set Editor height * @memberof CodeMirrorExt * @param {number} height - Editor height */ }, { key: 'setHeight', value: function setHeight(height) { var contentWrapper = this.getWrapperElement(); contentWrapper.style.height = height + 'px'; } /** * set min height * @param {number} minHeight - min height * @memberof CodeMirrorExt */ }, { key: 'setMinHeight', value: function setMinHeight(minHeight) { var contentWrapper = this.getWrapperElement(); contentWrapper.style.minHeight = minHeight + 'px'; } /** * Set the placeholder to CodeMirror * @param {string} placeholder - placeholder to set */ }, { key: 'setPlaceholder', value: function setPlaceholder(placeholder) { if (placeholder) { this.cm.setOption('placeholder', placeholder); } } /** * get code mirror wrapper element * @returns {HTMLElement} - code mirror wrapper element * @memberof CodeMirrorExt */ }, { key: 'getWrapperElement', value: function getWrapperElement() { return this.cm.getWrapperElement(); } /** * get code mirror cursor * @param {string} [start='head'] - which end of the selection. 'from'|'to'|'head'|'anchor' * @returns {Cursor} - code mirror cursor * @memberof CodeMirrorExt */ }, { key: 'getCursor', value: function getCursor(start) { return this.cm.getCursor(start); } /** * Set cursor position to end * @memberof CodeMirrorExt */ }, { key: 'moveCursorToEnd', value: function moveCursorToEnd() { var doc = this.getEditor().getDoc(); var lastLine = doc.lastLine(); doc.setCursor(lastLine, doc.getLine(lastLine).length); } /** * Set cursor position to start * @memberof CodeMirrorExt */ }, { key: 'moveCursorToStart', value: function moveCursorToStart() { var doc = this.getEditor().getDoc(); var firstLine = doc.firstLine(); doc.setCursor(firstLine, 0); } /** * Scroll Editor content to Top * @memberof CodeMirrorExt * @param {number} value - Scroll amount * @returns {number} - changed scroll top */ }, { key: 'scrollTop', value: function scrollTop(value) { if (value) { this.cm.scrollTo(0, value); } return this.cm.getScrollInfo().top; } /** * Get start, end position of current selection * @memberof CodeMirrorExt * @returns {{start: {line: *, ch: *}, end: {line: *, ch: *}}} */ }, { key: 'getRange', value: function getRange() { var start = this.cm.getCursor('from'); var end = this.cm.getCursor('to'); return { start: { line: start.line, ch: start.ch }, end: { line: end.line, ch: end.ch } }; } /** * add codemirror event handler * @param {string} type - event type * @param {function} func - handler function * @memberof CodeMirrorExt */ }, { key: 'on', value: function on(type, func) { this.cm.on(type, func); } /** * remove codemirror event handler * @param {string} type - event type * @param {function} func - handler function * @memberof CodeMirrorExt */ }, { key: 'off', value: function off(type, func) { this.cm.off(type, func); } }]); return CodeMirrorExt; }(); exports.default = CodeMirrorExt; /***/ }), /* 36 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * @fileoverview Implements ComponentManager * @author NHN Ent. FE Development Lab */ /** * Class ComponentManager */ var ComponentManager = function () { /** * Constructor * @param {MarkdownEditor|WysiwygEditor} editor - Editor instance */ function ComponentManager(editor) { _classCallCheck(this, ComponentManager); /** * private * @type {object} * @private */ this._managers = {}; this._editor = editor; } /** * addManager * Add manager * @memberof ComponentManager * @param {string|function} nameOrConstructor Manager name or constructor * @param {function} [ManagerConstructor] Constructor */ _createClass(ComponentManager, [{ key: "addManager", value: function addManager(nameOrConstructor, ManagerConstructor) { if (!ManagerConstructor) { ManagerConstructor = nameOrConstructor; nameOrConstructor = null; } var instance = new ManagerConstructor(this._editor); this._managers[nameOrConstructor || instance.name] = instance; } /** * getManager * Get manager by manager name * @memberof ComponentManager * @param {string} name Manager name * @returns {object} manager */ }, { key: "getManager", value: function getManager(name) { return this._managers[name]; } /** * Remove Manager. * @param {string} name - manager name */ }, { key: "removeManager", value: function removeManager(name) { var manager = this.getManager(name); if (!manager) { return; } if (manager.destroy) { manager.destroy(); } delete this._managers[name]; } }]); return ComponentManager; }(); exports.default = ComponentManager; /***/ }), /* 37 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview Implements wysiwyg table manager * @author NHN Ent. FE Development Lab */ var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _domUtils = __webpack_require__(4); var _domUtils2 = _interopRequireDefault(_domUtils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var isIE10 = _tuiCodeSnippet2.default.browser.msie && _tuiCodeSnippet2.default.browser.version === 10; var TABLE_CLASS_PREFIX = 'te-content-table-'; var isIE10And11 = _tuiCodeSnippet2.default.browser.msie && (_tuiCodeSnippet2.default.browser.version === 10 || _tuiCodeSnippet2.default.browser.version === 11); var BASIC_CELL_CONTENT = _tuiCodeSnippet2.default.browser.msie ? '' : '
'; var TABLE_CELL_SELECTED_CLASS_NAME = 'te-cell-selected'; /** * Class WwTableManager */ var WwTableManager = function () { /** * Creates an instance of WwTableManager. * @param {WysiwygEditor} wwe - WysiwygEditor instance * @memberof WwTableManager */ function WwTableManager(wwe) { _classCallCheck(this, WwTableManager); this.wwe = wwe; this.eventManager = wwe.eventManager; /** * Name property * @memberof WwTableManager# * @type {string} */ this.name = 'table'; this._lastCellNode = null; this._init(); } /** * _init * Initialize * @memberof WwTableManager * @private */ _createClass(WwTableManager, [{ key: '_init', value: function _init() { this._initKeyHandler(); this._initEvent(); this.tableID = 0; } /** * _initEvent * Initialize event * @memberof WwTableManager * @private */ }, { key: '_initEvent', value: function _initEvent() { var _this = this; this.eventManager.listen('wysiwygRangeChangeAfter.table', function () { var range = _this.wwe.getEditor().getSelection(); var isRangeInTable = _this.wwe.isInTable(range); _this._unwrapBlockInTable(); _this._completeTableIfNeed(); if (!isRangeInTable) { var selectionManager = _this.wwe.componentManager.getManager('tableSelection'); selectionManager.removeClassAttrbuteFromAllCellsIfNeed(); } _this._insertDefaultBlockBetweenTable(); }); this.eventManager.listen('wysiwygSetValueAfter.table', function () { _this._unwrapBlockInTable(); _this._insertDefaultBlockBetweenTable(); }); // remove last br in td or th this.eventManager.listen('wysiwygProcessHTMLText.table', function (html) { return html.replace(/
(<\/td>|<\/th>)/g, '$1'); }); this.eventManager.listen('cut.table', function () { var selectionManager = _this.wwe.componentManager.getManager('tableSelection'); var $selectedCells = selectionManager.getSelectedCells(); if ($selectedCells.length) { $selectedCells.get().forEach(function (cell) { return (0, _jquery2.default)(cell).html(BASIC_CELL_CONTENT); }); } selectionManager.removeClassAttrbuteFromAllCellsIfNeed(); }); this.eventManager.listen('copyBefore.table', function (_ref) { var $clipboardContainer = _ref.$clipboardContainer; return _this.updateTableHtmlOfClipboardIfNeed($clipboardContainer); }); } /** * Update table html of clipboard data, if has selected cells. * @param {jQuery} $clipboardContainer - jQuery element */ }, { key: 'updateTableHtmlOfClipboardIfNeed', value: function updateTableHtmlOfClipboardIfNeed($clipboardContainer) { var _this2 = this; var selectionManager = this.wwe.componentManager.getManager('tableSelection'); var $selectedCells = selectionManager.getSelectedCells(); if ($selectedCells.length) { selectionManager.createRangeBySelectedCells(); var fragment = this.wwe.getEditor().getSelection().cloneContents(); (0, _jquery2.default)(fragment).children().each(function (index, node) { var $node = (0, _jquery2.default)(node); if (!_this2.isTableOrSubTableElement(node.nodeName)) { return; } if (node.nodeName === 'TABLE' && $node.find('thead').length === 0 && $node.find('tbody').length === 0) { $node.remove(); } else if (node.previousSibling && node.previousSibling.nodeName === 'TABLE') { node.previousSibling.appendChild(node); } else { _this2._completeIncompleteTable(node); if (node.nodeName !== 'TABLE' && node.nodeName !== 'THEAD') { (0, _jquery2.default)(node).closest('table').find('thead').remove(); } } }); $clipboardContainer.append(fragment); $clipboardContainer.find('.' + TABLE_CELL_SELECTED_CLASS_NAME).removeClass(TABLE_CELL_SELECTED_CLASS_NAME); } } /** * Paste clibpard data that contains only table. * @param {Node} clipboardTable - table element of clipboard */ }, { key: 'pasteTableData', value: function pasteTableData(clipboardTable) { var $clipboardTable = (0, _jquery2.default)(clipboardTable); this._expandTableIfNeed($clipboardTable); this._pasteDataIntoTable($clipboardTable); } /** * _initKeyHandler * Initialize key event handler * @memberof WwTableManager * @private */ }, { key: '_initKeyHandler', value: function _initKeyHandler() { var _this3 = this; this.keyEventHandlers = { 'DEFAULT': function DEFAULT(ev, range, keymap) { var isRangeInTable = _this3.wwe.isInTable(range); if (isRangeInTable && !_this3._isSingleModifierKey(keymap)) { _this3._recordUndoStateIfNeed(range); _this3._removeBRIfNeed(range); _this3._removeContentsAndChangeSelectionIfNeed(range, keymap, ev); } else if (!isRangeInTable && _this3._lastCellNode) { _this3._recordUndoStateAndResetCellNode(range); } if (isRangeInTable && !_this3._isModifierKeyPushed(ev)) { _this3.wwe.getEditor().modifyDocument(function () { var selectionManager = _this3.wwe.componentManager.getManager('tableSelection'); selectionManager.removeClassAttrbuteFromAllCellsIfNeed(); }); } }, 'ENTER': function ENTER(ev, range) { var isNeedNext = void 0; if (_this3._isAfterTable(range)) { ev.preventDefault(); range.setStart(range.startContainer, range.startOffset - 1); _this3.wwe.breakToNewDefaultBlock(range); isNeedNext = false; } else if (_this3._isBeforeTable(range)) { ev.preventDefault(); _this3.wwe.breakToNewDefaultBlock(range, 'before'); isNeedNext = false; } else if (_this3.wwe.isInTable(range)) { if (_this3._isInStyledText(range)) { _this3.wwe.defer(function () { _this3._removeBRinStyleText(); }); } _this3._appendBrIfTdOrThNotHaveAsLastChild(range); isNeedNext = false; } return isNeedNext; }, 'BACK_SPACE': function BACK_SPACE(ev, range, keymap) { return _this3._handleBackspaceAndDeleteKeyEvent(ev, range, keymap); }, 'DELETE': function DELETE(ev, range, keymap) { return _this3._handleBackspaceAndDeleteKeyEvent(ev, range, keymap); }, 'TAB': function TAB() { return _this3._moveCursorTo('next', 'cell'); }, 'SHIFT+TAB': function SHIFTTAB(ev) { return _this3._moveCursorTo('previous', 'cell', ev); }, 'UP': function UP(ev) { return _this3._moveCursorTo('previous', 'row', ev); }, 'DOWN': function DOWN(ev) { return _this3._moveCursorTo('next', 'row', ev); } }; _tuiCodeSnippet2.default.forEach(this.keyEventHandlers, function (handler, key) { return _this3.wwe.addKeyEventHandler(key, handler); }); } /** * Check whether range is in style tag that is like 'B', 'I', 'S', 'SPAN', 'CODE' * Those tag is supported in Wysiwyg. * @param {Range} range range * @returns {Boolean} range is in the style tag * @private */ }, { key: '_isInStyledText', value: function _isInStyledText(range) { var startContainer = range.startContainer; var node = void 0; if (_domUtils2.default.isTextNode(startContainer)) { node = startContainer.parentNode; } else { node = startContainer; } return range.collapsed && _domUtils2.default.isStyledNode(node); } /** * When enter key occur in the styled text, 'br' tag insert in the style tag like 'b', 'i' etc. * So in thoes case, 'br' tag would be pulled out in this logic. * @private */ }, { key: '_removeBRinStyleText', value: function _removeBRinStyleText() { var afterRange = this.wwe.getRange(); var startContainer = afterRange.startContainer, startOffset = afterRange.startOffset; var styleNode = void 0; if (startContainer.nodeName === 'TD') { // This case is TEST
|
styleNode = _domUtils2.default.getChildNodeByOffset(startContainer, startOffset - 1); } else { styleNode = _domUtils2.default.getParentUntil(startContainer, 'TD'); } var brNode = styleNode.querySelector('br'); var _styleNode = styleNode, tdNode = _styleNode.parentNode, nodeName = _styleNode.nodeName; if (nodeName === 'CODE' && !brNode.previousSibling) { // cursor is located in the start of text // Before Enter : |TEST // After Enter :
|TEST
// TO BE :
|TEST tdNode.insertBefore(brNode, styleNode); afterRange.setStart(styleNode, 0); } else if (nodeName === 'CODE' && !brNode.nextSibling) { // cursor is located in the end of text // Before Enter : TEST| // After Enter : TEST
|
// TO BE : TEST
| tdNode.insertBefore(brNode, styleNode.nextSibling); afterRange.setStart(tdNode, _domUtils2.default.getNodeOffsetOfParent(brNode) + 1); } else { // [Case 1] cursor is located in the middle of text // Before Enter : TE|ST // After Enter : TE
|ST
// TO BE : TE
|ST // [Case 2] cursor is located in the start of text // Before Enter : |TEST // After Enter :
|TEST
// TO BE : |
TEST // [Case 3] cursor is located in the end of text // Before Enter : TEST| // After Enter : TEST
|
// TO BE : TEST
| var newNode = this._splitByBR(styleNode, brNode); afterRange.setStart(newNode, 0); } afterRange.collapse(true); this.wwe.getEditor().setSelection(afterRange); } /** * When container node have br node, split container base on br node and pull out BR. * After Enter : TE
ST
* TO BE : TE
ST * @param {Node} container container * @param {Node} brNode container * @returns {Node} node for positioning of cursor * @private */ }, { key: '_splitByBR', value: function _splitByBR(container, brNode) { var cloneStyleNode = container.cloneNode(true); var newBR = document.createElement('br'); var parentNode = container.parentNode; // Origin style node should be removed the back nodes of br node. _domUtils2.default.removeNodesByDirection(container, brNode, false); brNode.parentNode.removeChild(brNode); // Cloned style node should be removed the front nodes of br node var clonedBR = cloneStyleNode.querySelector('br'); _domUtils2.default.removeNodesByDirection(cloneStyleNode, clonedBR, true); clonedBR.parentNode.removeChild(clonedBR); parentNode.insertBefore(cloneStyleNode, container.nextSibling); parentNode.insertBefore(newBR, cloneStyleNode); var leafNode = _domUtils2.default.getLeafNode(cloneStyleNode); if (!_domUtils2.default.getTextLength(leafNode)) { leafNode.textContent = '\u200B'; } return leafNode; } /** * _isBeforeTable * Check whether passed range is right before table or not * @param {Range} range range * @returns {boolean} result * @memberof WwTableManager * @private */ }, { key: '_isBeforeTable', value: function _isBeforeTable(range) { return _domUtils2.default.getNodeName(_domUtils2.default.getChildNodeByOffset(range.startContainer, range.startOffset)) === 'TABLE'; } /** * _isAfterTable * Check whether passed range is right after table or not * @param {Range} range range * @returns {boolean} result * @memberof WwTableManager * @private */ }, { key: '_isAfterTable', value: function _isAfterTable(range) { var prevElem = _domUtils2.default.getPrevOffsetNodeUntil(range.startContainer, range.startOffset); return _domUtils2.default.getNodeName(prevElem) === 'TABLE' && range.commonAncestorContainer === this.wwe.get$Body()[0]; } /** * Handle backspace and delete key event * @param {object} ev - Event object * @param {Range} range - Range Object * @param {string} keymap - keymap * @returns {boolean} - need next * @private */ }, { key: '_handleBackspaceAndDeleteKeyEvent', value: function _handleBackspaceAndDeleteKeyEvent(ev, range, keymap) { var isBackspace = keymap === 'BACK_SPACE'; var selectionManager = this.wwe.componentManager.getManager('tableSelection'); var $selectedCells = selectionManager.getSelectedCells(); var isNeedNext = true; if (range.collapsed) { if (this.wwe.isInTable(range)) { if (isBackspace) { this._tableHandlerOnBackspace(range, ev); } else { this._tableHandlerOnDelete(range, ev); } this._insertBRIfNeed(range); this._removeContentsAndChangeSelectionIfNeed(range, keymap, ev); isNeedNext = false; } else if (!isBackspace && this._isBeforeTable(range) || isBackspace && this._isAfterTable(range)) { ev.preventDefault(); var startOffset = isBackspace ? range.startOffset - 1 : range.startOffset; this._removeTable(range, _domUtils2.default.getChildNodeByOffset(range.startContainer, startOffset)); isNeedNext = false; } } else if (this.wwe.isInTable(range)) { if ($selectedCells.length > 0) { var removed = this._removeContentsAndChangeSelectionIfNeed(range, keymap, ev); if (removed) { ev.preventDefault(); isNeedNext = false; } } } return isNeedNext; } /** * _tableHandlerOnBackspace * Backspace handler in table * @param {Range} range range * @param {Event} event event * @memberof WwTableManager * @private */ }, { key: '_tableHandlerOnBackspace', value: function _tableHandlerOnBackspace(range, event) { var prevNode = _domUtils2.default.getPrevOffsetNodeUntil(range.startContainer, range.startOffset, 'TR'), prevNodeName = _domUtils2.default.getNodeName(prevNode); if (!prevNode || prevNodeName === 'TD' || prevNodeName === 'TH') { event.preventDefault(); } else if (prevNodeName === 'BR' && prevNode.parentNode.childNodes.length !== 1) { event.preventDefault(); (0, _jquery2.default)(prevNode).remove(); } } /** * Return whether delete non text or not * @param {Range} range Range object * @returns {boolean} */ }, { key: 'isNonTextDeleting', value: function isNonTextDeleting(range) { var currentElement = range.startContainer; var nextNode = currentElement.nextSibling; var nextNodeName = _domUtils2.default.getNodeName(nextNode); var currentNodeName = _domUtils2.default.getNodeName(currentElement); var isCellDeleting = currentNodeName === nextNodeName && currentNodeName !== 'TEXT'; var isEndOfText = (!nextNode || nextNodeName === 'BR' && nextNode.parentNode.lastChild === nextNode) && _domUtils2.default.isTextNode(currentElement) && range.startOffset === currentElement.nodeValue.length; var isLastCellOfRow = !isEndOfText && (0, _jquery2.default)(currentElement).parents('tr').children().last()[0] === currentElement && (currentNodeName === 'TD' || currentNodeName === 'TH'); return isCellDeleting || isEndOfText || isLastCellOfRow; } /** * _tableHandlerOnDelete * Delete handler in table * @param {Range} range range * @param {Event} event event * @memberof WwTableManager * @private */ }, { key: '_tableHandlerOnDelete', value: function _tableHandlerOnDelete(range, event) { var needPreventDefault = this.isNonTextDeleting(range); if (needPreventDefault) { event.preventDefault(); range.startContainer.normalize(); } } /** * _appendBrIfTdOrThNotHaveAsLastChild * Append br if td or th doesn't have br as last child * @param {Range} range range * @memberof WwTableManager * @private */ }, { key: '_appendBrIfTdOrThNotHaveAsLastChild', value: function _appendBrIfTdOrThNotHaveAsLastChild(range) { var startContainerNodeName = _domUtils2.default.getNodeName(range.startContainer); var tdOrTh = void 0; if (startContainerNodeName === 'TD' || startContainerNodeName === 'TH') { tdOrTh = range.startContainer; } else { var paths = (0, _jquery2.default)(range.startContainer).parentsUntil('tr'); tdOrTh = paths[paths.length - 1]; } if (_domUtils2.default.getNodeName(tdOrTh.lastChild) !== 'BR' && _domUtils2.default.getNodeName(tdOrTh.lastChild) !== 'DIV' && !isIE10And11) { (0, _jquery2.default)(tdOrTh).append((0, _jquery2.default)('
')[0]); } } /** * _unwrapBlockInTable * Unwrap default block tag in table * For Squire default action making abnormal behavior, remove default blocks in Table after setValue() called * @memberof WwTableManager * @private */ }, { key: '_unwrapBlockInTable', value: function _unwrapBlockInTable() { this.wwe.get$Body().find('td div,th div,tr>br,td>br,th>br').each(function (index, node) { if (_domUtils2.default.getNodeName(node) === 'BR') { var parentNodeName = _domUtils2.default.getNodeName(node.parentNode); var isInTableCell = /TD|TH/.test(parentNodeName); var isEmptyTableCell = node.parentNode.textContent.length === 0; var isLastBR = node.parentNode.lastChild === node; if (parentNodeName === 'TR' || isInTableCell && !isEmptyTableCell && isLastBR) { (0, _jquery2.default)(node).remove(); } } else { (0, _jquery2.default)(node).children().unwrap(); } }); } /** * Insert default block between table element * @private */ }, { key: '_insertDefaultBlockBetweenTable', value: function _insertDefaultBlockBetweenTable() { this.wwe.get$Body().find('table').each(function (index, node) { if (node.nextElementSibling && node.nextElementSibling.nodeName === 'TABLE') { (0, _jquery2.default)('

').insertAfter(node); } }); } /** * _removeTable * Remove table * @param {Range} range range * @param {Node} table table * @memberof WwTableManager * @private */ }, { key: '_removeTable', value: function _removeTable(range, table) { if (table.tagName === 'TABLE') { this.wwe.getEditor().saveUndoState(range); this.wwe.saveSelection(range); (0, _jquery2.default)(table).remove(); this.wwe.restoreSavedSelection(); } } /** * _recordUndoStateIfNeed * record undo state if need * @param {Range} range range * @memberof WwTableManager * @private */ }, { key: '_recordUndoStateIfNeed', value: function _recordUndoStateIfNeed(range) { var currentCellNode = _domUtils2.default.getParentUntil(range.startContainer, 'TR'); if (range.collapsed && currentCellNode && this._lastCellNode !== currentCellNode) { this.wwe.getEditor().saveUndoState(range); this._lastCellNode = currentCellNode; } } /** * _recordUndoStateAndResetCellNode * record undo state and reset last cell node * @param {Range} range range * @memberof WwTableManager * @private */ }, { key: '_recordUndoStateAndResetCellNode', value: function _recordUndoStateAndResetCellNode(range) { this.wwe.getEditor().saveUndoState(range); this.resetLastCellNode(); } /** * Paste table data into table element * @param {DocumentFragment} fragment Fragment of table element within * @private */ }, { key: '_pasteDataIntoTable', value: function _pasteDataIntoTable(fragment) { var _wwe$getEditor$getSel = this.wwe.getEditor().getSelection(), startContainer = _wwe$getEditor$getSel.startContainer; var tableData = this._getTableDataFromTable(fragment); var isTableCell = startContainer.tagName === 'TD' || startContainer.tagName === 'TH'; var brString = isIE10 ? '' : '
'; var anchorElement = void 0, td = void 0, tr = void 0, tdContent = void 0; if (isTableCell) { anchorElement = startContainer; } else { anchorElement = _domUtils2.default.getParentUntilBy(startContainer, function (node) { return node.tagName === 'TD' || node.tagName === 'TH'; }, function (node) { return (0, _jquery2.default)(node).closest('table').length === 0; }); anchorElement = anchorElement ? anchorElement.parentNode : null; } anchorElement = anchorElement ? anchorElement : (0, _jquery2.default)(startContainer).find('th,td').get(0); td = anchorElement; while (tableData.length) { tr = tableData.shift(); while (td && tr.length) { tdContent = tr.shift(); if (tdContent.length) { td.textContent = tdContent; } else { td.innerHTML = brString; } td = _domUtils2.default.getTableCellByDirection(td, 'next'); } td = _domUtils2.default.getSiblingRowCellByDirection(anchorElement, 'next', false); anchorElement = td; } } /** * Get array data from table element * @param {DocumentFragment} fragment table element * @returns {Array} * @private */ }, { key: '_getTableDataFromTable', value: function _getTableDataFromTable(fragment) { var $fragment = (0, _jquery2.default)(fragment); var tableData = []; var trs = $fragment.find('tr'); trs.each(function (i, tr) { var trData = []; var tds = (0, _jquery2.default)(tr).children(); tds.each(function (index, cell) { trData.push(cell.textContent); }); if (trData.length) { tableData.push(trData); } }); return tableData; } /** * Remove selected table contents * @param {jQuery} $selectedCells Selected cells wrapped by jQuery * @private */ }, { key: '_removeTableContents', value: function _removeTableContents($selectedCells) { this.wwe.getEditor().saveUndoState(); $selectedCells.each(function (i, cell) { var brHTMLString = isIE10 ? '' : '
'; (0, _jquery2.default)(cell).html(brHTMLString); }); } /** * Wrap dangling table cells with new TR * @param {jQuery} $container - clipboard container * @returns {HTMLElement|null} */ }, { key: 'wrapDanglingTableCellsIntoTrIfNeed', value: function wrapDanglingTableCellsIntoTrIfNeed($container) { var danglingTableCells = $container.children('td,th'); var tr = void 0; if (danglingTableCells.length) { var $wrapperTr = (0, _jquery2.default)(''); danglingTableCells.each(function (i, cell) { $wrapperTr.append(cell); }); tr = $wrapperTr.get(0); } return tr; } /** * Wrap TRs with new TBODY * @param {jQuery} $container - clipboard container * @returns {HTMLElement|null} */ }, { key: 'wrapTrsIntoTbodyIfNeed', value: function wrapTrsIntoTbodyIfNeed($container) { var danglingTrs = $container.children('tr'); var ths = danglingTrs.find('th'); var tbody = void 0; if (ths.length) { ths.each(function (i, node) { var $node = (0, _jquery2.default)(node); var td = (0, _jquery2.default)(''); td.html($node.html()); td.insertBefore(node); $node.detach(); }); } if (danglingTrs.length) { var $wrapperTableBody = (0, _jquery2.default)(''); danglingTrs.each(function (i, tr) { $wrapperTableBody.append(tr); }); tbody = $wrapperTableBody.get(0); } return tbody; } /** * Wrap THEAD followed by TBODY both into Table * @param {jQuery} $container - clipboard container * @returns {HTMLElement|null} */ }, { key: 'wrapTheadAndTbodyIntoTableIfNeed', value: function wrapTheadAndTbodyIntoTableIfNeed($container) { var danglingThead = $container.children('thead'); var danglingTbody = $container.children('tbody'); var $wrapperTable = (0, _jquery2.default)('
'); var table = void 0; if (!danglingTbody.length && danglingThead.length) { $wrapperTable.append(danglingThead[0]); $wrapperTable.append(''); table = $wrapperTable.get(0); } else if (danglingTbody.length && !danglingThead.length) { $wrapperTable.append(''); $wrapperTable.append(danglingTbody[0]); table = $wrapperTable.get(0); } else if (danglingTbody.length && danglingThead.length) { $wrapperTable.append(danglingThead[0]); $wrapperTable.append(danglingTbody[0]); table = $wrapperTable.get(0); } return table; } /** * Whether pasting element is table element * @param {string} pastingNodeName Pasting node name * @returns {boolean} */ }, { key: 'isTableOrSubTableElement', value: function isTableOrSubTableElement(pastingNodeName) { return pastingNodeName === 'TABLE' || pastingNodeName === 'TBODY' || pastingNodeName === 'THEAD' || pastingNodeName === 'TR' || pastingNodeName === 'TD'; } /** * Stuff table cells into incomplete rows * @param {jQuery} $trs jQuery wrapped TRs * @param {number} maximumCellLength maximum cell length of table * @private */ }, { key: '_stuffTableCellsIntoIncompleteRow', value: function _stuffTableCellsIntoIncompleteRow($trs, maximumCellLength) { $trs.each(function (rowIndex, row) { var $row = (0, _jquery2.default)(row); var tableCells = $row.find('th,td'); var parentNodeName = _domUtils2.default.getNodeName($row.parent()[0]); var cellTagName = parentNodeName === 'THEAD' ? 'th' : 'td'; for (var cellLength = tableCells.length; cellLength < maximumCellLength; cellLength += 1) { $row.append((0, _jquery2.default)(tableCellGenerator(1, cellTagName))[0]); } }); } /** * Prepare to table cell stuffing * @param {jQuery} $trs jQuery wrapped TRs * @returns {{maximumCellLength: *, needTableCellStuffingAid: boolean}} */ }, { key: 'prepareToTableCellStuffing', value: function prepareToTableCellStuffing($trs) { var maximumCellLength = $trs.eq(0).find('th,td').length; var needTableCellStuffingAid = false; $trs.each(function (i, row) { var cellCount = (0, _jquery2.default)(row).find('th,td').length; if (maximumCellLength !== cellCount) { needTableCellStuffingAid = true; if (maximumCellLength < cellCount) { maximumCellLength = cellCount; } } }); return { maximumCellLength: maximumCellLength, needTableCellStuffingAid: needTableCellStuffingAid }; } /** * Add TBODY or THEAD if need * @param {jQuery} $table - Table jQuery element * @private */ }, { key: '_addTbodyOrTheadIfNeed', value: function _addTbodyOrTheadIfNeed($table) { var isTheadNotExists = !$table.find('thead').length; var isTbodyNotExists = !$table.find('tbody').length; var absentNode = void 0; if (isTheadNotExists) { absentNode = (0, _jquery2.default)('').get(0); $table.prepend(absentNode); } else if (isTbodyNotExists) { absentNode = (0, _jquery2.default)('').get(0); $table.append(absentNode); } } /** * Append table cells * @param {HTMLElement} node Table element */ }, { key: 'tableCellAppendAidForTableElement', value: function tableCellAppendAidForTableElement(node) { var $table = (0, _jquery2.default)(node); this._addTbodyOrTheadIfNeed($table); this._addTrIntoContainerIfNeed($table); var $trs = $table.find('tr'); var tableAidInformation = this.prepareToTableCellStuffing($trs); var maximumCellLength = tableAidInformation.maximumCellLength, needTableCellStuffingAid = tableAidInformation.needTableCellStuffingAid; if (needTableCellStuffingAid) { this._stuffTableCellsIntoIncompleteRow($trs, maximumCellLength); } } /** * Generate THEAD and append TDs with same amount of given TBODY * @param {HTMLElement} node TR element * @returns {{thead: HTMLElement, tbody: HTMLElement}} * @private */ }, { key: '_generateTheadAndTbodyFromTbody', value: function _generateTheadAndTbodyFromTbody(node) { var tr = (0, _jquery2.default)(''); var thead = (0, _jquery2.default)(''); tr.append(tableCellGenerator((0, _jquery2.default)(node).find('tr').eq(0).find('td').length, 'th')); thead.append(tr); return { thead: thead[0], tbody: node }; } /** * Generate TBODY and append TDs with same amount of given THEAD * @param {HTMLElement} node TR element * @returns {{thead: HTMLElement, tbody: HTMLElement}} * @private */ }, { key: '_generateTheadAndTbodyFromThead', value: function _generateTheadAndTbodyFromThead(node) { var tr = (0, _jquery2.default)(''); var tbody = (0, _jquery2.default)(''); tr.append(tableCellGenerator((0, _jquery2.default)(node).find('th').length, 'td')); tbody.append(tr); return { thead: node, tbody: tbody[0] }; } /** * Generate THEAD and TBODY and append given TR within * @param {HTMLElement} node TR element * @returns {{thead: HTMLElement, tbody: HTMLElement}} * @private */ }, { key: '_generateTheadAndTbodyFromTr', value: function _generateTheadAndTbodyFromTr(node) { var $node = (0, _jquery2.default)(node); var thead = (0, _jquery2.default)(''); var tbody = (0, _jquery2.default)(''); var theadRow = void 0, tbodyRow = void 0; if ($node.children()[0].tagName === 'TH') { theadRow = node; tbodyRow = (0, _jquery2.default)('' + tableCellGenerator($node.find('th').length, 'td') + '').get(0); } else { theadRow = (0, _jquery2.default)('' + tableCellGenerator($node.find('td').length, 'th') + '').get(0); tbodyRow = node; } thead.append(theadRow); tbody.append(tbodyRow); return { thead: thead[0], tbody: tbody[0] }; } /** * Complete passed table * @param {HTMLElement} node - Table inner element * @private */ }, { key: '_completeIncompleteTable', value: function _completeIncompleteTable(node) { var nodeName = node.tagName; var table = void 0, completedTableContents = void 0; if (nodeName === 'TABLE') { table = node; } else { table = document.createElement('table'); node.parentNode.insertBefore(table, node.nextSibling); if (nodeName === 'TBODY') { completedTableContents = this._generateTheadAndTbodyFromTbody(node); } else if (nodeName === 'THEAD') { completedTableContents = this._generateTheadAndTbodyFromThead(node); } else if (nodeName === 'TR') { completedTableContents = this._generateTheadAndTbodyFromTr(node); } table.appendChild(completedTableContents.thead); table.appendChild(completedTableContents.tbody); } this._removeEmptyRows(table); this.tableCellAppendAidForTableElement(table); } }, { key: '_removeEmptyRows', value: function _removeEmptyRows(table) { var trs = table.querySelectorAll('tr'); _tuiCodeSnippet2.default.forEachArray(trs, function (tr) { if (!tr.cells.length) { tr.parentNode.removeChild(tr); } }); } /** * Whole editor body searching incomplete table completion * @private */ }, { key: '_completeTableIfNeed', value: function _completeTableIfNeed() { var _this4 = this; var $body = this.wwe.getEditor().get$Body(); $body.children().each(function (index, node) { var $node = (0, _jquery2.default)(node); if (!_this4.isTableOrSubTableElement(node.nodeName)) { return; } if (node.nodeName === 'TABLE' && $node.find('tbody').length === 0) { $node.remove(); } else { _this4._completeIncompleteTable(node); } }); } /** * Reset _lastCellNode to null * @memberof WwTableManager */ }, { key: 'resetLastCellNode', value: function resetLastCellNode() { this._lastCellNode = null; } /** * Set _lastCellNode to given node * @param {HTMLElement} node Table cell * @memberof WwTableManager */ }, { key: 'setLastCellNode', value: function setLastCellNode(node) { this._lastCellNode = node; } /** * Return whether only modifier key pressed or not * @param {string} keymap Pressed keymap string * @returns {boolean} * @private */ }, { key: '_isSingleModifierKey', value: function _isSingleModifierKey(keymap) { return keymap === 'META' || keymap === 'SHIFT' || keymap === 'ALT' || keymap === 'CONTROL'; } /** * Return whether modifier keys pressed or not * @param {object} ev keyboard event object * @returns {boolean} * @private */ }, { key: '_isModifierKeyPushed', value: function _isModifierKeyPushed(ev) { return ev.metaKey || ev.ctrlKey || ev.altKey || ev.shiftKey; } /** * Add one row into empty TBODY * @param {jQuery} $table Currently processing table * @private */ }, { key: '_addTrIntoContainerIfNeed', value: function _addTrIntoContainerIfNeed($table) { var $trContainers = $table.children(); $trContainers.each(function (i, container) { var hasNoRows = (0, _jquery2.default)(container).find('tr').length === 0; if (hasNoRows) { (0, _jquery2.default)(container).append((0, _jquery2.default)('')[0]); } }); } }, { key: '_expandTableIfNeed', value: function _expandTableIfNeed(fragment) { var range = this.wwe.getEditor().getSelection().cloneRange(); var $table = (0, _jquery2.default)(range.startContainer).parents('table'); var difference = this._getColumnAndRowDifference(fragment, range); if (difference.column < 0) { this._appendCellForAllRow($table, difference.column); } if (difference.row < 0) { this._appendRow($table, difference.row); } } }, { key: '_getColumnAndRowDifference', value: function _getColumnAndRowDifference(fragment, range) { var tableData = this._getTableDataFromTable(fragment); var rowLength = tableData.length; var columnLength = tableData[0].length; var $currentCell = (0, _jquery2.default)(range.startContainer).closest('th,td'); var $currentRow = $currentCell.parent(); var currentColumnIndex = _domUtils2.default.getNodeOffsetOfParent($currentCell[0]); var currentRowIndex = _domUtils2.default.getNodeOffsetOfParent($currentCell[0].parentNode); var $table = $currentRow.parents('table'); var tableColumnLength = $table.find('tr').eq(0).children().length; var tableRowLength = $table.find('tr').length; var isInTbody = $currentRow.parents('tbody').length; if (isInTbody) { currentRowIndex += 1; } return { row: tableRowLength - (currentRowIndex + rowLength), column: tableColumnLength - (currentColumnIndex + columnLength) }; } }, { key: '_appendCellForAllRow', value: function _appendCellForAllRow($table, columnDifference) { var brString = isIE10 ? '' : '
'; $table.find('tr').each(function (i, row) { var tagName = void 0; for (var index = columnDifference; index < 0; index += 1) { if (i === 0) { tagName = 'th'; } else { tagName = 'td'; } (0, _jquery2.default)(row).append((0, _jquery2.default)('<' + tagName + '>' + brString + '')[0]); } }); } }, { key: '_appendRow', value: function _appendRow($table, rowDifference) { var newRow = $table.find('tr').last().clone(); var brHTMLSting = isIE10 ? '' : '
'; newRow.find('td').html(brHTMLSting); for (; rowDifference < 0; rowDifference += 1) { $table.find('tbody').append(newRow.clone()[0]); } } /** * Get sibling textNode by given direction * @param {HTMLElement} currentTextNode Current text node * @param {boolean} isNext Boolean value whether direction equals 'next' * @returns {boolean|null} * @private */ }, { key: '_getSiblingTextNodeByDirection', value: function _getSiblingTextNodeByDirection(currentTextNode, isNext) { var isPreviousLineExist = currentTextNode.previousSibling && currentTextNode.previousSibling.nodeName === 'BR' && currentTextNode.previousSibling.previousSibling && currentTextNode.previousSibling.previousSibling.nodeType === 3; var isNextLineExist = currentTextNode.nextSibling && currentTextNode.nextSibling.nodeName === 'BR' && currentTextNode.nextSibling.nextSibling && currentTextNode.nextSibling.nextSibling.nodeType === 3; var target = void 0; if (isNext && isNextLineExist) { target = currentTextNode.nextSibling.nextSibling; } else if (!isNext && isPreviousLineExist) { target = currentTextNode.previousSibling.previousSibling; } return target; } /** * Change selection to sibling cell * @param {HTMLElement} currentCell current TD or TH * @param {Range} range Range object * @param {string} direction 'next' or 'previous' * @param {string} scale 'row' or 'cell' * @private */ }, { key: '_changeSelectionToTargetCell', value: function _changeSelectionToTargetCell(currentCell, range, direction, scale) { var startContainer = range.startContainer; var isNext = direction === 'next'; var isRow = scale === 'row'; var target = void 0, textOffset = void 0; if (isRow) { if (_domUtils2.default.isTextNode(startContainer)) { target = this._getSiblingTextNodeByDirection(startContainer, isNext); if (target) { textOffset = target.length < range.startOffset ? target.length : range.startOffset; range.setStart(target, textOffset); range.collapse(true); return; } } target = _domUtils2.default.getSiblingRowCellByDirection(currentCell, direction, false); } else { target = _domUtils2.default.getTableCellByDirection(currentCell, direction); if (!target) { target = _domUtils2.default.getSiblingRowCellByDirection(currentCell, direction, true); } } if (target) { range.setStart(target, 0); range.collapse(true); } else { target = (0, _jquery2.default)(currentCell).parents('table').get(0); if (isNext) { range.setStart(target.nextElementSibling, 0); } else if (target.previousElementSibling && target.previousElementSibling.nodeName !== 'TABLE') { range.setStart(target.previousElementSibling, 1); } else { range.setStartBefore(target); } range.collapse(true); } } /** * Move cursor to given direction by interval formatter * @param {string} direction 'next' or 'previous' * @param {string} interval 'row' or 'cell' * @param {object} [ev] Event object * @returns {boolean | null} * @private */ }, { key: '_moveCursorTo', value: function _moveCursorTo(direction, interval, ev) { var sq = this.wwe.getEditor(); var range = sq.getSelection().cloneRange(); var currentCell = (0, _jquery2.default)(range.startContainer).closest('td,th').get(0); var isNeedNext = void 0; if (range.collapsed) { if (this.wwe.isInTable(range) && currentCell) { if ((direction === 'previous' || interval === 'row') && !_tuiCodeSnippet2.default.isUndefined(ev)) { ev.preventDefault(); } this._changeSelectionToTargetCell(currentCell, range, direction, interval); sq.setSelection(range); isNeedNext = false; } } return isNeedNext; } /** * Remove contents and change selection if need * @param {Range} range - Range object * @param {string} keymap - keymap * @param {object} ev - Event object * @returns {boolean} - true if contents has been removed * @private */ }, { key: '_removeContentsAndChangeSelectionIfNeed', value: function _removeContentsAndChangeSelectionIfNeed(range, keymap, ev) { var isTextInput = keymap.length <= 1; var isDeleteOperation = keymap === 'BACK_SPACE' || keymap === 'DELETE'; var $selectedCells = this.wwe.componentManager.getManager('tableSelection').getSelectedCells(); var firstSelectedCell = $selectedCells.first().get(0); var processed = false; if ((isTextInput || isDeleteOperation) && !this._isModifierKeyPushed(ev) && $selectedCells.length) { if (isDeleteOperation) { this._recordUndoStateIfNeed(range); } this._removeTableContents($selectedCells); this._lastCellNode = firstSelectedCell; range.setStart(firstSelectedCell, 0); range.collapse(true); this.wwe.getEditor().setSelection(range); processed = true; } return processed; } /** * Return new table ID class name string * @returns {string} * @memberof WwTableManager */ }, { key: 'getTableIDClassName', value: function getTableIDClassName() { var tableClassName = TABLE_CLASS_PREFIX + this.tableID; this.tableID += 1; return tableClassName; } /** * Remove br when text inputted * @param {Range} range Range object * @private */ }, { key: '_removeBRIfNeed', value: function _removeBRIfNeed(range) { var isText = _domUtils2.default.isTextNode(range.startContainer); var startContainer = isText ? range.startContainer.parentNode : range.startContainer; var nodeName = _domUtils2.default.getNodeName(startContainer); if (/td|th/i.test(nodeName) && range.collapsed && startContainer.textContent.length === 1) { (0, _jquery2.default)(startContainer).find('br').remove(); } } /** * Insert br when text deleted * @param {Range} range Range object * @private */ }, { key: '_insertBRIfNeed', value: function _insertBRIfNeed(range) { var isText = _domUtils2.default.isTextNode(range.startContainer); var currentCell = isText ? range.startContainer.parentNode : range.startContainer; var nodeName = _domUtils2.default.getNodeName(currentCell); var $currentCell = (0, _jquery2.default)(currentCell); if (/td|th/i.test(nodeName) && range.collapsed && !currentCell.textContent.length && !$currentCell.children().length && !isIE10And11) { currentCell.normalize(); $currentCell.append('
'); } } /** * Destroy. */ }, { key: 'destroy', value: function destroy() { var _this5 = this; this.eventManager.removeEventHandler('wysiwygRangeChangeAfter.table'); this.eventManager.removeEventHandler('wysiwygSetValueAfter.table'); this.eventManager.removeEventHandler('wysiwygProcessHTMLText.table'); this.eventManager.removeEventHandler('cut.table'); this.eventManager.removeEventHandler('copyBefore.table'); _tuiCodeSnippet2.default.forEach(this.keyEventHandlers, function (handler, key) { return _this5.wwe.removeKeyEventHandler(key, handler); }); } }]); return WwTableManager; }(); /** * Generate table cell HTML text * @param {number} amount Amount of cells * @param {string} tagName Tag name of cell 'td' or 'th' * @private * @returns {string} */ function tableCellGenerator(amount, tagName) { var brHTMLString = '
'; var cellString = '<' + tagName + '>' + brHTMLString + ''; var tdString = ''; for (var i = 0; i < amount; i += 1) { tdString = tdString + cellString; } return tdString; } exports.default = WwTableManager; /***/ }), /* 38 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview Implements wysiwyg table selection manager * @author NHN Ent. FE Development Lab */ var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _domUtils = __webpack_require__(4); var _domUtils2 = _interopRequireDefault(_domUtils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var TABLE_CELL_SELECTED_CLASS_NAME = 'te-cell-selected'; /** * Class WwTableSelectionManager */ var WwTableSelectionManager = function () { /** * Creates an instance of WwTableSelectionManager. * @param {WysiwygEditor} wwe - WysiwygEditor instance * @memberof WwTableSelectionManager */ function WwTableSelectionManager(wwe) { _classCallCheck(this, WwTableSelectionManager); this.wwe = wwe; this.eventManager = wwe.eventManager; /** * Name property * @memberof WwTableSelectionManager# * @type {string} */ this.name = 'tableSelection'; this._init(); } /** * _init * Initialize * @memberof WwTableSelectionManager * @private */ _createClass(WwTableSelectionManager, [{ key: '_init', value: function _init() { this._initEvent(); // For disable firefox's table tool UI and table resize handler if (_tuiCodeSnippet2.default.browser.firefox) { document.execCommand('enableObjectResizing', false, 'false'); document.execCommand('enableInlineTableEditing', false, 'false'); } } /** * _initEvent * Initialize event * @memberof WwTableSelectionManager * @private */ }, { key: '_initEvent', value: function _initEvent() { var _this = this; var selectionStart = void 0, selectionEnd = void 0, validSelectionEnd = void 0; /** * Start table selection timer * @type {object} * @private */ this._tableSelectionTimer = null; /** * Remove selection timer for Firefox table selection * @type {object} * @private */ this._removeSelectionTimer = null; /** * Boolean value for whether selection started * @type {boolean} * @private */ this._isSelectionStarted = false; var onMouseover = function onMouseover(ev) { selectionEnd = (0, _jquery2.default)(ev.data.target).closest('[contenteditable=true] td,th').get(0); var range = _this.wwe.getEditor().getSelection(); var isEndsInTable = (0, _jquery2.default)(selectionEnd).parents('[contenteditable=true] table').get(0); var isSameCell = selectionStart === selectionEnd; var isTextSelect = _this._isTextSelect(range, isSameCell) && !(0, _jquery2.default)(selectionStart).hasClass(TABLE_CELL_SELECTED_CLASS_NAME); if (_this._isSelectionStarted && isEndsInTable && !isTextSelect) { window.getSelection().removeAllRanges(); // For disable firefox's native table cell selection if (_tuiCodeSnippet2.default.browser.firefox && !_this._removeSelectionTimer) { _this._removeSelectionTimer = setInterval(function () { window.getSelection().removeAllRanges(); }, 10); } _this.highlightTableCellsBy(selectionStart, selectionEnd); validSelectionEnd = selectionEnd; } }; var finishSelection = function finishSelection() { if (_this._isSelectionStarted) { _this._isSelectionStarted = false; _this.eventManager.removeEventHandler('mouseover.tableSelection'); _this.eventManager.removeEventHandler('mouseup.tableSelection'); } }; var onMouseup = function onMouseup(ev) { selectionEnd = (0, _jquery2.default)(ev.data.target).closest('[contenteditable=true] td,th').get(0); var range = _this.wwe.getEditor().getSelection(); var isSameCell = selectionStart === selectionEnd; var isTextSelect = _this._isTextSelect(range, isSameCell) && !(0, _jquery2.default)(selectionStart).hasClass(TABLE_CELL_SELECTED_CLASS_NAME); _this._clearTableSelectionTimerIfNeed(); if (_this._isSelectionStarted) { if (isTextSelect) { _this.removeClassAttrbuteFromAllCellsIfNeed(); } else { _this.wwe.componentManager.getManager('table').resetLastCellNode(); selectionEnd = selectionEnd || validSelectionEnd; range = _this.wwe.getEditor().getSelection(); range.setStart(selectionEnd, 0); // IE wont fire copy/cut event if there is no selected range. // trick IE to fire the event if (_tuiCodeSnippet2.default.browser.msie) { range.setEnd(selectionEnd, 1); } else { range.setEnd(selectionEnd, 0); range.collapse(false); } _this.wwe.getEditor().setSelection(range); } if (_this.onDragEnd) { _this.onDragEnd(); } } finishSelection(); }; var onMousedown = function onMousedown(ev) { var MOUSE_RIGHT_BUTTON = 2; selectionStart = (0, _jquery2.default)(ev.data.target).closest('[contenteditable=true] td,th').get(0); var isSelectedCell = (0, _jquery2.default)(selectionStart).hasClass(TABLE_CELL_SELECTED_CLASS_NAME); selectionEnd = null; if (!isSelectedCell || isSelectedCell && ev.data.button !== MOUSE_RIGHT_BUTTON) { _this.removeClassAttrbuteFromAllCellsIfNeed(); _this.setTableSelectionTimerIfNeed(selectionStart); _this.eventManager.listen('mouseover.tableSelection', onMouseover); _this.eventManager.listen('mouseup.tableSelection', onMouseup); if (_this.onDragStart && selectionStart) { _this.onDragStart(selectionStart); } } else if (ev.data.button === MOUSE_RIGHT_BUTTON) { finishSelection(); } }; this.eventManager.listen('mousedown.tableSelection', onMousedown); this.eventManager.listen('copyBefore.tableSelection', finishSelection); this.eventManager.listen('pasteBefore.tableSelection', finishSelection); } /** * Return whether single cell text selection or not * @param {Range} range Range object * @param {boolean} isSameCell Boolean value for same cell selection * @returns {boolean} * @private */ }, { key: '_isTextSelect', value: function _isTextSelect(range, isSameCell) { return (/TD|TH|TEXT/i.test(range.commonAncestorContainer.nodeName) && isSameCell ); } /** * Set setTimeout and setInterval timer execution if table selecting situation * @param {HTMLElement} selectionStart Start element */ }, { key: 'setTableSelectionTimerIfNeed', value: function setTableSelectionTimerIfNeed(selectionStart) { var isTableSelecting = (0, _jquery2.default)(selectionStart).parents('[contenteditable=true] table').length; if (isTableSelecting) { this._isSelectionStarted = true; } } /** * Clear setTimeout and setInterval timer execution * @private */ }, { key: '_clearTableSelectionTimerIfNeed', value: function _clearTableSelectionTimerIfNeed() { clearTimeout(this._tableSelectionTimer); // For disable firefox's native table selection if (_tuiCodeSnippet2.default.browser.firefox && this._removeSelectionTimer) { clearTimeout(this._removeSelectionTimer); this._removeSelectionTimer = null; } } /** * Re arrange selection when table does not include both start and end selection element * @param {HTMLElement} selectionStart Start element of selection * @param {HTMLElement} selectionEnd End element of selection * @returns {{startContainer: HTMLElement, endContainer: HTMLElement}} * @private */ }, { key: '_reArrangeSelectionIfneed', value: function _reArrangeSelectionIfneed(selectionStart, selectionEnd) { var isRangeStartInTable = (0, _jquery2.default)(selectionStart).parents('[contenteditable=true] table').length; var isRangeEndInTable = (0, _jquery2.default)(selectionEnd).parents('[contenteditable=true] table').length; var isStartRangeOut = isRangeEndInTable && !isRangeStartInTable; var isEndRangeOut = !isRangeEndInTable && isRangeStartInTable; if (isStartRangeOut) { selectionStart = (0, _jquery2.default)(selectionEnd).parents('[contenteditable=true] table').find('th').first().get(0); } else if (isEndRangeOut) { selectionEnd = (0, _jquery2.default)(selectionStart).parents('[contenteditable=true] table').find('td').last().get(0); } return { startContainer: selectionStart, endContainer: selectionEnd }; } /** * Apply select direction to editor * @param {{startContainer: HTMLElement, endContainer: HTMLElement}} selectionInformation * Selection start and end element * @param {Range} range Range object * @returns {Range} * @private */ }, { key: '_applySelectionDirection', value: function _applySelectionDirection(selectionInformation, range) { var nodeOffsetOfParent = _domUtils2.default.getNodeOffsetOfParent; var selectionStart = selectionInformation.startContainer; var selectionEnd = selectionInformation.endContainer; var rowDirection = nodeOffsetOfParent((0, _jquery2.default)(selectionStart).closest('[contenteditable=true] tr')[0]) - nodeOffsetOfParent((0, _jquery2.default)(selectionEnd).closest('[contenteditable=true] tr')[0]); var cellDirection = nodeOffsetOfParent(selectionStart) - nodeOffsetOfParent(selectionEnd); var isSameRow = rowDirection === 0; var isRowIncreases = rowDirection < 0; var isColumnIncreases = cellDirection > 0; if (isSameRow) { if (isColumnIncreases) { range.setStart(selectionEnd, 0); range.setEnd(selectionStart, 1); } else { range.setStart(selectionStart, 0); range.setEnd(selectionEnd, 1); } } else if (isRowIncreases) { range.setStart(selectionStart, 0); range.setEnd(selectionEnd, 1); } else { range.setStart(selectionEnd, 0); range.setEnd(selectionStart, 1); } return range; } /** * Get selection coordinate by current selection * @param {HTMLElement} selectionStart start element * @param {HTMLElement} selectionEnd end element * @returns {{from: {row: number, cell: number}, to: {row: number, cell: number}}} * @memberof WwTableSelectionManager */ }, { key: 'getSelectionRangeFromTable', value: function getSelectionRangeFromTable(selectionStart, selectionEnd) { var nodeOffsetOfParent = _domUtils2.default.getNodeOffsetOfParent; var startRowOffset = nodeOffsetOfParent(selectionStart.parentNode); var endRowOffset = nodeOffsetOfParent(selectionEnd.parentNode); var startCellOffset = nodeOffsetOfParent(selectionStart); var endCellOffset = nodeOffsetOfParent(selectionEnd); var startCellContainer = _domUtils2.default.getParentUntil(selectionStart, 'TABLE'); var endCellContainer = _domUtils2.default.getParentUntil(selectionEnd, 'TABLE'); var isReversedTheadAndTbodySelect = _domUtils2.default.getNodeName(startCellContainer) === 'TBODY' && _domUtils2.default.getNodeName(endCellContainer) === 'THEAD'; var isTheadAndTbodySelect = startCellContainer !== endCellContainer; var isBothInTbody = !!(0, _jquery2.default)(selectionStart).parents('tbody').length && !!(0, _jquery2.default)(selectionEnd).parents('tbody').length; var start = { row: startRowOffset, cell: startCellOffset }; var end = { row: endRowOffset, cell: endCellOffset }; var from = void 0, to = void 0; if (isReversedTheadAndTbodySelect) { start.row += 1; } else if (isTheadAndTbodySelect) { end.row += 1; } else if (isBothInTbody) { start.row += 1; end.row += 1; } if (startRowOffset > endRowOffset || startRowOffset === endRowOffset && startCellOffset > endCellOffset) { from = end; to = start; } else { from = start; to = end; } return { from: from, to: to }; } /** * Highlight selected table cells * @param {HTMLElement} selectionStart start element * @param {HTMLElement} selectionEnd end element */ }, { key: 'highlightTableCellsBy', value: function highlightTableCellsBy(selectionStart, selectionEnd) { var trs = (0, _jquery2.default)(selectionStart).parents('[contenteditable=true] table').find('tr'); var selection = this.getSelectionRangeFromTable(selectionStart, selectionEnd); var rowFrom = selection.from.row; var cellFrom = selection.from.cell; var rowTo = selection.to.row; var cellTo = selection.to.cell; trs.each(function (rowIndex, row) { (0, _jquery2.default)(row).find('td,th').each(function (cellIndex, cell) { var $cell = (0, _jquery2.default)(cell); var isFromRow = rowIndex === rowFrom; var isToRow = rowIndex === rowTo; if (isFromRow && cellIndex < cellFrom || isToRow && cellIndex > cellTo || rowIndex < rowFrom || rowIndex > rowTo) { $cell.removeClass(TABLE_CELL_SELECTED_CLASS_NAME); } else { $cell.addClass(TABLE_CELL_SELECTED_CLASS_NAME); } }); }); } /** * Remove '.te-cell-selected' class from all of table Cell * @memberof WwTableSelectionManager */ }, { key: 'removeClassAttrbuteFromAllCellsIfNeed', value: function removeClassAttrbuteFromAllCellsIfNeed() { this.wwe.get$Body().find('td.' + TABLE_CELL_SELECTED_CLASS_NAME + ',th.' + TABLE_CELL_SELECTED_CLASS_NAME).each(function (i, node) { var $node = (0, _jquery2.default)(node); $node.removeClass(TABLE_CELL_SELECTED_CLASS_NAME); if (!$node.attr('class').length) { $node.removeAttr('class'); } }); } /** * gets selected cells * @returns {jQuery} selected cells * @memberof WwTableSelectionManager */ }, { key: 'getSelectedCells', value: function getSelectedCells() { return this.wwe.get$Body().find('.' + TABLE_CELL_SELECTED_CLASS_NAME); } /** * Create selection by selected cells and collapse that selection to end */ }, { key: 'createRangeBySelectedCells', value: function createRangeBySelectedCells() { var sq = this.wwe.getEditor(); var range = sq.getSelection().cloneRange(); var $selectedCells = this.getSelectedCells(); var firstSelectedCell = $selectedCells.first().get(0); var lastSelectedCell = $selectedCells.last().get(0); if ($selectedCells.length && this.wwe.isInTable(range)) { range.setStart(firstSelectedCell, 0); range.setEnd(lastSelectedCell, lastSelectedCell.childNodes.length); sq.setSelection(range); } } /** * Style to selected cells. * @param {function} onStyle - function for styling * @param {Object} [options] - options to be passed into onStyle */ }, { key: 'styleToSelectedCells', value: function styleToSelectedCells(onStyle, options) { this.createRangeBySelectedCells(); onStyle(this.wwe.getEditor(), options); } /** * Destroy. */ }, { key: 'destroy', value: function destroy() { this.eventManager.removeEventHandler('mousedown.tableSelection'); this.eventManager.removeEventHandler('mouseover.tableSelection'); this.eventManager.removeEventHandler('mouseup.tableSelection'); this.eventManager.removeEventHandler('copyBefore.tableSelection'); this.eventManager.removeEventHandler('pasteBefore.tableSelection'); } }]); return WwTableSelectionManager; }(); exports.default = WwTableSelectionManager; /***/ }), /* 39 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview Implements wysiwyg code block manager * @author NHN Ent. FE Development Lab */ var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _domUtils = __webpack_require__(4); var _domUtils2 = _interopRequireDefault(_domUtils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var isIE10 = _tuiCodeSnippet2.default.browser.msie && _tuiCodeSnippet2.default.browser.version === 10; var brString = isIE10 ? '' : '
'; var tagEntities = { '&': '&', '<': '<', '>': '>' }; var FIND_ZWS_RX = /\u200B/g; var CODEBLOCK_ATTR_NAME = 'data-te-codeblock'; /** * Class WwCodeBlockManager */ var WwCodeBlockManager = function () { /** * Creates an instance of WwCodeBlockManager. * @param {WysiwygEditor} wwe - wysiwygEditor instance * @memberof WwCodeBlockManager */ function WwCodeBlockManager(wwe) { _classCallCheck(this, WwCodeBlockManager); this.wwe = wwe; this.eventManager = wwe.eventManager; /** * Name property * @memberof WwCodeBlockManager# * @type {string} */ this.name = 'codeblock'; this._init(); } /** * _init * Initialize * @memberof WwCodeBlockManager * @private */ _createClass(WwCodeBlockManager, [{ key: '_init', value: function _init() { this._initKeyHandler(); this._initEvent(); } /** * _initKeyHandler * Initialize key event handler * @memberof WwCodeBlockManager * @private */ }, { key: '_initKeyHandler', value: function _initKeyHandler() { var _this = this; this._keyEventHandlers = { 'BACK_SPACE': this._onBackspaceKeyEventHandler.bind(this), 'ENTER': function ENTER(ev, range) { if (!_this.wwe.isInTable(range) && _this.wwe.getEditor().hasFormat('CODE')) { _this.wwe.defer(function () { var _wwe$getRange = _this.wwe.getRange(), startContainer = _wwe$getRange.startContainer; var codeNode = _this._getCodeNode(startContainer); if (codeNode && !_domUtils2.default.getTextLength(codeNode)) { codeNode.parentNode.removeChild(codeNode); } }); } } }; _tuiCodeSnippet2.default.forEach(this._keyEventHandlers, function (handler, key) { return _this.wwe.addKeyEventHandler(key, handler); }); } }, { key: '_getCodeNode', value: function _getCodeNode(node) { var result = void 0; if (node.nodeName === 'CODE') { result = node; } else if (node.parentNode.nodeName === 'CODE') { result = node.parentNode; } return result; } /** * _initEvent * Initialize eventmanager event * @memberof WwCodeBlockManager * @private */ }, { key: '_initEvent', value: function _initEvent() { var _this2 = this; this.eventManager.listen('wysiwygSetValueAfter.codeblock', function () { _this2.modifyCodeBlockForWysiwyg(); }); this.eventManager.listen('wysiwygProcessHTMLText.codeblock', function (html) { return _this2._changePreToPreCode(html); }); } /** * Prepare nodes for pasting to code block * @memberof WwCodeBlockManager * @param {Array.} nodes Node array * @returns {DocumentFragment} */ }, { key: 'prepareToPasteOnCodeblock', value: function prepareToPasteOnCodeblock(nodes) { var frag = this.wwe.getEditor().getDocument().createDocumentFragment(); var text = this.convertNodesToText(nodes); text = text.replace(/\n$/, ''); frag.appendChild(document.createTextNode(text)); return frag; } /** * Convert nodes to text for pasting to code block * @memberof WwCodeBlockManager * @param {Array.} nodes Node array * @returns {string} coverted string */ }, { key: 'convertNodesToText', value: function convertNodesToText(nodes) { var str = ''; var node = nodes.shift(); while (_tuiCodeSnippet2.default.isTruthy(node)) { var _node = node, childNodes = _node.childNodes; if (childNodes && _domUtils2.default.isBlockNode(node)) { str += this.convertNodesToText(_tuiCodeSnippet2.default.toArray(node.childNodes)); } else if (node.nodeName === 'BR') { str += '\n'; } else { var _node2 = node, textContent = _node2.textContent; str += sanitizeHtmlCode(textContent); } node = nodes.shift(); } return str; } /** * Copy content with code block style from code block selection * @memberof WwCodeBlockManager * @param {HTMLElement} element Copied element * @param {Range} range Range object * @returns {HTMLElement} * @private */ }, { key: '_copyCodeblockTypeFromRangeCodeblock', value: function _copyCodeblockTypeFromRangeCodeblock(element, range) { var blockNode = _domUtils2.default.getParentUntil(range.commonAncestorContainer, this.wwe.get$Body()[0]); if (_domUtils2.default.getNodeName(blockNode) === 'PRE') { var attrs = (0, _jquery2.default)(blockNode).prop('attributes'); _tuiCodeSnippet2.default.forEach(attrs, function (attr) { (0, _jquery2.default)(element).attr(attr.name, attr.value); }); } return element; } /** * Change pre tag to pre and code * @memberof WwCodeBlockManager * @param {string} html HTML string * @returns {string} * @private */ }, { key: '_changePreToPreCode', value: function _changePreToPreCode(html) { return html.replace(/((.|\n)*?)<\/pre>/g, function (match, codeAttr, code) { return '
' + code + '
'; }); } /** * Modify Code Block for Wysiwyg * @memberof WwCodeBlockManager * @param {HTMLElement} node root node to find pre * @private */ }, { key: 'modifyCodeBlockForWysiwyg', value: function modifyCodeBlockForWysiwyg(node) { if (!node) { node = this.wwe.get$Body(); } (0, _jquery2.default)(node).find('pre').each(function (index, pre) { var $pre = (0, _jquery2.default)(pre); var lang = $pre.find('code').attr('data-language'); var numberOfBackticks = $pre.find('code').attr('data-backticks'); // if this pre can have lines if ($pre.children().length > 1) { $pre.children().each(function (idx, childNode) { if ((childNode.nodeName === 'DIV' || childNode.nodeName === 'P') && !(0, _jquery2.default)(childNode).find('br').length) { (0, _jquery2.default)(childNode).append('\n'); } }); } $pre.find('br').replaceWith('\n'); var resultText = $pre.text().replace(/\s+$/, ''); $pre.empty(); $pre.html(resultText ? resultText : brString); if (lang) { $pre.attr('data-language', lang); $pre.addClass('lang-' + lang); } if (numberOfBackticks) { $pre.attr('data-backticks', numberOfBackticks); } $pre.attr(CODEBLOCK_ATTR_NAME, ''); }); } /** * Remove codeblock of first line when press backspace in first line * @memberof WwCodeBlockManager * @param {Event} ev Event object * @param {Range} range Range object * @returns {boolean} * @private */ }, { key: '_onBackspaceKeyEventHandler', value: function _onBackspaceKeyEventHandler(ev, range) { var isNeedNext = true; var sq = this.wwe.getEditor(); var container = range.commonAncestorContainer; if (this._isCodeBlockFirstLine(range) && !this._isFrontCodeblock(range)) { this._removeCodeblockFirstLine(container); range.collapse(true); isNeedNext = false; } else if (range.collapsed && this._isEmptyLine(container) && this._isBetweenSameCodeblocks(container)) { var previousSibling = container.previousSibling, nextSibling = container.nextSibling; var prevTextLength = previousSibling.textContent.length; sq.saveUndoState(range); container.parentNode.removeChild(container); this._mergeCodeblocks(previousSibling, nextSibling); range.setStart(previousSibling.childNodes[0], prevTextLength); range.collapse(true); isNeedNext = false; } if (!isNeedNext) { sq.setSelection(range); ev.preventDefault(); } return isNeedNext; } /** * Check node is empty line * @memberof WwCodeBlockManager * @param {Node} node node * @returns {boolean} * @private */ }, { key: '_isEmptyLine', value: function _isEmptyLine(node) { var nodeName = node.nodeName, childNodes = node.childNodes; var isEmpty = isIE10 ? node.textContent === '' : childNodes.length === 1 && childNodes[0].nodeName === 'BR'; return nodeName === 'DIV' && isEmpty; } /** * Check whether node is between same codeblocks * @memberof WwCodeBlockManager * @param {Node} node Node * @returns {boolean} * @private */ }, { key: '_isBetweenSameCodeblocks', value: function _isBetweenSameCodeblocks(node) { var previousSibling = node.previousSibling, nextSibling = node.nextSibling; return _domUtils2.default.getNodeName(previousSibling) === 'PRE' && _domUtils2.default.getNodeName(nextSibling) === 'PRE' && previousSibling.getAttribute('data-language') === nextSibling.getAttribute('data-language'); } }, { key: '_mergeCodeblocks', value: function _mergeCodeblocks(frontCodeblock, backCodeblock) { var postText = backCodeblock.textContent; frontCodeblock.childNodes[0].textContent += '\n' + postText; backCodeblock.parentNode.removeChild(backCodeblock); } /** * Check whether range is first line of code block * @memberof WwCodeBlockManager * @param {Range} range Range object * @returns {boolean} * @private */ }, { key: '_isCodeBlockFirstLine', value: function _isCodeBlockFirstLine(range) { return this.isInCodeBlock(range) && range.collapsed && range.startOffset === 0; } /** * Check whether front block of range is code block * @memberof WwCodeBlockManager * @param {Range} range Range object * @returns {boolean} * @private */ }, { key: '_isFrontCodeblock', value: function _isFrontCodeblock(range) { var block = _domUtils2.default.getParentUntil(range.startContainer, this.wwe.getEditor().getRoot()); var previousSibling = block.previousSibling; return previousSibling && previousSibling.nodeName === 'PRE'; } /** * Remove codeblock first line of codeblock * @memberof WwCodeBlockManager * @param {Node} node Pre Node * @private */ }, { key: '_removeCodeblockFirstLine', value: function _removeCodeblockFirstLine(node) { var sq = this.wwe.getEditor(); var preNode = node.nodeName === 'PRE' ? node : node.parentNode; var codeContent = preNode.textContent.replace(FIND_ZWS_RX, ''); sq.modifyBlocks(function () { var newFrag = sq.getDocument().createDocumentFragment(); var strArray = codeContent.split('\n'); var firstDiv = document.createElement('div'); var firstLine = strArray.shift(); firstDiv.innerHTML = '' + firstLine + brString; newFrag.appendChild(firstDiv); if (strArray.length) { var newPreNode = preNode.cloneNode(); newPreNode.textContent = strArray.join('\n'); newFrag.appendChild(newPreNode); } return newFrag; }); } /** * Return boolean value of whether current range is in the code block * @memberof WwCodeBlockManager * @param {Range} range Range object * @returns {boolean} */ }, { key: 'isInCodeBlock', value: function isInCodeBlock(range) { var target = void 0; if (range.collapsed) { target = range.startContainer; } else { target = range.commonAncestorContainer; } return !!(0, _jquery2.default)(target).closest('pre').length; } /** * Destroy. */ }, { key: 'destroy', value: function destroy() { var _this3 = this; this.eventManager.removeEventHandler('wysiwygSetValueAfter.codeblock'); this.eventManager.removeEventHandler('wysiwygProcessHTMLText.codeblock'); _tuiCodeSnippet2.default.forEach(this._keyEventHandlers, function (handler, key) { return _this3.wwe.removeKeyEventHandler(key, handler); }); } }]); return WwCodeBlockManager; }(); /** * Sanitize HTML code * @param {string} code code string * @returns {string} * @ignore */ function sanitizeHtmlCode(code) { return code ? code.replace(/[<>&]/g, function (tag) { return tagEntities[tag] || tag; }) : ''; } exports.default = WwCodeBlockManager; /***/ }), /* 40 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _uicontroller = __webpack_require__(8); var _uicontroller2 = _interopRequireDefault(_uicontroller); var _button = __webpack_require__(18); var _button2 = _interopRequireDefault(_button); var _toolbarItem = __webpack_require__(11); var _toolbarItem2 = _interopRequireDefault(_toolbarItem); var _toolbarDivider = __webpack_require__(41); var _toolbarDivider2 = _interopRequireDefault(_toolbarDivider); var _toolbarItemFactory = __webpack_require__(42); var _toolbarItemFactory2 = _interopRequireDefault(_toolbarItemFactory); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @fileoverview Implements toolbar * @author NHN Ent. FE Development Lab */ /** * Class Toolbar * @extends {UIController} */ var Toolbar = function (_UIController) { _inherits(Toolbar, _UIController); /** * Creates an instance of Toolbar. * @param {EventManager} eventManager - event manager * @param {ToolbarItem[]} [items=[]] - toolbar items * @memberof Toolbar */ /** * items * @memberof Toolbar * @private * @type {Array} */ function Toolbar(eventManager) { var items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; _classCallCheck(this, Toolbar); var _this = _possibleConstructorReturn(this, (Toolbar.__proto__ || Object.getPrototypeOf(Toolbar)).call(this, { tagName: 'div', className: 'tui-editor-defaultUI-toolbar' })); Object.defineProperty(_this, '_items', { enumerable: true, writable: true, value: [] }); _this._eventManager = eventManager; _this.setItems(items); _this._initEvent(eventManager); return _this; } /** * init event * @param {EventManager} eventManager - event manager */ /** * event manager * @memberof Toolbar * @private * @type {EventManager} */ _createClass(Toolbar, [{ key: '_initEvent', value: function _initEvent(eventManager) { var _this2 = this; eventManager.listen('stateChange', function (ev) { _this2._items.forEach(function (item) { if (item._state) { if (ev[item._state]) { item.$el.addClass('active'); } else { item.$el.removeClass('active'); } } }); }); eventManager.listen('changePreviewTabPreview', function () { return _this2.disableAllButton(); }); eventManager.listen('changePreviewTabWrite', function () { return _this2.enableAllButton(); }); eventManager.listen('changeMode', function () { return _this2.enableAllButton(); }); } /** * disable all toolbar button * @memberof Toolbar */ }, { key: 'disableAllButton', value: function disableAllButton() { this._items.forEach(function (item) { if (item instanceof _button2.default) { item.disable(); } }); } /** * enable all toolbar button * @memberof Toolbar */ }, { key: 'enableAllButton', value: function enableAllButton() { this._items.forEach(function (item) { if (item instanceof _button2.default) { item.enable(); } }); } /** * get toolbar items * @returns {ToolbarItem[]} - toolbar items * @memberof Toolbar */ }, { key: 'getItems', value: function getItems() { return this._items.slice(0); } /** * get toolbar item at given index * @param {number} index - item index * @returns {ToolbarItem} - toolbar item at the index */ }, { key: 'getItem', value: function getItem(index) { return this._items[index]; } /** * set toolbar items * @param {ToolbarItem[]} items - toolbar items * @memberof Toolbar */ }, { key: 'setItems', value: function setItems(items) { this.removeAllItems(); items.forEach(this.addItem.bind(this)); } /** * add toolbar item * @param {ToolbarItem|string|object} item - toolbar item * @memberof Toolbar */ }, { key: 'addItem', value: function addItem(item) { this.insertItem(this._items.length, item); } /** * insert toolbar item * @param {number} index - index at given item inserted * @param {ToolbarItem|string|object} item - toolbar item * @memberof Toolbar */ }, { key: 'insertItem', value: function insertItem(index, item) { var _this3 = this; if (_tuiCodeSnippet2.default.isString(item)) { item = _toolbarItemFactory2.default.create(item); } else if (_tuiCodeSnippet2.default.isString(item.type)) { item = _toolbarItemFactory2.default.create(item.type, item.options); } var children = this.$el.children(); if (index >= 0 && index < children.length) { item.$el.insertBefore(children.eq(index)); this._items.splice(index, 0, item); } else { item.$el.appendTo(this.$el); this._items.push(item); } item.onCommandHandler = function (e, commandName) { return _this3._eventManager.emit('command', commandName); }; item.onEventHandler = function (e, eventName) { return _this3._eventManager.emit(eventName); }; item.on('command', item.onCommandHandler); item.on('event', item.onEventHandler); } /** * get index of given item * @param {ToolbarItem} item - toolbar item * @returns {number} - index of given toolbar item * @memberof Toolbar */ }, { key: 'indexOfItem', value: function indexOfItem(item) { var index = void 0; if (item instanceof _toolbarItem2.default) { index = this._items.indexOf(item); } else if (_tuiCodeSnippet2.default.isString(item)) { var itemName = item; index = this._items.map(function (itemToTest) { return itemToTest.getName(); }).indexOf(itemName); } return index; } /** * remove an item * @param {ToolbarItem|number} item - an toolbar item or index of the item to remove * @param {boolean} destroy - destroy item or not * @returns {ToolbarItem|undefined} - removed item * @memberof Toolbar */ }, { key: 'removeItem', value: function removeItem(item) { var destroy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; var index = void 0; var removedItem = void 0; if (item instanceof _toolbarItem2.default) { index = this.indexOfItem(item); } else { index = item; } if (index >= 0) { removedItem = this._items.splice(index, 1)[0]; } if (removedItem) { if (destroy) { removedItem.destroy(); } else { removedItem.off('command', removedItem.onCommandHandler); removedItem.off('event', removedItem.onEventHandler); removedItem.$el.detach(); } } return removedItem; } /** * remove all toolbar items * @memberof Toolbar */ }, { key: 'removeAllItems', value: function removeAllItems() { while (this._items && this._items.length > 0) { this.removeItem(0); } } /** * destroy instance * @memberof Toolbar * @override */ }, { key: 'destroy', value: function destroy() { this.removeAllItems(); _get(Toolbar.prototype.__proto__ || Object.getPrototypeOf(Toolbar.prototype), 'destroy', this).call(this); } /** * add button * @param {Button} button - button instance * @param {Number} [index] - location the button will be placed * @memberof Toolbar * @deprecated */ }, { key: 'addButton', value: function addButton(button, index) { if (_tuiCodeSnippet2.default.isArray(button)) { var arrayIndex = button.length - 1; for (; arrayIndex >= 0; arrayIndex -= 1) { if (_tuiCodeSnippet2.default.isNumber(index)) { this._addButton(button[arrayIndex], index); } else { this._addButton(button); } } } else { this._addButton(button, index); } } /** * _addButton * @param {Button} button - button instance * @param {Number} index - location the button will be placed * @private * @deprecated */ }, { key: '_addButton', value: function _addButton(button, index) { var $btn = this._setButton(button, index).$el; if (_tuiCodeSnippet2.default.isNumber(index)) { this.$el.find('.' + _button2.default.className).eq(index - 1).before($btn); } else { this.$el.append($btn); } } /** * add divider * @returns {jQuery} - created divider jquery element * @memberof Toolbar * @deprecated */ }, { key: 'addDivider', value: function addDivider() { var $el = (0, _jquery2.default)('
'); this.$el.append($el); return $el; } /** * _setButton * @param {Button} button - button instance * @param {Number} index - location the button will be placed * @returns {Button} - button instance * @private * @deprecated */ }, { key: '_setButton', value: function _setButton(button, index) { var ev = this._eventManager; if (!(button instanceof _button2.default)) { button = new _button2.default(button); } button.on('command', function (e, commandName) { return ev.emit('command', commandName); }); button.on('event', function (e, eventName) { return ev.emit(eventName); }); if (_tuiCodeSnippet2.default.isNumber(index)) { this._items.splice(index, 0, button); } else { this._items.push(button); } return button; } }]); return Toolbar; }(_uicontroller2.default); exports.default = Toolbar; /***/ }), /* 41 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _toolbarItem = __webpack_require__(11); var _toolbarItem2 = _interopRequireDefault(_toolbarItem); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @fileoverview Implements Toolbar Divider * @author NHN Ent. FE Development Lab */ var ToolbarDivider = function (_ToolbarItem) { _inherits(ToolbarDivider, _ToolbarItem); /** * toolbar divider constructor * @memberof ToolbarDivider */ /** * item name * @memberof ToolbarDivider * @type {String} * @static */ function ToolbarDivider() { _classCallCheck(this, ToolbarDivider); return _possibleConstructorReturn(this, (ToolbarDivider.__proto__ || Object.getPrototypeOf(ToolbarDivider)).call(this, { name: ToolbarDivider.name, tagName: 'div', className: ToolbarDivider.className })); } /** * item class name * @memberof ToolbarDivider * @type {String} * @static */ return ToolbarDivider; }(_toolbarItem2.default); Object.defineProperty(ToolbarDivider, 'name', { enumerable: true, writable: true, value: 'divider' }); Object.defineProperty(ToolbarDivider, 'className', { enumerable: true, writable: true, value: 'tui-toolbar-divider' }); exports.default = ToolbarDivider; /***/ }), /* 42 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview Implements Toolbar Item Factory * @author NHN Ent. FE Development Lab */ var _toolbarItem = __webpack_require__(11); var _toolbarItem2 = _interopRequireDefault(_toolbarItem); var _toolbarButton = __webpack_require__(75); var _toolbarButton2 = _interopRequireDefault(_toolbarButton); var _toolbarDivider = __webpack_require__(41); var _toolbarDivider2 = _interopRequireDefault(_toolbarDivider); var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Toolbar Item Factory */ var ToolbarItemFactory = function () { function ToolbarItemFactory() { _classCallCheck(this, ToolbarItemFactory); } _createClass(ToolbarItemFactory, null, [{ key: 'create', /** * create toolbar item instance * @memberof ToolbarItemFactory * @param {string} name - toolbar item name * @param {object} [options] - options to the constructor * @return {ToolbarItem} - created toolbar item instance * @static */ /* eslint-disable complexity */ value: function create(name, options) { var toolbarItem = void 0; switch (name) { case 'heading': toolbarItem = new _toolbarButton2.default({ name: 'heading', className: 'tui-heading', event: 'openHeadingSelect', tooltip: _i18n2.default.get('Headings') }); break; case 'bold': toolbarItem = new _toolbarButton2.default({ name: 'bold', className: 'tui-bold', command: 'Bold', tooltip: _i18n2.default.get('Bold'), state: 'bold' }); break; case 'italic': toolbarItem = new _toolbarButton2.default({ name: 'italic', className: 'tui-italic', command: 'Italic', tooltip: _i18n2.default.get('Italic'), state: 'italic' }); break; case 'strike': toolbarItem = new _toolbarButton2.default({ name: 'strike', className: 'tui-strike', command: 'Strike', tooltip: _i18n2.default.get('Strike'), state: 'strike' }); break; case 'hr': toolbarItem = new _toolbarButton2.default({ name: 'hr', className: 'tui-hrline', command: 'HR', tooltip: _i18n2.default.get('Line') }); break; case 'quote': toolbarItem = new _toolbarButton2.default({ name: 'quote', className: 'tui-quote', command: 'Blockquote', tooltip: _i18n2.default.get('Blockquote'), state: 'quote' }); break; case 'ul': toolbarItem = new _toolbarButton2.default({ name: 'ul', className: 'tui-ul', command: 'UL', tooltip: _i18n2.default.get('Unordered list') }); break; case 'ol': toolbarItem = new _toolbarButton2.default({ name: 'ol', className: 'tui-ol', command: 'OL', tooltip: _i18n2.default.get('Ordered list') }); break; case 'task': toolbarItem = new _toolbarButton2.default({ name: 'task', className: 'tui-task', command: 'Task', tooltip: _i18n2.default.get('Task') }); break; case 'table': toolbarItem = new _toolbarButton2.default({ name: 'table', className: 'tui-table', event: 'openPopupAddTable', tooltip: _i18n2.default.get('Insert table') }); break; case 'image': toolbarItem = new _toolbarButton2.default({ name: 'image', className: 'tui-image', event: 'openPopupAddImage', tooltip: _i18n2.default.get('Insert image'), state: '' }); break; case 'link': toolbarItem = new _toolbarButton2.default({ name: 'link', className: 'tui-link', event: 'openPopupAddLink', tooltip: _i18n2.default.get('Insert link') }); break; case 'code': toolbarItem = new _toolbarButton2.default({ name: 'code', className: 'tui-code', command: 'Code', tooltip: _i18n2.default.get('Code'), state: 'code' }); break; case 'codeblock': toolbarItem = new _toolbarButton2.default({ name: 'codeblock', className: 'tui-codeblock', command: 'CodeBlock', tooltip: _i18n2.default.get('Insert CodeBlock'), state: 'codeBlock' }); break; case 'indent': toolbarItem = new _toolbarButton2.default({ name: 'indent', className: 'tui-indent', command: 'Indent', tooltip: _i18n2.default.get('Indent') }); break; case 'outdent': toolbarItem = new _toolbarButton2.default({ name: 'outdent', className: 'tui-outdent', command: 'Outdent', tooltip: _i18n2.default.get('Outdent') }); break; case 'divider': toolbarItem = new _toolbarDivider2.default(); break; case 'button': toolbarItem = new _toolbarButton2.default(options); break; case 'item': default: toolbarItem = new _toolbarItem2.default(options); } return toolbarItem; } /* eslint-enable complexity */ }]); return ToolbarItemFactory; }(); exports.default = ToolbarItemFactory; /***/ }), /* 43 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _uicontroller = __webpack_require__(8); var _uicontroller2 = _interopRequireDefault(_uicontroller); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @fileoverview Implements tab button ui * @author NHN Ent. FE Development Lab */ var CLASS_TAB_ACTIVE = 'te-tab-active'; /** * Class Tab * @extends {UIController} */ var Tab = function (_UIController) { _inherits(Tab, _UIController); /** * Creates an instance of Tab. * @param {object} options - options * @param {string} [options.initName] - name of the default activated button * @param {string[]} options.items - Button names to be created * @param {DOMElement[]} options.sections - Dom elements for tab * @param {function} [options.onItemClick] - when button is clicked pass button name to function * @memberof Tab */ function Tab() { var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; _classCallCheck(this, Tab); var _this = _possibleConstructorReturn(this, (Tab.__proto__ || Object.getPrototypeOf(Tab)).call(this, { tagName: 'div', className: 'te-tab' })); _this.sections = options.sections; _this._$activeButton = null; _this._render(options); _this._initEvent(options); return _this; } _createClass(Tab, [{ key: '_initEvent', value: function _initEvent(options) { var onItemClick = options.onItemClick; if (onItemClick) { this.on('itemClick', onItemClick); } this.on('click button', this._onTabButton.bind(this)); } }, { key: '_render', value: function _render(options) { var items = options.items, initName = options.initName; var tabButtons = []; for (var i = 0, len = items.length; i < len; i += 1) { tabButtons.push(''); } this.$el.html(tabButtons.join('')); this.activate(initName); } /** * activate * Activate Section & Button * @param {string} name button name to activate */ }, { key: 'activate', value: function activate(name) { var $button = this.$el.find('button:contains("' + name + '")'); this._activateTabByButton($button); } }, { key: '_onTabButton', value: function _onTabButton(ev) { var $button = (0, _jquery2.default)(ev.target); this._activateTabByButton($button); this.trigger('itemClick', $button.text()); } }, { key: '_activateTabByButton', value: function _activateTabByButton($button) { if (this._isActivatedButton($button)) { return; } this._updateClassByButton($button); } }, { key: '_updateClassByButton', value: function _updateClassByButton($activeButton) { // deactivate previously activated button if (this._$activeButton) { var sectionIndex = this._$activeButton.attr('data-index'); this._$activeButton.removeClass(CLASS_TAB_ACTIVE); if (this.sections) { this.sections[sectionIndex].removeClass(CLASS_TAB_ACTIVE); } } // activate new button $activeButton.addClass(CLASS_TAB_ACTIVE); this._$activeButton = $activeButton; var index = $activeButton.attr('data-index'); if (this.sections) { this.sections[index].addClass(CLASS_TAB_ACTIVE); } } }, { key: '_isActivatedButton', value: function _isActivatedButton($button) { return this._$activeButton && this._$activeButton.text() === $button.text(); } }]); return Tab; }(_uicontroller2.default); exports.default = Tab; /***/ }), /* 44 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Editor = __webpack_require__(45); // for jquery /** * @fileoverview entry point for editor * @author NHN Ent. FE Development Lab */ _jquery2.default.fn.tuiEditor = function () { var options = void 0, instance = void 0; var el = this.get(0); if (el) { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } options = args[0] || {}; instance = _jquery2.default.data(el, 'tuiEditor'); if (instance) { if (typeof options === 'string') { var _instance; return (_instance = instance)[options].apply(_instance, args.slice(1)); } } else { options.el = el; instance = Editor.factory(options); _jquery2.default.data(el, 'tuiEditor', instance); } } return this; }; module.exports = Editor; /***/ }), /* 45 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview Implemtents Editor * @author NHN Ent. FE Development Lab */ // markdown commands // wysiwyg Commands // langs var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _button = __webpack_require__(18); var _button2 = _interopRequireDefault(_button); var _markdownEditor = __webpack_require__(46); var _markdownEditor2 = _interopRequireDefault(_markdownEditor); var _mdPreview = __webpack_require__(12); var _mdPreview2 = _interopRequireDefault(_mdPreview); var _wysiwygEditor = __webpack_require__(56); var _wysiwygEditor2 = _interopRequireDefault(_wysiwygEditor); var _layout = __webpack_require__(70); var _layout2 = _interopRequireDefault(_layout); var _eventManager = __webpack_require__(15); var _eventManager2 = _interopRequireDefault(_eventManager); var _commandManager2 = __webpack_require__(2); var _commandManager3 = _interopRequireDefault(_commandManager2); var _extManager = __webpack_require__(16); var _extManager2 = _interopRequireDefault(_extManager); var _importManager = __webpack_require__(10); var _importManager2 = _interopRequireDefault(_importManager); var _wwCodeBlockManager = __webpack_require__(39); var _wwCodeBlockManager2 = _interopRequireDefault(_wwCodeBlockManager); var _convertor = __webpack_require__(17); var _convertor2 = _interopRequireDefault(_convertor); var _viewer = __webpack_require__(32); var _viewer2 = _interopRequireDefault(_viewer); var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); var _defaultUI = __webpack_require__(71); var _defaultUI2 = _interopRequireDefault(_defaultUI); var _domUtils = __webpack_require__(4); var _domUtils2 = _interopRequireDefault(_domUtils); var _wwTableManager = __webpack_require__(37); var _wwTableManager2 = _interopRequireDefault(_wwTableManager); var _wwTableSelectionManager = __webpack_require__(38); var _wwTableSelectionManager2 = _interopRequireDefault(_wwTableSelectionManager); var _codeBlockManager = __webpack_require__(7); var _codeBlockManager2 = _interopRequireDefault(_codeBlockManager); var _bold = __webpack_require__(89); var _bold2 = _interopRequireDefault(_bold); var _italic = __webpack_require__(90); var _italic2 = _interopRequireDefault(_italic); var _strike = __webpack_require__(91); var _strike2 = _interopRequireDefault(_strike); var _blockquote = __webpack_require__(92); var _blockquote2 = _interopRequireDefault(_blockquote); var _heading = __webpack_require__(93); var _heading2 = _interopRequireDefault(_heading); var _paragraph = __webpack_require__(94); var _paragraph2 = _interopRequireDefault(_paragraph); var _hr = __webpack_require__(95); var _hr2 = _interopRequireDefault(_hr); var _addLink = __webpack_require__(96); var _addLink2 = _interopRequireDefault(_addLink); var _addImage = __webpack_require__(97); var _addImage2 = _interopRequireDefault(_addImage); var _ul = __webpack_require__(98); var _ul2 = _interopRequireDefault(_ul); var _ol = __webpack_require__(99); var _ol2 = _interopRequireDefault(_ol); var _indent = __webpack_require__(100); var _indent2 = _interopRequireDefault(_indent); var _outdent = __webpack_require__(101); var _outdent2 = _interopRequireDefault(_outdent); var _table = __webpack_require__(102); var _table2 = _interopRequireDefault(_table); var _task = __webpack_require__(103); var _task2 = _interopRequireDefault(_task); var _code = __webpack_require__(104); var _code2 = _interopRequireDefault(_code); var _codeBlock = __webpack_require__(105); var _codeBlock2 = _interopRequireDefault(_codeBlock); var _bold3 = __webpack_require__(106); var _bold4 = _interopRequireDefault(_bold3); var _italic3 = __webpack_require__(107); var _italic4 = _interopRequireDefault(_italic3); var _strike3 = __webpack_require__(108); var _strike4 = _interopRequireDefault(_strike3); var _blockquote3 = __webpack_require__(109); var _blockquote4 = _interopRequireDefault(_blockquote3); var _addImage3 = __webpack_require__(110); var _addImage4 = _interopRequireDefault(_addImage3); var _addLink3 = __webpack_require__(111); var _addLink4 = _interopRequireDefault(_addLink3); var _hr3 = __webpack_require__(112); var _hr4 = _interopRequireDefault(_hr3); var _heading3 = __webpack_require__(113); var _heading4 = _interopRequireDefault(_heading3); var _paragraph3 = __webpack_require__(114); var _paragraph4 = _interopRequireDefault(_paragraph3); var _ul3 = __webpack_require__(115); var _ul4 = _interopRequireDefault(_ul3); var _ol3 = __webpack_require__(116); var _ol4 = _interopRequireDefault(_ol3); var _table3 = __webpack_require__(117); var _table4 = _interopRequireDefault(_table3); var _tableAddRow = __webpack_require__(118); var _tableAddRow2 = _interopRequireDefault(_tableAddRow); var _tableAddCol = __webpack_require__(119); var _tableAddCol2 = _interopRequireDefault(_tableAddCol); var _tableRemoveRow = __webpack_require__(120); var _tableRemoveRow2 = _interopRequireDefault(_tableRemoveRow); var _tableRemoveCol = __webpack_require__(121); var _tableRemoveCol2 = _interopRequireDefault(_tableRemoveCol); var _tableAlignCol = __webpack_require__(122); var _tableAlignCol2 = _interopRequireDefault(_tableAlignCol); var _tableRemove = __webpack_require__(123); var _tableRemove2 = _interopRequireDefault(_tableRemove); var _indent3 = __webpack_require__(124); var _indent4 = _interopRequireDefault(_indent3); var _outdent3 = __webpack_require__(125); var _outdent4 = _interopRequireDefault(_outdent3); var _task3 = __webpack_require__(126); var _task4 = _interopRequireDefault(_task3); var _code3 = __webpack_require__(127); var _code4 = _interopRequireDefault(_code3); var _codeBlock3 = __webpack_require__(128); var _codeBlock4 = _interopRequireDefault(_codeBlock3); __webpack_require__(129); __webpack_require__(130); __webpack_require__(131); __webpack_require__(132); __webpack_require__(133); __webpack_require__(134); __webpack_require__(135); __webpack_require__(136); __webpack_require__(137); __webpack_require__(138); __webpack_require__(139); __webpack_require__(140); __webpack_require__(141); __webpack_require__(142); __webpack_require__(143); __webpack_require__(144); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var __nedInstance = []; var gaTrackingId = 'UA-129966929-1'; /** * @callback addImageBlobHook * @param {File|Blob} fileOrBlob - image blob * @param {callback} callback - callback function to be called after * @param {string} source - source of an event the item belongs to. 'paste', 'drop', 'ui' */ /** * Class ToastUIEditor */ var ToastUIEditor = function () { /** * ToastUI Editor * @param {object} options Option object * @param {HTMLElement} options.el - container element * @param {string} [options.height='300px'] - Editor's height style value. Height is applied as border-box ex) '300px', '100%', 'auto' * @param {string} [options.minHeight='200px'] - Editor's min-height style value in pixel ex) '300px' * @param {string} [options.initialValue] - Editor's initial value * @param {string} [options.previewStyle] - Markdown editor's preview style (tab, vertical) * @param {string} [options.initialEditType] - Initial editor type (markdown, wysiwyg) * @param {object[]} [options.events] - eventlist Event list * @param {function} options.events.load - It would be emitted when editor fully load * @param {function} options.events.change - It would be emitted when content changed * @param {function} options.events.stateChange - It would be emitted when format change by cursor position * @param {function} options.events.focus - It would be emitted when editor get focus * @param {function} options.events.blur - It would be emitted when editor loose focus * @param {object[]} [options.hooks] - Hook list * @param {function} options.hooks.previewBeforeHook - Submit preview to hook URL before preview be shown * @param {addImageBlobHook} options.hooks.addImageBlobHook - hook for image upload. * @param {string} [options.language='en_US'] - language * @param {boolean} [options.useCommandShortcut=true] - whether use keyboard shortcuts to perform commands * @param {boolean} [options.useDefaultHTMLSanitizer=true] - use default htmlSanitizer * @param {string[]} [options.codeBlockLanguages] - supported code block languages to be listed. default is what highlight.js supports * @param {boolean} [options.usageStatistics=true] - send hostname to google analytics * @param {string[]} [options.toolbarItems] - toolbar items. * @param {boolean} [options.hideModeSwitch=false] - hide mode switch tab bar * @param {string[]} [options.exts] - extensions * @param {object} [options.customConvertor] - convertor extention * @param {string} [options.placeholder] - The placeholder text of the editable element. */ function ToastUIEditor(options) { var _this = this; _classCallCheck(this, ToastUIEditor); this.initialHtml = options.el.innerHTML; options.el.innerHTML = ''; this.options = _jquery2.default.extend({ previewStyle: 'tab', initialEditType: 'markdown', height: '300px', minHeight: '200px', language: 'en_US', useDefaultHTMLSanitizer: true, useCommandShortcut: true, codeBlockLanguages: _codeBlockManager.CodeBlockManager.getHighlightJSLanguages(), usageStatistics: true, toolbarItems: ['heading', 'bold', 'italic', 'strike', 'divider', 'hr', 'quote', 'divider', 'ul', 'ol', 'task', 'indent', 'outdent', 'divider', 'table', 'image', 'link', 'divider', 'code', 'codeblock'], hideModeSwitch: false, customConvertor: null }, options); this.eventManager = new _eventManager2.default(); this.importManager = new _importManager2.default(this.eventManager); this.commandManager = new _commandManager3.default(this, { useCommandShortcut: this.options.useCommandShortcut }); if (this.options.customConvertor) { // eslint-disable-next-line new-cap this.convertor = new this.options.customConvertor(this.eventManager); } else { this.convertor = new _convertor2.default(this.eventManager); } if (this.options.useDefaultHTMLSanitizer) { this.convertor.initHtmlSanitizer(); } if (this.options.hooks) { _tuiCodeSnippet2.default.forEach(this.options.hooks, function (fn, key) { return _this.addHook(key, fn); }); } if (this.options.events) { _tuiCodeSnippet2.default.forEach(this.options.events, function (fn, key) { return _this.on(key, fn); }); } this.layout = new _layout2.default(options, this.eventManager); this.i18n = _i18n2.default; this.i18n.setCode(this.options.language); this.setUI(this.options.UI || new _defaultUI2.default(this)); this.mdEditor = _markdownEditor2.default.factory(this.layout.getMdEditorContainerEl(), this.eventManager, this.options); this.preview = new _mdPreview2.default(this.layout.getPreviewEl(), this.eventManager, this.convertor); this.wwEditor = _wysiwygEditor2.default.factory(this.layout.getWwEditorContainerEl(), this.eventManager); this.toMarkOptions = null; this.changePreviewStyle(this.options.previewStyle); this.changeMode(this.options.initialEditType, true); this.minHeight(this.options.minHeight); this.height(this.options.height); this.setValue(this.options.initialValue, false); if (this.options.placeholder) { this.setPlaceholder(this.options.placeholder); } if (!this.options.initialValue) { this.setHtml(this.initialHtml, false); } _extManager2.default.applyExtension(this, this.options.exts); this.eventManager.emit('load', this); __nedInstance.push(this); this._addDefaultCommands(); if (this.options.usageStatistics) { _tuiCodeSnippet2.default.sendHostname('editor', gaTrackingId); } } /** * change preview style * @memberof ToastUIEditor * @param {string} style - 'tab'|'vertical' */ _createClass(ToastUIEditor, [{ key: 'changePreviewStyle', value: function changePreviewStyle(style) { this.layout.changePreviewStyle(style); this.mdPreviewStyle = style; this.eventManager.emit('changePreviewStyle', style); this.eventManager.emit('previewNeedsRefresh'); } /** * call commandManager's exec method * @memberof ToastUIEditor * @param {*} ...args Command argument */ }, { key: 'exec', value: function exec() { var _commandManager; (_commandManager = this.commandManager).exec.apply(_commandManager, arguments); } /** * add default commands * @memberof ToastUIEditor * @private */ }, { key: '_addDefaultCommands', value: function _addDefaultCommands() { this.addCommand(_bold2.default); this.addCommand(_italic2.default); this.addCommand(_blockquote2.default); this.addCommand(_heading2.default); this.addCommand(_paragraph2.default); this.addCommand(_hr2.default); this.addCommand(_addLink2.default); this.addCommand(_addImage2.default); this.addCommand(_ul2.default); this.addCommand(_ol2.default); this.addCommand(_indent2.default); this.addCommand(_outdent2.default); this.addCommand(_table2.default); this.addCommand(_task2.default); this.addCommand(_code2.default); this.addCommand(_codeBlock2.default); this.addCommand(_strike2.default); this.addCommand(_bold4.default); this.addCommand(_italic4.default); this.addCommand(_blockquote4.default); this.addCommand(_ul4.default); this.addCommand(_ol4.default); this.addCommand(_addImage4.default); this.addCommand(_addLink4.default); this.addCommand(_hr4.default); this.addCommand(_heading4.default); this.addCommand(_paragraph4.default); this.addCommand(_indent4.default); this.addCommand(_outdent4.default); this.addCommand(_task4.default); this.addCommand(_table4.default); this.addCommand(_tableAddRow2.default); this.addCommand(_tableAddCol2.default); this.addCommand(_tableRemoveRow2.default); this.addCommand(_tableRemoveCol2.default); this.addCommand(_tableAlignCol2.default); this.addCommand(_tableRemove2.default); this.addCommand(_code4.default); this.addCommand(_codeBlock4.default); this.addCommand(_strike4.default); } }, { key: 'addCommand', value: function addCommand(type, props) { if (!props) { this.commandManager.addCommand(type); } else { this.commandManager.addCommand(_commandManager3.default.command(type, props)); } } /** * After added command. */ }, { key: 'afterAddedCommand', value: function afterAddedCommand() { this.eventManager.emit('afterAddedCommand', this); } /** * Bind eventHandler to event type * @memberof ToastUIEditor * @param {string} type Event type * @param {function} handler Event handler */ }, { key: 'on', value: function on(type, handler) { this.eventManager.listen(type, handler); } /** * Unbind eventHandler from event type * @memberof ToastUIEditor * @param {string} type Event type */ }, { key: 'off', value: function off(type) { this.eventManager.removeEventHandler(type); } /** * Add hook to TUIEditor event * @memberof ToastUIEditor * @param {string} type Event type * @param {function} handler Event handler */ }, { key: 'addHook', value: function addHook(type, handler) { this.eventManager.removeEventHandler(type); this.eventManager.listen(type, handler); } /** * Remove hook from TUIEditor event * @memberof ToastUIEditor * @param {string} type Event type */ }, { key: 'removeHook', value: function removeHook(type) { this.eventManager.removeEventHandler(type); } /** * Get CodeMirror instance * @memberof ToastUIEditor * @returns {CodeMirror} */ }, { key: 'getCodeMirror', value: function getCodeMirror() { return this.mdEditor.getEditor(); } /** * Get SquireExt instance * @memberof ToastUIEditor * @returns {SquireExt} */ }, { key: 'getSquire', value: function getSquire() { return this.wwEditor.getEditor(); } /** * Set focus to current Editor * @memberof ToastUIEditor */ }, { key: 'focus', value: function focus() { this.getCurrentModeEditor().focus(); } /** * Remove focus of current Editor * @memberof ToastUIEditor */ }, { key: 'blur', value: function blur() { this.getCurrentModeEditor().blur(); } /** * Set cursor position to end * @memberof ToastUIEditor */ }, { key: 'moveCursorToEnd', value: function moveCursorToEnd() { this.getCurrentModeEditor().moveCursorToEnd(); } /** * Set cursor position to start * @memberof ToastUIEditor */ }, { key: 'moveCursorToStart', value: function moveCursorToStart() { this.getCurrentModeEditor().moveCursorToStart(); } /** * Set markdown syntax text. * @memberof ToastUIEditor * @param {string} markdown - markdown syntax text. * @param {boolean} [cursorToEnd=true] - move cursor to contents end */ }, { key: 'setMarkdown', value: function setMarkdown(markdown) { var cursorToEnd = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; markdown = markdown || ''; if (this.isMarkdownMode()) { this.mdEditor.setValue(markdown, cursorToEnd); } else { this.wwEditor.setValue(this.convertor.toHTML(markdown), cursorToEnd); } this.eventManager.emit('setMarkdownAfter', markdown); } /** * Set html value. * @memberof ToastUIEditor * @param {string} html - html syntax text * @param {boolean} [cursorToEnd=true] - move cursor to contents end */ }, { key: 'setHtml', value: function setHtml(html) { var cursorToEnd = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; html = html || ''; this.wwEditor.setValue(html, cursorToEnd); if (this.isMarkdownMode()) { var markdown = this.convertor.toMarkdown(this.wwEditor.getValue(), this.toMarkOptions); this.mdEditor.setValue(markdown, cursorToEnd); this.eventManager.emit('setMarkdownAfter', markdown); } } /** * Set markdown syntax text. * @memberof ToastUIEditor * @param {string} value - markdown syntax text * @param {boolean} [cursorToEnd=true] - move cursor to contents end * @deprecated */ }, { key: 'setValue', value: function setValue(value) { var cursorToEnd = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; this.setMarkdown(value, cursorToEnd); } /** * Get markdown syntax text. * @memberof ToastUIEditor * @returns {string} */ }, { key: 'getMarkdown', value: function getMarkdown() { var markdown = void 0; if (this.isMarkdownMode()) { markdown = this.mdEditor.getValue(); } else { markdown = this.convertor.toMarkdown(this.wwEditor.getValue(), this.toMarkOptions); } return markdown; } /** * Get html syntax text. * @memberof ToastUIEditor * @returns {string} */ }, { key: 'getHtml', value: function getHtml() { if (this.isWysiwygMode()) { this.mdEditor.setValue(this.convertor.toMarkdown(this.wwEditor.getValue(), this.toMarkOptions)); } return this.convertor.toHTML(this.mdEditor.getValue()); } /** * Get editor value. * @memberof ToastUIEditor * @returns {string} * @deprecated */ }, { key: 'getValue', value: function getValue() { return this.getMarkdown(); } /** * insert text * @param {string} text - text string to insert * @memberof ToastUIEditor */ }, { key: 'insertText', value: function insertText(text) { if (this.isMarkdownMode()) { this.mdEditor.replaceSelection(text); } else { this.wwEditor.insertText(text); } } /** * Add widget to selection * @memberof ToastUIEditor * @param {Range} selection Current selection * @param {Node} node widget node * @param {string} style Adding style "over" or "bottom" * @param {number} [offset] Offset for adjust position */ }, { key: 'addWidget', value: function addWidget(selection, node, style, offset) { this.getCurrentModeEditor().addWidget(selection, node, style, offset); } /** * Set and return edithr height * @memberof ToastUIEditor * @param {string} height - editor height * @returns {string} editor height */ }, { key: 'height', value: function height(_height) { if (_tuiCodeSnippet2.default.isExisty(_height)) { if (_height === 'auto') { (0, _jquery2.default)(this.options.el).addClass('auto-height'); this.minHeight(this.minHeight()); } else { (0, _jquery2.default)(this.options.el).removeClass('auto-height'); this.minHeight(_height); } if (_tuiCodeSnippet2.default.isNumber(_height)) { _height = _height + 'px'; } this.options.el.style.height = _height; this._height = _height; } return this._height; } /** * Set / Get min content height * @param {string} minHeight - min content height in pixel * @memberof ToastUIEditor * @returns {string} - min height in pixel */ }, { key: 'minHeight', value: function minHeight(_minHeight) { if (_tuiCodeSnippet2.default.isExisty(_minHeight)) { var editorHeight = this._ui.getEditorHeight(); var editorSectionHeight = this._ui.getEditorSectionHeight(); var diffHeight = editorHeight - editorSectionHeight; this._minHeight = _minHeight; _minHeight = parseInt(_minHeight, 10); _minHeight = Math.max(_minHeight - diffHeight, 0); this.wwEditor.setMinHeight(_minHeight); this.mdEditor.setMinHeight(_minHeight); this.preview.setMinHeight(_minHeight); } return this._minHeight; } /** * Get current editor mode name * @memberof ToastUIEditor * @returns {Object} mdEditor or wwEditor */ }, { key: 'getCurrentModeEditor', value: function getCurrentModeEditor() { var editor = void 0; if (this.isMarkdownMode()) { editor = this.mdEditor; } else { editor = this.wwEditor; } return editor; } /** * Return true if current editor mode is Markdown * @memberof ToastUIEditor * @returns {boolean} */ }, { key: 'isMarkdownMode', value: function isMarkdownMode() { return this.currentMode === 'markdown'; } /** * Return true if current editor mode is WYSIWYG * @memberof ToastUIEditor * @returns {boolean} */ }, { key: 'isWysiwygMode', value: function isWysiwygMode() { return this.currentMode === 'wysiwyg'; } /** * Return false * @memberof ToastUIEditor * @returns {boolean} */ }, { key: 'isViewer', value: function isViewer() { return false; } /** * Get current Markdown editor's preview style * @memberof ToastUIEditor * @returns {string} */ }, { key: 'getCurrentPreviewStyle', value: function getCurrentPreviewStyle() { return this.mdPreviewStyle; } /** * Change editor's mode to given mode string * @memberof ToastUIEditor * @param {string} mode - Editor mode name of want to change * @param {boolean} [isWithoutFocus] - Change mode without focus */ }, { key: 'changeMode', value: function changeMode(mode, isWithoutFocus) { if (this.currentMode === mode) { return; } this.eventManager.emit('changeModeBefore', this.currentMode); this.currentMode = mode; if (this.isWysiwygMode()) { this.layout.switchToWYSIWYG(); this.wwEditor.setValue(this.convertor.toHTML(this.mdEditor.getValue()), !isWithoutFocus); this.eventManager.emit('changeModeToWysiwyg'); } else { this.layout.switchToMarkdown(); this.mdEditor.resetState(); this.mdEditor.setValue(this.convertor.toMarkdown(this.wwEditor.getValue(), this.toMarkOptions), !isWithoutFocus); this.getCodeMirror().refresh(); this.eventManager.emit('changeModeToMarkdown'); } this.eventManager.emit('changeMode', mode); if (!isWithoutFocus) { this.focus(); } } /** * Remove TUIEditor from document * @memberof ToastUIEditor */ }, { key: 'remove', value: function remove() { var self = this; var i = __nedInstance.length - 1; this.wwEditor.remove(); this.mdEditor.remove(); this.layout.remove(); this.preview.remove(); if (this.getUI()) { this.getUI().remove(); } this.eventManager.emit('removeEditor'); this.eventManager.events.forEach(function (value, key) { self.off(key); }); this.eventManager = null; for (; i >= 0; i -= 1) { if (__nedInstance[i] === this) { __nedInstance.splice(i, 1); } } } /** * Hide TUIEditor * @memberof ToastUIEditor */ }, { key: 'hide', value: function hide() { this.eventManager.emit('hide', this); } /** * Show TUIEditor * @memberof ToastUIEditor */ }, { key: 'show', value: function show() { this.eventManager.emit('show', this); this.getCodeMirror().refresh(); } /** * Scroll Editor content to Top * @memberof ToastUIEditor * @param {number} value Scroll amount * @returns {number} */ }, { key: 'scrollTop', value: function scrollTop(value) { return this.getCurrentModeEditor().scrollTop(value); } /** * Set UI to private UI property * @memberof ToastUIEditor * @param {UI} UI UI instance */ }, { key: 'setUI', value: function setUI(UI) { this._ui = UI; } /** * Get _ui property * @memberof ToastUIEditor * @returns {UI} */ }, { key: 'getUI', value: function getUI() { return this._ui; } /** * Reset TUIEditor * @memberof ToastUIEditor */ }, { key: 'reset', value: function reset() { this.wwEditor.reset(); this.mdEditor.reset(); } /** * Get current range * @memberof ToastUIEditor * @returns {{start, end}|Range} */ }, { key: 'getRange', value: function getRange() { return this.getCurrentModeEditor().getRange(); } /** * Get text object of current range * @memberof ToastUIEditor * @param {{start, end}|Range} range Range object of each editor * @returns {object} TextObject class */ }, { key: 'getTextObject', value: function getTextObject(range) { return this.getCurrentModeEditor().getTextObject(range); } /** * get selected text * @returns {string} - selected text * @memberof ToastUIEditor */ }, { key: 'getSelectedText', value: function getSelectedText() { var range = this.getRange(); var textObject = this.getTextObject(range); return textObject.getTextContent() || ''; } /** * Set the placeholder on all editors * @param {string} placeholder - placeholder to set */ }, { key: 'setPlaceholder', value: function setPlaceholder(placeholder) { this.mdEditor.setPlaceholder(placeholder); this.wwEditor.setPlaceholder(placeholder); } /** * Get instance of TUIEditor * @memberof ToastUIEditor * @returns {Array} */ }], [{ key: 'getInstances', value: function getInstances() { return __nedInstance; } /** * Define extension * @memberof ToastUIEditor * @param {string} name Extension name * @param {ExtManager~extension} ext extension */ }, { key: 'defineExtension', value: function defineExtension(name, ext) { _extManager2.default.defineExtension(name, ext); } /** * Factory method for Editor * @memberof ToastUIEditor * @param {object} options Option for initialize TUIEditor * @returns {object} ToastUIEditor or ToastUIEditorViewer */ }, { key: 'factory', value: function factory(options) { var tuiEditor = void 0; if (options.viewer) { tuiEditor = new _viewer2.default(options); } else { tuiEditor = new ToastUIEditor(options); } return tuiEditor; } }]); return ToastUIEditor; }(); /** * check whther is viewer * @type {boolean} */ ToastUIEditor.isViewer = false; /** * I18n instance * @type {I18n} */ ToastUIEditor.i18n = _i18n2.default; /** * domUtil instance * @type {DomUtil} */ ToastUIEditor.domUtils = _domUtils2.default; /** * CodeBlockManager instance * @type {CodeBlockManager} */ ToastUIEditor.codeBlockManager = _codeBlockManager2.default; /** * Button class * @type {Class.'); this.$el.append(this._$buttonOpenModalEditor); this._eventManager.emit('removeEditor', function () { _this2._$buttonOpenModalEditor.off('click'); _this2._$buttonOpenModalEditor = null; }); } }, { key: '_initDOMEvent', value: function _initDOMEvent() { var _this3 = this; this._$buttonOpenModalEditor.on('click', function () { return _this3._openPopupCodeBlockEditor(); }); } }, { key: '_openPopupCodeBlockEditor', value: function _openPopupCodeBlockEditor() { this._eventManager.emit('openPopupCodeBlockEditor', this.getAttachedElement()); } }, { key: '_updateLanguage', value: function _updateLanguage() { var attachedElement = this.getAttachedElement(); var language = attachedElement ? attachedElement.getAttribute('data-language') : null; this._$languageLabel.text(language ? language : 'text'); } /** * update gadget position * @memberof CodeBlockGadget * @protected * @override */ }, { key: 'syncLayout', value: function syncLayout() { var $attachedElement = (0, _jquery2.default)(this.getAttachedElement()); var offset = $attachedElement.offset(); offset.left = offset.left + ($attachedElement.outerWidth() - GADGET_WIDTH); this.$el.offset(offset); this.$el.height(GADGET_HEIGHT); this.$el.width(GADGET_WIDTH); } /** * on show * @memberof CodeBlockGadget * @protected * @override */ }, { key: 'onShow', value: function onShow() { var _this4 = this; _get(CodeBlockGadget.prototype.__proto__ || Object.getPrototypeOf(CodeBlockGadget.prototype), 'onShow', this).call(this); this._onAttachedElementChange = function () { return _this4._updateLanguage(); }; (0, _jquery2.default)(this.getAttachedElement()).on(EVENT_LANGUAGE_CHANGED, this._onAttachedElementChange); this._updateLanguage(); } /** * on hide * @memberof CodeBlockGadget * @protected * @override */ }, { key: 'onHide', value: function onHide() { (0, _jquery2.default)(this.getAttachedElement()).off(EVENT_LANGUAGE_CHANGED, this._onAttachedElementChange); _get(CodeBlockGadget.prototype.__proto__ || Object.getPrototypeOf(CodeBlockGadget.prototype), 'onHide', this).call(this); } }]); return CodeBlockGadget; }(_blockOverlay2.default); exports.default = CodeBlockGadget; /***/ }), /* 69 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview Implements UI block overlay * @author NHN Ent. FE Development Lab */ var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Class BlockOverlay */ var BlockOverlay = function () { /** * Creates an instance of BlockOverlay. * @param {Object} options - options * @param {EventManager} options.eventManager - event manager instance * @param {HTMLElement} options.container - container element * @param {string} options.attachedSelector - selector string to find attached element * @memberof BlockOverlay */ function BlockOverlay(_ref) { var eventManager = _ref.eventManager, container = _ref.container, attachedSelector = _ref.attachedSelector; _classCallCheck(this, BlockOverlay); this._eventManager = eventManager; this._attachedSelector = '[contenteditable=true] ' + attachedSelector; this._$container = (0, _jquery2.default)(container); this._$attachedElement = null; /** * is activated. * if this blockOverlay is active, It always be visible unconditionally. * @type {boolean} */ this.active = false; this._createElement(); this._initEvent(); } _createClass(BlockOverlay, [{ key: '_createElement', value: function _createElement() { this.$el = (0, _jquery2.default)('
'); this.$el.css({ position: 'absolute', display: 'none', 'z-index': 1 }); this._$container.append(this.$el); } }, { key: '_initEvent', value: function _initEvent() { var _this = this; this._eventManager.listen('change', this._onChange.bind(this)); this._eventManager.listen('mouseover', this._onMouseOver.bind(this)); this._eventManager.listen('focus', function () { _this.setVisibility(false); }); this._eventManager.listen('mousedown', function () { _this.setVisibility(false); }); } }, { key: '_onChange', value: function _onChange() { if (this._$attachedElement && _jquery2.default.contains(document, this._$attachedElement[0])) { this.syncLayout(); } else { this.setVisibility(false); } } }, { key: '_onMouseOver', value: function _onMouseOver(ev) { var originalEvent = ev.data; var $eventTarget = (0, _jquery2.default)(originalEvent.target); var $attachedElement = $eventTarget.closest(this._attachedSelector); if ($attachedElement.length) { this._$attachedElement = $attachedElement; this.setVisibility(true); } else if ($eventTarget.closest(this.$el).length) { this.setVisibility(true); } else if (!this.active) { this.setVisibility(false); } } /** * update blockOverlay position & size update to attached element * you may want to override this to adjust position & size * @memberof BlockOverlay * @protected */ }, { key: 'syncLayout', value: function syncLayout() { this.$el.offset(this._$attachedElement.offset()); this.$el.width(this._$attachedElement.outerWidth()); this.$el.height(this._$attachedElement.outerHeight()); } /** * attached element * @protected * @returns {HTMLElement} - attached element * @memberof BlockOverlay */ }, { key: 'getAttachedElement', value: function getAttachedElement() { return this._$attachedElement ? this._$attachedElement.get(0) : null; } /** * visibility * @protected * @returns {boolean} visibility * @memberof BlockOverlay */ }, { key: 'getVisibility', value: function getVisibility() { return this.$el.css('display') === 'block'; } /** * visibility * @param {boolean} visibility - is visible * @protected * @memberof BlockOverlay */ }, { key: 'setVisibility', value: function setVisibility(visibility) { if (visibility && this._$attachedElement) { if (!this.getVisibility()) { this.$el.css('display', 'block'); this.syncLayout(); this.onShow(); } } else if (!visibility) { if (this.getVisibility()) { this.$el.css('display', 'none'); this.onHide(); } } } /** * called on show. you may want to override to get the event * @memberof BlockOverlay * @protected * @abstract */ }, { key: 'onShow', value: function onShow() {} /** * called on hide. you may want to override to get the event * @memberof BlockOverlay * @protected */ }, { key: 'onHide', value: function onHide() { this.active = false; this._$attachedElement = null; } }]); return BlockOverlay; }(); exports.default = BlockOverlay; /***/ }), /* 70 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview editor layout * @author NHN Ent. FE Development Lab */ var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Editor container template * @type {string} * @ignore */ var containerTmpl = ['
', '
', '
', '
', '
', '
', '
', '
', '
', '
'].join(''); /** * Class Layout */ var Layout = function () { /** * Creates an instance of Layout. * @param {object} options - Option object * @param {EventManager} eventManager - Event manager instance * @memberof Layout */ function Layout(options, eventManager) { _classCallCheck(this, Layout); this.$el = (0, _jquery2.default)(options.el); this.height = options.height; this.type = options.initialEditType; this.eventManager = eventManager; this.init(); this._initEvent(); } /** * Initializer * @memberof Layout */ _createClass(Layout, [{ key: 'init', value: function init() { this._renderLayout(); this._initMarkdownAndPreviewSection(); this._initWysiwygSection(); } /** * Initialize show and hide event * @memberof Layout * @private */ }, { key: '_initEvent', value: function _initEvent() { this.eventManager.listen('hide', this.hide.bind(this)); this.eventManager.listen('show', this.show.bind(this)); } /** * Create editor container with template * @memberof Layout * @private */ }, { key: '_renderLayout', value: function _renderLayout() { this.$el.css('box-sizing', 'border-box'); this.$containerEl = (0, _jquery2.default)(containerTmpl).appendTo(this.$el); } /** * Switch editor mode to WYSIWYG * @memberof Layout */ }, { key: 'switchToWYSIWYG', value: function switchToWYSIWYG() { this.$containerEl.removeClass('te-md-mode'); this.$containerEl.addClass('te-ww-mode'); } /** * Switch editor mode to Markdown * @memberof Layout */ }, { key: 'switchToMarkdown', value: function switchToMarkdown() { this.$containerEl.removeClass('te-ww-mode'); this.$containerEl.addClass('te-md-mode'); } /** * Initialize editor to Markdown and set preview section * @memberof Layout * @private */ }, { key: '_initMarkdownAndPreviewSection', value: function _initMarkdownAndPreviewSection() { this.$mdEditorContainerEl = this.$containerEl.find('.te-md-container .te-editor'); this.$previewEl = this.$containerEl.find('.te-md-container .te-preview'); } /** * Initialize editor to WYSIWYG * @memberof Layout * @private */ }, { key: '_initWysiwygSection', value: function _initWysiwygSection() { this.$wwEditorContainerEl = this.$containerEl.find('.te-ww-container .te-editor'); } /** * Set preview to vertical split style * @memberof Layout * @private */ }, { key: '_verticalSplitStyle', value: function _verticalSplitStyle() { this.$containerEl.find('.te-md-container').removeClass('te-preview-style-tab'); this.$containerEl.find('.te-md-container').addClass('te-preview-style-vertical'); } /** * Set tab style preview mode * @memberof Layout * @private */ }, { key: '_tabStyle', value: function _tabStyle() { this.$containerEl.find('.te-md-container').removeClass('te-preview-style-vertical'); this.$containerEl.find('.te-md-container').addClass('te-preview-style-tab'); } /** * Toggle preview style between tab and vertical split * @memberof Layout * @param {string} style Preview style ('tab' or 'vertical') */ }, { key: 'changePreviewStyle', value: function changePreviewStyle(style) { if (style === 'tab') { this._tabStyle(); } else if (style === 'vertical') { this._verticalSplitStyle(); } } /** * Hide Editor * @memberof Layout */ }, { key: 'hide', value: function hide() { this.$el.find('.tui-editor').addClass('te-hide'); } /** * Show Editor * @memberof Layout */ }, { key: 'show', value: function show() { this.$el.find('.tui-editor').removeClass('te-hide'); } /** * Remove Editor * @memberof Layout */ }, { key: 'remove', value: function remove() { this.$el.find('.tui-editor').remove(); } /** * Get jQuery wrapped editor container element * @memberof Layout * @returns {jQuery} */ }, { key: 'getEditorEl', value: function getEditorEl() { return this.$containerEl; } /** * Get jQuery wrapped preview element * @memberof Layout * @returns {jQuery} */ }, { key: 'getPreviewEl', value: function getPreviewEl() { return this.$previewEl; } /** * Get jQuery wrapped Markdown editor element * @memberof Layout * @returns {jQuery} */ }, { key: 'getMdEditorContainerEl', value: function getMdEditorContainerEl() { return this.$mdEditorContainerEl; } /** * Get jQuery wrapped WYSIWYG editor element * @memberof Layout * @returns {jQuery} */ }, { key: 'getWwEditorContainerEl', value: function getWwEditorContainerEl() { return this.$wwEditorContainerEl; } }]); return Layout; }(); exports.default = Layout; /***/ }), /* 71 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview default UI * @author NHN Ent. FE Development Lab */ var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _defaultToolbar = __webpack_require__(72); var _defaultToolbar2 = _interopRequireDefault(_defaultToolbar); var _tab = __webpack_require__(43); var _tab2 = _interopRequireDefault(_tab); var _layerpopup = __webpack_require__(5); var _layerpopup2 = _interopRequireDefault(_layerpopup); var _modeSwitch = __webpack_require__(77); var _modeSwitch2 = _interopRequireDefault(_modeSwitch); var _popupAddLink = __webpack_require__(78); var _popupAddLink2 = _interopRequireDefault(_popupAddLink); var _popupAddImage = __webpack_require__(79); var _popupAddImage2 = _interopRequireDefault(_popupAddImage); var _popupTableUtils = __webpack_require__(80); var _popupTableUtils2 = _interopRequireDefault(_popupTableUtils); var _popupAddTable = __webpack_require__(81); var _popupAddTable2 = _interopRequireDefault(_popupAddTable); var _popupAddHeading = __webpack_require__(82); var _popupAddHeading2 = _interopRequireDefault(_popupAddHeading); var _popupCodeBlockLanguages = __webpack_require__(83); var _popupCodeBlockLanguages2 = _interopRequireDefault(_popupCodeBlockLanguages); var _popupCodeBlockEditor = __webpack_require__(84); var _popupCodeBlockEditor2 = _interopRequireDefault(_popupCodeBlockEditor); var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); var _tooltip = __webpack_require__(34); var _tooltip2 = _interopRequireDefault(_tooltip); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var CLASS_TOOLBAR = 'te-toolbar-section'; var CLASS_MARKDOWN_TAB = 'te-markdown-tab-section'; var CLASS_EDITOR = 'te-editor-section'; var CLASS_MODE_SWITCH = 'te-mode-switch-section'; var CONTAINER_TEMPLATE = '\n
\n
\n
\n
\n
\n'; /** * Class Default UI * initialize ui instances. toolbar, popups */ var DefaultUI = function () { /** * Creates an instance of DefaultUI. * @param {ToastUIEditor} editor - editor instance * @memberof DefaultUI */ /** * mode switch instance * @memberof DefaultUI * @private * @type {ModeSwitch} */ /** * markdown tab section jQuery element * @memberof DefaultUI * @private * @type {HTMLElement} */ /** * editor type ww/md * @memberof DefaultUI * @private * @type {string} */ /** * @memberof DefaultUI * @type {HTMLElement} * @private */ /** * DefaultToolbar wrapper element * @memberof DefaultUI * @type {jQuery} */ function DefaultUI(editor) { _classCallCheck(this, DefaultUI); Object.defineProperty(this, 'name', { enumerable: true, writable: true, value: 'default' }); Object.defineProperty(this, '_popups', { enumerable: true, writable: true, value: [] }); this._editor = editor; this._initialEditType = editor.options.initialEditType; this._init(editor.options); this._initEvent(); } /** * popup instances * @memberof DefaultUI * @private * @type {Array} */ /** * markdown tab * @memberof DefaultUI * @private * @type {Tab} */ /** * editor instance * @memberof DefaultUI * @private * @type {ToastUIEditor} */ /** * editor section element * @memberof DefaultUI * @private * @type {HTMLElement} */ /** * DefaultToolbar instance * @memberof DefaultUI * @type {DefaultToolbar} * @private */ /** * UI name * @memberof DefaultUI * @type {string} */ _createClass(DefaultUI, [{ key: '_init', value: function _init(_ref) { var container = _ref.el, toolbarItems = _ref.toolbarItems, hideModeSwitch = _ref.hideModeSwitch; this.$el = (0, _jquery2.default)(CONTAINER_TEMPLATE).appendTo(container); this._container = container; this._editorSection = this.$el.find('.' + CLASS_EDITOR).get(0); this._editorSection.appendChild(this._editor.layout.getEditorEl().get(0)); this._initToolbar(this._editor.eventManager, toolbarItems); this._initModeSwitch(hideModeSwitch); this._initPopupAddLink(); this._initPopupAddImage(); this._initPopupAddTable(); this._initPopupAddHeading(); this._initPopupTableUtils(); this._initPopupCodeBlockLanguages(); this._initPopupCodeBlockEditor(); this._initMarkdownTab(); } }, { key: '_initEvent', value: function _initEvent() { this._editor.eventManager.listen('hide', this.hide.bind(this)); this._editor.eventManager.listen('show', this.show.bind(this)); this._editor.eventManager.listen('changeMode', this._markdownTabControl.bind(this)); this._editor.eventManager.listen('changePreviewStyle', this._markdownTabControl.bind(this)); } }, { key: '_initToolbar', value: function _initToolbar(eventManager, toolbarItems) { var toolbar = new _defaultToolbar2.default(eventManager, toolbarItems); this._toolbar = toolbar; this.$el.find('.' + CLASS_TOOLBAR).append(toolbar.$el); } }, { key: '_initModeSwitch', value: function _initModeSwitch(hideModeSwitch) { var _this = this; var modeSwitchTabBar = this.$el.find('.' + CLASS_MODE_SWITCH); var editType = this._initialEditType === 'markdown' ? _modeSwitch2.default.TYPE.MARKDOWN : _modeSwitch2.default.TYPE.WYSIWYG; var modeSwitch = new _modeSwitch2.default(modeSwitchTabBar, editType); this._modeSwitch = modeSwitch; if (hideModeSwitch) { modeSwitch.hide(); } modeSwitch.on('modeSwitched', function (ev, type) { return _this._editor.changeMode(type); }); } }, { key: '_initMarkdownTab', value: function _initMarkdownTab() { var editor = this._editor; this._markdownTab = new _tab2.default({ initName: _i18n2.default.get('Write'), items: [_i18n2.default.get('Write'), _i18n2.default.get('Preview')], sections: [editor.layout.getMdEditorContainerEl(), editor.layout.getPreviewEl()] }); this._$markdownTabSection = this.$el.find('.' + CLASS_MARKDOWN_TAB); this._$markdownTabSection.append(this._markdownTab.$el); this._markdownTab.on('itemClick', function (ev, itemText) { if (itemText === _i18n2.default.get('Preview')) { editor.eventManager.emit('previewNeedsRefresh'); editor.eventManager.emit('changePreviewTabPreview'); editor.eventManager.emit('closeAllPopup'); } else { editor.getCodeMirror().focus(); editor.eventManager.emit('changePreviewTabWrite'); } }); } }, { key: '_markdownTabControl', value: function _markdownTabControl() { if (this._editor.isMarkdownMode() && this._editor.getCurrentPreviewStyle() === 'tab') { this._$markdownTabSection.show(); this._markdownTab.activate(_i18n2.default.get('Write')); } else { this._$markdownTabSection.hide(); } } }, { key: '_initPopupAddLink', value: function _initPopupAddLink() { this._popups.push(new _popupAddLink2.default({ $target: this.$el, editor: this._editor })); } }, { key: '_initPopupAddImage', value: function _initPopupAddImage() { this._popups.push(new _popupAddImage2.default({ $target: this.$el, eventManager: this._editor.eventManager })); } }, { key: '_initPopupAddTable', value: function _initPopupAddTable() { this._popups.push(new _popupAddTable2.default({ $target: this._toolbar.$el, eventManager: this._editor.eventManager, $button: this.$el.find('button.tui-table'), css: { 'position': 'absolute' } })); } }, { key: '_initPopupAddHeading', value: function _initPopupAddHeading() { this._popups.push(new _popupAddHeading2.default({ $target: this._toolbar.$el, eventManager: this._editor.eventManager, $button: this.$el.find('button.tui-heading'), css: { 'position': 'absolute' } })); } }, { key: '_initPopupTableUtils', value: function _initPopupTableUtils() { var _this2 = this; this._editor.eventManager.listen('contextmenu', function (ev) { if ((0, _jquery2.default)(ev.data.target).parents('[contenteditable=true] table').length > 0) { ev.data.preventDefault(); _this2._editor.eventManager.emit('openPopupTableUtils', ev.data); } }); this._popups.push(new _popupTableUtils2.default({ $target: this.$el, eventManager: this._editor.eventManager })); } }, { key: '_initPopupCodeBlockLanguages', value: function _initPopupCodeBlockLanguages() { var editor = this._editor; this._popups.push(new _popupCodeBlockLanguages2.default({ $target: this.$el, eventManager: editor.eventManager, languages: editor.options.codeBlockLanguages })); } }, { key: '_initPopupCodeBlockEditor', value: function _initPopupCodeBlockEditor() { this._popups.push(new _popupCodeBlockEditor2.default({ $target: this.$el, eventManager: this._editor.eventManager, convertor: this._editor.convertor })); } /** * get toolbar instance * @returns {Toolbar} - toolbar instance * @memberof DefaultUI */ }, { key: 'getToolbar', value: function getToolbar() { return this._toolbar; } /** * set toolbar instance * @param {Toolbar} toolbar - toolbar * @memberof DefaultUI */ }, { key: 'setToolbar', value: function setToolbar(toolbar) { this._toolbar.destroy(); this._toolbar = toolbar; } /** * get mode switch instance * @memberof DefaultUI * @returns {ModeSwitch} - mode switch instance */ }, { key: 'getModeSwitch', value: function getModeSwitch() { return this._modeSwitch; } /** * get editor section height * @returns {Number} - height of editor section * @memberof DefaultUI */ }, { key: 'getEditorSectionHeight', value: function getEditorSectionHeight() { var clientRect = this._editorSection.getBoundingClientRect(); return clientRect.bottom - clientRect.top; } /** * get editor height * @returns {Number} - height of editor * @memberof DefaultUI */ }, { key: 'getEditorHeight', value: function getEditorHeight() { var clientRect = this._container.getBoundingClientRect(); return clientRect.bottom - clientRect.top; } /** * get Table Popup * @returns {PopupTableUtils} - PopupTableUtils * @memberof DefaultUI */ }, { key: 'getPopupTableUtils', value: function getPopupTableUtils() { var tablePopup = void 0; this._popups.forEach(function (popup) { if (popup instanceof _popupTableUtils2.default) { tablePopup = popup; } }); return tablePopup; } /** * hide * @memberof DefaultUI */ }, { key: 'hide', value: function hide() { this.$el.addClass('te-hide'); } /** * show * @memberof DefaultUI */ }, { key: 'show', value: function show() { this.$el.removeClass('te-hide'); } /** * remove * @memberof DefaultUI */ }, { key: 'remove', value: function remove() { this.$el.remove(); this._markdownTab.remove(); this._modeSwitch.remove(); this._toolbar.destroy(); this._popups.forEach(function (popup) { return popup.remove(); }); this._popups = []; _tooltip2.default.hide(); } /** * creates popup * @param {LayerPopupOption} options - layerPopup options * @returns {LayerPopup} - crated layerPopup * @memberof DefaultUI */ }, { key: 'createPopup', value: function createPopup(options) { return new _layerpopup2.default(options); } }]); return DefaultUI; }(); exports.default = DefaultUI; /***/ }), /* 72 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; var _resizeObserverPolyfill = __webpack_require__(73); var _resizeObserverPolyfill2 = _interopRequireDefault(_resizeObserverPolyfill); var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); var _toolbar = __webpack_require__(40); var _toolbar2 = _interopRequireDefault(_toolbar); var _popupDropdownToolbar = __webpack_require__(76); var _popupDropdownToolbar2 = _interopRequireDefault(_popupDropdownToolbar); var _toolbarItemFactory = __webpack_require__(42); var _toolbarItemFactory2 = _interopRequireDefault(_toolbarItemFactory); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @fileoverview implements DefaultToolbar * @author NHN Ent. FE Development Lab */ var MORE_BUTTON_NAME = 'more'; /** * default toolbar * @extends Toolbar */ var DefaultToolbar = function (_Toolbar) { _inherits(DefaultToolbar, _Toolbar); /** * popup dropdown toolbar * @memberof DefaultToolbar * @private * @type {PopupDropdownToolbar} */ function DefaultToolbar(eventManager, options) { _classCallCheck(this, DefaultToolbar); var _this = _possibleConstructorReturn(this, (DefaultToolbar.__proto__ || Object.getPrototypeOf(DefaultToolbar)).call(this, eventManager, options)); _this._init(eventManager); _this._bindWidthChangedEvent(); return _this; } /** * insert toolbar item * @param {number} index - index at given item inserted * @param {ToolbarItem|string|object} item - toolbar item * @memberof Toolbar */ /** * resize observer * @memberof DefaultToolbar * @private * @type {ResizeObserver} */ /** * more button * @memberof DefaultToolbar * @private * @type {ToolbarButton} */ _createClass(DefaultToolbar, [{ key: 'insertItem', value: function insertItem(index, item) { _get(DefaultToolbar.prototype.__proto__ || Object.getPrototypeOf(DefaultToolbar.prototype), 'insertItem', this).call(this, index, item); this._arrangeMoreButton(); } }, { key: '_init', value: function _init(eventManager) { var moreButton = _toolbarItemFactory2.default.create('button', { name: MORE_BUTTON_NAME, className: 'tui-more', tooltip: _i18n2.default.get('More'), event: _popupDropdownToolbar2.default.OPEN_EVENT }); this._moreButton = moreButton; this._popupDropdownToolbar = new _popupDropdownToolbar2.default({ eventManager: eventManager, $target: this.$el, $button: moreButton.$el }); this.addItem(moreButton); } }, { key: '_bindWidthChangedEvent', value: function _bindWidthChangedEvent() { var _this2 = this; this._observer = new _resizeObserverPolyfill2.default(function () { _this2._popupDropdownToolbar.hide(); _this2._balanceButtons(); }); this._observer.observe(this.$el.get(0)); } }, { key: '_balanceButtons', value: function _balanceButtons() { var _this3 = this; var dropDownToolbarItems = this._popupDropdownToolbar.getItems(); dropDownToolbarItems.forEach(function (item) { _this3._popupDropdownToolbar.removeItem(item, false); var itemLength = _this3.getItems().length; _get(DefaultToolbar.prototype.__proto__ || Object.getPrototypeOf(DefaultToolbar.prototype), 'insertItem', _this3).call(_this3, itemLength, item); }); this.removeItem(this._moreButton, false); _get(DefaultToolbar.prototype.__proto__ || Object.getPrototypeOf(DefaultToolbar.prototype), 'insertItem', this).call(this, 0, this._moreButton); var toolbarHeight = this.$el.height(); var defaultToolbarItems = this.getItems(); var overflowItems = defaultToolbarItems.filter(function (item) { return item.$el.position().top > toolbarHeight; }); overflowItems.forEach(function (item) { _this3.removeItem(item, false); _this3._popupDropdownToolbar.addItem(item); }); this._arrangeMoreButton(); } }, { key: '_arrangeMoreButton', value: function _arrangeMoreButton() { if (!this._popupDropdownToolbar) { return; } this.removeItem(this._moreButton, false); var hasOverflow = this._popupDropdownToolbar.getItems().length > 0; var itemLength = this.getItems().length; if (hasOverflow) { _get(DefaultToolbar.prototype.__proto__ || Object.getPrototypeOf(DefaultToolbar.prototype), 'insertItem', this).call(this, itemLength, this._moreButton); } } /** * destroy * @override */ }, { key: 'destroy', value: function destroy() { if (this._observer) { this._observer.disconnect(); this._observer = null; } } }]); return DefaultToolbar; }(_toolbar2.default); exports.default = DefaultToolbar; /***/ }), /* 73 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* WEBPACK VAR INJECTION */(function(global) {/** * A collection of shims that provide minimal functionality of the ES6 collections. * * These implementations are not meant to be used outside of the ResizeObserver * modules as they cover only a limited range of use cases. */ /* eslint-disable require-jsdoc, valid-jsdoc */ var MapShim = (function () { if (typeof Map !== 'undefined') { return Map; } /** * Returns index in provided array that matches the specified key. * * @param {Array} arr * @param {*} key * @returns {number} */ function getIndex(arr, key) { var result = -1; arr.some(function (entry, index) { if (entry[0] === key) { result = index; return true; } return false; }); return result; } return (function () { function anonymous() { this.__entries__ = []; } var prototypeAccessors = { size: { configurable: true } }; /** * @returns {boolean} */ prototypeAccessors.size.get = function () { return this.__entries__.length; }; /** * @param {*} key * @returns {*} */ anonymous.prototype.get = function (key) { var index = getIndex(this.__entries__, key); var entry = this.__entries__[index]; return entry && entry[1]; }; /** * @param {*} key * @param {*} value * @returns {void} */ anonymous.prototype.set = function (key, value) { var index = getIndex(this.__entries__, key); if (~index) { this.__entries__[index][1] = value; } else { this.__entries__.push([key, value]); } }; /** * @param {*} key * @returns {void} */ anonymous.prototype.delete = function (key) { var entries = this.__entries__; var index = getIndex(entries, key); if (~index) { entries.splice(index, 1); } }; /** * @param {*} key * @returns {void} */ anonymous.prototype.has = function (key) { return !!~getIndex(this.__entries__, key); }; /** * @returns {void} */ anonymous.prototype.clear = function () { this.__entries__.splice(0); }; /** * @param {Function} callback * @param {*} [ctx=null] * @returns {void} */ anonymous.prototype.forEach = function (callback, ctx) { var this$1 = this; if ( ctx === void 0 ) ctx = null; for (var i = 0, list = this$1.__entries__; i < list.length; i += 1) { var entry = list[i]; callback.call(ctx, entry[1], entry[0]); } }; Object.defineProperties( anonymous.prototype, prototypeAccessors ); return anonymous; }()); })(); /** * Detects whether window and document objects are available in current environment. */ var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && window.document === document; // Returns global object of a current environment. var global$1 = (function () { if (typeof global !== 'undefined' && global.Math === Math) { return global; } if (typeof self !== 'undefined' && self.Math === Math) { return self; } if (typeof window !== 'undefined' && window.Math === Math) { return window; } // eslint-disable-next-line no-new-func return Function('return this')(); })(); /** * A shim for the requestAnimationFrame which falls back to the setTimeout if * first one is not supported. * * @returns {number} Requests' identifier. */ var requestAnimationFrame$1 = (function () { if (typeof requestAnimationFrame === 'function') { // It's required to use a bounded function because IE sometimes throws // an "Invalid calling object" error if rAF is invoked without the global // object on the left hand side. return requestAnimationFrame.bind(global$1); } return function (callback) { return setTimeout(function () { return callback(Date.now()); }, 1000 / 60); }; })(); // Defines minimum timeout before adding a trailing call. var trailingTimeout = 2; /** * Creates a wrapper function which ensures that provided callback will be * invoked only once during the specified delay period. * * @param {Function} callback - Function to be invoked after the delay period. * @param {number} delay - Delay after which to invoke callback. * @returns {Function} */ var throttle = function (callback, delay) { var leadingCall = false, trailingCall = false, lastCallTime = 0; /** * Invokes the original callback function and schedules new invocation if * the "proxy" was called during current request. * * @returns {void} */ function resolvePending() { if (leadingCall) { leadingCall = false; callback(); } if (trailingCall) { proxy(); } } /** * Callback invoked after the specified delay. It will further postpone * invocation of the original function delegating it to the * requestAnimationFrame. * * @returns {void} */ function timeoutCallback() { requestAnimationFrame$1(resolvePending); } /** * Schedules invocation of the original function. * * @returns {void} */ function proxy() { var timeStamp = Date.now(); if (leadingCall) { // Reject immediately following calls. if (timeStamp - lastCallTime < trailingTimeout) { return; } // Schedule new call to be in invoked when the pending one is resolved. // This is important for "transitions" which never actually start // immediately so there is a chance that we might miss one if change // happens amids the pending invocation. trailingCall = true; } else { leadingCall = true; trailingCall = false; setTimeout(timeoutCallback, delay); } lastCallTime = timeStamp; } return proxy; }; // Minimum delay before invoking the update of observers. var REFRESH_DELAY = 20; // A list of substrings of CSS properties used to find transition events that // might affect dimensions of observed elements. var transitionKeys = ['top', 'right', 'bottom', 'left', 'width', 'height', 'size', 'weight']; // Check if MutationObserver is available. var mutationObserverSupported = typeof MutationObserver !== 'undefined'; /** * Singleton controller class which handles updates of ResizeObserver instances. */ var ResizeObserverController = function() { this.connected_ = false; this.mutationEventsAdded_ = false; this.mutationsObserver_ = null; this.observers_ = []; this.onTransitionEnd_ = this.onTransitionEnd_.bind(this); this.refresh = throttle(this.refresh.bind(this), REFRESH_DELAY); }; /** * Adds observer to observers list. * * @param {ResizeObserverSPI} observer - Observer to be added. * @returns {void} */ /** * Holds reference to the controller's instance. * * @private {ResizeObserverController} */ /** * Keeps reference to the instance of MutationObserver. * * @private {MutationObserver} */ /** * Indicates whether DOM listeners have been added. * * @private {boolean} */ ResizeObserverController.prototype.addObserver = function (observer) { if (!~this.observers_.indexOf(observer)) { this.observers_.push(observer); } // Add listeners if they haven't been added yet. if (!this.connected_) { this.connect_(); } }; /** * Removes observer from observers list. * * @param {ResizeObserverSPI} observer - Observer to be removed. * @returns {void} */ ResizeObserverController.prototype.removeObserver = function (observer) { var observers = this.observers_; var index = observers.indexOf(observer); // Remove observer if it's present in registry. if (~index) { observers.splice(index, 1); } // Remove listeners if controller has no connected observers. if (!observers.length && this.connected_) { this.disconnect_(); } }; /** * Invokes the update of observers. It will continue running updates insofar * it detects changes. * * @returns {void} */ ResizeObserverController.prototype.refresh = function () { var changesDetected = this.updateObservers_(); // Continue running updates if changes have been detected as there might // be future ones caused by CSS transitions. if (changesDetected) { this.refresh(); } }; /** * Updates every observer from observers list and notifies them of queued * entries. * * @private * @returns {boolean} Returns "true" if any observer has detected changes in * dimensions of it's elements. */ ResizeObserverController.prototype.updateObservers_ = function () { // Collect observers that have active observations. var activeObservers = this.observers_.filter(function (observer) { return observer.gatherActive(), observer.hasActive(); }); // Deliver notifications in a separate cycle in order to avoid any // collisions between observers, e.g. when multiple instances of // ResizeObserver are tracking the same element and the callback of one // of them changes content dimensions of the observed target. Sometimes // this may result in notifications being blocked for the rest of observers. activeObservers.forEach(function (observer) { return observer.broadcastActive(); }); return activeObservers.length > 0; }; /** * Initializes DOM listeners. * * @private * @returns {void} */ ResizeObserverController.prototype.connect_ = function () { // Do nothing if running in a non-browser environment or if listeners // have been already added. if (!isBrowser || this.connected_) { return; } // Subscription to the "Transitionend" event is used as a workaround for // delayed transitions. This way it's possible to capture at least the // final state of an element. document.addEventListener('transitionend', this.onTransitionEnd_); window.addEventListener('resize', this.refresh); if (mutationObserverSupported) { this.mutationsObserver_ = new MutationObserver(this.refresh); this.mutationsObserver_.observe(document, { attributes: true, childList: true, characterData: true, subtree: true }); } else { document.addEventListener('DOMSubtreeModified', this.refresh); this.mutationEventsAdded_ = true; } this.connected_ = true; }; /** * Removes DOM listeners. * * @private * @returns {void} */ ResizeObserverController.prototype.disconnect_ = function () { // Do nothing if running in a non-browser environment or if listeners // have been already removed. if (!isBrowser || !this.connected_) { return; } document.removeEventListener('transitionend', this.onTransitionEnd_); window.removeEventListener('resize', this.refresh); if (this.mutationsObserver_) { this.mutationsObserver_.disconnect(); } if (this.mutationEventsAdded_) { document.removeEventListener('DOMSubtreeModified', this.refresh); } this.mutationsObserver_ = null; this.mutationEventsAdded_ = false; this.connected_ = false; }; /** * "Transitionend" event handler. * * @private * @param {TransitionEvent} event * @returns {void} */ ResizeObserverController.prototype.onTransitionEnd_ = function (ref) { var propertyName = ref.propertyName; if ( propertyName === void 0 ) propertyName = ''; // Detect whether transition may affect dimensions of an element. var isReflowProperty = transitionKeys.some(function (key) { return !!~propertyName.indexOf(key); }); if (isReflowProperty) { this.refresh(); } }; /** * Returns instance of the ResizeObserverController. * * @returns {ResizeObserverController} */ ResizeObserverController.getInstance = function () { if (!this.instance_) { this.instance_ = new ResizeObserverController(); } return this.instance_; }; ResizeObserverController.instance_ = null; /** * Defines non-writable/enumerable properties of the provided target object. * * @param {Object} target - Object for which to define properties. * @param {Object} props - Properties to be defined. * @returns {Object} Target object. */ var defineConfigurable = (function (target, props) { for (var i = 0, list = Object.keys(props); i < list.length; i += 1) { var key = list[i]; Object.defineProperty(target, key, { value: props[key], enumerable: false, writable: false, configurable: true }); } return target; }); /** * Returns the global object associated with provided element. * * @param {Object} target * @returns {Object} */ var getWindowOf = (function (target) { // Assume that the element is an instance of Node, which means that it // has the "ownerDocument" property from which we can retrieve a // corresponding global object. var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView; // Return the local global object if it's not possible extract one from // provided element. return ownerGlobal || global$1; }); // Placeholder of an empty content rectangle. var emptyRect = createRectInit(0, 0, 0, 0); /** * Converts provided string to a number. * * @param {number|string} value * @returns {number} */ function toFloat(value) { return parseFloat(value) || 0; } /** * Extracts borders size from provided styles. * * @param {CSSStyleDeclaration} styles * @param {...string} positions - Borders positions (top, right, ...) * @returns {number} */ function getBordersSize(styles) { var positions = [], len = arguments.length - 1; while ( len-- > 0 ) positions[ len ] = arguments[ len + 1 ]; return positions.reduce(function (size, position) { var value = styles['border-' + position + '-width']; return size + toFloat(value); }, 0); } /** * Extracts paddings sizes from provided styles. * * @param {CSSStyleDeclaration} styles * @returns {Object} Paddings box. */ function getPaddings(styles) { var positions = ['top', 'right', 'bottom', 'left']; var paddings = {}; for (var i = 0, list = positions; i < list.length; i += 1) { var position = list[i]; var value = styles['padding-' + position]; paddings[position] = toFloat(value); } return paddings; } /** * Calculates content rectangle of provided SVG element. * * @param {SVGGraphicsElement} target - Element content rectangle of which needs * to be calculated. * @returns {DOMRectInit} */ function getSVGContentRect(target) { var bbox = target.getBBox(); return createRectInit(0, 0, bbox.width, bbox.height); } /** * Calculates content rectangle of provided HTMLElement. * * @param {HTMLElement} target - Element for which to calculate the content rectangle. * @returns {DOMRectInit} */ function getHTMLElementContentRect(target) { // Client width & height properties can't be // used exclusively as they provide rounded values. var clientWidth = target.clientWidth; var clientHeight = target.clientHeight; // By this condition we can catch all non-replaced inline, hidden and // detached elements. Though elements with width & height properties less // than 0.5 will be discarded as well. // // Without it we would need to implement separate methods for each of // those cases and it's not possible to perform a precise and performance // effective test for hidden elements. E.g. even jQuery's ':visible' filter // gives wrong results for elements with width & height less than 0.5. if (!clientWidth && !clientHeight) { return emptyRect; } var styles = getWindowOf(target).getComputedStyle(target); var paddings = getPaddings(styles); var horizPad = paddings.left + paddings.right; var vertPad = paddings.top + paddings.bottom; // Computed styles of width & height are being used because they are the // only dimensions available to JS that contain non-rounded values. It could // be possible to utilize the getBoundingClientRect if only it's data wasn't // affected by CSS transformations let alone paddings, borders and scroll bars. var width = toFloat(styles.width), height = toFloat(styles.height); // Width & height include paddings and borders when the 'border-box' box // model is applied (except for IE). if (styles.boxSizing === 'border-box') { // Following conditions are required to handle Internet Explorer which // doesn't include paddings and borders to computed CSS dimensions. // // We can say that if CSS dimensions + paddings are equal to the "client" // properties then it's either IE, and thus we don't need to subtract // anything, or an element merely doesn't have paddings/borders styles. if (Math.round(width + horizPad) !== clientWidth) { width -= getBordersSize(styles, 'left', 'right') + horizPad; } if (Math.round(height + vertPad) !== clientHeight) { height -= getBordersSize(styles, 'top', 'bottom') + vertPad; } } // Following steps can't be applied to the document's root element as its // client[Width/Height] properties represent viewport area of the window. // Besides, it's as well not necessary as the itself neither has // rendered scroll bars nor it can be clipped. if (!isDocumentElement(target)) { // In some browsers (only in Firefox, actually) CSS width & height // include scroll bars size which can be removed at this step as scroll // bars are the only difference between rounded dimensions + paddings // and "client" properties, though that is not always true in Chrome. var vertScrollbar = Math.round(width + horizPad) - clientWidth; var horizScrollbar = Math.round(height + vertPad) - clientHeight; // Chrome has a rather weird rounding of "client" properties. // E.g. for an element with content width of 314.2px it sometimes gives // the client width of 315px and for the width of 314.7px it may give // 314px. And it doesn't happen all the time. So just ignore this delta // as a non-relevant. if (Math.abs(vertScrollbar) !== 1) { width -= vertScrollbar; } if (Math.abs(horizScrollbar) !== 1) { height -= horizScrollbar; } } return createRectInit(paddings.left, paddings.top, width, height); } /** * Checks whether provided element is an instance of the SVGGraphicsElement. * * @param {Element} target - Element to be checked. * @returns {boolean} */ var isSVGGraphicsElement = (function () { // Some browsers, namely IE and Edge, don't have the SVGGraphicsElement // interface. if (typeof SVGGraphicsElement !== 'undefined') { return function (target) { return target instanceof getWindowOf(target).SVGGraphicsElement; }; } // If it's so, then check that element is at least an instance of the // SVGElement and that it has the "getBBox" method. // eslint-disable-next-line no-extra-parens return function (target) { return target instanceof getWindowOf(target).SVGElement && typeof target.getBBox === 'function'; }; })(); /** * Checks whether provided element is a document element (). * * @param {Element} target - Element to be checked. * @returns {boolean} */ function isDocumentElement(target) { return target === getWindowOf(target).document.documentElement; } /** * Calculates an appropriate content rectangle for provided html or svg element. * * @param {Element} target - Element content rectangle of which needs to be calculated. * @returns {DOMRectInit} */ function getContentRect(target) { if (!isBrowser) { return emptyRect; } if (isSVGGraphicsElement(target)) { return getSVGContentRect(target); } return getHTMLElementContentRect(target); } /** * Creates rectangle with an interface of the DOMRectReadOnly. * Spec: https://drafts.fxtf.org/geometry/#domrectreadonly * * @param {DOMRectInit} rectInit - Object with rectangle's x/y coordinates and dimensions. * @returns {DOMRectReadOnly} */ function createReadOnlyRect(ref) { var x = ref.x; var y = ref.y; var width = ref.width; var height = ref.height; // If DOMRectReadOnly is available use it as a prototype for the rectangle. var Constr = typeof DOMRectReadOnly !== 'undefined' ? DOMRectReadOnly : Object; var rect = Object.create(Constr.prototype); // Rectangle's properties are not writable and non-enumerable. defineConfigurable(rect, { x: x, y: y, width: width, height: height, top: y, right: x + width, bottom: height + y, left: x }); return rect; } /** * Creates DOMRectInit object based on the provided dimensions and the x/y coordinates. * Spec: https://drafts.fxtf.org/geometry/#dictdef-domrectinit * * @param {number} x - X coordinate. * @param {number} y - Y coordinate. * @param {number} width - Rectangle's width. * @param {number} height - Rectangle's height. * @returns {DOMRectInit} */ function createRectInit(x, y, width, height) { return { x: x, y: y, width: width, height: height }; } /** * Class that is responsible for computations of the content rectangle of * provided DOM element and for keeping track of it's changes. */ var ResizeObservation = function(target) { this.broadcastWidth = 0; this.broadcastHeight = 0; this.contentRect_ = createRectInit(0, 0, 0, 0); this.target = target; }; /** * Updates content rectangle and tells whether it's width or height properties * have changed since the last broadcast. * * @returns {boolean} */ /** * Reference to the last observed content rectangle. * * @private {DOMRectInit} */ /** * Broadcasted width of content rectangle. * * @type {number} */ ResizeObservation.prototype.isActive = function () { var rect = getContentRect(this.target); this.contentRect_ = rect; return rect.width !== this.broadcastWidth || rect.height !== this.broadcastHeight; }; /** * Updates 'broadcastWidth' and 'broadcastHeight' properties with a data * from the corresponding properties of the last observed content rectangle. * * @returns {DOMRectInit} Last observed content rectangle. */ ResizeObservation.prototype.broadcastRect = function () { var rect = this.contentRect_; this.broadcastWidth = rect.width; this.broadcastHeight = rect.height; return rect; }; var ResizeObserverEntry = function(target, rectInit) { var contentRect = createReadOnlyRect(rectInit); // According to the specification following properties are not writable // and are also not enumerable in the native implementation. // // Property accessors are not being used as they'd require to define a // private WeakMap storage which may cause memory leaks in browsers that // don't support this type of collections. defineConfigurable(this, { target: target, contentRect: contentRect }); }; var ResizeObserverSPI = function(callback, controller, callbackCtx) { this.activeObservations_ = []; this.observations_ = new MapShim(); if (typeof callback !== 'function') { throw new TypeError('The callback provided as parameter 1 is not a function.'); } this.callback_ = callback; this.controller_ = controller; this.callbackCtx_ = callbackCtx; }; /** * Starts observing provided element. * * @param {Element} target - Element to be observed. * @returns {void} */ /** * Registry of the ResizeObservation instances. * * @private {Map} */ /** * Public ResizeObserver instance which will be passed to the callback * function and used as a value of it's "this" binding. * * @private {ResizeObserver} */ /** * Collection of resize observations that have detected changes in dimensions * of elements. * * @private {Array} */ ResizeObserverSPI.prototype.observe = function (target) { if (!arguments.length) { throw new TypeError('1 argument required, but only 0 present.'); } // Do nothing if current environment doesn't have the Element interface. if (typeof Element === 'undefined' || !(Element instanceof Object)) { return; } if (!(target instanceof getWindowOf(target).Element)) { throw new TypeError('parameter 1 is not of type "Element".'); } var observations = this.observations_; // Do nothing if element is already being observed. if (observations.has(target)) { return; } observations.set(target, new ResizeObservation(target)); this.controller_.addObserver(this); // Force the update of observations. this.controller_.refresh(); }; /** * Stops observing provided element. * * @param {Element} target - Element to stop observing. * @returns {void} */ ResizeObserverSPI.prototype.unobserve = function (target) { if (!arguments.length) { throw new TypeError('1 argument required, but only 0 present.'); } // Do nothing if current environment doesn't have the Element interface. if (typeof Element === 'undefined' || !(Element instanceof Object)) { return; } if (!(target instanceof getWindowOf(target).Element)) { throw new TypeError('parameter 1 is not of type "Element".'); } var observations = this.observations_; // Do nothing if element is not being observed. if (!observations.has(target)) { return; } observations.delete(target); if (!observations.size) { this.controller_.removeObserver(this); } }; /** * Stops observing all elements. * * @returns {void} */ ResizeObserverSPI.prototype.disconnect = function () { this.clearActive(); this.observations_.clear(); this.controller_.removeObserver(this); }; /** * Collects observation instances the associated element of which has changed * it's content rectangle. * * @returns {void} */ ResizeObserverSPI.prototype.gatherActive = function () { var this$1 = this; this.clearActive(); this.observations_.forEach(function (observation) { if (observation.isActive()) { this$1.activeObservations_.push(observation); } }); }; /** * Invokes initial callback function with a list of ResizeObserverEntry * instances collected from active resize observations. * * @returns {void} */ ResizeObserverSPI.prototype.broadcastActive = function () { // Do nothing if observer doesn't have active observations. if (!this.hasActive()) { return; } var ctx = this.callbackCtx_; // Create ResizeObserverEntry instance for every active observation. var entries = this.activeObservations_.map(function (observation) { return new ResizeObserverEntry(observation.target, observation.broadcastRect()); }); this.callback_.call(ctx, entries, ctx); this.clearActive(); }; /** * Clears the collection of active observations. * * @returns {void} */ ResizeObserverSPI.prototype.clearActive = function () { this.activeObservations_.splice(0); }; /** * Tells whether observer has active observations. * * @returns {boolean} */ ResizeObserverSPI.prototype.hasActive = function () { return this.activeObservations_.length > 0; }; // Registry of internal observers. If WeakMap is not available use current shim // for the Map collection as it has all required methods and because WeakMap // can't be fully polyfilled anyway. var observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim(); /** * ResizeObserver API. Encapsulates the ResizeObserver SPI implementation * exposing only those methods and properties that are defined in the spec. */ var ResizeObserver = function(callback) { if (!(this instanceof ResizeObserver)) { throw new TypeError('Cannot call a class as a function.'); } if (!arguments.length) { throw new TypeError('1 argument required, but only 0 present.'); } var controller = ResizeObserverController.getInstance(); var observer = new ResizeObserverSPI(callback, controller, this); observers.set(this, observer); }; // Expose public methods of ResizeObserver. ['observe', 'unobserve', 'disconnect'].forEach(function (method) { ResizeObserver.prototype[method] = function () { return (ref = observers.get(this))[method].apply(ref, arguments); var ref; }; }); var index = (function () { // Export existing implementation if available. if (typeof global$1.ResizeObserver !== 'undefined') { return global$1.ResizeObserver; } return ResizeObserver; })(); /* harmony default export */ __webpack_exports__["default"] = (index); /* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(74))) /***/ }), /* 74 */ /***/ (function(module, exports) { var g; // This works in non-strict mode g = (function() { return this; })(); try { // This works if eval is allowed (see CSP) g = g || Function("return this")() || (1,eval)("this"); } catch(e) { // This works if the window reference is available if(typeof window === "object") g = window; } // g can still be undefined, but nothing to do about it... // We return undefined, instead of nothing here, so it's // easier to handle this case. if(!global) { ...} module.exports = g; /***/ }), /* 75 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _button = __webpack_require__(18); var _button2 = _interopRequireDefault(_button); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @fileoverview Implements UI Button * @author NHN Ent. FE Development Lab */ /** * Toolbar Button UI * @extends {ToolbarItem} */ var ToolbarButton = function (_Button) { _inherits(ToolbarButton, _Button); function ToolbarButton() { _classCallCheck(this, ToolbarButton); return _possibleConstructorReturn(this, (ToolbarButton.__proto__ || Object.getPrototypeOf(ToolbarButton)).apply(this, arguments)); } return ToolbarButton; }(_button2.default); exports.default = ToolbarButton; /***/ }), /* 76 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _layerpopup = __webpack_require__(5); var _layerpopup2 = _interopRequireDefault(_layerpopup); var _toolbar = __webpack_require__(40); var _toolbar2 = _interopRequireDefault(_toolbar); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @fileoverview implements DefaultToolbar * @author NHN Ent. FE Development Lab */ var PopupDropdownToolbar = function (_LayerPopup) { _inherits(PopupDropdownToolbar, _LayerPopup); /** * constructor * @param {object} options - popup options */ function PopupDropdownToolbar(options) { _classCallCheck(this, PopupDropdownToolbar); options = _tuiCodeSnippet2.default.extend({ header: false, className: 'te-dropdown-toolbar' }, options); return _possibleConstructorReturn(this, (PopupDropdownToolbar.__proto__ || Object.getPrototypeOf(PopupDropdownToolbar)).call(this, options)); } /** * get toolbar instance it contains * @returns {Toolbar} - toolbar instance */ /** * open event string * @memberof PopupDropdownToolbar * @static * @type {ToolbarButton} */ _createClass(PopupDropdownToolbar, [{ key: 'getToolbar', value: function getToolbar() { return this._toolbar; } /** * get toolbar items * @returns {ToolbarItem[]} - toolbar items * @memberof PopupDropdownToolbar */ }, { key: 'getItems', value: function getItems() { return this.getToolbar().getItems(); } /** * get toolbar item at given index * @param {number} index - item index * @returns {ToolbarItem} - toolbar item at the index * @memberof PopupDropdownToolbar */ }, { key: 'getItem', value: function getItem(index) { return this.getToolbar().getItem(index); } /** * set toolbar items * @param {ToolbarItem[]} items - toolbar items * @memberof PopupDropdownToolbar */ }, { key: 'setItems', value: function setItems(items) { this.getToolbar().setItems(items); } /** * add toolbar item * @param {ToolbarItem|string|object} item - toolbar item * @memberof PopupDropdownToolbar */ }, { key: 'addItem', value: function addItem(item) { this.getToolbar().addItem(item); } /** * insert toolbar item * @param {number} index - index at given item inserted * @param {ToolbarItem|string|object} item - toolbar item * @memberof PopupDropdownToolbar */ }, { key: 'insertItem', value: function insertItem(index, item) { this.getToolbar().insertItem(index, item); } /** * get index of given item * @param {ToolbarItem} item - toolbar item * @returns {number} - index of given toolbar item * @memberof PopupDropdownToolbar */ }, { key: 'indexOfItem', value: function indexOfItem(item) { return this.getToolbar().indexOfItem(item); } /** * remove an item * @param {number} index - item index to remove * @param {boolean} destroy - destroy item or not * @returns {ToolbarItem} - removed item * @memberof PopupDropdownToolbar */ }, { key: 'removeItem', value: function removeItem(index, destroy) { return this.getToolbar().removeItem(index, destroy); } /** * remove all toolbar items * @memberof PopupDropdownToolbar */ }, { key: 'removeAllItems', value: function removeAllItems() { this.getToolbar().removeAllItems(); } /** * init instance. * store properties & prepare before initialize DOM * @param {LayerPopupOption} options - layer popup options * @memberof PopupDropdownToolbar * @protected * @override */ }, { key: '_initInstance', value: function _initInstance(options) { _get(PopupDropdownToolbar.prototype.__proto__ || Object.getPrototypeOf(PopupDropdownToolbar.prototype), '_initInstance', this).call(this, options); var $button = options.$button, eventManager = options.eventManager; this._$button = $button; this._eventManager = eventManager; this._toolbar = new _toolbar2.default(eventManager); } /** * initialize DOM, render popup * @memberof PopupDropdownToolbar * @protected */ }, { key: '_initDOM', value: function _initDOM() { _get(PopupDropdownToolbar.prototype.__proto__ || Object.getPrototypeOf(PopupDropdownToolbar.prototype), '_initDOM', this).call(this); this.setContent(this._toolbar.$el); } /** * bind editor events * @memberof PopupDropdownToolbar * @protected */ }, { key: '_initEditorEvent', value: function _initEditorEvent() { var _this2 = this; _get(PopupDropdownToolbar.prototype.__proto__ || Object.getPrototypeOf(PopupDropdownToolbar.prototype), '_initEditorEvent', this).call(this); this._eventManager.listen('focus', function () { return _this2.hide(); }); this._eventManager.listen('closeAllPopup', function () { return _this2.hide(); }); this._eventManager.listen(PopupDropdownToolbar.OPEN_EVENT, function () { var isShown = _this2.isShow(); _this2._eventManager.emit('closeAllPopup'); if (!isShown) { _this2.show(); } // to give toolbar element enough width before the calculation _this2.$el.css({ left: '-1000px' }); var $button = _this2._$button; var position = $button.position(); var buttonOuterHeightWithMargin = $button.outerHeight(true); var buttonMarginBottom = (buttonOuterHeightWithMargin - $button.outerHeight()) / 2; var top = position.top + buttonOuterHeightWithMargin - buttonMarginBottom; var left = position.left + $button.outerWidth(true) - _this2.$el.outerWidth(true); _this2.$el.css({ top: top, left: left }); }); } }]); return PopupDropdownToolbar; }(_layerpopup2.default); Object.defineProperty(PopupDropdownToolbar, 'OPEN_EVENT', { enumerable: true, writable: true, value: 'openDropdownToolbar' }); exports.default = PopupDropdownToolbar; /***/ }), /* 77 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _uicontroller = __webpack_require__(8); var _uicontroller2 = _interopRequireDefault(_uicontroller); var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @fileoverview Implements ui mode switch * @author NHN Ent. FE Development Lab */ var MARKDOWN = 'markdown'; var WYSIWYG = 'wysiwyg'; /** * Class ModeSwitch * UI Control for switch between Markdown and WYSIWYG * @extends {UIController} */ var ModeSwitch = function (_UIController) { _inherits(ModeSwitch, _UIController); /** * Creates an instance of ModeSwitch. * @param {jQuery} $rootElement - root jquery element * @param {string} initialType - initial type of editor * @memberof ModeSwitch */ /** * current mode * @memberof ModeSwitch * @type {String} * @private */ /** * mode switch type * @memberof ModeSwitch * @property {string} MARKDOWN - Markdown * @property {string} WYSIWYG - WYSIWYG * @static */ function ModeSwitch($rootElement, initialType) { _classCallCheck(this, ModeSwitch); var _this = _possibleConstructorReturn(this, (ModeSwitch.__proto__ || Object.getPrototypeOf(ModeSwitch)).call(this, { tagName: 'div', className: 'te-mode-switch' })); Object.defineProperty(_this, '_buttons', { enumerable: true, writable: true, value: {} }); _this._render($rootElement); _this._switchType(_tuiCodeSnippet2.default.isExisty(initialType) ? initialType : MARKDOWN); return _this; } /** * is the switch tab bar shown * @returns {Boolean} - showing status */ /** * root element * @type {jQuery} */ /** * mode switch buttons * @memberof ModeSwitch * @type {Object} * @private */ _createClass(ModeSwitch, [{ key: 'isShown', value: function isShown() { return this._$rootElement.css('display') === 'block'; } /** * show switch tab bar * @memberof ModeSwitch */ }, { key: 'show', value: function show() { this._$rootElement.css('display', 'block'); } /** * hide switch tab bar * @memberof ModeSwitch */ }, { key: 'hide', value: function hide() { this._$rootElement.css('display', 'none'); } }, { key: '_render', value: function _render($rootElement) { this._buttons.$markdown = (0, _jquery2.default)(''); this._buttons.$wysiwyg = (0, _jquery2.default)(''); this.$el.append(this._buttons.$markdown); this.$el.append(this._buttons.$wysiwyg); if ($rootElement) { $rootElement.append(this.$el); this._$rootElement = $rootElement; } this.on('click .markdown', this._changeMarkdown.bind(this)); this.on('click .wysiwyg', this._changeWysiwyg.bind(this)); this.show(); } }, { key: '_changeMarkdown', value: function _changeMarkdown() { this._switchType(MARKDOWN); } }, { key: '_changeWysiwyg', value: function _changeWysiwyg() { this._switchType(WYSIWYG); } }, { key: '_setActiveButton', value: function _setActiveButton(type) { this._buttons.$markdown.removeClass('active'); this._buttons.$wysiwyg.removeClass('active'); this._buttons['$' + type].addClass('active'); } }, { key: '_switchType', value: function _switchType(type) { if (this._type === type) { return; } this._type = type; this._setActiveButton(type); this.trigger('modeSwitched', this._type); } }]); return ModeSwitch; }(_uicontroller2.default); Object.defineProperty(ModeSwitch, 'TYPE', { enumerable: true, writable: true, value: { MARKDOWN: MARKDOWN, WYSIWYG: WYSIWYG } }); exports.default = ModeSwitch; /***/ }), /* 78 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _layerpopup = __webpack_require__(5); var _layerpopup2 = _interopRequireDefault(_layerpopup); var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @fileoverview Implements PopupAddLink * @author NHN Ent. FE Development Lab */ var URL_REGEX = /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})(\/([^\s]*))?$/; /** * Class PopupAddLink * It implements a link Add Popup * @extends {LayerPopup} */ var PopupAddLink = function (_LayerPopup) { _inherits(PopupAddLink, _LayerPopup); /** * Creates an instance of PopupAddLink. * @param {LayerPopupOption} options - layer popup options * @memberof PopupAddLink */ function PopupAddLink(options) { _classCallCheck(this, PopupAddLink); var POPUP_CONTENT = '\n \n \n \n \n
\n \n \n
\n '; options = _tuiCodeSnippet2.default.extend({ header: true, title: _i18n2.default.get('Insert link'), className: 'te-popup-add-link tui-editor-popup', content: POPUP_CONTENT }, options); return _possibleConstructorReturn(this, (PopupAddLink.__proto__ || Object.getPrototypeOf(PopupAddLink)).call(this, options)); } /** * init instance. * store properties & prepare before initialize DOM * @param {LayerPopupOption} options - layer popup options * @memberof PopupAddLink * @protected * @override */ _createClass(PopupAddLink, [{ key: '_initInstance', value: function _initInstance(options) { _get(PopupAddLink.prototype.__proto__ || Object.getPrototypeOf(PopupAddLink.prototype), '_initInstance', this).call(this, options); this._editor = options.editor; this._eventManager = options.editor.eventManager; } /** * initialize DOM, render popup * @memberof PopupAddLink * @protected * @override */ }, { key: '_initDOM', value: function _initDOM() { _get(PopupAddLink.prototype.__proto__ || Object.getPrototypeOf(PopupAddLink.prototype), '_initDOM', this).call(this); var el = this.$el.get(0); this._inputText = el.querySelector('.te-link-text-input'); this._inputURL = el.querySelector('.te-url-input'); } /** * bind DOM events * @memberof PopupAddLink * @protected * @override */ }, { key: '_initDOMEvent', value: function _initDOMEvent() { var _this2 = this; _get(PopupAddLink.prototype.__proto__ || Object.getPrototypeOf(PopupAddLink.prototype), '_initDOMEvent', this).call(this); this.on('click .te-close-button', function () { return _this2.hide(); }); this.on('click .te-ok-button', function () { return _this2._addLink(); }); this.on('shown', function () { var inputText = _this2._inputText; var inputURL = _this2._inputURL; var selectedText = _this2._editor.getSelectedText().trim(); inputText.value = selectedText; if (URL_REGEX.exec(selectedText)) { inputURL.value = selectedText; } if (selectedText.length > 0 && inputURL.value.length < 1) { inputURL.focus(); } else { inputText.focus(); inputText.setSelectionRange(0, selectedText.length); } }); this.on('hidden', function () { _this2._resetInputs(); }); } /** * bind editor events * @memberof PopupAddLink * @protected * @abstract */ }, { key: '_initEditorEvent', value: function _initEditorEvent() { var _this3 = this; _get(PopupAddLink.prototype.__proto__ || Object.getPrototypeOf(PopupAddLink.prototype), '_initEditorEvent', this).call(this); var eventManager = this._eventManager; eventManager.listen('focus', function () { return _this3.hide(); }); eventManager.listen('closeAllPopup', function () { return _this3.hide(); }); eventManager.listen('openPopupAddLink', function () { eventManager.emit('closeAllPopup'); _this3.show(); }); } }, { key: '_addLink', value: function _addLink() { var _getValue2 = this._getValue(), url = _getValue2.url, linkText = _getValue2.linkText; this._clearValidationStyle(); if (linkText.length < 1) { (0, _jquery2.default)(this._inputText).addClass('wrong'); return; } if (url.length < 1) { (0, _jquery2.default)(this._inputURL).addClass('wrong'); return; } this._eventManager.emit('command', 'AddLink', { linkText: linkText, url: url }); this.hide(); } }, { key: '_getValue', value: function _getValue() { var url = this._inputURL.value; var linkText = this._inputText.value; return { url: url, linkText: linkText }; } }, { key: '_clearValidationStyle', value: function _clearValidationStyle() { (0, _jquery2.default)(this._inputURL).removeClass('wrong'); (0, _jquery2.default)(this._inputText).removeClass('wrong'); } }, { key: '_resetInputs', value: function _resetInputs() { this._inputText.value = ''; this._inputURL.value = ''; this._clearValidationStyle(); } }]); return PopupAddLink; }(_layerpopup2.default); exports.default = PopupAddLink; /***/ }), /* 79 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _layerpopup = __webpack_require__(5); var _layerpopup2 = _interopRequireDefault(_layerpopup); var _tab = __webpack_require__(43); var _tab2 = _interopRequireDefault(_tab); var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @fileoverview Implements PopupAddImage * @author NHN Ent. FE Development Lab */ var CLASS_IMAGE_URL_INPUT = 'te-image-url-input'; var CLASS_IMAGE_FILE_INPUT = 'te-image-file-input'; var CLASS_ALT_TEXT_INPUT = 'te-alt-text-input'; var CLASS_OK_BUTTON = 'te-ok-button'; var CLASS_CLOSE_BUTTON = 'te-close-button'; var CLASS_FILE_TYPE = 'te-file-type'; var CLASS_URL_TYPE = 'te-url-type'; var CLASS_TAB_SECTION = 'te-tab-section'; var TYPE_UI = 'ui'; /** * Class PopupAddImage * It implements a Image Add Popup * @extends {LayerPopup} */ var PopupAddImage = function (_LayerPopup) { _inherits(PopupAddImage, _LayerPopup); /** * Creates an instance of PopupAddImage. * @param {LayerPopupOption} options - layer popup option * @memberof PopupAddImage */ function PopupAddImage(options) { _classCallCheck(this, PopupAddImage); var POPUP_CONTENT = '\n
\n
\n \n \n
\n
\n \n \n
\n \n \n
\n \n \n
\n '; options = _tuiCodeSnippet2.default.extend({ header: true, title: _i18n2.default.get('Insert image'), className: 'te-popup-add-image tui-editor-popup', content: POPUP_CONTENT }, options); return _possibleConstructorReturn(this, (PopupAddImage.__proto__ || Object.getPrototypeOf(PopupAddImage)).call(this, options)); } /** * init instance. * store properties & prepare before initialize DOM * @param {LayerPopupOption} options - layer popup options * @memberof PopupAddImage * @protected * @override */ _createClass(PopupAddImage, [{ key: '_initInstance', value: function _initInstance(options) { _get(PopupAddImage.prototype.__proto__ || Object.getPrototypeOf(PopupAddImage.prototype), '_initInstance', this).call(this, options); this.eventManager = options.eventManager; } /** * initialize DOM, render popup * @memberof PopupAddImage * @protected * @override */ }, { key: '_initDOM', value: function _initDOM() { _get(PopupAddImage.prototype.__proto__ || Object.getPrototypeOf(PopupAddImage.prototype), '_initDOM', this).call(this); var $popup = this.$el; this._$imageUrlInput = $popup.find('.' + CLASS_IMAGE_URL_INPUT); this._$imageFileInput = $popup.find('.' + CLASS_IMAGE_FILE_INPUT); this._$altTextInput = $popup.find('.' + CLASS_ALT_TEXT_INPUT); var $fileTypeSection = $popup.find('.' + CLASS_FILE_TYPE); var $urlTypeSection = $popup.find('.' + CLASS_URL_TYPE); var $tabSection = this.$body.find('.' + CLASS_TAB_SECTION); this.tab = new _tab2.default({ initName: _i18n2.default.get('File'), items: [_i18n2.default.get('File'), _i18n2.default.get('URL')], sections: [$fileTypeSection, $urlTypeSection] }); $tabSection.append(this.tab.$el); } /** * bind DOM events * @memberof PopupAddImage * @protected * @override */ }, { key: '_initDOMEvent', value: function _initDOMEvent() { var _this2 = this; _get(PopupAddImage.prototype.__proto__ || Object.getPrototypeOf(PopupAddImage.prototype), '_initDOMEvent', this).call(this); this.on('shown', function () { return _this2._$imageUrlInput.focus(); }); this.on('hidden', function () { return _this2._resetInputs(); }); this.on('change .' + CLASS_IMAGE_FILE_INPUT, function () { var filename = _this2._$imageFileInput.val().split('\\').pop(); _this2._$altTextInput.val(filename); }); this.on('click .' + CLASS_CLOSE_BUTTON, function () { return _this2.hide(); }); this.on('click .' + CLASS_OK_BUTTON, function () { var imageUrl = _this2._$imageUrlInput.val(); var altText = _this2._$altTextInput.val(); if (imageUrl) { _this2._applyImage(imageUrl, altText); } else { var _$imageFileInput$get = _this2._$imageFileInput.get(0), files = _$imageFileInput$get.files; if (files.length) { var imageFile = files.item(0); var hookCallback = function hookCallback(url, text) { return _this2._applyImage(url, altText || text); }; _this2.eventManager.emit('addImageBlobHook', imageFile, hookCallback, TYPE_UI); } } _this2.hide(); }); this.tab.on('itemClick', function () { return _this2._resetInputs(); }); } /** * bind editor events * @memberof PopupAddImage * @protected * @abstract */ }, { key: '_initEditorEvent', value: function _initEditorEvent() { var _this3 = this; _get(PopupAddImage.prototype.__proto__ || Object.getPrototypeOf(PopupAddImage.prototype), '_initEditorEvent', this).call(this); this.eventManager.listen('focus', function () { return _this3.hide(); }); this.eventManager.listen('closeAllPopup', function () { return _this3.hide(); }); this.eventManager.listen('openPopupAddImage', function () { _this3.eventManager.emit('closeAllPopup'); _this3.show(); }); } }, { key: '_applyImage', value: function _applyImage(imageUrl, altText) { this.eventManager.emit('command', 'AddImage', { imageUrl: imageUrl, altText: altText || 'image' }); this.hide(); } }, { key: '_resetInputs', value: function _resetInputs() { this.$el.find('input').val(''); } }, { key: 'remove', value: function remove() { this.tab.remove(); _get(PopupAddImage.prototype.__proto__ || Object.getPrototypeOf(PopupAddImage.prototype), 'remove', this).call(this); } }]); return PopupAddImage; }(_layerpopup2.default); exports.default = PopupAddImage; /***/ }), /* 80 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _layerpopup = __webpack_require__(5); var _layerpopup2 = _interopRequireDefault(_layerpopup); var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @fileoverview Implements PopupTableUtils * @author NHN Ent. FE Development Lab */ /** * PopupTableUtils * It implements table utils popup * @extends {LayerPopup} */ var PopupTableUtils = function (_LayerPopup) { _inherits(PopupTableUtils, _LayerPopup); /** * Creates an instance of PopupTableUtils. * @param {LayerPopupOption} options - layer popup options * @memberof PopupTableUtils */ function PopupTableUtils(options) { _classCallCheck(this, PopupTableUtils); var POPUP_CONTENT = '\n \n \n \n \n
\n \n \n \n
\n \n '; options = _tuiCodeSnippet2.default.extend({ header: false, className: 'te-popup-table-utils', content: POPUP_CONTENT }, options); return _possibleConstructorReturn(this, (PopupTableUtils.__proto__ || Object.getPrototypeOf(PopupTableUtils)).call(this, options)); } /** * init instance. * store properties & prepare before initialize DOM * @param {LayerPopupOption} options - layer popup options * @memberof PopupTableUtils * @protected * @override */ _createClass(PopupTableUtils, [{ key: '_initInstance', value: function _initInstance(options) { _get(PopupTableUtils.prototype.__proto__ || Object.getPrototypeOf(PopupTableUtils.prototype), '_initInstance', this).call(this, options); this.eventManager = options.eventManager; } /** * bind DOM events * @memberof PopupTableUtils * @protected * @override */ }, { key: '_initDOMEvent', value: function _initDOMEvent() { var _this2 = this; _get(PopupTableUtils.prototype.__proto__ || Object.getPrototypeOf(PopupTableUtils.prototype), '_initDOMEvent', this).call(this); this.on('click .te-table-add-row', function () { return _this2.eventManager.emit('command', 'AddRow'); }); this.on('click .te-table-add-col', function () { return _this2.eventManager.emit('command', 'AddCol'); }); this.on('click .te-table-remove-row', function () { return _this2.eventManager.emit('command', 'RemoveRow'); }); this.on('click .te-table-col-align-left', function () { return _this2.eventManager.emit('command', 'AlignCol', 'left'); }); this.on('click .te-table-col-align-center', function () { return _this2.eventManager.emit('command', 'AlignCol', 'center'); }); this.on('click .te-table-col-align-right', function () { return _this2.eventManager.emit('command', 'AlignCol', 'right'); }); this.on('click .te-table-remove-col', function () { return _this2.eventManager.emit('command', 'RemoveCol'); }); this.on('click .te-table-remove', function () { return _this2.eventManager.emit('command', 'RemoveTable'); }); } /** * bind editor events * @memberof PopupTableUtils * @protected * @abstract */ }, { key: '_initEditorEvent', value: function _initEditorEvent() { var _this3 = this; _get(PopupTableUtils.prototype.__proto__ || Object.getPrototypeOf(PopupTableUtils.prototype), '_initEditorEvent', this).call(this); this.eventManager.listen('focus', function () { return _this3.hide(); }); this.eventManager.listen('mousedown', function () { return _this3.hide(); }); this.eventManager.listen('closeAllPopup', function () { return _this3.hide(); }); this.eventManager.listen('openPopupTableUtils', function (event) { var offset = _this3.$el.parent().offset(); var x = event.clientX - offset.left; var y = event.clientY - offset.top + (0, _jquery2.default)(window).scrollTop(); _this3.$el.css({ position: 'absolute', top: y + 5, // beside mouse pointer left: x + 10 }); _this3.eventManager.emit('closeAllPopup'); _this3.show(); }); } }]); return PopupTableUtils; }(_layerpopup2.default); exports.default = PopupTableUtils; /***/ }), /* 81 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _layerpopup = __webpack_require__(5); var _layerpopup2 = _interopRequireDefault(_layerpopup); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @fileoverview Implements PopupAddTable * @author NHN Ent. FE Development Lab */ var CLASS_TABLE_SELECTION = 'te-table-selection'; var CLASS_TABLE_HEADER = 'te-table-header'; var CLASS_TABLE_BODY = 'te-table-body'; var CLASS_SELECTION_AREA = 'te-selection-area'; var CLASS_DESCRIPTION = 'te-description'; var POPUP_CONTENT = '\n
\n
\n
\n
\n
\n

\n'; var CELL_WIDTH = 25; var CELL_HEIGHT = 17; var MIN_ROW_INDEX = 7; var MAX_ROW_INDEX = 14; var MIN_COL_INDEX = 5; var MAX_COL_INDEX = 9; var MIN_ROW_SELECTION_INDEX = 1; var MIN_COL_SELECTION_INDEX = 1; var HEADER_ROW_COUNT = 1; var LAST_BORDER = 1; /** * Class PopupAddTable * It implements Popup to add a table * @extends {LayerPopup} */ var PopupAddTable = function (_LayerPopup) { _inherits(PopupAddTable, _LayerPopup); /** * Creates an instance of PopupAddTable. * @param {LayerPopupOption} options - layer popup option * @memberof PopupAddTable */ /** * Toolbar Button which the Popup is bound to. * * @memberof PopupAddTable * @type {jQuery} * @private */ function PopupAddTable(options) { _classCallCheck(this, PopupAddTable); options = _tuiCodeSnippet2.default.extend({ header: false, className: 'te-popup-add-table', content: POPUP_CONTENT }, options); return _possibleConstructorReturn(this, (PopupAddTable.__proto__ || Object.getPrototypeOf(PopupAddTable)).call(this, options)); } /** * init instance. * store properties & prepare before initialize DOM * @param {LayerPopupOption} options - layer popup options * @memberof PopupAddTable * @protected * @override */ /** * EventManager instance * * @memberof PopupAddTabe * @type {EventManager} * @private */ _createClass(PopupAddTable, [{ key: '_initInstance', value: function _initInstance(options) { _get(PopupAddTable.prototype.__proto__ || Object.getPrototypeOf(PopupAddTable.prototype), '_initInstance', this).call(this, options); this._selectedBound = {}; this._tableBound = {}; this._eventManager = options.eventManager; this._$button = options.$button; } /** * initialize DOM, render popup * @memberof PopupAddTable * @protected * @override */ }, { key: '_initDOM', value: function _initDOM() { _get(PopupAddTable.prototype.__proto__ || Object.getPrototypeOf(PopupAddTable.prototype), '_initDOM', this).call(this); this._cacheElements(); this._setTableSizeByBound(MIN_COL_INDEX, MIN_ROW_INDEX); } /** * bind DOM events * @memberof PopupAddTable * @protected * @override */ }, { key: '_initDOMEvent', value: function _initDOMEvent(options) { var _this2 = this; _get(PopupAddTable.prototype.__proto__ || Object.getPrototypeOf(PopupAddTable.prototype), '_initDOMEvent', this).call(this, options); this.on('mousemove .' + CLASS_TABLE_SELECTION, function (ev) { var x = ev.pageX - _this2._selectionOffset.left; var y = ev.pageY - _this2._selectionOffset.top; var bound = _this2._getSelectionBoundByOffset(x, y); _this2._resizeTableBySelectionIfNeed(bound.col, bound.row); _this2._setSelectionAreaByBound(bound.col, bound.row); _this2._setDisplayText(bound.col, bound.row); _this2._setSelectedBound(bound.col, bound.row); }); this.on('click .' + CLASS_TABLE_SELECTION, function () { var tableSize = _this2._getSelectedTableSize(); _this2._eventManager.emit('command', 'Table', tableSize.col, tableSize.row); }); } /** * bind editor events * @memberof PopupAddTable * @protected * @abstract */ }, { key: '_initEditorEvent', value: function _initEditorEvent() { var _this3 = this; _get(PopupAddTable.prototype.__proto__ || Object.getPrototypeOf(PopupAddTable.prototype), '_initEditorEvent', this).call(this); this._eventManager.listen('focus', function () { return _this3.hide(); }); this._eventManager.listen('closeAllPopup', function () { return _this3.hide(); }); this._eventManager.listen('openPopupAddTable', function () { var $button = _this3._$button; var _$button$get = $button.get(0), offsetTop = _$button$get.offsetTop, offsetLeft = _$button$get.offsetLeft; _this3.$el.css({ top: offsetTop + $button.outerHeight(), left: offsetLeft }); _this3._eventManager.emit('closeAllPopup'); _this3.show(); _this3._selectionOffset = _this3.$el.find('.' + CLASS_TABLE_SELECTION).offset(); }); } /** * _cacheElements * Cache elements for use * @private */ }, { key: '_cacheElements', value: function _cacheElements() { this.$header = this.$el.find('.' + CLASS_TABLE_HEADER); this.$body = this.$el.find('.' + CLASS_TABLE_BODY); this.$selection = this.$el.find('.' + CLASS_SELECTION_AREA); this.$desc = this.$el.find('.' + CLASS_DESCRIPTION); } /** * _resizeTableBySelectionIfNeed * Resize table if need * @param {number} col column index * @param {number} row row index * @private */ }, { key: '_resizeTableBySelectionIfNeed', value: function _resizeTableBySelectionIfNeed(col, row) { var resizedBound = this._getResizedTableBound(col, row); if (resizedBound) { this._setTableSizeByBound(resizedBound.col, resizedBound.row); } } /** * _getResizedTableBound * Get resized table bound if Need * @param {number} col column index * @param {number} row row index * @returns {object} bound * @private */ }, { key: '_getResizedTableBound', value: function _getResizedTableBound(col, row) { var resizedCol = void 0, resizedRow = void 0, resizedBound = void 0; if (col >= MIN_COL_INDEX && col < MAX_COL_INDEX) { resizedCol = col + 1; } else if (col < MIN_COL_INDEX) { resizedCol = MIN_COL_INDEX; } if (row >= MIN_ROW_INDEX && row < MAX_ROW_INDEX) { resizedRow = row + 1; } else if (row < MIN_ROW_INDEX) { resizedRow = MIN_ROW_INDEX; } if (this._isNeedResizeTable(resizedCol, resizedRow)) { resizedBound = { row: resizedRow || this._tableBound.row, col: resizedCol || this._tableBound.col }; } return resizedBound; } /** * _isNeedResizeTable * check if need resize table * @param {number} col column index * @param {number} row row index * @returns {boolean} result * @private */ }, { key: '_isNeedResizeTable', value: function _isNeedResizeTable(col, row) { return col && col !== this._tableBound.col || row && row !== this._tableBound.row; } /** * _getBoundByOffset * Get bound by offset * @param {number} x offset * @param {number} y offset * @returns {object} bound * @private */ }, { key: '_getBoundByOffset', value: function _getBoundByOffset(x, y) { var row = parseInt(y / CELL_HEIGHT, 10); var col = parseInt(x / CELL_WIDTH, 10); return { row: row, col: col }; } /** * _getOffsetByBound * Get offset by bound * @param {number} col column index * @param {number} row row index * @returns {object} offset * @private */ }, { key: '_getOffsetByBound', value: function _getOffsetByBound(col, row) { var x = col * CELL_WIDTH + CELL_WIDTH, y = row * CELL_HEIGHT + CELL_HEIGHT; return { x: x, y: y }; } /** * _setTableSizeByBound * Set table size with bound * @param {number} col column index * @param {number} row row index * @private */ }, { key: '_setTableSizeByBound', value: function _setTableSizeByBound(col, row) { var boundOffset = this._getOffsetByBound(col, row - HEADER_ROW_COUNT); this._setTableSize(boundOffset.x, boundOffset.y); this._tableBound.row = row; this._tableBound.col = col; } /** * _getSelectionBoundByOffset * Get selection bound that process with range by offset * @param {number} x offset * @param {number} y offset * @returns {object} bound * @private */ }, { key: '_getSelectionBoundByOffset', value: function _getSelectionBoundByOffset(x, y) { var bound = this._getBoundByOffset(x, y); if (bound.row < MIN_ROW_SELECTION_INDEX) { bound.row = MIN_ROW_SELECTION_INDEX; } else if (bound.row > this._tableBound.row) { bound.row = this._tableBound.row; } if (bound.col < MIN_COL_SELECTION_INDEX) { bound.col = MIN_COL_SELECTION_INDEX; } else if (bound.col > this._tableBound.col) { bound.col = this._tableBound.col; } return bound; } /** * _setSelectionAreaByBound * Set selection area with bound * @param {number} col column index * @param {number} row row index * @private */ }, { key: '_setSelectionAreaByBound', value: function _setSelectionAreaByBound(col, row) { var boundOffset = this._getOffsetByBound(col, row); this._setSelectionArea(boundOffset.x, boundOffset.y); } /** * _setSelectedBound * Set selected bound * @param {number} col column index * @param {number} row row index * @private */ }, { key: '_setSelectedBound', value: function _setSelectedBound(col, row) { this._selectedBound.col = col; this._selectedBound.row = row; } /** * _getSelectedTableSize * Get selected table size * @returns {object} bound * @private */ }, { key: '_getSelectedTableSize', value: function _getSelectedTableSize() { return { row: this._selectedBound.row + 1, col: this._selectedBound.col + 1 }; } /** * _setDisplayText * Set selected table size text for display * @param {number} col column index * @param {number} row row index * @private */ }, { key: '_setDisplayText', value: function _setDisplayText(col, row) { this.$desc.html(col + 1 + ' x ' + (row + 1)); } /** * _setTableSize * Set table element size * @param {number} x offset * @param {number} y offset * @private */ }, { key: '_setTableSize', value: function _setTableSize(x, y) { x += LAST_BORDER; y += LAST_BORDER; this.$header.css({ height: CELL_HEIGHT, width: x }); this.$body.css({ height: y, width: x }); this.$el.css({ width: x + 30 }); } /** * _setSelectionArea * Set selection element size * @param {number} x offset * @param {number} y offset * @private */ }, { key: '_setSelectionArea', value: function _setSelectionArea(x, y) { x += LAST_BORDER; y += LAST_BORDER; this.$selection.css({ height: y, width: x }); } }]); return PopupAddTable; }(_layerpopup2.default); PopupAddTable.CELL_WIDTH = CELL_WIDTH; PopupAddTable.CELL_HEIGHT = CELL_HEIGHT; PopupAddTable.MIN_ROW_SELECTION_INDEX = MIN_ROW_SELECTION_INDEX; PopupAddTable.MIN_COL_SELECTION_INDEX = MIN_COL_SELECTION_INDEX; exports.default = PopupAddTable; /***/ }), /* 82 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _layerpopup = __webpack_require__(5); var _layerpopup2 = _interopRequireDefault(_layerpopup); var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @fileoverview Implements PopupAddTable * @author NHN Ent. FE Development Lab */ /** * Class PopupHeading * It implements Popup to add headings * @extends {LayerPopup} */ var PopupAddHeading = function (_LayerPopup) { _inherits(PopupAddHeading, _LayerPopup); /** * Creates an instance of PopupAddHeading. * @param {LayerPopupOption} options - layer popup option * @memberof PopupAddHeading */ function PopupAddHeading(options) { _classCallCheck(this, PopupAddHeading); var POPUP_CONTENT = '\n
    \n
  • ' + _i18n2.default.get('Heading') + ' 1

  • \n
  • ' + _i18n2.default.get('Heading') + ' 2

  • \n
  • ' + _i18n2.default.get('Heading') + ' 3

  • \n
  • ' + _i18n2.default.get('Heading') + ' 4

  • \n
  • ' + _i18n2.default.get('Heading') + ' 5
  • \n
  • ' + _i18n2.default.get('Heading') + ' 6
  • \n
  • ' + _i18n2.default.get('Paragraph') + '
  • \n
\n '; options = _tuiCodeSnippet2.default.extend({ header: false, className: 'te-heading-add', content: POPUP_CONTENT }, options); return _possibleConstructorReturn(this, (PopupAddHeading.__proto__ || Object.getPrototypeOf(PopupAddHeading)).call(this, options)); } /** * init instance. * store properties & prepare before initialize DOM * @param {LayerPopupOption} options - layer popup options * @memberof PopupAddHeading * @protected * @override */ _createClass(PopupAddHeading, [{ key: '_initInstance', value: function _initInstance(options) { _get(PopupAddHeading.prototype.__proto__ || Object.getPrototypeOf(PopupAddHeading.prototype), '_initInstance', this).call(this, options); this._eventManager = options.eventManager; this._$button = options.$button; } /** * bind DOM events * @memberof PopupAddHeading * @protected * @override */ }, { key: '_initDOMEvent', value: function _initDOMEvent() { var _this2 = this; _get(PopupAddHeading.prototype.__proto__ || Object.getPrototypeOf(PopupAddHeading.prototype), '_initDOMEvent', this).call(this); this.on('click li', function (ev) { var $li = (0, _jquery2.default)(ev.target).closest('li'); _this2._eventManager.emit('command', $li.data('type'), $li.data('value')); }); } /** * bind editor events * @memberof PopupAddHeading * @protected * @abstract */ }, { key: '_initEditorEvent', value: function _initEditorEvent() { var _this3 = this; _get(PopupAddHeading.prototype.__proto__ || Object.getPrototypeOf(PopupAddHeading.prototype), '_initEditorEvent', this).call(this); this._eventManager.listen('focus', this.hide.bind(this)); this._eventManager.listen('closeAllPopup', this.hide.bind(this)); this._eventManager.listen('openHeadingSelect', function () { var $button = _this3._$button; var _$button$get = $button.get(0), offsetTop = _$button$get.offsetTop, offsetLeft = _$button$get.offsetLeft; _this3.$el.css({ top: offsetTop + $button.outerHeight(), left: offsetLeft }); _this3._eventManager.emit('closeAllPopup'); _this3.show(); }); } }]); return PopupAddHeading; }(_layerpopup2.default); exports.default = PopupAddHeading; /***/ }), /* 83 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _layerpopup = __webpack_require__(5); var _layerpopup2 = _interopRequireDefault(_layerpopup); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @fileoverview Implements popup code block languages * @author NHN Ent. FE Development Lab */ var BUTTON_CLASS_PREFIX = 'te-popup-code-block-lang-'; /** * Class Popup code block languages select list * @extends {LayerPopup} */ var PopupCodeBlockLanguages = function (_LayerPopup) { _inherits(PopupCodeBlockLanguages, _LayerPopup); /** * Creates an instance of PopupCodeBlockLanguages. * @param {LayerPopupOption} options - layer popup option * @memberof PopupCodeBlockLanguages */ function PopupCodeBlockLanguages(options) { _classCallCheck(this, PopupCodeBlockLanguages); var popupButtonsHTML = []; var _options = options, languages = _options.languages; languages.forEach(function (lang) { return popupButtonsHTML.push(''); }); options = _tuiCodeSnippet2.default.extend({ header: false, className: 'te-popup-code-block-languages', content: popupButtonsHTML.join('') }, options); return _possibleConstructorReturn(this, (PopupCodeBlockLanguages.__proto__ || Object.getPrototypeOf(PopupCodeBlockLanguages)).call(this, options)); } /** * init instance. * store properties & prepare before initialize DOM * @param {LayerPopupOption} options - layer popup options * @memberof PopupCodeBlockLanguages * @protected * @override */ _createClass(PopupCodeBlockLanguages, [{ key: '_initInstance', value: function _initInstance(options) { _get(PopupCodeBlockLanguages.prototype.__proto__ || Object.getPrototypeOf(PopupCodeBlockLanguages.prototype), '_initInstance', this).call(this, options); this._onSelectedLanguage = null; this._onDismissed = null; this._currentButton = null; this._$buttons = null; this._languages = options.languages; this.eventManager = options.eventManager; } /** * initialize DOM, render popup * @memberof PopupCodeBlockLanguages * @protected * @override */ }, { key: '_initDOM', value: function _initDOM(options) { _get(PopupCodeBlockLanguages.prototype.__proto__ || Object.getPrototypeOf(PopupCodeBlockLanguages.prototype), '_initDOM', this).call(this, options); this.$el.css('z-index', 10000); this._$buttons = this.$el.find('button'); this._activateButtonByIndex(0); } /** * bind DOM events * @memberof PopupCodeBlockLanguages * @protected * @override */ }, { key: '_initDOMEvent', value: function _initDOMEvent() { var _this2 = this; _get(PopupCodeBlockLanguages.prototype.__proto__ || Object.getPrototypeOf(PopupCodeBlockLanguages.prototype), '_initDOMEvent', this).call(this); var handler = function handler(event) { var language = (0, _jquery2.default)(event.target).data('lang'); if (_this2._onSelectedLanguage) { _this2._onSelectedLanguage(language); } _this2.hide(); }; this._languages.forEach(function (lang) { return _this2.on('mousedown .' + BUTTON_CLASS_PREFIX + lang, handler); }); } /** * bind editor events * @memberof PopupCodeBlockLanguages * @protected * @abstract */ }, { key: '_initEditorEvent', value: function _initEditorEvent() { var _this3 = this; _get(PopupCodeBlockLanguages.prototype.__proto__ || Object.getPrototypeOf(PopupCodeBlockLanguages.prototype), '_initEditorEvent', this).call(this); this.eventManager.listen('openPopupCodeBlockLanguages', function (data) { _this3.show(data.callback); var elementStyle = _this3.$el.get(0).style; elementStyle.top = data.offset.top + 'px'; elementStyle.left = data.offset.left + 'px'; _this3.setCurrentLanguage(data.language); return _this3; }); this.eventManager.listen('focus', function () { return _this3.hide(); }); this.eventManager.listen('mousedown', function () { return _this3.hide(); }); this.eventManager.listen('closeAllPopup', function () { return _this3.hide(); }); this.eventManager.listen('closePopupCodeBlockLanguages', function () { return _this3.hide(); }); this.eventManager.listen('scroll', function () { return _this3.hide(); }); } /** * activate an item by index * @param {number} index - item index * @private * @memberof PopupCodeBlockLanguages */ }, { key: '_activateButtonByIndex', value: function _activateButtonByIndex(index) { if (this._currentButton) { (0, _jquery2.default)(this._currentButton).removeClass('active'); } this._currentButton = this._$buttons.get(index); (0, _jquery2.default)(this._currentButton).addClass('active'); this._currentButton.scrollIntoView(); } /** * move to prev language * @memberof PopupCodeBlockLanguages */ }, { key: 'prev', value: function prev() { var index = this._$buttons.index(this._currentButton) - 1; if (index < 0) { index = this._$buttons.length - 1; } this._activateButtonByIndex(index); } /** * move to next language * @memberof PopupCodeBlockLanguages */ }, { key: 'next', value: function next() { var index = this._$buttons.index(this._currentButton) + 1; if (index >= this._$buttons.length) { index = 0; } this._activateButtonByIndex(index); } /** * current language * @public * @memberof PopupCodeBlockLanguages * @returns {string} language */ }, { key: 'getCurrentLanguage', value: function getCurrentLanguage() { var language = (0, _jquery2.default)(this._currentButton).data('lang'); return language; } /** * set current language * @param {string} language - current language * @memberof PopupCodeBlockLanguages */ }, { key: 'setCurrentLanguage', value: function setCurrentLanguage(language) { var item = this._$buttons.filter('.' + BUTTON_CLASS_PREFIX + language); if (item.length > 0) { var index = this._$buttons.index(item); this._activateButtonByIndex(index); } } /** * show popup * @param {object} callback - to be called on language selected & dismissed * @protected * @memberof PopupCodeBlockLanguages */ }, { key: 'show', value: function show(callback) { this._onSelectedLanguage = callback.selected; this._onDismissed = callback.dismissed; _get(PopupCodeBlockLanguages.prototype.__proto__ || Object.getPrototypeOf(PopupCodeBlockLanguages.prototype), 'show', this).call(this); } /** * hide popup * @memberof PopupCodeBlockLanguages * @protected */ }, { key: 'hide', value: function hide() { if (this._onDismissed) { this._onDismissed(); } this._onSelectedLanguage = null; this._onDismissed = null; _get(PopupCodeBlockLanguages.prototype.__proto__ || Object.getPrototypeOf(PopupCodeBlockLanguages.prototype), 'hide', this).call(this); } }]); return PopupCodeBlockLanguages; }(_layerpopup2.default); exports.default = PopupCodeBlockLanguages; /***/ }), /* 84 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _layerpopup = __webpack_require__(5); var _layerpopup2 = _interopRequireDefault(_layerpopup); var _scrollSyncSplit = __webpack_require__(85); var _scrollSyncSplit2 = _interopRequireDefault(_scrollSyncSplit); var _codeBlockEditor = __webpack_require__(86); var _codeBlockEditor2 = _interopRequireDefault(_codeBlockEditor); var _codeBlockPreview = __webpack_require__(87); var _codeBlockPreview2 = _interopRequireDefault(_codeBlockPreview); var _codeBlockLanguagesCombo = __webpack_require__(88); var _codeBlockLanguagesCombo2 = _interopRequireDefault(_codeBlockLanguagesCombo); var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @fileoverview Implements popup code block editor * @author NHN Ent. FE Development Lab */ var CLASS_PREFIX = 'popup-editor-'; var CLASS_OK_BUTTON = 'te-ok-button'; var CLASS_CLOSE_BUTTON = 'te-close-button'; var CLASS_POPUP_CLOSE_BUTTON = 'tui-popup-close-button'; var TEMPLATE_HEADER_BUTTONS = '\n \n \n \n \n'; /** * Class popup code block editor * @extends {LayerPopup} */ var PopupCodeBlockEditor = function (_LayerPopup) { _inherits(PopupCodeBlockEditor, _LayerPopup); /** * Creates an instance of PopupCodeBlockEditor. * @param {LayerPopupOption} options - layer popup option * @memberof PopupCodeBlockEditor */ function PopupCodeBlockEditor(options) { _classCallCheck(this, PopupCodeBlockEditor); var TEMPLATE_CONTENT = '\n
\n
\n \n \n
\n '; options = _tuiCodeSnippet2.default.extend({ header: true, title: 'CodeBlock Editor', content: TEMPLATE_CONTENT, className: 'tui-popup-code-block-editor', headerButtons: TEMPLATE_HEADER_BUTTONS, modal: true }, options); return _possibleConstructorReturn(this, (PopupCodeBlockEditor.__proto__ || Object.getPrototypeOf(PopupCodeBlockEditor)).call(this, options)); } /** * init instance. * store properties & prepare before initialize DOM * @param {LayerPopupOption} options - layer popup options * @memberof PopupCodeBlockEditor * @protected * @override */ _createClass(PopupCodeBlockEditor, [{ key: '_initInstance', value: function _initInstance(options) { _get(PopupCodeBlockEditor.prototype.__proto__ || Object.getPrototypeOf(PopupCodeBlockEditor.prototype), '_initInstance', this).call(this, options); this.eventManager = options.eventManager; this.convertor = options.convertor; } /** * initialize DOM, render popup * @memberof PopupCodeBlockEditor * @protected * @override */ }, { key: '_initDOM', value: function _initDOM(options) { _get(PopupCodeBlockEditor.prototype.__proto__ || Object.getPrototypeOf(PopupCodeBlockEditor.prototype), '_initDOM', this).call(this, options); var el = this.$el.get(0); this._body = el.querySelector('.' + CLASS_PREFIX + 'body'); this._toggleFitButton = el.querySelector('.' + CLASS_PREFIX + 'toggle-fit'); this._togglePreviewButton = el.querySelector('.' + CLASS_PREFIX + 'toggle-preview'); this._toggleScrollButton = el.querySelector('.' + CLASS_PREFIX + 'toggle-scroll'); this._okButton = el.querySelector('.' + CLASS_OK_BUTTON); this._closeButton = el.querySelector('.' + CLASS_CLOSE_BUTTON); this._codeMirrorWrapper = this._createCodeBlockEditor(); this._previewWrapper = this._createPreview(); this._scrollSyncSplit = new _scrollSyncSplit2.default(this._body, this._codeMirrorWrapper, this._previewWrapper); this._updateFitWindowButton(); this._updatePreviewButton(); this._updateScrollButton(); this._codeBlockLanguagesCombo = this._createCodeBlockLanguagesCombo(); } /** * bind DOM events * @memberof PopupCodeBlockEditor * @protected * @override */ }, { key: '_initDOMEvent', value: function _initDOMEvent() { var _this2 = this; _get(PopupCodeBlockEditor.prototype.__proto__ || Object.getPrototypeOf(PopupCodeBlockEditor.prototype), '_initDOMEvent', this).call(this); this.on('scroll', function (ev) { return ev.preventDefault(); }); this.on('click .' + CLASS_PREFIX + 'toggle-fit', function () { return _this2._toggleFitToWindow(); }); this.on('click .' + CLASS_PREFIX + 'toggle-preview', function () { return _this2._togglePreview(); }); this.on('click .' + CLASS_PREFIX + 'toggle-scroll', function () { return _this2._toggleScroll(); }); this.on('click .' + CLASS_OK_BUTTON, function () { return _this2._save(); }); this.on('click .' + CLASS_CLOSE_BUTTON, function () { return _this2.hide(); }); this.on('click .' + CLASS_PREFIX + 'close', function () { return _this2.hide(); }); this.on('click .' + CLASS_PREFIX + 'editor-wrapper', function (ev) { if (ev.target === _this2._codeMirrorWrapper) { _this2._focusEditor(true); } }); } /** * bind editor events * @memberof PopupCodeBlockEditor * @protected * @abstract */ }, { key: '_initEditorEvent', value: function _initEditorEvent() { var _this3 = this; _get(PopupCodeBlockEditor.prototype.__proto__ || Object.getPrototypeOf(PopupCodeBlockEditor.prototype), '_initEditorEvent', this).call(this); this.eventManager.listen('openPopupCodeBlockEditor', function (codeBlockElement) { _this3.eventManager.emit('closeAllPopup'); _this3.show(codeBlockElement); return _this3; }); this.eventManager.listen('closeAllPopup', this.hide.bind(this)); this.eventManager.listen('closePopupCodeBlockEditor', this.hide.bind(this)); } }, { key: '_createCodeBlockEditor', value: function _createCodeBlockEditor() { var codeMirrorWrapper = document.createElement('div'); codeMirrorWrapper.className = CLASS_PREFIX + 'editor-wrapper'; this._codeBlockEditor = new _codeBlockEditor2.default(codeMirrorWrapper, this.eventManager); return codeMirrorWrapper; } }, { key: '_createPreview', value: function _createPreview() { var previewWrapper = document.createElement('div'); this._codeBlockPreview = new _codeBlockPreview2.default((0, _jquery2.default)(previewWrapper), this.eventManager, this.convertor, this._codeBlockEditor); return previewWrapper; } }, { key: '_createCodeBlockLanguagesCombo', value: function _createCodeBlockLanguagesCombo() { var _this4 = this; var titleElement = this.getTitleElement(); var codeBlockLanguagesCombo = new _codeBlockLanguagesCombo2.default(this.eventManager); codeBlockLanguagesCombo.setOnLanguageSelected(function (selectedLanguage) { _this4._codeBlockEditor.setLanguage(selectedLanguage); _this4._codeBlockEditor.refresh(); _this4._focusEditor(); }); titleElement.innerHTML = 'CodeBlock Editor'; titleElement.appendChild(codeBlockLanguagesCombo.getElement()); return codeBlockLanguagesCombo; } }, { key: '_updateFitWindowButton', value: function _updateFitWindowButton() { (0, _jquery2.default)(this._toggleFitButton).toggleClass('active', this.isFitToWindow()); } }, { key: '_updatePreviewButton', value: function _updatePreviewButton() { (0, _jquery2.default)(this._togglePreviewButton).toggleClass('active', this._scrollSyncSplit.isSplitView()); } }, { key: '_updateScrollButton', value: function _updateScrollButton() { if (this._scrollSyncSplit.isSplitView()) { this._toggleScrollButton.style.display = 'inline-block'; } else { this._toggleScrollButton.style.display = 'none'; } (0, _jquery2.default)(this._toggleScrollButton).toggleClass('active', this._scrollSyncSplit.isScrollSynced()); } }, { key: '_focusEditor', value: function _focusEditor(cursorToEnd) { this._codeBlockEditor.focus(); if (cursorToEnd) { this._codeBlockEditor.moveCursorToEnd(); } else { this._codeBlockEditor.moveCursorToStart(); } } }, { key: '_togglePreview', value: function _togglePreview() { this._scrollSyncSplit.toggleSplitView(); this._updatePreviewButton(); this._updateScrollButton(); this._codeBlockEditor.refresh(); } }, { key: '_toggleFitToWindow', value: function _toggleFitToWindow() { this.toggleFitToWindow(); this._updateFitWindowButton(); this._codeBlockEditor.refresh(); } }, { key: '_toggleScroll', value: function _toggleScroll() { this._scrollSyncSplit.toggleScrollSync(); this._updateScrollButton(); } /** * store code mirror text to wysiwyg code block * @memberof PopupCodeBlockEditor * @private */ }, { key: '_save', value: function _save() { this._codeBlockEditor.save(this._codeBlockElement); this.hide(); } /** * load code mirror text from wysiwyg code block * @param {HTMLElement} codeBlockElement - code block element instance to load code from * @private * @memberof PopupCodeBlockEditor */ }, { key: '_load', value: function _load(codeBlockElement) { this._codeBlockElement = codeBlockElement; this._codeBlockEditor.load(codeBlockElement); this._codeBlockLanguagesCombo.setLanguage(this._codeBlockEditor.getLanguage()); this._focusEditor(); this._codeBlockPreview.refresh(); } /** * show popup * @param {HTMLElement} codeBlockElement - code block element * @memberof PopupCodeBlockEditor * @override */ }, { key: 'show', value: function show(codeBlockElement) { _get(PopupCodeBlockEditor.prototype.__proto__ || Object.getPrototypeOf(PopupCodeBlockEditor.prototype), 'show', this).call(this); if (!codeBlockElement) { throw new Error('should be called with codeBlockElement'); } this._load(codeBlockElement); } /** * hide popup * @memberof PopupCodeBlockEditor * @override */ }, { key: 'hide', value: function hide() { this.setFitToWindow(false); if (this._codeBlockEditor) { this._codeBlockEditor.clear(); } if (this._codeBlockPreview) { this._codeBlockPreview.clear(); } this._codeBlockElement = null; _get(PopupCodeBlockEditor.prototype.__proto__ || Object.getPrototypeOf(PopupCodeBlockEditor.prototype), 'hide', this).call(this); } }]); return PopupCodeBlockEditor; }(_layerpopup2.default); exports.default = PopupCodeBlockEditor; /***/ }), /* 85 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview Implements scroll sync split * @author NHN Ent. FE Development Lab */ var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var CLASS_SPLIT_SCROLL = 'tui-split-scroll'; var CLASS_SINGLE_CONTENT = 'single-content'; var CLASS_SCROLL_SYNC = 'scroll-sync'; var CLASS_SCROLL_WRAPPER = 'tui-split-scroll-wrapper'; var CLASS_SCROLL_CONTENT = 'tui-split-scroll-content'; var CLASS_SPLITTER = 'tui-splitter'; var EVENT_REQUIRE_SCROLL_SYNC = 'requireScrollSync'; var EVENT_REQUIRE_SCROLL_INTO_VIEW = 'requireScrollIntoView'; var CLASS_CONTENT_LEFT = 'tui-split-content-left'; var CLASS_CONTENT_RIGHT = 'tui-split-content-right'; var CLASS_CONTENT = { 'left': CLASS_CONTENT_LEFT, 'right': CLASS_CONTENT_RIGHT }; /** * Class ScrollSyncSplit */ var ScrollSyncSplit = function () { /** * Creates an instance of ScrollSyncSplit. * @param {Element} baseElement - an element which attach a splitSyncSplit * @param {Element} leftElement - an element to be on left side split view * @param {Element} rightElement - an element to be on right side split view * @param {object} options - options * @param {boolean} [options.showScrollSyncButton=false] - show scroll sync button on top right corner * @param {boolean} [options.scrollSync=true] - true for enable scroll sync * @param {boolean} [options.splitView=true] - true for split, false for single view * @memberof ScrollSyncSplit */ function ScrollSyncSplit(baseElement, leftElement, rightElement) { var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; _classCallCheck(this, ScrollSyncSplit); options = _tuiCodeSnippet2.default.extend({ showScrollSyncButton: false, scrollSync: true, splitView: true }, options); this._baseElement = baseElement; /** * left, right side content elements */ this._contentElements = []; this._initDom(leftElement, rightElement, options); this._initDomEvent(); } _createClass(ScrollSyncSplit, [{ key: '_initDom', value: function _initDom(leftElement, rightElement, options) { var el = document.createElement('div'); el.className = CLASS_SPLIT_SCROLL; this._el = el; var scrollWrapper = document.createElement('div'); scrollWrapper.className = CLASS_SCROLL_WRAPPER; this._scrollWrapper = scrollWrapper; this._setScrollSync(options.scrollSync); this.setSplitView(options.splitView); var contentWrapper = document.createElement('div'); contentWrapper.className = CLASS_SCROLL_CONTENT; this._contentWrapper = contentWrapper; var splitter = document.createElement('div'); splitter.className = CLASS_SPLITTER; this._baseElement.appendChild(el); el.appendChild(scrollWrapper); scrollWrapper.appendChild(contentWrapper); scrollWrapper.appendChild(splitter); this._setLeft(leftElement); this._setRight(rightElement); } }, { key: '_initDomEvent', value: function _initDomEvent() { this._contentWrapper.addEventListener('scroll', this.sync.bind(this)); } }, { key: '_requireScrollIntoView', value: function _requireScrollIntoView(event) { var element = event.target; var _element$getBoundingC = element.getBoundingClientRect(), targetTop = _element$getBoundingC.top, targetBottom = _element$getBoundingC.bottom; var wrapperTop = void 0, wrapperBottom = void 0, wrapperElement = void 0; if (this.isScrollSynced()) { wrapperElement = this._contentWrapper; } else if ((0, _jquery2.default)(element).parents(this._contentElements.left).length) { wrapperElement = this._contentElements.left; } else if ((0, _jquery2.default)(element).parents(this._contentElements.right).length) { wrapperElement = this._contentElements.right; } else { return; } var _wrapperElement$getBo = wrapperElement.getBoundingClientRect(); wrapperTop = _wrapperElement$getBo.top; wrapperBottom = _wrapperElement$getBo.bottom; if (targetTop < wrapperTop) { wrapperElement.scrollTop = wrapperElement.scrollTop + targetTop - wrapperTop; } else if (targetBottom > wrapperBottom) { wrapperElement.scrollTop = wrapperElement.scrollTop + targetBottom - wrapperBottom; } this.sync(); } /** * set content element for given side * @param {Element} element - content element * @param {string} side - 'left' | 'right' * @memberof ScrollSyncSplit * @private */ }, { key: '_setContentElement', value: function _setContentElement(element, side) { var _this = this; var contentElement = this._contentElements[side]; if (contentElement) { (0, _jquery2.default)(contentElement).off(EVENT_REQUIRE_SCROLL_INTO_VIEW); this._contentWrapper.removeChild(contentElement); } (0, _jquery2.default)(element).addClass(CLASS_CONTENT[side]); this._contentWrapper.appendChild(element); (0, _jquery2.default)(element).on(EVENT_REQUIRE_SCROLL_INTO_VIEW, function (ev) { return _this._requireScrollIntoView(ev); }); (0, _jquery2.default)(element).on(EVENT_REQUIRE_SCROLL_SYNC, function () { return _this.sync(); }); this._contentElements[side] = element; this.sync(); } /** * set left side element * @param {Element} element - an element to be on left side split view * @memberof ScrollSyncSplit * @private */ }, { key: '_setLeft', value: function _setLeft(element) { this._setContentElement(element, 'left'); } /** * set right side element * @param {Element} element - an element to be on right side split view * @memberof ScrollSyncSplit * @private */ }, { key: '_setRight', value: function _setRight(element) { this._setContentElement(element, 'right'); } }, { key: '_setScrollSync', value: function _setScrollSync(activate) { (0, _jquery2.default)(this._el).toggleClass(CLASS_SCROLL_SYNC, activate); } /** * toggle multi scroll * @memberof ScrollSyncSplit */ }, { key: 'toggleScrollSync', value: function toggleScrollSync() { (0, _jquery2.default)(this._el).toggleClass(CLASS_SCROLL_SYNC); } }, { key: 'setSplitView', value: function setSplitView(activate) { (0, _jquery2.default)(this._el).toggleClass(CLASS_SINGLE_CONTENT, !activate); } /** * toggle split * @memberof ScrollSyncSplit */ }, { key: 'toggleSplitView', value: function toggleSplitView() { (0, _jquery2.default)(this._el).toggleClass(CLASS_SINGLE_CONTENT); } /** * is scroll synced * @returns {boolean} - true for synced, false for each scroll * @memberof ScrollSyncSplit */ }, { key: 'isScrollSynced', value: function isScrollSynced() { return (0, _jquery2.default)(this._el).hasClass(CLASS_SCROLL_SYNC); } /** * is split view * @returns {boolean} - true for split view, false for single view * @memberof ScrollSyncSplit */ }, { key: 'isSplitView', value: function isSplitView() { return !(0, _jquery2.default)(this._el).hasClass(CLASS_SINGLE_CONTENT); } /** * sync scroll * @memberof ScrollSyncSplit */ }, { key: 'sync', value: function sync() { if (!this._contentElements.left || !this._contentElements.right) { return; } var wrapperHeight = this._contentWrapper.clientHeight; var scrollTop = this._contentWrapper.scrollTop; var leftElement = this._contentElements.left; var rightElement = this._contentElements.right; var scrollingElement = leftElement.offsetHeight - wrapperHeight > 0 ? leftElement : rightElement; var followingElement = scrollingElement === leftElement ? rightElement : leftElement; var scrollingElementHeight = scrollingElement.offsetHeight; var scrollingElementScrollMax = Math.max(scrollingElementHeight - wrapperHeight, 0); var followingElementHeight = Math.max(followingElement.offsetHeight, wrapperHeight); var followingElementTopMax = scrollingElementHeight - followingElementHeight; scrollingElement.style.top = '0px'; followingElement.style.top = scrollTop / scrollingElementScrollMax * followingElementTopMax + 'px'; } /** * scroll top * @param {number} top - scroll top in pixel * @memberof ScrollSyncSplit */ }, { key: 'scrollTop', value: function scrollTop(top) { this._contentWrapper.scrollTop = top; } }]); return ScrollSyncSplit; }(); exports.default = ScrollSyncSplit; /***/ }), /* 86 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _codeMirrorExt = __webpack_require__(35); var _codeMirrorExt2 = _interopRequireDefault(_codeMirrorExt); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @fileoverview Implements code block editor * @author NHN Ent. FE Development Lab */ var EVENT_LANGUAGE_CHANGED = 'language-changed'; /** * Class Code Block Editor * @extends {CodeMirrorExt} */ var CodeBlockEditor = function (_CodeMirrorExt) { _inherits(CodeBlockEditor, _CodeMirrorExt); /** * Creates an instance of CodeBlockEditor. * @param {HTMLElement} el - code block editor container element * @param {EventManager} eventManager - event manager * @memberof CodeBlockEditor */ function CodeBlockEditor(el, eventManager) { _classCallCheck(this, CodeBlockEditor); var _this = _possibleConstructorReturn(this, (CodeBlockEditor.__proto__ || Object.getPrototypeOf(CodeBlockEditor)).call(this, el, { singleCursorHeightPerLine: false, theme: 'none' })); _this._language = ''; _this._eventManager = eventManager; _this._initEvent(); return _this; } _createClass(CodeBlockEditor, [{ key: '_initEvent', value: function _initEvent() { var _this2 = this; this.on('cursorActivity', this._onRequireScrollIntoView.bind(this)); this.on('beforeChange', function (cm, ev) { if (ev.origin === 'paste') { _this2._eventManager.emit('pasteBefore', { source: 'codeblock', data: ev }); } }); } }, { key: '_onRequireScrollIntoView', value: function _onRequireScrollIntoView() { var cursor = this.getCursor(); var wrapper = this.getWrapperElement(); // CodeMirror cursorActivity event fires before actually attach a new line element to DOM // we should proceed at next tick setTimeout(function () { var lineElement = wrapper.querySelector('pre:nth-child(' + (cursor.line + 1) + ')'); (0, _jquery2.default)(lineElement).trigger('requireScrollIntoView'); }, 0); } /** * load code from code block element * @param {HTMLElement} codeBlockElement - code block element * @memberof CodeBlockEditor */ }, { key: 'load', value: function load(codeBlockElement) { var el = codeBlockElement.cloneNode(true); this.setLanguage(el.getAttribute('data-language') || ''); this.setEditorCodeText(el.textContent); } /** * save code to code block element * @param {HTMLElement} codeBlockElement - code block element * @memberof CodeBlockEditor */ }, { key: 'save', value: function save(codeBlockElement) { codeBlockElement.innerHTML = ''; codeBlockElement.textContent = this.getEditorCodeText(); codeBlockElement.setAttribute('data-language', this._language); (0, _jquery2.default)(codeBlockElement).trigger(EVENT_LANGUAGE_CHANGED); } /** * clear code and language * @memberof CodeBlockEditor */ }, { key: 'clear', value: function clear() { this.setLanguage(''); this.setEditorCodeText(''); } /** * get code language * @returns {string} - code language * @memberof CodeBlockEditor */ }, { key: 'getLanguage', value: function getLanguage() { return this._language; } /** * set code language * @param {string} [language=''] - code language * @memberof CodeBlockEditor */ }, { key: 'setLanguage', value: function setLanguage() { var language = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; this._language = language; } /** * get code text * @returns {string} - code text * @memberof CodeBlockEditor */ }, { key: 'getEditorCodeText', value: function getEditorCodeText() { return this.getValue(); } /** * set code text * @param {string} [code=''] - code text * @memberof CodeBlockEditor */ }, { key: 'setEditorCodeText', value: function setEditorCodeText() { var code = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; this.setValue(code); } /** * refresh. call if codemirror resized * @memberof CodeBlockEditor */ }, { key: 'refresh', value: function refresh() { this.cm.refresh(); } }]); return CodeBlockEditor; }(_codeMirrorExt2.default); exports.default = CodeBlockEditor; /***/ }), /* 87 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; var _preview = __webpack_require__(13); var _preview2 = _interopRequireDefault(_preview); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * @fileoverview Implements CodeBlockPreview * @author NHN Ent. FE Development Lab */ var EVENT_REQUIRE_SCROLL_SYNC = 'requireScrollSync'; /** * Class Code block preview * @extends {Preview} */ var CodeBlockPreview = function (_Preview) { _inherits(CodeBlockPreview, _Preview); /** * Creates an instance of CodeBlockPreview. * @param {jQuery} $el - base element * @param {EventManager} eventManager - event manager * @param {Convertor} convertor - convertor * @param {CodeBlockEditor} codeBlockEditor - code block editor * @memberof CodeBlockPreview */ function CodeBlockPreview($el, eventManager, convertor, codeBlockEditor) { _classCallCheck(this, CodeBlockPreview); var _this = _possibleConstructorReturn(this, (CodeBlockPreview.__proto__ || Object.getPrototypeOf(CodeBlockPreview)).call(this, $el, eventManager, convertor, true)); _this._codeBlockEditor = codeBlockEditor; _this._initEvent(); return _this; } _createClass(CodeBlockPreview, [{ key: '_initEvent', value: function _initEvent() { var _this2 = this; this._codeBlockEditor.on('update', function () { return _this2.lazyRunner.run('refresh'); }); } /** * refresh preview * @memberof CodeBlockPreview * @override */ }, { key: 'refresh', value: function refresh() { var language = this._codeBlockEditor.getLanguage(); var codeText = this._codeBlockEditor.getEditorCodeText(); _get(CodeBlockPreview.prototype.__proto__ || Object.getPrototypeOf(CodeBlockPreview.prototype), 'refresh', this).call(this, '```' + language + '\n' + codeText + '\n```'); this.$el.trigger(EVENT_REQUIRE_SCROLL_SYNC); } /** * clear preview * @memberof CodeBlockPreview */ }, { key: 'clear', value: function clear() { _get(CodeBlockPreview.prototype.__proto__ || Object.getPrototypeOf(CodeBlockPreview.prototype), 'render', this).call(this, ''); } }]); return CodeBlockPreview; }(_preview2.default); exports.default = CodeBlockPreview; /***/ }), /* 88 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * @fileoverview Implements UI code block languages combo * @author NHN Ent. FE Development Lab */ var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); var _keyMapper = __webpack_require__(19); var _keyMapper2 = _interopRequireDefault(_keyMapper); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Class CodeBlockLanguagesCombo */ var CodeBlockLanguagesCombo = function () { /** * Creates an instance of CodeBlockLanguagesCombo. * @param {EventManager} eventManager - event manager instance * @memberof CodeBlockLanguagesCombo */ function CodeBlockLanguagesCombo(eventManager) { _classCallCheck(this, CodeBlockLanguagesCombo); this._eventManager = eventManager; this._initDOM(); this._initDOMEvent(); } _createClass(CodeBlockLanguagesCombo, [{ key: '_initDOM', value: function _initDOM() { this._inputLanguage = (0, _jquery2.default)('').get(0); this._wrapper = (0, _jquery2.default)('').get(0); this._wrapper.appendChild(this._inputLanguage); } }, { key: '_initDOMEvent', value: function _initDOMEvent() { var _this = this; this._inputLanguage.addEventListener('keydown', function (event) { return _this._onKeyEvent(event); }); this._inputLanguage.addEventListener('focus', function () { return _this._showPopupCodeBlockLanguages(); }); this._inputLanguage.addEventListener('focusout', function () { return _this._onFocusOut(); }); this._wrapper.addEventListener('mousedown', function (ev) { if (ev.target !== _this._wrapper) { return; } ev.preventDefault(); _this._toggleFocus(); }); } /** * show popup * @private * @memberof CodeBlockGadget */ }, { key: '_showPopupCodeBlockLanguages', value: function _showPopupCodeBlockLanguages() { var _this2 = this; var clientRect = this._inputLanguage.getBoundingClientRect(); (0, _jquery2.default)(this._wrapper).toggleClass('active', true); this.active = true; this._popupCodeBlockLanguages = this._eventManager.emitReduce('openPopupCodeBlockLanguages', { language: this._prevStoredLanguage, offset: { left: clientRect.left, top: clientRect.bottom }, callback: { selected: function selected(selectedLanguage) { return _this2._onLanguageSelectedFromList(selectedLanguage); }, dismissed: function dismissed() { _this2._popupCodeBlockLanguages = null; } } }); } }, { key: '_toggleFocus', value: function _toggleFocus() { var inputLanguage = this._inputLanguage; if ((0, _jquery2.default)(this._wrapper).hasClass('active')) { inputLanguage.blur(); } else { inputLanguage.focus(); } } }, { key: '_onFocusOut', value: function _onFocusOut() { (0, _jquery2.default)(this._wrapper).toggleClass('active', false); this._inputLanguage.value = this._prevStoredLanguage; this._hidePopupCodeBlockLanguages(); } }, { key: '_onKeyEvent', value: function _onKeyEvent(event) { if (this._popupCodeBlockLanguages) { switch (event.which) { case _keyMapper2.default.keyCode('UP'): this._popupCodeBlockLanguages.prev(); event.preventDefault(); break; case _keyMapper2.default.keyCode('DOWN'): this._popupCodeBlockLanguages.next(); event.preventDefault(); break; case _keyMapper2.default.keyCode('ENTER'): case _keyMapper2.default.keyCode('TAB'): { var language = this._popupCodeBlockLanguages.getCurrentLanguage(); this._inputLanguage.value = language; this._storeInputLanguage(); event.preventDefault(); break; } default: this._popupCodeBlockLanguages.hide(); } } else if (event.which === _keyMapper2.default.keyCode('ENTER') || event.which === _keyMapper2.default.keyCode('TAB')) { this._storeInputLanguage(); event.preventDefault(); } } }, { key: '_onLanguageSelectedFromList', value: function _onLanguageSelectedFromList(selectedLanguage) { this._inputLanguage.value = selectedLanguage; this._storeInputLanguage(); } /** * set a callback to be called on language selected * @param {function} callback - callback function * @memberof CodeBlockLanguagesCombo */ }, { key: 'setOnLanguageSelected', value: function setOnLanguageSelected(callback) { this._onLanguageSelected = callback; } /** * hide popup * @private * @memberof CodeBlockGadget */ }, { key: '_hidePopupCodeBlockLanguages', value: function _hidePopupCodeBlockLanguages() { this._eventManager.emit('closePopupCodeBlockLanguages'); } /** * set language * @param {string} language - code block language * @memberof CodeBlockLanguagesCombo */ }, { key: 'setLanguage', value: function setLanguage(language) { this._prevStoredLanguage = language; this._inputLanguage.value = language; } /** * store selection(typed) language & hide popup * @private * @memberof CodeBlockGadget */ }, { key: '_storeInputLanguage', value: function _storeInputLanguage() { var selectedLanguage = this._inputLanguage.value; this.setLanguage(selectedLanguage); if (this._onLanguageSelected) { this._onLanguageSelected(selectedLanguage); } this._hidePopupCodeBlockLanguages(); } /** * get element body * @returns {HTMLElement} - CodeBlockLanguagesCombo body element * @memberof CodeBlockLanguagesCombo */ }, { key: 'getElement', value: function getElement() { return this._wrapper; } }]); return CodeBlockLanguagesCombo; }(); exports.default = CodeBlockLanguagesCombo; /***/ }), /* 89 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); var _emphasisCommon = __webpack_require__(33); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * @fileoverview Implements Bold markdown command * @author NHN Ent. FE Development Lab */ var boldRangeRegex = /^(\*{2}|_{2}).*\1$/; var boldContentRegex = /[*_]{2,}([^*_]*)[*_]{2,}/g; var boldSymbol = '**'; /** * Bold * Add bold markdown syntax to markdown editor * @extends Command * @module markdownCommands/Bold * @ignore */ var Bold = _commandManager2.default.command('markdown', /** @lends Bold */{ name: 'Bold', keyMap: ['CTRL+B', 'META+B'], /** * Command Handler * @param {MarkdownEditor} mde MarkdownEditor instance */ exec: function exec(mde) { var cm = mde.getEditor(); var doc = cm.getDoc(); var originRange = mde.getRange(); (0, _emphasisCommon.changeSyntax)(doc, originRange, boldSymbol, boldRangeRegex, boldContentRegex); cm.focus(); } }); exports.default = Bold; /***/ }), /* 90 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); var _emphasisCommon = __webpack_require__(33); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * @fileoverview Implements Italic markdown command * @author NHN Ent. FE Development Lab */ var boldItalicRangeRegex = /^(\*{3}|_{3}).*\1$/; var boldRangeRegex = /^(\*{2}|_{2}).*\1$/; var italicRangeRegex = /^(\*|_).*\1$/; var italicContentRegex = /([^*_])[*_]([^*_]+)[*_]([^*_])/g; var isBoldItalic = function isBoldItalic(t) { return boldItalicRangeRegex.test(t); }; var isBold = function isBold(t) { return boldRangeRegex.test(t); }; var isItalic = function isItalic(t) { return italicRangeRegex.test(t); }; var italicSymbol = '*'; var boldSymbol = '**'; var boldItalicSymbol = '***'; var italicLength = italicSymbol.length; var boldLength = boldSymbol.length; var boldItalicLength = boldItalicSymbol.length; /** * remove italic syntax in the middle of given text * @param {string} text - text selected * @returns {string} - text eliminated all italic in the middle of it's content * @ignore */ var removeItalicInsideText = function removeItalicInsideText(text) { return text ? text.replace(italicContentRegex, '$1$2$3') : ''; }; var replaceText = function replaceText(doc, text, range) { // Check 3 cases when both text and expand text // case 1 : bold & italic (when expand 3 both front and end) => remove italic // case 2 : bold (when expand 2 both front and end) => append // case 3 : italic (expand 1 both front and end) => remove var expandReplaceBind = _emphasisCommon.expandReplace.bind(this, doc, range); return expandReplaceBind(boldItalicLength, isBoldItalic, function (t) { return (0, _emphasisCommon.removeSyntax)(t, italicSymbol); }) || expandReplaceBind(boldLength, isBold, function (t) { return (0, _emphasisCommon.appendSyntax)(removeItalicInsideText(t), italicSymbol); }) || expandReplaceBind(italicLength, isItalic, function (t) { return (0, _emphasisCommon.removeSyntax)(t, italicSymbol); }) || (0, _emphasisCommon.replace)(doc, text, isBoldItalic, function (t) { return (0, _emphasisCommon.removeSyntax)(t, italicSymbol); }) || (0, _emphasisCommon.replace)(doc, text, isBold, function (t) { return (0, _emphasisCommon.appendSyntax)(removeItalicInsideText(t), italicSymbol); }) || (0, _emphasisCommon.replace)(doc, text, isItalic, function (t) { return (0, _emphasisCommon.removeSyntax)(t, italicSymbol); }); }; var replaceEmptyText = function replaceEmptyText(doc, range) { // Check 3 cases when expand text // case 1 : bold & italic => remove italic // case 2 : bold => append // case 3 : italic => remove // if there is no match, make italic return (0, _emphasisCommon.expandReplace)(doc, range, boldItalicLength, isBoldItalic, function (t) { return (0, _emphasisCommon.removeSyntax)(t, italicSymbol); }) || (0, _emphasisCommon.expandReplace)(doc, range, boldLength, isBold, function (t) { return (0, _emphasisCommon.appendSyntax)(t, italicSymbol); }) || (0, _emphasisCommon.expandReplace)(doc, range, italicLength, isItalic, function () { return ''; }) || doc.replaceSelection('' + italicSymbol + italicSymbol, 'around'); }; /** * Italic * Add italic markdown syntax to markdown editor * @extends Command * @module markdownCommands/Italic * @ignore */ var Italic = _commandManager2.default.command('markdown', /** @lends Italic */{ name: 'Italic', keyMap: ['CTRL+I', 'META+I'], /** * Command handler * @param {MarkdownEditor} mde MarkdownEditor instance */ exec: function exec(mde) { var cm = mde.getEditor(); var doc = cm.getDoc(); var _doc$getCursor = doc.getCursor(), line = _doc$getCursor.line, ch = _doc$getCursor.ch; var range = mde.getRange(); var selectionStr = doc.getSelection(); if (selectionStr) { // check selectionStr match bold & italic, bold, italic and then // if there is no match, append italic if (!replaceText(doc, selectionStr, range)) { // Before append italic, remove italic inside text and then append italic // Example: One*Two*Three => *OneTwoThree* doc.replaceSelection((0, _emphasisCommon.appendSyntax)(removeItalicInsideText(selectionStr), italicSymbol), 'around'); } } else { replaceEmptyText(doc, range); var afterSelectStr = doc.getSelection(); var size = ch; // If text was not selected, after replace text, move cursor if (isBoldItalic(afterSelectStr) || isItalic(afterSelectStr) && !isBold(afterSelectStr)) { // For example **|** => ***|*** (move cusor +symbolLenth) size += italicLength; } else { // For example *|* => | (move cusor -symbolLenth) size -= italicLength; } doc.setCursor(line, size); } cm.focus(); } }); exports.default = Italic; /***/ }), /* 91 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); var _emphasisCommon = __webpack_require__(33); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * @fileoverview Implements StrikeThrough markdown command * @author NHN Ent. FE Development Lab */ var strikeRangeRegex = /^~~.*~~$/; var strikeContentRegex = /~~([^~]*)~~/g; var strikeSymbol = '~~'; /** * Strike * Add strike markdown syntax to markdown editor * @extends Command * @module markdownCommands/Strike * @ignore */ var Strike = _commandManager2.default.command('markdown', /** @lends Strike */{ name: 'Strike', keyMap: ['CTRL+S', 'META+S'], /** * Command handler * @param {MarkdownEditor} mde MarkdownEditor instance */ exec: function exec(mde) { var cm = mde.getEditor(); var doc = cm.getDoc(); var originRange = mde.getRange(); (0, _emphasisCommon.changeSyntax)(doc, originRange, strikeSymbol, strikeRangeRegex, strikeContentRegex); cm.focus(); } }); exports.default = Strike; /***/ }), /* 92 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var BlockquoteRegex = /^> ?/; /** * Blockquote * Add blockquote markdown syntax to markdown editor * @extends Command * @module markdownCommands/Blockquote * @ignore */ /** * @fileoverview Implements Blockquote markdown command * @author NHN Ent. FE Development Lab */ var Blockquote = _commandManager2.default.command('markdown', /** @lends Blockquote */{ name: 'Blockquote', keyMap: ['ALT+Q', 'ALT+Q'], /** * command handler * @param {MarkdownEditor} mde MarkdownEditor instance */ exec: function exec(mde) { var cm = mde.getEditor(); var doc = cm.getDoc(); var range = mde.getCurrentRange(); var from = { line: range.from.line, ch: 0 }; var to = { line: range.to.line, ch: doc.getLineHandle(range.to.line).text.length }; var textToModify = doc.getRange(from, to); var textLinesToModify = textToModify.split('\n'); var isNeedToRemove = this._haveBlockquote(textLinesToModify); var resultText = void 0; if (isNeedToRemove) { resultText = this._removeBlockquote(textLinesToModify); } else { resultText = this._addBlockquote(textLinesToModify); } doc.replaceRange(resultText.join('\n'), from, to); if (isNeedToRemove) { var length = textLinesToModify.length; if (this._isBlockquoteWithSpace(textLinesToModify[length - 1])) { range.to.ch -= 2; } else { range.to.ch -= 1; } } else { range.to.ch += 2; } doc.setCursor(range.to); cm.focus(); }, /** * check all text in textArr starts with '>' * @param {Array} textArr - text array * @returns {boolean} - true if all text in textArr starts with '>' * @private */ _haveBlockquote: function _haveBlockquote(textArr) { for (var i = 0; i < textArr.length; i += 1) { if (!BlockquoteRegex.test(textArr[i])) { return false; } } return true; }, /** * add '> ' to all text in textArr * @param {Array} textArr - text array * @returns {Array} - new text array added '> ' * @private */ _addBlockquote: function _addBlockquote(textArr) { return textArr.map(function (text) { return '> ' + text; }); }, /** * remove '> ' or '>' to all text in textArr * @param {Array} textArr - text array * @returns {Array} - new text array removed '> ' or '>' * @private */ _removeBlockquote: function _removeBlockquote(textArr) { return textArr.map(function (text) { return text.replace(BlockquoteRegex, ''); }); }, /** * check text start '> ' * @param {string} text - text * @returns {boolean} - if text start '> ', true * @private */ _isBlockquoteWithSpace: function _isBlockquoteWithSpace(text) { return (/^> /.test(text) ); } }); exports.default = Blockquote; /***/ }), /* 93 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * @fileoverview Implements Heading markdown command * @author NHN Ent. FE Development Lab */ var FIND_HEADING_RX = /^#+\s/g; /** * Heading * Add heading markdown syntax to markdown editor * @extends Command * @module markdownCommands/Heading * @ignore */ var Heading = _commandManager2.default.command('markdown', /** @lends Heading */{ name: 'Heading', /** * Command Handler * @param {MarkdownEditor} mde MarkdownEditor instance * @param {number} size heading size */ exec: function exec(mde, size) { var cm = mde.getEditor(); var doc = cm.getDoc(); var range = mde.getCurrentRange(); var from = { line: range.from.line, ch: 0 }; var to = { line: range.to.line, ch: doc.getLineHandle(range.to.line).text.length }; var lengthOfCurrentLineBefore = doc.getLine(to.line).length; var textToModify = doc.getRange(from, to); var textLinesToModify = textToModify.split('\n'); _tuiCodeSnippet2.default.forEachArray(textLinesToModify, function (line, index) { textLinesToModify[index] = getHeadingMarkdown(line, size); }); doc.replaceRange(textLinesToModify.join('\n'), from, to); range.to.ch += doc.getLine(to.line).length - lengthOfCurrentLineBefore; doc.setSelection(from, range.to); cm.focus(); } }); /** * Get heading markdown * @param {string} text Source test * @param {number} size size * @returns {string} */ function getHeadingMarkdown(text, size) { var foundedHeading = text.match(FIND_HEADING_RX); var heading = ''; do { heading += '#'; size -= 1; } while (size > 0); if (foundedHeading) { var _text$split = text.split(foundedHeading[0]); text = _text$split[1]; } return heading + ' ' + text; } exports.default = Heading; /***/ }), /* 94 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Paragraph * Convert selected lines to paragraph * @extends Command * @module markdownCommands/Paragraph * @ignore */ /** * @fileoverview Implements Paragraph markdown command * @author NHN Ent. FE Development Lab */ var Paragraph = _commandManager2.default.command('markdown', /** @lends Paragraph */{ name: 'Paragraph', /** * Command Handler * @param {MarkdownEditor} mde MarkdownEditor instance */ exec: function exec(mde) { var cm = mde.getEditor(); var doc = cm.getDoc(); var range = mde.getCurrentRange(); var from = { line: range.from.line, ch: 0 }; var to = { line: range.to.line, ch: doc.getLineHandle(range.to.line).text.length }; var lengthOfCurrentLineBefore = doc.getLine(to.line).length; var textToModify = doc.getRange(from, to); var textLines = textToModify.split('\n'); _tuiCodeSnippet2.default.forEachArray(textLines, function (line, index) { textLines[index] = getParagraphMarkdown(line); }); doc.replaceRange(textLines.join('\n'), from, to); range.to.ch += doc.getLine(to.line).length - lengthOfCurrentLineBefore; doc.setSelection(from, to); cm.focus(); } }); /** * Get paragraph markdown lineText * @param {string} lineText line lineText * @returns {string} */ function getParagraphMarkdown(lineText) { var headingRx = /^(#{1,6}| *((?:\*|-|\d\.)(?: \[[ xX]])?)) /; return lineText.replace(headingRx, ''); } exports.default = Paragraph; /***/ }), /* 95 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * HR * Add HR markdown syntax to markdown editor * @extends Command * @module markdownCommands/HR * @ignore */ var HR = _commandManager2.default.command('markdown', /** @lends HR */{ name: 'HR', keyMap: ['CTRL+L', 'META+L'], /** * Command handler * @param {MarkdownEditor} mde MarkdownEditor instance */ exec: function exec(mde) { var cm = mde.getEditor(); var doc = cm.getDoc(); var replaceText = ''; var range = mde.getCurrentRange(); var from = { line: range.from.line, ch: range.from.ch }; var to = { line: range.to.line, ch: range.to.ch }; if (range.collapsed) { replaceText = doc.getLine(from.line); from.ch = 0; to.ch = doc.getLineHandle(range.to.line).text.length; } if (doc.getLine(from.line).length) { replaceText += '\n\n* * *\n\n'; } else { replaceText += '\n* * *\n'; } doc.replaceRange(replaceText, from, to); cm.focus(); } }); /** * @fileoverview Implements HR markdown command * @author NHN Ent. FE Development Lab */ exports.default = HR; /***/ }), /* 96 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); var _importManager = __webpack_require__(10); var _importManager2 = _interopRequireDefault(_importManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * @fileoverview Implements Addlink markdown command * @author NHN Ent. FE Development Lab */ var decodeURIGraceful = _importManager2.default.decodeURIGraceful, encodeMarkdownCharacters = _importManager2.default.encodeMarkdownCharacters, escapeMarkdownCharacters = _importManager2.default.escapeMarkdownCharacters; /** * AddLink * Add link markdown syntax to markdown editor * @extends Command * @module markdownCommands/AddLink * @ignore */ var AddLink = _commandManager2.default.command('markdown', /** @lends AddLink */{ name: 'AddLink', /** * command handler for AddLink * @param {MarkdownEditor} mde - MarkdownEditor instance * @param {object} data - data for image */ exec: function exec(mde, data) { var cm = mde.getEditor(); var doc = cm.getDoc(); var range = mde.getCurrentRange(); var from = { line: range.from.line, ch: range.from.ch }; var to = { line: range.to.line, ch: range.to.ch }; var linkText = data.linkText, url = data.url; linkText = decodeURIGraceful(linkText); linkText = escapeMarkdownCharacters(linkText); url = encodeMarkdownCharacters(url); var replaceText = '[' + linkText + '](' + url + ')'; doc.replaceRange(replaceText, from, to); cm.focus(); } }); exports.default = AddLink; /***/ }), /* 97 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); var _importManager = __webpack_require__(10); var _importManager2 = _interopRequireDefault(_importManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * @fileoverview Implments AddImage markdown command * @author NHN Ent. FE Development Lab */ var decodeURIGraceful = _importManager2.default.decodeURIGraceful, encodeMarkdownCharacters = _importManager2.default.encodeMarkdownCharacters, escapeMarkdownCharacters = _importManager2.default.escapeMarkdownCharacters; /** * AddImage * Add Image markdown syntax to markdown Editor * @extends Command * @module markdownCommands/AddImage * @ignore */ var AddImage = _commandManager2.default.command('markdown', /** @lends AddImage */{ name: 'AddImage', /** * Command Handler * @param {MarkdownEditor} mde MarkdownEditor instance * @param {object} data data for image */ exec: function exec(mde, data) { var cm = mde.getEditor(); var doc = cm.getDoc(); var range = mde.getCurrentRange(); var from = { line: range.from.line, ch: range.from.ch }; var to = { line: range.to.line, ch: range.to.ch }; var altText = data.altText, imageUrl = data.imageUrl; altText = decodeURIGraceful(altText); altText = escapeMarkdownCharacters(altText); imageUrl = encodeMarkdownCharacters(imageUrl); var replaceText = '![' + altText + '](' + imageUrl + ')'; doc.replaceRange(replaceText, from, to, '+addImage'); cm.focus(); } }); exports.default = AddImage; /***/ }), /* 98 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * UL * Add unordered list markdown syntax to markdown editor * @extends Command * @module markdownCommands/UL * @ignore */ var UL = _commandManager2.default.command('markdown', /** @lends UL */{ name: 'UL', keyMap: ['CTRL+U', 'META+U'], /** * Command handler * @param {MarkdownEditor} mde MarkdownEditor instance */ exec: function exec(mde) { var range = mde.getCurrentRange(); var listManager = mde.componentManager.getManager('list'); listManager.changeSyntax(range, 'ul'); } }); /** * @fileoverview Implements UL markdown command * @author NHN Ent. FE Development Lab */ exports.default = UL; /***/ }), /* 99 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * OL * Add ordered list markdown syntax to markdown editor * @extends Command * @module markdownCommands/OL * @ignore */ var OL = _commandManager2.default.command('markdown', /** @lends OL */{ name: 'OL', keyMap: ['CTRL+O', 'META+O'], /** * Command handler * @param {MarkdownEditor} mde MarkdownEditor instance */ exec: function exec(mde) { var range = mde.getCurrentRange(); var listManager = mde.componentManager.getManager('list'); listManager.changeSyntax(range, 'ol'); } }); /** * @fileoverview Implements OL markdown command * @author NHN Ent. FE Development Lab */ exports.default = OL; /***/ }), /* 100 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Indent * Add Indent markdown syntax to markdown editor * @extends Command * @module markdownCommands/inent * @ignore */ var Indent = _commandManager2.default.command('markdown', /** @lends Indent */{ name: 'Indent', /** * Command handler * @param {MarkdownEditor} mde MarkdownEditor instance */ exec: function exec(mde) { var cm = mde.getEditor(); cm.execCommand('indentOrderedList'); } }); /** * @fileoverview Implements Indent markdown command * @author NHN Ent. FE Development Lab */ exports.default = Indent; /***/ }), /* 101 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Outdent * Add Outdent markdown syntax to markdown editor * @extends Command * @module markdownCommands/outdent * @ignore */ var Outdent = _commandManager2.default.command('markdown', /** @lends Outdent */{ name: 'Outdent', /** * Command handler * @param {MarkdownEditor} mde MarkdownEditor instance */ exec: function exec(mde) { var cm = mde.getEditor(); cm.execCommand('indentLessOrderedList'); } }); /** * @fileoverview Implements Outdent markdown command * @author NHN Ent. FE Development Lab */ exports.default = Outdent; /***/ }), /* 102 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Table * Add table markdown syntax to markdown editor * @extends Command * @module markdownCommands/Table * @ignore */ var Table = _commandManager2.default.command('markdown', /** @lends Table */{ name: 'Table', /** * Command handler * @param {MarkdownEditor} mde MarkdownEditor instance * @param {number} col column count * @param {number} row row count * @param {Array} data initial table data */ exec: function exec(mde, col, row, data) { var cm = mde.getEditor(); var doc = cm.getDoc(); var table = '\n'; if (cm.getCursor().ch > 0) { table += '\n'; } table += makeHeader(col, data); table += makeBody(col, row - 1, data); doc.replaceSelection(table); if (!data) { cm.setCursor(cm.getCursor().line - row, 2); } mde.focus(); } }); /** * makeHeader * make table header markdown string * @param {number} col Column count * @param {array} data Cell's text content * @returns {string} markdown string */ /** * @fileoverview Implements Table markdown command * @author NHN Ent. FE Development Lab */ function makeHeader(col, data) { var header = '|'; var border = '|'; var index = 0; while (col) { if (data) { header += ' ' + data[index] + ' |'; index += 1; } else { header += ' |'; } border += ' --- |'; col -= 1; } return header + '\n' + border + '\n'; } /** * makeBody * make table body markdown string * @param {number} col column count * @param {number} row row count * @param {Array} data initial table data * @returns {string} html string */ function makeBody(col, row, data) { var body = ''; var index = col; for (var irow = 0; irow < row; irow += 1) { body += '|'; for (var icol = 0; icol < col; icol += 1) { if (data) { body += ' ' + data[index] + ' |'; index += 1; } else { body += ' |'; } } body += '\n'; } body = body.replace(/\n$/g, ''); return body; } exports.default = Table; /***/ }), /* 103 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Task * @extends Command * @module markdownCommands/Task * @ignore */ var Task = _commandManager2.default.command('markdown', /** @lends Task */{ name: 'Task', keyMap: ['ALT+T', 'ALT+T'], /** * Command handler * @param {MarkdownEditor} mde MarkdownEditor instance */ exec: function exec(mde) { var range = mde.getCurrentRange(); var listManager = mde.componentManager.getManager('list'); listManager.changeSyntax(range, 'task'); } }); /** * @fileoverview Implements Task markdown command * @author NHN Ent. FE Development Lab */ exports.default = Task; /***/ }), /* 104 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var codeRangeRegex = /^`([^`]+)`$/; /** * @fileoverview Implements Code markdown command * @author NHN Ent. FE Development Lab */ var codeContentRegex = /`([^`]+)`/g; /** * Code * Add code markdown syntax to markdown editor * @extends Command * @module markdownCommands/Code * @ignore */ var Code = _commandManager2.default.command('markdown', /** @lends Code */{ name: 'Code', keyMap: ['SHIFT+CTRL+C', 'SHIFT+META+C'], /** * Command Handler * @param {MarkdownEditor} mde MarkdownEditor instance */ exec: function exec(mde) { var cm = mde.getEditor(); var doc = cm.getDoc(); var selection = doc.getSelection(); var cursor = cm.getCursor(); var hasSyntax = this.hasStrikeSyntax(selection); var result = void 0; if (hasSyntax) { result = this.remove(selection); result = this._removeCodeSyntax(result); } else { result = this._removeCodeSyntax(selection); result = this.append(result); } doc.replaceSelection(result, 'around'); if (!selection && !hasSyntax) { this.setCursorToCenter(doc, cursor, hasSyntax); } cm.focus(); }, /** * set cursor to center * @param {CodeMirror.doc} doc - codemirror document * @param {object} cursor - codemirror cursor * @param {boolean} isRemoved - whether it involes deletion */ setCursorToCenter: function setCursorToCenter(doc, cursor, isRemoved) { var pos = isRemoved ? -1 : 1; doc.setCursor(cursor.line, cursor.ch + pos); }, /** * has code syntax * @param {string} text Source text * @returns {boolean} true if the given text has a code syntax */ hasStrikeSyntax: function hasStrikeSyntax(text) { return codeRangeRegex.test(text); }, /** * apply Code * @param {string} text - selected text * @returns {string} - text after code syntax applied */ append: function append(text) { return '`' + text + '`'; }, /** * remove Code * @param {string} text - selected text * @returns {string} - text after code syntax removed */ remove: function remove(text) { return text.substr(1, text.length - 2); }, /** * remove bold syntax in the middle of given text * @param {string} text - text selected * @returns {string} - text eliminated all code in the middle of it's content * @private */ _removeCodeSyntax: function _removeCodeSyntax(text) { return text ? text.replace(codeContentRegex, '$1') : ''; } }); exports.default = Code; /***/ }), /* 105 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * CodeBlock * Add CodeBlock markdown syntax to markdown editor * @extends Command * @module markdownCommands/CodeBlock * @ignore */ var CodeBlock = _commandManager2.default.command('markdown', /** @lends CodeBlock */{ name: 'CodeBlock', keyMap: ['SHIFT+CTRL+P', 'SHIFT+META+P'], /** * Command handler * @param {MarkdownEditor} mde MarkdownEditor instance */ exec: function exec(mde) { var cm = mde.getEditor(); var doc = cm.getDoc(); var range = mde.getCurrentRange(); var replaceText = ['```', doc.getSelection(), '```']; var cursorOffset = 1; // insert a line break to the front if the selection starts in the middle of a text if (range.from.ch !== 0) { replaceText.unshift(''); cursorOffset += 1; } // insert a line break to the end if the selection has trailing text if (range.to.ch !== doc.getLine(range.to.line).length) { replaceText.push(''); } doc.replaceSelection(replaceText.join('\n')); cm.setCursor(range.from.line + cursorOffset, 0); cm.focus(); } }); /** * @fileoverview Implements CodeBlock markdown command * @author NHN Ent. FE Development Lab */ exports.default = CodeBlock; /***/ }), /* 106 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Bold * Add bold to selected wysiwyg editor content * @extends Command * @module wysiwygCommands/Bold * @ignore */ var Bold = _commandManager2.default.command('wysiwyg', /** @lends Bold */{ name: 'Bold', keyMap: ['CTRL+B', 'META+B'], /** * command handler * @param {WysiwygEditor} wwe wysiwygEditor instance */ exec: function exec(wwe) { var sq = wwe.getEditor(); var tableSelectionManager = wwe.componentManager.getManager('tableSelection'); wwe.focus(); if (sq.hasFormat('table') && tableSelectionManager.getSelectedCells().length) { tableSelectionManager.styleToSelectedCells(styleBold); var range = sq.getSelection(); range.collapse(true); sq.setSelection(range); } else { styleBold(sq); } } }); /** * Style bold. * @param {object} sq - squire editor instance */ /** * @fileoverview Implements bold WysiwygCommand * @author NHN Ent. FE Development Lab */ function styleBold(sq) { if (sq.hasFormat('b') || sq.hasFormat('strong')) { sq.changeFormat(null, { tag: 'b' }); } else if (!sq.hasFormat('a') && !sq.hasFormat('PRE')) { if (sq.hasFormat('code')) { sq.changeFormat(null, { tag: 'code' }); } sq.bold(); } } exports.default = Bold; /***/ }), /* 107 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Italic * Add Italic to selected wysiwyg editor content * @extends Command * @module wysiwygCommands/Italic * @ignore */ var Italic = _commandManager2.default.command('wysiwyg', /** @lends Italic */{ name: 'Italic', keyMap: ['CTRL+I', 'META+I'], /** * command handler * @param {WysiwygEditor} wwe wysiwygEditor instance */ exec: function exec(wwe) { var sq = wwe.getEditor(); var tableSelectionManager = wwe.componentManager.getManager('tableSelection'); wwe.focus(); if (sq.hasFormat('table') && tableSelectionManager.getSelectedCells().length) { tableSelectionManager.styleToSelectedCells(styleItalic); var range = sq.getSelection(); range.collapse(true); sq.setSelection(range); } else { styleItalic(sq); } } }); /** * Style italic. * @param {object} sq - squire editor instance */ /** * @fileoverview Implements italic WysiwygCommand * @author NHN Ent. FE Development Lab */ function styleItalic(sq) { if (sq.hasFormat('i') || sq.hasFormat('em')) { sq.changeFormat(null, { tag: 'i' }); } else if (!sq.hasFormat('a') && !sq.hasFormat('PRE')) { if (sq.hasFormat('code')) { sq.changeFormat(null, { tag: 'code' }); } sq.italic(); } } exports.default = Italic; /***/ }), /* 108 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Strike * Add strike to selected wysiwyg editor content * @extends Command * @module wysiwygCommands/Strike * @ignore */ var Strike = _commandManager2.default.command('wysiwyg', /** @lends Strike */{ name: 'Strike', keyMap: ['CTRL+S', 'META+S'], /** * command handler * @param {WysiwygEditor} wwe WysiwygEditor instance */ exec: function exec(wwe) { var sq = wwe.getEditor(); var tableSelectionManager = wwe.componentManager.getManager('tableSelection'); wwe.focus(); if (sq.hasFormat('table') && tableSelectionManager.getSelectedCells().length) { tableSelectionManager.styleToSelectedCells(styleStrike); var range = sq.getSelection(); range.collapse(true); sq.setSelection(range); } else { styleStrike(sq); } } }); /** * Style strike. * @param {object} sq - squire editor instance */ /** * @fileoverview Implements strike WysiwygCommand * @author NHN Ent. FE Development Lab */ function styleStrike(sq) { if (sq.hasFormat('S')) { sq.changeFormat(null, { tag: 'S' }); } else if (!sq.hasFormat('a') && !sq.hasFormat('PRE')) { if (sq.hasFormat('code')) { sq.changeFormat(null, { tag: 'code' }); } sq.strikethrough(); } } exports.default = Strike; /***/ }), /* 109 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Blockquote * Add Blockquote to selected wysiwyg editor content * @extends Command * @module wysiwygCommands/Blockquote * @ignore */ var Blockquote = _commandManager2.default.command('wysiwyg', /** @lends Blockquote */{ name: 'Blockquote', keyMap: ['ALT+Q', 'ALT+Q'], /** * command handler * @param {WysiwygEditor} wwe wysiwygEditor instance */ exec: function exec(wwe) { var sq = wwe.getEditor(); wwe.focus(); if (!sq.hasFormat('TABLE') && !sq.hasFormat('PRE')) { if (sq.hasFormat('BLOCKQUOTE')) { sq.decreaseQuoteLevel(); } else { sq.increaseQuoteLevel(); } } } }); /** * @fileoverview Implements block quote WysiwygCommand * @author NHN Ent. FE Development Lab */ exports.default = Blockquote; /***/ }), /* 110 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); var _importManager = __webpack_require__(10); var _importManager2 = _interopRequireDefault(_importManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * @fileoverview Implements AddImage wysiwyg command * @author NHN Ent. FE Development Lab */ var decodeURIGraceful = _importManager2.default.decodeURIGraceful, encodeMarkdownCharacters = _importManager2.default.encodeMarkdownCharacters; /** * AddImage * Add Image markdown syntax to wysiwyg Editor * @extends Command * @module wysiwygCommands/AddImage * @ignore */ var AddImage = _commandManager2.default.command('wysiwyg', /** @lends AddImage */{ name: 'AddImage', /** * command handler * @param {WysiwygEditor} wwe wysiwygEditor instance * @param {object} data data for image */ exec: function exec(wwe, data) { var sq = wwe.getEditor(); var altText = data.altText, imageUrl = data.imageUrl; altText = decodeURIGraceful(altText); imageUrl = encodeMarkdownCharacters(imageUrl); wwe.focus(); if (!sq.hasFormat('PRE')) { sq.insertImage(imageUrl, { 'alt': altText }); } } }); exports.default = AddImage; /***/ }), /* 111 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); var _importManager = __webpack_require__(10); var _importManager2 = _interopRequireDefault(_importManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var decodeURIGraceful = _importManager2.default.decodeURIGraceful, encodeMarkdownCharacters = _importManager2.default.encodeMarkdownCharacters; /** * AddLink * Add link markdown syntax to wysiwyg Editor * @extends Command * @module wysiwygCommands/AddLink * @ignore */ /** * @fileoverview Implements AddLink wysiwyg command * @author NHN Ent. FE Development Lab */ var AddLink = _commandManager2.default.command('wysiwyg', /** @lends AddLink */{ name: 'AddLink', /** * command handler * @param {WysiwygEditor} wwe - wysiwygEditor instance * @param {object} data - data for image */ exec: function exec(wwe, data) { var sq = wwe.getEditor(); var url = data.url, linkText = data.linkText; linkText = decodeURIGraceful(linkText); url = encodeMarkdownCharacters(url); wwe.focus(); if (!sq.hasFormat('PRE')) { sq.removeAllFormatting(); if (sq.getSelectedText()) { sq.makeLink(url); } else { var link = sq.createElement('A', { href: url }); (0, _jquery2.default)(link).text(linkText); sq.insertElement(link); } } } }); exports.default = AddLink; /***/ }), /* 112 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); var _domUtils = __webpack_require__(4); var _domUtils2 = _interopRequireDefault(_domUtils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * HR * Add horizontal line markdown syntax to wysiwyg Editor * @extends Command * @module wysiwygCommands/HR * @ignore */ /** * @fileoverview Implements HR wysiwyg command * @author NHN Ent. FE Development Lab */ var HR = _commandManager2.default.command('wysiwyg', /** @lends HR */{ name: 'HR', keyMap: ['CTRL+L', 'META+L'], /** * command handler * @param {WysiwygEditor} wwe wysiwygEditor instance */ exec: function exec(wwe) { var sq = wwe.getEditor(); var range = sq.getSelection(); var currentNode = void 0, nextBlockNode = void 0, previousSibling = void 0; if (range.collapsed && !sq.hasFormat('TABLE') && !sq.hasFormat('PRE')) { currentNode = _domUtils2.default.getChildNodeByOffset(range.startContainer, range.startOffset); nextBlockNode = _domUtils2.default.getTopNextNodeUnder(currentNode, wwe.get$Body()[0]); if (!nextBlockNode) { nextBlockNode = sq.createDefaultBlock(); wwe.get$Body().append(nextBlockNode); } var hr = sq.createElement('HR'); sq.modifyBlocks(function (frag) { frag.appendChild(hr); return frag; }); previousSibling = hr.previousSibling; if (previousSibling && _domUtils2.default.isTextNode(previousSibling) && _domUtils2.default.getTextLength(previousSibling) === 0) { hr.parentNode.removeChild(previousSibling); } range.selectNodeContents(nextBlockNode); range.collapse(true); sq.setSelection(range); } wwe.focus(); } }); exports.default = HR; /***/ }), /* 113 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Heading * Convert selected root level contents to heading with size wysiwyg Editor * @extends Command * @module wysiwygCommands/Heading * @ignore */ /** * @fileoverview Implements Heading wysiwyg command * @author NHN Ent. FE Development Lab */ var Heading = _commandManager2.default.command('wysiwyg', /** @lends Heading */{ name: 'Heading', /** * Command handler * @param {WysiwygEditor} wwe WYSIWYGEditor instance * @param {Number} size size */ exec: function exec(wwe, size) { var sq = wwe.getEditor(); var blockTagName = 'h1, h2, h3, h4, h5, h6, div'; wwe.focus(); if (!sq.hasFormat('TABLE') && !sq.hasFormat('PRE')) { sq.modifyBlocks(function (fragment) { (0, _jquery2.default)(fragment).children(blockTagName).each(function (index, block) { var headingHTML = ''; var $block = (0, _jquery2.default)(block); if ($block.is('DIV')) { $block.wrap(headingHTML); } else { var $wrapperHeading = (0, _jquery2.default)(headingHTML); $wrapperHeading.insertBefore(block); $wrapperHeading.html($block.html()); $block.remove(); } }); return fragment; }); } } }); exports.default = Heading; /***/ }), /* 114 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Paragraph * Convert selected contents to paragraph only heading and list * @extends Command * @module wysiwygCommands/Paragraph * @ignore */ /** * @fileoverview Implements Paragraph wysiwyg command * @author NHN Ent. FE Development Lab */ var Paragraph = _commandManager2.default.command('wysiwyg', /** @lends Paragraph */{ name: 'Paragraph', /** * Command handler * @param {WysiwygEditor} wwe WYSIWYGEditor instance */ exec: function exec(wwe) { var sq = wwe.getEditor(); wwe.focus(); if (!sq.hasFormat('TABLE') && !sq.hasFormat('PRE')) { sq.modifyBlocks(function (fragment) { var $newFragment = (0, _jquery2.default)(document.createDocumentFragment()); (0, _jquery2.default)(fragment).children().each(function (index, block) { if (block.nodeName.match(/h\d/i)) { $newFragment.append((0, _jquery2.default)(block).children()); } else if (block.nodeName.match(/ul|ol/i)) { (0, _jquery2.default)(block).find('li').each(function (i, listItem) { $newFragment.append((0, _jquery2.default)(listItem).children()); }); } else { $newFragment.append(block); } }); return $newFragment[0]; }); } } }); exports.default = Paragraph; /***/ }), /* 115 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); var _domUtils = __webpack_require__(4); var _domUtils2 = _interopRequireDefault(_domUtils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * UL * Add UL to selected wysiwyg editor content * @extends Command * @module wysiwygCommands/UL * @ignore */ /** * @fileoverview Implements ul WysiwygCommand * @author NHN Ent. FE Development Lab */ var UL = _commandManager2.default.command('wysiwyg', /** @lends UL */{ name: 'UL', keyMap: ['CTRL+U', 'META+U'], /** * Command Handler * @param {WysiwygEditor} wwe WYSIWYGEditor instance */ exec: function exec(wwe) { var sq = wwe.getEditor(); var range = sq.getSelection(); var listManager = wwe.componentManager.getManager('list'); var startContainer = range.startContainer, endContainer = range.endContainer, startOffset = range.startOffset, endOffset = range.endOffset; wwe.focus(); sq.saveUndoState(range); var lines = listManager.getLinesOfSelection(startContainer, endContainer); var newLIs = []; for (var i = 0; i < lines.length; i += 1) { var newLI = this._changeFormatToUnorderedListIfNeed(wwe, lines[i]); if (newLI) { newLIs.push(newLI); } } if (newLIs.length) { var newStartContainer = _domUtils2.default.containsNode(newLIs[0], startContainer) ? startContainer : newLIs[0]; var newEndContainer = _domUtils2.default.containsNode(newLIs[newLIs.length - 1], endContainer) ? endContainer : newLIs[newLIs.length - 1]; wwe.setSelectionByContainerAndOffset(newStartContainer, startOffset, newEndContainer, endOffset); } }, /** * Change format to unordered list if need * @param {WysiwygEditor} wwe Wysiwyg editor instance * @param {HTMLElement} target Element target for change * @returns {HTMLElement} newly created list * @private */ _changeFormatToUnorderedListIfNeed: function _changeFormatToUnorderedListIfNeed(wwe, target) { var sq = wwe.getEditor(); var range = sq.getSelection(); var taskManager = wwe.componentManager.getManager('task'); var newLI = void 0; if (!sq.hasFormat('TABLE') && !sq.hasFormat('PRE')) { range.setStart(target, 0); range.collapse(true); sq.setSelection(range); if (sq.hasFormat('LI')) { wwe.saveSelection(range); taskManager.unformatTask(range.startContainer); sq.replaceParent(range.startContainer, 'ol', 'ul'); wwe.restoreSavedSelection(); } else { wwe.unwrapBlockTag(); sq.makeUnorderedList(); } newLI = sq.getSelection().startContainer; } return newLI; } }); exports.default = UL; /***/ }), /* 116 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); var _domUtils = __webpack_require__(4); var _domUtils2 = _interopRequireDefault(_domUtils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * OL * Add OL to selected wysiwyg editor content * @extends Command * @module wysiwygCommands/OL * @ignore */ /** * @fileoverview Implements ol WysiwygCommand * @author NHN Ent. FE Development Lab */ var OL = _commandManager2.default.command('wysiwyg', /** @lends OL */{ name: 'OL', keyMap: ['CTRL+O', 'META+O'], /** * Command Handler * @param {WysiwygEditor} wwe WYSIWYGEditor instance */ exec: function exec(wwe) { var sq = wwe.getEditor(); var range = sq.getSelection(); var listManager = wwe.componentManager.getManager('list'); var startContainer = range.startContainer, startOffset = range.startOffset, endContainer = range.endContainer, endOffset = range.endOffset; wwe.focus(); sq.saveUndoState(range); var lines = listManager.getLinesOfSelection(startContainer, endContainer); var newLIs = []; for (var i = 0; i < lines.length; i += 1) { var newLI = this._changeFormatToOrderedListIfNeed(wwe, lines[i]); if (newLI) { newLIs.push(newLI); } } if (newLIs.length) { var newStartContainer = _domUtils2.default.containsNode(newLIs[0], startContainer) ? startContainer : newLIs[0]; var newEndContainer = _domUtils2.default.containsNode(newLIs[newLIs.length - 1], endContainer) ? endContainer : newLIs[newLIs.length - 1]; wwe.setSelectionByContainerAndOffset(newStartContainer, startOffset, newEndContainer, endOffset); } }, /** * Change format to unordered list if need * @param {WysiwygEditor} wwe Wysiwyg editor instance * @param {HTMLElement} target Element target for change * @returns {HTMLElement} newly created list item * @private */ _changeFormatToOrderedListIfNeed: function _changeFormatToOrderedListIfNeed(wwe, target) { var sq = wwe.getEditor(); var range = sq.getSelection(); var taskManager = wwe.componentManager.getManager('task'); var newLI = void 0; if (!sq.hasFormat('TABLE') && !sq.hasFormat('PRE')) { range.setStart(target, 0); range.collapse(true); sq.setSelection(range); if (sq.hasFormat('LI')) { wwe.saveSelection(range); taskManager.unformatTask(range.startContainer); sq.replaceParent(range.startContainer, 'ul', 'ol'); wwe.restoreSavedSelection(); } else { wwe.unwrapBlockTag(); sq.makeOrderedList(); } newLI = sq.getSelection().startContainer; } return newLI; } }); exports.default = OL; /***/ }), /* 117 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Table * Add table to selected wysiwyg editor content * @extends Command * @module wysiwygCommands/Table * @ignore */ var Table = _commandManager2.default.command('wysiwyg', /** @lends Table */{ name: 'Table', /** * Command Handler * @param {WysiwygEditor} wwe wysiwygEditor instance * @param {number} col column count * @param {number} row row count * @param {Array} data initial table data */ exec: function exec(wwe, col, row, data) { var sq = wwe.getEditor(); var tableIDClassName = wwe.componentManager.getManager('table').getTableIDClassName(); var tableHTMLString = void 0; if (!sq.getSelection().collapsed || sq.hasFormat('TABLE') || sq.hasFormat('PRE')) { wwe.focus(); return; } tableHTMLString = ''; tableHTMLString += makeHeader(col, data); tableHTMLString += makeBody(col, row - 1, data); tableHTMLString += '
'; sq.insertHTML(tableHTMLString); wwe.focus(); if (!data) { focusToFirstTh(sq, wwe.get$Body().find('.' + tableIDClassName)); } } }); /** * Focus to first th * @param {Squire} sq Squire instance * @param {jQuery} $table jQuery wrapped table element */ /** * @fileoverview Implements table WysiwygCommand * @author NHN Ent. FE Development Lab */ function focusToFirstTh(sq, $table) { var range = sq.getSelection(); range.selectNodeContents($table.find('th')[0]); range.collapse(true); sq.setSelection(range); } /** * makeHeader * make table header html string * @param {number} col column count * @param {string} data cell data * @returns {string} html string */ function makeHeader(col, data) { var header = ''; var index = 0; while (col) { header += ''; if (data) { header += data[index]; index += 1; } header += ''; col -= 1; } header += ''; return header; } /** * makeBody * make table body html string * @param {number} col column count * @param {number} row row count * @param {string} data cell data * @returns {string} html string */ function makeBody(col, row, data) { var body = ''; var index = col; for (var irow = 0; irow < row; irow += 1) { body += ''; for (var icol = 0; icol < col; icol += 1) { body += ''; if (data) { body += data[index]; index += 1; } body += ''; } body += ''; } body += ''; return body; } exports.default = Table; /***/ }), /* 118 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * AddRow * Add Row to selected table * @extends Command * @module wysiwygCommands/TableAddRow * @ignore */ var TableAddRow = _commandManager2.default.command('wysiwyg', /** @lends AddRow */{ name: 'AddRow', /** * command handler * @param {WysiwygEditor} wwe wysiwygEditor instance */ exec: function exec(wwe) { var sq = wwe.getEditor(); var range = sq.getSelection().cloneRange(); var selectedRowLength = getSelectedRowsLength(wwe); var $tr = void 0, $newRow = void 0; wwe.focus(); if (sq.hasFormat('TD')) { sq.saveUndoState(range); $tr = (0, _jquery2.default)(range.startContainer).closest('tr'); for (var i = 0; i < selectedRowLength; i += 1) { $newRow = getNewRow($tr); $newRow.insertAfter($tr); } focusToFirstTd(sq, $newRow); } else if (sq.hasFormat('TH')) { sq.saveUndoState(range); $tr = (0, _jquery2.default)(range.startContainer).parents('thead').next('tbody').children('tr').eq(0); for (var _i = 0; _i < selectedRowLength; _i += 1) { $newRow = getNewRow($tr); $newRow.insertBefore($tr); } focusToFirstTd(sq, $newRow); } } }); /** * get number of selected rows * @param {WysiwygEditor} wwe - wysiwygEditor instance * @returns {number} - number of selected rows * @ignore */ /** * @fileoverview Implements table add row WysiwygCommand * @author NHN Ent. FE Development Lab */ function getSelectedRowsLength(wwe) { var selectionMgr = wwe.componentManager.getManager('tableSelection'); var $selectedCells = selectionMgr.getSelectedCells(); var length = 1; if ($selectedCells.length > 1) { var first = $selectedCells.first().get(0); var last = $selectedCells.last().get(0); var range = selectionMgr.getSelectionRangeFromTable(first, last); length = range.to.row - range.from.row + 1; } return length; } /** * Get new row of given row * @param {jQuery} $tr - jQuery wrapped table row * @returns {jQuery} - new cloned jquery element * @ignore */ function getNewRow($tr) { var cloned = $tr.clone(); var htmlString = _tuiCodeSnippet2.default.browser.msie ? '' : '
'; cloned.find('td').html(htmlString); return cloned; } /** * Focus to first table cell * @param {Squire} sq - Squire instance * @param {jQuery} $tr - jQuery wrapped table row * @ignore */ function focusToFirstTd(sq, $tr) { var range = sq.getSelection(); range.selectNodeContents($tr.find('td')[0]); range.collapse(true); sq.setSelection(range); } exports.default = TableAddRow; /***/ }), /* 119 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); var _domUtils = __webpack_require__(4); var _domUtils2 = _interopRequireDefault(_domUtils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * AddCol * Add col to selected table * @extends Command * @module wysiwygCommands/TableAddCol * @ignore */ /** * @fileoverview Implements table add column WysiwygCommand * @author NHN Ent. FE Development Lab */ var TableAddCol = _commandManager2.default.command('wysiwyg', /** @lends AddCol */{ name: 'AddCol', /** * command handler * @param {WysiwygEditor} wwe wysiwygEditor instance */ exec: function exec(wwe) { var sq = wwe.getEditor(); var range = sq.getSelection().cloneRange(); var numberOfCols = getNumberOfCols(wwe); var $cell = void 0; wwe.focus(); if (sq.hasFormat('TR')) { sq.saveUndoState(range); $cell = getCellByRange(range); addColToCellAfter($cell, numberOfCols); focusToNextCell(sq, $cell); } } }); /** * get number of selected cols * @param {WysiwygEditor} wwe - wysiwyg editor instance * @returns {number} - number of selected cols * @ignore */ function getNumberOfCols(wwe) { var selectionMgr = wwe.componentManager.getManager('tableSelection'); var $selectedCells = selectionMgr.getSelectedCells(); var length = 1; if ($selectedCells.length > 0) { var maxLength = $selectedCells.get(0).parentNode.querySelectorAll('td, th').length; length = Math.min(maxLength, $selectedCells.length); } return length; } /** * Get cell by range object * @param {Range} range - range * @returns {jQuery} - jQuery html element * @ignore */ function getCellByRange(range) { var cell = range.startContainer; if (_domUtils2.default.getNodeName(cell) === 'TD' || _domUtils2.default.getNodeName(cell) === 'TH') { cell = (0, _jquery2.default)(cell); } else { cell = (0, _jquery2.default)(cell).parentsUntil('tr'); } return cell; } /** * Add column to after the current cell * @param {jQuery} $cell - jQuery wrapped table cell * @param {number} [numberOfCols=1] - number of cols * @ignore */ function addColToCellAfter($cell) { var numberOfCols = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; var index = $cell.index(); var cellToAdd = void 0; $cell.parents('table').find('tr').each(function (n, tr) { var isTBody = _domUtils2.default.getNodeName(tr.parentNode) === 'TBODY'; var isMSIE = _tuiCodeSnippet2.default.browser.msie; var cell = tr.children[index]; for (var i = 0; i < numberOfCols; i += 1) { if (isTBody) { cellToAdd = document.createElement('td'); } else { cellToAdd = document.createElement('th'); } if (!isMSIE) { cellToAdd.appendChild(document.createElement('br')); } (0, _jquery2.default)(cellToAdd).insertAfter(cell); } }); } /** * Focus to next cell * @param {Squire} sq - Squire instance * @param {jQuery} $cell - jQuery wrapped table cell * @ignore */ function focusToNextCell(sq, $cell) { var range = sq.getSelection(); range.selectNodeContents($cell.next()[0]); range.collapse(true); sq.setSelection(range); } exports.default = TableAddCol; /***/ }), /* 120 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * RemoveRow * remove Row to selected table * @extends Command * @module wysiwygCommands/TableRemoveRow * @ignore */ /** * @fileoverview Implements table remove row WysiwygCommand * @author NHN Ent. FE Development Lab */ var TableRemoveRow = _commandManager2.default.command('wysiwyg', /** @lends RemoveRow */{ name: 'RemoveRow', /** * command handler * @param {WysiwygEditor} wwe wysiwygEditor instance */ exec: function exec(wwe) { var sq = wwe.getEditor(); var range = sq.getSelection().cloneRange(); var $table = (0, _jquery2.default)(range.startContainer).parents('table'); var selectionMgr = wwe.componentManager.getManager('tableSelection'); var tableMgr = wwe.componentManager.getManager('table'); var $tr = getTrs(range, selectionMgr, $table); var tbodyRowLength = $table.find('tbody tr').length; wwe.focus(); if ((sq.hasFormat('TD') || sq.hasFormat('TABLE')) && tbodyRowLength > 1) { sq.saveUndoState(range); var $nextFocus = $tr.last().next()[0] ? $tr.last().next() : $tr.first().prev(); if ($nextFocus.length) { focusToFirstTd(sq, range, $nextFocus, tableMgr); } $tr.remove(); } selectionMgr.removeClassAttrbuteFromAllCellsIfNeed(); } }); /** * Focus to first TD in given TR * @param {SquireExt} sq Squire instance * @param {Range} range Range object * @param {jQuery} $tr jQuery wrapped TR * @param {object} tableMgr Table manager */ function focusToFirstTd(sq, range, $tr, tableMgr) { var nextFocusCell = $tr.find('td').get(0); range.setStart(nextFocusCell, 0); range.collapse(true); tableMgr.setLastCellNode(nextFocusCell); sq.setSelection(range); } /** * Get start, end row index from current range * @param {HTMLElement} firstSelectedCell Range object * @param {object} rangeInformation Range information object * @param {jQuery} $table jquery wrapped TABLE * @returns {jQuery} */ function getSelectedRows(firstSelectedCell, rangeInformation, $table) { var tbodyRowLength = $table.find('tbody tr').length; var isStartContainerInThead = (0, _jquery2.default)(firstSelectedCell).parents('thead').length; var startRowIndex = rangeInformation.from.row; var endRowIndex = rangeInformation.to.row; if (isStartContainerInThead) { startRowIndex += 1; } var isWholeTbodySelected = (startRowIndex === 1 || isStartContainerInThead) && endRowIndex === tbodyRowLength; if (isWholeTbodySelected) { endRowIndex -= 1; } return $table.find('tr').slice(startRowIndex, endRowIndex + 1); } /** * Get TRs * @param {Range} range Range object * @param {object} selectionMgr Table selection manager * @param {jQuery} $table current table * @returns {jQuery} */ function getTrs(range, selectionMgr, $table) { var $selectedCells = selectionMgr.getSelectedCells(); var rangeInformation = void 0, trs = void 0; if ($selectedCells.length) { rangeInformation = selectionMgr.getSelectionRangeFromTable($selectedCells.first().get(0), $selectedCells.last().get(0)); trs = getSelectedRows($selectedCells.first()[0], rangeInformation, $table); } else { var cell = (0, _jquery2.default)(range.startContainer).closest('td,th').get(0); rangeInformation = selectionMgr.getSelectionRangeFromTable(cell, cell); trs = getSelectedRows(cell, rangeInformation, $table); } return trs; } exports.default = TableRemoveRow; /***/ }), /* 121 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); var _domUtils = __webpack_require__(4); var _domUtils2 = _interopRequireDefault(_domUtils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * RemoveCol * remove Row to selected table * @extends Command * @module wysiwygCommands/TableRemoveCol * @ignore */ var TableRemoveCol = _commandManager2.default.command('wysiwyg', /** @lends RemoveCol */{ name: 'RemoveCol', /** * command handler * @param {WysiwygEditor} wwe wysiwygEditor instance */ exec: function exec(wwe) { var sq = wwe.getEditor(); var range = sq.getSelection().cloneRange(); var $table = (0, _jquery2.default)(range.startContainer).parents('table'); var tableMgr = wwe.componentManager.getManager('table'); var selectionMgr = wwe.componentManager.getManager('tableSelection'); var hasMultipleCols = (0, _jquery2.default)(range.startContainer).closest('table').find('thead tr th').length > 1; wwe.focus(); // IE 800a025e error on removing part of selection range. collapse range.collapse(true); sq.setSelection(range); if (sq.hasFormat('TR', null, range) && hasMultipleCols) { var tbodyColLength = $table.find('tbody tr:first td').length; var $selectedCellsByManager = selectionMgr.getSelectedCells(); if ($selectedCellsByManager.length < tbodyColLength) { sq.saveUndoState(range); var $nextFocus = void 0; if ($selectedCellsByManager.length > 1) { var $tailCell = $selectedCellsByManager.last(); var $headCell = $selectedCellsByManager.first(); $nextFocus = $tailCell.next().length ? $tailCell.next() : $headCell.prev(); removeMultipleColsByCells($selectedCellsByManager); } else { var $cell = getCellByRange(range); $nextFocus = $cell.next().length ? $cell.next() : $cell.prev(); removeColByCell($cell); } focusToCell(sq, $nextFocus, tableMgr); } } } }); /** * Get cell by range object * @param {Range} range range * @returns {HTMLElement|Node} */ /** * @fileoverview Implements table remove column WysiwygCommand * @author NHN Ent. FE Development Lab */ function getCellByRange(range) { var cell = range.startContainer; if (_domUtils2.default.getNodeName(cell) === 'TD' || _domUtils2.default.getNodeName(cell) === 'TH') { cell = (0, _jquery2.default)(cell); } else { cell = (0, _jquery2.default)(cell).parentsUntil('tr'); } return cell; } /** * Remove columns by given cells * @param {jQuery} $cells - jQuery table cells */ function removeMultipleColsByCells($cells) { var numberOfCells = $cells.length; for (var i = 0; i < numberOfCells; i += 1) { var $cellToDelete = $cells.eq(i); if ($cellToDelete.length > 0) { removeColByCell($cells.eq(i)); } } } /** * Remove column by given cell * @param {jQuery} $cell - jQuery wrapped table cell */ function removeColByCell($cell) { var index = $cell.index(); $cell.parents('table').find('tr').each(function (n, tr) { (0, _jquery2.default)(tr).children().eq(index).remove(); }); } /** * Focus to given cell * @param {Squire} sq - Squire instance * @param {jQuery} $cell - jQuery wrapped table cell * @param {object} tableMgr - Table manager instance */ function focusToCell(sq, $cell, tableMgr) { var nextFocusCell = $cell.get(0); if ($cell.length && _jquery2.default.contains(document, $cell)) { var range = sq.getSelection(); range.selectNodeContents($cell[0]); range.collapse(true); sq.setSelection(range); tableMgr.setLastCellNode(nextFocusCell); } } exports.default = TableRemoveCol; /***/ }), /* 122 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); var _domUtils = __webpack_require__(4); var _domUtils2 = _interopRequireDefault(_domUtils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * AlignCol * Align selected column's text content to given direction * @extends Command * @module wysiwygCommands/TableAlignCol * @ignore */ var TableAlignCol = _commandManager2.default.command('wysiwyg', /** @lends AlignCol */{ name: 'AlignCol', /** * command handler * @param {WysiwygEditor} wwe wysiwygEditor instance * @param {string} alignDirection Align direction */ exec: function exec(wwe, alignDirection) { var sq = wwe.getEditor(); var range = sq.getSelection().cloneRange(); var selectionMgr = wwe.componentManager.getManager('tableSelection'); var rangeInformation = getRangeInformation(range, selectionMgr); wwe.focus(); if (sq.hasFormat('TR')) { sq.saveUndoState(range); var $table = (0, _jquery2.default)(range.startContainer).parents('table'); var selectionInformation = getSelectionInformation($table, rangeInformation); setAlignAttributeToTableCells($table, alignDirection, selectionInformation); } selectionMgr.removeClassAttrbuteFromAllCellsIfNeed(); } }); /** * Set Column align * @param {jQuery} $table jQuery wrapped TABLE * @param {string} alignDirection 'left' or 'center' or 'right' * @param {{ * startColumnIndex: number, * endColumnIndex: number, * isDivided: boolean * }} selectionInformation start, end column index and boolean value for whether range divided or not */ /** * @fileoverview Implements table align column WysiwygCommand * @author NHN Ent. FE Development Lab */ function setAlignAttributeToTableCells($table, alignDirection, selectionInformation) { var isDivided = selectionInformation.isDivided || false; var start = selectionInformation.startColumnIndex; var end = selectionInformation.endColumnIndex; var columnLength = $table.find('tr').eq(0).find('td,th').length; $table.find('tr').each(function (n, tr) { (0, _jquery2.default)(tr).children('td,th').each(function (index, cell) { if (isDivided && (start <= index && index <= columnLength || index <= end)) { (0, _jquery2.default)(cell).attr('align', alignDirection); } else if (start <= index && index <= end) { (0, _jquery2.default)(cell).attr('align', alignDirection); } }); }); } /** * Return start, end column index and boolean value for whether range divided or not * @param {jQuery} $table jQuery wrapped TABLE * @param {{startColumnIndex: number, endColumnIndex: number}} rangeInformation Range information * @returns {{startColumnIndex: number, endColumnIndex: number, isDivided: boolean}} */ function getSelectionInformation($table, rangeInformation) { var columnLength = $table.find('tr').eq(0).find('td,th').length; var from = rangeInformation.from, to = rangeInformation.to; var startColumnIndex = void 0, endColumnIndex = void 0, isDivided = void 0; if (from.row === to.row) { startColumnIndex = from.cell; endColumnIndex = to.cell; } else if (from.row < to.row) { if (from.cell <= to.cell) { startColumnIndex = 0; endColumnIndex = columnLength - 1; } else { startColumnIndex = from.cell; endColumnIndex = to.cell; isDivided = true; } } return { startColumnIndex: startColumnIndex, endColumnIndex: endColumnIndex, isDivided: isDivided }; } /** * Get range information * @param {Range} range Range object * @param {object} selectionMgr Table selection manager * @returns {object} */ function getRangeInformation(range, selectionMgr) { var $selectedCells = selectionMgr.getSelectedCells(); var rangeInformation = void 0, startCell = void 0; if ($selectedCells.length) { rangeInformation = selectionMgr.getSelectionRangeFromTable($selectedCells.first().get(0), $selectedCells.last().get(0)); } else { var startContainer = range.startContainer; startCell = _domUtils2.default.isTextNode(startContainer) ? (0, _jquery2.default)(startContainer).parent('td,th')[0] : startContainer; rangeInformation = selectionMgr.getSelectionRangeFromTable(startCell, startCell); } return rangeInformation; } exports.default = TableAlignCol; /***/ }), /* 123 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * RemoveTable * Remove selected table * @extends Command * @module wysiwygCommands/TableRemove * @ignore */ /** * @fileoverview Implements table remove WysiwygCommand * @author NHN Ent. FE Development Lab */ var TableRemove = _commandManager2.default.command('wysiwyg', /** @lends RemoveTable */{ name: 'RemoveTable', /** * command handler * @param {WysiwygEditor} wwe wysiwygEditor instance */ exec: function exec(wwe) { var sq = wwe.getEditor(); var range = sq.getSelection().cloneRange(); if (sq.hasFormat('TABLE')) { sq.saveUndoState(range); var $table = (0, _jquery2.default)(range.startContainer).closest('table'); $table.remove(); } wwe.focus(); } }); exports.default = TableRemove; /***/ }), /* 124 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Indent * Indent list or task to wysiwyg Editor * @extends Command * @module wysiwygCommands/indent * @ignore */ /** * @fileoverview Implements Indent wysiwyg command * @author NHN Ent. FE Development Lab */ var Indent = _commandManager2.default.command('wysiwyg', /** @lends Indent */{ name: 'Indent', /** * Command Handler * @param {WysiwygEditor} wwe wysiwygEditor instance */ exec: function exec(wwe) { var listManager = wwe.componentManager.getManager('list'); var range = wwe.getEditor().getSelection(); var $node = (0, _jquery2.default)(range.startContainer).closest('li'); var prevClasses = void 0, nodeClasses = void 0, nextClasses = void 0; var $prev = $node.prev(); if ($prev.length && $node.length) { var $next = $node.find('li').eq(0); wwe.getEditor().saveUndoState(); nodeClasses = $node.attr('class'); prevClasses = $prev.attr('class'); nextClasses = $next.attr('class'); $node.removeAttr('class'); $prev.removeAttr('class'); if ($next.length && !$next.children('div').length) { $next.removeAttr('class'); } wwe.getEditor().increaseListLevel(); listManager.mergeList($node.get(0)); $node.attr('class', nodeClasses); $prev.attr('class', prevClasses); $next.attr('class', nextClasses); } } }); exports.default = Indent; /***/ }), /* 125 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Outdent * Outdent list or task to wysiwyg Editor * @extends Command * @module wysiwygCommands/Outdent * @ignore */ /** * @fileoverview Implements Outdent wysiwyg command * @author NHN Ent. FE Development Lab */ var Outdent = _commandManager2.default.command('wysiwyg', /** @lends Outdent */{ name: 'Outdent', /** * Command Handler * @param {WysiwygEditor} wwe WysiwygEditor instance */ exec: function exec(wwe) { var $node = getCurrent$Li(wwe); if ($node.length && isExecutable($node)) { wwe.getEditor().saveUndoState(); var nodeClasses = $node.attr('class'); wwe.getEditor().decreaseListLevel(); $node = getCurrent$Li(wwe); $node.attr('class', nodeClasses); } } }); /** * test if outdent the given list item * arbitrary list allows list item to be in any position * while markdown spec does not * @param {jQuery} $currentLiNode - jQuery list item element * @returns {boolean} - true to executable * @ignore */ function isExecutable($currentLiNode) { return !$currentLiNode.next().is('OL,UL'); } /** * Get list item element of current selection * @param {object} wwe Wysiwyg editor instance * @returns {jQuery} * @ignore */ function getCurrent$Li(wwe) { var range = wwe.getEditor().getSelection(); return (0, _jquery2.default)(range.startContainer).closest('li'); } exports.default = Outdent; /***/ }), /* 126 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); var _domUtils = __webpack_require__(4); var _domUtils2 = _interopRequireDefault(_domUtils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Task * Add Task to selected wysiwyg editor content * @extends Command * @module wysiwygCommands/Task * @ignore */ var Task = _commandManager2.default.command('wysiwyg', /** @lends Task */{ name: 'Task', keyMap: ['ALT+T', 'ALT+T'], /** * Command Handler * @param {WysiwygEditor} wwe WYSIWYGEditor instance */ exec: function exec(wwe) { var sq = wwe.getEditor(); var range = sq.getSelection(); var listManager = wwe.componentManager.getManager('list'); var startContainer = range.startContainer, endContainer = range.endContainer, startOffset = range.startOffset, endOffset = range.endOffset; wwe.focus(); sq.saveUndoState(range); var lines = listManager.getLinesOfSelection(startContainer, endContainer); var newLIs = []; for (var i = 0; i < lines.length; i += 1) { var newLI = this._changeFormatToTaskIfNeed(wwe, lines[i]); if (newLI) { newLIs.push(newLI); } } if (newLIs.length) { var newStartContainer = _domUtils2.default.containsNode(newLIs[0], startContainer) ? startContainer : newLIs[0]; var newEndContainer = _domUtils2.default.containsNode(newLIs[newLIs.length - 1], endContainer) ? endContainer : newLIs[newLIs.length - 1]; wwe.setSelectionByContainerAndOffset(newStartContainer, startOffset, newEndContainer, endOffset); } }, /** * Change format to unordered list and return current li element if need * @param {WysiwygEditor} wwe Wysiwyg editor instance * @param {HTMLElement} target Element target for change * @returns {HTMLElement} newly created list * @private */ _changeFormatToTaskIfNeed: function _changeFormatToTaskIfNeed(wwe, target) { var sq = wwe.getEditor(); var range = sq.getSelection(); var taskManager = wwe.componentManager.getManager('task'); var newLI = void 0; if (!sq.hasFormat('TABLE') && !sq.hasFormat('PRE')) { range.setStart(target, 0); range.collapse(true); sq.setSelection(range); if (!sq.hasFormat('li')) { sq.makeUnorderedList(); target = sq.getSelection().startContainer; } if ((0, _jquery2.default)(target).hasClass('task-list-item')) { taskManager.unformatTask(target); } else { taskManager.formatTask(target); } newLI = sq.getSelection().startContainer; } return newLI; } }); /** * @fileoverview Implements Task WysiwygCommand * @author NHN Ent. FE Development Lab */ exports.default = Task; /***/ }), /* 127 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); var _domUtils = __webpack_require__(4); var _domUtils2 = _interopRequireDefault(_domUtils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Code * Add bold to selected wysiwyg editor content * @extends Command * @module wysiwygCommands/Code * @ignore */ /** * @fileoverview Implements code WysiwygCommand * @author NHN Ent. FE Development Lab */ var Code = _commandManager2.default.command('wysiwyg', /** @lends Code */{ name: 'Code', keyMap: ['SHIFT+CTRL+C', 'SHIFT+META+C'], /** * command handler * @param {WysiwygEditor} wwe wysiwygEditor instance */ exec: function exec(wwe) { var sq = wwe.getEditor(); var tableSelectionManager = wwe.componentManager.getManager('tableSelection'); var _styleCode = _tuiCodeSnippet2.default.bind(styleCode, null, wwe.getEditor()); wwe.focus(); if (sq.hasFormat('table') && tableSelectionManager.getSelectedCells().length) { tableSelectionManager.styleToSelectedCells(_styleCode); var range = sq.getSelection(); range.collapse(true); sq.setSelection(range); } else { _styleCode(sq); } } }); /** * removeUnnecessaryCodeInNextToRange * Remove unnecessary code tag next to range, code tag made by squire * @param {Range} range range object */ function removeUnnecessaryCodeInNextToRange(range) { if (_domUtils2.default.getNodeName(range.startContainer.nextSibling) === 'CODE' && _domUtils2.default.getTextLength(range.startContainer.nextSibling) === 0) { (0, _jquery2.default)(range.startContainer.nextSibling).remove(); } } /** * Style code. * @param {object} editor - editor instance * @param {object} sq - squire editor instance */ function styleCode(editor, sq) { if (!sq.hasFormat('PRE') && sq.hasFormat('code')) { sq.changeFormat(null, { tag: 'code' }); removeUnnecessaryCodeInNextToRange(editor.getSelection().cloneRange()); } else if (!sq.hasFormat('a') && !sq.hasFormat('PRE')) { if (sq.hasFormat('b')) { sq.removeBold(); } else if (sq.hasFormat('i')) { sq.removeItalic(); } sq.changeFormat({ tag: 'code' }); var range = sq.getSelection().cloneRange(); range.setStart(range.endContainer, range.endOffset); range.collapse(true); sq.setSelection(range); } } exports.default = Code; /***/ }), /* 128 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tuiCodeSnippet = __webpack_require__(1); var _tuiCodeSnippet2 = _interopRequireDefault(_tuiCodeSnippet); var _commandManager = __webpack_require__(2); var _commandManager2 = _interopRequireDefault(_commandManager); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var CODEBLOCK_CLASS_TEMP = 'te-content-codeblock-temp'; /** * @fileoverview Implements code block WysiwygCommand * @author NHN Ent. FE Development Lab */ var CODEBLOCK_ATTR_NAME = 'data-te-codeblock'; /** * CodeBlock * Add CodeBlock to wysiwygEditor * @extends Command * @module wysiwygCommands/Codeblock * @ignore */ var CodeBlock = _commandManager2.default.command('wysiwyg', /** @lends CodeBlock */{ name: 'CodeBlock', keyMap: ['SHIFT+CTRL+P', 'SHIFT+META+P'], /** * Command handler * @param {WysiwygEditor} wwe wysiwygEditor instance * @param {string} type of language */ exec: function exec(wwe, type) { var sq = wwe.getEditor(); var range = sq.getSelection().cloneRange(); if (!sq.hasFormat('PRE') && !sq.hasFormat('TABLE')) { var attr = CODEBLOCK_ATTR_NAME + ' class = "' + CODEBLOCK_CLASS_TEMP + '"'; if (type) { attr += ' data-language="' + type + '"'; } var codeBlockBody = getCodeBlockBody(range, wwe); sq.insertHTML('
' + codeBlockBody + '
'); focusToFirstCode(wwe.get$Body().find('.' + CODEBLOCK_CLASS_TEMP), wwe); } wwe.focus(); } }); /** * focusToFirstCode * Focus to first code tag content of pre tag * @param {jQuery} $pre pre tag * @param {WysiwygEditor} wwe wysiwygEditor */ function focusToFirstCode($pre, wwe) { var range = wwe.getEditor().getSelection().cloneRange(); $pre.removeClass(CODEBLOCK_CLASS_TEMP); range.setStartBefore($pre.get(0).firstChild); range.collapse(true); wwe.getEditor().setSelection(range); } /** * getCodeBlockBody * get text wrapped by code * @param {object} range range object * @param {object} wwe wysiwyg editor * @returns {string} */ function getCodeBlockBody(range, wwe) { var mgr = wwe.componentManager.getManager('codeblock'); var codeBlock = void 0; if (range.collapsed) { codeBlock = '
'; } else { var contents = range.extractContents(); var nodes = _tuiCodeSnippet2.default.toArray(contents.childNodes); var tempDiv = (0, _jquery2.default)('
').append(mgr.prepareToPasteOnCodeblock(nodes)); codeBlock = tempDiv.html(); } return codeBlock; } exports.default = CodeBlock; /***/ }), /* 129 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } _i18n2.default.setLanguage(['en', 'en_US'], { 'Markdown': 'Markdown', 'WYSIWYG': 'WYSIWYG', 'Write': 'Write', 'Preview': 'Preview', 'Headings': 'Headings', 'Paragraph': 'Paragraph', 'Bold': 'Bold', 'Italic': 'Italic', 'Strike': 'Strike', 'Code': 'Inline code', 'Line': 'Line', 'Blockquote': 'Blockquote', 'Unordered list': 'Unordered list', 'Ordered list': 'Ordered list', 'Task': 'Task', 'Indent': 'Indent', 'Outdent': 'Outdent', 'Insert link': 'Insert link', 'Insert CodeBlock': 'Insert codeBlock', 'Insert table': 'Insert table', 'Insert image': 'Insert image', 'Heading': 'Heading', 'Image URL': 'Image URL', 'Select image file': 'Select image file', 'Description': 'Description', 'OK': 'OK', 'More': 'More', 'Cancel': 'Cancel', 'File': 'File', 'URL': 'URL', 'Link text': 'Link text', 'Add row': 'Add row', 'Add col': 'Add col', 'Remove row': 'Remove row', 'Remove col': 'Remove col', 'Align left': 'Align left', 'Align center': 'Align center', 'Align right': 'Align right', 'Remove table': 'Remove table', 'Would you like to paste as table?': 'Would you like to paste as table?', 'Text color': 'Text color', 'Auto scroll enabled': 'Auto scroll enabled', 'Auto scroll disabled': 'Auto scroll disabled', 'Choose language': 'Choose language' }); /** * @fileoverview I18N for English * @author NHN Ent. FE Development Lab */ /***/ }), /* 130 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } _i18n2.default.setLanguage(['ko', 'ko_KR'], { 'Markdown': '마크다운', 'WYSIWYG': '위지윅', 'Write': '편집하기', 'Preview': '미리보기', 'Headings': '제목크기', 'Paragraph': '본문', 'Bold': '굵게', 'Italic': '기울임꼴', 'Strike': '취소선', 'Code': '인라인 코드', 'Line': '문단나눔', 'Blockquote': '인용구', 'Unordered list': '글머리 기호', 'Ordered list': '번호 매기기', 'Task': '체크박스', 'Indent': '들여쓰기', 'Outdent': '내어쓰기', 'Insert link': '링크 삽입', 'Insert CodeBlock': '코드블럭 삽입', 'Insert table': '표 삽입', 'Insert image': '이미지 삽입', 'Heading': '제목', 'Image URL': '이미지 주소', 'Select image file': '이미지 파일을 선택하세요.', 'Description': '설명', 'OK': '확인', 'More': '더 보기', 'Cancel': '취소', 'File': '파일', 'URL': '주소', 'Link text': '링크 텍스트', 'Add row': '행 추가', 'Add col': '열 추가', 'Remove row': '행 삭제', 'Remove col': '열 삭제', 'Align left': '왼쪽 정렬', 'Align center': '가운데 정렬', 'Align right': '오른쪽 정렬', 'Remove table': '표 삭제', 'Would you like to paste as table?': '표형태로 붙여 넣겠습니까?', 'Text color': '글자 색상', 'Auto scroll enabled': '자동 스크롤 켜짐', 'Auto scroll disabled': '자동 스크롤 꺼짐', 'Choose language': '언어 선택' }); /** * @fileoverview I18N for Korean * @author NHN Ent. FE Development Lab */ /***/ }), /* 131 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } _i18n2.default.setLanguage(['zh', 'zh_CN'], { 'Markdown': 'Markdown', 'WYSIWYG': '所见即所得', 'Write': '编辑', 'Preview': '预览', 'Headings': '标题', 'Paragraph': '文本', 'Bold': '加粗', 'Italic': '斜体字', 'Strike': '删除线', 'Code': '内嵌代码', 'Line': '水平线', 'Blockquote': '引用块', 'Unordered list': '无序列表', 'Ordered list': '有序列表', 'Task': '任务', 'Indent': '缩进', 'Outdent': '减少缩进', 'Insert link': '插入链接', 'Insert CodeBlock': '插入代码块', 'Insert table': '插入表格', 'Insert image': '插入图片', 'Heading': '标题', 'Image URL': '图片网址', 'Select image file': '选择图片文件', 'Description': '说明', 'OK': '确认', 'More': '更多', 'Cancel': '取消', 'File': '文件', 'URL': 'URL', 'Link text': '链接文本', 'Add row': '添加行', 'Add col': '添加列', 'Remove row': '删除行', 'Remove col': '删除列', 'Align left': '左对齐', 'Align center': '居中对齐', 'Align right': '右对齐', 'Remove table': '删除表格', 'Would you like to paste as table?': '需要粘贴为表格吗?', 'Text color': '文字颜色', 'Auto scroll enabled': '自动滚动已启用', 'Auto scroll disabled': '自动滚动已禁用', 'Choose language': '选择语言' }); /** * @fileoverview I18N for Chinese * @author NHN Ent. FE Development Lab */ /***/ }), /* 132 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } _i18n2.default.setLanguage(['ja', 'ja_JP'], { 'Markdown': 'マークダウン', 'WYSIWYG': 'WYSIWYG', 'Write': '編集する', 'Preview': 'プレビュー', 'Headings': '見出し', 'Paragraph': '本文', 'Bold': '太字', 'Italic': 'イタリック', 'Strike': 'ストライク', 'Code': 'インラインコード', 'Line': 'ライン', 'Blockquote': '引用', 'Unordered list': '番号なしリスト', 'Ordered list': '順序付きリスト', 'Task': 'タスク', 'Indent': 'インデント', 'Outdent': 'アウトデント', 'Insert link': 'リンク挿入', 'Insert CodeBlock': 'コードブロック挿入', 'Insert table': 'テーブル挿入', 'Insert image': '画像挿入', 'Heading': '見出し', 'Image URL': 'イメージURL', 'Select image file': '画像ファイル選択', 'Description': 'ディスクリプション ', 'OK': 'はい', 'More': 'もっと', 'Cancel': 'キャンセル', 'File': 'ファイル', 'URL': 'URL', 'Link text': 'リンクテキスト', 'Add row': '行追加', 'Add col': '列追加', 'Remove row': '行削除', 'Remove col': '列削除', 'Align left': '左揃え', 'Align center': '中央揃え', 'Align right': '右揃え', 'Remove table': 'テーブル削除', 'Would you like to paste as table?': 'テーブルを貼り付けますか?', 'Text color': '文字色相', 'Auto scroll enabled': '自動スクロールが有効', 'Auto scroll disabled': '自動スクロールを無効に', 'Choose language': '言語選択' }); /** * @fileoverview I18N for Japanese * @author NHN Ent. FE Development Lab */ /***/ }), /* 133 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } _i18n2.default.setLanguage(['nl', 'nl_NL'], { 'Markdown': 'Markdown', 'WYSIWYG': 'WYSIWYG', 'Write': 'Opslaan', 'Preview': 'Voorbeeld', 'Headings': 'Koppen', 'Paragraph': 'Alinea', 'Bold': 'Vet', 'Italic': 'Cursief', 'Strike': 'Doorhalen', 'Code': 'Inline code', 'Line': 'Regel', 'Blockquote': 'Citaatblok', 'Unordered list': 'Opsomming', 'Ordered list': 'Genummerde opsomming', 'Task': 'Taak', 'Indent': 'Niveau verhogen', 'Outdent': 'Niveau verlagen', 'Insert link': 'Link invoegen', 'Insert CodeBlock': 'Codeblok toevoegen', 'Insert table': 'Tabel invoegen', 'Insert image': 'Afbeelding invoegen', 'Heading': 'Kop', 'Image URL': 'Afbeelding URL', 'Select image file': 'Selecteer een afbeelding', 'Description': 'Omschrijving', 'OK': 'OK', 'More': 'Meer', 'Cancel': 'Annuleren', 'File': 'Bestand', 'URL': 'URL', 'Link text': 'Link tekst', 'Add row': 'Rij toevoegen', 'Add col': 'Kolom toevoegen', 'Remove row': 'Rij verwijderen', 'Remove col': 'Kolom verwijderen', 'Align left': 'Links uitlijnen', 'Align center': 'Centreren', 'Align right': 'Rechts uitlijnen', 'Remove table': 'Verwijder tabel', 'Would you like to paste as table?': 'Wil je dit als tabel plakken?', 'Text color': 'Tekstkleur', 'Auto scroll enabled': 'Autoscroll ingeschakeld', 'Auto scroll disabled': 'Autoscroll uitgeschakeld', 'Choose language': 'Kies een taal' }); /** * @fileoverview I18N for Dutch * @author NHN Ent. FE Development Lab */ /***/ }), /* 134 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } _i18n2.default.setLanguage(['es', 'es_ES'], { 'Markdown': 'Markdown', 'WYSIWYG': 'WYSIWYG', 'Write': 'Escribir', 'Preview': 'Vista previa', 'Headings': 'Encabezados', 'Paragraph': 'Párrafo', 'Bold': 'Negrita', 'Italic': 'Itálica', 'Strike': 'Tachado', 'Code': 'Código', 'Line': 'Línea', 'Blockquote': 'Cita', 'Unordered list': 'Lista desordenada', 'Ordered list': 'Lista ordenada', 'Task': 'Tarea', 'Indent': 'Sangría', 'Outdent': 'Saliendo', 'Insert link': 'Insertar enlace', 'Insert CodeBlock': 'Insertar bloque de código', 'Insert table': 'Insertar tabla', 'Insert image': 'Insertar imagen', 'Heading': 'Encabezado', 'Image URL': 'URL de la imagen', 'Select image file': 'Seleccionar archivo de imagen', 'Description': 'Descripción', 'OK': 'Aceptar', 'More': 'Más', 'Cancel': 'Cancelar', 'File': 'Archivo', 'URL': 'URL', 'Link text': 'Texto del enlace', 'Add row': 'Agregar fila', 'Add col': 'Agregar columna', 'Remove row': 'Eliminar fila', 'Remove col': 'Eliminar columna', 'Align left': 'Alinear a la izquierda', 'Align center': 'Centrar', 'Align right': 'Alinear a la derecha', 'Remove table': 'Eliminar tabla', 'Would you like to paste as table?': '¿Desea pegar como tabla?', 'Text color': 'Color del texto', 'Auto scroll enabled': 'Desplazamiento automático habilitado', 'Auto scroll disabled': 'Desplazamiento automático deshabilitado', 'Choose language': 'Elegir idioma' }); /** * @fileoverview I18N for Spanish * @author Enrico Lamperti */ /***/ }), /* 135 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } _i18n2.default.setLanguage(['de', 'de_DE'], { 'Markdown': 'Markdown', 'WYSIWYG': 'WYSIWYG', 'Write': 'Verfassen', 'Preview': 'Vorschau', 'Headings': 'Überschriften', 'Paragraph': 'Text', 'Bold': 'Fett', 'Italic': 'Kursiv', 'Strike': 'Durchgestrichen', 'Code': 'Code', 'Line': 'Trennlinie', 'Blockquote': 'Blocktext', 'Unordered list': 'Aufzählung', 'Ordered list': 'Nummerierte Aufzählung', 'Task': 'Aufgabe', 'Indent': 'Einrücken', 'Outdent': 'Ausrücken', 'Insert link': 'Link einfügen', 'Insert CodeBlock': 'Codeblock einfügen', 'Insert table': 'Tabelle einfügen', 'Insert image': 'Grafik einfügen', 'Heading': 'Titel', 'Image URL': 'Bild URL', 'Select image file': 'Grafik auswählen', 'Description': 'Beschreibung', 'OK': 'OK', 'More': 'Mehr', 'Cancel': 'Abbrechen', 'File': 'Datei', 'URL': 'URL', 'Link text': 'Anzuzeigender Text', 'Add row': 'Zeile hinzufügen', 'Add col': 'Spalte hinzufügen', 'Remove row': 'Zeile entfernen', 'Remove col': 'Spalte entfernen', 'Align left': 'Links ausrichten', 'Align center': 'Zentrieren', 'Align right': 'Rechts ausrichten', 'Remove table': 'Tabelle entfernen', 'Would you like to paste as table?': 'Möchten Sie eine Tabelle einfügen?', 'Text color': 'Textfarbe', 'Auto scroll enabled': 'Autoscrollen aktiviert', 'Auto scroll disabled': 'Autoscrollen deaktiviert', 'Choose language': 'Sprache auswählen' }); /** * @fileoverview I18N for German * @author Jann-Niklas Kiepert */ /***/ }), /* 136 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } _i18n2.default.setLanguage(['ru', 'ru_RU'], { 'Markdown': 'Markdown', 'WYSIWYG': 'WYSIWYG', 'Write': 'Написать', 'Preview': 'Предварительный просмотр', 'Headings': 'Заголовки', 'Paragraph': 'Абзац', 'Bold': 'Жирный', 'Italic': 'Курсив', 'Strike': 'Зачеркнутый', 'Code': 'Встроенный код', 'Line': 'Строка', 'Blockquote': 'Блок цитирования', 'Unordered list': 'Неупорядоченный список', 'Ordered list': 'Упорядоченный список', 'Task': 'Задача', 'Indent': 'отступ', 'Outdent': 'Выступ', 'Insert link': 'Вставить ссылку', 'Insert CodeBlock': 'Вставить код', 'Insert table': 'Вставить таблицу', 'Insert image': 'Вставить изображение', 'Heading': 'Заголовок', 'Image URL': 'URL изображения', 'Select image file': 'Выбрать файл изображения', 'Description': 'Описание', 'OK': 'Хорошо', 'More': 'еще', 'Cancel': 'Отмена', 'File': 'Файл', 'URL': 'URL', 'Link text': 'Текст ссылки', 'Add row': 'Добавить ряд', 'Add col': 'Добавить столбец', 'Remove row': 'Удалить ряд', 'Remove col': 'Удалить столбец', 'Align left': 'Выровнять по левому краю', 'Align center': 'Выровнять по центру', 'Align right': 'Выровнять по правому краю', 'Remove table': 'Удалить таблицу', 'Would you like to paste as table?': 'Вы хотите вставить в виде таблицы?', 'Text color': 'Цвет текста', 'Auto scroll enabled': 'Автоматическая прокрутка включена', 'Auto scroll disabled': 'Автоматическая прокрутка отключена', 'Choose language': 'Выбрать язык' }); /** * @fileoverview I18N for Russian * @author Stepan Samko */ /***/ }), /* 137 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } _i18n2.default.setLanguage(['fr', 'fr_FR'], { 'Markdown': 'Markdown', 'WYSIWYG': 'WYSIWYG', 'Write': 'Écrire', 'Preview': 'Aperçu', 'Headings': 'En-têtes', 'Paragraph': 'Paragraphe', 'Bold': 'Gras', 'Italic': 'Italique', 'Strike': 'Barré', 'Code': 'Code en ligne', 'Line': 'Ligne', 'Blockquote': 'Citation', 'Unordered list': 'Liste non-ordonnée', 'Ordered list': 'Liste ordonnée', 'Task': 'Tâche', 'Indent': 'Retrait', 'Outdent': 'Sortir', 'Insert link': 'Insérer un lien', 'Insert CodeBlock': 'Insérer un bloc de code', 'Insert table': 'Insérer un tableau', 'Insert image': 'Insérer une image', 'Heading': 'En-tête', 'Image URL': 'URL de l\'image', 'Select image file': 'Sélectionnez un fichier image', 'Description': 'Description', 'OK': 'OK', 'More': 'de plus', 'Cancel': 'Annuler', 'File': 'Fichier', 'URL': 'URL', 'Link text': 'Texte du lien', 'Add row': 'Ajouter une ligne', 'Add col': 'Ajouter une colonne', 'Remove row': 'Supprimer une ligne', 'Remove col': 'Supprimer une colonne', 'Align left': 'Aligner à gauche', 'Align center': 'Aligner au centre', 'Align right': 'Aligner à droite', 'Remove table': 'Supprimer le tableau', 'Would you like to paste as table?': 'Voulez-vous coller ce contenu en tant que tableau ?', 'Text color': 'Couleur du texte', 'Auto scroll enabled': 'Défilement automatique activé', 'Auto scroll disabled': 'Défilement automatique désactivé', 'Choose language': 'Choix de la langue' }); /** * @fileoverview I18N for French * @author Stanislas Michalak */ /***/ }), /* 138 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } _i18n2.default.setLanguage(['uk', 'uk_UA'], { 'Markdown': 'Markdown', 'WYSIWYG': 'WYSIWYG', 'Write': 'Написати', 'Preview': 'Попередній перегляд', 'Headings': 'Заголовки', 'Paragraph': 'Абзац', 'Bold': 'Жирний', 'Italic': 'Курсив', 'Strike': 'Закреслений', 'Code': 'Вбудований код', 'Line': 'Лінія', 'Blockquote': 'Блок цитування', 'Unordered list': 'Невпорядкований список', 'Ordered list': 'Упорядкований список', 'Task': 'Завдання', 'Indent': 'відступ', 'Outdent': 'застарілий', 'Insert link': 'Вставити посилання', 'Insert CodeBlock': 'Вставити код', 'Insert table': 'Вставити таблицю', 'Insert image': 'Вставити зображення', 'Heading': 'Заголовок', 'Image URL': 'URL зображення', 'Select image file': 'Вибрати файл зображення', 'Description': 'Опис', 'OK': 'OK', 'More': 'ще', 'Cancel': 'Скасувати', 'File': 'Файл', 'URL': 'URL', 'Link text': 'Текст посилання', 'Add row': 'Додати ряд', 'Add col': 'Додати стовпчик', 'Remove row': 'Видалити ряд', 'Remove col': 'Видалити стовпчик', 'Align left': 'Вирівняти по лівому краю', 'Align center': 'Вирівняти по центру', 'Align right': 'Вирівняти по правому краю', 'Remove table': 'Видалити таблицю', 'Would you like to paste as table?': 'Ви хочете вставити у вигляді таблиці?', 'Text color': 'Колір тексту', 'Auto scroll enabled': 'Автоматична прокрутка включена', 'Auto scroll disabled': 'Автоматична прокрутка відключена', 'Choose language': 'Вибрати мову' }); /** * @fileoverview I18N for Ukrainian * @author Nikolya */ /***/ }), /* 139 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } _i18n2.default.setLanguage(['tr', 'tr_TR'], { 'Markdown': 'Markdown', 'WYSIWYG': 'WYSIWYG', 'Write': 'Düzenle', 'Preview': 'Ön izleme', 'Headings': 'Başlıklar', 'Paragraph': 'Paragraf', 'Bold': 'Kalın', 'Italic': 'İtalik', 'Strike': 'Altı çizgili', 'Code': 'Satır içi kod', 'Line': 'Çizgi', 'Blockquote': 'Alıntı', 'Unordered list': 'Sıralanmamış liste', 'Ordered list': 'Sıralı liste', 'Task': 'Görev kutusu', 'Indent': 'Girintiyi arttır', 'Outdent': 'Girintiyi azalt', 'Insert link': 'Bağlantı ekle', 'Insert CodeBlock': 'Kod bloku ekle', 'Insert table': 'Tablo ekle', 'Insert image': 'İmaj ekle', 'Heading': 'Başlık', 'Image URL': 'İmaj URL', 'Select image file': 'İmaj dosyası seç', 'Description': 'Açıklama', 'OK': 'Onay', 'More': 'Daha Fazla', 'Cancel': 'İptal', 'File': 'Dosya', 'URL': 'URL', 'Link text': 'Bağlantı yazısı', 'Add row': 'Satır ekle', 'Add col': 'Sütun ekle', 'Remove row': 'Satır sil', 'Remove col': 'Sütun sil', 'Align left': 'Sola hizala', 'Align center': 'Merkeze hizala', 'Align right': 'Sağa hizala', 'Remove table': 'Tabloyu kaldır', 'Would you like to paste as table?': 'Tablo olarak yapıştırmak ister misiniz?', 'Text color': 'Metin rengi', 'Auto scroll enabled': 'Otomatik kaydırma açık', 'Auto scroll disabled': 'Otomatik kaydırma kapalı', 'Choose language': 'Dil seçiniz' }); /** * @fileoverview I18N for Turkish * @author Mesut Gölcük */ /***/ }), /* 140 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } _i18n2.default.setLanguage(['fi', 'fi_FI'], { 'Markdown': 'Markdown', 'WYSIWYG': 'WYSIWYG', 'Write': 'Kirjoita', 'Preview': 'Esikatselu', 'Headings': 'Otsikot', 'Paragraph': 'Kappale', 'Bold': 'Lihavointi', 'Italic': 'Kursivointi', 'Strike': 'Yliviivaus', 'Code': 'Koodi', 'Line': 'Vaakaviiva', 'Blockquote': 'Lainaus', 'Unordered list': 'Luettelo', 'Ordered list': 'Numeroitu luettelo', 'Task': 'Tehtävä', 'Indent': 'Suurenna sisennystä', 'Outdent': 'Pienennä sisennystä', 'Insert link': 'Lisää linkki', 'Insert CodeBlock': 'Lisää koodia', 'Insert table': 'Lisää taulukko', 'Insert image': 'Lisää kuva', 'Heading': 'Otsikko', 'Image URL': 'Kuvan URL', 'Select image file': 'Valitse kuvatiedosto', 'Description': 'Kuvaus', 'OK': 'OK', 'More': 'Lisää', 'Cancel': 'Peruuta', 'File': 'Tiedosto', 'URL': 'URL', 'Link text': 'Linkkiteksti', 'Add row': 'Lisää rivi', 'Add col': 'Lisää sarake', 'Remove row': 'Poista rivi', 'Remove col': 'Poista sarake', 'Align left': 'Tasaus vasemmalle', 'Align center': 'Keskitä', 'Align right': 'Tasaus oikealle', 'Remove table': 'Poista taulukko', 'Would you like to paste as table?': 'Haluatko liittää taulukkomuodossa?', 'Text color': 'Tekstin väri', 'Auto scroll enabled': 'Automaattinen skrollaus käytössä', 'Auto scroll disabled': 'Automaattinen skrollaus pois käytöstä', 'Choose language': 'Valitse kieli' }); /** * @fileoverview I18N for Finnish * @author Tomi Mynttinen */ /***/ }), /* 141 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } _i18n2.default.setLanguage(['cs', 'cs_CZ'], { 'Markdown': 'Markdown', 'WYSIWYG': 'WYSIWYG', 'Write': 'Napsat', 'Preview': 'Náhled', 'Headings': 'Nadpisy', 'Paragraph': 'Odstavec', 'Bold': 'Tučné', 'Italic': 'Kurzíva', 'Strike': 'Přeškrtnuté', 'Code': 'Kód', 'Line': 'Vodorovná čára', 'Blockquote': 'Citace', 'Unordered list': 'Seznam s odrážkami', 'Ordered list': 'Číslovaný seznam', 'Task': 'Úkol', 'Indent': 'Zvětšit odsazení', 'Outdent': 'Zmenšit odsazení', 'Insert link': 'Vložit odkaz', 'Insert CodeBlock': 'Vložit blok kódu', 'Insert table': 'Vložit tabulku', 'Insert image': 'Vložit obrázek', 'Heading': 'Nadpis', 'Image URL': 'URL obrázku', 'Select image file': 'Vybrat obrázek', 'Description': 'Popis', 'OK': 'OK', 'More': 'Více', 'Cancel': 'Zrušit', 'File': 'Soubor', 'URL': 'URL', 'Link text': 'Text odkazu', 'Add row': 'Přidat řádek', 'Add col': 'Přidat sloupec', 'Remove row': 'Odebrat řádek', 'Remove col': 'Odebrat sloupec', 'Align left': 'Zarovnat vlevo', 'Align center': 'Zarovnat na střed', 'Align right': 'Zarovnat vpravo', 'Remove table': 'Odstranit tabulku', 'Would you like to paste as table?': 'Chcete vložit jako tabulku?', 'Text color': 'Barva textu', 'Auto scroll enabled': 'Automatické rolování zapnuto', 'Auto scroll disabled': 'Automatické rolování vypnuto', 'Choose language': 'Vybrat jazyk' }); /** * @fileoverview I18N for Czech * @author Dmitrij Tkačenko */ /***/ }), /* 142 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } _i18n2.default.setLanguage(['ar', 'ar_AR'], { 'Markdown': 'لغة ترميز', 'WYSIWYG': 'ما تراه هو ما تحصل عليه', 'Write': 'يكتب', 'Preview': 'عرض مسبق', 'Headings': 'العناوين', 'Paragraph': 'فقرة', 'Bold': 'خط عريض', 'Italic': 'خط مائل', 'Strike': 'إضراب', 'Code': 'رمز', 'Line': 'خط', 'Blockquote': 'فقرة مقتبسة', 'Unordered list': 'قائمة غير مرتبة', 'Ordered list': 'قائمة مرتبة', 'Task': 'مهمة', 'Indent': 'المسافة البادئة', 'Outdent': 'المسافة الخارجة', 'Insert link': 'أدخل الرابط', 'Insert CodeBlock': 'أدخل الكود', 'Insert table': 'أدخل جدول', 'Insert image': 'أدخل صورة', 'Heading': 'عنوان', 'Image URL': 'رابط الصورة', 'Select image file': 'حدد ملف الصورة', 'Description': 'وصف', 'OK': 'موافقة', 'More': 'أكثر', 'Cancel': 'إلغاء', 'File': 'ملف', 'URL': 'رابط', 'Link text': 'نص الرابط', 'Add row': 'ضف سطر', 'Add col': 'ضف عمود', 'Remove row': 'حذف سطر', 'Remove col': 'حذف عمود', 'Align left': 'محاذاة اليسار', 'Align center': 'محاذاة الوسط', 'Align right': 'محاذاة اليمين', 'Remove table': 'حذف الجدول', 'Would you like to paste as table?': 'هل تريد اللصق كجدول', 'Text color': 'لون النص', 'Auto scroll enabled': 'التحريك التلقائي ممكّن', 'Auto scroll disabled': 'التحريك التلقائي معطّل', 'Choose language': 'اختر اللغة' }); /** * @fileoverview I18N for Arabic * @author Amira Salah */ /***/ }), /* 143 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } _i18n2.default.setLanguage(['pl', 'pl_PL'], { 'Markdown': 'Markdown', 'WYSIWYG': 'WYSIWYG', 'Write': 'Napisz', 'Preview': 'Podgląd', 'Headings': 'Nagłówki', 'Paragraph': 'Akapit', 'Bold': 'Pogrubienie', 'Italic': 'Kursywa', 'Strike': 'Przekreślenie', 'Code': 'Fragment kodu', 'Line': 'Linia', 'Blockquote': 'Cytat', 'Unordered list': 'Lista nieuporządkowana', 'Ordered list': 'Lista uporządkowana', 'Task': 'Zadanie', 'Indent': 'Utwórz wcięcie', 'Outdent': 'Usuń wcięcie', 'Insert link': 'Umieść odnośnik', 'Insert CodeBlock': 'Umieść blok kodu', 'Insert table': 'Umieść tabelę', 'Insert image': 'Umieść obraz', 'Heading': 'Nagłówek', 'Image URL': 'Adres URL obrazu', 'Select image file': 'Wybierz plik obrazu', 'Description': 'Opis', 'OK': 'OK', 'More': 'Więcej', 'Cancel': 'Anuluj', 'File': 'Plik', 'URL': 'URL', 'Link text': 'Tekst odnośnika', 'Add row': 'Dodaj rząd', 'Add col': 'Dodaj kolumnę', 'Remove row': 'Usuń rząd', 'Remove col': 'Usuń kolumnę', 'Align left': 'Wyrównaj do lewej', 'Align center': 'Wyśrodkuj', 'Align right': 'Wyrównaj do prawej', 'Remove table': 'Usuń tabelę', 'Would you like to paste as table?': 'Czy chcesz wkleić tekst jako tabelę?', 'Text color': 'Kolor tekstu', 'Auto scroll enabled': 'Włączono automatyczne przewijanie', 'Auto scroll disabled': 'Wyłączono automatyczne przewijanie', 'Choose language': 'Wybierz język' }); /** * @fileoverview I18N for Polish * @author Marcin Mikołajczak */ /***/ }), /* 144 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _i18n = __webpack_require__(3); var _i18n2 = _interopRequireDefault(_i18n); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } _i18n2.default.setLanguage(['zhtw', 'zh_TW'], { 'Markdown': 'Markdown', 'WYSIWYG': '所見即所得', 'Write': '編輯', 'Preview': '預覽', 'Headings': '標題', 'Paragraph': '內文', 'Bold': '粗體', 'Italic': '斜體', 'Strike': '刪除線', 'Code': '內嵌程式碼', 'Line': '分隔線', 'Blockquote': '引言', 'Unordered list': '項目符號清單', 'Ordered list': '編號清單', 'Task': '核取方塊清單', 'Indent': '增加縮排', 'Outdent': '減少縮排', 'Insert link': '插入超連結', 'Insert CodeBlock': '插入程式碼區塊', 'Insert table': '插入表格', 'Insert image': '插入圖片', 'Heading': '標題', 'Image URL': '圖片網址', 'Select image file': '選擇圖片檔案', 'Description': '描述', 'OK': '確認', 'More': '更多', 'Cancel': '取消', 'File': '檔案', 'URL': 'URL', 'Link text': '超連結文字', 'Add row': '增加行', 'Add col': '增加列', 'Remove row': '刪除行', 'Remove col': '刪除列', 'Align left': '靠左對齊', 'Align center': '置中', 'Align right': '靠右對齊', 'Remove table': '刪除表格', 'Would you like to paste as table?': '您要以表格貼上嗎?', 'Text color': '文字顏色', 'Auto scroll enabled': '已啟用自動滾動', 'Auto scroll disabled': '已停用自動滾動', 'Choose language': '選擇語言' }); /** * @fileoverview I18N for Traditional Chinese * @author Tzu-Ray Su */ /***/ }) /******/ ]); });