@hufe921/canvas-editor 0.9.55 → 0.9.57
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 +35 -0
- package/dist/canvas-editor.es.js +374 -185
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +25 -25
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/command/Command.d.ts +4 -0
- package/dist/src/editor/core/command/CommandAdapt.d.ts +7 -3
- package/dist/src/editor/core/draw/control/Control.d.ts +2 -1
- package/dist/src/editor/core/draw/control/checkbox/CheckboxControl.d.ts +2 -2
- package/dist/src/editor/core/draw/control/select/SelectControl.d.ts +3 -3
- package/dist/src/editor/core/draw/control/text/TextControl.d.ts +3 -3
- package/dist/src/editor/core/draw/interactive/Search.d.ts +1 -0
- package/dist/src/editor/core/draw/particle/Separator.d.ts +3 -0
- package/dist/src/editor/core/draw/particle/Subscript.d.ts +1 -0
- package/dist/src/editor/core/draw/particle/Superscript.d.ts +1 -0
- package/dist/src/editor/core/draw/particle/table/TableParticle.d.ts +4 -0
- package/dist/src/editor/core/range/RangeManager.d.ts +1 -0
- package/dist/src/editor/dataset/constant/Cursor.d.ts +1 -1
- package/dist/src/editor/index.d.ts +2 -1
- package/dist/src/editor/interface/Control.d.ts +5 -1
- package/dist/src/editor/interface/Search.d.ts +1 -0
- package/package.json +2 -2
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.57";
|
|
27
27
|
var MaxHeightRatio;
|
|
28
28
|
(function(MaxHeightRatio2) {
|
|
29
29
|
MaxHeightRatio2["HALF"] = "half";
|
|
@@ -300,7 +300,7 @@ function isArrayEqual(arr1, arr2) {
|
|
|
300
300
|
}
|
|
301
301
|
return !arr1.some((item) => !arr2.includes(item));
|
|
302
302
|
}
|
|
303
|
-
const
|
|
303
|
+
const CURSOR_AGENT_OFFSET_HEIGHT = 12;
|
|
304
304
|
const defaultCursorOption = {
|
|
305
305
|
width: 1,
|
|
306
306
|
color: "#000000",
|
|
@@ -3766,7 +3766,6 @@ function formatElementList(elementList, options) {
|
|
|
3766
3766
|
elementList.splice(i, 0, __spreadProps(__spreadValues({}, valueStyleList[valueStyleIndex]), {
|
|
3767
3767
|
controlId,
|
|
3768
3768
|
value: value2,
|
|
3769
|
-
type: el.type,
|
|
3770
3769
|
letterSpacing: isLastLetter ? checkboxOption.gap : 0,
|
|
3771
3770
|
control: el.control,
|
|
3772
3771
|
controlComponent: ControlComponent.VALUE
|
|
@@ -3797,7 +3796,7 @@ function formatElementList(elementList, options) {
|
|
|
3797
3796
|
elementList.splice(i, 0, __spreadProps(__spreadValues({}, element), {
|
|
3798
3797
|
controlId,
|
|
3799
3798
|
value: value2,
|
|
3800
|
-
type:
|
|
3799
|
+
type: element.type || ElementType.TEXT,
|
|
3801
3800
|
control: el.control,
|
|
3802
3801
|
controlComponent: ControlComponent.VALUE
|
|
3803
3802
|
}));
|
|
@@ -4241,11 +4240,14 @@ function createDomFromElementList(elementList, options) {
|
|
|
4241
4240
|
const tab = document.createElement("span");
|
|
4242
4241
|
tab.innerHTML = `${NON_BREAKING_SPACE}${NON_BREAKING_SPACE}`;
|
|
4243
4242
|
clipboardDom.append(tab);
|
|
4243
|
+
} else if (element.type === ElementType.CONTROL) {
|
|
4244
|
+
const controlElement = document.createElement("span");
|
|
4245
|
+
const childDom = buildDom(zipElementList(((_b = element.control) == null ? void 0 : _b.value) || []));
|
|
4246
|
+
controlElement.innerHTML = childDom.innerHTML;
|
|
4247
|
+
clipboardDom.append(controlElement);
|
|
4244
4248
|
} else if (!element.type || element.type === ElementType.LATEX || TEXTLIKE_ELEMENT_TYPE.includes(element.type)) {
|
|
4245
4249
|
let text = "";
|
|
4246
|
-
if (element.
|
|
4247
|
-
text = ((_b = element.control.value) == null ? void 0 : _b.filter((v) => !v.type || TEXTLIKE_ELEMENT_TYPE.includes(v.type)).map((v) => v.value).join("")) || "";
|
|
4248
|
-
} else if (element.type === ElementType.DATE) {
|
|
4250
|
+
if (element.type === ElementType.DATE) {
|
|
4249
4251
|
text = ((_c = element.valueList) == null ? void 0 : _c.map((v) => v.value).join("")) || "";
|
|
4250
4252
|
} else {
|
|
4251
4253
|
text = element.value;
|
|
@@ -4797,8 +4799,9 @@ class Cursor {
|
|
|
4797
4799
|
const zoneManager = this.draw.getZone();
|
|
4798
4800
|
const curPageNo = zoneManager.isMainActive() ? pageNo : this.draw.getPageNo();
|
|
4799
4801
|
const preY = curPageNo * (height + pageGap);
|
|
4800
|
-
const
|
|
4801
|
-
const
|
|
4802
|
+
const defaultOffsetHeight = CURSOR_AGENT_OFFSET_HEIGHT * scale;
|
|
4803
|
+
const increaseHeight = Math.min(metrics.height / 4, defaultOffsetHeight);
|
|
4804
|
+
const cursorHeight = metrics.height + increaseHeight * 2;
|
|
4802
4805
|
const agentCursorDom = this.cursorAgent.getAgentCursorDom();
|
|
4803
4806
|
if (isFocus) {
|
|
4804
4807
|
setTimeout(() => {
|
|
@@ -4807,14 +4810,14 @@ class Cursor {
|
|
|
4807
4810
|
});
|
|
4808
4811
|
}
|
|
4809
4812
|
const descent = metrics.boundingBoxDescent < 0 ? 0 : metrics.boundingBoxDescent;
|
|
4810
|
-
const cursorTop = leftTop[1] + ascent + descent - (cursorHeight -
|
|
4813
|
+
const cursorTop = leftTop[1] + ascent + descent - (cursorHeight - increaseHeight) + preY;
|
|
4811
4814
|
const cursorLeft = hitLineStartIndex ? leftTop[0] : rightTop[0];
|
|
4812
4815
|
agentCursorDom.style.left = `${cursorLeft}px`;
|
|
4813
|
-
agentCursorDom.style.top = `${cursorTop + cursorHeight -
|
|
4816
|
+
agentCursorDom.style.top = `${cursorTop + cursorHeight - defaultOffsetHeight}px`;
|
|
4814
4817
|
if (!isShow)
|
|
4815
4818
|
return;
|
|
4816
4819
|
const isReadonly = this.draw.isReadonly();
|
|
4817
|
-
this.cursorDom.style.width = `${width}px`;
|
|
4820
|
+
this.cursorDom.style.width = `${width * scale}px`;
|
|
4818
4821
|
this.cursorDom.style.backgroundColor = color;
|
|
4819
4822
|
this.cursorDom.style.left = `${cursorLeft}px`;
|
|
4820
4823
|
this.cursorDom.style.top = `${cursorTop}px`;
|
|
@@ -5006,12 +5009,14 @@ class CheckboxControl {
|
|
|
5006
5009
|
setValue() {
|
|
5007
5010
|
return -1;
|
|
5008
5011
|
}
|
|
5009
|
-
setSelect(context = {}) {
|
|
5012
|
+
setSelect(codes, context = {}, options = {}) {
|
|
5013
|
+
if (!options.isIgnoreDisabledRule && this.control.isDisabledControl()) {
|
|
5014
|
+
return;
|
|
5015
|
+
}
|
|
5010
5016
|
const { control } = this.element;
|
|
5011
5017
|
const elementList = context.elementList || this.control.getElementList();
|
|
5012
5018
|
const { startIndex } = context.range || this.control.getRange();
|
|
5013
5019
|
const startElement = elementList[startIndex];
|
|
5014
|
-
const data2 = [];
|
|
5015
5020
|
let preIndex = startIndex;
|
|
5016
5021
|
while (preIndex > 0) {
|
|
5017
5022
|
const preElement = elementList[preIndex];
|
|
@@ -5020,9 +5025,7 @@ class CheckboxControl {
|
|
|
5020
5025
|
}
|
|
5021
5026
|
if (preElement.controlComponent === ControlComponent.CHECKBOX) {
|
|
5022
5027
|
const checkbox = preElement.checkbox;
|
|
5023
|
-
|
|
5024
|
-
data2.unshift(checkbox.code);
|
|
5025
|
-
}
|
|
5028
|
+
checkbox.value = codes.includes(checkbox.code);
|
|
5026
5029
|
}
|
|
5027
5030
|
preIndex--;
|
|
5028
5031
|
}
|
|
@@ -5034,15 +5037,17 @@ class CheckboxControl {
|
|
|
5034
5037
|
}
|
|
5035
5038
|
if (nextElement.controlComponent === ControlComponent.CHECKBOX) {
|
|
5036
5039
|
const checkbox = nextElement.checkbox;
|
|
5037
|
-
|
|
5038
|
-
data2.push(checkbox.code);
|
|
5039
|
-
}
|
|
5040
|
+
checkbox.value = codes.includes(checkbox.code);
|
|
5040
5041
|
}
|
|
5041
5042
|
nextIndex++;
|
|
5042
5043
|
}
|
|
5043
|
-
control.code =
|
|
5044
|
+
control.code = codes.join(",");
|
|
5045
|
+
this.control.repaintControl();
|
|
5044
5046
|
}
|
|
5045
5047
|
keydown(evt) {
|
|
5048
|
+
if (this.control.isDisabledControl()) {
|
|
5049
|
+
return null;
|
|
5050
|
+
}
|
|
5046
5051
|
const range = this.control.getRange();
|
|
5047
5052
|
this.control.shrinkBoundary();
|
|
5048
5053
|
const { startIndex, endIndex } = range;
|
|
@@ -5056,6 +5061,7 @@ class CheckboxControl {
|
|
|
5056
5061
|
}
|
|
5057
5062
|
}
|
|
5058
5063
|
function mousedown(evt, host) {
|
|
5064
|
+
var _a;
|
|
5059
5065
|
if (evt.button === MouseEventButton.RIGHT)
|
|
5060
5066
|
return;
|
|
5061
5067
|
const draw = host.getDraw();
|
|
@@ -5102,26 +5108,28 @@ function mousedown(evt, host) {
|
|
|
5102
5108
|
position.setCursorPosition(positionList[curIndex]);
|
|
5103
5109
|
const isSetCheckbox = isDirectHitCheckbox && !isReadonly;
|
|
5104
5110
|
if (isSetCheckbox) {
|
|
5105
|
-
const { checkbox } = curElement;
|
|
5106
|
-
|
|
5107
|
-
|
|
5111
|
+
const { checkbox, control } = curElement;
|
|
5112
|
+
const codes = ((_a = control == null ? void 0 : control.code) == null ? void 0 : _a.split(",")) || [];
|
|
5113
|
+
if (checkbox == null ? void 0 : checkbox.value) {
|
|
5114
|
+
const codeIndex = codes.findIndex((c) => c === checkbox.code);
|
|
5115
|
+
codes.splice(codeIndex, 1);
|
|
5108
5116
|
} else {
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
}
|
|
5117
|
+
if (checkbox == null ? void 0 : checkbox.code) {
|
|
5118
|
+
codes.push(checkbox.code);
|
|
5119
|
+
}
|
|
5112
5120
|
}
|
|
5113
|
-
const
|
|
5114
|
-
const activeControl = control.getActiveControl();
|
|
5121
|
+
const activeControl = draw.getControl().getActiveControl();
|
|
5115
5122
|
if (activeControl instanceof CheckboxControl) {
|
|
5116
|
-
activeControl.setSelect();
|
|
5123
|
+
activeControl.setSelect(codes);
|
|
5117
5124
|
}
|
|
5125
|
+
} else {
|
|
5126
|
+
draw.render({
|
|
5127
|
+
curIndex,
|
|
5128
|
+
isCompute: false,
|
|
5129
|
+
isSubmitHistory: false,
|
|
5130
|
+
isSetCursor: !isDirectHitImage && !isDirectHitCheckbox
|
|
5131
|
+
});
|
|
5118
5132
|
}
|
|
5119
|
-
draw.render({
|
|
5120
|
-
curIndex,
|
|
5121
|
-
isSubmitHistory: isSetCheckbox,
|
|
5122
|
-
isSetCursor: !isDirectHitImage && !isDirectHitCheckbox,
|
|
5123
|
-
isCompute: false
|
|
5124
|
-
});
|
|
5125
5133
|
if (hitLineStartIndex) {
|
|
5126
5134
|
host.getDraw().getCursor().drawCursor({
|
|
5127
5135
|
hitLineStartIndex
|
|
@@ -5716,7 +5724,6 @@ function input(data2, host) {
|
|
|
5716
5724
|
const cursor = draw.getCursor();
|
|
5717
5725
|
cursor.clearAgentDomValue();
|
|
5718
5726
|
}
|
|
5719
|
-
const activeControl = control.getActiveControl();
|
|
5720
5727
|
const { TEXT, HYPERLINK, SUBSCRIPT, SUPERSCRIPT, DATE } = ElementType;
|
|
5721
5728
|
const text = data2.replaceAll(`
|
|
5722
5729
|
`, ZERO);
|
|
@@ -5747,7 +5754,7 @@ function input(data2, host) {
|
|
|
5747
5754
|
return newElement;
|
|
5748
5755
|
});
|
|
5749
5756
|
let curIndex;
|
|
5750
|
-
if (
|
|
5757
|
+
if (control.getActiveControl() && !control.isRangInPostfix()) {
|
|
5751
5758
|
curIndex = control.setValue(inputData);
|
|
5752
5759
|
} else {
|
|
5753
5760
|
const start = startIndex + 1;
|
|
@@ -6148,7 +6155,7 @@ class CanvasEvent {
|
|
|
6148
6155
|
mousedown(evt, this);
|
|
6149
6156
|
}
|
|
6150
6157
|
click() {
|
|
6151
|
-
if (isIOS) {
|
|
6158
|
+
if (isIOS && !this.draw.isReadonly()) {
|
|
6152
6159
|
this.draw.getCursor().getAgentDom().focus();
|
|
6153
6160
|
}
|
|
6154
6161
|
}
|
|
@@ -6988,6 +6995,35 @@ class RangeManager {
|
|
|
6988
6995
|
}
|
|
6989
6996
|
return false;
|
|
6990
6997
|
}
|
|
6998
|
+
getKeywordRangeList(payload) {
|
|
6999
|
+
const searchMatchList = this.draw.getSearch().getMatchList(payload);
|
|
7000
|
+
const searchRangeMap = new Map();
|
|
7001
|
+
for (const searchMatch of searchMatchList) {
|
|
7002
|
+
const searchRange = searchRangeMap.get(searchMatch.groupId);
|
|
7003
|
+
if (searchRange) {
|
|
7004
|
+
searchRange.endIndex += 1;
|
|
7005
|
+
} else {
|
|
7006
|
+
const { type, groupId, tableId, index: index2, tdIndex, trIndex } = searchMatch;
|
|
7007
|
+
const range = {
|
|
7008
|
+
startIndex: index2 - 1,
|
|
7009
|
+
endIndex: index2
|
|
7010
|
+
};
|
|
7011
|
+
if (type === EditorContext.TABLE) {
|
|
7012
|
+
range.tableId = tableId;
|
|
7013
|
+
range.startTdIndex = tdIndex;
|
|
7014
|
+
range.endTdIndex = tdIndex;
|
|
7015
|
+
range.startTrIndex = trIndex;
|
|
7016
|
+
range.endTrIndex = trIndex;
|
|
7017
|
+
}
|
|
7018
|
+
searchRangeMap.set(groupId, range);
|
|
7019
|
+
}
|
|
7020
|
+
}
|
|
7021
|
+
const rangeList = [];
|
|
7022
|
+
searchRangeMap.forEach((searchRange) => {
|
|
7023
|
+
rangeList.push(searchRange);
|
|
7024
|
+
});
|
|
7025
|
+
return rangeList;
|
|
7026
|
+
}
|
|
6991
7027
|
setRange(startIndex, endIndex, tableId, startTdIndex, endTdIndex, startTrIndex, endTrIndex) {
|
|
6992
7028
|
this.range.startIndex = startIndex;
|
|
6993
7029
|
this.range.endIndex = endIndex;
|
|
@@ -7431,7 +7467,7 @@ class Search {
|
|
|
7431
7467
|
count
|
|
7432
7468
|
};
|
|
7433
7469
|
}
|
|
7434
|
-
|
|
7470
|
+
getMatchList(payload) {
|
|
7435
7471
|
const keyword = payload.toLocaleLowerCase();
|
|
7436
7472
|
const searchMatchList = [];
|
|
7437
7473
|
const elementListGroup = [];
|
|
@@ -7499,6 +7535,7 @@ class Search {
|
|
|
7499
7535
|
for (let d = 0; d < tr.tdList.length; d++) {
|
|
7500
7536
|
const td = tr.tdList[d];
|
|
7501
7537
|
const restArgs = {
|
|
7538
|
+
tableId: tableElement.id,
|
|
7502
7539
|
tableIndex: group2.index,
|
|
7503
7540
|
trIndex: t,
|
|
7504
7541
|
tdIndex: d,
|
|
@@ -7513,7 +7550,10 @@ class Search {
|
|
|
7513
7550
|
});
|
|
7514
7551
|
}
|
|
7515
7552
|
}
|
|
7516
|
-
|
|
7553
|
+
return searchMatchList;
|
|
7554
|
+
}
|
|
7555
|
+
compute(payload) {
|
|
7556
|
+
this.searchMatchList = this.getMatchList(payload);
|
|
7517
7557
|
}
|
|
7518
7558
|
render(ctx, pageIndex) {
|
|
7519
7559
|
var _a, _b;
|
|
@@ -7923,6 +7963,7 @@ class TableParticle {
|
|
|
7923
7963
|
this.options = draw.getOptions();
|
|
7924
7964
|
}
|
|
7925
7965
|
getTrListGroupByCol(payload) {
|
|
7966
|
+
var _a;
|
|
7926
7967
|
const trList = deepClone(payload);
|
|
7927
7968
|
for (let t = 0; t < payload.length; t++) {
|
|
7928
7969
|
const tr = trList[t];
|
|
@@ -7932,7 +7973,7 @@ class TableParticle {
|
|
|
7932
7973
|
const curRowIndex = rowIndex + rowspan - 1;
|
|
7933
7974
|
if (curRowIndex !== d) {
|
|
7934
7975
|
const changeTd = tr.tdList.splice(d, 1)[0];
|
|
7935
|
-
trList[curRowIndex].tdList.splice(colIndex, 0, changeTd);
|
|
7976
|
+
(_a = trList[curRowIndex]) == null ? void 0 : _a.tdList.splice(colIndex, 0, changeTd);
|
|
7936
7977
|
}
|
|
7937
7978
|
}
|
|
7938
7979
|
}
|
|
@@ -8019,6 +8060,7 @@ class TableParticle {
|
|
|
8019
8060
|
const isEmptyBorderType = borderType === TableBorder.EMPTY;
|
|
8020
8061
|
const isExternalBorderType = borderType === TableBorder.EXTERNAL;
|
|
8021
8062
|
ctx.save();
|
|
8063
|
+
ctx.lineWidth = scale;
|
|
8022
8064
|
if (!isEmptyBorderType) {
|
|
8023
8065
|
this._drawOuterBorder({
|
|
8024
8066
|
ctx,
|
|
@@ -8084,6 +8126,33 @@ class TableParticle {
|
|
|
8084
8126
|
}
|
|
8085
8127
|
}
|
|
8086
8128
|
}
|
|
8129
|
+
getTableWidth(element) {
|
|
8130
|
+
return element.colgroup.reduce((pre, cur) => pre + cur.width, 0);
|
|
8131
|
+
}
|
|
8132
|
+
getTableHeight(element) {
|
|
8133
|
+
const trList = element.trList;
|
|
8134
|
+
if (!(trList == null ? void 0 : trList.length))
|
|
8135
|
+
return 0;
|
|
8136
|
+
return this.getTdListByColIndex(trList, 0).reduce((pre, cur) => pre + cur.height, 0);
|
|
8137
|
+
}
|
|
8138
|
+
getRowCountByColIndex(trList, colIndex) {
|
|
8139
|
+
return this.getTdListByColIndex(trList, colIndex).reduce((pre, cur) => pre + cur.rowspan, 0);
|
|
8140
|
+
}
|
|
8141
|
+
getTdListByColIndex(trList, colIndex) {
|
|
8142
|
+
const data2 = [];
|
|
8143
|
+
for (let r = 0; r < trList.length; r++) {
|
|
8144
|
+
const tdList = trList[r].tdList;
|
|
8145
|
+
for (let d = 0; d < tdList.length; d++) {
|
|
8146
|
+
const td = tdList[d];
|
|
8147
|
+
const min = td.colIndex;
|
|
8148
|
+
const max = min + td.colspan - 1;
|
|
8149
|
+
if (colIndex >= min && colIndex <= max) {
|
|
8150
|
+
data2.push(td);
|
|
8151
|
+
}
|
|
8152
|
+
}
|
|
8153
|
+
}
|
|
8154
|
+
return data2;
|
|
8155
|
+
}
|
|
8087
8156
|
computeRowColInfo(element) {
|
|
8088
8157
|
const { colgroup, trList } = element;
|
|
8089
8158
|
if (!colgroup || !trList)
|
|
@@ -8096,42 +8165,27 @@ class TableParticle {
|
|
|
8096
8165
|
let rowMinHeight = 0;
|
|
8097
8166
|
for (let d = 0; d < tr.tdList.length; d++) {
|
|
8098
8167
|
const td = tr.tdList[d];
|
|
8099
|
-
let
|
|
8168
|
+
let colIndex = 0;
|
|
8100
8169
|
if (trList.length > 1 && t !== 0) {
|
|
8101
|
-
|
|
8102
|
-
|
|
8103
|
-
|
|
8104
|
-
|
|
8105
|
-
|
|
8106
|
-
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
continue;
|
|
8111
|
-
if (pTdX > x)
|
|
8112
|
-
break;
|
|
8113
|
-
if (pTdX === x && pTdY + pTdHeight > y) {
|
|
8114
|
-
const nextPTd = pTr.tdList[pD + 1];
|
|
8115
|
-
if (nextPTd && pTd.colIndex + pTd.colspan !== nextPTd.colIndex) {
|
|
8116
|
-
x = nextPTd.x;
|
|
8117
|
-
offsetXIndex = nextPTd.colIndex;
|
|
8118
|
-
} else {
|
|
8119
|
-
x += pTdWidth;
|
|
8120
|
-
offsetXIndex += pTd.colspan;
|
|
8121
|
-
}
|
|
8170
|
+
const preTd = tr.tdList[d - 1];
|
|
8171
|
+
const start = preTd ? preTd.colIndex + preTd.colspan : d;
|
|
8172
|
+
for (let c = start; c < colgroup.length; c++) {
|
|
8173
|
+
const rowCount = this.getRowCountByColIndex(trList.slice(0, t), c);
|
|
8174
|
+
if (rowCount === t) {
|
|
8175
|
+
colIndex = c;
|
|
8176
|
+
let preColWidth = 0;
|
|
8177
|
+
for (let preC = 0; preC < c; preC++) {
|
|
8178
|
+
preColWidth += colgroup[preC].width;
|
|
8122
8179
|
}
|
|
8180
|
+
x = preColWidth;
|
|
8181
|
+
break;
|
|
8123
8182
|
}
|
|
8124
8183
|
}
|
|
8125
|
-
}
|
|
8126
|
-
let colIndex = 0;
|
|
8127
|
-
const preTd = tr.tdList[d - 1];
|
|
8128
|
-
if (preTd) {
|
|
8129
|
-
colIndex = preTd.colIndex + offsetXIndex + 1;
|
|
8130
|
-
if (preTd.colspan > 1) {
|
|
8131
|
-
colIndex += preTd.colspan - 1;
|
|
8132
|
-
}
|
|
8133
8184
|
} else {
|
|
8134
|
-
|
|
8185
|
+
const preTd = tr.tdList[d - 1];
|
|
8186
|
+
if (preTd) {
|
|
8187
|
+
colIndex = preTd.colIndex + preTd.colspan;
|
|
8188
|
+
}
|
|
8135
8189
|
}
|
|
8136
8190
|
let width = 0;
|
|
8137
8191
|
for (let col = 0; col < td.colspan; col++) {
|
|
@@ -8139,7 +8193,8 @@ class TableParticle {
|
|
|
8139
8193
|
}
|
|
8140
8194
|
let height = 0;
|
|
8141
8195
|
for (let row = 0; row < td.rowspan; row++) {
|
|
8142
|
-
|
|
8196
|
+
const curTr = trList[row + t] || trList[t];
|
|
8197
|
+
height += curTr.height;
|
|
8143
8198
|
}
|
|
8144
8199
|
if (rowMinHeight === 0 || rowMinHeight > height) {
|
|
8145
8200
|
rowMinHeight = height;
|
|
@@ -8427,7 +8482,8 @@ class TableTool {
|
|
|
8427
8482
|
var _a;
|
|
8428
8483
|
let isChangeSize = false;
|
|
8429
8484
|
if (order === TableOrder.ROW) {
|
|
8430
|
-
const
|
|
8485
|
+
const trList = element.trList;
|
|
8486
|
+
const tr = trList[index2] || trList[index2 - 1];
|
|
8431
8487
|
const { defaultTrMinHeight } = this.options;
|
|
8432
8488
|
if (dy < 0 && tr.height + dy < defaultTrMinHeight) {
|
|
8433
8489
|
dy = defaultTrMinHeight - tr.height;
|
|
@@ -8671,30 +8727,41 @@ class Header {
|
|
|
8671
8727
|
}
|
|
8672
8728
|
}
|
|
8673
8729
|
class SuperscriptParticle {
|
|
8730
|
+
getOffsetY(element) {
|
|
8731
|
+
return -element.metrics.height / 2;
|
|
8732
|
+
}
|
|
8674
8733
|
render(ctx, element, x, y) {
|
|
8675
8734
|
ctx.save();
|
|
8676
8735
|
ctx.font = element.style;
|
|
8677
8736
|
if (element.color) {
|
|
8678
8737
|
ctx.fillStyle = element.color;
|
|
8679
8738
|
}
|
|
8680
|
-
ctx.fillText(element.value, x, y
|
|
8739
|
+
ctx.fillText(element.value, x, y + this.getOffsetY(element));
|
|
8681
8740
|
ctx.restore();
|
|
8682
8741
|
}
|
|
8683
8742
|
}
|
|
8684
8743
|
class SubscriptParticle {
|
|
8744
|
+
getOffsetY(element) {
|
|
8745
|
+
return element.metrics.height / 2;
|
|
8746
|
+
}
|
|
8685
8747
|
render(ctx, element, x, y) {
|
|
8686
8748
|
ctx.save();
|
|
8687
8749
|
ctx.font = element.style;
|
|
8688
8750
|
if (element.color) {
|
|
8689
8751
|
ctx.fillStyle = element.color;
|
|
8690
8752
|
}
|
|
8691
|
-
ctx.fillText(element.value, x, y + element
|
|
8753
|
+
ctx.fillText(element.value, x, y + this.getOffsetY(element));
|
|
8692
8754
|
ctx.restore();
|
|
8693
8755
|
}
|
|
8694
8756
|
}
|
|
8695
8757
|
class SeparatorParticle {
|
|
8758
|
+
constructor(draw) {
|
|
8759
|
+
__publicField(this, "options");
|
|
8760
|
+
this.options = draw.getOptions();
|
|
8761
|
+
}
|
|
8696
8762
|
render(ctx, element, x, y) {
|
|
8697
8763
|
ctx.save();
|
|
8764
|
+
ctx.lineWidth = this.options.scale;
|
|
8698
8765
|
if (element.color) {
|
|
8699
8766
|
ctx.strokeStyle = element.color;
|
|
8700
8767
|
}
|
|
@@ -8816,6 +8883,9 @@ class SelectControl {
|
|
|
8816
8883
|
return -1;
|
|
8817
8884
|
}
|
|
8818
8885
|
keydown(evt) {
|
|
8886
|
+
if (this.control.isDisabledControl()) {
|
|
8887
|
+
return null;
|
|
8888
|
+
}
|
|
8819
8889
|
const elementList = this.control.getElementList();
|
|
8820
8890
|
const range = this.control.getRange();
|
|
8821
8891
|
this.control.shrinkBoundary();
|
|
@@ -8847,6 +8917,9 @@ class SelectControl {
|
|
|
8847
8917
|
return endIndex;
|
|
8848
8918
|
}
|
|
8849
8919
|
cut() {
|
|
8920
|
+
if (this.control.isDisabledControl()) {
|
|
8921
|
+
return -1;
|
|
8922
|
+
}
|
|
8850
8923
|
this.control.shrinkBoundary();
|
|
8851
8924
|
const { startIndex, endIndex } = this.control.getRange();
|
|
8852
8925
|
if (startIndex === endIndex) {
|
|
@@ -8854,7 +8927,10 @@ class SelectControl {
|
|
|
8854
8927
|
}
|
|
8855
8928
|
return this.clearSelect();
|
|
8856
8929
|
}
|
|
8857
|
-
clearSelect(context = {}) {
|
|
8930
|
+
clearSelect(context = {}, options = {}) {
|
|
8931
|
+
if (!options.isIgnoreDisabledRule && this.control.isDisabledControl()) {
|
|
8932
|
+
return -1;
|
|
8933
|
+
}
|
|
8858
8934
|
const elementList = context.elementList || this.control.getElementList();
|
|
8859
8935
|
const { startIndex } = context.range || this.control.getRange();
|
|
8860
8936
|
const startElement = elementList[startIndex];
|
|
@@ -8886,7 +8962,10 @@ class SelectControl {
|
|
|
8886
8962
|
this.element.control.code = null;
|
|
8887
8963
|
return preIndex;
|
|
8888
8964
|
}
|
|
8889
|
-
setSelect(code, context = {}) {
|
|
8965
|
+
setSelect(code, context = {}, options = {}) {
|
|
8966
|
+
if (!options.isIgnoreDisabledRule && this.control.isDisabledControl()) {
|
|
8967
|
+
return;
|
|
8968
|
+
}
|
|
8890
8969
|
const control = this.element.control;
|
|
8891
8970
|
const valueSets = control.valueSets;
|
|
8892
8971
|
if (!Array.isArray(valueSets) || !valueSets.length)
|
|
@@ -8897,6 +8976,8 @@ class SelectControl {
|
|
|
8897
8976
|
const elementList = context.elementList || this.control.getElementList();
|
|
8898
8977
|
const styleElement = pickObject(this.getValue(context)[0], EDITOR_ELEMENT_STYLE_ATTR);
|
|
8899
8978
|
const prefixIndex = this.clearSelect(context);
|
|
8979
|
+
if (!~prefixIndex)
|
|
8980
|
+
return;
|
|
8900
8981
|
this.control.removePlaceholder(prefixIndex, context);
|
|
8901
8982
|
const propertyElement = omitObject(elementList[prefixIndex], EDITOR_ELEMENT_STYLE_ATTR);
|
|
8902
8983
|
const start = prefixIndex + 1;
|
|
@@ -8904,6 +8985,7 @@ class SelectControl {
|
|
|
8904
8985
|
const draw = this.control.getDraw();
|
|
8905
8986
|
for (let i = 0; i < data2.length; i++) {
|
|
8906
8987
|
const newElement = __spreadProps(__spreadValues(__spreadValues({}, styleElement), propertyElement), {
|
|
8988
|
+
type: ElementType.TEXT,
|
|
8907
8989
|
value: data2[i],
|
|
8908
8990
|
controlComponent: ControlComponent.VALUE
|
|
8909
8991
|
});
|
|
@@ -8953,7 +9035,7 @@ class SelectControl {
|
|
|
8953
9035
|
}
|
|
8954
9036
|
awake() {
|
|
8955
9037
|
var _a;
|
|
8956
|
-
if (this.isPopup)
|
|
9038
|
+
if (this.isPopup || this.control.isDisabledControl())
|
|
8957
9039
|
return;
|
|
8958
9040
|
const { startIndex } = this.control.getRange();
|
|
8959
9041
|
const elementList = this.control.getElementList();
|
|
@@ -9010,7 +9092,10 @@ class TextControl {
|
|
|
9010
9092
|
}
|
|
9011
9093
|
return data2;
|
|
9012
9094
|
}
|
|
9013
|
-
setValue(data2, context = {}) {
|
|
9095
|
+
setValue(data2, context = {}, options = {}) {
|
|
9096
|
+
if (!options.isIgnoreDisabledRule && this.control.isDisabledControl()) {
|
|
9097
|
+
return -1;
|
|
9098
|
+
}
|
|
9014
9099
|
const elementList = context.elementList || this.control.getElementList();
|
|
9015
9100
|
const range = context.range || this.control.getRange();
|
|
9016
9101
|
this.control.shrinkBoundary();
|
|
@@ -9033,7 +9118,10 @@ class TextControl {
|
|
|
9033
9118
|
}
|
|
9034
9119
|
return start + data2.length - 1;
|
|
9035
9120
|
}
|
|
9036
|
-
clearValue(context = {}) {
|
|
9121
|
+
clearValue(context = {}, options = {}) {
|
|
9122
|
+
if (!options.isIgnoreDisabledRule && this.control.isDisabledControl()) {
|
|
9123
|
+
return -1;
|
|
9124
|
+
}
|
|
9037
9125
|
const elementList = context.elementList || this.control.getElementList();
|
|
9038
9126
|
const range = context.range || this.control.getRange();
|
|
9039
9127
|
const { startIndex, endIndex } = range;
|
|
@@ -9045,6 +9133,9 @@ class TextControl {
|
|
|
9045
9133
|
return startIndex;
|
|
9046
9134
|
}
|
|
9047
9135
|
keydown(evt) {
|
|
9136
|
+
if (this.control.isDisabledControl()) {
|
|
9137
|
+
return null;
|
|
9138
|
+
}
|
|
9048
9139
|
const elementList = this.control.getElementList();
|
|
9049
9140
|
const range = this.control.getRange();
|
|
9050
9141
|
this.control.shrinkBoundary();
|
|
@@ -9097,6 +9188,9 @@ class TextControl {
|
|
|
9097
9188
|
return endIndex;
|
|
9098
9189
|
}
|
|
9099
9190
|
cut() {
|
|
9191
|
+
if (this.control.isDisabledControl()) {
|
|
9192
|
+
return -1;
|
|
9193
|
+
}
|
|
9100
9194
|
this.control.shrinkBoundary();
|
|
9101
9195
|
const { startIndex, endIndex } = this.control.getRange();
|
|
9102
9196
|
if (startIndex === endIndex) {
|
|
@@ -9183,6 +9277,10 @@ class Control {
|
|
|
9183
9277
|
}
|
|
9184
9278
|
return false;
|
|
9185
9279
|
}
|
|
9280
|
+
isDisabledControl() {
|
|
9281
|
+
var _a, _b;
|
|
9282
|
+
return !!((_b = (_a = this.activeControl) == null ? void 0 : _a.getElement().control) == null ? void 0 : _b.disabled);
|
|
9283
|
+
}
|
|
9186
9284
|
getContainer() {
|
|
9187
9285
|
return this.draw.getContainer();
|
|
9188
9286
|
}
|
|
@@ -9276,10 +9374,17 @@ class Control {
|
|
|
9276
9374
|
}
|
|
9277
9375
|
}
|
|
9278
9376
|
repaintControl(curIndex) {
|
|
9279
|
-
|
|
9280
|
-
|
|
9281
|
-
|
|
9282
|
-
|
|
9377
|
+
if (curIndex === void 0) {
|
|
9378
|
+
this.range.clearRange();
|
|
9379
|
+
this.draw.render({
|
|
9380
|
+
isSetCursor: false
|
|
9381
|
+
});
|
|
9382
|
+
} else {
|
|
9383
|
+
this.range.setRange(curIndex, curIndex);
|
|
9384
|
+
this.draw.render({
|
|
9385
|
+
curIndex
|
|
9386
|
+
});
|
|
9387
|
+
}
|
|
9283
9388
|
}
|
|
9284
9389
|
moveCursor(position) {
|
|
9285
9390
|
const { index: index2, trIndex, tdIndex, tdValueIndex } = position;
|
|
@@ -9432,49 +9537,62 @@ class Control {
|
|
|
9432
9537
|
return this.activeControl.cut();
|
|
9433
9538
|
}
|
|
9434
9539
|
getValueByConceptId(payload) {
|
|
9435
|
-
var _a;
|
|
9436
9540
|
const { conceptId } = payload;
|
|
9541
|
+
const result = [];
|
|
9542
|
+
const getValue = (elementList2) => {
|
|
9543
|
+
var _a;
|
|
9544
|
+
let i = 0;
|
|
9545
|
+
while (i < elementList2.length) {
|
|
9546
|
+
const element = elementList2[i];
|
|
9547
|
+
i++;
|
|
9548
|
+
if (element.type === ElementType.TABLE) {
|
|
9549
|
+
const trList = element.trList;
|
|
9550
|
+
for (let r = 0; r < trList.length; r++) {
|
|
9551
|
+
const tr = trList[r];
|
|
9552
|
+
for (let d = 0; d < tr.tdList.length; d++) {
|
|
9553
|
+
const td = tr.tdList[d];
|
|
9554
|
+
getValue(td.value);
|
|
9555
|
+
}
|
|
9556
|
+
}
|
|
9557
|
+
}
|
|
9558
|
+
if (((_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId) !== conceptId)
|
|
9559
|
+
continue;
|
|
9560
|
+
const { type, code, valueSets } = element.control;
|
|
9561
|
+
let j = i;
|
|
9562
|
+
let textControlValue = "";
|
|
9563
|
+
while (j < elementList2.length) {
|
|
9564
|
+
const nextElement = elementList2[j];
|
|
9565
|
+
if (nextElement.controlId !== element.controlId)
|
|
9566
|
+
break;
|
|
9567
|
+
if (type === ControlType.TEXT && nextElement.controlComponent === ControlComponent.VALUE) {
|
|
9568
|
+
textControlValue += nextElement.value;
|
|
9569
|
+
}
|
|
9570
|
+
j++;
|
|
9571
|
+
}
|
|
9572
|
+
if (type === ControlType.TEXT) {
|
|
9573
|
+
result.push(__spreadProps(__spreadValues({}, element.control), {
|
|
9574
|
+
value: textControlValue || null,
|
|
9575
|
+
innerText: textControlValue || null
|
|
9576
|
+
}));
|
|
9577
|
+
} else if (type === ControlType.SELECT || type === ControlType.CHECKBOX) {
|
|
9578
|
+
const innerText = code == null ? void 0 : code.split(",").map((selectCode) => {
|
|
9579
|
+
var _a2;
|
|
9580
|
+
return (_a2 = valueSets == null ? void 0 : valueSets.find((valueSet) => valueSet.code === selectCode)) == null ? void 0 : _a2.value;
|
|
9581
|
+
}).filter(Boolean).join("");
|
|
9582
|
+
result.push(__spreadProps(__spreadValues({}, element.control), {
|
|
9583
|
+
value: code || null,
|
|
9584
|
+
innerText: innerText || null
|
|
9585
|
+
}));
|
|
9586
|
+
}
|
|
9587
|
+
i = j;
|
|
9588
|
+
}
|
|
9589
|
+
};
|
|
9437
9590
|
const elementList = [
|
|
9438
9591
|
...this.draw.getHeaderElementList(),
|
|
9439
9592
|
...this.draw.getOriginalMainElementList(),
|
|
9440
9593
|
...this.draw.getFooterElementList()
|
|
9441
9594
|
];
|
|
9442
|
-
|
|
9443
|
-
let i = 0;
|
|
9444
|
-
while (i < elementList.length) {
|
|
9445
|
-
const element = elementList[i];
|
|
9446
|
-
i++;
|
|
9447
|
-
if (((_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId) !== conceptId)
|
|
9448
|
-
continue;
|
|
9449
|
-
const { type, code, valueSets } = element.control;
|
|
9450
|
-
let j = i;
|
|
9451
|
-
let textControlValue = "";
|
|
9452
|
-
while (j < elementList.length) {
|
|
9453
|
-
const nextElement = elementList[j];
|
|
9454
|
-
if (nextElement.controlId !== element.controlId)
|
|
9455
|
-
break;
|
|
9456
|
-
if (type === ControlType.TEXT && nextElement.controlComponent === ControlComponent.VALUE) {
|
|
9457
|
-
textControlValue += nextElement.value;
|
|
9458
|
-
}
|
|
9459
|
-
j++;
|
|
9460
|
-
}
|
|
9461
|
-
if (type === ControlType.TEXT) {
|
|
9462
|
-
result.push(__spreadProps(__spreadValues({}, element.control), {
|
|
9463
|
-
value: textControlValue || null,
|
|
9464
|
-
innerText: textControlValue || null
|
|
9465
|
-
}));
|
|
9466
|
-
} else if (type === ControlType.SELECT || type === ControlType.CHECKBOX) {
|
|
9467
|
-
const innerText = code == null ? void 0 : code.split(",").map((selectCode) => {
|
|
9468
|
-
var _a2;
|
|
9469
|
-
return (_a2 = valueSets == null ? void 0 : valueSets.find((valueSet) => valueSet.code === selectCode)) == null ? void 0 : _a2.value;
|
|
9470
|
-
}).filter(Boolean).join("");
|
|
9471
|
-
result.push(__spreadProps(__spreadValues({}, element.control), {
|
|
9472
|
-
value: code || null,
|
|
9473
|
-
innerText: innerText || null
|
|
9474
|
-
}));
|
|
9475
|
-
}
|
|
9476
|
-
i = j;
|
|
9477
|
-
}
|
|
9595
|
+
getValue(elementList);
|
|
9478
9596
|
return result;
|
|
9479
9597
|
}
|
|
9480
9598
|
setValueByConceptId(payload) {
|
|
@@ -9518,6 +9636,9 @@ class Control {
|
|
|
9518
9636
|
range: fakeRange,
|
|
9519
9637
|
elementList
|
|
9520
9638
|
};
|
|
9639
|
+
const controlRule = {
|
|
9640
|
+
isIgnoreDisabledRule: true
|
|
9641
|
+
};
|
|
9521
9642
|
if (type === ControlType.TEXT) {
|
|
9522
9643
|
const formatValue = [{ value }];
|
|
9523
9644
|
formatElementList(formatValue, {
|
|
@@ -9526,28 +9647,21 @@ class Control {
|
|
|
9526
9647
|
});
|
|
9527
9648
|
const text = new TextControl(element, this);
|
|
9528
9649
|
if (value) {
|
|
9529
|
-
text.setValue(formatValue, controlContext);
|
|
9650
|
+
text.setValue(formatValue, controlContext, controlRule);
|
|
9530
9651
|
} else {
|
|
9531
|
-
text.clearValue(controlContext);
|
|
9652
|
+
text.clearValue(controlContext, controlRule);
|
|
9532
9653
|
}
|
|
9533
9654
|
} else if (type === ControlType.SELECT) {
|
|
9534
9655
|
const select = new SelectControl(element, this);
|
|
9535
9656
|
if (value) {
|
|
9536
|
-
select.setSelect(value, controlContext);
|
|
9657
|
+
select.setSelect(value, controlContext, controlRule);
|
|
9537
9658
|
} else {
|
|
9538
|
-
select.clearSelect(controlContext);
|
|
9659
|
+
select.clearSelect(controlContext, controlRule);
|
|
9539
9660
|
}
|
|
9540
9661
|
} else if (type === ControlType.CHECKBOX) {
|
|
9541
9662
|
const checkbox = new CheckboxControl(element, this);
|
|
9542
|
-
const checkboxElementList = elementList.slice(fakeRange.startIndex + 1, fakeRange.endIndex + 1);
|
|
9543
9663
|
const codes = (value == null ? void 0 : value.split(",")) || [];
|
|
9544
|
-
|
|
9545
|
-
if (checkElement.controlComponent === ControlComponent.CHECKBOX) {
|
|
9546
|
-
const checkboxItem = checkElement.checkbox;
|
|
9547
|
-
checkboxItem.value = codes.includes(checkboxItem.code);
|
|
9548
|
-
}
|
|
9549
|
-
}
|
|
9550
|
-
checkbox.setSelect(controlContext);
|
|
9664
|
+
checkbox.setSelect(codes, controlContext, controlRule);
|
|
9551
9665
|
}
|
|
9552
9666
|
let newEndIndex = i;
|
|
9553
9667
|
while (newEndIndex < elementList.length) {
|
|
@@ -9574,21 +9688,26 @@ class Control {
|
|
|
9574
9688
|
}
|
|
9575
9689
|
}
|
|
9576
9690
|
setExtensionByConceptId(payload) {
|
|
9577
|
-
var _a;
|
|
9578
9691
|
const isReadonly = this.draw.isReadonly();
|
|
9579
9692
|
if (isReadonly)
|
|
9580
9693
|
return;
|
|
9581
9694
|
const { conceptId, extension } = payload;
|
|
9582
|
-
const
|
|
9583
|
-
|
|
9584
|
-
this.draw.getOriginalMainElementList(),
|
|
9585
|
-
this.draw.getFooterElementList()
|
|
9586
|
-
];
|
|
9587
|
-
for (const elementList of data2) {
|
|
9695
|
+
const setExtension = (elementList) => {
|
|
9696
|
+
var _a;
|
|
9588
9697
|
let i = 0;
|
|
9589
9698
|
while (i < elementList.length) {
|
|
9590
9699
|
const element = elementList[i];
|
|
9591
9700
|
i++;
|
|
9701
|
+
if (element.type === ElementType.TABLE) {
|
|
9702
|
+
const trList = element.trList;
|
|
9703
|
+
for (let r = 0; r < trList.length; r++) {
|
|
9704
|
+
const tr = trList[r];
|
|
9705
|
+
for (let d = 0; d < tr.tdList.length; d++) {
|
|
9706
|
+
const td = tr.tdList[d];
|
|
9707
|
+
setExtension(td.value);
|
|
9708
|
+
}
|
|
9709
|
+
}
|
|
9710
|
+
}
|
|
9592
9711
|
if (((_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId) !== conceptId)
|
|
9593
9712
|
continue;
|
|
9594
9713
|
element.control.extension = extension;
|
|
@@ -9601,6 +9720,14 @@ class Control {
|
|
|
9601
9720
|
}
|
|
9602
9721
|
i = newEndIndex;
|
|
9603
9722
|
}
|
|
9723
|
+
};
|
|
9724
|
+
const data2 = [
|
|
9725
|
+
this.draw.getHeaderElementList(),
|
|
9726
|
+
this.draw.getOriginalMainElementList(),
|
|
9727
|
+
this.draw.getFooterElementList()
|
|
9728
|
+
];
|
|
9729
|
+
for (const elementList of data2) {
|
|
9730
|
+
setExtension(elementList);
|
|
9604
9731
|
}
|
|
9605
9732
|
}
|
|
9606
9733
|
}
|
|
@@ -9612,7 +9739,7 @@ class CheckboxParticle {
|
|
|
9612
9739
|
render(ctx, element, x, y) {
|
|
9613
9740
|
const { checkbox: { gap, lineWidth, fillStyle, fontStyle }, scale } = this.options;
|
|
9614
9741
|
const { metrics, checkbox } = element;
|
|
9615
|
-
const left = Math.round(x + gap);
|
|
9742
|
+
const left = Math.round(x + gap * scale);
|
|
9616
9743
|
const top = Math.round(y - metrics.height + lineWidth);
|
|
9617
9744
|
const width = metrics.width - gap * 2 * scale;
|
|
9618
9745
|
const height = metrics.height;
|
|
@@ -11595,7 +11722,7 @@ class Draw {
|
|
|
11595
11722
|
this.footer = new Footer(this, data2.footer);
|
|
11596
11723
|
this.hyperlinkParticle = new HyperlinkParticle(this);
|
|
11597
11724
|
this.dateParticle = new DateParticle(this);
|
|
11598
|
-
this.separatorParticle = new SeparatorParticle();
|
|
11725
|
+
this.separatorParticle = new SeparatorParticle(this);
|
|
11599
11726
|
this.pageBreakParticle = new PageBreakParticle(this);
|
|
11600
11727
|
this.superscriptParticle = new SuperscriptParticle();
|
|
11601
11728
|
this.subscriptParticle = new SubscriptParticle();
|
|
@@ -11881,7 +12008,9 @@ class Draw {
|
|
|
11881
12008
|
let curIndex = -1;
|
|
11882
12009
|
const activeControl = this.control.getActiveControl();
|
|
11883
12010
|
if (activeControl && !this.control.isRangInPostfix()) {
|
|
11884
|
-
curIndex = activeControl.setValue(payload
|
|
12011
|
+
curIndex = activeControl.setValue(payload, void 0, {
|
|
12012
|
+
isIgnoreDisabledRule: true
|
|
12013
|
+
});
|
|
11885
12014
|
} else {
|
|
11886
12015
|
const elementList = this.getElementList();
|
|
11887
12016
|
const isCollapsed = startIndex === endIndex;
|
|
@@ -12343,7 +12472,7 @@ class Draw {
|
|
|
12343
12472
|
const rowList2 = this.computeRowList((td.width - tdPaddingWidth) * scale, td.value);
|
|
12344
12473
|
const rowHeight = rowList2.reduce((pre, cur) => pre + cur.height, 0);
|
|
12345
12474
|
td.rowList = rowList2;
|
|
12346
|
-
const curTdHeight =
|
|
12475
|
+
const curTdHeight = rowHeight / scale + tdPaddingHeight;
|
|
12347
12476
|
if (td.height < curTdHeight) {
|
|
12348
12477
|
const extraHeight = curTdHeight - td.height;
|
|
12349
12478
|
const changeTr = trList[t + td.rowspan - 1];
|
|
@@ -12356,7 +12485,7 @@ class Draw {
|
|
|
12356
12485
|
let curTdRealHeight = 0;
|
|
12357
12486
|
let i2 = 0;
|
|
12358
12487
|
while (i2 < td.rowspan) {
|
|
12359
|
-
const curTr = trList[i2 + t];
|
|
12488
|
+
const curTr = trList[i2 + t] || trList[t];
|
|
12360
12489
|
curTdMinHeight += curTr.minHeight;
|
|
12361
12490
|
curTdRealHeight += curTr.height;
|
|
12362
12491
|
i2++;
|
|
@@ -12389,8 +12518,8 @@ class Draw {
|
|
|
12389
12518
|
}
|
|
12390
12519
|
}
|
|
12391
12520
|
this.tableParticle.computeRowColInfo(element);
|
|
12392
|
-
const tableHeight =
|
|
12393
|
-
const tableWidth =
|
|
12521
|
+
const tableHeight = this.tableParticle.getTableHeight(element);
|
|
12522
|
+
const tableWidth = this.tableParticle.getTableWidth(element);
|
|
12394
12523
|
element.width = tableWidth;
|
|
12395
12524
|
element.height = tableHeight;
|
|
12396
12525
|
const elementWidth = tableWidth * scale;
|
|
@@ -12398,7 +12527,7 @@ class Draw {
|
|
|
12398
12527
|
metrics.width = elementWidth;
|
|
12399
12528
|
metrics.height = elementHeight;
|
|
12400
12529
|
metrics.boundingBoxDescent = elementHeight;
|
|
12401
|
-
metrics.boundingBoxAscent =
|
|
12530
|
+
metrics.boundingBoxAscent = -rowMargin;
|
|
12402
12531
|
const height2 = this.getHeight();
|
|
12403
12532
|
const marginHeight = this.getMainOuterHeight();
|
|
12404
12533
|
let curPagePreHeight = marginHeight;
|
|
@@ -12706,10 +12835,19 @@ class Draw {
|
|
|
12706
12835
|
}
|
|
12707
12836
|
}
|
|
12708
12837
|
if (element.underline || ((_a = element.control) == null ? void 0 : _a.underline)) {
|
|
12838
|
+
if ((preElement == null ? void 0 : preElement.type) === ElementType.SUPERSCRIPT && element.type !== ElementType.SUPERSCRIPT || (preElement == null ? void 0 : preElement.type) === ElementType.SUBSCRIPT && element.type !== ElementType.SUBSCRIPT) {
|
|
12839
|
+
this.underline.render(ctx);
|
|
12840
|
+
}
|
|
12709
12841
|
const rowMargin = defaultBasicRowMarginHeight * (element.rowMargin || defaultRowMargin) * scale;
|
|
12710
|
-
const
|
|
12842
|
+
const offsetX = element.left || 0;
|
|
12843
|
+
let offsetY2 = 0;
|
|
12844
|
+
if (element.type === ElementType.SUBSCRIPT) {
|
|
12845
|
+
offsetY2 = this.subscriptParticle.getOffsetY(element);
|
|
12846
|
+
} else if (element.type === ElementType.SUPERSCRIPT) {
|
|
12847
|
+
offsetY2 = this.superscriptParticle.getOffsetY(element);
|
|
12848
|
+
}
|
|
12711
12849
|
const color = element.controlComponent === ControlComponent.PLACEHOLDER ? void 0 : element.color;
|
|
12712
|
-
this.underline.recordFillInfo(ctx, x -
|
|
12850
|
+
this.underline.recordFillInfo(ctx, x - offsetX, y + curRow.height - rowMargin + offsetY2, metrics.width + offsetX, 0, color);
|
|
12713
12851
|
} else if ((preElement == null ? void 0 : preElement.underline) || ((_b = preElement == null ? void 0 : preElement.control) == null ? void 0 : _b.underline)) {
|
|
12714
12852
|
this.underline.render(ctx);
|
|
12715
12853
|
}
|
|
@@ -12990,6 +13128,8 @@ class Command {
|
|
|
12990
13128
|
__publicField(this, "executeSelectAll");
|
|
12991
13129
|
__publicField(this, "executeBackspace");
|
|
12992
13130
|
__publicField(this, "executeSetRange");
|
|
13131
|
+
__publicField(this, "executeReplaceRange");
|
|
13132
|
+
__publicField(this, "executeSetPositionContext");
|
|
12993
13133
|
__publicField(this, "executeForceUpdate");
|
|
12994
13134
|
__publicField(this, "executeBlur");
|
|
12995
13135
|
__publicField(this, "executeUndo");
|
|
@@ -13064,6 +13204,7 @@ class Command {
|
|
|
13064
13204
|
__publicField(this, "executeSetGroup");
|
|
13065
13205
|
__publicField(this, "executeDeleteGroup");
|
|
13066
13206
|
__publicField(this, "executeLocationGroup");
|
|
13207
|
+
__publicField(this, "executeSetZone");
|
|
13067
13208
|
__publicField(this, "executeSetControlValue");
|
|
13068
13209
|
__publicField(this, "executeSetControlExtension");
|
|
13069
13210
|
__publicField(this, "getCatalog");
|
|
@@ -13077,6 +13218,7 @@ class Command {
|
|
|
13077
13218
|
__publicField(this, "getRangeContext");
|
|
13078
13219
|
__publicField(this, "getRangeRow");
|
|
13079
13220
|
__publicField(this, "getRangeParagraph");
|
|
13221
|
+
__publicField(this, "getKeywordRangeList");
|
|
13080
13222
|
__publicField(this, "getPaperMargin");
|
|
13081
13223
|
__publicField(this, "getSearchNavigateInfo");
|
|
13082
13224
|
__publicField(this, "getLocale");
|
|
@@ -13090,6 +13232,8 @@ class Command {
|
|
|
13090
13232
|
this.executeSelectAll = adapt.selectAll.bind(adapt);
|
|
13091
13233
|
this.executeBackspace = adapt.backspace.bind(adapt);
|
|
13092
13234
|
this.executeSetRange = adapt.setRange.bind(adapt);
|
|
13235
|
+
this.executeReplaceRange = adapt.replaceRange.bind(adapt);
|
|
13236
|
+
this.executeSetPositionContext = adapt.setPositionContext.bind(adapt);
|
|
13093
13237
|
this.executeForceUpdate = adapt.forceUpdate.bind(adapt);
|
|
13094
13238
|
this.executeBlur = adapt.blur.bind(adapt);
|
|
13095
13239
|
this.executeUndo = adapt.undo.bind(adapt);
|
|
@@ -13164,6 +13308,7 @@ class Command {
|
|
|
13164
13308
|
this.executeSetGroup = adapt.setGroup.bind(adapt);
|
|
13165
13309
|
this.executeDeleteGroup = adapt.deleteGroup.bind(adapt);
|
|
13166
13310
|
this.executeLocationGroup = adapt.locationGroup.bind(adapt);
|
|
13311
|
+
this.executeSetZone = adapt.setZone.bind(adapt);
|
|
13167
13312
|
this.getImage = adapt.getImage.bind(adapt);
|
|
13168
13313
|
this.getOptions = adapt.getOptions.bind(adapt);
|
|
13169
13314
|
this.getValue = adapt.getValue.bind(adapt);
|
|
@@ -13174,6 +13319,7 @@ class Command {
|
|
|
13174
13319
|
this.getRangeContext = adapt.getRangeContext.bind(adapt);
|
|
13175
13320
|
this.getRangeRow = adapt.getRangeRow.bind(adapt);
|
|
13176
13321
|
this.getRangeParagraph = adapt.getRangeParagraph.bind(adapt);
|
|
13322
|
+
this.getKeywordRangeList = adapt.getKeywordRangeList.bind(adapt);
|
|
13177
13323
|
this.getCatalog = adapt.getCatalog.bind(adapt);
|
|
13178
13324
|
this.getPaperMargin = adapt.getPaperMargin.bind(adapt);
|
|
13179
13325
|
this.getSearchNavigateInfo = adapt.getSearchNavigateInfo.bind(adapt);
|
|
@@ -13298,10 +13444,10 @@ class CommandAdapt {
|
|
|
13298
13444
|
this.range.setRange(curIndex, curIndex);
|
|
13299
13445
|
this.draw.render({ curIndex });
|
|
13300
13446
|
}
|
|
13301
|
-
setRange(startIndex, endIndex) {
|
|
13447
|
+
setRange(startIndex, endIndex, tableId, startTdIndex, endTdIndex, startTrIndex, endTrIndex) {
|
|
13302
13448
|
if (startIndex < 0 || endIndex < 0 || endIndex < startIndex)
|
|
13303
13449
|
return;
|
|
13304
|
-
this.range.setRange(startIndex, endIndex);
|
|
13450
|
+
this.range.setRange(startIndex, endIndex, tableId, startTdIndex, endTdIndex, startTrIndex, endTrIndex);
|
|
13305
13451
|
const isCollapsed = startIndex === endIndex;
|
|
13306
13452
|
this.draw.render({
|
|
13307
13453
|
curIndex: isCollapsed ? startIndex : void 0,
|
|
@@ -13310,6 +13456,34 @@ class CommandAdapt {
|
|
|
13310
13456
|
isSetCursor: isCollapsed
|
|
13311
13457
|
});
|
|
13312
13458
|
}
|
|
13459
|
+
replaceRange(range) {
|
|
13460
|
+
this.setRange(range.startIndex, range.endIndex, range.tableId, range.startTdIndex, range.endTdIndex, range.startTrIndex, range.endTrIndex);
|
|
13461
|
+
}
|
|
13462
|
+
setPositionContext(range) {
|
|
13463
|
+
const { tableId, startTrIndex, startTdIndex } = range;
|
|
13464
|
+
const elementList = this.draw.getOriginalElementList();
|
|
13465
|
+
if (tableId) {
|
|
13466
|
+
const tableElementIndex = elementList.findIndex((el) => el.id === tableId);
|
|
13467
|
+
if (!~tableElementIndex)
|
|
13468
|
+
return;
|
|
13469
|
+
const tableElement = elementList[tableElementIndex];
|
|
13470
|
+
const tr = tableElement.trList[startTrIndex];
|
|
13471
|
+
const td = tr.tdList[startTdIndex];
|
|
13472
|
+
this.position.setPositionContext({
|
|
13473
|
+
isTable: true,
|
|
13474
|
+
index: tableElementIndex,
|
|
13475
|
+
trIndex: startTrIndex,
|
|
13476
|
+
tdIndex: startTdIndex,
|
|
13477
|
+
tdId: td.id,
|
|
13478
|
+
trId: tr.id,
|
|
13479
|
+
tableId
|
|
13480
|
+
});
|
|
13481
|
+
} else {
|
|
13482
|
+
this.position.setPositionContext({
|
|
13483
|
+
isTable: false
|
|
13484
|
+
});
|
|
13485
|
+
}
|
|
13486
|
+
}
|
|
13313
13487
|
forceUpdate(options) {
|
|
13314
13488
|
const { isSubmitHistory = false } = options || {};
|
|
13315
13489
|
this.range.clearRange();
|
|
@@ -13335,9 +13509,6 @@ class CommandAdapt {
|
|
|
13335
13509
|
this.historyManager.redo();
|
|
13336
13510
|
}
|
|
13337
13511
|
painter(options) {
|
|
13338
|
-
const isReadonly = this.draw.isReadonly();
|
|
13339
|
-
if (isReadonly)
|
|
13340
|
-
return;
|
|
13341
13512
|
const selection = this.range.getSelection();
|
|
13342
13513
|
if (!selection)
|
|
13343
13514
|
return;
|
|
@@ -13354,11 +13525,14 @@ class CommandAdapt {
|
|
|
13354
13525
|
this.draw.setPainterStyle(painterStyle, options);
|
|
13355
13526
|
}
|
|
13356
13527
|
applyPainterStyle() {
|
|
13528
|
+
const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
|
|
13529
|
+
if (isDisabled)
|
|
13530
|
+
return;
|
|
13357
13531
|
this.canvasEvent.applyPainterStyle();
|
|
13358
13532
|
}
|
|
13359
13533
|
format() {
|
|
13360
|
-
const
|
|
13361
|
-
if (
|
|
13534
|
+
const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
|
|
13535
|
+
if (isDisabled)
|
|
13362
13536
|
return;
|
|
13363
13537
|
const selection = this.range.getSelectionElementList();
|
|
13364
13538
|
if (!selection)
|
|
@@ -13374,8 +13548,8 @@ class CommandAdapt {
|
|
|
13374
13548
|
this.draw.render({ isSetCursor: false });
|
|
13375
13549
|
}
|
|
13376
13550
|
font(payload) {
|
|
13377
|
-
const
|
|
13378
|
-
if (
|
|
13551
|
+
const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
|
|
13552
|
+
if (isDisabled)
|
|
13379
13553
|
return;
|
|
13380
13554
|
const selection = this.range.getSelectionElementList();
|
|
13381
13555
|
if (!selection)
|
|
@@ -13389,8 +13563,8 @@ class CommandAdapt {
|
|
|
13389
13563
|
const { minSize, maxSize, defaultSize } = this.options;
|
|
13390
13564
|
if (payload < minSize || payload > maxSize)
|
|
13391
13565
|
return;
|
|
13392
|
-
const
|
|
13393
|
-
if (
|
|
13566
|
+
const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
|
|
13567
|
+
if (isDisabled)
|
|
13394
13568
|
return;
|
|
13395
13569
|
const selection = this.range.getTextLikeSelectionElementList();
|
|
13396
13570
|
if (!selection || !selection.length)
|
|
@@ -13408,8 +13582,8 @@ class CommandAdapt {
|
|
|
13408
13582
|
}
|
|
13409
13583
|
}
|
|
13410
13584
|
sizeAdd() {
|
|
13411
|
-
const
|
|
13412
|
-
if (
|
|
13585
|
+
const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
|
|
13586
|
+
if (isDisabled)
|
|
13413
13587
|
return;
|
|
13414
13588
|
const selection = this.range.getTextLikeSelectionElementList();
|
|
13415
13589
|
if (!selection || !selection.length)
|
|
@@ -13434,8 +13608,8 @@ class CommandAdapt {
|
|
|
13434
13608
|
}
|
|
13435
13609
|
}
|
|
13436
13610
|
sizeMinus() {
|
|
13437
|
-
const
|
|
13438
|
-
if (
|
|
13611
|
+
const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
|
|
13612
|
+
if (isDisabled)
|
|
13439
13613
|
return;
|
|
13440
13614
|
const selection = this.range.getTextLikeSelectionElementList();
|
|
13441
13615
|
if (!selection || !selection.length)
|
|
@@ -13460,8 +13634,8 @@ class CommandAdapt {
|
|
|
13460
13634
|
}
|
|
13461
13635
|
}
|
|
13462
13636
|
bold() {
|
|
13463
|
-
const
|
|
13464
|
-
if (
|
|
13637
|
+
const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
|
|
13638
|
+
if (isDisabled)
|
|
13465
13639
|
return;
|
|
13466
13640
|
const selection = this.range.getSelectionElementList();
|
|
13467
13641
|
if (!selection)
|
|
@@ -13473,8 +13647,8 @@ class CommandAdapt {
|
|
|
13473
13647
|
this.draw.render({ isSetCursor: false });
|
|
13474
13648
|
}
|
|
13475
13649
|
italic() {
|
|
13476
|
-
const
|
|
13477
|
-
if (
|
|
13650
|
+
const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
|
|
13651
|
+
if (isDisabled)
|
|
13478
13652
|
return;
|
|
13479
13653
|
const selection = this.range.getSelectionElementList();
|
|
13480
13654
|
if (!selection)
|
|
@@ -13486,8 +13660,8 @@ class CommandAdapt {
|
|
|
13486
13660
|
this.draw.render({ isSetCursor: false });
|
|
13487
13661
|
}
|
|
13488
13662
|
underline() {
|
|
13489
|
-
const
|
|
13490
|
-
if (
|
|
13663
|
+
const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
|
|
13664
|
+
if (isDisabled)
|
|
13491
13665
|
return;
|
|
13492
13666
|
const selection = this.range.getSelectionElementList();
|
|
13493
13667
|
if (!selection)
|
|
@@ -13502,8 +13676,8 @@ class CommandAdapt {
|
|
|
13502
13676
|
});
|
|
13503
13677
|
}
|
|
13504
13678
|
strikeout() {
|
|
13505
|
-
const
|
|
13506
|
-
if (
|
|
13679
|
+
const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
|
|
13680
|
+
if (isDisabled)
|
|
13507
13681
|
return;
|
|
13508
13682
|
const selection = this.range.getSelectionElementList();
|
|
13509
13683
|
if (!selection)
|
|
@@ -13518,8 +13692,8 @@ class CommandAdapt {
|
|
|
13518
13692
|
});
|
|
13519
13693
|
}
|
|
13520
13694
|
superscript() {
|
|
13521
|
-
const
|
|
13522
|
-
if (
|
|
13695
|
+
const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
|
|
13696
|
+
if (isDisabled)
|
|
13523
13697
|
return;
|
|
13524
13698
|
const selection = this.range.getSelectionElementList();
|
|
13525
13699
|
if (!selection)
|
|
@@ -13540,8 +13714,8 @@ class CommandAdapt {
|
|
|
13540
13714
|
this.draw.render({ isSetCursor: false });
|
|
13541
13715
|
}
|
|
13542
13716
|
subscript() {
|
|
13543
|
-
const
|
|
13544
|
-
if (
|
|
13717
|
+
const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
|
|
13718
|
+
if (isDisabled)
|
|
13545
13719
|
return;
|
|
13546
13720
|
const selection = this.range.getSelectionElementList();
|
|
13547
13721
|
if (!selection)
|
|
@@ -13562,8 +13736,8 @@ class CommandAdapt {
|
|
|
13562
13736
|
this.draw.render({ isSetCursor: false });
|
|
13563
13737
|
}
|
|
13564
13738
|
color(payload) {
|
|
13565
|
-
const
|
|
13566
|
-
if (
|
|
13739
|
+
const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
|
|
13740
|
+
if (isDisabled)
|
|
13567
13741
|
return;
|
|
13568
13742
|
const selection = this.range.getSelectionElementList();
|
|
13569
13743
|
if (!selection)
|
|
@@ -13577,8 +13751,8 @@ class CommandAdapt {
|
|
|
13577
13751
|
});
|
|
13578
13752
|
}
|
|
13579
13753
|
highlight(payload) {
|
|
13580
|
-
const
|
|
13581
|
-
if (
|
|
13754
|
+
const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
|
|
13755
|
+
if (isDisabled)
|
|
13582
13756
|
return;
|
|
13583
13757
|
const selection = this.range.getSelectionElementList();
|
|
13584
13758
|
if (!selection)
|
|
@@ -14469,6 +14643,9 @@ class CommandAdapt {
|
|
|
14469
14643
|
return [leftIndex, rightIndex];
|
|
14470
14644
|
}
|
|
14471
14645
|
deleteHyperlink() {
|
|
14646
|
+
const isReadonly = this.draw.isReadonly();
|
|
14647
|
+
if (isReadonly)
|
|
14648
|
+
return;
|
|
14472
14649
|
const hyperRange = this.getHyperlinkRange();
|
|
14473
14650
|
if (!hyperRange)
|
|
14474
14651
|
return;
|
|
@@ -14483,6 +14660,9 @@ class CommandAdapt {
|
|
|
14483
14660
|
});
|
|
14484
14661
|
}
|
|
14485
14662
|
cancelHyperlink() {
|
|
14663
|
+
const isReadonly = this.draw.isReadonly();
|
|
14664
|
+
if (isReadonly)
|
|
14665
|
+
return;
|
|
14486
14666
|
const hyperRange = this.getHyperlinkRange();
|
|
14487
14667
|
if (!hyperRange)
|
|
14488
14668
|
return;
|
|
@@ -14503,6 +14683,9 @@ class CommandAdapt {
|
|
|
14503
14683
|
});
|
|
14504
14684
|
}
|
|
14505
14685
|
editHyperlink(payload) {
|
|
14686
|
+
const isReadonly = this.draw.isReadonly();
|
|
14687
|
+
if (isReadonly)
|
|
14688
|
+
return;
|
|
14506
14689
|
const hyperRange = this.getHyperlinkRange();
|
|
14507
14690
|
if (!hyperRange)
|
|
14508
14691
|
return;
|
|
@@ -14602,8 +14785,8 @@ class CommandAdapt {
|
|
|
14602
14785
|
}
|
|
14603
14786
|
}
|
|
14604
14787
|
image(payload) {
|
|
14605
|
-
const
|
|
14606
|
-
if (
|
|
14788
|
+
const isDisabled = this.draw.isReadonly() || this.control.isDisabledControl();
|
|
14789
|
+
if (isDisabled)
|
|
14607
14790
|
return;
|
|
14608
14791
|
const activeControl = this.control.getActiveControl();
|
|
14609
14792
|
if (activeControl)
|
|
@@ -14905,6 +15088,9 @@ class CommandAdapt {
|
|
|
14905
15088
|
const paragraphElementList = this.range.getRangeParagraphElementList();
|
|
14906
15089
|
return paragraphElementList ? zipElementList(paragraphElementList) : null;
|
|
14907
15090
|
}
|
|
15091
|
+
getKeywordRangeList(payload) {
|
|
15092
|
+
return this.range.getKeywordRangeList(payload);
|
|
15093
|
+
}
|
|
14908
15094
|
pageMode(payload) {
|
|
14909
15095
|
this.draw.setPageMode(payload);
|
|
14910
15096
|
}
|
|
@@ -15084,6 +15270,9 @@ class CommandAdapt {
|
|
|
15084
15270
|
isSubmitHistory: false
|
|
15085
15271
|
});
|
|
15086
15272
|
}
|
|
15273
|
+
setZone(zone) {
|
|
15274
|
+
this.draw.getZone().setZone(zone);
|
|
15275
|
+
}
|
|
15087
15276
|
getControlValue(payload) {
|
|
15088
15277
|
return this.draw.getControl().getValueByConceptId(payload);
|
|
15089
15278
|
}
|