@siliconoid/xssml-editor 1.0.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.
@@ -0,0 +1,863 @@
1
+ import { Plugin, EditorState as EditorState$1, Transaction } from 'prosemirror-state';
2
+ import { NodeSpec, MarkSpec } from 'prosemirror-model';
3
+ import { EditorView as EditorView$1 } from 'prosemirror-view';
4
+
5
+ declare const HighlightCommands: {
6
+ highlight: string;
7
+ clearHighlight: string;
8
+ };
9
+
10
+ declare const HistoryCommands: {
11
+ undo: string;
12
+ redo: string;
13
+ clear: string;
14
+ };
15
+
16
+ declare const TextInputCommands: {
17
+ inputText: string;
18
+ replaceRange: string;
19
+ };
20
+
21
+ declare const PptCommands: {
22
+ insertPptControl: string;
23
+ };
24
+
25
+ declare const SoundEventCommands: {
26
+ /** Insert a sound event node */
27
+ insertSoundEvent: string;
28
+ };
29
+
30
+ declare const CmdCommands: {
31
+ insertCommand: string;
32
+ };
33
+
34
+ declare const DataCommands: {
35
+ insertData: string;
36
+ };
37
+
38
+ declare const WaitCommands: {
39
+ insertWait: string;
40
+ };
41
+
42
+ declare const BreakCommands: {
43
+ insertBreak: string;
44
+ };
45
+
46
+ declare const BreathCommands: {
47
+ insertBreath: string;
48
+ };
49
+
50
+ declare const PhonemeCommands: {
51
+ switchPhonemeMode: string;
52
+ insertPhoneme: string;
53
+ };
54
+
55
+ declare enum MarkTagType {
56
+ Word = "word",
57
+ Breath = "breath",
58
+ Break = "break",
59
+ Phoneme = "phoneme",
60
+ /** @description XSSML say-as element for text interpretation */
61
+ SayAs = "say-as",
62
+ /** @deprecated Use SayAs instead */
63
+ Number = "say-as",
64
+ /** @description XSSML sub element for text substitution */
65
+ Sub = "sub",
66
+ /** @deprecated Use Sub instead */
67
+ Alias = "sub",
68
+ Speaker = "speaker",
69
+ SpeechRate = "speed",
70
+ SpeechPitch = "pitch",
71
+ SpeechVolume = "volume",
72
+ SpeechLanguage = "lang",
73
+ Action = "action",
74
+ Avatar = "avatar",
75
+ Emotion = "emotion",
76
+ Command = "command",
77
+ Data = "data",
78
+ Wait = "wait",
79
+ PptControl = "ppt_control",
80
+ /** @description XSSML soundEvent element for audio effects */
81
+ SoundEvent = "soundEvent",
82
+ RangeAnchor = "range_anchor"
83
+ }
84
+ /**
85
+ * XSSML say-as interpret-as attribute values
86
+ * Currently supports core number interpretations.
87
+ * Can be extended to support XSSML 1.1 full spec: ordinal, characters, telephone, date, time, fraction, currency
88
+ * @see https://www.w3.org/TR/speech-synthesis11/#edef_say-as
89
+ */
90
+ declare enum SayAsInterpretType {
91
+ /** Auto-detect interpretation */
92
+ auto = "auto",
93
+ /** Speak as cardinal number (e.g., "one hundred twenty-three") */
94
+ cardinal = "cardinal",
95
+ /** Speak each digit individually (e.g., "one two three") */
96
+ digits = "digits"
97
+ }
98
+ declare enum ActionCommands {
99
+ insertAction = "insertAction",
100
+ clearAction = "clearAction"
101
+ }
102
+ declare enum SpeechRateCommands {
103
+ setSpeechRate = "setSpeechRate"
104
+ }
105
+ declare enum SpeechPitchCommands {
106
+ setSpeechPitch = "setSpeechPitch"
107
+ }
108
+ declare enum SpeechVolumeCommands {
109
+ setSpeechVolume = "setSpeechVolume"
110
+ }
111
+ declare enum SpeechLanguageCommands {
112
+ setSpeechLanguage = "setSpeechLanguage"
113
+ }
114
+
115
+ /**
116
+ * XSSML say-as command - handles text interpretation hints
117
+ * @see https://www.w3.org/TR/speech-synthesis11/#edef_say-as
118
+ */
119
+
120
+ declare const SayAsCommands: {
121
+ /** Set say-as interpretation for selected text */
122
+ setSayAs: string;
123
+ };
124
+
125
+ declare const WordCommands: {
126
+ insertWord: string;
127
+ };
128
+
129
+ interface EditorNodeSpec extends NodeSpec {
130
+ validate?: (state: EditorState) => {
131
+ available: boolean;
132
+ reason?: string;
133
+ };
134
+ handleClickOn?: (
135
+ view: EditorView,
136
+ pos: number,
137
+ node: Node,
138
+ nodePos: number,
139
+ event: MouseEvent,
140
+ direct: boolean,
141
+ ) => boolean | undefined;
142
+ }
143
+
144
+ interface EditorMarkSpec extends MarkSpec {
145
+ validate?: (state: EditorState) => {
146
+ available: boolean;
147
+ reason?: string;
148
+ };
149
+ }
150
+
151
+ interface TextMediaAttrs {
152
+ src: string;
153
+ name?: string;
154
+ mediaType: string;
155
+ extra?: string | object;
156
+ }
157
+
158
+ type EventCallback<T> = (data: T) => void;
159
+ /**
160
+ * 定义事件类型映射接口
161
+ * 用于指定事件名称和对应的数据类型
162
+ * 例如: { 'change': string, 'click': MouseEvent }
163
+ */
164
+ type EmitEvents = Record<string, any>;
165
+ interface IEventEmitter<T extends EmitEvents = EmitEvents> {
166
+ on<K extends keyof T>(event: K, callback: EventCallback<T[K]>): void;
167
+ off<K extends keyof T>(event: K, callback: EventCallback<T[K]>): void;
168
+ emit<K extends keyof T>(event: K, data: T[K]): void;
169
+ removeAllListeners(event?: keyof T): void;
170
+ }
171
+ declare class EventEmitter<T extends EmitEvents = EmitEvents> implements IEventEmitter {
172
+ private events;
173
+ /**
174
+ * 监听事件
175
+ * @param event 事件名
176
+ * @param callback 回调函数,参数类型会自动推断
177
+ */
178
+ on<K extends keyof T>(event: K, callback: EventCallback<T[K]>): void;
179
+ /**
180
+ * 移除事件监听器
181
+ * @param event 事件名
182
+ * @param callback 回调函数
183
+ */
184
+ off<K extends keyof T>(event: K, callback: EventCallback<T[K]>): void;
185
+ /**
186
+ * 触发事件
187
+ * @param event 事件名
188
+ * @param data 事件数据,类型会自动匹配
189
+ */
190
+ emit<K extends keyof T>(event: K, data: T[K]): void;
191
+ /**
192
+ * 移除所有监听器
193
+ * @param event 可选的事件名
194
+ */
195
+ removeAllListeners(event?: keyof T): void;
196
+ }
197
+
198
+ interface EditorStateChangeEvent {
199
+ commands: Record<string, {
200
+ available: boolean;
201
+ reason?: string;
202
+ }>;
203
+ }
204
+ interface WordCountEvent {
205
+ count: number;
206
+ maxCount?: number;
207
+ exceeded?: boolean;
208
+ }
209
+ interface FocusEvent {
210
+ focused: boolean;
211
+ }
212
+ interface ErrorEvent {
213
+ error: Error;
214
+ context?: unknown;
215
+ }
216
+ interface ClickedTextMediaAttrs extends TextMediaAttrs {
217
+ tagId: string;
218
+ }
219
+ /**
220
+ * 编辑器事件枚举
221
+ */
222
+ declare enum EditorEvent {
223
+ /** 状态变更 (命令状态、选区等) */
224
+ StateChange = "stateChange",
225
+ /** 字数统计变更 */
226
+ WordCount = "wordCount",
227
+ /** 编辑器获得焦点 */
228
+ Focus = "focus",
229
+ /** 编辑器失去焦点 */
230
+ Blur = "blur",
231
+ /** 发生错误 */
232
+ Error = "error",
233
+ /** 选区更新 (用于浮动菜单) */
234
+ SelectionUpdate = "selectionUpdate",
235
+ /** 右键菜单 (用于自定义菜单) */
236
+ ContextMenu = "contextMenu",
237
+ /** 文本多媒体节点点击 (插件事件) */
238
+ PluginTextMediaClick = "plugin.textmedia_click"
239
+ }
240
+ /**
241
+ * 选区更新事件
242
+ */
243
+ interface SelectionChangeEvent {
244
+ /** 是否有活跃选区 (非空选区) */
245
+ isActive: boolean;
246
+ /** 选区的屏幕位置矩形 */
247
+ rect: DOMRect | null;
248
+ /** 开始位置 */
249
+ from: number;
250
+ /** 结束位置 */
251
+ to: number;
252
+ /** 选区文本内容 (新增) */
253
+ text: string;
254
+ /** 选区 JSON 内容 (新增) */
255
+ content: any;
256
+ /** 关联的 DOM 节点 (如果有) */
257
+ target?: HTMLElement;
258
+ }
259
+ /**
260
+ * 右键菜单事件
261
+ */
262
+ interface ContextMenuEvent {
263
+ /** 原生事件 */
264
+ event: MouseEvent;
265
+ /** 点击位置 */
266
+ pos: number;
267
+ /** 点击位置的坐标 */
268
+ coords: {
269
+ left: number;
270
+ top: number;
271
+ };
272
+ /** 当前点击命中的节点及其属性 */
273
+ node?: {
274
+ type: string;
275
+ attrs: Record<string, any>;
276
+ };
277
+ /** 触发时刻的选区快照 (新增) */
278
+ selection: {
279
+ from: number;
280
+ to: number;
281
+ text: string;
282
+ content: any;
283
+ /** 点击位置是否在当前选区内 */
284
+ isClickInside: boolean;
285
+ };
286
+ }
287
+ type EditorEventMap = {
288
+ [EditorEvent.StateChange]: EditorStateChangeEvent;
289
+ [EditorEvent.WordCount]: WordCountEvent;
290
+ [EditorEvent.Focus]: FocusEvent;
291
+ [EditorEvent.Blur]: FocusEvent;
292
+ [EditorEvent.Error]: ErrorEvent;
293
+ [EditorEvent.SelectionUpdate]: SelectionChangeEvent;
294
+ [EditorEvent.ContextMenu]: ContextMenuEvent;
295
+ [EditorEvent.PluginTextMediaClick]: ClickedTextMediaAttrs;
296
+ [event: string]: unknown;
297
+ };
298
+
299
+ interface EditorConfig$1 {
300
+ parent: HTMLDivElement;
301
+ content?: string;
302
+ registry?: Registry;
303
+ maxWordCount?: number;
304
+ editable?: boolean;
305
+ /** 浮动菜单配置 (半封装模式) */
306
+ floatingMenu?: {
307
+ onRender: (mountPoint: HTMLElement, state: any) => void;
308
+ shouldShow?: (
309
+ view: any,
310
+ state: { isMouseDown: boolean; isContextMenuOpen: boolean },
311
+ ) => boolean;
312
+ };
313
+ /** 右键菜单配置 (半封装模式) */
314
+ contextMenu?: {
315
+ onRender: (mountPoint: HTMLElement, state: any) => void;
316
+ };
317
+ }
318
+
319
+ declare class EditorStateStore {
320
+ editable: boolean;
321
+ constructor();
322
+ setEditable(editable: boolean): void;
323
+ getEditable(): boolean;
324
+ }
325
+
326
+ declare class Registry$1 {
327
+ private nodes;
328
+ private marks;
329
+ private plugins;
330
+ registerNode(name: string, spec: EditorNodeSpec): void;
331
+ registerMark(name: string, spec: EditorMarkSpec): void;
332
+ registerPlugin(name: string, plugin: Plugin | ((...args: any[]) => Plugin)): void;
333
+ getNodes(): Record<string, EditorNodeSpec>;
334
+ getMarks(): Record<string, EditorMarkSpec>;
335
+ getPlugins(editorStateStore?: EditorStateStore): Plugin[];
336
+ clone(): Registry$1;
337
+ }
338
+ declare const registry: Registry$1;
339
+
340
+ /**
341
+ * 编辑器内容 JSON 结构 (ProseMirror Node 格式)
342
+ */
343
+ interface EditorContent {
344
+ type: string;
345
+ attrs?: Record<string, unknown>;
346
+ content?: (EditorContent | {
347
+ type: 'text';
348
+ text: string;
349
+ })[];
350
+ marks?: {
351
+ type: string;
352
+ attrs?: Record<string, unknown>;
353
+ }[];
354
+ }
355
+ /**
356
+ * 编辑器初始化配置项
357
+ */
358
+ interface EditorConfig {
359
+ /** 挂载的 DOM 容器 */
360
+ parent: HTMLElement;
361
+ /** 初始内容 (JSON 字符串) */
362
+ content?: string;
363
+ /** 自定义扩展注册表 */
364
+ registry?: Registry$1;
365
+ /** 最大字数限制 (默认: 10000) */
366
+ maxWordCount?: number;
367
+ /** 是否初始只读 */
368
+ editable?: boolean;
369
+ /** 浮动菜单配置 (半封装模式) */
370
+ floatingMenu?: {
371
+ onRender: (mountPoint: HTMLElement, state: any) => void;
372
+ shouldShow?: (view: any, state: {
373
+ isMouseDown: boolean;
374
+ isContextMenuOpen: boolean;
375
+ }) => boolean;
376
+ };
377
+ /** 右键菜单配置 (半封装模式) */
378
+ contextMenu?: {
379
+ onRender: (mountPoint: HTMLElement, state: any) => void;
380
+ };
381
+ }
382
+ /**
383
+ * 内容读取模式
384
+ */
385
+ declare enum ContentReadMode {
386
+ /** 全文 */
387
+ all = "all",
388
+ /** 选区 */
389
+ selection = "selection",
390
+ /** 从当前光标位置往右(往后) */
391
+ cursorRight = "cursor_right"
392
+ }
393
+ /**
394
+ * 命令错误码
395
+ */
396
+ declare enum CommandErrorCode {
397
+ /** 成功 */
398
+ Success = 0,
399
+ /** 参数缺失 */
400
+ ParamsMissing = 100000,
401
+ /** 参数无效 (格式、类型错误) */
402
+ ParamsInvalid = 100001,
403
+ /** 选区无效 (需要选区但未选择,或选区跨节点) */
404
+ SelectionInvalid = 100002,
405
+ /** 光标无效 (需要光标但未定位,或处于选区状态) */
406
+ CursorInvalid = 100003,
407
+ /** 编辑器状态错误 (如只读模式) */
408
+ StateError = 100004,
409
+ /** 命令未找到 */
410
+ CommandNotFound = 100005,
411
+ /** 内部执行时发生未捕获异常 */
412
+ ExecutionError = 999999
413
+ }
414
+ /**
415
+ * 播放片段
416
+ */
417
+ interface PlaybackSegment {
418
+ /** 类型 */
419
+ type: 'text' | 'soundEvent';
420
+ /** 文本内容 */
421
+ text: string;
422
+ /** 在编辑器中的起始位置 */
423
+ from: number;
424
+ /** 在编辑器中的结束位置 */
425
+ to: number;
426
+ /** 关联的自定义事件 (如音效、动作) */
427
+ events?: any[];
428
+ /** 关联的 TTS 标记 (如语速、语调、音量、语种) */
429
+ marks?: any[];
430
+ }
431
+ /**
432
+ * 命令执行结果
433
+ */
434
+ interface CommandResult$1 {
435
+ /** 是否执行成功 */
436
+ success: boolean;
437
+ /** 错误码 (当 success 为 false 时必填) */
438
+ code?: CommandErrorCode;
439
+ /** 失败原因 (如果有) */
440
+ reason?: string;
441
+ }
442
+ /**
443
+ * 命令可用性状态
444
+ */
445
+ interface CommandState {
446
+ /** 当前是否可用 */
447
+ available: boolean;
448
+ /** 错误码 (当 available 为 false 时提供) */
449
+ code?: CommandErrorCode;
450
+ /** 不可用原因 */
451
+ reason?: string;
452
+ }
453
+ /**
454
+ * 选区信息
455
+ */
456
+ interface SelectionRange {
457
+ /** 起始位置 */
458
+ from: number;
459
+ /** 结束位置 */
460
+ to: number;
461
+ /** 选中的纯文本 */
462
+ text: string;
463
+ }
464
+ /**
465
+ * MarkEditor 对外暴露的公共接口
466
+ */
467
+ interface IMarkEditor {
468
+ /** 是否可编辑 (读写控制) */
469
+ editable: boolean;
470
+ /** 当前已输入的有效字符总数 */
471
+ readonly count: number;
472
+ /**
473
+ * 获取当前选区信息
474
+ */
475
+ getSelection(): SelectionRange;
476
+ /**
477
+ * 获取编辑器纯文本内容
478
+ * @param options 读取配置
479
+ */
480
+ getPlainText(options?: {
481
+ contentMode?: ContentReadMode;
482
+ }): string;
483
+ /**
484
+ * 获取播放片段列表 (用于音画同步、分句合成)
485
+ * @param options 读取配置
486
+ */
487
+ getPlaybackSegments(options?: {
488
+ contentMode?: ContentReadMode;
489
+ }): PlaybackSegment[];
490
+ /**
491
+ * 执行编辑器命名命令
492
+ * @param commandName 命令名称 (建议配合枚举使用)
493
+ * @param args 命令参数
494
+ */
495
+ execute(commandName: string, ...args: unknown[]): CommandResult$1;
496
+ /**
497
+ * 设置编辑器内容
498
+ * @param content 新内容的 JSON 字符串,若为空则清空内容
499
+ * @param clearHistory 是否清除历史记录 (默认 true)
500
+ */
501
+ setContent(content?: string, clearHistory?: boolean): void;
502
+ /**
503
+ * 获取编辑器当前内容的 JSON 对象 (会自动过滤辅助字符)
504
+ */
505
+ toJSON(): EditorContent;
506
+ /**
507
+ * 从 HTML 导入内容 (内置 XSS 过滤与历史版本适配)
508
+ * @param html HTML 字符串
509
+ */
510
+ setContentFromHTML(html: string): void;
511
+ /**
512
+ * 从 XSSML 导入内容
513
+ * @param ssml XSSML 字符串
514
+ */
515
+ setContentFromSSML(ssml: string): void;
516
+ /**
517
+ * 获取所有注册命令的当前状态
518
+ */
519
+ getCurrentState(): Record<string, CommandState>;
520
+ /**
521
+ * 检查当前文档内容大小是否代表“空”
522
+ */
523
+ isEmptyContentSize(size: number): boolean;
524
+ /**
525
+ * 销毁编辑器实例,释放内存与事件
526
+ */
527
+ destroy(): void;
528
+ on<K extends keyof EditorEventMap>(event: K, listener: (payload: EditorEventMap[K]) => void): void;
529
+ off<K extends keyof EditorEventMap>(event: K, listener: (payload: EditorEventMap[K]) => void): void;
530
+ once<K extends keyof EditorEventMap>(event: K, listener: (payload: EditorEventMap[K]) => void): void;
531
+ }
532
+ /** 停顿 (Break) 参数 */
533
+ interface BreakAttrs {
534
+ /** 停顿时间 (毫秒) */
535
+ value: number;
536
+ /** 显示文本 */
537
+ label?: string;
538
+ }
539
+ /** 读法 (SayAs) 参数 */
540
+ interface SayAsAttrs {
541
+ /** 读法解析类型: digits(读数字), cardinal(读数值), auto(自动) */
542
+ interpretAs: string;
543
+ }
544
+ /** 音效 (SoundEvent) 参数 */
545
+ interface SoundEventAttrs {
546
+ /** 音效 ID/路径 */
547
+ value: string;
548
+ /** 显示标题 */
549
+ label: string;
550
+ /** 音量 (0-100) */
551
+ volume?: number;
552
+ }
553
+ /** 语速/语调/音量 调节参数 */
554
+ interface ProsodyAttrs {
555
+ /** 调节值 (通常 0-100,70位标准值) */
556
+ value: number;
557
+ }
558
+ /** 动作 (Action) 参数 */
559
+ interface ActionAttrs {
560
+ /** 动作标识值 */
561
+ value: string;
562
+ /** 显示标题 */
563
+ label: string;
564
+ }
565
+ /** 等待 (Wait) 参数 */
566
+ interface WaitAttrs {
567
+ /** 显示标题 */
568
+ label: string;
569
+ /** 等待值 (如秒数) */
570
+ value: string;
571
+ /** 等待类型: sleep(时长), video_ended(视频结束), audio_ended(音频结束) */
572
+ waitType: 'sleep' | 'video_ended' | 'audio_ended';
573
+ /** 附加上下文 */
574
+ context?: string;
575
+ }
576
+
577
+ declare class Editor extends EventEmitter<EditorEventMap> {
578
+ private view;
579
+ private config;
580
+ private registry;
581
+ private editorStateStore;
582
+ private commandRegister;
583
+ get editable(): boolean;
584
+ set editable(editable: boolean);
585
+ private wordcount;
586
+ private stateCollect;
587
+ maxWordCount: number;
588
+ private defaultPlugins;
589
+ isEmptyContentSize: (size: number) => size is 2;
590
+ getCurrentState(): Record<string, CommandState>;
591
+ constructor(props: EditorConfig$1);
592
+ private static mergeConfig;
593
+ private createView;
594
+ getSelection(): SelectionRange;
595
+ private mount;
596
+ getPlainText(options?: {
597
+ contentMode?: ContentReadMode;
598
+ }): string;
599
+ getPlaybackSegments(options?: {
600
+ contentMode?: ContentReadMode;
601
+ }): PlaybackSegment[];
602
+ execute(commandName: string, ...args: unknown[]): CommandResult$1;
603
+ setContent(content?: string, clearHistory?: boolean): void;
604
+ get count(): number;
605
+ toJSON(): any;
606
+ setContentFromSSML(ssml: string): void;
607
+ /**
608
+ * 通过 HTML 字符串设置编辑器内容
609
+ * 支持自动适配旧版的区间标记(数字读法等),并内置 XSS 过滤
610
+ * @param html HTML 字符串
611
+ */
612
+ setContentFromHTML(html: string): void;
613
+ destroy(): void;
614
+ }
615
+
616
+ interface ContextMenuState {
617
+ isActive: boolean;
618
+ event: MouseEvent;
619
+ pos: number;
620
+ coords: {
621
+ left: number;
622
+ top: number;
623
+ };
624
+ node?: {
625
+ type: string;
626
+ attrs: any;
627
+ };
628
+ selection: {
629
+ from: number;
630
+ to: number;
631
+ text: string;
632
+ content: any;
633
+ isClickInside: boolean;
634
+ };
635
+ target: HTMLElement;
636
+ }
637
+ interface ContextMenuOptions {
638
+ onRender?: (mountPoint: HTMLElement, state: ContextMenuState) => void;
639
+ }
640
+ declare class ContextMenuPlugin extends Plugin {
641
+ constructor(editor: Editor, options: ContextMenuOptions);
642
+ }
643
+
644
+ interface FloatingMenuState {
645
+ isActive: boolean;
646
+ rect: DOMRect | null;
647
+ from: number;
648
+ to: number;
649
+ text: string;
650
+ content: any;
651
+ target: HTMLElement;
652
+ isFlipped: boolean;
653
+ }
654
+ interface FloatingMenuOptions {
655
+ /**
656
+ * 允许业务方决定是否显示菜单的谓词函数
657
+ */
658
+ shouldShow?: (view: EditorView$1, state: {
659
+ isMouseDown: boolean;
660
+ isContextMenuOpen: boolean;
661
+ isPopoverVisible: boolean;
662
+ }) => boolean;
663
+ /**
664
+ * 渲染回调
665
+ */
666
+ onRender?: (mountPoint: HTMLElement, state: FloatingMenuState) => void;
667
+ }
668
+ declare class FloatingMenuPlugin extends Plugin {
669
+ constructor(editor: Editor, options: FloatingMenuOptions);
670
+ }
671
+
672
+ declare enum WordmarkCommands {
673
+ markWord = "markWord",
674
+ clearWordMark = "clearWordMark"
675
+ }
676
+
677
+ declare const TextMediaCommands: {
678
+ setTextMedia: string;
679
+ resetTextMediaStoredMark: string;
680
+ };
681
+
682
+ declare const NumberTipCommands: {
683
+ /** Switch number tagging mode */
684
+ switchNumberTipMode: string;
685
+ };
686
+
687
+ /**
688
+ * XSSML Editor SDK Logger
689
+ * Unified logging system to replace console.* calls
690
+ */
691
+ declare enum LogLevel {
692
+ ERROR = 0,
693
+ WARN = 1,
694
+ INFO = 2,
695
+ DEBUG = 3
696
+ }
697
+ declare class Logger {
698
+ private level;
699
+ private prefix;
700
+ /**
701
+ * Set the log level
702
+ */
703
+ setLevel(level: LogLevel): void;
704
+ /**
705
+ * Get current log level
706
+ */
707
+ getLevel(): LogLevel;
708
+ /**
709
+ * Log error messages
710
+ */
711
+ error(message: string, ...args: unknown[]): void;
712
+ /**
713
+ * Log warning messages
714
+ */
715
+ warn(message: string, ...args: unknown[]): void;
716
+ /**
717
+ * Log info messages
718
+ */
719
+ info(message: string, ...args: unknown[]): void;
720
+ /**
721
+ * Log debug messages
722
+ */
723
+ debug(message: string, ...args: unknown[]): void;
724
+ }
725
+ /**
726
+ * Global logger instance
727
+ */
728
+ declare const logger: Logger;
729
+
730
+ interface CommandContext {
731
+ state: EditorState$1;
732
+ dispatch: (tr: Transaction) => void;
733
+ view: EditorView$1;
734
+ editor?: Editor;
735
+ }
736
+ interface CommandResult {
737
+ success: boolean;
738
+ code?: CommandErrorCode;
739
+ reason?: string;
740
+ }
741
+ declare type CommandDefinitionProps = {
742
+ name: string;
743
+ description?: string;
744
+ execute: (context: CommandContext, ...args: unknown[]) => CommandResult;
745
+ validate?: (context: CommandContext, ...args: unknown[]) => {
746
+ available: boolean;
747
+ reason?: string;
748
+ code?: CommandErrorCode;
749
+ };
750
+ };
751
+ declare class CommandDefinition {
752
+ name: string;
753
+ description?: string;
754
+ execute: (context: CommandContext, ...args: unknown[]) => CommandResult;
755
+ validate?: (context: CommandContext, ...args: unknown[]) => {
756
+ available: boolean;
757
+ reason?: string;
758
+ code?: CommandErrorCode;
759
+ };
760
+ constructor(config: CommandDefinitionProps);
761
+ }
762
+
763
+ declare function registerCommand(command: CommandDefinition): void;
764
+
765
+ type CustomNodeType = 'number' | 'break' | 'breath' | 'word' | 'phoneme' | 'command' | 'data' | 'wait' | 'ppt_control';
766
+ type NodePosotionType = CustomNodeType | 'text' | 'soundEvent';
767
+ type ContentMark = {
768
+ type: 'textmedia';
769
+ attrs: Record<string, unknown>;
770
+ };
771
+ interface ProseMirrorNode {
772
+ type: string;
773
+ text?: string;
774
+ content?: ProseMirrorNode[];
775
+ attrs?: Record<string, any>;
776
+ marks?: ContentMark[];
777
+ }
778
+ interface ProseMirrorDoc {
779
+ type: string;
780
+ content: ProseMirrorNode[];
781
+ }
782
+ interface NodePosition {
783
+ type: NodePosotionType;
784
+ start: number;
785
+ end: number;
786
+ text: string;
787
+ attrs?: Record<string, any>;
788
+ marks?: ContentMark[];
789
+ }
790
+ interface TextCustomEvent {
791
+ type: 'command' | 'textmedia' | 'ppt_control';
792
+ trigger: 'before' | 'after' | 'inner';
793
+ charOffset: number;
794
+ attrs?: Record<string, any>;
795
+ extra?: Record<string, any>;
796
+ eventLifeType?: 'start' | 'stop';
797
+ }
798
+ interface Sentence {
799
+ text: string;
800
+ start: number;
801
+ end: number;
802
+ events: TextCustomEvent[];
803
+ /** 关联的 TTS 标记 (如语速、语调、音量、语种) */
804
+ marks?: any[];
805
+ taskType: 'text' | 'soundEvent';
806
+ }
807
+ interface Task {
808
+ text?: '';
809
+ taskType: 'wait';
810
+ data: Record<string, any>;
811
+ }
812
+ interface PreProcess {
813
+ type: string;
814
+ value: string;
815
+ }
816
+ interface ParagraphInfo {
817
+ index: number;
818
+ preProcess: PreProcess[];
819
+ sentences: (Sentence | Task)[];
820
+ }
821
+ interface ParagraphizedResult {
822
+ paragraphs: ParagraphInfo[];
823
+ }
824
+
825
+ declare const DataPlaceholderReg: RegExp;
826
+ declare class TextExtractor {
827
+ private currentPosition;
828
+ private readonly textRegExps;
829
+ private readonly config;
830
+ private readonly ATOMIC_NODE_TYPES;
831
+ private readonly SPLITED_NODE_TYPES;
832
+ private curParagraphLastRangeEvents;
833
+ /**
834
+ * 设置句子分割配置
835
+ * @param options 配置选项
836
+ */
837
+ setConfig(options: Partial<typeof this.config>): void;
838
+ /**
839
+ * 提取分句内容
840
+ * @param doc ProseMirror文档
841
+ * @param startPos 起始位置 (默认为0)
842
+ * @returns 分句结果,每句包含文本内容和位置信息
843
+ * @throws {Error} 当文档格式无效时抛出错误
844
+ */
845
+ extractSentences(doc: ProseMirrorDoc, startPos?: number): (Sentence | Task)[];
846
+ /**
847
+ * 将位置信息数组分割成句子
848
+ * @param positions 位置信息数组
849
+ * @returns 分句结果
850
+ */
851
+ private splitIntoSentences;
852
+ private isAtomicNode;
853
+ private isSplitedNode;
854
+ private getNodeSize;
855
+ private static createNodePosition;
856
+ private static handleSpecialNode;
857
+ private extractWithPosition;
858
+ extractParagraphizedSentences(doc: ProseMirrorDoc): ParagraphizedResult;
859
+ private static collectPreProcesss;
860
+ }
861
+
862
+ export { ActionCommands, BreakCommands, BreathCommands, CmdCommands, CommandErrorCode, ContentReadMode, ContextMenuPlugin, DataCommands, DataPlaceholderReg, EditorEvent, FloatingMenuPlugin, HighlightCommands, HistoryCommands, LogLevel, Editor as MarkEditor, MarkTagType, NumberTipCommands, PhonemeCommands, PptCommands, SayAsCommands, SayAsInterpretType, SoundEventCommands, SpeechLanguageCommands, SpeechPitchCommands, SpeechRateCommands, SpeechVolumeCommands, TextExtractor, TextInputCommands, TextMediaCommands, WaitCommands, WordCommands, WordmarkCommands, logger, registerCommand, registry };
863
+ export type { ActionAttrs, BreakAttrs, ClickedTextMediaAttrs, CommandResult$1 as CommandResult, CommandState, ContentMark, ContextMenuEvent, ContextMenuState, CustomNodeType, EditorConfig, EditorContent, EditorEventMap, EditorStateChangeEvent, ErrorEvent, FloatingMenuState, FocusEvent, IMarkEditor, NodePosition, NodePosotionType, ParagraphInfo, ParagraphizedResult, PlaybackSegment, PreProcess, ProseMirrorDoc, ProseMirrorNode, ProsodyAttrs, SayAsAttrs, SelectionChangeEvent, SelectionRange, Sentence, SoundEventAttrs, Task, TextCustomEvent, WaitAttrs, WordCountEvent };