@hailin-zheng/editor-core 1.1.28 → 1.1.30
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 +82 -47
- package/index-cjs.js.map +1 -1
- package/index.js +82 -47
- package/index.js.map +1 -1
- package/med_editor/framework/element-trace-tracking.d.ts +1 -0
- package/package.json +1 -1
package/index.js
CHANGED
@@ -673,13 +673,18 @@ function appendToOps(doc, ele, ops) {
|
|
673
673
|
docOpsMap.set(doc, array = []);
|
674
674
|
}
|
675
675
|
const prevEle = ElementUtil.getPrevSiblingElement(ele);
|
676
|
-
|
676
|
+
const log = {
|
677
677
|
index: ElementUtil.getControlIndex(ele, true),
|
678
678
|
parentIndex: ElementUtil.getControlIndex(ele.parent, true),
|
679
679
|
prevIndex: prevEle ? ElementUtil.getControlIndex(prevEle, true) : -1,
|
680
680
|
ele,
|
681
681
|
ops
|
682
|
-
}
|
682
|
+
};
|
683
|
+
if (log.prevIndex === -1) {
|
684
|
+
const nextEle = ElementUtil.getNextSiblingElement(ele);
|
685
|
+
log.nextIndex = nextEle ? ElementUtil.getControlIndex(nextEle, true) : -1;
|
686
|
+
}
|
687
|
+
array.push(log);
|
683
688
|
}
|
684
689
|
function inputText(ele, startIndex, input) {
|
685
690
|
const options = getDocCtx(ele);
|
@@ -3831,7 +3836,7 @@ class TableCellElement extends BlockContainerElement {
|
|
3831
3836
|
}
|
3832
3837
|
beginMeasure(data) {
|
3833
3838
|
//不被合并的单元格
|
3834
|
-
if (!this.length
|
3839
|
+
if (!this.length) {
|
3835
3840
|
this.addChild(data.createParaFn());
|
3836
3841
|
}
|
3837
3842
|
super.beginMeasure(data);
|
@@ -4950,7 +4955,7 @@ class TableUtil {
|
|
4950
4955
|
let index = colIndex;
|
4951
4956
|
for (let i = colIndex + 1; i < tb.getColsCount(); i++) {
|
4952
4957
|
const cell = currRow.getChild(i);
|
4953
|
-
if (cell.props.hMerge === 'continue') {
|
4958
|
+
if (cell && cell.props.hMerge === 'continue') {
|
4954
4959
|
index = i;
|
4955
4960
|
}
|
4956
4961
|
else {
|
@@ -5088,6 +5093,9 @@ class TableUtil {
|
|
5088
5093
|
}
|
5089
5094
|
}
|
5090
5095
|
tb.removeChild(row);
|
5096
|
+
if (tb.length === 0) {
|
5097
|
+
tb.remove();
|
5098
|
+
}
|
5091
5099
|
}
|
5092
5100
|
/**
|
5093
5101
|
* 移除列
|
@@ -5102,7 +5110,7 @@ class TableUtil {
|
|
5102
5110
|
const hMergeEndIndex = this.getHMergeEndIndex(tb, i, colIndex);
|
5103
5111
|
if (hMergeEndIndex > colIndex) {
|
5104
5112
|
const nextCell = row.getChild(colIndex + 1);
|
5105
|
-
nextCell.props.hMerge = hMergeEndIndex - colIndex
|
5113
|
+
nextCell.props.hMerge = hMergeEndIndex - colIndex >= 2 ? 'restart' : null;
|
5106
5114
|
}
|
5107
5115
|
}
|
5108
5116
|
else if (cell.props.hMerge === 'continue') {
|
@@ -5129,15 +5137,31 @@ class TableUtil {
|
|
5129
5137
|
if (!ss.startControl) {
|
5130
5138
|
return;
|
5131
5139
|
}
|
5132
|
-
const
|
5133
|
-
if (!
|
5134
|
-
|
5140
|
+
const tb = ElementUtil.getParentByType(ss.startControl, TableElement);
|
5141
|
+
if (!tb) {
|
5142
|
+
return;
|
5135
5143
|
}
|
5136
|
-
|
5137
|
-
|
5138
|
-
|
5139
|
-
|
5140
|
-
|
5144
|
+
if (ss.collapsed) {
|
5145
|
+
const startCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
|
5146
|
+
if (!startCell?.parent) {
|
5147
|
+
throw new Error('parent is null');
|
5148
|
+
}
|
5149
|
+
const currRow = startCell.parent;
|
5150
|
+
this.removeRow(currRow);
|
5151
|
+
}
|
5152
|
+
else {
|
5153
|
+
if (!ss.selectedRange || ss.selectedRange.target !== tb) {
|
5154
|
+
return;
|
5155
|
+
}
|
5156
|
+
const selectedRows = [];
|
5157
|
+
ss.selectedRange.selectedChildren.forEach(child => {
|
5158
|
+
if (child.target instanceof TableRowElement) {
|
5159
|
+
selectedRows.push(child.target);
|
5160
|
+
}
|
5161
|
+
});
|
5162
|
+
if (selectedRows.length) {
|
5163
|
+
selectedRows.forEach(row => this.removeRow(row));
|
5164
|
+
}
|
5141
5165
|
}
|
5142
5166
|
ss.clear();
|
5143
5167
|
}
|
@@ -5147,32 +5171,46 @@ class TableUtil {
|
|
5147
5171
|
*/
|
5148
5172
|
static removeCurrCol(ss) {
|
5149
5173
|
const startCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
|
5150
|
-
if (!startCell
|
5151
|
-
|
5174
|
+
if (!startCell) {
|
5175
|
+
return;
|
5152
5176
|
}
|
5177
|
+
let startColIndex = 0;
|
5178
|
+
let endColIndex = 0;
|
5153
5179
|
if (ss.collapsed) {
|
5154
5180
|
const currRow = startCell.parent;
|
5155
5181
|
const tb = currRow.parent;
|
5156
|
-
|
5182
|
+
startColIndex = startCell.getIndex();
|
5183
|
+
endColIndex = this.getHMergeEndIndex(tb, currRow.getIndex(), startColIndex);
|
5184
|
+
while (startColIndex <= endColIndex) {
|
5185
|
+
this.removeCol(tb, endColIndex);
|
5186
|
+
endColIndex--;
|
5187
|
+
}
|
5157
5188
|
ss.clear();
|
5158
5189
|
return;
|
5159
5190
|
}
|
5160
|
-
|
5161
|
-
|
5162
|
-
|
5163
|
-
|
5164
|
-
|
5165
|
-
|
5166
|
-
|
5167
|
-
|
5168
|
-
|
5169
|
-
|
5170
|
-
endColIndex
|
5191
|
+
else {
|
5192
|
+
const { ancestorCommonControl, startControl, endControl } = ss;
|
5193
|
+
if (ancestorCommonControl instanceof TableElement || ancestorCommonControl instanceof TableRowElement) {
|
5194
|
+
const tb = ancestorCommonControl instanceof TableElement ? ancestorCommonControl : ancestorCommonControl.parent;
|
5195
|
+
const startCell = ElementUtil.getParentByType(startControl, TableCellElement);
|
5196
|
+
const endCell = ElementUtil.getParentByType(endControl, TableCellElement);
|
5197
|
+
if (startCell?.parent?.parent === tb && endCell?.parent?.parent === tb) {
|
5198
|
+
const startColIndex = startCell.getIndex();
|
5199
|
+
let endColIndex = this.getHMergeEndIndex(tb, endCell.parent.getIndex(), endCell.getIndex());
|
5200
|
+
//选中所有的列,直接删除表格
|
5201
|
+
if (startColIndex === 0 && endColIndex === tb.props.cols.length - 1) {
|
5202
|
+
tb.remove();
|
5203
|
+
ss.clear();
|
5204
|
+
return;
|
5205
|
+
}
|
5206
|
+
while (startColIndex <= endColIndex) {
|
5207
|
+
this.removeCol(tb, endColIndex);
|
5208
|
+
endColIndex--;
|
5209
|
+
}
|
5171
5210
|
}
|
5172
5211
|
}
|
5173
|
-
|
5212
|
+
ss.clear();
|
5174
5213
|
}
|
5175
|
-
ss.clear();
|
5176
5214
|
}
|
5177
5215
|
/**
|
5178
5216
|
* 合并单元格
|
@@ -5735,7 +5773,7 @@ class TableElement extends BlockContainerElement {
|
|
5735
5773
|
this.props.cols = cols;
|
5736
5774
|
}
|
5737
5775
|
getColsCount() {
|
5738
|
-
return this.
|
5776
|
+
return this.props.cols.length;
|
5739
5777
|
}
|
5740
5778
|
clone(data) {
|
5741
5779
|
const clone = new TableElement();
|
@@ -5995,7 +6033,6 @@ class ElementSerialize {
|
|
5995
6033
|
prevEle = { ele: child, props: serializeChild };
|
5996
6034
|
}
|
5997
6035
|
}
|
5998
|
-
return result;
|
5999
6036
|
}
|
6000
6037
|
if (element.props && element.props['__attachedProperty'] && !result.props['__attachedProperty']) {
|
6001
6038
|
result.props['__attachedProperty'] = CommonUtil.cloneValue(element.props['__attachedProperty']);
|
@@ -14888,7 +14925,8 @@ class DocumentEvent {
|
|
14888
14925
|
if (!this.selectionState.cursorPos) {
|
14889
14926
|
return;
|
14890
14927
|
}
|
14891
|
-
let { x, y } = this.selectionState.cursorPos;
|
14928
|
+
let { x, y, height } = this.selectionState.cursorPos;
|
14929
|
+
y = y + (height / 2 * (up ? -1 : 1));
|
14892
14930
|
//y -= this.viewOptions.pageOffset.y;
|
14893
14931
|
for (let i = 0; i < 50; i++) {
|
14894
14932
|
const docEvent = new MouseElementEvent(this.docCtx);
|
@@ -15040,7 +15078,7 @@ class DocumentInput {
|
|
15040
15078
|
const evt = nodeEvt.sourceEvt;
|
15041
15079
|
const keyEvent = new KeyboradElementEvent(this.docCtx);
|
15042
15080
|
keyEvent.sourceEvent = evt;
|
15043
|
-
if (DocumentEvent.invokeEvent('ElementKeyDown', this.docCtx.selectionState.startControl, keyEvent, '
|
15081
|
+
if (DocumentEvent.invokeEvent('ElementKeyDown', this.docCtx.selectionState.startControl, keyEvent, 'All')) {
|
15044
15082
|
return;
|
15045
15083
|
}
|
15046
15084
|
if (evt.keyCode === 8) {
|
@@ -17275,28 +17313,25 @@ class ElementTrackManage {
|
|
17275
17313
|
}
|
17276
17314
|
}
|
17277
17315
|
restoreToInsert(index, parentIndex, prevIndex, data) {
|
17278
|
-
const prevSiblingEle = prevIndex !== -1 ? this.getControl(prevIndex) : null;
|
17316
|
+
const prevSiblingEle = prevIndex !== -1 ? this.getControl(prevIndex, true) : null;
|
17317
|
+
//const nextSiblingEle = prevSiblingEle ? prevSiblingEle.nextSibling : null;
|
17279
17318
|
//获取插入位置之前的元素,然后向后插入目标元素
|
17280
|
-
const ele = this.getControl(index - 1);
|
17319
|
+
//const ele = this.getControl(index - 1,true);
|
17320
|
+
const parent = this.getControl(parentIndex, true);
|
17281
17321
|
const target = data.clone(true);
|
17282
17322
|
if (prevSiblingEle) {
|
17283
17323
|
prevSiblingEle.parent.addChild(target, prevSiblingEle.getIndex() + 1);
|
17284
17324
|
}
|
17285
17325
|
else {
|
17286
|
-
|
17287
|
-
|
17288
|
-
|
17289
|
-
if (ele.type === 'tbc' && ele.getChildLength() === 2) {
|
17290
|
-
ele.clearItems();
|
17291
|
-
}
|
17292
|
-
ele.addChild(target, 0);
|
17293
|
-
return;
|
17294
|
-
}
|
17295
|
-
else {
|
17296
|
-
throw new Error('父级类型不正确');
|
17326
|
+
if (parent instanceof BranchElement) {
|
17327
|
+
if (parent.type === 'tbc' && parent.getChildLength() === 2) {
|
17328
|
+
parent.clearItems();
|
17297
17329
|
}
|
17330
|
+
parent.addChild(target, 0);
|
17331
|
+
}
|
17332
|
+
else {
|
17333
|
+
throw new Error('父级类型不正确');
|
17298
17334
|
}
|
17299
|
-
ele.parent.addChild(target, ele.getIndex() + 1);
|
17300
17335
|
}
|
17301
17336
|
}
|
17302
17337
|
/**
|