@hailin-zheng/editor-core 2.1.17 → 2.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index-cjs.d.ts +0 -1
- package/index-cjs.js +698 -574
- package/index-cjs.js.map +1 -1
- package/index.d.ts +0 -1
- package/index.js +698 -573
- package/index.js.map +1 -1
- package/med_editor/doc-editor.d.ts +3 -1
- package/med_editor/editor-core.d.ts +4 -0
- package/med_editor/framework/common-util.d.ts +1 -0
- package/med_editor/framework/document-arrange.d.ts +9 -4
- package/med_editor/framework/document-context.d.ts +0 -8
- package/med_editor/framework/document-paint.d.ts +3 -3
- package/med_editor/framework/document-print-offscreen.d.ts +4 -4
- package/med_editor/framework/document-svg.d.ts +10 -4
- package/med_editor/framework/element-define.d.ts +1 -3
- package/med_editor/framework/element-props.d.ts +15 -1
- package/med_editor/framework/element-reader.d.ts +6 -1
- package/med_editor/framework/element-render-cut.d.ts +7 -5
- package/med_editor/framework/element-util.d.ts +1 -1
- package/med_editor/framework/event-subject.d.ts +9 -0
- package/med_editor/framework/impl/comments/comment-element-impl.d.ts +7 -0
- package/med_editor/framework/impl/comments/comments-container-impl.d.ts +2 -22
- package/med_editor/framework/impl/data-element/data-element-image-impl.d.ts +0 -2
- package/med_editor/framework/impl/document/doc-impl.d.ts +20 -2
- package/med_editor/framework/impl/picture/image-impl.d.ts +0 -2
- package/med_editor/framework/impl/table/table-row-impl.d.ts +2 -0
- package/med_editor/framework/range-util.d.ts +1 -1
- package/med_editor/framework/render-define.d.ts +1 -1
- package/med_editor/framework/selection-overlays.d.ts +4 -2
- package/package.json +1 -1
- package/med_editor/framework/document-images-loader.d.ts +0 -20
package/index.js
CHANGED
@@ -553,6 +553,16 @@ class CommonUtil {
|
|
553
553
|
}
|
554
554
|
return str;
|
555
555
|
}
|
556
|
+
//随机生成rgb颜色
|
557
|
+
static randomRgbColor(opacity = -1) {
|
558
|
+
let r = Math.floor(Math.random() * 256); //随机生成256以内r值
|
559
|
+
let g = Math.floor(Math.random() * 256); //随机生成256以内g值
|
560
|
+
let b = Math.floor(Math.random() * 256); //随机生成256以内b值
|
561
|
+
if (opacity === -1) {
|
562
|
+
return `rgb(${r},${g},${b})`; //返回rgb(r,g,b)格式颜色
|
563
|
+
}
|
564
|
+
return `rgba(${r},${g},${b},${opacity})`; //返回rgba(r,g,b,a)格式颜色
|
565
|
+
}
|
556
566
|
/**
|
557
567
|
* 判断一个数值是否在另一个数值的增益区间中
|
558
568
|
* @param val
|
@@ -1072,6 +1082,40 @@ class SubjectSubscription$1 extends Subscription$1 {
|
|
1072
1082
|
function fromEvent(dom, type) {
|
1073
1083
|
return new DOMEventSource(dom, type);
|
1074
1084
|
}
|
1085
|
+
class EventBus {
|
1086
|
+
subs = new Map();
|
1087
|
+
on(event, handler) {
|
1088
|
+
let handlers = this.subs.get(event);
|
1089
|
+
if (!handlers) {
|
1090
|
+
handlers = [];
|
1091
|
+
this.subs.set(event, handlers);
|
1092
|
+
}
|
1093
|
+
const sub = new Subject$1();
|
1094
|
+
sub.subscribe(handler);
|
1095
|
+
handlers.push(sub);
|
1096
|
+
}
|
1097
|
+
off(event) {
|
1098
|
+
const subs = this.subs.get(event);
|
1099
|
+
if (subs) {
|
1100
|
+
subs.forEach(item => item.unsubscribe());
|
1101
|
+
}
|
1102
|
+
this.subs.delete(event);
|
1103
|
+
}
|
1104
|
+
emit(event, data) {
|
1105
|
+
const subs = this.subs.get(event);
|
1106
|
+
if (subs) {
|
1107
|
+
subs.forEach(item => item.next(data));
|
1108
|
+
}
|
1109
|
+
}
|
1110
|
+
clear() {
|
1111
|
+
this.subs.forEach((subs) => {
|
1112
|
+
subs.forEach((sub) => {
|
1113
|
+
sub.unsubscribe();
|
1114
|
+
});
|
1115
|
+
});
|
1116
|
+
this.subs.clear();
|
1117
|
+
}
|
1118
|
+
}
|
1075
1119
|
|
1076
1120
|
class Rect {
|
1077
1121
|
x = 0;
|
@@ -1676,17 +1720,7 @@ class ViewOptions {
|
|
1676
1720
|
//两个页的间距
|
1677
1721
|
docSpace = 0;
|
1678
1722
|
//是否显示审阅窗口
|
1679
|
-
|
1680
|
-
get showReviewWindow() {
|
1681
|
-
return this._showReviewWindow;
|
1682
|
-
}
|
1683
|
-
set showReviewWindow(value) {
|
1684
|
-
if (value === this._showReviewWindow) {
|
1685
|
-
return;
|
1686
|
-
}
|
1687
|
-
this._showReviewWindow = value;
|
1688
|
-
// this.onChange.next();
|
1689
|
-
}
|
1723
|
+
showReviewWindow = false;
|
1690
1724
|
//审阅窗口宽度
|
1691
1725
|
reviewWindowWidth = 200;
|
1692
1726
|
//缩放
|
@@ -2371,32 +2405,47 @@ class CommContentProps extends INotifyPropertyChanged {
|
|
2371
2405
|
createId;
|
2372
2406
|
createName;
|
2373
2407
|
createDate;
|
2408
|
+
text;
|
2374
2409
|
clone(dest) {
|
2375
2410
|
const clone = dest ?? new CommContentProps();
|
2376
2411
|
super.cloneAttachedProperty(clone);
|
2377
2412
|
clone.id = this.id;
|
2413
|
+
clone.text = this.text;
|
2378
2414
|
return clone;
|
2379
2415
|
}
|
2380
2416
|
getSerializeProps(viewOptions) {
|
2381
2417
|
return {
|
2382
|
-
id: this.id
|
2418
|
+
id: this.id,
|
2419
|
+
text: this.text
|
2383
2420
|
};
|
2384
2421
|
}
|
2385
2422
|
}
|
2386
2423
|
class CommProps extends INotifyPropertyChanged {
|
2387
2424
|
id;
|
2388
2425
|
markType;
|
2426
|
+
text;
|
2427
|
+
userId;
|
2428
|
+
userName;
|
2429
|
+
date;
|
2389
2430
|
clone(dest) {
|
2390
2431
|
const clone = dest ?? new CommProps();
|
2391
2432
|
super.cloneAttachedProperty(clone);
|
2392
2433
|
clone.id = this.id;
|
2393
2434
|
clone.markType = this.markType;
|
2435
|
+
clone.text = this.text;
|
2436
|
+
clone.userId = this.userId;
|
2437
|
+
clone.userName = this.userName;
|
2438
|
+
clone.date = this.date;
|
2394
2439
|
return clone;
|
2395
2440
|
}
|
2396
2441
|
getSerializeProps(viewOptions) {
|
2397
2442
|
return {
|
2398
2443
|
id: this.id,
|
2399
|
-
markType: this.markType
|
2444
|
+
markType: this.markType,
|
2445
|
+
text: this.text,
|
2446
|
+
userId: this.userId,
|
2447
|
+
userName: this.userName,
|
2448
|
+
date: this.date
|
2400
2449
|
};
|
2401
2450
|
}
|
2402
2451
|
}
|
@@ -2724,63 +2773,6 @@ class CommsContainerElement extends BlockContainerElement {
|
|
2724
2773
|
}
|
2725
2774
|
return clone;
|
2726
2775
|
}
|
2727
|
-
markPairs = [];
|
2728
|
-
/**
|
2729
|
-
* 清除所有的批注标识组合
|
2730
|
-
*/
|
2731
|
-
clearMarkItems() {
|
2732
|
-
this.markPairs.length = 0;
|
2733
|
-
}
|
2734
|
-
identifyCommMark(markElement) {
|
2735
|
-
const { id } = markElement.props;
|
2736
|
-
let matchItem = this.markPairs.find(item => item.id === id);
|
2737
|
-
if (!matchItem) {
|
2738
|
-
matchItem = { id };
|
2739
|
-
this.markPairs.push(matchItem);
|
2740
|
-
}
|
2741
|
-
matchItem[markElement.props.markType] = markElement;
|
2742
|
-
}
|
2743
|
-
/**
|
2744
|
-
* 根据id,移除批注标记以及批注内容
|
2745
|
-
* @param id
|
2746
|
-
*/
|
2747
|
-
removeCommMark(id) {
|
2748
|
-
const matchIndex = this.markPairs.findIndex(item => item.id === id);
|
2749
|
-
if (matchIndex >= 0) {
|
2750
|
-
const matchItem = this.markPairs[matchIndex];
|
2751
|
-
matchItem.start?.remove();
|
2752
|
-
matchItem.end?.remove();
|
2753
|
-
this.markPairs.splice(matchIndex, 1);
|
2754
|
-
}
|
2755
|
-
const commContent = this.getCommContent(id);
|
2756
|
-
if (commContent) {
|
2757
|
-
commContent.remove();
|
2758
|
-
}
|
2759
|
-
}
|
2760
|
-
/**
|
2761
|
-
* 清除所有批注
|
2762
|
-
*/
|
2763
|
-
clearAllComms() {
|
2764
|
-
for (let i = 0; i < this.markPairs.length; i++) {
|
2765
|
-
const { start, end } = this.markPairs[i];
|
2766
|
-
if (start) {
|
2767
|
-
start.remove();
|
2768
|
-
}
|
2769
|
-
if (end) {
|
2770
|
-
end.remove();
|
2771
|
-
}
|
2772
|
-
}
|
2773
|
-
this.clearItems();
|
2774
|
-
}
|
2775
|
-
getCommContent(id) {
|
2776
|
-
for (let i = 0; i < this.length; i++) {
|
2777
|
-
const commContent = this.getChild(i);
|
2778
|
-
if (commContent.props.id === id) {
|
2779
|
-
return commContent;
|
2780
|
-
}
|
2781
|
-
}
|
2782
|
-
return null;
|
2783
|
-
}
|
2784
2776
|
}
|
2785
2777
|
class CommsContainerRenderObject extends BlockContainerRenderObject {
|
2786
2778
|
//批注内容是否已经重组,只要重新绘制的时候组合一次即可
|
@@ -3242,7 +3234,7 @@ class DocumentElement extends BlockContainerElement {
|
|
3242
3234
|
bodyElement;
|
3243
3235
|
headerElement;
|
3244
3236
|
footerElement;
|
3245
|
-
commentsContainerElement;
|
3237
|
+
//commentsContainerElement!: CommsContainerElement;
|
3246
3238
|
headerEditState = false;
|
3247
3239
|
constructor() {
|
3248
3240
|
super('doc');
|
@@ -3320,6 +3312,49 @@ class DocumentElement extends BlockContainerElement {
|
|
3320
3312
|
ss.clear();
|
3321
3313
|
this.refreshView();
|
3322
3314
|
}
|
3315
|
+
markPairs = [];
|
3316
|
+
/**
|
3317
|
+
* 清除所有的批注标识组合
|
3318
|
+
*/
|
3319
|
+
clearMarkItems() {
|
3320
|
+
this.markPairs.length = 0;
|
3321
|
+
}
|
3322
|
+
identifyCommMark(markElement) {
|
3323
|
+
const { id } = markElement.props;
|
3324
|
+
let matchItem = this.markPairs.find(item => item.id === id);
|
3325
|
+
if (!matchItem) {
|
3326
|
+
matchItem = { id };
|
3327
|
+
this.markPairs.push(matchItem);
|
3328
|
+
}
|
3329
|
+
matchItem[markElement.props.markType] = markElement;
|
3330
|
+
}
|
3331
|
+
/**
|
3332
|
+
* 根据id,移除批注标记以及批注内容
|
3333
|
+
* @param id
|
3334
|
+
*/
|
3335
|
+
removeCommMark(id) {
|
3336
|
+
const matchIndex = this.markPairs.findIndex(item => item.id === id);
|
3337
|
+
if (matchIndex >= 0) {
|
3338
|
+
const matchItem = this.markPairs[matchIndex];
|
3339
|
+
matchItem.start?.remove();
|
3340
|
+
matchItem.end?.remove();
|
3341
|
+
this.markPairs.splice(matchIndex, 1);
|
3342
|
+
}
|
3343
|
+
}
|
3344
|
+
/**
|
3345
|
+
* 清除所有批注
|
3346
|
+
*/
|
3347
|
+
clearAllComms() {
|
3348
|
+
for (let i = 0; i < this.markPairs.length; i++) {
|
3349
|
+
const { start, end } = this.markPairs[i];
|
3350
|
+
if (start) {
|
3351
|
+
start.remove();
|
3352
|
+
}
|
3353
|
+
if (end) {
|
3354
|
+
end.remove();
|
3355
|
+
}
|
3356
|
+
}
|
3357
|
+
}
|
3323
3358
|
}
|
3324
3359
|
class DocumentRenderObject extends BlockContainerRenderObject {
|
3325
3360
|
constructor(ele) {
|
@@ -4674,10 +4709,16 @@ class TableRowElement extends BlockContainerElement {
|
|
4674
4709
|
}
|
4675
4710
|
}
|
4676
4711
|
class TableRowRenderObject extends MuiltBlockLineRenderObject {
|
4712
|
+
//被截断的行是否需要重新计算高度
|
4713
|
+
remeasureState = true;
|
4714
|
+
//当前行是否存在合并单元格
|
4715
|
+
hasMergeCells = undefined;
|
4677
4716
|
render(e) {
|
4678
4717
|
}
|
4679
4718
|
clone() {
|
4680
4719
|
const cloneRender = new TableRowRenderObject(this.element);
|
4720
|
+
cloneRender.remeasureState = this.remeasureState;
|
4721
|
+
cloneRender.hasMergeCells = this.hasMergeCells;
|
4681
4722
|
cloneRender.rect = ElementUtil.cloneRect(this.rect);
|
4682
4723
|
for (let i = 0; i < this.length; i++) {
|
4683
4724
|
cloneRender.addChild(this.getChild(i).clone());
|
@@ -5310,7 +5351,7 @@ class DocumentCursor {
|
|
5310
5351
|
}
|
5311
5352
|
|
5312
5353
|
class RangeUtil {
|
5313
|
-
static
|
5354
|
+
static getSectionRange(startControl, startOffset, endControl, endOffset, ancestorCommonControl) {
|
5314
5355
|
if (ancestorCommonControl instanceof TableElement || ancestorCommonControl instanceof TableRowElement) {
|
5315
5356
|
const tbElement = ancestorCommonControl instanceof TableElement ? ancestorCommonControl : ancestorCommonControl.parent;
|
5316
5357
|
return this.getTableSelectionRange(startControl, startOffset, endControl, endOffset, tbElement);
|
@@ -5389,7 +5430,7 @@ class RangeUtil {
|
|
5389
5430
|
});
|
5390
5431
|
}
|
5391
5432
|
else {
|
5392
|
-
const cellRange = this.
|
5433
|
+
const cellRange = this.getSectionRange(cellFirstLeafElement, 0, cellLastLeafElement, 1, cell);
|
5393
5434
|
cellRanges.push(cellRange);
|
5394
5435
|
}
|
5395
5436
|
}
|
@@ -7228,12 +7269,42 @@ class CommentsUtil {
|
|
7228
7269
|
}
|
7229
7270
|
}
|
7230
7271
|
|
7272
|
+
let activeEditorContext = null;
|
7273
|
+
function setActiveEditorContext(ctx) {
|
7274
|
+
activeEditorContext = ctx;
|
7275
|
+
}
|
7276
|
+
function getActiveEditorContext() {
|
7277
|
+
return activeEditorContext;
|
7278
|
+
}
|
7279
|
+
function createSignal(state) {
|
7280
|
+
let _state = state;
|
7281
|
+
const activeCtx = activeEditorContext;
|
7282
|
+
const signal = {
|
7283
|
+
get value() {
|
7284
|
+
return _state;
|
7285
|
+
},
|
7286
|
+
set value(v) {
|
7287
|
+
if (v === _state) {
|
7288
|
+
return;
|
7289
|
+
}
|
7290
|
+
_state = v;
|
7291
|
+
signal.onChange();
|
7292
|
+
},
|
7293
|
+
onChange: () => {
|
7294
|
+
activeCtx?.onChange();
|
7295
|
+
}
|
7296
|
+
};
|
7297
|
+
return signal;
|
7298
|
+
}
|
7299
|
+
|
7231
7300
|
class CommentElement extends LeafElement {
|
7301
|
+
color;
|
7232
7302
|
constructor() {
|
7233
7303
|
super('comm');
|
7234
7304
|
this.isDecorate = true;
|
7235
7305
|
this.disableClick = true;
|
7236
7306
|
this.props = new CommProps();
|
7307
|
+
this.color = CommonUtil.randomRgbColor(0.5);
|
7237
7308
|
}
|
7238
7309
|
createRenderObject() {
|
7239
7310
|
const render = new CommentRenderObject(this);
|
@@ -7286,6 +7357,7 @@ class CommentRenderObject extends LeafRenderObject {
|
|
7286
7357
|
}
|
7287
7358
|
}
|
7288
7359
|
}];
|
7360
|
+
this.createCommentTips(event);
|
7289
7361
|
return t;
|
7290
7362
|
}
|
7291
7363
|
clone() {
|
@@ -7293,6 +7365,90 @@ class CommentRenderObject extends LeafRenderObject {
|
|
7293
7365
|
clone.rect = ElementUtil.cloneRect(this.rect);
|
7294
7366
|
return clone;
|
7295
7367
|
}
|
7368
|
+
createCommentTips(event) {
|
7369
|
+
if (this.element.props.markType === 'end') {
|
7370
|
+
return;
|
7371
|
+
}
|
7372
|
+
if (this.element.paintRenders.indexOf(this) !== 0) {
|
7373
|
+
return;
|
7374
|
+
}
|
7375
|
+
const appCtx = getActiveEditorContext();
|
7376
|
+
const opType = '批注:';
|
7377
|
+
const content = this.element.props.text;
|
7378
|
+
const left = 5;
|
7379
|
+
let sel = 'div.tg-container';
|
7380
|
+
const node = {
|
7381
|
+
sel,
|
7382
|
+
key: this.element.props.id,
|
7383
|
+
data: {
|
7384
|
+
style: {
|
7385
|
+
left: `${left}px`,
|
7386
|
+
top: `${event.globalPos.y}px`
|
7387
|
+
},
|
7388
|
+
on: {
|
7389
|
+
click: (e) => {
|
7390
|
+
e.stopPropagation();
|
7391
|
+
appCtx?.emit('comment-click', {
|
7392
|
+
...this.element.props
|
7393
|
+
});
|
7394
|
+
//this.showCommentRange(appCtx!);
|
7395
|
+
},
|
7396
|
+
dblclick: (e) => {
|
7397
|
+
e.stopPropagation();
|
7398
|
+
appCtx?.emit('comment-dblclick', {
|
7399
|
+
...this.element.props
|
7400
|
+
});
|
7401
|
+
}
|
7402
|
+
}
|
7403
|
+
},
|
7404
|
+
children: [{
|
7405
|
+
sel: 'div.header',
|
7406
|
+
data: {},
|
7407
|
+
children: [{
|
7408
|
+
sel: 'span.header-user',
|
7409
|
+
data: {},
|
7410
|
+
text: this.element.props.userName,
|
7411
|
+
}, {
|
7412
|
+
sel: 'span.header-date',
|
7413
|
+
data: {},
|
7414
|
+
text: this.element.props.date,
|
7415
|
+
}]
|
7416
|
+
}, {
|
7417
|
+
sel: 'div.content',
|
7418
|
+
data: {},
|
7419
|
+
text: opType + content
|
7420
|
+
}, {
|
7421
|
+
sel: 'div.bg',
|
7422
|
+
data: {
|
7423
|
+
style: {
|
7424
|
+
background: this.element.color
|
7425
|
+
}
|
7426
|
+
}
|
7427
|
+
}]
|
7428
|
+
};
|
7429
|
+
event.addChangeTips(node);
|
7430
|
+
// <div class="container">
|
7431
|
+
// <div class="header">
|
7432
|
+
// <span class="header-user">张三</span>
|
7433
|
+
// <span class="header-date">2023.1.21 16:06</span>
|
7434
|
+
// </div>
|
7435
|
+
// <div class="content">修改了字符串</div>
|
7436
|
+
// </div>
|
7437
|
+
}
|
7438
|
+
/**
|
7439
|
+
* 显示批注范围
|
7440
|
+
* @private
|
7441
|
+
*/
|
7442
|
+
showCommentRange(appCtx) {
|
7443
|
+
const doc = ElementUtil.getParent(this.element, (item) => item.type === 'doc');
|
7444
|
+
const commPair = doc.treeFilter(item => item instanceof CommentElement && item.props.id === this.element.props.id);
|
7445
|
+
if (commPair.length === 2) {
|
7446
|
+
const range = new SelectionRange();
|
7447
|
+
range.setStart(commPair[0], 0);
|
7448
|
+
range.setEnd(commPair[1], 1);
|
7449
|
+
appCtx.selectionState.addRange(range);
|
7450
|
+
}
|
7451
|
+
}
|
7296
7452
|
}
|
7297
7453
|
class CommentFactory extends ElementFactory {
|
7298
7454
|
match(type) {
|
@@ -7303,6 +7459,7 @@ class CommentFactory extends ElementFactory {
|
|
7303
7459
|
const props = data.props;
|
7304
7460
|
ele.props.id = props.id;
|
7305
7461
|
ele.props.markType = props.markType;
|
7462
|
+
ele.props.text = props.text;
|
7306
7463
|
return ele;
|
7307
7464
|
}
|
7308
7465
|
}
|
@@ -8866,18 +9023,6 @@ class DataElementImage extends DataElementLeaf {
|
|
8866
9023
|
this.props.clone(clone.props);
|
8867
9024
|
return clone;
|
8868
9025
|
}
|
8869
|
-
loadImage(ctx) {
|
8870
|
-
if (this.status === 'no') {
|
8871
|
-
this.status = 'loading';
|
8872
|
-
const onCallback = (status) => {
|
8873
|
-
this.status = status;
|
8874
|
-
if (status === 'completed') {
|
8875
|
-
this.refreshView();
|
8876
|
-
}
|
8877
|
-
};
|
8878
|
-
ctx.imageLoader.loadImage(this.props.src, onCallback);
|
8879
|
-
}
|
8880
|
-
}
|
8881
9026
|
destroy() {
|
8882
9027
|
super.destroy();
|
8883
9028
|
}
|
@@ -8893,38 +9038,6 @@ class DataElementImage extends DataElementLeaf {
|
|
8893
9038
|
}
|
8894
9039
|
class DataImageRenderObject extends ResizeLeafRenderObject {
|
8895
9040
|
render(e) {
|
8896
|
-
const { render, position, docCtx } = e;
|
8897
|
-
const dataImgElement = this.element;
|
8898
|
-
const picProps = dataImgElement.props;
|
8899
|
-
if (dataImgElement.status === 'no') {
|
8900
|
-
dataImgElement.loadImage(docCtx);
|
8901
|
-
return;
|
8902
|
-
}
|
8903
|
-
if (dataImgElement.status === 'completed') {
|
8904
|
-
const imageSource = docCtx.imageLoader.getImage(picProps.src);
|
8905
|
-
if (!imageSource) {
|
8906
|
-
return;
|
8907
|
-
}
|
8908
|
-
if (picProps.border === 'all') {
|
8909
|
-
render.contentContext.strokeRect(position.x, position.y, this.rect.width, this.rect.height, 'black');
|
8910
|
-
}
|
8911
|
-
render.contentContext.ctx.drawImage(imageSource, 0, 0, imageSource.naturalWidth, imageSource.naturalHeight, position.x + 2, position.y + 2, picProps.width, picProps.height);
|
8912
|
-
}
|
8913
|
-
if (render.drawMode === 'view') {
|
8914
|
-
let { x, y } = position;
|
8915
|
-
const { width, height } = this.rect;
|
8916
|
-
const lineWidth = 5;
|
8917
|
-
const paintColor = '#0050b3';
|
8918
|
-
render.contentContext.strokeLines([{ x: x + lineWidth, y }, { x, y }, { x, y: y + height }, {
|
8919
|
-
x: x + lineWidth,
|
8920
|
-
y: y + height
|
8921
|
-
}], 1, paintColor);
|
8922
|
-
x = x + width;
|
8923
|
-
render.contentContext.strokeLines([{ x: x - lineWidth, y }, { x, y }, { x, y: y + height }, {
|
8924
|
-
x: x - lineWidth,
|
8925
|
-
y: y + height
|
8926
|
-
}], 1, paintColor);
|
8927
|
-
}
|
8928
9041
|
}
|
8929
9042
|
clone() {
|
8930
9043
|
const clone = new DataImageRenderObject(this.element);
|
@@ -9801,51 +9914,12 @@ class PictureElement extends LeafElement {
|
|
9801
9914
|
this.props.clone(clone.props);
|
9802
9915
|
return clone;
|
9803
9916
|
}
|
9804
|
-
loadImage(ctx) {
|
9805
|
-
if (this.status === 'no') {
|
9806
|
-
this.status = 'loading';
|
9807
|
-
//this.imageSource = new Image();
|
9808
|
-
//this.imageSource.src = this.props.src;
|
9809
|
-
// const onload = (e: any) => {
|
9810
|
-
// this.isLoad = 'completed';
|
9811
|
-
// this.refreshView('appearance');
|
9812
|
-
// };
|
9813
|
-
// const onerror = (e: any) => {
|
9814
|
-
// this.isLoad = 'error';
|
9815
|
-
// console.error(e);
|
9816
|
-
// };
|
9817
|
-
const onCallback = (status) => {
|
9818
|
-
this.status = status;
|
9819
|
-
if (status === 'completed') {
|
9820
|
-
this.refreshView();
|
9821
|
-
}
|
9822
|
-
};
|
9823
|
-
ctx.imageLoader.loadImage(this.props.src, onCallback);
|
9824
|
-
}
|
9825
|
-
}
|
9826
9917
|
destroy() {
|
9827
9918
|
super.destroy();
|
9828
9919
|
}
|
9829
9920
|
}
|
9830
9921
|
class PictureRenderObject extends ResizeLeafRenderObject {
|
9831
9922
|
render(e) {
|
9832
|
-
const { render, position, docCtx } = e;
|
9833
|
-
const picElement = this.element;
|
9834
|
-
const picProps = picElement.props;
|
9835
|
-
if (picElement.status === 'no') {
|
9836
|
-
picElement.loadImage(docCtx);
|
9837
|
-
return;
|
9838
|
-
}
|
9839
|
-
if (picElement.status === 'completed') {
|
9840
|
-
const imageSource = docCtx.imageLoader.getImage(picProps.src);
|
9841
|
-
if (!imageSource) {
|
9842
|
-
return;
|
9843
|
-
}
|
9844
|
-
if (picProps.border === 'all') {
|
9845
|
-
render.contentContext.strokeRect(position.x, position.y, this.rect.width, this.rect.height, 'black');
|
9846
|
-
}
|
9847
|
-
render.contentContext.ctx.drawImage(imageSource, 0, 0, imageSource.naturalWidth, imageSource.naturalHeight, position.x + 2, position.y + 2, picProps.width, picProps.height);
|
9848
|
-
}
|
9849
9923
|
}
|
9850
9924
|
clone() {
|
9851
9925
|
const clone = new PictureRenderObject(this.element);
|
@@ -11189,7 +11263,12 @@ class ElementUtil {
|
|
11189
11263
|
if (render instanceof TableRenderObject) {
|
11190
11264
|
//this.setTableAlign(render);
|
11191
11265
|
this.remeasureTableMerge(render);
|
11192
|
-
render.getItems().forEach(item =>
|
11266
|
+
render.getItems().forEach(item => {
|
11267
|
+
if (item.remeasureState) {
|
11268
|
+
this.remeasure(item, false);
|
11269
|
+
item.remeasureState = false;
|
11270
|
+
}
|
11271
|
+
}, null);
|
11193
11272
|
}
|
11194
11273
|
const innerRect = render.getInnerRect();
|
11195
11274
|
innerRect.height = 0;
|
@@ -11205,7 +11284,7 @@ class ElementUtil {
|
|
11205
11284
|
render.updateRenderHeight(innerRect);
|
11206
11285
|
return innerRect.height;
|
11207
11286
|
}
|
11208
|
-
static remeasureTableRow(rowRender,
|
11287
|
+
static remeasureTableRow(rowRender, forceColIndex = -1) {
|
11209
11288
|
const rowEle = rowRender.element;
|
11210
11289
|
let maxCellHeight = rowEle.props.minHeight > 20 ? rowEle.props.minHeight : 20;
|
11211
11290
|
//限制行最小高度
|
@@ -11214,7 +11293,7 @@ class ElementUtil {
|
|
11214
11293
|
for (let i = 0; i < rowRender.length; i++) {
|
11215
11294
|
const cellRender = rowRender.getChild(i);
|
11216
11295
|
const { vMerge } = cellRender.element.props;
|
11217
|
-
if (cellRender.rect.height > maxCellHeight && (vMerge !== 'restart' || i ===
|
11296
|
+
if (cellRender.rect.height > maxCellHeight && (vMerge !== 'restart' || i === forceColIndex)) {
|
11218
11297
|
maxCellHeight = cellRender.rect.height;
|
11219
11298
|
}
|
11220
11299
|
}
|
@@ -11223,7 +11302,7 @@ class ElementUtil {
|
|
11223
11302
|
const cellRender = rowRender.getChild(i);
|
11224
11303
|
const cellElement = cellRender.element;
|
11225
11304
|
const { vMerge } = cellElement.props;
|
11226
|
-
if ((vMerge !== 'restart' || i ===
|
11305
|
+
if ((vMerge !== 'restart' || i === forceColIndex) || cellRender.rect.height < maxCellHeight) {
|
11227
11306
|
cellRender.rect.height = maxCellHeight;
|
11228
11307
|
}
|
11229
11308
|
//处理单元格内容纵向居中
|
@@ -11318,11 +11397,16 @@ class ElementUtil {
|
|
11318
11397
|
let needReCalc = false;
|
11319
11398
|
for (let i = 0; i < tbRender.length; i++) {
|
11320
11399
|
const row = tbRender.getChild(i);
|
11400
|
+
if (row.hasMergeCells === false) {
|
11401
|
+
continue;
|
11402
|
+
}
|
11403
|
+
row.hasMergeCells = false;
|
11321
11404
|
for (let j = 0; j < row.length; j++) {
|
11322
11405
|
const cellRender = row.getChild(j);
|
11323
11406
|
const ele = cellRender.element;
|
11324
11407
|
const { vMerge } = ele.props;
|
11325
11408
|
if (vMerge === 'restart') {
|
11409
|
+
row.hasMergeCells = true;
|
11326
11410
|
const eleIndex = ele.getIndex();
|
11327
11411
|
const continueRows = this.getContinueVMergeRenderRows(tbRender, i, eleIndex);
|
11328
11412
|
if (!continueRows.length) {
|
@@ -13252,29 +13336,29 @@ class ElementPaint {
|
|
13252
13336
|
this.renderCtx.contentContext.fillRect(currPosition.x, currPosition.y, renderObject.rect.width, renderObject.rect.height, this.viewOptions.selectionOverlaysColor);
|
13253
13337
|
}
|
13254
13338
|
}
|
13255
|
-
if (inViewPort && this.viewOptions.showReviewWindow && this.docCtx.document.commentsContainerElement.cacheRender.selectedSet.has(element)) {
|
13256
|
-
|
13257
|
-
|
13258
|
-
|
13259
|
-
|
13260
|
-
|
13261
|
-
|
13262
|
-
|
13263
|
-
|
13264
|
-
|
13265
|
-
|
13266
|
-
|
13267
|
-
|
13268
|
-
|
13269
|
-
|
13270
|
-
|
13271
|
-
|
13272
|
-
|
13273
|
-
|
13274
|
-
|
13275
|
-
|
13276
|
-
|
13277
|
-
}
|
13339
|
+
// if (inViewPort && this.viewOptions.showReviewWindow && (<CommsContainerRenderObject>this.docCtx.document.commentsContainerElement.cacheRender).selectedSet.has(element)) {
|
13340
|
+
// if (renderObject instanceof LeafRenderObject || renderObject instanceof DataElementRenderObject) {
|
13341
|
+
// const measureCommContainer=<CommsContainerRenderObject>this.docCtx.document.commentsContainerElement.cacheRender;
|
13342
|
+
// const range = measureCommContainer.selectedSet.get(element) as SelectionContentRange;
|
13343
|
+
// if (range.isFullSelected) {
|
13344
|
+
// let commentRangePaintColor = '#ffd591';
|
13345
|
+
// for (let i = 0; i < measureCommContainer.commentRangeStatus.length; i++) {
|
13346
|
+
// const commentRangeStatus = measureCommContainer.commentRangeStatus[i];
|
13347
|
+
// if (commentRangeStatus.commContent.focus) {
|
13348
|
+
// if (RangeUtil.checkElementFullInRange(commentRangeStatus.range, element)) {
|
13349
|
+
// commentRangePaintColor = '#fa8c16';
|
13350
|
+
// }
|
13351
|
+
// }
|
13352
|
+
// }
|
13353
|
+
// const overlayRect = { x: currPosition.x, y: currPosition.y, width: rw, height: rh };
|
13354
|
+
// const paraLinePos = ElementUtil.getParaLinePos(renderObject, {
|
13355
|
+
// x: currPosition.x,
|
13356
|
+
// y: currPosition.y
|
13357
|
+
// });
|
13358
|
+
// this.renderCtx.overlaysContext.fillRect(overlayRect.x, paraLinePos.y, overlayRect.width, paraLinePos.height, commentRangePaintColor);
|
13359
|
+
// }
|
13360
|
+
// }
|
13361
|
+
// }
|
13278
13362
|
}
|
13279
13363
|
/**
|
13280
13364
|
* 触发页面绘制结束事件
|
@@ -13320,125 +13404,6 @@ class ElementPaint {
|
|
13320
13404
|
}
|
13321
13405
|
}
|
13322
13406
|
|
13323
|
-
/**
|
13324
|
-
* 用于处理选区拖蓝
|
13325
|
-
*/
|
13326
|
-
class SelectionOverlays {
|
13327
|
-
selectionState;
|
13328
|
-
selectionRange;
|
13329
|
-
selectedSets = new Map();
|
13330
|
-
constructor(selectionState) {
|
13331
|
-
this.selectionState = selectionState;
|
13332
|
-
}
|
13333
|
-
getSelectionTreeData() {
|
13334
|
-
let { ancestorCommonControl, startControl, startOffset, endControl, endOffset, collapsed } = this.selectionState;
|
13335
|
-
this.selectedSets.clear();
|
13336
|
-
if (this.selectionRange) {
|
13337
|
-
this.selectionRange.selectedChildren.length = 0;
|
13338
|
-
}
|
13339
|
-
this.selectionRange = null;
|
13340
|
-
if (!startControl || !endControl || !ancestorCommonControl) {
|
13341
|
-
//this.selectionRange?.selectedChildren.length=0;
|
13342
|
-
this.selectionState.selectedRange = null;
|
13343
|
-
return;
|
13344
|
-
}
|
13345
|
-
if (collapsed) {
|
13346
|
-
const commonRange = RangeUtil.getSelctionRange(startControl, startOffset, endControl, endOffset, ancestorCommonControl);
|
13347
|
-
this.selectionState.selectedRange = commonRange;
|
13348
|
-
this.selectedSets.clear();
|
13349
|
-
return;
|
13350
|
-
}
|
13351
|
-
const fixStartElement = this.fixStartSelectionElement(startControl, startOffset, ancestorCommonControl);
|
13352
|
-
startControl = fixStartElement.element;
|
13353
|
-
startOffset = fixStartElement.offset;
|
13354
|
-
const fixEndElement = this.fixEndSelectionElement(endControl, endOffset, ancestorCommonControl);
|
13355
|
-
endControl = fixEndElement.element;
|
13356
|
-
endOffset = fixEndElement.offset;
|
13357
|
-
const commonRange = RangeUtil.getSelctionRange(startControl, startOffset, endControl, endOffset, ancestorCommonControl);
|
13358
|
-
//console.log(commonRange);
|
13359
|
-
this.selectionRange = commonRange;
|
13360
|
-
this.convertSelectRangeToSet();
|
13361
|
-
this.selectionState.selectedRange = commonRange;
|
13362
|
-
}
|
13363
|
-
convertSelectRangeToSet() {
|
13364
|
-
this.selectedSets.clear();
|
13365
|
-
if (this.selectionRange) {
|
13366
|
-
SelectionOverlays.addToSets(this.selectionRange, this.selectedSets);
|
13367
|
-
}
|
13368
|
-
}
|
13369
|
-
static addToSets(range, set) {
|
13370
|
-
set.set(range.target, range);
|
13371
|
-
for (let i = 0; i < range.selectedChildren.length; i++) {
|
13372
|
-
//单元格全部选中效果,单元格整个拖蓝即可
|
13373
|
-
if (range.isFullSelected && range.target.type === 'tbc') {
|
13374
|
-
continue;
|
13375
|
-
}
|
13376
|
-
this.addToSets(range.selectedChildren[i], set);
|
13377
|
-
}
|
13378
|
-
}
|
13379
|
-
/**
|
13380
|
-
* 添加到批注集合
|
13381
|
-
* @param range
|
13382
|
-
* @param set
|
13383
|
-
*/
|
13384
|
-
static addToCommentSets(range, set) {
|
13385
|
-
set.set(range.target, range);
|
13386
|
-
for (let i = 0; i < range.selectedChildren.length; i++) {
|
13387
|
-
this.addToCommentSets(range.selectedChildren[i], set);
|
13388
|
-
}
|
13389
|
-
}
|
13390
|
-
/**
|
13391
|
-
* 修正开始选区内容
|
13392
|
-
* 1.如果当前选区开始于表格内容,结束选区位于表格外,则需要开始选区内容重定位到单元格第一个元素
|
13393
|
-
*/
|
13394
|
-
fixStartSelectionElement(element, offset, ancestorCommonControl) {
|
13395
|
-
if (!(ancestorCommonControl instanceof TableElement)) {
|
13396
|
-
const lookupParentCell = ElementUtil.getParentByType(element, TableCellElement);
|
13397
|
-
if (lookupParentCell) {
|
13398
|
-
if (!lookupParentCell.parent || !lookupParentCell.parent.parent) ;
|
13399
|
-
const lookupParentTbIndex = ElementUtil.getControlIndex(lookupParentCell.parent.parent);
|
13400
|
-
const ancestorCommonControlIndex = ElementUtil.getControlIndex(ancestorCommonControl);
|
13401
|
-
if (ancestorCommonControlIndex < lookupParentTbIndex) {
|
13402
|
-
const rowFirstLeafElement = ElementUtil.getFirstLeafElement(lookupParentCell.parent);
|
13403
|
-
if (!rowFirstLeafElement) {
|
13404
|
-
throw new Error('当前元素处于表格内元素,未能定位到当前单元格首个元素');
|
13405
|
-
}
|
13406
|
-
return {
|
13407
|
-
element: rowFirstLeafElement,
|
13408
|
-
offset: 0
|
13409
|
-
};
|
13410
|
-
}
|
13411
|
-
}
|
13412
|
-
}
|
13413
|
-
return { element, offset };
|
13414
|
-
}
|
13415
|
-
/**
|
13416
|
-
* 修正开始选区内容
|
13417
|
-
* 1.如果当前选区开始于表格内容,结束选区位于表格外,则需要开始选区内容重定位到单元格第一个元素
|
13418
|
-
*/
|
13419
|
-
fixEndSelectionElement(element, offset, ancestorCommonControl) {
|
13420
|
-
if (!(ancestorCommonControl instanceof TableElement)) {
|
13421
|
-
const lookupParentCell = ElementUtil.getParentByType(element, TableCellElement);
|
13422
|
-
if (lookupParentCell) {
|
13423
|
-
const lookupParentTbIndex = ElementUtil.getControlIndex(lookupParentCell.parent.parent);
|
13424
|
-
const ancestorCommonControlIndex = ElementUtil.getControlIndex(ancestorCommonControl);
|
13425
|
-
if (ancestorCommonControlIndex < lookupParentTbIndex) {
|
13426
|
-
const rowLastLeafElement = ElementUtil.getLastLeafElement(lookupParentCell.parent);
|
13427
|
-
if (!rowLastLeafElement) {
|
13428
|
-
ElementUtil.getLastLeafElement(lookupParentCell.parent);
|
13429
|
-
throw new Error('当前元素处于表格内元素,未能定位到当前单元格首个元素');
|
13430
|
-
}
|
13431
|
-
return {
|
13432
|
-
element: rowLastLeafElement,
|
13433
|
-
offset: 1
|
13434
|
-
};
|
13435
|
-
}
|
13436
|
-
}
|
13437
|
-
}
|
13438
|
-
return { element, offset };
|
13439
|
-
}
|
13440
|
-
}
|
13441
|
-
|
13442
13407
|
class DocumentEvalFunc {
|
13443
13408
|
docCtx;
|
13444
13409
|
constructor(docCtx) {
|
@@ -13479,83 +13444,11 @@ class DocumentEvalFunc {
|
|
13479
13444
|
this.scriptsFunc = null;
|
13480
13445
|
}
|
13481
13446
|
}
|
13482
|
-
/**
|
13483
|
-
* 触发动态脚本
|
13484
|
-
*/
|
13485
|
-
invokedScripts() {
|
13486
|
-
this.scriptsFunc?.();
|
13487
|
-
}
|
13488
|
-
}
|
13489
|
-
|
13490
|
-
class DocumentImagesBaseLoader {
|
13491
|
-
images = [];
|
13492
|
-
clear() {
|
13493
|
-
this.images.length = 0;
|
13494
|
-
}
|
13495
|
-
loadImage(src, onCallback) {
|
13496
|
-
if (!src) {
|
13497
|
-
return;
|
13498
|
-
}
|
13499
|
-
//已经存在的资源不需要重新加载
|
13500
|
-
let matchItem = this.images.find(item => item.src === src);
|
13501
|
-
if (matchItem) {
|
13502
|
-
if (matchItem.loadStatus === 'no') {
|
13503
|
-
matchItem.cbs.push(onCallback);
|
13504
|
-
}
|
13505
|
-
else {
|
13506
|
-
onCallback(matchItem.loadStatus);
|
13507
|
-
}
|
13508
|
-
return;
|
13509
|
-
}
|
13510
|
-
const task = this.createRequestImage(src);
|
13511
|
-
const imgItem = {
|
13512
|
-
ele: undefined,
|
13513
|
-
src,
|
13514
|
-
cbs: [onCallback],
|
13515
|
-
loadStatus: 'no',
|
13516
|
-
task
|
13517
|
-
};
|
13518
|
-
this.images.push(imgItem);
|
13519
|
-
// if (this.viewOptions.resourceMode === 'immediate') {
|
13520
|
-
// ele.onload = (e) => { this.invokeImgLoad(src, 'completed'); };
|
13521
|
-
// ele.onerror = (e) => { this.invokeImgLoad(src, 'error'); };
|
13522
|
-
// }
|
13523
|
-
}
|
13524
|
-
invokeImgLoad(src, status, data) {
|
13525
|
-
const img = this.images.find(item => item.src === src);
|
13526
|
-
if (img) {
|
13527
|
-
img.loadStatus = status;
|
13528
|
-
img.cbs.forEach(cb => cb(status));
|
13529
|
-
img.ele = data;
|
13530
|
-
}
|
13531
|
-
}
|
13532
|
-
getLoadTasks() {
|
13533
|
-
return this.images.map(item => item.task);
|
13534
|
-
}
|
13535
|
-
getImage(src) {
|
13536
|
-
const img = this.images.find(item => item.src === src);
|
13537
|
-
return img?.ele;
|
13538
|
-
}
|
13539
|
-
/**
|
13540
|
-
* 判断图片是否都已经加载完毕
|
13541
|
-
* 用于打印时判断,如果当前图片没有加载完毕就打印,图片是打印不出来
|
13542
|
-
* @returns
|
13543
|
-
*/
|
13544
|
-
imagesLoadCompleted() {
|
13545
|
-
if (this.images.length === 0) {
|
13546
|
-
return true;
|
13547
|
-
}
|
13548
|
-
return this.images.every(item => ['completed', 'error'].includes(item.loadStatus));
|
13549
|
-
}
|
13550
|
-
}
|
13551
|
-
class DocumentImagesLoader extends DocumentImagesBaseLoader {
|
13552
|
-
createRequestImage(url) {
|
13553
|
-
const ele = new Image();
|
13554
|
-
ele.src = url;
|
13555
|
-
return new Promise((r, i) => {
|
13556
|
-
ele.onload = (e) => { this.invokeImgLoad(url, 'completed', ele); r(); };
|
13557
|
-
ele.onerror = (e) => { this.invokeImgLoad(url, 'error', ele); r(); };
|
13558
|
-
});
|
13447
|
+
/**
|
13448
|
+
* 触发动态脚本
|
13449
|
+
*/
|
13450
|
+
invokedScripts() {
|
13451
|
+
this.scriptsFunc?.();
|
13559
13452
|
}
|
13560
13453
|
}
|
13561
13454
|
|
@@ -13571,7 +13464,7 @@ class EditorContext {
|
|
13571
13464
|
//文档刷新的订阅事件
|
13572
13465
|
//refSub!: Subscription;
|
13573
13466
|
syncRefresh;
|
13574
|
-
imageLoader;
|
13467
|
+
//imageLoader: IImageLoader;
|
13575
13468
|
dynamicFunc;
|
13576
13469
|
docChange;
|
13577
13470
|
clearPrevDocCb;
|
@@ -13581,7 +13474,7 @@ class EditorContext {
|
|
13581
13474
|
this.selectionState = selectionState;
|
13582
13475
|
this.viewOptions = viewOptions;
|
13583
13476
|
this.dynamicFunc = new DocumentEvalFunc(this);
|
13584
|
-
this.imageLoader = new DocumentImagesLoader();
|
13477
|
+
//this.imageLoader = new DocumentImagesLoader();
|
13585
13478
|
this.selectionState.onChangedEvent.subscribe(() => {
|
13586
13479
|
this.syncRefresh?.();
|
13587
13480
|
});
|
@@ -13622,7 +13515,7 @@ class EditorContext {
|
|
13622
13515
|
}
|
13623
13516
|
clear() {
|
13624
13517
|
this.selectionState.clear();
|
13625
|
-
this.imageLoader.clear();
|
13518
|
+
//this.imageLoader.clear();
|
13626
13519
|
this.dynamicFunc.destroyScripts();
|
13627
13520
|
this.isDirty = false;
|
13628
13521
|
}
|
@@ -13664,7 +13557,7 @@ class EditorContext {
|
|
13664
13557
|
this.document.destroy();
|
13665
13558
|
this.clearPrevDocCb?.();
|
13666
13559
|
//this.ele_types_handlers.length = 0;
|
13667
|
-
this.imageLoader.clear();
|
13560
|
+
//this.imageLoader.clear();
|
13668
13561
|
this._document = null;
|
13669
13562
|
}
|
13670
13563
|
/**
|
@@ -13699,6 +13592,17 @@ class EditorContext {
|
|
13699
13592
|
return this._document.modifyFlag === ModifyFlag$1.None ? 'appearance' : 'content';
|
13700
13593
|
}
|
13701
13594
|
}
|
13595
|
+
// export interface IImageLoader {
|
13596
|
+
// clear(): void;
|
13597
|
+
//
|
13598
|
+
// loadImage(src: string, onCallback: (status: ImgLoadStatus) => void): void;
|
13599
|
+
//
|
13600
|
+
// getImage(src: string): HTMLImageElement | undefined;
|
13601
|
+
//
|
13602
|
+
// imagesLoadCompleted(): boolean;
|
13603
|
+
//
|
13604
|
+
// getLoadTasks(): Array<Promise<void>>;
|
13605
|
+
// }
|
13702
13606
|
/**
|
13703
13607
|
* 文档上下文
|
13704
13608
|
*/
|
@@ -14592,13 +14496,139 @@ class ParagraphMeasure {
|
|
14592
14496
|
}
|
14593
14497
|
}
|
14594
14498
|
|
14499
|
+
/**
|
14500
|
+
* 用于处理选区拖蓝
|
14501
|
+
*/
|
14502
|
+
class SelectionOverlays {
|
14503
|
+
selectionState;
|
14504
|
+
selectionRange;
|
14505
|
+
//选区对象集合
|
14506
|
+
selectionEleSets = new Map();
|
14507
|
+
//批注对象集合
|
14508
|
+
commRangeSets = new Map();
|
14509
|
+
constructor(selectionState) {
|
14510
|
+
this.selectionState = selectionState;
|
14511
|
+
}
|
14512
|
+
getSelectionTreeData() {
|
14513
|
+
let { ancestorCommonControl, startControl, startOffset, endControl, endOffset, collapsed } = this.selectionState;
|
14514
|
+
this.selectionEleSets.clear();
|
14515
|
+
if (this.selectionRange) {
|
14516
|
+
this.selectionRange.selectedChildren.length = 0;
|
14517
|
+
}
|
14518
|
+
this.selectionRange = null;
|
14519
|
+
if (!startControl || !endControl || !ancestorCommonControl) {
|
14520
|
+
//this.selectionRange?.selectedChildren.length=0;
|
14521
|
+
this.selectionState.selectedRange = null;
|
14522
|
+
return;
|
14523
|
+
}
|
14524
|
+
if (collapsed) {
|
14525
|
+
const commonRange = RangeUtil.getSectionRange(startControl, startOffset, endControl, endOffset, ancestorCommonControl);
|
14526
|
+
this.selectionState.selectedRange = commonRange;
|
14527
|
+
this.selectionEleSets.clear();
|
14528
|
+
return;
|
14529
|
+
}
|
14530
|
+
const fixStartElement = this.fixStartSelectionElement(startControl, startOffset, ancestorCommonControl);
|
14531
|
+
startControl = fixStartElement.element;
|
14532
|
+
startOffset = fixStartElement.offset;
|
14533
|
+
const fixEndElement = this.fixEndSelectionElement(endControl, endOffset, ancestorCommonControl);
|
14534
|
+
endControl = fixEndElement.element;
|
14535
|
+
endOffset = fixEndElement.offset;
|
14536
|
+
const commonRange = RangeUtil.getSectionRange(startControl, startOffset, endControl, endOffset, ancestorCommonControl);
|
14537
|
+
//console.log(commonRange);
|
14538
|
+
this.selectionRange = commonRange;
|
14539
|
+
this.convertSelectRangeToSet();
|
14540
|
+
this.selectionState.selectedRange = commonRange;
|
14541
|
+
}
|
14542
|
+
convertSelectRangeToSet() {
|
14543
|
+
this.selectionEleSets.clear();
|
14544
|
+
if (this.selectionRange) {
|
14545
|
+
SelectionOverlays.addToSets(this.selectionRange, this.selectionEleSets);
|
14546
|
+
}
|
14547
|
+
}
|
14548
|
+
static addToSets(range, set) {
|
14549
|
+
set.set(range.target, range);
|
14550
|
+
for (let i = 0; i < range.selectedChildren.length; i++) {
|
14551
|
+
//单元格全部选中效果,单元格整个拖蓝即可
|
14552
|
+
if (range.isFullSelected && range.target.type === 'tbc') {
|
14553
|
+
continue;
|
14554
|
+
}
|
14555
|
+
this.addToSets(range.selectedChildren[i], set);
|
14556
|
+
}
|
14557
|
+
}
|
14558
|
+
/**
|
14559
|
+
* 添加到批注集合
|
14560
|
+
* @param range
|
14561
|
+
* @param set
|
14562
|
+
* @param rangeColor 用以显示批注区间的颜色
|
14563
|
+
*/
|
14564
|
+
static addToCommentSets(range, set, rangeColor) {
|
14565
|
+
range['rangeColor'] = rangeColor;
|
14566
|
+
set.set(range.target, range);
|
14567
|
+
for (let i = 0; i < range.selectedChildren.length; i++) {
|
14568
|
+
this.addToCommentSets(range.selectedChildren[i], set, rangeColor);
|
14569
|
+
}
|
14570
|
+
}
|
14571
|
+
/**
|
14572
|
+
* 修正开始选区内容
|
14573
|
+
* 1.如果当前选区开始于表格内容,结束选区位于表格外,则需要开始选区内容重定位到单元格第一个元素
|
14574
|
+
*/
|
14575
|
+
fixStartSelectionElement(element, offset, ancestorCommonControl) {
|
14576
|
+
if (!(ancestorCommonControl instanceof TableElement)) {
|
14577
|
+
const lookupParentCell = ElementUtil.getParentByType(element, TableCellElement);
|
14578
|
+
if (lookupParentCell) {
|
14579
|
+
if (!lookupParentCell.parent || !lookupParentCell.parent.parent) ;
|
14580
|
+
const lookupParentTbIndex = ElementUtil.getControlIndex(lookupParentCell.parent.parent);
|
14581
|
+
const ancestorCommonControlIndex = ElementUtil.getControlIndex(ancestorCommonControl);
|
14582
|
+
if (ancestorCommonControlIndex < lookupParentTbIndex) {
|
14583
|
+
const rowFirstLeafElement = ElementUtil.getFirstLeafElement(lookupParentCell.parent);
|
14584
|
+
if (!rowFirstLeafElement) {
|
14585
|
+
throw new Error('当前元素处于表格内元素,未能定位到当前单元格首个元素');
|
14586
|
+
}
|
14587
|
+
return {
|
14588
|
+
element: rowFirstLeafElement,
|
14589
|
+
offset: 0
|
14590
|
+
};
|
14591
|
+
}
|
14592
|
+
}
|
14593
|
+
}
|
14594
|
+
return { element, offset };
|
14595
|
+
}
|
14596
|
+
/**
|
14597
|
+
* 修正开始选区内容
|
14598
|
+
* 1.如果当前选区开始于表格内容,结束选区位于表格外,则需要开始选区内容重定位到单元格第一个元素
|
14599
|
+
*/
|
14600
|
+
fixEndSelectionElement(element, offset, ancestorCommonControl) {
|
14601
|
+
if (!(ancestorCommonControl instanceof TableElement)) {
|
14602
|
+
const lookupParentCell = ElementUtil.getParentByType(element, TableCellElement);
|
14603
|
+
if (lookupParentCell) {
|
14604
|
+
const lookupParentTbIndex = ElementUtil.getControlIndex(lookupParentCell.parent.parent);
|
14605
|
+
const ancestorCommonControlIndex = ElementUtil.getControlIndex(ancestorCommonControl);
|
14606
|
+
if (ancestorCommonControlIndex < lookupParentTbIndex) {
|
14607
|
+
const rowLastLeafElement = ElementUtil.getLastLeafElement(lookupParentCell.parent);
|
14608
|
+
if (!rowLastLeafElement) {
|
14609
|
+
ElementUtil.getLastLeafElement(lookupParentCell.parent);
|
14610
|
+
throw new Error('当前元素处于表格内元素,未能定位到当前单元格首个元素');
|
14611
|
+
}
|
14612
|
+
return {
|
14613
|
+
element: rowLastLeafElement,
|
14614
|
+
offset: 1
|
14615
|
+
};
|
14616
|
+
}
|
14617
|
+
}
|
14618
|
+
}
|
14619
|
+
return { element, offset };
|
14620
|
+
}
|
14621
|
+
}
|
14622
|
+
|
14595
14623
|
class DocumentArrange {
|
14596
14624
|
docCtx;
|
14597
14625
|
renderCtx;
|
14626
|
+
seo;
|
14598
14627
|
options;
|
14599
|
-
constructor(docCtx, renderCtx) {
|
14628
|
+
constructor(docCtx, renderCtx, seo) {
|
14600
14629
|
this.docCtx = docCtx;
|
14601
14630
|
this.renderCtx = renderCtx;
|
14631
|
+
this.seo = seo;
|
14602
14632
|
this.options = this.docCtx.viewOptions;
|
14603
14633
|
}
|
14604
14634
|
/**
|
@@ -14620,24 +14650,25 @@ class DocumentArrange {
|
|
14620
14650
|
parser: new DynamicContextParser(doc, this.docCtx.selectionState),
|
14621
14651
|
createParaFn: () => this.createDefaultPara()
|
14622
14652
|
};
|
14623
|
-
doc.
|
14653
|
+
doc.clearMarkItems();
|
14624
14654
|
this.clearPaintCache(doc, data);
|
14625
|
-
this.docCtx.viewOptions.showReviewWindow = this.docCtx.document.commentsContainerElement.markPairs.length > 0;
|
14655
|
+
//this.docCtx.viewOptions.showReviewWindow = this.docCtx.document.commentsContainerElement.markPairs.length > 0;
|
14626
14656
|
const docRenders = this.arrangeDoc();
|
14627
14657
|
this.setMeasureCompletedModifyFlag(doc);
|
14628
14658
|
this.cacheDocRenders(docRenders);
|
14659
|
+
this.generateCommRange();
|
14629
14660
|
return docRenders;
|
14630
14661
|
});
|
14631
14662
|
}
|
14632
|
-
commentsRender;
|
14663
|
+
//commentsRender!: CommsContainerRenderObject;
|
14633
14664
|
arrangeDoc() {
|
14634
14665
|
const doc = this.docCtx.document;
|
14635
14666
|
const docRender = doc.createRenderObject();
|
14636
14667
|
const innerRect = docRender.getInnerRect();
|
14637
14668
|
const headerRender = this.measureControl(doc.headerElement, innerRect.width);
|
14638
14669
|
const footerRender = this.measureControl(doc.footerElement, innerRect.width);
|
14639
|
-
const commentsRender = this.measureControl(doc.commentsContainerElement, this.options.reviewWindowWidth);
|
14640
|
-
this.commentsRender = commentsRender;
|
14670
|
+
//const commentsRender = this.measureControl(doc.commentsContainerElement, this.options.reviewWindowWidth) as CommsContainerRenderObject;
|
14671
|
+
//this.commentsRender = commentsRender;
|
14641
14672
|
const { headerLine, footerLine } = docRender;
|
14642
14673
|
let bodyMarginTop = headerLine + headerRender.rect.height + 6;
|
14643
14674
|
let bodyMarginBottom = footerLine + footerRender.rect.height;
|
@@ -14732,15 +14763,15 @@ class DocumentArrange {
|
|
14732
14763
|
cloneFooterRender.rect.x = limitRect.x;
|
14733
14764
|
cloneFooterRender.rect.y = documentRender.rect.height - bodyMarginBottom;
|
14734
14765
|
currColumn === 0 && documentRender.addChild(cloneFooterRender);
|
14735
|
-
//审阅模式,添加审阅窗口
|
14736
|
-
if (this.options.showReviewWindow && commentsRender) {
|
14737
|
-
|
14738
|
-
|
14739
|
-
|
14740
|
-
|
14741
|
-
|
14742
|
-
|
14743
|
-
}
|
14766
|
+
// //审阅模式,添加审阅窗口
|
14767
|
+
// if (this.options.showReviewWindow && commentsRender) {
|
14768
|
+
// const commentsContainer = this.createRenderObject(commentsRender.element) as CommsContainerRenderObject;
|
14769
|
+
// commentsContainer.padding.top = bodyMarginTop;
|
14770
|
+
// commentsContainer.rect.height = documentRender.rect.height;
|
14771
|
+
// documentRender.addChild(commentsContainer);
|
14772
|
+
// commentsContainer.rect.x = documentRender.rect.x + documentRender.rect.width;
|
14773
|
+
// documentRender.rect.width += this.options.reviewWindowWidth;
|
14774
|
+
// }
|
14744
14775
|
currColumn++;
|
14745
14776
|
if (currColumn === docColumns) {
|
14746
14777
|
currColumn = 0;
|
@@ -14768,8 +14799,7 @@ class DocumentArrange {
|
|
14768
14799
|
}
|
14769
14800
|
if (element instanceof BlockContentElement) {
|
14770
14801
|
const pRange = new ParagraphMeasure(this.options, this.renderCtx);
|
14771
|
-
|
14772
|
-
return innerLineRects;
|
14802
|
+
return pRange.measureParagraph(element, maxWidth);
|
14773
14803
|
}
|
14774
14804
|
else if (element instanceof BlockContainerElement) {
|
14775
14805
|
const renders = [];
|
@@ -14907,7 +14937,6 @@ class DocumentArrange {
|
|
14907
14937
|
* 切割渲染元素
|
14908
14938
|
* @param tbRender 被切割的对象
|
14909
14939
|
* @param limitHeight
|
14910
|
-
* @param addFunc
|
14911
14940
|
* @returns
|
14912
14941
|
*/
|
14913
14942
|
cutTable(tbRender, limitHeight) {
|
@@ -14937,29 +14966,27 @@ class DocumentArrange {
|
|
14937
14966
|
while (currRow) {
|
14938
14967
|
const rowContentHeight = this.getBlockLineHeight(currRow);
|
14939
14968
|
if (rowContentHeight + sumHeight > limitHeight) {
|
14940
|
-
|
14941
|
-
|
14942
|
-
|
14943
|
-
|
14944
|
-
|
14945
|
-
|
14946
|
-
|
14947
|
-
|
14948
|
-
|
14949
|
-
|
14950
|
-
|
14951
|
-
|
14952
|
-
|
14953
|
-
tbRender.removeChild(currRow);
|
14954
|
-
}
|
14955
|
-
if (currRow === joinRow) {
|
14956
|
-
break;
|
14957
|
-
}
|
14958
|
-
currRow = rows[++j];
|
14969
|
+
//行存在最小高度,且当前行跨页的情况下,不截断该行
|
14970
|
+
if (currRow.element.props.minHeight) {
|
14971
|
+
break;
|
14972
|
+
}
|
14973
|
+
//限制的外框尺寸
|
14974
|
+
const availHeight = limitHeight - sumHeight;
|
14975
|
+
const limitRenderInnerHeight = ElementUtil.innerRectMaxHeight(tbRender, availHeight);
|
14976
|
+
const cutRow = this.cutRowRenderItem(currRow, limitRenderInnerHeight);
|
14977
|
+
if (cutRow) {
|
14978
|
+
cloneTbRender.addChild(cutRow);
|
14979
|
+
sumHeight += cutRow.rect.height;
|
14980
|
+
if (currRow.getItems().some(item => item.length !== 0)) {
|
14981
|
+
cutRows.push(currRow);
|
14959
14982
|
}
|
14960
14983
|
else {
|
14984
|
+
tbRender.removeChild(currRow);
|
14985
|
+
}
|
14986
|
+
if (currRow === joinRow) {
|
14961
14987
|
break;
|
14962
14988
|
}
|
14989
|
+
currRow = rows[++j];
|
14963
14990
|
}
|
14964
14991
|
else {
|
14965
14992
|
break;
|
@@ -14991,6 +15018,7 @@ class DocumentArrange {
|
|
14991
15018
|
// if (render.element.props.minHeight > 0 && render.rect.height < limitHeight) {
|
14992
15019
|
// return null;
|
14993
15020
|
// }
|
15021
|
+
render.remeasureState = true;
|
14994
15022
|
const cloneRowRender = render.element.createRenderObject();
|
14995
15023
|
cloneRowRender.rect.width = render.rect.width;
|
14996
15024
|
//cloneRowRender.rect.maxWidth = render.rect.height;
|
@@ -15182,7 +15210,7 @@ class DocumentArrange {
|
|
15182
15210
|
}
|
15183
15211
|
identifyComment(ele) {
|
15184
15212
|
if (ele instanceof CommentElement) {
|
15185
|
-
this.docCtx.document.
|
15213
|
+
this.docCtx.document.identifyCommMark(ele);
|
15186
15214
|
}
|
15187
15215
|
}
|
15188
15216
|
cacheDoc;
|
@@ -15193,6 +15221,22 @@ class DocumentArrange {
|
|
15193
15221
|
});
|
15194
15222
|
this.cacheDoc = null;
|
15195
15223
|
}
|
15224
|
+
/**
|
15225
|
+
* 生成批注区间信息
|
15226
|
+
* @param renderTree
|
15227
|
+
*/
|
15228
|
+
generateCommRange() {
|
15229
|
+
this.seo.commRangeSets.clear();
|
15230
|
+
const commMarks = this.docCtx.document.markPairs;
|
15231
|
+
for (let i = 0; i < commMarks.length; i++) {
|
15232
|
+
const commMark = commMarks[i];
|
15233
|
+
if (commMark.start && commMark.end) {
|
15234
|
+
const ancestor = DocumentSelection.getAncestorCommonControl(commMark.start, commMark.end);
|
15235
|
+
const range = RangeUtil.getSectionRange(commMark.start, 0, commMark.end, 1, ancestor);
|
15236
|
+
SelectionOverlays.addToCommentSets(range, this.seo.commRangeSets, commMark.start.color);
|
15237
|
+
}
|
15238
|
+
}
|
15239
|
+
}
|
15196
15240
|
cacheRenders(renderTree) {
|
15197
15241
|
if (renderTree.element) {
|
15198
15242
|
renderTree.element.paintRenders.push(renderTree);
|
@@ -15887,7 +15931,10 @@ class ElementRenderCut {
|
|
15887
15931
|
documentRender.addChild(cloneFooterRender);
|
15888
15932
|
//审阅模式,添加审阅窗口
|
15889
15933
|
if (this.options.showReviewWindow && commentsRender) {
|
15890
|
-
const commentsContainer = commentsRender.element.createRenderObject({
|
15934
|
+
const commentsContainer = commentsRender.element.createRenderObject({
|
15935
|
+
options: this.options,
|
15936
|
+
renderCtx: this.renderContext
|
15937
|
+
});
|
15891
15938
|
commentsContainer.padding.top = bodyMarginTop;
|
15892
15939
|
commentsContainer.rect.height = documentRender.rect.height;
|
15893
15940
|
documentRender.addChild(commentsContainer);
|
@@ -15898,13 +15945,19 @@ class ElementRenderCut {
|
|
15898
15945
|
return docPages;
|
15899
15946
|
}
|
15900
15947
|
getDocInnerRect(documentRender) {
|
15901
|
-
const render = documentRender.element.createRenderObject({
|
15948
|
+
const render = documentRender.element.createRenderObject({
|
15949
|
+
options: this.options,
|
15950
|
+
renderCtx: this.renderContext
|
15951
|
+
});
|
15902
15952
|
render.padding = documentRender.padding;
|
15903
15953
|
return render.getInnerRect();
|
15904
15954
|
}
|
15905
15955
|
getFullViewDocRender(documentRender, documentElement) {
|
15906
15956
|
const commentsRender = documentRender.getChild(3);
|
15907
|
-
const commentsContainer = commentsRender.element.createRenderObject({
|
15957
|
+
const commentsContainer = commentsRender.element.createRenderObject({
|
15958
|
+
options: this.options,
|
15959
|
+
renderCtx: this.renderContext
|
15960
|
+
});
|
15908
15961
|
documentRender.rect.height -= commentsContainer.rect.height;
|
15909
15962
|
const bodyRender = documentRender.getChild(1);
|
15910
15963
|
if (this.options.showReviewWindow) {
|
@@ -15918,7 +15971,10 @@ class ElementRenderCut {
|
|
15918
15971
|
return [documentRender];
|
15919
15972
|
}
|
15920
15973
|
createEmptyBodyRender(bodyRender, limitRect) {
|
15921
|
-
const pageBodyRender = bodyRender.element.createRenderObject({
|
15974
|
+
const pageBodyRender = bodyRender.element.createRenderObject({
|
15975
|
+
options: this.options,
|
15976
|
+
renderCtx: this.renderContext
|
15977
|
+
});
|
15922
15978
|
pageBodyRender.rect.width = limitRect.width;
|
15923
15979
|
const bodyInnerLimitRect = pageBodyRender.getInnerRect();
|
15924
15980
|
if (this.options.fullPageView) {
|
@@ -15942,7 +15998,10 @@ class ElementRenderCut {
|
|
15942
15998
|
if (render instanceof TableRenderObject) {
|
15943
15999
|
return this.cutTable(render, limitHeight);
|
15944
16000
|
}
|
15945
|
-
const cloneRender = render.element.createRenderObject({
|
16001
|
+
const cloneRender = render.element.createRenderObject({
|
16002
|
+
options: this.options,
|
16003
|
+
renderCtx: this.renderContext
|
16004
|
+
});
|
15946
16005
|
cloneRender.setRenderWidth(render.rect.width);
|
15947
16006
|
if (render instanceof MuiltBlockLineRenderObject) {
|
15948
16007
|
let sumHeight = 0;
|
@@ -16077,16 +16136,16 @@ class ElementRenderCut {
|
|
16077
16136
|
}
|
16078
16137
|
const cloneRowRender = render.element.createRenderObject();
|
16079
16138
|
cloneRowRender.rect.width = render.rect.width;
|
16139
|
+
render.remeasureState = true;
|
16080
16140
|
//cloneRowRender.rect.maxWidth = render.rect.height;
|
16081
16141
|
const cellRenders = [...render.getItems()];
|
16082
16142
|
const cutCellRenders = [];
|
16083
16143
|
for (let i = 0; i < cellRenders.length; i++) {
|
16084
16144
|
const cellRender = cellRenders[i];
|
16145
|
+
this.markMergeRowRenderDirty(cellRender);
|
16085
16146
|
if (cellRender.rect.height > limitHeight) {
|
16086
|
-
//限制的外框尺寸
|
16087
|
-
const availHeight = limitHeight;
|
16088
16147
|
//限制的内框尺寸
|
16089
|
-
const limitCellHeight = ElementUtil.innerRectMaxHeight(cellRender,
|
16148
|
+
const limitCellHeight = ElementUtil.innerRectMaxHeight(cellRender, limitHeight);
|
16090
16149
|
const cutCellRender = this.cutRenderItem(cellRender, limitCellHeight);
|
16091
16150
|
if (cutCellRender) {
|
16092
16151
|
cutCellRenders.push(cutCellRender);
|
@@ -16110,7 +16169,10 @@ class ElementRenderCut {
|
|
16110
16169
|
for (let i = 0; i < cutCellRenders.length; i++) {
|
16111
16170
|
let cellRender = cutCellRenders[i];
|
16112
16171
|
if (!cellRender) {
|
16113
|
-
cellRender = cellRenders[i].element.createRenderObject({
|
16172
|
+
cellRender = cellRenders[i].element.createRenderObject({
|
16173
|
+
options: this.options,
|
16174
|
+
renderCtx: this.renderContext
|
16175
|
+
});
|
16114
16176
|
cellRender.rect = ElementUtil.cloneRect(cellRenders[i].rect);
|
16115
16177
|
ElementUtil.remeasure(cellRender);
|
16116
16178
|
}
|
@@ -16120,6 +16182,33 @@ class ElementRenderCut {
|
|
16120
16182
|
return cloneRowRender;
|
16121
16183
|
}
|
16122
16184
|
}
|
16185
|
+
/**
|
16186
|
+
* 标记合并单元格所在行需要重新计算
|
16187
|
+
* @param cellRender
|
16188
|
+
* @private
|
16189
|
+
*/
|
16190
|
+
markMergeRowRenderDirty(cellRender) {
|
16191
|
+
const cellEle = cellRender.element;
|
16192
|
+
if (cellEle.props.vMerge !== 'restart') {
|
16193
|
+
return;
|
16194
|
+
}
|
16195
|
+
const rowRender = cellRender.parent;
|
16196
|
+
rowRender.element;
|
16197
|
+
const tb = rowRender.parent;
|
16198
|
+
const cellYPos = cellRender.rect.y;
|
16199
|
+
for (let i = rowRender.getIndex() + 1; i < tb.length; i++) {
|
16200
|
+
const nextRowRender = tb.getChild(i);
|
16201
|
+
if (nextRowRender.rect.y <= cellYPos) {
|
16202
|
+
nextRowRender.remeasureState = true;
|
16203
|
+
nextRowRender.getItems().forEach(item => {
|
16204
|
+
this.markMergeRowRenderDirty(item);
|
16205
|
+
});
|
16206
|
+
}
|
16207
|
+
else {
|
16208
|
+
break;
|
16209
|
+
}
|
16210
|
+
}
|
16211
|
+
}
|
16123
16212
|
/**
|
16124
16213
|
* 修复->已经截断的合并单元格要向下移动到合适的位置
|
16125
16214
|
* @param tbRender
|
@@ -16243,7 +16332,7 @@ class ElementRenderCut {
|
|
16243
16332
|
class DocumentPaint {
|
16244
16333
|
renderContext;
|
16245
16334
|
docCtx;
|
16246
|
-
|
16335
|
+
seo;
|
16247
16336
|
elementMeasure;
|
16248
16337
|
elementRenderCut;
|
16249
16338
|
elementPaint;
|
@@ -16251,10 +16340,10 @@ class DocumentPaint {
|
|
16251
16340
|
docContainer;
|
16252
16341
|
//commsContainer!: CommsContainerRenderObject;
|
16253
16342
|
viewOptions;
|
16254
|
-
constructor(renderContext, docCtx,
|
16343
|
+
constructor(renderContext, docCtx, seo) {
|
16255
16344
|
this.renderContext = renderContext;
|
16256
16345
|
this.docCtx = docCtx;
|
16257
|
-
this.
|
16346
|
+
this.seo = seo;
|
16258
16347
|
this.viewOptions = this.docCtx.viewOptions;
|
16259
16348
|
this.elementMeasure = new ElementMeasure(this.docCtx, this.renderContext);
|
16260
16349
|
this.elementRenderCut = new ElementRenderCut(this.viewOptions, this.renderContext);
|
@@ -16276,7 +16365,7 @@ class DocumentPaint {
|
|
16276
16365
|
// //console.timeEnd('排版计时');
|
16277
16366
|
// //console.time('断页计时');
|
16278
16367
|
// const docPages = this.elementRenderCut.cutPage(documentRender, this.docCtx.document);
|
16279
|
-
const newMeasure = new DocumentArrange(this.docCtx, this.renderContext);
|
16368
|
+
const newMeasure = new DocumentArrange(this.docCtx, this.renderContext, this.seo);
|
16280
16369
|
const docPages = newMeasure.measureDoc();
|
16281
16370
|
// this.commsContainer = newMeasure.commentsRender as CommsContainerRenderObject;
|
16282
16371
|
// if (this.commsContainer) {
|
@@ -16373,7 +16462,7 @@ class DocumentPaint {
|
|
16373
16462
|
}
|
16374
16463
|
}
|
16375
16464
|
refreshView() {
|
16376
|
-
this.elementPaint.drawPages(this.docContainer, this.
|
16465
|
+
this.elementPaint.drawPages(this.docContainer, this.seo.selectionEleSets);
|
16377
16466
|
}
|
16378
16467
|
getDocPages() {
|
16379
16468
|
return this.docPages;
|
@@ -16388,31 +16477,31 @@ class DocumentPaint {
|
|
16388
16477
|
if (!this.viewOptions.showReviewWindow) {
|
16389
16478
|
return;
|
16390
16479
|
}
|
16391
|
-
const cce = this.docCtx.document.commentsContainerElement;
|
16392
|
-
const set = new Map();
|
16393
|
-
const commentRangeStatus = [];
|
16394
|
-
for (let i = 0; i < cce.length; i++) {
|
16395
|
-
|
16396
|
-
|
16397
|
-
|
16398
|
-
|
16399
|
-
|
16400
|
-
|
16401
|
-
|
16402
|
-
|
16403
|
-
|
16404
|
-
|
16405
|
-
|
16406
|
-
|
16407
|
-
|
16408
|
-
|
16409
|
-
|
16410
|
-
|
16411
|
-
|
16412
|
-
|
16413
|
-
}
|
16414
|
-
cce.cacheRender.selectedSet = set;
|
16415
|
-
cce.cacheRender.commentRangeStatus = commentRangeStatus;
|
16480
|
+
// const cce = this.docCtx.document.commentsContainerElement;
|
16481
|
+
// const set = new Map<Element, SelectionContentRange>();
|
16482
|
+
// const commentRangeStatus: Array<CommentRangeStatus> = [];
|
16483
|
+
// for (let i = 0; i < cce.length; i++) {
|
16484
|
+
// const commContent = cce.getChild(i) as CommContentElement;
|
16485
|
+
// const commMarkPair = cce.markPairs.find(item => item.id === commContent.props.id);
|
16486
|
+
// if (commMarkPair) {
|
16487
|
+
// if (commMarkPair.start) {
|
16488
|
+
// commContent.startMark = commMarkPair.start;
|
16489
|
+
// }
|
16490
|
+
// if (commMarkPair.end) {
|
16491
|
+
// commContent.endMark = commMarkPair.end;
|
16492
|
+
// }
|
16493
|
+
// }
|
16494
|
+
// const {startMark, endMark, props: {id}, focus} = commContent;
|
16495
|
+
// const ancestorCommonControl = DocumentSelection.getAncestorCommonControl(startMark, endMark);
|
16496
|
+
// const commonRange = RangeUtil.getSectionRange(startMark, 0, endMark, 1, ancestorCommonControl);
|
16497
|
+
// SelectionOverlays.addToCommentSets(commonRange, set);
|
16498
|
+
// commentRangeStatus.push({
|
16499
|
+
// commContent,
|
16500
|
+
// range: commonRange
|
16501
|
+
// })
|
16502
|
+
// }
|
16503
|
+
// (<CommsContainerRenderObject>cce.cacheRender).selectedSet = set;
|
16504
|
+
// (<CommsContainerRenderObject>cce.cacheRender).commentRangeStatus = commentRangeStatus;
|
16416
16505
|
}
|
16417
16506
|
}
|
16418
16507
|
|
@@ -16612,15 +16701,15 @@ class ElementReader {
|
|
16612
16701
|
document.bodyElement = document.find((item) => item instanceof DocumentBodyElement);
|
16613
16702
|
document.headerElement = document.find((item) => item instanceof DocumentHeaderElement);
|
16614
16703
|
document.footerElement = document.find((item) => item instanceof DocumentFooterElement);
|
16615
|
-
document.commentsContainerElement = document.find((item) => item instanceof CommsContainerElement);
|
16616
|
-
if (!document.commentsContainerElement) {
|
16617
|
-
|
16618
|
-
}
|
16704
|
+
// document.commentsContainerElement = document.find((item) => item instanceof CommsContainerElement) as CommsContainerElement;
|
16705
|
+
// if (!document.commentsContainerElement) {
|
16706
|
+
// document.commentsContainerElement = new CommsContainerElement();
|
16707
|
+
// }
|
16619
16708
|
document.clearItems();
|
16620
16709
|
document.addChild(document.headerElement);
|
16621
16710
|
document.addChild(document.bodyElement);
|
16622
16711
|
document.addChild(document.footerElement);
|
16623
|
-
document.addChild(document.commentsContainerElement);
|
16712
|
+
//document.addChild(document.commentsContainerElement);
|
16624
16713
|
this.docCtx.document = document;
|
16625
16714
|
document.viewOptions = this.docCtx.viewOptions;
|
16626
16715
|
const width = Math.floor(document.props.width * this.docCtx.viewOptions.mmToPixelsRatio);
|
@@ -16628,7 +16717,7 @@ class ElementReader {
|
|
16628
16717
|
this.docCtx.viewOptions.docPageSettings = new PageOptions(width, height, document.props.orient);
|
16629
16718
|
//this.viewOptions.viewSettings.width = this.viewOptions.docPageSettings.width + 10;
|
16630
16719
|
}
|
16631
|
-
readElement(data) {
|
16720
|
+
readElement(data, strictMode = false) {
|
16632
16721
|
if (typeof data === 'string') {
|
16633
16722
|
data = JSON.parse(data);
|
16634
16723
|
}
|
@@ -16643,19 +16732,27 @@ class ElementReader {
|
|
16643
16732
|
const children = data.children || [];
|
16644
16733
|
for (const child of children) {
|
16645
16734
|
//element.addChild(this.readElement(child));
|
16646
|
-
|
16735
|
+
const childEle = this.readElement(child);
|
16736
|
+
childEle && childArr.push(childEle);
|
16647
16737
|
}
|
16648
16738
|
}
|
16649
16739
|
factory.readCompleted(element, childArr);
|
16650
16740
|
return element;
|
16651
16741
|
}
|
16652
16742
|
}
|
16653
|
-
|
16743
|
+
if (strictMode) {
|
16744
|
+
throw new Error('未知的元素类型:' + type, data);
|
16745
|
+
}
|
16746
|
+
else {
|
16747
|
+
console.error('未知的元素类型:' + type, data);
|
16748
|
+
return null;
|
16749
|
+
}
|
16654
16750
|
}
|
16655
|
-
|
16656
|
-
|
16657
|
-
|
16658
|
-
|
16751
|
+
/**
|
16752
|
+
* 读取扩展属性
|
16753
|
+
* @param data
|
16754
|
+
* @param element
|
16755
|
+
*/
|
16659
16756
|
readExtendsProps(data, element) {
|
16660
16757
|
if (!data.props) {
|
16661
16758
|
return;
|
@@ -19503,7 +19600,7 @@ class DocumentChange {
|
|
19503
19600
|
return paragraph;
|
19504
19601
|
}
|
19505
19602
|
const last = ElementUtil.getLastLeafElement(paragraph);
|
19506
|
-
const selectedParaRange = RangeUtil.
|
19603
|
+
const selectedParaRange = RangeUtil.getSectionRange(startControl, startOffset, last, 1, paragraph);
|
19507
19604
|
selectedParaRange.isFullSelected = false;
|
19508
19605
|
const breakPara = ElementUtil.cloneRange(selectedParaRange, true);
|
19509
19606
|
ElementUtil.fixParagraphContent(paragraph);
|
@@ -20125,22 +20222,26 @@ class DocumentChange {
|
|
20125
20222
|
const id = nanoid(5);
|
20126
20223
|
const startCommMark = new CommentElement();
|
20127
20224
|
startCommMark.props.id = id;
|
20225
|
+
startCommMark.props.userId = this.viewOptions.editUser.id;
|
20226
|
+
startCommMark.props.userName = this.viewOptions.editUser.name;
|
20227
|
+
startCommMark.props.date = CommonUtil.formatNow('YYYY-MM-DD HH:mm:ss');
|
20128
20228
|
startCommMark.props.markType = 'start';
|
20129
20229
|
const endCommMark = new CommentElement();
|
20130
20230
|
endCommMark.props.id = id;
|
20131
20231
|
endCommMark.props.markType = 'end';
|
20132
20232
|
this.insertElement(endControl, endOffset, [endCommMark]);
|
20133
20233
|
this.insertElement(startControl, startOffset, [startCommMark]);
|
20134
|
-
|
20135
|
-
commContent
|
20136
|
-
commContent.props.
|
20137
|
-
commContent.props.
|
20138
|
-
commContent.props.
|
20139
|
-
|
20140
|
-
|
20141
|
-
|
20142
|
-
|
20143
|
-
|
20234
|
+
startCommMark.props.text = '插入测试批注信息' + new Date();
|
20235
|
+
// const commContent = new CommContentElement();
|
20236
|
+
// commContent.props.id = id;
|
20237
|
+
// commContent.props.createId = this.viewOptions.editUser.id;
|
20238
|
+
// commContent.props.createName = this.viewOptions.editUser.name;
|
20239
|
+
// commContent.props.createDate = new Date();
|
20240
|
+
// const pos = this.docComment.getCommMarkIndex(startCommMark);
|
20241
|
+
// if (pos < 0) {
|
20242
|
+
// throw new Error('获取插入的批注位置不正确');
|
20243
|
+
// }
|
20244
|
+
// this.docCtx.document.commentsContainerElement.addChild(commContent, pos);
|
20144
20245
|
this.selectionState.clear();
|
20145
20246
|
}
|
20146
20247
|
validate() {
|
@@ -20164,8 +20265,8 @@ class DocumentChange {
|
|
20164
20265
|
validateElement.props.title = caption + '验证';
|
20165
20266
|
validateElement.props.id = id;
|
20166
20267
|
validateElement.setContent(item.error);
|
20167
|
-
|
20168
|
-
this.docCtx.document.commentsContainerElement.addChild(validateElement, pos);
|
20268
|
+
this.docComment.getCommMarkIndex(startCommMark);
|
20269
|
+
//this.docCtx.document.commentsContainerElement.addChild(validateElement, pos);
|
20169
20270
|
});
|
20170
20271
|
this.docCtx.selectionState.clear();
|
20171
20272
|
return false;
|
@@ -20591,7 +20692,6 @@ class DocumentComment {
|
|
20591
20692
|
// }
|
20592
20693
|
// this.commMarkList = commList;
|
20593
20694
|
// this.commContentList = commContentList;
|
20594
|
-
this.docCtx.viewOptions.showReviewWindow = this.docCtx.document.commentsContainerElement.markPairs.length > 0;
|
20595
20695
|
this.isDirty = false;
|
20596
20696
|
}
|
20597
20697
|
/**
|
@@ -20627,28 +20727,46 @@ class DocumentComment {
|
|
20627
20727
|
if (!endRange) {
|
20628
20728
|
return;
|
20629
20729
|
}
|
20630
|
-
const
|
20631
|
-
|
20632
|
-
|
20633
|
-
|
20634
|
-
if (!startMark || !endMark) {
|
20635
|
-
continue;
|
20636
|
-
}
|
20637
|
-
const commPair = {
|
20638
|
-
startMark,
|
20639
|
-
endMark,
|
20640
|
-
startMarkStatus: RangeUtil.checkElementFullInRange(selectedRange, startMark),
|
20641
|
-
endMarkStatus: RangeUtil.checkElementFullInRange(selectedRange, endMark),
|
20642
|
-
};
|
20643
|
-
commPairs.push(commPair);
|
20644
|
-
}
|
20645
|
-
for (let i = 0; i < commPairs.length; i++) {
|
20646
|
-
const commPair = commPairs[i];
|
20647
|
-
if (commPair.endMarkStatus) {
|
20648
|
-
this.removeComment(commPair.endMark.props.id);
|
20730
|
+
const selectedComms = [];
|
20731
|
+
RangeUtil.recursionTraversalRangeHandler(selectedRange, (range) => {
|
20732
|
+
if (range.target instanceof CommentElement && range.isFullSelected) {
|
20733
|
+
selectedComms.push(range.target);
|
20649
20734
|
}
|
20650
|
-
|
20735
|
+
});
|
20736
|
+
if (selectedComms.length > 0) {
|
20737
|
+
const ids = selectedComms.map(item => item.props.id);
|
20738
|
+
const commList = this.docCtx.document.treeFilter(item => item.type === 'comm' && ids.indexOf(item.props.id) >= 0);
|
20739
|
+
commList.forEach(item => item.remove());
|
20740
|
+
return;
|
20651
20741
|
}
|
20742
|
+
return;
|
20743
|
+
// const commPairs: Array<CommMarkSelectedStatus> = [];
|
20744
|
+
// const markPairs = this.docCtx.document.commentsContainerElement.markPairs;
|
20745
|
+
// for (let i = 0; i < markPairs.length; i++) {
|
20746
|
+
// const {start: startMark, end: endMark} = markPairs[i];
|
20747
|
+
// if (!startMark || !endMark) {
|
20748
|
+
// continue;
|
20749
|
+
// }
|
20750
|
+
// const commPair: CommMarkSelectedStatus = {
|
20751
|
+
// startMark,
|
20752
|
+
// endMark,
|
20753
|
+
// startMarkStatus: RangeUtil.checkElementFullInRange(selectedRange, startMark),
|
20754
|
+
// endMarkStatus: RangeUtil.checkElementFullInRange(selectedRange, endMark),
|
20755
|
+
// };
|
20756
|
+
// commPairs.push(commPair)
|
20757
|
+
// }
|
20758
|
+
//
|
20759
|
+
// for (let i = 0; i < commPairs.length; i++) {
|
20760
|
+
// const commPair = commPairs[i];
|
20761
|
+
// if (commPair.endMarkStatus) {
|
20762
|
+
// this.removeComment(commPair.endMark.props.id);
|
20763
|
+
// } else if (commPair.startMarkStatus) {
|
20764
|
+
// // const newStartMark = new CommentElement();
|
20765
|
+
// // newStartMark.props.id = commPair.startMark.props.id;
|
20766
|
+
// // commPair.startMark.isDecorate = false;
|
20767
|
+
// // DocumentChange.insertElement(endRange.target, endRange.endOffset, [newStartMark]);
|
20768
|
+
// }
|
20769
|
+
// }
|
20652
20770
|
}
|
20653
20771
|
}
|
20654
20772
|
/**
|
@@ -20656,7 +20774,7 @@ class DocumentComment {
|
|
20656
20774
|
* @param id
|
20657
20775
|
*/
|
20658
20776
|
removeComment(id) {
|
20659
|
-
this.docCtx.document.
|
20777
|
+
this.docCtx.document.removeCommMark(id);
|
20660
20778
|
}
|
20661
20779
|
getCommMarkIndex(commMark) {
|
20662
20780
|
const markType = commMark.props.markType;
|
@@ -20668,7 +20786,7 @@ class DocumentComment {
|
|
20668
20786
|
* 清除所有批注
|
20669
20787
|
*/
|
20670
20788
|
clearAllComments() {
|
20671
|
-
this.docCtx.document.
|
20789
|
+
this.docCtx.document.clearAllComms();
|
20672
20790
|
this.docCtx.selectionState.clear();
|
20673
20791
|
}
|
20674
20792
|
/**
|
@@ -21094,15 +21212,15 @@ class ElementTrackManage {
|
|
21094
21212
|
|
21095
21213
|
class DocumentSvg {
|
21096
21214
|
viewOptions;
|
21097
|
-
|
21215
|
+
sso;
|
21098
21216
|
renderCtx;
|
21099
21217
|
highlights = [];
|
21100
21218
|
mode = "view";
|
21101
21219
|
//当前页位置
|
21102
21220
|
pagePos;
|
21103
|
-
constructor(viewOptions,
|
21221
|
+
constructor(viewOptions, sso, renderCtx) {
|
21104
21222
|
this.viewOptions = viewOptions;
|
21105
|
-
this.
|
21223
|
+
this.sso = sso;
|
21106
21224
|
this.renderCtx = renderCtx;
|
21107
21225
|
}
|
21108
21226
|
getVNode(render, selectionRects, parentPos) {
|
@@ -21112,22 +21230,8 @@ class DocumentSvg {
|
|
21112
21230
|
width: render.rect.width,
|
21113
21231
|
height: render.rect.height
|
21114
21232
|
};
|
21115
|
-
|
21116
|
-
|
21117
|
-
if (render.element && render instanceof LeafRenderObject) {
|
21118
|
-
if (range.isFullSelected) {
|
21119
|
-
selectionRects.push(currPos);
|
21120
|
-
}
|
21121
|
-
else {
|
21122
|
-
if (render.element instanceof TextGroupElement && range.endOffset > range.startOffset) {
|
21123
|
-
const { startX, endX } = ElementUtil.getTextRenderHorX(render, range.startOffset, range.endOffset);
|
21124
|
-
const width = endX - startX;
|
21125
|
-
const x = currPos.x + startX;
|
21126
|
-
selectionRects.push({ x, y: currPos.y, width, height: currPos.height });
|
21127
|
-
}
|
21128
|
-
}
|
21129
|
-
}
|
21130
|
-
}
|
21233
|
+
//处理选区遮罩
|
21234
|
+
this.createSelectionRect(render, selectionRects, currPos);
|
21131
21235
|
//审阅窗口重新计算位置
|
21132
21236
|
if (this.viewOptions.showReviewWindow && render instanceof CommsContainerRenderObject) {
|
21133
21237
|
CommentsUtil.arrangeComments(render);
|
@@ -21191,12 +21295,18 @@ class DocumentSvg {
|
|
21191
21295
|
if (selectionRectsTemp.length > 0) {
|
21192
21296
|
const startX = selectionRectsTemp[0].x;
|
21193
21297
|
const endX = selectionRectsTemp[selectionRectsTemp.length - 1].x + selectionRectsTemp[selectionRectsTemp.length - 1].width;
|
21194
|
-
selectionRects.push({
|
21298
|
+
selectionRects.push({
|
21299
|
+
x: startX,
|
21300
|
+
y: currPos.y,
|
21301
|
+
width: endX - startX,
|
21302
|
+
height: currPos.height,
|
21303
|
+
color: selectionRectsTemp[0].color
|
21304
|
+
});
|
21195
21305
|
selectionRectsTemp.length = 0;
|
21196
21306
|
}
|
21197
21307
|
}
|
21198
21308
|
else if (render instanceof TableCellRenderObject) {
|
21199
|
-
if (this.
|
21309
|
+
if (this.sso.selectionEleSets.has(render.element) && this.sso.selectionEleSets.get(render.element)?.isFullSelected) {
|
21200
21310
|
selectionRects.push(currPos);
|
21201
21311
|
selectionRectsTemp.length = 0;
|
21202
21312
|
}
|
@@ -21238,11 +21348,39 @@ class DocumentSvg {
|
|
21238
21348
|
}
|
21239
21349
|
return currVNode;
|
21240
21350
|
}
|
21351
|
+
createSelectionRect(render, selectionRects, currPos) {
|
21352
|
+
const items = [this.sso.selectionEleSets, this.sso.commRangeSets];
|
21353
|
+
for (const item of items) {
|
21354
|
+
if (item.has(render.element)) {
|
21355
|
+
const range = item.get(render.element);
|
21356
|
+
if (render.element && render instanceof LeafRenderObject) {
|
21357
|
+
if (range.isFullSelected) {
|
21358
|
+
selectionRects.push({ ...currPos, color: range['rangeColor'] });
|
21359
|
+
}
|
21360
|
+
else {
|
21361
|
+
if (render.element instanceof TextGroupElement && range.endOffset > range.startOffset) {
|
21362
|
+
const { startX, endX } = ElementUtil.getTextRenderHorX(render, range.startOffset, range.endOffset);
|
21363
|
+
const width = endX - startX;
|
21364
|
+
const x = currPos.x + startX;
|
21365
|
+
// @ts-ignore
|
21366
|
+
selectionRects.push({
|
21367
|
+
x,
|
21368
|
+
y: currPos.y,
|
21369
|
+
width,
|
21370
|
+
height: currPos.height,
|
21371
|
+
color: range['rangeColor']
|
21372
|
+
});
|
21373
|
+
}
|
21374
|
+
}
|
21375
|
+
}
|
21376
|
+
}
|
21377
|
+
}
|
21378
|
+
}
|
21241
21379
|
getHTMLVNode(docRenders) {
|
21242
21380
|
this.counterMap = {};
|
21243
|
-
|
21381
|
+
return docRenders.filter(item => this.checkInViewBox(item)).map(item => {
|
21244
21382
|
const pageSvg = this.getPageSvgVNode(item);
|
21245
|
-
|
21383
|
+
return {
|
21246
21384
|
sel: 'div.page-unit',
|
21247
21385
|
data: {
|
21248
21386
|
style: {
|
@@ -21257,9 +21395,7 @@ class DocumentSvg {
|
|
21257
21395
|
},
|
21258
21396
|
children: [pageSvg]
|
21259
21397
|
};
|
21260
|
-
return pageUnit;
|
21261
21398
|
});
|
21262
|
-
return pageNodes;
|
21263
21399
|
}
|
21264
21400
|
/**
|
21265
21401
|
* 判断当前元素是否在视窗内
|
@@ -21297,7 +21433,7 @@ class DocumentSvg {
|
|
21297
21433
|
ns: 'http://www.w3.org/2000/svg',
|
21298
21434
|
attrs: {
|
21299
21435
|
stroke: 'none',
|
21300
|
-
fill: 'rgb(85,165,255)',
|
21436
|
+
fill: item.color ?? 'rgb(85,165,255)',
|
21301
21437
|
'paint-order': 'stroke fill markers',
|
21302
21438
|
d: `M${item.x} ${item.y} L${item.x + item.width} ${item.y} L${item.x + item.width} ${item.y + item.height} L${item.x} ${item.y + item.height} Z`,
|
21303
21439
|
'fill-opacity': '0.5'
|
@@ -26307,7 +26443,10 @@ class DocumentPrintOffscreenBase {
|
|
26307
26443
|
const ss = new SelectionState();
|
26308
26444
|
this.docCtx = new EditorContext(ss, this.viewOptions);
|
26309
26445
|
this.renderCtx = this.createRenderCtx(ctx, this.viewOptions, this.docCtx);
|
26310
|
-
this.documentPaint = new DocumentPaint(this.renderCtx, this.docCtx,
|
26446
|
+
this.documentPaint = new DocumentPaint(this.renderCtx, this.docCtx, {
|
26447
|
+
selectionEleSets: new Map(),
|
26448
|
+
commRangeSets: new Map()
|
26449
|
+
});
|
26311
26450
|
this.elementReader = new ElementReader(this.docCtx);
|
26312
26451
|
this.docCtx.syncRefresh = () => {
|
26313
26452
|
};
|
@@ -26322,8 +26461,8 @@ class DocumentPrintOffscreenBase {
|
|
26322
26461
|
// const docProps = this.docCtx.document.props;
|
26323
26462
|
// printNodes(canvasNodes, {...docProps});
|
26324
26463
|
// }
|
26325
|
-
|
26326
|
-
|
26464
|
+
print(data, ranges = null) {
|
26465
|
+
this.prepare(data);
|
26327
26466
|
const canvasNodes = this.getSvgNodes(this.documentPaint.docPages, ranges);
|
26328
26467
|
if (!canvasNodes.length) {
|
26329
26468
|
console.warn('无可打印页');
|
@@ -26338,7 +26477,7 @@ class DocumentPrintOffscreenBase {
|
|
26338
26477
|
/**
|
26339
26478
|
* 续打
|
26340
26479
|
*/
|
26341
|
-
|
26480
|
+
printForContinuation(data, options) {
|
26342
26481
|
this.afterRenderEvent.subscribe((event) => {
|
26343
26482
|
const { index, renderCtx, docRender, pageSvgVNode } = event;
|
26344
26483
|
if (index === options.startDocIndex && options.startY !== 0) {
|
@@ -26352,7 +26491,7 @@ class DocumentPrintOffscreenBase {
|
|
26352
26491
|
pageSvgVNode.data.attrs['clip-path'] = `url(#${'page-clip-' + index})`;
|
26353
26492
|
}
|
26354
26493
|
});
|
26355
|
-
|
26494
|
+
this.prepare(data);
|
26356
26495
|
const printRanges = new Array(this.documentPaint.docPages.length).fill(0).map((item, index) => index).filter(index => index >= options.startDocIndex);
|
26357
26496
|
let svgNodes = this.getSvgNodes(this.documentPaint.docPages, printRanges);
|
26358
26497
|
if (!svgNodes.length) {
|
@@ -26377,8 +26516,8 @@ class DocumentPrintOffscreenBase {
|
|
26377
26516
|
// }
|
26378
26517
|
// return canvasNodes.map(node => node.toDataURL());
|
26379
26518
|
// }
|
26380
|
-
|
26381
|
-
|
26519
|
+
getPrintNodes(data, ranges = null) {
|
26520
|
+
this.prepare(data);
|
26382
26521
|
const canvasNodes = this.getSvgNodes(this.documentPaint.docPages, ranges);
|
26383
26522
|
return canvasNodes;
|
26384
26523
|
}
|
@@ -26389,11 +26528,11 @@ class DocumentPrintOffscreenBase {
|
|
26389
26528
|
* 读取数据,排版
|
26390
26529
|
* @param data
|
26391
26530
|
*/
|
26392
|
-
|
26531
|
+
prepare(data) {
|
26393
26532
|
//将doc的json格式数据读取转化为DocumentElement的树
|
26394
26533
|
this.elementReader.read(data);
|
26395
26534
|
this.documentPaint.rePages();
|
26396
|
-
await Promise.all(this.docCtx.imageLoader.getLoadTasks());
|
26535
|
+
//await Promise.all(this.docCtx.imageLoader.getLoadTasks());
|
26397
26536
|
const { scale, docPageSettings: { width, height } } = this.viewOptions;
|
26398
26537
|
this.renderCtx.update({ scale, width, height });
|
26399
26538
|
ElementUtil.setCanvasProps(this.renderCtx.mainContext.ctx.canvas, this.renderCtx.mainContext.ctx, {
|
@@ -26428,7 +26567,10 @@ class DocumentPrintOffscreenBase {
|
|
26428
26567
|
// return canvasList;
|
26429
26568
|
// }
|
26430
26569
|
getSvgNodes(docRenders, printRanges = null) {
|
26431
|
-
const docSvgHelper = new DocumentSvg(this.viewOptions,
|
26570
|
+
const docSvgHelper = new DocumentSvg(this.viewOptions, {
|
26571
|
+
selectionEleSets: new Map,
|
26572
|
+
commRangeSets: new Map()
|
26573
|
+
}, this.renderCtx); //.getHTMLVNode(docRenders) as Array<EditorVNodeObject>;
|
26432
26574
|
docSvgHelper.mode = 'print';
|
26433
26575
|
const patch = init([
|
26434
26576
|
modules.class,
|
@@ -26472,31 +26614,6 @@ class DocumentPrintOffscreen extends DocumentPrintOffscreenBase {
|
|
26472
26614
|
}
|
26473
26615
|
}
|
26474
26616
|
|
26475
|
-
let activeEditorContext = null;
|
26476
|
-
function setActiveEditorContext(ctx) {
|
26477
|
-
activeEditorContext = ctx;
|
26478
|
-
}
|
26479
|
-
function createSignal(state) {
|
26480
|
-
let _state = state;
|
26481
|
-
const activeCtx = activeEditorContext;
|
26482
|
-
const signal = {
|
26483
|
-
get value() {
|
26484
|
-
return _state;
|
26485
|
-
},
|
26486
|
-
set value(v) {
|
26487
|
-
if (v === _state) {
|
26488
|
-
return;
|
26489
|
-
}
|
26490
|
-
_state = v;
|
26491
|
-
signal.onChange();
|
26492
|
-
},
|
26493
|
-
onChange: () => {
|
26494
|
-
activeCtx?.onChange();
|
26495
|
-
}
|
26496
|
-
};
|
26497
|
-
return signal;
|
26498
|
-
}
|
26499
|
-
|
26500
26617
|
/**
|
26501
26618
|
* 渲染日历虚拟节点处理类
|
26502
26619
|
*/
|
@@ -27365,6 +27482,8 @@ class DocEditor {
|
|
27365
27482
|
onDestroy = new Subject$1();
|
27366
27483
|
beforeNodePatch = new Subject$1();
|
27367
27484
|
afterNodePatch = new Subject$1();
|
27485
|
+
//自定义事件传递消息
|
27486
|
+
eventBus;
|
27368
27487
|
editInput;
|
27369
27488
|
scrollContainer;
|
27370
27489
|
constructor(svgContainer) {
|
@@ -27395,13 +27514,14 @@ class DocEditor {
|
|
27395
27514
|
this.renderContext.init({ width: 500, height: 500, scale: 1 });
|
27396
27515
|
this.selectionState = this.documentSelection.selectionState;
|
27397
27516
|
this.selectionOverlays = new SelectionOverlays(this.documentSelection.selectionState);
|
27398
|
-
this.documentPaint = new DocumentPaint(this.renderContext, this.docCtx, this.selectionOverlays
|
27517
|
+
this.documentPaint = new DocumentPaint(this.renderContext, this.docCtx, this.selectionOverlays);
|
27399
27518
|
this.documentInput = new DocumentInput(this.docCtx);
|
27400
27519
|
this.docComment = new DocumentComment(this.docCtx);
|
27401
27520
|
this.elementReader = new ElementReader(this.docCtx);
|
27402
27521
|
this.documentChange = new DocumentChange(this.elementReader, this.docCtx, this.docComment, this.documentInput);
|
27403
27522
|
this.documentEvent = new DocumentEvent(this.documentPaint, this.docCtx, this.documentInput);
|
27404
27523
|
this.historyMange = new ElementTrackManage(this.docCtx, this.elementReader);
|
27524
|
+
this.eventBus = new EventBus();
|
27405
27525
|
this.createPatch();
|
27406
27526
|
this.documentEvent.hitInfoChanged.subscribe((hitInfo) => {
|
27407
27527
|
this.hitInfoChanged(hitInfo);
|
@@ -27941,6 +28061,7 @@ class DocEditor {
|
|
27941
28061
|
insertTable(rows, cols) {
|
27942
28062
|
const tb = TableUtil.createTable(rows, cols, this.selectionState);
|
27943
28063
|
this.documentChange.insertTable(tb);
|
28064
|
+
return tb;
|
27944
28065
|
}
|
27945
28066
|
/**
|
27946
28067
|
* 插入软换行符
|
@@ -27985,6 +28106,7 @@ class DocEditor {
|
|
27985
28106
|
this.docCtx.destroy();
|
27986
28107
|
this.documentEvent.clearSubEvent();
|
27987
28108
|
this.selectionState.destroy();
|
28109
|
+
this.eventBus.clear();
|
27988
28110
|
this.destroyDOM();
|
27989
28111
|
this.flushTask = null;
|
27990
28112
|
Object.keys(this).forEach(key => {
|
@@ -28498,7 +28620,7 @@ class DocEditor {
|
|
28498
28620
|
this.tipContainer = tipsContainer;
|
28499
28621
|
docContent.data.style.height = this.documentPaint.getDocumentContainerHeight().height + 'px';
|
28500
28622
|
const docRenders = this.documentPaint.docContainer.getItems();
|
28501
|
-
const svgGenerator = new DocumentSvg(this.viewOptions, this.selectionOverlays
|
28623
|
+
const svgGenerator = new DocumentSvg(this.viewOptions, this.selectionOverlays, this.renderContext);
|
28502
28624
|
const vNode = svgGenerator.getHTMLVNode(docRenders);
|
28503
28625
|
const children = docContent.children;
|
28504
28626
|
children.push(tipsContainer);
|
@@ -28805,7 +28927,7 @@ class DocEditor {
|
|
28805
28927
|
rule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
28806
28928
|
}
|
28807
28929
|
version() {
|
28808
|
-
return "2.1.
|
28930
|
+
return "2.1.19";
|
28809
28931
|
}
|
28810
28932
|
switchPageHeaderEditor() {
|
28811
28933
|
this.docCtx.document.switchPageHeaderEditor(this.selectionState, null);
|
@@ -28815,6 +28937,9 @@ class DocEditor {
|
|
28815
28937
|
const paraTexts = paras.map(item => ElementSerialize.serializeString(item, { all: false }));
|
28816
28938
|
return paraTexts.join('\n');
|
28817
28939
|
}
|
28940
|
+
emit(event, args) {
|
28941
|
+
this.eventBus.emit(event, args);
|
28942
|
+
}
|
28818
28943
|
}
|
28819
28944
|
|
28820
28945
|
/**
|
@@ -28986,5 +29111,5 @@ function removeDuplicatesEvent(events) {
|
|
28986
29111
|
return arr;
|
28987
29112
|
}
|
28988
29113
|
|
28989
|
-
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, CommentsUtil, 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,
|
29114
|
+
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, CommentsUtil, 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, DocumentPaint, DocumentPrintOffscreen, DocumentPrintOffscreenBase, DocumentProps, DocumentRenderObject, DocumentSelection, DocumentTemplate, DropElementEvent, EditMode, EditorContext, Element, ElementEvent, ElementFactory, ElementPaint, ElementReader, ElementSerialize, ElementUtil, EventBus, EventMap, EventSourceCore$1 as EventSourceCore, FillNullSpaceElement, FillNullSpaceRenderObject, GetTrackTipsEvent, GotCursorEvent, IDispose, INotifyPropertyChanged, InlineBlockContainer, InlineGroupElement, InlineGroupInputElement, InlineGroupRenderObject, InlineMuiltBlockLineRenderObject, InputElementEvent, IsInSideDataElement, IsInSideInlineGroupInputElement, KeyboradElementEvent, LeafElement, LeafRenderObject, LostCursorEvent, MarginProps, ModifyFlag$1 as ModifyFlag, MouseElementEvent, MousedownElementEvent, MuiltBlockLineRenderObject, OnceSubject, PSymbolElement, PSymbolRenderObject, PaddingProps, PageBreakElement, PageBreakFactory, PageBreakRenderObject, PageOptions, PaintContent, ParagraphElement, ParagraphFactory, ParagraphLineRectRenderObject, ParagraphNumberType, ParagraphProps, ParagraphRenderObject, PasteElementEvent, PictureElement, PictureFactory, PictureProps, PictureRenderObject, RadioBoxElement, RadioBoxFactory, RadioBoxProps, RadioBoxRenderObject, RangeUtil, Rect, RenderContext, RenderObject, RenderObjectType, ResizeLeafRenderObject, RunElementFactory, SelectionOverlays, SelectionRange, SelectionState, Subject$1 as Subject, SubjectSubscription$1 as SubjectSubscription, Subscription$1 as Subscription, TabElement, TabFactory, TabRenderObject, TableCellElement, TableCellFactory, TableCellProps, TableCellRenderObject, TableElement, TableFactory, TableProps, TableRenderObject, TableRowElement, TableRowFactory, TableRowProps, TableRowRenderObject, TableSplitCell, TableUtil, TextGroupElement, TextGroupFactory, TextGroupRenderObject, TextProps, TrackRunElement, TrackRunProps, TrackRunRenderObject, TrackRunTypeEnum, ValidateCondition, ValidateElement, ValidateProps, ValidateRenderObject, ViewOptions, clearChildrenRenderCache, clearTraces, createPrintTemplate, defaultParaHanging, deleteCurrentParagraph, docOpsMap, documentPrint, drawDecorator, elementTypeEventHandler, exportDecoratorHTML, falseChar, fontMapFunc, formatEle, fromEvent, generatePatch, getCalleeName, getFocusTextSegment, inputText, insertEle, invokeTypeHandler, isDate, logUpdateEleProps, objectToString$4 as objectToString, onTableContextmenu, onceTask, parser, printNodes, reactiveMap, removeEle, removeText, runTextLineRender, setChildrenModifyFlag, setDataElementProps, setNotifyChangedCallback, setTraceTrackingFlag, suppressTracking, targetMaps, textLineRenderMode, toRawType, toTypeString, trueChar, validateDataEle, validateDataEleRenderObj, validateInlineInputRenderObj, watchChanged };
|
28990
29115
|
//# sourceMappingURL=index.js.map
|