@hailin-zheng/editor-core 2.2.9 → 2.2.11
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 +126 -28
- package/index-cjs.js.map +1 -1
- package/index.js +125 -29
- package/index.js.map +1 -1
- package/med_editor/doc-editor.d.ts +6 -1
- package/med_editor/framework/document-change.d.ts +1 -1
- package/med_editor/framework/document-context.d.ts +1 -0
- package/med_editor/framework/document-event.d.ts +6 -1
- package/med_editor/framework/element-define.d.ts +4 -0
- package/med_editor/framework/impl/data-element/data-element-group-impl.d.ts +10 -3
- package/med_editor/framework/util/element-util.d.ts +7 -0
- package/package.json +2 -2
package/index-cjs.js
CHANGED
@@ -1539,7 +1539,7 @@ class BranchElement extends Element {
|
|
1539
1539
|
}
|
1540
1540
|
treeFilter(predicate, options) {
|
1541
1541
|
if (!options) {
|
1542
|
-
options = { includeChildren:
|
1542
|
+
options = { includeChildren: false };
|
1543
1543
|
}
|
1544
1544
|
const items = [];
|
1545
1545
|
for (let i = 0; i < this.length; i++) {
|
@@ -1552,7 +1552,7 @@ class BranchElement extends Element {
|
|
1552
1552
|
}
|
1553
1553
|
}
|
1554
1554
|
if (item instanceof BranchElement) {
|
1555
|
-
items.push(...item.treeFilter(predicate));
|
1555
|
+
items.push(...item.treeFilter(predicate, options));
|
1556
1556
|
}
|
1557
1557
|
}
|
1558
1558
|
return items;
|
@@ -1737,6 +1737,8 @@ class ViewOptions {
|
|
1737
1737
|
dataDecoratorNormalColor = '#0050b3';
|
1738
1738
|
dataDecoratorMouseEnterColor = '#0050b3';
|
1739
1739
|
dataDecoratorFocusedColor = '#0050b3';
|
1740
|
+
//是否显示数据元修饰符
|
1741
|
+
showDataEleDecorator = true;
|
1740
1742
|
//数据元没有输入值时背景颜色
|
1741
1743
|
dataEleEmptyBgColor = '';
|
1742
1744
|
//数据元鼠标悬浮颜色
|
@@ -1747,7 +1749,14 @@ class ViewOptions {
|
|
1747
1749
|
dataEleFocusedBgColor = '#d9d9d9';
|
1748
1750
|
//数据元正常背景颜色
|
1749
1751
|
dataEleNormalBgColor = '#fafafa';
|
1752
|
+
//数据元错误背景颜色
|
1750
1753
|
dataEleErrorBgColor = '#ff4d4f';
|
1754
|
+
//数据元正常背景颜色
|
1755
|
+
dataGroupEleNormalBgColor = '';
|
1756
|
+
//数据元鼠标悬浮颜色
|
1757
|
+
dataGroupMouseEnterBgColor = '';
|
1758
|
+
//数据元只读背景颜色
|
1759
|
+
dataGroupFocusedBgColor = '';
|
1751
1760
|
viewBackcolor = 'rgb(230,230,230)';
|
1752
1761
|
paraSymbolColor = 'rgb(128,128,128)';
|
1753
1762
|
dataGroupColor = 'rgb(0,80,179)';
|
@@ -8701,7 +8710,7 @@ class BreakFactory extends ElementFactory {
|
|
8701
8710
|
}
|
8702
8711
|
}
|
8703
8712
|
|
8704
|
-
class DataElementGroupElement extends
|
8713
|
+
class DataElementGroupElement extends InlineGroupInputElement {
|
8705
8714
|
constructor() {
|
8706
8715
|
super('data-group');
|
8707
8716
|
this.props = new DataElementGroupProps();
|
@@ -8741,7 +8750,6 @@ class DataElementGroupElement extends DataElementInlineGroup {
|
|
8741
8750
|
});
|
8742
8751
|
}
|
8743
8752
|
}
|
8744
|
-
this.onChangedValidate();
|
8745
8753
|
}
|
8746
8754
|
getValue() {
|
8747
8755
|
return ElementSerialize.serializeString(this, { all: false });
|
@@ -8793,6 +8801,24 @@ class DataElementGroupFactory extends DataElementBaseFactory {
|
|
8793
8801
|
dataEleProps.dataType = props.dataType;
|
8794
8802
|
return dataEleProps;
|
8795
8803
|
}
|
8804
|
+
}
|
8805
|
+
/**
|
8806
|
+
* 是否在数据组内部
|
8807
|
+
* @param control
|
8808
|
+
* @param offset
|
8809
|
+
*/
|
8810
|
+
function IsInSideDataGroup(control, offset) {
|
8811
|
+
const mathEle = ElementUtil.getParent(control, (item) => item instanceof DataElementGroupElement);
|
8812
|
+
if (mathEle) {
|
8813
|
+
if ((control === mathEle.startDecorate && offset === 0) || (control === mathEle.endDecorate && offset === 1)) {
|
8814
|
+
return false;
|
8815
|
+
}
|
8816
|
+
return true;
|
8817
|
+
}
|
8818
|
+
return false;
|
8819
|
+
}
|
8820
|
+
function validateDataGroup(control) {
|
8821
|
+
return control instanceof DataElementGroupElement;
|
8796
8822
|
}
|
8797
8823
|
|
8798
8824
|
class DataElementImage extends DataElementLeaf {
|
@@ -12525,6 +12551,14 @@ class ElementUtil {
|
|
12525
12551
|
static getDataElement(ele) {
|
12526
12552
|
return this.getParent(ele, item => item instanceof DataElementInlineGroup);
|
12527
12553
|
}
|
12554
|
+
/**
|
12555
|
+
* 向上查找类型为数据元的父级
|
12556
|
+
* @param ele
|
12557
|
+
* @returns
|
12558
|
+
*/
|
12559
|
+
static getDataGroupElement(ele) {
|
12560
|
+
return this.getParent(ele, item => item instanceof DataElementGroupElement);
|
12561
|
+
}
|
12528
12562
|
static getOSPlatform() {
|
12529
12563
|
const userAgent = navigator.userAgent;
|
12530
12564
|
if (userAgent.indexOf('Windows') > -1) {
|
@@ -12673,23 +12707,35 @@ class ElementUtil {
|
|
12673
12707
|
if (startControl.paintRenders.length === 0) {
|
12674
12708
|
return false;
|
12675
12709
|
}
|
12710
|
+
if (!ElementUtil.verifyHitable(startControl)) {
|
12711
|
+
return false;
|
12712
|
+
}
|
12676
12713
|
if (viewOptions.docMode === exports.DocMode.Design) {
|
12677
12714
|
return true;
|
12678
12715
|
}
|
12679
|
-
|
12716
|
+
//表单模式下
|
12680
12717
|
if (viewOptions.docMode === exports.DocMode.FormEdit) {
|
12681
|
-
|
12682
|
-
|
12718
|
+
//如果光标在数据元素中,判断是否可编辑
|
12719
|
+
if (IsInSideDataElement(startControl, startOffset)) {
|
12720
|
+
const dataEle = ElementUtil.getDataElement(startControl);
|
12721
|
+
//数据元不可编辑
|
12722
|
+
if (dataEle && !dataEle.props.editable) {
|
12723
|
+
return false;
|
12724
|
+
}
|
12725
|
+
return true;
|
12683
12726
|
}
|
12684
|
-
|
12685
|
-
|
12686
|
-
|
12687
|
-
|
12688
|
-
|
12689
|
-
|
12690
|
-
|
12691
|
-
|
12692
|
-
|
12727
|
+
else {
|
12728
|
+
//不在数据元中,需要判断是否在数据组中
|
12729
|
+
if (IsInSideDataGroup(startControl, startOffset)) {
|
12730
|
+
const dataGroup = ElementUtil.getDataGroupElement(startControl);
|
12731
|
+
//数据元不可编辑
|
12732
|
+
if (dataGroup && !dataGroup.props.editable) {
|
12733
|
+
return false;
|
12734
|
+
}
|
12735
|
+
}
|
12736
|
+
else {
|
12737
|
+
return false;
|
12738
|
+
}
|
12693
12739
|
}
|
12694
12740
|
}
|
12695
12741
|
return true;
|
@@ -13369,17 +13415,20 @@ class DocumentContext {
|
|
13369
13415
|
this.ss = ss;
|
13370
13416
|
}
|
13371
13417
|
getControlIDList() {
|
13372
|
-
const dataEleList = this.ctx.treeFilter(item =>
|
13418
|
+
const dataEleList = this.ctx.treeFilter(item => this.isDataEle(item));
|
13373
13419
|
return dataEleList.map(item => item.props.id);
|
13374
13420
|
}
|
13375
13421
|
getControlInstanceList(options) {
|
13376
|
-
return this.ctx.treeFilter(item =>
|
13422
|
+
return this.ctx.treeFilter(item => this.isDataEle(item), options);
|
13377
13423
|
}
|
13378
13424
|
getControlById(id) {
|
13379
|
-
return this.ctx.treeFind(item =>
|
13425
|
+
return this.ctx.treeFind(item => this.isDataEle(item) && item['props']['id'] === id);
|
13426
|
+
}
|
13427
|
+
isDataEle(ele) {
|
13428
|
+
return validateDataEle(ele) || ele instanceof DataElementGroupElement;
|
13380
13429
|
}
|
13381
13430
|
getControlByName(name) {
|
13382
|
-
return this.ctx.treeFind(item =>
|
13431
|
+
return this.ctx.treeFind(item => this.isDataEle(item) && item['props']['name'] === name);
|
13383
13432
|
}
|
13384
13433
|
/**
|
13385
13434
|
* 获取数据元值集合
|
@@ -13397,7 +13446,7 @@ class DocumentContext {
|
|
13397
13446
|
* @returns
|
13398
13447
|
*/
|
13399
13448
|
getDataElementModelList(options) {
|
13400
|
-
const dataEleList = this.ctx.treeFilter(item =>
|
13449
|
+
const dataEleList = this.ctx.treeFilter(item => this.isDataEle(item), options);
|
13401
13450
|
//数据元、数据组
|
13402
13451
|
const dataInlineGroups = dataEleList.filter(item => item instanceof DataElementInlineGroup);
|
13403
13452
|
const dataLeafs = dataEleList.filter(item => item instanceof DataElementLeaf);
|
@@ -15471,12 +15520,12 @@ class DocumentEvent {
|
|
15471
15520
|
},
|
15472
15521
|
mouseup: (evt) => {
|
15473
15522
|
this.mouseup(evt, ElementUtil.getMousePos(evt, scale));
|
15474
|
-
this.mouseClickHandle(evt);
|
15523
|
+
//this.mouseClickHandle(evt);
|
15475
15524
|
},
|
15476
15525
|
click: (evt) => {
|
15477
15526
|
//nulltext 不触发 click 事件,暂且这么处理
|
15478
15527
|
//移到 mouseup 事件中处理
|
15479
|
-
|
15528
|
+
this.mouseClickHandle(evt);
|
15480
15529
|
},
|
15481
15530
|
mousemove: (evt) => {
|
15482
15531
|
this.mousemove(evt, ElementUtil.getMousePos(evt, scale));
|
@@ -16703,6 +16752,30 @@ class DocumentEvent {
|
|
16703
16752
|
}
|
16704
16753
|
return null;
|
16705
16754
|
}
|
16755
|
+
/**
|
16756
|
+
* 获取当前光标所在的数据组
|
16757
|
+
* @returns
|
16758
|
+
*/
|
16759
|
+
getCurrentDataGroupElement(mode = 'strict') {
|
16760
|
+
const selectionState = this.selectionState;
|
16761
|
+
const { startControl, startOffset, collapsed, ancestorCommonControl } = selectionState;
|
16762
|
+
if (startControl && collapsed) {
|
16763
|
+
// if (!ElementUtil.verifyHitable(startControl)) {
|
16764
|
+
// return null;
|
16765
|
+
// }
|
16766
|
+
const dataEle = ElementUtil.getParent(startControl, validateDataGroup);
|
16767
|
+
if (mode === 'free' || IsInSideDataGroup(startControl, startOffset)) {
|
16768
|
+
return dataEle;
|
16769
|
+
}
|
16770
|
+
else {
|
16771
|
+
return null;
|
16772
|
+
}
|
16773
|
+
}
|
16774
|
+
else if (!collapsed && ancestorCommonControl) {
|
16775
|
+
return ElementUtil.getParent(ancestorCommonControl, validateDataGroup);
|
16776
|
+
}
|
16777
|
+
return null;
|
16778
|
+
}
|
16706
16779
|
}
|
16707
16780
|
|
16708
16781
|
/**
|
@@ -17531,8 +17604,12 @@ class DocumentChange {
|
|
17531
17604
|
* @private
|
17532
17605
|
*/
|
17533
17606
|
canDeleteInlineGroup(dataEle) {
|
17607
|
+
//当前编辑模式为表单模式,单独的数据元不可删除
|
17608
|
+
//存在于数据组内的数据元可以删除
|
17534
17609
|
if (this.viewOptions.docMode === exports.DocMode.FormEdit) {
|
17535
|
-
|
17610
|
+
if (dataEle.parent.type !== 'data-group') {
|
17611
|
+
return false;
|
17612
|
+
}
|
17536
17613
|
}
|
17537
17614
|
return dataEle.length === 2;
|
17538
17615
|
}
|
@@ -17847,6 +17924,14 @@ class DocumentChange {
|
|
17847
17924
|
}
|
17848
17925
|
return;
|
17849
17926
|
}
|
17927
|
+
const dataGroup = ElementUtil.getDataGroupElement(range.target);
|
17928
|
+
if (dataGroup) {
|
17929
|
+
this.deleteRange(range);
|
17930
|
+
if (!startPointElement || ElementUtil.getParent(startPointElement, item => validateDataGroup(item)) !== dataGroup) {
|
17931
|
+
this.selectionState.resetRange(dataGroup.startDecorate, 1);
|
17932
|
+
}
|
17933
|
+
return;
|
17934
|
+
}
|
17850
17935
|
//在数据元外删除
|
17851
17936
|
else {
|
17852
17937
|
this.loopForDelDataEleRange(range);
|
@@ -18462,9 +18547,13 @@ class DocumentChange {
|
|
18462
18547
|
}
|
18463
18548
|
getCursorElementByDeleteAction(control) {
|
18464
18549
|
if (this.viewOptions.docMode === exports.DocMode.FormEdit) {
|
18465
|
-
|
18550
|
+
//是否属于数据元或者数据组区域
|
18551
|
+
const isInDataAre = (ele) => {
|
18552
|
+
return ele.parent instanceof DataElementInlineGroup || ele.parent instanceof DataElementGroupElement;
|
18553
|
+
};
|
18554
|
+
if (isInDataAre(control)) {
|
18466
18555
|
const prevLeafElementInPara = ElementUtil.getRecursionPrevSiblingElement(control, true, true, this.viewOptions);
|
18467
|
-
if (prevLeafElementInPara &&
|
18556
|
+
if (prevLeafElementInPara && isInDataAre(prevLeafElementInPara)) {
|
18468
18557
|
return {
|
18469
18558
|
ele: prevLeafElementInPara,
|
18470
18559
|
offset: ElementUtil.getElementEndOffset(prevLeafElementInPara)
|
@@ -18472,7 +18561,7 @@ class DocumentChange {
|
|
18472
18561
|
}
|
18473
18562
|
else {
|
18474
18563
|
return {
|
18475
|
-
ele: control.parent.startDecorate,
|
18564
|
+
ele: (control.parent).startDecorate,
|
18476
18565
|
offset: 1
|
18477
18566
|
};
|
18478
18567
|
}
|
@@ -20951,6 +21040,13 @@ class DocEditor {
|
|
20951
21040
|
getCurrentDataElement() {
|
20952
21041
|
return this.documentEvent.getCurrentDataElement();
|
20953
21042
|
}
|
21043
|
+
/**
|
21044
|
+
* 回去当前光标所在数据组
|
21045
|
+
* @returns
|
21046
|
+
*/
|
21047
|
+
getCurrentDataGroupElement() {
|
21048
|
+
return this.documentEvent.getCurrentDataGroupElement();
|
21049
|
+
}
|
20954
21050
|
/**
|
20955
21051
|
* 移动光标到下一个数据元素上
|
20956
21052
|
*/
|
@@ -21984,7 +22080,7 @@ class DocEditor {
|
|
21984
22080
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
21985
22081
|
}
|
21986
22082
|
version() {
|
21987
|
-
return "2.2.
|
22083
|
+
return "2.2.11";
|
21988
22084
|
}
|
21989
22085
|
switchPageHeaderEditor() {
|
21990
22086
|
this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
|
@@ -27839,6 +27935,7 @@ exports.InlineGroupRenderObject = InlineGroupRenderObject;
|
|
27839
27935
|
exports.InlineMuiltBlockLineRenderObject = InlineMuiltBlockLineRenderObject;
|
27840
27936
|
exports.InputElementEvent = InputElementEvent;
|
27841
27937
|
exports.IsInSideDataElement = IsInSideDataElement;
|
27938
|
+
exports.IsInSideDataGroup = IsInSideDataGroup;
|
27842
27939
|
exports.IsInSideInlineGroupInputElement = IsInSideInlineGroupInputElement;
|
27843
27940
|
exports.KeyboradElementEvent = KeyboradElementEvent;
|
27844
27941
|
exports.LeafElement = LeafElement;
|
@@ -27965,6 +28062,7 @@ exports.toTypeString = toTypeString;
|
|
27965
28062
|
exports.trueChar = trueChar;
|
27966
28063
|
exports.validateDataEle = validateDataEle;
|
27967
28064
|
exports.validateDataEleRenderObj = validateDataEleRenderObj;
|
28065
|
+
exports.validateDataGroup = validateDataGroup;
|
27968
28066
|
exports.validateInlineInputRenderObj = validateInlineInputRenderObj;
|
27969
28067
|
exports.watchChanged = watchChanged;
|
27970
28068
|
//# sourceMappingURL=index-cjs.js.map
|