@hufe921/canvas-editor 0.9.42 → 0.9.44
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/CHANGELOG.md +26 -0
- package/dist/canvas-editor.es.js +428 -166
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +28 -23
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/command/Command.d.ts +2 -0
- package/dist/src/editor/core/command/CommandAdapt.d.ts +5 -3
- package/dist/src/editor/core/cursor/Cursor.d.ts +7 -0
- package/dist/src/editor/core/draw/Draw.d.ts +4 -2
- package/dist/src/editor/core/draw/control/Control.d.ts +3 -0
- package/dist/src/editor/core/range/RangeManager.d.ts +3 -0
- package/dist/src/editor/dataset/enum/Editor.d.ts +3 -1
- package/dist/src/editor/interface/Draw.d.ts +5 -1
- package/dist/src/editor/interface/Editor.d.ts +2 -0
- package/dist/src/editor/utils/element.d.ts +2 -0
- package/dist/src/editor/utils/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/canvas-editor.es.js
CHANGED
|
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23
23
|
return value;
|
|
24
24
|
};
|
|
25
25
|
var index = "";
|
|
26
|
-
const version = "0.9.
|
|
26
|
+
const version = "0.9.44";
|
|
27
27
|
var MaxHeightRatio;
|
|
28
28
|
(function(MaxHeightRatio2) {
|
|
29
29
|
MaxHeightRatio2["HALF"] = "half";
|
|
@@ -244,6 +244,18 @@ function convertStringToBase64(input2) {
|
|
|
244
244
|
const base64 = window.btoa(charArray.join(""));
|
|
245
245
|
return base64;
|
|
246
246
|
}
|
|
247
|
+
function findScrollContainer(element) {
|
|
248
|
+
let parent = element.parentElement;
|
|
249
|
+
while (parent) {
|
|
250
|
+
const style = window.getComputedStyle(parent);
|
|
251
|
+
const overflowY = style.getPropertyValue("overflow-y");
|
|
252
|
+
if (parent.scrollHeight > parent.clientHeight && (overflowY === "auto" || overflowY === "scroll")) {
|
|
253
|
+
return parent;
|
|
254
|
+
}
|
|
255
|
+
parent = parent.parentElement;
|
|
256
|
+
}
|
|
257
|
+
return document.documentElement;
|
|
258
|
+
}
|
|
247
259
|
const CURSOR_AGENT_HEIGHT = 12;
|
|
248
260
|
const defaultCursorOption = {
|
|
249
261
|
width: 1,
|
|
@@ -253,6 +265,13 @@ const defaultCursorOption = {
|
|
|
253
265
|
};
|
|
254
266
|
const EDITOR_COMPONENT = "editor-component";
|
|
255
267
|
const EDITOR_PREFIX = "ce";
|
|
268
|
+
var MoveDirection;
|
|
269
|
+
(function(MoveDirection2) {
|
|
270
|
+
MoveDirection2["UP"] = "top";
|
|
271
|
+
MoveDirection2["DOWN"] = "down";
|
|
272
|
+
MoveDirection2["LEFT"] = "left";
|
|
273
|
+
MoveDirection2["RIGHT"] = "right";
|
|
274
|
+
})(MoveDirection || (MoveDirection = {}));
|
|
256
275
|
var ElementType;
|
|
257
276
|
(function(ElementType2) {
|
|
258
277
|
ElementType2["TEXT"] = "text";
|
|
@@ -4076,6 +4095,32 @@ function convertElementToDom(element, options) {
|
|
|
4076
4095
|
dom.innerText = element.value.replace(new RegExp(`${ZERO}`, "g"), "\n");
|
|
4077
4096
|
return dom;
|
|
4078
4097
|
}
|
|
4098
|
+
function splitListElement(elementList) {
|
|
4099
|
+
let curListIndex = 0;
|
|
4100
|
+
const listElementListMap = new Map();
|
|
4101
|
+
for (let e = 0; e < elementList.length; e++) {
|
|
4102
|
+
const element = elementList[e];
|
|
4103
|
+
if (element.listWrap) {
|
|
4104
|
+
const listElementList = listElementListMap.get(curListIndex) || [];
|
|
4105
|
+
listElementList.push(element);
|
|
4106
|
+
listElementListMap.set(curListIndex, listElementList);
|
|
4107
|
+
} else {
|
|
4108
|
+
const valueList = element.value.split("\n");
|
|
4109
|
+
for (let c = 0; c < valueList.length; c++) {
|
|
4110
|
+
if (c > 0) {
|
|
4111
|
+
curListIndex += 1;
|
|
4112
|
+
}
|
|
4113
|
+
const value = valueList[c];
|
|
4114
|
+
const listElementList = listElementListMap.get(curListIndex) || [];
|
|
4115
|
+
listElementList.push(__spreadProps(__spreadValues({}, element), {
|
|
4116
|
+
value
|
|
4117
|
+
}));
|
|
4118
|
+
listElementListMap.set(curListIndex, listElementList);
|
|
4119
|
+
}
|
|
4120
|
+
}
|
|
4121
|
+
}
|
|
4122
|
+
return listElementListMap;
|
|
4123
|
+
}
|
|
4079
4124
|
function createDomFromElementList(elementList, options) {
|
|
4080
4125
|
function buildDom(payload) {
|
|
4081
4126
|
var _a, _b, _c, _d, _e;
|
|
@@ -4121,30 +4166,8 @@ function createDomFromElementList(elementList, options) {
|
|
|
4121
4166
|
if (element.listStyle) {
|
|
4122
4167
|
list.style.listStyleType = listStyleCSSMapping[element.listStyle];
|
|
4123
4168
|
}
|
|
4124
|
-
let curListIndex = 0;
|
|
4125
|
-
const listElementListMap = new Map();
|
|
4126
4169
|
const zipList = zipElementList(element.valueList);
|
|
4127
|
-
|
|
4128
|
-
const zipElement = zipList[z];
|
|
4129
|
-
if (zipElement.listWrap) {
|
|
4130
|
-
const listElementList = listElementListMap.get(curListIndex) || [];
|
|
4131
|
-
listElementList.push(zipElement);
|
|
4132
|
-
listElementListMap.set(curListIndex, listElementList);
|
|
4133
|
-
} else {
|
|
4134
|
-
const zipValueList = zipElement.value.split("\n");
|
|
4135
|
-
for (let c = 0; c < zipValueList.length; c++) {
|
|
4136
|
-
if (c > 0) {
|
|
4137
|
-
curListIndex += 1;
|
|
4138
|
-
}
|
|
4139
|
-
const value = zipValueList[c];
|
|
4140
|
-
const listElementList = listElementListMap.get(curListIndex) || [];
|
|
4141
|
-
listElementList.push(__spreadProps(__spreadValues({}, zipElement), {
|
|
4142
|
-
value
|
|
4143
|
-
}));
|
|
4144
|
-
listElementListMap.set(curListIndex, listElementList);
|
|
4145
|
-
}
|
|
4146
|
-
}
|
|
4147
|
-
}
|
|
4170
|
+
const listElementListMap = splitListElement(zipList);
|
|
4148
4171
|
listElementListMap.forEach((listElementList) => {
|
|
4149
4172
|
const li = document.createElement("li");
|
|
4150
4173
|
const childDom = buildDom(listElementList);
|
|
@@ -4387,6 +4410,58 @@ function getElementListByHTML(htmlText, options) {
|
|
|
4387
4410
|
clipboardDom.remove();
|
|
4388
4411
|
return elementList;
|
|
4389
4412
|
}
|
|
4413
|
+
function getTextFromElementList(elementList) {
|
|
4414
|
+
function buildText(payload) {
|
|
4415
|
+
var _a, _b, _c, _d;
|
|
4416
|
+
let text = "";
|
|
4417
|
+
for (let e = 0; e < payload.length; e++) {
|
|
4418
|
+
const element = payload[e];
|
|
4419
|
+
if (element.type === ElementType.TABLE) {
|
|
4420
|
+
text += `
|
|
4421
|
+
`;
|
|
4422
|
+
const trList = element.trList;
|
|
4423
|
+
for (let t = 0; t < trList.length; t++) {
|
|
4424
|
+
const tr = trList[t];
|
|
4425
|
+
for (let d = 0; d < tr.tdList.length; d++) {
|
|
4426
|
+
const td = tr.tdList[d];
|
|
4427
|
+
const tdText = buildText(zipElementList(td.value));
|
|
4428
|
+
const isFirst = d === 0;
|
|
4429
|
+
const isLast = tr.tdList.length - 1 === d;
|
|
4430
|
+
text += `${!isFirst ? ` ` : ``}${tdText}${isLast ? `
|
|
4431
|
+
` : ``}`;
|
|
4432
|
+
}
|
|
4433
|
+
}
|
|
4434
|
+
} else if (element.type === ElementType.HYPERLINK) {
|
|
4435
|
+
text += element.valueList.map((v) => v.value).join("");
|
|
4436
|
+
} else if (element.type === ElementType.TITLE) {
|
|
4437
|
+
text += `${buildText(zipElementList(element.valueList))}`;
|
|
4438
|
+
} else if (element.type === ElementType.LIST) {
|
|
4439
|
+
const zipList = zipElementList(element.valueList);
|
|
4440
|
+
const listElementListMap = splitListElement(zipList);
|
|
4441
|
+
listElementListMap.forEach((listElementList, listIndex) => {
|
|
4442
|
+
const isLast = listElementListMap.size - 1 === listIndex;
|
|
4443
|
+
text += `
|
|
4444
|
+
${listIndex + 1}.${buildText(listElementList)}${isLast ? `
|
|
4445
|
+
` : ``}`;
|
|
4446
|
+
});
|
|
4447
|
+
} else if (element.type === ElementType.CHECKBOX) {
|
|
4448
|
+
text += ((_a = element.checkbox) == null ? void 0 : _a.value) ? `\u2611` : `\u25A1`;
|
|
4449
|
+
} else if (!element.type || element.type === ElementType.LATEX || TEXTLIKE_ELEMENT_TYPE.includes(element.type)) {
|
|
4450
|
+
let textLike = "";
|
|
4451
|
+
if (element.type === ElementType.CONTROL) {
|
|
4452
|
+
textLike = ((_c = (_b = element.control.value) == null ? void 0 : _b[0]) == null ? void 0 : _c.value) || "";
|
|
4453
|
+
} else if (element.type === ElementType.DATE) {
|
|
4454
|
+
textLike = ((_d = element.valueList) == null ? void 0 : _d.map((v) => v.value).join("")) || "";
|
|
4455
|
+
} else {
|
|
4456
|
+
textLike = element.value;
|
|
4457
|
+
}
|
|
4458
|
+
text += textLike.replace(new RegExp(`${ZERO}`, "g"), "\n");
|
|
4459
|
+
}
|
|
4460
|
+
}
|
|
4461
|
+
return text;
|
|
4462
|
+
}
|
|
4463
|
+
return buildText(zipElementList(elementList));
|
|
4464
|
+
}
|
|
4390
4465
|
class CursorAgent {
|
|
4391
4466
|
constructor(draw, canvasEvent) {
|
|
4392
4467
|
__publicField(this, "draw");
|
|
@@ -4619,6 +4694,40 @@ class Cursor {
|
|
|
4619
4694
|
this.cursorDom.style.display = "none";
|
|
4620
4695
|
this._clearBlinkTimeout();
|
|
4621
4696
|
}
|
|
4697
|
+
moveCursorToVisible(payload) {
|
|
4698
|
+
const { cursorPosition, direction } = payload;
|
|
4699
|
+
if (!cursorPosition || !direction)
|
|
4700
|
+
return;
|
|
4701
|
+
const { pageNo, coordinate: { leftTop, leftBottom } } = cursorPosition;
|
|
4702
|
+
const prePageY = pageNo * (this.draw.getHeight() + this.draw.getPageGap()) + this.container.getBoundingClientRect().top;
|
|
4703
|
+
const isUp = direction === MoveDirection.UP;
|
|
4704
|
+
const x = leftBottom[0];
|
|
4705
|
+
const y = isUp ? leftTop[1] + prePageY : leftBottom[1] + prePageY;
|
|
4706
|
+
const scrollContainer = findScrollContainer(this.container);
|
|
4707
|
+
const rect = {
|
|
4708
|
+
left: 0,
|
|
4709
|
+
right: 0,
|
|
4710
|
+
top: 0,
|
|
4711
|
+
bottom: 0
|
|
4712
|
+
};
|
|
4713
|
+
if (scrollContainer === document.documentElement) {
|
|
4714
|
+
rect.right = window.innerWidth;
|
|
4715
|
+
rect.bottom = window.innerHeight;
|
|
4716
|
+
} else {
|
|
4717
|
+
const { left, right, top, bottom } = scrollContainer.getBoundingClientRect();
|
|
4718
|
+
rect.left = left;
|
|
4719
|
+
rect.right = right;
|
|
4720
|
+
rect.top = top;
|
|
4721
|
+
rect.bottom = bottom;
|
|
4722
|
+
}
|
|
4723
|
+
const { maskMargin } = this.options;
|
|
4724
|
+
rect.top += maskMargin[0];
|
|
4725
|
+
rect.bottom -= maskMargin[2];
|
|
4726
|
+
if (!(x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom)) {
|
|
4727
|
+
const { scrollLeft, scrollTop } = scrollContainer;
|
|
4728
|
+
isUp ? scrollContainer.scroll(scrollLeft, scrollTop - (rect.top - y)) : scrollContainer.scroll(scrollLeft, scrollTop + y - rect.bottom);
|
|
4729
|
+
}
|
|
4730
|
+
}
|
|
4622
4731
|
}
|
|
4623
4732
|
var MouseEventButton;
|
|
4624
4733
|
(function(MouseEventButton2) {
|
|
@@ -4925,6 +5034,8 @@ function mouseup(evt, host) {
|
|
|
4925
5034
|
var _a, _b, _c;
|
|
4926
5035
|
if (host.isAllowDrop) {
|
|
4927
5036
|
const draw = host.getDraw();
|
|
5037
|
+
if (draw.isReadonly())
|
|
5038
|
+
return;
|
|
4928
5039
|
const position = draw.getPosition();
|
|
4929
5040
|
const positionList = position.getPositionList();
|
|
4930
5041
|
const rangeManager = draw.getRange();
|
|
@@ -5275,7 +5386,6 @@ function keydown(evt, host) {
|
|
|
5275
5386
|
if (isReadonly)
|
|
5276
5387
|
return;
|
|
5277
5388
|
let anchorPosition = cursorPosition;
|
|
5278
|
-
const isUp = evt.key === KeyMap.Up;
|
|
5279
5389
|
if (evt.shiftKey) {
|
|
5280
5390
|
if (startIndex === cursorPosition.index) {
|
|
5281
5391
|
anchorPosition = positionList[endIndex];
|
|
@@ -5283,62 +5393,83 @@ function keydown(evt, host) {
|
|
|
5283
5393
|
anchorPosition = positionList[startIndex];
|
|
5284
5394
|
}
|
|
5285
5395
|
}
|
|
5286
|
-
const {
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
const curDistance = position2.coordinate.rightTop[0] - leftTop[0];
|
|
5302
|
-
if (curDistance > maxDistance) {
|
|
5303
|
-
maxIndex = position2.index;
|
|
5304
|
-
maxDistance = curDistance;
|
|
5305
|
-
break;
|
|
5306
|
-
}
|
|
5396
|
+
const { index: index22, rowNo, rowIndex, coordinate: { leftTop: [curLeftX], rightTop: [curRightX] } } = anchorPosition;
|
|
5397
|
+
const isUp = evt.key === KeyMap.Up;
|
|
5398
|
+
if (isUp && rowIndex === 0 || !isUp && rowIndex === draw.getRowCount() - 1) {
|
|
5399
|
+
return;
|
|
5400
|
+
}
|
|
5401
|
+
const probablePosition = [];
|
|
5402
|
+
if (isUp) {
|
|
5403
|
+
let p = index22 - 1;
|
|
5404
|
+
while (p > 0) {
|
|
5405
|
+
const position2 = positionList[p];
|
|
5406
|
+
p--;
|
|
5407
|
+
if (position2.rowNo === rowNo)
|
|
5408
|
+
continue;
|
|
5409
|
+
if (probablePosition[0] && probablePosition[0].rowNo !== position2.rowNo) {
|
|
5410
|
+
break;
|
|
5307
5411
|
}
|
|
5308
|
-
|
|
5309
|
-
|
|
5412
|
+
probablePosition.unshift(position2);
|
|
5413
|
+
}
|
|
5414
|
+
} else {
|
|
5415
|
+
let p = index22 + 1;
|
|
5416
|
+
while (p < positionList.length) {
|
|
5417
|
+
const position2 = positionList[p];
|
|
5418
|
+
p++;
|
|
5419
|
+
if (position2.rowNo === rowNo)
|
|
5420
|
+
continue;
|
|
5421
|
+
if (probablePosition[0] && probablePosition[0].rowNo !== position2.rowNo) {
|
|
5422
|
+
break;
|
|
5310
5423
|
}
|
|
5424
|
+
probablePosition.push(position2);
|
|
5311
5425
|
}
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5426
|
+
}
|
|
5427
|
+
let nextIndex = 0;
|
|
5428
|
+
for (let p = 0; p < probablePosition.length; p++) {
|
|
5429
|
+
const nextPosition = probablePosition[p];
|
|
5430
|
+
const { coordinate: { leftTop: [nextLeftX], rightTop: [nextRightX] } } = nextPosition;
|
|
5431
|
+
if (p === probablePosition.length - 1) {
|
|
5432
|
+
nextIndex = nextPosition.index;
|
|
5433
|
+
}
|
|
5434
|
+
if (curRightX <= nextLeftX || curLeftX >= nextRightX)
|
|
5435
|
+
continue;
|
|
5436
|
+
nextIndex = nextPosition.index;
|
|
5437
|
+
break;
|
|
5438
|
+
}
|
|
5439
|
+
if (!nextIndex)
|
|
5440
|
+
return;
|
|
5441
|
+
let anchorStartIndex = nextIndex;
|
|
5442
|
+
let anchorEndIndex = nextIndex;
|
|
5443
|
+
if (evt.shiftKey) {
|
|
5444
|
+
if (startIndex !== endIndex) {
|
|
5445
|
+
if (startIndex === cursorPosition.index) {
|
|
5446
|
+
anchorStartIndex = startIndex;
|
|
5322
5447
|
} else {
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5448
|
+
anchorEndIndex = endIndex;
|
|
5449
|
+
}
|
|
5450
|
+
} else {
|
|
5451
|
+
if (isUp) {
|
|
5452
|
+
anchorEndIndex = endIndex;
|
|
5453
|
+
} else {
|
|
5454
|
+
anchorStartIndex = startIndex;
|
|
5328
5455
|
}
|
|
5329
5456
|
}
|
|
5330
|
-
if (anchorStartIndex > anchorEndIndex) {
|
|
5331
|
-
[anchorStartIndex, anchorEndIndex] = [anchorEndIndex, anchorStartIndex];
|
|
5332
|
-
}
|
|
5333
|
-
rangeManager.setRange(anchorStartIndex, anchorEndIndex);
|
|
5334
|
-
const isCollapsed2 = anchorStartIndex === anchorEndIndex;
|
|
5335
|
-
draw.render({
|
|
5336
|
-
curIndex: isCollapsed2 ? anchorStartIndex : void 0,
|
|
5337
|
-
isSetCursor: isCollapsed2,
|
|
5338
|
-
isSubmitHistory: false,
|
|
5339
|
-
isCompute: false
|
|
5340
|
-
});
|
|
5341
5457
|
}
|
|
5458
|
+
if (anchorStartIndex > anchorEndIndex) {
|
|
5459
|
+
[anchorStartIndex, anchorEndIndex] = [anchorEndIndex, anchorStartIndex];
|
|
5460
|
+
}
|
|
5461
|
+
rangeManager.setRange(anchorStartIndex, anchorEndIndex);
|
|
5462
|
+
const isCollapsed2 = anchorStartIndex === anchorEndIndex;
|
|
5463
|
+
draw.render({
|
|
5464
|
+
curIndex: isCollapsed2 ? anchorStartIndex : void 0,
|
|
5465
|
+
isSetCursor: isCollapsed2,
|
|
5466
|
+
isSubmitHistory: false,
|
|
5467
|
+
isCompute: false
|
|
5468
|
+
});
|
|
5469
|
+
draw.getCursor().moveCursorToVisible({
|
|
5470
|
+
cursorPosition: positionList[isUp ? anchorStartIndex : anchorEndIndex],
|
|
5471
|
+
direction: isUp ? MoveDirection.UP : MoveDirection.DOWN
|
|
5472
|
+
});
|
|
5342
5473
|
} else if (isMod(evt) && evt.key === KeyMap.Z) {
|
|
5343
5474
|
if (isReadonly)
|
|
5344
5475
|
return;
|
|
@@ -6056,6 +6187,8 @@ var EditorMode;
|
|
|
6056
6187
|
EditorMode2["EDIT"] = "edit";
|
|
6057
6188
|
EditorMode2["CLEAN"] = "clean";
|
|
6058
6189
|
EditorMode2["READONLY"] = "readonly";
|
|
6190
|
+
EditorMode2["FORM"] = "form";
|
|
6191
|
+
EditorMode2["PRINT"] = "print";
|
|
6059
6192
|
})(EditorMode || (EditorMode = {}));
|
|
6060
6193
|
var EditorZone;
|
|
6061
6194
|
(function(EditorZone2) {
|
|
@@ -6419,11 +6552,10 @@ class Position {
|
|
|
6419
6552
|
};
|
|
6420
6553
|
}
|
|
6421
6554
|
adjustPositionContext(payload) {
|
|
6422
|
-
const isReadonly = this.draw.isReadonly();
|
|
6423
6555
|
const positionResult = this.getPositionByXY(payload);
|
|
6424
6556
|
if (!~positionResult.index)
|
|
6425
6557
|
return null;
|
|
6426
|
-
if (positionResult.isControl &&
|
|
6558
|
+
if (positionResult.isControl && this.draw.getMode() !== EditorMode.READONLY) {
|
|
6427
6559
|
const { index: index22, isTable: isTable2, trIndex: trIndex2, tdIndex: tdIndex2, tdValueIndex } = positionResult;
|
|
6428
6560
|
const control = this.draw.getControl();
|
|
6429
6561
|
const { newIndex } = control.moveCursor({
|
|
@@ -6491,12 +6623,35 @@ class RangeManager {
|
|
|
6491
6623
|
const elementList = this.draw.getElementList();
|
|
6492
6624
|
return elementList.slice(startIndex + 1, endIndex + 1);
|
|
6493
6625
|
}
|
|
6626
|
+
getSelectionElementList() {
|
|
6627
|
+
if (this.range.isCrossRowCol) {
|
|
6628
|
+
const rowCol = this.draw.getTableParticle().getRangeRowCol();
|
|
6629
|
+
if (!rowCol)
|
|
6630
|
+
return null;
|
|
6631
|
+
const elementList = [];
|
|
6632
|
+
for (let r = 0; r < rowCol.length; r++) {
|
|
6633
|
+
const row = rowCol[r];
|
|
6634
|
+
for (let c = 0; c < row.length; c++) {
|
|
6635
|
+
const col = row[c];
|
|
6636
|
+
elementList.push(...col.value);
|
|
6637
|
+
}
|
|
6638
|
+
}
|
|
6639
|
+
return elementList;
|
|
6640
|
+
}
|
|
6641
|
+
return this.getSelection();
|
|
6642
|
+
}
|
|
6494
6643
|
getTextLikeSelection() {
|
|
6495
6644
|
const selection = this.getSelection();
|
|
6496
6645
|
if (!selection)
|
|
6497
6646
|
return null;
|
|
6498
6647
|
return selection.filter((s) => !s.type || TEXTLIKE_ELEMENT_TYPE.includes(s.type));
|
|
6499
6648
|
}
|
|
6649
|
+
getTextLikeSelectionElementList() {
|
|
6650
|
+
const selection = this.getSelectionElementList();
|
|
6651
|
+
if (!selection)
|
|
6652
|
+
return null;
|
|
6653
|
+
return selection.filter((s) => !s.type || TEXTLIKE_ELEMENT_TYPE.includes(s.type));
|
|
6654
|
+
}
|
|
6500
6655
|
getRangeRow() {
|
|
6501
6656
|
const { startIndex, endIndex } = this.range;
|
|
6502
6657
|
if (!~startIndex && !~endIndex)
|
|
@@ -6516,6 +6671,30 @@ class RangeManager {
|
|
|
6516
6671
|
}
|
|
6517
6672
|
return rangeRow;
|
|
6518
6673
|
}
|
|
6674
|
+
getRangeRowElementList() {
|
|
6675
|
+
const { startIndex, endIndex, isCrossRowCol } = this.range;
|
|
6676
|
+
if (!~startIndex && !~endIndex)
|
|
6677
|
+
return null;
|
|
6678
|
+
if (isCrossRowCol) {
|
|
6679
|
+
return this.getSelectionElementList();
|
|
6680
|
+
}
|
|
6681
|
+
const rangeRow = this.getRangeRow();
|
|
6682
|
+
if (!rangeRow)
|
|
6683
|
+
return null;
|
|
6684
|
+
const positionList = this.position.getPositionList();
|
|
6685
|
+
const elementList = this.draw.getElementList();
|
|
6686
|
+
const rowElementList = [];
|
|
6687
|
+
for (let p = 0; p < positionList.length; p++) {
|
|
6688
|
+
const position = positionList[p];
|
|
6689
|
+
const rowSet = rangeRow.get(position.pageNo);
|
|
6690
|
+
if (!rowSet)
|
|
6691
|
+
continue;
|
|
6692
|
+
if (rowSet.has(position.rowNo)) {
|
|
6693
|
+
rowElementList.push(elementList[p]);
|
|
6694
|
+
}
|
|
6695
|
+
}
|
|
6696
|
+
return rowElementList;
|
|
6697
|
+
}
|
|
6519
6698
|
getRangeParagraph() {
|
|
6520
6699
|
var _a, _b, _c;
|
|
6521
6700
|
const { startIndex, endIndex } = this.range;
|
|
@@ -6810,7 +6989,7 @@ class RangeManager {
|
|
|
6810
6989
|
ctx.restore();
|
|
6811
6990
|
}
|
|
6812
6991
|
toString() {
|
|
6813
|
-
const selection = this.
|
|
6992
|
+
const selection = this.getTextLikeSelection();
|
|
6814
6993
|
if (!selection)
|
|
6815
6994
|
return "";
|
|
6816
6995
|
return selection.map((s) => s.value).join("").replace(new RegExp(ZERO, "g"), "");
|
|
@@ -7409,13 +7588,6 @@ class ScrollObserver {
|
|
|
7409
7588
|
};
|
|
7410
7589
|
}
|
|
7411
7590
|
}
|
|
7412
|
-
var MoveDirection;
|
|
7413
|
-
(function(MoveDirection2) {
|
|
7414
|
-
MoveDirection2["UP"] = "top";
|
|
7415
|
-
MoveDirection2["DOWN"] = "down";
|
|
7416
|
-
MoveDirection2["LEFT"] = "left";
|
|
7417
|
-
MoveDirection2["RIGHT"] = "right";
|
|
7418
|
-
})(MoveDirection || (MoveDirection = {}));
|
|
7419
7591
|
class SelectionObserver {
|
|
7420
7592
|
constructor(draw) {
|
|
7421
7593
|
__publicField(this, "step", 5);
|
|
@@ -8661,6 +8833,17 @@ class Control {
|
|
|
8661
8833
|
getDraw() {
|
|
8662
8834
|
return this.draw;
|
|
8663
8835
|
}
|
|
8836
|
+
filterAssistElement(payload) {
|
|
8837
|
+
const editorDataKeys = ["header", "main", "footer"];
|
|
8838
|
+
editorDataKeys.forEach((key) => {
|
|
8839
|
+
payload[key] = payload[key].filter((element) => {
|
|
8840
|
+
if (element.type !== ElementType.CONTROL)
|
|
8841
|
+
return true;
|
|
8842
|
+
return element.controlComponent !== ControlComponent.PREFIX && element.controlComponent !== ControlComponent.POSTFIX && element.controlComponent !== ControlComponent.PLACEHOLDER;
|
|
8843
|
+
});
|
|
8844
|
+
});
|
|
8845
|
+
return payload;
|
|
8846
|
+
}
|
|
8664
8847
|
isPartRangeInControlOutside() {
|
|
8665
8848
|
const { startIndex, endIndex } = this.getRange();
|
|
8666
8849
|
if (!~startIndex && !~endIndex)
|
|
@@ -8683,6 +8866,18 @@ class Control {
|
|
|
8683
8866
|
const element = elementList[startIndex];
|
|
8684
8867
|
return element.controlComponent === ControlComponent.POSTFIX;
|
|
8685
8868
|
}
|
|
8869
|
+
isRangeWithinControl() {
|
|
8870
|
+
const { startIndex, endIndex } = this.getRange();
|
|
8871
|
+
if (!~startIndex && !~endIndex)
|
|
8872
|
+
return false;
|
|
8873
|
+
const elementList = this.getElementList();
|
|
8874
|
+
const startElement = elementList[startIndex];
|
|
8875
|
+
const endElement = elementList[endIndex];
|
|
8876
|
+
if ((startElement.type === ElementType.CONTROL || endElement.type === ElementType.CONTROL) && endElement.controlComponent !== ControlComponent.POSTFIX && startElement.controlId === endElement.controlId) {
|
|
8877
|
+
return true;
|
|
8878
|
+
}
|
|
8879
|
+
return false;
|
|
8880
|
+
}
|
|
8686
8881
|
getContainer() {
|
|
8687
8882
|
return this.draw.getContainer();
|
|
8688
8883
|
}
|
|
@@ -10665,6 +10860,7 @@ class Draw {
|
|
|
10665
10860
|
__publicField(this, "visiblePageNoList");
|
|
10666
10861
|
__publicField(this, "intersectionPageNo");
|
|
10667
10862
|
__publicField(this, "lazyRenderIntersectionObserver");
|
|
10863
|
+
__publicField(this, "printModeData");
|
|
10668
10864
|
this.container = this._wrapContainer(rootContainer);
|
|
10669
10865
|
this.pageList = [];
|
|
10670
10866
|
this.ctxList = [];
|
|
@@ -10726,6 +10922,7 @@ class Draw {
|
|
|
10726
10922
|
this.visiblePageNoList = [];
|
|
10727
10923
|
this.intersectionPageNo = 0;
|
|
10728
10924
|
this.lazyRenderIntersectionObserver = null;
|
|
10925
|
+
this.printModeData = null;
|
|
10729
10926
|
this.render({
|
|
10730
10927
|
isInit: true,
|
|
10731
10928
|
isSetCursor: false
|
|
@@ -10735,10 +10932,36 @@ class Draw {
|
|
|
10735
10932
|
return this.mode;
|
|
10736
10933
|
}
|
|
10737
10934
|
setMode(payload) {
|
|
10935
|
+
if (this.mode === payload)
|
|
10936
|
+
return;
|
|
10937
|
+
if (payload === EditorMode.PRINT) {
|
|
10938
|
+
this.printModeData = {
|
|
10939
|
+
header: this.header.getElementList(),
|
|
10940
|
+
main: this.elementList,
|
|
10941
|
+
footer: this.footer.getElementList()
|
|
10942
|
+
};
|
|
10943
|
+
this.setEditorData(this.control.filterAssistElement(deepClone(this.printModeData)));
|
|
10944
|
+
}
|
|
10945
|
+
if (this.mode === EditorMode.PRINT && this.printModeData) {
|
|
10946
|
+
this.setEditorData(this.printModeData);
|
|
10947
|
+
this.printModeData = null;
|
|
10948
|
+
}
|
|
10738
10949
|
this.mode = payload;
|
|
10950
|
+
this.render({
|
|
10951
|
+
isSetCursor: false,
|
|
10952
|
+
isSubmitHistory: false
|
|
10953
|
+
});
|
|
10739
10954
|
}
|
|
10740
10955
|
isReadonly() {
|
|
10741
|
-
|
|
10956
|
+
switch (this.mode) {
|
|
10957
|
+
case EditorMode.READONLY:
|
|
10958
|
+
case EditorMode.PRINT:
|
|
10959
|
+
return true;
|
|
10960
|
+
case EditorMode.FORM:
|
|
10961
|
+
return !this.control.isRangeWithinControl();
|
|
10962
|
+
default:
|
|
10963
|
+
return false;
|
|
10964
|
+
}
|
|
10742
10965
|
}
|
|
10743
10966
|
getOriginalWidth() {
|
|
10744
10967
|
const { paperDirection, width, height } = this.options;
|
|
@@ -11057,10 +11280,16 @@ class Draw {
|
|
|
11057
11280
|
getRowCount() {
|
|
11058
11281
|
return this.rowList.length;
|
|
11059
11282
|
}
|
|
11060
|
-
async getDataURL(
|
|
11283
|
+
async getDataURL(payload = {}) {
|
|
11284
|
+
const { pixelRatio, mode } = payload;
|
|
11061
11285
|
if (pixelRatio) {
|
|
11062
11286
|
this.setPagePixelRatio(pixelRatio);
|
|
11063
11287
|
}
|
|
11288
|
+
const currentMode = this.mode;
|
|
11289
|
+
const isSwitchMode = !!mode && currentMode !== mode;
|
|
11290
|
+
if (isSwitchMode) {
|
|
11291
|
+
this.setMode(mode);
|
|
11292
|
+
}
|
|
11064
11293
|
this.render({
|
|
11065
11294
|
isLazy: false,
|
|
11066
11295
|
isCompute: false,
|
|
@@ -11072,6 +11301,9 @@ class Draw {
|
|
|
11072
11301
|
if (pixelRatio) {
|
|
11073
11302
|
this.setPagePixelRatio(null);
|
|
11074
11303
|
}
|
|
11304
|
+
if (isSwitchMode) {
|
|
11305
|
+
this.setMode(currentMode);
|
|
11306
|
+
}
|
|
11075
11307
|
return dataUrlList;
|
|
11076
11308
|
}
|
|
11077
11309
|
getPainterStyle() {
|
|
@@ -11244,28 +11476,35 @@ class Draw {
|
|
|
11244
11476
|
const { header, main, footer } = payload;
|
|
11245
11477
|
if (!header && !main && !footer)
|
|
11246
11478
|
return;
|
|
11247
|
-
|
|
11248
|
-
|
|
11479
|
+
const pageComponentData = [header, main, footer];
|
|
11480
|
+
pageComponentData.forEach((data2) => {
|
|
11481
|
+
if (!data2)
|
|
11482
|
+
return;
|
|
11483
|
+
formatElementList(data2, {
|
|
11249
11484
|
editorOptions: this.options
|
|
11250
11485
|
});
|
|
11486
|
+
});
|
|
11487
|
+
this.setEditorData({
|
|
11488
|
+
header,
|
|
11489
|
+
main,
|
|
11490
|
+
footer
|
|
11491
|
+
});
|
|
11492
|
+
this.historyManager.recovery();
|
|
11493
|
+
this.render({
|
|
11494
|
+
isSetCursor: false
|
|
11495
|
+
});
|
|
11496
|
+
}
|
|
11497
|
+
setEditorData(payload) {
|
|
11498
|
+
const { header, main, footer } = payload;
|
|
11499
|
+
if (header) {
|
|
11251
11500
|
this.header.setElementList(header);
|
|
11252
11501
|
}
|
|
11253
11502
|
if (main) {
|
|
11254
|
-
formatElementList(main, {
|
|
11255
|
-
editorOptions: this.options
|
|
11256
|
-
});
|
|
11257
11503
|
this.elementList = main;
|
|
11258
11504
|
}
|
|
11259
11505
|
if (footer) {
|
|
11260
|
-
formatElementList(footer, {
|
|
11261
|
-
editorOptions: this.options
|
|
11262
|
-
});
|
|
11263
11506
|
this.footer.setElementList(footer);
|
|
11264
11507
|
}
|
|
11265
|
-
this.historyManager.recovery();
|
|
11266
|
-
this.render({
|
|
11267
|
-
isSetCursor: false
|
|
11268
|
-
});
|
|
11269
11508
|
}
|
|
11270
11509
|
_wrapContainer(rootContainer) {
|
|
11271
11510
|
const container = document.createElement("div");
|
|
@@ -11647,6 +11886,7 @@ class Draw {
|
|
|
11647
11886
|
}
|
|
11648
11887
|
drawRow(ctx, payload) {
|
|
11649
11888
|
const { rowList, pageNo, elementList, positionList, startIndex, zone } = payload;
|
|
11889
|
+
const isPrintMode = this.mode === EditorMode.PRINT;
|
|
11650
11890
|
const { scale, tdPadding } = this.options;
|
|
11651
11891
|
const { isCrossRowCol, tableId } = this.range.getRange();
|
|
11652
11892
|
let index2 = startIndex;
|
|
@@ -11700,7 +11940,7 @@ class Draw {
|
|
|
11700
11940
|
} else if (element.type === ElementType.SEPARATOR) {
|
|
11701
11941
|
this.separatorParticle.render(ctx, element, x, y);
|
|
11702
11942
|
} else if (element.type === ElementType.PAGE_BREAK) {
|
|
11703
|
-
if (this.mode !== EditorMode.CLEAN) {
|
|
11943
|
+
if (this.mode !== EditorMode.CLEAN && !isPrintMode) {
|
|
11704
11944
|
this.pageBreakParticle.render(ctx, element, x, y);
|
|
11705
11945
|
}
|
|
11706
11946
|
} else if (element.type === ElementType.CHECKBOX || element.controlComponent === ControlComponent.CHECKBOX) {
|
|
@@ -11777,13 +12017,15 @@ class Draw {
|
|
|
11777
12017
|
this.listParticle.drawListStyle(ctx, curRow, positionList[curRow.startIndex]);
|
|
11778
12018
|
}
|
|
11779
12019
|
this._drawRichText(ctx);
|
|
11780
|
-
if (
|
|
11781
|
-
|
|
11782
|
-
|
|
11783
|
-
|
|
11784
|
-
|
|
11785
|
-
|
|
11786
|
-
|
|
12020
|
+
if (!isPrintMode) {
|
|
12021
|
+
if (rangeRecord.width && rangeRecord.height) {
|
|
12022
|
+
const { x, y, width, height } = rangeRecord;
|
|
12023
|
+
this.range.render(ctx, x, y, width, height);
|
|
12024
|
+
}
|
|
12025
|
+
if (isCrossRowCol && tableRangeElement && tableRangeElement.id === tableId) {
|
|
12026
|
+
const { coordinate: { leftTop: [x, y] } } = positionList[curRow.startIndex];
|
|
12027
|
+
this.tableParticle.drawRange(ctx, tableRangeElement, x, y);
|
|
12028
|
+
}
|
|
11787
12029
|
}
|
|
11788
12030
|
}
|
|
11789
12031
|
}
|
|
@@ -12023,6 +12265,7 @@ class Command {
|
|
|
12023
12265
|
__publicField(this, "executeTableTdVerticalAlign");
|
|
12024
12266
|
__publicField(this, "executeTableBorderType");
|
|
12025
12267
|
__publicField(this, "executeTableTdBackgroundColor");
|
|
12268
|
+
__publicField(this, "executeTableSelectAll");
|
|
12026
12269
|
__publicField(this, "executeImage");
|
|
12027
12270
|
__publicField(this, "executeHyperlink");
|
|
12028
12271
|
__publicField(this, "executeDeleteHyperlink");
|
|
@@ -12059,6 +12302,7 @@ class Command {
|
|
|
12059
12302
|
__publicField(this, "getImage");
|
|
12060
12303
|
__publicField(this, "getValue");
|
|
12061
12304
|
__publicField(this, "getHTML");
|
|
12305
|
+
__publicField(this, "getText");
|
|
12062
12306
|
__publicField(this, "getWordCount");
|
|
12063
12307
|
__publicField(this, "getRangeText");
|
|
12064
12308
|
__publicField(this, "getRangeContext");
|
|
@@ -12105,6 +12349,7 @@ class Command {
|
|
|
12105
12349
|
this.executeTableTdVerticalAlign = adapt.tableTdVerticalAlign.bind(adapt);
|
|
12106
12350
|
this.executeTableBorderType = adapt.tableBorderType.bind(adapt);
|
|
12107
12351
|
this.executeTableTdBackgroundColor = adapt.tableTdBackgroundColor.bind(adapt);
|
|
12352
|
+
this.executeTableSelectAll = adapt.tableSelectAll.bind(adapt);
|
|
12108
12353
|
this.executeImage = adapt.image.bind(adapt);
|
|
12109
12354
|
this.executeHyperlink = adapt.hyperlink.bind(adapt);
|
|
12110
12355
|
this.executeDeleteHyperlink = adapt.deleteHyperlink.bind(adapt);
|
|
@@ -12140,6 +12385,7 @@ class Command {
|
|
|
12140
12385
|
this.getImage = adapt.getImage.bind(adapt);
|
|
12141
12386
|
this.getValue = adapt.getValue.bind(adapt);
|
|
12142
12387
|
this.getHTML = adapt.getHTML.bind(adapt);
|
|
12388
|
+
this.getText = adapt.getText.bind(adapt);
|
|
12143
12389
|
this.getWordCount = adapt.getWordCount.bind(adapt);
|
|
12144
12390
|
this.getRangeText = adapt.getRangeText.bind(adapt);
|
|
12145
12391
|
this.getRangeContext = adapt.getRangeContext.bind(adapt);
|
|
@@ -12228,14 +12474,7 @@ class CommandAdapt {
|
|
|
12228
12474
|
this.i18n = draw.getI18n();
|
|
12229
12475
|
}
|
|
12230
12476
|
mode(payload) {
|
|
12231
|
-
const mode = this.draw.getMode();
|
|
12232
|
-
if (mode === payload)
|
|
12233
|
-
return;
|
|
12234
12477
|
this.draw.setMode(payload);
|
|
12235
|
-
this.draw.render({
|
|
12236
|
-
isSetCursor: false,
|
|
12237
|
-
isSubmitHistory: false
|
|
12238
|
-
});
|
|
12239
12478
|
}
|
|
12240
12479
|
cut() {
|
|
12241
12480
|
const isReadonly = this.draw.isReadonly();
|
|
@@ -12327,7 +12566,7 @@ class CommandAdapt {
|
|
|
12327
12566
|
const isReadonly = this.draw.isReadonly();
|
|
12328
12567
|
if (isReadonly)
|
|
12329
12568
|
return;
|
|
12330
|
-
const selection = this.range.
|
|
12569
|
+
const selection = this.range.getSelectionElementList();
|
|
12331
12570
|
if (!selection)
|
|
12332
12571
|
return;
|
|
12333
12572
|
selection.forEach((el) => {
|
|
@@ -12344,7 +12583,7 @@ class CommandAdapt {
|
|
|
12344
12583
|
const isReadonly = this.draw.isReadonly();
|
|
12345
12584
|
if (isReadonly)
|
|
12346
12585
|
return;
|
|
12347
|
-
const selection = this.range.
|
|
12586
|
+
const selection = this.range.getSelectionElementList();
|
|
12348
12587
|
if (!selection)
|
|
12349
12588
|
return;
|
|
12350
12589
|
selection.forEach((el) => {
|
|
@@ -12359,7 +12598,7 @@ class CommandAdapt {
|
|
|
12359
12598
|
const isReadonly = this.draw.isReadonly();
|
|
12360
12599
|
if (isReadonly)
|
|
12361
12600
|
return;
|
|
12362
|
-
const selection = this.range.
|
|
12601
|
+
const selection = this.range.getTextLikeSelectionElementList();
|
|
12363
12602
|
if (!selection || !selection.length)
|
|
12364
12603
|
return;
|
|
12365
12604
|
let isExistUpdate = false;
|
|
@@ -12378,7 +12617,7 @@ class CommandAdapt {
|
|
|
12378
12617
|
const isReadonly = this.draw.isReadonly();
|
|
12379
12618
|
if (isReadonly)
|
|
12380
12619
|
return;
|
|
12381
|
-
const selection = this.range.
|
|
12620
|
+
const selection = this.range.getTextLikeSelectionElementList();
|
|
12382
12621
|
if (!selection || !selection.length)
|
|
12383
12622
|
return;
|
|
12384
12623
|
const { defaultSize, maxSize } = this.options;
|
|
@@ -12404,7 +12643,7 @@ class CommandAdapt {
|
|
|
12404
12643
|
const isReadonly = this.draw.isReadonly();
|
|
12405
12644
|
if (isReadonly)
|
|
12406
12645
|
return;
|
|
12407
|
-
const selection = this.range.
|
|
12646
|
+
const selection = this.range.getTextLikeSelectionElementList();
|
|
12408
12647
|
if (!selection || !selection.length)
|
|
12409
12648
|
return;
|
|
12410
12649
|
const { defaultSize, minSize } = this.options;
|
|
@@ -12430,7 +12669,7 @@ class CommandAdapt {
|
|
|
12430
12669
|
const isReadonly = this.draw.isReadonly();
|
|
12431
12670
|
if (isReadonly)
|
|
12432
12671
|
return;
|
|
12433
|
-
const selection = this.range.
|
|
12672
|
+
const selection = this.range.getSelectionElementList();
|
|
12434
12673
|
if (!selection)
|
|
12435
12674
|
return;
|
|
12436
12675
|
const noBoldIndex = selection.findIndex((s) => !s.bold);
|
|
@@ -12443,7 +12682,7 @@ class CommandAdapt {
|
|
|
12443
12682
|
const isReadonly = this.draw.isReadonly();
|
|
12444
12683
|
if (isReadonly)
|
|
12445
12684
|
return;
|
|
12446
|
-
const selection = this.range.
|
|
12685
|
+
const selection = this.range.getSelectionElementList();
|
|
12447
12686
|
if (!selection)
|
|
12448
12687
|
return;
|
|
12449
12688
|
const noItalicIndex = selection.findIndex((s) => !s.italic);
|
|
@@ -12456,7 +12695,7 @@ class CommandAdapt {
|
|
|
12456
12695
|
const isReadonly = this.draw.isReadonly();
|
|
12457
12696
|
if (isReadonly)
|
|
12458
12697
|
return;
|
|
12459
|
-
const selection = this.range.
|
|
12698
|
+
const selection = this.range.getSelectionElementList();
|
|
12460
12699
|
if (!selection)
|
|
12461
12700
|
return;
|
|
12462
12701
|
const noUnderlineIndex = selection.findIndex((s) => !s.underline);
|
|
@@ -12469,7 +12708,7 @@ class CommandAdapt {
|
|
|
12469
12708
|
const isReadonly = this.draw.isReadonly();
|
|
12470
12709
|
if (isReadonly)
|
|
12471
12710
|
return;
|
|
12472
|
-
const selection = this.range.
|
|
12711
|
+
const selection = this.range.getSelectionElementList();
|
|
12473
12712
|
if (!selection)
|
|
12474
12713
|
return;
|
|
12475
12714
|
const noStrikeoutIndex = selection.findIndex((s) => !s.strikeout);
|
|
@@ -12485,7 +12724,7 @@ class CommandAdapt {
|
|
|
12485
12724
|
const activeControl = this.control.getActiveControl();
|
|
12486
12725
|
if (activeControl)
|
|
12487
12726
|
return;
|
|
12488
|
-
const selection = this.range.
|
|
12727
|
+
const selection = this.range.getSelectionElementList();
|
|
12489
12728
|
if (!selection)
|
|
12490
12729
|
return;
|
|
12491
12730
|
const superscriptIndex = selection.findIndex((s) => s.type === ElementType.SUPERSCRIPT);
|
|
@@ -12510,7 +12749,7 @@ class CommandAdapt {
|
|
|
12510
12749
|
const activeControl = this.control.getActiveControl();
|
|
12511
12750
|
if (activeControl)
|
|
12512
12751
|
return;
|
|
12513
|
-
const selection = this.range.
|
|
12752
|
+
const selection = this.range.getSelectionElementList();
|
|
12514
12753
|
if (!selection)
|
|
12515
12754
|
return;
|
|
12516
12755
|
const subscriptIndex = selection.findIndex((s) => s.type === ElementType.SUBSCRIPT);
|
|
@@ -12532,7 +12771,7 @@ class CommandAdapt {
|
|
|
12532
12771
|
const isReadonly = this.draw.isReadonly();
|
|
12533
12772
|
if (isReadonly)
|
|
12534
12773
|
return;
|
|
12535
|
-
const selection = this.range.
|
|
12774
|
+
const selection = this.range.getSelectionElementList();
|
|
12536
12775
|
if (!selection)
|
|
12537
12776
|
return;
|
|
12538
12777
|
selection.forEach((el) => {
|
|
@@ -12547,7 +12786,7 @@ class CommandAdapt {
|
|
|
12547
12786
|
const isReadonly = this.draw.isReadonly();
|
|
12548
12787
|
if (isReadonly)
|
|
12549
12788
|
return;
|
|
12550
|
-
const selection = this.range.
|
|
12789
|
+
const selection = this.range.getSelectionElementList();
|
|
12551
12790
|
if (!selection)
|
|
12552
12791
|
return;
|
|
12553
12792
|
selection.forEach((el) => {
|
|
@@ -12630,20 +12869,12 @@ class CommandAdapt {
|
|
|
12630
12869
|
const { startIndex, endIndex } = this.range.getRange();
|
|
12631
12870
|
if (!~startIndex && !~endIndex)
|
|
12632
12871
|
return;
|
|
12633
|
-
const
|
|
12634
|
-
if (!
|
|
12872
|
+
const rowElementList = this.range.getRangeRowElementList();
|
|
12873
|
+
if (!rowElementList)
|
|
12635
12874
|
return;
|
|
12636
|
-
|
|
12637
|
-
|
|
12638
|
-
|
|
12639
|
-
const position = positionList[p];
|
|
12640
|
-
const rowSet = rangeRow.get(position.pageNo);
|
|
12641
|
-
if (!rowSet)
|
|
12642
|
-
continue;
|
|
12643
|
-
if (rowSet.has(position.rowNo)) {
|
|
12644
|
-
elementList[p].rowFlex = payload;
|
|
12645
|
-
}
|
|
12646
|
-
}
|
|
12875
|
+
rowElementList.forEach((element) => {
|
|
12876
|
+
element.rowFlex = payload;
|
|
12877
|
+
});
|
|
12647
12878
|
const isSetCursor = startIndex === endIndex;
|
|
12648
12879
|
const curIndex = isSetCursor ? endIndex : startIndex;
|
|
12649
12880
|
this.draw.render({ curIndex, isSetCursor });
|
|
@@ -12655,20 +12886,12 @@ class CommandAdapt {
|
|
|
12655
12886
|
const { startIndex, endIndex } = this.range.getRange();
|
|
12656
12887
|
if (!~startIndex && !~endIndex)
|
|
12657
12888
|
return;
|
|
12658
|
-
const
|
|
12659
|
-
if (!
|
|
12889
|
+
const rowElementList = this.range.getRangeRowElementList();
|
|
12890
|
+
if (!rowElementList)
|
|
12660
12891
|
return;
|
|
12661
|
-
|
|
12662
|
-
|
|
12663
|
-
|
|
12664
|
-
const position = positionList[p];
|
|
12665
|
-
const rowSet = rangeRow.get(position.pageNo);
|
|
12666
|
-
if (!rowSet)
|
|
12667
|
-
continue;
|
|
12668
|
-
if (rowSet.has(position.rowNo)) {
|
|
12669
|
-
elementList[p].rowMargin = payload;
|
|
12670
|
-
}
|
|
12671
|
-
}
|
|
12892
|
+
rowElementList.forEach((element) => {
|
|
12893
|
+
element.rowMargin = payload;
|
|
12894
|
+
});
|
|
12672
12895
|
const isSetCursor = startIndex === endIndex;
|
|
12673
12896
|
const curIndex = isSetCursor ? endIndex : startIndex;
|
|
12674
12897
|
this.draw.render({ curIndex, isSetCursor });
|
|
@@ -13255,21 +13478,22 @@ class CommandAdapt {
|
|
|
13255
13478
|
this.tableTool.render();
|
|
13256
13479
|
}
|
|
13257
13480
|
tableTdVerticalAlign(payload) {
|
|
13258
|
-
var _a, _b, _c;
|
|
13259
13481
|
const isReadonly = this.draw.isReadonly();
|
|
13260
13482
|
if (isReadonly)
|
|
13261
13483
|
return;
|
|
13262
|
-
const
|
|
13263
|
-
if (!
|
|
13264
|
-
return;
|
|
13265
|
-
const { index: index2, trIndex, tdIndex } = positionContext;
|
|
13266
|
-
const originalElementList = this.draw.getOriginalElementList();
|
|
13267
|
-
const element = originalElementList[index2];
|
|
13268
|
-
const curTd = (_c = (_b = (_a = element == null ? void 0 : element.trList) == null ? void 0 : _a[trIndex]) == null ? void 0 : _b.tdList) == null ? void 0 : _c[tdIndex];
|
|
13269
|
-
if (!curTd || curTd.verticalAlign === payload || !curTd.verticalAlign && payload === VerticalAlign.TOP) {
|
|
13484
|
+
const rowCol = this.draw.getTableParticle().getRangeRowCol();
|
|
13485
|
+
if (!rowCol)
|
|
13270
13486
|
return;
|
|
13487
|
+
for (let r = 0; r < rowCol.length; r++) {
|
|
13488
|
+
const row = rowCol[r];
|
|
13489
|
+
for (let c = 0; c < row.length; c++) {
|
|
13490
|
+
const td = row[c];
|
|
13491
|
+
if (!td || td.verticalAlign === payload || !td.verticalAlign && payload === VerticalAlign.TOP) {
|
|
13492
|
+
continue;
|
|
13493
|
+
}
|
|
13494
|
+
td.verticalAlign = payload;
|
|
13495
|
+
}
|
|
13271
13496
|
}
|
|
13272
|
-
curTd.verticalAlign = payload;
|
|
13273
13497
|
const { endIndex } = this.range.getRange();
|
|
13274
13498
|
this.draw.render({
|
|
13275
13499
|
curIndex: endIndex
|
|
@@ -13314,6 +13538,30 @@ class CommandAdapt {
|
|
|
13314
13538
|
isCompute: false
|
|
13315
13539
|
});
|
|
13316
13540
|
}
|
|
13541
|
+
tableSelectAll() {
|
|
13542
|
+
const positionContext = this.position.getPositionContext();
|
|
13543
|
+
const { index: index2, tableId, isTable } = positionContext;
|
|
13544
|
+
if (!isTable || !tableId)
|
|
13545
|
+
return;
|
|
13546
|
+
const { startIndex, endIndex } = this.range.getRange();
|
|
13547
|
+
const originalElementList = this.draw.getOriginalElementList();
|
|
13548
|
+
const trList = originalElementList[index2].trList;
|
|
13549
|
+
const endTrIndex = trList.length - 1;
|
|
13550
|
+
const endTdIndex = trList[endTrIndex].tdList.length - 1;
|
|
13551
|
+
this.range.replaceRange({
|
|
13552
|
+
startIndex,
|
|
13553
|
+
endIndex,
|
|
13554
|
+
tableId,
|
|
13555
|
+
startTdIndex: 0,
|
|
13556
|
+
endTdIndex,
|
|
13557
|
+
startTrIndex: 0,
|
|
13558
|
+
endTrIndex
|
|
13559
|
+
});
|
|
13560
|
+
this.draw.render({
|
|
13561
|
+
isCompute: false,
|
|
13562
|
+
isSubmitHistory: false
|
|
13563
|
+
});
|
|
13564
|
+
}
|
|
13317
13565
|
hyperlink(payload) {
|
|
13318
13566
|
const isReadonly = this.draw.isReadonly();
|
|
13319
13567
|
if (isReadonly)
|
|
@@ -13671,7 +13919,10 @@ class CommandAdapt {
|
|
|
13671
13919
|
}
|
|
13672
13920
|
const width = this.draw.getOriginalWidth();
|
|
13673
13921
|
const height = this.draw.getOriginalHeight();
|
|
13674
|
-
const base64List = await this.draw.getDataURL(
|
|
13922
|
+
const base64List = await this.draw.getDataURL({
|
|
13923
|
+
pixelRatio: printPixelRatio,
|
|
13924
|
+
mode: EditorMode.PRINT
|
|
13925
|
+
});
|
|
13675
13926
|
printImageBase64(base64List, width, height);
|
|
13676
13927
|
if (scale !== 1) {
|
|
13677
13928
|
this.draw.setPageScale(scale);
|
|
@@ -13706,8 +13957,8 @@ class CommandAdapt {
|
|
|
13706
13957
|
isSetCursor: false
|
|
13707
13958
|
});
|
|
13708
13959
|
}
|
|
13709
|
-
getImage(
|
|
13710
|
-
return this.draw.getDataURL(
|
|
13960
|
+
getImage(payload) {
|
|
13961
|
+
return this.draw.getDataURL(payload);
|
|
13711
13962
|
}
|
|
13712
13963
|
getValue(options) {
|
|
13713
13964
|
return this.draw.getValue(options);
|
|
@@ -13723,6 +13974,16 @@ class CommandAdapt {
|
|
|
13723
13974
|
footer: createDomFromElementList(footerElementList, options).innerHTML
|
|
13724
13975
|
};
|
|
13725
13976
|
}
|
|
13977
|
+
getText() {
|
|
13978
|
+
const headerElementList = this.draw.getHeaderElementList();
|
|
13979
|
+
const mainElementList = this.draw.getOriginalMainElementList();
|
|
13980
|
+
const footerElementList = this.draw.getFooterElementList();
|
|
13981
|
+
return {
|
|
13982
|
+
header: getTextFromElementList(headerElementList),
|
|
13983
|
+
main: getTextFromElementList(mainElementList),
|
|
13984
|
+
footer: getTextFromElementList(footerElementList)
|
|
13985
|
+
};
|
|
13986
|
+
}
|
|
13726
13987
|
getWordCount() {
|
|
13727
13988
|
return this.workerManager.getWordCount();
|
|
13728
13989
|
}
|
|
@@ -14808,7 +15069,8 @@ class Editor {
|
|
|
14808
15069
|
inactiveAlpha: 0.6,
|
|
14809
15070
|
historyMaxRecordCount: 100,
|
|
14810
15071
|
wordBreak: WordBreak.BREAK_WORD,
|
|
14811
|
-
printPixelRatio: 3
|
|
15072
|
+
printPixelRatio: 3,
|
|
15073
|
+
maskMargin: [0, 0, 0, 0]
|
|
14812
15074
|
}, options), {
|
|
14813
15075
|
header: headerOptions,
|
|
14814
15076
|
footer: footerOptions,
|