@hailin-zheng/editor-core 2.2.25 → 2.2.27
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 +109 -18
- package/index-cjs.js.map +1 -1
- package/index.js +109 -19
- package/index.js.map +1 -1
- package/med_editor/doc-editor.d.ts +6 -0
- package/med_editor/framework/document-change.d.ts +13 -1
- package/med_editor/framework/element-props.d.ts +3 -2
- package/package.json +1 -1
package/index-cjs.js
CHANGED
@@ -2604,9 +2604,9 @@ class DataEleListProps extends DataEleBaseTextProps {
|
|
2604
2604
|
}
|
2605
2605
|
options = [];
|
2606
2606
|
/**
|
2607
|
-
*
|
2607
|
+
* 是否持久化选项到病历文件里面
|
2608
2608
|
*/
|
2609
|
-
|
2609
|
+
persistItems = true;
|
2610
2610
|
dropDownStyle;
|
2611
2611
|
/**
|
2612
2612
|
* 是否允许多选
|
@@ -2620,28 +2620,41 @@ class DataEleListProps extends DataEleBaseTextProps {
|
|
2620
2620
|
clone.dropDownStyle = this.dropDownStyle;
|
2621
2621
|
clone.multiSelect = this.multiSelect;
|
2622
2622
|
clone.displayField = this.displayField;
|
2623
|
+
clone.persistItems = this.persistItems;
|
2623
2624
|
return clone;
|
2624
2625
|
}
|
2625
2626
|
getSerializeProps(options) {
|
2626
2627
|
const props = {
|
2627
|
-
options: [...this.options],
|
2628
2628
|
multiSelect: this.multiSelect,
|
2629
2629
|
dropDownStyle: this.dropDownStyle,
|
2630
|
+
persistItems: this.persistItems,
|
2630
2631
|
};
|
2631
2632
|
if (this.displayField && this.displayField !== 'value') {
|
2632
2633
|
props['displayField'] = this.displayField;
|
2633
2634
|
}
|
2635
|
+
if (this.persistItems) {
|
2636
|
+
props.options = [...this.options];
|
2637
|
+
}
|
2634
2638
|
super.getBaseProps(props, options);
|
2635
2639
|
return props;
|
2636
2640
|
}
|
2637
2641
|
updateProps(props) {
|
2638
2642
|
super.updateProps(props);
|
2639
|
-
this
|
2640
|
-
this.multiSelect = props.multiSelect;
|
2641
|
-
this.dropDownStyle = props.dropDownStyle;
|
2642
|
-
this.displayField = props.displayField;
|
2643
|
+
updatePartialProps(this, props);
|
2643
2644
|
}
|
2644
2645
|
}
|
2646
|
+
function updatePartialProps(destProps, sourceProps) {
|
2647
|
+
const destPropsKeys = Object.keys(destProps);
|
2648
|
+
const sourcePropsKeys = Object.keys(sourceProps);
|
2649
|
+
sourcePropsKeys.forEach(key => {
|
2650
|
+
if (destPropsKeys.includes(key)) {
|
2651
|
+
if (destProps[key] === sourceProps[key]) {
|
2652
|
+
return;
|
2653
|
+
}
|
2654
|
+
destProps[key] = sourceProps[key];
|
2655
|
+
}
|
2656
|
+
});
|
2657
|
+
}
|
2645
2658
|
class CommContentProps extends INotifyPropertyChanged {
|
2646
2659
|
id;
|
2647
2660
|
createId;
|
@@ -9408,6 +9421,7 @@ class DataElementListFactory extends DataElementBaseFactory {
|
|
9408
9421
|
dataEleProps.options = [...options];
|
9409
9422
|
dataEleProps.dropDownStyle = props.dropDownStyle;
|
9410
9423
|
dataEleProps.displayField = props.displayField ?? 'value';
|
9424
|
+
dataEleProps.persistItems = props.persistItems ?? true;
|
9411
9425
|
return dataEleProps;
|
9412
9426
|
}
|
9413
9427
|
}
|
@@ -18653,18 +18667,45 @@ class DocumentChange {
|
|
18653
18667
|
*/
|
18654
18668
|
insertElement(targetElement, targetOffset, destEleArray) {
|
18655
18669
|
let lastEle;
|
18670
|
+
//创建文本元素并插入
|
18671
|
+
const insertNewText = (text, parent, index) => {
|
18672
|
+
const inputTextProps = this.getDefaultTextPropsByOptions();
|
18673
|
+
const newTextEle = ElementUtil.getNewTextGroup(inputTextProps);
|
18674
|
+
newTextEle.text = text;
|
18675
|
+
parent.addChild(newTextEle, index);
|
18676
|
+
};
|
18656
18677
|
if (targetElement instanceof TextGroupElement) {
|
18657
18678
|
const { leftElement, rightElement } = this.splitText(targetElement, targetOffset);
|
18658
18679
|
if (leftElement) {
|
18659
18680
|
for (let i = 0; i < destEleArray.length; i++) {
|
18660
18681
|
lastEle = destEleArray[i];
|
18661
|
-
|
18682
|
+
//判断是否可以插入元素
|
18683
|
+
if (this.canInsertElement(leftElement.parent, lastEle)) {
|
18684
|
+
leftElement.parent.addChild(lastEle, leftElement.getIndex() + 1 + i);
|
18685
|
+
}
|
18686
|
+
else {
|
18687
|
+
//序列化为纯文本
|
18688
|
+
const serializeString = ElementSerialize.serializeString(lastEle);
|
18689
|
+
if (serializeString) {
|
18690
|
+
insertNewText(serializeString, leftElement.parent, leftElement.getIndex() + 1 + i);
|
18691
|
+
}
|
18692
|
+
}
|
18662
18693
|
}
|
18663
18694
|
}
|
18664
18695
|
else if (rightElement) {
|
18665
18696
|
for (let i = 0; i < destEleArray.length; i++) {
|
18666
18697
|
lastEle = destEleArray[i];
|
18667
|
-
|
18698
|
+
//判断是否可以插入元素
|
18699
|
+
if (this.canInsertElement(rightElement.parent, lastEle)) {
|
18700
|
+
rightElement.parent.addChild(lastEle, rightElement.getIndex());
|
18701
|
+
}
|
18702
|
+
else {
|
18703
|
+
//序列化为纯文本
|
18704
|
+
const serializeString = ElementSerialize.serializeString(lastEle);
|
18705
|
+
if (serializeString) {
|
18706
|
+
insertNewText(serializeString, rightElement.parent, rightElement.getIndex());
|
18707
|
+
}
|
18708
|
+
}
|
18668
18709
|
}
|
18669
18710
|
}
|
18670
18711
|
}
|
@@ -18673,13 +18714,39 @@ class DocumentChange {
|
|
18673
18714
|
let insertTargetOffset = targetOffset;
|
18674
18715
|
for (let i = 0; i < destEleArray.length; i++) {
|
18675
18716
|
lastEle = destEleArray[i];
|
18676
|
-
|
18677
|
-
insertTarget
|
18678
|
-
|
18717
|
+
//判断是否可以插入元素
|
18718
|
+
if (this.canInsertElement(insertTarget.parent, lastEle)) {
|
18719
|
+
insertTarget.parent.addChild(lastEle, insertTarget.getIndex() + insertTargetOffset);
|
18720
|
+
insertTarget = lastEle;
|
18721
|
+
insertTargetOffset = 1;
|
18722
|
+
}
|
18679
18723
|
}
|
18680
18724
|
}
|
18681
18725
|
return lastEle;
|
18682
18726
|
}
|
18727
|
+
/**
|
18728
|
+
* 校验容器是否允许插入元素
|
18729
|
+
* @param container
|
18730
|
+
* @param ele
|
18731
|
+
* @returns
|
18732
|
+
*/
|
18733
|
+
canInsertElement(container, ele) {
|
18734
|
+
//是否为数据元
|
18735
|
+
const isDataEle = container instanceof DataElementInlineGroup;
|
18736
|
+
//数据元内部不能嵌套数据元
|
18737
|
+
if (isDataEle && ele instanceof DataElementInlineGroup) {
|
18738
|
+
return false;
|
18739
|
+
}
|
18740
|
+
//非布局元素不可以插入段落
|
18741
|
+
if (!(container instanceof BlockContainerElement) && ele instanceof BlockContentElement) {
|
18742
|
+
return false;
|
18743
|
+
}
|
18744
|
+
//段落内容内不能插入布局元素
|
18745
|
+
if (!(container instanceof BlockContentElement) && ele instanceof BlockContainerElement) {
|
18746
|
+
return false;
|
18747
|
+
}
|
18748
|
+
return true;
|
18749
|
+
}
|
18683
18750
|
/**
|
18684
18751
|
* 根据开始位置和结束位置,将字符切割成指定的区间
|
18685
18752
|
* @param text
|
@@ -18935,10 +19002,7 @@ class DocumentChange {
|
|
18935
19002
|
}
|
18936
19003
|
//表单模式:如果复制的是单格式的文本,需要序列化为纯文本处理
|
18937
19004
|
if (this.viewOptions.docMode === exports.DocMode.FormEdit) {
|
18938
|
-
|
18939
|
-
if (pasteString) {
|
18940
|
-
this.pastePlainText(pasteString);
|
18941
|
-
}
|
19005
|
+
this.handlePasteInFormEditMode(pasteEles);
|
18942
19006
|
return;
|
18943
19007
|
}
|
18944
19008
|
//复制的内容为表格,且操作位于单元格内
|
@@ -18966,6 +19030,23 @@ class DocumentChange {
|
|
18966
19030
|
this.selectionState.resetRange(lastEle, -1);
|
18967
19031
|
}
|
18968
19032
|
}
|
19033
|
+
/**
|
19034
|
+
* 处理表单模式下的粘贴事件
|
19035
|
+
* @param data 要粘贴的元素
|
19036
|
+
*/
|
19037
|
+
handlePasteInFormEditMode(data) {
|
19038
|
+
// if (data.some(item => this.canInsertElement()))
|
19039
|
+
// const pasteString = data.map(item => ElementSerialize.serializeString(item)).join('');
|
19040
|
+
// if (pasteString) {
|
19041
|
+
// this.pastePlainText(pasteString);
|
19042
|
+
// }
|
19043
|
+
const { startControl, startOffset } = this.selectionState;
|
19044
|
+
const lastEle = this.insertElement(startControl, startOffset, data);
|
19045
|
+
this.selectionState.clear();
|
19046
|
+
if (lastEle && lastEle.parent) {
|
19047
|
+
this.selectionState.resetRange(lastEle, -1);
|
19048
|
+
}
|
19049
|
+
}
|
18969
19050
|
/**
|
18970
19051
|
* 复制单元格向另一个单元格粘贴
|
18971
19052
|
* @private
|
@@ -21713,12 +21794,13 @@ class DocEditor {
|
|
21713
21794
|
// if (this.docCtx.refreshType) {
|
21714
21795
|
// this.triggerDocChange();
|
21715
21796
|
// }
|
21797
|
+
const trackChangeState = this.trackChangeState;
|
21716
21798
|
this.flushTask = () => {
|
21717
21799
|
//读取变更记录,可能会同步影响文档内容
|
21718
21800
|
const isChanged = this.readDocChangeLog();
|
21719
21801
|
this.refreshDocument();
|
21720
21802
|
//触发文档改变
|
21721
|
-
if (isChanged) {
|
21803
|
+
if (isChanged && trackChangeState) {
|
21722
21804
|
this.triggerDocChange();
|
21723
21805
|
}
|
21724
21806
|
this.flushTask = null;
|
@@ -22041,6 +22123,14 @@ class DocEditor {
|
|
22041
22123
|
getDocSchema() {
|
22042
22124
|
return ElementSerialize.serialize(this.docCtx.document, this.viewOptions);
|
22043
22125
|
}
|
22126
|
+
/**
|
22127
|
+
* 获取元素模型
|
22128
|
+
* @param ele
|
22129
|
+
* @returns
|
22130
|
+
*/
|
22131
|
+
getEleSchemaJSON(ele) {
|
22132
|
+
return JSON.stringify(ElementSerialize.serialize(ele, this.viewOptions));
|
22133
|
+
}
|
22044
22134
|
getDocSchemaJSON() {
|
22045
22135
|
const res = JSON.stringify(this.getDocSchema());
|
22046
22136
|
return res;
|
@@ -23051,7 +23141,7 @@ class DocEditor {
|
|
23051
23141
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
23052
23142
|
}
|
23053
23143
|
version() {
|
23054
|
-
return "2.2.
|
23144
|
+
return "2.2.27";
|
23055
23145
|
}
|
23056
23146
|
switchPageHeaderEditor() {
|
23057
23147
|
this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
|
@@ -29086,6 +29176,7 @@ exports.textLineRenderMode = textLineRenderMode;
|
|
29086
29176
|
exports.toRawType = toRawType;
|
29087
29177
|
exports.toTypeString = toTypeString;
|
29088
29178
|
exports.trueChar = trueChar;
|
29179
|
+
exports.updatePartialProps = updatePartialProps;
|
29089
29180
|
exports.validateDataEle = validateDataEle;
|
29090
29181
|
exports.validateDataEleRenderObj = validateDataEleRenderObj;
|
29091
29182
|
exports.validateDataGroup = validateDataGroup;
|