Skip to content

Commit fce84fa

Browse files
devvaannshabose
authored andcommitted
fix: make the live preview expand button toggle design mode again
1 parent 866f6b3 commit fce84fa

4 files changed

Lines changed: 24 additions & 22 deletions

File tree

‎src/extensionsIntegrated/Phoenix-live-preview/live-preview.css‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,13 +370,13 @@
370370
}
371371

372372
#reloadLivePreviewButton,
373-
#fullScreenLivePreviewButton {
373+
#designModeToggleLivePreviewButton {
374374
border: 1px solid transparent;
375375
border-radius: 3px;
376376
}
377377

378378
#live-preview-plugin-toolbar #reloadLivePreviewButton:hover,
379-
#live-preview-plugin-toolbar #fullScreenLivePreviewButton:hover {
379+
#live-preview-plugin-toolbar #designModeToggleLivePreviewButton:hover {
380380
border-color: rgba(255, 255, 255, 0.1) !important;
381381
background: transparent !important;
382382
box-shadow: none !important;

‎src/extensionsIntegrated/Phoenix-live-preview/main.js‎

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ define(function (require, exports, module) {
194194
$modeBtn,
195195
$modeBtnGroup,
196196
$previewBtn,
197-
$fullScreenBtn;
197+
$designModeBtn;
198198

199199
let customLivePreviewBannerShown = false;
200200

@@ -866,7 +866,7 @@ define(function (require, exports, module) {
866866
livePreview: Strings.LIVE_DEV_STATUS_TIP_OUT_OF_SYNC,
867867
clickToReload: Strings.LIVE_DEV_CLICK_TO_RELOAD_PAGE,
868868
clickToToggleEdit: Strings.LIVE_PREVIEW_MODE_TOGGLE_EDIT,
869-
fullScreenLivePreview: Strings.LIVE_PREVIEW_FULL_SCREEN,
869+
switchToDesignMode: Strings.CCB_SWITCH_TO_DESIGN_MODE,
870870
livePreviewSettings: Strings.LIVE_DEV_SETTINGS,
871871
livePreviewConfigureModes: Strings.LIVE_PREVIEW_CONFIGURE_MODES,
872872
clickToPopout: Strings.LIVE_DEV_CLICK_POPOUT,
@@ -899,7 +899,7 @@ define(function (require, exports, module) {
899899
$modeBtn = $panel.find("#livePreviewModeBtn");
900900
$modeBtnGroup = $panel.find("#lpModeBtnGroup");
901901
$previewBtn = $panel.find("#previewModeLivePreviewButton");
902-
$fullScreenBtn = $panel.find("#fullScreenLivePreviewButton");
902+
$designModeBtn = $panel.find("#designModeToggleLivePreviewButton");
903903

904904
// Markdown theme toggle — persist user choice
905905
MarkdownSync.setThemeToggleHandler((theme) => {
@@ -982,25 +982,26 @@ define(function (require, exports, module) {
982982
Metrics.countEvent(Metrics.EVENT_TYPE.LIVE_PREVIEW, "reloadBtn", "click");
983983
});
984984

985-
function _updateFullScreenButton() {
986-
const on = WorkspaceManager.isInLPFullScreen && WorkspaceManager.isInLPFullScreen();
987-
$fullScreenBtn.find("i")
985+
// Mirrors the control bar's design mode toggle so the user can switch without leaving the preview.
986+
function _updateDesignModeButton() {
987+
const on = WorkspaceManager.isInDesignMode && WorkspaceManager.isInDesignMode();
988+
$designModeBtn.find("i")
988989
.removeClass("fa-expand fa-compress")
989990
.addClass(on ? "fa-compress" : "fa-expand");
990-
$fullScreenBtn.attr("title",
991-
on ? Strings.LIVE_PREVIEW_EXIT_FULL_SCREEN : Strings.LIVE_PREVIEW_FULL_SCREEN);
991+
$designModeBtn.attr("title",
992+
on ? Strings.CCB_SWITCH_TO_CODE_EDITOR : Strings.CCB_SWITCH_TO_DESIGN_MODE);
993+
if ($modeBtn) {
994+
$modeBtn.toggle(!on && !_isMdviewrActive);
995+
}
992996
}
993-
$fullScreenBtn.click(()=>{
994-
CommandManager.execute(Commands.VIEW_TOGGLE_LP_FULL_SCREEN);
995-
Metrics.countEvent(Metrics.EVENT_TYPE.LIVE_PREVIEW, "fullScreenBtn", "click");
997+
$designModeBtn.click(()=>{
998+
CommandManager.execute(Commands.VIEW_TOGGLE_DESIGN_MODE);
999+
Metrics.countEvent(Metrics.EVENT_TYPE.LIVE_PREVIEW, "designModeBtn", "click");
9961000
});
9971001
WorkspaceManager.off(WorkspaceManager.EVENT_WORKSPACE_DESIGN_MODE_CHANGE + ".livePreview");
9981002
WorkspaceManager.on(WorkspaceManager.EVENT_WORKSPACE_DESIGN_MODE_CHANGE + ".livePreview",
999-
_updateLPControlsForMdviewer);
1000-
WorkspaceManager.off(WorkspaceManager.EVENT_WORKSPACE_LP_FULL_SCREEN_CHANGE + ".livePreview");
1001-
WorkspaceManager.on(WorkspaceManager.EVENT_WORKSPACE_LP_FULL_SCREEN_CHANGE + ".livePreview",
1002-
_updateFullScreenButton);
1003-
_updateFullScreenButton();
1003+
_updateDesignModeButton);
1004+
_updateDesignModeButton();
10041005

10051006
// init the status overlay
10061007
_initOverlay();

‎src/extensionsIntegrated/Phoenix-live-preview/panel.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<button id="reloadLivePreviewButton" title="{{clickToReload}}" class="btn-alt-quiet toolbar-button">
55
<i class="fa-solid fa-arrow-rotate-right"></i>
66
</button>
7-
<button id="fullScreenLivePreviewButton" title="{{fullScreenLivePreview}}" class="btn-alt-quiet toolbar-button">
7+
<button id="designModeToggleLivePreviewButton" title="{{switchToDesignMode}}" class="btn-alt-quiet toolbar-button">
88
<i class="fa-solid fa-expand"></i>
99
</button>
1010
<span id="lpModeBtnGroup" class="lp-mode-btn-group">

‎test/spec/CentralControlBar-integ-test.js‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,15 +1492,16 @@ define(function (require, exports, module) {
14921492
expect(SidebarView.isVisible()).toBe(true);
14931493
});
14941494

1495-
it("should dispatch VIEW_TOGGLE_LP_FULL_SCREEN from the live preview expand button",
1495+
it("should dispatch VIEW_TOGGLE_DESIGN_MODE from the live preview expand button",
14961496
async function () {
14971497
await openLivePreview();
14981498

14991499
const executed = recordCommands(function () {
1500-
_$("#fullScreenLivePreviewButton").trigger("click");
1500+
_$("#designModeToggleLivePreviewButton").trigger("click");
15011501
});
15021502

1503-
expect(executed).toContain(Commands.VIEW_TOGGLE_LP_FULL_SCREEN);
1503+
expect(executed).toContain(Commands.VIEW_TOGGLE_DESIGN_MODE);
1504+
expect(executed).not.toContain(Commands.VIEW_TOGGLE_LP_FULL_SCREEN);
15041505
});
15051506
});
15061507
});

0 commit comments

Comments
 (0)