@ssml-builder-js/ssml-editor-react 2.4.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/CHANGELOG.md +91 -0
- package/dist/index.d.mts +288 -0
- package/dist/index.d.ts +288 -0
- package/dist/index.js +5423 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +5385 -0
- package/dist/index.mjs.map +1 -0
- package/e2e/monaco-editor.spec.ts +126 -0
- package/package.json +57 -0
- package/src/SsmlEditor.tsx +1302 -0
- package/src/buttonVisibility.ts +36 -0
- package/src/clearSsmlDocument.ts +57 -0
- package/src/components/popovers/InsertionPopover.tsx +136 -0
- package/src/components/popovers/InsertionPopovers.tsx +47 -0
- package/src/components/popovers/ProsodyPopovers.tsx +78 -0
- package/src/components/popovers/TextPopovers.tsx +8 -0
- package/src/components/popovers/TimingPopovers.tsx +8 -0
- package/src/constants/ssmlPresets.ts +660 -0
- package/src/constants/ui.ts +11 -0
- package/src/editableSsml.ts +251 -0
- package/src/formatXml.ts +600 -0
- package/src/hooks/useSsmlEditorState.ts +704 -0
- package/src/hooks/useSsmlMonaco.ts +393 -0
- package/src/index.tsx +50 -0
- package/src/locales.ts +435 -0
- package/src/ssmlCodeAction.ts +144 -0
- package/src/ssmlCodeLens.ts +226 -0
- package/src/ssmlCompletion.ts +129 -0
- package/src/ssmlContext.ts +196 -0
- package/src/ssmlDiagnostics.ts +191 -0
- package/src/ssmlHover.ts +703 -0
- package/src/ssmlInsertion.ts +75 -0
- package/src/ssmlInsertions.ts +471 -0
- package/src/styles/editorStyles.ts +282 -0
- package/test/format-xml-edge-cases.test.ts +107 -0
- package/test/index.test.ts +597 -0
- package/test/randomized-editor-invariants.test.ts +520 -0
- package/test/ui-components.test.tsx +854 -0
- package/tsconfig.json +10 -0
- package/tsup.config.ts +17 -0
- package/vitest.config.mjs +10 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# @ssml-builder-js/ssml-editor-react
|
|
2
|
+
|
|
3
|
+
## 2.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add SSML text-node translation helpers and Azure semantic validation, improve Azure TTS endpoint and logger handling, support React 18 peer dependencies, and complete independent package publishing metadata.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @ssml-builder-js/ssml-core@2.4.0
|
|
13
|
+
|
|
14
|
+
## 2.3.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- deecde6: Add CodeLens quick controls for editing and managing SSML prosody and break tags.
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- @ssml-builder-js/ssml-core@2.3.0
|
|
23
|
+
|
|
24
|
+
## 2.2.0
|
|
25
|
+
|
|
26
|
+
### Minor Changes
|
|
27
|
+
|
|
28
|
+
- e124614: ---
|
|
29
|
+
|
|
30
|
+
"@ssml-builder-js/ssml-editor-elements": minor
|
|
31
|
+
"@ssml-builder-js/ssml-editor-react": minor
|
|
32
|
+
"@ssml-builder-js/ssml-core": minor
|
|
33
|
+
"@ssml-builder-js/azure-tts-client": minor
|
|
34
|
+
"playground": minor
|
|
35
|
+
|
|
36
|
+
***
|
|
37
|
+
|
|
38
|
+
- **Web Components サポート (`@ssml-builder-js/ssml-editor-elements`) の追加**
|
|
39
|
+
- フレームワーク非依存で利用可能な `<ssml-editor>` カスタム要素(Custom Element)パッケージを新設。
|
|
40
|
+
- ルートパッケージからのエクスポート(`ssml-builder-js/elements`)および Playground での React / Web Components 切り替え動作環境を整備。
|
|
41
|
+
- **多言語音声モデル(Voice)ごとの感情スタイル動的フィルタリングの拡充**
|
|
42
|
+
- 日本語(`ja-JP`)、英語(`en-US`)、中国語(`zh-CN`)、韓国語、欧州言語等の Neural 音声モデルに対応する発話スタイル一覧を公式仕様に合わせて網羅。
|
|
43
|
+
- 感情非対応の音声モデルに対する disabled 表示・フォールバック処理を実装。
|
|
44
|
+
- **スタイル選択 UI の `<optgroup>` カテゴリ分類**
|
|
45
|
+
- `ProsodyPopovers` 内のスタイル選択肢を「感情・トーン(Emotions)」「会話・シナリオ(Scenarios)」「メディア・報道(Media)」にグループ化し、視認性と操作性を向上。
|
|
46
|
+
- **ツールバーのアクティブタグ状態表示 (Active State Feedback)**
|
|
47
|
+
|
|
48
|
+
- エディタ内のカーソル位置(キャレット)を囲む SSML タグをリアルタイムに検知し、対応するツールバーボタン(Prosody, Style 等)をハイライト表示する機能を追加。
|
|
49
|
+
|
|
50
|
+
- モノレポ各パッケージのビルド設定(tsup)および型定義エクスポート(dts)を最適化。
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- Updated dependencies [e124614]
|
|
55
|
+
- @ssml-builder-js/ssml-core@2.2.0
|
|
56
|
+
|
|
57
|
+
## 2.1.0
|
|
58
|
+
|
|
59
|
+
### Minor Changes
|
|
60
|
+
|
|
61
|
+
- 5b21410: Filter express-as style completion and Emotion menu options by the active parent voice.
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- 845a6d3: - **`<mstts:express-as>` のスタイル動的フィルタリング:** 親要素の `<voice name="...">` に応じて利用可能な感情スタイル(`style`)のみを自動補完・Popover 選択肢へ動的に絞り込む機能を追加。
|
|
66
|
+
- **Quick Fix (CodeAction) の拡張:** 未閉じタグの自動補完挿入および無効な属性値の 1 クリック修正に対応。
|
|
67
|
+
- **自動補完およびエディタ内部設計の最適化:** 入力時の Range 置換精度の改善および Popover コンポーネント・状態管理のモジュール分離を実施。
|
|
68
|
+
- Updated dependencies [845a6d3]
|
|
69
|
+
- @ssml-builder-js/ssml-core@2.1.0
|
|
70
|
+
|
|
71
|
+
## 2.0.0
|
|
72
|
+
|
|
73
|
+
### Major Changes
|
|
74
|
+
|
|
75
|
+
- 4935073: ---
|
|
76
|
+
|
|
77
|
+
### Patch Changes
|
|
78
|
+
|
|
79
|
+
- Updated dependencies [4935073]
|
|
80
|
+
- @ssml-builder-js/ssml-core@2.0.0
|
|
81
|
+
|
|
82
|
+
## 1.0.0
|
|
83
|
+
|
|
84
|
+
### Major Changes
|
|
85
|
+
|
|
86
|
+
- 6c78e70: chore: initial release
|
|
87
|
+
|
|
88
|
+
### Patch Changes
|
|
89
|
+
|
|
90
|
+
- Updated dependencies [6c78e70]
|
|
91
|
+
- @ssml-builder-js/ssml-core@1.0.0
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
+
import { SsmlDocument } from '@ssml-builder-js/ssml-core';
|
|
4
|
+
import { OnMount, Monaco } from '@monaco-editor/react';
|
|
5
|
+
|
|
6
|
+
type SsmlEditorInsertionButton = "break" | "emphasis" | "rate" | "pitch" | "volume" | "emotion" | "say-as" | "phoneme" | "audio" | "sub" | "lang" | "mark" | "bookmark" | "mstts:silence" | "mstts:viseme" | (string & {});
|
|
7
|
+
type SsmlEditorButton = "help" | SsmlEditorInsertionButton | "undo" | "redo" | "clearAll" | "format" | "decorations" | (string & {});
|
|
8
|
+
type SsmlEditorButtonVisibility = Readonly<Partial<Record<string, boolean>>>;
|
|
9
|
+
|
|
10
|
+
type SsmlEditorLocale = "ja" | "en";
|
|
11
|
+
type SsmlEditorLanguage = SsmlEditorLocale;
|
|
12
|
+
type SsmlEditorLocalizedText = Readonly<Record<SsmlEditorLocale, string>>;
|
|
13
|
+
interface EditorCopy {
|
|
14
|
+
editorAriaLabel: string;
|
|
15
|
+
toolbarAriaLabel: string;
|
|
16
|
+
undo: string;
|
|
17
|
+
undoTitle: string;
|
|
18
|
+
redo: string;
|
|
19
|
+
redoTitle: string;
|
|
20
|
+
clearAll: string;
|
|
21
|
+
clearAllTitle: string;
|
|
22
|
+
help: string;
|
|
23
|
+
helpTitle: string;
|
|
24
|
+
helpHeading: string;
|
|
25
|
+
helpDescription: string;
|
|
26
|
+
parameters: string;
|
|
27
|
+
format: string;
|
|
28
|
+
formatTitle: string;
|
|
29
|
+
decorations: string;
|
|
30
|
+
decorationsShowTitle: string;
|
|
31
|
+
decorationsHideTitle: string;
|
|
32
|
+
syntaxError: string;
|
|
33
|
+
selectionActions: string;
|
|
34
|
+
selectionCountSuffix: string;
|
|
35
|
+
previewSelection: string;
|
|
36
|
+
previewSelectionTitle: string;
|
|
37
|
+
noAvailableOptions: string;
|
|
38
|
+
styleNotSupported: string;
|
|
39
|
+
categoryEmotions: string;
|
|
40
|
+
categoryScenarios: string;
|
|
41
|
+
categoryMedia: string;
|
|
42
|
+
categoryOther: string;
|
|
43
|
+
}
|
|
44
|
+
interface InlineBadgeCopy {
|
|
45
|
+
pause: string;
|
|
46
|
+
pitch: string;
|
|
47
|
+
prosody: string;
|
|
48
|
+
}
|
|
49
|
+
interface SsmlHoverParameterCopy {
|
|
50
|
+
title: string;
|
|
51
|
+
description: string;
|
|
52
|
+
}
|
|
53
|
+
interface SsmlHoverTagCopy {
|
|
54
|
+
title: string;
|
|
55
|
+
description: string;
|
|
56
|
+
parameters: Readonly<Record<string, SsmlHoverParameterCopy>>;
|
|
57
|
+
}
|
|
58
|
+
interface SsmlHoverLocale {
|
|
59
|
+
parameterHeading: string;
|
|
60
|
+
parametersHeading: string;
|
|
61
|
+
allowedValues: string;
|
|
62
|
+
example: string;
|
|
63
|
+
noParameters: string;
|
|
64
|
+
tags: Readonly<Record<string, SsmlHoverTagCopy>>;
|
|
65
|
+
}
|
|
66
|
+
declare const EDITOR_COPY: Readonly<Record<SsmlEditorLocale, EditorCopy>>;
|
|
67
|
+
declare const INLINE_BADGE_COPY: Readonly<Record<SsmlEditorLocale, InlineBadgeCopy>>;
|
|
68
|
+
declare const SSML_HOVER_COPY: Readonly<Record<SsmlEditorLocale, SsmlHoverLocale>>;
|
|
69
|
+
|
|
70
|
+
type SsmlEditorInsertionMode = "insert" | "wrap";
|
|
71
|
+
interface SsmlEditorInsertionOption {
|
|
72
|
+
value: string;
|
|
73
|
+
labels: SsmlEditorLocalizedText;
|
|
74
|
+
descriptions?: SsmlEditorLocalizedText;
|
|
75
|
+
}
|
|
76
|
+
interface SsmlEditorInsertionTemplate {
|
|
77
|
+
prefix: string;
|
|
78
|
+
suffix: string;
|
|
79
|
+
mode: SsmlEditorInsertionMode;
|
|
80
|
+
}
|
|
81
|
+
interface SsmlEditorInsertionDefinition {
|
|
82
|
+
id: string;
|
|
83
|
+
icon: string;
|
|
84
|
+
tagName?: string;
|
|
85
|
+
selfClosing?: boolean;
|
|
86
|
+
labels: SsmlEditorLocalizedText;
|
|
87
|
+
titles?: SsmlEditorLocalizedText;
|
|
88
|
+
descriptions: SsmlEditorLocalizedText;
|
|
89
|
+
parameterDescription: SsmlEditorLocalizedText;
|
|
90
|
+
options: readonly SsmlEditorInsertionOption[];
|
|
91
|
+
createTemplate: (value: string) => SsmlEditorInsertionTemplate;
|
|
92
|
+
}
|
|
93
|
+
interface SsmlEditorCustomInsertionDefinition {
|
|
94
|
+
id: string;
|
|
95
|
+
tagName: string;
|
|
96
|
+
attribute?: string;
|
|
97
|
+
icon?: string;
|
|
98
|
+
labels: SsmlEditorLocalizedText;
|
|
99
|
+
titles?: SsmlEditorLocalizedText;
|
|
100
|
+
descriptions?: SsmlEditorLocalizedText;
|
|
101
|
+
parameterDescription?: SsmlEditorLocalizedText;
|
|
102
|
+
options: readonly SsmlEditorInsertionOption[];
|
|
103
|
+
mode?: SsmlEditorInsertionMode;
|
|
104
|
+
}
|
|
105
|
+
type SsmlEditorCustomInsertion = SsmlEditorInsertionDefinition | SsmlEditorCustomInsertionDefinition;
|
|
106
|
+
type SsmlEditorCustomInsertionCollection = readonly SsmlEditorCustomInsertion[] | Readonly<Record<string, SsmlEditorCustomInsertion | undefined>>;
|
|
107
|
+
interface SsmlEditorInsertionGroup {
|
|
108
|
+
id: string;
|
|
109
|
+
labels: SsmlEditorLocalizedText;
|
|
110
|
+
insertionIds: readonly string[];
|
|
111
|
+
}
|
|
112
|
+
interface SsmlEditorToolbarGroup {
|
|
113
|
+
id: string;
|
|
114
|
+
buttonIds: readonly string[];
|
|
115
|
+
}
|
|
116
|
+
type SsmlEditorTheme = "system" | "light" | "dark";
|
|
117
|
+
type SsmlEditorWordWrap = "off" | "on" | "wordWrapColumn" | "bounded";
|
|
118
|
+
type SsmlEditorLineNumbers = "on" | "off" | "relative" | "interval";
|
|
119
|
+
interface SsmlEditorOptions {
|
|
120
|
+
height?: string | number;
|
|
121
|
+
minHeight?: string | number;
|
|
122
|
+
readOnly?: boolean;
|
|
123
|
+
theme?: SsmlEditorTheme;
|
|
124
|
+
fontSize?: number;
|
|
125
|
+
wordWrap?: SsmlEditorWordWrap;
|
|
126
|
+
lineNumbers?: SsmlEditorLineNumbers;
|
|
127
|
+
minimap?: boolean;
|
|
128
|
+
automaticLayout?: boolean;
|
|
129
|
+
}
|
|
130
|
+
type SsmlInsertionOption = SsmlEditorInsertionOption;
|
|
131
|
+
type SsmlInsertionTemplate = SsmlEditorInsertionTemplate;
|
|
132
|
+
type SsmlInsertionDefinition = SsmlEditorInsertionDefinition;
|
|
133
|
+
declare function createSsmlEditorInsertionDefinition(definition: SsmlEditorCustomInsertionDefinition): SsmlEditorInsertionDefinition;
|
|
134
|
+
declare const SSML_INSERTIONS: ({
|
|
135
|
+
id: string;
|
|
136
|
+
icon: string;
|
|
137
|
+
tagName: string;
|
|
138
|
+
selfClosing: true;
|
|
139
|
+
labels: {
|
|
140
|
+
ja: string;
|
|
141
|
+
en: string;
|
|
142
|
+
};
|
|
143
|
+
descriptions: {
|
|
144
|
+
ja: string;
|
|
145
|
+
en: string;
|
|
146
|
+
};
|
|
147
|
+
parameterDescription: {
|
|
148
|
+
ja: string;
|
|
149
|
+
en: string;
|
|
150
|
+
};
|
|
151
|
+
options: readonly SsmlEditorInsertionOption[];
|
|
152
|
+
createTemplate: (value: string) => {
|
|
153
|
+
prefix: string;
|
|
154
|
+
suffix: string;
|
|
155
|
+
mode: "insert";
|
|
156
|
+
};
|
|
157
|
+
} | {
|
|
158
|
+
id: string;
|
|
159
|
+
icon: string;
|
|
160
|
+
tagName: string;
|
|
161
|
+
labels: {
|
|
162
|
+
ja: string;
|
|
163
|
+
en: string;
|
|
164
|
+
};
|
|
165
|
+
descriptions: {
|
|
166
|
+
ja: string;
|
|
167
|
+
en: string;
|
|
168
|
+
};
|
|
169
|
+
parameterDescription: {
|
|
170
|
+
ja: string;
|
|
171
|
+
en: string;
|
|
172
|
+
};
|
|
173
|
+
options: readonly SsmlEditorInsertionOption[];
|
|
174
|
+
createTemplate: (value: string) => {
|
|
175
|
+
prefix: string;
|
|
176
|
+
suffix: string;
|
|
177
|
+
mode: "wrap";
|
|
178
|
+
};
|
|
179
|
+
selfClosing?: undefined;
|
|
180
|
+
})[];
|
|
181
|
+
interface SsmlEditorProps {
|
|
182
|
+
document: SsmlDocument;
|
|
183
|
+
onChange?: (document: SsmlDocument) => void;
|
|
184
|
+
onSsmlChange?: (xml: string) => void;
|
|
185
|
+
onSelectionChange?: (info: SelectionInfo) => void;
|
|
186
|
+
/** Called with the selected partial SSML when the selection preview action is used. The action is disabled when omitted. */
|
|
187
|
+
onPreviewSelection?: (ssml: string) => void;
|
|
188
|
+
/** UI language. Japanese is used when omitted. */
|
|
189
|
+
language?: SsmlEditorLanguage;
|
|
190
|
+
/** UI locale. Japanese is used when omitted; takes precedence over the legacy language prop. */
|
|
191
|
+
locale?: SsmlEditorLocale;
|
|
192
|
+
/** Whether the toolbar is displayed. */
|
|
193
|
+
showToolbar?: boolean;
|
|
194
|
+
/** Whether toolbar action icons are displayed. */
|
|
195
|
+
showToolbarIcons?: boolean;
|
|
196
|
+
/** Whether toolbar action text labels are displayed. */
|
|
197
|
+
showToolbarLabels?: boolean;
|
|
198
|
+
/** Whether inline SSML decorations are displayed. The toolbar switch can change this at runtime. */
|
|
199
|
+
showDecorations?: boolean;
|
|
200
|
+
/** Whether SSML CodeLens quick controls are displayed. */
|
|
201
|
+
enableCodeLens?: boolean;
|
|
202
|
+
/** Controls which editor action buttons are displayed. Unspecified buttons are shown. */
|
|
203
|
+
buttonVisibility?: SsmlEditorButtonVisibility;
|
|
204
|
+
/** Monaco editor settings. */
|
|
205
|
+
editorOptions?: SsmlEditorOptions;
|
|
206
|
+
/** Alias for editorOptions. */
|
|
207
|
+
settings?: SsmlEditorOptions;
|
|
208
|
+
/** Fallback UI displayed while Monaco is loading. */
|
|
209
|
+
loadingFallback?: ReactNode;
|
|
210
|
+
/** Height of the Monaco editor. */
|
|
211
|
+
height?: string | number;
|
|
212
|
+
/** Minimum height of the Monaco editor container. */
|
|
213
|
+
minHeight?: string | number;
|
|
214
|
+
/** Whether the Monaco editor is read-only. */
|
|
215
|
+
readOnly?: boolean;
|
|
216
|
+
/** Monaco theme mode. */
|
|
217
|
+
theme?: SsmlEditorTheme;
|
|
218
|
+
/** Monaco editor font size. */
|
|
219
|
+
fontSize?: number;
|
|
220
|
+
/** Monaco editor word wrapping mode. */
|
|
221
|
+
wordWrap?: SsmlEditorWordWrap;
|
|
222
|
+
/** Monaco editor line number mode. */
|
|
223
|
+
lineNumbers?: SsmlEditorLineNumbers;
|
|
224
|
+
/** Whether the Monaco minimap is displayed. */
|
|
225
|
+
minimap?: boolean;
|
|
226
|
+
/** Whether Monaco automatically lays out when its container changes size. */
|
|
227
|
+
automaticLayout?: boolean;
|
|
228
|
+
/** Reorders all toolbar controls. Unlisted controls follow. */
|
|
229
|
+
toolbarOrder?: readonly SsmlEditorButton[];
|
|
230
|
+
/** Adds vertical separators between configured toolbar groups. */
|
|
231
|
+
toolbarGroups?: readonly SsmlEditorToolbarGroup[];
|
|
232
|
+
/** Reorders built-in and custom insertion menus. Unlisted insertions follow. */
|
|
233
|
+
insertionOrder?: readonly string[];
|
|
234
|
+
/** Visually groups insertion menus when toolbarGroups is not supplied. */
|
|
235
|
+
insertionGroups?: readonly SsmlEditorInsertionGroup[];
|
|
236
|
+
/** Replaces built-in insertion definitions with custom definitions by ID. */
|
|
237
|
+
customInsertions?: SsmlEditorCustomInsertionCollection;
|
|
238
|
+
/** Adds insertion definitions without replacing built-in definitions. */
|
|
239
|
+
additionalInsertions?: SsmlEditorCustomInsertionCollection;
|
|
240
|
+
/** Candidate style values shown by the built-in emotion insertion. */
|
|
241
|
+
emotionStyles?: readonly string[];
|
|
242
|
+
/** Class name applied to the editor container. */
|
|
243
|
+
className?: string;
|
|
244
|
+
/** Inline styles applied to the editor container. */
|
|
245
|
+
style?: CSSProperties;
|
|
246
|
+
/** Class name applied to the toolbar. */
|
|
247
|
+
toolbarClassName?: string;
|
|
248
|
+
/** Inline styles applied to the toolbar. */
|
|
249
|
+
toolbarStyle?: CSSProperties;
|
|
250
|
+
/** Class name applied to the editor display area. */
|
|
251
|
+
displayClassName?: string;
|
|
252
|
+
/** Inline styles applied to the editor display area. */
|
|
253
|
+
displayStyle?: CSSProperties;
|
|
254
|
+
}
|
|
255
|
+
interface SelectionInfo {
|
|
256
|
+
selectedText: string;
|
|
257
|
+
characterCount: number;
|
|
258
|
+
hasSelection: boolean;
|
|
259
|
+
}
|
|
260
|
+
interface SsmlEditorRef {
|
|
261
|
+
getSelectedSsml(): string | null;
|
|
262
|
+
getCurrentLineSsml(): string | null;
|
|
263
|
+
getFullSsml(): string;
|
|
264
|
+
}
|
|
265
|
+
declare const SsmlEditor: react.ForwardRefExoticComponent<SsmlEditorProps & react.RefAttributes<SsmlEditorRef>>;
|
|
266
|
+
|
|
267
|
+
type MonacoEditor = Parameters<OnMount>[0];
|
|
268
|
+
|
|
269
|
+
interface SsmlTagRange {
|
|
270
|
+
start: number;
|
|
271
|
+
end: number;
|
|
272
|
+
}
|
|
273
|
+
declare function updateTagAttribute(text: string, tagRange: SsmlTagRange, attributeName: string, newValue: string): string;
|
|
274
|
+
|
|
275
|
+
type SsmlCodeLensAction = {
|
|
276
|
+
type: "attribute";
|
|
277
|
+
insertionId: "rate" | "pitch" | "break";
|
|
278
|
+
attributeName: "rate" | "pitch" | "time";
|
|
279
|
+
tagRange: SsmlTagRange;
|
|
280
|
+
} | {
|
|
281
|
+
type: "unwrap" | "delete";
|
|
282
|
+
tagRange: SsmlTagRange;
|
|
283
|
+
elementRange: SsmlTagRange;
|
|
284
|
+
};
|
|
285
|
+
type SsmlCodeLensCallback = (action: SsmlCodeLensAction) => void;
|
|
286
|
+
declare function registerSsmlCodeLens(monaco: Monaco, editor: MonacoEditor, onOpenPopover: SsmlCodeLensCallback): ReturnType<Monaco["languages"]["registerCodeLensProvider"]>;
|
|
287
|
+
|
|
288
|
+
export { EDITOR_COPY, type EditorCopy, INLINE_BADGE_COPY, type InlineBadgeCopy, SSML_HOVER_COPY, SSML_INSERTIONS, type SelectionInfo, type SsmlCodeLensAction, type SsmlCodeLensCallback, 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, type SsmlTagRange, createSsmlEditorInsertionDefinition, registerSsmlCodeLens, updateTagAttribute };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
+
import { SsmlDocument } from '@ssml-builder-js/ssml-core';
|
|
4
|
+
import { OnMount, Monaco } from '@monaco-editor/react';
|
|
5
|
+
|
|
6
|
+
type SsmlEditorInsertionButton = "break" | "emphasis" | "rate" | "pitch" | "volume" | "emotion" | "say-as" | "phoneme" | "audio" | "sub" | "lang" | "mark" | "bookmark" | "mstts:silence" | "mstts:viseme" | (string & {});
|
|
7
|
+
type SsmlEditorButton = "help" | SsmlEditorInsertionButton | "undo" | "redo" | "clearAll" | "format" | "decorations" | (string & {});
|
|
8
|
+
type SsmlEditorButtonVisibility = Readonly<Partial<Record<string, boolean>>>;
|
|
9
|
+
|
|
10
|
+
type SsmlEditorLocale = "ja" | "en";
|
|
11
|
+
type SsmlEditorLanguage = SsmlEditorLocale;
|
|
12
|
+
type SsmlEditorLocalizedText = Readonly<Record<SsmlEditorLocale, string>>;
|
|
13
|
+
interface EditorCopy {
|
|
14
|
+
editorAriaLabel: string;
|
|
15
|
+
toolbarAriaLabel: string;
|
|
16
|
+
undo: string;
|
|
17
|
+
undoTitle: string;
|
|
18
|
+
redo: string;
|
|
19
|
+
redoTitle: string;
|
|
20
|
+
clearAll: string;
|
|
21
|
+
clearAllTitle: string;
|
|
22
|
+
help: string;
|
|
23
|
+
helpTitle: string;
|
|
24
|
+
helpHeading: string;
|
|
25
|
+
helpDescription: string;
|
|
26
|
+
parameters: string;
|
|
27
|
+
format: string;
|
|
28
|
+
formatTitle: string;
|
|
29
|
+
decorations: string;
|
|
30
|
+
decorationsShowTitle: string;
|
|
31
|
+
decorationsHideTitle: string;
|
|
32
|
+
syntaxError: string;
|
|
33
|
+
selectionActions: string;
|
|
34
|
+
selectionCountSuffix: string;
|
|
35
|
+
previewSelection: string;
|
|
36
|
+
previewSelectionTitle: string;
|
|
37
|
+
noAvailableOptions: string;
|
|
38
|
+
styleNotSupported: string;
|
|
39
|
+
categoryEmotions: string;
|
|
40
|
+
categoryScenarios: string;
|
|
41
|
+
categoryMedia: string;
|
|
42
|
+
categoryOther: string;
|
|
43
|
+
}
|
|
44
|
+
interface InlineBadgeCopy {
|
|
45
|
+
pause: string;
|
|
46
|
+
pitch: string;
|
|
47
|
+
prosody: string;
|
|
48
|
+
}
|
|
49
|
+
interface SsmlHoverParameterCopy {
|
|
50
|
+
title: string;
|
|
51
|
+
description: string;
|
|
52
|
+
}
|
|
53
|
+
interface SsmlHoverTagCopy {
|
|
54
|
+
title: string;
|
|
55
|
+
description: string;
|
|
56
|
+
parameters: Readonly<Record<string, SsmlHoverParameterCopy>>;
|
|
57
|
+
}
|
|
58
|
+
interface SsmlHoverLocale {
|
|
59
|
+
parameterHeading: string;
|
|
60
|
+
parametersHeading: string;
|
|
61
|
+
allowedValues: string;
|
|
62
|
+
example: string;
|
|
63
|
+
noParameters: string;
|
|
64
|
+
tags: Readonly<Record<string, SsmlHoverTagCopy>>;
|
|
65
|
+
}
|
|
66
|
+
declare const EDITOR_COPY: Readonly<Record<SsmlEditorLocale, EditorCopy>>;
|
|
67
|
+
declare const INLINE_BADGE_COPY: Readonly<Record<SsmlEditorLocale, InlineBadgeCopy>>;
|
|
68
|
+
declare const SSML_HOVER_COPY: Readonly<Record<SsmlEditorLocale, SsmlHoverLocale>>;
|
|
69
|
+
|
|
70
|
+
type SsmlEditorInsertionMode = "insert" | "wrap";
|
|
71
|
+
interface SsmlEditorInsertionOption {
|
|
72
|
+
value: string;
|
|
73
|
+
labels: SsmlEditorLocalizedText;
|
|
74
|
+
descriptions?: SsmlEditorLocalizedText;
|
|
75
|
+
}
|
|
76
|
+
interface SsmlEditorInsertionTemplate {
|
|
77
|
+
prefix: string;
|
|
78
|
+
suffix: string;
|
|
79
|
+
mode: SsmlEditorInsertionMode;
|
|
80
|
+
}
|
|
81
|
+
interface SsmlEditorInsertionDefinition {
|
|
82
|
+
id: string;
|
|
83
|
+
icon: string;
|
|
84
|
+
tagName?: string;
|
|
85
|
+
selfClosing?: boolean;
|
|
86
|
+
labels: SsmlEditorLocalizedText;
|
|
87
|
+
titles?: SsmlEditorLocalizedText;
|
|
88
|
+
descriptions: SsmlEditorLocalizedText;
|
|
89
|
+
parameterDescription: SsmlEditorLocalizedText;
|
|
90
|
+
options: readonly SsmlEditorInsertionOption[];
|
|
91
|
+
createTemplate: (value: string) => SsmlEditorInsertionTemplate;
|
|
92
|
+
}
|
|
93
|
+
interface SsmlEditorCustomInsertionDefinition {
|
|
94
|
+
id: string;
|
|
95
|
+
tagName: string;
|
|
96
|
+
attribute?: string;
|
|
97
|
+
icon?: string;
|
|
98
|
+
labels: SsmlEditorLocalizedText;
|
|
99
|
+
titles?: SsmlEditorLocalizedText;
|
|
100
|
+
descriptions?: SsmlEditorLocalizedText;
|
|
101
|
+
parameterDescription?: SsmlEditorLocalizedText;
|
|
102
|
+
options: readonly SsmlEditorInsertionOption[];
|
|
103
|
+
mode?: SsmlEditorInsertionMode;
|
|
104
|
+
}
|
|
105
|
+
type SsmlEditorCustomInsertion = SsmlEditorInsertionDefinition | SsmlEditorCustomInsertionDefinition;
|
|
106
|
+
type SsmlEditorCustomInsertionCollection = readonly SsmlEditorCustomInsertion[] | Readonly<Record<string, SsmlEditorCustomInsertion | undefined>>;
|
|
107
|
+
interface SsmlEditorInsertionGroup {
|
|
108
|
+
id: string;
|
|
109
|
+
labels: SsmlEditorLocalizedText;
|
|
110
|
+
insertionIds: readonly string[];
|
|
111
|
+
}
|
|
112
|
+
interface SsmlEditorToolbarGroup {
|
|
113
|
+
id: string;
|
|
114
|
+
buttonIds: readonly string[];
|
|
115
|
+
}
|
|
116
|
+
type SsmlEditorTheme = "system" | "light" | "dark";
|
|
117
|
+
type SsmlEditorWordWrap = "off" | "on" | "wordWrapColumn" | "bounded";
|
|
118
|
+
type SsmlEditorLineNumbers = "on" | "off" | "relative" | "interval";
|
|
119
|
+
interface SsmlEditorOptions {
|
|
120
|
+
height?: string | number;
|
|
121
|
+
minHeight?: string | number;
|
|
122
|
+
readOnly?: boolean;
|
|
123
|
+
theme?: SsmlEditorTheme;
|
|
124
|
+
fontSize?: number;
|
|
125
|
+
wordWrap?: SsmlEditorWordWrap;
|
|
126
|
+
lineNumbers?: SsmlEditorLineNumbers;
|
|
127
|
+
minimap?: boolean;
|
|
128
|
+
automaticLayout?: boolean;
|
|
129
|
+
}
|
|
130
|
+
type SsmlInsertionOption = SsmlEditorInsertionOption;
|
|
131
|
+
type SsmlInsertionTemplate = SsmlEditorInsertionTemplate;
|
|
132
|
+
type SsmlInsertionDefinition = SsmlEditorInsertionDefinition;
|
|
133
|
+
declare function createSsmlEditorInsertionDefinition(definition: SsmlEditorCustomInsertionDefinition): SsmlEditorInsertionDefinition;
|
|
134
|
+
declare const SSML_INSERTIONS: ({
|
|
135
|
+
id: string;
|
|
136
|
+
icon: string;
|
|
137
|
+
tagName: string;
|
|
138
|
+
selfClosing: true;
|
|
139
|
+
labels: {
|
|
140
|
+
ja: string;
|
|
141
|
+
en: string;
|
|
142
|
+
};
|
|
143
|
+
descriptions: {
|
|
144
|
+
ja: string;
|
|
145
|
+
en: string;
|
|
146
|
+
};
|
|
147
|
+
parameterDescription: {
|
|
148
|
+
ja: string;
|
|
149
|
+
en: string;
|
|
150
|
+
};
|
|
151
|
+
options: readonly SsmlEditorInsertionOption[];
|
|
152
|
+
createTemplate: (value: string) => {
|
|
153
|
+
prefix: string;
|
|
154
|
+
suffix: string;
|
|
155
|
+
mode: "insert";
|
|
156
|
+
};
|
|
157
|
+
} | {
|
|
158
|
+
id: string;
|
|
159
|
+
icon: string;
|
|
160
|
+
tagName: string;
|
|
161
|
+
labels: {
|
|
162
|
+
ja: string;
|
|
163
|
+
en: string;
|
|
164
|
+
};
|
|
165
|
+
descriptions: {
|
|
166
|
+
ja: string;
|
|
167
|
+
en: string;
|
|
168
|
+
};
|
|
169
|
+
parameterDescription: {
|
|
170
|
+
ja: string;
|
|
171
|
+
en: string;
|
|
172
|
+
};
|
|
173
|
+
options: readonly SsmlEditorInsertionOption[];
|
|
174
|
+
createTemplate: (value: string) => {
|
|
175
|
+
prefix: string;
|
|
176
|
+
suffix: string;
|
|
177
|
+
mode: "wrap";
|
|
178
|
+
};
|
|
179
|
+
selfClosing?: undefined;
|
|
180
|
+
})[];
|
|
181
|
+
interface SsmlEditorProps {
|
|
182
|
+
document: SsmlDocument;
|
|
183
|
+
onChange?: (document: SsmlDocument) => void;
|
|
184
|
+
onSsmlChange?: (xml: string) => void;
|
|
185
|
+
onSelectionChange?: (info: SelectionInfo) => void;
|
|
186
|
+
/** Called with the selected partial SSML when the selection preview action is used. The action is disabled when omitted. */
|
|
187
|
+
onPreviewSelection?: (ssml: string) => void;
|
|
188
|
+
/** UI language. Japanese is used when omitted. */
|
|
189
|
+
language?: SsmlEditorLanguage;
|
|
190
|
+
/** UI locale. Japanese is used when omitted; takes precedence over the legacy language prop. */
|
|
191
|
+
locale?: SsmlEditorLocale;
|
|
192
|
+
/** Whether the toolbar is displayed. */
|
|
193
|
+
showToolbar?: boolean;
|
|
194
|
+
/** Whether toolbar action icons are displayed. */
|
|
195
|
+
showToolbarIcons?: boolean;
|
|
196
|
+
/** Whether toolbar action text labels are displayed. */
|
|
197
|
+
showToolbarLabels?: boolean;
|
|
198
|
+
/** Whether inline SSML decorations are displayed. The toolbar switch can change this at runtime. */
|
|
199
|
+
showDecorations?: boolean;
|
|
200
|
+
/** Whether SSML CodeLens quick controls are displayed. */
|
|
201
|
+
enableCodeLens?: boolean;
|
|
202
|
+
/** Controls which editor action buttons are displayed. Unspecified buttons are shown. */
|
|
203
|
+
buttonVisibility?: SsmlEditorButtonVisibility;
|
|
204
|
+
/** Monaco editor settings. */
|
|
205
|
+
editorOptions?: SsmlEditorOptions;
|
|
206
|
+
/** Alias for editorOptions. */
|
|
207
|
+
settings?: SsmlEditorOptions;
|
|
208
|
+
/** Fallback UI displayed while Monaco is loading. */
|
|
209
|
+
loadingFallback?: ReactNode;
|
|
210
|
+
/** Height of the Monaco editor. */
|
|
211
|
+
height?: string | number;
|
|
212
|
+
/** Minimum height of the Monaco editor container. */
|
|
213
|
+
minHeight?: string | number;
|
|
214
|
+
/** Whether the Monaco editor is read-only. */
|
|
215
|
+
readOnly?: boolean;
|
|
216
|
+
/** Monaco theme mode. */
|
|
217
|
+
theme?: SsmlEditorTheme;
|
|
218
|
+
/** Monaco editor font size. */
|
|
219
|
+
fontSize?: number;
|
|
220
|
+
/** Monaco editor word wrapping mode. */
|
|
221
|
+
wordWrap?: SsmlEditorWordWrap;
|
|
222
|
+
/** Monaco editor line number mode. */
|
|
223
|
+
lineNumbers?: SsmlEditorLineNumbers;
|
|
224
|
+
/** Whether the Monaco minimap is displayed. */
|
|
225
|
+
minimap?: boolean;
|
|
226
|
+
/** Whether Monaco automatically lays out when its container changes size. */
|
|
227
|
+
automaticLayout?: boolean;
|
|
228
|
+
/** Reorders all toolbar controls. Unlisted controls follow. */
|
|
229
|
+
toolbarOrder?: readonly SsmlEditorButton[];
|
|
230
|
+
/** Adds vertical separators between configured toolbar groups. */
|
|
231
|
+
toolbarGroups?: readonly SsmlEditorToolbarGroup[];
|
|
232
|
+
/** Reorders built-in and custom insertion menus. Unlisted insertions follow. */
|
|
233
|
+
insertionOrder?: readonly string[];
|
|
234
|
+
/** Visually groups insertion menus when toolbarGroups is not supplied. */
|
|
235
|
+
insertionGroups?: readonly SsmlEditorInsertionGroup[];
|
|
236
|
+
/** Replaces built-in insertion definitions with custom definitions by ID. */
|
|
237
|
+
customInsertions?: SsmlEditorCustomInsertionCollection;
|
|
238
|
+
/** Adds insertion definitions without replacing built-in definitions. */
|
|
239
|
+
additionalInsertions?: SsmlEditorCustomInsertionCollection;
|
|
240
|
+
/** Candidate style values shown by the built-in emotion insertion. */
|
|
241
|
+
emotionStyles?: readonly string[];
|
|
242
|
+
/** Class name applied to the editor container. */
|
|
243
|
+
className?: string;
|
|
244
|
+
/** Inline styles applied to the editor container. */
|
|
245
|
+
style?: CSSProperties;
|
|
246
|
+
/** Class name applied to the toolbar. */
|
|
247
|
+
toolbarClassName?: string;
|
|
248
|
+
/** Inline styles applied to the toolbar. */
|
|
249
|
+
toolbarStyle?: CSSProperties;
|
|
250
|
+
/** Class name applied to the editor display area. */
|
|
251
|
+
displayClassName?: string;
|
|
252
|
+
/** Inline styles applied to the editor display area. */
|
|
253
|
+
displayStyle?: CSSProperties;
|
|
254
|
+
}
|
|
255
|
+
interface SelectionInfo {
|
|
256
|
+
selectedText: string;
|
|
257
|
+
characterCount: number;
|
|
258
|
+
hasSelection: boolean;
|
|
259
|
+
}
|
|
260
|
+
interface SsmlEditorRef {
|
|
261
|
+
getSelectedSsml(): string | null;
|
|
262
|
+
getCurrentLineSsml(): string | null;
|
|
263
|
+
getFullSsml(): string;
|
|
264
|
+
}
|
|
265
|
+
declare const SsmlEditor: react.ForwardRefExoticComponent<SsmlEditorProps & react.RefAttributes<SsmlEditorRef>>;
|
|
266
|
+
|
|
267
|
+
type MonacoEditor = Parameters<OnMount>[0];
|
|
268
|
+
|
|
269
|
+
interface SsmlTagRange {
|
|
270
|
+
start: number;
|
|
271
|
+
end: number;
|
|
272
|
+
}
|
|
273
|
+
declare function updateTagAttribute(text: string, tagRange: SsmlTagRange, attributeName: string, newValue: string): string;
|
|
274
|
+
|
|
275
|
+
type SsmlCodeLensAction = {
|
|
276
|
+
type: "attribute";
|
|
277
|
+
insertionId: "rate" | "pitch" | "break";
|
|
278
|
+
attributeName: "rate" | "pitch" | "time";
|
|
279
|
+
tagRange: SsmlTagRange;
|
|
280
|
+
} | {
|
|
281
|
+
type: "unwrap" | "delete";
|
|
282
|
+
tagRange: SsmlTagRange;
|
|
283
|
+
elementRange: SsmlTagRange;
|
|
284
|
+
};
|
|
285
|
+
type SsmlCodeLensCallback = (action: SsmlCodeLensAction) => void;
|
|
286
|
+
declare function registerSsmlCodeLens(monaco: Monaco, editor: MonacoEditor, onOpenPopover: SsmlCodeLensCallback): ReturnType<Monaco["languages"]["registerCodeLensProvider"]>;
|
|
287
|
+
|
|
288
|
+
export { EDITOR_COPY, type EditorCopy, INLINE_BADGE_COPY, type InlineBadgeCopy, SSML_HOVER_COPY, SSML_INSERTIONS, type SelectionInfo, type SsmlCodeLensAction, type SsmlCodeLensCallback, 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, type SsmlTagRange, createSsmlEditorInsertionDefinition, registerSsmlCodeLens, updateTagAttribute };
|