@hufe921/canvas-editor 0.9.73 → 0.9.75
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 +48 -0
- package/dist/canvas-editor.es.js +229 -59
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +34 -34
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/draw/Draw.d.ts +4 -0
- package/dist/src/editor/core/draw/control/Control.d.ts +3 -0
- package/dist/src/editor/core/draw/control/richtext/Border.d.ts +10 -0
- package/dist/src/editor/core/draw/particle/LineBreakParticle.d.ts +10 -0
- package/dist/src/editor/core/draw/particle/block/modules/IFrameBlock.d.ts +1 -0
- package/dist/src/editor/core/history/HistoryManager.d.ts +1 -0
- package/dist/src/editor/dataset/constant/Element.d.ts +2 -0
- package/dist/src/editor/dataset/constant/LineBreak.d.ts +2 -0
- package/dist/src/editor/interface/Block.d.ts +2 -1
- package/dist/src/editor/interface/Control.d.ts +12 -1
- package/dist/src/editor/interface/Draw.d.ts +2 -0
- package/dist/src/editor/interface/Editor.d.ts +2 -0
- package/dist/src/editor/interface/Element.d.ts +1 -0
- package/dist/src/editor/interface/LineBreak.d.ts +5 -0
- package/dist/src/editor/interface/Listener.d.ts +1 -0
- package/dist/src/editor/interface/Row.d.ts +1 -0
- package/package.json +1 -1
package/dist/canvas-editor.es.js
CHANGED
|
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23
23
|
return value;
|
|
24
24
|
};
|
|
25
25
|
var index = "";
|
|
26
|
-
const version = "0.9.
|
|
26
|
+
const version = "0.9.75";
|
|
27
27
|
var MaxHeightRatio;
|
|
28
28
|
(function(MaxHeightRatio2) {
|
|
29
29
|
MaxHeightRatio2["HALF"] = "half";
|
|
@@ -455,7 +455,8 @@ const EDITOR_ELEMENT_ZIP_ATTR = [
|
|
|
455
455
|
"conceptId",
|
|
456
456
|
"imgDisplay",
|
|
457
457
|
"imgFloatPosition",
|
|
458
|
-
"textDecoration"
|
|
458
|
+
"textDecoration",
|
|
459
|
+
"extension"
|
|
459
460
|
];
|
|
460
461
|
const TABLE_TD_ZIP_ATTR = [
|
|
461
462
|
"verticalAlign",
|
|
@@ -479,6 +480,14 @@ const CONTROL_CONTEXT_ATTR = [
|
|
|
479
480
|
"controlId",
|
|
480
481
|
"controlComponent"
|
|
481
482
|
];
|
|
483
|
+
const CONTROL_STYLE_ATTR = [
|
|
484
|
+
"font",
|
|
485
|
+
"size",
|
|
486
|
+
"bold",
|
|
487
|
+
"highlight",
|
|
488
|
+
"italic",
|
|
489
|
+
"strikeout"
|
|
490
|
+
];
|
|
482
491
|
const EDITOR_ELEMENT_CONTEXT_ATTR = [
|
|
483
492
|
...TABLE_CONTEXT_ATTR,
|
|
484
493
|
...TITLE_CONTEXT_ATTR,
|
|
@@ -3857,20 +3866,21 @@ function formatElementList(elementList, options) {
|
|
|
3857
3866
|
const { editorOptions: { control: controlOption, checkbox: checkboxOption } } = options;
|
|
3858
3867
|
const controlId = getUUID();
|
|
3859
3868
|
elementList.splice(i, 1);
|
|
3860
|
-
const
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3869
|
+
const controlContext = pickObject(el, EDITOR_ELEMENT_CONTEXT_ATTR);
|
|
3870
|
+
const controlDefaultStyle = pickObject(el.control, CONTROL_STYLE_ATTR);
|
|
3871
|
+
const thePrePostfixArg = __spreadProps(__spreadValues({}, controlDefaultStyle), {
|
|
3872
|
+
color: editorOptions.control.bracketColor
|
|
3873
|
+
});
|
|
3864
3874
|
const prefixStrList = splitText(prefix || controlOption.prefix);
|
|
3865
3875
|
for (let p = 0; p < prefixStrList.length; p++) {
|
|
3866
3876
|
const value2 = prefixStrList[p];
|
|
3867
|
-
elementList.splice(i, 0, __spreadValues({
|
|
3877
|
+
elementList.splice(i, 0, __spreadProps(__spreadValues(__spreadValues({}, controlContext), thePrePostfixArg), {
|
|
3868
3878
|
controlId,
|
|
3869
3879
|
value: value2,
|
|
3870
3880
|
type: el.type,
|
|
3871
3881
|
control: el.control,
|
|
3872
3882
|
controlComponent: ControlComponent.PREFIX
|
|
3873
|
-
}
|
|
3883
|
+
}));
|
|
3874
3884
|
i++;
|
|
3875
3885
|
}
|
|
3876
3886
|
if (value && value.length || type === ControlType.CHECKBOX || type === ControlType.SELECT && code && (!value || !value.length)) {
|
|
@@ -3882,7 +3892,7 @@ function formatElementList(elementList, options) {
|
|
|
3882
3892
|
let valueStyleIndex = 0;
|
|
3883
3893
|
for (let v = 0; v < valueSets.length; v++) {
|
|
3884
3894
|
const valueSet = valueSets[v];
|
|
3885
|
-
elementList.splice(i, 0, {
|
|
3895
|
+
elementList.splice(i, 0, __spreadProps(__spreadValues({}, controlContext), {
|
|
3886
3896
|
controlId,
|
|
3887
3897
|
value: "",
|
|
3888
3898
|
type: el.type,
|
|
@@ -3892,13 +3902,13 @@ function formatElementList(elementList, options) {
|
|
|
3892
3902
|
code: valueSet.code,
|
|
3893
3903
|
value: codeList.includes(valueSet.code)
|
|
3894
3904
|
}
|
|
3895
|
-
});
|
|
3905
|
+
}));
|
|
3896
3906
|
i++;
|
|
3897
3907
|
const valueStrList = splitText(valueSet.value);
|
|
3898
3908
|
for (let e = 0; e < valueStrList.length; e++) {
|
|
3899
3909
|
const value2 = valueStrList[e];
|
|
3900
3910
|
const isLastLetter = e === valueStrList.length - 1;
|
|
3901
|
-
elementList.splice(i, 0, __spreadProps(__spreadValues({}, valueStyleList[valueStyleIndex]), {
|
|
3911
|
+
elementList.splice(i, 0, __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, controlContext), controlDefaultStyle), valueStyleList[valueStyleIndex]), {
|
|
3902
3912
|
controlId,
|
|
3903
3913
|
value: value2 === "\n" ? ZERO : value2,
|
|
3904
3914
|
letterSpacing: isLastLetter ? checkboxOption.gap : 0,
|
|
@@ -3929,7 +3939,7 @@ function formatElementList(elementList, options) {
|
|
|
3929
3939
|
for (let v = 0; v < valueList.length; v++) {
|
|
3930
3940
|
const element = valueList[v];
|
|
3931
3941
|
const value2 = element.value;
|
|
3932
|
-
elementList.splice(i, 0, __spreadProps(__spreadValues({}, element), {
|
|
3942
|
+
elementList.splice(i, 0, __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, controlContext), controlDefaultStyle), element), {
|
|
3933
3943
|
controlId,
|
|
3934
3944
|
value: value2 === "\n" ? ZERO : value2,
|
|
3935
3945
|
type: element.type || ElementType.TEXT,
|
|
@@ -3940,33 +3950,32 @@ function formatElementList(elementList, options) {
|
|
|
3940
3950
|
}
|
|
3941
3951
|
}
|
|
3942
3952
|
} else if (placeholder) {
|
|
3943
|
-
const thePlaceholderArgs = {}
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
}
|
|
3953
|
+
const thePlaceholderArgs = __spreadProps(__spreadValues({}, controlDefaultStyle), {
|
|
3954
|
+
color: editorOptions.control.placeholderColor
|
|
3955
|
+
});
|
|
3947
3956
|
const placeholderStrList = splitText(placeholder);
|
|
3948
3957
|
for (let p = 0; p < placeholderStrList.length; p++) {
|
|
3949
3958
|
const value2 = placeholderStrList[p];
|
|
3950
|
-
elementList.splice(i, 0, __spreadValues({
|
|
3959
|
+
elementList.splice(i, 0, __spreadProps(__spreadValues(__spreadValues({}, controlContext), thePlaceholderArgs), {
|
|
3951
3960
|
controlId,
|
|
3952
3961
|
value: value2 === "\n" ? ZERO : value2,
|
|
3953
3962
|
type: el.type,
|
|
3954
3963
|
control: el.control,
|
|
3955
3964
|
controlComponent: ControlComponent.PLACEHOLDER
|
|
3956
|
-
}
|
|
3965
|
+
}));
|
|
3957
3966
|
i++;
|
|
3958
3967
|
}
|
|
3959
3968
|
}
|
|
3960
3969
|
const postfixStrList = splitText(postfix || controlOption.postfix);
|
|
3961
3970
|
for (let p = 0; p < postfixStrList.length; p++) {
|
|
3962
3971
|
const value2 = postfixStrList[p];
|
|
3963
|
-
elementList.splice(i, 0, __spreadValues({
|
|
3972
|
+
elementList.splice(i, 0, __spreadProps(__spreadValues(__spreadValues({}, controlContext), thePrePostfixArg), {
|
|
3964
3973
|
controlId,
|
|
3965
3974
|
value: value2,
|
|
3966
3975
|
type: el.type,
|
|
3967
3976
|
control: el.control,
|
|
3968
3977
|
controlComponent: ControlComponent.POSTFIX
|
|
3969
|
-
}
|
|
3978
|
+
}));
|
|
3970
3979
|
i++;
|
|
3971
3980
|
}
|
|
3972
3981
|
i--;
|
|
@@ -4172,7 +4181,8 @@ function zipElementList(payload) {
|
|
|
4172
4181
|
} else if (element.controlId) {
|
|
4173
4182
|
const controlId = element.controlId;
|
|
4174
4183
|
if (controlId) {
|
|
4175
|
-
const
|
|
4184
|
+
const controlDefaultStyle = pickObject(element, CONTROL_STYLE_ATTR);
|
|
4185
|
+
const control = __spreadValues(__spreadValues({}, element.control), controlDefaultStyle);
|
|
4176
4186
|
const controlElement = {
|
|
4177
4187
|
type: ElementType.CONTROL,
|
|
4178
4188
|
value: "",
|
|
@@ -5724,6 +5734,12 @@ function mousemove(evt, host) {
|
|
|
5724
5734
|
}
|
|
5725
5735
|
if (start === end)
|
|
5726
5736
|
return;
|
|
5737
|
+
const elementList = draw.getElementList();
|
|
5738
|
+
const startElement = elementList[start + 1];
|
|
5739
|
+
const endElement = elementList[end];
|
|
5740
|
+
if ((startElement == null ? void 0 : startElement.controlComponent) === ControlComponent.PLACEHOLDER && (endElement == null ? void 0 : endElement.controlComponent) === ControlComponent.PLACEHOLDER && startElement.controlId === endElement.controlId) {
|
|
5741
|
+
return;
|
|
5742
|
+
}
|
|
5727
5743
|
rangeManager.setRange(start, end);
|
|
5728
5744
|
}
|
|
5729
5745
|
draw.render({
|
|
@@ -6723,7 +6739,7 @@ function getWordRangeBySegmenter(host) {
|
|
|
6723
6739
|
const paragraphInfo = rangeManager.getRangeParagraphInfo();
|
|
6724
6740
|
if (!paragraphInfo)
|
|
6725
6741
|
return null;
|
|
6726
|
-
const paragraphText = ((_a = paragraphInfo == null ? void 0 : paragraphInfo.elementList) == null ? void 0 : _a.map((e) => !e.type ||
|
|
6742
|
+
const paragraphText = ((_a = paragraphInfo == null ? void 0 : paragraphInfo.elementList) == null ? void 0 : _a.map((e) => !e.type || e.type !== ElementType.CONTROL && TEXTLIKE_ELEMENT_TYPE.includes(e.type) ? e.value : ZERO).join("")) || "";
|
|
6727
6743
|
if (!paragraphText)
|
|
6728
6744
|
return null;
|
|
6729
6745
|
const cursorStartIndex = cursorPosition.index;
|
|
@@ -7239,6 +7255,9 @@ class HistoryManager {
|
|
|
7239
7255
|
isCanRedo() {
|
|
7240
7256
|
return !!this.redoStack.length;
|
|
7241
7257
|
}
|
|
7258
|
+
isStackEmpty() {
|
|
7259
|
+
return !this.undoStack.length && !this.redoStack.length;
|
|
7260
|
+
}
|
|
7242
7261
|
recovery() {
|
|
7243
7262
|
this.undoStack = [];
|
|
7244
7263
|
this.redoStack = [];
|
|
@@ -7311,10 +7330,11 @@ class Position {
|
|
|
7311
7330
|
let index2 = startIndex;
|
|
7312
7331
|
for (let i = 0; i < rowList.length; i++) {
|
|
7313
7332
|
const curRow = rowList[i];
|
|
7333
|
+
const curRowWidth = curRow.width + (curRow.offsetX || 0);
|
|
7314
7334
|
if (curRow.rowFlex === RowFlex.CENTER) {
|
|
7315
|
-
x += (innerWidth -
|
|
7335
|
+
x += (innerWidth - curRowWidth) / 2;
|
|
7316
7336
|
} else if (curRow.rowFlex === RowFlex.RIGHT) {
|
|
7317
|
-
x += innerWidth -
|
|
7337
|
+
x += innerWidth - curRowWidth;
|
|
7318
7338
|
}
|
|
7319
7339
|
x += curRow.offsetX || 0;
|
|
7320
7340
|
const tablePreX = x;
|
|
@@ -8020,6 +8040,7 @@ class RangeManager {
|
|
|
8020
8040
|
this.setRange(range.startIndex, range.endIndex, range.tableId, range.startTdIndex, range.endTdIndex, range.startTrIndex, range.endTrIndex);
|
|
8021
8041
|
}
|
|
8022
8042
|
setRangeStyle() {
|
|
8043
|
+
var _a;
|
|
8023
8044
|
const rangeStyleChangeListener = this.listener.rangeStyleChange;
|
|
8024
8045
|
const isSubscribeRangeStyleChange = this.eventBus.isSubscribe("rangeStyleChange");
|
|
8025
8046
|
if (!rangeStyleChangeListener && !isSubscribeRangeStyleChange)
|
|
@@ -8046,8 +8067,8 @@ class RangeManager {
|
|
|
8046
8067
|
const bold = !~curElementList.findIndex((el) => !el.bold);
|
|
8047
8068
|
const italic = !~curElementList.findIndex((el) => !el.italic);
|
|
8048
8069
|
const underline = !~curElementList.findIndex((el) => {
|
|
8049
|
-
var
|
|
8050
|
-
return !el.underline && !((
|
|
8070
|
+
var _a2;
|
|
8071
|
+
return !el.underline && !((_a2 = el.control) == null ? void 0 : _a2.underline);
|
|
8051
8072
|
});
|
|
8052
8073
|
const strikeout = !~curElementList.findIndex((el) => !el.strikeout);
|
|
8053
8074
|
const color = curElement.color || null;
|
|
@@ -8063,6 +8084,7 @@ class RangeManager {
|
|
|
8063
8084
|
const undo = this.historyManager.isCanUndo();
|
|
8064
8085
|
const redo = this.historyManager.isCanRedo();
|
|
8065
8086
|
const groupIds = curElement.groupIds || null;
|
|
8087
|
+
const extension = (_a = curElement.extension) != null ? _a : null;
|
|
8066
8088
|
const rangeStyle = {
|
|
8067
8089
|
type,
|
|
8068
8090
|
undo,
|
|
@@ -8083,7 +8105,8 @@ class RangeManager {
|
|
|
8083
8105
|
listType,
|
|
8084
8106
|
listStyle,
|
|
8085
8107
|
groupIds,
|
|
8086
|
-
textDecoration
|
|
8108
|
+
textDecoration,
|
|
8109
|
+
extension
|
|
8087
8110
|
};
|
|
8088
8111
|
if (rangeStyleChangeListener) {
|
|
8089
8112
|
rangeStyleChangeListener(rangeStyle);
|
|
@@ -8123,7 +8146,8 @@ class RangeManager {
|
|
|
8123
8146
|
listType: null,
|
|
8124
8147
|
listStyle: null,
|
|
8125
8148
|
groupIds: null,
|
|
8126
|
-
textDecoration: null
|
|
8149
|
+
textDecoration: null,
|
|
8150
|
+
extension: null
|
|
8127
8151
|
};
|
|
8128
8152
|
if (rangeStyleChangeListener) {
|
|
8129
8153
|
rangeStyleChangeListener(rangeStyle);
|
|
@@ -8553,7 +8577,7 @@ class Search {
|
|
|
8553
8577
|
let index2 = text.indexOf(payload2);
|
|
8554
8578
|
while (index2 !== -1) {
|
|
8555
8579
|
matchStartIndexList.push(index2);
|
|
8556
|
-
index2 = text.indexOf(payload2, index2 +
|
|
8580
|
+
index2 = text.indexOf(payload2, index2 + payload2.length);
|
|
8557
8581
|
}
|
|
8558
8582
|
for (let m = 0; m < matchStartIndexList.length; m++) {
|
|
8559
8583
|
const startIndex = matchStartIndexList[m];
|
|
@@ -10085,6 +10109,47 @@ class ControlSearch {
|
|
|
10085
10109
|
ctx.restore();
|
|
10086
10110
|
}
|
|
10087
10111
|
}
|
|
10112
|
+
class ControlBorder {
|
|
10113
|
+
constructor(draw) {
|
|
10114
|
+
__publicField(this, "borderRect");
|
|
10115
|
+
__publicField(this, "options");
|
|
10116
|
+
this.borderRect = this.clearBorderInfo();
|
|
10117
|
+
this.options = draw.getOptions();
|
|
10118
|
+
}
|
|
10119
|
+
clearBorderInfo() {
|
|
10120
|
+
this.borderRect = {
|
|
10121
|
+
x: 0,
|
|
10122
|
+
y: 0,
|
|
10123
|
+
width: 0,
|
|
10124
|
+
height: 0
|
|
10125
|
+
};
|
|
10126
|
+
return this.borderRect;
|
|
10127
|
+
}
|
|
10128
|
+
recordBorderInfo(x, y, width, height) {
|
|
10129
|
+
const isFirstRecord = !this.borderRect.width;
|
|
10130
|
+
if (isFirstRecord) {
|
|
10131
|
+
this.borderRect.x = x;
|
|
10132
|
+
this.borderRect.y = y;
|
|
10133
|
+
this.borderRect.height = height;
|
|
10134
|
+
}
|
|
10135
|
+
this.borderRect.width += width;
|
|
10136
|
+
}
|
|
10137
|
+
render(ctx) {
|
|
10138
|
+
if (!this.borderRect.width)
|
|
10139
|
+
return;
|
|
10140
|
+
const { scale, control: { borderWidth, borderColor } } = this.options;
|
|
10141
|
+
const { x, y, width, height } = this.borderRect;
|
|
10142
|
+
ctx.save();
|
|
10143
|
+
ctx.translate(0, 1 * scale);
|
|
10144
|
+
ctx.lineWidth = borderWidth * scale;
|
|
10145
|
+
ctx.strokeStyle = borderColor;
|
|
10146
|
+
ctx.beginPath();
|
|
10147
|
+
ctx.rect(x, y, width, height);
|
|
10148
|
+
ctx.stroke();
|
|
10149
|
+
ctx.restore();
|
|
10150
|
+
this.clearBorderInfo();
|
|
10151
|
+
}
|
|
10152
|
+
}
|
|
10088
10153
|
class SelectControl {
|
|
10089
10154
|
constructor(element, control) {
|
|
10090
10155
|
__publicField(this, "element");
|
|
@@ -10227,7 +10292,9 @@ class SelectControl {
|
|
|
10227
10292
|
if (!valueSet)
|
|
10228
10293
|
return;
|
|
10229
10294
|
const elementList = context.elementList || this.control.getElementList();
|
|
10230
|
-
const
|
|
10295
|
+
const range = context.range || this.control.getRange();
|
|
10296
|
+
const valueElement = this.getValue(context)[0];
|
|
10297
|
+
const styleElement = valueElement ? pickObject(valueElement, EDITOR_ELEMENT_STYLE_ATTR) : pickObject(elementList[range.startIndex], CONTROL_STYLE_ATTR);
|
|
10231
10298
|
const prefixIndex = this.clearSelect(context);
|
|
10232
10299
|
if (!~prefixIndex)
|
|
10233
10300
|
return;
|
|
@@ -10360,7 +10427,11 @@ class TextControl {
|
|
|
10360
10427
|
this.control.removePlaceholder(startIndex, context);
|
|
10361
10428
|
}
|
|
10362
10429
|
const startElement = elementList[startIndex];
|
|
10363
|
-
const anchorElement = startElement.type && !TEXTLIKE_ELEMENT_TYPE.includes(startElement.type) || startElement.controlComponent === ControlComponent.PREFIX ? pickObject(startElement, [
|
|
10430
|
+
const anchorElement = startElement.type && !TEXTLIKE_ELEMENT_TYPE.includes(startElement.type) || startElement.controlComponent === ControlComponent.PREFIX ? pickObject(startElement, [
|
|
10431
|
+
"control",
|
|
10432
|
+
"controlId",
|
|
10433
|
+
...CONTROL_STYLE_ATTR
|
|
10434
|
+
]) : omitObject(startElement, ["type"]);
|
|
10364
10435
|
const start = range.startIndex + 1;
|
|
10365
10436
|
for (let i = 0; i < data2.length; i++) {
|
|
10366
10437
|
const newElement = __spreadProps(__spreadValues(__spreadValues({}, anchorElement), data2[i]), {
|
|
@@ -10461,6 +10532,7 @@ class TextControl {
|
|
|
10461
10532
|
}
|
|
10462
10533
|
class Control {
|
|
10463
10534
|
constructor(draw) {
|
|
10535
|
+
__publicField(this, "controlBorder");
|
|
10464
10536
|
__publicField(this, "draw");
|
|
10465
10537
|
__publicField(this, "range");
|
|
10466
10538
|
__publicField(this, "listener");
|
|
@@ -10469,6 +10541,7 @@ class Control {
|
|
|
10469
10541
|
__publicField(this, "options");
|
|
10470
10542
|
__publicField(this, "controlOptions");
|
|
10471
10543
|
__publicField(this, "activeControl");
|
|
10544
|
+
this.controlBorder = new ControlBorder(draw);
|
|
10472
10545
|
this.draw = draw;
|
|
10473
10546
|
this.range = draw.getRange();
|
|
10474
10547
|
this.listener = draw.getListener();
|
|
@@ -11091,6 +11164,12 @@ class Control {
|
|
|
11091
11164
|
}
|
|
11092
11165
|
return zipElementList(controlElementList);
|
|
11093
11166
|
}
|
|
11167
|
+
recordBorderInfo(x, y, width, height) {
|
|
11168
|
+
this.controlBorder.recordBorderInfo(x, y, width, height);
|
|
11169
|
+
}
|
|
11170
|
+
drawBorder(ctx) {
|
|
11171
|
+
this.controlBorder.render(ctx);
|
|
11172
|
+
}
|
|
11094
11173
|
}
|
|
11095
11174
|
class CheckboxParticle {
|
|
11096
11175
|
constructor(draw) {
|
|
@@ -12229,25 +12308,36 @@ const _IFrameBlock = class {
|
|
|
12229
12308
|
__publicField(this, "element");
|
|
12230
12309
|
this.element = element;
|
|
12231
12310
|
}
|
|
12311
|
+
_defineIframeProperties(iframeWindow) {
|
|
12312
|
+
Object.defineProperties(iframeWindow, {
|
|
12313
|
+
parent: {
|
|
12314
|
+
get: () => null
|
|
12315
|
+
},
|
|
12316
|
+
__POWERED_BY_CANVAS_EDITOR__: {
|
|
12317
|
+
get: () => true
|
|
12318
|
+
}
|
|
12319
|
+
});
|
|
12320
|
+
}
|
|
12232
12321
|
render(blockItemContainer) {
|
|
12233
|
-
var _a;
|
|
12322
|
+
var _a, _b;
|
|
12234
12323
|
const block = this.element.block;
|
|
12235
12324
|
const iframe = document.createElement("iframe");
|
|
12325
|
+
iframe.setAttribute("data-id", this.element.id);
|
|
12236
12326
|
iframe.sandbox.add(..._IFrameBlock.sandbox);
|
|
12237
12327
|
iframe.style.border = "none";
|
|
12238
12328
|
iframe.style.width = "100%";
|
|
12239
12329
|
iframe.style.height = "100%";
|
|
12240
|
-
|
|
12330
|
+
if ((_a = block.iframeBlock) == null ? void 0 : _a.src) {
|
|
12331
|
+
iframe.src = block.iframeBlock.src;
|
|
12332
|
+
} else if ((_b = block.iframeBlock) == null ? void 0 : _b.srcdoc) {
|
|
12333
|
+
iframe.srcdoc = block.iframeBlock.srcdoc;
|
|
12334
|
+
}
|
|
12241
12335
|
blockItemContainer.append(iframe);
|
|
12336
|
+
this._defineIframeProperties(iframe.contentWindow);
|
|
12242
12337
|
}
|
|
12243
12338
|
};
|
|
12244
12339
|
let IFrameBlock = _IFrameBlock;
|
|
12245
|
-
__publicField(IFrameBlock, "sandbox", [
|
|
12246
|
-
"allow-forms",
|
|
12247
|
-
"allow-scripts",
|
|
12248
|
-
"allow-same-origin",
|
|
12249
|
-
"allow-popups"
|
|
12250
|
-
]);
|
|
12340
|
+
__publicField(IFrameBlock, "sandbox", ["allow-scripts", "allow-same-origin"]);
|
|
12251
12341
|
class VideoBlock {
|
|
12252
12342
|
constructor(element) {
|
|
12253
12343
|
__publicField(this, "element");
|
|
@@ -13001,6 +13091,41 @@ class ListParticle {
|
|
|
13001
13091
|
}
|
|
13002
13092
|
}
|
|
13003
13093
|
}
|
|
13094
|
+
const _LineBreakParticle = class {
|
|
13095
|
+
constructor(draw) {
|
|
13096
|
+
__publicField(this, "options");
|
|
13097
|
+
this.options = draw.getOptions();
|
|
13098
|
+
}
|
|
13099
|
+
render(ctx, element, x, y) {
|
|
13100
|
+
const { scale, lineBreak: { color, lineWidth } } = this.options;
|
|
13101
|
+
ctx.save();
|
|
13102
|
+
ctx.beginPath();
|
|
13103
|
+
const top = y - _LineBreakParticle.HEIGHT * scale / 2;
|
|
13104
|
+
const left2 = x + element.metrics.width;
|
|
13105
|
+
ctx.translate(left2, top);
|
|
13106
|
+
ctx.scale(scale, scale);
|
|
13107
|
+
ctx.strokeStyle = color;
|
|
13108
|
+
ctx.lineWidth = lineWidth;
|
|
13109
|
+
ctx.lineCap = "round";
|
|
13110
|
+
ctx.lineJoin = "round";
|
|
13111
|
+
ctx.beginPath();
|
|
13112
|
+
ctx.moveTo(8, 0);
|
|
13113
|
+
ctx.lineTo(12, 0);
|
|
13114
|
+
ctx.lineTo(12, 6);
|
|
13115
|
+
ctx.lineTo(3, 6);
|
|
13116
|
+
ctx.moveTo(3, 6);
|
|
13117
|
+
ctx.lineTo(6, 3);
|
|
13118
|
+
ctx.moveTo(3, 6);
|
|
13119
|
+
ctx.lineTo(6, 9);
|
|
13120
|
+
ctx.stroke();
|
|
13121
|
+
ctx.closePath();
|
|
13122
|
+
ctx.restore();
|
|
13123
|
+
}
|
|
13124
|
+
};
|
|
13125
|
+
let LineBreakParticle = _LineBreakParticle;
|
|
13126
|
+
__publicField(LineBreakParticle, "WIDTH", 12);
|
|
13127
|
+
__publicField(LineBreakParticle, "HEIGHT", 9);
|
|
13128
|
+
__publicField(LineBreakParticle, "GAP", 3);
|
|
13004
13129
|
class Placeholder {
|
|
13005
13130
|
constructor(draw) {
|
|
13006
13131
|
__publicField(this, "draw");
|
|
@@ -13033,10 +13158,14 @@ class Placeholder {
|
|
|
13033
13158
|
});
|
|
13034
13159
|
}
|
|
13035
13160
|
_computePositionList() {
|
|
13161
|
+
const { lineBreak, scale } = this.options;
|
|
13036
13162
|
const headerExtraHeight = this.draw.getHeader().getExtraHeight();
|
|
13037
13163
|
const innerWidth = this.draw.getInnerWidth();
|
|
13038
13164
|
const margins = this.draw.getMargins();
|
|
13039
|
-
|
|
13165
|
+
let startX = margins[3];
|
|
13166
|
+
if (!lineBreak.disabled) {
|
|
13167
|
+
startX += (LineBreakParticle.WIDTH + LineBreakParticle.GAP) * scale;
|
|
13168
|
+
}
|
|
13040
13169
|
const startY = margins[0] + headerExtraHeight;
|
|
13041
13170
|
this.position.computePageRowPosition({
|
|
13042
13171
|
positionList: this.positionList,
|
|
@@ -13075,7 +13204,8 @@ class Placeholder {
|
|
|
13075
13204
|
rowList: this.rowList,
|
|
13076
13205
|
pageNo: 0,
|
|
13077
13206
|
startIndex: 0,
|
|
13078
|
-
innerWidth
|
|
13207
|
+
innerWidth,
|
|
13208
|
+
isDrawLineBreak: false
|
|
13079
13209
|
});
|
|
13080
13210
|
ctx.restore();
|
|
13081
13211
|
}
|
|
@@ -13290,6 +13420,7 @@ class Draw {
|
|
|
13290
13420
|
__publicField(this, "checkboxParticle");
|
|
13291
13421
|
__publicField(this, "blockParticle");
|
|
13292
13422
|
__publicField(this, "listParticle");
|
|
13423
|
+
__publicField(this, "lineBreakParticle");
|
|
13293
13424
|
__publicField(this, "control");
|
|
13294
13425
|
__publicField(this, "workerManager");
|
|
13295
13426
|
__publicField(this, "scrollObserver");
|
|
@@ -13351,6 +13482,7 @@ class Draw {
|
|
|
13351
13482
|
this.checkboxParticle = new CheckboxParticle(this);
|
|
13352
13483
|
this.blockParticle = new BlockParticle(this);
|
|
13353
13484
|
this.listParticle = new ListParticle(this);
|
|
13485
|
+
this.lineBreakParticle = new LineBreakParticle(this);
|
|
13354
13486
|
this.control = new Control(this);
|
|
13355
13487
|
this.scrollObserver = new ScrollObserver(this);
|
|
13356
13488
|
this.selectionObserver = new SelectionObserver(this);
|
|
@@ -13374,7 +13506,8 @@ class Draw {
|
|
|
13374
13506
|
this.printModeData = null;
|
|
13375
13507
|
this.render({
|
|
13376
13508
|
isInit: true,
|
|
13377
|
-
isSetCursor: false
|
|
13509
|
+
isSetCursor: false,
|
|
13510
|
+
isFirstRender: true
|
|
13378
13511
|
});
|
|
13379
13512
|
}
|
|
13380
13513
|
getLetterReg() {
|
|
@@ -13403,6 +13536,7 @@ class Draw {
|
|
|
13403
13536
|
this.setEditorData(this.printModeData);
|
|
13404
13537
|
this.printModeData = null;
|
|
13405
13538
|
}
|
|
13539
|
+
this.range.clearRange();
|
|
13406
13540
|
this.mode = payload;
|
|
13407
13541
|
this.render({
|
|
13408
13542
|
isSetCursor: false,
|
|
@@ -13580,6 +13714,9 @@ class Draw {
|
|
|
13580
13714
|
getRange() {
|
|
13581
13715
|
return this.range;
|
|
13582
13716
|
}
|
|
13717
|
+
getLineBreakParticle() {
|
|
13718
|
+
return this.lineBreakParticle;
|
|
13719
|
+
}
|
|
13583
13720
|
getHeaderElementList() {
|
|
13584
13721
|
return this.header.getElementList();
|
|
13585
13722
|
}
|
|
@@ -13991,7 +14128,8 @@ class Draw {
|
|
|
13991
14128
|
});
|
|
13992
14129
|
this.historyManager.recovery();
|
|
13993
14130
|
this.render({
|
|
13994
|
-
isSetCursor: false
|
|
14131
|
+
isSetCursor: false,
|
|
14132
|
+
isFirstRender: true
|
|
13995
14133
|
});
|
|
13996
14134
|
}
|
|
13997
14135
|
setEditorData(payload) {
|
|
@@ -14058,6 +14196,10 @@ class Draw {
|
|
|
14058
14196
|
getElementSize(el) {
|
|
14059
14197
|
return el.actualSize || el.size || this.options.defaultSize;
|
|
14060
14198
|
}
|
|
14199
|
+
getElementRowMargin(el) {
|
|
14200
|
+
const { defaultBasicRowMarginHeight, defaultRowMargin, scale } = this.options;
|
|
14201
|
+
return defaultBasicRowMarginHeight * (el.rowMargin || defaultRowMargin) * scale;
|
|
14202
|
+
}
|
|
14061
14203
|
computeRowList(payload) {
|
|
14062
14204
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
14063
14205
|
const { innerWidth, elementList, isPagingMode = false } = payload;
|
|
@@ -14368,8 +14510,10 @@ class Draw {
|
|
|
14368
14510
|
const word = `${(preElement == null ? void 0 : preElement.value) || ""}${element.value}`;
|
|
14369
14511
|
if (this.WORD_LIKE_REG.test(word)) {
|
|
14370
14512
|
const { width, endElement } = this.textParticle.measureWord(ctx, elementList, i);
|
|
14371
|
-
|
|
14372
|
-
|
|
14513
|
+
if (width <= availableWidth) {
|
|
14514
|
+
curRowWidth += width;
|
|
14515
|
+
nextElement = endElement;
|
|
14516
|
+
}
|
|
14373
14517
|
}
|
|
14374
14518
|
curRowWidth += this.textParticle.measurePunctuationWidth(ctx, nextElement);
|
|
14375
14519
|
}
|
|
@@ -14382,7 +14526,10 @@ class Draw {
|
|
|
14382
14526
|
}
|
|
14383
14527
|
}
|
|
14384
14528
|
listId = element.listId;
|
|
14385
|
-
|
|
14529
|
+
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;
|
|
14530
|
+
const isWidthNotEnough = curRowWidth > availableWidth;
|
|
14531
|
+
if (isForceBreak || isWidthNotEnough) {
|
|
14532
|
+
curRow.isWidthNotEnough = isWidthNotEnough && !isForceBreak;
|
|
14386
14533
|
if (curRow.startIndex === 0 && curRow.elementList.length === 1 && INLINE_ELEMENT_TYPE.includes(element.type)) {
|
|
14387
14534
|
curRow.height = defaultBasicRowMarginHeight;
|
|
14388
14535
|
}
|
|
@@ -14492,11 +14639,11 @@ class Draw {
|
|
|
14492
14639
|
}
|
|
14493
14640
|
}
|
|
14494
14641
|
drawRow(ctx, payload) {
|
|
14495
|
-
var _a, _b, _c;
|
|
14642
|
+
var _a, _b, _c, _d, _e, _f;
|
|
14496
14643
|
this._drawHighlight(ctx, payload);
|
|
14497
|
-
const {
|
|
14644
|
+
const { scale, tdPadding, group: group2, lineBreak } = this.options;
|
|
14645
|
+
const { rowList, pageNo, elementList, positionList, startIndex, zone: zone2, isDrawLineBreak = !lineBreak.disabled } = payload;
|
|
14498
14646
|
const isPrintMode = this.mode === EditorMode.PRINT;
|
|
14499
|
-
const { scale, tdPadding, defaultBasicRowMarginHeight, defaultRowMargin, group: group2 } = this.options;
|
|
14500
14647
|
const { isCrossRowCol, tableId } = this.range.getRange();
|
|
14501
14648
|
let index2 = startIndex;
|
|
14502
14649
|
for (let i = 0; i < rowList.length; i++) {
|
|
@@ -14574,11 +14721,23 @@ class Draw {
|
|
|
14574
14721
|
this.textParticle.complete();
|
|
14575
14722
|
}
|
|
14576
14723
|
}
|
|
14577
|
-
if (
|
|
14724
|
+
if (isDrawLineBreak && !curRow.isWidthNotEnough && j === curRow.elementList.length - 1) {
|
|
14725
|
+
this.lineBreakParticle.render(ctx, element, x, y + curRow.height / 2);
|
|
14726
|
+
}
|
|
14727
|
+
if ((_a = element.control) == null ? void 0 : _a.border) {
|
|
14728
|
+
if (((_b = preElement == null ? void 0 : preElement.control) == null ? void 0 : _b.border) && preElement.controlId !== element.controlId) {
|
|
14729
|
+
this.control.drawBorder(ctx);
|
|
14730
|
+
}
|
|
14731
|
+
const rowMargin = this.getElementRowMargin(element);
|
|
14732
|
+
this.control.recordBorderInfo(x, y + rowMargin, element.metrics.width, curRow.height - 2 * rowMargin);
|
|
14733
|
+
} else if ((_c = preElement == null ? void 0 : preElement.control) == null ? void 0 : _c.border) {
|
|
14734
|
+
this.control.drawBorder(ctx);
|
|
14735
|
+
}
|
|
14736
|
+
if (element.underline || ((_d = element.control) == null ? void 0 : _d.underline)) {
|
|
14578
14737
|
if ((preElement == null ? void 0 : preElement.type) === ElementType.SUPERSCRIPT && element.type !== ElementType.SUPERSCRIPT || (preElement == null ? void 0 : preElement.type) === ElementType.SUBSCRIPT && element.type !== ElementType.SUBSCRIPT) {
|
|
14579
14738
|
this.underline.render(ctx);
|
|
14580
14739
|
}
|
|
14581
|
-
const rowMargin =
|
|
14740
|
+
const rowMargin = this.getElementRowMargin(element);
|
|
14582
14741
|
const offsetX = element.left || 0;
|
|
14583
14742
|
let offsetY2 = 0;
|
|
14584
14743
|
if (element.type === ElementType.SUBSCRIPT) {
|
|
@@ -14587,8 +14746,8 @@ class Draw {
|
|
|
14587
14746
|
offsetY2 = this.superscriptParticle.getOffsetY(element);
|
|
14588
14747
|
}
|
|
14589
14748
|
const color = element.controlComponent === ControlComponent.PLACEHOLDER ? void 0 : element.color;
|
|
14590
|
-
this.underline.recordFillInfo(ctx, x - offsetX, y + curRow.height - rowMargin + offsetY2, metrics.width + offsetX, 0, color, (
|
|
14591
|
-
} else if ((preElement == null ? void 0 : preElement.underline) || ((
|
|
14749
|
+
this.underline.recordFillInfo(ctx, x - offsetX, y + curRow.height - rowMargin + offsetY2, metrics.width + offsetX, 0, color, (_e = element.textDecoration) == null ? void 0 : _e.style);
|
|
14750
|
+
} else if ((preElement == null ? void 0 : preElement.underline) || ((_f = preElement == null ? void 0 : preElement.control) == null ? void 0 : _f.underline)) {
|
|
14592
14751
|
this.underline.render(ctx);
|
|
14593
14752
|
}
|
|
14594
14753
|
if (element.strikeout) {
|
|
@@ -14651,7 +14810,8 @@ class Draw {
|
|
|
14651
14810
|
pageNo,
|
|
14652
14811
|
startIndex: 0,
|
|
14653
14812
|
innerWidth: (td.width - tdPaddingWidth) * scale,
|
|
14654
|
-
zone: zone2
|
|
14813
|
+
zone: zone2,
|
|
14814
|
+
isDrawLineBreak
|
|
14655
14815
|
});
|
|
14656
14816
|
}
|
|
14657
14817
|
}
|
|
@@ -14661,6 +14821,7 @@ class Draw {
|
|
|
14661
14821
|
this.listParticle.drawListStyle(ctx, curRow, positionList[curRow.startIndex]);
|
|
14662
14822
|
}
|
|
14663
14823
|
this.textParticle.complete();
|
|
14824
|
+
this.control.drawBorder(ctx);
|
|
14664
14825
|
this.underline.render(ctx);
|
|
14665
14826
|
this.strikeout.render(ctx);
|
|
14666
14827
|
this.group.render(ctx);
|
|
@@ -14786,7 +14947,7 @@ class Draw {
|
|
|
14786
14947
|
render(payload) {
|
|
14787
14948
|
var _a;
|
|
14788
14949
|
const { header, footer } = this.options;
|
|
14789
|
-
const { isSubmitHistory = true, isSetCursor = true, isCompute = true, isLazy = true, isInit = false, isSourceHistory = false } = payload || {};
|
|
14950
|
+
const { isSubmitHistory = true, isSetCursor = true, isCompute = true, isLazy = true, isInit = false, isSourceHistory = false, isFirstRender = false } = payload || {};
|
|
14790
14951
|
let { curIndex } = payload || {};
|
|
14791
14952
|
const innerWidth = this.getInnerWidth();
|
|
14792
14953
|
const isPagingMode = this.getIsPagingMode();
|
|
@@ -14849,7 +15010,7 @@ class Draw {
|
|
|
14849
15010
|
}
|
|
14850
15011
|
this.cursor.drawCursor();
|
|
14851
15012
|
}
|
|
14852
|
-
if (isSubmitHistory) {
|
|
15013
|
+
if (isSubmitHistory && !isFirstRender || curIndex !== void 0 && this.historyManager.isStackEmpty()) {
|
|
14853
15014
|
const oldElementList = getSlimCloneElementList(this.elementList);
|
|
14854
15015
|
const oldHeaderElementList = getSlimCloneElementList(this.header.getElementList());
|
|
14855
15016
|
const oldFooterElementList = getSlimCloneElementList(this.footer.getElementList());
|
|
@@ -16741,7 +16902,7 @@ class CommandAdapt {
|
|
|
16741
16902
|
if (!~startIndex && !~endIndex)
|
|
16742
16903
|
return;
|
|
16743
16904
|
const { value, width, height } = payload;
|
|
16744
|
-
this.
|
|
16905
|
+
this.insertElementList([
|
|
16745
16906
|
{
|
|
16746
16907
|
value,
|
|
16747
16908
|
width,
|
|
@@ -18058,7 +18219,9 @@ const defaultControlOption = {
|
|
|
18058
18219
|
placeholderColor: "#9c9b9b",
|
|
18059
18220
|
bracketColor: "#000000",
|
|
18060
18221
|
prefix: "{",
|
|
18061
|
-
postfix: "}"
|
|
18222
|
+
postfix: "}",
|
|
18223
|
+
borderWidth: 1,
|
|
18224
|
+
borderColor: "#000000"
|
|
18062
18225
|
};
|
|
18063
18226
|
const defaultCheckboxOption = {
|
|
18064
18227
|
width: 14,
|
|
@@ -18374,6 +18537,11 @@ const defaultBackground = {
|
|
|
18374
18537
|
size: BackgroundSize.COVER,
|
|
18375
18538
|
repeat: BackgroundRepeat.NO_REPEAT
|
|
18376
18539
|
};
|
|
18540
|
+
const defaultLineBreak = {
|
|
18541
|
+
disabled: true,
|
|
18542
|
+
color: "#CCCCCC",
|
|
18543
|
+
lineWidth: 1.5
|
|
18544
|
+
};
|
|
18377
18545
|
class Editor {
|
|
18378
18546
|
constructor(container, data2, options = {}) {
|
|
18379
18547
|
__publicField(this, "command");
|
|
@@ -18396,6 +18564,7 @@ class Editor {
|
|
|
18396
18564
|
const pageBreakOptions = __spreadValues(__spreadValues({}, defaultPageBreakOption), options.pageBreak);
|
|
18397
18565
|
const zoneOptions = __spreadValues(__spreadValues({}, defaultZoneOption), options.zone);
|
|
18398
18566
|
const backgroundOptions = __spreadValues(__spreadValues({}, defaultBackground), options.background);
|
|
18567
|
+
const lineBreakOptions = __spreadValues(__spreadValues({}, defaultLineBreak), options.lineBreak);
|
|
18399
18568
|
const editorOptions = __spreadProps(__spreadValues({
|
|
18400
18569
|
mode: EditorMode.EDIT,
|
|
18401
18570
|
defaultType: "TEXT",
|
|
@@ -18452,7 +18621,8 @@ class Editor {
|
|
|
18452
18621
|
group: groupOptions,
|
|
18453
18622
|
pageBreak: pageBreakOptions,
|
|
18454
18623
|
zone: zoneOptions,
|
|
18455
|
-
background: backgroundOptions
|
|
18624
|
+
background: backgroundOptions,
|
|
18625
|
+
lineBreak: lineBreakOptions
|
|
18456
18626
|
});
|
|
18457
18627
|
data2 = deepClone(data2);
|
|
18458
18628
|
let headerElementList = [];
|