File tree Expand file tree Collapse file tree
packages/fluent-editor/src/modules Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import type { Delta } from 'quill'
21import type TypeToolbar from 'quill/modules/toolbar'
32import type FluentEditor from '../fluent-editor'
43import data from '@emoji-mart/data'
@@ -178,33 +177,20 @@ class EmojiModule {
178177 }
179178
180179 try {
181- const emojiDelta = this . quill . insertText ( selection . index , emoji . native , 'user' )
180+ // 记录插入位置
181+ const insertIndex = selection . index
182+ this . quill . insertText ( insertIndex , emoji . native , 'user' )
182183
183184 this . closeDialog ( )
184185
185- // 异步设置光标位置,确保插入完成后再设置
186- this . setSelectionAfterEmoji ( emojiDelta )
186+ // 设置光标到表情符号后面
187+ this . quill . setSelection ( insertIndex + emoji . native . length )
187188 }
188189 catch ( error ) {
189190 console . error ( 'Failed to insert emoji:' , error )
190191 }
191192 }
192193
193- // 设置表情插入后的光标位置
194- private setSelectionAfterEmoji ( emojiDelta : Delta ) {
195- setTimeout ( ( ) => {
196- try {
197- const newSelection = this . quill . getSelection ( true )
198- if ( newSelection && emojiDelta ) {
199- this . quill . setSelection ( newSelection . index + emojiDelta . length ( ) )
200- }
201- }
202- catch ( error ) {
203- console . warn ( 'Failed to set selection after emoji insertion:' , error )
204- }
205- } , 0 )
206- }
207-
208194 // 处理外部点击事件
209195 private handleClickOutside ( event : MouseEvent ) {
210196 const button = this . getEmojiButton ( )
You can’t perform that action at this time.
0 commit comments