Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbdabdec

Browse files
fix: display IME characters during composition (#2263)
Co-authored-by: ras0q <ras0q@users.noreply.github.com>Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parentd00c18d commitbdabdec

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
importtype{ModelRef}from'vue'
2+
import{ref,watch}from'vue'
3+
4+
exportfunctionuseIME(content:ModelRef<string>){
5+
constcomposingContent=ref(content.value)
6+
watch(content,(v)=>{
7+
if(v!==composingContent.value){
8+
composingContent.value=v
9+
}
10+
})
11+
12+
functiononInput(e:Event){
13+
if(!(einstanceofInputEvent)||!(e.targetinstanceofHTMLTextAreaElement)){
14+
return
15+
}
16+
17+
if(e.isComposing){
18+
composingContent.value=e.target.value
19+
}
20+
else{
21+
content.value=e.target.value
22+
}
23+
}
24+
25+
functiononCompositionEnd(){
26+
content.value=composingContent.value
27+
}
28+
29+
return{ composingContent, onInput, onCompositionEnd}
30+
}

‎packages/client/internals/ShikiEditor.vue‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<script setup lang="ts">
22
import {getHighlighter }from'#slidev/shiki'
33
import {ref,shallowRef }from'vue'
4+
import {useIME }from'../composables/useIME'
45
56
const props=defineProps<{
67
placeholder?:string
78
}>()
89
const content=defineModel<string>({ required:true })
10+
const { composingContent, onInput, onCompositionEnd }=useIME(content)
911
1012
const textareaEl=ref<HTMLTextAreaElement|null>(null)
1113
@@ -16,10 +18,12 @@ getHighlighter().then(h => highlight.value = h)
1618
<template>
1719
<divclass="absolute left-3 right-0 inset-y-2 font-mono overflow-x-hidden overflow-y-auto cursor-text">
1820
<divv-if="highlight"class="relative w-full h-max min-h-full">
19-
<divclass="relative w-full h-max"v-html="`${highlight(content, 'markdown')}&nbsp;`" />
21+
<divclass="relative w-full h-max"v-html="`${highlight(composingContent, 'markdown')}&nbsp;`" />
2022
<textarea
21-
ref="textareaEl"v-model="content":placeholder="props.placeholder"
23+
ref="textareaEl"v-model="composingContent":placeholder="props.placeholder"
2224
class="absolute inset-0 resize-none text-transparent bg-transparent focus:outline-none caret-black dark:caret-white overflow-y-hidden"
25+
@input="onInput"
26+
@compositionend="onCompositionEnd"
2327
/>
2428
</div>
2529
</div>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp