@hufe921/canvas-editor 0.9.13 → 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 +305 -61
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +18 -18
- 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/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;
|
|
@@ -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;
|
|
@@ -3642,7 +3659,8 @@ function writeElementList(elementList, options) {
|
|
|
3642
3659
|
dom.innerText = text2.replace(new RegExp(`${ZERO}`, "g"), "\n");
|
|
3643
3660
|
dom.style.fontFamily = element.font || options.defaultFont;
|
|
3644
3661
|
if (element.rowFlex) {
|
|
3645
|
-
|
|
3662
|
+
const isAlignment = element.rowFlex === RowFlex.ALIGNMENT;
|
|
3663
|
+
dom.style.textAlign = isAlignment ? "justify" : element.rowFlex;
|
|
3646
3664
|
}
|
|
3647
3665
|
if (element.color) {
|
|
3648
3666
|
dom.style.color = element.color;
|
|
@@ -3672,18 +3690,23 @@ function writeElementList(elementList, options) {
|
|
|
3672
3690
|
function getElementListByHTML(htmlText, options) {
|
|
3673
3691
|
const elementList = [];
|
|
3674
3692
|
function findTextNode(dom) {
|
|
3675
|
-
var _a;
|
|
3676
3693
|
if (dom.nodeType === 3) {
|
|
3677
|
-
const
|
|
3694
|
+
const parentNode = dom.parentNode;
|
|
3695
|
+
const rowFlex = getElementRowFlex(parentNode);
|
|
3678
3696
|
const value = dom.textContent;
|
|
3679
|
-
|
|
3680
|
-
|
|
3697
|
+
const style = window.getComputedStyle(parentNode);
|
|
3698
|
+
if (value && parentNode.nodeName !== "STYLE") {
|
|
3699
|
+
const element = {
|
|
3681
3700
|
value,
|
|
3682
3701
|
color: style.color,
|
|
3683
3702
|
bold: Number(style.fontWeight) > 500,
|
|
3684
3703
|
italic: style.fontStyle.includes("italic"),
|
|
3685
3704
|
size: Math.floor(Number(style.fontSize.replace("px", "")))
|
|
3686
|
-
}
|
|
3705
|
+
};
|
|
3706
|
+
if (rowFlex !== RowFlex.LEFT) {
|
|
3707
|
+
element.rowFlex = rowFlex;
|
|
3708
|
+
}
|
|
3709
|
+
elementList.push(element);
|
|
3687
3710
|
}
|
|
3688
3711
|
} else if (dom.nodeType === 1) {
|
|
3689
3712
|
const childNodes = dom.childNodes;
|
|
@@ -3729,39 +3752,35 @@ function getElementListByHTML(htmlText, options) {
|
|
|
3729
3752
|
colgroup: [],
|
|
3730
3753
|
trList: []
|
|
3731
3754
|
};
|
|
3732
|
-
|
|
3733
|
-
tableElement.querySelectorAll("tr").forEach((trElement, trIndex) => {
|
|
3755
|
+
tableElement.querySelectorAll("tr").forEach((trElement) => {
|
|
3734
3756
|
const trHeightStr = window.getComputedStyle(trElement).height.replace("px", "");
|
|
3735
3757
|
const tr = {
|
|
3736
3758
|
height: Number(trHeightStr),
|
|
3737
3759
|
tdList: []
|
|
3738
3760
|
};
|
|
3739
|
-
trElement.querySelectorAll("td").forEach((tdElement) => {
|
|
3740
|
-
const
|
|
3741
|
-
const rowspan = tdElement.rowSpan;
|
|
3742
|
-
if (trIndex === 0) {
|
|
3743
|
-
tdCount += colspan;
|
|
3744
|
-
}
|
|
3761
|
+
trElement.querySelectorAll("th,td").forEach((tdElement) => {
|
|
3762
|
+
const tableCell = tdElement;
|
|
3745
3763
|
const td = {
|
|
3746
|
-
colspan,
|
|
3747
|
-
rowspan,
|
|
3764
|
+
colspan: tableCell.colSpan,
|
|
3765
|
+
rowspan: tableCell.rowSpan,
|
|
3748
3766
|
value: [{
|
|
3749
|
-
value:
|
|
3767
|
+
value: tableCell.innerText
|
|
3750
3768
|
}]
|
|
3751
3769
|
};
|
|
3752
3770
|
tr.tdList.push(td);
|
|
3753
3771
|
});
|
|
3754
|
-
|
|
3772
|
+
if (tr.tdList.length) {
|
|
3773
|
+
element.trList.push(tr);
|
|
3774
|
+
}
|
|
3755
3775
|
});
|
|
3756
|
-
if (
|
|
3776
|
+
if (element.trList.length) {
|
|
3777
|
+
const tdCount = element.trList[0].tdList.reduce((pre, cur) => pre + cur.colspan, 0);
|
|
3757
3778
|
const width = Math.ceil(options.innerWidth / tdCount);
|
|
3758
3779
|
for (let i = 0; i < tdCount; i++) {
|
|
3759
3780
|
element.colgroup.push({
|
|
3760
3781
|
width
|
|
3761
3782
|
});
|
|
3762
3783
|
}
|
|
3763
|
-
}
|
|
3764
|
-
if (element.colgroup) {
|
|
3765
3784
|
elementList.push(element);
|
|
3766
3785
|
}
|
|
3767
3786
|
} else if (node.nodeName === "INPUT" && node.type === ControlComponent.CHECKBOX) {
|
|
@@ -7699,6 +7718,69 @@ class Previewer {
|
|
|
7699
7718
|
this.resizerSelection.style.display = "none";
|
|
7700
7719
|
}
|
|
7701
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
|
+
};
|
|
7702
7784
|
class DatePicker {
|
|
7703
7785
|
constructor(options = {}) {
|
|
7704
7786
|
__publicField(this, "options");
|
|
@@ -7707,9 +7789,11 @@ class DatePicker {
|
|
|
7707
7789
|
__publicField(this, "renderOptions");
|
|
7708
7790
|
__publicField(this, "isDatePicker");
|
|
7709
7791
|
__publicField(this, "pickDate");
|
|
7792
|
+
__publicField(this, "lang");
|
|
7710
7793
|
this.options = __spreadValues({
|
|
7711
7794
|
mountDom: document.body
|
|
7712
7795
|
}, options);
|
|
7796
|
+
this.lang = datePicker$1;
|
|
7713
7797
|
this.now = new Date();
|
|
7714
7798
|
this.dom = this._createDom();
|
|
7715
7799
|
this.renderOptions = null;
|
|
@@ -7745,7 +7829,8 @@ class DatePicker {
|
|
|
7745
7829
|
datePickerTitle.append(nextYearTitle);
|
|
7746
7830
|
const datePickerWeek = document.createElement("div");
|
|
7747
7831
|
datePickerWeek.classList.add(`${EDITOR_PREFIX}-date-week`);
|
|
7748
|
-
const
|
|
7832
|
+
const { weeks: { sun, mon, tue, wed, thu, fri, sat } } = this.lang;
|
|
7833
|
+
const weekList = [sun, mon, tue, wed, thu, fri, sat];
|
|
7749
7834
|
weekList.forEach((week) => {
|
|
7750
7835
|
const weekDom = document.createElement("span");
|
|
7751
7836
|
weekDom.innerText = `${week}`;
|
|
@@ -7761,7 +7846,7 @@ class DatePicker {
|
|
|
7761
7846
|
let hourTime;
|
|
7762
7847
|
let minuteTime;
|
|
7763
7848
|
let secondTime;
|
|
7764
|
-
const timeList = [
|
|
7849
|
+
const timeList = [this.lang.hour, this.lang.minute, this.lang.second];
|
|
7765
7850
|
timeList.forEach((t, i) => {
|
|
7766
7851
|
const li = document.createElement("li");
|
|
7767
7852
|
const timeText = document.createElement("span");
|
|
@@ -7791,13 +7876,13 @@ class DatePicker {
|
|
|
7791
7876
|
datePickerMenu.classList.add(`${EDITOR_PREFIX}-date-menu`);
|
|
7792
7877
|
const timeMenu = document.createElement("button");
|
|
7793
7878
|
timeMenu.classList.add(`${EDITOR_PREFIX}-date-menu__time`);
|
|
7794
|
-
timeMenu.innerText =
|
|
7879
|
+
timeMenu.innerText = this.lang.timeSelect;
|
|
7795
7880
|
const nowMenu = document.createElement("button");
|
|
7796
7881
|
nowMenu.classList.add(`${EDITOR_PREFIX}-date-menu__now`);
|
|
7797
|
-
nowMenu.innerText =
|
|
7882
|
+
nowMenu.innerText = this.lang.now;
|
|
7798
7883
|
const submitMenu = document.createElement("button");
|
|
7799
7884
|
submitMenu.classList.add(`${EDITOR_PREFIX}-date-menu__submit`);
|
|
7800
|
-
submitMenu.innerText =
|
|
7885
|
+
submitMenu.innerText = this.lang.confirm;
|
|
7801
7886
|
datePickerMenu.append(timeMenu);
|
|
7802
7887
|
datePickerMenu.append(nowMenu);
|
|
7803
7888
|
datePickerMenu.append(submitMenu);
|
|
@@ -7808,6 +7893,7 @@ class DatePicker {
|
|
|
7808
7893
|
return {
|
|
7809
7894
|
container: datePickerContainer,
|
|
7810
7895
|
dateWrap,
|
|
7896
|
+
datePickerWeek,
|
|
7811
7897
|
timeWrap,
|
|
7812
7898
|
title: {
|
|
7813
7899
|
preYear: preYearTitle,
|
|
@@ -7906,6 +7992,22 @@ class DatePicker {
|
|
|
7906
7992
|
}
|
|
7907
7993
|
this.pickDate = new Date(this.now);
|
|
7908
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
|
+
}
|
|
7909
8011
|
_update() {
|
|
7910
8012
|
const localDate = new Date();
|
|
7911
8013
|
const localYear = localDate.getFullYear();
|
|
@@ -7921,7 +8023,7 @@ class DatePicker {
|
|
|
7921
8023
|
}
|
|
7922
8024
|
const year = this.now.getFullYear();
|
|
7923
8025
|
const month = this.now.getMonth() + 1;
|
|
7924
|
-
this.dom.title.now.innerText = `${year}
|
|
8026
|
+
this.dom.title.now.innerText = `${year}${this.lang.year} ${String(month).padStart(2, "0")}${this.lang.month}`;
|
|
7925
8027
|
const curDate = new Date(year, month, 0);
|
|
7926
8028
|
const curDay = curDate.getDate();
|
|
7927
8029
|
let curWeek = new Date(year, month - 1, 1).getDay();
|
|
@@ -7975,11 +8077,11 @@ class DatePicker {
|
|
|
7975
8077
|
if (this.isDatePicker) {
|
|
7976
8078
|
this.dom.dateWrap.classList.add("active");
|
|
7977
8079
|
this.dom.timeWrap.classList.remove("active");
|
|
7978
|
-
this.dom.menu.time.innerText =
|
|
8080
|
+
this.dom.menu.time.innerText = this.lang.timeSelect;
|
|
7979
8081
|
} else {
|
|
7980
8082
|
this.dom.dateWrap.classList.remove("active");
|
|
7981
8083
|
this.dom.timeWrap.classList.add("active");
|
|
7982
|
-
this.dom.menu.time.innerText =
|
|
8084
|
+
this.dom.menu.time.innerText = this.lang.return;
|
|
7983
8085
|
this._setTimePick();
|
|
7984
8086
|
}
|
|
7985
8087
|
}
|
|
@@ -8087,6 +8189,10 @@ class DatePicker {
|
|
|
8087
8189
|
}
|
|
8088
8190
|
render(option) {
|
|
8089
8191
|
this.renderOptions = option;
|
|
8192
|
+
if (this.options.getLang) {
|
|
8193
|
+
this.lang = this.options.getLang();
|
|
8194
|
+
this._setLang();
|
|
8195
|
+
}
|
|
8090
8196
|
this._setValue();
|
|
8091
8197
|
this._update();
|
|
8092
8198
|
this._setPosition();
|
|
@@ -8105,9 +8211,31 @@ class DateParticle {
|
|
|
8105
8211
|
__publicField(this, "datePicker");
|
|
8106
8212
|
this.draw = draw;
|
|
8107
8213
|
this.range = draw.getRange();
|
|
8214
|
+
const i18n = draw.getI18n();
|
|
8215
|
+
const t = i18n.t.bind(i18n);
|
|
8108
8216
|
this.datePicker = new DatePicker({
|
|
8109
8217
|
mountDom: draw.getContainer(),
|
|
8110
|
-
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
|
+
})
|
|
8111
8239
|
});
|
|
8112
8240
|
}
|
|
8113
8241
|
_setValue(date) {
|
|
@@ -8340,6 +8468,102 @@ class BlockParticle {
|
|
|
8340
8468
|
});
|
|
8341
8469
|
}
|
|
8342
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
|
+
}
|
|
8343
8567
|
class Draw {
|
|
8344
8568
|
constructor(rootContainer, options, elementList, listener) {
|
|
8345
8569
|
__publicField(this, "container");
|
|
@@ -8352,6 +8576,7 @@ class Draw {
|
|
|
8352
8576
|
__publicField(this, "position");
|
|
8353
8577
|
__publicField(this, "elementList");
|
|
8354
8578
|
__publicField(this, "listener");
|
|
8579
|
+
__publicField(this, "i18n");
|
|
8355
8580
|
__publicField(this, "canvasEvent");
|
|
8356
8581
|
__publicField(this, "globalEvent");
|
|
8357
8582
|
__publicField(this, "cursor");
|
|
@@ -8400,6 +8625,7 @@ class Draw {
|
|
|
8400
8625
|
this._formatContainer();
|
|
8401
8626
|
this.pageContainer = this._createPageContainer();
|
|
8402
8627
|
this._createPage(0);
|
|
8628
|
+
this.i18n = new I18n();
|
|
8403
8629
|
this.historyManager = new HistoryManager();
|
|
8404
8630
|
this.position = new Position(this);
|
|
8405
8631
|
this.range = new RangeManager(this);
|
|
@@ -8631,6 +8857,9 @@ class Draw {
|
|
|
8631
8857
|
getWorkerManager() {
|
|
8632
8858
|
return this.workerManager;
|
|
8633
8859
|
}
|
|
8860
|
+
getI18n() {
|
|
8861
|
+
return this.i18n;
|
|
8862
|
+
}
|
|
8634
8863
|
getRowCount() {
|
|
8635
8864
|
return this.rowList.length;
|
|
8636
8865
|
}
|
|
@@ -8778,7 +9007,7 @@ class Draw {
|
|
|
8778
9007
|
return `${el.italic ? "italic " : ""}${el.bold ? "bold " : ""}${size * scale}px ${font}`;
|
|
8779
9008
|
}
|
|
8780
9009
|
_computeRowList(innerWidth, elementList) {
|
|
8781
|
-
var _a, _b, _c;
|
|
9010
|
+
var _a, _b, _c, _d;
|
|
8782
9011
|
const { defaultSize, defaultRowMargin, scale, tdPadding, defaultTabWidth } = this.options;
|
|
8783
9012
|
const defaultBasicRowMarginHeight = this.getDefaultBasicRowMarginHeight();
|
|
8784
9013
|
const tdGap = tdPadding * 2;
|
|
@@ -8977,7 +9206,7 @@ class Draw {
|
|
|
8977
9206
|
height,
|
|
8978
9207
|
elementList: [rowElement],
|
|
8979
9208
|
ascent,
|
|
8980
|
-
rowFlex:
|
|
9209
|
+
rowFlex: (_d = elementList[i + 1]) == null ? void 0 : _d.rowFlex,
|
|
8981
9210
|
isPageBreak: element.type === ElementType.PAGE_BREAK
|
|
8982
9211
|
});
|
|
8983
9212
|
} else {
|
|
@@ -9387,6 +9616,7 @@ const _Command = class {
|
|
|
9387
9616
|
_Command.setPaperMargin = adapt.setPaperMargin.bind(adapt);
|
|
9388
9617
|
_Command.insertElementList = adapt.insertElementList.bind(adapt);
|
|
9389
9618
|
_Command.removeControl = adapt.removeControl.bind(adapt);
|
|
9619
|
+
_Command.setLocale = adapt.setLocale.bind(adapt);
|
|
9390
9620
|
}
|
|
9391
9621
|
executeMode(payload) {
|
|
9392
9622
|
return _Command.mode(payload);
|
|
@@ -9595,6 +9825,9 @@ const _Command = class {
|
|
|
9595
9825
|
executeRemoveControl() {
|
|
9596
9826
|
return _Command.removeControl();
|
|
9597
9827
|
}
|
|
9828
|
+
executeSetLocale(payload) {
|
|
9829
|
+
return _Command.setLocale(payload);
|
|
9830
|
+
}
|
|
9598
9831
|
};
|
|
9599
9832
|
let Command = _Command;
|
|
9600
9833
|
__publicField(Command, "mode");
|
|
@@ -9666,6 +9899,7 @@ __publicField(Command, "getPaperMargin");
|
|
|
9666
9899
|
__publicField(Command, "setPaperMargin");
|
|
9667
9900
|
__publicField(Command, "insertElementList");
|
|
9668
9901
|
__publicField(Command, "removeControl");
|
|
9902
|
+
__publicField(Command, "setLocale");
|
|
9669
9903
|
const defaultWatermarkOption = {
|
|
9670
9904
|
data: "",
|
|
9671
9905
|
color: "#AEB5C0",
|
|
@@ -9721,6 +9955,7 @@ class CommandAdapt {
|
|
|
9721
9955
|
__publicField(this, "control");
|
|
9722
9956
|
__publicField(this, "workerManager");
|
|
9723
9957
|
__publicField(this, "searchManager");
|
|
9958
|
+
__publicField(this, "i18n");
|
|
9724
9959
|
this.draw = draw;
|
|
9725
9960
|
this.range = draw.getRange();
|
|
9726
9961
|
this.position = draw.getPosition();
|
|
@@ -9731,6 +9966,7 @@ class CommandAdapt {
|
|
|
9731
9966
|
this.control = draw.getControl();
|
|
9732
9967
|
this.workerManager = draw.getWorkerManager();
|
|
9733
9968
|
this.searchManager = draw.getSearch();
|
|
9969
|
+
this.i18n = draw.getI18n();
|
|
9734
9970
|
}
|
|
9735
9971
|
mode(payload) {
|
|
9736
9972
|
const mode = this.draw.getMode();
|
|
@@ -11095,6 +11331,9 @@ class CommandAdapt {
|
|
|
11095
11331
|
curIndex: newIndex
|
|
11096
11332
|
});
|
|
11097
11333
|
}
|
|
11334
|
+
setLocale(payload) {
|
|
11335
|
+
this.i18n.setLocale(payload);
|
|
11336
|
+
}
|
|
11098
11337
|
}
|
|
11099
11338
|
class Listener {
|
|
11100
11339
|
constructor() {
|
|
@@ -11122,9 +11361,11 @@ class Register {
|
|
|
11122
11361
|
constructor(payload) {
|
|
11123
11362
|
__publicField(this, "contextMenuList");
|
|
11124
11363
|
__publicField(this, "shortcutList");
|
|
11125
|
-
|
|
11364
|
+
__publicField(this, "langMap");
|
|
11365
|
+
const { contextMenu, shortcut, i18n } = payload;
|
|
11126
11366
|
this.contextMenuList = contextMenu.registerContextMenuList.bind(contextMenu);
|
|
11127
11367
|
this.shortcutList = shortcut.registerShortcutList.bind(shortcut);
|
|
11368
|
+
this.langMap = i18n.registerLangMap.bind(i18n);
|
|
11128
11369
|
}
|
|
11129
11370
|
}
|
|
11130
11371
|
const NAME_PLACEHOLDER = {
|
|
@@ -11132,7 +11373,7 @@ const NAME_PLACEHOLDER = {
|
|
|
11132
11373
|
};
|
|
11133
11374
|
const controlMenus = [
|
|
11134
11375
|
{
|
|
11135
|
-
|
|
11376
|
+
i18nPath: "contextmenu.control.delete",
|
|
11136
11377
|
when: (payload) => {
|
|
11137
11378
|
var _a;
|
|
11138
11379
|
return !payload.editorHasSelection && ((_a = payload.startElement) == null ? void 0 : _a.type) === ElementType.CONTROL;
|
|
@@ -11144,7 +11385,7 @@ const controlMenus = [
|
|
|
11144
11385
|
];
|
|
11145
11386
|
const globalMenus = [
|
|
11146
11387
|
{
|
|
11147
|
-
|
|
11388
|
+
i18nPath: "contextmenu.global.cut",
|
|
11148
11389
|
shortCut: "Ctrl + X",
|
|
11149
11390
|
when: (payload) => {
|
|
11150
11391
|
return !payload.isReadonly;
|
|
@@ -11154,7 +11395,7 @@ const globalMenus = [
|
|
|
11154
11395
|
}
|
|
11155
11396
|
},
|
|
11156
11397
|
{
|
|
11157
|
-
|
|
11398
|
+
i18nPath: "contextmenu.global.copy",
|
|
11158
11399
|
shortCut: "Ctrl + C",
|
|
11159
11400
|
when: (payload) => {
|
|
11160
11401
|
return payload.editorHasSelection;
|
|
@@ -11164,7 +11405,7 @@ const globalMenus = [
|
|
|
11164
11405
|
}
|
|
11165
11406
|
},
|
|
11166
11407
|
{
|
|
11167
|
-
|
|
11408
|
+
i18nPath: "contextmenu.global.paste",
|
|
11168
11409
|
shortCut: "Ctrl + V",
|
|
11169
11410
|
when: (payload) => {
|
|
11170
11411
|
return !payload.isReadonly && payload.editorTextFocus;
|
|
@@ -11174,7 +11415,7 @@ const globalMenus = [
|
|
|
11174
11415
|
}
|
|
11175
11416
|
},
|
|
11176
11417
|
{
|
|
11177
|
-
|
|
11418
|
+
i18nPath: "contextmenu.global.selectAll",
|
|
11178
11419
|
shortCut: "Ctrl + A",
|
|
11179
11420
|
when: (payload) => {
|
|
11180
11421
|
return payload.editorTextFocus;
|
|
@@ -11187,8 +11428,8 @@ const globalMenus = [
|
|
|
11187
11428
|
isDivider: true
|
|
11188
11429
|
},
|
|
11189
11430
|
{
|
|
11431
|
+
i18nPath: "contextmenu.global.print",
|
|
11190
11432
|
icon: "print",
|
|
11191
|
-
name: "\u6253\u5370",
|
|
11192
11433
|
when: () => true,
|
|
11193
11434
|
callback: (command) => {
|
|
11194
11435
|
command.executePrint();
|
|
@@ -11197,7 +11438,7 @@ const globalMenus = [
|
|
|
11197
11438
|
];
|
|
11198
11439
|
const hyperlinkMenus = [
|
|
11199
11440
|
{
|
|
11200
|
-
|
|
11441
|
+
i18nPath: "contextmenu.hyperlink.delete",
|
|
11201
11442
|
when: (payload) => {
|
|
11202
11443
|
var _a;
|
|
11203
11444
|
return ((_a = payload.startElement) == null ? void 0 : _a.type) === ElementType.HYPERLINK;
|
|
@@ -11207,7 +11448,7 @@ const hyperlinkMenus = [
|
|
|
11207
11448
|
}
|
|
11208
11449
|
},
|
|
11209
11450
|
{
|
|
11210
|
-
|
|
11451
|
+
i18nPath: "contextmenu.hyperlink.cancel",
|
|
11211
11452
|
when: (payload) => {
|
|
11212
11453
|
var _a;
|
|
11213
11454
|
return ((_a = payload.startElement) == null ? void 0 : _a.type) === ElementType.HYPERLINK;
|
|
@@ -11217,7 +11458,7 @@ const hyperlinkMenus = [
|
|
|
11217
11458
|
}
|
|
11218
11459
|
},
|
|
11219
11460
|
{
|
|
11220
|
-
|
|
11461
|
+
i18nPath: "contextmenu.hyperlink.edit",
|
|
11221
11462
|
when: (payload) => {
|
|
11222
11463
|
var _a;
|
|
11223
11464
|
return ((_a = payload.startElement) == null ? void 0 : _a.type) === ElementType.HYPERLINK;
|
|
@@ -11233,7 +11474,7 @@ const hyperlinkMenus = [
|
|
|
11233
11474
|
];
|
|
11234
11475
|
const imageMenus = [
|
|
11235
11476
|
{
|
|
11236
|
-
|
|
11477
|
+
i18nPath: "contextmenu.image.change",
|
|
11237
11478
|
icon: "image-change",
|
|
11238
11479
|
when: (payload) => {
|
|
11239
11480
|
var _a;
|
|
@@ -11256,7 +11497,7 @@ const imageMenus = [
|
|
|
11256
11497
|
}
|
|
11257
11498
|
},
|
|
11258
11499
|
{
|
|
11259
|
-
|
|
11500
|
+
i18nPath: "contextmenu.image.saveAs",
|
|
11260
11501
|
icon: "image",
|
|
11261
11502
|
when: (payload) => {
|
|
11262
11503
|
var _a;
|
|
@@ -11267,21 +11508,21 @@ const imageMenus = [
|
|
|
11267
11508
|
}
|
|
11268
11509
|
},
|
|
11269
11510
|
{
|
|
11270
|
-
|
|
11511
|
+
i18nPath: "contextmenu.image.textWrap",
|
|
11271
11512
|
when: (payload) => {
|
|
11272
11513
|
var _a;
|
|
11273
11514
|
return !payload.editorHasSelection && ((_a = payload.startElement) == null ? void 0 : _a.type) === ElementType.IMAGE;
|
|
11274
11515
|
},
|
|
11275
11516
|
childMenus: [
|
|
11276
11517
|
{
|
|
11277
|
-
|
|
11518
|
+
i18nPath: "contextmenu.image.textWrapType.embed",
|
|
11278
11519
|
when: () => true,
|
|
11279
11520
|
callback: (command, context) => {
|
|
11280
11521
|
command.executeChangeImageDisplay(context.startElement, ImageDisplay.BLOCK);
|
|
11281
11522
|
}
|
|
11282
11523
|
},
|
|
11283
11524
|
{
|
|
11284
|
-
|
|
11525
|
+
i18nPath: "contextmenu.image.textWrapType.upDown",
|
|
11285
11526
|
when: () => true,
|
|
11286
11527
|
callback: (command, context) => {
|
|
11287
11528
|
command.executeChangeImageDisplay(context.startElement, ImageDisplay.INLINE);
|
|
@@ -11295,14 +11536,14 @@ const tableMenus = [
|
|
|
11295
11536
|
isDivider: true
|
|
11296
11537
|
},
|
|
11297
11538
|
{
|
|
11298
|
-
|
|
11539
|
+
i18nPath: "contextmenu.table.insertRowCol",
|
|
11299
11540
|
icon: "insert-row-col",
|
|
11300
11541
|
when: (payload) => {
|
|
11301
11542
|
return !payload.isReadonly && payload.isInTable;
|
|
11302
11543
|
},
|
|
11303
11544
|
childMenus: [
|
|
11304
11545
|
{
|
|
11305
|
-
|
|
11546
|
+
i18nPath: "contextmenu.table.insertTopRow",
|
|
11306
11547
|
icon: "insert-top-row",
|
|
11307
11548
|
when: () => true,
|
|
11308
11549
|
callback: (command) => {
|
|
@@ -11310,7 +11551,7 @@ const tableMenus = [
|
|
|
11310
11551
|
}
|
|
11311
11552
|
},
|
|
11312
11553
|
{
|
|
11313
|
-
|
|
11554
|
+
i18nPath: "contextmenu.table.insertBottomRow",
|
|
11314
11555
|
icon: "insert-bottom-row",
|
|
11315
11556
|
when: () => true,
|
|
11316
11557
|
callback: (command) => {
|
|
@@ -11318,7 +11559,7 @@ const tableMenus = [
|
|
|
11318
11559
|
}
|
|
11319
11560
|
},
|
|
11320
11561
|
{
|
|
11321
|
-
|
|
11562
|
+
i18nPath: "contextmenu.table.insertLeftCol",
|
|
11322
11563
|
icon: "insert-left-col",
|
|
11323
11564
|
when: () => true,
|
|
11324
11565
|
callback: (command) => {
|
|
@@ -11326,7 +11567,7 @@ const tableMenus = [
|
|
|
11326
11567
|
}
|
|
11327
11568
|
},
|
|
11328
11569
|
{
|
|
11329
|
-
|
|
11570
|
+
i18nPath: "contextmenu.table.insertRightCol",
|
|
11330
11571
|
icon: "insert-right-col",
|
|
11331
11572
|
when: () => true,
|
|
11332
11573
|
callback: (command) => {
|
|
@@ -11336,14 +11577,14 @@ const tableMenus = [
|
|
|
11336
11577
|
]
|
|
11337
11578
|
},
|
|
11338
11579
|
{
|
|
11339
|
-
|
|
11580
|
+
i18nPath: "contextmenu.table.deleteRowCol",
|
|
11340
11581
|
icon: "delete-row-col",
|
|
11341
11582
|
when: (payload) => {
|
|
11342
11583
|
return !payload.isReadonly && payload.isInTable;
|
|
11343
11584
|
},
|
|
11344
11585
|
childMenus: [
|
|
11345
11586
|
{
|
|
11346
|
-
|
|
11587
|
+
i18nPath: "contextmenu.table.deleteRow",
|
|
11347
11588
|
icon: "delete-row",
|
|
11348
11589
|
when: () => true,
|
|
11349
11590
|
callback: (command) => {
|
|
@@ -11351,7 +11592,7 @@ const tableMenus = [
|
|
|
11351
11592
|
}
|
|
11352
11593
|
},
|
|
11353
11594
|
{
|
|
11354
|
-
|
|
11595
|
+
i18nPath: "contextmenu.table.deleteCol",
|
|
11355
11596
|
icon: "delete-col",
|
|
11356
11597
|
when: () => true,
|
|
11357
11598
|
callback: (command) => {
|
|
@@ -11359,7 +11600,7 @@ const tableMenus = [
|
|
|
11359
11600
|
}
|
|
11360
11601
|
},
|
|
11361
11602
|
{
|
|
11362
|
-
|
|
11603
|
+
i18nPath: "contextmenu.table.deleteTable",
|
|
11363
11604
|
icon: "delete-table",
|
|
11364
11605
|
when: () => true,
|
|
11365
11606
|
callback: (command) => {
|
|
@@ -11369,7 +11610,7 @@ const tableMenus = [
|
|
|
11369
11610
|
]
|
|
11370
11611
|
},
|
|
11371
11612
|
{
|
|
11372
|
-
|
|
11613
|
+
i18nPath: "contextmenu.table.mergeCell",
|
|
11373
11614
|
icon: "merge-cell",
|
|
11374
11615
|
when: (payload) => {
|
|
11375
11616
|
return !payload.isReadonly && payload.isCrossRowCol;
|
|
@@ -11379,7 +11620,7 @@ const tableMenus = [
|
|
|
11379
11620
|
}
|
|
11380
11621
|
},
|
|
11381
11622
|
{
|
|
11382
|
-
|
|
11623
|
+
i18nPath: "contextmenu.table.mergeCancelCell",
|
|
11383
11624
|
icon: "merge-cancel-cell",
|
|
11384
11625
|
when: (payload) => {
|
|
11385
11626
|
return !payload.isReadonly && payload.isInTable;
|
|
@@ -11395,6 +11636,7 @@ class ContextMenu {
|
|
|
11395
11636
|
__publicField(this, "command");
|
|
11396
11637
|
__publicField(this, "range");
|
|
11397
11638
|
__publicField(this, "position");
|
|
11639
|
+
__publicField(this, "i18n");
|
|
11398
11640
|
__publicField(this, "container");
|
|
11399
11641
|
__publicField(this, "contextMenuList");
|
|
11400
11642
|
__publicField(this, "contextMenuContainerList");
|
|
@@ -11439,6 +11681,7 @@ class ContextMenu {
|
|
|
11439
11681
|
this.command = command;
|
|
11440
11682
|
this.range = draw.getRange();
|
|
11441
11683
|
this.position = draw.getPosition();
|
|
11684
|
+
this.i18n = draw.getI18n();
|
|
11442
11685
|
this.container = draw.getContainer();
|
|
11443
11686
|
this.context = null;
|
|
11444
11687
|
this.contextMenuList = [
|
|
@@ -11549,7 +11792,7 @@ class ContextMenu {
|
|
|
11549
11792
|
icon.classList.add(`${EDITOR_PREFIX}-contextmenu-${menu.icon}`);
|
|
11550
11793
|
}
|
|
11551
11794
|
const span = document.createElement("span");
|
|
11552
|
-
const name = this._formatName(menu.name);
|
|
11795
|
+
const name = menu.i18nPath ? this._formatName(this.i18n.t(menu.i18nPath)) : this._formatName(menu.name || "");
|
|
11553
11796
|
span.append(document.createTextNode(name));
|
|
11554
11797
|
menuItem.append(span);
|
|
11555
11798
|
if (menu.shortCut) {
|
|
@@ -11820,7 +12063,8 @@ class Editor {
|
|
|
11820
12063
|
const shortcut = new Shortcut(draw, this.command);
|
|
11821
12064
|
this.register = new Register({
|
|
11822
12065
|
contextMenu,
|
|
11823
|
-
shortcut
|
|
12066
|
+
shortcut,
|
|
12067
|
+
i18n: draw.getI18n()
|
|
11824
12068
|
});
|
|
11825
12069
|
this.destroy = () => {
|
|
11826
12070
|
draw.destroy();
|