@naersen/tts-rich-text 0.4.0 → 0.5.0

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.
package/README.md CHANGED
@@ -238,6 +238,22 @@ import '@naersen/tts-rich-text/theme-default.css'
238
238
 
239
239
  这些组件共享 `TtsEditorRoot` 提供的编辑器上下文,不能脱离 Root 单独使用。布局接近原项目时使用完整的 `TtsRichTextEditor`;页面结构差异较大时再组合原子组件,业务接口仍统一通过 `services` 注入。
240
240
 
241
+ ### 组合式 API
242
+
243
+ 自定义工具栏、试听面板或业务弹窗时,可以从包根入口引入:
244
+
245
+ ```ts
246
+ import {
247
+ useGlobalAudioControl,
248
+ useSSETool,
249
+ useSynthesizeAudioTool,
250
+ useTestAudioTool,
251
+ useVoiceChangeConfirm
252
+ } from '@naersen/tts-rich-text'
253
+ ```
254
+
255
+ `useSynthesizeAudioTool` 和 `useTestAudioTool` 会读取编辑器 services,需要在 `TtsEditorRoot` 的后代组件中调用。`useGlobalAudioControl` 和 `useSSETool` 可以独立使用。
256
+
241
257
  ## 对外方法
242
258
 
243
259
  通过组件 ref 可以调用:
@@ -2,7 +2,7 @@ import { Ref } from 'vue';
2
2
  import { TtsServiceContext } from '../../../type';
3
3
  type ScrollTarget = Ref<HTMLElement | null | undefined> | (() => HTMLElement | null | undefined);
4
4
  type StreamRunner = (data: Record<string, unknown>, context: TtsServiceContext) => Promise<string | void>;
5
- interface UseSseToolOptions {
5
+ export interface UseSseToolOptions {
6
6
  runner?: StreamRunner;
7
7
  onChange?: (text: string) => void;
8
8
  scrollTarget?: ScrollTarget;
@@ -1,4 +1,8 @@
1
1
  export { useEditorContext, useEditorProvider, useRichTextEditor, type RichTextEditor, type UseRichTextEditorOptions } from '../components/tts-rich-text/editor/useRichTextEditor';
2
2
  export { createCustomTagNode, CustomTagName } from '../components/tts-rich-text/editor/nodes/tag-node';
3
3
  export { createTtsCharacterCount } from '../components/tts-rich-text/editor/plugins/tts-character-count';
4
+ export { useSSETool, type UseSseToolOptions } from '../components/tts-rich-text/editor/useSSETool';
5
+ export { useTestAudioTool } from '../components/tts-rich-text/editor/useTestAudioTool';
6
+ export { globalAudioControlKey, useGlobalAudioControl } from '../components/tts-rich-text/hooks/useGlobalAudioControl';
7
+ export { useSynthesizeAudioTool } from '../components/tts-rich-text/hooks/useSynthesizeAudioTool';
4
8
  export { useVoiceChangeConfirm } from '../components/tts-rich-text/hooks/useVoiceChangeConfirm';