@bendyline/squisq-editor-react 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NOTICE.md +40 -0
- package/dist/index.d.ts +188 -55
- package/dist/index.js +5094 -2948
- package/dist/monaco.js +0 -1
- package/dist/styles/index.css +234 -145
- package/package.json +9 -6
- package/dist/index.js.map +0 -1
- package/dist/monaco.js.map +0 -1
- package/src/BlockCardView.tsx +0 -121
- package/src/BlockPreviewPanel.tsx +0 -69
- package/src/BlockPropertiesPopover.tsx +0 -222
- package/src/DocumentSettingsDialog.tsx +0 -272
- package/src/DropZoneOverlay.tsx +0 -137
- package/src/EditorContext.tsx +0 -1274
- package/src/EditorShell.tsx +0 -1358
- package/src/EmojiPicker.tsx +0 -332
- package/src/FolderView.tsx +0 -131
- package/src/Icon.tsx +0 -26
- package/src/ImageEditor.tsx +0 -395
- package/src/ImageNodeView.tsx +0 -284
- package/src/ImageViewer.tsx +0 -221
- package/src/InlineIcon.ts +0 -84
- package/src/InlinePreviewGutter.tsx +0 -590
- package/src/LinkDialog.tsx +0 -276
- package/src/MediaBin.tsx +0 -500
- package/src/MentionExtension.tsx +0 -261
- package/src/OutlinePanel.tsx +0 -547
- package/src/PlainHtmlPreview.tsx +0 -277
- package/src/PreviewControls.tsx +0 -1265
- package/src/PreviewPanel.tsx +0 -426
- package/src/RawEditor.tsx +0 -743
- package/src/RecorderEntry.tsx +0 -162
- package/src/StatusBar.tsx +0 -51
- package/src/TemplateAnnotation.ts +0 -167
- package/src/TemplateContentPreview.tsx +0 -56
- package/src/TemplatePicker.tsx +0 -1314
- package/src/ThemeCustomizerPanel.tsx +0 -304
- package/src/ThemePicker.tsx +0 -433
- package/src/TimelineBlockPreview.tsx +0 -37
- package/src/TimelineTrack.tsx +0 -671
- package/src/Toolbar.tsx +0 -2885
- package/src/Tooltip.tsx +0 -142
- package/src/TransitionPicker.tsx +0 -390
- package/src/VersionHistoryPanel.tsx +0 -359
- package/src/ViewMenuPanel.tsx +0 -189
- package/src/ViewSwitcher.tsx +0 -56
- package/src/WysiwygEditor.tsx +0 -806
- package/src/__tests__/blockProperties.test.ts +0 -92
- package/src/__tests__/blockPropertiesPopoverTheme.test.tsx +0 -33
- package/src/__tests__/blockRange.test.ts +0 -105
- package/src/__tests__/blockTagActivity.test.ts +0 -183
- package/src/__tests__/buildDocumentPreviewMarkdown.test.ts +0 -75
- package/src/__tests__/buildPreviewDocContent.test.ts +0 -65
- package/src/__tests__/buildPreviewDocTransition.test.ts +0 -92
- package/src/__tests__/canvasSurfaceTextEditing.test.tsx +0 -60
- package/src/__tests__/codeContextSectionView.test.tsx +0 -97
- package/src/__tests__/codeContextZoneManager.test.ts +0 -127
- package/src/__tests__/createShapeLayer.test.ts +0 -46
- package/src/__tests__/customLayoutManagerTheme.test.tsx +0 -34
- package/src/__tests__/detectMarkdown.test.ts +0 -73
- package/src/__tests__/diffContextSections.test.ts +0 -39
- package/src/__tests__/documentSettingsDialog.test.tsx +0 -197
- package/src/__tests__/drawingShapeRoundTrip.test.ts +0 -49
- package/src/__tests__/editorScrollHandoff.test.tsx +0 -102
- package/src/__tests__/editorScrollSync.test.ts +0 -65
- package/src/__tests__/editorShellCodeContext.test.tsx +0 -86
- package/src/__tests__/editorShellProps.test.tsx +0 -550
- package/src/__tests__/embeddedMedia.test.ts +0 -48
- package/src/__tests__/emojiPicker.test.tsx +0 -93
- package/src/__tests__/fileKind.test.ts +0 -112
- package/src/__tests__/findMode.test.tsx +0 -104
- package/src/__tests__/findModel.test.ts +0 -55
- package/src/__tests__/headingTransition.test.ts +0 -176
- package/src/__tests__/imageEditAffordance.test.tsx +0 -272
- package/src/__tests__/imageEditModalContract.test.tsx +0 -119
- package/src/__tests__/imageEditorShell.test.tsx +0 -94
- package/src/__tests__/imageEditorState.test.ts +0 -171
- package/src/__tests__/inlinePreviewGutter.test.tsx +0 -62
- package/src/__tests__/inlinePreviewGutterAllBlocks.test.tsx +0 -103
- package/src/__tests__/jsonEditor.test.tsx +0 -223
- package/src/__tests__/layersPanel.test.tsx +0 -167
- package/src/__tests__/layoutChildRoundTrip.test.ts +0 -71
- package/src/__tests__/linkDialogDocPicker.test.tsx +0 -137
- package/src/__tests__/majorApiTypes.test.ts +0 -26
- package/src/__tests__/markdownCodeFence.test.ts +0 -45
- package/src/__tests__/mediaAttachmentFlow.test.ts +0 -110
- package/src/__tests__/mediaBinDrop.test.tsx +0 -90
- package/src/__tests__/mediaReferences.test.ts +0 -97
- package/src/__tests__/narrationSave.test.ts +0 -148
- package/src/__tests__/outlinePanel.test.tsx +0 -169
- package/src/__tests__/outlineSource.test.ts +0 -217
- package/src/__tests__/plainHtmlPreview.test.tsx +0 -125
- package/src/__tests__/presentationMode.test.tsx +0 -290
- package/src/__tests__/previewControls.test.tsx +0 -571
- package/src/__tests__/previewPanelAudioFailure.test.tsx +0 -46
- package/src/__tests__/previewPanelPresentation.test.tsx +0 -126
- package/src/__tests__/previewPanelTransforms.test.tsx +0 -117
- package/src/__tests__/propertiesPanel.test.tsx +0 -69
- package/src/__tests__/rawEditorModelIsolation.test.ts +0 -19
- package/src/__tests__/recorderFormats.test.ts +0 -146
- package/src/__tests__/recorderMediaInsert.test.ts +0 -86
- package/src/__tests__/recorderTheme.test.tsx +0 -42
- package/src/__tests__/recorderTimingJson.test.ts +0 -41
- package/src/__tests__/resolveBlockVisual.test.ts +0 -43
- package/src/__tests__/selectionConversions.test.ts +0 -80
- package/src/__tests__/statusBar.test.tsx +0 -27
- package/src/__tests__/teleprompter.test.tsx +0 -190
- package/src/__tests__/templateAnnotationRoundTrip.test.ts +0 -99
- package/src/__tests__/templateContentPreview.test.ts +0 -101
- package/src/__tests__/templatePickerMetadata.test.ts +0 -32
- package/src/__tests__/templatePickerPortal.test.tsx +0 -62
- package/src/__tests__/timelineSource.test.ts +0 -134
- package/src/__tests__/tiptapBridge.test.ts +0 -575
- package/src/__tests__/tiptapBridgeConformance.test.ts +0 -47
- package/src/__tests__/tiptapCodeBlockRoundTrip.test.ts +0 -109
- package/src/__tests__/tiptapImageRoundTrip.test.ts +0 -73
- package/src/__tests__/toolbarSelectionConversion.test.tsx +0 -190
- package/src/__tests__/tooltip.test.tsx +0 -72
- package/src/__tests__/transformStyleId.test.ts +0 -13
- package/src/__tests__/transitionCatalog.test.ts +0 -64
- package/src/__tests__/useBlockNavigator.test.tsx +0 -67
- package/src/__tests__/useImageEditor.test.tsx +0 -226
- package/src/__tests__/useJsonEditorTokens.test.ts +0 -59
- package/src/__tests__/useMediaRecorder.test.ts +0 -302
- package/src/__tests__/useTimelineClock.test.ts +0 -21
- package/src/__tests__/versionHistory.test.tsx +0 -197
- package/src/__tests__/viewMenuPanel.test.tsx +0 -130
- package/src/__tests__/writeCanvasSettings.test.ts +0 -15
- package/src/__tests__/wysiwygImageUpload.test.ts +0 -69
- package/src/__tests__/wysiwygTemplateBadgeFocus.test.tsx +0 -56
- package/src/asciiDiagram/AsciiDiagramExtension.ts +0 -343
- package/src/asciiDiagram/AsciiDiagramWidget.tsx +0 -254
- package/src/asciiDiagram/RepairableDiagramExtension.ts +0 -200
- package/src/asciiDiagram/__tests__/AsciiDiagramExtension.test.ts +0 -164
- package/src/asciiDiagram/__tests__/RepairableDiagramExtension.test.ts +0 -159
- package/src/asciiDiagram/__tests__/asciiDiagramCommands.test.ts +0 -284
- package/src/asciiDiagram/__tests__/asciiDiagramOps.test.ts +0 -114
- package/src/asciiDiagram/__tests__/asciiPaste.test.ts +0 -43
- package/src/asciiDiagram/asciiDiagramCommands.ts +0 -174
- package/src/asciiDiagram/asciiDiagramData.ts +0 -149
- package/src/asciiDiagram/asciiDiagramOps.ts +0 -238
- package/src/asciiDiagram/asciiPaste.ts +0 -19
- package/src/blockProperties.ts +0 -88
- package/src/blockRange.ts +0 -132
- package/src/blockSlice.ts +0 -75
- package/src/blockTagActivity.ts +0 -233
- package/src/buildDocumentPreviewMarkdown.ts +0 -168
- package/src/buildPreviewDoc.ts +0 -407
- package/src/codeContext/CodeContextSectionView.tsx +0 -124
- package/src/codeContext/CodeContextZoneManager.ts +0 -149
- package/src/codeContext/CodeContextZones.tsx +0 -121
- package/src/codeContext/diffContextSections.ts +0 -38
- package/src/codeContext/types.ts +0 -75
- package/src/codeSnippet/CodeSnippetExtension.ts +0 -205
- package/src/codeSnippet/CodeSnippetWidget.tsx +0 -109
- package/src/codeSnippet/__tests__/CodeSnippetExtension.test.ts +0 -95
- package/src/codeSnippet/__tests__/codeSnippetLanguages.test.ts +0 -50
- package/src/codeSnippet/codeSnippetCommands.ts +0 -21
- package/src/codeSnippet/codeSnippetData.ts +0 -43
- package/src/codeSnippet/codeSnippetLanguages.ts +0 -216
- package/src/customTemplates/AddBin.tsx +0 -126
- package/src/customTemplates/CustomLayoutManager.tsx +0 -234
- package/src/customTemplates/CustomTemplateContext.tsx +0 -188
- package/src/customTemplates/LayerToolbar.tsx +0 -580
- package/src/customTemplates/ShapeGlyph.tsx +0 -47
- package/src/customTemplates/TemplateDesigner.tsx +0 -433
- package/src/customTemplates/__tests__/library.test.ts +0 -96
- package/src/customTemplates/__tests__/normalizePositions.test.ts +0 -109
- package/src/customTemplates/__tests__/shapeDefs.test.ts +0 -49
- package/src/customTemplates/__tests__/useMemoryLayerAdapter.test.ts +0 -108
- package/src/customTemplates/designer.css +0 -732
- package/src/customTemplates/index.ts +0 -31
- package/src/customTemplates/library.ts +0 -110
- package/src/customTemplates/normalizePositions.ts +0 -75
- package/src/customTemplates/shapeDefs.ts +0 -131
- package/src/customTemplates/thumbnail.tsx +0 -63
- package/src/customTemplates/tokenDefs.ts +0 -60
- package/src/customTemplates/useDocCustomTemplates.ts +0 -52
- package/src/customTemplates/useMemoryLayerAdapter.ts +0 -129
- package/src/customThemes/CustomThemeContext.tsx +0 -185
- package/src/customThemes/CustomThemeDialog.tsx +0 -316
- package/src/customThemes/ImportThemeSection.tsx +0 -178
- package/src/customThemes/__tests__/CustomThemeContext.test.tsx +0 -64
- package/src/customThemes/__tests__/CustomThemeDialog.test.tsx +0 -47
- package/src/customThemes/__tests__/customThemeLibrary.test.ts +0 -60
- package/src/customThemes/__tests__/importThemeSection.test.tsx +0 -192
- package/src/customThemes/customThemeLibrary.ts +0 -100
- package/src/customThemes/index.ts +0 -37
- package/src/customThemes/themeControls.tsx +0 -229
- package/src/customThemes/themeDraft.ts +0 -288
- package/src/customThemes/useDocCustomThemes.ts +0 -49
- package/src/detectMarkdown.ts +0 -62
- package/src/diagram/DiagramCanvas.tsx +0 -260
- package/src/diagram/DiagramMaximizedOverlay.tsx +0 -46
- package/src/diagram/diagramCommands.ts +0 -604
- package/src/diagram/diagramConstants.ts +0 -17
- package/src/diagram/types.ts +0 -35
- package/src/editorScrollSync.ts +0 -73
- package/src/embeddedMedia.ts +0 -78
- package/src/emojiData.ts +0 -1317
- package/src/fileKind.ts +0 -158
- package/src/find/FindHighlightExtension.ts +0 -81
- package/src/find/FindToolbar.tsx +0 -314
- package/src/find/findModel.ts +0 -77
- package/src/frontmatter.ts +0 -29
- package/src/frontmatterSettings.ts +0 -23
- package/src/headingTransition.ts +0 -291
- package/src/hooks/useFileDrop.ts +0 -266
- package/src/imageEditor/CanvasSurface.tsx +0 -703
- package/src/imageEditor/ImageVersionHistoryDropdown.tsx +0 -396
- package/src/imageEditor/LayersPanel.tsx +0 -218
- package/src/imageEditor/PropertiesPanel.tsx +0 -474
- package/src/imageEditor/Toolbar.tsx +0 -459
- package/src/imageEditor/createShapeLayer.ts +0 -280
- package/src/imageEditor/icons.tsx +0 -68
- package/src/imageEditor/image-editor.css +0 -574
- package/src/imageEditor/layers/EditorImageLayer.tsx +0 -45
- package/src/imageEditor/layers/EditorShapeLayer.tsx +0 -62
- package/src/imageEditor/layers/EditorTextLayer.tsx +0 -45
- package/src/imageEditor/layers/SelectionHandles.tsx +0 -86
- package/src/imageEditor/state.ts +0 -173
- package/src/imageEditor/useImageEditor.ts +0 -385
- package/src/imageEditor/useImageEditorTokens.ts +0 -70
- package/src/index.ts +0 -559
- package/src/jsonEditor/EmbeddedRichTextField.tsx +0 -81
- package/src/jsonEditor/JsonEditor.tsx +0 -81
- package/src/jsonEditor/JsonEditorContext.tsx +0 -81
- package/src/jsonEditor/RenderNode.tsx +0 -87
- package/src/jsonEditor/editors.tsx +0 -745
- package/src/jsonEditor/index.ts +0 -2
- package/src/jsonEditor/json-editor.css +0 -463
- package/src/jsonEditor/useJsonEditorTokens.ts +0 -33
- package/src/markdownCodeFence.ts +0 -72
- package/src/mediaDragMime.ts +0 -32
- package/src/mediaEntries.ts +0 -12
- package/src/mediaReferences.ts +0 -301
- package/src/mermaid/MermaidDiagramCanvas.tsx +0 -693
- package/src/mermaid/MermaidDiagramExtension.ts +0 -243
- package/src/mermaid/MermaidDiagramTypeThumbnail.tsx +0 -184
- package/src/mermaid/MermaidDiagramWidget.tsx +0 -653
- package/src/mermaid/MermaidShapePalette.tsx +0 -245
- package/src/mermaid/__tests__/MermaidDiagramExtension.test.ts +0 -361
- package/src/mermaid/__tests__/mermaidDiagramTypes.test.ts +0 -35
- package/src/mermaid/__tests__/mermaidRenderer.test.ts +0 -49
- package/src/mermaid/__tests__/mermaidSourceOps.test.ts +0 -213
- package/src/mermaid/__tests__/mermaidSyntax.test.ts +0 -71
- package/src/mermaid/mermaidCommands.ts +0 -34
- package/src/mermaid/mermaidData.ts +0 -31
- package/src/mermaid/mermaidDiagramTypes.ts +0 -325
- package/src/mermaid/mermaidModel.ts +0 -31
- package/src/mermaid/mermaidRenderer.ts +0 -181
- package/src/mermaid/mermaidShapes.ts +0 -113
- package/src/mermaid/mermaidSourceOps.ts +0 -454
- package/src/monaco.ts +0 -35
- package/src/monacoWorkers.ts +0 -89
- package/src/outlineSource.ts +0 -171
- package/src/presentation/PresentationMode.tsx +0 -596
- package/src/rawEditorIsolation.ts +0 -18
- package/src/recorder/RecorderButton.tsx +0 -80
- package/src/recorder/RecorderModal.tsx +0 -706
- package/src/recorder/RecorderPanel.tsx +0 -77
- package/src/recorder/formats.ts +0 -159
- package/src/recorder/hooks/useMediaRecorder.ts +0 -436
- package/src/recorder/hooks/useStreamPreview.ts +0 -47
- package/src/recorder/insertMediaBlock.ts +0 -30
- package/src/recorder/sources/cameraStream.ts +0 -32
- package/src/recorder/sources/micStream.ts +0 -25
- package/src/recorder/sources/screenStream.ts +0 -162
- package/src/recorder/timingJson.ts +0 -66
- package/src/resolveBlockVisual.ts +0 -39
- package/src/scene/Scene.tsx +0 -647
- package/src/scene/SceneBlockExtension.ts +0 -205
- package/src/scene/SceneBlockToolbar.tsx +0 -216
- package/src/scene/SceneBlockWidget.tsx +0 -441
- package/src/scene/ScenePropsBar.tsx +0 -85
- package/src/scene/SceneSelection.tsx +0 -111
- package/src/scene/SceneSideToolbar.tsx +0 -89
- package/src/scene/SceneViewControls.tsx +0 -43
- package/src/scene/SceneViewport.tsx +0 -106
- package/src/scene/ShapePalette.tsx +0 -196
- package/src/scene/__tests__/DiagramAdapter.test.ts +0 -142
- package/src/scene/__tests__/SceneBlockExtension.test.ts +0 -33
- package/src/scene/__tests__/bezierEdit.test.ts +0 -85
- package/src/scene/__tests__/blockLayers.test.ts +0 -57
- package/src/scene/__tests__/fitScale.test.ts +0 -19
- package/src/scene/__tests__/sceneIsolation.test.tsx +0 -119
- package/src/scene/__tests__/shapeLayers.test.ts +0 -106
- package/src/scene/__tests__/useSceneHitTest.test.ts +0 -90
- package/src/scene/__tests__/useScenePanZoom.test.ts +0 -130
- package/src/scene/adapters/DiagramAdapter.ts +0 -79
- package/src/scene/adapters/DrawingAdapter.ts +0 -420
- package/src/scene/adapters/LayoutAdapter.ts +0 -313
- package/src/scene/adapters/blockLayers.ts +0 -159
- package/src/scene/commands/SceneCommand.ts +0 -84
- package/src/scene/commands/drawingCommands.ts +0 -318
- package/src/scene/commands/layoutCommands.ts +0 -301
- package/src/scene/fitScale.ts +0 -17
- package/src/scene/hooks/useSceneHitTest.ts +0 -105
- package/src/scene/hooks/useScenePanZoom.ts +0 -154
- package/src/scene/hooks/useSceneSelection.ts +0 -62
- package/src/scene/index.ts +0 -90
- package/src/scene/layers/DiagramEdges.tsx +0 -142
- package/src/scene/layers/edgeGeometry.ts +0 -104
- package/src/scene/layers/nodeCard.tsx +0 -164
- package/src/scene/layers/renderLayer.tsx +0 -70
- package/src/scene/layers/shapeLayers.ts +0 -201
- package/src/scene/paths/bezierEdit.ts +0 -208
- package/src/scene/scene.css +0 -874
- package/src/scene/text/SceneTextOverlay.tsx +0 -161
- package/src/scene/text/sceneTextChannel.ts +0 -46
- package/src/scene/text/sceneTextConfig.ts +0 -31
- package/src/scene/text/sceneTiptap.ts +0 -36
- package/src/scene/text/useSceneTextEditing.ts +0 -39
- package/src/scene/tools/ConnectTool.ts +0 -209
- package/src/scene/tools/DrawingConnectTool.ts +0 -231
- package/src/scene/tools/PathTool.ts +0 -158
- package/src/scene/tools/PlaceTool.ts +0 -47
- package/src/scene/tools/SceneTool.ts +0 -85
- package/src/scene/tools/SelectTool.ts +0 -300
- package/src/scene/tools/ShapeTool.ts +0 -143
- package/src/scene/tools/TextTool.ts +0 -72
- package/src/scene/tools/TokenTool.ts +0 -95
- package/src/scene/tools/createDrawShapeTool.ts +0 -82
- package/src/selectionConversions.ts +0 -155
- package/src/styles/ascii-diagram.css +0 -79
- package/src/styles/ascii-timeline.css +0 -596
- package/src/styles/code-context.css +0 -155
- package/src/styles/code-snippet.css +0 -76
- package/src/styles/diagram.css +0 -183
- package/src/styles/editor.css +0 -7131
- package/src/styles/folder-view.css +0 -210
- package/src/styles/image-edit-affordance.css +0 -201
- package/src/styles/index.css +0 -20
- package/src/styles/mermaid-diagram.css +0 -487
- package/src/styles/tree-view.css +0 -189
- package/src/teleprompter/TeleprompterControls.tsx +0 -218
- package/src/teleprompter/TeleprompterSelfView.tsx +0 -22
- package/src/teleprompter/TeleprompterSurface.tsx +0 -267
- package/src/teleprompter/TeleprompterView.tsx +0 -338
- package/src/teleprompter/canvasRenderer.ts +0 -161
- package/src/teleprompter/floatingWindow.ts +0 -352
- package/src/teleprompter/index.ts +0 -61
- package/src/teleprompter/pcmWorklet.ts +0 -62
- package/src/teleprompter/recording/insertPreamble.ts +0 -80
- package/src/teleprompter/recording/narrationSave.ts +0 -134
- package/src/teleprompter/recording/useNarrationRecorder.ts +0 -367
- package/src/teleprompter/scrollModel.ts +0 -85
- package/src/teleprompter/teleprompterTheme.ts +0 -303
- package/src/teleprompter/types.ts +0 -38
- package/src/teleprompter/useFloatingWindow.ts +0 -74
- package/src/teleprompter/useMicAnalysis.ts +0 -211
- package/src/teleprompter/useTeleprompter.ts +0 -421
- package/src/templateContentPreviewResolver.ts +0 -360
- package/src/timeline/TimelineEditorWidget.tsx +0 -861
- package/src/timeline/TimelineViewExtension.ts +0 -252
- package/src/timeline/__tests__/TimelineEditorWidget.test.tsx +0 -414
- package/src/timeline/__tests__/TimelineViewExtension.test.ts +0 -163
- package/src/timeline/__tests__/timelineCommands.test.ts +0 -359
- package/src/timeline/__tests__/timelineOps.test.ts +0 -277
- package/src/timeline/__tests__/timelinePaste.test.ts +0 -34
- package/src/timeline/timelineCommands.ts +0 -421
- package/src/timeline/timelineData.ts +0 -54
- package/src/timeline/timelineOps.ts +0 -381
- package/src/timeline/timelinePaste.ts +0 -8
- package/src/timelineSource.ts +0 -244
- package/src/tiptap/TiptapAudio.tsx +0 -86
- package/src/tiptap/TiptapVideo.tsx +0 -119
- package/src/tiptap/useResolvedMediaSrc.ts +0 -47
- package/src/tiptapBridge.ts +0 -986
- package/src/tooltipPlacement.ts +0 -13
- package/src/transformStyleId.ts +0 -17
- package/src/transitionCatalog.ts +0 -159
- package/src/treeview/TreeOutlineWidget.tsx +0 -390
- package/src/treeview/TreeViewExtension.ts +0 -250
- package/src/treeview/__tests__/TreeOutlineWidget.test.tsx +0 -156
- package/src/treeview/__tests__/TreeViewExtension.test.ts +0 -122
- package/src/treeview/__tests__/treeOps.test.ts +0 -177
- package/src/treeview/__tests__/treePaste.test.ts +0 -40
- package/src/treeview/__tests__/treeViewCommands.test.ts +0 -179
- package/src/treeview/treeOps.ts +0 -231
- package/src/treeview/treePaste.ts +0 -13
- package/src/treeview/treeViewCommands.ts +0 -99
- package/src/treeview/treeViewData.ts +0 -41
- package/src/types/monaco-shims.d.ts +0 -10
- package/src/useBlockNavigator.ts +0 -153
- package/src/useHeadingLayout.ts +0 -294
- package/src/useMonacoLoader.ts +0 -82
- package/src/useTimelineClock.ts +0 -76
- package/src/utils/collectInlineFontAwesomeCss.ts +0 -69
- package/src/utils/dropUtils.ts +0 -136
- package/src/utils/normalizeMalformedAssetUrl.ts +0 -22
- package/src/writeCanvasSettings.ts +0 -30
- package/src/wysiwygImageUpload.ts +0 -113
package/src/WysiwygEditor.tsx
DELETED
|
@@ -1,806 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WysiwygEditor
|
|
3
|
-
*
|
|
4
|
-
* Tiptap-based rich text editor that provides a WYSIWYG editing experience
|
|
5
|
-
* for markdown content. Uses squisq's parseMarkdown/stringifyMarkdown for
|
|
6
|
-
* conversion rather than Tiptap's built-in HTML serialization, ensuring
|
|
7
|
-
* perfect fidelity with the markdown format.
|
|
8
|
-
*
|
|
9
|
-
* Includes extensions for GFM features: tables, task lists, strikethrough,
|
|
10
|
-
* and code blocks.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
14
|
-
import type { CSSProperties } from 'react';
|
|
15
|
-
import { useEditor, EditorContent } from '@tiptap/react';
|
|
16
|
-
import { Selection } from '@tiptap/pm/state';
|
|
17
|
-
import type { EditorView as ProseMirrorView } from '@tiptap/pm/view';
|
|
18
|
-
import StarterKit from '@tiptap/starter-kit';
|
|
19
|
-
import Table from '@tiptap/extension-table';
|
|
20
|
-
import TableRow from '@tiptap/extension-table-row';
|
|
21
|
-
import TableCell from '@tiptap/extension-table-cell';
|
|
22
|
-
import TableHeader from '@tiptap/extension-table-header';
|
|
23
|
-
import TaskList from '@tiptap/extension-task-list';
|
|
24
|
-
import TaskItem from '@tiptap/extension-task-item';
|
|
25
|
-
import Link from '@tiptap/extension-link';
|
|
26
|
-
import Placeholder from '@tiptap/extension-placeholder';
|
|
27
|
-
import { resolveFontFamily, FONT_FALLBACKS, VIEWPORT_PRESETS } from '@bendyline/squisq/schemas';
|
|
28
|
-
import { DEFAULT_THEME, flattenBlocks, markdownToDoc } from '@bendyline/squisq/doc';
|
|
29
|
-
import { parseMarkdown } from '@bendyline/squisq/markdown';
|
|
30
|
-
import { HeadingWithTemplate } from './TemplateAnnotation';
|
|
31
|
-
import { AsciiDiagramExtension } from './asciiDiagram/AsciiDiagramExtension';
|
|
32
|
-
import { RepairableDiagramExtension } from './asciiDiagram/RepairableDiagramExtension';
|
|
33
|
-
import { applyRepairCommand } from './asciiDiagram/asciiDiagramCommands';
|
|
34
|
-
import { shouldPasteAsAsciiFence } from './asciiDiagram/asciiPaste';
|
|
35
|
-
import { MermaidDiagramExtension } from './mermaid/MermaidDiagramExtension';
|
|
36
|
-
import { CodeSnippetExtension } from './codeSnippet/CodeSnippetExtension';
|
|
37
|
-
import { TreeViewExtension } from './treeview/TreeViewExtension';
|
|
38
|
-
import { shouldPasteAsTreeFence } from './treeview/treePaste';
|
|
39
|
-
import { TimelineViewExtension } from './timeline/TimelineViewExtension';
|
|
40
|
-
import { shouldPasteAsTimelineFence } from './timeline/timelinePaste';
|
|
41
|
-
import { BlockTagActivityExtension } from './blockTagActivity';
|
|
42
|
-
import { SceneBlockExtension } from './scene/SceneBlockExtension';
|
|
43
|
-
import { InlineIcon } from './InlineIcon';
|
|
44
|
-
import { ImageWithMediaProvider } from './ImageNodeView';
|
|
45
|
-
import { TiptapVideo } from './tiptap/TiptapVideo';
|
|
46
|
-
import { TiptapAudio } from './tiptap/TiptapAudio';
|
|
47
|
-
import { TemplateBadgePopover, TEMPLATE_NAMES } from './TemplatePicker';
|
|
48
|
-
import { BlockPropertiesPopover } from './BlockPropertiesPopover';
|
|
49
|
-
import {
|
|
50
|
-
CustomTemplateProvider,
|
|
51
|
-
TemplateDesigner,
|
|
52
|
-
type DesignerSaveTarget,
|
|
53
|
-
} from './customTemplates';
|
|
54
|
-
import { saveLibraryTemplate } from './customTemplates/library';
|
|
55
|
-
import { useDocCustomTemplates } from './customTemplates/useDocCustomTemplates';
|
|
56
|
-
import type { CustomTemplateDefinition } from '@bendyline/squisq/schemas';
|
|
57
|
-
import { profileBlockContents, recommendTemplatesForBlock } from '@bendyline/squisq/recommend';
|
|
58
|
-
import { findBlockSliceByHeadingIndex } from './blockSlice';
|
|
59
|
-
import { stripFrontmatter } from './frontmatter';
|
|
60
|
-
import { useEditorContext } from './EditorContext';
|
|
61
|
-
import { buildMentionExtension } from './MentionExtension';
|
|
62
|
-
import { markdownToTiptap, tiptapToMarkdown } from './tiptapBridge';
|
|
63
|
-
import { looksLikeMarkdown } from './detectMarkdown';
|
|
64
|
-
import { SQUISQ_MEDIA_MIME, parseSquisqMediaPayload } from './mediaDragMime';
|
|
65
|
-
import { usePreviewSettingsOptional } from './PreviewControls';
|
|
66
|
-
import { uploadAndInsertImages } from './wysiwygImageUpload';
|
|
67
|
-
import { writeCanvasSettingsStyle, type WriteCanvasSettings } from './writeCanvasSettings';
|
|
68
|
-
import { FindHighlightExtension } from './find/FindHighlightExtension';
|
|
69
|
-
|
|
70
|
-
type ImageMutationView = Pick<ProseMirrorView, 'state' | 'dispatch'>;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Rotating placeholder prompts shown when the editor is empty. One is
|
|
74
|
-
* picked at random per editor mount. Hosts can override by passing the
|
|
75
|
-
* `placeholder` prop with a fixed string.
|
|
76
|
-
*/
|
|
77
|
-
const EMPTY_PROMPTS = [
|
|
78
|
-
'Start typing your content, or drop images on top of me...',
|
|
79
|
-
'Write anything -- paste markdown, drag in images, or just start typing...',
|
|
80
|
-
'Type away. Markdown syntax works too...',
|
|
81
|
-
'Chapter 1 begins here...',
|
|
82
|
-
'Once upon a time...',
|
|
83
|
-
"A blank page. Exciting, isn't it?",
|
|
84
|
-
'The first word is always the hardest...',
|
|
85
|
-
'Plot twist: this is where it all starts...',
|
|
86
|
-
];
|
|
87
|
-
|
|
88
|
-
const BLOCK_TAG_DATA_VALUES = {
|
|
89
|
-
none: 'hidden',
|
|
90
|
-
active: 'active',
|
|
91
|
-
always: 'visible',
|
|
92
|
-
} as const;
|
|
93
|
-
|
|
94
|
-
function pickEmptyPrompt(): string {
|
|
95
|
-
return EMPTY_PROMPTS[Math.floor(Math.random() * EMPTY_PROMPTS.length)];
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export interface WysiwygEditorProps {
|
|
99
|
-
/**
|
|
100
|
-
* Placeholder text when the editor is empty. If omitted, one of several
|
|
101
|
-
* rotating prompts is picked at random on mount. Pass a fixed string to
|
|
102
|
-
* override with a host-specific call to action.
|
|
103
|
-
*/
|
|
104
|
-
placeholder?: string;
|
|
105
|
-
/** Additional class name for the container */
|
|
106
|
-
className?: string;
|
|
107
|
-
/**
|
|
108
|
-
* If set, a plain Enter keypress fires this callback instead of inserting
|
|
109
|
-
* a newline, and Cmd/Ctrl+Enter inserts a soft break. Chat-composer UX.
|
|
110
|
-
*/
|
|
111
|
-
submitOnEnter?: () => void;
|
|
112
|
-
/** Disable Tiptap editing — renders content but blocks input. */
|
|
113
|
-
readOnly?: boolean;
|
|
114
|
-
/** Host-controlled base text size and line spacing for the Write canvas. */
|
|
115
|
-
writeCanvasSettings?: WriteCanvasSettings;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Rich WYSIWYG markdown editor built on Tiptap (ProseMirror).
|
|
120
|
-
* Binds to the shared EditorContext for source synchronization.
|
|
121
|
-
*/
|
|
122
|
-
export function WysiwygEditor({
|
|
123
|
-
placeholder,
|
|
124
|
-
className,
|
|
125
|
-
submitOnEnter,
|
|
126
|
-
readOnly = false,
|
|
127
|
-
writeCanvasSettings,
|
|
128
|
-
}: WysiwygEditorProps) {
|
|
129
|
-
const {
|
|
130
|
-
editorSource,
|
|
131
|
-
setEditorSource,
|
|
132
|
-
setTiptapEditor,
|
|
133
|
-
mediaProvider,
|
|
134
|
-
mentionProvider,
|
|
135
|
-
blockTagVisibility,
|
|
136
|
-
themeInheritance,
|
|
137
|
-
colorScheme,
|
|
138
|
-
bumpMediaRevision,
|
|
139
|
-
sceneTextChannel,
|
|
140
|
-
} = useEditorContext();
|
|
141
|
-
// Custom templates inlined in the active doc's frontmatter + the
|
|
142
|
-
// persist callback that writes a new list back into the source.
|
|
143
|
-
const { docTemplates, onDocTemplatesChange } = useDocCustomTemplates();
|
|
144
|
-
// Designer modal visibility. `null` when closed; `{ initial }` when
|
|
145
|
-
// open. `initial` is undefined for a "+ New" flow or set to an
|
|
146
|
-
// existing template to edit it.
|
|
147
|
-
const [designerState, setDesignerState] = useState<{ initial?: CustomTemplateDefinition } | null>(
|
|
148
|
-
null,
|
|
149
|
-
);
|
|
150
|
-
const handleDesignerSave = useCallback(
|
|
151
|
-
(def: CustomTemplateDefinition, target: DesignerSaveTarget) => {
|
|
152
|
-
if (target === 'doc') {
|
|
153
|
-
const existingIdx = docTemplates.findIndex((t) => t.name === def.name);
|
|
154
|
-
const next =
|
|
155
|
-
existingIdx >= 0
|
|
156
|
-
? docTemplates.map((t, i) => (i === existingIdx ? def : t))
|
|
157
|
-
: [...docTemplates, def];
|
|
158
|
-
onDocTemplatesChange(next);
|
|
159
|
-
} else {
|
|
160
|
-
saveLibraryTemplate(def);
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
[docTemplates, onDocTemplatesChange],
|
|
164
|
-
);
|
|
165
|
-
// Keep a ref so the mention extension — created once at editor mount —
|
|
166
|
-
// always sees the latest provider. Swapping projects changes
|
|
167
|
-
// the provider without remounting the editor.
|
|
168
|
-
const mentionProviderRef = useRef(mentionProvider);
|
|
169
|
-
useEffect(() => {
|
|
170
|
-
mentionProviderRef.current = mentionProvider;
|
|
171
|
-
}, [mentionProvider]);
|
|
172
|
-
// Stable per mount: either the host-supplied string, or a random pick
|
|
173
|
-
// from EMPTY_PROMPTS. Re-renders don't reshuffle.
|
|
174
|
-
const resolvedPlaceholder = useMemo(() => placeholder ?? pickEmptyPrompt(), [placeholder]);
|
|
175
|
-
const isExternalUpdate = useRef(false);
|
|
176
|
-
const lastSourceRef = useRef(editorSource);
|
|
177
|
-
// Keep a ref so the editor's drop/paste handlers (created once) always
|
|
178
|
-
// see the current MediaProvider without needing to recreate the editor.
|
|
179
|
-
const mediaProviderRef = useRef(mediaProvider);
|
|
180
|
-
useEffect(() => {
|
|
181
|
-
mediaProviderRef.current = mediaProvider;
|
|
182
|
-
}, [mediaProvider]);
|
|
183
|
-
// Preserve frontmatter across edits — hidden from WYSIWYG but prepended on
|
|
184
|
-
// save. In block mode the bound slice carries no frontmatter, so this is an
|
|
185
|
-
// empty string and the splice in `setEditorSource` keeps the doc's real
|
|
186
|
-
// frontmatter intact.
|
|
187
|
-
const frontmatterRef = useRef(stripFrontmatter(editorSource).frontmatter);
|
|
188
|
-
// Stash the latest submit callback so the editor's handleKeyDown (bound
|
|
189
|
-
// once at creation) always sees the current value.
|
|
190
|
-
const submitOnEnterRef = useRef(submitOnEnter);
|
|
191
|
-
useEffect(() => {
|
|
192
|
-
submitOnEnterRef.current = submitOnEnter;
|
|
193
|
-
}, [submitOnEnter]);
|
|
194
|
-
const editor = useEditor({
|
|
195
|
-
editable: !readOnly,
|
|
196
|
-
extensions: [
|
|
197
|
-
StarterKit.configure({
|
|
198
|
-
// Disable built-in heading; we use HeadingWithTemplate instead
|
|
199
|
-
heading: false,
|
|
200
|
-
codeBlock: {
|
|
201
|
-
HTMLAttributes: { class: 'squisq-code-block' },
|
|
202
|
-
},
|
|
203
|
-
}),
|
|
204
|
-
HeadingWithTemplate.configure({ levels: [1, 2, 3, 4, 5, 6] }),
|
|
205
|
-
BlockTagActivityExtension,
|
|
206
|
-
AsciiDiagramExtension.configure({ textChannel: sceneTextChannel }),
|
|
207
|
-
MermaidDiagramExtension,
|
|
208
|
-
CodeSnippetExtension,
|
|
209
|
-
RepairableDiagramExtension.configure({ onRepair: applyRepairCommand }),
|
|
210
|
-
TimelineViewExtension,
|
|
211
|
-
TreeViewExtension,
|
|
212
|
-
SceneBlockExtension.configure({ textChannel: sceneTextChannel }),
|
|
213
|
-
Table.configure({ resizable: true }),
|
|
214
|
-
TableRow,
|
|
215
|
-
TableCell,
|
|
216
|
-
TableHeader,
|
|
217
|
-
TaskList,
|
|
218
|
-
TaskItem.configure({ nested: true }),
|
|
219
|
-
Link.configure({
|
|
220
|
-
openOnClick: false,
|
|
221
|
-
autolink: true,
|
|
222
|
-
HTMLAttributes: { rel: 'noopener noreferrer', target: '_blank' },
|
|
223
|
-
}),
|
|
224
|
-
ImageWithMediaProvider.configure({ inline: false }),
|
|
225
|
-
TiptapVideo,
|
|
226
|
-
TiptapAudio,
|
|
227
|
-
Placeholder.configure({ placeholder: resolvedPlaceholder }),
|
|
228
|
-
buildMentionExtension(() => mentionProviderRef.current),
|
|
229
|
-
InlineIcon,
|
|
230
|
-
FindHighlightExtension,
|
|
231
|
-
],
|
|
232
|
-
content: markdownToTiptap(stripFrontmatter(editorSource).body),
|
|
233
|
-
onUpdate: ({ editor: ed }) => {
|
|
234
|
-
if (isExternalUpdate.current) return;
|
|
235
|
-
// Keep the source channel synchronous with Tiptap. Structural actions
|
|
236
|
-
// such as block navigation/addition may run in the very next browser
|
|
237
|
-
// event; deferring this write lets a stale callback serialize the newly
|
|
238
|
-
// selected block into the previous block's range. The expensive full-doc
|
|
239
|
-
// parse remains debounced in EditorContext, so correctness here does not
|
|
240
|
-
// reintroduce parse-on-every-keystroke work.
|
|
241
|
-
const bodyMd = tiptapToMarkdown(ed.getHTML());
|
|
242
|
-
const newSource = frontmatterRef.current + bodyMd;
|
|
243
|
-
lastSourceRef.current = newSource;
|
|
244
|
-
setEditorSource(newSource);
|
|
245
|
-
},
|
|
246
|
-
editorProps: {
|
|
247
|
-
attributes: {
|
|
248
|
-
class: 'squisq-wysiwyg-editor',
|
|
249
|
-
'data-testid': 'wysiwyg-editor',
|
|
250
|
-
},
|
|
251
|
-
// Chat-composer mode: Enter commits via submitOnEnter(), Cmd/Ctrl+Enter
|
|
252
|
-
// inserts a soft break. When no callback is set, fall through to Tiptap's
|
|
253
|
-
// normal behavior (Enter = paragraph break, Shift+Enter = soft break).
|
|
254
|
-
handleKeyDown: (view, event) => {
|
|
255
|
-
if (event.key !== 'Enter' || !submitOnEnterRef.current) return false;
|
|
256
|
-
// Defer Enter to an open mention/suggestion popover so the user
|
|
257
|
-
// can pick the highlighted candidate. ProseMirror plugins fire
|
|
258
|
-
// AFTER editorProps.handleKeyDown, so without this short-circuit
|
|
259
|
-
// plain Enter submits the message and the popover closes
|
|
260
|
-
// without inserting the mention. The MentionExtension marks
|
|
261
|
-
// its container with `display: block` while items are showing
|
|
262
|
-
// and `display: none` when empty — only short-circuit when
|
|
263
|
-
// there's actually a candidate to pick.
|
|
264
|
-
const popover = view.dom
|
|
265
|
-
.closest('.squisq-editor-shell')
|
|
266
|
-
?.querySelector<HTMLElement>('.squisq-mention-popover');
|
|
267
|
-
if (popover && popover.style.display !== 'none') {
|
|
268
|
-
return false;
|
|
269
|
-
}
|
|
270
|
-
if (event.metaKey || event.ctrlKey) {
|
|
271
|
-
// User wants a newline. Insert a hard-break and stop propagation so
|
|
272
|
-
// we don't also create a new paragraph.
|
|
273
|
-
event.preventDefault();
|
|
274
|
-
view.dispatch(
|
|
275
|
-
view.state.tr.replaceSelectionWith(view.state.schema.nodes.hardBreak.create()),
|
|
276
|
-
);
|
|
277
|
-
return true;
|
|
278
|
-
}
|
|
279
|
-
if (event.shiftKey) {
|
|
280
|
-
// Preserve the conventional Shift+Enter soft break.
|
|
281
|
-
return false;
|
|
282
|
-
}
|
|
283
|
-
// Plain Enter — submit.
|
|
284
|
-
event.preventDefault();
|
|
285
|
-
submitOnEnterRef.current();
|
|
286
|
-
return true;
|
|
287
|
-
},
|
|
288
|
-
// When the clipboard's plain-text payload looks like markdown source,
|
|
289
|
-
// convert it via tiptapBridge before pasting. This applies even when
|
|
290
|
-
// the clipboard also contains HTML (most rich-text sources do), since
|
|
291
|
-
// the markdown-looking text is usually what the user actually wants.
|
|
292
|
-
// Without this, pasted markdown shows up as literal "# Heading" text
|
|
293
|
-
// instead of becoming a real heading.
|
|
294
|
-
handlePaste: (view, event) => {
|
|
295
|
-
const clipboard = event.clipboardData;
|
|
296
|
-
if (!clipboard) return false;
|
|
297
|
-
|
|
298
|
-
// Image files in the clipboard → upload via MediaProvider and insert
|
|
299
|
-
const imageFiles = filesFromClipboard(clipboard);
|
|
300
|
-
if (imageFiles.length > 0 && mediaProviderRef.current) {
|
|
301
|
-
event.preventDefault();
|
|
302
|
-
uploadAndInsertImages(view, imageFiles, mediaProviderRef.current, bumpMediaRevision);
|
|
303
|
-
return true;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
const text = clipboard.getData('text/plain');
|
|
307
|
-
if (!text) return false;
|
|
308
|
-
|
|
309
|
-
// Bare (unfenced) ASCII diagram art → verbatim into a fresh code
|
|
310
|
-
// block, which AsciiDiagramExtension turns into an interactive
|
|
311
|
-
// canvas. Must run BEFORE the markdown branch: `| x |` art rows
|
|
312
|
-
// false-positive as GFM table rows and would be mangled.
|
|
313
|
-
if (shouldPasteAsAsciiFence(text)) {
|
|
314
|
-
const codeBlockType = view.state.schema.nodes.codeBlock;
|
|
315
|
-
if (codeBlockType) {
|
|
316
|
-
event.preventDefault();
|
|
317
|
-
// Tag the fence `diagram` so its identity survives a later
|
|
318
|
-
// flatten → markdown → re-import round-trip (the language class
|
|
319
|
-
// round-trips; fence meta does not).
|
|
320
|
-
view.dispatch(
|
|
321
|
-
view.state.tr.replaceSelectionWith(
|
|
322
|
-
codeBlockType.create({ language: 'diagram' }, view.state.schema.text(text)),
|
|
323
|
-
),
|
|
324
|
-
);
|
|
325
|
-
return true;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// Bare (unfenced) marker rails → an explicit timeline code block.
|
|
330
|
-
// Run before the tree gate because timeline callout elbows can look
|
|
331
|
-
// like nested tree connectors to a deliberately lenient parser.
|
|
332
|
-
if (shouldPasteAsTimelineFence(text)) {
|
|
333
|
-
const codeBlockType = view.state.schema.nodes.codeBlock;
|
|
334
|
-
if (codeBlockType) {
|
|
335
|
-
event.preventDefault();
|
|
336
|
-
view.dispatch(
|
|
337
|
-
view.state.tr.replaceSelectionWith(
|
|
338
|
-
codeBlockType.create({ language: 'timeline' }, view.state.schema.text(text)),
|
|
339
|
-
),
|
|
340
|
-
);
|
|
341
|
-
return true;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// Bare (unfenced) ASCII tree art → a fresh code block that the
|
|
346
|
-
// TreeViewExtension turns into an outline. After the diagram gate,
|
|
347
|
-
// before markdown (the `├──` lines must not be mangled as prose).
|
|
348
|
-
if (shouldPasteAsTreeFence(text)) {
|
|
349
|
-
const codeBlockType = view.state.schema.nodes.codeBlock;
|
|
350
|
-
if (codeBlockType) {
|
|
351
|
-
event.preventDefault();
|
|
352
|
-
// Tag the fence `tree` so its identity survives round-trips.
|
|
353
|
-
view.dispatch(
|
|
354
|
-
view.state.tr.replaceSelectionWith(
|
|
355
|
-
codeBlockType.create({ language: 'tree' }, view.state.schema.text(text)),
|
|
356
|
-
),
|
|
357
|
-
);
|
|
358
|
-
return true;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
if (!looksLikeMarkdown(text)) return false;
|
|
363
|
-
const html = markdownToTiptap(text);
|
|
364
|
-
if (!html) return false;
|
|
365
|
-
event.preventDefault();
|
|
366
|
-
view.pasteHTML(html);
|
|
367
|
-
return true;
|
|
368
|
-
},
|
|
369
|
-
// When image files are dropped onto the editor, upload them via the
|
|
370
|
-
// MediaProvider and insert <img> nodes referencing the relative paths.
|
|
371
|
-
// Also handles drags from the MediaBin, which reference existing
|
|
372
|
-
// entries via a custom MIME type and skip the upload step.
|
|
373
|
-
// Falls through to default handling for non-image drops or when no
|
|
374
|
-
// MediaProvider is available.
|
|
375
|
-
handleDrop: (view, event, _slice, moved) => {
|
|
376
|
-
const dt = event.dataTransfer;
|
|
377
|
-
if (!dt) return false;
|
|
378
|
-
|
|
379
|
-
// Internal node move (the user dragged an existing node within
|
|
380
|
-
// the document). ProseMirror's `moved` flag is true in this
|
|
381
|
-
// case; let it handle the reposition natively so width/height
|
|
382
|
-
// attributes are preserved and the source node is removed.
|
|
383
|
-
// Without this short-circuit, the browser also exposes the
|
|
384
|
-
// dragged `<img>` as a virtual file in `dataTransfer`, so the
|
|
385
|
-
// upload-and-insert path below would fire — producing a
|
|
386
|
-
// dimension-less duplicate next to the original.
|
|
387
|
-
if (moved) return false;
|
|
388
|
-
|
|
389
|
-
// In-app drag from the MediaBin — insert without uploading
|
|
390
|
-
const squisqRaw = dt.getData(SQUISQ_MEDIA_MIME);
|
|
391
|
-
if (squisqRaw) {
|
|
392
|
-
const payload = parseSquisqMediaPayload(squisqRaw);
|
|
393
|
-
if (payload && payload.mimeType.startsWith('image/')) {
|
|
394
|
-
event.preventDefault();
|
|
395
|
-
moveSelectionToDropPoint(view, event);
|
|
396
|
-
insertImageNode(view, payload.name, payload.alt);
|
|
397
|
-
return true;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
const imageFiles = filesFromDataTransfer(dt);
|
|
402
|
-
if (imageFiles.length === 0) {
|
|
403
|
-
// Nothing image-like in the drop. Let the browser / ProseMirror
|
|
404
|
-
// handle it (links, text, etc.). Log enough to debug if the user
|
|
405
|
-
// expected this to be an image drop — Windows/browser combos
|
|
406
|
-
// sometimes deliver image drags without a usable File payload.
|
|
407
|
-
if (dt.files.length > 0 || dt.items.length > 0) {
|
|
408
|
-
console.warn(
|
|
409
|
-
'[squisq-editor] Drop received with no recognizable image File. Types:',
|
|
410
|
-
Array.from(dt.types ?? []),
|
|
411
|
-
'files:',
|
|
412
|
-
Array.from(dt.files).map((f) => `${f.name} (${f.type || 'no-type'})`),
|
|
413
|
-
);
|
|
414
|
-
}
|
|
415
|
-
return false;
|
|
416
|
-
}
|
|
417
|
-
if (!mediaProviderRef.current) {
|
|
418
|
-
console.warn(
|
|
419
|
-
'[squisq-editor] Image drop received but no MediaProvider is wired up; cannot persist the image. Pass `mediaProvider` to EditorShell / EditorProvider.',
|
|
420
|
-
);
|
|
421
|
-
return false;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
event.preventDefault();
|
|
425
|
-
moveSelectionToDropPoint(view, event);
|
|
426
|
-
uploadAndInsertImages(view, imageFiles, mediaProviderRef.current, bumpMediaRevision);
|
|
427
|
-
return true;
|
|
428
|
-
},
|
|
429
|
-
},
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
// Register / unregister the Tiptap editor instance with the shared context
|
|
433
|
-
useEffect(() => {
|
|
434
|
-
if (editor) {
|
|
435
|
-
setTiptapEditor(editor);
|
|
436
|
-
}
|
|
437
|
-
return () => setTiptapEditor(null);
|
|
438
|
-
}, [editor, setTiptapEditor]);
|
|
439
|
-
|
|
440
|
-
// Tiptap reads `editable` only at creation; mirror later changes via
|
|
441
|
-
// setEditable so flipping readOnly from the host takes effect without
|
|
442
|
-
// remounting the editor.
|
|
443
|
-
useEffect(() => {
|
|
444
|
-
if (editor) editor.setEditable(!readOnly);
|
|
445
|
-
}, [editor, readOnly]);
|
|
446
|
-
|
|
447
|
-
// ── Template badge → popover ─────────────────────────────────────
|
|
448
|
-
// The HeadingWithTemplate extension renders an inert `.squisq-template-badge`
|
|
449
|
-
// span inside templated headings. We delegate clicks at the container
|
|
450
|
-
// level so we can locate the heading position and open the gallery
|
|
451
|
-
// anchored at that badge.
|
|
452
|
-
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
453
|
-
const [badgeMenu, setBadgeMenu] = useState<{
|
|
454
|
-
rect: DOMRect;
|
|
455
|
-
template: string;
|
|
456
|
-
headingPos: number;
|
|
457
|
-
headingIndex: number;
|
|
458
|
-
} | null>(null);
|
|
459
|
-
const [propsMenu, setPropsMenu] = useState<{
|
|
460
|
-
rect: DOMRect;
|
|
461
|
-
headingPos: number;
|
|
462
|
-
blockAttrs: string | null;
|
|
463
|
-
templateParams: string | null;
|
|
464
|
-
} | null>(null);
|
|
465
|
-
|
|
466
|
-
const closeBadgeMenu = useCallback(() => {
|
|
467
|
-
setBadgeMenu(null);
|
|
468
|
-
// The portaled gallery moves focus into its search field. Restore the
|
|
469
|
-
// document's preserved ProseMirror selection after React has unmounted the
|
|
470
|
-
// dialog, so the caret resumes blinking where the author left it.
|
|
471
|
-
requestAnimationFrame(() => {
|
|
472
|
-
if (editor && !editor.isDestroyed) editor.commands.focus();
|
|
473
|
-
});
|
|
474
|
-
}, [editor]);
|
|
475
|
-
|
|
476
|
-
useEffect(() => {
|
|
477
|
-
if (!editor) return;
|
|
478
|
-
const root = containerRef.current;
|
|
479
|
-
if (!root) return;
|
|
480
|
-
const onClick = (e: MouseEvent) => {
|
|
481
|
-
const target = e.target as HTMLElement | null;
|
|
482
|
-
if (!target) return;
|
|
483
|
-
const propsBadge = target.closest('.squisq-props-badge') as HTMLElement | null;
|
|
484
|
-
const templateBadge = target.closest('.squisq-template-badge') as HTMLElement | null;
|
|
485
|
-
const badge = propsBadge ?? templateBadge;
|
|
486
|
-
if (!badge || !root.contains(badge)) return;
|
|
487
|
-
e.preventDefault();
|
|
488
|
-
e.stopPropagation();
|
|
489
|
-
// Find the parent heading element and resolve its document position.
|
|
490
|
-
const headingEl = badge.closest('h1,h2,h3,h4,h5,h6') as HTMLElement | null;
|
|
491
|
-
if (!headingEl) return;
|
|
492
|
-
let pos: number | null = null;
|
|
493
|
-
try {
|
|
494
|
-
pos = editor.view.posAtDOM(headingEl, 0);
|
|
495
|
-
} catch {
|
|
496
|
-
pos = null;
|
|
497
|
-
}
|
|
498
|
-
if (pos == null) return;
|
|
499
|
-
// posAtDOM returns the position *inside* the heading; subtract 1
|
|
500
|
-
// to land on the heading node itself so setNodeMarkup targets it.
|
|
501
|
-
const headingPos = Math.max(0, pos - 1);
|
|
502
|
-
const node = editor.state.doc.nodeAt(headingPos);
|
|
503
|
-
if (!node || node.type.name !== 'heading') return;
|
|
504
|
-
|
|
505
|
-
// Block-properties badge → open the properties palette.
|
|
506
|
-
if (propsBadge) {
|
|
507
|
-
setBadgeMenu(null);
|
|
508
|
-
setPropsMenu({
|
|
509
|
-
rect: badge.getBoundingClientRect(),
|
|
510
|
-
headingPos,
|
|
511
|
-
blockAttrs: (node.attrs.dataBlockAttrs as string | null) ?? null,
|
|
512
|
-
templateParams: (node.attrs.dataTemplateParams as string | null) ?? null,
|
|
513
|
-
});
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
// Template badge → open the template gallery. Count how many headings
|
|
518
|
-
// precede this one so the markdown-source slice helper can locate the
|
|
519
|
-
// matching heading by index.
|
|
520
|
-
let headingIndex = 0;
|
|
521
|
-
let count = 0;
|
|
522
|
-
editor.state.doc.descendants((n, p) => {
|
|
523
|
-
if (n.type.name !== 'heading') return;
|
|
524
|
-
if (p === headingPos) {
|
|
525
|
-
headingIndex = count;
|
|
526
|
-
return false;
|
|
527
|
-
}
|
|
528
|
-
count++;
|
|
529
|
-
});
|
|
530
|
-
setPropsMenu(null);
|
|
531
|
-
setBadgeMenu({
|
|
532
|
-
rect: badge.getBoundingClientRect(),
|
|
533
|
-
template: (node.attrs.dataTemplate as string | null) ?? '',
|
|
534
|
-
headingPos,
|
|
535
|
-
headingIndex,
|
|
536
|
-
});
|
|
537
|
-
};
|
|
538
|
-
root.addEventListener('mousedown', onClick);
|
|
539
|
-
return () => root.removeEventListener('mousedown', onClick);
|
|
540
|
-
}, [editor]);
|
|
541
|
-
|
|
542
|
-
// Sync external changes into Tiptap. `editorSource` also changes when the
|
|
543
|
-
// user navigates to a different block in block-at-a-time mode, so this same
|
|
544
|
-
// path reloads the card with the newly selected block's slice.
|
|
545
|
-
useEffect(() => {
|
|
546
|
-
if (!editor) return;
|
|
547
|
-
if (editorSource === lastSourceRef.current) return;
|
|
548
|
-
// In block/timeline mode `setEditorSource` normalizes the slice's trailing
|
|
549
|
-
// whitespace (a `\n\n` before the next block) before splicing, so the
|
|
550
|
-
// re-extracted `editorSource` differs from what we just emitted by trailing
|
|
551
|
-
// whitespace only. Re-setting content for that would reset the caret to the
|
|
552
|
-
// end on every keystroke — so only reload when the body actually changed.
|
|
553
|
-
if (editorSource.replace(/\s+$/, '') === lastSourceRef.current.replace(/\s+$/, '')) {
|
|
554
|
-
lastSourceRef.current = editorSource;
|
|
555
|
-
return;
|
|
556
|
-
}
|
|
557
|
-
isExternalUpdate.current = true;
|
|
558
|
-
const { body, frontmatter } = stripFrontmatter(editorSource);
|
|
559
|
-
frontmatterRef.current = frontmatter;
|
|
560
|
-
const content = markdownToTiptap(body);
|
|
561
|
-
editor.commands.setContent(content);
|
|
562
|
-
lastSourceRef.current = editorSource;
|
|
563
|
-
isExternalUpdate.current = false;
|
|
564
|
-
}, [editorSource, editor]);
|
|
565
|
-
|
|
566
|
-
// Match the WYSIWYG editor's appearance to the active Squisq theme when one
|
|
567
|
-
// is set in frontmatter or picked in the preview dropdown. The block-props
|
|
568
|
-
// affordance always carries the theme's primary as UI accent (like the
|
|
569
|
-
// outline); document-content inheritance is driven by the View menu setting:
|
|
570
|
-
// - 'none' → don't inherit anything
|
|
571
|
-
// - 'fonts' → body + heading fonts only (historical default)
|
|
572
|
-
// - 'fonts-colors' → fonts plus the theme's canvas / text colors
|
|
573
|
-
// Pushed as CSS custom properties on the container so the stylesheet
|
|
574
|
-
// can pick them up (with sensible fallbacks for hosts that don't have
|
|
575
|
-
// a PreviewSettingsProvider in scope).
|
|
576
|
-
const previewSettings = usePreviewSettingsOptional();
|
|
577
|
-
const activeTheme = previewSettings?.activeTheme;
|
|
578
|
-
const badgePreviewSource = useMemo(() => {
|
|
579
|
-
if (!badgeMenu) return undefined;
|
|
580
|
-
try {
|
|
581
|
-
const previewDoc = markdownToDoc(parseMarkdown(editorSource), { autoTemplates: false });
|
|
582
|
-
const block = flattenBlocks(previewDoc.blocks)[badgeMenu.headingIndex];
|
|
583
|
-
if (!block) return undefined;
|
|
584
|
-
return {
|
|
585
|
-
block,
|
|
586
|
-
theme: previewSettings?.activeTheme ?? DEFAULT_THEME,
|
|
587
|
-
viewport: previewSettings?.activeViewport ?? VIEWPORT_PRESETS.landscape,
|
|
588
|
-
basePath: '/',
|
|
589
|
-
mediaProvider,
|
|
590
|
-
customTemplates: docTemplates,
|
|
591
|
-
};
|
|
592
|
-
} catch {
|
|
593
|
-
return undefined;
|
|
594
|
-
}
|
|
595
|
-
}, [
|
|
596
|
-
badgeMenu,
|
|
597
|
-
docTemplates,
|
|
598
|
-
editorSource,
|
|
599
|
-
mediaProvider,
|
|
600
|
-
previewSettings?.activeTheme,
|
|
601
|
-
previewSettings?.activeViewport,
|
|
602
|
-
]);
|
|
603
|
-
const themeStyle = useMemo<CSSProperties>(() => {
|
|
604
|
-
if (!activeTheme) return {};
|
|
605
|
-
const out: Record<string, string> = {
|
|
606
|
-
'--squisq-block-props-accent': activeTheme.colors.primary,
|
|
607
|
-
};
|
|
608
|
-
if (themeInheritance === 'none') return out as CSSProperties;
|
|
609
|
-
Object.assign(out, {
|
|
610
|
-
'--squisq-theme-body-font': resolveFontFamily(
|
|
611
|
-
activeTheme.typography.bodyFont,
|
|
612
|
-
FONT_FALLBACKS.sans,
|
|
613
|
-
),
|
|
614
|
-
'--squisq-theme-title-font': resolveFontFamily(
|
|
615
|
-
activeTheme.typography.titleFont,
|
|
616
|
-
FONT_FALLBACKS.sans,
|
|
617
|
-
),
|
|
618
|
-
});
|
|
619
|
-
if (themeInheritance === 'fonts-colors') {
|
|
620
|
-
const colors = activeTheme.colors;
|
|
621
|
-
out['--squisq-theme-bg'] = colors.background;
|
|
622
|
-
// backgroundLight gives a subtle on-canvas surface for inline emphasis
|
|
623
|
-
// (inline `code`, code blocks). Themes always define it.
|
|
624
|
-
out['--squisq-theme-bg-muted'] = colors.backgroundLight;
|
|
625
|
-
out['--squisq-theme-text'] = colors.text;
|
|
626
|
-
out['--squisq-theme-text-muted'] = colors.textMuted;
|
|
627
|
-
out['--squisq-theme-primary'] = colors.primary;
|
|
628
|
-
}
|
|
629
|
-
return out as CSSProperties;
|
|
630
|
-
}, [activeTheme, themeInheritance]);
|
|
631
|
-
|
|
632
|
-
return (
|
|
633
|
-
<CustomTemplateProvider docTemplates={docTemplates} onDocTemplatesChange={onDocTemplatesChange}>
|
|
634
|
-
<div
|
|
635
|
-
className={`squisq-wysiwyg-container${className ? ` ${className}` : ''}`}
|
|
636
|
-
style={{
|
|
637
|
-
width: '100%',
|
|
638
|
-
height: '100%',
|
|
639
|
-
overflow: 'auto',
|
|
640
|
-
...themeStyle,
|
|
641
|
-
...writeCanvasSettingsStyle(writeCanvasSettings),
|
|
642
|
-
}}
|
|
643
|
-
data-testid="wysiwyg-container"
|
|
644
|
-
data-block-tags={BLOCK_TAG_DATA_VALUES[blockTagVisibility]}
|
|
645
|
-
data-theme-inheritance={themeInheritance}
|
|
646
|
-
ref={containerRef}
|
|
647
|
-
>
|
|
648
|
-
<EditorContent editor={editor} style={{ height: '100%' }} />
|
|
649
|
-
{badgeMenu && (
|
|
650
|
-
<TemplateBadgePopover
|
|
651
|
-
anchorRect={badgeMenu.rect}
|
|
652
|
-
value={badgeMenu.template}
|
|
653
|
-
colorScheme={colorScheme}
|
|
654
|
-
recommended={(() => {
|
|
655
|
-
// `headingIndex` is counted within the mounted Tiptap doc, which
|
|
656
|
-
// reflects `editorSource` — the active block's slice in block
|
|
657
|
-
// mode, the full document otherwise.
|
|
658
|
-
const slice = findBlockSliceByHeadingIndex(editorSource, badgeMenu.headingIndex);
|
|
659
|
-
if (!slice) return undefined;
|
|
660
|
-
const profile = profileBlockContents(slice);
|
|
661
|
-
return recommendTemplatesForBlock(profile, TEMPLATE_NAMES).recommended;
|
|
662
|
-
})()}
|
|
663
|
-
previewSource={badgePreviewSource}
|
|
664
|
-
onOpenDesigner={() => {
|
|
665
|
-
setBadgeMenu(null);
|
|
666
|
-
setDesignerState({});
|
|
667
|
-
}}
|
|
668
|
-
onChange={(name) => {
|
|
669
|
-
if (!editor) return;
|
|
670
|
-
const tr = editor.state.tr.setNodeMarkup(badgeMenu.headingPos, undefined, {
|
|
671
|
-
...editor.state.doc.nodeAt(badgeMenu.headingPos)?.attrs,
|
|
672
|
-
dataTemplate: name === '' ? null : name,
|
|
673
|
-
});
|
|
674
|
-
editor.view.dispatch(tr);
|
|
675
|
-
}}
|
|
676
|
-
onClose={closeBadgeMenu}
|
|
677
|
-
/>
|
|
678
|
-
)}
|
|
679
|
-
{propsMenu && (
|
|
680
|
-
<BlockPropertiesPopover
|
|
681
|
-
anchorRect={propsMenu.rect}
|
|
682
|
-
blockAttrs={propsMenu.blockAttrs}
|
|
683
|
-
templateParams={propsMenu.templateParams}
|
|
684
|
-
colorScheme={colorScheme}
|
|
685
|
-
accentColor={activeTheme?.colors.primary}
|
|
686
|
-
onChange={(nextInner) => {
|
|
687
|
-
if (!editor) return;
|
|
688
|
-
const current = editor.state.doc.nodeAt(propsMenu.headingPos);
|
|
689
|
-
if (!current || current.type.name !== 'heading') return;
|
|
690
|
-
const tr = editor.state.tr.setNodeMarkup(propsMenu.headingPos, undefined, {
|
|
691
|
-
...current.attrs,
|
|
692
|
-
dataBlockAttrs: nextInner,
|
|
693
|
-
});
|
|
694
|
-
editor.view.dispatch(tr);
|
|
695
|
-
}}
|
|
696
|
-
onAnnotationChange={(next) => {
|
|
697
|
-
if (!editor) return;
|
|
698
|
-
const current = editor.state.doc.nodeAt(propsMenu.headingPos);
|
|
699
|
-
if (!current || current.type.name !== 'heading') return;
|
|
700
|
-
const tr = editor.state.tr.setNodeMarkup(propsMenu.headingPos, undefined, {
|
|
701
|
-
...current.attrs,
|
|
702
|
-
dataBlockAttrs: next.blockAttrsInner,
|
|
703
|
-
dataTemplateParams: next.templateParams,
|
|
704
|
-
});
|
|
705
|
-
editor.view.dispatch(tr);
|
|
706
|
-
}}
|
|
707
|
-
onClose={() => setPropsMenu(null)}
|
|
708
|
-
/>
|
|
709
|
-
)}
|
|
710
|
-
{designerState && (
|
|
711
|
-
<TemplateDesigner
|
|
712
|
-
initial={designerState.initial}
|
|
713
|
-
onSave={handleDesignerSave}
|
|
714
|
-
onClose={() => setDesignerState(null)}
|
|
715
|
-
mediaProvider={mediaProvider}
|
|
716
|
-
colorScheme={colorScheme}
|
|
717
|
-
/>
|
|
718
|
-
)}
|
|
719
|
-
</div>
|
|
720
|
-
</CustomTemplateProvider>
|
|
721
|
-
);
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
// ── Image drop / paste helpers ─────────────────────────────────────
|
|
725
|
-
|
|
726
|
-
/** Extension-based fallback when a dragged file has no `type` set (rare
|
|
727
|
-
* but happens when sources omit the MIME — e.g. some screenshot tools). */
|
|
728
|
-
const IMAGE_EXT_RE = /\.(png|jpe?g|gif|webp|bmp|svg|avif|ico)$/i;
|
|
729
|
-
|
|
730
|
-
function looksLikeImageFile(file: File): boolean {
|
|
731
|
-
if (file.type.startsWith('image/')) return true;
|
|
732
|
-
return IMAGE_EXT_RE.test(file.name);
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
/** Extract image File objects from a DataTransfer (drop event). Reads
|
|
736
|
-
* from both `dt.files` and `dt.items`; some drag sources (cross-tab
|
|
737
|
-
* drags, certain native apps) populate only one of the two. */
|
|
738
|
-
function filesFromDataTransfer(dt: DataTransfer): File[] {
|
|
739
|
-
const files: File[] = [];
|
|
740
|
-
const seen = new Set<string>();
|
|
741
|
-
|
|
742
|
-
for (let i = 0; i < dt.files.length; i++) {
|
|
743
|
-
const file = dt.files[i];
|
|
744
|
-
if (looksLikeImageFile(file)) {
|
|
745
|
-
files.push(file);
|
|
746
|
-
seen.add(`${file.name}|${file.size}`);
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
if (dt.items) {
|
|
751
|
-
for (let i = 0; i < dt.items.length; i++) {
|
|
752
|
-
const item = dt.items[i];
|
|
753
|
-
if (item.kind !== 'file') continue;
|
|
754
|
-
const file = item.getAsFile();
|
|
755
|
-
if (!file) continue;
|
|
756
|
-
if (!looksLikeImageFile(file)) continue;
|
|
757
|
-
const key = `${file.name}|${file.size}`;
|
|
758
|
-
if (seen.has(key)) continue;
|
|
759
|
-
files.push(file);
|
|
760
|
-
seen.add(key);
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
return files;
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
/** Extract image File objects from a clipboard's items (paste event). */
|
|
768
|
-
function filesFromClipboard(clipboard: DataTransfer): File[] {
|
|
769
|
-
const files: File[] = [];
|
|
770
|
-
// clipboardData.items is the most reliable source for pasted images
|
|
771
|
-
if (clipboard.items) {
|
|
772
|
-
for (let i = 0; i < clipboard.items.length; i++) {
|
|
773
|
-
const item = clipboard.items[i];
|
|
774
|
-
if (item.kind === 'file' && item.type.startsWith('image/')) {
|
|
775
|
-
const file = item.getAsFile();
|
|
776
|
-
if (file) files.push(file);
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
return files;
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
/** Insert an image node at the current selection using the schema image type. */
|
|
784
|
-
function insertImageNode(view: ImageMutationView, src: string, alt: string): void {
|
|
785
|
-
const { schema } = view.state;
|
|
786
|
-
const imageType = schema.nodes.image;
|
|
787
|
-
if (!imageType) return;
|
|
788
|
-
const node = imageType.create({ src, alt });
|
|
789
|
-
const tr = view.state.tr.replaceSelectionWith(node);
|
|
790
|
-
view.dispatch(tr);
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
/** Move the selection to the document position under the drop event's coordinates. */
|
|
794
|
-
function moveSelectionToDropPoint(view: ProseMirrorView, event: DragEvent): void {
|
|
795
|
-
const coords = view.posAtCoords({ left: event.clientX, top: event.clientY });
|
|
796
|
-
if (!coords) return;
|
|
797
|
-
const tr = view.state.tr.setSelection(Selection.near(view.state.doc.resolve(coords.pos)));
|
|
798
|
-
view.dispatch(tr);
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
/**
|
|
802
|
-
* Hook to access the Tiptap editor instance for toolbar commands.
|
|
803
|
-
* The WysiwygEditor must be mounted as a sibling or descendant.
|
|
804
|
-
*/
|
|
805
|
-
// eslint-disable-next-line react-refresh/only-export-components
|
|
806
|
-
export { useEditor as useTiptapEditor } from '@tiptap/react';
|