@open-press/core 0.7.1 → 1.0.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/README.md +6 -3
- package/engine/cli.mjs +8 -8
- package/engine/commands/_shared.mjs +37 -15
- package/engine/commands/dev.mjs +2 -2
- package/engine/commands/image.mjs +29 -0
- package/engine/commands/skills-sync.mjs +71 -0
- package/engine/commands/typecheck.mjs +63 -1
- package/engine/commands/upgrade.mjs +3 -3
- package/engine/document-export.mjs +1 -1
- package/engine/output/chrome-pdf.mjs +110 -3
- package/engine/output/static-server.mjs +87 -9
- package/engine/react/comment-endpoint.mjs +13 -39
- package/engine/react/comment-marker.mjs +43 -19
- package/engine/react/document-entry.mjs +46 -28
- package/engine/react/document-export.mjs +328 -164
- package/engine/react/http-json.mjs +24 -0
- package/engine/react/mdx-compile.mjs +126 -3
- package/engine/react/measurement-css.mjs +114 -1
- package/engine/react/object-entities.mjs +204 -0
- package/engine/react/pagination/allocator.mjs +48 -3
- package/engine/react/pagination.mjs +1 -1
- package/engine/react/pipeline/allocate.mjs +41 -72
- package/engine/react/pipeline/frame-measurement.mjs +6 -0
- package/engine/react/press-tree-inspection.mjs +172 -0
- package/engine/react/project-asset-endpoint.mjs +6 -24
- package/engine/react/source-edit-endpoint.d.mts +10 -0
- package/engine/react/source-edit-endpoint.mjs +75 -0
- package/engine/react/sources/mdx-resolver.mjs +13 -15
- package/engine/react/style-discovery.mjs +23 -8
- package/engine/runtime/config.d.mts +8 -0
- package/engine/runtime/config.mjs +57 -60
- package/engine/runtime/file-utils.mjs +9 -1
- package/engine/runtime/file-walk.mjs +22 -0
- package/engine/runtime/inspection.mjs +1 -20
- package/engine/runtime/page-geometry.mjs +131 -0
- package/engine/runtime/path-utils.mjs +20 -0
- package/engine/runtime/source-text-tools.d.mts +102 -0
- package/engine/runtime/source-text-tools.mjs +551 -16
- package/engine/runtime/source-workspace.mjs +16 -34
- package/engine/runtime/validation.mjs +19 -10
- package/package.json +3 -5
- package/src/openpress/app/OpenPressApp.tsx +296 -0
- package/src/openpress/{renderer.tsx → app/OpenPressRuntime.tsx} +20 -9
- package/src/openpress/app/WorkspaceGalleryPage.tsx +219 -0
- package/src/openpress/app/index.ts +2 -0
- package/src/openpress/core/Frame.tsx +26 -15
- package/src/openpress/core/FrameContext.tsx +10 -3
- package/src/openpress/core/MdxArea.tsx +11 -12
- package/src/openpress/core/Press.tsx +25 -4
- package/src/openpress/core/Workspace.tsx +36 -0
- package/src/openpress/core/cn.ts +4 -0
- package/src/openpress/core/index.tsx +11 -3
- package/src/openpress/core/primitives.tsx +74 -6
- package/src/openpress/core/types.ts +94 -41
- package/src/openpress/core/useSource.ts +1 -1
- package/src/openpress/{anchorMap.ts → document-model/anchorMapModel.ts} +1 -1
- package/src/openpress/{indexes.ts → document-model/documentIndexes.ts} +1 -1
- package/src/openpress/{types.ts → document-model/documentTypes.ts} +51 -0
- package/src/openpress/document-model/index.ts +7 -0
- package/src/openpress/document-model/objectEntityModel.ts +55 -0
- package/src/openpress/{projectIdentity.ts → document-model/projectIdentityModel.ts} +1 -1
- package/src/openpress/{reactDocumentMetadata.ts → document-model/reactDocumentMetadataModel.ts} +1 -1
- package/src/openpress/document-model/workspaceManifestModel.ts +57 -0
- package/src/openpress/manuscript/index.tsx +49 -7
- package/src/openpress/mdx/index.ts +15 -7
- package/src/openpress/reader/PageThumbnailsPanel.tsx +168 -0
- package/src/openpress/{publicPage.tsx → reader/PublicReaderPage.tsx} +31 -51
- package/src/openpress/{workbenchPanels.tsx → reader/ReaderNavigationPanel.tsx} +6 -5
- package/src/openpress/reader/index.ts +11 -0
- package/src/openpress/reader/pageViewportScaleModel.ts +73 -0
- package/src/openpress/reader/readerTypes.ts +4 -0
- package/src/openpress/reader/usePageViewportScale.ts +119 -0
- package/src/openpress/reader/usePanelState.ts +56 -0
- package/src/openpress/reader/useReaderHashSync.ts +61 -0
- package/src/openpress/reader/useReaderKeyboardNav.ts +48 -0
- package/src/openpress/reader/useReaderRuntime.ts +146 -0
- package/src/openpress/reader/useReaderScrollAnchor.ts +64 -0
- package/src/openpress/shared/Panel.tsx +77 -0
- package/src/openpress/shared/index.ts +4 -0
- package/src/openpress/shared/numberUtils.ts +3 -0
- package/src/openpress/{runtimeMode.ts → shared/runtimeMode.ts} +0 -11
- package/src/openpress/workbench/Workbench.tsx +506 -0
- package/src/openpress/workbench/actions/DeploymentControl.tsx +157 -0
- package/src/openpress/workbench/actions/ExportImageControl.tsx +96 -0
- package/src/openpress/workbench/actions/PageZoomControl.tsx +182 -0
- package/src/openpress/workbench/actions/SearchControl.tsx +345 -0
- package/src/openpress/workbench/actions/deploymentStatusModel.ts +112 -0
- package/src/openpress/workbench/actions/index.ts +6 -0
- package/src/openpress/workbench/actions/useDeploymentWorkbench.ts +136 -0
- package/src/openpress/workbench/dialog/WorkbenchDialog.tsx +72 -0
- package/src/openpress/workbench/dialog/index.ts +1 -0
- package/src/openpress/workbench/document/components/DocumentPanel.tsx +127 -0
- package/src/openpress/workbench/document/components/InlineSourceEditorLayer.tsx +207 -0
- package/src/openpress/workbench/document/components/ReaderStage.tsx +9 -0
- package/src/openpress/workbench/document/hooks/useDocumentWorkbenchModel.ts +34 -0
- package/src/openpress/workbench/document/hooks/useInlineDocumentEditor.ts +525 -0
- package/src/openpress/workbench/document/index.ts +10 -0
- package/src/openpress/workbench/index.ts +2 -0
- package/src/openpress/workbench/inspector/InlineInspectorLayer.tsx +459 -0
- package/src/openpress/workbench/inspector/index.ts +5 -0
- package/src/openpress/workbench/inspector/inlineCommentModel.ts +125 -0
- package/src/openpress/workbench/inspector/inspectorGeometryModel.ts +160 -0
- package/src/openpress/workbench/inspector/inspectorModel.ts +408 -0
- package/src/openpress/workbench/inspector/useInspectorComments.ts +254 -0
- package/src/openpress/workbench/mentions/MentionSuggestionList.tsx +41 -0
- package/src/openpress/workbench/mentions/index.ts +2 -0
- package/src/openpress/{composerMentions.ts → workbench/mentions/useComposerMentions.ts} +1 -4
- package/src/openpress/workbench/panels/Panel.tsx +1 -0
- package/src/openpress/workbench/panels/PendingCommentsPanel.tsx +80 -0
- package/src/openpress/workbench/panels/WorkbenchControlPanel.tsx +29 -0
- package/src/openpress/workbench/panels/index.ts +3 -0
- package/src/openpress/workbench/project/ProjectEntryPanel.tsx +525 -0
- package/src/openpress/workbench/project/ProjectPreviewDialog.tsx +35 -0
- package/src/openpress/workbench/project/index.ts +2 -0
- package/src/openpress/workbench/project/projectPreviewTypes.ts +11 -0
- package/src/openpress/workbench/shell/WorkbenchShell.tsx +167 -0
- package/src/openpress/workbench/shell/index.ts +1 -0
- package/src/openpress/workbench/workbenchFormatters.ts +120 -0
- package/src/openpress/workbench/workbenchTypes.ts +35 -0
- package/src/styles/openpress/print-route.css +0 -2
- package/src/styles/openpress/{project-workspace.css → project-preview-panel.css} +13 -407
- package/src/styles/openpress/public-viewer.css +25 -320
- package/src/styles/openpress/reader-runtime.css +252 -55
- package/src/styles/openpress/responsive.css +145 -270
- package/src/styles/openpress/workbench-panels.css +327 -178
- package/src/styles/openpress/workbench.css +986 -451
- package/src/styles/openpress/workspace-gallery.css +300 -0
- package/src/styles/openpress.css +2 -1
- package/tsconfig.json +1 -1
- package/vite.config.ts +50 -0
- package/engine/commands/init.mjs +0 -24
- package/engine/init.mjs +0 -90
- package/src/openpress/App.tsx +0 -127
- package/src/openpress/inspector.ts +0 -282
- package/src/openpress/projectWorkspace.tsx +0 -919
- package/src/openpress/readerRuntime.ts +0 -230
- package/src/openpress/workbench.tsx +0 -1265
- package/src/openpress/workbenchTypes.ts +0 -4
- /package/src/openpress/{readerPageRegistry.ts → reader/readerPageRegistry.ts} +0 -0
- /package/src/openpress/{pageRoute.ts → reader/readerPageRoute.ts} +0 -0
- /package/src/openpress/{readerScroll.ts → reader/readerScroll.ts} +0 -0
- /package/src/openpress/{readerState.ts → reader/readerStateModel.ts} +0 -0
- /package/src/openpress/{frameScheduler.ts → shared/frameScheduler.ts} +0 -0
- /package/src/openpress/{projectSources.ts → workbench/project/projectSourceModel.ts} +0 -0
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo, useState, type MouseEvent as ReactMouseEvent } from "react";
|
|
2
|
-
import { getSourceBlockMap } from "./reactDocumentMetadata";
|
|
3
|
-
import type { ReaderDocument, SourceBlock } from "./types";
|
|
4
|
-
|
|
5
|
-
const DEFAULT_INSPECTOR_STORAGE_KEY = "openpress:inspector-mode";
|
|
6
|
-
|
|
7
|
-
export type InspectorIntent = "edit" | "delete" | "add";
|
|
8
|
-
export type InspectorPlacement = "block" | "before";
|
|
9
|
-
|
|
10
|
-
export interface InspectorTarget {
|
|
11
|
-
blockId: string;
|
|
12
|
-
placement: InspectorPlacement;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface InspectorState {
|
|
16
|
-
enabled: boolean;
|
|
17
|
-
inspectorMode: boolean;
|
|
18
|
-
selectedBlockId: string | null;
|
|
19
|
-
selectedBlock: SourceBlock | null;
|
|
20
|
-
selectedTarget: InspectorTarget | null;
|
|
21
|
-
commentIntent: InspectorIntent;
|
|
22
|
-
setInspectorMode: (enabled: boolean) => void;
|
|
23
|
-
toggleInspectorMode: () => void;
|
|
24
|
-
setCommentIntent: (intent: InspectorIntent) => void;
|
|
25
|
-
selectTarget: (target: InspectorTarget | null) => SourceBlock | null;
|
|
26
|
-
inspectTarget: (target: EventTarget | null) => SourceBlock | null;
|
|
27
|
-
handleClick: (event: ReactMouseEvent) => boolean;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface InspectorCommentResult {
|
|
31
|
-
ok: boolean;
|
|
32
|
-
comment?: {
|
|
33
|
-
id?: string;
|
|
34
|
-
timestamp?: string;
|
|
35
|
-
path?: string;
|
|
36
|
-
line?: number;
|
|
37
|
-
note?: string;
|
|
38
|
-
hint?: string;
|
|
39
|
-
};
|
|
40
|
-
message?: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface PendingComment {
|
|
44
|
-
id: string;
|
|
45
|
-
timestamp?: string;
|
|
46
|
-
path: string;
|
|
47
|
-
absolutePath?: string;
|
|
48
|
-
line: number;
|
|
49
|
-
marker?: string;
|
|
50
|
-
note: string;
|
|
51
|
-
hint?: string;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface CommentListResult {
|
|
55
|
-
ok: boolean;
|
|
56
|
-
comments?: PendingComment[];
|
|
57
|
-
message?: string;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface CommentClearResult {
|
|
61
|
-
ok: boolean;
|
|
62
|
-
removedCount: number;
|
|
63
|
-
comments?: PendingComment[];
|
|
64
|
-
message?: string;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export async function submitInspectorComment({
|
|
68
|
-
block,
|
|
69
|
-
note,
|
|
70
|
-
intent,
|
|
71
|
-
placement,
|
|
72
|
-
endpoint = "/__openpress/comment",
|
|
73
|
-
fetchImpl = globalThis.fetch?.bind(globalThis),
|
|
74
|
-
}: {
|
|
75
|
-
block: SourceBlock | null;
|
|
76
|
-
note: string;
|
|
77
|
-
intent?: InspectorIntent;
|
|
78
|
-
placement?: InspectorPlacement;
|
|
79
|
-
endpoint?: string;
|
|
80
|
-
fetchImpl?: typeof fetch;
|
|
81
|
-
}): Promise<InspectorCommentResult> {
|
|
82
|
-
if (!block) throw new Error("OpenPress inspector comment requires a selected block.");
|
|
83
|
-
const normalizedNote = note.trim();
|
|
84
|
-
if (!normalizedNote) throw new Error("OpenPress inspector comment note must not be empty.");
|
|
85
|
-
if (!block.path || !block.source?.line) throw new Error("OpenPress inspector selected block has no editable source location.");
|
|
86
|
-
if (typeof fetchImpl !== "function") throw new Error("OpenPress inspector comment endpoint is unavailable.");
|
|
87
|
-
|
|
88
|
-
const response = await fetchImpl(endpoint, {
|
|
89
|
-
method: "POST",
|
|
90
|
-
headers: { "Content-Type": "application/json" },
|
|
91
|
-
body: JSON.stringify({
|
|
92
|
-
target: {
|
|
93
|
-
blockId: block.id,
|
|
94
|
-
path: block.path,
|
|
95
|
-
source: block.source,
|
|
96
|
-
},
|
|
97
|
-
note: normalizedNote,
|
|
98
|
-
hint: formatInspectorHint({ intent, placement }),
|
|
99
|
-
}),
|
|
100
|
-
});
|
|
101
|
-
const result = await response.json().catch(() => null) as InspectorCommentResult | null;
|
|
102
|
-
if (!response.ok) {
|
|
103
|
-
throw new Error(result?.message ?? `OpenPress inspector comment failed with status ${response.status}`);
|
|
104
|
-
}
|
|
105
|
-
return result ?? { ok: true };
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export async function fetchInspectorComments({
|
|
109
|
-
endpoint = "/__openpress/comment",
|
|
110
|
-
fetchImpl = globalThis.fetch?.bind(globalThis),
|
|
111
|
-
}: {
|
|
112
|
-
endpoint?: string;
|
|
113
|
-
fetchImpl?: typeof fetch;
|
|
114
|
-
} = {}): Promise<PendingComment[]> {
|
|
115
|
-
if (typeof fetchImpl !== "function") throw new Error("OpenPress inspector comment endpoint is unavailable.");
|
|
116
|
-
|
|
117
|
-
const response = await fetchImpl(endpoint, { method: "GET" });
|
|
118
|
-
const result = await response.json().catch(() => null) as CommentListResult | null;
|
|
119
|
-
if (!response.ok) {
|
|
120
|
-
throw new Error(result?.message ?? `OpenPress inspector comment list failed with status ${response.status}`);
|
|
121
|
-
}
|
|
122
|
-
return Array.isArray(result?.comments) ? result.comments : [];
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export async function clearInspectorComment({
|
|
126
|
-
id,
|
|
127
|
-
all = false,
|
|
128
|
-
endpoint = "/__openpress/comment",
|
|
129
|
-
fetchImpl = globalThis.fetch?.bind(globalThis),
|
|
130
|
-
}: {
|
|
131
|
-
id?: string;
|
|
132
|
-
all?: boolean;
|
|
133
|
-
endpoint?: string;
|
|
134
|
-
fetchImpl?: typeof fetch;
|
|
135
|
-
} = {}): Promise<CommentClearResult> {
|
|
136
|
-
if (typeof fetchImpl !== "function") throw new Error("OpenPress inspector comment endpoint is unavailable.");
|
|
137
|
-
if (!all && !id) throw new Error("OpenPress inspector comment clear requires an id or all=true.");
|
|
138
|
-
|
|
139
|
-
const response = await fetchImpl(endpoint, {
|
|
140
|
-
method: "DELETE",
|
|
141
|
-
headers: { "Content-Type": "application/json" },
|
|
142
|
-
body: JSON.stringify(all ? { all: true } : { id }),
|
|
143
|
-
});
|
|
144
|
-
const result = await response.json().catch(() => null) as CommentClearResult | null;
|
|
145
|
-
if (!response.ok) {
|
|
146
|
-
throw new Error(result?.message ?? `OpenPress inspector comment clear failed with status ${response.status}`);
|
|
147
|
-
}
|
|
148
|
-
return result ?? { ok: true, removedCount: 0 };
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export async function updateInspectorComment({
|
|
152
|
-
id,
|
|
153
|
-
note,
|
|
154
|
-
intent,
|
|
155
|
-
placement,
|
|
156
|
-
endpoint = "/__openpress/comment",
|
|
157
|
-
fetchImpl = globalThis.fetch?.bind(globalThis),
|
|
158
|
-
}: {
|
|
159
|
-
id: string;
|
|
160
|
-
note: string;
|
|
161
|
-
intent?: InspectorIntent;
|
|
162
|
-
placement?: InspectorPlacement;
|
|
163
|
-
endpoint?: string;
|
|
164
|
-
fetchImpl?: typeof fetch;
|
|
165
|
-
}): Promise<InspectorCommentResult> {
|
|
166
|
-
const normalizedNote = note.trim();
|
|
167
|
-
if (!id.trim()) throw new Error("OpenPress inspector comment update requires an id.");
|
|
168
|
-
if (!normalizedNote) throw new Error("OpenPress inspector comment note must not be empty.");
|
|
169
|
-
if (typeof fetchImpl !== "function") throw new Error("OpenPress inspector comment endpoint is unavailable.");
|
|
170
|
-
|
|
171
|
-
const response = await fetchImpl(endpoint, {
|
|
172
|
-
method: "PATCH",
|
|
173
|
-
headers: { "Content-Type": "application/json" },
|
|
174
|
-
body: JSON.stringify({
|
|
175
|
-
id,
|
|
176
|
-
note: normalizedNote,
|
|
177
|
-
hint: formatInspectorHint({ intent, placement }),
|
|
178
|
-
}),
|
|
179
|
-
});
|
|
180
|
-
const result = await response.json().catch(() => null) as InspectorCommentResult | null;
|
|
181
|
-
if (!response.ok) {
|
|
182
|
-
throw new Error(result?.message ?? `OpenPress inspector comment update failed with status ${response.status}`);
|
|
183
|
-
}
|
|
184
|
-
return result ?? { ok: true };
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export function useInspector(
|
|
188
|
-
document: ReaderDocument,
|
|
189
|
-
{
|
|
190
|
-
enabled = false,
|
|
191
|
-
storageKey = DEFAULT_INSPECTOR_STORAGE_KEY,
|
|
192
|
-
}: {
|
|
193
|
-
enabled?: boolean;
|
|
194
|
-
storageKey?: string;
|
|
195
|
-
} = {},
|
|
196
|
-
): InspectorState {
|
|
197
|
-
const blockMap = useMemo(() => getSourceBlockMap(document), [document]);
|
|
198
|
-
const [inspectorMode, setInspectorModeState] = useState(() => {
|
|
199
|
-
if (!enabled || typeof window === "undefined") return false;
|
|
200
|
-
return window.localStorage.getItem(storageKey) === "on";
|
|
201
|
-
});
|
|
202
|
-
const [selectedTarget, setSelectedTarget] = useState<InspectorTarget | null>(null);
|
|
203
|
-
const [commentIntent, setCommentIntent] = useState<InspectorIntent>("edit");
|
|
204
|
-
|
|
205
|
-
useEffect(() => {
|
|
206
|
-
if (!enabled && inspectorMode) setInspectorModeState(false);
|
|
207
|
-
}, [enabled, inspectorMode]);
|
|
208
|
-
|
|
209
|
-
const setInspectorMode = useCallback((nextEnabled: boolean) => {
|
|
210
|
-
setInspectorModeState(nextEnabled);
|
|
211
|
-
if (typeof window !== "undefined") {
|
|
212
|
-
window.localStorage.setItem(storageKey, nextEnabled ? "on" : "off");
|
|
213
|
-
}
|
|
214
|
-
if (!nextEnabled) setSelectedTarget(null);
|
|
215
|
-
}, [storageKey]);
|
|
216
|
-
|
|
217
|
-
const selectTarget = useCallback((target: InspectorTarget | null) => {
|
|
218
|
-
setSelectedTarget(target);
|
|
219
|
-
if (!target) return null;
|
|
220
|
-
setCommentIntent(target.placement === "before" ? "add" : "edit");
|
|
221
|
-
const sourceBlock = blockMap[target.blockId] ?? null;
|
|
222
|
-
return sourceBlock;
|
|
223
|
-
}, [blockMap]);
|
|
224
|
-
|
|
225
|
-
const inspectTarget = useCallback((target: EventTarget | null) => {
|
|
226
|
-
const inspectorTarget = findInspectorTarget(target);
|
|
227
|
-
return selectTarget(inspectorTarget);
|
|
228
|
-
}, [selectTarget]);
|
|
229
|
-
|
|
230
|
-
const handleClick = useCallback((event: ReactMouseEvent) => {
|
|
231
|
-
if (!enabled || !inspectorMode) return false;
|
|
232
|
-
const inspectorTarget = findInspectorTarget(event.target);
|
|
233
|
-
if (!inspectorTarget) return false;
|
|
234
|
-
selectTarget(inspectorTarget);
|
|
235
|
-
event.preventDefault();
|
|
236
|
-
event.stopPropagation();
|
|
237
|
-
return true;
|
|
238
|
-
}, [enabled, inspectorMode, selectTarget]);
|
|
239
|
-
|
|
240
|
-
const selectedBlockId = selectedTarget?.blockId ?? null;
|
|
241
|
-
const selectedBlock = selectedBlockId ? (blockMap[selectedBlockId] ?? null) : null;
|
|
242
|
-
|
|
243
|
-
return {
|
|
244
|
-
enabled,
|
|
245
|
-
inspectorMode: enabled && inspectorMode,
|
|
246
|
-
selectedBlockId,
|
|
247
|
-
selectedBlock,
|
|
248
|
-
selectedTarget,
|
|
249
|
-
commentIntent,
|
|
250
|
-
setInspectorMode,
|
|
251
|
-
toggleInspectorMode: () => setInspectorMode(!inspectorMode),
|
|
252
|
-
setCommentIntent,
|
|
253
|
-
selectTarget,
|
|
254
|
-
inspectTarget,
|
|
255
|
-
handleClick,
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
export function findInspectorTarget(target: EventTarget | null): InspectorTarget | null {
|
|
260
|
-
if (typeof Element === "undefined") return null;
|
|
261
|
-
if (!(target instanceof Element)) return null;
|
|
262
|
-
const insertTarget = target.closest<HTMLElement>("[data-openpress-insert-before-block-id]");
|
|
263
|
-
const insertBeforeBlockId = insertTarget?.dataset.openpressInsertBeforeBlockId;
|
|
264
|
-
if (insertBeforeBlockId) return { blockId: insertBeforeBlockId, placement: "before" };
|
|
265
|
-
|
|
266
|
-
const element = target.closest<HTMLElement>("[data-openpress-block-id]");
|
|
267
|
-
const blockId = element?.dataset.openpressBlockId;
|
|
268
|
-
return blockId ? { blockId, placement: "block" } : null;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
export function formatInspectorHint({
|
|
272
|
-
intent,
|
|
273
|
-
placement,
|
|
274
|
-
}: {
|
|
275
|
-
intent?: InspectorIntent;
|
|
276
|
-
placement?: InspectorPlacement;
|
|
277
|
-
} = {}) {
|
|
278
|
-
const parts = ["openpress-react-inspector"];
|
|
279
|
-
if (intent) parts.push(`intent=${intent}`);
|
|
280
|
-
if (placement) parts.push(`placement=${placement}`);
|
|
281
|
-
return parts.join(" ");
|
|
282
|
-
}
|