@alpaca-editor/sharedien-dam 1.0.4170 → 1.0.4173

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alpaca-editor/sharedien-dam",
3
- "version": "1.0.4170",
3
+ "version": "1.0.4173",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,5 +1,9 @@
1
1
  import React from "react";
2
- import { ClientFieldButton, PictureRawValue, VariantFieldActionProps } from "@alpaca-editor/core";
2
+ import {
3
+ ClientFieldButton,
4
+ PictureRawValue,
5
+ VariantFieldActionProps,
6
+ } from "@alpaca-editor/core";
3
7
  import { DamSelector } from "./DamSelector";
4
8
  import { DamImageValue, DamSelectorProps } from "./types";
5
9
  import { ExternalLink } from "lucide-react";
@@ -7,11 +11,18 @@ import { ExternalLink } from "lucide-react";
7
11
  export const DamSelectorButton: ClientFieldButton = {
8
12
  label: "Select from DAM",
9
13
  icon: (<ExternalLink strokeWidth={1} size={16} />) as React.ReactNode,
10
- showInMenu: false, // Primary action - appears outside menu
11
- clientAction: async ({ editContext, field, variantName: contextVariantName }: VariantFieldActionProps) => {
12
- const data = await editContext.openDialog<DamImageValue, DamSelectorProps>(DamSelector, {
13
- language: field.descriptor.item.language
14
- });
14
+ isPimaryAction: false, // Primary action - appears outside menu
15
+ clientAction: async ({
16
+ editContext,
17
+ field,
18
+ variantName: contextVariantName,
19
+ }: VariantFieldActionProps) => {
20
+ const data = await editContext.openDialog<DamImageValue, DamSelectorProps>(
21
+ DamSelector,
22
+ {
23
+ language: field.descriptor.item.language,
24
+ }
25
+ );
15
26
 
16
27
  if (data?.mediaId || data?.videoId) {
17
28
  const raw = (() => {
@@ -28,29 +39,40 @@ export const DamSelectorButton: ClientFieldButton = {
28
39
  // Get variant name from context (when called from PictureEditor variant button)
29
40
  // or fallback to trying to determine it from field data
30
41
  let variantName: string | undefined = contextVariantName;
31
-
42
+
32
43
  if (!variantName && raw.Variants && raw.Variants.length > 0) {
33
44
  // Use the first variant's name if available
34
45
  variantName = raw.Variants[0]?.Name;
35
46
  }
36
-
47
+
37
48
  // If we still don't have a variant name, try to get it from the field's value
38
- if (!variantName && field.value && typeof field.value === 'object' && 'variants' in field.value) {
49
+ if (
50
+ !variantName &&
51
+ field.value &&
52
+ typeof field.value === "object" &&
53
+ "variants" in field.value
54
+ ) {
39
55
  const variants = (field.value as any).variants;
40
- if (Array.isArray(variants) && variants.length > 0 && variants[0]?.name) {
56
+ if (
57
+ Array.isArray(variants) &&
58
+ variants.length > 0 &&
59
+ variants[0]?.name
60
+ ) {
41
61
  variantName = variants[0].name;
42
62
  }
43
63
  }
44
64
 
45
65
  if (!variantName) {
46
- console.warn("Cannot determine variant name for DAM selection. No variants found in picture field.");
66
+ console.warn(
67
+ "Cannot determine variant name for DAM selection. No variants found in picture field."
68
+ );
47
69
  return;
48
70
  }
49
71
 
50
72
  // Update or create the variant
51
73
  if (!raw.Variants) raw.Variants = [];
52
74
  const selected = raw.Variants.find((x: any) => x.Name == variantName);
53
-
75
+
54
76
  if (selected) {
55
77
  selected.MediaId = data.mediaId;
56
78
  selected.VideoId = data.videoId;
@@ -72,4 +94,4 @@ export const DamSelectorButton: ClientFieldButton = {
72
94
  isGenerator: false,
73
95
  id: "select-from-dam",
74
96
  description: "Opens the sharedien DAM to select an image or video",
75
- }
97
+ };