@hufe921/canvas-editor 0.9.10 → 0.9.12
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/README.md +8 -6
- package/dist/canvas-editor.es.js +856 -501
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +16 -16
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/event/CanvasEvent.d.ts +18 -14
- package/dist/src/editor/core/event/GlobalEvent.d.ts +1 -1
- package/dist/src/editor/core/event/handlers/click.d.ts +8 -0
- package/dist/src/editor/core/event/handlers/composition.d.ts +8 -0
- package/dist/src/editor/core/event/handlers/copy.d.ts +2 -0
- package/dist/src/editor/core/event/handlers/cut.d.ts +2 -0
- package/dist/src/editor/core/event/handlers/drag.d.ts +6 -0
- package/dist/src/editor/core/event/handlers/drop.d.ts +2 -0
- package/dist/src/editor/core/event/handlers/input.d.ts +2 -0
- package/dist/src/editor/core/event/handlers/keydown.d.ts +2 -0
- package/dist/src/editor/core/event/handlers/mousedown.d.ts +2 -0
- package/dist/src/editor/core/event/handlers/mouseleave.d.ts +2 -0
- package/dist/src/editor/core/event/handlers/mousemove.d.ts +2 -0
- package/dist/src/editor/core/event/handlers/mouseup.d.ts +2 -0
- package/dist/src/editor/core/position/Position.d.ts +1 -0
- package/dist/src/editor/core/range/RangeManager.d.ts +1 -0
- package/dist/src/editor/dataset/constant/Element.d.ts +1 -1
- package/package.json +8 -3
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.12";
|
|
27
27
|
const ZERO = "\u200B";
|
|
28
28
|
const WRAP = "\n";
|
|
29
29
|
var RowFlex;
|
|
@@ -92,7 +92,7 @@ function downloadFile(href, fileName) {
|
|
|
92
92
|
a.download = fileName;
|
|
93
93
|
a.click();
|
|
94
94
|
}
|
|
95
|
-
function threeClick(dom, fn) {
|
|
95
|
+
function threeClick$1(dom, fn) {
|
|
96
96
|
nClickEvent(3, dom, fn);
|
|
97
97
|
}
|
|
98
98
|
function nClickEvent(n, dom, fn) {
|
|
@@ -3557,11 +3557,25 @@ function writeClipboardItem(text, html) {
|
|
|
3557
3557
|
return;
|
|
3558
3558
|
const plainText = new Blob([text], { type: "text/plain" });
|
|
3559
3559
|
const htmlText = new Blob([html], { type: "text/html" });
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3560
|
+
if (window.ClipboardItem) {
|
|
3561
|
+
const item = new ClipboardItem({
|
|
3562
|
+
[plainText.type]: plainText,
|
|
3563
|
+
[htmlText.type]: htmlText
|
|
3564
|
+
});
|
|
3565
|
+
window.navigator.clipboard.write([item]);
|
|
3566
|
+
} else {
|
|
3567
|
+
const fakeElement = document.createElement("div");
|
|
3568
|
+
fakeElement.setAttribute("contenteditable", "true");
|
|
3569
|
+
fakeElement.innerHTML = html;
|
|
3570
|
+
document.body.append(fakeElement);
|
|
3571
|
+
const selection = window.getSelection();
|
|
3572
|
+
const range = document.createRange();
|
|
3573
|
+
range.selectNodeContents(fakeElement);
|
|
3574
|
+
selection == null ? void 0 : selection.removeAllRanges();
|
|
3575
|
+
selection == null ? void 0 : selection.addRange(range);
|
|
3576
|
+
document.execCommand("copy");
|
|
3577
|
+
fakeElement.remove();
|
|
3578
|
+
}
|
|
3565
3579
|
}
|
|
3566
3580
|
function writeElementList(elementList, options) {
|
|
3567
3581
|
const clipboardDom = document.createElement("div");
|
|
@@ -3947,8 +3961,6 @@ var KeyMap;
|
|
|
3947
3961
|
KeyMap2["EIGHT"] = "8";
|
|
3948
3962
|
KeyMap2["NINE"] = "9";
|
|
3949
3963
|
})(KeyMap || (KeyMap = {}));
|
|
3950
|
-
const LETTER_REG = /[a-zA-Z]/;
|
|
3951
|
-
const NUMBER_LIKE_REG = /[0-9.]/;
|
|
3952
3964
|
class CheckboxControl {
|
|
3953
3965
|
constructor(element, control) {
|
|
3954
3966
|
__publicField(this, "element");
|
|
@@ -4046,442 +4058,628 @@ class CheckboxControl {
|
|
|
4046
4058
|
return endIndex;
|
|
4047
4059
|
}
|
|
4048
4060
|
}
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
this.isAllowDrag = false;
|
|
4069
|
-
this.isCompositing = false;
|
|
4070
|
-
this.mouseDownStartPosition = null;
|
|
4071
|
-
this.pageContainer = draw.getPageContainer();
|
|
4072
|
-
this.pageList = draw.getPageList();
|
|
4073
|
-
this.draw = draw;
|
|
4074
|
-
this.options = draw.getOptions();
|
|
4075
|
-
this.cursor = null;
|
|
4076
|
-
this.position = this.draw.getPosition();
|
|
4077
|
-
this.range = this.draw.getRange();
|
|
4078
|
-
this.historyManager = this.draw.getHistoryManager();
|
|
4079
|
-
this.previewer = this.draw.getPreviewer();
|
|
4080
|
-
this.tableTool = this.draw.getTableTool();
|
|
4081
|
-
this.hyperlinkParticle = this.draw.getHyperlinkParticle();
|
|
4082
|
-
this.dateParticle = this.draw.getDateParticle();
|
|
4083
|
-
this.listener = this.draw.getListener();
|
|
4084
|
-
this.control = this.draw.getControl();
|
|
4061
|
+
function mousedown(evt, host) {
|
|
4062
|
+
if (evt.button === MouseEventButton.RIGHT)
|
|
4063
|
+
return;
|
|
4064
|
+
const draw = host.getDraw();
|
|
4065
|
+
const isReadonly = draw.isReadonly();
|
|
4066
|
+
const rangeManager = draw.getRange();
|
|
4067
|
+
const position = draw.getPosition();
|
|
4068
|
+
if (!host.isAllowDrag) {
|
|
4069
|
+
const range = rangeManager.getRange();
|
|
4070
|
+
if (!isReadonly && range.startIndex !== range.endIndex) {
|
|
4071
|
+
const isPointInRange = rangeManager.getIsPointInRange(evt.offsetX, evt.offsetY);
|
|
4072
|
+
if (isPointInRange) {
|
|
4073
|
+
host.isAllowDrag = true;
|
|
4074
|
+
host.cacheRange = deepClone(range);
|
|
4075
|
+
host.cacheElementList = draw.getElementList();
|
|
4076
|
+
host.cachePositionList = position.getPositionList();
|
|
4077
|
+
return;
|
|
4078
|
+
}
|
|
4079
|
+
}
|
|
4085
4080
|
}
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
this.pageContainer.addEventListener("mousemove", this.mousemove.bind(this));
|
|
4091
|
-
this.pageContainer.addEventListener("dblclick", this.dblclick.bind(this));
|
|
4092
|
-
threeClick(this.pageContainer, this.threeClick.bind(this));
|
|
4081
|
+
const target = evt.target;
|
|
4082
|
+
const pageIndex = target.dataset.index;
|
|
4083
|
+
if (pageIndex) {
|
|
4084
|
+
draw.setPageNo(Number(pageIndex));
|
|
4093
4085
|
}
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4086
|
+
host.isAllowSelection = true;
|
|
4087
|
+
const positionResult = position.adjustPositionContext({
|
|
4088
|
+
x: evt.offsetX,
|
|
4089
|
+
y: evt.offsetY
|
|
4090
|
+
});
|
|
4091
|
+
const { index: index2, isDirectHit, isCheckbox, isImage, isTable, tdValueIndex } = positionResult;
|
|
4092
|
+
host.mouseDownStartPosition = __spreadProps(__spreadValues({}, positionResult), {
|
|
4093
|
+
index: isTable ? tdValueIndex : index2
|
|
4094
|
+
});
|
|
4095
|
+
const elementList = draw.getElementList();
|
|
4096
|
+
const positionList = position.getPositionList();
|
|
4097
|
+
const curIndex = isTable ? tdValueIndex : index2;
|
|
4098
|
+
const curElement = elementList[curIndex];
|
|
4099
|
+
const isDirectHitImage = !!(isDirectHit && isImage);
|
|
4100
|
+
const isDirectHitCheckbox = !!(isDirectHit && isCheckbox);
|
|
4101
|
+
if (~index2) {
|
|
4102
|
+
rangeManager.setRange(curIndex, curIndex);
|
|
4103
|
+
position.setCursorPosition(positionList[curIndex]);
|
|
4104
|
+
const isSetCheckbox = isDirectHitCheckbox && !isReadonly;
|
|
4105
|
+
if (isSetCheckbox) {
|
|
4106
|
+
const { checkbox } = curElement;
|
|
4107
|
+
if (checkbox) {
|
|
4108
|
+
checkbox.value = !checkbox.value;
|
|
4109
|
+
} else {
|
|
4110
|
+
curElement.checkbox = {
|
|
4111
|
+
value: true
|
|
4112
|
+
};
|
|
4113
|
+
}
|
|
4114
|
+
const control = draw.getControl();
|
|
4115
|
+
const activeControl = control.getActiveControl();
|
|
4116
|
+
if (activeControl instanceof CheckboxControl) {
|
|
4117
|
+
activeControl.setSelect();
|
|
4118
|
+
}
|
|
4098
4119
|
}
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4120
|
+
draw.render({
|
|
4121
|
+
curIndex,
|
|
4122
|
+
isSubmitHistory: isSetCheckbox,
|
|
4123
|
+
isSetCursor: !isDirectHitImage && !isDirectHitCheckbox,
|
|
4124
|
+
isComputeRowList: false
|
|
4103
4125
|
});
|
|
4104
|
-
this.draw.setPainterStyle(null);
|
|
4105
4126
|
}
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4127
|
+
const previewer = draw.getPreviewer();
|
|
4128
|
+
previewer.clearResizer();
|
|
4129
|
+
if (isDirectHitImage && !isReadonly) {
|
|
4130
|
+
previewer.drawResizer(curElement, positionList[curIndex], curElement.type === ElementType.LATEX ? {
|
|
4131
|
+
mime: "svg",
|
|
4132
|
+
srcKey: "laTexSVG"
|
|
4133
|
+
} : {});
|
|
4134
|
+
}
|
|
4135
|
+
const tableTool = draw.getTableTool();
|
|
4136
|
+
tableTool.dispose();
|
|
4137
|
+
if (isTable && !isReadonly) {
|
|
4138
|
+
const originalElementList = draw.getOriginalElementList();
|
|
4139
|
+
const originalPositionList = position.getOriginalPositionList();
|
|
4140
|
+
tableTool.render(originalElementList[index2], originalPositionList[index2]);
|
|
4141
|
+
}
|
|
4142
|
+
const hyperlinkParticle = draw.getHyperlinkParticle();
|
|
4143
|
+
hyperlinkParticle.clearHyperlinkPopup();
|
|
4144
|
+
if (curElement.type === ElementType.HYPERLINK) {
|
|
4145
|
+
hyperlinkParticle.drawHyperlinkPopup(curElement, positionList[curIndex]);
|
|
4146
|
+
}
|
|
4147
|
+
const dateParticle = draw.getDateParticle();
|
|
4148
|
+
dateParticle.clearDatePicker();
|
|
4149
|
+
if (curElement.type === ElementType.DATE && !isReadonly) {
|
|
4150
|
+
dateParticle.renderDatePicker(curElement, positionList[curIndex]);
|
|
4151
|
+
}
|
|
4152
|
+
}
|
|
4153
|
+
function mouseup(evt, host) {
|
|
4154
|
+
if (host.isAllowDrop) {
|
|
4155
|
+
const draw = host.getDraw();
|
|
4156
|
+
const position = draw.getPosition();
|
|
4157
|
+
const rangeManager = draw.getRange();
|
|
4158
|
+
const cacheRange = host.cacheRange;
|
|
4159
|
+
const cacheElementList = host.cacheElementList;
|
|
4160
|
+
const cachePositionList = host.cachePositionList;
|
|
4161
|
+
const range = rangeManager.getRange();
|
|
4162
|
+
const elementList = draw.getElementList();
|
|
4163
|
+
const positionList = position.getPositionList();
|
|
4164
|
+
const startPosition = positionList[range.startIndex];
|
|
4165
|
+
const cacheStartElement = cacheElementList[cacheRange.startIndex];
|
|
4166
|
+
const startElement = elementList[range.startIndex];
|
|
4167
|
+
let curIndex = range.startIndex;
|
|
4168
|
+
if (cacheStartElement.tdId === startElement.tdId && range.startIndex > cacheRange.endIndex) {
|
|
4169
|
+
curIndex -= cacheRange.endIndex - cacheRange.startIndex;
|
|
4170
|
+
}
|
|
4171
|
+
const deleteElementList = cacheElementList.splice(cacheRange.startIndex + 1, cacheRange.endIndex - cacheRange.startIndex);
|
|
4172
|
+
let restArg = {};
|
|
4173
|
+
if (startElement.tableId) {
|
|
4174
|
+
const { tdId, trId, tableId } = startElement;
|
|
4175
|
+
restArg = { tdId, trId, tableId };
|
|
4176
|
+
}
|
|
4177
|
+
const replaceElementList = deleteElementList.map((el) => {
|
|
4178
|
+
const newElement = __spreadValues({
|
|
4179
|
+
value: el.value
|
|
4180
|
+
}, restArg);
|
|
4181
|
+
EDITOR_ELEMENT_STYLE_ATTR.forEach((attr) => {
|
|
4182
|
+
const value = el[attr];
|
|
4183
|
+
if (value !== void 0) {
|
|
4184
|
+
newElement[attr] = value;
|
|
4185
|
+
}
|
|
4118
4186
|
});
|
|
4187
|
+
return newElement;
|
|
4119
4188
|
});
|
|
4120
|
-
|
|
4121
|
-
const
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4189
|
+
elementList.splice(curIndex + 1, 0, ...replaceElementList);
|
|
4190
|
+
const cacheStartPosition = cachePositionList[cacheRange.startIndex];
|
|
4191
|
+
const positionContext = position.getPositionContext();
|
|
4192
|
+
let positionContextIndex = positionContext.index;
|
|
4193
|
+
if (positionContextIndex) {
|
|
4194
|
+
if (startElement.tableId && !cacheStartElement.tableId) {
|
|
4195
|
+
if (cacheStartPosition.index < positionContextIndex) {
|
|
4196
|
+
positionContextIndex -= deleteElementList.length;
|
|
4197
|
+
}
|
|
4198
|
+
} else if (!startElement.tableId && cacheStartElement.tableId) {
|
|
4199
|
+
if (startPosition.index < positionContextIndex) {
|
|
4200
|
+
positionContextIndex += deleteElementList.length;
|
|
4201
|
+
}
|
|
4202
|
+
}
|
|
4203
|
+
position.setPositionContext(__spreadProps(__spreadValues({}, positionContext), {
|
|
4204
|
+
index: positionContextIndex
|
|
4205
|
+
}));
|
|
4133
4206
|
}
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4207
|
+
rangeManager.setRange(curIndex, curIndex + deleteElementList.length, range.tableId, range.startTdIndex, range.endTdIndex, range.startTrIndex, range.endTrIndex);
|
|
4208
|
+
draw.render({
|
|
4209
|
+
isSetCursor: false
|
|
4137
4210
|
});
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4211
|
+
host.isAllowDrag = false;
|
|
4212
|
+
host.isAllowDrop = false;
|
|
4213
|
+
} else if (host.isAllowDrag) {
|
|
4214
|
+
host.mousedown(evt);
|
|
4215
|
+
host.isAllowDrag = false;
|
|
4216
|
+
}
|
|
4217
|
+
}
|
|
4218
|
+
function mouseleave(evt, host) {
|
|
4219
|
+
const draw = host.getDraw();
|
|
4220
|
+
const pageContainer = draw.getPageContainer();
|
|
4221
|
+
const { x, y, width, height } = pageContainer.getBoundingClientRect();
|
|
4222
|
+
if (evt.x >= x && evt.x <= x + width && evt.y >= y && evt.y <= y + height)
|
|
4223
|
+
return;
|
|
4224
|
+
host.setIsAllowSelection(false);
|
|
4225
|
+
}
|
|
4226
|
+
function mousemove(evt, host) {
|
|
4227
|
+
const draw = host.getDraw();
|
|
4228
|
+
if (host.isAllowDrag) {
|
|
4229
|
+
const x = evt.offsetX;
|
|
4230
|
+
const y = evt.offsetY;
|
|
4231
|
+
const { startIndex: startIndex2, endIndex: endIndex2 } = host.cacheRange;
|
|
4232
|
+
const positionList = host.cachePositionList;
|
|
4233
|
+
for (let p = startIndex2 + 1; p <= endIndex2; p++) {
|
|
4234
|
+
const { coordinate: { leftTop, rightBottom } } = positionList[p];
|
|
4235
|
+
if (x >= leftTop[0] && x <= rightBottom[0] && y >= leftTop[1] && y <= rightBottom[1]) {
|
|
4150
4236
|
return;
|
|
4151
|
-
|
|
4237
|
+
}
|
|
4152
4238
|
}
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
isComputeRowList: false
|
|
4157
|
-
});
|
|
4239
|
+
host.dragover(evt);
|
|
4240
|
+
host.isAllowDrop = true;
|
|
4241
|
+
return;
|
|
4158
4242
|
}
|
|
4159
|
-
|
|
4160
|
-
|
|
4243
|
+
if (!host.isAllowSelection || !host.mouseDownStartPosition)
|
|
4244
|
+
return;
|
|
4245
|
+
const target = evt.target;
|
|
4246
|
+
const pageIndex = target.dataset.index;
|
|
4247
|
+
if (pageIndex) {
|
|
4248
|
+
draw.setPageNo(Number(pageIndex));
|
|
4249
|
+
}
|
|
4250
|
+
const position = draw.getPosition();
|
|
4251
|
+
const positionResult = position.getPositionByXY({
|
|
4252
|
+
x: evt.offsetX,
|
|
4253
|
+
y: evt.offsetY
|
|
4254
|
+
});
|
|
4255
|
+
const { index: index2, isTable, tdValueIndex, tdIndex, trIndex, tableId } = positionResult;
|
|
4256
|
+
const { index: startIndex, isTable: startIsTable, tdIndex: startTdIndex, trIndex: startTrIndex } = host.mouseDownStartPosition;
|
|
4257
|
+
const endIndex = isTable ? tdValueIndex : index2;
|
|
4258
|
+
const rangeManager = draw.getRange();
|
|
4259
|
+
if (isTable && startIsTable && (tdIndex !== startTdIndex || trIndex !== startTrIndex)) {
|
|
4260
|
+
rangeManager.setRange(endIndex, endIndex, tableId, startTdIndex, tdIndex, startTrIndex, trIndex);
|
|
4261
|
+
} else {
|
|
4262
|
+
let end = ~endIndex ? endIndex : 0;
|
|
4263
|
+
let start = startIndex;
|
|
4264
|
+
if (start > end) {
|
|
4265
|
+
[start, end] = [end, start];
|
|
4266
|
+
}
|
|
4267
|
+
if (start === end)
|
|
4161
4268
|
return;
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4269
|
+
rangeManager.setRange(start, end);
|
|
4270
|
+
}
|
|
4271
|
+
draw.render({
|
|
4272
|
+
isSubmitHistory: false,
|
|
4273
|
+
isSetCursor: false,
|
|
4274
|
+
isComputeRowList: false
|
|
4275
|
+
});
|
|
4276
|
+
}
|
|
4277
|
+
function keydown(evt, host) {
|
|
4278
|
+
var _a;
|
|
4279
|
+
const draw = host.getDraw();
|
|
4280
|
+
const position = draw.getPosition();
|
|
4281
|
+
const cursorPosition = position.getCursorPosition();
|
|
4282
|
+
if (!cursorPosition)
|
|
4283
|
+
return;
|
|
4284
|
+
const isReadonly = draw.isReadonly();
|
|
4285
|
+
const historyManager = draw.getHistoryManager();
|
|
4286
|
+
const elementList = draw.getElementList();
|
|
4287
|
+
const positionList = position.getPositionList();
|
|
4288
|
+
const { index: index2 } = cursorPosition;
|
|
4289
|
+
const rangeManager = draw.getRange();
|
|
4290
|
+
const { startIndex, endIndex } = rangeManager.getRange();
|
|
4291
|
+
const isCollapsed = startIndex === endIndex;
|
|
4292
|
+
const control = draw.getControl();
|
|
4293
|
+
const isPartRangeInControlOutside = control.isPartRangeInControlOutside();
|
|
4294
|
+
const activeControl = control.getActiveControl();
|
|
4295
|
+
if (evt.key === KeyMap.Backspace) {
|
|
4296
|
+
if (isReadonly || isPartRangeInControlOutside)
|
|
4297
|
+
return;
|
|
4298
|
+
let curIndex;
|
|
4299
|
+
if (activeControl) {
|
|
4300
|
+
curIndex = control.keydown(evt);
|
|
4301
|
+
} else {
|
|
4302
|
+
if (isCollapsed && elementList[index2].value === ZERO && index2 === 0) {
|
|
4303
|
+
evt.preventDefault();
|
|
4304
|
+
return;
|
|
4305
|
+
}
|
|
4306
|
+
if (!isCollapsed) {
|
|
4307
|
+
elementList.splice(startIndex + 1, endIndex - startIndex);
|
|
4184
4308
|
} else {
|
|
4185
|
-
|
|
4309
|
+
elementList.splice(index2, 1);
|
|
4186
4310
|
}
|
|
4311
|
+
curIndex = isCollapsed ? index2 - 1 : startIndex;
|
|
4187
4312
|
}
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
const elementList = this.draw.getElementList();
|
|
4204
|
-
const positionList = this.position.getPositionList();
|
|
4205
|
-
const curIndex = isTable ? tdValueIndex : index2;
|
|
4206
|
-
const curElement = elementList[curIndex];
|
|
4207
|
-
const isDirectHitImage = !!(isDirectHit && isImage);
|
|
4208
|
-
const isDirectHitCheckbox = !!(isDirectHit && isCheckbox);
|
|
4209
|
-
if (~index2) {
|
|
4210
|
-
this.range.setRange(curIndex, curIndex);
|
|
4211
|
-
this.position.setCursorPosition(positionList[curIndex]);
|
|
4212
|
-
const isSetCheckbox = isDirectHitCheckbox && !isReadonly;
|
|
4213
|
-
if (isSetCheckbox) {
|
|
4214
|
-
const { checkbox } = curElement;
|
|
4215
|
-
if (checkbox) {
|
|
4216
|
-
checkbox.value = !checkbox.value;
|
|
4217
|
-
} else {
|
|
4218
|
-
curElement.checkbox = {
|
|
4219
|
-
value: true
|
|
4220
|
-
};
|
|
4221
|
-
}
|
|
4222
|
-
const activeControl = this.control.getActiveControl();
|
|
4223
|
-
if (activeControl instanceof CheckboxControl) {
|
|
4224
|
-
activeControl.setSelect();
|
|
4225
|
-
}
|
|
4313
|
+
rangeManager.setRange(curIndex, curIndex);
|
|
4314
|
+
draw.render({ curIndex });
|
|
4315
|
+
} else if (evt.key === KeyMap.Delete) {
|
|
4316
|
+
if (isReadonly || isPartRangeInControlOutside)
|
|
4317
|
+
return;
|
|
4318
|
+
let curIndex;
|
|
4319
|
+
if (activeControl) {
|
|
4320
|
+
curIndex = control.keydown(evt);
|
|
4321
|
+
} else if (((_a = elementList[endIndex + 1]) == null ? void 0 : _a.type) === ElementType.CONTROL) {
|
|
4322
|
+
curIndex = control.removeControl(endIndex + 1);
|
|
4323
|
+
} else {
|
|
4324
|
+
if (!isCollapsed) {
|
|
4325
|
+
elementList.splice(startIndex + 1, endIndex - startIndex);
|
|
4326
|
+
} else {
|
|
4327
|
+
elementList.splice(index2 + 1, 1);
|
|
4226
4328
|
}
|
|
4227
|
-
|
|
4228
|
-
curIndex,
|
|
4229
|
-
isSubmitHistory: isSetCheckbox,
|
|
4230
|
-
isSetCursor: !isDirectHitImage && !isDirectHitCheckbox,
|
|
4231
|
-
isComputeRowList: false
|
|
4232
|
-
});
|
|
4233
|
-
}
|
|
4234
|
-
this.previewer.clearResizer();
|
|
4235
|
-
if (isDirectHitImage && !isReadonly) {
|
|
4236
|
-
this.previewer.drawResizer(curElement, positionList[curIndex], curElement.type === ElementType.LATEX ? {
|
|
4237
|
-
mime: "svg",
|
|
4238
|
-
srcKey: "laTexSVG"
|
|
4239
|
-
} : {});
|
|
4240
|
-
}
|
|
4241
|
-
this.tableTool.dispose();
|
|
4242
|
-
if (isTable && !isReadonly) {
|
|
4243
|
-
const originalElementList = this.draw.getOriginalElementList();
|
|
4244
|
-
const originalPositionList = this.position.getOriginalPositionList();
|
|
4245
|
-
this.tableTool.render(originalElementList[index2], originalPositionList[index2]);
|
|
4329
|
+
curIndex = isCollapsed ? index2 : startIndex;
|
|
4246
4330
|
}
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4331
|
+
rangeManager.setRange(curIndex, curIndex);
|
|
4332
|
+
draw.render({ curIndex });
|
|
4333
|
+
} else if (evt.key === KeyMap.Enter) {
|
|
4334
|
+
if (isReadonly || isPartRangeInControlOutside)
|
|
4335
|
+
return;
|
|
4336
|
+
const positionContext = position.getPositionContext();
|
|
4337
|
+
let restArg = {};
|
|
4338
|
+
if (positionContext.isTable) {
|
|
4339
|
+
const { tdId, trId, tableId } = positionContext;
|
|
4340
|
+
restArg = { tdId, trId, tableId };
|
|
4250
4341
|
}
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4342
|
+
const enterText = __spreadValues({
|
|
4343
|
+
value: ZERO
|
|
4344
|
+
}, restArg);
|
|
4345
|
+
let curIndex;
|
|
4346
|
+
if (activeControl) {
|
|
4347
|
+
curIndex = control.setValue([enterText]);
|
|
4348
|
+
} else {
|
|
4349
|
+
if (isCollapsed) {
|
|
4350
|
+
elementList.splice(index2 + 1, 0, enterText);
|
|
4351
|
+
} else {
|
|
4352
|
+
elementList.splice(startIndex + 1, endIndex - startIndex, enterText);
|
|
4353
|
+
}
|
|
4354
|
+
curIndex = index2 + 1;
|
|
4254
4355
|
}
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
this.setIsAllowDrag(false);
|
|
4261
|
-
}
|
|
4262
|
-
keydown(evt) {
|
|
4263
|
-
var _a;
|
|
4264
|
-
const isReadonly = this.draw.isReadonly();
|
|
4265
|
-
const cursorPosition = this.position.getCursorPosition();
|
|
4266
|
-
if (!cursorPosition)
|
|
4356
|
+
rangeManager.setRange(curIndex, curIndex);
|
|
4357
|
+
draw.render({ curIndex });
|
|
4358
|
+
evt.preventDefault();
|
|
4359
|
+
} else if (evt.key === KeyMap.Left) {
|
|
4360
|
+
if (isReadonly)
|
|
4267
4361
|
return;
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
if (isCollapsed && elementList[index2].value === ZERO && index2 === 0) {
|
|
4283
|
-
evt.preventDefault();
|
|
4284
|
-
return;
|
|
4285
|
-
}
|
|
4286
|
-
if (!isCollapsed) {
|
|
4287
|
-
elementList.splice(startIndex + 1, endIndex - startIndex);
|
|
4362
|
+
if (index2 > 0) {
|
|
4363
|
+
const curIndex = startIndex - 1;
|
|
4364
|
+
let anchorStartIndex = curIndex;
|
|
4365
|
+
let anchorEndIndex = curIndex;
|
|
4366
|
+
const cursorPosition2 = position.getCursorPosition();
|
|
4367
|
+
if (evt.shiftKey && cursorPosition2) {
|
|
4368
|
+
if (startIndex !== endIndex) {
|
|
4369
|
+
if (startIndex === cursorPosition2.index) {
|
|
4370
|
+
anchorStartIndex = startIndex;
|
|
4371
|
+
anchorEndIndex = endIndex - 1;
|
|
4372
|
+
} else {
|
|
4373
|
+
anchorStartIndex = curIndex;
|
|
4374
|
+
anchorEndIndex = endIndex;
|
|
4375
|
+
}
|
|
4288
4376
|
} else {
|
|
4289
|
-
|
|
4377
|
+
anchorEndIndex = endIndex;
|
|
4290
4378
|
}
|
|
4291
|
-
curIndex = isCollapsed ? index2 - 1 : startIndex;
|
|
4292
4379
|
}
|
|
4293
|
-
|
|
4294
|
-
this.draw.render({ curIndex });
|
|
4295
|
-
} else if (evt.key === KeyMap.Delete) {
|
|
4296
|
-
if (isReadonly || isPartRangeInControlOutside)
|
|
4380
|
+
if (!~anchorStartIndex || !~anchorEndIndex)
|
|
4297
4381
|
return;
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4382
|
+
rangeManager.setRange(anchorStartIndex, anchorEndIndex);
|
|
4383
|
+
const isCollapsed2 = anchorStartIndex === anchorEndIndex;
|
|
4384
|
+
draw.render({
|
|
4385
|
+
curIndex: isCollapsed2 ? anchorStartIndex : void 0,
|
|
4386
|
+
isSetCursor: isCollapsed2,
|
|
4387
|
+
isSubmitHistory: false,
|
|
4388
|
+
isComputeRowList: false
|
|
4389
|
+
});
|
|
4390
|
+
evt.preventDefault();
|
|
4391
|
+
}
|
|
4392
|
+
} else if (evt.key === KeyMap.Right) {
|
|
4393
|
+
if (isReadonly)
|
|
4394
|
+
return;
|
|
4395
|
+
if (index2 < positionList.length - 1) {
|
|
4396
|
+
const curIndex = endIndex + 1;
|
|
4397
|
+
let anchorStartIndex = curIndex;
|
|
4398
|
+
let anchorEndIndex = curIndex;
|
|
4399
|
+
const cursorPosition2 = position.getCursorPosition();
|
|
4400
|
+
if (evt.shiftKey && cursorPosition2) {
|
|
4401
|
+
if (startIndex !== endIndex) {
|
|
4402
|
+
if (startIndex === cursorPosition2.index) {
|
|
4403
|
+
anchorStartIndex = startIndex;
|
|
4404
|
+
anchorEndIndex = curIndex;
|
|
4405
|
+
} else {
|
|
4406
|
+
anchorStartIndex = startIndex + 1;
|
|
4407
|
+
anchorEndIndex = endIndex;
|
|
4408
|
+
}
|
|
4306
4409
|
} else {
|
|
4307
|
-
|
|
4410
|
+
anchorStartIndex = startIndex;
|
|
4308
4411
|
}
|
|
4309
|
-
curIndex = isCollapsed ? index2 : startIndex;
|
|
4310
4412
|
}
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
} else if (evt.key === KeyMap.Enter) {
|
|
4314
|
-
if (isReadonly || isPartRangeInControlOutside)
|
|
4413
|
+
const maxElementListIndex = elementList.length - 1;
|
|
4414
|
+
if (anchorStartIndex > maxElementListIndex || anchorEndIndex > maxElementListIndex)
|
|
4315
4415
|
return;
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
}, restArg);
|
|
4325
|
-
let curIndex;
|
|
4326
|
-
if (activeControl) {
|
|
4327
|
-
curIndex = this.control.setValue([enterText]);
|
|
4328
|
-
} else {
|
|
4329
|
-
if (isCollapsed) {
|
|
4330
|
-
elementList.splice(index2 + 1, 0, enterText);
|
|
4331
|
-
} else {
|
|
4332
|
-
elementList.splice(startIndex + 1, endIndex - startIndex, enterText);
|
|
4333
|
-
}
|
|
4334
|
-
curIndex = index2 + 1;
|
|
4335
|
-
}
|
|
4336
|
-
this.range.setRange(curIndex, curIndex);
|
|
4337
|
-
this.draw.render({ curIndex });
|
|
4416
|
+
rangeManager.setRange(anchorStartIndex, anchorEndIndex);
|
|
4417
|
+
const isCollapsed2 = anchorStartIndex === anchorEndIndex;
|
|
4418
|
+
draw.render({
|
|
4419
|
+
curIndex: isCollapsed2 ? anchorStartIndex : void 0,
|
|
4420
|
+
isSetCursor: isCollapsed2,
|
|
4421
|
+
isSubmitHistory: false,
|
|
4422
|
+
isComputeRowList: false
|
|
4423
|
+
});
|
|
4338
4424
|
evt.preventDefault();
|
|
4339
|
-
}
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
}
|
|
4351
|
-
}
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
return;
|
|
4366
|
-
const { rowNo, index: index22, coordinate: { leftTop, rightTop } } = cursorPosition;
|
|
4367
|
-
if (evt.key === KeyMap.Up && rowNo !== 0 || evt.key === KeyMap.Down && rowNo !== this.draw.getRowCount()) {
|
|
4368
|
-
const probablePosition = evt.key === KeyMap.Up ? position.slice(0, index22).filter((p) => p.rowNo === rowNo - 1) : position.slice(index22, position.length - 1).filter((p) => p.rowNo === rowNo + 1);
|
|
4369
|
-
let maxIndex = 0;
|
|
4370
|
-
let maxDistance = 0;
|
|
4371
|
-
for (let p = 0; p < probablePosition.length; p++) {
|
|
4372
|
-
const position2 = probablePosition[p];
|
|
4373
|
-
if (position2.coordinate.leftTop[0] >= leftTop[0] && position2.coordinate.leftTop[0] <= rightTop[0]) {
|
|
4374
|
-
const curDistance = rightTop[0] - position2.coordinate.leftTop[0];
|
|
4375
|
-
if (curDistance > maxDistance) {
|
|
4376
|
-
maxIndex = position2.index;
|
|
4377
|
-
maxDistance = curDistance;
|
|
4378
|
-
}
|
|
4379
|
-
} else if (position2.coordinate.leftTop[0] <= leftTop[0] && position2.coordinate.rightTop[0] >= leftTop[0]) {
|
|
4380
|
-
const curDistance = position2.coordinate.rightTop[0] - leftTop[0];
|
|
4381
|
-
if (curDistance > maxDistance) {
|
|
4382
|
-
maxIndex = position2.index;
|
|
4383
|
-
maxDistance = curDistance;
|
|
4384
|
-
}
|
|
4425
|
+
}
|
|
4426
|
+
} else if (evt.key === KeyMap.Up || evt.key === KeyMap.Down) {
|
|
4427
|
+
if (isReadonly)
|
|
4428
|
+
return;
|
|
4429
|
+
let anchorPosition = cursorPosition;
|
|
4430
|
+
const isUp = evt.key === KeyMap.Up;
|
|
4431
|
+
if (evt.shiftKey) {
|
|
4432
|
+
if (startIndex === cursorPosition.index) {
|
|
4433
|
+
anchorPosition = positionList[endIndex];
|
|
4434
|
+
} else {
|
|
4435
|
+
anchorPosition = positionList[startIndex];
|
|
4436
|
+
}
|
|
4437
|
+
}
|
|
4438
|
+
const { rowNo, index: index22, pageNo, coordinate: { leftTop, rightTop } } = anchorPosition;
|
|
4439
|
+
if (isUp && rowNo !== 0 || !isUp && rowNo !== draw.getRowCount()) {
|
|
4440
|
+
const probablePosition = isUp ? positionList.slice(0, index22).filter((p) => p.rowNo === rowNo - 1 && pageNo === p.pageNo) : positionList.slice(index22, positionList.length - 1).filter((p) => p.rowNo === rowNo + 1 && pageNo === p.pageNo);
|
|
4441
|
+
let maxIndex = 0;
|
|
4442
|
+
let maxDistance = 0;
|
|
4443
|
+
for (let p = 0; p < probablePosition.length; p++) {
|
|
4444
|
+
const position2 = probablePosition[p];
|
|
4445
|
+
if (position2.coordinate.leftTop[0] >= leftTop[0] && position2.coordinate.leftTop[0] <= rightTop[0]) {
|
|
4446
|
+
const curDistance = rightTop[0] - position2.coordinate.leftTop[0];
|
|
4447
|
+
if (curDistance > maxDistance) {
|
|
4448
|
+
maxIndex = position2.index;
|
|
4449
|
+
maxDistance = curDistance;
|
|
4450
|
+
break;
|
|
4385
4451
|
}
|
|
4386
|
-
|
|
4452
|
+
} else if (position2.coordinate.leftTop[0] <= leftTop[0] && position2.coordinate.rightTop[0] >= leftTop[0]) {
|
|
4453
|
+
const curDistance = position2.coordinate.rightTop[0] - leftTop[0];
|
|
4454
|
+
if (curDistance > maxDistance) {
|
|
4387
4455
|
maxIndex = position2.index;
|
|
4456
|
+
maxDistance = curDistance;
|
|
4457
|
+
break;
|
|
4388
4458
|
}
|
|
4389
4459
|
}
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
curIndex,
|
|
4394
|
-
isSubmitHistory: false,
|
|
4395
|
-
isComputeRowList: false
|
|
4396
|
-
});
|
|
4397
|
-
}
|
|
4398
|
-
} else if (evt.ctrlKey && evt.key === KeyMap.Z) {
|
|
4399
|
-
if (isReadonly)
|
|
4400
|
-
return;
|
|
4401
|
-
this.historyManager.undo();
|
|
4402
|
-
evt.preventDefault();
|
|
4403
|
-
} else if (evt.ctrlKey && evt.key === KeyMap.Y) {
|
|
4404
|
-
if (isReadonly)
|
|
4405
|
-
return;
|
|
4406
|
-
this.historyManager.redo();
|
|
4407
|
-
evt.preventDefault();
|
|
4408
|
-
} else if (evt.ctrlKey && evt.key === KeyMap.C) {
|
|
4409
|
-
this.copy();
|
|
4410
|
-
evt.preventDefault();
|
|
4411
|
-
} else if (evt.ctrlKey && evt.key === KeyMap.X) {
|
|
4412
|
-
this.cut();
|
|
4413
|
-
evt.preventDefault();
|
|
4414
|
-
} else if (evt.ctrlKey && evt.key === KeyMap.A) {
|
|
4415
|
-
this.selectAll();
|
|
4416
|
-
evt.preventDefault();
|
|
4417
|
-
} else if (evt.ctrlKey && evt.key === KeyMap.S) {
|
|
4418
|
-
if (isReadonly)
|
|
4419
|
-
return;
|
|
4420
|
-
if (this.listener.saved) {
|
|
4421
|
-
this.listener.saved(this.draw.getValue());
|
|
4460
|
+
if (p === probablePosition.length - 1 && maxIndex === 0) {
|
|
4461
|
+
maxIndex = position2.index;
|
|
4462
|
+
}
|
|
4422
4463
|
}
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
evt.
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
}
|
|
4434
|
-
}
|
|
4435
|
-
dblclick() {
|
|
4436
|
-
const cursorPosition = this.position.getCursorPosition();
|
|
4437
|
-
if (!cursorPosition)
|
|
4438
|
-
return;
|
|
4439
|
-
const { value, index: index2 } = cursorPosition;
|
|
4440
|
-
const elementList = this.draw.getElementList();
|
|
4441
|
-
let upCount = 0;
|
|
4442
|
-
let downCount = 0;
|
|
4443
|
-
const isNumber = NUMBER_LIKE_REG.test(value);
|
|
4444
|
-
if (isNumber || LETTER_REG.test(value)) {
|
|
4445
|
-
let upStartIndex = index2 - 1;
|
|
4446
|
-
while (upStartIndex > 0) {
|
|
4447
|
-
const value2 = elementList[upStartIndex].value;
|
|
4448
|
-
if (isNumber && NUMBER_LIKE_REG.test(value2) || !isNumber && LETTER_REG.test(value2)) {
|
|
4449
|
-
upCount++;
|
|
4450
|
-
upStartIndex--;
|
|
4464
|
+
const curIndex = maxIndex;
|
|
4465
|
+
let anchorStartIndex = curIndex;
|
|
4466
|
+
let anchorEndIndex = curIndex;
|
|
4467
|
+
if (evt.shiftKey) {
|
|
4468
|
+
if (startIndex !== endIndex) {
|
|
4469
|
+
if (startIndex === cursorPosition.index) {
|
|
4470
|
+
anchorStartIndex = startIndex;
|
|
4471
|
+
} else {
|
|
4472
|
+
anchorEndIndex = endIndex;
|
|
4473
|
+
}
|
|
4451
4474
|
} else {
|
|
4452
|
-
|
|
4475
|
+
if (isUp) {
|
|
4476
|
+
anchorEndIndex = endIndex;
|
|
4477
|
+
} else {
|
|
4478
|
+
anchorStartIndex = startIndex;
|
|
4479
|
+
}
|
|
4453
4480
|
}
|
|
4454
4481
|
}
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4482
|
+
if (anchorStartIndex > anchorEndIndex) {
|
|
4483
|
+
[anchorStartIndex, anchorEndIndex] = [anchorEndIndex, anchorStartIndex];
|
|
4484
|
+
}
|
|
4485
|
+
rangeManager.setRange(anchorStartIndex, anchorEndIndex);
|
|
4486
|
+
const isCollapsed2 = anchorStartIndex === anchorEndIndex;
|
|
4487
|
+
draw.render({
|
|
4488
|
+
curIndex: isCollapsed2 ? anchorStartIndex : void 0,
|
|
4489
|
+
isSetCursor: isCollapsed2,
|
|
4490
|
+
isSubmitHistory: false,
|
|
4491
|
+
isComputeRowList: false
|
|
4492
|
+
});
|
|
4493
|
+
}
|
|
4494
|
+
} else if (evt.ctrlKey && evt.key === KeyMap.Z) {
|
|
4495
|
+
if (isReadonly)
|
|
4496
|
+
return;
|
|
4497
|
+
historyManager.undo();
|
|
4498
|
+
evt.preventDefault();
|
|
4499
|
+
} else if (evt.ctrlKey && evt.key === KeyMap.Y) {
|
|
4500
|
+
if (isReadonly)
|
|
4501
|
+
return;
|
|
4502
|
+
historyManager.redo();
|
|
4503
|
+
evt.preventDefault();
|
|
4504
|
+
} else if (evt.ctrlKey && evt.key === KeyMap.C) {
|
|
4505
|
+
host.copy();
|
|
4506
|
+
evt.preventDefault();
|
|
4507
|
+
} else if (evt.ctrlKey && evt.key === KeyMap.X) {
|
|
4508
|
+
host.cut();
|
|
4509
|
+
evt.preventDefault();
|
|
4510
|
+
} else if (evt.ctrlKey && evt.key === KeyMap.A) {
|
|
4511
|
+
host.selectAll();
|
|
4512
|
+
evt.preventDefault();
|
|
4513
|
+
} else if (evt.ctrlKey && evt.key === KeyMap.S) {
|
|
4514
|
+
if (isReadonly)
|
|
4515
|
+
return;
|
|
4516
|
+
const listener = draw.getListener();
|
|
4517
|
+
if (listener.saved) {
|
|
4518
|
+
listener.saved(draw.getValue());
|
|
4519
|
+
}
|
|
4520
|
+
evt.preventDefault();
|
|
4521
|
+
} else if (evt.key === KeyMap.ESC) {
|
|
4522
|
+
host.clearPainterStyle();
|
|
4523
|
+
evt.preventDefault();
|
|
4524
|
+
} else if (evt.key === KeyMap.TAB) {
|
|
4525
|
+
draw.insertElementList([{
|
|
4526
|
+
type: ElementType.TAB,
|
|
4527
|
+
value: ""
|
|
4528
|
+
}]);
|
|
4529
|
+
evt.preventDefault();
|
|
4530
|
+
}
|
|
4531
|
+
}
|
|
4532
|
+
function input(data2, host) {
|
|
4533
|
+
var _a;
|
|
4534
|
+
const draw = host.getDraw();
|
|
4535
|
+
const isReadonly = draw.isReadonly();
|
|
4536
|
+
if (isReadonly)
|
|
4537
|
+
return;
|
|
4538
|
+
const position = draw.getPosition();
|
|
4539
|
+
const cursorPosition = position.getCursorPosition();
|
|
4540
|
+
if (!data2 || !cursorPosition || host.isCompositing)
|
|
4541
|
+
return;
|
|
4542
|
+
const control = draw.getControl();
|
|
4543
|
+
if (control.isPartRangeInControlOutside()) {
|
|
4544
|
+
return;
|
|
4545
|
+
}
|
|
4546
|
+
const activeControl = control.getActiveControl();
|
|
4547
|
+
const { TEXT, HYPERLINK, SUBSCRIPT, SUPERSCRIPT, DATE } = ElementType;
|
|
4548
|
+
const text = data2.replaceAll(`
|
|
4549
|
+
`, ZERO);
|
|
4550
|
+
const cursor = draw.getCursor();
|
|
4551
|
+
const agentDom = cursor.getAgentDom();
|
|
4552
|
+
agentDom.value = "";
|
|
4553
|
+
const { index: index2 } = cursorPosition;
|
|
4554
|
+
const rangeManager = draw.getRange();
|
|
4555
|
+
const { startIndex, endIndex } = rangeManager.getRange();
|
|
4556
|
+
const isCollapsed = startIndex === endIndex;
|
|
4557
|
+
const positionContext = position.getPositionContext();
|
|
4558
|
+
let restArg = {};
|
|
4559
|
+
if (positionContext.isTable) {
|
|
4560
|
+
const { tdId, trId, tableId } = positionContext;
|
|
4561
|
+
restArg = { tdId, trId, tableId };
|
|
4562
|
+
}
|
|
4563
|
+
const elementList = draw.getElementList();
|
|
4564
|
+
const element = elementList[endIndex];
|
|
4565
|
+
const inputData = splitText(text).map((value) => {
|
|
4566
|
+
const newElement = __spreadValues({
|
|
4567
|
+
value
|
|
4568
|
+
}, restArg);
|
|
4569
|
+
const nextElement = elementList[endIndex + 1];
|
|
4570
|
+
if (element.type === TEXT || !element.type && element.value !== ZERO || element.type === HYPERLINK && (nextElement == null ? void 0 : nextElement.type) === HYPERLINK || element.type === DATE && (nextElement == null ? void 0 : nextElement.type) === DATE || element.type === SUBSCRIPT && (nextElement == null ? void 0 : nextElement.type) === SUBSCRIPT || element.type === SUPERSCRIPT && (nextElement == null ? void 0 : nextElement.type) === SUPERSCRIPT) {
|
|
4571
|
+
EDITOR_ELEMENT_COPY_ATTR.forEach((attr) => {
|
|
4572
|
+
const value2 = element[attr];
|
|
4573
|
+
if (value2 !== void 0) {
|
|
4574
|
+
newElement[attr] = value2;
|
|
4463
4575
|
}
|
|
4576
|
+
});
|
|
4577
|
+
}
|
|
4578
|
+
return newElement;
|
|
4579
|
+
});
|
|
4580
|
+
let curIndex;
|
|
4581
|
+
if (activeControl && ((_a = elementList[endIndex + 1]) == null ? void 0 : _a.controlId) === element.controlId) {
|
|
4582
|
+
curIndex = control.setValue(inputData);
|
|
4583
|
+
} else {
|
|
4584
|
+
let start = 0;
|
|
4585
|
+
if (isCollapsed) {
|
|
4586
|
+
start = index2 + 1;
|
|
4587
|
+
} else {
|
|
4588
|
+
start = startIndex + 1;
|
|
4589
|
+
elementList.splice(startIndex + 1, endIndex - startIndex);
|
|
4590
|
+
}
|
|
4591
|
+
for (let i = 0; i < inputData.length; i++) {
|
|
4592
|
+
elementList.splice(start + i, 0, inputData[i]);
|
|
4593
|
+
}
|
|
4594
|
+
curIndex = (isCollapsed ? index2 : startIndex) + inputData.length;
|
|
4595
|
+
}
|
|
4596
|
+
rangeManager.setRange(curIndex, curIndex);
|
|
4597
|
+
draw.render({ curIndex });
|
|
4598
|
+
}
|
|
4599
|
+
function cut(host) {
|
|
4600
|
+
const draw = host.getDraw();
|
|
4601
|
+
const rangeManager = draw.getRange();
|
|
4602
|
+
const { startIndex, endIndex } = rangeManager.getRange();
|
|
4603
|
+
if (!~startIndex && !~startIndex)
|
|
4604
|
+
return;
|
|
4605
|
+
const isReadonly = draw.isReadonly();
|
|
4606
|
+
if (isReadonly)
|
|
4607
|
+
return;
|
|
4608
|
+
const control = draw.getControl();
|
|
4609
|
+
const isPartRangeInControlOutside = control.isPartRangeInControlOutside();
|
|
4610
|
+
if (isPartRangeInControlOutside)
|
|
4611
|
+
return;
|
|
4612
|
+
const activeControl = control.getActiveControl();
|
|
4613
|
+
const elementList = draw.getElementList();
|
|
4614
|
+
let start = startIndex;
|
|
4615
|
+
let end = endIndex;
|
|
4616
|
+
if (startIndex === endIndex) {
|
|
4617
|
+
const position = draw.getPosition();
|
|
4618
|
+
const positionList = position.getPositionList();
|
|
4619
|
+
const startPosition = positionList[startIndex];
|
|
4620
|
+
const curRowNo = startPosition.rowNo;
|
|
4621
|
+
const curPageNo = startPosition.pageNo;
|
|
4622
|
+
const cutElementIndexList = [];
|
|
4623
|
+
for (let p = 0; p < positionList.length; p++) {
|
|
4624
|
+
const position2 = positionList[p];
|
|
4625
|
+
if (position2.pageNo > curPageNo)
|
|
4626
|
+
break;
|
|
4627
|
+
if (position2.pageNo === curPageNo && position2.rowNo === curRowNo) {
|
|
4628
|
+
cutElementIndexList.push(p);
|
|
4464
4629
|
}
|
|
4465
4630
|
}
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
isSetCursor: false,
|
|
4470
|
-
isComputeRowList: false
|
|
4471
|
-
});
|
|
4631
|
+
const firstElementIndex = cutElementIndexList[0] - 1;
|
|
4632
|
+
start = firstElementIndex < 0 ? 0 : firstElementIndex;
|
|
4633
|
+
end = cutElementIndexList[cutElementIndexList.length - 1];
|
|
4472
4634
|
}
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4635
|
+
const options = draw.getOptions();
|
|
4636
|
+
writeElementList(elementList.slice(start + 1, end + 1), options);
|
|
4637
|
+
let curIndex;
|
|
4638
|
+
if (activeControl) {
|
|
4639
|
+
curIndex = control.cut();
|
|
4640
|
+
} else {
|
|
4641
|
+
elementList.splice(start + 1, end - start);
|
|
4642
|
+
curIndex = start;
|
|
4643
|
+
}
|
|
4644
|
+
rangeManager.setRange(curIndex, curIndex);
|
|
4645
|
+
draw.render({ curIndex });
|
|
4646
|
+
}
|
|
4647
|
+
function copy(host) {
|
|
4648
|
+
const draw = host.getDraw();
|
|
4649
|
+
const rangeManager = draw.getRange();
|
|
4650
|
+
const { startIndex, endIndex } = rangeManager.getRange();
|
|
4651
|
+
if (startIndex !== endIndex) {
|
|
4652
|
+
const options = draw.getOptions();
|
|
4653
|
+
const elementList = draw.getElementList();
|
|
4654
|
+
writeElementList(elementList.slice(startIndex + 1, endIndex + 1), options);
|
|
4655
|
+
}
|
|
4656
|
+
}
|
|
4657
|
+
function drop(evt, host) {
|
|
4658
|
+
var _a;
|
|
4659
|
+
evt.preventDefault();
|
|
4660
|
+
const data2 = (_a = evt.dataTransfer) == null ? void 0 : _a.getData("text");
|
|
4661
|
+
if (data2) {
|
|
4662
|
+
host.input(data2);
|
|
4663
|
+
}
|
|
4664
|
+
}
|
|
4665
|
+
const LETTER_REG = /[a-zA-Z]/;
|
|
4666
|
+
const NUMBER_LIKE_REG = /[0-9.]/;
|
|
4667
|
+
function dblclick(host) {
|
|
4668
|
+
const draw = host.getDraw();
|
|
4669
|
+
const position = draw.getPosition();
|
|
4670
|
+
const cursorPosition = position.getCursorPosition();
|
|
4671
|
+
if (!cursorPosition)
|
|
4672
|
+
return;
|
|
4673
|
+
const { value, index: index2 } = cursorPosition;
|
|
4674
|
+
let upCount = 0;
|
|
4675
|
+
let downCount = 0;
|
|
4676
|
+
const isNumber = NUMBER_LIKE_REG.test(value);
|
|
4677
|
+
if (isNumber || LETTER_REG.test(value)) {
|
|
4678
|
+
const elementList = draw.getElementList();
|
|
4481
4679
|
let upStartIndex = index2 - 1;
|
|
4482
4680
|
while (upStartIndex > 0) {
|
|
4483
|
-
const
|
|
4484
|
-
if (
|
|
4681
|
+
const value2 = elementList[upStartIndex].value;
|
|
4682
|
+
if (isNumber && NUMBER_LIKE_REG.test(value2) || !isNumber && LETTER_REG.test(value2)) {
|
|
4485
4683
|
upCount++;
|
|
4486
4684
|
upStartIndex--;
|
|
4487
4685
|
} else {
|
|
@@ -4490,113 +4688,184 @@ class CanvasEvent {
|
|
|
4490
4688
|
}
|
|
4491
4689
|
let downStartIndex = index2 + 1;
|
|
4492
4690
|
while (downStartIndex < elementList.length) {
|
|
4493
|
-
const
|
|
4494
|
-
if (
|
|
4691
|
+
const value2 = elementList[downStartIndex].value;
|
|
4692
|
+
if (isNumber && NUMBER_LIKE_REG.test(value2) || !isNumber && LETTER_REG.test(value2)) {
|
|
4495
4693
|
downCount++;
|
|
4496
4694
|
downStartIndex++;
|
|
4497
4695
|
} else {
|
|
4498
4696
|
break;
|
|
4499
4697
|
}
|
|
4500
4698
|
}
|
|
4501
|
-
this.range.setRange(index2 - upCount - 1, index2 + downCount);
|
|
4502
|
-
this.draw.render({
|
|
4503
|
-
isSubmitHistory: false,
|
|
4504
|
-
isSetCursor: false,
|
|
4505
|
-
isComputeRowList: false
|
|
4506
|
-
});
|
|
4507
4699
|
}
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
const
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
const { tdId, trId, tableId } = positionContext;
|
|
4535
|
-
restArg = { tdId, trId, tableId };
|
|
4700
|
+
const rangeManager = draw.getRange();
|
|
4701
|
+
rangeManager.setRange(index2 - upCount - 1, index2 + downCount);
|
|
4702
|
+
draw.render({
|
|
4703
|
+
isSubmitHistory: false,
|
|
4704
|
+
isSetCursor: false,
|
|
4705
|
+
isComputeRowList: false
|
|
4706
|
+
});
|
|
4707
|
+
}
|
|
4708
|
+
function threeClick(host) {
|
|
4709
|
+
const draw = host.getDraw();
|
|
4710
|
+
const position = draw.getPosition();
|
|
4711
|
+
const cursorPosition = position.getCursorPosition();
|
|
4712
|
+
if (!cursorPosition)
|
|
4713
|
+
return;
|
|
4714
|
+
const { index: index2 } = cursorPosition;
|
|
4715
|
+
const elementList = draw.getElementList();
|
|
4716
|
+
let upCount = 0;
|
|
4717
|
+
let downCount = 0;
|
|
4718
|
+
let upStartIndex = index2 - 1;
|
|
4719
|
+
while (upStartIndex > 0) {
|
|
4720
|
+
const value = elementList[upStartIndex].value;
|
|
4721
|
+
if (value !== ZERO) {
|
|
4722
|
+
upCount++;
|
|
4723
|
+
upStartIndex--;
|
|
4724
|
+
} else {
|
|
4725
|
+
break;
|
|
4536
4726
|
}
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
EDITOR_ELEMENT_COPY_ATTR.forEach((attr) => {
|
|
4545
|
-
const value2 = element[attr];
|
|
4546
|
-
if (value2 !== void 0) {
|
|
4547
|
-
newElement[attr] = value2;
|
|
4548
|
-
}
|
|
4549
|
-
});
|
|
4550
|
-
}
|
|
4551
|
-
return newElement;
|
|
4552
|
-
});
|
|
4553
|
-
let curIndex;
|
|
4554
|
-
if (activeControl && ((_a = elementList[endIndex + 1]) == null ? void 0 : _a.controlId) === element.controlId) {
|
|
4555
|
-
curIndex = this.control.setValue(inputData);
|
|
4727
|
+
}
|
|
4728
|
+
let downStartIndex = index2 + 1;
|
|
4729
|
+
while (downStartIndex < elementList.length) {
|
|
4730
|
+
const value = elementList[downStartIndex].value;
|
|
4731
|
+
if (value !== ZERO) {
|
|
4732
|
+
downCount++;
|
|
4733
|
+
downStartIndex++;
|
|
4556
4734
|
} else {
|
|
4557
|
-
|
|
4558
|
-
if (isCollapsed) {
|
|
4559
|
-
start = index2 + 1;
|
|
4560
|
-
} else {
|
|
4561
|
-
start = startIndex + 1;
|
|
4562
|
-
elementList.splice(startIndex + 1, endIndex - startIndex);
|
|
4563
|
-
}
|
|
4564
|
-
for (let i = 0; i < inputData.length; i++) {
|
|
4565
|
-
elementList.splice(start + i, 0, inputData[i]);
|
|
4566
|
-
}
|
|
4567
|
-
curIndex = (isCollapsed ? index2 : startIndex) + inputData.length;
|
|
4735
|
+
break;
|
|
4568
4736
|
}
|
|
4569
|
-
this.range.setRange(curIndex, curIndex);
|
|
4570
|
-
this.draw.render({ curIndex });
|
|
4571
4737
|
}
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4738
|
+
const rangeManager = draw.getRange();
|
|
4739
|
+
rangeManager.setRange(index2 - upCount - 1, index2 + downCount);
|
|
4740
|
+
draw.render({
|
|
4741
|
+
isSubmitHistory: false,
|
|
4742
|
+
isSetCursor: false,
|
|
4743
|
+
isComputeRowList: false
|
|
4744
|
+
});
|
|
4745
|
+
}
|
|
4746
|
+
var click = {
|
|
4747
|
+
dblclick,
|
|
4748
|
+
threeClick
|
|
4749
|
+
};
|
|
4750
|
+
function compositionstart(host) {
|
|
4751
|
+
host.isCompositing = true;
|
|
4752
|
+
}
|
|
4753
|
+
function compositionend(host) {
|
|
4754
|
+
host.isCompositing = false;
|
|
4755
|
+
}
|
|
4756
|
+
var composition = {
|
|
4757
|
+
compositionstart,
|
|
4758
|
+
compositionend
|
|
4759
|
+
};
|
|
4760
|
+
function dragover(evt, host) {
|
|
4761
|
+
const draw = host.getDraw();
|
|
4762
|
+
const isReadonly = draw.isReadonly();
|
|
4763
|
+
if (isReadonly)
|
|
4764
|
+
return;
|
|
4765
|
+
evt.preventDefault();
|
|
4766
|
+
const pageContainer = draw.getPageContainer();
|
|
4767
|
+
const editorRegion = findParent(evt.target, (node) => node === pageContainer, true);
|
|
4768
|
+
if (!editorRegion)
|
|
4769
|
+
return;
|
|
4770
|
+
const target = evt.target;
|
|
4771
|
+
const pageIndex = target.dataset.index;
|
|
4772
|
+
if (pageIndex) {
|
|
4773
|
+
draw.setPageNo(Number(pageIndex));
|
|
4774
|
+
}
|
|
4775
|
+
const position = draw.getPosition();
|
|
4776
|
+
const { isTable, tdValueIndex, index: index2 } = position.adjustPositionContext({
|
|
4777
|
+
x: evt.offsetX,
|
|
4778
|
+
y: evt.offsetY
|
|
4779
|
+
});
|
|
4780
|
+
const positionList = position.getPositionList();
|
|
4781
|
+
const curIndex = isTable ? tdValueIndex : index2;
|
|
4782
|
+
if (~index2) {
|
|
4783
|
+
const rangeManager = draw.getRange();
|
|
4784
|
+
rangeManager.setRange(curIndex, curIndex);
|
|
4785
|
+
position.setCursorPosition(positionList[curIndex]);
|
|
4786
|
+
}
|
|
4787
|
+
const cursor = draw.getCursor();
|
|
4788
|
+
cursor.drawCursor();
|
|
4789
|
+
}
|
|
4790
|
+
var drag = {
|
|
4791
|
+
dragover
|
|
4792
|
+
};
|
|
4793
|
+
class CanvasEvent {
|
|
4794
|
+
constructor(draw) {
|
|
4795
|
+
__publicField(this, "isAllowSelection");
|
|
4796
|
+
__publicField(this, "isCompositing");
|
|
4797
|
+
__publicField(this, "isAllowDrag");
|
|
4798
|
+
__publicField(this, "isAllowDrop");
|
|
4799
|
+
__publicField(this, "cacheRange");
|
|
4800
|
+
__publicField(this, "cacheElementList");
|
|
4801
|
+
__publicField(this, "cachePositionList");
|
|
4802
|
+
__publicField(this, "mouseDownStartPosition");
|
|
4803
|
+
__publicField(this, "draw");
|
|
4804
|
+
__publicField(this, "pageContainer");
|
|
4805
|
+
__publicField(this, "pageList");
|
|
4806
|
+
__publicField(this, "range");
|
|
4807
|
+
__publicField(this, "position");
|
|
4808
|
+
this.draw = draw;
|
|
4809
|
+
this.pageContainer = draw.getPageContainer();
|
|
4810
|
+
this.pageList = draw.getPageList();
|
|
4811
|
+
this.range = this.draw.getRange();
|
|
4812
|
+
this.position = this.draw.getPosition();
|
|
4813
|
+
this.isAllowSelection = false;
|
|
4814
|
+
this.isCompositing = false;
|
|
4815
|
+
this.isAllowDrag = false;
|
|
4816
|
+
this.isAllowDrop = false;
|
|
4817
|
+
this.cacheRange = null;
|
|
4818
|
+
this.cacheElementList = null;
|
|
4819
|
+
this.cachePositionList = null;
|
|
4820
|
+
this.mouseDownStartPosition = null;
|
|
4821
|
+
}
|
|
4822
|
+
getDraw() {
|
|
4823
|
+
return this.draw;
|
|
4824
|
+
}
|
|
4825
|
+
register() {
|
|
4826
|
+
this.pageContainer.addEventListener("mousedown", this.mousedown.bind(this));
|
|
4827
|
+
this.pageContainer.addEventListener("mouseup", this.mouseup.bind(this));
|
|
4828
|
+
this.pageContainer.addEventListener("mouseleave", this.mouseleave.bind(this));
|
|
4829
|
+
this.pageContainer.addEventListener("mousemove", this.mousemove.bind(this));
|
|
4830
|
+
this.pageContainer.addEventListener("dblclick", this.dblclick.bind(this));
|
|
4831
|
+
this.pageContainer.addEventListener("dragover", this.dragover.bind(this));
|
|
4832
|
+
this.pageContainer.addEventListener("drop", this.drop.bind(this));
|
|
4833
|
+
threeClick$1(this.pageContainer, this.threeClick.bind(this));
|
|
4834
|
+
}
|
|
4835
|
+
setIsAllowSelection(payload) {
|
|
4836
|
+
this.isAllowSelection = payload;
|
|
4837
|
+
if (!payload) {
|
|
4838
|
+
this.applyPainterStyle();
|
|
4593
4839
|
}
|
|
4594
4840
|
}
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4841
|
+
setIsAllowDrag(payload) {
|
|
4842
|
+
this.isAllowDrag = payload;
|
|
4843
|
+
this.isAllowDrop = payload;
|
|
4844
|
+
}
|
|
4845
|
+
clearPainterStyle() {
|
|
4846
|
+
this.pageList.forEach((p) => {
|
|
4847
|
+
p.style.cursor = "text";
|
|
4848
|
+
});
|
|
4849
|
+
this.draw.setPainterStyle(null);
|
|
4850
|
+
}
|
|
4851
|
+
applyPainterStyle() {
|
|
4852
|
+
const painterStyle = this.draw.getPainterStyle();
|
|
4853
|
+
if (!painterStyle)
|
|
4854
|
+
return;
|
|
4855
|
+
const selection = this.range.getSelection();
|
|
4856
|
+
if (!selection)
|
|
4857
|
+
return;
|
|
4858
|
+
const painterStyleKeys = Object.keys(painterStyle);
|
|
4859
|
+
selection.forEach((s) => {
|
|
4860
|
+
painterStyleKeys.forEach((pKey) => {
|
|
4861
|
+
const key = pKey;
|
|
4862
|
+
s[key] = painterStyle[key];
|
|
4863
|
+
});
|
|
4864
|
+
});
|
|
4865
|
+
this.draw.render({ isSetCursor: false });
|
|
4866
|
+
const painterOptions = this.draw.getPainterOptions();
|
|
4867
|
+
if (!painterOptions || !painterOptions.isDblclick) {
|
|
4868
|
+
this.clearPainterStyle();
|
|
4600
4869
|
}
|
|
4601
4870
|
}
|
|
4602
4871
|
selectAll() {
|
|
@@ -4608,11 +4877,47 @@ class CanvasEvent {
|
|
|
4608
4877
|
isComputeRowList: false
|
|
4609
4878
|
});
|
|
4610
4879
|
}
|
|
4880
|
+
mousemove(evt) {
|
|
4881
|
+
mousemove(evt, this);
|
|
4882
|
+
}
|
|
4883
|
+
mousedown(evt) {
|
|
4884
|
+
mousedown(evt, this);
|
|
4885
|
+
}
|
|
4886
|
+
mouseup(evt) {
|
|
4887
|
+
mouseup(evt, this);
|
|
4888
|
+
}
|
|
4889
|
+
mouseleave(evt) {
|
|
4890
|
+
mouseleave(evt, this);
|
|
4891
|
+
}
|
|
4892
|
+
keydown(evt) {
|
|
4893
|
+
keydown(evt, this);
|
|
4894
|
+
}
|
|
4895
|
+
dblclick() {
|
|
4896
|
+
click.dblclick(this);
|
|
4897
|
+
}
|
|
4898
|
+
threeClick() {
|
|
4899
|
+
click.threeClick(this);
|
|
4900
|
+
}
|
|
4901
|
+
input(data2) {
|
|
4902
|
+
input(data2, this);
|
|
4903
|
+
}
|
|
4904
|
+
cut() {
|
|
4905
|
+
cut(this);
|
|
4906
|
+
}
|
|
4907
|
+
copy() {
|
|
4908
|
+
copy(this);
|
|
4909
|
+
}
|
|
4611
4910
|
compositionstart() {
|
|
4612
|
-
this
|
|
4911
|
+
composition.compositionstart(this);
|
|
4613
4912
|
}
|
|
4614
4913
|
compositionend() {
|
|
4615
|
-
this
|
|
4914
|
+
composition.compositionend(this);
|
|
4915
|
+
}
|
|
4916
|
+
drop(evt) {
|
|
4917
|
+
drop(evt, this);
|
|
4918
|
+
}
|
|
4919
|
+
dragover(evt) {
|
|
4920
|
+
drag.dragover(evt, this);
|
|
4616
4921
|
}
|
|
4617
4922
|
}
|
|
4618
4923
|
class GlobalEvent {
|
|
@@ -4651,8 +4956,9 @@ class GlobalEvent {
|
|
|
4651
4956
|
this.control.destroyControl();
|
|
4652
4957
|
this.dateParticle.clearDatePicker();
|
|
4653
4958
|
});
|
|
4654
|
-
__publicField(this, "
|
|
4959
|
+
__publicField(this, "setCanvasEventAbility", () => {
|
|
4655
4960
|
this.canvasEvent.setIsAllowDrag(false);
|
|
4961
|
+
this.canvasEvent.setIsAllowSelection(false);
|
|
4656
4962
|
});
|
|
4657
4963
|
__publicField(this, "setRangeStyle", () => {
|
|
4658
4964
|
this.range.setRangeStyle();
|
|
@@ -4700,7 +5006,7 @@ class GlobalEvent {
|
|
|
4700
5006
|
window.addEventListener("blur", this.recoverEffect);
|
|
4701
5007
|
document.addEventListener("keyup", this.setRangeStyle);
|
|
4702
5008
|
document.addEventListener("click", this.recoverEffect);
|
|
4703
|
-
document.addEventListener("mouseup", this.
|
|
5009
|
+
document.addEventListener("mouseup", this.setCanvasEventAbility);
|
|
4704
5010
|
document.addEventListener("wheel", this.setPageScale, { passive: false });
|
|
4705
5011
|
document.addEventListener("visibilitychange", this._handleVisibilityChange);
|
|
4706
5012
|
}
|
|
@@ -4708,7 +5014,7 @@ class GlobalEvent {
|
|
|
4708
5014
|
window.removeEventListener("blur", this.recoverEffect);
|
|
4709
5015
|
document.removeEventListener("keyup", this.setRangeStyle);
|
|
4710
5016
|
document.removeEventListener("click", this.recoverEffect);
|
|
4711
|
-
document.removeEventListener("mouseup", this.
|
|
5017
|
+
document.removeEventListener("mouseup", this.setCanvasEventAbility);
|
|
4712
5018
|
document.removeEventListener("wheel", this.setPageScale);
|
|
4713
5019
|
document.removeEventListener("visibilitychange", this._handleVisibilityChange);
|
|
4714
5020
|
}
|
|
@@ -4915,6 +5221,43 @@ class Position {
|
|
|
4915
5221
|
isControl: ((_b = elementList[curPositionIndex]) == null ? void 0 : _b.type) === ElementType.CONTROL
|
|
4916
5222
|
};
|
|
4917
5223
|
}
|
|
5224
|
+
adjustPositionContext(payload) {
|
|
5225
|
+
const isReadonly = this.draw.isReadonly();
|
|
5226
|
+
const { x, y } = payload;
|
|
5227
|
+
const positionResult = this.getPositionByXY({
|
|
5228
|
+
x,
|
|
5229
|
+
y
|
|
5230
|
+
});
|
|
5231
|
+
if (positionResult.isControl && !isReadonly) {
|
|
5232
|
+
const { index: index22, isTable: isTable2, trIndex: trIndex2, tdIndex: tdIndex2, tdValueIndex } = positionResult;
|
|
5233
|
+
const control = this.draw.getControl();
|
|
5234
|
+
const { newIndex } = control.moveCursor({
|
|
5235
|
+
index: index22,
|
|
5236
|
+
isTable: isTable2,
|
|
5237
|
+
trIndex: trIndex2,
|
|
5238
|
+
tdIndex: tdIndex2,
|
|
5239
|
+
tdValueIndex
|
|
5240
|
+
});
|
|
5241
|
+
if (isTable2) {
|
|
5242
|
+
positionResult.tdValueIndex = newIndex;
|
|
5243
|
+
} else {
|
|
5244
|
+
positionResult.index = newIndex;
|
|
5245
|
+
}
|
|
5246
|
+
}
|
|
5247
|
+
const { index: index2, isCheckbox, isControl, isTable, trIndex, tdIndex, tdId, trId, tableId } = positionResult;
|
|
5248
|
+
this.setPositionContext({
|
|
5249
|
+
isTable: isTable || false,
|
|
5250
|
+
isCheckbox: isCheckbox || false,
|
|
5251
|
+
isControl: isControl || false,
|
|
5252
|
+
index: index2,
|
|
5253
|
+
trIndex,
|
|
5254
|
+
tdIndex,
|
|
5255
|
+
tdId,
|
|
5256
|
+
trId,
|
|
5257
|
+
tableId
|
|
5258
|
+
});
|
|
5259
|
+
return positionResult;
|
|
5260
|
+
}
|
|
4918
5261
|
}
|
|
4919
5262
|
class RangeManager {
|
|
4920
5263
|
constructor(draw) {
|
|
@@ -4963,6 +5306,17 @@ class RangeManager {
|
|
|
4963
5306
|
}
|
|
4964
5307
|
return rangeRow;
|
|
4965
5308
|
}
|
|
5309
|
+
getIsPointInRange(x, y) {
|
|
5310
|
+
const { startIndex, endIndex } = this.range;
|
|
5311
|
+
const positionList = this.position.getPositionList();
|
|
5312
|
+
for (let p = startIndex + 1; p <= endIndex; p++) {
|
|
5313
|
+
const { coordinate: { leftTop, rightBottom } } = positionList[p];
|
|
5314
|
+
if (x >= leftTop[0] && x <= rightBottom[0] && y >= leftTop[1] && y <= rightBottom[1]) {
|
|
5315
|
+
return true;
|
|
5316
|
+
}
|
|
5317
|
+
}
|
|
5318
|
+
return false;
|
|
5319
|
+
}
|
|
4966
5320
|
setRange(startIndex, endIndex, tableId, startTdIndex, endTdIndex, startTrIndex, endTrIndex) {
|
|
4967
5321
|
this.range.startIndex = startIndex;
|
|
4968
5322
|
this.range.endIndex = endIndex;
|
|
@@ -5234,6 +5588,7 @@ class Margin {
|
|
|
5234
5588
|
const margins = this.draw.getMargins();
|
|
5235
5589
|
const marginIndicatorSize = this.draw.getMarginIndicatorSize();
|
|
5236
5590
|
ctx.save();
|
|
5591
|
+
ctx.translate(0.5, 0.5);
|
|
5237
5592
|
ctx.strokeStyle = marginIndicatorColor;
|
|
5238
5593
|
ctx.beginPath();
|
|
5239
5594
|
const leftTopPoint = [margins[3], margins[0]];
|
|
@@ -10714,7 +11069,7 @@ const globalMenus = [
|
|
|
10714
11069
|
name: "\u526A\u5207",
|
|
10715
11070
|
shortCut: "Ctrl + X",
|
|
10716
11071
|
when: (payload) => {
|
|
10717
|
-
return !payload.isReadonly
|
|
11072
|
+
return !payload.isReadonly;
|
|
10718
11073
|
},
|
|
10719
11074
|
callback: (command) => {
|
|
10720
11075
|
command.executeCut();
|