@hufe921/canvas-editor 0.9.77 → 0.9.79
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 +47 -0
- package/dist/canvas-editor.es.js +731 -285
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +36 -36
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/command/Command.d.ts +1 -0
- package/dist/src/editor/core/command/CommandAdapt.d.ts +2 -1
- package/dist/src/editor/core/draw/control/Control.d.ts +6 -2
- package/dist/src/editor/core/draw/control/checkbox/CheckboxControl.d.ts +1 -0
- package/dist/src/editor/core/draw/control/select/SelectControl.d.ts +2 -0
- package/dist/src/editor/core/draw/control/text/TextControl.d.ts +1 -0
- package/dist/src/editor/dataset/constant/Element.d.ts +1 -1
- package/dist/src/editor/interface/Control.d.ts +13 -0
- package/dist/src/editor/interface/Draw.d.ts +1 -0
- package/dist/src/editor/interface/Editor.d.ts +1 -0
- package/dist/src/editor/interface/Element.d.ts +1 -0
- package/dist/src/editor/interface/Range.d.ts +3 -0
- package/dist/src/editor/interface/contextmenu/ContextMenu.d.ts +3 -0
- package/dist/src/editor/utils/element.d.ts +9 -1
- package/dist/src/editor/utils/option.d.ts +3 -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.79";
|
|
27
27
|
var MaxHeightRatio;
|
|
28
28
|
(function(MaxHeightRatio2) {
|
|
29
29
|
MaxHeightRatio2["HALF"] = "half";
|
|
@@ -177,19 +177,27 @@ function getUUID() {
|
|
|
177
177
|
}
|
|
178
178
|
function splitText(text) {
|
|
179
179
|
const data2 = [];
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
180
|
+
if (Intl.Segmenter) {
|
|
181
|
+
const segmenter = new Intl.Segmenter();
|
|
182
|
+
const segments = segmenter.segment(text);
|
|
183
|
+
for (const { segment } of segments) {
|
|
184
|
+
data2.push(segment);
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
const symbolMap = new Map();
|
|
188
|
+
for (const match of text.matchAll(UNICODE_SYMBOL_REG)) {
|
|
189
|
+
symbolMap.set(match.index, match[0]);
|
|
190
|
+
}
|
|
191
|
+
let t = 0;
|
|
192
|
+
while (t < text.length) {
|
|
193
|
+
const symbol = symbolMap.get(t);
|
|
194
|
+
if (symbol) {
|
|
195
|
+
data2.push(symbol);
|
|
196
|
+
t += symbol.length;
|
|
197
|
+
} else {
|
|
198
|
+
data2.push(text[t]);
|
|
199
|
+
t++;
|
|
200
|
+
}
|
|
193
201
|
}
|
|
194
202
|
}
|
|
195
203
|
return data2;
|
|
@@ -421,7 +429,6 @@ const EDITOR_ELEMENT_COPY_ATTR = [
|
|
|
421
429
|
"dateId",
|
|
422
430
|
"dateFormat",
|
|
423
431
|
"groupIds",
|
|
424
|
-
"rowFlex",
|
|
425
432
|
"rowMargin",
|
|
426
433
|
"textDecoration"
|
|
427
434
|
];
|
|
@@ -460,7 +467,8 @@ const EDITOR_ELEMENT_ZIP_ATTR = [
|
|
|
460
467
|
"imgDisplay",
|
|
461
468
|
"imgFloatPosition",
|
|
462
469
|
"textDecoration",
|
|
463
|
-
"extension"
|
|
470
|
+
"extension",
|
|
471
|
+
"externalId"
|
|
464
472
|
];
|
|
465
473
|
const TABLE_TD_ZIP_ATTR = [
|
|
466
474
|
"verticalAlign",
|
|
@@ -499,7 +507,8 @@ const CONTROL_STYLE_ATTR = [
|
|
|
499
507
|
const EDITOR_ELEMENT_CONTEXT_ATTR = [
|
|
500
508
|
...TABLE_CONTEXT_ATTR,
|
|
501
509
|
...TITLE_CONTEXT_ATTR,
|
|
502
|
-
...LIST_CONTEXT_ATTR
|
|
510
|
+
...LIST_CONTEXT_ATTR,
|
|
511
|
+
...EDITOR_ROW_ATTR
|
|
503
512
|
];
|
|
504
513
|
const TEXTLIKE_ELEMENT_TYPE = [
|
|
505
514
|
ElementType.TEXT,
|
|
@@ -513,7 +522,7 @@ const IMAGE_ELEMENT_TYPE = [
|
|
|
513
522
|
ElementType.IMAGE,
|
|
514
523
|
ElementType.LATEX
|
|
515
524
|
];
|
|
516
|
-
const
|
|
525
|
+
const BLOCK_ELEMENT_TYPE = [
|
|
517
526
|
ElementType.BLOCK,
|
|
518
527
|
ElementType.PAGE_BREAK,
|
|
519
528
|
ElementType.SEPARATOR,
|
|
@@ -4235,11 +4244,11 @@ function zipElementList(payload) {
|
|
|
4235
4244
|
if (controlId) {
|
|
4236
4245
|
const controlDefaultStyle = pickObject(element, CONTROL_STYLE_ATTR);
|
|
4237
4246
|
const control = __spreadValues(__spreadValues({}, element.control), controlDefaultStyle);
|
|
4238
|
-
const controlElement = {
|
|
4247
|
+
const controlElement = __spreadProps(__spreadValues({}, pickObject(element, EDITOR_ROW_ATTR)), {
|
|
4239
4248
|
type: ElementType.CONTROL,
|
|
4240
4249
|
value: "",
|
|
4241
4250
|
control
|
|
4242
|
-
};
|
|
4251
|
+
});
|
|
4243
4252
|
const valueList = [];
|
|
4244
4253
|
while (e < elementList.length) {
|
|
4245
4254
|
const controlE = elementList[e];
|
|
@@ -4277,7 +4286,7 @@ function zipElementList(payload) {
|
|
|
4277
4286
|
}
|
|
4278
4287
|
return zipElementListData;
|
|
4279
4288
|
}
|
|
4280
|
-
function
|
|
4289
|
+
function convertTextAlignToRowFlex(node) {
|
|
4281
4290
|
const textAlign = window.getComputedStyle(node).textAlign;
|
|
4282
4291
|
switch (textAlign) {
|
|
4283
4292
|
case "left":
|
|
@@ -4296,6 +4305,24 @@ function getElementRowFlex(node) {
|
|
|
4296
4305
|
return RowFlex.LEFT;
|
|
4297
4306
|
}
|
|
4298
4307
|
}
|
|
4308
|
+
function convertRowFlexToTextAlign(rowFlex) {
|
|
4309
|
+
return rowFlex === RowFlex.ALIGNMENT ? "justify" : rowFlex;
|
|
4310
|
+
}
|
|
4311
|
+
function convertRowFlexToJustifyContent(rowFlex) {
|
|
4312
|
+
switch (rowFlex) {
|
|
4313
|
+
case RowFlex.LEFT:
|
|
4314
|
+
return "flex-start";
|
|
4315
|
+
case RowFlex.CENTER:
|
|
4316
|
+
return "center";
|
|
4317
|
+
case RowFlex.RIGHT:
|
|
4318
|
+
return "flex-end";
|
|
4319
|
+
case RowFlex.ALIGNMENT:
|
|
4320
|
+
case RowFlex.JUSTIFY:
|
|
4321
|
+
return "space-between";
|
|
4322
|
+
default:
|
|
4323
|
+
return "flex-start";
|
|
4324
|
+
}
|
|
4325
|
+
}
|
|
4299
4326
|
function isTextLikeElement(element) {
|
|
4300
4327
|
return !element.type || TEXTLIKE_ELEMENT_TYPE.includes(element.type);
|
|
4301
4328
|
}
|
|
@@ -4319,9 +4346,10 @@ function formatElementContext(sourceElementList, formatElementList2, anchorIndex
|
|
|
4319
4346
|
isBreakWarped = true;
|
|
4320
4347
|
}
|
|
4321
4348
|
if (isBreakWarped || !copyElement.listId && targetElement.type === ElementType.LIST) {
|
|
4322
|
-
|
|
4349
|
+
const cloneAttr = [...TABLE_CONTEXT_ATTR, ...EDITOR_ROW_ATTR];
|
|
4350
|
+
cloneProperty(cloneAttr, copyElement, targetElement);
|
|
4323
4351
|
(_a = targetElement.valueList) == null ? void 0 : _a.forEach((valueItem) => {
|
|
4324
|
-
cloneProperty(
|
|
4352
|
+
cloneProperty(cloneAttr, copyElement, valueItem);
|
|
4325
4353
|
});
|
|
4326
4354
|
continue;
|
|
4327
4355
|
}
|
|
@@ -4337,14 +4365,11 @@ function convertElementToDom(element, options) {
|
|
|
4337
4365
|
tagName = "sup";
|
|
4338
4366
|
} else if (element.type === ElementType.SUBSCRIPT) {
|
|
4339
4367
|
tagName = "sub";
|
|
4340
|
-
} else if (element.rowFlex === RowFlex.CENTER || element.rowFlex === RowFlex.RIGHT) {
|
|
4341
|
-
tagName = "p";
|
|
4342
4368
|
}
|
|
4343
4369
|
const dom = document.createElement(tagName);
|
|
4344
4370
|
dom.style.fontFamily = element.font || options.defaultFont;
|
|
4345
4371
|
if (element.rowFlex) {
|
|
4346
|
-
|
|
4347
|
-
dom.style.textAlign = isAlignment ? "justify" : element.rowFlex;
|
|
4372
|
+
dom.style.textAlign = convertRowFlexToTextAlign(element.rowFlex);
|
|
4348
4373
|
}
|
|
4349
4374
|
if (element.color) {
|
|
4350
4375
|
dom.style.color = element.color;
|
|
@@ -4399,10 +4424,40 @@ function splitListElement(elementList) {
|
|
|
4399
4424
|
}
|
|
4400
4425
|
return listElementListMap;
|
|
4401
4426
|
}
|
|
4427
|
+
function groupElementListByRowFlex(elementList) {
|
|
4428
|
+
var _a;
|
|
4429
|
+
const elementListGroupList = [];
|
|
4430
|
+
if (!elementList.length)
|
|
4431
|
+
return elementListGroupList;
|
|
4432
|
+
let currentRowFlex = ((_a = elementList[0]) == null ? void 0 : _a.rowFlex) || null;
|
|
4433
|
+
elementListGroupList.push({
|
|
4434
|
+
rowFlex: currentRowFlex,
|
|
4435
|
+
data: [elementList[0]]
|
|
4436
|
+
});
|
|
4437
|
+
for (let e = 1; e < elementList.length; e++) {
|
|
4438
|
+
const element = elementList[e];
|
|
4439
|
+
const rowFlex = element.rowFlex || null;
|
|
4440
|
+
if (currentRowFlex === rowFlex && !getIsBlockElement(element) && !getIsBlockElement(elementList[e - 1])) {
|
|
4441
|
+
const lastElementListGroup = elementListGroupList[elementListGroupList.length - 1];
|
|
4442
|
+
lastElementListGroup.data.push(element);
|
|
4443
|
+
} else {
|
|
4444
|
+
elementListGroupList.push({
|
|
4445
|
+
rowFlex,
|
|
4446
|
+
data: [element]
|
|
4447
|
+
});
|
|
4448
|
+
currentRowFlex = rowFlex;
|
|
4449
|
+
}
|
|
4450
|
+
}
|
|
4451
|
+
for (let g = 0; g < elementListGroupList.length; g++) {
|
|
4452
|
+
const elementListGroup = elementListGroupList[g];
|
|
4453
|
+
elementListGroup.data = zipElementList(elementListGroup.data);
|
|
4454
|
+
}
|
|
4455
|
+
return elementListGroupList;
|
|
4456
|
+
}
|
|
4402
4457
|
function createDomFromElementList(elementList, options) {
|
|
4403
4458
|
function buildDom(payload) {
|
|
4404
4459
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
4405
|
-
const
|
|
4460
|
+
const clipboardDom2 = document.createElement("div");
|
|
4406
4461
|
for (let e = 0; e < payload.length; e++) {
|
|
4407
4462
|
const element = payload[e];
|
|
4408
4463
|
if (element.type === ElementType.TABLE) {
|
|
@@ -4452,7 +4507,7 @@ function createDomFromElementList(elementList, options) {
|
|
|
4452
4507
|
if ((_d = td.borderTypes) == null ? void 0 : _d.includes(TdBorder.LEFT)) {
|
|
4453
4508
|
tdDom.style.borderLeft = borderStyle;
|
|
4454
4509
|
}
|
|
4455
|
-
const childDom =
|
|
4510
|
+
const childDom = createDomFromElementList(td.value, options);
|
|
4456
4511
|
tdDom.innerHTML = childDom.innerHTML;
|
|
4457
4512
|
if (td.backgroundColor) {
|
|
4458
4513
|
tdDom.style.backgroundColor = td.backgroundColor;
|
|
@@ -4461,19 +4516,19 @@ function createDomFromElementList(elementList, options) {
|
|
|
4461
4516
|
}
|
|
4462
4517
|
tableDom.append(trDom);
|
|
4463
4518
|
}
|
|
4464
|
-
|
|
4519
|
+
clipboardDom2.append(tableDom);
|
|
4465
4520
|
} else if (element.type === ElementType.HYPERLINK) {
|
|
4466
4521
|
const a = document.createElement("a");
|
|
4467
4522
|
a.innerText = element.valueList.map((v) => v.value).join("");
|
|
4468
4523
|
if (element.url) {
|
|
4469
4524
|
a.href = element.url;
|
|
4470
4525
|
}
|
|
4471
|
-
|
|
4526
|
+
clipboardDom2.append(a);
|
|
4472
4527
|
} else if (element.type === ElementType.TITLE) {
|
|
4473
4528
|
const h = document.createElement(`h${titleOrderNumberMapping[element.level]}`);
|
|
4474
|
-
const childDom = buildDom(
|
|
4529
|
+
const childDom = buildDom(element.valueList);
|
|
4475
4530
|
h.innerHTML = childDom.innerHTML;
|
|
4476
|
-
|
|
4531
|
+
clipboardDom2.append(h);
|
|
4477
4532
|
} else if (element.type === ElementType.LIST) {
|
|
4478
4533
|
const list = document.createElement(listTypeElementMapping[element.listType]);
|
|
4479
4534
|
if (element.listStyle) {
|
|
@@ -4487,7 +4542,7 @@ function createDomFromElementList(elementList, options) {
|
|
|
4487
4542
|
li.innerHTML = childDom.innerHTML;
|
|
4488
4543
|
list.append(li);
|
|
4489
4544
|
});
|
|
4490
|
-
|
|
4545
|
+
clipboardDom2.append(list);
|
|
4491
4546
|
} else if (element.type === ElementType.IMAGE) {
|
|
4492
4547
|
const img = document.createElement("img");
|
|
4493
4548
|
if (element.value) {
|
|
@@ -4495,33 +4550,33 @@ function createDomFromElementList(elementList, options) {
|
|
|
4495
4550
|
img.width = element.width;
|
|
4496
4551
|
img.height = element.height;
|
|
4497
4552
|
}
|
|
4498
|
-
|
|
4553
|
+
clipboardDom2.append(img);
|
|
4499
4554
|
} else if (element.type === ElementType.SEPARATOR) {
|
|
4500
4555
|
const hr = document.createElement("hr");
|
|
4501
|
-
|
|
4556
|
+
clipboardDom2.append(hr);
|
|
4502
4557
|
} else if (element.type === ElementType.CHECKBOX) {
|
|
4503
4558
|
const checkbox = document.createElement("input");
|
|
4504
4559
|
checkbox.type = "checkbox";
|
|
4505
4560
|
if ((_e = element.checkbox) == null ? void 0 : _e.value) {
|
|
4506
4561
|
checkbox.setAttribute("checked", "true");
|
|
4507
4562
|
}
|
|
4508
|
-
|
|
4563
|
+
clipboardDom2.append(checkbox);
|
|
4509
4564
|
} else if (element.type === ElementType.RADIO) {
|
|
4510
4565
|
const radio = document.createElement("input");
|
|
4511
4566
|
radio.type = "radio";
|
|
4512
4567
|
if ((_f = element.radio) == null ? void 0 : _f.value) {
|
|
4513
4568
|
radio.setAttribute("checked", "true");
|
|
4514
4569
|
}
|
|
4515
|
-
|
|
4570
|
+
clipboardDom2.append(radio);
|
|
4516
4571
|
} else if (element.type === ElementType.TAB) {
|
|
4517
4572
|
const tab2 = document.createElement("span");
|
|
4518
4573
|
tab2.innerHTML = `${NON_BREAKING_SPACE}${NON_BREAKING_SPACE}`;
|
|
4519
|
-
|
|
4574
|
+
clipboardDom2.append(tab2);
|
|
4520
4575
|
} else if (element.type === ElementType.CONTROL) {
|
|
4521
4576
|
const controlElement = document.createElement("span");
|
|
4522
|
-
const childDom = buildDom(
|
|
4577
|
+
const childDom = buildDom(((_g = element.control) == null ? void 0 : _g.value) || []);
|
|
4523
4578
|
controlElement.innerHTML = childDom.innerHTML;
|
|
4524
|
-
|
|
4579
|
+
clipboardDom2.append(controlElement);
|
|
4525
4580
|
} else if (!element.type || element.type === ElementType.LATEX || TEXTLIKE_ELEMENT_TYPE.includes(element.type)) {
|
|
4526
4581
|
let text = "";
|
|
4527
4582
|
if (element.type === ElementType.DATE) {
|
|
@@ -4535,23 +4590,44 @@ function createDomFromElementList(elementList, options) {
|
|
|
4535
4590
|
if (((_i = payload[e - 1]) == null ? void 0 : _i.type) === ElementType.TITLE) {
|
|
4536
4591
|
text = text.replace(/^\n/, "");
|
|
4537
4592
|
}
|
|
4538
|
-
if (dom.tagName === "P") {
|
|
4539
|
-
text = text.replace(/\n$/, "");
|
|
4540
|
-
}
|
|
4541
4593
|
dom.innerText = text.replace(new RegExp(`${ZERO}`, "g"), "\n");
|
|
4542
|
-
|
|
4594
|
+
clipboardDom2.append(dom);
|
|
4543
4595
|
}
|
|
4544
4596
|
}
|
|
4545
|
-
return
|
|
4597
|
+
return clipboardDom2;
|
|
4546
4598
|
}
|
|
4547
|
-
|
|
4599
|
+
const clipboardDom = document.createElement("div");
|
|
4600
|
+
const groupElementList = groupElementListByRowFlex(elementList);
|
|
4601
|
+
for (let g = 0; g < groupElementList.length; g++) {
|
|
4602
|
+
const elementGroupRowFlex = groupElementList[g];
|
|
4603
|
+
const isDefaultRowFlex = !elementGroupRowFlex.rowFlex || elementGroupRowFlex.rowFlex === RowFlex.LEFT;
|
|
4604
|
+
const rowFlexDom = document.createElement("div");
|
|
4605
|
+
if (!isDefaultRowFlex) {
|
|
4606
|
+
const firstElement = elementGroupRowFlex.data[0];
|
|
4607
|
+
if (getIsBlockElement(firstElement)) {
|
|
4608
|
+
rowFlexDom.style.display = "flex";
|
|
4609
|
+
rowFlexDom.style.justifyContent = convertRowFlexToJustifyContent(firstElement.rowFlex);
|
|
4610
|
+
} else {
|
|
4611
|
+
rowFlexDom.style.textAlign = convertRowFlexToTextAlign(elementGroupRowFlex.rowFlex);
|
|
4612
|
+
}
|
|
4613
|
+
}
|
|
4614
|
+
rowFlexDom.innerHTML = buildDom(elementGroupRowFlex.data).innerHTML;
|
|
4615
|
+
if (!isDefaultRowFlex) {
|
|
4616
|
+
clipboardDom.append(rowFlexDom);
|
|
4617
|
+
} else {
|
|
4618
|
+
rowFlexDom.childNodes.forEach((child) => {
|
|
4619
|
+
clipboardDom.append(child.cloneNode(true));
|
|
4620
|
+
});
|
|
4621
|
+
}
|
|
4622
|
+
}
|
|
4623
|
+
return clipboardDom;
|
|
4548
4624
|
}
|
|
4549
4625
|
function convertTextNodeToElement(textNode) {
|
|
4550
4626
|
if (!textNode || textNode.nodeType !== 3)
|
|
4551
4627
|
return null;
|
|
4552
4628
|
const parentNode = textNode.parentNode;
|
|
4553
4629
|
const anchorNode = parentNode.nodeName === "FONT" ? parentNode.parentNode : parentNode;
|
|
4554
|
-
const rowFlex =
|
|
4630
|
+
const rowFlex = convertTextAlignToRowFlex(anchorNode);
|
|
4555
4631
|
const value = textNode.textContent;
|
|
4556
4632
|
const style = window.getComputedStyle(anchorNode);
|
|
4557
4633
|
if (!value || anchorNode.nodeName === "STYLE")
|
|
@@ -4820,6 +4896,9 @@ function getSlimCloneElementList(elementList) {
|
|
|
4820
4896
|
"style"
|
|
4821
4897
|
]);
|
|
4822
4898
|
}
|
|
4899
|
+
function getIsBlockElement(element) {
|
|
4900
|
+
return !!(element == null ? void 0 : element.type) && (BLOCK_ELEMENT_TYPE.includes(element.type) || element.imgDisplay === ImageDisplay.INLINE);
|
|
4901
|
+
}
|
|
4823
4902
|
function setClipboardData(data2) {
|
|
4824
4903
|
localStorage.setItem(EDITOR_CLIPBOARD, JSON.stringify({
|
|
4825
4904
|
text: data2.text,
|
|
@@ -5201,8 +5280,10 @@ class Cursor {
|
|
|
5201
5280
|
const cursorLeft = hitLineStartIndex ? leftTop[0] : rightTop[0];
|
|
5202
5281
|
agentCursorDom.style.left = `${cursorLeft}px`;
|
|
5203
5282
|
agentCursorDom.style.top = `${cursorTop + cursorHeight - defaultOffsetHeight}px`;
|
|
5204
|
-
if (!isShow)
|
|
5283
|
+
if (!isShow) {
|
|
5284
|
+
this.recoveryCursor();
|
|
5205
5285
|
return;
|
|
5286
|
+
}
|
|
5206
5287
|
const isReadonly = this.draw.isReadonly();
|
|
5207
5288
|
this.cursorDom.style.width = `${width * scale}px`;
|
|
5208
5289
|
this.cursorDom.style.backgroundColor = color;
|
|
@@ -5357,6 +5438,9 @@ class CheckboxControl {
|
|
|
5357
5438
|
this.element = element;
|
|
5358
5439
|
this.control = control;
|
|
5359
5440
|
}
|
|
5441
|
+
setElement(element) {
|
|
5442
|
+
this.element = element;
|
|
5443
|
+
}
|
|
5360
5444
|
getElement() {
|
|
5361
5445
|
return this.element;
|
|
5362
5446
|
}
|
|
@@ -6077,7 +6161,7 @@ function enter(evt, host) {
|
|
|
6077
6161
|
evt.preventDefault();
|
|
6078
6162
|
}
|
|
6079
6163
|
function left(evt, host) {
|
|
6080
|
-
var _a;
|
|
6164
|
+
var _a, _b;
|
|
6081
6165
|
const draw = host.getDraw();
|
|
6082
6166
|
const isReadonly = draw.isReadonly();
|
|
6083
6167
|
if (isReadonly)
|
|
@@ -6094,11 +6178,18 @@ function left(evt, host) {
|
|
|
6094
6178
|
const { startIndex, endIndex } = rangeManager.getRange();
|
|
6095
6179
|
const isCollapsed = rangeManager.getIsCollapsed();
|
|
6096
6180
|
const elementList = draw.getElementList();
|
|
6181
|
+
const control = draw.getControl();
|
|
6182
|
+
if (draw.getMode() === EditorMode.FORM && control.getActiveControl() && ((_a = elementList[index2]) == null ? void 0 : _a.controlComponent) === ControlComponent.PREFIX) {
|
|
6183
|
+
control.initNextControl({
|
|
6184
|
+
direction: MoveDirection.UP
|
|
6185
|
+
});
|
|
6186
|
+
return;
|
|
6187
|
+
}
|
|
6097
6188
|
let moveCount = 1;
|
|
6098
6189
|
if (isMod(evt)) {
|
|
6099
6190
|
const LETTER_REG = draw.getLetterReg();
|
|
6100
6191
|
const moveStartIndex = evt.shiftKey && !isCollapsed && startIndex === (cursorPosition == null ? void 0 : cursorPosition.index) ? endIndex : startIndex;
|
|
6101
|
-
if (LETTER_REG.test((
|
|
6192
|
+
if (LETTER_REG.test((_b = elementList[moveStartIndex]) == null ? void 0 : _b.value)) {
|
|
6102
6193
|
let i = moveStartIndex - 1;
|
|
6103
6194
|
while (i > 0) {
|
|
6104
6195
|
const element = elementList[i];
|
|
@@ -6208,7 +6299,7 @@ function left(evt, host) {
|
|
|
6208
6299
|
evt.preventDefault();
|
|
6209
6300
|
}
|
|
6210
6301
|
function right(evt, host) {
|
|
6211
|
-
var _a;
|
|
6302
|
+
var _a, _b;
|
|
6212
6303
|
const draw = host.getDraw();
|
|
6213
6304
|
const isReadonly = draw.isReadonly();
|
|
6214
6305
|
if (isReadonly)
|
|
@@ -6226,11 +6317,18 @@ function right(evt, host) {
|
|
|
6226
6317
|
const { startIndex, endIndex } = rangeManager.getRange();
|
|
6227
6318
|
const isCollapsed = rangeManager.getIsCollapsed();
|
|
6228
6319
|
let elementList = draw.getElementList();
|
|
6320
|
+
const control = draw.getControl();
|
|
6321
|
+
if (draw.getMode() === EditorMode.FORM && control.getActiveControl() && ((_a = elementList[index2 + 1]) == null ? void 0 : _a.controlComponent) === ControlComponent.POSTFIX) {
|
|
6322
|
+
control.initNextControl({
|
|
6323
|
+
direction: MoveDirection.DOWN
|
|
6324
|
+
});
|
|
6325
|
+
return;
|
|
6326
|
+
}
|
|
6229
6327
|
let moveCount = 1;
|
|
6230
6328
|
if (isMod(evt)) {
|
|
6231
6329
|
const LETTER_REG = draw.getLetterReg();
|
|
6232
6330
|
const moveStartIndex = evt.shiftKey && !isCollapsed && startIndex === (cursorPosition == null ? void 0 : cursorPosition.index) ? endIndex : startIndex;
|
|
6233
|
-
if (LETTER_REG.test((
|
|
6331
|
+
if (LETTER_REG.test((_b = elementList[moveStartIndex + 1]) == null ? void 0 : _b.value)) {
|
|
6234
6332
|
let i = moveStartIndex + 2;
|
|
6235
6333
|
while (i < elementList.length) {
|
|
6236
6334
|
const element = elementList[i];
|
|
@@ -6346,16 +6444,24 @@ function tab(evt, host) {
|
|
|
6346
6444
|
const isReadonly = draw.isReadonly();
|
|
6347
6445
|
if (isReadonly)
|
|
6348
6446
|
return;
|
|
6349
|
-
const tabElement = {
|
|
6350
|
-
type: ElementType.TAB,
|
|
6351
|
-
value: ""
|
|
6352
|
-
};
|
|
6353
|
-
const rangeManager = draw.getRange();
|
|
6354
|
-
const { startIndex } = rangeManager.getRange();
|
|
6355
|
-
const elementList = draw.getElementList();
|
|
6356
|
-
formatElementContext(elementList, [tabElement], startIndex);
|
|
6357
|
-
draw.insertElementList([tabElement]);
|
|
6358
6447
|
evt.preventDefault();
|
|
6448
|
+
const control = draw.getControl();
|
|
6449
|
+
const activeControl = control.getActiveControl();
|
|
6450
|
+
if (activeControl) {
|
|
6451
|
+
control.initNextControl({
|
|
6452
|
+
direction: evt.shiftKey ? MoveDirection.UP : MoveDirection.DOWN
|
|
6453
|
+
});
|
|
6454
|
+
} else {
|
|
6455
|
+
const tabElement = {
|
|
6456
|
+
type: ElementType.TAB,
|
|
6457
|
+
value: ""
|
|
6458
|
+
};
|
|
6459
|
+
const rangeManager = draw.getRange();
|
|
6460
|
+
const { startIndex } = rangeManager.getRange();
|
|
6461
|
+
const elementList = draw.getElementList();
|
|
6462
|
+
formatElementContext(elementList, [tabElement], startIndex);
|
|
6463
|
+
draw.insertElementList([tabElement]);
|
|
6464
|
+
}
|
|
6359
6465
|
}
|
|
6360
6466
|
function getNextPositionIndex(payload) {
|
|
6361
6467
|
const { positionList, index: index2, isUp, rowNo, cursorX } = payload;
|
|
@@ -7293,11 +7399,15 @@ class GlobalEvent {
|
|
|
7293
7399
|
}
|
|
7294
7400
|
});
|
|
7295
7401
|
__publicField(this, "_handleVisibilityChange", () => {
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
const
|
|
7299
|
-
|
|
7300
|
-
|
|
7402
|
+
if (document.visibilityState === "visible") {
|
|
7403
|
+
const range = this.range.getRange();
|
|
7404
|
+
const isSetCursor = !!~range.startIndex && !!~range.endIndex && range.startIndex === range.endIndex;
|
|
7405
|
+
this.range.replaceRange(range);
|
|
7406
|
+
this.draw.render({
|
|
7407
|
+
isSetCursor,
|
|
7408
|
+
isCompute: false,
|
|
7409
|
+
isSubmitHistory: false,
|
|
7410
|
+
curIndex: range.startIndex
|
|
7301
7411
|
});
|
|
7302
7412
|
}
|
|
7303
7413
|
});
|
|
@@ -9819,23 +9929,25 @@ class TableTool {
|
|
|
9819
9929
|
dx = nextColWidth - this.MIN_TD_WIDTH;
|
|
9820
9930
|
}
|
|
9821
9931
|
const moveColWidth = curColWidth + dx;
|
|
9822
|
-
|
|
9823
|
-
|
|
9824
|
-
|
|
9825
|
-
|
|
9826
|
-
|
|
9827
|
-
|
|
9828
|
-
|
|
9829
|
-
|
|
9932
|
+
if (index2 === colgroup.length - 1) {
|
|
9933
|
+
let moveTableWidth = 0;
|
|
9934
|
+
for (let c = 0; c < colgroup.length; c++) {
|
|
9935
|
+
const group2 = colgroup[c];
|
|
9936
|
+
if (c === index2 + 1) {
|
|
9937
|
+
moveTableWidth -= dx;
|
|
9938
|
+
}
|
|
9939
|
+
if (c === index2) {
|
|
9940
|
+
moveTableWidth += moveColWidth;
|
|
9941
|
+
}
|
|
9942
|
+
if (c !== index2) {
|
|
9943
|
+
moveTableWidth += group2.width;
|
|
9944
|
+
}
|
|
9830
9945
|
}
|
|
9831
|
-
if (
|
|
9832
|
-
|
|
9946
|
+
if (moveTableWidth > innerWidth) {
|
|
9947
|
+
const tableWidth = element.width;
|
|
9948
|
+
dx = innerWidth - tableWidth;
|
|
9833
9949
|
}
|
|
9834
9950
|
}
|
|
9835
|
-
if (moveTableWidth > innerWidth) {
|
|
9836
|
-
const tableWidth = element.width;
|
|
9837
|
-
dx = innerWidth - tableWidth;
|
|
9838
|
-
}
|
|
9839
9951
|
if (dx) {
|
|
9840
9952
|
if (colgroup.length - 1 !== index2) {
|
|
9841
9953
|
colgroup[index2 + 1].width -= dx / scale;
|
|
@@ -10310,9 +10422,15 @@ class SelectControl {
|
|
|
10310
10422
|
this.isPopup = false;
|
|
10311
10423
|
this.selectDom = null;
|
|
10312
10424
|
}
|
|
10425
|
+
setElement(element) {
|
|
10426
|
+
this.element = element;
|
|
10427
|
+
}
|
|
10313
10428
|
getElement() {
|
|
10314
10429
|
return this.element;
|
|
10315
10430
|
}
|
|
10431
|
+
getIsPopup() {
|
|
10432
|
+
return this.isPopup;
|
|
10433
|
+
}
|
|
10316
10434
|
getCode() {
|
|
10317
10435
|
var _a;
|
|
10318
10436
|
return ((_a = this.element.control) == null ? void 0 : _a.code) || null;
|
|
@@ -10395,7 +10513,8 @@ class SelectControl {
|
|
|
10395
10513
|
return this.clearSelect();
|
|
10396
10514
|
}
|
|
10397
10515
|
clearSelect(context = {}, options = {}) {
|
|
10398
|
-
|
|
10516
|
+
const { isIgnoreDisabledRule = false, isAddPlaceholder = true } = options;
|
|
10517
|
+
if (!isIgnoreDisabledRule && this.control.getIsDisabledControl()) {
|
|
10399
10518
|
return -1;
|
|
10400
10519
|
}
|
|
10401
10520
|
const elementList = context.elementList || this.control.getElementList();
|
|
@@ -10425,7 +10544,9 @@ class SelectControl {
|
|
|
10425
10544
|
return -1;
|
|
10426
10545
|
const draw = this.control.getDraw();
|
|
10427
10546
|
draw.spliceElementList(elementList, leftIndex + 1, rightIndex - leftIndex);
|
|
10428
|
-
|
|
10547
|
+
if (isAddPlaceholder) {
|
|
10548
|
+
this.control.addPlaceholder(preIndex, context);
|
|
10549
|
+
}
|
|
10429
10550
|
this.element.control.code = null;
|
|
10430
10551
|
return preIndex;
|
|
10431
10552
|
}
|
|
@@ -10433,21 +10554,35 @@ class SelectControl {
|
|
|
10433
10554
|
if (!options.isIgnoreDisabledRule && this.control.getIsDisabledControl()) {
|
|
10434
10555
|
return;
|
|
10435
10556
|
}
|
|
10557
|
+
const elementList = context.elementList || this.control.getElementList();
|
|
10558
|
+
const range = context.range || this.control.getRange();
|
|
10436
10559
|
const control = this.element.control;
|
|
10560
|
+
const oldCode = control.code;
|
|
10561
|
+
if (code === oldCode) {
|
|
10562
|
+
this.control.repaintControl({
|
|
10563
|
+
curIndex: range.startIndex,
|
|
10564
|
+
isCompute: false,
|
|
10565
|
+
isSubmitHistory: false
|
|
10566
|
+
});
|
|
10567
|
+
this.destroy();
|
|
10568
|
+
return;
|
|
10569
|
+
}
|
|
10437
10570
|
const valueSets = control.valueSets;
|
|
10438
10571
|
if (!Array.isArray(valueSets) || !valueSets.length)
|
|
10439
10572
|
return;
|
|
10440
10573
|
const valueSet = valueSets.find((v) => v.code === code);
|
|
10441
10574
|
if (!valueSet)
|
|
10442
10575
|
return;
|
|
10443
|
-
const elementList = context.elementList || this.control.getElementList();
|
|
10444
|
-
const range = context.range || this.control.getRange();
|
|
10445
10576
|
const valueElement = this.getValue(context)[0];
|
|
10446
10577
|
const styleElement = valueElement ? pickObject(valueElement, EDITOR_ELEMENT_STYLE_ATTR) : pickObject(elementList[range.startIndex], CONTROL_STYLE_ATTR);
|
|
10447
|
-
const prefixIndex = this.clearSelect(context
|
|
10578
|
+
const prefixIndex = this.clearSelect(context, {
|
|
10579
|
+
isAddPlaceholder: false
|
|
10580
|
+
});
|
|
10448
10581
|
if (!~prefixIndex)
|
|
10449
10582
|
return;
|
|
10450
|
-
|
|
10583
|
+
if (!oldCode) {
|
|
10584
|
+
this.control.removePlaceholder(prefixIndex, context);
|
|
10585
|
+
}
|
|
10451
10586
|
const propertyElement = omitObject(elementList[prefixIndex], EDITOR_ELEMENT_STYLE_ATTR);
|
|
10452
10587
|
const start = prefixIndex + 1;
|
|
10453
10588
|
const data2 = splitText(valueSet.value);
|
|
@@ -10461,10 +10596,12 @@ class SelectControl {
|
|
|
10461
10596
|
formatElementContext(elementList, [newElement], prefixIndex);
|
|
10462
10597
|
draw.spliceElementList(elementList, start + i, 0, newElement);
|
|
10463
10598
|
}
|
|
10464
|
-
|
|
10599
|
+
control.code = code;
|
|
10465
10600
|
if (!context.range) {
|
|
10466
10601
|
const newIndex = start + data2.length - 1;
|
|
10467
|
-
this.control.repaintControl(
|
|
10602
|
+
this.control.repaintControl({
|
|
10603
|
+
curIndex: newIndex
|
|
10604
|
+
});
|
|
10468
10605
|
this.destroy();
|
|
10469
10606
|
}
|
|
10470
10607
|
}
|
|
@@ -10529,6 +10666,9 @@ class TextControl {
|
|
|
10529
10666
|
this.element = element;
|
|
10530
10667
|
this.control = control;
|
|
10531
10668
|
}
|
|
10669
|
+
setElement(element) {
|
|
10670
|
+
this.element = element;
|
|
10671
|
+
}
|
|
10532
10672
|
getElement() {
|
|
10533
10673
|
return this.element;
|
|
10534
10674
|
}
|
|
@@ -10797,9 +10937,11 @@ class Control {
|
|
|
10797
10937
|
return positionList[endIndex] || null;
|
|
10798
10938
|
}
|
|
10799
10939
|
getPreY() {
|
|
10940
|
+
var _a, _b;
|
|
10800
10941
|
const height = this.draw.getHeight();
|
|
10801
10942
|
const pageGap = this.draw.getPageGap();
|
|
10802
|
-
|
|
10943
|
+
const pageNo = (_b = (_a = this.getPosition()) == null ? void 0 : _a.pageNo) != null ? _b : this.draw.getPageNo();
|
|
10944
|
+
return pageNo * (height + pageGap);
|
|
10803
10945
|
}
|
|
10804
10946
|
getRange() {
|
|
10805
10947
|
return this.range.getRange();
|
|
@@ -10879,19 +11021,36 @@ class Control {
|
|
|
10879
11021
|
});
|
|
10880
11022
|
}
|
|
10881
11023
|
}
|
|
10882
|
-
repaintControl(
|
|
11024
|
+
repaintControl(options = {}) {
|
|
11025
|
+
const { curIndex, isCompute = true, isSubmitHistory = true } = options;
|
|
10883
11026
|
if (curIndex === void 0) {
|
|
10884
11027
|
this.range.clearRange();
|
|
10885
11028
|
this.draw.render({
|
|
11029
|
+
isCompute,
|
|
11030
|
+
isSubmitHistory,
|
|
10886
11031
|
isSetCursor: false
|
|
10887
11032
|
});
|
|
10888
11033
|
} else {
|
|
10889
11034
|
this.range.setRange(curIndex, curIndex);
|
|
10890
11035
|
this.draw.render({
|
|
10891
|
-
curIndex
|
|
11036
|
+
curIndex,
|
|
11037
|
+
isCompute,
|
|
11038
|
+
isSubmitHistory
|
|
10892
11039
|
});
|
|
10893
11040
|
}
|
|
10894
11041
|
}
|
|
11042
|
+
reAwakeControl() {
|
|
11043
|
+
if (!this.activeControl)
|
|
11044
|
+
return;
|
|
11045
|
+
const elementList = this.getElementList();
|
|
11046
|
+
const range = this.getRange();
|
|
11047
|
+
const element = elementList[range.startIndex];
|
|
11048
|
+
this.activeControl.setElement(element);
|
|
11049
|
+
if (this.activeControl instanceof SelectControl && this.activeControl.getIsPopup()) {
|
|
11050
|
+
this.activeControl.destroy();
|
|
11051
|
+
this.activeControl.awake();
|
|
11052
|
+
}
|
|
11053
|
+
}
|
|
10895
11054
|
moveCursor(position) {
|
|
10896
11055
|
const { index: index2, trIndex, tdIndex, tdValueIndex } = position;
|
|
10897
11056
|
let elementList = this.draw.getOriginalElementList();
|
|
@@ -11171,6 +11330,7 @@ class Control {
|
|
|
11171
11330
|
editorOptions: this.options
|
|
11172
11331
|
});
|
|
11173
11332
|
const text = new TextControl(element, this);
|
|
11333
|
+
this.activeControl = text;
|
|
11174
11334
|
if (value) {
|
|
11175
11335
|
text.setValue(formatValue, controlContext, controlRule);
|
|
11176
11336
|
} else {
|
|
@@ -11178,6 +11338,7 @@ class Control {
|
|
|
11178
11338
|
}
|
|
11179
11339
|
} else if (type === ControlType.SELECT) {
|
|
11180
11340
|
const select = new SelectControl(element, this);
|
|
11341
|
+
this.activeControl = select;
|
|
11181
11342
|
if (value) {
|
|
11182
11343
|
select.setSelect(value, controlContext, controlRule);
|
|
11183
11344
|
} else {
|
|
@@ -11185,13 +11346,16 @@ class Control {
|
|
|
11185
11346
|
}
|
|
11186
11347
|
} else if (type === ControlType.CHECKBOX) {
|
|
11187
11348
|
const checkbox = new CheckboxControl(element, this);
|
|
11349
|
+
this.activeControl = checkbox;
|
|
11188
11350
|
const codes = (value == null ? void 0 : value.split(",")) || [];
|
|
11189
11351
|
checkbox.setSelect(codes, controlContext, controlRule);
|
|
11190
11352
|
} else if (type === ControlType.RADIO) {
|
|
11191
11353
|
const radio = new RadioControl(element, this);
|
|
11354
|
+
this.activeControl = radio;
|
|
11192
11355
|
const codes = value ? [value] : [];
|
|
11193
11356
|
radio.setSelect(codes, controlContext, controlRule);
|
|
11194
11357
|
}
|
|
11358
|
+
this.activeControl = null;
|
|
11195
11359
|
let newEndIndex = i;
|
|
11196
11360
|
while (newEndIndex < elementList.length) {
|
|
11197
11361
|
const nextElement = elementList[newEndIndex];
|
|
@@ -11202,6 +11366,7 @@ class Control {
|
|
|
11202
11366
|
i = newEndIndex;
|
|
11203
11367
|
}
|
|
11204
11368
|
};
|
|
11369
|
+
this.destroyControl();
|
|
11205
11370
|
const data2 = [
|
|
11206
11371
|
this.draw.getHeaderElementList(),
|
|
11207
11372
|
this.draw.getOriginalMainElementList(),
|
|
@@ -11331,6 +11496,237 @@ class Control {
|
|
|
11331
11496
|
drawBorder(ctx) {
|
|
11332
11497
|
this.controlBorder.render(ctx);
|
|
11333
11498
|
}
|
|
11499
|
+
getPreControlContext() {
|
|
11500
|
+
if (!this.activeControl)
|
|
11501
|
+
return null;
|
|
11502
|
+
const position = this.draw.getPosition();
|
|
11503
|
+
const positionContext = position.getPositionContext();
|
|
11504
|
+
if (!positionContext)
|
|
11505
|
+
return null;
|
|
11506
|
+
const controlElement = this.activeControl.getElement();
|
|
11507
|
+
function getPreContext(elementList2, start) {
|
|
11508
|
+
for (let e = start; e > 0; e--) {
|
|
11509
|
+
const element = elementList2[e];
|
|
11510
|
+
if (element.type === ElementType.TABLE) {
|
|
11511
|
+
const trList = element.trList || [];
|
|
11512
|
+
for (let r = trList.length - 1; r >= 0; r--) {
|
|
11513
|
+
const tr = trList[r];
|
|
11514
|
+
const tdList = tr.tdList;
|
|
11515
|
+
for (let d = tdList.length - 1; d >= 0; d--) {
|
|
11516
|
+
const td = tdList[d];
|
|
11517
|
+
const context2 = getPreContext(td.value, td.value.length - 1);
|
|
11518
|
+
if (context2) {
|
|
11519
|
+
return {
|
|
11520
|
+
positionContext: {
|
|
11521
|
+
isTable: true,
|
|
11522
|
+
index: e,
|
|
11523
|
+
trIndex: r,
|
|
11524
|
+
tdIndex: d,
|
|
11525
|
+
tdId: td.id,
|
|
11526
|
+
trId: tr.id,
|
|
11527
|
+
tableId: element.id
|
|
11528
|
+
},
|
|
11529
|
+
nextIndex: context2.nextIndex
|
|
11530
|
+
};
|
|
11531
|
+
}
|
|
11532
|
+
}
|
|
11533
|
+
}
|
|
11534
|
+
}
|
|
11535
|
+
if (!element.controlId || element.controlId === controlElement.controlId) {
|
|
11536
|
+
continue;
|
|
11537
|
+
}
|
|
11538
|
+
let nextIndex = e;
|
|
11539
|
+
while (nextIndex > 0) {
|
|
11540
|
+
const nextElement = elementList2[nextIndex];
|
|
11541
|
+
if (nextElement.controlComponent === ControlComponent.VALUE || nextElement.controlComponent === ControlComponent.PREFIX) {
|
|
11542
|
+
break;
|
|
11543
|
+
}
|
|
11544
|
+
nextIndex--;
|
|
11545
|
+
}
|
|
11546
|
+
return {
|
|
11547
|
+
positionContext: {
|
|
11548
|
+
isTable: false
|
|
11549
|
+
},
|
|
11550
|
+
nextIndex
|
|
11551
|
+
};
|
|
11552
|
+
}
|
|
11553
|
+
return null;
|
|
11554
|
+
}
|
|
11555
|
+
const { startIndex } = this.range.getRange();
|
|
11556
|
+
const elementList = this.getElementList();
|
|
11557
|
+
const context = getPreContext(elementList, startIndex);
|
|
11558
|
+
if (context) {
|
|
11559
|
+
return {
|
|
11560
|
+
positionContext: positionContext.isTable ? positionContext : context.positionContext,
|
|
11561
|
+
nextIndex: context.nextIndex
|
|
11562
|
+
};
|
|
11563
|
+
}
|
|
11564
|
+
if (controlElement.tableId) {
|
|
11565
|
+
const originalElementList = this.draw.getOriginalElementList();
|
|
11566
|
+
const { index: index2, trIndex, tdIndex } = positionContext;
|
|
11567
|
+
const trList = originalElementList[index2].trList;
|
|
11568
|
+
for (let r = trIndex; r >= 0; r--) {
|
|
11569
|
+
const tr = trList[r];
|
|
11570
|
+
const tdList = tr.tdList;
|
|
11571
|
+
for (let d = tdList.length - 1; d >= 0; d--) {
|
|
11572
|
+
if (trIndex === r && d >= tdIndex)
|
|
11573
|
+
continue;
|
|
11574
|
+
const td = tdList[d];
|
|
11575
|
+
const context3 = getPreContext(td.value, td.value.length - 1);
|
|
11576
|
+
if (context3) {
|
|
11577
|
+
return {
|
|
11578
|
+
positionContext: {
|
|
11579
|
+
isTable: true,
|
|
11580
|
+
index: positionContext.index,
|
|
11581
|
+
trIndex: r,
|
|
11582
|
+
tdIndex: d,
|
|
11583
|
+
tdId: td.id,
|
|
11584
|
+
trId: tr.id,
|
|
11585
|
+
tableId: controlElement.tableId
|
|
11586
|
+
},
|
|
11587
|
+
nextIndex: context3.nextIndex
|
|
11588
|
+
};
|
|
11589
|
+
}
|
|
11590
|
+
}
|
|
11591
|
+
}
|
|
11592
|
+
const context2 = getPreContext(originalElementList, index2 - 1);
|
|
11593
|
+
if (context2) {
|
|
11594
|
+
return {
|
|
11595
|
+
positionContext: {
|
|
11596
|
+
isTable: false
|
|
11597
|
+
},
|
|
11598
|
+
nextIndex: context2.nextIndex
|
|
11599
|
+
};
|
|
11600
|
+
}
|
|
11601
|
+
}
|
|
11602
|
+
return null;
|
|
11603
|
+
}
|
|
11604
|
+
getNextControlContext() {
|
|
11605
|
+
if (!this.activeControl)
|
|
11606
|
+
return null;
|
|
11607
|
+
const position = this.draw.getPosition();
|
|
11608
|
+
const positionContext = position.getPositionContext();
|
|
11609
|
+
if (!positionContext)
|
|
11610
|
+
return null;
|
|
11611
|
+
const controlElement = this.activeControl.getElement();
|
|
11612
|
+
function getNextContext(elementList2, start) {
|
|
11613
|
+
for (let e = start; e < elementList2.length; e++) {
|
|
11614
|
+
const element = elementList2[e];
|
|
11615
|
+
if (element.type === ElementType.TABLE) {
|
|
11616
|
+
const trList = element.trList || [];
|
|
11617
|
+
for (let r = 0; r < trList.length; r++) {
|
|
11618
|
+
const tr = trList[r];
|
|
11619
|
+
const tdList = tr.tdList;
|
|
11620
|
+
for (let d = 0; d < tdList.length; d++) {
|
|
11621
|
+
const td = tdList[d];
|
|
11622
|
+
const context2 = getNextContext(td.value, 0);
|
|
11623
|
+
if (context2) {
|
|
11624
|
+
return {
|
|
11625
|
+
positionContext: {
|
|
11626
|
+
isTable: true,
|
|
11627
|
+
index: e,
|
|
11628
|
+
trIndex: r,
|
|
11629
|
+
tdIndex: d,
|
|
11630
|
+
tdId: td.id,
|
|
11631
|
+
trId: tr.id,
|
|
11632
|
+
tableId: element.id
|
|
11633
|
+
},
|
|
11634
|
+
nextIndex: context2.nextIndex
|
|
11635
|
+
};
|
|
11636
|
+
}
|
|
11637
|
+
}
|
|
11638
|
+
}
|
|
11639
|
+
}
|
|
11640
|
+
if (!element.controlId || element.controlId === controlElement.controlId) {
|
|
11641
|
+
continue;
|
|
11642
|
+
}
|
|
11643
|
+
return {
|
|
11644
|
+
positionContext: {
|
|
11645
|
+
isTable: false
|
|
11646
|
+
},
|
|
11647
|
+
nextIndex: e
|
|
11648
|
+
};
|
|
11649
|
+
}
|
|
11650
|
+
return null;
|
|
11651
|
+
}
|
|
11652
|
+
const { endIndex } = this.range.getRange();
|
|
11653
|
+
const elementList = this.getElementList();
|
|
11654
|
+
const context = getNextContext(elementList, endIndex);
|
|
11655
|
+
if (context) {
|
|
11656
|
+
return {
|
|
11657
|
+
positionContext: positionContext.isTable ? positionContext : context.positionContext,
|
|
11658
|
+
nextIndex: context.nextIndex
|
|
11659
|
+
};
|
|
11660
|
+
}
|
|
11661
|
+
if (controlElement.tableId) {
|
|
11662
|
+
const originalElementList = this.draw.getOriginalElementList();
|
|
11663
|
+
const { index: index2, trIndex, tdIndex } = positionContext;
|
|
11664
|
+
const trList = originalElementList[index2].trList;
|
|
11665
|
+
for (let r = trIndex; r < trList.length; r++) {
|
|
11666
|
+
const tr = trList[r];
|
|
11667
|
+
const tdList = tr.tdList;
|
|
11668
|
+
for (let d = 0; d < tdList.length; d++) {
|
|
11669
|
+
if (trIndex === r && d <= tdIndex)
|
|
11670
|
+
continue;
|
|
11671
|
+
const td = tdList[d];
|
|
11672
|
+
const context3 = getNextContext(td.value, 0);
|
|
11673
|
+
if (context3) {
|
|
11674
|
+
return {
|
|
11675
|
+
positionContext: {
|
|
11676
|
+
isTable: true,
|
|
11677
|
+
index: positionContext.index,
|
|
11678
|
+
trIndex: r,
|
|
11679
|
+
tdIndex: d,
|
|
11680
|
+
tdId: td.id,
|
|
11681
|
+
trId: tr.id,
|
|
11682
|
+
tableId: controlElement.tableId
|
|
11683
|
+
},
|
|
11684
|
+
nextIndex: context3.nextIndex
|
|
11685
|
+
};
|
|
11686
|
+
}
|
|
11687
|
+
}
|
|
11688
|
+
}
|
|
11689
|
+
const context2 = getNextContext(originalElementList, index2 + 1);
|
|
11690
|
+
if (context2) {
|
|
11691
|
+
return {
|
|
11692
|
+
positionContext: {
|
|
11693
|
+
isTable: false
|
|
11694
|
+
},
|
|
11695
|
+
nextIndex: context2.nextIndex
|
|
11696
|
+
};
|
|
11697
|
+
}
|
|
11698
|
+
}
|
|
11699
|
+
return null;
|
|
11700
|
+
}
|
|
11701
|
+
initNextControl(option = {}) {
|
|
11702
|
+
const { direction = MoveDirection.DOWN } = option;
|
|
11703
|
+
let context = null;
|
|
11704
|
+
if (direction === MoveDirection.UP) {
|
|
11705
|
+
context = this.getPreControlContext();
|
|
11706
|
+
} else {
|
|
11707
|
+
context = this.getNextControlContext();
|
|
11708
|
+
}
|
|
11709
|
+
if (!context)
|
|
11710
|
+
return;
|
|
11711
|
+
const { nextIndex, positionContext } = context;
|
|
11712
|
+
const position = this.draw.getPosition();
|
|
11713
|
+
position.setPositionContext(positionContext);
|
|
11714
|
+
this.draw.getRange().replaceRange({
|
|
11715
|
+
startIndex: nextIndex,
|
|
11716
|
+
endIndex: nextIndex
|
|
11717
|
+
});
|
|
11718
|
+
this.draw.render({
|
|
11719
|
+
curIndex: nextIndex,
|
|
11720
|
+
isCompute: false,
|
|
11721
|
+
isSetCursor: true,
|
|
11722
|
+
isSubmitHistory: false
|
|
11723
|
+
});
|
|
11724
|
+
const positionList = position.getPositionList();
|
|
11725
|
+
this.draw.getCursor().moveCursorToVisible({
|
|
11726
|
+
cursorPosition: positionList[nextIndex],
|
|
11727
|
+
direction
|
|
11728
|
+
});
|
|
11729
|
+
}
|
|
11334
11730
|
}
|
|
11335
11731
|
class CheckboxParticle {
|
|
11336
11732
|
constructor(draw) {
|
|
@@ -11561,11 +11957,13 @@ class Previewer {
|
|
|
11561
11957
|
this.previewerImage = null;
|
|
11562
11958
|
}
|
|
11563
11959
|
_getElementPosition(element, position = null) {
|
|
11960
|
+
var _a;
|
|
11564
11961
|
let x = 0;
|
|
11565
11962
|
let y = 0;
|
|
11566
11963
|
const height = this.draw.getHeight();
|
|
11567
11964
|
const pageGap = this.draw.getPageGap();
|
|
11568
|
-
const
|
|
11965
|
+
const pageNo = (_a = position == null ? void 0 : position.pageNo) != null ? _a : this.draw.getPageNo();
|
|
11966
|
+
const preY = pageNo * (height + pageGap);
|
|
11569
11967
|
if (element.imgFloatPosition) {
|
|
11570
11968
|
x = element.imgFloatPosition.x;
|
|
11571
11969
|
y = element.imgFloatPosition.y + preY;
|
|
@@ -11634,11 +12032,14 @@ class Previewer {
|
|
|
11634
12032
|
const mousemoveFn = this._mousemove.bind(this);
|
|
11635
12033
|
document.addEventListener("mousemove", mousemoveFn);
|
|
11636
12034
|
document.addEventListener("mouseup", () => {
|
|
12035
|
+
var _a;
|
|
11637
12036
|
if (this.curElement) {
|
|
11638
12037
|
this.curElement.width = this.width;
|
|
11639
12038
|
this.curElement.height = this.height;
|
|
11640
|
-
this.draw.render({
|
|
11641
|
-
|
|
12039
|
+
this.draw.render({
|
|
12040
|
+
isSetCursor: true,
|
|
12041
|
+
curIndex: (_a = this.curPosition) == null ? void 0 : _a.index
|
|
12042
|
+
});
|
|
11642
12043
|
}
|
|
11643
12044
|
this.resizerImageContainer.style.display = "none";
|
|
11644
12045
|
document.removeEventListener("mousemove", mousemoveFn);
|
|
@@ -14196,10 +14597,18 @@ class Draw {
|
|
|
14196
14597
|
this.footer.recovery();
|
|
14197
14598
|
this.zone.setZone(EditorZone.MAIN);
|
|
14198
14599
|
}
|
|
14600
|
+
const { startIndex } = this.range.getRange();
|
|
14601
|
+
const isCollapsed = this.range.getIsCollapsed();
|
|
14199
14602
|
this.render({
|
|
14200
|
-
|
|
14201
|
-
|
|
14603
|
+
isSetCursor: true,
|
|
14604
|
+
curIndex: startIndex,
|
|
14605
|
+
isSubmitHistory: false
|
|
14202
14606
|
});
|
|
14607
|
+
if (!isCollapsed) {
|
|
14608
|
+
this.cursor.drawCursor({
|
|
14609
|
+
isShow: false
|
|
14610
|
+
});
|
|
14611
|
+
}
|
|
14203
14612
|
setTimeout(() => {
|
|
14204
14613
|
if (this.listener.pageModeChange) {
|
|
14205
14614
|
this.listener.pageModeChange(payload);
|
|
@@ -14458,14 +14867,11 @@ class Draw {
|
|
|
14458
14867
|
} else {
|
|
14459
14868
|
const elementWidth = element.width * scale;
|
|
14460
14869
|
const elementHeight = element.height * scale;
|
|
14461
|
-
|
|
14462
|
-
|
|
14463
|
-
|
|
14464
|
-
const adaptiveWidth = surplusWidth > 0 ? surplusWidth : Math.min(elementWidth, availableWidth);
|
|
14465
|
-
const adaptiveHeight = elementHeight * adaptiveWidth / elementWidth;
|
|
14466
|
-
element.width = adaptiveWidth / scale;
|
|
14870
|
+
if (elementWidth > availableWidth) {
|
|
14871
|
+
const adaptiveHeight = elementHeight * availableWidth / elementWidth;
|
|
14872
|
+
element.width = availableWidth / scale;
|
|
14467
14873
|
element.height = adaptiveHeight / scale;
|
|
14468
|
-
metrics.width =
|
|
14874
|
+
metrics.width = availableWidth;
|
|
14469
14875
|
metrics.height = adaptiveHeight;
|
|
14470
14876
|
metrics.boundingBoxDescent = adaptiveHeight;
|
|
14471
14877
|
} else {
|
|
@@ -14761,29 +15167,16 @@ class Draw {
|
|
|
14761
15167
|
const isForceBreak = element.type === ElementType.SEPARATOR || 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 || (preElement == null ? void 0 : preElement.listId) !== element.listId || i !== 0 && element.value === ZERO;
|
|
14762
15168
|
const isWidthNotEnough = curRowWidth > availableWidth;
|
|
14763
15169
|
if (isForceBreak || isWidthNotEnough) {
|
|
14764
|
-
curRow.isWidthNotEnough = isWidthNotEnough && !isForceBreak;
|
|
14765
|
-
if (curRow.startIndex === 0 && curRow.elementList.length === 1 && INLINE_ELEMENT_TYPE.includes(element.type)) {
|
|
14766
|
-
curRow.height = defaultBasicRowMarginHeight;
|
|
14767
|
-
}
|
|
14768
|
-
if ((preElement == null ? void 0 : preElement.rowFlex) === RowFlex.JUSTIFY || (preElement == null ? void 0 : preElement.rowFlex) === RowFlex.ALIGNMENT && isWidthNotEnough) {
|
|
14769
|
-
const rowElementList = ((_g = curRow.elementList[0]) == null ? void 0 : _g.value) === ZERO ? curRow.elementList.slice(1) : curRow.elementList;
|
|
14770
|
-
const gap = (availableWidth - curRow.width) / (rowElementList.length - 1);
|
|
14771
|
-
for (let e = 0; e < rowElementList.length - 1; e++) {
|
|
14772
|
-
const el = rowElementList[e];
|
|
14773
|
-
el.metrics.width += gap;
|
|
14774
|
-
}
|
|
14775
|
-
curRow.width = availableWidth;
|
|
14776
|
-
}
|
|
14777
15170
|
const row = {
|
|
14778
15171
|
width: metrics.width,
|
|
14779
15172
|
height,
|
|
14780
15173
|
startIndex: i,
|
|
14781
15174
|
elementList: [rowElement],
|
|
14782
15175
|
ascent,
|
|
14783
|
-
rowFlex: ((
|
|
15176
|
+
rowFlex: ((_g = elementList[i]) == null ? void 0 : _g.rowFlex) || ((_h = elementList[i + 1]) == null ? void 0 : _h.rowFlex),
|
|
14784
15177
|
isPageBreak: element.type === ElementType.PAGE_BREAK
|
|
14785
15178
|
};
|
|
14786
|
-
if (rowElement.controlComponent !== ControlComponent.PREFIX && ((
|
|
15179
|
+
if (rowElement.controlComponent !== ControlComponent.PREFIX && ((_i = rowElement.control) == null ? void 0 : _i.indentation) === ControlIndentation.VALUE_START) {
|
|
14787
15180
|
const preStartIndex = curRow.elementList.findIndex((el) => el.controlId === rowElement.controlId && el.controlComponent !== ControlComponent.PREFIX);
|
|
14788
15181
|
if (~preStartIndex) {
|
|
14789
15182
|
const preRowPositionList = this.position.computeRowPosition({
|
|
@@ -14804,12 +15197,27 @@ class Draw {
|
|
|
14804
15197
|
rowList.push(row);
|
|
14805
15198
|
} else {
|
|
14806
15199
|
curRow.width += metrics.width;
|
|
14807
|
-
if (
|
|
15200
|
+
if (i === 0 && getIsBlockElement(elementList[1])) {
|
|
15201
|
+
curRow.height = defaultBasicRowMarginHeight;
|
|
15202
|
+
curRow.ascent = defaultBasicRowMarginHeight;
|
|
15203
|
+
} else if (curRow.height < height) {
|
|
14808
15204
|
curRow.height = height;
|
|
14809
15205
|
curRow.ascent = ascent;
|
|
14810
15206
|
}
|
|
14811
15207
|
curRow.elementList.push(rowElement);
|
|
14812
15208
|
}
|
|
15209
|
+
if (isForceBreak || isWidthNotEnough || i === elementList.length - 1) {
|
|
15210
|
+
curRow.isWidthNotEnough = isWidthNotEnough && !isForceBreak;
|
|
15211
|
+
if ((preElement == null ? void 0 : preElement.rowFlex) === RowFlex.JUSTIFY || (preElement == null ? void 0 : preElement.rowFlex) === RowFlex.ALIGNMENT && isWidthNotEnough) {
|
|
15212
|
+
const rowElementList = ((_j = curRow.elementList[0]) == null ? void 0 : _j.value) === ZERO ? curRow.elementList.slice(1) : curRow.elementList;
|
|
15213
|
+
const gap = (availableWidth - curRow.width) / (rowElementList.length - 1);
|
|
15214
|
+
for (let e = 0; e < rowElementList.length - 1; e++) {
|
|
15215
|
+
const el = rowElementList[e];
|
|
15216
|
+
el.metrics.width += gap;
|
|
15217
|
+
}
|
|
15218
|
+
curRow.width = availableWidth;
|
|
15219
|
+
}
|
|
15220
|
+
}
|
|
14813
15221
|
}
|
|
14814
15222
|
return rowList;
|
|
14815
15223
|
}
|
|
@@ -14956,7 +15364,7 @@ class Draw {
|
|
|
14956
15364
|
this.textParticle.complete();
|
|
14957
15365
|
}
|
|
14958
15366
|
}
|
|
14959
|
-
if (isDrawLineBreak && !curRow.isWidthNotEnough && j === curRow.elementList.length - 1) {
|
|
15367
|
+
if (isDrawLineBreak && !isPrintMode && this.mode !== EditorMode.CLEAN && !curRow.isWidthNotEnough && j === curRow.elementList.length - 1) {
|
|
14960
15368
|
this.lineBreakParticle.render(ctx, element, x, y + curRow.height / 2);
|
|
14961
15369
|
}
|
|
14962
15370
|
if ((_a = element.control) == null ? void 0 : _a.border) {
|
|
@@ -15085,7 +15493,7 @@ class Draw {
|
|
|
15085
15493
|
_clearPage(pageNo) {
|
|
15086
15494
|
const ctx = this.ctxList[pageNo];
|
|
15087
15495
|
const pageDom = this.pageList[pageNo];
|
|
15088
|
-
ctx.clearRect(0, 0, pageDom.width, pageDom.height);
|
|
15496
|
+
ctx.clearRect(0, 0, Math.max(pageDom.width, this.getWidth()), Math.max(pageDom.height, this.getHeight()));
|
|
15089
15497
|
this.blockParticle.clear();
|
|
15090
15498
|
}
|
|
15091
15499
|
_drawPage(payload) {
|
|
@@ -15232,6 +15640,9 @@ class Draw {
|
|
|
15232
15640
|
this.submitHistory(curIndex);
|
|
15233
15641
|
}
|
|
15234
15642
|
nextTick(() => {
|
|
15643
|
+
if (isCompute && this.control.getActiveControl()) {
|
|
15644
|
+
this.control.reAwakeControl();
|
|
15645
|
+
}
|
|
15235
15646
|
if (isCompute && !this.isReadonly() && this.position.getPositionContext().isTable) {
|
|
15236
15647
|
this.tableTool.render();
|
|
15237
15648
|
}
|
|
@@ -15412,6 +15823,7 @@ class Command {
|
|
|
15412
15823
|
__publicField(this, "executeSetControlExtension");
|
|
15413
15824
|
__publicField(this, "executeSetControlProperties");
|
|
15414
15825
|
__publicField(this, "executeSetControlHighlight");
|
|
15826
|
+
__publicField(this, "executeUpdateOptions");
|
|
15415
15827
|
__publicField(this, "getCatalog");
|
|
15416
15828
|
__publicField(this, "getImage");
|
|
15417
15829
|
__publicField(this, "getOptions");
|
|
@@ -15517,6 +15929,7 @@ class Command {
|
|
|
15517
15929
|
this.executeDeleteGroup = adapt.deleteGroup.bind(adapt);
|
|
15518
15930
|
this.executeLocationGroup = adapt.locationGroup.bind(adapt);
|
|
15519
15931
|
this.executeSetZone = adapt.setZone.bind(adapt);
|
|
15932
|
+
this.executeUpdateOptions = adapt.updateOptions.bind(adapt);
|
|
15520
15933
|
this.getImage = adapt.getImage.bind(adapt);
|
|
15521
15934
|
this.getOptions = adapt.getOptions.bind(adapt);
|
|
15522
15935
|
this.getValue = adapt.getValue.bind(adapt);
|
|
@@ -15557,6 +15970,160 @@ var VerticalAlign;
|
|
|
15557
15970
|
VerticalAlign2["MIDDLE"] = "middle";
|
|
15558
15971
|
VerticalAlign2["BOTTOM"] = "bottom";
|
|
15559
15972
|
})(VerticalAlign || (VerticalAlign = {}));
|
|
15973
|
+
const defaultBackground = {
|
|
15974
|
+
color: "#FFFFFF",
|
|
15975
|
+
image: "",
|
|
15976
|
+
size: BackgroundSize.COVER,
|
|
15977
|
+
repeat: BackgroundRepeat.NO_REPEAT
|
|
15978
|
+
};
|
|
15979
|
+
const defaultCheckboxOption = {
|
|
15980
|
+
width: 14,
|
|
15981
|
+
height: 14,
|
|
15982
|
+
gap: 5,
|
|
15983
|
+
lineWidth: 1,
|
|
15984
|
+
fillStyle: "#5175f4",
|
|
15985
|
+
strokeStyle: "#ffffff"
|
|
15986
|
+
};
|
|
15987
|
+
const defaultControlOption = {
|
|
15988
|
+
placeholderColor: "#9c9b9b",
|
|
15989
|
+
bracketColor: "#000000",
|
|
15990
|
+
prefix: "{",
|
|
15991
|
+
postfix: "}",
|
|
15992
|
+
borderWidth: 1,
|
|
15993
|
+
borderColor: "#000000"
|
|
15994
|
+
};
|
|
15995
|
+
const defaultFooterOption = {
|
|
15996
|
+
bottom: 30,
|
|
15997
|
+
maxHeightRadio: MaxHeightRatio.HALF,
|
|
15998
|
+
disabled: false
|
|
15999
|
+
};
|
|
16000
|
+
const defaultGroupOption = {
|
|
16001
|
+
opacity: 0.1,
|
|
16002
|
+
backgroundColor: "#E99D00",
|
|
16003
|
+
activeOpacity: 0.5,
|
|
16004
|
+
activeBackgroundColor: "#E99D00",
|
|
16005
|
+
disabled: false
|
|
16006
|
+
};
|
|
16007
|
+
const defaultHeaderOption = {
|
|
16008
|
+
top: 30,
|
|
16009
|
+
maxHeightRadio: MaxHeightRatio.HALF,
|
|
16010
|
+
disabled: false
|
|
16011
|
+
};
|
|
16012
|
+
const defaultLineBreak = {
|
|
16013
|
+
disabled: true,
|
|
16014
|
+
color: "#CCCCCC",
|
|
16015
|
+
lineWidth: 1.5
|
|
16016
|
+
};
|
|
16017
|
+
const defaultPageBreakOption = {
|
|
16018
|
+
font: "Microsoft YaHei",
|
|
16019
|
+
fontSize: 12,
|
|
16020
|
+
lineDash: [3, 1]
|
|
16021
|
+
};
|
|
16022
|
+
const defaultPlaceholderOption = {
|
|
16023
|
+
data: "",
|
|
16024
|
+
color: "#DCDFE6",
|
|
16025
|
+
opacity: 1,
|
|
16026
|
+
size: 16,
|
|
16027
|
+
font: "Microsoft YaHei"
|
|
16028
|
+
};
|
|
16029
|
+
const defaultRadioOption = {
|
|
16030
|
+
width: 14,
|
|
16031
|
+
height: 14,
|
|
16032
|
+
gap: 5,
|
|
16033
|
+
lineWidth: 1,
|
|
16034
|
+
fillStyle: "#5175f4",
|
|
16035
|
+
strokeStyle: "#000000"
|
|
16036
|
+
};
|
|
16037
|
+
const defaultSeparatorOption = {
|
|
16038
|
+
lineWidth: 1,
|
|
16039
|
+
strokeStyle: "#000000"
|
|
16040
|
+
};
|
|
16041
|
+
const defaultTableOption = {
|
|
16042
|
+
tdPadding: [0, 5, 5, 5],
|
|
16043
|
+
defaultTrMinHeight: 42,
|
|
16044
|
+
defaultColMinWidth: 40
|
|
16045
|
+
};
|
|
16046
|
+
const defaultZoneOption = {
|
|
16047
|
+
tipDisabled: true
|
|
16048
|
+
};
|
|
16049
|
+
function mergeOption(options = {}) {
|
|
16050
|
+
const tableOptions = __spreadValues(__spreadValues({}, defaultTableOption), options.table);
|
|
16051
|
+
const headerOptions = __spreadValues(__spreadValues({}, defaultHeaderOption), options.header);
|
|
16052
|
+
const footerOptions = __spreadValues(__spreadValues({}, defaultFooterOption), options.footer);
|
|
16053
|
+
const pageNumberOptions = __spreadValues(__spreadValues({}, defaultPageNumberOption), options.pageNumber);
|
|
16054
|
+
const waterMarkOptions = __spreadValues(__spreadValues({}, defaultWatermarkOption), options.watermark);
|
|
16055
|
+
const controlOptions = __spreadValues(__spreadValues({}, defaultControlOption), options.control);
|
|
16056
|
+
const checkboxOptions = __spreadValues(__spreadValues({}, defaultCheckboxOption), options.checkbox);
|
|
16057
|
+
const radioOptions = __spreadValues(__spreadValues({}, defaultRadioOption), options.radio);
|
|
16058
|
+
const cursorOptions = __spreadValues(__spreadValues({}, defaultCursorOption), options.cursor);
|
|
16059
|
+
const titleOptions = __spreadValues(__spreadValues({}, defaultTitleOption), options.title);
|
|
16060
|
+
const placeholderOptions = __spreadValues(__spreadValues({}, defaultPlaceholderOption), options.placeholder);
|
|
16061
|
+
const groupOptions = __spreadValues(__spreadValues({}, defaultGroupOption), options.group);
|
|
16062
|
+
const pageBreakOptions = __spreadValues(__spreadValues({}, defaultPageBreakOption), options.pageBreak);
|
|
16063
|
+
const zoneOptions = __spreadValues(__spreadValues({}, defaultZoneOption), options.zone);
|
|
16064
|
+
const backgroundOptions = __spreadValues(__spreadValues({}, defaultBackground), options.background);
|
|
16065
|
+
const lineBreakOptions = __spreadValues(__spreadValues({}, defaultLineBreak), options.lineBreak);
|
|
16066
|
+
const separatorOptions = __spreadValues(__spreadValues({}, defaultSeparatorOption), options.separator);
|
|
16067
|
+
return __spreadProps(__spreadValues({
|
|
16068
|
+
mode: EditorMode.EDIT,
|
|
16069
|
+
defaultType: "TEXT",
|
|
16070
|
+
defaultColor: "#000000",
|
|
16071
|
+
defaultFont: "Microsoft YaHei",
|
|
16072
|
+
defaultSize: 16,
|
|
16073
|
+
minSize: 5,
|
|
16074
|
+
maxSize: 72,
|
|
16075
|
+
defaultRowMargin: 1,
|
|
16076
|
+
defaultBasicRowMarginHeight: 8,
|
|
16077
|
+
defaultTabWidth: 32,
|
|
16078
|
+
width: 794,
|
|
16079
|
+
height: 1123,
|
|
16080
|
+
scale: 1,
|
|
16081
|
+
pageGap: 20,
|
|
16082
|
+
underlineColor: "#000000",
|
|
16083
|
+
strikeoutColor: "#FF0000",
|
|
16084
|
+
rangeAlpha: 0.6,
|
|
16085
|
+
rangeColor: "#AECBFA",
|
|
16086
|
+
rangeMinWidth: 5,
|
|
16087
|
+
searchMatchAlpha: 0.6,
|
|
16088
|
+
searchMatchColor: "#FFFF00",
|
|
16089
|
+
searchNavigateMatchColor: "#AAD280",
|
|
16090
|
+
highlightAlpha: 0.6,
|
|
16091
|
+
resizerColor: "#4182D9",
|
|
16092
|
+
resizerSize: 5,
|
|
16093
|
+
marginIndicatorSize: 35,
|
|
16094
|
+
marginIndicatorColor: "#BABABA",
|
|
16095
|
+
margins: [100, 120, 100, 120],
|
|
16096
|
+
pageMode: PageMode.PAGING,
|
|
16097
|
+
defaultHyperlinkColor: "#0000FF",
|
|
16098
|
+
paperDirection: PaperDirection.VERTICAL,
|
|
16099
|
+
inactiveAlpha: 0.6,
|
|
16100
|
+
historyMaxRecordCount: 100,
|
|
16101
|
+
wordBreak: WordBreak.BREAK_WORD,
|
|
16102
|
+
printPixelRatio: 3,
|
|
16103
|
+
maskMargin: [0, 0, 0, 0],
|
|
16104
|
+
letterClass: [LETTER_CLASS.ENGLISH],
|
|
16105
|
+
contextMenuDisableKeys: [],
|
|
16106
|
+
scrollContainerSelector: ""
|
|
16107
|
+
}, options), {
|
|
16108
|
+
table: tableOptions,
|
|
16109
|
+
header: headerOptions,
|
|
16110
|
+
footer: footerOptions,
|
|
16111
|
+
pageNumber: pageNumberOptions,
|
|
16112
|
+
watermark: waterMarkOptions,
|
|
16113
|
+
control: controlOptions,
|
|
16114
|
+
checkbox: checkboxOptions,
|
|
16115
|
+
radio: radioOptions,
|
|
16116
|
+
cursor: cursorOptions,
|
|
16117
|
+
title: titleOptions,
|
|
16118
|
+
placeholder: placeholderOptions,
|
|
16119
|
+
group: groupOptions,
|
|
16120
|
+
pageBreak: pageBreakOptions,
|
|
16121
|
+
zone: zoneOptions,
|
|
16122
|
+
background: backgroundOptions,
|
|
16123
|
+
lineBreak: lineBreakOptions,
|
|
16124
|
+
separator: separatorOptions
|
|
16125
|
+
});
|
|
16126
|
+
}
|
|
15560
16127
|
function printImageBase64(base64List, options) {
|
|
15561
16128
|
const { width, height, direction = PaperDirection.VERTICAL } = options;
|
|
15562
16129
|
const iframe = document.createElement("iframe");
|
|
@@ -17157,14 +17724,15 @@ class CommandAdapt {
|
|
|
17157
17724
|
const { startIndex, endIndex } = this.range.getRange();
|
|
17158
17725
|
if (!~startIndex && !~endIndex)
|
|
17159
17726
|
return;
|
|
17160
|
-
const { value, width, height } = payload;
|
|
17727
|
+
const { value, width, height, imgDisplay } = payload;
|
|
17161
17728
|
this.insertElementList([
|
|
17162
17729
|
{
|
|
17163
17730
|
value,
|
|
17164
17731
|
width,
|
|
17165
17732
|
height,
|
|
17166
17733
|
id: getUUID(),
|
|
17167
|
-
type: ElementType.IMAGE
|
|
17734
|
+
type: ElementType.IMAGE,
|
|
17735
|
+
imgDisplay
|
|
17168
17736
|
}
|
|
17169
17737
|
]);
|
|
17170
17738
|
}
|
|
@@ -17341,9 +17909,9 @@ class CommandAdapt {
|
|
|
17341
17909
|
if (element.imgDisplay === display)
|
|
17342
17910
|
return;
|
|
17343
17911
|
element.imgDisplay = display;
|
|
17912
|
+
const { startIndex, endIndex } = this.range.getRange();
|
|
17344
17913
|
if (display === ImageDisplay.FLOAT_TOP || display === ImageDisplay.FLOAT_BOTTOM) {
|
|
17345
17914
|
const positionList = this.position.getPositionList();
|
|
17346
|
-
const { startIndex } = this.range.getRange();
|
|
17347
17915
|
const { coordinate: { leftTop } } = positionList[startIndex];
|
|
17348
17916
|
element.imgFloatPosition = {
|
|
17349
17917
|
x: leftTop[0],
|
|
@@ -17354,7 +17922,8 @@ class CommandAdapt {
|
|
|
17354
17922
|
}
|
|
17355
17923
|
this.draw.getPreviewer().clearResizer();
|
|
17356
17924
|
this.draw.render({
|
|
17357
|
-
isSetCursor:
|
|
17925
|
+
isSetCursor: true,
|
|
17926
|
+
curIndex: endIndex
|
|
17358
17927
|
});
|
|
17359
17928
|
}
|
|
17360
17929
|
getImage(payload) {
|
|
@@ -17449,7 +18018,15 @@ class CommandAdapt {
|
|
|
17449
18018
|
});
|
|
17450
18019
|
}
|
|
17451
18020
|
const zone2 = this.draw.getZone().getZone();
|
|
17452
|
-
const isTable = this.position.getPositionContext()
|
|
18021
|
+
const { isTable, trIndex, tdIndex, index: index2 } = this.position.getPositionContext();
|
|
18022
|
+
let tableElement = null;
|
|
18023
|
+
if (isTable) {
|
|
18024
|
+
const originalElementList = this.draw.getOriginalElementList();
|
|
18025
|
+
const originTableElement = originalElementList[index2] || null;
|
|
18026
|
+
if (originTableElement) {
|
|
18027
|
+
tableElement = zipElementList([originTableElement])[0];
|
|
18028
|
+
}
|
|
18029
|
+
}
|
|
17453
18030
|
return deepClone({
|
|
17454
18031
|
isCollapsed,
|
|
17455
18032
|
startElement,
|
|
@@ -17458,7 +18035,10 @@ class CommandAdapt {
|
|
|
17458
18035
|
endPageNo,
|
|
17459
18036
|
rangeRects,
|
|
17460
18037
|
zone: zone2,
|
|
17461
|
-
isTable
|
|
18038
|
+
isTable,
|
|
18039
|
+
trIndex: trIndex != null ? trIndex : null,
|
|
18040
|
+
tdIndex: tdIndex != null ? tdIndex : null,
|
|
18041
|
+
tableElement
|
|
17462
18042
|
});
|
|
17463
18043
|
}
|
|
17464
18044
|
getRangeRow() {
|
|
@@ -17678,6 +18258,13 @@ class CommandAdapt {
|
|
|
17678
18258
|
setControlHighlight(payload) {
|
|
17679
18259
|
this.draw.getControl().setHighlightList(payload);
|
|
17680
18260
|
}
|
|
18261
|
+
updateOptions(payload) {
|
|
18262
|
+
const newOption = mergeOption(payload);
|
|
18263
|
+
Object.entries(newOption).forEach(([key, value]) => {
|
|
18264
|
+
Reflect.set(this.options, key, value);
|
|
18265
|
+
});
|
|
18266
|
+
this.forceUpdate();
|
|
18267
|
+
}
|
|
17681
18268
|
getControlList() {
|
|
17682
18269
|
return this.draw.getControl().getList();
|
|
17683
18270
|
}
|
|
@@ -18370,9 +18957,16 @@ class ContextMenu {
|
|
|
18370
18957
|
const { isCrossRowCol: crossRowCol, startIndex, endIndex } = this.range.getRange();
|
|
18371
18958
|
const editorTextFocus = !!(~startIndex || ~endIndex);
|
|
18372
18959
|
const editorHasSelection = editorTextFocus && startIndex !== endIndex;
|
|
18373
|
-
const
|
|
18374
|
-
|
|
18375
|
-
|
|
18960
|
+
const { isTable, trIndex, tdIndex, index: index2 } = this.position.getPositionContext();
|
|
18961
|
+
let tableElement = null;
|
|
18962
|
+
if (isTable) {
|
|
18963
|
+
const originalElementList = this.draw.getOriginalElementList();
|
|
18964
|
+
const originTableElement = originalElementList[index2] || null;
|
|
18965
|
+
if (originTableElement) {
|
|
18966
|
+
tableElement = zipElementList([originTableElement])[0];
|
|
18967
|
+
}
|
|
18968
|
+
}
|
|
18969
|
+
const isCrossRowCol = isTable && !!crossRowCol;
|
|
18376
18970
|
const elementList = this.draw.getElementList();
|
|
18377
18971
|
const startElement = elementList[startIndex] || null;
|
|
18378
18972
|
const endElement = elementList[endIndex] || null;
|
|
@@ -18383,9 +18977,12 @@ class ContextMenu {
|
|
|
18383
18977
|
isReadonly,
|
|
18384
18978
|
editorHasSelection,
|
|
18385
18979
|
editorTextFocus,
|
|
18386
|
-
isInTable,
|
|
18387
18980
|
isCrossRowCol,
|
|
18388
|
-
zone: zone2
|
|
18981
|
+
zone: zone2,
|
|
18982
|
+
isInTable: isTable,
|
|
18983
|
+
trIndex: trIndex != null ? trIndex : null,
|
|
18984
|
+
tdIndex: tdIndex != null ? tdIndex : null,
|
|
18985
|
+
tableElement
|
|
18389
18986
|
};
|
|
18390
18987
|
}
|
|
18391
18988
|
_createContextMenuContainer() {
|
|
@@ -18526,35 +19123,6 @@ class ContextMenu {
|
|
|
18526
19123
|
this.contextMenuRelationShip.clear();
|
|
18527
19124
|
}
|
|
18528
19125
|
}
|
|
18529
|
-
const defaultHeaderOption = {
|
|
18530
|
-
top: 30,
|
|
18531
|
-
maxHeightRadio: MaxHeightRatio.HALF,
|
|
18532
|
-
disabled: false
|
|
18533
|
-
};
|
|
18534
|
-
const defaultControlOption = {
|
|
18535
|
-
placeholderColor: "#9c9b9b",
|
|
18536
|
-
bracketColor: "#000000",
|
|
18537
|
-
prefix: "{",
|
|
18538
|
-
postfix: "}",
|
|
18539
|
-
borderWidth: 1,
|
|
18540
|
-
borderColor: "#000000"
|
|
18541
|
-
};
|
|
18542
|
-
const defaultCheckboxOption = {
|
|
18543
|
-
width: 14,
|
|
18544
|
-
height: 14,
|
|
18545
|
-
gap: 5,
|
|
18546
|
-
lineWidth: 1,
|
|
18547
|
-
fillStyle: "#5175f4",
|
|
18548
|
-
strokeStyle: "#ffffff"
|
|
18549
|
-
};
|
|
18550
|
-
const defaultRadioOption = {
|
|
18551
|
-
width: 14,
|
|
18552
|
-
height: 14,
|
|
18553
|
-
gap: 5,
|
|
18554
|
-
lineWidth: 1,
|
|
18555
|
-
fillStyle: "#5175f4",
|
|
18556
|
-
strokeStyle: "#000000"
|
|
18557
|
-
};
|
|
18558
19126
|
const richtextKeys = [
|
|
18559
19127
|
{
|
|
18560
19128
|
key: KeyMap.X_UPPERCASE,
|
|
@@ -18784,18 +19352,6 @@ class Shortcut {
|
|
|
18784
19352
|
}
|
|
18785
19353
|
}
|
|
18786
19354
|
}
|
|
18787
|
-
const defaultFooterOption = {
|
|
18788
|
-
bottom: 30,
|
|
18789
|
-
maxHeightRadio: MaxHeightRatio.HALF,
|
|
18790
|
-
disabled: false
|
|
18791
|
-
};
|
|
18792
|
-
const defaultPlaceholderOption = {
|
|
18793
|
-
data: "",
|
|
18794
|
-
color: "#DCDFE6",
|
|
18795
|
-
opacity: 1,
|
|
18796
|
-
size: 16,
|
|
18797
|
-
font: "Microsoft YaHei"
|
|
18798
|
-
};
|
|
18799
19355
|
class Plugin {
|
|
18800
19356
|
constructor(editor) {
|
|
18801
19357
|
__publicField(this, "editor");
|
|
@@ -18842,47 +19398,12 @@ class EventBus {
|
|
|
18842
19398
|
return !!eventSet && eventSet.size > 0;
|
|
18843
19399
|
}
|
|
18844
19400
|
}
|
|
18845
|
-
const defaultGroupOption = {
|
|
18846
|
-
opacity: 0.1,
|
|
18847
|
-
backgroundColor: "#E99D00",
|
|
18848
|
-
activeOpacity: 0.5,
|
|
18849
|
-
activeBackgroundColor: "#E99D00",
|
|
18850
|
-
disabled: false
|
|
18851
|
-
};
|
|
18852
19401
|
class Override {
|
|
18853
19402
|
constructor() {
|
|
18854
19403
|
__publicField(this, "paste");
|
|
18855
19404
|
__publicField(this, "copy");
|
|
18856
19405
|
}
|
|
18857
19406
|
}
|
|
18858
|
-
const defaultPageBreakOption = {
|
|
18859
|
-
font: "Microsoft YaHei",
|
|
18860
|
-
fontSize: 12,
|
|
18861
|
-
lineDash: [3, 1]
|
|
18862
|
-
};
|
|
18863
|
-
const defaultZoneOption = {
|
|
18864
|
-
tipDisabled: true
|
|
18865
|
-
};
|
|
18866
|
-
const defaultBackground = {
|
|
18867
|
-
color: "#FFFFFF",
|
|
18868
|
-
image: "",
|
|
18869
|
-
size: BackgroundSize.COVER,
|
|
18870
|
-
repeat: BackgroundRepeat.NO_REPEAT
|
|
18871
|
-
};
|
|
18872
|
-
const defaultLineBreak = {
|
|
18873
|
-
disabled: true,
|
|
18874
|
-
color: "#CCCCCC",
|
|
18875
|
-
lineWidth: 1.5
|
|
18876
|
-
};
|
|
18877
|
-
const defaultSeparatorOption = {
|
|
18878
|
-
lineWidth: 1,
|
|
18879
|
-
strokeStyle: "#000000"
|
|
18880
|
-
};
|
|
18881
|
-
const defaultTableOption = {
|
|
18882
|
-
tdPadding: [0, 5, 5, 5],
|
|
18883
|
-
defaultTrMinHeight: 42,
|
|
18884
|
-
defaultColMinWidth: 40
|
|
18885
|
-
};
|
|
18886
19407
|
class Editor {
|
|
18887
19408
|
constructor(container, data2, options = {}) {
|
|
18888
19409
|
__publicField(this, "command");
|
|
@@ -18892,82 +19413,7 @@ class Editor {
|
|
|
18892
19413
|
__publicField(this, "register");
|
|
18893
19414
|
__publicField(this, "destroy");
|
|
18894
19415
|
__publicField(this, "use");
|
|
18895
|
-
const
|
|
18896
|
-
const headerOptions = __spreadValues(__spreadValues({}, defaultHeaderOption), options.header);
|
|
18897
|
-
const footerOptions = __spreadValues(__spreadValues({}, defaultFooterOption), options.footer);
|
|
18898
|
-
const pageNumberOptions = __spreadValues(__spreadValues({}, defaultPageNumberOption), options.pageNumber);
|
|
18899
|
-
const waterMarkOptions = __spreadValues(__spreadValues({}, defaultWatermarkOption), options.watermark);
|
|
18900
|
-
const controlOptions = __spreadValues(__spreadValues({}, defaultControlOption), options.control);
|
|
18901
|
-
const checkboxOptions = __spreadValues(__spreadValues({}, defaultCheckboxOption), options.checkbox);
|
|
18902
|
-
const radioOptions = __spreadValues(__spreadValues({}, defaultRadioOption), options.radio);
|
|
18903
|
-
const cursorOptions = __spreadValues(__spreadValues({}, defaultCursorOption), options.cursor);
|
|
18904
|
-
const titleOptions = __spreadValues(__spreadValues({}, defaultTitleOption), options.title);
|
|
18905
|
-
const placeholderOptions = __spreadValues(__spreadValues({}, defaultPlaceholderOption), options.placeholder);
|
|
18906
|
-
const groupOptions = __spreadValues(__spreadValues({}, defaultGroupOption), options.group);
|
|
18907
|
-
const pageBreakOptions = __spreadValues(__spreadValues({}, defaultPageBreakOption), options.pageBreak);
|
|
18908
|
-
const zoneOptions = __spreadValues(__spreadValues({}, defaultZoneOption), options.zone);
|
|
18909
|
-
const backgroundOptions = __spreadValues(__spreadValues({}, defaultBackground), options.background);
|
|
18910
|
-
const lineBreakOptions = __spreadValues(__spreadValues({}, defaultLineBreak), options.lineBreak);
|
|
18911
|
-
const separatorOptions = __spreadValues(__spreadValues({}, defaultSeparatorOption), options.separator);
|
|
18912
|
-
const editorOptions = __spreadProps(__spreadValues({
|
|
18913
|
-
mode: EditorMode.EDIT,
|
|
18914
|
-
defaultType: "TEXT",
|
|
18915
|
-
defaultColor: "#000000",
|
|
18916
|
-
defaultFont: "Microsoft YaHei",
|
|
18917
|
-
defaultSize: 16,
|
|
18918
|
-
minSize: 5,
|
|
18919
|
-
maxSize: 72,
|
|
18920
|
-
defaultRowMargin: 1,
|
|
18921
|
-
defaultBasicRowMarginHeight: 8,
|
|
18922
|
-
defaultTabWidth: 32,
|
|
18923
|
-
width: 794,
|
|
18924
|
-
height: 1123,
|
|
18925
|
-
scale: 1,
|
|
18926
|
-
pageGap: 20,
|
|
18927
|
-
underlineColor: "#000000",
|
|
18928
|
-
strikeoutColor: "#FF0000",
|
|
18929
|
-
rangeAlpha: 0.6,
|
|
18930
|
-
rangeColor: "#AECBFA",
|
|
18931
|
-
rangeMinWidth: 5,
|
|
18932
|
-
searchMatchAlpha: 0.6,
|
|
18933
|
-
searchMatchColor: "#FFFF00",
|
|
18934
|
-
searchNavigateMatchColor: "#AAD280",
|
|
18935
|
-
highlightAlpha: 0.6,
|
|
18936
|
-
resizerColor: "#4182D9",
|
|
18937
|
-
resizerSize: 5,
|
|
18938
|
-
marginIndicatorSize: 35,
|
|
18939
|
-
marginIndicatorColor: "#BABABA",
|
|
18940
|
-
margins: [100, 120, 100, 120],
|
|
18941
|
-
pageMode: PageMode.PAGING,
|
|
18942
|
-
defaultHyperlinkColor: "#0000FF",
|
|
18943
|
-
paperDirection: PaperDirection.VERTICAL,
|
|
18944
|
-
inactiveAlpha: 0.6,
|
|
18945
|
-
historyMaxRecordCount: 100,
|
|
18946
|
-
wordBreak: WordBreak.BREAK_WORD,
|
|
18947
|
-
printPixelRatio: 3,
|
|
18948
|
-
maskMargin: [0, 0, 0, 0],
|
|
18949
|
-
letterClass: [LETTER_CLASS.ENGLISH],
|
|
18950
|
-
contextMenuDisableKeys: [],
|
|
18951
|
-
scrollContainerSelector: ""
|
|
18952
|
-
}, options), {
|
|
18953
|
-
table: tableOptions,
|
|
18954
|
-
header: headerOptions,
|
|
18955
|
-
footer: footerOptions,
|
|
18956
|
-
pageNumber: pageNumberOptions,
|
|
18957
|
-
watermark: waterMarkOptions,
|
|
18958
|
-
control: controlOptions,
|
|
18959
|
-
checkbox: checkboxOptions,
|
|
18960
|
-
radio: radioOptions,
|
|
18961
|
-
cursor: cursorOptions,
|
|
18962
|
-
title: titleOptions,
|
|
18963
|
-
placeholder: placeholderOptions,
|
|
18964
|
-
group: groupOptions,
|
|
18965
|
-
pageBreak: pageBreakOptions,
|
|
18966
|
-
zone: zoneOptions,
|
|
18967
|
-
background: backgroundOptions,
|
|
18968
|
-
lineBreak: lineBreakOptions,
|
|
18969
|
-
separator: separatorOptions
|
|
18970
|
-
});
|
|
19416
|
+
const editorOptions = mergeOption(options);
|
|
18971
19417
|
data2 = deepClone(data2);
|
|
18972
19418
|
let headerElementList = [];
|
|
18973
19419
|
let mainElementList = [];
|