diff --git a/components.d.ts b/components.d.ts index 029ff3b..d79fbb5 100644 --- a/components.d.ts +++ b/components.d.ts @@ -59,9 +59,7 @@ declare module 'vue' { NoticeEditor: typeof import('./src/components/group/manage/NoticeEditor.vue')['default'] NoticeTab: typeof import('./src/components/group/manage/NoticeTab.vue')['default'] NotificationApi: typeof import('./src/components/common/NotificationApi.vue')['default'] - NProgress: typeof import('naive-ui')['NProgress'] NRadio: typeof import('naive-ui')['NRadio'] - NTag: typeof import('naive-ui')['NTag'] NVirtualList: typeof import('naive-ui')['NVirtualList'] RevokeMessage: typeof import('./src/components/talk/message/RevokeMessage.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] diff --git a/src/components/editor/Editor.vue b/src/components/editor/Editor.vue index f4b24d2..072badb 100644 --- a/src/components/editor/Editor.vue +++ b/src/components/editor/Editor.vue @@ -572,6 +572,26 @@ function hideMentionDom() { } } +/** + * 处理编辑消息事件 + * @param data 消息数据 + */ +function onSubscribeEdit(data: any) { + console.log('data', data) + const quill = getQuill() + if (!quill) return + + // 清空当前编辑器内容 + quill.setContents([]) + + // 插入要编辑的文本内容 + quill.setText(data.content) + + // 设置光标位置到末尾 + const index = quill.getLength() - 1 + quill.setSelection(index > 0 ? index : 0, 0, 'user') +} + // 监听聊天索引变化,切换聊天时加载对应草稿 watch(indexName, loadEditorDraftText, { immediate: true }) @@ -588,7 +608,8 @@ onUnmounted(() => { // 订阅编辑器相关事件总线事件 useEventBus([ { name: EditorConst.Mention, event: onSubscribeMention }, // @成员事件 - { name: EditorConst.Quote, event: onSubscribeQuote } // 引用事件 + { name: EditorConst.Quote, event: onSubscribeQuote }, // 引用事件 + { name: EditorConst.Edit, event: onSubscribeEdit } // 编辑消息事件 ]) diff --git a/src/components/talk/message/RevokeMessage.vue b/src/components/talk/message/RevokeMessage.vue index a3da869..caf96c0 100644 --- a/src/components/talk/message/RevokeMessage.vue +++ b/src/components/talk/message/RevokeMessage.vue @@ -1,7 +1,9 @@