@sutrata/editor 0.1.0 → 0.1.2

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 (152) hide show
  1. package/README.md +87 -0
  2. package/dist/ai/generated-providers.json +1 -1
  3. package/package.json +36 -9
  4. package/scripts/copy-assets.mjs +0 -16
  5. package/scripts/generate-providers.mjs +0 -127
  6. package/src/ai/OnboardingDialog.tsx +0 -390
  7. package/src/ai/VoiceConfirmDialog.tsx +0 -137
  8. package/src/ai/VoiceToolbar.tsx +0 -321
  9. package/src/ai/ai-client.ts +0 -596
  10. package/src/ai/commands.ts +0 -164
  11. package/src/ai/generated-providers.json +0 -3696
  12. package/src/ai/prompts.ts +0 -62
  13. package/src/ai/voice-service.ts +0 -96
  14. package/src/autocomplete/AutocompletePlugin.ts +0 -21
  15. package/src/autocomplete/suggestions.ts +0 -147
  16. package/src/context/DocumentContext.tsx +0 -648
  17. package/src/desktop-api.d.ts +0 -40
  18. package/src/editor/EditorView.tsx +0 -82
  19. package/src/editor/SelectionMenu.tsx +0 -152
  20. package/src/editor/attr-pencil-plugin.ts +0 -172
  21. package/src/editor/character-decoration-plugin.ts +0 -104
  22. package/src/editor/editor-bus.ts +0 -51
  23. package/src/editor/find-highlight-plugin.ts +0 -68
  24. package/src/editor/frontmatter-field-view.ts +0 -52
  25. package/src/editor/frontmatter-field.ts +0 -115
  26. package/src/editor/grapheme-cursor.ts +0 -99
  27. package/src/editor/ime-plugin.ts +0 -85
  28. package/src/editor/insert-helper.ts +0 -43
  29. package/src/editor/keymap.ts +0 -124
  30. package/src/editor/language-class-plugin.ts +0 -91
  31. package/src/editor/plugins.ts +0 -26
  32. package/src/editor/prosemirror-to-sutra.ts +0 -192
  33. package/src/editor/scene-heading-view.ts +0 -147
  34. package/src/editor/schema.ts +0 -156
  35. package/src/editor/sutra-to-prosemirror.ts +0 -156
  36. package/src/extensions/storage-adapter.ts +0 -65
  37. package/src/extensions/types.ts +0 -60
  38. package/src/file/docx-exporter.ts +0 -585
  39. package/src/file/docx-importer.ts +0 -313
  40. package/src/file/print-paginator.ts +0 -301
  41. package/src/file/templates.ts +0 -73
  42. package/src/file/workflow-reports.ts +0 -820
  43. package/src/findreplace/FindReplace.tsx +0 -242
  44. package/src/findreplace/find-engine.ts +0 -97
  45. package/src/findreplace/scroll-to-match.ts +0 -89
  46. package/src/fonts/tofu-detect.ts +0 -53
  47. package/src/i18n/LanguageContext.tsx +0 -207
  48. package/src/i18n/language-detect.ts +0 -73
  49. package/src/i18n/useTranslation.tsx +0 -74
  50. package/src/index.ts +0 -27
  51. package/src/locales/bn.json +0 -143
  52. package/src/locales/en.json +0 -143
  53. package/src/locales/gu.json +0 -143
  54. package/src/locales/hi.json +0 -143
  55. package/src/locales/kn.json +0 -143
  56. package/src/locales/ml.json +0 -143
  57. package/src/locales/mr.json +0 -143
  58. package/src/locales/or.json +0 -143
  59. package/src/locales/pa.json +0 -143
  60. package/src/locales/si.json +0 -143
  61. package/src/locales/ta.json +0 -143
  62. package/src/locales/te.json +0 -143
  63. package/src/navigator/SceneNavigator.tsx +0 -844
  64. package/src/navigator/StatisticsDialog.tsx +0 -249
  65. package/src/navigator/scene-list.ts +0 -84
  66. package/src/settings/SettingsDialog.tsx +0 -303
  67. package/src/shell/AppBar.tsx +0 -354
  68. package/src/shell/AppShell.tsx +0 -71
  69. package/src/shell/ConfirmDialog.tsx +0 -71
  70. package/src/shell/ElementToolbar.tsx +0 -175
  71. package/src/shell/LanguageStatus.tsx +0 -101
  72. package/src/shell/StatusBar.tsx +0 -135
  73. package/src/shell/SutrataLogo.tsx +0 -89
  74. package/src/shell/Toast.tsx +0 -46
  75. package/src/shell/ToolbarButton.tsx +0 -30
  76. package/src/shell/VersionHistory.tsx +0 -212
  77. package/src/shell/Watermark.tsx +0 -9
  78. package/src/shell/fonts/fonts.css +0 -1133
  79. package/src/shell/icons.tsx +0 -335
  80. package/src/shell/toolbar-actions.ts +0 -59
  81. package/src/source/SourceView.tsx +0 -111
  82. package/src/source/find-highlight-source.ts +0 -57
  83. package/src/source/sutra-lang.ts +0 -121
  84. package/src/spellcheck/dictionaries.ts +0 -21
  85. package/src/spellcheck/hunspell.ts +0 -110
  86. package/src/spellcheck/spellcheck-plugin.ts +0 -83
  87. package/src/styles/StyleDialog.tsx +0 -148
  88. package/src/styles/builtin-styles.ts +0 -139
  89. package/src/styles/css-adapter.ts +0 -76
  90. package/src/styles/docx-adapter.ts +0 -109
  91. package/src/styles/embed-fonts.ts +0 -81
  92. package/src/styles/pagination.ts +0 -27
  93. package/src/styles/print-adapter.ts +0 -288
  94. package/src/styles/registry.ts +0 -20
  95. package/src/styles/screenplay.css +0 -3006
  96. package/src/styles/script-ranges.ts +0 -17
  97. package/src/styles/types.ts +0 -104
  98. package/src/styles/validate.ts +0 -114
  99. package/src/templates/templates.ts +0 -194
  100. package/src/titlepage/ExportDialog.tsx +0 -494
  101. package/src/titlepage/TitlePageDialog.tsx +0 -312
  102. package/src/titlepage/frontmatter-form.ts +0 -280
  103. package/src/titlepage/languages.ts +0 -37
  104. package/src/types.ts +0 -7
  105. package/tests/AppBar.test.tsx +0 -35
  106. package/tests/AppShell.test.tsx +0 -22
  107. package/tests/ElementToolbar.test.tsx +0 -36
  108. package/tests/LanguageStatus.test.tsx +0 -129
  109. package/tests/SelectionMenu.test.tsx +0 -71
  110. package/tests/ToolbarButton.test.tsx +0 -24
  111. package/tests/ai-onboarding.test.ts +0 -102
  112. package/tests/ai-status.test.tsx +0 -72
  113. package/tests/ai-structured.test.ts +0 -94
  114. package/tests/autocomplete/AutocompletePlugin.test.ts +0 -20
  115. package/tests/autocomplete/suggestions.test.ts +0 -106
  116. package/tests/document-context.test.tsx +0 -565
  117. package/tests/docx-importer.test.ts +0 -160
  118. package/tests/editor/character-decoration-plugin.test.ts +0 -101
  119. package/tests/editor/character-extension.test.ts +0 -44
  120. package/tests/editor/grapheme-cursor.test.ts +0 -118
  121. package/tests/editor/ime-plugin.test.ts +0 -72
  122. package/tests/editor/inline-note-bridge.test.ts +0 -32
  123. package/tests/editor/language-class-plugin.test.ts +0 -265
  124. package/tests/editor/title-page.test.ts +0 -124
  125. package/tests/embed-fonts.test.ts +0 -17
  126. package/tests/exporters.test.ts +0 -365
  127. package/tests/findreplace/FindReplace.test.tsx +0 -391
  128. package/tests/findreplace/find-engine.test.ts +0 -86
  129. package/tests/findreplace/scroll-to-match.test.ts +0 -50
  130. package/tests/fonts/tofu-detect.test.ts +0 -122
  131. package/tests/i18n/LanguageContext.test.tsx +0 -146
  132. package/tests/i18n/language-detect.test.ts +0 -54
  133. package/tests/i18n/locale-parity.test.ts +0 -25
  134. package/tests/i18n/useTranslation.test.tsx +0 -45
  135. package/tests/keymap.test.ts +0 -18
  136. package/tests/navigator/SceneNavigator.test.tsx +0 -177
  137. package/tests/navigator/StatisticsDialog.test.tsx +0 -63
  138. package/tests/navigator/scene-list.test.ts +0 -71
  139. package/tests/print-paginator.test.ts +0 -82
  140. package/tests/shell/VersionHistory.test.tsx +0 -129
  141. package/tests/spellcheck/hunspell.test.ts +0 -82
  142. package/tests/spellcheck/spellcheck-plugin.test.ts +0 -56
  143. package/tests/styles.test.ts +0 -315
  144. package/tests/templates/templates.test.ts +0 -83
  145. package/tests/titlepage/TitlePageDialog.test.tsx +0 -90
  146. package/tests/titlepage/apply-title-page.test.ts +0 -61
  147. package/tests/titlepage/frontmatter-form.test.ts +0 -115
  148. package/tests/toolbar-actions.test.ts +0 -93
  149. package/tests/voice-commands.test.ts +0 -58
  150. package/tsconfig.json +0 -17
  151. package/vitest.config.ts +0 -11
  152. package/vitest.setup.ts +0 -65
@@ -1,265 +0,0 @@
1
- import { describe, it, expect } from 'vitest'
2
- import { EditorState } from 'prosemirror-state'
3
- import { schema } from '../../src/editor/schema'
4
- import { createLanguageClassPlugin } from '../../src/editor/language-class-plugin'
5
-
6
- describe('language-class-plugin', () => {
7
- function createStateWithPlugin(docContent: any) {
8
- const plugin = createLanguageClassPlugin()
9
- const state = EditorState.create({
10
- doc: schema.node('doc', null, [schema.nodeFromJSON(docContent)]),
11
- plugins: [plugin],
12
- })
13
- return { state, plugin }
14
- }
15
-
16
- function collectDecorations(decorationSet: any): any[] {
17
- // DecorationSet.find() returns an array of Decoration objects
18
- return decorationSet.find()
19
- }
20
-
21
- it('applies .cs-lang-en to English text block', () => {
22
- const { state, plugin } = createStateWithPlugin({
23
- type: 'action',
24
- content: [{ type: 'text', text: 'Hello world' }],
25
- })
26
-
27
- const decorationSet = plugin.getState(state)
28
- expect(decorationSet).toBeDefined()
29
-
30
- const decorations = collectDecorations(decorationSet)
31
- expect(decorations.length).toBeGreaterThan(0)
32
-
33
- const hasEnglishClass = decorations.some((d: any) =>
34
- d.spec?.class?.includes('cs-lang-en')
35
- )
36
- expect(hasEnglishClass).toBe(true)
37
- })
38
-
39
- it('applies .cs-lang-ta to Tamil text block', () => {
40
- const { state, plugin } = createStateWithPlugin({
41
- type: 'dialogue',
42
- content: [{ type: 'text', text: 'இது ஒரு தமிழ் வாக்கியம்' }],
43
- })
44
-
45
- const decorationSet = plugin.getState(state)
46
- const decorations = collectDecorations(decorationSet)
47
- expect(decorations.length).toBeGreaterThan(0)
48
-
49
- // Check that a decoration with Tamil class exists
50
- const hasTamilClass = decorations.some((d: any) =>
51
- d.spec?.class?.includes('cs-lang-ta')
52
- )
53
- expect(hasTamilClass).toBe(true)
54
- })
55
-
56
- it('applies .cs-lang-hi to Hindi/Devanagari text block', () => {
57
- const { state, plugin } = createStateWithPlugin({
58
- type: 'character',
59
- content: [{ type: 'text', text: 'यह एक हिंदी वाक्य है' }],
60
- })
61
-
62
- const decorationSet = plugin.getState(state)
63
- const decorations = collectDecorations(decorationSet)
64
-
65
- const hasHindiClass = decorations.some((d: any) =>
66
- d.spec?.class?.includes('cs-lang-hi')
67
- )
68
- expect(hasHindiClass).toBe(true)
69
- })
70
-
71
- it('respects inline {lang=…} tag override', () => {
72
- const { state, plugin } = createStateWithPlugin({
73
- type: 'parenthetical',
74
- content: [{ type: 'text', text: 'English text {lang=ml}' }],
75
- })
76
-
77
- const decorationSet = plugin.getState(state)
78
- const decorations = collectDecorations(decorationSet)
79
-
80
- const hasMalayalamClass = decorations.some((d: any) =>
81
- d.spec?.class?.includes('cs-lang-ml')
82
- )
83
- expect(hasMalayalamClass).toBe(true)
84
- })
85
-
86
- it('updates classes on doc change', () => {
87
- const { state: initialState, plugin } = createStateWithPlugin({
88
- type: 'action',
89
- content: [{ type: 'text', text: 'Hello world' }],
90
- })
91
-
92
- let state = initialState
93
- let decorationSet = plugin.getState(state)
94
- let decorations = collectDecorations(decorationSet)
95
-
96
- const englishCount = decorations.filter((d: any) =>
97
- d.spec?.class?.includes('cs-lang-en')
98
- ).length
99
- expect(englishCount).toBeGreaterThan(0)
100
-
101
- // Update the doc - select all text in the block and replace with Tamil
102
- // The block content starts at position 1 (after the opening tag)
103
- // Find the end of the text node
104
- const selection = state.selection
105
- const from = 1 // start of content in the block
106
- const to = state.doc.content.content[0].nodeSize - 1 // end of action node minus closing
107
-
108
- const tr = state.tr.deleteRange(from, to).insertText('இது ஒரு தமிழ் வாக்கியம்', from)
109
- const newState = state.apply(tr)
110
- decorationSet = plugin.getState(newState)
111
- decorations = collectDecorations(decorationSet)
112
-
113
- // Should now have Tamil decoration
114
- const hasTamilClass = decorations.some((d: any) =>
115
- d.spec?.class?.includes('cs-lang-ta')
116
- )
117
- expect(hasTamilClass).toBe(true)
118
- })
119
-
120
- it('defaults to .cs-lang-en for empty blocks', () => {
121
- const { state, plugin } = createStateWithPlugin({
122
- type: 'dialogue',
123
- content: [],
124
- })
125
-
126
- const decorationSet = plugin.getState(state)
127
- const decorations = collectDecorations(decorationSet)
128
-
129
- const hasEnglishClass = decorations.some((d: any) =>
130
- d.spec?.class?.includes('cs-lang-en')
131
- )
132
- expect(hasEnglishClass).toBe(true)
133
- })
134
-
135
- it('handles multiple blocks with different languages', () => {
136
- const plugin = createLanguageClassPlugin()
137
- const state = EditorState.create({
138
- doc: schema.node('doc', null, [
139
- schema.node('action', null, [schema.text('Hello world')]),
140
- schema.node('dialogue', null, [schema.text('இது ஒரு தமிழ் வாக்கியம்')]),
141
- schema.node('character', null, [schema.text('यह एक हिंदी वाक्य है')]),
142
- ]),
143
- plugins: [plugin],
144
- })
145
-
146
- const decorationSet = plugin.getState(state)
147
- const decorations = collectDecorations(decorationSet)
148
-
149
- const englishCount = decorations.filter((d: any) =>
150
- d.spec?.class?.includes('cs-lang-en')
151
- ).length
152
- const tamilCount = decorations.filter((d: any) =>
153
- d.spec?.class?.includes('cs-lang-ta')
154
- ).length
155
- const hindiCount = decorations.filter((d: any) =>
156
- d.spec?.class?.includes('cs-lang-hi')
157
- ).length
158
-
159
- expect(englishCount).toBe(1)
160
- expect(tamilCount).toBe(1)
161
- expect(hindiCount).toBe(1)
162
- })
163
-
164
- it('class persists across selection changes', () => {
165
- const { state: initialState, plugin } = createStateWithPlugin({
166
- type: 'dialogue',
167
- content: [{ type: 'text', text: 'இது ஒரு தமிழ் வாக்கியம்' }],
168
- })
169
-
170
- const decorationSet1 = plugin.getState(initialState)
171
- const decorations1 = collectDecorations(decorationSet1)
172
-
173
- // Change selection without changing doc
174
- const tr = initialState.tr.setSelection(initialState.selection)
175
- const newState = initialState.apply(tr)
176
- const decorationSet2 = plugin.getState(newState)
177
- const decorations2 = collectDecorations(decorationSet2)
178
-
179
- // Decorations should remain the same
180
- const class1 = decorations1[0]?.spec?.class
181
- const class2 = decorations2[0]?.spec?.class
182
-
183
- expect(class1).toBe(class2)
184
- expect(class1).toContain('cs-lang-ta')
185
- })
186
-
187
- it('applies Telugu language class correctly', () => {
188
- const { state, plugin } = createStateWithPlugin({
189
- type: 'parenthetical',
190
- content: [{ type: 'text', text: 'ఇది ఒక నమూనా లైన్' }],
191
- })
192
-
193
- const decorationSet = plugin.getState(state)
194
- const decorations = collectDecorations(decorationSet)
195
-
196
- const hasTeluguClass = decorations.some((d: any) =>
197
- d.spec?.class?.includes('cs-lang-te')
198
- )
199
- expect(hasTeluguClass).toBe(true)
200
- })
201
-
202
- it('applies Kannada language class correctly', () => {
203
- const { state, plugin } = createStateWithPlugin({
204
- type: 'centered',
205
- content: [{ type: 'text', text: 'ಇದು ಒಂದು ಮಾದರಿ ಲೈನ್' }],
206
- })
207
-
208
- const decorationSet = plugin.getState(state)
209
- const decorations = collectDecorations(decorationSet)
210
-
211
- const hasKannadaClass = decorations.some((d: any) =>
212
- d.spec?.class?.includes('cs-lang-kn')
213
- )
214
- expect(hasKannadaClass).toBe(true)
215
- })
216
-
217
- it('applies Malayalam language class correctly', () => {
218
- const { state, plugin } = createStateWithPlugin({
219
- type: 'lyrics',
220
- content: [{ type: 'text', text: 'ഇത് ഒരു സാമ്പിൾ ലൈൻ ആണ്' }],
221
- })
222
-
223
- const decorationSet = plugin.getState(state)
224
- const decorations = collectDecorations(decorationSet)
225
-
226
- const hasMalayalamClass = decorations.some((d: any) =>
227
- d.spec?.class?.includes('cs-lang-ml')
228
- )
229
- expect(hasMalayalamClass).toBe(true)
230
- })
231
-
232
- it('does not apply classes to non-block nodes', () => {
233
- const plugin = createLanguageClassPlugin()
234
- const state = EditorState.create({
235
- doc: schema.node('doc', null, [
236
- schema.node('action', null, [schema.text('Some text')]),
237
- ]),
238
- plugins: [plugin],
239
- })
240
-
241
- const decorationSet = plugin.getState(state)
242
- const decorations = collectDecorations(decorationSet)
243
-
244
- // Should have exactly 1 decoration (for the action block, not for inline text nodes)
245
- expect(decorations.length).toBe(1)
246
- })
247
-
248
- it('skips decorating the doc node itself', () => {
249
- const { state, plugin } = createStateWithPlugin({
250
- type: 'action',
251
- content: [{ type: 'text', text: 'Hello' }],
252
- })
253
-
254
- const decorationSet = plugin.getState(state)
255
- const decorations = collectDecorations(decorationSet)
256
-
257
- // Should not have a decoration for the doc node (offset 0)
258
- const hasDocDecoration = decorations.some((d: any) =>
259
- d.from === 0 && d.to === state.doc.nodeSize
260
- )
261
- // The decoration should be for the action block, not the entire doc
262
- expect(decorations.length).toBeGreaterThan(0)
263
- expect(hasDocDecoration).toBe(false)
264
- })
265
- })
@@ -1,124 +0,0 @@
1
- import { describe, it, expect, afterEach } from 'vitest'
2
- import { EditorState, TextSelection } from 'prosemirror-state'
3
- import { EditorView } from 'prosemirror-view'
4
- import { parse } from '@sutrata/parser'
5
- import { schema } from '../../src/editor/schema'
6
- import { sutraToProsemirror } from '../../src/editor/sutra-to-prosemirror'
7
- import { prosemirrorToSutra } from '../../src/editor/prosemirror-to-sutra'
8
- import { keymapBindings } from '../../src/editor/keymap'
9
- import { createAttrPencilPlugin } from '../../src/editor/attr-pencil-plugin'
10
-
11
- const SAMPLE = `---
12
- title:
13
- en: The Long Rain
14
- hi: लंबी बारिश
15
- author: Sivaraj
16
- custom_key: kept
17
- ---
18
-
19
- ## INT. KITCHEN - NIGHT
20
-
21
- Action line.
22
- `
23
-
24
- describe('title_page bridge (frontmatter in the editor)', () => {
25
- it('renders frontmatter as a title_page node with dotted keys for nested maps', () => {
26
- const doc = sutraToProsemirror(parse(SAMPLE))
27
- const first = doc.firstChild!
28
- expect(first.type.name).toBe('title_page')
29
- const keys: string[] = []
30
- first.forEach(f => keys.push(f.attrs['fmKey'] as string))
31
- expect(keys).toEqual(['title.en', 'title.hi', 'author', 'custom_key'])
32
- expect(first.child(0).textContent).toBe('The Long Rain')
33
- expect(first.child(1).textContent).toBe('लंबी बारिश')
34
- })
35
-
36
- it('round-trips frontmatter through the editor bridge (fixes WYSIWYG frontmatter loss)', () => {
37
- const doc = sutraToProsemirror(parse(SAMPLE))
38
- const out = prosemirrorToSutra(doc)
39
- const reparsed = parse(out)
40
- expect(reparsed.frontmatter).not.toBeNull()
41
- expect(reparsed.frontmatter!.data).toEqual({
42
- title: { en: 'The Long Rain', hi: 'लंबी बारिश' },
43
- author: 'Sivaraj',
44
- custom_key: 'kept',
45
- })
46
- expect(out).toContain('## INT. KITCHEN - NIGHT')
47
- expect(out).toContain('Action line.')
48
- })
49
-
50
- it('does not invent a frontmatter block when none exists', () => {
51
- const doc = sutraToProsemirror(parse('## Scene 1\n\nAction.\n'))
52
- expect(doc.firstChild!.type.name).toBe('scene_heading')
53
- expect(prosemirrorToSutra(doc)).not.toContain('---')
54
- })
55
-
56
- it('Enter inside a frontmatter field moves to the next field without splitting', () => {
57
- const doc = sutraToProsemirror(parse(SAMPLE))
58
- let state = EditorState.create({ doc, schema })
59
- // Position 2 = inside the first field's content
60
- state = state.apply(state.tr.setSelection(TextSelection.create(state.doc, 2)))
61
- expect(state.selection.$from.parent.attrs['fmKey']).toBe('title.en')
62
-
63
- let after: EditorState | null = null
64
- const handled = keymapBindings['Enter']!(state, tr => { after = state.apply(tr) })
65
- expect(handled).toBe(true)
66
- expect(after!.doc.eq(state.doc)).toBe(true) // no split, no new node
67
- expect(after!.selection.$from.parent.type.name).toBe('frontmatter_field')
68
- expect(after!.selection.$from.parent.attrs['fmKey']).toBe('title.hi')
69
- })
70
- })
71
-
72
- describe('attr pencil plugin', () => {
73
- let view: EditorView | null = null
74
-
75
- afterEach(() => {
76
- view?.destroy()
77
- view = null
78
- document.querySelector('.cs-attr-menu')?.remove()
79
- })
80
-
81
- function mount(text: string): EditorView {
82
- const doc = sutraToProsemirror(parse(text))
83
- const state = EditorState.create({ doc, schema, plugins: [createAttrPencilPlugin()] })
84
- view = new EditorView(document.createElement('div'), { state })
85
- return view
86
- }
87
-
88
- it('renders a pencil widget on scene headings and the title page card', () => {
89
- const v = mount(SAMPLE)
90
- const pencils = v.dom.querySelectorAll('.cs-attr-pencil')
91
- expect(pencils.length).toBe(2)
92
- expect(v.dom.querySelectorAll('.cs-tp-pencil').length).toBe(1)
93
- })
94
-
95
- it('scene pencil menu inserts a metadata line with the picked key', () => {
96
- const v = mount(SAMPLE)
97
- const pencil = [...v.dom.querySelectorAll('.cs-attr-pencil')]
98
- .find(p => !p.classList.contains('cs-tp-pencil'))!
99
- pencil.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }))
100
-
101
- const menu = document.querySelector('.cs-attr-menu')
102
- expect(menu).not.toBeNull()
103
- const statusItem = [...menu!.querySelectorAll('.cs-attr-menu-item')]
104
- .find(i => i.textContent === '+ status')!
105
- statusItem.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }))
106
-
107
- const out = prosemirrorToSutra(v.state.doc)
108
- expect(out).toContain('## INT. KITCHEN - NIGHT\n& status:')
109
- // Cursor placed inside the new (empty) metadata node
110
- expect(v.state.selection.$from.parent.type.name).toBe('scene_metadata')
111
- })
112
-
113
- it('title page pencil opens the title page form instead of an add-field menu', () => {
114
- const v = mount(SAMPLE)
115
- const pencil = v.dom.querySelector('.cs-tp-pencil')!
116
- let opened = false
117
- window.addEventListener('cs:open-title-page', () => { opened = true })
118
-
119
- pencil.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }))
120
-
121
- expect(opened).toBe(true)
122
- expect(document.querySelector('.cs-attr-menu')).toBeNull()
123
- })
124
- })
@@ -1,17 +0,0 @@
1
- import { describe, it, expect } from 'vitest'
2
- import { embedFontFacesFor } from '../src/styles/embed-fonts'
3
-
4
- describe('embed-fonts', () => {
5
- it('returns an empty string and does not throw when no matching @font-face rules are loaded', async () => {
6
- // jsdom's test document never loads fonts.css via a real <link>, so this exercises the
7
- // "nothing found" path — the real embedding behavior is verified end-to-end against an
8
- // actual browser (see the multi-style implementation notes), since it depends on
9
- // document.styleSheets/fetch/FileReader, none of which jsdom meaningfully implements.
10
- const css = await embedFontFacesFor(['Noto Serif', 'Noto Serif Tamil'])
11
- expect(css).toBe('')
12
- })
13
-
14
- it('does not throw for an empty family list', async () => {
15
- await expect(embedFontFacesFor([])).resolves.toBe('')
16
- })
17
- })