@histoire/app 1.0.0-beta.2 → 1.0.0-beta.3
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/dist/app/style/theme.css +8 -0
- package/dist/bundled/app.css +2 -2
- package/dist/bundled/chunks/{AboutSection-D3IIVsiV.js → AboutSection-mX7J6xrz.js} +2 -2
- package/dist/bundled/chunks/{AgentCursor-Cg5SLa2H.js → AgentCursor-DcVxonMC.js} +2 -2
- package/dist/bundled/chunks/{AgentPlanApproval-D4hnGlYs.js → AgentPlanApproval-22I_Lbhn.js} +1 -1
- package/dist/bundled/chunks/{AgentsSection-CJGS9C2q.js → AgentsSection-DWmUKCX-.js} +1 -1
- package/dist/bundled/chunks/{AiPanel-B9QWRuSg.js → AiPanel-BICtbtCE.js} +4 -4
- package/dist/bundled/chunks/{AppearanceSection-DMjmDr1Y.js → AppearanceSection-maVgcfMk.js} +6 -6
- package/dist/bundled/chunks/{BasePopover-CQQ8wKev.js → BasePopover-B3Y5H1gd.js} +1 -1
- package/dist/bundled/chunks/{CommentsCanvasOverlay-UX-oYgnx.js → CommentsCanvasOverlay-DhqtbJNX.js} +5 -5
- package/dist/bundled/chunks/{DevBrowseStatus-D2rIG8uC.js → DevBrowseStatus-B6cLRu19.js} +2 -2
- package/dist/bundled/chunks/{DocsTab-BR3BktyF.js → DocsTab-PpFKAC6Q.js} +4 -4
- package/dist/bundled/chunks/{EventsTab-BP0hCGqL.js → EventsTab-DLVYcX1N.js} +3 -3
- package/dist/bundled/chunks/{GeneralSection-CT_-32qT.js → GeneralSection-dvmJUgqN.js} +1 -1
- package/dist/bundled/chunks/{InspectionPanel-C6kUdJj9.js → InspectionPanel-DDuT3guJ.js} +2 -2
- package/dist/bundled/chunks/{InspectorGuideLink-Bqlz1aaY.js → InspectorGuideLink-7Ui_Y2Wd.js} +1 -1
- package/dist/bundled/chunks/{MarkdownPage-DD7XyGkq.js → MarkdownPage-D_LpsCvG.js} +3 -3
- package/dist/bundled/chunks/{MarketplaceUpdateBody-B1cn_zeo.js → MarketplaceUpdateBody-BtLPpA7F.js} +2 -2
- package/dist/bundled/chunks/{MarketplaceView-eDPLtc_x.js → MarketplaceView-C1sVFRsq.js} +39 -10
- package/dist/bundled/chunks/{MatrixInspector-eIr_N5eH.js → MatrixInspector-wqkJJnuf.js} +3 -3
- package/dist/bundled/chunks/{MatrixView-CDmN-Kl9.js → MatrixView-D-Snu47M.js} +82 -40
- package/dist/bundled/chunks/{MatrixVisualActions-Cx3QzDTD.js → MatrixVisualActions-D3b-cp7N.js} +2 -2
- package/dist/bundled/chunks/{McpActivity-CiK3jUTY.js → McpActivity-r2CFr-ny.js} +1 -1
- package/dist/bundled/chunks/{McpSection-DRGzPGXO.js → McpSection-swh7qlM0.js} +1 -1
- package/dist/bundled/chunks/{NeedsAttention-C5zjd6RT.js → NeedsAttention-Cf6ihlT0.js} +2 -2
- package/dist/bundled/chunks/{PermissionPrompt-i5VbZCCJ.js → PermissionPrompt-CXTPfiIu.js} +1 -1
- package/dist/bundled/chunks/{PluginsSection-B3ZWAjrk.js → PluginsSection-Dhv2haa3.js} +6 -3
- package/dist/bundled/chunks/{ScreenshotPopover-DWcV_NAf.js → ScreenshotPopover-BZ37-dfK.js} +4 -4
- package/dist/bundled/chunks/{SettingsPage-BvT1FOl7.js → SettingsPage-D6ZOAgS9.js} +11 -11
- package/dist/bundled/chunks/{ShortcutsSection-D3-4e5Ug.js → ShortcutsSection-EK2-e56v.js} +1 -1
- package/dist/bundled/chunks/{StoryInspector-BJKzoeHc.js → StoryInspector-DCNgw0x8.js} +14 -11
- package/dist/bundled/chunks/{TestsPanel-CpBld3wM.js → TestsPanel-D1USqA8I.js} +5 -5
- package/dist/bundled/chunks/{TestsSection-CEXW49Ge.js → TestsSection-CIkkHlyK.js} +1 -1
- package/dist/bundled/chunks/{TestsTab-B-ZNDgGi.js → TestsTab-ykf9zwmG.js} +3 -3
- package/dist/bundled/chunks/{ThreadMessage-CPRLVXXQ.js → ThreadMessage-DxrvoIea.js} +5 -5
- package/dist/bundled/chunks/{ToolbarPopover-Nd-us4Fg.js → ToolbarPopover-CXizdbQq.js} +3 -3
- package/dist/bundled/chunks/{ViewportsSection-3EWu6WSc.js → ViewportsSection-D6mpKTSM.js} +1 -1
- package/dist/bundled/chunks/{VisualViewer-DV5mNFT8.js → VisualViewer-BQqfw1ov.js} +2 -2
- package/dist/bundled/chunks/{WorkbenchPanelAction-Cl68QrDs.js → WorkbenchPanelAction-SLby10Vh.js} +6 -2
- package/dist/bundled/chunks/{WorkbenchVirtualList-CUTamRgO.js → WorkbenchVirtualList-HCZiNo7p.js} +1 -1
- package/dist/bundled/chunks/{background-CG5-SPiv.js → background-CUUIkZVL.js} +7 -1
- package/dist/bundled/chunks/{canvas-settings-EP62RnvB.js → canvas-settings-Cw7AXzFG.js} +31 -13
- package/dist/bundled/chunks/{capture-SFV9pF9b.js → capture-DxD6llwl.js} +1 -1
- package/dist/bundled/chunks/{color-scheme-mhmCnofm.js → color-scheme-zLURTKoT.js} +1 -0
- package/dist/bundled/chunks/{content-view-Bpn8As7f.js → content-view-ChEpdsxh.js} +2 -2
- package/dist/bundled/chunks/{controls-view-COcHf8Pm.js → controls-view-CtDADD0e.js} +3 -3
- package/dist/bundled/chunks/{explorer-view-5gTgnjcf.js → explorer-view-B717fDtg.js} +6 -4
- package/dist/bundled/chunks/{extensions-DUXM9uEy.js → extensions-BtOjYv3e.js} +11 -2
- package/dist/bundled/chunks/{frame-ledger-BHZ0nJjD.js → frame-ledger-C67dpCuY.js} +160 -45
- package/dist/bundled/chunks/{frame-screenshot-D9R_xDns.js → frame-screenshot-IEmQR7TR.js} +1 -1
- package/dist/bundled/chunks/{icons-Bd36WZPu.js → icons-DoUVE4X3.js} +2 -2
- package/dist/bundled/chunks/{local-mount-CCa2jcqi.js → local-mount-CQ14I_16.js} +2 -1
- package/dist/bundled/chunks/{marketplace-DKeNfni-.js → marketplace-BE5IMmf3.js} +9 -3
- package/dist/bundled/chunks/{measurement-DfNeNMZe.js → measurement-BPE7RMeb.js} +1 -1
- package/dist/bundled/chunks/{model-DhvdMZzS.js → model-CIFxQfDH.js} +1 -1
- package/dist/bundled/chunks/{navigation-view-GU5-aPWL.js → navigation-view-Co43QbrR.js} +2 -2
- package/dist/bundled/chunks/{ownership-004rrffQ.js → ownership-BVQ3d672.js} +1 -1
- package/dist/bundled/chunks/{selection-DQJWdqhl.js → selection-BTc1fRMu.js} +1 -1
- package/dist/bundled/chunks/{settings-DC0gilMg.js → settings-BbefKI5N.js} +1 -1
- package/dist/bundled/chunks/{src-BazVZNon.js → src-CDZfcmuw.js} +7 -1
- package/dist/bundled/chunks/{tests-view-B9J9Gvpt.js → tests-view-RYpujVD_.js} +2 -2
- package/dist/bundled/chunks/{use-install-plan-ChZg4Xyq.js → use-install-plan-D0tiW2wu.js} +1 -1
- package/dist/bundled/chunks/{visual-CId9zv09.js → visual-nnXRPOP8.js} +1 -1
- package/dist/bundled/index.js +580 -313
- package/dist/embed/EmbedDocument.vue_vue_type_script_setup_true_lang.js +6 -1
- package/dist/embed/adapters/explorer-session.js +2 -1
- package/dist/embed/adapters/explorer-view.js +1 -0
- package/dist/embed/adapters/local-mount.js +2 -1
- package/dist/embed/adapters/runtime-frame.js +7 -1
- package/dist/embed/adapters/sandbox-urls.d.ts +2 -0
- package/dist/embed/adapters/sandbox-urls.js +1 -0
- package/dist/embed/app.css +2 -2
- package/dist/embed/handshake.js +5 -2
- package/dist/embed/packages/histoire-vue/src/components/embed/HistoireEmbed.js +6 -0
- package/dist/embed/packages/histoire-vue/src/components/preview/surface.js +11 -2
- package/dist/embed/surfaces.d.ts +2 -0
- package/dist/style.css +57 -13
- package/package.json +8 -8
- package/src/app/components/base/overflow/BaseOverflowToolbar.vue +1 -1
- package/src/app/components/base/overflow/BaseOverflowToolbarItem.vue +1 -1
- package/src/app/components/base/popover/BasePopover.vue +1 -1
- package/src/app/components/canvas/CanvasFrame.vue +47 -8
- package/src/app/components/canvas/CanvasReplicaPreview.vue +3 -1
- package/src/app/components/canvas/CanvasSingleVariant.vue +10 -5
- package/src/app/components/canvas/CanvasStatus.vue +6 -2
- package/src/app/components/canvas/CanvasViewport.vue +29 -10
- package/src/app/components/canvas/FramePaddingAligners.vue +44 -0
- package/src/app/components/canvas/SingleVariantResizeHandles.vue +3 -0
- package/src/app/components/canvas/frame-layout.ts +44 -23
- package/src/app/components/canvas/frame-props-override.ts +16 -2
- package/src/app/components/canvas/matrix/MatrixCell.vue +19 -6
- package/src/app/components/canvas/matrix/MatrixView.vue +10 -8
- package/src/app/components/canvas/matrix/matrix-layout.ts +32 -14
- package/src/app/components/canvas/matrix/matrix-registration.ts +4 -4
- package/src/app/components/canvas/single-resize.ts +4 -2
- package/src/app/components/canvas/single-viewport.ts +5 -0
- package/src/app/components/canvas/story-frame-size.ts +15 -0
- package/src/app/components/canvas/toolbar/ArrangeSwitch.vue +1 -1
- package/src/app/components/canvas/toolbar/CanvasToolbar.vue +1 -1
- package/src/app/components/canvas/toolbar/SearchMatchStepper.vue +1 -1
- package/src/app/components/canvas/toolbar/ToolSwitch.vue +1 -1
- package/src/app/components/canvas/toolbar/ViewportMenu.vue +46 -16
- package/src/app/components/canvas/toolbar/ZoomMenu.vue +13 -11
- package/src/app/components/canvas/toolbar/viewport-size.ts +14 -0
- package/src/app/components/canvas/useCanvasVariantSize.ts +24 -6
- package/src/app/components/canvas/useSingleVariantGeometry.ts +7 -4
- package/src/app/components/comments/prompt/AttachMenuPanel.vue +1 -1
- package/src/app/components/comments/prompt/PromptSuggestions.vue +1 -1
- package/src/app/components/embed/EmbedMenu.vue +8 -6
- package/src/app/components/inspector/InspectorTabs.vue +1 -1
- package/src/app/components/inspector/inspection/plugin.ts +1 -1
- package/src/app/components/marketplace/browse/CatalogState.vue +3 -0
- package/src/app/components/marketplace/detail/DetailHeader.vue +13 -5
- package/src/app/components/marketplace/install/use-install-wizard.ts +7 -2
- package/src/app/components/menu/ContextMenu.vue +1 -1
- package/src/app/components/menu/SubMenu.vue +1 -1
- package/src/app/components/pages/settings/PluginsSection.vue +4 -0
- package/src/app/components/pages/settings/plugins/use-plugin-updates.ts +3 -3
- package/src/app/components/shell/WorkbenchApp.vue +2 -2
- package/src/app/components/shell/WorkbenchPanelAction.vue +5 -3
- package/src/app/composables/canvas-settings.ts +23 -9
- package/src/app/standalone/workbench.ts +2 -0
- package/src/app/stores/canvas.ts +47 -7
- package/src/app/stores/marketplace.ts +1 -0
- package/src/app/stores/story-canvas-views.ts +15 -2
- package/src/app/style/theme.css +8 -0
- package/src/app/util/background.ts +7 -0
- package/src/app/util/frame-actions.ts +6 -0
- package/src/app/util/marketplace-client.ts +5 -2
- package/src/embed/EmbedDocument.vue +1 -1
- package/src/embed/adapters/explorer-session.ts +2 -2
- package/src/embed/adapters/explorer-view.ts +1 -1
- package/src/embed/adapters/local-mount.ts +1 -1
- package/src/embed/adapters/runtime-frame.ts +6 -1
- package/src/embed/adapters/sandbox-urls.ts +3 -0
- package/src/embed/handshake.ts +4 -2
- package/src/embed/surfaces.ts +2 -0
|
@@ -25,6 +25,8 @@ const props = defineProps<{
|
|
|
25
25
|
cols?: string
|
|
26
26
|
/** Logical dimensions shared with normal canvas previews. */
|
|
27
27
|
size: { width: number, height: number }
|
|
28
|
+
/** Gutter around each cell's variant, from the story or the project. */
|
|
29
|
+
padding?: number
|
|
28
30
|
/** Absolute first-party preview source URL. */
|
|
29
31
|
previewBase: string
|
|
30
32
|
/** Measured fixed chrome; matrix adds its own axis-control reservation once. */
|
|
@@ -46,14 +48,16 @@ const { story, variant } = useSelection()
|
|
|
46
48
|
const baseVariant = computed(() => variant.value?.id ?? story.value?.variants[0]?.id)
|
|
47
49
|
const rowValues = computed(() => matrix.rowAxis.value ? filterMatrixValues(matrix.rowAxis.value, matrix.rowValues.value) : [])
|
|
48
50
|
const colValues = computed(() => matrix.colAxis.value ? filterMatrixValues(matrix.colAxis.value, matrix.colValues.value) : [])
|
|
49
|
-
/** Matrix projections share a variant
|
|
51
|
+
/** Matrix projections share a variant and measure their own content in Auto fit. */
|
|
50
52
|
function cellSize(cell: MatrixCellData) {
|
|
51
53
|
const target = { storyId: story.value?.id ?? '', variantId: baseVariant.value ?? '' }
|
|
52
|
-
|
|
54
|
+
const measured = canvas.autoFitContent ? canvas.contentSizes.get(cell.key, canvasContentKey(snapshot.value, target, cell.props)) : undefined
|
|
55
|
+
return measured ?? props.size
|
|
53
56
|
}
|
|
57
|
+
const gutter = computed(() => props.padding ?? 0)
|
|
54
58
|
/** Rendering and selection share fixed-pixel matrix gutter/gap calculations. */
|
|
55
59
|
function layoutFrames(zoom = canvas.effectiveZoom) {
|
|
56
|
-
return layoutMatrixFrames(matrix.cells.value, { storyId: story.value?.id ?? '', variantId: baseVariant.value ?? '', rows: rowValues.value, cols: colValues.value, size:
|
|
60
|
+
return layoutMatrixFrames(matrix.cells.value, { storyId: story.value?.id ?? '', variantId: baseVariant.value ?? '', rows: rowValues.value, cols: colValues.value, size: cellSize, padding: gutter.value, zoom })
|
|
57
61
|
}
|
|
58
62
|
const frames = computed(() => layoutFrames())
|
|
59
63
|
const topInset = computed(() => Math.max(props.uiHidden ? MATRIX_COLUMN_HEADER : MATRIX_TOP_INSET, props.contentInsets?.topInset ?? 0))
|
|
@@ -76,16 +80,14 @@ const rowPosition = computed(() => {
|
|
|
76
80
|
if (!frames.value.length) return []
|
|
77
81
|
return rowValues.value.map((value, index) => {
|
|
78
82
|
const frame = frames.value[index * colValues.value.length]
|
|
79
|
-
|
|
80
|
-
return { value, style: { top: `${(frame.y + height / 2) * canvas.effectiveZoom + canvas.panOffset.y}px`, left: `${canvas.panOffset.x}px`, width: `${MATRIX_ROW_GUTTER}px` } }
|
|
83
|
+
return { value, style: { top: `${(frame.y + frame.height / 2) * canvas.effectiveZoom + canvas.panOffset.y}px`, left: `${canvas.panOffset.x}px`, width: `${MATRIX_ROW_GUTTER}px` } }
|
|
81
84
|
})
|
|
82
85
|
})
|
|
83
86
|
const colPosition = computed(() => {
|
|
84
87
|
if (!frames.value.length) return []
|
|
85
88
|
return colValues.value.map((value, index) => {
|
|
86
89
|
const frame = frames.value[index]
|
|
87
|
-
|
|
88
|
-
return { value, style: { top: `${frame.y * canvas.effectiveZoom + canvas.panOffset.y - MATRIX_COLUMN_HEADER}px`, left: `${frame.x * canvas.effectiveZoom + canvas.panOffset.x}px`, width: `${width * canvas.effectiveZoom}px` } }
|
|
90
|
+
return { value, style: { top: `${frame.y * canvas.effectiveZoom + canvas.panOffset.y - MATRIX_COLUMN_HEADER}px`, left: `${frame.x * canvas.effectiveZoom + canvas.panOffset.x}px`, width: `${frame.width * canvas.effectiveZoom}px` } }
|
|
89
91
|
})
|
|
90
92
|
})
|
|
91
93
|
|
|
@@ -116,7 +118,7 @@ onMounted(() => {
|
|
|
116
118
|
<div class="htw:absolute htw:inset-0" :style="{ top: `${-topInset}px` }">
|
|
117
119
|
<span v-for="(position, index) in rowPosition" :key="index" class="htw:absolute htw:overflow-hidden htw:text-muted htw:font-mono htw:text-[11px] htw:whitespace-nowrap htw:text-ellipsis htw:[transform:translateY(-50%)] htw:pe-3" :style="position.style">{{ matrix.rows.value }}={{ JSON.stringify(position.value) }}</span>
|
|
118
120
|
<span v-for="(position, index) in colPosition" :key="index" class="htw:absolute htw:overflow-hidden htw:text-muted htw:font-mono htw:text-[11px] htw:whitespace-nowrap htw:text-ellipsis htw:text-center" :style="position.style">{{ matrix.cols.value }}={{ JSON.stringify(position.value) }}</span>
|
|
119
|
-
<MatrixCell v-for="(cell, index) in matrix.cells.value" :key="cell.key" :cell="cell" :frame="frames[index]" :fit-bounds="zoom => layoutFrames(zoom)[index]" :live="live.has(cell.key)" :variant-id="baseVariant ?? ''" :preview-base="previewBase" />
|
|
121
|
+
<MatrixCell v-for="(cell, index) in matrix.cells.value" :key="cell.key" :cell="cell" :frame="frames[index]" :fit-bounds="zoom => layoutFrames(zoom)[index]" :live="live.has(cell.key)" :variant-id="baseVariant ?? ''" :preview-base="previewBase" :padding="gutter" :fixed-size="!!canvas.frameSizeFromCode" />
|
|
120
122
|
</div>
|
|
121
123
|
</div>
|
|
122
124
|
</div>
|
|
@@ -14,6 +14,12 @@ export const MATRIX_COLUMN_HEADER = 28
|
|
|
14
14
|
/** Adjacent previews retain the same screen-space separation. */
|
|
15
15
|
const MATRIX_GAP = 16
|
|
16
16
|
|
|
17
|
+
/** Matrix card geometry with its independently sized sandbox. */
|
|
18
|
+
export interface MatrixFrameLayout extends CanvasFrameLayout {
|
|
19
|
+
/** Intrinsic sandbox bounds in canvas coordinates. */
|
|
20
|
+
contentRect: CanvasRect
|
|
21
|
+
}
|
|
22
|
+
|
|
17
23
|
/** Inputs keep runtime preview dimensions separate from fixed board chrome. */
|
|
18
24
|
interface MatrixLayoutOptions {
|
|
19
25
|
/** Exact catalog story owner. */
|
|
@@ -26,34 +32,46 @@ interface MatrixLayoutOptions {
|
|
|
26
32
|
cols: readonly MatrixValue[]
|
|
27
33
|
/** Logical preview dimensions from existing viewport settings. */
|
|
28
34
|
size: CanvasSize | ((cell: MatrixCellData) => CanvasSize)
|
|
35
|
+
/** Logical gutter around each sandbox. */
|
|
36
|
+
padding?: number
|
|
29
37
|
/** Current numeric zoom; chrome converts screen pixels into world units. */
|
|
30
38
|
zoom: number
|
|
31
39
|
}
|
|
32
40
|
|
|
33
|
-
/**
|
|
34
|
-
export function layoutMatrixFrames(cells: readonly MatrixCellData[], options: MatrixLayoutOptions):
|
|
41
|
+
/** Fill row and column tracks in world coordinates while retaining fixed-pixel chrome. */
|
|
42
|
+
export function layoutMatrixFrames(cells: readonly MatrixCellData[], options: MatrixLayoutOptions): MatrixFrameLayout[] {
|
|
35
43
|
const scale = clampZoom(options.zoom)
|
|
44
|
+
const padding = options.padding ?? 0
|
|
36
45
|
const sizes = cells.map(cell => typeof options.size === 'function' ? options.size(cell) : options.size)
|
|
37
46
|
const rows = cells.map(cell => options.rows.findIndex(value => equalMatrixValue(value, cell.row)))
|
|
38
47
|
const cols = cells.map(cell => options.cols.findIndex(value => equalMatrixValue(value, cell.col)))
|
|
39
48
|
const widths = options.cols.map(() => 0)
|
|
40
49
|
const heights = options.rows.map(() => 0)
|
|
41
50
|
sizes.forEach((size, index) => {
|
|
42
|
-
widths[cols[index]] = Math.max(widths[cols[index]], size.width)
|
|
43
|
-
heights[rows[index]] = Math.max(heights[rows[index]], size.height)
|
|
51
|
+
widths[cols[index]] = Math.max(widths[cols[index]], size.width + padding * 2)
|
|
52
|
+
heights[rows[index]] = Math.max(heights[rows[index]], size.height + padding * 2)
|
|
44
53
|
})
|
|
45
54
|
const xs = canvasTrackOffsets(widths, MATRIX_GAP / scale, MATRIX_ROW_GUTTER / scale)
|
|
46
55
|
const ys = canvasTrackOffsets(heights, MATRIX_GAP / scale, MATRIX_COLUMN_HEADER / scale)
|
|
47
|
-
return cells.map((cell, index) =>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
return cells.map((cell, index) => {
|
|
57
|
+
const column = cols[index]
|
|
58
|
+
const row = rows[index]
|
|
59
|
+
const x = xs[column]
|
|
60
|
+
const y = ys[row]
|
|
61
|
+
const { width, height } = sizes[index]
|
|
62
|
+
const contentRect = { x: x + padding, y: y + padding, width, height }
|
|
63
|
+
return {
|
|
64
|
+
id: cell.key,
|
|
65
|
+
storyId: options.storyId,
|
|
66
|
+
variantId: options.variantId,
|
|
67
|
+
x,
|
|
68
|
+
y,
|
|
69
|
+
width: widths[column],
|
|
70
|
+
height: heights[row],
|
|
71
|
+
contentRect,
|
|
72
|
+
runtimeBounds: contentRect,
|
|
73
|
+
}
|
|
74
|
+
})
|
|
57
75
|
}
|
|
58
76
|
|
|
59
77
|
/** Include row and column labels once, without artificial scaled outer margins. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CanvasFrames } from '../../../composables/canvas-settings.js'
|
|
2
|
-
import type { CanvasFrameLayout } from '../frame-layout.js'
|
|
3
2
|
import type { CanvasRect } from '../pan/usePanZoom.js'
|
|
3
|
+
import type { MatrixFrameLayout } from './matrix-layout.js'
|
|
4
4
|
import { watch } from 'vue'
|
|
5
5
|
|
|
6
6
|
/** Bind exact base preset ownership while geometry-only updates retain its document. */
|
|
@@ -8,7 +8,7 @@ export function watchMatrixFrameRegistration(options: {
|
|
|
8
8
|
/** Canvas registry owned by nearest viewport. */
|
|
9
9
|
registry: CanvasFrames
|
|
10
10
|
/** Current layout can change without changing target. */
|
|
11
|
-
getFrame: () =>
|
|
11
|
+
getFrame: () => MatrixFrameLayout
|
|
12
12
|
/** Candidate-zoom cell bounds supplied by arrangement owner. */
|
|
13
13
|
getFitBounds?: (zoom: number) => CanvasRect
|
|
14
14
|
/** Collected base variant shared by cells. */
|
|
@@ -23,11 +23,11 @@ export function watchMatrixFrameRegistration(options: {
|
|
|
23
23
|
options.onTargetChange()
|
|
24
24
|
unregister()
|
|
25
25
|
const frame = options.getFrame()
|
|
26
|
-
unregister = options.registry.registerFrame({ id: frame.id, storyId: frame.storyId, variantId: options.getVariantId(), rect: frame, fitBounds: options.getFitBounds, propsOverride: options.getPropsOverride?.() })
|
|
26
|
+
unregister = options.registry.registerFrame({ id: frame.id, storyId: frame.storyId, variantId: options.getVariantId(), rect: frame.contentRect, fitBounds: options.getFitBounds, propsOverride: options.getPropsOverride?.() })
|
|
27
27
|
}, { immediate: true, flush: 'sync' })
|
|
28
28
|
const stopGeometry = watch(options.getFrame, (frame) => {
|
|
29
29
|
const entry = options.registry.getFrame(frame.id)
|
|
30
|
-
if (entry) entry.rect = frame
|
|
30
|
+
if (entry) entry.rect = frame.contentRect
|
|
31
31
|
}, { flush: 'sync' })
|
|
32
32
|
const stopProps = watch(() => options.getPropsOverride?.(), (value) => {
|
|
33
33
|
const entry = options.registry.getFrame(options.getFrame().id)
|
|
@@ -50,6 +50,8 @@ export interface SingleResizeControllerOptions {
|
|
|
50
50
|
onResize: (size: SingleResizeSize) => void
|
|
51
51
|
/** Persist completed physical dimensions. */
|
|
52
52
|
onCommit: (size: SingleResizeSize) => void
|
|
53
|
+
/** Story gutter between frame edge and viewport; pointers measure the frame, sizes exclude it. */
|
|
54
|
+
getInset?: () => number
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
/** Clamp and round one logical viewport dimension. */
|
|
@@ -95,12 +97,12 @@ export function createSingleResizeController(options: SingleResizeControllerOpti
|
|
|
95
97
|
function pointerWidth(event: PointerEvent, geometry: SingleResizeGeometry): number {
|
|
96
98
|
const right = event.clientX + edgeOffset.x - geometry.surface.left + geometry.surface.scrollLeft
|
|
97
99
|
const displayed = right > geometry.surface.width ? right : right * 2 - geometry.surface.width
|
|
98
|
-
return displayed / geometry.zoom
|
|
100
|
+
return displayed / geometry.zoom - (options.getInset?.() ?? 0) * 2
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
/** Project a bottom-edge pointer through native scroll and displayed zoom. */
|
|
102
104
|
function pointerHeight(event: PointerEvent, geometry: SingleResizeGeometry): number {
|
|
103
|
-
return (event.clientY + edgeOffset.y - geometry.surface.top + geometry.surface.scrollTop) / geometry.zoom
|
|
105
|
+
return (event.clientY + edgeOffset.y - geometry.surface.top + geometry.surface.scrollTop) / geometry.zoom - (options.getInset?.() ?? 0) * 2
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
/** Begin primary pointer ownership for one grip. */
|
|
@@ -18,6 +18,11 @@ export function singleVariantArea(viewport: CanvasSize, insets: CanvasContentIns
|
|
|
18
18
|
return { x: padding, y: top, width: Math.max(1, Math.round(viewport.width - inspectorWidth - padding * 2)), height: Math.max(1, Math.round(viewport.height - top - (insets.bottomInset ?? 0) - padding)) }
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/** Room left for the variant once a story gutter surrounds it. */
|
|
22
|
+
export function insetArea(area: CanvasSize, padding: number): CanvasSize {
|
|
23
|
+
return { width: Math.max(1, area.width - padding * 2), height: Math.max(1, area.height - padding * 2) }
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
/** Resolve logical dimensions without shrinking oversized presets or scaling content. */
|
|
22
27
|
export function resolveSingleViewport(area: CanvasSize, settings: Pick<HistoireSettings, 'responsiveWidth' | 'responsiveHeight' | 'rotate'>, mode: SingleViewportState['mode']): CanvasSize {
|
|
23
28
|
if (mode === 'responsive') return { width: area.width, height: area.height }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { HistoireCatalogStory } from '@histoire/sdk'
|
|
2
|
+
import type { StoryCanvasViews } from '../../stores/story-canvas-views.js'
|
|
3
|
+
|
|
4
|
+
/** Width and height a story declares in its layout, whether or not they are in use. */
|
|
5
|
+
export function declaredFrameSize(story: Pick<HistoireCatalogStory, 'layout'> | undefined): { width?: number, height?: number } | undefined {
|
|
6
|
+
const layout = story?.layout
|
|
7
|
+
if (!layout?.width && !layout?.height) return undefined
|
|
8
|
+
return { width: layout.width, height: layout.height }
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Declared size in use: absent once the story is switched to the toolbar viewport for this session. */
|
|
12
|
+
export function storyFrameSize(views: StoryCanvasViews, story: Pick<HistoireCatalogStory, 'id' | 'layout'> | undefined): { width?: number, height?: number } | undefined {
|
|
13
|
+
if (!story || views.usesToolbarViewport(story.id)) return undefined
|
|
14
|
+
return declaredFrameSize(story)
|
|
15
|
+
}
|
|
@@ -15,7 +15,7 @@ const presentation = useToolbarPresentation()
|
|
|
15
15
|
</script>
|
|
16
16
|
|
|
17
17
|
<template>
|
|
18
|
-
<div :data-presentation="presentation" class="histoire-button-group-options htw:data-[presentation=menu]:flex-col htw:data-[presentation=menu]:items-stretch htw:data-[presentation=menu]:gap-
|
|
18
|
+
<div :data-presentation="presentation" class="histoire-button-group-options htw:data-[presentation=menu]:flex-col htw:data-[presentation=menu]:items-stretch htw:data-[presentation=menu]:gap-px htw:data-[presentation=menu]:p-0 htw:data-[presentation=menu]:bg-transparent" role="group" aria-label="Arrange frames">
|
|
19
19
|
<ToolbarButton menu-role="menuitemradio" label="Single variant" icon="document" :pressed="arrange === 'single'" @click="emit('arrange', 'single')" />
|
|
20
20
|
<ToolbarButton menu-role="menuitemradio" label="Grid" icon="grid" :pressed="arrange === 'grid'" @click="emit('arrange', 'grid')" />
|
|
21
21
|
<ToolbarButton menu-role="menuitemradio" label="List" icon="list-boxes" :pressed="arrange === 'list'" @click="emit('arrange', 'list')" />
|
|
@@ -119,7 +119,7 @@ onBeforeUnmount(() => disposers.forEach(dispose => dispose()))
|
|
|
119
119
|
</BaseOverflowToolbarItem>
|
|
120
120
|
<BaseOverflowToolbarItem v-if="view.showsGroup('viewport')" id="viewport" separator-before>
|
|
121
121
|
<ViewportMenu v-model:open="open" @edit-presets="emit('editPresets')" />
|
|
122
|
-
<ToolbarButton label="Rotate viewport" icon="rotate" :pressed="!canvas.autoFitContent && snapshot.settings.rotate" @click="rotateViewport" />
|
|
122
|
+
<ToolbarButton label="Rotate viewport" icon="rotate" :disabled="!!canvas.frameSizeFromCode" :pressed="!canvas.frameSizeFromCode && !canvas.autoFitContent && snapshot.settings.rotate" @click="rotateViewport" />
|
|
123
123
|
<PluginToolbarItem v-for="item in pluginItems?.viewport" :key="plugin.keyOf(item)" :item="item" :workbench="plugin.workbench!" :revision="plugin.revision.value" :open="open" @update:open="setOpen" @error="emit('error', $event)" />
|
|
124
124
|
</BaseOverflowToolbarItem>
|
|
125
125
|
<BaseOverflowToolbarItem v-if="view.showsGroup('zoom')" id="zoom" separator-before>
|
|
@@ -19,7 +19,7 @@ const presentation = useToolbarPresentation()
|
|
|
19
19
|
</script>
|
|
20
20
|
|
|
21
21
|
<template>
|
|
22
|
-
<span v-if="count > 0" :data-presentation="presentation" class="htw:flex htw:items-center htw:flex-none htw:gap-0.5 htw:group/search-stepper htw:data-[presentation=menu]:flex-col htw:data-[presentation=menu]:items-stretch htw:data-[presentation=menu]:gap-
|
|
22
|
+
<span v-if="count > 0" :data-presentation="presentation" class="htw:flex htw:items-center htw:flex-none htw:gap-0.5 htw:group/search-stepper htw:data-[presentation=menu]:flex-col htw:data-[presentation=menu]:items-stretch htw:data-[presentation=menu]:gap-px htw:data-[presentation=menu]:p-0 htw:data-[presentation=menu]:bg-transparent">
|
|
23
23
|
<ToolbarButton label="Previous search match" icon="chevron-up" @click="emit('previous')" />
|
|
24
24
|
<span class="htw:[line-height:normal] htw:min-w-9 htw:text-muted htw:font-mono htw:text-[11px] htw:text-center htw:whitespace-nowrap htw:group-data-[presentation=menu]/search-stepper:py-1 htw:group-data-[presentation=menu]/search-stepper:px-2 htw:group-data-[presentation=menu]/search-stepper:text-start" role="status" aria-label="Search matches" aria-live="polite">{{ position }} / {{ count }}</span>
|
|
25
25
|
<ToolbarButton label="Next search match" icon="chevron-down" @click="emit('next')" />
|
|
@@ -27,7 +27,7 @@ const presentation = useToolbarPresentation()
|
|
|
27
27
|
</script>
|
|
28
28
|
|
|
29
29
|
<template>
|
|
30
|
-
<div :data-presentation="presentation" :data-leading="leading" class="histoire-button-group-options htw:data-[presentation=menu]:flex-col htw:data-[presentation=menu]:items-stretch htw:data-[presentation=menu]:gap-
|
|
30
|
+
<div :data-presentation="presentation" :data-leading="leading" class="histoire-button-group-options htw:data-[presentation=menu]:flex-col htw:data-[presentation=menu]:items-stretch htw:data-[presentation=menu]:gap-px htw:data-[presentation=menu]:p-0 htw:data-[presentation=menu]:bg-transparent htw:data-[presentation=inline]:data-[leading=true]:-ms-[3px]" role="group" aria-label="Canvas tool">
|
|
31
31
|
<ToolbarButton menu-role="menuitemradio" label="Select" icon="cursor-1" :shortcut="shortcuts?.hint('canvas.select')" :pressed="activeTool === 'select'" @click="canvas.setTool('select')" />
|
|
32
32
|
<ToolbarButton menu-role="menuitemradio" label="Pan" icon="move" :shortcut="shortcuts?.hint('canvas.pan')" :pressed="activeTool === 'pan'" :disabled="!panAvailable" :description="panAvailable ? undefined : 'Pan isn’t available in single variant view'" @click="canvas.setTool('pan')" />
|
|
33
33
|
<ToolbarButton menu-role="menuitemradio" label="Measure" icon="ruler" :shortcut="shortcuts?.hint('canvas.measure')" :pressed="activeTool === 'measure'" :disabled="!measureAvailable" :description="measureAvailable ? undefined : 'Measurement isn’t available for this story'" @click="canvas.setTool('measure')" />
|
|
@@ -3,6 +3,7 @@ import { BuiltinIcon, HstButton, HstText } from '@histoire/controls/vue'
|
|
|
3
3
|
import { computed, ref, watch } from 'vue'
|
|
4
4
|
import { useCanvasStore } from '../../../composables/canvas-settings.js'
|
|
5
5
|
import { usePresetConfigStore } from '../../../stores/presets-config.js'
|
|
6
|
+
import { useStoryCanvasViews } from '../../../stores/story-canvas-views.js'
|
|
6
7
|
import { histoireConfig } from '../../../util/config.js'
|
|
7
8
|
|
|
8
9
|
import PopoverDivider from '../../base/popover/PopoverDivider.vue'
|
|
@@ -13,15 +14,24 @@ import PopoverTitle from '../../base/popover/PopoverTitle.vue'
|
|
|
13
14
|
import { useCanvasPreviewSettings } from './session-settings.js'
|
|
14
15
|
import { parseViewportSize } from './settings.js'
|
|
15
16
|
import ToolbarPopover from './ToolbarPopover.vue'
|
|
16
|
-
import { useCanvasViewportDimensions } from './viewport-size.js'
|
|
17
|
+
import { useCanvasViewportDimensions, useDeclaredStoryFrame } from './viewport-size.js'
|
|
17
18
|
|
|
18
19
|
defineProps<{ open: string | null }>()
|
|
19
20
|
const emit = defineEmits<{ 'update:open': [value: string | null], 'editPresets': [] }>()
|
|
20
21
|
const { snapshot, update } = useCanvasPreviewSettings()
|
|
21
22
|
const canvas = useCanvasStore()
|
|
23
|
+
const views = useStoryCanvasViews()
|
|
22
24
|
const presetsOwner = usePresetConfigStore()
|
|
23
25
|
const presets = computed(() => presetsOwner?.responsivePresets.value ?? histoireConfig.responsivePresets ?? [])
|
|
24
26
|
const dimensions = useCanvasViewportDimensions()
|
|
27
|
+
const declared = useDeclaredStoryFrame()
|
|
28
|
+
const fromCode = computed(() => !!canvas.frameSizeFromCode)
|
|
29
|
+
/** The story's own size replaces the toolbar viewport, so the trigger says where it comes from. */
|
|
30
|
+
const triggerLabel = computed(() => {
|
|
31
|
+
if (fromCode.value) return 'From code'
|
|
32
|
+
if (canvas.autoFitContent) return 'Auto fit'
|
|
33
|
+
return String(dimensions.value.width)
|
|
34
|
+
})
|
|
25
35
|
const customWidth = ref('')
|
|
26
36
|
const customHeight = ref('')
|
|
27
37
|
const error = ref('')
|
|
@@ -30,9 +40,21 @@ watch(dimensions, (size) => {
|
|
|
30
40
|
customHeight.value = size.height === null ? '' : String(size.height)
|
|
31
41
|
}, { immediate: true })
|
|
32
42
|
|
|
43
|
+
/** Size the selected story from its code until the page reloads. */
|
|
44
|
+
function selectCode(): void {
|
|
45
|
+
if (declared.value) views.setStorySizeFromCode(declared.value.storyId, true)
|
|
46
|
+
emit('update:open', null)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Any other option sizes the selected story from the toolbar viewport instead of its code. */
|
|
50
|
+
function leaveCode(): void {
|
|
51
|
+
if (declared.value) views.setStorySizeFromCode(declared.value.storyId, false)
|
|
52
|
+
}
|
|
53
|
+
|
|
33
54
|
/** Named preset sizes retain logical orientation and use existing settings persistence. */
|
|
34
55
|
function preset(width: number, height?: number | null) {
|
|
35
56
|
error.value = ''
|
|
57
|
+
leaveCode()
|
|
36
58
|
canvas.setAutoFitContent(false)
|
|
37
59
|
if (canvas.arrangement === 'single') canvas.setSingleViewportMode('fixed')
|
|
38
60
|
update({ responsiveWidth: width, responsiveHeight: height ?? null, rotate: false })
|
|
@@ -44,6 +66,7 @@ function custom() {
|
|
|
44
66
|
const patch = parseViewportSize(customWidth.value, customHeight.value)
|
|
45
67
|
error.value = patch ? '' : 'Use whole pixels from 1 to 16384.'
|
|
46
68
|
if (patch) {
|
|
69
|
+
leaveCode()
|
|
47
70
|
canvas.setAutoFitContent(false)
|
|
48
71
|
if (canvas.arrangement === 'single') canvas.setSingleViewportMode('fixed')
|
|
49
72
|
update(patch)
|
|
@@ -53,6 +76,7 @@ function custom() {
|
|
|
53
76
|
/** Responsive option fills available canvas width using bounded current root dimensions. */
|
|
54
77
|
function responsive() {
|
|
55
78
|
error.value = ''
|
|
79
|
+
leaveCode()
|
|
56
80
|
canvas.setAutoFitContent(false)
|
|
57
81
|
if (canvas.arrangement === 'single') canvas.setSingleViewportMode('responsive')
|
|
58
82
|
else update({ responsiveWidth: Math.max(1, Math.round(canvas.viewport.width - canvas.inspectorWidth - 64)), responsiveHeight: null, rotate: false })
|
|
@@ -62,32 +86,38 @@ function responsive() {
|
|
|
62
86
|
/** Content mode retains stored manual viewport and independent camera zoom. */
|
|
63
87
|
function autoFit(): void {
|
|
64
88
|
error.value = ''
|
|
89
|
+
leaveCode()
|
|
65
90
|
canvas.setAutoFitContent(true)
|
|
66
91
|
emit('update:open', null)
|
|
67
92
|
}
|
|
68
93
|
</script>
|
|
69
94
|
|
|
70
95
|
<template>
|
|
71
|
-
<ToolbarPopover id="viewport" :open="open" label="Viewport" icon="laptop" :width="280" @update:open="emit('update:open', $event)">
|
|
96
|
+
<ToolbarPopover id="viewport" :open="open" label="Viewport" :icon="fromCode ? 'code' : 'laptop'" :width="280" @update:open="emit('update:open', $event)">
|
|
72
97
|
<template #trigger>
|
|
73
|
-
<span class="htw:text-text htw:font-mono htw:text-[11px]">{{
|
|
98
|
+
<span class="htw:text-text htw:font-mono htw:text-[11px]">{{ triggerLabel }}</span><BuiltinIcon icon="chevron-down" :size="16" />
|
|
74
99
|
</template>
|
|
75
100
|
<PopoverTitle>
|
|
76
101
|
Viewport
|
|
77
102
|
</PopoverTitle>
|
|
78
|
-
<
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
<
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
103
|
+
<div class="htw:menu-rows">
|
|
104
|
+
<PopoverRow v-if="declared" :aria-pressed="!!fromCode" @click="selectCode">
|
|
105
|
+
<BuiltinIcon icon="code" :size="16" />From code<PopoverMeta>{{ declared.width ?? 'Auto' }} × {{ declared.height ?? 'Auto' }}</PopoverMeta>
|
|
106
|
+
</PopoverRow>
|
|
107
|
+
<PopoverRow :aria-pressed="!fromCode && !canvas.autoFitContent && canvas.arrangement === 'single' && canvas.singleViewport.mode === 'responsive'" @click="responsive">
|
|
108
|
+
<BuiltinIcon icon="arrows-horizontal" :size="16" />{{ canvas.arrangement === 'single' ? 'Fill viewport' : 'Responsive' }}<PopoverMeta>fill</PopoverMeta>
|
|
109
|
+
</PopoverRow>
|
|
110
|
+
<PopoverRow :aria-pressed="!fromCode && canvas.autoFitContent" @click="autoFit">
|
|
111
|
+
<BuiltinIcon icon="ruler" :size="16" />Auto fit content
|
|
112
|
+
</PopoverRow>
|
|
113
|
+
<PopoverRow v-for="(option, index) in presets" :key="index" :aria-pressed="!fromCode && !canvas.autoFitContent && (canvas.arrangement !== 'single' || canvas.singleViewport.mode === 'fixed') && snapshot.settings.responsiveWidth === option.width && snapshot.settings.responsiveHeight === (option.height ?? null)" @click="preset(option.width, option.height)">
|
|
114
|
+
<BuiltinIcon :icon="option.width < 500 ? 'mobile' : option.width < 900 ? 'tablet' : 'screen'" :size="16" /><span>{{ option.label }}</span><PopoverMeta>
|
|
115
|
+
{{ option.width }}<template v-if="option.height">
|
|
116
|
+
× {{ option.height }}
|
|
117
|
+
</template>
|
|
118
|
+
</PopoverMeta>
|
|
119
|
+
</PopoverRow>
|
|
120
|
+
</div>
|
|
91
121
|
<PopoverDivider />
|
|
92
122
|
<form class="viewport-custom htw:flex htw:items-center htw:gap-1.5 htw:py-1.5 htw:px-2 htw:text-muted htw:text-[11px]" @submit.prevent="custom">
|
|
93
123
|
<span class="htw:mr-auto">Custom</span><HstText v-model="customWidth" class="htw:flex-1 htw:min-w-0" layout="inline" aria-label="Custom width" inputmode="numeric" @change="custom" /><span>×</span><HstText v-model="customHeight" class="htw:flex-1 htw:min-w-0" layout="inline" aria-label="Custom height" placeholder="Auto" inputmode="numeric" @change="custom" />
|
|
@@ -37,17 +37,19 @@ function selection() {
|
|
|
37
37
|
<template #trigger>
|
|
38
38
|
<span class="htw:text-text htw:font-mono htw:text-[11px] htw:min-w-[29px]">{{ label }}</span>
|
|
39
39
|
</template>
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
{{
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
<div class="htw:menu-rows">
|
|
41
|
+
<PopoverRow :aria-pressed="canvas.zoom === 'fit'" @click="zoom('fit')">
|
|
42
|
+
Fit to canvas<PopoverMeta>{{ shortcuts?.hint('canvas.fit') || '⇧1' }}</PopoverMeta>
|
|
43
|
+
</PopoverRow>
|
|
44
|
+
<PopoverRow v-if="canvas.arrangement !== 'single'" :disabled="!selectedFrame" :aria-pressed="canvas.zoom === 'selection'" @click="selection">
|
|
45
|
+
Zoom to selection<PopoverMeta>{{ shortcuts?.hint('canvas.selection') || '⇧2' }}</PopoverMeta>
|
|
46
|
+
</PopoverRow>
|
|
47
|
+
<PopoverRow v-for="value in [.25, .5, 1, 2]" :key="value" :aria-pressed="canvas.zoom === value" @click="zoom(value)">
|
|
48
|
+
{{ value * 100 }}%<PopoverMeta v-if="value === 1">
|
|
49
|
+
{{ shortcuts?.hint('canvas.actual') || '⇧0' }}
|
|
50
|
+
</PopoverMeta>
|
|
51
|
+
</PopoverRow>
|
|
52
|
+
</div>
|
|
51
53
|
<template v-if="settings">
|
|
52
54
|
<PopoverDivider />
|
|
53
55
|
<PopoverRow class="htw:cursor-default" as="label">
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { useHistoireSnapshot } from '@histoire/vue'
|
|
2
2
|
import { computed } from 'vue'
|
|
3
3
|
import { useCanvasFrames, useCanvasStore } from '../../../composables/canvas-settings.js'
|
|
4
|
+
import { isBuiltinCanvasArrangement } from '../../../stores/canvas-arrangement.js'
|
|
4
5
|
import { getSelectedCanvasFrame } from '../frame-target.js'
|
|
6
|
+
import { declaredFrameSize } from '../story-frame-size.js'
|
|
5
7
|
import { viewportDimensions } from './settings.js'
|
|
6
8
|
|
|
7
9
|
/** Toolbar uses physical selection dimensions, including locally selected Matrix cells. */
|
|
@@ -18,3 +20,15 @@ export function useCanvasViewportDimensions() {
|
|
|
18
20
|
return viewportDimensions(snapshot.value.settings)
|
|
19
21
|
})
|
|
20
22
|
}
|
|
23
|
+
|
|
24
|
+
/** Selected story and its declared size in arrangements that support From code. */
|
|
25
|
+
export function useDeclaredStoryFrame() {
|
|
26
|
+
const canvas = useCanvasStore()
|
|
27
|
+
const snapshot = useHistoireSnapshot()
|
|
28
|
+
return computed(() => {
|
|
29
|
+
if (canvas.arrangement === 'single' || !isBuiltinCanvasArrangement(canvas.arrangement)) return undefined
|
|
30
|
+
const story = snapshot.value.catalog.stories.find(item => item.id === snapshot.value.selection?.storyId)
|
|
31
|
+
const size = declaredFrameSize(story)
|
|
32
|
+
return story && size ? { storyId: story.id, ...size } : undefined
|
|
33
|
+
})
|
|
34
|
+
}
|
|
@@ -1,22 +1,40 @@
|
|
|
1
1
|
import type { CanvasStore } from '../../stores/canvas.js'
|
|
2
|
+
import type { CanvasSize } from './pan/usePanZoom.js'
|
|
2
3
|
import { getHistoireTargetKey } from '@histoire/protocol'
|
|
3
4
|
import { useHistoireSnapshot } from '@histoire/vue'
|
|
4
5
|
import { computed } from 'vue'
|
|
5
6
|
import { canvasContentKey } from './content-sizes.js'
|
|
6
7
|
|
|
7
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Resolve canonical fallback and source-fenced variant sizes for every ordinary layout.
|
|
10
|
+
* @param canvas Workbench canvas owning fit mode and measured content.
|
|
11
|
+
*/
|
|
8
12
|
export function useCanvasVariantSize(canvas: CanvasStore) {
|
|
9
13
|
const snapshot = useHistoireSnapshot()
|
|
10
|
-
const
|
|
14
|
+
const viewport = computed(() => {
|
|
11
15
|
const settings = snapshot.value.settings
|
|
12
16
|
return { width: settings.rotate && settings.responsiveHeight ? settings.responsiveHeight : settings.responsiveWidth, height: settings.rotate ? settings.responsiveWidth : settings.responsiveHeight ?? 640 }
|
|
13
17
|
})
|
|
18
|
+
const size = computed(() => {
|
|
19
|
+
const declared = canvas.frameSizeFromCode
|
|
20
|
+
return { width: declared?.width ?? viewport.value.width, height: declared?.height ?? viewport.value.height }
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
/** Cache belongs to this source and target, independently of mounted frame lifetime. */
|
|
24
|
+
function measuredSize(variantId: string | null | undefined): CanvasSize | undefined {
|
|
25
|
+
const target = { storyId: snapshot.value.selection?.storyId ?? '', variantId }
|
|
26
|
+
return canvas.autoFitContent ? canvas.contentSizes.get(getHistoireTargetKey(target), canvasContentKey(snapshot.value, target)) : undefined
|
|
27
|
+
}
|
|
28
|
+
|
|
14
29
|
return {
|
|
15
30
|
size,
|
|
16
|
-
/**
|
|
17
|
-
frameContentSize(variantId: string | null | undefined) {
|
|
18
|
-
|
|
19
|
-
|
|
31
|
+
/** Grid and List size from active content fit, code, or the toolbar viewport. */
|
|
32
|
+
frameContentSize(variantId: string | null | undefined): CanvasSize {
|
|
33
|
+
return measuredSize(variantId) ?? size.value
|
|
34
|
+
},
|
|
35
|
+
/** Single size: measured content or the viewport, ignoring declared dimensions. */
|
|
36
|
+
viewportContentSize(variantId: string | null | undefined): CanvasSize {
|
|
37
|
+
return measuredSize(variantId) ?? viewport.value
|
|
20
38
|
},
|
|
21
39
|
}
|
|
22
40
|
}
|
|
@@ -2,7 +2,7 @@ import type { HistoireSettings } from '@histoire/protocol'
|
|
|
2
2
|
import type { CanvasContentInsets, CanvasStore } from '../../stores/canvas.js'
|
|
3
3
|
import type { CanvasSize } from './pan/usePanZoom.js'
|
|
4
4
|
import { computed, shallowRef, watch } from 'vue'
|
|
5
|
-
import { resolveSingleViewport, singleVariantArea } from './single-viewport.js'
|
|
5
|
+
import { insetArea, resolveSingleViewport, singleVariantArea } from './single-viewport.js'
|
|
6
6
|
|
|
7
7
|
/** Native document geometry stays independent of remembered canvas transforms. */
|
|
8
8
|
export function useSingleVariantGeometry(canvas: CanvasStore, options: {
|
|
@@ -14,13 +14,16 @@ export function useSingleVariantGeometry(canvas: CanvasStore, options: {
|
|
|
14
14
|
hidden: () => boolean
|
|
15
15
|
/** Selected variant's measured content overrides stored viewport dimensions. */
|
|
16
16
|
contentSize?: () => CanvasSize | undefined
|
|
17
|
+
/** Story gutter around the variant; a responsive viewport leaves room for it. */
|
|
18
|
+
padding?: () => number
|
|
17
19
|
}) {
|
|
18
20
|
const insets = shallowRef<CanvasContentInsets>({})
|
|
19
21
|
const area = computed(() => singleVariantArea(canvas.viewport, insets.value, options.inspectorWidth(), options.hidden()))
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
+
const padding = computed(() => options.padding?.() ?? 0)
|
|
23
|
+
const size = computed(() => canvas.singleViewportDraft ?? options.contentSize?.() ?? resolveSingleViewport(insetArea(area.value, padding.value), options.settings(), canvas.singleViewport.mode))
|
|
24
|
+
watch([area, size, padding], ([available, logical, gutter]) => {
|
|
22
25
|
const measured = canvas.viewport.width > 0 && canvas.viewport.height > 0
|
|
23
|
-
canvas.setSingleGeometry(measured ? available : { width: 0, height: 0 }, logical)
|
|
26
|
+
canvas.setSingleGeometry(measured ? available : { width: 0, height: 0 }, logical, gutter)
|
|
24
27
|
}, { immediate: true })
|
|
25
28
|
return { area, size,
|
|
26
29
|
/** Publish changed geometry only; frame layout watches cannot trigger a resize loop. */
|
|
@@ -57,7 +57,7 @@ sendUiEvent('histoire:ui:screenshot-list', { requestId })
|
|
|
57
57
|
<PopoverTitle>
|
|
58
58
|
Recent screenshots
|
|
59
59
|
</PopoverTitle>
|
|
60
|
-
<div class="htw:grid htw:[grid-template-columns:repeat(3,_1fr)] htw:gap-
|
|
60
|
+
<div class="htw:grid htw:[grid-template-columns:repeat(3,_1fr)] htw:gap-px htw:pt-0 htw:px-2 htw:pb-2">
|
|
61
61
|
<button v-for="file in recent" :key="file.path" type="button" role="menuitem" tabindex="-1" :aria-label="`Attach screenshot of ${catalogTargetLabel(file, snapshot.catalog)}`" :title="catalogTargetLabel(file, snapshot.catalog)" class="htw:[aspect-ratio:4_/_3] htw:p-0 htw:overflow-hidden htw:border htw:border-border htw:rounded-control htw:bg-chip htw:cursor-pointer htw:hover:border-agent htw:hover:outline-none htw:focus-visible:border-agent htw:focus-visible:outline-none" @click="emit('screenshot', file.path)">
|
|
62
62
|
<img :src="screenshotUrl(file.path)" alt="" class="htw:block htw:w-full htw:h-full htw:object-cover">
|
|
63
63
|
</button>
|
|
@@ -22,7 +22,7 @@ const emit = defineEmits<{
|
|
|
22
22
|
|
|
23
23
|
<template>
|
|
24
24
|
<!-- Pointer presses are prevented so focus never leaves the message field. -->
|
|
25
|
-
<ul :id="id" class="htw:absolute htw:[z-index:2] htw:[right:-1px] htw:[bottom:calc(100%_+_4px)] htw:[left:-1px] htw:max-h-55 htw:m-0 htw:p-1 htw:overflow-y-auto htw:list-none htw:border htw:border-border htw:rounded-control htw:bg-surface htw:shadow-panel" role="listbox" :aria-label="label" @mousedown.prevent>
|
|
25
|
+
<ul :id="id" class="htw:absolute htw:[z-index:2] htw:[right:-1px] htw:[bottom:calc(100%_+_4px)] htw:[left:-1px] htw:max-h-55 htw:m-0 htw:p-1 htw:overflow-y-auto htw:list-none htw:border htw:border-border htw:rounded-control htw:bg-surface htw:shadow-panel htw:menu-rows" role="listbox" :aria-label="label" @mousedown.prevent>
|
|
26
26
|
<li v-for="(item, index) in items" :id="`${id}-${index}`" :key="item.id" role="option" :aria-selected="index === active" class="htw:flex htw:items-center htw:gap-2 htw:min-w-0 htw:py-1.25 htw:px-2 htw:rounded-control htw:text-body htw:text-[12px] htw:cursor-pointer htw:aria-selected:bg-chip" @click="emit('pick', index)">
|
|
27
27
|
<BuiltinIcon :icon="item.icon" :size="14" class="htw:flex-none htw:text-muted" /><span class="htw:flex-none htw:font-mono">{{ item.label }}</span><span v-if="item.detail" class="htw:min-w-0 htw:overflow-hidden htw:text-muted htw:text-ellipsis htw:whitespace-nowrap">{{ item.detail }}</span>
|
|
28
28
|
</li>
|
|
@@ -26,11 +26,13 @@ function open(scope: 'story' | 'variant'): void {
|
|
|
26
26
|
|
|
27
27
|
<template>
|
|
28
28
|
<ToolbarPopover id="embed" ref="popover" :open="props.open" label="Embed" icon="code" :width="220" @update:open="emit('update:open', $event)">
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
<div class="htw:menu-rows">
|
|
30
|
+
<PopoverRow :disabled="!snapshot.selection?.variantId || !controller.available(snapshot.selection.storyId, snapshot.selection.variantId)" @click="open('variant')">
|
|
31
|
+
Embed this variant
|
|
32
|
+
</PopoverRow>
|
|
33
|
+
<PopoverRow :disabled="!snapshot.selection || !controller.available(snapshot.selection.storyId)" @click="open('story')">
|
|
34
|
+
Embed this story
|
|
35
|
+
</PopoverRow>
|
|
36
|
+
</div>
|
|
35
37
|
</ToolbarPopover>
|
|
36
38
|
</template>
|
|
@@ -92,7 +92,7 @@ function choose(value: InspectorTab): void {
|
|
|
92
92
|
<BuiltinIcon icon="chevron-down" class="htw:flex-none" :size="16" />
|
|
93
93
|
</HstButton>
|
|
94
94
|
<BasePopover v-if="open" v-model:open="open" :anchor="trigger" label="More tabs" role="menu" :width="200" :focus-last="focusLast">
|
|
95
|
-
<div @keydown="menuKey">
|
|
95
|
+
<div class="htw:menu-rows" @keydown="menuKey">
|
|
96
96
|
<MenuItem v-for="tab in menu" :key="tab.value" :label="tab.label" :icon="tab.icon" :data-histoire-contribution="getInspectorTabId(tab.value)" :class="{ 'htw:opacity-60': tab.dimmed }" @click="choose(tab.value)">
|
|
97
97
|
<component :is="tab.badge" v-if="tab.badge" />
|
|
98
98
|
<span v-else-if="tab.badgeText !== undefined" class="htw:text-muted htw:text-[13px] htw:tabular-nums">{{ tab.badgeText }}</span>
|
|
@@ -66,7 +66,7 @@ function setupInspection(api: WorkbenchPluginApi, session: HistoireSession, curr
|
|
|
66
66
|
remove = undefined
|
|
67
67
|
}
|
|
68
68
|
if (canPick && !removeTool) {
|
|
69
|
-
removeTool = api.canvas.addTool({ id: 'pick', label: 'Pick element', icon: '
|
|
69
|
+
removeTool = api.canvas.addTool({ id: 'pick', label: 'Pick element', icon: 'target', cursor: 'crosshair', available: context => typeof context.canvas.viewportToFrame === 'function', onPointerUp: (event, context) => void picker.pick(event, context), onCancel: picker.cancel, onDeactivate: picker.cancel })
|
|
70
70
|
}
|
|
71
71
|
else if (!canPick && removeTool) {
|
|
72
72
|
picker.cancel()
|
|
@@ -25,5 +25,8 @@ const ready = computed(() => !!store.page.value && store.pageView.value === prop
|
|
|
25
25
|
<p v-if="ready && ['stale', 'error'].includes(store.page.value.sources.community)" role="status" class="htw:m-0 htw:rounded-control htw:bg-chip htw:p-[12px] htw:text-[12px] htw:text-muted">
|
|
26
26
|
Community plugins unavailable<span v-if="store.page.value.sources.community === 'stale'"> · Showing saved results</span>
|
|
27
27
|
</p>
|
|
28
|
+
<p v-if="ready && store.page.value.sources.official !== 'ok'" role="status" class="htw:m-0 htw:rounded-control htw:bg-chip htw:p-[12px] htw:text-[12px] htw:text-muted">
|
|
29
|
+
{{ store.page.value.sources.official === 'stale' ? 'Showing saved official plugins' : 'Showing bundled official plugins' }}
|
|
30
|
+
</p>
|
|
28
31
|
<slot v-if="ready" />
|
|
29
32
|
</template>
|