@sutrata/editor 0.1.1 → 0.2.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.
Files changed (268) hide show
  1. package/README.md +87 -0
  2. package/dist/ai/VoiceConfirmDialog.d.ts +1 -0
  3. package/dist/ai/VoiceConfirmDialog.js +6 -6
  4. package/dist/ai/VoiceToolbar.d.ts +1 -0
  5. package/dist/ai/VoiceToolbar.js +22 -16
  6. package/dist/ai/clean-response.d.ts +7 -0
  7. package/dist/ai/clean-response.js +58 -0
  8. package/dist/ai/format-transcript.d.ts +3 -0
  9. package/dist/ai/format-transcript.js +7 -0
  10. package/dist/ai/prompts.d.ts +8 -1
  11. package/dist/ai/prompts.js +34 -7
  12. package/dist/autocomplete/suggestions.js +1 -1
  13. package/dist/context/DocumentContext.d.ts +28 -4
  14. package/dist/context/DocumentContext.js +67 -37
  15. package/dist/editor/EditorView.js +32 -4
  16. package/dist/editor/SelectionMenu.js +5 -3
  17. package/dist/editor/external-decorations-plugin.d.ts +23 -0
  18. package/dist/editor/external-decorations-plugin.js +151 -0
  19. package/dist/editor/omitted-scene-plugin.d.ts +9 -0
  20. package/dist/editor/omitted-scene-plugin.js +44 -0
  21. package/dist/editor/plugins.js +4 -0
  22. package/dist/editor/private-metadata-plugin.d.ts +10 -0
  23. package/dist/editor/private-metadata-plugin.js +60 -0
  24. package/dist/editor/prosemirror-to-sutra.js +179 -74
  25. package/dist/editor/scene-heading-view.js +2 -0
  26. package/dist/editor/schema.js +69 -12
  27. package/dist/editor/sutra-to-prosemirror.d.ts +2 -0
  28. package/dist/editor/sutra-to-prosemirror.js +32 -34
  29. package/dist/extensions/ai-provider.d.ts +44 -0
  30. package/dist/extensions/ai-provider.js +27 -0
  31. package/dist/extensions/collab.d.ts +21 -0
  32. package/dist/extensions/collab.js +6 -0
  33. package/dist/extensions/command-registry.d.ts +49 -0
  34. package/dist/extensions/command-registry.js +28 -0
  35. package/dist/extensions/decorations.d.ts +48 -0
  36. package/dist/extensions/decorations.js +6 -0
  37. package/dist/extensions/export-registry.d.ts +59 -0
  38. package/dist/extensions/export-registry.js +10 -0
  39. package/dist/extensions/panel-registry.d.ts +30 -0
  40. package/dist/extensions/panel-registry.js +16 -0
  41. package/dist/extensions/registries.d.ts +15 -0
  42. package/dist/extensions/registries.js +12 -0
  43. package/dist/extensions/registry-store.d.ts +26 -0
  44. package/dist/extensions/registry-store.js +35 -0
  45. package/dist/extensions/session.d.ts +29 -0
  46. package/dist/extensions/session.js +20 -0
  47. package/dist/extensions/speech-provider.d.ts +35 -0
  48. package/dist/extensions/speech-provider.js +17 -0
  49. package/dist/file/builtin-exporters.d.ts +9 -0
  50. package/dist/file/builtin-exporters.js +72 -0
  51. package/dist/file/docx-exporter.js +7 -4
  52. package/dist/file/docx-importer.d.ts +9 -0
  53. package/dist/file/docx-importer.js +47 -19
  54. package/dist/file/scene-number.d.ts +5 -0
  55. package/dist/file/scene-number.js +8 -0
  56. package/dist/file/workflow-reports.js +13 -7
  57. package/dist/findreplace/FindReplace.js +5 -2
  58. package/dist/import/AIImportDialog.d.ts +11 -0
  59. package/dist/import/AIImportDialog.js +112 -0
  60. package/dist/import/ai-import.d.ts +51 -0
  61. package/dist/import/ai-import.js +200 -0
  62. package/dist/import/apply-import.d.ts +7 -0
  63. package/dist/import/apply-import.js +35 -0
  64. package/dist/import/extract.d.ts +17 -0
  65. package/dist/import/extract.js +18 -0
  66. package/dist/index.d.ts +17 -2
  67. package/dist/index.js +7 -0
  68. package/dist/locales/bn.json +8 -0
  69. package/dist/locales/en.json +8 -0
  70. package/dist/locales/gu.json +8 -0
  71. package/dist/locales/hi.json +8 -0
  72. package/dist/locales/kn.json +8 -0
  73. package/dist/locales/ml.json +8 -0
  74. package/dist/locales/mr.json +8 -0
  75. package/dist/locales/or.json +8 -0
  76. package/dist/locales/pa.json +8 -0
  77. package/dist/locales/si.json +8 -0
  78. package/dist/locales/ta.json +8 -0
  79. package/dist/locales/te.json +8 -0
  80. package/dist/navigator/SceneNavigator.js +125 -131
  81. package/dist/navigator/StatisticsDialog.js +5 -1
  82. package/dist/navigator/scene-edits.d.ts +18 -0
  83. package/dist/navigator/scene-edits.js +143 -0
  84. package/dist/navigator/scene-list.js +4 -4
  85. package/dist/navigator/scene-numbering.d.ts +37 -0
  86. package/dist/navigator/scene-numbering.js +88 -0
  87. package/dist/settings/SettingsDialog.js +8 -120
  88. package/dist/shell/AppBar.js +21 -2
  89. package/dist/shell/AppShell.js +18 -4
  90. package/dist/shell/ElementToolbar.d.ts +5 -0
  91. package/dist/shell/ElementToolbar.js +35 -25
  92. package/dist/shell/LanguageStatus.js +6 -0
  93. package/dist/shell/StatusBar.js +11 -6
  94. package/dist/shell/builtin-commands.d.ts +10 -0
  95. package/dist/shell/builtin-commands.js +43 -0
  96. package/dist/shell/icons.d.ts +6 -0
  97. package/dist/shell/icons.js +6 -0
  98. package/dist/shell/use-commands.d.ts +7 -0
  99. package/dist/shell/use-commands.js +24 -0
  100. package/dist/shell/use-panel-context.d.ts +3 -0
  101. package/dist/shell/use-panel-context.js +39 -0
  102. package/dist/source/SourceView.js +18 -1
  103. package/dist/styles/screenplay.css +113 -1
  104. package/dist/titlepage/ExportDialog.d.ts +5 -0
  105. package/dist/titlepage/ExportDialog.js +59 -96
  106. package/package.json +32 -5
  107. package/dist/ai/OnboardingDialog.d.ts +0 -6
  108. package/dist/ai/OnboardingDialog.js +0 -115
  109. package/dist/ai/ai-client.d.ts +0 -71
  110. package/dist/ai/ai-client.js +0 -494
  111. package/dist/ai/generated-providers.json +0 -3696
  112. package/dist/ai/voice-service.d.ts +0 -15
  113. package/dist/ai/voice-service.js +0 -81
  114. package/dist/editor/character-view.d.ts +0 -35
  115. package/dist/editor/character-view.js +0 -112
  116. package/dist/editor/transliterate-input.d.ts +0 -10
  117. package/dist/editor/transliterate-input.js +0 -88
  118. package/dist/extensions/types.d.ts +0 -73
  119. package/dist/extensions/types.js +0 -12
  120. package/scripts/copy-assets.mjs +0 -16
  121. package/scripts/generate-providers.mjs +0 -127
  122. package/src/ai/OnboardingDialog.tsx +0 -390
  123. package/src/ai/VoiceConfirmDialog.tsx +0 -137
  124. package/src/ai/VoiceToolbar.tsx +0 -321
  125. package/src/ai/ai-client.ts +0 -596
  126. package/src/ai/commands.ts +0 -164
  127. package/src/ai/generated-providers.json +0 -3696
  128. package/src/ai/prompts.ts +0 -62
  129. package/src/ai/voice-service.ts +0 -96
  130. package/src/autocomplete/AutocompletePlugin.ts +0 -21
  131. package/src/autocomplete/suggestions.ts +0 -147
  132. package/src/context/DocumentContext.tsx +0 -648
  133. package/src/desktop-api.d.ts +0 -40
  134. package/src/editor/EditorView.tsx +0 -82
  135. package/src/editor/SelectionMenu.tsx +0 -152
  136. package/src/editor/attr-pencil-plugin.ts +0 -172
  137. package/src/editor/character-decoration-plugin.ts +0 -104
  138. package/src/editor/editor-bus.ts +0 -51
  139. package/src/editor/find-highlight-plugin.ts +0 -68
  140. package/src/editor/frontmatter-field-view.ts +0 -52
  141. package/src/editor/frontmatter-field.ts +0 -115
  142. package/src/editor/grapheme-cursor.ts +0 -99
  143. package/src/editor/ime-plugin.ts +0 -85
  144. package/src/editor/insert-helper.ts +0 -43
  145. package/src/editor/keymap.ts +0 -124
  146. package/src/editor/language-class-plugin.ts +0 -91
  147. package/src/editor/plugins.ts +0 -26
  148. package/src/editor/prosemirror-to-sutra.ts +0 -192
  149. package/src/editor/scene-heading-view.ts +0 -147
  150. package/src/editor/schema.ts +0 -156
  151. package/src/editor/sutra-to-prosemirror.ts +0 -156
  152. package/src/extensions/storage-adapter.ts +0 -65
  153. package/src/extensions/types.ts +0 -60
  154. package/src/file/docx-exporter.ts +0 -585
  155. package/src/file/docx-importer.ts +0 -313
  156. package/src/file/print-paginator.ts +0 -301
  157. package/src/file/templates.ts +0 -73
  158. package/src/file/workflow-reports.ts +0 -820
  159. package/src/findreplace/FindReplace.tsx +0 -242
  160. package/src/findreplace/find-engine.ts +0 -97
  161. package/src/findreplace/scroll-to-match.ts +0 -89
  162. package/src/fonts/tofu-detect.ts +0 -53
  163. package/src/i18n/LanguageContext.tsx +0 -207
  164. package/src/i18n/language-detect.ts +0 -73
  165. package/src/i18n/useTranslation.tsx +0 -74
  166. package/src/index.ts +0 -27
  167. package/src/locales/bn.json +0 -143
  168. package/src/locales/en.json +0 -143
  169. package/src/locales/gu.json +0 -143
  170. package/src/locales/hi.json +0 -143
  171. package/src/locales/kn.json +0 -143
  172. package/src/locales/ml.json +0 -143
  173. package/src/locales/mr.json +0 -143
  174. package/src/locales/or.json +0 -143
  175. package/src/locales/pa.json +0 -143
  176. package/src/locales/si.json +0 -143
  177. package/src/locales/ta.json +0 -143
  178. package/src/locales/te.json +0 -143
  179. package/src/navigator/SceneNavigator.tsx +0 -844
  180. package/src/navigator/StatisticsDialog.tsx +0 -249
  181. package/src/navigator/scene-list.ts +0 -84
  182. package/src/settings/SettingsDialog.tsx +0 -303
  183. package/src/shell/AppBar.tsx +0 -354
  184. package/src/shell/AppShell.tsx +0 -71
  185. package/src/shell/ConfirmDialog.tsx +0 -71
  186. package/src/shell/ElementToolbar.tsx +0 -175
  187. package/src/shell/LanguageStatus.tsx +0 -101
  188. package/src/shell/StatusBar.tsx +0 -135
  189. package/src/shell/SutrataLogo.tsx +0 -89
  190. package/src/shell/Toast.tsx +0 -46
  191. package/src/shell/ToolbarButton.tsx +0 -30
  192. package/src/shell/VersionHistory.tsx +0 -212
  193. package/src/shell/Watermark.tsx +0 -9
  194. package/src/shell/fonts/fonts.css +0 -1133
  195. package/src/shell/icons.tsx +0 -335
  196. package/src/shell/toolbar-actions.ts +0 -59
  197. package/src/source/SourceView.tsx +0 -111
  198. package/src/source/find-highlight-source.ts +0 -57
  199. package/src/source/sutra-lang.ts +0 -121
  200. package/src/spellcheck/dictionaries.ts +0 -21
  201. package/src/spellcheck/hunspell.ts +0 -110
  202. package/src/spellcheck/spellcheck-plugin.ts +0 -83
  203. package/src/styles/StyleDialog.tsx +0 -148
  204. package/src/styles/builtin-styles.ts +0 -139
  205. package/src/styles/css-adapter.ts +0 -76
  206. package/src/styles/docx-adapter.ts +0 -109
  207. package/src/styles/embed-fonts.ts +0 -81
  208. package/src/styles/pagination.ts +0 -27
  209. package/src/styles/print-adapter.ts +0 -288
  210. package/src/styles/registry.ts +0 -20
  211. package/src/styles/screenplay.css +0 -3006
  212. package/src/styles/script-ranges.ts +0 -17
  213. package/src/styles/types.ts +0 -104
  214. package/src/styles/validate.ts +0 -114
  215. package/src/templates/templates.ts +0 -194
  216. package/src/titlepage/ExportDialog.tsx +0 -494
  217. package/src/titlepage/TitlePageDialog.tsx +0 -312
  218. package/src/titlepage/frontmatter-form.ts +0 -280
  219. package/src/titlepage/languages.ts +0 -37
  220. package/src/types.ts +0 -7
  221. package/tests/AppBar.test.tsx +0 -35
  222. package/tests/AppShell.test.tsx +0 -22
  223. package/tests/ElementToolbar.test.tsx +0 -36
  224. package/tests/LanguageStatus.test.tsx +0 -129
  225. package/tests/SelectionMenu.test.tsx +0 -71
  226. package/tests/ToolbarButton.test.tsx +0 -24
  227. package/tests/ai-onboarding.test.ts +0 -102
  228. package/tests/ai-status.test.tsx +0 -72
  229. package/tests/ai-structured.test.ts +0 -94
  230. package/tests/autocomplete/AutocompletePlugin.test.ts +0 -20
  231. package/tests/autocomplete/suggestions.test.ts +0 -106
  232. package/tests/document-context.test.tsx +0 -565
  233. package/tests/docx-importer.test.ts +0 -160
  234. package/tests/editor/character-decoration-plugin.test.ts +0 -101
  235. package/tests/editor/character-extension.test.ts +0 -44
  236. package/tests/editor/grapheme-cursor.test.ts +0 -118
  237. package/tests/editor/ime-plugin.test.ts +0 -72
  238. package/tests/editor/inline-note-bridge.test.ts +0 -32
  239. package/tests/editor/language-class-plugin.test.ts +0 -265
  240. package/tests/editor/title-page.test.ts +0 -124
  241. package/tests/embed-fonts.test.ts +0 -17
  242. package/tests/exporters.test.ts +0 -365
  243. package/tests/findreplace/FindReplace.test.tsx +0 -391
  244. package/tests/findreplace/find-engine.test.ts +0 -86
  245. package/tests/findreplace/scroll-to-match.test.ts +0 -50
  246. package/tests/fonts/tofu-detect.test.ts +0 -122
  247. package/tests/i18n/LanguageContext.test.tsx +0 -146
  248. package/tests/i18n/language-detect.test.ts +0 -54
  249. package/tests/i18n/locale-parity.test.ts +0 -25
  250. package/tests/i18n/useTranslation.test.tsx +0 -45
  251. package/tests/keymap.test.ts +0 -18
  252. package/tests/navigator/SceneNavigator.test.tsx +0 -177
  253. package/tests/navigator/StatisticsDialog.test.tsx +0 -63
  254. package/tests/navigator/scene-list.test.ts +0 -71
  255. package/tests/print-paginator.test.ts +0 -82
  256. package/tests/shell/VersionHistory.test.tsx +0 -129
  257. package/tests/spellcheck/hunspell.test.ts +0 -82
  258. package/tests/spellcheck/spellcheck-plugin.test.ts +0 -56
  259. package/tests/styles.test.ts +0 -315
  260. package/tests/templates/templates.test.ts +0 -83
  261. package/tests/titlepage/TitlePageDialog.test.tsx +0 -90
  262. package/tests/titlepage/apply-title-page.test.ts +0 -61
  263. package/tests/titlepage/frontmatter-form.test.ts +0 -115
  264. package/tests/toolbar-actions.test.ts +0 -93
  265. package/tests/voice-commands.test.ts +0 -58
  266. package/tsconfig.json +0 -17
  267. package/vitest.config.ts +0 -11
  268. package/vitest.setup.ts +0 -65
@@ -1,164 +0,0 @@
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
- }