@orion-studios/payload-studio 0.5.0-beta.106 → 0.5.0-beta.107
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.
|
@@ -2114,6 +2114,7 @@ function BlockFrame({
|
|
|
2114
2114
|
}) {
|
|
2115
2115
|
const [dropPosition, setDropPosition] = (0, import_react5.useState)(null);
|
|
2116
2116
|
const [dropHovered, setDropHovered] = (0, import_react5.useState)(false);
|
|
2117
|
+
const frameRef = (0, import_react5.useRef)(null);
|
|
2117
2118
|
const isDragging = dragIndex === index;
|
|
2118
2119
|
const isAnyDragging = dragIndex !== null;
|
|
2119
2120
|
const isDropTarget = dragIndex !== null && dragIndex !== index && dropPosition !== null;
|
|
@@ -2128,6 +2129,7 @@ function BlockFrame({
|
|
|
2128
2129
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2129
2130
|
"div",
|
|
2130
2131
|
{
|
|
2132
|
+
ref: frameRef,
|
|
2131
2133
|
onClick: onSelect,
|
|
2132
2134
|
onDragEnter: (event) => {
|
|
2133
2135
|
if (dragIndex === null || dragIndex === index) {
|
|
@@ -2160,7 +2162,6 @@ function BlockFrame({
|
|
|
2160
2162
|
setDropPosition(position);
|
|
2161
2163
|
}
|
|
2162
2164
|
},
|
|
2163
|
-
onDragStart: () => setDragIndex(index),
|
|
2164
2165
|
onDrop: (event) => {
|
|
2165
2166
|
event.preventDefault();
|
|
2166
2167
|
if (dragIndex === null) {
|
|
@@ -2270,6 +2271,14 @@ function BlockFrame({
|
|
|
2270
2271
|
},
|
|
2271
2272
|
onDragStart: (event) => {
|
|
2272
2273
|
event.stopPropagation();
|
|
2274
|
+
if (event.dataTransfer && frameRef.current) {
|
|
2275
|
+
const rect = frameRef.current.getBoundingClientRect();
|
|
2276
|
+
const offsetX = Math.max(0, Math.min(rect.width, event.clientX - rect.left));
|
|
2277
|
+
const offsetY = Math.max(0, Math.min(rect.height, event.clientY - rect.top));
|
|
2278
|
+
event.dataTransfer.effectAllowed = "move";
|
|
2279
|
+
event.dataTransfer.setData("text/plain", label);
|
|
2280
|
+
event.dataTransfer.setDragImage(frameRef.current, offsetX, offsetY);
|
|
2281
|
+
}
|
|
2273
2282
|
onSelect();
|
|
2274
2283
|
setDragIndex(index);
|
|
2275
2284
|
},
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "../chunk-ROTPP5CU.mjs";
|
|
7
7
|
|
|
8
8
|
// src/studio-pages/builder/BuilderPageEditor.tsx
|
|
9
|
-
import { useCallback, useEffect as useEffect5, useMemo as useMemo2, useRef as
|
|
9
|
+
import { useCallback, useEffect as useEffect5, useMemo as useMemo2, useRef as useRef3, useState as useState6 } from "react";
|
|
10
10
|
|
|
11
11
|
// src/blocks/blocks/sectionStyleFields.ts
|
|
12
12
|
var sectionStyleDefaults = {
|
|
@@ -1980,7 +1980,7 @@ function UploadOverlay({ label = "Uploading image..." }) {
|
|
|
1980
1980
|
}
|
|
1981
1981
|
|
|
1982
1982
|
// src/studio-pages/builder/ui/BlockFrame.tsx
|
|
1983
|
-
import { useEffect as useEffect4, useState as useState5 } from "react";
|
|
1983
|
+
import { useEffect as useEffect4, useRef as useRef2, useState as useState5 } from "react";
|
|
1984
1984
|
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1985
1985
|
function BlockFrame({
|
|
1986
1986
|
children,
|
|
@@ -1994,6 +1994,7 @@ function BlockFrame({
|
|
|
1994
1994
|
}) {
|
|
1995
1995
|
const [dropPosition, setDropPosition] = useState5(null);
|
|
1996
1996
|
const [dropHovered, setDropHovered] = useState5(false);
|
|
1997
|
+
const frameRef = useRef2(null);
|
|
1997
1998
|
const isDragging = dragIndex === index;
|
|
1998
1999
|
const isAnyDragging = dragIndex !== null;
|
|
1999
2000
|
const isDropTarget = dragIndex !== null && dragIndex !== index && dropPosition !== null;
|
|
@@ -2008,6 +2009,7 @@ function BlockFrame({
|
|
|
2008
2009
|
return /* @__PURE__ */ jsxs6(
|
|
2009
2010
|
"div",
|
|
2010
2011
|
{
|
|
2012
|
+
ref: frameRef,
|
|
2011
2013
|
onClick: onSelect,
|
|
2012
2014
|
onDragEnter: (event) => {
|
|
2013
2015
|
if (dragIndex === null || dragIndex === index) {
|
|
@@ -2040,7 +2042,6 @@ function BlockFrame({
|
|
|
2040
2042
|
setDropPosition(position);
|
|
2041
2043
|
}
|
|
2042
2044
|
},
|
|
2043
|
-
onDragStart: () => setDragIndex(index),
|
|
2044
2045
|
onDrop: (event) => {
|
|
2045
2046
|
event.preventDefault();
|
|
2046
2047
|
if (dragIndex === null) {
|
|
@@ -2150,6 +2151,14 @@ function BlockFrame({
|
|
|
2150
2151
|
},
|
|
2151
2152
|
onDragStart: (event) => {
|
|
2152
2153
|
event.stopPropagation();
|
|
2154
|
+
if (event.dataTransfer && frameRef.current) {
|
|
2155
|
+
const rect = frameRef.current.getBoundingClientRect();
|
|
2156
|
+
const offsetX = Math.max(0, Math.min(rect.width, event.clientX - rect.left));
|
|
2157
|
+
const offsetY = Math.max(0, Math.min(rect.height, event.clientY - rect.top));
|
|
2158
|
+
event.dataTransfer.effectAllowed = "move";
|
|
2159
|
+
event.dataTransfer.setData("text/plain", label);
|
|
2160
|
+
event.dataTransfer.setDragImage(frameRef.current, offsetX, offsetY);
|
|
2161
|
+
}
|
|
2153
2162
|
onSelect();
|
|
2154
2163
|
setDragIndex(index);
|
|
2155
2164
|
},
|
|
@@ -3991,7 +4000,7 @@ function BuilderPageEditor({
|
|
|
3991
4000
|
renderBlockPreview,
|
|
3992
4001
|
siteThemeTokens
|
|
3993
4002
|
}) {
|
|
3994
|
-
const editorRootRef =
|
|
4003
|
+
const editorRootRef = useRef3(null);
|
|
3995
4004
|
const doc = initialDoc ?? {};
|
|
3996
4005
|
const sourceStudioDocument = doc.studioDocument && typeof doc.studioDocument === "object" ? doc.studioDocument : {};
|
|
3997
4006
|
const sourceMetadata = sourceStudioDocument.metadata && typeof sourceStudioDocument.metadata === "object" ? sourceStudioDocument.metadata : {};
|
|
@@ -4029,12 +4038,12 @@ function BuilderPageEditor({
|
|
|
4029
4038
|
const [settingsPanelMode, setSettingsPanelMode] = useState6("basic");
|
|
4030
4039
|
const [settingsSearchQuery, setSettingsSearchQuery] = useState6("");
|
|
4031
4040
|
const { activeSidebarPanel, setActiveSidebarPanel } = usePersistentSidebarPanel(pageID);
|
|
4032
|
-
const historyBypassRef =
|
|
4033
|
-
const previousSnapshotRef =
|
|
4041
|
+
const historyBypassRef = useRef3(true);
|
|
4042
|
+
const previousSnapshotRef = useRef3({
|
|
4034
4043
|
layout: migrateLayoutToSettingsV2(cloneBlockLayout(initialLayout).map((block) => withSectionStyleDefaults2(block))),
|
|
4035
4044
|
pageDefaults: clonePageDefaults(initialPageDefaults)
|
|
4036
4045
|
});
|
|
4037
|
-
const lastSavedRef =
|
|
4046
|
+
const lastSavedRef = useRef3(cloneSnapshot(previousSnapshotRef.current));
|
|
4038
4047
|
const selectedBlock = useMemo2(
|
|
4039
4048
|
() => selectedIndex !== null ? layout[selectedIndex] : null,
|
|
4040
4049
|
[layout, selectedIndex]
|