@alpaca-editor/contenthub 1.0.4112 → 1.0.4118
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/package.json +1 -1
- package/src/DamSelector.tsx +42 -28
package/package.json
CHANGED
package/src/DamSelector.tsx
CHANGED
|
@@ -1,34 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
Dialog,
|
|
3
|
+
DialogContent,
|
|
4
|
+
DialogHeader,
|
|
5
|
+
DialogTitle,
|
|
6
|
+
} from "@alpaca-editor/core";
|
|
7
|
+
import { DialogProps } from "@alpaca-editor/core";
|
|
8
|
+
import { useEffect } from "react";
|
|
9
|
+
import { DamImageValue, DamSelectorProps } from "./types";
|
|
5
10
|
|
|
6
11
|
export function DamSelector({
|
|
7
12
|
onClose,
|
|
8
13
|
contentHubHost,
|
|
9
14
|
contentHubBrowsePage,
|
|
10
|
-
externalRedirectKey
|
|
15
|
+
externalRedirectKey,
|
|
11
16
|
}: DamSelectorProps & DialogProps<DamImageValue>) {
|
|
12
|
-
|
|
13
17
|
useEffect(() => {
|
|
14
18
|
const handleMessage = (message: MessageEvent) => {
|
|
15
|
-
console.log(
|
|
16
|
-
|
|
17
|
-
const normalizedHost = contentHubHost.replace(/\/$/,
|
|
18
|
-
const messageOrigin = message.origin.replace(/\/$/,
|
|
19
|
-
|
|
19
|
+
console.log("Received message:", message);
|
|
20
|
+
|
|
21
|
+
const normalizedHost = contentHubHost.replace(/\/$/, "");
|
|
22
|
+
const messageOrigin = message.origin.replace(/\/$/, "");
|
|
23
|
+
|
|
20
24
|
if (messageOrigin !== normalizedHost) {
|
|
21
|
-
console.log(
|
|
25
|
+
console.log("Origin mismatch:", messageOrigin, normalizedHost);
|
|
22
26
|
return;
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
const data = message.data as DamImageValue;
|
|
26
30
|
if (!data || !data.public_link) {
|
|
27
|
-
console.log(
|
|
31
|
+
console.log("Invalid data received:", data);
|
|
28
32
|
return;
|
|
29
33
|
}
|
|
30
34
|
|
|
31
|
-
console.log(
|
|
35
|
+
console.log("Processing valid data:", data);
|
|
32
36
|
onClose(data);
|
|
33
37
|
};
|
|
34
38
|
|
|
@@ -38,20 +42,30 @@ export function DamSelector({
|
|
|
38
42
|
|
|
39
43
|
return (
|
|
40
44
|
<Dialog
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
className="select-medidialog"
|
|
48
|
-
draggable={false}
|
|
49
|
-
resizable={false}
|
|
45
|
+
open={true}
|
|
46
|
+
onOpenChange={(open) => {
|
|
47
|
+
if (!open) {
|
|
48
|
+
onClose(null);
|
|
49
|
+
}
|
|
50
|
+
}}
|
|
50
51
|
>
|
|
51
|
-
<
|
|
52
|
-
className="w-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
<DialogContent
|
|
53
|
+
className="max-w-none select-medidialog"
|
|
54
|
+
style={{ width: "90vw", height: "90vh" }}
|
|
55
|
+
>
|
|
56
|
+
<DialogHeader>
|
|
57
|
+
<DialogTitle>Insert from Sitecore DAM</DialogTitle>
|
|
58
|
+
</DialogHeader>
|
|
59
|
+
<div
|
|
60
|
+
className="flex-1 overflow-hidden"
|
|
61
|
+
style={{ height: "calc(100% - 71px)" }}
|
|
62
|
+
>
|
|
63
|
+
<iframe
|
|
64
|
+
className="w-full h-full border-none"
|
|
65
|
+
src={`${contentHubHost}${contentHubBrowsePage}?externalRedirectKey=${externalRedirectKey}&externalRedirectUrl=${window.location.href}&hasExternalRedirect=true`}
|
|
66
|
+
/>
|
|
67
|
+
</div>
|
|
68
|
+
</DialogContent>
|
|
55
69
|
</Dialog>
|
|
56
70
|
);
|
|
57
|
-
}
|
|
71
|
+
}
|