@sutrata/editor 0.1.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/LICENSE +674 -0
- package/dist/ai/OnboardingDialog.d.ts +6 -0
- package/dist/ai/OnboardingDialog.js +115 -0
- package/dist/ai/VoiceConfirmDialog.d.ts +9 -0
- package/dist/ai/VoiceConfirmDialog.js +37 -0
- package/dist/ai/VoiceToolbar.d.ts +2 -0
- package/dist/ai/VoiceToolbar.js +177 -0
- package/dist/ai/ai-client.d.ts +71 -0
- package/dist/ai/ai-client.js +494 -0
- package/dist/ai/commands.d.ts +12 -0
- package/dist/ai/commands.js +140 -0
- package/dist/ai/generated-providers.json +3696 -0
- package/dist/ai/prompts.d.ts +25 -0
- package/dist/ai/prompts.js +59 -0
- package/dist/ai/voice-service.d.ts +15 -0
- package/dist/ai/voice-service.js +81 -0
- package/dist/autocomplete/AutocompletePlugin.d.ts +2 -0
- package/dist/autocomplete/AutocompletePlugin.js +19 -0
- package/dist/autocomplete/suggestions.d.ts +25 -0
- package/dist/autocomplete/suggestions.js +126 -0
- package/dist/context/DocumentContext.d.ts +68 -0
- package/dist/context/DocumentContext.js +605 -0
- package/dist/desktop-api.d.ts +40 -0
- package/dist/editor/EditorView.d.ts +2 -0
- package/dist/editor/EditorView.js +78 -0
- package/dist/editor/SelectionMenu.d.ts +2 -0
- package/dist/editor/SelectionMenu.js +102 -0
- package/dist/editor/attr-pencil-plugin.d.ts +17 -0
- package/dist/editor/attr-pencil-plugin.js +158 -0
- package/dist/editor/character-decoration-plugin.d.ts +26 -0
- package/dist/editor/character-decoration-plugin.js +77 -0
- package/dist/editor/character-view.d.ts +35 -0
- package/dist/editor/character-view.js +112 -0
- package/dist/editor/editor-bus.d.ts +14 -0
- package/dist/editor/editor-bus.js +39 -0
- package/dist/editor/find-highlight-plugin.d.ts +7 -0
- package/dist/editor/find-highlight-plugin.js +57 -0
- package/dist/editor/frontmatter-field-view.d.ts +10 -0
- package/dist/editor/frontmatter-field-view.js +48 -0
- package/dist/editor/frontmatter-field.d.ts +21 -0
- package/dist/editor/frontmatter-field.js +116 -0
- package/dist/editor/grapheme-cursor.d.ts +10 -0
- package/dist/editor/grapheme-cursor.js +104 -0
- package/dist/editor/ime-plugin.d.ts +18 -0
- package/dist/editor/ime-plugin.js +71 -0
- package/dist/editor/insert-helper.d.ts +1 -0
- package/dist/editor/insert-helper.js +42 -0
- package/dist/editor/keymap.d.ts +3 -0
- package/dist/editor/keymap.js +131 -0
- package/dist/editor/language-class-plugin.d.ts +7 -0
- package/dist/editor/language-class-plugin.js +75 -0
- package/dist/editor/plugins.d.ts +1 -0
- package/dist/editor/plugins.js +25 -0
- package/dist/editor/prosemirror-to-sutra.d.ts +2 -0
- package/dist/editor/prosemirror-to-sutra.js +208 -0
- package/dist/editor/scene-heading-view.d.ts +27 -0
- package/dist/editor/scene-heading-view.js +136 -0
- package/dist/editor/schema.d.ts +3 -0
- package/dist/editor/schema.js +135 -0
- package/dist/editor/sutra-to-prosemirror.d.ts +3 -0
- package/dist/editor/sutra-to-prosemirror.js +154 -0
- package/dist/editor/transliterate-input.d.ts +10 -0
- package/dist/editor/transliterate-input.js +88 -0
- package/dist/extensions/storage-adapter.d.ts +59 -0
- package/dist/extensions/storage-adapter.js +9 -0
- package/dist/extensions/types.d.ts +73 -0
- package/dist/extensions/types.js +12 -0
- package/dist/file/docx-exporter.d.ts +8 -0
- package/dist/file/docx-exporter.js +494 -0
- package/dist/file/docx-importer.d.ts +10 -0
- package/dist/file/docx-importer.js +283 -0
- package/dist/file/print-paginator.d.ts +29 -0
- package/dist/file/print-paginator.js +289 -0
- package/dist/file/templates.d.ts +2 -0
- package/dist/file/templates.js +66 -0
- package/dist/file/workflow-reports.d.ts +34 -0
- package/dist/file/workflow-reports.js +719 -0
- package/dist/findreplace/FindReplace.d.ts +2 -0
- package/dist/findreplace/FindReplace.js +164 -0
- package/dist/findreplace/find-engine.d.ts +29 -0
- package/dist/findreplace/find-engine.js +69 -0
- package/dist/findreplace/scroll-to-match.d.ts +29 -0
- package/dist/findreplace/scroll-to-match.js +74 -0
- package/dist/fonts/tofu-detect.d.ts +1 -0
- package/dist/fonts/tofu-detect.js +48 -0
- package/dist/i18n/LanguageContext.d.ts +10 -0
- package/dist/i18n/LanguageContext.js +174 -0
- package/dist/i18n/language-detect.d.ts +1 -0
- package/dist/i18n/language-detect.js +58 -0
- package/dist/i18n/useTranslation.d.ts +11 -0
- package/dist/i18n/useTranslation.js +60 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +5 -0
- package/dist/locales/bn.json +143 -0
- package/dist/locales/en.json +143 -0
- package/dist/locales/gu.json +143 -0
- package/dist/locales/hi.json +143 -0
- package/dist/locales/kn.json +143 -0
- package/dist/locales/ml.json +143 -0
- package/dist/locales/mr.json +143 -0
- package/dist/locales/or.json +143 -0
- package/dist/locales/pa.json +143 -0
- package/dist/locales/si.json +143 -0
- package/dist/locales/ta.json +143 -0
- package/dist/locales/te.json +143 -0
- package/dist/navigator/SceneNavigator.d.ts +2 -0
- package/dist/navigator/SceneNavigator.js +612 -0
- package/dist/navigator/StatisticsDialog.d.ts +6 -0
- package/dist/navigator/StatisticsDialog.js +146 -0
- package/dist/navigator/scene-list.d.ts +16 -0
- package/dist/navigator/scene-list.js +70 -0
- package/dist/settings/SettingsDialog.d.ts +6 -0
- package/dist/settings/SettingsDialog.js +147 -0
- package/dist/shell/AppBar.d.ts +2 -0
- package/dist/shell/AppBar.js +34 -0
- package/dist/shell/AppShell.d.ts +2 -0
- package/dist/shell/AppShell.js +30 -0
- package/dist/shell/ConfirmDialog.d.ts +16 -0
- package/dist/shell/ConfirmDialog.js +23 -0
- package/dist/shell/ElementToolbar.d.ts +2 -0
- package/dist/shell/ElementToolbar.js +30 -0
- package/dist/shell/LanguageStatus.d.ts +2 -0
- package/dist/shell/LanguageStatus.js +65 -0
- package/dist/shell/StatusBar.d.ts +2 -0
- package/dist/shell/StatusBar.js +54 -0
- package/dist/shell/SutrataLogo.d.ts +8 -0
- package/dist/shell/SutrataLogo.js +7 -0
- package/dist/shell/Toast.d.ts +12 -0
- package/dist/shell/Toast.js +21 -0
- package/dist/shell/ToolbarButton.d.ts +11 -0
- package/dist/shell/ToolbarButton.js +4 -0
- package/dist/shell/VersionHistory.d.ts +12 -0
- package/dist/shell/VersionHistory.js +89 -0
- package/dist/shell/Watermark.d.ts +3 -0
- package/dist/shell/Watermark.js +10 -0
- package/dist/shell/fonts/fonts.css +1133 -0
- package/dist/shell/icons.d.ts +45 -0
- package/dist/shell/icons.js +51 -0
- package/dist/shell/toolbar-actions.d.ts +6 -0
- package/dist/shell/toolbar-actions.js +58 -0
- package/dist/source/SourceView.d.ts +1 -0
- package/dist/source/SourceView.js +106 -0
- package/dist/source/find-highlight-source.d.ts +14 -0
- package/dist/source/find-highlight-source.js +47 -0
- package/dist/source/sutra-lang.d.ts +2 -0
- package/dist/source/sutra-lang.js +97 -0
- package/dist/spellcheck/dictionaries.d.ts +9 -0
- package/dist/spellcheck/dictionaries.js +16 -0
- package/dist/spellcheck/hunspell.d.ts +23 -0
- package/dist/spellcheck/hunspell.js +94 -0
- package/dist/spellcheck/spellcheck-plugin.d.ts +18 -0
- package/dist/spellcheck/spellcheck-plugin.js +75 -0
- package/dist/styles/StyleDialog.d.ts +6 -0
- package/dist/styles/StyleDialog.js +63 -0
- package/dist/styles/builtin-styles.d.ts +43 -0
- package/dist/styles/builtin-styles.js +131 -0
- package/dist/styles/css-adapter.d.ts +32 -0
- package/dist/styles/css-adapter.js +71 -0
- package/dist/styles/docx-adapter.d.ts +7 -0
- package/dist/styles/docx-adapter.js +84 -0
- package/dist/styles/embed-fonts.d.ts +20 -0
- package/dist/styles/embed-fonts.js +81 -0
- package/dist/styles/pagination.d.ts +19 -0
- package/dist/styles/pagination.js +22 -0
- package/dist/styles/print-adapter.d.ts +6 -0
- package/dist/styles/print-adapter.js +288 -0
- package/dist/styles/registry.d.ts +6 -0
- package/dist/styles/registry.js +14 -0
- package/dist/styles/screenplay.css +3006 -0
- package/dist/styles/script-ranges.d.ts +6 -0
- package/dist/styles/script-ranges.js +17 -0
- package/dist/styles/types.d.ts +93 -0
- package/dist/styles/types.js +18 -0
- package/dist/styles/validate.d.ts +12 -0
- package/dist/styles/validate.js +105 -0
- package/dist/templates/templates.d.ts +10 -0
- package/dist/templates/templates.js +181 -0
- package/dist/titlepage/ExportDialog.d.ts +1 -0
- package/dist/titlepage/ExportDialog.js +152 -0
- package/dist/titlepage/TitlePageDialog.d.ts +6 -0
- package/dist/titlepage/TitlePageDialog.js +96 -0
- package/dist/titlepage/frontmatter-form.d.ts +56 -0
- package/dist/titlepage/frontmatter-form.js +245 -0
- package/dist/titlepage/languages.d.ts +10 -0
- package/dist/titlepage/languages.js +31 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.js +1 -0
- package/package.json +47 -0
- package/scripts/copy-assets.mjs +16 -0
- package/scripts/generate-providers.mjs +127 -0
- package/src/ai/OnboardingDialog.tsx +390 -0
- package/src/ai/VoiceConfirmDialog.tsx +137 -0
- package/src/ai/VoiceToolbar.tsx +321 -0
- package/src/ai/ai-client.ts +596 -0
- package/src/ai/commands.ts +164 -0
- package/src/ai/generated-providers.json +3696 -0
- package/src/ai/prompts.ts +62 -0
- package/src/ai/voice-service.ts +96 -0
- package/src/autocomplete/AutocompletePlugin.ts +21 -0
- package/src/autocomplete/suggestions.ts +147 -0
- package/src/context/DocumentContext.tsx +648 -0
- package/src/desktop-api.d.ts +40 -0
- package/src/editor/EditorView.tsx +82 -0
- package/src/editor/SelectionMenu.tsx +152 -0
- package/src/editor/attr-pencil-plugin.ts +172 -0
- package/src/editor/character-decoration-plugin.ts +104 -0
- package/src/editor/editor-bus.ts +51 -0
- package/src/editor/find-highlight-plugin.ts +68 -0
- package/src/editor/frontmatter-field-view.ts +52 -0
- package/src/editor/frontmatter-field.ts +115 -0
- package/src/editor/grapheme-cursor.ts +99 -0
- package/src/editor/ime-plugin.ts +85 -0
- package/src/editor/insert-helper.ts +43 -0
- package/src/editor/keymap.ts +124 -0
- package/src/editor/language-class-plugin.ts +91 -0
- package/src/editor/plugins.ts +26 -0
- package/src/editor/prosemirror-to-sutra.ts +192 -0
- package/src/editor/scene-heading-view.ts +147 -0
- package/src/editor/schema.ts +156 -0
- package/src/editor/sutra-to-prosemirror.ts +156 -0
- package/src/extensions/storage-adapter.ts +65 -0
- package/src/extensions/types.ts +60 -0
- package/src/file/docx-exporter.ts +585 -0
- package/src/file/docx-importer.ts +313 -0
- package/src/file/print-paginator.ts +301 -0
- package/src/file/templates.ts +73 -0
- package/src/file/workflow-reports.ts +820 -0
- package/src/findreplace/FindReplace.tsx +242 -0
- package/src/findreplace/find-engine.ts +97 -0
- package/src/findreplace/scroll-to-match.ts +89 -0
- package/src/fonts/tofu-detect.ts +53 -0
- package/src/i18n/LanguageContext.tsx +207 -0
- package/src/i18n/language-detect.ts +73 -0
- package/src/i18n/useTranslation.tsx +74 -0
- package/src/index.ts +27 -0
- package/src/locales/bn.json +143 -0
- package/src/locales/en.json +143 -0
- package/src/locales/gu.json +143 -0
- package/src/locales/hi.json +143 -0
- package/src/locales/kn.json +143 -0
- package/src/locales/ml.json +143 -0
- package/src/locales/mr.json +143 -0
- package/src/locales/or.json +143 -0
- package/src/locales/pa.json +143 -0
- package/src/locales/si.json +143 -0
- package/src/locales/ta.json +143 -0
- package/src/locales/te.json +143 -0
- package/src/navigator/SceneNavigator.tsx +844 -0
- package/src/navigator/StatisticsDialog.tsx +249 -0
- package/src/navigator/scene-list.ts +84 -0
- package/src/settings/SettingsDialog.tsx +303 -0
- package/src/shell/AppBar.tsx +354 -0
- package/src/shell/AppShell.tsx +71 -0
- package/src/shell/ConfirmDialog.tsx +71 -0
- package/src/shell/ElementToolbar.tsx +175 -0
- package/src/shell/LanguageStatus.tsx +101 -0
- package/src/shell/StatusBar.tsx +135 -0
- package/src/shell/SutrataLogo.tsx +89 -0
- package/src/shell/Toast.tsx +46 -0
- package/src/shell/ToolbarButton.tsx +30 -0
- package/src/shell/VersionHistory.tsx +212 -0
- package/src/shell/Watermark.tsx +9 -0
- package/src/shell/fonts/fonts.css +1133 -0
- package/src/shell/icons.tsx +335 -0
- package/src/shell/toolbar-actions.ts +59 -0
- package/src/source/SourceView.tsx +111 -0
- package/src/source/find-highlight-source.ts +57 -0
- package/src/source/sutra-lang.ts +121 -0
- package/src/spellcheck/dictionaries.ts +21 -0
- package/src/spellcheck/hunspell.ts +110 -0
- package/src/spellcheck/spellcheck-plugin.ts +83 -0
- package/src/styles/StyleDialog.tsx +148 -0
- package/src/styles/builtin-styles.ts +139 -0
- package/src/styles/css-adapter.ts +76 -0
- package/src/styles/docx-adapter.ts +109 -0
- package/src/styles/embed-fonts.ts +81 -0
- package/src/styles/pagination.ts +27 -0
- package/src/styles/print-adapter.ts +288 -0
- package/src/styles/registry.ts +20 -0
- package/src/styles/screenplay.css +3006 -0
- package/src/styles/script-ranges.ts +17 -0
- package/src/styles/types.ts +104 -0
- package/src/styles/validate.ts +114 -0
- package/src/templates/templates.ts +194 -0
- package/src/titlepage/ExportDialog.tsx +494 -0
- package/src/titlepage/TitlePageDialog.tsx +312 -0
- package/src/titlepage/frontmatter-form.ts +280 -0
- package/src/titlepage/languages.ts +37 -0
- package/src/types.ts +7 -0
- package/tests/AppBar.test.tsx +35 -0
- package/tests/AppShell.test.tsx +22 -0
- package/tests/ElementToolbar.test.tsx +36 -0
- package/tests/LanguageStatus.test.tsx +129 -0
- package/tests/SelectionMenu.test.tsx +71 -0
- package/tests/ToolbarButton.test.tsx +24 -0
- package/tests/ai-onboarding.test.ts +102 -0
- package/tests/ai-status.test.tsx +72 -0
- package/tests/ai-structured.test.ts +94 -0
- package/tests/autocomplete/AutocompletePlugin.test.ts +20 -0
- package/tests/autocomplete/suggestions.test.ts +106 -0
- package/tests/document-context.test.tsx +565 -0
- package/tests/docx-importer.test.ts +160 -0
- package/tests/editor/character-decoration-plugin.test.ts +101 -0
- package/tests/editor/character-extension.test.ts +44 -0
- package/tests/editor/grapheme-cursor.test.ts +118 -0
- package/tests/editor/ime-plugin.test.ts +72 -0
- package/tests/editor/inline-note-bridge.test.ts +32 -0
- package/tests/editor/language-class-plugin.test.ts +265 -0
- package/tests/editor/title-page.test.ts +124 -0
- package/tests/embed-fonts.test.ts +17 -0
- package/tests/exporters.test.ts +365 -0
- package/tests/findreplace/FindReplace.test.tsx +391 -0
- package/tests/findreplace/find-engine.test.ts +86 -0
- package/tests/findreplace/scroll-to-match.test.ts +50 -0
- package/tests/fonts/tofu-detect.test.ts +122 -0
- package/tests/i18n/LanguageContext.test.tsx +146 -0
- package/tests/i18n/language-detect.test.ts +54 -0
- package/tests/i18n/locale-parity.test.ts +25 -0
- package/tests/i18n/useTranslation.test.tsx +45 -0
- package/tests/keymap.test.ts +18 -0
- package/tests/navigator/SceneNavigator.test.tsx +177 -0
- package/tests/navigator/StatisticsDialog.test.tsx +63 -0
- package/tests/navigator/scene-list.test.ts +71 -0
- package/tests/print-paginator.test.ts +82 -0
- package/tests/shell/VersionHistory.test.tsx +129 -0
- package/tests/spellcheck/hunspell.test.ts +82 -0
- package/tests/spellcheck/spellcheck-plugin.test.ts +56 -0
- package/tests/styles.test.ts +315 -0
- package/tests/templates/templates.test.ts +83 -0
- package/tests/titlepage/TitlePageDialog.test.tsx +90 -0
- package/tests/titlepage/apply-title-page.test.ts +61 -0
- package/tests/titlepage/frontmatter-form.test.ts +115 -0
- package/tests/toolbar-actions.test.ts +93 -0
- package/tests/voice-commands.test.ts +58 -0
- package/tsconfig.json +17 -0
- package/vitest.config.ts +11 -0
- package/vitest.setup.ts +65 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
export type CommandType =
|
|
2
|
+
| 'scene'
|
|
3
|
+
| 'character'
|
|
4
|
+
| 'dialogue'
|
|
5
|
+
| 'parenthetical'
|
|
6
|
+
| 'transition'
|
|
7
|
+
| 'lyrics'
|
|
8
|
+
| 'action'
|
|
9
|
+
| 'literal'
|
|
10
|
+
| 'plain';
|
|
11
|
+
|
|
12
|
+
export interface CommandDefinition {
|
|
13
|
+
type: CommandType;
|
|
14
|
+
keywords: string[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const LOCALIZED_COMMANDS: Record<string, CommandDefinition[]> = {
|
|
18
|
+
en: [
|
|
19
|
+
{ type: 'literal', keywords: ['literal', 'plain', 'bypass'] },
|
|
20
|
+
{ type: 'scene', keywords: ['new scene', 'scene heading', 'scene'] },
|
|
21
|
+
{ type: 'character', keywords: ['character name', 'character', 'char'] },
|
|
22
|
+
{ type: 'dialogue', keywords: ['dialogue', 'dialog', 'says'] },
|
|
23
|
+
{ type: 'parenthetical', keywords: ['parenthetical', 'bracket', 'brackets'] },
|
|
24
|
+
{ type: 'transition', keywords: ['transition', 'fade out', 'fade in', 'cut to'] },
|
|
25
|
+
{ type: 'lyrics', keywords: ['lyrics', 'sing lyrics', 'song'] },
|
|
26
|
+
{ type: 'action', keywords: ['action description', 'action'] },
|
|
27
|
+
],
|
|
28
|
+
hi: [
|
|
29
|
+
{ type: 'literal', keywords: ['शब्दशः', 'वास्तविक', 'प्लेन'] },
|
|
30
|
+
{ type: 'scene', keywords: ['नया दृश्य', 'दृश्य'] },
|
|
31
|
+
{ type: 'character', keywords: ['पात्र नाम', 'पात्र', 'चरित्र'] },
|
|
32
|
+
{ type: 'dialogue', keywords: ['संवाद', 'बोलता है', 'बोलती है'] },
|
|
33
|
+
{ type: 'parenthetical', keywords: ['कोष्ठक', 'ब्रैकेट'] },
|
|
34
|
+
{ type: 'transition', keywords: ['बदलाव', 'कट टू'] },
|
|
35
|
+
{ type: 'lyrics', keywords: ['गीत', 'गाना'] },
|
|
36
|
+
{ type: 'action', keywords: ['विवरण', 'एक्शन'] },
|
|
37
|
+
],
|
|
38
|
+
ta: [
|
|
39
|
+
{ type: 'literal', keywords: ['உண்மையான', 'வார்த்தை', 'நேரடி'] },
|
|
40
|
+
{ type: 'scene', keywords: ['புதிய காட்சி', 'காட்சி'] },
|
|
41
|
+
{ type: 'character', keywords: ['கதாபாத்திரம் பெயர்', 'கதாபாத்திரம்'] },
|
|
42
|
+
{ type: 'dialogue', keywords: ['வசனம்', 'பேசுகிறார்'] },
|
|
43
|
+
{ type: 'parenthetical', keywords: ['அடைப்புக்குறி', 'பிராக்கெட்'] },
|
|
44
|
+
{ type: 'transition', keywords: ['மாற்றம்', 'கட் டூ'] },
|
|
45
|
+
{ type: 'lyrics', keywords: ['பாடல்', 'பாட்டு'] },
|
|
46
|
+
{ type: 'action', keywords: ['செயல்', 'விளக்கம்'] },
|
|
47
|
+
],
|
|
48
|
+
te: [
|
|
49
|
+
{ type: 'literal', keywords: ['యథార్థం', 'సాధారణ'] },
|
|
50
|
+
{ type: 'scene', keywords: ['కొత్త సన్నివేశం', 'సన్నివేశం'] },
|
|
51
|
+
{ type: 'character', keywords: ['పాత్ర పేరు', 'పాత్ర'] },
|
|
52
|
+
{ type: 'dialogue', keywords: ['సంభాషణ', 'మాట్లాడు'] },
|
|
53
|
+
{ type: 'parenthetical', keywords: ['బ్రాకెట్', 'వరణము'] },
|
|
54
|
+
{ type: 'transition', keywords: ['మార్పు', 'కట్ టు'] },
|
|
55
|
+
{ type: 'lyrics', keywords: ['పాట', 'గీతం'] },
|
|
56
|
+
{ type: 'action', keywords: ['చర్య', 'వివరణ'] },
|
|
57
|
+
],
|
|
58
|
+
ml: [
|
|
59
|
+
{ type: 'literal', keywords: ['യഥാർത്ഥ', 'സാധാരണ'] },
|
|
60
|
+
{ type: 'scene', keywords: ['പുതിയ രംഗം', 'രംഗം'] },
|
|
61
|
+
{ type: 'character', keywords: ['കഥാപാത്രം പേര്', 'കഥാപാത്രം'] },
|
|
62
|
+
{ type: 'dialogue', keywords: ['സംഭാഷണം', 'പറയുന്നു'] },
|
|
63
|
+
{ type: 'parenthetical', keywords: ['ബ്രാക്കറ്റ്'] },
|
|
64
|
+
{ type: 'transition', keywords: ['മാറ്റം', 'കട്ട് ടു'] },
|
|
65
|
+
{ type: 'lyrics', keywords: ['പാട്ട്', 'ഗാനം'] },
|
|
66
|
+
{ type: 'action', keywords: ['പ്രവർത്തി', 'വിവരണം'] },
|
|
67
|
+
],
|
|
68
|
+
kn: [
|
|
69
|
+
{ type: 'literal', keywords: ['ನಿಜವಾದ', 'ಸಾಮಾನ್ಯ'] },
|
|
70
|
+
{ type: 'scene', keywords: ['ಹೊಸ ದೃಶ್ಯ', 'ದೃಶ್ಯ'] },
|
|
71
|
+
{ type: 'character', keywords: ['ಪಾತ್ರ ಹೆಸರು', 'ಪಾತ್ರ'] },
|
|
72
|
+
{ type: 'dialogue', keywords: ['ಸಂಭಾಷಣೆ', 'ಹೇಳುತ್ತದೆ'] },
|
|
73
|
+
{ type: 'parenthetical', keywords: ['ವರಣಚಿಹ್ನೆ', 'ಬ್ರಾಕೆಟ್'] },
|
|
74
|
+
{ type: 'transition', keywords: ['ಬದಲಾವಣೆ', 'ಕಟ್ ಟು'] },
|
|
75
|
+
{ type: 'lyrics', keywords: ['ಹಾಡು', 'ಗೀತೆ'] },
|
|
76
|
+
{ type: 'action', keywords: ['ಕ್ರಿಯೆ', 'ವಿವರಣೆ'] },
|
|
77
|
+
],
|
|
78
|
+
bn: [
|
|
79
|
+
{ type: 'literal', keywords: ['আক্ষরিক', 'সাধারণ'] },
|
|
80
|
+
{ type: 'scene', keywords: ['নতুন দৃশ্য', 'দৃশ্য'] },
|
|
81
|
+
{ type: 'character', keywords: ['চরিত্রের নাম', 'চরিত্র'] },
|
|
82
|
+
{ type: 'dialogue', keywords: ['সংলাপ', 'বলে'] },
|
|
83
|
+
{ type: 'parenthetical', keywords: ['বন্ধনী', 'ব্র্যাকেট'] },
|
|
84
|
+
{ type: 'transition', keywords: ['পরিবর্তন', 'কাট টু'] },
|
|
85
|
+
{ type: 'lyrics', keywords: ['গান', 'গীতি'] },
|
|
86
|
+
{ type: 'action', keywords: ['ক্রিয়া', 'বর্ণনা'] },
|
|
87
|
+
],
|
|
88
|
+
gu: [
|
|
89
|
+
{ type: 'literal', keywords: ['શાબ્દિક', 'સામાન્ય'] },
|
|
90
|
+
{ type: 'scene', keywords: ['નવું દ્રશ્ય', 'દ્રશ્ય'] },
|
|
91
|
+
{ type: 'character', keywords: ['પાત્રનું નામ', 'પાત્ર'] },
|
|
92
|
+
{ type: 'dialogue', keywords: ['સંવાદ', 'બોલે છે'] },
|
|
93
|
+
{ type: 'parenthetical', keywords: ['કૌંસ', 'બ્રેકેટ'] },
|
|
94
|
+
{ type: 'transition', keywords: ['પરિવર્તન', 'કટ ટુ'] },
|
|
95
|
+
{ type: 'lyrics', keywords: ['ગીત', 'ગાણું'] },
|
|
96
|
+
{ type: 'action', keywords: ['ક્રિયા', 'વર્ણન'] },
|
|
97
|
+
],
|
|
98
|
+
mr: [
|
|
99
|
+
{ type: 'literal', keywords: ['शाब्दिक', 'साधे'] },
|
|
100
|
+
{ type: 'scene', keywords: ['नवीन दृश्य', 'दृश्य'] },
|
|
101
|
+
{ type: 'character', keywords: ['पात्राचे नाव', 'पात्र'] },
|
|
102
|
+
{ type: 'dialogue', keywords: ['संवाद', 'बोलतो', 'बोलते'] },
|
|
103
|
+
{ type: 'parenthetical', keywords: ['कंसात', 'ब्रॅकेट'] },
|
|
104
|
+
{ type: 'transition', keywords: ['बदल', 'कट टू'] },
|
|
105
|
+
{ type: 'lyrics', keywords: ['गाणे', 'गीत'] },
|
|
106
|
+
{ type: 'action', keywords: ['कृती', 'वर्णन'] },
|
|
107
|
+
],
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export interface ParsedVoiceResult {
|
|
111
|
+
type: CommandType | 'action';
|
|
112
|
+
text: string;
|
|
113
|
+
isLiteral: boolean;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function parseVoiceCommand(transcript: string, langCode: string): ParsedVoiceResult {
|
|
117
|
+
const normText = transcript.trim();
|
|
118
|
+
// Get language mapping, default to English if not found
|
|
119
|
+
const baseLang = langCode.split('-')[0] || 'en';
|
|
120
|
+
const defs = LOCALIZED_COMMANDS[baseLang] || LOCALIZED_COMMANDS.en!;
|
|
121
|
+
|
|
122
|
+
// 1. Check for literal bypass sequence
|
|
123
|
+
const literalDef = defs.find(d => d.type === 'literal');
|
|
124
|
+
if (literalDef) {
|
|
125
|
+
for (const kw of literalDef.keywords) {
|
|
126
|
+
if (normText.toLowerCase().startsWith(kw + ' ')) {
|
|
127
|
+
return {
|
|
128
|
+
type: 'action',
|
|
129
|
+
text: normText.substring(kw.length + 1).trim(),
|
|
130
|
+
isLiteral: true,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// 2. Scan other formatting keywords
|
|
137
|
+
for (const def of defs) {
|
|
138
|
+
if (def.type === 'literal') continue;
|
|
139
|
+
for (const kw of def.keywords) {
|
|
140
|
+
// Check if text starts with the keyword followed by space or is exactly the keyword
|
|
141
|
+
const prefix = kw + ' ';
|
|
142
|
+
if (normText.toLowerCase().startsWith(prefix)) {
|
|
143
|
+
return {
|
|
144
|
+
type: def.type,
|
|
145
|
+
text: normText.substring(kw.length + 1).trim(),
|
|
146
|
+
isLiteral: false,
|
|
147
|
+
};
|
|
148
|
+
} else if (normText.toLowerCase() === kw) {
|
|
149
|
+
return {
|
|
150
|
+
type: def.type,
|
|
151
|
+
text: '',
|
|
152
|
+
isLiteral: false,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// 3. Fallback to default action text
|
|
159
|
+
return {
|
|
160
|
+
type: 'action',
|
|
161
|
+
text: normText,
|
|
162
|
+
isLiteral: false,
|
|
163
|
+
};
|
|
164
|
+
}
|