@hailin-zheng/editor-core 2.1.5 → 2.1.7
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 +183 -100
- package/index-cjs.js.map +1 -1
- package/index.js +183 -100
- package/index.js.map +1 -1
- package/med_editor/framework/common-util.d.ts +3 -0
- package/med_editor/framework/document-print-offscreen.d.ts +1 -0
- package/med_editor/framework/document-print.d.ts +2 -2
- package/med_editor/framework/document-svg.d.ts +1 -1
- package/med_editor/framework/element-define.d.ts +4 -0
- package/med_editor/framework/element-props.d.ts +1 -0
- package/med_editor/framework/impl/data-element/data-element-date-impl.d.ts +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
@@ -291,7 +291,8 @@ class RenderObject {
|
|
291
291
|
data: {
|
292
292
|
ns: "http://www.w3.org/2000/svg",
|
293
293
|
attrs: {
|
294
|
-
transform: `translate(${this.rect.x},${this.rect.y})`
|
294
|
+
//transform: `translate(${this.rect.x},${this.rect.y})`
|
295
|
+
translate: { x: this.rect.x, y: this.rect.y }
|
295
296
|
}
|
296
297
|
}
|
297
298
|
};
|
@@ -668,6 +669,35 @@ class CommonUtil {
|
|
668
669
|
}
|
669
670
|
return true;
|
670
671
|
}
|
672
|
+
static debounce(fn, wait) {
|
673
|
+
let timeout;
|
674
|
+
let lastExecTime = 0;
|
675
|
+
return function (...args) {
|
676
|
+
const context = this;
|
677
|
+
const elapsed = Date.now() - lastExecTime;
|
678
|
+
const shouldCallNow = elapsed >= wait;
|
679
|
+
clearTimeout(timeout);
|
680
|
+
if (shouldCallNow) {
|
681
|
+
fn.apply(context, args);
|
682
|
+
lastExecTime = Date.now();
|
683
|
+
}
|
684
|
+
else {
|
685
|
+
timeout = setTimeout(() => {
|
686
|
+
fn.apply(context, args);
|
687
|
+
lastExecTime = Date.now();
|
688
|
+
}, wait - elapsed);
|
689
|
+
}
|
690
|
+
};
|
691
|
+
}
|
692
|
+
static btoa(str) {
|
693
|
+
// 将SVG字符串转换为UTF-8编码的字节数组
|
694
|
+
const encoder = new TextEncoder();
|
695
|
+
encoder.encode(str);
|
696
|
+
// 将字节数组编码为Base64字符串
|
697
|
+
//return btoa(String.fromCharCode.apply(null, svgArray));
|
698
|
+
return btoa(unescape(encodeURIComponent(str)));
|
699
|
+
//return btoa(str.replace(/[\u00A0-\u2666]/g, c => `&#${c.charCodeAt(0)};`));
|
700
|
+
}
|
671
701
|
}
|
672
702
|
|
673
703
|
const docOpsMap = new Map();
|
@@ -838,7 +868,7 @@ function getExactDiffProps(oldProps, newProps) {
|
|
838
868
|
function generatePatch(doc) {
|
839
869
|
const insertOpsMap = new Map();
|
840
870
|
const formatOpsMap = new Map();
|
841
|
-
const
|
871
|
+
const patches = [];
|
842
872
|
const ops = docOpsMap.get(doc);
|
843
873
|
if (!ops || !ops.length) {
|
844
874
|
return [];
|
@@ -869,11 +899,14 @@ function generatePatch(doc) {
|
|
869
899
|
// op.prevIndex = log.prevIndex;
|
870
900
|
// op.parentIndex = log.parentIndex;
|
871
901
|
// }
|
872
|
-
|
902
|
+
if ('insert' in op.ops) {
|
903
|
+
op.ops.insert = ele.clone(true);
|
904
|
+
}
|
905
|
+
patches.push({ index: op.index, parentIndex: op.parentIndex, prevIndex: op.prevIndex, ops: op.ops });
|
873
906
|
}
|
874
907
|
//清空
|
875
908
|
ops.length = 0;
|
876
|
-
return
|
909
|
+
return patches;
|
877
910
|
}
|
878
911
|
/**
|
879
912
|
* 获取删除元素的操作
|
@@ -1049,7 +1082,10 @@ var ModifyFlag$1;
|
|
1049
1082
|
const elementTypeEventHandler = [];
|
1050
1083
|
function invokeTypeHandler(ele, eventName, e, useCapture = false) {
|
1051
1084
|
const predicate = (ele, th) => {
|
1052
|
-
if (
|
1085
|
+
if (!th.elementTypeCategory) {
|
1086
|
+
th.elementTypeCategory = CommonUtil.isConstructor(th.elementType) ? 'constructor' : 'function';
|
1087
|
+
}
|
1088
|
+
if (th.elementTypeCategory === 'constructor') {
|
1053
1089
|
return ele instanceof th.elementType;
|
1054
1090
|
}
|
1055
1091
|
else {
|
@@ -1112,6 +1148,7 @@ class Element {
|
|
1112
1148
|
logUpdateEleProps(this, p, oldValue, newValue);
|
1113
1149
|
this.pubOnChange('self');
|
1114
1150
|
}
|
1151
|
+
key;
|
1115
1152
|
//元素是否禁止复制,例如批注元素
|
1116
1153
|
//forbidCopy: boolean;
|
1117
1154
|
constructor(type) {
|
@@ -1123,6 +1160,7 @@ class Element {
|
|
1123
1160
|
this.addEvent('ElementMouseLeave', (evt) => {
|
1124
1161
|
this.isMouseenter = false;
|
1125
1162
|
});
|
1163
|
+
this.key = nanoid(5);
|
1126
1164
|
}
|
1127
1165
|
destroy() {
|
1128
1166
|
this._eventMap?.clear(this);
|
@@ -1542,6 +1580,9 @@ class ViewOptions {
|
|
1542
1580
|
trackDelColor = '#000';
|
1543
1581
|
showLineRect;
|
1544
1582
|
showCharRect;
|
1583
|
+
//数据元交互修饰模式
|
1584
|
+
dataEleDecoratorMode = 'outline';
|
1585
|
+
dataEleDecoratorColor = '#0050b3';
|
1545
1586
|
showTabChar;
|
1546
1587
|
showSpaceChar;
|
1547
1588
|
showLineBreak;
|
@@ -2463,6 +2504,7 @@ class DataEleDateProps extends DataEleBaseTextProps {
|
|
2463
2504
|
minValue;
|
2464
2505
|
maxValue;
|
2465
2506
|
format;
|
2507
|
+
value;
|
2466
2508
|
clone(dest) {
|
2467
2509
|
const clone = dest ?? new DataEleDateProps();
|
2468
2510
|
super.clone(clone);
|
@@ -2475,7 +2517,8 @@ class DataEleDateProps extends DataEleBaseTextProps {
|
|
2475
2517
|
const props = {
|
2476
2518
|
minValue: this.minValue,
|
2477
2519
|
maxValue: this.maxValue,
|
2478
|
-
format: this.format
|
2520
|
+
format: this.format,
|
2521
|
+
value: this.value
|
2479
2522
|
};
|
2480
2523
|
this.getBaseProps(props, options);
|
2481
2524
|
return props;
|
@@ -3451,9 +3494,10 @@ class DocumentRenderObject extends BlockContainerRenderObject {
|
|
3451
3494
|
data: {
|
3452
3495
|
ns: "http://www.w3.org/2000/svg",
|
3453
3496
|
attrs: {
|
3497
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
3454
3498
|
width: this.rect.width,
|
3455
|
-
height: this.rect.height,
|
3456
|
-
viewBox: `0 0 ${this.rect.width} ${this.rect.height}`,
|
3499
|
+
height: this.rect.height - 1,
|
3500
|
+
viewBox: `0 0 ${this.rect.width} ${this.rect.height - 1}`,
|
3457
3501
|
overflow: "hidden"
|
3458
3502
|
},
|
3459
3503
|
},
|
@@ -3895,8 +3939,21 @@ function drawDecorator(e, r) {
|
|
3895
3939
|
}
|
3896
3940
|
function exportDecoratorHTML(event, r) {
|
3897
3941
|
const canPaint = r.element.isMouseenter || r.element.isFocused;
|
3898
|
-
if (canPaint) {
|
3899
|
-
|
3942
|
+
if (!canPaint) {
|
3943
|
+
return;
|
3944
|
+
}
|
3945
|
+
const mode = event.options.dataEleDecoratorMode;
|
3946
|
+
const color = event.options.dataEleDecoratorColor;
|
3947
|
+
if (mode === 'none') {
|
3948
|
+
return;
|
3949
|
+
}
|
3950
|
+
if (mode === 'overlay') {
|
3951
|
+
const bgX = event.relativePagePos.x;
|
3952
|
+
const bgY = event.relativePagePos.y;
|
3953
|
+
event.highlights.push(ElementUtil.getFillSvgRect(bgX, bgY, r.rect.width, r.rect.height, color));
|
3954
|
+
return;
|
3955
|
+
}
|
3956
|
+
else if (mode === 'outline') {
|
3900
3957
|
const verOffset = 0;
|
3901
3958
|
const renderPosMap = getCurrentParaGroupRenders(r).map(item => ({ pos: getRenderPosToDoc(item), render: item }));
|
3902
3959
|
if (renderPosMap.length > 1) {
|
@@ -3930,7 +3987,7 @@ function exportDecoratorHTML(event, r) {
|
|
3930
3987
|
ns: 'http://www.w3.org/2000/svg',
|
3931
3988
|
attrs: {
|
3932
3989
|
d: path,
|
3933
|
-
stroke:
|
3990
|
+
stroke: color,
|
3934
3991
|
fill: 'none',
|
3935
3992
|
'stroke-width': 1
|
3936
3993
|
}
|
@@ -4046,15 +4103,7 @@ class DocumentBodyRenderObject extends MuiltBlockLineRenderObject {
|
|
4046
4103
|
return cloneRender;
|
4047
4104
|
}
|
4048
4105
|
exportHTML(event) {
|
4049
|
-
const t =
|
4050
|
-
sel: "g",
|
4051
|
-
data: {
|
4052
|
-
ns: "http://www.w3.org/2000/svg",
|
4053
|
-
attrs: {
|
4054
|
-
transform: `translate(${this.rect.x},${this.rect.y})`
|
4055
|
-
}
|
4056
|
-
}
|
4057
|
-
};
|
4106
|
+
const t = super.exportHTML(event);
|
4058
4107
|
if (this.element.disableClick && event.mode === 'view') {
|
4059
4108
|
t.data.attrs['opacity'] = 0.5;
|
4060
4109
|
}
|
@@ -4258,16 +4307,7 @@ class DocumentHeaderRenderObject extends BlockContainerRenderObject {
|
|
4258
4307
|
}
|
4259
4308
|
};
|
4260
4309
|
}
|
4261
|
-
const t =
|
4262
|
-
sel: "g",
|
4263
|
-
data: {
|
4264
|
-
ns: "http://www.w3.org/2000/svg",
|
4265
|
-
attrs: {
|
4266
|
-
transform: `translate(${this.rect.x},${this.rect.y})`
|
4267
|
-
}
|
4268
|
-
},
|
4269
|
-
children: []
|
4270
|
-
};
|
4310
|
+
const t = super.exportHTML(event);
|
4271
4311
|
// if (this.element.disableClick && event.mode === 'view') {
|
4272
4312
|
// t.data.attrs.opacity = 0.5;
|
4273
4313
|
// }
|
@@ -4836,7 +4876,8 @@ class TextGroupRenderObject extends LeafRenderObject {
|
|
4836
4876
|
data: {
|
4837
4877
|
ns: "http://www.w3.org/2000/svg",
|
4838
4878
|
attrs: {
|
4839
|
-
"transform": `translate(0,${(height - props.fontSize) / 2})`,
|
4879
|
+
//"transform": `translate(0,${(height - props.fontSize) / 2})`,
|
4880
|
+
"translate": { x: 0, y: (height - props.fontSize) / 2 },
|
4840
4881
|
'dominant-baseline': 'hanging',
|
4841
4882
|
'font-family': this.element.props.fontName,
|
4842
4883
|
'font-size': fontSize,
|
@@ -7220,7 +7261,7 @@ class CommentRenderObject extends LeafRenderObject {
|
|
7220
7261
|
data: {
|
7221
7262
|
ns: 'http://www.w3.org/2000/svg',
|
7222
7263
|
attrs: {
|
7223
|
-
|
7264
|
+
translate: { x: 0, y: paraLinePos.y - renderPos.y },
|
7224
7265
|
width: 2,
|
7225
7266
|
height: paraLinePos.height,
|
7226
7267
|
fill: color
|
@@ -8609,8 +8650,9 @@ class DataElementDate extends DataElementInlineGroup {
|
|
8609
8650
|
return super.cloneSelf(data, DataElementDate);
|
8610
8651
|
}
|
8611
8652
|
setValue(val) {
|
8612
|
-
if (val === null) {
|
8653
|
+
if (val === null || typeof val === 'undefined') {
|
8613
8654
|
this.clearInnerItems();
|
8655
|
+
this.props.value = '';
|
8614
8656
|
return;
|
8615
8657
|
}
|
8616
8658
|
const format = this.props.format ?? 'YYYY-MM-DD';
|
@@ -8624,18 +8666,24 @@ class DataElementDate extends DataElementInlineGroup {
|
|
8624
8666
|
}
|
8625
8667
|
this.pubOnChange('self');
|
8626
8668
|
this.clearInnerItems();
|
8669
|
+
this.props.value = date.format('YYYY-MM-DD HH:mm:ss');
|
8627
8670
|
const valueText = new TextGroupElement();
|
8628
8671
|
this.props.valueTextProps.clone(valueText.props);
|
8629
8672
|
valueText.text = formatStr;
|
8630
8673
|
this.addChild(valueText, this.length - 1);
|
8631
8674
|
this.onChangedValidate();
|
8632
8675
|
}
|
8633
|
-
isValid(val) {
|
8634
|
-
|
8676
|
+
isValid(val, format) {
|
8677
|
+
if (!format) {
|
8678
|
+
format = this.props.format ?? 'YYYY-MM-DD';
|
8679
|
+
}
|
8635
8680
|
const date = moment(val, format);
|
8636
8681
|
return date.isValid();
|
8637
8682
|
}
|
8638
8683
|
getValue() {
|
8684
|
+
if (this.props.value) {
|
8685
|
+
return this.props.value;
|
8686
|
+
}
|
8639
8687
|
return ElementSerialize.serializeString(this);
|
8640
8688
|
}
|
8641
8689
|
validate() {
|
@@ -8682,6 +8730,7 @@ class DataElementDateFactory extends DataElementBaseFactory {
|
|
8682
8730
|
dataEleProps.minValue = props.minValue;
|
8683
8731
|
dataEleProps.maxValue = props.maxValue;
|
8684
8732
|
dataEleProps.format = props.format;
|
8733
|
+
dataEleProps.value = props.value ?? '';
|
8685
8734
|
//dataEleProps.caption = props.caption;
|
8686
8735
|
//dataEleProps.type = props.type;
|
8687
8736
|
dataEleProps.nullText = props.nullText;
|
@@ -9605,7 +9654,7 @@ function renderMHHTML(event, element, isPaint, nodes = []) {
|
|
9605
9654
|
data: {
|
9606
9655
|
ns: "http://www.w3.org/2000/svg",
|
9607
9656
|
attrs: {
|
9608
|
-
|
9657
|
+
translate: { x, y: y + (height - leftRect.height) / 2 },
|
9609
9658
|
'dominant-baseline': 'Hanging',
|
9610
9659
|
'font-family': defaultTextProps.fontName,
|
9611
9660
|
'font-size': defaultTextProps.fontSize,
|
@@ -9622,7 +9671,7 @@ function renderMHHTML(event, element, isPaint, nodes = []) {
|
|
9622
9671
|
data: {
|
9623
9672
|
ns: "http://www.w3.org/2000/svg",
|
9624
9673
|
attrs: {
|
9625
|
-
|
9674
|
+
translate: { x: x + (middleWidth - topRect.width) / 2, y: y - 2 },
|
9626
9675
|
'dominant-baseline': 'Hanging',
|
9627
9676
|
'font-family': defaultTextProps.fontName,
|
9628
9677
|
'font-size': defaultTextProps.fontSize,
|
@@ -9641,7 +9690,7 @@ function renderMHHTML(event, element, isPaint, nodes = []) {
|
|
9641
9690
|
data: {
|
9642
9691
|
ns: "http://www.w3.org/2000/svg",
|
9643
9692
|
attrs: {
|
9644
|
-
|
9693
|
+
translate: { x: x + (middleWidth - bottomRect.width) / 2, y: y + topRect.height + 2 },
|
9645
9694
|
'dominant-baseline': 'Hanging',
|
9646
9695
|
'font-family': defaultTextProps.fontName,
|
9647
9696
|
'font-size': defaultTextProps.fontSize,
|
@@ -9658,7 +9707,7 @@ function renderMHHTML(event, element, isPaint, nodes = []) {
|
|
9658
9707
|
data: {
|
9659
9708
|
ns: "http://www.w3.org/2000/svg",
|
9660
9709
|
attrs: {
|
9661
|
-
|
9710
|
+
translate: { x, y: y + (height - leftRect.height) / 2 },
|
9662
9711
|
'dominant-baseline': 'Hanging',
|
9663
9712
|
'font-family': defaultTextProps.fontName,
|
9664
9713
|
'font-size': defaultTextProps.fontSize,
|
@@ -19926,10 +19975,7 @@ class DocumentChange {
|
|
19926
19975
|
insertSoftBr() {
|
19927
19976
|
let { startControl, startOffset } = this.selectionState;
|
19928
19977
|
const lastEle = this.insertElement(startControl, startOffset, [new BreakElement()]);
|
19929
|
-
|
19930
|
-
if (focusEle) {
|
19931
|
-
this.selectionState.resetRange(focusEle, 0);
|
19932
|
-
}
|
19978
|
+
this.selectionState.resetRange(lastEle, -1);
|
19933
19979
|
}
|
19934
19980
|
insertPageBreakSymbol() {
|
19935
19981
|
let { startControl, startOffset } = this.selectionState;
|
@@ -20247,19 +20293,20 @@ function createPrintTemplate({ width, height, orient }) {
|
|
20247
20293
|
-moz-box-sizing: border-box;
|
20248
20294
|
}
|
20249
20295
|
@page {
|
20250
|
-
size: ${orient};
|
20296
|
+
size: ${width}px ${height - 1}px ${orient};
|
20251
20297
|
margin: 0;
|
20252
20298
|
}
|
20253
20299
|
div {
|
20254
|
-
width: ${width}
|
20255
|
-
min-height: ${height}
|
20300
|
+
width: ${width}px;
|
20301
|
+
min-height: ${height - 1}px;
|
20302
|
+
overflow: hidden;
|
20256
20303
|
font-size: 0;
|
20257
20304
|
}
|
20258
20305
|
@media print {
|
20259
20306
|
html,
|
20260
20307
|
body {
|
20261
|
-
width: ${width}
|
20262
|
-
height: ${height}
|
20308
|
+
width: ${width}px;
|
20309
|
+
height: ${height - 1}px;
|
20263
20310
|
}
|
20264
20311
|
div {
|
20265
20312
|
width: initial;
|
@@ -20290,7 +20337,7 @@ function printNodes(printNodes, options, printEvent = null) {
|
|
20290
20337
|
console.warn('无可打印节点');
|
20291
20338
|
return;
|
20292
20339
|
}
|
20293
|
-
const printSize =
|
20340
|
+
const printSize = options;
|
20294
20341
|
const iframeHTML = createPrintTemplate(printSize);
|
20295
20342
|
printIFrame.contentWindow?.document.write(iframeHTML);
|
20296
20343
|
printIFrame.contentWindow?.document.close();
|
@@ -20316,18 +20363,6 @@ function printNodes(printNodes, options, printEvent = null) {
|
|
20316
20363
|
}
|
20317
20364
|
printIFrame.onload = () => {
|
20318
20365
|
setTimeout(() => {
|
20319
|
-
printIFrame.contentWindow?.window.matchMedia('print').addListener(function (query) {
|
20320
|
-
if (!query.matches) {
|
20321
|
-
console.log('用户已经打印');
|
20322
|
-
// 执行打印完成后需要执行的代码
|
20323
|
-
}
|
20324
|
-
});
|
20325
|
-
printIFrame.contentWindow?.window.matchMedia('screen').addListener(function (query) {
|
20326
|
-
if (!query.matches) {
|
20327
|
-
console.log('用户已经打印');
|
20328
|
-
// 执行打印完成后需要执行的代码
|
20329
|
-
}
|
20330
|
-
});
|
20331
20366
|
printIFrame.contentWindow?.print();
|
20332
20367
|
printIFrame.parentNode?.removeChild(printIFrame);
|
20333
20368
|
}, 0);
|
@@ -21088,6 +21123,40 @@ class DocumentSvg {
|
|
21088
21123
|
}
|
21089
21124
|
}
|
21090
21125
|
selectionRects.push(...selectionRectsTemp);
|
21126
|
+
// if (currVNode && currVNode.data?.attrs?.transform) {
|
21127
|
+
// currVNode.data.attrs.transform = `translate(${currVNode.data?.attrs?.transform.x},${currVNode.data?.attrs?.transform.y})`
|
21128
|
+
// }
|
21129
|
+
if (currVNode && currVNode.children) {
|
21130
|
+
let translateX = 0, translateY = 0;
|
21131
|
+
let line = false;
|
21132
|
+
if (render instanceof ParagraphLineRectRenderObject) {
|
21133
|
+
translateX = render.rect.x;
|
21134
|
+
translateY = render.rect.y;
|
21135
|
+
line = true;
|
21136
|
+
}
|
21137
|
+
currVNode.children.forEach(item => {
|
21138
|
+
if (item && item.data?.attrs?.translate && !item.data?.attrs?.transform) {
|
21139
|
+
item.data.attrs.transform = `translate(${item.data.attrs.translate.x + translateX},${item.data.attrs.translate.y + translateY})`;
|
21140
|
+
delete item.data.attrs.translate;
|
21141
|
+
}
|
21142
|
+
if (line && !item.data.attrs.transform) {
|
21143
|
+
item.data.attrs.transform = `translate(${translateX},${translateY})`;
|
21144
|
+
}
|
21145
|
+
// if (item && item.data?.attrs?.transform && typeof item.data?.attrs?.transform === 'object') {
|
21146
|
+
// item.data.attrs.transform = `translate(${item.data.attrs.transform.x + translateX},${item.data.attrs.transform.y + translateY})`
|
21147
|
+
// } else {
|
21148
|
+
// if (line && !item.data.attrs.transform) {
|
21149
|
+
// item.data.attrs.transform = `translate(${translateX},${translateY})`;
|
21150
|
+
// }
|
21151
|
+
// }
|
21152
|
+
});
|
21153
|
+
if (line) {
|
21154
|
+
return currVNode.children;
|
21155
|
+
}
|
21156
|
+
}
|
21157
|
+
if (currVNode && render.element) {
|
21158
|
+
currVNode.key = render.element.key + render.element.paintRenders.indexOf(render);
|
21159
|
+
}
|
21091
21160
|
return currVNode;
|
21092
21161
|
}
|
21093
21162
|
getHTMLVNode(docRenders) {
|
@@ -21105,11 +21174,7 @@ class DocumentSvg {
|
|
21105
21174
|
position: 'absolute',
|
21106
21175
|
background: 'white',
|
21107
21176
|
"box-shadow": "rgba(158, 161, 165, 0.4) 0px 2px 12px 0px",
|
21108
|
-
}
|
21109
|
-
hook: {
|
21110
|
-
insert: (vnode) => {
|
21111
|
-
}
|
21112
|
-
},
|
21177
|
+
}
|
21113
21178
|
},
|
21114
21179
|
children: [pageSvg]
|
21115
21180
|
};
|
@@ -21119,8 +21184,8 @@ class DocumentSvg {
|
|
21119
21184
|
}
|
21120
21185
|
/**
|
21121
21186
|
* 判断当前元素是否在视窗内
|
21122
|
-
* @param rect
|
21123
21187
|
* @private
|
21188
|
+
* @param item
|
21124
21189
|
*/
|
21125
21190
|
checkInViewBox(item) {
|
21126
21191
|
if (!this.viewOptions.virtualViewMode || this.mode === 'print') {
|
@@ -26195,46 +26260,31 @@ class DocumentPrintOffscreenBase {
|
|
26195
26260
|
* 续打
|
26196
26261
|
*/
|
26197
26262
|
async printForContinuation(data, options) {
|
26198
|
-
// const sub = this.beforeRenderEvent.subscribe((event) => {
|
26199
|
-
// const {index, renderCtx, docRender, pageSvgVNode} = event;
|
26200
|
-
// if (index === options.startDocIndex) {
|
26201
|
-
// const bodyRender = docRender.getChild(1);
|
26202
|
-
// let x = 0, y = options.startY, width = bodyRender.rect.width,
|
26203
|
-
// height = bodyRender.rect.height - (options.startY - bodyRender.rect.y);
|
26204
|
-
// if (options.startDocIndex === options.endDocIndex) {
|
26205
|
-
// height = options.endY - options.startY;
|
26206
|
-
// }
|
26207
|
-
// renderCtx.mainContext.clip(x, y, width, height);
|
26208
|
-
// }
|
26209
|
-
// });
|
26210
26263
|
this.afterRenderEvent.subscribe((event) => {
|
26211
26264
|
const { index, renderCtx, docRender, pageSvgVNode } = event;
|
26212
26265
|
if (index === options.startDocIndex && options.startY !== 0) {
|
26213
26266
|
const bodyRender = docRender.getChild(1);
|
26214
|
-
let x = bodyRender.rect.x, y = options.startY, width = bodyRender.rect.width,
|
26215
|
-
|
26216
|
-
|
26217
|
-
// }
|
26267
|
+
let x = bodyRender.rect.x, y = options.startY, width = bodyRender.rect.width,
|
26268
|
+
//由于body下面紧跟着页脚线,由于虚打不需要绘制该线,因此要裁剪掉2个像素
|
26269
|
+
height = bodyRender.rect.height - (options.startY - bodyRender.rect.y) - 2;
|
26218
26270
|
const pageClip = ElementUtil.createClipPath('page-clip-' + index, width, height, x, y);
|
26219
26271
|
//pageSvgVNode.children?.push(pageClip)
|
26220
26272
|
pageSvgVNode.children?.push(pageClip);
|
26221
26273
|
pageSvgVNode.data.attrs['clip-path'] = `url(#${'page-clip-' + index})`;
|
26222
26274
|
}
|
26223
|
-
// if (options.startDocIndex !== options.endDocIndex && index === options.endDocIndex) {
|
26224
|
-
// const bodyRender = docRender.getChild(1);
|
26225
|
-
// const height = bodyRender.rect.height - (options.endY - bodyRender.rect.y);
|
26226
|
-
// renderCtx.contentContext.clearRect(bodyRender.rect.x, options.endY, bodyRender.rect.width, height);
|
26227
|
-
// }
|
26228
26275
|
});
|
26229
26276
|
await this.prepare(data);
|
26230
26277
|
const printRanges = new Array(this.documentPaint.docPages.length).fill(0).map((item, index) => index).filter(index => index >= options.startDocIndex);
|
26231
|
-
|
26232
|
-
if (!
|
26278
|
+
let svgNodes = this.getSvgNodes(this.documentPaint.docPages, printRanges);
|
26279
|
+
if (!svgNodes.length) {
|
26233
26280
|
console.warn('无可打印页');
|
26234
26281
|
return;
|
26235
26282
|
}
|
26236
|
-
const docProps = this.docCtx.
|
26237
|
-
|
26283
|
+
const docProps = this.docCtx.viewOptions.docPageSettings;
|
26284
|
+
// if (docProps.orient === 'landscape') {
|
26285
|
+
// svgNodes = svgNodes.map(item => 'data:image/svg+xml;base64,' + CommonUtil.btoa(item)).map(item => `<img src="${item}" width="${docProps.width}px" height="${docProps.height-1}px" style="display: block"/>`);
|
26286
|
+
// }
|
26287
|
+
printNodes(svgNodes, docProps);
|
26238
26288
|
}
|
26239
26289
|
// /**
|
26240
26290
|
// * 获取绘制的图片,格式为Base64编码
|
@@ -26253,6 +26303,9 @@ class DocumentPrintOffscreenBase {
|
|
26253
26303
|
const canvasNodes = this.getSvgNodes(this.documentPaint.docPages, ranges);
|
26254
26304
|
return canvasNodes;
|
26255
26305
|
}
|
26306
|
+
Encode64(str) {
|
26307
|
+
return btoa(encodeURIComponent(str));
|
26308
|
+
}
|
26256
26309
|
/**
|
26257
26310
|
* 读取数据,排版
|
26258
26311
|
* @param data
|
@@ -26302,7 +26355,7 @@ class DocumentPrintOffscreenBase {
|
|
26302
26355
|
modules.class,
|
26303
26356
|
modules.props,
|
26304
26357
|
modules.attributes,
|
26305
|
-
modules.style
|
26358
|
+
modules.style,
|
26306
26359
|
]);
|
26307
26360
|
// const pageSvgVNodes = docRenders.filter((item, index) =>
|
26308
26361
|
// !printRanges || printRanges.indexOf(index) >= 0)
|
@@ -26614,6 +26667,17 @@ class EditorCalendarVNode {
|
|
26614
26667
|
sel: 'div.editor-calendar-footer-right',
|
26615
26668
|
data: {},
|
26616
26669
|
children: [{
|
26670
|
+
sel: 'div.editor-calendar-footer-right-btn',
|
26671
|
+
data: {
|
26672
|
+
on: {
|
26673
|
+
click: () => {
|
26674
|
+
this.onSetValue.next(undefined);
|
26675
|
+
}
|
26676
|
+
}
|
26677
|
+
},
|
26678
|
+
text: '清除'
|
26679
|
+
},
|
26680
|
+
{
|
26617
26681
|
sel: 'div.editor-calendar-footer-right-btn',
|
26618
26682
|
data: {
|
26619
26683
|
on: {
|
@@ -27643,10 +27707,22 @@ class DocEditor {
|
|
27643
27707
|
* 处理全选当前段落
|
27644
27708
|
*/
|
27645
27709
|
docDblClickHandle(evt) {
|
27646
|
-
|
27647
|
-
|
27710
|
+
//1.如果在数据元中双击,则默认选中数据元内部的所有内容
|
27711
|
+
const currDataEle = this.getCurrentDataElement();
|
27712
|
+
if (currDataEle && currDataEle instanceof DataElementInlineGroup && currDataEle.length > 2) {
|
27713
|
+
const range = new SelectionRange();
|
27714
|
+
range.setStart(currDataEle.startDecorate, 1);
|
27715
|
+
range.setEnd(currDataEle.endDecorate, 0);
|
27716
|
+
this.selectionState.addRange(range);
|
27648
27717
|
this.flushToSchedule();
|
27649
27718
|
}
|
27719
|
+
else {
|
27720
|
+
//2.默认选词
|
27721
|
+
const res = getFocusTextSegment(this.selectionState);
|
27722
|
+
if (res) {
|
27723
|
+
this.flushToSchedule();
|
27724
|
+
}
|
27725
|
+
}
|
27650
27726
|
this.updateSelection();
|
27651
27727
|
this.onDblClickEvent.next(evt);
|
27652
27728
|
}
|
@@ -28083,6 +28159,10 @@ class DocEditor {
|
|
28083
28159
|
}
|
28084
28160
|
}
|
28085
28161
|
scrollToPosition(pos) {
|
28162
|
+
const scale = this.viewOptions.scale;
|
28163
|
+
//处理缩放
|
28164
|
+
pos.x = pos.x * scale;
|
28165
|
+
pos.y = pos.y * scale;
|
28086
28166
|
if (pos.y - this.viewOptions.pageOffset.y > 0 && pos.y - this.viewOptions.pageOffset.y < this.viewOptions.viewSettings.height) {
|
28087
28167
|
return;
|
28088
28168
|
}
|
@@ -28283,9 +28363,12 @@ class DocEditor {
|
|
28283
28363
|
//console.timeEnd('patch');
|
28284
28364
|
};
|
28285
28365
|
render();
|
28286
|
-
this.onShouldRender.subscribe(() => {
|
28366
|
+
// this.onShouldRender.subscribe(() => {
|
28367
|
+
// render();
|
28368
|
+
// });
|
28369
|
+
this.onShouldRender.subscribe(CommonUtil.debounce(() => {
|
28287
28370
|
render();
|
28288
|
-
});
|
28371
|
+
}, 32));
|
28289
28372
|
}
|
28290
28373
|
/**
|
28291
28374
|
* 留痕提示的容器框,用于渲染后重新计算纵向位置
|
@@ -28559,10 +28642,10 @@ class DocEditor {
|
|
28559
28642
|
if (dataEle && dataEle instanceof DataElementDate && dataEle.props.editable) {
|
28560
28643
|
const position = editor.getDataElementPosition(dataEle.startDecorate);
|
28561
28644
|
let currVal = dataEle.getValue();
|
28562
|
-
if (!dataEle.isValid(currVal)) {
|
28645
|
+
if (!dataEle.isValid(currVal, 'YYYY-MM-DD HH:mm:ss')) {
|
28563
28646
|
currVal = '';
|
28564
28647
|
}
|
28565
|
-
return calendar.render(position, currVal
|
28648
|
+
return calendar.render(position, currVal);
|
28566
28649
|
}
|
28567
28650
|
calendar.reset();
|
28568
28651
|
return null;
|
@@ -28626,7 +28709,7 @@ class DocEditor {
|
|
28626
28709
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
28627
28710
|
}
|
28628
28711
|
version() {
|
28629
|
-
return "2.1.
|
28712
|
+
return "2.1.7";
|
28630
28713
|
}
|
28631
28714
|
}
|
28632
28715
|
|