diff --git a/src/LiveDevelopment/BrowserScripts/RemoteFunctions.js b/src/LiveDevelopment/BrowserScripts/RemoteFunctions.js index f4bb2aa50..6d2aa2e40 100644 --- a/src/LiveDevelopment/BrowserScripts/RemoteFunctions.js +++ b/src/LiveDevelopment/BrowserScripts/RemoteFunctions.js @@ -60,8 +60,8 @@ function RemoteFunctions(config = {}) { const AUTO_SCROLL_SPEED = 12; // pixels per scroll const AUTO_SCROLL_EDGE_SIZE = 0.05; // 5% of viewport height (either top/bottom) - // to track the state as we want to have a selected state for image gallery - let imageGallerySelected = false; + // initialized from config, defaults to true if not set + let imageGallerySelected = config.imageGalleryState !== undefined ? config.imageGalleryState : true; /** * this function is responsible to auto scroll the live preview when @@ -117,20 +117,16 @@ function RemoteFunctions(config = {}) { } /** - * 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 + * check if an element is inspectable. + * inspectable elements are those which doesn't have data-brackets-id, + * this normally happens when content is DOM content is inserted by some scripting language */ - function isElementEditable(element, onlyHighlight = false) { + function isElementInspectable(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.toLowerCase() !== "body" && // shouldn't be the body tag element.tagName.toLowerCase() !== "html" && // shouldn't be the HTML tag !_isInsideHeadTag(element)) { // shouldn't be inside the head tag like meta tags and all @@ -139,6 +135,20 @@ function RemoteFunctions(config = {}) { return false; } + /** + * This is a checker function for editable elements, it makes sure that the element satisfies all the required check + * - 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) { + // for an element to be editable it should satisfy all inspectable checks and should also have data-brackets-id + return isElementInspectable(element, onlyHighlight) && + element.hasAttribute("data-brackets-id"); + } + // 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, // except for -