@opentiny/tiny-robot 0.4.2-alpha.4 → 0.4.2-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/dist/action-group/ActionGroup.vue.d.ts +26 -0
  2. package/dist/action-group/ActionGroupItem.vue.d.ts +18 -0
  3. package/dist/action-group/index.d.ts +12 -0
  4. package/dist/action-group/index.type.d.ts +17 -0
  5. package/dist/anchor/components/AnchorItem.vue.d.ts +24 -0
  6. package/dist/anchor/components/AnchorList.vue.d.ts +20 -0
  7. package/dist/anchor/components/AnchorOverlay.vue.d.ts +33 -0
  8. package/dist/anchor/components/AnchorSearch.vue.d.ts +7 -0
  9. package/dist/anchor/composables/index.d.ts +5 -0
  10. package/dist/anchor/composables/useActiveSync.d.ts +10 -0
  11. package/dist/anchor/composables/useFloatingOffset.d.ts +6 -0
  12. package/dist/anchor/composables/useNavController.d.ts +12 -0
  13. package/dist/anchor/composables/useOverlayInteractions.d.ts +6 -0
  14. package/dist/anchor/composables/useTargetFeedback.d.ts +5 -0
  15. package/dist/anchor/defaults.d.ts +16 -0
  16. package/dist/anchor/index.d.ts +7 -0
  17. package/dist/anchor/index.type.d.ts +60 -0
  18. package/dist/anchor/index.vue.d.ts +159 -0
  19. package/dist/anchor/internal.type.d.ts +103 -0
  20. package/dist/anchor/utils/scroll.d.ts +7 -0
  21. package/dist/anchor/utils/target.d.ts +6 -0
  22. package/dist/attachments/components/FileCard.vue.d.ts +18 -0
  23. package/dist/attachments/components/ImagePreview.vue.d.ts +17 -0
  24. package/dist/attachments/components/index.d.ts +2 -0
  25. package/dist/attachments/composables/index.d.ts +5 -0
  26. package/dist/attachments/composables/useFileCard.d.ts +15 -0
  27. package/dist/attachments/composables/useFileType.d.ts +20 -0
  28. package/dist/attachments/composables/useImagePreview.d.ts +18 -0
  29. package/dist/attachments/composables/useListType.d.ts +11 -0
  30. package/dist/attachments/index.d.ts +7 -0
  31. package/dist/attachments/index.js +2 -2
  32. package/dist/attachments/index.type.d.ts +70 -0
  33. package/dist/attachments/index.vue.d.ts +27 -0
  34. package/dist/attachments/utils.d.ts +3 -0
  35. package/dist/base-popper/components/Popper.vue.d.ts +28 -0
  36. package/dist/base-popper/index.d.ts +2 -0
  37. package/dist/base-popper/index.vue.d.ts +41 -0
  38. package/dist/bubble/Bubble.vue.d.ts +39 -0
  39. package/dist/bubble/BubbleBoxWrapper.vue.d.ts +22 -0
  40. package/dist/bubble/BubbleContentWrapper.vue.d.ts +16 -0
  41. package/dist/bubble/BubbleItem.vue.d.ts +36 -0
  42. package/dist/bubble/BubbleList.vue.d.ts +41 -0
  43. package/dist/bubble/BubbleProvider.vue.d.ts +18 -0
  44. package/dist/bubble/composables/index.d.ts +10 -0
  45. package/dist/bubble/composables/useBubbleBoxRenderer.d.ts +18 -0
  46. package/dist/bubble/composables/useBubbleContentRenderer.d.ts +18 -0
  47. package/dist/bubble/composables/useBubbleStateChange.d.ts +2 -0
  48. package/dist/bubble/composables/useBubbleStore.d.ts +16 -0
  49. package/dist/bubble/composables/useContentResolver.d.ts +5 -0
  50. package/dist/bubble/composables/useCopyCleanup.d.ts +6 -0
  51. package/dist/bubble/composables/useMessageContent.d.ts +5 -0
  52. package/dist/bubble/composables/useMessageGroup.d.ts +4 -0
  53. package/dist/bubble/composables/useOmitMessageFields.d.ts +12 -0
  54. package/dist/bubble/composables/useToolCall.d.ts +25 -0
  55. package/dist/bubble/constants.d.ts +42 -0
  56. package/dist/bubble/index.d.ts +19 -0
  57. package/dist/bubble/index.type.d.ts +171 -0
  58. package/dist/bubble/renderers/Box.vue.d.ts +18 -0
  59. package/dist/bubble/renderers/Image.vue.d.ts +4 -0
  60. package/dist/bubble/renderers/Loading.vue.d.ts +4 -0
  61. package/dist/bubble/renderers/Markdown.vue.d.ts +4 -0
  62. package/dist/bubble/renderers/Reasoning.vue.d.ts +9 -0
  63. package/dist/bubble/renderers/Text.vue.d.ts +4 -0
  64. package/dist/bubble/renderers/Tool.vue.d.ts +14 -0
  65. package/dist/bubble/renderers/ToolRole.vue.d.ts +4 -0
  66. package/dist/bubble/renderers/Tools.vue.d.ts +4 -0
  67. package/dist/bubble/renderers/allRenderers.d.ts +93 -0
  68. package/dist/bubble/renderers/defaultRenderers.d.ts +27 -0
  69. package/dist/bubble/utils.d.ts +7 -0
  70. package/dist/chat/components/ChatConversation.vue.d.ts +70 -0
  71. package/dist/chat/components/ChatLauncherButton.vue.d.ts +12 -0
  72. package/dist/chat/components/ChatMcpTrigger.vue.d.ts +30 -0
  73. package/dist/chat/components/ChatThemeToggleButton.vue.d.ts +2 -0
  74. package/dist/chat/components/ChatWelcome.vue.d.ts +13 -0
  75. package/dist/chat/composables/useChatConversation.d.ts +37 -0
  76. package/dist/chat/composables/useChatMcp.d.ts +29 -0
  77. package/dist/chat/composables/useChatModel.d.ts +27 -0
  78. package/dist/chat/index.d.ts +9 -0
  79. package/dist/chat/index.js +13701 -0
  80. package/dist/chat/index.type.d.ts +88 -0
  81. package/dist/chat/index.vue.d.ts +58 -0
  82. package/dist/container/index.d.ts +7 -0
  83. package/dist/container/index.type.d.ts +20 -0
  84. package/dist/container/index.vue.d.ts +32 -0
  85. package/dist/conversations/index.d.ts +7 -0
  86. package/dist/conversations/index.vue.d.ts +2 -0
  87. package/dist/drag-overlay/constants.d.ts +17 -0
  88. package/dist/drag-overlay/directives/vDropzone.d.ts +14 -0
  89. package/dist/drag-overlay/index.d.ts +7 -0
  90. package/dist/drag-overlay/index.type.d.ts +105 -0
  91. package/dist/drag-overlay/index.vue.d.ts +20 -0
  92. package/dist/dropdown-menu/composables/usePopperHover.d.ts +6 -0
  93. package/dist/dropdown-menu/index.d.ts +7 -0
  94. package/dist/dropdown-menu/index.js +17 -17
  95. package/dist/dropdown-menu/index.type.d.ts +42 -0
  96. package/dist/dropdown-menu/index.vue.d.ts +217 -0
  97. package/dist/feedback/components/SourceList.vue.d.ts +11 -0
  98. package/dist/feedback/components/index.d.ts +1 -0
  99. package/dist/feedback/index.d.ts +7 -0
  100. package/dist/feedback/index.type.d.ts +25 -0
  101. package/dist/feedback/index.vue.d.ts +13 -0
  102. package/dist/flow-layout-buttons/index.d.ts +7 -0
  103. package/dist/flow-layout-buttons/index.js +1 -1
  104. package/dist/flow-layout-buttons/index.type.d.ts +35 -0
  105. package/dist/flow-layout-buttons/index.vue.d.ts +22 -0
  106. package/dist/history/components/Empty.vue.d.ts +7 -0
  107. package/dist/history/components/MenuList.vue.d.ts +24 -0
  108. package/dist/history/composables/useRenameEditor.d.ts +22 -0
  109. package/dist/history/constants.d.ts +1 -0
  110. package/dist/history/index.d.ts +7 -0
  111. package/dist/history/index.type.d.ts +33 -0
  112. package/dist/history/index.vue.d.ts +18 -0
  113. package/dist/icon-button/index.d.ts +7 -0
  114. package/dist/icon-button/index.type.d.ts +7 -0
  115. package/dist/icon-button/index.vue.d.ts +6 -0
  116. package/dist/index.d.ts +49 -5018
  117. package/dist/index.js +1 -1
  118. package/dist/mcp-add-form/components/CodeEditor.vue.d.ts +9 -0
  119. package/dist/mcp-add-form/components/FormEditor.vue.d.ts +10 -0
  120. package/dist/mcp-add-form/components/index.d.ts +2 -0
  121. package/dist/mcp-add-form/index.d.ts +7 -0
  122. package/dist/mcp-add-form/index.type.d.ts +19 -0
  123. package/dist/mcp-add-form/index.vue.d.ts +13 -0
  124. package/dist/mcp-server-picker/components/NoData.vue.d.ts +7 -0
  125. package/dist/mcp-server-picker/components/PluginCard.vue.d.ts +40 -0
  126. package/dist/mcp-server-picker/components/PluginModal.vue.d.ts +15 -0
  127. package/dist/mcp-server-picker/components/index.d.ts +3 -0
  128. package/dist/mcp-server-picker/index.d.ts +7 -0
  129. package/dist/mcp-server-picker/index.js +83 -80
  130. package/dist/mcp-server-picker/index.type.d.ts +99 -0
  131. package/dist/mcp-server-picker/index.vue.d.ts +71 -0
  132. package/dist/prompts/index.d.ts +12 -0
  133. package/dist/prompts/index.type.d.ts +59 -0
  134. package/dist/prompts/prompt.vue.d.ts +5 -0
  135. package/dist/prompts/prompts.vue.d.ts +20 -0
  136. package/dist/sender/components/editor-content/index.vue.d.ts +4 -0
  137. package/dist/sender/components/footer/index.vue.d.ts +38 -0
  138. package/dist/sender/components/layouts/MultiLineLayout.vue.d.ts +43 -0
  139. package/dist/sender/components/layouts/SingleLineLayout.vue.d.ts +32 -0
  140. package/dist/sender/composables/index.d.ts +7 -0
  141. package/dist/sender/composables/useAutoSize.d.ts +5 -0
  142. package/dist/sender/composables/useEditor.d.ts +13 -0
  143. package/dist/sender/composables/useKeyboardShortcuts.d.ts +7 -0
  144. package/dist/sender/composables/useModeSwitch.d.ts +4 -0
  145. package/dist/sender/composables/useSenderCore.d.ts +31 -0
  146. package/dist/sender/composables/useSlotScope.d.ts +10 -0
  147. package/dist/sender/context/index.d.ts +6 -0
  148. package/dist/sender/context/types.d.ts +7 -0
  149. package/dist/sender/extensions/constants.d.ts +94 -0
  150. package/dist/sender/extensions/index.d.ts +12 -0
  151. package/dist/sender/extensions/mention/commands.d.ts +20 -0
  152. package/dist/sender/extensions/mention/components/mention-list.vue.d.ts +18 -0
  153. package/dist/sender/extensions/mention/components/mention-view.vue.d.ts +19 -0
  154. package/dist/sender/extensions/mention/extension.d.ts +6 -0
  155. package/dist/sender/extensions/mention/index.d.ts +22 -0
  156. package/dist/sender/extensions/mention/plugin.d.ts +16 -0
  157. package/dist/sender/extensions/mention/types.d.ts +126 -0
  158. package/dist/sender/extensions/mention/utils.d.ts +34 -0
  159. package/dist/sender/extensions/suggestion/extension.d.ts +8 -0
  160. package/dist/sender/extensions/suggestion/index.d.ts +20 -0
  161. package/dist/sender/extensions/suggestion/plugin.d.ts +21 -0
  162. package/dist/sender/extensions/suggestion/suggestion-list.vue.d.ts +46 -0
  163. package/dist/sender/extensions/suggestion/types.d.ts +254 -0
  164. package/dist/sender/extensions/suggestion/utils/filter.d.ts +29 -0
  165. package/dist/sender/extensions/suggestion/utils/highlight.d.ts +73 -0
  166. package/dist/sender/extensions/template/block/extension.d.ts +6 -0
  167. package/dist/sender/extensions/template/block/plugins.d.ts +13 -0
  168. package/dist/sender/extensions/template/block/template-block-view.vue.d.ts +14 -0
  169. package/dist/sender/extensions/template/commands.d.ts +31 -0
  170. package/dist/sender/extensions/template/extension.d.ts +6 -0
  171. package/dist/sender/extensions/template/index.d.ts +21 -0
  172. package/dist/sender/extensions/template/select/dropdown-manager.d.ts +23 -0
  173. package/dist/sender/extensions/template/select/extension.d.ts +5 -0
  174. package/dist/sender/extensions/template/select/plugins.d.ts +34 -0
  175. package/dist/sender/extensions/template/select/template-select-view.vue.d.ts +20 -0
  176. package/dist/sender/extensions/template/types.d.ts +100 -0
  177. package/dist/sender/extensions/template/utils.d.ts +20 -0
  178. package/dist/sender/extensions/utils/id-generator.d.ts +16 -0
  179. package/dist/sender/extensions/utils/index.d.ts +7 -0
  180. package/dist/sender/extensions/utils/keyboard.d.ts +49 -0
  181. package/dist/sender/extensions/utils/position.d.ts +25 -0
  182. package/dist/sender/index.d.ts +136 -0
  183. package/dist/sender/index.type.d.ts +302 -0
  184. package/dist/sender/index.vue.d.ts +90 -0
  185. package/dist/sender/types/base.d.ts +239 -0
  186. package/dist/sender/types/components.d.ts +68 -0
  187. package/dist/sender/types/composables.d.ts +122 -0
  188. package/dist/sender/types/context.d.ts +132 -0
  189. package/dist/sender/types/slots.d.ts +67 -0
  190. package/dist/sender/utils/countGraphemes.d.ts +1 -0
  191. package/dist/sender-actions/action-button/index.vue.d.ts +23 -0
  192. package/dist/sender-actions/clear-button/index.vue.d.ts +2 -0
  193. package/dist/sender-actions/clear-button/useClearButtonState.d.ts +6 -0
  194. package/dist/sender-actions/default-actions/index.vue.d.ts +17 -0
  195. package/dist/sender-actions/index.d.ts +21 -0
  196. package/dist/sender-actions/index.type.d.ts +7 -0
  197. package/dist/sender-actions/submit-button/index.vue.d.ts +2 -0
  198. package/dist/sender-actions/types/common.d.ts +40 -0
  199. package/dist/sender-actions/types/index.d.ts +5 -0
  200. package/dist/sender-actions/types/tooltip.d.ts +7 -0
  201. package/dist/sender-actions/upload-button/index.type.d.ts +57 -0
  202. package/dist/sender-actions/upload-button/index.vue.d.ts +16 -0
  203. package/dist/sender-actions/utils/tooltip.d.ts +8 -0
  204. package/dist/sender-actions/voice-button/index.type.d.ts +78 -0
  205. package/dist/sender-actions/voice-button/index.vue.d.ts +43 -0
  206. package/dist/sender-actions/voice-button/speech.types.d.ts +40 -0
  207. package/dist/sender-actions/voice-button/useSpeechHandler.d.ts +10 -0
  208. package/dist/sender-actions/voice-button/webSpeechHandler.d.ts +40 -0
  209. package/dist/sender-actions/word-counter/index.vue.d.ts +2 -0
  210. package/dist/sender-compat/index.d.ts +7 -0
  211. package/dist/sender-compat/index.type.d.ts +91 -0
  212. package/dist/sender-compat/index.vue.d.ts +532 -0
  213. package/dist/shared/composables/createTeleport.d.ts +2 -0
  214. package/dist/shared/composables/index.d.ts +5 -0
  215. package/dist/shared/composables/useAutoScroll.d.ts +25 -0
  216. package/dist/shared/composables/useSlotRefs.d.ts +12 -0
  217. package/dist/shared/composables/useTeleportTarget.d.ts +11 -0
  218. package/dist/shared/composables/useTouchDevice.d.ts +3 -0
  219. package/dist/shared/utils.d.ts +7 -0
  220. package/dist/style.css +1 -1
  221. package/dist/suggestion-pills/components/PillButton.vue.d.ts +16 -0
  222. package/dist/suggestion-pills/components/index.d.ts +1 -0
  223. package/dist/suggestion-pills/index.d.ts +13 -0
  224. package/dist/suggestion-pills/index.js +12 -12
  225. package/dist/suggestion-pills/index.type.d.ts +45 -0
  226. package/dist/suggestion-pills/index.vue.d.ts +44 -0
  227. package/dist/suggestion-popover/components/Backdrop.vue.d.ts +5 -0
  228. package/dist/suggestion-popover/components/Header.vue.d.ts +4 -0
  229. package/dist/suggestion-popover/components/Loading.vue.d.ts +17 -0
  230. package/dist/suggestion-popover/components/NoData.vue.d.ts +17 -0
  231. package/dist/suggestion-popover/components/Tooltip.vue.d.ts +19 -0
  232. package/dist/suggestion-popover/index.d.ts +7 -0
  233. package/dist/suggestion-popover/index.js +35 -35
  234. package/dist/suggestion-popover/index.type.d.ts +80 -0
  235. package/dist/suggestion-popover/index.vue.d.ts +262 -0
  236. package/dist/theme-provider/constants.d.ts +6 -0
  237. package/dist/theme-provider/index.d.ts +9 -0
  238. package/dist/theme-provider/index.js +32 -41
  239. package/dist/theme-provider/index.type.d.ts +18 -0
  240. package/dist/theme-provider/index.vue.d.ts +32 -0
  241. package/dist/theme-provider/useTheme.d.ts +11 -0
  242. package/dist/useTheme.js +22 -0
  243. package/dist/welcome/index.d.ts +7 -0
  244. package/dist/welcome/index.type.d.ts +10 -0
  245. package/dist/welcome/index.vue.d.ts +18 -0
  246. package/package.json +22 -3
@@ -0,0 +1,6 @@
1
+ import { Node } from '@tiptap/core';
2
+ import { MentionOptions } from './types';
3
+ /**
4
+ * Mention 扩展定义
5
+ */
6
+ export declare const Mention: Node<MentionOptions, any>;
@@ -0,0 +1,22 @@
1
+ import { Ref } from 'vue';
2
+ import { MentionItem, MentionOptions } from './types';
3
+ export { Mention } from './extension';
4
+ export { MentionPluginKey } from './plugin';
5
+ export { mentionCommands } from './commands';
6
+ export * from './types';
7
+ export * from './utils';
8
+ /**
9
+ * 创建 Mention 扩展的便捷函数
10
+ *
11
+ * @param items - 提及项列表
12
+ * @param char - 触发字符,默认 '@'
13
+ * @param options - 其他配置项
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const extensions = [mention(items)]
18
+ * const extensions = [mention(items, '#')]
19
+ * const extensions = [mention(items, '@', { allowSpaces: true })]
20
+ * ```
21
+ */
22
+ export declare function mention(items: MentionItem[] | Ref<MentionItem[]>, char?: string, options?: Partial<Omit<MentionOptions, 'items' | 'char'>>): import('@tiptap/core').Node<MentionOptions, any>;
@@ -0,0 +1,16 @@
1
+ import { Plugin, PluginKey } from '@tiptap/pm/state';
2
+ import { Editor } from '@tiptap/core';
3
+ import { Ref } from 'vue';
4
+ import { MentionItem, MentionSuggestionState } from './types';
5
+ export declare const MentionPluginKey: PluginKey<MentionSuggestionState>;
6
+ interface PluginOptions {
7
+ editor: Editor;
8
+ char: string;
9
+ items: MentionItem[] | Ref<MentionItem[]>;
10
+ allowSpaces: boolean;
11
+ }
12
+ /**
13
+ * 创建 Suggestion 插件
14
+ */
15
+ export declare function createSuggestionPlugin(options: PluginOptions): Plugin;
16
+ export {};
@@ -0,0 +1,126 @@
1
+ import { Ref } from 'vue';
2
+ /**
3
+ * 提及项数据结构(用户侧)
4
+ *
5
+ * 用户传入的数据格式,id 可选,插件会自动生成
6
+ */
7
+ export interface MentionItem {
8
+ /**
9
+ * 唯一标识(可选)
10
+ *
11
+ * 如果不提供,插件会自动生成
12
+ */
13
+ id?: string;
14
+ /**
15
+ * 显示名称,如 "小小画家"(必传)
16
+ */
17
+ label: string;
18
+ /**
19
+ * 关联值(必传)
20
+ *
21
+ * 可以是任意字符串值,如 AI 提示词、用户 ID、标签内容等
22
+ */
23
+ value: string;
24
+ /**
25
+ * 图标(可选)
26
+ */
27
+ icon?: string;
28
+ }
29
+ /**
30
+ * 结构化数据项(提交时返回)
31
+ *
32
+ * 用于表示文本和 mention 的混合结构
33
+ */
34
+ export type MentionStructuredItem = {
35
+ type: 'text';
36
+ content: string;
37
+ } | {
38
+ type: 'mention';
39
+ content: string;
40
+ value: string;
41
+ };
42
+ /**
43
+ * Mention 节点属性(内部使用)
44
+ *
45
+ * ProseMirror 节点的属性,id 必填(由插件保证)
46
+ */
47
+ export interface MentionAttrs {
48
+ /**
49
+ * 唯一标识(必填)
50
+ *
51
+ * 由插件自动生成或使用用户提供的值
52
+ */
53
+ id: string;
54
+ /**
55
+ * 显示名称
56
+ */
57
+ label: string;
58
+ /**
59
+ * 关联值(可选)
60
+ */
61
+ value?: string;
62
+ }
63
+ /**
64
+ * Mention 配置选项
65
+ */
66
+ export interface MentionOptions {
67
+ /**
68
+ * 提及项列表
69
+ */
70
+ items: MentionItem[] | Ref<MentionItem[]>;
71
+ /**
72
+ * 触发字符,默认 '@'
73
+ */
74
+ char: string;
75
+ /**
76
+ * 是否允许空格,默认 false
77
+ */
78
+ allowSpaces?: boolean;
79
+ /**
80
+ * HTML 属性
81
+ */
82
+ HTMLAttributes?: Record<string, unknown>;
83
+ }
84
+ /**
85
+ * Mention Suggestion 插件状态
86
+ */
87
+ export interface MentionSuggestionState {
88
+ /**
89
+ * 是否激活
90
+ */
91
+ active: boolean;
92
+ /**
93
+ * 触发范围
94
+ */
95
+ range: {
96
+ from: number;
97
+ to: number;
98
+ } | null;
99
+ /**
100
+ * 查询文本
101
+ */
102
+ query: string;
103
+ /**
104
+ * 过滤后的提及项列表
105
+ */
106
+ filteredItems: MentionItem[];
107
+ }
108
+ /**
109
+ * 扩展 Tiptap Commands 接口
110
+ *
111
+ * 使 TypeScript 能够识别自定义命令
112
+ */
113
+ declare module '@tiptap/core' {
114
+ interface Commands<ReturnType> {
115
+ mention: {
116
+ /**
117
+ * 插入 mention 节点
118
+ */
119
+ insertMention: (attrs: Partial<MentionAttrs>) => ReturnType;
120
+ /**
121
+ * 删除 mention 节点
122
+ */
123
+ deleteMention: (id: string) => ReturnType;
124
+ };
125
+ }
126
+ }
@@ -0,0 +1,34 @@
1
+ import { Editor } from '@tiptap/core';
2
+ import { MentionItem, MentionStructuredItem } from './types';
3
+ /**
4
+ * 获取所有 mention 节点(辅助函数)
5
+ *
6
+ * 返回文档中所有的 mention 节点数据
7
+ */
8
+ export declare function getMentions(editor: Editor): MentionItem[];
9
+ /**
10
+ * 获取包含 mention 标签的完整文本
11
+ *
12
+ * 自动从编辑器中获取 mention 扩展的 char 配置
13
+ *
14
+ * @param editor - 编辑器实例
15
+ *
16
+ * @example
17
+ * getTextWithMentions(editor) // @代码分析 hello world @文本分析 12315
18
+ * // 如果配置了 char: '#',则返回:#代码分析 hello world #文本分析 12315
19
+ */
20
+ export declare function getTextWithMentions(editor: Editor): string;
21
+ /**
22
+ * 获取结构化数据(包含文本和 mention 的混合结构)
23
+ *
24
+ * 返回按顺序排列的文本和 mention 节点,用于确认内容和顺序
25
+ *
26
+ * @example
27
+ * 输入:帮我分析 @张三 的周报(或 #标签 等,取决于 char 配置)
28
+ * 返回:[
29
+ * { type: 'text', content: '帮我分析 ' },
30
+ * { type: 'mention', content: '张三', value: '...' },
31
+ * { type: 'text', content: ' 的周报' }
32
+ * ]
33
+ */
34
+ export declare function getMentionStructuredData(editor: Editor): MentionStructuredItem[];
@@ -0,0 +1,8 @@
1
+ import { Extension } from '@tiptap/core';
2
+ import { SuggestionOptions } from './types';
3
+ /**
4
+ * Suggestion 扩展定义
5
+ *
6
+ * 支持全局匹配模式的智能联想功能
7
+ */
8
+ export declare const Suggestion: Extension<SuggestionOptions, any>;
@@ -0,0 +1,20 @@
1
+ import { Ref } from 'vue';
2
+ import { SenderSuggestionItem, SuggestionOptions } from './types';
3
+ export { Suggestion } from './extension';
4
+ export { SuggestionPluginKey } from './plugin';
5
+ export * from './types';
6
+ export { syncAutoComplete } from './utils/filter';
7
+ export { processHighlights, highlightSuggestionText, convertHighlightsArrayToTextParts } from './utils/highlight';
8
+ /**
9
+ * 创建 Suggestion 扩展的便捷函数
10
+ *
11
+ * @param items - 建议项列表
12
+ * @param options - 其他配置项
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const extensions = [suggestion(suggestions)]
17
+ * const extensions = [suggestion(suggestions, { popupWidth: 500 })]
18
+ * ```
19
+ */
20
+ export declare function suggestion(items: SenderSuggestionItem[] | Ref<SenderSuggestionItem[]>, options?: Partial<Omit<SuggestionOptions, 'items'>>): import('@tiptap/core').Extension<SuggestionOptions, any>;
@@ -0,0 +1,21 @@
1
+ import { Plugin, PluginKey } from '@tiptap/pm/state';
2
+ import { Editor } from '@tiptap/core';
3
+ import { SuggestionOptions, SuggestionState } from './types';
4
+ /**
5
+ * 插件 Key,用于访问插件状态
6
+ */
7
+ export declare const SuggestionPluginKey: PluginKey<SuggestionState>;
8
+ /**
9
+ * 插件配置接口
10
+ */
11
+ interface PluginOptions extends SuggestionOptions {
12
+ editor: Editor;
13
+ }
14
+ /**
15
+ * 创建 Suggestion 插件
16
+ *
17
+ * @param options - 插件配置
18
+ * @returns ProseMirror 插件
19
+ */
20
+ export declare function createSuggestionPlugin(options: PluginOptions): Plugin;
21
+ export {};
@@ -0,0 +1,46 @@
1
+ import { SenderSuggestionItem } from './types';
2
+ /**
3
+ * 建议列表组件 Props
4
+ */
5
+ export interface Props {
6
+ /**
7
+ * 是否显示
8
+ */
9
+ show: boolean;
10
+ /**
11
+ * 建议项列表
12
+ */
13
+ suggestions: SenderSuggestionItem[];
14
+ /**
15
+ * 弹窗样式
16
+ */
17
+ popupStyle: Record<string, string | number>;
18
+ /**
19
+ * 键盘选中的索引
20
+ */
21
+ activeKeyboardIndex: number;
22
+ /**
23
+ * 鼠标悬停的索引
24
+ */
25
+ activeMouseIndex: number;
26
+ /**
27
+ * 用户输入的文本
28
+ */
29
+ inputValue: string;
30
+ /**
31
+ * 选择回调函数
32
+ */
33
+ onSelect?: (item: SenderSuggestionItem) => void;
34
+ /**
35
+ * 鼠标进入回调函数
36
+ */
37
+ onMouseEnter?: (index: number) => void;
38
+ /**
39
+ * 鼠标离开回调函数
40
+ */
41
+ onMouseLeave?: () => void;
42
+ }
43
+ declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
44
+ suggestionsListRef: HTMLDivElement;
45
+ }, any>;
46
+ export default _default;
@@ -0,0 +1,254 @@
1
+ import { Ref } from 'vue';
2
+ /**
3
+ * Suggestion 插件类型定义
4
+ *
5
+ * 包含建议项、高亮、插件配置和状态等类型定义
6
+ */
7
+ /**
8
+ * 高亮文本片段
9
+ */
10
+ export interface SuggestionTextPart {
11
+ text: string;
12
+ isMatch: boolean;
13
+ }
14
+ /**
15
+ * 高亮函数类型
16
+ *
17
+ * @param suggestionText - 建议项文本
18
+ * @param inputText - 用户输入文本
19
+ * @returns 包含文本片段和匹配状态的数组
20
+ */
21
+ export type HighlightFunction = (suggestionText: string, inputText: string) => SuggestionTextPart[];
22
+ /**
23
+ * 建议项类型
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * // 自动匹配
28
+ * { content: 'ECS-云服务器' }
29
+ *
30
+ * // 精确指定高亮
31
+ * {
32
+ * content: 'ECS-云服务器',
33
+ * highlights: ['ECS', '云服务器']
34
+ * }
35
+ *
36
+ * // 自定义高亮函数
37
+ * {
38
+ * content: 'ECS-云服务器',
39
+ * highlights: (text, query) => [
40
+ * { text: 'ECS', isMatch: true },
41
+ * { text: '-云服务器', isMatch: false }
42
+ * ]
43
+ * }
44
+ * ```
45
+ */
46
+ export interface SenderSuggestionItem {
47
+ /**
48
+ * 建议项内容(必填)
49
+ */
50
+ content: string;
51
+ /**
52
+ * 显示标签(可选)
53
+ *
54
+ * 默认使用 content
55
+ */
56
+ label?: string;
57
+ /**
58
+ * 高亮方式(可选)
59
+ *
60
+ * - undefined: 自动匹配(默认)
61
+ * - string[]: 精确指定高亮片段
62
+ * - function: 自定义高亮逻辑
63
+ */
64
+ highlights?: string[] | HighlightFunction;
65
+ /**
66
+ * 自定义数据(可选)
67
+ *
68
+ * 用于扩展功能
69
+ */
70
+ data?: Record<string, unknown>;
71
+ }
72
+ /**
73
+ * 插件状态
74
+ *
75
+ * 管理建议列表的显示、过滤、选中等状态
76
+ */
77
+ export interface SuggestionState {
78
+ /**
79
+ * 是否激活(有匹配的建议项)
80
+ */
81
+ active: boolean;
82
+ /**
83
+ * 匹配范围
84
+ *
85
+ * 全局模式:整个文档范围
86
+ * 字符模式:触发字符到光标的范围
87
+ */
88
+ range: {
89
+ from: number;
90
+ to: number;
91
+ } | null;
92
+ /**
93
+ * 查询文本
94
+ *
95
+ * 全局模式:整个输入内容
96
+ * 字符模式:触发字符后的文本
97
+ */
98
+ query: string;
99
+ /**
100
+ * 过滤后的建议项
101
+ */
102
+ filteredSuggestions: SenderSuggestionItem[];
103
+ /**
104
+ * 当前选中的建议项索引
105
+ *
106
+ * -1 表示未选中
107
+ */
108
+ selectedIndex: number;
109
+ /**
110
+ * 自动补全文本
111
+ *
112
+ * 选中项的剩余部分
113
+ */
114
+ autoCompleteText: string;
115
+ /**
116
+ * 是否显示 Tab 提示
117
+ */
118
+ showTabIndicator: boolean;
119
+ }
120
+ /**
121
+ * 插件配置选项
122
+ */
123
+ export interface SuggestionOptions {
124
+ /**
125
+ * 建议项列表(可选)
126
+ *
127
+ * 不传或传空数组时,建议功能不会显示
128
+ *
129
+ * @default []
130
+ *
131
+ * @example
132
+ * ```typescript
133
+ * const items = ref([
134
+ * { content: 'ECS-云服务器' },
135
+ * { content: 'RDS-数据库' }
136
+ * ])
137
+ * ```
138
+ */
139
+ items?: SenderSuggestionItem[] | Ref<SenderSuggestionItem[]>;
140
+ /**
141
+ * 自定义过滤函数(可选)
142
+ *
143
+ * - 不传:不过滤,直接显示所有项
144
+ * - 传入:使用自定义过滤逻辑
145
+ *
146
+ * @default undefined(不过滤)
147
+ *
148
+ * @example 模糊匹配过滤
149
+ * ```typescript
150
+ * filterFn: (items, query) => {
151
+ * return items.filter(item =>
152
+ * item.content.toLowerCase().includes(query.toLowerCase())
153
+ * )
154
+ * }
155
+ * ```
156
+ *
157
+ * @example 前缀匹配过滤
158
+ * ```typescript
159
+ * filterFn: (items, query) => {
160
+ * return items.filter(item =>
161
+ * item.content.toLowerCase().startsWith(query.toLowerCase())
162
+ * )
163
+ * }
164
+ * ```
165
+ */
166
+ filterFn?: (suggestions: SenderSuggestionItem[], query: string) => SenderSuggestionItem[];
167
+ /**
168
+ * 选中建议项的按键
169
+ *
170
+ * 注意:Tab 键用于自动补全,不受此配置控制
171
+ *
172
+ * @default ['Enter']
173
+ *
174
+ * @example 只允许 Enter 选中
175
+ * ```typescript
176
+ * activeSuggestionKeys: ['Enter']
177
+ * ```
178
+ *
179
+ * @example 允许 Enter 和 Space 选中
180
+ * ```typescript
181
+ * activeSuggestionKeys: ['Enter', ' '] // 注意:空格键是 ' '
182
+ * ```
183
+ *
184
+ * @example 禁用所有选中按键(只能点击)
185
+ * ```typescript
186
+ * activeSuggestionKeys: []
187
+ * ```
188
+ */
189
+ activeSuggestionKeys?: string[];
190
+ /**
191
+ * 弹窗宽度
192
+ *
193
+ * @default 400
194
+ */
195
+ popupWidth?: number | string;
196
+ /**
197
+ * 是否显示自动补全提示
198
+ *
199
+ * @default true
200
+ */
201
+ showAutoComplete?: boolean;
202
+ /**
203
+ * 选中建议项的回调
204
+ *
205
+ * @param item - 选中的建议项(包含完整的 SenderSuggestionItem 信息)
206
+ * @returns 返回 false 可阻止默认回填行为
207
+ *
208
+ * @example 默认行为(自动回填)
209
+ * ```typescript
210
+ * onSelect: (item) => {
211
+ * console.log('Selected:', item)
212
+ * // 不返回 false,内容会自动回填
213
+ * }
214
+ * ```
215
+ *
216
+ * @example 阻止默认行为并自定义回填
217
+ * ```typescript
218
+ * onSelect: (item) => {
219
+ * editor.commands.setContent(`前缀-${item.content}-后缀`)
220
+ * return false // 阻止默认回填
221
+ * }
222
+ * ```
223
+ *
224
+ * @example 条件性阻止
225
+ * ```typescript
226
+ * onSelect: (item) => {
227
+ * if (item.data?.needsValidation) {
228
+ * validateAndFill(item)
229
+ * return false
230
+ * }
231
+ * // 否则使用默认回填
232
+ * }
233
+ * ```
234
+ */
235
+ onSelect?: (item: SenderSuggestionItem) => void | false;
236
+ }
237
+ /**
238
+ * 插件 Key 类型
239
+ *
240
+ * 用于访问插件状态
241
+ */
242
+ export interface SuggestionPluginKeyType {
243
+ getState: (state: EditorState) => SuggestionState | undefined;
244
+ }
245
+ /**
246
+ * EditorState 类型(来自 @tiptap/pm/state)
247
+ */
248
+ export interface EditorState {
249
+ doc: unknown;
250
+ selection: unknown;
251
+ storedMarks: unknown;
252
+ schema: unknown;
253
+ [key: string]: unknown;
254
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * 计算自动补全文本
3
+ *
4
+ * 检查选中项是否以输入内容开头,如果是则返回剩余部分
5
+ *
6
+ * @param selectedSuggestion - 选中的建议项内容
7
+ * @param inputText - 用户输入的文本
8
+ * @returns 补全信息
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // 有补全文本
13
+ * syncAutoComplete('ECS-云服务器', 'ECS')
14
+ * // { text: '-云服务器', show: true, showTab: true }
15
+ *
16
+ * // 无补全文本(输入完整)
17
+ * syncAutoComplete('ECS', 'ECS')
18
+ * // { text: '', show: false, showTab: false }
19
+ *
20
+ * // 不匹配
21
+ * syncAutoComplete('ECS-云服务器', 'CDN')
22
+ * // { text: '', show: false, showTab: false }
23
+ * ```
24
+ */
25
+ export declare const syncAutoComplete: (selectedSuggestion: string, inputText: string) => {
26
+ text: string;
27
+ show: boolean;
28
+ showTab: boolean;
29
+ };
@@ -0,0 +1,73 @@
1
+ import { SenderSuggestionItem, SuggestionTextPart } from '../types';
2
+ /**
3
+ * 将预定义的高亮字符串数组转换为文本片段
4
+ *
5
+ * @param content - 完整的建议文本
6
+ * @param highlights - 需要高亮的文本片段数组
7
+ * @returns 包含文本片段和匹配状态的数组
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const result = convertHighlightsArrayToTextParts('ECS-云服务器', ['ECS', '云服务器'])
12
+ * // [
13
+ * // { text: 'ECS', isMatch: true },
14
+ * // { text: '-', isMatch: false },
15
+ * // { text: '云服务器', isMatch: true }
16
+ * // ]
17
+ * ```
18
+ */
19
+ export declare const convertHighlightsArrayToTextParts: (content: string, highlights: string[]) => SuggestionTextPart[];
20
+ /**
21
+ * 处理建议项文本高亮(自动匹配模式)
22
+ *
23
+ * @param suggestionText - 建议文本
24
+ * @param inputText - 输入文本
25
+ * @returns 包含文本片段和匹配状态的数组
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * const result = highlightSuggestionText('ECS-云服务器', 'ECS')
30
+ * // [
31
+ * // { text: 'ECS', isMatch: true },
32
+ * // { text: '-云服务器', isMatch: false }
33
+ * // ]
34
+ * ```
35
+ */
36
+ export declare const highlightSuggestionText: (suggestionText: string, inputText: string) => SuggestionTextPart[];
37
+ /**
38
+ * 处理建议项的高亮
39
+ *
40
+ * 支持三种高亮模式:
41
+ * 1. 自动匹配:根据输入内容自动高亮
42
+ * 2. 精确指定:通过数组指定要高亮的文本片段
43
+ * 3. 自定义函数:完全自定义高亮逻辑
44
+ *
45
+ * @param item - 建议项
46
+ * @param inputText - 用户输入文本
47
+ * @returns 包含文本片段和匹配状态的数组
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * // 自动匹配
52
+ * processHighlights({ content: 'ECS-云服务器' }, 'ECS')
53
+ *
54
+ * // 精确指定
55
+ * processHighlights(
56
+ * { content: 'ECS-云服务器', highlights: ['ECS', '云服务器'] },
57
+ * 'ECS'
58
+ * )
59
+ *
60
+ * // 自定义函数
61
+ * processHighlights(
62
+ * {
63
+ * content: 'ECS-云服务器',
64
+ * highlights: (text, query) => [
65
+ * { text: 'ECS', isMatch: true },
66
+ * { text: '-云服务器', isMatch: false }
67
+ * ]
68
+ * },
69
+ * 'ECS'
70
+ * )
71
+ * ```
72
+ */
73
+ export declare const processHighlights: (item: SenderSuggestionItem, inputText: string) => SuggestionTextPart[];
@@ -0,0 +1,6 @@
1
+ import { Node } from '@tiptap/core';
2
+ import { TemplateOptions } from '../types';
3
+ /**
4
+ * TemplateBlock 节点定义(可编辑块)
5
+ */
6
+ export declare const TemplateBlock: Node<TemplateOptions, any>;
@@ -0,0 +1,13 @@
1
+ import { Plugin } from '@tiptap/pm/state';
2
+ /**
3
+ * 零宽字符管理插件
4
+ */
5
+ export declare function ensureZeroWidthChars(): Plugin<any>;
6
+ /**
7
+ * 键盘导航插件
8
+ */
9
+ export declare function keyboardNavigationPlugin(): Plugin<any>;
10
+ /**
11
+ * 粘贴处理插件
12
+ */
13
+ export declare function pasteHandlerPlugin(): Plugin<any>;