feat(EditorSender):增加clear事件,增加暴露实例的submit方法#302
feat(EditorSender):增加clear事件,增加暴露实例的submit方法#302yumushang wants to merge 2 commits intoelement-plus-x:mainfrom
Conversation
WalkthroughAdds an EditorSender Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant EditorSender
participant Consumer
User->>EditorSender: Trigger clear action
EditorSender->>EditorSender: Clear content & move cursor to end
EditorSender-->>Consumer: emit("clear", txt)
sequenceDiagram
participant Consumer
participant EditorSender
Consumer->>EditorSender: call submit()
EditorSender->>EditorSender: onSubmit()
EditorSender-->>Consumer: proceed with submission flow
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
packages/core/src/components/EditorSender/index.vue (1)
177-182: ESLint: add space after comma in emits('clear', txt)Static analysis flagged a comma-spacing error at Line 181. Fix to satisfy lint and keep style consistent.
- emits('clear',txt); + emits('clear', txt);
🧹 Nitpick comments (1)
apps/docs/zh/components/editorSender/index.md (1)
135-135: Align docs with implementation: make txt optional for 'clear'Implementation emits
txtoptionally and types.ts usestxt?: string. Update docs to reflect optional parameter.-| `clear` | 清空内容时触发 | `txt: string` - 参数txt为清空后插入的文本 | +| `clear` | 清空内容时触发 | `txt?: string` - 可选参数txt为清空后插入的文本 |
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
apps/docs/zh/components/editorSender/index.md(2 hunks)packages/core/src/components/EditorSender/index.vue(2 hunks)packages/core/src/components/EditorSender/types.d.ts(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
packages/core/src/components/EditorSender/types.d.ts (6)
packages/core/src/components/Sender/types.d.ts (2)
SenderEmits(53-66)TriggerEvent(46-51)packages/core/src/components/MentionSender/types.d.ts (1)
MentionSenderEmits(52-65)packages/core/src/components/BubbleList/types.d.ts (1)
BubbleListEmits(27-29)packages/core/src/components/Conversations/types.d.ts (1)
ConversationsEmits(101-109)packages/core/src/components/Typewriter/types.d.ts (1)
TypewriterEmits(26-30)packages/core/src/components/ThoughtChain/types.d.ts (1)
ThoughtChainEmits(126-128)
apps/docs/zh/components/editorSender/index.md (1)
packages/core/src/components/Sender/types.d.ts (2)
SenderEmits(53-66)SenderProps(1-44)
packages/core/src/components/EditorSender/index.vue (1)
packages/core/src/components/Sender/types.d.ts (1)
SenderEmits(53-66)
🪛 ESLint
packages/core/src/components/EditorSender/index.vue
[error] 181-181: A space is required after ','.
(style/comma-spacing)
[error] 460-460: Missing space before value for key 'submit'.
(style/key-spacing)
🔇 Additional comments (1)
apps/docs/zh/components/editorSender/index.md (1)
146-146: LGTM: submit() instance method is documented correctlyMatches the exposed method in index.vue and PR objective.
e72fe8c to
c7448cc
Compare
EditorSender 1、增加clear事件 2、增加暴露实例的submit方法
There was a problem hiding this comment.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
packages/core/src/components/EditorSender/index.vue (1)
360-375: Falsy rank check can skip rank 0; check nullish instead
if (!rank)wrongly treats0as not-found, breaking updates for the first node.Apply this diff:
function updateSelectTag(elm: HTMLElement, tag: TagInfo) { const rank = opNode.value?.getRankByElm(elm.parentElement!); - if (!rank) { + if (rank == null) { return; } const chatNode = opNode.value?.getNodeByRank(rank); if (!chatNode) { return; }
🧹 Nitpick comments (1)
packages/core/src/components/EditorSender/index.vue (1)
177-182: Fix ESLint comma-spacing in clear emitMissing space after comma triggers ESLint: A space is required after ','.
Apply this diff:
function onClear(txt?: string) { chat.value!.clear(txt); // 将光标移动到末尾 focusToEnd(); - emits('clear',txt); + emits('clear', txt); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
apps/docs/zh/components/editorSender/index.md(2 hunks)packages/core/src/components/EditorSender/index.vue(2 hunks)packages/core/src/components/EditorSender/types.d.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/core/src/components/EditorSender/types.d.ts
- apps/docs/zh/components/editorSender/index.md
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/core/src/components/EditorSender/index.vue (1)
packages/core/src/components/Sender/types.d.ts (1)
SenderEmits(53-66)
🪛 ESLint
packages/core/src/components/EditorSender/index.vue
[error] 181-181: A space is required after ','.
(style/comma-spacing)
🔇 Additional comments (2)
packages/core/src/components/EditorSender/index.vue (2)
458-467: Expose submit via defineExpose — LGTM
submitis now publicly exposed and spacing is correct. This aligns with the PR goals and the earlier lint warning has been addressed.
50-51: EditorSender emits typing includes 'clear' — verifiedVerified: EditorSenderEmits declares the clear event and the implementation emits it; no consumer-facing typing changes missing.
Files checked:
- packages/core/src/components/EditorSender/types.d.ts — contains "(e: 'clear', txt: string): void"
- packages/core/src/components/EditorSender/index.vue — defines onClear(txt?: string) and calls emits('clear', txt)
- packages/core/src/components/EditorSender/components/ClearButton/index.vue — emits 'clear' from the button
No changes required.
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/core/src/components/EditorSender/index.vue (2)
20-21: Import missing Vue APIs used below.
getCurrentInstanceandcomputedare used but not imported, causing TS/compile errors.Apply:
-import { onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue'; +import { onBeforeUnmount, onMounted, reactive, ref, watch, computed, getCurrentInstance } from 'vue';Also applies to: 52-56
48-51: Maketxtoptional in the ‘clear’ emit signature
In packages/core/src/components/EditorSender/types.d.ts (line 77), change(e: 'clear', txt: string): void;to
(e: 'clear', txt?: string): void;
♻️ Duplicate comments (1)
packages/core/src/components/EditorSender/index.vue (1)
473-476: Expose submit API: spacing fix looks good and resolves prior lint.
submit: onSubmitnow matches key-spacing convention noted in an earlier review.
🧹 Nitpick comments (3)
packages/core/src/components/EditorSender/index.vue (3)
188-188: Fix ESLint comma-spacing in clear emit.Missing space after comma triggers style/comma-spacing.
Apply:
- emits('clear',txt); + emits('clear', txt);
172-178: Make submit emptiness check source-of-truth.Use the editor’s actual state at submit time to avoid stale
chatState.isEmpty.function onSubmit() { - // 内容纯空 拦截发送 - if (chatState.isEmpty) { + // 内容纯空 拦截发送 + if (chat.value?.isEmpty(true)) { return; } emits('submit', getCurrentValue()); }
184-189: Ensure UI state syncs immediately after clear.If
clear()doesn’t emit youroperatehook,chatStatemay stay stale. Update it or emitchangeexplicitly.function onClear(txt?: string) { chat.value!.clear(txt); // 将光标移动到末尾 focusToEnd(); + // 保证状态同步(若底层未触发 operate) + chatState.isEmpty = chat.value!.isEmpty(true); + chatState.textLength = chat.value!.textLength; emits('clear', txt); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
apps/docs/zh/components/editorSender/index.md(2 hunks)packages/core/src/components/EditorSender/index.vue(2 hunks)packages/core/src/components/EditorSender/types.d.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/core/src/components/EditorSender/types.d.ts
- apps/docs/zh/components/editorSender/index.md
🧰 Additional context used
🧬 Code graph analysis (1)
packages/core/src/components/EditorSender/index.vue (1)
packages/core/src/components/Sender/types.d.ts (2)
SenderEmits(53-66)TriggerEvent(46-51)
🪛 ESLint
packages/core/src/components/EditorSender/index.vue
[error] 188-188: A space is required after ','.
(style/comma-spacing)
EditorSender 组件
1、增加clear事件,方便监听clear后,清空上传的文件。
2、增加暴露实例的submit方法,方便直接通过函数调用提交方法。
Summary by CodeRabbit
New Features
Documentation