0.7.0 • Published 10 months ago
@ssml-utilities/editor-react v0.7.0
SSML Editor
SSML Editor は、Speech Synthesis Markup Language (SSML)を編集するための React コンポーネントです。シンタックスハイライトと編集機能を提供します。
インストール
npm install @ssml-utilities/editor-react使用方法
import { SSMLEditor } from "@ssml-utilities/editor-react";
function App() {
const [ssml, setSSML] = useState("<speak>Hello, world!</speak>");
return (
<SSMLEditor
initialValue={ssml}
onChange={(value) => setSSML(value)}
width="800px"
height="400px"
/>
);
}プロパティ
| プロパティ名 | 型 | 必須 | デフォルト値 | 説明 |
|---|---|---|---|---|
| initialValue | string | いいえ | '' | エディタの初期値として表示される SSML テキスト |
| onChange | (value: string) => void | いいえ | - | SSML テキストが変更された時に呼び出されるコールバック関数 |
| width | string | いいえ | '600px' | エディタの幅 |
| height | string | いいえ | '300px' | エディタの高さ |
| onWrapTag | (wrapFn: (tagName: string, attributes?: TagAttributes) => void) => void | いいえ | - | タグでテキストを囲む関数を受け取るコールバック |
| wrapTagShortCuts | { tagName: string; shortcut: (e: KeyboardEvent) => boolean; attributes?: TagAttributes }[] | いいえ | - | キーボードショートカットの設定 |
機能
- リアルタイムのシンタックスハイライト
- SSML タグの自動補完
- エラー表示
- カスタマイズ可能なスタイリング
- キーボードショートカット
- タグ属性のサポート
例
import { SSMLEditor } from "@ssml-utilities/editor-react";
function App() {
return (
<SSMLEditor
initialValue={`<speak>
<prosody rate="slow" pitch="+2st">
こんにちは、世界!
</prosody>
</speak>`}
width="100%"
height="500px"
/>
);
}キーボードショートカットの例
<SSMLEditor
wrapTagShortCuts={[
{
tagName: "speak",
shortcut: (e) => e.key === "s" && e.shiftKey && (e.ctrlKey || e.metaKey),
},
{
tagName: "break",
shortcut: (e) => e.key === "b" && e.shiftKey && (e.ctrlKey || e.metaKey),
attributes: { time: "200ms" },
},
{
tagName: "prosody",
shortcut: (e) => e.key === "p" && e.shiftKey && (e.ctrlKey || e.metaKey),
attributes: { rate: "120%", pitch: "+2st" },
}
]}
/>タグ属性の使用例
function App() {
const wrapWithTagRef = useRef<(tagName: string, attributes?: TagAttributes) => void>();
const handleWrapButtonClick = () => {
wrapWithTagRef.current?.("prosody", {
rate: "120%",
pitch: "+2st"
});
};
return (
<>
<button onClick={handleWrapButtonClick}>Wrap with prosody</button>
<SSMLEditor
onWrapTag={(wrapFn) => {
wrapWithTagRef.current = wrapFn;
}}
/>
</>
);
}ライセンス
MIT ライセンスの下で公開されています。詳細はLICENSEファイルを参照してください。
0.5.10
12 months ago
0.5.11
12 months ago
0.5.8
12 months ago
0.5.7
12 months ago
0.5.9
12 months ago
0.5.14
11 months ago
0.5.15
11 months ago
0.3.0
1 year ago
0.2.0
1 year ago
0.5.4
12 months ago
0.5.3
12 months ago
0.5.6
12 months ago
0.5.5
12 months ago
0.5.0
1 year ago
0.4.0
1 year ago
0.3.1
1 year ago
0.7.0
10 months ago
0.6.1
10 months ago
0.5.2
12 months ago
0.6.0
10 months ago
0.5.1
12 months ago
0.1.2
1 year ago
0.1.0
1 year ago