mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-10 12:28:12 +00:00
feat(studio): route element delete through SDK removeElement (§3.1) (#1465)
Co-authored-by: Miguel Ángel <miguel07alm@protonmail.com>
This commit is contained in:
co-authored by
Miguel Ángel
parent
8585fffc92
commit
bce571c2a1
@@ -26,6 +26,8 @@ interface UseElementLifecycleOpsParams {
|
||||
projectIdRef: React.MutableRefObject<string | null>;
|
||||
reloadPreview: () => void;
|
||||
clearDomSelection: () => void;
|
||||
/** Route delete through SDK when session resolves the hf-id; returns true if handled. */
|
||||
onTrySdkDelete?: (hfId: string, originalContent: string, targetPath: string) => Promise<boolean>;
|
||||
commitPositionPatchToHtml: (
|
||||
selection: DomEditSelection,
|
||||
patches: PatchOperation[],
|
||||
@@ -44,6 +46,7 @@ export function useElementLifecycleOps({
|
||||
projectIdRef,
|
||||
reloadPreview,
|
||||
clearDomSelection,
|
||||
onTrySdkDelete,
|
||||
commitPositionPatchToHtml,
|
||||
onElementDeleted,
|
||||
}: UseElementLifecycleOpsParams) {
|
||||
@@ -74,6 +77,16 @@ export function useElementLifecycleOps({
|
||||
throw new Error("Selected element has no patchable target");
|
||||
}
|
||||
|
||||
if (onTrySdkDelete && selection.hfId) {
|
||||
const handled = await onTrySdkDelete(selection.hfId, originalContent, targetPath);
|
||||
if (handled) {
|
||||
clearDomSelection();
|
||||
usePlayerStore.getState().setSelectedElementId(null);
|
||||
showToast(`Deleted ${label}. Use Undo to restore it.`, "info");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
domEditSaveTimestampRef.current = Date.now();
|
||||
const removeResponse = await fetch(
|
||||
`/api/projects/${pid}/file-mutations/remove-element/${encodeURIComponent(targetPath)}`,
|
||||
@@ -118,6 +131,7 @@ export function useElementLifecycleOps({
|
||||
clearDomSelection,
|
||||
domEditSaveTimestampRef,
|
||||
editHistory.recordEdit,
|
||||
onTrySdkDelete,
|
||||
onElementDeleted,
|
||||
projectIdRef,
|
||||
reloadPreview,
|
||||
@@ -126,6 +140,9 @@ export function useElementLifecycleOps({
|
||||
],
|
||||
);
|
||||
|
||||
// ponytail: z-index reorder writes inline-style patches via commitPositionPatchToHtml →
|
||||
// persistDomEditOperations → onTrySdkPersist, so it is already SDK-cut-over as setStyle.
|
||||
// No SDK reorder/reparent op exists; DOM sibling order stays server-authoritative if ever needed.
|
||||
const handleDomZIndexReorderCommit = useCallback(
|
||||
(
|
||||
entries: Array<{
|
||||
|
||||
Reference in New Issue
Block a user