@jxsuite/studio 0.24.0 → 0.25.1

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/studio.js CHANGED
@@ -262456,7 +262456,7 @@ function defaultDef(tag3) {
262456
262456
  else if (tag3 === "input")
262457
262457
  def3.attributes = { type: "text", placeholder: "Enter text..." };
262458
262458
  else if (tag3 === "img")
262459
- def3.attributes = { src: "", alt: "Image" };
262459
+ def3.attributes = { alt: "Image" };
262460
262460
  else if (tag3 === "iframe")
262461
262461
  def3.attributes = { src: "" };
262462
262462
  else if (tag3 === "select")
@@ -262731,6 +262731,8 @@ init_store();
262731
262731
  init_workspace2();
262732
262732
 
262733
262733
  // src/utils/edit-display.ts
262734
+ var mediaTags = new Set(["img", "video", "source", "iframe", "audio"]);
262735
+ var TRANSPARENT_PX = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
262734
262736
  function templateToEditDisplay(str) {
262735
262737
  return str.replace(/\$\{([^}]+)\}/g, "❪ $1 ❫");
262736
262738
  }
@@ -262750,9 +262752,38 @@ function prepareForEditMode(node) {
262750
262752
  return node.map(prepareForEditMode);
262751
262753
  const obj = node;
262752
262754
  const out = {};
262755
+ let needsMediaPlaceholder = false;
262756
+ const isMediaElement = mediaTags.has(obj.tagName || "");
262757
+ if (isMediaElement) {
262758
+ const attrs = obj.attributes;
262759
+ const topSrc = obj.src;
262760
+ const attrSrc = attrs?.src;
262761
+ const topPoster = obj.poster;
262762
+ const attrPoster = attrs?.poster;
262763
+ const hasSrc = topSrc && topSrc !== "" || attrSrc && attrSrc !== "";
262764
+ const hasPoster = topPoster && topPoster !== "" || attrPoster && attrPoster !== "";
262765
+ if (!hasSrc && !hasPoster) {
262766
+ needsMediaPlaceholder = true;
262767
+ }
262768
+ }
262753
262769
  for (const [k, v] of Object.entries(obj)) {
262754
- if (k === "state" || k === "$media" || k === "$props" || k === "$elements") {
262770
+ if (k === "state" || k === "$media" || k === "$elements") {
262755
262771
  out[k] = v;
262772
+ } else if (k === "$props" && v && typeof v === "object") {
262773
+ const propsOut = {};
262774
+ for (const [pk, pv] of Object.entries(v)) {
262775
+ if (typeof pv === "string" && pv.includes("${")) {
262776
+ const isUrlAttr = pk === "src" || pk === "href" || pk === "poster" || pk === "action";
262777
+ propsOut[pk] = isUrlAttr ? "" : templateToEditDisplay(pv);
262778
+ } else if (pv && typeof pv === "object" && pv.$ref) {
262779
+ const ref3 = pv.$ref;
262780
+ const label = ref3.startsWith("#/state/") ? ref3.slice(8) : ref3;
262781
+ propsOut[pk] = `{${label}}`;
262782
+ } else {
262783
+ propsOut[pk] = pv;
262784
+ }
262785
+ }
262786
+ out[k] = propsOut;
262756
262787
  } else if (k === "children") {
262757
262788
  if (Array.isArray(v)) {
262758
262789
  out.children = v.map(prepareForEditMode);
@@ -262798,6 +262829,29 @@ function prepareForEditMode(node) {
262798
262829
  ];
262799
262830
  }
262800
262831
  }
262832
+ } else if (k === "attributes" && isMediaElement && v && typeof v === "object") {
262833
+ const attrs = v;
262834
+ const processed = {};
262835
+ for (const [ak, av] of Object.entries(attrs)) {
262836
+ if (ak === "src" || ak === "poster") {
262837
+ if (typeof av === "string" && av !== "" && !av.includes("${")) {
262838
+ processed[ak] = av;
262839
+ } else {
262840
+ needsMediaPlaceholder = true;
262841
+ processed[ak] = TRANSPARENT_PX;
262842
+ }
262843
+ } else if (typeof av === "string" && av.includes("${")) {
262844
+ const isUrlAttr = ak === "href" || ak === "action";
262845
+ processed[ak] = isUrlAttr ? "" : templateToEditDisplay(av);
262846
+ } else if (av && typeof av === "object" && av.$ref) {
262847
+ const ref3 = av.$ref;
262848
+ const label = ref3.startsWith("#/state/") ? ref3.slice(8) : ref3;
262849
+ processed[ak] = `{${label}}`;
262850
+ } else {
262851
+ processed[ak] = av;
262852
+ }
262853
+ }
262854
+ out.attributes = processed;
262801
262855
  } else if (k === "style") {
262802
262856
  if (v && typeof v === "object") {
262803
262857
  const s = {};
@@ -262809,14 +262863,31 @@ function prepareForEditMode(node) {
262809
262863
  out.style = v;
262810
262864
  }
262811
262865
  } else if (typeof v === "string" && v.includes("${")) {
262812
- const isUrlAttr = k === "src" || k === "href" || k === "poster" || k === "action";
262813
- out[k] = isUrlAttr ? "" : templateToEditDisplay(v);
262866
+ const isMediaSrc = (k === "src" || k === "poster") && mediaTags.has(obj.tagName || "");
262867
+ if (isMediaSrc) {
262868
+ needsMediaPlaceholder = true;
262869
+ out[k] = TRANSPARENT_PX;
262870
+ } else {
262871
+ const isUrlAttr = k === "src" || k === "href" || k === "poster" || k === "action";
262872
+ out[k] = isUrlAttr ? "" : templateToEditDisplay(v);
262873
+ }
262814
262874
  } else if (v && typeof v === "object" && v.$ref) {
262815
262875
  const ref3 = v.$ref;
262816
262876
  const label = ref3.startsWith("#/state/") ? ref3.slice(8) : ref3;
262817
- out[k] = `{${label}}`;
262877
+ const isMediaSrc = (k === "src" || k === "poster") && mediaTags.has(obj.tagName || "");
262878
+ if (isMediaSrc) {
262879
+ needsMediaPlaceholder = true;
262880
+ out[k] = TRANSPARENT_PX;
262881
+ } else {
262882
+ out[k] = `{${label}}`;
262883
+ }
262818
262884
  } else {
262819
- out[k] = prepareForEditMode(v);
262885
+ if ((k === "src" || k === "poster") && v === "" && mediaTags.has(obj.tagName || "")) {
262886
+ needsMediaPlaceholder = true;
262887
+ out[k] = TRANSPARENT_PX;
262888
+ } else {
262889
+ out[k] = prepareForEditMode(v);
262890
+ }
262820
262891
  }
262821
262892
  }
262822
262893
  if (out.tagName && !out.textContent && !out.innerHTML) {
@@ -262883,6 +262954,12 @@ function prepareForEditMode(node) {
262883
262954
  }
262884
262955
  }
262885
262956
  }
262957
+ if (needsMediaPlaceholder) {
262958
+ const cls = out.className || "";
262959
+ if (!cls.includes("empty-media-placeholder")) {
262960
+ out.className = cls ? cls + " empty-media-placeholder" : "empty-media-placeholder";
262961
+ }
262962
+ }
262886
262963
  return out;
262887
262964
  }
262888
262965
 
@@ -312661,5 +312738,5 @@ effect(() => {
312661
312738
  scheduleAutosave();
312662
312739
  });
312663
312740
 
312664
- //# debugId=764A387CBBA5D51564756E2164756E21
312741
+ //# debugId=8A6CA76BD8515F1464756E2164756E21
312665
312742
  //# sourceMappingURL=studio.js.map