mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-05-09 20:38:40 +00:00
fix snippetbar just in case
This commit is contained in:
@@ -11,6 +11,21 @@ import MetadataEditor from './metadataEditor/metadataEditor.jsx';
|
|||||||
|
|
||||||
const EDITOR_THEME_KEY = 'HB_editor_theme';
|
const EDITOR_THEME_KEY = 'HB_editor_theme';
|
||||||
|
|
||||||
|
import * as themesImport from '@uiw/codemirror-themes-all';
|
||||||
|
import defaultCM5Theme from '@themes/codeMirror/default.js';
|
||||||
|
import darkbrewery from '@themes/codeMirror/darkbrewery.js';
|
||||||
|
|
||||||
|
const themes = { default: defaultCM5Theme, darkbrewery, ...themesImport };
|
||||||
|
|
||||||
|
const EditorThemes = Object.entries(themes)
|
||||||
|
.filter(([name, value]) =>
|
||||||
|
Array.isArray(value) &&
|
||||||
|
!name.endsWith('Init') &&
|
||||||
|
!name.endsWith('Style')
|
||||||
|
)
|
||||||
|
.map(([name]) => name);
|
||||||
|
|
||||||
|
|
||||||
const PAGEBREAK_REGEX_V3 = /^(?=\\page(?:break)?(?: *{[^\n{}]*})?$)/m;
|
const PAGEBREAK_REGEX_V3 = /^(?=\\page(?:break)?(?: *{[^\n{}]*})?$)/m;
|
||||||
//const SNIPPETBREAK_REGEX_V3 = /^\\snippet\ .*$/;
|
//const SNIPPETBREAK_REGEX_V3 = /^\\snippet\ .*$/;
|
||||||
const DEFAULT_STYLE_TEXT = dedent`
|
const DEFAULT_STYLE_TEXT = dedent`
|
||||||
@@ -75,10 +90,10 @@ const Editor = createReactClass({
|
|||||||
document.addEventListener('keydown', this.handleControlKeys);
|
document.addEventListener('keydown', this.handleControlKeys);
|
||||||
|
|
||||||
const editorTheme = window.localStorage.getItem(EDITOR_THEME_KEY);
|
const editorTheme = window.localStorage.getItem(EDITOR_THEME_KEY);
|
||||||
if(editorTheme) {
|
if (editorTheme && EditorThemes.includes(editorTheme)) {
|
||||||
this.setState({
|
this.setState({ editorTheme });
|
||||||
editorTheme : editorTheme
|
} else {
|
||||||
});
|
this.setState({ editorTheme: 'default' });
|
||||||
}
|
}
|
||||||
const snippetBar = document.querySelector('.editor > .snippetBar');
|
const snippetBar = document.querySelector('.editor > .snippetBar');
|
||||||
if(!snippetBar) return;
|
if(!snippetBar) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user