ssml-builder-js 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,373 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, CSSProperties } from 'react';
3
+
4
+ type SsmlAttributeValue = string | number;
5
+ type SsmlAttributes = Record<string, SsmlAttributeValue>;
6
+ interface SsmlText {
7
+ type: "text";
8
+ value: string;
9
+ }
10
+ type SsmlNode = string | SsmlText | SsmlElement;
11
+ interface SsmlElementBase {
12
+ children?: SsmlNode[];
13
+ attributes?: SsmlAttributes;
14
+ }
15
+ interface VoiceElement extends SsmlElementBase {
16
+ type: "voice";
17
+ name?: string;
18
+ effect?: string;
19
+ }
20
+ interface ProsodyElement extends SsmlElementBase {
21
+ type: "prosody";
22
+ rate?: SsmlAttributeValue;
23
+ pitch?: SsmlAttributeValue;
24
+ volume?: SsmlAttributeValue;
25
+ contour?: string;
26
+ range?: SsmlAttributeValue;
27
+ }
28
+ interface BreakElement extends SsmlElementBase {
29
+ type: "break";
30
+ time?: SsmlAttributeValue;
31
+ strength?: string;
32
+ }
33
+ interface ExpressAsElement extends SsmlElementBase {
34
+ type: "express-as" | "expressAs" | "mstts:express-as";
35
+ style?: string;
36
+ styleDegree?: SsmlAttributeValue;
37
+ role?: string;
38
+ }
39
+ interface SayAsElement extends SsmlElementBase {
40
+ type: "say-as" | "sayAs";
41
+ interpretAs?: string;
42
+ format?: string;
43
+ detail?: string;
44
+ }
45
+ interface PhonemeElement extends SsmlElementBase {
46
+ type: "phoneme";
47
+ alphabet?: string;
48
+ ph?: string;
49
+ }
50
+ interface EmphasisElement extends SsmlElementBase {
51
+ type: "emphasis";
52
+ level?: string;
53
+ }
54
+ interface AudioElement extends SsmlElementBase {
55
+ type: "audio";
56
+ src?: string;
57
+ desc?: string;
58
+ clipBegin?: SsmlAttributeValue;
59
+ clipEnd?: SsmlAttributeValue;
60
+ speed?: SsmlAttributeValue;
61
+ repeatCount?: SsmlAttributeValue;
62
+ repeatDuration?: SsmlAttributeValue;
63
+ soundLevel?: SsmlAttributeValue;
64
+ }
65
+ interface SubElement extends SsmlElementBase {
66
+ type: "sub";
67
+ alias?: string;
68
+ }
69
+ interface LangElement extends SsmlElementBase {
70
+ type: "lang";
71
+ lang?: string;
72
+ }
73
+ interface MarkElement extends SsmlElementBase {
74
+ type: "mark";
75
+ name?: string;
76
+ }
77
+ interface BookmarkElement extends SsmlElementBase {
78
+ type: "bookmark";
79
+ mark?: string;
80
+ }
81
+ interface LexiconElement extends SsmlElementBase {
82
+ type: "lexicon";
83
+ uri?: string;
84
+ }
85
+ interface ParagraphElement extends SsmlElementBase {
86
+ type: "p";
87
+ }
88
+ interface SentenceElement extends SsmlElementBase {
89
+ type: "s";
90
+ }
91
+ interface WordElement extends SsmlElementBase {
92
+ type: "w";
93
+ }
94
+ interface MsttsSilenceElement extends SsmlElementBase {
95
+ type: "mstts:silence" | "silence";
96
+ typeValue?: string;
97
+ silenceType?: string;
98
+ value?: SsmlAttributeValue;
99
+ }
100
+ interface MsttsVisemeElement extends SsmlElementBase {
101
+ type: "mstts:viseme" | "viseme";
102
+ typeValue?: string;
103
+ visemeType?: string;
104
+ }
105
+ interface CustomElement extends SsmlElementBase {
106
+ type: "custom" | "element";
107
+ name: string;
108
+ }
109
+ type SsmlElement = VoiceElement | ProsodyElement | BreakElement | ExpressAsElement | SayAsElement | PhonemeElement | EmphasisElement | AudioElement | SubElement | LangElement | MarkElement | BookmarkElement | LexiconElement | ParagraphElement | SentenceElement | WordElement | MsttsSilenceElement | MsttsVisemeElement | CustomElement;
110
+ interface SsmlDocument {
111
+ type?: "speak";
112
+ version: string;
113
+ lang: string;
114
+ children?: SsmlNode[];
115
+ /** @deprecated Use children to represent the document body. */
116
+ content?: string;
117
+ attributes?: SsmlAttributes;
118
+ }
119
+
120
+ type SsmlEditorInsertionButton = "break" | "emphasis" | "rate" | "pitch" | "volume" | "emotion" | "say-as" | "phoneme" | "audio" | "sub" | "lang" | "mark" | "bookmark" | "mstts:silence" | "mstts:viseme" | (string & {});
121
+ type SsmlEditorButton = "help" | SsmlEditorInsertionButton | "undo" | "redo" | "clearAll" | "format" | "decorations" | (string & {});
122
+ type SsmlEditorButtonVisibility = Readonly<Partial<Record<string, boolean>>>;
123
+
124
+ type SsmlEditorLocale = "ja" | "en";
125
+ type SsmlEditorLanguage = SsmlEditorLocale;
126
+ type SsmlEditorLocalizedText = Readonly<Record<SsmlEditorLocale, string>>;
127
+ interface EditorCopy {
128
+ editorAriaLabel: string;
129
+ toolbarAriaLabel: string;
130
+ undo: string;
131
+ undoTitle: string;
132
+ redo: string;
133
+ redoTitle: string;
134
+ clearAll: string;
135
+ clearAllTitle: string;
136
+ help: string;
137
+ helpTitle: string;
138
+ helpHeading: string;
139
+ helpDescription: string;
140
+ parameters: string;
141
+ format: string;
142
+ formatTitle: string;
143
+ decorations: string;
144
+ decorationsShowTitle: string;
145
+ decorationsHideTitle: string;
146
+ syntaxError: string;
147
+ selectionActions: string;
148
+ selectionCountSuffix: string;
149
+ previewSelection: string;
150
+ previewSelectionTitle: string;
151
+ }
152
+ interface InlineBadgeCopy {
153
+ pause: string;
154
+ pitch: string;
155
+ prosody: string;
156
+ }
157
+ interface SsmlHoverParameterCopy {
158
+ title: string;
159
+ description: string;
160
+ }
161
+ interface SsmlHoverTagCopy {
162
+ title: string;
163
+ description: string;
164
+ parameters: Readonly<Record<string, SsmlHoverParameterCopy>>;
165
+ }
166
+ interface SsmlHoverLocale {
167
+ parameterHeading: string;
168
+ parametersHeading: string;
169
+ allowedValues: string;
170
+ example: string;
171
+ noParameters: string;
172
+ tags: Readonly<Record<string, SsmlHoverTagCopy>>;
173
+ }
174
+ declare const EDITOR_COPY: Readonly<Record<SsmlEditorLocale, EditorCopy>>;
175
+ declare const INLINE_BADGE_COPY: Readonly<Record<SsmlEditorLocale, InlineBadgeCopy>>;
176
+ declare const SSML_HOVER_COPY: Readonly<Record<SsmlEditorLocale, SsmlHoverLocale>>;
177
+
178
+ type SsmlEditorInsertionMode = "insert" | "wrap";
179
+ interface SsmlEditorInsertionOption {
180
+ value: string;
181
+ labels: SsmlEditorLocalizedText;
182
+ descriptions?: SsmlEditorLocalizedText;
183
+ }
184
+ interface SsmlEditorInsertionTemplate {
185
+ prefix: string;
186
+ suffix: string;
187
+ mode: SsmlEditorInsertionMode;
188
+ }
189
+ interface SsmlEditorInsertionDefinition {
190
+ id: string;
191
+ icon: string;
192
+ tagName?: string;
193
+ selfClosing?: boolean;
194
+ labels: SsmlEditorLocalizedText;
195
+ titles?: SsmlEditorLocalizedText;
196
+ descriptions: SsmlEditorLocalizedText;
197
+ parameterDescription: SsmlEditorLocalizedText;
198
+ options: readonly SsmlEditorInsertionOption[];
199
+ createTemplate: (value: string) => SsmlEditorInsertionTemplate;
200
+ }
201
+ interface SsmlEditorCustomInsertionDefinition {
202
+ id: string;
203
+ tagName: string;
204
+ attribute?: string;
205
+ icon?: string;
206
+ labels: SsmlEditorLocalizedText;
207
+ titles?: SsmlEditorLocalizedText;
208
+ descriptions?: SsmlEditorLocalizedText;
209
+ parameterDescription?: SsmlEditorLocalizedText;
210
+ options: readonly SsmlEditorInsertionOption[];
211
+ mode?: SsmlEditorInsertionMode;
212
+ }
213
+ type SsmlEditorCustomInsertion = SsmlEditorInsertionDefinition | SsmlEditorCustomInsertionDefinition;
214
+ type SsmlEditorCustomInsertionCollection = readonly SsmlEditorCustomInsertion[] | Readonly<Record<string, SsmlEditorCustomInsertion | undefined>>;
215
+ interface SsmlEditorInsertionGroup {
216
+ id: string;
217
+ labels: SsmlEditorLocalizedText;
218
+ insertionIds: readonly string[];
219
+ }
220
+ interface SsmlEditorToolbarGroup {
221
+ id: string;
222
+ buttonIds: readonly string[];
223
+ }
224
+ type SsmlEditorTheme = "system" | "light" | "dark";
225
+ type SsmlEditorWordWrap = "off" | "on" | "wordWrapColumn" | "bounded";
226
+ type SsmlEditorLineNumbers = "on" | "off" | "relative" | "interval";
227
+ interface SsmlEditorOptions {
228
+ height?: string | number;
229
+ minHeight?: string | number;
230
+ readOnly?: boolean;
231
+ theme?: SsmlEditorTheme;
232
+ fontSize?: number;
233
+ wordWrap?: SsmlEditorWordWrap;
234
+ lineNumbers?: SsmlEditorLineNumbers;
235
+ minimap?: boolean;
236
+ automaticLayout?: boolean;
237
+ }
238
+ type SsmlInsertionOption = SsmlEditorInsertionOption;
239
+ type SsmlInsertionTemplate = SsmlEditorInsertionTemplate;
240
+ type SsmlInsertionDefinition = SsmlEditorInsertionDefinition;
241
+ declare function createSsmlEditorInsertionDefinition(definition: SsmlEditorCustomInsertionDefinition): SsmlEditorInsertionDefinition;
242
+ declare const SSML_INSERTIONS: ({
243
+ id: string;
244
+ icon: string;
245
+ tagName: string;
246
+ selfClosing: true;
247
+ labels: {
248
+ ja: string;
249
+ en: string;
250
+ };
251
+ descriptions: {
252
+ ja: string;
253
+ en: string;
254
+ };
255
+ parameterDescription: {
256
+ ja: string;
257
+ en: string;
258
+ };
259
+ options: readonly SsmlEditorInsertionOption[];
260
+ createTemplate: (value: string) => {
261
+ prefix: string;
262
+ suffix: string;
263
+ mode: "insert";
264
+ };
265
+ } | {
266
+ id: string;
267
+ icon: string;
268
+ tagName: string;
269
+ labels: {
270
+ ja: string;
271
+ en: string;
272
+ };
273
+ descriptions: {
274
+ ja: string;
275
+ en: string;
276
+ };
277
+ parameterDescription: {
278
+ ja: string;
279
+ en: string;
280
+ };
281
+ options: readonly SsmlEditorInsertionOption[];
282
+ createTemplate: (value: string) => {
283
+ prefix: string;
284
+ suffix: string;
285
+ mode: "wrap";
286
+ };
287
+ selfClosing?: undefined;
288
+ })[];
289
+ interface SsmlEditorProps {
290
+ document: SsmlDocument;
291
+ onChange?: (document: SsmlDocument) => void;
292
+ onSsmlChange?: (xml: string) => void;
293
+ onSelectionChange?: (info: SelectionInfo) => void;
294
+ /** Called with the selected partial SSML when the selection preview action is used. The action is disabled when omitted. */
295
+ onPreviewSelection?: (ssml: string) => void;
296
+ /** UI language. Japanese is used when omitted. */
297
+ language?: SsmlEditorLanguage;
298
+ /** UI locale. Japanese is used when omitted; takes precedence over the legacy language prop. */
299
+ locale?: SsmlEditorLocale;
300
+ /** Whether the toolbar is displayed. */
301
+ showToolbar?: boolean;
302
+ /** Whether toolbar action icons are displayed. */
303
+ showToolbarIcons?: boolean;
304
+ /** Whether toolbar action text labels are displayed. */
305
+ showToolbarLabels?: boolean;
306
+ /** Whether inline SSML decorations are displayed. The toolbar switch can change this at runtime. */
307
+ showDecorations?: boolean;
308
+ /** Controls which editor action buttons are displayed. Unspecified buttons are shown. */
309
+ buttonVisibility?: SsmlEditorButtonVisibility;
310
+ /** Monaco editor settings. */
311
+ editorOptions?: SsmlEditorOptions;
312
+ /** Alias for editorOptions. */
313
+ settings?: SsmlEditorOptions;
314
+ /** Fallback UI displayed while Monaco is loading. */
315
+ loadingFallback?: ReactNode;
316
+ /** Height of the Monaco editor. */
317
+ height?: string | number;
318
+ /** Minimum height of the Monaco editor container. */
319
+ minHeight?: string | number;
320
+ /** Whether the Monaco editor is read-only. */
321
+ readOnly?: boolean;
322
+ /** Monaco theme mode. */
323
+ theme?: SsmlEditorTheme;
324
+ /** Monaco editor font size. */
325
+ fontSize?: number;
326
+ /** Monaco editor word wrapping mode. */
327
+ wordWrap?: SsmlEditorWordWrap;
328
+ /** Monaco editor line number mode. */
329
+ lineNumbers?: SsmlEditorLineNumbers;
330
+ /** Whether the Monaco minimap is displayed. */
331
+ minimap?: boolean;
332
+ /** Whether Monaco automatically lays out when its container changes size. */
333
+ automaticLayout?: boolean;
334
+ /** Reorders all toolbar controls. Unlisted controls follow. */
335
+ toolbarOrder?: readonly SsmlEditorButton[];
336
+ /** Adds vertical separators between configured toolbar groups. */
337
+ toolbarGroups?: readonly SsmlEditorToolbarGroup[];
338
+ /** Reorders built-in and custom insertion menus. Unlisted insertions follow. */
339
+ insertionOrder?: readonly string[];
340
+ /** Visually groups insertion menus when toolbarGroups is not supplied. */
341
+ insertionGroups?: readonly SsmlEditorInsertionGroup[];
342
+ /** Replaces built-in insertion definitions with custom definitions by ID. */
343
+ customInsertions?: SsmlEditorCustomInsertionCollection;
344
+ /** Adds insertion definitions without replacing built-in definitions. */
345
+ additionalInsertions?: SsmlEditorCustomInsertionCollection;
346
+ /** Candidate style values shown by the built-in emotion insertion. */
347
+ emotionStyles?: readonly string[];
348
+ /** Class name applied to the editor container. */
349
+ className?: string;
350
+ /** Inline styles applied to the editor container. */
351
+ style?: CSSProperties;
352
+ /** Class name applied to the toolbar. */
353
+ toolbarClassName?: string;
354
+ /** Inline styles applied to the toolbar. */
355
+ toolbarStyle?: CSSProperties;
356
+ /** Class name applied to the editor display area. */
357
+ displayClassName?: string;
358
+ /** Inline styles applied to the editor display area. */
359
+ displayStyle?: CSSProperties;
360
+ }
361
+ interface SelectionInfo {
362
+ selectedText: string;
363
+ characterCount: number;
364
+ hasSelection: boolean;
365
+ }
366
+ interface SsmlEditorRef {
367
+ getSelectedSsml(): string | null;
368
+ getCurrentLineSsml(): string | null;
369
+ getFullSsml(): string;
370
+ }
371
+ declare const SsmlEditor: react.ForwardRefExoticComponent<SsmlEditorProps & react.RefAttributes<SsmlEditorRef>>;
372
+
373
+ export { EDITOR_COPY, type EditorCopy, INLINE_BADGE_COPY, type InlineBadgeCopy, SSML_HOVER_COPY, SSML_INSERTIONS, type SelectionInfo, SsmlEditor, type SsmlEditorButton, type SsmlEditorButtonVisibility, type SsmlEditorCustomInsertion, type SsmlEditorCustomInsertionCollection, type SsmlEditorCustomInsertionDefinition, type SsmlEditorInsertionButton, type SsmlEditorInsertionDefinition, type SsmlEditorInsertionGroup, type SsmlEditorInsertionMode, type SsmlEditorInsertionOption, type SsmlEditorInsertionTemplate, type SsmlEditorLanguage, type SsmlEditorLineNumbers, type SsmlEditorLocale, type SsmlEditorLocalizedText, type SsmlEditorOptions, type SsmlEditorProps, type SsmlEditorRef, type SsmlEditorTheme, type SsmlEditorToolbarGroup, type SsmlEditorWordWrap, type SsmlHoverLocale, type SsmlHoverParameterCopy, type SsmlHoverTagCopy, type SsmlInsertionDefinition, type SsmlInsertionOption, type SsmlInsertionTemplate, createSsmlEditorInsertionDefinition };