@mgamadeus/ddd-design-studio 0.5.1 → 0.6.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/dist/canvas/index.js +40 -15
- package/dist/canvas/index.js.map +1 -1
- package/dist/{chunk-FXDTHFHX.js → chunk-GPHJ2WQ3.js} +58 -2
- package/dist/chunk-GPHJ2WQ3.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -55
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-FXDTHFHX.js.map +0 -1
package/dist/canvas/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
isResponsiveBoard,
|
|
24
24
|
normalizeBoardCode,
|
|
25
25
|
pageHeightAtWidth,
|
|
26
|
+
parseSiteFrameMessage,
|
|
26
27
|
splitThemeReference,
|
|
27
28
|
useCheckedContentUrl,
|
|
28
29
|
useDesignStudio,
|
|
@@ -32,7 +33,7 @@ import {
|
|
|
32
33
|
viewportOfComment,
|
|
33
34
|
viewportWithWidth,
|
|
34
35
|
wasContentUrlLoaded
|
|
35
|
-
} from "../chunk-
|
|
36
|
+
} from "../chunk-GPHJ2WQ3.js";
|
|
36
37
|
|
|
37
38
|
// src/canvas/DesignStudioCanvasScreen.tsx
|
|
38
39
|
import { normalizeDddError as normalizeDddError2 } from "@mgamadeus/ddd-web/api";
|
|
@@ -622,6 +623,7 @@ var BoardNodeComponent = ({ id, data }) => {
|
|
|
622
623
|
thumbnailVariant,
|
|
623
624
|
showsLiveHtml: showsLiveHtml && isReady,
|
|
624
625
|
htmlUrl,
|
|
626
|
+
runsScripts: board.runsScripts === true,
|
|
625
627
|
title
|
|
626
628
|
}
|
|
627
629
|
),
|
|
@@ -642,7 +644,7 @@ var BoardNodeComponent = ({ id, data }) => {
|
|
|
642
644
|
src: liveHtmlUrl,
|
|
643
645
|
onLoad: () => setLoadedFrameUrl(liveHtmlUrl),
|
|
644
646
|
title: title || "Board",
|
|
645
|
-
sandbox:
|
|
647
|
+
sandbox: boardSandbox(board),
|
|
646
648
|
referrerPolicy: "no-referrer",
|
|
647
649
|
loading: "lazy",
|
|
648
650
|
width,
|
|
@@ -681,6 +683,7 @@ var BoardNodeComponent = ({ id, data }) => {
|
|
|
681
683
|
] });
|
|
682
684
|
};
|
|
683
685
|
var BoardNode = memo(BoardNodeComponent);
|
|
686
|
+
var boardSandbox = (board) => board?.runsScripts === true ? "allow-scripts" : "";
|
|
684
687
|
var ResponsiveBoardFrames = ({
|
|
685
688
|
board,
|
|
686
689
|
frameHeightMode,
|
|
@@ -688,6 +691,7 @@ var ResponsiveBoardFrames = ({
|
|
|
688
691
|
thumbnailVariant,
|
|
689
692
|
showsLiveHtml,
|
|
690
693
|
htmlUrl,
|
|
694
|
+
runsScripts,
|
|
691
695
|
title
|
|
692
696
|
}) => {
|
|
693
697
|
let left = 0;
|
|
@@ -704,6 +708,7 @@ var ResponsiveBoardFrames = ({
|
|
|
704
708
|
thumbnailVariant,
|
|
705
709
|
showsLiveHtml,
|
|
706
710
|
htmlUrl,
|
|
711
|
+
runsScripts,
|
|
707
712
|
title
|
|
708
713
|
},
|
|
709
714
|
frame.deviceKey ?? frameLeft
|
|
@@ -718,6 +723,7 @@ var ResponsiveBoardFrame = ({
|
|
|
718
723
|
thumbnailVariant,
|
|
719
724
|
showsLiveHtml,
|
|
720
725
|
htmlUrl,
|
|
726
|
+
runsScripts,
|
|
721
727
|
title
|
|
722
728
|
}) => {
|
|
723
729
|
const texts = useDesignStudioTexts();
|
|
@@ -760,7 +766,7 @@ var ResponsiveBoardFrame = ({
|
|
|
760
766
|
{
|
|
761
767
|
src: liveHtmlUrl,
|
|
762
768
|
title: `${title} \xB7 ${deviceLabel}`,
|
|
763
|
-
sandbox: "",
|
|
769
|
+
sandbox: runsScripts ? "allow-scripts" : "",
|
|
764
770
|
referrerPolicy: "no-referrer",
|
|
765
771
|
loading: "lazy",
|
|
766
772
|
width: frameWidth,
|
|
@@ -918,7 +924,23 @@ var BoardFocusView = ({
|
|
|
918
924
|
const bezelPadding = !isResponsive || showsDeviceFrame ? 24 : 0;
|
|
919
925
|
const scale = isResponsive && stageWidth > 0 ? Math.min(1, (stageWidth - 48) / (width + bezelPadding)) : 1;
|
|
920
926
|
const frameOfWidth = isResponsive ? framesOf(board).find((frame) => frame.width === width) : void 0;
|
|
921
|
-
const htmlUrl =
|
|
927
|
+
const boardHtmlPath = board?.htmlUrl ? isResponsive ? `${board.htmlUrl}&site=1` : board.htmlUrl : null;
|
|
928
|
+
const htmlUrl = useCheckedContentUrl(useStableContentUrl(designContentUrl(apiBaseUrl, boardHtmlPath), true));
|
|
929
|
+
const frameRef = useRef2(null);
|
|
930
|
+
const [frameScrollTop, setFrameScrollTop] = useState5(0);
|
|
931
|
+
useEffect3(() => setFrameScrollTop(0), [htmlUrl, width]);
|
|
932
|
+
useEffect3(() => {
|
|
933
|
+
if (!isResponsive) return;
|
|
934
|
+
const onMessage = (event) => {
|
|
935
|
+
if (!frameRef.current || event.source !== frameRef.current.contentWindow) return;
|
|
936
|
+
const message = parseSiteFrameMessage(event.data);
|
|
937
|
+
if (message?.type === "scroll") setFrameScrollTop(message.top);
|
|
938
|
+
};
|
|
939
|
+
window.addEventListener("message", onMessage);
|
|
940
|
+
return () => window.removeEventListener("message", onMessage);
|
|
941
|
+
}, [isResponsive]);
|
|
942
|
+
const scrollOffset = isResponsive ? frameScrollTop : 0;
|
|
943
|
+
const contentHeight = isResponsive ? screenHeight : height;
|
|
922
944
|
const thumbnailUrl = useStableContentUrl(
|
|
923
945
|
designContentUrl(apiBaseUrl, isResponsive ? frameOfWidth?.thumbnailUrl : board?.thumbnailUrl),
|
|
924
946
|
true
|
|
@@ -938,7 +960,7 @@ var BoardFocusView = ({
|
|
|
938
960
|
const rect = event.currentTarget.getBoundingClientRect();
|
|
939
961
|
return {
|
|
940
962
|
x: Math.max(0, Math.min(width, (event.clientX - rect.left) / scale)),
|
|
941
|
-
y: Math.max(0, Math.min(
|
|
963
|
+
y: Math.max(0, Math.min(contentHeight, (event.clientY - rect.top) / scale)) + scrollOffset
|
|
942
964
|
};
|
|
943
965
|
};
|
|
944
966
|
const startRegion = (event) => {
|
|
@@ -975,7 +997,7 @@ var BoardFocusView = ({
|
|
|
975
997
|
const rect = event.currentTarget.getBoundingClientRect();
|
|
976
998
|
setPendingPin({
|
|
977
999
|
x: Math.round((event.clientX - rect.left) / scale),
|
|
978
|
-
y: Math.round((event.clientY - rect.top) / scale),
|
|
1000
|
+
y: Math.round((event.clientY - rect.top) / scale + scrollOffset),
|
|
979
1001
|
viewport: isResponsive ? viewport : null
|
|
980
1002
|
});
|
|
981
1003
|
setIsPlacingPin(false);
|
|
@@ -1045,11 +1067,12 @@ var BoardFocusView = ({
|
|
|
1045
1067
|
"div",
|
|
1046
1068
|
{
|
|
1047
1069
|
className: cx(
|
|
1048
|
-
"relative overflow-
|
|
1070
|
+
"relative overflow-x-hidden bg-card",
|
|
1071
|
+
isResponsive ? "overflow-y-hidden" : "overflow-y-auto",
|
|
1049
1072
|
!isResponsive || showsDeviceFrame ? !isResponsive || viewport.width < 600 ? "rounded-[44px]" : "rounded-[18px]" : "rounded-md ring-1 ring-foreground/10"
|
|
1050
1073
|
),
|
|
1051
1074
|
style: { width, height: screenHeight },
|
|
1052
|
-
children: /* @__PURE__ */ jsxs4("div", { className: "relative", style: { width, height }, children: [
|
|
1075
|
+
children: /* @__PURE__ */ jsxs4("div", { className: "relative overflow-hidden", style: { width, height: contentHeight }, children: [
|
|
1053
1076
|
thumbnailUrl && // biome-ignore lint/performance/noImgElement: API thumbnail under the live board while it loads
|
|
1054
1077
|
/* @__PURE__ */ jsx4(
|
|
1055
1078
|
"img",
|
|
@@ -1057,19 +1080,21 @@ var BoardFocusView = ({
|
|
|
1057
1080
|
src: thumbnailUrl,
|
|
1058
1081
|
alt: "",
|
|
1059
1082
|
width,
|
|
1060
|
-
height,
|
|
1061
|
-
className: "pointer-events-none absolute
|
|
1083
|
+
height: isResponsive ? void 0 : height,
|
|
1084
|
+
className: "pointer-events-none absolute left-0 select-none",
|
|
1085
|
+
style: { top: -scrollOffset, width }
|
|
1062
1086
|
}
|
|
1063
1087
|
),
|
|
1064
1088
|
htmlUrl && /* @__PURE__ */ jsx4(
|
|
1065
1089
|
"iframe",
|
|
1066
1090
|
{
|
|
1091
|
+
ref: frameRef,
|
|
1067
1092
|
src: htmlUrl,
|
|
1068
1093
|
title: board.title ?? board.boardKey ?? "Board",
|
|
1069
|
-
sandbox: "",
|
|
1094
|
+
sandbox: isResponsive ? "allow-scripts" : boardSandbox(board),
|
|
1070
1095
|
referrerPolicy: "no-referrer",
|
|
1071
1096
|
width,
|
|
1072
|
-
height,
|
|
1097
|
+
height: contentHeight,
|
|
1073
1098
|
className: "absolute inset-0 border-0 bg-transparent"
|
|
1074
1099
|
},
|
|
1075
1100
|
htmlUrl
|
|
@@ -1104,7 +1129,7 @@ var BoardFocusView = ({
|
|
|
1104
1129
|
),
|
|
1105
1130
|
style: {
|
|
1106
1131
|
left: shownRegion.x,
|
|
1107
|
-
top: shownRegion.y,
|
|
1132
|
+
top: shownRegion.y - scrollOffset,
|
|
1108
1133
|
width: shownRegion.width,
|
|
1109
1134
|
height: shownRegion.height
|
|
1110
1135
|
}
|
|
@@ -1122,7 +1147,7 @@ var BoardFocusView = ({
|
|
|
1122
1147
|
thread.root.isResolved ? "bg-muted text-muted-foreground" : "bg-primary text-primary-foreground",
|
|
1123
1148
|
highlightedCommentId === Number(thread.root.id) && "ring-brand scale-110"
|
|
1124
1149
|
),
|
|
1125
|
-
style: { left: thread.root.x ?? 0, top: thread.root.y ?? 0 },
|
|
1150
|
+
style: { left: thread.root.x ?? 0, top: (thread.root.y ?? 0) - scrollOffset },
|
|
1126
1151
|
children: thread.pinNumber
|
|
1127
1152
|
},
|
|
1128
1153
|
String(thread.root.id)
|
|
@@ -1131,7 +1156,7 @@ var BoardFocusView = ({
|
|
|
1131
1156
|
"span",
|
|
1132
1157
|
{
|
|
1133
1158
|
className: "absolute z-20 flex size-7 -translate-x-1/2 -translate-y-full items-center justify-center rounded-full rounded-bl-none bg-brand text-card shadow-surface-raised ring-2 ring-card",
|
|
1134
|
-
style: { left: pendingPin.x, top: pendingPin.y },
|
|
1159
|
+
style: { left: pendingPin.x, top: pendingPin.y - scrollOffset },
|
|
1135
1160
|
"aria-hidden": true,
|
|
1136
1161
|
children: /* @__PURE__ */ jsx4(MapPin, { className: "size-4" })
|
|
1137
1162
|
}
|