@bendyline/squisq-editor-react 2.1.0 → 2.3.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 (415) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.md +40 -0
  3. package/dist/chunk-54UGTQBO.js +862 -0
  4. package/dist/chunk-5JMHFAVW.js +2408 -0
  5. package/dist/chunk-5Q4JN4I5.js +132 -0
  6. package/dist/chunk-6VDYKI3L.js +49 -0
  7. package/dist/chunk-GS7QWYFT.js +9 -0
  8. package/dist/chunk-MJJK7YQB.js +949 -0
  9. package/dist/chunk-NITZVAXL.js +986 -0
  10. package/dist/chunk-TRCKHRBS.js +35234 -0
  11. package/dist/chunk-V44VP242.js +3256 -0
  12. package/dist/image-editor/index.d.ts +223 -0
  13. package/dist/image-editor/index.js +15 -0
  14. package/dist/index.d.ts +2060 -4040
  15. package/dist/index.js +496 -40014
  16. package/dist/json-editor/index.d.ts +27 -0
  17. package/dist/json-editor/index.js +7 -0
  18. package/dist/monaco.d.ts +1 -1
  19. package/dist/monaco.js +1 -2
  20. package/dist/recorder/index.d.ts +407 -0
  21. package/dist/recorder/index.js +43 -0
  22. package/dist/shell/index.d.ts +9 -0
  23. package/dist/shell/index.js +22 -0
  24. package/dist/shell-BxSCBm4H.d.ts +1064 -0
  25. package/dist/styles/index.css +598 -161
  26. package/dist/teleprompter/index.d.ts +497 -0
  27. package/dist/teleprompter/index.js +57 -0
  28. package/package.json +34 -8
  29. package/dist/index.js.map +0 -1
  30. package/dist/monaco.js.map +0 -1
  31. package/src/BlockCardView.tsx +0 -121
  32. package/src/BlockPreviewPanel.tsx +0 -69
  33. package/src/BlockPropertiesPopover.tsx +0 -222
  34. package/src/DocumentSettingsDialog.tsx +0 -272
  35. package/src/DropZoneOverlay.tsx +0 -137
  36. package/src/EditorContext.tsx +0 -1274
  37. package/src/EditorShell.tsx +0 -1358
  38. package/src/EmojiPicker.tsx +0 -332
  39. package/src/FolderView.tsx +0 -131
  40. package/src/Icon.tsx +0 -26
  41. package/src/ImageEditor.tsx +0 -395
  42. package/src/ImageNodeView.tsx +0 -284
  43. package/src/ImageViewer.tsx +0 -221
  44. package/src/InlineIcon.ts +0 -84
  45. package/src/InlinePreviewGutter.tsx +0 -590
  46. package/src/LinkDialog.tsx +0 -276
  47. package/src/MediaBin.tsx +0 -500
  48. package/src/MentionExtension.tsx +0 -261
  49. package/src/OutlinePanel.tsx +0 -547
  50. package/src/PlainHtmlPreview.tsx +0 -277
  51. package/src/PreviewControls.tsx +0 -1265
  52. package/src/PreviewPanel.tsx +0 -426
  53. package/src/RawEditor.tsx +0 -743
  54. package/src/RecorderEntry.tsx +0 -162
  55. package/src/StatusBar.tsx +0 -51
  56. package/src/TemplateAnnotation.ts +0 -167
  57. package/src/TemplateContentPreview.tsx +0 -56
  58. package/src/TemplatePicker.tsx +0 -1314
  59. package/src/ThemeCustomizerPanel.tsx +0 -304
  60. package/src/ThemePicker.tsx +0 -433
  61. package/src/TimelineBlockPreview.tsx +0 -37
  62. package/src/TimelineTrack.tsx +0 -671
  63. package/src/Toolbar.tsx +0 -2885
  64. package/src/Tooltip.tsx +0 -142
  65. package/src/TransitionPicker.tsx +0 -390
  66. package/src/VersionHistoryPanel.tsx +0 -359
  67. package/src/ViewMenuPanel.tsx +0 -189
  68. package/src/ViewSwitcher.tsx +0 -56
  69. package/src/WysiwygEditor.tsx +0 -806
  70. package/src/__tests__/blockProperties.test.ts +0 -92
  71. package/src/__tests__/blockPropertiesPopoverTheme.test.tsx +0 -33
  72. package/src/__tests__/blockRange.test.ts +0 -105
  73. package/src/__tests__/blockTagActivity.test.ts +0 -183
  74. package/src/__tests__/buildDocumentPreviewMarkdown.test.ts +0 -75
  75. package/src/__tests__/buildPreviewDocContent.test.ts +0 -65
  76. package/src/__tests__/buildPreviewDocTransition.test.ts +0 -92
  77. package/src/__tests__/canvasSurfaceTextEditing.test.tsx +0 -60
  78. package/src/__tests__/codeContextSectionView.test.tsx +0 -97
  79. package/src/__tests__/codeContextZoneManager.test.ts +0 -127
  80. package/src/__tests__/createShapeLayer.test.ts +0 -46
  81. package/src/__tests__/customLayoutManagerTheme.test.tsx +0 -34
  82. package/src/__tests__/detectMarkdown.test.ts +0 -73
  83. package/src/__tests__/diffContextSections.test.ts +0 -39
  84. package/src/__tests__/documentSettingsDialog.test.tsx +0 -197
  85. package/src/__tests__/drawingShapeRoundTrip.test.ts +0 -49
  86. package/src/__tests__/editorScrollHandoff.test.tsx +0 -102
  87. package/src/__tests__/editorScrollSync.test.ts +0 -65
  88. package/src/__tests__/editorShellCodeContext.test.tsx +0 -86
  89. package/src/__tests__/editorShellProps.test.tsx +0 -550
  90. package/src/__tests__/embeddedMedia.test.ts +0 -48
  91. package/src/__tests__/emojiPicker.test.tsx +0 -93
  92. package/src/__tests__/fileKind.test.ts +0 -112
  93. package/src/__tests__/findMode.test.tsx +0 -104
  94. package/src/__tests__/findModel.test.ts +0 -55
  95. package/src/__tests__/headingTransition.test.ts +0 -176
  96. package/src/__tests__/imageEditAffordance.test.tsx +0 -272
  97. package/src/__tests__/imageEditModalContract.test.tsx +0 -119
  98. package/src/__tests__/imageEditorShell.test.tsx +0 -94
  99. package/src/__tests__/imageEditorState.test.ts +0 -171
  100. package/src/__tests__/inlinePreviewGutter.test.tsx +0 -62
  101. package/src/__tests__/inlinePreviewGutterAllBlocks.test.tsx +0 -103
  102. package/src/__tests__/jsonEditor.test.tsx +0 -223
  103. package/src/__tests__/layersPanel.test.tsx +0 -167
  104. package/src/__tests__/layoutChildRoundTrip.test.ts +0 -71
  105. package/src/__tests__/linkDialogDocPicker.test.tsx +0 -137
  106. package/src/__tests__/majorApiTypes.test.ts +0 -26
  107. package/src/__tests__/markdownCodeFence.test.ts +0 -45
  108. package/src/__tests__/mediaAttachmentFlow.test.ts +0 -110
  109. package/src/__tests__/mediaBinDrop.test.tsx +0 -90
  110. package/src/__tests__/mediaReferences.test.ts +0 -97
  111. package/src/__tests__/narrationSave.test.ts +0 -148
  112. package/src/__tests__/outlinePanel.test.tsx +0 -169
  113. package/src/__tests__/outlineSource.test.ts +0 -217
  114. package/src/__tests__/plainHtmlPreview.test.tsx +0 -125
  115. package/src/__tests__/presentationMode.test.tsx +0 -290
  116. package/src/__tests__/previewControls.test.tsx +0 -571
  117. package/src/__tests__/previewPanelAudioFailure.test.tsx +0 -46
  118. package/src/__tests__/previewPanelPresentation.test.tsx +0 -126
  119. package/src/__tests__/previewPanelTransforms.test.tsx +0 -117
  120. package/src/__tests__/propertiesPanel.test.tsx +0 -69
  121. package/src/__tests__/rawEditorModelIsolation.test.ts +0 -19
  122. package/src/__tests__/recorderFormats.test.ts +0 -146
  123. package/src/__tests__/recorderMediaInsert.test.ts +0 -86
  124. package/src/__tests__/recorderTheme.test.tsx +0 -42
  125. package/src/__tests__/recorderTimingJson.test.ts +0 -41
  126. package/src/__tests__/resolveBlockVisual.test.ts +0 -43
  127. package/src/__tests__/selectionConversions.test.ts +0 -80
  128. package/src/__tests__/statusBar.test.tsx +0 -27
  129. package/src/__tests__/teleprompter.test.tsx +0 -190
  130. package/src/__tests__/templateAnnotationRoundTrip.test.ts +0 -99
  131. package/src/__tests__/templateContentPreview.test.ts +0 -101
  132. package/src/__tests__/templatePickerMetadata.test.ts +0 -32
  133. package/src/__tests__/templatePickerPortal.test.tsx +0 -62
  134. package/src/__tests__/timelineSource.test.ts +0 -134
  135. package/src/__tests__/tiptapBridge.test.ts +0 -575
  136. package/src/__tests__/tiptapBridgeConformance.test.ts +0 -47
  137. package/src/__tests__/tiptapCodeBlockRoundTrip.test.ts +0 -109
  138. package/src/__tests__/tiptapImageRoundTrip.test.ts +0 -73
  139. package/src/__tests__/toolbarSelectionConversion.test.tsx +0 -190
  140. package/src/__tests__/tooltip.test.tsx +0 -72
  141. package/src/__tests__/transformStyleId.test.ts +0 -13
  142. package/src/__tests__/transitionCatalog.test.ts +0 -64
  143. package/src/__tests__/useBlockNavigator.test.tsx +0 -67
  144. package/src/__tests__/useImageEditor.test.tsx +0 -226
  145. package/src/__tests__/useJsonEditorTokens.test.ts +0 -59
  146. package/src/__tests__/useMediaRecorder.test.ts +0 -302
  147. package/src/__tests__/useTimelineClock.test.ts +0 -21
  148. package/src/__tests__/versionHistory.test.tsx +0 -197
  149. package/src/__tests__/viewMenuPanel.test.tsx +0 -130
  150. package/src/__tests__/writeCanvasSettings.test.ts +0 -15
  151. package/src/__tests__/wysiwygImageUpload.test.ts +0 -69
  152. package/src/__tests__/wysiwygTemplateBadgeFocus.test.tsx +0 -56
  153. package/src/asciiDiagram/AsciiDiagramExtension.ts +0 -343
  154. package/src/asciiDiagram/AsciiDiagramWidget.tsx +0 -254
  155. package/src/asciiDiagram/RepairableDiagramExtension.ts +0 -200
  156. package/src/asciiDiagram/__tests__/AsciiDiagramExtension.test.ts +0 -164
  157. package/src/asciiDiagram/__tests__/RepairableDiagramExtension.test.ts +0 -159
  158. package/src/asciiDiagram/__tests__/asciiDiagramCommands.test.ts +0 -284
  159. package/src/asciiDiagram/__tests__/asciiDiagramOps.test.ts +0 -114
  160. package/src/asciiDiagram/__tests__/asciiPaste.test.ts +0 -43
  161. package/src/asciiDiagram/asciiDiagramCommands.ts +0 -174
  162. package/src/asciiDiagram/asciiDiagramData.ts +0 -149
  163. package/src/asciiDiagram/asciiDiagramOps.ts +0 -238
  164. package/src/asciiDiagram/asciiPaste.ts +0 -19
  165. package/src/blockProperties.ts +0 -88
  166. package/src/blockRange.ts +0 -132
  167. package/src/blockSlice.ts +0 -75
  168. package/src/blockTagActivity.ts +0 -233
  169. package/src/buildDocumentPreviewMarkdown.ts +0 -168
  170. package/src/buildPreviewDoc.ts +0 -407
  171. package/src/codeContext/CodeContextSectionView.tsx +0 -124
  172. package/src/codeContext/CodeContextZoneManager.ts +0 -149
  173. package/src/codeContext/CodeContextZones.tsx +0 -121
  174. package/src/codeContext/diffContextSections.ts +0 -38
  175. package/src/codeContext/types.ts +0 -75
  176. package/src/codeSnippet/CodeSnippetExtension.ts +0 -205
  177. package/src/codeSnippet/CodeSnippetWidget.tsx +0 -109
  178. package/src/codeSnippet/__tests__/CodeSnippetExtension.test.ts +0 -95
  179. package/src/codeSnippet/__tests__/codeSnippetLanguages.test.ts +0 -50
  180. package/src/codeSnippet/codeSnippetCommands.ts +0 -21
  181. package/src/codeSnippet/codeSnippetData.ts +0 -43
  182. package/src/codeSnippet/codeSnippetLanguages.ts +0 -216
  183. package/src/customTemplates/AddBin.tsx +0 -126
  184. package/src/customTemplates/CustomLayoutManager.tsx +0 -234
  185. package/src/customTemplates/CustomTemplateContext.tsx +0 -188
  186. package/src/customTemplates/LayerToolbar.tsx +0 -580
  187. package/src/customTemplates/ShapeGlyph.tsx +0 -47
  188. package/src/customTemplates/TemplateDesigner.tsx +0 -433
  189. package/src/customTemplates/__tests__/library.test.ts +0 -96
  190. package/src/customTemplates/__tests__/normalizePositions.test.ts +0 -109
  191. package/src/customTemplates/__tests__/shapeDefs.test.ts +0 -49
  192. package/src/customTemplates/__tests__/useMemoryLayerAdapter.test.ts +0 -108
  193. package/src/customTemplates/designer.css +0 -732
  194. package/src/customTemplates/index.ts +0 -31
  195. package/src/customTemplates/library.ts +0 -110
  196. package/src/customTemplates/normalizePositions.ts +0 -75
  197. package/src/customTemplates/shapeDefs.ts +0 -131
  198. package/src/customTemplates/thumbnail.tsx +0 -63
  199. package/src/customTemplates/tokenDefs.ts +0 -60
  200. package/src/customTemplates/useDocCustomTemplates.ts +0 -52
  201. package/src/customTemplates/useMemoryLayerAdapter.ts +0 -129
  202. package/src/customThemes/CustomThemeContext.tsx +0 -185
  203. package/src/customThemes/CustomThemeDialog.tsx +0 -316
  204. package/src/customThemes/ImportThemeSection.tsx +0 -178
  205. package/src/customThemes/__tests__/CustomThemeContext.test.tsx +0 -64
  206. package/src/customThemes/__tests__/CustomThemeDialog.test.tsx +0 -47
  207. package/src/customThemes/__tests__/customThemeLibrary.test.ts +0 -60
  208. package/src/customThemes/__tests__/importThemeSection.test.tsx +0 -192
  209. package/src/customThemes/customThemeLibrary.ts +0 -100
  210. package/src/customThemes/index.ts +0 -37
  211. package/src/customThemes/themeControls.tsx +0 -229
  212. package/src/customThemes/themeDraft.ts +0 -288
  213. package/src/customThemes/useDocCustomThemes.ts +0 -49
  214. package/src/detectMarkdown.ts +0 -62
  215. package/src/diagram/DiagramCanvas.tsx +0 -260
  216. package/src/diagram/DiagramMaximizedOverlay.tsx +0 -46
  217. package/src/diagram/diagramCommands.ts +0 -604
  218. package/src/diagram/diagramConstants.ts +0 -17
  219. package/src/diagram/types.ts +0 -35
  220. package/src/editorScrollSync.ts +0 -73
  221. package/src/embeddedMedia.ts +0 -78
  222. package/src/emojiData.ts +0 -1317
  223. package/src/fileKind.ts +0 -158
  224. package/src/find/FindHighlightExtension.ts +0 -81
  225. package/src/find/FindToolbar.tsx +0 -314
  226. package/src/find/findModel.ts +0 -77
  227. package/src/frontmatter.ts +0 -29
  228. package/src/frontmatterSettings.ts +0 -23
  229. package/src/headingTransition.ts +0 -291
  230. package/src/hooks/useFileDrop.ts +0 -266
  231. package/src/imageEditor/CanvasSurface.tsx +0 -703
  232. package/src/imageEditor/ImageVersionHistoryDropdown.tsx +0 -396
  233. package/src/imageEditor/LayersPanel.tsx +0 -218
  234. package/src/imageEditor/PropertiesPanel.tsx +0 -474
  235. package/src/imageEditor/Toolbar.tsx +0 -459
  236. package/src/imageEditor/createShapeLayer.ts +0 -280
  237. package/src/imageEditor/icons.tsx +0 -68
  238. package/src/imageEditor/image-editor.css +0 -574
  239. package/src/imageEditor/layers/EditorImageLayer.tsx +0 -45
  240. package/src/imageEditor/layers/EditorShapeLayer.tsx +0 -62
  241. package/src/imageEditor/layers/EditorTextLayer.tsx +0 -45
  242. package/src/imageEditor/layers/SelectionHandles.tsx +0 -86
  243. package/src/imageEditor/state.ts +0 -173
  244. package/src/imageEditor/useImageEditor.ts +0 -385
  245. package/src/imageEditor/useImageEditorTokens.ts +0 -70
  246. package/src/index.ts +0 -559
  247. package/src/jsonEditor/EmbeddedRichTextField.tsx +0 -81
  248. package/src/jsonEditor/JsonEditor.tsx +0 -81
  249. package/src/jsonEditor/JsonEditorContext.tsx +0 -81
  250. package/src/jsonEditor/RenderNode.tsx +0 -87
  251. package/src/jsonEditor/editors.tsx +0 -745
  252. package/src/jsonEditor/index.ts +0 -2
  253. package/src/jsonEditor/json-editor.css +0 -463
  254. package/src/jsonEditor/useJsonEditorTokens.ts +0 -33
  255. package/src/markdownCodeFence.ts +0 -72
  256. package/src/mediaDragMime.ts +0 -32
  257. package/src/mediaEntries.ts +0 -12
  258. package/src/mediaReferences.ts +0 -301
  259. package/src/mermaid/MermaidDiagramCanvas.tsx +0 -693
  260. package/src/mermaid/MermaidDiagramExtension.ts +0 -243
  261. package/src/mermaid/MermaidDiagramTypeThumbnail.tsx +0 -184
  262. package/src/mermaid/MermaidDiagramWidget.tsx +0 -653
  263. package/src/mermaid/MermaidShapePalette.tsx +0 -245
  264. package/src/mermaid/__tests__/MermaidDiagramExtension.test.ts +0 -361
  265. package/src/mermaid/__tests__/mermaidDiagramTypes.test.ts +0 -35
  266. package/src/mermaid/__tests__/mermaidRenderer.test.ts +0 -49
  267. package/src/mermaid/__tests__/mermaidSourceOps.test.ts +0 -213
  268. package/src/mermaid/__tests__/mermaidSyntax.test.ts +0 -71
  269. package/src/mermaid/mermaidCommands.ts +0 -34
  270. package/src/mermaid/mermaidData.ts +0 -31
  271. package/src/mermaid/mermaidDiagramTypes.ts +0 -325
  272. package/src/mermaid/mermaidModel.ts +0 -31
  273. package/src/mermaid/mermaidRenderer.ts +0 -181
  274. package/src/mermaid/mermaidShapes.ts +0 -113
  275. package/src/mermaid/mermaidSourceOps.ts +0 -454
  276. package/src/monaco.ts +0 -35
  277. package/src/monacoWorkers.ts +0 -89
  278. package/src/outlineSource.ts +0 -171
  279. package/src/presentation/PresentationMode.tsx +0 -596
  280. package/src/rawEditorIsolation.ts +0 -18
  281. package/src/recorder/RecorderButton.tsx +0 -80
  282. package/src/recorder/RecorderModal.tsx +0 -706
  283. package/src/recorder/RecorderPanel.tsx +0 -77
  284. package/src/recorder/formats.ts +0 -159
  285. package/src/recorder/hooks/useMediaRecorder.ts +0 -436
  286. package/src/recorder/hooks/useStreamPreview.ts +0 -47
  287. package/src/recorder/insertMediaBlock.ts +0 -30
  288. package/src/recorder/sources/cameraStream.ts +0 -32
  289. package/src/recorder/sources/micStream.ts +0 -25
  290. package/src/recorder/sources/screenStream.ts +0 -162
  291. package/src/recorder/timingJson.ts +0 -66
  292. package/src/resolveBlockVisual.ts +0 -39
  293. package/src/scene/Scene.tsx +0 -647
  294. package/src/scene/SceneBlockExtension.ts +0 -205
  295. package/src/scene/SceneBlockToolbar.tsx +0 -216
  296. package/src/scene/SceneBlockWidget.tsx +0 -441
  297. package/src/scene/ScenePropsBar.tsx +0 -85
  298. package/src/scene/SceneSelection.tsx +0 -111
  299. package/src/scene/SceneSideToolbar.tsx +0 -89
  300. package/src/scene/SceneViewControls.tsx +0 -43
  301. package/src/scene/SceneViewport.tsx +0 -106
  302. package/src/scene/ShapePalette.tsx +0 -196
  303. package/src/scene/__tests__/DiagramAdapter.test.ts +0 -142
  304. package/src/scene/__tests__/SceneBlockExtension.test.ts +0 -33
  305. package/src/scene/__tests__/bezierEdit.test.ts +0 -85
  306. package/src/scene/__tests__/blockLayers.test.ts +0 -57
  307. package/src/scene/__tests__/fitScale.test.ts +0 -19
  308. package/src/scene/__tests__/sceneIsolation.test.tsx +0 -119
  309. package/src/scene/__tests__/shapeLayers.test.ts +0 -106
  310. package/src/scene/__tests__/useSceneHitTest.test.ts +0 -90
  311. package/src/scene/__tests__/useScenePanZoom.test.ts +0 -130
  312. package/src/scene/adapters/DiagramAdapter.ts +0 -79
  313. package/src/scene/adapters/DrawingAdapter.ts +0 -420
  314. package/src/scene/adapters/LayoutAdapter.ts +0 -313
  315. package/src/scene/adapters/blockLayers.ts +0 -159
  316. package/src/scene/commands/SceneCommand.ts +0 -84
  317. package/src/scene/commands/drawingCommands.ts +0 -318
  318. package/src/scene/commands/layoutCommands.ts +0 -301
  319. package/src/scene/fitScale.ts +0 -17
  320. package/src/scene/hooks/useSceneHitTest.ts +0 -105
  321. package/src/scene/hooks/useScenePanZoom.ts +0 -154
  322. package/src/scene/hooks/useSceneSelection.ts +0 -62
  323. package/src/scene/index.ts +0 -90
  324. package/src/scene/layers/DiagramEdges.tsx +0 -142
  325. package/src/scene/layers/edgeGeometry.ts +0 -104
  326. package/src/scene/layers/nodeCard.tsx +0 -164
  327. package/src/scene/layers/renderLayer.tsx +0 -70
  328. package/src/scene/layers/shapeLayers.ts +0 -201
  329. package/src/scene/paths/bezierEdit.ts +0 -208
  330. package/src/scene/scene.css +0 -874
  331. package/src/scene/text/SceneTextOverlay.tsx +0 -161
  332. package/src/scene/text/sceneTextChannel.ts +0 -46
  333. package/src/scene/text/sceneTextConfig.ts +0 -31
  334. package/src/scene/text/sceneTiptap.ts +0 -36
  335. package/src/scene/text/useSceneTextEditing.ts +0 -39
  336. package/src/scene/tools/ConnectTool.ts +0 -209
  337. package/src/scene/tools/DrawingConnectTool.ts +0 -231
  338. package/src/scene/tools/PathTool.ts +0 -158
  339. package/src/scene/tools/PlaceTool.ts +0 -47
  340. package/src/scene/tools/SceneTool.ts +0 -85
  341. package/src/scene/tools/SelectTool.ts +0 -300
  342. package/src/scene/tools/ShapeTool.ts +0 -143
  343. package/src/scene/tools/TextTool.ts +0 -72
  344. package/src/scene/tools/TokenTool.ts +0 -95
  345. package/src/scene/tools/createDrawShapeTool.ts +0 -82
  346. package/src/selectionConversions.ts +0 -155
  347. package/src/styles/ascii-diagram.css +0 -79
  348. package/src/styles/ascii-timeline.css +0 -596
  349. package/src/styles/code-context.css +0 -155
  350. package/src/styles/code-snippet.css +0 -76
  351. package/src/styles/diagram.css +0 -183
  352. package/src/styles/editor.css +0 -7131
  353. package/src/styles/folder-view.css +0 -210
  354. package/src/styles/image-edit-affordance.css +0 -201
  355. package/src/styles/index.css +0 -20
  356. package/src/styles/mermaid-diagram.css +0 -487
  357. package/src/styles/tree-view.css +0 -189
  358. package/src/teleprompter/TeleprompterControls.tsx +0 -218
  359. package/src/teleprompter/TeleprompterSelfView.tsx +0 -22
  360. package/src/teleprompter/TeleprompterSurface.tsx +0 -267
  361. package/src/teleprompter/TeleprompterView.tsx +0 -338
  362. package/src/teleprompter/canvasRenderer.ts +0 -161
  363. package/src/teleprompter/floatingWindow.ts +0 -352
  364. package/src/teleprompter/index.ts +0 -61
  365. package/src/teleprompter/pcmWorklet.ts +0 -62
  366. package/src/teleprompter/recording/insertPreamble.ts +0 -80
  367. package/src/teleprompter/recording/narrationSave.ts +0 -134
  368. package/src/teleprompter/recording/useNarrationRecorder.ts +0 -367
  369. package/src/teleprompter/scrollModel.ts +0 -85
  370. package/src/teleprompter/teleprompterTheme.ts +0 -303
  371. package/src/teleprompter/types.ts +0 -38
  372. package/src/teleprompter/useFloatingWindow.ts +0 -74
  373. package/src/teleprompter/useMicAnalysis.ts +0 -211
  374. package/src/teleprompter/useTeleprompter.ts +0 -421
  375. package/src/templateContentPreviewResolver.ts +0 -360
  376. package/src/timeline/TimelineEditorWidget.tsx +0 -861
  377. package/src/timeline/TimelineViewExtension.ts +0 -252
  378. package/src/timeline/__tests__/TimelineEditorWidget.test.tsx +0 -414
  379. package/src/timeline/__tests__/TimelineViewExtension.test.ts +0 -163
  380. package/src/timeline/__tests__/timelineCommands.test.ts +0 -359
  381. package/src/timeline/__tests__/timelineOps.test.ts +0 -277
  382. package/src/timeline/__tests__/timelinePaste.test.ts +0 -34
  383. package/src/timeline/timelineCommands.ts +0 -421
  384. package/src/timeline/timelineData.ts +0 -54
  385. package/src/timeline/timelineOps.ts +0 -381
  386. package/src/timeline/timelinePaste.ts +0 -8
  387. package/src/timelineSource.ts +0 -244
  388. package/src/tiptap/TiptapAudio.tsx +0 -86
  389. package/src/tiptap/TiptapVideo.tsx +0 -119
  390. package/src/tiptap/useResolvedMediaSrc.ts +0 -47
  391. package/src/tiptapBridge.ts +0 -986
  392. package/src/tooltipPlacement.ts +0 -13
  393. package/src/transformStyleId.ts +0 -17
  394. package/src/transitionCatalog.ts +0 -159
  395. package/src/treeview/TreeOutlineWidget.tsx +0 -390
  396. package/src/treeview/TreeViewExtension.ts +0 -250
  397. package/src/treeview/__tests__/TreeOutlineWidget.test.tsx +0 -156
  398. package/src/treeview/__tests__/TreeViewExtension.test.ts +0 -122
  399. package/src/treeview/__tests__/treeOps.test.ts +0 -177
  400. package/src/treeview/__tests__/treePaste.test.ts +0 -40
  401. package/src/treeview/__tests__/treeViewCommands.test.ts +0 -179
  402. package/src/treeview/treeOps.ts +0 -231
  403. package/src/treeview/treePaste.ts +0 -13
  404. package/src/treeview/treeViewCommands.ts +0 -99
  405. package/src/treeview/treeViewData.ts +0 -41
  406. package/src/types/monaco-shims.d.ts +0 -10
  407. package/src/useBlockNavigator.ts +0 -153
  408. package/src/useHeadingLayout.ts +0 -294
  409. package/src/useMonacoLoader.ts +0 -82
  410. package/src/useTimelineClock.ts +0 -76
  411. package/src/utils/collectInlineFontAwesomeCss.ts +0 -69
  412. package/src/utils/dropUtils.ts +0 -136
  413. package/src/utils/normalizeMalformedAssetUrl.ts +0 -22
  414. package/src/writeCanvasSettings.ts +0 -30
  415. package/src/wysiwygImageUpload.ts +0 -113
@@ -0,0 +1,986 @@
1
+ // src/tiptapBridge.ts
2
+ import { resolveIcon } from "@bendyline/squisq/icons";
3
+ import {
4
+ matchTrailingTemplateAnnotation,
5
+ matchTrailingPandocAttr,
6
+ tokenizeAttrTokens
7
+ } from "@bendyline/squisq/markdown";
8
+ var RE_BOLD_STAR = /\*\*(?![\s*])(.+?)(?<![\s*])\*\*/g;
9
+ var RE_BOLD_UNDER = /(?<![\p{L}\p{N}_])__(?![\s_])(.+?)(?<![\s_])__(?![\p{L}\p{N}_])/gu;
10
+ var RE_ITALIC_STAR = /\*(?![\s*])(.+?)(?<![\s*])\*/g;
11
+ var RE_ITALIC_UNDER = /(?<![\p{L}\p{N}_])_(?![\s_])(.+?)(?<![\s_])_(?![\p{L}\p{N}_])/gu;
12
+ var RE_STRIKETHROUGH = /~~(.+?)~~/g;
13
+ var ESCAPABLE_MD_CHARS = ["*", "_", "~", "\\"];
14
+ var RE_MD_ESCAPE = /\\([*_~\\])/g;
15
+ var RE_INLINE_CODE = /`(.+?)`/g;
16
+ var RE_IMAGE = /!\[(.*?)\]\((.+?)\)/g;
17
+ var RE_MENTION = /@\[([^\]]+?)\]\(([a-z][a-z0-9+.-]*)\\?:([^)\s]+)\)/gi;
18
+ var RE_MENTION_TAG = /<span\b[^>]*?\bdata-mention\b[^>]*?>(?:<[^>]+>)*([^<]*)<\/span>/gi;
19
+ var RE_ICON_MD = /\{\[([a-zA-Z0-9_:-]+)\]\}/g;
20
+ var RE_ICON_TAG = /<i\b[^>]*?\bdata-icon="([^"]*)"[^>]*?><\/i>/gi;
21
+ var RE_STRONG_TAG = /<strong>(.*?)<\/strong>/g;
22
+ var RE_B_TAG = /<b>(.*?)<\/b>/g;
23
+ var RE_EM_TAG = /<em>(.*?)<\/em>/g;
24
+ var RE_I_TAG = /<i>(.*?)<\/i>/g;
25
+ var RE_S_TAG = /<s>(.*?)<\/s>/g;
26
+ var RE_DEL_TAG = /<del>(.*?)<\/del>/g;
27
+ var RE_CODE_TAG = /<code>(.*?)<\/code>/g;
28
+ var RE_A_TAG = /<a\b([^>]*)>(.*?)<\/a>/g;
29
+ var RE_IMG_TAG = /<img\b([^>]*)>/g;
30
+ var RE_STRIP_TAGS = /<[^>]+>/g;
31
+ function markdownToTiptap(markdown) {
32
+ if (!markdown.trim()) return "<p></p>";
33
+ const html = markdown.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
34
+ const lines = html.split("\n");
35
+ const frontmatterEnd = findFrontmatterEnd(lines);
36
+ const outputBlocks = [];
37
+ let inCodeBlock = false;
38
+ let codeBlockLang = "";
39
+ let codeBlockLines = [];
40
+ const listStack = [];
41
+ let inTable = false;
42
+ let tableLines = [];
43
+ let pendingBlankLines = 0;
44
+ let lastBlockWasList = false;
45
+ const flushPendingBlankParagraphs = () => {
46
+ if (pendingBlankLines === 0) return;
47
+ const emptyParagraphs = outputBlocks.length === 0 ? pendingBlankLines : Math.max(0, pendingBlankLines - 1);
48
+ for (let i = 0; i < emptyParagraphs; i++) {
49
+ outputBlocks.push("<p></p>");
50
+ }
51
+ pendingBlankLines = 0;
52
+ };
53
+ const pushBlock = (block) => {
54
+ flushPendingBlankParagraphs();
55
+ outputBlocks.push(block);
56
+ lastBlockWasList = false;
57
+ };
58
+ const sealOpenItem = (level) => {
59
+ if (level.openAttrs === null) return;
60
+ level.items.push(`<li${level.openAttrs}>${level.openContent}</li>`);
61
+ level.openAttrs = null;
62
+ level.openContent = "";
63
+ };
64
+ const popListLevel = () => {
65
+ const level = listStack.pop();
66
+ if (!level) return;
67
+ sealOpenItem(level);
68
+ if (level.items.length === 0) return;
69
+ const tag = level.type === "ol" ? "ol" : "ul";
70
+ let attr = level.type === "task" ? ' data-type="taskList"' : "";
71
+ if (level.type === "ol" && level.start != null && level.start !== 1) {
72
+ attr += ` start="${level.start}"`;
73
+ }
74
+ const html2 = `<${tag}${attr}>${level.items.join("")}</${tag}>`;
75
+ const parent = listStack[listStack.length - 1];
76
+ if (!parent) {
77
+ pushBlock(html2);
78
+ lastBlockWasList = true;
79
+ return;
80
+ }
81
+ if (parent.openAttrs === null) {
82
+ parent.openAttrs = parent.type === "task" ? ' data-type="taskItem"' : "";
83
+ parent.openContent = "<p></p>";
84
+ }
85
+ parent.openContent += html2;
86
+ };
87
+ const flushList = () => {
88
+ while (listStack.length > 0) popListLevel();
89
+ };
90
+ const addListItem = (indent, type, attrs, content, start = null) => {
91
+ while (listStack.length > 0 && indent < listStack[listStack.length - 1].minIndent) {
92
+ popListLevel();
93
+ }
94
+ const top = listStack[listStack.length - 1];
95
+ if (!top) {
96
+ listStack.push({
97
+ indent,
98
+ minIndent: 0,
99
+ type,
100
+ start,
101
+ items: [],
102
+ openAttrs: attrs,
103
+ openContent: content
104
+ });
105
+ return;
106
+ }
107
+ if (indent > top.indent) {
108
+ listStack.push({
109
+ indent,
110
+ minIndent: top.indent + 1,
111
+ type,
112
+ start,
113
+ items: [],
114
+ openAttrs: attrs,
115
+ openContent: content
116
+ });
117
+ return;
118
+ }
119
+ if (indent < top.indent) top.indent = indent;
120
+ if (top.type !== type) {
121
+ const { indent: depth, minIndent } = top;
122
+ popListLevel();
123
+ listStack.push({
124
+ indent: depth,
125
+ minIndent,
126
+ type,
127
+ start,
128
+ items: [],
129
+ openAttrs: attrs,
130
+ openContent: content
131
+ });
132
+ return;
133
+ }
134
+ sealOpenItem(top);
135
+ top.openAttrs = attrs;
136
+ top.openContent = content;
137
+ };
138
+ const flushTable = () => {
139
+ if (!inTable || tableLines.length === 0) {
140
+ inTable = false;
141
+ tableLines = [];
142
+ return;
143
+ }
144
+ const separatorCells = tableLines.length >= 2 ? parseTableCells(tableLines[1]) : [];
145
+ const isSeparator = separatorCells.length > 0 && separatorCells.every((cell) => /^:?-+:?$/.test(cell.trim()));
146
+ if (tableLines.length < 2 || !isSeparator) {
147
+ for (const tl of tableLines) {
148
+ pushBlock(`<p>${inlineToHtml(tl)}</p>`);
149
+ }
150
+ inTable = false;
151
+ tableLines = [];
152
+ return;
153
+ }
154
+ const alignments = parseAlignments(tableLines[1]);
155
+ const headerCells = parseTableCells(tableLines[0]);
156
+ const thHtml = headerCells.map((cell, i) => {
157
+ const align = alignments[i];
158
+ const style = align ? ` style="text-align: ${align}"` : "";
159
+ return `<th${style}>${inlineToHtml(cell)}</th>`;
160
+ }).join("");
161
+ const bodyHtml = tableLines.slice(2).map((rowLine) => {
162
+ const cells = parseTableCells(rowLine);
163
+ const tdHtml = cells.map((cell, i) => {
164
+ const align = alignments[i];
165
+ const style = align ? ` style="text-align: ${align}"` : "";
166
+ return `<td${style}>${inlineToHtml(cell)}</td>`;
167
+ }).join("");
168
+ return `<tr>${tdHtml}</tr>`;
169
+ }).join("");
170
+ pushBlock(`<table><thead><tr>${thHtml}</tr></thead><tbody>${bodyHtml}</tbody></table>`);
171
+ inTable = false;
172
+ tableLines = [];
173
+ };
174
+ for (let i = 0; i < lines.length; i++) {
175
+ const line = lines[i];
176
+ if (line.startsWith("```")) {
177
+ if (!inCodeBlock) {
178
+ flushList();
179
+ flushTable();
180
+ flushPendingBlankParagraphs();
181
+ inCodeBlock = true;
182
+ codeBlockLang = line.slice(3).trim();
183
+ codeBlockLines = [];
184
+ continue;
185
+ } else {
186
+ const langAttr = codeBlockLang ? ` class="language-${escapeHtml(codeBlockLang)}"` : "";
187
+ pushBlock(`<pre><code${langAttr}>${escapeHtml(codeBlockLines.join("\n"))}</code></pre>`);
188
+ inCodeBlock = false;
189
+ codeBlockLang = "";
190
+ codeBlockLines = [];
191
+ continue;
192
+ }
193
+ }
194
+ if (inCodeBlock) {
195
+ codeBlockLines.push(line);
196
+ continue;
197
+ }
198
+ if (inTable && !/^\|.*\|$/.test(line.trim())) {
199
+ flushTable();
200
+ }
201
+ if (line.trim() === "") {
202
+ flushList();
203
+ pendingBlankLines++;
204
+ continue;
205
+ }
206
+ const precededByBlank = pendingBlankLines > 0 || outputBlocks.length === 0;
207
+ if (precededByBlank && !inTable && listStack.length === 0 && !lastBlockWasList && isIndentedCodeLine(line)) {
208
+ const codeLines = [];
209
+ let scan = i;
210
+ for (; scan < lines.length; scan++) {
211
+ const scanned = lines[scan];
212
+ if (scanned.trim() === "") {
213
+ codeLines.push("");
214
+ continue;
215
+ }
216
+ if (!isIndentedCodeLine(scanned)) break;
217
+ codeLines.push(stripCodeIndent(scanned));
218
+ }
219
+ let end = codeLines.length;
220
+ while (end > 0 && codeLines[end - 1] === "") end--;
221
+ const trailingBlanks = codeLines.length - end;
222
+ codeLines.length = end;
223
+ i = scan - trailingBlanks - 1;
224
+ pushBlock(`<pre><code>${escapeHtml(codeLines.join("\n"))}</code></pre>`);
225
+ continue;
226
+ }
227
+ flushPendingBlankParagraphs();
228
+ const headingMatch = line.match(/^(#{1,6})\s+(.+)$/);
229
+ if (headingMatch) {
230
+ flushList();
231
+ pushBlock(headingToHtml(headingMatch[1].length, headingMatch[2]));
232
+ continue;
233
+ }
234
+ if (/^(---|\*\*\*|___)(\s*)$/.test(line.trim())) {
235
+ flushList();
236
+ pushBlock("<hr>");
237
+ continue;
238
+ }
239
+ if (line.startsWith("> ")) {
240
+ flushList();
241
+ const quoteLines = [line.slice(2)];
242
+ while (i + 1 < lines.length && lines[i + 1].startsWith("> ")) {
243
+ i++;
244
+ quoteLines.push(lines[i].slice(2));
245
+ }
246
+ pushBlock(
247
+ `<blockquote>${quoteLines.map((quoteLine) => `<p>${inlineToHtml(quoteLine)}</p>`).join("")}</blockquote>`
248
+ );
249
+ continue;
250
+ }
251
+ const taskMatch = line.match(/^([ \t]*)[-*+]\s+\[([xX ])\]\s*(.*)$/);
252
+ if (taskMatch) {
253
+ const checkedAttr = taskMatch[2].toLowerCase() === "x" ? ' data-checked="true"' : "";
254
+ addListItem(
255
+ indentWidth(taskMatch[1]),
256
+ "task",
257
+ ` data-type="taskItem"${checkedAttr}`,
258
+ `<p>${inlineToHtml(taskMatch[3])}</p>`
259
+ );
260
+ continue;
261
+ }
262
+ const ulMatch = line.match(/^([ \t]*)[-*+]\s+(.+)$/);
263
+ if (ulMatch) {
264
+ addListItem(indentWidth(ulMatch[1]), "ul", "", `<p>${inlineToHtml(ulMatch[2])}</p>`);
265
+ continue;
266
+ }
267
+ const olMatch = line.match(/^([ \t]*)(\d+)\.\s+(.+)$/);
268
+ if (olMatch) {
269
+ addListItem(
270
+ indentWidth(olMatch[1]),
271
+ "ol",
272
+ "",
273
+ `<p>${inlineToHtml(olMatch[3])}</p>`,
274
+ parseInt(olMatch[2], 10)
275
+ );
276
+ continue;
277
+ }
278
+ if (/^\|.*\|$/.test(line.trim())) {
279
+ if (!inTable) {
280
+ flushList();
281
+ inTable = true;
282
+ tableLines = [];
283
+ }
284
+ tableLines.push(line);
285
+ continue;
286
+ }
287
+ const standaloneImageMatch = line.trim().match(/^!\[(.*?)\]\((.+?)\)$/);
288
+ if (standaloneImageMatch) {
289
+ flushList();
290
+ const alt = escapeHtml(standaloneImageMatch[1] ?? "");
291
+ const src = escapeHtml(standaloneImageMatch[2] ?? "");
292
+ pushBlock(`<img alt="${alt}" src="${src}">`);
293
+ continue;
294
+ }
295
+ const trimmed = line.trim();
296
+ if (/^<img\b[^>]*>$/i.test(trimmed)) {
297
+ flushList();
298
+ pushBlock(trimmed);
299
+ continue;
300
+ }
301
+ if (/^<(?:video|audio)\b[^>]*>(?:[\s\S]*?<\/(?:video|audio)>)?$/i.test(trimmed)) {
302
+ flushList();
303
+ pushBlock(trimmed);
304
+ continue;
305
+ }
306
+ const setextLevel = i + 1 < lines.length && i + 1 > frontmatterEnd ? matchSetextUnderline(lines[i + 1]) : null;
307
+ if (setextLevel !== null) {
308
+ flushList();
309
+ i++;
310
+ pushBlock(headingToHtml(setextLevel, line.trim()));
311
+ continue;
312
+ }
313
+ flushList();
314
+ pushBlock(`<p>${inlineToHtml(line)}</p>`);
315
+ }
316
+ if (inCodeBlock) {
317
+ const langAttr = codeBlockLang ? ` class="language-${escapeHtml(codeBlockLang)}"` : "";
318
+ pushBlock(`<pre><code${langAttr}>${escapeHtml(codeBlockLines.join("\n"))}</code></pre>`);
319
+ }
320
+ flushList();
321
+ flushTable();
322
+ flushPendingBlankParagraphs();
323
+ return outputBlocks.join("") || "<p></p>";
324
+ }
325
+ function tiptapToMarkdown(html) {
326
+ if (!html || html === "<p></p>") return "";
327
+ const lines = [];
328
+ let remaining = html;
329
+ while (remaining.length > 0) {
330
+ const headingMatch = remaining.match(/^<h([1-6])([^>]*)>(.*?)<\/h\1>/s);
331
+ if (headingMatch) {
332
+ const level = parseInt(headingMatch[1], 10);
333
+ const attrs = headingMatch[2];
334
+ const headingHtml = headingMatch[3];
335
+ const chromeStart = headingHtml.search(
336
+ /<span\b[^>]*\bclass="[^"]*\bsquisq-(?:template|props)-badge\b[^"]*"[^>]*>/i
337
+ );
338
+ let text = htmlToInline(chromeStart >= 0 ? headingHtml.slice(0, chromeStart) : headingHtml);
339
+ const blockAttrsMatch = attrs.match(/data-block-attrs="([^"]*)"/);
340
+ const tmplMatch = attrs.match(/data-template="([^"]+)"/);
341
+ const paramsMatch = attrs.match(/data-template-params="([^"]+)"/);
342
+ const hasEmptyTemplateAnnotation = /\sdata-template-empty(?:="[^"]*")?/.test(attrs);
343
+ if (blockAttrsMatch) {
344
+ const inner = unescapeHtml(blockAttrsMatch[1]);
345
+ text += ` {${inner}}`;
346
+ }
347
+ if (tmplMatch || paramsMatch) {
348
+ let annotation = tmplMatch ? tmplMatch[1] : "";
349
+ if (paramsMatch) {
350
+ annotation += (annotation ? " " : "") + unescapeHtml(paramsMatch[1]);
351
+ }
352
+ text += ` {[${annotation}]}`;
353
+ } else if (hasEmptyTemplateAnnotation) {
354
+ text += " {[]}";
355
+ }
356
+ lines.push("#".repeat(level) + " " + text);
357
+ lines.push("");
358
+ remaining = remaining.slice(headingMatch[0].length);
359
+ continue;
360
+ }
361
+ const codeMatch = remaining.match(/^<pre\b[^>]*><code\b([^>]*)>(.*?)<\/code><\/pre>/s);
362
+ if (codeMatch) {
363
+ const lang = /\bclass="language-([^"]*)"/.exec(codeMatch[1] ?? "")?.[1] ?? "";
364
+ const code = unescapeHtml(codeMatch[2]);
365
+ lines.push("```" + lang);
366
+ lines.push(code);
367
+ lines.push("```");
368
+ lines.push("");
369
+ remaining = remaining.slice(codeMatch[0].length);
370
+ continue;
371
+ }
372
+ const bqMatch = remaining.match(/^<blockquote>(.*?)<\/blockquote>/s);
373
+ if (bqMatch) {
374
+ const paragraphs = bqMatch[1].split(/<\/p>\s*<p[^>]*>/i).map((paragraph) => paragraph.replace(/^<p[^>]*>/i, "").replace(/<\/p>\s*$/i, ""));
375
+ for (const paragraph of paragraphs) {
376
+ for (const quoteLine of htmlToInline(paragraph).split("\n")) {
377
+ lines.push("> " + quoteLine);
378
+ }
379
+ }
380
+ const next = remaining.slice(bqMatch[0].length);
381
+ if (!/^\s*<blockquote>/.test(next)) lines.push("");
382
+ remaining = next;
383
+ continue;
384
+ }
385
+ if (remaining.startsWith("<hr>") || remaining.startsWith("<hr/>") || remaining.startsWith("<hr />")) {
386
+ const hrMatch = remaining.match(/^<hr\s*\/?>/);
387
+ lines.push("---");
388
+ lines.push("");
389
+ remaining = remaining.slice(hrMatch[0].length);
390
+ continue;
391
+ }
392
+ const tableMatch = remaining.match(
393
+ /^<div[^>]*class="[^"]*tableWrapper[^"]*"[^>]*><table[^>]*>(.*?)<\/table>\s*<\/div>/s
394
+ ) || remaining.match(/^<table[^>]*>(.*?)<\/table>/s);
395
+ if (tableMatch) {
396
+ const tableContent = tableMatch[1];
397
+ const rows = [];
398
+ const rowRegex = /<tr[^>]*>(.*?)<\/tr>/gs;
399
+ let rowExec;
400
+ while ((rowExec = rowRegex.exec(tableContent)) !== null) {
401
+ const rowHtml = rowExec[1];
402
+ const cells = [];
403
+ const cellRegex = /<(th|td)([^>]*)>(.*?)<\/\1>/gs;
404
+ let cellExec;
405
+ while ((cellExec = cellRegex.exec(rowHtml)) !== null) {
406
+ const tag = cellExec[1];
407
+ const attrs = cellExec[2];
408
+ const content = htmlToInline(cellExec[3].replace(/<\/?p>/g, ""));
409
+ const alignExec = attrs.match(/text-align:\s*(left|center|right)/);
410
+ cells.push({
411
+ content,
412
+ align: alignExec ? alignExec[1] : null,
413
+ isHeader: tag === "th"
414
+ });
415
+ }
416
+ if (cells.length > 0) {
417
+ rows.push(cells);
418
+ }
419
+ }
420
+ if (rows.length > 0) {
421
+ const headerIdx = rows.findIndex((r) => r.some((c) => c.isHeader));
422
+ const hIdx = headerIdx >= 0 ? headerIdx : 0;
423
+ const headerRow = rows[hIdx];
424
+ const dataRows = rows.filter((_, i) => i !== hIdx);
425
+ const aligns = headerRow.map((c) => c.align);
426
+ lines.push("| " + headerRow.map((c) => c.content || " ").join(" | ") + " |");
427
+ lines.push(
428
+ "| " + aligns.map((a) => {
429
+ if (a === "center") return ":---:";
430
+ if (a === "right") return "---:";
431
+ return "---";
432
+ }).join(" | ") + " |"
433
+ );
434
+ for (const row of dataRows) {
435
+ lines.push("| " + row.map((c) => c.content || " ").join(" | ") + " |");
436
+ }
437
+ lines.push("");
438
+ }
439
+ remaining = remaining.slice(tableMatch[0].length);
440
+ continue;
441
+ }
442
+ const listOpenMatch = remaining.match(/^<(ul|ol)\b([^>]*)>/i);
443
+ if (listOpenMatch) {
444
+ const tag = listOpenMatch[1].toLowerCase();
445
+ const matched = matchBalancedTag(remaining, 0, tag);
446
+ if (matched) {
447
+ const isTask = /data-type="taskList"/i.test(listOpenMatch[2] ?? "");
448
+ lines.push(
449
+ ...renderList(matched.inner, tag === "ol", isTask, "", readListStart(listOpenMatch[2]))
450
+ );
451
+ lines.push("");
452
+ remaining = remaining.slice(matched.end);
453
+ continue;
454
+ }
455
+ }
456
+ const pMatch = remaining.match(/^<p>(.*?)<\/p>/s);
457
+ if (pMatch) {
458
+ const text = htmlToInline(pMatch[1]);
459
+ if (text.trim()) {
460
+ lines.push(text);
461
+ lines.push("");
462
+ } else {
463
+ lines.push("");
464
+ }
465
+ remaining = remaining.slice(pMatch[0].length);
466
+ continue;
467
+ }
468
+ const imgMatch = remaining.match(/^<img\b([^>]*)>/);
469
+ if (imgMatch) {
470
+ const attrs = imgMatch[1] ?? "";
471
+ const src = /\bsrc="([^"]*)"/i.exec(attrs)?.[1];
472
+ if (src) {
473
+ const alt = /\balt="([^"]*)"/i.exec(attrs)?.[1] ?? "";
474
+ lines.push(serializeImage(src, alt, attrs));
475
+ lines.push("");
476
+ }
477
+ remaining = remaining.slice(imgMatch[0].length);
478
+ continue;
479
+ }
480
+ const mediaMatch = remaining.match(/^<(video|audio)\b([^>]*)>(?:[\s\S]*?<\/\1>)?/);
481
+ if (mediaMatch) {
482
+ const tag = mediaMatch[1] === "video" ? "video" : "audio";
483
+ lines.push(serializeMediaTag(tag, mediaMatch[2] ?? ""));
484
+ lines.push("");
485
+ remaining = remaining.slice(mediaMatch[0].length);
486
+ continue;
487
+ }
488
+ const skipMatch = remaining.match(/^(<[^>]+>|\s+)/);
489
+ if (skipMatch) {
490
+ remaining = remaining.slice(skipMatch[0].length);
491
+ continue;
492
+ }
493
+ const textMatch = remaining.match(/^([^<]+)/);
494
+ if (textMatch) {
495
+ lines.push(unescapeHtml(textMatch[1]));
496
+ remaining = remaining.slice(textMatch[0].length);
497
+ continue;
498
+ }
499
+ remaining = remaining.slice(1);
500
+ }
501
+ return lines.join("\n");
502
+ }
503
+ function matchBalancedTag(html, start, tag) {
504
+ const re = new RegExp(`<${tag}\\b[^>]*>|</${tag}\\s*>`, "gi");
505
+ re.lastIndex = start;
506
+ let depth = 0;
507
+ let innerStart = -1;
508
+ let match;
509
+ while ((match = re.exec(html)) !== null) {
510
+ if (match[0][1] === "/") {
511
+ depth--;
512
+ if (depth === 0)
513
+ return { inner: html.slice(innerStart, match.index), end: match.index + match[0].length };
514
+ if (depth < 0) return null;
515
+ } else {
516
+ if (depth === 0) {
517
+ if (match.index !== start) return null;
518
+ innerStart = match.index + match[0].length;
519
+ }
520
+ depth++;
521
+ }
522
+ }
523
+ return null;
524
+ }
525
+ function splitTopLevelListItems(inner) {
526
+ const items = [];
527
+ const re = /<li\b([^>]*)>|<\/li\s*>/gi;
528
+ let depth = 0;
529
+ let itemStart = -1;
530
+ let itemAttrs = "";
531
+ let match;
532
+ while ((match = re.exec(inner)) !== null) {
533
+ if (match[0][1] === "/") {
534
+ depth--;
535
+ if (depth === 0 && itemStart >= 0) {
536
+ items.push({ attrs: itemAttrs, inner: inner.slice(itemStart, match.index) });
537
+ }
538
+ if (depth < 0) depth = 0;
539
+ } else {
540
+ if (depth === 0) {
541
+ itemStart = match.index + match[0].length;
542
+ itemAttrs = match[1] ?? "";
543
+ }
544
+ depth++;
545
+ }
546
+ }
547
+ return items;
548
+ }
549
+ function readListStart(attrs) {
550
+ const parsed = parseInt(/\bstart="(\d+)"/i.exec(attrs ?? "")?.[1] ?? "", 10);
551
+ return Number.isFinite(parsed) ? parsed : 1;
552
+ }
553
+ function splitItemContent(itemHtml) {
554
+ const nested = [];
555
+ let content = "";
556
+ let cursor = 0;
557
+ const re = /<(ul|ol)\b([^>]*)>/gi;
558
+ let match;
559
+ while ((match = re.exec(itemHtml)) !== null) {
560
+ const tag = match[1].toLowerCase();
561
+ const matched = matchBalancedTag(itemHtml, match.index, tag);
562
+ if (!matched) break;
563
+ content += itemHtml.slice(cursor, match.index);
564
+ nested.push({
565
+ ordered: tag === "ol",
566
+ task: /data-type="taskList"/i.test(match[2] ?? ""),
567
+ inner: matched.inner,
568
+ start: readListStart(match[2])
569
+ });
570
+ cursor = matched.end;
571
+ re.lastIndex = matched.end;
572
+ }
573
+ return { content: content + itemHtml.slice(cursor), nested };
574
+ }
575
+ function renderList(inner, ordered, task, indent, start = 1) {
576
+ const lines = [];
577
+ const items = splitTopLevelListItems(inner);
578
+ items.forEach((item, idx) => {
579
+ const { content, nested } = splitItemContent(item.inner);
580
+ const marker = ordered ? `${start + idx}. ` : "- ";
581
+ if (task) {
582
+ const checked = /data-checked="true"/.test(item.attrs);
583
+ const body = content.replace(/<label\b[^>]*>.*?<\/label>/s, "");
584
+ const text = htmlToInline(body.replace(/<[^>]+>/g, "").trim());
585
+ lines.push(`${indent}- [${checked ? "x" : " "}] ${text}`.trimEnd());
586
+ } else {
587
+ lines.push(...renderListItem(marker, content, indent));
588
+ }
589
+ const childIndent = indent + " ".repeat(task ? 2 : marker.length);
590
+ for (const child of nested) {
591
+ lines.push(...renderList(child.inner, child.ordered, child.task, childIndent, child.start));
592
+ }
593
+ });
594
+ return lines;
595
+ }
596
+ function renderListItem(prefix, html, outerIndent = "") {
597
+ const indent = outerIndent + " ".repeat(prefix.length);
598
+ const media = [];
599
+ const htmlWithoutMedia = html.replace(
600
+ /<(video|audio)\b([^>]*)>(?:[\s\S]*?<\/\1>)?/gi,
601
+ (_full, tag, attrs) => {
602
+ media.push(serializeMediaTag(tag.toLowerCase() === "video" ? "video" : "audio", attrs ?? ""));
603
+ return "";
604
+ }
605
+ );
606
+ const paragraphs = htmlWithoutMedia.split(/<\/p>\s*<p[^>]*>/i).map((p) => p.replace(/^<p[^>]*>/i, "").replace(/<\/p>\s*$/i, ""));
607
+ const textLines = [];
608
+ paragraphs.forEach((paragraph, pIdx) => {
609
+ const inline = htmlToInline(paragraph).trim();
610
+ if (!inline) return;
611
+ const subLines = inline.split("\n");
612
+ subLines.forEach((sub, sIdx) => {
613
+ if (pIdx === 0 && sIdx === 0) {
614
+ textLines.push(outerIndent + prefix + sub);
615
+ } else {
616
+ if (sIdx === 0) textLines.push("");
617
+ textLines.push(indent + sub);
618
+ }
619
+ });
620
+ });
621
+ if (textLines.length === 0 && media.length === 0) return [outerIndent + prefix];
622
+ const result = [];
623
+ if (textLines.length > 0) {
624
+ result.push(...textLines);
625
+ for (const tag of media) {
626
+ result.push("");
627
+ result.push(indent + tag);
628
+ }
629
+ } else {
630
+ result.push(outerIndent + prefix + media[0]);
631
+ for (const tag of media.slice(1)) {
632
+ result.push("");
633
+ result.push(indent + tag);
634
+ }
635
+ }
636
+ return result;
637
+ }
638
+ function findFrontmatterEnd(lines) {
639
+ if (lines[0]?.trim() !== "---") return -1;
640
+ for (let i = 1; i < lines.length; i++) {
641
+ if (lines[i].trim() === "---") return i;
642
+ }
643
+ return -1;
644
+ }
645
+ function matchSetextUnderline(line) {
646
+ const match = /^ {0,3}(=+|-+)[ \t]*$/.exec(line);
647
+ if (!match) return null;
648
+ return match[1][0] === "=" ? 1 : 2;
649
+ }
650
+ function isIndentedCodeLine(line) {
651
+ return /^(?: {4}|\t)/.test(line) && line.trim() !== "";
652
+ }
653
+ function stripCodeIndent(line) {
654
+ return line.startsWith(" ") ? line.slice(1) : line.slice(4);
655
+ }
656
+ function headingToHtml(level, rawText) {
657
+ let text = rawText;
658
+ let attrs = "";
659
+ let templateInner = null;
660
+ let pandocInner = null;
661
+ for (let pass = 0; pass < 4; pass++) {
662
+ let matched = false;
663
+ if (templateInner == null) {
664
+ const m = matchTrailingTemplateAnnotation(text);
665
+ if (m) {
666
+ templateInner = m.inner.trim();
667
+ text = text.slice(0, m.index).trimEnd();
668
+ matched = true;
669
+ }
670
+ }
671
+ if (pandocInner == null) {
672
+ const m = matchTrailingPandocAttr(text);
673
+ if (m) {
674
+ pandocInner = m.inner.trim();
675
+ text = text.slice(0, m.index).trimEnd();
676
+ matched = true;
677
+ }
678
+ }
679
+ if (!matched) break;
680
+ }
681
+ if (templateInner != null) {
682
+ const tokens = tokenizeAttrTokens(templateInner);
683
+ if (tokens.length === 0) {
684
+ attrs += ' data-template-empty="true"';
685
+ }
686
+ const firstIsParam = tokens.length > 0 && tokens[0].indexOf("=") > 0;
687
+ if (!firstIsParam && tokens[0]) {
688
+ attrs += ` data-template="${escapeHtml(tokens[0])}"`;
689
+ }
690
+ const params = tokens.slice(firstIsParam ? 0 : 1).filter((t) => t.includes("="));
691
+ if (params.length > 0) {
692
+ attrs += ` data-template-params="${escapeHtml(params.join(" "))}"`;
693
+ }
694
+ }
695
+ if (pandocInner != null) {
696
+ attrs += ` data-block-attrs="${escapeHtml(pandocInner)}"`;
697
+ }
698
+ return `<h${level}${attrs}>${inlineToHtml(text)}</h${level}>`;
699
+ }
700
+ function indentWidth(raw) {
701
+ let width = 0;
702
+ for (const ch of raw) width += ch === " " ? 4 : 1;
703
+ return width;
704
+ }
705
+ function parseTableCells(line) {
706
+ let inner = line.trim();
707
+ if (inner.startsWith("|")) inner = inner.slice(1);
708
+ if (inner.endsWith("|")) inner = inner.slice(0, -1);
709
+ return inner.split("|").map((cell) => cell.trim());
710
+ }
711
+ function parseAlignments(separatorLine) {
712
+ return parseTableCells(separatorLine).map((cell) => {
713
+ const s = cell.replace(/\s/g, "");
714
+ if (s.startsWith(":") && s.endsWith(":")) return "center";
715
+ if (s.endsWith(":")) return "right";
716
+ if (s.startsWith(":")) return "left";
717
+ return null;
718
+ });
719
+ }
720
+ function serializeMediaTag(tag, attrs) {
721
+ const src = /\bsrc="([^"]*)"/i.exec(attrs)?.[1] ?? "";
722
+ const controls = /\bcontrols\b/i.test(attrs);
723
+ const width = /\bwidth="([^"]*)"/i.exec(attrs)?.[1];
724
+ const height = /\bheight="([^"]*)"/i.exec(attrs)?.[1];
725
+ const poster = tag === "video" ? /\bposter="([^"]*)"/i.exec(attrs)?.[1] : void 0;
726
+ const parts = [`<${tag} src="${src}"`];
727
+ if (controls) parts.push(" controls");
728
+ if (width) parts.push(` width="${width}"`);
729
+ if (height) parts.push(` height="${height}"`);
730
+ if (poster) parts.push(` poster="${poster}"`);
731
+ parts.push(`></${tag}>`);
732
+ return parts.join("");
733
+ }
734
+ function serializeImage(src, alt, attrs) {
735
+ const width = /\bwidth="([^"]*)"/i.exec(attrs)?.[1];
736
+ const height = /\bheight="([^"]*)"/i.exec(attrs)?.[1];
737
+ const title = /\btitle="([^"]*)"/i.exec(attrs)?.[1];
738
+ if (!width && !height) {
739
+ return `![${alt}](${src})`;
740
+ }
741
+ const parts = [`<img alt="${alt}" src="${src}"`];
742
+ if (width) parts.push(` width="${width}"`);
743
+ if (height) parts.push(` height="${height}"`);
744
+ if (title) parts.push(` title="${title}"`);
745
+ parts.push(">");
746
+ return parts.join("");
747
+ }
748
+ function escapeHtml(text) {
749
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
750
+ }
751
+ function unescapeHtml(text) {
752
+ return text.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&nbsp;|&#160;|&#xA0;/gi, "\xA0").replace(/&amp;/g, "&");
753
+ }
754
+ function inlineToHtml(text) {
755
+ const placeholders = [];
756
+ const stash = (html) => {
757
+ const token = `\0PH${placeholders.length}\0`;
758
+ placeholders.push(html);
759
+ return token;
760
+ };
761
+ let staged = text.replace(
762
+ RE_INLINE_CODE,
763
+ (_m, code) => stash(`<code>${escapeHtml(code)}</code>`)
764
+ );
765
+ staged = staged.replace(
766
+ RE_IMAGE,
767
+ (_m, alt, src) => stash(`<img alt="${escapeHtml(alt)}" src="${escapeHtml(src)}">`)
768
+ );
769
+ staged = staged.replace(
770
+ RE_MENTION,
771
+ (_m, label, kind, id) => stash(
772
+ `<span data-mention="true" data-kind="${escapeHtml(kind)}" data-id="${escapeHtml(id)}" data-label="${escapeHtml(label)}" class="mention">@${escapeHtml(label)}</span>`
773
+ )
774
+ );
775
+ staged = staged.replace(RE_ICON_MD, (full, token) => {
776
+ const icon = resolveIcon(token);
777
+ if (!icon) return full;
778
+ return stash(
779
+ `<i class="fa-${icon.family} fa-${icon.name}" data-icon="${escapeHtml(token)}" data-family="${icon.family}" data-name="${icon.name}" contenteditable="false"></i>`
780
+ );
781
+ });
782
+ staged = replaceMarkdownLinks(staged, (linkText, destination) => {
783
+ const { url, title } = splitLinkDestination(destination);
784
+ const titleAttr = title === null ? "" : ` title="${escapeHtml(title)}"`;
785
+ return stash(`<a href="${escapeHtml(url)}"${titleAttr}>${inlineToHtml(linkText)}</a>`);
786
+ });
787
+ let result = escapeHtml(staged);
788
+ result = result.replace(
789
+ RE_MD_ESCAPE,
790
+ (_m, ch) => `\0ESC${ESCAPABLE_MD_CHARS.indexOf(ch)}\0`
791
+ );
792
+ result = result.replace(RE_BOLD_STAR, "<strong>$1</strong>");
793
+ result = result.replace(RE_BOLD_UNDER, "<strong>$1</strong>");
794
+ result = result.replace(RE_ITALIC_STAR, "<em>$1</em>");
795
+ result = result.replace(RE_ITALIC_UNDER, "<em>$1</em>");
796
+ result = result.replace(RE_STRIKETHROUGH, "<s>$1</s>");
797
+ for (let index = 0; index < ESCAPABLE_MD_CHARS.length; index++) {
798
+ result = result.split(`\0ESC${index}\0`).join(ESCAPABLE_MD_CHARS[index]);
799
+ }
800
+ for (let index = placeholders.length - 1; index >= 0; index--) {
801
+ result = result.split(`\0PH${index}\0`).join(placeholders[index] ?? "");
802
+ }
803
+ return preserveLeadingSpaces(result);
804
+ }
805
+ function replaceMarkdownLinks(text, replace) {
806
+ let output = "";
807
+ let consumedThrough = 0;
808
+ let searchFrom = 0;
809
+ while (searchFrom < text.length) {
810
+ const labelOpen = text.indexOf("[", searchFrom);
811
+ if (labelOpen < 0) break;
812
+ if (isEscapedMarkdownCharacter(text, labelOpen)) {
813
+ searchFrom = labelOpen + 1;
814
+ continue;
815
+ }
816
+ const labelClose = findMatchingMarkdownDelimiter(text, labelOpen, "[", "]");
817
+ const destinationOpen = labelClose + 1;
818
+ if (labelClose < 0 || text[destinationOpen] !== "(") {
819
+ searchFrom = labelOpen + 1;
820
+ continue;
821
+ }
822
+ const destinationClose = findMatchingMarkdownDelimiter(text, destinationOpen, "(", ")");
823
+ if (destinationClose < 0) {
824
+ searchFrom = labelOpen + 1;
825
+ continue;
826
+ }
827
+ const label = text.slice(labelOpen + 1, labelClose);
828
+ const href = text.slice(destinationOpen + 1, destinationClose);
829
+ if (!label || !href) {
830
+ searchFrom = labelOpen + 1;
831
+ continue;
832
+ }
833
+ output += text.slice(consumedThrough, labelOpen) + replace(label, href);
834
+ consumedThrough = destinationClose + 1;
835
+ searchFrom = consumedThrough;
836
+ }
837
+ return output + text.slice(consumedThrough);
838
+ }
839
+ function splitLinkDestination(destination) {
840
+ const OPENER_FOR = { '"': '"', "'": "'", ")": "(" };
841
+ const trimmed = destination.trimEnd();
842
+ const opener = OPENER_FOR[trimmed[trimmed.length - 1] ?? ""];
843
+ if (!opener) return { url: destination.trim(), title: null };
844
+ for (let index = trimmed.length - 2; index > 0; index--) {
845
+ if (trimmed[index] !== opener) continue;
846
+ if (isEscapedMarkdownCharacter(trimmed, index)) continue;
847
+ if (!/\s/.test(trimmed[index - 1])) continue;
848
+ const url = trimmed.slice(0, index).trim();
849
+ if (!url) continue;
850
+ return {
851
+ url,
852
+ // Backslash escapes inside a title are real escapes (`\"` is a literal
853
+ // quote), matching core's parser.
854
+ title: trimmed.slice(index + 1, -1).replace(/\\([\\"'()])/g, "$1")
855
+ };
856
+ }
857
+ return { url: destination.trim(), title: null };
858
+ }
859
+ function escapeLinkTitleAttr(attrValue) {
860
+ return attrValue.replace(/\\/g, "\\\\").replace(/&quot;/g, "\\&quot;");
861
+ }
862
+ function findMatchingMarkdownDelimiter(text, start, open, close) {
863
+ let depth = 0;
864
+ for (let index = start; index < text.length; index++) {
865
+ if (isEscapedMarkdownCharacter(text, index)) continue;
866
+ if (text[index] === open) depth++;
867
+ if (text[index] !== close) continue;
868
+ depth--;
869
+ if (depth === 0) return index;
870
+ }
871
+ return -1;
872
+ }
873
+ function isEscapedMarkdownCharacter(text, index) {
874
+ let backslashes = 0;
875
+ for (let cursor = index - 1; cursor >= 0 && text[cursor] === "\\"; cursor--) {
876
+ backslashes++;
877
+ }
878
+ return backslashes % 2 === 1;
879
+ }
880
+ function isMarkdownWordChar(ch) {
881
+ return ch !== void 0 && /[\p{L}\p{N}_]/u.test(ch);
882
+ }
883
+ function isMarkdownSpace(ch) {
884
+ return ch === void 0 || /\s/.test(ch);
885
+ }
886
+ var RE_BARE_URL = /(?:https?:\/\/|ftp:\/\/|www\.)(?:\([^\s<>()]*\)|[^\s<>[\]()])+/gi;
887
+ function escapeMarkdownText(text) {
888
+ let out = "";
889
+ let cursor = 0;
890
+ RE_BARE_URL.lastIndex = 0;
891
+ let url;
892
+ while ((url = RE_BARE_URL.exec(text)) !== null) {
893
+ out += escapeMarkdownRun(text.slice(cursor, url.index));
894
+ out += url[0];
895
+ cursor = url.index + url[0].length;
896
+ }
897
+ return out + escapeMarkdownRun(text.slice(cursor));
898
+ }
899
+ function escapeMarkdownRun(text) {
900
+ let out = "";
901
+ for (let i = 0; i < text.length; i++) {
902
+ const ch = text[i];
903
+ const prev = text[i - 1];
904
+ const next = text[i + 1];
905
+ if (ch === "\\") {
906
+ out += ESCAPABLE_MD_CHARS.includes(next ?? "") ? "\\\\" : "\\";
907
+ continue;
908
+ }
909
+ if (ch === "~") {
910
+ out += prev === "~" || next === "~" ? "\\~" : "~";
911
+ continue;
912
+ }
913
+ if (ch === "*") {
914
+ out += !isMarkdownSpace(next) || !isMarkdownSpace(prev) ? "\\*" : "*";
915
+ continue;
916
+ }
917
+ if (ch === "_") {
918
+ const canOpen = !isMarkdownWordChar(prev) && !isMarkdownSpace(next);
919
+ const canClose = !isMarkdownWordChar(next) && !isMarkdownSpace(prev);
920
+ out += canOpen || canClose ? "\\_" : "_";
921
+ continue;
922
+ }
923
+ out += ch;
924
+ }
925
+ return out;
926
+ }
927
+ function escapeMarkdownTextNodes(html) {
928
+ let out = "";
929
+ let cursor = 0;
930
+ const re = /<code\b[^>]*>[\s\S]*?<\/code>|<[^>]+>/gi;
931
+ let match;
932
+ while ((match = re.exec(html)) !== null) {
933
+ out += escapeMarkdownText(html.slice(cursor, match.index));
934
+ out += match[0];
935
+ cursor = match.index + match[0].length;
936
+ }
937
+ return out + escapeMarkdownText(html.slice(cursor));
938
+ }
939
+ function htmlToInline(html) {
940
+ let result = html;
941
+ result = result.replace(/<br\s*\/?>/gi, " \n");
942
+ result = escapeMarkdownTextNodes(result);
943
+ result = result.replace(RE_ICON_TAG, (_m, token) => `{[${token}]}`);
944
+ result = result.replace(RE_STRONG_TAG, "**$1**");
945
+ result = result.replace(RE_B_TAG, "**$1**");
946
+ result = result.replace(RE_EM_TAG, "*$1*");
947
+ result = result.replace(RE_I_TAG, "*$1*");
948
+ result = result.replace(RE_S_TAG, "~~$1~~");
949
+ result = result.replace(RE_DEL_TAG, "~~$1~~");
950
+ result = result.replace(RE_CODE_TAG, "`$1`");
951
+ result = result.replace(RE_MENTION_TAG, (match, _inner) => {
952
+ const kind = /data-kind="([^"]*)"/i.exec(match)?.[1] ?? "";
953
+ const id = /data-id="([^"]*)"/i.exec(match)?.[1] ?? "";
954
+ const label = /data-label="([^"]*)"/i.exec(match)?.[1] ?? "";
955
+ if (!kind || !id || !label) return match;
956
+ return `@[${label}](${kind}:${id})`;
957
+ });
958
+ result = result.replace(RE_A_TAG, (match, attrs, text) => {
959
+ const href = /\bhref="([^"]*)"/i.exec(attrs)?.[1];
960
+ if (href === void 0) return match;
961
+ const title = /\btitle="([^"]*)"/i.exec(attrs)?.[1];
962
+ const titlePart = title ? ` "${escapeLinkTitleAttr(title)}"` : "";
963
+ return `[${text}](${href}${titlePart})`;
964
+ });
965
+ result = result.replace(RE_IMG_TAG, (match, attrs) => {
966
+ const src = /\bsrc="([^"]*)"/i.exec(attrs)?.[1];
967
+ if (!src) return match;
968
+ const alt = /\balt="([^"]*)"/i.exec(attrs)?.[1] ?? "";
969
+ return serializeImage(src, alt, attrs);
970
+ });
971
+ result = result.replace(RE_STRIP_TAGS, "");
972
+ return restoreLeadingSpaces(unescapeHtml(result));
973
+ }
974
+ function preserveLeadingSpaces(html) {
975
+ return html.replace(/^ +/, (spaces) => "&nbsp;".repeat(spaces.length));
976
+ }
977
+ function restoreLeadingSpaces(text) {
978
+ return text.replace(/(^|\n)(\u00a0+)/g, (_match, prefix, spaces) => {
979
+ return prefix + " ".repeat(spaces.length);
980
+ });
981
+ }
982
+
983
+ export {
984
+ markdownToTiptap,
985
+ tiptapToMarkdown
986
+ };