@salesforce/ui-design-mode 12.6.3 → 12.7.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.
Files changed (33) hide show
  1. package/dist/authoring/core/DesignPropertyPanelRoot.d.ts.map +1 -1
  2. package/dist/authoring/core/editors/BoxDimensionEditor.d.ts.map +1 -1
  3. package/dist/authoring/core/editors/ColorEditor.d.cts +9 -7
  4. package/dist/authoring/core/editors/ColorEditor.d.ts +9 -7
  5. package/dist/authoring/core/editors/ColorEditor.d.ts.map +1 -1
  6. package/dist/authoring/core/utils/colorOcclusion.d.cts +185 -0
  7. package/dist/authoring/core/utils/colorOcclusion.d.ts +185 -0
  8. package/dist/authoring/core/utils/colorOcclusion.d.ts.map +1 -0
  9. package/dist/authoring/core/utils/colorUtils.d.cts +26 -0
  10. package/dist/authoring/core/utils/colorUtils.d.ts +26 -0
  11. package/dist/authoring/core/utils/colorUtils.d.ts.map +1 -1
  12. package/dist/authoring/react/index.js +4 -4
  13. package/dist/authoring/web-component/index.js +22 -22
  14. package/dist/protocol/messageTypes.d.ts.map +1 -1
  15. package/dist/protocol/version.cjs +1 -1
  16. package/dist/protocol/version.js +1 -1
  17. package/dist/runtime/design-mode-interactions.js +451 -94
  18. package/dist/runtime/interactions/eventHandlers.d.cts +17 -32
  19. package/dist/runtime/interactions/eventHandlers.d.ts +17 -32
  20. package/dist/runtime/interactions/eventHandlers.d.ts.map +1 -1
  21. package/dist/runtime/interactions/interactionsController.d.cts +1 -8
  22. package/dist/runtime/interactions/interactionsController.d.ts +1 -8
  23. package/dist/runtime/interactions/interactionsController.d.ts.map +1 -1
  24. package/dist/runtime/interactions/interceptOverlay.d.cts +172 -0
  25. package/dist/runtime/interactions/interceptOverlay.d.ts +172 -0
  26. package/dist/runtime/interactions/interceptOverlay.d.ts.map +1 -0
  27. package/dist/runtime/interactions/utils/cssUtils.d.cts +22 -0
  28. package/dist/runtime/interactions/utils/cssUtils.d.ts +22 -0
  29. package/dist/runtime/interactions/utils/cssUtils.d.ts.map +1 -1
  30. package/package.json +2 -2
  31. package/dist/authoring/core/utils/backgroundOcclusion.d.cts +0 -48
  32. package/dist/authoring/core/utils/backgroundOcclusion.d.ts +0 -48
  33. package/dist/authoring/core/utils/backgroundOcclusion.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"messageTypes.d.ts","sourceRoot":"","sources":["../../src/protocol/messageTypes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;GASG;AAEH;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACrB;AAID,MAAM,WAAW,yBAAyB;IACzC,IAAI,EAAE,qBAAqB,CAAC;IAC5B;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,0BAA0B;IAC1C,IAAI,EAAE,sBAAsB,CAAC;CAC7B;AAED,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,cAAc,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,cAAc,CAAC;CAChC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAC/C,cAAc,CAAC,EAAE,cAAc,CAAC;CAChC;AAED;;;;;;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AM,kBAAkB,EAAG,gBAAyB,CAAC;AAC5D,eAAO,MAAM,4BAA4B,EAAG,0BAAmC,CAAC;AAChF,eAAO,MAAM,sBAAsB,EAAG,oBAA6B,CAAC;AACpE,eAAO,MAAM,gBAAgB,EAAG,cAAuB,CAAC;AAIxD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAG,gBAAyB,CAAC"}
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const UI_DESIGN_MODE_VERSION = "12.6.3";
3
+ const UI_DESIGN_MODE_VERSION = "12.7.0";
4
4
  exports.UI_DESIGN_MODE_VERSION = UI_DESIGN_MODE_VERSION;
@@ -1,4 +1,4 @@
1
- const UI_DESIGN_MODE_VERSION = "12.6.3";
1
+ const UI_DESIGN_MODE_VERSION = "12.7.0";
2
2
  export {
3
3
  UI_DESIGN_MODE_VERSION
4
4
  };
@@ -44,7 +44,7 @@
44
44
  ];
45
45
 
46
46
  // src/protocol/version.ts
47
- var UI_DESIGN_MODE_VERSION = "12.6.3";
47
+ var UI_DESIGN_MODE_VERSION = "12.7.0";
48
48
 
49
49
  // src/runtime/interactions/utils/sourceUtils.ts
50
50
  function parseRequiredInt(value) {
@@ -257,6 +257,7 @@
257
257
  margin: box("margin", "marginTop", "marginRight", "marginBottom", "marginLeft"),
258
258
  backgroundColor: prop("backgroundColor"),
259
259
  backgroundImage: prop("backgroundImage"),
260
+ backgroundClip: prop("backgroundClip"),
260
261
  borderWidth: box(
261
262
  "borderWidth",
262
263
  "borderTopWidth",
@@ -266,6 +267,7 @@
266
267
  ),
267
268
  borderStyle: prop("borderStyle", "borderTopStyle"),
268
269
  borderColor: prop("borderColor", "borderTopColor"),
270
+ borderImageSource: prop("borderImageSource"),
269
271
  borderRadius: box(
270
272
  "borderRadius",
271
273
  "borderTopLeftRadius",
@@ -274,6 +276,7 @@
274
276
  "borderBottomLeftRadius"
275
277
  ),
276
278
  color: prop("color"),
279
+ webkitTextFillColor: prop("webkitTextFillColor"),
277
280
  fontFamily: prop("fontFamily"),
278
281
  fontSize: prop("fontSize"),
279
282
  fontWeight: prop("fontWeight"),
@@ -554,57 +557,17 @@
554
557
  this.currentHighlightedElements = [];
555
558
  this.selectedElement = null;
556
559
  this.selectedElements = [];
557
- this.handleMouseOver = this.handleMouseOver.bind(this);
558
- this.handleMouseLeave = this.handleMouseLeave.bind(this);
559
- this.handleClick = this.handleClick.bind(this);
560
- this.handlePointerDown = this.handlePointerDown.bind(this);
561
- }
562
- /**
563
- * Swallow pointer/mouse-down so the previewed app cannot react to it (e.g.
564
- * Radix opens dropdowns on `pointerdown`, before our `click` handler runs).
565
- * In design mode the app is inspected, not driven; selection still happens on
566
- * `click`. Exception: events inside the element being inline-text-edited pass
567
- * through so the caret can be placed.
568
- *
569
- * Deliberately does NOT call `preventDefault()`. `stopPropagation` +
570
- * `stopImmediatePropagation` are what keep the app from reacting; `preventDefault`
571
- * additionally cancelled two *browser* default actions we do want:
572
- *
573
- * 1. The focus shift. In an embedded preview that is cross-document: a text
574
- * field focused in the HOST panel never blurs, so the panel — which commits
575
- * a typed draft on blur — silently discards the user's edit when they click
576
- * another element in the canvas (W-23560967). Keyboard Tab/Enter still worked,
577
- * because focus movement by keyboard is not a mousedown default action, which
578
- * is exactly what made the bug look arbitrary.
579
- * 2. Text-selection drag. That one we still want suppressed, so it is handled by
580
- * a `user-select: none` rule the controller installs while interactions are
581
- * active (exempting `[contenteditable="true"]` so inline text editing keeps
582
- * its caret and selection). CSS is the right tool: it suppresses the drag
583
- * without also cancelling focus.
584
- *
585
- * Note `preventDefault` on `pointerdown` ALONE also cancels the focus shift, so
586
- * dropping it only for `mousedown` would not have fixed this.
587
- */
588
- handlePointerDown(e) {
589
- if (!this.isInteractionsActive()) {
590
- return;
591
- }
592
- const target = e.target;
593
- if (target.isContentEditable) {
594
- return;
595
- }
596
- e.stopPropagation();
597
- e.stopImmediatePropagation?.();
598
560
  }
599
561
  _findHighlightableElement(target) {
600
562
  return this.componentMatcher.findHighlightableElement(target);
601
563
  }
602
- handleMouseOver(e) {
603
- if (!this.isInteractionsActive()) {
604
- return;
605
- }
606
- e.stopPropagation();
607
- const target = e.target;
564
+ /**
565
+ * Drive the hover highlight for the element under the cursor. The intercept
566
+ * overlay resolves that element by geometry (`elementsFromPoint`) and calls
567
+ * this directly — the pointer never reaches the app, so there is no
568
+ * `mouseover` event and `event.target` is always the intercept layer.
569
+ */
570
+ hoverAtTarget(target) {
608
571
  if (target.nodeType !== 1 || target.tagName === "HTML" || target.tagName === "BODY") {
609
572
  this.clearHoverHighlight();
610
573
  return;
@@ -637,13 +600,12 @@
637
600
  this.currentHighlightedElements = [];
638
601
  }
639
602
  }
640
- handleClick(e) {
641
- if (!this.isInteractionsActive()) {
642
- return;
643
- }
644
- e.preventDefault();
645
- e.stopPropagation();
646
- const target = e.target;
603
+ /**
604
+ * Resolve the element under the cursor to its highlightable element and select
605
+ * it. The intercept overlay resolves that element by geometry and calls this on
606
+ * click.
607
+ */
608
+ selectAtTarget(target) {
647
609
  if (target.nodeType !== 1 || target.tagName === "HTML" || target.tagName === "BODY") {
648
610
  return;
649
611
  }
@@ -658,10 +620,11 @@
658
620
  * hover highlight, select the element and all others sharing its source
659
621
  * location, make it editable if it's text, and notify the host.
660
622
  *
661
- * This is the shared selection routine for both a user click (`handleClick`)
662
- * and a programmatic `select-element` request (controller `selectByIdentity`).
663
- * Callers are responsible for resolving `element` to a highlightable node
664
- * (authorization gate); this method assumes that has already happened.
623
+ * This is the shared selection routine for both a user selection (the intercept
624
+ * overlay's click path, via `selectAtTarget`) and a programmatic `select-element`
625
+ * request (controller `selectByIdentity`). Callers are responsible for resolving
626
+ * `element` to a highlightable node (authorization gate); this method assumes
627
+ * that has already happened.
665
628
  */
666
629
  selectElement(element) {
667
630
  if (this.selectedElement && this.selectedElement === element) {
@@ -702,6 +665,428 @@
702
665
  }
703
666
  };
704
667
 
668
+ // src/runtime/interactions/interceptOverlay.ts
669
+ var INTERCEPT_ID = "design-mode-intercept";
670
+ var INTERCEPT_Z_INDEX = 2147483646;
671
+ var raf = typeof requestAnimationFrame === "function" ? (cb) => requestAnimationFrame(cb) : (cb) => setTimeout(cb, 16);
672
+ function caretRangeAtPoint(x, y) {
673
+ const doc = document;
674
+ if (typeof doc.caretRangeFromPoint === "function") {
675
+ return doc.caretRangeFromPoint(x, y);
676
+ }
677
+ if (typeof doc.caretPositionFromPoint === "function") {
678
+ const pos = doc.caretPositionFromPoint(x, y);
679
+ if (pos) {
680
+ const range = document.createRange();
681
+ range.setStart(pos.offsetNode, pos.offset);
682
+ range.collapse(true);
683
+ return range;
684
+ }
685
+ }
686
+ return null;
687
+ }
688
+ function isWordChar(ch) {
689
+ return !!ch && /[\p{L}\p{N}_]/u.test(ch);
690
+ }
691
+ var InterceptOverlay = class {
692
+ constructor(isInteractionsActive, eventHandlers) {
693
+ __publicField(this, "isInteractionsActive");
694
+ __publicField(this, "eventHandlers");
695
+ __publicField(this, "layer");
696
+ __publicField(this, "moveScheduled");
697
+ // Bumped whenever a queued hover frame must be invalidated (the pointer left, or
698
+ // the layer was torn down) so a coalesced move can't repaint hover chrome late.
699
+ __publicField(this, "hoverGeneration");
700
+ __publicField(this, "lastX");
701
+ __publicField(this, "lastY");
702
+ // The text element currently being inline-edited (focused under the layer) and
703
+ // its saved inline outline, restored when editing ends.
704
+ __publicField(this, "editing");
705
+ __publicField(this, "savedOutline");
706
+ // Text drag-selection state: the anchor caret captured on mousedown, whether the
707
+ // pointer is down mid-drag, and whether a move has extended it to a real
708
+ // (non-collapsed) range so the trailing click leaves it be. Live whenever a press
709
+ // lands on canvas text — editing only constrains the gesture, it doesn't gate it.
710
+ __publicField(this, "dragging");
711
+ __publicField(this, "dragAnchor");
712
+ __publicField(this, "dragSelected");
713
+ __publicField(this, "onMove");
714
+ __publicField(this, "onClick");
715
+ __publicField(this, "onSwallow");
716
+ __publicField(this, "onLeave");
717
+ __publicField(this, "onEditableBlur");
718
+ __publicField(this, "onMouseDown");
719
+ __publicField(this, "onMouseUp");
720
+ __publicField(this, "onDblClick");
721
+ this.isInteractionsActive = isInteractionsActive;
722
+ this.eventHandlers = eventHandlers;
723
+ this.layer = null;
724
+ this.moveScheduled = false;
725
+ this.hoverGeneration = 0;
726
+ this.lastX = 0;
727
+ this.lastY = 0;
728
+ this.editing = null;
729
+ this.savedOutline = "";
730
+ this.dragging = false;
731
+ this.dragAnchor = null;
732
+ this.dragSelected = false;
733
+ this.onMove = this._onMove.bind(this);
734
+ this.onClick = this._onClick.bind(this);
735
+ this.onSwallow = this._onSwallow.bind(this);
736
+ this.onLeave = this._onLeave.bind(this);
737
+ this.onEditableBlur = this._exitEditMode.bind(this);
738
+ this.onMouseDown = this._onMouseDown.bind(this);
739
+ this.onMouseUp = this._onMouseUp.bind(this);
740
+ this.onDblClick = this._onDblClick.bind(this);
741
+ }
742
+ /** Mount the intercept layer (idempotent). Tied to enable/disable. */
743
+ mount() {
744
+ if (this.layer || typeof document === "undefined") {
745
+ return;
746
+ }
747
+ const layer = document.createElement("div");
748
+ layer.id = INTERCEPT_ID;
749
+ Object.assign(layer.style, {
750
+ position: "fixed",
751
+ inset: "0",
752
+ margin: "0",
753
+ padding: "0",
754
+ border: "0",
755
+ background: "transparent",
756
+ zIndex: String(INTERCEPT_Z_INDEX),
757
+ pointerEvents: "auto",
758
+ cursor: "default"
759
+ });
760
+ layer.style.setProperty("user-select", "none", "important");
761
+ layer.style.setProperty("-webkit-user-select", "none", "important");
762
+ layer.addEventListener("mousemove", this.onMove);
763
+ layer.addEventListener("mouseleave", this.onLeave);
764
+ layer.addEventListener("click", this.onClick, true);
765
+ layer.addEventListener("dblclick", this.onDblClick, true);
766
+ layer.addEventListener("mousedown", this.onMouseDown, true);
767
+ layer.addEventListener("mouseup", this.onMouseUp, true);
768
+ layer.addEventListener("pointerdown", this.onSwallow, true);
769
+ document.documentElement.appendChild(layer);
770
+ this.layer = layer;
771
+ }
772
+ /** Remove the intercept layer (idempotent). */
773
+ unmount() {
774
+ if (!this.layer) {
775
+ return;
776
+ }
777
+ this._exitEditMode();
778
+ this.hoverGeneration++;
779
+ this.moveScheduled = false;
780
+ this.layer.removeEventListener("mousemove", this.onMove);
781
+ this.layer.removeEventListener("mouseleave", this.onLeave);
782
+ this.layer.removeEventListener("click", this.onClick, true);
783
+ this.layer.removeEventListener("dblclick", this.onDblClick, true);
784
+ this.layer.removeEventListener("mousedown", this.onMouseDown, true);
785
+ this.layer.removeEventListener("mouseup", this.onMouseUp, true);
786
+ this.layer.removeEventListener("pointerdown", this.onSwallow, true);
787
+ this.layer.remove();
788
+ this.layer = null;
789
+ }
790
+ /**
791
+ * The topmost previewed-app element at (x, y), skipping our own intercept
792
+ * layer. `elementsFromPoint` already omits `pointer-events:none` nodes, so the
793
+ * overlay chrome host is never in the stack — only the intercept layer needs
794
+ * filtering out.
795
+ */
796
+ resolveTarget(x, y) {
797
+ const stack = document.elementsFromPoint(x, y);
798
+ for (const el of stack) {
799
+ if (el === this.layer || el.id === INTERCEPT_ID) {
800
+ continue;
801
+ }
802
+ return el;
803
+ }
804
+ return null;
805
+ }
806
+ _onMove(e) {
807
+ if (!this.isInteractionsActive()) {
808
+ return;
809
+ }
810
+ this.lastX = e.clientX;
811
+ this.lastY = e.clientY;
812
+ if (this.dragging) {
813
+ if (e.buttons === 0) {
814
+ this._resetDrag();
815
+ } else {
816
+ this._extendDragTo(e.clientX, e.clientY);
817
+ return;
818
+ }
819
+ }
820
+ if (this.moveScheduled) {
821
+ return;
822
+ }
823
+ this.moveScheduled = true;
824
+ const generation = this.hoverGeneration;
825
+ raf(() => {
826
+ this.moveScheduled = false;
827
+ if (this.dragging) {
828
+ return;
829
+ }
830
+ if (!this.isInteractionsActive() || generation !== this.hoverGeneration) {
831
+ return;
832
+ }
833
+ const el = this.resolveTarget(this.lastX, this.lastY);
834
+ if (el) {
835
+ this.eventHandlers.hoverAtTarget(el);
836
+ } else {
837
+ this.eventHandlers.handleMouseLeave();
838
+ }
839
+ });
840
+ }
841
+ _onClick(e) {
842
+ if (!this.isInteractionsActive()) {
843
+ return;
844
+ }
845
+ e.preventDefault();
846
+ e.stopPropagation();
847
+ if (this.dragSelected) {
848
+ this.dragSelected = false;
849
+ return;
850
+ }
851
+ const el = this.resolveTarget(e.clientX, e.clientY);
852
+ if (!el) {
853
+ return;
854
+ }
855
+ const priorEditable = typeof el.closest === "function" ? el.closest('[contenteditable="true"]') : null;
856
+ this.eventHandlers.selectAtTarget(el);
857
+ if (priorEditable) {
858
+ this._enterEditMode(priorEditable, e.clientX, e.clientY);
859
+ } else {
860
+ this._exitEditMode();
861
+ }
862
+ }
863
+ /**
864
+ * Begin (or continue) inline editing of `editable`: neutralize its UA focus
865
+ * outline, focus it, and emulate the caret at the click point. No hole is
866
+ * opened — the layer stays over the app so hover/active never fire and a click
867
+ * can't activate an interactive tag; the element is edited purely via focus +
868
+ * keyboard. Re-called on each click so a later click repositions the caret.
869
+ */
870
+ _enterEditMode(editable, x, y) {
871
+ if (this.editing && this.editing !== editable) {
872
+ this._exitEditMode();
873
+ }
874
+ if (this.editing !== editable) {
875
+ this.editing = editable;
876
+ this.savedOutline = editable.style.outline;
877
+ editable.style.outline = "none";
878
+ editable.addEventListener("blur", this.onEditableBlur, { once: true });
879
+ }
880
+ this._placeCaret(editable, x, y);
881
+ }
882
+ /** End inline editing: restore the outline and drop the blur listener. */
883
+ _exitEditMode() {
884
+ if (!this.editing) {
885
+ return;
886
+ }
887
+ const editable = this.editing;
888
+ this.editing = null;
889
+ editable.style.outline = this.savedOutline;
890
+ this.savedOutline = "";
891
+ editable.removeEventListener("blur", this.onEditableBlur);
892
+ this._resetDrag();
893
+ }
894
+ /**
895
+ * Focus the editable and place a collapsed caret at the click point. Only moves the
896
+ * caret when the point resolves to a position inside the editable — a click in the
897
+ * element's own padding/whitespace (past the last glyph) keeps the current caret
898
+ * rather than dropping it into an adjacent node.
899
+ */
900
+ _placeCaret(editable, x, y) {
901
+ editable.focus();
902
+ this._applySelectionRange(this._caretRangeIn(editable, x, y));
903
+ }
904
+ /** Replace the current selection with `range` (no-op when null or outside a window). */
905
+ _applySelectionRange(range) {
906
+ const selection = typeof window !== "undefined" ? window.getSelection() : null;
907
+ if (selection && range) {
908
+ selection.removeAllRanges();
909
+ selection.addRange(range);
910
+ }
911
+ }
912
+ /**
913
+ * Resolve a caret Range at (x, y) with the intercept layer momentarily hidden:
914
+ * the layer covers the app, so a hit-test would otherwise resolve into the layer
915
+ * rather than the text beneath. Hiding is synchronous around the single call — no
916
+ * paint or event dispatch happens in between, so there is no hover flash and the
917
+ * app never receives a pointer event.
918
+ */
919
+ _caretRangeHidden(x, y) {
920
+ const prevDisplay = this.layer ? this.layer.style.display : "";
921
+ if (this.layer) {
922
+ this.layer.style.display = "none";
923
+ }
924
+ const range = caretRangeAtPoint(x, y);
925
+ if (this.layer) {
926
+ this.layer.style.display = prevDisplay;
927
+ }
928
+ return range;
929
+ }
930
+ /**
931
+ * A caret Range at (x, y) via the hidden hit-test, constrained to `el`: when `el` is
932
+ * given the point must fall inside it (used while editing / word-selecting to keep the
933
+ * gesture within the edited element); when null the caret may land anywhere in the
934
+ * document (free text selection for copying). Returns null when there's no caret, or
935
+ * one resolved outside `el`.
936
+ */
937
+ _caretRangeIn(el, x, y) {
938
+ const range = this._caretRangeHidden(x, y);
939
+ return range && (!el || el.contains(range.startContainer)) ? range : null;
940
+ }
941
+ /** The {@link _caretRangeIn} caret as a `{node, offset}` point (null when unresolved). */
942
+ _caretPointIn(el, x, y) {
943
+ const range = this._caretRangeIn(el, x, y);
944
+ return range ? { node: range.startContainer, offset: range.startOffset } : null;
945
+ }
946
+ /**
947
+ * mousedown: swallow like {@link _onSwallow} and start a potential text drag by
948
+ * recording the anchor caret under the press (confined to the edited element while
949
+ * editing, free otherwise). When the press lands anywhere within the element being
950
+ * edited, the press additionally preventDefaults. That preventDefault is essential
951
+ * while editing: the layer isn't focusable, so a press on it would otherwise shift
952
+ * focus off the editable — blurring it and tearing down edit mode (the blur runs
953
+ * _exitEditMode + the editableManager's commit) before the click could reposition
954
+ * the caret or a move could extend a selection. Suppressing the shift keeps the
955
+ * editable focused throughout. The decision is by geometry, not by where a caret
956
+ * resolves, so a press just past the last glyph (in the element's own padding)
957
+ * still repositions rather than exiting. Off an edit the press is left to shift
958
+ * focus as usual (see _onSwallow) so a focused host-panel field blurs and commits —
959
+ * the drag still selects because the selection is set on later moves, after that
960
+ * shift.
961
+ */
962
+ _onMouseDown(e) {
963
+ if (!this.isInteractionsActive()) {
964
+ return;
965
+ }
966
+ e.stopPropagation();
967
+ this._resetDrag();
968
+ if (this.editing && this._pressInsideEditing(e.clientX, e.clientY)) {
969
+ e.preventDefault();
970
+ }
971
+ const anchor = this._caretPointIn(this.editing, e.clientX, e.clientY);
972
+ if (anchor) {
973
+ this.dragging = true;
974
+ this.dragAnchor = anchor;
975
+ }
976
+ }
977
+ /** Whether (x, y) falls on the element being edited or a descendant of it. */
978
+ _pressInsideEditing(x, y) {
979
+ if (!this.editing) {
980
+ return false;
981
+ }
982
+ const target = this.resolveTarget(x, y);
983
+ return !!target && (target === this.editing || this.editing.contains(target));
984
+ }
985
+ /** mouseup: end the drag. `dragSelected` survives for the trailing click. */
986
+ _onMouseUp(e) {
987
+ if (!this.isInteractionsActive()) {
988
+ return;
989
+ }
990
+ e.stopPropagation();
991
+ this.dragging = false;
992
+ }
993
+ /** Clear all text drag-selection state. */
994
+ _resetDrag() {
995
+ this.dragging = false;
996
+ this.dragAnchor = null;
997
+ this.dragSelected = false;
998
+ }
999
+ /**
1000
+ * Extend the text selection from the drag anchor to the caret at (x, y). While
1001
+ * editing, a point outside the edited element is ignored so the selection stays
1002
+ * within it; off an edit the selection may span freely, like a native drag.
1003
+ */
1004
+ _extendDragTo(x, y) {
1005
+ if (!this.dragAnchor) {
1006
+ return;
1007
+ }
1008
+ const focus = this._caretPointIn(this.editing, x, y);
1009
+ if (!focus) {
1010
+ return;
1011
+ }
1012
+ const selection = typeof window !== "undefined" ? window.getSelection() : null;
1013
+ if (!selection) {
1014
+ return;
1015
+ }
1016
+ selection.setBaseAndExtent(
1017
+ this.dragAnchor.node,
1018
+ this.dragAnchor.offset,
1019
+ focus.node,
1020
+ focus.offset
1021
+ );
1022
+ if (!selection.isCollapsed) {
1023
+ this.dragSelected = true;
1024
+ }
1025
+ }
1026
+ /** Double-click selects the word under the cursor (editable or not, for copying). */
1027
+ _onDblClick(e) {
1028
+ if (!this.isInteractionsActive()) {
1029
+ return;
1030
+ }
1031
+ e.preventDefault();
1032
+ e.stopPropagation();
1033
+ this._applySelectionRange(this._wordRangeAt(this.editing, e.clientX, e.clientY));
1034
+ }
1035
+ /**
1036
+ * A Range spanning the word under (x, y): expand outward from the caret over word
1037
+ * characters (Unicode letters/digits/underscore). On a non-word character, select
1038
+ * that single character, matching a browser's minimal double-click selection. When
1039
+ * `el` is given the point must fall inside it (word-select while editing); when
1040
+ * null the word may be anywhere in the document. Returns null when there's no caret
1041
+ * (or it's outside `el`).
1042
+ */
1043
+ _wordRangeAt(el, x, y) {
1044
+ const caret = this._caretRangeIn(el, x, y);
1045
+ if (!caret) {
1046
+ return null;
1047
+ }
1048
+ const node = caret.startContainer;
1049
+ if (node.nodeType !== Node.TEXT_NODE) {
1050
+ return caret;
1051
+ }
1052
+ const text = node.textContent ?? "";
1053
+ const offset = caret.startOffset;
1054
+ let start = offset;
1055
+ let end = offset;
1056
+ while (start > 0 && isWordChar(text[start - 1])) {
1057
+ start--;
1058
+ }
1059
+ while (end < text.length && isWordChar(text[end])) {
1060
+ end++;
1061
+ }
1062
+ if (start === end) {
1063
+ if (offset < text.length) {
1064
+ end = offset + 1;
1065
+ } else if (offset > 0) {
1066
+ start = offset - 1;
1067
+ }
1068
+ }
1069
+ const range = document.createRange();
1070
+ range.setStart(node, start);
1071
+ range.setEnd(node, end);
1072
+ return range;
1073
+ }
1074
+ _onSwallow(e) {
1075
+ if (!this.isInteractionsActive()) {
1076
+ return;
1077
+ }
1078
+ e.stopPropagation();
1079
+ }
1080
+ _onLeave() {
1081
+ if (!this.isInteractionsActive()) {
1082
+ return;
1083
+ }
1084
+ this._resetDrag();
1085
+ this.hoverGeneration++;
1086
+ this.eventHandlers.handleMouseLeave();
1087
+ }
1088
+ };
1089
+
705
1090
  // src/runtime/interactions/overlayManager.ts
706
1091
  var TAB_HEIGHT_ESTIMATE = 18;
707
1092
  var OVERLAY_Z_INDEX = 2147483647;
@@ -712,7 +1097,7 @@
712
1097
  hover: 0,
713
1098
  selected: Math.round(BORDER_WIDTH.selected / 2)
714
1099
  };
715
- var raf = typeof requestAnimationFrame === "function" ? (cb) => requestAnimationFrame(cb) : (cb) => setTimeout(cb, 16);
1100
+ var raf2 = typeof requestAnimationFrame === "function" ? (cb) => requestAnimationFrame(cb) : (cb) => setTimeout(cb, 16);
716
1101
  var OverlayManager = class {
717
1102
  constructor() {
718
1103
  __publicField(this, "hostId");
@@ -945,7 +1330,7 @@
945
1330
  return;
946
1331
  }
947
1332
  this.repositionScheduled = true;
948
- raf(() => {
1333
+ raf2(() => {
949
1334
  this.repositionScheduled = false;
950
1335
  this._reposition();
951
1336
  });
@@ -966,9 +1351,6 @@
966
1351
 
967
1352
  // src/runtime/interactions/interactionsController.ts
968
1353
  var MAX_DRIFT_LINE_DELTA = 50;
969
- var SELECT_SUPPRESS_STYLE_ID = "sfdc-design-mode-select-suppress";
970
- var SELECT_SUPPRESS_CSS = `:root{-webkit-user-select:none;user-select:none;}
971
- [contenteditable="true"],[contenteditable="true"] *{-webkit-user-select:text;user-select:text;}`;
972
1354
  var mediaAppliers = {
973
1355
  // Whitelist by construction: this applier reads only the attribute keys
974
1356
  // valid for <img> and ignores anything else in `attrs`. The map is never
@@ -997,6 +1379,7 @@
997
1379
  __publicField(this, "communicationManager");
998
1380
  __publicField(this, "editableManager");
999
1381
  __publicField(this, "eventHandlers");
1382
+ __publicField(this, "interceptOverlay");
1000
1383
  this.enabled = enabled;
1001
1384
  this.isActive = false;
1002
1385
  this.componentMatcher = new ComponentMatcher({
@@ -1049,6 +1432,7 @@
1049
1432
  this.editableManager,
1050
1433
  this.communicationManager
1051
1434
  );
1435
+ this.interceptOverlay = new InterceptOverlay(() => this.isActive, this.eventHandlers);
1052
1436
  }
1053
1437
  /**
1054
1438
  * Initialize the design mode interactions
@@ -1058,11 +1442,6 @@
1058
1442
  return;
1059
1443
  }
1060
1444
  this.overlayManager.mountOverlay();
1061
- document.addEventListener("mouseover", this.eventHandlers.handleMouseOver);
1062
- document.addEventListener("mouseleave", this.eventHandlers.handleMouseLeave);
1063
- document.addEventListener("pointerdown", this.eventHandlers.handlePointerDown, true);
1064
- document.addEventListener("mousedown", this.eventHandlers.handlePointerDown, true);
1065
- document.addEventListener("click", this.eventHandlers.handleClick, true);
1066
1445
  this.communicationManager.notifyInitializationComplete();
1067
1446
  }
1068
1447
  /**
@@ -1073,7 +1452,7 @@
1073
1452
  enable(workspaceRoots = []) {
1074
1453
  this.componentMatcher.setWorkspaceRoots(workspaceRoots);
1075
1454
  this.isActive = true;
1076
- this._mountSelectSuppression();
1455
+ this.interceptOverlay.mount();
1077
1456
  }
1078
1457
  /**
1079
1458
  * Disable the design mode interactions
@@ -1081,25 +1460,7 @@
1081
1460
  disable() {
1082
1461
  this.isActive = false;
1083
1462
  this.eventHandlers.clearAll();
1084
- this._unmountSelectSuppression();
1085
- }
1086
- /**
1087
- * Install the text-selection suppression sheet (idempotent). Tied to
1088
- * enable/disable rather than initialize/destroy so the previewed app selects
1089
- * text normally whenever design mode is off.
1090
- */
1091
- _mountSelectSuppression() {
1092
- if (typeof document === "undefined") return;
1093
- if (document.getElementById(SELECT_SUPPRESS_STYLE_ID)) return;
1094
- const style = document.createElement("style");
1095
- style.id = SELECT_SUPPRESS_STYLE_ID;
1096
- style.textContent = SELECT_SUPPRESS_CSS;
1097
- document.head.appendChild(style);
1098
- }
1099
- /** Remove the suppression sheet so text is selectable again outside design mode. */
1100
- _unmountSelectSuppression() {
1101
- if (typeof document === "undefined") return;
1102
- document.getElementById(SELECT_SUPPRESS_STYLE_ID)?.remove();
1463
+ this.interceptOverlay.unmount();
1103
1464
  }
1104
1465
  /**
1105
1466
  * Programmatically select an element by source identity — the runtime side of
@@ -1217,11 +1578,7 @@
1217
1578
  * Cleanup and remove event listeners
1218
1579
  */
1219
1580
  destroy() {
1220
- document.removeEventListener("mouseover", this.eventHandlers.handleMouseOver);
1221
- document.removeEventListener("mouseleave", this.eventHandlers.handleMouseLeave);
1222
- document.removeEventListener("pointerdown", this.eventHandlers.handlePointerDown, true);
1223
- document.removeEventListener("mousedown", this.eventHandlers.handlePointerDown, true);
1224
- document.removeEventListener("click", this.eventHandlers.handleClick, true);
1581
+ this.interceptOverlay.unmount();
1225
1582
  this.overlayManager.unmountOverlay();
1226
1583
  this.eventHandlers.clearAll();
1227
1584
  }