@alpaca-editor/contenthub 1.0.4114 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/DamSelector.tsx +42 -28
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alpaca-editor/contenthub",
3
- "version": "1.0.4114",
3
+ "version": "1.0.4118",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,34 +1,38 @@
1
- import { Dialog } from 'primereact/dialog';
2
- import { DialogProps } from '@alpaca-editor/core';
3
- import { useEffect } from 'react';
4
- import { DamImageValue, DamSelectorProps } from './types';
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('Received message:', message);
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('Origin mismatch:', messageOrigin, normalizedHost);
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('Invalid data received:', data);
31
+ console.log("Invalid data received:", data);
28
32
  return;
29
33
  }
30
34
 
31
- console.log('Processing valid data:', data);
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
- visible={true}
42
- onHide={() => onClose(null)}
43
- header="Insert from Sitecore DAM"
44
- modal
45
- style={{ width: '90vw', height: '90vh' }}
46
- contentStyle={{ padding: 0, height: 'calc(100% - 71px)' }} // 71px accounts for header height
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
- <iframe
52
- className="w-full h-full border-none"
53
- src={`${contentHubHost}${contentHubBrowsePage}?externalRedirectKey=${externalRedirectKey}&externalRedirectUrl=${window.location.href}&hasExternalRedirect=true`}
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
+ }