Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 0 additions & 104 deletions src/LiveDevelopment/BrowserScripts/LiveDevProtocolRemote.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,109 +538,5 @@
}
}
window.document.addEventListener("click", onDocumentClick);
window.document.addEventListener("keydown", function (e) {
// Check if user is editing text content - if so, allow normal text cut
// Get the truly active element, even if inside shadow roots
let activeElement = document.activeElement;

const isEditingText = activeElement && (
// Check for standard form input elements
['INPUT', 'TEXTAREA'].includes(activeElement.tagName) ||
// Check for contentEditable elements
activeElement.isContentEditable ||
// Check for ARIA roles that indicate text input
['textbox', 'searchbox', 'combobox'].includes(activeElement.getAttribute('role')) ||
// Check if element is designed to receive text input
(activeElement.hasAttribute("contenteditable") && activeElement.hasAttribute("data-brackets-id"))
);

// Check if a Phoenix tool is active (has data-phcode-internal-* attribute)
const isActiveElementPhoenixTool = activeElement && Array.from(activeElement.attributes || []).some(attr =>
attr.name.startsWith('data-phcode-internal-') && attr.value === 'true'
);

const isInEditMode = window._LD && window._LD.getMode && window._LD.getMode() === 'edit';

// for undo. refer to LivePreviewEdit.js file 'handleLivePreviewEditOperation' function
if (!isEditingText && !isActiveElementPhoenixTool && isInEditMode &&
(e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "z" && !e.shiftKey) {
MessageBroker.send({
livePreviewEditEnabled: true,
undoLivePreviewOperation: true
});
}

// for redo - supports both Ctrl+Y and Ctrl+Shift+Z (Cmd+Y and Cmd+Shift+Z on Mac)
if (!isEditingText && !isActiveElementPhoenixTool && isInEditMode && (e.ctrlKey || e.metaKey) &&
(e.key.toLowerCase() === "y" || (e.key.toLowerCase() === "z" && e.shiftKey))) {
MessageBroker.send({
livePreviewEditEnabled: true,
redoLivePreviewOperation: true
});
}

// Cut: Ctrl+X / Cmd+X - operates on selected element
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "x") {

// Only handle element cut if not editing text and in edit mode
if (!isEditingText && !isActiveElementPhoenixTool && isInEditMode && window._LD.handleCutElement) {
e.preventDefault();
window._LD.handleCutElement();
}
}

// Copy: Ctrl+C / Cmd+C - operates on selected element
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "c") {

// Only handle element copy if not editing text and in edit mode
if (!isEditingText && !isActiveElementPhoenixTool && isInEditMode && window._LD.handleCopyElement) {
e.preventDefault();
window._LD.handleCopyElement();
}
}

// Paste: Ctrl+V / Cmd+V - operates on selected element
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "v") {

// Only handle element paste if not editing text and in edit mode
if (!isEditingText && !isActiveElementPhoenixTool && isInEditMode && window._LD.handlePasteElement) {
e.preventDefault();
window._LD.handlePasteElement();
}
}

if (e.key.toLowerCase() === 'delete' || e.key.toLowerCase() === 'backspace') {
if (!isEditingText && !isActiveElementPhoenixTool && isInEditMode && window._LD.handleDeleteElement) {
e.preventDefault();
window._LD.handleDeleteElement();
}
}

// for save
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "s") {
e.preventDefault();

// to check if user was in between editing text
// in such cases we first finish the editing and then save
if (isEditingText && window._LD && window._LD.finishEditing) {

window._LD.finishEditing(activeElement);
}

MessageBroker.send({
livePreviewEditEnabled: true,
saveCurrentDocument: true
});
}

// for preview button (play icon) toggle
if (e.key === 'F8') {
e.preventDefault();
MessageBroker.send({
livePreviewEditEnabled: true,
toggleLivePreviewMode: true
});
}
});

}(this));
5 changes: 3 additions & 2 deletions src/LiveDevelopment/BrowserScripts/RemoteFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function RemoteFunctions(config = {}) {
// this is just a test function here to check if live preview. fn call is working correctly.
console.log("Hello World", param);
});
const MessageBroker = window._Brackets_MessageBroker; // to be used by plugins.

const SHARED_STATE = {
__description: "Use this to keep shared state for Live Preview Edit instead of window.*"
Expand Down Expand Up @@ -753,7 +754,7 @@ function RemoteFunctions(config = {}) {

// send cursor movement message to editor so cursor jumps to clicked element
if (element.hasAttribute(GLOBALS.DATA_BRACKETS_ID_ATTR)) {
window._Brackets_MessageBroker.send({
MessageBroker.send({
"tagId": element.getAttribute(GLOBALS.DATA_BRACKETS_ID_ATTR),
"nodeID": element.id,
"nodeClassList": element.classList,
Expand Down Expand Up @@ -1285,7 +1286,7 @@ function RemoteFunctions(config = {}) {
// we need to refresh the config once the load is completed
// this is important because messageBroker gets ready for use only when load fires
window.addEventListener('load', function() {
window._Brackets_MessageBroker.send({
MessageBroker.send({
requestConfigRefresh: true
});
});
Expand Down
2 changes: 1 addition & 1 deletion tracking-repos.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"phoenixPro": {
"commitID": "3826a7180c9463ecf02f4051e78696d503c7c6f1"
"commitID": "ec8ca8e2f0631c7440e3a4372688523406c080d2"
}
}
Loading