Date: Fri, 2 Aug 2024 11:18:11 +0800
Subject: [PATCH 4/8] prevent repeated addition of default language
---
.../src/extensions/code-block/CodeBlockViewRenderer.vue | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/ui/packages/editor/src/extensions/code-block/CodeBlockViewRenderer.vue b/ui/packages/editor/src/extensions/code-block/CodeBlockViewRenderer.vue
index 1646d6dc79..886ce5c6a1 100644
--- a/ui/packages/editor/src/extensions/code-block/CodeBlockViewRenderer.vue
+++ b/ui/packages/editor/src/extensions/code-block/CodeBlockViewRenderer.vue
@@ -23,14 +23,17 @@ const props = defineProps<{
}>();
const languageOptions = computed(() => {
- let languages = [];
+ let languages: Array = [];
const lang = props.extension.options.languages;
if (typeof lang === "function") {
languages = lang(props.editor.state);
} else {
languages = lang;
}
- languages.unshift("auto");
+ languages = languages || [];
+ if (languages.indexOf("auto") === -1) {
+ languages.unshift("auto");
+ }
return languages.map((language) => ({
label: language.replace(/( |^)[a-z]/g, (L) => L.toUpperCase()),
value: language,
@@ -55,8 +58,6 @@ const themeOptions = computed(() => {
themes = theme;
}
- themes = themes || [];
-
if (!themes) {
return undefined;
}
From 8ba70c91fb88e6064c2d8ed7be847375e921e1c0 Mon Sep 17 00:00:00 2001
From: LIlGG <1103069291@qq.com>
Date: Mon, 5 Aug 2024 14:47:25 +0800
Subject: [PATCH 5/8] rename select.vue to CodeBlockSelect.vue
---
.../{Select.vue => CodeBlockSelect.vue} | 7 +++--
.../code-block/CodeBlockViewRenderer.vue | 27 +++++++------------
ui/src/components/editor/DefaultEditor.vue | 8 +++---
3 files changed, 17 insertions(+), 25 deletions(-)
rename ui/packages/editor/src/extensions/code-block/{Select.vue => CodeBlockSelect.vue} (98%)
diff --git a/ui/packages/editor/src/extensions/code-block/Select.vue b/ui/packages/editor/src/extensions/code-block/CodeBlockSelect.vue
similarity index 98%
rename from ui/packages/editor/src/extensions/code-block/Select.vue
rename to ui/packages/editor/src/extensions/code-block/CodeBlockSelect.vue
index 6b6b54daf0..daf2db2c34 100644
--- a/ui/packages/editor/src/extensions/code-block/Select.vue
+++ b/ui/packages/editor/src/extensions/code-block/CodeBlockSelect.vue
@@ -10,7 +10,6 @@ export interface Option {
const props = defineProps<{
container?: any;
containerClass?: string;
- placeholder?: string;
options: Option[];
filterSort?: (options: Option[], query: string) => number;
}>();
@@ -19,9 +18,9 @@ const value = defineModel({
default: "",
});
-const emit = defineEmits({
- select: () => true,
-});
+const emit = defineEmits<{
+ (event: "select"): void;
+}>();
const isFocus = ref(false);
const inputValue = ref("");
diff --git a/ui/packages/editor/src/extensions/code-block/CodeBlockViewRenderer.vue b/ui/packages/editor/src/extensions/code-block/CodeBlockViewRenderer.vue
index 886ce5c6a1..202a4e9fe7 100644
--- a/ui/packages/editor/src/extensions/code-block/CodeBlockViewRenderer.vue
+++ b/ui/packages/editor/src/extensions/code-block/CodeBlockViewRenderer.vue
@@ -1,26 +1,19 @@