@amplifyup/sdk 0.1.59 → 0.1.60

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/react.mjs CHANGED
@@ -2349,12 +2349,17 @@ Available Console Commands:
2349
2349
  }
2350
2350
  try {
2351
2351
  if (event.data?.type === "AMPLIFYUP_RICHTEXT_EDITING") {
2352
- document.querySelectorAll(".amplifyup-richtext-editing").forEach((el) => el.classList.remove("amplifyup-richtext-editing"));
2352
+ document.querySelectorAll(".amplifyup-richtext-editing").forEach((el) => {
2353
+ el.classList.remove("amplifyup-richtext-editing");
2354
+ el.style.minHeight = "";
2355
+ el.style.height = "";
2356
+ el.style.display = "";
2357
+ });
2353
2358
  if (event.data.active && event.data.fieldName) {
2354
2359
  if (!document.getElementById("amplifyup-richtext-editing-style")) {
2355
2360
  const style = document.createElement("style");
2356
2361
  style.id = "amplifyup-richtext-editing-style";
2357
- style.textContent = "[data-amplifyup-field].amplifyup-richtext-editing{outline:none!important;visibility:hidden!important;}";
2362
+ style.textContent = "[data-amplifyup-field].amplifyup-richtext-editing{outline:none!important;visibility:hidden!important;display:block!important;box-sizing:border-box!important;}";
2358
2363
  document.head.appendChild(style);
2359
2364
  }
2360
2365
  const editRoot = event.data.layoutNodeId ? document.querySelector(
@@ -2363,7 +2368,15 @@ Available Console Commands:
2363
2368
  const editField = editRoot.querySelector(
2364
2369
  `[data-amplifyup-field="${event.data.fieldName}"]`
2365
2370
  );
2366
- if (editField) editField.classList.add("amplifyup-richtext-editing");
2371
+ if (editField) {
2372
+ editField.classList.add("amplifyup-richtext-editing");
2373
+ const editHeight = Number(event.data.height) || 0;
2374
+ if (editHeight > 0) {
2375
+ editField.style.display = "block";
2376
+ editField.style.minHeight = `${editHeight}px`;
2377
+ editField.style.height = `${editHeight}px`;
2378
+ }
2379
+ }
2367
2380
  }
2368
2381
  return;
2369
2382
  }
@@ -3897,6 +3910,7 @@ function ComposerInlineField({
3897
3910
  ref: elRef,
3898
3911
  className,
3899
3912
  "data-amplifyup-field": name,
3913
+ "data-amplifyup-field-type": rich ? "richtext" : "text",
3900
3914
  "data-amplifyup-node-id": layoutNodeId || void 0,
3901
3915
  "data-amplifyup-empty-hint": showHint ? "true" : void 0,
3902
3916
  contentEditable: !rich && !showRendered,
@@ -3992,6 +4006,7 @@ function ComposerInlineHtml({
3992
4006
  ref: elRef,
3993
4007
  className,
3994
4008
  "data-amplifyup-field": name,
4009
+ "data-amplifyup-field-type": "richtext",
3995
4010
  "data-amplifyup-node-id": layoutNodeId || void 0,
3996
4011
  dangerouslySetInnerHTML: { __html: html },
3997
4012
  onMouseDown: (event) => {
@@ -4242,6 +4257,8 @@ function Image(props) {
4242
4257
  inferEditName(name, context?.props, sourceValue),
4243
4258
  sourceValue
4244
4259
  );
4260
+ const composerEdit = useComposerEditMode();
4261
+ const editName = inferEditName(name, context?.props, sourceValue);
4245
4262
  warnProjectionProps("Image", name, hasExplicitValue);
4246
4263
  if (!context && !hasExplicitValue) {
4247
4264
  console.warn(
@@ -4250,15 +4267,42 @@ function Image(props) {
4250
4267
  return null;
4251
4268
  }
4252
4269
  const src = imageSrc(fieldValue);
4253
- if (!src) return null;
4254
4270
  const portable = isPortableImageValue(fieldValue) ? fieldValue : null;
4255
4271
  const alt = altProp ?? portable?.alt ?? "";
4256
4272
  const width = widthProp ?? portable?.width;
4257
4273
  const height = heightProp ?? portable?.height;
4274
+ const fieldAttrs = composerEdit && editName ? {
4275
+ "data-amplifyup-field": editName,
4276
+ "data-amplifyup-field-type": "image",
4277
+ "data-amplifyup-node-id": context?.layoutNodeId || void 0
4278
+ } : null;
4279
+ if (!src) {
4280
+ if (!composerEdit || !fieldAttrs) return null;
4281
+ return /* @__PURE__ */ jsx(
4282
+ "span",
4283
+ {
4284
+ ...fieldAttrs,
4285
+ className,
4286
+ role: "img",
4287
+ "aria-label": alt || editName || "Image",
4288
+ style: {
4289
+ display: "inline-block",
4290
+ minWidth: width ? void 0 : 48,
4291
+ minHeight: height ? void 0 : 48,
4292
+ width: width || void 0,
4293
+ height: height || void 0,
4294
+ background: "color-mix(in srgb, currentColor 8%, transparent)",
4295
+ outline: "1px dashed color-mix(in srgb, currentColor 40%, transparent)",
4296
+ outlineOffset: 2
4297
+ }
4298
+ }
4299
+ );
4300
+ }
4258
4301
  return /* @__PURE__ */ jsx(
4259
4302
  "img",
4260
4303
  {
4261
4304
  ...imgProps,
4305
+ ...fieldAttrs,
4262
4306
  src,
4263
4307
  alt,
4264
4308
  className,