make requested changes

This commit is contained in:
Dan Harrin
2025-06-09 08:35:18 +01:00
parent 6f67e5eff7
commit 41a466d771
5 changed files with 34 additions and 32 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB

File diff suppressed because one or more lines are too long
@@ -19,31 +19,9 @@ export default function codeEditorFormComponent({
themeCompartment: new Compartment(),
state,
isDarkMode: function () {
return document.documentElement.classList.contains('dark')
},
getThemeExtensions: function () {
return this.isDarkMode() ? [oneDark] : []
},
getLanguageExtension: function () {
if (!language) {
return []
}
const extensions = {
css,
html,
javascript,
json,
php,
}
return extensions[language]?.() || []
},
init: function () {
const languageExtension = this.getLanguageExtension()
this.editor = new EditorView({
parent: this.$refs.editor,
state: EditorState.create({
@@ -60,7 +38,7 @@ export default function codeEditorFormComponent({
this.state = viewUpdate.state.doc.toString()
}),
this.getLanguageExtension(),
...(languageExtension ? [languageExtension] : []),
this.themeCompartment.of(this.getThemeExtensions()),
],
}),
@@ -94,6 +72,30 @@ export default function codeEditorFormComponent({
})
},
isDarkMode: function () {
return document.documentElement.classList.contains('dark')
},
getThemeExtensions: function () {
return this.isDarkMode() ? [oneDark] : []
},
getLanguageExtension: function () {
if (!language) {
return null
}
const extensions = {
css,
html,
javascript,
json,
php,
}
return extensions[language]?.() || null
},
destroy: function () {
if (this.themeObserver) {
this.themeObserver.disconnect()