mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-15 13:55:19 +00:00
refac
This commit is contained in:
parent
1c64269387
commit
5eaee44daa
1 changed files with 17 additions and 7 deletions
|
|
@ -149,10 +149,15 @@
|
||||||
export let onChange = (e) => {};
|
export let onChange = (e) => {};
|
||||||
|
|
||||||
// create a lowlight instance with all languages loaded
|
// create a lowlight instance with all languages loaded
|
||||||
const lowlight = createLowlight(hljs.listLanguages().reduce((obj, lang) => {
|
const lowlight = createLowlight(
|
||||||
obj[lang] = () => hljs.getLanguage(lang);
|
hljs.listLanguages().reduce(
|
||||||
return obj;
|
(obj, lang) => {
|
||||||
}, {} as Record<string, any>));
|
obj[lang] = () => hljs.getLanguage(lang);
|
||||||
|
return obj;
|
||||||
|
},
|
||||||
|
{} as Record<string, any>
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
export let editor: Editor | null = null;
|
export let editor: Editor | null = null;
|
||||||
|
|
||||||
|
|
@ -501,9 +506,14 @@
|
||||||
|
|
||||||
export const focus = () => {
|
export const focus = () => {
|
||||||
if (editor) {
|
if (editor) {
|
||||||
editor.view.focus();
|
try {
|
||||||
// Scroll to the current selection
|
editor.view?.focus();
|
||||||
editor.view.dispatch(editor.view.state.tr.scrollIntoView());
|
// Scroll to the current selection
|
||||||
|
editor.view?.dispatch(editor.view.state.tr.scrollIntoView());
|
||||||
|
} catch (e) {
|
||||||
|
// sometimes focusing throws an error, ignore
|
||||||
|
console.warn('Error focusing editor', e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue