@hailin-zheng/editor-core 2.2.0 → 2.2.2
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/editor.css +54 -2
- package/index-cjs.js +282 -153
- package/index-cjs.js.map +1 -1
- package/index.js +281 -154
- package/index.js.map +1 -1
- package/med_editor/framework/doc-layout/document-arrange.d.ts +6 -0
- package/med_editor/framework/document-context.d.ts +4 -7
- package/med_editor/framework/document-paginator.d.ts +5 -0
- package/med_editor/framework/element-props.d.ts +0 -2
- package/med_editor/framework/impl/data-element/data-element-base-impl.d.ts +13 -0
- package/package.json +1 -1
package/index-cjs.js
CHANGED
@@ -833,28 +833,21 @@ function getDocCtx(ele) {
|
|
833
833
|
if (!doc) {
|
834
834
|
return null;
|
835
835
|
}
|
836
|
-
|
837
|
-
if (!options || !options.enableTrackHistory) {
|
838
|
-
return null;
|
839
|
-
}
|
840
|
-
return {
|
841
|
-
doc,
|
842
|
-
options: doc['viewOptions']
|
843
|
-
};
|
836
|
+
return doc;
|
844
837
|
}
|
845
838
|
function insertEle(ele) {
|
846
839
|
if (ele.type === 'psym') {
|
847
840
|
return;
|
848
841
|
}
|
849
|
-
const
|
850
|
-
if (!
|
842
|
+
const docCtx = getDocCtx(ele);
|
843
|
+
if (!docCtx) {
|
851
844
|
return;
|
852
845
|
}
|
853
846
|
// const serializeObj = getEleSerializeFunc(ele, options);
|
854
847
|
// if (!serializeObj) {
|
855
848
|
// return;
|
856
849
|
// }
|
857
|
-
appendToOps(
|
850
|
+
appendToOps(docCtx, ele, {
|
858
851
|
//如果当前插入的为单元格,由于新插入的单元格,内部的内容没有补足,导致后续计算索引会出现问题
|
859
852
|
//之前为ele.clone(true);
|
860
853
|
insert: ele
|
@@ -864,11 +857,11 @@ function removeEle(ele) {
|
|
864
857
|
if (ele.type === 'psym') {
|
865
858
|
return;
|
866
859
|
}
|
867
|
-
const
|
868
|
-
if (!
|
860
|
+
const docCtx = getDocCtx(ele);
|
861
|
+
if (!docCtx) {
|
869
862
|
return;
|
870
863
|
}
|
871
|
-
appendToOps(
|
864
|
+
appendToOps(docCtx, ele, {
|
872
865
|
delete: ele.clone(true),
|
873
866
|
});
|
874
867
|
}
|
@@ -891,15 +884,15 @@ function getOpsLog(ele, ops) {
|
|
891
884
|
};
|
892
885
|
}
|
893
886
|
function inputText(ele, startIndex, input) {
|
894
|
-
const
|
895
|
-
if (!
|
887
|
+
const docCtx = getDocCtx(ele);
|
888
|
+
if (!docCtx) {
|
896
889
|
return;
|
897
890
|
}
|
898
891
|
if (!input) {
|
899
892
|
return;
|
900
893
|
}
|
901
894
|
//处理修复:如果当前的文字刚插入,这时候输入的文字内容已经被序列化到操作日志中了,就不需要生成操作日志
|
902
|
-
let array = docOpsMap.get(
|
895
|
+
let array = docOpsMap.get(docCtx);
|
903
896
|
if (array) {
|
904
897
|
const lastLog = array[array.length - 1];
|
905
898
|
if (lastLog && 'insert' in lastLog.ops) {
|
@@ -908,7 +901,7 @@ function inputText(ele, startIndex, input) {
|
|
908
901
|
}
|
909
902
|
}
|
910
903
|
}
|
911
|
-
appendToOps(
|
904
|
+
appendToOps(docCtx, ele, {
|
912
905
|
insText: {
|
913
906
|
index: startIndex,
|
914
907
|
length: input.length
|
@@ -917,14 +910,14 @@ function inputText(ele, startIndex, input) {
|
|
917
910
|
});
|
918
911
|
}
|
919
912
|
function removeText(ele, index, length, content) {
|
920
|
-
const
|
921
|
-
if (!
|
913
|
+
const docCtx = getDocCtx(ele);
|
914
|
+
if (!docCtx) {
|
922
915
|
return;
|
923
916
|
}
|
924
917
|
if (!length) {
|
925
918
|
return;
|
926
919
|
}
|
927
|
-
appendToOps(
|
920
|
+
appendToOps(docCtx, ele, {
|
928
921
|
delText: {
|
929
922
|
index,
|
930
923
|
length
|
@@ -939,15 +932,15 @@ function removeText(ele, index, length, content) {
|
|
939
932
|
* @returns
|
940
933
|
*/
|
941
934
|
function formatEle(ele, props) {
|
942
|
-
const
|
943
|
-
if (!
|
935
|
+
const docCtx = getDocCtx(ele);
|
936
|
+
if (!docCtx) {
|
944
937
|
return;
|
945
938
|
}
|
946
939
|
const updateKeys = Object.keys(props);
|
947
940
|
if (!updateKeys.length) {
|
948
941
|
return;
|
949
942
|
}
|
950
|
-
appendToOps(
|
943
|
+
appendToOps(docCtx, ele, {
|
951
944
|
format: getExactDiffProps(ele.props, props)
|
952
945
|
});
|
953
946
|
}
|
@@ -959,11 +952,11 @@ function formatEle(ele, props) {
|
|
959
952
|
* @param newValue
|
960
953
|
*/
|
961
954
|
function logUpdateEleProps(ele, p, oldValue, newValue) {
|
962
|
-
const
|
963
|
-
if (!
|
955
|
+
const docCtx = getDocCtx(ele);
|
956
|
+
if (!docCtx) {
|
964
957
|
return;
|
965
958
|
}
|
966
|
-
appendToOps(
|
959
|
+
appendToOps(docCtx, ele, {
|
967
960
|
format: {
|
968
961
|
[p]: {
|
969
962
|
oldValue,
|
@@ -2142,7 +2135,6 @@ class DocumentProps extends INotifyPropertyChanged {
|
|
2142
2135
|
createUserId;
|
2143
2136
|
createUserName;
|
2144
2137
|
createDate;
|
2145
|
-
scripts;
|
2146
2138
|
columns = 1;
|
2147
2139
|
version;
|
2148
2140
|
clone(dest) {
|
@@ -2153,7 +2145,6 @@ class DocumentProps extends INotifyPropertyChanged {
|
|
2153
2145
|
clone.padding = this.padding.clone();
|
2154
2146
|
clone.headerLine = this.headerLine;
|
2155
2147
|
clone.footerLine = this.footerLine;
|
2156
|
-
clone.scripts = this.scripts;
|
2157
2148
|
clone.createUserId = this.createUserId;
|
2158
2149
|
clone.createUserName = this.createUserName;
|
2159
2150
|
clone.createDate = this.createDate;
|
@@ -2173,9 +2164,6 @@ class DocumentProps extends INotifyPropertyChanged {
|
|
2173
2164
|
createUserName: this.createUserName,
|
2174
2165
|
createUserId: this.createUserId,
|
2175
2166
|
};
|
2176
|
-
if (this.scripts) {
|
2177
|
-
props['scripts'] = this.scripts;
|
2178
|
-
}
|
2179
2167
|
if (this.orient && this.orient !== 'portrait') {
|
2180
2168
|
props['orient'] = this.orient;
|
2181
2169
|
}
|
@@ -2409,7 +2397,6 @@ class DataEleBaseProps extends INotifyPropertyChanged {
|
|
2409
2397
|
printable;
|
2410
2398
|
secretBrowse;
|
2411
2399
|
editable = true;
|
2412
|
-
deleteable;
|
2413
2400
|
minLength;
|
2414
2401
|
underline;
|
2415
2402
|
expression;
|
@@ -2425,7 +2412,6 @@ class DataEleBaseProps extends INotifyPropertyChanged {
|
|
2425
2412
|
target.fieldName = source.fieldName;
|
2426
2413
|
target.required = source.required;
|
2427
2414
|
target.editable = source.editable;
|
2428
|
-
target.deleteable = source.deleteable;
|
2429
2415
|
target.secretBrowse = source.secretBrowse;
|
2430
2416
|
target.printable = source.printable;
|
2431
2417
|
target.minLength = source.minLength;
|
@@ -2455,9 +2441,6 @@ class DataEleBaseProps extends INotifyPropertyChanged {
|
|
2455
2441
|
if (!this.editable) {
|
2456
2442
|
props['editable'] = this.editable;
|
2457
2443
|
}
|
2458
|
-
if (this.deleteable) {
|
2459
|
-
props["deleteable"] = this.deleteable;
|
2460
|
-
}
|
2461
2444
|
if (this.minLength) {
|
2462
2445
|
props["minLength"] = this.minLength;
|
2463
2446
|
}
|
@@ -3681,7 +3664,8 @@ class DocumentRenderObject extends BlockContainerRenderObject {
|
|
3681
3664
|
width: this.rect.width,
|
3682
3665
|
height: this.rect.height - 1,
|
3683
3666
|
viewBox: `0 0 ${this.rect.width} ${this.rect.height - 1}`,
|
3684
|
-
overflow: "hidden"
|
3667
|
+
overflow: "hidden",
|
3668
|
+
"shape-rendering": "optimizeSpeed"
|
3685
3669
|
},
|
3686
3670
|
},
|
3687
3671
|
children: [
|
@@ -3731,7 +3715,6 @@ class DocumentFactory extends ElementFactory {
|
|
3731
3715
|
docProps.padding = new PaddingProps(props.padding.top, props.padding.bottom, props.padding.left, props.padding.right);
|
3732
3716
|
docProps.headerLine = props.headerLine ?? 12;
|
3733
3717
|
docProps.footerLine = props.footerLine ?? 12;
|
3734
|
-
docProps.scripts = props.scripts;
|
3735
3718
|
docProps.createUserId = props.createUserId;
|
3736
3719
|
docProps.createUserName = props.createUserName;
|
3737
3720
|
docProps.createDate = props.createDate;
|
@@ -3973,6 +3956,7 @@ class DataElementRenderObject extends InlineGroupRenderObject {
|
|
3973
3956
|
}
|
3974
3957
|
});
|
3975
3958
|
}
|
3959
|
+
renderErrorTip(event, this);
|
3976
3960
|
return node;
|
3977
3961
|
}
|
3978
3962
|
}
|
@@ -4028,6 +4012,11 @@ class DataElementBaseFactory extends ElementFactory {
|
|
4028
4012
|
}
|
4029
4013
|
}
|
4030
4014
|
}
|
4015
|
+
/**
|
4016
|
+
* 渲染数据元背景修饰
|
4017
|
+
* @param event
|
4018
|
+
* @param r
|
4019
|
+
*/
|
4031
4020
|
function exportDecoratorHTML(event, r) {
|
4032
4021
|
const canPaint = r.element.isMouseenter || r.element.isFocused;
|
4033
4022
|
if (!canPaint) {
|
@@ -4072,10 +4061,12 @@ function exportDecoratorHTML(event, r) {
|
|
4072
4061
|
const sharpPoints1 = CommonUtil.resharpPoints(rightPoints);
|
4073
4062
|
const sharpPoints = CommonUtil.resharpPoints([...leftPoints.reverse()]);
|
4074
4063
|
const path = [...sharpPoints, ...sharpPoints1, sharpPoints[0]].map((item, index) => ((index === 0) ? 'M' : "L") + item.x + " " + item.y).join(" ");
|
4075
|
-
event.highlights.push(ElementUtil.createSvgPath({
|
4064
|
+
event.highlights.push(ElementUtil.createSvgPath({
|
4065
|
+
d: path,
|
4076
4066
|
stroke: color,
|
4077
4067
|
fill: 'none',
|
4078
|
-
'stroke-width': 1
|
4068
|
+
'stroke-width': 1
|
4069
|
+
}));
|
4079
4070
|
return;
|
4080
4071
|
}
|
4081
4072
|
}
|
@@ -4090,6 +4081,110 @@ function exportDecoratorHTML(event, r) {
|
|
4090
4081
|
}
|
4091
4082
|
}
|
4092
4083
|
}
|
4084
|
+
/**
|
4085
|
+
* 渲染数据源验证错误提示框
|
4086
|
+
*/
|
4087
|
+
function renderErrorTip(event, r) {
|
4088
|
+
if (!event.options.enableDataEleInputValidate || event.mode === 'print') {
|
4089
|
+
return;
|
4090
|
+
}
|
4091
|
+
const ele = r.element;
|
4092
|
+
//元素调用内部验证
|
4093
|
+
ele.onChangedValidate();
|
4094
|
+
if (!ele.errorTip) {
|
4095
|
+
return;
|
4096
|
+
}
|
4097
|
+
//渲染底部波浪线
|
4098
|
+
renderUnderWavyLine(event, r, 'red');
|
4099
|
+
if (ele.paintRenders.indexOf(r) !== 0) {
|
4100
|
+
return;
|
4101
|
+
}
|
4102
|
+
const { x, y } = event.globalPos;
|
4103
|
+
const docRender = ElementUtil.getParentRender(r, DocumentRenderObject);
|
4104
|
+
const content = ele.errorTip;
|
4105
|
+
let left = ele.isFocused ? -10 : 5;
|
4106
|
+
//显示在文档的右测
|
4107
|
+
left += docRender.rect.x + docRender.rect.width + 20;
|
4108
|
+
let sel = 'div.tg-container';
|
4109
|
+
if (ele.isFocused) {
|
4110
|
+
sel += '.tg-container--selected';
|
4111
|
+
}
|
4112
|
+
const node = {
|
4113
|
+
sel,
|
4114
|
+
key: ele.props.id,
|
4115
|
+
data: {
|
4116
|
+
style: {
|
4117
|
+
left: `${left}px`,
|
4118
|
+
top: `${y}px`
|
4119
|
+
},
|
4120
|
+
dataset: {
|
4121
|
+
key: ele.key
|
4122
|
+
}
|
4123
|
+
},
|
4124
|
+
children: [{
|
4125
|
+
sel: 'div.header',
|
4126
|
+
data: {},
|
4127
|
+
children: [{
|
4128
|
+
sel: 'span.header-user',
|
4129
|
+
data: {},
|
4130
|
+
text: ele.props.caption,
|
4131
|
+
}]
|
4132
|
+
}, {
|
4133
|
+
sel: 'div.content',
|
4134
|
+
data: {},
|
4135
|
+
text: content
|
4136
|
+
}]
|
4137
|
+
};
|
4138
|
+
event.addChangeTips(node);
|
4139
|
+
const triangleTipX = x + r.rect.width / 2;
|
4140
|
+
const tipLineAWidth = docRender.rect.x + docRender.rect.width - triangleTipX;
|
4141
|
+
const tipLineA = {
|
4142
|
+
sel: 'div.doc-triangle-line',
|
4143
|
+
data: {
|
4144
|
+
style: {
|
4145
|
+
left: `${triangleTipX}px`,
|
4146
|
+
top: `${y + r.rect.height}px`,
|
4147
|
+
width: tipLineAWidth + 'px'
|
4148
|
+
}
|
4149
|
+
}
|
4150
|
+
};
|
4151
|
+
const tipLineB = {
|
4152
|
+
sel: 'div.doc-triangle-line',
|
4153
|
+
data: {
|
4154
|
+
style: {
|
4155
|
+
left: `${triangleTipX + tipLineAWidth}px`,
|
4156
|
+
top: `${y + r.rect.height}px`,
|
4157
|
+
width: 20 + 'px'
|
4158
|
+
},
|
4159
|
+
dataset: {
|
4160
|
+
key: ele.key
|
4161
|
+
}
|
4162
|
+
}
|
4163
|
+
};
|
4164
|
+
const triangleTip = {
|
4165
|
+
sel: `div.doc-triangle`,
|
4166
|
+
data: {
|
4167
|
+
style: {
|
4168
|
+
left: `${triangleTipX}px`,
|
4169
|
+
top: `${y + r.rect.height * 2 / 3}px`
|
4170
|
+
}
|
4171
|
+
}
|
4172
|
+
};
|
4173
|
+
event.addChangeTips(triangleTip);
|
4174
|
+
event.addChangeTips(tipLineA);
|
4175
|
+
event.addChangeTips(tipLineB);
|
4176
|
+
}
|
4177
|
+
/**
|
4178
|
+
* 渲染底部波浪线
|
4179
|
+
*/
|
4180
|
+
function renderUnderWavyLine(event, r, color) {
|
4181
|
+
const { x, y } = event.relativePagePos;
|
4182
|
+
let d = `M ${x} ${y + r.rect.height - 2} q 1.5,2, `;
|
4183
|
+
const width = r.rect.width;
|
4184
|
+
d += Array(Math.ceil(width / 3)).fill("3,0").join(' t ');
|
4185
|
+
const path = ElementUtil.createSvgPath({ d, fill: 'none', stroke: color });
|
4186
|
+
event.highlights.push(path);
|
4187
|
+
}
|
4093
4188
|
/**
|
4094
4189
|
* 获取渲染元素相对稳当的位置
|
4095
4190
|
* @param render
|
@@ -6830,7 +6925,7 @@ class CommentElement extends LeafElement {
|
|
6830
6925
|
constructor() {
|
6831
6926
|
super('comm');
|
6832
6927
|
//this.isDecorate = true;
|
6833
|
-
this.disableClick = true;
|
6928
|
+
//this.disableClick = true;
|
6834
6929
|
this.props = new CommProps();
|
6835
6930
|
this.color = CommonUtil.randomRgbColor(0.5);
|
6836
6931
|
}
|
@@ -6860,6 +6955,9 @@ class CommentElement extends LeafElement {
|
|
6860
6955
|
}
|
6861
6956
|
class CommentRenderObject extends LeafRenderObject {
|
6862
6957
|
exportSVG(event) {
|
6958
|
+
if (event.mode === 'print') {
|
6959
|
+
return;
|
6960
|
+
}
|
6863
6961
|
const renderPos = { ...event.relativePagePos };
|
6864
6962
|
const paraLinePos = ElementUtil.getParaLinePos(this, { x: renderPos.x, y: renderPos.y });
|
6865
6963
|
const color = '#ff4d4f';
|
@@ -8366,9 +8464,6 @@ class DataElementDate extends DataElementInlineGroup {
|
|
8366
8464
|
this.onChangedValidate();
|
8367
8465
|
}
|
8368
8466
|
isValid(val, format) {
|
8369
|
-
if (!format) {
|
8370
|
-
format = this.props.format ?? 'YYYY-MM-DD';
|
8371
|
-
}
|
8372
8467
|
const date = moment__default["default"](val, format);
|
8373
8468
|
return date.isValid();
|
8374
8469
|
}
|
@@ -8383,8 +8478,7 @@ class DataElementDate extends DataElementInlineGroup {
|
|
8383
8478
|
if (res) {
|
8384
8479
|
return res;
|
8385
8480
|
}
|
8386
|
-
const
|
8387
|
-
const date = moment__default["default"](this.getValue(), format, true);
|
8481
|
+
const date = moment__default["default"](this.getValue(), true);
|
8388
8482
|
if (!date.isValid()) {
|
8389
8483
|
return '日期格式不正确';
|
8390
8484
|
}
|
@@ -10754,7 +10848,6 @@ class ElementUtil {
|
|
10754
10848
|
dest.printable = props.printable ?? true;
|
10755
10849
|
dest.required = props.required;
|
10756
10850
|
dest.secretBrowse = props.secretBrowse;
|
10757
|
-
dest.deleteable = props.deleteable;
|
10758
10851
|
dest.underline = props.underline;
|
10759
10852
|
dest.expression = props.expression;
|
10760
10853
|
dest.hidden = props.hidden;
|
@@ -12840,54 +12933,6 @@ class PaintContent {
|
|
12840
12933
|
}
|
12841
12934
|
}
|
12842
12935
|
|
12843
|
-
class DocumentEvalFunc {
|
12844
|
-
docCtx;
|
12845
|
-
constructor(docCtx) {
|
12846
|
-
this.docCtx = docCtx;
|
12847
|
-
}
|
12848
|
-
scriptsFunc;
|
12849
|
-
/**
|
12850
|
-
* 实例化动态脚本
|
12851
|
-
*/
|
12852
|
-
initScripts(scripts) {
|
12853
|
-
this.destroyScripts();
|
12854
|
-
if (scripts) {
|
12855
|
-
try {
|
12856
|
-
const func = new Function("docCtx", scripts);
|
12857
|
-
this.scriptsFunc = func(this.docCtx);
|
12858
|
-
}
|
12859
|
-
catch (e) {
|
12860
|
-
console.error("自定义标本解析错误", e);
|
12861
|
-
}
|
12862
|
-
}
|
12863
|
-
// const func = (docCtx: DocumentContext) => {
|
12864
|
-
// const sexELe = docCtx.getControlById('NqoYI')
|
12865
|
-
// const dyEle = docCtx.getControlById('gTuBI');
|
12866
|
-
// return () => {
|
12867
|
-
// if (sexELe && dyEle) {
|
12868
|
-
// const sexValue = sexELe.getValue();
|
12869
|
-
// const dyValue = sexValue === '1' ? '男的吗' : sexValue === '2' ? '女的吗' : '难道是人妖吗';
|
12870
|
-
// dyEle.setValue(dyValue);
|
12871
|
-
// }
|
12872
|
-
// };
|
12873
|
-
// };
|
12874
|
-
}
|
12875
|
-
/**
|
12876
|
-
* 销毁动态脚本实例
|
12877
|
-
*/
|
12878
|
-
destroyScripts() {
|
12879
|
-
if (this.scriptsFunc) {
|
12880
|
-
this.scriptsFunc = null;
|
12881
|
-
}
|
12882
|
-
}
|
12883
|
-
/**
|
12884
|
-
* 触发动态脚本
|
12885
|
-
*/
|
12886
|
-
invokedScripts() {
|
12887
|
-
this.scriptsFunc?.();
|
12888
|
-
}
|
12889
|
-
}
|
12890
|
-
|
12891
12936
|
/**
|
12892
12937
|
* 当前打开的文档的上下文信息,当前文档所有的属性设置都暴露在上下文中
|
12893
12938
|
*/
|
@@ -12898,22 +12943,29 @@ class EditorContext {
|
|
12898
12943
|
cursorRect;
|
12899
12944
|
_document;
|
12900
12945
|
syncRefresh;
|
12901
|
-
dynamicFunc;
|
12902
12946
|
docChange;
|
12903
12947
|
clearPrevDocCb;
|
12904
12948
|
//绘制结束之后回调函数
|
12905
|
-
|
12949
|
+
nextViewFns = [];
|
12950
|
+
//批注元素存在的标志,用于判断文档空间进行布局
|
12951
|
+
commentFlag = false;
|
12952
|
+
//留痕元素存在的标志,用于判断文档空间进行布局
|
12953
|
+
trackFlag = false;
|
12906
12954
|
constructor(selectionState, viewOptions) {
|
12907
12955
|
this.selectionState = selectionState;
|
12908
12956
|
this.viewOptions = viewOptions;
|
12909
|
-
this.dynamicFunc = new DocumentEvalFunc(this);
|
12910
12957
|
//this.imageLoader = new DocumentImagesLoader();
|
12911
12958
|
this.selectionState.onChangedEvent.subscribe(() => {
|
12912
12959
|
this.syncRefresh?.();
|
12913
12960
|
});
|
12914
12961
|
}
|
12915
12962
|
onNextView(cb) {
|
12916
|
-
|
12963
|
+
if (!cb) {
|
12964
|
+
this.nextViewFns.length = 0;
|
12965
|
+
return;
|
12966
|
+
}
|
12967
|
+
//this.nextViewFn = cb;
|
12968
|
+
this.nextViewFns.push(cb);
|
12917
12969
|
}
|
12918
12970
|
get document() {
|
12919
12971
|
return this._document;
|
@@ -12921,7 +12973,6 @@ class EditorContext {
|
|
12921
12973
|
set document(value) {
|
12922
12974
|
this.clearPrevDocCb?.();
|
12923
12975
|
this._document = value;
|
12924
|
-
this.initScripts();
|
12925
12976
|
// this.refSub = this._document.refreshSubject.subscribe((data) => {
|
12926
12977
|
// data = data ?? 'content';
|
12927
12978
|
// this.isDirty = this.isDirty || data === 'content';
|
@@ -12949,8 +13000,6 @@ class EditorContext {
|
|
12949
13000
|
}
|
12950
13001
|
clear() {
|
12951
13002
|
this.selectionState.clear();
|
12952
|
-
//this.imageLoader.clear();
|
12953
|
-
this.dynamicFunc.destroyScripts();
|
12954
13003
|
this.isDirty = false;
|
12955
13004
|
//this.clearEleDepMaps();
|
12956
13005
|
}
|
@@ -13002,12 +13051,6 @@ class EditorContext {
|
|
13002
13051
|
this.document.viewOptions.textRowLineMode = !this.document.viewOptions.textRowLineMode;
|
13003
13052
|
this.syncRefresh();
|
13004
13053
|
}
|
13005
|
-
/**
|
13006
|
-
* 实例化动态脚本
|
13007
|
-
*/
|
13008
|
-
initScripts() {
|
13009
|
-
this.dynamicFunc.initScripts(this.document.props.scripts);
|
13010
|
-
}
|
13011
13054
|
/**
|
13012
13055
|
* 替换数据元
|
13013
13056
|
*/
|
@@ -13026,6 +13069,15 @@ class EditorContext {
|
|
13026
13069
|
}
|
13027
13070
|
return this._document.modifyFlag === exports.ModifyFlag.None ? 'appearance' : 'content';
|
13028
13071
|
}
|
13072
|
+
adaptiveScale() {
|
13073
|
+
if (this.viewOptions.pageLayoutMode !== 'fit-page') {
|
13074
|
+
return this.viewOptions.scale;
|
13075
|
+
}
|
13076
|
+
const docWidth = this.viewOptions.contentWidth;
|
13077
|
+
const viewWidth = this.viewOptions.viewSettings.width;
|
13078
|
+
const availableWidth = viewWidth * 0.9;
|
13079
|
+
return Math.round(availableWidth * 100 / docWidth) / 100;
|
13080
|
+
}
|
13029
13081
|
}
|
13030
13082
|
/**
|
13031
13083
|
* 文档上下文
|
@@ -14191,9 +14243,7 @@ class DocumentArrange {
|
|
14191
14243
|
execute: this.execute,
|
14192
14244
|
createParaFn: () => this.createDefaultPara()
|
14193
14245
|
};
|
14194
|
-
|
14195
|
-
this.clearPaintCache(doc, data);
|
14196
|
-
//this.docCtx.viewOptions.showReviewWindow = this.docCtx.document.commentsContainerElement.markPairs.length > 0;
|
14246
|
+
this.reset(data);
|
14197
14247
|
const docRenders = this.arrangeDoc();
|
14198
14248
|
this.setMeasureCompletedModifyFlag(doc);
|
14199
14249
|
this.cacheDocRenders(docRenders);
|
@@ -14201,7 +14251,17 @@ class DocumentArrange {
|
|
14201
14251
|
return docRenders;
|
14202
14252
|
});
|
14203
14253
|
}
|
14204
|
-
|
14254
|
+
/**
|
14255
|
+
* 重置文档测量的相关信息
|
14256
|
+
* @param data
|
14257
|
+
* @private
|
14258
|
+
*/
|
14259
|
+
reset(data) {
|
14260
|
+
this.docCtx.document.clearMarkItems();
|
14261
|
+
this.docCtx.trackFlag = false;
|
14262
|
+
this.docCtx.commentFlag = false;
|
14263
|
+
this.clearPaintCache(data.doc, data);
|
14264
|
+
}
|
14205
14265
|
arrangeDoc() {
|
14206
14266
|
const doc = this.docCtx.document;
|
14207
14267
|
const docRender = doc.createRenderObject();
|
@@ -14745,8 +14805,12 @@ class DocumentArrange {
|
|
14745
14805
|
}
|
14746
14806
|
identifyComment(ele) {
|
14747
14807
|
if (ele instanceof CommentElement) {
|
14808
|
+
this.docCtx.commentFlag = true;
|
14748
14809
|
this.docCtx.document.identifyCommMark(ele);
|
14749
14810
|
}
|
14811
|
+
else if (ele instanceof TrackRunElement) {
|
14812
|
+
this.docCtx.trackFlag = true;
|
14813
|
+
}
|
14750
14814
|
}
|
14751
14815
|
cacheDoc;
|
14752
14816
|
cacheDocRenders(docs) {
|
@@ -14827,8 +14891,31 @@ class DocumentPaginator {
|
|
14827
14891
|
this.docContainer.rect.width = this.viewOptions.docPageSettings.width;
|
14828
14892
|
const newMeasure = new DocumentArrange(this.docCtx, this.renderContext, this.seo);
|
14829
14893
|
this.docPages = newMeasure.measureDoc();
|
14894
|
+
this.adjustTipLayoutWidth();
|
14830
14895
|
this.layoutPages();
|
14831
14896
|
}
|
14897
|
+
/**
|
14898
|
+
* 处理计算提示框布局宽度
|
14899
|
+
* @private
|
14900
|
+
*/
|
14901
|
+
adjustTipLayoutWidth() {
|
14902
|
+
let layoutFlag = false;
|
14903
|
+
if (this.docCtx.trackFlag && this.docCtx.viewOptions.showTrackChangesTip || this.docCtx.commentFlag) {
|
14904
|
+
layoutFlag = true;
|
14905
|
+
}
|
14906
|
+
if (layoutFlag) {
|
14907
|
+
if (this.viewOptions.reviewWindowWidth === 0) {
|
14908
|
+
this.viewOptions.reviewWindowWidth = 250;
|
14909
|
+
this.viewOptions.scale = this.docCtx.adaptiveScale();
|
14910
|
+
}
|
14911
|
+
}
|
14912
|
+
else {
|
14913
|
+
if (this.viewOptions.reviewWindowWidth > 0) {
|
14914
|
+
this.viewOptions.reviewWindowWidth = 0;
|
14915
|
+
this.viewOptions.scale = this.docCtx.adaptiveScale();
|
14916
|
+
}
|
14917
|
+
}
|
14918
|
+
}
|
14832
14919
|
/**
|
14833
14920
|
* 文档页面显示布局
|
14834
14921
|
*/
|
@@ -16836,7 +16923,7 @@ class DocumentChange {
|
|
16836
16923
|
if (res && res.isCancel) {
|
16837
16924
|
return;
|
16838
16925
|
}
|
16839
|
-
this.docComment.syncUpdateComments();
|
16926
|
+
//this.docComment.syncUpdateComments();
|
16840
16927
|
if (collapsed) {
|
16841
16928
|
this.onBackspaceElement(startControl, startOffset);
|
16842
16929
|
}
|
@@ -18478,6 +18565,7 @@ class ElementTrackManage {
|
|
18478
18565
|
*/
|
18479
18566
|
generateTrack() {
|
18480
18567
|
if (!this.docCtx.viewOptions.enableTrackHistory) {
|
18568
|
+
clearTraces(this.docCtx.document);
|
18481
18569
|
return;
|
18482
18570
|
}
|
18483
18571
|
const ops = generatePatch(this.docCtx.document);
|
@@ -20255,8 +20343,6 @@ class DocEditor {
|
|
20255
20343
|
trackChangeState = true;
|
20256
20344
|
flushToSchedule() {
|
20257
20345
|
if (this.docCtx.refreshType === 'content') {
|
20258
|
-
//触发动态脚本
|
20259
|
-
this.docCtx.dynamicFunc.invokedScripts();
|
20260
20346
|
this.triggerDocChange();
|
20261
20347
|
}
|
20262
20348
|
if (this.flushTask) {
|
@@ -20267,10 +20353,11 @@ class DocEditor {
|
|
20267
20353
|
this.readDocChangeLog();
|
20268
20354
|
this.refreshDocument();
|
20269
20355
|
this.flushTask = null;
|
20270
|
-
|
20271
|
-
|
20356
|
+
//回调
|
20357
|
+
let cbs = [...this.docCtx.nextViewFns];
|
20358
|
+
if (cbs.length) {
|
20272
20359
|
this.docCtx.onNextView(null);
|
20273
|
-
cb();
|
20360
|
+
cbs.forEach(cb => cb());
|
20274
20361
|
return;
|
20275
20362
|
}
|
20276
20363
|
this.historyMange.generateTrack();
|
@@ -20431,7 +20518,7 @@ class DocEditor {
|
|
20431
20518
|
this.editInput.style.left = position.x + 'px';
|
20432
20519
|
this.editInput.style.top = position.y + 'px';
|
20433
20520
|
this.editInput.style.height = position.height + 'px';
|
20434
|
-
this.editInput.style.width = "
|
20521
|
+
this.editInput.style.width = "1.6px";
|
20435
20522
|
this.editInput.readOnly = false;
|
20436
20523
|
this.setCursorVisibility(true);
|
20437
20524
|
//判断光标位置是否被可见,如果不可见,需要将其设置到可见区域
|
@@ -20614,14 +20701,7 @@ class DocEditor {
|
|
20614
20701
|
* @private
|
20615
20702
|
*/
|
20616
20703
|
adaptiveScale() {
|
20617
|
-
|
20618
|
-
return;
|
20619
|
-
}
|
20620
|
-
const docWidth = this.docCtx.viewOptions.docPageSettings.width;
|
20621
|
-
const viewWidth = this.docCtx.viewOptions.viewSettings.width;
|
20622
|
-
const availableWidth = viewWidth * 0.9;
|
20623
|
-
const scale = Math.round(availableWidth * 100 / docWidth) / 100;
|
20624
|
-
this.viewOptions.scale = scale;
|
20704
|
+
this.viewOptions.scale = this.docCtx.adaptiveScale();
|
20625
20705
|
}
|
20626
20706
|
/**
|
20627
20707
|
* 缩放视图
|
@@ -21220,12 +21300,20 @@ class DocEditor {
|
|
21220
21300
|
},
|
21221
21301
|
children: []
|
21222
21302
|
};
|
21303
|
+
const scaleFitContainer = {
|
21304
|
+
sel: 'div#scale-fit-container',
|
21305
|
+
data: {
|
21306
|
+
style: { overflow: 'hidden', height: '0px', }
|
21307
|
+
},
|
21308
|
+
children: [docContent]
|
21309
|
+
};
|
21223
21310
|
if (!this.documentPaginator?.docContainer) {
|
21224
|
-
return
|
21311
|
+
return scaleFitContainer;
|
21225
21312
|
}
|
21226
21313
|
const tipsContainer = this.createChangeTipContainer();
|
21227
21314
|
this.tipContainer = tipsContainer;
|
21228
21315
|
docContent.data.style.height = this.documentPaginator.getDocumentContainerHeight().height + 'px';
|
21316
|
+
scaleFitContainer.data.style['height'] = this.documentPaginator.getDocumentContainerHeight().height * this.viewOptions.scale + 'px';
|
21229
21317
|
const docRenders = this.documentPaginator.docContainer.getItems();
|
21230
21318
|
const svgGenerator = new DocumentSvg(this.viewOptions, this.selectionOverlays, this.renderContext);
|
21231
21319
|
const vNode = svgGenerator.getHTMLVNode(docRenders);
|
@@ -21233,12 +21321,12 @@ class DocEditor {
|
|
21233
21321
|
children.push(tipsContainer);
|
21234
21322
|
children.push(...vNode);
|
21235
21323
|
tipsContainer.children?.push(...svgGenerator.changeTips);
|
21236
|
-
this.updateTipLayoutWidth();
|
21324
|
+
//this.updateTipLayoutWidth();
|
21237
21325
|
const sub = this.afterNodePatch.subscribe(() => {
|
21238
21326
|
this.updateTipLayoutAfterPatch();
|
21239
21327
|
sub.unsubscribe();
|
21240
21328
|
});
|
21241
|
-
return
|
21329
|
+
return scaleFitContainer;
|
21242
21330
|
}
|
21243
21331
|
};
|
21244
21332
|
}
|
@@ -21252,14 +21340,14 @@ class DocEditor {
|
|
21252
21340
|
if (this.viewOptions.reviewWindowWidth > 0) {
|
21253
21341
|
this.viewOptions.reviewWindowWidth = 0;
|
21254
21342
|
//刷新页面
|
21255
|
-
this.adjustPageLayout();
|
21343
|
+
this.docCtx.onNextView(() => { this.adjustPageLayout(); });
|
21256
21344
|
}
|
21257
21345
|
}
|
21258
21346
|
else {
|
21259
21347
|
if (this.viewOptions.reviewWindowWidth === 0) {
|
21260
21348
|
this.viewOptions.reviewWindowWidth = 250;
|
21261
21349
|
//刷新页面
|
21262
|
-
this.adjustPageLayout();
|
21350
|
+
this.docCtx.onNextView(() => { this.adjustPageLayout(); });
|
21263
21351
|
}
|
21264
21352
|
}
|
21265
21353
|
}
|
@@ -21347,30 +21435,21 @@ class DocEditor {
|
|
21347
21435
|
};
|
21348
21436
|
const itemsVNode = options.map(item => {
|
21349
21437
|
const ckbVNode = {
|
21350
|
-
sel: multiSelect ? '
|
21351
|
-
data: {
|
21352
|
-
attrs: {
|
21353
|
-
type: 'checkbox',
|
21354
|
-
name: 'data-list',
|
21355
|
-
}
|
21356
|
-
}
|
21438
|
+
sel: multiSelect ? 'div.editor-list-checkbox' : 'div.editor-list-radiobox',
|
21439
|
+
data: {}
|
21357
21440
|
};
|
21358
21441
|
if (item.checked) {
|
21359
|
-
ckbVNode.
|
21442
|
+
ckbVNode.sel += '.checked';
|
21443
|
+
//ckbVNode.data.attrs['checked'] = true;
|
21360
21444
|
}
|
21361
21445
|
return {
|
21362
|
-
sel: 'div', data: {
|
21446
|
+
sel: 'div', data: { on: {
|
21447
|
+
click: () => {
|
21448
|
+
onChangeHandler(item.code);
|
21449
|
+
}
|
21450
|
+
} }, children: [ckbVNode, {
|
21363
21451
|
sel: 'label',
|
21364
|
-
data: {
|
21365
|
-
attrs: {
|
21366
|
-
//for:"data-list-"+item.code,
|
21367
|
-
},
|
21368
|
-
on: {
|
21369
|
-
click: (evt) => {
|
21370
|
-
onChangeHandler(item.code);
|
21371
|
-
}
|
21372
|
-
}
|
21373
|
-
},
|
21452
|
+
data: {},
|
21374
21453
|
text: item.value
|
21375
21454
|
}]
|
21376
21455
|
};
|
@@ -21534,7 +21613,7 @@ class DocEditor {
|
|
21534
21613
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
21535
21614
|
}
|
21536
21615
|
version() {
|
21537
|
-
return "2.2.
|
21616
|
+
return "2.2.2";
|
21538
21617
|
}
|
21539
21618
|
switchPageHeaderEditor() {
|
21540
21619
|
this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
|
@@ -21684,6 +21763,54 @@ class DocumentCombine {
|
|
21684
21763
|
}
|
21685
21764
|
}
|
21686
21765
|
|
21766
|
+
class DocumentEvalFunc {
|
21767
|
+
docCtx;
|
21768
|
+
constructor(docCtx) {
|
21769
|
+
this.docCtx = docCtx;
|
21770
|
+
}
|
21771
|
+
scriptsFunc;
|
21772
|
+
/**
|
21773
|
+
* 实例化动态脚本
|
21774
|
+
*/
|
21775
|
+
initScripts(scripts) {
|
21776
|
+
this.destroyScripts();
|
21777
|
+
if (scripts) {
|
21778
|
+
try {
|
21779
|
+
const func = new Function("docCtx", scripts);
|
21780
|
+
this.scriptsFunc = func(this.docCtx);
|
21781
|
+
}
|
21782
|
+
catch (e) {
|
21783
|
+
console.error("自定义标本解析错误", e);
|
21784
|
+
}
|
21785
|
+
}
|
21786
|
+
// const func = (docCtx: DocumentContext) => {
|
21787
|
+
// const sexELe = docCtx.getControlById('NqoYI')
|
21788
|
+
// const dyEle = docCtx.getControlById('gTuBI');
|
21789
|
+
// return () => {
|
21790
|
+
// if (sexELe && dyEle) {
|
21791
|
+
// const sexValue = sexELe.getValue();
|
21792
|
+
// const dyValue = sexValue === '1' ? '男的吗' : sexValue === '2' ? '女的吗' : '难道是人妖吗';
|
21793
|
+
// dyEle.setValue(dyValue);
|
21794
|
+
// }
|
21795
|
+
// };
|
21796
|
+
// };
|
21797
|
+
}
|
21798
|
+
/**
|
21799
|
+
* 销毁动态脚本实例
|
21800
|
+
*/
|
21801
|
+
destroyScripts() {
|
21802
|
+
if (this.scriptsFunc) {
|
21803
|
+
this.scriptsFunc = null;
|
21804
|
+
}
|
21805
|
+
}
|
21806
|
+
/**
|
21807
|
+
* 触发动态脚本
|
21808
|
+
*/
|
21809
|
+
invokedScripts() {
|
21810
|
+
this.scriptsFunc?.();
|
21811
|
+
}
|
21812
|
+
}
|
21813
|
+
|
21687
21814
|
function createPrintTemplate({ width, height, orient }) {
|
21688
21815
|
return `
|
21689
21816
|
<!DOCTYPE html>
|
@@ -27272,6 +27399,8 @@ exports.parser = parser;
|
|
27272
27399
|
exports.reactiveMap = reactiveMap;
|
27273
27400
|
exports.removeEle = removeEle;
|
27274
27401
|
exports.removeText = removeText;
|
27402
|
+
exports.renderErrorTip = renderErrorTip;
|
27403
|
+
exports.renderUnderWavyLine = renderUnderWavyLine;
|
27275
27404
|
exports.runTextLineRender = runTextLineRender;
|
27276
27405
|
exports.setChildrenModifyFlag = setChildrenModifyFlag;
|
27277
27406
|
exports.setDataElementProps = setDataElementProps;
|