@hailin-zheng/editor-core 2.1.28 → 2.2.0
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 +17 -3
- package/index-cjs.d.ts +12 -12
- package/index-cjs.js +574 -1074
- package/index-cjs.js.map +1 -1
- package/index.d.ts +12 -12
- package/index.js +594 -1093
- package/index.js.map +1 -1
- package/med_editor/doc-editor.d.ts +10 -6
- package/med_editor/doc-rule.d.ts +1 -1
- package/med_editor/editor-core.d.ts +1 -1
- package/med_editor/framework/{document-eval-func.d.ts → code-interpreter/document-eval-func.d.ts} +1 -1
- package/med_editor/framework/{dynamic-execute.d.ts → code-interpreter/dynamic-execute.d.ts} +3 -3
- package/med_editor/framework/{document-arrange.d.ts → doc-layout/document-arrange.d.ts} +7 -12
- package/med_editor/framework/{paragraph-arrange.d.ts → doc-layout/paragraph-arrange.d.ts} +5 -5
- package/med_editor/framework/document-change.d.ts +1 -1
- package/med_editor/framework/document-context.d.ts +5 -12
- package/med_editor/framework/document-event.d.ts +3 -14
- package/med_editor/framework/document-input-cursor.d.ts +1 -1
- package/med_editor/framework/document-paginator.d.ts +1 -7
- package/med_editor/framework/document-svg.d.ts +12 -8
- package/med_editor/framework/element-define.d.ts +3 -9
- package/med_editor/framework/element-event-define.d.ts +2 -2
- package/med_editor/framework/element-props.d.ts +1 -1
- package/med_editor/framework/element-serialize.d.ts +1 -1
- package/med_editor/framework/{element-trace-manage.d.ts → history/element-trace-manage.d.ts} +3 -2
- package/med_editor/framework/{element-trace-tracking.d.ts → history/element-trace-tracking.d.ts} +2 -2
- package/med_editor/framework/impl/document/doc-impl.d.ts +1 -11
- package/med_editor/framework/impl/index.d.ts +0 -1
- package/med_editor/framework/impl/table/table-split-cell.d.ts +1 -1
- package/med_editor/framework/impl/table/table-util.d.ts +1 -1
- package/med_editor/framework/impl/text/track-run-impl.d.ts +2 -2
- package/med_editor/framework/{document-print-offscreen.d.ts → print/document-print-offscreen.d.ts} +8 -8
- package/med_editor/framework/{document-print.d.ts → print/document-print.d.ts} +1 -1
- package/med_editor/framework/{document-selection.d.ts → selection/document-selection.d.ts} +5 -5
- package/med_editor/framework/{range-util.d.ts → selection/range-util.d.ts} +2 -2
- package/med_editor/framework/{selection-overlays.d.ts → selection/selection-overlays.d.ts} +1 -1
- package/med_editor/framework/util/adjust-viewport-elements.d.ts +12 -0
- package/med_editor/framework/{common-util.d.ts → util/common-util.d.ts} +2 -2
- package/med_editor/framework/{document-segmenter.d.ts → util/document-segmenter.d.ts} +1 -1
- package/med_editor/framework/{element-util.d.ts → util/element-util.d.ts} +13 -12
- package/med_editor/framework/{editor-calendar-vnode.d.ts → vnode/editor-calendar-vnode.d.ts} +4 -4
- package/package.json +2 -2
- package/controls/ButtonBase.d.ts +0 -10
- package/controls/Canvas.d.ts +0 -7
- package/controls/Config.d.ts +0 -12
- package/controls/FlexBox.d.ts +0 -81
- package/controls/Input.d.ts +0 -33
- package/controls/MedTimeLine/TimeAxis.d.ts +0 -21
- package/controls/MedTimeLine/TimeSlider.d.ts +0 -19
- package/controls/Menu.d.ts +0 -31
- package/controls/Node.d.ts +0 -232
- package/controls/NodeEvent.d.ts +0 -138
- package/controls/Rect.d.ts +0 -4
- package/controls/ScrollView.d.ts +0 -57
- package/controls/StackPanel.d.ts +0 -27
- package/controls/SurfaceView.d.ts +0 -44
- package/controls/Text.d.ts +0 -46
- package/controls/TextBase.d.ts +0 -19
- package/controls/ViewPaint.d.ts +0 -64
- package/controls/Window.d.ts +0 -27
- package/controls/WrapPanel.d.ts +0 -10
- package/controls/event-subject.d.ts +0 -42
- package/med_editor/framework/impl/comments/comments-util.d.ts +0 -5
- package/med_editor/rule-control.d.ts +0 -66
- package/timeline/TimeLineControl.d.ts +0 -47
- package/timeline/TimeValueGridControl.d.ts +0 -106
- package/timeline/TimelineConfig.d.ts +0 -68
- package/timeline/TimelineScrollbar.d.ts +0 -25
- package/timeline/TimelineStatus.d.ts +0 -61
- package/timeline/TimelineTick.d.ts +0 -63
- package/timeline/example.d.ts +0 -2
- /package/med_editor/framework/{ast-parser.d.ts → code-interpreter/ast-parser.d.ts} +0 -0
- /package/med_editor/framework/{event-subject.d.ts → infrastructure/event-subject.d.ts} +0 -0
- /package/med_editor/framework/{notify.d.ts → infrastructure/notify.d.ts} +0 -0
package/index.js
CHANGED
@@ -4,7 +4,7 @@ import * as acor from 'acorn';
|
|
4
4
|
import { generate } from 'astring';
|
5
5
|
import estraverse from 'estraverse';
|
6
6
|
import JsBarcode from 'jsbarcode';
|
7
|
-
import { toVNode, init as init$1, styleModule, classModule, attributesModule, eventListenersModule, h } from 'snabbdom';
|
7
|
+
import { toVNode, init as init$1, styleModule, classModule, attributesModule, eventListenersModule, datasetModule, h } from 'snabbdom';
|
8
8
|
|
9
9
|
/**
|
10
10
|
* 元素事件
|
@@ -951,7 +951,7 @@ function getExactDiffProps(oldProps, newProps) {
|
|
951
951
|
});
|
952
952
|
return obj;
|
953
953
|
}
|
954
|
-
function generatePatch(doc) {
|
954
|
+
function generatePatch(doc, clear = true) {
|
955
955
|
const insertOpsMap = new Map();
|
956
956
|
const formatOpsMap = new Map();
|
957
957
|
const patches = [];
|
@@ -977,6 +977,9 @@ function generatePatch(doc) {
|
|
977
977
|
}
|
978
978
|
formatOpsMap.set(ele, op);
|
979
979
|
}
|
980
|
+
if ('insert' in op.ops) {
|
981
|
+
insertOpsMap.set(ele, op);
|
982
|
+
}
|
980
983
|
// if ('insert' in op.ops) {
|
981
984
|
// op.ops.insert = ele.clone(true);
|
982
985
|
// const log = getOpsLog(ele, op.ops);
|
@@ -984,17 +987,17 @@ function generatePatch(doc) {
|
|
984
987
|
// op.prevIndex = log.prevIndex;
|
985
988
|
// op.parentIndex = log.parentIndex;
|
986
989
|
// }
|
987
|
-
if ('insert' in op.ops) {
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
}
|
990
|
+
// if ('insert' in op.ops) {
|
991
|
+
// const prevEle = ElementUtil.getPrevSiblingElement(ele);
|
992
|
+
// op.ops.insert = ele.clone(true);
|
993
|
+
// op.index = ElementUtil.getControlIndex(ele, true);
|
994
|
+
// op.parentIndex = ElementUtil.getControlIndex(ele.parent, true);
|
995
|
+
// op.prevIndex = prevEle ? ElementUtil.getControlIndex(prevEle, true) : -1;
|
996
|
+
// }
|
994
997
|
patches.push({ index: op.index, parentIndex: op.parentIndex, prevIndex: op.prevIndex, ops: op.ops });
|
995
998
|
}
|
996
999
|
//清空
|
997
|
-
ops.length = 0;
|
1000
|
+
clear && (ops.length = 0);
|
998
1001
|
return patches;
|
999
1002
|
}
|
1000
1003
|
/**
|
@@ -1025,11 +1028,11 @@ function mergeDiffProps(prevFormat, currFormat) {
|
|
1025
1028
|
/**
|
1026
1029
|
* 订阅者
|
1027
1030
|
*/
|
1028
|
-
class Subscription
|
1031
|
+
class Subscription {
|
1029
1032
|
closed = false;
|
1030
1033
|
once = false;
|
1031
1034
|
}
|
1032
|
-
class EventSourceCore
|
1035
|
+
class EventSourceCore {
|
1033
1036
|
closed = false;
|
1034
1037
|
subs = [];
|
1035
1038
|
next(data) {
|
@@ -1058,7 +1061,7 @@ class EventSourceCore$1 {
|
|
1058
1061
|
/**
|
1059
1062
|
* DOM事件处理
|
1060
1063
|
*/
|
1061
|
-
class DOMEventSource extends EventSourceCore
|
1064
|
+
class DOMEventSource extends EventSourceCore {
|
1062
1065
|
dom;
|
1063
1066
|
type;
|
1064
1067
|
constructor(dom, type) {
|
@@ -1078,7 +1081,7 @@ class DOMEventSource extends EventSourceCore$1 {
|
|
1078
1081
|
return sub;
|
1079
1082
|
}
|
1080
1083
|
}
|
1081
|
-
class DOMSubscription extends Subscription
|
1084
|
+
class DOMSubscription extends Subscription {
|
1082
1085
|
listener;
|
1083
1086
|
cancel;
|
1084
1087
|
constructor(listener, cancel) {
|
@@ -1097,23 +1100,23 @@ class DOMSubscription extends Subscription$1 {
|
|
1097
1100
|
this.cancel();
|
1098
1101
|
}
|
1099
1102
|
}
|
1100
|
-
class Subject
|
1103
|
+
class Subject extends EventSourceCore {
|
1101
1104
|
subscribe(listener) {
|
1102
|
-
const sub = new SubjectSubscription
|
1105
|
+
const sub = new SubjectSubscription(listener, () => {
|
1103
1106
|
this.removeSub(sub);
|
1104
1107
|
});
|
1105
1108
|
this.addSub(sub);
|
1106
1109
|
return sub;
|
1107
1110
|
}
|
1108
1111
|
}
|
1109
|
-
class OnceSubject extends Subject
|
1112
|
+
class OnceSubject extends Subject {
|
1110
1113
|
subscribe(listener) {
|
1111
1114
|
const sub = super.subscribe(listener);
|
1112
1115
|
sub.once = true;
|
1113
1116
|
return sub;
|
1114
1117
|
}
|
1115
1118
|
}
|
1116
|
-
class SubjectSubscription
|
1119
|
+
class SubjectSubscription extends Subscription {
|
1117
1120
|
listener;
|
1118
1121
|
cancel;
|
1119
1122
|
constructor(listener, cancel) {
|
@@ -1143,7 +1146,7 @@ class EventBus {
|
|
1143
1146
|
handlers = [];
|
1144
1147
|
this.subs.set(event, handlers);
|
1145
1148
|
}
|
1146
|
-
const sub = new Subject
|
1149
|
+
const sub = new Subject();
|
1147
1150
|
sub.subscribe(handler);
|
1148
1151
|
handlers.push(sub);
|
1149
1152
|
}
|
@@ -1179,7 +1182,7 @@ class Rect {
|
|
1179
1182
|
/**
|
1180
1183
|
* 修改标志
|
1181
1184
|
*/
|
1182
|
-
var ModifyFlag
|
1185
|
+
var ModifyFlag;
|
1183
1186
|
(function (ModifyFlag) {
|
1184
1187
|
//被修改
|
1185
1188
|
ModifyFlag[ModifyFlag["Modify"] = 0] = "Modify";
|
@@ -1187,7 +1190,7 @@ var ModifyFlag$1;
|
|
1187
1190
|
ModifyFlag[ModifyFlag["None"] = 1] = "None";
|
1188
1191
|
//子项被修改
|
1189
1192
|
ModifyFlag[ModifyFlag["Track"] = 2] = "Track";
|
1190
|
-
})(ModifyFlag
|
1193
|
+
})(ModifyFlag || (ModifyFlag = {}));
|
1191
1194
|
/**
|
1192
1195
|
* 类型事件处理
|
1193
1196
|
*/
|
@@ -1215,11 +1218,11 @@ function invokeTypeHandler(ele, eventName, e, useCapture = false) {
|
|
1215
1218
|
*/
|
1216
1219
|
class Element {
|
1217
1220
|
type;
|
1218
|
-
modifyFlag = ModifyFlag
|
1221
|
+
modifyFlag = ModifyFlag.Modify;
|
1219
1222
|
isMouseenter;
|
1220
1223
|
_eventMap;
|
1221
|
-
_refreshEvent = new Subject
|
1222
|
-
_onChangeEvent = new Subject
|
1224
|
+
_refreshEvent = new Subject();
|
1225
|
+
_onChangeEvent = new Subject();
|
1223
1226
|
observers = new WeakMap();
|
1224
1227
|
paintRenders = [];
|
1225
1228
|
cacheRender;
|
@@ -1373,22 +1376,22 @@ class LeafElement extends Element {
|
|
1373
1376
|
return 1;
|
1374
1377
|
}
|
1375
1378
|
pubOnChange(selfChange) {
|
1376
|
-
if (this.modifyFlag === ModifyFlag
|
1379
|
+
if (this.modifyFlag === ModifyFlag.None) {
|
1377
1380
|
this.refreshView();
|
1378
1381
|
}
|
1379
|
-
if (this.modifyFlag === ModifyFlag
|
1382
|
+
if (this.modifyFlag === ModifyFlag.Track && selfChange === 'tracker') {
|
1380
1383
|
return;
|
1381
1384
|
}
|
1382
|
-
if (this.modifyFlag === ModifyFlag
|
1385
|
+
if (this.modifyFlag === ModifyFlag.Modify) {
|
1383
1386
|
return;
|
1384
1387
|
}
|
1385
1388
|
if (selfChange === 'tracker') {
|
1386
|
-
if (this.modifyFlag === ModifyFlag
|
1387
|
-
this.modifyFlag = ModifyFlag
|
1389
|
+
if (this.modifyFlag === ModifyFlag.None) {
|
1390
|
+
this.modifyFlag = ModifyFlag.Track;
|
1388
1391
|
}
|
1389
1392
|
}
|
1390
1393
|
else {
|
1391
|
-
this.modifyFlag = ModifyFlag
|
1394
|
+
this.modifyFlag = ModifyFlag.Modify;
|
1392
1395
|
}
|
1393
1396
|
this._onChangeEvent.next();
|
1394
1397
|
}
|
@@ -1490,15 +1493,22 @@ class BranchElement extends Element {
|
|
1490
1493
|
}, 0);
|
1491
1494
|
}
|
1492
1495
|
getSelfLength(pure) {
|
1493
|
-
|
1496
|
+
const len = 1 + this.chilren.reduce((prev, curr) => {
|
1494
1497
|
return prev + curr.getSelfLength(pure);
|
1495
1498
|
}, 0);
|
1499
|
+
//fixed:block-container类型的元素,比如表格单元格,再插入元素的时候,内部没有
|
1500
|
+
//段落,但是在文档排版时,会补充段落元素;因此在插入时,统计的index和len是有问题的
|
1501
|
+
//因此在统计的时候,手动将数量修复
|
1502
|
+
if (len === 1 && this instanceof BlockContainerElement) {
|
1503
|
+
return 2;
|
1504
|
+
}
|
1505
|
+
return len;
|
1496
1506
|
}
|
1497
1507
|
treeFilter(predicate) {
|
1498
1508
|
const items = [];
|
1499
1509
|
for (let i = 0; i < this.length; i++) {
|
1500
1510
|
const item = this.getChild(i);
|
1501
|
-
if (predicate(item
|
1511
|
+
if (predicate(item)) {
|
1502
1512
|
items.push(item);
|
1503
1513
|
}
|
1504
1514
|
if (item instanceof BranchElement) {
|
@@ -1510,7 +1520,7 @@ class BranchElement extends Element {
|
|
1510
1520
|
treeFind(predicate) {
|
1511
1521
|
for (let i = 0; i < this.length; i++) {
|
1512
1522
|
const item = this.getChild(i);
|
1513
|
-
if (predicate(item
|
1523
|
+
if (predicate(item)) {
|
1514
1524
|
return item;
|
1515
1525
|
}
|
1516
1526
|
if (item instanceof BranchElement) {
|
@@ -1523,19 +1533,19 @@ class BranchElement extends Element {
|
|
1523
1533
|
return null;
|
1524
1534
|
}
|
1525
1535
|
pubOnChange(selfChange) {
|
1526
|
-
if (this.modifyFlag === ModifyFlag
|
1536
|
+
if (this.modifyFlag === ModifyFlag.Track && selfChange === 'tracker') {
|
1527
1537
|
return;
|
1528
1538
|
}
|
1529
|
-
if (this.modifyFlag === ModifyFlag
|
1539
|
+
if (this.modifyFlag === ModifyFlag.Modify) {
|
1530
1540
|
return;
|
1531
1541
|
}
|
1532
1542
|
if (selfChange === 'tracker') {
|
1533
|
-
if (this.modifyFlag === ModifyFlag
|
1534
|
-
this.modifyFlag = ModifyFlag
|
1543
|
+
if (this.modifyFlag === ModifyFlag.None) {
|
1544
|
+
this.modifyFlag = ModifyFlag.Track;
|
1535
1545
|
}
|
1536
1546
|
}
|
1537
1547
|
else {
|
1538
|
-
this.modifyFlag = ModifyFlag
|
1548
|
+
this.modifyFlag = ModifyFlag.Modify;
|
1539
1549
|
//clearChildrenRenderCache(this);
|
1540
1550
|
for (let i = 0; i < this.length; i++) {
|
1541
1551
|
this.getChild(i).pubOnChange('to-child');
|
@@ -1757,28 +1767,12 @@ class ViewOptions {
|
|
1757
1767
|
defaultIndent = 20;
|
1758
1768
|
//内容区宽度,受审阅窗口宽度影响
|
1759
1769
|
get contentWidth() {
|
1760
|
-
|
1761
|
-
return this.docPageSettings.width + this.reviewWindowWidth;
|
1762
|
-
}
|
1763
|
-
return this.docPageSettings.width;
|
1764
|
-
}
|
1765
|
-
/**
|
1766
|
-
* 内容区域的高度
|
1767
|
-
* 同时限定canvas的最小宽度
|
1768
|
-
*/
|
1769
|
-
get ContentWidth() {
|
1770
|
-
let width = this.docPageSettings.width;
|
1771
|
-
if (this.showReviewWindow) {
|
1772
|
-
width = width + this.reviewWindowWidth;
|
1773
|
-
}
|
1774
|
-
return width;
|
1770
|
+
return this.docPageSettings.width + this.reviewWindowWidth;
|
1775
1771
|
}
|
1776
1772
|
//两个页的间距
|
1777
1773
|
docSpace = 0;
|
1778
|
-
//是否显示审阅窗口
|
1779
|
-
showReviewWindow = false;
|
1780
1774
|
//审阅窗口宽度
|
1781
|
-
reviewWindowWidth =
|
1775
|
+
reviewWindowWidth = 0;
|
1782
1776
|
//缩放
|
1783
1777
|
_scale = 1;
|
1784
1778
|
get scale() {
|
@@ -1817,7 +1811,7 @@ class ViewOptions {
|
|
1817
1811
|
editUser = { id: '', name: '' };
|
1818
1812
|
//留痕区域的生效时间段,同一用户的留痕块在此时间外需要生成新的留痕块
|
1819
1813
|
trackChangePeriod = 10;
|
1820
|
-
onChange = new Subject
|
1814
|
+
onChange = new Subject();
|
1821
1815
|
//打印模式,普通模式,续打模式
|
1822
1816
|
printMode = 'normal';
|
1823
1817
|
constructor() {
|
@@ -2886,65 +2880,6 @@ class BodyPartProps extends INotifyPropertyChanged {
|
|
2886
2880
|
}
|
2887
2881
|
}
|
2888
2882
|
|
2889
|
-
class CommsContainerElement extends BlockContainerElement {
|
2890
|
-
constructor() {
|
2891
|
-
super('comm-list');
|
2892
|
-
}
|
2893
|
-
createRenderObject(data) {
|
2894
|
-
const render = new CommsContainerRenderObject(this);
|
2895
|
-
render.rect.width = data.options.reviewWindowWidth;
|
2896
|
-
return render;
|
2897
|
-
}
|
2898
|
-
serialize(viewOptions) {
|
2899
|
-
return {
|
2900
|
-
type: this.type,
|
2901
|
-
props: {}
|
2902
|
-
};
|
2903
|
-
}
|
2904
|
-
clone(data) {
|
2905
|
-
const clone = new CommsContainerElement();
|
2906
|
-
cloneElementBase(this, clone);
|
2907
|
-
cloneChildren(this, clone, data);
|
2908
|
-
return clone;
|
2909
|
-
}
|
2910
|
-
}
|
2911
|
-
class CommsContainerRenderObject extends BlockContainerRenderObject {
|
2912
|
-
//批注内容是否已经重组,只要重新绘制的时候组合一次即可
|
2913
|
-
isMeasureComm;
|
2914
|
-
commsMarks = [];
|
2915
|
-
clone() {
|
2916
|
-
const clone = new CommsContainerRenderObject(this.element);
|
2917
|
-
clone.rect = ElementUtil.cloneRect(this.rect);
|
2918
|
-
for (let i = 0; i < this.length; i++) {
|
2919
|
-
clone.addChild(this.getChild(i).clone());
|
2920
|
-
}
|
2921
|
-
return clone;
|
2922
|
-
}
|
2923
|
-
exportSVG(event) {
|
2924
|
-
const t = super.exportSVG(event);
|
2925
|
-
t.children = [ElementUtil.createSvgEle('rect', {
|
2926
|
-
x: 0,
|
2927
|
-
y: 0,
|
2928
|
-
width: this.rect.width,
|
2929
|
-
height: this.rect.height,
|
2930
|
-
fill: '#fafafa',
|
2931
|
-
stroke: 'black',
|
2932
|
-
'paint-order': 'stroke fill markers',
|
2933
|
-
'stroke-width': 0.5,
|
2934
|
-
})];
|
2935
|
-
return t;
|
2936
|
-
}
|
2937
|
-
}
|
2938
|
-
class CommentsFactory extends ElementFactory {
|
2939
|
-
match(type) {
|
2940
|
-
return type === "comm-list";
|
2941
|
-
}
|
2942
|
-
createElement(data) {
|
2943
|
-
const commentsEle = new CommsContainerElement();
|
2944
|
-
return commentsEle;
|
2945
|
-
}
|
2946
|
-
}
|
2947
|
-
|
2948
2883
|
class DataDecorateElement extends LeafElement {
|
2949
2884
|
dataEle;
|
2950
2885
|
isPrefix;
|
@@ -3111,7 +3046,7 @@ class ParagraphElement extends BlockContentElement {
|
|
3111
3046
|
super('p');
|
3112
3047
|
this.props = new ParagraphProps();
|
3113
3048
|
this.addEvent('BackspaceKey', (evt) => {
|
3114
|
-
if (evt.selectionState.collapsed) {
|
3049
|
+
if (evt.selectionState.editable && evt.selectionState.collapsed) {
|
3115
3050
|
const pFirstLeafElement = ElementUtil.getFirstLeafElement(this);
|
3116
3051
|
if (pFirstLeafElement === evt.source && evt.sourceOffset === 0) {
|
3117
3052
|
if (this.props.numberType >= 0) {
|
@@ -3127,7 +3062,7 @@ class ParagraphElement extends BlockContentElement {
|
|
3127
3062
|
}, true);
|
3128
3063
|
this.addEvent('ElementKeyDown', evt => {
|
3129
3064
|
//当前存在缩进,点击tab
|
3130
|
-
if (evt.sourceEvent.keyCode === 9) {
|
3065
|
+
if (evt.selectionState.editable && evt.sourceEvent.keyCode === 9) {
|
3131
3066
|
const { startControl, startOffset } = evt.selectionState;
|
3132
3067
|
if (startOffset === 0 && startControl === this.getChild(0)) {
|
3133
3068
|
const defaultIndent = evt.ctx.viewOptions.defaultIndent;
|
@@ -3643,60 +3578,6 @@ class DocumentRenderObject extends BlockContainerRenderObject {
|
|
3643
3578
|
render.contentContext.drawText(viewOptions.copyRightInfo, textP, position.x + 5, position.y + 5, 100, 12);
|
3644
3579
|
}
|
3645
3580
|
}
|
3646
|
-
/**
|
3647
|
-
* 绘制文档边距线
|
3648
|
-
*/
|
3649
|
-
drawMarginLine(position, render, docWidth, docHeight) {
|
3650
|
-
const padding = this.padding;
|
3651
|
-
let paddingPos = { x: padding.left + position.x, y: padding.top + position.y };
|
3652
|
-
const drawLineWidth = 0.5;
|
3653
|
-
const lineWidth = 20;
|
3654
|
-
render.overlaysContext.strokeLines([{ x: paddingPos.x - lineWidth, y: paddingPos.y }, paddingPos, {
|
3655
|
-
x: paddingPos.x,
|
3656
|
-
y: paddingPos.y - lineWidth
|
3657
|
-
}], drawLineWidth);
|
3658
|
-
paddingPos = { x: docWidth - padding.right + position.x, y: padding.top + position.y };
|
3659
|
-
render.overlaysContext.strokeLines([{ x: paddingPos.x + lineWidth, y: paddingPos.y }, paddingPos, {
|
3660
|
-
x: paddingPos.x,
|
3661
|
-
y: paddingPos.y - lineWidth
|
3662
|
-
}], drawLineWidth);
|
3663
|
-
paddingPos = { x: padding.left + position.x, y: docHeight - this.padding.bottom + position.y };
|
3664
|
-
render.overlaysContext.strokeLines([{ x: paddingPos.x - lineWidth, y: paddingPos.y }, paddingPos, {
|
3665
|
-
x: paddingPos.x,
|
3666
|
-
y: paddingPos.y + lineWidth
|
3667
|
-
}], drawLineWidth);
|
3668
|
-
paddingPos = { x: docWidth - padding.left + position.x, y: docHeight - this.padding.bottom + position.y };
|
3669
|
-
render.overlaysContext.strokeLines([{ x: paddingPos.x + lineWidth, y: paddingPos.y }, paddingPos, {
|
3670
|
-
x: paddingPos.x,
|
3671
|
-
y: paddingPos.y + lineWidth
|
3672
|
-
}], drawLineWidth);
|
3673
|
-
}
|
3674
|
-
/**
|
3675
|
-
* 绘制水印
|
3676
|
-
* @param ctx
|
3677
|
-
* @param position
|
3678
|
-
*/
|
3679
|
-
drawWatermark(ctx, viewOptions, position) {
|
3680
|
-
if (viewOptions.watermark) {
|
3681
|
-
const watermark = viewOptions.watermark;
|
3682
|
-
ctx.contentContext.ctx.save();
|
3683
|
-
ctx.contentContext.ctx.translate(position.x, position.y);
|
3684
|
-
const { width, height } = this.rect;
|
3685
|
-
const degrees = Math.atan(height / width) * 180 / Math.PI;
|
3686
|
-
ctx.contentContext.ctx.rotate(degrees * Math.PI / 180);
|
3687
|
-
ctx.contentContext.ctx.globalAlpha = 0.3;
|
3688
|
-
const d = Math.sqrt(width * width + height * height);
|
3689
|
-
const textProps = new TextProps();
|
3690
|
-
textProps.color = "#000000";
|
3691
|
-
textProps.fontName = '楷体';
|
3692
|
-
textProps.fontSize = 60;
|
3693
|
-
const textWidth = ctx.contentContext.measureText(watermark, textProps).width;
|
3694
|
-
const x = d / 2 - textWidth / 2;
|
3695
|
-
ctx.contentContext.ctx.font = textProps.getFont();
|
3696
|
-
ctx.contentContext.ctx.fillText(watermark, x, 30);
|
3697
|
-
ctx.contentContext.ctx.restore();
|
3698
|
-
}
|
3699
|
-
}
|
3700
3581
|
clone() {
|
3701
3582
|
throw new Error('未实现');
|
3702
3583
|
}
|
@@ -3741,9 +3622,6 @@ class DocumentRenderObject extends BlockContainerRenderObject {
|
|
3741
3622
|
return pageNumNode;
|
3742
3623
|
}
|
3743
3624
|
exportSVG(event) {
|
3744
|
-
const padding = this.padding;
|
3745
|
-
event.options.docPageSettings;
|
3746
|
-
({ x: padding.left, y: padding.top });
|
3747
3625
|
const selection = {
|
3748
3626
|
sel: "g",
|
3749
3627
|
data: {
|
@@ -4485,7 +4363,7 @@ class TableRowElement extends BlockContainerElement {
|
|
4485
4363
|
beginMeasure(data) {
|
4486
4364
|
super.beginMeasure(data);
|
4487
4365
|
//在差异更新中,由于行内单元格存在合并行的情况,需要将当前行内存在合并的单元格,将其修改标志改为修改
|
4488
|
-
if (this.modifyFlag === ModifyFlag
|
4366
|
+
if (this.modifyFlag === ModifyFlag.Track) {
|
4489
4367
|
this.checkRowModifyState();
|
4490
4368
|
}
|
4491
4369
|
}
|
@@ -4505,17 +4383,17 @@ class TableRowElement extends BlockContainerElement {
|
|
4505
4383
|
const endRowIndex = TableUtil.getVMergeEndIndex(tb, currRowIndex, i);
|
4506
4384
|
const startRowIndex = TableUtil.getVMergeStartIndex(tb, currRowIndex, i);
|
4507
4385
|
for (let j = startRowIndex; j <= endRowIndex; j++) {
|
4508
|
-
setChildrenModifyFlag(ModifyFlag
|
4386
|
+
setChildrenModifyFlag(ModifyFlag.Modify, tb.getChild(j));
|
4509
4387
|
}
|
4510
4388
|
}
|
4511
4389
|
else if (cell.props.vMerge === 'restart') {
|
4512
4390
|
const endRowIndex = TableUtil.getVMergeEndIndex(tb, currRowIndex, i);
|
4513
4391
|
for (let j = currRowIndex; j <= endRowIndex; j++) {
|
4514
|
-
setChildrenModifyFlag(ModifyFlag
|
4392
|
+
setChildrenModifyFlag(ModifyFlag.Modify, tb.getChild(j));
|
4515
4393
|
}
|
4516
4394
|
break;
|
4517
4395
|
}
|
4518
|
-
cell.modifyFlag = ModifyFlag
|
4396
|
+
cell.modifyFlag = ModifyFlag.Modify;
|
4519
4397
|
}
|
4520
4398
|
}
|
4521
4399
|
createRenderObject() {
|
@@ -4620,7 +4498,7 @@ class TextGroupElement extends LeafElement {
|
|
4620
4498
|
return this.textMeasures.map(item => item.char).join('');
|
4621
4499
|
}
|
4622
4500
|
createRenderObject(data) {
|
4623
|
-
if (!this.isMeasure || this.modifyFlag !== ModifyFlag
|
4501
|
+
if (!this.isMeasure || this.modifyFlag !== ModifyFlag.None || !this.cacheRender) {
|
4624
4502
|
data.renderCtx.contentContext.measureTextUnits(this.textMeasures, this.props);
|
4625
4503
|
//data.renderCtx.contentContext.measureTextMetrics(this.props.getFont());
|
4626
4504
|
this.isMeasure = true;
|
@@ -5441,7 +5319,8 @@ class TableUtil {
|
|
5441
5319
|
currCell.props.hMerge = null;
|
5442
5320
|
}
|
5443
5321
|
if (currCell !== startCell) {
|
5444
|
-
|
5322
|
+
//单元格存在有效内容
|
5323
|
+
if (currCell.getChildLength() > 2) {
|
5445
5324
|
cellContents.push(...ElementUtil.getChildrenElements(currCell.clone(true)));
|
5446
5325
|
currCell.clearItems();
|
5447
5326
|
}
|
@@ -5506,6 +5385,9 @@ class TableUtil {
|
|
5506
5385
|
this.restoreCellMerge(cell);
|
5507
5386
|
}
|
5508
5387
|
}
|
5388
|
+
else {
|
5389
|
+
break;
|
5390
|
+
}
|
5509
5391
|
}
|
5510
5392
|
}
|
5511
5393
|
if (hMerge === 'restart') {
|
@@ -5517,6 +5399,9 @@ class TableUtil {
|
|
5517
5399
|
this.restoreCellMerge(cell);
|
5518
5400
|
}
|
5519
5401
|
}
|
5402
|
+
else {
|
5403
|
+
break;
|
5404
|
+
}
|
5520
5405
|
}
|
5521
5406
|
}
|
5522
5407
|
cell.props.hMerge = null;
|
@@ -6496,94 +6381,6 @@ class CommentContentFactory extends ElementFactory {
|
|
6496
6381
|
}
|
6497
6382
|
}
|
6498
6383
|
|
6499
|
-
class CommentsUtil {
|
6500
|
-
static createCommentsImage(commWindow) {
|
6501
|
-
const commContainer = commWindow.element.cacheRender;
|
6502
|
-
commWindow.clear();
|
6503
|
-
for (let i = 0; i < commContainer.length; i++) {
|
6504
|
-
const commRender = commContainer.getChild(i);
|
6505
|
-
const commEle = commRender.element;
|
6506
|
-
const mapComm = commWindow.commsMarks.find(item => item.element.props.id === commEle.props.id);
|
6507
|
-
if (mapComm) {
|
6508
|
-
const commContentRender = commRender.clone();
|
6509
|
-
commContentRender.rect.x = 0;
|
6510
|
-
commContentRender.rect.y = 0;
|
6511
|
-
commWindow.addChild(commContentRender);
|
6512
|
-
}
|
6513
|
-
}
|
6514
|
-
}
|
6515
|
-
static arrangeComments(commWindow) {
|
6516
|
-
if (commWindow.isMeasureComm) {
|
6517
|
-
return;
|
6518
|
-
}
|
6519
|
-
const commContainer = commWindow.element.cacheRender;
|
6520
|
-
const commMap = [];
|
6521
|
-
const docRender = ElementUtil.getParentRender(commWindow, DocumentRenderObject);
|
6522
|
-
const docRenderPos = ElementUtil.getRenderAbsolutePaintPos(docRender);
|
6523
|
-
for (let i = 0; i < commContainer.length; i++) {
|
6524
|
-
const commRender = commContainer.getChild(i);
|
6525
|
-
const commEle = commRender.element;
|
6526
|
-
const mapComm = commWindow.commsMarks.find(item => item.element.props.id === commEle.props.id);
|
6527
|
-
if (mapComm) {
|
6528
|
-
const commRenderPos = ElementUtil.getRenderAbsolutePaintPos(mapComm);
|
6529
|
-
const commPos = { x: commRenderPos.x - docRenderPos.x, y: commRenderPos.y - docRenderPos.y };
|
6530
|
-
const commMarkLinePos = ElementUtil.getParaLinePos(mapComm, commPos);
|
6531
|
-
commPos.y = commMarkLinePos.y + 2;
|
6532
|
-
const commContentRender = commWindow.getItems().find(item => item.element === commRender.element);
|
6533
|
-
//const commContentRender = commRender.clone() as CommContentBaseRenderObject<any>;
|
6534
|
-
commContentRender.rect.x = 0;
|
6535
|
-
commContentRender.rect.y = commPos.y;
|
6536
|
-
//commWindow.addChild(commContentRender);
|
6537
|
-
commMap.push({
|
6538
|
-
commMarkRender: mapComm,
|
6539
|
-
commMarkPos: commPos,
|
6540
|
-
commContentRender: commContentRender
|
6541
|
-
});
|
6542
|
-
}
|
6543
|
-
}
|
6544
|
-
let sumCommentHeight = 0;
|
6545
|
-
for (let i = 0; i < commMap.length; i++) {
|
6546
|
-
const map = commMap[i];
|
6547
|
-
const prevRender = commMap[i - 1]?.commContentRender;
|
6548
|
-
const { commContentRender } = map;
|
6549
|
-
sumCommentHeight += commContentRender.rect.height + 5;
|
6550
|
-
if (prevRender) {
|
6551
|
-
const { y: prevY, height: prevHeight } = prevRender.rect;
|
6552
|
-
if (commContentRender.rect.y < prevY + prevHeight) {
|
6553
|
-
commContentRender.rect.y = prevY + prevHeight + 5;
|
6554
|
-
}
|
6555
|
-
}
|
6556
|
-
commContentRender.commMarkRender = { render: map.commMarkRender, pos: map.commMarkPos };
|
6557
|
-
}
|
6558
|
-
if (!commMap.length) {
|
6559
|
-
return;
|
6560
|
-
}
|
6561
|
-
const lastCommentMap = commMap[commMap.length - 1];
|
6562
|
-
const { commContentRender: lastCommContentRender } = lastCommentMap;
|
6563
|
-
const { rect: lastRect } = lastCommContentRender;
|
6564
|
-
//批注内容超出文档,需要重新排序
|
6565
|
-
if (lastRect.y + lastRect.height > docRender.rect.height) {
|
6566
|
-
//总内容小于容器高度,则进行倒排
|
6567
|
-
//否则进行正排
|
6568
|
-
if (sumCommentHeight < docRender.rect.height) {
|
6569
|
-
lastRect.y = docRender.rect.height - lastRect.height;
|
6570
|
-
for (let i = commMap.length - 1; i >= 0; i--) {
|
6571
|
-
const map = commMap[i];
|
6572
|
-
const prevRender = commMap[i + 1]?.commContentRender;
|
6573
|
-
const { commContentRender } = map;
|
6574
|
-
if (prevRender) {
|
6575
|
-
const { y: prevY } = prevRender.rect;
|
6576
|
-
if (commContentRender.rect.y + commContentRender.rect.height > prevY) {
|
6577
|
-
commContentRender.rect.y = prevY - commContentRender.rect.height - 5;
|
6578
|
-
}
|
6579
|
-
}
|
6580
|
-
commContentRender.commMarkRender = { render: map.commMarkRender, pos: map.commMarkPos };
|
6581
|
-
}
|
6582
|
-
}
|
6583
|
-
}
|
6584
|
-
}
|
6585
|
-
}
|
6586
|
-
|
6587
6384
|
let activeEditorContext = null;
|
6588
6385
|
function setActiveEditorContext(ctx) {
|
6589
6386
|
activeEditorContext = ctx;
|
@@ -6796,7 +6593,7 @@ class SelectionState {
|
|
6796
6593
|
set endControl(value) {
|
6797
6594
|
this._endControl = value;
|
6798
6595
|
}
|
6799
|
-
onChangedEvent = new Subject
|
6596
|
+
onChangedEvent = new Subject();
|
6800
6597
|
startControlIndex;
|
6801
6598
|
startOffset;
|
6802
6599
|
endControlIndex;
|
@@ -7003,7 +6800,7 @@ class CommentElement extends LeafElement {
|
|
7003
6800
|
color;
|
7004
6801
|
constructor() {
|
7005
6802
|
super('comm');
|
7006
|
-
this.isDecorate = true;
|
6803
|
+
//this.isDecorate = true;
|
7007
6804
|
this.disableClick = true;
|
7008
6805
|
this.props = new CommProps();
|
7009
6806
|
this.color = CommonUtil.randomRgbColor(0.5);
|
@@ -7059,10 +6856,14 @@ class CommentRenderObject extends LeafRenderObject {
|
|
7059
6856
|
if (this.element.paintRenders.indexOf(this) !== 0) {
|
7060
6857
|
return;
|
7061
6858
|
}
|
6859
|
+
const { x, y } = event.globalPos;
|
6860
|
+
const docRender = ElementUtil.getParentRender(this, DocumentRenderObject);
|
7062
6861
|
const appCtx = getActiveEditorContext();
|
7063
6862
|
const opType = '批注:';
|
7064
6863
|
const content = this.element.props.text;
|
7065
|
-
|
6864
|
+
let left = 5;
|
6865
|
+
//显示在文档的右测
|
6866
|
+
left += docRender.rect.x + docRender.rect.width + 20;
|
7066
6867
|
let sel = 'div.tg-container';
|
7067
6868
|
const node = {
|
7068
6869
|
sel,
|
@@ -7070,7 +6871,10 @@ class CommentRenderObject extends LeafRenderObject {
|
|
7070
6871
|
data: {
|
7071
6872
|
style: {
|
7072
6873
|
left: `${left}px`,
|
7073
|
-
top: `${
|
6874
|
+
top: `${y}px`
|
6875
|
+
},
|
6876
|
+
dataset: {
|
6877
|
+
key: this.element.key
|
7074
6878
|
},
|
7075
6879
|
on: {
|
7076
6880
|
click: (e) => {
|
@@ -7113,6 +6917,43 @@ class CommentRenderObject extends LeafRenderObject {
|
|
7113
6917
|
}]
|
7114
6918
|
};
|
7115
6919
|
event.addChangeTips(node);
|
6920
|
+
const triangleTipX = x + this.rect.width / 2;
|
6921
|
+
const tipLineAWidth = docRender.rect.x + docRender.rect.width - triangleTipX;
|
6922
|
+
const tipLineA = {
|
6923
|
+
sel: 'div.doc-triangle-line',
|
6924
|
+
data: {
|
6925
|
+
style: {
|
6926
|
+
left: `${triangleTipX}px`,
|
6927
|
+
top: `${y + this.rect.height}px`,
|
6928
|
+
width: tipLineAWidth + 'px'
|
6929
|
+
}
|
6930
|
+
}
|
6931
|
+
};
|
6932
|
+
const tipLineB = {
|
6933
|
+
sel: 'div.doc-triangle-line',
|
6934
|
+
data: {
|
6935
|
+
style: {
|
6936
|
+
left: `${triangleTipX + tipLineAWidth}px`,
|
6937
|
+
top: `${y + this.rect.height}px`,
|
6938
|
+
width: 20 + 'px'
|
6939
|
+
},
|
6940
|
+
dataset: {
|
6941
|
+
key: this.element.key
|
6942
|
+
}
|
6943
|
+
}
|
6944
|
+
};
|
6945
|
+
const triangleTip = {
|
6946
|
+
sel: `div.doc-triangle`,
|
6947
|
+
data: {
|
6948
|
+
style: {
|
6949
|
+
left: `${triangleTipX}px`,
|
6950
|
+
top: `${y + this.rect.height * 2 / 3}px`
|
6951
|
+
}
|
6952
|
+
}
|
6953
|
+
};
|
6954
|
+
event.addChangeTips(triangleTip);
|
6955
|
+
event.addChangeTips(tipLineA);
|
6956
|
+
event.addChangeTips(tipLineB);
|
7116
6957
|
// <div class="container">
|
7117
6958
|
// <div class="header">
|
7118
6959
|
// <span class="header-user">张三</span>
|
@@ -7146,10 +6987,72 @@ class CommentFactory extends ElementFactory {
|
|
7146
6987
|
ele.props.id = props.id;
|
7147
6988
|
ele.props.markType = props.markType;
|
7148
6989
|
ele.props.text = props.text;
|
6990
|
+
ele.props.userId = props.userId;
|
6991
|
+
ele.props.userName = props.userName;
|
6992
|
+
ele.props.date = props.date;
|
7149
6993
|
return ele;
|
7150
6994
|
}
|
7151
6995
|
}
|
7152
6996
|
|
6997
|
+
class CommsContainerElement extends BlockContainerElement {
|
6998
|
+
constructor() {
|
6999
|
+
super('comm-list');
|
7000
|
+
}
|
7001
|
+
createRenderObject(data) {
|
7002
|
+
const render = new CommsContainerRenderObject(this);
|
7003
|
+
render.rect.width = data.options.reviewWindowWidth;
|
7004
|
+
return render;
|
7005
|
+
}
|
7006
|
+
serialize(viewOptions) {
|
7007
|
+
return {
|
7008
|
+
type: this.type,
|
7009
|
+
props: {}
|
7010
|
+
};
|
7011
|
+
}
|
7012
|
+
clone(data) {
|
7013
|
+
const clone = new CommsContainerElement();
|
7014
|
+
cloneElementBase(this, clone);
|
7015
|
+
cloneChildren(this, clone, data);
|
7016
|
+
return clone;
|
7017
|
+
}
|
7018
|
+
}
|
7019
|
+
class CommsContainerRenderObject extends BlockContainerRenderObject {
|
7020
|
+
//批注内容是否已经重组,只要重新绘制的时候组合一次即可
|
7021
|
+
isMeasureComm;
|
7022
|
+
commsMarks = [];
|
7023
|
+
clone() {
|
7024
|
+
const clone = new CommsContainerRenderObject(this.element);
|
7025
|
+
clone.rect = ElementUtil.cloneRect(this.rect);
|
7026
|
+
for (let i = 0; i < this.length; i++) {
|
7027
|
+
clone.addChild(this.getChild(i).clone());
|
7028
|
+
}
|
7029
|
+
return clone;
|
7030
|
+
}
|
7031
|
+
exportSVG(event) {
|
7032
|
+
const t = super.exportSVG(event);
|
7033
|
+
t.children = [ElementUtil.createSvgEle('rect', {
|
7034
|
+
x: 0,
|
7035
|
+
y: 0,
|
7036
|
+
width: this.rect.width,
|
7037
|
+
height: this.rect.height,
|
7038
|
+
fill: '#fafafa',
|
7039
|
+
stroke: 'black',
|
7040
|
+
'paint-order': 'stroke fill markers',
|
7041
|
+
'stroke-width': 0.5,
|
7042
|
+
})];
|
7043
|
+
return t;
|
7044
|
+
}
|
7045
|
+
}
|
7046
|
+
class CommentsFactory extends ElementFactory {
|
7047
|
+
match(type) {
|
7048
|
+
return type === "comm-list";
|
7049
|
+
}
|
7050
|
+
createElement(data) {
|
7051
|
+
const commentsEle = new CommsContainerElement();
|
7052
|
+
return commentsEle;
|
7053
|
+
}
|
7054
|
+
}
|
7055
|
+
|
7153
7056
|
/**
|
7154
7057
|
* 数据元验证提示
|
7155
7058
|
*/
|
@@ -10597,7 +10500,7 @@ class TrackRunRenderObject extends InlineGroupRenderObject {
|
|
10597
10500
|
if (fillColor) {
|
10598
10501
|
t.data.attrs['fill'] = fillColor;
|
10599
10502
|
}
|
10600
|
-
this.
|
10503
|
+
this.createModifyTips(event);
|
10601
10504
|
const { x, y } = event.relativePagePos;
|
10602
10505
|
const color = this.element.type === 'ins-run' ? 'green' : 'red';
|
10603
10506
|
if (this.element.type === 'del-run') {
|
@@ -10605,35 +10508,39 @@ class TrackRunRenderObject extends InlineGroupRenderObject {
|
|
10605
10508
|
event.highlights.push(ElementUtil.getStrokeSvgPath(`M${x} ${delY} H${x + this.rect.width}`, 'red', 1));
|
10606
10509
|
event.highlights.push(ElementUtil.getStrokeSvgPath(`M${x} ${delY + 4} H${x + this.rect.width}`, 'red', 1));
|
10607
10510
|
}
|
10608
|
-
if (this.element.gotFocus
|
10511
|
+
if (this.element.gotFocus) {
|
10609
10512
|
//起始位置
|
10610
10513
|
if (this.element.paintRenders.indexOf(this) === 0) {
|
10611
10514
|
const pathPoints = [];
|
10612
10515
|
pathPoints.push({ x: x, y: y + this.rect.height / 3 });
|
10613
10516
|
pathPoints.push({ x, y });
|
10614
10517
|
pathPoints.push({ x: x + this.rect.width, y: y });
|
10615
|
-
event.highlights.push(ElementUtil.getStrokeSvgPath(pathPoints, color,
|
10518
|
+
event.highlights.push(ElementUtil.getStrokeSvgPath(pathPoints, color, 1));
|
10616
10519
|
}
|
10617
10520
|
if (this.element.paintRenders.indexOf(this) === this.element.paintRenders.length - 1) {
|
10618
10521
|
const pathPoints = [];
|
10619
10522
|
pathPoints.push({ x: x, y: y + this.rect.height });
|
10620
10523
|
pathPoints.push({ x: x + this.rect.width, y: y + this.rect.height });
|
10621
10524
|
pathPoints.push({ x: x + this.rect.width, y: y + this.rect.height * 2 / 3 });
|
10622
|
-
event.highlights.push(ElementUtil.getStrokeSvgPath(pathPoints, color,
|
10525
|
+
event.highlights.push(ElementUtil.getStrokeSvgPath(pathPoints, color, 1));
|
10623
10526
|
}
|
10624
10527
|
}
|
10625
10528
|
return t;
|
10626
10529
|
}
|
10627
|
-
|
10530
|
+
createModifyTips(event) {
|
10628
10531
|
if (this.element.paintRenders.indexOf(this) !== 0) {
|
10629
10532
|
return;
|
10630
10533
|
}
|
10631
10534
|
if (!event.options.showTrackChangesTip) {
|
10632
10535
|
return;
|
10633
10536
|
}
|
10537
|
+
const { x, y } = event.globalPos;
|
10538
|
+
const docRender = ElementUtil.getParentRender(this, DocumentRenderObject);
|
10634
10539
|
const opType = this.element.type === 'ins-run' ? '插入:' : '删除:';
|
10635
10540
|
const content = ElementSerialize.serializeString(this.element, { all: true });
|
10636
|
-
|
10541
|
+
let left = this.element.gotFocus ? -10 : 5;
|
10542
|
+
//显示在文档的右测
|
10543
|
+
left += docRender.rect.x + docRender.rect.width + 20;
|
10637
10544
|
let sel = 'div.tg-container';
|
10638
10545
|
if (this.element.gotFocus) {
|
10639
10546
|
sel += '.tg-container--selected';
|
@@ -10644,7 +10551,10 @@ class TrackRunRenderObject extends InlineGroupRenderObject {
|
|
10644
10551
|
data: {
|
10645
10552
|
style: {
|
10646
10553
|
left: `${left}px`,
|
10647
|
-
top: `${
|
10554
|
+
top: `${y}px`
|
10555
|
+
},
|
10556
|
+
dataset: {
|
10557
|
+
key: this.element.key
|
10648
10558
|
}
|
10649
10559
|
},
|
10650
10560
|
children: [{
|
@@ -10666,6 +10576,43 @@ class TrackRunRenderObject extends InlineGroupRenderObject {
|
|
10666
10576
|
}]
|
10667
10577
|
};
|
10668
10578
|
event.addChangeTips(node);
|
10579
|
+
const triangleTipX = x + this.rect.width / 2;
|
10580
|
+
const tipLineAWidth = docRender.rect.x + docRender.rect.width - triangleTipX;
|
10581
|
+
const tipLineA = {
|
10582
|
+
sel: 'div.doc-triangle-line',
|
10583
|
+
data: {
|
10584
|
+
style: {
|
10585
|
+
left: `${triangleTipX}px`,
|
10586
|
+
top: `${y + this.rect.height}px`,
|
10587
|
+
width: tipLineAWidth + 'px'
|
10588
|
+
}
|
10589
|
+
}
|
10590
|
+
};
|
10591
|
+
const tipLineB = {
|
10592
|
+
sel: 'div.doc-triangle-line',
|
10593
|
+
data: {
|
10594
|
+
style: {
|
10595
|
+
left: `${triangleTipX + tipLineAWidth}px`,
|
10596
|
+
top: `${y + this.rect.height}px`,
|
10597
|
+
width: 20 + 'px'
|
10598
|
+
},
|
10599
|
+
dataset: {
|
10600
|
+
key: this.element.key
|
10601
|
+
}
|
10602
|
+
}
|
10603
|
+
};
|
10604
|
+
const triangleTip = {
|
10605
|
+
sel: `div.doc-triangle`,
|
10606
|
+
data: {
|
10607
|
+
style: {
|
10608
|
+
left: `${triangleTipX}px`,
|
10609
|
+
top: `${y + this.rect.height * 2 / 3}px`
|
10610
|
+
}
|
10611
|
+
}
|
10612
|
+
};
|
10613
|
+
event.addChangeTips(triangleTip);
|
10614
|
+
event.addChangeTips(tipLineA);
|
10615
|
+
event.addChangeTips(tipLineB);
|
10669
10616
|
}
|
10670
10617
|
clone() {
|
10671
10618
|
const cloneRender = new TrackRunRenderObject(this.element);
|
@@ -12046,9 +11993,6 @@ class ElementUtil {
|
|
12046
11993
|
if (element instanceof DocumentHeaderElement) {
|
12047
11994
|
return { type: 'header', target: element };
|
12048
11995
|
}
|
12049
|
-
if (element instanceof CommsContainerElement) {
|
12050
|
-
return { type: 'review', target: element };
|
12051
|
-
}
|
12052
11996
|
return this.getElementRegionTarget(element.parent);
|
12053
11997
|
}
|
12054
11998
|
/**
|
@@ -12417,6 +12361,22 @@ class ElementUtil {
|
|
12417
12361
|
delete ele.attribute[attr];
|
12418
12362
|
}
|
12419
12363
|
}
|
12364
|
+
static getMatchItems(item, predicate) {
|
12365
|
+
const items = [];
|
12366
|
+
if (predicate(item)) {
|
12367
|
+
items.push(item);
|
12368
|
+
}
|
12369
|
+
if (item instanceof BranchElement) {
|
12370
|
+
for (let i = 0; i < item.length; i++) {
|
12371
|
+
const child = item.getChild(i);
|
12372
|
+
const matchItems = this.getMatchItems(child, predicate);
|
12373
|
+
if (matchItems) {
|
12374
|
+
items.push(...matchItems);
|
12375
|
+
}
|
12376
|
+
}
|
12377
|
+
}
|
12378
|
+
return items;
|
12379
|
+
}
|
12420
12380
|
}
|
12421
12381
|
|
12422
12382
|
var TextUnitsHolder;
|
@@ -12913,7 +12873,7 @@ class EditorContext {
|
|
12913
12873
|
docChange;
|
12914
12874
|
clearPrevDocCb;
|
12915
12875
|
//绘制结束之后回调函数
|
12916
|
-
|
12876
|
+
nextViewFn;
|
12917
12877
|
constructor(selectionState, viewOptions) {
|
12918
12878
|
this.selectionState = selectionState;
|
12919
12879
|
this.viewOptions = viewOptions;
|
@@ -12923,8 +12883,8 @@ class EditorContext {
|
|
12923
12883
|
this.syncRefresh?.();
|
12924
12884
|
});
|
12925
12885
|
}
|
12926
|
-
|
12927
|
-
this.
|
12886
|
+
onNextView(cb) {
|
12887
|
+
this.nextViewFn = cb;
|
12928
12888
|
}
|
12929
12889
|
get document() {
|
12930
12890
|
return this._document;
|
@@ -12952,6 +12912,7 @@ class EditorContext {
|
|
12952
12912
|
this.selectionState?.renderContainer?.destroy();
|
12953
12913
|
this.clear();
|
12954
12914
|
this._document.destroy();
|
12915
|
+
clearTraces(this._document);
|
12955
12916
|
}
|
12956
12917
|
this.clearPrevDocCb = null;
|
12957
12918
|
this.selectionState.startHitInfo = null;
|
@@ -13034,7 +12995,7 @@ class EditorContext {
|
|
13034
12995
|
if (!this._document) {
|
13035
12996
|
return null;
|
13036
12997
|
}
|
13037
|
-
return this._document.modifyFlag === ModifyFlag
|
12998
|
+
return this._document.modifyFlag === ModifyFlag.None ? 'appearance' : 'content';
|
13038
12999
|
}
|
13039
13000
|
}
|
13040
13001
|
/**
|
@@ -14336,7 +14297,7 @@ class DocumentArrange {
|
|
14336
14297
|
};
|
14337
14298
|
}
|
14338
14299
|
measureControl(element, maxWidth) {
|
14339
|
-
if (element.modifyFlag === ModifyFlag
|
14300
|
+
if (element.modifyFlag === ModifyFlag.None && element.cacheRender) {
|
14340
14301
|
return element.cacheRender;
|
14341
14302
|
}
|
14342
14303
|
if (element instanceof BlockContentElement) {
|
@@ -14738,7 +14699,7 @@ class DocumentArrange {
|
|
14738
14699
|
this.setMeasureCompletedModifyFlag(ele.getChild(i));
|
14739
14700
|
}
|
14740
14701
|
}
|
14741
|
-
ele.modifyFlag = ModifyFlag
|
14702
|
+
ele.modifyFlag = ModifyFlag.None;
|
14742
14703
|
if (!ele.loaded) {
|
14743
14704
|
ele.loaded = true;
|
14744
14705
|
}
|
@@ -14788,9 +14749,6 @@ class DocumentArrange {
|
|
14788
14749
|
}
|
14789
14750
|
for (let i = 0; i < renderTree.length; i++) {
|
14790
14751
|
const currRender = renderTree.getChild(i);
|
14791
|
-
if (currRender.element) {
|
14792
|
-
this.cacheCommsRender(currRender);
|
14793
|
-
}
|
14794
14752
|
if (currRender instanceof BranchRenderObject) {
|
14795
14753
|
this.cacheRenders(currRender);
|
14796
14754
|
}
|
@@ -14799,26 +14757,6 @@ class DocumentArrange {
|
|
14799
14757
|
}
|
14800
14758
|
}
|
14801
14759
|
}
|
14802
|
-
/**
|
14803
|
-
* 缓存批注标志
|
14804
|
-
* @private
|
14805
|
-
*/
|
14806
|
-
cacheCommsRender(render) {
|
14807
|
-
if (render.element && render.element.type === 'comm') {
|
14808
|
-
const commElement = render.element;
|
14809
|
-
if (commElement.props.markType === 'start') {
|
14810
|
-
const currDocRender = this.cacheDoc;
|
14811
|
-
const docCommContainer = currDocRender.getItems().find(item => item instanceof CommsContainerRenderObject);
|
14812
|
-
if (docCommContainer) {
|
14813
|
-
docCommContainer.commsMarks.push(render);
|
14814
|
-
}
|
14815
|
-
}
|
14816
|
-
}
|
14817
|
-
if (render.element && render.element.type === 'comm-list') {
|
14818
|
-
const commContainer = render;
|
14819
|
-
CommentsUtil.createCommentsImage(commContainer);
|
14820
|
-
}
|
14821
|
-
}
|
14822
14760
|
endMeasures(ele) {
|
14823
14761
|
ele.endMeasure();
|
14824
14762
|
if (ele instanceof BranchElement) {
|
@@ -14859,14 +14797,11 @@ class DocumentPaginator {
|
|
14859
14797
|
this.docCtx.selectionState.renderContainer = this.docContainer;
|
14860
14798
|
this.docContainer.rect.width = this.viewOptions.docPageSettings.width;
|
14861
14799
|
const newMeasure = new DocumentArrange(this.docCtx, this.renderContext, this.seo);
|
14862
|
-
|
14863
|
-
this.setCommRangeMark();
|
14864
|
-
this.docPages = docPages;
|
14800
|
+
this.docPages = newMeasure.measureDoc();
|
14865
14801
|
this.layoutPages();
|
14866
14802
|
}
|
14867
14803
|
/**
|
14868
14804
|
* 文档页面显示布局
|
14869
|
-
* @param pages
|
14870
14805
|
*/
|
14871
14806
|
layoutPages() {
|
14872
14807
|
if (!this.docContainer || !this.docPages) {
|
@@ -14949,39 +14884,6 @@ class DocumentPaginator {
|
|
14949
14884
|
getDocContainer() {
|
14950
14885
|
return this.docContainer;
|
14951
14886
|
}
|
14952
|
-
/***
|
14953
|
-
* 设置审阅区间样式痕迹
|
14954
|
-
*/
|
14955
|
-
setCommRangeMark() {
|
14956
|
-
if (!this.viewOptions.showReviewWindow) {
|
14957
|
-
return;
|
14958
|
-
}
|
14959
|
-
// const cce = this.docCtx.document.commentsContainerElement;
|
14960
|
-
// const set = new Map<Element, SelectionContentRange>();
|
14961
|
-
// const commentRangeStatus: Array<CommentRangeStatus> = [];
|
14962
|
-
// for (let i = 0; i < cce.length; i++) {
|
14963
|
-
// const commContent = cce.getChild(i) as CommContentElement;
|
14964
|
-
// const commMarkPair = cce.markPairs.find(item => item.id === commContent.props.id);
|
14965
|
-
// if (commMarkPair) {
|
14966
|
-
// if (commMarkPair.start) {
|
14967
|
-
// commContent.startMark = commMarkPair.start;
|
14968
|
-
// }
|
14969
|
-
// if (commMarkPair.end) {
|
14970
|
-
// commContent.endMark = commMarkPair.end;
|
14971
|
-
// }
|
14972
|
-
// }
|
14973
|
-
// const {startMark, endMark, props: {id}, focus} = commContent;
|
14974
|
-
// const ancestorCommonControl = DocumentSelection.getAncestorCommonControl(startMark, endMark);
|
14975
|
-
// const commonRange = RangeUtil.getSectionRange(startMark, 0, endMark, 1, ancestorCommonControl);
|
14976
|
-
// SelectionOverlays.addToCommentSets(commonRange, set);
|
14977
|
-
// commentRangeStatus.push({
|
14978
|
-
// commContent,
|
14979
|
-
// range: commonRange
|
14980
|
-
// })
|
14981
|
-
// }
|
14982
|
-
// (<CommsContainerRenderObject>cce.cacheRender).selectedSet = set;
|
14983
|
-
// (<CommsContainerRenderObject>cce.cacheRender).commentRangeStatus = commentRangeStatus;
|
14984
|
-
}
|
14985
14887
|
}
|
14986
14888
|
|
14987
14889
|
class ElementReader {
|
@@ -15117,491 +15019,6 @@ class ElementReader {
|
|
15117
15019
|
}
|
15118
15020
|
}
|
15119
15021
|
|
15120
|
-
class Subscription {
|
15121
|
-
closed = false;
|
15122
|
-
once = false;
|
15123
|
-
}
|
15124
|
-
class EventSourceCore {
|
15125
|
-
closed = false;
|
15126
|
-
subs = [];
|
15127
|
-
next(data) {
|
15128
|
-
const subs = [...this.subs];
|
15129
|
-
subs.forEach((sub) => {
|
15130
|
-
sub.invoke(data);
|
15131
|
-
if (sub.once) {
|
15132
|
-
sub.unsubscribe();
|
15133
|
-
}
|
15134
|
-
});
|
15135
|
-
}
|
15136
|
-
addSub(sub) {
|
15137
|
-
this.subs.push(sub);
|
15138
|
-
}
|
15139
|
-
removeSub(sub) {
|
15140
|
-
const index = this.subs.indexOf(sub);
|
15141
|
-
if (index >= 0) {
|
15142
|
-
this.subs.splice(index, 1);
|
15143
|
-
}
|
15144
|
-
}
|
15145
|
-
unsubscribe() {
|
15146
|
-
this.subs.length = 0;
|
15147
|
-
this.closed = true;
|
15148
|
-
}
|
15149
|
-
}
|
15150
|
-
class Subject extends EventSourceCore {
|
15151
|
-
subscribe(listener) {
|
15152
|
-
const sub = new SubjectSubscription(listener, () => {
|
15153
|
-
this.removeSub(sub);
|
15154
|
-
});
|
15155
|
-
this.addSub(sub);
|
15156
|
-
return sub;
|
15157
|
-
}
|
15158
|
-
onceSubscribe(listener) {
|
15159
|
-
const sub = this.subscribe(listener);
|
15160
|
-
sub.once = true;
|
15161
|
-
return sub;
|
15162
|
-
}
|
15163
|
-
}
|
15164
|
-
class SubjectSubscription extends Subscription {
|
15165
|
-
listener;
|
15166
|
-
cancel;
|
15167
|
-
constructor(listener, cancel) {
|
15168
|
-
super();
|
15169
|
-
this.listener = listener;
|
15170
|
-
this.cancel = cancel;
|
15171
|
-
}
|
15172
|
-
invoke(data) {
|
15173
|
-
if (this.closed) {
|
15174
|
-
return;
|
15175
|
-
}
|
15176
|
-
this.listener(data);
|
15177
|
-
}
|
15178
|
-
unsubscribe() {
|
15179
|
-
this.closed = true;
|
15180
|
-
this.cancel();
|
15181
|
-
}
|
15182
|
-
}
|
15183
|
-
|
15184
|
-
var ModifyFlag;
|
15185
|
-
(function (ModifyFlag) {
|
15186
|
-
ModifyFlag[ModifyFlag["None"] = 0] = "None";
|
15187
|
-
ModifyFlag[ModifyFlag["Modify"] = 1] = "Modify";
|
15188
|
-
ModifyFlag[ModifyFlag["Track"] = 2] = "Track";
|
15189
|
-
})(ModifyFlag || (ModifyFlag = {}));
|
15190
|
-
class NodeCore {
|
15191
|
-
enableClip = true;
|
15192
|
-
pointEvent = true;
|
15193
|
-
allowHitTest = false;
|
15194
|
-
hitTest(hitPos, currPos) {
|
15195
|
-
return false;
|
15196
|
-
}
|
15197
|
-
get enable() {
|
15198
|
-
return this._enable;
|
15199
|
-
}
|
15200
|
-
set enable(value) {
|
15201
|
-
this.propertyChanged('enable', this._enable, value);
|
15202
|
-
}
|
15203
|
-
_enable = true;
|
15204
|
-
enableFocus = false;
|
15205
|
-
isFocused = false;
|
15206
|
-
get cursor() {
|
15207
|
-
return this._cursor;
|
15208
|
-
}
|
15209
|
-
set cursor(value) {
|
15210
|
-
this.propertyChanged('cursor', this._cursor, value);
|
15211
|
-
this._cursor = value;
|
15212
|
-
}
|
15213
|
-
_cursor = 'default';
|
15214
|
-
get visible() {
|
15215
|
-
return this._visible;
|
15216
|
-
}
|
15217
|
-
set visible(value) {
|
15218
|
-
this.propertyChanged('visible', this._visible, value);
|
15219
|
-
this._visible = value;
|
15220
|
-
}
|
15221
|
-
_visible = true;
|
15222
|
-
get borderRadius() {
|
15223
|
-
return this._borderRadius;
|
15224
|
-
}
|
15225
|
-
set borderRadius(value) {
|
15226
|
-
this.propertyChanged('borderRadius', this._borderRadius, value);
|
15227
|
-
this._borderRadius = value;
|
15228
|
-
}
|
15229
|
-
get width() {
|
15230
|
-
return this._width;
|
15231
|
-
}
|
15232
|
-
set width(value) {
|
15233
|
-
this.propertyChanged('width', this._width, value);
|
15234
|
-
this._width = value;
|
15235
|
-
}
|
15236
|
-
get height() {
|
15237
|
-
return this._height;
|
15238
|
-
}
|
15239
|
-
set height(value) {
|
15240
|
-
this.propertyChanged('height', this._height, value);
|
15241
|
-
this._height = value;
|
15242
|
-
}
|
15243
|
-
get x() {
|
15244
|
-
return this._x;
|
15245
|
-
}
|
15246
|
-
set x(value) {
|
15247
|
-
this.propertyChanged('x', this._x, value);
|
15248
|
-
this._x = value;
|
15249
|
-
}
|
15250
|
-
get y() {
|
15251
|
-
return this._y;
|
15252
|
-
}
|
15253
|
-
set y(value) {
|
15254
|
-
this.propertyChanged('y', this._y, value);
|
15255
|
-
this._y = value;
|
15256
|
-
}
|
15257
|
-
_minWidth = Number.NaN;
|
15258
|
-
_minHeight = Number.NaN;
|
15259
|
-
get minWidth() {
|
15260
|
-
return this._minWidth;
|
15261
|
-
}
|
15262
|
-
set minWidth(value) {
|
15263
|
-
this.propertyChanged('minWidth', this._minWidth, value);
|
15264
|
-
this._minWidth = value;
|
15265
|
-
}
|
15266
|
-
get minHeight() {
|
15267
|
-
return this._minHeight;
|
15268
|
-
}
|
15269
|
-
set minHeight(value) {
|
15270
|
-
this.propertyChanged('minHeight', this._minHeight, value);
|
15271
|
-
this._minHeight = value;
|
15272
|
-
}
|
15273
|
-
get bgColor() {
|
15274
|
-
return this._bgColor;
|
15275
|
-
}
|
15276
|
-
set bgColor(value) {
|
15277
|
-
this.propertyChanged('bgColor', this._bgColor, value);
|
15278
|
-
this._bgColor = value;
|
15279
|
-
}
|
15280
|
-
_border = 0;
|
15281
|
-
get border() {
|
15282
|
-
return this._border;
|
15283
|
-
}
|
15284
|
-
set border(value) {
|
15285
|
-
this.propertyChanged('border', this._border, Math.abs(value));
|
15286
|
-
this._border = value;
|
15287
|
-
}
|
15288
|
-
_padding = 0;
|
15289
|
-
get padding() {
|
15290
|
-
return this._padding;
|
15291
|
-
}
|
15292
|
-
set padding(value) {
|
15293
|
-
this.propertyChanged('padding', this._padding, Math.abs(value));
|
15294
|
-
this._padding = value;
|
15295
|
-
}
|
15296
|
-
_borderRadius = 0;
|
15297
|
-
_borderColor;
|
15298
|
-
get borderColor() {
|
15299
|
-
return this._borderColor;
|
15300
|
-
}
|
15301
|
-
set borderColor(value) {
|
15302
|
-
this.propertyChanged('borderColor', this._borderColor, value);
|
15303
|
-
this._borderColor = value;
|
15304
|
-
}
|
15305
|
-
_shadowBlur = 0;
|
15306
|
-
_shadowColor;
|
15307
|
-
get shadowBlur() {
|
15308
|
-
return this._shadowBlur;
|
15309
|
-
}
|
15310
|
-
set shadowBlur(value) {
|
15311
|
-
this.propertyChanged('shadowBlur', this._shadowBlur, value);
|
15312
|
-
this._shadowBlur = value;
|
15313
|
-
}
|
15314
|
-
get shadowColor() {
|
15315
|
-
return this._shadowColor;
|
15316
|
-
}
|
15317
|
-
set shadowColor(value) {
|
15318
|
-
this.propertyChanged('shadowColor', this._shadowColor, value);
|
15319
|
-
this._shadowColor = value;
|
15320
|
-
}
|
15321
|
-
_isMouseenter = false;
|
15322
|
-
get isMouseenter() {
|
15323
|
-
return this._isMouseenter;
|
15324
|
-
}
|
15325
|
-
set isMouseenter(value) {
|
15326
|
-
this.propertyChanged('isMouseenter', this._isMouseenter, value);
|
15327
|
-
this._isMouseenter = value;
|
15328
|
-
}
|
15329
|
-
_overflowHidden = true;
|
15330
|
-
get overflowHidden() {
|
15331
|
-
return this._overflowHidden;
|
15332
|
-
}
|
15333
|
-
set overflowHidden(value) {
|
15334
|
-
this.propertyChanged('overflowHidden', this._overflowHidden, value);
|
15335
|
-
this._overflowHidden = value;
|
15336
|
-
}
|
15337
|
-
outlineColor = '';
|
15338
|
-
outlineStyle = 'none';
|
15339
|
-
outlineWidth = 0;
|
15340
|
-
_width = Number.NaN;
|
15341
|
-
_height = Number.NaN;
|
15342
|
-
_x = 0;
|
15343
|
-
_y = 0;
|
15344
|
-
//测量需要的大小
|
15345
|
-
desiredSize;
|
15346
|
-
//绘制的大小
|
15347
|
-
renderSize;
|
15348
|
-
//最终分配的大小
|
15349
|
-
finalRect;
|
15350
|
-
_bgColor;
|
15351
|
-
_modifyFlag = ModifyFlag.Modify;
|
15352
|
-
get modifyFlag() {
|
15353
|
-
return this._modifyFlag;
|
15354
|
-
}
|
15355
|
-
set modifyFlag(value) {
|
15356
|
-
this._modifyFlag = value;
|
15357
|
-
}
|
15358
|
-
onChangedEvent = new Subject();
|
15359
|
-
listenerEvents = [];
|
15360
|
-
parent;
|
15361
|
-
propertyChanged(prop, old, newV) {
|
15362
|
-
if (this._modifyFlag == ModifyFlag.Modify) {
|
15363
|
-
return;
|
15364
|
-
}
|
15365
|
-
if (old === newV) {
|
15366
|
-
return;
|
15367
|
-
}
|
15368
|
-
this.onChanged();
|
15369
|
-
}
|
15370
|
-
onChanged() {
|
15371
|
-
if (this._modifyFlag == ModifyFlag.Modify) {
|
15372
|
-
return;
|
15373
|
-
}
|
15374
|
-
this._modifyFlag = ModifyFlag.Modify;
|
15375
|
-
// if (this.parent) {
|
15376
|
-
// this.parent.onChildChanged();
|
15377
|
-
// }
|
15378
|
-
this.onChangedEvent.next();
|
15379
|
-
}
|
15380
|
-
addEventListener(name, listener, useCapture = false) {
|
15381
|
-
this.listenerEvents.push({
|
15382
|
-
name,
|
15383
|
-
listener: listener,
|
15384
|
-
useCapture
|
15385
|
-
});
|
15386
|
-
}
|
15387
|
-
removeEventListener(name, listener, useCapture = false) {
|
15388
|
-
const index = this.listenerEvents.findIndex(item => item.name === name && item.listener === listener && item.useCapture === useCapture);
|
15389
|
-
if (index >= 0) {
|
15390
|
-
this.listenerEvents.splice(index, 1);
|
15391
|
-
}
|
15392
|
-
}
|
15393
|
-
/**
|
15394
|
-
* 父容器传入参数,子容器设置坐标位置
|
15395
|
-
* @param e
|
15396
|
-
* @param finalRect
|
15397
|
-
*/
|
15398
|
-
arrange(e, finalRect) {
|
15399
|
-
if (!this._visible) {
|
15400
|
-
this.finalRect = { x: finalRect.x, y: finalRect.y, width: 0, height: 0 };
|
15401
|
-
return;
|
15402
|
-
}
|
15403
|
-
const contentSize = this.getContentSize(finalRect.width, finalRect.height);
|
15404
|
-
const finalSize = this.arrangeOverride(e, contentSize);
|
15405
|
-
this.renderSize = this.getOuterSize({
|
15406
|
-
width: Math.min(contentSize.width, finalSize.width),
|
15407
|
-
height: Math.min(contentSize.height, finalSize.height)
|
15408
|
-
});
|
15409
|
-
this.finalRect = { x: finalRect.x, y: finalRect.y, width: this.renderSize.width, height: this.renderSize.height };
|
15410
|
-
}
|
15411
|
-
arrangeOverride(e, finalSize) {
|
15412
|
-
return finalSize;
|
15413
|
-
}
|
15414
|
-
/**
|
15415
|
-
* 测量阶段
|
15416
|
-
* @param e
|
15417
|
-
* @param availableSize
|
15418
|
-
*/
|
15419
|
-
measure(e, availableSize) {
|
15420
|
-
if (!this._visible) {
|
15421
|
-
this.desiredSize = { width: 0, height: 0 };
|
15422
|
-
return;
|
15423
|
-
}
|
15424
|
-
let width = 0, height = 0;
|
15425
|
-
if (Number.isNaN(this._width)) {
|
15426
|
-
width = availableSize.width;
|
15427
|
-
}
|
15428
|
-
else {
|
15429
|
-
width = this.getPercentWidth(availableSize.width);
|
15430
|
-
}
|
15431
|
-
if (Number.isNaN(this._height)) {
|
15432
|
-
height = availableSize.height;
|
15433
|
-
}
|
15434
|
-
else {
|
15435
|
-
height = this.getPercentHeight(availableSize.height);
|
15436
|
-
}
|
15437
|
-
const measureSize = this.getOuterSize(this.measureOverride(e, this.getContentSize(width, height)));
|
15438
|
-
if (Number.isNaN(this._width)) {
|
15439
|
-
width = measureSize.width;
|
15440
|
-
}
|
15441
|
-
if (Number.isNaN(this._height)) {
|
15442
|
-
height = measureSize.height;
|
15443
|
-
}
|
15444
|
-
this.desiredSize = { width, height };
|
15445
|
-
}
|
15446
|
-
getPercentWidth(val) {
|
15447
|
-
if (typeof this._width === 'object') {
|
15448
|
-
return val * this._width.value / 100;
|
15449
|
-
}
|
15450
|
-
else {
|
15451
|
-
return this._width;
|
15452
|
-
}
|
15453
|
-
}
|
15454
|
-
getPercentHeight(val) {
|
15455
|
-
if (typeof this._height === 'object') {
|
15456
|
-
return val * this._height.value / 100;
|
15457
|
-
}
|
15458
|
-
else {
|
15459
|
-
return this._height;
|
15460
|
-
}
|
15461
|
-
}
|
15462
|
-
/**
|
15463
|
-
* 获取内容尺寸
|
15464
|
-
* 元素模型为边框模型,元素的大小为默认包含边框大小,内容大小需要减去边框大小
|
15465
|
-
* @private
|
15466
|
-
* @param width
|
15467
|
-
* @param height
|
15468
|
-
*/
|
15469
|
-
getContentSize(width, height) {
|
15470
|
-
return {
|
15471
|
-
width: width - this._border * 2 - this._padding * 2,
|
15472
|
-
height: height - this._border * 2 - this.padding * 2
|
15473
|
-
};
|
15474
|
-
}
|
15475
|
-
/**
|
15476
|
-
* 获取外部尺寸
|
15477
|
-
* @param availableSize
|
15478
|
-
* @private
|
15479
|
-
*/
|
15480
|
-
getOuterSize(availableSize) {
|
15481
|
-
return {
|
15482
|
-
width: availableSize.width + this._border * 2 + this._padding * 2,
|
15483
|
-
height: availableSize.height + this._border * 2 + this._padding * 2
|
15484
|
-
};
|
15485
|
-
}
|
15486
|
-
/**
|
15487
|
-
* 子元素需重写该方法
|
15488
|
-
* @param e
|
15489
|
-
* @param availableSize
|
15490
|
-
*/
|
15491
|
-
measureOverride(e, availableSize) {
|
15492
|
-
return availableSize;
|
15493
|
-
}
|
15494
|
-
preRender(e) {
|
15495
|
-
return true;
|
15496
|
-
}
|
15497
|
-
attachedProp = {};
|
15498
|
-
setAttachedProp(name, val) {
|
15499
|
-
const key = name;
|
15500
|
-
this.propertyChanged(key, this.attachedProp[key], val);
|
15501
|
-
this.attachedProp[key] = val;
|
15502
|
-
}
|
15503
|
-
getAttachedPropValue(name) {
|
15504
|
-
return this.attachedProp[name];
|
15505
|
-
}
|
15506
|
-
removeAttachedProp(name) {
|
15507
|
-
this.propertyChanged(name, this.attachedProp[name], undefined);
|
15508
|
-
delete this.attachedProp[name];
|
15509
|
-
}
|
15510
|
-
/**
|
15511
|
-
* 绘制轮廓
|
15512
|
-
*/
|
15513
|
-
renderOutline(renderCtx) {
|
15514
|
-
drawOutline(this, renderCtx);
|
15515
|
-
clipContent(this, renderCtx);
|
15516
|
-
drawBorderline(this, renderCtx);
|
15517
|
-
translate(renderCtx, this.finalRect.x, this.finalRect.y);
|
15518
|
-
translate(renderCtx, this.border + this.padding, this.border + this.padding);
|
15519
|
-
}
|
15520
|
-
}
|
15521
|
-
/**
|
15522
|
-
* 绘制边框
|
15523
|
-
* @param node
|
15524
|
-
* @param renderCtx
|
15525
|
-
*/
|
15526
|
-
function drawBorderline(node, renderCtx) {
|
15527
|
-
//renderCtx.contentContext.fillRect(node.x, node.y, node.finalRect.width, node.finalRect.height, node.bgColor);
|
15528
|
-
if (!node.border) {
|
15529
|
-
return;
|
15530
|
-
}
|
15531
|
-
let { finalRect: { x, y, width, height } } = node;
|
15532
|
-
const ctx = renderCtx.ctx;
|
15533
|
-
ctx.save();
|
15534
|
-
ctx.fillStyle = node.borderColor;
|
15535
|
-
ctx.beginPath();
|
15536
|
-
ctx.moveTo(x, y);
|
15537
|
-
ctx.lineTo(x + width, y);
|
15538
|
-
ctx.lineTo(x + width, y + height);
|
15539
|
-
ctx.lineTo(x, y + height);
|
15540
|
-
ctx.lineTo(x, y);
|
15541
|
-
ctx.closePath();
|
15542
|
-
ctx.fill();
|
15543
|
-
if (node.border) {
|
15544
|
-
ctx.globalCompositeOperation = 'source-atop';
|
15545
|
-
x += node.border;
|
15546
|
-
y += node.border;
|
15547
|
-
width -= node.border * 2;
|
15548
|
-
height -= node.border * 2;
|
15549
|
-
const bgColor = node.bgColor ? node.bgColor : 'white';
|
15550
|
-
ctx.fillStyle = bgColor;
|
15551
|
-
renderCtx.roundRect(x, y, width, height, node.borderRadius);
|
15552
|
-
}
|
15553
|
-
ctx.fill();
|
15554
|
-
ctx.restore();
|
15555
|
-
//裁剪子内容区域范围
|
15556
|
-
node.enableClip && renderCtx.clipFunc(() => renderCtx.roundRect(x, y, width, height, node.borderRadius));
|
15557
|
-
}
|
15558
|
-
/**
|
15559
|
-
* 绘制外轮廓
|
15560
|
-
*/
|
15561
|
-
function drawOutline(node, renderCtx) {
|
15562
|
-
if (node.outlineWidth <= 0 || node.outlineStyle === 'none' || !node.outlineColor) {
|
15563
|
-
return;
|
15564
|
-
}
|
15565
|
-
let { x, y, finalRect: { width, height } } = node;
|
15566
|
-
x -= node.outlineWidth / 2;
|
15567
|
-
y -= node.outlineWidth / 2;
|
15568
|
-
width += node.outlineWidth;
|
15569
|
-
height += node.outlineWidth;
|
15570
|
-
renderCtx.strokeRect(x, y, width, height, node.outlineColor, node.outlineWidth, node.borderRadius);
|
15571
|
-
}
|
15572
|
-
function clipContent(node, renderCtx) {
|
15573
|
-
const x = node.finalRect.x;
|
15574
|
-
const y = node.finalRect.y;
|
15575
|
-
const width = node.finalRect.width;
|
15576
|
-
const height = node.finalRect.height;
|
15577
|
-
renderCtx.ctx.lineWidth = 0;
|
15578
|
-
//绘制背景
|
15579
|
-
if (node.bgColor) {
|
15580
|
-
renderCtx.fillRect(x, y, width, height, node.bgColor, node.shadowBlur, node.shadowColor, node.borderRadius);
|
15581
|
-
}
|
15582
|
-
//确定绘制裁剪范围
|
15583
|
-
renderCtx.clipFunc(() => renderCtx.roundRect(x, y, width, height, node.borderRadius));
|
15584
|
-
}
|
15585
|
-
function translate(renderCtx, x, y) {
|
15586
|
-
renderCtx.ctx.translate(x, y);
|
15587
|
-
}
|
15588
|
-
|
15589
|
-
class RectNode extends NodeCore {
|
15590
|
-
render(e) {
|
15591
|
-
// const {render}=e;
|
15592
|
-
// const ctx=render.contentContext.ctx;
|
15593
|
-
//
|
15594
|
-
// var gradient = ctx.createLinearGradient(0,0, this.finalRect.width,0);
|
15595
|
-
//
|
15596
|
-
// gradient.addColorStop(0, 'green');
|
15597
|
-
// gradient.addColorStop(.5, 'cyan');
|
15598
|
-
// gradient.addColorStop(1, 'blue');
|
15599
|
-
//
|
15600
|
-
// ctx.fillStyle=gradient;
|
15601
|
-
// ctx.fill();
|
15602
|
-
}
|
15603
|
-
}
|
15604
|
-
|
15605
15022
|
/**
|
15606
15023
|
* 事件系统
|
15607
15024
|
*/
|
@@ -15619,13 +15036,13 @@ class DocumentEvent {
|
|
15619
15036
|
focusedRect;
|
15620
15037
|
//当前光标所在的元素
|
15621
15038
|
currentMouseoverRender;
|
15622
|
-
hitInfoChanged = new Subject
|
15623
|
-
clickEvent = new Subject
|
15624
|
-
dblClickEvent = new Subject
|
15625
|
-
tripleClickEvent = new Subject
|
15626
|
-
changeCursor = new Subject
|
15627
|
-
contextMenu = new Subject
|
15628
|
-
trackTipsChanged = new Subject
|
15039
|
+
hitInfoChanged = new Subject();
|
15040
|
+
clickEvent = new Subject();
|
15041
|
+
dblClickEvent = new Subject();
|
15042
|
+
tripleClickEvent = new Subject();
|
15043
|
+
changeCursor = new Subject();
|
15044
|
+
contextMenu = new Subject();
|
15045
|
+
trackTipsChanged = new Subject();
|
15629
15046
|
//光标处于边框的绘制元素
|
15630
15047
|
edgeRenderInfo;
|
15631
15048
|
//当前鼠标所在的page-position
|
@@ -16845,119 +16262,6 @@ class DocumentEvent {
|
|
16845
16262
|
// }
|
16846
16263
|
// }
|
16847
16264
|
}
|
16848
|
-
/**
|
16849
|
-
* 开启打印区域
|
16850
|
-
*/
|
16851
|
-
startPrintArea(editor) {
|
16852
|
-
const cancelToken = {};
|
16853
|
-
const startRect = new RectNode();
|
16854
|
-
startRect.x = 0;
|
16855
|
-
startRect.y = 0;
|
16856
|
-
startRect.width = editor.width;
|
16857
|
-
startRect.height = 0;
|
16858
|
-
//设置半透明颜色
|
16859
|
-
startRect.bgColor = this.viewOptions.selectPrintAreaBgColor;
|
16860
|
-
startRect.pointEvent = false;
|
16861
|
-
const endRect = new RectNode();
|
16862
|
-
endRect.x = 0;
|
16863
|
-
endRect.y = editor.finalRect.height;
|
16864
|
-
endRect.width = editor.width;
|
16865
|
-
endRect.height = 0;
|
16866
|
-
//设置半透明颜色
|
16867
|
-
endRect.bgColor = this.viewOptions.selectPrintAreaBgColor;
|
16868
|
-
endRect.pointEvent = false;
|
16869
|
-
let state = 'start';
|
16870
|
-
editor.parent?.addChild(startRect);
|
16871
|
-
editor.parent?.addChild(endRect);
|
16872
|
-
let startY = 0, startDocIndex = 0, endY = 0, endDocIndex = 0;
|
16873
|
-
const onMousemoveHandler = (evt) => {
|
16874
|
-
const pos = evt.sourceHitPos;
|
16875
|
-
if (state === 'start') {
|
16876
|
-
startRect.height = pos.y;
|
16877
|
-
}
|
16878
|
-
else {
|
16879
|
-
if (startRect.height + 5 > pos.y) {
|
16880
|
-
return;
|
16881
|
-
}
|
16882
|
-
endRect.y = pos.y;
|
16883
|
-
endRect.height = editor.finalRect.height - pos.y;
|
16884
|
-
}
|
16885
|
-
};
|
16886
|
-
const onKeydownHandler = (evt) => {
|
16887
|
-
if (evt.sourceEvt.keyCode === 27) {
|
16888
|
-
cancelToken.cancel?.();
|
16889
|
-
}
|
16890
|
-
};
|
16891
|
-
const onClickHandler = (evt) => {
|
16892
|
-
const pos = evt.sourceHitPos;
|
16893
|
-
const hitDoc = this.getHitDocPage({ globalX: pos.x, globalY: pos.y });
|
16894
|
-
if (!hitDoc) {
|
16895
|
-
return;
|
16896
|
-
}
|
16897
|
-
const { docIndex, hitPagePos } = hitDoc;
|
16898
|
-
if (state === 'start') {
|
16899
|
-
startY = hitPagePos.y;
|
16900
|
-
startDocIndex = docIndex;
|
16901
|
-
state = 'end';
|
16902
|
-
}
|
16903
|
-
else {
|
16904
|
-
if (startRect.height + 5 > pos.y) {
|
16905
|
-
return;
|
16906
|
-
}
|
16907
|
-
endY = hitPagePos.y;
|
16908
|
-
endDocIndex = docIndex;
|
16909
|
-
cancelToken.onFinish?.({
|
16910
|
-
startY,
|
16911
|
-
startDocIndex,
|
16912
|
-
endY,
|
16913
|
-
endDocIndex
|
16914
|
-
});
|
16915
|
-
}
|
16916
|
-
};
|
16917
|
-
editor.addEventListener('mousemove', onMousemoveHandler);
|
16918
|
-
editor.addEventListener('keydown', onKeydownHandler);
|
16919
|
-
editor.addEventListener('click', onClickHandler);
|
16920
|
-
cancelToken.cancel = () => {
|
16921
|
-
if (!startRect.parent) {
|
16922
|
-
return;
|
16923
|
-
}
|
16924
|
-
startRect.parent?.removeChild(startRect);
|
16925
|
-
endRect.parent?.removeChild(endRect);
|
16926
|
-
editor.removeEventListener('mousemove', onMousemoveHandler);
|
16927
|
-
editor.removeEventListener('keydown', onKeydownHandler);
|
16928
|
-
editor.removeEventListener('click', onClickHandler);
|
16929
|
-
};
|
16930
|
-
return cancelToken;
|
16931
|
-
}
|
16932
|
-
clicks = 0;
|
16933
|
-
timeout;
|
16934
|
-
/**
|
16935
|
-
* 处理三击事件
|
16936
|
-
*/
|
16937
|
-
handleTripleClick() {
|
16938
|
-
this.clicks++;
|
16939
|
-
let curr = this;
|
16940
|
-
if (this.clicks === 1) {
|
16941
|
-
// 设置延时,等待第二次点击
|
16942
|
-
this.timeout = setTimeout(function () {
|
16943
|
-
curr.clicks = 0;
|
16944
|
-
}, 300);
|
16945
|
-
}
|
16946
|
-
else if (this.clicks === 2) {
|
16947
|
-
// 第二次点击后,清除延时
|
16948
|
-
clearTimeout(curr.timeout);
|
16949
|
-
// 设置延时,等待第三次点击
|
16950
|
-
curr.timeout = setTimeout(function () {
|
16951
|
-
curr.clicks = 0;
|
16952
|
-
}, 300);
|
16953
|
-
}
|
16954
|
-
else if (curr.clicks === 3) {
|
16955
|
-
// 第三次点击后,处理三击事件并清除延时
|
16956
|
-
clearTimeout(curr.timeout);
|
16957
|
-
this.tripleClickEvent.next();
|
16958
|
-
this.clicks = 0;
|
16959
|
-
}
|
16960
|
-
}
|
16961
16265
|
/**
|
16962
16266
|
* 获取当前光标所在的数据元
|
16963
16267
|
* @returns
|
@@ -16990,34 +16294,34 @@ class DocumentEvent {
|
|
16990
16294
|
class DocumentInput {
|
16991
16295
|
docCtx;
|
16992
16296
|
//输入内容事件
|
16993
|
-
onInputEvent = new Subject
|
16297
|
+
onInputEvent = new Subject();
|
16994
16298
|
//backspace 键盘事件
|
16995
|
-
onBackspaceEvent = new Subject
|
16299
|
+
onBackspaceEvent = new Subject();
|
16996
16300
|
//delete 键盘事件
|
16997
|
-
onDeleteEvent = new Subject
|
16301
|
+
onDeleteEvent = new Subject();
|
16998
16302
|
//enter 键盘事件
|
16999
|
-
onEnterEvent = new Subject
|
16303
|
+
onEnterEvent = new Subject();
|
17000
16304
|
//左键
|
17001
|
-
onLeftEvent = new Subject
|
16305
|
+
onLeftEvent = new Subject();
|
17002
16306
|
//右键
|
17003
|
-
onRightEvent = new Subject
|
16307
|
+
onRightEvent = new Subject();
|
17004
16308
|
//复制
|
17005
|
-
onCopyEvent = new Subject
|
16309
|
+
onCopyEvent = new Subject();
|
17006
16310
|
//剪切
|
17007
|
-
onCutEvent = new Subject
|
16311
|
+
onCutEvent = new Subject();
|
17008
16312
|
//粘贴
|
17009
|
-
onPasteEvent = new Subject
|
16313
|
+
onPasteEvent = new Subject();
|
17010
16314
|
//插入换行符
|
17011
|
-
onInsertBr = new Subject
|
16315
|
+
onInsertBr = new Subject();
|
17012
16316
|
//ctrl+A 全选事件
|
17013
|
-
onSelectAllEvent = new Subject
|
16317
|
+
onSelectAllEvent = new Subject();
|
17014
16318
|
//home 事件
|
17015
|
-
onHomeEvent = new Subject
|
16319
|
+
onHomeEvent = new Subject();
|
17016
16320
|
//end 事件
|
17017
|
-
onEndEvent = new Subject
|
17018
|
-
onUpEvent = new Subject
|
17019
|
-
onDownEvent = new Subject
|
17020
|
-
onTabKeyEvent = new Subject
|
16321
|
+
onEndEvent = new Subject();
|
16322
|
+
onUpEvent = new Subject();
|
16323
|
+
onDownEvent = new Subject();
|
16324
|
+
onTabKeyEvent = new Subject();
|
17021
16325
|
constructor(docCtx) {
|
17022
16326
|
this.docCtx = docCtx;
|
17023
16327
|
}
|
@@ -17205,7 +16509,7 @@ class DocumentChange {
|
|
17205
16509
|
});
|
17206
16510
|
}
|
17207
16511
|
newInput(data) {
|
17208
|
-
if (data.composition && data.data === '
|
16512
|
+
if (data.composition && data.data === '啊') {
|
17209
16513
|
debugger;
|
17210
16514
|
}
|
17211
16515
|
const { startControl, startOffset, collapsed, enableTrackChanges } = this.selectionState;
|
@@ -17230,6 +16534,9 @@ class DocumentChange {
|
|
17230
16534
|
const comp = data.compositionStartInfo;
|
17231
16535
|
comp.element = newInput;
|
17232
16536
|
comp.offset = 0;
|
16537
|
+
//修正数据
|
16538
|
+
if (data.composition)
|
16539
|
+
this.documentInput.correctInputEle(newInput, newInput.text, 0);
|
17233
16540
|
this.inputTextGroup(newInput, data);
|
17234
16541
|
return;
|
17235
16542
|
}
|
@@ -17281,7 +16588,7 @@ class DocumentChange {
|
|
17281
16588
|
return true;
|
17282
16589
|
};
|
17283
16590
|
//利用回调完成后续的输入处理
|
17284
|
-
this.docCtx.
|
16591
|
+
this.docCtx.onNextView(cb);
|
17285
16592
|
}
|
17286
16593
|
/**
|
17287
16594
|
* 当前元素是否在正确的留痕区域(ins-run、del-run),情况分为以下情况
|
@@ -18410,7 +17717,7 @@ class DocumentChange {
|
|
18410
17717
|
const cb = () => {
|
18411
17718
|
this.handlePasteContent({ text: pasteText, doc: pasteData }, this.selectionState);
|
18412
17719
|
};
|
18413
|
-
this.docCtx.
|
17720
|
+
this.docCtx.onNextView(cb);
|
18414
17721
|
return;
|
18415
17722
|
}
|
18416
17723
|
this.handlePasteContent({ text: pasteText, doc: pasteData }, this.selectionState);
|
@@ -19344,7 +18651,7 @@ class ElementTrackManage {
|
|
19344
18651
|
if (!ssLog) {
|
19345
18652
|
return;
|
19346
18653
|
}
|
19347
|
-
this.docCtx.
|
18654
|
+
this.docCtx.onNextView(() => {
|
19348
18655
|
const { startIndex, startOffset, endIndex, endOffset, editable } = ssLog;
|
19349
18656
|
const range = new SelectionRange();
|
19350
18657
|
const sc = this.getControl(startIndex, false);
|
@@ -19450,6 +18757,9 @@ class ElementTrackManage {
|
|
19450
18757
|
getControl(index, pure = true) {
|
19451
18758
|
return ElementUtil.getControlByIndex(this.docCtx.document, { currIndex: -1, index: index }, pure);
|
19452
18759
|
}
|
18760
|
+
getControlIndex(control) {
|
18761
|
+
return ElementUtil.getControlIndex(control, true);
|
18762
|
+
}
|
19453
18763
|
}
|
19454
18764
|
|
19455
18765
|
class DocumentSvg {
|
@@ -19465,7 +18775,7 @@ class DocumentSvg {
|
|
19465
18775
|
this.sso = sso;
|
19466
18776
|
this.renderCtx = renderCtx;
|
19467
18777
|
}
|
19468
|
-
getVNode(render,
|
18778
|
+
getVNode(render, parentMaskRect, parentPos) {
|
19469
18779
|
const currPos = {
|
19470
18780
|
x: parentPos.x + render.rect.x,
|
19471
18781
|
y: parentPos.y + render.rect.y,
|
@@ -19473,17 +18783,13 @@ class DocumentSvg {
|
|
19473
18783
|
height: render.rect.height
|
19474
18784
|
};
|
19475
18785
|
//处理选区遮罩
|
19476
|
-
this.createSelectionRect(render,
|
19477
|
-
|
19478
|
-
if (this.viewOptions.showReviewWindow && render instanceof CommsContainerRenderObject) {
|
19479
|
-
CommentsUtil.arrangeComments(render);
|
19480
|
-
}
|
19481
|
-
const getChildNodes = (node, selectionRects) => {
|
18786
|
+
this.createSelectionRect(render, parentMaskRect, currPos);
|
18787
|
+
const getChildNodes = (node, selectionMask) => {
|
19482
18788
|
if (node instanceof BranchRenderObject) {
|
19483
18789
|
const children = [];
|
19484
18790
|
for (let i = 0; i < node.length; i++) {
|
19485
18791
|
const child = node.getChild(i);
|
19486
|
-
const vNode = this.getVNode(child,
|
18792
|
+
const vNode = this.getVNode(child, selectionMask, currPos);
|
19487
18793
|
if (Array.isArray(vNode)) {
|
19488
18794
|
children.push(...vNode);
|
19489
18795
|
}
|
@@ -19493,14 +18799,12 @@ class DocumentSvg {
|
|
19493
18799
|
}
|
19494
18800
|
return children;
|
19495
18801
|
}
|
19496
|
-
|
19497
|
-
return null;
|
19498
|
-
}
|
18802
|
+
return null;
|
19499
18803
|
};
|
19500
|
-
let
|
18804
|
+
let currMaskGroup = { selection: [], mask: [] };
|
19501
18805
|
const vNodeOptions = {
|
19502
18806
|
getChildNodes: (node) => {
|
19503
|
-
return getChildNodes(node,
|
18807
|
+
return getChildNodes(node, currMaskGroup);
|
19504
18808
|
},
|
19505
18809
|
options: this.viewOptions,
|
19506
18810
|
highlights: [],
|
@@ -19520,7 +18824,7 @@ class DocumentSvg {
|
|
19520
18824
|
this.highlights.push(...vNodeOptions.highlights);
|
19521
18825
|
}
|
19522
18826
|
if (currVNode && !currVNode.isCompleted) {
|
19523
|
-
const childNodes = getChildNodes(render,
|
18827
|
+
const childNodes = getChildNodes(render, currMaskGroup);
|
19524
18828
|
if (childNodes) {
|
19525
18829
|
if (!currVNode.children) {
|
19526
18830
|
currVNode.children = [];
|
@@ -19534,26 +18838,22 @@ class DocumentSvg {
|
|
19534
18838
|
}
|
19535
18839
|
}
|
19536
18840
|
if (render instanceof ParagraphLineRectRenderObject) {
|
19537
|
-
if (
|
19538
|
-
|
19539
|
-
const endX = selectionRectsTemp[selectionRectsTemp.length - 1].x + selectionRectsTemp[selectionRectsTemp.length - 1].width;
|
19540
|
-
selectionRects.push({
|
19541
|
-
x: startX,
|
19542
|
-
y: currPos.y,
|
19543
|
-
width: endX - startX,
|
19544
|
-
height: currPos.height,
|
19545
|
-
color: selectionRectsTemp[0].color
|
19546
|
-
});
|
19547
|
-
selectionRectsTemp.length = 0;
|
18841
|
+
if (currMaskGroup.selection.length > 0) {
|
18842
|
+
this.combineParaLineSelection(parentMaskRect.selection, currMaskGroup.selection, currPos);
|
19548
18843
|
}
|
19549
18844
|
}
|
19550
18845
|
else if (render instanceof TableCellRenderObject) {
|
19551
18846
|
if (this.sso.selectionEleSets.has(render.element) && this.sso.selectionEleSets.get(render.element)?.isFullSelected) {
|
19552
|
-
|
19553
|
-
|
18847
|
+
parentMaskRect.selection.push(currPos);
|
18848
|
+
currMaskGroup.selection.length = 0;
|
18849
|
+
}
|
18850
|
+
if (this.sso.commRangeSets.has(render.element) && this.sso.commRangeSets.get(render.element)?.isFullSelected) {
|
18851
|
+
parentMaskRect.mask.push(currPos);
|
18852
|
+
currMaskGroup.mask.length = 0;
|
19554
18853
|
}
|
19555
18854
|
}
|
19556
|
-
|
18855
|
+
parentMaskRect.selection.push(...currMaskGroup.selection);
|
18856
|
+
parentMaskRect.mask.push(...currMaskGroup.mask);
|
19557
18857
|
// if (currVNode && currVNode.data?.attrs?.transform) {
|
19558
18858
|
// currVNode.data.attrs.transform = `translate(${currVNode.data?.attrs?.transform.x},${currVNode.data?.attrs?.transform.y})`
|
19559
18859
|
// }
|
@@ -19573,13 +18873,6 @@ class DocumentSvg {
|
|
19573
18873
|
if (line && !item.data.attrs.transform) {
|
19574
18874
|
item.data.attrs.transform = `translate(${translateX},${translateY})`;
|
19575
18875
|
}
|
19576
|
-
// if (item && item.data?.attrs?.transform && typeof item.data?.attrs?.transform === 'object') {
|
19577
|
-
// item.data.attrs.transform = `translate(${item.data.attrs.transform.x + translateX},${item.data.attrs.transform.y + translateY})`
|
19578
|
-
// } else {
|
19579
|
-
// if (line && !item.data.attrs.transform) {
|
19580
|
-
// item.data.attrs.transform = `translate(${translateX},${translateY})`;
|
19581
|
-
// }
|
19582
|
-
// }
|
19583
18876
|
});
|
19584
18877
|
if (line) {
|
19585
18878
|
return currVNode.children;
|
@@ -19590,32 +18883,35 @@ class DocumentSvg {
|
|
19590
18883
|
}
|
19591
18884
|
return currVNode;
|
19592
18885
|
}
|
19593
|
-
createSelectionRect(render,
|
19594
|
-
const
|
19595
|
-
|
19596
|
-
|
19597
|
-
|
19598
|
-
|
19599
|
-
|
19600
|
-
|
19601
|
-
|
19602
|
-
|
19603
|
-
|
19604
|
-
|
19605
|
-
|
19606
|
-
|
19607
|
-
|
19608
|
-
|
19609
|
-
|
19610
|
-
|
19611
|
-
width,
|
19612
|
-
height: currPos.height,
|
19613
|
-
color: range['rangeColor']
|
19614
|
-
});
|
19615
|
-
}
|
18886
|
+
createSelectionRect(render, selectionMask, currPos) {
|
18887
|
+
const createMaskVNode = (range, selectionRects) => {
|
18888
|
+
if (render.element && render instanceof LeafRenderObject) {
|
18889
|
+
if (range.isFullSelected) {
|
18890
|
+
selectionRects.push({ ...currPos, color: range['rangeColor'] });
|
18891
|
+
}
|
18892
|
+
else {
|
18893
|
+
if (render.element instanceof TextGroupElement && range.endOffset > range.startOffset) {
|
18894
|
+
const { startX, endX } = ElementUtil.getTextRenderHorX(render, range.startOffset, range.endOffset);
|
18895
|
+
const width = endX - startX;
|
18896
|
+
const x = currPos.x + startX;
|
18897
|
+
selectionRects.push({
|
18898
|
+
x,
|
18899
|
+
y: currPos.y,
|
18900
|
+
width,
|
18901
|
+
height: currPos.height,
|
18902
|
+
color: range['rangeColor']
|
18903
|
+
});
|
19616
18904
|
}
|
19617
18905
|
}
|
19618
18906
|
}
|
18907
|
+
};
|
18908
|
+
if (this.sso.selectionEleSets.has(render.element)) {
|
18909
|
+
const range = this.sso.selectionEleSets.get(render.element);
|
18910
|
+
createMaskVNode(range, selectionMask.selection);
|
18911
|
+
}
|
18912
|
+
if (this.sso.commRangeSets.has(render.element)) {
|
18913
|
+
const range = this.sso.commRangeSets.get(render.element);
|
18914
|
+
createMaskVNode(range, selectionMask.mask);
|
19619
18915
|
}
|
19620
18916
|
}
|
19621
18917
|
getHTMLVNode(docRenders) {
|
@@ -19664,12 +18960,13 @@ class DocumentSvg {
|
|
19664
18960
|
}
|
19665
18961
|
getPageSvgVNode(item) {
|
19666
18962
|
this.highlights = [];
|
19667
|
-
const rects = [];
|
18963
|
+
const rects = { selection: [], mask: [] };
|
19668
18964
|
this.pagePos = { x: item.rect.x, y: item.rect.y };
|
19669
18965
|
const pageSvg = this.getVNode(item, rects, { x: -item.rect.x, y: -item.rect.y });
|
19670
18966
|
const selectionNode = pageSvg.children?.find(item => item && item.data?.attrs?.id === 'selection');
|
19671
|
-
const
|
19672
|
-
|
18967
|
+
const highlightNode = pageSvg.children?.find(item => item && item.data?.attrs?.id === 'highlight');
|
18968
|
+
rects.selection = rects.selection.concat(rects.mask);
|
18969
|
+
selectionNode.children = rects.selection.map(item => ({
|
19673
18970
|
sel: 'path',
|
19674
18971
|
data: {
|
19675
18972
|
ns: 'http://www.w3.org/2000/svg',
|
@@ -19682,7 +18979,7 @@ class DocumentSvg {
|
|
19682
18979
|
}
|
19683
18980
|
}
|
19684
18981
|
}));
|
19685
|
-
|
18982
|
+
highlightNode.children = this.highlights;
|
19686
18983
|
return pageSvg;
|
19687
18984
|
}
|
19688
18985
|
counterMap = {};
|
@@ -19702,6 +18999,25 @@ class DocumentSvg {
|
|
19702
18999
|
addChangeTips(tipVNode) {
|
19703
19000
|
this.changeTips.push(tipVNode);
|
19704
19001
|
}
|
19002
|
+
/**
|
19003
|
+
* 合并段落行选区
|
19004
|
+
* @param parentMaskRect
|
19005
|
+
* @param currMaskRect
|
19006
|
+
* @param currPos
|
19007
|
+
* @private
|
19008
|
+
*/
|
19009
|
+
combineParaLineSelection(parentMaskRect, currMaskRect, currPos) {
|
19010
|
+
const startX = currMaskRect[0].x;
|
19011
|
+
const endX = currMaskRect[currMaskRect.length - 1].x + currMaskRect[currMaskRect.length - 1].width;
|
19012
|
+
parentMaskRect.push({
|
19013
|
+
x: startX,
|
19014
|
+
y: currPos.y,
|
19015
|
+
width: endX - startX,
|
19016
|
+
height: currPos.height,
|
19017
|
+
color: currMaskRect[0].color
|
19018
|
+
});
|
19019
|
+
currMaskRect.length = 0;
|
19020
|
+
}
|
19705
19021
|
}
|
19706
19022
|
|
19707
19023
|
/**
|
@@ -19714,7 +19030,7 @@ class EditorCalendarVNode {
|
|
19714
19030
|
currCalendarMode;
|
19715
19031
|
selectedDate;
|
19716
19032
|
currentDate = '';
|
19717
|
-
onSetValue = new Subject
|
19033
|
+
onSetValue = new Subject();
|
19718
19034
|
currTime;
|
19719
19035
|
selectedTime;
|
19720
19036
|
constructor(viewOptions) {
|
@@ -20535,6 +19851,154 @@ class DocRule {
|
|
20535
19851
|
}
|
20536
19852
|
}
|
20537
19853
|
|
19854
|
+
function calculateOverflow(rect, viewport) {
|
19855
|
+
const overflow = rect.y + rect.height - (viewport.y + viewport.height);
|
19856
|
+
return overflow > 0 ? overflow : 0;
|
19857
|
+
}
|
19858
|
+
function adjustRectangles(rectangles, startIndex, endIndex, overflow) {
|
19859
|
+
for (let i = startIndex; i < endIndex; i++) {
|
19860
|
+
const currentRect = rectangles[i];
|
19861
|
+
currentRect.y -= overflow;
|
19862
|
+
}
|
19863
|
+
}
|
19864
|
+
function placeRectangles(rectangles, viewport) {
|
19865
|
+
// Step 1: 过滤视窗内的矩形并按y值排序
|
19866
|
+
const sortedRectangles = rectangles
|
19867
|
+
.filter(rect => rect.y + rect.height >= viewport.y &&
|
19868
|
+
rect.y <= viewport.y + viewport.height)
|
19869
|
+
.sort((a, b) => a.y - b.y);
|
19870
|
+
// Step 2: 遍历并调整矩形位置
|
19871
|
+
for (let i = 1; i < sortedRectangles.length; i++) {
|
19872
|
+
const currentRect = sortedRectangles[i];
|
19873
|
+
const prevRect = sortedRectangles[i - 1];
|
19874
|
+
// Step 3: 调整重叠矩形的位置
|
19875
|
+
if (currentRect.y < prevRect.y + prevRect.height) {
|
19876
|
+
currentRect.y = prevRect.y + prevRect.height;
|
19877
|
+
}
|
19878
|
+
// Step 4: 处理超出视窗的情况
|
19879
|
+
let overflow = calculateOverflow(currentRect, viewport);
|
19880
|
+
if (overflow <= 0) {
|
19881
|
+
continue;
|
19882
|
+
}
|
19883
|
+
//紧挨着的上级兄弟元素之间存在足够空间
|
19884
|
+
const remainingSpace = currentRect.y - prevRect.y - prevRect.height;
|
19885
|
+
if (remainingSpace > 0) {
|
19886
|
+
if (remainingSpace >= overflow) {
|
19887
|
+
currentRect.y -= overflow;
|
19888
|
+
continue;
|
19889
|
+
}
|
19890
|
+
else {
|
19891
|
+
overflow -= remainingSpace;
|
19892
|
+
adjustRectangles(sortedRectangles, i - 1, i, remainingSpace);
|
19893
|
+
currentRect.y -= remainingSpace;
|
19894
|
+
}
|
19895
|
+
}
|
19896
|
+
const space = findSpace(sortedRectangles, viewport, i - 1, i, overflow);
|
19897
|
+
//完全没有可用空间,后续元素按照顺序排列即可
|
19898
|
+
if (space === overflow) {
|
19899
|
+
const prevRect = sortedRectangles[i - 1];
|
19900
|
+
sortedRectangles.filter((item, index) => index >= i).reduce((prev, curr) => { curr.y = prev.y + prev.height; return curr; }, prevRect);
|
19901
|
+
break;
|
19902
|
+
}
|
19903
|
+
currentRect.y -= (overflow - space);
|
19904
|
+
}
|
19905
|
+
return sortedRectangles;
|
19906
|
+
}
|
19907
|
+
function findSpace(sortedRectangles, viewport, i, overflowIndex, overflow) {
|
19908
|
+
for (let j = i; j >= 0; j--) {
|
19909
|
+
let currentRect = sortedRectangles[j];
|
19910
|
+
let aboveRect = sortedRectangles[j - 1];
|
19911
|
+
if (aboveRect === undefined) {
|
19912
|
+
aboveRect = { y: viewport.y, height: 0, width: 0, x: 0 };
|
19913
|
+
}
|
19914
|
+
const remainingSpace = currentRect.y - aboveRect.y - aboveRect.height;
|
19915
|
+
//存在可用空间
|
19916
|
+
if (remainingSpace > 0) {
|
19917
|
+
if (remainingSpace >= overflow) {
|
19918
|
+
adjustRectangles(sortedRectangles, j, overflowIndex, overflow);
|
19919
|
+
return 0;
|
19920
|
+
}
|
19921
|
+
else {
|
19922
|
+
overflow -= remainingSpace;
|
19923
|
+
// 调整当前元素到溢出元素之间的元素的y值
|
19924
|
+
adjustRectangles(sortedRectangles, j, overflowIndex, remainingSpace);
|
19925
|
+
return findSpace(sortedRectangles, viewport, j - 1, overflowIndex, overflow);
|
19926
|
+
}
|
19927
|
+
}
|
19928
|
+
else {
|
19929
|
+
return findSpace(sortedRectangles, viewport, j - 1, overflowIndex, overflow);
|
19930
|
+
}
|
19931
|
+
}
|
19932
|
+
return overflow;
|
19933
|
+
}
|
19934
|
+
/**
|
19935
|
+
* 调整页面提示框位置,使其在视窗内的位置合理
|
19936
|
+
*/
|
19937
|
+
function adjustViewportElements(tipContainer, viewPort) {
|
19938
|
+
viewPort.y /= viewPort.scale;
|
19939
|
+
viewPort.height /= viewPort.scale;
|
19940
|
+
const tipContainerEle = tipContainer.elm;
|
19941
|
+
const tipContainerRect = tipContainerEle.getBoundingClientRect();
|
19942
|
+
const children = tipContainer.children;
|
19943
|
+
if (!children || children.length === 0) {
|
19944
|
+
return;
|
19945
|
+
}
|
19946
|
+
const nativeEle = [];
|
19947
|
+
for (let i = 0; i < children.length; i++) {
|
19948
|
+
const item = children[i];
|
19949
|
+
const elm = item.elm;
|
19950
|
+
if (!elm.classList.contains("tg-container")) {
|
19951
|
+
continue;
|
19952
|
+
}
|
19953
|
+
const runKey = elm.dataset['key'];
|
19954
|
+
const lineElm = tipContainerEle.querySelector(`.doc-triangle-line[data-key='${runKey}']`);
|
19955
|
+
const linePos = getEleAbsolutePos(lineElm);
|
19956
|
+
const eleRect = { elm, lineElm, x: 0, y: 0, width: 0, height: 0, linePos };
|
19957
|
+
nativeEle.push(eleRect);
|
19958
|
+
const rect = elm.getBoundingClientRect();
|
19959
|
+
eleRect.y = linePos.y;
|
19960
|
+
eleRect.x = (rect.x - tipContainerRect.x) / viewPort.scale;
|
19961
|
+
eleRect.width = rect.width / viewPort.scale;
|
19962
|
+
eleRect.height = rect.height / viewPort.scale;
|
19963
|
+
}
|
19964
|
+
if (nativeEle.length) {
|
19965
|
+
const sortedRectangles = placeRectangles(nativeEle, viewPort);
|
19966
|
+
for (let i = 0; i < sortedRectangles.length; i++) {
|
19967
|
+
const item = sortedRectangles[i];
|
19968
|
+
item.elm.style.top = item.y + 'px';
|
19969
|
+
const rotationAngle = calculateRotationAngle(item.linePos, item);
|
19970
|
+
const distance = calculateDistance(item.linePos, item);
|
19971
|
+
rotateDiv(item.lineElm, rotationAngle, distance);
|
19972
|
+
}
|
19973
|
+
}
|
19974
|
+
}
|
19975
|
+
function getEleAbsolutePos(elm) {
|
19976
|
+
const topStr = elm.style.top;
|
19977
|
+
const leftStr = elm.style.left;
|
19978
|
+
return {
|
19979
|
+
x: parseInt(leftStr.substring(0, leftStr.length - 2)),
|
19980
|
+
y: parseInt(topStr.substring(0, topStr.length - 2))
|
19981
|
+
};
|
19982
|
+
}
|
19983
|
+
function calculateRotationAngle(a, b) {
|
19984
|
+
const deltaX = b.x - a.x;
|
19985
|
+
const deltaY = b.y - a.y;
|
19986
|
+
// 使用反正切函数计算旋转角度
|
19987
|
+
const angleInRadians = Math.atan2(deltaY, deltaX);
|
19988
|
+
// 将弧度转换为度数
|
19989
|
+
const angleInDegrees = angleInRadians * (180 / Math.PI);
|
19990
|
+
return angleInDegrees;
|
19991
|
+
}
|
19992
|
+
function rotateDiv(c, angle, distance) {
|
19993
|
+
c.style.transform = `rotate(${angle}deg)`;
|
19994
|
+
c.style.width = `${distance}px`;
|
19995
|
+
}
|
19996
|
+
function calculateDistance(a, b) {
|
19997
|
+
const deltaX = b.x - a.x;
|
19998
|
+
const deltaY = b.y - a.y;
|
19999
|
+
return Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
20000
|
+
}
|
20001
|
+
|
20538
20002
|
class DocEditor {
|
20539
20003
|
svgContainer;
|
20540
20004
|
//private docContent!: HTMLElement;
|
@@ -20552,28 +20016,25 @@ class DocEditor {
|
|
20552
20016
|
selectionOverlays;
|
20553
20017
|
//private docRule: DocRule;
|
20554
20018
|
historyMange;
|
20555
|
-
selectionChanged = new Subject
|
20556
|
-
beforeRenderSubject = new Subject
|
20557
|
-
afterRenderSubject = new Subject
|
20558
|
-
onBeforeSetCursorSubject = new Subject
|
20559
|
-
contentChanged = new Subject
|
20560
|
-
onPatchVNodeSubject = new Subject
|
20019
|
+
selectionChanged = new Subject();
|
20020
|
+
beforeRenderSubject = new Subject();
|
20021
|
+
afterRenderSubject = new Subject();
|
20022
|
+
onBeforeSetCursorSubject = new Subject();
|
20023
|
+
contentChanged = new Subject();
|
20024
|
+
onPatchVNodeSubject = new Subject();
|
20561
20025
|
selectionState;
|
20562
|
-
|
20563
|
-
|
20564
|
-
onDblClickEvent = new Subject$1();
|
20565
|
-
onClickEvent = new Subject$1();
|
20566
|
-
onScrollViewEvent = new Subject$1();
|
20026
|
+
onDblClickEvent = new Subject();
|
20027
|
+
onClickEvent = new Subject();
|
20567
20028
|
//文档改变事件:内容及样式,业务模块需要根据此事件,来追踪当前文档是否改变的状态
|
20568
|
-
onDocChangedEvent = new Subject
|
20029
|
+
onDocChangedEvent = new Subject();
|
20569
20030
|
//执行flushTask,refreshDoc之前,此时可以在文档计算排版之前改变内容
|
20570
|
-
onBeforeRefreshDocument = new Subject
|
20031
|
+
onBeforeRefreshDocument = new Subject();
|
20571
20032
|
//文档视图尺寸改变事件
|
20572
|
-
onDocViewSizeChanged = new Subject
|
20033
|
+
onDocViewSizeChanged = new Subject();
|
20573
20034
|
//编辑器销毁事件
|
20574
|
-
onDestroy = new Subject
|
20575
|
-
beforeNodePatch = new Subject
|
20576
|
-
afterNodePatch = new Subject
|
20035
|
+
onDestroy = new Subject();
|
20036
|
+
beforeNodePatch = new Subject();
|
20037
|
+
afterNodePatch = new Subject();
|
20577
20038
|
//自定义事件传递消息
|
20578
20039
|
eventBus;
|
20579
20040
|
editInput;
|
@@ -20588,7 +20049,6 @@ class DocEditor {
|
|
20588
20049
|
this.viewOptions.drawCharRectColor = 'green';
|
20589
20050
|
this.viewOptions.showLineRect = true;
|
20590
20051
|
this.viewOptions.docSpace = 20;
|
20591
|
-
this.viewOptions.reviewWindowWidth = 200;
|
20592
20052
|
this.viewOptions.defaultFontName = '宋体';
|
20593
20053
|
this.viewOptions.editorVersion = this.version();
|
20594
20054
|
//this.viewOptions.scale = 2;
|
@@ -20774,11 +20234,13 @@ class DocEditor {
|
|
20774
20234
|
return null;
|
20775
20235
|
}
|
20776
20236
|
this.flushTask = () => {
|
20237
|
+
//读取变更记录,可能会同步影响文档内容
|
20238
|
+
this.readDocChangeLog();
|
20777
20239
|
this.refreshDocument();
|
20778
20240
|
this.flushTask = null;
|
20779
|
-
let cb = this.docCtx.
|
20241
|
+
let cb = this.docCtx.nextViewFn;
|
20780
20242
|
if (cb) {
|
20781
|
-
this.docCtx.
|
20243
|
+
this.docCtx.onNextView(null);
|
20782
20244
|
cb();
|
20783
20245
|
return;
|
20784
20246
|
}
|
@@ -21209,7 +20671,7 @@ class DocEditor {
|
|
21209
20671
|
this.onDocViewSizeChanged.unsubscribe();
|
21210
20672
|
this.flushTask = null;
|
21211
20673
|
Object.keys(this).forEach(key => {
|
21212
|
-
if (this[key] instanceof Subject
|
20674
|
+
if (this[key] instanceof Subject) {
|
21213
20675
|
this[key].unsubscribe();
|
21214
20676
|
}
|
21215
20677
|
});
|
@@ -21315,7 +20777,7 @@ class DocEditor {
|
|
21315
20777
|
}
|
21316
20778
|
/**
|
21317
20779
|
* 设置段落样式
|
21318
|
-
* @param
|
20780
|
+
* @param setterFunc
|
21319
20781
|
*/
|
21320
20782
|
setParaStyleByFn(setterFunc) {
|
21321
20783
|
DocumentChange.setParaStyle(this.selectionState, setterFunc);
|
@@ -21676,7 +21138,8 @@ class DocEditor {
|
|
21676
21138
|
styleModule,
|
21677
21139
|
classModule,
|
21678
21140
|
attributesModule,
|
21679
|
-
eventListenersModule
|
21141
|
+
eventListenersModule,
|
21142
|
+
datasetModule
|
21680
21143
|
]);
|
21681
21144
|
setActiveEditorContext(this);
|
21682
21145
|
const vNodeFunc = this.renderRoot();
|
@@ -21741,6 +21204,7 @@ class DocEditor {
|
|
21741
21204
|
children.push(tipsContainer);
|
21742
21205
|
children.push(...vNode);
|
21743
21206
|
tipsContainer.children?.push(...svgGenerator.changeTips);
|
21207
|
+
this.updateTipLayoutWidth();
|
21744
21208
|
const sub = this.afterNodePatch.subscribe(() => {
|
21745
21209
|
this.updateTipLayoutAfterPatch();
|
21746
21210
|
sub.unsubscribe();
|
@@ -21750,42 +21214,50 @@ class DocEditor {
|
|
21750
21214
|
};
|
21751
21215
|
}
|
21752
21216
|
/**
|
21753
|
-
*
|
21217
|
+
* 更新提示区域布局宽度,根据渲染的节点,判断是否需要设置提示区域宽度
|
21754
21218
|
* @private
|
21755
21219
|
*/
|
21756
|
-
|
21757
|
-
const
|
21758
|
-
if (!
|
21759
|
-
|
21760
|
-
|
21761
|
-
|
21762
|
-
|
21763
|
-
for (let i = 0; i < children.length; i++) {
|
21764
|
-
const item = children[i];
|
21765
|
-
const elm = item.elm;
|
21766
|
-
const topStr = elm.style.top;
|
21767
|
-
let topPixs = Number.parseInt(topStr.substring(0, topStr.length - 2));
|
21768
|
-
const rect = elm.getBoundingClientRect();
|
21769
|
-
if (topPixs + gap < prevPos.y) {
|
21770
|
-
topPixs = (prevPos.y + gap);
|
21771
|
-
elm.style.top = topPixs + 'px';
|
21220
|
+
updateTipLayoutWidth() {
|
21221
|
+
const tipChildren = this.tipContainer?.children;
|
21222
|
+
if (!tipChildren || !tipChildren.length) {
|
21223
|
+
if (this.viewOptions.reviewWindowWidth > 0) {
|
21224
|
+
this.viewOptions.reviewWindowWidth = 0;
|
21225
|
+
//刷新页面
|
21226
|
+
this.adjustPageLayout();
|
21772
21227
|
}
|
21773
|
-
|
21774
|
-
|
21228
|
+
}
|
21229
|
+
else {
|
21230
|
+
if (this.viewOptions.reviewWindowWidth === 0) {
|
21231
|
+
this.viewOptions.reviewWindowWidth = 250;
|
21232
|
+
//刷新页面
|
21233
|
+
this.adjustPageLayout();
|
21775
21234
|
}
|
21776
|
-
prevPos.y = topPixs + rect.height;
|
21777
21235
|
}
|
21778
21236
|
}
|
21237
|
+
/**
|
21238
|
+
* 更新留痕提示框位置在文档渲染后
|
21239
|
+
* @private
|
21240
|
+
*/
|
21241
|
+
updateTipLayoutAfterPatch() {
|
21242
|
+
const viewBoxRect = {
|
21243
|
+
x: this.viewOptions.pageOffset.x,
|
21244
|
+
y: this.viewOptions.pageOffset.y,
|
21245
|
+
width: this.viewOptions.viewSettings.width,
|
21246
|
+
height: this.viewOptions.viewSettings.height,
|
21247
|
+
scale: this.viewOptions.scale
|
21248
|
+
};
|
21249
|
+
adjustViewportElements(this.tipContainer, viewBoxRect);
|
21250
|
+
}
|
21779
21251
|
createChangeTipContainer() {
|
21780
21252
|
const docRect = this.documentPaginator.docContainer.getItems()[0].rect;
|
21781
|
-
|
21253
|
+
docRect.x + docRect.width + 20;
|
21782
21254
|
return {
|
21783
|
-
sel: 'div.
|
21255
|
+
sel: 'div.decorate-container',
|
21784
21256
|
data: {
|
21785
|
-
|
21786
|
-
|
21787
|
-
|
21788
|
-
|
21257
|
+
/* style: {
|
21258
|
+
left: x + 'px',
|
21259
|
+
top: '0px',
|
21260
|
+
}*/
|
21789
21261
|
},
|
21790
21262
|
children: []
|
21791
21263
|
};
|
@@ -21866,7 +21338,6 @@ class DocEditor {
|
|
21866
21338
|
},
|
21867
21339
|
on: {
|
21868
21340
|
click: (evt) => {
|
21869
|
-
console.log('dd');
|
21870
21341
|
onChangeHandler(item.code);
|
21871
21342
|
}
|
21872
21343
|
}
|
@@ -22034,7 +21505,7 @@ class DocEditor {
|
|
22034
21505
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
22035
21506
|
}
|
22036
21507
|
version() {
|
22037
|
-
return "2.
|
21508
|
+
return "2.2.0";
|
22038
21509
|
}
|
22039
21510
|
switchPageHeaderEditor() {
|
22040
21511
|
this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
|
@@ -22114,6 +21585,36 @@ class DocEditor {
|
|
22114
21585
|
])
|
22115
21586
|
]);
|
22116
21587
|
}
|
21588
|
+
readDocChangeLog() {
|
21589
|
+
//获取文档的变更日志
|
21590
|
+
const ops = generatePatch(this.docCtx.document, false);
|
21591
|
+
for (let i = 0; i < ops.length; i++) {
|
21592
|
+
const op = ops[i];
|
21593
|
+
if ('delete' in op.ops) {
|
21594
|
+
const delItem = op.ops.delete;
|
21595
|
+
//获取删除的批注元素
|
21596
|
+
const getDelCommItems = ElementUtil.getMatchItems(delItem, (item) => item instanceof CommentElement);
|
21597
|
+
const maps = {};
|
21598
|
+
getDelCommItems.forEach(item => {
|
21599
|
+
let num = maps[item.props.id];
|
21600
|
+
if (num === undefined) {
|
21601
|
+
maps[item.props.id] = 1;
|
21602
|
+
}
|
21603
|
+
else {
|
21604
|
+
maps[item.props.id] = num + 1;
|
21605
|
+
}
|
21606
|
+
});
|
21607
|
+
//获取需要删除的批注元素
|
21608
|
+
const keys = Object.keys(maps).filter(key => maps[key] === 1);
|
21609
|
+
if (keys.length) {
|
21610
|
+
const commItems = this.docCtx.document.treeFilter(item => item instanceof CommentElement);
|
21611
|
+
const delCommItems = commItems.filter(item => keys.includes(item.props.id));
|
21612
|
+
delCommItems.forEach(item => item.remove());
|
21613
|
+
return true;
|
21614
|
+
}
|
21615
|
+
}
|
21616
|
+
}
|
21617
|
+
}
|
22117
21618
|
}
|
22118
21619
|
|
22119
21620
|
/**
|
@@ -27211,10 +26712,10 @@ class DocumentPrintOffscreenBase {
|
|
27211
26712
|
docCtx;
|
27212
26713
|
renderCtx;
|
27213
26714
|
elementReader;
|
27214
|
-
beforeRenderEvent = new Subject
|
27215
|
-
afterRenderEvent = new Subject
|
27216
|
-
beforePrint = new Subject
|
27217
|
-
afterPrint = new Subject
|
26715
|
+
beforeRenderEvent = new Subject();
|
26716
|
+
afterRenderEvent = new Subject();
|
26717
|
+
beforePrint = new Subject();
|
26718
|
+
afterPrint = new Subject();
|
27218
26719
|
constructor() {
|
27219
26720
|
this.viewOptions = new ViewOptions();
|
27220
26721
|
this.viewOptions.copyRightInfo = '万达信息电子病历编辑器,www.wondersgroup.com';
|
@@ -27500,5 +27001,5 @@ function removeDuplicatesEvent(events) {
|
|
27500
27001
|
return arr;
|
27501
27002
|
}
|
27502
27003
|
|
27503
|
-
export { BlockContainerElement, BlockContainerRenderObject, BlockContentElement, BlockContentRenderObject, BlockLineRectRenderObject, BodyPartProps, BooleanEnum, BorderProps, BranchElement, BranchRenderObject, BreakElement, BreakFactory, BreakRenderObject, CheckBoxElement, CheckBoxFactory, CheckBoxProps, CheckBoxRenderObject, ColumnPatchUtil, CommContentBaseElement, CommContentBaseRenderObject, CommContentElement, CommContentProps, CommContentRenderObject, CommProps, CommentContentFactory, CommentElement, CommentFactory, CommentRenderObject, CommentsFactory,
|
27004
|
+
export { BlockContainerElement, BlockContainerRenderObject, BlockContentElement, BlockContentRenderObject, BlockLineRectRenderObject, BodyPartProps, BooleanEnum, BorderProps, BranchElement, BranchRenderObject, BreakElement, BreakFactory, BreakRenderObject, CheckBoxElement, CheckBoxFactory, CheckBoxProps, CheckBoxRenderObject, ColumnPatchUtil, CommContentBaseElement, CommContentBaseRenderObject, CommContentElement, CommContentProps, CommContentRenderObject, CommProps, CommentContentFactory, CommentElement, CommentFactory, CommentRenderObject, CommentsFactory, CommonUtil, CommsContainerElement, CommsContainerRenderObject, ContentMenuItem, ContextMenuElementEvent, CopyElementEvent, DOMEventSource, DOMSubscription, DataDecorateElement, DataDecorateProps, DataDecorateRenderObject, DataEleBaseProps, DataEleBaseTextProps, DataEleCheckProps, DataEleDateProps, DataEleImageProps, DataEleListProps, DataEleMHProps, DataElementBarcode, DataElementBarcodeFactory, DataElementBarcodeProps, DataElementBarcodeRenderObject, DataElementBaseFactory, DataElementCheck, DataElementCheckFactory, DataElementCheckRenderObject, DataElementDate, DataElementDateFactory, DataElementDateRenderObject, DataElementGroupElement, DataElementGroupFactory, DataElementGroupProps, DataElementGroupRenderObject, DataElementImage, DataElementImgFactory, DataElementInlineGroup, DataElementLeaf, DataElementList, DataElementListFactory, DataElementListRenderObject, DataElementMH, DataElementMHFactory, DataElementRenderObject, DataElementText, DataElementTextFactory, DataElementTextRenderObject, DataImageRenderObject, DataRenderMH, DocEditor, DocMode, DocumentBodyElement, DocumentBodyFactory, DocumentBodyPartElement, DocumentBodyPartFactory, DocumentBodyPartRenderObject, DocumentBodyRenderObject, DocumentChange, DocumentCombine, DocumentComment, DocumentContainerRender, DocumentContext, DocumentCursor, DocumentElement, DocumentEvalFunc, DocumentEvent, DocumentFactory, DocumentFooterElement, DocumentFooterFactory, DocumentFooterRenderObject, DocumentHeaderElement, DocumentHeaderFactory, DocumentHeaderRenderObject, DocumentInput, DocumentPaginator, DocumentPrintOffscreen, DocumentPrintOffscreenBase, DocumentProps, DocumentRenderObject, DocumentSelection, DocumentTemplate, DropElementEvent, EditMode, EditorContext, Element, ElementEvent, ElementFactory, ElementReader, ElementSerialize, ElementUtil, EventBus, EventMap, EventSourceCore, FillNullSpaceElement, FillNullSpaceRenderObject, GetTrackTipsEvent, GotCursorEvent, IDispose, INotifyPropertyChanged, InlineBlockContainer, InlineGroupElement, InlineGroupInputElement, InlineGroupRenderObject, InlineMuiltBlockLineRenderObject, InputElementEvent, IsInSideDataElement, IsInSideInlineGroupInputElement, KeyboradElementEvent, LeafElement, LeafRenderObject, LostCursorEvent, MarginProps, ModifyFlag, MouseElementEvent, MousedownElementEvent, MuiltBlockLineRenderObject, OnceSubject, PSymbolElement, PSymbolRenderObject, PaddingProps, PageBreakElement, PageBreakFactory, PageBreakRenderObject, PageOptions, PaintContent, ParagraphElement, ParagraphFactory, ParagraphLineRectRenderObject, ParagraphNumberType, ParagraphProps, ParagraphRenderObject, PasteElementEvent, PermanentTeethElement, PermanentTeethFactory, PermanentTeethProps, PermanentTeethRenderObject, PictureElement, PictureFactory, PictureProps, PictureRenderObject, RadioBoxElement, RadioBoxFactory, RadioBoxProps, RadioBoxRenderObject, RangeUtil, Rect, RenderContext, RenderObject, RenderObjectType, ResizeLeafRenderObject, RowMinHeight, RunElementFactory, SVGElement, SVGFactory, SVGProps, SVGRenderObject, SelectionOverlays, SelectionRange, SelectionState, Subject, SubjectSubscription, Subscription, TabElement, TabFactory, TabRenderObject, TableCellElement, TableCellFactory, TableCellProps, TableCellRenderObject, TableElement, TableFactory, TableProps, TableRenderObject, TableRowElement, TableRowFactory, TableRowProps, TableRowRenderObject, TableSplitCell, TableUtil, TextGroupElement, TextGroupFactory, TextGroupRenderObject, TextProps, TextUnitsHolder, TrackRunElement, TrackRunProps, TrackRunRenderObject, TrackRunTypeEnum, ValidateCondition, ValidateElement, ValidateProps, ValidateRenderObject, ViewOptions, addReturn, clearChildrenRenderCache, clearTraces, cloneChildren, cloneElementBase, defaultParaHanging, deleteCurrentParagraph, docOpsMap, elementTypeEventHandler, exportDecoratorHTML, falseChar, fontMapFunc, formatEle, fromEvent, generatePatch, getCalleeName, getFocusTextSegment, inputText, insertEle, invokeTypeHandler, isDate, logUpdateEleProps, objectToString$4 as objectToString, onTableContextmenu, onceTask, parser, reactiveMap, removeEle, removeText, runTextLineRender, setChildrenModifyFlag, setDataElementProps, setNotifyChangedCallback, setTraceTrackingFlag, suppressTracking, targetMaps, textLineRenderMode, toRawType, toTypeString, trueChar, validateDataEle, validateDataEleRenderObj, validateInlineInputRenderObj, watchChanged };
|
27504
27005
|
//# sourceMappingURL=index.js.map
|