From b2310e53fcf089cab6e0ead7f4a7ee93f212fcb4 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 14 Dec 2021 18:04:47 -0800 Subject: [PATCH] Fix node text edition error --- .../mindplot/src/components/MultilineTextEditor.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/mindplot/src/components/MultilineTextEditor.js b/packages/mindplot/src/components/MultilineTextEditor.js index 8ac52db5..838b1e42 100644 --- a/packages/mindplot/src/components/MultilineTextEditor.js +++ b/packages/mindplot/src/components/MultilineTextEditor.js @@ -92,8 +92,8 @@ class MultilineTextEditor extends Events { break; case 'tab': event.preventDefault(); - var start = $(this).get(0).selectionStart; - var end = $(this).get(0).selectionEnd; + const start = $(this).get(0).selectionStart; + const end = $(this).get(0).selectionEnd; // set textarea value to: text before caret + tab + text after caret $(this).val(`${$(this).val().substring(0, start)}\t${$(this).val().substring(end)}`); @@ -101,6 +101,9 @@ class MultilineTextEditor extends Events { // put caret at right position again $(this).get(0).selectionStart = $(this).get(0).selectionEnd = start + 1; break; + default: + // No actions... + break; } event.stopPropagation(); }); @@ -192,8 +195,9 @@ class MultilineTextEditor extends Events { font.color = nodeText.getColor(); this._setStyle(font); const me = this; + // Set editor's initial size - const displayFunc = function () { + const displayFunc = function displayFunc() { // Position the editor and set the size... const textShape = topic.getTextShape(); @@ -212,7 +216,7 @@ class MultilineTextEditor extends Events { me._positionCursor(inputElem, !$defined(defaultText)); }; - this._timeoutId = displayFunc.delay(10); + this._timeoutId = setTimeout(() => displayFunc(), 10); } _setStyle(fontStyle) {