From b0a03d53fcedc864e5dcd794dd7b0d0d92400405 Mon Sep 17 00:00:00 2001 From: tophf Date: Sat, 24 Apr 2021 16:26:14 +0300 Subject: [PATCH] move lazyKeymaps definition to the base init --- edit/base.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/edit/base.js b/edit/base.js index f44686d2..117394f7 100644 --- a/edit/base.js +++ b/edit/base.js @@ -24,6 +24,10 @@ const editor = { dirty: DirtyReporter(), isUsercss: false, isWindowed: false, + lazyKeymaps: { + emacs: '/vendor/codemirror/keymap/emacs', + vim: '/vendor/codemirror/keymap/vim', + }, livePreview: null, /** @type {'customName'|'name'} */ nameTarget: 'name', @@ -43,10 +47,6 @@ const editor = { //#region pre-init const baseInit = (() => { - const lazyKeymaps = { - emacs: '/vendor/codemirror/keymap/emacs', - vim: '/vendor/codemirror/keymap/vim', - }; const domReady = waitForSelector('#sections'); return { @@ -65,8 +65,8 @@ const baseInit = (() => { /** Preloads vim/emacs keymap only if it's the active one, otherwise will load later */ function loadKeymaps() { const km = prefs.get('editor.keyMap'); - return /emacs/i.test(km) && require([lazyKeymaps.emacs]) || - /vim/i.test(km) && require([lazyKeymaps.vim]); + return /emacs/i.test(km) && require([editor.lazyKeymaps.emacs]) || + /vim/i.test(km) && require([editor.lazyKeymaps.vim]); } async function loadStyle() { @@ -83,7 +83,6 @@ const baseInit = (() => { }; // switching the mode here to show the correct page ASAP, usually before DOMContentLoaded editor.isUsercss = Boolean(style.usercssData || !style.id && prefs.get('newStyleAsUsercss')); - editor.lazyKeymaps = lazyKeymaps; editor.style = style; editor.updateTitle(false); document.documentElement.classList.toggle('usercss', editor.isUsercss);