Skip to content

Commit 49dc3a6

Browse files
committed
deploy: 606b7d0
1 parent d84be26 commit 49dc3a6

File tree

101 files changed

+18264
-1480
lines changed

Some content is hidden

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

101 files changed

+18264
-1480
lines changed

LiveDevelopment/BrowserScripts/LiveDevProtocolRemote.js

Lines changed: 61 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@
128128
}
129129
};
130130

131+
global._Brackets_MessageBroker = MessageBroker;
132+
131133
/**
132134
* Runtime Domain. Implements remote commands for "Runtime.*"
133135
*/
@@ -390,27 +392,69 @@
390392
function onDocumentClick(event) {
391393
// Get the user's current selection
392394
const selection = window.getSelection();
393-
394-
// Check if there is a selection
395-
if (selection.toString().length > 0) {
396-
// if there is any selection like text or others, we don't see it as a live selection event
397-
// Eg: user may selects ome text in live preview to copy, in which case we should nt treat it
398-
// as a live select.
399-
return;
400-
}
401395
var element = event.target;
402396
if (element && element.hasAttribute('data-brackets-id')) {
403-
MessageBroker.send({
404-
"tagId": element.getAttribute('data-brackets-id'),
405-
"nodeID": element.id,
406-
"nodeClassList": element.classList,
407-
"nodeName": element.nodeName,
408-
"allSelectors": _getAllInheritedSelectorsInOrder(element),
409-
"contentEditable": element.contentEditable === 'true',
410-
"clicked": true
411-
});
397+
// Check if it's a double-click for direct editing
398+
if (event.detail === 2 && !['INPUT', 'TEXTAREA', 'SELECT'].includes(element.tagName)) {
399+
// Double-click detected, enable direct editing
400+
// Make the element editable
401+
if (window._LD && window._LD.DOMEditHandler) {
402+
// Use the existing DOMEditHandler to handle the edit
403+
window._LD.startEditing(element);
404+
} else {
405+
MessageBroker.send({
406+
"tagId": element.getAttribute('data-brackets-id'),
407+
"nodeID": element.id,
408+
"nodeClassList": element.classList,
409+
"nodeName": element.nodeName,
410+
"allSelectors": _getAllInheritedSelectorsInOrder(element),
411+
"contentEditable": element.contentEditable === 'true',
412+
"clicked": true,
413+
"edit": true
414+
});
415+
}
416+
417+
// Prevent default behavior and stop propagation
418+
event.preventDefault();
419+
event.stopPropagation();
420+
} else {
421+
// Regular click, just send the information
422+
// Check if there is a selection
423+
if (selection.toString().length > 0) {
424+
// if there is any selection like text or others, we don't see it as a live selection event
425+
// Eg: user may selects ome text in live preview to copy, in which case we should nt treat it
426+
// as a live select.
427+
return;
428+
}
429+
MessageBroker.send({
430+
"tagId": element.getAttribute('data-brackets-id'),
431+
"nodeID": element.id,
432+
"nodeClassList": element.classList,
433+
"nodeName": element.nodeName,
434+
"allSelectors": _getAllInheritedSelectorsInOrder(element),
435+
"contentEditable": element.contentEditable === 'true',
436+
"clicked": true
437+
});
438+
}
412439
}
413440
}
414441
window.document.addEventListener("click", onDocumentClick);
442+
window.document.addEventListener("keydown", function (e) {
443+
// for undo. refer to LivePreviewEdit.js file 'handleLivePreviewEditOperation' function
444+
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "z") {
445+
MessageBroker.send({
446+
livePreviewEditEnabled: true,
447+
undoLivePreviewOperation: true
448+
});
449+
}
450+
451+
// for redo
452+
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "y") {
453+
MessageBroker.send({
454+
livePreviewEditEnabled: true,
455+
redoLivePreviewOperation: true
456+
});
457+
}
458+
});
415459

416460
}(this));

0 commit comments

Comments
 (0)