Skip to content

Commit 0a0e9a1

Browse files
committed
feat: hide/show image ribbon as soon as the setting is updated
1 parent e0683a8 commit 0a0e9a1

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3628,11 +3628,19 @@ function RemoteFunctions(config = {}) {
36283628
const highlightModeChanged = oldHighlightMode !== newHighlightMode;
36293629
const isProStatusChanged = oldConfig.isProUser !== config.isProUser;
36303630
const highlightSettingChanged = oldConfig.highlight !== config.highlight;
3631+
const imageRibbonJustEnabled = !oldConfig.imageRibbon && config.imageRibbon;
36313632

36323633
// Handle significant configuration changes
36333634
if (highlightModeChanged || isProStatusChanged || highlightSettingChanged) {
36343635
_handleConfigurationChange();
36353636
}
3637+
3638+
// if user enabled the image ribbon setting and an image is selected, then we show the image ribbon
3639+
if (imageRibbonJustEnabled && previouslyClickedElement &&
3640+
previouslyClickedElement.tagName.toLowerCase() === 'img') {
3641+
_imageRibbonGallery = new ImageRibbonGallery(previouslyClickedElement);
3642+
}
3643+
36363644
_updateEventListeners();
36373645

36383646
return JSON.stringify(config);

src/LiveDevelopment/LiveDevMultiBrowser.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,15 @@ define(function (require, exports, module) {
718718
}
719719
}
720720

721+
/**
722+
* Dismiss image ribbon gallery if it's open
723+
*/
724+
function dismissImageRibbonGallery() {
725+
if (_protocol) {
726+
_protocol.evaluate("_LD.dismissImageRibbonGallery()");
727+
}
728+
}
729+
721730
/**
722731
* Register event handlers in the remote browser for live preview functionality
723732
*/
@@ -804,6 +813,7 @@ define(function (require, exports, module) {
804813
exports.redrawHighlight = redrawHighlight;
805814
exports.hasVisibleLivePreviewBoxes = hasVisibleLivePreviewBoxes;
806815
exports.dismissLivePreviewBoxes = dismissLivePreviewBoxes;
816+
exports.dismissImageRibbonGallery = dismissImageRibbonGallery;
807817
exports.registerHandlers = registerHandlers;
808818
exports.updateConfig = updateConfig;
809819
exports.init = init;

src/LiveDevelopment/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,10 @@ define(function main(require, exports, module) {
371371
function updateImageRibbonConfig() {
372372
const prefValue = PreferencesManager.get("livePreviewImageRibbon");
373373
config.imageRibbon = prefValue !== false; // default to true if undefined
374+
374375
if (MultiBrowserLiveDev && MultiBrowserLiveDev.status >= MultiBrowserLiveDev.STATUS_ACTIVE) {
376+
if (!prefValue) { MultiBrowserLiveDev.dismissImageRibbonGallery(); } // to remove any existing image ribbons
377+
375378
MultiBrowserLiveDev.updateConfig(JSON.stringify(config));
376379
MultiBrowserLiveDev.registerHandlers();
377380
}

0 commit comments

Comments
 (0)