Skip to content

Commit c9cc6a3

Browse files
committed
fix: replace v-bind="$attrs" with v-bind="editorAttrs" for improved attribute handling
1 parent 5818820 commit c9cc6a3

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

ui/src/components/codemirror-editor/index.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
:style="codemirrorStyle"
88
:tab-size="4"
99
:autofocus="true"
10-
v-bind="$attrs"
10+
v-bind="editorAttrs"
1111
/>
1212

1313
<div class="codemirror-editor__footer">
@@ -39,14 +39,15 @@
3939
</template>
4040

4141
<script setup lang="ts">
42-
import { ref, computed, watch } from 'vue'
42+
import { ref, computed, watch, useAttrs } from 'vue'
4343
import { Codemirror } from 'vue-codemirror'
4444
import { python } from '@codemirror/lang-python'
4545
import { oneDark } from '@codemirror/theme-one-dark'
4646
import { linter, type Diagnostic } from '@codemirror/lint'
4747
import FunctionApi from '@/api/function-lib'
4848
4949
defineOptions({ name: 'CodemirrorEditor' })
50+
const editorAttrs = useAttrs() as any
5051
5152
const props = defineProps<{
5253
title: String

ui/src/components/dynamics-form/items/JsonInput.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div style="width: 100%" class="function-CodemirrorEditor">
33
<Codemirror
4-
v-bind="$attrs"
4+
v-bind="editorAttrs"
55
ref="cmRef"
66
v-model="model_value"
77
:extensions="extensions"
@@ -51,7 +51,7 @@ import { json, jsonParseLinter } from '@codemirror/lang-json'
5151
import { oneDark } from '@codemirror/theme-one-dark'
5252
import { Codemirror } from 'vue-codemirror'
5353
import { linter } from '@codemirror/lint'
54-
import { computed, ref } from 'vue'
54+
import { computed, ref, useAttrs } from 'vue'
5555
import { t } from '@/locales'
5656
const props = withDefaults(defineProps<{ modelValue?: any }>(), { modelValue: () => {} })
5757
const emit = defineEmits(['update:modelValue'])
@@ -124,6 +124,8 @@ const validate_rules = (rule: any, value: any, callback: any) => {
124124
return true
125125
}
126126
127+
const editorAttrs = useAttrs() as any
128+
127129
defineExpose({ validate_rules: validate_rules })
128130
</script>
129131
<style lang="scss">

ui/src/components/markdown/MdEditor.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
<template>
2-
<MdEditor :language="language" noIconfont noPrettier v-bind="$attrs">
2+
<MdEditor :language="language" noIconfont noPrettier v-bind="editorAttrs">
33
<template #defFooters>
44
<slot name="defFooters"> </slot>
55
</template>
66
</MdEditor>
77
</template>
88

99
<script setup lang="ts">
10-
import { computed } from 'vue'
10+
import { computed, useAttrs } from 'vue'
1111
import { MdEditor, config } from 'md-editor-v3'
1212
import { getBrowserLang } from '@/locales/index'
1313
import './assets/markdown-iconfont.js'
1414
// 引入公共库中的语言配置
1515
import ZH_TW from '@vavt/cm-extension/dist/locale/zh-TW'
1616
1717
defineOptions({ name: 'MdEditor' })
18+
const editorAttrs = useAttrs() as any
1819
const language = computed(() => localStorage.getItem('MaxKB-locale') || getBrowserLang() || '')
1920
config({
2021
editorConfig: {

ui/src/components/markdown/MdPreview.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
<template>
2-
<MdPreview :language="language" noIconfont noPrettier :codeFoldable="false" v-bind="$attrs" />
2+
<MdPreview
3+
:language="language"
4+
noIconfont
5+
noPrettier
6+
:codeFoldable="false"
7+
v-bind="previewAttrs"
8+
/>
39
</template>
410

511
<script setup lang="ts">
6-
import { computed } from 'vue'
12+
import { computed, useAttrs } from 'vue'
713
import { MdPreview, config } from 'md-editor-v3'
814
import { getBrowserLang } from '@/locales/index'
915
import useStore from '@/stores'
1016
// 引入公共库中的语言配置
1117
import ZH_TW from '@vavt/cm-extension/dist/locale/zh-TW'
1218
1319
defineOptions({ name: 'MdPreview' })
20+
const previewAttrs = useAttrs() as any
1421
const { user } = useStore()
1522
const language = computed(() => user.getLanguage() || getBrowserLang() || '')
1623
config({

0 commit comments

Comments
 (0)