@hailin-zheng/editor-core 2.2.1 → 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 +52 -1
- package/index-cjs.js +125 -105
- package/index-cjs.js.map +1 -1
- package/index.js +125 -105
- 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 +3 -6
- package/med_editor/framework/document-paginator.d.ts +5 -0
- package/med_editor/framework/element-props.d.ts +0 -1
- package/package.json +1 -1
package/index.js
CHANGED
@@ -2106,7 +2106,6 @@ class DocumentProps extends INotifyPropertyChanged {
|
|
2106
2106
|
createUserId;
|
2107
2107
|
createUserName;
|
2108
2108
|
createDate;
|
2109
|
-
scripts;
|
2110
2109
|
columns = 1;
|
2111
2110
|
version;
|
2112
2111
|
clone(dest) {
|
@@ -2117,7 +2116,6 @@ class DocumentProps extends INotifyPropertyChanged {
|
|
2117
2116
|
clone.padding = this.padding.clone();
|
2118
2117
|
clone.headerLine = this.headerLine;
|
2119
2118
|
clone.footerLine = this.footerLine;
|
2120
|
-
clone.scripts = this.scripts;
|
2121
2119
|
clone.createUserId = this.createUserId;
|
2122
2120
|
clone.createUserName = this.createUserName;
|
2123
2121
|
clone.createDate = this.createDate;
|
@@ -2137,9 +2135,6 @@ class DocumentProps extends INotifyPropertyChanged {
|
|
2137
2135
|
createUserName: this.createUserName,
|
2138
2136
|
createUserId: this.createUserId,
|
2139
2137
|
};
|
2140
|
-
if (this.scripts) {
|
2141
|
-
props['scripts'] = this.scripts;
|
2142
|
-
}
|
2143
2138
|
if (this.orient && this.orient !== 'portrait') {
|
2144
2139
|
props['orient'] = this.orient;
|
2145
2140
|
}
|
@@ -3691,7 +3686,6 @@ class DocumentFactory extends ElementFactory {
|
|
3691
3686
|
docProps.padding = new PaddingProps(props.padding.top, props.padding.bottom, props.padding.left, props.padding.right);
|
3692
3687
|
docProps.headerLine = props.headerLine ?? 12;
|
3693
3688
|
docProps.footerLine = props.footerLine ?? 12;
|
3694
|
-
docProps.scripts = props.scripts;
|
3695
3689
|
docProps.createUserId = props.createUserId;
|
3696
3690
|
docProps.createUserName = props.createUserName;
|
3697
3691
|
docProps.createDate = props.createDate;
|
@@ -6902,7 +6896,7 @@ class CommentElement extends LeafElement {
|
|
6902
6896
|
constructor() {
|
6903
6897
|
super('comm');
|
6904
6898
|
//this.isDecorate = true;
|
6905
|
-
this.disableClick = true;
|
6899
|
+
//this.disableClick = true;
|
6906
6900
|
this.props = new CommProps();
|
6907
6901
|
this.color = CommonUtil.randomRgbColor(0.5);
|
6908
6902
|
}
|
@@ -12910,54 +12904,6 @@ class PaintContent {
|
|
12910
12904
|
}
|
12911
12905
|
}
|
12912
12906
|
|
12913
|
-
class DocumentEvalFunc {
|
12914
|
-
docCtx;
|
12915
|
-
constructor(docCtx) {
|
12916
|
-
this.docCtx = docCtx;
|
12917
|
-
}
|
12918
|
-
scriptsFunc;
|
12919
|
-
/**
|
12920
|
-
* 实例化动态脚本
|
12921
|
-
*/
|
12922
|
-
initScripts(scripts) {
|
12923
|
-
this.destroyScripts();
|
12924
|
-
if (scripts) {
|
12925
|
-
try {
|
12926
|
-
const func = new Function("docCtx", scripts);
|
12927
|
-
this.scriptsFunc = func(this.docCtx);
|
12928
|
-
}
|
12929
|
-
catch (e) {
|
12930
|
-
console.error("自定义标本解析错误", e);
|
12931
|
-
}
|
12932
|
-
}
|
12933
|
-
// const func = (docCtx: DocumentContext) => {
|
12934
|
-
// const sexELe = docCtx.getControlById('NqoYI')
|
12935
|
-
// const dyEle = docCtx.getControlById('gTuBI');
|
12936
|
-
// return () => {
|
12937
|
-
// if (sexELe && dyEle) {
|
12938
|
-
// const sexValue = sexELe.getValue();
|
12939
|
-
// const dyValue = sexValue === '1' ? '男的吗' : sexValue === '2' ? '女的吗' : '难道是人妖吗';
|
12940
|
-
// dyEle.setValue(dyValue);
|
12941
|
-
// }
|
12942
|
-
// };
|
12943
|
-
// };
|
12944
|
-
}
|
12945
|
-
/**
|
12946
|
-
* 销毁动态脚本实例
|
12947
|
-
*/
|
12948
|
-
destroyScripts() {
|
12949
|
-
if (this.scriptsFunc) {
|
12950
|
-
this.scriptsFunc = null;
|
12951
|
-
}
|
12952
|
-
}
|
12953
|
-
/**
|
12954
|
-
* 触发动态脚本
|
12955
|
-
*/
|
12956
|
-
invokedScripts() {
|
12957
|
-
this.scriptsFunc?.();
|
12958
|
-
}
|
12959
|
-
}
|
12960
|
-
|
12961
12907
|
/**
|
12962
12908
|
* 当前打开的文档的上下文信息,当前文档所有的属性设置都暴露在上下文中
|
12963
12909
|
*/
|
@@ -12968,16 +12914,17 @@ class EditorContext {
|
|
12968
12914
|
cursorRect;
|
12969
12915
|
_document;
|
12970
12916
|
syncRefresh;
|
12971
|
-
dynamicFunc;
|
12972
12917
|
docChange;
|
12973
12918
|
clearPrevDocCb;
|
12974
12919
|
//绘制结束之后回调函数
|
12975
|
-
//nextViewFn!: (() => void) | null;
|
12976
12920
|
nextViewFns = [];
|
12921
|
+
//批注元素存在的标志,用于判断文档空间进行布局
|
12922
|
+
commentFlag = false;
|
12923
|
+
//留痕元素存在的标志,用于判断文档空间进行布局
|
12924
|
+
trackFlag = false;
|
12977
12925
|
constructor(selectionState, viewOptions) {
|
12978
12926
|
this.selectionState = selectionState;
|
12979
12927
|
this.viewOptions = viewOptions;
|
12980
|
-
this.dynamicFunc = new DocumentEvalFunc(this);
|
12981
12928
|
//this.imageLoader = new DocumentImagesLoader();
|
12982
12929
|
this.selectionState.onChangedEvent.subscribe(() => {
|
12983
12930
|
this.syncRefresh?.();
|
@@ -12997,7 +12944,6 @@ class EditorContext {
|
|
12997
12944
|
set document(value) {
|
12998
12945
|
this.clearPrevDocCb?.();
|
12999
12946
|
this._document = value;
|
13000
|
-
this.initScripts();
|
13001
12947
|
// this.refSub = this._document.refreshSubject.subscribe((data) => {
|
13002
12948
|
// data = data ?? 'content';
|
13003
12949
|
// this.isDirty = this.isDirty || data === 'content';
|
@@ -13025,8 +12971,6 @@ class EditorContext {
|
|
13025
12971
|
}
|
13026
12972
|
clear() {
|
13027
12973
|
this.selectionState.clear();
|
13028
|
-
//this.imageLoader.clear();
|
13029
|
-
this.dynamicFunc.destroyScripts();
|
13030
12974
|
this.isDirty = false;
|
13031
12975
|
//this.clearEleDepMaps();
|
13032
12976
|
}
|
@@ -13078,12 +13022,6 @@ class EditorContext {
|
|
13078
13022
|
this.document.viewOptions.textRowLineMode = !this.document.viewOptions.textRowLineMode;
|
13079
13023
|
this.syncRefresh();
|
13080
13024
|
}
|
13081
|
-
/**
|
13082
|
-
* 实例化动态脚本
|
13083
|
-
*/
|
13084
|
-
initScripts() {
|
13085
|
-
this.dynamicFunc.initScripts(this.document.props.scripts);
|
13086
|
-
}
|
13087
13025
|
/**
|
13088
13026
|
* 替换数据元
|
13089
13027
|
*/
|
@@ -13102,6 +13040,15 @@ class EditorContext {
|
|
13102
13040
|
}
|
13103
13041
|
return this._document.modifyFlag === ModifyFlag.None ? 'appearance' : 'content';
|
13104
13042
|
}
|
13043
|
+
adaptiveScale() {
|
13044
|
+
if (this.viewOptions.pageLayoutMode !== 'fit-page') {
|
13045
|
+
return this.viewOptions.scale;
|
13046
|
+
}
|
13047
|
+
const docWidth = this.viewOptions.contentWidth;
|
13048
|
+
const viewWidth = this.viewOptions.viewSettings.width;
|
13049
|
+
const availableWidth = viewWidth * 0.9;
|
13050
|
+
return Math.round(availableWidth * 100 / docWidth) / 100;
|
13051
|
+
}
|
13105
13052
|
}
|
13106
13053
|
/**
|
13107
13054
|
* 文档上下文
|
@@ -14267,9 +14214,7 @@ class DocumentArrange {
|
|
14267
14214
|
execute: this.execute,
|
14268
14215
|
createParaFn: () => this.createDefaultPara()
|
14269
14216
|
};
|
14270
|
-
|
14271
|
-
this.clearPaintCache(doc, data);
|
14272
|
-
//this.docCtx.viewOptions.showReviewWindow = this.docCtx.document.commentsContainerElement.markPairs.length > 0;
|
14217
|
+
this.reset(data);
|
14273
14218
|
const docRenders = this.arrangeDoc();
|
14274
14219
|
this.setMeasureCompletedModifyFlag(doc);
|
14275
14220
|
this.cacheDocRenders(docRenders);
|
@@ -14277,7 +14222,17 @@ class DocumentArrange {
|
|
14277
14222
|
return docRenders;
|
14278
14223
|
});
|
14279
14224
|
}
|
14280
|
-
|
14225
|
+
/**
|
14226
|
+
* 重置文档测量的相关信息
|
14227
|
+
* @param data
|
14228
|
+
* @private
|
14229
|
+
*/
|
14230
|
+
reset(data) {
|
14231
|
+
this.docCtx.document.clearMarkItems();
|
14232
|
+
this.docCtx.trackFlag = false;
|
14233
|
+
this.docCtx.commentFlag = false;
|
14234
|
+
this.clearPaintCache(data.doc, data);
|
14235
|
+
}
|
14281
14236
|
arrangeDoc() {
|
14282
14237
|
const doc = this.docCtx.document;
|
14283
14238
|
const docRender = doc.createRenderObject();
|
@@ -14821,8 +14776,12 @@ class DocumentArrange {
|
|
14821
14776
|
}
|
14822
14777
|
identifyComment(ele) {
|
14823
14778
|
if (ele instanceof CommentElement) {
|
14779
|
+
this.docCtx.commentFlag = true;
|
14824
14780
|
this.docCtx.document.identifyCommMark(ele);
|
14825
14781
|
}
|
14782
|
+
else if (ele instanceof TrackRunElement) {
|
14783
|
+
this.docCtx.trackFlag = true;
|
14784
|
+
}
|
14826
14785
|
}
|
14827
14786
|
cacheDoc;
|
14828
14787
|
cacheDocRenders(docs) {
|
@@ -14903,8 +14862,31 @@ class DocumentPaginator {
|
|
14903
14862
|
this.docContainer.rect.width = this.viewOptions.docPageSettings.width;
|
14904
14863
|
const newMeasure = new DocumentArrange(this.docCtx, this.renderContext, this.seo);
|
14905
14864
|
this.docPages = newMeasure.measureDoc();
|
14865
|
+
this.adjustTipLayoutWidth();
|
14906
14866
|
this.layoutPages();
|
14907
14867
|
}
|
14868
|
+
/**
|
14869
|
+
* 处理计算提示框布局宽度
|
14870
|
+
* @private
|
14871
|
+
*/
|
14872
|
+
adjustTipLayoutWidth() {
|
14873
|
+
let layoutFlag = false;
|
14874
|
+
if (this.docCtx.trackFlag && this.docCtx.viewOptions.showTrackChangesTip || this.docCtx.commentFlag) {
|
14875
|
+
layoutFlag = true;
|
14876
|
+
}
|
14877
|
+
if (layoutFlag) {
|
14878
|
+
if (this.viewOptions.reviewWindowWidth === 0) {
|
14879
|
+
this.viewOptions.reviewWindowWidth = 250;
|
14880
|
+
this.viewOptions.scale = this.docCtx.adaptiveScale();
|
14881
|
+
}
|
14882
|
+
}
|
14883
|
+
else {
|
14884
|
+
if (this.viewOptions.reviewWindowWidth > 0) {
|
14885
|
+
this.viewOptions.reviewWindowWidth = 0;
|
14886
|
+
this.viewOptions.scale = this.docCtx.adaptiveScale();
|
14887
|
+
}
|
14888
|
+
}
|
14889
|
+
}
|
14908
14890
|
/**
|
14909
14891
|
* 文档页面显示布局
|
14910
14892
|
*/
|
@@ -16912,7 +16894,7 @@ class DocumentChange {
|
|
16912
16894
|
if (res && res.isCancel) {
|
16913
16895
|
return;
|
16914
16896
|
}
|
16915
|
-
this.docComment.syncUpdateComments();
|
16897
|
+
//this.docComment.syncUpdateComments();
|
16916
16898
|
if (collapsed) {
|
16917
16899
|
this.onBackspaceElement(startControl, startOffset);
|
16918
16900
|
}
|
@@ -20332,8 +20314,6 @@ class DocEditor {
|
|
20332
20314
|
trackChangeState = true;
|
20333
20315
|
flushToSchedule() {
|
20334
20316
|
if (this.docCtx.refreshType === 'content') {
|
20335
|
-
//触发动态脚本
|
20336
|
-
this.docCtx.dynamicFunc.invokedScripts();
|
20337
20317
|
this.triggerDocChange();
|
20338
20318
|
}
|
20339
20319
|
if (this.flushTask) {
|
@@ -20692,14 +20672,7 @@ class DocEditor {
|
|
20692
20672
|
* @private
|
20693
20673
|
*/
|
20694
20674
|
adaptiveScale() {
|
20695
|
-
|
20696
|
-
return;
|
20697
|
-
}
|
20698
|
-
const docWidth = this.docCtx.viewOptions.docPageSettings.width;
|
20699
|
-
const viewWidth = this.docCtx.viewOptions.viewSettings.width;
|
20700
|
-
const availableWidth = viewWidth * 0.9;
|
20701
|
-
const scale = Math.round(availableWidth * 100 / docWidth) / 100;
|
20702
|
-
this.viewOptions.scale = scale;
|
20675
|
+
this.viewOptions.scale = this.docCtx.adaptiveScale();
|
20703
20676
|
}
|
20704
20677
|
/**
|
20705
20678
|
* 缩放视图
|
@@ -21298,12 +21271,20 @@ class DocEditor {
|
|
21298
21271
|
},
|
21299
21272
|
children: []
|
21300
21273
|
};
|
21274
|
+
const scaleFitContainer = {
|
21275
|
+
sel: 'div#scale-fit-container',
|
21276
|
+
data: {
|
21277
|
+
style: { overflow: 'hidden', height: '0px', }
|
21278
|
+
},
|
21279
|
+
children: [docContent]
|
21280
|
+
};
|
21301
21281
|
if (!this.documentPaginator?.docContainer) {
|
21302
|
-
return
|
21282
|
+
return scaleFitContainer;
|
21303
21283
|
}
|
21304
21284
|
const tipsContainer = this.createChangeTipContainer();
|
21305
21285
|
this.tipContainer = tipsContainer;
|
21306
21286
|
docContent.data.style.height = this.documentPaginator.getDocumentContainerHeight().height + 'px';
|
21287
|
+
scaleFitContainer.data.style['height'] = this.documentPaginator.getDocumentContainerHeight().height * this.viewOptions.scale + 'px';
|
21307
21288
|
const docRenders = this.documentPaginator.docContainer.getItems();
|
21308
21289
|
const svgGenerator = new DocumentSvg(this.viewOptions, this.selectionOverlays, this.renderContext);
|
21309
21290
|
const vNode = svgGenerator.getHTMLVNode(docRenders);
|
@@ -21311,12 +21292,12 @@ class DocEditor {
|
|
21311
21292
|
children.push(tipsContainer);
|
21312
21293
|
children.push(...vNode);
|
21313
21294
|
tipsContainer.children?.push(...svgGenerator.changeTips);
|
21314
|
-
this.updateTipLayoutWidth();
|
21295
|
+
//this.updateTipLayoutWidth();
|
21315
21296
|
const sub = this.afterNodePatch.subscribe(() => {
|
21316
21297
|
this.updateTipLayoutAfterPatch();
|
21317
21298
|
sub.unsubscribe();
|
21318
21299
|
});
|
21319
|
-
return
|
21300
|
+
return scaleFitContainer;
|
21320
21301
|
}
|
21321
21302
|
};
|
21322
21303
|
}
|
@@ -21425,30 +21406,21 @@ class DocEditor {
|
|
21425
21406
|
};
|
21426
21407
|
const itemsVNode = options.map(item => {
|
21427
21408
|
const ckbVNode = {
|
21428
|
-
sel: multiSelect ? '
|
21429
|
-
data: {
|
21430
|
-
attrs: {
|
21431
|
-
type: 'checkbox',
|
21432
|
-
name: 'data-list',
|
21433
|
-
}
|
21434
|
-
}
|
21409
|
+
sel: multiSelect ? 'div.editor-list-checkbox' : 'div.editor-list-radiobox',
|
21410
|
+
data: {}
|
21435
21411
|
};
|
21436
21412
|
if (item.checked) {
|
21437
|
-
ckbVNode.
|
21413
|
+
ckbVNode.sel += '.checked';
|
21414
|
+
//ckbVNode.data.attrs['checked'] = true;
|
21438
21415
|
}
|
21439
21416
|
return {
|
21440
|
-
sel: 'div', data: {
|
21417
|
+
sel: 'div', data: { on: {
|
21418
|
+
click: () => {
|
21419
|
+
onChangeHandler(item.code);
|
21420
|
+
}
|
21421
|
+
} }, children: [ckbVNode, {
|
21441
21422
|
sel: 'label',
|
21442
|
-
data: {
|
21443
|
-
attrs: {
|
21444
|
-
//for:"data-list-"+item.code,
|
21445
|
-
},
|
21446
|
-
on: {
|
21447
|
-
click: (evt) => {
|
21448
|
-
onChangeHandler(item.code);
|
21449
|
-
}
|
21450
|
-
}
|
21451
|
-
},
|
21423
|
+
data: {},
|
21452
21424
|
text: item.value
|
21453
21425
|
}]
|
21454
21426
|
};
|
@@ -21612,7 +21584,7 @@ class DocEditor {
|
|
21612
21584
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
21613
21585
|
}
|
21614
21586
|
version() {
|
21615
|
-
return "2.2.
|
21587
|
+
return "2.2.2";
|
21616
21588
|
}
|
21617
21589
|
switchPageHeaderEditor() {
|
21618
21590
|
this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
|
@@ -21762,6 +21734,54 @@ class DocumentCombine {
|
|
21762
21734
|
}
|
21763
21735
|
}
|
21764
21736
|
|
21737
|
+
class DocumentEvalFunc {
|
21738
|
+
docCtx;
|
21739
|
+
constructor(docCtx) {
|
21740
|
+
this.docCtx = docCtx;
|
21741
|
+
}
|
21742
|
+
scriptsFunc;
|
21743
|
+
/**
|
21744
|
+
* 实例化动态脚本
|
21745
|
+
*/
|
21746
|
+
initScripts(scripts) {
|
21747
|
+
this.destroyScripts();
|
21748
|
+
if (scripts) {
|
21749
|
+
try {
|
21750
|
+
const func = new Function("docCtx", scripts);
|
21751
|
+
this.scriptsFunc = func(this.docCtx);
|
21752
|
+
}
|
21753
|
+
catch (e) {
|
21754
|
+
console.error("自定义标本解析错误", e);
|
21755
|
+
}
|
21756
|
+
}
|
21757
|
+
// const func = (docCtx: DocumentContext) => {
|
21758
|
+
// const sexELe = docCtx.getControlById('NqoYI')
|
21759
|
+
// const dyEle = docCtx.getControlById('gTuBI');
|
21760
|
+
// return () => {
|
21761
|
+
// if (sexELe && dyEle) {
|
21762
|
+
// const sexValue = sexELe.getValue();
|
21763
|
+
// const dyValue = sexValue === '1' ? '男的吗' : sexValue === '2' ? '女的吗' : '难道是人妖吗';
|
21764
|
+
// dyEle.setValue(dyValue);
|
21765
|
+
// }
|
21766
|
+
// };
|
21767
|
+
// };
|
21768
|
+
}
|
21769
|
+
/**
|
21770
|
+
* 销毁动态脚本实例
|
21771
|
+
*/
|
21772
|
+
destroyScripts() {
|
21773
|
+
if (this.scriptsFunc) {
|
21774
|
+
this.scriptsFunc = null;
|
21775
|
+
}
|
21776
|
+
}
|
21777
|
+
/**
|
21778
|
+
* 触发动态脚本
|
21779
|
+
*/
|
21780
|
+
invokedScripts() {
|
21781
|
+
this.scriptsFunc?.();
|
21782
|
+
}
|
21783
|
+
}
|
21784
|
+
|
21765
21785
|
function createPrintTemplate({ width, height, orient }) {
|
21766
21786
|
return `
|
21767
21787
|
<!DOCTYPE html>
|