Fix: minor

This commit is contained in:
eight 2018-10-14 16:17:45 +08:00
parent 05a87ed00f
commit 05a6208f5c
3 changed files with 9 additions and 9 deletions

View File

@ -1,5 +1,4 @@
/* global importScripts workerUtil CSSLint require metaParser */ /* global importScripts workerUtil CSSLint require metaParser */
/* exported editorWorker */
'use strict'; 'use strict';
importScripts('/js/worker-util.js'); importScripts('/js/worker-util.js');

View File

@ -14,10 +14,10 @@ const rerouteHotkeys = (() => {
'colorpicker', 'colorpicker',
]); ]);
rerouteHotkeys(true);
return rerouteHotkeys; return rerouteHotkeys;
// note that this function relies on `editor`. Calling this function before
// the editor is initialized may throw an error.
function rerouteHotkeys(enable, immediately) { function rerouteHotkeys(enable, immediately) {
if (!immediately) { if (!immediately) {
debounce(rerouteHotkeys, 0, enable, true); debounce(rerouteHotkeys, 0, enable, true);
@ -29,9 +29,6 @@ const rerouteHotkeys = (() => {
} }
function rerouteHandler(event) { function rerouteHandler(event) {
if (typeof editor === 'undefined') {
return;
}
const keyName = CodeMirror.keyName(event); const keyName = CodeMirror.keyName(event);
if (!keyName) { if (!keyName) {
return; return;

View File

@ -70,17 +70,21 @@ function createResizeGrip(cm) {
} }
function createSection({ function createSection({
// data model
originalSection, originalSection,
genId,
dirty, dirty,
// util
nextEditor,
prevEditor,
genId,
// emit events
// TODO: better names like `onRemoved`? Or make a real event emitter.
showMozillaFormatImport, showMozillaFormatImport,
removeSection, removeSection,
insertSectionAfter, insertSectionAfter,
moveSectionUp, moveSectionUp,
moveSectionDown, moveSectionDown,
restoreSection, restoreSection,
nextEditor,
prevEditor
}) { }) {
const sectionId = genId(); const sectionId = genId();
const el = template.section.cloneNode(true); const el = template.section.cloneNode(true);