e-virt-table 1.3.18 → 1.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +30 -24
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/Editor.d.ts +1 -0
- package/dist/lib/Editor.js +46 -18
- package/dist/lib/Editor.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -6741,29 +6741,28 @@ class Oi {
|
|
|
6741
6741
|
this.ctx.on("outsideMousedown", () => {
|
|
6742
6742
|
this.cellTarget && this.cellTarget.editorType === "text" && this.clearEditor();
|
|
6743
6743
|
}), this.ctx.on("moveFocus", (t) => {
|
|
6744
|
-
this.cellTarget = t;
|
|
6744
|
+
this.cellTarget = t, this.resetEditorStyle();
|
|
6745
6745
|
const { xArr: e, yArr: i } = this.ctx.selector;
|
|
6746
6746
|
this.selectorArrStr = JSON.stringify(e) + JSON.stringify(i);
|
|
6747
6747
|
}), this.ctx.on("onScroll", () => {
|
|
6748
6748
|
this.enable && this.doneEdit();
|
|
6749
6749
|
}), this.ctx.on("hoverIconClick", (t) => {
|
|
6750
6750
|
this.editCell(t.rowIndex, t.colIndex);
|
|
6751
|
-
}), this.ctx.on("cellMousedown", () => {
|
|
6752
|
-
this.inputEl.focus({ preventScroll: !0 });
|
|
6753
6751
|
}), this.ctx.on("keydown", (t) => {
|
|
6754
6752
|
if (!this.ctx.isTarget(t) || !this.ctx.focusCell || this.ctx.finding)
|
|
6755
6753
|
return;
|
|
6756
|
-
|
|
6754
|
+
const { focusCell: e } = this.ctx;
|
|
6755
|
+
if (e.isVerticalVisible() && e.isHorizontalVisible() || this.ctx.emit("scrollToIndex", e.rowIndex, e.colIndex), t.code === "Escape" && this.ctx.editing) {
|
|
6757
6756
|
this.cancel = !0;
|
|
6758
|
-
const { focusCell:
|
|
6759
|
-
|
|
6757
|
+
const { focusCell: f } = this.ctx;
|
|
6758
|
+
f && (this.ctx.emit("setSelectorCell", f), this.cellTarget = f), this.doneEdit();
|
|
6760
6759
|
return;
|
|
6761
6760
|
}
|
|
6762
6761
|
if ((t.altKey || t.metaKey) && t.key === "Enter" && this.ctx.editing && this.inputEl) {
|
|
6763
6762
|
t.preventDefault();
|
|
6764
|
-
const
|
|
6765
|
-
this.inputEl.value =
|
|
6766
|
-
` +
|
|
6763
|
+
const f = this.inputEl.selectionStart, u = this.inputEl.value.substring(0, f), x = this.inputEl.value.substring(f);
|
|
6764
|
+
this.inputEl.value = u + `
|
|
6765
|
+
` + x, this.inputEl.selectionStart = this.inputEl.selectionEnd = f + 1, this.autoSize();
|
|
6767
6766
|
return;
|
|
6768
6767
|
}
|
|
6769
6768
|
if (t.code === "Tab" && this.ctx.editing) {
|
|
@@ -6786,8 +6785,8 @@ class Oi {
|
|
|
6786
6785
|
t.preventDefault(), this.startEdit();
|
|
6787
6786
|
return;
|
|
6788
6787
|
}
|
|
6789
|
-
const
|
|
6790
|
-
|
|
6788
|
+
const s = t.key, o = t.ctrlKey, r = t.altKey, a = t.shiftKey, l = t.metaKey;
|
|
6789
|
+
if (o || r || a || l || [
|
|
6791
6790
|
"Enter",
|
|
6792
6791
|
"Escape",
|
|
6793
6792
|
"Tab",
|
|
@@ -6814,7 +6813,14 @@ class Oi {
|
|
|
6814
6813
|
"F10",
|
|
6815
6814
|
"F11",
|
|
6816
6815
|
"F12"
|
|
6817
|
-
].includes(
|
|
6816
|
+
].includes(s))
|
|
6817
|
+
return;
|
|
6818
|
+
const d = document.activeElement === this.inputEl;
|
|
6819
|
+
if (!this.ctx.selectOnlyOne || !d) {
|
|
6820
|
+
t.preventDefault(), this.inputEl.blur();
|
|
6821
|
+
return;
|
|
6822
|
+
}
|
|
6823
|
+
this.startEdit(!0);
|
|
6818
6824
|
}), this.ctx.on("cellMouseup", (t) => {
|
|
6819
6825
|
if (this.ctx.isPointer || !this.isInSelectorRange(t.rowIndex, t.colIndex))
|
|
6820
6826
|
return;
|
|
@@ -6829,7 +6835,7 @@ class Oi {
|
|
|
6829
6835
|
return;
|
|
6830
6836
|
}
|
|
6831
6837
|
}
|
|
6832
|
-
if (this.selectorArrStr = s, this.doneEdit(), this.cellTarget = t, this.ctx.config.ENABLE_EDIT_SINGLE_CLICK) {
|
|
6838
|
+
if (this.selectorArrStr = s, this.doneEdit(), this.cellTarget = t, this.ctx.selectOnlyOne && this.inputEl.focus({ preventScroll: !0 }), this.resetEditorStyle(), this.ctx.config.ENABLE_EDIT_SINGLE_CLICK) {
|
|
6833
6839
|
if (this.ctx.config.ENABLE_MERGE_CELL_LINK && this.ctx.onlyMergeCell) {
|
|
6834
6840
|
this.startEdit();
|
|
6835
6841
|
return;
|
|
@@ -6837,7 +6843,7 @@ class Oi {
|
|
|
6837
6843
|
this.ctx.selectOnlyOne && this.startEdit();
|
|
6838
6844
|
}
|
|
6839
6845
|
}), this.ctx.on("mousedownBodyOutside", () => {
|
|
6840
|
-
this.
|
|
6846
|
+
this.clearEditor();
|
|
6841
6847
|
});
|
|
6842
6848
|
}
|
|
6843
6849
|
isInSelectorRange(t, e) {
|
|
@@ -6848,6 +6854,8 @@ class Oi {
|
|
|
6848
6854
|
this.inputEl = document.createElement("textarea"), this.inputEl.id = "e-virt-table-editor-textarea", this.inputEl.setAttribute("rows", "1"), this.inputEl.setAttribute("tabindex", "-1"), this.inputEl.addEventListener("input", this.autoSize.bind(this)), this.editorEl = this.ctx.editorElement, this.inputEl.className = "e-virt-table-editor-textarea", this.editorEl.appendChild(this.inputEl), this.ctx.containerElement.appendChild(this.editorEl);
|
|
6849
6855
|
}
|
|
6850
6856
|
autoSize() {
|
|
6857
|
+
if (!this.ctx.editing)
|
|
6858
|
+
return;
|
|
6851
6859
|
const t = this.inputEl.value;
|
|
6852
6860
|
this.cellTarget && this.cellTarget.type === "number" && t !== "" && (this.ctx.emit("cellHideTooltip"), /^-?\d+(\.\d+)?$/.test(t) || this.ctx.emit("cellShowTooltip", this.cellTarget, this.ctx.config.NUMBER_ERROR_TIP)), this.inputEl.style.height = "auto";
|
|
6853
6861
|
let e = this.inputEl.scrollHeight, i = this.ctx.body.visibleHeight;
|
|
@@ -6872,7 +6880,7 @@ class Oi {
|
|
|
6872
6880
|
header: d
|
|
6873
6881
|
} = this.ctx;
|
|
6874
6882
|
let f = this.ctx.body.visibleHeight;
|
|
6875
|
-
o > f && (o = f), this.editorEl.style.display = "inline-block", this.editorEl.style.zIndex = "100", this.editorEl.style.left = `${this.drawX - 1}px`, this.editorEl.style.top = `${this.drawY
|
|
6883
|
+
o > f && (o = f), this.editorEl.style.display = "inline-block", this.editorEl.style.zIndex = "100", this.editorEl.style.left = `${this.drawX - 1}px`, this.editorEl.style.top = `${this.drawY}px`, this.editorEl.style.bottom = "auto", this.editorEl.style.maxWidth = "none", this.editorEl.style.maxHeight = `${f}px`, ["text"].includes(s) ? (this.inputEl.style.opacity = "1", this.inputEl.style.position = "relative", this.inputEl.style.display = "inline-block", this.inputEl.style.minWidth = `${r - 1}px`, this.inputEl.style.minHeight = `${o - 1}px`, this.inputEl.style.maxHeight = `${f}px`, this.inputEl.style.width = `${r}px`, this.inputEl.style.height = "auto", this.inputEl.style.padding = `${h}px`, this.inputEl.value = "", i !== null && (this.inputEl.value = i)) : (this.inputEl.style.opacity = "0", this.inputEl.style.position = "absolute"), (this.inputEl.scrollHeight > o || this.drawY < d.height) && this.autoSize();
|
|
6876
6884
|
}
|
|
6877
6885
|
doneEditByInput() {
|
|
6878
6886
|
if (this.cellTarget && this.cellTarget.editorType === "text") {
|
|
@@ -6906,18 +6914,16 @@ class Oi {
|
|
|
6906
6914
|
o && !l && (this.enable = !0, this.ctx.editing = !0, this.cellTarget = o, this.startEditByInput(this.cellTarget), this.ctx.emit("startEdit", this.cellTarget), this.ctx.emit("draw"));
|
|
6907
6915
|
}
|
|
6908
6916
|
doneEdit() {
|
|
6909
|
-
|
|
6910
|
-
return;
|
|
6911
|
-
const {
|
|
6912
|
-
header: t,
|
|
6913
|
-
config: { CELL_HEIGHT: e }
|
|
6914
|
-
} = this.ctx;
|
|
6915
|
-
this.doneEditByInput(), this.ctx.emit("cellHideTooltip"), this.ctx.emit("doneEdit", this.cellTarget), this.enable = !1, this.ctx.editing = !1, this.inputEl.style.display = "inline-block", this.editorEl.style.left = "0px", this.editorEl.style.top = `${t.height}px`, this.editorEl.style.maxHeight = `${e}px`, this.editorEl.style.zIndex = "-1", setTimeout(() => {
|
|
6917
|
+
this.enable && (this.doneEditByInput(), this.ctx.emit("cellHideTooltip"), this.ctx.emit("doneEdit", this.cellTarget), this.enable = !1, this.ctx.editing = !1, this.resetEditorStyle(), setTimeout(() => {
|
|
6916
6918
|
this.inputEl.focus({ preventScroll: !0 });
|
|
6917
|
-
}, 0), this.ctx.emit("draw");
|
|
6919
|
+
}, 0), this.ctx.emit("draw"));
|
|
6920
|
+
}
|
|
6921
|
+
resetEditorStyle() {
|
|
6922
|
+
const t = this.cellTarget;
|
|
6923
|
+
t && (this.editorEl.style.left = `${t.drawX}px`, this.editorEl.style.top = `${t.drawY}px`, this.editorEl.style.maxWidth = "1px", this.editorEl.style.maxHeight = "1px", this.editorEl.style.zIndex = "-1");
|
|
6918
6924
|
}
|
|
6919
6925
|
clearEditor() {
|
|
6920
|
-
this.doneEdit(), this.cellTarget = null, this.selectorArrStr = "", this.ctx.clearSelector(), this.ctx.focusCell = void 0, this.ctx.emit("draw");
|
|
6926
|
+
this.doneEdit(), this.cellTarget = null, this.selectorArrStr = "", this.ctx.clearSelector(), this.ctx.focusCell = void 0, this.inputEl.blur(), this.ctx.emit("draw");
|
|
6921
6927
|
}
|
|
6922
6928
|
destroy() {
|
|
6923
6929
|
var t;
|