diff --git a/src/LiveDevelopment/BrowserScripts/LiveDevProtocolRemote.js b/src/LiveDevelopment/BrowserScripts/LiveDevProtocolRemote.js index 760baec58..0024fd0e2 100644 --- a/src/LiveDevelopment/BrowserScripts/LiveDevProtocolRemote.js +++ b/src/LiveDevelopment/BrowserScripts/LiveDevProtocolRemote.js @@ -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)); diff --git a/src/LiveDevelopment/BrowserScripts/RemoteFunctions.js b/src/LiveDevelopment/BrowserScripts/RemoteFunctions.js index 874bc7929..8b22fed7d 100644 --- a/src/LiveDevelopment/BrowserScripts/RemoteFunctions.js +++ b/src/LiveDevelopment/BrowserScripts/RemoteFunctions.js @@ -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.*" @@ -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, @@ -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 }); }); diff --git a/tracking-repos.json b/tracking-repos.json index 7c1589391..6dbe90bb9 100644 --- a/tracking-repos.json +++ b/tracking-repos.json @@ -1,5 +1,5 @@ { "phoenixPro": { - "commitID": "3826a7180c9463ecf02f4051e78696d503c7c6f1" + "commitID": "ec8ca8e2f0631c7440e3a4372688523406c080d2" } }