@licium/editor-plugin-table-merged-cell 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +181 -0
- package/dist/toastui-editor-plugin-table-merged-cell.css +27 -0
- package/dist/toastui-editor-plugin-table-merged-cell.js +1235 -0
- package/package.json +49 -0
- package/types/index.d.ts +105 -0
|
@@ -0,0 +1,1235 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* TOAST UI Editor : Table Merged Cell Plugin
|
|
3
|
+
* @version 3.1.0 | Sun Dec 28 2025
|
|
4
|
+
* @author NHN Cloud FE Development Lab <dl_javascript@nhn.com>
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
/******/ (function() { // webpackBootstrap
|
|
8
|
+
/******/ "use strict";
|
|
9
|
+
/******/ var __webpack_modules__ = ({
|
|
10
|
+
|
|
11
|
+
/***/ 893:
|
|
12
|
+
/***/ (function(module) {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @fileoverview Execute the provided callback once for each element present in the array(or Array-like object) in ascending order.
|
|
16
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Execute the provided callback once for each element present
|
|
23
|
+
* in the array(or Array-like object) in ascending order.
|
|
24
|
+
* If the callback function returns false, the loop will be stopped.
|
|
25
|
+
* Callback function(iteratee) is invoked with three arguments:
|
|
26
|
+
* 1) The value of the element
|
|
27
|
+
* 2) The index of the element
|
|
28
|
+
* 3) The array(or Array-like object) being traversed
|
|
29
|
+
* @param {Array|Arguments|NodeList} arr The array(or Array-like object) that will be traversed
|
|
30
|
+
* @param {function} iteratee Callback function
|
|
31
|
+
* @param {Object} [context] Context(this) of callback function
|
|
32
|
+
* @memberof module:collection
|
|
33
|
+
* @example
|
|
34
|
+
* // ES6
|
|
35
|
+
* import forEachArray from 'tui-code-snippet/collection/forEachArray';
|
|
36
|
+
*
|
|
37
|
+
* // CommonJS
|
|
38
|
+
* const forEachArray = require('tui-code-snippet/collection/forEachArray');
|
|
39
|
+
*
|
|
40
|
+
* let sum = 0;
|
|
41
|
+
*
|
|
42
|
+
* forEachArray([1,2,3], function(value){
|
|
43
|
+
* sum += value;
|
|
44
|
+
* });
|
|
45
|
+
* alert(sum); // 6
|
|
46
|
+
*/
|
|
47
|
+
function forEachArray(arr, iteratee, context) {
|
|
48
|
+
var index = 0;
|
|
49
|
+
var len = arr.length;
|
|
50
|
+
|
|
51
|
+
context = context || null;
|
|
52
|
+
|
|
53
|
+
for (; index < len; index += 1) {
|
|
54
|
+
if (iteratee.call(context, arr[index], index, arr) === false) {
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
module.exports = forEachArray;
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
/***/ }),
|
|
64
|
+
|
|
65
|
+
/***/ 990:
|
|
66
|
+
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @fileoverview Transform the Array-like object to Array.
|
|
70
|
+
* @author NHN FE Development Lab <dl_javascript@nhn.com>
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
var forEachArray = __webpack_require__(893);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Transform the Array-like object to Array.
|
|
79
|
+
* In low IE (below 8), Array.prototype.slice.call is not perfect. So, try-catch statement is used.
|
|
80
|
+
* @param {*} arrayLike Array-like object
|
|
81
|
+
* @returns {Array} Array
|
|
82
|
+
* @memberof module:collection
|
|
83
|
+
* @example
|
|
84
|
+
* // ES6
|
|
85
|
+
* import toArray from 'tui-code-snippet/collection/toArray';
|
|
86
|
+
*
|
|
87
|
+
* // CommonJS
|
|
88
|
+
* const toArray = require('tui-code-snippet/collection/toArray');
|
|
89
|
+
*
|
|
90
|
+
* const arrayLike = {
|
|
91
|
+
* 0: 'one',
|
|
92
|
+
* 1: 'two',
|
|
93
|
+
* 2: 'three',
|
|
94
|
+
* 3: 'four',
|
|
95
|
+
* length: 4
|
|
96
|
+
* };
|
|
97
|
+
* const result = toArray(arrayLike);
|
|
98
|
+
*
|
|
99
|
+
* alert(result instanceof Array); // true
|
|
100
|
+
* alert(result); // one,two,three,four
|
|
101
|
+
*/
|
|
102
|
+
function toArray(arrayLike) {
|
|
103
|
+
var arr;
|
|
104
|
+
try {
|
|
105
|
+
arr = Array.prototype.slice.call(arrayLike);
|
|
106
|
+
} catch (e) {
|
|
107
|
+
arr = [];
|
|
108
|
+
forEachArray(arrayLike, function(value) {
|
|
109
|
+
arr.push(value);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return arr;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
module.exports = toArray;
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
/***/ })
|
|
120
|
+
|
|
121
|
+
/******/ });
|
|
122
|
+
/************************************************************************/
|
|
123
|
+
/******/ // The module cache
|
|
124
|
+
/******/ var __webpack_module_cache__ = {};
|
|
125
|
+
/******/
|
|
126
|
+
/******/ // The require function
|
|
127
|
+
/******/ function __webpack_require__(moduleId) {
|
|
128
|
+
/******/ // Check if module is in cache
|
|
129
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
130
|
+
/******/ if (cachedModule !== undefined) {
|
|
131
|
+
/******/ return cachedModule.exports;
|
|
132
|
+
/******/ }
|
|
133
|
+
/******/ // Create a new module (and put it into the cache)
|
|
134
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
135
|
+
/******/ // no module.id needed
|
|
136
|
+
/******/ // no module.loaded needed
|
|
137
|
+
/******/ exports: {}
|
|
138
|
+
/******/ };
|
|
139
|
+
/******/
|
|
140
|
+
/******/ // Execute the module function
|
|
141
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
142
|
+
/******/
|
|
143
|
+
/******/ // Return the exports of the module
|
|
144
|
+
/******/ return module.exports;
|
|
145
|
+
/******/ }
|
|
146
|
+
/******/
|
|
147
|
+
/************************************************************************/
|
|
148
|
+
/******/ /* webpack/runtime/compat get default export */
|
|
149
|
+
/******/ !function() {
|
|
150
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
151
|
+
/******/ __webpack_require__.n = function(module) {
|
|
152
|
+
/******/ var getter = module && module.__esModule ?
|
|
153
|
+
/******/ function() { return module['default']; } :
|
|
154
|
+
/******/ function() { return module; };
|
|
155
|
+
/******/ __webpack_require__.d(getter, { a: getter });
|
|
156
|
+
/******/ return getter;
|
|
157
|
+
/******/ };
|
|
158
|
+
/******/ }();
|
|
159
|
+
/******/
|
|
160
|
+
/******/ /* webpack/runtime/define property getters */
|
|
161
|
+
/******/ !function() {
|
|
162
|
+
/******/ // define getter functions for harmony exports
|
|
163
|
+
/******/ __webpack_require__.d = function(exports, definition) {
|
|
164
|
+
/******/ for(var key in definition) {
|
|
165
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
166
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
167
|
+
/******/ }
|
|
168
|
+
/******/ }
|
|
169
|
+
/******/ };
|
|
170
|
+
/******/ }();
|
|
171
|
+
/******/
|
|
172
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
173
|
+
/******/ !function() {
|
|
174
|
+
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
|
|
175
|
+
/******/ }();
|
|
176
|
+
/******/
|
|
177
|
+
/************************************************************************/
|
|
178
|
+
var __webpack_exports__ = {};
|
|
179
|
+
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
180
|
+
!function() {
|
|
181
|
+
|
|
182
|
+
// EXPORTS
|
|
183
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
184
|
+
"default": function() { return /* binding */ tableMergedCellPlugin; }
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
;// CONCATENATED MODULE: ./src/markdown/parser.ts
|
|
188
|
+
function getSpanInfo(content, type, oppositeType) {
|
|
189
|
+
var reSpan = new RegExp("^((?:" + oppositeType + "=[0-9]+:)?)" + type + "=([0-9]+):(.*)");
|
|
190
|
+
var parsed = reSpan.exec(content);
|
|
191
|
+
var spanCount = 1;
|
|
192
|
+
if (parsed) {
|
|
193
|
+
spanCount = parseInt(parsed[2], 10);
|
|
194
|
+
content = parsed[1] + parsed[3];
|
|
195
|
+
}
|
|
196
|
+
return [spanCount, content];
|
|
197
|
+
}
|
|
198
|
+
function extendTableCellIndexWithRowspanMap(node, parent, rowspan) {
|
|
199
|
+
var prevRow = parent.prev;
|
|
200
|
+
if (prevRow) {
|
|
201
|
+
var columnLen = parent.parent.parent.columns.length;
|
|
202
|
+
// increment the index when prev row has the rowspan count.
|
|
203
|
+
for (var i = node.startIdx; i < columnLen; i += 1) {
|
|
204
|
+
var prevRowspanCount = prevRow.rowspanMap[i];
|
|
205
|
+
if (prevRowspanCount && prevRowspanCount > 1) {
|
|
206
|
+
parent.rowspanMap[i] = prevRowspanCount - 1;
|
|
207
|
+
if (i <= node.endIdx) {
|
|
208
|
+
node.startIdx += 1;
|
|
209
|
+
node.endIdx += 1;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (rowspan > 1) {
|
|
215
|
+
var startIdx = node.startIdx, endIdx = node.endIdx;
|
|
216
|
+
for (var i = startIdx; i <= endIdx; i += 1) {
|
|
217
|
+
parent.rowspanMap[i] = rowspan;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
var markdownParsers = {
|
|
222
|
+
// @ts-expect-error
|
|
223
|
+
tableRow: function (node, _a) {
|
|
224
|
+
var entering = _a.entering;
|
|
225
|
+
if (entering) {
|
|
226
|
+
node.rowspanMap = {};
|
|
227
|
+
if (node.prev && !node.firstChild) {
|
|
228
|
+
var prevRowspanMap_1 = node.prev.rowspanMap;
|
|
229
|
+
Object.keys(prevRowspanMap_1).forEach(function (key) {
|
|
230
|
+
if (prevRowspanMap_1[key] > 1) {
|
|
231
|
+
node.rowspanMap[key] = prevRowspanMap_1[key] - 1;
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
// @ts-expect-error
|
|
238
|
+
tableCell: function (node, _a) {
|
|
239
|
+
var _b, _c;
|
|
240
|
+
var entering = _a.entering;
|
|
241
|
+
var parent = node.parent, prev = node.prev, stringContent = node.stringContent;
|
|
242
|
+
if (entering) {
|
|
243
|
+
var attrs = {};
|
|
244
|
+
var content = stringContent;
|
|
245
|
+
var _d = [1, 1], colspan = _d[0], rowspan = _d[1];
|
|
246
|
+
_b = getSpanInfo(content, '@cols', '@rows'), colspan = _b[0], content = _b[1];
|
|
247
|
+
_c = getSpanInfo(content, '@rows', '@cols'), rowspan = _c[0], content = _c[1];
|
|
248
|
+
node.stringContent = content;
|
|
249
|
+
if (prev) {
|
|
250
|
+
node.startIdx = prev.endIdx + 1;
|
|
251
|
+
node.endIdx = node.startIdx;
|
|
252
|
+
}
|
|
253
|
+
if (colspan > 1) {
|
|
254
|
+
attrs.colspan = colspan;
|
|
255
|
+
node.endIdx += colspan - 1;
|
|
256
|
+
}
|
|
257
|
+
if (rowspan > 1) {
|
|
258
|
+
attrs.rowspan = rowspan;
|
|
259
|
+
}
|
|
260
|
+
node.attrs = attrs;
|
|
261
|
+
extendTableCellIndexWithRowspanMap(node, parent, rowspan);
|
|
262
|
+
var tablePart = parent.parent;
|
|
263
|
+
if (tablePart.type === 'tableBody' && node.endIdx >= tablePart.parent.columns.length) {
|
|
264
|
+
node.ignored = true;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
;// CONCATENATED MODULE: ./src/markdown/renderer.ts
|
|
271
|
+
var __assign = (undefined && undefined.__assign) || function () {
|
|
272
|
+
__assign = Object.assign || function(t) {
|
|
273
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
274
|
+
s = arguments[i];
|
|
275
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
276
|
+
t[p] = s[p];
|
|
277
|
+
}
|
|
278
|
+
return t;
|
|
279
|
+
};
|
|
280
|
+
return __assign.apply(this, arguments);
|
|
281
|
+
};
|
|
282
|
+
var toHTMLRenderers = {
|
|
283
|
+
// @ts-ignore
|
|
284
|
+
tableRow: function (node, _a) {
|
|
285
|
+
var entering = _a.entering, origin = _a.origin;
|
|
286
|
+
if (entering) {
|
|
287
|
+
return origin();
|
|
288
|
+
}
|
|
289
|
+
var result = [];
|
|
290
|
+
if (node.lastChild) {
|
|
291
|
+
var columnLen = node.parent.parent.columns.length;
|
|
292
|
+
var lastColIdx = node.lastChild.endIdx;
|
|
293
|
+
for (var i = lastColIdx + 1; i < columnLen; i += 1) {
|
|
294
|
+
if (!node.prev || !node.prev.rowspanMap[i] || node.prev.rowspanMap[i] <= 1) {
|
|
295
|
+
result.push({
|
|
296
|
+
type: 'openTag',
|
|
297
|
+
tagName: 'td',
|
|
298
|
+
outerNewLine: true,
|
|
299
|
+
}, {
|
|
300
|
+
type: 'closeTag',
|
|
301
|
+
tagName: 'td',
|
|
302
|
+
outerNewLine: true,
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
result.push({
|
|
308
|
+
type: 'closeTag',
|
|
309
|
+
tagName: 'tr',
|
|
310
|
+
outerNewLine: true,
|
|
311
|
+
});
|
|
312
|
+
return result;
|
|
313
|
+
},
|
|
314
|
+
// @ts-ignore
|
|
315
|
+
tableCell: function (node, _a) {
|
|
316
|
+
var entering = _a.entering, origin = _a.origin;
|
|
317
|
+
var result = origin();
|
|
318
|
+
if (node.ignored) {
|
|
319
|
+
return result;
|
|
320
|
+
}
|
|
321
|
+
if (entering) {
|
|
322
|
+
var attributes = __assign({}, node.attrs);
|
|
323
|
+
result.attributes = __assign(__assign({}, result.attributes), attributes);
|
|
324
|
+
}
|
|
325
|
+
return result;
|
|
326
|
+
},
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
;// CONCATENATED MODULE: ./src/wysiwyg/renderer.ts
|
|
330
|
+
var DELIM_LENGH = 3;
|
|
331
|
+
function repeat(text, count) {
|
|
332
|
+
var result = '';
|
|
333
|
+
for (var i = 0; i < count; i += 1) {
|
|
334
|
+
result += text;
|
|
335
|
+
}
|
|
336
|
+
return result;
|
|
337
|
+
}
|
|
338
|
+
function createTableHeadDelim(textContent, columnAlign) {
|
|
339
|
+
var textLen = textContent.length;
|
|
340
|
+
var leftDelim = '';
|
|
341
|
+
var rightDelim = '';
|
|
342
|
+
if (columnAlign === 'left') {
|
|
343
|
+
leftDelim = ':';
|
|
344
|
+
textLen -= 1;
|
|
345
|
+
}
|
|
346
|
+
else if (columnAlign === 'right') {
|
|
347
|
+
rightDelim = ':';
|
|
348
|
+
textLen -= 1;
|
|
349
|
+
}
|
|
350
|
+
else if (columnAlign === 'center') {
|
|
351
|
+
leftDelim = ':';
|
|
352
|
+
rightDelim = ':';
|
|
353
|
+
textLen -= 2;
|
|
354
|
+
}
|
|
355
|
+
return "" + leftDelim + repeat('-', Math.max(textLen, DELIM_LENGH)) + rightDelim;
|
|
356
|
+
}
|
|
357
|
+
function createDelim(node) {
|
|
358
|
+
var _a = node.attrs, rowspan = _a.rowspan, colspan = _a.colspan;
|
|
359
|
+
var spanInfo = '';
|
|
360
|
+
if (rowspan) {
|
|
361
|
+
spanInfo = "@rows=" + rowspan + ":";
|
|
362
|
+
}
|
|
363
|
+
if (colspan) {
|
|
364
|
+
spanInfo = "@cols=" + colspan + ":" + spanInfo;
|
|
365
|
+
}
|
|
366
|
+
return { delim: "| " + spanInfo };
|
|
367
|
+
}
|
|
368
|
+
var toMarkdownRenderers = {
|
|
369
|
+
tableHead: function (nodeInfo) {
|
|
370
|
+
var row = nodeInfo.node.firstChild;
|
|
371
|
+
var delim = '';
|
|
372
|
+
if (row) {
|
|
373
|
+
row.forEach(function (_a) {
|
|
374
|
+
var textContent = _a.textContent, attrs = _a.attrs;
|
|
375
|
+
var headDelim = createTableHeadDelim(textContent, attrs.align);
|
|
376
|
+
delim += "| " + headDelim + " ";
|
|
377
|
+
if (attrs.colspan) {
|
|
378
|
+
for (var i = 0; i < attrs.colspan - 1; i += 1) {
|
|
379
|
+
delim += "| " + headDelim + " ";
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
return { delim: delim };
|
|
385
|
+
},
|
|
386
|
+
tableHeadCell: function (nodeInfo) {
|
|
387
|
+
return createDelim(nodeInfo.node);
|
|
388
|
+
},
|
|
389
|
+
tableBodyCell: function (nodeInfo) {
|
|
390
|
+
return createDelim(nodeInfo.node);
|
|
391
|
+
},
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
;// CONCATENATED MODULE: ./src/i18n/langs.ts
|
|
395
|
+
function addLangs(i18n) {
|
|
396
|
+
i18n.setLanguage(['ko', 'ko-KR'], {
|
|
397
|
+
'Merge cells': '셀 병합',
|
|
398
|
+
'Split cells': '셀 병합해제',
|
|
399
|
+
'Cannot change part of merged cell': '병합된 셀의 일부를 변경할 수 없습니다.',
|
|
400
|
+
'Cannot paste row merged cells into the table header': '테이블 헤더에는 행 병합된 셀을 붙여넣을 수 없습니다.',
|
|
401
|
+
});
|
|
402
|
+
i18n.setLanguage(['en', 'en-US'], {
|
|
403
|
+
'Merge cells': 'Merge cells',
|
|
404
|
+
'Split cells': 'Split cells',
|
|
405
|
+
'Cannot change part of merged cell': 'Cannot change part of merged cell.',
|
|
406
|
+
'Cannot paste row merged cells into the table header': 'Cannot paste row merged cells into the table header.',
|
|
407
|
+
});
|
|
408
|
+
i18n.setLanguage(['es', 'es-ES'], {
|
|
409
|
+
'Merge cells': 'Combinar celdas',
|
|
410
|
+
'Split cells': 'Separar celdas',
|
|
411
|
+
'Cannot change part of merged cell': 'No se puede cambiar parte de una celda combinada.',
|
|
412
|
+
'Cannot paste row merged cells into the table header': 'No se pueden pegar celdas combinadas en el encabezado de tabla.',
|
|
413
|
+
});
|
|
414
|
+
i18n.setLanguage(['ja', 'ja-JP'], {
|
|
415
|
+
'Merge cells': 'セルの結合',
|
|
416
|
+
'Split cells': 'セルの結合を解除',
|
|
417
|
+
'Cannot change part of merged cell': '結合されたセルの一部を変更することはできません。',
|
|
418
|
+
'Cannot paste row merged cells into the table header': '行にマージされたセルをヘッダーに貼り付けることはできません。',
|
|
419
|
+
});
|
|
420
|
+
i18n.setLanguage(['nl', 'nl-NL'], {
|
|
421
|
+
'Merge cells': 'Cellen samenvoegen',
|
|
422
|
+
'Split cells': 'Samengevoegde cellen ongedaan maken',
|
|
423
|
+
'Cannot change part of merged cell': 'Kan geen deel uit van een samengevoegde cel veranderen.',
|
|
424
|
+
'Cannot paste row merged cells into the table header': 'Kan geen rij met samengevoegde cellen in de koptekst plakken.',
|
|
425
|
+
});
|
|
426
|
+
i18n.setLanguage('zh-CN', {
|
|
427
|
+
'Merge cells': '合并单元格',
|
|
428
|
+
'Split cells': '取消合并单元格',
|
|
429
|
+
'Cannot change part of merged cell': '无法更改合并单元格的一部分。',
|
|
430
|
+
'Cannot paste row merged cells into the table header': '无法将行合并单元格粘贴到标题中。',
|
|
431
|
+
});
|
|
432
|
+
i18n.setLanguage(['de', 'de-DE'], {
|
|
433
|
+
'Merge cells': 'Zellen zusammenführen',
|
|
434
|
+
'Split cells': 'Zusammenführen rückgängig machen',
|
|
435
|
+
'Cannot change part of merged cell': 'Der Teil der verbundenen Zelle kann nicht geändert werden.',
|
|
436
|
+
'Cannot paste row merged cells into the table header': 'Die Zeile der verbundenen Zellen kann nicht in die Kopfzeile eingefügt werden.',
|
|
437
|
+
});
|
|
438
|
+
i18n.setLanguage(['ru', 'ru-RU'], {
|
|
439
|
+
'Merge cells': 'Объединить ячейки',
|
|
440
|
+
'Split cells': 'Разъединить ячейки',
|
|
441
|
+
'Cannot change part of merged cell': 'Вы не можете изменять часть комбинированной ячейки.',
|
|
442
|
+
'Cannot paste row merged cells into the table header': 'Вы не можете вставлять объединенные ячейки в заголовок таблицы.',
|
|
443
|
+
});
|
|
444
|
+
i18n.setLanguage(['fr', 'fr-FR'], {
|
|
445
|
+
'Merge cells': 'Fusionner les cellules',
|
|
446
|
+
'Split cells': 'Séparer les cellules',
|
|
447
|
+
'Cannot change part of merged cell': 'Impossible de modifier une partie de la cellule fusionnée.',
|
|
448
|
+
'Cannot paste row merged cells into the table header': "Impossible de coller les cellules fusionnées dans l'en-tête du tableau.",
|
|
449
|
+
});
|
|
450
|
+
i18n.setLanguage(['uk', 'uk-UA'], {
|
|
451
|
+
'Merge cells': "Об'єднати комірки",
|
|
452
|
+
'Split cells': "Роз'єднати комірки",
|
|
453
|
+
'Cannot change part of merged cell': 'Ви не можете змінювати частину комбінованої комірки.',
|
|
454
|
+
'Cannot paste row merged cells into the table header': "Ви не можете вставляти об'єднані комірки в заголовок таблиці.",
|
|
455
|
+
});
|
|
456
|
+
i18n.setLanguage(['tr', 'tr-TR'], {
|
|
457
|
+
'Merge cells': 'Hücreleri birleştir',
|
|
458
|
+
'Split cells': 'Hücreleri ayır',
|
|
459
|
+
'Cannot change part of merged cell': 'Birleştirilmiş hücrelerin bir kısmı değiştirelemez.',
|
|
460
|
+
'Cannot paste row merged cells into the table header': 'Satırda birleştirilmiş hücreler sütun başlığına yapıştırılamaz',
|
|
461
|
+
});
|
|
462
|
+
i18n.setLanguage(['fi', 'fi-FI'], {
|
|
463
|
+
'Merge cells': 'Yhdistä solut',
|
|
464
|
+
'Split cells': 'Jaa solut',
|
|
465
|
+
'Cannot change part of merged cell': 'Yhdistettyjen solujen osaa ei voi muuttaa',
|
|
466
|
+
'Cannot paste row merged cells into the table header': 'Soluja ei voi yhdistää taulukon otsikkoriviin',
|
|
467
|
+
});
|
|
468
|
+
i18n.setLanguage(['cs', 'cs-CZ'], {
|
|
469
|
+
'Merge cells': 'Spojit buňky',
|
|
470
|
+
'Split cells': 'Rozpojit buňky',
|
|
471
|
+
'Cannot change part of merged cell': 'Nelze měnit část spojené buňky',
|
|
472
|
+
'Cannot paste row merged cells into the table header': 'Nelze vkládat spojené buňky do záhlaví tabulky',
|
|
473
|
+
});
|
|
474
|
+
i18n.setLanguage('ar', {
|
|
475
|
+
'Merge cells': 'دمج الوحدات',
|
|
476
|
+
'Split cells': 'إلغاء دمج الوحدات',
|
|
477
|
+
'Cannot change part of merged cell': 'لا يمكن تغيير جزء من الخلية المدموجة',
|
|
478
|
+
'Cannot paste row merged cells into the table header': 'لا يمكن لصق الخلايا المدموجة من صف واحد في رأس الجدول',
|
|
479
|
+
});
|
|
480
|
+
i18n.setLanguage(['pl', 'pl-PL'], {
|
|
481
|
+
'Merge cells': 'Scal komórki',
|
|
482
|
+
'Split cells': 'Rozłącz komórki',
|
|
483
|
+
'Cannot change part of merged cell': 'Nie można zmienić części scalonej komórki.',
|
|
484
|
+
'Cannot paste row merged cells into the table header': 'Nie można wkleić komórek o scalonym rzędzie w nagłówek tabeli.',
|
|
485
|
+
});
|
|
486
|
+
i18n.setLanguage('zh-TW', {
|
|
487
|
+
'Merge cells': '合併儲存格',
|
|
488
|
+
'Split cells': '取消合併儲存格',
|
|
489
|
+
'Cannot change part of merged cell': '無法變更儲存格的一部分。',
|
|
490
|
+
'Cannot paste row merged cells into the table header': '無法將合併的儲存格貼上至表格標題中。',
|
|
491
|
+
});
|
|
492
|
+
i18n.setLanguage(['gl', 'gl-ES'], {
|
|
493
|
+
'Merge cells': 'Combinar celas',
|
|
494
|
+
'Split cells': 'Separar celas',
|
|
495
|
+
'Cannot change part of merged cell': 'Non se pode cambiar parte dunha cela combinada',
|
|
496
|
+
'Cannot paste row merged cells into the table header': 'Non se poden pegar celas no encabezado da táboa',
|
|
497
|
+
});
|
|
498
|
+
i18n.setLanguage(['sv', 'sv-SE'], {
|
|
499
|
+
'Merge cells': 'Sammanfoga celler',
|
|
500
|
+
'Split cells': 'Dela celler',
|
|
501
|
+
'Cannot change part of merged cell': 'Ej möjligt att ändra en del av en sammanfogad cell',
|
|
502
|
+
'Cannot paste row merged cells into the table header': 'Ej möjligt att klistra in rad-sammanfogade celler i tabellens huvud',
|
|
503
|
+
});
|
|
504
|
+
i18n.setLanguage(['it', 'it-IT'], {
|
|
505
|
+
'Merge cells': 'Unisci celle',
|
|
506
|
+
'Split cells': 'Separa celle',
|
|
507
|
+
'Cannot change part of merged cell': 'Non è possibile modificare parte di una cella unita',
|
|
508
|
+
'Cannot paste row merged cells into the table header': "Non è possibile incollare celle unite per riga nell'intestazione della tabella",
|
|
509
|
+
});
|
|
510
|
+
i18n.setLanguage(['nb', 'nb-NO'], {
|
|
511
|
+
'Merge cells': 'Slå sammen celler',
|
|
512
|
+
'Split cells': 'Separer celler',
|
|
513
|
+
'Cannot change part of merged cell': 'Kan ikke endre deler av sammenslåtte celler',
|
|
514
|
+
'Cannot paste row merged cells into the table header': 'Kan ikke lime inn rad med sammenslåtte celler',
|
|
515
|
+
});
|
|
516
|
+
i18n.setLanguage(['hr', 'hr-HR'], {
|
|
517
|
+
'Merge cells': 'Spoji ćelije',
|
|
518
|
+
'Split cells': 'Odspoji ćelije',
|
|
519
|
+
'Cannot change part of merged cell': 'Ne mogu mijenjati dio spojene ćelije.',
|
|
520
|
+
'Cannot paste row merged cells into the table header': 'Ne mogu zaljepiti redak spojenih ćelija u zaglavlje tablice',
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
;// CONCATENATED MODULE: ./src/wysiwyg/tableOffsetMapMixin.ts
|
|
525
|
+
var tableOffsetMapMixin_assign = (undefined && undefined.__assign) || function () {
|
|
526
|
+
tableOffsetMapMixin_assign = Object.assign || function(t) {
|
|
527
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
528
|
+
s = arguments[i];
|
|
529
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
530
|
+
t[p] = s[p];
|
|
531
|
+
}
|
|
532
|
+
return t;
|
|
533
|
+
};
|
|
534
|
+
return tableOffsetMapMixin_assign.apply(this, arguments);
|
|
535
|
+
};
|
|
536
|
+
var offsetMapMixin = {
|
|
537
|
+
extendedRowspan: function (rowIdx, colIdx) {
|
|
538
|
+
var rowspanInfo = this.rowInfo[rowIdx].rowspanMap[colIdx];
|
|
539
|
+
return !!rowspanInfo && rowspanInfo.startSpanIdx !== rowIdx;
|
|
540
|
+
},
|
|
541
|
+
extendedColspan: function (rowIdx, colIdx) {
|
|
542
|
+
var colspanInfo = this.rowInfo[rowIdx].colspanMap[colIdx];
|
|
543
|
+
return !!colspanInfo && colspanInfo.startSpanIdx !== colIdx;
|
|
544
|
+
},
|
|
545
|
+
getRowspanCount: function (rowIdx, colIdx) {
|
|
546
|
+
var rowspanInfo = this.rowInfo[rowIdx].rowspanMap[colIdx];
|
|
547
|
+
return rowspanInfo ? rowspanInfo.count : 0;
|
|
548
|
+
},
|
|
549
|
+
getColspanCount: function (rowIdx, colIdx) {
|
|
550
|
+
var colspanInfo = this.rowInfo[rowIdx].colspanMap[colIdx];
|
|
551
|
+
return colspanInfo ? colspanInfo.count : 0;
|
|
552
|
+
},
|
|
553
|
+
decreaseColspanCount: function (rowIdx, colIdx) {
|
|
554
|
+
var colspanInfo = this.rowInfo[rowIdx].colspanMap[colIdx];
|
|
555
|
+
var startColspanInfo = this.rowInfo[rowIdx].colspanMap[colspanInfo.startSpanIdx];
|
|
556
|
+
startColspanInfo.count -= 1;
|
|
557
|
+
return startColspanInfo.count;
|
|
558
|
+
},
|
|
559
|
+
decreaseRowspanCount: function (rowIdx, colIdx) {
|
|
560
|
+
var rowspanInfo = this.rowInfo[rowIdx].rowspanMap[colIdx];
|
|
561
|
+
var startRowspanInfo = this.rowInfo[rowspanInfo.startSpanIdx].rowspanMap[colIdx];
|
|
562
|
+
startRowspanInfo.count -= 1;
|
|
563
|
+
return startRowspanInfo.count;
|
|
564
|
+
},
|
|
565
|
+
getColspanStartInfo: function (rowIdx, colIdx) {
|
|
566
|
+
var colspanMap = this.rowInfo[rowIdx].colspanMap;
|
|
567
|
+
var colspanInfo = colspanMap[colIdx];
|
|
568
|
+
if (colspanInfo) {
|
|
569
|
+
var startSpanIdx = colspanInfo.startSpanIdx;
|
|
570
|
+
var cellInfo = this.rowInfo[rowIdx][startSpanIdx];
|
|
571
|
+
return {
|
|
572
|
+
node: this.table.nodeAt(cellInfo.offset - this.tableStartOffset),
|
|
573
|
+
pos: cellInfo.offset,
|
|
574
|
+
startSpanIdx: startSpanIdx,
|
|
575
|
+
count: colspanMap[startSpanIdx].count,
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
return null;
|
|
579
|
+
},
|
|
580
|
+
getRowspanStartInfo: function (rowIdx, colIdx) {
|
|
581
|
+
var rowspanMap = this.rowInfo[rowIdx].rowspanMap;
|
|
582
|
+
var rowspanInfo = rowspanMap[colIdx];
|
|
583
|
+
if (rowspanInfo) {
|
|
584
|
+
var startSpanIdx = rowspanInfo.startSpanIdx;
|
|
585
|
+
var cellInfo = this.rowInfo[startSpanIdx][colIdx];
|
|
586
|
+
return {
|
|
587
|
+
node: this.table.nodeAt(cellInfo.offset - this.tableStartOffset),
|
|
588
|
+
pos: cellInfo.offset,
|
|
589
|
+
startSpanIdx: startSpanIdx,
|
|
590
|
+
count: this.rowInfo[startSpanIdx].rowspanMap[colIdx].count,
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
return null;
|
|
594
|
+
},
|
|
595
|
+
getSpannedOffsets: function (selectionInfo) {
|
|
596
|
+
var startRowIdx = selectionInfo.startRowIdx, startColIdx = selectionInfo.startColIdx, endRowIdx = selectionInfo.endRowIdx, endColIdx = selectionInfo.endColIdx;
|
|
597
|
+
for (var rowIdx = endRowIdx; rowIdx >= startRowIdx; rowIdx -= 1) {
|
|
598
|
+
if (this.rowInfo[rowIdx]) {
|
|
599
|
+
var _a = this.rowInfo[rowIdx], rowspanMap = _a.rowspanMap, colspanMap = _a.colspanMap;
|
|
600
|
+
for (var colIdx = endColIdx; colIdx >= startColIdx; colIdx -= 1) {
|
|
601
|
+
var rowspanInfo = rowspanMap[colIdx];
|
|
602
|
+
var colspanInfo = colspanMap[colIdx];
|
|
603
|
+
if (rowspanInfo) {
|
|
604
|
+
startRowIdx = Math.min(startRowIdx, rowspanInfo.startSpanIdx);
|
|
605
|
+
}
|
|
606
|
+
if (colspanInfo) {
|
|
607
|
+
startColIdx = Math.min(startColIdx, colspanInfo.startSpanIdx);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
for (var rowIdx = startRowIdx; rowIdx <= endRowIdx; rowIdx += 1) {
|
|
613
|
+
if (this.rowInfo[rowIdx]) {
|
|
614
|
+
var _b = this.rowInfo[rowIdx], rowspanMap = _b.rowspanMap, colspanMap = _b.colspanMap;
|
|
615
|
+
for (var colIdx = startColIdx; colIdx <= endColIdx; colIdx += 1) {
|
|
616
|
+
var rowspanInfo = rowspanMap[colIdx];
|
|
617
|
+
var colspanInfo = colspanMap[colIdx];
|
|
618
|
+
if (rowspanInfo) {
|
|
619
|
+
endRowIdx = Math.max(endRowIdx, rowIdx + rowspanInfo.count - 1);
|
|
620
|
+
}
|
|
621
|
+
if (colspanInfo) {
|
|
622
|
+
endColIdx = Math.max(endColIdx, colIdx + colspanInfo.count - 1);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
return { startRowIdx: startRowIdx, startColIdx: startColIdx, endRowIdx: endRowIdx, endColIdx: endColIdx };
|
|
628
|
+
},
|
|
629
|
+
};
|
|
630
|
+
function extendPrevRowspan(prevRowInfo, rowInfo) {
|
|
631
|
+
var rowspanMap = rowInfo.rowspanMap, colspanMap = rowInfo.colspanMap;
|
|
632
|
+
var prevRowspanMap = prevRowInfo.rowspanMap, prevColspanMap = prevRowInfo.colspanMap;
|
|
633
|
+
Object.keys(prevRowspanMap).forEach(function (key) {
|
|
634
|
+
var colIdx = Number(key);
|
|
635
|
+
var prevRowspanInfo = prevRowspanMap[colIdx];
|
|
636
|
+
if ((prevRowspanInfo === null || prevRowspanInfo === void 0 ? void 0 : prevRowspanInfo.count) > 1) {
|
|
637
|
+
var prevColspanInfo = prevColspanMap[colIdx];
|
|
638
|
+
var count = prevRowspanInfo.count, startSpanIdx = prevRowspanInfo.startSpanIdx;
|
|
639
|
+
rowspanMap[colIdx] = { count: count - 1, startSpanIdx: startSpanIdx };
|
|
640
|
+
colspanMap[colIdx] = prevColspanInfo;
|
|
641
|
+
rowInfo[colIdx] = tableOffsetMapMixin_assign(tableOffsetMapMixin_assign({}, prevRowInfo[colIdx]), { extended: true });
|
|
642
|
+
rowInfo.length += 1;
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
function extendPrevColspan(rowspan, colspan, rowIdx, colIdx, rowInfo) {
|
|
647
|
+
var rowspanMap = rowInfo.rowspanMap, colspanMap = rowInfo.colspanMap;
|
|
648
|
+
for (var i = 1; i < colspan; i += 1) {
|
|
649
|
+
colspanMap[colIdx + i] = { count: colspan - i, startSpanIdx: colIdx };
|
|
650
|
+
if (rowspan > 1) {
|
|
651
|
+
rowspanMap[colIdx + i] = { count: rowspan, startSpanIdx: rowIdx };
|
|
652
|
+
}
|
|
653
|
+
rowInfo[colIdx + i] = tableOffsetMapMixin_assign({}, rowInfo[colIdx]);
|
|
654
|
+
rowInfo.length += 1;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
var createOffsetMapMixin = function (headOrBody, startOffset, startFromBody) {
|
|
658
|
+
if (startFromBody === void 0) { startFromBody = false; }
|
|
659
|
+
var cellInfoMatrix = [];
|
|
660
|
+
var beInBody = headOrBody.type.name === 'tableBody';
|
|
661
|
+
headOrBody.forEach(function (row, rowOffset, rowIdx) {
|
|
662
|
+
// get row index based on table(not table head or table body)
|
|
663
|
+
var rowIdxInWholeTable = beInBody && !startFromBody ? rowIdx + 1 : rowIdx;
|
|
664
|
+
var prevRowInfo = cellInfoMatrix[rowIdx - 1];
|
|
665
|
+
var rowInfo = { rowspanMap: {}, colspanMap: {}, length: 0 };
|
|
666
|
+
if (prevRowInfo) {
|
|
667
|
+
extendPrevRowspan(prevRowInfo, rowInfo);
|
|
668
|
+
}
|
|
669
|
+
row.forEach(function (_a, cellOffset) {
|
|
670
|
+
var _b, _c;
|
|
671
|
+
var nodeSize = _a.nodeSize, attrs = _a.attrs;
|
|
672
|
+
var colspan = (_b = attrs.colspan) !== null && _b !== void 0 ? _b : 1;
|
|
673
|
+
var rowspan = (_c = attrs.rowspan) !== null && _c !== void 0 ? _c : 1;
|
|
674
|
+
var colIdx = 0;
|
|
675
|
+
while (rowInfo[colIdx]) {
|
|
676
|
+
colIdx += 1;
|
|
677
|
+
}
|
|
678
|
+
rowInfo[colIdx] = {
|
|
679
|
+
// 2 is the sum of the front and back positions of the tag
|
|
680
|
+
offset: startOffset + rowOffset + cellOffset + 2,
|
|
681
|
+
nodeSize: nodeSize,
|
|
682
|
+
};
|
|
683
|
+
rowInfo.length += 1;
|
|
684
|
+
if (rowspan > 1) {
|
|
685
|
+
rowInfo.rowspanMap[colIdx] = { count: rowspan, startSpanIdx: rowIdxInWholeTable };
|
|
686
|
+
}
|
|
687
|
+
if (colspan > 1) {
|
|
688
|
+
rowInfo.colspanMap[colIdx] = { count: colspan, startSpanIdx: colIdx };
|
|
689
|
+
extendPrevColspan(rowspan, colspan, rowIdxInWholeTable, colIdx, rowInfo);
|
|
690
|
+
}
|
|
691
|
+
});
|
|
692
|
+
cellInfoMatrix.push(rowInfo);
|
|
693
|
+
});
|
|
694
|
+
return cellInfoMatrix;
|
|
695
|
+
};
|
|
696
|
+
|
|
697
|
+
// EXTERNAL MODULE: ../../node_modules/tui-code-snippet/collection/toArray.js
|
|
698
|
+
var toArray = __webpack_require__(990);
|
|
699
|
+
var toArray_default = /*#__PURE__*/__webpack_require__.n(toArray);
|
|
700
|
+
;// CONCATENATED MODULE: ./src/wysiwyg/contextMenu.ts
|
|
701
|
+
|
|
702
|
+
var TABLE_CELL_SELECT_CLASS = '.toastui-editor-cell-selected';
|
|
703
|
+
function hasSpanAttr(tableCell) {
|
|
704
|
+
return (Number(tableCell.getAttribute('colspan')) > 1 || Number(tableCell.getAttribute('rowspan')) > 1);
|
|
705
|
+
}
|
|
706
|
+
function hasSpanningCell(headOrBody) {
|
|
707
|
+
return toArray_default()(headOrBody.querySelectorAll(TABLE_CELL_SELECT_CLASS)).some(hasSpanAttr);
|
|
708
|
+
}
|
|
709
|
+
function isCellSelected(headOrBody) {
|
|
710
|
+
return !!headOrBody.querySelectorAll(TABLE_CELL_SELECT_CLASS).length;
|
|
711
|
+
}
|
|
712
|
+
function createMergedTableContextMenu(context, tableCell) {
|
|
713
|
+
var i18n = context.i18n, eventEmitter = context.eventEmitter;
|
|
714
|
+
var headOrBody = tableCell.parentElement.parentElement;
|
|
715
|
+
var mergedTableContextMenu = [];
|
|
716
|
+
if (isCellSelected(headOrBody)) {
|
|
717
|
+
mergedTableContextMenu.push({
|
|
718
|
+
label: i18n.get('Merge cells'),
|
|
719
|
+
onClick: function () { return eventEmitter.emit('command', 'mergeCells'); },
|
|
720
|
+
className: 'merge-cells',
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
if (hasSpanAttr(tableCell) || hasSpanningCell(headOrBody)) {
|
|
724
|
+
mergedTableContextMenu.push({
|
|
725
|
+
label: i18n.get('Split cells'),
|
|
726
|
+
onClick: function () { return eventEmitter.emit('command', 'splitCells'); },
|
|
727
|
+
className: 'split-cells',
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
return mergedTableContextMenu;
|
|
731
|
+
}
|
|
732
|
+
function addMergedTableContextMenu(context) {
|
|
733
|
+
context.eventEmitter.listen('contextmenu', function () {
|
|
734
|
+
var args = [];
|
|
735
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
736
|
+
args[_i] = arguments[_i];
|
|
737
|
+
}
|
|
738
|
+
var _a = args[0], menuGroups = _a.menuGroups, tableCell = _a.tableCell;
|
|
739
|
+
var mergedTableContextMenu = createMergedTableContextMenu(context, tableCell);
|
|
740
|
+
if (mergedTableContextMenu.length) {
|
|
741
|
+
// add merged table context menu on third group
|
|
742
|
+
menuGroups.splice(2, 0, mergedTableContextMenu);
|
|
743
|
+
}
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
;// CONCATENATED MODULE: ./src/wysiwyg/util.ts
|
|
748
|
+
var util_assign = (undefined && undefined.__assign) || function () {
|
|
749
|
+
util_assign = Object.assign || function(t) {
|
|
750
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
751
|
+
s = arguments[i];
|
|
752
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
753
|
+
t[p] = s[p];
|
|
754
|
+
}
|
|
755
|
+
return t;
|
|
756
|
+
};
|
|
757
|
+
return util_assign.apply(this, arguments);
|
|
758
|
+
};
|
|
759
|
+
function findNodeBy(pos, condition) {
|
|
760
|
+
var depth = pos.depth;
|
|
761
|
+
while (depth >= 0) {
|
|
762
|
+
var node = pos.node(depth);
|
|
763
|
+
if (condition(node, depth)) {
|
|
764
|
+
return {
|
|
765
|
+
node: node,
|
|
766
|
+
depth: depth,
|
|
767
|
+
offset: depth > 0 ? pos.before(depth) : 0,
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
depth -= 1;
|
|
771
|
+
}
|
|
772
|
+
return null;
|
|
773
|
+
}
|
|
774
|
+
function findCell(pos) {
|
|
775
|
+
return findNodeBy(pos, function (_a) {
|
|
776
|
+
var type = _a.type;
|
|
777
|
+
return type.name === 'tableHeadCell' || type.name === 'tableBodyCell';
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
function getResolvedSelection(selection, context) {
|
|
781
|
+
if (selection instanceof context.pmState.TextSelection) {
|
|
782
|
+
var $anchor = selection.$anchor;
|
|
783
|
+
var foundCell = findCell($anchor);
|
|
784
|
+
if (foundCell) {
|
|
785
|
+
var anchor = $anchor.node(0).resolve($anchor.before(foundCell.depth));
|
|
786
|
+
return { anchor: anchor, head: anchor };
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
var _a = selection, startCell = _a.startCell, endCell = _a.endCell;
|
|
790
|
+
return { anchor: startCell, head: endCell };
|
|
791
|
+
}
|
|
792
|
+
function getRowAndColumnCount(_a) {
|
|
793
|
+
var startRowIdx = _a.startRowIdx, startColIdx = _a.startColIdx, endRowIdx = _a.endRowIdx, endColIdx = _a.endColIdx;
|
|
794
|
+
return { rowCount: endRowIdx - startRowIdx + 1, columnCount: endColIdx - startColIdx + 1 };
|
|
795
|
+
}
|
|
796
|
+
function setAttrs(cell, attrs) {
|
|
797
|
+
return util_assign(util_assign({}, cell.attrs), attrs);
|
|
798
|
+
}
|
|
799
|
+
function getCellSelectionClass(selection) {
|
|
800
|
+
var proto = Object.getPrototypeOf(selection);
|
|
801
|
+
return proto.constructor;
|
|
802
|
+
}
|
|
803
|
+
function createDummyCells(columnCount, rowIdx, schema, attrs) {
|
|
804
|
+
if (attrs === void 0) { attrs = null; }
|
|
805
|
+
var _a = schema.nodes, tableHeadCell = _a.tableHeadCell, tableBodyCell = _a.tableBodyCell, paragraph = _a.paragraph;
|
|
806
|
+
var cell = rowIdx === 0 ? tableHeadCell : tableBodyCell;
|
|
807
|
+
var cells = [];
|
|
808
|
+
for (var index = 0; index < columnCount; index += 1) {
|
|
809
|
+
cells.push(cell.create(attrs, paragraph.create()));
|
|
810
|
+
}
|
|
811
|
+
return cells;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
;// CONCATENATED MODULE: ./src/wysiwyg/command/mergeCells.ts
|
|
815
|
+
|
|
816
|
+
function createMergeCellsCommand(context, OffsetMap) {
|
|
817
|
+
var FragmentClass = context.pmModel.Fragment;
|
|
818
|
+
var mergeCells = function (_, state, dispatch) {
|
|
819
|
+
var selection = state.selection, tr = state.tr;
|
|
820
|
+
var _a = getResolvedSelection(selection, context), anchor = _a.anchor, head = _a.head;
|
|
821
|
+
// @ts-ignore
|
|
822
|
+
// judge cell selection
|
|
823
|
+
if (!anchor || !head || !selection.isCellSelection) {
|
|
824
|
+
return false;
|
|
825
|
+
}
|
|
826
|
+
var map = OffsetMap.create(anchor);
|
|
827
|
+
var CellSelection = getCellSelectionClass(selection);
|
|
828
|
+
var totalRowCount = map.totalRowCount, totalColumnCount = map.totalColumnCount;
|
|
829
|
+
var selectionInfo = map.getRectOffsets(anchor, head);
|
|
830
|
+
var _b = getRowAndColumnCount(selectionInfo), rowCount = _b.rowCount, columnCount = _b.columnCount;
|
|
831
|
+
var startRowIdx = selectionInfo.startRowIdx, startColIdx = selectionInfo.startColIdx, endRowIdx = selectionInfo.endRowIdx, endColIdx = selectionInfo.endColIdx;
|
|
832
|
+
var allSelected = rowCount >= totalRowCount - 1 && columnCount === totalColumnCount;
|
|
833
|
+
var hasTableHead = startRowIdx === 0 && endRowIdx > startRowIdx;
|
|
834
|
+
if (allSelected || hasTableHead) {
|
|
835
|
+
return false;
|
|
836
|
+
}
|
|
837
|
+
var fragment = FragmentClass.empty;
|
|
838
|
+
for (var rowIdx = startRowIdx; rowIdx <= endRowIdx; rowIdx += 1) {
|
|
839
|
+
for (var colIdx = startColIdx; colIdx <= endColIdx; colIdx += 1) {
|
|
840
|
+
// set first cell content
|
|
841
|
+
if (rowIdx === startRowIdx && colIdx === startColIdx) {
|
|
842
|
+
fragment = appendFragment(rowIdx, colIdx, fragment, map);
|
|
843
|
+
// set each cell content and delete the cell for spanning
|
|
844
|
+
}
|
|
845
|
+
else if (!map.extendedRowspan(rowIdx, colIdx) && !map.extendedColspan(rowIdx, colIdx)) {
|
|
846
|
+
var _c = map.getCellInfo(rowIdx, colIdx), offset = _c.offset, nodeSize = _c.nodeSize;
|
|
847
|
+
var from = tr.mapping.map(offset);
|
|
848
|
+
var to = from + nodeSize;
|
|
849
|
+
fragment = appendFragment(rowIdx, colIdx, fragment, map);
|
|
850
|
+
tr.delete(from, to);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
var _d = map.getNodeAndPos(startRowIdx, startColIdx), node = _d.node, pos = _d.pos;
|
|
855
|
+
// set rowspan, colspan to first root cell
|
|
856
|
+
setSpanToRootCell(tr, fragment, {
|
|
857
|
+
startNode: node,
|
|
858
|
+
startPos: pos,
|
|
859
|
+
rowCount: rowCount,
|
|
860
|
+
columnCount: columnCount,
|
|
861
|
+
});
|
|
862
|
+
tr.setSelection(new CellSelection(tr.doc.resolve(pos)));
|
|
863
|
+
dispatch(tr);
|
|
864
|
+
return true;
|
|
865
|
+
};
|
|
866
|
+
return mergeCells;
|
|
867
|
+
}
|
|
868
|
+
function setSpanToRootCell(tr, fragment, rangeInfo) {
|
|
869
|
+
var startNode = rangeInfo.startNode, startPos = rangeInfo.startPos, rowCount = rangeInfo.rowCount, columnCount = rangeInfo.columnCount;
|
|
870
|
+
tr.setNodeMarkup(startPos, null, setAttrs(startNode, { colspan: columnCount, rowspan: rowCount }));
|
|
871
|
+
if (fragment.size) {
|
|
872
|
+
// add 1 for text start offset(not node start offset)
|
|
873
|
+
tr.replaceWith(startPos + 1, startPos + startNode.content.size, fragment);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
function appendFragment(rowIdx, colIdx, fragment, map) {
|
|
877
|
+
var targetFragment = map.getNodeAndPos(rowIdx, colIdx).node.content;
|
|
878
|
+
// prevent to add empty string
|
|
879
|
+
return targetFragment.size > 2 ? fragment.append(targetFragment) : fragment;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
;// CONCATENATED MODULE: ./src/wysiwyg/command/splitCells.ts
|
|
883
|
+
|
|
884
|
+
function getColspanEndIdx(rowIdx, colIdx, map) {
|
|
885
|
+
var endColIdx = colIdx;
|
|
886
|
+
if (!map.extendedRowspan(rowIdx, colIdx) && map.extendedColspan(rowIdx, colIdx)) {
|
|
887
|
+
var _a = map.getColspanStartInfo(rowIdx, colIdx), startSpanIdx = _a.startSpanIdx, count = _a.count;
|
|
888
|
+
endColIdx = startSpanIdx + count;
|
|
889
|
+
}
|
|
890
|
+
return endColIdx;
|
|
891
|
+
}
|
|
892
|
+
function judgeInsertToNextRow(map, mappedPos, rowIdx, colIdx) {
|
|
893
|
+
var totalColumnCount = map.totalColumnCount;
|
|
894
|
+
return (map.extendedRowspan(rowIdx, colIdx) &&
|
|
895
|
+
map.extendedRowspan(rowIdx, totalColumnCount - 1) &&
|
|
896
|
+
mappedPos === map.posAt(rowIdx, totalColumnCount - 1));
|
|
897
|
+
}
|
|
898
|
+
function createSplitCellsCommand(context, OffsetMap) {
|
|
899
|
+
var splitCells = function (_, state, dispatch, view) {
|
|
900
|
+
var selection = state.selection, tr = state.tr;
|
|
901
|
+
var _a = getResolvedSelection(selection, context), anchor = _a.anchor, head = _a.head;
|
|
902
|
+
if (!anchor || !head) {
|
|
903
|
+
return false;
|
|
904
|
+
}
|
|
905
|
+
var map = OffsetMap.create(anchor);
|
|
906
|
+
var selectionInfo = map.getRectOffsets(anchor, head);
|
|
907
|
+
var startRowIdx = selectionInfo.startRowIdx, startColIdx = selectionInfo.startColIdx, endRowIdx = selectionInfo.endRowIdx, endColIdx = selectionInfo.endColIdx;
|
|
908
|
+
var lastCellPos = -1;
|
|
909
|
+
for (var rowIdx = startRowIdx; rowIdx <= endRowIdx; rowIdx += 1) {
|
|
910
|
+
for (var colIdx = startColIdx; colIdx <= endColIdx; colIdx += 1) {
|
|
911
|
+
if (map.extendedRowspan(rowIdx, colIdx) || map.extendedColspan(rowIdx, colIdx)) {
|
|
912
|
+
// insert empty cell in spanning cell position
|
|
913
|
+
var node = map.getNodeAndPos(rowIdx, colIdx).node;
|
|
914
|
+
var colspanEndIdx = getColspanEndIdx(rowIdx, colIdx, map);
|
|
915
|
+
var mappedPos = map.posAt(rowIdx, colspanEndIdx);
|
|
916
|
+
var pos = tr.mapping.map(mappedPos);
|
|
917
|
+
// add 2(tr end, open tag length) to insert the cell on the next row
|
|
918
|
+
// in case that all next cells are spanning on the current row
|
|
919
|
+
if (judgeInsertToNextRow(map, mappedPos, rowIdx, colspanEndIdx)) {
|
|
920
|
+
pos += 2;
|
|
921
|
+
}
|
|
922
|
+
// get the last cell position for cell selection after splitting cells
|
|
923
|
+
lastCellPos = Math.max(pos, lastCellPos);
|
|
924
|
+
tr.insert(pos, node.type.createAndFill(setAttrs(node, { colspan: null, rowspan: null })));
|
|
925
|
+
}
|
|
926
|
+
else {
|
|
927
|
+
// remove colspan, rowspan of the root spanning cell
|
|
928
|
+
var _b = map.getNodeAndPos(rowIdx, colIdx), node = _b.node, pos = _b.pos;
|
|
929
|
+
// get the last cell position for cell selection after splitting cells
|
|
930
|
+
lastCellPos = Math.max(tr.mapping.map(pos), lastCellPos);
|
|
931
|
+
tr.setNodeMarkup(tr.mapping.map(pos), null, setAttrs(node, { colspan: null, rowspan: null }));
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
dispatch(tr);
|
|
936
|
+
setCellSelection(view, selection, OffsetMap, map.tableStartOffset, selectionInfo);
|
|
937
|
+
return true;
|
|
938
|
+
};
|
|
939
|
+
return splitCells;
|
|
940
|
+
}
|
|
941
|
+
function setCellSelection(view, selection, OffsetMap, tableStartPos, selectionInfo) {
|
|
942
|
+
// @ts-ignore
|
|
943
|
+
// judge cell selection
|
|
944
|
+
if (selection.isCellSelection) {
|
|
945
|
+
var tr = view.state.tr;
|
|
946
|
+
var CellSelection = getCellSelectionClass(selection);
|
|
947
|
+
var startRowIdx = selectionInfo.startRowIdx, startColIdx = selectionInfo.startColIdx, endRowIdx = selectionInfo.endRowIdx, endColIdx = selectionInfo.endColIdx;
|
|
948
|
+
// get changed cell offsets
|
|
949
|
+
var map = OffsetMap.create(tr.doc.resolve(tableStartPos));
|
|
950
|
+
var startOffset = map.getCellInfo(startRowIdx, startColIdx).offset;
|
|
951
|
+
var endOffset = map.getCellInfo(endRowIdx, endColIdx).offset;
|
|
952
|
+
tr.setSelection(new CellSelection(tr.doc.resolve(startOffset), tr.doc.resolve(endOffset)));
|
|
953
|
+
view.dispatch(tr);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
;// CONCATENATED MODULE: ./src/wysiwyg/command/removeColumn.ts
|
|
958
|
+
|
|
959
|
+
function createRemoveColumnCommand(context, OffsetMap) {
|
|
960
|
+
var removeColumn = function (_, state, dispatch) {
|
|
961
|
+
var selection = state.selection, tr = state.tr;
|
|
962
|
+
var _a = getResolvedSelection(selection, context), anchor = _a.anchor, head = _a.head;
|
|
963
|
+
if (!anchor || !head) {
|
|
964
|
+
return false;
|
|
965
|
+
}
|
|
966
|
+
var map = OffsetMap.create(anchor);
|
|
967
|
+
var selectionInfo = map.getRectOffsets(anchor, head);
|
|
968
|
+
var totalColumnCount = map.totalColumnCount, totalRowCount = map.totalRowCount;
|
|
969
|
+
var columnCount = getRowAndColumnCount(selectionInfo).columnCount;
|
|
970
|
+
var selectedAllColumn = columnCount === totalColumnCount;
|
|
971
|
+
if (selectedAllColumn) {
|
|
972
|
+
return false;
|
|
973
|
+
}
|
|
974
|
+
var startColIdx = selectionInfo.startColIdx, endColIdx = selectionInfo.endColIdx;
|
|
975
|
+
var mapStart = tr.mapping.maps.length;
|
|
976
|
+
for (var rowIdx = 0; rowIdx < totalRowCount; rowIdx += 1) {
|
|
977
|
+
for (var colIdx = endColIdx; colIdx >= startColIdx; colIdx -= 1) {
|
|
978
|
+
var _b = map.getCellInfo(rowIdx, colIdx), offset = _b.offset, nodeSize = _b.nodeSize;
|
|
979
|
+
var colspanInfo = map.getColspanStartInfo(rowIdx, colIdx);
|
|
980
|
+
if (!map.extendedRowspan(rowIdx, colIdx)) {
|
|
981
|
+
// decrease colspan count inside the col-spanning cell
|
|
982
|
+
if ((colspanInfo === null || colspanInfo === void 0 ? void 0 : colspanInfo.count) > 1) {
|
|
983
|
+
var _c = map.getColspanStartInfo(rowIdx, colIdx), node = _c.node, pos = _c.pos;
|
|
984
|
+
var colspan = map.decreaseColspanCount(rowIdx, colIdx);
|
|
985
|
+
var attrs = setAttrs(node, { colspan: colspan > 1 ? colspan : null });
|
|
986
|
+
tr.setNodeMarkup(tr.mapping.slice(mapStart).map(pos), null, attrs);
|
|
987
|
+
}
|
|
988
|
+
else {
|
|
989
|
+
var from = tr.mapping.slice(mapStart).map(offset);
|
|
990
|
+
var to = from + nodeSize;
|
|
991
|
+
tr.delete(from, to);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
dispatch(tr);
|
|
997
|
+
return true;
|
|
998
|
+
};
|
|
999
|
+
return removeColumn;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
;// CONCATENATED MODULE: ./src/wysiwyg/command/removeRow.ts
|
|
1003
|
+
|
|
1004
|
+
function getRowRanges(map, rowIdx) {
|
|
1005
|
+
var totalColumnCount = map.totalColumnCount;
|
|
1006
|
+
var from = Number.MAX_VALUE;
|
|
1007
|
+
var to = 0;
|
|
1008
|
+
for (var colIdx = 0; colIdx < totalColumnCount; colIdx += 1) {
|
|
1009
|
+
if (!map.extendedRowspan(rowIdx, colIdx)) {
|
|
1010
|
+
var _a = map.getCellInfo(rowIdx, colIdx), offset = _a.offset, nodeSize = _a.nodeSize;
|
|
1011
|
+
from = Math.min(from, offset);
|
|
1012
|
+
to = Math.max(to, offset + nodeSize);
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
return { from: from, to: to };
|
|
1016
|
+
}
|
|
1017
|
+
function createRemoveRowCommand(context, OffsetMap) {
|
|
1018
|
+
var removeRow = function (_, state, dispatch) {
|
|
1019
|
+
var selection = state.selection, tr = state.tr;
|
|
1020
|
+
var _a = getResolvedSelection(selection, context), anchor = _a.anchor, head = _a.head;
|
|
1021
|
+
if (anchor && head) {
|
|
1022
|
+
var map = OffsetMap.create(anchor);
|
|
1023
|
+
var totalRowCount = map.totalRowCount, totalColumnCount = map.totalColumnCount;
|
|
1024
|
+
var selectionInfo = map.getRectOffsets(anchor, head);
|
|
1025
|
+
var rowCount = getRowAndColumnCount(selectionInfo).rowCount;
|
|
1026
|
+
var startRowIdx = selectionInfo.startRowIdx, endRowIdx = selectionInfo.endRowIdx;
|
|
1027
|
+
var selectedThead = startRowIdx === 0;
|
|
1028
|
+
var selectedAllTbodyRow = rowCount === totalRowCount - 1;
|
|
1029
|
+
if (selectedAllTbodyRow || selectedThead) {
|
|
1030
|
+
return false;
|
|
1031
|
+
}
|
|
1032
|
+
for (var rowIdx = endRowIdx; rowIdx >= startRowIdx; rowIdx -= 1) {
|
|
1033
|
+
var mapStart = tr.mapping.maps.length;
|
|
1034
|
+
var _b = getRowRanges(map, rowIdx), from = _b.from, to = _b.to;
|
|
1035
|
+
// delete table row
|
|
1036
|
+
tr.delete(from - 1, to + 1);
|
|
1037
|
+
for (var colIdx = 0; colIdx < totalColumnCount; colIdx += 1) {
|
|
1038
|
+
var rowspanInfo = map.getRowspanStartInfo(rowIdx, colIdx);
|
|
1039
|
+
if ((rowspanInfo === null || rowspanInfo === void 0 ? void 0 : rowspanInfo.count) > 1 && !map.extendedColspan(rowIdx, colIdx)) {
|
|
1040
|
+
// decrease rowspan count inside the row-spanning cell
|
|
1041
|
+
// eslint-disable-next-line max-depth
|
|
1042
|
+
if (map.extendedRowspan(rowIdx, colIdx)) {
|
|
1043
|
+
var _c = map.getRowspanStartInfo(rowIdx, colIdx), node = _c.node, pos = _c.pos;
|
|
1044
|
+
var rowspan = map.decreaseRowspanCount(rowIdx, colIdx);
|
|
1045
|
+
var attrs = setAttrs(node, { rowspan: rowspan > 1 ? rowspan : null });
|
|
1046
|
+
tr.setNodeMarkup(tr.mapping.slice(mapStart).map(pos), null, attrs);
|
|
1047
|
+
// the row-spanning cell should be moved down
|
|
1048
|
+
}
|
|
1049
|
+
else if (!map.extendedRowspan(rowIdx, colIdx)) {
|
|
1050
|
+
var _d = map.getRowspanStartInfo(rowIdx, colIdx), node = _d.node, count = _d.count;
|
|
1051
|
+
var attrs = setAttrs(node, { rowspan: count > 2 ? count - 1 : null });
|
|
1052
|
+
var copiedCell = node.type.create(attrs, node.content);
|
|
1053
|
+
tr.insert(tr.mapping.slice(mapStart).map(map.posAt(rowIdx + 1, colIdx)), copiedCell);
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
map = OffsetMap.create(tr.doc.resolve(map.tableStartOffset));
|
|
1058
|
+
}
|
|
1059
|
+
dispatch(tr);
|
|
1060
|
+
return true;
|
|
1061
|
+
}
|
|
1062
|
+
return false;
|
|
1063
|
+
};
|
|
1064
|
+
return removeRow;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
;// CONCATENATED MODULE: ./src/wysiwyg/command/direction.ts
|
|
1068
|
+
// eslint-disable-next-line no-shadow
|
|
1069
|
+
var Direction;
|
|
1070
|
+
(function (Direction) {
|
|
1071
|
+
Direction["LEFT"] = "left";
|
|
1072
|
+
Direction["RIGHT"] = "right";
|
|
1073
|
+
Direction["UP"] = "up";
|
|
1074
|
+
Direction["DOWN"] = "down";
|
|
1075
|
+
})(Direction || (Direction = {}));
|
|
1076
|
+
|
|
1077
|
+
;// CONCATENATED MODULE: ./src/wysiwyg/command/addRow.ts
|
|
1078
|
+
|
|
1079
|
+
|
|
1080
|
+
function getTargetRowInfo(direction, map, selectionInfo) {
|
|
1081
|
+
var targetRowIdx;
|
|
1082
|
+
var judgeToExtendRowspan;
|
|
1083
|
+
var insertColIdx;
|
|
1084
|
+
var nodeSize;
|
|
1085
|
+
if (direction === Direction.UP) {
|
|
1086
|
+
targetRowIdx = selectionInfo.startRowIdx;
|
|
1087
|
+
judgeToExtendRowspan = function (colIdx) { return map.extendedRowspan(targetRowIdx, colIdx); };
|
|
1088
|
+
insertColIdx = 0;
|
|
1089
|
+
nodeSize = -1;
|
|
1090
|
+
}
|
|
1091
|
+
else {
|
|
1092
|
+
targetRowIdx = selectionInfo.endRowIdx;
|
|
1093
|
+
judgeToExtendRowspan = function (colIdx) { return map.getRowspanCount(targetRowIdx, colIdx) > 1; };
|
|
1094
|
+
insertColIdx = map.totalColumnCount - 1;
|
|
1095
|
+
nodeSize = !map.extendedRowspan(targetRowIdx, insertColIdx)
|
|
1096
|
+
? map.getCellInfo(targetRowIdx, insertColIdx).nodeSize + 1
|
|
1097
|
+
: 2;
|
|
1098
|
+
}
|
|
1099
|
+
return { targetRowIdx: targetRowIdx, judgeToExtendRowspan: judgeToExtendRowspan, insertColIdx: insertColIdx, nodeSize: nodeSize };
|
|
1100
|
+
}
|
|
1101
|
+
function createAddRowCommand(context, OffsetMap, direction) {
|
|
1102
|
+
var addRow = function (_, state, dispatch) {
|
|
1103
|
+
var selection = state.selection, schema = state.schema, tr = state.tr;
|
|
1104
|
+
var _a = getResolvedSelection(selection, context), anchor = _a.anchor, head = _a.head;
|
|
1105
|
+
if (!anchor || !head) {
|
|
1106
|
+
return false;
|
|
1107
|
+
}
|
|
1108
|
+
var map = OffsetMap.create(anchor);
|
|
1109
|
+
var totalColumnCount = map.totalColumnCount;
|
|
1110
|
+
var selectionInfo = map.getRectOffsets(anchor, head);
|
|
1111
|
+
var rowCount = getRowAndColumnCount(selectionInfo).rowCount;
|
|
1112
|
+
var _b = getTargetRowInfo(direction, map, selectionInfo), targetRowIdx = _b.targetRowIdx, judgeToExtendRowspan = _b.judgeToExtendRowspan, insertColIdx = _b.insertColIdx, nodeSize = _b.nodeSize;
|
|
1113
|
+
var selectedThead = targetRowIdx === 0;
|
|
1114
|
+
if (selectedThead) {
|
|
1115
|
+
return false;
|
|
1116
|
+
}
|
|
1117
|
+
var rows = [];
|
|
1118
|
+
var from = tr.mapping.map(map.posAt(targetRowIdx, insertColIdx)) + nodeSize;
|
|
1119
|
+
var cells = [];
|
|
1120
|
+
for (var colIdx = 0; colIdx < totalColumnCount; colIdx += 1) {
|
|
1121
|
+
// increase rowspan count inside the row-spanning cell
|
|
1122
|
+
if (judgeToExtendRowspan(colIdx)) {
|
|
1123
|
+
var _c = map.getRowspanStartInfo(targetRowIdx, colIdx), node = _c.node, pos = _c.pos;
|
|
1124
|
+
var attrs = setAttrs(node, { rowspan: node.attrs.rowspan + rowCount });
|
|
1125
|
+
tr.setNodeMarkup(tr.mapping.map(pos), null, attrs);
|
|
1126
|
+
}
|
|
1127
|
+
else {
|
|
1128
|
+
cells = cells.concat(createDummyCells(1, targetRowIdx, schema));
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
for (var i = 0; i < rowCount; i += 1) {
|
|
1132
|
+
rows.push(schema.nodes.tableRow.create(null, cells));
|
|
1133
|
+
}
|
|
1134
|
+
dispatch(tr.insert(from, rows));
|
|
1135
|
+
return true;
|
|
1136
|
+
};
|
|
1137
|
+
return addRow;
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
;// CONCATENATED MODULE: ./src/wysiwyg/command/addColumn.ts
|
|
1141
|
+
|
|
1142
|
+
|
|
1143
|
+
function getTargetColInfo(direction, map, selectionInfo) {
|
|
1144
|
+
var targetColIdx;
|
|
1145
|
+
var judgeToExtendColspan;
|
|
1146
|
+
var insertColIdx;
|
|
1147
|
+
if (direction === Direction.LEFT) {
|
|
1148
|
+
targetColIdx = selectionInfo.startColIdx;
|
|
1149
|
+
judgeToExtendColspan = function (rowIdx) { return map.extendedColspan(rowIdx, targetColIdx); };
|
|
1150
|
+
insertColIdx = targetColIdx;
|
|
1151
|
+
}
|
|
1152
|
+
else {
|
|
1153
|
+
targetColIdx = selectionInfo.endColIdx;
|
|
1154
|
+
judgeToExtendColspan = function (rowIdx) { return map.getColspanCount(rowIdx, targetColIdx) > 1; };
|
|
1155
|
+
insertColIdx = targetColIdx + 1;
|
|
1156
|
+
}
|
|
1157
|
+
return { targetColIdx: targetColIdx, judgeToExtendColspan: judgeToExtendColspan, insertColIdx: insertColIdx };
|
|
1158
|
+
}
|
|
1159
|
+
function createAddColumnCommand(context, OffsetMap, direction) {
|
|
1160
|
+
var addColumn = function (_, state, dispatch) {
|
|
1161
|
+
var selection = state.selection, tr = state.tr, schema = state.schema;
|
|
1162
|
+
var _a = getResolvedSelection(selection, context), anchor = _a.anchor, head = _a.head;
|
|
1163
|
+
if (!anchor || !head) {
|
|
1164
|
+
return false;
|
|
1165
|
+
}
|
|
1166
|
+
var map = OffsetMap.create(anchor);
|
|
1167
|
+
var selectionInfo = map.getRectOffsets(anchor, head);
|
|
1168
|
+
var _b = getTargetColInfo(direction, map, selectionInfo), targetColIdx = _b.targetColIdx, judgeToExtendColspan = _b.judgeToExtendColspan, insertColIdx = _b.insertColIdx;
|
|
1169
|
+
var columnCount = getRowAndColumnCount(selectionInfo).columnCount;
|
|
1170
|
+
var totalRowCount = map.totalRowCount;
|
|
1171
|
+
for (var rowIdx = 0; rowIdx < totalRowCount; rowIdx += 1) {
|
|
1172
|
+
// increase colspan count inside the col-spanning cell
|
|
1173
|
+
if (judgeToExtendColspan(rowIdx)) {
|
|
1174
|
+
var _c = map.getColspanStartInfo(rowIdx, targetColIdx), node = _c.node, pos = _c.pos;
|
|
1175
|
+
var attrs = setAttrs(node, { colspan: node.attrs.colspan + columnCount });
|
|
1176
|
+
tr.setNodeMarkup(tr.mapping.map(pos), null, attrs);
|
|
1177
|
+
}
|
|
1178
|
+
else {
|
|
1179
|
+
var cells = createDummyCells(columnCount, rowIdx, schema);
|
|
1180
|
+
tr.insert(tr.mapping.map(map.posAt(rowIdx, insertColIdx)), cells);
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
dispatch(tr);
|
|
1184
|
+
return true;
|
|
1185
|
+
};
|
|
1186
|
+
return addColumn;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
;// CONCATENATED MODULE: ./src/wysiwyg/commandFactory.ts
|
|
1190
|
+
|
|
1191
|
+
|
|
1192
|
+
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
function createCommands(context, OffsetMap) {
|
|
1198
|
+
return {
|
|
1199
|
+
mergeCells: createMergeCellsCommand(context, OffsetMap),
|
|
1200
|
+
splitCells: createSplitCellsCommand(context, OffsetMap),
|
|
1201
|
+
addRowToUp: createAddRowCommand(context, OffsetMap, Direction.UP),
|
|
1202
|
+
addRowToDown: createAddRowCommand(context, OffsetMap, Direction.DOWN),
|
|
1203
|
+
removeRow: createRemoveRowCommand(context, OffsetMap),
|
|
1204
|
+
addColumnToLeft: createAddColumnCommand(context, OffsetMap, Direction.LEFT),
|
|
1205
|
+
addColumnToRight: createAddColumnCommand(context, OffsetMap, Direction.RIGHT),
|
|
1206
|
+
removeColumn: createRemoveColumnCommand(context, OffsetMap),
|
|
1207
|
+
};
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
;// CONCATENATED MODULE: ./src/index.ts
|
|
1211
|
+
|
|
1212
|
+
|
|
1213
|
+
|
|
1214
|
+
|
|
1215
|
+
|
|
1216
|
+
|
|
1217
|
+
|
|
1218
|
+
|
|
1219
|
+
function tableMergedCellPlugin(context) {
|
|
1220
|
+
var i18n = context.i18n, eventEmitter = context.eventEmitter;
|
|
1221
|
+
var TableOffsetMap = eventEmitter.emitReduce('mixinTableOffsetMapPrototype', offsetMapMixin, createOffsetMapMixin);
|
|
1222
|
+
addLangs(i18n);
|
|
1223
|
+
addMergedTableContextMenu(context);
|
|
1224
|
+
return {
|
|
1225
|
+
toHTMLRenderers: toHTMLRenderers,
|
|
1226
|
+
markdownParsers: markdownParsers,
|
|
1227
|
+
toMarkdownRenderers: toMarkdownRenderers,
|
|
1228
|
+
wysiwygCommands: createCommands(context, TableOffsetMap),
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
}();
|
|
1233
|
+
module.exports = __webpack_exports__["default"];
|
|
1234
|
+
/******/ })()
|
|
1235
|
+
;
|