@hufe921/canvas-editor 0.9.31 → 0.9.32
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 +44 -0
- package/README.md +2 -2
- package/dist/canvas-editor.es.js +802 -236
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +21 -17
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/command/Command.d.ts +3 -1
- package/dist/src/editor/core/command/CommandAdapt.d.ts +2 -0
- package/dist/src/editor/core/cursor/Cursor.d.ts +1 -0
- package/dist/src/editor/core/draw/Draw.d.ts +4 -0
- package/dist/src/editor/core/draw/control/Control.d.ts +1 -0
- package/dist/src/editor/core/draw/particle/ListParticle.d.ts +13 -0
- package/dist/src/editor/core/draw/particle/previewer/Previewer.d.ts +1 -0
- package/dist/src/editor/core/range/RangeManager.d.ts +4 -1
- package/dist/src/editor/core/shortcut/keys/listKeys.d.ts +2 -0
- package/dist/src/editor/core/shortcut/keys/titleKeys.d.ts +2 -0
- package/dist/src/editor/dataset/constant/Element.d.ts +2 -0
- package/dist/src/editor/dataset/constant/List.d.ts +4 -0
- package/dist/src/editor/dataset/enum/Element.d.ts +2 -1
- package/dist/src/editor/dataset/enum/List.d.ts +18 -0
- package/dist/src/editor/index.d.ts +2 -1
- package/dist/src/editor/interface/Element.d.ts +9 -1
- package/dist/src/editor/interface/Footer.d.ts +1 -0
- package/dist/src/editor/interface/Header.d.ts +1 -0
- package/dist/src/editor/interface/Listener.d.ts +3 -1
- package/dist/src/editor/interface/PageNumber.d.ts +1 -0
- package/dist/src/editor/interface/Position.d.ts +1 -0
- package/dist/src/editor/interface/Range.d.ts +1 -0
- package/dist/src/editor/interface/Row.d.ts +3 -0
- package/dist/src/editor/utils/element.d.ts +2 -0
- package/package.json +2 -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.32";
|
|
27
27
|
var MaxHeightRatio;
|
|
28
28
|
(function(MaxHeightRatio2) {
|
|
29
29
|
MaxHeightRatio2["HALF"] = "half";
|
|
@@ -198,6 +198,7 @@ var ElementType;
|
|
|
198
198
|
ElementType2["DATE"] = "date";
|
|
199
199
|
ElementType2["BLOCK"] = "block";
|
|
200
200
|
ElementType2["TITLE"] = "title";
|
|
201
|
+
ElementType2["LIST"] = "list";
|
|
201
202
|
})(ElementType || (ElementType = {}));
|
|
202
203
|
const EDITOR_ELEMENT_STYLE_ATTR = [
|
|
203
204
|
"bold",
|
|
@@ -223,9 +224,7 @@ const EDITOR_ELEMENT_COPY_ATTR = [
|
|
|
223
224
|
"url",
|
|
224
225
|
"hyperlinkId",
|
|
225
226
|
"dateId",
|
|
226
|
-
"dateFormat"
|
|
227
|
-
"level",
|
|
228
|
-
"titleId"
|
|
227
|
+
"dateFormat"
|
|
229
228
|
];
|
|
230
229
|
const EDITOR_ELEMENT_ZIP_ATTR = [
|
|
231
230
|
"type",
|
|
@@ -251,7 +250,19 @@ const EDITOR_ELEMENT_ZIP_ATTR = [
|
|
|
251
250
|
"checkbox",
|
|
252
251
|
"dateFormat",
|
|
253
252
|
"block",
|
|
254
|
-
"level"
|
|
253
|
+
"level",
|
|
254
|
+
"listType",
|
|
255
|
+
"listStyle"
|
|
256
|
+
];
|
|
257
|
+
const EDITOR_ELEMENT_CONTEXT_ATTR = [
|
|
258
|
+
"tdId",
|
|
259
|
+
"trId",
|
|
260
|
+
"tableId",
|
|
261
|
+
"level",
|
|
262
|
+
"titleId",
|
|
263
|
+
"listId",
|
|
264
|
+
"listType",
|
|
265
|
+
"listStyle"
|
|
255
266
|
];
|
|
256
267
|
const TEXTLIKE_ELEMENT_TYPE = [
|
|
257
268
|
ElementType.TEXT,
|
|
@@ -269,8 +280,51 @@ const INLINE_ELEMENT_TYPE = [
|
|
|
269
280
|
];
|
|
270
281
|
const INLINE_NODE_NAME = [
|
|
271
282
|
"HR",
|
|
272
|
-
"TABLE"
|
|
283
|
+
"TABLE",
|
|
284
|
+
"UL",
|
|
285
|
+
"OL"
|
|
286
|
+
];
|
|
287
|
+
const VIRTUAL_ELEMENT_TYPE = [
|
|
288
|
+
ElementType.TITLE,
|
|
289
|
+
ElementType.LIST
|
|
273
290
|
];
|
|
291
|
+
var ListType;
|
|
292
|
+
(function(ListType2) {
|
|
293
|
+
ListType2["UL"] = "ul";
|
|
294
|
+
ListType2["OL"] = "ol";
|
|
295
|
+
})(ListType || (ListType = {}));
|
|
296
|
+
var UlStyle;
|
|
297
|
+
(function(UlStyle2) {
|
|
298
|
+
UlStyle2["DISC"] = "disc";
|
|
299
|
+
UlStyle2["CIRCLE"] = "circle";
|
|
300
|
+
UlStyle2["SQUARE"] = "square";
|
|
301
|
+
})(UlStyle || (UlStyle = {}));
|
|
302
|
+
var OlStyle;
|
|
303
|
+
(function(OlStyle2) {
|
|
304
|
+
OlStyle2["DECIMAL"] = "decimal";
|
|
305
|
+
})(OlStyle || (OlStyle = {}));
|
|
306
|
+
var ListStyle;
|
|
307
|
+
(function(ListStyle2) {
|
|
308
|
+
ListStyle2["DISC"] = "disc";
|
|
309
|
+
ListStyle2["CIRCLE"] = "circle";
|
|
310
|
+
ListStyle2["SQUARE"] = "square";
|
|
311
|
+
ListStyle2["DECIMAL"] = "decimal";
|
|
312
|
+
})(ListStyle || (ListStyle = {}));
|
|
313
|
+
const ulStyleMapping = {
|
|
314
|
+
[UlStyle.DISC]: "\u2022",
|
|
315
|
+
[UlStyle.CIRCLE]: "\u25E6",
|
|
316
|
+
[UlStyle.SQUARE]: "\u25AB\uFE0E"
|
|
317
|
+
};
|
|
318
|
+
const listTypeElementMapping = {
|
|
319
|
+
[ListType.OL]: "ol",
|
|
320
|
+
[ListType.UL]: "ul"
|
|
321
|
+
};
|
|
322
|
+
const listStyleCSSMapping = {
|
|
323
|
+
[ListStyle.DISC]: "disc",
|
|
324
|
+
[ListStyle.CIRCLE]: "circle",
|
|
325
|
+
[ListStyle.SQUARE]: "square",
|
|
326
|
+
[ListStyle.DECIMAL]: "decimal"
|
|
327
|
+
};
|
|
274
328
|
var TitleLevel;
|
|
275
329
|
(function(TitleLevel2) {
|
|
276
330
|
TitleLevel2["FIRST"] = "first";
|
|
@@ -3354,11 +3408,11 @@ function unzipElementList(elementList) {
|
|
|
3354
3408
|
return result;
|
|
3355
3409
|
}
|
|
3356
3410
|
function formatElementList(elementList, options) {
|
|
3357
|
-
var _a;
|
|
3358
3411
|
const { isHandleFirstElement, editorOptions } = __spreadValues({
|
|
3359
3412
|
isHandleFirstElement: true
|
|
3360
3413
|
}, options);
|
|
3361
|
-
|
|
3414
|
+
const startElement = elementList[0];
|
|
3415
|
+
if (isHandleFirstElement && (startElement == null ? void 0 : startElement.value) !== ZERO && (startElement == null ? void 0 : startElement.value) !== "\n") {
|
|
3362
3416
|
elementList.unshift({
|
|
3363
3417
|
value: ZERO
|
|
3364
3418
|
});
|
|
@@ -3366,7 +3420,49 @@ function formatElementList(elementList, options) {
|
|
|
3366
3420
|
let i = 0;
|
|
3367
3421
|
while (i < elementList.length) {
|
|
3368
3422
|
let el = elementList[i];
|
|
3369
|
-
if (el.type === ElementType.
|
|
3423
|
+
if (el.type === ElementType.TITLE) {
|
|
3424
|
+
elementList.splice(i, 1);
|
|
3425
|
+
const valueList = el.valueList || [];
|
|
3426
|
+
formatElementList(valueList, __spreadProps(__spreadValues({}, options), {
|
|
3427
|
+
isHandleFirstElement: false
|
|
3428
|
+
}));
|
|
3429
|
+
if (valueList.length) {
|
|
3430
|
+
const titleId = getUUID();
|
|
3431
|
+
const titleOptions = editorOptions.title;
|
|
3432
|
+
for (let v = 0; v < valueList.length; v++) {
|
|
3433
|
+
const value = valueList[v];
|
|
3434
|
+
value.titleId = titleId;
|
|
3435
|
+
value.level = el.level;
|
|
3436
|
+
if (isTextLikeElement(value)) {
|
|
3437
|
+
if (!value.size) {
|
|
3438
|
+
value.size = titleOptions[titleSizeMapping[value.level]];
|
|
3439
|
+
}
|
|
3440
|
+
if (value.bold === void 0) {
|
|
3441
|
+
value.bold = true;
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
elementList.splice(i, 0, value);
|
|
3445
|
+
i++;
|
|
3446
|
+
}
|
|
3447
|
+
}
|
|
3448
|
+
i--;
|
|
3449
|
+
} else if (el.type === ElementType.LIST) {
|
|
3450
|
+
elementList.splice(i, 1);
|
|
3451
|
+
const valueList = el.valueList || [];
|
|
3452
|
+
formatElementList(valueList, __spreadValues({}, options));
|
|
3453
|
+
if (valueList.length) {
|
|
3454
|
+
const listId = getUUID();
|
|
3455
|
+
for (let v = 0; v < valueList.length; v++) {
|
|
3456
|
+
const value = valueList[v];
|
|
3457
|
+
value.listId = listId;
|
|
3458
|
+
value.listType = el.listType;
|
|
3459
|
+
value.listStyle = el.listStyle;
|
|
3460
|
+
elementList.splice(i, 0, value);
|
|
3461
|
+
i++;
|
|
3462
|
+
}
|
|
3463
|
+
}
|
|
3464
|
+
i--;
|
|
3465
|
+
} else if (el.type === ElementType.TABLE) {
|
|
3370
3466
|
const tableId = getUUID();
|
|
3371
3467
|
el.id = tableId;
|
|
3372
3468
|
if (el.trList) {
|
|
@@ -3426,32 +3522,6 @@ function formatElementList(elementList, options) {
|
|
|
3426
3522
|
}
|
|
3427
3523
|
}
|
|
3428
3524
|
i--;
|
|
3429
|
-
} else if (el.type === ElementType.TITLE) {
|
|
3430
|
-
elementList.splice(i, 1);
|
|
3431
|
-
const valueList = el.valueList || [];
|
|
3432
|
-
formatElementList(valueList, __spreadProps(__spreadValues({}, options), {
|
|
3433
|
-
isHandleFirstElement: false
|
|
3434
|
-
}));
|
|
3435
|
-
if (valueList.length) {
|
|
3436
|
-
const titleId = getUUID();
|
|
3437
|
-
const titleOptions = editorOptions.title;
|
|
3438
|
-
for (let v = 0; v < valueList.length; v++) {
|
|
3439
|
-
const value = valueList[v];
|
|
3440
|
-
value.titleId = titleId;
|
|
3441
|
-
value.level = el.level;
|
|
3442
|
-
if (isTextLikeElement(value)) {
|
|
3443
|
-
if (!value.size) {
|
|
3444
|
-
value.size = titleOptions[titleSizeMapping[value.level]];
|
|
3445
|
-
}
|
|
3446
|
-
if (value.bold === void 0) {
|
|
3447
|
-
value.bold = true;
|
|
3448
|
-
}
|
|
3449
|
-
}
|
|
3450
|
-
elementList.splice(i, 0, value);
|
|
3451
|
-
i++;
|
|
3452
|
-
}
|
|
3453
|
-
}
|
|
3454
|
-
i--;
|
|
3455
3525
|
} else if (el.type === ElementType.CONTROL) {
|
|
3456
3526
|
const { prefix, postfix, value, placeholder, code, type, valueSets } = el.control;
|
|
3457
3527
|
const controlId = getUUID();
|
|
@@ -3630,7 +3700,53 @@ function zipElementList(payload) {
|
|
|
3630
3700
|
e++;
|
|
3631
3701
|
continue;
|
|
3632
3702
|
}
|
|
3633
|
-
if (element.
|
|
3703
|
+
if (element.titleId && element.level) {
|
|
3704
|
+
const titleId = element.titleId;
|
|
3705
|
+
const level = element.level;
|
|
3706
|
+
const titleElement = {
|
|
3707
|
+
type: ElementType.TITLE,
|
|
3708
|
+
value: "",
|
|
3709
|
+
level
|
|
3710
|
+
};
|
|
3711
|
+
const valueList = [];
|
|
3712
|
+
while (e < elementList.length) {
|
|
3713
|
+
const titleE = elementList[e];
|
|
3714
|
+
if (titleId !== titleE.titleId) {
|
|
3715
|
+
e--;
|
|
3716
|
+
break;
|
|
3717
|
+
}
|
|
3718
|
+
delete titleE.level;
|
|
3719
|
+
valueList.push(titleE);
|
|
3720
|
+
e++;
|
|
3721
|
+
}
|
|
3722
|
+
titleElement.valueList = zipElementList(valueList);
|
|
3723
|
+
element = titleElement;
|
|
3724
|
+
} else if (element.listId && element.listType) {
|
|
3725
|
+
const listId = element.listId;
|
|
3726
|
+
const listType = element.listType;
|
|
3727
|
+
const listStyle = element.listStyle;
|
|
3728
|
+
const listElement = {
|
|
3729
|
+
type: ElementType.LIST,
|
|
3730
|
+
value: "",
|
|
3731
|
+
listId,
|
|
3732
|
+
listType,
|
|
3733
|
+
listStyle
|
|
3734
|
+
};
|
|
3735
|
+
const valueList = [];
|
|
3736
|
+
while (e < elementList.length) {
|
|
3737
|
+
const listE = elementList[e];
|
|
3738
|
+
if (listId !== listE.listId) {
|
|
3739
|
+
e--;
|
|
3740
|
+
break;
|
|
3741
|
+
}
|
|
3742
|
+
delete listE.listType;
|
|
3743
|
+
delete listE.listStyle;
|
|
3744
|
+
valueList.push(listE);
|
|
3745
|
+
e++;
|
|
3746
|
+
}
|
|
3747
|
+
listElement.valueList = zipElementList(valueList);
|
|
3748
|
+
element = listElement;
|
|
3749
|
+
} else if (element.type === ElementType.TABLE) {
|
|
3634
3750
|
if (element.trList) {
|
|
3635
3751
|
for (let t = 0; t < element.trList.length; t++) {
|
|
3636
3752
|
const tr = element.trList[t];
|
|
@@ -3691,27 +3807,6 @@ function zipElementList(payload) {
|
|
|
3691
3807
|
}
|
|
3692
3808
|
dateElement.valueList = zipElementList(valueList);
|
|
3693
3809
|
element = dateElement;
|
|
3694
|
-
} else if (element.titleId && element.level) {
|
|
3695
|
-
const titleId = element.titleId;
|
|
3696
|
-
const level = element.level;
|
|
3697
|
-
const titleElement = {
|
|
3698
|
-
type: ElementType.TITLE,
|
|
3699
|
-
value: "",
|
|
3700
|
-
level
|
|
3701
|
-
};
|
|
3702
|
-
const valueList = [];
|
|
3703
|
-
while (e < elementList.length) {
|
|
3704
|
-
const titleE = elementList[e];
|
|
3705
|
-
if (titleId !== titleE.titleId) {
|
|
3706
|
-
e--;
|
|
3707
|
-
break;
|
|
3708
|
-
}
|
|
3709
|
-
delete titleE.level;
|
|
3710
|
-
valueList.push(titleE);
|
|
3711
|
-
e++;
|
|
3712
|
-
}
|
|
3713
|
-
titleElement.valueList = zipElementList(valueList);
|
|
3714
|
-
element = titleElement;
|
|
3715
3810
|
} else if (element.type === ElementType.CONTROL) {
|
|
3716
3811
|
const controlId = element.controlId;
|
|
3717
3812
|
const control = element.control;
|
|
@@ -3776,6 +3871,35 @@ function getElementRowFlex(node) {
|
|
|
3776
3871
|
function isTextLikeElement(element) {
|
|
3777
3872
|
return !element.type || TEXTLIKE_ELEMENT_TYPE.includes(element.type);
|
|
3778
3873
|
}
|
|
3874
|
+
function getAnchorElement(elementList, anchorIndex) {
|
|
3875
|
+
const anchorElement = elementList[anchorIndex];
|
|
3876
|
+
if (!anchorElement)
|
|
3877
|
+
return null;
|
|
3878
|
+
const anchorNextElement = elementList[anchorIndex + 1];
|
|
3879
|
+
return !anchorElement.listId && anchorElement.value === ZERO && anchorNextElement && anchorNextElement.value !== ZERO ? anchorNextElement : anchorElement;
|
|
3880
|
+
}
|
|
3881
|
+
function formatElementContext(sourceElementList, formatElementList2, anchorIndex) {
|
|
3882
|
+
const copyElement = getAnchorElement(sourceElementList, anchorIndex);
|
|
3883
|
+
if (!copyElement)
|
|
3884
|
+
return;
|
|
3885
|
+
for (let e = 0; e < formatElementList2.length; e++) {
|
|
3886
|
+
const targetElement = formatElementList2[e];
|
|
3887
|
+
if (!copyElement.listId && targetElement.type === ElementType.LIST)
|
|
3888
|
+
continue;
|
|
3889
|
+
if (targetElement.valueList && targetElement.valueList.length) {
|
|
3890
|
+
formatElementContext(sourceElementList, targetElement.valueList, anchorIndex);
|
|
3891
|
+
}
|
|
3892
|
+
for (let i = 0; i < EDITOR_ELEMENT_CONTEXT_ATTR.length; i++) {
|
|
3893
|
+
const attr = EDITOR_ELEMENT_CONTEXT_ATTR[i];
|
|
3894
|
+
const value = copyElement[attr];
|
|
3895
|
+
if (value !== void 0) {
|
|
3896
|
+
targetElement[attr] = value;
|
|
3897
|
+
} else {
|
|
3898
|
+
delete targetElement[attr];
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3901
|
+
}
|
|
3902
|
+
}
|
|
3779
3903
|
function writeClipboardItem(text, html) {
|
|
3780
3904
|
if (!text || !html)
|
|
3781
3905
|
return;
|
|
@@ -3818,9 +3942,7 @@ function convertElementToDom(element, options) {
|
|
|
3818
3942
|
if (element.italic) {
|
|
3819
3943
|
dom.style.fontStyle = "italic";
|
|
3820
3944
|
}
|
|
3821
|
-
|
|
3822
|
-
dom.style.fontSize = `${element.size}px`;
|
|
3823
|
-
}
|
|
3945
|
+
dom.style.fontSize = `${element.size || options.defaultSize}px`;
|
|
3824
3946
|
if (element.highlight) {
|
|
3825
3947
|
dom.style.backgroundColor = element.highlight;
|
|
3826
3948
|
}
|
|
@@ -3864,6 +3986,36 @@ function writeElementList(elementList, options) {
|
|
|
3864
3986
|
const childDom = buildDomFromElementList(zipElementList(element.valueList));
|
|
3865
3987
|
h.innerHTML = childDom.innerHTML;
|
|
3866
3988
|
clipboardDom2.append(h);
|
|
3989
|
+
} else if (element.type === ElementType.LIST) {
|
|
3990
|
+
const list = document.createElement(listTypeElementMapping[element.listType]);
|
|
3991
|
+
if (element.listStyle) {
|
|
3992
|
+
list.style.listStyleType = listStyleCSSMapping[element.listStyle];
|
|
3993
|
+
}
|
|
3994
|
+
let curListIndex = 0;
|
|
3995
|
+
const listElementListMap = new Map();
|
|
3996
|
+
const zipList = zipElementList(element.valueList);
|
|
3997
|
+
for (let z = 0; z < zipList.length; z++) {
|
|
3998
|
+
const zipElement = zipList[z];
|
|
3999
|
+
const zipValueList = zipElement.value.split("\n");
|
|
4000
|
+
for (let c = 0; c < zipValueList.length; c++) {
|
|
4001
|
+
if (c > 0) {
|
|
4002
|
+
curListIndex += 1;
|
|
4003
|
+
}
|
|
4004
|
+
const value = zipValueList[c];
|
|
4005
|
+
const listElementList = listElementListMap.get(curListIndex) || [];
|
|
4006
|
+
listElementList.push(__spreadProps(__spreadValues({}, zipElement), {
|
|
4007
|
+
value
|
|
4008
|
+
}));
|
|
4009
|
+
listElementListMap.set(curListIndex, listElementList);
|
|
4010
|
+
}
|
|
4011
|
+
}
|
|
4012
|
+
listElementListMap.forEach((listElementList) => {
|
|
4013
|
+
const li = document.createElement("li");
|
|
4014
|
+
const childDom = buildDomFromElementList(listElementList);
|
|
4015
|
+
li.innerHTML = childDom.innerHTML;
|
|
4016
|
+
list.append(li);
|
|
4017
|
+
});
|
|
4018
|
+
clipboardDom2.append(list);
|
|
3867
4019
|
} else if (element.type === ElementType.IMAGE) {
|
|
3868
4020
|
const img = document.createElement("img");
|
|
3869
4021
|
if (element.value) {
|
|
@@ -3971,6 +4123,27 @@ function getElementListByHTML(htmlText, options) {
|
|
|
3971
4123
|
value: "\n"
|
|
3972
4124
|
});
|
|
3973
4125
|
}
|
|
4126
|
+
} else if (node.nodeName === "UL" || node.nodeName === "OL") {
|
|
4127
|
+
const listNode = node;
|
|
4128
|
+
const listElement = {
|
|
4129
|
+
value: "",
|
|
4130
|
+
type: ElementType.LIST,
|
|
4131
|
+
valueList: []
|
|
4132
|
+
};
|
|
4133
|
+
if (node.nodeName === "OL") {
|
|
4134
|
+
listElement.listType = ListType.OL;
|
|
4135
|
+
} else {
|
|
4136
|
+
listElement.listType = ListType.UL;
|
|
4137
|
+
listElement.listStyle = listNode.style.listStyleType;
|
|
4138
|
+
}
|
|
4139
|
+
listNode.querySelectorAll("li").forEach((li) => {
|
|
4140
|
+
const liValueList = getElementListByHTML(li.innerHTML, options);
|
|
4141
|
+
liValueList.unshift({
|
|
4142
|
+
value: "\n"
|
|
4143
|
+
});
|
|
4144
|
+
listElement.valueList.push(...liValueList);
|
|
4145
|
+
});
|
|
4146
|
+
elementList.push(listElement);
|
|
3974
4147
|
} else if (node.nodeName === "HR") {
|
|
3975
4148
|
elementList.push({
|
|
3976
4149
|
value: "\n",
|
|
@@ -4051,7 +4224,8 @@ function getElementListByHTML(htmlText, options) {
|
|
|
4051
4224
|
document.body.appendChild(clipboardDom);
|
|
4052
4225
|
const deleteNodes = [];
|
|
4053
4226
|
clipboardDom.childNodes.forEach((child) => {
|
|
4054
|
-
|
|
4227
|
+
var _a;
|
|
4228
|
+
if (child.nodeType !== 1 && !((_a = child.textContent) == null ? void 0 : _a.trim())) {
|
|
4055
4229
|
deleteNodes.push(child);
|
|
4056
4230
|
}
|
|
4057
4231
|
});
|
|
@@ -4096,6 +4270,9 @@ class CursorAgent {
|
|
|
4096
4270
|
const clipboardData = evt.clipboardData;
|
|
4097
4271
|
if (!clipboardData)
|
|
4098
4272
|
return;
|
|
4273
|
+
const rangeManager = this.draw.getRange();
|
|
4274
|
+
const { startIndex } = rangeManager.getRange();
|
|
4275
|
+
const elementList = this.draw.getElementList();
|
|
4099
4276
|
let isHTML = false;
|
|
4100
4277
|
for (let i = 0; i < clipboardData.items.length; i++) {
|
|
4101
4278
|
const item = clipboardData.items[i];
|
|
@@ -4114,10 +4291,34 @@ class CursorAgent {
|
|
|
4114
4291
|
}
|
|
4115
4292
|
if (item.type === "text/html" && isHTML) {
|
|
4116
4293
|
item.getAsString((htmlText) => {
|
|
4117
|
-
const
|
|
4294
|
+
const pasteElementList = getElementListByHTML(htmlText, {
|
|
4118
4295
|
innerWidth: this.draw.getOriginalInnerWidth()
|
|
4119
4296
|
});
|
|
4120
|
-
|
|
4297
|
+
if (~startIndex && !rangeManager.getIsSelectAll()) {
|
|
4298
|
+
const anchorElement = elementList[startIndex];
|
|
4299
|
+
if ((anchorElement == null ? void 0 : anchorElement.titleId) || (anchorElement == null ? void 0 : anchorElement.listId)) {
|
|
4300
|
+
let start = 0;
|
|
4301
|
+
while (start < pasteElementList.length) {
|
|
4302
|
+
const pasteElement = pasteElementList[start];
|
|
4303
|
+
if (VIRTUAL_ELEMENT_TYPE.includes(pasteElement.type)) {
|
|
4304
|
+
pasteElementList.splice(start, 1);
|
|
4305
|
+
if (pasteElement.valueList) {
|
|
4306
|
+
for (let v = 0; v < pasteElement.valueList.length; v++) {
|
|
4307
|
+
const element = pasteElement.valueList[v];
|
|
4308
|
+
if (element.value === ZERO || element.value === "\n")
|
|
4309
|
+
continue;
|
|
4310
|
+
pasteElementList.splice(start, 0, element);
|
|
4311
|
+
start++;
|
|
4312
|
+
}
|
|
4313
|
+
}
|
|
4314
|
+
start--;
|
|
4315
|
+
}
|
|
4316
|
+
start++;
|
|
4317
|
+
}
|
|
4318
|
+
}
|
|
4319
|
+
formatElementContext(elementList, pasteElementList, startIndex);
|
|
4320
|
+
}
|
|
4321
|
+
this.draw.insertElementList(pasteElementList);
|
|
4121
4322
|
});
|
|
4122
4323
|
}
|
|
4123
4324
|
} else if (item.kind === "file") {
|
|
@@ -4131,12 +4332,16 @@ class CursorAgent {
|
|
|
4131
4332
|
const value = fileReader.result;
|
|
4132
4333
|
image.src = value;
|
|
4133
4334
|
image.onload = () => {
|
|
4134
|
-
|
|
4335
|
+
const imageElement = {
|
|
4135
4336
|
value,
|
|
4136
4337
|
type: ElementType.IMAGE,
|
|
4137
4338
|
width: image.width,
|
|
4138
4339
|
height: image.height
|
|
4139
|
-
}
|
|
4340
|
+
};
|
|
4341
|
+
if (~startIndex) {
|
|
4342
|
+
formatElementContext(elementList, [imageElement], startIndex);
|
|
4343
|
+
}
|
|
4344
|
+
this.draw.insertElementList([imageElement]);
|
|
4140
4345
|
};
|
|
4141
4346
|
};
|
|
4142
4347
|
}
|
|
@@ -4186,7 +4391,7 @@ class Cursor {
|
|
|
4186
4391
|
if (!cursorPosition)
|
|
4187
4392
|
return;
|
|
4188
4393
|
const { scale, cursor } = this.options;
|
|
4189
|
-
const { color, width, isBlink = true } = __spreadValues(__spreadValues({}, cursor), payload);
|
|
4394
|
+
const { color, width, isShow = true, isBlink = true } = __spreadValues(__spreadValues({}, cursor), payload);
|
|
4190
4395
|
const height = this.draw.getHeight();
|
|
4191
4396
|
const pageGap = this.draw.getPageGap();
|
|
4192
4397
|
const { metrics, coordinate: { leftTop, rightTop }, ascent, pageNo } = cursorPosition;
|
|
@@ -4205,6 +4410,8 @@ class Cursor {
|
|
|
4205
4410
|
const cursorLeft = rightTop[0];
|
|
4206
4411
|
agentCursorDom.style.left = `${cursorLeft}px`;
|
|
4207
4412
|
agentCursorDom.style.top = `${cursorTop + cursorHeight - CURSOR_AGENT_HEIGHT * scale}px`;
|
|
4413
|
+
if (!isShow)
|
|
4414
|
+
return;
|
|
4208
4415
|
const isReadonly = this.draw.isReadonly();
|
|
4209
4416
|
this.cursorDom.style.width = `${width}px`;
|
|
4210
4417
|
this.cursorDom.style.backgroundColor = color;
|
|
@@ -4490,6 +4697,9 @@ function mousedown(evt, host) {
|
|
|
4490
4697
|
mime: "svg",
|
|
4491
4698
|
srcKey: "laTexSVG"
|
|
4492
4699
|
} : {});
|
|
4700
|
+
draw.getCursor().drawCursor({
|
|
4701
|
+
isShow: false
|
|
4702
|
+
});
|
|
4493
4703
|
}
|
|
4494
4704
|
const tableTool = draw.getTableTool();
|
|
4495
4705
|
tableTool.dispose();
|
|
@@ -4530,6 +4740,15 @@ function mouseup(evt, host) {
|
|
|
4530
4740
|
const cacheElementList = host.cacheElementList;
|
|
4531
4741
|
const cachePositionList = host.cachePositionList;
|
|
4532
4742
|
const range = rangeManager.getRange();
|
|
4743
|
+
if (range.startIndex >= cacheRange.startIndex && range.endIndex <= cacheRange.endIndex) {
|
|
4744
|
+
rangeManager.replaceRange(__spreadValues({}, cacheRange));
|
|
4745
|
+
draw.render({
|
|
4746
|
+
isSetCursor: false,
|
|
4747
|
+
isCompute: false,
|
|
4748
|
+
isSubmitHistory: false
|
|
4749
|
+
});
|
|
4750
|
+
return;
|
|
4751
|
+
}
|
|
4533
4752
|
const dragElementList = cacheElementList.slice(cacheRange.startIndex + 1, cacheRange.endIndex + 1);
|
|
4534
4753
|
const isContainControl = dragElementList.find((element) => element.type === ElementType.CONTROL);
|
|
4535
4754
|
if (isContainControl) {
|
|
@@ -4547,18 +4766,12 @@ function mouseup(evt, host) {
|
|
|
4547
4766
|
}
|
|
4548
4767
|
const editorOptions = draw.getOptions();
|
|
4549
4768
|
const elementList = draw.getElementList();
|
|
4550
|
-
const anchorElement = elementList[range.startIndex];
|
|
4551
|
-
let restArg = {};
|
|
4552
|
-
if (anchorElement.tableId) {
|
|
4553
|
-
const { tdId, trId, tableId } = anchorElement;
|
|
4554
|
-
restArg = { tdId, trId, tableId };
|
|
4555
|
-
}
|
|
4556
4769
|
const replaceElementList = dragElementList.map((el) => {
|
|
4557
4770
|
var _a2;
|
|
4558
4771
|
if (!el.type || el.type === ElementType.TEXT || ((_a2 = el.control) == null ? void 0 : _a2.type) === ControlType.TEXT) {
|
|
4559
|
-
const newElement =
|
|
4772
|
+
const newElement = {
|
|
4560
4773
|
value: el.value
|
|
4561
|
-
}
|
|
4774
|
+
};
|
|
4562
4775
|
EDITOR_ELEMENT_STYLE_ATTR.forEach((attr) => {
|
|
4563
4776
|
const value = el[attr];
|
|
4564
4777
|
if (value !== void 0) {
|
|
@@ -4575,6 +4788,7 @@ function mouseup(evt, host) {
|
|
|
4575
4788
|
return newElement;
|
|
4576
4789
|
}
|
|
4577
4790
|
});
|
|
4791
|
+
formatElementContext(elementList, replaceElementList, range.startIndex);
|
|
4578
4792
|
const cacheRangeStartId = createDragId(cacheElementList[cacheRange.startIndex]);
|
|
4579
4793
|
const cacheRangeEndId = createDragId(cacheElementList[cacheRange.endIndex]);
|
|
4580
4794
|
const replaceLength = replaceElementList.length;
|
|
@@ -4586,7 +4800,7 @@ function mouseup(evt, host) {
|
|
|
4586
4800
|
rangeEnd = activeControl.setValue(replaceElementList);
|
|
4587
4801
|
rangeStart = rangeEnd - replaceLength;
|
|
4588
4802
|
} else {
|
|
4589
|
-
|
|
4803
|
+
draw.spliceElementList(elementList, rangeStart + 1, 0, ...replaceElementList);
|
|
4590
4804
|
}
|
|
4591
4805
|
if (!~rangeEnd) {
|
|
4592
4806
|
draw.render({
|
|
@@ -4606,7 +4820,7 @@ function mouseup(evt, host) {
|
|
|
4606
4820
|
}));
|
|
4607
4821
|
(_c = control.getActiveControl()) == null ? void 0 : _c.cut();
|
|
4608
4822
|
} else {
|
|
4609
|
-
|
|
4823
|
+
draw.spliceElementList(cacheElementList, cacheRangeStartIndex + 1, cacheRangeEndIndex - cacheRangeStartIndex);
|
|
4610
4824
|
}
|
|
4611
4825
|
const startElement = elementList[range.startIndex];
|
|
4612
4826
|
const cacheStartElement = cacheElementList[cacheRange.startIndex];
|
|
@@ -4700,7 +4914,7 @@ function mousemove(evt, host) {
|
|
|
4700
4914
|
});
|
|
4701
4915
|
}
|
|
4702
4916
|
function keydown(evt, host) {
|
|
4703
|
-
var _a;
|
|
4917
|
+
var _a, _b;
|
|
4704
4918
|
if (host.isComposing)
|
|
4705
4919
|
return;
|
|
4706
4920
|
const draw = host.getDraw();
|
|
@@ -4740,9 +4954,9 @@ function keydown(evt, host) {
|
|
|
4740
4954
|
});
|
|
4741
4955
|
}
|
|
4742
4956
|
if (!isCollapsed) {
|
|
4743
|
-
|
|
4957
|
+
draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex);
|
|
4744
4958
|
} else {
|
|
4745
|
-
|
|
4959
|
+
draw.spliceElementList(elementList, index2, 1);
|
|
4746
4960
|
}
|
|
4747
4961
|
curIndex = isCollapsed ? index2 - 1 : startIndex;
|
|
4748
4962
|
}
|
|
@@ -4758,9 +4972,9 @@ function keydown(evt, host) {
|
|
|
4758
4972
|
curIndex = control.removeControl(endIndex + 1);
|
|
4759
4973
|
} else {
|
|
4760
4974
|
if (!isCollapsed) {
|
|
4761
|
-
|
|
4975
|
+
draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex);
|
|
4762
4976
|
} else {
|
|
4763
|
-
|
|
4977
|
+
draw.spliceElementList(elementList, index2 + 1, 1);
|
|
4764
4978
|
}
|
|
4765
4979
|
curIndex = isCollapsed ? index2 : startIndex;
|
|
4766
4980
|
}
|
|
@@ -4769,23 +4983,21 @@ function keydown(evt, host) {
|
|
|
4769
4983
|
} else if (evt.key === KeyMap.Enter) {
|
|
4770
4984
|
if (isReadonly || isPartRangeInControlOutside)
|
|
4771
4985
|
return;
|
|
4772
|
-
const
|
|
4773
|
-
let restArg = {};
|
|
4774
|
-
if (positionContext.isTable) {
|
|
4775
|
-
const { tdId, trId, tableId } = positionContext;
|
|
4776
|
-
restArg = { tdId, trId, tableId };
|
|
4777
|
-
}
|
|
4778
|
-
const enterText = __spreadValues({
|
|
4986
|
+
const enterText = {
|
|
4779
4987
|
value: ZERO
|
|
4780
|
-
}
|
|
4988
|
+
};
|
|
4989
|
+
const endElement = elementList[endIndex];
|
|
4990
|
+
if (!(endElement.titleId && endElement.titleId !== ((_b = elementList[endIndex + 1]) == null ? void 0 : _b.titleId))) {
|
|
4991
|
+
formatElementContext(elementList, [enterText], startIndex);
|
|
4992
|
+
}
|
|
4781
4993
|
let curIndex;
|
|
4782
4994
|
if (activeControl && !control.isRangInPostfix()) {
|
|
4783
4995
|
curIndex = control.setValue([enterText]);
|
|
4784
4996
|
} else {
|
|
4785
4997
|
if (isCollapsed) {
|
|
4786
|
-
|
|
4998
|
+
draw.spliceElementList(elementList, index2 + 1, 0, enterText);
|
|
4787
4999
|
} else {
|
|
4788
|
-
|
|
5000
|
+
draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex, enterText);
|
|
4789
5001
|
}
|
|
4790
5002
|
curIndex = index2 + 1;
|
|
4791
5003
|
}
|
|
@@ -4999,20 +5211,14 @@ function input(data2, host) {
|
|
|
4999
5211
|
`, ZERO);
|
|
5000
5212
|
const rangeManager = draw.getRange();
|
|
5001
5213
|
const { startIndex, endIndex } = rangeManager.getRange();
|
|
5002
|
-
const positionContext = position.getPositionContext();
|
|
5003
|
-
let restArg = {};
|
|
5004
|
-
if (positionContext.isTable) {
|
|
5005
|
-
const { tdId, trId, tableId } = positionContext;
|
|
5006
|
-
restArg = { tdId, trId, tableId };
|
|
5007
|
-
}
|
|
5008
5214
|
const elementList = draw.getElementList();
|
|
5009
|
-
const
|
|
5010
|
-
|
|
5011
|
-
|
|
5215
|
+
const copyElement = getAnchorElement(elementList, endIndex);
|
|
5216
|
+
if (!copyElement)
|
|
5217
|
+
return;
|
|
5012
5218
|
const inputData = splitText(text).map((value) => {
|
|
5013
|
-
const newElement =
|
|
5219
|
+
const newElement = {
|
|
5014
5220
|
value
|
|
5015
|
-
}
|
|
5221
|
+
};
|
|
5016
5222
|
const nextElement = elementList[endIndex + 1];
|
|
5017
5223
|
if (copyElement.type === TEXT || !copyElement.type && copyElement.value !== ZERO || copyElement.type === HYPERLINK && (nextElement == null ? void 0 : nextElement.type) === HYPERLINK || copyElement.type === DATE && (nextElement == null ? void 0 : nextElement.type) === DATE || copyElement.type === SUBSCRIPT && (nextElement == null ? void 0 : nextElement.type) === SUBSCRIPT || copyElement.type === SUPERSCRIPT && (nextElement == null ? void 0 : nextElement.type) === SUPERSCRIPT) {
|
|
5018
5224
|
EDITOR_ELEMENT_COPY_ATTR.forEach((attr) => {
|
|
@@ -5033,11 +5239,10 @@ function input(data2, host) {
|
|
|
5033
5239
|
} else {
|
|
5034
5240
|
const start = startIndex + 1;
|
|
5035
5241
|
if (startIndex !== endIndex) {
|
|
5036
|
-
|
|
5037
|
-
}
|
|
5038
|
-
for (let i = 0; i < inputData.length; i++) {
|
|
5039
|
-
elementList.splice(start + i, 0, inputData[i]);
|
|
5242
|
+
draw.spliceElementList(elementList, start, endIndex - startIndex);
|
|
5040
5243
|
}
|
|
5244
|
+
formatElementContext(elementList, inputData, startIndex);
|
|
5245
|
+
draw.spliceElementList(elementList, start, 0, ...inputData);
|
|
5041
5246
|
curIndex = startIndex + inputData.length;
|
|
5042
5247
|
}
|
|
5043
5248
|
if (~curIndex) {
|
|
@@ -5107,7 +5312,7 @@ function cut(host) {
|
|
|
5107
5312
|
if (activeControl) {
|
|
5108
5313
|
curIndex = control.cut();
|
|
5109
5314
|
} else {
|
|
5110
|
-
|
|
5315
|
+
draw.spliceElementList(elementList, start + 1, end - start);
|
|
5111
5316
|
curIndex = start;
|
|
5112
5317
|
}
|
|
5113
5318
|
rangeManager.setRange(curIndex, curIndex);
|
|
@@ -5650,7 +5855,7 @@ class Position {
|
|
|
5650
5855
|
this.positionList = payload;
|
|
5651
5856
|
}
|
|
5652
5857
|
computePageRowPosition(payload) {
|
|
5653
|
-
const { positionList, rowList, pageNo, startX, startY, startIndex, innerWidth } = payload;
|
|
5858
|
+
const { positionList, rowList, pageNo, startX, startY, startRowIndex, startIndex, innerWidth } = payload;
|
|
5654
5859
|
const { scale, tdPadding } = this.options;
|
|
5655
5860
|
let x = startX;
|
|
5656
5861
|
let y = startY;
|
|
@@ -5662,6 +5867,9 @@ class Position {
|
|
|
5662
5867
|
} else if (curRow.rowFlex === RowFlex.RIGHT) {
|
|
5663
5868
|
x += innerWidth - curRow.width;
|
|
5664
5869
|
}
|
|
5870
|
+
if (curRow.isList) {
|
|
5871
|
+
x += curRow.offsetX || 0;
|
|
5872
|
+
}
|
|
5665
5873
|
const tablePreX = x;
|
|
5666
5874
|
const tablePreY = y;
|
|
5667
5875
|
for (let j = 0; j < curRow.elementList.length; j++) {
|
|
@@ -5672,6 +5880,7 @@ class Position {
|
|
|
5672
5880
|
pageNo,
|
|
5673
5881
|
index: index2,
|
|
5674
5882
|
value: element.value,
|
|
5883
|
+
rowIndex: startRowIndex + i,
|
|
5675
5884
|
rowNo: i,
|
|
5676
5885
|
metrics,
|
|
5677
5886
|
ascent: offsetY,
|
|
@@ -5699,12 +5908,13 @@ class Position {
|
|
|
5699
5908
|
positionList: td.positionList,
|
|
5700
5909
|
rowList: rowList2,
|
|
5701
5910
|
pageNo,
|
|
5911
|
+
startRowIndex: 0,
|
|
5702
5912
|
startIndex: 0,
|
|
5703
5913
|
startX: (td.x + tdPadding) * scale + tablePreX,
|
|
5704
5914
|
startY: td.y * scale + tablePreY,
|
|
5705
5915
|
innerWidth: (td.width - tdGap) * scale
|
|
5706
5916
|
});
|
|
5707
|
-
if (td.verticalAlign === VerticalAlign.MIDDLE || td.verticalAlign
|
|
5917
|
+
if (td.verticalAlign === VerticalAlign.MIDDLE || td.verticalAlign === VerticalAlign.BOTTOM) {
|
|
5708
5918
|
const rowsHeight = rowList2.reduce((pre, cur) => pre + cur.height, 0);
|
|
5709
5919
|
const blankHeight = (td.height - tdGap) * scale - rowsHeight;
|
|
5710
5920
|
const offsetHeight = td.verticalAlign === VerticalAlign.MIDDLE ? blankHeight / 2 : blankHeight;
|
|
@@ -5740,6 +5950,7 @@ class Position {
|
|
|
5740
5950
|
const header = this.draw.getHeader();
|
|
5741
5951
|
const extraHeight = header.getExtraHeight();
|
|
5742
5952
|
const startY = margins[0] + extraHeight;
|
|
5953
|
+
let startRowIndex = 0;
|
|
5743
5954
|
for (let i = 0; i < pageRowList.length; i++) {
|
|
5744
5955
|
const rowList = pageRowList[i];
|
|
5745
5956
|
const startIndex = rowList[0].startIndex;
|
|
@@ -5747,11 +5958,13 @@ class Position {
|
|
|
5747
5958
|
positionList: this.positionList,
|
|
5748
5959
|
rowList,
|
|
5749
5960
|
pageNo: i,
|
|
5961
|
+
startRowIndex,
|
|
5750
5962
|
startIndex,
|
|
5751
5963
|
startX,
|
|
5752
5964
|
startY,
|
|
5753
5965
|
innerWidth
|
|
5754
5966
|
});
|
|
5967
|
+
startRowIndex += rowList.length;
|
|
5755
5968
|
}
|
|
5756
5969
|
}
|
|
5757
5970
|
setCursorPosition(position) {
|
|
@@ -6011,6 +6224,89 @@ class RangeManager {
|
|
|
6011
6224
|
}
|
|
6012
6225
|
return rangeRow;
|
|
6013
6226
|
}
|
|
6227
|
+
getRangeParagraph() {
|
|
6228
|
+
var _a, _b, _c;
|
|
6229
|
+
const { startIndex, endIndex } = this.range;
|
|
6230
|
+
if (!~startIndex && !~endIndex)
|
|
6231
|
+
return null;
|
|
6232
|
+
const positionList = this.position.getPositionList();
|
|
6233
|
+
const elementList = this.draw.getElementList();
|
|
6234
|
+
const rangeRow = new Map();
|
|
6235
|
+
let start = startIndex;
|
|
6236
|
+
while (start > 0) {
|
|
6237
|
+
if (elementList[start].titleId !== ((_a = elementList[start - 1]) == null ? void 0 : _a.titleId))
|
|
6238
|
+
break;
|
|
6239
|
+
const { pageNo, rowNo } = positionList[start];
|
|
6240
|
+
let rowArray = rangeRow.get(pageNo);
|
|
6241
|
+
if (!rowArray) {
|
|
6242
|
+
rowArray = [];
|
|
6243
|
+
rangeRow.set(pageNo, rowArray);
|
|
6244
|
+
}
|
|
6245
|
+
if (!rowArray.includes(rowNo)) {
|
|
6246
|
+
rowArray.unshift(rowNo);
|
|
6247
|
+
}
|
|
6248
|
+
if (((_b = positionList[start]) == null ? void 0 : _b.value) === ZERO)
|
|
6249
|
+
break;
|
|
6250
|
+
start--;
|
|
6251
|
+
}
|
|
6252
|
+
if (startIndex !== endIndex) {
|
|
6253
|
+
let middle = startIndex + 1;
|
|
6254
|
+
while (middle < endIndex) {
|
|
6255
|
+
const { pageNo, rowNo } = positionList[middle];
|
|
6256
|
+
let rowArray = rangeRow.get(pageNo);
|
|
6257
|
+
if (!rowArray) {
|
|
6258
|
+
rowArray = [];
|
|
6259
|
+
rangeRow.set(pageNo, rowArray);
|
|
6260
|
+
}
|
|
6261
|
+
if (!rowArray.includes(rowNo)) {
|
|
6262
|
+
rowArray.push(rowNo);
|
|
6263
|
+
}
|
|
6264
|
+
middle++;
|
|
6265
|
+
}
|
|
6266
|
+
}
|
|
6267
|
+
let end = endIndex;
|
|
6268
|
+
while (end < positionList.length) {
|
|
6269
|
+
if (positionList[end].value === ZERO || elementList[end].titleId !== ((_c = elementList[end + 1]) == null ? void 0 : _c.titleId))
|
|
6270
|
+
break;
|
|
6271
|
+
const { pageNo, rowNo } = positionList[end];
|
|
6272
|
+
let rowArray = rangeRow.get(pageNo);
|
|
6273
|
+
if (!rowArray) {
|
|
6274
|
+
rowArray = [];
|
|
6275
|
+
rangeRow.set(pageNo, rowArray);
|
|
6276
|
+
}
|
|
6277
|
+
if (!rowArray.includes(rowNo)) {
|
|
6278
|
+
rowArray.push(rowNo);
|
|
6279
|
+
}
|
|
6280
|
+
end++;
|
|
6281
|
+
}
|
|
6282
|
+
return rangeRow;
|
|
6283
|
+
}
|
|
6284
|
+
getRangeElementList() {
|
|
6285
|
+
const { startIndex, endIndex } = this.range;
|
|
6286
|
+
if (!~startIndex && !~endIndex)
|
|
6287
|
+
return null;
|
|
6288
|
+
const rangeElementList = [];
|
|
6289
|
+
const rangeRow = this.getRangeParagraph();
|
|
6290
|
+
if (!rangeRow)
|
|
6291
|
+
return null;
|
|
6292
|
+
const elementList = this.draw.getElementList();
|
|
6293
|
+
const positionList = this.position.getPositionList();
|
|
6294
|
+
for (let p = 0; p < positionList.length; p++) {
|
|
6295
|
+
const position = positionList[p];
|
|
6296
|
+
const rowArray = rangeRow.get(position.pageNo);
|
|
6297
|
+
if (!rowArray)
|
|
6298
|
+
continue;
|
|
6299
|
+
if (rowArray.includes(position.rowNo)) {
|
|
6300
|
+
rangeElementList.push(elementList[p]);
|
|
6301
|
+
}
|
|
6302
|
+
}
|
|
6303
|
+
return rangeElementList;
|
|
6304
|
+
}
|
|
6305
|
+
getIsSelectAll() {
|
|
6306
|
+
const elementList = this.draw.getElementList();
|
|
6307
|
+
const { startIndex, endIndex } = this.range;
|
|
6308
|
+
return startIndex === 0 && elementList.length - 1 === endIndex;
|
|
6309
|
+
}
|
|
6014
6310
|
getIsPointInRange(x, y) {
|
|
6015
6311
|
const { startIndex, endIndex } = this.range;
|
|
6016
6312
|
const positionList = this.position.getPositionList();
|
|
@@ -6049,12 +6345,17 @@ class RangeManager {
|
|
|
6049
6345
|
setRangeStyle() {
|
|
6050
6346
|
if (!this.listener.rangeStyleChange)
|
|
6051
6347
|
return;
|
|
6052
|
-
const { endIndex } = this.range;
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6348
|
+
const { endIndex, isCrossRowCol } = this.range;
|
|
6349
|
+
let curElement;
|
|
6350
|
+
if (isCrossRowCol) {
|
|
6351
|
+
const originalElementList = this.draw.getOriginalElementList();
|
|
6352
|
+
const positionContext = this.position.getPositionContext();
|
|
6353
|
+
curElement = originalElementList[positionContext.index];
|
|
6354
|
+
} else {
|
|
6355
|
+
const index2 = ~endIndex ? endIndex : 0;
|
|
6356
|
+
const elementList = this.draw.getElementList();
|
|
6357
|
+
curElement = getAnchorElement(elementList, index2);
|
|
6358
|
+
}
|
|
6058
6359
|
if (!curElement)
|
|
6059
6360
|
return;
|
|
6060
6361
|
const curElementList = this.getSelection() || [curElement];
|
|
@@ -6071,6 +6372,8 @@ class RangeManager {
|
|
|
6071
6372
|
const rowMargin = curElement.rowMargin || this.options.defaultRowMargin;
|
|
6072
6373
|
const dashArray = curElement.dashArray || [];
|
|
6073
6374
|
const level = curElement.level || null;
|
|
6375
|
+
const listType = curElement.listType || null;
|
|
6376
|
+
const listStyle = curElement.listStyle || null;
|
|
6074
6377
|
const painter = !!this.draw.getPainterStyle();
|
|
6075
6378
|
const undo = this.historyManager.isCanUndo();
|
|
6076
6379
|
const redo = this.historyManager.isCanRedo();
|
|
@@ -6090,7 +6393,9 @@ class RangeManager {
|
|
|
6090
6393
|
rowFlex,
|
|
6091
6394
|
rowMargin,
|
|
6092
6395
|
dashArray,
|
|
6093
|
-
level
|
|
6396
|
+
level,
|
|
6397
|
+
listType,
|
|
6398
|
+
listStyle
|
|
6094
6399
|
});
|
|
6095
6400
|
}
|
|
6096
6401
|
recoveryRangeStyle() {
|
|
@@ -6118,7 +6423,9 @@ class RangeManager {
|
|
|
6118
6423
|
rowFlex: null,
|
|
6119
6424
|
rowMargin,
|
|
6120
6425
|
dashArray: [],
|
|
6121
|
-
level: null
|
|
6426
|
+
level: null,
|
|
6427
|
+
listType: null,
|
|
6428
|
+
listStyle: null
|
|
6122
6429
|
});
|
|
6123
6430
|
}
|
|
6124
6431
|
shrinkBoundary() {
|
|
@@ -6665,7 +6972,8 @@ const defaultPageNumberOption = {
|
|
|
6665
6972
|
color: "#000000",
|
|
6666
6973
|
rowFlex: RowFlex.CENTER,
|
|
6667
6974
|
format: FORMAT_PLACEHOLDER.PAGE_NO,
|
|
6668
|
-
numberType: NumberType.ARABIC
|
|
6975
|
+
numberType: NumberType.ARABIC,
|
|
6976
|
+
disabled: false
|
|
6669
6977
|
};
|
|
6670
6978
|
class PageNumber {
|
|
6671
6979
|
constructor(draw) {
|
|
@@ -7441,6 +7749,7 @@ class Header {
|
|
|
7441
7749
|
positionList: this.positionList,
|
|
7442
7750
|
rowList: this.rowList,
|
|
7443
7751
|
pageNo: 0,
|
|
7752
|
+
startRowIndex: 0,
|
|
7444
7753
|
startIndex: 0,
|
|
7445
7754
|
startX,
|
|
7446
7755
|
startY,
|
|
@@ -7448,7 +7757,9 @@ class Header {
|
|
|
7448
7757
|
});
|
|
7449
7758
|
}
|
|
7450
7759
|
getHeaderTop() {
|
|
7451
|
-
const { header: { top }, scale } = this.options;
|
|
7760
|
+
const { header: { top, disabled }, scale } = this.options;
|
|
7761
|
+
if (disabled)
|
|
7762
|
+
return 0;
|
|
7452
7763
|
return Math.floor(top * scale);
|
|
7453
7764
|
}
|
|
7454
7765
|
getMaxHeight() {
|
|
@@ -7708,7 +8019,8 @@ class SelectControl {
|
|
|
7708
8019
|
}
|
|
7709
8020
|
if (!~leftIndex || !~rightIndex)
|
|
7710
8021
|
return -1;
|
|
7711
|
-
|
|
8022
|
+
const draw = this.control.getDraw();
|
|
8023
|
+
draw.spliceElementList(elementList, leftIndex + 1, rightIndex - leftIndex);
|
|
7712
8024
|
this.control.addPlaceholder(preIndex);
|
|
7713
8025
|
this.element.control.code = null;
|
|
7714
8026
|
return preIndex;
|
|
@@ -7727,11 +8039,14 @@ class SelectControl {
|
|
|
7727
8039
|
const startElement = elementList[startIndex];
|
|
7728
8040
|
const start = startIndex + 1;
|
|
7729
8041
|
const data2 = splitText(valueSet.value);
|
|
8042
|
+
const draw = this.control.getDraw();
|
|
7730
8043
|
for (let i = 0; i < data2.length; i++) {
|
|
7731
|
-
|
|
8044
|
+
const newElement = __spreadProps(__spreadValues({}, startElement), {
|
|
7732
8045
|
value: data2[i],
|
|
7733
8046
|
controlComponent: ControlComponent.VALUE
|
|
7734
|
-
})
|
|
8047
|
+
});
|
|
8048
|
+
formatElementContext(elementList, [newElement], startIndex);
|
|
8049
|
+
draw.spliceElementList(elementList, start + i, 0, newElement);
|
|
7735
8050
|
}
|
|
7736
8051
|
const newIndex = start + data2.length - 1;
|
|
7737
8052
|
this.control.repaintControl(newIndex);
|
|
@@ -7835,17 +8150,20 @@ class TextControl {
|
|
|
7835
8150
|
const range = this.control.getRange();
|
|
7836
8151
|
this.control.shrinkBoundary();
|
|
7837
8152
|
const { startIndex, endIndex } = range;
|
|
8153
|
+
const draw = this.control.getDraw();
|
|
7838
8154
|
if (startIndex !== endIndex) {
|
|
7839
|
-
|
|
8155
|
+
draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex);
|
|
7840
8156
|
} else {
|
|
7841
8157
|
this.control.removePlaceholder(startIndex);
|
|
7842
8158
|
}
|
|
7843
8159
|
const startElement = elementList[startIndex];
|
|
7844
8160
|
const start = range.startIndex + 1;
|
|
7845
8161
|
for (let i = 0; i < data2.length; i++) {
|
|
7846
|
-
|
|
8162
|
+
const newElement = __spreadProps(__spreadValues(__spreadValues({}, startElement), data2[i]), {
|
|
7847
8163
|
controlComponent: ControlComponent.VALUE
|
|
7848
|
-
})
|
|
8164
|
+
});
|
|
8165
|
+
formatElementContext(elementList, [newElement], startIndex);
|
|
8166
|
+
draw.spliceElementList(elementList, start + i, 0, newElement);
|
|
7849
8167
|
}
|
|
7850
8168
|
return start + data2.length - 1;
|
|
7851
8169
|
}
|
|
@@ -7856,9 +8174,10 @@ class TextControl {
|
|
|
7856
8174
|
const { startIndex, endIndex } = range;
|
|
7857
8175
|
const startElement = elementList[startIndex];
|
|
7858
8176
|
const endElement = elementList[endIndex];
|
|
8177
|
+
const draw = this.control.getDraw();
|
|
7859
8178
|
if (evt.key === KeyMap.Backspace) {
|
|
7860
8179
|
if (startIndex !== endIndex) {
|
|
7861
|
-
|
|
8180
|
+
draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex);
|
|
7862
8181
|
const value = this.getValue();
|
|
7863
8182
|
if (!value.length) {
|
|
7864
8183
|
this.control.addPlaceholder(startIndex);
|
|
@@ -7868,7 +8187,7 @@ class TextControl {
|
|
|
7868
8187
|
if (startElement.controlComponent === ControlComponent.PREFIX || endElement.controlComponent === ControlComponent.POSTFIX || startElement.controlComponent === ControlComponent.PLACEHOLDER) {
|
|
7869
8188
|
return this.control.removeControl(startIndex);
|
|
7870
8189
|
} else {
|
|
7871
|
-
|
|
8190
|
+
draw.spliceElementList(elementList, startIndex, 1);
|
|
7872
8191
|
const value = this.getValue();
|
|
7873
8192
|
if (!value.length) {
|
|
7874
8193
|
this.control.addPlaceholder(startIndex - 1);
|
|
@@ -7878,7 +8197,7 @@ class TextControl {
|
|
|
7878
8197
|
}
|
|
7879
8198
|
} else if (evt.key === KeyMap.Delete) {
|
|
7880
8199
|
if (startIndex !== endIndex) {
|
|
7881
|
-
|
|
8200
|
+
draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex);
|
|
7882
8201
|
const value = this.getValue();
|
|
7883
8202
|
if (!value.length) {
|
|
7884
8203
|
this.control.addPlaceholder(startIndex);
|
|
@@ -7889,7 +8208,7 @@ class TextControl {
|
|
|
7889
8208
|
if (startElement.controlComponent === ControlComponent.PREFIX && endNextElement.controlComponent === ControlComponent.PLACEHOLDER || endNextElement.controlComponent === ControlComponent.POSTFIX || startElement.controlComponent === ControlComponent.PLACEHOLDER) {
|
|
7890
8209
|
return this.control.removeControl(startIndex);
|
|
7891
8210
|
} else {
|
|
7892
|
-
|
|
8211
|
+
draw.spliceElementList(elementList, startIndex + 1, 1);
|
|
7893
8212
|
const value = this.getValue();
|
|
7894
8213
|
if (!value.length) {
|
|
7895
8214
|
this.control.addPlaceholder(startIndex);
|
|
@@ -7906,8 +8225,9 @@ class TextControl {
|
|
|
7906
8225
|
if (startIndex === endIndex) {
|
|
7907
8226
|
return startIndex;
|
|
7908
8227
|
}
|
|
8228
|
+
const draw = this.control.getDraw();
|
|
7909
8229
|
const elementList = this.control.getElementList();
|
|
7910
|
-
|
|
8230
|
+
draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex);
|
|
7911
8231
|
const value = this.getValue();
|
|
7912
8232
|
if (!value.length) {
|
|
7913
8233
|
this.control.addPlaceholder(startIndex);
|
|
@@ -7928,6 +8248,9 @@ class Control {
|
|
|
7928
8248
|
this.options = draw.getOptions().control;
|
|
7929
8249
|
this.activeControl = null;
|
|
7930
8250
|
}
|
|
8251
|
+
getDraw() {
|
|
8252
|
+
return this.draw;
|
|
8253
|
+
}
|
|
7931
8254
|
isPartRangeInControlOutside() {
|
|
7932
8255
|
const { startIndex, endIndex } = this.getRange();
|
|
7933
8256
|
if (!~startIndex && !~endIndex)
|
|
@@ -8121,7 +8444,7 @@ class Control {
|
|
|
8121
8444
|
if (!~leftIndex && !~rightIndex)
|
|
8122
8445
|
return startIndex;
|
|
8123
8446
|
leftIndex = ~leftIndex ? leftIndex : 0;
|
|
8124
|
-
|
|
8447
|
+
this.draw.spliceElementList(elementList, leftIndex + 1, rightIndex - leftIndex);
|
|
8125
8448
|
return leftIndex;
|
|
8126
8449
|
}
|
|
8127
8450
|
removePlaceholder(startIndex) {
|
|
@@ -8135,7 +8458,7 @@ class Control {
|
|
|
8135
8458
|
if (curElement.controlId !== startElement.controlId)
|
|
8136
8459
|
break;
|
|
8137
8460
|
if (curElement.controlComponent === ControlComponent.PLACEHOLDER) {
|
|
8138
|
-
|
|
8461
|
+
this.draw.spliceElementList(elementList, index2, 1);
|
|
8139
8462
|
} else {
|
|
8140
8463
|
index2++;
|
|
8141
8464
|
}
|
|
@@ -8151,14 +8474,16 @@ class Control {
|
|
|
8151
8474
|
const placeholderStrList = splitText(control.placeholder);
|
|
8152
8475
|
for (let p = 0; p < placeholderStrList.length; p++) {
|
|
8153
8476
|
const value = placeholderStrList[p];
|
|
8154
|
-
|
|
8477
|
+
const newElement = {
|
|
8155
8478
|
value,
|
|
8156
8479
|
controlId: startElement.controlId,
|
|
8157
8480
|
type: ElementType.CONTROL,
|
|
8158
8481
|
control: startElement.control,
|
|
8159
8482
|
controlComponent: ControlComponent.PLACEHOLDER,
|
|
8160
8483
|
color: this.options.placeholderColor
|
|
8161
|
-
}
|
|
8484
|
+
};
|
|
8485
|
+
formatElementContext(elementList, [newElement], startIndex);
|
|
8486
|
+
this.draw.spliceElementList(elementList, startIndex + p + 1, 0, newElement);
|
|
8162
8487
|
}
|
|
8163
8488
|
}
|
|
8164
8489
|
setValue(data2) {
|
|
@@ -8271,6 +8596,12 @@ class Previewer {
|
|
|
8271
8596
|
__publicField(this, "curHandleIndex");
|
|
8272
8597
|
__publicField(this, "previewerContainer");
|
|
8273
8598
|
__publicField(this, "previewerImage");
|
|
8599
|
+
__publicField(this, "_keydown", () => {
|
|
8600
|
+
if (this.resizerSelection.style.display === "block") {
|
|
8601
|
+
this.clearResizer();
|
|
8602
|
+
document.removeEventListener("keydown", this._keydown);
|
|
8603
|
+
}
|
|
8604
|
+
});
|
|
8274
8605
|
this.container = draw.getContainer();
|
|
8275
8606
|
this.canvas = draw.getPage();
|
|
8276
8607
|
this.draw = draw;
|
|
@@ -8543,9 +8874,11 @@ class Previewer {
|
|
|
8543
8874
|
this.curPosition = position;
|
|
8544
8875
|
this.width = this.curElement.width * scale;
|
|
8545
8876
|
this.height = this.curElement.height * scale;
|
|
8877
|
+
document.addEventListener("keydown", this._keydown);
|
|
8546
8878
|
}
|
|
8547
8879
|
clearResizer() {
|
|
8548
8880
|
this.resizerSelection.style.display = "none";
|
|
8881
|
+
document.removeEventListener("keydown", this._keydown);
|
|
8549
8882
|
}
|
|
8550
8883
|
}
|
|
8551
8884
|
const contextmenu$1 = {
|
|
@@ -9090,16 +9423,18 @@ class DateParticle {
|
|
|
9090
9423
|
const [leftIndex, rightIndex] = range;
|
|
9091
9424
|
const elementList = this.draw.getElementList();
|
|
9092
9425
|
const startElement = elementList[leftIndex + 1];
|
|
9093
|
-
|
|
9426
|
+
this.draw.spliceElementList(elementList, leftIndex + 1, rightIndex - leftIndex);
|
|
9094
9427
|
this.range.setRange(leftIndex, leftIndex);
|
|
9095
|
-
|
|
9428
|
+
const dateElement = {
|
|
9096
9429
|
type: ElementType.DATE,
|
|
9097
9430
|
value: "",
|
|
9098
9431
|
dateFormat: startElement.dateFormat,
|
|
9099
9432
|
valueList: [{
|
|
9100
9433
|
value: date
|
|
9101
9434
|
}]
|
|
9102
|
-
}
|
|
9435
|
+
};
|
|
9436
|
+
formatElementContext(elementList, [dateElement], leftIndex);
|
|
9437
|
+
this.draw.insertElementList([dateElement]);
|
|
9103
9438
|
}
|
|
9104
9439
|
getDateElementRange() {
|
|
9105
9440
|
let leftIndex = -1;
|
|
@@ -9596,6 +9931,7 @@ class Footer {
|
|
|
9596
9931
|
positionList: this.positionList,
|
|
9597
9932
|
rowList: this.rowList,
|
|
9598
9933
|
pageNo: 0,
|
|
9934
|
+
startRowIndex: 0,
|
|
9599
9935
|
startIndex: 0,
|
|
9600
9936
|
startX,
|
|
9601
9937
|
startY,
|
|
@@ -9603,7 +9939,9 @@ class Footer {
|
|
|
9603
9939
|
});
|
|
9604
9940
|
}
|
|
9605
9941
|
getFooterBottom() {
|
|
9606
|
-
const { footer: { bottom }, scale } = this.options;
|
|
9942
|
+
const { footer: { bottom, disabled }, scale } = this.options;
|
|
9943
|
+
if (disabled)
|
|
9944
|
+
return 0;
|
|
9607
9945
|
return Math.floor(bottom * scale);
|
|
9608
9946
|
}
|
|
9609
9947
|
getMaxHeight() {
|
|
@@ -9651,6 +9989,85 @@ class Footer {
|
|
|
9651
9989
|
});
|
|
9652
9990
|
}
|
|
9653
9991
|
}
|
|
9992
|
+
class ListParticle {
|
|
9993
|
+
constructor(draw) {
|
|
9994
|
+
__publicField(this, "options");
|
|
9995
|
+
__publicField(this, "UN_COUNT_STYLE_WIDTH", 20);
|
|
9996
|
+
__publicField(this, "MEASURE_BASE_TEXT", "0");
|
|
9997
|
+
__publicField(this, "LIST_GAP", 10);
|
|
9998
|
+
this.options = draw.getOptions();
|
|
9999
|
+
}
|
|
10000
|
+
computeListStyle(ctx, elementList) {
|
|
10001
|
+
const listStyleMap = new Map();
|
|
10002
|
+
let start = 0;
|
|
10003
|
+
let curListId = elementList[start].listId;
|
|
10004
|
+
let curElementList = [];
|
|
10005
|
+
const elementLength = elementList.length;
|
|
10006
|
+
while (start < elementLength) {
|
|
10007
|
+
const curElement = elementList[start];
|
|
10008
|
+
if (curListId && curListId === curElement.listId) {
|
|
10009
|
+
curElementList.push(curElement);
|
|
10010
|
+
} else {
|
|
10011
|
+
if (curElement.listId && curElement.listId !== curListId) {
|
|
10012
|
+
if (curElementList.length) {
|
|
10013
|
+
const width = this.getListStyleWidth(ctx, curElementList);
|
|
10014
|
+
listStyleMap.set(curListId, width);
|
|
10015
|
+
}
|
|
10016
|
+
curListId = curElement.listId;
|
|
10017
|
+
curElementList = curListId ? [curElement] : [];
|
|
10018
|
+
}
|
|
10019
|
+
}
|
|
10020
|
+
start++;
|
|
10021
|
+
}
|
|
10022
|
+
if (curElementList.length) {
|
|
10023
|
+
const width = this.getListStyleWidth(ctx, curElementList);
|
|
10024
|
+
listStyleMap.set(curListId, width);
|
|
10025
|
+
}
|
|
10026
|
+
return listStyleMap;
|
|
10027
|
+
}
|
|
10028
|
+
getListStyleWidth(ctx, listElementList) {
|
|
10029
|
+
const { scale } = this.options;
|
|
10030
|
+
const startElement = listElementList[0];
|
|
10031
|
+
if (startElement.listStyle && startElement.listStyle !== ListStyle.DECIMAL) {
|
|
10032
|
+
return this.UN_COUNT_STYLE_WIDTH * scale;
|
|
10033
|
+
}
|
|
10034
|
+
const count = listElementList.reduce((pre, cur) => {
|
|
10035
|
+
if (cur.value === ZERO) {
|
|
10036
|
+
pre += 1;
|
|
10037
|
+
}
|
|
10038
|
+
return pre;
|
|
10039
|
+
}, 0);
|
|
10040
|
+
if (!count)
|
|
10041
|
+
return 0;
|
|
10042
|
+
const text = `${this.MEASURE_BASE_TEXT.repeat(String(count).length)}${KeyMap.PERIOD}`;
|
|
10043
|
+
const textMetrics = ctx.measureText(text);
|
|
10044
|
+
return Math.ceil((textMetrics.width + this.LIST_GAP) * scale);
|
|
10045
|
+
}
|
|
10046
|
+
drawListStyle(ctx, row, position) {
|
|
10047
|
+
const { elementList, offsetX, listIndex, ascent } = row;
|
|
10048
|
+
const startElement = elementList[0];
|
|
10049
|
+
if (startElement.value !== ZERO)
|
|
10050
|
+
return;
|
|
10051
|
+
let text = "";
|
|
10052
|
+
if (startElement.listType === ListType.UL) {
|
|
10053
|
+
if (startElement.listStyle) {
|
|
10054
|
+
text = ulStyleMapping[startElement.listStyle] || ulStyleMapping[UlStyle.DISC];
|
|
10055
|
+
}
|
|
10056
|
+
} else {
|
|
10057
|
+
text = `${listIndex + 1}${KeyMap.PERIOD}`;
|
|
10058
|
+
}
|
|
10059
|
+
if (!text)
|
|
10060
|
+
return;
|
|
10061
|
+
const { coordinate: { leftTop: [startX, startY] } } = position;
|
|
10062
|
+
const x = startX - offsetX;
|
|
10063
|
+
const y = startY + ascent;
|
|
10064
|
+
const { defaultFont, defaultSize, scale } = this.options;
|
|
10065
|
+
ctx.save();
|
|
10066
|
+
ctx.font = `${defaultSize * scale}px ${defaultFont}`;
|
|
10067
|
+
ctx.fillText(text, x, y);
|
|
10068
|
+
ctx.restore();
|
|
10069
|
+
}
|
|
10070
|
+
}
|
|
9654
10071
|
class Draw {
|
|
9655
10072
|
constructor(rootContainer, options, data2, listener) {
|
|
9656
10073
|
__publicField(this, "container");
|
|
@@ -9696,6 +10113,7 @@ class Draw {
|
|
|
9696
10113
|
__publicField(this, "subscriptParticle");
|
|
9697
10114
|
__publicField(this, "checkboxParticle");
|
|
9698
10115
|
__publicField(this, "blockParticle");
|
|
10116
|
+
__publicField(this, "listParticle");
|
|
9699
10117
|
__publicField(this, "control");
|
|
9700
10118
|
__publicField(this, "workerManager");
|
|
9701
10119
|
__publicField(this, "scrollObserver");
|
|
@@ -9750,6 +10168,7 @@ class Draw {
|
|
|
9750
10168
|
this.subscriptParticle = new SubscriptParticle();
|
|
9751
10169
|
this.checkboxParticle = new CheckboxParticle(this);
|
|
9752
10170
|
this.blockParticle = new BlockParticle(this);
|
|
10171
|
+
this.listParticle = new ListParticle(this);
|
|
9753
10172
|
this.control = new Control(this);
|
|
9754
10173
|
this.scrollObserver = new ScrollObserver(this);
|
|
9755
10174
|
this.selectionObserver = new SelectionObserver();
|
|
@@ -9980,18 +10399,9 @@ class Draw {
|
|
|
9980
10399
|
const isCollapsed = startIndex === endIndex;
|
|
9981
10400
|
const start = startIndex + 1;
|
|
9982
10401
|
if (!isCollapsed) {
|
|
9983
|
-
|
|
9984
|
-
}
|
|
9985
|
-
const positionContext = this.position.getPositionContext();
|
|
9986
|
-
for (let i = 0; i < payload.length; i++) {
|
|
9987
|
-
const element = payload[i];
|
|
9988
|
-
if (positionContext.isTable) {
|
|
9989
|
-
element.tdId = positionContext.tdId;
|
|
9990
|
-
element.trId = positionContext.trId;
|
|
9991
|
-
element.tableId = positionContext.tableId;
|
|
9992
|
-
}
|
|
9993
|
-
elementList.splice(start + i, 0, element);
|
|
10402
|
+
this.spliceElementList(elementList, start, endIndex - startIndex);
|
|
9994
10403
|
}
|
|
10404
|
+
this.spliceElementList(elementList, start, 0, ...payload);
|
|
9995
10405
|
curIndex = startIndex + payload.length;
|
|
9996
10406
|
}
|
|
9997
10407
|
if (~curIndex) {
|
|
@@ -10001,6 +10411,27 @@ class Draw {
|
|
|
10001
10411
|
});
|
|
10002
10412
|
}
|
|
10003
10413
|
}
|
|
10414
|
+
spliceElementList(elementList, start, deleteCount, ...items) {
|
|
10415
|
+
var _a;
|
|
10416
|
+
if (deleteCount > 0) {
|
|
10417
|
+
const endIndex = start + deleteCount;
|
|
10418
|
+
const endElement = elementList[endIndex];
|
|
10419
|
+
const endElementListId = endElement == null ? void 0 : endElement.listId;
|
|
10420
|
+
if (endElementListId && ((_a = elementList[start - 1]) == null ? void 0 : _a.listId) !== endElementListId) {
|
|
10421
|
+
let startIndex = endIndex;
|
|
10422
|
+
while (startIndex < elementList.length) {
|
|
10423
|
+
const curElement = elementList[startIndex];
|
|
10424
|
+
if (curElement.listId !== endElementListId || curElement.value === ZERO)
|
|
10425
|
+
break;
|
|
10426
|
+
delete curElement.listId;
|
|
10427
|
+
delete curElement.listType;
|
|
10428
|
+
delete curElement.listStyle;
|
|
10429
|
+
startIndex++;
|
|
10430
|
+
}
|
|
10431
|
+
}
|
|
10432
|
+
}
|
|
10433
|
+
elementList.splice(start, deleteCount, ...items);
|
|
10434
|
+
}
|
|
10004
10435
|
getCanvasEvent() {
|
|
10005
10436
|
return this.canvasEvent;
|
|
10006
10437
|
}
|
|
@@ -10031,6 +10462,9 @@ class Draw {
|
|
|
10031
10462
|
getDateParticle() {
|
|
10032
10463
|
return this.dateParticle;
|
|
10033
10464
|
}
|
|
10465
|
+
getListParticle() {
|
|
10466
|
+
return this.listParticle;
|
|
10467
|
+
}
|
|
10034
10468
|
getControl() {
|
|
10035
10469
|
return this.control;
|
|
10036
10470
|
}
|
|
@@ -10137,15 +10571,17 @@ class Draw {
|
|
|
10137
10571
|
});
|
|
10138
10572
|
}
|
|
10139
10573
|
setPaperSize(width, height) {
|
|
10140
|
-
const dpr = window.devicePixelRatio;
|
|
10141
10574
|
this.options.width = width;
|
|
10142
10575
|
this.options.height = height;
|
|
10143
|
-
|
|
10576
|
+
const dpr = window.devicePixelRatio;
|
|
10577
|
+
const realWidth = this.getWidth();
|
|
10578
|
+
const realHeight = this.getHeight();
|
|
10579
|
+
this.container.style.width = `${realWidth}px`;
|
|
10144
10580
|
this.pageList.forEach((p, i) => {
|
|
10145
|
-
p.width =
|
|
10146
|
-
p.height =
|
|
10147
|
-
p.style.width = `${
|
|
10148
|
-
p.style.height = `${
|
|
10581
|
+
p.width = realWidth * dpr;
|
|
10582
|
+
p.height = realHeight * dpr;
|
|
10583
|
+
p.style.width = `${realWidth}px`;
|
|
10584
|
+
p.style.height = `${realHeight}px`;
|
|
10149
10585
|
this._initPageContext(this.ctxList[i]);
|
|
10150
10586
|
});
|
|
10151
10587
|
this.render({
|
|
@@ -10249,6 +10685,7 @@ class Draw {
|
|
|
10249
10685
|
const defaultBasicRowMarginHeight = this.getDefaultBasicRowMarginHeight();
|
|
10250
10686
|
const canvas = document.createElement("canvas");
|
|
10251
10687
|
const ctx = canvas.getContext("2d");
|
|
10688
|
+
const listStyleMap = this.listParticle.computeListStyle(ctx, elementList);
|
|
10252
10689
|
const rowList = [];
|
|
10253
10690
|
if (elementList.length) {
|
|
10254
10691
|
rowList.push({
|
|
@@ -10260,6 +10697,8 @@ class Draw {
|
|
|
10260
10697
|
rowFlex: (_a = elementList == null ? void 0 : elementList[1]) == null ? void 0 : _a.rowFlex
|
|
10261
10698
|
});
|
|
10262
10699
|
}
|
|
10700
|
+
let listId;
|
|
10701
|
+
let listIndex = 0;
|
|
10263
10702
|
for (let i = 0; i < elementList.length; i++) {
|
|
10264
10703
|
const curRow = rowList[rowList.length - 1];
|
|
10265
10704
|
const element = elementList[i];
|
|
@@ -10270,14 +10709,17 @@ class Draw {
|
|
|
10270
10709
|
boundingBoxAscent: 0,
|
|
10271
10710
|
boundingBoxDescent: 0
|
|
10272
10711
|
};
|
|
10712
|
+
const offsetX = element.listId ? listStyleMap.get(element.listId) || 0 : 0;
|
|
10713
|
+
const availableWidth = innerWidth - offsetX;
|
|
10273
10714
|
if (element.type === ElementType.IMAGE || element.type === ElementType.LATEX) {
|
|
10274
10715
|
const elementWidth = element.width * scale;
|
|
10275
10716
|
const elementHeight = element.height * scale;
|
|
10276
10717
|
const curRowWidth2 = element.imgDisplay === ImageDisplay.INLINE ? 0 : curRow.width;
|
|
10277
|
-
if (curRowWidth2 + elementWidth >
|
|
10278
|
-
const surplusWidth =
|
|
10279
|
-
|
|
10280
|
-
element.
|
|
10718
|
+
if (curRowWidth2 + elementWidth > availableWidth) {
|
|
10719
|
+
const surplusWidth = availableWidth - curRowWidth2;
|
|
10720
|
+
const adaptiveWidth = surplusWidth > 0 ? surplusWidth : Math.min(elementWidth, availableWidth);
|
|
10721
|
+
element.width = adaptiveWidth;
|
|
10722
|
+
element.height = elementHeight * adaptiveWidth / elementWidth;
|
|
10281
10723
|
metrics.width = element.width;
|
|
10282
10724
|
metrics.height = element.height;
|
|
10283
10725
|
metrics.boundingBoxDescent = element.height;
|
|
@@ -10396,7 +10838,7 @@ class Draw {
|
|
|
10396
10838
|
const cloneElement = deepClone(element);
|
|
10397
10839
|
cloneElement.trList = cloneTrList;
|
|
10398
10840
|
cloneElement.id = getUUID();
|
|
10399
|
-
|
|
10841
|
+
this.spliceElementList(elementList, i + 1, 0, cloneElement);
|
|
10400
10842
|
const positionContext = this.position.getPositionContext();
|
|
10401
10843
|
if (positionContext.isTable && positionContext.trIndex === deleteStart) {
|
|
10402
10844
|
positionContext.index += 1;
|
|
@@ -10406,14 +10848,14 @@ class Draw {
|
|
|
10406
10848
|
}
|
|
10407
10849
|
}
|
|
10408
10850
|
} else if (element.type === ElementType.SEPARATOR) {
|
|
10409
|
-
element.width =
|
|
10410
|
-
metrics.width =
|
|
10851
|
+
element.width = availableWidth;
|
|
10852
|
+
metrics.width = availableWidth;
|
|
10411
10853
|
metrics.height = defaultSize;
|
|
10412
10854
|
metrics.boundingBoxAscent = -rowMargin;
|
|
10413
10855
|
metrics.boundingBoxDescent = -rowMargin;
|
|
10414
10856
|
} else if (element.type === ElementType.PAGE_BREAK) {
|
|
10415
|
-
element.width =
|
|
10416
|
-
metrics.width =
|
|
10857
|
+
element.width = availableWidth;
|
|
10858
|
+
metrics.width = availableWidth;
|
|
10417
10859
|
metrics.height = defaultSize;
|
|
10418
10860
|
} else if (element.type === ElementType.CHECKBOX || element.controlComponent === ControlComponent.CHECKBOX) {
|
|
10419
10861
|
const { width, height: height2, gap } = this.options.checkbox;
|
|
@@ -10427,12 +10869,11 @@ class Draw {
|
|
|
10427
10869
|
metrics.boundingBoxDescent = 0;
|
|
10428
10870
|
metrics.boundingBoxAscent = metrics.height;
|
|
10429
10871
|
} else if (element.type === ElementType.BLOCK) {
|
|
10430
|
-
const innerWidth2 = this.getInnerWidth();
|
|
10431
10872
|
if (!element.width) {
|
|
10432
|
-
metrics.width =
|
|
10873
|
+
metrics.width = availableWidth;
|
|
10433
10874
|
} else {
|
|
10434
10875
|
const elementWidth = element.width * scale;
|
|
10435
|
-
metrics.width = elementWidth
|
|
10876
|
+
metrics.width = Math.min(elementWidth, availableWidth);
|
|
10436
10877
|
}
|
|
10437
10878
|
metrics.height = element.height * scale;
|
|
10438
10879
|
metrics.boundingBoxDescent = metrics.height;
|
|
@@ -10457,9 +10898,8 @@ class Draw {
|
|
|
10457
10898
|
metrics.boundingBoxDescent += metrics.height / 2;
|
|
10458
10899
|
}
|
|
10459
10900
|
}
|
|
10460
|
-
const ascent = metrics.boundingBoxAscent + rowMargin;
|
|
10461
|
-
const
|
|
10462
|
-
const height = ascent + descent;
|
|
10901
|
+
const ascent = element.imgDisplay !== ImageDisplay.INLINE && element.type === ElementType.IMAGE || element.type === ElementType.LATEX ? metrics.height + rowMargin : metrics.boundingBoxAscent + rowMargin;
|
|
10902
|
+
const height = rowMargin + metrics.boundingBoxAscent + metrics.boundingBoxDescent + rowMargin;
|
|
10463
10903
|
const rowElement = Object.assign(element, {
|
|
10464
10904
|
metrics,
|
|
10465
10905
|
style: this._getFont(element, scale)
|
|
@@ -10467,19 +10907,27 @@ class Draw {
|
|
|
10467
10907
|
const preElement = elementList[i - 1];
|
|
10468
10908
|
const nextElement = elementList[i + 1];
|
|
10469
10909
|
const curRowWidth = curRow.width + metrics.width + this.textParticle.measurePunctuationWidth(ctx, nextElement);
|
|
10470
|
-
if (element.
|
|
10471
|
-
if (
|
|
10910
|
+
if (element.listId) {
|
|
10911
|
+
if (element.listId !== listId) {
|
|
10912
|
+
listIndex = 0;
|
|
10913
|
+
} else if (element.value === ZERO) {
|
|
10914
|
+
listIndex++;
|
|
10915
|
+
}
|
|
10916
|
+
}
|
|
10917
|
+
listId = element.listId;
|
|
10918
|
+
if (element.type === ElementType.TABLE || (preElement == null ? void 0 : preElement.type) === ElementType.TABLE || (preElement == null ? void 0 : preElement.type) === ElementType.BLOCK || element.type === ElementType.BLOCK || (preElement == null ? void 0 : preElement.imgDisplay) === ImageDisplay.INLINE || element.imgDisplay === ImageDisplay.INLINE || curRowWidth > availableWidth || i !== 0 && element.value === ZERO || (preElement == null ? void 0 : preElement.listId) !== element.listId) {
|
|
10919
|
+
if (curRow.startIndex === 0 && curRow.elementList.length === 1 && (INLINE_ELEMENT_TYPE.includes(element.type) || element.listId)) {
|
|
10472
10920
|
curRow.height = defaultBasicRowMarginHeight;
|
|
10473
10921
|
}
|
|
10474
|
-
if ((preElement == null ? void 0 : preElement.rowFlex) === RowFlex.ALIGNMENT && curRowWidth >
|
|
10475
|
-
const gap = (
|
|
10922
|
+
if ((preElement == null ? void 0 : preElement.rowFlex) === RowFlex.ALIGNMENT && curRowWidth > availableWidth) {
|
|
10923
|
+
const gap = (availableWidth - curRow.width) / curRow.elementList.length;
|
|
10476
10924
|
for (let e = 0; e < curRow.elementList.length; e++) {
|
|
10477
10925
|
const el = curRow.elementList[e];
|
|
10478
10926
|
el.metrics.width += gap;
|
|
10479
10927
|
}
|
|
10480
|
-
curRow.width =
|
|
10928
|
+
curRow.width = availableWidth;
|
|
10481
10929
|
}
|
|
10482
|
-
|
|
10930
|
+
const row = {
|
|
10483
10931
|
width: metrics.width,
|
|
10484
10932
|
height,
|
|
10485
10933
|
startIndex: i,
|
|
@@ -10487,16 +10935,18 @@ class Draw {
|
|
|
10487
10935
|
ascent,
|
|
10488
10936
|
rowFlex: (_d = elementList[i + 1]) == null ? void 0 : _d.rowFlex,
|
|
10489
10937
|
isPageBreak: element.type === ElementType.PAGE_BREAK
|
|
10490
|
-
}
|
|
10938
|
+
};
|
|
10939
|
+
if (element.listId) {
|
|
10940
|
+
row.isList = true;
|
|
10941
|
+
row.offsetX = listStyleMap.get(element.listId);
|
|
10942
|
+
row.listIndex = listIndex;
|
|
10943
|
+
}
|
|
10944
|
+
rowList.push(row);
|
|
10491
10945
|
} else {
|
|
10492
10946
|
curRow.width += metrics.width;
|
|
10493
10947
|
if (curRow.height < height) {
|
|
10494
10948
|
curRow.height = height;
|
|
10495
|
-
|
|
10496
|
-
curRow.ascent = metrics.height;
|
|
10497
|
-
} else {
|
|
10498
|
-
curRow.ascent = ascent;
|
|
10499
|
-
}
|
|
10949
|
+
curRow.ascent = ascent;
|
|
10500
10950
|
}
|
|
10501
10951
|
curRow.elementList.push(rowElement);
|
|
10502
10952
|
}
|
|
@@ -10675,6 +11125,9 @@ class Draw {
|
|
|
10675
11125
|
}
|
|
10676
11126
|
}
|
|
10677
11127
|
}
|
|
11128
|
+
if (curRow.isList) {
|
|
11129
|
+
this.listParticle.drawListStyle(ctx, curRow, positionList[curRow.startIndex]);
|
|
11130
|
+
}
|
|
10678
11131
|
this._drawRichText(ctx);
|
|
10679
11132
|
if (rangeRecord.width && rangeRecord.height) {
|
|
10680
11133
|
const { x, y, width, height } = rangeRecord;
|
|
@@ -10694,7 +11147,7 @@ class Draw {
|
|
|
10694
11147
|
}
|
|
10695
11148
|
_drawPage(payload) {
|
|
10696
11149
|
const { elementList, positionList, rowList, pageNo } = payload;
|
|
10697
|
-
const { inactiveAlpha, pageMode } = this.options;
|
|
11150
|
+
const { inactiveAlpha, pageMode, header, footer, pageNumber } = this.options;
|
|
10698
11151
|
const innerWidth = this.getInnerWidth();
|
|
10699
11152
|
const ctx = this.ctxList[pageNo];
|
|
10700
11153
|
ctx.globalAlpha = !this.zone.isMainActive() ? inactiveAlpha : 1;
|
|
@@ -10711,9 +11164,15 @@ class Draw {
|
|
|
10711
11164
|
innerWidth,
|
|
10712
11165
|
zone: EditorZone.MAIN
|
|
10713
11166
|
});
|
|
10714
|
-
|
|
10715
|
-
|
|
10716
|
-
|
|
11167
|
+
if (!header.disabled) {
|
|
11168
|
+
this.header.render(ctx, pageNo);
|
|
11169
|
+
}
|
|
11170
|
+
if (!pageNumber.disabled) {
|
|
11171
|
+
this.pageNumber.render(ctx, pageNo);
|
|
11172
|
+
}
|
|
11173
|
+
if (!footer.disabled) {
|
|
11174
|
+
this.footer.render(ctx, pageNo);
|
|
11175
|
+
}
|
|
10717
11176
|
if (this.search.getSearchKeyword()) {
|
|
10718
11177
|
this.search.render(ctx, pageNo);
|
|
10719
11178
|
}
|
|
@@ -10757,13 +11216,17 @@ class Draw {
|
|
|
10757
11216
|
}
|
|
10758
11217
|
render(payload) {
|
|
10759
11218
|
var _a;
|
|
10760
|
-
const { pageMode } = this.options;
|
|
11219
|
+
const { pageMode, header, footer } = this.options;
|
|
10761
11220
|
const { isSubmitHistory = true, isSetCursor = true, isCompute = true, isLazy = true } = payload || {};
|
|
10762
11221
|
let { curIndex } = payload || {};
|
|
10763
11222
|
const innerWidth = this.getInnerWidth();
|
|
10764
11223
|
if (isCompute) {
|
|
10765
|
-
|
|
10766
|
-
|
|
11224
|
+
if (!header.disabled) {
|
|
11225
|
+
this.header.compute();
|
|
11226
|
+
}
|
|
11227
|
+
if (!footer.disabled) {
|
|
11228
|
+
this.footer.compute();
|
|
11229
|
+
}
|
|
10767
11230
|
this.rowList = this.computeRowList(innerWidth, this.elementList);
|
|
10768
11231
|
this.pageRowList = this._computePageList();
|
|
10769
11232
|
this.position.computePositionList();
|
|
@@ -10877,6 +11340,7 @@ const _Command = class {
|
|
|
10877
11340
|
_Command.color = adapt.color.bind(adapt);
|
|
10878
11341
|
_Command.highlight = adapt.highlight.bind(adapt);
|
|
10879
11342
|
_Command.title = adapt.title.bind(adapt);
|
|
11343
|
+
_Command.list = adapt.list.bind(adapt);
|
|
10880
11344
|
_Command.left = adapt.rowFlex.bind(adapt);
|
|
10881
11345
|
_Command.center = adapt.rowFlex.bind(adapt);
|
|
10882
11346
|
_Command.right = adapt.rowFlex.bind(adapt);
|
|
@@ -11018,6 +11482,9 @@ const _Command = class {
|
|
|
11018
11482
|
executeRowMargin(payload) {
|
|
11019
11483
|
return _Command.rowMargin(payload);
|
|
11020
11484
|
}
|
|
11485
|
+
executeList(listType, listStyle) {
|
|
11486
|
+
return _Command.list(listType, listStyle);
|
|
11487
|
+
}
|
|
11021
11488
|
executeInsertTable(row, col) {
|
|
11022
11489
|
return _Command.insertTable(row, col);
|
|
11023
11490
|
}
|
|
@@ -11180,6 +11647,7 @@ __publicField(Command, "subscript");
|
|
|
11180
11647
|
__publicField(Command, "color");
|
|
11181
11648
|
__publicField(Command, "highlight");
|
|
11182
11649
|
__publicField(Command, "title");
|
|
11650
|
+
__publicField(Command, "list");
|
|
11183
11651
|
__publicField(Command, "left");
|
|
11184
11652
|
__publicField(Command, "center");
|
|
11185
11653
|
__publicField(Command, "right");
|
|
@@ -11352,9 +11820,9 @@ class CommandAdapt {
|
|
|
11352
11820
|
return;
|
|
11353
11821
|
}
|
|
11354
11822
|
if (!isCollapsed) {
|
|
11355
|
-
|
|
11823
|
+
this.draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex);
|
|
11356
11824
|
} else {
|
|
11357
|
-
|
|
11825
|
+
this.draw.spliceElementList(elementList, startIndex, 1);
|
|
11358
11826
|
}
|
|
11359
11827
|
const curIndex = isCollapsed ? startIndex - 1 : startIndex;
|
|
11360
11828
|
this.range.setRange(curIndex, curIndex);
|
|
@@ -11647,25 +12115,10 @@ class CommandAdapt {
|
|
|
11647
12115
|
const { startIndex, endIndex } = this.range.getRange();
|
|
11648
12116
|
if (!~startIndex && !~endIndex)
|
|
11649
12117
|
return;
|
|
11650
|
-
let changeElementList = [];
|
|
11651
12118
|
const elementList = this.draw.getElementList();
|
|
11652
|
-
|
|
11653
|
-
|
|
11654
|
-
|
|
11655
|
-
return;
|
|
11656
|
-
const positionList = this.position.getPositionList();
|
|
11657
|
-
for (let p = 0; p < positionList.length; p++) {
|
|
11658
|
-
const position = positionList[p];
|
|
11659
|
-
const rowSet = rangeRow.get(position.pageNo);
|
|
11660
|
-
if (!rowSet)
|
|
11661
|
-
continue;
|
|
11662
|
-
if (rowSet.has(position.rowNo)) {
|
|
11663
|
-
changeElementList.push(elementList[p]);
|
|
11664
|
-
}
|
|
11665
|
-
}
|
|
11666
|
-
} else {
|
|
11667
|
-
changeElementList = elementList.slice(startIndex + 1, endIndex + 1);
|
|
11668
|
-
}
|
|
12119
|
+
const changeElementList = startIndex === endIndex ? this.range.getRangeElementList() : elementList.slice(startIndex + 1, endIndex + 1);
|
|
12120
|
+
if (!changeElementList || !changeElementList.length)
|
|
12121
|
+
return;
|
|
11669
12122
|
const titleId = getUUID();
|
|
11670
12123
|
const titleOptions = this.draw.getOptions().title;
|
|
11671
12124
|
changeElementList.forEach((el) => {
|
|
@@ -11691,6 +12144,35 @@ class CommandAdapt {
|
|
|
11691
12144
|
const curIndex = isSetCursor ? endIndex : startIndex;
|
|
11692
12145
|
this.draw.render({ curIndex, isSetCursor });
|
|
11693
12146
|
}
|
|
12147
|
+
list(listType, listStyle) {
|
|
12148
|
+
const isReadonly = this.draw.isReadonly();
|
|
12149
|
+
if (isReadonly)
|
|
12150
|
+
return;
|
|
12151
|
+
const { startIndex, endIndex } = this.range.getRange();
|
|
12152
|
+
if (!~startIndex && !~endIndex)
|
|
12153
|
+
return;
|
|
12154
|
+
const changeElementList = this.range.getRangeElementList();
|
|
12155
|
+
if (!changeElementList || !changeElementList.length)
|
|
12156
|
+
return;
|
|
12157
|
+
const isUnsetList = changeElementList.find((el) => el.listType === listType && el.listStyle === listStyle);
|
|
12158
|
+
const listId = getUUID();
|
|
12159
|
+
changeElementList.forEach((el) => {
|
|
12160
|
+
if (!isUnsetList && listType) {
|
|
12161
|
+
el.listId = listId;
|
|
12162
|
+
el.listType = listType;
|
|
12163
|
+
el.listStyle = listStyle;
|
|
12164
|
+
} else {
|
|
12165
|
+
if (el.listId) {
|
|
12166
|
+
delete el.listId;
|
|
12167
|
+
delete el.listType;
|
|
12168
|
+
delete el.listStyle;
|
|
12169
|
+
}
|
|
12170
|
+
}
|
|
12171
|
+
});
|
|
12172
|
+
const isSetCursor = startIndex === endIndex;
|
|
12173
|
+
const curIndex = isSetCursor ? endIndex : startIndex;
|
|
12174
|
+
this.draw.render({ curIndex, isSetCursor });
|
|
12175
|
+
}
|
|
11694
12176
|
rowFlex(payload) {
|
|
11695
12177
|
const isReadonly = this.draw.isReadonly();
|
|
11696
12178
|
if (isReadonly)
|
|
@@ -11742,6 +12224,7 @@ class CommandAdapt {
|
|
|
11742
12224
|
this.draw.render({ curIndex, isSetCursor });
|
|
11743
12225
|
}
|
|
11744
12226
|
insertTable(row, col) {
|
|
12227
|
+
var _a;
|
|
11745
12228
|
const isReadonly = this.draw.isReadonly();
|
|
11746
12229
|
if (isReadonly)
|
|
11747
12230
|
return;
|
|
@@ -11752,7 +12235,15 @@ class CommandAdapt {
|
|
|
11752
12235
|
if (!~startIndex && !~endIndex)
|
|
11753
12236
|
return;
|
|
11754
12237
|
const elementList = this.draw.getElementList();
|
|
11755
|
-
|
|
12238
|
+
let offsetX = 0;
|
|
12239
|
+
if ((_a = elementList[startIndex]) == null ? void 0 : _a.listId) {
|
|
12240
|
+
const positionList = this.position.getPositionList();
|
|
12241
|
+
const { rowIndex } = positionList[startIndex];
|
|
12242
|
+
const rowList = this.draw.getRowList();
|
|
12243
|
+
const row2 = rowList[rowIndex];
|
|
12244
|
+
offsetX = (row2 == null ? void 0 : row2.offsetX) || 0;
|
|
12245
|
+
}
|
|
12246
|
+
const innerWidth = this.draw.getOriginalInnerWidth() - offsetX;
|
|
11756
12247
|
const colgroup = [];
|
|
11757
12248
|
const colWidth = innerWidth / col;
|
|
11758
12249
|
for (let c = 0; c < col; c++) {
|
|
@@ -11785,12 +12276,9 @@ class CommandAdapt {
|
|
|
11785
12276
|
formatElementList([element], {
|
|
11786
12277
|
editorOptions: this.options
|
|
11787
12278
|
});
|
|
12279
|
+
formatElementContext(elementList, [element], startIndex);
|
|
11788
12280
|
const curIndex = startIndex + 1;
|
|
11789
|
-
|
|
11790
|
-
elementList.splice(curIndex, 0, element);
|
|
11791
|
-
} else {
|
|
11792
|
-
elementList.splice(curIndex, endIndex - startIndex, element);
|
|
11793
|
-
}
|
|
12281
|
+
this.draw.spliceElementList(elementList, curIndex, startIndex === endIndex ? 0 : endIndex - startIndex, element);
|
|
11794
12282
|
this.range.setRange(curIndex, curIndex);
|
|
11795
12283
|
this.draw.render({ curIndex, isSetCursor: false });
|
|
11796
12284
|
}
|
|
@@ -12364,11 +12852,8 @@ class CommandAdapt {
|
|
|
12364
12852
|
if (!newElementList)
|
|
12365
12853
|
return;
|
|
12366
12854
|
const start = startIndex + 1;
|
|
12367
|
-
|
|
12368
|
-
|
|
12369
|
-
} else {
|
|
12370
|
-
elementList.splice(start, endIndex - startIndex, ...newElementList);
|
|
12371
|
-
}
|
|
12855
|
+
formatElementContext(elementList, newElementList, startIndex);
|
|
12856
|
+
this.draw.spliceElementList(elementList, start, startIndex === endIndex ? 0 : endIndex - startIndex, ...newElementList);
|
|
12372
12857
|
const curIndex = start + newElementList.length - 1;
|
|
12373
12858
|
this.range.setRange(curIndex, curIndex);
|
|
12374
12859
|
this.draw.render({ curIndex });
|
|
@@ -12414,7 +12899,7 @@ class CommandAdapt {
|
|
|
12414
12899
|
return;
|
|
12415
12900
|
const elementList = this.draw.getElementList();
|
|
12416
12901
|
const [leftIndex, rightIndex] = hyperRange;
|
|
12417
|
-
|
|
12902
|
+
this.draw.spliceElementList(elementList, leftIndex, rightIndex - leftIndex + 1);
|
|
12418
12903
|
this.draw.getHyperlinkParticle().clearHyperlinkPopup();
|
|
12419
12904
|
const newIndex = leftIndex - 1;
|
|
12420
12905
|
this.range.setRange(newIndex, newIndex);
|
|
@@ -12483,11 +12968,12 @@ class CommandAdapt {
|
|
|
12483
12968
|
type: ElementType.SEPARATOR,
|
|
12484
12969
|
dashArray: payload
|
|
12485
12970
|
};
|
|
12971
|
+
formatElementContext(elementList, [newElement], startIndex);
|
|
12486
12972
|
if (startIndex !== 0 && elementList[startIndex].value === ZERO) {
|
|
12487
|
-
|
|
12973
|
+
this.draw.spliceElementList(elementList, startIndex, 1, newElement);
|
|
12488
12974
|
curIndex = startIndex - 1;
|
|
12489
12975
|
} else {
|
|
12490
|
-
|
|
12976
|
+
this.draw.spliceElementList(elementList, startIndex + 1, 0, newElement);
|
|
12491
12977
|
curIndex = startIndex;
|
|
12492
12978
|
}
|
|
12493
12979
|
}
|
|
@@ -12557,11 +13043,8 @@ class CommandAdapt {
|
|
|
12557
13043
|
type: ElementType.IMAGE
|
|
12558
13044
|
};
|
|
12559
13045
|
const curIndex = startIndex + 1;
|
|
12560
|
-
|
|
12561
|
-
|
|
12562
|
-
} else {
|
|
12563
|
-
elementList.splice(curIndex, endIndex - startIndex, element);
|
|
12564
|
-
}
|
|
13046
|
+
formatElementContext(elementList, [element], startIndex);
|
|
13047
|
+
this.draw.spliceElementList(elementList, curIndex, startIndex === endIndex ? 0 : endIndex - startIndex, element);
|
|
12565
13048
|
this.range.setRange(curIndex, curIndex);
|
|
12566
13049
|
this.draw.render({ curIndex });
|
|
12567
13050
|
}
|
|
@@ -12625,7 +13108,7 @@ class CommandAdapt {
|
|
|
12625
13108
|
const curIndex = index2 + tableDiffCount;
|
|
12626
13109
|
const tableElement = tableElementList[curIndex];
|
|
12627
13110
|
if (curGroupId === match.groupId) {
|
|
12628
|
-
|
|
13111
|
+
this.draw.spliceElementList(tableElementList, curIndex, 1);
|
|
12629
13112
|
tableDiffCount--;
|
|
12630
13113
|
continue;
|
|
12631
13114
|
}
|
|
@@ -12634,7 +13117,7 @@ class CommandAdapt {
|
|
|
12634
13117
|
if (p === 0) {
|
|
12635
13118
|
tableElement.value = value;
|
|
12636
13119
|
} else {
|
|
12637
|
-
|
|
13120
|
+
this.draw.spliceElementList(tableElementList, curIndex + p, 0, __spreadProps(__spreadValues({}, tableElement), {
|
|
12638
13121
|
value
|
|
12639
13122
|
}));
|
|
12640
13123
|
tableDiffCount++;
|
|
@@ -12650,7 +13133,7 @@ class CommandAdapt {
|
|
|
12650
13133
|
firstMatchIndex = m;
|
|
12651
13134
|
}
|
|
12652
13135
|
if (curGroupId === match.groupId) {
|
|
12653
|
-
|
|
13136
|
+
this.draw.spliceElementList(elementList, curIndex, 1);
|
|
12654
13137
|
pageDiffCount--;
|
|
12655
13138
|
continue;
|
|
12656
13139
|
}
|
|
@@ -12659,7 +13142,7 @@ class CommandAdapt {
|
|
|
12659
13142
|
if (p === 0) {
|
|
12660
13143
|
element.value = value;
|
|
12661
13144
|
} else {
|
|
12662
|
-
|
|
13145
|
+
this.draw.spliceElementList(elementList, curIndex + p, 0, __spreadProps(__spreadValues({}, element), {
|
|
12663
13146
|
value
|
|
12664
13147
|
}));
|
|
12665
13148
|
pageDiffCount++;
|
|
@@ -12789,6 +13272,9 @@ class CommandAdapt {
|
|
|
12789
13272
|
const isReadonly = this.draw.isReadonly();
|
|
12790
13273
|
if (isReadonly)
|
|
12791
13274
|
return;
|
|
13275
|
+
const { startIndex } = this.range.getRange();
|
|
13276
|
+
const elementList = this.draw.getElementList();
|
|
13277
|
+
formatElementContext(elementList, payload, startIndex);
|
|
12792
13278
|
this.draw.insertElementList(payload);
|
|
12793
13279
|
}
|
|
12794
13280
|
removeControl() {
|
|
@@ -13398,7 +13884,8 @@ class ContextMenu {
|
|
|
13398
13884
|
}
|
|
13399
13885
|
const defaultHeaderOption = {
|
|
13400
13886
|
top: 30,
|
|
13401
|
-
maxHeightRadio: MaxHeightRatio.HALF
|
|
13887
|
+
maxHeightRadio: MaxHeightRatio.HALF,
|
|
13888
|
+
disabled: false
|
|
13402
13889
|
};
|
|
13403
13890
|
const richtextKeys = [
|
|
13404
13891
|
{
|
|
@@ -13489,6 +13976,82 @@ const richtextKeys = [
|
|
|
13489
13976
|
}
|
|
13490
13977
|
}
|
|
13491
13978
|
];
|
|
13979
|
+
const titleKeys = [
|
|
13980
|
+
{
|
|
13981
|
+
key: KeyMap.ZERO,
|
|
13982
|
+
alt: true,
|
|
13983
|
+
ctrl: true,
|
|
13984
|
+
callback: (command) => {
|
|
13985
|
+
command.executeTitle(null);
|
|
13986
|
+
}
|
|
13987
|
+
},
|
|
13988
|
+
{
|
|
13989
|
+
key: KeyMap.ONE,
|
|
13990
|
+
alt: true,
|
|
13991
|
+
ctrl: true,
|
|
13992
|
+
callback: (command) => {
|
|
13993
|
+
command.executeTitle(TitleLevel.FIRST);
|
|
13994
|
+
}
|
|
13995
|
+
},
|
|
13996
|
+
{
|
|
13997
|
+
key: KeyMap.TWO,
|
|
13998
|
+
alt: true,
|
|
13999
|
+
ctrl: true,
|
|
14000
|
+
callback: (command) => {
|
|
14001
|
+
command.executeTitle(TitleLevel.SECOND);
|
|
14002
|
+
}
|
|
14003
|
+
},
|
|
14004
|
+
{
|
|
14005
|
+
key: KeyMap.THREE,
|
|
14006
|
+
alt: true,
|
|
14007
|
+
ctrl: true,
|
|
14008
|
+
callback: (command) => {
|
|
14009
|
+
command.executeTitle(TitleLevel.THIRD);
|
|
14010
|
+
}
|
|
14011
|
+
},
|
|
14012
|
+
{
|
|
14013
|
+
key: KeyMap.FOUR,
|
|
14014
|
+
alt: true,
|
|
14015
|
+
ctrl: true,
|
|
14016
|
+
callback: (command) => {
|
|
14017
|
+
command.executeTitle(TitleLevel.FOURTH);
|
|
14018
|
+
}
|
|
14019
|
+
},
|
|
14020
|
+
{
|
|
14021
|
+
key: KeyMap.FIVE,
|
|
14022
|
+
alt: true,
|
|
14023
|
+
ctrl: true,
|
|
14024
|
+
callback: (command) => {
|
|
14025
|
+
command.executeTitle(TitleLevel.FIFTH);
|
|
14026
|
+
}
|
|
14027
|
+
},
|
|
14028
|
+
{
|
|
14029
|
+
key: KeyMap.SIX,
|
|
14030
|
+
alt: true,
|
|
14031
|
+
ctrl: true,
|
|
14032
|
+
callback: (command) => {
|
|
14033
|
+
command.executeTitle(TitleLevel.SIXTH);
|
|
14034
|
+
}
|
|
14035
|
+
}
|
|
14036
|
+
];
|
|
14037
|
+
const listKeys = [
|
|
14038
|
+
{
|
|
14039
|
+
key: KeyMap.I,
|
|
14040
|
+
shift: true,
|
|
14041
|
+
mod: true,
|
|
14042
|
+
callback: (command) => {
|
|
14043
|
+
command.executeList(ListType.UL, ListStyle.DISC);
|
|
14044
|
+
}
|
|
14045
|
+
},
|
|
14046
|
+
{
|
|
14047
|
+
key: KeyMap.U,
|
|
14048
|
+
shift: true,
|
|
14049
|
+
mod: true,
|
|
14050
|
+
callback: (command) => {
|
|
14051
|
+
command.executeList(ListType.OL);
|
|
14052
|
+
}
|
|
14053
|
+
}
|
|
14054
|
+
];
|
|
13492
14055
|
class Shortcut {
|
|
13493
14056
|
constructor(draw, command) {
|
|
13494
14057
|
__publicField(this, "command");
|
|
@@ -13503,7 +14066,9 @@ class Shortcut {
|
|
|
13503
14066
|
this.globalShortcutList = [];
|
|
13504
14067
|
this.agentShortcutList = [];
|
|
13505
14068
|
this._addShortcutList([
|
|
13506
|
-
...richtextKeys
|
|
14069
|
+
...richtextKeys,
|
|
14070
|
+
...titleKeys,
|
|
14071
|
+
...listKeys
|
|
13507
14072
|
]);
|
|
13508
14073
|
this._addEvent();
|
|
13509
14074
|
const agentDom = draw.getCursor().getAgentDom();
|
|
@@ -13546,7 +14111,8 @@ class Shortcut {
|
|
|
13546
14111
|
}
|
|
13547
14112
|
const defaultFooterOption = {
|
|
13548
14113
|
bottom: 30,
|
|
13549
|
-
maxHeightRadio: MaxHeightRatio.HALF
|
|
14114
|
+
maxHeightRadio: MaxHeightRatio.HALF,
|
|
14115
|
+
disabled: false
|
|
13550
14116
|
};
|
|
13551
14117
|
class Editor {
|
|
13552
14118
|
constructor(container, data2, options = {}) {
|
|
@@ -13642,5 +14208,5 @@ class Editor {
|
|
|
13642
14208
|
};
|
|
13643
14209
|
}
|
|
13644
14210
|
}
|
|
13645
|
-
export { BlockType, Command, ControlType, EDITOR_COMPONENT, Editor, EditorComponent, EditorMode, EditorZone, ElementType, ImageDisplay, KeyMap, MaxHeightRatio, NumberType, PageMode, PaperDirection, RowFlex, TableBorder, TitleLevel, VerticalAlign, Editor as default };
|
|
14211
|
+
export { BlockType, Command, ControlType, EDITOR_COMPONENT, Editor, EditorComponent, EditorMode, EditorZone, ElementType, ImageDisplay, KeyMap, ListStyle, ListType, MaxHeightRatio, NumberType, PageMode, PaperDirection, RowFlex, TableBorder, TitleLevel, VerticalAlign, Editor as default };
|
|
13646
14212
|
//# sourceMappingURL=canvas-editor.es.js.map
|