@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.js CHANGED
@@ -2355,12 +2355,17 @@ Available Console Commands:
2355
2355
  }
2356
2356
  try {
2357
2357
  if (event.data?.type === "AMPLIFYUP_RICHTEXT_EDITING") {
2358
- document.querySelectorAll(".amplifyup-richtext-editing").forEach((el) => el.classList.remove("amplifyup-richtext-editing"));
2358
+ document.querySelectorAll(".amplifyup-richtext-editing").forEach((el) => {
2359
+ el.classList.remove("amplifyup-richtext-editing");
2360
+ el.style.minHeight = "";
2361
+ el.style.height = "";
2362
+ el.style.display = "";
2363
+ });
2359
2364
  if (event.data.active && event.data.fieldName) {
2360
2365
  if (!document.getElementById("amplifyup-richtext-editing-style")) {
2361
2366
  const style = document.createElement("style");
2362
2367
  style.id = "amplifyup-richtext-editing-style";
2363
- style.textContent = "[data-amplifyup-field].amplifyup-richtext-editing{outline:none!important;visibility:hidden!important;}";
2368
+ style.textContent = "[data-amplifyup-field].amplifyup-richtext-editing{outline:none!important;visibility:hidden!important;display:block!important;box-sizing:border-box!important;}";
2364
2369
  document.head.appendChild(style);
2365
2370
  }
2366
2371
  const editRoot = event.data.layoutNodeId ? document.querySelector(
@@ -2369,7 +2374,15 @@ Available Console Commands:
2369
2374
  const editField = editRoot.querySelector(
2370
2375
  `[data-amplifyup-field="${event.data.fieldName}"]`
2371
2376
  );
2372
- if (editField) editField.classList.add("amplifyup-richtext-editing");
2377
+ if (editField) {
2378
+ editField.classList.add("amplifyup-richtext-editing");
2379
+ const editHeight = Number(event.data.height) || 0;
2380
+ if (editHeight > 0) {
2381
+ editField.style.display = "block";
2382
+ editField.style.minHeight = `${editHeight}px`;
2383
+ editField.style.height = `${editHeight}px`;
2384
+ }
2385
+ }
2373
2386
  }
2374
2387
  return;
2375
2388
  }
@@ -3903,6 +3916,7 @@ function ComposerInlineField({
3903
3916
  ref: elRef,
3904
3917
  className,
3905
3918
  "data-amplifyup-field": name,
3919
+ "data-amplifyup-field-type": rich ? "richtext" : "text",
3906
3920
  "data-amplifyup-node-id": layoutNodeId || void 0,
3907
3921
  "data-amplifyup-empty-hint": showHint ? "true" : void 0,
3908
3922
  contentEditable: !rich && !showRendered,
@@ -3998,6 +4012,7 @@ function ComposerInlineHtml({
3998
4012
  ref: elRef,
3999
4013
  className,
4000
4014
  "data-amplifyup-field": name,
4015
+ "data-amplifyup-field-type": "richtext",
4001
4016
  "data-amplifyup-node-id": layoutNodeId || void 0,
4002
4017
  dangerouslySetInnerHTML: { __html: html },
4003
4018
  onMouseDown: (event) => {
@@ -4248,6 +4263,8 @@ function Image(props) {
4248
4263
  inferEditName(name, context?.props, sourceValue),
4249
4264
  sourceValue
4250
4265
  );
4266
+ const composerEdit = useComposerEditMode();
4267
+ const editName = inferEditName(name, context?.props, sourceValue);
4251
4268
  warnProjectionProps("Image", name, hasExplicitValue);
4252
4269
  if (!context && !hasExplicitValue) {
4253
4270
  console.warn(
@@ -4256,15 +4273,42 @@ function Image(props) {
4256
4273
  return null;
4257
4274
  }
4258
4275
  const src = imageSrc(fieldValue);
4259
- if (!src) return null;
4260
4276
  const portable = isPortableImageValue(fieldValue) ? fieldValue : null;
4261
4277
  const alt = altProp ?? portable?.alt ?? "";
4262
4278
  const width = widthProp ?? portable?.width;
4263
4279
  const height = heightProp ?? portable?.height;
4280
+ const fieldAttrs = composerEdit && editName ? {
4281
+ "data-amplifyup-field": editName,
4282
+ "data-amplifyup-field-type": "image",
4283
+ "data-amplifyup-node-id": context?.layoutNodeId || void 0
4284
+ } : null;
4285
+ if (!src) {
4286
+ if (!composerEdit || !fieldAttrs) return null;
4287
+ return /* @__PURE__ */ jsxRuntime.jsx(
4288
+ "span",
4289
+ {
4290
+ ...fieldAttrs,
4291
+ className,
4292
+ role: "img",
4293
+ "aria-label": alt || editName || "Image",
4294
+ style: {
4295
+ display: "inline-block",
4296
+ minWidth: width ? void 0 : 48,
4297
+ minHeight: height ? void 0 : 48,
4298
+ width: width || void 0,
4299
+ height: height || void 0,
4300
+ background: "color-mix(in srgb, currentColor 8%, transparent)",
4301
+ outline: "1px dashed color-mix(in srgb, currentColor 40%, transparent)",
4302
+ outlineOffset: 2
4303
+ }
4304
+ }
4305
+ );
4306
+ }
4264
4307
  return /* @__PURE__ */ jsxRuntime.jsx(
4265
4308
  "img",
4266
4309
  {
4267
4310
  ...imgProps,
4311
+ ...fieldAttrs,
4268
4312
  src,
4269
4313
  alt,
4270
4314
  className,