@orion-studios/payload-studio 0.6.0-beta.178 → 0.6.0-beta.179

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.
@@ -1909,7 +1909,8 @@ var normalizeCssColorValue = (value) => {
1909
1909
  return "";
1910
1910
  }
1911
1911
  const trimmed = value.trim();
1912
- return trimmed && trimmed !== "none" ? trimmed : "";
1912
+ const normalized = trimmed.toLowerCase();
1913
+ return trimmed && normalized !== "none" && normalized !== "transparent" && normalized !== "rgba(0, 0, 0, 0)" ? trimmed : "";
1913
1914
  };
1914
1915
  var getStyleColorValue = (style, property) => normalizeCssColorValue(
1915
1916
  style[property] || style[property.replace(/-([a-z])/g, (_, char) => char.toUpperCase())]
@@ -2026,6 +2027,32 @@ var negativePaddingVariableForSide = (side) => `--orion-negative-padding-${side}
2026
2027
  var negativePaddingBackgroundAttribute = "data-orion-negative-padding-background";
2027
2028
  var negativePaddingBackgroundVariable = "--orion-negative-padding-background";
2028
2029
  var hasNegativePaddingState = (attrs, style) => negativePaddingSides.some((side) => Boolean(attrs[negativePaddingAttributeForSide(side)] || style[negativePaddingVariableForSide(side)]));
2030
+ var removeGeneratedSelectionMargins = (component) => {
2031
+ const style = component?.getStyle?.() || {};
2032
+ const cleanup = {};
2033
+ ["margin-top", "margin-bottom"].forEach((property) => {
2034
+ const value = String(style[property] || "").trim();
2035
+ if (value === "-2px" || value === "-2") {
2036
+ cleanup[property] = "";
2037
+ }
2038
+ });
2039
+ if (Object.keys(cleanup).length > 0) {
2040
+ component?.addStyle?.(cleanup);
2041
+ }
2042
+ };
2043
+ var removeGeneratedNegativePaddingMargin = (component, side, negativePaddingValue) => {
2044
+ if (side !== "top" && side !== "bottom") {
2045
+ return;
2046
+ }
2047
+ const property = `margin-${side}`;
2048
+ const style = component?.getStyle?.() || {};
2049
+ const currentMargin = String(style[property] || "").trim();
2050
+ const generatedMargin = String(negativePaddingValue || "").trim();
2051
+ if (generatedMargin && currentMargin === generatedMargin) {
2052
+ component?.addStyle?.({ [property]: "" });
2053
+ writeStylePanelLength(property, "0px");
2054
+ }
2055
+ };
2029
2056
  var getStoredOrionBackgroundColor = (attrs, style) => {
2030
2057
  const block = parseOrionBlockAttribute(attrs["data-orion-block"]);
2031
2058
  return firstString(
@@ -2620,10 +2647,12 @@ function GrapesPageEditor({
2620
2647
  selectedComponentRef.current = selected;
2621
2648
  lastSelectedComponentRef.current = selected;
2622
2649
  if (property.startsWith("padding-") && !String(value).trim().startsWith("-")) {
2650
+ removeGeneratedSelectionMargins(selected);
2623
2651
  const side = negativePaddingSideFromProperty(property);
2624
2652
  if (side) {
2625
2653
  const attrs = selected.getAttributes?.() || {};
2626
2654
  const selectedStyle = selected.getStyle?.() || {};
2655
+ const currentNegativePaddingValue = attrs[negativePaddingAttributeForSide(side)] || selectedStyle[negativePaddingVariableForSide(side)];
2627
2656
  const nextNegativePaddingBySide = Object.fromEntries(
2628
2657
  negativePaddingSides.map((paddingSide) => [
2629
2658
  paddingSide,
@@ -2637,9 +2666,20 @@ function GrapesPageEditor({
2637
2666
  selected.removeStyle?.(negativePaddingVariableForSide(side));
2638
2667
  selected.removeAttributes?.(negativePaddingAttributeForSide(side));
2639
2668
  selected.removeClass?.(`is-orion-negative-padding-${side}`);
2669
+ removeGeneratedNegativePaddingMargin(selected, side, currentNegativePaddingValue);
2640
2670
  if (!hasOtherNegativePadding) {
2641
2671
  if (negativePaddingBackground) {
2642
2672
  selected.addStyle?.({ "background-color": negativePaddingBackground });
2673
+ const block = parseOrionBlockAttribute(attrs["data-orion-block"]);
2674
+ if (Object.keys(block).length > 0) {
2675
+ selected.addAttributes?.({
2676
+ "data-orion-background-color": negativePaddingBackground,
2677
+ "data-orion-block": serializeOrionBlockAttribute({
2678
+ ...block,
2679
+ backgroundColor: negativePaddingBackground
2680
+ })
2681
+ });
2682
+ }
2643
2683
  }
2644
2684
  selected.removeStyle?.(negativePaddingBackgroundVariable);
2645
2685
  selected.removeAttributes?.(negativePaddingBackgroundAttribute);
@@ -2660,6 +2700,13 @@ function GrapesPageEditor({
2660
2700
  }
2661
2701
  selected.addStyle?.({ [property]: value });
2662
2702
  editorRef.current?.select?.(selected);
2703
+ if (property.startsWith("padding-")) {
2704
+ window.requestAnimationFrame(() => {
2705
+ spacingProperties.filter((spacingProperty) => spacingProperty.startsWith("margin-")).forEach((spacingProperty) => {
2706
+ writeStylePanelLength(spacingProperty, firstString(selected.getStyle?.()?.[spacingProperty], "0px"));
2707
+ });
2708
+ });
2709
+ }
2663
2710
  };
2664
2711
  const applyNegativeSpacingInput = (property, value, baseValue) => {
2665
2712
  const selected = getCurrentOrionBlockTarget(getCurrentStyleTarget());
@@ -2689,6 +2736,7 @@ function GrapesPageEditor({
2689
2736
  );
2690
2737
  selected.addClass?.("orion-builder-v2-negative-padding");
2691
2738
  selected.addClass?.(`is-orion-negative-padding-${side}`);
2739
+ removeGeneratedSelectionMargins(selected);
2692
2740
  selected.addAttributes?.({
2693
2741
  ...backgroundColor ? { [negativePaddingBackgroundAttribute]: backgroundColor } : {},
2694
2742
  [negativePaddingAttributeForSide(side)]: negativeStyleValue
@@ -2792,7 +2840,10 @@ function GrapesPageEditor({
2792
2840
  if (Object.keys(block).length === 0) {
2793
2841
  return;
2794
2842
  }
2795
- const backgroundColor = getStyleColorValue(component?.getStyle?.() || target.getStyle?.() || {}, "background-color");
2843
+ const targetStyle = target.getStyle?.() || {};
2844
+ const componentStyle = component?.getStyle?.() || targetStyle;
2845
+ const negativePaddingActive = hasNegativePaddingState(attrs, targetStyle) || hasNegativePaddingState(attrs, componentStyle);
2846
+ const backgroundColor = negativePaddingActive ? getStoredOrionBackgroundColor(attrs, targetStyle) || getStoredOrionBackgroundColor(attrs, componentStyle) : getStyleColorValue(componentStyle || targetStyle, "background-color");
2796
2847
  if (!backgroundColor) {
2797
2848
  return;
2798
2849
  }
@@ -3002,7 +3053,11 @@ function GrapesPageEditor({
3002
3053
  rememberComponentSnapshot(component);
3003
3054
  markSelectedCanvasBlock(component);
3004
3055
  refreshSelectedState(component);
3005
- window.requestAnimationFrame(() => {
3056
+ const writeSpacingControls = () => {
3057
+ const activeComponent = selectedComponentRef.current;
3058
+ if (!activeComponent || component !== activeComponent && getCurrentOrionBlockTarget(component) !== activeComponent) {
3059
+ return;
3060
+ }
3006
3061
  const element = spacingTargetForComponent(component);
3007
3062
  if (!element) {
3008
3063
  return;
@@ -3010,6 +3065,9 @@ function GrapesPageEditor({
3010
3065
  const computed = window.getComputedStyle(element);
3011
3066
  const attrs = component.getAttributes?.() || {};
3012
3067
  const style = component.getStyle?.() || {};
3068
+ if (hasNegativePaddingState(attrs, style)) {
3069
+ removeGeneratedSelectionMargins(component);
3070
+ }
3013
3071
  spacingProperties.forEach((property) => {
3014
3072
  const negativePaddingSide = negativePaddingSideFromProperty(property);
3015
3073
  const negativePaddingValue = negativePaddingSide ? firstString(attrs[negativePaddingAttributeForSide(negativePaddingSide)]) : "";
@@ -3018,12 +3076,16 @@ function GrapesPageEditor({
3018
3076
  return;
3019
3077
  }
3020
3078
  if (property.startsWith("margin-")) {
3021
- writeStylePanelLength(property, firstString(style[property], computed.getPropertyValue(property)));
3079
+ writeStylePanelLength(property, firstString(style[property], "0px"));
3022
3080
  return;
3023
3081
  }
3024
3082
  writeStylePanelLength(property, computed.getPropertyValue(property));
3025
3083
  });
3026
- });
3084
+ };
3085
+ window.requestAnimationFrame(writeSpacingControls);
3086
+ window.setTimeout(writeSpacingControls, 80);
3087
+ window.setTimeout(writeSpacingControls, 240);
3088
+ window.setTimeout(writeSpacingControls, 600);
3027
3089
  };
3028
3090
  const applyQuickLayout = (layout) => {
3029
3091
  const component = selectedComponentRef.current;
@@ -1785,7 +1785,8 @@ var normalizeCssColorValue = (value) => {
1785
1785
  return "";
1786
1786
  }
1787
1787
  const trimmed = value.trim();
1788
- return trimmed && trimmed !== "none" ? trimmed : "";
1788
+ const normalized = trimmed.toLowerCase();
1789
+ return trimmed && normalized !== "none" && normalized !== "transparent" && normalized !== "rgba(0, 0, 0, 0)" ? trimmed : "";
1789
1790
  };
1790
1791
  var getStyleColorValue = (style, property) => normalizeCssColorValue(
1791
1792
  style[property] || style[property.replace(/-([a-z])/g, (_, char) => char.toUpperCase())]
@@ -1902,6 +1903,32 @@ var negativePaddingVariableForSide = (side) => `--orion-negative-padding-${side}
1902
1903
  var negativePaddingBackgroundAttribute = "data-orion-negative-padding-background";
1903
1904
  var negativePaddingBackgroundVariable = "--orion-negative-padding-background";
1904
1905
  var hasNegativePaddingState = (attrs, style) => negativePaddingSides.some((side) => Boolean(attrs[negativePaddingAttributeForSide(side)] || style[negativePaddingVariableForSide(side)]));
1906
+ var removeGeneratedSelectionMargins = (component) => {
1907
+ const style = component?.getStyle?.() || {};
1908
+ const cleanup = {};
1909
+ ["margin-top", "margin-bottom"].forEach((property) => {
1910
+ const value = String(style[property] || "").trim();
1911
+ if (value === "-2px" || value === "-2") {
1912
+ cleanup[property] = "";
1913
+ }
1914
+ });
1915
+ if (Object.keys(cleanup).length > 0) {
1916
+ component?.addStyle?.(cleanup);
1917
+ }
1918
+ };
1919
+ var removeGeneratedNegativePaddingMargin = (component, side, negativePaddingValue) => {
1920
+ if (side !== "top" && side !== "bottom") {
1921
+ return;
1922
+ }
1923
+ const property = `margin-${side}`;
1924
+ const style = component?.getStyle?.() || {};
1925
+ const currentMargin = String(style[property] || "").trim();
1926
+ const generatedMargin = String(negativePaddingValue || "").trim();
1927
+ if (generatedMargin && currentMargin === generatedMargin) {
1928
+ component?.addStyle?.({ [property]: "" });
1929
+ writeStylePanelLength(property, "0px");
1930
+ }
1931
+ };
1905
1932
  var getStoredOrionBackgroundColor = (attrs, style) => {
1906
1933
  const block = parseOrionBlockAttribute(attrs["data-orion-block"]);
1907
1934
  return firstString(
@@ -2496,10 +2523,12 @@ function GrapesPageEditor({
2496
2523
  selectedComponentRef.current = selected;
2497
2524
  lastSelectedComponentRef.current = selected;
2498
2525
  if (property.startsWith("padding-") && !String(value).trim().startsWith("-")) {
2526
+ removeGeneratedSelectionMargins(selected);
2499
2527
  const side = negativePaddingSideFromProperty(property);
2500
2528
  if (side) {
2501
2529
  const attrs = selected.getAttributes?.() || {};
2502
2530
  const selectedStyle = selected.getStyle?.() || {};
2531
+ const currentNegativePaddingValue = attrs[negativePaddingAttributeForSide(side)] || selectedStyle[negativePaddingVariableForSide(side)];
2503
2532
  const nextNegativePaddingBySide = Object.fromEntries(
2504
2533
  negativePaddingSides.map((paddingSide) => [
2505
2534
  paddingSide,
@@ -2513,9 +2542,20 @@ function GrapesPageEditor({
2513
2542
  selected.removeStyle?.(negativePaddingVariableForSide(side));
2514
2543
  selected.removeAttributes?.(negativePaddingAttributeForSide(side));
2515
2544
  selected.removeClass?.(`is-orion-negative-padding-${side}`);
2545
+ removeGeneratedNegativePaddingMargin(selected, side, currentNegativePaddingValue);
2516
2546
  if (!hasOtherNegativePadding) {
2517
2547
  if (negativePaddingBackground) {
2518
2548
  selected.addStyle?.({ "background-color": negativePaddingBackground });
2549
+ const block = parseOrionBlockAttribute(attrs["data-orion-block"]);
2550
+ if (Object.keys(block).length > 0) {
2551
+ selected.addAttributes?.({
2552
+ "data-orion-background-color": negativePaddingBackground,
2553
+ "data-orion-block": serializeOrionBlockAttribute({
2554
+ ...block,
2555
+ backgroundColor: negativePaddingBackground
2556
+ })
2557
+ });
2558
+ }
2519
2559
  }
2520
2560
  selected.removeStyle?.(negativePaddingBackgroundVariable);
2521
2561
  selected.removeAttributes?.(negativePaddingBackgroundAttribute);
@@ -2536,6 +2576,13 @@ function GrapesPageEditor({
2536
2576
  }
2537
2577
  selected.addStyle?.({ [property]: value });
2538
2578
  editorRef.current?.select?.(selected);
2579
+ if (property.startsWith("padding-")) {
2580
+ window.requestAnimationFrame(() => {
2581
+ spacingProperties.filter((spacingProperty) => spacingProperty.startsWith("margin-")).forEach((spacingProperty) => {
2582
+ writeStylePanelLength(spacingProperty, firstString(selected.getStyle?.()?.[spacingProperty], "0px"));
2583
+ });
2584
+ });
2585
+ }
2539
2586
  };
2540
2587
  const applyNegativeSpacingInput = (property, value, baseValue) => {
2541
2588
  const selected = getCurrentOrionBlockTarget(getCurrentStyleTarget());
@@ -2565,6 +2612,7 @@ function GrapesPageEditor({
2565
2612
  );
2566
2613
  selected.addClass?.("orion-builder-v2-negative-padding");
2567
2614
  selected.addClass?.(`is-orion-negative-padding-${side}`);
2615
+ removeGeneratedSelectionMargins(selected);
2568
2616
  selected.addAttributes?.({
2569
2617
  ...backgroundColor ? { [negativePaddingBackgroundAttribute]: backgroundColor } : {},
2570
2618
  [negativePaddingAttributeForSide(side)]: negativeStyleValue
@@ -2668,7 +2716,10 @@ function GrapesPageEditor({
2668
2716
  if (Object.keys(block).length === 0) {
2669
2717
  return;
2670
2718
  }
2671
- const backgroundColor = getStyleColorValue(component?.getStyle?.() || target.getStyle?.() || {}, "background-color");
2719
+ const targetStyle = target.getStyle?.() || {};
2720
+ const componentStyle = component?.getStyle?.() || targetStyle;
2721
+ const negativePaddingActive = hasNegativePaddingState(attrs, targetStyle) || hasNegativePaddingState(attrs, componentStyle);
2722
+ const backgroundColor = negativePaddingActive ? getStoredOrionBackgroundColor(attrs, targetStyle) || getStoredOrionBackgroundColor(attrs, componentStyle) : getStyleColorValue(componentStyle || targetStyle, "background-color");
2672
2723
  if (!backgroundColor) {
2673
2724
  return;
2674
2725
  }
@@ -2878,7 +2929,11 @@ function GrapesPageEditor({
2878
2929
  rememberComponentSnapshot(component);
2879
2930
  markSelectedCanvasBlock(component);
2880
2931
  refreshSelectedState(component);
2881
- window.requestAnimationFrame(() => {
2932
+ const writeSpacingControls = () => {
2933
+ const activeComponent = selectedComponentRef.current;
2934
+ if (!activeComponent || component !== activeComponent && getCurrentOrionBlockTarget(component) !== activeComponent) {
2935
+ return;
2936
+ }
2882
2937
  const element = spacingTargetForComponent(component);
2883
2938
  if (!element) {
2884
2939
  return;
@@ -2886,6 +2941,9 @@ function GrapesPageEditor({
2886
2941
  const computed = window.getComputedStyle(element);
2887
2942
  const attrs = component.getAttributes?.() || {};
2888
2943
  const style = component.getStyle?.() || {};
2944
+ if (hasNegativePaddingState(attrs, style)) {
2945
+ removeGeneratedSelectionMargins(component);
2946
+ }
2889
2947
  spacingProperties.forEach((property) => {
2890
2948
  const negativePaddingSide = negativePaddingSideFromProperty(property);
2891
2949
  const negativePaddingValue = negativePaddingSide ? firstString(attrs[negativePaddingAttributeForSide(negativePaddingSide)]) : "";
@@ -2894,12 +2952,16 @@ function GrapesPageEditor({
2894
2952
  return;
2895
2953
  }
2896
2954
  if (property.startsWith("margin-")) {
2897
- writeStylePanelLength(property, firstString(style[property], computed.getPropertyValue(property)));
2955
+ writeStylePanelLength(property, firstString(style[property], "0px"));
2898
2956
  return;
2899
2957
  }
2900
2958
  writeStylePanelLength(property, computed.getPropertyValue(property));
2901
2959
  });
2902
- });
2960
+ };
2961
+ window.requestAnimationFrame(writeSpacingControls);
2962
+ window.setTimeout(writeSpacingControls, 80);
2963
+ window.setTimeout(writeSpacingControls, 240);
2964
+ window.setTimeout(writeSpacingControls, 600);
2903
2965
  };
2904
2966
  const applyQuickLayout = (layout) => {
2905
2967
  const component = selectedComponentRef.current;
package/dist/index.mjs CHANGED
@@ -8,6 +8,10 @@ import "./chunk-ZTXJG4K5.mjs";
8
8
  import {
9
9
  blocks_exports
10
10
  } from "./chunk-JQAHXYAM.mjs";
11
+ import {
12
+ admin_app_exports
13
+ } from "./chunk-RKTIFEUY.mjs";
14
+ import "./chunk-W2UOCJDX.mjs";
11
15
  import {
12
16
  studio_pages_exports
13
17
  } from "./chunk-276KAPGM.mjs";
@@ -16,10 +20,6 @@ import "./chunk-OQSEJXC4.mjs";
16
20
  import {
17
21
  studio_exports
18
22
  } from "./chunk-ADIIWIYL.mjs";
19
- import {
20
- admin_app_exports
21
- } from "./chunk-RKTIFEUY.mjs";
22
- import "./chunk-W2UOCJDX.mjs";
23
23
  import "./chunk-6BWS3CLP.mjs";
24
24
  export {
25
25
  admin_exports as admin,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orion-studios/payload-studio",
3
- "version": "0.6.0-beta.178",
3
+ "version": "0.6.0-beta.179",
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",
@@ -139,6 +139,7 @@
139
139
  "typescript": "^5.3.0"
140
140
  },
141
141
  "dependencies": {
142
+ "@orion-studios/payload-studio": "file:",
142
143
  "grapesjs": "^0.22.16",
143
144
  "sanitize-html": "^2.17.3"
144
145
  }