@hufe921/canvas-editor 0.9.12 → 0.9.14
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/dist/canvas-editor.es.js +394 -72
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +17 -15
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/command/Command.d.ts +2 -0
- package/dist/src/editor/core/command/CommandAdapt.d.ts +2 -0
- package/dist/src/editor/core/contextmenu/ContextMenu.d.ts +1 -0
- package/dist/src/editor/core/draw/Draw.d.ts +3 -0
- package/dist/src/editor/core/draw/particle/date/DatePicker.d.ts +23 -0
- package/dist/src/editor/core/i18n/I18n.d.ts +9 -0
- package/dist/src/editor/core/register/Register.d.ts +4 -0
- package/dist/src/editor/index.d.ts +2 -1
- package/dist/src/editor/interface/contextmenu/ContextMenu.d.ts +40 -0
- package/dist/src/editor/interface/i18n/I18n.d.ts +6 -0
- package/dist/src/editor/utils/clipboard.d.ts +5 -1
- package/dist/src/editor/utils/element.d.ts +2 -1
- 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.14";
|
|
27
27
|
const ZERO = "\u200B";
|
|
28
28
|
const WRAP = "\n";
|
|
29
29
|
var RowFlex;
|
|
@@ -187,6 +187,25 @@ const TEXTLIKE_ELEMENT_TYPE = [
|
|
|
187
187
|
ElementType.CONTROL,
|
|
188
188
|
ElementType.DATE
|
|
189
189
|
];
|
|
190
|
+
var ControlType;
|
|
191
|
+
(function(ControlType2) {
|
|
192
|
+
ControlType2["TEXT"] = "text";
|
|
193
|
+
ControlType2["SELECT"] = "select";
|
|
194
|
+
ControlType2["CHECKBOX"] = "checkbox";
|
|
195
|
+
})(ControlType || (ControlType = {}));
|
|
196
|
+
var ControlComponent;
|
|
197
|
+
(function(ControlComponent2) {
|
|
198
|
+
ControlComponent2["PREFIX"] = "prefix";
|
|
199
|
+
ControlComponent2["POSTFIX"] = "postfix";
|
|
200
|
+
ControlComponent2["PLACEHOLDER"] = "placeholder";
|
|
201
|
+
ControlComponent2["VALUE"] = "value";
|
|
202
|
+
ControlComponent2["CHECKBOX"] = "checkbox";
|
|
203
|
+
})(ControlComponent || (ControlComponent = {}));
|
|
204
|
+
var ImageDisplay;
|
|
205
|
+
(function(ImageDisplay2) {
|
|
206
|
+
ImageDisplay2["INLINE"] = "inline";
|
|
207
|
+
ImageDisplay2["BLOCK"] = "block";
|
|
208
|
+
})(ImageDisplay || (ImageDisplay = {}));
|
|
190
209
|
class ImageParticle {
|
|
191
210
|
constructor(draw) {
|
|
192
211
|
__publicField(this, "options");
|
|
@@ -3178,25 +3197,6 @@ const defaultControlOption = {
|
|
|
3178
3197
|
prefix: "{",
|
|
3179
3198
|
postfix: "}"
|
|
3180
3199
|
};
|
|
3181
|
-
var ControlType;
|
|
3182
|
-
(function(ControlType2) {
|
|
3183
|
-
ControlType2["TEXT"] = "text";
|
|
3184
|
-
ControlType2["SELECT"] = "select";
|
|
3185
|
-
ControlType2["CHECKBOX"] = "checkbox";
|
|
3186
|
-
})(ControlType || (ControlType = {}));
|
|
3187
|
-
var ControlComponent;
|
|
3188
|
-
(function(ControlComponent2) {
|
|
3189
|
-
ControlComponent2["PREFIX"] = "prefix";
|
|
3190
|
-
ControlComponent2["POSTFIX"] = "postfix";
|
|
3191
|
-
ControlComponent2["PLACEHOLDER"] = "placeholder";
|
|
3192
|
-
ControlComponent2["VALUE"] = "value";
|
|
3193
|
-
ControlComponent2["CHECKBOX"] = "checkbox";
|
|
3194
|
-
})(ControlComponent || (ControlComponent = {}));
|
|
3195
|
-
var ImageDisplay;
|
|
3196
|
-
(function(ImageDisplay2) {
|
|
3197
|
-
ImageDisplay2["INLINE"] = "inline";
|
|
3198
|
-
ImageDisplay2["BLOCK"] = "block";
|
|
3199
|
-
})(ImageDisplay || (ImageDisplay = {}));
|
|
3200
3200
|
function formatElementList(elementList, options) {
|
|
3201
3201
|
var _a;
|
|
3202
3202
|
const { isHandleFirstElement, editorOptions } = __spreadValues({
|
|
@@ -3552,6 +3552,23 @@ function zipElementList(payload) {
|
|
|
3552
3552
|
}
|
|
3553
3553
|
return zipElementListData;
|
|
3554
3554
|
}
|
|
3555
|
+
function getElementRowFlex(node) {
|
|
3556
|
+
const textAlign = window.getComputedStyle(node).textAlign;
|
|
3557
|
+
switch (textAlign) {
|
|
3558
|
+
case "left":
|
|
3559
|
+
case "start":
|
|
3560
|
+
return RowFlex.LEFT;
|
|
3561
|
+
case "center":
|
|
3562
|
+
return RowFlex.CENTER;
|
|
3563
|
+
case "right":
|
|
3564
|
+
case "end":
|
|
3565
|
+
return RowFlex.RIGHT;
|
|
3566
|
+
case "justify":
|
|
3567
|
+
return RowFlex.ALIGNMENT;
|
|
3568
|
+
default:
|
|
3569
|
+
return RowFlex.LEFT;
|
|
3570
|
+
}
|
|
3571
|
+
}
|
|
3555
3572
|
function writeClipboardItem(text, html) {
|
|
3556
3573
|
if (!text || !html)
|
|
3557
3574
|
return;
|
|
@@ -3580,7 +3597,7 @@ function writeClipboardItem(text, html) {
|
|
|
3580
3597
|
function writeElementList(elementList, options) {
|
|
3581
3598
|
const clipboardDom = document.createElement("div");
|
|
3582
3599
|
function buildDomFromElementList(payload) {
|
|
3583
|
-
var _a, _b, _c, _d;
|
|
3600
|
+
var _a, _b, _c, _d, _e;
|
|
3584
3601
|
for (let e = 0; e < payload.length; e++) {
|
|
3585
3602
|
const element = payload[e];
|
|
3586
3603
|
if (element.type === ElementType.TABLE) {
|
|
@@ -3593,6 +3610,8 @@ function writeElementList(elementList, options) {
|
|
|
3593
3610
|
const tdDom = document.createElement("td");
|
|
3594
3611
|
tdDom.style.border = "1px solid";
|
|
3595
3612
|
const td = tr.tdList[d];
|
|
3613
|
+
tdDom.colSpan = td.colspan;
|
|
3614
|
+
tdDom.rowSpan = td.rowspan;
|
|
3596
3615
|
tdDom.innerText = ((_a = td.value[0]) == null ? void 0 : _a.value) || "";
|
|
3597
3616
|
trDom.append(tdDom);
|
|
3598
3617
|
}
|
|
@@ -3617,12 +3636,19 @@ function writeElementList(elementList, options) {
|
|
|
3617
3636
|
} else if (element.type === ElementType.SEPARATOR) {
|
|
3618
3637
|
const hr = document.createElement("hr");
|
|
3619
3638
|
clipboardDom.append(hr);
|
|
3639
|
+
} else if (element.type === ElementType.CHECKBOX) {
|
|
3640
|
+
const checkbox = document.createElement("input");
|
|
3641
|
+
checkbox.type = "checkbox";
|
|
3642
|
+
if ((_b = element.checkbox) == null ? void 0 : _b.value) {
|
|
3643
|
+
checkbox.setAttribute("checked", "true");
|
|
3644
|
+
}
|
|
3645
|
+
clipboardDom.append(checkbox);
|
|
3620
3646
|
} else if (!element.type || element.type === ElementType.LATEX || TEXTLIKE_ELEMENT_TYPE.includes(element.type)) {
|
|
3621
3647
|
let text2 = "";
|
|
3622
3648
|
if (element.type === ElementType.CONTROL) {
|
|
3623
|
-
text2 = ((
|
|
3649
|
+
text2 = ((_d = (_c = element.control.value) == null ? void 0 : _c[0]) == null ? void 0 : _d.value) || "";
|
|
3624
3650
|
} else if (element.type === ElementType.DATE) {
|
|
3625
|
-
text2 = ((
|
|
3651
|
+
text2 = ((_e = element.valueList) == null ? void 0 : _e.map((v) => v.value).join("")) || "";
|
|
3626
3652
|
} else {
|
|
3627
3653
|
text2 = element.value;
|
|
3628
3654
|
}
|
|
@@ -3633,7 +3659,8 @@ function writeElementList(elementList, options) {
|
|
|
3633
3659
|
dom.innerText = text2.replace(new RegExp(`${ZERO}`, "g"), "\n");
|
|
3634
3660
|
dom.style.fontFamily = element.font || options.defaultFont;
|
|
3635
3661
|
if (element.rowFlex) {
|
|
3636
|
-
|
|
3662
|
+
const isAlignment = element.rowFlex === RowFlex.ALIGNMENT;
|
|
3663
|
+
dom.style.textAlign = isAlignment ? "justify" : element.rowFlex;
|
|
3637
3664
|
}
|
|
3638
3665
|
if (element.color) {
|
|
3639
3666
|
dom.style.color = element.color;
|
|
@@ -3660,20 +3687,26 @@ function writeElementList(elementList, options) {
|
|
|
3660
3687
|
return;
|
|
3661
3688
|
writeClipboardItem(text, html);
|
|
3662
3689
|
}
|
|
3663
|
-
function getElementListByHTML(htmlText) {
|
|
3690
|
+
function getElementListByHTML(htmlText, options) {
|
|
3664
3691
|
const elementList = [];
|
|
3665
3692
|
function findTextNode(dom) {
|
|
3666
3693
|
if (dom.nodeType === 3) {
|
|
3667
|
-
const
|
|
3694
|
+
const parentNode = dom.parentNode;
|
|
3695
|
+
const rowFlex = getElementRowFlex(parentNode);
|
|
3668
3696
|
const value = dom.textContent;
|
|
3669
|
-
|
|
3670
|
-
|
|
3697
|
+
const style = window.getComputedStyle(parentNode);
|
|
3698
|
+
if (value && parentNode.nodeName !== "STYLE") {
|
|
3699
|
+
const element = {
|
|
3671
3700
|
value,
|
|
3672
3701
|
color: style.color,
|
|
3673
3702
|
bold: Number(style.fontWeight) > 500,
|
|
3674
3703
|
italic: style.fontStyle.includes("italic"),
|
|
3675
3704
|
size: Math.floor(Number(style.fontSize.replace("px", "")))
|
|
3676
|
-
}
|
|
3705
|
+
};
|
|
3706
|
+
if (rowFlex !== RowFlex.LEFT) {
|
|
3707
|
+
element.rowFlex = rowFlex;
|
|
3708
|
+
}
|
|
3709
|
+
elementList.push(element);
|
|
3677
3710
|
}
|
|
3678
3711
|
} else if (dom.nodeType === 1) {
|
|
3679
3712
|
const childNodes = dom.childNodes;
|
|
@@ -3696,6 +3729,68 @@ function getElementListByHTML(htmlText) {
|
|
|
3696
3729
|
url: aElement.href
|
|
3697
3730
|
});
|
|
3698
3731
|
}
|
|
3732
|
+
} else if (node.nodeName === "HR") {
|
|
3733
|
+
elementList.push({
|
|
3734
|
+
value: "\n",
|
|
3735
|
+
type: ElementType.SEPARATOR
|
|
3736
|
+
});
|
|
3737
|
+
} else if (node.nodeName === "IMG") {
|
|
3738
|
+
const { src, width, height } = node;
|
|
3739
|
+
if (src && width && height) {
|
|
3740
|
+
elementList.push({
|
|
3741
|
+
width,
|
|
3742
|
+
height,
|
|
3743
|
+
value: src,
|
|
3744
|
+
type: ElementType.IMAGE
|
|
3745
|
+
});
|
|
3746
|
+
}
|
|
3747
|
+
} else if (node.nodeName === "TABLE") {
|
|
3748
|
+
const tableElement = node;
|
|
3749
|
+
const element = {
|
|
3750
|
+
type: ElementType.TABLE,
|
|
3751
|
+
value: "\n",
|
|
3752
|
+
colgroup: [],
|
|
3753
|
+
trList: []
|
|
3754
|
+
};
|
|
3755
|
+
tableElement.querySelectorAll("tr").forEach((trElement) => {
|
|
3756
|
+
const trHeightStr = window.getComputedStyle(trElement).height.replace("px", "");
|
|
3757
|
+
const tr = {
|
|
3758
|
+
height: Number(trHeightStr),
|
|
3759
|
+
tdList: []
|
|
3760
|
+
};
|
|
3761
|
+
trElement.querySelectorAll("th,td").forEach((tdElement) => {
|
|
3762
|
+
const tableCell = tdElement;
|
|
3763
|
+
const td = {
|
|
3764
|
+
colspan: tableCell.colSpan,
|
|
3765
|
+
rowspan: tableCell.rowSpan,
|
|
3766
|
+
value: [{
|
|
3767
|
+
value: tableCell.innerText
|
|
3768
|
+
}]
|
|
3769
|
+
};
|
|
3770
|
+
tr.tdList.push(td);
|
|
3771
|
+
});
|
|
3772
|
+
if (tr.tdList.length) {
|
|
3773
|
+
element.trList.push(tr);
|
|
3774
|
+
}
|
|
3775
|
+
});
|
|
3776
|
+
if (element.trList.length) {
|
|
3777
|
+
const tdCount = element.trList[0].tdList.reduce((pre, cur) => pre + cur.colspan, 0);
|
|
3778
|
+
const width = Math.ceil(options.innerWidth / tdCount);
|
|
3779
|
+
for (let i = 0; i < tdCount; i++) {
|
|
3780
|
+
element.colgroup.push({
|
|
3781
|
+
width
|
|
3782
|
+
});
|
|
3783
|
+
}
|
|
3784
|
+
elementList.push(element);
|
|
3785
|
+
}
|
|
3786
|
+
} else if (node.nodeName === "INPUT" && node.type === ControlComponent.CHECKBOX) {
|
|
3787
|
+
elementList.push({
|
|
3788
|
+
type: ElementType.CHECKBOX,
|
|
3789
|
+
value: "",
|
|
3790
|
+
checkbox: {
|
|
3791
|
+
value: node.checked
|
|
3792
|
+
}
|
|
3793
|
+
});
|
|
3699
3794
|
} else {
|
|
3700
3795
|
findTextNode(node);
|
|
3701
3796
|
if (node.nodeType === 1 && n !== childNodes.length - 1) {
|
|
@@ -3778,7 +3873,9 @@ class CursorAgent {
|
|
|
3778
3873
|
}
|
|
3779
3874
|
if (item.type === "text/html" && isHTML) {
|
|
3780
3875
|
item.getAsString((htmlText) => {
|
|
3781
|
-
const elementList = getElementListByHTML(htmlText
|
|
3876
|
+
const elementList = getElementListByHTML(htmlText, {
|
|
3877
|
+
innerWidth: this.draw.getOriginalInnerWidth()
|
|
3878
|
+
});
|
|
3782
3879
|
this.draw.insertElementList(elementList);
|
|
3783
3880
|
});
|
|
3784
3881
|
}
|
|
@@ -4392,7 +4489,7 @@ function keydown(evt, host) {
|
|
|
4392
4489
|
} else if (evt.key === KeyMap.Right) {
|
|
4393
4490
|
if (isReadonly)
|
|
4394
4491
|
return;
|
|
4395
|
-
if (index2 < positionList.length
|
|
4492
|
+
if (index2 < positionList.length) {
|
|
4396
4493
|
const curIndex = endIndex + 1;
|
|
4397
4494
|
let anchorStartIndex = curIndex;
|
|
4398
4495
|
let anchorEndIndex = curIndex;
|
|
@@ -7621,6 +7718,69 @@ class Previewer {
|
|
|
7621
7718
|
this.resizerSelection.style.display = "none";
|
|
7622
7719
|
}
|
|
7623
7720
|
}
|
|
7721
|
+
const contextmenu$1 = {
|
|
7722
|
+
global: {
|
|
7723
|
+
cut: "\u526A\u5207",
|
|
7724
|
+
copy: "\u590D\u5236",
|
|
7725
|
+
paste: "\u7C98\u8D34",
|
|
7726
|
+
selectAll: "\u5168\u9009",
|
|
7727
|
+
print: "\u6253\u5370"
|
|
7728
|
+
},
|
|
7729
|
+
control: {
|
|
7730
|
+
"delete": "\u5220\u9664\u63A7\u4EF6"
|
|
7731
|
+
},
|
|
7732
|
+
hyperlink: {
|
|
7733
|
+
"delete": "\u5220\u9664\u94FE\u63A5",
|
|
7734
|
+
cancel: "\u53D6\u6D88\u94FE\u63A5",
|
|
7735
|
+
edit: "\u7F16\u8F91\u94FE\u63A5"
|
|
7736
|
+
},
|
|
7737
|
+
image: {
|
|
7738
|
+
change: "\u66F4\u6539\u56FE\u7247",
|
|
7739
|
+
saveAs: "\u53E6\u5B58\u4E3A\u56FE\u7247",
|
|
7740
|
+
textWrap: "\u6587\u5B57\u73AF\u7ED5",
|
|
7741
|
+
textWrapType: {
|
|
7742
|
+
embed: "\u5D4C\u5165\u578B",
|
|
7743
|
+
upDown: "\u4E0A\u4E0B\u578B\u73AF\u7ED5"
|
|
7744
|
+
}
|
|
7745
|
+
},
|
|
7746
|
+
table: {
|
|
7747
|
+
insertRowCol: "\u63D2\u5165\u884C\u5217",
|
|
7748
|
+
insertTopRow: "\u4E0A\u65B9\u63D2\u51651\u884C",
|
|
7749
|
+
insertBottomRow: "\u4E0B\u65B9\u63D2\u51651\u884C",
|
|
7750
|
+
insertLeftCol: "\u5DE6\u4FA7\u63D2\u51651\u5217",
|
|
7751
|
+
insertRightCol: "\u53F3\u4FA7\u63D2\u51651\u5217",
|
|
7752
|
+
deleteRowCol: "\u5220\u9664\u884C\u5217",
|
|
7753
|
+
deleteRow: "\u5220\u96641\u884C",
|
|
7754
|
+
deleteCol: "\u5220\u96641\u5217",
|
|
7755
|
+
deleteTable: "\u5220\u9664\u6574\u4E2A\u8868\u683C",
|
|
7756
|
+
mergeCell: "\u5408\u5E76\u5355\u5143\u683C",
|
|
7757
|
+
mergeCancelCell: "\u53D6\u6D88\u5408\u5E76"
|
|
7758
|
+
}
|
|
7759
|
+
};
|
|
7760
|
+
const datePicker$1 = {
|
|
7761
|
+
now: "\u6B64\u523B",
|
|
7762
|
+
confirm: "\u786E\u5B9A",
|
|
7763
|
+
"return": "\u8FD4\u56DE\u65E5\u671F",
|
|
7764
|
+
timeSelect: "\u65F6\u95F4\u9009\u62E9",
|
|
7765
|
+
weeks: {
|
|
7766
|
+
sun: "\u65E5",
|
|
7767
|
+
mon: "\u4E00",
|
|
7768
|
+
tue: "\u4E8C",
|
|
7769
|
+
wed: "\u4E09",
|
|
7770
|
+
thu: "\u56DB",
|
|
7771
|
+
fri: "\u4E94",
|
|
7772
|
+
sat: "\u516D"
|
|
7773
|
+
},
|
|
7774
|
+
year: "\u5E74",
|
|
7775
|
+
month: "\u6708",
|
|
7776
|
+
hour: "\u65F6",
|
|
7777
|
+
minute: "\u5206",
|
|
7778
|
+
second: "\u79D2"
|
|
7779
|
+
};
|
|
7780
|
+
var zhCN = {
|
|
7781
|
+
contextmenu: contextmenu$1,
|
|
7782
|
+
datePicker: datePicker$1
|
|
7783
|
+
};
|
|
7624
7784
|
class DatePicker {
|
|
7625
7785
|
constructor(options = {}) {
|
|
7626
7786
|
__publicField(this, "options");
|
|
@@ -7629,9 +7789,11 @@ class DatePicker {
|
|
|
7629
7789
|
__publicField(this, "renderOptions");
|
|
7630
7790
|
__publicField(this, "isDatePicker");
|
|
7631
7791
|
__publicField(this, "pickDate");
|
|
7792
|
+
__publicField(this, "lang");
|
|
7632
7793
|
this.options = __spreadValues({
|
|
7633
7794
|
mountDom: document.body
|
|
7634
7795
|
}, options);
|
|
7796
|
+
this.lang = datePicker$1;
|
|
7635
7797
|
this.now = new Date();
|
|
7636
7798
|
this.dom = this._createDom();
|
|
7637
7799
|
this.renderOptions = null;
|
|
@@ -7667,7 +7829,8 @@ class DatePicker {
|
|
|
7667
7829
|
datePickerTitle.append(nextYearTitle);
|
|
7668
7830
|
const datePickerWeek = document.createElement("div");
|
|
7669
7831
|
datePickerWeek.classList.add(`${EDITOR_PREFIX}-date-week`);
|
|
7670
|
-
const
|
|
7832
|
+
const { weeks: { sun, mon, tue, wed, thu, fri, sat } } = this.lang;
|
|
7833
|
+
const weekList = [sun, mon, tue, wed, thu, fri, sat];
|
|
7671
7834
|
weekList.forEach((week) => {
|
|
7672
7835
|
const weekDom = document.createElement("span");
|
|
7673
7836
|
weekDom.innerText = `${week}`;
|
|
@@ -7683,7 +7846,7 @@ class DatePicker {
|
|
|
7683
7846
|
let hourTime;
|
|
7684
7847
|
let minuteTime;
|
|
7685
7848
|
let secondTime;
|
|
7686
|
-
const timeList = [
|
|
7849
|
+
const timeList = [this.lang.hour, this.lang.minute, this.lang.second];
|
|
7687
7850
|
timeList.forEach((t, i) => {
|
|
7688
7851
|
const li = document.createElement("li");
|
|
7689
7852
|
const timeText = document.createElement("span");
|
|
@@ -7713,13 +7876,13 @@ class DatePicker {
|
|
|
7713
7876
|
datePickerMenu.classList.add(`${EDITOR_PREFIX}-date-menu`);
|
|
7714
7877
|
const timeMenu = document.createElement("button");
|
|
7715
7878
|
timeMenu.classList.add(`${EDITOR_PREFIX}-date-menu__time`);
|
|
7716
|
-
timeMenu.innerText =
|
|
7879
|
+
timeMenu.innerText = this.lang.timeSelect;
|
|
7717
7880
|
const nowMenu = document.createElement("button");
|
|
7718
7881
|
nowMenu.classList.add(`${EDITOR_PREFIX}-date-menu__now`);
|
|
7719
|
-
nowMenu.innerText =
|
|
7882
|
+
nowMenu.innerText = this.lang.now;
|
|
7720
7883
|
const submitMenu = document.createElement("button");
|
|
7721
7884
|
submitMenu.classList.add(`${EDITOR_PREFIX}-date-menu__submit`);
|
|
7722
|
-
submitMenu.innerText =
|
|
7885
|
+
submitMenu.innerText = this.lang.confirm;
|
|
7723
7886
|
datePickerMenu.append(timeMenu);
|
|
7724
7887
|
datePickerMenu.append(nowMenu);
|
|
7725
7888
|
datePickerMenu.append(submitMenu);
|
|
@@ -7730,6 +7893,7 @@ class DatePicker {
|
|
|
7730
7893
|
return {
|
|
7731
7894
|
container: datePickerContainer,
|
|
7732
7895
|
dateWrap,
|
|
7896
|
+
datePickerWeek,
|
|
7733
7897
|
timeWrap,
|
|
7734
7898
|
title: {
|
|
7735
7899
|
preYear: preYearTitle,
|
|
@@ -7828,6 +7992,22 @@ class DatePicker {
|
|
|
7828
7992
|
}
|
|
7829
7993
|
this.pickDate = new Date(this.now);
|
|
7830
7994
|
}
|
|
7995
|
+
_setLang() {
|
|
7996
|
+
this.dom.menu.time.innerText = this.lang.timeSelect;
|
|
7997
|
+
this.dom.menu.now.innerText = this.lang.now;
|
|
7998
|
+
this.dom.menu.submit.innerText = this.lang.confirm;
|
|
7999
|
+
const { weeks: { sun, mon, tue, wed, thu, fri, sat } } = this.lang;
|
|
8000
|
+
const weekList = [sun, mon, tue, wed, thu, fri, sat];
|
|
8001
|
+
this.dom.datePickerWeek.childNodes.forEach((child, i) => {
|
|
8002
|
+
child.innerText = weekList[i];
|
|
8003
|
+
});
|
|
8004
|
+
const hourTitle = this.dom.time.hour.previousElementSibling;
|
|
8005
|
+
hourTitle.innerText = this.lang.hour;
|
|
8006
|
+
const minuteTitle = this.dom.time.minute.previousElementSibling;
|
|
8007
|
+
minuteTitle.innerText = this.lang.minute;
|
|
8008
|
+
const secondTitle = this.dom.time.second.previousElementSibling;
|
|
8009
|
+
secondTitle.innerText = this.lang.second;
|
|
8010
|
+
}
|
|
7831
8011
|
_update() {
|
|
7832
8012
|
const localDate = new Date();
|
|
7833
8013
|
const localYear = localDate.getFullYear();
|
|
@@ -7843,7 +8023,7 @@ class DatePicker {
|
|
|
7843
8023
|
}
|
|
7844
8024
|
const year = this.now.getFullYear();
|
|
7845
8025
|
const month = this.now.getMonth() + 1;
|
|
7846
|
-
this.dom.title.now.innerText = `${year}
|
|
8026
|
+
this.dom.title.now.innerText = `${year}${this.lang.year} ${String(month).padStart(2, "0")}${this.lang.month}`;
|
|
7847
8027
|
const curDate = new Date(year, month, 0);
|
|
7848
8028
|
const curDay = curDate.getDate();
|
|
7849
8029
|
let curWeek = new Date(year, month - 1, 1).getDay();
|
|
@@ -7897,11 +8077,11 @@ class DatePicker {
|
|
|
7897
8077
|
if (this.isDatePicker) {
|
|
7898
8078
|
this.dom.dateWrap.classList.add("active");
|
|
7899
8079
|
this.dom.timeWrap.classList.remove("active");
|
|
7900
|
-
this.dom.menu.time.innerText =
|
|
8080
|
+
this.dom.menu.time.innerText = this.lang.timeSelect;
|
|
7901
8081
|
} else {
|
|
7902
8082
|
this.dom.dateWrap.classList.remove("active");
|
|
7903
8083
|
this.dom.timeWrap.classList.add("active");
|
|
7904
|
-
this.dom.menu.time.innerText =
|
|
8084
|
+
this.dom.menu.time.innerText = this.lang.return;
|
|
7905
8085
|
this._setTimePick();
|
|
7906
8086
|
}
|
|
7907
8087
|
}
|
|
@@ -8009,6 +8189,10 @@ class DatePicker {
|
|
|
8009
8189
|
}
|
|
8010
8190
|
render(option) {
|
|
8011
8191
|
this.renderOptions = option;
|
|
8192
|
+
if (this.options.getLang) {
|
|
8193
|
+
this.lang = this.options.getLang();
|
|
8194
|
+
this._setLang();
|
|
8195
|
+
}
|
|
8012
8196
|
this._setValue();
|
|
8013
8197
|
this._update();
|
|
8014
8198
|
this._setPosition();
|
|
@@ -8027,9 +8211,31 @@ class DateParticle {
|
|
|
8027
8211
|
__publicField(this, "datePicker");
|
|
8028
8212
|
this.draw = draw;
|
|
8029
8213
|
this.range = draw.getRange();
|
|
8214
|
+
const i18n = draw.getI18n();
|
|
8215
|
+
const t = i18n.t.bind(i18n);
|
|
8030
8216
|
this.datePicker = new DatePicker({
|
|
8031
8217
|
mountDom: draw.getContainer(),
|
|
8032
|
-
onSubmit: this._setValue.bind(this)
|
|
8218
|
+
onSubmit: this._setValue.bind(this),
|
|
8219
|
+
getLang: () => ({
|
|
8220
|
+
now: t("datePicker.now"),
|
|
8221
|
+
confirm: t("datePicker.confirm"),
|
|
8222
|
+
return: t("datePicker.return"),
|
|
8223
|
+
timeSelect: t("datePicker.timeSelect"),
|
|
8224
|
+
weeks: {
|
|
8225
|
+
sun: t("datePicker.weeks.sun"),
|
|
8226
|
+
mon: t("datePicker.weeks.mon"),
|
|
8227
|
+
tue: t("datePicker.weeks.tue"),
|
|
8228
|
+
wed: t("datePicker.weeks.wed"),
|
|
8229
|
+
thu: t("datePicker.weeks.thu"),
|
|
8230
|
+
fri: t("datePicker.weeks.fri"),
|
|
8231
|
+
sat: t("datePicker.weeks.sat")
|
|
8232
|
+
},
|
|
8233
|
+
year: t("datePicker.year"),
|
|
8234
|
+
month: t("datePicker.month"),
|
|
8235
|
+
hour: t("datePicker.hour"),
|
|
8236
|
+
minute: t("datePicker.minute"),
|
|
8237
|
+
second: t("datePicker.second")
|
|
8238
|
+
})
|
|
8033
8239
|
});
|
|
8034
8240
|
}
|
|
8035
8241
|
_setValue(date) {
|
|
@@ -8262,6 +8468,102 @@ class BlockParticle {
|
|
|
8262
8468
|
});
|
|
8263
8469
|
}
|
|
8264
8470
|
}
|
|
8471
|
+
const contextmenu = {
|
|
8472
|
+
global: {
|
|
8473
|
+
cut: "Cut",
|
|
8474
|
+
copy: "Copy",
|
|
8475
|
+
paste: "Paste",
|
|
8476
|
+
selectAll: "Select all",
|
|
8477
|
+
print: "Print"
|
|
8478
|
+
},
|
|
8479
|
+
control: {
|
|
8480
|
+
"delete": "Delete control"
|
|
8481
|
+
},
|
|
8482
|
+
hyperlink: {
|
|
8483
|
+
"delete": "Delete hyperlink",
|
|
8484
|
+
cancel: "Cancel hyperlink",
|
|
8485
|
+
edit: "Edit hyperlink"
|
|
8486
|
+
},
|
|
8487
|
+
image: {
|
|
8488
|
+
change: "Change image",
|
|
8489
|
+
saveAs: "Save as image",
|
|
8490
|
+
textWrap: "Text wrap",
|
|
8491
|
+
textWrapType: {
|
|
8492
|
+
embed: "Embed",
|
|
8493
|
+
upDown: "Up down"
|
|
8494
|
+
}
|
|
8495
|
+
},
|
|
8496
|
+
table: {
|
|
8497
|
+
insertRowCol: "Insert row col",
|
|
8498
|
+
insertTopRow: "Insert top 1 row",
|
|
8499
|
+
insertBottomRow: "Insert bottom 1 row",
|
|
8500
|
+
insertLeftCol: "Insert left 1 col",
|
|
8501
|
+
insertRightCol: "Insert right 1 col",
|
|
8502
|
+
deleteRowCol: "Delete row col",
|
|
8503
|
+
deleteRow: "Delete 1 row",
|
|
8504
|
+
deleteCol: "Delete 1 col",
|
|
8505
|
+
deleteTable: "Delete table",
|
|
8506
|
+
mergeCell: "Merge cell",
|
|
8507
|
+
mergeCancelCell: "Cancel merge cell"
|
|
8508
|
+
}
|
|
8509
|
+
};
|
|
8510
|
+
const datePicker = {
|
|
8511
|
+
now: "Now",
|
|
8512
|
+
confirm: "Confirm",
|
|
8513
|
+
"return": "Return",
|
|
8514
|
+
timeSelect: "Time select",
|
|
8515
|
+
weeks: {
|
|
8516
|
+
sun: "Sun",
|
|
8517
|
+
mon: "Mon",
|
|
8518
|
+
tue: "Tue",
|
|
8519
|
+
wed: "Wed",
|
|
8520
|
+
thu: "Thu",
|
|
8521
|
+
fri: "Fri",
|
|
8522
|
+
sat: "Sat"
|
|
8523
|
+
},
|
|
8524
|
+
year: " ",
|
|
8525
|
+
month: " ",
|
|
8526
|
+
hour: "Hour",
|
|
8527
|
+
minute: "Minute",
|
|
8528
|
+
second: "Second"
|
|
8529
|
+
};
|
|
8530
|
+
var en = {
|
|
8531
|
+
contextmenu,
|
|
8532
|
+
datePicker
|
|
8533
|
+
};
|
|
8534
|
+
class I18n {
|
|
8535
|
+
constructor() {
|
|
8536
|
+
__publicField(this, "langMap", new Map([
|
|
8537
|
+
["zhCN", zhCN],
|
|
8538
|
+
["en", en]
|
|
8539
|
+
]));
|
|
8540
|
+
__publicField(this, "currentLocale", "zhCN");
|
|
8541
|
+
}
|
|
8542
|
+
registerLangMap(locale, lang) {
|
|
8543
|
+
this.langMap.set(locale, lang);
|
|
8544
|
+
}
|
|
8545
|
+
setLocale(locale) {
|
|
8546
|
+
this.currentLocale = locale;
|
|
8547
|
+
}
|
|
8548
|
+
getLang() {
|
|
8549
|
+
return this.langMap.get(this.currentLocale) || zhCN;
|
|
8550
|
+
}
|
|
8551
|
+
t(path) {
|
|
8552
|
+
const keyList = path.split(".");
|
|
8553
|
+
let value = "";
|
|
8554
|
+
let item = this.getLang();
|
|
8555
|
+
for (let k = 0; k < keyList.length; k++) {
|
|
8556
|
+
const key = keyList[k];
|
|
8557
|
+
const currentValue = Reflect.get(item, key);
|
|
8558
|
+
if (currentValue) {
|
|
8559
|
+
value = item = currentValue;
|
|
8560
|
+
} else {
|
|
8561
|
+
return "";
|
|
8562
|
+
}
|
|
8563
|
+
}
|
|
8564
|
+
return value;
|
|
8565
|
+
}
|
|
8566
|
+
}
|
|
8265
8567
|
class Draw {
|
|
8266
8568
|
constructor(rootContainer, options, elementList, listener) {
|
|
8267
8569
|
__publicField(this, "container");
|
|
@@ -8274,6 +8576,7 @@ class Draw {
|
|
|
8274
8576
|
__publicField(this, "position");
|
|
8275
8577
|
__publicField(this, "elementList");
|
|
8276
8578
|
__publicField(this, "listener");
|
|
8579
|
+
__publicField(this, "i18n");
|
|
8277
8580
|
__publicField(this, "canvasEvent");
|
|
8278
8581
|
__publicField(this, "globalEvent");
|
|
8279
8582
|
__publicField(this, "cursor");
|
|
@@ -8322,6 +8625,7 @@ class Draw {
|
|
|
8322
8625
|
this._formatContainer();
|
|
8323
8626
|
this.pageContainer = this._createPageContainer();
|
|
8324
8627
|
this._createPage(0);
|
|
8628
|
+
this.i18n = new I18n();
|
|
8325
8629
|
this.historyManager = new HistoryManager();
|
|
8326
8630
|
this.position = new Position(this);
|
|
8327
8631
|
this.range = new RangeManager(this);
|
|
@@ -8553,6 +8857,9 @@ class Draw {
|
|
|
8553
8857
|
getWorkerManager() {
|
|
8554
8858
|
return this.workerManager;
|
|
8555
8859
|
}
|
|
8860
|
+
getI18n() {
|
|
8861
|
+
return this.i18n;
|
|
8862
|
+
}
|
|
8556
8863
|
getRowCount() {
|
|
8557
8864
|
return this.rowList.length;
|
|
8558
8865
|
}
|
|
@@ -8700,7 +9007,7 @@ class Draw {
|
|
|
8700
9007
|
return `${el.italic ? "italic " : ""}${el.bold ? "bold " : ""}${size * scale}px ${font}`;
|
|
8701
9008
|
}
|
|
8702
9009
|
_computeRowList(innerWidth, elementList) {
|
|
8703
|
-
var _a, _b, _c;
|
|
9010
|
+
var _a, _b, _c, _d;
|
|
8704
9011
|
const { defaultSize, defaultRowMargin, scale, tdPadding, defaultTabWidth } = this.options;
|
|
8705
9012
|
const defaultBasicRowMarginHeight = this.getDefaultBasicRowMarginHeight();
|
|
8706
9013
|
const tdGap = tdPadding * 2;
|
|
@@ -8899,7 +9206,7 @@ class Draw {
|
|
|
8899
9206
|
height,
|
|
8900
9207
|
elementList: [rowElement],
|
|
8901
9208
|
ascent,
|
|
8902
|
-
rowFlex:
|
|
9209
|
+
rowFlex: (_d = elementList[i + 1]) == null ? void 0 : _d.rowFlex,
|
|
8903
9210
|
isPageBreak: element.type === ElementType.PAGE_BREAK
|
|
8904
9211
|
});
|
|
8905
9212
|
} else {
|
|
@@ -9309,6 +9616,7 @@ const _Command = class {
|
|
|
9309
9616
|
_Command.setPaperMargin = adapt.setPaperMargin.bind(adapt);
|
|
9310
9617
|
_Command.insertElementList = adapt.insertElementList.bind(adapt);
|
|
9311
9618
|
_Command.removeControl = adapt.removeControl.bind(adapt);
|
|
9619
|
+
_Command.setLocale = adapt.setLocale.bind(adapt);
|
|
9312
9620
|
}
|
|
9313
9621
|
executeMode(payload) {
|
|
9314
9622
|
return _Command.mode(payload);
|
|
@@ -9517,6 +9825,9 @@ const _Command = class {
|
|
|
9517
9825
|
executeRemoveControl() {
|
|
9518
9826
|
return _Command.removeControl();
|
|
9519
9827
|
}
|
|
9828
|
+
executeSetLocale(payload) {
|
|
9829
|
+
return _Command.setLocale(payload);
|
|
9830
|
+
}
|
|
9520
9831
|
};
|
|
9521
9832
|
let Command = _Command;
|
|
9522
9833
|
__publicField(Command, "mode");
|
|
@@ -9588,6 +9899,7 @@ __publicField(Command, "getPaperMargin");
|
|
|
9588
9899
|
__publicField(Command, "setPaperMargin");
|
|
9589
9900
|
__publicField(Command, "insertElementList");
|
|
9590
9901
|
__publicField(Command, "removeControl");
|
|
9902
|
+
__publicField(Command, "setLocale");
|
|
9591
9903
|
const defaultWatermarkOption = {
|
|
9592
9904
|
data: "",
|
|
9593
9905
|
color: "#AEB5C0",
|
|
@@ -9643,6 +9955,7 @@ class CommandAdapt {
|
|
|
9643
9955
|
__publicField(this, "control");
|
|
9644
9956
|
__publicField(this, "workerManager");
|
|
9645
9957
|
__publicField(this, "searchManager");
|
|
9958
|
+
__publicField(this, "i18n");
|
|
9646
9959
|
this.draw = draw;
|
|
9647
9960
|
this.range = draw.getRange();
|
|
9648
9961
|
this.position = draw.getPosition();
|
|
@@ -9653,6 +9966,7 @@ class CommandAdapt {
|
|
|
9653
9966
|
this.control = draw.getControl();
|
|
9654
9967
|
this.workerManager = draw.getWorkerManager();
|
|
9655
9968
|
this.searchManager = draw.getSearch();
|
|
9969
|
+
this.i18n = draw.getI18n();
|
|
9656
9970
|
}
|
|
9657
9971
|
mode(payload) {
|
|
9658
9972
|
const mode = this.draw.getMode();
|
|
@@ -11017,6 +11331,9 @@ class CommandAdapt {
|
|
|
11017
11331
|
curIndex: newIndex
|
|
11018
11332
|
});
|
|
11019
11333
|
}
|
|
11334
|
+
setLocale(payload) {
|
|
11335
|
+
this.i18n.setLocale(payload);
|
|
11336
|
+
}
|
|
11020
11337
|
}
|
|
11021
11338
|
class Listener {
|
|
11022
11339
|
constructor() {
|
|
@@ -11044,9 +11361,11 @@ class Register {
|
|
|
11044
11361
|
constructor(payload) {
|
|
11045
11362
|
__publicField(this, "contextMenuList");
|
|
11046
11363
|
__publicField(this, "shortcutList");
|
|
11047
|
-
|
|
11364
|
+
__publicField(this, "langMap");
|
|
11365
|
+
const { contextMenu, shortcut, i18n } = payload;
|
|
11048
11366
|
this.contextMenuList = contextMenu.registerContextMenuList.bind(contextMenu);
|
|
11049
11367
|
this.shortcutList = shortcut.registerShortcutList.bind(shortcut);
|
|
11368
|
+
this.langMap = i18n.registerLangMap.bind(i18n);
|
|
11050
11369
|
}
|
|
11051
11370
|
}
|
|
11052
11371
|
const NAME_PLACEHOLDER = {
|
|
@@ -11054,7 +11373,7 @@ const NAME_PLACEHOLDER = {
|
|
|
11054
11373
|
};
|
|
11055
11374
|
const controlMenus = [
|
|
11056
11375
|
{
|
|
11057
|
-
|
|
11376
|
+
i18nPath: "contextmenu.control.delete",
|
|
11058
11377
|
when: (payload) => {
|
|
11059
11378
|
var _a;
|
|
11060
11379
|
return !payload.editorHasSelection && ((_a = payload.startElement) == null ? void 0 : _a.type) === ElementType.CONTROL;
|
|
@@ -11066,7 +11385,7 @@ const controlMenus = [
|
|
|
11066
11385
|
];
|
|
11067
11386
|
const globalMenus = [
|
|
11068
11387
|
{
|
|
11069
|
-
|
|
11388
|
+
i18nPath: "contextmenu.global.cut",
|
|
11070
11389
|
shortCut: "Ctrl + X",
|
|
11071
11390
|
when: (payload) => {
|
|
11072
11391
|
return !payload.isReadonly;
|
|
@@ -11076,7 +11395,7 @@ const globalMenus = [
|
|
|
11076
11395
|
}
|
|
11077
11396
|
},
|
|
11078
11397
|
{
|
|
11079
|
-
|
|
11398
|
+
i18nPath: "contextmenu.global.copy",
|
|
11080
11399
|
shortCut: "Ctrl + C",
|
|
11081
11400
|
when: (payload) => {
|
|
11082
11401
|
return payload.editorHasSelection;
|
|
@@ -11086,7 +11405,7 @@ const globalMenus = [
|
|
|
11086
11405
|
}
|
|
11087
11406
|
},
|
|
11088
11407
|
{
|
|
11089
|
-
|
|
11408
|
+
i18nPath: "contextmenu.global.paste",
|
|
11090
11409
|
shortCut: "Ctrl + V",
|
|
11091
11410
|
when: (payload) => {
|
|
11092
11411
|
return !payload.isReadonly && payload.editorTextFocus;
|
|
@@ -11096,7 +11415,7 @@ const globalMenus = [
|
|
|
11096
11415
|
}
|
|
11097
11416
|
},
|
|
11098
11417
|
{
|
|
11099
|
-
|
|
11418
|
+
i18nPath: "contextmenu.global.selectAll",
|
|
11100
11419
|
shortCut: "Ctrl + A",
|
|
11101
11420
|
when: (payload) => {
|
|
11102
11421
|
return payload.editorTextFocus;
|
|
@@ -11109,8 +11428,8 @@ const globalMenus = [
|
|
|
11109
11428
|
isDivider: true
|
|
11110
11429
|
},
|
|
11111
11430
|
{
|
|
11431
|
+
i18nPath: "contextmenu.global.print",
|
|
11112
11432
|
icon: "print",
|
|
11113
|
-
name: "\u6253\u5370",
|
|
11114
11433
|
when: () => true,
|
|
11115
11434
|
callback: (command) => {
|
|
11116
11435
|
command.executePrint();
|
|
@@ -11119,7 +11438,7 @@ const globalMenus = [
|
|
|
11119
11438
|
];
|
|
11120
11439
|
const hyperlinkMenus = [
|
|
11121
11440
|
{
|
|
11122
|
-
|
|
11441
|
+
i18nPath: "contextmenu.hyperlink.delete",
|
|
11123
11442
|
when: (payload) => {
|
|
11124
11443
|
var _a;
|
|
11125
11444
|
return ((_a = payload.startElement) == null ? void 0 : _a.type) === ElementType.HYPERLINK;
|
|
@@ -11129,7 +11448,7 @@ const hyperlinkMenus = [
|
|
|
11129
11448
|
}
|
|
11130
11449
|
},
|
|
11131
11450
|
{
|
|
11132
|
-
|
|
11451
|
+
i18nPath: "contextmenu.hyperlink.cancel",
|
|
11133
11452
|
when: (payload) => {
|
|
11134
11453
|
var _a;
|
|
11135
11454
|
return ((_a = payload.startElement) == null ? void 0 : _a.type) === ElementType.HYPERLINK;
|
|
@@ -11139,7 +11458,7 @@ const hyperlinkMenus = [
|
|
|
11139
11458
|
}
|
|
11140
11459
|
},
|
|
11141
11460
|
{
|
|
11142
|
-
|
|
11461
|
+
i18nPath: "contextmenu.hyperlink.edit",
|
|
11143
11462
|
when: (payload) => {
|
|
11144
11463
|
var _a;
|
|
11145
11464
|
return ((_a = payload.startElement) == null ? void 0 : _a.type) === ElementType.HYPERLINK;
|
|
@@ -11155,7 +11474,7 @@ const hyperlinkMenus = [
|
|
|
11155
11474
|
];
|
|
11156
11475
|
const imageMenus = [
|
|
11157
11476
|
{
|
|
11158
|
-
|
|
11477
|
+
i18nPath: "contextmenu.image.change",
|
|
11159
11478
|
icon: "image-change",
|
|
11160
11479
|
when: (payload) => {
|
|
11161
11480
|
var _a;
|
|
@@ -11178,7 +11497,7 @@ const imageMenus = [
|
|
|
11178
11497
|
}
|
|
11179
11498
|
},
|
|
11180
11499
|
{
|
|
11181
|
-
|
|
11500
|
+
i18nPath: "contextmenu.image.saveAs",
|
|
11182
11501
|
icon: "image",
|
|
11183
11502
|
when: (payload) => {
|
|
11184
11503
|
var _a;
|
|
@@ -11189,21 +11508,21 @@ const imageMenus = [
|
|
|
11189
11508
|
}
|
|
11190
11509
|
},
|
|
11191
11510
|
{
|
|
11192
|
-
|
|
11511
|
+
i18nPath: "contextmenu.image.textWrap",
|
|
11193
11512
|
when: (payload) => {
|
|
11194
11513
|
var _a;
|
|
11195
11514
|
return !payload.editorHasSelection && ((_a = payload.startElement) == null ? void 0 : _a.type) === ElementType.IMAGE;
|
|
11196
11515
|
},
|
|
11197
11516
|
childMenus: [
|
|
11198
11517
|
{
|
|
11199
|
-
|
|
11518
|
+
i18nPath: "contextmenu.image.textWrapType.embed",
|
|
11200
11519
|
when: () => true,
|
|
11201
11520
|
callback: (command, context) => {
|
|
11202
11521
|
command.executeChangeImageDisplay(context.startElement, ImageDisplay.BLOCK);
|
|
11203
11522
|
}
|
|
11204
11523
|
},
|
|
11205
11524
|
{
|
|
11206
|
-
|
|
11525
|
+
i18nPath: "contextmenu.image.textWrapType.upDown",
|
|
11207
11526
|
when: () => true,
|
|
11208
11527
|
callback: (command, context) => {
|
|
11209
11528
|
command.executeChangeImageDisplay(context.startElement, ImageDisplay.INLINE);
|
|
@@ -11217,14 +11536,14 @@ const tableMenus = [
|
|
|
11217
11536
|
isDivider: true
|
|
11218
11537
|
},
|
|
11219
11538
|
{
|
|
11220
|
-
|
|
11539
|
+
i18nPath: "contextmenu.table.insertRowCol",
|
|
11221
11540
|
icon: "insert-row-col",
|
|
11222
11541
|
when: (payload) => {
|
|
11223
11542
|
return !payload.isReadonly && payload.isInTable;
|
|
11224
11543
|
},
|
|
11225
11544
|
childMenus: [
|
|
11226
11545
|
{
|
|
11227
|
-
|
|
11546
|
+
i18nPath: "contextmenu.table.insertTopRow",
|
|
11228
11547
|
icon: "insert-top-row",
|
|
11229
11548
|
when: () => true,
|
|
11230
11549
|
callback: (command) => {
|
|
@@ -11232,7 +11551,7 @@ const tableMenus = [
|
|
|
11232
11551
|
}
|
|
11233
11552
|
},
|
|
11234
11553
|
{
|
|
11235
|
-
|
|
11554
|
+
i18nPath: "contextmenu.table.insertBottomRow",
|
|
11236
11555
|
icon: "insert-bottom-row",
|
|
11237
11556
|
when: () => true,
|
|
11238
11557
|
callback: (command) => {
|
|
@@ -11240,7 +11559,7 @@ const tableMenus = [
|
|
|
11240
11559
|
}
|
|
11241
11560
|
},
|
|
11242
11561
|
{
|
|
11243
|
-
|
|
11562
|
+
i18nPath: "contextmenu.table.insertLeftCol",
|
|
11244
11563
|
icon: "insert-left-col",
|
|
11245
11564
|
when: () => true,
|
|
11246
11565
|
callback: (command) => {
|
|
@@ -11248,7 +11567,7 @@ const tableMenus = [
|
|
|
11248
11567
|
}
|
|
11249
11568
|
},
|
|
11250
11569
|
{
|
|
11251
|
-
|
|
11570
|
+
i18nPath: "contextmenu.table.insertRightCol",
|
|
11252
11571
|
icon: "insert-right-col",
|
|
11253
11572
|
when: () => true,
|
|
11254
11573
|
callback: (command) => {
|
|
@@ -11258,14 +11577,14 @@ const tableMenus = [
|
|
|
11258
11577
|
]
|
|
11259
11578
|
},
|
|
11260
11579
|
{
|
|
11261
|
-
|
|
11580
|
+
i18nPath: "contextmenu.table.deleteRowCol",
|
|
11262
11581
|
icon: "delete-row-col",
|
|
11263
11582
|
when: (payload) => {
|
|
11264
11583
|
return !payload.isReadonly && payload.isInTable;
|
|
11265
11584
|
},
|
|
11266
11585
|
childMenus: [
|
|
11267
11586
|
{
|
|
11268
|
-
|
|
11587
|
+
i18nPath: "contextmenu.table.deleteRow",
|
|
11269
11588
|
icon: "delete-row",
|
|
11270
11589
|
when: () => true,
|
|
11271
11590
|
callback: (command) => {
|
|
@@ -11273,7 +11592,7 @@ const tableMenus = [
|
|
|
11273
11592
|
}
|
|
11274
11593
|
},
|
|
11275
11594
|
{
|
|
11276
|
-
|
|
11595
|
+
i18nPath: "contextmenu.table.deleteCol",
|
|
11277
11596
|
icon: "delete-col",
|
|
11278
11597
|
when: () => true,
|
|
11279
11598
|
callback: (command) => {
|
|
@@ -11281,7 +11600,7 @@ const tableMenus = [
|
|
|
11281
11600
|
}
|
|
11282
11601
|
},
|
|
11283
11602
|
{
|
|
11284
|
-
|
|
11603
|
+
i18nPath: "contextmenu.table.deleteTable",
|
|
11285
11604
|
icon: "delete-table",
|
|
11286
11605
|
when: () => true,
|
|
11287
11606
|
callback: (command) => {
|
|
@@ -11291,7 +11610,7 @@ const tableMenus = [
|
|
|
11291
11610
|
]
|
|
11292
11611
|
},
|
|
11293
11612
|
{
|
|
11294
|
-
|
|
11613
|
+
i18nPath: "contextmenu.table.mergeCell",
|
|
11295
11614
|
icon: "merge-cell",
|
|
11296
11615
|
when: (payload) => {
|
|
11297
11616
|
return !payload.isReadonly && payload.isCrossRowCol;
|
|
@@ -11301,7 +11620,7 @@ const tableMenus = [
|
|
|
11301
11620
|
}
|
|
11302
11621
|
},
|
|
11303
11622
|
{
|
|
11304
|
-
|
|
11623
|
+
i18nPath: "contextmenu.table.mergeCancelCell",
|
|
11305
11624
|
icon: "merge-cancel-cell",
|
|
11306
11625
|
when: (payload) => {
|
|
11307
11626
|
return !payload.isReadonly && payload.isInTable;
|
|
@@ -11317,6 +11636,7 @@ class ContextMenu {
|
|
|
11317
11636
|
__publicField(this, "command");
|
|
11318
11637
|
__publicField(this, "range");
|
|
11319
11638
|
__publicField(this, "position");
|
|
11639
|
+
__publicField(this, "i18n");
|
|
11320
11640
|
__publicField(this, "container");
|
|
11321
11641
|
__publicField(this, "contextMenuList");
|
|
11322
11642
|
__publicField(this, "contextMenuContainerList");
|
|
@@ -11361,6 +11681,7 @@ class ContextMenu {
|
|
|
11361
11681
|
this.command = command;
|
|
11362
11682
|
this.range = draw.getRange();
|
|
11363
11683
|
this.position = draw.getPosition();
|
|
11684
|
+
this.i18n = draw.getI18n();
|
|
11364
11685
|
this.container = draw.getContainer();
|
|
11365
11686
|
this.context = null;
|
|
11366
11687
|
this.contextMenuList = [
|
|
@@ -11375,11 +11696,11 @@ class ContextMenu {
|
|
|
11375
11696
|
this._addEvent();
|
|
11376
11697
|
}
|
|
11377
11698
|
_addEvent() {
|
|
11378
|
-
|
|
11699
|
+
this.container.addEventListener("contextmenu", this._proxyContextMenuEvent);
|
|
11379
11700
|
document.addEventListener("mousedown", this._handleEffect);
|
|
11380
11701
|
}
|
|
11381
11702
|
removeEvent() {
|
|
11382
|
-
|
|
11703
|
+
this.container.removeEventListener("contextmenu", this._proxyContextMenuEvent);
|
|
11383
11704
|
document.removeEventListener("mousedown", this._handleEffect);
|
|
11384
11705
|
}
|
|
11385
11706
|
_getContext() {
|
|
@@ -11471,7 +11792,7 @@ class ContextMenu {
|
|
|
11471
11792
|
icon.classList.add(`${EDITOR_PREFIX}-contextmenu-${menu.icon}`);
|
|
11472
11793
|
}
|
|
11473
11794
|
const span = document.createElement("span");
|
|
11474
|
-
const name = this._formatName(menu.name);
|
|
11795
|
+
const name = menu.i18nPath ? this._formatName(this.i18n.t(menu.i18nPath)) : this._formatName(menu.name || "");
|
|
11475
11796
|
span.append(document.createTextNode(name));
|
|
11476
11797
|
menuItem.append(span);
|
|
11477
11798
|
if (menu.shortCut) {
|
|
@@ -11742,7 +12063,8 @@ class Editor {
|
|
|
11742
12063
|
const shortcut = new Shortcut(draw, this.command);
|
|
11743
12064
|
this.register = new Register({
|
|
11744
12065
|
contextMenu,
|
|
11745
|
-
shortcut
|
|
12066
|
+
shortcut,
|
|
12067
|
+
i18n: draw.getI18n()
|
|
11746
12068
|
});
|
|
11747
12069
|
this.destroy = () => {
|
|
11748
12070
|
draw.destroy();
|