Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -370,13 +370,13 @@
}

#reloadLivePreviewButton,
#fullScreenLivePreviewButton {
#designModeToggleLivePreviewButton {
border: 1px solid transparent;
border-radius: 3px;
}

#live-preview-plugin-toolbar #reloadLivePreviewButton:hover,
#live-preview-plugin-toolbar #fullScreenLivePreviewButton:hover {
#live-preview-plugin-toolbar #designModeToggleLivePreviewButton:hover {
border-color: rgba(255, 255, 255, 0.1) !important;
background: transparent !important;
box-shadow: none !important;
Expand Down
33 changes: 17 additions & 16 deletions src/extensionsIntegrated/Phoenix-live-preview/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
$modeBtn,
$modeBtnGroup,
$previewBtn,
$fullScreenBtn;
$designModeBtn;

let customLivePreviewBannerShown = false;

Expand Down Expand Up @@ -866,7 +866,7 @@
livePreview: Strings.LIVE_DEV_STATUS_TIP_OUT_OF_SYNC,
clickToReload: Strings.LIVE_DEV_CLICK_TO_RELOAD_PAGE,
clickToToggleEdit: Strings.LIVE_PREVIEW_MODE_TOGGLE_EDIT,
fullScreenLivePreview: Strings.LIVE_PREVIEW_FULL_SCREEN,
switchToDesignMode: Strings.CCB_SWITCH_TO_DESIGN_MODE,
livePreviewSettings: Strings.LIVE_DEV_SETTINGS,
livePreviewConfigureModes: Strings.LIVE_PREVIEW_CONFIGURE_MODES,
clickToPopout: Strings.LIVE_DEV_CLICK_POPOUT,
Expand Down Expand Up @@ -899,7 +899,7 @@
$modeBtn = $panel.find("#livePreviewModeBtn");
$modeBtnGroup = $panel.find("#lpModeBtnGroup");
$previewBtn = $panel.find("#previewModeLivePreviewButton");
$fullScreenBtn = $panel.find("#fullScreenLivePreviewButton");
$designModeBtn = $panel.find("#designModeToggleLivePreviewButton");

// Markdown theme toggle — persist user choice
MarkdownSync.setThemeToggleHandler((theme) => {
Expand Down Expand Up @@ -982,25 +982,26 @@
Metrics.countEvent(Metrics.EVENT_TYPE.LIVE_PREVIEW, "reloadBtn", "click");
});

function _updateFullScreenButton() {
const on = WorkspaceManager.isInLPFullScreen && WorkspaceManager.isInLPFullScreen();
$fullScreenBtn.find("i")
// Mirrors the control bar's design mode toggle so the user can switch without leaving the preview.
function _updateDesignModeButton() {
const on = WorkspaceManager.isInDesignMode && WorkspaceManager.isInDesignMode();

Check warning on line 987 in src/extensionsIntegrated/Phoenix-live-preview/main.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer using an optional chain expression instead, as it's more concise and easier to read.

See more on https://sonarcloud.io/project/issues?id=phcode-dev_phoenix&issues=AaCu-kp1TjYI7k7EDWsg&open=AaCu-kp1TjYI7k7EDWsg&pullRequest=3207
$designModeBtn.find("i")
.removeClass("fa-expand fa-compress")
.addClass(on ? "fa-compress" : "fa-expand");
$fullScreenBtn.attr("title",
on ? Strings.LIVE_PREVIEW_EXIT_FULL_SCREEN : Strings.LIVE_PREVIEW_FULL_SCREEN);
$designModeBtn.attr("title",
on ? Strings.CCB_SWITCH_TO_CODE_EDITOR : Strings.CCB_SWITCH_TO_DESIGN_MODE);
if ($modeBtn) {
$modeBtn.toggle(!on && !_isMdviewrActive);
}
}
$fullScreenBtn.click(()=>{
CommandManager.execute(Commands.VIEW_TOGGLE_LP_FULL_SCREEN);
Metrics.countEvent(Metrics.EVENT_TYPE.LIVE_PREVIEW, "fullScreenBtn", "click");
$designModeBtn.click(()=>{
CommandManager.execute(Commands.VIEW_TOGGLE_DESIGN_MODE);
Metrics.countEvent(Metrics.EVENT_TYPE.LIVE_PREVIEW, "designModeBtn", "click");
});
WorkspaceManager.off(WorkspaceManager.EVENT_WORKSPACE_DESIGN_MODE_CHANGE + ".livePreview");
WorkspaceManager.on(WorkspaceManager.EVENT_WORKSPACE_DESIGN_MODE_CHANGE + ".livePreview",
_updateLPControlsForMdviewer);
WorkspaceManager.off(WorkspaceManager.EVENT_WORKSPACE_LP_FULL_SCREEN_CHANGE + ".livePreview");
WorkspaceManager.on(WorkspaceManager.EVENT_WORKSPACE_LP_FULL_SCREEN_CHANGE + ".livePreview",
_updateFullScreenButton);
_updateFullScreenButton();
_updateDesignModeButton);
_updateDesignModeButton();

// init the status overlay
_initOverlay();
Expand Down
2 changes: 1 addition & 1 deletion src/extensionsIntegrated/Phoenix-live-preview/panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<button id="reloadLivePreviewButton" title="{{clickToReload}}" class="btn-alt-quiet toolbar-button">
<i class="fa-solid fa-arrow-rotate-right"></i>
</button>
<button id="fullScreenLivePreviewButton" title="{{fullScreenLivePreview}}" class="btn-alt-quiet toolbar-button">
<button id="designModeToggleLivePreviewButton" title="{{switchToDesignMode}}" class="btn-alt-quiet toolbar-button">
<i class="fa-solid fa-expand"></i>
</button>
<span id="lpModeBtnGroup" class="lp-mode-btn-group">
Expand Down
7 changes: 4 additions & 3 deletions test/spec/CentralControlBar-integ-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1492,15 +1492,16 @@ define(function (require, exports, module) {
expect(SidebarView.isVisible()).toBe(true);
});

it("should dispatch VIEW_TOGGLE_LP_FULL_SCREEN from the live preview expand button",
it("should dispatch VIEW_TOGGLE_DESIGN_MODE from the live preview expand button",
async function () {
await openLivePreview();

const executed = recordCommands(function () {
_$("#fullScreenLivePreviewButton").trigger("click");
_$("#designModeToggleLivePreviewButton").trigger("click");
});

expect(executed).toContain(Commands.VIEW_TOGGLE_LP_FULL_SCREEN);
expect(executed).toContain(Commands.VIEW_TOGGLE_DESIGN_MODE);
expect(executed).not.toContain(Commands.VIEW_TOGGLE_LP_FULL_SCREEN);
});
});
});
Expand Down
Loading