@hufe921/canvas-editor 0.9.79 → 0.9.80
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 +25 -0
- package/dist/canvas-editor.es.js +2218 -1860
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +37 -37
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/command/Command.d.ts +1 -0
- package/dist/src/editor/core/command/CommandAdapt.d.ts +1 -0
- package/dist/src/editor/core/draw/control/date/DateControl.d.ts +24 -0
- package/dist/src/editor/core/draw/particle/date/DatePicker.d.ts +8 -7
- package/dist/src/editor/dataset/enum/Control.d.ts +2 -1
- package/dist/src/editor/interface/Control.d.ts +4 -5
- 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.80";
|
|
27
27
|
var MaxHeightRatio;
|
|
28
28
|
(function(MaxHeightRatio2) {
|
|
29
29
|
MaxHeightRatio2["HALF"] = "half";
|
|
@@ -3735,6 +3735,7 @@ var ControlType;
|
|
|
3735
3735
|
ControlType2["SELECT"] = "select";
|
|
3736
3736
|
ControlType2["CHECKBOX"] = "checkbox";
|
|
3737
3737
|
ControlType2["RADIO"] = "radio";
|
|
3738
|
+
ControlType2["DATE"] = "date";
|
|
3738
3739
|
})(ControlType || (ControlType = {}));
|
|
3739
3740
|
var ControlComponent;
|
|
3740
3741
|
(function(ControlComponent2) {
|
|
@@ -6086,13 +6087,21 @@ function del(evt, host) {
|
|
|
6086
6087
|
if (!cursorPosition)
|
|
6087
6088
|
return;
|
|
6088
6089
|
const { index: index2 } = cursorPosition;
|
|
6089
|
-
const
|
|
6090
|
-
if (
|
|
6091
|
-
draw.spliceElementList(elementList,
|
|
6090
|
+
const positionContext = position.getPositionContext();
|
|
6091
|
+
if (positionContext.isDirectHit && positionContext.isImage) {
|
|
6092
|
+
draw.spliceElementList(elementList, index2, 1);
|
|
6093
|
+
curIndex = index2 - 1;
|
|
6092
6094
|
} else {
|
|
6093
|
-
|
|
6095
|
+
const isCollapsed = rangeManager.getIsCollapsed();
|
|
6096
|
+
if (!isCollapsed) {
|
|
6097
|
+
draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex);
|
|
6098
|
+
} else {
|
|
6099
|
+
if (!elementList[index2 + 1])
|
|
6100
|
+
return;
|
|
6101
|
+
draw.spliceElementList(elementList, index2 + 1, 1);
|
|
6102
|
+
}
|
|
6103
|
+
curIndex = isCollapsed ? index2 : startIndex;
|
|
6094
6104
|
}
|
|
6095
|
-
curIndex = isCollapsed ? index2 : startIndex;
|
|
6096
6105
|
}
|
|
6097
6106
|
if (curIndex === null)
|
|
6098
6107
|
return;
|
|
@@ -6127,7 +6136,10 @@ function enter(evt, host) {
|
|
|
6127
6136
|
formatElementContext(elementList, [enterText], startIndex);
|
|
6128
6137
|
const copyElement = getAnchorElement(elementList, endIndex);
|
|
6129
6138
|
if (copyElement) {
|
|
6130
|
-
const copyAttr = [...
|
|
6139
|
+
const copyAttr = [...EDITOR_ROW_ATTR];
|
|
6140
|
+
if (copyElement.controlComponent !== ControlComponent.POSTFIX) {
|
|
6141
|
+
copyAttr.push(...EDITOR_ELEMENT_STYLE_ATTR);
|
|
6142
|
+
}
|
|
6131
6143
|
copyAttr.forEach((attr) => {
|
|
6132
6144
|
const value = copyElement[attr];
|
|
6133
6145
|
if (value !== void 0) {
|
|
@@ -6447,7 +6459,7 @@ function tab(evt, host) {
|
|
|
6447
6459
|
evt.preventDefault();
|
|
6448
6460
|
const control = draw.getControl();
|
|
6449
6461
|
const activeControl = control.getActiveControl();
|
|
6450
|
-
if (activeControl) {
|
|
6462
|
+
if (activeControl && control.getIsRangeWithinControl()) {
|
|
6451
6463
|
control.initNextControl({
|
|
6452
6464
|
direction: evt.shiftKey ? MoveDirection.UP : MoveDirection.DOWN
|
|
6453
6465
|
});
|
|
@@ -7746,7 +7758,7 @@ class Position {
|
|
|
7746
7758
|
this.positionContext = payload;
|
|
7747
7759
|
}
|
|
7748
7760
|
getPositionByXY(payload) {
|
|
7749
|
-
var _a, _b, _c;
|
|
7761
|
+
var _a, _b, _c, _d, _e;
|
|
7750
7762
|
const { x, y, isTable } = payload;
|
|
7751
7763
|
let { elementList, positionList } = payload;
|
|
7752
7764
|
if (!elementList) {
|
|
@@ -7908,7 +7920,8 @@ class Position {
|
|
|
7908
7920
|
}
|
|
7909
7921
|
if (!isLastArea) {
|
|
7910
7922
|
const header = this.draw.getHeader();
|
|
7911
|
-
const
|
|
7923
|
+
const headerHeight = header.getHeight();
|
|
7924
|
+
const headerBottomY = header.getHeaderTop() + headerHeight;
|
|
7912
7925
|
const footer = this.draw.getFooter();
|
|
7913
7926
|
const pageHeight = this.draw.getHeight();
|
|
7914
7927
|
const footerTopY = pageHeight - (footer.getFooterBottom() + footer.getHeight());
|
|
@@ -7933,14 +7946,45 @@ class Position {
|
|
|
7933
7946
|
};
|
|
7934
7947
|
}
|
|
7935
7948
|
}
|
|
7949
|
+
const margins = this.draw.getMargins();
|
|
7950
|
+
if (y <= margins[1]) {
|
|
7951
|
+
for (let p = 0; p < positionList.length; p++) {
|
|
7952
|
+
const position = positionList[p];
|
|
7953
|
+
if (position.pageNo !== positionNo || position.rowNo !== 0)
|
|
7954
|
+
continue;
|
|
7955
|
+
const { leftTop, rightTop } = position.coordinate;
|
|
7956
|
+
if (x <= margins[3] || x >= leftTop[0] && x <= rightTop[0] || ((_b = positionList[p + 1]) == null ? void 0 : _b.rowNo) !== 0) {
|
|
7957
|
+
return {
|
|
7958
|
+
index: position.index
|
|
7959
|
+
};
|
|
7960
|
+
}
|
|
7961
|
+
}
|
|
7962
|
+
} else {
|
|
7963
|
+
const lastLetter = lastLetterList[lastLetterList.length - 1];
|
|
7964
|
+
if (lastLetter) {
|
|
7965
|
+
const lastRowNo = lastLetter.rowNo;
|
|
7966
|
+
for (let p = 0; p < positionList.length; p++) {
|
|
7967
|
+
const position = positionList[p];
|
|
7968
|
+
if (position.pageNo !== positionNo || position.rowNo !== lastRowNo) {
|
|
7969
|
+
continue;
|
|
7970
|
+
}
|
|
7971
|
+
const { leftTop, rightTop } = position.coordinate;
|
|
7972
|
+
if (x <= margins[3] || x >= leftTop[0] && x <= rightTop[0] || ((_c = positionList[p + 1]) == null ? void 0 : _c.rowNo) !== lastRowNo) {
|
|
7973
|
+
return {
|
|
7974
|
+
index: position.index
|
|
7975
|
+
};
|
|
7976
|
+
}
|
|
7977
|
+
}
|
|
7978
|
+
}
|
|
7979
|
+
}
|
|
7936
7980
|
return {
|
|
7937
|
-
index: ((
|
|
7981
|
+
index: ((_d = lastLetterList[lastLetterList.length - 1]) == null ? void 0 : _d.index) || positionList.length - 1
|
|
7938
7982
|
};
|
|
7939
7983
|
}
|
|
7940
7984
|
return {
|
|
7941
7985
|
hitLineStartIndex,
|
|
7942
7986
|
index: curPositionIndex,
|
|
7943
|
-
isControl: !!((
|
|
7987
|
+
isControl: !!((_e = elementList[curPositionIndex]) == null ? void 0 : _e.controlId)
|
|
7944
7988
|
};
|
|
7945
7989
|
}
|
|
7946
7990
|
getFloatPositionByXY(payload) {
|
|
@@ -10819,309 +10863,495 @@ class TextControl {
|
|
|
10819
10863
|
return startIndex;
|
|
10820
10864
|
}
|
|
10821
10865
|
}
|
|
10822
|
-
class
|
|
10823
|
-
constructor(draw) {
|
|
10824
|
-
__publicField(this, "controlBorder");
|
|
10866
|
+
class DatePicker {
|
|
10867
|
+
constructor(draw, options = {}) {
|
|
10825
10868
|
__publicField(this, "draw");
|
|
10826
|
-
__publicField(this, "range");
|
|
10827
|
-
__publicField(this, "listener");
|
|
10828
|
-
__publicField(this, "eventBus");
|
|
10829
|
-
__publicField(this, "controlSearch");
|
|
10830
10869
|
__publicField(this, "options");
|
|
10831
|
-
__publicField(this, "
|
|
10832
|
-
__publicField(this, "
|
|
10833
|
-
this
|
|
10870
|
+
__publicField(this, "now");
|
|
10871
|
+
__publicField(this, "dom");
|
|
10872
|
+
__publicField(this, "renderOptions");
|
|
10873
|
+
__publicField(this, "isDatePicker");
|
|
10874
|
+
__publicField(this, "pickDate");
|
|
10875
|
+
__publicField(this, "lang");
|
|
10834
10876
|
this.draw = draw;
|
|
10835
|
-
this.
|
|
10836
|
-
this.
|
|
10837
|
-
this.
|
|
10838
|
-
this.
|
|
10839
|
-
this.
|
|
10840
|
-
this.
|
|
10841
|
-
this.
|
|
10842
|
-
|
|
10843
|
-
setHighlightList(payload) {
|
|
10844
|
-
this.controlSearch.setHighlightList(payload);
|
|
10845
|
-
}
|
|
10846
|
-
computeHighlightList() {
|
|
10847
|
-
const highlightList = this.controlSearch.getHighlightList();
|
|
10848
|
-
if (highlightList.length) {
|
|
10849
|
-
this.controlSearch.computeHighlightList();
|
|
10850
|
-
}
|
|
10851
|
-
}
|
|
10852
|
-
renderHighlightList(ctx, pageNo) {
|
|
10853
|
-
const highlightMatchResult = this.controlSearch.getHighlightMatchResult();
|
|
10854
|
-
if (highlightMatchResult.length) {
|
|
10855
|
-
this.controlSearch.renderHighlightList(ctx, pageNo);
|
|
10856
|
-
}
|
|
10857
|
-
}
|
|
10858
|
-
getDraw() {
|
|
10859
|
-
return this.draw;
|
|
10877
|
+
this.options = options;
|
|
10878
|
+
this.lang = this._getLang();
|
|
10879
|
+
this.now = new Date();
|
|
10880
|
+
this.dom = this._createDom();
|
|
10881
|
+
this.renderOptions = null;
|
|
10882
|
+
this.isDatePicker = true;
|
|
10883
|
+
this.pickDate = null;
|
|
10884
|
+
this._bindEvent();
|
|
10860
10885
|
}
|
|
10861
|
-
|
|
10862
|
-
|
|
10863
|
-
|
|
10864
|
-
|
|
10865
|
-
|
|
10866
|
-
|
|
10867
|
-
|
|
10868
|
-
|
|
10869
|
-
|
|
10870
|
-
|
|
10871
|
-
|
|
10872
|
-
|
|
10886
|
+
_createDom() {
|
|
10887
|
+
const datePickerContainer = document.createElement("div");
|
|
10888
|
+
datePickerContainer.classList.add(`${EDITOR_PREFIX}-date-container`);
|
|
10889
|
+
datePickerContainer.setAttribute(EDITOR_COMPONENT, EditorComponent.POPUP);
|
|
10890
|
+
const dateWrap = document.createElement("div");
|
|
10891
|
+
dateWrap.classList.add(`${EDITOR_PREFIX}-date-wrap`);
|
|
10892
|
+
const datePickerTitle = document.createElement("div");
|
|
10893
|
+
datePickerTitle.classList.add(`${EDITOR_PREFIX}-date-title`);
|
|
10894
|
+
const preYearTitle = document.createElement("span");
|
|
10895
|
+
preYearTitle.classList.add(`${EDITOR_PREFIX}-date-title__pre-year`);
|
|
10896
|
+
preYearTitle.innerText = `<<`;
|
|
10897
|
+
const preMonthTitle = document.createElement("span");
|
|
10898
|
+
preMonthTitle.classList.add(`${EDITOR_PREFIX}-date-title__pre-month`);
|
|
10899
|
+
preMonthTitle.innerText = `<`;
|
|
10900
|
+
const nowTitle = document.createElement("span");
|
|
10901
|
+
nowTitle.classList.add(`${EDITOR_PREFIX}-date-title__now`);
|
|
10902
|
+
const nextMonthTitle = document.createElement("span");
|
|
10903
|
+
nextMonthTitle.classList.add(`${EDITOR_PREFIX}-date-title__next-month`);
|
|
10904
|
+
nextMonthTitle.innerText = `>`;
|
|
10905
|
+
const nextYearTitle = document.createElement("span");
|
|
10906
|
+
nextYearTitle.classList.add(`${EDITOR_PREFIX}-date-title__next-year`);
|
|
10907
|
+
nextYearTitle.innerText = `>>`;
|
|
10908
|
+
datePickerTitle.append(preYearTitle);
|
|
10909
|
+
datePickerTitle.append(preMonthTitle);
|
|
10910
|
+
datePickerTitle.append(nowTitle);
|
|
10911
|
+
datePickerTitle.append(nextMonthTitle);
|
|
10912
|
+
datePickerTitle.append(nextYearTitle);
|
|
10913
|
+
const datePickerWeek = document.createElement("div");
|
|
10914
|
+
datePickerWeek.classList.add(`${EDITOR_PREFIX}-date-week`);
|
|
10915
|
+
const { weeks: { sun, mon, tue, wed, thu, fri, sat } } = this.lang;
|
|
10916
|
+
const weekList = [sun, mon, tue, wed, thu, fri, sat];
|
|
10917
|
+
weekList.forEach((week) => {
|
|
10918
|
+
const weekDom = document.createElement("span");
|
|
10919
|
+
weekDom.innerText = `${week}`;
|
|
10920
|
+
datePickerWeek.append(weekDom);
|
|
10921
|
+
});
|
|
10922
|
+
const datePickerDay = document.createElement("div");
|
|
10923
|
+
datePickerDay.classList.add(`${EDITOR_PREFIX}-date-day`);
|
|
10924
|
+
dateWrap.append(datePickerTitle);
|
|
10925
|
+
dateWrap.append(datePickerWeek);
|
|
10926
|
+
dateWrap.append(datePickerDay);
|
|
10927
|
+
const timeWrap = document.createElement("ul");
|
|
10928
|
+
timeWrap.classList.add(`${EDITOR_PREFIX}-time-wrap`);
|
|
10929
|
+
let hourTime;
|
|
10930
|
+
let minuteTime;
|
|
10931
|
+
let secondTime;
|
|
10932
|
+
const timeList = [this.lang.hour, this.lang.minute, this.lang.second];
|
|
10933
|
+
timeList.forEach((t, i) => {
|
|
10934
|
+
const li = document.createElement("li");
|
|
10935
|
+
const timeText = document.createElement("span");
|
|
10936
|
+
timeText.innerText = t;
|
|
10937
|
+
li.append(timeText);
|
|
10938
|
+
const ol = document.createElement("ol");
|
|
10939
|
+
const isHour = i === 0;
|
|
10940
|
+
const isMinute = i === 1;
|
|
10941
|
+
const endIndex = isHour ? 24 : 60;
|
|
10942
|
+
for (let i2 = 0; i2 < endIndex; i2++) {
|
|
10943
|
+
const time = document.createElement("li");
|
|
10944
|
+
time.innerText = `${String(i2).padStart(2, "0")}`;
|
|
10945
|
+
time.setAttribute("data-id", `${i2}`);
|
|
10946
|
+
ol.append(time);
|
|
10873
10947
|
}
|
|
10874
|
-
if (
|
|
10875
|
-
|
|
10876
|
-
if (
|
|
10877
|
-
|
|
10878
|
-
|
|
10879
|
-
|
|
10880
|
-
}
|
|
10948
|
+
if (isHour) {
|
|
10949
|
+
hourTime = ol;
|
|
10950
|
+
} else if (isMinute) {
|
|
10951
|
+
minuteTime = ol;
|
|
10952
|
+
} else {
|
|
10953
|
+
secondTime = ol;
|
|
10881
10954
|
}
|
|
10882
|
-
|
|
10955
|
+
li.append(ol);
|
|
10956
|
+
timeWrap.append(li);
|
|
10883
10957
|
});
|
|
10958
|
+
const datePickerMenu = document.createElement("div");
|
|
10959
|
+
datePickerMenu.classList.add(`${EDITOR_PREFIX}-date-menu`);
|
|
10960
|
+
const timeMenu = document.createElement("button");
|
|
10961
|
+
timeMenu.classList.add(`${EDITOR_PREFIX}-date-menu__time`);
|
|
10962
|
+
timeMenu.innerText = this.lang.timeSelect;
|
|
10963
|
+
const nowMenu = document.createElement("button");
|
|
10964
|
+
nowMenu.classList.add(`${EDITOR_PREFIX}-date-menu__now`);
|
|
10965
|
+
nowMenu.innerText = this.lang.now;
|
|
10966
|
+
const submitMenu = document.createElement("button");
|
|
10967
|
+
submitMenu.classList.add(`${EDITOR_PREFIX}-date-menu__submit`);
|
|
10968
|
+
submitMenu.innerText = this.lang.confirm;
|
|
10969
|
+
datePickerMenu.append(timeMenu);
|
|
10970
|
+
datePickerMenu.append(nowMenu);
|
|
10971
|
+
datePickerMenu.append(submitMenu);
|
|
10972
|
+
datePickerContainer.append(dateWrap);
|
|
10973
|
+
datePickerContainer.append(timeWrap);
|
|
10974
|
+
datePickerContainer.append(datePickerMenu);
|
|
10975
|
+
this.draw.getContainer().append(datePickerContainer);
|
|
10976
|
+
return {
|
|
10977
|
+
container: datePickerContainer,
|
|
10978
|
+
dateWrap,
|
|
10979
|
+
datePickerWeek,
|
|
10980
|
+
timeWrap,
|
|
10981
|
+
title: {
|
|
10982
|
+
preYear: preYearTitle,
|
|
10983
|
+
preMonth: preMonthTitle,
|
|
10984
|
+
now: nowTitle,
|
|
10985
|
+
nextMonth: nextMonthTitle,
|
|
10986
|
+
nextYear: nextYearTitle
|
|
10987
|
+
},
|
|
10988
|
+
day: datePickerDay,
|
|
10989
|
+
time: {
|
|
10990
|
+
hour: hourTime,
|
|
10991
|
+
minute: minuteTime,
|
|
10992
|
+
second: secondTime
|
|
10993
|
+
},
|
|
10994
|
+
menu: {
|
|
10995
|
+
time: timeMenu,
|
|
10996
|
+
now: nowMenu,
|
|
10997
|
+
submit: submitMenu
|
|
10998
|
+
}
|
|
10999
|
+
};
|
|
10884
11000
|
}
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
|
|
10888
|
-
|
|
10889
|
-
|
|
10890
|
-
|
|
10891
|
-
|
|
10892
|
-
|
|
10893
|
-
|
|
10894
|
-
|
|
10895
|
-
|
|
10896
|
-
|
|
10897
|
-
|
|
10898
|
-
|
|
10899
|
-
|
|
10900
|
-
|
|
10901
|
-
|
|
10902
|
-
|
|
10903
|
-
|
|
10904
|
-
|
|
10905
|
-
|
|
10906
|
-
|
|
10907
|
-
|
|
10908
|
-
|
|
10909
|
-
|
|
10910
|
-
|
|
10911
|
-
|
|
10912
|
-
|
|
10913
|
-
|
|
10914
|
-
|
|
10915
|
-
|
|
10916
|
-
|
|
10917
|
-
|
|
10918
|
-
|
|
10919
|
-
|
|
10920
|
-
|
|
10921
|
-
|
|
10922
|
-
|
|
10923
|
-
|
|
10924
|
-
|
|
10925
|
-
|
|
10926
|
-
|
|
10927
|
-
|
|
10928
|
-
|
|
10929
|
-
|
|
10930
|
-
|
|
10931
|
-
|
|
10932
|
-
|
|
10933
|
-
|
|
10934
|
-
|
|
10935
|
-
|
|
10936
|
-
|
|
10937
|
-
|
|
11001
|
+
_bindEvent() {
|
|
11002
|
+
this.dom.title.preYear.onclick = () => {
|
|
11003
|
+
this._preYear();
|
|
11004
|
+
};
|
|
11005
|
+
this.dom.title.preMonth.onclick = () => {
|
|
11006
|
+
this._preMonth();
|
|
11007
|
+
};
|
|
11008
|
+
this.dom.title.nextMonth.onclick = () => {
|
|
11009
|
+
this._nextMonth();
|
|
11010
|
+
};
|
|
11011
|
+
this.dom.title.nextYear.onclick = () => {
|
|
11012
|
+
this._nextYear();
|
|
11013
|
+
};
|
|
11014
|
+
this.dom.menu.time.onclick = () => {
|
|
11015
|
+
this.isDatePicker = !this.isDatePicker;
|
|
11016
|
+
this._toggleDateTimePicker();
|
|
11017
|
+
};
|
|
11018
|
+
this.dom.menu.now.onclick = () => {
|
|
11019
|
+
this._now();
|
|
11020
|
+
this._submit();
|
|
11021
|
+
};
|
|
11022
|
+
this.dom.menu.submit.onclick = () => {
|
|
11023
|
+
this.dispose();
|
|
11024
|
+
this._submit();
|
|
11025
|
+
};
|
|
11026
|
+
this.dom.time.hour.onclick = (evt) => {
|
|
11027
|
+
if (!this.pickDate)
|
|
11028
|
+
return;
|
|
11029
|
+
const li = evt.target;
|
|
11030
|
+
const id = li.dataset.id;
|
|
11031
|
+
if (!id)
|
|
11032
|
+
return;
|
|
11033
|
+
this.pickDate.setHours(Number(id));
|
|
11034
|
+
this._setTimePick(false);
|
|
11035
|
+
};
|
|
11036
|
+
this.dom.time.minute.onclick = (evt) => {
|
|
11037
|
+
if (!this.pickDate)
|
|
11038
|
+
return;
|
|
11039
|
+
const li = evt.target;
|
|
11040
|
+
const id = li.dataset.id;
|
|
11041
|
+
if (!id)
|
|
11042
|
+
return;
|
|
11043
|
+
this.pickDate.setMinutes(Number(id));
|
|
11044
|
+
this._setTimePick(false);
|
|
11045
|
+
};
|
|
11046
|
+
this.dom.time.second.onclick = (evt) => {
|
|
11047
|
+
if (!this.pickDate)
|
|
11048
|
+
return;
|
|
11049
|
+
const li = evt.target;
|
|
11050
|
+
const id = li.dataset.id;
|
|
11051
|
+
if (!id)
|
|
11052
|
+
return;
|
|
11053
|
+
this.pickDate.setSeconds(Number(id));
|
|
11054
|
+
this._setTimePick(false);
|
|
11055
|
+
};
|
|
10938
11056
|
}
|
|
10939
|
-
|
|
10940
|
-
|
|
11057
|
+
_setPosition() {
|
|
11058
|
+
if (!this.renderOptions)
|
|
11059
|
+
return;
|
|
11060
|
+
const { position: { coordinate: { leftTop: [left2, top] }, lineHeight, pageNo } } = this.renderOptions;
|
|
10941
11061
|
const height = this.draw.getHeight();
|
|
10942
11062
|
const pageGap = this.draw.getPageGap();
|
|
10943
|
-
const
|
|
10944
|
-
|
|
11063
|
+
const currentPageNo = pageNo != null ? pageNo : this.draw.getPageNo();
|
|
11064
|
+
const preY = currentPageNo * (height + pageGap);
|
|
11065
|
+
this.dom.container.style.left = `${left2}px`;
|
|
11066
|
+
this.dom.container.style.top = `${top + preY + lineHeight}px`;
|
|
10945
11067
|
}
|
|
10946
|
-
|
|
10947
|
-
return
|
|
11068
|
+
isInvalidDate(value) {
|
|
11069
|
+
return value.toDateString() === "Invalid Date";
|
|
10948
11070
|
}
|
|
10949
|
-
|
|
10950
|
-
|
|
11071
|
+
_setValue() {
|
|
11072
|
+
var _a;
|
|
11073
|
+
const value = (_a = this.renderOptions) == null ? void 0 : _a.value;
|
|
11074
|
+
if (value) {
|
|
11075
|
+
const setDate = new Date(value);
|
|
11076
|
+
this.now = this.isInvalidDate(setDate) ? new Date() : setDate;
|
|
11077
|
+
} else {
|
|
11078
|
+
this.now = new Date();
|
|
11079
|
+
}
|
|
11080
|
+
this.pickDate = new Date(this.now);
|
|
10951
11081
|
}
|
|
10952
|
-
|
|
10953
|
-
|
|
11082
|
+
_getLang() {
|
|
11083
|
+
const i18n = this.draw.getI18n();
|
|
11084
|
+
const t = i18n.t.bind(i18n);
|
|
11085
|
+
return {
|
|
11086
|
+
now: t("datePicker.now"),
|
|
11087
|
+
confirm: t("datePicker.confirm"),
|
|
11088
|
+
return: t("datePicker.return"),
|
|
11089
|
+
timeSelect: t("datePicker.timeSelect"),
|
|
11090
|
+
weeks: {
|
|
11091
|
+
sun: t("datePicker.weeks.sun"),
|
|
11092
|
+
mon: t("datePicker.weeks.mon"),
|
|
11093
|
+
tue: t("datePicker.weeks.tue"),
|
|
11094
|
+
wed: t("datePicker.weeks.wed"),
|
|
11095
|
+
thu: t("datePicker.weeks.thu"),
|
|
11096
|
+
fri: t("datePicker.weeks.fri"),
|
|
11097
|
+
sat: t("datePicker.weeks.sat")
|
|
11098
|
+
},
|
|
11099
|
+
year: t("datePicker.year"),
|
|
11100
|
+
month: t("datePicker.month"),
|
|
11101
|
+
hour: t("datePicker.hour"),
|
|
11102
|
+
minute: t("datePicker.minute"),
|
|
11103
|
+
second: t("datePicker.second")
|
|
11104
|
+
};
|
|
10954
11105
|
}
|
|
10955
|
-
|
|
10956
|
-
|
|
10957
|
-
|
|
10958
|
-
|
|
10959
|
-
const
|
|
10960
|
-
const
|
|
10961
|
-
|
|
10962
|
-
|
|
10963
|
-
|
|
10964
|
-
|
|
10965
|
-
|
|
10966
|
-
|
|
10967
|
-
|
|
10968
|
-
|
|
11106
|
+
_setLangChange() {
|
|
11107
|
+
this.dom.menu.time.innerText = this.lang.timeSelect;
|
|
11108
|
+
this.dom.menu.now.innerText = this.lang.now;
|
|
11109
|
+
this.dom.menu.submit.innerText = this.lang.confirm;
|
|
11110
|
+
const { weeks: { sun, mon, tue, wed, thu, fri, sat } } = this.lang;
|
|
11111
|
+
const weekList = [sun, mon, tue, wed, thu, fri, sat];
|
|
11112
|
+
this.dom.datePickerWeek.childNodes.forEach((child, i) => {
|
|
11113
|
+
const childElement = child;
|
|
11114
|
+
childElement.innerText = weekList[i];
|
|
11115
|
+
});
|
|
11116
|
+
const hourTitle = this.dom.time.hour.previousElementSibling;
|
|
11117
|
+
hourTitle.innerText = this.lang.hour;
|
|
11118
|
+
const minuteTitle = this.dom.time.minute.previousElementSibling;
|
|
11119
|
+
minuteTitle.innerText = this.lang.minute;
|
|
11120
|
+
const secondTitle = this.dom.time.second.previousElementSibling;
|
|
11121
|
+
secondTitle.innerText = this.lang.second;
|
|
11122
|
+
}
|
|
11123
|
+
_update() {
|
|
11124
|
+
const localDate = new Date();
|
|
11125
|
+
const localYear = localDate.getFullYear();
|
|
11126
|
+
const localMonth = localDate.getMonth() + 1;
|
|
11127
|
+
const localDay = localDate.getDate();
|
|
11128
|
+
let pickYear = null;
|
|
11129
|
+
let pickMonth = null;
|
|
11130
|
+
let pickDay = null;
|
|
11131
|
+
if (this.pickDate) {
|
|
11132
|
+
pickYear = this.pickDate.getFullYear();
|
|
11133
|
+
pickMonth = this.pickDate.getMonth() + 1;
|
|
11134
|
+
pickDay = this.pickDate.getDate();
|
|
10969
11135
|
}
|
|
10970
|
-
this.
|
|
10971
|
-
const
|
|
10972
|
-
|
|
10973
|
-
|
|
10974
|
-
|
|
10975
|
-
|
|
10976
|
-
|
|
10977
|
-
|
|
10978
|
-
} else if (control.type === ControlType.CHECKBOX) {
|
|
10979
|
-
this.activeControl = new CheckboxControl(element, this);
|
|
10980
|
-
} else if (control.type === ControlType.RADIO) {
|
|
10981
|
-
this.activeControl = new RadioControl(element, this);
|
|
11136
|
+
const year = this.now.getFullYear();
|
|
11137
|
+
const month = this.now.getMonth() + 1;
|
|
11138
|
+
this.dom.title.now.innerText = `${year}${this.lang.year} ${String(month).padStart(2, "0")}${this.lang.month}`;
|
|
11139
|
+
const curDate = new Date(year, month, 0);
|
|
11140
|
+
const curDay = curDate.getDate();
|
|
11141
|
+
let curWeek = new Date(year, month - 1, 1).getDay();
|
|
11142
|
+
if (curWeek === 0) {
|
|
11143
|
+
curWeek = 7;
|
|
10982
11144
|
}
|
|
10983
|
-
|
|
10984
|
-
|
|
10985
|
-
|
|
10986
|
-
|
|
10987
|
-
|
|
10988
|
-
|
|
10989
|
-
|
|
10990
|
-
|
|
10991
|
-
|
|
10992
|
-
|
|
10993
|
-
|
|
10994
|
-
|
|
10995
|
-
|
|
10996
|
-
|
|
10997
|
-
|
|
10998
|
-
|
|
10999
|
-
if (
|
|
11000
|
-
|
|
11145
|
+
const preDay = new Date(year, month - 1, 0).getDate();
|
|
11146
|
+
this.dom.day.innerHTML = "";
|
|
11147
|
+
const preStartDay = preDay - curWeek + 1;
|
|
11148
|
+
for (let i = preStartDay; i <= preDay; i++) {
|
|
11149
|
+
const dayDom = document.createElement("div");
|
|
11150
|
+
dayDom.classList.add("disable");
|
|
11151
|
+
dayDom.innerText = `${i}`;
|
|
11152
|
+
dayDom.onclick = () => {
|
|
11153
|
+
const newMonth = month - 2;
|
|
11154
|
+
this.now = new Date(year, newMonth, i);
|
|
11155
|
+
this._setDatePick(year, newMonth, i);
|
|
11156
|
+
};
|
|
11157
|
+
this.dom.day.append(dayDom);
|
|
11158
|
+
}
|
|
11159
|
+
for (let i = 1; i <= curDay; i++) {
|
|
11160
|
+
const dayDom = document.createElement("div");
|
|
11161
|
+
if (localYear === year && localMonth === month && localDay === i) {
|
|
11162
|
+
dayDom.classList.add("active");
|
|
11001
11163
|
}
|
|
11002
|
-
|
|
11003
|
-
|
|
11004
|
-
destroyControl() {
|
|
11005
|
-
if (this.activeControl) {
|
|
11006
|
-
if (this.activeControl instanceof SelectControl) {
|
|
11007
|
-
this.activeControl.destroy();
|
|
11164
|
+
if (this.pickDate && pickYear === year && pickMonth === month && pickDay === i) {
|
|
11165
|
+
dayDom.classList.add("select");
|
|
11008
11166
|
}
|
|
11009
|
-
|
|
11010
|
-
|
|
11011
|
-
const
|
|
11012
|
-
|
|
11013
|
-
|
|
11014
|
-
|
|
11015
|
-
|
|
11016
|
-
|
|
11017
|
-
|
|
11018
|
-
|
|
11019
|
-
|
|
11020
|
-
|
|
11021
|
-
|
|
11167
|
+
dayDom.innerText = `${i}`;
|
|
11168
|
+
dayDom.onclick = (evt) => {
|
|
11169
|
+
const newMonth = month - 1;
|
|
11170
|
+
this.now = new Date(year, newMonth, i);
|
|
11171
|
+
this._setDatePick(year, newMonth, i);
|
|
11172
|
+
evt.stopPropagation();
|
|
11173
|
+
};
|
|
11174
|
+
this.dom.day.append(dayDom);
|
|
11175
|
+
}
|
|
11176
|
+
const nextEndDay = 6 * 7 - curWeek - curDay;
|
|
11177
|
+
for (let i = 1; i <= nextEndDay; i++) {
|
|
11178
|
+
const dayDom = document.createElement("div");
|
|
11179
|
+
dayDom.classList.add("disable");
|
|
11180
|
+
dayDom.innerText = `${i}`;
|
|
11181
|
+
dayDom.onclick = () => {
|
|
11182
|
+
this.now = new Date(year, month, i);
|
|
11183
|
+
this._setDatePick(year, month, i);
|
|
11184
|
+
};
|
|
11185
|
+
this.dom.day.append(dayDom);
|
|
11022
11186
|
}
|
|
11023
11187
|
}
|
|
11024
|
-
|
|
11025
|
-
|
|
11026
|
-
|
|
11027
|
-
this.
|
|
11028
|
-
this.
|
|
11029
|
-
isCompute,
|
|
11030
|
-
isSubmitHistory,
|
|
11031
|
-
isSetCursor: false
|
|
11032
|
-
});
|
|
11188
|
+
_toggleDateTimePicker() {
|
|
11189
|
+
if (this.isDatePicker) {
|
|
11190
|
+
this.dom.dateWrap.classList.add("active");
|
|
11191
|
+
this.dom.timeWrap.classList.remove("active");
|
|
11192
|
+
this.dom.menu.time.innerText = this.lang.timeSelect;
|
|
11033
11193
|
} else {
|
|
11034
|
-
this.
|
|
11035
|
-
this.
|
|
11036
|
-
|
|
11037
|
-
|
|
11038
|
-
isSubmitHistory
|
|
11039
|
-
});
|
|
11194
|
+
this.dom.dateWrap.classList.remove("active");
|
|
11195
|
+
this.dom.timeWrap.classList.add("active");
|
|
11196
|
+
this.dom.menu.time.innerText = this.lang.return;
|
|
11197
|
+
this._setTimePick();
|
|
11040
11198
|
}
|
|
11041
11199
|
}
|
|
11042
|
-
|
|
11043
|
-
|
|
11044
|
-
|
|
11045
|
-
|
|
11046
|
-
|
|
11047
|
-
|
|
11048
|
-
this.
|
|
11049
|
-
if (this.activeControl instanceof SelectControl && this.activeControl.getIsPopup()) {
|
|
11050
|
-
this.activeControl.destroy();
|
|
11051
|
-
this.activeControl.awake();
|
|
11052
|
-
}
|
|
11200
|
+
_setDatePick(year, month, day) {
|
|
11201
|
+
var _a, _b, _c;
|
|
11202
|
+
this.now = new Date(year, month, day);
|
|
11203
|
+
(_a = this.pickDate) == null ? void 0 : _a.setFullYear(year);
|
|
11204
|
+
(_b = this.pickDate) == null ? void 0 : _b.setMonth(month);
|
|
11205
|
+
(_c = this.pickDate) == null ? void 0 : _c.setDate(day);
|
|
11206
|
+
this._update();
|
|
11053
11207
|
}
|
|
11054
|
-
|
|
11055
|
-
|
|
11056
|
-
|
|
11057
|
-
|
|
11058
|
-
const
|
|
11059
|
-
|
|
11060
|
-
|
|
11061
|
-
|
|
11208
|
+
_setTimePick(isIntoView = true) {
|
|
11209
|
+
var _a, _b, _c;
|
|
11210
|
+
const hour = ((_a = this.pickDate) == null ? void 0 : _a.getHours()) || 0;
|
|
11211
|
+
const minute = ((_b = this.pickDate) == null ? void 0 : _b.getMinutes()) || 0;
|
|
11212
|
+
const second = ((_c = this.pickDate) == null ? void 0 : _c.getSeconds()) || 0;
|
|
11213
|
+
const { hour: hourDom, minute: minuteDom, second: secondDom } = this.dom.time;
|
|
11214
|
+
const timeDomList = [hourDom, minuteDom, secondDom];
|
|
11215
|
+
timeDomList.forEach((timeDom) => {
|
|
11216
|
+
timeDom.querySelectorAll("li").forEach((li) => li.classList.remove("active"));
|
|
11217
|
+
});
|
|
11218
|
+
const pickList = [
|
|
11219
|
+
[hourDom, hour],
|
|
11220
|
+
[minuteDom, minute],
|
|
11221
|
+
[secondDom, second]
|
|
11222
|
+
];
|
|
11223
|
+
pickList.forEach(([dom, time]) => {
|
|
11224
|
+
const pickDom = dom.querySelector(`[data-id='${time}']`);
|
|
11225
|
+
pickDom.classList.add("active");
|
|
11226
|
+
if (isIntoView) {
|
|
11227
|
+
this._scrollIntoView(dom, pickDom);
|
|
11228
|
+
}
|
|
11229
|
+
});
|
|
11230
|
+
}
|
|
11231
|
+
_scrollIntoView(container, selected) {
|
|
11232
|
+
if (!selected) {
|
|
11233
|
+
container.scrollTop = 0;
|
|
11234
|
+
return;
|
|
11235
|
+
}
|
|
11236
|
+
const offsetParents = [];
|
|
11237
|
+
let pointer = selected.offsetParent;
|
|
11238
|
+
while (pointer && container !== pointer && container.contains(pointer)) {
|
|
11239
|
+
offsetParents.push(pointer);
|
|
11240
|
+
pointer = pointer.offsetParent;
|
|
11241
|
+
}
|
|
11242
|
+
const top = selected.offsetTop + offsetParents.reduce((prev, curr) => prev + curr.offsetTop, 0);
|
|
11243
|
+
const bottom = top + selected.offsetHeight;
|
|
11244
|
+
const viewRectTop = container.scrollTop;
|
|
11245
|
+
const viewRectBottom = viewRectTop + container.clientHeight;
|
|
11246
|
+
if (top < viewRectTop) {
|
|
11247
|
+
container.scrollTop = top;
|
|
11248
|
+
} else if (bottom > viewRectBottom) {
|
|
11249
|
+
container.scrollTop = bottom - container.clientHeight;
|
|
11250
|
+
}
|
|
11251
|
+
}
|
|
11252
|
+
_preMonth() {
|
|
11253
|
+
this.now.setMonth(this.now.getMonth() - 1);
|
|
11254
|
+
this._update();
|
|
11255
|
+
}
|
|
11256
|
+
_nextMonth() {
|
|
11257
|
+
this.now.setMonth(this.now.getMonth() + 1);
|
|
11258
|
+
this._update();
|
|
11259
|
+
}
|
|
11260
|
+
_preYear() {
|
|
11261
|
+
this.now.setFullYear(this.now.getFullYear() - 1);
|
|
11262
|
+
this._update();
|
|
11263
|
+
}
|
|
11264
|
+
_nextYear() {
|
|
11265
|
+
this.now.setFullYear(this.now.getFullYear() + 1);
|
|
11266
|
+
this._update();
|
|
11267
|
+
}
|
|
11268
|
+
_now() {
|
|
11269
|
+
this.pickDate = new Date();
|
|
11270
|
+
this.dispose();
|
|
11271
|
+
}
|
|
11272
|
+
_toggleVisible(isVisible) {
|
|
11273
|
+
if (isVisible) {
|
|
11274
|
+
this.dom.container.classList.add("active");
|
|
11062
11275
|
} else {
|
|
11063
|
-
|
|
11276
|
+
this.dom.container.classList.remove("active");
|
|
11064
11277
|
}
|
|
11065
|
-
|
|
11066
|
-
|
|
11067
|
-
|
|
11068
|
-
|
|
11069
|
-
|
|
11070
|
-
|
|
11071
|
-
|
|
11072
|
-
while (startIndex < elementList.length) {
|
|
11073
|
-
const nextElement = elementList[startIndex];
|
|
11074
|
-
if (nextElement.controlId !== element.controlId) {
|
|
11075
|
-
return {
|
|
11076
|
-
newIndex: startIndex - 1,
|
|
11077
|
-
newElement: elementList[startIndex - 1]
|
|
11078
|
-
};
|
|
11079
|
-
}
|
|
11080
|
-
startIndex++;
|
|
11081
|
-
}
|
|
11082
|
-
} else if (element.controlComponent === ControlComponent.PREFIX) {
|
|
11083
|
-
let startIndex = newIndex + 1;
|
|
11084
|
-
while (startIndex < elementList.length) {
|
|
11085
|
-
const nextElement = elementList[startIndex];
|
|
11086
|
-
if (nextElement.controlId !== element.controlId || nextElement.controlComponent !== ControlComponent.PREFIX) {
|
|
11087
|
-
return {
|
|
11088
|
-
newIndex: startIndex - 1,
|
|
11089
|
-
newElement: elementList[startIndex - 1]
|
|
11090
|
-
};
|
|
11091
|
-
}
|
|
11092
|
-
startIndex++;
|
|
11093
|
-
}
|
|
11094
|
-
} else if (element.controlComponent === ControlComponent.PLACEHOLDER) {
|
|
11095
|
-
let startIndex = newIndex - 1;
|
|
11096
|
-
while (startIndex > 0) {
|
|
11097
|
-
const preElement = elementList[startIndex];
|
|
11098
|
-
if (preElement.controlId !== element.controlId || preElement.controlComponent === ControlComponent.PREFIX) {
|
|
11099
|
-
return {
|
|
11100
|
-
newIndex: startIndex,
|
|
11101
|
-
newElement: elementList[startIndex]
|
|
11102
|
-
};
|
|
11103
|
-
}
|
|
11104
|
-
startIndex--;
|
|
11105
|
-
}
|
|
11278
|
+
}
|
|
11279
|
+
_submit() {
|
|
11280
|
+
var _a;
|
|
11281
|
+
if (this.options.onSubmit && this.pickDate) {
|
|
11282
|
+
const format = (_a = this.renderOptions) == null ? void 0 : _a.dateFormat;
|
|
11283
|
+
const pickDateString = this.formatDate(this.pickDate, format);
|
|
11284
|
+
this.options.onSubmit(pickDateString);
|
|
11106
11285
|
}
|
|
11107
|
-
|
|
11108
|
-
|
|
11109
|
-
|
|
11286
|
+
}
|
|
11287
|
+
formatDate(date, format = "yyyy-MM-dd hh:mm:ss") {
|
|
11288
|
+
let dateString = format;
|
|
11289
|
+
const dateOption = {
|
|
11290
|
+
"y+": date.getFullYear().toString(),
|
|
11291
|
+
"M+": (date.getMonth() + 1).toString(),
|
|
11292
|
+
"d+": date.getDate().toString(),
|
|
11293
|
+
"h+": date.getHours().toString(),
|
|
11294
|
+
"m+": date.getMinutes().toString(),
|
|
11295
|
+
"s+": date.getSeconds().toString()
|
|
11110
11296
|
};
|
|
11297
|
+
for (const k in dateOption) {
|
|
11298
|
+
const reg = new RegExp("(" + k + ")").exec(format);
|
|
11299
|
+
const key = k;
|
|
11300
|
+
if (reg) {
|
|
11301
|
+
dateString = dateString.replace(reg[1], reg[1].length === 1 ? dateOption[key] : dateOption[key].padStart(reg[1].length, "0"));
|
|
11302
|
+
}
|
|
11303
|
+
}
|
|
11304
|
+
return dateString;
|
|
11111
11305
|
}
|
|
11112
|
-
|
|
11113
|
-
|
|
11306
|
+
render(option) {
|
|
11307
|
+
this.renderOptions = option;
|
|
11308
|
+
this.lang = this._getLang();
|
|
11309
|
+
this._setLangChange();
|
|
11310
|
+
this._setValue();
|
|
11311
|
+
this._update();
|
|
11312
|
+
this._setPosition();
|
|
11313
|
+
this.isDatePicker = true;
|
|
11314
|
+
this._toggleDateTimePicker();
|
|
11315
|
+
this._toggleVisible(true);
|
|
11316
|
+
}
|
|
11317
|
+
dispose() {
|
|
11318
|
+
this._toggleVisible(false);
|
|
11319
|
+
}
|
|
11320
|
+
destroy() {
|
|
11321
|
+
this.dom.container.remove();
|
|
11322
|
+
}
|
|
11323
|
+
}
|
|
11324
|
+
class DateControl {
|
|
11325
|
+
constructor(element, control) {
|
|
11326
|
+
__publicField(this, "draw");
|
|
11327
|
+
__publicField(this, "element");
|
|
11328
|
+
__publicField(this, "control");
|
|
11329
|
+
__publicField(this, "isPopup");
|
|
11330
|
+
__publicField(this, "datePicker");
|
|
11331
|
+
const draw = control.getDraw();
|
|
11332
|
+
this.draw = draw;
|
|
11333
|
+
this.element = element;
|
|
11334
|
+
this.control = control;
|
|
11335
|
+
this.isPopup = false;
|
|
11336
|
+
this.datePicker = null;
|
|
11337
|
+
}
|
|
11338
|
+
setElement(element) {
|
|
11339
|
+
this.element = element;
|
|
11340
|
+
}
|
|
11341
|
+
getElement() {
|
|
11342
|
+
return this.element;
|
|
11343
|
+
}
|
|
11344
|
+
getIsPopup() {
|
|
11345
|
+
return this.isPopup;
|
|
11346
|
+
}
|
|
11347
|
+
getValueRange(context = {}) {
|
|
11348
|
+
const elementList = context.elementList || this.control.getElementList();
|
|
11349
|
+
const { startIndex } = context.range || this.control.getRange();
|
|
11114
11350
|
const startElement = elementList[startIndex];
|
|
11115
|
-
const { deletable = true } = startElement.control;
|
|
11116
|
-
if (!deletable)
|
|
11117
|
-
return null;
|
|
11118
|
-
let leftIndex = -1;
|
|
11119
|
-
let rightIndex = -1;
|
|
11120
11351
|
let preIndex = startIndex;
|
|
11121
11352
|
while (preIndex > 0) {
|
|
11122
11353
|
const preElement = elementList[preIndex];
|
|
11123
|
-
if (preElement.controlId !== startElement.controlId) {
|
|
11124
|
-
leftIndex = preIndex;
|
|
11354
|
+
if (preElement.controlId !== startElement.controlId || preElement.controlComponent === ControlComponent.PREFIX) {
|
|
11125
11355
|
break;
|
|
11126
11356
|
}
|
|
11127
11357
|
preIndex--;
|
|
@@ -11129,1671 +11359,1708 @@ class Control {
|
|
|
11129
11359
|
let nextIndex = startIndex + 1;
|
|
11130
11360
|
while (nextIndex < elementList.length) {
|
|
11131
11361
|
const nextElement = elementList[nextIndex];
|
|
11132
|
-
if (nextElement.controlId !== startElement.controlId) {
|
|
11133
|
-
rightIndex = nextIndex - 1;
|
|
11362
|
+
if (nextElement.controlId !== startElement.controlId || nextElement.controlComponent === ControlComponent.POSTFIX) {
|
|
11134
11363
|
break;
|
|
11135
11364
|
}
|
|
11136
11365
|
nextIndex++;
|
|
11137
11366
|
}
|
|
11138
|
-
if (
|
|
11139
|
-
|
|
11140
|
-
|
|
11141
|
-
if (!~leftIndex && !~rightIndex)
|
|
11142
|
-
return startIndex;
|
|
11143
|
-
leftIndex = ~leftIndex ? leftIndex : 0;
|
|
11144
|
-
this.draw.spliceElementList(elementList, leftIndex + 1, rightIndex - leftIndex);
|
|
11145
|
-
return leftIndex;
|
|
11367
|
+
if (preIndex === nextIndex)
|
|
11368
|
+
return null;
|
|
11369
|
+
return [preIndex, nextIndex - 1];
|
|
11146
11370
|
}
|
|
11147
|
-
|
|
11148
|
-
const elementList = context.elementList || this.getElementList();
|
|
11149
|
-
const
|
|
11150
|
-
|
|
11151
|
-
|
|
11152
|
-
|
|
11153
|
-
|
|
11154
|
-
|
|
11155
|
-
|
|
11156
|
-
|
|
11157
|
-
|
|
11158
|
-
if (curElement.controlComponent === ControlComponent.PLACEHOLDER) {
|
|
11159
|
-
if (!isHasSubmitHistory) {
|
|
11160
|
-
isHasSubmitHistory = true;
|
|
11161
|
-
this.draw.getHistoryManager().popUndo();
|
|
11162
|
-
this.draw.submitHistory(startIndex);
|
|
11163
|
-
}
|
|
11164
|
-
elementList.splice(index2, 1);
|
|
11165
|
-
} else {
|
|
11166
|
-
index2++;
|
|
11167
|
-
}
|
|
11371
|
+
getValue(context = {}) {
|
|
11372
|
+
const elementList = context.elementList || this.control.getElementList();
|
|
11373
|
+
const range = this.getValueRange(context);
|
|
11374
|
+
if (!range)
|
|
11375
|
+
return [];
|
|
11376
|
+
const data2 = [];
|
|
11377
|
+
const [startIndex, endIndex] = range;
|
|
11378
|
+
for (let i = startIndex; i <= endIndex; i++) {
|
|
11379
|
+
const element = elementList[i];
|
|
11380
|
+
if (element.controlComponent === ControlComponent.VALUE) {
|
|
11381
|
+
data2.push(element);
|
|
11168
11382
|
}
|
|
11169
11383
|
}
|
|
11384
|
+
return data2;
|
|
11170
11385
|
}
|
|
11171
|
-
|
|
11172
|
-
|
|
11386
|
+
setValue(data2, context = {}, options = {}) {
|
|
11387
|
+
if (!options.isIgnoreDisabledRule && this.control.getIsDisabledControl()) {
|
|
11388
|
+
return -1;
|
|
11389
|
+
}
|
|
11390
|
+
const elementList = context.elementList || this.control.getElementList();
|
|
11391
|
+
const range = context.range || this.control.getRange();
|
|
11392
|
+
this.control.shrinkBoundary(context);
|
|
11393
|
+
const { startIndex, endIndex } = range;
|
|
11394
|
+
const draw = this.control.getDraw();
|
|
11395
|
+
if (startIndex !== endIndex) {
|
|
11396
|
+
draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex);
|
|
11397
|
+
} else {
|
|
11398
|
+
this.control.removePlaceholder(startIndex, context);
|
|
11399
|
+
}
|
|
11173
11400
|
const startElement = elementList[startIndex];
|
|
11174
|
-
const
|
|
11175
|
-
|
|
11176
|
-
|
|
11177
|
-
|
|
11178
|
-
|
|
11179
|
-
|
|
11180
|
-
|
|
11181
|
-
|
|
11182
|
-
|
|
11183
|
-
|
|
11184
|
-
control: startElement.control,
|
|
11185
|
-
controlComponent: ControlComponent.PLACEHOLDER,
|
|
11186
|
-
color: this.controlOptions.placeholderColor
|
|
11187
|
-
};
|
|
11401
|
+
const anchorElement = startElement.type && !TEXTLIKE_ELEMENT_TYPE.includes(startElement.type) || startElement.controlComponent === ControlComponent.PREFIX ? pickObject(startElement, [
|
|
11402
|
+
"control",
|
|
11403
|
+
"controlId",
|
|
11404
|
+
...CONTROL_STYLE_ATTR
|
|
11405
|
+
]) : omitObject(startElement, ["type"]);
|
|
11406
|
+
const start = range.startIndex + 1;
|
|
11407
|
+
for (let i = 0; i < data2.length; i++) {
|
|
11408
|
+
const newElement = __spreadProps(__spreadValues(__spreadValues({}, anchorElement), data2[i]), {
|
|
11409
|
+
controlComponent: ControlComponent.VALUE
|
|
11410
|
+
});
|
|
11188
11411
|
formatElementContext(elementList, [newElement], startIndex);
|
|
11189
|
-
|
|
11412
|
+
draw.spliceElementList(elementList, start + i, 0, newElement);
|
|
11190
11413
|
}
|
|
11414
|
+
return start + data2.length - 1;
|
|
11191
11415
|
}
|
|
11192
|
-
|
|
11193
|
-
|
|
11194
|
-
|
|
11416
|
+
clearSelect(context = {}, options = {}) {
|
|
11417
|
+
const { isIgnoreDisabledRule = false, isAddPlaceholder = true } = options;
|
|
11418
|
+
if (!isIgnoreDisabledRule && this.control.getIsDisabledControl()) {
|
|
11419
|
+
return -1;
|
|
11195
11420
|
}
|
|
11196
|
-
|
|
11197
|
-
|
|
11198
|
-
|
|
11199
|
-
|
|
11200
|
-
|
|
11421
|
+
const range = this.getValueRange(context);
|
|
11422
|
+
if (!range)
|
|
11423
|
+
return -1;
|
|
11424
|
+
const [leftIndex, rightIndex] = range;
|
|
11425
|
+
if (!~leftIndex || !~rightIndex)
|
|
11426
|
+
return -1;
|
|
11427
|
+
const elementList = context.elementList || this.control.getElementList();
|
|
11428
|
+
const draw = this.control.getDraw();
|
|
11429
|
+
draw.spliceElementList(elementList, leftIndex + 1, rightIndex - leftIndex);
|
|
11430
|
+
if (isAddPlaceholder) {
|
|
11431
|
+
this.control.addPlaceholder(leftIndex, context);
|
|
11201
11432
|
}
|
|
11202
|
-
return
|
|
11433
|
+
return leftIndex;
|
|
11203
11434
|
}
|
|
11204
|
-
|
|
11205
|
-
if (!this.
|
|
11206
|
-
|
|
11435
|
+
setSelect(date, context = {}, options = {}) {
|
|
11436
|
+
if (!options.isIgnoreDisabledRule && this.control.getIsDisabledControl()) {
|
|
11437
|
+
return;
|
|
11438
|
+
}
|
|
11439
|
+
const elementList = context.elementList || this.control.getElementList();
|
|
11440
|
+
const range = context.range || this.control.getRange();
|
|
11441
|
+
const valueElement = this.getValue(context)[0];
|
|
11442
|
+
const styleElement = valueElement ? pickObject(valueElement, EDITOR_ELEMENT_STYLE_ATTR) : pickObject(elementList[range.startIndex], CONTROL_STYLE_ATTR);
|
|
11443
|
+
const prefixIndex = this.clearSelect(context, {
|
|
11444
|
+
isAddPlaceholder: false
|
|
11445
|
+
});
|
|
11446
|
+
if (!~prefixIndex)
|
|
11447
|
+
return;
|
|
11448
|
+
const propertyElement = omitObject(elementList[prefixIndex], EDITOR_ELEMENT_STYLE_ATTR);
|
|
11449
|
+
const start = prefixIndex + 1;
|
|
11450
|
+
const draw = this.control.getDraw();
|
|
11451
|
+
for (let i = 0; i < date.length; i++) {
|
|
11452
|
+
const newElement = __spreadProps(__spreadValues(__spreadValues({}, styleElement), propertyElement), {
|
|
11453
|
+
type: ElementType.TEXT,
|
|
11454
|
+
value: date[i],
|
|
11455
|
+
controlComponent: ControlComponent.VALUE
|
|
11456
|
+
});
|
|
11457
|
+
formatElementContext(elementList, [newElement], prefixIndex);
|
|
11458
|
+
draw.spliceElementList(elementList, start + i, 0, newElement);
|
|
11459
|
+
}
|
|
11460
|
+
if (!context.range) {
|
|
11461
|
+
const newIndex = start + date.length - 1;
|
|
11462
|
+
this.control.repaintControl({
|
|
11463
|
+
curIndex: newIndex
|
|
11464
|
+
});
|
|
11465
|
+
this.destroy();
|
|
11207
11466
|
}
|
|
11208
|
-
return this.activeControl.cut();
|
|
11209
11467
|
}
|
|
11210
|
-
|
|
11211
|
-
|
|
11212
|
-
|
|
11213
|
-
|
|
11214
|
-
|
|
11215
|
-
|
|
11216
|
-
|
|
11217
|
-
|
|
11218
|
-
|
|
11219
|
-
|
|
11220
|
-
|
|
11221
|
-
|
|
11222
|
-
|
|
11223
|
-
|
|
11224
|
-
|
|
11225
|
-
|
|
11226
|
-
|
|
11227
|
-
}
|
|
11468
|
+
keydown(evt) {
|
|
11469
|
+
if (this.control.getIsDisabledControl()) {
|
|
11470
|
+
return null;
|
|
11471
|
+
}
|
|
11472
|
+
const elementList = this.control.getElementList();
|
|
11473
|
+
const range = this.control.getRange();
|
|
11474
|
+
this.control.shrinkBoundary();
|
|
11475
|
+
const { startIndex, endIndex } = range;
|
|
11476
|
+
const startElement = elementList[startIndex];
|
|
11477
|
+
const endElement = elementList[endIndex];
|
|
11478
|
+
const draw = this.control.getDraw();
|
|
11479
|
+
if (evt.key === KeyMap.Backspace) {
|
|
11480
|
+
if (startIndex !== endIndex) {
|
|
11481
|
+
draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex);
|
|
11482
|
+
const value = this.getValue();
|
|
11483
|
+
if (!value.length) {
|
|
11484
|
+
this.control.addPlaceholder(startIndex);
|
|
11228
11485
|
}
|
|
11229
|
-
|
|
11230
|
-
|
|
11231
|
-
|
|
11232
|
-
|
|
11233
|
-
|
|
11234
|
-
|
|
11235
|
-
const
|
|
11236
|
-
if (
|
|
11237
|
-
|
|
11238
|
-
if (type === ControlType.TEXT && nextElement.controlComponent === ControlComponent.VALUE) {
|
|
11239
|
-
textControlValue += nextElement.value;
|
|
11486
|
+
return startIndex;
|
|
11487
|
+
} else {
|
|
11488
|
+
if (startElement.controlComponent === ControlComponent.PREFIX || endElement.controlComponent === ControlComponent.POSTFIX || startElement.controlComponent === ControlComponent.PLACEHOLDER) {
|
|
11489
|
+
return this.control.removeControl(startIndex);
|
|
11490
|
+
} else {
|
|
11491
|
+
draw.spliceElementList(elementList, startIndex, 1);
|
|
11492
|
+
const value = this.getValue();
|
|
11493
|
+
if (!value.length) {
|
|
11494
|
+
this.control.addPlaceholder(startIndex - 1);
|
|
11240
11495
|
}
|
|
11241
|
-
|
|
11242
|
-
}
|
|
11243
|
-
if (type === ControlType.TEXT) {
|
|
11244
|
-
result.push(__spreadProps(__spreadValues({}, element.control), {
|
|
11245
|
-
zone: zone2,
|
|
11246
|
-
value: textControlValue || null,
|
|
11247
|
-
innerText: textControlValue || null
|
|
11248
|
-
}));
|
|
11249
|
-
} else if (type === ControlType.SELECT || type === ControlType.CHECKBOX || type === ControlType.RADIO) {
|
|
11250
|
-
const innerText = code == null ? void 0 : code.split(",").map((selectCode) => {
|
|
11251
|
-
var _a2;
|
|
11252
|
-
return (_a2 = valueSets == null ? void 0 : valueSets.find((valueSet) => valueSet.code === selectCode)) == null ? void 0 : _a2.value;
|
|
11253
|
-
}).filter(Boolean).join("");
|
|
11254
|
-
result.push(__spreadProps(__spreadValues({}, element.control), {
|
|
11255
|
-
zone: zone2,
|
|
11256
|
-
value: code || null,
|
|
11257
|
-
innerText: innerText || null
|
|
11258
|
-
}));
|
|
11496
|
+
return startIndex - 1;
|
|
11259
11497
|
}
|
|
11260
|
-
i = j;
|
|
11261
11498
|
}
|
|
11262
|
-
}
|
|
11263
|
-
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11269
|
-
|
|
11270
|
-
|
|
11271
|
-
|
|
11272
|
-
|
|
11273
|
-
|
|
11274
|
-
|
|
11499
|
+
} else if (evt.key === KeyMap.Delete) {
|
|
11500
|
+
if (startIndex !== endIndex) {
|
|
11501
|
+
draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex);
|
|
11502
|
+
const value = this.getValue();
|
|
11503
|
+
if (!value.length) {
|
|
11504
|
+
this.control.addPlaceholder(startIndex);
|
|
11505
|
+
}
|
|
11506
|
+
return startIndex;
|
|
11507
|
+
} else {
|
|
11508
|
+
const endNextElement = elementList[endIndex + 1];
|
|
11509
|
+
if (startElement.controlComponent === ControlComponent.PREFIX && endNextElement.controlComponent === ControlComponent.PLACEHOLDER || endNextElement.controlComponent === ControlComponent.POSTFIX || startElement.controlComponent === ControlComponent.PLACEHOLDER) {
|
|
11510
|
+
return this.control.removeControl(startIndex);
|
|
11511
|
+
} else {
|
|
11512
|
+
draw.spliceElementList(elementList, startIndex + 1, 1);
|
|
11513
|
+
const value = this.getValue();
|
|
11514
|
+
if (!value.length) {
|
|
11515
|
+
this.control.addPlaceholder(startIndex);
|
|
11516
|
+
}
|
|
11517
|
+
return startIndex;
|
|
11518
|
+
}
|
|
11275
11519
|
}
|
|
11276
|
-
];
|
|
11277
|
-
for (const { zone: zone2, elementList } of data2) {
|
|
11278
|
-
getValue(elementList, zone2);
|
|
11279
11520
|
}
|
|
11280
|
-
return
|
|
11521
|
+
return endIndex;
|
|
11281
11522
|
}
|
|
11282
|
-
|
|
11283
|
-
|
|
11284
|
-
|
|
11523
|
+
cut() {
|
|
11524
|
+
if (this.control.getIsDisabledControl()) {
|
|
11525
|
+
return -1;
|
|
11526
|
+
}
|
|
11527
|
+
this.control.shrinkBoundary();
|
|
11528
|
+
const { startIndex, endIndex } = this.control.getRange();
|
|
11529
|
+
if (startIndex === endIndex) {
|
|
11530
|
+
return startIndex;
|
|
11531
|
+
}
|
|
11532
|
+
const draw = this.control.getDraw();
|
|
11533
|
+
const elementList = this.control.getElementList();
|
|
11534
|
+
draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex);
|
|
11535
|
+
const value = this.getValue();
|
|
11536
|
+
if (!value.length) {
|
|
11537
|
+
this.control.addPlaceholder(startIndex);
|
|
11538
|
+
}
|
|
11539
|
+
return startIndex;
|
|
11540
|
+
}
|
|
11541
|
+
awake() {
|
|
11542
|
+
var _a, _b;
|
|
11543
|
+
if (this.isPopup || this.control.getIsDisabledControl())
|
|
11544
|
+
return;
|
|
11545
|
+
const position = this.control.getPosition();
|
|
11546
|
+
if (!position)
|
|
11547
|
+
return;
|
|
11548
|
+
const elementList = this.draw.getElementList();
|
|
11549
|
+
const { startIndex } = this.control.getRange();
|
|
11550
|
+
if (((_a = elementList[startIndex + 1]) == null ? void 0 : _a.controlId) !== this.element.controlId) {
|
|
11285
11551
|
return;
|
|
11286
|
-
let isExistSet = false;
|
|
11287
|
-
const { conceptId, value } = payload;
|
|
11288
|
-
const setValue = (elementList) => {
|
|
11289
|
-
var _a;
|
|
11290
|
-
let i = 0;
|
|
11291
|
-
while (i < elementList.length) {
|
|
11292
|
-
const element = elementList[i];
|
|
11293
|
-
i++;
|
|
11294
|
-
if (element.type === ElementType.TABLE) {
|
|
11295
|
-
const trList = element.trList;
|
|
11296
|
-
for (let r = 0; r < trList.length; r++) {
|
|
11297
|
-
const tr = trList[r];
|
|
11298
|
-
for (let d = 0; d < tr.tdList.length; d++) {
|
|
11299
|
-
const td = tr.tdList[d];
|
|
11300
|
-
setValue(td.value);
|
|
11301
|
-
}
|
|
11302
|
-
}
|
|
11303
|
-
}
|
|
11304
|
-
if (((_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId) !== conceptId)
|
|
11305
|
-
continue;
|
|
11306
|
-
isExistSet = true;
|
|
11307
|
-
const { type } = element.control;
|
|
11308
|
-
let currentEndIndex = i;
|
|
11309
|
-
while (currentEndIndex < elementList.length) {
|
|
11310
|
-
const nextElement = elementList[currentEndIndex];
|
|
11311
|
-
if (nextElement.controlId !== element.controlId)
|
|
11312
|
-
break;
|
|
11313
|
-
currentEndIndex++;
|
|
11314
|
-
}
|
|
11315
|
-
const fakeRange = {
|
|
11316
|
-
startIndex: i - 1,
|
|
11317
|
-
endIndex: currentEndIndex - 2
|
|
11318
|
-
};
|
|
11319
|
-
const controlContext = {
|
|
11320
|
-
range: fakeRange,
|
|
11321
|
-
elementList
|
|
11322
|
-
};
|
|
11323
|
-
const controlRule = {
|
|
11324
|
-
isIgnoreDisabledRule: true
|
|
11325
|
-
};
|
|
11326
|
-
if (type === ControlType.TEXT) {
|
|
11327
|
-
const formatValue = [{ value }];
|
|
11328
|
-
formatElementList(formatValue, {
|
|
11329
|
-
isHandleFirstElement: false,
|
|
11330
|
-
editorOptions: this.options
|
|
11331
|
-
});
|
|
11332
|
-
const text = new TextControl(element, this);
|
|
11333
|
-
this.activeControl = text;
|
|
11334
|
-
if (value) {
|
|
11335
|
-
text.setValue(formatValue, controlContext, controlRule);
|
|
11336
|
-
} else {
|
|
11337
|
-
text.clearValue(controlContext, controlRule);
|
|
11338
|
-
}
|
|
11339
|
-
} else if (type === ControlType.SELECT) {
|
|
11340
|
-
const select = new SelectControl(element, this);
|
|
11341
|
-
this.activeControl = select;
|
|
11342
|
-
if (value) {
|
|
11343
|
-
select.setSelect(value, controlContext, controlRule);
|
|
11344
|
-
} else {
|
|
11345
|
-
select.clearSelect(controlContext, controlRule);
|
|
11346
|
-
}
|
|
11347
|
-
} else if (type === ControlType.CHECKBOX) {
|
|
11348
|
-
const checkbox = new CheckboxControl(element, this);
|
|
11349
|
-
this.activeControl = checkbox;
|
|
11350
|
-
const codes = (value == null ? void 0 : value.split(",")) || [];
|
|
11351
|
-
checkbox.setSelect(codes, controlContext, controlRule);
|
|
11352
|
-
} else if (type === ControlType.RADIO) {
|
|
11353
|
-
const radio = new RadioControl(element, this);
|
|
11354
|
-
this.activeControl = radio;
|
|
11355
|
-
const codes = value ? [value] : [];
|
|
11356
|
-
radio.setSelect(codes, controlContext, controlRule);
|
|
11357
|
-
}
|
|
11358
|
-
this.activeControl = null;
|
|
11359
|
-
let newEndIndex = i;
|
|
11360
|
-
while (newEndIndex < elementList.length) {
|
|
11361
|
-
const nextElement = elementList[newEndIndex];
|
|
11362
|
-
if (nextElement.controlId !== element.controlId)
|
|
11363
|
-
break;
|
|
11364
|
-
newEndIndex++;
|
|
11365
|
-
}
|
|
11366
|
-
i = newEndIndex;
|
|
11367
|
-
}
|
|
11368
|
-
};
|
|
11369
|
-
this.destroyControl();
|
|
11370
|
-
const data2 = [
|
|
11371
|
-
this.draw.getHeaderElementList(),
|
|
11372
|
-
this.draw.getOriginalMainElementList(),
|
|
11373
|
-
this.draw.getFooterElementList()
|
|
11374
|
-
];
|
|
11375
|
-
for (const elementList of data2) {
|
|
11376
|
-
setValue(elementList);
|
|
11377
|
-
}
|
|
11378
|
-
if (isExistSet) {
|
|
11379
|
-
this.draw.render({
|
|
11380
|
-
isSetCursor: false
|
|
11381
|
-
});
|
|
11382
11552
|
}
|
|
11553
|
+
this.datePicker = new DatePicker(this.draw, {
|
|
11554
|
+
onSubmit: this._setDate.bind(this)
|
|
11555
|
+
});
|
|
11556
|
+
const value = this.getValue().map((el) => el.value).join("") || "";
|
|
11557
|
+
const dateFormat = (_b = this.element.control) == null ? void 0 : _b.dateFormat;
|
|
11558
|
+
this.datePicker.render({
|
|
11559
|
+
value,
|
|
11560
|
+
position,
|
|
11561
|
+
dateFormat
|
|
11562
|
+
});
|
|
11563
|
+
this.isPopup = true;
|
|
11383
11564
|
}
|
|
11384
|
-
|
|
11385
|
-
|
|
11386
|
-
if (
|
|
11565
|
+
destroy() {
|
|
11566
|
+
var _a;
|
|
11567
|
+
if (!this.isPopup)
|
|
11387
11568
|
return;
|
|
11388
|
-
|
|
11389
|
-
|
|
11569
|
+
(_a = this.datePicker) == null ? void 0 : _a.destroy();
|
|
11570
|
+
this.isPopup = false;
|
|
11571
|
+
}
|
|
11572
|
+
_setDate(date) {
|
|
11573
|
+
if (!date) {
|
|
11574
|
+
this.clearSelect();
|
|
11575
|
+
} else {
|
|
11576
|
+
this.setSelect(date);
|
|
11577
|
+
}
|
|
11578
|
+
this.destroy();
|
|
11579
|
+
}
|
|
11580
|
+
}
|
|
11581
|
+
class Control {
|
|
11582
|
+
constructor(draw) {
|
|
11583
|
+
__publicField(this, "controlBorder");
|
|
11584
|
+
__publicField(this, "draw");
|
|
11585
|
+
__publicField(this, "range");
|
|
11586
|
+
__publicField(this, "listener");
|
|
11587
|
+
__publicField(this, "eventBus");
|
|
11588
|
+
__publicField(this, "controlSearch");
|
|
11589
|
+
__publicField(this, "options");
|
|
11590
|
+
__publicField(this, "controlOptions");
|
|
11591
|
+
__publicField(this, "activeControl");
|
|
11592
|
+
this.controlBorder = new ControlBorder(draw);
|
|
11593
|
+
this.draw = draw;
|
|
11594
|
+
this.range = draw.getRange();
|
|
11595
|
+
this.listener = draw.getListener();
|
|
11596
|
+
this.eventBus = draw.getEventBus();
|
|
11597
|
+
this.controlSearch = new ControlSearch(this);
|
|
11598
|
+
this.options = draw.getOptions();
|
|
11599
|
+
this.controlOptions = this.options.control;
|
|
11600
|
+
this.activeControl = null;
|
|
11601
|
+
}
|
|
11602
|
+
setHighlightList(payload) {
|
|
11603
|
+
this.controlSearch.setHighlightList(payload);
|
|
11604
|
+
}
|
|
11605
|
+
computeHighlightList() {
|
|
11606
|
+
const highlightList = this.controlSearch.getHighlightList();
|
|
11607
|
+
if (highlightList.length) {
|
|
11608
|
+
this.controlSearch.computeHighlightList();
|
|
11609
|
+
}
|
|
11610
|
+
}
|
|
11611
|
+
renderHighlightList(ctx, pageNo) {
|
|
11612
|
+
const highlightMatchResult = this.controlSearch.getHighlightMatchResult();
|
|
11613
|
+
if (highlightMatchResult.length) {
|
|
11614
|
+
this.controlSearch.renderHighlightList(ctx, pageNo);
|
|
11615
|
+
}
|
|
11616
|
+
}
|
|
11617
|
+
getDraw() {
|
|
11618
|
+
return this.draw;
|
|
11619
|
+
}
|
|
11620
|
+
filterAssistElement(elementList) {
|
|
11621
|
+
return elementList.filter((element) => {
|
|
11390
11622
|
var _a;
|
|
11391
|
-
|
|
11392
|
-
|
|
11393
|
-
|
|
11394
|
-
|
|
11395
|
-
|
|
11396
|
-
|
|
11397
|
-
|
|
11398
|
-
const tr = trList[r];
|
|
11399
|
-
for (let d = 0; d < tr.tdList.length; d++) {
|
|
11400
|
-
const td = tr.tdList[d];
|
|
11401
|
-
setExtension(td.value);
|
|
11402
|
-
}
|
|
11623
|
+
if (element.type === ElementType.TABLE) {
|
|
11624
|
+
const trList = element.trList;
|
|
11625
|
+
for (let r = 0; r < trList.length; r++) {
|
|
11626
|
+
const tr = trList[r];
|
|
11627
|
+
for (let d = 0; d < tr.tdList.length; d++) {
|
|
11628
|
+
const td = tr.tdList[d];
|
|
11629
|
+
td.value = this.filterAssistElement(td.value);
|
|
11403
11630
|
}
|
|
11404
11631
|
}
|
|
11405
|
-
if (((_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId) !== conceptId)
|
|
11406
|
-
continue;
|
|
11407
|
-
element.control.extension = extension;
|
|
11408
|
-
let newEndIndex = i;
|
|
11409
|
-
while (newEndIndex < elementList.length) {
|
|
11410
|
-
const nextElement = elementList[newEndIndex];
|
|
11411
|
-
if (nextElement.controlId !== element.controlId)
|
|
11412
|
-
break;
|
|
11413
|
-
newEndIndex++;
|
|
11414
|
-
}
|
|
11415
|
-
i = newEndIndex;
|
|
11416
11632
|
}
|
|
11417
|
-
|
|
11418
|
-
|
|
11419
|
-
|
|
11420
|
-
|
|
11421
|
-
|
|
11422
|
-
|
|
11423
|
-
for (const elementList of data2) {
|
|
11424
|
-
setExtension(elementList);
|
|
11425
|
-
}
|
|
11426
|
-
}
|
|
11427
|
-
setPropertiesByConceptId(payload) {
|
|
11428
|
-
var _a;
|
|
11429
|
-
const isReadonly = this.draw.isReadonly();
|
|
11430
|
-
if (isReadonly)
|
|
11431
|
-
return;
|
|
11432
|
-
const { conceptId, properties } = payload;
|
|
11433
|
-
let isExistUpdate = false;
|
|
11434
|
-
const pageComponentData = {
|
|
11435
|
-
header: this.draw.getHeaderElementList(),
|
|
11436
|
-
main: this.draw.getOriginalMainElementList(),
|
|
11437
|
-
footer: this.draw.getFooterElementList()
|
|
11438
|
-
};
|
|
11439
|
-
for (const key in pageComponentData) {
|
|
11440
|
-
const elementList = pageComponentData[key];
|
|
11441
|
-
let i = 0;
|
|
11442
|
-
while (i < elementList.length) {
|
|
11443
|
-
const element = elementList[i];
|
|
11444
|
-
i++;
|
|
11445
|
-
if (((_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId) !== conceptId)
|
|
11446
|
-
continue;
|
|
11447
|
-
isExistUpdate = true;
|
|
11448
|
-
element.control = __spreadProps(__spreadValues(__spreadValues({}, element.control), properties), {
|
|
11449
|
-
value: element.control.value
|
|
11450
|
-
});
|
|
11451
|
-
let newEndIndex = i;
|
|
11452
|
-
while (newEndIndex < elementList.length) {
|
|
11453
|
-
const nextElement = elementList[newEndIndex];
|
|
11454
|
-
if (nextElement.controlId !== element.controlId)
|
|
11455
|
-
break;
|
|
11456
|
-
newEndIndex++;
|
|
11633
|
+
if (!element.controlId)
|
|
11634
|
+
return true;
|
|
11635
|
+
if ((_a = element.control) == null ? void 0 : _a.minWidth) {
|
|
11636
|
+
if (element.controlComponent === ControlComponent.PREFIX || element.controlComponent === ControlComponent.POSTFIX) {
|
|
11637
|
+
element.value = "";
|
|
11638
|
+
return true;
|
|
11457
11639
|
}
|
|
11458
|
-
i = newEndIndex;
|
|
11459
11640
|
}
|
|
11460
|
-
|
|
11461
|
-
if (!isExistUpdate)
|
|
11462
|
-
return;
|
|
11463
|
-
for (const key in pageComponentData) {
|
|
11464
|
-
const pageComponentKey = key;
|
|
11465
|
-
const elementList = zipElementList(pageComponentData[pageComponentKey]);
|
|
11466
|
-
pageComponentData[pageComponentKey] = elementList;
|
|
11467
|
-
formatElementList(elementList, {
|
|
11468
|
-
editorOptions: this.options
|
|
11469
|
-
});
|
|
11470
|
-
}
|
|
11471
|
-
this.draw.setEditorData(pageComponentData);
|
|
11472
|
-
this.draw.render({
|
|
11473
|
-
isSetCursor: false
|
|
11641
|
+
return element.controlComponent !== ControlComponent.PREFIX && element.controlComponent !== ControlComponent.POSTFIX && element.controlComponent !== ControlComponent.PLACEHOLDER;
|
|
11474
11642
|
});
|
|
11475
11643
|
}
|
|
11476
|
-
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
|
|
11480
|
-
|
|
11481
|
-
|
|
11482
|
-
const
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11486
|
-
if (element.controlId) {
|
|
11487
|
-
controlElementList.push(element);
|
|
11488
|
-
}
|
|
11489
|
-
}
|
|
11644
|
+
getIsRangeCanCaptureEvent() {
|
|
11645
|
+
if (!this.activeControl)
|
|
11646
|
+
return false;
|
|
11647
|
+
const { startIndex, endIndex } = this.getRange();
|
|
11648
|
+
if (!~startIndex && !~endIndex)
|
|
11649
|
+
return false;
|
|
11650
|
+
const elementList = this.getElementList();
|
|
11651
|
+
const startElement = elementList[startIndex];
|
|
11652
|
+
if (startIndex === endIndex && startElement.controlComponent === ControlComponent.POSTFIX) {
|
|
11653
|
+
return true;
|
|
11490
11654
|
}
|
|
11491
|
-
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
|
|
11496
|
-
drawBorder(ctx) {
|
|
11497
|
-
this.controlBorder.render(ctx);
|
|
11655
|
+
const endElement = elementList[endIndex];
|
|
11656
|
+
if (startElement.controlId && startElement.controlId === endElement.controlId && endElement.controlComponent !== ControlComponent.POSTFIX) {
|
|
11657
|
+
return true;
|
|
11658
|
+
}
|
|
11659
|
+
return false;
|
|
11498
11660
|
}
|
|
11499
|
-
|
|
11661
|
+
getIsRangeInPostfix() {
|
|
11500
11662
|
if (!this.activeControl)
|
|
11501
|
-
return
|
|
11502
|
-
const
|
|
11503
|
-
|
|
11504
|
-
|
|
11505
|
-
|
|
11506
|
-
const
|
|
11507
|
-
|
|
11508
|
-
|
|
11509
|
-
|
|
11510
|
-
|
|
11511
|
-
|
|
11512
|
-
|
|
11513
|
-
|
|
11514
|
-
|
|
11515
|
-
|
|
11516
|
-
|
|
11517
|
-
|
|
11518
|
-
|
|
11519
|
-
|
|
11520
|
-
|
|
11521
|
-
|
|
11522
|
-
|
|
11523
|
-
|
|
11524
|
-
|
|
11525
|
-
|
|
11526
|
-
|
|
11527
|
-
|
|
11528
|
-
|
|
11529
|
-
|
|
11530
|
-
|
|
11531
|
-
|
|
11532
|
-
|
|
11533
|
-
|
|
11534
|
-
|
|
11535
|
-
|
|
11536
|
-
|
|
11537
|
-
|
|
11538
|
-
|
|
11539
|
-
|
|
11540
|
-
|
|
11541
|
-
|
|
11542
|
-
|
|
11543
|
-
|
|
11544
|
-
|
|
11663
|
+
return false;
|
|
11664
|
+
const { startIndex, endIndex } = this.getRange();
|
|
11665
|
+
if (startIndex !== endIndex)
|
|
11666
|
+
return false;
|
|
11667
|
+
const elementList = this.getElementList();
|
|
11668
|
+
const element = elementList[startIndex];
|
|
11669
|
+
return element.controlComponent === ControlComponent.POSTFIX;
|
|
11670
|
+
}
|
|
11671
|
+
getIsRangeWithinControl() {
|
|
11672
|
+
const { startIndex, endIndex } = this.getRange();
|
|
11673
|
+
if (!~startIndex && !~endIndex)
|
|
11674
|
+
return false;
|
|
11675
|
+
const elementList = this.getElementList();
|
|
11676
|
+
const startElement = elementList[startIndex];
|
|
11677
|
+
const endElement = elementList[endIndex];
|
|
11678
|
+
if (startElement.controlId && startElement.controlId === endElement.controlId && endElement.controlComponent !== ControlComponent.POSTFIX) {
|
|
11679
|
+
return true;
|
|
11680
|
+
}
|
|
11681
|
+
return false;
|
|
11682
|
+
}
|
|
11683
|
+
getIsDisabledControl() {
|
|
11684
|
+
var _a, _b;
|
|
11685
|
+
return !!((_b = (_a = this.activeControl) == null ? void 0 : _a.getElement().control) == null ? void 0 : _b.disabled);
|
|
11686
|
+
}
|
|
11687
|
+
getContainer() {
|
|
11688
|
+
return this.draw.getContainer();
|
|
11689
|
+
}
|
|
11690
|
+
getElementList() {
|
|
11691
|
+
return this.draw.getElementList();
|
|
11692
|
+
}
|
|
11693
|
+
getPosition() {
|
|
11694
|
+
const positionList = this.draw.getPosition().getPositionList();
|
|
11695
|
+
const { endIndex } = this.range.getRange();
|
|
11696
|
+
return positionList[endIndex] || null;
|
|
11697
|
+
}
|
|
11698
|
+
getPreY() {
|
|
11699
|
+
var _a, _b;
|
|
11700
|
+
const height = this.draw.getHeight();
|
|
11701
|
+
const pageGap = this.draw.getPageGap();
|
|
11702
|
+
const pageNo = (_b = (_a = this.getPosition()) == null ? void 0 : _a.pageNo) != null ? _b : this.draw.getPageNo();
|
|
11703
|
+
return pageNo * (height + pageGap);
|
|
11704
|
+
}
|
|
11705
|
+
getRange() {
|
|
11706
|
+
return this.range.getRange();
|
|
11707
|
+
}
|
|
11708
|
+
shrinkBoundary(context = {}) {
|
|
11709
|
+
this.range.shrinkBoundary(context);
|
|
11710
|
+
}
|
|
11711
|
+
getActiveControl() {
|
|
11712
|
+
return this.activeControl;
|
|
11713
|
+
}
|
|
11714
|
+
initControl() {
|
|
11715
|
+
const isReadonly = this.draw.isReadonly();
|
|
11716
|
+
if (isReadonly)
|
|
11717
|
+
return;
|
|
11718
|
+
const elementList = this.getElementList();
|
|
11719
|
+
const range = this.getRange();
|
|
11720
|
+
const element = elementList[range.startIndex];
|
|
11721
|
+
if (this.activeControl) {
|
|
11722
|
+
if (this.activeControl instanceof SelectControl || this.activeControl instanceof DateControl) {
|
|
11723
|
+
if (element.controlComponent === ControlComponent.POSTFIX) {
|
|
11724
|
+
this.activeControl.destroy();
|
|
11725
|
+
} else {
|
|
11726
|
+
this.activeControl.awake();
|
|
11545
11727
|
}
|
|
11546
|
-
return {
|
|
11547
|
-
positionContext: {
|
|
11548
|
-
isTable: false
|
|
11549
|
-
},
|
|
11550
|
-
nextIndex
|
|
11551
|
-
};
|
|
11552
11728
|
}
|
|
11553
|
-
|
|
11729
|
+
const controlElement = this.activeControl.getElement();
|
|
11730
|
+
if (element.controlId === controlElement.controlId)
|
|
11731
|
+
return;
|
|
11554
11732
|
}
|
|
11555
|
-
|
|
11556
|
-
const
|
|
11557
|
-
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
|
|
11561
|
-
|
|
11562
|
-
|
|
11733
|
+
this.destroyControl();
|
|
11734
|
+
const control = element.control;
|
|
11735
|
+
if (control.type === ControlType.TEXT) {
|
|
11736
|
+
this.activeControl = new TextControl(element, this);
|
|
11737
|
+
} else if (control.type === ControlType.SELECT) {
|
|
11738
|
+
const selectControl = new SelectControl(element, this);
|
|
11739
|
+
this.activeControl = selectControl;
|
|
11740
|
+
selectControl.awake();
|
|
11741
|
+
} else if (control.type === ControlType.CHECKBOX) {
|
|
11742
|
+
this.activeControl = new CheckboxControl(element, this);
|
|
11743
|
+
} else if (control.type === ControlType.RADIO) {
|
|
11744
|
+
this.activeControl = new RadioControl(element, this);
|
|
11745
|
+
} else if (control.type === ControlType.DATE) {
|
|
11746
|
+
const dateControl = new DateControl(element, this);
|
|
11747
|
+
this.activeControl = dateControl;
|
|
11748
|
+
dateControl.awake();
|
|
11563
11749
|
}
|
|
11564
|
-
|
|
11565
|
-
|
|
11566
|
-
const
|
|
11567
|
-
const
|
|
11568
|
-
|
|
11569
|
-
|
|
11570
|
-
|
|
11571
|
-
|
|
11572
|
-
|
|
11573
|
-
|
|
11574
|
-
|
|
11575
|
-
|
|
11576
|
-
if (context3) {
|
|
11577
|
-
return {
|
|
11578
|
-
positionContext: {
|
|
11579
|
-
isTable: true,
|
|
11580
|
-
index: positionContext.index,
|
|
11581
|
-
trIndex: r,
|
|
11582
|
-
tdIndex: d,
|
|
11583
|
-
tdId: td.id,
|
|
11584
|
-
trId: tr.id,
|
|
11585
|
-
tableId: controlElement.tableId
|
|
11586
|
-
},
|
|
11587
|
-
nextIndex: context3.nextIndex
|
|
11588
|
-
};
|
|
11589
|
-
}
|
|
11590
|
-
}
|
|
11750
|
+
nextTick(() => {
|
|
11751
|
+
var _a;
|
|
11752
|
+
const controlChangeListener = this.listener.controlChange;
|
|
11753
|
+
const isSubscribeControlChange = this.eventBus.isSubscribe("controlChange");
|
|
11754
|
+
if (!controlChangeListener && !isSubscribeControlChange)
|
|
11755
|
+
return;
|
|
11756
|
+
let payload;
|
|
11757
|
+
const value = (_a = this.activeControl) == null ? void 0 : _a.getValue();
|
|
11758
|
+
if (value && value.length) {
|
|
11759
|
+
payload = zipElementList(value)[0].control;
|
|
11760
|
+
} else {
|
|
11761
|
+
payload = pickElementAttr(deepClone(element)).control;
|
|
11591
11762
|
}
|
|
11592
|
-
|
|
11593
|
-
|
|
11594
|
-
return {
|
|
11595
|
-
positionContext: {
|
|
11596
|
-
isTable: false
|
|
11597
|
-
},
|
|
11598
|
-
nextIndex: context2.nextIndex
|
|
11599
|
-
};
|
|
11763
|
+
if (controlChangeListener) {
|
|
11764
|
+
controlChangeListener(payload);
|
|
11600
11765
|
}
|
|
11601
|
-
|
|
11602
|
-
|
|
11766
|
+
if (isSubscribeControlChange) {
|
|
11767
|
+
this.eventBus.emit("controlChange", payload);
|
|
11768
|
+
}
|
|
11769
|
+
});
|
|
11603
11770
|
}
|
|
11604
|
-
|
|
11605
|
-
if (
|
|
11606
|
-
|
|
11607
|
-
|
|
11608
|
-
|
|
11609
|
-
|
|
11610
|
-
|
|
11611
|
-
|
|
11612
|
-
|
|
11613
|
-
|
|
11614
|
-
|
|
11615
|
-
if (
|
|
11616
|
-
|
|
11617
|
-
for (let r = 0; r < trList.length; r++) {
|
|
11618
|
-
const tr = trList[r];
|
|
11619
|
-
const tdList = tr.tdList;
|
|
11620
|
-
for (let d = 0; d < tdList.length; d++) {
|
|
11621
|
-
const td = tdList[d];
|
|
11622
|
-
const context2 = getNextContext(td.value, 0);
|
|
11623
|
-
if (context2) {
|
|
11624
|
-
return {
|
|
11625
|
-
positionContext: {
|
|
11626
|
-
isTable: true,
|
|
11627
|
-
index: e,
|
|
11628
|
-
trIndex: r,
|
|
11629
|
-
tdIndex: d,
|
|
11630
|
-
tdId: td.id,
|
|
11631
|
-
trId: tr.id,
|
|
11632
|
-
tableId: element.id
|
|
11633
|
-
},
|
|
11634
|
-
nextIndex: context2.nextIndex
|
|
11635
|
-
};
|
|
11636
|
-
}
|
|
11637
|
-
}
|
|
11638
|
-
}
|
|
11771
|
+
destroyControl() {
|
|
11772
|
+
if (this.activeControl) {
|
|
11773
|
+
if (this.activeControl instanceof SelectControl || this.activeControl instanceof DateControl) {
|
|
11774
|
+
this.activeControl.destroy();
|
|
11775
|
+
}
|
|
11776
|
+
this.activeControl = null;
|
|
11777
|
+
nextTick(() => {
|
|
11778
|
+
const controlChangeListener = this.listener.controlChange;
|
|
11779
|
+
const isSubscribeControlChange = this.eventBus.isSubscribe("controlChange");
|
|
11780
|
+
if (!controlChangeListener && !isSubscribeControlChange)
|
|
11781
|
+
return;
|
|
11782
|
+
if (controlChangeListener) {
|
|
11783
|
+
controlChangeListener(null);
|
|
11639
11784
|
}
|
|
11640
|
-
if (
|
|
11641
|
-
|
|
11785
|
+
if (isSubscribeControlChange) {
|
|
11786
|
+
this.eventBus.emit("controlChange", null);
|
|
11642
11787
|
}
|
|
11643
|
-
|
|
11644
|
-
positionContext: {
|
|
11645
|
-
isTable: false
|
|
11646
|
-
},
|
|
11647
|
-
nextIndex: e
|
|
11648
|
-
};
|
|
11649
|
-
}
|
|
11650
|
-
return null;
|
|
11651
|
-
}
|
|
11652
|
-
const { endIndex } = this.range.getRange();
|
|
11653
|
-
const elementList = this.getElementList();
|
|
11654
|
-
const context = getNextContext(elementList, endIndex);
|
|
11655
|
-
if (context) {
|
|
11656
|
-
return {
|
|
11657
|
-
positionContext: positionContext.isTable ? positionContext : context.positionContext,
|
|
11658
|
-
nextIndex: context.nextIndex
|
|
11659
|
-
};
|
|
11788
|
+
});
|
|
11660
11789
|
}
|
|
11661
|
-
if (controlElement.tableId) {
|
|
11662
|
-
const originalElementList = this.draw.getOriginalElementList();
|
|
11663
|
-
const { index: index2, trIndex, tdIndex } = positionContext;
|
|
11664
|
-
const trList = originalElementList[index2].trList;
|
|
11665
|
-
for (let r = trIndex; r < trList.length; r++) {
|
|
11666
|
-
const tr = trList[r];
|
|
11667
|
-
const tdList = tr.tdList;
|
|
11668
|
-
for (let d = 0; d < tdList.length; d++) {
|
|
11669
|
-
if (trIndex === r && d <= tdIndex)
|
|
11670
|
-
continue;
|
|
11671
|
-
const td = tdList[d];
|
|
11672
|
-
const context3 = getNextContext(td.value, 0);
|
|
11673
|
-
if (context3) {
|
|
11674
|
-
return {
|
|
11675
|
-
positionContext: {
|
|
11676
|
-
isTable: true,
|
|
11677
|
-
index: positionContext.index,
|
|
11678
|
-
trIndex: r,
|
|
11679
|
-
tdIndex: d,
|
|
11680
|
-
tdId: td.id,
|
|
11681
|
-
trId: tr.id,
|
|
11682
|
-
tableId: controlElement.tableId
|
|
11683
|
-
},
|
|
11684
|
-
nextIndex: context3.nextIndex
|
|
11685
|
-
};
|
|
11686
|
-
}
|
|
11687
|
-
}
|
|
11688
|
-
}
|
|
11689
|
-
const context2 = getNextContext(originalElementList, index2 + 1);
|
|
11690
|
-
if (context2) {
|
|
11691
|
-
return {
|
|
11692
|
-
positionContext: {
|
|
11693
|
-
isTable: false
|
|
11694
|
-
},
|
|
11695
|
-
nextIndex: context2.nextIndex
|
|
11696
|
-
};
|
|
11697
|
-
}
|
|
11698
|
-
}
|
|
11699
|
-
return null;
|
|
11700
11790
|
}
|
|
11701
|
-
|
|
11702
|
-
const {
|
|
11703
|
-
|
|
11704
|
-
|
|
11705
|
-
|
|
11791
|
+
repaintControl(options = {}) {
|
|
11792
|
+
const { curIndex, isCompute = true, isSubmitHistory = true } = options;
|
|
11793
|
+
if (curIndex === void 0) {
|
|
11794
|
+
this.range.clearRange();
|
|
11795
|
+
this.draw.render({
|
|
11796
|
+
isCompute,
|
|
11797
|
+
isSubmitHistory,
|
|
11798
|
+
isSetCursor: false
|
|
11799
|
+
});
|
|
11706
11800
|
} else {
|
|
11707
|
-
|
|
11801
|
+
this.range.setRange(curIndex, curIndex);
|
|
11802
|
+
this.draw.render({
|
|
11803
|
+
curIndex,
|
|
11804
|
+
isCompute,
|
|
11805
|
+
isSubmitHistory
|
|
11806
|
+
});
|
|
11708
11807
|
}
|
|
11709
|
-
if (!context)
|
|
11710
|
-
return;
|
|
11711
|
-
const { nextIndex, positionContext } = context;
|
|
11712
|
-
const position = this.draw.getPosition();
|
|
11713
|
-
position.setPositionContext(positionContext);
|
|
11714
|
-
this.draw.getRange().replaceRange({
|
|
11715
|
-
startIndex: nextIndex,
|
|
11716
|
-
endIndex: nextIndex
|
|
11717
|
-
});
|
|
11718
|
-
this.draw.render({
|
|
11719
|
-
curIndex: nextIndex,
|
|
11720
|
-
isCompute: false,
|
|
11721
|
-
isSetCursor: true,
|
|
11722
|
-
isSubmitHistory: false
|
|
11723
|
-
});
|
|
11724
|
-
const positionList = position.getPositionList();
|
|
11725
|
-
this.draw.getCursor().moveCursorToVisible({
|
|
11726
|
-
cursorPosition: positionList[nextIndex],
|
|
11727
|
-
direction
|
|
11728
|
-
});
|
|
11729
11808
|
}
|
|
11730
|
-
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
this.
|
|
11737
|
-
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
if (checkbox) {
|
|
11741
|
-
checkbox.value = !checkbox.value;
|
|
11742
|
-
} else {
|
|
11743
|
-
element.checkbox = {
|
|
11744
|
-
value: true
|
|
11745
|
-
};
|
|
11809
|
+
reAwakeControl() {
|
|
11810
|
+
if (!this.activeControl)
|
|
11811
|
+
return;
|
|
11812
|
+
const elementList = this.getElementList();
|
|
11813
|
+
const range = this.getRange();
|
|
11814
|
+
const element = elementList[range.startIndex];
|
|
11815
|
+
this.activeControl.setElement(element);
|
|
11816
|
+
if ((this.activeControl instanceof DateControl || this.activeControl instanceof SelectControl) && this.activeControl.getIsPopup()) {
|
|
11817
|
+
this.activeControl.destroy();
|
|
11818
|
+
this.activeControl.awake();
|
|
11746
11819
|
}
|
|
11747
|
-
this.draw.render({
|
|
11748
|
-
isCompute: false,
|
|
11749
|
-
isSetCursor: false
|
|
11750
|
-
});
|
|
11751
11820
|
}
|
|
11752
|
-
|
|
11753
|
-
const {
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
const
|
|
11757
|
-
|
|
11758
|
-
|
|
11759
|
-
|
|
11760
|
-
ctx.beginPath();
|
|
11761
|
-
ctx.translate(0.5, 0.5);
|
|
11762
|
-
if (checkbox == null ? void 0 : checkbox.value) {
|
|
11763
|
-
ctx.lineWidth = lineWidth;
|
|
11764
|
-
ctx.strokeStyle = fillStyle;
|
|
11765
|
-
ctx.rect(left2, top, width, height);
|
|
11766
|
-
ctx.stroke();
|
|
11767
|
-
ctx.beginPath();
|
|
11768
|
-
ctx.fillStyle = fillStyle;
|
|
11769
|
-
ctx.fillRect(left2, top, width, height);
|
|
11770
|
-
ctx.beginPath();
|
|
11771
|
-
ctx.strokeStyle = strokeStyle;
|
|
11772
|
-
ctx.lineWidth = lineWidth * 2 * scale;
|
|
11773
|
-
ctx.moveTo(left2 + 2 * scale, top + height / 2);
|
|
11774
|
-
ctx.lineTo(left2 + width / 2, top + height - 3 * scale);
|
|
11775
|
-
ctx.lineTo(left2 + width - 2 * scale, top + 3 * scale);
|
|
11776
|
-
ctx.stroke();
|
|
11821
|
+
moveCursor(position) {
|
|
11822
|
+
const { index: index2, trIndex, tdIndex, tdValueIndex } = position;
|
|
11823
|
+
let elementList = this.draw.getOriginalElementList();
|
|
11824
|
+
let element;
|
|
11825
|
+
const newIndex = position.isTable ? tdValueIndex : index2;
|
|
11826
|
+
if (position.isTable) {
|
|
11827
|
+
elementList = elementList[index2].trList[trIndex].tdList[tdIndex].value;
|
|
11828
|
+
element = elementList[tdValueIndex];
|
|
11777
11829
|
} else {
|
|
11778
|
-
|
|
11779
|
-
ctx.rect(left2, top, width, height);
|
|
11780
|
-
ctx.stroke();
|
|
11830
|
+
element = elementList[index2];
|
|
11781
11831
|
}
|
|
11782
|
-
|
|
11783
|
-
|
|
11784
|
-
|
|
11785
|
-
|
|
11786
|
-
class RadioParticle {
|
|
11787
|
-
constructor(draw) {
|
|
11788
|
-
__publicField(this, "draw");
|
|
11789
|
-
__publicField(this, "options");
|
|
11790
|
-
this.draw = draw;
|
|
11791
|
-
this.options = draw.getOptions();
|
|
11792
|
-
}
|
|
11793
|
-
setSelect(element) {
|
|
11794
|
-
const { radio } = element;
|
|
11795
|
-
if (radio) {
|
|
11796
|
-
radio.value = !radio.value;
|
|
11797
|
-
} else {
|
|
11798
|
-
element.radio = {
|
|
11799
|
-
value: true
|
|
11832
|
+
if (element.controlComponent === ControlComponent.VALUE) {
|
|
11833
|
+
return {
|
|
11834
|
+
newIndex,
|
|
11835
|
+
newElement: element
|
|
11800
11836
|
};
|
|
11837
|
+
} else if (element.controlComponent === ControlComponent.POSTFIX) {
|
|
11838
|
+
let startIndex = newIndex + 1;
|
|
11839
|
+
while (startIndex < elementList.length) {
|
|
11840
|
+
const nextElement = elementList[startIndex];
|
|
11841
|
+
if (nextElement.controlId !== element.controlId) {
|
|
11842
|
+
return {
|
|
11843
|
+
newIndex: startIndex - 1,
|
|
11844
|
+
newElement: elementList[startIndex - 1]
|
|
11845
|
+
};
|
|
11846
|
+
}
|
|
11847
|
+
startIndex++;
|
|
11848
|
+
}
|
|
11849
|
+
} else if (element.controlComponent === ControlComponent.PREFIX) {
|
|
11850
|
+
let startIndex = newIndex + 1;
|
|
11851
|
+
while (startIndex < elementList.length) {
|
|
11852
|
+
const nextElement = elementList[startIndex];
|
|
11853
|
+
if (nextElement.controlId !== element.controlId || nextElement.controlComponent !== ControlComponent.PREFIX) {
|
|
11854
|
+
return {
|
|
11855
|
+
newIndex: startIndex - 1,
|
|
11856
|
+
newElement: elementList[startIndex - 1]
|
|
11857
|
+
};
|
|
11858
|
+
}
|
|
11859
|
+
startIndex++;
|
|
11860
|
+
}
|
|
11861
|
+
} else if (element.controlComponent === ControlComponent.PLACEHOLDER) {
|
|
11862
|
+
let startIndex = newIndex - 1;
|
|
11863
|
+
while (startIndex > 0) {
|
|
11864
|
+
const preElement = elementList[startIndex];
|
|
11865
|
+
if (preElement.controlId !== element.controlId || preElement.controlComponent === ControlComponent.PREFIX) {
|
|
11866
|
+
return {
|
|
11867
|
+
newIndex: startIndex,
|
|
11868
|
+
newElement: elementList[startIndex]
|
|
11869
|
+
};
|
|
11870
|
+
}
|
|
11871
|
+
startIndex--;
|
|
11872
|
+
}
|
|
11801
11873
|
}
|
|
11802
|
-
|
|
11803
|
-
|
|
11804
|
-
|
|
11805
|
-
}
|
|
11874
|
+
return {
|
|
11875
|
+
newIndex,
|
|
11876
|
+
newElement: element
|
|
11877
|
+
};
|
|
11806
11878
|
}
|
|
11807
|
-
|
|
11808
|
-
const
|
|
11809
|
-
const
|
|
11810
|
-
const
|
|
11811
|
-
|
|
11812
|
-
|
|
11813
|
-
|
|
11814
|
-
|
|
11815
|
-
|
|
11816
|
-
|
|
11817
|
-
|
|
11818
|
-
|
|
11819
|
-
|
|
11820
|
-
|
|
11821
|
-
|
|
11822
|
-
|
|
11823
|
-
ctx.fillStyle = fillStyle;
|
|
11824
|
-
ctx.arc(left2 + width / 2, top + height / 2, width / 3, 0, Math.PI * 2);
|
|
11825
|
-
ctx.fill();
|
|
11879
|
+
removeControl(startIndex, context = {}) {
|
|
11880
|
+
const elementList = context.elementList || this.getElementList();
|
|
11881
|
+
const startElement = elementList[startIndex];
|
|
11882
|
+
const { deletable = true } = startElement.control;
|
|
11883
|
+
if (!deletable)
|
|
11884
|
+
return null;
|
|
11885
|
+
let leftIndex = -1;
|
|
11886
|
+
let rightIndex = -1;
|
|
11887
|
+
let preIndex = startIndex;
|
|
11888
|
+
while (preIndex > 0) {
|
|
11889
|
+
const preElement = elementList[preIndex];
|
|
11890
|
+
if (preElement.controlId !== startElement.controlId) {
|
|
11891
|
+
leftIndex = preIndex;
|
|
11892
|
+
break;
|
|
11893
|
+
}
|
|
11894
|
+
preIndex--;
|
|
11826
11895
|
}
|
|
11827
|
-
|
|
11828
|
-
|
|
11829
|
-
|
|
11830
|
-
|
|
11831
|
-
|
|
11832
|
-
|
|
11833
|
-
|
|
11834
|
-
|
|
11835
|
-
|
|
11836
|
-
|
|
11837
|
-
|
|
11838
|
-
|
|
11839
|
-
|
|
11840
|
-
|
|
11841
|
-
|
|
11842
|
-
|
|
11843
|
-
|
|
11844
|
-
const objURL = blob$1 && (window.URL || window.webkitURL).createObjectURL(blob$1);
|
|
11845
|
-
try {
|
|
11846
|
-
return objURL ? new Worker(objURL) : new Worker("data:application/javascript;base64," + encodedJs$1, { type: "module" });
|
|
11847
|
-
} finally {
|
|
11848
|
-
objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
|
|
11849
|
-
}
|
|
11850
|
-
}
|
|
11851
|
-
const encodedJs = "KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBuOyhmdW5jdGlvbihvKXtvLlRBQkxFPSJ0YWJsZSJ9KShufHwobj17fSkpO2Z1bmN0aW9uIGMobyl7Y29uc3QgdD1bXTtmb3IoY29uc3QgcyBvZiBvKXtpZihzLnR5cGU9PT1uLlRBQkxFKXtjb25zdCBlPXMudHJMaXN0O2ZvcihsZXQgcj0wO3I8ZS5sZW5ndGg7cisrKXtjb25zdCBpPWVbcl07Zm9yKGxldCB1PTA7dTxpLnRkTGlzdC5sZW5ndGg7dSsrKXtjb25zdCBkPWkudGRMaXN0W3VdO3QucHVzaCguLi5jKGQudmFsdWUpKX19fWlmKCEhcy5ncm91cElkcylmb3IoY29uc3QgZSBvZiBzLmdyb3VwSWRzKXQuaW5jbHVkZXMoZSl8fHQucHVzaChlKX1yZXR1cm4gdH1vbm1lc3NhZ2U9bz0+e2NvbnN0IHQ9by5kYXRhLHM9Yyh0KTtwb3N0TWVzc2FnZShzKX19KSgpO30pKCk7Cg==";
|
|
11852
|
-
const blob = typeof window !== "undefined" && window.Blob && new Blob([atob(encodedJs)], { type: "text/javascript;charset=utf-8" });
|
|
11853
|
-
function WorkerWrapper() {
|
|
11854
|
-
const objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
|
|
11855
|
-
try {
|
|
11856
|
-
return objURL ? new Worker(objURL) : new Worker("data:application/javascript;base64," + encodedJs, { type: "module" });
|
|
11857
|
-
} finally {
|
|
11858
|
-
objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
|
|
11859
|
-
}
|
|
11860
|
-
}
|
|
11861
|
-
class WorkerManager {
|
|
11862
|
-
constructor(draw) {
|
|
11863
|
-
__publicField(this, "draw");
|
|
11864
|
-
__publicField(this, "wordCountWorker");
|
|
11865
|
-
__publicField(this, "catalogWorker");
|
|
11866
|
-
__publicField(this, "groupWorker");
|
|
11867
|
-
this.draw = draw;
|
|
11868
|
-
this.wordCountWorker = new WorkerWrapper$2();
|
|
11869
|
-
this.catalogWorker = new WorkerWrapper$1();
|
|
11870
|
-
this.groupWorker = new WorkerWrapper();
|
|
11871
|
-
}
|
|
11872
|
-
getWordCount() {
|
|
11873
|
-
return new Promise((resolve, reject) => {
|
|
11874
|
-
this.wordCountWorker.onmessage = (evt) => {
|
|
11875
|
-
resolve(evt.data);
|
|
11876
|
-
};
|
|
11877
|
-
this.wordCountWorker.onerror = (evt) => {
|
|
11878
|
-
reject(evt);
|
|
11879
|
-
};
|
|
11880
|
-
const elementList = this.draw.getOriginalMainElementList();
|
|
11881
|
-
this.wordCountWorker.postMessage(elementList);
|
|
11882
|
-
});
|
|
11896
|
+
let nextIndex = startIndex + 1;
|
|
11897
|
+
while (nextIndex < elementList.length) {
|
|
11898
|
+
const nextElement = elementList[nextIndex];
|
|
11899
|
+
if (nextElement.controlId !== startElement.controlId) {
|
|
11900
|
+
rightIndex = nextIndex - 1;
|
|
11901
|
+
break;
|
|
11902
|
+
}
|
|
11903
|
+
nextIndex++;
|
|
11904
|
+
}
|
|
11905
|
+
if (nextIndex === elementList.length) {
|
|
11906
|
+
rightIndex = nextIndex - 1;
|
|
11907
|
+
}
|
|
11908
|
+
if (!~leftIndex && !~rightIndex)
|
|
11909
|
+
return startIndex;
|
|
11910
|
+
leftIndex = ~leftIndex ? leftIndex : 0;
|
|
11911
|
+
this.draw.spliceElementList(elementList, leftIndex + 1, rightIndex - leftIndex);
|
|
11912
|
+
return leftIndex;
|
|
11883
11913
|
}
|
|
11884
|
-
|
|
11885
|
-
|
|
11886
|
-
|
|
11887
|
-
|
|
11888
|
-
|
|
11889
|
-
|
|
11890
|
-
|
|
11891
|
-
|
|
11892
|
-
|
|
11893
|
-
|
|
11894
|
-
|
|
11914
|
+
removePlaceholder(startIndex, context = {}) {
|
|
11915
|
+
const elementList = context.elementList || this.getElementList();
|
|
11916
|
+
const startElement = elementList[startIndex];
|
|
11917
|
+
const nextElement = elementList[startIndex + 1];
|
|
11918
|
+
if (startElement.controlComponent === ControlComponent.PLACEHOLDER || nextElement.controlComponent === ControlComponent.PLACEHOLDER) {
|
|
11919
|
+
let isHasSubmitHistory = false;
|
|
11920
|
+
let index2 = startIndex;
|
|
11921
|
+
while (index2 < elementList.length) {
|
|
11922
|
+
const curElement = elementList[index2];
|
|
11923
|
+
if (curElement.controlId !== startElement.controlId)
|
|
11924
|
+
break;
|
|
11925
|
+
if (curElement.controlComponent === ControlComponent.PLACEHOLDER) {
|
|
11926
|
+
if (!isHasSubmitHistory) {
|
|
11927
|
+
isHasSubmitHistory = true;
|
|
11928
|
+
this.draw.getHistoryManager().popUndo();
|
|
11929
|
+
this.draw.submitHistory(startIndex);
|
|
11930
|
+
}
|
|
11931
|
+
elementList.splice(index2, 1);
|
|
11932
|
+
} else {
|
|
11933
|
+
index2++;
|
|
11934
|
+
}
|
|
11935
|
+
}
|
|
11936
|
+
}
|
|
11895
11937
|
}
|
|
11896
|
-
|
|
11897
|
-
|
|
11898
|
-
|
|
11899
|
-
|
|
11900
|
-
|
|
11901
|
-
|
|
11902
|
-
|
|
11938
|
+
addPlaceholder(startIndex, context = {}) {
|
|
11939
|
+
const elementList = context.elementList || this.getElementList();
|
|
11940
|
+
const startElement = elementList[startIndex];
|
|
11941
|
+
const control = startElement.control;
|
|
11942
|
+
if (!control.placeholder)
|
|
11943
|
+
return;
|
|
11944
|
+
const placeholderStrList = splitText(control.placeholder);
|
|
11945
|
+
for (let p = 0; p < placeholderStrList.length; p++) {
|
|
11946
|
+
const value = placeholderStrList[p];
|
|
11947
|
+
const newElement = {
|
|
11948
|
+
value,
|
|
11949
|
+
controlId: startElement.controlId,
|
|
11950
|
+
type: ElementType.CONTROL,
|
|
11951
|
+
control: startElement.control,
|
|
11952
|
+
controlComponent: ControlComponent.PLACEHOLDER,
|
|
11953
|
+
color: this.controlOptions.placeholderColor
|
|
11903
11954
|
};
|
|
11904
|
-
|
|
11905
|
-
this.
|
|
11906
|
-
}
|
|
11955
|
+
formatElementContext(elementList, [newElement], startIndex);
|
|
11956
|
+
this.draw.spliceElementList(elementList, startIndex + p + 1, 0, newElement);
|
|
11957
|
+
}
|
|
11907
11958
|
}
|
|
11908
|
-
|
|
11909
|
-
|
|
11910
|
-
|
|
11911
|
-
|
|
11912
|
-
|
|
11913
|
-
__publicField(this, "draw");
|
|
11914
|
-
__publicField(this, "options");
|
|
11915
|
-
__publicField(this, "curElement");
|
|
11916
|
-
__publicField(this, "curElementSrc");
|
|
11917
|
-
__publicField(this, "previewerDrawOption");
|
|
11918
|
-
__publicField(this, "curPosition");
|
|
11919
|
-
__publicField(this, "resizerSelection");
|
|
11920
|
-
__publicField(this, "resizerHandleList");
|
|
11921
|
-
__publicField(this, "resizerImageContainer");
|
|
11922
|
-
__publicField(this, "resizerImage");
|
|
11923
|
-
__publicField(this, "resizerSize");
|
|
11924
|
-
__publicField(this, "width");
|
|
11925
|
-
__publicField(this, "height");
|
|
11926
|
-
__publicField(this, "mousedownX");
|
|
11927
|
-
__publicField(this, "mousedownY");
|
|
11928
|
-
__publicField(this, "curHandleIndex");
|
|
11929
|
-
__publicField(this, "previewerContainer");
|
|
11930
|
-
__publicField(this, "previewerImage");
|
|
11931
|
-
__publicField(this, "_keydown", () => {
|
|
11932
|
-
if (this.resizerSelection.style.display === "block") {
|
|
11933
|
-
this.clearResizer();
|
|
11934
|
-
document.removeEventListener("keydown", this._keydown);
|
|
11935
|
-
}
|
|
11936
|
-
});
|
|
11937
|
-
this.container = draw.getContainer();
|
|
11938
|
-
this.canvas = draw.getPage();
|
|
11939
|
-
this.draw = draw;
|
|
11940
|
-
this.options = draw.getOptions();
|
|
11941
|
-
this.curElement = null;
|
|
11942
|
-
this.curElementSrc = "";
|
|
11943
|
-
this.previewerDrawOption = {};
|
|
11944
|
-
this.curPosition = null;
|
|
11945
|
-
const { resizerSelection, resizerHandleList, resizerImageContainer, resizerImage, resizerSize } = this._createResizerDom();
|
|
11946
|
-
this.resizerSelection = resizerSelection;
|
|
11947
|
-
this.resizerHandleList = resizerHandleList;
|
|
11948
|
-
this.resizerImageContainer = resizerImageContainer;
|
|
11949
|
-
this.resizerImage = resizerImage;
|
|
11950
|
-
this.resizerSize = resizerSize;
|
|
11951
|
-
this.width = 0;
|
|
11952
|
-
this.height = 0;
|
|
11953
|
-
this.mousedownX = 0;
|
|
11954
|
-
this.mousedownY = 0;
|
|
11955
|
-
this.curHandleIndex = 0;
|
|
11956
|
-
this.previewerContainer = null;
|
|
11957
|
-
this.previewerImage = null;
|
|
11959
|
+
setValue(data2) {
|
|
11960
|
+
if (!this.activeControl) {
|
|
11961
|
+
throw new Error("active control is null");
|
|
11962
|
+
}
|
|
11963
|
+
return this.activeControl.setValue(data2);
|
|
11958
11964
|
}
|
|
11959
|
-
|
|
11960
|
-
|
|
11961
|
-
|
|
11962
|
-
let y = 0;
|
|
11963
|
-
const height = this.draw.getHeight();
|
|
11964
|
-
const pageGap = this.draw.getPageGap();
|
|
11965
|
-
const pageNo = (_a = position == null ? void 0 : position.pageNo) != null ? _a : this.draw.getPageNo();
|
|
11966
|
-
const preY = pageNo * (height + pageGap);
|
|
11967
|
-
if (element.imgFloatPosition) {
|
|
11968
|
-
x = element.imgFloatPosition.x;
|
|
11969
|
-
y = element.imgFloatPosition.y + preY;
|
|
11970
|
-
} else if (position) {
|
|
11971
|
-
const { coordinate: { leftTop: [left2, top] }, ascent } = position;
|
|
11972
|
-
x = left2;
|
|
11973
|
-
y = top + preY + ascent;
|
|
11965
|
+
keydown(evt) {
|
|
11966
|
+
if (!this.activeControl) {
|
|
11967
|
+
throw new Error("active control is null");
|
|
11974
11968
|
}
|
|
11975
|
-
return
|
|
11969
|
+
return this.activeControl.keydown(evt);
|
|
11976
11970
|
}
|
|
11977
|
-
|
|
11978
|
-
|
|
11979
|
-
|
|
11980
|
-
resizerSelection.style.display = "none";
|
|
11981
|
-
resizerSelection.style.borderColor = this.options.resizerColor;
|
|
11982
|
-
const resizerHandleList = [];
|
|
11983
|
-
for (let i = 0; i < 8; i++) {
|
|
11984
|
-
const handleDom = document.createElement("div");
|
|
11985
|
-
handleDom.style.background = this.options.resizerColor;
|
|
11986
|
-
handleDom.classList.add(`resizer-handle`);
|
|
11987
|
-
handleDom.classList.add(`handle-${i}`);
|
|
11988
|
-
handleDom.setAttribute("data-index", String(i));
|
|
11989
|
-
handleDom.onmousedown = this._mousedown.bind(this);
|
|
11990
|
-
resizerSelection.append(handleDom);
|
|
11991
|
-
resizerHandleList.push(handleDom);
|
|
11971
|
+
cut() {
|
|
11972
|
+
if (!this.activeControl) {
|
|
11973
|
+
throw new Error("active control is null");
|
|
11992
11974
|
}
|
|
11993
|
-
this.
|
|
11994
|
-
const resizerSizeView = document.createElement("div");
|
|
11995
|
-
resizerSizeView.classList.add(`${EDITOR_PREFIX}-resizer-size-view`);
|
|
11996
|
-
const resizerSize = document.createElement("span");
|
|
11997
|
-
resizerSizeView.append(resizerSize);
|
|
11998
|
-
resizerSelection.append(resizerSizeView);
|
|
11999
|
-
const resizerImageContainer = document.createElement("div");
|
|
12000
|
-
resizerImageContainer.classList.add(`${EDITOR_PREFIX}-resizer-image`);
|
|
12001
|
-
resizerImageContainer.style.display = "none";
|
|
12002
|
-
const resizerImage = document.createElement("img");
|
|
12003
|
-
resizerImageContainer.append(resizerImage);
|
|
12004
|
-
this.container.append(resizerImageContainer);
|
|
12005
|
-
return {
|
|
12006
|
-
resizerSelection,
|
|
12007
|
-
resizerHandleList,
|
|
12008
|
-
resizerImageContainer,
|
|
12009
|
-
resizerImage,
|
|
12010
|
-
resizerSize
|
|
12011
|
-
};
|
|
11975
|
+
return this.activeControl.cut();
|
|
12012
11976
|
}
|
|
12013
|
-
|
|
12014
|
-
|
|
12015
|
-
|
|
12016
|
-
|
|
12017
|
-
const { scale } = this.options;
|
|
12018
|
-
this.mousedownX = evt.x;
|
|
12019
|
-
this.mousedownY = evt.y;
|
|
12020
|
-
const target = evt.target;
|
|
12021
|
-
this.curHandleIndex = Number(target.dataset.index);
|
|
12022
|
-
const cursor = window.getComputedStyle(target).cursor;
|
|
12023
|
-
document.body.style.cursor = cursor;
|
|
12024
|
-
this.canvas.style.cursor = cursor;
|
|
12025
|
-
this.resizerImage.src = this.curElementSrc;
|
|
12026
|
-
this.resizerImageContainer.style.display = "block";
|
|
12027
|
-
const { x: resizerLeft, y: resizerTop } = this._getElementPosition(this.curElement, this.curPosition);
|
|
12028
|
-
this.resizerImageContainer.style.left = `${resizerLeft}px`;
|
|
12029
|
-
this.resizerImageContainer.style.top = `${resizerTop}px`;
|
|
12030
|
-
this.resizerImage.style.width = `${this.curElement.width * scale}px`;
|
|
12031
|
-
this.resizerImage.style.height = `${this.curElement.height * scale}px`;
|
|
12032
|
-
const mousemoveFn = this._mousemove.bind(this);
|
|
12033
|
-
document.addEventListener("mousemove", mousemoveFn);
|
|
12034
|
-
document.addEventListener("mouseup", () => {
|
|
11977
|
+
getValueByConceptId(payload) {
|
|
11978
|
+
const { conceptId } = payload;
|
|
11979
|
+
const result = [];
|
|
11980
|
+
const getValue = (elementList, zone2) => {
|
|
12035
11981
|
var _a;
|
|
12036
|
-
|
|
12037
|
-
|
|
12038
|
-
|
|
12039
|
-
|
|
12040
|
-
|
|
12041
|
-
|
|
12042
|
-
|
|
11982
|
+
let i = 0;
|
|
11983
|
+
while (i < elementList.length) {
|
|
11984
|
+
const element = elementList[i];
|
|
11985
|
+
i++;
|
|
11986
|
+
if (element.type === ElementType.TABLE) {
|
|
11987
|
+
const trList = element.trList;
|
|
11988
|
+
for (let r = 0; r < trList.length; r++) {
|
|
11989
|
+
const tr = trList[r];
|
|
11990
|
+
for (let d = 0; d < tr.tdList.length; d++) {
|
|
11991
|
+
const td = tr.tdList[d];
|
|
11992
|
+
getValue(td.value, zone2);
|
|
11993
|
+
}
|
|
11994
|
+
}
|
|
11995
|
+
}
|
|
11996
|
+
if (((_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId) !== conceptId)
|
|
11997
|
+
continue;
|
|
11998
|
+
const { type, code, valueSets } = element.control;
|
|
11999
|
+
let j = i;
|
|
12000
|
+
let textControlValue = "";
|
|
12001
|
+
while (j < elementList.length) {
|
|
12002
|
+
const nextElement = elementList[j];
|
|
12003
|
+
if (nextElement.controlId !== element.controlId)
|
|
12004
|
+
break;
|
|
12005
|
+
if ((type === ControlType.TEXT || type === ControlType.DATE) && nextElement.controlComponent === ControlComponent.VALUE) {
|
|
12006
|
+
textControlValue += nextElement.value;
|
|
12007
|
+
}
|
|
12008
|
+
j++;
|
|
12009
|
+
}
|
|
12010
|
+
if (type === ControlType.TEXT || type === ControlType.DATE) {
|
|
12011
|
+
result.push(__spreadProps(__spreadValues({}, element.control), {
|
|
12012
|
+
zone: zone2,
|
|
12013
|
+
value: textControlValue || null,
|
|
12014
|
+
innerText: textControlValue || null
|
|
12015
|
+
}));
|
|
12016
|
+
} else if (type === ControlType.SELECT || type === ControlType.CHECKBOX || type === ControlType.RADIO) {
|
|
12017
|
+
const innerText = code == null ? void 0 : code.split(",").map((selectCode) => {
|
|
12018
|
+
var _a2;
|
|
12019
|
+
return (_a2 = valueSets == null ? void 0 : valueSets.find((valueSet) => valueSet.code === selectCode)) == null ? void 0 : _a2.value;
|
|
12020
|
+
}).filter(Boolean).join("");
|
|
12021
|
+
result.push(__spreadProps(__spreadValues({}, element.control), {
|
|
12022
|
+
zone: zone2,
|
|
12023
|
+
value: code || null,
|
|
12024
|
+
innerText: innerText || null
|
|
12025
|
+
}));
|
|
12026
|
+
}
|
|
12027
|
+
i = j;
|
|
12043
12028
|
}
|
|
12044
|
-
|
|
12045
|
-
|
|
12046
|
-
|
|
12047
|
-
|
|
12048
|
-
|
|
12049
|
-
|
|
12050
|
-
|
|
12051
|
-
|
|
12029
|
+
};
|
|
12030
|
+
const data2 = [
|
|
12031
|
+
{
|
|
12032
|
+
zone: EditorZone.HEADER,
|
|
12033
|
+
elementList: this.draw.getHeaderElementList()
|
|
12034
|
+
},
|
|
12035
|
+
{
|
|
12036
|
+
zone: EditorZone.MAIN,
|
|
12037
|
+
elementList: this.draw.getOriginalMainElementList()
|
|
12038
|
+
},
|
|
12039
|
+
{
|
|
12040
|
+
zone: EditorZone.FOOTER,
|
|
12041
|
+
elementList: this.draw.getFooterElementList()
|
|
12042
|
+
}
|
|
12043
|
+
];
|
|
12044
|
+
for (const { zone: zone2, elementList } of data2) {
|
|
12045
|
+
getValue(elementList, zone2);
|
|
12046
|
+
}
|
|
12047
|
+
return result;
|
|
12052
12048
|
}
|
|
12053
|
-
|
|
12054
|
-
|
|
12049
|
+
setValueByConceptId(payload) {
|
|
12050
|
+
const isReadonly = this.draw.isReadonly();
|
|
12051
|
+
if (isReadonly)
|
|
12055
12052
|
return;
|
|
12056
|
-
|
|
12057
|
-
|
|
12058
|
-
|
|
12059
|
-
|
|
12060
|
-
|
|
12061
|
-
|
|
12062
|
-
|
|
12063
|
-
|
|
12064
|
-
|
|
12065
|
-
|
|
12053
|
+
let isExistSet = false;
|
|
12054
|
+
const { conceptId, value } = payload;
|
|
12055
|
+
const setValue = (elementList) => {
|
|
12056
|
+
var _a;
|
|
12057
|
+
let i = 0;
|
|
12058
|
+
while (i < elementList.length) {
|
|
12059
|
+
const element = elementList[i];
|
|
12060
|
+
i++;
|
|
12061
|
+
if (element.type === ElementType.TABLE) {
|
|
12062
|
+
const trList = element.trList;
|
|
12063
|
+
for (let r = 0; r < trList.length; r++) {
|
|
12064
|
+
const tr = trList[r];
|
|
12065
|
+
for (let d = 0; d < tr.tdList.length; d++) {
|
|
12066
|
+
const td = tr.tdList[d];
|
|
12067
|
+
setValue(td.value);
|
|
12068
|
+
}
|
|
12069
|
+
}
|
|
12066
12070
|
}
|
|
12067
|
-
|
|
12068
|
-
|
|
12069
|
-
|
|
12070
|
-
|
|
12071
|
-
|
|
12072
|
-
{
|
|
12073
|
-
const
|
|
12074
|
-
|
|
12075
|
-
|
|
12076
|
-
|
|
12071
|
+
if (((_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId) !== conceptId)
|
|
12072
|
+
continue;
|
|
12073
|
+
isExistSet = true;
|
|
12074
|
+
const { type } = element.control;
|
|
12075
|
+
let currentEndIndex = i;
|
|
12076
|
+
while (currentEndIndex < elementList.length) {
|
|
12077
|
+
const nextElement = elementList[currentEndIndex];
|
|
12078
|
+
if (nextElement.controlId !== element.controlId)
|
|
12079
|
+
break;
|
|
12080
|
+
currentEndIndex++;
|
|
12077
12081
|
}
|
|
12078
|
-
|
|
12079
|
-
|
|
12080
|
-
|
|
12081
|
-
|
|
12082
|
-
|
|
12083
|
-
|
|
12084
|
-
|
|
12082
|
+
const fakeRange = {
|
|
12083
|
+
startIndex: i - 1,
|
|
12084
|
+
endIndex: currentEndIndex - 2
|
|
12085
|
+
};
|
|
12086
|
+
const controlContext = {
|
|
12087
|
+
range: fakeRange,
|
|
12088
|
+
elementList
|
|
12089
|
+
};
|
|
12090
|
+
const controlRule = {
|
|
12091
|
+
isIgnoreDisabledRule: true
|
|
12092
|
+
};
|
|
12093
|
+
if (type === ControlType.TEXT) {
|
|
12094
|
+
const formatValue = [{ value }];
|
|
12095
|
+
formatElementList(formatValue, {
|
|
12096
|
+
isHandleFirstElement: false,
|
|
12097
|
+
editorOptions: this.options
|
|
12098
|
+
});
|
|
12099
|
+
const text = new TextControl(element, this);
|
|
12100
|
+
this.activeControl = text;
|
|
12101
|
+
if (value) {
|
|
12102
|
+
text.setValue(formatValue, controlContext, controlRule);
|
|
12103
|
+
} else {
|
|
12104
|
+
text.clearValue(controlContext, controlRule);
|
|
12105
|
+
}
|
|
12106
|
+
} else if (type === ControlType.SELECT) {
|
|
12107
|
+
const select = new SelectControl(element, this);
|
|
12108
|
+
this.activeControl = select;
|
|
12109
|
+
if (value) {
|
|
12110
|
+
select.setSelect(value, controlContext, controlRule);
|
|
12111
|
+
} else {
|
|
12112
|
+
select.clearSelect(controlContext, controlRule);
|
|
12113
|
+
}
|
|
12114
|
+
} else if (type === ControlType.CHECKBOX) {
|
|
12115
|
+
const checkbox = new CheckboxControl(element, this);
|
|
12116
|
+
this.activeControl = checkbox;
|
|
12117
|
+
const codes = (value == null ? void 0 : value.split(",")) || [];
|
|
12118
|
+
checkbox.setSelect(codes, controlContext, controlRule);
|
|
12119
|
+
} else if (type === ControlType.RADIO) {
|
|
12120
|
+
const radio = new RadioControl(element, this);
|
|
12121
|
+
this.activeControl = radio;
|
|
12122
|
+
const codes = value ? [value] : [];
|
|
12123
|
+
radio.setSelect(codes, controlContext, controlRule);
|
|
12124
|
+
} else if (type === ControlType.DATE) {
|
|
12125
|
+
const date = new DateControl(element, this);
|
|
12126
|
+
this.activeControl = date;
|
|
12127
|
+
if (value) {
|
|
12128
|
+
date.setSelect(value, controlContext, controlRule);
|
|
12129
|
+
} else {
|
|
12130
|
+
date.clearSelect(controlContext, controlRule);
|
|
12131
|
+
}
|
|
12085
12132
|
}
|
|
12086
|
-
|
|
12087
|
-
|
|
12088
|
-
|
|
12089
|
-
|
|
12090
|
-
|
|
12091
|
-
|
|
12092
|
-
|
|
12093
|
-
case 6:
|
|
12094
|
-
{
|
|
12095
|
-
const offsetX = this.mousedownX - evt.x;
|
|
12096
|
-
const offsetY = evt.y - this.mousedownY;
|
|
12097
|
-
dx = Math.cbrt(offsetX ** 3 + offsetY ** 3);
|
|
12098
|
-
dy = this.curElement.height * dx / this.curElement.width;
|
|
12133
|
+
this.activeControl = null;
|
|
12134
|
+
let newEndIndex = i;
|
|
12135
|
+
while (newEndIndex < elementList.length) {
|
|
12136
|
+
const nextElement = elementList[newEndIndex];
|
|
12137
|
+
if (nextElement.controlId !== element.controlId)
|
|
12138
|
+
break;
|
|
12139
|
+
newEndIndex++;
|
|
12099
12140
|
}
|
|
12100
|
-
|
|
12101
|
-
|
|
12102
|
-
|
|
12103
|
-
|
|
12141
|
+
i = newEndIndex;
|
|
12142
|
+
}
|
|
12143
|
+
};
|
|
12144
|
+
this.destroyControl();
|
|
12145
|
+
const data2 = [
|
|
12146
|
+
this.draw.getHeaderElementList(),
|
|
12147
|
+
this.draw.getOriginalMainElementList(),
|
|
12148
|
+
this.draw.getFooterElementList()
|
|
12149
|
+
];
|
|
12150
|
+
for (const elementList of data2) {
|
|
12151
|
+
setValue(elementList);
|
|
12152
|
+
}
|
|
12153
|
+
if (isExistSet) {
|
|
12154
|
+
this.draw.render({
|
|
12155
|
+
isSetCursor: false
|
|
12156
|
+
});
|
|
12104
12157
|
}
|
|
12105
|
-
const dw = this.curElement.width + dx / scale;
|
|
12106
|
-
const dh = this.curElement.height + dy / scale;
|
|
12107
|
-
if (dw <= 0 || dh <= 0)
|
|
12108
|
-
return;
|
|
12109
|
-
this.width = dw;
|
|
12110
|
-
this.height = dh;
|
|
12111
|
-
const elementWidth = dw * scale;
|
|
12112
|
-
const elementHeight = dh * scale;
|
|
12113
|
-
this.resizerImage.style.width = `${elementWidth}px`;
|
|
12114
|
-
this.resizerImage.style.height = `${elementHeight}px`;
|
|
12115
|
-
this._updateResizerRect(elementWidth, elementHeight);
|
|
12116
|
-
this._updateResizerSizeView(elementWidth, elementHeight);
|
|
12117
|
-
evt.preventDefault();
|
|
12118
12158
|
}
|
|
12119
|
-
|
|
12120
|
-
const
|
|
12121
|
-
|
|
12122
|
-
|
|
12123
|
-
|
|
12124
|
-
|
|
12125
|
-
this._clearPreviewer();
|
|
12126
|
-
};
|
|
12127
|
-
previewerContainer.append(closeBtn);
|
|
12128
|
-
const imgContainer = document.createElement("div");
|
|
12129
|
-
imgContainer.classList.add(`${EDITOR_PREFIX}-image-container`);
|
|
12130
|
-
const img = document.createElement("img");
|
|
12131
|
-
img.src = this.curElementSrc;
|
|
12132
|
-
img.draggable = false;
|
|
12133
|
-
imgContainer.append(img);
|
|
12134
|
-
this.previewerImage = img;
|
|
12135
|
-
previewerContainer.append(imgContainer);
|
|
12136
|
-
let x = 0;
|
|
12137
|
-
let y = 0;
|
|
12138
|
-
let scaleSize = 1;
|
|
12139
|
-
let rotateSize = 0;
|
|
12140
|
-
const menuContainer = document.createElement("div");
|
|
12141
|
-
menuContainer.classList.add(`${EDITOR_PREFIX}-image-menu`);
|
|
12142
|
-
const zoomIn = document.createElement("i");
|
|
12143
|
-
zoomIn.classList.add("zoom-in");
|
|
12144
|
-
zoomIn.onclick = () => {
|
|
12145
|
-
scaleSize += 0.1;
|
|
12146
|
-
this._setPreviewerTransform(scaleSize, rotateSize, x, y);
|
|
12147
|
-
};
|
|
12148
|
-
menuContainer.append(zoomIn);
|
|
12149
|
-
const zoomOut = document.createElement("i");
|
|
12150
|
-
zoomOut.onclick = () => {
|
|
12151
|
-
if (scaleSize - 0.1 <= 0.1)
|
|
12152
|
-
return;
|
|
12153
|
-
scaleSize -= 0.1;
|
|
12154
|
-
this._setPreviewerTransform(scaleSize, rotateSize, x, y);
|
|
12155
|
-
};
|
|
12156
|
-
zoomOut.classList.add("zoom-out");
|
|
12157
|
-
menuContainer.append(zoomOut);
|
|
12158
|
-
const rotate = document.createElement("i");
|
|
12159
|
-
rotate.classList.add("rotate");
|
|
12160
|
-
rotate.onclick = () => {
|
|
12161
|
-
rotateSize += 1;
|
|
12162
|
-
this._setPreviewerTransform(scaleSize, rotateSize, x, y);
|
|
12163
|
-
};
|
|
12164
|
-
menuContainer.append(rotate);
|
|
12165
|
-
const originalSize = document.createElement("i");
|
|
12166
|
-
originalSize.classList.add("original-size");
|
|
12167
|
-
originalSize.onclick = () => {
|
|
12168
|
-
x = 0;
|
|
12169
|
-
y = 0;
|
|
12170
|
-
scaleSize = 1;
|
|
12171
|
-
rotateSize = 0;
|
|
12172
|
-
this._setPreviewerTransform(scaleSize, rotateSize, x, y);
|
|
12173
|
-
};
|
|
12174
|
-
menuContainer.append(originalSize);
|
|
12175
|
-
const imageDownload = document.createElement("i");
|
|
12176
|
-
imageDownload.classList.add("image-download");
|
|
12177
|
-
imageDownload.onclick = () => {
|
|
12159
|
+
setExtensionByConceptId(payload) {
|
|
12160
|
+
const isReadonly = this.draw.isReadonly();
|
|
12161
|
+
if (isReadonly)
|
|
12162
|
+
return;
|
|
12163
|
+
const { conceptId, extension } = payload;
|
|
12164
|
+
const setExtension = (elementList) => {
|
|
12178
12165
|
var _a;
|
|
12179
|
-
|
|
12180
|
-
|
|
12181
|
-
|
|
12182
|
-
|
|
12183
|
-
|
|
12184
|
-
|
|
12185
|
-
|
|
12186
|
-
|
|
12187
|
-
|
|
12188
|
-
|
|
12189
|
-
|
|
12190
|
-
|
|
12191
|
-
|
|
12192
|
-
|
|
12193
|
-
|
|
12194
|
-
|
|
12195
|
-
|
|
12196
|
-
|
|
12197
|
-
|
|
12198
|
-
|
|
12199
|
-
|
|
12200
|
-
|
|
12201
|
-
|
|
12202
|
-
|
|
12203
|
-
|
|
12204
|
-
previewerContainer.onmouseup = () => {
|
|
12205
|
-
isAllowDrag = false;
|
|
12206
|
-
previewerContainer.style.cursor = "auto";
|
|
12207
|
-
};
|
|
12208
|
-
previewerContainer.onwheel = (evt) => {
|
|
12209
|
-
evt.preventDefault();
|
|
12210
|
-
if (evt.deltaY < 0) {
|
|
12211
|
-
scaleSize += 0.1;
|
|
12212
|
-
} else {
|
|
12213
|
-
if (scaleSize - 0.1 <= 0.1)
|
|
12214
|
-
return;
|
|
12215
|
-
scaleSize -= 0.1;
|
|
12166
|
+
let i = 0;
|
|
12167
|
+
while (i < elementList.length) {
|
|
12168
|
+
const element = elementList[i];
|
|
12169
|
+
i++;
|
|
12170
|
+
if (element.type === ElementType.TABLE) {
|
|
12171
|
+
const trList = element.trList;
|
|
12172
|
+
for (let r = 0; r < trList.length; r++) {
|
|
12173
|
+
const tr = trList[r];
|
|
12174
|
+
for (let d = 0; d < tr.tdList.length; d++) {
|
|
12175
|
+
const td = tr.tdList[d];
|
|
12176
|
+
setExtension(td.value);
|
|
12177
|
+
}
|
|
12178
|
+
}
|
|
12179
|
+
}
|
|
12180
|
+
if (((_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId) !== conceptId)
|
|
12181
|
+
continue;
|
|
12182
|
+
element.control.extension = extension;
|
|
12183
|
+
let newEndIndex = i;
|
|
12184
|
+
while (newEndIndex < elementList.length) {
|
|
12185
|
+
const nextElement = elementList[newEndIndex];
|
|
12186
|
+
if (nextElement.controlId !== element.controlId)
|
|
12187
|
+
break;
|
|
12188
|
+
newEndIndex++;
|
|
12189
|
+
}
|
|
12190
|
+
i = newEndIndex;
|
|
12216
12191
|
}
|
|
12217
|
-
this._setPreviewerTransform(scaleSize, rotateSize, x, y);
|
|
12218
12192
|
};
|
|
12193
|
+
const data2 = [
|
|
12194
|
+
this.draw.getHeaderElementList(),
|
|
12195
|
+
this.draw.getOriginalMainElementList(),
|
|
12196
|
+
this.draw.getFooterElementList()
|
|
12197
|
+
];
|
|
12198
|
+
for (const elementList of data2) {
|
|
12199
|
+
setExtension(elementList);
|
|
12200
|
+
}
|
|
12219
12201
|
}
|
|
12220
|
-
|
|
12221
|
-
if (!this.previewerImage)
|
|
12222
|
-
return;
|
|
12223
|
-
this.previewerImage.style.left = `${x}px`;
|
|
12224
|
-
this.previewerImage.style.top = `${y}px`;
|
|
12225
|
-
this.previewerImage.style.transform = `scale(${scale}) rotate(${rotate * 90}deg)`;
|
|
12226
|
-
}
|
|
12227
|
-
_clearPreviewer() {
|
|
12202
|
+
setPropertiesByConceptId(payload) {
|
|
12228
12203
|
var _a;
|
|
12229
|
-
|
|
12230
|
-
|
|
12231
|
-
|
|
12232
|
-
|
|
12233
|
-
|
|
12234
|
-
const
|
|
12235
|
-
|
|
12236
|
-
|
|
12237
|
-
|
|
12238
|
-
|
|
12239
|
-
|
|
12240
|
-
|
|
12241
|
-
|
|
12204
|
+
const isReadonly = this.draw.isReadonly();
|
|
12205
|
+
if (isReadonly)
|
|
12206
|
+
return;
|
|
12207
|
+
const { conceptId, properties } = payload;
|
|
12208
|
+
let isExistUpdate = false;
|
|
12209
|
+
const pageComponentData = {
|
|
12210
|
+
header: this.draw.getHeaderElementList(),
|
|
12211
|
+
main: this.draw.getOriginalMainElementList(),
|
|
12212
|
+
footer: this.draw.getFooterElementList()
|
|
12213
|
+
};
|
|
12214
|
+
for (const key in pageComponentData) {
|
|
12215
|
+
const elementList = pageComponentData[key];
|
|
12216
|
+
let i = 0;
|
|
12217
|
+
while (i < elementList.length) {
|
|
12218
|
+
const element = elementList[i];
|
|
12219
|
+
i++;
|
|
12220
|
+
if (((_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId) !== conceptId)
|
|
12221
|
+
continue;
|
|
12222
|
+
isExistUpdate = true;
|
|
12223
|
+
element.control = __spreadProps(__spreadValues(__spreadValues({}, element.control), properties), {
|
|
12224
|
+
value: element.control.value
|
|
12225
|
+
});
|
|
12226
|
+
let newEndIndex = i;
|
|
12227
|
+
while (newEndIndex < elementList.length) {
|
|
12228
|
+
const nextElement = elementList[newEndIndex];
|
|
12229
|
+
if (nextElement.controlId !== element.controlId)
|
|
12230
|
+
break;
|
|
12231
|
+
newEndIndex++;
|
|
12232
|
+
}
|
|
12233
|
+
i = newEndIndex;
|
|
12234
|
+
}
|
|
12242
12235
|
}
|
|
12236
|
+
if (!isExistUpdate)
|
|
12237
|
+
return;
|
|
12238
|
+
for (const key in pageComponentData) {
|
|
12239
|
+
const pageComponentKey = key;
|
|
12240
|
+
const elementList = zipElementList(pageComponentData[pageComponentKey]);
|
|
12241
|
+
pageComponentData[pageComponentKey] = elementList;
|
|
12242
|
+
formatElementList(elementList, {
|
|
12243
|
+
editorOptions: this.options
|
|
12244
|
+
});
|
|
12245
|
+
}
|
|
12246
|
+
this.draw.setEditorData(pageComponentData);
|
|
12247
|
+
this.draw.render({
|
|
12248
|
+
isSetCursor: false
|
|
12249
|
+
});
|
|
12243
12250
|
}
|
|
12244
|
-
|
|
12245
|
-
|
|
12246
|
-
|
|
12247
|
-
|
|
12248
|
-
|
|
12249
|
-
|
|
12250
|
-
|
|
12251
|
-
|
|
12252
|
-
|
|
12253
|
-
|
|
12254
|
-
|
|
12255
|
-
|
|
12251
|
+
getList() {
|
|
12252
|
+
const controlElementList = [];
|
|
12253
|
+
function getControlElementList(elementList) {
|
|
12254
|
+
for (let e = 0; e < elementList.length; e++) {
|
|
12255
|
+
const element = elementList[e];
|
|
12256
|
+
if (element.type === ElementType.TABLE) {
|
|
12257
|
+
const trList = element.trList;
|
|
12258
|
+
for (let r = 0; r < trList.length; r++) {
|
|
12259
|
+
const tr = trList[r];
|
|
12260
|
+
for (let d = 0; d < tr.tdList.length; d++) {
|
|
12261
|
+
const td = tr.tdList[d];
|
|
12262
|
+
const tdElement = td.value;
|
|
12263
|
+
getControlElementList(tdElement);
|
|
12264
|
+
}
|
|
12265
|
+
}
|
|
12266
|
+
}
|
|
12267
|
+
if (element.controlId) {
|
|
12268
|
+
controlElementList.push(element);
|
|
12269
|
+
}
|
|
12270
|
+
}
|
|
12271
|
+
}
|
|
12272
|
+
const data2 = [
|
|
12273
|
+
this.draw.getHeader().getElementList(),
|
|
12274
|
+
this.draw.getOriginalMainElementList(),
|
|
12275
|
+
this.draw.getFooter().getElementList()
|
|
12276
|
+
];
|
|
12277
|
+
for (const elementList of data2) {
|
|
12278
|
+
getControlElementList(elementList);
|
|
12279
|
+
}
|
|
12280
|
+
return zipElementList(controlElementList);
|
|
12256
12281
|
}
|
|
12257
|
-
|
|
12258
|
-
|
|
12259
|
-
const elementWidth = element.width * scale;
|
|
12260
|
-
const elementHeight = element.height * scale;
|
|
12261
|
-
this._updateResizerSizeView(elementWidth, elementHeight);
|
|
12262
|
-
const { x: resizerLeft, y: resizerTop } = this._getElementPosition(element, position);
|
|
12263
|
-
this.resizerSelection.style.left = `${resizerLeft}px`;
|
|
12264
|
-
this.resizerSelection.style.top = `${resizerTop}px`;
|
|
12265
|
-
this._updateResizerRect(elementWidth, elementHeight);
|
|
12266
|
-
this.resizerSelection.style.display = "block";
|
|
12267
|
-
this.curElement = element;
|
|
12268
|
-
this.curPosition = position;
|
|
12269
|
-
this.width = elementWidth;
|
|
12270
|
-
this.height = elementHeight;
|
|
12282
|
+
recordBorderInfo(x, y, width, height) {
|
|
12283
|
+
this.controlBorder.recordBorderInfo(x, y, width, height);
|
|
12271
12284
|
}
|
|
12272
|
-
|
|
12273
|
-
this.
|
|
12274
|
-
document.removeEventListener("keydown", this._keydown);
|
|
12285
|
+
drawBorder(ctx) {
|
|
12286
|
+
this.controlBorder.render(ctx);
|
|
12275
12287
|
}
|
|
12276
|
-
|
|
12277
|
-
|
|
12278
|
-
|
|
12279
|
-
|
|
12280
|
-
|
|
12281
|
-
|
|
12282
|
-
|
|
12283
|
-
|
|
12284
|
-
|
|
12285
|
-
|
|
12286
|
-
|
|
12287
|
-
|
|
12288
|
-
|
|
12289
|
-
|
|
12290
|
-
|
|
12291
|
-
|
|
12292
|
-
|
|
12293
|
-
|
|
12294
|
-
|
|
12295
|
-
|
|
12296
|
-
|
|
12297
|
-
|
|
12298
|
-
|
|
12299
|
-
|
|
12300
|
-
|
|
12301
|
-
|
|
12288
|
+
getPreControlContext() {
|
|
12289
|
+
if (!this.activeControl)
|
|
12290
|
+
return null;
|
|
12291
|
+
const position = this.draw.getPosition();
|
|
12292
|
+
const positionContext = position.getPositionContext();
|
|
12293
|
+
if (!positionContext)
|
|
12294
|
+
return null;
|
|
12295
|
+
const controlElement = this.activeControl.getElement();
|
|
12296
|
+
function getPreContext(elementList2, start) {
|
|
12297
|
+
for (let e = start; e > 0; e--) {
|
|
12298
|
+
const element = elementList2[e];
|
|
12299
|
+
if (element.type === ElementType.TABLE) {
|
|
12300
|
+
const trList = element.trList || [];
|
|
12301
|
+
for (let r = trList.length - 1; r >= 0; r--) {
|
|
12302
|
+
const tr = trList[r];
|
|
12303
|
+
const tdList = tr.tdList;
|
|
12304
|
+
for (let d = tdList.length - 1; d >= 0; d--) {
|
|
12305
|
+
const td = tdList[d];
|
|
12306
|
+
const context2 = getPreContext(td.value, td.value.length - 1);
|
|
12307
|
+
if (context2) {
|
|
12308
|
+
return {
|
|
12309
|
+
positionContext: {
|
|
12310
|
+
isTable: true,
|
|
12311
|
+
index: e,
|
|
12312
|
+
trIndex: r,
|
|
12313
|
+
tdIndex: d,
|
|
12314
|
+
tdId: td.id,
|
|
12315
|
+
trId: tr.id,
|
|
12316
|
+
tableId: element.id
|
|
12317
|
+
},
|
|
12318
|
+
nextIndex: context2.nextIndex
|
|
12319
|
+
};
|
|
12320
|
+
}
|
|
12321
|
+
}
|
|
12322
|
+
}
|
|
12323
|
+
}
|
|
12324
|
+
if (!element.controlId || element.controlId === controlElement.controlId) {
|
|
12325
|
+
continue;
|
|
12326
|
+
}
|
|
12327
|
+
let nextIndex = e;
|
|
12328
|
+
while (nextIndex > 0) {
|
|
12329
|
+
const nextElement = elementList2[nextIndex];
|
|
12330
|
+
if (nextElement.controlComponent === ControlComponent.VALUE || nextElement.controlComponent === ControlComponent.PREFIX) {
|
|
12331
|
+
break;
|
|
12332
|
+
}
|
|
12333
|
+
nextIndex--;
|
|
12334
|
+
}
|
|
12335
|
+
return {
|
|
12336
|
+
positionContext: {
|
|
12337
|
+
isTable: false
|
|
12338
|
+
},
|
|
12339
|
+
nextIndex
|
|
12340
|
+
};
|
|
12341
|
+
}
|
|
12342
|
+
return null;
|
|
12302
12343
|
}
|
|
12303
|
-
|
|
12304
|
-
|
|
12305
|
-
|
|
12306
|
-
|
|
12307
|
-
|
|
12308
|
-
|
|
12309
|
-
|
|
12310
|
-
|
|
12311
|
-
|
|
12312
|
-
|
|
12313
|
-
|
|
12314
|
-
|
|
12315
|
-
|
|
12316
|
-
|
|
12317
|
-
|
|
12318
|
-
|
|
12319
|
-
|
|
12320
|
-
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
|
|
12327
|
-
|
|
12328
|
-
|
|
12329
|
-
|
|
12330
|
-
|
|
12344
|
+
const { startIndex } = this.range.getRange();
|
|
12345
|
+
const elementList = this.getElementList();
|
|
12346
|
+
const context = getPreContext(elementList, startIndex);
|
|
12347
|
+
if (context) {
|
|
12348
|
+
return {
|
|
12349
|
+
positionContext: positionContext.isTable ? positionContext : context.positionContext,
|
|
12350
|
+
nextIndex: context.nextIndex
|
|
12351
|
+
};
|
|
12352
|
+
}
|
|
12353
|
+
if (controlElement.tableId) {
|
|
12354
|
+
const originalElementList = this.draw.getOriginalElementList();
|
|
12355
|
+
const { index: index2, trIndex, tdIndex } = positionContext;
|
|
12356
|
+
const trList = originalElementList[index2].trList;
|
|
12357
|
+
for (let r = trIndex; r >= 0; r--) {
|
|
12358
|
+
const tr = trList[r];
|
|
12359
|
+
const tdList = tr.tdList;
|
|
12360
|
+
for (let d = tdList.length - 1; d >= 0; d--) {
|
|
12361
|
+
if (trIndex === r && d >= tdIndex)
|
|
12362
|
+
continue;
|
|
12363
|
+
const td = tdList[d];
|
|
12364
|
+
const context3 = getPreContext(td.value, td.value.length - 1);
|
|
12365
|
+
if (context3) {
|
|
12366
|
+
return {
|
|
12367
|
+
positionContext: {
|
|
12368
|
+
isTable: true,
|
|
12369
|
+
index: positionContext.index,
|
|
12370
|
+
trIndex: r,
|
|
12371
|
+
tdIndex: d,
|
|
12372
|
+
tdId: td.id,
|
|
12373
|
+
trId: tr.id,
|
|
12374
|
+
tableId: controlElement.tableId
|
|
12375
|
+
},
|
|
12376
|
+
nextIndex: context3.nextIndex
|
|
12377
|
+
};
|
|
12378
|
+
}
|
|
12379
|
+
}
|
|
12380
|
+
}
|
|
12381
|
+
const context2 = getPreContext(originalElementList, index2 - 1);
|
|
12382
|
+
if (context2) {
|
|
12383
|
+
return {
|
|
12384
|
+
positionContext: {
|
|
12385
|
+
isTable: false
|
|
12386
|
+
},
|
|
12387
|
+
nextIndex: context2.nextIndex
|
|
12388
|
+
};
|
|
12389
|
+
}
|
|
12390
|
+
}
|
|
12391
|
+
return null;
|
|
12392
|
+
}
|
|
12393
|
+
getNextControlContext() {
|
|
12394
|
+
if (!this.activeControl)
|
|
12395
|
+
return null;
|
|
12396
|
+
const position = this.draw.getPosition();
|
|
12397
|
+
const positionContext = position.getPositionContext();
|
|
12398
|
+
if (!positionContext)
|
|
12399
|
+
return null;
|
|
12400
|
+
const controlElement = this.activeControl.getElement();
|
|
12401
|
+
function getNextContext(elementList2, start) {
|
|
12402
|
+
for (let e = start; e < elementList2.length; e++) {
|
|
12403
|
+
const element = elementList2[e];
|
|
12404
|
+
if (element.type === ElementType.TABLE) {
|
|
12405
|
+
const trList = element.trList || [];
|
|
12406
|
+
for (let r = 0; r < trList.length; r++) {
|
|
12407
|
+
const tr = trList[r];
|
|
12408
|
+
const tdList = tr.tdList;
|
|
12409
|
+
for (let d = 0; d < tdList.length; d++) {
|
|
12410
|
+
const td = tdList[d];
|
|
12411
|
+
const context2 = getNextContext(td.value, 0);
|
|
12412
|
+
if (context2) {
|
|
12413
|
+
return {
|
|
12414
|
+
positionContext: {
|
|
12415
|
+
isTable: true,
|
|
12416
|
+
index: e,
|
|
12417
|
+
trIndex: r,
|
|
12418
|
+
tdIndex: d,
|
|
12419
|
+
tdId: td.id,
|
|
12420
|
+
trId: tr.id,
|
|
12421
|
+
tableId: element.id
|
|
12422
|
+
},
|
|
12423
|
+
nextIndex: context2.nextIndex
|
|
12424
|
+
};
|
|
12425
|
+
}
|
|
12426
|
+
}
|
|
12427
|
+
}
|
|
12428
|
+
}
|
|
12429
|
+
if (!element.controlId || element.controlId === controlElement.controlId) {
|
|
12430
|
+
continue;
|
|
12431
|
+
}
|
|
12432
|
+
return {
|
|
12433
|
+
positionContext: {
|
|
12434
|
+
isTable: false
|
|
12435
|
+
},
|
|
12436
|
+
nextIndex: e
|
|
12437
|
+
};
|
|
12438
|
+
}
|
|
12439
|
+
return null;
|
|
12440
|
+
}
|
|
12441
|
+
const { endIndex } = this.range.getRange();
|
|
12442
|
+
const elementList = this.getElementList();
|
|
12443
|
+
const context = getNextContext(elementList, endIndex);
|
|
12444
|
+
if (context) {
|
|
12445
|
+
return {
|
|
12446
|
+
positionContext: positionContext.isTable ? positionContext : context.positionContext,
|
|
12447
|
+
nextIndex: context.nextIndex
|
|
12448
|
+
};
|
|
12449
|
+
}
|
|
12450
|
+
if (controlElement.tableId) {
|
|
12451
|
+
const originalElementList = this.draw.getOriginalElementList();
|
|
12452
|
+
const { index: index2, trIndex, tdIndex } = positionContext;
|
|
12453
|
+
const trList = originalElementList[index2].trList;
|
|
12454
|
+
for (let r = trIndex; r < trList.length; r++) {
|
|
12455
|
+
const tr = trList[r];
|
|
12456
|
+
const tdList = tr.tdList;
|
|
12457
|
+
for (let d = 0; d < tdList.length; d++) {
|
|
12458
|
+
if (trIndex === r && d <= tdIndex)
|
|
12459
|
+
continue;
|
|
12460
|
+
const td = tdList[d];
|
|
12461
|
+
const context3 = getNextContext(td.value, 0);
|
|
12462
|
+
if (context3) {
|
|
12463
|
+
return {
|
|
12464
|
+
positionContext: {
|
|
12465
|
+
isTable: true,
|
|
12466
|
+
index: positionContext.index,
|
|
12467
|
+
trIndex: r,
|
|
12468
|
+
tdIndex: d,
|
|
12469
|
+
tdId: td.id,
|
|
12470
|
+
trId: tr.id,
|
|
12471
|
+
tableId: controlElement.tableId
|
|
12472
|
+
},
|
|
12473
|
+
nextIndex: context3.nextIndex
|
|
12474
|
+
};
|
|
12475
|
+
}
|
|
12476
|
+
}
|
|
12477
|
+
}
|
|
12478
|
+
const context2 = getNextContext(originalElementList, index2 + 1);
|
|
12479
|
+
if (context2) {
|
|
12480
|
+
return {
|
|
12481
|
+
positionContext: {
|
|
12482
|
+
isTable: false
|
|
12483
|
+
},
|
|
12484
|
+
nextIndex: context2.nextIndex
|
|
12485
|
+
};
|
|
12486
|
+
}
|
|
12487
|
+
}
|
|
12488
|
+
return null;
|
|
12489
|
+
}
|
|
12490
|
+
initNextControl(option = {}) {
|
|
12491
|
+
const { direction = MoveDirection.DOWN } = option;
|
|
12492
|
+
let context = null;
|
|
12493
|
+
if (direction === MoveDirection.UP) {
|
|
12494
|
+
context = this.getPreControlContext();
|
|
12495
|
+
} else {
|
|
12496
|
+
context = this.getNextControlContext();
|
|
12497
|
+
}
|
|
12498
|
+
if (!context)
|
|
12499
|
+
return;
|
|
12500
|
+
const { nextIndex, positionContext } = context;
|
|
12501
|
+
const position = this.draw.getPosition();
|
|
12502
|
+
position.setPositionContext(positionContext);
|
|
12503
|
+
this.draw.getRange().replaceRange({
|
|
12504
|
+
startIndex: nextIndex,
|
|
12505
|
+
endIndex: nextIndex
|
|
12506
|
+
});
|
|
12507
|
+
this.draw.render({
|
|
12508
|
+
curIndex: nextIndex,
|
|
12509
|
+
isCompute: false,
|
|
12510
|
+
isSetCursor: true,
|
|
12511
|
+
isSubmitHistory: false
|
|
12512
|
+
});
|
|
12513
|
+
const positionList = position.getPositionList();
|
|
12514
|
+
this.draw.getCursor().moveCursorToVisible({
|
|
12515
|
+
cursorPosition: positionList[nextIndex],
|
|
12516
|
+
direction
|
|
12517
|
+
});
|
|
12518
|
+
}
|
|
12519
|
+
}
|
|
12520
|
+
class CheckboxParticle {
|
|
12521
|
+
constructor(draw) {
|
|
12522
|
+
__publicField(this, "draw");
|
|
12523
|
+
__publicField(this, "options");
|
|
12524
|
+
this.draw = draw;
|
|
12525
|
+
this.options = draw.getOptions();
|
|
12526
|
+
}
|
|
12527
|
+
setSelect(element) {
|
|
12528
|
+
const { checkbox } = element;
|
|
12529
|
+
if (checkbox) {
|
|
12530
|
+
checkbox.value = !checkbox.value;
|
|
12531
|
+
} else {
|
|
12532
|
+
element.checkbox = {
|
|
12533
|
+
value: true
|
|
12534
|
+
};
|
|
12535
|
+
}
|
|
12536
|
+
this.draw.render({
|
|
12537
|
+
isCompute: false,
|
|
12538
|
+
isSetCursor: false
|
|
12539
|
+
});
|
|
12540
|
+
}
|
|
12541
|
+
render(ctx, element, x, y) {
|
|
12542
|
+
const { checkbox: { gap, lineWidth, fillStyle, strokeStyle }, scale } = this.options;
|
|
12543
|
+
const { metrics, checkbox } = element;
|
|
12544
|
+
const left2 = Math.round(x + gap * scale);
|
|
12545
|
+
const top = Math.round(y - metrics.height + lineWidth);
|
|
12546
|
+
const width = metrics.width - gap * 2 * scale;
|
|
12547
|
+
const height = metrics.height;
|
|
12548
|
+
ctx.save();
|
|
12549
|
+
ctx.beginPath();
|
|
12550
|
+
ctx.translate(0.5, 0.5);
|
|
12551
|
+
if (checkbox == null ? void 0 : checkbox.value) {
|
|
12552
|
+
ctx.lineWidth = lineWidth;
|
|
12553
|
+
ctx.strokeStyle = fillStyle;
|
|
12554
|
+
ctx.rect(left2, top, width, height);
|
|
12555
|
+
ctx.stroke();
|
|
12556
|
+
ctx.beginPath();
|
|
12557
|
+
ctx.fillStyle = fillStyle;
|
|
12558
|
+
ctx.fillRect(left2, top, width, height);
|
|
12559
|
+
ctx.beginPath();
|
|
12560
|
+
ctx.strokeStyle = strokeStyle;
|
|
12561
|
+
ctx.lineWidth = lineWidth * 2 * scale;
|
|
12562
|
+
ctx.moveTo(left2 + 2 * scale, top + height / 2);
|
|
12563
|
+
ctx.lineTo(left2 + width / 2, top + height - 3 * scale);
|
|
12564
|
+
ctx.lineTo(left2 + width - 2 * scale, top + 3 * scale);
|
|
12565
|
+
ctx.stroke();
|
|
12566
|
+
} else {
|
|
12567
|
+
ctx.lineWidth = lineWidth;
|
|
12568
|
+
ctx.rect(left2, top, width, height);
|
|
12569
|
+
ctx.stroke();
|
|
12570
|
+
}
|
|
12571
|
+
ctx.closePath();
|
|
12572
|
+
ctx.restore();
|
|
12331
12573
|
}
|
|
12332
|
-
}
|
|
12333
|
-
|
|
12334
|
-
|
|
12335
|
-
|
|
12336
|
-
"return": "\u8FD4\u56DE\u65E5\u671F",
|
|
12337
|
-
timeSelect: "\u65F6\u95F4\u9009\u62E9",
|
|
12338
|
-
weeks: {
|
|
12339
|
-
sun: "\u65E5",
|
|
12340
|
-
mon: "\u4E00",
|
|
12341
|
-
tue: "\u4E8C",
|
|
12342
|
-
wed: "\u4E09",
|
|
12343
|
-
thu: "\u56DB",
|
|
12344
|
-
fri: "\u4E94",
|
|
12345
|
-
sat: "\u516D"
|
|
12346
|
-
},
|
|
12347
|
-
year: "\u5E74",
|
|
12348
|
-
month: "\u6708",
|
|
12349
|
-
hour: "\u65F6",
|
|
12350
|
-
minute: "\u5206",
|
|
12351
|
-
second: "\u79D2"
|
|
12352
|
-
};
|
|
12353
|
-
const frame$1 = {
|
|
12354
|
-
header: "\u9875\u7709",
|
|
12355
|
-
footer: "\u9875\u811A"
|
|
12356
|
-
};
|
|
12357
|
-
const pageBreak$1 = {
|
|
12358
|
-
displayName: "\u5206\u9875\u7B26"
|
|
12359
|
-
};
|
|
12360
|
-
const zone$1 = {
|
|
12361
|
-
headerTip: "\u53CC\u51FB\u7F16\u8F91\u9875\u7709",
|
|
12362
|
-
footerTip: "\u53CC\u51FB\u7F16\u8F91\u9875\u811A"
|
|
12363
|
-
};
|
|
12364
|
-
var zhCN = {
|
|
12365
|
-
contextmenu: contextmenu$1,
|
|
12366
|
-
datePicker: datePicker$1,
|
|
12367
|
-
frame: frame$1,
|
|
12368
|
-
pageBreak: pageBreak$1,
|
|
12369
|
-
zone: zone$1
|
|
12370
|
-
};
|
|
12371
|
-
class DatePicker {
|
|
12372
|
-
constructor(options = {}) {
|
|
12574
|
+
}
|
|
12575
|
+
class RadioParticle {
|
|
12576
|
+
constructor(draw) {
|
|
12577
|
+
__publicField(this, "draw");
|
|
12373
12578
|
__publicField(this, "options");
|
|
12374
|
-
|
|
12375
|
-
|
|
12376
|
-
__publicField(this, "renderOptions");
|
|
12377
|
-
__publicField(this, "isDatePicker");
|
|
12378
|
-
__publicField(this, "pickDate");
|
|
12379
|
-
__publicField(this, "lang");
|
|
12380
|
-
this.options = __spreadValues({
|
|
12381
|
-
mountDom: document.body
|
|
12382
|
-
}, options);
|
|
12383
|
-
this.lang = datePicker$1;
|
|
12384
|
-
this.now = new Date();
|
|
12385
|
-
this.dom = this._createDom();
|
|
12386
|
-
this.renderOptions = null;
|
|
12387
|
-
this.isDatePicker = true;
|
|
12388
|
-
this.pickDate = null;
|
|
12389
|
-
this._bindEvent();
|
|
12579
|
+
this.draw = draw;
|
|
12580
|
+
this.options = draw.getOptions();
|
|
12390
12581
|
}
|
|
12391
|
-
|
|
12392
|
-
const
|
|
12393
|
-
|
|
12394
|
-
|
|
12395
|
-
|
|
12396
|
-
|
|
12397
|
-
|
|
12398
|
-
|
|
12399
|
-
|
|
12400
|
-
|
|
12401
|
-
|
|
12402
|
-
|
|
12403
|
-
preMonthTitle.innerText = `<`;
|
|
12404
|
-
const nowTitle = document.createElement("span");
|
|
12405
|
-
nowTitle.classList.add(`${EDITOR_PREFIX}-date-title__now`);
|
|
12406
|
-
const nextMonthTitle = document.createElement("span");
|
|
12407
|
-
nextMonthTitle.classList.add(`${EDITOR_PREFIX}-date-title__next-month`);
|
|
12408
|
-
nextMonthTitle.innerText = `>`;
|
|
12409
|
-
const nextYearTitle = document.createElement("span");
|
|
12410
|
-
nextYearTitle.classList.add(`${EDITOR_PREFIX}-date-title__next-year`);
|
|
12411
|
-
nextYearTitle.innerText = `>>`;
|
|
12412
|
-
datePickerTitle.append(preYearTitle);
|
|
12413
|
-
datePickerTitle.append(preMonthTitle);
|
|
12414
|
-
datePickerTitle.append(nowTitle);
|
|
12415
|
-
datePickerTitle.append(nextMonthTitle);
|
|
12416
|
-
datePickerTitle.append(nextYearTitle);
|
|
12417
|
-
const datePickerWeek = document.createElement("div");
|
|
12418
|
-
datePickerWeek.classList.add(`${EDITOR_PREFIX}-date-week`);
|
|
12419
|
-
const { weeks: { sun, mon, tue, wed, thu, fri, sat } } = this.lang;
|
|
12420
|
-
const weekList = [sun, mon, tue, wed, thu, fri, sat];
|
|
12421
|
-
weekList.forEach((week) => {
|
|
12422
|
-
const weekDom = document.createElement("span");
|
|
12423
|
-
weekDom.innerText = `${week}`;
|
|
12424
|
-
datePickerWeek.append(weekDom);
|
|
12582
|
+
setSelect(element) {
|
|
12583
|
+
const { radio } = element;
|
|
12584
|
+
if (radio) {
|
|
12585
|
+
radio.value = !radio.value;
|
|
12586
|
+
} else {
|
|
12587
|
+
element.radio = {
|
|
12588
|
+
value: true
|
|
12589
|
+
};
|
|
12590
|
+
}
|
|
12591
|
+
this.draw.render({
|
|
12592
|
+
isCompute: false,
|
|
12593
|
+
isSetCursor: false
|
|
12425
12594
|
});
|
|
12426
|
-
|
|
12427
|
-
|
|
12428
|
-
|
|
12429
|
-
|
|
12430
|
-
|
|
12431
|
-
const
|
|
12432
|
-
|
|
12433
|
-
|
|
12434
|
-
|
|
12435
|
-
|
|
12436
|
-
|
|
12437
|
-
|
|
12438
|
-
|
|
12439
|
-
|
|
12440
|
-
|
|
12441
|
-
|
|
12442
|
-
|
|
12443
|
-
|
|
12444
|
-
|
|
12445
|
-
|
|
12446
|
-
|
|
12447
|
-
|
|
12448
|
-
|
|
12449
|
-
|
|
12450
|
-
|
|
12451
|
-
|
|
12452
|
-
|
|
12453
|
-
|
|
12454
|
-
|
|
12455
|
-
|
|
12456
|
-
|
|
12457
|
-
|
|
12595
|
+
}
|
|
12596
|
+
render(ctx, element, x, y) {
|
|
12597
|
+
const { radio: { gap, lineWidth, fillStyle, strokeStyle }, scale } = this.options;
|
|
12598
|
+
const { metrics, radio } = element;
|
|
12599
|
+
const left2 = Math.round(x + gap * scale);
|
|
12600
|
+
const top = Math.round(y - metrics.height + lineWidth);
|
|
12601
|
+
const width = metrics.width - gap * 2 * scale;
|
|
12602
|
+
const height = metrics.height;
|
|
12603
|
+
ctx.save();
|
|
12604
|
+
ctx.beginPath();
|
|
12605
|
+
ctx.translate(0.5, 0.5);
|
|
12606
|
+
ctx.strokeStyle = (radio == null ? void 0 : radio.value) ? fillStyle : strokeStyle;
|
|
12607
|
+
ctx.lineWidth = lineWidth;
|
|
12608
|
+
ctx.arc(left2 + width / 2, top + height / 2, width / 2, 0, Math.PI * 2);
|
|
12609
|
+
ctx.stroke();
|
|
12610
|
+
if (radio == null ? void 0 : radio.value) {
|
|
12611
|
+
ctx.beginPath();
|
|
12612
|
+
ctx.fillStyle = fillStyle;
|
|
12613
|
+
ctx.arc(left2 + width / 2, top + height / 2, width / 3, 0, Math.PI * 2);
|
|
12614
|
+
ctx.fill();
|
|
12615
|
+
}
|
|
12616
|
+
ctx.closePath();
|
|
12617
|
+
ctx.restore();
|
|
12618
|
+
}
|
|
12619
|
+
}
|
|
12620
|
+
const encodedJs$2 = "KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBmOyhmdW5jdGlvbih0KXt0LlRFWFQ9InRleHQiLHQuVEFCTEU9InRhYmxlIix0LkhZUEVSTElOSz0iaHlwZXJsaW5rIix0LkNPTlRST0w9ImNvbnRyb2wifSkoZnx8KGY9e30pKTt2YXIgcDsoZnVuY3Rpb24odCl7dC5WQUxVRT0idmFsdWUifSkocHx8KHA9e30pKTtjb25zdCBoPSJcdTIwMEIiLGc9YApgO2Z1bmN0aW9uIGEodCl7bGV0IGw9IiIsbj0wO2Zvcig7bjx0Lmxlbmd0aDspe2NvbnN0IG89dFtuXTtpZihvLnR5cGU9PT1mLlRBQkxFKXtpZihvLnRyTGlzdClmb3IobGV0IHI9MDtyPG8udHJMaXN0Lmxlbmd0aDtyKyspe2NvbnN0IHM9by50ckxpc3Rbcl07Zm9yKGxldCBlPTA7ZTxzLnRkTGlzdC5sZW5ndGg7ZSsrKXtjb25zdCBpPXMudGRMaXN0W2VdO2wrPWEoaS52YWx1ZSl9fX1lbHNlIGlmKG8udHlwZT09PWYuSFlQRVJMSU5LKXtjb25zdCByPW8uaHlwZXJsaW5rSWQscz1bXTtmb3IoO248dC5sZW5ndGg7KXtjb25zdCBlPXRbbl07aWYociE9PWUuaHlwZXJsaW5rSWQpe24tLTticmVha31kZWxldGUgZS50eXBlLHMucHVzaChlKSxuKyt9bCs9YShzKX1lbHNlIGlmKG8uY29udHJvbElkKXtjb25zdCByPW8uY29udHJvbElkLHM9W107Zm9yKDtuPHQubGVuZ3RoOyl7Y29uc3QgZT10W25dO2lmKHIhPT1lLmNvbnRyb2xJZCl7bi0tO2JyZWFrfWUuY29udHJvbENvbXBvbmVudD09PXAuVkFMVUUmJihkZWxldGUgZS5jb250cm9sSWQscy5wdXNoKGUpKSxuKyt9bCs9YShzKX1lbHNlKCFvLnR5cGV8fG8udHlwZT09PWYuVEVYVCkmJihsKz1vLnZhbHVlKTtuKyt9cmV0dXJuIGx9ZnVuY3Rpb24gZCh0KXtjb25zdCBsPVtdLG49L1swLTldLyxvPS9bQS1aYS16XS8scj0vXHMvO2xldCBzPSExLGU9ITEsaT0iIjtmdW5jdGlvbiB1KCl7aSYmKGwucHVzaChpKSxpPSIiKX1mb3IoY29uc3QgYyBvZiB0KW8udGVzdChjKT8oc3x8dSgpLGkrPWMscz0hMCxlPSExKTpuLnRlc3QoYyk/KGV8fHUoKSxpKz1jLHM9ITEsZT0hMCk6KHUoKSxzPSExLGU9ITEsci50ZXN0KGMpfHxsLnB1c2goYykpO3JldHVybiB1KCksbH1vbm1lc3NhZ2U9dD0+e2NvbnN0IGw9dC5kYXRhLG89YShsKS5yZXBsYWNlKG5ldyBSZWdFeHAoYF4ke2h9YCksIiIpLnJlcGxhY2UobmV3IFJlZ0V4cChoLCJnIiksZykscj1kKG8pO3Bvc3RNZXNzYWdlKHIubGVuZ3RoKX19KSgpO30pKCk7Cg==";
|
|
12621
|
+
const blob$2 = typeof window !== "undefined" && window.Blob && new Blob([atob(encodedJs$2)], { type: "text/javascript;charset=utf-8" });
|
|
12622
|
+
function WorkerWrapper$2() {
|
|
12623
|
+
const objURL = blob$2 && (window.URL || window.webkitURL).createObjectURL(blob$2);
|
|
12624
|
+
try {
|
|
12625
|
+
return objURL ? new Worker(objURL) : new Worker("data:application/javascript;base64," + encodedJs$2, { type: "module" });
|
|
12626
|
+
} finally {
|
|
12627
|
+
objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
|
|
12628
|
+
}
|
|
12629
|
+
}
|
|
12630
|
+
const encodedJs$1 = "KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBhOyhmdW5jdGlvbih0KXt0LlRFWFQ9InRleHQiLHQuSU1BR0U9ImltYWdlIix0LlRBQkxFPSJ0YWJsZSIsdC5IWVBFUkxJTks9Imh5cGVybGluayIsdC5TVVBFUlNDUklQVD0ic3VwZXJzY3JpcHQiLHQuU1VCU0NSSVBUPSJzdWJzY3JpcHQiLHQuU0VQQVJBVE9SPSJzZXBhcmF0b3IiLHQuUEFHRV9CUkVBSz0icGFnZUJyZWFrIix0LkNPTlRST0w9ImNvbnRyb2wiLHQuQ0hFQ0tCT1g9ImNoZWNrYm94Iix0LlJBRElPPSJyYWRpbyIsdC5MQVRFWD0ibGF0ZXgiLHQuVEFCPSJ0YWIiLHQuREFURT0iZGF0ZSIsdC5CTE9DSz0iYmxvY2siLHQuVElUTEU9InRpdGxlIix0LkxJU1Q9Imxpc3QifSkoYXx8KGE9e30pKTt2YXIgYzsoZnVuY3Rpb24odCl7dC5GSVJTVD0iZmlyc3QiLHQuU0VDT05EPSJzZWNvbmQiLHQuVEhJUkQ9InRoaXJkIix0LkZPVVJUSD0iZm91cnRoIix0LkZJRlRIPSJmaWZ0aCIsdC5TSVhUSD0ic2l4dGgifSkoY3x8KGM9e30pKTtjb25zdCBJPXtbYy5GSVJTVF06MSxbYy5TRUNPTkRdOjIsW2MuVEhJUkRdOjMsW2MuRk9VUlRIXTo0LFtjLkZJRlRIXTo1LFtjLlNJWFRIXTo2fSx2PVthLlRFWFQsYS5IWVBFUkxJTkssYS5TVUJTQ1JJUFQsYS5TVVBFUlNDUklQVCxhLkNPTlRST0wsYS5EQVRFXSxoPSJcdTIwMEIiO2Z1bmN0aW9uIFQodCl7cmV0dXJuIXQudHlwZXx8di5pbmNsdWRlcyh0LnR5cGUpfWZ1bmN0aW9uIGYodCl7Y29uc3QgaT1bXTtsZXQgZT0wO2Zvcig7ZTx0Lmxlbmd0aDspe2NvbnN0IHM9dFtlXTtpZihzLnRpdGxlSWQpe2NvbnN0IG89cy50aXRsZUlkLGw9cy5sZXZlbCxuPXt0eXBlOmEuVElUTEUsdmFsdWU6IiIsbGV2ZWw6bCx0aXRsZUlkOm99LHI9W107Zm9yKDtlPHQubGVuZ3RoOyl7Y29uc3QgdT10W2VdO2lmKG8hPT11LnRpdGxlSWQpe2UtLTticmVha31yLnB1c2godSksZSsrfW4udmFsdWU9ci5maWx0ZXIodT0+VCh1KSkubWFwKHU9PnUudmFsdWUpLmpvaW4oIiIpLnJlcGxhY2UobmV3IFJlZ0V4cChoLCJnIiksIiIpLGkucHVzaChuKX1lKyt9aWYoIWkubGVuZ3RoKXJldHVybiBudWxsO2NvbnN0IGc9KHMsbyk9Pntjb25zdCBsPW8uc3ViQ2F0YWxvZ1tvLnN1YkNhdGFsb2cubGVuZ3RoLTFdLG49SVtsPT1udWxsP3ZvaWQgMDpsLmxldmVsXSxyPUlbcy5sZXZlbF07bCYmcj5uP2cocyxsKTpvLnN1YkNhdGFsb2cucHVzaCh7aWQ6cy50aXRsZUlkLG5hbWU6cy52YWx1ZSxsZXZlbDpzLmxldmVsLHN1YkNhdGFsb2c6W119KX0sUj1bXTtmb3IobGV0IHM9MDtzPGkubGVuZ3RoO3MrKyl7Y29uc3Qgbz1pW3NdLGw9UltSLmxlbmd0aC0xXSxuPUlbbD09bnVsbD92b2lkIDA6bC5sZXZlbF0scj1JW28ubGV2ZWxdO2wmJnI+bj9nKG8sbCk6Ui5wdXNoKHtpZDpvLnRpdGxlSWQsbmFtZTpvLnZhbHVlLGxldmVsOm8ubGV2ZWwsc3ViQ2F0YWxvZzpbXX0pfXJldHVybiBSfW9ubWVzc2FnZT10PT57Y29uc3QgaT10LmRhdGEsZT1mKGkpO3Bvc3RNZXNzYWdlKGUpfX0pKCk7fSkoKTsK";
|
|
12631
|
+
const blob$1 = typeof window !== "undefined" && window.Blob && new Blob([atob(encodedJs$1)], { type: "text/javascript;charset=utf-8" });
|
|
12632
|
+
function WorkerWrapper$1() {
|
|
12633
|
+
const objURL = blob$1 && (window.URL || window.webkitURL).createObjectURL(blob$1);
|
|
12634
|
+
try {
|
|
12635
|
+
return objURL ? new Worker(objURL) : new Worker("data:application/javascript;base64," + encodedJs$1, { type: "module" });
|
|
12636
|
+
} finally {
|
|
12637
|
+
objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
|
|
12638
|
+
}
|
|
12639
|
+
}
|
|
12640
|
+
const encodedJs = "KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBuOyhmdW5jdGlvbihvKXtvLlRBQkxFPSJ0YWJsZSJ9KShufHwobj17fSkpO2Z1bmN0aW9uIGMobyl7Y29uc3QgdD1bXTtmb3IoY29uc3QgcyBvZiBvKXtpZihzLnR5cGU9PT1uLlRBQkxFKXtjb25zdCBlPXMudHJMaXN0O2ZvcihsZXQgcj0wO3I8ZS5sZW5ndGg7cisrKXtjb25zdCBpPWVbcl07Zm9yKGxldCB1PTA7dTxpLnRkTGlzdC5sZW5ndGg7dSsrKXtjb25zdCBkPWkudGRMaXN0W3VdO3QucHVzaCguLi5jKGQudmFsdWUpKX19fWlmKCEhcy5ncm91cElkcylmb3IoY29uc3QgZSBvZiBzLmdyb3VwSWRzKXQuaW5jbHVkZXMoZSl8fHQucHVzaChlKX1yZXR1cm4gdH1vbm1lc3NhZ2U9bz0+e2NvbnN0IHQ9by5kYXRhLHM9Yyh0KTtwb3N0TWVzc2FnZShzKX19KSgpO30pKCk7Cg==";
|
|
12641
|
+
const blob = typeof window !== "undefined" && window.Blob && new Blob([atob(encodedJs)], { type: "text/javascript;charset=utf-8" });
|
|
12642
|
+
function WorkerWrapper() {
|
|
12643
|
+
const objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
|
|
12644
|
+
try {
|
|
12645
|
+
return objURL ? new Worker(objURL) : new Worker("data:application/javascript;base64," + encodedJs, { type: "module" });
|
|
12646
|
+
} finally {
|
|
12647
|
+
objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
|
|
12648
|
+
}
|
|
12649
|
+
}
|
|
12650
|
+
class WorkerManager {
|
|
12651
|
+
constructor(draw) {
|
|
12652
|
+
__publicField(this, "draw");
|
|
12653
|
+
__publicField(this, "wordCountWorker");
|
|
12654
|
+
__publicField(this, "catalogWorker");
|
|
12655
|
+
__publicField(this, "groupWorker");
|
|
12656
|
+
this.draw = draw;
|
|
12657
|
+
this.wordCountWorker = new WorkerWrapper$2();
|
|
12658
|
+
this.catalogWorker = new WorkerWrapper$1();
|
|
12659
|
+
this.groupWorker = new WorkerWrapper();
|
|
12660
|
+
}
|
|
12661
|
+
getWordCount() {
|
|
12662
|
+
return new Promise((resolve, reject) => {
|
|
12663
|
+
this.wordCountWorker.onmessage = (evt) => {
|
|
12664
|
+
resolve(evt.data);
|
|
12665
|
+
};
|
|
12666
|
+
this.wordCountWorker.onerror = (evt) => {
|
|
12667
|
+
reject(evt);
|
|
12668
|
+
};
|
|
12669
|
+
const elementList = this.draw.getOriginalMainElementList();
|
|
12670
|
+
this.wordCountWorker.postMessage(elementList);
|
|
12671
|
+
});
|
|
12672
|
+
}
|
|
12673
|
+
getCatalog() {
|
|
12674
|
+
return new Promise((resolve, reject) => {
|
|
12675
|
+
this.catalogWorker.onmessage = (evt) => {
|
|
12676
|
+
resolve(evt.data);
|
|
12677
|
+
};
|
|
12678
|
+
this.catalogWorker.onerror = (evt) => {
|
|
12679
|
+
reject(evt);
|
|
12680
|
+
};
|
|
12681
|
+
const elementList = this.draw.getOriginalMainElementList();
|
|
12682
|
+
this.catalogWorker.postMessage(elementList);
|
|
12683
|
+
});
|
|
12684
|
+
}
|
|
12685
|
+
getGroupIds() {
|
|
12686
|
+
return new Promise((resolve, reject) => {
|
|
12687
|
+
this.groupWorker.onmessage = (evt) => {
|
|
12688
|
+
resolve(evt.data);
|
|
12689
|
+
};
|
|
12690
|
+
this.groupWorker.onerror = (evt) => {
|
|
12691
|
+
reject(evt);
|
|
12692
|
+
};
|
|
12693
|
+
const elementList = this.draw.getOriginalMainElementList();
|
|
12694
|
+
this.groupWorker.postMessage(elementList);
|
|
12695
|
+
});
|
|
12696
|
+
}
|
|
12697
|
+
}
|
|
12698
|
+
class Previewer {
|
|
12699
|
+
constructor(draw) {
|
|
12700
|
+
__publicField(this, "container");
|
|
12701
|
+
__publicField(this, "canvas");
|
|
12702
|
+
__publicField(this, "draw");
|
|
12703
|
+
__publicField(this, "options");
|
|
12704
|
+
__publicField(this, "curElement");
|
|
12705
|
+
__publicField(this, "curElementSrc");
|
|
12706
|
+
__publicField(this, "previewerDrawOption");
|
|
12707
|
+
__publicField(this, "curPosition");
|
|
12708
|
+
__publicField(this, "resizerSelection");
|
|
12709
|
+
__publicField(this, "resizerHandleList");
|
|
12710
|
+
__publicField(this, "resizerImageContainer");
|
|
12711
|
+
__publicField(this, "resizerImage");
|
|
12712
|
+
__publicField(this, "resizerSize");
|
|
12713
|
+
__publicField(this, "width");
|
|
12714
|
+
__publicField(this, "height");
|
|
12715
|
+
__publicField(this, "mousedownX");
|
|
12716
|
+
__publicField(this, "mousedownY");
|
|
12717
|
+
__publicField(this, "curHandleIndex");
|
|
12718
|
+
__publicField(this, "previewerContainer");
|
|
12719
|
+
__publicField(this, "previewerImage");
|
|
12720
|
+
__publicField(this, "_keydown", () => {
|
|
12721
|
+
if (this.resizerSelection.style.display === "block") {
|
|
12722
|
+
this.clearResizer();
|
|
12723
|
+
document.removeEventListener("keydown", this._keydown);
|
|
12458
12724
|
}
|
|
12459
|
-
li.append(ol);
|
|
12460
|
-
timeWrap.append(li);
|
|
12461
12725
|
});
|
|
12462
|
-
|
|
12463
|
-
|
|
12464
|
-
|
|
12465
|
-
|
|
12466
|
-
|
|
12467
|
-
|
|
12468
|
-
|
|
12469
|
-
|
|
12470
|
-
const
|
|
12471
|
-
|
|
12472
|
-
|
|
12473
|
-
|
|
12474
|
-
|
|
12475
|
-
|
|
12476
|
-
|
|
12477
|
-
|
|
12478
|
-
|
|
12479
|
-
this.
|
|
12726
|
+
this.container = draw.getContainer();
|
|
12727
|
+
this.canvas = draw.getPage();
|
|
12728
|
+
this.draw = draw;
|
|
12729
|
+
this.options = draw.getOptions();
|
|
12730
|
+
this.curElement = null;
|
|
12731
|
+
this.curElementSrc = "";
|
|
12732
|
+
this.previewerDrawOption = {};
|
|
12733
|
+
this.curPosition = null;
|
|
12734
|
+
const { resizerSelection, resizerHandleList, resizerImageContainer, resizerImage, resizerSize } = this._createResizerDom();
|
|
12735
|
+
this.resizerSelection = resizerSelection;
|
|
12736
|
+
this.resizerHandleList = resizerHandleList;
|
|
12737
|
+
this.resizerImageContainer = resizerImageContainer;
|
|
12738
|
+
this.resizerImage = resizerImage;
|
|
12739
|
+
this.resizerSize = resizerSize;
|
|
12740
|
+
this.width = 0;
|
|
12741
|
+
this.height = 0;
|
|
12742
|
+
this.mousedownX = 0;
|
|
12743
|
+
this.mousedownY = 0;
|
|
12744
|
+
this.curHandleIndex = 0;
|
|
12745
|
+
this.previewerContainer = null;
|
|
12746
|
+
this.previewerImage = null;
|
|
12747
|
+
}
|
|
12748
|
+
_getElementPosition(element, position = null) {
|
|
12749
|
+
var _a;
|
|
12750
|
+
let x = 0;
|
|
12751
|
+
let y = 0;
|
|
12752
|
+
const height = this.draw.getHeight();
|
|
12753
|
+
const pageGap = this.draw.getPageGap();
|
|
12754
|
+
const pageNo = (_a = position == null ? void 0 : position.pageNo) != null ? _a : this.draw.getPageNo();
|
|
12755
|
+
const preY = pageNo * (height + pageGap);
|
|
12756
|
+
if (element.imgFloatPosition) {
|
|
12757
|
+
x = element.imgFloatPosition.x;
|
|
12758
|
+
y = element.imgFloatPosition.y + preY;
|
|
12759
|
+
} else if (position) {
|
|
12760
|
+
const { coordinate: { leftTop: [left2, top] }, ascent } = position;
|
|
12761
|
+
x = left2;
|
|
12762
|
+
y = top + preY + ascent;
|
|
12763
|
+
}
|
|
12764
|
+
return { x, y };
|
|
12765
|
+
}
|
|
12766
|
+
_createResizerDom() {
|
|
12767
|
+
const resizerSelection = document.createElement("div");
|
|
12768
|
+
resizerSelection.classList.add(`${EDITOR_PREFIX}-resizer-selection`);
|
|
12769
|
+
resizerSelection.style.display = "none";
|
|
12770
|
+
resizerSelection.style.borderColor = this.options.resizerColor;
|
|
12771
|
+
const resizerHandleList = [];
|
|
12772
|
+
for (let i = 0; i < 8; i++) {
|
|
12773
|
+
const handleDom = document.createElement("div");
|
|
12774
|
+
handleDom.style.background = this.options.resizerColor;
|
|
12775
|
+
handleDom.classList.add(`resizer-handle`);
|
|
12776
|
+
handleDom.classList.add(`handle-${i}`);
|
|
12777
|
+
handleDom.setAttribute("data-index", String(i));
|
|
12778
|
+
handleDom.onmousedown = this._mousedown.bind(this);
|
|
12779
|
+
resizerSelection.append(handleDom);
|
|
12780
|
+
resizerHandleList.push(handleDom);
|
|
12781
|
+
}
|
|
12782
|
+
this.container.append(resizerSelection);
|
|
12783
|
+
const resizerSizeView = document.createElement("div");
|
|
12784
|
+
resizerSizeView.classList.add(`${EDITOR_PREFIX}-resizer-size-view`);
|
|
12785
|
+
const resizerSize = document.createElement("span");
|
|
12786
|
+
resizerSizeView.append(resizerSize);
|
|
12787
|
+
resizerSelection.append(resizerSizeView);
|
|
12788
|
+
const resizerImageContainer = document.createElement("div");
|
|
12789
|
+
resizerImageContainer.classList.add(`${EDITOR_PREFIX}-resizer-image`);
|
|
12790
|
+
resizerImageContainer.style.display = "none";
|
|
12791
|
+
const resizerImage = document.createElement("img");
|
|
12792
|
+
resizerImageContainer.append(resizerImage);
|
|
12793
|
+
this.container.append(resizerImageContainer);
|
|
12480
12794
|
return {
|
|
12481
|
-
|
|
12482
|
-
|
|
12483
|
-
|
|
12484
|
-
|
|
12485
|
-
|
|
12486
|
-
preYear: preYearTitle,
|
|
12487
|
-
preMonth: preMonthTitle,
|
|
12488
|
-
now: nowTitle,
|
|
12489
|
-
nextMonth: nextMonthTitle,
|
|
12490
|
-
nextYear: nextYearTitle
|
|
12491
|
-
},
|
|
12492
|
-
day: datePickerDay,
|
|
12493
|
-
time: {
|
|
12494
|
-
hour: hourTime,
|
|
12495
|
-
minute: minuteTime,
|
|
12496
|
-
second: secondTime
|
|
12497
|
-
},
|
|
12498
|
-
menu: {
|
|
12499
|
-
time: timeMenu,
|
|
12500
|
-
now: nowMenu,
|
|
12501
|
-
submit: submitMenu
|
|
12502
|
-
}
|
|
12795
|
+
resizerSelection,
|
|
12796
|
+
resizerHandleList,
|
|
12797
|
+
resizerImageContainer,
|
|
12798
|
+
resizerImage,
|
|
12799
|
+
resizerSize
|
|
12503
12800
|
};
|
|
12504
12801
|
}
|
|
12505
|
-
|
|
12506
|
-
this.
|
|
12507
|
-
|
|
12508
|
-
|
|
12509
|
-
|
|
12510
|
-
|
|
12511
|
-
|
|
12512
|
-
|
|
12513
|
-
|
|
12802
|
+
_mousedown(evt) {
|
|
12803
|
+
this.canvas = this.draw.getPage();
|
|
12804
|
+
if (!this.curElement)
|
|
12805
|
+
return;
|
|
12806
|
+
const { scale } = this.options;
|
|
12807
|
+
this.mousedownX = evt.x;
|
|
12808
|
+
this.mousedownY = evt.y;
|
|
12809
|
+
const target = evt.target;
|
|
12810
|
+
this.curHandleIndex = Number(target.dataset.index);
|
|
12811
|
+
const cursor = window.getComputedStyle(target).cursor;
|
|
12812
|
+
document.body.style.cursor = cursor;
|
|
12813
|
+
this.canvas.style.cursor = cursor;
|
|
12814
|
+
this.resizerImage.src = this.curElementSrc;
|
|
12815
|
+
this.resizerImageContainer.style.display = "block";
|
|
12816
|
+
const { x: resizerLeft, y: resizerTop } = this._getElementPosition(this.curElement, this.curPosition);
|
|
12817
|
+
this.resizerImageContainer.style.left = `${resizerLeft}px`;
|
|
12818
|
+
this.resizerImageContainer.style.top = `${resizerTop}px`;
|
|
12819
|
+
this.resizerImage.style.width = `${this.curElement.width * scale}px`;
|
|
12820
|
+
this.resizerImage.style.height = `${this.curElement.height * scale}px`;
|
|
12821
|
+
const mousemoveFn = this._mousemove.bind(this);
|
|
12822
|
+
document.addEventListener("mousemove", mousemoveFn);
|
|
12823
|
+
document.addEventListener("mouseup", () => {
|
|
12824
|
+
var _a;
|
|
12825
|
+
if (this.curElement) {
|
|
12826
|
+
this.curElement.width = this.width;
|
|
12827
|
+
this.curElement.height = this.height;
|
|
12828
|
+
this.draw.render({
|
|
12829
|
+
isSetCursor: true,
|
|
12830
|
+
curIndex: (_a = this.curPosition) == null ? void 0 : _a.index
|
|
12831
|
+
});
|
|
12832
|
+
}
|
|
12833
|
+
this.resizerImageContainer.style.display = "none";
|
|
12834
|
+
document.removeEventListener("mousemove", mousemoveFn);
|
|
12835
|
+
document.body.style.cursor = "";
|
|
12836
|
+
this.canvas.style.cursor = "text";
|
|
12837
|
+
}, {
|
|
12838
|
+
once: true
|
|
12839
|
+
});
|
|
12840
|
+
evt.preventDefault();
|
|
12841
|
+
}
|
|
12842
|
+
_mousemove(evt) {
|
|
12843
|
+
if (!this.curElement)
|
|
12844
|
+
return;
|
|
12845
|
+
const { scale } = this.options;
|
|
12846
|
+
let dx = 0;
|
|
12847
|
+
let dy = 0;
|
|
12848
|
+
switch (this.curHandleIndex) {
|
|
12849
|
+
case 0:
|
|
12850
|
+
{
|
|
12851
|
+
const offsetX = this.mousedownX - evt.x;
|
|
12852
|
+
const offsetY = this.mousedownY - evt.y;
|
|
12853
|
+
dx = Math.cbrt(offsetX ** 3 + offsetY ** 3);
|
|
12854
|
+
dy = this.curElement.height * dx / this.curElement.width;
|
|
12855
|
+
}
|
|
12856
|
+
break;
|
|
12857
|
+
case 1:
|
|
12858
|
+
dy = this.mousedownY - evt.y;
|
|
12859
|
+
break;
|
|
12860
|
+
case 2:
|
|
12861
|
+
{
|
|
12862
|
+
const offsetX = evt.x - this.mousedownX;
|
|
12863
|
+
const offsetY = this.mousedownY - evt.y;
|
|
12864
|
+
dx = Math.cbrt(offsetX ** 3 + offsetY ** 3);
|
|
12865
|
+
dy = this.curElement.height * dx / this.curElement.width;
|
|
12866
|
+
}
|
|
12867
|
+
break;
|
|
12868
|
+
case 4:
|
|
12869
|
+
{
|
|
12870
|
+
const offsetX = evt.x - this.mousedownX;
|
|
12871
|
+
const offsetY = evt.y - this.mousedownY;
|
|
12872
|
+
dx = Math.cbrt(offsetX ** 3 + offsetY ** 3);
|
|
12873
|
+
dy = this.curElement.height * dx / this.curElement.width;
|
|
12874
|
+
}
|
|
12875
|
+
break;
|
|
12876
|
+
case 3:
|
|
12877
|
+
dx = evt.x - this.mousedownX;
|
|
12878
|
+
break;
|
|
12879
|
+
case 5:
|
|
12880
|
+
dy = evt.y - this.mousedownY;
|
|
12881
|
+
break;
|
|
12882
|
+
case 6:
|
|
12883
|
+
{
|
|
12884
|
+
const offsetX = this.mousedownX - evt.x;
|
|
12885
|
+
const offsetY = evt.y - this.mousedownY;
|
|
12886
|
+
dx = Math.cbrt(offsetX ** 3 + offsetY ** 3);
|
|
12887
|
+
dy = this.curElement.height * dx / this.curElement.width;
|
|
12888
|
+
}
|
|
12889
|
+
break;
|
|
12890
|
+
case 7:
|
|
12891
|
+
dx = this.mousedownX - evt.x;
|
|
12892
|
+
break;
|
|
12893
|
+
}
|
|
12894
|
+
const dw = this.curElement.width + dx / scale;
|
|
12895
|
+
const dh = this.curElement.height + dy / scale;
|
|
12896
|
+
if (dw <= 0 || dh <= 0)
|
|
12897
|
+
return;
|
|
12898
|
+
this.width = dw;
|
|
12899
|
+
this.height = dh;
|
|
12900
|
+
const elementWidth = dw * scale;
|
|
12901
|
+
const elementHeight = dh * scale;
|
|
12902
|
+
this.resizerImage.style.width = `${elementWidth}px`;
|
|
12903
|
+
this.resizerImage.style.height = `${elementHeight}px`;
|
|
12904
|
+
this._updateResizerRect(elementWidth, elementHeight);
|
|
12905
|
+
this._updateResizerSizeView(elementWidth, elementHeight);
|
|
12906
|
+
evt.preventDefault();
|
|
12907
|
+
}
|
|
12908
|
+
_drawPreviewer() {
|
|
12909
|
+
const previewerContainer = document.createElement("div");
|
|
12910
|
+
previewerContainer.classList.add(`${EDITOR_PREFIX}-image-previewer`);
|
|
12911
|
+
const closeBtn = document.createElement("i");
|
|
12912
|
+
closeBtn.classList.add("image-close");
|
|
12913
|
+
closeBtn.onclick = () => {
|
|
12914
|
+
this._clearPreviewer();
|
|
12514
12915
|
};
|
|
12515
|
-
|
|
12516
|
-
|
|
12916
|
+
previewerContainer.append(closeBtn);
|
|
12917
|
+
const imgContainer = document.createElement("div");
|
|
12918
|
+
imgContainer.classList.add(`${EDITOR_PREFIX}-image-container`);
|
|
12919
|
+
const img = document.createElement("img");
|
|
12920
|
+
img.src = this.curElementSrc;
|
|
12921
|
+
img.draggable = false;
|
|
12922
|
+
imgContainer.append(img);
|
|
12923
|
+
this.previewerImage = img;
|
|
12924
|
+
previewerContainer.append(imgContainer);
|
|
12925
|
+
let x = 0;
|
|
12926
|
+
let y = 0;
|
|
12927
|
+
let scaleSize = 1;
|
|
12928
|
+
let rotateSize = 0;
|
|
12929
|
+
const menuContainer = document.createElement("div");
|
|
12930
|
+
menuContainer.classList.add(`${EDITOR_PREFIX}-image-menu`);
|
|
12931
|
+
const zoomIn = document.createElement("i");
|
|
12932
|
+
zoomIn.classList.add("zoom-in");
|
|
12933
|
+
zoomIn.onclick = () => {
|
|
12934
|
+
scaleSize += 0.1;
|
|
12935
|
+
this._setPreviewerTransform(scaleSize, rotateSize, x, y);
|
|
12517
12936
|
};
|
|
12518
|
-
|
|
12519
|
-
|
|
12520
|
-
|
|
12937
|
+
menuContainer.append(zoomIn);
|
|
12938
|
+
const zoomOut = document.createElement("i");
|
|
12939
|
+
zoomOut.onclick = () => {
|
|
12940
|
+
if (scaleSize - 0.1 <= 0.1)
|
|
12941
|
+
return;
|
|
12942
|
+
scaleSize -= 0.1;
|
|
12943
|
+
this._setPreviewerTransform(scaleSize, rotateSize, x, y);
|
|
12521
12944
|
};
|
|
12522
|
-
|
|
12523
|
-
|
|
12524
|
-
|
|
12945
|
+
zoomOut.classList.add("zoom-out");
|
|
12946
|
+
menuContainer.append(zoomOut);
|
|
12947
|
+
const rotate = document.createElement("i");
|
|
12948
|
+
rotate.classList.add("rotate");
|
|
12949
|
+
rotate.onclick = () => {
|
|
12950
|
+
rotateSize += 1;
|
|
12951
|
+
this._setPreviewerTransform(scaleSize, rotateSize, x, y);
|
|
12525
12952
|
};
|
|
12526
|
-
|
|
12527
|
-
|
|
12528
|
-
|
|
12953
|
+
menuContainer.append(rotate);
|
|
12954
|
+
const originalSize = document.createElement("i");
|
|
12955
|
+
originalSize.classList.add("original-size");
|
|
12956
|
+
originalSize.onclick = () => {
|
|
12957
|
+
x = 0;
|
|
12958
|
+
y = 0;
|
|
12959
|
+
scaleSize = 1;
|
|
12960
|
+
rotateSize = 0;
|
|
12961
|
+
this._setPreviewerTransform(scaleSize, rotateSize, x, y);
|
|
12529
12962
|
};
|
|
12530
|
-
|
|
12531
|
-
|
|
12532
|
-
|
|
12533
|
-
|
|
12534
|
-
|
|
12535
|
-
|
|
12536
|
-
|
|
12537
|
-
this.pickDate.setHours(Number(id));
|
|
12538
|
-
this._setTimePick(false);
|
|
12963
|
+
menuContainer.append(originalSize);
|
|
12964
|
+
const imageDownload = document.createElement("i");
|
|
12965
|
+
imageDownload.classList.add("image-download");
|
|
12966
|
+
imageDownload.onclick = () => {
|
|
12967
|
+
var _a;
|
|
12968
|
+
const { mime } = this.previewerDrawOption;
|
|
12969
|
+
downloadFile(img.src, `${(_a = this.curElement) == null ? void 0 : _a.id}.${mime || "png"}`);
|
|
12539
12970
|
};
|
|
12540
|
-
|
|
12541
|
-
|
|
12542
|
-
|
|
12543
|
-
|
|
12544
|
-
|
|
12545
|
-
|
|
12546
|
-
|
|
12547
|
-
|
|
12548
|
-
|
|
12971
|
+
menuContainer.append(imageDownload);
|
|
12972
|
+
previewerContainer.append(menuContainer);
|
|
12973
|
+
this.previewerContainer = previewerContainer;
|
|
12974
|
+
document.body.append(previewerContainer);
|
|
12975
|
+
let startX = 0;
|
|
12976
|
+
let startY = 0;
|
|
12977
|
+
let isAllowDrag = false;
|
|
12978
|
+
img.onmousedown = (evt) => {
|
|
12979
|
+
isAllowDrag = true;
|
|
12980
|
+
startX = evt.x;
|
|
12981
|
+
startY = evt.y;
|
|
12982
|
+
previewerContainer.style.cursor = "move";
|
|
12549
12983
|
};
|
|
12550
|
-
|
|
12551
|
-
if (!
|
|
12552
|
-
return;
|
|
12553
|
-
const li = evt.target;
|
|
12554
|
-
const id = li.dataset.id;
|
|
12555
|
-
if (!id)
|
|
12984
|
+
previewerContainer.onmousemove = (evt) => {
|
|
12985
|
+
if (!isAllowDrag)
|
|
12556
12986
|
return;
|
|
12557
|
-
|
|
12558
|
-
|
|
12559
|
-
|
|
12560
|
-
|
|
12561
|
-
|
|
12562
|
-
|
|
12563
|
-
|
|
12564
|
-
|
|
12565
|
-
|
|
12566
|
-
|
|
12567
|
-
|
|
12568
|
-
|
|
12569
|
-
|
|
12570
|
-
|
|
12571
|
-
|
|
12572
|
-
|
|
12573
|
-
|
|
12574
|
-
|
|
12575
|
-
const setDate = new Date(value);
|
|
12576
|
-
this.now = this.isInvalidDate(setDate) ? new Date() : setDate;
|
|
12577
|
-
} else {
|
|
12578
|
-
this.now = new Date();
|
|
12579
|
-
}
|
|
12580
|
-
this.pickDate = new Date(this.now);
|
|
12581
|
-
}
|
|
12582
|
-
_setLang() {
|
|
12583
|
-
this.dom.menu.time.innerText = this.lang.timeSelect;
|
|
12584
|
-
this.dom.menu.now.innerText = this.lang.now;
|
|
12585
|
-
this.dom.menu.submit.innerText = this.lang.confirm;
|
|
12586
|
-
const { weeks: { sun, mon, tue, wed, thu, fri, sat } } = this.lang;
|
|
12587
|
-
const weekList = [sun, mon, tue, wed, thu, fri, sat];
|
|
12588
|
-
this.dom.datePickerWeek.childNodes.forEach((child, i) => {
|
|
12589
|
-
const childElement = child;
|
|
12590
|
-
childElement.innerText = weekList[i];
|
|
12591
|
-
});
|
|
12592
|
-
const hourTitle = this.dom.time.hour.previousElementSibling;
|
|
12593
|
-
hourTitle.innerText = this.lang.hour;
|
|
12594
|
-
const minuteTitle = this.dom.time.minute.previousElementSibling;
|
|
12595
|
-
minuteTitle.innerText = this.lang.minute;
|
|
12596
|
-
const secondTitle = this.dom.time.second.previousElementSibling;
|
|
12597
|
-
secondTitle.innerText = this.lang.second;
|
|
12598
|
-
}
|
|
12599
|
-
_update() {
|
|
12600
|
-
const localDate = new Date();
|
|
12601
|
-
const localYear = localDate.getFullYear();
|
|
12602
|
-
const localMonth = localDate.getMonth() + 1;
|
|
12603
|
-
const localDay = localDate.getDate();
|
|
12604
|
-
let pickYear = null;
|
|
12605
|
-
let pickMonth = null;
|
|
12606
|
-
let pickDay = null;
|
|
12607
|
-
if (this.pickDate) {
|
|
12608
|
-
pickYear = this.pickDate.getFullYear();
|
|
12609
|
-
pickMonth = this.pickDate.getMonth() + 1;
|
|
12610
|
-
pickDay = this.pickDate.getDate();
|
|
12611
|
-
}
|
|
12612
|
-
const year = this.now.getFullYear();
|
|
12613
|
-
const month = this.now.getMonth() + 1;
|
|
12614
|
-
this.dom.title.now.innerText = `${year}${this.lang.year} ${String(month).padStart(2, "0")}${this.lang.month}`;
|
|
12615
|
-
const curDate = new Date(year, month, 0);
|
|
12616
|
-
const curDay = curDate.getDate();
|
|
12617
|
-
let curWeek = new Date(year, month - 1, 1).getDay();
|
|
12618
|
-
if (curWeek === 0) {
|
|
12619
|
-
curWeek = 7;
|
|
12620
|
-
}
|
|
12621
|
-
const preDay = new Date(year, month - 1, 0).getDate();
|
|
12622
|
-
this.dom.day.innerHTML = "";
|
|
12623
|
-
const preStartDay = preDay - curWeek + 1;
|
|
12624
|
-
for (let i = preStartDay; i <= preDay; i++) {
|
|
12625
|
-
const dayDom = document.createElement("div");
|
|
12626
|
-
dayDom.classList.add("disable");
|
|
12627
|
-
dayDom.innerText = `${i}`;
|
|
12628
|
-
dayDom.onclick = () => {
|
|
12629
|
-
const newMonth = month - 2;
|
|
12630
|
-
this.now = new Date(year, newMonth, i);
|
|
12631
|
-
this._setDatePick(year, newMonth, i);
|
|
12632
|
-
};
|
|
12633
|
-
this.dom.day.append(dayDom);
|
|
12634
|
-
}
|
|
12635
|
-
for (let i = 1; i <= curDay; i++) {
|
|
12636
|
-
const dayDom = document.createElement("div");
|
|
12637
|
-
if (localYear === year && localMonth === month && localDay === i) {
|
|
12638
|
-
dayDom.classList.add("active");
|
|
12639
|
-
}
|
|
12640
|
-
if (this.pickDate && pickYear === year && pickMonth === month && pickDay === i) {
|
|
12641
|
-
dayDom.classList.add("select");
|
|
12642
|
-
}
|
|
12643
|
-
dayDom.innerText = `${i}`;
|
|
12644
|
-
dayDom.onclick = (evt) => {
|
|
12645
|
-
const newMonth = month - 1;
|
|
12646
|
-
this.now = new Date(year, newMonth, i);
|
|
12647
|
-
this._setDatePick(year, newMonth, i);
|
|
12648
|
-
evt.stopPropagation();
|
|
12649
|
-
};
|
|
12650
|
-
this.dom.day.append(dayDom);
|
|
12651
|
-
}
|
|
12652
|
-
const nextEndDay = 6 * 7 - curWeek - curDay;
|
|
12653
|
-
for (let i = 1; i <= nextEndDay; i++) {
|
|
12654
|
-
const dayDom = document.createElement("div");
|
|
12655
|
-
dayDom.classList.add("disable");
|
|
12656
|
-
dayDom.innerText = `${i}`;
|
|
12657
|
-
dayDom.onclick = () => {
|
|
12658
|
-
this.now = new Date(year, month, i);
|
|
12659
|
-
this._setDatePick(year, month, i);
|
|
12660
|
-
};
|
|
12661
|
-
this.dom.day.append(dayDom);
|
|
12662
|
-
}
|
|
12663
|
-
}
|
|
12664
|
-
_toggleDateTimePicker() {
|
|
12665
|
-
if (this.isDatePicker) {
|
|
12666
|
-
this.dom.dateWrap.classList.add("active");
|
|
12667
|
-
this.dom.timeWrap.classList.remove("active");
|
|
12668
|
-
this.dom.menu.time.innerText = this.lang.timeSelect;
|
|
12669
|
-
} else {
|
|
12670
|
-
this.dom.dateWrap.classList.remove("active");
|
|
12671
|
-
this.dom.timeWrap.classList.add("active");
|
|
12672
|
-
this.dom.menu.time.innerText = this.lang.return;
|
|
12673
|
-
this._setTimePick();
|
|
12674
|
-
}
|
|
12675
|
-
}
|
|
12676
|
-
_setDatePick(year, month, day) {
|
|
12677
|
-
var _a, _b, _c;
|
|
12678
|
-
this.now = new Date(year, month, day);
|
|
12679
|
-
(_a = this.pickDate) == null ? void 0 : _a.setFullYear(year);
|
|
12680
|
-
(_b = this.pickDate) == null ? void 0 : _b.setMonth(month);
|
|
12681
|
-
(_c = this.pickDate) == null ? void 0 : _c.setDate(day);
|
|
12682
|
-
this._update();
|
|
12683
|
-
}
|
|
12684
|
-
_setTimePick(isIntoView = true) {
|
|
12685
|
-
var _a, _b, _c;
|
|
12686
|
-
const hour = ((_a = this.pickDate) == null ? void 0 : _a.getHours()) || 0;
|
|
12687
|
-
const minute = ((_b = this.pickDate) == null ? void 0 : _b.getMinutes()) || 0;
|
|
12688
|
-
const second = ((_c = this.pickDate) == null ? void 0 : _c.getSeconds()) || 0;
|
|
12689
|
-
const { hour: hourDom, minute: minuteDom, second: secondDom } = this.dom.time;
|
|
12690
|
-
const timeDomList = [hourDom, minuteDom, secondDom];
|
|
12691
|
-
timeDomList.forEach((timeDom) => {
|
|
12692
|
-
timeDom.querySelectorAll("li").forEach((li) => li.classList.remove("active"));
|
|
12693
|
-
});
|
|
12694
|
-
const pickList = [
|
|
12695
|
-
[hourDom, hour],
|
|
12696
|
-
[minuteDom, minute],
|
|
12697
|
-
[secondDom, second]
|
|
12698
|
-
];
|
|
12699
|
-
pickList.forEach(([dom, time]) => {
|
|
12700
|
-
const pickDom = dom.querySelector(`[data-id='${time}']`);
|
|
12701
|
-
pickDom.classList.add("active");
|
|
12702
|
-
if (isIntoView) {
|
|
12703
|
-
this._scrollIntoView(dom, pickDom);
|
|
12987
|
+
x += evt.x - startX;
|
|
12988
|
+
y += evt.y - startY;
|
|
12989
|
+
startX = evt.x;
|
|
12990
|
+
startY = evt.y;
|
|
12991
|
+
this._setPreviewerTransform(scaleSize, rotateSize, x, y);
|
|
12992
|
+
};
|
|
12993
|
+
previewerContainer.onmouseup = () => {
|
|
12994
|
+
isAllowDrag = false;
|
|
12995
|
+
previewerContainer.style.cursor = "auto";
|
|
12996
|
+
};
|
|
12997
|
+
previewerContainer.onwheel = (evt) => {
|
|
12998
|
+
evt.preventDefault();
|
|
12999
|
+
if (evt.deltaY < 0) {
|
|
13000
|
+
scaleSize += 0.1;
|
|
13001
|
+
} else {
|
|
13002
|
+
if (scaleSize - 0.1 <= 0.1)
|
|
13003
|
+
return;
|
|
13004
|
+
scaleSize -= 0.1;
|
|
12704
13005
|
}
|
|
12705
|
-
|
|
13006
|
+
this._setPreviewerTransform(scaleSize, rotateSize, x, y);
|
|
13007
|
+
};
|
|
12706
13008
|
}
|
|
12707
|
-
|
|
12708
|
-
if (!
|
|
12709
|
-
container.scrollTop = 0;
|
|
13009
|
+
_setPreviewerTransform(scale, rotate, x, y) {
|
|
13010
|
+
if (!this.previewerImage)
|
|
12710
13011
|
return;
|
|
12711
|
-
}
|
|
12712
|
-
|
|
12713
|
-
|
|
12714
|
-
while (pointer && container !== pointer && container.contains(pointer)) {
|
|
12715
|
-
offsetParents.push(pointer);
|
|
12716
|
-
pointer = pointer.offsetParent;
|
|
12717
|
-
}
|
|
12718
|
-
const top = selected.offsetTop + offsetParents.reduce((prev, curr) => prev + curr.offsetTop, 0);
|
|
12719
|
-
const bottom = top + selected.offsetHeight;
|
|
12720
|
-
const viewRectTop = container.scrollTop;
|
|
12721
|
-
const viewRectBottom = viewRectTop + container.clientHeight;
|
|
12722
|
-
if (top < viewRectTop) {
|
|
12723
|
-
container.scrollTop = top;
|
|
12724
|
-
} else if (bottom > viewRectBottom) {
|
|
12725
|
-
container.scrollTop = bottom - container.clientHeight;
|
|
12726
|
-
}
|
|
12727
|
-
}
|
|
12728
|
-
_preMonth() {
|
|
12729
|
-
this.now.setMonth(this.now.getMonth() - 1);
|
|
12730
|
-
this._update();
|
|
12731
|
-
}
|
|
12732
|
-
_nextMonth() {
|
|
12733
|
-
this.now.setMonth(this.now.getMonth() + 1);
|
|
12734
|
-
this._update();
|
|
12735
|
-
}
|
|
12736
|
-
_preYear() {
|
|
12737
|
-
this.now.setFullYear(this.now.getFullYear() - 1);
|
|
12738
|
-
this._update();
|
|
12739
|
-
}
|
|
12740
|
-
_nextYear() {
|
|
12741
|
-
this.now.setFullYear(this.now.getFullYear() + 1);
|
|
12742
|
-
this._update();
|
|
13012
|
+
this.previewerImage.style.left = `${x}px`;
|
|
13013
|
+
this.previewerImage.style.top = `${y}px`;
|
|
13014
|
+
this.previewerImage.style.transform = `scale(${scale}) rotate(${rotate * 90}deg)`;
|
|
12743
13015
|
}
|
|
12744
|
-
|
|
12745
|
-
|
|
12746
|
-
this.
|
|
13016
|
+
_clearPreviewer() {
|
|
13017
|
+
var _a;
|
|
13018
|
+
(_a = this.previewerContainer) == null ? void 0 : _a.remove();
|
|
13019
|
+
this.previewerContainer = null;
|
|
13020
|
+
document.body.style.overflow = "auto";
|
|
12747
13021
|
}
|
|
12748
|
-
|
|
12749
|
-
|
|
12750
|
-
|
|
12751
|
-
|
|
12752
|
-
|
|
13022
|
+
_updateResizerRect(width, height) {
|
|
13023
|
+
const handleSize = this.options.resizerSize;
|
|
13024
|
+
this.resizerSelection.style.width = `${width}px`;
|
|
13025
|
+
this.resizerSelection.style.height = `${height}px`;
|
|
13026
|
+
for (let i = 0; i < 8; i++) {
|
|
13027
|
+
const left2 = i === 0 || i === 6 || i === 7 ? -handleSize : i === 1 || i === 5 ? width / 2 : width - handleSize;
|
|
13028
|
+
const top = i === 0 || i === 1 || i === 2 ? -handleSize : i === 3 || i === 7 ? height / 2 - handleSize : height - handleSize;
|
|
13029
|
+
this.resizerHandleList[i].style.left = `${left2}px`;
|
|
13030
|
+
this.resizerHandleList[i].style.top = `${top}px`;
|
|
12753
13031
|
}
|
|
12754
13032
|
}
|
|
12755
|
-
|
|
12756
|
-
|
|
12757
|
-
if (this.options.onSubmit && this.pickDate) {
|
|
12758
|
-
const format = (_a = this.renderOptions) == null ? void 0 : _a.element.dateFormat;
|
|
12759
|
-
const pickDateString = this.formatDate(this.pickDate, format);
|
|
12760
|
-
this.options.onSubmit(pickDateString);
|
|
12761
|
-
}
|
|
13033
|
+
_updateResizerSizeView(width, height) {
|
|
13034
|
+
this.resizerSize.innerText = `${Math.round(width)} \xD7 ${Math.round(height)}`;
|
|
12762
13035
|
}
|
|
12763
|
-
|
|
12764
|
-
|
|
12765
|
-
|
|
12766
|
-
"y+": date.getFullYear().toString(),
|
|
12767
|
-
"M+": (date.getMonth() + 1).toString(),
|
|
12768
|
-
"d+": date.getDate().toString(),
|
|
12769
|
-
"h+": date.getHours().toString(),
|
|
12770
|
-
"m+": date.getMinutes().toString(),
|
|
12771
|
-
"s+": date.getSeconds().toString()
|
|
12772
|
-
};
|
|
12773
|
-
for (const k in dateOption) {
|
|
12774
|
-
const reg = new RegExp("(" + k + ")").exec(format);
|
|
12775
|
-
const key = k;
|
|
12776
|
-
if (reg) {
|
|
12777
|
-
dateString = dateString.replace(reg[1], reg[1].length === 1 ? dateOption[key] : dateOption[key].padStart(reg[1].length, "0"));
|
|
12778
|
-
}
|
|
12779
|
-
}
|
|
12780
|
-
return dateString;
|
|
13036
|
+
render() {
|
|
13037
|
+
this._drawPreviewer();
|
|
13038
|
+
document.body.style.overflow = "hidden";
|
|
12781
13039
|
}
|
|
12782
|
-
|
|
12783
|
-
this.
|
|
12784
|
-
|
|
12785
|
-
|
|
12786
|
-
|
|
12787
|
-
}
|
|
12788
|
-
this._setValue();
|
|
12789
|
-
this._update();
|
|
12790
|
-
this._setPosition();
|
|
12791
|
-
this.isDatePicker = true;
|
|
12792
|
-
this._toggleDateTimePicker();
|
|
12793
|
-
this._toggleVisible(true);
|
|
13040
|
+
drawResizer(element, position = null, options = {}) {
|
|
13041
|
+
this.previewerDrawOption = options;
|
|
13042
|
+
this.curElementSrc = element[options.srcKey || "value"] || "";
|
|
13043
|
+
this.updateResizer(element, position);
|
|
13044
|
+
document.addEventListener("keydown", this._keydown);
|
|
12794
13045
|
}
|
|
12795
|
-
|
|
12796
|
-
this.
|
|
13046
|
+
updateResizer(element, position = null) {
|
|
13047
|
+
const { scale } = this.options;
|
|
13048
|
+
const elementWidth = element.width * scale;
|
|
13049
|
+
const elementHeight = element.height * scale;
|
|
13050
|
+
this._updateResizerSizeView(elementWidth, elementHeight);
|
|
13051
|
+
const { x: resizerLeft, y: resizerTop } = this._getElementPosition(element, position);
|
|
13052
|
+
this.resizerSelection.style.left = `${resizerLeft}px`;
|
|
13053
|
+
this.resizerSelection.style.top = `${resizerTop}px`;
|
|
13054
|
+
this._updateResizerRect(elementWidth, elementHeight);
|
|
13055
|
+
this.resizerSelection.style.display = "block";
|
|
13056
|
+
this.curElement = element;
|
|
13057
|
+
this.curPosition = position;
|
|
13058
|
+
this.width = elementWidth;
|
|
13059
|
+
this.height = elementHeight;
|
|
13060
|
+
}
|
|
13061
|
+
clearResizer() {
|
|
13062
|
+
this.resizerSelection.style.display = "none";
|
|
13063
|
+
document.removeEventListener("keydown", this._keydown);
|
|
12797
13064
|
}
|
|
12798
13065
|
}
|
|
12799
13066
|
class DateParticle {
|
|
@@ -12803,31 +13070,8 @@ class DateParticle {
|
|
|
12803
13070
|
__publicField(this, "datePicker");
|
|
12804
13071
|
this.draw = draw;
|
|
12805
13072
|
this.range = draw.getRange();
|
|
12806
|
-
|
|
12807
|
-
|
|
12808
|
-
this.datePicker = new DatePicker({
|
|
12809
|
-
mountDom: draw.getContainer(),
|
|
12810
|
-
onSubmit: this._setValue.bind(this),
|
|
12811
|
-
getLang: () => ({
|
|
12812
|
-
now: t("datePicker.now"),
|
|
12813
|
-
confirm: t("datePicker.confirm"),
|
|
12814
|
-
return: t("datePicker.return"),
|
|
12815
|
-
timeSelect: t("datePicker.timeSelect"),
|
|
12816
|
-
weeks: {
|
|
12817
|
-
sun: t("datePicker.weeks.sun"),
|
|
12818
|
-
mon: t("datePicker.weeks.mon"),
|
|
12819
|
-
tue: t("datePicker.weeks.tue"),
|
|
12820
|
-
wed: t("datePicker.weeks.wed"),
|
|
12821
|
-
thu: t("datePicker.weeks.thu"),
|
|
12822
|
-
fri: t("datePicker.weeks.fri"),
|
|
12823
|
-
sat: t("datePicker.weeks.sat")
|
|
12824
|
-
},
|
|
12825
|
-
year: t("datePicker.year"),
|
|
12826
|
-
month: t("datePicker.month"),
|
|
12827
|
-
hour: t("datePicker.hour"),
|
|
12828
|
-
minute: t("datePicker.minute"),
|
|
12829
|
-
second: t("datePicker.second")
|
|
12830
|
-
})
|
|
13073
|
+
this.datePicker = new DatePicker(draw, {
|
|
13074
|
+
onSubmit: this._setValue.bind(this)
|
|
12831
13075
|
});
|
|
12832
13076
|
}
|
|
12833
13077
|
_setValue(date) {
|
|
@@ -12893,17 +13137,13 @@ class DateParticle {
|
|
|
12893
13137
|
this.datePicker.dispose();
|
|
12894
13138
|
}
|
|
12895
13139
|
renderDatePicker(element, position) {
|
|
12896
|
-
const height = this.draw.getHeight();
|
|
12897
|
-
const pageGap = this.draw.getPageGap();
|
|
12898
|
-
const startTop = this.draw.getPageNo() * (height + pageGap);
|
|
12899
13140
|
const elementList = this.draw.getElementList();
|
|
12900
13141
|
const range = this.getDateElementRange();
|
|
12901
13142
|
const value = range ? elementList.slice(range[0] + 1, range[1] + 1).map((el) => el.value).join("") : "";
|
|
12902
13143
|
this.datePicker.render({
|
|
12903
13144
|
value,
|
|
12904
|
-
element,
|
|
12905
13145
|
position,
|
|
12906
|
-
|
|
13146
|
+
dateFormat: element.dateFormat
|
|
12907
13147
|
});
|
|
12908
13148
|
}
|
|
12909
13149
|
}
|
|
@@ -13066,6 +13306,100 @@ class BlockParticle {
|
|
|
13066
13306
|
});
|
|
13067
13307
|
}
|
|
13068
13308
|
}
|
|
13309
|
+
const contextmenu$1 = {
|
|
13310
|
+
global: {
|
|
13311
|
+
cut: "\u526A\u5207",
|
|
13312
|
+
copy: "\u590D\u5236",
|
|
13313
|
+
paste: "\u7C98\u8D34",
|
|
13314
|
+
selectAll: "\u5168\u9009",
|
|
13315
|
+
print: "\u6253\u5370"
|
|
13316
|
+
},
|
|
13317
|
+
control: {
|
|
13318
|
+
"delete": "\u5220\u9664\u63A7\u4EF6"
|
|
13319
|
+
},
|
|
13320
|
+
hyperlink: {
|
|
13321
|
+
"delete": "\u5220\u9664\u94FE\u63A5",
|
|
13322
|
+
cancel: "\u53D6\u6D88\u94FE\u63A5",
|
|
13323
|
+
edit: "\u7F16\u8F91\u94FE\u63A5"
|
|
13324
|
+
},
|
|
13325
|
+
image: {
|
|
13326
|
+
change: "\u66F4\u6539\u56FE\u7247",
|
|
13327
|
+
saveAs: "\u53E6\u5B58\u4E3A\u56FE\u7247",
|
|
13328
|
+
textWrap: "\u6587\u5B57\u73AF\u7ED5",
|
|
13329
|
+
textWrapType: {
|
|
13330
|
+
embed: "\u5D4C\u5165\u578B",
|
|
13331
|
+
upDown: "\u4E0A\u4E0B\u578B\u73AF\u7ED5",
|
|
13332
|
+
floatTop: "\u6D6E\u4E8E\u6587\u5B57\u4E0A\u65B9",
|
|
13333
|
+
floatBottom: "\u886C\u4E8E\u6587\u5B57\u4E0B\u65B9"
|
|
13334
|
+
}
|
|
13335
|
+
},
|
|
13336
|
+
table: {
|
|
13337
|
+
insertRowCol: "\u63D2\u5165\u884C\u5217",
|
|
13338
|
+
insertTopRow: "\u4E0A\u65B9\u63D2\u51651\u884C",
|
|
13339
|
+
insertBottomRow: "\u4E0B\u65B9\u63D2\u51651\u884C",
|
|
13340
|
+
insertLeftCol: "\u5DE6\u4FA7\u63D2\u51651\u5217",
|
|
13341
|
+
insertRightCol: "\u53F3\u4FA7\u63D2\u51651\u5217",
|
|
13342
|
+
deleteRowCol: "\u5220\u9664\u884C\u5217",
|
|
13343
|
+
deleteRow: "\u5220\u96641\u884C",
|
|
13344
|
+
deleteCol: "\u5220\u96641\u5217",
|
|
13345
|
+
deleteTable: "\u5220\u9664\u6574\u4E2A\u8868\u683C",
|
|
13346
|
+
mergeCell: "\u5408\u5E76\u5355\u5143\u683C",
|
|
13347
|
+
mergeCancelCell: "\u53D6\u6D88\u5408\u5E76",
|
|
13348
|
+
verticalAlign: "\u5782\u76F4\u5BF9\u9F50",
|
|
13349
|
+
verticalAlignTop: "\u9876\u7AEF\u5BF9\u9F50",
|
|
13350
|
+
verticalAlignMiddle: "\u5782\u76F4\u5C45\u4E2D",
|
|
13351
|
+
verticalAlignBottom: "\u5E95\u7AEF\u5BF9\u9F50",
|
|
13352
|
+
border: "\u8868\u683C\u8FB9\u6846",
|
|
13353
|
+
borderAll: "\u6240\u6709\u6846\u7EBF",
|
|
13354
|
+
borderEmpty: "\u65E0\u6846\u7EBF",
|
|
13355
|
+
borderExternal: "\u5916\u4FA7\u6846\u7EBF",
|
|
13356
|
+
borderTd: "\u5355\u5143\u683C\u8FB9\u6846",
|
|
13357
|
+
borderTdTop: "\u4E0A\u8FB9\u6846",
|
|
13358
|
+
borderTdRight: "\u53F3\u8FB9\u6846",
|
|
13359
|
+
borderTdBottom: "\u4E0B\u8FB9\u6846",
|
|
13360
|
+
borderTdLeft: "\u5DE6\u8FB9\u6846",
|
|
13361
|
+
borderTdForward: "\u6B63\u659C\u7EBF",
|
|
13362
|
+
borderTdBack: "\u53CD\u659C\u7EBF"
|
|
13363
|
+
}
|
|
13364
|
+
};
|
|
13365
|
+
const datePicker$1 = {
|
|
13366
|
+
now: "\u6B64\u523B",
|
|
13367
|
+
confirm: "\u786E\u5B9A",
|
|
13368
|
+
"return": "\u8FD4\u56DE\u65E5\u671F",
|
|
13369
|
+
timeSelect: "\u65F6\u95F4\u9009\u62E9",
|
|
13370
|
+
weeks: {
|
|
13371
|
+
sun: "\u65E5",
|
|
13372
|
+
mon: "\u4E00",
|
|
13373
|
+
tue: "\u4E8C",
|
|
13374
|
+
wed: "\u4E09",
|
|
13375
|
+
thu: "\u56DB",
|
|
13376
|
+
fri: "\u4E94",
|
|
13377
|
+
sat: "\u516D"
|
|
13378
|
+
},
|
|
13379
|
+
year: "\u5E74",
|
|
13380
|
+
month: "\u6708",
|
|
13381
|
+
hour: "\u65F6",
|
|
13382
|
+
minute: "\u5206",
|
|
13383
|
+
second: "\u79D2"
|
|
13384
|
+
};
|
|
13385
|
+
const frame$1 = {
|
|
13386
|
+
header: "\u9875\u7709",
|
|
13387
|
+
footer: "\u9875\u811A"
|
|
13388
|
+
};
|
|
13389
|
+
const pageBreak$1 = {
|
|
13390
|
+
displayName: "\u5206\u9875\u7B26"
|
|
13391
|
+
};
|
|
13392
|
+
const zone$1 = {
|
|
13393
|
+
headerTip: "\u53CC\u51FB\u7F16\u8F91\u9875\u7709",
|
|
13394
|
+
footerTip: "\u53CC\u51FB\u7F16\u8F91\u9875\u811A"
|
|
13395
|
+
};
|
|
13396
|
+
var zhCN = {
|
|
13397
|
+
contextmenu: contextmenu$1,
|
|
13398
|
+
datePicker: datePicker$1,
|
|
13399
|
+
frame: frame$1,
|
|
13400
|
+
pageBreak: pageBreak$1,
|
|
13401
|
+
zone: zone$1
|
|
13402
|
+
};
|
|
13069
13403
|
const contextmenu = {
|
|
13070
13404
|
global: {
|
|
13071
13405
|
cut: "Cut",
|
|
@@ -14429,7 +14763,7 @@ class Draw {
|
|
|
14429
14763
|
});
|
|
14430
14764
|
}
|
|
14431
14765
|
spliceElementList(elementList, start, deleteCount, ...items) {
|
|
14432
|
-
var _a, _b;
|
|
14766
|
+
var _a, _b, _c;
|
|
14433
14767
|
if (deleteCount > 0) {
|
|
14434
14768
|
const endIndex = start + deleteCount;
|
|
14435
14769
|
const endElement = elementList[endIndex];
|
|
@@ -14450,7 +14784,7 @@ class Draw {
|
|
|
14450
14784
|
if (!this.control.getActiveControl()) {
|
|
14451
14785
|
let deleteIndex = endIndex - 1;
|
|
14452
14786
|
while (deleteIndex >= start) {
|
|
14453
|
-
if (((_b = elementList[deleteIndex].control) == null ? void 0 :
|
|
14787
|
+
if (((_c = (_b = elementList[deleteIndex]) == null ? void 0 : _b.control) == null ? void 0 : _c.deletable) !== false) {
|
|
14454
14788
|
elementList.splice(deleteIndex, 1);
|
|
14455
14789
|
}
|
|
14456
14790
|
deleteIndex--;
|
|
@@ -15824,6 +16158,7 @@ class Command {
|
|
|
15824
16158
|
__publicField(this, "executeSetControlProperties");
|
|
15825
16159
|
__publicField(this, "executeSetControlHighlight");
|
|
15826
16160
|
__publicField(this, "executeUpdateOptions");
|
|
16161
|
+
__publicField(this, "executeInsertTitle");
|
|
15827
16162
|
__publicField(this, "getCatalog");
|
|
15828
16163
|
__publicField(this, "getImage");
|
|
15829
16164
|
__publicField(this, "getOptions");
|
|
@@ -15930,6 +16265,7 @@ class Command {
|
|
|
15930
16265
|
this.executeLocationGroup = adapt.locationGroup.bind(adapt);
|
|
15931
16266
|
this.executeSetZone = adapt.setZone.bind(adapt);
|
|
15932
16267
|
this.executeUpdateOptions = adapt.updateOptions.bind(adapt);
|
|
16268
|
+
this.executeInsertTitle = adapt.insertTitle.bind(adapt);
|
|
15933
16269
|
this.getImage = adapt.getImage.bind(adapt);
|
|
15934
16270
|
this.getOptions = adapt.getOptions.bind(adapt);
|
|
15935
16271
|
this.getValue = adapt.getValue.bind(adapt);
|
|
@@ -16718,6 +17054,7 @@ class CommandAdapt {
|
|
|
16718
17054
|
} else {
|
|
16719
17055
|
if (el.titleId) {
|
|
16720
17056
|
delete el.titleId;
|
|
17057
|
+
delete el.title;
|
|
16721
17058
|
delete el.level;
|
|
16722
17059
|
delete el.size;
|
|
16723
17060
|
delete el.bold;
|
|
@@ -18331,6 +18668,27 @@ class CommandAdapt {
|
|
|
18331
18668
|
}
|
|
18332
18669
|
return result;
|
|
18333
18670
|
}
|
|
18671
|
+
insertTitle(payload) {
|
|
18672
|
+
var _a;
|
|
18673
|
+
const isReadonly = this.draw.isReadonly();
|
|
18674
|
+
if (isReadonly)
|
|
18675
|
+
return;
|
|
18676
|
+
const cloneElement = deepClone(payload);
|
|
18677
|
+
const { startIndex } = this.range.getRange();
|
|
18678
|
+
const elementList = this.draw.getElementList();
|
|
18679
|
+
const copyElement = getAnchorElement(elementList, startIndex);
|
|
18680
|
+
if (!copyElement)
|
|
18681
|
+
return;
|
|
18682
|
+
const cloneAttr = [
|
|
18683
|
+
...TABLE_CONTEXT_ATTR,
|
|
18684
|
+
...EDITOR_ROW_ATTR,
|
|
18685
|
+
...LIST_CONTEXT_ATTR
|
|
18686
|
+
];
|
|
18687
|
+
(_a = cloneElement.valueList) == null ? void 0 : _a.forEach((valueItem) => {
|
|
18688
|
+
cloneProperty(cloneAttr, copyElement, valueItem);
|
|
18689
|
+
});
|
|
18690
|
+
this.draw.insertElementList([cloneElement]);
|
|
18691
|
+
}
|
|
18334
18692
|
}
|
|
18335
18693
|
class Listener {
|
|
18336
18694
|
constructor() {
|