@orion-studios/payload-studio 0.6.0-beta.125 → 0.6.0-beta.127

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.
@@ -1117,6 +1117,9 @@ var registerProjectDynamicComponents = (editor, adapter) => {
1117
1117
  },
1118
1118
  components: "",
1119
1119
  droppable: false,
1120
+ highlightable: true,
1121
+ hoverable: true,
1122
+ selectable: true,
1120
1123
  tagName: "div",
1121
1124
  traits: [
1122
1125
  ...(definition.traits || []).map((trait) => ({
@@ -1524,6 +1527,12 @@ var canvasSelectionCss = `
1524
1527
  outline-color: #c7643d !important;
1525
1528
  }
1526
1529
 
1530
+ .orion-builder-v2-selected-block {
1531
+ outline: 2px solid #c7643d !important;
1532
+ outline-offset: -2px !important;
1533
+ position: relative;
1534
+ }
1535
+
1527
1536
  .xo-builder-preview-grid {
1528
1537
  display: grid;
1529
1538
  gap: 22px;
@@ -2108,7 +2117,7 @@ function GrapesPageEditor({
2108
2117
  };
2109
2118
  const getCurrentStyleTarget = () => selectedComponentRef.current || lastSelectedComponentRef.current || (editorRef.current?.getSelected?.() || null);
2110
2119
  const findOrionBlockByElement = (element) => {
2111
- const target = element?.closest("[data-orion-block]");
2120
+ const target = element?.closest("[data-orion-block], [data-orion-component]");
2112
2121
  const targetID = target?.id || "";
2113
2122
  if (!targetID) {
2114
2123
  return null;
@@ -2116,14 +2125,14 @@ function GrapesPageEditor({
2116
2125
  const editor = editorRef.current;
2117
2126
  const wrapper = editor?.DomComponents?.getWrapper?.() || null;
2118
2127
  const component = wrapper?.find?.(`#${CSS.escape(targetID)}`)?.[0] || null;
2119
- return Object.keys(parseOrionBlockAttribute(component?.getAttributes?.()?.["data-orion-block"])).length > 0 ? component : null;
2128
+ return isOrionBlockComponent(component) ? component : null;
2120
2129
  };
2121
2130
  const findOrionBlockAncestor = (component) => {
2122
2131
  let current = component;
2123
2132
  const visited = /* @__PURE__ */ new Set();
2124
2133
  while (current && !visited.has(current)) {
2125
2134
  visited.add(current);
2126
- if (Object.keys(parseOrionBlockAttribute(current.getAttributes?.()?.["data-orion-block"])).length > 0) {
2135
+ if (isOrionBlockComponent(current)) {
2127
2136
  return current;
2128
2137
  }
2129
2138
  current = current.parent?.() || null;
@@ -2134,7 +2143,10 @@ function GrapesPageEditor({
2134
2143
  const findSelectedCanvasOrionBlock = () => {
2135
2144
  const editor = editorRef.current;
2136
2145
  const wrapper = editor?.DomComponents?.getWrapper?.() || null;
2137
- const candidates = wrapper?.find?.("[data-orion-block]") || [];
2146
+ const candidates = [
2147
+ ...wrapper?.find?.("[data-orion-block]") || [],
2148
+ ...wrapper?.find?.("[data-orion-component]") || []
2149
+ ];
2138
2150
  return candidates.find((candidate) => {
2139
2151
  const element = candidate.getEl?.();
2140
2152
  return Boolean(
@@ -2164,10 +2176,11 @@ function GrapesPageEditor({
2164
2176
  }
2165
2177
  const candidates = [
2166
2178
  ...selectedID ? wrapper.find?.(`#${selectedID}`) || [] : [],
2167
- ...wrapper.find?.("[data-orion-block]") || []
2179
+ ...wrapper.find?.("[data-orion-block]") || [],
2180
+ ...wrapper.find?.("[data-orion-component]") || []
2168
2181
  ];
2169
2182
  return candidates.find(
2170
- (candidate) => Object.keys(parseOrionBlockAttribute(candidate.getAttributes?.()?.["data-orion-block"])).length > 0
2183
+ (candidate) => isOrionBlockComponent(candidate)
2171
2184
  ) || component || selected || null;
2172
2185
  };
2173
2186
  const selectStyleManagerTarget = (component) => {
@@ -2177,6 +2190,11 @@ function GrapesPageEditor({
2177
2190
  const editor = editorRef.current;
2178
2191
  editor?.StyleManager?.select?.(component);
2179
2192
  };
2193
+ const markSelectedCanvasBlock = (component) => {
2194
+ const canvasDocument = editorRef.current?.Canvas?.getDocument?.();
2195
+ canvasDocument?.querySelectorAll(".orion-builder-v2-selected-block").forEach((element) => element.classList.remove("orion-builder-v2-selected-block"));
2196
+ component?.getEl?.()?.classList.add("orion-builder-v2-selected-block");
2197
+ };
2180
2198
  const updateSelectedItems = (updater) => {
2181
2199
  const component = getCurrentOrionBlockTarget();
2182
2200
  if (!component) {
@@ -2539,6 +2557,7 @@ function GrapesPageEditor({
2539
2557
  }
2540
2558
  hydrateSelectedTypographyStyleFromOrionBlock(component);
2541
2559
  rememberComponentSnapshot(component);
2560
+ markSelectedCanvasBlock(component);
2542
2561
  refreshSelectedState(component);
2543
2562
  window.requestAnimationFrame(() => {
2544
2563
  const element = spacingTargetForComponent(component);
@@ -2692,6 +2711,7 @@ function GrapesPageEditor({
2692
2711
  editorRef.current?.select?.(snapshot.component);
2693
2712
  selectStyleManagerTarget(snapshot.component);
2694
2713
  lastComponentSnapshotRef.current.set(snapshot.component, snapshot);
2714
+ markSelectedCanvasBlock(snapshot.component);
2695
2715
  refreshSelectedState(snapshot.component);
2696
2716
  };
2697
2717
  const restoreCustomHistoryEntry = (entry, target) => {
@@ -2706,6 +2726,17 @@ function GrapesPageEditor({
2706
2726
  }
2707
2727
  restoreComponentSnapshot(snapshot);
2708
2728
  };
2729
+ const equivalentHistoryAttributes = (before, after) => {
2730
+ const beforeBlock = parseOrionBlockAttribute(before["data-orion-block"]);
2731
+ const afterBlock = parseOrionBlockAttribute(after["data-orion-block"]);
2732
+ const beforeComparable = { ...before };
2733
+ const afterComparable = { ...after };
2734
+ if (Object.keys(beforeBlock).length > 0 && Object.keys(afterBlock).length > 0 && JSON.stringify(beforeBlock.items || []) === JSON.stringify(afterBlock.items || [])) {
2735
+ beforeComparable["data-orion-block"] = "";
2736
+ afterComparable["data-orion-block"] = "";
2737
+ }
2738
+ return JSON.stringify(beforeComparable) === JSON.stringify(afterComparable);
2739
+ };
2709
2740
  const pushCustomHistoryEntry = (before, after) => {
2710
2741
  if (!before && !after) {
2711
2742
  return;
@@ -2713,7 +2744,7 @@ function GrapesPageEditor({
2713
2744
  if (before && after && before.component !== after.component) {
2714
2745
  return;
2715
2746
  }
2716
- if (before && after && JSON.stringify(before.style) === JSON.stringify(after.style) && JSON.stringify(before.attributes) === JSON.stringify(after.attributes)) {
2747
+ if (before && after && JSON.stringify(before.style) === JSON.stringify(after.style) && equivalentHistoryAttributes(before.attributes, after.attributes)) {
2717
2748
  return;
2718
2749
  }
2719
2750
  customUndoStackRef.current.push({ after, before });
@@ -2737,6 +2768,7 @@ function GrapesPageEditor({
2737
2768
  selectedComponentRef.current = selected;
2738
2769
  lastSelectedComponentRef.current = selected;
2739
2770
  selectStyleManagerTarget(selected);
2771
+ markSelectedCanvasBlock(selected);
2740
2772
  refreshSelectedState(selected);
2741
2773
  }
2742
2774
  updateHistoryState(editor);
@@ -3046,9 +3078,11 @@ function GrapesPageEditor({
3046
3078
  editor.select?.(target);
3047
3079
  }
3048
3080
  selectStyleManagerTarget(target);
3081
+ markSelectedCanvasBlock(target);
3049
3082
  rehydrateSelectedComponentControls(target);
3050
3083
  window.setTimeout(() => {
3051
3084
  selectStyleManagerTarget(target);
3085
+ markSelectedCanvasBlock(target);
3052
3086
  rehydrateSelectedComponentControls(target);
3053
3087
  }, 120);
3054
3088
  });
@@ -3071,6 +3105,7 @@ function GrapesPageEditor({
3071
3105
  return;
3072
3106
  }
3073
3107
  selectedComponentRef.current = null;
3108
+ markSelectedCanvasBlock(null);
3074
3109
  refreshSelectedState(null);
3075
3110
  });
3076
3111
  const bindCanvasSelectionTracking = () => {
@@ -3086,6 +3121,9 @@ function GrapesPageEditor({
3086
3121
  selectedComponentRef.current = target;
3087
3122
  lastSelectedComponentRef.current = target;
3088
3123
  rememberComponentSnapshot(target);
3124
+ editor.select?.(target);
3125
+ selectStyleManagerTarget(target);
3126
+ markSelectedCanvasBlock(target);
3089
3127
  refreshSelectedState(target);
3090
3128
  };
3091
3129
  canvasDocument.addEventListener("pointerdown", trackCanvasSelection, true);
@@ -993,6 +993,9 @@ var registerProjectDynamicComponents = (editor, adapter) => {
993
993
  },
994
994
  components: "",
995
995
  droppable: false,
996
+ highlightable: true,
997
+ hoverable: true,
998
+ selectable: true,
996
999
  tagName: "div",
997
1000
  traits: [
998
1001
  ...(definition.traits || []).map((trait) => ({
@@ -1400,6 +1403,12 @@ var canvasSelectionCss = `
1400
1403
  outline-color: #c7643d !important;
1401
1404
  }
1402
1405
 
1406
+ .orion-builder-v2-selected-block {
1407
+ outline: 2px solid #c7643d !important;
1408
+ outline-offset: -2px !important;
1409
+ position: relative;
1410
+ }
1411
+
1403
1412
  .xo-builder-preview-grid {
1404
1413
  display: grid;
1405
1414
  gap: 22px;
@@ -1984,7 +1993,7 @@ function GrapesPageEditor({
1984
1993
  };
1985
1994
  const getCurrentStyleTarget = () => selectedComponentRef.current || lastSelectedComponentRef.current || (editorRef.current?.getSelected?.() || null);
1986
1995
  const findOrionBlockByElement = (element) => {
1987
- const target = element?.closest("[data-orion-block]");
1996
+ const target = element?.closest("[data-orion-block], [data-orion-component]");
1988
1997
  const targetID = target?.id || "";
1989
1998
  if (!targetID) {
1990
1999
  return null;
@@ -1992,14 +2001,14 @@ function GrapesPageEditor({
1992
2001
  const editor = editorRef.current;
1993
2002
  const wrapper = editor?.DomComponents?.getWrapper?.() || null;
1994
2003
  const component = wrapper?.find?.(`#${CSS.escape(targetID)}`)?.[0] || null;
1995
- return Object.keys(parseOrionBlockAttribute(component?.getAttributes?.()?.["data-orion-block"])).length > 0 ? component : null;
2004
+ return isOrionBlockComponent(component) ? component : null;
1996
2005
  };
1997
2006
  const findOrionBlockAncestor = (component) => {
1998
2007
  let current = component;
1999
2008
  const visited = /* @__PURE__ */ new Set();
2000
2009
  while (current && !visited.has(current)) {
2001
2010
  visited.add(current);
2002
- if (Object.keys(parseOrionBlockAttribute(current.getAttributes?.()?.["data-orion-block"])).length > 0) {
2011
+ if (isOrionBlockComponent(current)) {
2003
2012
  return current;
2004
2013
  }
2005
2014
  current = current.parent?.() || null;
@@ -2010,7 +2019,10 @@ function GrapesPageEditor({
2010
2019
  const findSelectedCanvasOrionBlock = () => {
2011
2020
  const editor = editorRef.current;
2012
2021
  const wrapper = editor?.DomComponents?.getWrapper?.() || null;
2013
- const candidates = wrapper?.find?.("[data-orion-block]") || [];
2022
+ const candidates = [
2023
+ ...wrapper?.find?.("[data-orion-block]") || [],
2024
+ ...wrapper?.find?.("[data-orion-component]") || []
2025
+ ];
2014
2026
  return candidates.find((candidate) => {
2015
2027
  const element = candidate.getEl?.();
2016
2028
  return Boolean(
@@ -2040,10 +2052,11 @@ function GrapesPageEditor({
2040
2052
  }
2041
2053
  const candidates = [
2042
2054
  ...selectedID ? wrapper.find?.(`#${selectedID}`) || [] : [],
2043
- ...wrapper.find?.("[data-orion-block]") || []
2055
+ ...wrapper.find?.("[data-orion-block]") || [],
2056
+ ...wrapper.find?.("[data-orion-component]") || []
2044
2057
  ];
2045
2058
  return candidates.find(
2046
- (candidate) => Object.keys(parseOrionBlockAttribute(candidate.getAttributes?.()?.["data-orion-block"])).length > 0
2059
+ (candidate) => isOrionBlockComponent(candidate)
2047
2060
  ) || component || selected || null;
2048
2061
  };
2049
2062
  const selectStyleManagerTarget = (component) => {
@@ -2053,6 +2066,11 @@ function GrapesPageEditor({
2053
2066
  const editor = editorRef.current;
2054
2067
  editor?.StyleManager?.select?.(component);
2055
2068
  };
2069
+ const markSelectedCanvasBlock = (component) => {
2070
+ const canvasDocument = editorRef.current?.Canvas?.getDocument?.();
2071
+ canvasDocument?.querySelectorAll(".orion-builder-v2-selected-block").forEach((element) => element.classList.remove("orion-builder-v2-selected-block"));
2072
+ component?.getEl?.()?.classList.add("orion-builder-v2-selected-block");
2073
+ };
2056
2074
  const updateSelectedItems = (updater) => {
2057
2075
  const component = getCurrentOrionBlockTarget();
2058
2076
  if (!component) {
@@ -2415,6 +2433,7 @@ function GrapesPageEditor({
2415
2433
  }
2416
2434
  hydrateSelectedTypographyStyleFromOrionBlock(component);
2417
2435
  rememberComponentSnapshot(component);
2436
+ markSelectedCanvasBlock(component);
2418
2437
  refreshSelectedState(component);
2419
2438
  window.requestAnimationFrame(() => {
2420
2439
  const element = spacingTargetForComponent(component);
@@ -2568,6 +2587,7 @@ function GrapesPageEditor({
2568
2587
  editorRef.current?.select?.(snapshot.component);
2569
2588
  selectStyleManagerTarget(snapshot.component);
2570
2589
  lastComponentSnapshotRef.current.set(snapshot.component, snapshot);
2590
+ markSelectedCanvasBlock(snapshot.component);
2571
2591
  refreshSelectedState(snapshot.component);
2572
2592
  };
2573
2593
  const restoreCustomHistoryEntry = (entry, target) => {
@@ -2582,6 +2602,17 @@ function GrapesPageEditor({
2582
2602
  }
2583
2603
  restoreComponentSnapshot(snapshot);
2584
2604
  };
2605
+ const equivalentHistoryAttributes = (before, after) => {
2606
+ const beforeBlock = parseOrionBlockAttribute(before["data-orion-block"]);
2607
+ const afterBlock = parseOrionBlockAttribute(after["data-orion-block"]);
2608
+ const beforeComparable = { ...before };
2609
+ const afterComparable = { ...after };
2610
+ if (Object.keys(beforeBlock).length > 0 && Object.keys(afterBlock).length > 0 && JSON.stringify(beforeBlock.items || []) === JSON.stringify(afterBlock.items || [])) {
2611
+ beforeComparable["data-orion-block"] = "";
2612
+ afterComparable["data-orion-block"] = "";
2613
+ }
2614
+ return JSON.stringify(beforeComparable) === JSON.stringify(afterComparable);
2615
+ };
2585
2616
  const pushCustomHistoryEntry = (before, after) => {
2586
2617
  if (!before && !after) {
2587
2618
  return;
@@ -2589,7 +2620,7 @@ function GrapesPageEditor({
2589
2620
  if (before && after && before.component !== after.component) {
2590
2621
  return;
2591
2622
  }
2592
- if (before && after && JSON.stringify(before.style) === JSON.stringify(after.style) && JSON.stringify(before.attributes) === JSON.stringify(after.attributes)) {
2623
+ if (before && after && JSON.stringify(before.style) === JSON.stringify(after.style) && equivalentHistoryAttributes(before.attributes, after.attributes)) {
2593
2624
  return;
2594
2625
  }
2595
2626
  customUndoStackRef.current.push({ after, before });
@@ -2613,6 +2644,7 @@ function GrapesPageEditor({
2613
2644
  selectedComponentRef.current = selected;
2614
2645
  lastSelectedComponentRef.current = selected;
2615
2646
  selectStyleManagerTarget(selected);
2647
+ markSelectedCanvasBlock(selected);
2616
2648
  refreshSelectedState(selected);
2617
2649
  }
2618
2650
  updateHistoryState(editor);
@@ -2922,9 +2954,11 @@ function GrapesPageEditor({
2922
2954
  editor.select?.(target);
2923
2955
  }
2924
2956
  selectStyleManagerTarget(target);
2957
+ markSelectedCanvasBlock(target);
2925
2958
  rehydrateSelectedComponentControls(target);
2926
2959
  window.setTimeout(() => {
2927
2960
  selectStyleManagerTarget(target);
2961
+ markSelectedCanvasBlock(target);
2928
2962
  rehydrateSelectedComponentControls(target);
2929
2963
  }, 120);
2930
2964
  });
@@ -2947,6 +2981,7 @@ function GrapesPageEditor({
2947
2981
  return;
2948
2982
  }
2949
2983
  selectedComponentRef.current = null;
2984
+ markSelectedCanvasBlock(null);
2950
2985
  refreshSelectedState(null);
2951
2986
  });
2952
2987
  const bindCanvasSelectionTracking = () => {
@@ -2962,6 +2997,9 @@ function GrapesPageEditor({
2962
2997
  selectedComponentRef.current = target;
2963
2998
  lastSelectedComponentRef.current = target;
2964
2999
  rememberComponentSnapshot(target);
3000
+ editor.select?.(target);
3001
+ selectStyleManagerTarget(target);
3002
+ markSelectedCanvasBlock(target);
2965
3003
  refreshSelectedState(target);
2966
3004
  };
2967
3005
  canvasDocument.addEventListener("pointerdown", trackCanvasSelection, true);
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import {
2
- admin_exports
3
- } from "./chunk-JC3UV74N.mjs";
4
1
  import {
5
2
  admin_app_exports
6
3
  } from "./chunk-RKTIFEUY.mjs";
4
+ import {
5
+ admin_exports
6
+ } from "./chunk-JC3UV74N.mjs";
7
7
  import "./chunk-W2UOCJDX.mjs";
8
8
  import {
9
9
  blocks_exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orion-studios/payload-studio",
3
- "version": "0.6.0-beta.125",
3
+ "version": "0.6.0-beta.127",
4
4
  "description": "Base CMS, builder, and custom admin toolkit for Orion Studios websites",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",