@salesforce/ui-bundle 9.4.1 → 9.6.0

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.
@@ -223,6 +223,22 @@
223
223
  }
224
224
 
225
225
  // src/design/interactions/communicationManager.ts
226
+ function getMediaInfo(element) {
227
+ switch (element.tagName) {
228
+ case "IMG": {
229
+ const img = element;
230
+ return {
231
+ tag: "img",
232
+ src: img.getAttribute("src") ?? "",
233
+ alt: img.getAttribute("alt") ?? "",
234
+ width: img.getAttribute("width") ?? "",
235
+ height: img.getAttribute("height") ?? ""
236
+ };
237
+ }
238
+ default:
239
+ return void 0;
240
+ }
241
+ }
226
242
  var CommunicationManager = class {
227
243
  constructor() {
228
244
  }
@@ -243,6 +259,7 @@
243
259
  const debugSource = getSourceFromDataAttributes(element);
244
260
  const textType = element.dataset?.textType ?? "none";
245
261
  const hasNonEditableText = TEXT_TAGS.includes(element.tagName) && (textType === "dynamic" || textType === "mixed");
262
+ const media = getMediaInfo(element);
246
263
  try {
247
264
  if (window.parent !== window) {
248
265
  window.parent.postMessage(
@@ -255,7 +272,8 @@
255
272
  ...styles
256
273
  },
257
274
  debugSource,
258
- hasNonEditableText
275
+ hasNonEditableText,
276
+ ...media ? { media } : {}
259
277
  }
260
278
  },
261
279
  "*"
@@ -588,6 +606,21 @@
588
606
  };
589
607
 
590
608
  // src/design/interactions/interactionsController.ts
609
+ var mediaAppliers = {
610
+ img: (el, attrs) => {
611
+ const img = el;
612
+ if (attrs.src !== void 0) img.setAttribute("src", attrs.src);
613
+ if (attrs.alt !== void 0) img.setAttribute("alt", attrs.alt);
614
+ if (attrs.width !== void 0) {
615
+ if (attrs.width === "") img.removeAttribute("width");
616
+ else img.setAttribute("width", attrs.width);
617
+ }
618
+ if (attrs.height !== void 0) {
619
+ if (attrs.height === "") img.removeAttribute("height");
620
+ else img.setAttribute("height", attrs.height);
621
+ }
622
+ }
623
+ };
591
624
  var InteractionsController = class {
592
625
  constructor(enabled = true) {
593
626
  __publicField(this, "enabled");
@@ -701,6 +734,31 @@
701
734
  el.textContent = text;
702
735
  }
703
736
  }
737
+ /**
738
+ * Apply attribute changes to all elements at the given source location whose
739
+ * `tagName` matches `tag` (case-insensitive). Per-tag appliers declare which
740
+ * attributes are valid and how empty-string values are handled (e.g. for
741
+ * `img`, an empty `width`/`height` clears the attribute).
742
+ *
743
+ * No-op if the tag has no registered applier. When `sourceLocation` is
744
+ * omitted (live edit), the source is read from the currently selected
745
+ * element; when provided (undo/redo replay), it is used directly.
746
+ *
747
+ * To support a new tag, add an entry to {@link mediaAppliers}.
748
+ *
749
+ * @param tag - The HTML tag the change targets (e.g. `"img"`).
750
+ * @param attributes - Sparse map of attribute names to their new string values; `undefined` values are skipped.
751
+ * @param sourceLocation - Explicit source location for undo/redo; falls back to the selected element when omitted.
752
+ */
753
+ applyMediaChange(tag, attributes, sourceLocation) {
754
+ const applier = mediaAppliers[tag.toLowerCase()];
755
+ if (!applier) return;
756
+ const tagNameUpper = tag.toUpperCase();
757
+ for (const el of this.resolveTargets(sourceLocation)) {
758
+ if (el.tagName !== tagNameUpper) continue;
759
+ applier(el, attributes);
760
+ }
761
+ }
704
762
  /**
705
763
  * Cleanup and remove event listeners
706
764
  */
@@ -747,6 +805,17 @@
747
805
  parseSourceLocation(typed.sourceLocation)
748
806
  );
749
807
  }
808
+ if (typed && typed.type === "media-change") {
809
+ const tag = typeof typed.tag === "string" ? typed.tag : "";
810
+ const rawAttributes = typed.attributes && typeof typed.attributes === "object" ? typed.attributes : {};
811
+ const attributes = {};
812
+ for (const [key, raw] of Object.entries(rawAttributes)) {
813
+ attributes[key] = raw === void 0 ? void 0 : String(raw);
814
+ }
815
+ if (tag) {
816
+ interactions.applyMediaChange(tag, attributes, parseSourceLocation(typed.sourceLocation));
817
+ }
818
+ }
750
819
  if (typed && typed.type === "enable-interactions") {
751
820
  window.enableInteractions?.();
752
821
  }
@@ -3,6 +3,37 @@
3
3
  * All rights reserved.
4
4
  * For full license text, see the LICENSE.txt file
5
5
  */
6
+ /**
7
+ * Editable attributes reported for an `<img>` element on selection. Strings
8
+ * mirror the raw HTML attribute values; missing attributes are reported as `""`.
9
+ *
10
+ * - `width` / `height` are unitless integer strings (px); `""` means the
11
+ * attribute is absent and the image renders at its intrinsic size.
12
+ */
13
+ interface ImageMediaInfo {
14
+ tag: "img";
15
+ src: string;
16
+ alt: string;
17
+ width: string;
18
+ height: string;
19
+ }
20
+ /**
21
+ * Discriminated union of media-element metadata, keyed by `tag`. To support a
22
+ * new media tag in future if required, add a variant here and a matching case
23
+ * in {@link getMediaInfo}.
24
+ */
25
+ export type MediaInfo = ImageMediaInfo;
26
+ /**
27
+ * Extract editable media metadata from a selected element.
28
+ *
29
+ * Switches on `element.tagName` and returns the variant matching the tag, or
30
+ * `undefined` for elements without a registered media tag (the caller then
31
+ * omits the `media` field from the `component-selected` payload).
32
+ *
33
+ * @param element - The selected DOM element.
34
+ * @returns The media info variant for the element's tag, or `undefined` if the tag is not media.
35
+ */
36
+ export declare function getMediaInfo(element: HTMLElement): MediaInfo | undefined;
6
37
  export declare class CommunicationManager {
7
38
  constructor();
8
39
  /**
@@ -22,4 +53,5 @@ export declare class CommunicationManager {
22
53
  */
23
54
  notifyInitializationComplete(): void;
24
55
  }
56
+ export {};
25
57
  //# sourceMappingURL=communicationManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"communicationManager.d.ts","sourceRoot":"","sources":["../../../src/design/interactions/communicationManager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiBH,qBAAa,oBAAoB;;IAKhC;;;OAGG;IACH,uBAAuB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAuDnD;;;;;OAKG;IACH,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAyBnF;;OAEG;IACH,4BAA4B,IAAI,IAAI;CAepC"}
1
+ {"version":3,"file":"communicationManager.d.ts","sourceRoot":"","sources":["../../../src/design/interactions/communicationManager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiBH;;;;;;GAMG;AACH,UAAU,cAAc;IACvB,GAAG,EAAE,KAAK,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,cAAc,CAAC;AAEvC;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,GAAG,SAAS,CAexE;AAED,qBAAa,oBAAoB;;IAKhC;;;OAGG;IACH,uBAAuB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IA0DnD;;;;;OAKG;IACH,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAyBnF;;OAEG;IACH,4BAA4B,IAAI,IAAI;CAepC"}
@@ -28,6 +28,23 @@ export declare class InteractionsController {
28
28
  */
29
29
  applyStyleChange(property: string, value: string, sourceLocation?: SourceLocation): void;
30
30
  applyTextChange(text: string, sourceLocation?: SourceLocation): void;
31
+ /**
32
+ * Apply attribute changes to all elements at the given source location whose
33
+ * `tagName` matches `tag` (case-insensitive). Per-tag appliers declare which
34
+ * attributes are valid and how empty-string values are handled (e.g. for
35
+ * `img`, an empty `width`/`height` clears the attribute).
36
+ *
37
+ * No-op if the tag has no registered applier. When `sourceLocation` is
38
+ * omitted (live edit), the source is read from the currently selected
39
+ * element; when provided (undo/redo replay), it is used directly.
40
+ *
41
+ * To support a new tag, add an entry to {@link mediaAppliers}.
42
+ *
43
+ * @param tag - The HTML tag the change targets (e.g. `"img"`).
44
+ * @param attributes - Sparse map of attribute names to their new string values; `undefined` values are skipped.
45
+ * @param sourceLocation - Explicit source location for undo/redo; falls back to the selected element when omitted.
46
+ */
47
+ applyMediaChange(tag: string, attributes: Record<string, string | undefined>, sourceLocation?: SourceLocation): void;
31
48
  /**
32
49
  * Cleanup and remove event listeners
33
50
  */
@@ -1 +1 @@
1
- {"version":3,"file":"interactionsController.d.ts","sourceRoot":"","sources":["../../../src/design/interactions/interactionsController.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,OAAO,EAGN,KAAK,cAAc,EACnB,MAAM,qBAAqB,CAAC;AAE7B,qBAAa,sBAAsB;IAClC,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,QAAQ,CAAU;IAE1B,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,oBAAoB,CAAuB;IACnD,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,aAAa,CAAgB;gBAEzB,OAAO,UAAO;IAwD1B;;OAEG;IACH,UAAU,IAAI,IAAI;IAiBlB;;OAEG;IACH,MAAM,IAAI,IAAI;IAKd;;OAEG;IACH,OAAO,IAAI,IAAI;IAMf,OAAO,CAAC,cAAc;IAWtB;;;;OAIG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI;IAMxF,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI;IAMpE;;OAEG;IACH,OAAO,IAAI,IAAI;CAOf"}
1
+ {"version":3,"file":"interactionsController.d.ts","sourceRoot":"","sources":["../../../src/design/interactions/interactionsController.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,OAAO,EAGN,KAAK,cAAc,EACnB,MAAM,qBAAqB,CAAC;AAmC7B,qBAAa,sBAAsB;IAClC,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,QAAQ,CAAU;IAE1B,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,oBAAoB,CAAuB;IACnD,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,aAAa,CAAgB;gBAEzB,OAAO,UAAO;IAwD1B;;OAEG;IACH,UAAU,IAAI,IAAI;IAiBlB;;OAEG;IACH,MAAM,IAAI,IAAI;IAKd;;OAEG;IACH,OAAO,IAAI,IAAI;IAMf,OAAO,CAAC,cAAc;IAWtB;;;;OAIG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI;IAMxF,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI;IAMpE;;;;;;;;;;;;;;;OAeG;IACH,gBAAgB,CACf,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EAC9C,cAAc,CAAC,EAAE,cAAc,GAC7B,IAAI;IAUP;;OAEG;IACH,OAAO,IAAI,IAAI;CAOf"}
@@ -1,4 +1,4 @@
1
- const version = "9.4.1";
1
+ const version = "9.6.0";
2
2
  export {
3
3
  version
4
4
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@salesforce/ui-bundle",
3
3
  "description": "Core package for Salesforce UI Bundles",
4
- "version": "9.4.1",
4
+ "version": "9.6.0",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@salesforce/core": "^8.23.4",
47
- "@salesforce/platform-sdk": "^9.4.1",
47
+ "@salesforce/platform-sdk": "^9.6.0",
48
48
  "micromatch": "^4.0.8",
49
49
  "path-to-regexp": "^8.3.0"
50
50
  },