@hailin-zheng/editor-core 1.1.27 → 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 +69 -36
- package/index-cjs.js.map +1 -1
- package/index.js +69 -36
- 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();
|
@@ -5963,11 +5996,14 @@ class ElementSerialize {
|
|
5963
5996
|
* @param viewOptions
|
5964
5997
|
*/
|
5965
5998
|
static serialize(element, viewOptions) {
|
5999
|
+
const result = element.serialize(viewOptions);
|
6000
|
+
if (!result) {
|
6001
|
+
return null;
|
6002
|
+
}
|
6003
|
+
if (result.complete) {
|
6004
|
+
return result;
|
6005
|
+
}
|
5966
6006
|
if (element instanceof BranchElement) {
|
5967
|
-
const result = element.serialize(viewOptions);
|
5968
|
-
if (!result || result.complete) {
|
5969
|
-
return result;
|
5970
|
-
}
|
5971
6007
|
result.children = [];
|
5972
6008
|
let prevEle = null;
|
5973
6009
|
for (let i = 0; i < element.length; i++) {
|
@@ -5982,9 +6018,6 @@ class ElementSerialize {
|
|
5982
6018
|
if (serializeChild) {
|
5983
6019
|
delete serializeChild.complete;
|
5984
6020
|
serializeChild.props = serializeChild.props || {};
|
5985
|
-
if (child.props && child.props['__attachedProperty']) {
|
5986
|
-
serializeChild.props['__attachedProperty'] = CommonUtil.cloneValue(child.props['__attachedProperty']);
|
5987
|
-
}
|
5988
6021
|
if (Object.keys(serializeChild.props).length === 0) {
|
5989
6022
|
delete serializeChild.props;
|
5990
6023
|
}
|
@@ -5995,11 +6028,11 @@ class ElementSerialize {
|
|
5995
6028
|
prevEle = { ele: child, props: serializeChild };
|
5996
6029
|
}
|
5997
6030
|
}
|
5998
|
-
return result;
|
5999
6031
|
}
|
6000
|
-
|
6001
|
-
|
6032
|
+
if (element.props && element.props['__attachedProperty'] && !result.props['__attachedProperty']) {
|
6033
|
+
result.props['__attachedProperty'] = CommonUtil.cloneValue(element.props['__attachedProperty']);
|
6002
6034
|
}
|
6035
|
+
return result;
|
6003
6036
|
}
|
6004
6037
|
static serializeString(element, options = { all: false }) {
|
6005
6038
|
if (!options.all && element instanceof TrackRunElement && element.type === TrackRunTypeEnum.Deleted) {
|