Skip to content

Commit 6915a91

Browse files
committed
feat: show a toast message when folder selection dialog is open
1 parent 610aff9 commit 6915a91

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3679,20 +3679,86 @@ function RemoteFunctions(config = {}) {
36793679
var _hoverLockTimer = null;
36803680

36813681
const DOWNLOAD_EVENTS = {
3682+
DIALOG_OPENED: 'dialogOpened',
3683+
DIALOG_CLOSED: 'dialogClosed',
36823684
STARTED: 'downloadStarted',
36833685
COMPLETED: 'downloadCompleted',
36843686
CANCELLED: 'downloadCancelled',
36853687
ERROR: 'downloadError'
36863688
};
36873689

36883690
let _activeDownloads = new Map();
3691+
let _dialogOverlay = null;
3692+
3693+
function _showDialogOverlay() {
3694+
// don't create multiple overlays
3695+
if (_dialogOverlay) {
3696+
return;
3697+
}
3698+
3699+
// create overlay container
3700+
const overlay = window.document.createElement('div');
3701+
overlay.className = 'phoenix-dialog-overlay';
3702+
overlay.setAttribute('data-phcode-internal-c15r5a9', 'true');
3703+
overlay.style.cssText = 'position: fixed; top: 0; left: 0; width: 100%; height: 100%; ' +
3704+
'background: rgba(0, 0, 0, 0.5); z-index: 10000; pointer-events: auto;';
3705+
3706+
// create toast card (matching existing overlay style: #666 background, #ededed text)
3707+
const toast = window.document.createElement('div');
3708+
toast.className = 'phoenix-dialog-toast';
3709+
toast.setAttribute('data-phcode-internal-c15r5a9', 'true');
3710+
toast.style.cssText = 'position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); ' +
3711+
'background: #666; color: #ededed; padding: 24px 32px; border-radius: 6px; ' +
3712+
'box-shadow: 0 4px 12px rgba(0,0,0,0.15); font-size: 16px; text-align: center;';
3713+
3714+
// create icon
3715+
const icon = window.document.createElement('span');
3716+
icon.className = 'phoenix-dialog-icon';
3717+
icon.setAttribute('data-phcode-internal-c15r5a9', 'true');
3718+
icon.style.cssText = 'margin-right: 10px; font-size: 18px;';
3719+
icon.textContent = 'ⓘ';
3720+
3721+
// create message
3722+
const message = window.document.createElement('span');
3723+
message.className = 'phoenix-dialog-message';
3724+
message.setAttribute('data-phcode-internal-c15r5a9', 'true');
3725+
message.textContent = 'Select image download location in the editor to continue';
3726+
3727+
// assemble the structure
3728+
toast.appendChild(icon);
3729+
toast.appendChild(message);
3730+
overlay.appendChild(toast);
3731+
3732+
// append to body
3733+
window.document.body.appendChild(overlay);
3734+
_dialogOverlay = overlay;
3735+
}
3736+
3737+
function _hideDialogOverlay() {
3738+
if (_dialogOverlay && _dialogOverlay.parentNode) {
3739+
_dialogOverlay.parentNode.removeChild(_dialogOverlay);
3740+
_dialogOverlay = null;
3741+
}
3742+
}
36893743

36903744
function handleDownloadEvent(eventType, data) {
36913745
const downloadId = data && data.downloadId;
36923746
if (!downloadId) {
36933747
return;
36943748
}
36953749

3750+
// handle dialog events (these don't require download to exist)
3751+
if (eventType === DOWNLOAD_EVENTS.DIALOG_OPENED) {
3752+
_showDialogOverlay();
3753+
return;
3754+
}
3755+
3756+
if (eventType === DOWNLOAD_EVENTS.DIALOG_CLOSED) {
3757+
_hideDialogOverlay();
3758+
return;
3759+
}
3760+
3761+
// handle download events (these require download to exist)
36963762
const download = _activeDownloads.get(downloadId);
36973763
if (!download) {
36983764
return;

src/LiveDevelopment/LivePreviewEdit.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ define(function (require, exports, module) {
4747
const IMAGE_DOWNLOAD_PERSIST_FOLDER_KEY = "imageGallery.persistFolder";
4848

4949
const DOWNLOAD_EVENTS = {
50+
DIALOG_OPENED: 'dialogOpened',
51+
DIALOG_CLOSED: 'dialogClosed',
5052
STARTED: 'downloadStarted',
5153
COMPLETED: 'downloadCompleted',
5254
CANCELLED: 'downloadCancelled',
@@ -1156,6 +1158,11 @@ define(function (require, exports, module) {
11561158
const $suggestions = $dlg.find("#folder-suggestions");
11571159
const $rememberCheckbox = $dlg.find("#remember-folder-checkbox");
11581160

1161+
// notify live preview that dialog is now open
1162+
if (message && message.downloadId) {
1163+
_sendDownloadStatusToBrowser(DOWNLOAD_EVENTS.DIALOG_OPENED, { downloadId: message.downloadId });
1164+
}
1165+
11591166
let folderList = [];
11601167
let rootFolders = [];
11611168
let stringMatcher = null;
@@ -1226,6 +1233,12 @@ define(function (require, exports, module) {
12261233
_sendDownloadStatusToBrowser(DOWNLOAD_EVENTS.CANCELLED, { downloadId: message.downloadId });
12271234
}
12281235
}
1236+
1237+
// notify live preview that dialog is now closed
1238+
if (message && message.downloadId) {
1239+
_sendDownloadStatusToBrowser(DOWNLOAD_EVENTS.DIALOG_CLOSED, { downloadId: message.downloadId });
1240+
}
1241+
12291242
dialog.close();
12301243
});
12311244
}

0 commit comments

Comments
 (0)