@parhelia/contenthub 0.1.10745 → 0.1.11654

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/README.md CHANGED
@@ -25,3 +25,7 @@ import '@parhelia/contenthub/styles.css';
25
25
 
26
26
  See LICENSE file for details.
27
27
 
28
+ ## Documentation
29
+
30
+ For complete documentation, visit [https://parhelia.ai](https://parhelia.ai)
31
+
@@ -0,0 +1,3 @@
1
+ import { DialogProps } from "@parhelia/core";
2
+ import { DamImageValue, DamSelectorProps } from "./types";
3
+ export declare function DamSelector({ onClose, contentHubHost, contentHubBrowsePage, externalRedirectKey, }: DamSelectorProps & DialogProps<DamImageValue>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Dialog, DialogContent, DialogHeader, DialogTitle, } from "@parhelia/core";
3
+ import { useEffect } from "react";
4
+ export function DamSelector({ onClose, contentHubHost, contentHubBrowsePage, externalRedirectKey, }) {
5
+ useEffect(() => {
6
+ const handleMessage = (message) => {
7
+ console.log("Received message:", message);
8
+ const normalizedHost = contentHubHost.replace(/\/$/, "");
9
+ const messageOrigin = message.origin.replace(/\/$/, "");
10
+ if (messageOrigin !== normalizedHost) {
11
+ console.log("Origin mismatch:", messageOrigin, normalizedHost);
12
+ return;
13
+ }
14
+ const data = message.data;
15
+ if (!data || !data.public_link) {
16
+ console.log("Invalid data received:", data);
17
+ return;
18
+ }
19
+ console.log("Processing valid data:", data);
20
+ onClose(data);
21
+ };
22
+ window.addEventListener("message", handleMessage);
23
+ return () => window.removeEventListener("message", handleMessage);
24
+ }, [contentHubHost, onClose]);
25
+ return (_jsx(Dialog, { open: true, onOpenChange: (open) => {
26
+ if (!open) {
27
+ onClose(null);
28
+ }
29
+ }, children: _jsxs(DialogContent, { className: "max-w-none select-medidialog", style: { width: "90vw", height: "90vh" }, children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: "Insert from Sitecore DAM" }) }), _jsx("div", { className: "flex-1 overflow-hidden", style: { height: "calc(100% - 71px)" }, children: _jsx("iframe", { className: "w-full h-full border-none", src: `${contentHubHost}${contentHubBrowsePage}?externalRedirectKey=${externalRedirectKey}&externalRedirectUrl=${window.location.href}&hasExternalRedirect=true` }) })] }) }));
30
+ }
31
+ //# sourceMappingURL=DamSelector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DamSelector.js","sourceRoot":"","sources":["../src/DamSelector.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,EACN,aAAa,EACb,YAAY,EACZ,WAAW,GACZ,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC,MAAM,UAAU,WAAW,CAAC,EAC1B,OAAO,EACP,cAAc,EACd,oBAAoB,EACpB,mBAAmB,GAC2B;IAC9C,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,aAAa,GAAG,CAAC,OAAqB,EAAE,EAAE;YAC9C,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;YAE1C,MAAM,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACzD,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAExD,IAAI,aAAa,KAAK,cAAc,EAAE,CAAC;gBACrC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;gBAC/D,OAAO;YACT,CAAC;YAED,MAAM,IAAI,GAAG,OAAO,CAAC,IAAqB,CAAC;YAC3C,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;gBAC/B,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAC;gBAC5C,OAAO;YACT,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAC;YAC5C,OAAO,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC,CAAC;QAEF,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QAClD,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IACpE,CAAC,EAAE,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC;IAE9B,OAAO,CACL,KAAC,MAAM,IACL,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE;YACrB,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,OAAO,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC;QACH,CAAC,YAED,MAAC,aAAa,IACZ,SAAS,EAAC,8BAA8B,EACxC,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAExC,KAAC,YAAY,cACX,KAAC,WAAW,2CAAuC,GACtC,EACf,cACE,SAAS,EAAC,wBAAwB,EAClC,KAAK,EAAE,EAAE,MAAM,EAAE,mBAAmB,EAAE,YAEtC,iBACE,SAAS,EAAC,2BAA2B,EACrC,GAAG,EAAE,GAAG,cAAc,GAAG,oBAAoB,wBAAwB,mBAAmB,wBAAwB,MAAM,CAAC,QAAQ,CAAC,IAAI,2BAA2B,GAC/J,GACE,IACQ,GACT,CACV,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ClientFieldButton } from "@parhelia/core";
2
+ export declare const DamSelectorButton: ClientFieldButton;
@@ -0,0 +1,27 @@
1
+ import { DamSelector } from "./DamSelector";
2
+ export const DamSelectorButton = {
3
+ label: "Open Content Hub",
4
+ icon: "ExternalLink",
5
+ clientAction: async ({ editContext, field }) => {
6
+ const contentHubConfig = editContext.configuration.extensions
7
+ .contentHub;
8
+ console.log("contentHubConfig", contentHubConfig);
9
+ const data = await editContext.openDialog(DamSelector, {
10
+ contentHubHost: contentHubConfig.contentHubHost,
11
+ contentHubBrowsePage: contentHubConfig.contentHubBrowsePage,
12
+ externalRedirectKey: contentHubConfig.externalRedirectKey,
13
+ });
14
+ if (data != null) {
15
+ const rawValue = `<image src="${data?.public_link}" dam-id="${data?.["dam-id"]}" width="${data?.width}" height="${data?.height}" alt="${data?.alt}" dam-content-type="Image" thumbnailsrc="${data?.thumbnailsrc}" />`;
16
+ editContext.operations.editField({
17
+ field: field.descriptor,
18
+ rawValue: rawValue,
19
+ refresh: "immediate",
20
+ });
21
+ }
22
+ },
23
+ isGenerator: false,
24
+ id: "open-contenthub-dam",
25
+ description: "Opens the Content Hub DAM to select an image",
26
+ };
27
+ //# sourceMappingURL=DamSelectorButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DamSelectorButton.js","sourceRoot":"","sources":["../src/DamSelectorButton.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,MAAM,CAAC,MAAM,iBAAiB,GAAsB;IAClD,KAAK,EAAE,kBAAkB;IACzB,IAAI,EAAE,cAAc;IACpB,YAAY,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,EAAE;QAC7C,MAAM,gBAAgB,GAAG,WAAY,CAAC,aAAa,CAAC,UAAU;aAC3D,UAAiC,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;QAElD,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,UAAU,CACvC,WAAW,EACX;YACE,cAAc,EAAE,gBAAgB,CAAC,cAAc;YAC/C,oBAAoB,EAAE,gBAAgB,CAAC,oBAAoB;YAC3D,mBAAmB,EAAE,gBAAgB,CAAC,mBAAmB;SAC1D,CACF,CAAC;QAEF,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;YACjB,MAAM,QAAQ,GAAG,eAAe,IAAI,EAAE,WAAW,aAAa,IAAI,EAAE,CAAC,QAAQ,CAAC,YAAY,IAAI,EAAE,KAAK,aAAa,IAAI,EAAE,MAAM,UAAU,IAAI,EAAE,GAAG,4CAA4C,IAAI,EAAE,YAAY,MAAM,CAAC;YAEtN,WAAY,CAAC,UAAU,CAAC,SAAS,CAAC;gBAChC,KAAK,EAAE,KAAK,CAAC,UAAU;gBACvB,QAAQ,EAAE,QAAQ;gBAClB,OAAO,EAAE,WAAW;aACrB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,WAAW,EAAE,KAAK;IAClB,EAAE,EAAE,qBAAqB;IACzB,WAAW,EAAE,8CAA8C;CAC5D,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { EditorConfiguration } from "@parhelia/core";
2
+ import { ContentHubExtension, DamImageValue } from "./types";
3
+ import { DamSelector } from "./DamSelector";
4
+ export type { DamImageValue, ContentHubExtension };
5
+ export { DamSelector };
6
+ /**
7
+ * Configures the ContentHub extension for the editor
8
+ * @param configuration - The editor configuration object
9
+ * @param contentHubHost - The base URL of the Content Hub instance (e.g., "https://your-instance.sitecoresandbox.cloud")
10
+ * @param browsePage - The relative path to the browse page (will be appended to contentHubHost)
11
+ * @returns The updated configuration object
12
+ */
13
+ export declare function configureContentHub(configuration: EditorConfiguration, contentHub: ContentHubExtension): EditorConfiguration;
@@ -0,0 +1,35 @@
1
+ import { DamSelectorButton } from "./DamSelectorButton";
2
+ import { DamSelector } from "./DamSelector";
3
+ export { DamSelector };
4
+ /**
5
+ * Configures the ContentHub extension for the editor
6
+ * @param configuration - The editor configuration object
7
+ * @param contentHubHost - The base URL of the Content Hub instance (e.g., "https://your-instance.sitecoresandbox.cloud")
8
+ * @param browsePage - The relative path to the browse page (will be appended to contentHubHost)
9
+ * @returns The updated configuration object
10
+ */
11
+ export function configureContentHub(configuration, contentHub) {
12
+ configuration.extensions = {
13
+ ...configuration.extensions,
14
+ contentHub: {
15
+ contentHubHost: contentHub.contentHubHost,
16
+ contentHubBrowsePage: contentHub.contentHubBrowsePage,
17
+ externalRedirectKey: contentHub.externalRedirectKey
18
+ }
19
+ };
20
+ if (!configuration.fieldTypes.image) {
21
+ configuration.fieldTypes.image = {
22
+ editor: () => null,
23
+ buttons: []
24
+ };
25
+ }
26
+ if (!configuration.fieldTypes.image.buttons) {
27
+ configuration.fieldTypes.image.buttons = [];
28
+ }
29
+ const buttonExists = configuration.fieldTypes.image.buttons.some((btn) => btn.id === DamSelectorButton.id);
30
+ if (!buttonExists) {
31
+ configuration.fieldTypes.image.buttons.push(DamSelectorButton);
32
+ }
33
+ return configuration;
34
+ }
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,aAAkC,EAClC,UAA+B;IAE/B,aAAa,CAAC,UAAU,GAAG;QACzB,GAAG,aAAa,CAAC,UAAU;QAC3B,UAAU,EAAE;YACV,cAAc,EAAE,UAAU,CAAC,cAAc;YACzC,oBAAoB,EAAE,UAAU,CAAC,oBAAoB;YACrD,mBAAmB,EAAE,UAAU,CAAC,mBAAmB;SACpD;KACF,CAAC;IAEF,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACpC,aAAa,CAAC,UAAU,CAAC,KAAK,GAAG;YAC/B,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI;YAClB,OAAO,EAAE,EAAE;SACZ,CAAA;IACH,CAAC;IAED,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QAC5C,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC;IAC9C,CAAC;IAED,MAAM,YAAY,GAAG,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAC9D,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,iBAAiB,CAAC,EAAE,CACzC,CAAC;IAEF,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACjE,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC"}
@@ -0,0 +1,20 @@
1
+ export type DamSelectorProps = {
2
+ contentHubHost: string;
3
+ contentHubBrowsePage: string;
4
+ externalRedirectKey: string;
5
+ };
6
+ export type DamImageValue = {
7
+ src: string;
8
+ 'dam-id': string;
9
+ width: number;
10
+ height: number;
11
+ alt: string;
12
+ 'dam-content-type': string;
13
+ thumbnailsrc: string;
14
+ public_link: string;
15
+ };
16
+ export type ContentHubExtension = {
17
+ contentHubHost: string;
18
+ contentHubBrowsePage: string;
19
+ externalRedirectKey: string;
20
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,47 +1,49 @@
1
- {
2
- "name": "@parhelia/contenthub",
3
- "version": "0.1.10745",
4
- "type": "module",
5
- "publishConfig": {
6
- "access": "public"
7
- },
8
- "main": "./dist/index.js",
9
- "module": "./dist/index.js",
10
- "types": "./dist/index.d.ts",
11
- "exports": {
12
- ".": {
13
- "types": "./dist/index.d.ts",
14
- "import": "./dist/index.js"
15
- },
16
- "./styles.css": "./styles.css"
17
- },
18
- "files": [
19
- "dist/",
20
- "styles.css",
21
- "README.md",
22
- "LICENSE"
23
- ],
24
- "scripts": {
25
- "build": "tsc -p tsconfig.build.json",
26
- "lint": "eslint . --max-warnings 0",
27
- "generate:component": "turbo gen react-component",
28
- "check-types": "tsc --noEmit"
29
- },
30
- "devDependencies": {
31
- "@repo/eslint-config": "*",
32
- "@repo/typescript-config": "*",
33
- "@turbo/gen": "^2.4.4",
34
- "@types/node": "^22.13.9",
35
- "@types/react": "19.0.10",
36
- "@types/react-dom": "19.0.4",
37
- "eslint": "^9.22.0",
38
- "typescript": "5.8.2"
39
- },
40
- "dependencies": {
41
- "@tailwindcss/postcss": "^4.0.14",
42
- "postcss": "^8.5.3",
43
- "react": "^19.0.0",
44
- "react-dom": "^19.0.0",
45
- "tailwindcss": "^4.0.14"
46
- }
47
- }
1
+ {
2
+ "name": "@parhelia/contenthub",
3
+ "version": "0.1.11654",
4
+ "type": "module",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "main": "./dist/index.js",
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "development": "./src/index.ts",
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ },
17
+ "./styles.css": "./styles.css"
18
+ },
19
+ "files": [
20
+ "dist/",
21
+ "styles.css",
22
+ "README.md",
23
+ "LICENSE"
24
+ ],
25
+ "scripts": {
26
+ "build": "tsc -p tsconfig.build.json",
27
+ "lint": "eslint . --max-warnings 0",
28
+ "generate:component": "turbo gen react-component",
29
+ "check-types": "tsc --noEmit"
30
+ },
31
+ "devDependencies": {
32
+ "@repo/eslint-config": "*",
33
+ "@repo/typescript-config": "*",
34
+ "@turbo/gen": "^2.4.4",
35
+ "@types/node": "^22.13.9",
36
+ "@types/react": "19.2.2",
37
+ "@types/react-dom": "19.2.2",
38
+ "eslint": "^9.22.0",
39
+ "typescript": "5.8.2"
40
+ },
41
+ "dependencies": {
42
+ "@parhelia/core": "*",
43
+ "@tailwindcss/postcss": "^4.0.14",
44
+ "postcss": "^8.5.3",
45
+ "react": "19.2.3",
46
+ "react-dom": "19.2.3",
47
+ "tailwindcss": "^4.0.14"
48
+ }
49
+ }