@amplifyup/sdk 0.1.59 → 0.1.61
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 +16 -3
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +16 -3
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.js +16 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -3
- package/dist/index.mjs.map +1 -1
- package/dist/react.js +90 -5
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +90 -5
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
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) =>
|
|
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)
|
|
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
|
}
|
|
@@ -3733,6 +3746,20 @@ function canInlineEditRichText(name, value) {
|
|
|
3733
3746
|
}
|
|
3734
3747
|
return true;
|
|
3735
3748
|
}
|
|
3749
|
+
function isLikelyImagePropName(name) {
|
|
3750
|
+
const n = name.toLowerCase();
|
|
3751
|
+
return n.includes("image") || n.includes("thumbnail") || n.includes("photo") || n.includes("avatar") || n.includes("poster") || n.includes("logo") || n.endsWith("img") || n.endsWith("_src") || n.endsWith("Src");
|
|
3752
|
+
}
|
|
3753
|
+
function portableImageUrl(value) {
|
|
3754
|
+
if (typeof value === "string") return value.trim();
|
|
3755
|
+
if (value && typeof value === "object" && !Array.isArray(value) && "url" in value) {
|
|
3756
|
+
const url = value.url;
|
|
3757
|
+
if (url == null) return "";
|
|
3758
|
+
if (typeof url === "string") return url.trim();
|
|
3759
|
+
return null;
|
|
3760
|
+
}
|
|
3761
|
+
return null;
|
|
3762
|
+
}
|
|
3736
3763
|
function inferEditName(explicitName, contextProps, sourceValue) {
|
|
3737
3764
|
if (explicitName) return explicitName;
|
|
3738
3765
|
if (!contextProps) return "";
|
|
@@ -3740,6 +3767,22 @@ function inferEditName(explicitName, contextProps, sourceValue) {
|
|
|
3740
3767
|
(key) => Object.is(contextProps[key], sourceValue)
|
|
3741
3768
|
);
|
|
3742
3769
|
if (keys.length === 1) return keys[0];
|
|
3770
|
+
const srcUrl = portableImageUrl(sourceValue);
|
|
3771
|
+
if (srcUrl !== null) {
|
|
3772
|
+
const byUrl = Object.keys(contextProps).filter((key) => {
|
|
3773
|
+
const other = portableImageUrl(contextProps[key]);
|
|
3774
|
+
return other !== null && other === srcUrl;
|
|
3775
|
+
});
|
|
3776
|
+
if (byUrl.length === 1) return byUrl[0];
|
|
3777
|
+
if (srcUrl === "") {
|
|
3778
|
+
const emptyImageKeys = Object.keys(contextProps).filter((key) => {
|
|
3779
|
+
if (!isLikelyImagePropName(key)) return false;
|
|
3780
|
+
const other = portableImageUrl(contextProps[key]);
|
|
3781
|
+
return other === "" || contextProps[key] == null;
|
|
3782
|
+
});
|
|
3783
|
+
if (emptyImageKeys.length === 1) return emptyImageKeys[0];
|
|
3784
|
+
}
|
|
3785
|
+
}
|
|
3743
3786
|
if (keys.length === 0 || isComposerEmptyText(sourceValue)) return "";
|
|
3744
3787
|
return keys[0];
|
|
3745
3788
|
}
|
|
@@ -3903,6 +3946,7 @@ function ComposerInlineField({
|
|
|
3903
3946
|
ref: elRef,
|
|
3904
3947
|
className,
|
|
3905
3948
|
"data-amplifyup-field": name,
|
|
3949
|
+
"data-amplifyup-field-type": rich ? "richtext" : "text",
|
|
3906
3950
|
"data-amplifyup-node-id": layoutNodeId || void 0,
|
|
3907
3951
|
"data-amplifyup-empty-hint": showHint ? "true" : void 0,
|
|
3908
3952
|
contentEditable: !rich && !showRendered,
|
|
@@ -3998,6 +4042,7 @@ function ComposerInlineHtml({
|
|
|
3998
4042
|
ref: elRef,
|
|
3999
4043
|
className,
|
|
4000
4044
|
"data-amplifyup-field": name,
|
|
4045
|
+
"data-amplifyup-field-type": "richtext",
|
|
4001
4046
|
"data-amplifyup-node-id": layoutNodeId || void 0,
|
|
4002
4047
|
dangerouslySetInnerHTML: { __html: html },
|
|
4003
4048
|
onMouseDown: (event) => {
|
|
@@ -4248,6 +4293,8 @@ function Image(props) {
|
|
|
4248
4293
|
inferEditName(name, context?.props, sourceValue),
|
|
4249
4294
|
sourceValue
|
|
4250
4295
|
);
|
|
4296
|
+
const composerEdit = useComposerEditMode();
|
|
4297
|
+
const editName = inferEditName(name, context?.props, sourceValue);
|
|
4251
4298
|
warnProjectionProps("Image", name, hasExplicitValue);
|
|
4252
4299
|
if (!context && !hasExplicitValue) {
|
|
4253
4300
|
console.warn(
|
|
@@ -4256,20 +4303,58 @@ function Image(props) {
|
|
|
4256
4303
|
return null;
|
|
4257
4304
|
}
|
|
4258
4305
|
const src = imageSrc(fieldValue);
|
|
4259
|
-
if (!src) return null;
|
|
4260
4306
|
const portable = isPortableImageValue(fieldValue) ? fieldValue : null;
|
|
4261
4307
|
const alt = altProp ?? portable?.alt ?? "";
|
|
4262
4308
|
const width = widthProp ?? portable?.width;
|
|
4263
4309
|
const height = heightProp ?? portable?.height;
|
|
4310
|
+
const fieldAttrs = composerEdit && editName ? {
|
|
4311
|
+
"data-amplifyup-field": editName,
|
|
4312
|
+
"data-amplifyup-field-type": "image",
|
|
4313
|
+
"data-amplifyup-node-id": context?.layoutNodeId || void 0
|
|
4314
|
+
} : null;
|
|
4315
|
+
if (composerEdit && !editName && (hasExplicitValue || name)) {
|
|
4316
|
+
console.warn(
|
|
4317
|
+
'[AmplifyUp SDK] Image could not infer a Composer field name from value={\u2026}. Pass name="yourProp" (same as the component prop) so the image can be selected.'
|
|
4318
|
+
);
|
|
4319
|
+
}
|
|
4320
|
+
if (!src) {
|
|
4321
|
+
if (!composerEdit || !fieldAttrs) return null;
|
|
4322
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4323
|
+
"span",
|
|
4324
|
+
{
|
|
4325
|
+
...fieldAttrs,
|
|
4326
|
+
className,
|
|
4327
|
+
role: "img",
|
|
4328
|
+
"aria-label": alt || editName || "Image",
|
|
4329
|
+
style: {
|
|
4330
|
+
display: "block",
|
|
4331
|
+
boxSizing: "border-box",
|
|
4332
|
+
minWidth: width ? void 0 : 120,
|
|
4333
|
+
minHeight: height ? void 0 : 80,
|
|
4334
|
+
width: width || "100%",
|
|
4335
|
+
height: height || void 0,
|
|
4336
|
+
background: "color-mix(in srgb, currentColor 8%, transparent)",
|
|
4337
|
+
outline: "2px dashed hsl(82 100% 45%)",
|
|
4338
|
+
outlineOffset: 2,
|
|
4339
|
+
cursor: "pointer"
|
|
4340
|
+
}
|
|
4341
|
+
}
|
|
4342
|
+
);
|
|
4343
|
+
}
|
|
4264
4344
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4265
4345
|
"img",
|
|
4266
4346
|
{
|
|
4267
4347
|
...imgProps,
|
|
4348
|
+
...fieldAttrs,
|
|
4268
4349
|
src,
|
|
4269
4350
|
alt,
|
|
4270
4351
|
className,
|
|
4271
4352
|
width,
|
|
4272
|
-
height
|
|
4353
|
+
height,
|
|
4354
|
+
style: {
|
|
4355
|
+
...typeof imgProps.style === "object" && imgProps.style ? imgProps.style : {},
|
|
4356
|
+
...composerEdit && fieldAttrs ? { cursor: "pointer" } : null
|
|
4357
|
+
}
|
|
4273
4358
|
}
|
|
4274
4359
|
);
|
|
4275
4360
|
}
|