@hailin-zheng/editor-core 2.2.8 → 2.2.10
Sign up to get free protection for your applications and to get access to all the features.
- package/editor.css +3 -0
- package/index-cjs.js +173 -89
- package/index-cjs.js.map +1 -1
- package/index.js +173 -90
- package/index.js.map +1 -1
- package/med_editor/doc-editor.d.ts +1 -1
- package/med_editor/framework/document-change.d.ts +1 -1
- package/med_editor/framework/document-context.d.ts +6 -2
- package/med_editor/framework/element-define.d.ts +3 -1
- package/med_editor/framework/element-props.d.ts +1 -3
- package/med_editor/framework/impl/data-element/data-element-group-impl.d.ts +10 -1
- package/med_editor/framework/util/element-util.d.ts +7 -0
- package/package.json +2 -2
package/editor.css
CHANGED
package/index-cjs.js
CHANGED
@@ -1537,12 +1537,19 @@ class BranchElement extends Element {
|
|
1537
1537
|
}
|
1538
1538
|
return len;
|
1539
1539
|
}
|
1540
|
-
treeFilter(predicate) {
|
1540
|
+
treeFilter(predicate, options) {
|
1541
|
+
if (!options) {
|
1542
|
+
options = { includeChildren: true };
|
1543
|
+
}
|
1541
1544
|
const items = [];
|
1542
1545
|
for (let i = 0; i < this.length; i++) {
|
1543
1546
|
const item = this.getChild(i);
|
1544
1547
|
if (predicate(item)) {
|
1545
1548
|
items.push(item);
|
1549
|
+
//已经匹配节点,不需要匹配当前元素的子节点
|
1550
|
+
if (!options.includeChildren) {
|
1551
|
+
continue;
|
1552
|
+
}
|
1546
1553
|
}
|
1547
1554
|
if (item instanceof BranchElement) {
|
1548
1555
|
items.push(...item.treeFilter(predicate));
|
@@ -2870,15 +2877,7 @@ class ValidateProps {
|
|
2870
2877
|
return clone;
|
2871
2878
|
}
|
2872
2879
|
}
|
2873
|
-
class DataElementGroupProps extends
|
2874
|
-
clone(dest) {
|
2875
|
-
const clone = dest ?? new DataElementGroupProps();
|
2876
|
-
super.cloneBaseProps(clone);
|
2877
|
-
}
|
2878
|
-
getSerializeProps(options) {
|
2879
|
-
const props = {};
|
2880
|
-
return this.getBaseProps(props, options);
|
2881
|
-
}
|
2880
|
+
class DataElementGroupProps extends DataEleBaseTextProps {
|
2882
2881
|
}
|
2883
2882
|
class DataElementBarcodeProps {
|
2884
2883
|
type = 'code128';
|
@@ -8647,6 +8646,61 @@ class DataElementDateFactory extends DataElementBaseFactory {
|
|
8647
8646
|
}
|
8648
8647
|
}
|
8649
8648
|
|
8649
|
+
class BreakElement extends LeafElement {
|
8650
|
+
textProps;
|
8651
|
+
constructor() {
|
8652
|
+
super('br');
|
8653
|
+
this.textProps = new TextProps();
|
8654
|
+
this.textProps.fontSize = 14;
|
8655
|
+
this.textProps.fontName = '宋体';
|
8656
|
+
this.textProps.color = '#595959';
|
8657
|
+
}
|
8658
|
+
createRenderObject() {
|
8659
|
+
const symbol = new BreakRenderObject(this);
|
8660
|
+
symbol.rect.height = 14;
|
8661
|
+
symbol.rect.width = 7;
|
8662
|
+
return symbol;
|
8663
|
+
}
|
8664
|
+
serialize() {
|
8665
|
+
return {
|
8666
|
+
type: 'br',
|
8667
|
+
props: {}
|
8668
|
+
};
|
8669
|
+
}
|
8670
|
+
clone() {
|
8671
|
+
const clone = new BreakElement();
|
8672
|
+
cloneElementBase(this, clone);
|
8673
|
+
return clone;
|
8674
|
+
}
|
8675
|
+
}
|
8676
|
+
class BreakRenderObject extends LeafRenderObject {
|
8677
|
+
exportSVG(event) {
|
8678
|
+
if (!event.options.showEnterSymbol || event.mode === 'print') {
|
8679
|
+
return null;
|
8680
|
+
}
|
8681
|
+
return ElementUtil.createSvgText('↓', { 'dominant-baseline': 'hanging',
|
8682
|
+
'font-family': 'Courier',
|
8683
|
+
'font-size': this.rect.height,
|
8684
|
+
x: this.rect.x + 4,
|
8685
|
+
y: this.rect.y,
|
8686
|
+
fill: 'green' });
|
8687
|
+
}
|
8688
|
+
clone() {
|
8689
|
+
const render = new BreakRenderObject(this.element);
|
8690
|
+
render.rect = ElementUtil.cloneRect(this.rect);
|
8691
|
+
return render;
|
8692
|
+
}
|
8693
|
+
}
|
8694
|
+
class BreakFactory extends ElementFactory {
|
8695
|
+
match(type) {
|
8696
|
+
return type === 'br';
|
8697
|
+
}
|
8698
|
+
createElement(data) {
|
8699
|
+
const ele = new BreakElement();
|
8700
|
+
return ele;
|
8701
|
+
}
|
8702
|
+
}
|
8703
|
+
|
8650
8704
|
class DataElementGroupElement extends InlineGroupInputElement {
|
8651
8705
|
constructor() {
|
8652
8706
|
super('data-group');
|
@@ -8660,6 +8714,37 @@ class DataElementGroupElement extends InlineGroupInputElement {
|
|
8660
8714
|
this.refreshView();
|
8661
8715
|
});
|
8662
8716
|
}
|
8717
|
+
setValue(val) {
|
8718
|
+
if (val === null || val === undefined) {
|
8719
|
+
val = '';
|
8720
|
+
}
|
8721
|
+
if (this.getValue() === val) {
|
8722
|
+
return;
|
8723
|
+
}
|
8724
|
+
this.pubOnChange('self');
|
8725
|
+
this.clearInnerItems();
|
8726
|
+
if (typeof val !== 'string') {
|
8727
|
+
val += '';
|
8728
|
+
}
|
8729
|
+
if (val) {
|
8730
|
+
const items = val.split('<br/>');
|
8731
|
+
if (items.length) {
|
8732
|
+
items.forEach((item, index) => {
|
8733
|
+
const valueText = new TextGroupElement();
|
8734
|
+
this.props.valueTextProps.clone(valueText.props);
|
8735
|
+
valueText.text = item + '';
|
8736
|
+
this.addChild(valueText, this.length - 1);
|
8737
|
+
if (index < items.length - 1) {
|
8738
|
+
const brElement = new BreakElement();
|
8739
|
+
this.addChild(brElement, this.length - 1);
|
8740
|
+
}
|
8741
|
+
});
|
8742
|
+
}
|
8743
|
+
}
|
8744
|
+
}
|
8745
|
+
getValue() {
|
8746
|
+
return ElementSerialize.serializeString(this, { all: false });
|
8747
|
+
}
|
8663
8748
|
clone(data) {
|
8664
8749
|
return super.cloneSelf(data, DataElementGroupElement);
|
8665
8750
|
}
|
@@ -8695,9 +8780,33 @@ class DataElementGroupFactory extends DataElementBaseFactory {
|
|
8695
8780
|
createElement(data) {
|
8696
8781
|
const props = data.props;
|
8697
8782
|
const ele = new DataElementGroupElement();
|
8698
|
-
|
8783
|
+
this.createDataEleProps(ele.props, props);
|
8699
8784
|
return ele;
|
8700
8785
|
}
|
8786
|
+
createDataEleProps(dest, props) {
|
8787
|
+
const dataEleProps = dest;
|
8788
|
+
ElementUtil.readEleBaseProps(dataEleProps, props);
|
8789
|
+
dataEleProps.nullText = props.nullText;
|
8790
|
+
dataEleProps.nullTextProps = ElementUtil.readTextProps(null, props.nullTextProps, this.options);
|
8791
|
+
dataEleProps.valueTextProps = ElementUtil.readTextProps(null, props.valueTextProps, this.options);
|
8792
|
+
dataEleProps.dataType = props.dataType;
|
8793
|
+
return dataEleProps;
|
8794
|
+
}
|
8795
|
+
}
|
8796
|
+
/**
|
8797
|
+
* 是否在数据组内部
|
8798
|
+
* @param control
|
8799
|
+
* @param offset
|
8800
|
+
*/
|
8801
|
+
function IsInSideDataGroup(control, offset) {
|
8802
|
+
const mathEle = ElementUtil.getParent(control, (item) => item instanceof DataElementGroupElement);
|
8803
|
+
if (mathEle) {
|
8804
|
+
if ((control === mathEle.startDecorate && offset === 0) || (control === mathEle.endDecorate && offset === 1)) {
|
8805
|
+
return false;
|
8806
|
+
}
|
8807
|
+
return true;
|
8808
|
+
}
|
8809
|
+
return false;
|
8701
8810
|
}
|
8702
8811
|
|
8703
8812
|
class DataElementImage extends DataElementLeaf {
|
@@ -8939,61 +9048,6 @@ class DataElementListFactory extends DataElementBaseFactory {
|
|
8939
9048
|
}
|
8940
9049
|
}
|
8941
9050
|
|
8942
|
-
class BreakElement extends LeafElement {
|
8943
|
-
textProps;
|
8944
|
-
constructor() {
|
8945
|
-
super('br');
|
8946
|
-
this.textProps = new TextProps();
|
8947
|
-
this.textProps.fontSize = 14;
|
8948
|
-
this.textProps.fontName = '宋体';
|
8949
|
-
this.textProps.color = '#595959';
|
8950
|
-
}
|
8951
|
-
createRenderObject() {
|
8952
|
-
const symbol = new BreakRenderObject(this);
|
8953
|
-
symbol.rect.height = 14;
|
8954
|
-
symbol.rect.width = 7;
|
8955
|
-
return symbol;
|
8956
|
-
}
|
8957
|
-
serialize() {
|
8958
|
-
return {
|
8959
|
-
type: 'br',
|
8960
|
-
props: {}
|
8961
|
-
};
|
8962
|
-
}
|
8963
|
-
clone() {
|
8964
|
-
const clone = new BreakElement();
|
8965
|
-
cloneElementBase(this, clone);
|
8966
|
-
return clone;
|
8967
|
-
}
|
8968
|
-
}
|
8969
|
-
class BreakRenderObject extends LeafRenderObject {
|
8970
|
-
exportSVG(event) {
|
8971
|
-
if (!event.options.showEnterSymbol || event.mode === 'print') {
|
8972
|
-
return null;
|
8973
|
-
}
|
8974
|
-
return ElementUtil.createSvgText('↓', { 'dominant-baseline': 'hanging',
|
8975
|
-
'font-family': 'Courier',
|
8976
|
-
'font-size': this.rect.height,
|
8977
|
-
x: this.rect.x + 4,
|
8978
|
-
y: this.rect.y,
|
8979
|
-
fill: 'green' });
|
8980
|
-
}
|
8981
|
-
clone() {
|
8982
|
-
const render = new BreakRenderObject(this.element);
|
8983
|
-
render.rect = ElementUtil.cloneRect(this.rect);
|
8984
|
-
return render;
|
8985
|
-
}
|
8986
|
-
}
|
8987
|
-
class BreakFactory extends ElementFactory {
|
8988
|
-
match(type) {
|
8989
|
-
return type === 'br';
|
8990
|
-
}
|
8991
|
-
createElement(data) {
|
8992
|
-
const ele = new BreakElement();
|
8993
|
-
return ele;
|
8994
|
-
}
|
8995
|
-
}
|
8996
|
-
|
8997
9051
|
class DataElementText extends DataElementInlineGroup {
|
8998
9052
|
//props: DataEleBaseTextProps;
|
8999
9053
|
constructor() {
|
@@ -12485,6 +12539,14 @@ class ElementUtil {
|
|
12485
12539
|
static getDataElement(ele) {
|
12486
12540
|
return this.getParent(ele, item => item instanceof DataElementInlineGroup);
|
12487
12541
|
}
|
12542
|
+
/**
|
12543
|
+
* 向上查找类型为数据元的父级
|
12544
|
+
* @param ele
|
12545
|
+
* @returns
|
12546
|
+
*/
|
12547
|
+
static getDataGroupElement(ele) {
|
12548
|
+
return this.getParent(ele, item => item instanceof DataElementGroupElement);
|
12549
|
+
}
|
12488
12550
|
static getOSPlatform() {
|
12489
12551
|
const userAgent = navigator.userAgent;
|
12490
12552
|
if (userAgent.indexOf('Windows') > -1) {
|
@@ -12633,23 +12695,35 @@ class ElementUtil {
|
|
12633
12695
|
if (startControl.paintRenders.length === 0) {
|
12634
12696
|
return false;
|
12635
12697
|
}
|
12698
|
+
if (!ElementUtil.verifyHitable(startControl)) {
|
12699
|
+
return false;
|
12700
|
+
}
|
12636
12701
|
if (viewOptions.docMode === exports.DocMode.Design) {
|
12637
12702
|
return true;
|
12638
12703
|
}
|
12639
|
-
|
12704
|
+
//表单模式下
|
12640
12705
|
if (viewOptions.docMode === exports.DocMode.FormEdit) {
|
12641
|
-
|
12642
|
-
|
12706
|
+
//如果光标在数据元素中,判断是否可编辑
|
12707
|
+
if (IsInSideDataElement(startControl, startOffset)) {
|
12708
|
+
const dataEle = ElementUtil.getDataElement(startControl);
|
12709
|
+
//数据元不可编辑
|
12710
|
+
if (dataEle && !dataEle.props.editable) {
|
12711
|
+
return false;
|
12712
|
+
}
|
12713
|
+
return true;
|
12643
12714
|
}
|
12644
|
-
|
12645
|
-
|
12646
|
-
|
12647
|
-
|
12648
|
-
|
12649
|
-
|
12650
|
-
|
12651
|
-
|
12652
|
-
|
12715
|
+
else {
|
12716
|
+
//不在数据元中,需要判断是否在数据组中
|
12717
|
+
if (IsInSideDataGroup(startControl, startOffset)) {
|
12718
|
+
const dataGroup = ElementUtil.getDataGroupElement(startControl);
|
12719
|
+
//数据元不可编辑
|
12720
|
+
if (dataGroup && !dataGroup.props.editable) {
|
12721
|
+
return false;
|
12722
|
+
}
|
12723
|
+
}
|
12724
|
+
else {
|
12725
|
+
return false;
|
12726
|
+
}
|
12653
12727
|
}
|
12654
12728
|
}
|
12655
12729
|
return true;
|
@@ -13332,8 +13406,8 @@ class DocumentContext {
|
|
13332
13406
|
const dataEleList = this.ctx.treeFilter(item => validateDataEle(item));
|
13333
13407
|
return dataEleList.map(item => item.props.id);
|
13334
13408
|
}
|
13335
|
-
getControlInstanceList() {
|
13336
|
-
return this.ctx.treeFilter(item => validateDataEle(item));
|
13409
|
+
getControlInstanceList(options) {
|
13410
|
+
return this.ctx.treeFilter(item => validateDataEle(item), options);
|
13337
13411
|
}
|
13338
13412
|
getControlById(id) {
|
13339
13413
|
return this.ctx.treeFind(item => validateDataEle(item) && item['props']['id'] === id);
|
@@ -13356,8 +13430,9 @@ class DocumentContext {
|
|
13356
13430
|
* 获取数据元结构以及get\set闭包调用函数
|
13357
13431
|
* @returns
|
13358
13432
|
*/
|
13359
|
-
getDataElementModelList() {
|
13360
|
-
const dataEleList = this.ctx.treeFilter(item => validateDataEle(item)
|
13433
|
+
getDataElementModelList(options) {
|
13434
|
+
const dataEleList = this.ctx.treeFilter(item => validateDataEle(item), options);
|
13435
|
+
//数据元、数据组
|
13361
13436
|
const dataInlineGroups = dataEleList.filter(item => item instanceof DataElementInlineGroup);
|
13362
13437
|
const dataLeafs = dataEleList.filter(item => item instanceof DataElementLeaf);
|
13363
13438
|
//复选框数据元
|
@@ -13366,7 +13441,7 @@ class DocumentContext {
|
|
13366
13441
|
const dataOtherLeafValues = CommonUtil.removeUnionSet(dataLeafs, dataCheckList).map(item => ({
|
13367
13442
|
id: item.props.id,
|
13368
13443
|
name: item.props.name,
|
13369
|
-
fieldName: item.props.
|
13444
|
+
fieldName: item.props.fieldName,
|
13370
13445
|
item,
|
13371
13446
|
getValue: () => {
|
13372
13447
|
return item.getValue();
|
@@ -17490,8 +17565,12 @@ class DocumentChange {
|
|
17490
17565
|
* @private
|
17491
17566
|
*/
|
17492
17567
|
canDeleteInlineGroup(dataEle) {
|
17568
|
+
//当前编辑模式为表单模式,单独的数据元不可删除
|
17569
|
+
//存在于数据组内的数据元可以删除
|
17493
17570
|
if (this.viewOptions.docMode === exports.DocMode.FormEdit) {
|
17494
|
-
|
17571
|
+
if (dataEle.parent.type !== 'data-group') {
|
17572
|
+
return false;
|
17573
|
+
}
|
17495
17574
|
}
|
17496
17575
|
return dataEle.length === 2;
|
17497
17576
|
}
|
@@ -18421,9 +18500,13 @@ class DocumentChange {
|
|
18421
18500
|
}
|
18422
18501
|
getCursorElementByDeleteAction(control) {
|
18423
18502
|
if (this.viewOptions.docMode === exports.DocMode.FormEdit) {
|
18424
|
-
|
18503
|
+
//是否属于数据元或者数据组区域
|
18504
|
+
const isInDataAre = (ele) => {
|
18505
|
+
return ele.parent instanceof DataElementInlineGroup || ele.parent instanceof DataElementGroupElement;
|
18506
|
+
};
|
18507
|
+
if (isInDataAre(control)) {
|
18425
18508
|
const prevLeafElementInPara = ElementUtil.getRecursionPrevSiblingElement(control, true, true, this.viewOptions);
|
18426
|
-
if (prevLeafElementInPara &&
|
18509
|
+
if (prevLeafElementInPara && isInDataAre(prevLeafElementInPara)) {
|
18427
18510
|
return {
|
18428
18511
|
ele: prevLeafElementInPara,
|
18429
18512
|
offset: ElementUtil.getElementEndOffset(prevLeafElementInPara)
|
@@ -18431,7 +18514,7 @@ class DocumentChange {
|
|
18431
18514
|
}
|
18432
18515
|
else {
|
18433
18516
|
return {
|
18434
|
-
ele: control.parent.startDecorate,
|
18517
|
+
ele: (control.parent).startDecorate,
|
18435
18518
|
offset: 1
|
18436
18519
|
};
|
18437
18520
|
}
|
@@ -20904,7 +20987,7 @@ class DocEditor {
|
|
20904
20987
|
this.onDblClickEvent.next(evt);
|
20905
20988
|
}
|
20906
20989
|
/**
|
20907
|
-
*
|
20990
|
+
* 获取当前光标所在的数据元或者数据组
|
20908
20991
|
* @returns
|
20909
20992
|
*/
|
20910
20993
|
getCurrentDataElement() {
|
@@ -21943,7 +22026,7 @@ class DocEditor {
|
|
21943
22026
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
21944
22027
|
}
|
21945
22028
|
version() {
|
21946
|
-
return "2.2.
|
22029
|
+
return "2.2.10";
|
21947
22030
|
}
|
21948
22031
|
switchPageHeaderEditor() {
|
21949
22032
|
this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
|
@@ -27798,6 +27881,7 @@ exports.InlineGroupRenderObject = InlineGroupRenderObject;
|
|
27798
27881
|
exports.InlineMuiltBlockLineRenderObject = InlineMuiltBlockLineRenderObject;
|
27799
27882
|
exports.InputElementEvent = InputElementEvent;
|
27800
27883
|
exports.IsInSideDataElement = IsInSideDataElement;
|
27884
|
+
exports.IsInSideDataGroup = IsInSideDataGroup;
|
27801
27885
|
exports.IsInSideInlineGroupInputElement = IsInSideInlineGroupInputElement;
|
27802
27886
|
exports.KeyboradElementEvent = KeyboradElementEvent;
|
27803
27887
|
exports.LeafElement = LeafElement;
|