@hufe921/canvas-editor 0.9.10 → 0.9.11
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 +5 -4
- package/dist/canvas-editor.es.js +764 -502
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +17 -17
- 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 +1 -1
package/dist/canvas-editor.es.js
CHANGED
|
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23
23
|
return value;
|
|
24
24
|
};
|
|
25
25
|
var index = "";
|
|
26
|
-
const version = "0.9.
|
|
26
|
+
const version = "0.9.11";
|
|
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) {
|
|
@@ -3947,8 +3947,6 @@ var KeyMap;
|
|
|
3947
3947
|
KeyMap2["EIGHT"] = "8";
|
|
3948
3948
|
KeyMap2["NINE"] = "9";
|
|
3949
3949
|
})(KeyMap || (KeyMap = {}));
|
|
3950
|
-
const LETTER_REG = /[a-zA-Z]/;
|
|
3951
|
-
const NUMBER_LIKE_REG = /[0-9.]/;
|
|
3952
3950
|
class CheckboxControl {
|
|
3953
3951
|
constructor(element, control) {
|
|
3954
3952
|
__publicField(this, "element");
|
|
@@ -4046,57 +4044,712 @@ class CheckboxControl {
|
|
|
4046
4044
|
return endIndex;
|
|
4047
4045
|
}
|
|
4048
4046
|
}
|
|
4047
|
+
function mousedown(evt, host) {
|
|
4048
|
+
if (evt.button === MouseEventButton.RIGHT)
|
|
4049
|
+
return;
|
|
4050
|
+
const draw = host.getDraw();
|
|
4051
|
+
const isReadonly = draw.isReadonly();
|
|
4052
|
+
const rangeManager = draw.getRange();
|
|
4053
|
+
const position = draw.getPosition();
|
|
4054
|
+
if (!host.isAllowDrag) {
|
|
4055
|
+
const range = rangeManager.getRange();
|
|
4056
|
+
if (!isReadonly && range.startIndex !== range.endIndex) {
|
|
4057
|
+
const isPointInRange = rangeManager.getIsPointInRange(evt.offsetX, evt.offsetY);
|
|
4058
|
+
if (isPointInRange) {
|
|
4059
|
+
host.isAllowDrag = true;
|
|
4060
|
+
host.cacheRange = deepClone(range);
|
|
4061
|
+
host.cacheElementList = draw.getElementList();
|
|
4062
|
+
host.cachePositionList = position.getPositionList();
|
|
4063
|
+
return;
|
|
4064
|
+
}
|
|
4065
|
+
}
|
|
4066
|
+
}
|
|
4067
|
+
const target = evt.target;
|
|
4068
|
+
const pageIndex = target.dataset.index;
|
|
4069
|
+
if (pageIndex) {
|
|
4070
|
+
draw.setPageNo(Number(pageIndex));
|
|
4071
|
+
}
|
|
4072
|
+
host.isAllowSelection = true;
|
|
4073
|
+
const positionResult = position.adjustPositionContext({
|
|
4074
|
+
x: evt.offsetX,
|
|
4075
|
+
y: evt.offsetY
|
|
4076
|
+
});
|
|
4077
|
+
const { index: index2, isDirectHit, isCheckbox, isImage, isTable, tdValueIndex } = positionResult;
|
|
4078
|
+
host.mouseDownStartPosition = __spreadProps(__spreadValues({}, positionResult), {
|
|
4079
|
+
index: isTable ? tdValueIndex : index2
|
|
4080
|
+
});
|
|
4081
|
+
const elementList = draw.getElementList();
|
|
4082
|
+
const positionList = position.getPositionList();
|
|
4083
|
+
const curIndex = isTable ? tdValueIndex : index2;
|
|
4084
|
+
const curElement = elementList[curIndex];
|
|
4085
|
+
const isDirectHitImage = !!(isDirectHit && isImage);
|
|
4086
|
+
const isDirectHitCheckbox = !!(isDirectHit && isCheckbox);
|
|
4087
|
+
if (~index2) {
|
|
4088
|
+
rangeManager.setRange(curIndex, curIndex);
|
|
4089
|
+
position.setCursorPosition(positionList[curIndex]);
|
|
4090
|
+
const isSetCheckbox = isDirectHitCheckbox && !isReadonly;
|
|
4091
|
+
if (isSetCheckbox) {
|
|
4092
|
+
const { checkbox } = curElement;
|
|
4093
|
+
if (checkbox) {
|
|
4094
|
+
checkbox.value = !checkbox.value;
|
|
4095
|
+
} else {
|
|
4096
|
+
curElement.checkbox = {
|
|
4097
|
+
value: true
|
|
4098
|
+
};
|
|
4099
|
+
}
|
|
4100
|
+
const control = draw.getControl();
|
|
4101
|
+
const activeControl = control.getActiveControl();
|
|
4102
|
+
if (activeControl instanceof CheckboxControl) {
|
|
4103
|
+
activeControl.setSelect();
|
|
4104
|
+
}
|
|
4105
|
+
}
|
|
4106
|
+
draw.render({
|
|
4107
|
+
curIndex,
|
|
4108
|
+
isSubmitHistory: isSetCheckbox,
|
|
4109
|
+
isSetCursor: !isDirectHitImage && !isDirectHitCheckbox,
|
|
4110
|
+
isComputeRowList: false
|
|
4111
|
+
});
|
|
4112
|
+
}
|
|
4113
|
+
const previewer = draw.getPreviewer();
|
|
4114
|
+
previewer.clearResizer();
|
|
4115
|
+
if (isDirectHitImage && !isReadonly) {
|
|
4116
|
+
previewer.drawResizer(curElement, positionList[curIndex], curElement.type === ElementType.LATEX ? {
|
|
4117
|
+
mime: "svg",
|
|
4118
|
+
srcKey: "laTexSVG"
|
|
4119
|
+
} : {});
|
|
4120
|
+
}
|
|
4121
|
+
const tableTool = draw.getTableTool();
|
|
4122
|
+
tableTool.dispose();
|
|
4123
|
+
if (isTable && !isReadonly) {
|
|
4124
|
+
const originalElementList = draw.getOriginalElementList();
|
|
4125
|
+
const originalPositionList = position.getOriginalPositionList();
|
|
4126
|
+
tableTool.render(originalElementList[index2], originalPositionList[index2]);
|
|
4127
|
+
}
|
|
4128
|
+
const hyperlinkParticle = draw.getHyperlinkParticle();
|
|
4129
|
+
hyperlinkParticle.clearHyperlinkPopup();
|
|
4130
|
+
if (curElement.type === ElementType.HYPERLINK) {
|
|
4131
|
+
hyperlinkParticle.drawHyperlinkPopup(curElement, positionList[curIndex]);
|
|
4132
|
+
}
|
|
4133
|
+
const dateParticle = draw.getDateParticle();
|
|
4134
|
+
dateParticle.clearDatePicker();
|
|
4135
|
+
if (curElement.type === ElementType.DATE && !isReadonly) {
|
|
4136
|
+
dateParticle.renderDatePicker(curElement, positionList[curIndex]);
|
|
4137
|
+
}
|
|
4138
|
+
}
|
|
4139
|
+
function mouseup(evt, host) {
|
|
4140
|
+
if (host.isAllowDrop) {
|
|
4141
|
+
const draw = host.getDraw();
|
|
4142
|
+
const position = draw.getPosition();
|
|
4143
|
+
const rangeManager = draw.getRange();
|
|
4144
|
+
const cacheRange = host.cacheRange;
|
|
4145
|
+
const cacheElementList = host.cacheElementList;
|
|
4146
|
+
const cachePositionList = host.cachePositionList;
|
|
4147
|
+
const range = rangeManager.getRange();
|
|
4148
|
+
const elementList = draw.getElementList();
|
|
4149
|
+
const positionList = position.getPositionList();
|
|
4150
|
+
const startPosition = positionList[range.startIndex];
|
|
4151
|
+
const cacheStartElement = cacheElementList[cacheRange.startIndex];
|
|
4152
|
+
const startElement = elementList[range.startIndex];
|
|
4153
|
+
let curIndex = range.startIndex;
|
|
4154
|
+
if (cacheStartElement.tdId === startElement.tdId && range.startIndex > cacheRange.endIndex) {
|
|
4155
|
+
curIndex -= cacheRange.endIndex - cacheRange.startIndex;
|
|
4156
|
+
}
|
|
4157
|
+
const deleteElementList = cacheElementList.splice(cacheRange.startIndex + 1, cacheRange.endIndex - cacheRange.startIndex);
|
|
4158
|
+
let restArg = {};
|
|
4159
|
+
if (startElement.tableId) {
|
|
4160
|
+
const { tdId, trId, tableId } = startElement;
|
|
4161
|
+
restArg = { tdId, trId, tableId };
|
|
4162
|
+
}
|
|
4163
|
+
const replaceElementList = deleteElementList.map((el) => {
|
|
4164
|
+
const newElement = __spreadValues({
|
|
4165
|
+
value: el.value
|
|
4166
|
+
}, restArg);
|
|
4167
|
+
EDITOR_ELEMENT_STYLE_ATTR.forEach((attr) => {
|
|
4168
|
+
const value = el[attr];
|
|
4169
|
+
if (value !== void 0) {
|
|
4170
|
+
newElement[attr] = value;
|
|
4171
|
+
}
|
|
4172
|
+
});
|
|
4173
|
+
return newElement;
|
|
4174
|
+
});
|
|
4175
|
+
elementList.splice(curIndex + 1, 0, ...replaceElementList);
|
|
4176
|
+
const cacheStartPosition = cachePositionList[cacheRange.startIndex];
|
|
4177
|
+
const positionContext = position.getPositionContext();
|
|
4178
|
+
let positionContextIndex = positionContext.index;
|
|
4179
|
+
if (positionContextIndex) {
|
|
4180
|
+
if (startElement.tableId && !cacheStartElement.tableId) {
|
|
4181
|
+
if (cacheStartPosition.index < positionContextIndex) {
|
|
4182
|
+
positionContextIndex -= deleteElementList.length;
|
|
4183
|
+
}
|
|
4184
|
+
} else if (!startElement.tableId && cacheStartElement.tableId) {
|
|
4185
|
+
if (startPosition.index < positionContextIndex) {
|
|
4186
|
+
positionContextIndex += deleteElementList.length;
|
|
4187
|
+
}
|
|
4188
|
+
}
|
|
4189
|
+
position.setPositionContext(__spreadProps(__spreadValues({}, positionContext), {
|
|
4190
|
+
index: positionContextIndex
|
|
4191
|
+
}));
|
|
4192
|
+
}
|
|
4193
|
+
rangeManager.setRange(curIndex, curIndex + deleteElementList.length, range.tableId, range.startTdIndex, range.endTdIndex, range.startTrIndex, range.endTrIndex);
|
|
4194
|
+
draw.render({
|
|
4195
|
+
isSetCursor: false
|
|
4196
|
+
});
|
|
4197
|
+
host.isAllowDrag = false;
|
|
4198
|
+
host.isAllowDrop = false;
|
|
4199
|
+
} else if (host.isAllowDrag) {
|
|
4200
|
+
host.mousedown(evt);
|
|
4201
|
+
host.isAllowDrag = false;
|
|
4202
|
+
}
|
|
4203
|
+
}
|
|
4204
|
+
function mouseleave(evt, host) {
|
|
4205
|
+
const draw = host.getDraw();
|
|
4206
|
+
const pageContainer = draw.getPageContainer();
|
|
4207
|
+
const { x, y, width, height } = pageContainer.getBoundingClientRect();
|
|
4208
|
+
if (evt.x >= x && evt.x <= x + width && evt.y >= y && evt.y <= y + height)
|
|
4209
|
+
return;
|
|
4210
|
+
host.setIsAllowSelection(false);
|
|
4211
|
+
}
|
|
4212
|
+
function mousemove(evt, host) {
|
|
4213
|
+
const draw = host.getDraw();
|
|
4214
|
+
if (host.isAllowDrag) {
|
|
4215
|
+
const x = evt.offsetX;
|
|
4216
|
+
const y = evt.offsetY;
|
|
4217
|
+
const { startIndex: startIndex2, endIndex: endIndex2 } = host.cacheRange;
|
|
4218
|
+
const positionList = host.cachePositionList;
|
|
4219
|
+
for (let p = startIndex2 + 1; p <= endIndex2; p++) {
|
|
4220
|
+
const { coordinate: { leftTop, rightBottom } } = positionList[p];
|
|
4221
|
+
if (x >= leftTop[0] && x <= rightBottom[0] && y >= leftTop[1] && y <= rightBottom[1]) {
|
|
4222
|
+
return;
|
|
4223
|
+
}
|
|
4224
|
+
}
|
|
4225
|
+
host.dragover(evt);
|
|
4226
|
+
host.isAllowDrop = true;
|
|
4227
|
+
return;
|
|
4228
|
+
}
|
|
4229
|
+
if (!host.isAllowSelection || !host.mouseDownStartPosition)
|
|
4230
|
+
return;
|
|
4231
|
+
const target = evt.target;
|
|
4232
|
+
const pageIndex = target.dataset.index;
|
|
4233
|
+
if (pageIndex) {
|
|
4234
|
+
draw.setPageNo(Number(pageIndex));
|
|
4235
|
+
}
|
|
4236
|
+
const position = draw.getPosition();
|
|
4237
|
+
const positionResult = position.getPositionByXY({
|
|
4238
|
+
x: evt.offsetX,
|
|
4239
|
+
y: evt.offsetY
|
|
4240
|
+
});
|
|
4241
|
+
const { index: index2, isTable, tdValueIndex, tdIndex, trIndex, tableId } = positionResult;
|
|
4242
|
+
const { index: startIndex, isTable: startIsTable, tdIndex: startTdIndex, trIndex: startTrIndex } = host.mouseDownStartPosition;
|
|
4243
|
+
const endIndex = isTable ? tdValueIndex : index2;
|
|
4244
|
+
const rangeManager = draw.getRange();
|
|
4245
|
+
if (isTable && startIsTable && (tdIndex !== startTdIndex || trIndex !== startTrIndex)) {
|
|
4246
|
+
rangeManager.setRange(endIndex, endIndex, tableId, startTdIndex, tdIndex, startTrIndex, trIndex);
|
|
4247
|
+
} else {
|
|
4248
|
+
let end = ~endIndex ? endIndex : 0;
|
|
4249
|
+
let start = startIndex;
|
|
4250
|
+
if (start > end) {
|
|
4251
|
+
[start, end] = [end, start];
|
|
4252
|
+
}
|
|
4253
|
+
if (start === end)
|
|
4254
|
+
return;
|
|
4255
|
+
rangeManager.setRange(start, end);
|
|
4256
|
+
}
|
|
4257
|
+
draw.render({
|
|
4258
|
+
isSubmitHistory: false,
|
|
4259
|
+
isSetCursor: false,
|
|
4260
|
+
isComputeRowList: false
|
|
4261
|
+
});
|
|
4262
|
+
}
|
|
4263
|
+
function keydown(evt, host) {
|
|
4264
|
+
var _a;
|
|
4265
|
+
const draw = host.getDraw();
|
|
4266
|
+
const position = draw.getPosition();
|
|
4267
|
+
const cursorPosition = position.getCursorPosition();
|
|
4268
|
+
if (!cursorPosition)
|
|
4269
|
+
return;
|
|
4270
|
+
const isReadonly = draw.isReadonly();
|
|
4271
|
+
const historyManager = draw.getHistoryManager();
|
|
4272
|
+
const elementList = draw.getElementList();
|
|
4273
|
+
const positionList = position.getPositionList();
|
|
4274
|
+
const { index: index2 } = cursorPosition;
|
|
4275
|
+
const rangeManager = draw.getRange();
|
|
4276
|
+
const { startIndex, endIndex } = rangeManager.getRange();
|
|
4277
|
+
const isCollapsed = startIndex === endIndex;
|
|
4278
|
+
const control = draw.getControl();
|
|
4279
|
+
const isPartRangeInControlOutside = control.isPartRangeInControlOutside();
|
|
4280
|
+
const activeControl = control.getActiveControl();
|
|
4281
|
+
if (evt.key === KeyMap.Backspace) {
|
|
4282
|
+
if (isReadonly || isPartRangeInControlOutside)
|
|
4283
|
+
return;
|
|
4284
|
+
let curIndex;
|
|
4285
|
+
if (activeControl) {
|
|
4286
|
+
curIndex = control.keydown(evt);
|
|
4287
|
+
} else {
|
|
4288
|
+
if (isCollapsed && elementList[index2].value === ZERO && index2 === 0) {
|
|
4289
|
+
evt.preventDefault();
|
|
4290
|
+
return;
|
|
4291
|
+
}
|
|
4292
|
+
if (!isCollapsed) {
|
|
4293
|
+
elementList.splice(startIndex + 1, endIndex - startIndex);
|
|
4294
|
+
} else {
|
|
4295
|
+
elementList.splice(index2, 1);
|
|
4296
|
+
}
|
|
4297
|
+
curIndex = isCollapsed ? index2 - 1 : startIndex;
|
|
4298
|
+
}
|
|
4299
|
+
rangeManager.setRange(curIndex, curIndex);
|
|
4300
|
+
draw.render({ curIndex });
|
|
4301
|
+
} else if (evt.key === KeyMap.Delete) {
|
|
4302
|
+
if (isReadonly || isPartRangeInControlOutside)
|
|
4303
|
+
return;
|
|
4304
|
+
let curIndex;
|
|
4305
|
+
if (activeControl) {
|
|
4306
|
+
curIndex = control.keydown(evt);
|
|
4307
|
+
} else if (((_a = elementList[endIndex + 1]) == null ? void 0 : _a.type) === ElementType.CONTROL) {
|
|
4308
|
+
curIndex = control.removeControl(endIndex + 1);
|
|
4309
|
+
} else {
|
|
4310
|
+
if (!isCollapsed) {
|
|
4311
|
+
elementList.splice(startIndex + 1, endIndex - startIndex);
|
|
4312
|
+
} else {
|
|
4313
|
+
elementList.splice(index2 + 1, 1);
|
|
4314
|
+
}
|
|
4315
|
+
curIndex = isCollapsed ? index2 : startIndex;
|
|
4316
|
+
}
|
|
4317
|
+
rangeManager.setRange(curIndex, curIndex);
|
|
4318
|
+
draw.render({ curIndex });
|
|
4319
|
+
} else if (evt.key === KeyMap.Enter) {
|
|
4320
|
+
if (isReadonly || isPartRangeInControlOutside)
|
|
4321
|
+
return;
|
|
4322
|
+
const positionContext = position.getPositionContext();
|
|
4323
|
+
let restArg = {};
|
|
4324
|
+
if (positionContext.isTable) {
|
|
4325
|
+
const { tdId, trId, tableId } = positionContext;
|
|
4326
|
+
restArg = { tdId, trId, tableId };
|
|
4327
|
+
}
|
|
4328
|
+
const enterText = __spreadValues({
|
|
4329
|
+
value: ZERO
|
|
4330
|
+
}, restArg);
|
|
4331
|
+
let curIndex;
|
|
4332
|
+
if (activeControl) {
|
|
4333
|
+
curIndex = control.setValue([enterText]);
|
|
4334
|
+
} else {
|
|
4335
|
+
if (isCollapsed) {
|
|
4336
|
+
elementList.splice(index2 + 1, 0, enterText);
|
|
4337
|
+
} else {
|
|
4338
|
+
elementList.splice(startIndex + 1, endIndex - startIndex, enterText);
|
|
4339
|
+
}
|
|
4340
|
+
curIndex = index2 + 1;
|
|
4341
|
+
}
|
|
4342
|
+
rangeManager.setRange(curIndex, curIndex);
|
|
4343
|
+
draw.render({ curIndex });
|
|
4344
|
+
evt.preventDefault();
|
|
4345
|
+
} else if (evt.key === KeyMap.Left) {
|
|
4346
|
+
if (isReadonly)
|
|
4347
|
+
return;
|
|
4348
|
+
if (index2 > 0) {
|
|
4349
|
+
const curIndex = index2 - 1;
|
|
4350
|
+
rangeManager.setRange(curIndex, curIndex);
|
|
4351
|
+
draw.render({
|
|
4352
|
+
curIndex,
|
|
4353
|
+
isSubmitHistory: false,
|
|
4354
|
+
isComputeRowList: false
|
|
4355
|
+
});
|
|
4356
|
+
}
|
|
4357
|
+
} else if (evt.key === KeyMap.Right) {
|
|
4358
|
+
if (isReadonly)
|
|
4359
|
+
return;
|
|
4360
|
+
if (index2 < positionList.length - 1) {
|
|
4361
|
+
const curIndex = index2 + 1;
|
|
4362
|
+
rangeManager.setRange(curIndex, curIndex);
|
|
4363
|
+
draw.render({
|
|
4364
|
+
curIndex,
|
|
4365
|
+
isSubmitHistory: false,
|
|
4366
|
+
isComputeRowList: false
|
|
4367
|
+
});
|
|
4368
|
+
}
|
|
4369
|
+
} else if (evt.key === KeyMap.Up || evt.key === KeyMap.Down) {
|
|
4370
|
+
if (isReadonly)
|
|
4371
|
+
return;
|
|
4372
|
+
const { rowNo, index: index22, coordinate: { leftTop, rightTop } } = cursorPosition;
|
|
4373
|
+
if (evt.key === KeyMap.Up && rowNo !== 0 || evt.key === KeyMap.Down && rowNo !== draw.getRowCount()) {
|
|
4374
|
+
const probablePosition = evt.key === KeyMap.Up ? positionList.slice(0, index22).filter((p) => p.rowNo === rowNo - 1) : positionList.slice(index22, positionList.length - 1).filter((p) => p.rowNo === rowNo + 1);
|
|
4375
|
+
let maxIndex = 0;
|
|
4376
|
+
let maxDistance = 0;
|
|
4377
|
+
for (let p = 0; p < probablePosition.length; p++) {
|
|
4378
|
+
const position2 = probablePosition[p];
|
|
4379
|
+
if (position2.coordinate.leftTop[0] >= leftTop[0] && position2.coordinate.leftTop[0] <= rightTop[0]) {
|
|
4380
|
+
const curDistance = rightTop[0] - position2.coordinate.leftTop[0];
|
|
4381
|
+
if (curDistance > maxDistance) {
|
|
4382
|
+
maxIndex = position2.index;
|
|
4383
|
+
maxDistance = curDistance;
|
|
4384
|
+
}
|
|
4385
|
+
} else if (position2.coordinate.leftTop[0] <= leftTop[0] && position2.coordinate.rightTop[0] >= leftTop[0]) {
|
|
4386
|
+
const curDistance = position2.coordinate.rightTop[0] - leftTop[0];
|
|
4387
|
+
if (curDistance > maxDistance) {
|
|
4388
|
+
maxIndex = position2.index;
|
|
4389
|
+
maxDistance = curDistance;
|
|
4390
|
+
}
|
|
4391
|
+
}
|
|
4392
|
+
if (p === probablePosition.length - 1 && maxIndex === 0) {
|
|
4393
|
+
maxIndex = position2.index;
|
|
4394
|
+
}
|
|
4395
|
+
}
|
|
4396
|
+
const curIndex = maxIndex;
|
|
4397
|
+
rangeManager.setRange(curIndex, curIndex);
|
|
4398
|
+
draw.render({
|
|
4399
|
+
curIndex,
|
|
4400
|
+
isSubmitHistory: false,
|
|
4401
|
+
isComputeRowList: false
|
|
4402
|
+
});
|
|
4403
|
+
}
|
|
4404
|
+
} else if (evt.ctrlKey && evt.key === KeyMap.Z) {
|
|
4405
|
+
if (isReadonly)
|
|
4406
|
+
return;
|
|
4407
|
+
historyManager.undo();
|
|
4408
|
+
evt.preventDefault();
|
|
4409
|
+
} else if (evt.ctrlKey && evt.key === KeyMap.Y) {
|
|
4410
|
+
if (isReadonly)
|
|
4411
|
+
return;
|
|
4412
|
+
historyManager.redo();
|
|
4413
|
+
evt.preventDefault();
|
|
4414
|
+
} else if (evt.ctrlKey && evt.key === KeyMap.C) {
|
|
4415
|
+
host.copy();
|
|
4416
|
+
evt.preventDefault();
|
|
4417
|
+
} else if (evt.ctrlKey && evt.key === KeyMap.X) {
|
|
4418
|
+
host.cut();
|
|
4419
|
+
evt.preventDefault();
|
|
4420
|
+
} else if (evt.ctrlKey && evt.key === KeyMap.A) {
|
|
4421
|
+
host.selectAll();
|
|
4422
|
+
evt.preventDefault();
|
|
4423
|
+
} else if (evt.ctrlKey && evt.key === KeyMap.S) {
|
|
4424
|
+
if (isReadonly)
|
|
4425
|
+
return;
|
|
4426
|
+
const listener = draw.getListener();
|
|
4427
|
+
if (listener.saved) {
|
|
4428
|
+
listener.saved(draw.getValue());
|
|
4429
|
+
}
|
|
4430
|
+
evt.preventDefault();
|
|
4431
|
+
} else if (evt.key === KeyMap.ESC) {
|
|
4432
|
+
host.clearPainterStyle();
|
|
4433
|
+
evt.preventDefault();
|
|
4434
|
+
} else if (evt.key === KeyMap.TAB) {
|
|
4435
|
+
draw.insertElementList([{
|
|
4436
|
+
type: ElementType.TAB,
|
|
4437
|
+
value: ""
|
|
4438
|
+
}]);
|
|
4439
|
+
evt.preventDefault();
|
|
4440
|
+
}
|
|
4441
|
+
}
|
|
4442
|
+
function input(data2, host) {
|
|
4443
|
+
var _a;
|
|
4444
|
+
const draw = host.getDraw();
|
|
4445
|
+
const isReadonly = draw.isReadonly();
|
|
4446
|
+
if (isReadonly)
|
|
4447
|
+
return;
|
|
4448
|
+
const position = draw.getPosition();
|
|
4449
|
+
const cursorPosition = position.getCursorPosition();
|
|
4450
|
+
if (!data2 || !cursorPosition || host.isCompositing)
|
|
4451
|
+
return;
|
|
4452
|
+
const control = draw.getControl();
|
|
4453
|
+
if (control.isPartRangeInControlOutside()) {
|
|
4454
|
+
return;
|
|
4455
|
+
}
|
|
4456
|
+
const activeControl = control.getActiveControl();
|
|
4457
|
+
const { TEXT, HYPERLINK, SUBSCRIPT, SUPERSCRIPT, DATE } = ElementType;
|
|
4458
|
+
const text = data2.replaceAll(`
|
|
4459
|
+
`, ZERO);
|
|
4460
|
+
const cursor = draw.getCursor();
|
|
4461
|
+
const agentDom = cursor.getAgentDom();
|
|
4462
|
+
agentDom.value = "";
|
|
4463
|
+
const { index: index2 } = cursorPosition;
|
|
4464
|
+
const rangeManager = draw.getRange();
|
|
4465
|
+
const { startIndex, endIndex } = rangeManager.getRange();
|
|
4466
|
+
const isCollapsed = startIndex === endIndex;
|
|
4467
|
+
const positionContext = position.getPositionContext();
|
|
4468
|
+
let restArg = {};
|
|
4469
|
+
if (positionContext.isTable) {
|
|
4470
|
+
const { tdId, trId, tableId } = positionContext;
|
|
4471
|
+
restArg = { tdId, trId, tableId };
|
|
4472
|
+
}
|
|
4473
|
+
const elementList = draw.getElementList();
|
|
4474
|
+
const element = elementList[endIndex];
|
|
4475
|
+
const inputData = splitText(text).map((value) => {
|
|
4476
|
+
const newElement = __spreadValues({
|
|
4477
|
+
value
|
|
4478
|
+
}, restArg);
|
|
4479
|
+
const nextElement = elementList[endIndex + 1];
|
|
4480
|
+
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) {
|
|
4481
|
+
EDITOR_ELEMENT_COPY_ATTR.forEach((attr) => {
|
|
4482
|
+
const value2 = element[attr];
|
|
4483
|
+
if (value2 !== void 0) {
|
|
4484
|
+
newElement[attr] = value2;
|
|
4485
|
+
}
|
|
4486
|
+
});
|
|
4487
|
+
}
|
|
4488
|
+
return newElement;
|
|
4489
|
+
});
|
|
4490
|
+
let curIndex;
|
|
4491
|
+
if (activeControl && ((_a = elementList[endIndex + 1]) == null ? void 0 : _a.controlId) === element.controlId) {
|
|
4492
|
+
curIndex = control.setValue(inputData);
|
|
4493
|
+
} else {
|
|
4494
|
+
let start = 0;
|
|
4495
|
+
if (isCollapsed) {
|
|
4496
|
+
start = index2 + 1;
|
|
4497
|
+
} else {
|
|
4498
|
+
start = startIndex + 1;
|
|
4499
|
+
elementList.splice(startIndex + 1, endIndex - startIndex);
|
|
4500
|
+
}
|
|
4501
|
+
for (let i = 0; i < inputData.length; i++) {
|
|
4502
|
+
elementList.splice(start + i, 0, inputData[i]);
|
|
4503
|
+
}
|
|
4504
|
+
curIndex = (isCollapsed ? index2 : startIndex) + inputData.length;
|
|
4505
|
+
}
|
|
4506
|
+
rangeManager.setRange(curIndex, curIndex);
|
|
4507
|
+
draw.render({ curIndex });
|
|
4508
|
+
}
|
|
4509
|
+
function cut(host) {
|
|
4510
|
+
const draw = host.getDraw();
|
|
4511
|
+
const rangeManager = draw.getRange();
|
|
4512
|
+
const { startIndex, endIndex } = rangeManager.getRange();
|
|
4513
|
+
if (!~startIndex && !~startIndex)
|
|
4514
|
+
return;
|
|
4515
|
+
const isReadonly = draw.isReadonly();
|
|
4516
|
+
if (isReadonly)
|
|
4517
|
+
return;
|
|
4518
|
+
const control = draw.getControl();
|
|
4519
|
+
const isPartRangeInControlOutside = control.isPartRangeInControlOutside();
|
|
4520
|
+
if (isPartRangeInControlOutside)
|
|
4521
|
+
return;
|
|
4522
|
+
const activeControl = control.getActiveControl();
|
|
4523
|
+
const elementList = draw.getElementList();
|
|
4524
|
+
let start = startIndex;
|
|
4525
|
+
let end = endIndex;
|
|
4526
|
+
if (startIndex === endIndex) {
|
|
4527
|
+
const position = draw.getPosition();
|
|
4528
|
+
const positionList = position.getPositionList();
|
|
4529
|
+
const curRowNo = positionList[startIndex].rowNo;
|
|
4530
|
+
const cutElementIndexList = [];
|
|
4531
|
+
for (let p = 0; p < positionList.length; p++) {
|
|
4532
|
+
const position2 = positionList[p];
|
|
4533
|
+
if (position2.rowNo > curRowNo)
|
|
4534
|
+
break;
|
|
4535
|
+
if (position2.rowNo === curRowNo) {
|
|
4536
|
+
cutElementIndexList.push(p);
|
|
4537
|
+
}
|
|
4538
|
+
}
|
|
4539
|
+
const firstElementIndex = cutElementIndexList[0] - 1;
|
|
4540
|
+
start = firstElementIndex < 0 ? 0 : firstElementIndex;
|
|
4541
|
+
end = cutElementIndexList[cutElementIndexList.length - 1];
|
|
4542
|
+
}
|
|
4543
|
+
const options = draw.getOptions();
|
|
4544
|
+
writeElementList(elementList.slice(start + 1, end + 1), options);
|
|
4545
|
+
let curIndex;
|
|
4546
|
+
if (activeControl) {
|
|
4547
|
+
curIndex = control.cut();
|
|
4548
|
+
} else {
|
|
4549
|
+
elementList.splice(start + 1, end - start);
|
|
4550
|
+
curIndex = start;
|
|
4551
|
+
}
|
|
4552
|
+
rangeManager.setRange(curIndex, curIndex);
|
|
4553
|
+
draw.render({ curIndex });
|
|
4554
|
+
}
|
|
4555
|
+
function copy(host) {
|
|
4556
|
+
const draw = host.getDraw();
|
|
4557
|
+
const rangeManager = draw.getRange();
|
|
4558
|
+
const { startIndex, endIndex } = rangeManager.getRange();
|
|
4559
|
+
if (startIndex !== endIndex) {
|
|
4560
|
+
const options = draw.getOptions();
|
|
4561
|
+
const elementList = draw.getElementList();
|
|
4562
|
+
writeElementList(elementList.slice(startIndex + 1, endIndex + 1), options);
|
|
4563
|
+
}
|
|
4564
|
+
}
|
|
4565
|
+
function drop(evt, host) {
|
|
4566
|
+
var _a;
|
|
4567
|
+
evt.preventDefault();
|
|
4568
|
+
const data2 = (_a = evt.dataTransfer) == null ? void 0 : _a.getData("text");
|
|
4569
|
+
if (data2) {
|
|
4570
|
+
host.input(data2);
|
|
4571
|
+
}
|
|
4572
|
+
}
|
|
4573
|
+
const LETTER_REG = /[a-zA-Z]/;
|
|
4574
|
+
const NUMBER_LIKE_REG = /[0-9.]/;
|
|
4575
|
+
function dblclick(host) {
|
|
4576
|
+
const draw = host.getDraw();
|
|
4577
|
+
const position = draw.getPosition();
|
|
4578
|
+
const cursorPosition = position.getCursorPosition();
|
|
4579
|
+
if (!cursorPosition)
|
|
4580
|
+
return;
|
|
4581
|
+
const { value, index: index2 } = cursorPosition;
|
|
4582
|
+
let upCount = 0;
|
|
4583
|
+
let downCount = 0;
|
|
4584
|
+
const isNumber = NUMBER_LIKE_REG.test(value);
|
|
4585
|
+
if (isNumber || LETTER_REG.test(value)) {
|
|
4586
|
+
const elementList = draw.getElementList();
|
|
4587
|
+
let upStartIndex = index2 - 1;
|
|
4588
|
+
while (upStartIndex > 0) {
|
|
4589
|
+
const value2 = elementList[upStartIndex].value;
|
|
4590
|
+
if (isNumber && NUMBER_LIKE_REG.test(value2) || !isNumber && LETTER_REG.test(value2)) {
|
|
4591
|
+
upCount++;
|
|
4592
|
+
upStartIndex--;
|
|
4593
|
+
} else {
|
|
4594
|
+
break;
|
|
4595
|
+
}
|
|
4596
|
+
}
|
|
4597
|
+
let downStartIndex = index2 + 1;
|
|
4598
|
+
while (downStartIndex < elementList.length) {
|
|
4599
|
+
const value2 = elementList[downStartIndex].value;
|
|
4600
|
+
if (isNumber && NUMBER_LIKE_REG.test(value2) || !isNumber && LETTER_REG.test(value2)) {
|
|
4601
|
+
downCount++;
|
|
4602
|
+
downStartIndex++;
|
|
4603
|
+
} else {
|
|
4604
|
+
break;
|
|
4605
|
+
}
|
|
4606
|
+
}
|
|
4607
|
+
}
|
|
4608
|
+
const rangeManager = draw.getRange();
|
|
4609
|
+
rangeManager.setRange(index2 - upCount - 1, index2 + downCount);
|
|
4610
|
+
draw.render({
|
|
4611
|
+
isSubmitHistory: false,
|
|
4612
|
+
isSetCursor: false,
|
|
4613
|
+
isComputeRowList: false
|
|
4614
|
+
});
|
|
4615
|
+
}
|
|
4616
|
+
function threeClick(host) {
|
|
4617
|
+
const draw = host.getDraw();
|
|
4618
|
+
const position = draw.getPosition();
|
|
4619
|
+
const cursorPosition = position.getCursorPosition();
|
|
4620
|
+
if (!cursorPosition)
|
|
4621
|
+
return;
|
|
4622
|
+
const { index: index2 } = cursorPosition;
|
|
4623
|
+
const elementList = draw.getElementList();
|
|
4624
|
+
let upCount = 0;
|
|
4625
|
+
let downCount = 0;
|
|
4626
|
+
let upStartIndex = index2 - 1;
|
|
4627
|
+
while (upStartIndex > 0) {
|
|
4628
|
+
const value = elementList[upStartIndex].value;
|
|
4629
|
+
if (value !== ZERO) {
|
|
4630
|
+
upCount++;
|
|
4631
|
+
upStartIndex--;
|
|
4632
|
+
} else {
|
|
4633
|
+
break;
|
|
4634
|
+
}
|
|
4635
|
+
}
|
|
4636
|
+
let downStartIndex = index2 + 1;
|
|
4637
|
+
while (downStartIndex < elementList.length) {
|
|
4638
|
+
const value = elementList[downStartIndex].value;
|
|
4639
|
+
if (value !== ZERO) {
|
|
4640
|
+
downCount++;
|
|
4641
|
+
downStartIndex++;
|
|
4642
|
+
} else {
|
|
4643
|
+
break;
|
|
4644
|
+
}
|
|
4645
|
+
}
|
|
4646
|
+
const rangeManager = draw.getRange();
|
|
4647
|
+
rangeManager.setRange(index2 - upCount - 1, index2 + downCount);
|
|
4648
|
+
draw.render({
|
|
4649
|
+
isSubmitHistory: false,
|
|
4650
|
+
isSetCursor: false,
|
|
4651
|
+
isComputeRowList: false
|
|
4652
|
+
});
|
|
4653
|
+
}
|
|
4654
|
+
var click = {
|
|
4655
|
+
dblclick,
|
|
4656
|
+
threeClick
|
|
4657
|
+
};
|
|
4658
|
+
function compositionstart(host) {
|
|
4659
|
+
host.isCompositing = true;
|
|
4660
|
+
}
|
|
4661
|
+
function compositionend(host) {
|
|
4662
|
+
host.isCompositing = false;
|
|
4663
|
+
}
|
|
4664
|
+
var composition = {
|
|
4665
|
+
compositionstart,
|
|
4666
|
+
compositionend
|
|
4667
|
+
};
|
|
4668
|
+
function dragover(evt, host) {
|
|
4669
|
+
const draw = host.getDraw();
|
|
4670
|
+
const isReadonly = draw.isReadonly();
|
|
4671
|
+
if (isReadonly)
|
|
4672
|
+
return;
|
|
4673
|
+
evt.preventDefault();
|
|
4674
|
+
const pageContainer = draw.getPageContainer();
|
|
4675
|
+
const editorRegion = findParent(evt.target, (node) => node === pageContainer, true);
|
|
4676
|
+
if (!editorRegion)
|
|
4677
|
+
return;
|
|
4678
|
+
const target = evt.target;
|
|
4679
|
+
const pageIndex = target.dataset.index;
|
|
4680
|
+
if (pageIndex) {
|
|
4681
|
+
draw.setPageNo(Number(pageIndex));
|
|
4682
|
+
}
|
|
4683
|
+
const position = draw.getPosition();
|
|
4684
|
+
const { isTable, tdValueIndex, index: index2 } = position.adjustPositionContext({
|
|
4685
|
+
x: evt.offsetX,
|
|
4686
|
+
y: evt.offsetY
|
|
4687
|
+
});
|
|
4688
|
+
const positionList = position.getPositionList();
|
|
4689
|
+
const curIndex = isTable ? tdValueIndex : index2;
|
|
4690
|
+
if (~index2) {
|
|
4691
|
+
const rangeManager = draw.getRange();
|
|
4692
|
+
rangeManager.setRange(curIndex, curIndex);
|
|
4693
|
+
position.setCursorPosition(positionList[curIndex]);
|
|
4694
|
+
}
|
|
4695
|
+
const cursor = draw.getCursor();
|
|
4696
|
+
cursor.drawCursor();
|
|
4697
|
+
}
|
|
4698
|
+
var drag = {
|
|
4699
|
+
dragover
|
|
4700
|
+
};
|
|
4049
4701
|
class CanvasEvent {
|
|
4050
4702
|
constructor(draw) {
|
|
4051
|
-
__publicField(this, "
|
|
4703
|
+
__publicField(this, "isAllowSelection");
|
|
4052
4704
|
__publicField(this, "isCompositing");
|
|
4705
|
+
__publicField(this, "isAllowDrag");
|
|
4706
|
+
__publicField(this, "isAllowDrop");
|
|
4707
|
+
__publicField(this, "cacheRange");
|
|
4708
|
+
__publicField(this, "cacheElementList");
|
|
4709
|
+
__publicField(this, "cachePositionList");
|
|
4053
4710
|
__publicField(this, "mouseDownStartPosition");
|
|
4054
4711
|
__publicField(this, "draw");
|
|
4055
|
-
__publicField(this, "options");
|
|
4056
4712
|
__publicField(this, "pageContainer");
|
|
4057
4713
|
__publicField(this, "pageList");
|
|
4058
|
-
__publicField(this, "position");
|
|
4059
4714
|
__publicField(this, "range");
|
|
4060
|
-
__publicField(this, "
|
|
4061
|
-
|
|
4062
|
-
__publicField(this, "previewer");
|
|
4063
|
-
__publicField(this, "tableTool");
|
|
4064
|
-
__publicField(this, "hyperlinkParticle");
|
|
4065
|
-
__publicField(this, "dateParticle");
|
|
4066
|
-
__publicField(this, "listener");
|
|
4067
|
-
__publicField(this, "control");
|
|
4068
|
-
this.isAllowDrag = false;
|
|
4069
|
-
this.isCompositing = false;
|
|
4070
|
-
this.mouseDownStartPosition = null;
|
|
4715
|
+
__publicField(this, "position");
|
|
4716
|
+
this.draw = draw;
|
|
4071
4717
|
this.pageContainer = draw.getPageContainer();
|
|
4072
4718
|
this.pageList = draw.getPageList();
|
|
4073
|
-
this.draw = draw;
|
|
4074
|
-
this.options = draw.getOptions();
|
|
4075
|
-
this.cursor = null;
|
|
4076
|
-
this.position = this.draw.getPosition();
|
|
4077
4719
|
this.range = this.draw.getRange();
|
|
4078
|
-
this.
|
|
4079
|
-
this.
|
|
4080
|
-
this.
|
|
4081
|
-
this.
|
|
4082
|
-
this.
|
|
4083
|
-
this.
|
|
4084
|
-
this.
|
|
4720
|
+
this.position = this.draw.getPosition();
|
|
4721
|
+
this.isAllowSelection = false;
|
|
4722
|
+
this.isCompositing = false;
|
|
4723
|
+
this.isAllowDrag = false;
|
|
4724
|
+
this.isAllowDrop = false;
|
|
4725
|
+
this.cacheRange = null;
|
|
4726
|
+
this.cacheElementList = null;
|
|
4727
|
+
this.cachePositionList = null;
|
|
4728
|
+
this.mouseDownStartPosition = null;
|
|
4729
|
+
}
|
|
4730
|
+
getDraw() {
|
|
4731
|
+
return this.draw;
|
|
4085
4732
|
}
|
|
4086
4733
|
register() {
|
|
4087
|
-
this.cursor = this.draw.getCursor();
|
|
4088
4734
|
this.pageContainer.addEventListener("mousedown", this.mousedown.bind(this));
|
|
4735
|
+
this.pageContainer.addEventListener("mouseup", this.mouseup.bind(this));
|
|
4089
4736
|
this.pageContainer.addEventListener("mouseleave", this.mouseleave.bind(this));
|
|
4090
4737
|
this.pageContainer.addEventListener("mousemove", this.mousemove.bind(this));
|
|
4091
4738
|
this.pageContainer.addEventListener("dblclick", this.dblclick.bind(this));
|
|
4092
|
-
|
|
4739
|
+
this.pageContainer.addEventListener("dragover", this.dragover.bind(this));
|
|
4740
|
+
this.pageContainer.addEventListener("drop", this.drop.bind(this));
|
|
4741
|
+
threeClick$1(this.pageContainer, this.threeClick.bind(this));
|
|
4093
4742
|
}
|
|
4094
|
-
|
|
4095
|
-
this.
|
|
4743
|
+
setIsAllowSelection(payload) {
|
|
4744
|
+
this.isAllowSelection = payload;
|
|
4096
4745
|
if (!payload) {
|
|
4097
4746
|
this.applyPainterStyle();
|
|
4098
4747
|
}
|
|
4099
4748
|
}
|
|
4749
|
+
setIsAllowDrag(payload) {
|
|
4750
|
+
this.isAllowDrag = payload;
|
|
4751
|
+
this.isAllowDrop = payload;
|
|
4752
|
+
}
|
|
4100
4753
|
clearPainterStyle() {
|
|
4101
4754
|
this.pageList.forEach((p) => {
|
|
4102
4755
|
p.style.cursor = "text";
|
|
@@ -4123,496 +4776,56 @@ class CanvasEvent {
|
|
|
4123
4776
|
this.clearPainterStyle();
|
|
4124
4777
|
}
|
|
4125
4778
|
}
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
const target = evt.target;
|
|
4130
|
-
const pageIndex = target.dataset.index;
|
|
4131
|
-
if (pageIndex) {
|
|
4132
|
-
this.draw.setPageNo(Number(pageIndex));
|
|
4133
|
-
}
|
|
4134
|
-
const positionResult = this.position.getPositionByXY({
|
|
4135
|
-
x: evt.offsetX,
|
|
4136
|
-
y: evt.offsetY
|
|
4137
|
-
});
|
|
4138
|
-
const { index: index2, isTable, tdValueIndex, tdIndex, trIndex, tableId } = positionResult;
|
|
4139
|
-
const { index: startIndex, isTable: startIsTable, tdIndex: startTdIndex, trIndex: startTrIndex } = this.mouseDownStartPosition;
|
|
4140
|
-
const endIndex = isTable ? tdValueIndex : index2;
|
|
4141
|
-
if (isTable && startIsTable && (tdIndex !== startTdIndex || trIndex !== startTrIndex)) {
|
|
4142
|
-
this.range.setRange(endIndex, endIndex, tableId, startTdIndex, tdIndex, startTrIndex, trIndex);
|
|
4143
|
-
} else {
|
|
4144
|
-
let end = ~endIndex ? endIndex : 0;
|
|
4145
|
-
let start = startIndex;
|
|
4146
|
-
if (start > end) {
|
|
4147
|
-
[start, end] = [end, start];
|
|
4148
|
-
}
|
|
4149
|
-
if (start === end)
|
|
4150
|
-
return;
|
|
4151
|
-
this.range.setRange(start, end);
|
|
4152
|
-
}
|
|
4779
|
+
selectAll() {
|
|
4780
|
+
const position = this.position.getPositionList();
|
|
4781
|
+
this.range.setRange(0, position.length - 1);
|
|
4153
4782
|
this.draw.render({
|
|
4154
4783
|
isSubmitHistory: false,
|
|
4155
4784
|
isSetCursor: false,
|
|
4156
4785
|
isComputeRowList: false
|
|
4157
4786
|
});
|
|
4158
4787
|
}
|
|
4788
|
+
mousemove(evt) {
|
|
4789
|
+
mousemove(evt, this);
|
|
4790
|
+
}
|
|
4159
4791
|
mousedown(evt) {
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
const pageIndex = target.dataset.index;
|
|
4165
|
-
if (pageIndex) {
|
|
4166
|
-
this.draw.setPageNo(Number(pageIndex));
|
|
4167
|
-
}
|
|
4168
|
-
this.isAllowDrag = true;
|
|
4169
|
-
const positionResult = this.position.getPositionByXY({
|
|
4170
|
-
x: evt.offsetX,
|
|
4171
|
-
y: evt.offsetY
|
|
4172
|
-
});
|
|
4173
|
-
if (positionResult.isControl && !isReadonly) {
|
|
4174
|
-
const { index: index22, isTable: isTable2, trIndex: trIndex2, tdIndex: tdIndex2, tdValueIndex: tdValueIndex2 } = positionResult;
|
|
4175
|
-
const { newIndex } = this.control.moveCursor({
|
|
4176
|
-
index: index22,
|
|
4177
|
-
isTable: isTable2,
|
|
4178
|
-
trIndex: trIndex2,
|
|
4179
|
-
tdIndex: tdIndex2,
|
|
4180
|
-
tdValueIndex: tdValueIndex2
|
|
4181
|
-
});
|
|
4182
|
-
if (isTable2) {
|
|
4183
|
-
positionResult.tdValueIndex = newIndex;
|
|
4184
|
-
} else {
|
|
4185
|
-
positionResult.index = newIndex;
|
|
4186
|
-
}
|
|
4187
|
-
}
|
|
4188
|
-
const { index: index2, isDirectHit, isCheckbox, isControl, isImage, isTable, trIndex, tdIndex, tdValueIndex, tdId, trId, tableId } = positionResult;
|
|
4189
|
-
this.position.setPositionContext({
|
|
4190
|
-
isTable: isTable || false,
|
|
4191
|
-
isCheckbox: isCheckbox || false,
|
|
4192
|
-
isControl: isControl || false,
|
|
4193
|
-
index: index2,
|
|
4194
|
-
trIndex,
|
|
4195
|
-
tdIndex,
|
|
4196
|
-
tdId,
|
|
4197
|
-
trId,
|
|
4198
|
-
tableId
|
|
4199
|
-
});
|
|
4200
|
-
this.mouseDownStartPosition = __spreadProps(__spreadValues({}, positionResult), {
|
|
4201
|
-
index: isTable ? tdValueIndex : index2
|
|
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
|
-
}
|
|
4226
|
-
}
|
|
4227
|
-
this.draw.render({
|
|
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]);
|
|
4246
|
-
}
|
|
4247
|
-
this.hyperlinkParticle.clearHyperlinkPopup();
|
|
4248
|
-
if (curElement.type === ElementType.HYPERLINK) {
|
|
4249
|
-
this.hyperlinkParticle.drawHyperlinkPopup(curElement, positionList[curIndex]);
|
|
4250
|
-
}
|
|
4251
|
-
this.dateParticle.clearDatePicker();
|
|
4252
|
-
if (curElement.type === ElementType.DATE && !isReadonly) {
|
|
4253
|
-
this.dateParticle.renderDatePicker(curElement, positionList[curIndex]);
|
|
4254
|
-
}
|
|
4792
|
+
mousedown(evt, this);
|
|
4793
|
+
}
|
|
4794
|
+
mouseup(evt) {
|
|
4795
|
+
mouseup(evt, this);
|
|
4255
4796
|
}
|
|
4256
4797
|
mouseleave(evt) {
|
|
4257
|
-
|
|
4258
|
-
if (evt.x >= x && evt.x <= x + width && evt.y >= y && evt.y <= y + height)
|
|
4259
|
-
return;
|
|
4260
|
-
this.setIsAllowDrag(false);
|
|
4798
|
+
mouseleave(evt, this);
|
|
4261
4799
|
}
|
|
4262
4800
|
keydown(evt) {
|
|
4263
|
-
|
|
4264
|
-
const isReadonly = this.draw.isReadonly();
|
|
4265
|
-
const cursorPosition = this.position.getCursorPosition();
|
|
4266
|
-
if (!cursorPosition)
|
|
4267
|
-
return;
|
|
4268
|
-
const elementList = this.draw.getElementList();
|
|
4269
|
-
const position = this.position.getPositionList();
|
|
4270
|
-
const { index: index2 } = cursorPosition;
|
|
4271
|
-
const { startIndex, endIndex } = this.range.getRange();
|
|
4272
|
-
const isCollapsed = startIndex === endIndex;
|
|
4273
|
-
const isPartRangeInControlOutside = this.control.isPartRangeInControlOutside();
|
|
4274
|
-
const activeControl = this.control.getActiveControl();
|
|
4275
|
-
if (evt.key === KeyMap.Backspace) {
|
|
4276
|
-
if (isReadonly || isPartRangeInControlOutside)
|
|
4277
|
-
return;
|
|
4278
|
-
let curIndex;
|
|
4279
|
-
if (activeControl) {
|
|
4280
|
-
curIndex = this.control.keydown(evt);
|
|
4281
|
-
} else {
|
|
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);
|
|
4288
|
-
} else {
|
|
4289
|
-
elementList.splice(index2, 1);
|
|
4290
|
-
}
|
|
4291
|
-
curIndex = isCollapsed ? index2 - 1 : startIndex;
|
|
4292
|
-
}
|
|
4293
|
-
this.range.setRange(curIndex, curIndex);
|
|
4294
|
-
this.draw.render({ curIndex });
|
|
4295
|
-
} else if (evt.key === KeyMap.Delete) {
|
|
4296
|
-
if (isReadonly || isPartRangeInControlOutside)
|
|
4297
|
-
return;
|
|
4298
|
-
let curIndex;
|
|
4299
|
-
if (activeControl) {
|
|
4300
|
-
curIndex = this.control.keydown(evt);
|
|
4301
|
-
} else if (((_a = elementList[endIndex + 1]) == null ? void 0 : _a.type) === ElementType.CONTROL) {
|
|
4302
|
-
curIndex = this.control.removeControl(endIndex + 1);
|
|
4303
|
-
} else {
|
|
4304
|
-
if (!isCollapsed) {
|
|
4305
|
-
elementList.splice(startIndex + 1, endIndex - startIndex);
|
|
4306
|
-
} else {
|
|
4307
|
-
elementList.splice(index2 + 1, 1);
|
|
4308
|
-
}
|
|
4309
|
-
curIndex = isCollapsed ? index2 : startIndex;
|
|
4310
|
-
}
|
|
4311
|
-
this.range.setRange(curIndex, curIndex);
|
|
4312
|
-
this.draw.render({ curIndex });
|
|
4313
|
-
} else if (evt.key === KeyMap.Enter) {
|
|
4314
|
-
if (isReadonly || isPartRangeInControlOutside)
|
|
4315
|
-
return;
|
|
4316
|
-
const positionContext = this.position.getPositionContext();
|
|
4317
|
-
let restArg = {};
|
|
4318
|
-
if (positionContext.isTable) {
|
|
4319
|
-
const { tdId, trId, tableId } = positionContext;
|
|
4320
|
-
restArg = { tdId, trId, tableId };
|
|
4321
|
-
}
|
|
4322
|
-
const enterText = __spreadValues({
|
|
4323
|
-
value: ZERO
|
|
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 });
|
|
4338
|
-
evt.preventDefault();
|
|
4339
|
-
} else if (evt.key === KeyMap.Left) {
|
|
4340
|
-
if (isReadonly)
|
|
4341
|
-
return;
|
|
4342
|
-
if (index2 > 0) {
|
|
4343
|
-
const curIndex = index2 - 1;
|
|
4344
|
-
this.range.setRange(curIndex, curIndex);
|
|
4345
|
-
this.draw.render({
|
|
4346
|
-
curIndex,
|
|
4347
|
-
isSubmitHistory: false,
|
|
4348
|
-
isComputeRowList: false
|
|
4349
|
-
});
|
|
4350
|
-
}
|
|
4351
|
-
} else if (evt.key === KeyMap.Right) {
|
|
4352
|
-
if (isReadonly)
|
|
4353
|
-
return;
|
|
4354
|
-
if (index2 < position.length - 1) {
|
|
4355
|
-
const curIndex = index2 + 1;
|
|
4356
|
-
this.range.setRange(curIndex, curIndex);
|
|
4357
|
-
this.draw.render({
|
|
4358
|
-
curIndex,
|
|
4359
|
-
isSubmitHistory: false,
|
|
4360
|
-
isComputeRowList: false
|
|
4361
|
-
});
|
|
4362
|
-
}
|
|
4363
|
-
} else if (evt.key === KeyMap.Up || evt.key === KeyMap.Down) {
|
|
4364
|
-
if (isReadonly)
|
|
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
|
-
}
|
|
4385
|
-
}
|
|
4386
|
-
if (p === probablePosition.length - 1 && maxIndex === 0) {
|
|
4387
|
-
maxIndex = position2.index;
|
|
4388
|
-
}
|
|
4389
|
-
}
|
|
4390
|
-
const curIndex = maxIndex;
|
|
4391
|
-
this.range.setRange(curIndex, curIndex);
|
|
4392
|
-
this.draw.render({
|
|
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());
|
|
4422
|
-
}
|
|
4423
|
-
evt.preventDefault();
|
|
4424
|
-
} else if (evt.key === KeyMap.ESC) {
|
|
4425
|
-
this.clearPainterStyle();
|
|
4426
|
-
evt.preventDefault();
|
|
4427
|
-
} else if (evt.key === KeyMap.TAB) {
|
|
4428
|
-
this.draw.insertElementList([{
|
|
4429
|
-
type: ElementType.TAB,
|
|
4430
|
-
value: ""
|
|
4431
|
-
}]);
|
|
4432
|
-
evt.preventDefault();
|
|
4433
|
-
}
|
|
4801
|
+
keydown(evt, this);
|
|
4434
4802
|
}
|
|
4435
4803
|
dblclick() {
|
|
4436
|
-
|
|
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--;
|
|
4451
|
-
} else {
|
|
4452
|
-
break;
|
|
4453
|
-
}
|
|
4454
|
-
}
|
|
4455
|
-
let downStartIndex = index2 + 1;
|
|
4456
|
-
while (downStartIndex < elementList.length) {
|
|
4457
|
-
const value2 = elementList[downStartIndex].value;
|
|
4458
|
-
if (isNumber && NUMBER_LIKE_REG.test(value2) || !isNumber && LETTER_REG.test(value2)) {
|
|
4459
|
-
downCount++;
|
|
4460
|
-
downStartIndex++;
|
|
4461
|
-
} else {
|
|
4462
|
-
break;
|
|
4463
|
-
}
|
|
4464
|
-
}
|
|
4465
|
-
}
|
|
4466
|
-
this.range.setRange(index2 - upCount - 1, index2 + downCount);
|
|
4467
|
-
this.draw.render({
|
|
4468
|
-
isSubmitHistory: false,
|
|
4469
|
-
isSetCursor: false,
|
|
4470
|
-
isComputeRowList: false
|
|
4471
|
-
});
|
|
4804
|
+
click.dblclick(this);
|
|
4472
4805
|
}
|
|
4473
4806
|
threeClick() {
|
|
4474
|
-
|
|
4475
|
-
if (!cursorPosition)
|
|
4476
|
-
return;
|
|
4477
|
-
const { index: index2 } = cursorPosition;
|
|
4478
|
-
const elementList = this.draw.getElementList();
|
|
4479
|
-
let upCount = 0;
|
|
4480
|
-
let downCount = 0;
|
|
4481
|
-
let upStartIndex = index2 - 1;
|
|
4482
|
-
while (upStartIndex > 0) {
|
|
4483
|
-
const value = elementList[upStartIndex].value;
|
|
4484
|
-
if (value !== ZERO) {
|
|
4485
|
-
upCount++;
|
|
4486
|
-
upStartIndex--;
|
|
4487
|
-
} else {
|
|
4488
|
-
break;
|
|
4489
|
-
}
|
|
4490
|
-
}
|
|
4491
|
-
let downStartIndex = index2 + 1;
|
|
4492
|
-
while (downStartIndex < elementList.length) {
|
|
4493
|
-
const value = elementList[downStartIndex].value;
|
|
4494
|
-
if (value !== ZERO) {
|
|
4495
|
-
downCount++;
|
|
4496
|
-
downStartIndex++;
|
|
4497
|
-
} else {
|
|
4498
|
-
break;
|
|
4499
|
-
}
|
|
4500
|
-
}
|
|
4501
|
-
this.range.setRange(index2 - upCount - 1, index2 + downCount);
|
|
4502
|
-
this.draw.render({
|
|
4503
|
-
isSubmitHistory: false,
|
|
4504
|
-
isSetCursor: false,
|
|
4505
|
-
isComputeRowList: false
|
|
4506
|
-
});
|
|
4807
|
+
click.threeClick(this);
|
|
4507
4808
|
}
|
|
4508
4809
|
input(data2) {
|
|
4509
|
-
|
|
4510
|
-
const isReadonly = this.draw.isReadonly();
|
|
4511
|
-
if (isReadonly)
|
|
4512
|
-
return;
|
|
4513
|
-
if (!this.cursor)
|
|
4514
|
-
return;
|
|
4515
|
-
const cursorPosition = this.position.getCursorPosition();
|
|
4516
|
-
if (!data2 || !cursorPosition || this.isCompositing)
|
|
4517
|
-
return;
|
|
4518
|
-
if (this.control.isPartRangeInControlOutside()) {
|
|
4519
|
-
return;
|
|
4520
|
-
}
|
|
4521
|
-
const activeControl = this.control.getActiveControl();
|
|
4522
|
-
const { TEXT, HYPERLINK, SUBSCRIPT, SUPERSCRIPT, DATE } = ElementType;
|
|
4523
|
-
const text = data2.replaceAll(`
|
|
4524
|
-
`, ZERO);
|
|
4525
|
-
const elementList = this.draw.getElementList();
|
|
4526
|
-
const agentDom = this.cursor.getAgentDom();
|
|
4527
|
-
agentDom.value = "";
|
|
4528
|
-
const { index: index2 } = cursorPosition;
|
|
4529
|
-
const { startIndex, endIndex } = this.range.getRange();
|
|
4530
|
-
const isCollapsed = startIndex === endIndex;
|
|
4531
|
-
const positionContext = this.position.getPositionContext();
|
|
4532
|
-
let restArg = {};
|
|
4533
|
-
if (positionContext.isTable) {
|
|
4534
|
-
const { tdId, trId, tableId } = positionContext;
|
|
4535
|
-
restArg = { tdId, trId, tableId };
|
|
4536
|
-
}
|
|
4537
|
-
const element = elementList[endIndex];
|
|
4538
|
-
const inputData = splitText(text).map((value) => {
|
|
4539
|
-
const newElement = __spreadValues({
|
|
4540
|
-
value
|
|
4541
|
-
}, restArg);
|
|
4542
|
-
const nextElement = elementList[endIndex + 1];
|
|
4543
|
-
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) {
|
|
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);
|
|
4556
|
-
} else {
|
|
4557
|
-
let start = 0;
|
|
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;
|
|
4568
|
-
}
|
|
4569
|
-
this.range.setRange(curIndex, curIndex);
|
|
4570
|
-
this.draw.render({ curIndex });
|
|
4810
|
+
input(data2, this);
|
|
4571
4811
|
}
|
|
4572
4812
|
cut() {
|
|
4573
|
-
|
|
4574
|
-
if (isReadonly)
|
|
4575
|
-
return;
|
|
4576
|
-
const isPartRangeInControlOutside = this.control.isPartRangeInControlOutside();
|
|
4577
|
-
if (isPartRangeInControlOutside)
|
|
4578
|
-
return;
|
|
4579
|
-
const activeControl = this.control.getActiveControl();
|
|
4580
|
-
const { startIndex, endIndex } = this.range.getRange();
|
|
4581
|
-
const elementList = this.draw.getElementList();
|
|
4582
|
-
if (startIndex !== endIndex) {
|
|
4583
|
-
writeElementList(elementList.slice(startIndex + 1, endIndex + 1), this.options);
|
|
4584
|
-
let curIndex;
|
|
4585
|
-
if (activeControl) {
|
|
4586
|
-
curIndex = this.control.cut();
|
|
4587
|
-
} else {
|
|
4588
|
-
elementList.splice(startIndex + 1, endIndex - startIndex);
|
|
4589
|
-
curIndex = startIndex;
|
|
4590
|
-
}
|
|
4591
|
-
this.range.setRange(curIndex, curIndex);
|
|
4592
|
-
this.draw.render({ curIndex });
|
|
4593
|
-
}
|
|
4813
|
+
cut(this);
|
|
4594
4814
|
}
|
|
4595
4815
|
copy() {
|
|
4596
|
-
|
|
4597
|
-
const elementList = this.draw.getElementList();
|
|
4598
|
-
if (startIndex !== endIndex) {
|
|
4599
|
-
writeElementList(elementList.slice(startIndex + 1, endIndex + 1), this.options);
|
|
4600
|
-
}
|
|
4601
|
-
}
|
|
4602
|
-
selectAll() {
|
|
4603
|
-
const position = this.position.getPositionList();
|
|
4604
|
-
this.range.setRange(0, position.length - 1);
|
|
4605
|
-
this.draw.render({
|
|
4606
|
-
isSubmitHistory: false,
|
|
4607
|
-
isSetCursor: false,
|
|
4608
|
-
isComputeRowList: false
|
|
4609
|
-
});
|
|
4816
|
+
copy(this);
|
|
4610
4817
|
}
|
|
4611
4818
|
compositionstart() {
|
|
4612
|
-
this
|
|
4819
|
+
composition.compositionstart(this);
|
|
4613
4820
|
}
|
|
4614
4821
|
compositionend() {
|
|
4615
|
-
this
|
|
4822
|
+
composition.compositionend(this);
|
|
4823
|
+
}
|
|
4824
|
+
drop(evt) {
|
|
4825
|
+
drop(evt, this);
|
|
4826
|
+
}
|
|
4827
|
+
dragover(evt) {
|
|
4828
|
+
drag.dragover(evt, this);
|
|
4616
4829
|
}
|
|
4617
4830
|
}
|
|
4618
4831
|
class GlobalEvent {
|
|
@@ -4651,8 +4864,9 @@ class GlobalEvent {
|
|
|
4651
4864
|
this.control.destroyControl();
|
|
4652
4865
|
this.dateParticle.clearDatePicker();
|
|
4653
4866
|
});
|
|
4654
|
-
__publicField(this, "
|
|
4867
|
+
__publicField(this, "setCanvasEventAbility", () => {
|
|
4655
4868
|
this.canvasEvent.setIsAllowDrag(false);
|
|
4869
|
+
this.canvasEvent.setIsAllowSelection(false);
|
|
4656
4870
|
});
|
|
4657
4871
|
__publicField(this, "setRangeStyle", () => {
|
|
4658
4872
|
this.range.setRangeStyle();
|
|
@@ -4700,7 +4914,7 @@ class GlobalEvent {
|
|
|
4700
4914
|
window.addEventListener("blur", this.recoverEffect);
|
|
4701
4915
|
document.addEventListener("keyup", this.setRangeStyle);
|
|
4702
4916
|
document.addEventListener("click", this.recoverEffect);
|
|
4703
|
-
document.addEventListener("mouseup", this.
|
|
4917
|
+
document.addEventListener("mouseup", this.setCanvasEventAbility);
|
|
4704
4918
|
document.addEventListener("wheel", this.setPageScale, { passive: false });
|
|
4705
4919
|
document.addEventListener("visibilitychange", this._handleVisibilityChange);
|
|
4706
4920
|
}
|
|
@@ -4708,7 +4922,7 @@ class GlobalEvent {
|
|
|
4708
4922
|
window.removeEventListener("blur", this.recoverEffect);
|
|
4709
4923
|
document.removeEventListener("keyup", this.setRangeStyle);
|
|
4710
4924
|
document.removeEventListener("click", this.recoverEffect);
|
|
4711
|
-
document.removeEventListener("mouseup", this.
|
|
4925
|
+
document.removeEventListener("mouseup", this.setCanvasEventAbility);
|
|
4712
4926
|
document.removeEventListener("wheel", this.setPageScale);
|
|
4713
4927
|
document.removeEventListener("visibilitychange", this._handleVisibilityChange);
|
|
4714
4928
|
}
|
|
@@ -4915,6 +5129,43 @@ class Position {
|
|
|
4915
5129
|
isControl: ((_b = elementList[curPositionIndex]) == null ? void 0 : _b.type) === ElementType.CONTROL
|
|
4916
5130
|
};
|
|
4917
5131
|
}
|
|
5132
|
+
adjustPositionContext(payload) {
|
|
5133
|
+
const isReadonly = this.draw.isReadonly();
|
|
5134
|
+
const { x, y } = payload;
|
|
5135
|
+
const positionResult = this.getPositionByXY({
|
|
5136
|
+
x,
|
|
5137
|
+
y
|
|
5138
|
+
});
|
|
5139
|
+
if (positionResult.isControl && !isReadonly) {
|
|
5140
|
+
const { index: index22, isTable: isTable2, trIndex: trIndex2, tdIndex: tdIndex2, tdValueIndex } = positionResult;
|
|
5141
|
+
const control = this.draw.getControl();
|
|
5142
|
+
const { newIndex } = control.moveCursor({
|
|
5143
|
+
index: index22,
|
|
5144
|
+
isTable: isTable2,
|
|
5145
|
+
trIndex: trIndex2,
|
|
5146
|
+
tdIndex: tdIndex2,
|
|
5147
|
+
tdValueIndex
|
|
5148
|
+
});
|
|
5149
|
+
if (isTable2) {
|
|
5150
|
+
positionResult.tdValueIndex = newIndex;
|
|
5151
|
+
} else {
|
|
5152
|
+
positionResult.index = newIndex;
|
|
5153
|
+
}
|
|
5154
|
+
}
|
|
5155
|
+
const { index: index2, isCheckbox, isControl, isTable, trIndex, tdIndex, tdId, trId, tableId } = positionResult;
|
|
5156
|
+
this.setPositionContext({
|
|
5157
|
+
isTable: isTable || false,
|
|
5158
|
+
isCheckbox: isCheckbox || false,
|
|
5159
|
+
isControl: isControl || false,
|
|
5160
|
+
index: index2,
|
|
5161
|
+
trIndex,
|
|
5162
|
+
tdIndex,
|
|
5163
|
+
tdId,
|
|
5164
|
+
trId,
|
|
5165
|
+
tableId
|
|
5166
|
+
});
|
|
5167
|
+
return positionResult;
|
|
5168
|
+
}
|
|
4918
5169
|
}
|
|
4919
5170
|
class RangeManager {
|
|
4920
5171
|
constructor(draw) {
|
|
@@ -4963,6 +5214,17 @@ class RangeManager {
|
|
|
4963
5214
|
}
|
|
4964
5215
|
return rangeRow;
|
|
4965
5216
|
}
|
|
5217
|
+
getIsPointInRange(x, y) {
|
|
5218
|
+
const { startIndex, endIndex } = this.range;
|
|
5219
|
+
const positionList = this.position.getPositionList();
|
|
5220
|
+
for (let p = startIndex + 1; p <= endIndex; p++) {
|
|
5221
|
+
const { coordinate: { leftTop, rightBottom } } = positionList[p];
|
|
5222
|
+
if (x >= leftTop[0] && x <= rightBottom[0] && y >= leftTop[1] && y <= rightBottom[1]) {
|
|
5223
|
+
return true;
|
|
5224
|
+
}
|
|
5225
|
+
}
|
|
5226
|
+
return false;
|
|
5227
|
+
}
|
|
4966
5228
|
setRange(startIndex, endIndex, tableId, startTdIndex, endTdIndex, startTrIndex, endTrIndex) {
|
|
4967
5229
|
this.range.startIndex = startIndex;
|
|
4968
5230
|
this.range.endIndex = endIndex;
|
|
@@ -10714,7 +10976,7 @@ const globalMenus = [
|
|
|
10714
10976
|
name: "\u526A\u5207",
|
|
10715
10977
|
shortCut: "Ctrl + X",
|
|
10716
10978
|
when: (payload) => {
|
|
10717
|
-
return !payload.isReadonly
|
|
10979
|
+
return !payload.isReadonly;
|
|
10718
10980
|
},
|
|
10719
10981
|
callback: (command) => {
|
|
10720
10982
|
command.executeCut();
|