@bendyline/squisq-editor-react 1.3.0 → 1.5.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 (461) 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 +184 -4
  10. package/dist/EditorShell.d.ts.map +1 -1
  11. package/dist/EditorShell.js +184 -12
  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/MediaBin.d.ts +12 -1
  42. package/dist/MediaBin.d.ts.map +1 -1
  43. package/dist/MediaBin.js +13 -3
  44. package/dist/MediaBin.js.map +1 -1
  45. package/dist/MentionExtension.js +10 -7
  46. package/dist/MentionExtension.js.map +1 -1
  47. package/dist/OutlinePanel.d.ts +17 -0
  48. package/dist/OutlinePanel.d.ts.map +1 -0
  49. package/dist/OutlinePanel.js +167 -0
  50. package/dist/OutlinePanel.js.map +1 -0
  51. package/dist/PlainHtmlPreview.d.ts +50 -0
  52. package/dist/PlainHtmlPreview.d.ts.map +1 -0
  53. package/dist/PlainHtmlPreview.js +155 -0
  54. package/dist/PlainHtmlPreview.js.map +1 -0
  55. package/dist/PreviewControls.d.ts +15 -1
  56. package/dist/PreviewControls.d.ts.map +1 -1
  57. package/dist/PreviewControls.js +75 -18
  58. package/dist/PreviewControls.js.map +1 -1
  59. package/dist/PreviewPanel.d.ts +11 -10
  60. package/dist/PreviewPanel.d.ts.map +1 -1
  61. package/dist/PreviewPanel.js +20 -17
  62. package/dist/PreviewPanel.js.map +1 -1
  63. package/dist/RawEditor.d.ts.map +1 -1
  64. package/dist/RawEditor.js +198 -4
  65. package/dist/RawEditor.js.map +1 -1
  66. package/dist/RecorderEntry.d.ts +24 -0
  67. package/dist/RecorderEntry.d.ts.map +1 -0
  68. package/dist/RecorderEntry.js +139 -0
  69. package/dist/RecorderEntry.js.map +1 -0
  70. package/dist/TemplateAnnotation.d.ts.map +1 -1
  71. package/dist/TemplateAnnotation.js +32 -6
  72. package/dist/TemplateAnnotation.js.map +1 -1
  73. package/dist/TemplatePicker.d.ts +53 -0
  74. package/dist/TemplatePicker.d.ts.map +1 -0
  75. package/dist/TemplatePicker.js +388 -0
  76. package/dist/TemplatePicker.js.map +1 -0
  77. package/dist/ThemeCustomizerPanel.d.ts +32 -0
  78. package/dist/ThemeCustomizerPanel.d.ts.map +1 -0
  79. package/dist/ThemeCustomizerPanel.js +256 -0
  80. package/dist/ThemeCustomizerPanel.js.map +1 -0
  81. package/dist/ThemePicker.d.ts +33 -0
  82. package/dist/ThemePicker.d.ts.map +1 -0
  83. package/dist/ThemePicker.js +148 -0
  84. package/dist/ThemePicker.js.map +1 -0
  85. package/dist/Toolbar.d.ts.map +1 -1
  86. package/dist/Toolbar.js +508 -33
  87. package/dist/Toolbar.js.map +1 -1
  88. package/dist/VersionHistoryPanel.d.ts +14 -0
  89. package/dist/VersionHistoryPanel.d.ts.map +1 -0
  90. package/dist/VersionHistoryPanel.js +147 -0
  91. package/dist/VersionHistoryPanel.js.map +1 -0
  92. package/dist/ViewMenuPanel.d.ts +13 -0
  93. package/dist/ViewMenuPanel.d.ts.map +1 -0
  94. package/dist/ViewMenuPanel.js +58 -0
  95. package/dist/ViewMenuPanel.js.map +1 -0
  96. package/dist/WysiwygEditor.d.ts.map +1 -1
  97. package/dist/WysiwygEditor.js +198 -9
  98. package/dist/WysiwygEditor.js.map +1 -1
  99. package/dist/__tests__/detectMarkdown.test.js +0 -14
  100. package/dist/__tests__/detectMarkdown.test.js.map +1 -1
  101. package/dist/__tests__/documentSettingsDialog.test.d.ts +2 -0
  102. package/dist/__tests__/documentSettingsDialog.test.d.ts.map +1 -0
  103. package/dist/__tests__/documentSettingsDialog.test.js +132 -0
  104. package/dist/__tests__/documentSettingsDialog.test.js.map +1 -0
  105. package/dist/__tests__/emojiPicker.test.d.ts +2 -0
  106. package/dist/__tests__/emojiPicker.test.d.ts.map +1 -0
  107. package/dist/__tests__/emojiPicker.test.js +111 -0
  108. package/dist/__tests__/emojiPicker.test.js.map +1 -0
  109. package/dist/__tests__/fileKind.test.js +13 -0
  110. package/dist/__tests__/fileKind.test.js.map +1 -1
  111. package/dist/__tests__/imageEditAffordance.test.d.ts +2 -0
  112. package/dist/__tests__/imageEditAffordance.test.d.ts.map +1 -0
  113. package/dist/__tests__/imageEditAffordance.test.js +188 -0
  114. package/dist/__tests__/imageEditAffordance.test.js.map +1 -0
  115. package/dist/__tests__/imageEditorShell.test.d.ts +2 -0
  116. package/dist/__tests__/imageEditorShell.test.d.ts.map +1 -0
  117. package/dist/__tests__/imageEditorShell.test.js +52 -0
  118. package/dist/__tests__/imageEditorShell.test.js.map +1 -0
  119. package/dist/__tests__/imageEditorState.test.d.ts +3 -0
  120. package/dist/__tests__/imageEditorState.test.d.ts.map +1 -0
  121. package/dist/__tests__/imageEditorState.test.js +148 -0
  122. package/dist/__tests__/imageEditorState.test.js.map +1 -0
  123. package/dist/__tests__/inlinePreviewGutter.test.d.ts +2 -0
  124. package/dist/__tests__/inlinePreviewGutter.test.d.ts.map +1 -0
  125. package/dist/__tests__/inlinePreviewGutter.test.js +51 -0
  126. package/dist/__tests__/inlinePreviewGutter.test.js.map +1 -0
  127. package/dist/__tests__/inlinePreviewGutterAllBlocks.test.d.ts +2 -0
  128. package/dist/__tests__/inlinePreviewGutterAllBlocks.test.d.ts.map +1 -0
  129. package/dist/__tests__/inlinePreviewGutterAllBlocks.test.js +63 -0
  130. package/dist/__tests__/inlinePreviewGutterAllBlocks.test.js.map +1 -0
  131. package/dist/__tests__/jsonEditor.test.d.ts +2 -0
  132. package/dist/__tests__/jsonEditor.test.d.ts.map +1 -0
  133. package/dist/__tests__/jsonEditor.test.js +134 -0
  134. package/dist/__tests__/jsonEditor.test.js.map +1 -0
  135. package/dist/__tests__/layersPanel.test.d.ts +2 -0
  136. package/dist/__tests__/layersPanel.test.d.ts.map +1 -0
  137. package/dist/__tests__/layersPanel.test.js +84 -0
  138. package/dist/__tests__/layersPanel.test.js.map +1 -0
  139. package/dist/__tests__/linkDialogDocPicker.test.d.ts +7 -0
  140. package/dist/__tests__/linkDialogDocPicker.test.d.ts.map +1 -0
  141. package/dist/__tests__/linkDialogDocPicker.test.js +75 -0
  142. package/dist/__tests__/linkDialogDocPicker.test.js.map +1 -0
  143. package/dist/__tests__/mediaAttachmentFlow.test.d.ts +2 -0
  144. package/dist/__tests__/mediaAttachmentFlow.test.d.ts.map +1 -0
  145. package/dist/__tests__/mediaAttachmentFlow.test.js +99 -0
  146. package/dist/__tests__/mediaAttachmentFlow.test.js.map +1 -0
  147. package/dist/__tests__/outlinePanel.test.d.ts +2 -0
  148. package/dist/__tests__/outlinePanel.test.d.ts.map +1 -0
  149. package/dist/__tests__/outlinePanel.test.js +68 -0
  150. package/dist/__tests__/outlinePanel.test.js.map +1 -0
  151. package/dist/__tests__/plainHtmlPreview.test.d.ts +2 -0
  152. package/dist/__tests__/plainHtmlPreview.test.d.ts.map +1 -0
  153. package/dist/__tests__/plainHtmlPreview.test.js +87 -0
  154. package/dist/__tests__/plainHtmlPreview.test.js.map +1 -0
  155. package/dist/__tests__/propertiesPanel.test.d.ts +2 -0
  156. package/dist/__tests__/propertiesPanel.test.d.ts.map +1 -0
  157. package/dist/__tests__/propertiesPanel.test.js +64 -0
  158. package/dist/__tests__/propertiesPanel.test.js.map +1 -0
  159. package/dist/__tests__/recorderFormats.test.d.ts +2 -0
  160. package/dist/__tests__/recorderFormats.test.d.ts.map +1 -0
  161. package/dist/__tests__/recorderFormats.test.js +121 -0
  162. package/dist/__tests__/recorderFormats.test.js.map +1 -0
  163. package/dist/__tests__/recorderTimingJson.test.d.ts +2 -0
  164. package/dist/__tests__/recorderTimingJson.test.d.ts.map +1 -0
  165. package/dist/__tests__/recorderTimingJson.test.js +37 -0
  166. package/dist/__tests__/recorderTimingJson.test.js.map +1 -0
  167. package/dist/__tests__/templateAnnotationRoundTrip.test.d.ts +2 -0
  168. package/dist/__tests__/templateAnnotationRoundTrip.test.d.ts.map +1 -0
  169. package/dist/__tests__/templateAnnotationRoundTrip.test.js +31 -0
  170. package/dist/__tests__/templateAnnotationRoundTrip.test.js.map +1 -0
  171. package/dist/__tests__/tiptapBridge.test.js +26 -0
  172. package/dist/__tests__/tiptapBridge.test.js.map +1 -1
  173. package/dist/__tests__/tiptapImageRoundTrip.test.d.ts +2 -0
  174. package/dist/__tests__/tiptapImageRoundTrip.test.d.ts.map +1 -0
  175. package/dist/__tests__/tiptapImageRoundTrip.test.js +68 -0
  176. package/dist/__tests__/tiptapImageRoundTrip.test.js.map +1 -0
  177. package/dist/__tests__/useImageEditor.test.d.ts +2 -0
  178. package/dist/__tests__/useImageEditor.test.d.ts.map +1 -0
  179. package/dist/__tests__/useImageEditor.test.js +131 -0
  180. package/dist/__tests__/useImageEditor.test.js.map +1 -0
  181. package/dist/__tests__/useMediaRecorder.test.d.ts +2 -0
  182. package/dist/__tests__/useMediaRecorder.test.d.ts.map +1 -0
  183. package/dist/__tests__/useMediaRecorder.test.js +153 -0
  184. package/dist/__tests__/useMediaRecorder.test.js.map +1 -0
  185. package/dist/__tests__/versionHistory.test.d.ts +2 -0
  186. package/dist/__tests__/versionHistory.test.d.ts.map +1 -0
  187. package/dist/__tests__/versionHistory.test.js +124 -0
  188. package/dist/__tests__/versionHistory.test.js.map +1 -0
  189. package/dist/blockSlice.d.ts +24 -0
  190. package/dist/blockSlice.d.ts.map +1 -0
  191. package/dist/blockSlice.js +63 -0
  192. package/dist/blockSlice.js.map +1 -0
  193. package/dist/buildPreviewDoc.d.ts.map +1 -1
  194. package/dist/buildPreviewDoc.js +52 -2
  195. package/dist/buildPreviewDoc.js.map +1 -1
  196. package/dist/emojiData.d.ts +81 -0
  197. package/dist/emojiData.d.ts.map +1 -0
  198. package/dist/emojiData.js +1283 -0
  199. package/dist/emojiData.js.map +1 -0
  200. package/dist/fileKind.d.ts +6 -2
  201. package/dist/fileKind.d.ts.map +1 -1
  202. package/dist/fileKind.js +25 -4
  203. package/dist/fileKind.js.map +1 -1
  204. package/dist/hooks/useFileDrop.d.ts.map +1 -1
  205. package/dist/hooks/useFileDrop.js +40 -4
  206. package/dist/hooks/useFileDrop.js.map +1 -1
  207. package/dist/imageEditor/CanvasSurface.d.ts +31 -0
  208. package/dist/imageEditor/CanvasSurface.d.ts.map +1 -0
  209. package/dist/imageEditor/CanvasSurface.js +264 -0
  210. package/dist/imageEditor/CanvasSurface.js.map +1 -0
  211. package/dist/imageEditor/ImageVersionHistoryDropdown.d.ts +39 -0
  212. package/dist/imageEditor/ImageVersionHistoryDropdown.d.ts.map +1 -0
  213. package/dist/imageEditor/ImageVersionHistoryDropdown.js +283 -0
  214. package/dist/imageEditor/ImageVersionHistoryDropdown.js.map +1 -0
  215. package/dist/imageEditor/LayersPanel.d.ts +14 -0
  216. package/dist/imageEditor/LayersPanel.d.ts.map +1 -0
  217. package/dist/imageEditor/LayersPanel.js +43 -0
  218. package/dist/imageEditor/LayersPanel.js.map +1 -0
  219. package/dist/imageEditor/PropertiesPanel.d.ts +14 -0
  220. package/dist/imageEditor/PropertiesPanel.d.ts.map +1 -0
  221. package/dist/imageEditor/PropertiesPanel.js +97 -0
  222. package/dist/imageEditor/PropertiesPanel.js.map +1 -0
  223. package/dist/imageEditor/Toolbar.d.ts +30 -0
  224. package/dist/imageEditor/Toolbar.d.ts.map +1 -0
  225. package/dist/imageEditor/Toolbar.js +108 -0
  226. package/dist/imageEditor/Toolbar.js.map +1 -0
  227. package/dist/imageEditor/icons.d.ts +24 -0
  228. package/dist/imageEditor/icons.d.ts.map +1 -0
  229. package/dist/imageEditor/icons.js +45 -0
  230. package/dist/imageEditor/icons.js.map +1 -0
  231. package/dist/imageEditor/layers/EditorImageLayer.d.ts +16 -0
  232. package/dist/imageEditor/layers/EditorImageLayer.d.ts.map +1 -0
  233. package/dist/imageEditor/layers/EditorImageLayer.js +37 -0
  234. package/dist/imageEditor/layers/EditorImageLayer.js.map +1 -0
  235. package/dist/imageEditor/layers/EditorShapeLayer.d.ts +15 -0
  236. package/dist/imageEditor/layers/EditorShapeLayer.d.ts.map +1 -0
  237. package/dist/imageEditor/layers/EditorShapeLayer.js +20 -0
  238. package/dist/imageEditor/layers/EditorShapeLayer.js.map +1 -0
  239. package/dist/imageEditor/layers/EditorTextLayer.d.ts +18 -0
  240. package/dist/imageEditor/layers/EditorTextLayer.d.ts.map +1 -0
  241. package/dist/imageEditor/layers/EditorTextLayer.js +13 -0
  242. package/dist/imageEditor/layers/EditorTextLayer.js.map +1 -0
  243. package/dist/imageEditor/layers/SelectionHandles.d.ts +17 -0
  244. package/dist/imageEditor/layers/SelectionHandles.d.ts.map +1 -0
  245. package/dist/imageEditor/layers/SelectionHandles.js +19 -0
  246. package/dist/imageEditor/layers/SelectionHandles.js.map +1 -0
  247. package/dist/imageEditor/state.d.ts +76 -0
  248. package/dist/imageEditor/state.d.ts.map +1 -0
  249. package/dist/imageEditor/state.js +87 -0
  250. package/dist/imageEditor/state.js.map +1 -0
  251. package/dist/imageEditor/useImageEditor.d.ts +53 -0
  252. package/dist/imageEditor/useImageEditor.d.ts.map +1 -0
  253. package/dist/imageEditor/useImageEditor.js +244 -0
  254. package/dist/imageEditor/useImageEditor.js.map +1 -0
  255. package/dist/imageEditor/useImageEditorTokens.d.ts +16 -0
  256. package/dist/imageEditor/useImageEditorTokens.d.ts.map +1 -0
  257. package/dist/imageEditor/useImageEditorTokens.js +45 -0
  258. package/dist/imageEditor/useImageEditorTokens.js.map +1 -0
  259. package/dist/index.d.ts +48 -1
  260. package/dist/index.d.ts.map +1 -1
  261. package/dist/index.js +36 -0
  262. package/dist/index.js.map +1 -1
  263. package/dist/jsonEditor/EmbeddedRichTextField.d.ts +15 -0
  264. package/dist/jsonEditor/EmbeddedRichTextField.d.ts.map +1 -0
  265. package/dist/jsonEditor/EmbeddedRichTextField.js +74 -0
  266. package/dist/jsonEditor/EmbeddedRichTextField.js.map +1 -0
  267. package/dist/jsonEditor/JsonEditor.d.ts +36 -0
  268. package/dist/jsonEditor/JsonEditor.d.ts.map +1 -0
  269. package/dist/jsonEditor/JsonEditor.js +15 -0
  270. package/dist/jsonEditor/JsonEditor.js.map +1 -0
  271. package/dist/jsonEditor/JsonEditorContext.d.ts +28 -0
  272. package/dist/jsonEditor/JsonEditorContext.d.ts.map +1 -0
  273. package/dist/jsonEditor/JsonEditorContext.js +41 -0
  274. package/dist/jsonEditor/JsonEditorContext.js.map +1 -0
  275. package/dist/jsonEditor/RenderNode.d.ts +16 -0
  276. package/dist/jsonEditor/RenderNode.d.ts.map +1 -0
  277. package/dist/jsonEditor/RenderNode.js +32 -0
  278. package/dist/jsonEditor/RenderNode.js.map +1 -0
  279. package/dist/jsonEditor/editors.d.ts +36 -0
  280. package/dist/jsonEditor/editors.d.ts.map +1 -0
  281. package/dist/jsonEditor/editors.js +347 -0
  282. package/dist/jsonEditor/editors.js.map +1 -0
  283. package/dist/jsonEditor/index.d.ts +3 -0
  284. package/dist/jsonEditor/index.d.ts.map +1 -0
  285. package/dist/jsonEditor/index.js +2 -0
  286. package/dist/jsonEditor/index.js.map +1 -0
  287. package/dist/jsonEditor/useJsonEditorTokens.d.ts +13 -0
  288. package/dist/jsonEditor/useJsonEditorTokens.d.ts.map +1 -0
  289. package/dist/jsonEditor/useJsonEditorTokens.js +38 -0
  290. package/dist/jsonEditor/useJsonEditorTokens.js.map +1 -0
  291. package/dist/recorder/RecorderButton.d.ts +31 -0
  292. package/dist/recorder/RecorderButton.d.ts.map +1 -0
  293. package/dist/recorder/RecorderButton.js +24 -0
  294. package/dist/recorder/RecorderButton.js.map +1 -0
  295. package/dist/recorder/RecorderModal.d.ts +59 -0
  296. package/dist/recorder/RecorderModal.d.ts.map +1 -0
  297. package/dist/recorder/RecorderModal.js +333 -0
  298. package/dist/recorder/RecorderModal.js.map +1 -0
  299. package/dist/recorder/RecorderPanel.d.ts +25 -0
  300. package/dist/recorder/RecorderPanel.d.ts.map +1 -0
  301. package/dist/recorder/RecorderPanel.js +30 -0
  302. package/dist/recorder/RecorderPanel.js.map +1 -0
  303. package/dist/recorder/formats.d.ts +51 -0
  304. package/dist/recorder/formats.d.ts.map +1 -0
  305. package/dist/recorder/formats.js +144 -0
  306. package/dist/recorder/formats.js.map +1 -0
  307. package/dist/recorder/hooks/useMediaRecorder.d.ts +90 -0
  308. package/dist/recorder/hooks/useMediaRecorder.d.ts.map +1 -0
  309. package/dist/recorder/hooks/useMediaRecorder.js +277 -0
  310. package/dist/recorder/hooks/useMediaRecorder.js.map +1 -0
  311. package/dist/recorder/hooks/useStreamPreview.d.ts +22 -0
  312. package/dist/recorder/hooks/useStreamPreview.d.ts.map +1 -0
  313. package/dist/recorder/hooks/useStreamPreview.js +44 -0
  314. package/dist/recorder/hooks/useStreamPreview.js.map +1 -0
  315. package/dist/recorder/sources/cameraStream.d.ts +22 -0
  316. package/dist/recorder/sources/cameraStream.d.ts.map +1 -0
  317. package/dist/recorder/sources/cameraStream.js +24 -0
  318. package/dist/recorder/sources/cameraStream.js.map +1 -0
  319. package/dist/recorder/sources/micStream.d.ts +15 -0
  320. package/dist/recorder/sources/micStream.d.ts.map +1 -0
  321. package/dist/recorder/sources/micStream.js +24 -0
  322. package/dist/recorder/sources/micStream.js.map +1 -0
  323. package/dist/recorder/sources/screenStream.d.ts +53 -0
  324. package/dist/recorder/sources/screenStream.d.ts.map +1 -0
  325. package/dist/recorder/sources/screenStream.js +114 -0
  326. package/dist/recorder/sources/screenStream.js.map +1 -0
  327. package/dist/recorder/timingJson.d.ts +51 -0
  328. package/dist/recorder/timingJson.d.ts.map +1 -0
  329. package/dist/recorder/timingJson.js +42 -0
  330. package/dist/recorder/timingJson.js.map +1 -0
  331. package/dist/tiptap/TiptapAudio.d.ts +26 -0
  332. package/dist/tiptap/TiptapAudio.d.ts.map +1 -0
  333. package/dist/tiptap/TiptapAudio.js +58 -0
  334. package/dist/tiptap/TiptapAudio.js.map +1 -0
  335. package/dist/tiptap/TiptapVideo.d.ts +30 -0
  336. package/dist/tiptap/TiptapVideo.d.ts.map +1 -0
  337. package/dist/tiptap/TiptapVideo.js +66 -0
  338. package/dist/tiptap/TiptapVideo.js.map +1 -0
  339. package/dist/tiptap/useResolvedMediaSrc.d.ts +2 -0
  340. package/dist/tiptap/useResolvedMediaSrc.d.ts.map +1 -0
  341. package/dist/tiptap/useResolvedMediaSrc.js +42 -0
  342. package/dist/tiptap/useResolvedMediaSrc.js.map +1 -0
  343. package/dist/tiptapBridge.d.ts.map +1 -1
  344. package/dist/tiptapBridge.js +210 -16
  345. package/dist/tiptapBridge.js.map +1 -1
  346. package/dist/useHeadingLayout.d.ts +54 -0
  347. package/dist/useHeadingLayout.d.ts.map +1 -0
  348. package/dist/useHeadingLayout.js +260 -0
  349. package/dist/useHeadingLayout.js.map +1 -0
  350. package/dist/utils/collectInlineFontAwesomeCss.d.ts +21 -0
  351. package/dist/utils/collectInlineFontAwesomeCss.d.ts.map +1 -0
  352. package/dist/utils/collectInlineFontAwesomeCss.js +68 -0
  353. package/dist/utils/collectInlineFontAwesomeCss.js.map +1 -0
  354. package/dist/utils/dropUtils.d.ts +21 -2
  355. package/dist/utils/dropUtils.d.ts.map +1 -1
  356. package/dist/utils/dropUtils.js +43 -4
  357. package/dist/utils/dropUtils.js.map +1 -1
  358. package/dist/utils/normalizeMalformedAssetUrl.d.ts +15 -0
  359. package/dist/utils/normalizeMalformedAssetUrl.d.ts.map +1 -0
  360. package/dist/utils/normalizeMalformedAssetUrl.js +27 -0
  361. package/dist/utils/normalizeMalformedAssetUrl.js.map +1 -0
  362. package/package.json +8 -5
  363. package/src/DocumentSettingsDialog.tsx +266 -0
  364. package/src/EditorContext.tsx +534 -10
  365. package/src/EditorShell.tsx +691 -63
  366. package/src/EmojiPicker.tsx +332 -0
  367. package/src/ImageEditor.tsx +327 -0
  368. package/src/ImageNodeView.tsx +222 -21
  369. package/src/ImageViewer.tsx +221 -0
  370. package/src/InlineIcon.ts +84 -0
  371. package/src/InlinePreviewGutter.tsx +582 -0
  372. package/src/LinkDialog.tsx +276 -0
  373. package/src/MediaBin.tsx +22 -3
  374. package/src/MentionExtension.tsx +10 -7
  375. package/src/OutlinePanel.tsx +295 -0
  376. package/src/PlainHtmlPreview.tsx +211 -0
  377. package/src/PreviewControls.tsx +130 -24
  378. package/src/PreviewPanel.tsx +38 -21
  379. package/src/RawEditor.tsx +215 -4
  380. package/src/RecorderEntry.tsx +164 -0
  381. package/src/TemplateAnnotation.ts +32 -6
  382. package/src/TemplatePicker.tsx +818 -0
  383. package/src/ThemeCustomizerPanel.tsx +595 -0
  384. package/src/ThemePicker.tsx +319 -0
  385. package/src/Toolbar.tsx +708 -111
  386. package/src/VersionHistoryPanel.tsx +329 -0
  387. package/src/ViewMenuPanel.tsx +188 -0
  388. package/src/WysiwygEditor.tsx +229 -9
  389. package/src/__tests__/detectMarkdown.test.ts +0 -15
  390. package/src/__tests__/documentSettingsDialog.test.tsx +147 -0
  391. package/src/__tests__/emojiPicker.test.tsx +133 -0
  392. package/src/__tests__/fileKind.test.ts +16 -0
  393. package/src/__tests__/imageEditAffordance.test.tsx +268 -0
  394. package/src/__tests__/imageEditorShell.test.tsx +57 -0
  395. package/src/__tests__/imageEditorState.test.ts +171 -0
  396. package/src/__tests__/inlinePreviewGutter.test.tsx +62 -0
  397. package/src/__tests__/inlinePreviewGutterAllBlocks.test.tsx +103 -0
  398. package/src/__tests__/jsonEditor.test.tsx +168 -0
  399. package/src/__tests__/layersPanel.test.tsx +97 -0
  400. package/src/__tests__/linkDialogDocPicker.test.tsx +137 -0
  401. package/src/__tests__/mediaAttachmentFlow.test.ts +110 -0
  402. package/src/__tests__/outlinePanel.test.tsx +79 -0
  403. package/src/__tests__/plainHtmlPreview.test.tsx +107 -0
  404. package/src/__tests__/propertiesPanel.test.tsx +69 -0
  405. package/src/__tests__/recorderFormats.test.ts +146 -0
  406. package/src/__tests__/recorderTimingJson.test.ts +41 -0
  407. package/src/__tests__/templateAnnotationRoundTrip.test.ts +34 -0
  408. package/src/__tests__/tiptapBridge.test.ts +29 -0
  409. package/src/__tests__/tiptapImageRoundTrip.test.ts +73 -0
  410. package/src/__tests__/useImageEditor.test.tsx +159 -0
  411. package/src/__tests__/useMediaRecorder.test.ts +186 -0
  412. package/src/__tests__/versionHistory.test.tsx +197 -0
  413. package/src/blockSlice.ts +75 -0
  414. package/src/buildPreviewDoc.ts +61 -6
  415. package/src/emojiData.ts +1337 -0
  416. package/src/fileKind.ts +30 -6
  417. package/src/hooks/useFileDrop.ts +40 -4
  418. package/src/imageEditor/CanvasSurface.tsx +402 -0
  419. package/src/imageEditor/ImageVersionHistoryDropdown.tsx +396 -0
  420. package/src/imageEditor/LayersPanel.tsx +143 -0
  421. package/src/imageEditor/PropertiesPanel.tsx +428 -0
  422. package/src/imageEditor/Toolbar.tsx +242 -0
  423. package/src/imageEditor/icons.tsx +144 -0
  424. package/src/imageEditor/image-editor.css +450 -0
  425. package/src/imageEditor/layers/EditorImageLayer.tsx +45 -0
  426. package/src/imageEditor/layers/EditorShapeLayer.tsx +62 -0
  427. package/src/imageEditor/layers/EditorTextLayer.tsx +45 -0
  428. package/src/imageEditor/layers/SelectionHandles.tsx +86 -0
  429. package/src/imageEditor/state.ts +153 -0
  430. package/src/imageEditor/useImageEditor.ts +328 -0
  431. package/src/imageEditor/useImageEditorTokens.ts +70 -0
  432. package/src/index.ts +82 -0
  433. package/src/jsonEditor/EmbeddedRichTextField.tsx +81 -0
  434. package/src/jsonEditor/JsonEditor.tsx +81 -0
  435. package/src/jsonEditor/JsonEditorContext.tsx +75 -0
  436. package/src/jsonEditor/RenderNode.tsx +66 -0
  437. package/src/jsonEditor/editors.tsx +678 -0
  438. package/src/jsonEditor/index.ts +2 -0
  439. package/src/jsonEditor/json-editor.css +463 -0
  440. package/src/jsonEditor/useJsonEditorTokens.ts +63 -0
  441. package/src/recorder/RecorderButton.tsx +72 -0
  442. package/src/recorder/RecorderModal.tsx +596 -0
  443. package/src/recorder/RecorderPanel.tsx +93 -0
  444. package/src/recorder/formats.ts +159 -0
  445. package/src/recorder/hooks/useMediaRecorder.ts +378 -0
  446. package/src/recorder/hooks/useStreamPreview.ts +47 -0
  447. package/src/recorder/sources/cameraStream.ts +32 -0
  448. package/src/recorder/sources/micStream.ts +25 -0
  449. package/src/recorder/sources/screenStream.ts +162 -0
  450. package/src/recorder/timingJson.ts +66 -0
  451. package/src/styles/editor.css +2490 -51
  452. package/src/styles/image-edit-affordance.css +201 -0
  453. package/src/styles/index.css +10 -0
  454. package/src/tiptap/TiptapAudio.tsx +86 -0
  455. package/src/tiptap/TiptapVideo.tsx +119 -0
  456. package/src/tiptap/useResolvedMediaSrc.ts +47 -0
  457. package/src/tiptapBridge.ts +227 -22
  458. package/src/useHeadingLayout.ts +294 -0
  459. package/src/utils/collectInlineFontAwesomeCss.ts +69 -0
  460. package/src/utils/dropUtils.ts +54 -6
  461. package/src/utils/normalizeMalformedAssetUrl.ts +22 -0
@@ -6,35 +6,62 @@
6
6
  *
7
7
  * The ProseMirror node retains the original relative path so markdown roundtrip
8
8
  * is preserved — only the rendered DOM uses the resolved URL.
9
+ *
10
+ * When the image is hovered or selected, a small floating "Edit" affordance
11
+ * appears in the top-right corner — clicking it calls `openImageEdit` on the
12
+ * editor context, which `<EditorShell>` consumes to open a modal
13
+ * `<ImageEditor>` on the source path. Only shown for paths that are
14
+ * relative (i.e. live in the document's media container).
9
15
  */
10
16
 
11
- import { useEffect, useState } from 'react';
17
+ import { useEffect, useRef, useState } from 'react';
12
18
  import { NodeViewWrapper, ReactNodeViewRenderer } from '@tiptap/react';
13
19
  import type { NodeViewProps } from '@tiptap/react';
14
20
  import Image from '@tiptap/extension-image';
15
21
  import { useEditorContext } from './EditorContext';
22
+ import { normalizeMalformedAssetUrl } from './utils/normalizeMalformedAssetUrl';
16
23
 
17
- function ImageComponent({ node }: NodeViewProps) {
18
- const { src, alt, title } = node.attrs as { src: string; alt: string; title: string };
19
- const { mediaProvider, imageDisplayMode } = useEditorContext();
24
+ function ImageComponent({ node, selected, editor, updateAttributes }: NodeViewProps) {
25
+ const { src, alt, title, width } = node.attrs as {
26
+ src: string;
27
+ alt: string;
28
+ title: string;
29
+ width: number | null;
30
+ height: number | null;
31
+ };
32
+ const { mediaProvider, imageDisplayMode, openImageEdit, mediaRevision } = useEditorContext();
20
33
  const [resolvedSrc, setResolvedSrc] = useState(src);
34
+ const [hovered, setHovered] = useState(false);
35
+ const imgRef = useRef<HTMLImageElement | null>(null);
36
+ // Live preview width while a resize gesture is in flight. Null means
37
+ // "use the persisted width attr". Committed to node attrs on mouseup.
38
+ const [previewWidth, setPreviewWidth] = useState<number | null>(null);
21
39
  const isThumbnail = imageDisplayMode === 'thumbnail';
40
+ const isEditable = editor?.isEditable ?? true;
22
41
 
42
+ // MS "Save Page As Web Page" / pandoc-style imports sometimes leave
43
+ // image srcs in the shape `http://<doc>_files/<asset>` — the asset
44
+ // folder got URL-parsed as a hostname because no scheme separator was
45
+ // ever there. Detect that shape (bare hostname, no dots/ports, ending
46
+ // in `_files`) and recover the original relative path so the media
47
+ // provider can resolve it from the workspace.
48
+ const normalizedRelativePath = normalizeMalformedAssetUrl(src);
23
49
  const isRelative =
24
50
  src &&
25
51
  !src.startsWith('blob:') &&
26
52
  !src.startsWith('http') &&
27
53
  !src.startsWith('data:') &&
28
54
  !src.startsWith('/');
55
+ const resolveAs = normalizedRelativePath ?? (isRelative ? src : null);
29
56
 
30
57
  useEffect(() => {
31
- if (!mediaProvider || !isRelative) {
58
+ if (!mediaProvider || !resolveAs) {
32
59
  setResolvedSrc(src);
33
60
  return;
34
61
  }
35
62
 
36
63
  let cancelled = false;
37
- mediaProvider.resolveUrl(src).then(
64
+ mediaProvider.resolveUrl(resolveAs).then(
38
65
  (resolved) => {
39
66
  if (!cancelled) setResolvedSrc(resolved);
40
67
  },
@@ -46,37 +73,211 @@ function ImageComponent({ node }: NodeViewProps) {
46
73
  return () => {
47
74
  cancelled = true;
48
75
  };
49
- }, [src, mediaProvider, isRelative]);
76
+ // `mediaRevision` is bumped after the image editor writes back to the
77
+ // same path — re-resolve so we pick up the fresh blob URL.
78
+ }, [src, resolveAs, mediaProvider, mediaRevision]);
79
+
80
+ // The Edit affordance is only meaningful when:
81
+ // - the editor is editable (read-only previews skip it),
82
+ // - the path is relative (lives in the doc's container, so the editor
83
+ // can read+write it back), and
84
+ // - a media provider is wired (the modal resolves the URL through it).
85
+ const canEdit = isEditable && isRelative && mediaProvider !== null;
86
+ const showAffordance = canEdit && (selected || hovered);
87
+ // Resize handle is shown for any selected image in an editable view —
88
+ // even non-relative ones (external URLs, data URIs) — so authors can
89
+ // size remote pictures the same way as local ones.
90
+ const canResize = isEditable && !isThumbnail;
91
+ const showResize = canResize && (selected || hovered);
92
+
93
+ // Effective render width: live preview while dragging, otherwise the
94
+ // persisted attr. Height is always derived from the natural aspect
95
+ // ratio of the image element so authors can't accidentally squash it.
96
+ const effectiveWidth = previewWidth ?? width ?? null;
97
+
98
+ const beginResize = (event: React.MouseEvent) => {
99
+ if (!canResize) return;
100
+ event.preventDefault();
101
+ event.stopPropagation();
102
+ const imgEl = imgRef.current;
103
+ if (!imgEl) return;
104
+ const startWidth = imgEl.getBoundingClientRect().width;
105
+ const startX = event.clientX;
106
+ // Cap at the image's natural width so dragging out doesn't upscale
107
+ // past the source pixels (which just looks blurry).
108
+ const maxWidth = imgEl.naturalWidth || Infinity;
109
+ const minWidth = 24;
110
+
111
+ const onMove = (e: MouseEvent) => {
112
+ const next = Math.max(minWidth, Math.min(maxWidth, startWidth + (e.clientX - startX)));
113
+ setPreviewWidth(Math.round(next));
114
+ };
115
+ const onUp = (e: MouseEvent) => {
116
+ window.removeEventListener('mousemove', onMove);
117
+ window.removeEventListener('mouseup', onUp);
118
+ const finalWidth = Math.max(minWidth, Math.min(maxWidth, startWidth + (e.clientX - startX)));
119
+ const naturalW = imgEl.naturalWidth;
120
+ const naturalH = imgEl.naturalHeight;
121
+ const w = Math.round(finalWidth);
122
+ const h = naturalW > 0 && naturalH > 0 ? Math.round((w * naturalH) / naturalW) : null;
123
+ setPreviewWidth(null);
124
+ updateAttributes({ width: w, height: h });
125
+ };
126
+ window.addEventListener('mousemove', onMove);
127
+ window.addEventListener('mouseup', onUp);
128
+ };
129
+
130
+ const resetSize = (event: React.MouseEvent) => {
131
+ if (!canResize) return;
132
+ event.preventDefault();
133
+ event.stopPropagation();
134
+ setPreviewWidth(null);
135
+ updateAttributes({ width: null, height: null });
136
+ };
137
+
138
+ const baseStyle: React.CSSProperties = isThumbnail
139
+ ? {
140
+ maxWidth: '100px',
141
+ maxHeight: '100px',
142
+ width: 'auto',
143
+ height: 'auto',
144
+ objectFit: 'contain',
145
+ display: 'block',
146
+ }
147
+ : effectiveWidth
148
+ ? {
149
+ width: `${effectiveWidth}px`,
150
+ maxWidth: '100%',
151
+ height: 'auto',
152
+ display: 'block',
153
+ }
154
+ : { maxWidth: '100%', height: 'auto', display: 'block' };
50
155
 
51
156
  return (
52
- <NodeViewWrapper as="figure" style={{ margin: '0.5em 0' }}>
157
+ <NodeViewWrapper
158
+ as="figure"
159
+ // `data-drag-handle` tells ProseMirror that drags starting on this
160
+ // wrapper are NODE moves (not OS-level image drags). Without it,
161
+ // grabbing the inner `<img>` fires the browser's default image-drag
162
+ // behaviour: the picture is packaged as a virtual file in
163
+ // `dataTransfer.files`, the drop is treated as an external upload,
164
+ // and the source node is never removed — producing a duplicate.
165
+ // Combined with `draggable: true` in the node spec, this gives
166
+ // ProseMirror's default dropHandler a real internal move which
167
+ // preserves the `width`/`height` attrs and deletes the original.
168
+ draggable
169
+ data-drag-handle
170
+ style={{ margin: '0.5em 0', position: 'relative', display: 'inline-block', maxWidth: '100%' }}
171
+ onMouseEnter={() => setHovered(true)}
172
+ onMouseLeave={() => setHovered(false)}
173
+ >
53
174
  <img
175
+ ref={imgRef}
54
176
  src={resolvedSrc}
55
177
  alt={alt || ''}
56
178
  title={title || undefined}
57
179
  className={isThumbnail ? 'squisq-image squisq-image--thumbnail' : 'squisq-image'}
58
- style={
59
- isThumbnail
60
- ? {
61
- maxWidth: '100px',
62
- maxHeight: '100px',
63
- width: 'auto',
64
- height: 'auto',
65
- objectFit: 'contain',
66
- display: 'block',
67
- }
68
- : { maxWidth: '100%', height: 'auto', display: 'block' }
69
- }
180
+ style={baseStyle}
181
+ // Disable the inner `<img>`'s native HTML5 drag so the gesture is
182
+ // captured by the wrapper's `data-drag-handle` instead. (Without
183
+ // this the browser still emits its own dragstart on the image
184
+ // and ProseMirror sees an external file drop.)
185
+ draggable={false}
186
+ onDragStart={(e) => e.preventDefault()}
187
+ data-selected={selected ? 'true' : undefined}
70
188
  />
189
+ {showAffordance && (
190
+ <button
191
+ type="button"
192
+ className="squisq-image-edit-affordance"
193
+ data-testid="image-edit-affordance"
194
+ // Stop the click from re-selecting the ProseMirror node and from
195
+ // bubbling to host handlers like file-drop overlays.
196
+ onMouseDown={(e) => e.preventDefault()}
197
+ onClick={(e) => {
198
+ e.preventDefault();
199
+ e.stopPropagation();
200
+ openImageEdit(src);
201
+ }}
202
+ title="Edit image"
203
+ aria-label={`Edit image ${alt || src}`}
204
+ >
205
+ <span aria-hidden="true" style={{ fontSize: '0.95em', lineHeight: 1 }}>
206
+
207
+ </span>
208
+ <span>Edit</span>
209
+ </button>
210
+ )}
211
+ {showResize && (
212
+ <>
213
+ <span
214
+ className="squisq-image-resize-handle"
215
+ data-testid="image-resize-handle"
216
+ onMouseDown={beginResize}
217
+ // Double-click clears the persisted width/height so the image
218
+ // returns to its natural rendered size.
219
+ onDoubleClick={resetSize}
220
+ title="Drag to resize · double-click to reset"
221
+ aria-label="Resize image"
222
+ role="separator"
223
+ />
224
+ {(previewWidth != null || width != null) && (
225
+ <span className="squisq-image-resize-readout" aria-hidden="true">
226
+ {Math.round(effectiveWidth ?? 0)}px
227
+ </span>
228
+ )}
229
+ </>
230
+ )}
71
231
  </NodeViewWrapper>
72
232
  );
73
233
  }
74
234
 
75
235
  /**
76
236
  * Image extension with a custom React NodeView that resolves URLs
77
- * through the EditorContext's MediaProvider.
237
+ * through the EditorContext's MediaProvider, plus author-controlled
238
+ * width/height attributes for in-editor resizing.
239
+ *
240
+ * When `width` (and optionally `height`) is set, the markdown serializer
241
+ * (`tiptapToMarkdown` in `tiptapBridge.ts`) emits an HTML `<img>` tag
242
+ * rather than the `![alt](src)` shorthand so dimensions survive a
243
+ * markdown ↔ WYSIWYG round-trip.
78
244
  */
79
245
  export const ImageWithMediaProvider = Image.extend({
246
+ // Mark the node draggable so ProseMirror handles drag-to-reposition
247
+ // as an internal node move (preserves `width`/`height` attrs and
248
+ // removes the source node automatically). Combined with the
249
+ // `data-drag-handle` on the NodeViewWrapper, this is what makes the
250
+ // `moved` flag true in `handleDrop` so the editor's file-upload path
251
+ // doesn't fire on a drag-reorder.
252
+ draggable: true,
253
+ addAttributes() {
254
+ const parent = this.parent?.() ?? {};
255
+ return {
256
+ ...parent,
257
+ width: {
258
+ default: null,
259
+ parseHTML: (element) => {
260
+ const raw = element.getAttribute('width');
261
+ if (!raw) return null;
262
+ const n = parseInt(raw, 10);
263
+ return Number.isFinite(n) && n > 0 ? n : null;
264
+ },
265
+ renderHTML: (attrs: { width?: number | null }) =>
266
+ attrs.width ? { width: String(attrs.width) } : {},
267
+ },
268
+ height: {
269
+ default: null,
270
+ parseHTML: (element) => {
271
+ const raw = element.getAttribute('height');
272
+ if (!raw) return null;
273
+ const n = parseInt(raw, 10);
274
+ return Number.isFinite(n) && n > 0 ? n : null;
275
+ },
276
+ renderHTML: (attrs: { height?: number | null }) =>
277
+ attrs.height ? { height: String(attrs.height) } : {},
278
+ },
279
+ };
280
+ },
80
281
  addNodeView() {
81
282
  return ReactNodeViewRenderer(ImageComponent);
82
283
  },
@@ -0,0 +1,221 @@
1
+ /**
2
+ * ImageViewer
3
+ *
4
+ * Read-only image viewer used when EditorShell runs in `image` file mode
5
+ * (PNG/JPEG/etc.). Renders a centered image that fits its container with
6
+ * a small overlay toolbar for fit / 100% / zoom in / zoom out, and a
7
+ * status row showing intrinsic dimensions and current zoom.
8
+ *
9
+ * Lifecycle of the `src` URL is the caller's responsibility — when fed a
10
+ * blob URL, the host should `URL.revokeObjectURL` on unmount or src change.
11
+ *
12
+ * Future image-editing actions (rotate, flip, crop) will slot in alongside
13
+ * the existing zoom controls.
14
+ */
15
+
16
+ import { useCallback, useEffect, useRef, useState } from 'react';
17
+ import type { CSSProperties, MouseEvent as ReactMouseEvent } from 'react';
18
+
19
+ export interface ImageViewerProps {
20
+ /** Image source — typically a blob: URL the host owns and revokes. */
21
+ src: string;
22
+ /** Alt text for accessibility. Defaults to empty string (decorative). */
23
+ alt?: string;
24
+ /** Additional class name on the outer container. */
25
+ className?: string;
26
+ /** Color theme for the chrome around the image. */
27
+ theme?: 'light' | 'dark';
28
+ }
29
+
30
+ const MIN_ZOOM = 0.1;
31
+ const MAX_ZOOM = 16;
32
+ const ZOOM_STEP = 1.25;
33
+
34
+ type FitState = { mode: 'fit' } | { mode: 'manual'; zoom: number };
35
+
36
+ export function ImageViewer({ src, alt = '', className, theme = 'light' }: ImageViewerProps) {
37
+ const imgRef = useRef<HTMLImageElement | null>(null);
38
+ const stageRef = useRef<HTMLDivElement | null>(null);
39
+
40
+ const [naturalSize, setNaturalSize] = useState<{ w: number; h: number } | null>(null);
41
+ const [fitZoom, setFitZoom] = useState<number>(1);
42
+ const [state, setState] = useState<FitState>({ mode: 'fit' });
43
+ const [pan, setPan] = useState<{ x: number; y: number }>({ x: 0, y: 0 });
44
+ const [error, setError] = useState<string | null>(null);
45
+
46
+ useEffect(() => {
47
+ setNaturalSize(null);
48
+ setState({ mode: 'fit' });
49
+ setPan({ x: 0, y: 0 });
50
+ setError(null);
51
+ }, [src]);
52
+
53
+ const recomputeFitZoom = useCallback(() => {
54
+ const stage = stageRef.current;
55
+ if (!stage || !naturalSize) return;
56
+ const { clientWidth, clientHeight } = stage;
57
+ if (clientWidth === 0 || clientHeight === 0) return;
58
+ const fit = Math.min(clientWidth / naturalSize.w, clientHeight / naturalSize.h, 1);
59
+ setFitZoom(fit > 0 ? fit : 1);
60
+ }, [naturalSize]);
61
+
62
+ useEffect(() => {
63
+ recomputeFitZoom();
64
+ if (typeof ResizeObserver === 'undefined') return;
65
+ const stage = stageRef.current;
66
+ if (!stage) return;
67
+ const ro = new ResizeObserver(() => recomputeFitZoom());
68
+ ro.observe(stage);
69
+ return () => ro.disconnect();
70
+ }, [recomputeFitZoom]);
71
+
72
+ const handleLoad = useCallback(() => {
73
+ const img = imgRef.current;
74
+ if (!img) return;
75
+ setNaturalSize({ w: img.naturalWidth, h: img.naturalHeight });
76
+ }, []);
77
+
78
+ const handleError = useCallback(() => {
79
+ setError('Failed to load image');
80
+ }, []);
81
+
82
+ const effectiveZoom = state.mode === 'fit' ? fitZoom : state.zoom;
83
+
84
+ const setZoom = useCallback((next: number) => {
85
+ const clamped = Math.max(MIN_ZOOM, Math.min(MAX_ZOOM, next));
86
+ setState({ mode: 'manual', zoom: clamped });
87
+ }, []);
88
+
89
+ const onFit = useCallback(() => {
90
+ setState({ mode: 'fit' });
91
+ setPan({ x: 0, y: 0 });
92
+ }, []);
93
+ const onActual = useCallback(() => {
94
+ setZoom(1);
95
+ setPan({ x: 0, y: 0 });
96
+ }, [setZoom]);
97
+ const onZoomIn = useCallback(() => setZoom(effectiveZoom * ZOOM_STEP), [effectiveZoom, setZoom]);
98
+ const onZoomOut = useCallback(() => setZoom(effectiveZoom / ZOOM_STEP), [effectiveZoom, setZoom]);
99
+
100
+ const dragRef = useRef<{ startX: number; startY: number; panX: number; panY: number } | null>(
101
+ null,
102
+ );
103
+ const onMouseDown = useCallback(
104
+ (e: ReactMouseEvent<HTMLDivElement>) => {
105
+ if (effectiveZoom <= fitZoom) return;
106
+ dragRef.current = { startX: e.clientX, startY: e.clientY, panX: pan.x, panY: pan.y };
107
+ e.preventDefault();
108
+ },
109
+ [effectiveZoom, fitZoom, pan.x, pan.y],
110
+ );
111
+
112
+ useEffect(() => {
113
+ const onMove = (e: MouseEvent) => {
114
+ const drag = dragRef.current;
115
+ if (!drag) return;
116
+ setPan({
117
+ x: drag.panX + (e.clientX - drag.startX),
118
+ y: drag.panY + (e.clientY - drag.startY),
119
+ });
120
+ };
121
+ const onUp = () => {
122
+ dragRef.current = null;
123
+ };
124
+ window.addEventListener('mousemove', onMove);
125
+ window.addEventListener('mouseup', onUp);
126
+ return () => {
127
+ window.removeEventListener('mousemove', onMove);
128
+ window.removeEventListener('mouseup', onUp);
129
+ };
130
+ }, []);
131
+
132
+ const isPannable = effectiveZoom > fitZoom + 1e-6;
133
+
134
+ const imgStyle: CSSProperties = naturalSize
135
+ ? {
136
+ width: `${naturalSize.w * effectiveZoom}px`,
137
+ height: `${naturalSize.h * effectiveZoom}px`,
138
+ transform: `translate(${pan.x}px, ${pan.y}px)`,
139
+ }
140
+ : { maxWidth: '100%', maxHeight: '100%' };
141
+
142
+ const containerCls = ['squisq-image-viewer', `squisq-image-viewer--${theme}`, className]
143
+ .filter(Boolean)
144
+ .join(' ');
145
+
146
+ return (
147
+ <div className={containerCls} data-testid="image-viewer">
148
+ <div
149
+ ref={stageRef}
150
+ className="squisq-image-viewer-stage"
151
+ onMouseDown={onMouseDown}
152
+ style={{ cursor: isPannable ? (dragRef.current ? 'grabbing' : 'grab') : 'default' }}
153
+ >
154
+ {/* future: rotate, flip, crop overlays go here */}
155
+ {error ? (
156
+ <div className="squisq-image-viewer-error">{error}</div>
157
+ ) : (
158
+ <img
159
+ ref={imgRef}
160
+ src={src}
161
+ alt={alt}
162
+ className="squisq-image-viewer-img"
163
+ style={imgStyle}
164
+ onLoad={handleLoad}
165
+ onError={handleError}
166
+ draggable={false}
167
+ />
168
+ )}
169
+ <div className="squisq-image-viewer-toolbar">
170
+ <button
171
+ type="button"
172
+ className="squisq-image-viewer-btn"
173
+ onClick={onZoomOut}
174
+ aria-label="Zoom out"
175
+ title="Zoom out"
176
+ >
177
+
178
+ </button>
179
+ <button
180
+ type="button"
181
+ className="squisq-image-viewer-btn"
182
+ onClick={onFit}
183
+ aria-pressed={state.mode === 'fit'}
184
+ title="Fit to viewport"
185
+ >
186
+ Fit
187
+ </button>
188
+ <button
189
+ type="button"
190
+ className="squisq-image-viewer-btn"
191
+ onClick={onActual}
192
+ title="Actual size (100%)"
193
+ >
194
+ 100%
195
+ </button>
196
+ <button
197
+ type="button"
198
+ className="squisq-image-viewer-btn"
199
+ onClick={onZoomIn}
200
+ aria-label="Zoom in"
201
+ title="Zoom in"
202
+ >
203
+ +
204
+ </button>
205
+ </div>
206
+ </div>
207
+ <div className="squisq-image-viewer-status">
208
+ {naturalSize ? (
209
+ <>
210
+ <span>
211
+ {naturalSize.w} × {naturalSize.h}
212
+ </span>
213
+ <span>{Math.round(effectiveZoom * 100)}%</span>
214
+ </>
215
+ ) : (
216
+ <span>Loading…</span>
217
+ )}
218
+ </div>
219
+ </div>
220
+ );
221
+ }
@@ -0,0 +1,84 @@
1
+ /**
2
+ * InlineIcon — Tiptap Node Extension
3
+ *
4
+ * Atomic inline node that round-trips FontAwesome icons through the
5
+ * WYSIWYG editor. The markdown bridge stashes `{[github]}` source as
6
+ * `<i data-icon="github" data-family="brands" data-name="github"
7
+ * class="fa-brands fa-github"></i>`; this extension lets ProseMirror
8
+ * recognize that markup, persist the attributes through edits, and
9
+ * re-emit it when serializing back to HTML/markdown.
10
+ *
11
+ * Atom / inline / non-selectable means the icon behaves like an emoji:
12
+ * the caret can land before or after it, Backspace deletes it whole,
13
+ * and Tiptap won't try to put content inside it.
14
+ */
15
+
16
+ import { Node, mergeAttributes } from '@tiptap/core';
17
+
18
+ interface InlineIconAttrs {
19
+ /** Token as authored in markdown — e.g. `github`, `fa-solid:user`. */
20
+ token: string;
21
+ family: 'brands' | 'solid' | 'regular';
22
+ name: string;
23
+ }
24
+
25
+ export const InlineIcon = Node.create({
26
+ name: 'inlineIcon',
27
+ group: 'inline',
28
+ inline: true,
29
+ atom: true,
30
+ selectable: true,
31
+ draggable: false,
32
+
33
+ addAttributes() {
34
+ return {
35
+ token: {
36
+ default: '',
37
+ parseHTML: (el: HTMLElement) => el.getAttribute('data-icon') ?? '',
38
+ renderHTML: (attrs: InlineIconAttrs) => (attrs.token ? { 'data-icon': attrs.token } : {}),
39
+ },
40
+ family: {
41
+ default: 'solid',
42
+ parseHTML: (el: HTMLElement) => el.getAttribute('data-family') ?? 'solid',
43
+ renderHTML: (attrs: InlineIconAttrs) =>
44
+ attrs.family ? { 'data-family': attrs.family } : {},
45
+ },
46
+ name: {
47
+ default: '',
48
+ parseHTML: (el: HTMLElement) => el.getAttribute('data-name') ?? '',
49
+ renderHTML: (attrs: InlineIconAttrs) => (attrs.name ? { 'data-name': attrs.name } : {}),
50
+ },
51
+ };
52
+ },
53
+
54
+ parseHTML() {
55
+ // Tiptap's built-in Italic mark also claims `<i>` tags. We need a
56
+ // higher priority than the default (50) so ProseMirror picks
57
+ // InlineIcon over Italic for `<i data-icon=…>` markup — otherwise
58
+ // the markdown → WYSIWYG round-trip silently drops the icon and
59
+ // produces an empty italic mark instead.
60
+ return [
61
+ {
62
+ tag: 'i[data-icon]',
63
+ priority: 100,
64
+ },
65
+ ];
66
+ },
67
+
68
+ renderHTML({ HTMLAttributes }) {
69
+ const family = (HTMLAttributes['data-family'] as string | undefined) ?? 'solid';
70
+ const name = (HTMLAttributes['data-name'] as string | undefined) ?? '';
71
+ // The `<i>` carries `class="fa-brands fa-github"` so the bundled
72
+ // FontAwesome CSS picks it up. We also keep `data-*` mirrors so
73
+ // the bridge regex can round-trip back to markdown without
74
+ // parsing the class string.
75
+ const className = name ? `fa-${family} fa-${name}` : '';
76
+ return [
77
+ 'i',
78
+ mergeAttributes(HTMLAttributes, {
79
+ class: className,
80
+ contenteditable: 'false',
81
+ }),
82
+ ];
83
+ },
84
+ });