wxiaoguang 2023-05-10 23:50:58 +08:00 committed by GitHub
parent 54f399c4df
commit 23ae939ef3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 111 additions and 39 deletions

View file

@ -1,5 +1,5 @@
import {basename, extname, isObject, isDarkTheme} from '../utils.js';
import {debounce} from 'throttle-debounce';
import {onInputDebounce} from '../utils/dom.js';
const languagesByFilename = {};
const languagesByExt = {};
@ -164,7 +164,7 @@ export async function createCodeEditor(textarea, filenameInput) {
...getEditorConfigOptions(editorConfig),
});
filenameInput.addEventListener('input', debounce(500, () => {
filenameInput.addEventListener('input', onInputDebounce(() => {
const filename = filenameInput.value;
const previewable = previewableExts.has(extname(filename));
togglePreviewDisplay(previewable);