@hailin-zheng/editor-core 2.0.16 → 2.0.17
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 +105 -67
- package/index-cjs.js.map +1 -1
- package/index.js +105 -67
- package/index.js.map +1 -1
- package/med_editor/doc-editor.d.ts +1 -0
- package/med_editor/framework/element-props.d.ts +2 -0
- package/med_editor/framework/impl/data-element/data-element-check-impl.d.ts +2 -0
- package/package.json +1 -1
package/index-cjs.js
CHANGED
@@ -2273,12 +2273,14 @@ class DataEleListProps extends DataEleBaseTextProps {
|
|
2273
2273
|
* 是否允许多选
|
2274
2274
|
*/
|
2275
2275
|
multiSelect;
|
2276
|
+
displayField = 'value';
|
2276
2277
|
clone(dest) {
|
2277
2278
|
const clone = dest ?? new DataEleListProps();
|
2278
2279
|
super.clone(clone);
|
2279
2280
|
clone.options = [...this.options];
|
2280
2281
|
clone.dropDownStyle = this.dropDownStyle;
|
2281
2282
|
clone.multiSelect = this.multiSelect;
|
2283
|
+
clone.displayField = this.displayField;
|
2282
2284
|
return clone;
|
2283
2285
|
}
|
2284
2286
|
getSerializeProps(options) {
|
@@ -2287,6 +2289,9 @@ class DataEleListProps extends DataEleBaseTextProps {
|
|
2287
2289
|
multiSelect: this.multiSelect,
|
2288
2290
|
dropDownStyle: this.dropDownStyle,
|
2289
2291
|
};
|
2292
|
+
if (this.displayField && this.displayField !== 'value') {
|
2293
|
+
props['displayField'] = this.displayField;
|
2294
|
+
}
|
2290
2295
|
super.getBaseProps(props, options);
|
2291
2296
|
return props;
|
2292
2297
|
}
|
@@ -2295,6 +2300,7 @@ class DataEleListProps extends DataEleBaseTextProps {
|
|
2295
2300
|
this.options = props.options;
|
2296
2301
|
this.multiSelect = props.multiSelect;
|
2297
2302
|
this.dropDownStyle = props.dropDownStyle;
|
2303
|
+
this.displayField = props.displayField;
|
2298
2304
|
}
|
2299
2305
|
}
|
2300
2306
|
class CommContentProps extends INotifyPropertyChanged {
|
@@ -2348,6 +2354,7 @@ class DataEleCheckProps extends DataEleBaseProps {
|
|
2348
2354
|
falseChar = falseChar;
|
2349
2355
|
trueStateColor = '#f00000';
|
2350
2356
|
falseStateColor = '#000000';
|
2357
|
+
style = 'CheckBox';
|
2351
2358
|
clone(dest) {
|
2352
2359
|
const clone = dest ?? new DataEleCheckProps();
|
2353
2360
|
super.cloneBaseProps(clone);
|
@@ -2362,6 +2369,7 @@ class DataEleCheckProps extends DataEleBaseProps {
|
|
2362
2369
|
clone.border = this.border;
|
2363
2370
|
clone.trueStateColor = this.trueStateColor;
|
2364
2371
|
clone.falseStateColor = this.falseStateColor;
|
2372
|
+
clone.style = this.style;
|
2365
2373
|
return clone;
|
2366
2374
|
}
|
2367
2375
|
getSerializeProps(options) {
|
@@ -2390,6 +2398,9 @@ class DataEleCheckProps extends DataEleBaseProps {
|
|
2390
2398
|
if (this.falseStateColor !== '#000000') {
|
2391
2399
|
props.falseStateColor = this.falseStateColor;
|
2392
2400
|
}
|
2401
|
+
if (this.style !== 'CheckBox') {
|
2402
|
+
props.style = this.style;
|
2403
|
+
}
|
2393
2404
|
this.getBaseProps(props, options);
|
2394
2405
|
return props;
|
2395
2406
|
}
|
@@ -2406,6 +2417,7 @@ class DataEleCheckProps extends DataEleBaseProps {
|
|
2406
2417
|
this.trueStateColor = props.trueStateColor;
|
2407
2418
|
this.falseStateColor = props.falseStateColor;
|
2408
2419
|
this.border = props.border;
|
2420
|
+
this.style = props.style;
|
2409
2421
|
}
|
2410
2422
|
}
|
2411
2423
|
class DataEleImageProps extends DataEleBaseProps {
|
@@ -4779,7 +4791,7 @@ class TextGroupRenderObject extends LeafRenderObject {
|
|
4779
4791
|
return curr.actualSize + prev;
|
4780
4792
|
}, this.rect.x);
|
4781
4793
|
const x = arr.join(' ');
|
4782
|
-
const y = this.textMeasures.map(item => this.rect.y + vertHeight).join(' ');
|
4794
|
+
const y = this.rect.y + vertHeight; //this.textMeasures.map(item => this.rect.y + vertHeight).join(' ');
|
4783
4795
|
const text = this.textMeasures.map(item => {
|
4784
4796
|
return item.char;
|
4785
4797
|
}).join('');
|
@@ -10889,74 +10901,83 @@ class DataElementCheckRenderObject extends LeafRenderObject {
|
|
10889
10901
|
});
|
10890
10902
|
}
|
10891
10903
|
else {
|
10904
|
+
const style = props.style;
|
10892
10905
|
if (props.multiSelect) {
|
10893
|
-
t.
|
10894
|
-
|
10895
|
-
data: {
|
10896
|
-
ns: "http://www.w3.org/2000/svg",
|
10897
|
-
attrs: {
|
10898
|
-
x: 2,
|
10899
|
-
y: 0,
|
10900
|
-
width,
|
10901
|
-
height,
|
10902
|
-
stroke: 'black',
|
10903
|
-
fill: 'none',
|
10904
|
-
'stroke-width': 1
|
10905
|
-
}
|
10906
|
-
}
|
10907
|
-
});
|
10908
|
-
if (props.checked) {
|
10909
|
-
const paths = ElementUtil.getCheckboxPath(2, 0, props.size, props.size);
|
10910
|
-
t.children.push({
|
10911
|
-
sel: 'path',
|
10912
|
-
data: {
|
10913
|
-
ns: "http://www.w3.org/2000/svg",
|
10914
|
-
attrs: {
|
10915
|
-
d: paths.map((item, index) => {
|
10916
|
-
return `${index === 0 ? 'M' : 'L'}${item.x},${item.y}`;
|
10917
|
-
}).join(' '),
|
10918
|
-
stroke: 'red',
|
10919
|
-
fill: 'none',
|
10920
|
-
'stroke-width': 2
|
10921
|
-
}
|
10922
|
-
}
|
10923
|
-
});
|
10924
|
-
}
|
10906
|
+
style === 'RadioButton' ? this.drawCircleCheckbox(t, width, height, props.checked)
|
10907
|
+
: this.drawRectCheckbox(t, width, height, props.size, props.checked);
|
10925
10908
|
}
|
10926
10909
|
else {
|
10927
|
-
t.
|
10928
|
-
|
10929
|
-
|
10930
|
-
|
10931
|
-
|
10932
|
-
|
10933
|
-
|
10934
|
-
|
10935
|
-
|
10936
|
-
|
10937
|
-
|
10938
|
-
|
10910
|
+
style === 'CheckBox' ? this.drawRectCheckbox(t, width, height, props.size, props.checked)
|
10911
|
+
: this.drawCircleCheckbox(t, width, height, props.checked);
|
10912
|
+
}
|
10913
|
+
}
|
10914
|
+
return t;
|
10915
|
+
}
|
10916
|
+
drawRectCheckbox(t, width, height, size, checked) {
|
10917
|
+
t.children.push({
|
10918
|
+
sel: 'rect',
|
10919
|
+
data: {
|
10920
|
+
ns: "http://www.w3.org/2000/svg",
|
10921
|
+
attrs: {
|
10922
|
+
x: 2,
|
10923
|
+
y: 0,
|
10924
|
+
width,
|
10925
|
+
height,
|
10926
|
+
stroke: 'black',
|
10927
|
+
fill: 'none',
|
10928
|
+
'stroke-width': 1
|
10929
|
+
}
|
10930
|
+
}
|
10931
|
+
});
|
10932
|
+
if (checked) {
|
10933
|
+
const paths = ElementUtil.getCheckboxPath(2, 0, size, size);
|
10934
|
+
t.children.push({
|
10935
|
+
sel: 'path',
|
10936
|
+
data: {
|
10937
|
+
ns: "http://www.w3.org/2000/svg",
|
10938
|
+
attrs: {
|
10939
|
+
d: paths.map((item, index) => {
|
10940
|
+
return `${index === 0 ? 'M' : 'L'}${item.x},${item.y}`;
|
10941
|
+
}).join(' '),
|
10942
|
+
stroke: 'red',
|
10943
|
+
fill: 'none',
|
10944
|
+
'stroke-width': 2
|
10939
10945
|
}
|
10940
|
-
}
|
10941
|
-
|
10942
|
-
|
10943
|
-
|
10944
|
-
|
10945
|
-
|
10946
|
-
|
10947
|
-
|
10948
|
-
|
10949
|
-
|
10950
|
-
|
10951
|
-
|
10952
|
-
|
10953
|
-
|
10954
|
-
|
10955
|
-
|
10946
|
+
}
|
10947
|
+
});
|
10948
|
+
}
|
10949
|
+
}
|
10950
|
+
drawCircleCheckbox(t, width, height, checked) {
|
10951
|
+
t.children.push({
|
10952
|
+
sel: 'circle',
|
10953
|
+
data: {
|
10954
|
+
ns: "http://www.w3.org/2000/svg",
|
10955
|
+
attrs: {
|
10956
|
+
cx: 2 + width / 2,
|
10957
|
+
cy: height / 2,
|
10958
|
+
r: width / 3,
|
10959
|
+
stroke: 'black',
|
10960
|
+
fill: 'none',
|
10961
|
+
'stroke-width': 1
|
10956
10962
|
}
|
10957
10963
|
}
|
10964
|
+
});
|
10965
|
+
if (checked) {
|
10966
|
+
t.children.push({
|
10967
|
+
sel: 'circle',
|
10968
|
+
data: {
|
10969
|
+
ns: "http://www.w3.org/2000/svg",
|
10970
|
+
attrs: {
|
10971
|
+
cx: 2 + width / 2,
|
10972
|
+
cy: height / 2,
|
10973
|
+
r: width / 5,
|
10974
|
+
stroke: 'black',
|
10975
|
+
fill: 'black',
|
10976
|
+
'stroke-width': 1
|
10977
|
+
}
|
10978
|
+
}
|
10979
|
+
});
|
10958
10980
|
}
|
10959
|
-
return t;
|
10960
10981
|
}
|
10961
10982
|
}
|
10962
10983
|
class DataElementCheckFactory extends ElementFactory {
|
@@ -10981,6 +11002,7 @@ class DataElementCheckFactory extends ElementFactory {
|
|
10981
11002
|
dataEleProps.trueChar = props.trueChar ?? trueChar;
|
10982
11003
|
dataEleProps.falseChar = props.falseChar ?? falseChar;
|
10983
11004
|
dataEleProps.border = props.border ?? true;
|
11005
|
+
dataEleProps.style = props.style ?? 'CheckBox';
|
10984
11006
|
return dataEleProps;
|
10985
11007
|
}
|
10986
11008
|
}
|
@@ -11375,6 +11397,8 @@ class DataElementList extends DataElementInlineGroup {
|
|
11375
11397
|
}
|
11376
11398
|
this.pubOnChange('self');
|
11377
11399
|
this.clearInnerItems();
|
11400
|
+
let displayField = this.props.displayField;
|
11401
|
+
displayField = displayField ? displayField : 'value';
|
11378
11402
|
if (this.props.multiSelect) {
|
11379
11403
|
for (let i = 0; i < vals.length; i++) {
|
11380
11404
|
const val = vals[i];
|
@@ -11383,12 +11407,14 @@ class DataElementList extends DataElementInlineGroup {
|
|
11383
11407
|
const valueText = new TextGroupElement();
|
11384
11408
|
this.props.valueTextProps.clone(valueText.props);
|
11385
11409
|
const splitSymbol = i < vals.length - 1 ? ';' : '';
|
11386
|
-
valueText.text = option
|
11410
|
+
valueText.text = option[displayField] + splitSymbol;
|
11387
11411
|
this.addChild(valueText, this.length - 1);
|
11388
11412
|
}
|
11389
11413
|
}
|
11390
11414
|
}
|
11391
11415
|
else {
|
11416
|
+
let displayField = this.props.displayField;
|
11417
|
+
displayField = displayField ? displayField : 'value';
|
11392
11418
|
if (vals.length > 1) {
|
11393
11419
|
console.warn('当前下拉框是单选模式,不能传入多个值');
|
11394
11420
|
}
|
@@ -11397,7 +11423,7 @@ class DataElementList extends DataElementInlineGroup {
|
|
11397
11423
|
if (option) {
|
11398
11424
|
const valueText = new TextGroupElement();
|
11399
11425
|
this.props.valueTextProps.clone(valueText.props);
|
11400
|
-
valueText.text = option
|
11426
|
+
valueText.text = option[displayField];
|
11401
11427
|
this.addChild(valueText, this.length - 1);
|
11402
11428
|
}
|
11403
11429
|
}
|
@@ -11408,10 +11434,12 @@ class DataElementList extends DataElementInlineGroup {
|
|
11408
11434
|
if (!values) {
|
11409
11435
|
return '';
|
11410
11436
|
}
|
11437
|
+
let displayField = this.props.displayField;
|
11438
|
+
displayField = displayField ? displayField : 'value';
|
11411
11439
|
const valueItems = values.split(';');
|
11412
11440
|
const valueCode = [];
|
11413
11441
|
for (const valueItem of valueItems) {
|
11414
|
-
const option = this.props.options.find(item => item
|
11442
|
+
const option = this.props.options.find(item => item[displayField] === valueItem);
|
11415
11443
|
if (option) {
|
11416
11444
|
valueCode.push(option.code);
|
11417
11445
|
}
|
@@ -11456,6 +11484,7 @@ class DataElementListFactory extends DataElementBaseFactory {
|
|
11456
11484
|
dataEleProps.multiSelect = props.multiSelect;
|
11457
11485
|
dataEleProps.options = [...options];
|
11458
11486
|
dataEleProps.dropDownStyle = props.dropDownStyle;
|
11487
|
+
dataEleProps.displayField = props.displayField ?? 'value';
|
11459
11488
|
return dataEleProps;
|
11460
11489
|
}
|
11461
11490
|
}
|
@@ -27564,6 +27593,15 @@ class DocEditor {
|
|
27564
27593
|
const { startControl, startOffset } = this.selectionState;
|
27565
27594
|
this.insertElement(startControl, startOffset, [ele]);
|
27566
27595
|
}
|
27596
|
+
test() {
|
27597
|
+
const text = new TextGroupElement();
|
27598
|
+
text.props.fontName = '宋体';
|
27599
|
+
text.props.fontSize = 14;
|
27600
|
+
text.text = '哈哈';
|
27601
|
+
const br = new BreakElement();
|
27602
|
+
const { startControl, startOffset } = this.selectionState;
|
27603
|
+
this.insertElement(startControl, startOffset, [text, br]);
|
27604
|
+
}
|
27567
27605
|
switchPageLayout(mode) {
|
27568
27606
|
this.viewOptions.pageLayoutMode = mode;
|
27569
27607
|
this.flushToSchedule();
|
@@ -27714,7 +27752,7 @@ class DocEditor {
|
|
27714
27752
|
const vNodeFunc = this.renderRoot();
|
27715
27753
|
setActiveEditorContext(null);
|
27716
27754
|
const render = () => {
|
27717
|
-
console.time('patch');
|
27755
|
+
//console.time('patch');
|
27718
27756
|
setActiveEditorContext(this);
|
27719
27757
|
const vNode = vNodeFunc.render();
|
27720
27758
|
setActiveEditorContext(null);
|
@@ -27726,7 +27764,7 @@ class DocEditor {
|
|
27726
27764
|
this.vNodeDocContent = this.nodePatch(this.svgContainer, vNode);
|
27727
27765
|
}
|
27728
27766
|
this.afterNodePatch.next();
|
27729
|
-
console.timeEnd('patch');
|
27767
|
+
//console.timeEnd('patch');
|
27730
27768
|
};
|
27731
27769
|
render();
|
27732
27770
|
this.onShouldRender.subscribe(() => {
|