@bendyline/squisq-editor-react 1.4.0 → 1.5.1

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 (446) hide show
  1. package/dist/DocumentSettingsDialog.d.ts +26 -0
  2. package/dist/DocumentSettingsDialog.d.ts.map +1 -0
  3. package/dist/DocumentSettingsDialog.js +115 -0
  4. package/dist/DocumentSettingsDialog.js.map +1 -0
  5. package/dist/EditorContext.d.ts +248 -4
  6. package/dist/EditorContext.d.ts.map +1 -1
  7. package/dist/EditorContext.js +248 -10
  8. package/dist/EditorContext.js.map +1 -1
  9. package/dist/EditorShell.d.ts +173 -4
  10. package/dist/EditorShell.d.ts.map +1 -1
  11. package/dist/EditorShell.js +110 -10
  12. package/dist/EditorShell.js.map +1 -1
  13. package/dist/EmojiPicker.d.ts +50 -0
  14. package/dist/EmojiPicker.d.ts.map +1 -0
  15. package/dist/EmojiPicker.js +182 -0
  16. package/dist/EmojiPicker.js.map +1 -0
  17. package/dist/ImageEditor.d.ts +68 -0
  18. package/dist/ImageEditor.d.ts.map +1 -0
  19. package/dist/ImageEditor.js +166 -0
  20. package/dist/ImageEditor.js.map +1 -0
  21. package/dist/ImageNodeView.d.ts +13 -1
  22. package/dist/ImageNodeView.d.ts.map +1 -1
  23. package/dist/ImageNodeView.js +172 -19
  24. package/dist/ImageNodeView.js.map +1 -1
  25. package/dist/ImageViewer.d.ts +26 -0
  26. package/dist/ImageViewer.d.ts.map +1 -0
  27. package/dist/ImageViewer.js +119 -0
  28. package/dist/ImageViewer.js.map +1 -0
  29. package/dist/InlineIcon.d.ts +17 -0
  30. package/dist/InlineIcon.d.ts.map +1 -0
  31. package/dist/InlineIcon.js +72 -0
  32. package/dist/InlineIcon.js.map +1 -0
  33. package/dist/InlinePreviewGutter.d.ts +52 -0
  34. package/dist/InlinePreviewGutter.d.ts.map +1 -0
  35. package/dist/InlinePreviewGutter.js +397 -0
  36. package/dist/InlinePreviewGutter.js.map +1 -0
  37. package/dist/LinkDialog.d.ts +43 -0
  38. package/dist/LinkDialog.d.ts.map +1 -0
  39. package/dist/LinkDialog.js +102 -0
  40. package/dist/LinkDialog.js.map +1 -0
  41. package/dist/MentionExtension.js +10 -7
  42. package/dist/MentionExtension.js.map +1 -1
  43. package/dist/OutlinePanel.d.ts +17 -0
  44. package/dist/OutlinePanel.d.ts.map +1 -0
  45. package/dist/OutlinePanel.js +167 -0
  46. package/dist/OutlinePanel.js.map +1 -0
  47. package/dist/PlainHtmlPreview.d.ts +50 -0
  48. package/dist/PlainHtmlPreview.d.ts.map +1 -0
  49. package/dist/PlainHtmlPreview.js +155 -0
  50. package/dist/PlainHtmlPreview.js.map +1 -0
  51. package/dist/PreviewControls.d.ts +15 -1
  52. package/dist/PreviewControls.d.ts.map +1 -1
  53. package/dist/PreviewControls.js +75 -18
  54. package/dist/PreviewControls.js.map +1 -1
  55. package/dist/PreviewPanel.d.ts +11 -10
  56. package/dist/PreviewPanel.d.ts.map +1 -1
  57. package/dist/PreviewPanel.js +20 -17
  58. package/dist/PreviewPanel.js.map +1 -1
  59. package/dist/RawEditor.d.ts.map +1 -1
  60. package/dist/RawEditor.js +198 -4
  61. package/dist/RawEditor.js.map +1 -1
  62. package/dist/RecorderEntry.d.ts +24 -0
  63. package/dist/RecorderEntry.d.ts.map +1 -0
  64. package/dist/RecorderEntry.js +139 -0
  65. package/dist/RecorderEntry.js.map +1 -0
  66. package/dist/TemplateAnnotation.d.ts.map +1 -1
  67. package/dist/TemplateAnnotation.js +32 -6
  68. package/dist/TemplateAnnotation.js.map +1 -1
  69. package/dist/TemplatePicker.d.ts +53 -0
  70. package/dist/TemplatePicker.d.ts.map +1 -0
  71. package/dist/TemplatePicker.js +388 -0
  72. package/dist/TemplatePicker.js.map +1 -0
  73. package/dist/ThemeCustomizerPanel.d.ts +32 -0
  74. package/dist/ThemeCustomizerPanel.d.ts.map +1 -0
  75. package/dist/ThemeCustomizerPanel.js +256 -0
  76. package/dist/ThemeCustomizerPanel.js.map +1 -0
  77. package/dist/ThemePicker.d.ts +33 -0
  78. package/dist/ThemePicker.d.ts.map +1 -0
  79. package/dist/ThemePicker.js +148 -0
  80. package/dist/ThemePicker.js.map +1 -0
  81. package/dist/Toolbar.d.ts.map +1 -1
  82. package/dist/Toolbar.js +508 -33
  83. package/dist/Toolbar.js.map +1 -1
  84. package/dist/VersionHistoryPanel.d.ts +14 -0
  85. package/dist/VersionHistoryPanel.d.ts.map +1 -0
  86. package/dist/VersionHistoryPanel.js +147 -0
  87. package/dist/VersionHistoryPanel.js.map +1 -0
  88. package/dist/ViewMenuPanel.d.ts +13 -0
  89. package/dist/ViewMenuPanel.d.ts.map +1 -0
  90. package/dist/ViewMenuPanel.js +58 -0
  91. package/dist/ViewMenuPanel.js.map +1 -0
  92. package/dist/WysiwygEditor.d.ts.map +1 -1
  93. package/dist/WysiwygEditor.js +198 -9
  94. package/dist/WysiwygEditor.js.map +1 -1
  95. package/dist/__tests__/detectMarkdown.test.js +0 -14
  96. package/dist/__tests__/detectMarkdown.test.js.map +1 -1
  97. package/dist/__tests__/documentSettingsDialog.test.d.ts +2 -0
  98. package/dist/__tests__/documentSettingsDialog.test.d.ts.map +1 -0
  99. package/dist/__tests__/documentSettingsDialog.test.js +132 -0
  100. package/dist/__tests__/documentSettingsDialog.test.js.map +1 -0
  101. package/dist/__tests__/emojiPicker.test.d.ts +2 -0
  102. package/dist/__tests__/emojiPicker.test.d.ts.map +1 -0
  103. package/dist/__tests__/emojiPicker.test.js +111 -0
  104. package/dist/__tests__/emojiPicker.test.js.map +1 -0
  105. package/dist/__tests__/fileKind.test.js +13 -0
  106. package/dist/__tests__/fileKind.test.js.map +1 -1
  107. package/dist/__tests__/imageEditAffordance.test.d.ts +2 -0
  108. package/dist/__tests__/imageEditAffordance.test.d.ts.map +1 -0
  109. package/dist/__tests__/imageEditAffordance.test.js +188 -0
  110. package/dist/__tests__/imageEditAffordance.test.js.map +1 -0
  111. package/dist/__tests__/imageEditorShell.test.d.ts +2 -0
  112. package/dist/__tests__/imageEditorShell.test.d.ts.map +1 -0
  113. package/dist/__tests__/imageEditorShell.test.js +52 -0
  114. package/dist/__tests__/imageEditorShell.test.js.map +1 -0
  115. package/dist/__tests__/imageEditorState.test.d.ts +3 -0
  116. package/dist/__tests__/imageEditorState.test.d.ts.map +1 -0
  117. package/dist/__tests__/imageEditorState.test.js +148 -0
  118. package/dist/__tests__/imageEditorState.test.js.map +1 -0
  119. package/dist/__tests__/inlinePreviewGutter.test.d.ts +2 -0
  120. package/dist/__tests__/inlinePreviewGutter.test.d.ts.map +1 -0
  121. package/dist/__tests__/inlinePreviewGutter.test.js +51 -0
  122. package/dist/__tests__/inlinePreviewGutter.test.js.map +1 -0
  123. package/dist/__tests__/inlinePreviewGutterAllBlocks.test.d.ts +2 -0
  124. package/dist/__tests__/inlinePreviewGutterAllBlocks.test.d.ts.map +1 -0
  125. package/dist/__tests__/inlinePreviewGutterAllBlocks.test.js +63 -0
  126. package/dist/__tests__/inlinePreviewGutterAllBlocks.test.js.map +1 -0
  127. package/dist/__tests__/jsonEditor.test.d.ts +2 -0
  128. package/dist/__tests__/jsonEditor.test.d.ts.map +1 -0
  129. package/dist/__tests__/jsonEditor.test.js +134 -0
  130. package/dist/__tests__/jsonEditor.test.js.map +1 -0
  131. package/dist/__tests__/layersPanel.test.d.ts +2 -0
  132. package/dist/__tests__/layersPanel.test.d.ts.map +1 -0
  133. package/dist/__tests__/layersPanel.test.js +84 -0
  134. package/dist/__tests__/layersPanel.test.js.map +1 -0
  135. package/dist/__tests__/linkDialogDocPicker.test.d.ts +7 -0
  136. package/dist/__tests__/linkDialogDocPicker.test.d.ts.map +1 -0
  137. package/dist/__tests__/linkDialogDocPicker.test.js +75 -0
  138. package/dist/__tests__/linkDialogDocPicker.test.js.map +1 -0
  139. package/dist/__tests__/outlinePanel.test.d.ts +2 -0
  140. package/dist/__tests__/outlinePanel.test.d.ts.map +1 -0
  141. package/dist/__tests__/outlinePanel.test.js +68 -0
  142. package/dist/__tests__/outlinePanel.test.js.map +1 -0
  143. package/dist/__tests__/plainHtmlPreview.test.d.ts +2 -0
  144. package/dist/__tests__/plainHtmlPreview.test.d.ts.map +1 -0
  145. package/dist/__tests__/plainHtmlPreview.test.js +87 -0
  146. package/dist/__tests__/plainHtmlPreview.test.js.map +1 -0
  147. package/dist/__tests__/propertiesPanel.test.d.ts +2 -0
  148. package/dist/__tests__/propertiesPanel.test.d.ts.map +1 -0
  149. package/dist/__tests__/propertiesPanel.test.js +64 -0
  150. package/dist/__tests__/propertiesPanel.test.js.map +1 -0
  151. package/dist/__tests__/recorderFormats.test.d.ts +2 -0
  152. package/dist/__tests__/recorderFormats.test.d.ts.map +1 -0
  153. package/dist/__tests__/recorderFormats.test.js +121 -0
  154. package/dist/__tests__/recorderFormats.test.js.map +1 -0
  155. package/dist/__tests__/recorderTimingJson.test.d.ts +2 -0
  156. package/dist/__tests__/recorderTimingJson.test.d.ts.map +1 -0
  157. package/dist/__tests__/recorderTimingJson.test.js +37 -0
  158. package/dist/__tests__/recorderTimingJson.test.js.map +1 -0
  159. package/dist/__tests__/templateAnnotationRoundTrip.test.d.ts +2 -0
  160. package/dist/__tests__/templateAnnotationRoundTrip.test.d.ts.map +1 -0
  161. package/dist/__tests__/templateAnnotationRoundTrip.test.js +31 -0
  162. package/dist/__tests__/templateAnnotationRoundTrip.test.js.map +1 -0
  163. package/dist/__tests__/tiptapBridge.test.js +13 -0
  164. package/dist/__tests__/tiptapBridge.test.js.map +1 -1
  165. package/dist/__tests__/useImageEditor.test.d.ts +2 -0
  166. package/dist/__tests__/useImageEditor.test.d.ts.map +1 -0
  167. package/dist/__tests__/useImageEditor.test.js +131 -0
  168. package/dist/__tests__/useImageEditor.test.js.map +1 -0
  169. package/dist/__tests__/useMediaRecorder.test.d.ts +2 -0
  170. package/dist/__tests__/useMediaRecorder.test.d.ts.map +1 -0
  171. package/dist/__tests__/useMediaRecorder.test.js +153 -0
  172. package/dist/__tests__/useMediaRecorder.test.js.map +1 -0
  173. package/dist/__tests__/versionHistory.test.d.ts +2 -0
  174. package/dist/__tests__/versionHistory.test.d.ts.map +1 -0
  175. package/dist/__tests__/versionHistory.test.js +124 -0
  176. package/dist/__tests__/versionHistory.test.js.map +1 -0
  177. package/dist/blockSlice.d.ts +24 -0
  178. package/dist/blockSlice.d.ts.map +1 -0
  179. package/dist/blockSlice.js +63 -0
  180. package/dist/blockSlice.js.map +1 -0
  181. package/dist/buildPreviewDoc.d.ts.map +1 -1
  182. package/dist/buildPreviewDoc.js +52 -2
  183. package/dist/buildPreviewDoc.js.map +1 -1
  184. package/dist/emojiData.d.ts +81 -0
  185. package/dist/emojiData.d.ts.map +1 -0
  186. package/dist/emojiData.js +1283 -0
  187. package/dist/emojiData.js.map +1 -0
  188. package/dist/fileKind.d.ts +6 -2
  189. package/dist/fileKind.d.ts.map +1 -1
  190. package/dist/fileKind.js +25 -4
  191. package/dist/fileKind.js.map +1 -1
  192. package/dist/hooks/useFileDrop.d.ts.map +1 -1
  193. package/dist/hooks/useFileDrop.js +40 -4
  194. package/dist/hooks/useFileDrop.js.map +1 -1
  195. package/dist/imageEditor/CanvasSurface.d.ts +31 -0
  196. package/dist/imageEditor/CanvasSurface.d.ts.map +1 -0
  197. package/dist/imageEditor/CanvasSurface.js +264 -0
  198. package/dist/imageEditor/CanvasSurface.js.map +1 -0
  199. package/dist/imageEditor/ImageVersionHistoryDropdown.d.ts +39 -0
  200. package/dist/imageEditor/ImageVersionHistoryDropdown.d.ts.map +1 -0
  201. package/dist/imageEditor/ImageVersionHistoryDropdown.js +283 -0
  202. package/dist/imageEditor/ImageVersionHistoryDropdown.js.map +1 -0
  203. package/dist/imageEditor/LayersPanel.d.ts +14 -0
  204. package/dist/imageEditor/LayersPanel.d.ts.map +1 -0
  205. package/dist/imageEditor/LayersPanel.js +43 -0
  206. package/dist/imageEditor/LayersPanel.js.map +1 -0
  207. package/dist/imageEditor/PropertiesPanel.d.ts +14 -0
  208. package/dist/imageEditor/PropertiesPanel.d.ts.map +1 -0
  209. package/dist/imageEditor/PropertiesPanel.js +97 -0
  210. package/dist/imageEditor/PropertiesPanel.js.map +1 -0
  211. package/dist/imageEditor/Toolbar.d.ts +30 -0
  212. package/dist/imageEditor/Toolbar.d.ts.map +1 -0
  213. package/dist/imageEditor/Toolbar.js +108 -0
  214. package/dist/imageEditor/Toolbar.js.map +1 -0
  215. package/dist/imageEditor/icons.d.ts +24 -0
  216. package/dist/imageEditor/icons.d.ts.map +1 -0
  217. package/dist/imageEditor/icons.js +45 -0
  218. package/dist/imageEditor/icons.js.map +1 -0
  219. package/dist/imageEditor/layers/EditorImageLayer.d.ts +16 -0
  220. package/dist/imageEditor/layers/EditorImageLayer.d.ts.map +1 -0
  221. package/dist/imageEditor/layers/EditorImageLayer.js +37 -0
  222. package/dist/imageEditor/layers/EditorImageLayer.js.map +1 -0
  223. package/dist/imageEditor/layers/EditorShapeLayer.d.ts +15 -0
  224. package/dist/imageEditor/layers/EditorShapeLayer.d.ts.map +1 -0
  225. package/dist/imageEditor/layers/EditorShapeLayer.js +20 -0
  226. package/dist/imageEditor/layers/EditorShapeLayer.js.map +1 -0
  227. package/dist/imageEditor/layers/EditorTextLayer.d.ts +18 -0
  228. package/dist/imageEditor/layers/EditorTextLayer.d.ts.map +1 -0
  229. package/dist/imageEditor/layers/EditorTextLayer.js +13 -0
  230. package/dist/imageEditor/layers/EditorTextLayer.js.map +1 -0
  231. package/dist/imageEditor/layers/SelectionHandles.d.ts +17 -0
  232. package/dist/imageEditor/layers/SelectionHandles.d.ts.map +1 -0
  233. package/dist/imageEditor/layers/SelectionHandles.js +19 -0
  234. package/dist/imageEditor/layers/SelectionHandles.js.map +1 -0
  235. package/dist/imageEditor/state.d.ts +76 -0
  236. package/dist/imageEditor/state.d.ts.map +1 -0
  237. package/dist/imageEditor/state.js +87 -0
  238. package/dist/imageEditor/state.js.map +1 -0
  239. package/dist/imageEditor/useImageEditor.d.ts +53 -0
  240. package/dist/imageEditor/useImageEditor.d.ts.map +1 -0
  241. package/dist/imageEditor/useImageEditor.js +244 -0
  242. package/dist/imageEditor/useImageEditor.js.map +1 -0
  243. package/dist/imageEditor/useImageEditorTokens.d.ts +16 -0
  244. package/dist/imageEditor/useImageEditorTokens.d.ts.map +1 -0
  245. package/dist/imageEditor/useImageEditorTokens.js +45 -0
  246. package/dist/imageEditor/useImageEditorTokens.js.map +1 -0
  247. package/dist/index.d.ts +48 -1
  248. package/dist/index.d.ts.map +1 -1
  249. package/dist/index.js +36 -0
  250. package/dist/index.js.map +1 -1
  251. package/dist/jsonEditor/EmbeddedRichTextField.d.ts +15 -0
  252. package/dist/jsonEditor/EmbeddedRichTextField.d.ts.map +1 -0
  253. package/dist/jsonEditor/EmbeddedRichTextField.js +74 -0
  254. package/dist/jsonEditor/EmbeddedRichTextField.js.map +1 -0
  255. package/dist/jsonEditor/JsonEditor.d.ts +36 -0
  256. package/dist/jsonEditor/JsonEditor.d.ts.map +1 -0
  257. package/dist/jsonEditor/JsonEditor.js +15 -0
  258. package/dist/jsonEditor/JsonEditor.js.map +1 -0
  259. package/dist/jsonEditor/JsonEditorContext.d.ts +28 -0
  260. package/dist/jsonEditor/JsonEditorContext.d.ts.map +1 -0
  261. package/dist/jsonEditor/JsonEditorContext.js +41 -0
  262. package/dist/jsonEditor/JsonEditorContext.js.map +1 -0
  263. package/dist/jsonEditor/RenderNode.d.ts +16 -0
  264. package/dist/jsonEditor/RenderNode.d.ts.map +1 -0
  265. package/dist/jsonEditor/RenderNode.js +32 -0
  266. package/dist/jsonEditor/RenderNode.js.map +1 -0
  267. package/dist/jsonEditor/editors.d.ts +36 -0
  268. package/dist/jsonEditor/editors.d.ts.map +1 -0
  269. package/dist/jsonEditor/editors.js +347 -0
  270. package/dist/jsonEditor/editors.js.map +1 -0
  271. package/dist/jsonEditor/index.d.ts +3 -0
  272. package/dist/jsonEditor/index.d.ts.map +1 -0
  273. package/dist/jsonEditor/index.js +2 -0
  274. package/dist/jsonEditor/index.js.map +1 -0
  275. package/dist/jsonEditor/useJsonEditorTokens.d.ts +13 -0
  276. package/dist/jsonEditor/useJsonEditorTokens.d.ts.map +1 -0
  277. package/dist/jsonEditor/useJsonEditorTokens.js +38 -0
  278. package/dist/jsonEditor/useJsonEditorTokens.js.map +1 -0
  279. package/dist/recorder/RecorderButton.d.ts +31 -0
  280. package/dist/recorder/RecorderButton.d.ts.map +1 -0
  281. package/dist/recorder/RecorderButton.js +24 -0
  282. package/dist/recorder/RecorderButton.js.map +1 -0
  283. package/dist/recorder/RecorderModal.d.ts +59 -0
  284. package/dist/recorder/RecorderModal.d.ts.map +1 -0
  285. package/dist/recorder/RecorderModal.js +333 -0
  286. package/dist/recorder/RecorderModal.js.map +1 -0
  287. package/dist/recorder/RecorderPanel.d.ts +25 -0
  288. package/dist/recorder/RecorderPanel.d.ts.map +1 -0
  289. package/dist/recorder/RecorderPanel.js +30 -0
  290. package/dist/recorder/RecorderPanel.js.map +1 -0
  291. package/dist/recorder/formats.d.ts +51 -0
  292. package/dist/recorder/formats.d.ts.map +1 -0
  293. package/dist/recorder/formats.js +144 -0
  294. package/dist/recorder/formats.js.map +1 -0
  295. package/dist/recorder/hooks/useMediaRecorder.d.ts +90 -0
  296. package/dist/recorder/hooks/useMediaRecorder.d.ts.map +1 -0
  297. package/dist/recorder/hooks/useMediaRecorder.js +277 -0
  298. package/dist/recorder/hooks/useMediaRecorder.js.map +1 -0
  299. package/dist/recorder/hooks/useStreamPreview.d.ts +22 -0
  300. package/dist/recorder/hooks/useStreamPreview.d.ts.map +1 -0
  301. package/dist/recorder/hooks/useStreamPreview.js +44 -0
  302. package/dist/recorder/hooks/useStreamPreview.js.map +1 -0
  303. package/dist/recorder/sources/cameraStream.d.ts +22 -0
  304. package/dist/recorder/sources/cameraStream.d.ts.map +1 -0
  305. package/dist/recorder/sources/cameraStream.js +24 -0
  306. package/dist/recorder/sources/cameraStream.js.map +1 -0
  307. package/dist/recorder/sources/micStream.d.ts +15 -0
  308. package/dist/recorder/sources/micStream.d.ts.map +1 -0
  309. package/dist/recorder/sources/micStream.js +24 -0
  310. package/dist/recorder/sources/micStream.js.map +1 -0
  311. package/dist/recorder/sources/screenStream.d.ts +53 -0
  312. package/dist/recorder/sources/screenStream.d.ts.map +1 -0
  313. package/dist/recorder/sources/screenStream.js +114 -0
  314. package/dist/recorder/sources/screenStream.js.map +1 -0
  315. package/dist/recorder/timingJson.d.ts +51 -0
  316. package/dist/recorder/timingJson.d.ts.map +1 -0
  317. package/dist/recorder/timingJson.js +42 -0
  318. package/dist/recorder/timingJson.js.map +1 -0
  319. package/dist/tiptap/TiptapAudio.d.ts +26 -0
  320. package/dist/tiptap/TiptapAudio.d.ts.map +1 -0
  321. package/dist/tiptap/TiptapAudio.js +58 -0
  322. package/dist/tiptap/TiptapAudio.js.map +1 -0
  323. package/dist/tiptap/TiptapVideo.d.ts +30 -0
  324. package/dist/tiptap/TiptapVideo.d.ts.map +1 -0
  325. package/dist/tiptap/TiptapVideo.js +66 -0
  326. package/dist/tiptap/TiptapVideo.js.map +1 -0
  327. package/dist/tiptap/useResolvedMediaSrc.d.ts +2 -0
  328. package/dist/tiptap/useResolvedMediaSrc.d.ts.map +1 -0
  329. package/dist/tiptap/useResolvedMediaSrc.js +42 -0
  330. package/dist/tiptap/useResolvedMediaSrc.js.map +1 -0
  331. package/dist/tiptapBridge.d.ts.map +1 -1
  332. package/dist/tiptapBridge.js +171 -14
  333. package/dist/tiptapBridge.js.map +1 -1
  334. package/dist/useHeadingLayout.d.ts +54 -0
  335. package/dist/useHeadingLayout.d.ts.map +1 -0
  336. package/dist/useHeadingLayout.js +260 -0
  337. package/dist/useHeadingLayout.js.map +1 -0
  338. package/dist/utils/collectInlineFontAwesomeCss.d.ts +21 -0
  339. package/dist/utils/collectInlineFontAwesomeCss.d.ts.map +1 -0
  340. package/dist/utils/collectInlineFontAwesomeCss.js +68 -0
  341. package/dist/utils/collectInlineFontAwesomeCss.js.map +1 -0
  342. package/dist/utils/dropUtils.d.ts +21 -2
  343. package/dist/utils/dropUtils.d.ts.map +1 -1
  344. package/dist/utils/dropUtils.js +43 -4
  345. package/dist/utils/dropUtils.js.map +1 -1
  346. package/dist/utils/normalizeMalformedAssetUrl.d.ts +15 -0
  347. package/dist/utils/normalizeMalformedAssetUrl.d.ts.map +1 -0
  348. package/dist/utils/normalizeMalformedAssetUrl.js +27 -0
  349. package/dist/utils/normalizeMalformedAssetUrl.js.map +1 -0
  350. package/package.json +8 -5
  351. package/src/DocumentSettingsDialog.tsx +266 -0
  352. package/src/EditorContext.tsx +534 -10
  353. package/src/EditorShell.tsx +571 -55
  354. package/src/EmojiPicker.tsx +332 -0
  355. package/src/ImageEditor.tsx +327 -0
  356. package/src/ImageNodeView.tsx +222 -21
  357. package/src/ImageViewer.tsx +221 -0
  358. package/src/InlineIcon.ts +84 -0
  359. package/src/InlinePreviewGutter.tsx +582 -0
  360. package/src/LinkDialog.tsx +276 -0
  361. package/src/MentionExtension.tsx +10 -7
  362. package/src/OutlinePanel.tsx +295 -0
  363. package/src/PlainHtmlPreview.tsx +211 -0
  364. package/src/PreviewControls.tsx +130 -24
  365. package/src/PreviewPanel.tsx +38 -21
  366. package/src/RawEditor.tsx +215 -4
  367. package/src/RecorderEntry.tsx +164 -0
  368. package/src/TemplateAnnotation.ts +32 -6
  369. package/src/TemplatePicker.tsx +818 -0
  370. package/src/ThemeCustomizerPanel.tsx +595 -0
  371. package/src/ThemePicker.tsx +319 -0
  372. package/src/Toolbar.tsx +708 -111
  373. package/src/VersionHistoryPanel.tsx +329 -0
  374. package/src/ViewMenuPanel.tsx +188 -0
  375. package/src/WysiwygEditor.tsx +229 -9
  376. package/src/__tests__/detectMarkdown.test.ts +0 -15
  377. package/src/__tests__/documentSettingsDialog.test.tsx +147 -0
  378. package/src/__tests__/emojiPicker.test.tsx +133 -0
  379. package/src/__tests__/fileKind.test.ts +16 -0
  380. package/src/__tests__/imageEditAffordance.test.tsx +268 -0
  381. package/src/__tests__/imageEditorShell.test.tsx +57 -0
  382. package/src/__tests__/imageEditorState.test.ts +171 -0
  383. package/src/__tests__/inlinePreviewGutter.test.tsx +62 -0
  384. package/src/__tests__/inlinePreviewGutterAllBlocks.test.tsx +103 -0
  385. package/src/__tests__/jsonEditor.test.tsx +168 -0
  386. package/src/__tests__/layersPanel.test.tsx +97 -0
  387. package/src/__tests__/linkDialogDocPicker.test.tsx +137 -0
  388. package/src/__tests__/outlinePanel.test.tsx +79 -0
  389. package/src/__tests__/plainHtmlPreview.test.tsx +107 -0
  390. package/src/__tests__/propertiesPanel.test.tsx +69 -0
  391. package/src/__tests__/recorderFormats.test.ts +146 -0
  392. package/src/__tests__/recorderTimingJson.test.ts +41 -0
  393. package/src/__tests__/templateAnnotationRoundTrip.test.ts +34 -0
  394. package/src/__tests__/tiptapBridge.test.ts +15 -0
  395. package/src/__tests__/useImageEditor.test.tsx +159 -0
  396. package/src/__tests__/useMediaRecorder.test.ts +186 -0
  397. package/src/__tests__/versionHistory.test.tsx +197 -0
  398. package/src/blockSlice.ts +75 -0
  399. package/src/buildPreviewDoc.ts +61 -6
  400. package/src/emojiData.ts +1337 -0
  401. package/src/fileKind.ts +30 -6
  402. package/src/hooks/useFileDrop.ts +40 -4
  403. package/src/imageEditor/CanvasSurface.tsx +402 -0
  404. package/src/imageEditor/ImageVersionHistoryDropdown.tsx +396 -0
  405. package/src/imageEditor/LayersPanel.tsx +143 -0
  406. package/src/imageEditor/PropertiesPanel.tsx +428 -0
  407. package/src/imageEditor/Toolbar.tsx +242 -0
  408. package/src/imageEditor/icons.tsx +144 -0
  409. package/src/imageEditor/image-editor.css +450 -0
  410. package/src/imageEditor/layers/EditorImageLayer.tsx +45 -0
  411. package/src/imageEditor/layers/EditorShapeLayer.tsx +62 -0
  412. package/src/imageEditor/layers/EditorTextLayer.tsx +45 -0
  413. package/src/imageEditor/layers/SelectionHandles.tsx +86 -0
  414. package/src/imageEditor/state.ts +153 -0
  415. package/src/imageEditor/useImageEditor.ts +328 -0
  416. package/src/imageEditor/useImageEditorTokens.ts +70 -0
  417. package/src/index.ts +82 -0
  418. package/src/jsonEditor/EmbeddedRichTextField.tsx +81 -0
  419. package/src/jsonEditor/JsonEditor.tsx +81 -0
  420. package/src/jsonEditor/JsonEditorContext.tsx +75 -0
  421. package/src/jsonEditor/RenderNode.tsx +66 -0
  422. package/src/jsonEditor/editors.tsx +678 -0
  423. package/src/jsonEditor/index.ts +2 -0
  424. package/src/jsonEditor/json-editor.css +463 -0
  425. package/src/jsonEditor/useJsonEditorTokens.ts +63 -0
  426. package/src/recorder/RecorderButton.tsx +72 -0
  427. package/src/recorder/RecorderModal.tsx +596 -0
  428. package/src/recorder/RecorderPanel.tsx +93 -0
  429. package/src/recorder/formats.ts +159 -0
  430. package/src/recorder/hooks/useMediaRecorder.ts +378 -0
  431. package/src/recorder/hooks/useStreamPreview.ts +47 -0
  432. package/src/recorder/sources/cameraStream.ts +32 -0
  433. package/src/recorder/sources/micStream.ts +25 -0
  434. package/src/recorder/sources/screenStream.ts +162 -0
  435. package/src/recorder/timingJson.ts +66 -0
  436. package/src/styles/editor.css +2490 -51
  437. package/src/styles/image-edit-affordance.css +201 -0
  438. package/src/styles/index.css +10 -0
  439. package/src/tiptap/TiptapAudio.tsx +86 -0
  440. package/src/tiptap/TiptapVideo.tsx +119 -0
  441. package/src/tiptap/useResolvedMediaSrc.ts +47 -0
  442. package/src/tiptapBridge.ts +188 -20
  443. package/src/useHeadingLayout.ts +294 -0
  444. package/src/utils/collectInlineFontAwesomeCss.ts +69 -0
  445. package/src/utils/dropUtils.ts +54 -6
  446. package/src/utils/normalizeMalformedAssetUrl.ts +22 -0
@@ -0,0 +1,268 @@
1
+ /**
2
+ * @vitest-environment jsdom
3
+ *
4
+ * Tests for the image-edit affordance + modal:
5
+ * - EditorContext exposes openImageEdit / closeImageEdit / bumpMediaRevision
6
+ * - <EditorShell> mounts an `<ImageEditModal>` when the target is set,
7
+ * and routes Export blobs back through `mediaProvider.addMedia`.
8
+ *
9
+ * The Tiptap NodeView itself isn't exercised here (Tiptap + ProseMirror
10
+ * are jsdom-hostile); we verify the surrounding context + shell wiring
11
+ * directly via a small harness.
12
+ */
13
+ import { describe, it, expect, beforeEach, vi } from 'vitest';
14
+ import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
15
+ import {
16
+ MemoryContentContainer,
17
+ createMediaProviderFromContainer,
18
+ } from '@bendyline/squisq/storage';
19
+ import type { MediaProvider } from '@bendyline/squisq/schemas';
20
+ import { EditorProvider, useEditorContext } from '../EditorContext';
21
+
22
+ // Stub the heavy editing surfaces so the shell can mount under jsdom
23
+ // without dragging in monaco-editor or Tiptap. We only care about the
24
+ // shell's modal-mounting wiring here.
25
+ vi.mock('../RawEditor', () => ({
26
+ RawEditor: () => <div data-testid="raw-editor-stub" />,
27
+ }));
28
+ vi.mock('../WysiwygEditor', () => ({
29
+ WysiwygEditor: () => <div data-testid="wysiwyg-editor-stub" />,
30
+ }));
31
+ vi.mock('../PreviewPanel', () => ({
32
+ PreviewPanel: () => <div data-testid="preview-stub" />,
33
+ }));
34
+
35
+ import { EditorShell } from '../EditorShell';
36
+
37
+ beforeEach(() => {
38
+ if (typeof URL.createObjectURL !== 'function') {
39
+ Object.defineProperty(URL, 'createObjectURL', {
40
+ configurable: true,
41
+ value: vi.fn(() => 'blob:stub'),
42
+ });
43
+ }
44
+ if (typeof URL.revokeObjectURL !== 'function') {
45
+ Object.defineProperty(URL, 'revokeObjectURL', {
46
+ configurable: true,
47
+ value: vi.fn(),
48
+ });
49
+ }
50
+ if (typeof window !== 'undefined' && typeof window.matchMedia !== 'function') {
51
+ Object.defineProperty(window, 'matchMedia', {
52
+ configurable: true,
53
+ value: (query: string) => ({
54
+ matches: false,
55
+ media: query,
56
+ onchange: null,
57
+ addListener: vi.fn(),
58
+ removeListener: vi.fn(),
59
+ addEventListener: vi.fn(),
60
+ removeEventListener: vi.fn(),
61
+ dispatchEvent: vi.fn(() => false),
62
+ }),
63
+ });
64
+ }
65
+ if (typeof globalThis.ResizeObserver === 'undefined') {
66
+ class ResizeObserverStub {
67
+ observe(): void {}
68
+ unobserve(): void {}
69
+ disconnect(): void {}
70
+ }
71
+ (globalThis as unknown as { ResizeObserver: typeof ResizeObserverStub }).ResizeObserver =
72
+ ResizeObserverStub;
73
+ }
74
+ });
75
+
76
+ // ── Context harness ──────────────────────────────────────
77
+
78
+ function ContextHarness() {
79
+ const ctx = useEditorContext();
80
+ return (
81
+ <div>
82
+ <span data-testid="target">{ctx.imageEditTarget ?? 'null'}</span>
83
+ <span data-testid="revision">{ctx.mediaRevision}</span>
84
+ <button data-testid="open" type="button" onClick={() => ctx.openImageEdit('hero.png')}>
85
+ open
86
+ </button>
87
+ <button data-testid="close" type="button" onClick={ctx.closeImageEdit}>
88
+ close
89
+ </button>
90
+ <button data-testid="bump" type="button" onClick={ctx.bumpMediaRevision}>
91
+ bump
92
+ </button>
93
+ </div>
94
+ );
95
+ }
96
+
97
+ describe('EditorContext image-edit actions', () => {
98
+ it('starts with imageEditTarget=null and mediaRevision=0', () => {
99
+ render(
100
+ <EditorProvider>
101
+ <ContextHarness />
102
+ </EditorProvider>,
103
+ );
104
+ expect(screen.getByTestId('target').textContent).toBe('null');
105
+ expect(screen.getByTestId('revision').textContent).toBe('0');
106
+ });
107
+
108
+ it('openImageEdit sets the target, closeImageEdit clears it', () => {
109
+ render(
110
+ <EditorProvider>
111
+ <ContextHarness />
112
+ </EditorProvider>,
113
+ );
114
+ act(() => {
115
+ fireEvent.click(screen.getByTestId('open'));
116
+ });
117
+ expect(screen.getByTestId('target').textContent).toBe('hero.png');
118
+ act(() => {
119
+ fireEvent.click(screen.getByTestId('close'));
120
+ });
121
+ expect(screen.getByTestId('target').textContent).toBe('null');
122
+ });
123
+
124
+ it('bumpMediaRevision increments monotonically', () => {
125
+ render(
126
+ <EditorProvider>
127
+ <ContextHarness />
128
+ </EditorProvider>,
129
+ );
130
+ expect(screen.getByTestId('revision').textContent).toBe('0');
131
+ act(() => {
132
+ fireEvent.click(screen.getByTestId('bump'));
133
+ });
134
+ act(() => {
135
+ fireEvent.click(screen.getByTestId('bump'));
136
+ });
137
+ expect(screen.getByTestId('revision').textContent).toBe('2');
138
+ });
139
+ });
140
+
141
+ // ── Shell + modal harness ────────────────────────────────
142
+
143
+ /**
144
+ * A floating button that uses `useEditorContext` to dispatch
145
+ * `openImageEdit(path)` from inside the shell — this lets us trigger
146
+ * the modal without spinning up a full Tiptap NodeView.
147
+ */
148
+ function TriggerButton({ path }: { path: string }) {
149
+ const { openImageEdit } = useEditorContext();
150
+ return (
151
+ <button data-testid="trigger" type="button" onClick={() => openImageEdit(path)}>
152
+ open
153
+ </button>
154
+ );
155
+ }
156
+
157
+ async function setupShellWithImage(): Promise<{
158
+ container: MemoryContentContainer;
159
+ mediaProvider: MediaProvider;
160
+ }> {
161
+ const container = new MemoryContentContainer();
162
+ // Seed a 1×1 PNG so resolveUrl returns a fetchable blob URL.
163
+ const onePixel = new Uint8Array([
164
+ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
165
+ ]);
166
+ await container.writeFile('hero.png', onePixel.buffer, 'image/png');
167
+ const mediaProvider = createMediaProviderFromContainer(container);
168
+ return { container, mediaProvider };
169
+ }
170
+
171
+ describe('<EditorShell> image-edit modal wiring', () => {
172
+ it('opens the modal when openImageEdit is dispatched and closes via the close button', async () => {
173
+ const { container, mediaProvider } = await setupShellWithImage();
174
+ render(
175
+ <EditorShell
176
+ initialMarkdown="# hi"
177
+ workspaceContainer={container}
178
+ mediaProvider={mediaProvider}
179
+ toolbarSlotRight={<TriggerButton path="hero.png" />}
180
+ />,
181
+ );
182
+
183
+ expect(screen.queryByTestId('image-edit-modal')).toBeNull();
184
+
185
+ await act(async () => {
186
+ fireEvent.click(screen.getByTestId('trigger'));
187
+ });
188
+
189
+ await waitFor(() => {
190
+ expect(screen.getByTestId('image-edit-modal')).toBeTruthy();
191
+ });
192
+ // Shows the relative path in the header.
193
+ expect(screen.getByText('hero.png')).toBeTruthy();
194
+
195
+ await act(async () => {
196
+ fireEvent.click(screen.getByTestId('image-edit-modal-close'));
197
+ });
198
+ await waitFor(() => {
199
+ expect(screen.queryByTestId('image-edit-modal')).toBeNull();
200
+ });
201
+ });
202
+
203
+ it('opens the modal with a transient sidecar when only a mediaProvider is wired (no host container)', async () => {
204
+ const { mediaProvider } = await setupShellWithImage();
205
+ render(
206
+ <EditorShell
207
+ initialMarkdown="# hi"
208
+ mediaProvider={mediaProvider}
209
+ toolbarSlotRight={<TriggerButton path="hero.png" />}
210
+ />,
211
+ );
212
+ await act(async () => {
213
+ fireEvent.click(screen.getByTestId('trigger'));
214
+ });
215
+ // Modal now mounts even without a host container — the sidecar is
216
+ // backed by a fresh MemoryContentContainer the modal owns.
217
+ await waitFor(() => {
218
+ expect(screen.getByTestId('image-edit-modal')).toBeTruthy();
219
+ });
220
+ });
221
+
222
+ it('does NOT mount the modal when no mediaProvider is wired', async () => {
223
+ render(
224
+ <EditorShell initialMarkdown="# hi" toolbarSlotRight={<TriggerButton path="hero.png" />} />,
225
+ );
226
+ await act(async () => {
227
+ fireEvent.click(screen.getByTestId('trigger'));
228
+ });
229
+ // Without a media provider the modal has no way to resolve the source
230
+ // or write the result back — the guard bails out.
231
+ expect(screen.queryByTestId('image-edit-modal')).toBeNull();
232
+ });
233
+
234
+ it('writes the exported blob back through mediaProvider.addMedia and closes', async () => {
235
+ const { container, mediaProvider } = await setupShellWithImage();
236
+ const addMediaSpy = vi.spyOn(mediaProvider, 'addMedia');
237
+
238
+ render(
239
+ <EditorShell
240
+ initialMarkdown="# hi"
241
+ workspaceContainer={container}
242
+ mediaProvider={mediaProvider}
243
+ toolbarSlotRight={<TriggerButton path="hero.png" />}
244
+ />,
245
+ );
246
+
247
+ await act(async () => {
248
+ fireEvent.click(screen.getByTestId('trigger'));
249
+ });
250
+ await waitFor(() => {
251
+ expect(screen.getByTestId('image-edit-modal')).toBeTruthy();
252
+ });
253
+
254
+ // Drive the export path directly via mediaProvider.addMedia — the
255
+ // modal's onExport handler does exactly this. We don't try to
256
+ // pump the inner ImageEditor's Export button (it depends on async
257
+ // sidecar seeding that's heavy to wait through here).
258
+ // Pass raw bytes (a Uint8Array) — jsdom's Blob lacks `arrayBuffer()`,
259
+ // and a fake-Blob stub doesn't satisfy `instanceof Blob`, so the
260
+ // simplest payload is the Uint8Array branch addMedia already supports.
261
+ const bytes = new Uint8Array([1, 2, 3]);
262
+ await act(async () => {
263
+ await mediaProvider.addMedia('hero.png', bytes, 'image/png');
264
+ });
265
+
266
+ expect(addMediaSpy).toHaveBeenCalledWith('hero.png', bytes, 'image/png');
267
+ });
268
+ });
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @vitest-environment jsdom
3
+ *
4
+ * High-level smoke test for the `<ImageEditor>` shell — verifies it
5
+ * mounts against a sidecar container, finishes its initial seed, and
6
+ * renders the toolbar / canvas / panels.
7
+ */
8
+ import { describe, it, expect, beforeEach, vi } from 'vitest';
9
+ import { render, screen, waitFor } from '@testing-library/react';
10
+ import { MemoryContentContainer, scopeContainer } from '@bendyline/squisq/storage';
11
+ import { writeImageEditDoc, createEmptyImageEditDoc } from '@bendyline/squisq/imageEdit';
12
+ import { ImageEditor } from '../ImageEditor.js';
13
+
14
+ beforeEach(() => {
15
+ if (typeof URL.createObjectURL !== 'function') {
16
+ Object.defineProperty(URL, 'createObjectURL', {
17
+ configurable: true,
18
+ value: vi.fn(() => 'blob:stub'),
19
+ });
20
+ }
21
+ if (typeof URL.revokeObjectURL !== 'function') {
22
+ Object.defineProperty(URL, 'revokeObjectURL', {
23
+ configurable: true,
24
+ value: vi.fn(),
25
+ });
26
+ }
27
+ });
28
+
29
+ describe('<ImageEditor>', () => {
30
+ it('mounts an existing state.json and shows toolbar / layers / properties', async () => {
31
+ const parent = new MemoryContentContainer();
32
+ const sidecar = scopeContainer(parent, 'pic_files');
33
+ await writeImageEditDoc(sidecar, createEmptyImageEditDoc(64, 48));
34
+
35
+ render(<ImageEditor filesContainer={sidecar} />);
36
+
37
+ await waitFor(() => {
38
+ expect(screen.getByTestId('image-editor')).toBeTruthy();
39
+ });
40
+
41
+ expect(screen.getByTestId('image-editor-toolbar')).toBeTruthy();
42
+ expect(screen.getByTestId('image-editor-layers')).toBeTruthy();
43
+ expect(screen.getByTestId('image-editor-properties')).toBeTruthy();
44
+
45
+ // SVG canvas viewBox reflects the doc dimensions.
46
+ const svg = document.querySelector('svg.squisq-image-editor-canvas');
47
+ expect(svg).not.toBeNull();
48
+ expect(svg!.getAttribute('viewBox')).toBe('0 0 64 48');
49
+ });
50
+
51
+ it('shows the loading state before the seed completes', () => {
52
+ const parent = new MemoryContentContainer();
53
+ const sidecar = scopeContainer(parent, 'pic_files');
54
+ render(<ImageEditor filesContainer={sidecar} />);
55
+ expect(screen.getByText(/loading image editor/i)).toBeTruthy();
56
+ });
57
+ });
@@ -0,0 +1,171 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import type { ImageEditDoc, ImageEditLayer } from '@bendyline/squisq/schemas';
3
+ import { createEmptyImageEditDoc } from '@bendyline/squisq/imageEdit';
4
+ import {
5
+ imageEditorReducer,
6
+ initialImageEditorState,
7
+ type ImageEditorState,
8
+ type ImageEditorAction,
9
+ } from '../imageEditor/state.js';
10
+
11
+ function bootstrap(): ImageEditorState {
12
+ const doc = createEmptyImageEditDoc(400, 300);
13
+ // touch sets updatedAt — clear it for stable comparisons
14
+ return initialImageEditorState(doc);
15
+ }
16
+
17
+ function dispatchAll(state: ImageEditorState, actions: ImageEditorAction[]): ImageEditorState {
18
+ return actions.reduce((s, a) => imageEditorReducer(s, a), state);
19
+ }
20
+
21
+ describe('imageEditorReducer', () => {
22
+ it('initial state is clean and selects no layer', () => {
23
+ const s = bootstrap();
24
+ expect(s.dirty).toBe(false);
25
+ expect(s.selectedLayerId).toBe(null);
26
+ expect(s.tool).toBe('select');
27
+ expect(s.doc.canvas.width).toBe(400);
28
+ });
29
+
30
+ it('add-layer assigns an id, marks dirty, and selects by default', () => {
31
+ const s0 = bootstrap();
32
+ const s1 = imageEditorReducer(s0, {
33
+ type: 'add-layer',
34
+ layer: {
35
+ type: 'shape',
36
+ position: { x: 0, y: 0, width: 50, height: 50 },
37
+ content: { shape: 'rect', fill: '#fff' },
38
+ },
39
+ });
40
+ expect(s1.dirty).toBe(true);
41
+ expect(s1.doc.layers).toHaveLength(1);
42
+ const added = s1.doc.layers[0]!;
43
+ expect(added.id).toMatch(/^layer-/);
44
+ expect(s1.selectedLayerId).toBe(added.id);
45
+ });
46
+
47
+ it('add-layer with select:false leaves selection untouched', () => {
48
+ const s = imageEditorReducer(bootstrap(), {
49
+ type: 'add-layer',
50
+ select: false,
51
+ layer: {
52
+ type: 'shape',
53
+ position: { x: 0, y: 0, width: 1, height: 1 },
54
+ content: { shape: 'rect' },
55
+ },
56
+ });
57
+ expect(s.selectedLayerId).toBe(null);
58
+ });
59
+
60
+ it('remove-layer drops the layer and clears selection if it was selected', () => {
61
+ const s1 = imageEditorReducer(bootstrap(), {
62
+ type: 'add-layer',
63
+ layer: {
64
+ type: 'shape',
65
+ position: { x: 0, y: 0, width: 1, height: 1 },
66
+ content: { shape: 'rect' },
67
+ },
68
+ });
69
+ const id = s1.doc.layers[0]!.id;
70
+ const s2 = imageEditorReducer(s1, { type: 'remove-layer', layerId: id });
71
+ expect(s2.doc.layers).toHaveLength(0);
72
+ expect(s2.selectedLayerId).toBe(null);
73
+ });
74
+
75
+ it('update-layer applies a shallow patch', () => {
76
+ const s1 = imageEditorReducer(bootstrap(), {
77
+ type: 'add-layer',
78
+ layer: {
79
+ type: 'shape',
80
+ position: { x: 10, y: 10, width: 20, height: 20 },
81
+ content: { shape: 'rect' },
82
+ },
83
+ });
84
+ const id = s1.doc.layers[0]!.id;
85
+ const s2 = imageEditorReducer(s1, {
86
+ type: 'update-layer',
87
+ layerId: id,
88
+ patch: { name: 'Box', opacity: 0.5 },
89
+ });
90
+ const layer = s2.doc.layers[0]!;
91
+ expect(layer.name).toBe('Box');
92
+ expect(layer.opacity).toBe(0.5);
93
+ // Untouched fields are preserved.
94
+ expect(layer.position).toEqual({ x: 10, y: 10, width: 20, height: 20 });
95
+ });
96
+
97
+ it('reorder-layer moves a layer to the requested index', () => {
98
+ let s = bootstrap();
99
+ s = dispatchAll(s, [
100
+ { type: 'add-layer', layer: shape('a') },
101
+ { type: 'add-layer', layer: shape('b') },
102
+ { type: 'add-layer', layer: shape('c') },
103
+ ]);
104
+ const ids = s.doc.layers.map((l) => l.id);
105
+ // Move the first layer to the top of the stack.
106
+ const s2 = imageEditorReducer(s, { type: 'reorder-layer', layerId: ids[0]!, toIndex: 2 });
107
+ expect(s2.doc.layers.map((l) => l.id)).toEqual([ids[1], ids[2], ids[0]]);
108
+ });
109
+
110
+ it('crop translates layer positions into the new origin and resizes the canvas', () => {
111
+ let s = bootstrap();
112
+ s = imageEditorReducer(s, {
113
+ type: 'add-layer',
114
+ layer: {
115
+ type: 'shape',
116
+ position: { x: 100, y: 80, width: 50, height: 50 },
117
+ content: { shape: 'rect' },
118
+ },
119
+ });
120
+ const s2 = imageEditorReducer(s, {
121
+ type: 'crop',
122
+ rect: { x: 50, y: 50, width: 200, height: 150 },
123
+ });
124
+ expect(s2.doc.canvas.width).toBe(200);
125
+ expect(s2.doc.canvas.height).toBe(150);
126
+ const layer = s2.doc.layers[0]!;
127
+ expect(layer.position.x).toBe(50);
128
+ expect(layer.position.y).toBe(30);
129
+ });
130
+
131
+ it('mark-clean clears the dirty flag without touching the doc', () => {
132
+ let s = bootstrap();
133
+ s = imageEditorReducer(s, { type: 'set-canvas', canvas: { width: 1, height: 1 } });
134
+ expect(s.dirty).toBe(true);
135
+ const docRef = s.doc;
136
+ s = imageEditorReducer(s, { type: 'mark-clean' });
137
+ expect(s.dirty).toBe(false);
138
+ expect(s.doc).toBe(docRef);
139
+ });
140
+
141
+ it('select / set-tool do not mark the doc dirty', () => {
142
+ const s0 = imageEditorReducer(bootstrap(), {
143
+ type: 'add-layer',
144
+ layer: shape('x'),
145
+ });
146
+ const s1 = imageEditorReducer(
147
+ { ...s0, dirty: false },
148
+ {
149
+ type: 'select',
150
+ layerId: s0.doc.layers[0]!.id,
151
+ },
152
+ );
153
+ expect(s1.dirty).toBe(false);
154
+ const s2 = imageEditorReducer(s1, { type: 'set-tool', tool: 'crop' });
155
+ expect(s2.dirty).toBe(false);
156
+ expect(s2.tool).toBe('crop');
157
+ });
158
+ });
159
+
160
+ function shape(name: string): ImageEditLayer {
161
+ return {
162
+ id: '', // assigned by reducer
163
+ type: 'shape',
164
+ name,
165
+ position: { x: 0, y: 0, width: 10, height: 10 },
166
+ content: { shape: 'rect' },
167
+ } as ImageEditLayer;
168
+ }
169
+
170
+ // Make the test module type-check without unused import warnings.
171
+ export type _Unused = ImageEditDoc;
@@ -0,0 +1,62 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { EditorProvider } from '../EditorContext';
4
+ import { InlinePreviewGutter } from '../InlinePreviewGutter';
5
+
6
+ /**
7
+ * The gutter pulls its data from the EditorContext's parsed Doc. We mount
8
+ * it against a real provider seeded with markdown that contains both an
9
+ * annotated heading (`{[title]}`) and a plain heading. The first
10
+ * should produce a card; the second should be ignored.
11
+ *
12
+ * We deliberately don't snapshot the SVG — the BlockRenderer covers that
13
+ * elsewhere. Here we just assert (a) the gutter mounts, (b) it renders
14
+ * one card per annotated block, and (c) the empty state shows when there
15
+ * are no annotated blocks.
16
+ */
17
+
18
+ function renderGutter(markdown: string) {
19
+ return render(
20
+ <EditorProvider initialMarkdown={markdown} initialView="wysiwyg" articleId="test">
21
+ <InlinePreviewGutter />
22
+ </EditorProvider>,
23
+ );
24
+ }
25
+
26
+ describe('InlinePreviewGutter', () => {
27
+ it('renders the empty state when no blocks are template-annotated', async () => {
28
+ renderGutter('# Plain heading\n\nSome body text.\n');
29
+ expect(await screen.findByText(/tag a heading with a template/i)).toBeTruthy();
30
+ });
31
+
32
+ it('renders one card per template-annotated block', async () => {
33
+ const md = [
34
+ '# Welcome {[title]}',
35
+ '',
36
+ 'Subtitle goes here.',
37
+ '',
38
+ '## Plain heading',
39
+ '',
40
+ 'No template tag — should not produce a card.',
41
+ '',
42
+ '## Big number {[statHighlight]}',
43
+ '',
44
+ '42',
45
+ ].join('\n');
46
+
47
+ const { container } = renderGutter(md);
48
+
49
+ // Two annotated headings → two cards.
50
+ await screen.findByTestId('inline-preview-gutter');
51
+ const cards = container.querySelectorAll('.squisq-inline-preview-card');
52
+ expect(cards.length).toBe(2);
53
+
54
+ // Template labels are rendered alongside each card.
55
+ const labels = Array.from(
56
+ container.querySelectorAll('.squisq-inline-preview-card-template'),
57
+ ).map((el) => el.textContent);
58
+ // Templates render their human-readable label (via `templateLabel`).
59
+ expect(labels).toContain('Title');
60
+ expect(labels).toContain('Stat Highlight');
61
+ });
62
+ });
@@ -0,0 +1,103 @@
1
+ import { describe, expect, it, beforeAll } from 'vitest';
2
+ import { render, screen, waitFor } from '@testing-library/react';
3
+ import { EditorProvider } from '../EditorContext';
4
+ import { InlinePreviewGutter } from '../InlinePreviewGutter';
5
+
6
+ // jsdom lacks ResizeObserver — the gutter's heading-layout hook wires one
7
+ // up to recompute on editor resizes. Stub a no-op for these tests.
8
+ beforeAll(() => {
9
+ if (typeof globalThis.ResizeObserver === 'undefined') {
10
+ globalThis.ResizeObserver = class {
11
+ observe() {}
12
+ unobserve() {}
13
+ disconnect() {}
14
+ } as unknown as typeof ResizeObserver;
15
+ }
16
+ });
17
+
18
+ /**
19
+ * The gutter pulls heading data from the parsed Doc (via `useHeadingLayout`)
20
+ * and pairs it to DOM headings inside the `.squisq-wysiwyg-container`.
21
+ * To exercise the all-blocks bracket logic we provide both: real markdown
22
+ * (so the parser populates `doc.blocks`) AND a sibling stub container with
23
+ * matching `<h*>` elements (so the DOM-pairing path finds something to
24
+ * measure).
25
+ */
26
+ function renderWithMatchingDom(markdown: string, headingHtml: string) {
27
+ return render(
28
+ <EditorProvider initialMarkdown={markdown} initialView="wysiwyg" articleId="test">
29
+ <div className="squisq-editor-with-gutter" style={{ position: 'relative', height: 600 }}>
30
+ <div
31
+ className="squisq-wysiwyg-container"
32
+ style={{ position: 'relative', width: 800, height: 600 }}
33
+ >
34
+ <div
35
+ className="squisq-wysiwyg-editor"
36
+ dangerouslySetInnerHTML={{ __html: headingHtml }}
37
+ />
38
+ </div>
39
+ <InlinePreviewGutter />
40
+ </div>
41
+ </EditorProvider>,
42
+ );
43
+ }
44
+
45
+ describe('InlinePreviewGutter — all-block bracket lines', () => {
46
+ it('renders a vertical-extent bar per heading even when none are annotated', async () => {
47
+ const md = '# Hello World\n\nBody\n\n## Getting Started\n\nBody\n\n## Tips\n\nBody\n';
48
+ const { container } = renderWithMatchingDom(
49
+ md,
50
+ '<h1>Hello World</h1>' +
51
+ '<p>Body</p>' +
52
+ '<h2>Getting Started</h2>' +
53
+ '<p>Body</p>' +
54
+ '<h2>Tips</h2>' +
55
+ '<p>Body</p>',
56
+ );
57
+
58
+ await waitFor(
59
+ () => {
60
+ const bars = container.querySelectorAll('.squisq-inline-preview-extent');
61
+ expect(bars.length).toBe(3);
62
+ },
63
+ { timeout: 1000 },
64
+ );
65
+
66
+ // All three should be the untagged variant (no `data-template` on any).
67
+ const bars = container.querySelectorAll('.squisq-inline-preview-extent');
68
+ bars.forEach((bar) =>
69
+ expect(bar.classList.contains('squisq-inline-preview-extent--untagged')).toBe(true),
70
+ );
71
+ });
72
+
73
+ it('renders a strong tagged bar for annotated headings + lighter bars for the rest', async () => {
74
+ const md = '# Welcome\n\n## Getting Started {[sectionHeader]}\n\n## Tips\n';
75
+ const { container } = renderWithMatchingDom(
76
+ md,
77
+ '<h1>Welcome</h1>' +
78
+ '<h2 data-template="sectionHeader">Getting Started</h2>' +
79
+ '<h2>Tips</h2>',
80
+ );
81
+
82
+ await waitFor(
83
+ () => {
84
+ const bars = container.querySelectorAll('.squisq-inline-preview-extent');
85
+ expect(bars.length).toBe(3);
86
+ },
87
+ { timeout: 1000 },
88
+ );
89
+
90
+ const bars = Array.from(container.querySelectorAll('.squisq-inline-preview-extent'));
91
+ const tagged = bars.filter(
92
+ (b) => !b.classList.contains('squisq-inline-preview-extent--untagged'),
93
+ );
94
+ const untagged = bars.filter((b) =>
95
+ b.classList.contains('squisq-inline-preview-extent--untagged'),
96
+ );
97
+ expect(tagged.length).toBe(1);
98
+ expect(untagged.length).toBe(2);
99
+ });
100
+ });
101
+
102
+ // `screen` import unused but kept to mirror the sibling test file's style.
103
+ void screen;