@amplifyup/sdk 0.1.58 → 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/AmplifyRenderer.js +32 -0
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +32 -0
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -0
- package/dist/index.mjs.map +1 -1
- package/dist/react.js +64 -1
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +64 -1
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -2354,6 +2354,38 @@ Available Console Commands:
|
|
|
2354
2354
|
return;
|
|
2355
2355
|
}
|
|
2356
2356
|
try {
|
|
2357
|
+
if (event.data?.type === "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
|
+
});
|
|
2364
|
+
if (event.data.active && event.data.fieldName) {
|
|
2365
|
+
if (!document.getElementById("amplifyup-richtext-editing-style")) {
|
|
2366
|
+
const style = document.createElement("style");
|
|
2367
|
+
style.id = "amplifyup-richtext-editing-style";
|
|
2368
|
+
style.textContent = "[data-amplifyup-field].amplifyup-richtext-editing{outline:none!important;visibility:hidden!important;display:block!important;box-sizing:border-box!important;}";
|
|
2369
|
+
document.head.appendChild(style);
|
|
2370
|
+
}
|
|
2371
|
+
const editRoot = event.data.layoutNodeId ? document.querySelector(
|
|
2372
|
+
`[data-node-id="${event.data.layoutNodeId}"], [data-amplifyup-node-id="${event.data.layoutNodeId}"]`
|
|
2373
|
+
) || document : document;
|
|
2374
|
+
const editField = editRoot.querySelector(
|
|
2375
|
+
`[data-amplifyup-field="${event.data.fieldName}"]`
|
|
2376
|
+
);
|
|
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
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
return;
|
|
2388
|
+
}
|
|
2357
2389
|
if (event.data?.type === "AMPLIFYUP_FIELD_PATCH") {
|
|
2358
2390
|
window.dispatchEvent(
|
|
2359
2391
|
new CustomEvent("amplifyup:field-patch", { detail: event.data })
|
|
@@ -3884,6 +3916,7 @@ function ComposerInlineField({
|
|
|
3884
3916
|
ref: elRef,
|
|
3885
3917
|
className,
|
|
3886
3918
|
"data-amplifyup-field": name,
|
|
3919
|
+
"data-amplifyup-field-type": rich ? "richtext" : "text",
|
|
3887
3920
|
"data-amplifyup-node-id": layoutNodeId || void 0,
|
|
3888
3921
|
"data-amplifyup-empty-hint": showHint ? "true" : void 0,
|
|
3889
3922
|
contentEditable: !rich && !showRendered,
|
|
@@ -3979,6 +4012,7 @@ function ComposerInlineHtml({
|
|
|
3979
4012
|
ref: elRef,
|
|
3980
4013
|
className,
|
|
3981
4014
|
"data-amplifyup-field": name,
|
|
4015
|
+
"data-amplifyup-field-type": "richtext",
|
|
3982
4016
|
"data-amplifyup-node-id": layoutNodeId || void 0,
|
|
3983
4017
|
dangerouslySetInnerHTML: { __html: html },
|
|
3984
4018
|
onMouseDown: (event) => {
|
|
@@ -4229,6 +4263,8 @@ function Image(props) {
|
|
|
4229
4263
|
inferEditName(name, context?.props, sourceValue),
|
|
4230
4264
|
sourceValue
|
|
4231
4265
|
);
|
|
4266
|
+
const composerEdit = useComposerEditMode();
|
|
4267
|
+
const editName = inferEditName(name, context?.props, sourceValue);
|
|
4232
4268
|
warnProjectionProps("Image", name, hasExplicitValue);
|
|
4233
4269
|
if (!context && !hasExplicitValue) {
|
|
4234
4270
|
console.warn(
|
|
@@ -4237,15 +4273,42 @@ function Image(props) {
|
|
|
4237
4273
|
return null;
|
|
4238
4274
|
}
|
|
4239
4275
|
const src = imageSrc(fieldValue);
|
|
4240
|
-
if (!src) return null;
|
|
4241
4276
|
const portable = isPortableImageValue(fieldValue) ? fieldValue : null;
|
|
4242
4277
|
const alt = altProp ?? portable?.alt ?? "";
|
|
4243
4278
|
const width = widthProp ?? portable?.width;
|
|
4244
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
|
+
}
|
|
4245
4307
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4246
4308
|
"img",
|
|
4247
4309
|
{
|
|
4248
4310
|
...imgProps,
|
|
4311
|
+
...fieldAttrs,
|
|
4249
4312
|
src,
|
|
4250
4313
|
alt,
|
|
4251
4314
|
className,
|