Skip to content

Commit 694e42c

Browse files
authored
修复md编辑器无法监听粘贴复制问题 (#90)
* [fix]编辑器监听问题修复 * fix * auto prettier format code * fix --------- Co-authored-by: linjm8780860 <11494038+linjm8780860@users.noreply.github.com>
1 parent 2c69050 commit 694e42c

4 files changed

Lines changed: 29 additions & 5 deletions

File tree

src/components/community/detail/Index.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,9 @@
10941094
<div v-if="currentVersion?.review_state === 1" class="flex items-center gap-1">
10951095
<span class="text-green-500">{{ t('community.detail.positive') }}</span>
10961096
<span class="text-gray-500">{{
1097-
currentVersion?.review_at ? currentVersion?.review_at?.replace(/-/g, '') : ''
1097+
currentVersion?.review_at
1098+
? currentVersion?.review_at?.replace(/-/g, '/').split(' ')[0]
1099+
: ''
10981100
}}</span>
10991101
</div>
11001102
<span v-else class="text-red-500"> {{ t('community.detail.negative') }} </span>

src/components/markdown/Index.vue

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
</template>
7777

7878
<script setup>
79-
import { ref, onMounted } from 'vue'
79+
import { ref, onMounted, watch } from 'vue'
8080
import screenfull from 'screenfull'
8181
import highlight from 'highlight.js'
8282
import prettier from 'prettier'
@@ -162,10 +162,30 @@
162162
const text = ref(props.modelValue)
163163
const emit = defineEmits(['update:modelValue', 'isUploading'])
164164
165+
// 修复handleInput函数中的bug
165166
const handleInput = () => {
166-
emit('update:modelValue', text)
167+
emit('update:modelValue', text.value)
167168
}
168169
170+
// 添加watch监听,确保所有值变化都会触发update:modelValue
171+
watch(
172+
text,
173+
newValue => {
174+
emit('update:modelValue', newValue)
175+
},
176+
{ immediate: false }
177+
)
178+
179+
// 监听props.modelValue的变化,确保双向绑定正确工作
180+
watch(
181+
() => props.modelValue,
182+
newValue => {
183+
if (newValue !== text.value) {
184+
text.value = newValue
185+
}
186+
}
187+
)
188+
169189
const handleKeydown = event => {
170190
if (BLOCKED_KEYS.includes(event.key)) {
171191
event.stopPropagation()

src/components/model-select/detail/Index.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,9 @@
913913
<div v-if="currentVersion?.review_state === 1" class="flex items-center gap-1">
914914
<span class="text-green-500">{{ t('community.detail.positive') }}</span>
915915
<span class="text-gray-500">{{
916-
currentVersion?.review_at ? currentVersion?.review_at?.replace(/-/g, '') : ''
916+
currentVersion?.review_at
917+
? currentVersion?.review_at?.replace(/-/g, '/').split(' ')[0]
918+
: ''
917919
}}</span>
918920
</div>
919921
<span v-else class="text-red-500"> {{ t('community.detail.negative') }} </span>

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.24
1+
1.2.25

0 commit comments

Comments
 (0)