Skip to content

Commit

Permalink
refactor: recover seperated logic
Browse files Browse the repository at this point in the history
  • Loading branch information
seonim-ryu committed Jul 28, 2020
1 parent 1d5075c commit e54b659
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions apps/editor/src/js/markdownEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
*/
Expand Down

0 comments on commit e54b659

Please sign in to comment.