UNPKG

tui-editor

Version:

GFM Markdown Wysiwyg Editor - Productive and Extensible

1,719 lines (1,449 loc) 493 kB
/*! * tui-editor * @version 1.4.10 * @author NHN FE Development Lab <dl_javascript@nhn.com> (https://nhn.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("to-mark"), require("tui-chart"), require("markdown-it"), require("highlight.js"), require("tui-color-picker"), require("plantuml-encoder")); else if(typeof define === 'function' && define.amd) define(["jquery", "tui-code-snippet", "to-mark", "tui-chart", "markdown-it", "highlight.js", "tui-color-picker", "plantuml-encoder"], factory); else if(typeof exports === 'object') exports["Editor"] = factory(require("jquery"), require("tui-code-snippet"), require("to-mark"), require("tui-chart"), require("markdown-it"), require("highlight.js"), require("tui-color-picker"), require("plantuml-encoder")); else root["tui"] = root["tui"] || {}, root["tui"]["Editor"] = factory(root["$"], root["tui"]["util"], root["toMark"], root["tui"]["chart"], root["markdownit"], root["hljs"], root["tui"]["colorPicker"], root["plantumlEncoder"]); })(window, function(__WEBPACK_EXTERNAL_MODULE__0__, __WEBPACK_EXTERNAL_MODULE__1__, __WEBPACK_EXTERNAL_MODULE__17__, __WEBPACK_EXTERNAL_MODULE__29__, __WEBPACK_EXTERNAL_MODULE__39__, __WEBPACK_EXTERNAL_MODULE__49__, __WEBPACK_EXTERNAL_MODULE__82__, __WEBPACK_EXTERNAL_MODULE__84__) { 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, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // 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 = 27); /******/ }) /************************************************************************/ /******/ ([ /* 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 }); /** * @fileoverview Editor/Viewer proxy for extensions * @author NHN FE Development Lab <dl_javascript@nhn.com> */ /* eslint global-require: 0 no-empty: 0 */ var Editor = void 0; try { Editor = __webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module '../editor'"); e.code = 'MODULE_NOT_FOUND'; throw e; }())); } catch (e) {} if (!Editor) { try { Editor = __webpack_require__(16); } catch (e) {} } exports.default = Editor; /***/ }), /* 3 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createTableData = createTableData; exports.createCellIndexData = createCellIndexData; 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 }; } /** * Parse cell like td or th. * @param {HTMLElement} cell - cell element like td or th * @param {number} rowIndex - row index * @param {number} colIndex - column index * @returns {{ * nodeName: string, * colspan: number, * rowspan: number, * content: string, * align: ?string * }} * @private */ /** * @fileoverview Implements tableDataHandler * @author NHN FE Development Lab <dl_javascript@nhn.com> */ function _parseCell(cell, rowIndex, colIndex) { var $cell = (0, _jquery2.default)(cell); var colspan = $cell.attr('colspan'); var rowspan = $cell.attr('rowspan'); var nodeName = cell.nodeName; if (nodeName !== 'TH' && nodeName !== 'TD') { return null; } var cellData = { nodeName: cell.nodeName, colspan: colspan ? parseInt(colspan, 10) : 1, rowspan: rowspan ? parseInt(rowspan, 10) : 1, content: $cell.html(), elementIndex: { rowIndex: rowIndex, colIndex: colIndex } }; if (cell.nodeName === 'TH' && cell.align) { cellData.align = cell.align; } return cellData; } /** * Add merged cell. * @param {object} base - base table data * @param {object} cellData - cell data * @param {number} startRowIndex - start row index * @param {number} startCellIndex - start cell index * @private */ function _addMergedCell(base, cellData, startRowIndex, startCellIndex) { var colspan = cellData.colspan, rowspan = cellData.rowspan, nodeName = cellData.nodeName; var colMerged = colspan > 1; var rowMerged = rowspan > 1; if (!colMerged && !rowMerged) { return; } var limitRowIndex = startRowIndex + rowspan; var limitCellIndex = startCellIndex + colspan; _tuiCodeSnippet2.default.range(startRowIndex, limitRowIndex).forEach(function (rowIndex) { base[rowIndex] = base[rowIndex] || []; _tuiCodeSnippet2.default.range(startCellIndex, limitCellIndex).forEach(function (cellIndex) { var mergedData = { nodeName: nodeName }; if (rowIndex === startRowIndex && cellIndex === startCellIndex) { return; } if (colMerged) { mergedData.colMergeWith = startCellIndex; } if (rowMerged) { mergedData.rowMergeWith = startRowIndex; } base[rowIndex][cellIndex] = mergedData; }); }); } /** * Create table data from jQuery table Element. * @param {jQuery} $table - jQuery table element * @returns {Array.<Array.<object>>} * @ignore */ function createTableData($table) { var tableData = []; $table.find('tr').each(function (rowIndex, tr) { var stackedColCount = 0; tableData[rowIndex] = tableData[rowIndex] || []; (0, _jquery2.default)(tr).children().each(function (colIndex, cell) { var cellData = _parseCell(cell, rowIndex, colIndex); if (!cellData) { return; } var dataColIndex = colIndex + stackedColCount; while (tableData[rowIndex][dataColIndex]) { dataColIndex += 1; stackedColCount += 1; } tableData[rowIndex][dataColIndex] = cellData; _addMergedCell(tableData, cellData, rowIndex, dataColIndex); }); }); if ($table[0].className) { tableData.className = $table[0].className; } return tableData; } /** * Create cell index data of table data. * @param {Array.<Array.<object>>} tableData - table data * @returns {Array.<Array.<object>>} * @ignore */ function createCellIndexData(tableData) { var mappingData = []; tableData.forEach(function (row, rowIndex) { var mappingRow = []; row.forEach(function (cell, colIndex) { if (_tuiCodeSnippet2.default.isUndefined(cell.colMergeWith) && _tuiCodeSnippet2.default.isUndefined(cell.rowMergeWith)) { mappingRow.push({ rowIndex: rowIndex, colIndex: colIndex }); } }); mappingData.push(mappingRow); }); return mappingData; } /** * Get header aligns. * @param {Array.<Array.<object>>} tableData - table data * @returns {Array.<?string>} * @private */ function _getHeaderAligns(tableData) { var headRowData = tableData[0]; return headRowData.map(function (cellData) { var align = void 0; if (_tuiCodeSnippet2.default.isExisty(cellData.colMergeWith)) { align = headRowData[cellData.colMergeWith].align; } else { align = cellData.align; } return align; }); } /** * Create render data. * @param {Array.<object>} tableData - table data * @param {Array.<object>} cellIndexData - cell index data * @returns {Array.<Array.<object>>} * @ignore */ function createRenderData(tableData, cellIndexData) { var headerAligns = _getHeaderAligns(tableData); var renderData = cellIndexData.map(function (row) { return row.map(function (_ref) { var rowIndex = _ref.rowIndex, colIndex = _ref.colIndex; return _tuiCodeSnippet2.default.extend({ align: headerAligns[colIndex] }, tableData[rowIndex][colIndex]); }); }); if (tableData.className) { renderData.className = tableData.className; } return renderData; } var BASIC_CELL_CONTENT = _tuiCodeSnippet2.default.browser.msie ? '' : '<br>'; /** * Create basic cell data. * @param {number} rowIndex - row index * @param {number} colIndex - column index * @param {string} nodeName - node name * @returns {{ * nodeName: string, * colspan: number, * rowspan: number, * content: string * }} * @ignore */ function createBasicCell(rowIndex, colIndex, nodeName) { return { nodeName: nodeName || 'TD', colspan: 1, rowspan: 1, content: BASIC_CELL_CONTENT, elementIndex: { rowIndex: rowIndex, colIndex: colIndex } }; } /** * Find element row index. * @param {jQuery} $cell - cell jQuery element like td or th * @returns {number} * @ignore */ function findElementRowIndex($cell) { var $tr = $cell.closest('tr'); var rowIndex = $tr.prevAll().length; if ($tr.parent()[0].nodeName === 'TBODY') { rowIndex += 1; } return rowIndex; } /** * Find element col index. * @param {jQuery} $cell - cell jQuery element like td or th * @returns {number} * @ignore */ function findElementColIndex($cell) { return $cell.closest('td, th').prevAll().length; } /** * Find indexes of base table data from mappin data. * @param {Array.<Array.<object>>} cellIndexData - cell index data * @param {jQuery} $cell - cell jQuery element like td or th * @returns {{rowIndex: number, cellIndex: number}} * @ignore */ function findCellIndex(cellIndexData, $cell) { var elementRowIndex = findElementRowIndex($cell); var elementColIndex = findElementColIndex($cell); return cellIndexData[elementRowIndex][elementColIndex]; } /** * Find last index of col merged cells. * @param {Array.<Array.<object>>} tableData - tableData data * @param {number} rowIndex - row index of base data * @param {number} colIndex - column index of tabld data * @returns {number} * @ignore */ function findRowMergedLastIndex(tableData, rowIndex, colIndex) { var cellData = tableData[rowIndex][colIndex]; var foundRowIndex = rowIndex; if (cellData.rowspan > 1) { foundRowIndex += cellData.rowspan - 1; } return foundRowIndex; } /** * Find last index of col merged cells. * @param {Array.<Array.<object>>} tableData - tableData data * @param {number} rowIndex - row index of base data * @param {number} colIndex - column index of tabld data * @returns {number} * @ignore */ function findColMergedLastIndex(tableData, rowIndex, colIndex) { var cellData = tableData[rowIndex][colIndex]; var foundColIndex = colIndex; if (cellData.colspan > 1) { foundColIndex += cellData.colspan - 1; } return foundColIndex; } /** * Find cell element index. * @param {Array.<Array.<object>>} tableData - tableData data * @param {number} rowIndex - row index of base data * @param {number} colIndex - col index of base data * @returns {{rowIndex: number, colIndex: number}} * @ignore */ function findElementIndex(tableData, rowIndex, colIndex) { var cellData = tableData[rowIndex][colIndex]; rowIndex = _tuiCodeSnippet2.default.isExisty(cellData.rowMergeWith) ? cellData.rowMergeWith : rowIndex; colIndex = _tuiCodeSnippet2.default.isExisty(cellData.colMergeWith) ? cellData.colMergeWith : colIndex; return tableData[rowIndex][colIndex].elementIndex; } /** * Stuff cells into incomplete row. * @param {Array.<Array.<object>>} tableData - table data * @param {number} limitIndex - limit index * @ignore */ function stuffCellsIntoIncompleteRow(tableData, limitIndex) { tableData.forEach(function (rowData, rowIndex) { var startIndex = rowData.length; if (startIndex) { var nodeName = rowData[0].nodeName; _tuiCodeSnippet2.default.range(startIndex, limitIndex).forEach(function (colIndex) { rowData.push(createBasicCell(rowIndex, colIndex, nodeName)); }); } }); } /** * Add tbody or thead of table data if need. * @param {Array.<Array.<object>>} tableData - table data * @returns {boolean} * @ignore */ function addTbodyOrTheadIfNeed(tableData) { var header = tableData[0]; var cellCount = header.length; var added = true; if (!cellCount && tableData[1]) { _tuiCodeSnippet2.default.range(0, tableData[1].length).forEach(function (colIndex) { header.push(createBasicCell(0, colIndex, 'TH')); }); } else if (tableData[0][0].nodeName !== 'TH') { var _ref2; var newHeader = _tuiCodeSnippet2.default.range(0, cellCount).map(function (colIndex) { return createBasicCell(0, colIndex, 'TH'); }); (_ref2 = []).concat.apply(_ref2, tableData).forEach(function (cellData) { if (cellData.elementIndex) { cellData.elementIndex.rowIndex += 1; } }); tableData.unshift(newHeader); } else if (tableData.length === 1) { var newRow = _tuiCodeSnippet2.default.range(0, cellCount).map(function (colIndex) { return createBasicCell(1, colIndex, 'TD'); }); tableData.push(newRow); } else { added = false; } return added; } exports.default = { createTableData: createTableData, createCellIndexData: createCellIndexData, createRenderData: createRenderData, findElementRowIndex: findElementRowIndex, findElementColIndex: findElementColIndex, findCellIndex: findCellIndex, createBasicCell: createBasicCell, findRowMergedLastIndex: findRowMergedLastIndex, findColMergedLastIndex: findColMergedLastIndex, findElementIndex: findElementIndex, stuffCellsIntoIncompleteRow: stuffCellsIntoIncompleteRow, addTbodyOrTheadIfNeed: addTbodyOrTheadIfNeed }; /***/ }), /* 4 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _jquery = __webpack_require__(0); var _jquery2 = _interopRequireDefault(_jquery); var _tableDataHandler = __webpack_require__(3); var _tableDataHandler2 = _interopRequireDefault(_tableDataHandler); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Create cell html. * @param {object} cell - cell data of table base data * @returns {string} * @private */ /** * @fileoverview Implements tableRenderer * @author NHN FE Development Lab <dl_javascript@nhn.com> */ function _createCellHtml(cell) { var attrs = cell.colspan > 1 ? ' colspan="' + cell.colspan + '"' : ''; attrs += cell.rowspan > 1 ? ' rowspan="' + cell.rowspan + '"' : ''; attrs += cell.align ? ' align="' + cell.align + '"' : ''; return '<' + cell.nodeName + attrs + '>' + cell.content + '</' + cell.nodeName + '>'; } /** * Create html for thead or tbody. * @param {Array.<Array.<object>>} trs - tr list * @param {string} wrapperNodeName - wrapper node name like THEAD, TBODY * @returns {string} * @private */ function _createTheadOrTbodyHtml(trs, wrapperNodeName) { var html = ''; if (trs.length) { html = trs.map(function (tr) { var tdHtml = tr.map(_createCellHtml).join(''); return '<tr>' + tdHtml + '</tr>'; }).join(''); html = '<' + wrapperNodeName + '>' + html + '</' + wrapperNodeName + '>'; } return html; } /** * Create table html. * @param {Array.<Array.<object>>} renderData - table data for render * @returns {string} * @private */ function createTableHtml(renderData) { var thead = renderData[0] ? [renderData[0]] : []; var tbody = renderData.slice(1); var theadHtml = _createTheadOrTbodyHtml(thead, 'THEAD'); var tbodyHtml = _createTheadOrTbodyHtml(tbody, 'TBODY'); var className = renderData.className ? ' class="' + renderData.className + '"' : ''; return '<table' + className + '>' + (theadHtml + tbodyHtml) + '</table>'; } /** * Replace table. * @param {jQuery} $table - table jQuery element * @param {Array.<Array.<object>>} tableData - table data * @returns {jQuery} * @ignore */ function replaceTable($table, tableData) { var cellIndexData = _tableDataHandler2.default.createCellIndexData(tableData); var renderData = _tableDataHandler2.default.createRenderData(tableData, cellIndexData); var $newTable = (0, _jquery2.default)(createTableHtml(renderData)); $table.replaceWith($newTable); return $newTable; } /** * Focus to cell. * @param {squireext} sq - squire instance * @param {range} range - range object * @param {HTMLElement} targetCell - cell element for focus * @ignore */ function focusToCell(sq, range, targetCell) { range.selectNodeContents(targetCell); range.collapse(true); sq.setSelection(range); } exports.default = { createTableHtml: createTableHtml, replaceTable: replaceTable, focusToCell: focusToCell }; /***/ }), /* 5 */ /***/ (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 _tableDataHandler = __webpack_require__(3); var _tableDataHandler2 = _interopRequireDefault(_tableDataHandler); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Find unmerged table range. * @param {Array.<Array.<object>>} tableData - table data * @param {jQuery} $start - start talbe cell jQuery element * @param {jQuery} $end - end table cell jQuery element * @returns {{ * start: {rowIndex: number, colIndex: number}, * end: {rowIndex: number, colIndex: number} * }} * @private */ function _findUnmergedRange(tableData, $start, $end) { var cellIndexData = _tableDataHandler2.default.createCellIndexData(tableData); var startCellIndex = _tableDataHandler2.default.findCellIndex(cellIndexData, $start); var endCellIndex = _tableDataHandler2.default.findCellIndex(cellIndexData, $end); var startRowIndex = void 0, endRowIndex = void 0, startColIndex = void 0, endColIndex = void 0; if (startCellIndex.rowIndex > endCellIndex.rowIndex) { startRowIndex = endCellIndex.rowIndex; endRowIndex = startCellIndex.rowIndex; } else { startRowIndex = startCellIndex.rowIndex; endRowIndex = endCellIndex.rowIndex; } if (startCellIndex.colIndex > endCellIndex.colIndex) { startColIndex = endCellIndex.colIndex; endColIndex = startCellIndex.colIndex; } else { startColIndex = startCellIndex.colIndex; endColIndex = endCellIndex.colIndex; } return { start: { rowIndex: startRowIndex, colIndex: startColIndex }, end: { rowIndex: endRowIndex, colIndex: endColIndex } }; } /** * Expand table range by row merge properties like rowspan, rowMergeWith. * @param {Array.<Array.<object>>} tableData - table data * @param {{ * start: {rowIndex: number, colIndex: number}, * end: {rowIndex: number, colIndex: number} * }} tableRange - table range * @param {string} rangeType - range type like start, end * @private */ /** * @fileoverview Implements tableRangeHandler * @author NHN FE Development Lab <dl_javascript@nhn.com> */ function _expandRowMergedRange(tableData, tableRange, rangeType) { var rowIndex = tableRange[rangeType].rowIndex; var rowData = tableData[rowIndex]; _tuiCodeSnippet2.default.range(tableRange.start.colIndex, tableRange.end.colIndex + 1).forEach(function (colIndex) { var cellData = rowData[colIndex]; var rowMergeWith = cellData.rowMergeWith; var lastRowMergedIndex = -1; if (_tuiCodeSnippet2.default.isExisty(rowMergeWith)) { if (rowMergeWith < tableRange.start.rowIndex) { tableRange.start.rowIndex = rowMergeWith; } lastRowMergedIndex = rowMergeWith + tableData[rowMergeWith][colIndex].rowspan - 1; } else if (cellData.rowspan > 1) { lastRowMergedIndex = rowIndex + cellData.rowspan - 1; } if (lastRowMergedIndex > tableRange.end.rowIndex) { tableRange.end.rowIndex = lastRowMergedIndex; } }); } /** * Expand table range by column merge properties like colspan, colMergeWith. * @param {Array.<Array.<object>>} tableData - table data * @param {{ * start: {rowIndex: number, colIndex: number}, * end: {rowIndex: number, colIndex: number} * }} tableRange - table range * @param {number} rowIndex - row index * @param {number} colIndex - column index * @private */ function _expandColMergedRange(tableData, tableRange, rowIndex, colIndex) { var rowData = tableData[rowIndex]; var cellData = rowData[colIndex]; var colMergeWith = cellData.colMergeWith; var lastColMergedIndex = -1; if (_tuiCodeSnippet2.default.isExisty(colMergeWith)) { if (colMergeWith < tableRange.start.colIndex) { tableRange.start.colIndex = colMergeWith; } lastColMergedIndex = colMergeWith + rowData[colMergeWith].colspan - 1; } else if (cellData.colspan > 1) { lastColMergedIndex = colIndex + cellData.colspan - 1; } if (lastColMergedIndex > tableRange.end.colIndex) { tableRange.end.colIndex = lastColMergedIndex; } } /** * Expand table range by merge properties like colspan, rowspan. * @param {Array.<Array.<object>>} tableData - table data * @param {{ * start: {rowIndex: number, colIndex: number}, * end: {rowIndex: number, colIndex: number} * }} tableRange - table range * @returns {{ * start: {rowIndex: number, colIndex: number}, * end: {rowIndex: number, colIndex: number} * }} * @private */ function _expandMergedRange(tableData, tableRange) { var rangeStr = ''; while (rangeStr !== JSON.stringify(tableRange)) { rangeStr = JSON.stringify(tableRange); _expandRowMergedRange(tableData, tableRange, 'start'); _expandRowMergedRange(tableData, tableRange, 'end'); _tuiCodeSnippet2.default.range(tableRange.start.rowIndex, tableRange.end.rowIndex + 1).forEach(function (rowIndex) { _expandColMergedRange(tableData, tableRange, rowIndex, tableRange.start.colIndex); _expandColMergedRange(tableData, tableRange, rowIndex, tableRange.end.colIndex); }); } return tableRange; } /** * Find table range for selection. * @param {Array.<Array.<object>>} tableData - table data * @param {jQuery} $start - start jQuery element * @param {jQuery} $end - end jQuery element * @returns {{ * start: {rowIndex: number, colIndex: number}, * end: {rowIndex: number, colIndex: number} * }} * @ignore */ function findSelectionRange(tableData, $start, $end) { var unmergedRange = _findUnmergedRange(tableData, $start, $end); return _expandMergedRange(tableData, unmergedRange); } /** * Get table selection range. * @param {Array.<Array.<object>>} tableData - table data * @param {jQuery} $selectedCells - selected cells jQuery elements * @param {jQuery} $startContainer - start container jQuery element of text range * @returns {{ * start: {rowIndex: number, colIndex: number}, * end: {rowIndex: number, colIndex: number} *}} * @ignore */ function getTableSelectionRange(tableData, $selectedCells, $startContainer) { var cellIndexData = _tableDataHandler2.default.createCellIndexData(tableData); var tableRange = {}; if ($selectedCells.length) { var startRange = _tableDataHandler2.default.findCellIndex(cellIndexData, $selectedCells.first()); var endRange = _tuiCodeSnippet2.default.extend({}, startRange); $selectedCells.each(function (index, cell) { var cellIndex = _tableDataHandler2.default.findCellIndex(cellIndexData, (0, _jquery2.default)(cell)); var cellData = tableData[cellIndex.rowIndex][cellIndex.colIndex]; var lastRowMergedIndex = cellIndex.rowIndex + cellData.rowspan - 1; var lastColMergedIndex = cellIndex.colIndex + cellData.colspan - 1; endRange.rowIndex = Math.max(endRange.rowIndex, lastRowMergedIndex); endRange.colIndex = Math.max(endRange.colIndex, lastColMergedIndex); }); tableRange.start = startRange; tableRange.end = endRange; } else { var cellIndex = _tableDataHandler2.default.findCellIndex(cellIndexData, $startContainer); tableRange.start = cellIndex; tableRange.end = _tuiCodeSnippet2.default.extend({}, cellIndex); } return tableRange; } exports.default = { findSelectionRange: findSelectionRange, getTableSelectionRange: getTableSelectionRange }; /***/ }), /* 6 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to permit // persons to whom the Software is furnished to do so, subject to the // following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. // a duplex stream is just a stream that is both readable and writable. // Since JS doesn't have multiple prototypal inheritance, this class // prototypally inherits from Readable, and then parasitically from // Writable. /*<replacement>*/ var pna = __webpack_require__(11); /*</replacement>*/ /*<replacement>*/ var objectKeys = Object.keys || function (obj) { var keys = []; for (var key in obj) { keys.push(key); }return keys; }; /*</replacement>*/ module.exports = Duplex; /*<replacement>*/ var util = __webpack_require__(9); util.inherits = __webpack_require__(7); /*</replacement>*/ var Readable = __webpack_require__(20); var Writable = __webpack_require__(15); util.inherits(Duplex, Readable); { // avoid scope creep, the keys array can then be collected var keys = objectKeys(Writable.prototype); for (var v = 0; v < keys.length; v++) { var method = keys[v]; if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; } } function Duplex(options) { if (!(this instanceof Duplex)) return new Duplex(options); Readable.call(this, options); Writable.call(this, options); if (options && options.readable === false) this.readable = false; if (options && options.writable === false) this.writable = false; this.allowHalfOpen = true; if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; this.once('end', onend); } Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { // making it explicit this property is not enumerable // because otherwise some prototype manipulation in // userland will fail enumerable: false, get: function () { return this._writableState.highWaterMark; } }); // the no-half-open enforcer function onend() { // if we allow half-open state, or if the writable side ended, // then we're ok. if (this.allowHalfOpen || this._writableState.ended) return; // no more data can be written. // But allow more writes to happen in this tick. pna.nextTick(onEndNT, this); } function onEndNT(self) { self.end(); } Object.defineProperty(Duplex.prototype, 'destroyed', { get: function () { if (this._readableState === undefined || this._writableState === undefined) { return false; } return this._readableState.destroyed && this._writableState.destroyed; }, set: function (value) { // we ignore the value if the stream // has not been initialized yet if (this._readableState === undefined || this._writableState === undefined) { return; } // backward compatibility, the user is explicitly // managing destroyed this._readableState.destroyed = value; this._writableState.destroyed = value; } }); Duplex.prototype._destroy = function (err, cb) { this.push(null); this.end(); pna.nextTick(cb, err); }; /***/ }), /* 7 */ /***/ (function(module, exports) { if (typeof Object.create === 'function') { // implementation from standard node.js 'util' module module.exports = function inherits(ctor, superCtor) { if (superCtor) { ctor.super_ = superCtor ctor.prototype = Object.create(superCtor.prototype, { constructor: { value: ctor, enumerable: false, writable: true, configurable: true } }) } }; } else { // old school shim for old browsers module.exports = function inherits(ctor, superCtor) { if (superCtor) { ctor.super_ = superCtor var TempCtor = function () {} TempCtor.prototype = superCtor.prototype ctor.prototype = new TempCtor() ctor.prototype.constructor = ctor } } } /***/ }), /* 8 */ /***/ (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 || new Function("return 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; /***/ }), /* 9 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to permit // persons to whom the Software is furnished to do so, subject to the // following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. // NOTE: These type checking functions intentionally don't use `instanceof` // because it is fragile and can be easily faked with `Object.create()`. function isArray(arg) { if (Array.isArray) { return Array.isArray(arg); } return objectToString(arg) === '[object Array]'; } exports.isArray = isArray; function isBoolean(arg) { return typeof arg === 'boolean'; } exports.isBoolean = isBoolean; function isNull(arg) { return arg === null; } exports.isNull = isNull; function isNullOrUndefined(arg) { return arg == null; } exports.isNullOrUndefined = isNullOrUndefined; function isNumber(arg) { return typeof arg === 'number'; } exports.isNumber = isNumber; function isString(arg) { return typeof arg === 'string'; } exports.isString = isString; function isSymbol(arg) { return typeof arg === 'symbol'; } exports.isSymbol = isSymbol; function isUndefined(arg) { return arg === void 0; } exports.isUndefined = isUndefined; function isRegExp(re) { return objectToString(re) === '[object RegExp]'; } exports.isRegExp = isRegExp; function isObject(arg) { return typeof arg === 'object' && arg !== null; } exports.isObject = isObject; function isDate(d) { return objectToString(d) === '[object Date]'; } exports.isDate = isDate; function isError(e) { return (objectToString(e) === '[object Error]' || e instanceof Error); } exports.isError = isError; function isFunction(arg) { return typeof arg === 'function'; } exports.isFunction = isFunction; function isPrimitive(arg) { return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || typeof arg === 'symbol' || // ES6 symbol typeof arg === 'undefined'; } exports.isPrimitive = isPrimitive; exports.isBuffer = Buffer.isBuffer; function objectToString(o) { return Object.prototype.toString.call(o); } /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(23).Buffer)) /***/ }), /* 10 */ /***/ (function(module, exports) { // shim for using process in browser var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it // don't break things. But we need to wrap it in a try catch in case it is // wrapped in strict mode code which doesn't define any globals. It's inside a // function because try/catches deoptimize in certain engines. var cachedSetTimeout; var cachedClearTimeout; function defaultSetTimout() { throw new Error('setTimeout has not been defined'); } function defaultClearTimeout () { throw new Error('clearTimeout has not been defined'); } (function () { try { if (typeof setTimeout === 'function') { cachedSetTimeout = setTimeout; } else { cachedSetTimeout = defaultSetTimout; } } catch (e) { cachedSetTimeout = defaultSetTimout; } try { if (typeof clearTimeout === 'function') { cachedClearTimeout = clearTimeout; } else { cachedClearTimeout = defaultClearTimeout; } } catch (e) { cachedClearTimeout = defaultClearTimeout; } } ()) function runTimeout(fun) { if (cachedSetTimeout === setTimeout) { //normal enviroments in sane situations return setTimeout(fun, 0); } // if setTimeout wasn't available but was latter defined if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { cachedSetTimeout = setTimeout; return setTimeout(fun, 0); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedSetTimeout(fun, 0); } catch(e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedSetTimeout.call(null, fun, 0); } catch(e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error return cachedSetTimeout.call(this, fun, 0); } } } function runClearTimeout(marker) { if (cachedClearTimeout === clearTimeout) { //normal enviroments in sane situations return clearTimeout(marker); } // if clearTimeout wasn't available but was latter defined if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { cachedClearTimeout = clearTimeout; return clearTimeout(marker); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedClearTimeout(marker); } catch (e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedClearTimeout.call(null, marker); } catch (e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. // Some versions of I.E. have different rules for clearTimeout vs setTimeout return cachedClearTimeout.call(this, marker); } } } var queue = []; var draining = false; var currentQueue; var queueIndex = -1; function cleanUpNextTick() { if (!draining || !currentQueue) { return; } draining = false; if (currentQueue.length) { queue = currentQueue.concat(queue); } else { queueIndex = -1; } if (queue.length) { drainQueue(); } } function drainQueue() { if (draining) { return; } var timeout = runTimeout(cleanUpNextTick); draining = true; var len = queue.length; while(len) { currentQueue = queue; queue = []; while (++queueIndex < len) { if (currentQueue) { currentQueue[queueIndex].run(); } } queueIndex = -1; len = queue.length; } currentQueue = null; draining = false; runClearTimeout(timeout); } process.nextTick = function (fun) { var args = new Array(arguments.length - 1); if (arguments.length > 1) { for (var i = 1; i < arguments.length; i++) { args[i - 1] = arguments[i]; } } queue.push(new Item(fun, args)); if (queue.length === 1 && !draining) { runTimeout(drainQueue); } }; // v8 likes predictible objects function Item(fun, array) { this.fun = fun; this.array = array; } Item.prototype.run = function () { this.fun.apply(null, this.array); }; process.title = 'browser'; process.browser = true; process.env = {}; process.argv = []; process.version = ''; // empty string to avoid regexp issues process.versions = {}; function noop() {} process.on = noop; process.addListener = noop; process.once = noop; process.off = noop; process.removeListener = noop; process.removeAllListeners = noop; process.emit = noop; process.prependListener = noop; process.prependOnceListener = noop; process.listeners = function (name) { return [] } process.binding = function (name) { throw new Error('process.binding is not supported'); }; process.cwd = function () { return '/' }; process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; process.umask = function() { return 0; }; /***/ }), /* 11 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(process) { if (typeof process === 'undefined' || !process.version || process.version.indexOf('v0.') === 0 || process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { module.exports = { nextTick: nextTick }; } else { module.exports = process } function nextTick(fn, arg1, arg2, arg3) { if (typeof fn !== 'function') { throw new TypeError('"callback" argument must be a function'); } var len = arguments.length; var args, i; switch (len) { case 0: case 1: return process.nextTick(fn); case 2: return process.nextTick(function afterTickOne() { fn.call(null, arg1); }); case 3: return process.nextTick(function afterTickTwo() { fn.call(null, arg1, arg2); }); case 4: return process.nextTick(function afterTickThree() { fn.call(null, arg1, arg2, arg3); }); default: args = new Array(len - 1); i = 0; while (i < args.length) { args[i++] = arguments[i]; } return process.nextTick(function afterTick() { fn.apply(null, args); }); } } /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(10))) /***/ }), /* 12 */ /***/ (function(module, exports, __webpack_require__) { /* eslint-disable node/no-deprecated-api */ var buffer = __webpack_require__(23) var Buffer = buffer.Buffer // alternative to using Object.keys for old browsers function copyProps (src, dst) { for (var key in src) { dst[key] = src[key] } } if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { module.exports = buffer } else { // Copy properties from require('buffer') copyProps(buffer, exports) exports.Buffer = SafeBuffer } function SafeBuffer (arg, encodingOrOffset, length) { return Buffer(arg, encodingOrOffset, length) } // Copy static methods from Buffer copyProps(Buffer, SafeBuffer) SafeBuffer.from = function (arg, encodingOrOffset, length) { if (typeof arg === 'number') { throw new TypeError('Argument must not be a number') } return Buffer(arg, encodingOrOffset, length) } SafeBuffer.alloc = function (size, fill, encoding) { if (typeof size !== 'number') { throw new TypeError('Argument must be a number') } var buf = Buffer(size) if (fill !== undefined) { if (typeof encoding === 'string') { buf.fill(fill, encoding) } else { buf.fill(fill) } } else { buf.fill(0) } return buf } SafeBuffer.allocUnsafe = function (size) { if (typeof size !== 'number') { throw new TypeError('Argument must be a number') } return Buffer(size) } SafeBuffer.allocUnsafeSlow = function (size) { if (typeof size !== 'number') { throw new TypeError('Argument must be a number') } return buffer.SlowBuffer(size) } /***/ }), /* 13 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to permit // persons to whom the Software is furnished to do so, subject to the // following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. var R = typeof Reflect === 'object' ? Reflect : null var ReflectApply = R && typeof R.apply === 'function' ? R.apply : function ReflectApply(target, receiver, args) { return Function.prototype.apply.call(target, receiver, args); } var ReflectOwnKeys if (R && typeof R.ownKeys === 'function') { ReflectOwnKeys = R.ownKeys } else if (Object.getOwnPropertySymbols) { ReflectOwnKeys = function ReflectOwnKeys(target) { return Object.getOwnPropertyNames(target) .concat(Object.getOwnPropertySymbols(target)); }; } else { ReflectOwnKeys = function ReflectOwnKeys(target) { return Object.getOwnPropertyNames(target); }; } function ProcessEmitWarning(warning) { if (console && console.warn) console.warn(warning); } var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) { return value !== value; } function EventEmitter() { EventEmitter.init.call(this); } module.exports = EventEmitter; // Backwards-compat with node 0.10.x EventEmitter.EventEmitter = EventEmitter; EventEmitter.prototype._events = undefined; EventEmitter.prototype._eventsCount = 0; EventEmitter.prototype._maxListeners = undefined; // By default EventEmitters will print a warning if more than 10 listeners are // added to it. This is a useful default which helps finding memory leaks. var defaultMaxListeners = 10; Object.defineProperty(EventEmitter, 'defaultMaxListeners', { enumerable: true, get: function() { return defaultMaxListeners; }, set: function(arg) { if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) { throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.'); } defaultMaxListeners = arg; } }); EventEmitter.init = function() { if (this._events === undefined || this._events === Object.getPrototypeOf(this)._events) { this._events = Object.create(null); this._eventsCount = 0; } this._maxListeners = this._maxListeners || undefined; }; // Obviously not all Emitters should be limited to 10. This function allows // that to be increased. Set to zero for unlimited. EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) { throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.'); } this._maxListeners = n; return this; }; function $getMaxListeners(that) { if (that._maxListeners === undefined) return EventEmitter.defaultMaxListeners; return that._maxListeners; } EventEmitter.prototype.getMaxListeners = function getMaxListeners() { return $getMaxListeners(this); }; EventEmitter.prototype.emit = function emit(type) { var args = []; for (var i = 1; i < arguments.length; i++) args.push(arguments[i]); var doError = (type === 'error'); var events = this._events; if (events !== undefined) doError = (doError && events.error === undefined); else if (!doError) return false; // If there is no 'error' event listener then throw. if (doError) { var er; if (args.length > 0) er = args[0]; if (er instanceof Error) { // Note: The comments on the `throw` lines are intentional, they show // up in Node's output if this results in an unhandled exception. throw er; // Unhandled 'error' event } // At least give some kind of context to the user var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : '')); err.context = er; throw err; // Unhandled 'error' event } var handler = events[type]; if (handler === undefined) return false; if (typeof handler === 'function') { ReflectApply(handler, this, args); } else { var len = handler.length; var listeners = arrayClone(handler, len); for (var i = 0; i < len; ++i) ReflectApply(listeners[i], this, args); } return true; }; function _addListener(target, type, listener, prepend) { var m; var events; var existing; if (typeof listener !== 'function') { t