@bendyline/squisq-editor-react 2.0.1 → 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/README.md +10 -2
- package/dist/index.d.ts +683 -60
- package/dist/index.js +9648 -3750
- package/dist/monaco.js +0 -1
- package/dist/styles/index.css +1160 -241
- package/package.json +10 -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 -1247
- package/src/EditorShell.tsx +0 -1334
- 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 -1250
- package/src/PreviewPanel.tsx +0 -422
- package/src/RawEditor.tsx +0 -731
- package/src/RecorderEntry.tsx +0 -159
- 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 -2587
- 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 -792
- 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 -48
- 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 -485
- 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__/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__/mediaAttachmentFlow.test.ts +0 -110
- package/src/__tests__/mediaBinDrop.test.tsx +0 -90
- package/src/__tests__/mediaReferences.test.ts +0 -82
- 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 -540
- 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 -566
- 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 -164
- 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__/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 -145
- 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 -405
- 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/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 -259
- 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/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 -470
- 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/mediaDragMime.ts +0 -32
- package/src/mediaEntries.ts +0 -12
- package/src/mediaReferences.ts +0 -299
- 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 -616
- package/src/scene/SceneBlockExtension.ts +0 -205
- package/src/scene/SceneBlockToolbar.tsx +0 -201
- 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/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__/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 -103
- 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/hooks/useSceneHitTest.ts +0 -105
- package/src/scene/hooks/useScenePanZoom.ts +0 -147
- 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 -792
- 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/diagram.css +0 -183
- package/src/styles/editor.css +0 -6811
- package/src/styles/folder-view.css +0 -210
- package/src/styles/image-edit-affordance.css +0 -201
- package/src/styles/index.css +0 -18
- 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/wysiwygImageUpload.ts +0 -113
package/src/TemplatePicker.tsx
DELETED
|
@@ -1,1314 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TemplatePicker
|
|
3
|
-
*
|
|
4
|
-
* A custom popover that replaces the plain <select> for block templates.
|
|
5
|
-
* Each template entry shows a mini wireframe SVG, a human-readable label,
|
|
6
|
-
* and a one-sentence description so authors can quickly find the right layout.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { useEffect, useId, useMemo, useRef, useState } from 'react';
|
|
10
|
-
import { createPortal } from 'react-dom';
|
|
11
|
-
import type { CustomTemplateDefinition } from '@bendyline/squisq/schemas';
|
|
12
|
-
import { TEMPLATE_METADATA, resolveTemplateName } from '@bendyline/squisq/doc';
|
|
13
|
-
import { extractPlainText } from '@bendyline/squisq/markdown';
|
|
14
|
-
import { useCustomTemplates } from './customTemplates/CustomTemplateContext';
|
|
15
|
-
import { TemplateThumbnail } from './customTemplates/thumbnail';
|
|
16
|
-
import { TemplateContentPreview } from './TemplateContentPreview';
|
|
17
|
-
import {
|
|
18
|
-
resolveTemplateContentPreviewResult,
|
|
19
|
-
type TemplatePreviewSource,
|
|
20
|
-
} from './templateContentPreviewResolver';
|
|
21
|
-
|
|
22
|
-
// ── Template metadata ─────────────────────────────────────────────
|
|
23
|
-
//
|
|
24
|
-
// The canonical list of built-in templates (which ids exist, their labels,
|
|
25
|
-
// and their descriptions) lives in core's `TEMPLATE_METADATA`. The entries
|
|
26
|
-
// below add the one thing core can't hold — a React/SVG preview icon per id —
|
|
27
|
-
// and MUST stay 1:1 with `TEMPLATE_METADATA` (same ids, same order, same
|
|
28
|
-
// label/description). `templatePickerMetadata.test.ts` enforces this, so a
|
|
29
|
-
// template added to the core registry without a picker icon (or vice versa)
|
|
30
|
-
// fails the build instead of silently disappearing from the gallery.
|
|
31
|
-
|
|
32
|
-
interface TemplateEntry {
|
|
33
|
-
name: string;
|
|
34
|
-
label: string;
|
|
35
|
-
description: string;
|
|
36
|
-
icon: JSX.Element;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** Matches every gallery when multiple editor instances are mounted. */
|
|
40
|
-
export const TEMPLATE_GALLERY_PORTAL_SELECTOR = '[data-squisq-template-gallery-portal]';
|
|
41
|
-
|
|
42
|
-
const TEMPLATE_GALLERY_DIALOG_ID = 'squisq-template-gallery-dialog';
|
|
43
|
-
const TEMPLATE_GALLERY_PORTAL_ID_PREFIX = 'squisq-template-gallery-portal';
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Give each portaled gallery a stable, collision-free id. Hosts should match
|
|
47
|
-
* galleries through {@link TEMPLATE_GALLERY_PORTAL_SELECTOR}; a process-wide
|
|
48
|
-
* singleton id cannot identify the right editor when several are mounted.
|
|
49
|
-
*/
|
|
50
|
-
function useTemplateGalleryPortalId(): string {
|
|
51
|
-
return `${TEMPLATE_GALLERY_PORTAL_ID_PREFIX}-${useId().replace(/:/g, '')}`;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const W = 56;
|
|
55
|
-
const H = 40;
|
|
56
|
-
|
|
57
|
-
/** Neutral fill for structural shapes */
|
|
58
|
-
const F1 = '#d1d5db';
|
|
59
|
-
/** Slightly darker fill for important / featured elements */
|
|
60
|
-
const F2 = '#9ca3af';
|
|
61
|
-
/** Accent fill (stat number, image, play button) */
|
|
62
|
-
const FA = '#818cf8';
|
|
63
|
-
|
|
64
|
-
function TemplateIcon({ children }: { children: React.ReactNode }) {
|
|
65
|
-
return (
|
|
66
|
-
<svg
|
|
67
|
-
width={W}
|
|
68
|
-
height={H}
|
|
69
|
-
viewBox={`0 0 ${W} ${H}`}
|
|
70
|
-
aria-hidden="true"
|
|
71
|
-
className="squisq-template-picker-icon"
|
|
72
|
-
>
|
|
73
|
-
{children}
|
|
74
|
-
</svg>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const NONE_ENTRY: TemplateEntry = {
|
|
79
|
-
name: '',
|
|
80
|
-
label: '— none —',
|
|
81
|
-
description: 'Plain heading block with no visual treatment.',
|
|
82
|
-
icon: (
|
|
83
|
-
<TemplateIcon>
|
|
84
|
-
<rect
|
|
85
|
-
x={4}
|
|
86
|
-
y={4}
|
|
87
|
-
width={48}
|
|
88
|
-
height={32}
|
|
89
|
-
rx={2}
|
|
90
|
-
fill="none"
|
|
91
|
-
stroke={F1}
|
|
92
|
-
strokeWidth={1.5}
|
|
93
|
-
strokeDasharray="3 2"
|
|
94
|
-
/>
|
|
95
|
-
<rect x={12} y={15} width={32} height={4} rx={1} fill={F1} />
|
|
96
|
-
<rect x={16} y={22} width={24} height={3} rx={1} fill={F1} opacity={0.6} />
|
|
97
|
-
</TemplateIcon>
|
|
98
|
-
),
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
// eslint-disable-next-line react-refresh/only-export-components
|
|
102
|
-
export const TEMPLATE_ENTRIES: TemplateEntry[] = [
|
|
103
|
-
{
|
|
104
|
-
name: 'title',
|
|
105
|
-
label: 'Title',
|
|
106
|
-
description: 'A bold opening slide with large title text, perfect for covers and chapters.',
|
|
107
|
-
icon: (
|
|
108
|
-
<TemplateIcon>
|
|
109
|
-
<rect x={4} y={4} width={48} height={32} rx={2} fill={F1} opacity={0.3} />
|
|
110
|
-
<rect x={8} y={11} width={40} height={8} rx={1} fill={FA} />
|
|
111
|
-
<rect x={14} y={23} width={28} height={3} rx={1} fill={F2} />
|
|
112
|
-
<rect x={20} y={29} width={16} height={2} rx={1} fill={F1} />
|
|
113
|
-
</TemplateIcon>
|
|
114
|
-
),
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
name: 'sectionHeader',
|
|
118
|
-
label: 'Section Header',
|
|
119
|
-
description: 'A clean section break with a prominent title and optional subtitle.',
|
|
120
|
-
icon: (
|
|
121
|
-
<TemplateIcon>
|
|
122
|
-
<rect x={4} y={4} width={3} height={32} rx={1} fill={FA} />
|
|
123
|
-
<rect x={11} y={8} width={36} height={6} rx={1} fill={F2} />
|
|
124
|
-
<rect x={11} y={18} width={28} height={3} rx={1} fill={F1} />
|
|
125
|
-
<rect x={11} y={24} width={20} height={2.5} rx={1} fill={F1} opacity={0.7} />
|
|
126
|
-
</TemplateIcon>
|
|
127
|
-
),
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
name: 'statHighlight',
|
|
131
|
-
label: 'Stat Highlight',
|
|
132
|
-
description: 'Showcases a single key number or metric with supporting context.',
|
|
133
|
-
icon: (
|
|
134
|
-
<TemplateIcon>
|
|
135
|
-
<rect x={14} y={4} width={28} height={16} rx={2} fill={FA} />
|
|
136
|
-
<rect x={10} y={24} width={36} height={3.5} rx={1} fill={F2} />
|
|
137
|
-
<rect x={16} y={30} width={24} height={2.5} rx={1} fill={F1} />
|
|
138
|
-
</TemplateIcon>
|
|
139
|
-
),
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
name: 'quote',
|
|
143
|
-
label: 'Quote',
|
|
144
|
-
description: 'Displays a stylized pull quote with decorative marks and attribution.',
|
|
145
|
-
icon: (
|
|
146
|
-
<TemplateIcon>
|
|
147
|
-
<text
|
|
148
|
-
x={5}
|
|
149
|
-
y={18}
|
|
150
|
-
fontSize={18}
|
|
151
|
-
fill={FA}
|
|
152
|
-
fontFamily="serif"
|
|
153
|
-
fontWeight="bold"
|
|
154
|
-
opacity={0.7}
|
|
155
|
-
>
|
|
156
|
-
"
|
|
157
|
-
</text>
|
|
158
|
-
<rect x={16} y={8} width={36} height={4} rx={1} fill={F2} />
|
|
159
|
-
<rect x={16} y={15} width={32} height={4} rx={1} fill={F2} />
|
|
160
|
-
<rect x={16} y={22} width={24} height={4} rx={1} fill={F2} />
|
|
161
|
-
<rect x={16} y={31} width={18} height={2.5} rx={1} fill={F1} />
|
|
162
|
-
</TemplateIcon>
|
|
163
|
-
),
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
name: 'factCard',
|
|
167
|
-
label: 'Fact Card',
|
|
168
|
-
description: 'Presents a focused fact or insight with a labeled header and body text.',
|
|
169
|
-
icon: (
|
|
170
|
-
<TemplateIcon>
|
|
171
|
-
<rect x={4} y={4} width={20} height={6} rx={3} fill={FA} opacity={0.8} />
|
|
172
|
-
<rect x={4} y={14} width={48} height={5} rx={1} fill={F2} />
|
|
173
|
-
<rect x={4} y={22} width={44} height={3.5} rx={1} fill={F1} />
|
|
174
|
-
<rect x={4} y={28} width={36} height={3} rx={1} fill={F1} opacity={0.7} />
|
|
175
|
-
</TemplateIcon>
|
|
176
|
-
),
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
name: 'twoColumn',
|
|
180
|
-
label: 'Two Column',
|
|
181
|
-
description: 'Divides the slide into two equal side-by-side content columns.',
|
|
182
|
-
icon: (
|
|
183
|
-
<TemplateIcon>
|
|
184
|
-
<rect x={3} y={4} width={23} height={32} rx={2} fill={F1} opacity={0.4} />
|
|
185
|
-
<rect x={3} y={4} width={23} height={7} rx={2} fill={F2} opacity={0.6} />
|
|
186
|
-
<rect x={6} y={15} width={17} height={3} rx={1} fill={F1} />
|
|
187
|
-
<rect x={6} y={21} width={14} height={2.5} rx={1} fill={F1} opacity={0.7} />
|
|
188
|
-
<rect x={30} y={4} width={23} height={32} rx={2} fill={F1} opacity={0.4} />
|
|
189
|
-
<rect x={30} y={4} width={23} height={7} rx={2} fill={F2} opacity={0.6} />
|
|
190
|
-
<rect x={33} y={15} width={17} height={3} rx={1} fill={F1} />
|
|
191
|
-
<rect x={33} y={21} width={14} height={2.5} rx={1} fill={F1} opacity={0.7} />
|
|
192
|
-
</TemplateIcon>
|
|
193
|
-
),
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
name: 'dateEvent',
|
|
197
|
-
label: 'Date Event',
|
|
198
|
-
description: 'Highlights a date-based event or milestone with a prominent date display.',
|
|
199
|
-
icon: (
|
|
200
|
-
<TemplateIcon>
|
|
201
|
-
<rect x={3} y={4} width={18} height={18} rx={3} fill={FA} opacity={0.85} />
|
|
202
|
-
<rect x={6} y={8} width={12} height={2} rx={1} fill="white" opacity={0.7} />
|
|
203
|
-
<rect x={6} y={13} width={12} height={6} rx={1} fill="white" opacity={0.5} />
|
|
204
|
-
<rect x={25} y={6} width={27} height={5} rx={1} fill={F2} />
|
|
205
|
-
<rect x={25} y={15} width={22} height={3} rx={1} fill={F1} />
|
|
206
|
-
<rect x={25} y={21} width={16} height={2.5} rx={1} fill={F1} opacity={0.7} />
|
|
207
|
-
<rect x={3} y={27} width={50} height={2.5} rx={1} fill={F1} opacity={0.5} />
|
|
208
|
-
<rect x={3} y={32} width={40} height={2} rx={1} fill={F1} opacity={0.4} />
|
|
209
|
-
</TemplateIcon>
|
|
210
|
-
),
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
name: 'imageWithCaption',
|
|
214
|
-
label: 'Image with Caption',
|
|
215
|
-
description: 'Displays a full-bleed image with an optional caption below.',
|
|
216
|
-
icon: (
|
|
217
|
-
<TemplateIcon>
|
|
218
|
-
<rect x={3} y={3} width={50} height={28} rx={2} fill={F2} opacity={0.5} />
|
|
219
|
-
<line x1={3} y1={14} x2={53} y2={14} stroke="white" strokeWidth={0.5} opacity={0.3} />
|
|
220
|
-
<polygon points="22,10 22,20 32,15" fill="white" opacity={0.4} />
|
|
221
|
-
<rect x={10} y={35} width={36} height={2.5} rx={1} fill={F1} />
|
|
222
|
-
</TemplateIcon>
|
|
223
|
-
),
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
name: 'leftFeature',
|
|
227
|
-
label: 'Left Feature',
|
|
228
|
-
description: 'Image on the left, title and body text stacked on the right.',
|
|
229
|
-
icon: (
|
|
230
|
-
<TemplateIcon>
|
|
231
|
-
<rect x={3} y={4} width={24} height={32} rx={2} fill={F2} opacity={0.55} />
|
|
232
|
-
<polygon points="11,16 11,24 19,20" fill="white" opacity={0.5} />
|
|
233
|
-
<rect x={31} y={9} width={20} height={4} rx={1} fill={FA} />
|
|
234
|
-
<rect x={31} y={17} width={22} height={2.5} rx={1} fill={F1} />
|
|
235
|
-
<rect x={31} y={22} width={22} height={2.5} rx={1} fill={F1} opacity={0.75} />
|
|
236
|
-
<rect x={31} y={27} width={16} height={2.5} rx={1} fill={F1} opacity={0.6} />
|
|
237
|
-
</TemplateIcon>
|
|
238
|
-
),
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
name: 'rightFeature',
|
|
242
|
-
label: 'Right Feature',
|
|
243
|
-
description: 'Image on the right, title and body text stacked on the left.',
|
|
244
|
-
icon: (
|
|
245
|
-
<TemplateIcon>
|
|
246
|
-
<rect x={29} y={4} width={24} height={32} rx={2} fill={F2} opacity={0.55} />
|
|
247
|
-
<polygon points="37,16 37,24 45,20" fill="white" opacity={0.5} />
|
|
248
|
-
<rect x={3} y={9} width={20} height={4} rx={1} fill={FA} />
|
|
249
|
-
<rect x={3} y={17} width={22} height={2.5} rx={1} fill={F1} />
|
|
250
|
-
<rect x={3} y={22} width={22} height={2.5} rx={1} fill={F1} opacity={0.75} />
|
|
251
|
-
<rect x={3} y={27} width={16} height={2.5} rx={1} fill={F1} opacity={0.6} />
|
|
252
|
-
</TemplateIcon>
|
|
253
|
-
),
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
name: 'map',
|
|
257
|
-
label: 'Map',
|
|
258
|
-
description: 'Embeds an interactive map centered on a geographic location.',
|
|
259
|
-
icon: (
|
|
260
|
-
<TemplateIcon>
|
|
261
|
-
<rect x={3} y={3} width={50} height={34} rx={2} fill={F1} opacity={0.3} />
|
|
262
|
-
<line x1={3} y1={13} x2={53} y2={13} stroke={F1} strokeWidth={1} />
|
|
263
|
-
<line x1={3} y1={23} x2={53} y2={23} stroke={F1} strokeWidth={1} />
|
|
264
|
-
<line x1={18} y1={3} x2={18} y2={37} stroke={F1} strokeWidth={1} />
|
|
265
|
-
<line x1={38} y1={3} x2={38} y2={37} stroke={F1} strokeWidth={1} />
|
|
266
|
-
<circle cx={28} cy={18} r={4} fill={FA} opacity={0.8} />
|
|
267
|
-
<line x1={28} y1={22} x2={28} y2={26} stroke={FA} strokeWidth={1.5} opacity={0.6} />
|
|
268
|
-
</TemplateIcon>
|
|
269
|
-
),
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
name: 'fullBleedQuote',
|
|
273
|
-
label: 'Full Bleed Quote',
|
|
274
|
-
description: 'A full-width quote that spans the entire slide for maximum impact.',
|
|
275
|
-
icon: (
|
|
276
|
-
<TemplateIcon>
|
|
277
|
-
<rect x={4} y={4} width={48} height={32} rx={2} fill={F2} opacity={0.2} />
|
|
278
|
-
<text
|
|
279
|
-
x={5}
|
|
280
|
-
y={15}
|
|
281
|
-
fontSize={16}
|
|
282
|
-
fill={FA}
|
|
283
|
-
fontFamily="serif"
|
|
284
|
-
fontWeight="bold"
|
|
285
|
-
opacity={0.8}
|
|
286
|
-
>
|
|
287
|
-
"
|
|
288
|
-
</text>
|
|
289
|
-
<rect x={4} y={14} width={48} height={5} rx={1} fill={F2} />
|
|
290
|
-
<rect x={4} y={22} width={44} height={5} rx={1} fill={F2} />
|
|
291
|
-
<rect x={4} y={30} width={30} height={4} rx={1} fill={F2} opacity={0.7} />
|
|
292
|
-
</TemplateIcon>
|
|
293
|
-
),
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
name: 'list',
|
|
297
|
-
label: 'List',
|
|
298
|
-
description: 'Renders a bulleted or numbered list in a clean, card-style layout.',
|
|
299
|
-
icon: (
|
|
300
|
-
<TemplateIcon>
|
|
301
|
-
<rect x={4} y={5} width={6} height={5} rx={3} fill={FA} opacity={0.8} />
|
|
302
|
-
<rect x={14} y={6} width={38} height={4} rx={1} fill={F2} />
|
|
303
|
-
<rect x={4} y={17} width={6} height={5} rx={3} fill={FA} opacity={0.8} />
|
|
304
|
-
<rect x={14} y={18} width={34} height={4} rx={1} fill={F2} />
|
|
305
|
-
<rect x={4} y={29} width={6} height={5} rx={3} fill={FA} opacity={0.8} />
|
|
306
|
-
<rect x={14} y={30} width={36} height={4} rx={1} fill={F2} />
|
|
307
|
-
</TemplateIcon>
|
|
308
|
-
),
|
|
309
|
-
},
|
|
310
|
-
{
|
|
311
|
-
name: 'photoGrid',
|
|
312
|
-
label: 'Photo Grid',
|
|
313
|
-
description: 'Arranges multiple photos in a 2×2 or 3×3 mosaic grid.',
|
|
314
|
-
icon: (
|
|
315
|
-
<TemplateIcon>
|
|
316
|
-
<rect x={3} y={3} width={23} height={16} rx={1.5} fill={F2} opacity={0.55} />
|
|
317
|
-
<rect x={30} y={3} width={23} height={16} rx={1.5} fill={F2} opacity={0.7} />
|
|
318
|
-
<rect x={3} y={22} width={23} height={16} rx={1.5} fill={F2} opacity={0.8} />
|
|
319
|
-
<rect x={30} y={22} width={23} height={16} rx={1.5} fill={F2} opacity={0.5} />
|
|
320
|
-
</TemplateIcon>
|
|
321
|
-
),
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
name: 'definitionCard',
|
|
325
|
-
label: 'Definition Card',
|
|
326
|
-
description: 'Shows a term and its definition in a structured, dictionary-style card.',
|
|
327
|
-
icon: (
|
|
328
|
-
<TemplateIcon>
|
|
329
|
-
<rect x={4} y={6} width={32} height={6} rx={1} fill={FA} opacity={0.8} />
|
|
330
|
-
<rect x={4} y={17} width={48} height={3.5} rx={1} fill={F1} />
|
|
331
|
-
<rect x={4} y={23} width={44} height={3} rx={1} fill={F1} opacity={0.8} />
|
|
332
|
-
<rect x={4} y={29} width={36} height={3} rx={1} fill={F1} opacity={0.6} />
|
|
333
|
-
</TemplateIcon>
|
|
334
|
-
),
|
|
335
|
-
},
|
|
336
|
-
{
|
|
337
|
-
name: 'comparisonBar',
|
|
338
|
-
label: 'Comparison Bar',
|
|
339
|
-
description: 'Visualizes two or more values side-by-side with labeled horizontal bars.',
|
|
340
|
-
icon: (
|
|
341
|
-
<TemplateIcon>
|
|
342
|
-
<rect x={4} y={5} width={14} height={3} rx={1} fill={F1} />
|
|
343
|
-
<rect x={20} y={4} width={32} height={5} rx={1} fill={FA} opacity={0.85} />
|
|
344
|
-
<rect x={4} y={16} width={14} height={3} rx={1} fill={F1} />
|
|
345
|
-
<rect x={20} y={15} width={22} height={5} rx={1} fill={F2} opacity={0.7} />
|
|
346
|
-
<rect x={4} y={27} width={14} height={3} rx={1} fill={F1} />
|
|
347
|
-
<rect x={20} y={26} width={28} height={5} rx={1} fill={F2} opacity={0.5} />
|
|
348
|
-
</TemplateIcon>
|
|
349
|
-
),
|
|
350
|
-
},
|
|
351
|
-
{
|
|
352
|
-
name: 'pullQuote',
|
|
353
|
-
label: 'Pull Quote',
|
|
354
|
-
description: 'A stylized pull quote with large decorative marks and centered text.',
|
|
355
|
-
icon: (
|
|
356
|
-
<TemplateIcon>
|
|
357
|
-
<text x={3} y={20} fontSize={26} fill={FA} fontFamily="serif" opacity={0.5}>
|
|
358
|
-
"
|
|
359
|
-
</text>
|
|
360
|
-
<rect x={16} y={7} width={36} height={4.5} rx={1} fill={F2} />
|
|
361
|
-
<rect x={16} y={15} width={34} height={4.5} rx={1} fill={F2} />
|
|
362
|
-
<rect x={16} y={23} width={28} height={4.5} rx={1} fill={F2} />
|
|
363
|
-
<rect x={32} y={31} width={20} height={3} rx={1} fill={F1} />
|
|
364
|
-
<text x={44} y={42} fontSize={26} fill={FA} fontFamily="serif" opacity={0.3}>
|
|
365
|
-
"
|
|
366
|
-
</text>
|
|
367
|
-
</TemplateIcon>
|
|
368
|
-
),
|
|
369
|
-
},
|
|
370
|
-
{
|
|
371
|
-
name: 'videoWithCaption',
|
|
372
|
-
label: 'Video with Caption',
|
|
373
|
-
description: 'Embeds a video player with an optional caption below.',
|
|
374
|
-
icon: (
|
|
375
|
-
<TemplateIcon>
|
|
376
|
-
<rect x={3} y={3} width={50} height={28} rx={2} fill={F1} opacity={0.4} />
|
|
377
|
-
<rect x={3} y={3} width={50} height={28} rx={2} fill={F2} opacity={0.25} />
|
|
378
|
-
<circle cx={28} cy={17} r={8} fill={FA} opacity={0.7} />
|
|
379
|
-
<polygon points="25,13 25,21 33,17" fill="white" />
|
|
380
|
-
<rect x={10} y={35} width={36} height={2.5} rx={1} fill={F1} />
|
|
381
|
-
</TemplateIcon>
|
|
382
|
-
),
|
|
383
|
-
},
|
|
384
|
-
{
|
|
385
|
-
name: 'videoPullQuote',
|
|
386
|
-
label: 'Video Pull Quote',
|
|
387
|
-
description: 'Combines a video panel with a highlighted pull quote side-by-side.',
|
|
388
|
-
icon: (
|
|
389
|
-
<TemplateIcon>
|
|
390
|
-
<rect x={3} y={4} width={23} height={32} rx={2} fill={F2} opacity={0.35} />
|
|
391
|
-
<circle cx={14.5} cy={20} r={6} fill={FA} opacity={0.65} />
|
|
392
|
-
<polygon points="12,17 12,23 18,20" fill="white" />
|
|
393
|
-
<rect x={30} y={4} width={23} height={32} rx={2} fill={F1} opacity={0.3} />
|
|
394
|
-
<text x={32} y={16} fontSize={12} fill={FA} fontFamily="serif" opacity={0.6}>
|
|
395
|
-
"
|
|
396
|
-
</text>
|
|
397
|
-
<rect x={30} y={17} width={20} height={3.5} rx={1} fill={F2} />
|
|
398
|
-
<rect x={30} y={23} width={18} height={3} rx={1} fill={F1} />
|
|
399
|
-
<rect x={30} y={29} width={14} height={2.5} rx={1} fill={F1} opacity={0.7} />
|
|
400
|
-
</TemplateIcon>
|
|
401
|
-
),
|
|
402
|
-
},
|
|
403
|
-
{
|
|
404
|
-
name: 'dataTable',
|
|
405
|
-
label: 'Data Table',
|
|
406
|
-
description: 'Renders tabular data in a clean, styled table with a header row.',
|
|
407
|
-
icon: (
|
|
408
|
-
<TemplateIcon>
|
|
409
|
-
<rect x={3} y={3} width={50} height={8} rx={1.5} fill={FA} opacity={0.7} />
|
|
410
|
-
<rect x={3} y={13} width={50} height={6} rx={1} fill={F1} opacity={0.5} />
|
|
411
|
-
<rect x={3} y={21} width={50} height={6} rx={1} fill={F1} opacity={0.35} />
|
|
412
|
-
<rect x={3} y={29} width={50} height={6} rx={1} fill={F1} opacity={0.5} />
|
|
413
|
-
<line x1={20} y1={3} x2={20} y2={35} stroke="white" strokeWidth={1} opacity={0.4} />
|
|
414
|
-
<line x1={37} y1={3} x2={37} y2={35} stroke="white" strokeWidth={1} opacity={0.4} />
|
|
415
|
-
</TemplateIcon>
|
|
416
|
-
),
|
|
417
|
-
},
|
|
418
|
-
{
|
|
419
|
-
name: 'diagram',
|
|
420
|
-
label: 'Diagram',
|
|
421
|
-
description:
|
|
422
|
-
'Renders sub-headings as connected nodes — edit visually as a node-and-edge diagram.',
|
|
423
|
-
icon: (
|
|
424
|
-
<TemplateIcon>
|
|
425
|
-
<rect x={4} y={6} width={16} height={10} rx={2} fill={FA} opacity={0.85} />
|
|
426
|
-
<rect x={36} y={6} width={16} height={10} rx={2} fill={F2} opacity={0.8} />
|
|
427
|
-
<rect x={20} y={24} width={16} height={10} rx={2} fill={F2} opacity={0.8} />
|
|
428
|
-
<path d="M 20 11 L 36 11" stroke={FA} strokeWidth={1.5} fill="none" opacity={0.7} />
|
|
429
|
-
<path d="M 36 11 L 32 8.5 L 32 13.5 Z" fill={FA} opacity={0.7} />
|
|
430
|
-
<path
|
|
431
|
-
d="M 12 16 C 12 22, 24 22, 24 24"
|
|
432
|
-
stroke={FA}
|
|
433
|
-
strokeWidth={1.5}
|
|
434
|
-
fill="none"
|
|
435
|
-
opacity={0.7}
|
|
436
|
-
/>
|
|
437
|
-
<path
|
|
438
|
-
d="M 44 16 C 44 22, 32 22, 32 24"
|
|
439
|
-
stroke={FA}
|
|
440
|
-
strokeWidth={1.5}
|
|
441
|
-
fill="none"
|
|
442
|
-
opacity={0.7}
|
|
443
|
-
/>
|
|
444
|
-
</TemplateIcon>
|
|
445
|
-
),
|
|
446
|
-
},
|
|
447
|
-
{
|
|
448
|
-
name: 'tree',
|
|
449
|
-
label: 'Tree',
|
|
450
|
-
description:
|
|
451
|
-
'Renders an ASCII file-tree / outline fence as a filesystem-style treeview — edit as an outline.',
|
|
452
|
-
icon: (
|
|
453
|
-
<TemplateIcon>
|
|
454
|
-
<rect x={6} y={5} width={16} height={7} rx={1.5} fill={FA} opacity={0.85} />
|
|
455
|
-
<path
|
|
456
|
-
d="M 12 12 L 12 34 M 12 20 L 22 20 M 12 34 L 22 34"
|
|
457
|
-
stroke={F1}
|
|
458
|
-
strokeWidth={1.5}
|
|
459
|
-
fill="none"
|
|
460
|
-
opacity={0.7}
|
|
461
|
-
/>
|
|
462
|
-
<rect x={24} y={16} width={14} height={7} rx={1.5} fill={F2} opacity={0.8} />
|
|
463
|
-
<rect x={24} y={30} width={14} height={7} rx={1.5} fill={F2} opacity={0.8} />
|
|
464
|
-
<rect x={26} y={2} width={14} height={7} rx={1.5} fill={F2} opacity={0.6} />
|
|
465
|
-
</TemplateIcon>
|
|
466
|
-
),
|
|
467
|
-
},
|
|
468
|
-
{
|
|
469
|
-
name: 'timeline',
|
|
470
|
-
label: 'Timeline',
|
|
471
|
-
description:
|
|
472
|
-
'Plots events across one or more horizontal tracks with callouts and optional branching links.',
|
|
473
|
-
icon: (
|
|
474
|
-
<TemplateIcon>
|
|
475
|
-
<path d="M 5 21 L 51 21" stroke={F1} strokeWidth={1.8} fill="none" />
|
|
476
|
-
<path d="M 47 18 L 52 21 L 47 24" stroke={F1} strokeWidth={1.5} fill="none" />
|
|
477
|
-
<circle cx={13} cy={21} r={3} fill={FA} />
|
|
478
|
-
<circle cx={29} cy={21} r={3} fill={F2} />
|
|
479
|
-
<circle cx={44} cy={21} r={3} fill={FA} />
|
|
480
|
-
<path d="M 13 18 L 13 10 M 29 24 L 29 32 M 44 18 L 44 8" stroke={F1} strokeWidth={1} />
|
|
481
|
-
<rect x={7} y={5} width={12} height={3} rx={1} fill={F2} opacity={0.8} />
|
|
482
|
-
<rect x={23} y={33} width={12} height={3} rx={1} fill={F2} opacity={0.8} />
|
|
483
|
-
<rect x={38} y={3} width={12} height={3} rx={1} fill={F2} opacity={0.8} />
|
|
484
|
-
</TemplateIcon>
|
|
485
|
-
),
|
|
486
|
-
},
|
|
487
|
-
{
|
|
488
|
-
name: 'layout',
|
|
489
|
-
label: 'Layout',
|
|
490
|
-
description:
|
|
491
|
-
"Free-form 2D canvas — drag layers into place. Use for one-off block layouts that don't fit a template.",
|
|
492
|
-
icon: (
|
|
493
|
-
<TemplateIcon>
|
|
494
|
-
<rect
|
|
495
|
-
x={3}
|
|
496
|
-
y={3}
|
|
497
|
-
width={50}
|
|
498
|
-
height={34}
|
|
499
|
-
rx={2}
|
|
500
|
-
fill="none"
|
|
501
|
-
stroke={F1}
|
|
502
|
-
strokeWidth={1}
|
|
503
|
-
strokeDasharray="3 2"
|
|
504
|
-
/>
|
|
505
|
-
<rect x={7} y={7} width={20} height={12} rx={1.5} fill={FA} opacity={0.85} />
|
|
506
|
-
<rect x={30} y={7} width={20} height={26} rx={1.5} fill={F2} opacity={0.7} />
|
|
507
|
-
<rect x={7} y={22} width={20} height={11} rx={1.5} fill={F1} opacity={0.7} />
|
|
508
|
-
</TemplateIcon>
|
|
509
|
-
),
|
|
510
|
-
},
|
|
511
|
-
{
|
|
512
|
-
name: 'drawing',
|
|
513
|
-
label: 'Drawing',
|
|
514
|
-
description: 'Free-form sketches — draw shapes, paths, and text directly on a 2D surface.',
|
|
515
|
-
icon: (
|
|
516
|
-
<TemplateIcon>
|
|
517
|
-
<rect x={3} y={3} width={50} height={34} rx={2} fill="none" stroke={F1} strokeWidth={1} />
|
|
518
|
-
<path
|
|
519
|
-
d="M 8 28 C 14 12, 26 14, 30 22 S 44 32, 50 14"
|
|
520
|
-
stroke={FA}
|
|
521
|
-
strokeWidth={2}
|
|
522
|
-
fill="none"
|
|
523
|
-
opacity={0.85}
|
|
524
|
-
strokeLinecap="round"
|
|
525
|
-
/>
|
|
526
|
-
<circle cx={10} cy={10} r={2.5} fill={F2} />
|
|
527
|
-
<rect x={40} y={28} width={8} height={6} rx={1} fill={F2} opacity={0.7} />
|
|
528
|
-
</TemplateIcon>
|
|
529
|
-
),
|
|
530
|
-
},
|
|
531
|
-
];
|
|
532
|
-
|
|
533
|
-
/**
|
|
534
|
-
* Canonical template names known to the picker, in the order they
|
|
535
|
-
* appear in the gallery. Exported so callers can hand the same list to
|
|
536
|
-
* `recommendTemplatesForBlock()` and stay in sync with the visual
|
|
537
|
-
* order.
|
|
538
|
-
*/
|
|
539
|
-
export const TEMPLATE_NAMES: readonly string[] = TEMPLATE_ENTRIES.map((e) => e.name);
|
|
540
|
-
|
|
541
|
-
/**
|
|
542
|
-
* Convert a camelCase template id to a human-readable label. Accepts both
|
|
543
|
-
* the canonical short ids (`title`, `quote`, `map`, `list`) and the
|
|
544
|
-
* legacy long ones (`titleBlock`, `quoteBlock`, `mapBlock`, `listBlock`)
|
|
545
|
-
* so existing documents keep showing a friendly label without first
|
|
546
|
-
* normalizing their annotations.
|
|
547
|
-
*/
|
|
548
|
-
// eslint-disable-next-line react-refresh/only-export-components
|
|
549
|
-
export function templateLabel(
|
|
550
|
-
name: string,
|
|
551
|
-
customTemplates?: readonly CustomTemplateDefinition[],
|
|
552
|
-
): string {
|
|
553
|
-
if (!name) return '— none —';
|
|
554
|
-
// `resolveTemplateName` + `TEMPLATE_METADATA` are the canonical source of
|
|
555
|
-
// truth in core; both legacy long ids (`titleBlock`) and short ids resolve
|
|
556
|
-
// through it, so the picker never has to maintain its own alias/label table.
|
|
557
|
-
const resolved = resolveTemplateName(name);
|
|
558
|
-
const meta = TEMPLATE_METADATA[resolved];
|
|
559
|
-
if (meta) return meta.label;
|
|
560
|
-
const custom = customTemplates?.find((t) => t.name === resolved);
|
|
561
|
-
if (custom) return custom.label;
|
|
562
|
-
// Fallback: split camelCase
|
|
563
|
-
return resolved.replace(/([A-Z])/g, ' $1').replace(/^./, (s) => s.toUpperCase());
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
// ── Component ─────────────────────────────────────────────────────
|
|
567
|
-
|
|
568
|
-
export interface TemplatePickerProps {
|
|
569
|
-
value: string;
|
|
570
|
-
onChange: (name: string) => void;
|
|
571
|
-
/** Active editor chrome theme, used by the portaled dialog. */
|
|
572
|
-
colorScheme?: 'light' | 'dark';
|
|
573
|
-
/** When true, shows only the trigger button (no popover) — used in the overflow menu. */
|
|
574
|
-
compact?: boolean;
|
|
575
|
-
/**
|
|
576
|
-
* Template names to surface in a "Recommended for this block" section
|
|
577
|
-
* above the full list. When omitted or empty, the gallery renders as a
|
|
578
|
-
* single ungrouped grid (legacy behavior).
|
|
579
|
-
*/
|
|
580
|
-
recommended?: readonly string[];
|
|
581
|
-
/**
|
|
582
|
-
* Optional callback fired when the user clicks the "+ New custom
|
|
583
|
-
* template" card pinned at the top of the gallery. The host wires this
|
|
584
|
-
* to open the modal `TemplateDesigner`. When omitted, the card is
|
|
585
|
-
* hidden.
|
|
586
|
-
*/
|
|
587
|
-
onOpenDesigner?: () => void;
|
|
588
|
-
/**
|
|
589
|
-
* Active block content used to render live template thumbnails. When omitted,
|
|
590
|
-
* or when a template cannot be meaningfully derived from the block, cards use
|
|
591
|
-
* their static wireframe icons.
|
|
592
|
-
*/
|
|
593
|
-
previewSource?: TemplatePreviewSource;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
export function TemplatePicker({
|
|
597
|
-
value,
|
|
598
|
-
onChange,
|
|
599
|
-
colorScheme = 'light',
|
|
600
|
-
compact,
|
|
601
|
-
recommended,
|
|
602
|
-
onOpenDesigner,
|
|
603
|
-
previewSource,
|
|
604
|
-
}: TemplatePickerProps) {
|
|
605
|
-
const [open, setOpen] = useState(false);
|
|
606
|
-
const [dialogStyle, setDialogStyle] = useState<React.CSSProperties>({});
|
|
607
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
|
608
|
-
const triggerRef = useRef<HTMLButtonElement>(null);
|
|
609
|
-
const dialogRef = useRef<HTMLDivElement>(null);
|
|
610
|
-
const dialogId = `${TEMPLATE_GALLERY_DIALOG_ID}-${useId().replace(/:/g, '')}`;
|
|
611
|
-
|
|
612
|
-
const updateDialogBounds = () => {
|
|
613
|
-
if (!triggerRef.current) return;
|
|
614
|
-
setDialogStyle(computeDialogStyle(triggerRef.current));
|
|
615
|
-
};
|
|
616
|
-
|
|
617
|
-
const handleOpen = () => {
|
|
618
|
-
updateDialogBounds();
|
|
619
|
-
setOpen((v) => !v);
|
|
620
|
-
};
|
|
621
|
-
|
|
622
|
-
// Close on outside click
|
|
623
|
-
useEffect(() => {
|
|
624
|
-
if (!open) return;
|
|
625
|
-
const handler = (e: MouseEvent) => {
|
|
626
|
-
const target = e.target as Node;
|
|
627
|
-
const inTrigger = triggerRef.current?.contains(target);
|
|
628
|
-
const inDialog = dialogRef.current?.contains(target);
|
|
629
|
-
if (!inTrigger && !inDialog) {
|
|
630
|
-
setOpen(false);
|
|
631
|
-
}
|
|
632
|
-
};
|
|
633
|
-
document.addEventListener('mousedown', handler);
|
|
634
|
-
return () => document.removeEventListener('mousedown', handler);
|
|
635
|
-
}, [open]);
|
|
636
|
-
|
|
637
|
-
// Close on Escape
|
|
638
|
-
useEffect(() => {
|
|
639
|
-
if (!open) return;
|
|
640
|
-
const handler = (e: KeyboardEvent) => {
|
|
641
|
-
if (e.key === 'Escape') setOpen(false);
|
|
642
|
-
};
|
|
643
|
-
document.addEventListener('keydown', handler);
|
|
644
|
-
return () => document.removeEventListener('keydown', handler);
|
|
645
|
-
}, [open]);
|
|
646
|
-
|
|
647
|
-
// Reposition on scroll/resize while open
|
|
648
|
-
useEffect(() => {
|
|
649
|
-
if (!open) return;
|
|
650
|
-
requestAnimationFrame(updateDialogBounds);
|
|
651
|
-
const handler = () => updateDialogBounds();
|
|
652
|
-
window.addEventListener('scroll', handler, true);
|
|
653
|
-
window.addEventListener('resize', handler);
|
|
654
|
-
return () => {
|
|
655
|
-
window.removeEventListener('scroll', handler, true);
|
|
656
|
-
window.removeEventListener('resize', handler);
|
|
657
|
-
};
|
|
658
|
-
}, [open]);
|
|
659
|
-
|
|
660
|
-
const handleSelect = (name: string) => {
|
|
661
|
-
onChange(name);
|
|
662
|
-
setOpen(false);
|
|
663
|
-
};
|
|
664
|
-
|
|
665
|
-
const currentLabel = templateLabel(value);
|
|
666
|
-
const currentEntry: TemplateEntry =
|
|
667
|
-
(value && TEMPLATE_ENTRIES.find((e) => e.name === value)) || NONE_ENTRY;
|
|
668
|
-
const dialogTitle = templateDialogTitle(previewSource);
|
|
669
|
-
|
|
670
|
-
if (compact) {
|
|
671
|
-
// In overflow menu, use a simple select for space efficiency
|
|
672
|
-
const all: TemplateEntry[] = [NONE_ENTRY, ...TEMPLATE_ENTRIES];
|
|
673
|
-
return (
|
|
674
|
-
<select
|
|
675
|
-
className="squisq-template-picker-select"
|
|
676
|
-
value={value}
|
|
677
|
-
onChange={(e) => onChange(e.target.value)}
|
|
678
|
-
>
|
|
679
|
-
{all.map((e) => (
|
|
680
|
-
<option key={e.name} value={e.name}>
|
|
681
|
-
{e.label}
|
|
682
|
-
</option>
|
|
683
|
-
))}
|
|
684
|
-
</select>
|
|
685
|
-
);
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
const gallery = open
|
|
689
|
-
? createPortal(
|
|
690
|
-
<TemplateGalleryDialog
|
|
691
|
-
dialogRef={dialogRef}
|
|
692
|
-
dialogId={dialogId}
|
|
693
|
-
title={dialogTitle}
|
|
694
|
-
colorScheme={colorScheme}
|
|
695
|
-
style={dialogStyle}
|
|
696
|
-
onClose={() => setOpen(false)}
|
|
697
|
-
>
|
|
698
|
-
<TemplateGalleryBody
|
|
699
|
-
value={value}
|
|
700
|
-
onSelect={handleSelect}
|
|
701
|
-
style={{}}
|
|
702
|
-
recommended={recommended}
|
|
703
|
-
onOpenDesigner={onOpenDesigner}
|
|
704
|
-
previewSource={previewSource}
|
|
705
|
-
/>
|
|
706
|
-
</TemplateGalleryDialog>,
|
|
707
|
-
document.body,
|
|
708
|
-
)
|
|
709
|
-
: null;
|
|
710
|
-
|
|
711
|
-
return (
|
|
712
|
-
<div className="squisq-template-picker-popover-host" ref={containerRef}>
|
|
713
|
-
<button
|
|
714
|
-
ref={triggerRef}
|
|
715
|
-
type="button"
|
|
716
|
-
className={`squisq-template-picker-trigger${open ? ' squisq-template-picker-trigger--open' : ''}`}
|
|
717
|
-
onClick={handleOpen}
|
|
718
|
-
aria-haspopup="dialog"
|
|
719
|
-
aria-expanded={open}
|
|
720
|
-
aria-controls={open ? dialogId : undefined}
|
|
721
|
-
title="Choose block type"
|
|
722
|
-
>
|
|
723
|
-
<span className="squisq-template-picker-trigger-label">Block:</span>
|
|
724
|
-
<span className="squisq-template-picker-trigger-thumb" aria-hidden="true">
|
|
725
|
-
{currentEntry.icon}
|
|
726
|
-
</span>
|
|
727
|
-
<span className="squisq-template-picker-trigger-value">
|
|
728
|
-
{value ? currentLabel : '(No visual)'}
|
|
729
|
-
</span>
|
|
730
|
-
<svg
|
|
731
|
-
className="squisq-template-picker-trigger-caret"
|
|
732
|
-
width="10"
|
|
733
|
-
height="10"
|
|
734
|
-
viewBox="0 0 10 10"
|
|
735
|
-
fill="currentColor"
|
|
736
|
-
aria-hidden="true"
|
|
737
|
-
>
|
|
738
|
-
<path
|
|
739
|
-
d="M2 3.5l3 3 3-3"
|
|
740
|
-
stroke="currentColor"
|
|
741
|
-
strokeWidth="1.5"
|
|
742
|
-
strokeLinecap="round"
|
|
743
|
-
fill="none"
|
|
744
|
-
/>
|
|
745
|
-
</svg>
|
|
746
|
-
</button>
|
|
747
|
-
{gallery}
|
|
748
|
-
</div>
|
|
749
|
-
);
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
// ── Reusable gallery body ──────────────────────────────────────────
|
|
753
|
-
|
|
754
|
-
function TemplateGalleryDialog({
|
|
755
|
-
dialogRef,
|
|
756
|
-
dialogId,
|
|
757
|
-
children,
|
|
758
|
-
title,
|
|
759
|
-
colorScheme,
|
|
760
|
-
style,
|
|
761
|
-
onClose,
|
|
762
|
-
}: {
|
|
763
|
-
dialogRef: React.RefObject<HTMLDivElement>;
|
|
764
|
-
dialogId: string;
|
|
765
|
-
children: React.ReactNode;
|
|
766
|
-
title: string;
|
|
767
|
-
colorScheme: 'light' | 'dark';
|
|
768
|
-
style: React.CSSProperties;
|
|
769
|
-
onClose: () => void;
|
|
770
|
-
}) {
|
|
771
|
-
return (
|
|
772
|
-
<div
|
|
773
|
-
ref={dialogRef}
|
|
774
|
-
id={dialogId}
|
|
775
|
-
className="squisq-template-gallery-dialog"
|
|
776
|
-
data-theme={colorScheme}
|
|
777
|
-
style={style}
|
|
778
|
-
onMouseDown={(event) => {
|
|
779
|
-
if (event.target === event.currentTarget) onClose();
|
|
780
|
-
}}
|
|
781
|
-
>
|
|
782
|
-
<div
|
|
783
|
-
className="squisq-template-gallery-dialog-panel"
|
|
784
|
-
role="dialog"
|
|
785
|
-
aria-modal="true"
|
|
786
|
-
aria-label={title}
|
|
787
|
-
>
|
|
788
|
-
<div className="squisq-template-gallery-dialog-header">
|
|
789
|
-
<h2 className="squisq-template-gallery-dialog-title">{title}</h2>
|
|
790
|
-
<button
|
|
791
|
-
type="button"
|
|
792
|
-
className="squisq-template-gallery-dialog-close"
|
|
793
|
-
onClick={onClose}
|
|
794
|
-
aria-label="Close block type picker"
|
|
795
|
-
>
|
|
796
|
-
<svg width="14" height="14" viewBox="0 0 14 14" aria-hidden="true">
|
|
797
|
-
<path
|
|
798
|
-
d="M3.2 3.2l7.6 7.6M10.8 3.2l-7.6 7.6"
|
|
799
|
-
stroke="currentColor"
|
|
800
|
-
strokeWidth="1.7"
|
|
801
|
-
strokeLinecap="round"
|
|
802
|
-
/>
|
|
803
|
-
</svg>
|
|
804
|
-
</button>
|
|
805
|
-
</div>
|
|
806
|
-
<div className="squisq-template-gallery-dialog-body">{children}</div>
|
|
807
|
-
</div>
|
|
808
|
-
</div>
|
|
809
|
-
);
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
/**
|
|
813
|
-
* The dialog/grid markup shared by the toolbar `TemplatePicker` and the
|
|
814
|
-
* inline `TemplateBadgeMenu`. Renders all template cards plus the
|
|
815
|
-
* "(none)" option; no positioning logic — callers supply `style` (typically
|
|
816
|
-
* a `position: fixed` rect from `getBoundingClientRect()`).
|
|
817
|
-
*/
|
|
818
|
-
function TemplateCard({
|
|
819
|
-
entry,
|
|
820
|
-
value,
|
|
821
|
-
onSelect,
|
|
822
|
-
previewSource,
|
|
823
|
-
}: {
|
|
824
|
-
entry: TemplateEntry;
|
|
825
|
-
value: string;
|
|
826
|
-
onSelect: (name: string) => void;
|
|
827
|
-
previewSource?: TemplatePreviewSource;
|
|
828
|
-
}) {
|
|
829
|
-
return (
|
|
830
|
-
<button
|
|
831
|
-
type="button"
|
|
832
|
-
role="option"
|
|
833
|
-
aria-selected={value === entry.name}
|
|
834
|
-
className={`squisq-template-gallery-card${value === entry.name ? ' squisq-template-gallery-card--selected' : ''}`}
|
|
835
|
-
onClick={() => onSelect(entry.name)}
|
|
836
|
-
title={entry.description}
|
|
837
|
-
>
|
|
838
|
-
<div className="squisq-template-gallery-card-icon">
|
|
839
|
-
<TemplateContentPreview
|
|
840
|
-
templateName={entry.name}
|
|
841
|
-
source={previewSource}
|
|
842
|
-
fallback={entry.icon}
|
|
843
|
-
/>
|
|
844
|
-
</div>
|
|
845
|
-
<div className="squisq-template-gallery-card-body">
|
|
846
|
-
<span className="squisq-template-gallery-card-name">{entry.label}</span>
|
|
847
|
-
<span className="squisq-template-gallery-card-desc">{entry.description}</span>
|
|
848
|
-
</div>
|
|
849
|
-
</button>
|
|
850
|
-
);
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
function splitBlockTypeEntriesByContent(
|
|
854
|
-
entries: readonly TemplateEntry[],
|
|
855
|
-
previewSource?: TemplatePreviewSource,
|
|
856
|
-
): { blockTypeEntries: TemplateEntry[]; contentNeededEntries: TemplateEntry[] } {
|
|
857
|
-
if (!previewSource) return { blockTypeEntries: [...entries], contentNeededEntries: [] };
|
|
858
|
-
|
|
859
|
-
const blockTypeEntries: TemplateEntry[] = [];
|
|
860
|
-
const contentNeededEntries: TemplateEntry[] = [];
|
|
861
|
-
|
|
862
|
-
for (const entry of entries) {
|
|
863
|
-
const result = resolveTemplateContentPreviewResult(entry.name, previewSource);
|
|
864
|
-
if (result.warning) contentNeededEntries.push(entry);
|
|
865
|
-
else blockTypeEntries.push(entry);
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
return { blockTypeEntries, contentNeededEntries };
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
function TemplateGalleryBody({
|
|
872
|
-
value,
|
|
873
|
-
onSelect,
|
|
874
|
-
style,
|
|
875
|
-
recommended,
|
|
876
|
-
onOpenDesigner,
|
|
877
|
-
previewSource,
|
|
878
|
-
}: {
|
|
879
|
-
value: string;
|
|
880
|
-
onSelect: (name: string) => void;
|
|
881
|
-
style: React.CSSProperties;
|
|
882
|
-
recommended?: readonly string[];
|
|
883
|
-
onOpenDesigner?: () => void;
|
|
884
|
-
previewSource?: TemplatePreviewSource;
|
|
885
|
-
}) {
|
|
886
|
-
const galleryId = useTemplateGalleryPortalId();
|
|
887
|
-
const [query, setQuery] = useState('');
|
|
888
|
-
const searchRef = useRef<HTMLInputElement>(null);
|
|
889
|
-
// Pull merged doc + library templates from the surrounding context.
|
|
890
|
-
// When the host hasn't wrapped the editor in a CustomTemplateProvider
|
|
891
|
-
// we silently degrade to "no custom templates", which preserves the
|
|
892
|
-
// legacy behaviour for any caller that hasn't opted in.
|
|
893
|
-
const customCtx = useCustomTemplates();
|
|
894
|
-
const customTemplates = useMemo(() => customCtx?.allTemplates ?? [], [customCtx]);
|
|
895
|
-
|
|
896
|
-
// Auto-focus the search input when the gallery mounts so the user can
|
|
897
|
-
// start typing immediately to filter templates.
|
|
898
|
-
useEffect(() => {
|
|
899
|
-
searchRef.current?.focus();
|
|
900
|
-
}, []);
|
|
901
|
-
|
|
902
|
-
const trimmedQuery = query.trim().toLowerCase();
|
|
903
|
-
const hasQuery = trimmedQuery.length > 0;
|
|
904
|
-
|
|
905
|
-
// For search results we match both built-in entries and custom
|
|
906
|
-
// templates by label/name/description so the user can find a custom
|
|
907
|
-
// template by typing its name.
|
|
908
|
-
const matches = useMemo(() => {
|
|
909
|
-
if (!hasQuery) return null;
|
|
910
|
-
const built = TEMPLATE_ENTRIES.filter(
|
|
911
|
-
(e) =>
|
|
912
|
-
e.label.toLowerCase().includes(trimmedQuery) ||
|
|
913
|
-
e.description.toLowerCase().includes(trimmedQuery) ||
|
|
914
|
-
e.name.toLowerCase().includes(trimmedQuery),
|
|
915
|
-
);
|
|
916
|
-
const custom = customTemplates.filter(
|
|
917
|
-
(t) =>
|
|
918
|
-
t.label.toLowerCase().includes(trimmedQuery) ||
|
|
919
|
-
t.name.toLowerCase().includes(trimmedQuery) ||
|
|
920
|
-
(t.description ?? '').toLowerCase().includes(trimmedQuery),
|
|
921
|
-
);
|
|
922
|
-
return { built, custom };
|
|
923
|
-
}, [hasQuery, trimmedQuery, customTemplates]);
|
|
924
|
-
|
|
925
|
-
const recommendedSet = useMemo(
|
|
926
|
-
() => (recommended && recommended.length > 0 ? new Set(recommended) : null),
|
|
927
|
-
[recommended],
|
|
928
|
-
);
|
|
929
|
-
const recommendedEntries = useMemo(
|
|
930
|
-
() => (recommendedSet ? TEMPLATE_ENTRIES.filter((e) => recommendedSet.has(e.name)) : []),
|
|
931
|
-
[recommendedSet],
|
|
932
|
-
);
|
|
933
|
-
const restEntries = useMemo(
|
|
934
|
-
() =>
|
|
935
|
-
recommendedSet
|
|
936
|
-
? TEMPLATE_ENTRIES.filter((e) => !recommendedSet.has(e.name))
|
|
937
|
-
: TEMPLATE_ENTRIES,
|
|
938
|
-
[recommendedSet],
|
|
939
|
-
);
|
|
940
|
-
const { blockTypeEntries, contentNeededEntries } = useMemo(
|
|
941
|
-
() => splitBlockTypeEntriesByContent(restEntries, previewSource),
|
|
942
|
-
[restEntries, previewSource],
|
|
943
|
-
);
|
|
944
|
-
const grouped = !hasQuery && (recommendedEntries.length > 0 || contentNeededEntries.length > 0);
|
|
945
|
-
|
|
946
|
-
return (
|
|
947
|
-
<div
|
|
948
|
-
id={galleryId}
|
|
949
|
-
data-squisq-template-gallery-portal=""
|
|
950
|
-
className={`squisq-template-gallery${grouped ? ' squisq-template-gallery--segmented' : ''}`}
|
|
951
|
-
role="listbox"
|
|
952
|
-
aria-label="Block types"
|
|
953
|
-
style={style}
|
|
954
|
-
>
|
|
955
|
-
<div className="squisq-template-gallery-search">
|
|
956
|
-
<svg
|
|
957
|
-
className="squisq-template-gallery-search-icon"
|
|
958
|
-
width="14"
|
|
959
|
-
height="14"
|
|
960
|
-
viewBox="0 0 16 16"
|
|
961
|
-
fill="none"
|
|
962
|
-
aria-hidden="true"
|
|
963
|
-
>
|
|
964
|
-
<circle cx="7" cy="7" r="5" stroke="currentColor" strokeWidth="1.5" />
|
|
965
|
-
<path d="M11 11l3 3" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
|
966
|
-
</svg>
|
|
967
|
-
<input
|
|
968
|
-
ref={searchRef}
|
|
969
|
-
type="search"
|
|
970
|
-
className="squisq-template-gallery-search-input"
|
|
971
|
-
placeholder="Search block types…"
|
|
972
|
-
value={query}
|
|
973
|
-
onChange={(e) => setQuery(e.target.value)}
|
|
974
|
-
aria-label="Search block types"
|
|
975
|
-
/>
|
|
976
|
-
</div>
|
|
977
|
-
|
|
978
|
-
{!hasQuery && (
|
|
979
|
-
<button
|
|
980
|
-
type="button"
|
|
981
|
-
role="option"
|
|
982
|
-
aria-selected={value === ''}
|
|
983
|
-
className={`squisq-template-gallery-none${value === '' ? ' squisq-template-gallery-card--selected' : ''}`}
|
|
984
|
-
onClick={() => onSelect('')}
|
|
985
|
-
>
|
|
986
|
-
{NONE_ENTRY.icon}
|
|
987
|
-
<span className="squisq-template-gallery-none-label">{NONE_ENTRY.label}</span>
|
|
988
|
-
<span className="squisq-template-gallery-none-desc">{NONE_ENTRY.description}</span>
|
|
989
|
-
</button>
|
|
990
|
-
)}
|
|
991
|
-
|
|
992
|
-
{hasQuery ? (
|
|
993
|
-
matches && (matches.built.length > 0 || matches.custom.length > 0) ? (
|
|
994
|
-
<>
|
|
995
|
-
{matches.custom.length > 0 && (
|
|
996
|
-
<div className="squisq-template-gallery-section">
|
|
997
|
-
<h3 className="squisq-template-gallery-section-title">Custom</h3>
|
|
998
|
-
<div className="squisq-template-gallery-grid">
|
|
999
|
-
{matches.custom.map((def) => (
|
|
1000
|
-
<CustomTemplateCard
|
|
1001
|
-
key={def.name}
|
|
1002
|
-
def={def}
|
|
1003
|
-
value={value}
|
|
1004
|
-
onSelect={onSelect}
|
|
1005
|
-
/>
|
|
1006
|
-
))}
|
|
1007
|
-
</div>
|
|
1008
|
-
</div>
|
|
1009
|
-
)}
|
|
1010
|
-
{matches.built.length > 0 && (
|
|
1011
|
-
<div className="squisq-template-gallery-grid">
|
|
1012
|
-
{matches.built.map((entry) => (
|
|
1013
|
-
<TemplateCard
|
|
1014
|
-
key={entry.name}
|
|
1015
|
-
entry={entry}
|
|
1016
|
-
value={value}
|
|
1017
|
-
onSelect={onSelect}
|
|
1018
|
-
previewSource={previewSource}
|
|
1019
|
-
/>
|
|
1020
|
-
))}
|
|
1021
|
-
</div>
|
|
1022
|
-
)}
|
|
1023
|
-
</>
|
|
1024
|
-
) : (
|
|
1025
|
-
<div className="squisq-template-gallery-empty">No block types match "{query}".</div>
|
|
1026
|
-
)
|
|
1027
|
-
) : (
|
|
1028
|
-
<>
|
|
1029
|
-
{/* "+ New custom template" card pinned at the top — only shown
|
|
1030
|
-
when the host has wired up `onOpenDesigner`. */}
|
|
1031
|
-
{onOpenDesigner && (
|
|
1032
|
-
<button type="button" className="squisq-template-gallery-new" onClick={onOpenDesigner}>
|
|
1033
|
-
<span className="squisq-template-gallery-new-plus" aria-hidden="true">
|
|
1034
|
-
+
|
|
1035
|
-
</span>
|
|
1036
|
-
<span className="squisq-template-gallery-new-body">
|
|
1037
|
-
<span className="squisq-template-gallery-new-label">New block type</span>
|
|
1038
|
-
<span className="squisq-template-gallery-new-desc">
|
|
1039
|
-
Design a reusable block type with placeholders for {'{title}'} and {'{content}'}.
|
|
1040
|
-
</span>
|
|
1041
|
-
</span>
|
|
1042
|
-
</button>
|
|
1043
|
-
)}
|
|
1044
|
-
|
|
1045
|
-
{customTemplates.length > 0 && (
|
|
1046
|
-
<div className="squisq-template-gallery-section">
|
|
1047
|
-
<h3 className="squisq-template-gallery-section-title">Custom</h3>
|
|
1048
|
-
<div className="squisq-template-gallery-grid">
|
|
1049
|
-
{customTemplates.map((def) => (
|
|
1050
|
-
<CustomTemplateCard key={def.name} def={def} value={value} onSelect={onSelect} />
|
|
1051
|
-
))}
|
|
1052
|
-
</div>
|
|
1053
|
-
</div>
|
|
1054
|
-
)}
|
|
1055
|
-
|
|
1056
|
-
{recommendedEntries.length > 0 && (
|
|
1057
|
-
<div className="squisq-template-gallery-section">
|
|
1058
|
-
<h3 className="squisq-template-gallery-section-title">Suggested Block Types</h3>
|
|
1059
|
-
<div className="squisq-template-gallery-grid">
|
|
1060
|
-
{recommendedEntries.map((entry) => (
|
|
1061
|
-
<TemplateCard
|
|
1062
|
-
key={entry.name}
|
|
1063
|
-
entry={entry}
|
|
1064
|
-
value={value}
|
|
1065
|
-
onSelect={onSelect}
|
|
1066
|
-
previewSource={previewSource}
|
|
1067
|
-
/>
|
|
1068
|
-
))}
|
|
1069
|
-
</div>
|
|
1070
|
-
</div>
|
|
1071
|
-
)}
|
|
1072
|
-
|
|
1073
|
-
{grouped ? (
|
|
1074
|
-
<>
|
|
1075
|
-
{blockTypeEntries.length > 0 && (
|
|
1076
|
-
<div className="squisq-template-gallery-section">
|
|
1077
|
-
<h3 className="squisq-template-gallery-section-title">Block Types</h3>
|
|
1078
|
-
<div className="squisq-template-gallery-grid">
|
|
1079
|
-
{blockTypeEntries.map((entry) => (
|
|
1080
|
-
<TemplateCard
|
|
1081
|
-
key={entry.name}
|
|
1082
|
-
entry={entry}
|
|
1083
|
-
value={value}
|
|
1084
|
-
onSelect={onSelect}
|
|
1085
|
-
previewSource={previewSource}
|
|
1086
|
-
/>
|
|
1087
|
-
))}
|
|
1088
|
-
</div>
|
|
1089
|
-
</div>
|
|
1090
|
-
)}
|
|
1091
|
-
|
|
1092
|
-
{contentNeededEntries.length > 0 && (
|
|
1093
|
-
<div className="squisq-template-gallery-section">
|
|
1094
|
-
<h3 className="squisq-template-gallery-section-title">Block Types for Content</h3>
|
|
1095
|
-
<div className="squisq-template-gallery-grid">
|
|
1096
|
-
{contentNeededEntries.map((entry) => (
|
|
1097
|
-
<TemplateCard
|
|
1098
|
-
key={entry.name}
|
|
1099
|
-
entry={entry}
|
|
1100
|
-
value={value}
|
|
1101
|
-
onSelect={onSelect}
|
|
1102
|
-
previewSource={previewSource}
|
|
1103
|
-
/>
|
|
1104
|
-
))}
|
|
1105
|
-
</div>
|
|
1106
|
-
</div>
|
|
1107
|
-
)}
|
|
1108
|
-
</>
|
|
1109
|
-
) : (
|
|
1110
|
-
<div className="squisq-template-gallery-grid">
|
|
1111
|
-
{blockTypeEntries.map((entry) => (
|
|
1112
|
-
<TemplateCard
|
|
1113
|
-
key={entry.name}
|
|
1114
|
-
entry={entry}
|
|
1115
|
-
value={value}
|
|
1116
|
-
onSelect={onSelect}
|
|
1117
|
-
previewSource={previewSource}
|
|
1118
|
-
/>
|
|
1119
|
-
))}
|
|
1120
|
-
</div>
|
|
1121
|
-
)}
|
|
1122
|
-
</>
|
|
1123
|
-
)}
|
|
1124
|
-
</div>
|
|
1125
|
-
);
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
/**
|
|
1129
|
-
* Picker card for a user-authored template. Mirrors `TemplateCard`'s
|
|
1130
|
-
* shape so it slots into the gallery grid, but draws the thumbnail by
|
|
1131
|
-
* rendering the template's layers via `<TemplateThumbnail>`. Selecting
|
|
1132
|
-
* it dispatches the template name; the host's `applyTemplate` (called
|
|
1133
|
-
* separately by the badge update flow) inlines the def into the doc.
|
|
1134
|
-
*/
|
|
1135
|
-
function CustomTemplateCard({
|
|
1136
|
-
def,
|
|
1137
|
-
value,
|
|
1138
|
-
onSelect,
|
|
1139
|
-
}: {
|
|
1140
|
-
def: CustomTemplateDefinition;
|
|
1141
|
-
value: string;
|
|
1142
|
-
onSelect: (name: string) => void;
|
|
1143
|
-
}) {
|
|
1144
|
-
return (
|
|
1145
|
-
<button
|
|
1146
|
-
type="button"
|
|
1147
|
-
role="option"
|
|
1148
|
-
aria-selected={value === def.name}
|
|
1149
|
-
className={`squisq-template-gallery-card${
|
|
1150
|
-
value === def.name ? ' squisq-template-gallery-card--selected' : ''
|
|
1151
|
-
}`}
|
|
1152
|
-
onClick={() => onSelect(def.name)}
|
|
1153
|
-
title={def.description ?? def.label}
|
|
1154
|
-
>
|
|
1155
|
-
<div className="squisq-template-gallery-card-icon">
|
|
1156
|
-
<TemplateThumbnail def={def} />
|
|
1157
|
-
</div>
|
|
1158
|
-
<div className="squisq-template-gallery-card-body">
|
|
1159
|
-
<span className="squisq-template-gallery-card-name">{def.label}</span>
|
|
1160
|
-
<span className="squisq-template-gallery-card-desc">
|
|
1161
|
-
{def.description ?? 'Custom block type'}
|
|
1162
|
-
</span>
|
|
1163
|
-
</div>
|
|
1164
|
-
</button>
|
|
1165
|
-
);
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
// ── Inline badge popover (anchored at a heading badge) ─────────────
|
|
1169
|
-
|
|
1170
|
-
export interface TemplateBadgePopoverProps {
|
|
1171
|
-
/** DOMRect of the badge that triggered the popover (in viewport coords). */
|
|
1172
|
-
anchorRect: DOMRect;
|
|
1173
|
-
/** Currently active template name (empty string for none). */
|
|
1174
|
-
value: string;
|
|
1175
|
-
onChange: (name: string) => void;
|
|
1176
|
-
onClose: () => void;
|
|
1177
|
-
/** Active editor chrome theme, used by the portaled dialog. */
|
|
1178
|
-
colorScheme?: 'light' | 'dark';
|
|
1179
|
-
/** Optional list of template names to surface as "Recommended for this block". */
|
|
1180
|
-
recommended?: readonly string[];
|
|
1181
|
-
/**
|
|
1182
|
-
* Optional callback for the "+ New custom template" card. When
|
|
1183
|
-
* supplied, the gallery shows the card pinned at the top; clicking
|
|
1184
|
-
* it closes the popover and opens the designer.
|
|
1185
|
-
*/
|
|
1186
|
-
onOpenDesigner?: () => void;
|
|
1187
|
-
/**
|
|
1188
|
-
* Active block content used to render live template thumbnails. Falls back to
|
|
1189
|
-
* static icons when a candidate cannot be derived.
|
|
1190
|
-
*/
|
|
1191
|
-
previewSource?: TemplatePreviewSource;
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
/**
|
|
1195
|
-
* Standalone dialog that mirrors the toolbar `TemplatePicker`'s gallery
|
|
1196
|
-
* when opened from an inline heading badge.
|
|
1197
|
-
*/
|
|
1198
|
-
export function TemplateBadgePopover({
|
|
1199
|
-
anchorRect,
|
|
1200
|
-
value,
|
|
1201
|
-
onChange,
|
|
1202
|
-
onClose,
|
|
1203
|
-
colorScheme = 'light',
|
|
1204
|
-
recommended,
|
|
1205
|
-
onOpenDesigner,
|
|
1206
|
-
previewSource,
|
|
1207
|
-
}: TemplateBadgePopoverProps) {
|
|
1208
|
-
const [style, setStyle] = useState<React.CSSProperties>(() => computeDialogStyle(anchorRect));
|
|
1209
|
-
const dialogRef = useRef<HTMLDivElement>(null);
|
|
1210
|
-
const dialogId = `${TEMPLATE_GALLERY_DIALOG_ID}-${useId().replace(/:/g, '')}`;
|
|
1211
|
-
|
|
1212
|
-
// Reposition once after mount so the dialog covers the current editor shell.
|
|
1213
|
-
useEffect(() => {
|
|
1214
|
-
const frame = requestAnimationFrame(() => setStyle(computeDialogStyle(anchorRect)));
|
|
1215
|
-
return () => cancelAnimationFrame(frame);
|
|
1216
|
-
}, [anchorRect]);
|
|
1217
|
-
|
|
1218
|
-
// Outside click + Escape close
|
|
1219
|
-
useEffect(() => {
|
|
1220
|
-
const onKey = (e: KeyboardEvent) => {
|
|
1221
|
-
if (e.key === 'Escape') onClose();
|
|
1222
|
-
};
|
|
1223
|
-
const onMouse = (e: MouseEvent) => {
|
|
1224
|
-
const target = e.target as Node;
|
|
1225
|
-
const inDialog = dialogRef.current?.contains(target);
|
|
1226
|
-
if (!inDialog) onClose();
|
|
1227
|
-
};
|
|
1228
|
-
// Defer the mousedown listener by one frame so the click that opened
|
|
1229
|
-
// us doesn't immediately close us.
|
|
1230
|
-
const id = requestAnimationFrame(() => {
|
|
1231
|
-
document.addEventListener('mousedown', onMouse);
|
|
1232
|
-
});
|
|
1233
|
-
document.addEventListener('keydown', onKey);
|
|
1234
|
-
return () => {
|
|
1235
|
-
cancelAnimationFrame(id);
|
|
1236
|
-
document.removeEventListener('mousedown', onMouse);
|
|
1237
|
-
document.removeEventListener('keydown', onKey);
|
|
1238
|
-
};
|
|
1239
|
-
}, [onClose]);
|
|
1240
|
-
|
|
1241
|
-
const handleSelect = (name: string) => {
|
|
1242
|
-
onChange(name);
|
|
1243
|
-
onClose();
|
|
1244
|
-
};
|
|
1245
|
-
|
|
1246
|
-
const dialogTitle = templateDialogTitle(previewSource);
|
|
1247
|
-
|
|
1248
|
-
return createPortal(
|
|
1249
|
-
<TemplateGalleryDialog
|
|
1250
|
-
dialogRef={dialogRef}
|
|
1251
|
-
dialogId={dialogId}
|
|
1252
|
-
title={dialogTitle}
|
|
1253
|
-
colorScheme={colorScheme}
|
|
1254
|
-
style={style}
|
|
1255
|
-
onClose={onClose}
|
|
1256
|
-
>
|
|
1257
|
-
<TemplateGalleryBody
|
|
1258
|
-
value={value}
|
|
1259
|
-
onSelect={handleSelect}
|
|
1260
|
-
style={{}}
|
|
1261
|
-
recommended={recommended}
|
|
1262
|
-
onOpenDesigner={onOpenDesigner}
|
|
1263
|
-
previewSource={previewSource}
|
|
1264
|
-
/>
|
|
1265
|
-
</TemplateGalleryDialog>,
|
|
1266
|
-
document.body,
|
|
1267
|
-
);
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
function templateDialogTitle(previewSource?: TemplatePreviewSource): string {
|
|
1271
|
-
return `Block Type for ${templateDialogBlockTitle(previewSource)}`;
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
function templateDialogBlockTitle(previewSource?: TemplatePreviewSource): string {
|
|
1275
|
-
const block = previewSource?.block;
|
|
1276
|
-
if (!block) return 'this block';
|
|
1277
|
-
|
|
1278
|
-
const headingText = block.sourceHeading ? extractPlainText(block.sourceHeading).trim() : '';
|
|
1279
|
-
const title = (headingText || block.title || '').replace(/\s+/g, ' ').trim();
|
|
1280
|
-
return title || 'this block';
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
function computeDialogStyle(anchor: Element | DOMRect): React.CSSProperties {
|
|
1284
|
-
const shellRect = findEditorShellRect(anchor);
|
|
1285
|
-
const left = Math.max(0, shellRect.left);
|
|
1286
|
-
const top = Math.max(0, shellRect.top);
|
|
1287
|
-
const right = Math.min(window.innerWidth, shellRect.right);
|
|
1288
|
-
const bottom = Math.min(window.innerHeight, shellRect.bottom);
|
|
1289
|
-
|
|
1290
|
-
return {
|
|
1291
|
-
position: 'fixed',
|
|
1292
|
-
top,
|
|
1293
|
-
left,
|
|
1294
|
-
width: Math.max(0, right - left),
|
|
1295
|
-
height: Math.max(0, bottom - top),
|
|
1296
|
-
zIndex: 9999,
|
|
1297
|
-
};
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
function findEditorShellRect(anchor: Element | DOMRect): DOMRect {
|
|
1301
|
-
if (anchor instanceof Element) {
|
|
1302
|
-
const shell = anchor.closest('.squisq-editor-shell');
|
|
1303
|
-
if (shell) return shell.getBoundingClientRect();
|
|
1304
|
-
} else {
|
|
1305
|
-
const x = anchor.left + anchor.width / 2;
|
|
1306
|
-
const y = anchor.top + anchor.height / 2;
|
|
1307
|
-
for (const element of document.elementsFromPoint(x, y)) {
|
|
1308
|
-
const shell = element.closest('.squisq-editor-shell');
|
|
1309
|
-
if (shell) return shell.getBoundingClientRect();
|
|
1310
|
-
}
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
return new DOMRect(0, 0, window.innerWidth, window.innerHeight);
|
|
1314
|
-
}
|