@mgamadeus/ddd-design-studio 0.5.0 → 0.5.2
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 +33 -13
- package/dist/canvas/index.js.map +1 -1
- package/dist/{chunk-NCMXGWLC.js → chunk-GPHJ2WQ3.js} +65 -2
- package/dist/chunk-GPHJ2WQ3.js.map +1 -0
- package/dist/index.js +7 -57
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-NCMXGWLC.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";
|
|
@@ -918,7 +919,23 @@ var BoardFocusView = ({
|
|
|
918
919
|
const bezelPadding = !isResponsive || showsDeviceFrame ? 24 : 0;
|
|
919
920
|
const scale = isResponsive && stageWidth > 0 ? Math.min(1, (stageWidth - 48) / (width + bezelPadding)) : 1;
|
|
920
921
|
const frameOfWidth = isResponsive ? framesOf(board).find((frame) => frame.width === width) : void 0;
|
|
921
|
-
const htmlUrl =
|
|
922
|
+
const boardHtmlPath = board?.htmlUrl ? isResponsive ? `${board.htmlUrl}&site=1` : board.htmlUrl : null;
|
|
923
|
+
const htmlUrl = useCheckedContentUrl(useStableContentUrl(designContentUrl(apiBaseUrl, boardHtmlPath), true));
|
|
924
|
+
const frameRef = useRef2(null);
|
|
925
|
+
const [frameScrollTop, setFrameScrollTop] = useState5(0);
|
|
926
|
+
useEffect3(() => setFrameScrollTop(0), [htmlUrl, width]);
|
|
927
|
+
useEffect3(() => {
|
|
928
|
+
if (!isResponsive) return;
|
|
929
|
+
const onMessage = (event) => {
|
|
930
|
+
if (!frameRef.current || event.source !== frameRef.current.contentWindow) return;
|
|
931
|
+
const message = parseSiteFrameMessage(event.data);
|
|
932
|
+
if (message?.type === "scroll") setFrameScrollTop(message.top);
|
|
933
|
+
};
|
|
934
|
+
window.addEventListener("message", onMessage);
|
|
935
|
+
return () => window.removeEventListener("message", onMessage);
|
|
936
|
+
}, [isResponsive]);
|
|
937
|
+
const scrollOffset = isResponsive ? frameScrollTop : 0;
|
|
938
|
+
const contentHeight = isResponsive ? screenHeight : height;
|
|
922
939
|
const thumbnailUrl = useStableContentUrl(
|
|
923
940
|
designContentUrl(apiBaseUrl, isResponsive ? frameOfWidth?.thumbnailUrl : board?.thumbnailUrl),
|
|
924
941
|
true
|
|
@@ -938,7 +955,7 @@ var BoardFocusView = ({
|
|
|
938
955
|
const rect = event.currentTarget.getBoundingClientRect();
|
|
939
956
|
return {
|
|
940
957
|
x: Math.max(0, Math.min(width, (event.clientX - rect.left) / scale)),
|
|
941
|
-
y: Math.max(0, Math.min(
|
|
958
|
+
y: Math.max(0, Math.min(contentHeight, (event.clientY - rect.top) / scale)) + scrollOffset
|
|
942
959
|
};
|
|
943
960
|
};
|
|
944
961
|
const startRegion = (event) => {
|
|
@@ -975,7 +992,7 @@ var BoardFocusView = ({
|
|
|
975
992
|
const rect = event.currentTarget.getBoundingClientRect();
|
|
976
993
|
setPendingPin({
|
|
977
994
|
x: Math.round((event.clientX - rect.left) / scale),
|
|
978
|
-
y: Math.round((event.clientY - rect.top) / scale),
|
|
995
|
+
y: Math.round((event.clientY - rect.top) / scale + scrollOffset),
|
|
979
996
|
viewport: isResponsive ? viewport : null
|
|
980
997
|
});
|
|
981
998
|
setIsPlacingPin(false);
|
|
@@ -1045,11 +1062,12 @@ var BoardFocusView = ({
|
|
|
1045
1062
|
"div",
|
|
1046
1063
|
{
|
|
1047
1064
|
className: cx(
|
|
1048
|
-
"relative overflow-
|
|
1065
|
+
"relative overflow-x-hidden bg-card",
|
|
1066
|
+
isResponsive ? "overflow-y-hidden" : "overflow-y-auto",
|
|
1049
1067
|
!isResponsive || showsDeviceFrame ? !isResponsive || viewport.width < 600 ? "rounded-[44px]" : "rounded-[18px]" : "rounded-md ring-1 ring-foreground/10"
|
|
1050
1068
|
),
|
|
1051
1069
|
style: { width, height: screenHeight },
|
|
1052
|
-
children: /* @__PURE__ */ jsxs4("div", { className: "relative", style: { width, height }, children: [
|
|
1070
|
+
children: /* @__PURE__ */ jsxs4("div", { className: "relative overflow-hidden", style: { width, height: contentHeight }, children: [
|
|
1053
1071
|
thumbnailUrl && // biome-ignore lint/performance/noImgElement: API thumbnail under the live board while it loads
|
|
1054
1072
|
/* @__PURE__ */ jsx4(
|
|
1055
1073
|
"img",
|
|
@@ -1057,19 +1075,21 @@ var BoardFocusView = ({
|
|
|
1057
1075
|
src: thumbnailUrl,
|
|
1058
1076
|
alt: "",
|
|
1059
1077
|
width,
|
|
1060
|
-
height,
|
|
1061
|
-
className: "pointer-events-none absolute
|
|
1078
|
+
height: isResponsive ? void 0 : height,
|
|
1079
|
+
className: "pointer-events-none absolute left-0 select-none",
|
|
1080
|
+
style: { top: -scrollOffset, width }
|
|
1062
1081
|
}
|
|
1063
1082
|
),
|
|
1064
1083
|
htmlUrl && /* @__PURE__ */ jsx4(
|
|
1065
1084
|
"iframe",
|
|
1066
1085
|
{
|
|
1086
|
+
ref: frameRef,
|
|
1067
1087
|
src: htmlUrl,
|
|
1068
1088
|
title: board.title ?? board.boardKey ?? "Board",
|
|
1069
|
-
sandbox: "",
|
|
1089
|
+
sandbox: isResponsive ? "allow-scripts" : "",
|
|
1070
1090
|
referrerPolicy: "no-referrer",
|
|
1071
1091
|
width,
|
|
1072
|
-
height,
|
|
1092
|
+
height: contentHeight,
|
|
1073
1093
|
className: "absolute inset-0 border-0 bg-transparent"
|
|
1074
1094
|
},
|
|
1075
1095
|
htmlUrl
|
|
@@ -1104,7 +1124,7 @@ var BoardFocusView = ({
|
|
|
1104
1124
|
),
|
|
1105
1125
|
style: {
|
|
1106
1126
|
left: shownRegion.x,
|
|
1107
|
-
top: shownRegion.y,
|
|
1127
|
+
top: shownRegion.y - scrollOffset,
|
|
1108
1128
|
width: shownRegion.width,
|
|
1109
1129
|
height: shownRegion.height
|
|
1110
1130
|
}
|
|
@@ -1122,7 +1142,7 @@ var BoardFocusView = ({
|
|
|
1122
1142
|
thread.root.isResolved ? "bg-muted text-muted-foreground" : "bg-primary text-primary-foreground",
|
|
1123
1143
|
highlightedCommentId === Number(thread.root.id) && "ring-brand scale-110"
|
|
1124
1144
|
),
|
|
1125
|
-
style: { left: thread.root.x ?? 0, top: thread.root.y ?? 0 },
|
|
1145
|
+
style: { left: thread.root.x ?? 0, top: (thread.root.y ?? 0) - scrollOffset },
|
|
1126
1146
|
children: thread.pinNumber
|
|
1127
1147
|
},
|
|
1128
1148
|
String(thread.root.id)
|
|
@@ -1131,7 +1151,7 @@ var BoardFocusView = ({
|
|
|
1131
1151
|
"span",
|
|
1132
1152
|
{
|
|
1133
1153
|
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 },
|
|
1154
|
+
style: { left: pendingPin.x, top: pendingPin.y - scrollOffset },
|
|
1135
1155
|
"aria-hidden": true,
|
|
1136
1156
|
children: /* @__PURE__ */ jsx4(MapPin, { className: "size-4" })
|
|
1137
1157
|
}
|