@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-cjs.js
CHANGED
@@ -320,7 +320,8 @@ class RenderObject {
|
|
320
320
|
data: {
|
321
321
|
ns: "http://www.w3.org/2000/svg",
|
322
322
|
attrs: {
|
323
|
-
transform: `translate(${this.rect.x},${this.rect.y})`
|
323
|
+
//transform: `translate(${this.rect.x},${this.rect.y})`
|
324
|
+
translate: { x: this.rect.x, y: this.rect.y }
|
324
325
|
}
|
325
326
|
}
|
326
327
|
};
|
@@ -697,6 +698,35 @@ class CommonUtil {
|
|
697
698
|
}
|
698
699
|
return true;
|
699
700
|
}
|
701
|
+
static debounce(fn, wait) {
|
702
|
+
let timeout;
|
703
|
+
let lastExecTime = 0;
|
704
|
+
return function (...args) {
|
705
|
+
const context = this;
|
706
|
+
const elapsed = Date.now() - lastExecTime;
|
707
|
+
const shouldCallNow = elapsed >= wait;
|
708
|
+
clearTimeout(timeout);
|
709
|
+
if (shouldCallNow) {
|
710
|
+
fn.apply(context, args);
|
711
|
+
lastExecTime = Date.now();
|
712
|
+
}
|
713
|
+
else {
|
714
|
+
timeout = setTimeout(() => {
|
715
|
+
fn.apply(context, args);
|
716
|
+
lastExecTime = Date.now();
|
717
|
+
}, wait - elapsed);
|
718
|
+
}
|
719
|
+
};
|
720
|
+
}
|
721
|
+
static btoa(str) {
|
722
|
+
// 将SVG字符串转换为UTF-8编码的字节数组
|
723
|
+
const encoder = new TextEncoder();
|
724
|
+
encoder.encode(str);
|
725
|
+
// 将字节数组编码为Base64字符串
|
726
|
+
//return btoa(String.fromCharCode.apply(null, svgArray));
|
727
|
+
return btoa(unescape(encodeURIComponent(str)));
|
728
|
+
//return btoa(str.replace(/[\u00A0-\u2666]/g, c => `&#${c.charCodeAt(0)};`));
|
729
|
+
}
|
700
730
|
}
|
701
731
|
|
702
732
|
const docOpsMap = new Map();
|
@@ -867,7 +897,7 @@ function getExactDiffProps(oldProps, newProps) {
|
|
867
897
|
function generatePatch(doc) {
|
868
898
|
const insertOpsMap = new Map();
|
869
899
|
const formatOpsMap = new Map();
|
870
|
-
const
|
900
|
+
const patches = [];
|
871
901
|
const ops = docOpsMap.get(doc);
|
872
902
|
if (!ops || !ops.length) {
|
873
903
|
return [];
|
@@ -898,11 +928,14 @@ function generatePatch(doc) {
|
|
898
928
|
// op.prevIndex = log.prevIndex;
|
899
929
|
// op.parentIndex = log.parentIndex;
|
900
930
|
// }
|
901
|
-
|
931
|
+
if ('insert' in op.ops) {
|
932
|
+
op.ops.insert = ele.clone(true);
|
933
|
+
}
|
934
|
+
patches.push({ index: op.index, parentIndex: op.parentIndex, prevIndex: op.prevIndex, ops: op.ops });
|
902
935
|
}
|
903
936
|
//清空
|
904
937
|
ops.length = 0;
|
905
|
-
return
|
938
|
+
return patches;
|
906
939
|
}
|
907
940
|
/**
|
908
941
|
* 获取删除元素的操作
|
@@ -1078,7 +1111,10 @@ exports.ModifyFlag = void 0;
|
|
1078
1111
|
const elementTypeEventHandler = [];
|
1079
1112
|
function invokeTypeHandler(ele, eventName, e, useCapture = false) {
|
1080
1113
|
const predicate = (ele, th) => {
|
1081
|
-
if (
|
1114
|
+
if (!th.elementTypeCategory) {
|
1115
|
+
th.elementTypeCategory = CommonUtil.isConstructor(th.elementType) ? 'constructor' : 'function';
|
1116
|
+
}
|
1117
|
+
if (th.elementTypeCategory === 'constructor') {
|
1082
1118
|
return ele instanceof th.elementType;
|
1083
1119
|
}
|
1084
1120
|
else {
|
@@ -1141,6 +1177,7 @@ class Element {
|
|
1141
1177
|
logUpdateEleProps(this, p, oldValue, newValue);
|
1142
1178
|
this.pubOnChange('self');
|
1143
1179
|
}
|
1180
|
+
key;
|
1144
1181
|
//元素是否禁止复制,例如批注元素
|
1145
1182
|
//forbidCopy: boolean;
|
1146
1183
|
constructor(type) {
|
@@ -1152,6 +1189,7 @@ class Element {
|
|
1152
1189
|
this.addEvent('ElementMouseLeave', (evt) => {
|
1153
1190
|
this.isMouseenter = false;
|
1154
1191
|
});
|
1192
|
+
this.key = nanoid.nanoid(5);
|
1155
1193
|
}
|
1156
1194
|
destroy() {
|
1157
1195
|
this._eventMap?.clear(this);
|
@@ -1571,6 +1609,9 @@ class ViewOptions {
|
|
1571
1609
|
trackDelColor = '#000';
|
1572
1610
|
showLineRect;
|
1573
1611
|
showCharRect;
|
1612
|
+
//数据元交互修饰模式
|
1613
|
+
dataEleDecoratorMode = 'outline';
|
1614
|
+
dataEleDecoratorColor = '#0050b3';
|
1574
1615
|
showTabChar;
|
1575
1616
|
showSpaceChar;
|
1576
1617
|
showLineBreak;
|
@@ -2492,6 +2533,7 @@ class DataEleDateProps extends DataEleBaseTextProps {
|
|
2492
2533
|
minValue;
|
2493
2534
|
maxValue;
|
2494
2535
|
format;
|
2536
|
+
value;
|
2495
2537
|
clone(dest) {
|
2496
2538
|
const clone = dest ?? new DataEleDateProps();
|
2497
2539
|
super.clone(clone);
|
@@ -2504,7 +2546,8 @@ class DataEleDateProps extends DataEleBaseTextProps {
|
|
2504
2546
|
const props = {
|
2505
2547
|
minValue: this.minValue,
|
2506
2548
|
maxValue: this.maxValue,
|
2507
|
-
format: this.format
|
2549
|
+
format: this.format,
|
2550
|
+
value: this.value
|
2508
2551
|
};
|
2509
2552
|
this.getBaseProps(props, options);
|
2510
2553
|
return props;
|
@@ -3480,9 +3523,10 @@ class DocumentRenderObject extends BlockContainerRenderObject {
|
|
3480
3523
|
data: {
|
3481
3524
|
ns: "http://www.w3.org/2000/svg",
|
3482
3525
|
attrs: {
|
3526
|
+
"xmlns": "http://www.w3.org/2000/svg",
|
3483
3527
|
width: this.rect.width,
|
3484
|
-
height: this.rect.height,
|
3485
|
-
viewBox: `0 0 ${this.rect.width} ${this.rect.height}`,
|
3528
|
+
height: this.rect.height - 1,
|
3529
|
+
viewBox: `0 0 ${this.rect.width} ${this.rect.height - 1}`,
|
3486
3530
|
overflow: "hidden"
|
3487
3531
|
},
|
3488
3532
|
},
|
@@ -3924,8 +3968,21 @@ function drawDecorator(e, r) {
|
|
3924
3968
|
}
|
3925
3969
|
function exportDecoratorHTML(event, r) {
|
3926
3970
|
const canPaint = r.element.isMouseenter || r.element.isFocused;
|
3927
|
-
if (canPaint) {
|
3928
|
-
|
3971
|
+
if (!canPaint) {
|
3972
|
+
return;
|
3973
|
+
}
|
3974
|
+
const mode = event.options.dataEleDecoratorMode;
|
3975
|
+
const color = event.options.dataEleDecoratorColor;
|
3976
|
+
if (mode === 'none') {
|
3977
|
+
return;
|
3978
|
+
}
|
3979
|
+
if (mode === 'overlay') {
|
3980
|
+
const bgX = event.relativePagePos.x;
|
3981
|
+
const bgY = event.relativePagePos.y;
|
3982
|
+
event.highlights.push(ElementUtil.getFillSvgRect(bgX, bgY, r.rect.width, r.rect.height, color));
|
3983
|
+
return;
|
3984
|
+
}
|
3985
|
+
else if (mode === 'outline') {
|
3929
3986
|
const verOffset = 0;
|
3930
3987
|
const renderPosMap = getCurrentParaGroupRenders(r).map(item => ({ pos: getRenderPosToDoc(item), render: item }));
|
3931
3988
|
if (renderPosMap.length > 1) {
|
@@ -3959,7 +4016,7 @@ function exportDecoratorHTML(event, r) {
|
|
3959
4016
|
ns: 'http://www.w3.org/2000/svg',
|
3960
4017
|
attrs: {
|
3961
4018
|
d: path,
|
3962
|
-
stroke:
|
4019
|
+
stroke: color,
|
3963
4020
|
fill: 'none',
|
3964
4021
|
'stroke-width': 1
|
3965
4022
|
}
|
@@ -4075,15 +4132,7 @@ class DocumentBodyRenderObject extends MuiltBlockLineRenderObject {
|
|
4075
4132
|
return cloneRender;
|
4076
4133
|
}
|
4077
4134
|
exportHTML(event) {
|
4078
|
-
const t =
|
4079
|
-
sel: "g",
|
4080
|
-
data: {
|
4081
|
-
ns: "http://www.w3.org/2000/svg",
|
4082
|
-
attrs: {
|
4083
|
-
transform: `translate(${this.rect.x},${this.rect.y})`
|
4084
|
-
}
|
4085
|
-
}
|
4086
|
-
};
|
4135
|
+
const t = super.exportHTML(event);
|
4087
4136
|
if (this.element.disableClick && event.mode === 'view') {
|
4088
4137
|
t.data.attrs['opacity'] = 0.5;
|
4089
4138
|
}
|
@@ -4287,16 +4336,7 @@ class DocumentHeaderRenderObject extends BlockContainerRenderObject {
|
|
4287
4336
|
}
|
4288
4337
|
};
|
4289
4338
|
}
|
4290
|
-
const t =
|
4291
|
-
sel: "g",
|
4292
|
-
data: {
|
4293
|
-
ns: "http://www.w3.org/2000/svg",
|
4294
|
-
attrs: {
|
4295
|
-
transform: `translate(${this.rect.x},${this.rect.y})`
|
4296
|
-
}
|
4297
|
-
},
|
4298
|
-
children: []
|
4299
|
-
};
|
4339
|
+
const t = super.exportHTML(event);
|
4300
4340
|
// if (this.element.disableClick && event.mode === 'view') {
|
4301
4341
|
// t.data.attrs.opacity = 0.5;
|
4302
4342
|
// }
|
@@ -4865,7 +4905,8 @@ class TextGroupRenderObject extends LeafRenderObject {
|
|
4865
4905
|
data: {
|
4866
4906
|
ns: "http://www.w3.org/2000/svg",
|
4867
4907
|
attrs: {
|
4868
|
-
"transform": `translate(0,${(height - props.fontSize) / 2})`,
|
4908
|
+
//"transform": `translate(0,${(height - props.fontSize) / 2})`,
|
4909
|
+
"translate": { x: 0, y: (height - props.fontSize) / 2 },
|
4869
4910
|
'dominant-baseline': 'hanging',
|
4870
4911
|
'font-family': this.element.props.fontName,
|
4871
4912
|
'font-size': fontSize,
|
@@ -7249,7 +7290,7 @@ class CommentRenderObject extends LeafRenderObject {
|
|
7249
7290
|
data: {
|
7250
7291
|
ns: 'http://www.w3.org/2000/svg',
|
7251
7292
|
attrs: {
|
7252
|
-
|
7293
|
+
translate: { x: 0, y: paraLinePos.y - renderPos.y },
|
7253
7294
|
width: 2,
|
7254
7295
|
height: paraLinePos.height,
|
7255
7296
|
fill: color
|
@@ -8638,8 +8679,9 @@ class DataElementDate extends DataElementInlineGroup {
|
|
8638
8679
|
return super.cloneSelf(data, DataElementDate);
|
8639
8680
|
}
|
8640
8681
|
setValue(val) {
|
8641
|
-
if (val === null) {
|
8682
|
+
if (val === null || typeof val === 'undefined') {
|
8642
8683
|
this.clearInnerItems();
|
8684
|
+
this.props.value = '';
|
8643
8685
|
return;
|
8644
8686
|
}
|
8645
8687
|
const format = this.props.format ?? 'YYYY-MM-DD';
|
@@ -8653,18 +8695,24 @@ class DataElementDate extends DataElementInlineGroup {
|
|
8653
8695
|
}
|
8654
8696
|
this.pubOnChange('self');
|
8655
8697
|
this.clearInnerItems();
|
8698
|
+
this.props.value = date.format('YYYY-MM-DD HH:mm:ss');
|
8656
8699
|
const valueText = new TextGroupElement();
|
8657
8700
|
this.props.valueTextProps.clone(valueText.props);
|
8658
8701
|
valueText.text = formatStr;
|
8659
8702
|
this.addChild(valueText, this.length - 1);
|
8660
8703
|
this.onChangedValidate();
|
8661
8704
|
}
|
8662
|
-
isValid(val) {
|
8663
|
-
|
8705
|
+
isValid(val, format) {
|
8706
|
+
if (!format) {
|
8707
|
+
format = this.props.format ?? 'YYYY-MM-DD';
|
8708
|
+
}
|
8664
8709
|
const date = moment__default["default"](val, format);
|
8665
8710
|
return date.isValid();
|
8666
8711
|
}
|
8667
8712
|
getValue() {
|
8713
|
+
if (this.props.value) {
|
8714
|
+
return this.props.value;
|
8715
|
+
}
|
8668
8716
|
return ElementSerialize.serializeString(this);
|
8669
8717
|
}
|
8670
8718
|
validate() {
|
@@ -8711,6 +8759,7 @@ class DataElementDateFactory extends DataElementBaseFactory {
|
|
8711
8759
|
dataEleProps.minValue = props.minValue;
|
8712
8760
|
dataEleProps.maxValue = props.maxValue;
|
8713
8761
|
dataEleProps.format = props.format;
|
8762
|
+
dataEleProps.value = props.value ?? '';
|
8714
8763
|
//dataEleProps.caption = props.caption;
|
8715
8764
|
//dataEleProps.type = props.type;
|
8716
8765
|
dataEleProps.nullText = props.nullText;
|
@@ -9634,7 +9683,7 @@ function renderMHHTML(event, element, isPaint, nodes = []) {
|
|
9634
9683
|
data: {
|
9635
9684
|
ns: "http://www.w3.org/2000/svg",
|
9636
9685
|
attrs: {
|
9637
|
-
|
9686
|
+
translate: { x, y: y + (height - leftRect.height) / 2 },
|
9638
9687
|
'dominant-baseline': 'Hanging',
|
9639
9688
|
'font-family': defaultTextProps.fontName,
|
9640
9689
|
'font-size': defaultTextProps.fontSize,
|
@@ -9651,7 +9700,7 @@ function renderMHHTML(event, element, isPaint, nodes = []) {
|
|
9651
9700
|
data: {
|
9652
9701
|
ns: "http://www.w3.org/2000/svg",
|
9653
9702
|
attrs: {
|
9654
|
-
|
9703
|
+
translate: { x: x + (middleWidth - topRect.width) / 2, y: y - 2 },
|
9655
9704
|
'dominant-baseline': 'Hanging',
|
9656
9705
|
'font-family': defaultTextProps.fontName,
|
9657
9706
|
'font-size': defaultTextProps.fontSize,
|
@@ -9670,7 +9719,7 @@ function renderMHHTML(event, element, isPaint, nodes = []) {
|
|
9670
9719
|
data: {
|
9671
9720
|
ns: "http://www.w3.org/2000/svg",
|
9672
9721
|
attrs: {
|
9673
|
-
|
9722
|
+
translate: { x: x + (middleWidth - bottomRect.width) / 2, y: y + topRect.height + 2 },
|
9674
9723
|
'dominant-baseline': 'Hanging',
|
9675
9724
|
'font-family': defaultTextProps.fontName,
|
9676
9725
|
'font-size': defaultTextProps.fontSize,
|
@@ -9687,7 +9736,7 @@ function renderMHHTML(event, element, isPaint, nodes = []) {
|
|
9687
9736
|
data: {
|
9688
9737
|
ns: "http://www.w3.org/2000/svg",
|
9689
9738
|
attrs: {
|
9690
|
-
|
9739
|
+
translate: { x, y: y + (height - leftRect.height) / 2 },
|
9691
9740
|
'dominant-baseline': 'Hanging',
|
9692
9741
|
'font-family': defaultTextProps.fontName,
|
9693
9742
|
'font-size': defaultTextProps.fontSize,
|
@@ -19955,10 +20004,7 @@ class DocumentChange {
|
|
19955
20004
|
insertSoftBr() {
|
19956
20005
|
let { startControl, startOffset } = this.selectionState;
|
19957
20006
|
const lastEle = this.insertElement(startControl, startOffset, [new BreakElement()]);
|
19958
|
-
|
19959
|
-
if (focusEle) {
|
19960
|
-
this.selectionState.resetRange(focusEle, 0);
|
19961
|
-
}
|
20007
|
+
this.selectionState.resetRange(lastEle, -1);
|
19962
20008
|
}
|
19963
20009
|
insertPageBreakSymbol() {
|
19964
20010
|
let { startControl, startOffset } = this.selectionState;
|
@@ -20276,19 +20322,20 @@ function createPrintTemplate({ width, height, orient }) {
|
|
20276
20322
|
-moz-box-sizing: border-box;
|
20277
20323
|
}
|
20278
20324
|
@page {
|
20279
|
-
size: ${orient};
|
20325
|
+
size: ${width}px ${height - 1}px ${orient};
|
20280
20326
|
margin: 0;
|
20281
20327
|
}
|
20282
20328
|
div {
|
20283
|
-
width: ${width}
|
20284
|
-
min-height: ${height}
|
20329
|
+
width: ${width}px;
|
20330
|
+
min-height: ${height - 1}px;
|
20331
|
+
overflow: hidden;
|
20285
20332
|
font-size: 0;
|
20286
20333
|
}
|
20287
20334
|
@media print {
|
20288
20335
|
html,
|
20289
20336
|
body {
|
20290
|
-
width: ${width}
|
20291
|
-
height: ${height}
|
20337
|
+
width: ${width}px;
|
20338
|
+
height: ${height - 1}px;
|
20292
20339
|
}
|
20293
20340
|
div {
|
20294
20341
|
width: initial;
|
@@ -20319,7 +20366,7 @@ function printNodes(printNodes, options, printEvent = null) {
|
|
20319
20366
|
console.warn('无可打印节点');
|
20320
20367
|
return;
|
20321
20368
|
}
|
20322
|
-
const printSize =
|
20369
|
+
const printSize = options;
|
20323
20370
|
const iframeHTML = createPrintTemplate(printSize);
|
20324
20371
|
printIFrame.contentWindow?.document.write(iframeHTML);
|
20325
20372
|
printIFrame.contentWindow?.document.close();
|
@@ -20345,18 +20392,6 @@ function printNodes(printNodes, options, printEvent = null) {
|
|
20345
20392
|
}
|
20346
20393
|
printIFrame.onload = () => {
|
20347
20394
|
setTimeout(() => {
|
20348
|
-
printIFrame.contentWindow?.window.matchMedia('print').addListener(function (query) {
|
20349
|
-
if (!query.matches) {
|
20350
|
-
console.log('用户已经打印');
|
20351
|
-
// 执行打印完成后需要执行的代码
|
20352
|
-
}
|
20353
|
-
});
|
20354
|
-
printIFrame.contentWindow?.window.matchMedia('screen').addListener(function (query) {
|
20355
|
-
if (!query.matches) {
|
20356
|
-
console.log('用户已经打印');
|
20357
|
-
// 执行打印完成后需要执行的代码
|
20358
|
-
}
|
20359
|
-
});
|
20360
20395
|
printIFrame.contentWindow?.print();
|
20361
20396
|
printIFrame.parentNode?.removeChild(printIFrame);
|
20362
20397
|
}, 0);
|
@@ -21117,6 +21152,40 @@ class DocumentSvg {
|
|
21117
21152
|
}
|
21118
21153
|
}
|
21119
21154
|
selectionRects.push(...selectionRectsTemp);
|
21155
|
+
// if (currVNode && currVNode.data?.attrs?.transform) {
|
21156
|
+
// currVNode.data.attrs.transform = `translate(${currVNode.data?.attrs?.transform.x},${currVNode.data?.attrs?.transform.y})`
|
21157
|
+
// }
|
21158
|
+
if (currVNode && currVNode.children) {
|
21159
|
+
let translateX = 0, translateY = 0;
|
21160
|
+
let line = false;
|
21161
|
+
if (render instanceof ParagraphLineRectRenderObject) {
|
21162
|
+
translateX = render.rect.x;
|
21163
|
+
translateY = render.rect.y;
|
21164
|
+
line = true;
|
21165
|
+
}
|
21166
|
+
currVNode.children.forEach(item => {
|
21167
|
+
if (item && item.data?.attrs?.translate && !item.data?.attrs?.transform) {
|
21168
|
+
item.data.attrs.transform = `translate(${item.data.attrs.translate.x + translateX},${item.data.attrs.translate.y + translateY})`;
|
21169
|
+
delete item.data.attrs.translate;
|
21170
|
+
}
|
21171
|
+
if (line && !item.data.attrs.transform) {
|
21172
|
+
item.data.attrs.transform = `translate(${translateX},${translateY})`;
|
21173
|
+
}
|
21174
|
+
// if (item && item.data?.attrs?.transform && typeof item.data?.attrs?.transform === 'object') {
|
21175
|
+
// item.data.attrs.transform = `translate(${item.data.attrs.transform.x + translateX},${item.data.attrs.transform.y + translateY})`
|
21176
|
+
// } else {
|
21177
|
+
// if (line && !item.data.attrs.transform) {
|
21178
|
+
// item.data.attrs.transform = `translate(${translateX},${translateY})`;
|
21179
|
+
// }
|
21180
|
+
// }
|
21181
|
+
});
|
21182
|
+
if (line) {
|
21183
|
+
return currVNode.children;
|
21184
|
+
}
|
21185
|
+
}
|
21186
|
+
if (currVNode && render.element) {
|
21187
|
+
currVNode.key = render.element.key + render.element.paintRenders.indexOf(render);
|
21188
|
+
}
|
21120
21189
|
return currVNode;
|
21121
21190
|
}
|
21122
21191
|
getHTMLVNode(docRenders) {
|
@@ -21134,11 +21203,7 @@ class DocumentSvg {
|
|
21134
21203
|
position: 'absolute',
|
21135
21204
|
background: 'white',
|
21136
21205
|
"box-shadow": "rgba(158, 161, 165, 0.4) 0px 2px 12px 0px",
|
21137
|
-
}
|
21138
|
-
hook: {
|
21139
|
-
insert: (vnode) => {
|
21140
|
-
}
|
21141
|
-
},
|
21206
|
+
}
|
21142
21207
|
},
|
21143
21208
|
children: [pageSvg]
|
21144
21209
|
};
|
@@ -21148,8 +21213,8 @@ class DocumentSvg {
|
|
21148
21213
|
}
|
21149
21214
|
/**
|
21150
21215
|
* 判断当前元素是否在视窗内
|
21151
|
-
* @param rect
|
21152
21216
|
* @private
|
21217
|
+
* @param item
|
21153
21218
|
*/
|
21154
21219
|
checkInViewBox(item) {
|
21155
21220
|
if (!this.viewOptions.virtualViewMode || this.mode === 'print') {
|
@@ -26224,46 +26289,31 @@ class DocumentPrintOffscreenBase {
|
|
26224
26289
|
* 续打
|
26225
26290
|
*/
|
26226
26291
|
async printForContinuation(data, options) {
|
26227
|
-
// const sub = this.beforeRenderEvent.subscribe((event) => {
|
26228
|
-
// const {index, renderCtx, docRender, pageSvgVNode} = event;
|
26229
|
-
// if (index === options.startDocIndex) {
|
26230
|
-
// const bodyRender = docRender.getChild(1);
|
26231
|
-
// let x = 0, y = options.startY, width = bodyRender.rect.width,
|
26232
|
-
// height = bodyRender.rect.height - (options.startY - bodyRender.rect.y);
|
26233
|
-
// if (options.startDocIndex === options.endDocIndex) {
|
26234
|
-
// height = options.endY - options.startY;
|
26235
|
-
// }
|
26236
|
-
// renderCtx.mainContext.clip(x, y, width, height);
|
26237
|
-
// }
|
26238
|
-
// });
|
26239
26292
|
this.afterRenderEvent.subscribe((event) => {
|
26240
26293
|
const { index, renderCtx, docRender, pageSvgVNode } = event;
|
26241
26294
|
if (index === options.startDocIndex && options.startY !== 0) {
|
26242
26295
|
const bodyRender = docRender.getChild(1);
|
26243
|
-
let x = bodyRender.rect.x, y = options.startY, width = bodyRender.rect.width,
|
26244
|
-
|
26245
|
-
|
26246
|
-
// }
|
26296
|
+
let x = bodyRender.rect.x, y = options.startY, width = bodyRender.rect.width,
|
26297
|
+
//由于body下面紧跟着页脚线,由于虚打不需要绘制该线,因此要裁剪掉2个像素
|
26298
|
+
height = bodyRender.rect.height - (options.startY - bodyRender.rect.y) - 2;
|
26247
26299
|
const pageClip = ElementUtil.createClipPath('page-clip-' + index, width, height, x, y);
|
26248
26300
|
//pageSvgVNode.children?.push(pageClip)
|
26249
26301
|
pageSvgVNode.children?.push(pageClip);
|
26250
26302
|
pageSvgVNode.data.attrs['clip-path'] = `url(#${'page-clip-' + index})`;
|
26251
26303
|
}
|
26252
|
-
// if (options.startDocIndex !== options.endDocIndex && index === options.endDocIndex) {
|
26253
|
-
// const bodyRender = docRender.getChild(1);
|
26254
|
-
// const height = bodyRender.rect.height - (options.endY - bodyRender.rect.y);
|
26255
|
-
// renderCtx.contentContext.clearRect(bodyRender.rect.x, options.endY, bodyRender.rect.width, height);
|
26256
|
-
// }
|
26257
26304
|
});
|
26258
26305
|
await this.prepare(data);
|
26259
26306
|
const printRanges = new Array(this.documentPaint.docPages.length).fill(0).map((item, index) => index).filter(index => index >= options.startDocIndex);
|
26260
|
-
|
26261
|
-
if (!
|
26307
|
+
let svgNodes = this.getSvgNodes(this.documentPaint.docPages, printRanges);
|
26308
|
+
if (!svgNodes.length) {
|
26262
26309
|
console.warn('无可打印页');
|
26263
26310
|
return;
|
26264
26311
|
}
|
26265
|
-
const docProps = this.docCtx.
|
26266
|
-
|
26312
|
+
const docProps = this.docCtx.viewOptions.docPageSettings;
|
26313
|
+
// if (docProps.orient === 'landscape') {
|
26314
|
+
// 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"/>`);
|
26315
|
+
// }
|
26316
|
+
printNodes(svgNodes, docProps);
|
26267
26317
|
}
|
26268
26318
|
// /**
|
26269
26319
|
// * 获取绘制的图片,格式为Base64编码
|
@@ -26282,6 +26332,9 @@ class DocumentPrintOffscreenBase {
|
|
26282
26332
|
const canvasNodes = this.getSvgNodes(this.documentPaint.docPages, ranges);
|
26283
26333
|
return canvasNodes;
|
26284
26334
|
}
|
26335
|
+
Encode64(str) {
|
26336
|
+
return btoa(encodeURIComponent(str));
|
26337
|
+
}
|
26285
26338
|
/**
|
26286
26339
|
* 读取数据,排版
|
26287
26340
|
* @param data
|
@@ -26331,7 +26384,7 @@ class DocumentPrintOffscreenBase {
|
|
26331
26384
|
modules.class,
|
26332
26385
|
modules.props,
|
26333
26386
|
modules.attributes,
|
26334
|
-
modules.style
|
26387
|
+
modules.style,
|
26335
26388
|
]);
|
26336
26389
|
// const pageSvgVNodes = docRenders.filter((item, index) =>
|
26337
26390
|
// !printRanges || printRanges.indexOf(index) >= 0)
|
@@ -26643,6 +26696,17 @@ class EditorCalendarVNode {
|
|
26643
26696
|
sel: 'div.editor-calendar-footer-right',
|
26644
26697
|
data: {},
|
26645
26698
|
children: [{
|
26699
|
+
sel: 'div.editor-calendar-footer-right-btn',
|
26700
|
+
data: {
|
26701
|
+
on: {
|
26702
|
+
click: () => {
|
26703
|
+
this.onSetValue.next(undefined);
|
26704
|
+
}
|
26705
|
+
}
|
26706
|
+
},
|
26707
|
+
text: '清除'
|
26708
|
+
},
|
26709
|
+
{
|
26646
26710
|
sel: 'div.editor-calendar-footer-right-btn',
|
26647
26711
|
data: {
|
26648
26712
|
on: {
|
@@ -27672,10 +27736,22 @@ class DocEditor {
|
|
27672
27736
|
* 处理全选当前段落
|
27673
27737
|
*/
|
27674
27738
|
docDblClickHandle(evt) {
|
27675
|
-
|
27676
|
-
|
27739
|
+
//1.如果在数据元中双击,则默认选中数据元内部的所有内容
|
27740
|
+
const currDataEle = this.getCurrentDataElement();
|
27741
|
+
if (currDataEle && currDataEle instanceof DataElementInlineGroup && currDataEle.length > 2) {
|
27742
|
+
const range = new SelectionRange();
|
27743
|
+
range.setStart(currDataEle.startDecorate, 1);
|
27744
|
+
range.setEnd(currDataEle.endDecorate, 0);
|
27745
|
+
this.selectionState.addRange(range);
|
27677
27746
|
this.flushToSchedule();
|
27678
27747
|
}
|
27748
|
+
else {
|
27749
|
+
//2.默认选词
|
27750
|
+
const res = getFocusTextSegment(this.selectionState);
|
27751
|
+
if (res) {
|
27752
|
+
this.flushToSchedule();
|
27753
|
+
}
|
27754
|
+
}
|
27679
27755
|
this.updateSelection();
|
27680
27756
|
this.onDblClickEvent.next(evt);
|
27681
27757
|
}
|
@@ -28112,6 +28188,10 @@ class DocEditor {
|
|
28112
28188
|
}
|
28113
28189
|
}
|
28114
28190
|
scrollToPosition(pos) {
|
28191
|
+
const scale = this.viewOptions.scale;
|
28192
|
+
//处理缩放
|
28193
|
+
pos.x = pos.x * scale;
|
28194
|
+
pos.y = pos.y * scale;
|
28115
28195
|
if (pos.y - this.viewOptions.pageOffset.y > 0 && pos.y - this.viewOptions.pageOffset.y < this.viewOptions.viewSettings.height) {
|
28116
28196
|
return;
|
28117
28197
|
}
|
@@ -28312,9 +28392,12 @@ class DocEditor {
|
|
28312
28392
|
//console.timeEnd('patch');
|
28313
28393
|
};
|
28314
28394
|
render();
|
28315
|
-
this.onShouldRender.subscribe(() => {
|
28395
|
+
// this.onShouldRender.subscribe(() => {
|
28396
|
+
// render();
|
28397
|
+
// });
|
28398
|
+
this.onShouldRender.subscribe(CommonUtil.debounce(() => {
|
28316
28399
|
render();
|
28317
|
-
});
|
28400
|
+
}, 32));
|
28318
28401
|
}
|
28319
28402
|
/**
|
28320
28403
|
* 留痕提示的容器框,用于渲染后重新计算纵向位置
|
@@ -28588,10 +28671,10 @@ class DocEditor {
|
|
28588
28671
|
if (dataEle && dataEle instanceof DataElementDate && dataEle.props.editable) {
|
28589
28672
|
const position = editor.getDataElementPosition(dataEle.startDecorate);
|
28590
28673
|
let currVal = dataEle.getValue();
|
28591
|
-
if (!dataEle.isValid(currVal)) {
|
28674
|
+
if (!dataEle.isValid(currVal, 'YYYY-MM-DD HH:mm:ss')) {
|
28592
28675
|
currVal = '';
|
28593
28676
|
}
|
28594
|
-
return calendar.render(position, currVal
|
28677
|
+
return calendar.render(position, currVal);
|
28595
28678
|
}
|
28596
28679
|
calendar.reset();
|
28597
28680
|
return null;
|
@@ -28655,7 +28738,7 @@ class DocEditor {
|
|
28655
28738
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
28656
28739
|
}
|
28657
28740
|
version() {
|
28658
|
-
return "2.1.
|
28741
|
+
return "2.1.7";
|
28659
28742
|
}
|
28660
28743
|
}
|
28661
28744
|
|