roosterjs-content-model-core 9.45.1 → 9.46.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.
Files changed (67) hide show
  1. package/lib/command/cutCopy/getContentForCopy.js +4 -15
  2. package/lib/command/cutCopy/getContentForCopy.js.map +1 -1
  3. package/lib/coreApi/setDOMSelection/setDOMSelection.js +5 -58
  4. package/lib/coreApi/setDOMSelection/setDOMSelection.js.map +1 -1
  5. package/lib/coreApi/setDOMSelection/setTableCellsStyle.d.ts +17 -0
  6. package/lib/coreApi/setDOMSelection/setTableCellsStyle.js +85 -0
  7. package/lib/coreApi/setDOMSelection/setTableCellsStyle.js.map +1 -0
  8. package/lib/coreApi/setDOMSelection/toggleTableSelection.d.ts +8 -0
  9. package/lib/coreApi/setDOMSelection/toggleTableSelection.js +34 -0
  10. package/lib/coreApi/setDOMSelection/toggleTableSelection.js.map +1 -0
  11. package/lib/coreApi/switchShadowEdit/switchShadowEdit.js +3 -0
  12. package/lib/coreApi/switchShadowEdit/switchShadowEdit.js.map +1 -1
  13. package/lib/corePlugin/selection/SelectionPlugin.js +3 -0
  14. package/lib/corePlugin/selection/SelectionPlugin.js.map +1 -1
  15. package/lib/editor/Editor.js +1 -1
  16. package/lib/editor/Editor.js.map +1 -1
  17. package/lib-amd/command/cutCopy/getContentForCopy.js +5 -14
  18. package/lib-amd/command/cutCopy/getContentForCopy.js.map +1 -1
  19. package/lib-amd/coreApi/setDOMSelection/setDOMSelection.js +4 -58
  20. package/lib-amd/coreApi/setDOMSelection/setDOMSelection.js.map +1 -1
  21. package/lib-amd/coreApi/setDOMSelection/setTableCellsStyle.d.ts +17 -0
  22. package/lib-amd/coreApi/setDOMSelection/setTableCellsStyle.js +85 -0
  23. package/lib-amd/coreApi/setDOMSelection/setTableCellsStyle.js.map +1 -0
  24. package/lib-amd/coreApi/setDOMSelection/toggleTableSelection.d.ts +8 -0
  25. package/lib-amd/coreApi/setDOMSelection/toggleTableSelection.js +34 -0
  26. package/lib-amd/coreApi/setDOMSelection/toggleTableSelection.js.map +1 -0
  27. package/lib-amd/coreApi/switchShadowEdit/switchShadowEdit.js +3 -1
  28. package/lib-amd/coreApi/switchShadowEdit/switchShadowEdit.js.map +1 -1
  29. package/lib-amd/corePlugin/selection/SelectionPlugin.js +3 -0
  30. package/lib-amd/corePlugin/selection/SelectionPlugin.js.map +1 -1
  31. package/lib-amd/editor/Editor.js +1 -1
  32. package/lib-amd/editor/Editor.js.map +1 -1
  33. package/lib-mjs/command/cutCopy/getContentForCopy.js +5 -16
  34. package/lib-mjs/command/cutCopy/getContentForCopy.js.map +1 -1
  35. package/lib-mjs/coreApi/setDOMSelection/setDOMSelection.js +5 -58
  36. package/lib-mjs/coreApi/setDOMSelection/setDOMSelection.js.map +1 -1
  37. package/lib-mjs/coreApi/setDOMSelection/setTableCellsStyle.d.ts +17 -0
  38. package/lib-mjs/coreApi/setDOMSelection/setTableCellsStyle.js +80 -0
  39. package/lib-mjs/coreApi/setDOMSelection/setTableCellsStyle.js.map +1 -0
  40. package/lib-mjs/coreApi/setDOMSelection/toggleTableSelection.d.ts +8 -0
  41. package/lib-mjs/coreApi/setDOMSelection/toggleTableSelection.js +30 -0
  42. package/lib-mjs/coreApi/setDOMSelection/toggleTableSelection.js.map +1 -0
  43. package/lib-mjs/coreApi/switchShadowEdit/switchShadowEdit.js +3 -0
  44. package/lib-mjs/coreApi/switchShadowEdit/switchShadowEdit.js.map +1 -1
  45. package/lib-mjs/corePlugin/selection/SelectionPlugin.js +3 -0
  46. package/lib-mjs/corePlugin/selection/SelectionPlugin.js.map +1 -1
  47. package/lib-mjs/editor/Editor.js +1 -1
  48. package/lib-mjs/editor/Editor.js.map +1 -1
  49. package/package.json +4 -4
  50. package/lib/command/cutCopy/preprocessTable.d.ts +0 -5
  51. package/lib/command/cutCopy/preprocessTable.js +0 -22
  52. package/lib/command/cutCopy/preprocessTable.js.map +0 -1
  53. package/lib/command/cutCopy/pruneUnselectedModel.d.ts +0 -5
  54. package/lib/command/cutCopy/pruneUnselectedModel.js +0 -135
  55. package/lib/command/cutCopy/pruneUnselectedModel.js.map +0 -1
  56. package/lib-amd/command/cutCopy/preprocessTable.d.ts +0 -5
  57. package/lib-amd/command/cutCopy/preprocessTable.js +0 -22
  58. package/lib-amd/command/cutCopy/preprocessTable.js.map +0 -1
  59. package/lib-amd/command/cutCopy/pruneUnselectedModel.d.ts +0 -5
  60. package/lib-amd/command/cutCopy/pruneUnselectedModel.js +0 -136
  61. package/lib-amd/command/cutCopy/pruneUnselectedModel.js.map +0 -1
  62. package/lib-mjs/command/cutCopy/preprocessTable.d.ts +0 -5
  63. package/lib-mjs/command/cutCopy/preprocessTable.js +0 -18
  64. package/lib-mjs/command/cutCopy/preprocessTable.js.map +0 -1
  65. package/lib-mjs/command/cutCopy/pruneUnselectedModel.d.ts +0 -5
  66. package/lib-mjs/command/cutCopy/pruneUnselectedModel.js +0 -131
  67. package/lib-mjs/command/cutCopy/pruneUnselectedModel.js.map +0 -1
@@ -1,22 +0,0 @@
1
- define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function (require, exports, tslib_1, roosterjs_content_model_dom_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.preprocessTable = void 0;
5
- /**
6
- * @internal
7
- */
8
- function preprocessTable(table) {
9
- var sel = (0, roosterjs_content_model_dom_1.getSelectedCells)(table);
10
- table.rows = table.rows
11
- .map(function (row) {
12
- return (0, tslib_1.__assign)((0, tslib_1.__assign)({}, row), { cells: row.cells.filter(function (cell) { return cell.isSelected; }) });
13
- })
14
- .filter(function (row) { return row.cells.length > 0; });
15
- delete table.format.width;
16
- table.widths = sel
17
- ? table.widths.filter(function (_, index) { return index >= (sel === null || sel === void 0 ? void 0 : sel.firstColumn) && index <= (sel === null || sel === void 0 ? void 0 : sel.lastColumn); })
18
- : [];
19
- }
20
- exports.preprocessTable = preprocessTable;
21
- });
22
- //# sourceMappingURL=preprocessTable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"preprocessTable.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/command/cutCopy/preprocessTable.ts"],"names":[],"mappings":";;;;IAGA;;OAEG;IACH,SAAgB,eAAe,CAAC,KAAwB;QACpD,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QACpC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI;aAClB,GAAG,CAAC,UAAA,GAAG;YACJ,uDACO,GAAG,KACN,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,UAAA,IAAI,IAAI,OAAA,IAAI,CAAC,UAAU,EAAf,CAAe,CAAC,IAClD;QACN,CAAC,CAAC;aACD,MAAM,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAApB,CAAoB,CAAC,CAAC;QAEzC,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;QAE1B,KAAK,CAAC,MAAM,GAAG,GAAG;YACd,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,UAAC,CAAC,EAAE,KAAK,IAAK,OAAA,KAAK,KAAI,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,WAAW,CAAA,IAAI,KAAK,KAAI,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,CAAA,EAArD,CAAqD,CAAC;YAC1F,CAAC,CAAC,EAAE,CAAC;IACb,CAAC;IAhBD,0CAgBC","sourcesContent":["import { getSelectedCells } from 'roosterjs-content-model-dom';\nimport type { ContentModelTable } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function preprocessTable(table: ContentModelTable) {\n const sel = getSelectedCells(table);\n table.rows = table.rows\n .map(row => {\n return {\n ...row,\n cells: row.cells.filter(cell => cell.isSelected),\n };\n })\n .filter(row => row.cells.length > 0);\n\n delete table.format.width;\n\n table.widths = sel\n ? table.widths.filter((_, index) => index >= sel?.firstColumn && index <= sel?.lastColumn)\n : [];\n}\n"]}
@@ -1,5 +0,0 @@
1
- import type { ContentModelBlockGroupBase, ContentModelBlockGroupType } from 'roosterjs-content-model-types';
2
- /**
3
- * @internal
4
- */
5
- export declare function pruneUnselectedModel(model: ContentModelBlockGroupBase<ContentModelBlockGroupType, HTMLElement>): void;
@@ -1,136 +0,0 @@
1
- define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.pruneUnselectedModel = void 0;
5
- /**
6
- * @internal
7
- */
8
- function pruneUnselectedModel(model) {
9
- pruneUnselectedModelInternal(model, false /* isSelectionAfterElement */);
10
- unwrap(model);
11
- }
12
- exports.pruneUnselectedModel = pruneUnselectedModel;
13
- function pruneUnselectedModelInternal(model, isSelectionAfterElement) {
14
- var e_1, _a, _b;
15
- for (var index = model.blocks.length - 1; index >= 0; index--) {
16
- var block = model.blocks[index];
17
- switch (block.blockType) {
18
- case 'BlockGroup':
19
- pruneUnselectedModelInternal(block, isSelectionAfterElement);
20
- if (block.blockGroupType == 'General'
21
- ? block.blocks.length == 0 && !block.isSelected
22
- : block.blocks.length == 0) {
23
- model.blocks.splice(index, 1);
24
- }
25
- break;
26
- case 'Divider':
27
- case 'Entity':
28
- if (!block.isSelected) {
29
- model.blocks.splice(index, 1);
30
- }
31
- else {
32
- isSelectionAfterElement = true;
33
- }
34
- break;
35
- case 'Paragraph':
36
- var newSegments = [];
37
- try {
38
- for (var _c = (e_1 = void 0, (0, tslib_1.__values)(block.segments)), _d = _c.next(); !_d.done; _d = _c.next()) {
39
- var segment = _d.value;
40
- if (segment.segmentType == 'General') {
41
- pruneUnselectedModel(segment);
42
- if (segment.blocks.length > 0 || segment.isSelected) {
43
- newSegments.push(segment);
44
- }
45
- }
46
- else if (segment.isSelected && segment.segmentType != 'SelectionMarker') {
47
- newSegments.push(segment);
48
- }
49
- }
50
- }
51
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
52
- finally {
53
- try {
54
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
55
- }
56
- finally { if (e_1) throw e_1.error; }
57
- }
58
- block.segments = newSegments;
59
- if (block.segments.length == 0) {
60
- model.blocks.splice(index, 1);
61
- }
62
- else {
63
- isSelectionAfterElement = true;
64
- }
65
- break;
66
- case 'Table':
67
- var filteredRows = [];
68
- for (var i = 0; i < block.rows.length; i++) {
69
- var row = block.rows[i];
70
- for (var j = 0; j < row.cells.length; j++) {
71
- var cell = row.cells[j];
72
- if (!cell.isSelected) {
73
- pruneUnselectedModelInternal(cell, isSelectionAfterElement);
74
- }
75
- else {
76
- isSelectionAfterElement = true;
77
- }
78
- }
79
- var newCells = [];
80
- for (var k = 0; k < row.cells.length; k++) {
81
- var cell = row.cells[k];
82
- if (cell.isSelected || cell.blocks.length > 0) {
83
- newCells.push(cell);
84
- }
85
- }
86
- row.cells = newCells;
87
- if (row.cells.length > 0) {
88
- filteredRows.push(row);
89
- }
90
- }
91
- if (!isSelectionAfterElement &&
92
- filteredRows.length == 1 &&
93
- filteredRows[0].cells.length == 1 &&
94
- !filteredRows[0].cells[0].isSelected) {
95
- var cell = filteredRows[0].cells[0];
96
- (_b = model.blocks).splice.apply(_b, (0, tslib_1.__spreadArray)([index, 1], (0, tslib_1.__read)(cell.blocks), false));
97
- }
98
- else if (filteredRows.length == 0) {
99
- model.blocks.splice(index, 1);
100
- }
101
- else {
102
- block.rows = filteredRows;
103
- }
104
- break;
105
- }
106
- }
107
- return isSelectionAfterElement;
108
- }
109
- function unwrap(model) {
110
- var block = model.blocks[0];
111
- if (model.blocks.length == 1) {
112
- while (block.blockType == 'BlockGroup') {
113
- model.blocks = block.blocks;
114
- block = model.blocks[0];
115
- if (model.blocks.length > 1) {
116
- return;
117
- }
118
- }
119
- if (block.blockType == 'Paragraph') {
120
- block.isImplicit = true;
121
- block.format = {};
122
- inheritSegmentFormatToChildren(block);
123
- }
124
- }
125
- }
126
- function inheritSegmentFormatToChildren(parent) {
127
- var value = parent.segmentFormat;
128
- if (value !== undefined) {
129
- for (var index = 0; index < parent.segments.length; index++) {
130
- var segment = parent.segments[index];
131
- segment.format = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, parent.segmentFormat), segment.format);
132
- }
133
- }
134
- }
135
- });
136
- //# sourceMappingURL=pruneUnselectedModel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pruneUnselectedModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/command/cutCopy/pruneUnselectedModel.ts"],"names":[],"mappings":";;;;IASA;;OAEG;IACH,SAAgB,oBAAoB,CAChC,KAA0E;QAE1E,4BAA4B,CAAC,KAAK,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;QAEzE,MAAM,CAAC,KAAK,CAAC,CAAC;IAClB,CAAC;IAND,oDAMC;IAED,SAAS,4BAA4B,CACjC,KAA0E,EAC1E,uBAAgC;;QAEhC,KAAK,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE;YAC3D,IAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAElC,QAAQ,KAAK,CAAC,SAAS,EAAE;gBACrB,KAAK,YAAY;oBACb,4BAA4B,CAAC,KAAK,EAAE,uBAAuB,CAAC,CAAC;oBAC7D,IACI,KAAK,CAAC,cAAc,IAAI,SAAS;wBAC7B,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU;wBAC/C,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,EAChC;wBACE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;qBACjC;oBACD,MAAM;gBACV,KAAK,SAAS,CAAC;gBACf,KAAK,QAAQ;oBACT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,CAAC,aAAa,GACpB,OAAO,CAAC,MAAM,CACpB,CAAC;aACL;SACJ;IACL,CAAC","sourcesContent":["import type {\n ContentModelBlockGroupBase,\n ContentModelBlockGroupType,\n ContentModelParagraph,\n ContentModelSegment,\n ContentModelTableCell,\n ContentModelTableRow,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function pruneUnselectedModel(\n model: ContentModelBlockGroupBase<ContentModelBlockGroupType, HTMLElement>\n) {\n pruneUnselectedModelInternal(model, false /* isSelectionAfterElement */);\n\n unwrap(model);\n}\n\nfunction pruneUnselectedModelInternal(\n model: ContentModelBlockGroupBase<ContentModelBlockGroupType, HTMLElement>,\n isSelectionAfterElement: boolean\n) {\n for (let index = model.blocks.length - 1; index >= 0; index--) {\n const block = model.blocks[index];\n\n switch (block.blockType) {\n case 'BlockGroup':\n pruneUnselectedModelInternal(block, isSelectionAfterElement);\n if (\n block.blockGroupType == 'General'\n ? block.blocks.length == 0 && !block.isSelected\n : block.blocks.length == 0\n ) {\n model.blocks.splice(index, 1);\n }\n break;\n case 'Divider':\n case 'Entity':\n if (!block.isSelected) {\n model.blocks.splice(index, 1);\n } else {\n isSelectionAfterElement = true;\n }\n break;\n case 'Paragraph':\n const newSegments: ContentModelSegment[] = [];\n for (const segment of block.segments) {\n if (segment.segmentType == 'General') {\n pruneUnselectedModel(segment);\n if (segment.blocks.length > 0 || segment.isSelected) {\n newSegments.push(segment);\n }\n } else if (segment.isSelected && segment.segmentType != 'SelectionMarker') {\n newSegments.push(segment);\n }\n }\n block.segments = newSegments;\n if (block.segments.length == 0) {\n model.blocks.splice(index, 1);\n } else {\n isSelectionAfterElement = true;\n }\n break;\n case 'Table':\n const filteredRows: ContentModelTableRow[] = [];\n for (let i = 0; i < block.rows.length; i++) {\n const row = block.rows[i];\n for (let j = 0; j < row.cells.length; j++) {\n const cell = row.cells[j];\n if (!cell.isSelected) {\n pruneUnselectedModelInternal(cell, isSelectionAfterElement);\n } else {\n isSelectionAfterElement = true;\n }\n }\n\n const newCells: ContentModelTableCell[] = [];\n for (let k = 0; k < row.cells.length; k++) {\n const cell = row.cells[k];\n if (cell.isSelected || cell.blocks.length > 0) {\n newCells.push(cell);\n }\n }\n row.cells = newCells;\n\n if (row.cells.length > 0) {\n filteredRows.push(row);\n }\n }\n\n if (\n !isSelectionAfterElement &&\n filteredRows.length == 1 &&\n filteredRows[0].cells.length == 1 &&\n !filteredRows[0].cells[0].isSelected\n ) {\n const cell = filteredRows[0].cells[0];\n model.blocks.splice(index, 1, ...cell.blocks);\n } else if (filteredRows.length == 0) {\n model.blocks.splice(index, 1);\n } else {\n block.rows = filteredRows;\n }\n break;\n }\n }\n return isSelectionAfterElement;\n}\n\nfunction unwrap(model: ContentModelBlockGroupBase<ContentModelBlockGroupType, HTMLElement>) {\n let block = model.blocks[0];\n if (model.blocks.length == 1) {\n while (block.blockType == 'BlockGroup') {\n model.blocks = block.blocks;\n block = model.blocks[0];\n\n if (model.blocks.length > 1) {\n return;\n }\n }\n\n if (block.blockType == 'Paragraph') {\n block.isImplicit = true;\n block.format = {};\n inheritSegmentFormatToChildren(block);\n }\n }\n}\n\nfunction inheritSegmentFormatToChildren(parent: ContentModelParagraph) {\n const value = parent.segmentFormat;\n if (value !== undefined) {\n for (let index = 0; index < parent.segments.length; index++) {\n const segment = parent.segments[index];\n segment.format = {\n ...parent.segmentFormat,\n ...segment.format,\n };\n }\n }\n}\n"]}
@@ -1,5 +0,0 @@
1
- import type { ContentModelTable } from 'roosterjs-content-model-types';
2
- /**
3
- * @internal
4
- */
5
- export declare function preprocessTable(table: ContentModelTable): void;
@@ -1,18 +0,0 @@
1
- import { __assign } from "tslib";
2
- import { getSelectedCells } from 'roosterjs-content-model-dom';
3
- /**
4
- * @internal
5
- */
6
- export function preprocessTable(table) {
7
- var sel = getSelectedCells(table);
8
- table.rows = table.rows
9
- .map(function (row) {
10
- return __assign(__assign({}, row), { cells: row.cells.filter(function (cell) { return cell.isSelected; }) });
11
- })
12
- .filter(function (row) { return row.cells.length > 0; });
13
- delete table.format.width;
14
- table.widths = sel
15
- ? table.widths.filter(function (_, index) { return index >= (sel === null || sel === void 0 ? void 0 : sel.firstColumn) && index <= (sel === null || sel === void 0 ? void 0 : sel.lastColumn); })
16
- : [];
17
- }
18
- //# sourceMappingURL=preprocessTable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"preprocessTable.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/command/cutCopy/preprocessTable.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAwB;IACpD,IAAM,GAAG,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACpC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI;SAClB,GAAG,CAAC,UAAA,GAAG;QACJ,6BACO,GAAG,KACN,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,UAAA,IAAI,IAAI,OAAA,IAAI,CAAC,UAAU,EAAf,CAAe,CAAC,IAClD;IACN,CAAC,CAAC;SACD,MAAM,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAApB,CAAoB,CAAC,CAAC;IAEzC,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;IAE1B,KAAK,CAAC,MAAM,GAAG,GAAG;QACd,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,UAAC,CAAC,EAAE,KAAK,IAAK,OAAA,KAAK,KAAI,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,WAAW,CAAA,IAAI,KAAK,KAAI,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,CAAA,EAArD,CAAqD,CAAC;QAC1F,CAAC,CAAC,EAAE,CAAC;AACb,CAAC","sourcesContent":["import { getSelectedCells } from 'roosterjs-content-model-dom';\nimport type { ContentModelTable } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function preprocessTable(table: ContentModelTable) {\n const sel = getSelectedCells(table);\n table.rows = table.rows\n .map(row => {\n return {\n ...row,\n cells: row.cells.filter(cell => cell.isSelected),\n };\n })\n .filter(row => row.cells.length > 0);\n\n delete table.format.width;\n\n table.widths = sel\n ? table.widths.filter((_, index) => index >= sel?.firstColumn && index <= sel?.lastColumn)\n : [];\n}\n"]}
@@ -1,5 +0,0 @@
1
- import type { ContentModelBlockGroupBase, ContentModelBlockGroupType } from 'roosterjs-content-model-types';
2
- /**
3
- * @internal
4
- */
5
- export declare function pruneUnselectedModel(model: ContentModelBlockGroupBase<ContentModelBlockGroupType, HTMLElement>): void;
@@ -1,131 +0,0 @@
1
- import { __assign, __read, __spreadArray, __values } from "tslib";
2
- /**
3
- * @internal
4
- */
5
- export function pruneUnselectedModel(model) {
6
- pruneUnselectedModelInternal(model, false /* isSelectionAfterElement */);
7
- unwrap(model);
8
- }
9
- function pruneUnselectedModelInternal(model, isSelectionAfterElement) {
10
- var e_1, _a, _b;
11
- for (var index = model.blocks.length - 1; index >= 0; index--) {
12
- var block = model.blocks[index];
13
- switch (block.blockType) {
14
- case 'BlockGroup':
15
- pruneUnselectedModelInternal(block, isSelectionAfterElement);
16
- if (block.blockGroupType == 'General'
17
- ? block.blocks.length == 0 && !block.isSelected
18
- : block.blocks.length == 0) {
19
- model.blocks.splice(index, 1);
20
- }
21
- break;
22
- case 'Divider':
23
- case 'Entity':
24
- if (!block.isSelected) {
25
- model.blocks.splice(index, 1);
26
- }
27
- else {
28
- isSelectionAfterElement = true;
29
- }
30
- break;
31
- case 'Paragraph':
32
- var newSegments = [];
33
- try {
34
- for (var _c = (e_1 = void 0, __values(block.segments)), _d = _c.next(); !_d.done; _d = _c.next()) {
35
- var segment = _d.value;
36
- if (segment.segmentType == 'General') {
37
- pruneUnselectedModel(segment);
38
- if (segment.blocks.length > 0 || segment.isSelected) {
39
- newSegments.push(segment);
40
- }
41
- }
42
- else if (segment.isSelected && segment.segmentType != 'SelectionMarker') {
43
- newSegments.push(segment);
44
- }
45
- }
46
- }
47
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
48
- finally {
49
- try {
50
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
51
- }
52
- finally { if (e_1) throw e_1.error; }
53
- }
54
- block.segments = newSegments;
55
- if (block.segments.length == 0) {
56
- model.blocks.splice(index, 1);
57
- }
58
- else {
59
- isSelectionAfterElement = true;
60
- }
61
- break;
62
- case 'Table':
63
- var filteredRows = [];
64
- for (var i = 0; i < block.rows.length; i++) {
65
- var row = block.rows[i];
66
- for (var j = 0; j < row.cells.length; j++) {
67
- var cell = row.cells[j];
68
- if (!cell.isSelected) {
69
- pruneUnselectedModelInternal(cell, isSelectionAfterElement);
70
- }
71
- else {
72
- isSelectionAfterElement = true;
73
- }
74
- }
75
- var newCells = [];
76
- for (var k = 0; k < row.cells.length; k++) {
77
- var cell = row.cells[k];
78
- if (cell.isSelected || cell.blocks.length > 0) {
79
- newCells.push(cell);
80
- }
81
- }
82
- row.cells = newCells;
83
- if (row.cells.length > 0) {
84
- filteredRows.push(row);
85
- }
86
- }
87
- if (!isSelectionAfterElement &&
88
- filteredRows.length == 1 &&
89
- filteredRows[0].cells.length == 1 &&
90
- !filteredRows[0].cells[0].isSelected) {
91
- var cell = filteredRows[0].cells[0];
92
- (_b = model.blocks).splice.apply(_b, __spreadArray([index, 1], __read(cell.blocks), false));
93
- }
94
- else if (filteredRows.length == 0) {
95
- model.blocks.splice(index, 1);
96
- }
97
- else {
98
- block.rows = filteredRows;
99
- }
100
- break;
101
- }
102
- }
103
- return isSelectionAfterElement;
104
- }
105
- function unwrap(model) {
106
- var block = model.blocks[0];
107
- if (model.blocks.length == 1) {
108
- while (block.blockType == 'BlockGroup') {
109
- model.blocks = block.blocks;
110
- block = model.blocks[0];
111
- if (model.blocks.length > 1) {
112
- return;
113
- }
114
- }
115
- if (block.blockType == 'Paragraph') {
116
- block.isImplicit = true;
117
- block.format = {};
118
- inheritSegmentFormatToChildren(block);
119
- }
120
- }
121
- }
122
- function inheritSegmentFormatToChildren(parent) {
123
- var value = parent.segmentFormat;
124
- if (value !== undefined) {
125
- for (var index = 0; index < parent.segments.length; index++) {
126
- var segment = parent.segments[index];
127
- segment.format = __assign(__assign({}, parent.segmentFormat), segment.format);
128
- }
129
- }
130
- }
131
- //# sourceMappingURL=pruneUnselectedModel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pruneUnselectedModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-core/lib/command/cutCopy/pruneUnselectedModel.ts"],"names":[],"mappings":";AASA;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAChC,KAA0E;IAE1E,4BAA4B,CAAC,KAAK,EAAE,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAEzE,MAAM,CAAC,KAAK,CAAC,CAAC;AAClB,CAAC;AAED,SAAS,4BAA4B,CACjC,KAA0E,EAC1E,uBAAgC;;IAEhC,KAAK,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE;QAC3D,IAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAElC,QAAQ,KAAK,CAAC,SAAS,EAAE;YACrB,KAAK,YAAY;gBACb,4BAA4B,CAAC,KAAK,EAAE,uBAAuB,CAAC,CAAC;gBAC7D,IACI,KAAK,CAAC,cAAc,IAAI,SAAS;oBAC7B,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU;oBAC/C,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,EAChC;oBACE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;iBACjC;gBACD,MAAM;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,OAAO,CAAC,MAAM,yBACP,MAAM,CAAC,aAAa,GACpB,OAAO,CAAC,MAAM,CACpB,CAAC;SACL;KACJ;AACL,CAAC","sourcesContent":["import type {\n ContentModelBlockGroupBase,\n ContentModelBlockGroupType,\n ContentModelParagraph,\n ContentModelSegment,\n ContentModelTableCell,\n ContentModelTableRow,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function pruneUnselectedModel(\n model: ContentModelBlockGroupBase<ContentModelBlockGroupType, HTMLElement>\n) {\n pruneUnselectedModelInternal(model, false /* isSelectionAfterElement */);\n\n unwrap(model);\n}\n\nfunction pruneUnselectedModelInternal(\n model: ContentModelBlockGroupBase<ContentModelBlockGroupType, HTMLElement>,\n isSelectionAfterElement: boolean\n) {\n for (let index = model.blocks.length - 1; index >= 0; index--) {\n const block = model.blocks[index];\n\n switch (block.blockType) {\n case 'BlockGroup':\n pruneUnselectedModelInternal(block, isSelectionAfterElement);\n if (\n block.blockGroupType == 'General'\n ? block.blocks.length == 0 && !block.isSelected\n : block.blocks.length == 0\n ) {\n model.blocks.splice(index, 1);\n }\n break;\n case 'Divider':\n case 'Entity':\n if (!block.isSelected) {\n model.blocks.splice(index, 1);\n } else {\n isSelectionAfterElement = true;\n }\n break;\n case 'Paragraph':\n const newSegments: ContentModelSegment[] = [];\n for (const segment of block.segments) {\n if (segment.segmentType == 'General') {\n pruneUnselectedModel(segment);\n if (segment.blocks.length > 0 || segment.isSelected) {\n newSegments.push(segment);\n }\n } else if (segment.isSelected && segment.segmentType != 'SelectionMarker') {\n newSegments.push(segment);\n }\n }\n block.segments = newSegments;\n if (block.segments.length == 0) {\n model.blocks.splice(index, 1);\n } else {\n isSelectionAfterElement = true;\n }\n break;\n case 'Table':\n const filteredRows: ContentModelTableRow[] = [];\n for (let i = 0; i < block.rows.length; i++) {\n const row = block.rows[i];\n for (let j = 0; j < row.cells.length; j++) {\n const cell = row.cells[j];\n if (!cell.isSelected) {\n pruneUnselectedModelInternal(cell, isSelectionAfterElement);\n } else {\n isSelectionAfterElement = true;\n }\n }\n\n const newCells: ContentModelTableCell[] = [];\n for (let k = 0; k < row.cells.length; k++) {\n const cell = row.cells[k];\n if (cell.isSelected || cell.blocks.length > 0) {\n newCells.push(cell);\n }\n }\n row.cells = newCells;\n\n if (row.cells.length > 0) {\n filteredRows.push(row);\n }\n }\n\n if (\n !isSelectionAfterElement &&\n filteredRows.length == 1 &&\n filteredRows[0].cells.length == 1 &&\n !filteredRows[0].cells[0].isSelected\n ) {\n const cell = filteredRows[0].cells[0];\n model.blocks.splice(index, 1, ...cell.blocks);\n } else if (filteredRows.length == 0) {\n model.blocks.splice(index, 1);\n } else {\n block.rows = filteredRows;\n }\n break;\n }\n }\n return isSelectionAfterElement;\n}\n\nfunction unwrap(model: ContentModelBlockGroupBase<ContentModelBlockGroupType, HTMLElement>) {\n let block = model.blocks[0];\n if (model.blocks.length == 1) {\n while (block.blockType == 'BlockGroup') {\n model.blocks = block.blocks;\n block = model.blocks[0];\n\n if (model.blocks.length > 1) {\n return;\n }\n }\n\n if (block.blockType == 'Paragraph') {\n block.isImplicit = true;\n block.format = {};\n inheritSegmentFormatToChildren(block);\n }\n }\n}\n\nfunction inheritSegmentFormatToChildren(parent: ContentModelParagraph) {\n const value = parent.segmentFormat;\n if (value !== undefined) {\n for (let index = 0; index < parent.segments.length; index++) {\n const segment = parent.segments[index];\n segment.format = {\n ...parent.segmentFormat,\n ...segment.format,\n };\n }\n }\n}\n"]}