@hailin-zheng/editor-core 1.1.28 → 1.1.29
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/index-cjs.js +59 -27
- package/index-cjs.js.map +1 -1
- package/index.js +59 -27
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
@@ -4950,7 +4950,7 @@ class TableUtil {
|
|
4950
4950
|
let index = colIndex;
|
4951
4951
|
for (let i = colIndex + 1; i < tb.getColsCount(); i++) {
|
4952
4952
|
const cell = currRow.getChild(i);
|
4953
|
-
if (cell.props.hMerge === 'continue') {
|
4953
|
+
if (cell && cell.props.hMerge === 'continue') {
|
4954
4954
|
index = i;
|
4955
4955
|
}
|
4956
4956
|
else {
|
@@ -5088,6 +5088,9 @@ class TableUtil {
|
|
5088
5088
|
}
|
5089
5089
|
}
|
5090
5090
|
tb.removeChild(row);
|
5091
|
+
if (tb.length === 0) {
|
5092
|
+
tb.remove();
|
5093
|
+
}
|
5091
5094
|
}
|
5092
5095
|
/**
|
5093
5096
|
* 移除列
|
@@ -5129,15 +5132,31 @@ class TableUtil {
|
|
5129
5132
|
if (!ss.startControl) {
|
5130
5133
|
return;
|
5131
5134
|
}
|
5132
|
-
const
|
5133
|
-
if (!
|
5134
|
-
|
5135
|
+
const tb = ElementUtil.getParentByType(ss.startControl, TableElement);
|
5136
|
+
if (!tb) {
|
5137
|
+
return;
|
5135
5138
|
}
|
5136
|
-
|
5137
|
-
|
5138
|
-
|
5139
|
-
|
5140
|
-
|
5139
|
+
if (ss.collapsed) {
|
5140
|
+
const startCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
|
5141
|
+
if (!startCell?.parent) {
|
5142
|
+
throw new Error('parent is null');
|
5143
|
+
}
|
5144
|
+
const currRow = startCell.parent;
|
5145
|
+
this.removeRow(currRow);
|
5146
|
+
}
|
5147
|
+
else {
|
5148
|
+
if (!ss.selectedRange || ss.selectedRange.target !== tb) {
|
5149
|
+
return;
|
5150
|
+
}
|
5151
|
+
const selectedRows = [];
|
5152
|
+
ss.selectedRange.selectedChildren.forEach(child => {
|
5153
|
+
if (child.target instanceof TableRowElement) {
|
5154
|
+
selectedRows.push(child.target);
|
5155
|
+
}
|
5156
|
+
});
|
5157
|
+
if (selectedRows.length) {
|
5158
|
+
selectedRows.forEach(row => this.removeRow(row));
|
5159
|
+
}
|
5141
5160
|
}
|
5142
5161
|
ss.clear();
|
5143
5162
|
}
|
@@ -5147,32 +5166,46 @@ class TableUtil {
|
|
5147
5166
|
*/
|
5148
5167
|
static removeCurrCol(ss) {
|
5149
5168
|
const startCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
|
5150
|
-
if (!startCell
|
5151
|
-
|
5169
|
+
if (!startCell) {
|
5170
|
+
return;
|
5152
5171
|
}
|
5172
|
+
let startColIndex = 0;
|
5173
|
+
let endColIndex = 0;
|
5153
5174
|
if (ss.collapsed) {
|
5154
5175
|
const currRow = startCell.parent;
|
5155
5176
|
const tb = currRow.parent;
|
5156
|
-
|
5177
|
+
startColIndex = startCell.getIndex();
|
5178
|
+
endColIndex = this.getHMergeEndIndex(tb, currRow.getIndex(), startColIndex);
|
5179
|
+
while (startColIndex <= endColIndex) {
|
5180
|
+
this.removeCol(tb, endColIndex);
|
5181
|
+
endColIndex--;
|
5182
|
+
}
|
5157
5183
|
ss.clear();
|
5158
5184
|
return;
|
5159
5185
|
}
|
5160
|
-
|
5161
|
-
|
5162
|
-
|
5163
|
-
|
5164
|
-
|
5165
|
-
|
5166
|
-
|
5167
|
-
|
5168
|
-
|
5169
|
-
|
5170
|
-
endColIndex
|
5186
|
+
else {
|
5187
|
+
const { ancestorCommonControl, startControl, endControl } = ss;
|
5188
|
+
if (ancestorCommonControl instanceof TableElement || ancestorCommonControl instanceof TableRowElement) {
|
5189
|
+
const tb = ancestorCommonControl instanceof TableElement ? ancestorCommonControl : ancestorCommonControl.parent;
|
5190
|
+
const startCell = ElementUtil.getParentByType(startControl, TableCellElement);
|
5191
|
+
const endCell = ElementUtil.getParentByType(endControl, TableCellElement);
|
5192
|
+
if (startCell?.parent?.parent === tb && endCell?.parent?.parent === tb) {
|
5193
|
+
const startColIndex = startCell.getIndex();
|
5194
|
+
let endColIndex = this.getHMergeEndIndex(tb, endCell.parent.getIndex(), endCell.getIndex());
|
5195
|
+
//选中所有的列,直接删除表格
|
5196
|
+
if (startColIndex === 0 && endColIndex === tb.props.cols.length - 1) {
|
5197
|
+
tb.remove();
|
5198
|
+
ss.clear();
|
5199
|
+
return;
|
5200
|
+
}
|
5201
|
+
while (startColIndex <= endColIndex) {
|
5202
|
+
this.removeCol(tb, endColIndex);
|
5203
|
+
endColIndex--;
|
5204
|
+
}
|
5171
5205
|
}
|
5172
5206
|
}
|
5173
|
-
|
5207
|
+
ss.clear();
|
5174
5208
|
}
|
5175
|
-
ss.clear();
|
5176
5209
|
}
|
5177
5210
|
/**
|
5178
5211
|
* 合并单元格
|
@@ -5735,7 +5768,7 @@ class TableElement extends BlockContainerElement {
|
|
5735
5768
|
this.props.cols = cols;
|
5736
5769
|
}
|
5737
5770
|
getColsCount() {
|
5738
|
-
return this.
|
5771
|
+
return this.props.cols.length;
|
5739
5772
|
}
|
5740
5773
|
clone(data) {
|
5741
5774
|
const clone = new TableElement();
|
@@ -5995,7 +6028,6 @@ class ElementSerialize {
|
|
5995
6028
|
prevEle = { ele: child, props: serializeChild };
|
5996
6029
|
}
|
5997
6030
|
}
|
5998
|
-
return result;
|
5999
6031
|
}
|
6000
6032
|
if (element.props && element.props['__attachedProperty'] && !result.props['__attachedProperty']) {
|
6001
6033
|
result.props['__attachedProperty'] = CommonUtil.cloneValue(element.props['__attachedProperty']);
|