@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-cjs.js
CHANGED
@@ -4979,7 +4979,7 @@ class TableUtil {
|
|
4979
4979
|
let index = colIndex;
|
4980
4980
|
for (let i = colIndex + 1; i < tb.getColsCount(); i++) {
|
4981
4981
|
const cell = currRow.getChild(i);
|
4982
|
-
if (cell.props.hMerge === 'continue') {
|
4982
|
+
if (cell && cell.props.hMerge === 'continue') {
|
4983
4983
|
index = i;
|
4984
4984
|
}
|
4985
4985
|
else {
|
@@ -5117,6 +5117,9 @@ class TableUtil {
|
|
5117
5117
|
}
|
5118
5118
|
}
|
5119
5119
|
tb.removeChild(row);
|
5120
|
+
if (tb.length === 0) {
|
5121
|
+
tb.remove();
|
5122
|
+
}
|
5120
5123
|
}
|
5121
5124
|
/**
|
5122
5125
|
* 移除列
|
@@ -5158,15 +5161,31 @@ class TableUtil {
|
|
5158
5161
|
if (!ss.startControl) {
|
5159
5162
|
return;
|
5160
5163
|
}
|
5161
|
-
const
|
5162
|
-
if (!
|
5163
|
-
|
5164
|
+
const tb = ElementUtil.getParentByType(ss.startControl, TableElement);
|
5165
|
+
if (!tb) {
|
5166
|
+
return;
|
5164
5167
|
}
|
5165
|
-
|
5166
|
-
|
5167
|
-
|
5168
|
-
|
5169
|
-
|
5168
|
+
if (ss.collapsed) {
|
5169
|
+
const startCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
|
5170
|
+
if (!startCell?.parent) {
|
5171
|
+
throw new Error('parent is null');
|
5172
|
+
}
|
5173
|
+
const currRow = startCell.parent;
|
5174
|
+
this.removeRow(currRow);
|
5175
|
+
}
|
5176
|
+
else {
|
5177
|
+
if (!ss.selectedRange || ss.selectedRange.target !== tb) {
|
5178
|
+
return;
|
5179
|
+
}
|
5180
|
+
const selectedRows = [];
|
5181
|
+
ss.selectedRange.selectedChildren.forEach(child => {
|
5182
|
+
if (child.target instanceof TableRowElement) {
|
5183
|
+
selectedRows.push(child.target);
|
5184
|
+
}
|
5185
|
+
});
|
5186
|
+
if (selectedRows.length) {
|
5187
|
+
selectedRows.forEach(row => this.removeRow(row));
|
5188
|
+
}
|
5170
5189
|
}
|
5171
5190
|
ss.clear();
|
5172
5191
|
}
|
@@ -5176,32 +5195,46 @@ class TableUtil {
|
|
5176
5195
|
*/
|
5177
5196
|
static removeCurrCol(ss) {
|
5178
5197
|
const startCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
|
5179
|
-
if (!startCell
|
5180
|
-
|
5198
|
+
if (!startCell) {
|
5199
|
+
return;
|
5181
5200
|
}
|
5201
|
+
let startColIndex = 0;
|
5202
|
+
let endColIndex = 0;
|
5182
5203
|
if (ss.collapsed) {
|
5183
5204
|
const currRow = startCell.parent;
|
5184
5205
|
const tb = currRow.parent;
|
5185
|
-
|
5206
|
+
startColIndex = startCell.getIndex();
|
5207
|
+
endColIndex = this.getHMergeEndIndex(tb, currRow.getIndex(), startColIndex);
|
5208
|
+
while (startColIndex <= endColIndex) {
|
5209
|
+
this.removeCol(tb, endColIndex);
|
5210
|
+
endColIndex--;
|
5211
|
+
}
|
5186
5212
|
ss.clear();
|
5187
5213
|
return;
|
5188
5214
|
}
|
5189
|
-
|
5190
|
-
|
5191
|
-
|
5192
|
-
|
5193
|
-
|
5194
|
-
|
5195
|
-
|
5196
|
-
|
5197
|
-
|
5198
|
-
|
5199
|
-
endColIndex
|
5215
|
+
else {
|
5216
|
+
const { ancestorCommonControl, startControl, endControl } = ss;
|
5217
|
+
if (ancestorCommonControl instanceof TableElement || ancestorCommonControl instanceof TableRowElement) {
|
5218
|
+
const tb = ancestorCommonControl instanceof TableElement ? ancestorCommonControl : ancestorCommonControl.parent;
|
5219
|
+
const startCell = ElementUtil.getParentByType(startControl, TableCellElement);
|
5220
|
+
const endCell = ElementUtil.getParentByType(endControl, TableCellElement);
|
5221
|
+
if (startCell?.parent?.parent === tb && endCell?.parent?.parent === tb) {
|
5222
|
+
const startColIndex = startCell.getIndex();
|
5223
|
+
let endColIndex = this.getHMergeEndIndex(tb, endCell.parent.getIndex(), endCell.getIndex());
|
5224
|
+
//选中所有的列,直接删除表格
|
5225
|
+
if (startColIndex === 0 && endColIndex === tb.props.cols.length - 1) {
|
5226
|
+
tb.remove();
|
5227
|
+
ss.clear();
|
5228
|
+
return;
|
5229
|
+
}
|
5230
|
+
while (startColIndex <= endColIndex) {
|
5231
|
+
this.removeCol(tb, endColIndex);
|
5232
|
+
endColIndex--;
|
5233
|
+
}
|
5200
5234
|
}
|
5201
5235
|
}
|
5202
|
-
|
5236
|
+
ss.clear();
|
5203
5237
|
}
|
5204
|
-
ss.clear();
|
5205
5238
|
}
|
5206
5239
|
/**
|
5207
5240
|
* 合并单元格
|
@@ -5764,7 +5797,7 @@ class TableElement extends BlockContainerElement {
|
|
5764
5797
|
this.props.cols = cols;
|
5765
5798
|
}
|
5766
5799
|
getColsCount() {
|
5767
|
-
return this.
|
5800
|
+
return this.props.cols.length;
|
5768
5801
|
}
|
5769
5802
|
clone(data) {
|
5770
5803
|
const clone = new TableElement();
|
@@ -5992,11 +6025,14 @@ class ElementSerialize {
|
|
5992
6025
|
* @param viewOptions
|
5993
6026
|
*/
|
5994
6027
|
static serialize(element, viewOptions) {
|
6028
|
+
const result = element.serialize(viewOptions);
|
6029
|
+
if (!result) {
|
6030
|
+
return null;
|
6031
|
+
}
|
6032
|
+
if (result.complete) {
|
6033
|
+
return result;
|
6034
|
+
}
|
5995
6035
|
if (element instanceof BranchElement) {
|
5996
|
-
const result = element.serialize(viewOptions);
|
5997
|
-
if (!result || result.complete) {
|
5998
|
-
return result;
|
5999
|
-
}
|
6000
6036
|
result.children = [];
|
6001
6037
|
let prevEle = null;
|
6002
6038
|
for (let i = 0; i < element.length; i++) {
|
@@ -6011,9 +6047,6 @@ class ElementSerialize {
|
|
6011
6047
|
if (serializeChild) {
|
6012
6048
|
delete serializeChild.complete;
|
6013
6049
|
serializeChild.props = serializeChild.props || {};
|
6014
|
-
if (child.props && child.props['__attachedProperty']) {
|
6015
|
-
serializeChild.props['__attachedProperty'] = CommonUtil.cloneValue(child.props['__attachedProperty']);
|
6016
|
-
}
|
6017
6050
|
if (Object.keys(serializeChild.props).length === 0) {
|
6018
6051
|
delete serializeChild.props;
|
6019
6052
|
}
|
@@ -6024,11 +6057,11 @@ class ElementSerialize {
|
|
6024
6057
|
prevEle = { ele: child, props: serializeChild };
|
6025
6058
|
}
|
6026
6059
|
}
|
6027
|
-
return result;
|
6028
6060
|
}
|
6029
|
-
|
6030
|
-
|
6061
|
+
if (element.props && element.props['__attachedProperty'] && !result.props['__attachedProperty']) {
|
6062
|
+
result.props['__attachedProperty'] = CommonUtil.cloneValue(element.props['__attachedProperty']);
|
6031
6063
|
}
|
6064
|
+
return result;
|
6032
6065
|
}
|
6033
6066
|
static serializeString(element, options = { all: false }) {
|
6034
6067
|
if (!options.all && element instanceof TrackRunElement && element.type === exports.TrackRunTypeEnum.Deleted) {
|