diff --git a/src/LiveDevelopment/BrowserScripts/RemoteFunctions.js b/src/LiveDevelopment/BrowserScripts/RemoteFunctions.js index e83ee6e6b9..95040bc71d 100644 --- a/src/LiveDevelopment/BrowserScripts/RemoteFunctions.js +++ b/src/LiveDevelopment/BrowserScripts/RemoteFunctions.js @@ -113,20 +113,44 @@ function RemoteFunctions(config = {}) { return event.ctrlKey; } + /** + * This is a checker function for editable elements, it makes sure that the element satisfies all the required checks + * - When onlyHighlight is false → config.isProUser must be true + * - When onlyHighlight is true → config.isProUser can be true or false (doesn't matter) + * @param {DOMElement} element + * @param {boolean} [onlyHighlight=false] - If true, bypasses the isProUser check + * @returns {boolean} - True if the element is editable else false + */ + function isElementEditable(element, onlyHighlight = false) { + if(!config.isProUser && !onlyHighlight) { + return false; + } + + if(element && // element should exist + element.hasAttribute("data-brackets-id") && // should have the data-brackets-id attribute + element.tagName !== "BODY" && // shouldn't be the body tag + element.tagName !== "HTML" && // shouldn't be the HTML tag + !_isInsideHeadTag(element)) { // shouldn't be inside the head tag like meta tags and all + return true; + } + return false; + } + // helper function to check if an element is inside the HEAD tag - // we need this because we don't wanna trigger the element highlights on head tag and its children + // we need this because we don't wanna trigger the element highlights on head tag and its children, + // except for