Skip to content

Commit 3437e14

Browse files
committed
deploy: cd657c3
1 parent 65ac39c commit 3437e14

File tree

61 files changed

+244
-92
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+244
-92
lines changed

LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ function RemoteFunctions(config = {}) {
2929

3030
let _hoverHighlight;
3131
let _clickHighlight;
32+
let _cssSelectorHighlight; // temporary highlight for CSS selector matches in edit mode
3233
let _hoverLockTimer = null;
34+
let _cssSelectorHighlightTimer = null; // timer for clearing temporary CSS selector highlights
3335

3436
// this will store the element that was clicked previously (before the new click)
3537
// we need this so that we can remove click styling from the previous element when a new element is clicked
@@ -775,6 +777,36 @@ function RemoteFunctions(config = {}) {
775777
selectElement(element);
776778
}
777779

780+
// clear temporary CSS selector highlights
781+
function clearCssSelectorHighlight() {
782+
if (_cssSelectorHighlightTimer) {
783+
clearTimeout(_cssSelectorHighlightTimer);
784+
_cssSelectorHighlightTimer = null;
785+
}
786+
if (_cssSelectorHighlight) {
787+
_cssSelectorHighlight.clear();
788+
_cssSelectorHighlight = null;
789+
}
790+
}
791+
792+
// create temporary CSS selector highlights for edit mode
793+
function createCssSelectorHighlight(nodes, rule) {
794+
// Clear any existing temporary highlights
795+
clearCssSelectorHighlight();
796+
797+
// Create new temporary highlight for all matching elements
798+
_cssSelectorHighlight = new Highlight("#cfc");
799+
for (var i = 0; i < nodes.length; i++) {
800+
if (LivePreviewView.isElementInspectable(nodes[i], true) && nodes[i].nodeType === Node.ELEMENT_NODE) {
801+
_cssSelectorHighlight.add(nodes[i], true);
802+
}
803+
}
804+
_cssSelectorHighlight.selector = rule;
805+
806+
// Clear temporary highlights after 2 seconds
807+
_cssSelectorHighlightTimer = setTimeout(clearCssSelectorHighlight, 2000);
808+
}
809+
778810
// remove active highlights
779811
function hideHighlight() {
780812
if (_clickHighlight) {
@@ -785,6 +817,7 @@ function RemoteFunctions(config = {}) {
785817
_hoverHighlight.clear();
786818
_hoverHighlight = null;
787819
}
820+
clearCssSelectorHighlight();
788821
}
789822

790823
// highlight an element
@@ -832,6 +865,11 @@ function RemoteFunctions(config = {}) {
832865
if (!foundValidElement) {
833866
dismissUIAndCleanupState();
834867
}
868+
869+
// In edit mode, create temporary highlights AFTER selection to avoid clearing
870+
if (config.mode === 'edit') {
871+
createCssSelectorHighlight(nodes, rule);
872+
}
835873
}
836874

837875
// recreate UI boxes so that they are placed properly

LiveDevelopment/MultiBrowserImpl/documents/LiveDocument.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)