@worktile/theia 15.0.18 → 15.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/esm2020/interfaces/editor.mjs +1 -1
- package/esm2020/interfaces/plugins/plugin-key.mjs +2 -2
- package/esm2020/interfaces/valid-children-types.mjs +7 -7
- package/esm2020/plugins/common/insert-data-by-invalid-type.mjs +23 -0
- package/esm2020/plugins/deserialize/deserialize-html.plugin.mjs +53 -0
- package/esm2020/plugins/deserialize/deserialize-md.plugin.mjs +130 -0
- package/esm2020/plugins/index.mjs +5 -5
- package/esm2020/plugins/mention/mention.plugin.mjs +3 -2
- package/esm2020/plugins/mention/mention.type.mjs +1 -1
- package/esm2020/plugins/table/components/insert-mark/insert-mark.component.mjs +18 -7
- package/esm2020/plugins/table/components/row/row.component.mjs +3 -5
- package/esm2020/plugins/table/components/table.component.mjs +17 -107
- package/esm2020/plugins/table/components/td/td.component.mjs +3 -4
- package/esm2020/plugins/table/components/toolbar/table-options.component.mjs +5 -4
- package/esm2020/plugins/table/components/toolbar/table-toolbar.component.mjs +12 -7
- package/esm2020/plugins/table/table.editor.mjs +5 -6
- package/esm2020/plugins/table/table.plugin.mjs +16 -17
- package/esm2020/plugins/table/table.store.mjs +58 -174
- package/esm2020/plugins/table/transforms/clear-table-node.mjs +3 -3
- package/esm2020/plugins/table/transforms/insert-column.mjs +4 -3
- package/esm2020/plugins/table/transforms/insert-row.mjs +4 -3
- package/esm2020/plugins/table/transforms/remove-column.mjs +3 -3
- package/esm2020/plugins/table/transforms/remove-row.mjs +3 -5
- package/esm2020/plugins/table/transforms/remove-table.mjs +4 -4
- package/esm2020/plugins/table/utils/calculate-table.mjs +109 -0
- package/esm2020/plugins/table/utils/cell-position.mjs +36 -0
- package/esm2020/plugins/table/utils/create-table-position.mjs +10 -0
- package/esm2020/plugins/table/utils/get-grid-columns.mjs +7 -2
- package/esm2020/plugins/table/utils/get-min-max-cell-index.mjs +64 -0
- package/esm2020/plugins/table/utils/get-select-cell-node.mjs +3 -6
- package/esm2020/plugins/table/utils/is-range-in-table.mjs +6 -6
- package/esm2020/plugins/table/utils/is-selection-in-table.mjs +3 -5
- package/esm2020/plugins/table/utils/merge-cell.mjs +17 -2
- package/esm2020/plugins/table/utils/split-cell.mjs +3 -6
- package/esm2020/plugins/table/utils/table-entry.mjs +21 -0
- package/esm2020/services/table-contextmenu.service.mjs +10 -7
- package/esm2020/utils/index.mjs +2 -1
- package/esm2020/utils/insert-data-by-invalid-type.mjs +62 -0
- package/esm2020/utils/merge-element-options.mjs +5 -5
- package/fesm2015/worktile-theia.mjs +460 -407
- package/fesm2015/worktile-theia.mjs.map +1 -1
- package/fesm2020/worktile-theia.mjs +461 -409
- package/fesm2020/worktile-theia.mjs.map +1 -1
- package/interfaces/plugins/plugin-key.d.ts +1 -1
- package/interfaces/valid-children-types.d.ts +1 -1
- package/package.json +1 -1
- package/plugins/common/insert-data-by-invalid-type.d.ts +2 -0
- package/plugins/mention/mention.type.d.ts +3 -1
- package/plugins/table/components/insert-mark/insert-mark.component.d.ts +6 -3
- package/plugins/table/components/table.component.d.ts +0 -13
- package/plugins/table/components/toolbar/table-options.component.d.ts +1 -1
- package/plugins/table/table.editor.d.ts +4 -1
- package/plugins/table/table.store.d.ts +2 -20
- package/plugins/table/utils/calculate-table.d.ts +3 -0
- package/plugins/table/utils/cell-position.d.ts +14 -0
- package/plugins/table/utils/create-table-position.d.ts +3 -0
- package/plugins/table/utils/get-grid-columns.d.ts +1 -1
- package/plugins/table/utils/get-min-max-cell-index.d.ts +4 -0
- package/plugins/table/utils/is-range-in-table.d.ts +2 -2
- package/plugins/table/utils/merge-cell.d.ts +1 -0
- package/plugins/table/utils/table-entry.d.ts +5 -0
- package/utils/index.d.ts +1 -0
- package/utils/insert-data-by-invalid-type.d.ts +1 -0
- package/esm2020/plugins/common/auto-insert-data.mjs +0 -75
- package/esm2020/plugins/deserializers/deserialize-html.plugin.mjs +0 -48
- package/esm2020/plugins/deserializers/deserialize-md.plugin.mjs +0 -130
- package/plugins/common/auto-insert-data.d.ts +0 -2
- /package/plugins/{deserializers → deserialize}/deserialize-html.plugin.d.ts +0 -0
- /package/plugins/{deserializers → deserialize}/deserialize-md.plugin.d.ts +0 -0
|
@@ -2001,28 +2001,28 @@ const inValidTypes = [
|
|
|
2001
2001
|
const DefaultElementOptions = [
|
|
2002
2002
|
{
|
|
2003
2003
|
type: ElementKinds.bulletedList,
|
|
2004
|
-
|
|
2004
|
+
invalidChildrenTypes: [...inValidTypes, ...HEADING_TYPES]
|
|
2005
2005
|
},
|
|
2006
2006
|
{
|
|
2007
2007
|
type: ElementKinds.numberedList,
|
|
2008
|
-
|
|
2008
|
+
invalidChildrenTypes: [...inValidTypes, ...HEADING_TYPES]
|
|
2009
2009
|
},
|
|
2010
2010
|
{
|
|
2011
2011
|
type: ElementKinds.listItem,
|
|
2012
|
-
|
|
2012
|
+
invalidChildrenTypes: [...inValidTypes, ...HEADING_TYPES]
|
|
2013
2013
|
},
|
|
2014
2014
|
{
|
|
2015
2015
|
type: ElementKinds.blockquote,
|
|
2016
|
-
|
|
2016
|
+
invalidChildrenTypes: inValidTypes
|
|
2017
2017
|
},
|
|
2018
2018
|
{
|
|
2019
2019
|
type: ElementKinds.table,
|
|
2020
|
-
|
|
2020
|
+
invalidChildrenTypes: [ElementKinds.table]
|
|
2021
2021
|
},
|
|
2022
2022
|
{
|
|
2023
2023
|
type: ElementKinds.tableCell,
|
|
2024
2024
|
isSecondaryContainer: true,
|
|
2025
|
-
|
|
2025
|
+
invalidChildrenTypes: [ElementKinds.table, ElementKinds.tableCell]
|
|
2026
2026
|
}
|
|
2027
2027
|
];
|
|
2028
2028
|
|
|
@@ -2053,7 +2053,7 @@ var PluginKeys;
|
|
|
2053
2053
|
PluginKeys["removeVoid"] = "remove-void";
|
|
2054
2054
|
PluginKeys["removeEmpty"] = "remove-empty";
|
|
2055
2055
|
PluginKeys["theHistory"] = "the-history";
|
|
2056
|
-
PluginKeys["
|
|
2056
|
+
PluginKeys["insertDataByInvalidType"] = "insert-data-by-invalid-type";
|
|
2057
2057
|
PluginKeys["autoFormat"] = "auto-format";
|
|
2058
2058
|
PluginKeys["transforms"] = "transforms";
|
|
2059
2059
|
PluginKeys["moveSelection"] = "move-selection";
|
|
@@ -2199,19 +2199,19 @@ const isPureEmptyParagraph = (editor, block) => {
|
|
|
2199
2199
|
};
|
|
2200
2200
|
|
|
2201
2201
|
const mergeElementOptions = (elementOptions) => {
|
|
2202
|
-
elementOptions = elementOptions.filter(item => item.
|
|
2202
|
+
elementOptions = elementOptions.filter(item => item.invalidChildrenTypes.length > 0);
|
|
2203
2203
|
const combinationData = [...DefaultElementOptions, ...elementOptions];
|
|
2204
2204
|
const dataInfo = {};
|
|
2205
2205
|
combinationData.forEach(item => {
|
|
2206
|
-
const { type,
|
|
2206
|
+
const { type, invalidChildrenTypes, isSecondaryContainer } = item;
|
|
2207
2207
|
if (!dataInfo[type]) {
|
|
2208
2208
|
dataInfo[type] = {
|
|
2209
2209
|
type,
|
|
2210
|
-
|
|
2210
|
+
invalidChildrenTypes,
|
|
2211
2211
|
isSecondaryContainer
|
|
2212
2212
|
};
|
|
2213
2213
|
}
|
|
2214
|
-
dataInfo[type].
|
|
2214
|
+
dataInfo[type].invalidChildrenTypes = Array.from(new Set([...invalidChildrenTypes, ...dataInfo[type].inValidChildrenTypes]));
|
|
2215
2215
|
});
|
|
2216
2216
|
return dataInfo;
|
|
2217
2217
|
};
|
|
@@ -2418,6 +2418,63 @@ const refocus = (editor) => {
|
|
|
2418
2418
|
AngularEditor.focus(editor);
|
|
2419
2419
|
};
|
|
2420
2420
|
|
|
2421
|
+
function insertDataByInvalidType(editor, fragment) {
|
|
2422
|
+
var _a, _b;
|
|
2423
|
+
if (fragment) {
|
|
2424
|
+
let allElementOptions = DefaultElementOptions;
|
|
2425
|
+
if ((_a = editor.extraElementOptions) === null || _a === void 0 ? void 0 : _a.length) {
|
|
2426
|
+
const extraInfo = mergeElementOptions(editor.extraElementOptions);
|
|
2427
|
+
allElementOptions = Object.values(extraInfo);
|
|
2428
|
+
}
|
|
2429
|
+
if (isAcrossBlocks(editor, fragment) || Editor.isVoid(editor, fragment[0])) {
|
|
2430
|
+
const { selection } = editor;
|
|
2431
|
+
const [start] = Editor.edges(editor, selection);
|
|
2432
|
+
// query whether there is a node to be verified
|
|
2433
|
+
const tryVerifyNode = allElementOptions.find(item => getAboveByType(editor, item.type, { at: start, mode: 'lowest' }));
|
|
2434
|
+
if (tryVerifyNode) {
|
|
2435
|
+
// is exist invalid element type in fragment
|
|
2436
|
+
const invalidIndex = fragment.findIndex(item => tryVerifyNode.invalidChildrenTypes.includes(item.type));
|
|
2437
|
+
if (invalidIndex > -1) {
|
|
2438
|
+
const invalidFragmentData = fragment.slice(invalidIndex, fragment.length);
|
|
2439
|
+
const allowParentTypes = ((_b = getPluginOptions(editor, invalidFragmentData[0].type)) === null || _b === void 0 ? void 0 : _b.allowParentTypes) || [];
|
|
2440
|
+
const insertNodePath = getInsertElementsPath(editor, allowParentTypes);
|
|
2441
|
+
if (insertNodePath) {
|
|
2442
|
+
Editor.withoutNormalizing(editor, () => {
|
|
2443
|
+
Transforms.insertNodes(editor, fragment, { at: insertNodePath });
|
|
2444
|
+
Transforms.select(editor, Editor.start(editor, insertNodePath));
|
|
2445
|
+
});
|
|
2446
|
+
return false;
|
|
2447
|
+
}
|
|
2448
|
+
const [, anchorBlockPath] = anchorBlockEntry(editor);
|
|
2449
|
+
const nextPath = Path.next([anchorBlockPath[0]]);
|
|
2450
|
+
Transforms.insertNodes(editor, fragment, { at: nextPath });
|
|
2451
|
+
Transforms.select(editor, Editor.start(editor, nextPath));
|
|
2452
|
+
return false;
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
Editor.withoutNormalizing(editor, () => {
|
|
2456
|
+
const isEmptyParagraph$1 = isEmptyParagraph(editor, editor.selection.anchor);
|
|
2457
|
+
const emptyPath = Path.parent(editor.selection.anchor.path);
|
|
2458
|
+
Transforms.insertNodes(editor, fragment);
|
|
2459
|
+
if (isEmptyParagraph$1) {
|
|
2460
|
+
Transforms.delete(editor, { at: emptyPath });
|
|
2461
|
+
const lastPath = emptyPath.pop();
|
|
2462
|
+
Transforms.select(editor, [...emptyPath, lastPath + fragment.length - 1]);
|
|
2463
|
+
}
|
|
2464
|
+
else {
|
|
2465
|
+
const lastPath = emptyPath.pop();
|
|
2466
|
+
Transforms.select(editor, [...emptyPath, lastPath + fragment.length]);
|
|
2467
|
+
}
|
|
2468
|
+
AngularEditor.focus(editor);
|
|
2469
|
+
Transforms.collapse(editor, { edge: 'end' });
|
|
2470
|
+
});
|
|
2471
|
+
return false;
|
|
2472
|
+
}
|
|
2473
|
+
return true;
|
|
2474
|
+
}
|
|
2475
|
+
return true;
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2421
2478
|
const toolbarInitialize = (toolbarItems, global = DefaultGlobalToolbarDefinition, inline = DefaultInlineToolbarDefinition) => {
|
|
2422
2479
|
const toolbarDefinition = {
|
|
2423
2480
|
global,
|
|
@@ -3766,13 +3823,22 @@ class TablePosition {
|
|
|
3766
3823
|
}
|
|
3767
3824
|
}
|
|
3768
3825
|
|
|
3826
|
+
const createTablePosition = (editor, path) => {
|
|
3827
|
+
var _a;
|
|
3828
|
+
path = path || ((_a = editor.selection.anchor) === null || _a === void 0 ? void 0 : _a.path);
|
|
3829
|
+
if (!path) {
|
|
3830
|
+
throw new Error('Path invalid');
|
|
3831
|
+
}
|
|
3832
|
+
return TablePosition.create(new TableOptions(), editor, path);
|
|
3833
|
+
};
|
|
3834
|
+
|
|
3769
3835
|
/**
|
|
3770
3836
|
* True if the given range is inside one table
|
|
3771
3837
|
*/
|
|
3772
|
-
function isRangeInTable(opts,
|
|
3773
|
-
const {
|
|
3774
|
-
const startPosition =
|
|
3775
|
-
const endPosition =
|
|
3838
|
+
function isRangeInTable(opts, editor, range) {
|
|
3839
|
+
const { focus } = range;
|
|
3840
|
+
const startPosition = createTablePosition(editor);
|
|
3841
|
+
const endPosition = createTablePosition(editor, focus.path);
|
|
3776
3842
|
// Only handle events in tables
|
|
3777
3843
|
if (!startPosition.isInTable() || !endPosition.isInTable()) {
|
|
3778
3844
|
return false;
|
|
@@ -3806,8 +3872,7 @@ function isRectangularInTableCells(editor, cells) {
|
|
|
3806
3872
|
let minCol = col;
|
|
3807
3873
|
let maxRow = row;
|
|
3808
3874
|
let minRow = row;
|
|
3809
|
-
const
|
|
3810
|
-
const pos = TablePosition.create(new TableOptions(), editor, path);
|
|
3875
|
+
const pos = createTablePosition(editor);
|
|
3811
3876
|
for (let { row, col } of cells) {
|
|
3812
3877
|
const { hidden, rowspan, colspan } = pos.findCellByPath({ row, col });
|
|
3813
3878
|
if (hidden) {
|
|
@@ -4150,7 +4215,7 @@ function insertTable(opts, editor, rows = 3, columns = 3, getCellContent) {
|
|
|
4150
4215
|
}
|
|
4151
4216
|
|
|
4152
4217
|
function getInsertRowState(opts, editor, count = 1, at) {
|
|
4153
|
-
const tablePosition =
|
|
4218
|
+
const tablePosition = createTablePosition(editor);
|
|
4154
4219
|
let table = tablePosition.table;
|
|
4155
4220
|
let tableEntry = tablePosition.tableEntry;
|
|
4156
4221
|
// Create a new row with the right count of cells
|
|
@@ -4240,7 +4305,7 @@ function insertColumn(opts, editor, count = 1, at, // Column index
|
|
|
4240
4305
|
getCell) {
|
|
4241
4306
|
const { selection } = editor;
|
|
4242
4307
|
const { anchor: { path } } = selection;
|
|
4243
|
-
const tablePosition =
|
|
4308
|
+
const tablePosition = createTablePosition(editor, path);
|
|
4244
4309
|
let table = tablePosition.table;
|
|
4245
4310
|
let tableEntry = tablePosition.tableEntry;
|
|
4246
4311
|
const insertColumnIndex = typeof at === 'undefined' ? tablePosition.getColumnIndex() + 1 : at;
|
|
@@ -4306,9 +4371,7 @@ function clearCell(opts, editor, cellEntry) {
|
|
|
4306
4371
|
}
|
|
4307
4372
|
|
|
4308
4373
|
function removeRow(opts, editor, selectRowIndex) {
|
|
4309
|
-
const
|
|
4310
|
-
const { anchor: { path } } = selection;
|
|
4311
|
-
const tablePosition = TablePosition.create(opts, editor, path);
|
|
4374
|
+
const tablePosition = createTablePosition(editor);
|
|
4312
4375
|
const { tableEntry, table, rowEntry: [rowNode, rowPath] } = tablePosition;
|
|
4313
4376
|
selectRowIndex = selectRowIndex === undefined ? [...rowPath].pop() : selectRowIndex;
|
|
4314
4377
|
const at = tableEntry[1].concat(selectRowIndex);
|
|
@@ -4378,7 +4441,7 @@ function removeColumns(table, columnsCount, index) {
|
|
|
4378
4441
|
function removeColumn(opts, editor, selectColIndex) {
|
|
4379
4442
|
const { selection } = editor;
|
|
4380
4443
|
const { anchor: { path } } = selection;
|
|
4381
|
-
const tablePosition =
|
|
4444
|
+
const tablePosition = createTablePosition(editor, path);
|
|
4382
4445
|
const { tableEntry, table, row, cellEntry: [cellNode, cellPath] } = tablePosition;
|
|
4383
4446
|
const rows = tableEntry[0].children;
|
|
4384
4447
|
selectColIndex = selectColIndex === undefined ? [...cellPath].pop() : selectColIndex;
|
|
@@ -4430,8 +4493,8 @@ const NextPath = (path) => {
|
|
|
4430
4493
|
function removeTable(opts, editor) {
|
|
4431
4494
|
const { selection } = editor;
|
|
4432
4495
|
const { anchor: { path } } = selection;
|
|
4433
|
-
const pos =
|
|
4434
|
-
const {
|
|
4496
|
+
const pos = createTablePosition(editor, path);
|
|
4497
|
+
const { tableEntry: [, tablePath] } = pos;
|
|
4435
4498
|
let nextFocusEntry = null;
|
|
4436
4499
|
let shouldCollapseToEnd = false;
|
|
4437
4500
|
const nextEntry = Editor.next(editor, { at: tablePath });
|
|
@@ -5198,7 +5261,8 @@ const withMention = (editor) => {
|
|
|
5198
5261
|
else {
|
|
5199
5262
|
const mentions = (_a = getPluginOptions(editor, PluginKeys.mention)) === null || _a === void 0 ? void 0 : _a.mentions;
|
|
5200
5263
|
const currentMention = mentions === null || mentions === void 0 ? void 0 : mentions.find(m => (m === null || m === void 0 ? void 0 : m.trigger) === text);
|
|
5201
|
-
|
|
5264
|
+
const isDisabledTrigger = currentMention && currentMention.disableTrigger ? currentMention === null || currentMention === void 0 ? void 0 : currentMention.disableTrigger(editor) : false;
|
|
5265
|
+
if (editor.selection && currentMention && !isDisabledTrigger) {
|
|
5202
5266
|
MentionEditor.openSuggestion(editor, currentMention.type);
|
|
5203
5267
|
}
|
|
5204
5268
|
const searchInfo = MentionEditor.getSearchInfo(editor);
|
|
@@ -6207,7 +6271,7 @@ const TableEditor = {
|
|
|
6207
6271
|
const tableNode = getAboveByType(editor, ElementKinds.table);
|
|
6208
6272
|
if (tableNode) {
|
|
6209
6273
|
const tableComponent = ELEMENT_TO_COMPONENT.get(tableNode[0]);
|
|
6210
|
-
const selectedCellPositions = tableComponent.tableStore.
|
|
6274
|
+
const selectedCellPositions = tableComponent.tableStore.getSelectedCellPositions();
|
|
6211
6275
|
if (selectedCellPositions.length > 0) {
|
|
6212
6276
|
return selectedCellPositions;
|
|
6213
6277
|
}
|
|
@@ -6322,9 +6386,7 @@ const TableEditor = {
|
|
|
6322
6386
|
if (!TableEditor.hasHeaderRow(editor) && !TableEditor.hasHeaderColumn(editor)) {
|
|
6323
6387
|
return false;
|
|
6324
6388
|
}
|
|
6325
|
-
const
|
|
6326
|
-
const selection = editor.selection;
|
|
6327
|
-
const position = TablePosition.create(opts, editor, selection.focus.path);
|
|
6389
|
+
const position = createTablePosition(editor, editor.selection.focus.path);
|
|
6328
6390
|
if (TableEditor.hasHeaderRow(editor) && position.getRowIndex() === 0) {
|
|
6329
6391
|
return true;
|
|
6330
6392
|
}
|
|
@@ -7328,63 +7390,13 @@ const createColorPlugin = createPluginFactory({
|
|
|
7328
7390
|
}
|
|
7329
7391
|
});
|
|
7330
7392
|
|
|
7331
|
-
const
|
|
7393
|
+
const withInsertDataByInvalidType = (editor) => {
|
|
7332
7394
|
const { insertData } = editor;
|
|
7333
|
-
let allElementOptions = DefaultElementOptions;
|
|
7334
|
-
// if (validChildren?.length) {
|
|
7335
|
-
// const validInfo = mergeElementOptions(validChildren);
|
|
7336
|
-
// allElementOptions = Object.values(validInfo);
|
|
7337
|
-
// }
|
|
7338
7395
|
editor.insertData = (data) => {
|
|
7339
|
-
var _a, _b;
|
|
7340
|
-
if ((_a = editor.extraElementOptions) === null || _a === void 0 ? void 0 : _a.length) {
|
|
7341
|
-
const extraInfo = mergeElementOptions(editor.extraElementOptions);
|
|
7342
|
-
allElementOptions = Object.values(extraInfo);
|
|
7343
|
-
}
|
|
7344
7396
|
const fragment = extractFragment(data);
|
|
7345
7397
|
if (fragment) {
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
const [start] = Editor.edges(editor, selection);
|
|
7349
|
-
// query whether there is a node to be verified
|
|
7350
|
-
const tryVerifyNode = allElementOptions.find(item => getAboveByType(editor, item.type, { at: start, mode: 'lowest' }));
|
|
7351
|
-
if (tryVerifyNode) {
|
|
7352
|
-
// is exist invalid element type in fragment
|
|
7353
|
-
const invalidIndex = fragment.findIndex(item => tryVerifyNode.inValidChildrenTypes.includes(item.type));
|
|
7354
|
-
if (invalidIndex > -1) {
|
|
7355
|
-
const invalidFragmentData = fragment.slice(invalidIndex, fragment.length);
|
|
7356
|
-
const allowParentTypes = ((_b = getPluginOptions(editor, invalidFragmentData[0].type)) === null || _b === void 0 ? void 0 : _b.allowParentTypes) || [];
|
|
7357
|
-
const insertNodePath = getInsertElementsPath(editor, allowParentTypes);
|
|
7358
|
-
if (insertNodePath) {
|
|
7359
|
-
Editor.withoutNormalizing(editor, () => {
|
|
7360
|
-
Transforms.insertNodes(editor, fragment, { at: insertNodePath });
|
|
7361
|
-
Transforms.select(editor, Editor.start(editor, insertNodePath));
|
|
7362
|
-
});
|
|
7363
|
-
return;
|
|
7364
|
-
}
|
|
7365
|
-
const [, anchorBlockPath] = anchorBlockEntry(editor);
|
|
7366
|
-
const nextPath = Path.next([anchorBlockPath[0]]);
|
|
7367
|
-
Transforms.insertNodes(editor, fragment, { at: nextPath });
|
|
7368
|
-
Transforms.select(editor, Editor.start(editor, nextPath));
|
|
7369
|
-
return;
|
|
7370
|
-
}
|
|
7371
|
-
}
|
|
7372
|
-
Editor.withoutNormalizing(editor, () => {
|
|
7373
|
-
const isEmptyParagraph$1 = isEmptyParagraph(editor, editor.selection.anchor);
|
|
7374
|
-
const emptyPath = Path.parent(editor.selection.anchor.path);
|
|
7375
|
-
Transforms.insertNodes(editor, fragment);
|
|
7376
|
-
if (isEmptyParagraph$1) {
|
|
7377
|
-
Transforms.delete(editor, { at: emptyPath });
|
|
7378
|
-
const lastPath = emptyPath.pop();
|
|
7379
|
-
Transforms.select(editor, [...emptyPath, lastPath + fragment.length - 1]);
|
|
7380
|
-
}
|
|
7381
|
-
else {
|
|
7382
|
-
const lastPath = emptyPath.pop();
|
|
7383
|
-
Transforms.select(editor, [...emptyPath, lastPath + fragment.length]);
|
|
7384
|
-
}
|
|
7385
|
-
AngularEditor.focus(editor);
|
|
7386
|
-
Transforms.collapse(editor, { edge: 'end' });
|
|
7387
|
-
});
|
|
7398
|
+
const isContinue = insertDataByInvalidType(editor, fragment);
|
|
7399
|
+
if (!isContinue) {
|
|
7388
7400
|
return;
|
|
7389
7401
|
}
|
|
7390
7402
|
}
|
|
@@ -7392,9 +7404,9 @@ const withAutoInsertData = (editor) => {
|
|
|
7392
7404
|
};
|
|
7393
7405
|
return editor;
|
|
7394
7406
|
};
|
|
7395
|
-
const
|
|
7396
|
-
key: PluginKeys.
|
|
7397
|
-
withOverrides:
|
|
7407
|
+
const createInsertDataByInvalidTypePlugin = createPluginFactory({
|
|
7408
|
+
key: PluginKeys.insertDataByInvalidType,
|
|
7409
|
+
withOverrides: withInsertDataByInvalidType
|
|
7398
7410
|
});
|
|
7399
7411
|
|
|
7400
7412
|
const withBlockCard = (editor) => {
|
|
@@ -8022,6 +8034,10 @@ const withDeserializeHTML = (editor) => {
|
|
|
8022
8034
|
ImageEditor.handleBase64ImageElement(editor, node);
|
|
8023
8035
|
}
|
|
8024
8036
|
});
|
|
8037
|
+
const isContinue = insertDataByInvalidType(editor, fragment);
|
|
8038
|
+
if (!isContinue) {
|
|
8039
|
+
return;
|
|
8040
|
+
}
|
|
8025
8041
|
Transforms.insertFragment(editor, fragment);
|
|
8026
8042
|
return;
|
|
8027
8043
|
}
|
|
@@ -11138,9 +11154,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImpor
|
|
|
11138
11154
|
}], ctorParameters: function () { return [{ type: i0.NgZone }]; } });
|
|
11139
11155
|
|
|
11140
11156
|
function splitCell(editor) {
|
|
11141
|
-
const
|
|
11142
|
-
const { anchor } = editor.selection;
|
|
11143
|
-
const tablePosition = TablePosition.create(opts, editor, anchor.path);
|
|
11157
|
+
const tablePosition = createTablePosition(editor);
|
|
11144
11158
|
const { cell, table, cellEntry } = tablePosition;
|
|
11145
11159
|
if ((!cell.rowspan && !cell.colspan) || (cell.rowspan === 1 && cell.colspan === 1))
|
|
11146
11160
|
return editor;
|
|
@@ -11166,9 +11180,7 @@ function resetTableCell(editor, table, cell, cellRow, cellCol) {
|
|
|
11166
11180
|
}
|
|
11167
11181
|
|
|
11168
11182
|
function getSelectCellNode(editor, selectedCells) {
|
|
11169
|
-
const
|
|
11170
|
-
const opts = new TableOptions();
|
|
11171
|
-
const pos = TablePosition.create(opts, editor, anchor.path);
|
|
11183
|
+
const pos = createTablePosition(editor);
|
|
11172
11184
|
return selectedCells
|
|
11173
11185
|
.map(item => {
|
|
11174
11186
|
const node = pos.findCellByPath(item);
|
|
@@ -11179,12 +11191,48 @@ function getSelectCellNode(editor, selectedCells) {
|
|
|
11179
11191
|
.filter(item => item);
|
|
11180
11192
|
}
|
|
11181
11193
|
|
|
11194
|
+
/* cell-position 有关的函数 */
|
|
11195
|
+
const isSelectedAllCell = (editor, selectedCellPositions) => {
|
|
11196
|
+
const pos = createTablePosition(editor);
|
|
11197
|
+
return !!selectedCellPositions.length && pos.getHeight() * pos.getWidth() === selectedCellPositions.length;
|
|
11198
|
+
};
|
|
11199
|
+
const getSelectedCellPositions = (editor, selectedCells) => {
|
|
11200
|
+
return selectedCells === null || selectedCells === void 0 ? void 0 : selectedCells.map((cell) => {
|
|
11201
|
+
const path = AngularEditor.findPath(editor, cell);
|
|
11202
|
+
const [row, col] = path.slice(-2);
|
|
11203
|
+
return { row, col };
|
|
11204
|
+
});
|
|
11205
|
+
};
|
|
11206
|
+
/* 获取一定范围内所有的单元格 */
|
|
11207
|
+
const getCellPositionsFromRange = (startRow, startCol, endRow, endCol) => {
|
|
11208
|
+
const result = [];
|
|
11209
|
+
for (let row = startRow; row < endRow; row++) {
|
|
11210
|
+
for (let col = startCol; col < endCol; col++) {
|
|
11211
|
+
result.push({ row, col });
|
|
11212
|
+
}
|
|
11213
|
+
}
|
|
11214
|
+
return result;
|
|
11215
|
+
};
|
|
11216
|
+
/**
|
|
11217
|
+
* 去重重复的单元格位置
|
|
11218
|
+
* @returns
|
|
11219
|
+
*/
|
|
11220
|
+
const uniqueCellPosition = (cells, selectedCellPositions) => {
|
|
11221
|
+
const result = [];
|
|
11222
|
+
const modCells = new Set();
|
|
11223
|
+
cells.concat(selectedCellPositions).forEach(cell => modCells.add(JSON.stringify(cell)));
|
|
11224
|
+
modCells.forEach((cell) => result.push(JSON.parse(cell)));
|
|
11225
|
+
return result;
|
|
11226
|
+
};
|
|
11227
|
+
|
|
11182
11228
|
function isSelectedCellMerged(editor) {
|
|
11183
11229
|
if (editor && editor.selection) {
|
|
11184
11230
|
const opts = new TableOptions();
|
|
11185
11231
|
const { anchor } = editor.selection;
|
|
11186
11232
|
const { cell } = TablePosition.create(opts, editor, anchor.path);
|
|
11187
|
-
|
|
11233
|
+
if (cell) {
|
|
11234
|
+
return (cell.colspan && cell.colspan !== 1) || (cell.rowspan && cell.rowspan !== 1);
|
|
11235
|
+
}
|
|
11188
11236
|
}
|
|
11189
11237
|
return false;
|
|
11190
11238
|
}
|
|
@@ -11264,6 +11312,17 @@ function mergeCellContent(editor, leftTopCellPath, cellPath) {
|
|
|
11264
11312
|
});
|
|
11265
11313
|
});
|
|
11266
11314
|
}
|
|
11315
|
+
// 计算合并前的单元格
|
|
11316
|
+
function getCellPositionsBeforeMerge(editor, { row, col }) {
|
|
11317
|
+
const pos = createTablePosition(editor);
|
|
11318
|
+
const { rowspan, colspan } = pos.findCellByPath({ row, col });
|
|
11319
|
+
if (rowspan || colspan) {
|
|
11320
|
+
const colSpan = colspan !== null && colspan !== void 0 ? colspan : 1;
|
|
11321
|
+
const rowSpan = rowspan !== null && rowspan !== void 0 ? rowspan : 1;
|
|
11322
|
+
return getCellPositionsFromRange(row, col, row + rowSpan, col + colSpan);
|
|
11323
|
+
}
|
|
11324
|
+
return [{ row, col }];
|
|
11325
|
+
}
|
|
11267
11326
|
|
|
11268
11327
|
function setCellMenuVisibility(editor, menuList, tableInfo) {
|
|
11269
11328
|
const { selectedCellPositions, isFullscreen, isSelectedTable, selectedRowsIndex, selectedColumnsIndex } = tableInfo;
|
|
@@ -11369,10 +11428,87 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImpor
|
|
|
11369
11428
|
args: ['mousedown', ['$event']]
|
|
11370
11429
|
}] } });
|
|
11371
11430
|
|
|
11372
|
-
|
|
11373
|
-
|
|
11374
|
-
|
|
11431
|
+
const getTableEntry = (editor) => {
|
|
11432
|
+
const { tableEntry } = createTablePosition(editor);
|
|
11433
|
+
return tableEntry;
|
|
11434
|
+
};
|
|
11435
|
+
const getTablePath = (editor) => {
|
|
11436
|
+
const tableEntry = getTableEntry(editor);
|
|
11437
|
+
return tableEntry[1];
|
|
11438
|
+
};
|
|
11439
|
+
const getTable = (editor) => {
|
|
11440
|
+
const { tableEntry } = createTablePosition(editor);
|
|
11441
|
+
return tableEntry[0];
|
|
11442
|
+
};
|
|
11443
|
+
const getSelectedCell = (editor) => {
|
|
11444
|
+
if (editor && editor.selection) {
|
|
11445
|
+
const { cell } = createTablePosition(editor);
|
|
11446
|
+
return cell;
|
|
11447
|
+
}
|
|
11448
|
+
return null;
|
|
11449
|
+
};
|
|
11450
|
+
|
|
11451
|
+
const getMinAndMaxCellIndex = (editor, selectedCellPositions, maxRow, maxCol, minRow, minCol, table) => {
|
|
11452
|
+
const beforeCols = [];
|
|
11453
|
+
const beforeRows = [];
|
|
11454
|
+
let spanSelectedCells = [];
|
|
11455
|
+
if (selectedCellPositions.length) {
|
|
11456
|
+
spanSelectedCells = selectedCellPositions
|
|
11457
|
+
.map(item => {
|
|
11458
|
+
const { row, col } = item;
|
|
11459
|
+
const node = table.children[row].children[col];
|
|
11460
|
+
if (!node.hidden) {
|
|
11461
|
+
return Object.assign(Object.assign({}, item), { colspan: node.colspan || 1, rowspan: node.rowspan || 1 });
|
|
11462
|
+
}
|
|
11463
|
+
})
|
|
11464
|
+
.filter(item => item);
|
|
11465
|
+
}
|
|
11466
|
+
table.children.map((row, rowIndex) => {
|
|
11467
|
+
if (rowIndex <= maxRow) {
|
|
11468
|
+
row.children.map((cell, colIndex) => {
|
|
11469
|
+
if (colIndex <= maxCol) {
|
|
11470
|
+
const cellRowIndex = rowIndex + (cell.rowspan || 1) - 1;
|
|
11471
|
+
const cellColIndex = colIndex + (cell.colspan || 1) - 1;
|
|
11472
|
+
if (spanSelectedCells.length) {
|
|
11473
|
+
const { row: selectRow, col: selectCol, rowspan: selectRowspan, colspan: selectColspan } = spanSelectedCells[0];
|
|
11474
|
+
if (selectRow + selectRowspan - 1 >= minRow && selectCol + selectColspan - 1 >= minCol) {
|
|
11475
|
+
minRow = Math.min(spanSelectedCells[0].row, minRow);
|
|
11476
|
+
minCol = Math.min(spanSelectedCells[0].col, minCol);
|
|
11477
|
+
}
|
|
11478
|
+
}
|
|
11479
|
+
if (cell.colspan && cell.colspan > 1) {
|
|
11480
|
+
beforeCols.push({ rowIndex, colIndex, cellColIndex });
|
|
11481
|
+
if (cellColIndex >= minCol && cellRowIndex >= minRow) {
|
|
11482
|
+
maxCol = Math.max(maxCol, cellColIndex);
|
|
11483
|
+
minCol = Math.min(minCol, colIndex);
|
|
11484
|
+
}
|
|
11485
|
+
}
|
|
11486
|
+
if (cell.rowspan && cell.rowspan > 1) {
|
|
11487
|
+
beforeRows.push({ rowIndex, colIndex, cellRowIndex });
|
|
11488
|
+
if (cellColIndex >= minCol && cellRowIndex >= minRow) {
|
|
11489
|
+
minRow = Math.min(minRow, rowIndex);
|
|
11490
|
+
maxRow = Math.max(maxRow, cellRowIndex);
|
|
11491
|
+
}
|
|
11492
|
+
}
|
|
11493
|
+
}
|
|
11494
|
+
});
|
|
11495
|
+
}
|
|
11496
|
+
});
|
|
11497
|
+
// 判断选区范围内之前的单元格 如果存在cellColIndex === minCol,表示当前获取的minCol并不是最小的,重新获取minCol
|
|
11498
|
+
const colNode = beforeCols.filter(item => item.rowIndex <= maxRow && item.colIndex <= maxCol && item.rowIndex >= minRow && item.cellColIndex === minCol);
|
|
11499
|
+
const rowNode = beforeRows.filter(item => item.rowIndex <= maxRow && item.colIndex <= maxCol && item.colIndex >= minCol && item.cellRowIndex === minRow);
|
|
11500
|
+
if (colNode.length || rowNode.length) {
|
|
11501
|
+
return getMinAndMaxCellIndex(editor, selectedCellPositions, maxRow, maxCol, minRow, minCol, table);
|
|
11375
11502
|
}
|
|
11503
|
+
return {
|
|
11504
|
+
minRow,
|
|
11505
|
+
maxRow,
|
|
11506
|
+
minCol,
|
|
11507
|
+
maxCol
|
|
11508
|
+
};
|
|
11509
|
+
};
|
|
11510
|
+
|
|
11511
|
+
class TableStore {
|
|
11376
11512
|
get dangerousCells() {
|
|
11377
11513
|
return this.dangerousCells$.getValue();
|
|
11378
11514
|
}
|
|
@@ -11390,45 +11526,32 @@ class TableStore {
|
|
|
11390
11526
|
this.isRightClicking = false;
|
|
11391
11527
|
this.pointerSelection = false;
|
|
11392
11528
|
this.isSelectedAllCell = () => {
|
|
11393
|
-
|
|
11394
|
-
|
|
11395
|
-
|
|
11396
|
-
|
|
11397
|
-
|
|
11398
|
-
const opts = new TableOptions();
|
|
11399
|
-
return TablePosition.create(opts, this.editor, path);
|
|
11529
|
+
if (!this.editor.selection)
|
|
11530
|
+
return false;
|
|
11531
|
+
const pos = createTablePosition(this.editor);
|
|
11532
|
+
const selectedCellPositions = this.getSelectedCellPositions();
|
|
11533
|
+
return !!selectedCellPositions.length && pos.getHeight() * pos.getWidth() === selectedCellPositions.length;
|
|
11400
11534
|
};
|
|
11401
11535
|
}
|
|
11402
|
-
getTableEntry() {
|
|
11403
|
-
const { tableEntry } = this.createTablePosition();
|
|
11404
|
-
return tableEntry;
|
|
11405
|
-
}
|
|
11406
|
-
getTablePath() {
|
|
11407
|
-
const tableEntry = this.getTableEntry();
|
|
11408
|
-
return tableEntry[1];
|
|
11409
|
-
}
|
|
11410
11536
|
getSelectedCellPositions() {
|
|
11411
|
-
return this.selectedCells$.getValue()
|
|
11412
|
-
const path = AngularEditor.findPath(this.editor, cell);
|
|
11413
|
-
const [row, col] = path.slice(-2);
|
|
11414
|
-
return { row, col };
|
|
11415
|
-
});
|
|
11537
|
+
return getSelectedCellPositions(this.editor, this.selectedCells$.getValue());
|
|
11416
11538
|
}
|
|
11417
|
-
|
|
11539
|
+
setSelectedColumnsAndRowIndex() {
|
|
11418
11540
|
var _a;
|
|
11419
11541
|
if (!((_a = this.editor) === null || _a === void 0 ? void 0 : _a.selection)) {
|
|
11420
11542
|
return;
|
|
11421
11543
|
}
|
|
11422
|
-
const pos = this.
|
|
11544
|
+
const pos = createTablePosition(this.editor);
|
|
11423
11545
|
if (!(pos === null || pos === void 0 ? void 0 : pos.table)) {
|
|
11424
11546
|
return;
|
|
11425
11547
|
}
|
|
11426
11548
|
const mergeBeforeCells = [];
|
|
11427
|
-
this.
|
|
11549
|
+
const selectedCellPositions = this.getSelectedCellPositions();
|
|
11550
|
+
selectedCellPositions.forEach(({ row, col }) => {
|
|
11428
11551
|
// 计算合并单元格数据时,要按合并前的数据处理
|
|
11429
|
-
mergeBeforeCells.push(...this.
|
|
11552
|
+
mergeBeforeCells.push(...getCellPositionsBeforeMerge(this.editor, { row, col }));
|
|
11430
11553
|
});
|
|
11431
|
-
const cells =
|
|
11554
|
+
const cells = uniqueCellPosition(mergeBeforeCells, selectedCellPositions);
|
|
11432
11555
|
const rowGroup = groupBy(cells, ({ row }) => row);
|
|
11433
11556
|
const colGroup = groupBy(cells, ({ col }) => col);
|
|
11434
11557
|
this.selectedRowsIndex = [];
|
|
@@ -11445,7 +11568,7 @@ class TableStore {
|
|
|
11445
11568
|
}
|
|
11446
11569
|
this.selectedRowsIndex = uniq(this.selectedRowsIndex);
|
|
11447
11570
|
this.selectedColumnsIndex = uniq(this.selectedColumnsIndex);
|
|
11448
|
-
if (
|
|
11571
|
+
if (isSelectedAllCell(this.editor, selectedCellPositions)) {
|
|
11449
11572
|
this.isSelectedTable = true;
|
|
11450
11573
|
}
|
|
11451
11574
|
else {
|
|
@@ -11453,64 +11576,40 @@ class TableStore {
|
|
|
11453
11576
|
}
|
|
11454
11577
|
}
|
|
11455
11578
|
setSelectedCells(cells, pos) {
|
|
11456
|
-
const uniqueCells = this.pointerSelection ? this.
|
|
11579
|
+
const uniqueCells = this.pointerSelection ? uniqueCellPosition(cells, this.getSelectedCellPositions()) : cells;
|
|
11457
11580
|
const cellElements = uniqueCells.map(cell => {
|
|
11458
11581
|
return pos.findCellByPath(cell);
|
|
11459
11582
|
});
|
|
11460
11583
|
this.selectedCells$.next(cellElements);
|
|
11461
|
-
this.
|
|
11584
|
+
this.setSelectedColumnsAndRowIndex();
|
|
11462
11585
|
}
|
|
11463
11586
|
initEditor(editor) {
|
|
11464
11587
|
this.editor = editor;
|
|
11465
11588
|
}
|
|
11466
|
-
/**
|
|
11467
|
-
* 去重重复的单元格位置
|
|
11468
|
-
* @returns
|
|
11469
|
-
*/
|
|
11470
|
-
uniqueCellPosition(cells) {
|
|
11471
|
-
const result = [];
|
|
11472
|
-
const modCells = new Set();
|
|
11473
|
-
cells.concat(this.selectedCellPositions).forEach(cell => modCells.add(JSON.stringify(cell)));
|
|
11474
|
-
modCells.forEach((cell) => result.push(JSON.parse(cell)));
|
|
11475
|
-
return result;
|
|
11476
|
-
}
|
|
11477
|
-
/**
|
|
11478
|
-
* 获取一定范围内所有的单元格
|
|
11479
|
-
* @returns
|
|
11480
|
-
*/
|
|
11481
|
-
getCellPositionsFromRange(startRow, startCol, endRow, endCol) {
|
|
11482
|
-
const result = [];
|
|
11483
|
-
for (let row = startRow; row < endRow; row++) {
|
|
11484
|
-
for (let col = startCol; col < endCol; col++) {
|
|
11485
|
-
result.push({ row, col });
|
|
11486
|
-
}
|
|
11487
|
-
}
|
|
11488
|
-
return result;
|
|
11489
|
-
}
|
|
11490
11589
|
selectRow(editor, index) {
|
|
11491
11590
|
this.clearLastFocusPath();
|
|
11492
|
-
const pos =
|
|
11493
|
-
const cells =
|
|
11591
|
+
const pos = createTablePosition(editor);
|
|
11592
|
+
const cells = getCellPositionsFromRange(index, 0, index + 1, pos.getWidth());
|
|
11494
11593
|
this.setSelectedCells(cells, pos);
|
|
11495
11594
|
this.focusCell(editor, pos.tableEntry[1].concat([index, 0]));
|
|
11496
11595
|
}
|
|
11497
11596
|
selectColumn(editor, index) {
|
|
11498
11597
|
this.clearLastFocusPath();
|
|
11499
|
-
const pos =
|
|
11500
|
-
const cells =
|
|
11598
|
+
const pos = createTablePosition(editor);
|
|
11599
|
+
const cells = getCellPositionsFromRange(0, index, pos.getHeight(), index + 1);
|
|
11501
11600
|
this.setSelectedCells(cells, pos);
|
|
11502
11601
|
this.focusCell(editor, pos.tableEntry[1].concat([0, index]));
|
|
11503
11602
|
}
|
|
11504
11603
|
selectTable(editor) {
|
|
11505
11604
|
this.isSelectedTable = true;
|
|
11506
|
-
const pos =
|
|
11507
|
-
const cells =
|
|
11605
|
+
const pos = createTablePosition(editor);
|
|
11606
|
+
const cells = getCellPositionsFromRange(0, 0, pos.getHeight(), pos.getWidth());
|
|
11508
11607
|
this.setSelectedCells(cells, pos);
|
|
11509
11608
|
this.focusCell(editor, pos.tableEntry[1].concat([0, 0]));
|
|
11510
11609
|
}
|
|
11511
11610
|
// 拖选
|
|
11512
11611
|
selectCells(editor) {
|
|
11513
|
-
const pos =
|
|
11612
|
+
const pos = createTablePosition(editor);
|
|
11514
11613
|
const anchorPath = this.anchorCellPath.slice(-2);
|
|
11515
11614
|
const focusPath = this.focusCellPath.slice(-2);
|
|
11516
11615
|
const rows = [anchorPath[0], focusPath[0]].sort((m, n) => m - n);
|
|
@@ -11523,69 +11622,10 @@ class TableStore {
|
|
|
11523
11622
|
const focusCol = focusPath[1] + (focusColspanCount || 1) - 1;
|
|
11524
11623
|
let initMaxCol = Math.max(anchorCol, focusCol);
|
|
11525
11624
|
let initMaxRow = Math.max(anchorRow, focusRow);
|
|
11526
|
-
const { minRow, maxRow, minCol, maxCol } = this.
|
|
11527
|
-
const cells =
|
|
11625
|
+
const { minRow, maxRow, minCol, maxCol } = getMinAndMaxCellIndex(this.editor, this.getSelectedCellPositions(), initMaxRow, initMaxCol, rows[0], columns[0], pos.table);
|
|
11626
|
+
const cells = getCellPositionsFromRange(minRow, minCol, maxRow + 1, maxCol + 1);
|
|
11528
11627
|
this.setSelectedCells(cells, pos);
|
|
11529
11628
|
}
|
|
11530
|
-
getMinAndMaxCellIndex(maxRow, maxCol, minRow, minCol, table) {
|
|
11531
|
-
const beforeCols = [];
|
|
11532
|
-
const beforeRows = [];
|
|
11533
|
-
let spanSelectedCells = [];
|
|
11534
|
-
if (this.selectedCellPositions.length) {
|
|
11535
|
-
spanSelectedCells = this.selectedCellPositions
|
|
11536
|
-
.map(item => {
|
|
11537
|
-
const { row, col } = item;
|
|
11538
|
-
const node = table.children[row].children[col];
|
|
11539
|
-
if (!node.hidden) {
|
|
11540
|
-
return Object.assign(Object.assign({}, item), { colspan: node.colspan || 1, rowspan: node.rowspan || 1 });
|
|
11541
|
-
}
|
|
11542
|
-
})
|
|
11543
|
-
.filter(item => item);
|
|
11544
|
-
}
|
|
11545
|
-
table.children.map((row, rowIndex) => {
|
|
11546
|
-
if (rowIndex <= maxRow) {
|
|
11547
|
-
row.children.map((cell, colIndex) => {
|
|
11548
|
-
if (colIndex <= maxCol) {
|
|
11549
|
-
const cellRowIndex = rowIndex + (cell.rowspan || 1) - 1;
|
|
11550
|
-
const cellColIndex = colIndex + (cell.colspan || 1) - 1;
|
|
11551
|
-
if (spanSelectedCells.length) {
|
|
11552
|
-
const { row: selectRow, col: selectCol, rowspan: selectRowspan, colspan: selectColspan } = spanSelectedCells[0];
|
|
11553
|
-
if (selectRow + selectRowspan - 1 >= minRow && selectCol + selectColspan - 1 >= minCol) {
|
|
11554
|
-
minRow = Math.min(spanSelectedCells[0].row, minRow);
|
|
11555
|
-
minCol = Math.min(spanSelectedCells[0].col, minCol);
|
|
11556
|
-
}
|
|
11557
|
-
}
|
|
11558
|
-
if (cell.colspan && cell.colspan > 1) {
|
|
11559
|
-
beforeCols.push({ rowIndex, colIndex, cellColIndex });
|
|
11560
|
-
if (cellColIndex >= minCol && cellRowIndex >= minRow) {
|
|
11561
|
-
maxCol = Math.max(maxCol, cellColIndex);
|
|
11562
|
-
minCol = Math.min(minCol, colIndex);
|
|
11563
|
-
}
|
|
11564
|
-
}
|
|
11565
|
-
if (cell.rowspan && cell.rowspan > 1) {
|
|
11566
|
-
beforeRows.push({ rowIndex, colIndex, cellRowIndex });
|
|
11567
|
-
if (cellColIndex >= minCol && cellRowIndex >= minRow) {
|
|
11568
|
-
minRow = Math.min(minRow, rowIndex);
|
|
11569
|
-
maxRow = Math.max(maxRow, cellRowIndex);
|
|
11570
|
-
}
|
|
11571
|
-
}
|
|
11572
|
-
}
|
|
11573
|
-
});
|
|
11574
|
-
}
|
|
11575
|
-
});
|
|
11576
|
-
// 判断选区范围内之前的单元格 如果存在cellColIndex === minCol,表示当前获取的minCol并不是最小的,重新获取minCol
|
|
11577
|
-
const colNode = beforeCols.filter(item => item.rowIndex <= maxRow && item.colIndex <= maxCol && item.rowIndex >= minRow && item.cellColIndex === minCol);
|
|
11578
|
-
const rowNode = beforeRows.filter(item => item.rowIndex <= maxRow && item.colIndex <= maxCol && item.colIndex >= minCol && item.cellRowIndex === minRow);
|
|
11579
|
-
if (colNode.length || rowNode.length) {
|
|
11580
|
-
return this.getMinAndMaxCellIndex(maxRow, maxCol, minRow, minCol, table);
|
|
11581
|
-
}
|
|
11582
|
-
return {
|
|
11583
|
-
minRow,
|
|
11584
|
-
maxRow,
|
|
11585
|
-
minCol,
|
|
11586
|
-
maxCol
|
|
11587
|
-
};
|
|
11588
|
-
}
|
|
11589
11629
|
// 选择单元格
|
|
11590
11630
|
selectCell(cell, editor) {
|
|
11591
11631
|
var _a;
|
|
@@ -11595,33 +11635,23 @@ class TableStore {
|
|
|
11595
11635
|
this.focusCellPath = path;
|
|
11596
11636
|
this.focusCellElement = cell;
|
|
11597
11637
|
const [row, col] = path.slice(-2);
|
|
11598
|
-
const pos =
|
|
11638
|
+
const pos = createTablePosition(editor);
|
|
11599
11639
|
const result = [{ row, col }];
|
|
11640
|
+
const selectedCellPositions = this.getSelectedCellPositions();
|
|
11600
11641
|
if (this.pointerSelection) {
|
|
11601
|
-
result.push(...
|
|
11642
|
+
result.push(...selectedCellPositions);
|
|
11602
11643
|
// 处理单元格选中时,处理为选中多单元格
|
|
11603
|
-
const selectedCells = this.
|
|
11644
|
+
const selectedCells = getCellPositionsBeforeMerge(this.editor, { row, col });
|
|
11604
11645
|
result.push(...selectedCells);
|
|
11605
11646
|
// 已聚焦的单元格在多选模式下选中(暂存上次聚焦的单元格数据)
|
|
11606
11647
|
const focusCell = (_a = this.lastFocusCellPath) === null || _a === void 0 ? void 0 : _a.slice(-2);
|
|
11607
11648
|
if (focusCell) {
|
|
11608
|
-
const focusCells = this.
|
|
11649
|
+
const focusCells = getCellPositionsBeforeMerge(this.editor, { row: focusCell[0], col: focusCell[1] });
|
|
11609
11650
|
result.push(...focusCells);
|
|
11610
11651
|
}
|
|
11611
11652
|
}
|
|
11612
11653
|
this.setSelectedCells(result, pos);
|
|
11613
11654
|
}
|
|
11614
|
-
// 计算合并前的单元格
|
|
11615
|
-
getCellPositionsBeforeMerge({ row, col }) {
|
|
11616
|
-
const pos = this.createTablePosition();
|
|
11617
|
-
const { rowspan, colspan } = pos.findCellByPath({ row, col });
|
|
11618
|
-
if (rowspan || colspan) {
|
|
11619
|
-
const colSpan = colspan !== null && colspan !== void 0 ? colspan : 1;
|
|
11620
|
-
const rowSpan = rowspan !== null && rowspan !== void 0 ? rowspan : 1;
|
|
11621
|
-
return this.getCellPositionsFromRange(row, col, row + rowSpan, col + colSpan);
|
|
11622
|
-
}
|
|
11623
|
-
return [{ row, col }];
|
|
11624
|
-
}
|
|
11625
11655
|
selectedCellsChange() {
|
|
11626
11656
|
return this.selectedCells$.asObservable().pipe(skip(1));
|
|
11627
11657
|
}
|
|
@@ -11675,9 +11705,10 @@ class TableStore {
|
|
|
11675
11705
|
this.focusCellElement = cell;
|
|
11676
11706
|
}
|
|
11677
11707
|
else {
|
|
11708
|
+
const selectedCellPositions = this.getSelectedCellPositions();
|
|
11678
11709
|
isChanged =
|
|
11679
11710
|
!this.focusCellPath ||
|
|
11680
|
-
(this.focusCellPath.toString() === this.anchorCellPath.toString() &&
|
|
11711
|
+
(this.focusCellPath.toString() === this.anchorCellPath.toString() && selectedCellPositions.length === 0);
|
|
11681
11712
|
}
|
|
11682
11713
|
if (this.isPrepareSelecting && isChanged) {
|
|
11683
11714
|
if (JSON.stringify(this.preFocusCellPath) !== JSON.stringify(this.focusCellPath)) {
|
|
@@ -11703,15 +11734,16 @@ class TableStore {
|
|
|
11703
11734
|
return this.dangerousCells$.asObservable().pipe(skip(1));
|
|
11704
11735
|
}
|
|
11705
11736
|
setDangerousCells() {
|
|
11737
|
+
const selectedCellPositions = this.getSelectedCellPositions();
|
|
11706
11738
|
this.dangerousRowsIndex = this.selectedRowsIndex;
|
|
11707
11739
|
this.dangerousColumnsIndex = this.selectedColumnsIndex;
|
|
11708
|
-
this.dangerousCells$.next(
|
|
11740
|
+
this.dangerousCells$.next(selectedCellPositions);
|
|
11709
11741
|
}
|
|
11710
11742
|
clearDangerousCells() {
|
|
11711
11743
|
this.dangerousRowsIndex = [];
|
|
11712
11744
|
this.dangerousColumnsIndex = [];
|
|
11713
11745
|
this.dangerousCells$.next([]);
|
|
11714
|
-
const pos = this.
|
|
11746
|
+
const pos = createTablePosition(this.editor);
|
|
11715
11747
|
if (pos.table) {
|
|
11716
11748
|
this.isSelectedTable = this.selectedRowsIndex.length === pos.getHeight() && this.selectedColumnsIndex.length === pos.getWidth();
|
|
11717
11749
|
}
|
|
@@ -11720,9 +11752,10 @@ class TableStore {
|
|
|
11720
11752
|
return merge(this.dangerousCells$.asObservable().pipe(skip(1)), this.selectedCells$.asObservable().pipe(skip(1)));
|
|
11721
11753
|
}
|
|
11722
11754
|
setDangerousRows() {
|
|
11723
|
-
const
|
|
11755
|
+
const selectedCellPositions = this.getSelectedCellPositions();
|
|
11756
|
+
const cells = selectedCellPositions;
|
|
11724
11757
|
const rows = uniq(map(cells, 'row')).valueOf();
|
|
11725
|
-
const pos = this.
|
|
11758
|
+
const pos = createTablePosition(this.editor);
|
|
11726
11759
|
const result = [];
|
|
11727
11760
|
this.dangerousRowsIndex = rows;
|
|
11728
11761
|
this.isSelectedTable = rows.length === pos.getHeight();
|
|
@@ -11740,9 +11773,10 @@ class TableStore {
|
|
|
11740
11773
|
this.dangerousCells$.next(result);
|
|
11741
11774
|
}
|
|
11742
11775
|
setDangerousColumns() {
|
|
11743
|
-
const
|
|
11776
|
+
const selectedCellPositions = this.getSelectedCellPositions();
|
|
11777
|
+
const cells = selectedCellPositions;
|
|
11744
11778
|
const cols = uniq(map(cells, 'col')).valueOf();
|
|
11745
|
-
const pos = this.
|
|
11779
|
+
const pos = createTablePosition(this.editor);
|
|
11746
11780
|
const result = [];
|
|
11747
11781
|
this.dangerousColumnsIndex = cols;
|
|
11748
11782
|
this.isSelectedTable = cols.length === pos.getWidth();
|
|
@@ -11761,21 +11795,22 @@ class TableStore {
|
|
|
11761
11795
|
}
|
|
11762
11796
|
setDangerousTable() {
|
|
11763
11797
|
this.isSelectedTable = true;
|
|
11764
|
-
const pos = this.
|
|
11765
|
-
const cells =
|
|
11798
|
+
const pos = createTablePosition(this.editor);
|
|
11799
|
+
const cells = getCellPositionsFromRange(0, 0, pos.getHeight(), pos.getWidth());
|
|
11766
11800
|
this.dangerousRowsIndex = [...Array(pos.getHeight())].map((_, i) => i);
|
|
11767
11801
|
this.dangerousColumnsIndex = [...Array(pos.getWidth())].map((_, i) => i);
|
|
11768
11802
|
this.dangerousCells$.next(cells);
|
|
11769
11803
|
}
|
|
11770
11804
|
selectFirstCell() {
|
|
11771
|
-
const
|
|
11772
|
-
const
|
|
11805
|
+
const selectedCellPositions = this.getSelectedCellPositions();
|
|
11806
|
+
const { row, col } = selectedCellPositions[0];
|
|
11807
|
+
const tablePath = getTablePath(this.editor);
|
|
11773
11808
|
const path = Editor.start(this.editor, [...tablePath, row, col]);
|
|
11774
11809
|
Transforms.select(this.editor, path);
|
|
11775
11810
|
}
|
|
11776
11811
|
setSelectedCellsBackgroundColor(backgroundColor) {
|
|
11777
|
-
const
|
|
11778
|
-
const
|
|
11812
|
+
const tablePath = getTablePath(this.editor);
|
|
11813
|
+
const cells = this.getSelectedCellPositions();
|
|
11779
11814
|
Editor.withoutNormalizing(this.editor, () => {
|
|
11780
11815
|
for (const { row, col } of cells) {
|
|
11781
11816
|
const cellPath = [...tablePath, row, col];
|
|
@@ -11783,16 +11818,9 @@ class TableStore {
|
|
|
11783
11818
|
}
|
|
11784
11819
|
});
|
|
11785
11820
|
}
|
|
11786
|
-
getSelectedCellBackgroundColor() {
|
|
11787
|
-
if (this.editor && this.editor.selection) {
|
|
11788
|
-
const { cell } = this.createTablePosition();
|
|
11789
|
-
return cell && cell.backgroundColor;
|
|
11790
|
-
}
|
|
11791
|
-
return '';
|
|
11792
|
-
}
|
|
11793
11821
|
clearSelectedCellsContent() {
|
|
11794
|
-
const cells = this.
|
|
11795
|
-
const tablePosition = this.
|
|
11822
|
+
const cells = this.getSelectedCellPositions();
|
|
11823
|
+
const tablePosition = createTablePosition(this.editor);
|
|
11796
11824
|
if (tablePosition.isInTable()) {
|
|
11797
11825
|
Editor.withoutNormalizing(this.editor, () => {
|
|
11798
11826
|
for (const { row, col } of cells) {
|
|
@@ -11804,12 +11832,9 @@ class TableStore {
|
|
|
11804
11832
|
Transforms.select(this.editor, Editor.start(this.editor, tablePosition.cellEntry[1]));
|
|
11805
11833
|
}
|
|
11806
11834
|
}
|
|
11807
|
-
mergeCell(editor) {
|
|
11808
|
-
mergeCell(editor, this.selectedCellPositions);
|
|
11809
|
-
}
|
|
11810
11835
|
setTableOptions(editor, newOptions) {
|
|
11811
|
-
const tablePosition =
|
|
11812
|
-
const tablePath = this.
|
|
11836
|
+
const tablePosition = createTablePosition(editor);
|
|
11837
|
+
const tablePath = getTablePath(this.editor);
|
|
11813
11838
|
const table = tablePosition.table;
|
|
11814
11839
|
const options = Object.assign(Object.assign({}, table.options), newOptions);
|
|
11815
11840
|
Transforms.setNodes(editor, { options }, { at: tablePath });
|
|
@@ -11821,7 +11846,7 @@ class TableStore {
|
|
|
11821
11846
|
removeColumnOrRows(selectedRowIndexs = this.selectedRowsIndex, selectedColumnIndexs = this.selectedColumnsIndex) {
|
|
11822
11847
|
var _a;
|
|
11823
11848
|
const { isSelectedTable } = this;
|
|
11824
|
-
const tablePosition = this.
|
|
11849
|
+
const tablePosition = createTablePosition(this.editor);
|
|
11825
11850
|
if (isSelectedTable) {
|
|
11826
11851
|
TableEditor.removeTable(this.editor);
|
|
11827
11852
|
return;
|
|
@@ -11872,7 +11897,8 @@ class TheTableContextMenuService {
|
|
|
11872
11897
|
return this.tableStore && this.tableStore.editor;
|
|
11873
11898
|
}
|
|
11874
11899
|
get backgroundColor() {
|
|
11875
|
-
|
|
11900
|
+
const cell = getSelectedCell(this.editor);
|
|
11901
|
+
return cell ? cell.backgroundColor : '';
|
|
11876
11902
|
}
|
|
11877
11903
|
constructor(colorSelectService, tableStore, thyPopover, ngZone, theContextService) {
|
|
11878
11904
|
this.colorSelectService = colorSelectService;
|
|
@@ -11989,7 +12015,7 @@ class TheTableContextMenuService {
|
|
|
11989
12015
|
name: '合并单元格',
|
|
11990
12016
|
visibility: true,
|
|
11991
12017
|
actionHandle: () => {
|
|
11992
|
-
this.tableStore.
|
|
12018
|
+
mergeCell(this.editor, this.tableStore.getSelectedCellPositions());
|
|
11993
12019
|
}
|
|
11994
12020
|
},
|
|
11995
12021
|
{
|
|
@@ -12048,7 +12074,7 @@ class TheTableContextMenuService {
|
|
|
12048
12074
|
];
|
|
12049
12075
|
}
|
|
12050
12076
|
getSelectedCell() {
|
|
12051
|
-
const selectedCellPositions = this.tableStore.
|
|
12077
|
+
const selectedCellPositions = this.tableStore.getSelectedCellPositions();
|
|
12052
12078
|
const selectCellNodes = getSelectCellNode(this.editor, selectedCellPositions);
|
|
12053
12079
|
sortCell(selectCellNodes);
|
|
12054
12080
|
const leftCellDict = getLeftCellDict(selectCellNodes);
|
|
@@ -12064,14 +12090,15 @@ class TheTableContextMenuService {
|
|
|
12064
12090
|
}
|
|
12065
12091
|
openMenuList(event) {
|
|
12066
12092
|
this.ngZone.run(() => {
|
|
12067
|
-
const {
|
|
12093
|
+
const { isFullscreen, selectedRowsIndex, selectedColumnsIndex, isSelectedTable } = this.tableStore;
|
|
12094
|
+
const selectedCellPositions = this.tableStore.getSelectedCellPositions();
|
|
12068
12095
|
const tableInfo = { selectedCellPositions, isFullscreen, selectedRowsIndex, selectedColumnsIndex, isSelectedTable };
|
|
12069
12096
|
const { row, col } = this.getSelectedCell();
|
|
12070
12097
|
setCellMenuVisibility(this.editor, this.menuEntities, tableInfo);
|
|
12071
12098
|
this.menuEntities.forEach(item => {
|
|
12072
12099
|
switch (item.key) {
|
|
12073
12100
|
case 'background-color':
|
|
12074
|
-
item.backgroundColor = this.
|
|
12101
|
+
item.backgroundColor = this.backgroundColor;
|
|
12075
12102
|
break;
|
|
12076
12103
|
case TableInsertType.insertRowsUp:
|
|
12077
12104
|
case TableInsertType.insertRowsDown:
|
|
@@ -12140,9 +12167,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImpor
|
|
|
12140
12167
|
}], ctorParameters: function () { return [{ type: TheColorSelectService }, { type: TableStore }, { type: i1$1.ThyPopover }, { type: i0.NgZone }, { type: TheContextService }]; } });
|
|
12141
12168
|
|
|
12142
12169
|
class TheTableOptionsComponent {
|
|
12143
|
-
get table() {
|
|
12144
|
-
return this.tableStore && this.tableStore.getTableEntry()[0];
|
|
12145
|
-
}
|
|
12146
12170
|
constructor(popoverRef) {
|
|
12147
12171
|
this.popoverRef = popoverRef;
|
|
12148
12172
|
this.tableDropdownList = [
|
|
@@ -12163,6 +12187,9 @@ class TheTableOptionsComponent {
|
|
|
12163
12187
|
ngOnInit() {
|
|
12164
12188
|
this.setColumnOptions();
|
|
12165
12189
|
}
|
|
12190
|
+
get table() {
|
|
12191
|
+
return getTable(this.editor);
|
|
12192
|
+
}
|
|
12166
12193
|
setColumnOptions() {
|
|
12167
12194
|
this.tableDropdownList.forEach(item => {
|
|
12168
12195
|
const tableComponent = ELEMENT_TO_COMPONENT.get(this.table);
|
|
@@ -12250,7 +12277,7 @@ class TheTableToolbarComponent {
|
|
|
12250
12277
|
actionHandle: () => {
|
|
12251
12278
|
event.preventDefault();
|
|
12252
12279
|
event.stopPropagation();
|
|
12253
|
-
this.tableStore.
|
|
12280
|
+
mergeCell(this.editor, this.tableStore.getSelectedCellPositions());
|
|
12254
12281
|
this.popoverRef.close();
|
|
12255
12282
|
this.tableStore.clearSelectedCells();
|
|
12256
12283
|
}
|
|
@@ -12273,12 +12300,13 @@ class TheTableToolbarComponent {
|
|
|
12273
12300
|
ngOnInit() {
|
|
12274
12301
|
var _a, _b, _c;
|
|
12275
12302
|
this.isColumnEqual = (_c = (_b = (_a = this.tableElement) === null || _a === void 0 ? void 0 : _a.columns) === null || _b === void 0 ? void 0 : _b.every(col => this.tableElement.columns[0].width === col.width)) !== null && _c !== void 0 ? _c : true;
|
|
12276
|
-
const
|
|
12277
|
-
const tableInfo = { selectedCellPositions, isSelectedTable };
|
|
12303
|
+
const selectedCellPositions = this.tableStore.getSelectedCellPositions();
|
|
12304
|
+
const tableInfo = { selectedCellPositions, isSelectedTable: this.tableStore.isSelectedTable };
|
|
12278
12305
|
this.isRectangle = isRectangularInTableCells(this.editor, selectedCellPositions);
|
|
12279
12306
|
this.setDeleteIcon();
|
|
12280
12307
|
setCellMenuVisibility(this.editor, this.cellMenuList, tableInfo);
|
|
12281
|
-
|
|
12308
|
+
const cell = getSelectedCell(this.editor);
|
|
12309
|
+
this.selectedColor = cell ? cell.backgroundColor : '';
|
|
12282
12310
|
const path = TheEditor.findPath(this.editor, this.tableElement);
|
|
12283
12311
|
this.tableChangeSubscriber = this.tableStore.tableChange().subscribe(() => {
|
|
12284
12312
|
var _a;
|
|
@@ -12292,8 +12320,9 @@ class TheTableToolbarComponent {
|
|
|
12292
12320
|
this.colorSelectService.closeColorSelect();
|
|
12293
12321
|
}
|
|
12294
12322
|
setDeleteIcon() {
|
|
12295
|
-
const {
|
|
12296
|
-
const
|
|
12323
|
+
const { selectedRowsIndex, selectedColumnsIndex } = this.tableStore;
|
|
12324
|
+
const selectedCellPositions = this.tableStore.getSelectedCellPositions();
|
|
12325
|
+
const pos = createTablePosition(this.editor);
|
|
12297
12326
|
if (this.tableStore.selectedRowsIndex.length > 0) {
|
|
12298
12327
|
this.deleteIcon = DeleteIcon['table-delete-rows'];
|
|
12299
12328
|
this.iconName = '删除整行';
|
|
@@ -12571,9 +12600,13 @@ const getGridColumns = (headerRow, cellsWidth) => {
|
|
|
12571
12600
|
});
|
|
12572
12601
|
return result;
|
|
12573
12602
|
};
|
|
12574
|
-
const getColumnsWidth = (cellRow) => {
|
|
12603
|
+
const getColumnsWidth = (cellRow, isColgroup = false) => {
|
|
12575
12604
|
const result = [];
|
|
12576
12605
|
cellRow.childNodes.forEach((item) => {
|
|
12606
|
+
if (isColgroup && IS_SAFARI) {
|
|
12607
|
+
result.push(item.offsetWidth);
|
|
12608
|
+
return;
|
|
12609
|
+
}
|
|
12577
12610
|
if (item.getBoundingClientRect) {
|
|
12578
12611
|
result.push(item.getBoundingClientRect().width);
|
|
12579
12612
|
}
|
|
@@ -12581,6 +12614,113 @@ const getColumnsWidth = (cellRow) => {
|
|
|
12581
12614
|
return result;
|
|
12582
12615
|
};
|
|
12583
12616
|
|
|
12617
|
+
/**
|
|
12618
|
+
* 计算最小行跨距单元格
|
|
12619
|
+
* @param element TableElement
|
|
12620
|
+
* @returns
|
|
12621
|
+
*/
|
|
12622
|
+
const calculateMinRowSpanCellForRows = (element) => {
|
|
12623
|
+
const cells = element.children.map((row, index) => {
|
|
12624
|
+
const noHiddenCells = row.children.filter(cell => !cell.hidden);
|
|
12625
|
+
if (noHiddenCells.length > 0) {
|
|
12626
|
+
const minRowspan = Math.min.apply(Math, noHiddenCells.map(cell => {
|
|
12627
|
+
return cell.rowspan || 1;
|
|
12628
|
+
}));
|
|
12629
|
+
const cell = row.children.find(item => !item.hidden && (item.rowspan || 1) === minRowspan);
|
|
12630
|
+
return {
|
|
12631
|
+
cell,
|
|
12632
|
+
rowIndex: index
|
|
12633
|
+
};
|
|
12634
|
+
}
|
|
12635
|
+
else {
|
|
12636
|
+
return {
|
|
12637
|
+
rowIndex: index
|
|
12638
|
+
};
|
|
12639
|
+
}
|
|
12640
|
+
});
|
|
12641
|
+
return cells;
|
|
12642
|
+
};
|
|
12643
|
+
/**
|
|
12644
|
+
* 计算行控件的平均高度
|
|
12645
|
+
* @param previousCombineRowIndex
|
|
12646
|
+
* @param previousRowIndex
|
|
12647
|
+
* @param rowControls
|
|
12648
|
+
*/
|
|
12649
|
+
const calculateRowControlsAvgHeight = (previousCombineRowIndex, previousRowIndex, rowControls) => {
|
|
12650
|
+
const rowControl = rowControls[previousRowIndex];
|
|
12651
|
+
const count = previousCombineRowIndex - previousRowIndex;
|
|
12652
|
+
const avgHeight = Math.floor(rowControl.height / (count + 1));
|
|
12653
|
+
const firstHeight = rowControl.height - avgHeight * count;
|
|
12654
|
+
rowControl.height = firstHeight;
|
|
12655
|
+
rowControls
|
|
12656
|
+
.filter((_, index) => index > previousRowIndex && index <= previousCombineRowIndex)
|
|
12657
|
+
.forEach(rowControl => {
|
|
12658
|
+
rowControl.height = avgHeight;
|
|
12659
|
+
});
|
|
12660
|
+
};
|
|
12661
|
+
const getBelowRowHeight = (editor, cells, index, rowIndex, rowspan) => {
|
|
12662
|
+
let belowRowlHeight = 0;
|
|
12663
|
+
cells.slice(index + 1, cells.length).map(item => {
|
|
12664
|
+
if (!item.cell) {
|
|
12665
|
+
return;
|
|
12666
|
+
}
|
|
12667
|
+
if (rowIndex + rowspan > item.rowIndex) {
|
|
12668
|
+
const cellDom = AngularEditor.toDOMNode(editor, item.cell);
|
|
12669
|
+
if (item.cell.rowspan > 1) {
|
|
12670
|
+
// 如果下方单元格的rowspan > 1,递归计算
|
|
12671
|
+
const height = getBelowRowHeight(editor, cells, cells.findIndex(cell => cell.rowIndex === item.rowIndex), item.rowIndex, item.cell.rowspan);
|
|
12672
|
+
belowRowlHeight += getElementHeight(cellDom) - height;
|
|
12673
|
+
}
|
|
12674
|
+
else {
|
|
12675
|
+
belowRowlHeight += getElementHeight(cellDom);
|
|
12676
|
+
}
|
|
12677
|
+
}
|
|
12678
|
+
});
|
|
12679
|
+
return belowRowlHeight;
|
|
12680
|
+
};
|
|
12681
|
+
const calculateRowControls = (editor, element) => {
|
|
12682
|
+
const minRowSpanCellForRows = calculateMinRowSpanCellForRows(element);
|
|
12683
|
+
const rowControls = [];
|
|
12684
|
+
let previousRowIndex = 0;
|
|
12685
|
+
let previousCombineRowIndex = 0;
|
|
12686
|
+
minRowSpanCellForRows.forEach((cellInfo, index) => {
|
|
12687
|
+
if (!cellInfo.cell) {
|
|
12688
|
+
rowControls.push({
|
|
12689
|
+
height: 0,
|
|
12690
|
+
rowIndex: index
|
|
12691
|
+
});
|
|
12692
|
+
previousCombineRowIndex = index;
|
|
12693
|
+
if (index === minRowSpanCellForRows.length - 1) {
|
|
12694
|
+
calculateRowControlsAvgHeight(previousCombineRowIndex, previousRowIndex, rowControls);
|
|
12695
|
+
}
|
|
12696
|
+
return;
|
|
12697
|
+
}
|
|
12698
|
+
// calculate combine row height
|
|
12699
|
+
if (previousCombineRowIndex > previousRowIndex) {
|
|
12700
|
+
calculateRowControlsAvgHeight(previousCombineRowIndex, previousRowIndex, rowControls);
|
|
12701
|
+
previousCombineRowIndex = 0;
|
|
12702
|
+
}
|
|
12703
|
+
const cellDom = AngularEditor.toDOMNode(editor, cellInfo.cell);
|
|
12704
|
+
let height = getElementHeight(cellDom);
|
|
12705
|
+
// 当cell为合并的单元格(rowspan > 1),计算其实际高度(当前单元格的高度 - 下方合并单元格的高度)
|
|
12706
|
+
if (cellInfo.cell.rowspan > 1) {
|
|
12707
|
+
const calcHeight = height - getBelowRowHeight(editor, minRowSpanCellForRows, index, cellInfo.rowIndex, cellInfo.cell.rowspan);
|
|
12708
|
+
rowControls.push({
|
|
12709
|
+
height: calcHeight,
|
|
12710
|
+
rowIndex: cellInfo.rowIndex
|
|
12711
|
+
});
|
|
12712
|
+
}
|
|
12713
|
+
else {
|
|
12714
|
+
rowControls.push({
|
|
12715
|
+
height,
|
|
12716
|
+
rowIndex: cellInfo.rowIndex
|
|
12717
|
+
});
|
|
12718
|
+
}
|
|
12719
|
+
previousRowIndex = index;
|
|
12720
|
+
});
|
|
12721
|
+
return rowControls;
|
|
12722
|
+
};
|
|
12723
|
+
|
|
12584
12724
|
const TABLE_SELECTOR = '.the-table';
|
|
12585
12725
|
const TABLE_WRAPPER_SELECTOR = '.the-table-wrapper';
|
|
12586
12726
|
const RESIZE_OVERLAY_SELECTOR = '.the-table-resize-overlay-thumb';
|
|
@@ -12678,19 +12818,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImpor
|
|
|
12678
12818
|
} });
|
|
12679
12819
|
|
|
12680
12820
|
class TheInsertMarkComponent {
|
|
12681
|
-
get disabled() {
|
|
12682
|
-
return this.tableStore && !!this.tableStore.selectedCellPositions.length;
|
|
12683
|
-
}
|
|
12684
12821
|
get editor() {
|
|
12685
12822
|
return this.tableStore && this.tableStore.editor;
|
|
12686
12823
|
}
|
|
12687
12824
|
constructor(cdr, renderer2) {
|
|
12688
12825
|
this.cdr = cdr;
|
|
12689
12826
|
this.renderer2 = renderer2;
|
|
12827
|
+
this.destroy$ = new Subject();
|
|
12690
12828
|
this.tooltipContent = '';
|
|
12829
|
+
this.disabled = false;
|
|
12691
12830
|
}
|
|
12692
12831
|
ngOnInit() {
|
|
12693
12832
|
this.tooltipContent = this.type === 'row' ? '插入行' : '插入列';
|
|
12833
|
+
this.tableStore
|
|
12834
|
+
.selectedCellsChange()
|
|
12835
|
+
.pipe(takeUntil(this.destroy$))
|
|
12836
|
+
.subscribe(selectedCellPositions => {
|
|
12837
|
+
this.disabled = !!selectedCellPositions.length;
|
|
12838
|
+
});
|
|
12839
|
+
}
|
|
12840
|
+
ngOnDestroy() {
|
|
12841
|
+
var _a, _b;
|
|
12842
|
+
(_a = this.destroy$) === null || _a === void 0 ? void 0 : _a.next();
|
|
12843
|
+
(_b = this.destroy$) === null || _b === void 0 ? void 0 : _b.complete();
|
|
12694
12844
|
}
|
|
12695
12845
|
onMouseDown(event) {
|
|
12696
12846
|
event.preventDefault();
|
|
@@ -12726,7 +12876,7 @@ class TheInsertMarkComponent {
|
|
|
12726
12876
|
getLength() {
|
|
12727
12877
|
const { selection } = this.editor;
|
|
12728
12878
|
if (selection && Range.isCollapsed(selection)) {
|
|
12729
|
-
const { table } =
|
|
12879
|
+
const { table } = createTablePosition(this.editor, selection.anchor.path);
|
|
12730
12880
|
if (!table) {
|
|
12731
12881
|
return;
|
|
12732
12882
|
}
|
|
@@ -12787,7 +12937,7 @@ class TheTableComponent extends TheBaseElementComponent {
|
|
|
12787
12937
|
if (this.initialized) {
|
|
12788
12938
|
Promise.resolve().then(() => {
|
|
12789
12939
|
this.tableStore.emitTableChange();
|
|
12790
|
-
this.tableStore.
|
|
12940
|
+
this.tableStore.setSelectedColumnsAndRowIndex();
|
|
12791
12941
|
this.bindTableScrollingShadow();
|
|
12792
12942
|
this.useRowControls();
|
|
12793
12943
|
this.setHeaderCellStyle();
|
|
@@ -12856,7 +13006,7 @@ class TheTableComponent extends TheBaseElementComponent {
|
|
|
12856
13006
|
.selectedCellsChange()
|
|
12857
13007
|
.pipe(takeUntil(this.destroy$))
|
|
12858
13008
|
.subscribe(() => {
|
|
12859
|
-
this.isSelectedAllCell = this.tableStore.
|
|
13009
|
+
this.isSelectedAllCell = isSelectedAllCell(this.editor, this.tableStore.getSelectedCellPositions());
|
|
12860
13010
|
});
|
|
12861
13011
|
}
|
|
12862
13012
|
getWrapperWidth() {
|
|
@@ -12955,7 +13105,7 @@ class TheTableComponent extends TheBaseElementComponent {
|
|
|
12955
13105
|
}
|
|
12956
13106
|
calcHeaderRowShadow() {
|
|
12957
13107
|
var _a;
|
|
12958
|
-
const headerRowHeight = (_a = this.
|
|
13108
|
+
const headerRowHeight = (_a = calculateRowControls(this.editor, this.element)[0]) === null || _a === void 0 ? void 0 : _a.height;
|
|
12959
13109
|
let height = headerRowHeight;
|
|
12960
13110
|
// 默认(没有聚焦)的 top 值:滚动容器高度 + 表格的padding(8)
|
|
12961
13111
|
let top = this.scrollContainerTop + TABLE_PADDING$1;
|
|
@@ -12981,7 +13131,7 @@ class TheTableComponent extends TheBaseElementComponent {
|
|
|
12981
13131
|
this.scrollContainerTop = event.target.getBoundingClientRect().top;
|
|
12982
13132
|
const clientRect = this.theTableElement.nativeElement.getBoundingClientRect();
|
|
12983
13133
|
const headerTopHeight = this.isInTable ? -19 : 11;
|
|
12984
|
-
const headerRowHeight = (_a = this.
|
|
13134
|
+
const headerRowHeight = (_a = calculateRowControls(this.editor, this.element)[0]) === null || _a === void 0 ? void 0 : _a.height;
|
|
12985
13135
|
const top = clientRect.top + headerTopHeight;
|
|
12986
13136
|
this.isStickyTop =
|
|
12987
13137
|
top <= this.scrollContainerTop + 8 &&
|
|
@@ -13063,7 +13213,9 @@ class TheTableComponent extends TheBaseElementComponent {
|
|
|
13063
13213
|
const colControl = this.columnControlsWrapper.nativeElement;
|
|
13064
13214
|
if (this.freezeRowPipe.transform(this.element, this.headerRow, this.tablePluginOptions)) {
|
|
13065
13215
|
const headerRow = this.tbodyElement.nativeElement.childNodes[0];
|
|
13066
|
-
const cellsWidth = ((_a = this.colgroup) === null || _a === void 0 ? void 0 : _a.nativeElement)
|
|
13216
|
+
const cellsWidth = ((_a = this.colgroup) === null || _a === void 0 ? void 0 : _a.nativeElement)
|
|
13217
|
+
? getColumnsWidth(this.colgroup.nativeElement, true)
|
|
13218
|
+
: this.getDefaultCellWidth();
|
|
13067
13219
|
const gridColumns = getGridColumns(headerRow, cellsWidth);
|
|
13068
13220
|
const tablePadding = 44;
|
|
13069
13221
|
let tableWidth = this.elementRef.nativeElement.getBoundingClientRect().width;
|
|
@@ -13081,7 +13233,7 @@ class TheTableComponent extends TheBaseElementComponent {
|
|
|
13081
13233
|
const headerRow = this.nativeElement.querySelector('tbody tr');
|
|
13082
13234
|
const rowControlInner = this.rowControlsInner.nativeElement;
|
|
13083
13235
|
const tableCornerBtn = this.cornerControl.nativeElement;
|
|
13084
|
-
const headerRowHeight = (_a = this.
|
|
13236
|
+
const headerRowHeight = (_a = calculateRowControls(this.editor, this.element)[0]) === null || _a === void 0 ? void 0 : _a.height;
|
|
13085
13237
|
const numberedColumn = (_b = this.element.options) === null || _b === void 0 ? void 0 : _b.numberedColumn;
|
|
13086
13238
|
if (this.isStickyTop) {
|
|
13087
13239
|
this.renderer.addClass(this.nativeElement, TableWithStickyRowClass);
|
|
@@ -13180,107 +13332,12 @@ class TheTableComponent extends TheBaseElementComponent {
|
|
|
13180
13332
|
useRowControls() {
|
|
13181
13333
|
var _a;
|
|
13182
13334
|
if ((this.selection && !this.readonly) || ((_a = this.element.options) === null || _a === void 0 ? void 0 : _a.numberedColumn) || this.tableStore.isRightClicking) {
|
|
13183
|
-
this.rowControls = this.
|
|
13335
|
+
this.rowControls = calculateRowControls(this.editor, this.element);
|
|
13184
13336
|
}
|
|
13185
13337
|
}
|
|
13186
13338
|
detectChanges() {
|
|
13187
13339
|
this.cdr.detectChanges();
|
|
13188
13340
|
}
|
|
13189
|
-
calculateMinRowSpanCellForRows() {
|
|
13190
|
-
const cells = this.element.children.map((row, index) => {
|
|
13191
|
-
const noHiddenCells = row.children.filter(cell => !cell.hidden);
|
|
13192
|
-
if (noHiddenCells.length > 0) {
|
|
13193
|
-
const minRowspan = Math.min.apply(Math, noHiddenCells.map(cell => {
|
|
13194
|
-
return cell.rowspan || 1;
|
|
13195
|
-
}));
|
|
13196
|
-
const cell = row.children.find(item => !item.hidden && (item.rowspan || 1) === minRowspan);
|
|
13197
|
-
return {
|
|
13198
|
-
cell,
|
|
13199
|
-
rowIndex: index
|
|
13200
|
-
};
|
|
13201
|
-
}
|
|
13202
|
-
else {
|
|
13203
|
-
return {
|
|
13204
|
-
rowIndex: index
|
|
13205
|
-
};
|
|
13206
|
-
}
|
|
13207
|
-
});
|
|
13208
|
-
return cells;
|
|
13209
|
-
}
|
|
13210
|
-
calculateRowControls() {
|
|
13211
|
-
const minRowSpanCellForRows = this.calculateMinRowSpanCellForRows();
|
|
13212
|
-
const rowControls = [];
|
|
13213
|
-
let previousRowIndex = 0;
|
|
13214
|
-
let previousCombineRowIndex = 0;
|
|
13215
|
-
minRowSpanCellForRows.forEach((cellInfo, index) => {
|
|
13216
|
-
if (!cellInfo.cell) {
|
|
13217
|
-
rowControls.push({
|
|
13218
|
-
height: 0,
|
|
13219
|
-
rowIndex: index
|
|
13220
|
-
});
|
|
13221
|
-
previousCombineRowIndex = index;
|
|
13222
|
-
if (index === minRowSpanCellForRows.length - 1) {
|
|
13223
|
-
this.calculateRowControlsAvgHeight(previousCombineRowIndex, previousRowIndex, rowControls);
|
|
13224
|
-
}
|
|
13225
|
-
return;
|
|
13226
|
-
}
|
|
13227
|
-
// calculate combine row height
|
|
13228
|
-
if (previousCombineRowIndex > previousRowIndex) {
|
|
13229
|
-
this.calculateRowControlsAvgHeight(previousCombineRowIndex, previousRowIndex, rowControls);
|
|
13230
|
-
previousCombineRowIndex = 0;
|
|
13231
|
-
}
|
|
13232
|
-
const cellDom = AngularEditor.toDOMNode(this.editor, cellInfo.cell);
|
|
13233
|
-
let height = getElementHeight(cellDom);
|
|
13234
|
-
// 当cell为合并的单元格(rowspan > 1),计算其实际高度(当前单元格的高度 - 下方合并单元格的高度)
|
|
13235
|
-
if (cellInfo.cell.rowspan > 1) {
|
|
13236
|
-
const calcHeight = height - this.getBelowRowHeight(minRowSpanCellForRows, index, cellInfo.rowIndex, cellInfo.cell.rowspan);
|
|
13237
|
-
rowControls.push({
|
|
13238
|
-
height: calcHeight,
|
|
13239
|
-
rowIndex: cellInfo.rowIndex
|
|
13240
|
-
});
|
|
13241
|
-
}
|
|
13242
|
-
else {
|
|
13243
|
-
rowControls.push({
|
|
13244
|
-
height,
|
|
13245
|
-
rowIndex: cellInfo.rowIndex
|
|
13246
|
-
});
|
|
13247
|
-
}
|
|
13248
|
-
previousRowIndex = index;
|
|
13249
|
-
});
|
|
13250
|
-
return rowControls;
|
|
13251
|
-
}
|
|
13252
|
-
calculateRowControlsAvgHeight(previousCombineRowIndex, previousRowIndex, rowControls) {
|
|
13253
|
-
const rowControl = rowControls[previousRowIndex];
|
|
13254
|
-
const count = previousCombineRowIndex - previousRowIndex;
|
|
13255
|
-
const avgHeight = Math.floor(rowControl.height / (count + 1));
|
|
13256
|
-
const firstHeight = rowControl.height - avgHeight * count;
|
|
13257
|
-
rowControl.height = firstHeight;
|
|
13258
|
-
rowControls
|
|
13259
|
-
.filter((item, _index) => _index > previousRowIndex && _index <= previousCombineRowIndex)
|
|
13260
|
-
.forEach(rowControl => {
|
|
13261
|
-
rowControl.height = avgHeight;
|
|
13262
|
-
});
|
|
13263
|
-
}
|
|
13264
|
-
getBelowRowHeight(cells, index, rowIndex, rowspan) {
|
|
13265
|
-
let belowRowlHeight = 0;
|
|
13266
|
-
cells.slice(index + 1, cells.length).map(item => {
|
|
13267
|
-
if (!item.cell) {
|
|
13268
|
-
return;
|
|
13269
|
-
}
|
|
13270
|
-
if (rowIndex + rowspan > item.rowIndex) {
|
|
13271
|
-
const cellDom = AngularEditor.toDOMNode(this.editor, item.cell);
|
|
13272
|
-
if (item.cell.rowspan > 1) {
|
|
13273
|
-
// 如果下方单元格的rowspan > 1,递归计算
|
|
13274
|
-
const height = this.getBelowRowHeight(cells, cells.findIndex(cell => cell.rowIndex === item.rowIndex), item.rowIndex, item.cell.rowspan);
|
|
13275
|
-
belowRowlHeight += getElementHeight(cellDom) - height;
|
|
13276
|
-
}
|
|
13277
|
-
else {
|
|
13278
|
-
belowRowlHeight += getElementHeight(cellDom);
|
|
13279
|
-
}
|
|
13280
|
-
}
|
|
13281
|
-
});
|
|
13282
|
-
return belowRowlHeight;
|
|
13283
|
-
}
|
|
13284
13341
|
resolveImage() {
|
|
13285
13342
|
const imageElements = this.nativeElement.querySelectorAll('img');
|
|
13286
13343
|
if (imageElements.length) {
|
|
@@ -13310,8 +13367,8 @@ class TheTableComponent extends TheBaseElementComponent {
|
|
|
13310
13367
|
if (this.selection && !this.readonly) {
|
|
13311
13368
|
const opts = new TableOptions();
|
|
13312
13369
|
const selection = this.editor.selection;
|
|
13313
|
-
const startPosition =
|
|
13314
|
-
const endPosition =
|
|
13370
|
+
const startPosition = createTablePosition(this.editor);
|
|
13371
|
+
const endPosition = createTablePosition(this.editor, selection.focus.path);
|
|
13315
13372
|
this.isInTable = startPosition.isInTable() && endPosition.isInTable();
|
|
13316
13373
|
}
|
|
13317
13374
|
else {
|
|
@@ -13457,8 +13514,8 @@ class TheTableComponent extends TheBaseElementComponent {
|
|
|
13457
13514
|
return !isVirtualKey(e) && !this.theTableContextMenuService.isOpened;
|
|
13458
13515
|
})))
|
|
13459
13516
|
.pipe(filter(() => {
|
|
13460
|
-
|
|
13461
|
-
return (
|
|
13517
|
+
const selectedCellPositions = this.tableStore.getSelectedCellPositions();
|
|
13518
|
+
return (selectedCellPositions === null || selectedCellPositions === void 0 ? void 0 : selectedCellPositions.length) > 0;
|
|
13462
13519
|
}), takeUntil(this.destroy$))
|
|
13463
13520
|
.subscribe((e) => {
|
|
13464
13521
|
if (e.type === 'keydown') {
|
|
@@ -13644,7 +13701,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImpor
|
|
|
13644
13701
|
*/
|
|
13645
13702
|
function clearTableNode(opts, editor, isTopToBot) {
|
|
13646
13703
|
const { selection } = editor;
|
|
13647
|
-
const element =
|
|
13704
|
+
const element = createTablePosition(editor, selection.focus.path);
|
|
13648
13705
|
const rowIndex = element.getRowIndex();
|
|
13649
13706
|
const colIndex = element.getColumnIndex();
|
|
13650
13707
|
const removeRow = isTopToBot ? 0 : rowIndex + 1;
|
|
@@ -13695,9 +13752,8 @@ class TheTableRowComponent extends TheBaseElementComponent {
|
|
|
13695
13752
|
}
|
|
13696
13753
|
onContextChange() {
|
|
13697
13754
|
super.onContextChange();
|
|
13698
|
-
const opts = new TableOptions();
|
|
13699
13755
|
const path = TheEditor.findPath(this.editor, this.element);
|
|
13700
|
-
const tablePosition =
|
|
13756
|
+
const tablePosition = createTablePosition(this.editor, path.concat(0));
|
|
13701
13757
|
const rowIndex = tablePosition.getRowIndex();
|
|
13702
13758
|
if (rowIndex === 0) {
|
|
13703
13759
|
this.renderer.addClass(this.elementRef.nativeElement, 'the-sticky-row');
|
|
@@ -14253,10 +14309,9 @@ class TheTdComponent extends TheBaseElementComponent {
|
|
|
14253
14309
|
useElementStyle(this.elementRef.nativeElement, this.element);
|
|
14254
14310
|
}
|
|
14255
14311
|
useTablePosition() {
|
|
14256
|
-
const opts = new TableOptions();
|
|
14257
14312
|
const path = TheEditor.findPath(this.editor, this.element);
|
|
14258
14313
|
// must be path of cell's children
|
|
14259
|
-
this.tablePosition =
|
|
14314
|
+
this.tablePosition = createTablePosition(this.editor, path.concat(0));
|
|
14260
14315
|
}
|
|
14261
14316
|
useBackground() {
|
|
14262
14317
|
if (this.element.backgroundColor !== this.backgroundColor) {
|
|
@@ -14911,7 +14966,7 @@ const withTable = (editor) => {
|
|
|
14911
14966
|
const [, startBlockPath] = Editor.above(editor, {
|
|
14912
14967
|
match: n => Editor.isBlock(editor, n)
|
|
14913
14968
|
});
|
|
14914
|
-
const startPosition =
|
|
14969
|
+
const startPosition = createTablePosition(editor);
|
|
14915
14970
|
if (startBlockPath.length <= startPosition.cellEntry[1].length + 1 &&
|
|
14916
14971
|
startBlockPath.pop() === 0 &&
|
|
14917
14972
|
selection.anchor.offset === 0 &&
|
|
@@ -14925,8 +14980,8 @@ const withTable = (editor) => {
|
|
|
14925
14980
|
const opts = new TableOptions();
|
|
14926
14981
|
const afterPoint = Editor.after(editor, editor.selection);
|
|
14927
14982
|
if (afterPoint && isRangeInTable(opts, editor, { anchor: afterPoint, focus: afterPoint })) {
|
|
14928
|
-
const beforePosition =
|
|
14929
|
-
const afterPosition =
|
|
14983
|
+
const beforePosition = createTablePosition(editor);
|
|
14984
|
+
const afterPosition = createTablePosition(editor, afterPoint.path);
|
|
14930
14985
|
if (beforePosition.cell && beforePosition.cell !== afterPosition.cell) {
|
|
14931
14986
|
return;
|
|
14932
14987
|
}
|
|
@@ -14962,8 +15017,8 @@ const withTable = (editor) => {
|
|
|
14962
15017
|
onKeydown(event);
|
|
14963
15018
|
return;
|
|
14964
15019
|
}
|
|
14965
|
-
const startPosition =
|
|
14966
|
-
const endPosition =
|
|
15020
|
+
const startPosition = createTablePosition(editor);
|
|
15021
|
+
const endPosition = createTablePosition(editor, selection.focus.path);
|
|
14967
15022
|
const isCollapsed = Range.isCollapsed(selection);
|
|
14968
15023
|
if (startPosition && endPosition && endPosition.isInTable()) {
|
|
14969
15024
|
// for keyboard up and down key in the table
|
|
@@ -15040,7 +15095,7 @@ const withTable = (editor) => {
|
|
|
15040
15095
|
}
|
|
15041
15096
|
if (isMoveBackward) {
|
|
15042
15097
|
const beforePoint = Editor.before(editor, editor.selection);
|
|
15043
|
-
const beforePosition = beforePoint &&
|
|
15098
|
+
const beforePosition = beforePoint && createTablePosition(editor, beforePoint.path);
|
|
15044
15099
|
if (beforePosition && beforePosition.cell && beforePosition.cell.hidden) {
|
|
15045
15100
|
event.preventDefault();
|
|
15046
15101
|
const at = Editor.end(editor, TheEditor.findPath(editor, beforePosition.findPrevious()));
|
|
@@ -15049,7 +15104,7 @@ const withTable = (editor) => {
|
|
|
15049
15104
|
}
|
|
15050
15105
|
if (isMoveForward) {
|
|
15051
15106
|
const afterPoint = Editor.after(editor, editor.selection);
|
|
15052
|
-
const afterPosition = afterPoint &&
|
|
15107
|
+
const afterPosition = afterPoint && createTablePosition(editor, afterPoint.path);
|
|
15053
15108
|
if (afterPosition.cell && afterPosition.cell.hidden) {
|
|
15054
15109
|
event.preventDefault();
|
|
15055
15110
|
const nextCell = afterPosition.findNext();
|
|
@@ -15098,10 +15153,9 @@ const withTable = (editor) => {
|
|
|
15098
15153
|
setFragmentData(unit);
|
|
15099
15154
|
return;
|
|
15100
15155
|
}
|
|
15101
|
-
const
|
|
15102
|
-
const tablePosition = TablePosition.create(opts, editor, selection.anchor.path);
|
|
15156
|
+
const tablePosition = createTablePosition(editor);
|
|
15103
15157
|
const tableComponent = ELEMENT_TO_COMPONENT.get(tablePosition.table);
|
|
15104
|
-
const selectedCellPositions = tableComponent.tableStore.
|
|
15158
|
+
const selectedCellPositions = tableComponent.tableStore.getSelectedCellPositions();
|
|
15105
15159
|
let tableFragment = null;
|
|
15106
15160
|
if (tableComponent.tableStore.selectedRowsIndex.length > 0) {
|
|
15107
15161
|
const rows = tablePosition.table.children.slice(tableComponent.tableStore.selectedRowsIndex[0], tableComponent.tableStore.selectedRowsIndex[tableComponent.tableStore.selectedRowsIndex.length - 1] + 1);
|
|
@@ -15150,7 +15204,7 @@ const withTable = (editor) => {
|
|
|
15150
15204
|
fragment.length === 1 &&
|
|
15151
15205
|
Element$1.isElement(fragment[0]) &&
|
|
15152
15206
|
fragment[0].type === ElementKinds.table) {
|
|
15153
|
-
const tablePosition =
|
|
15207
|
+
const tablePosition = createTablePosition(editor);
|
|
15154
15208
|
const clipboardTable = fragment[0].children;
|
|
15155
15209
|
const clipboardRow = clipboardTable[0].children;
|
|
15156
15210
|
const selectRowIndex = tablePosition.getRowIndex();
|
|
@@ -15292,7 +15346,7 @@ const withTable = (editor) => {
|
|
|
15292
15346
|
node.hidden) {
|
|
15293
15347
|
setTimeout(() => {
|
|
15294
15348
|
const opts = new TableOptions();
|
|
15295
|
-
const tablePosition =
|
|
15349
|
+
const tablePosition = createTablePosition(editor);
|
|
15296
15350
|
const origin = getOriginCell(tablePosition.table, tablePosition.getRowIndex(), tablePosition.getColumnIndex());
|
|
15297
15351
|
if (origin) {
|
|
15298
15352
|
const path = AngularEditor.findPath(editor, origin);
|
|
@@ -15328,10 +15382,9 @@ const withTable = (editor) => {
|
|
|
15328
15382
|
deleteCutData();
|
|
15329
15383
|
return;
|
|
15330
15384
|
}
|
|
15331
|
-
const
|
|
15332
|
-
const element = TablePosition.create(opts, editor, selection.anchor.path);
|
|
15385
|
+
const element = createTablePosition(editor);
|
|
15333
15386
|
const tableComponent = ELEMENT_TO_COMPONENT.get(element.table);
|
|
15334
|
-
const selectedCellPositions = tableComponent.tableStore.
|
|
15387
|
+
const selectedCellPositions = tableComponent.tableStore.getSelectedCellPositions();
|
|
15335
15388
|
if (selectedCellPositions.length > 0) {
|
|
15336
15389
|
Editor.withoutNormalizing(editor, () => {
|
|
15337
15390
|
if (tableComponent.tableStore.isSelectedTable) {
|
|
@@ -15358,7 +15411,7 @@ const withTable = (editor) => {
|
|
|
15358
15411
|
const isSelectionOperation = editor.operations.every(op => Operation.isSelectionOperation(op));
|
|
15359
15412
|
if (isCollapsed && isSelectionOperation) {
|
|
15360
15413
|
const opts = new TableOptions();
|
|
15361
|
-
const tablePosition =
|
|
15414
|
+
const tablePosition = createTablePosition(editor);
|
|
15362
15415
|
if (tablePosition.isInTable() && tablePosition.cell.hidden) {
|
|
15363
15416
|
TableEditor.selectOriginCell(editor, tablePosition.table, tablePosition.getRowIndex(), tablePosition.getColumnIndex(), false);
|
|
15364
15417
|
}
|
|
@@ -15555,7 +15608,7 @@ const createTodoItemPlugin = createPluginFactory({
|
|
|
15555
15608
|
const internalPlugins = () => [
|
|
15556
15609
|
createTheHistoryPlugin(),
|
|
15557
15610
|
createCommonPlugin(),
|
|
15558
|
-
|
|
15611
|
+
createInsertDataByInvalidTypePlugin(),
|
|
15559
15612
|
createRemoveEmptyPlugin(),
|
|
15560
15613
|
createRemoveVoidPlugin(),
|
|
15561
15614
|
createBlockCardPlugin(),
|
|
@@ -16531,5 +16584,5 @@ const withTestPlugin = (plugins, initValue) => {
|
|
|
16531
16584
|
* Generated bundle index. Do not edit.
|
|
16532
16585
|
*/
|
|
16533
16586
|
|
|
16534
|
-
export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETE_BACKWARD_TYPES, BackgroundColors, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, COMPONENTS, CONTAINER_BLOCKS, CONTROL_KEY, CodeEditor, ColorEditor, Colors, ColumnResizeNotifierSource, DEFAULT_LANGUAGE, DEFAULT_SCROLL_CONTAINER, DISABLED_OPERATE_TYPES, DefaultElementOptions, DefaultGlobalToolbarDefinition, DefaultInlineToolbarDefinition, DefaultPluginMenu, DropdownMode, ELEMENT_UNIQUE_ID, ElementKinds, ErrorCodes, FontSizeTypes, FontSizes, HEADING_TYPES, HeadingEditor, HoveredCellInfo, HrEditor, IS_MAC, ImageEditor, IndentEditor, Indents, InlineCodeEditor, LINK_DEFAULT_TEXT, LIST_BLOCK_TYPES, LayoutTypes, LinkEditor, ListEditor, MarkEditor, MarkProps, MarkTypes, MentionEditor, PICTURE_ACCEPTED_UPLOAD_MIME, PICTURE_ACCEPTED_UPLOAD_SIZE, PLUGIN_COMPONENTS, PluginKeys, PluginMenuIcons, PluginMenuSvgs, Position, QuickInsertEditor, STANDARD_HEADING_TYPES, ScrollDirection, SpecialBackgroundColor, SpecialTextColor, TAB_SPACE, THE_EDITOR_CONVERSION_HINT_REF, THE_EDITOR_ORIGIN_ANCHOR, THE_EDITOR_POPOVER_REF, THE_EDITOR_PREVIOUS_SELECTION, THE_EDITOR_UUID, THE_INLINE_TOOLBAR_TYPES, THE_LISTBOX_PARENT_GROUP_TOKEN, THE_LISTBOX_PARENT_OPTION_TOKEN, THE_LISTBOX_TOKEN, THE_MODE_PROVIDER, THE_MODE_TOKEN, THE_PLUGIN_MENU_REF, THE_UPLOAD_SERVICE_TOKEN, TableCellEventDispatcher, TableEditor, TableHeaderBackgroundColor, TheBaseElementComponent, TheBaseSuggestion, TheBaseToolbarDropdown, TheBaseToolbarItem, TheContextService, TheDataMode, TheDefaultElementComponent, TheEditor, TheEditorComponent, TheEditorModule, TheImageComponent, TheListboxDirective, TheListboxGroupDirective, TheListboxOptionDirective, TheMode, TheModeConfig, ThePluginMenu, ThePluginMenuComponent, ThePluginMenuItemType, ThePreventDefaultDirective, index$1 as TheQueries, TheToolbarComponent, TheToolbarDropdownComponent, TheToolbarGroupComponent, TheToolbarGroupToken, TheToolbarItemComponent, TheToolbarService, index as TheTransforms, TodoItemEditor, ToolbarActionTypes, ToolbarAlignment, ToolbarItemType, ToolbarMoreGroup, VOID_BLOCK_TYPES, VerticalAlignEditor, VerticalAlignment, ZERO_WIDTH_CHAR, autoFocus, base64toBlob, buildPluginMenu, buildPluginMenuItemMap, coercePixelsFromCssValue, combinePlugins, copyNode, copyNodeForSafari, createEmptyParagraph, createMentionPlugin, createPluginFactory, createToolbar, createVerticalAlignPlugin, dataDeserialize, dataSerializing, deleteElementKey, extractFragment, filterTextFormat, flattenDeepPlugins, getColsTotalWidth, getEditorUUID, getElementClassByPrefix, getElementHeight, getElementWidth, getEndBlock, getPlugin, getPluginOptions, getPlugins, getRowsTotalHeight, getStartBlock, getToolbarClass, headingOptions, htmlToTheia, idCreator, inValidTypes, initializeDefaultMenuIcons, internalPlugins, isCleanEmptyParagraph, isDirectionKeydown, isPureEmptyParagraph, mergeArray, mergeDeepPlugins, mergeElementOptions, mergeOptions, nestedStructureByKey, plainToTheia, pluginsByKey, reSelection, recursionNodes, refocus, scrollIntoView, setEditorUUID, useElementStyle, withMention, withTestPlugin, withTheia };
|
|
16587
|
+
export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETE_BACKWARD_TYPES, BackgroundColors, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, COMPONENTS, CONTAINER_BLOCKS, CONTROL_KEY, CodeEditor, ColorEditor, Colors, ColumnResizeNotifierSource, DEFAULT_LANGUAGE, DEFAULT_SCROLL_CONTAINER, DISABLED_OPERATE_TYPES, DefaultElementOptions, DefaultGlobalToolbarDefinition, DefaultInlineToolbarDefinition, DefaultPluginMenu, DropdownMode, ELEMENT_UNIQUE_ID, ElementKinds, ErrorCodes, FontSizeTypes, FontSizes, HEADING_TYPES, HeadingEditor, HoveredCellInfo, HrEditor, IS_MAC, ImageEditor, IndentEditor, Indents, InlineCodeEditor, LINK_DEFAULT_TEXT, LIST_BLOCK_TYPES, LayoutTypes, LinkEditor, ListEditor, MarkEditor, MarkProps, MarkTypes, MentionEditor, PICTURE_ACCEPTED_UPLOAD_MIME, PICTURE_ACCEPTED_UPLOAD_SIZE, PLUGIN_COMPONENTS, PluginKeys, PluginMenuIcons, PluginMenuSvgs, Position, QuickInsertEditor, STANDARD_HEADING_TYPES, ScrollDirection, SpecialBackgroundColor, SpecialTextColor, TAB_SPACE, THE_EDITOR_CONVERSION_HINT_REF, THE_EDITOR_ORIGIN_ANCHOR, THE_EDITOR_POPOVER_REF, THE_EDITOR_PREVIOUS_SELECTION, THE_EDITOR_UUID, THE_INLINE_TOOLBAR_TYPES, THE_LISTBOX_PARENT_GROUP_TOKEN, THE_LISTBOX_PARENT_OPTION_TOKEN, THE_LISTBOX_TOKEN, THE_MODE_PROVIDER, THE_MODE_TOKEN, THE_PLUGIN_MENU_REF, THE_UPLOAD_SERVICE_TOKEN, TableCellEventDispatcher, TableEditor, TableHeaderBackgroundColor, TheBaseElementComponent, TheBaseSuggestion, TheBaseToolbarDropdown, TheBaseToolbarItem, TheContextService, TheDataMode, TheDefaultElementComponent, TheEditor, TheEditorComponent, TheEditorModule, TheImageComponent, TheListboxDirective, TheListboxGroupDirective, TheListboxOptionDirective, TheMode, TheModeConfig, ThePluginMenu, ThePluginMenuComponent, ThePluginMenuItemType, ThePreventDefaultDirective, index$1 as TheQueries, TheToolbarComponent, TheToolbarDropdownComponent, TheToolbarGroupComponent, TheToolbarGroupToken, TheToolbarItemComponent, TheToolbarService, index as TheTransforms, TodoItemEditor, ToolbarActionTypes, ToolbarAlignment, ToolbarItemType, ToolbarMoreGroup, VOID_BLOCK_TYPES, VerticalAlignEditor, VerticalAlignment, ZERO_WIDTH_CHAR, autoFocus, base64toBlob, buildPluginMenu, buildPluginMenuItemMap, coercePixelsFromCssValue, combinePlugins, copyNode, copyNodeForSafari, createEmptyParagraph, createMentionPlugin, createPluginFactory, createToolbar, createVerticalAlignPlugin, dataDeserialize, dataSerializing, deleteElementKey, extractFragment, filterTextFormat, flattenDeepPlugins, getColsTotalWidth, getEditorUUID, getElementClassByPrefix, getElementHeight, getElementWidth, getEndBlock, getPlugin, getPluginOptions, getPlugins, getRowsTotalHeight, getStartBlock, getToolbarClass, headingOptions, htmlToTheia, idCreator, inValidTypes, initializeDefaultMenuIcons, insertDataByInvalidType, internalPlugins, isCleanEmptyParagraph, isDirectionKeydown, isPureEmptyParagraph, mergeArray, mergeDeepPlugins, mergeElementOptions, mergeOptions, nestedStructureByKey, plainToTheia, pluginsByKey, reSelection, recursionNodes, refocus, scrollIntoView, setEditorUUID, useElementStyle, withMention, withTestPlugin, withTheia };
|
|
16535
16588
|
//# sourceMappingURL=worktile-theia.mjs.map
|