mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
make requested changes
This commit is contained in:
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 |
+7
-7
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()
|
||||
|
||||
Reference in New Issue
Block a user