From e54b659e0935a555d698e573285ffa938521beb2 Mon Sep 17 00:00:00 2001 From: seonim-ryu Date: Tue, 28 Jul 2020 21:58:45 +0900 Subject: [PATCH] refactor: recover seperated logic --- apps/editor/src/js/markdownEditor.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/apps/editor/src/js/markdownEditor.js b/apps/editor/src/js/markdownEditor.js index ac0baa2f10..84c210e1b8 100644 --- a/apps/editor/src/js/markdownEditor.js +++ b/apps/editor/src/js/markdownEditor.js @@ -346,7 +346,9 @@ class MarkdownEditor extends CodeMirrorExt { } _changeTextToTaskMarker() { - const mdNode = this._getNodeByCursor(); + const { line, ch } = this.cm.getCursor(); + const mdCh = this.cm.getLine(line).length === ch ? ch : ch + 1; + const mdNode = this.toastMark.findNodeAtPosition([line + 1, mdCh]); const paraNode = findClosestNode( mdNode, node => node.type === 'paragraph' && node.parent && node.parent.type === 'item' @@ -453,13 +455,6 @@ class MarkdownEditor extends CodeMirrorExt { this._setToolbarState(state); } - _getNodeByCursor() { - const { line, ch } = this.cm.getCursor(); - const mdCh = this.cm.getLine(line).length === ch ? ch : ch + 1; - - return this.toastMark.findNodeAtPosition([line + 1, mdCh]); - } - /** * latestState reset */