diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-09-12 16:28:47 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-09-12 16:28:56 +0800 |
commit | a6c7ca4626d495580c7a60dee7d0f5ccb090a629 (patch) | |
tree | 84991a018e106515e8c87783ac1c30f105d900c0 /src/editor.mjs | |
parent | a67e5adede9fca1326e50bd530861fae75b2bf3d (diff) |
chore: Fix warning from eslint
Diffstat (limited to 'src/editor.mjs')
-rw-r--r-- | src/editor.mjs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/editor.mjs b/src/editor.mjs index beee35b..5470b64 100644 --- a/src/editor.mjs +++ b/src/editor.mjs | |||
@@ -1,3 +1,5 @@ | |||
1 | /*global EasyMDE*/ | ||
2 | /*eslint no-undef: "error"*/ | ||
1 | import { markdown2HTML, generateMaps } from './dumbymap' | 3 | import { markdown2HTML, generateMaps } from './dumbymap' |
2 | import { defaultAliasesForRenderer, parseConfigsFromYaml } from 'mapclay' | 4 | import { defaultAliasesForRenderer, parseConfigsFromYaml } from 'mapclay' |
3 | import { createDocLinks } from './dumbymap.mjs' | 5 | import { createDocLinks } from './dumbymap.mjs' |
@@ -270,7 +272,7 @@ const getSuggestions = (anchor) => { | |||
270 | .then(rendererModule => { | 272 | .then(rendererModule => { |
271 | rendererOptions[renderer] = rendererModule.default.validOptions | 273 | rendererOptions[renderer] = rendererModule.default.validOptions |
272 | }) | 274 | }) |
273 | .catch(() => { | 275 | .catch(_ => { |
274 | markInputIsInvalid(lineWithRenderer) | 276 | markInputIsInvalid(lineWithRenderer) |
275 | console.warn(`Fail to get valid options from renderer with URL ${rendererUrl}`) | 277 | console.warn(`Fail to get valid options from renderer with URL ${rendererUrl}`) |
276 | }) | 278 | }) |
@@ -406,6 +408,7 @@ cm.on('keydown', (_, e) => { | |||
406 | const focusSuggestion = e.shiftKey ? previousSuggestion : nextSuggestion | 408 | const focusSuggestion = e.shiftKey ? previousSuggestion : nextSuggestion |
407 | 409 | ||
408 | // Current editor selection state | 410 | // Current editor selection state |
411 | const anchor = cm.getCursor() | ||
409 | switch (e.key) { | 412 | switch (e.key) { |
410 | case 'Tab': | 413 | case 'Tab': |
411 | Array.from(suggestionsEle.children).forEach(s => s.classList.remove('focus')) | 414 | Array.from(suggestionsEle.children).forEach(s => s.classList.remove('focus')) |
@@ -416,7 +419,6 @@ cm.on('keydown', (_, e) => { | |||
416 | currentSuggestion.onclick() | 419 | currentSuggestion.onclick() |
417 | break; | 420 | break; |
418 | case 'Escape': | 421 | case 'Escape': |
419 | const anchor = cm.getCursor() | ||
420 | suggestionsEle.style.display = 'none'; | 422 | suggestionsEle.style.display = 'none'; |
421 | // Focus editor again | 423 | // Focus editor again |
422 | setTimeout(() => cm.focus() && cm.setCursor(anchor), 100) | 424 | setTimeout(() => cm.focus() && cm.setCursor(anchor), 100) |