Browse Source

fix(gui-v2): remove IE insertAtCursor logic

pull/2998/head
Wing-Kam Wong 2 years ago
parent
commit
8c87d2ee21
  1. 10
      packages/nc-gui-v2/utils/formulaUtils.ts

10
packages/nc-gui-v2/utils/formulaUtils.ts

@ -398,17 +398,11 @@ const formulaList = Object.keys(formulas)
// ref : https://stackoverflow.com/a/11077016
function insertAtCursor(myField: typeof AntInput, myValue: string, len = 0, b = 0) {
// IE support
if (document) {
myField.focus()
const sel = document.createRange() as any
sel.text = myValue
} // MOZILLA and others
else if (myField.selectionStart || myField.selectionStart === '0') {
// MOZILLA and others
if (myField.selectionStart || myField.selectionStart === 0) {
const startPos = myField.selectionStart
const endPos = myField.selectionEnd
myField.value = myField.value.substring(0, startPos - len) + myValue + myField.value.substring(endPos, myField.value.length)
const pos = +startPos - len + myValue.length - b
// https://stackoverflow.com/a/4302688
if (myField.setSelectionRange) {

Loading…
Cancel
Save