Skip to content

Commit 138313c

Browse files
committed
refactor: move dismissLivePreviewEditBoxes into pro extension
1 parent c5670f3 commit 138313c

File tree

7 files changed

+35
-44
lines changed

7 files changed

+35
-44
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5627,7 +5627,6 @@ function RemoteFunctions(config = {}) {
56275627
"startEditing" : startEditing,
56285628
"finishEditing" : finishEditing,
56295629
"dismissUIAndCleanupState" : dismissUIAndCleanupState,
5630-
"enableHoverListeners" : enableHoverListeners,
56315630
"handleDownloadEvent" : handleDownloadEvent,
56325631
"showToastMessage" : showToastMessage
56335632
};

src/LiveDevelopment/LiveDevMultiBrowser.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -699,16 +699,6 @@ define(function (require, exports, module) {
699699
}
700700
}
701701

702-
/**
703-
* Dismiss live preview boxes like info box, options box, AI box
704-
*/
705-
function dismissLivePreviewBoxes() {
706-
if (_protocol) {
707-
_protocol.evaluate("_LD.enableHoverListeners()"); // so that if hover lock is there it will get cleared
708-
_protocol.evaluate("_LD.dismissUIAndCleanupState()");
709-
}
710-
}
711-
712702
/**
713703
* Update configuration in the remote browser
714704
*/
@@ -784,7 +774,6 @@ define(function (require, exports, module) {
784774
exports.showHighlight = showHighlight;
785775
exports.hideHighlight = hideHighlight;
786776
exports.redrawHighlight = redrawHighlight;
787-
exports.dismissLivePreviewBoxes = dismissLivePreviewBoxes;
788777
exports.updateConfig = updateConfig;
789778
exports.init = init;
790779
exports.isActive = isActive;

src/LiveDevelopment/main.js

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ define(function main(require, exports, module) {
4444
Strings = require("strings"),
4545
ExtensionUtils = require("utils/ExtensionUtils"),
4646
StringUtils = require("utils/StringUtils"),
47-
EventDispatcher = require("utils/EventDispatcher"),
48-
WorkspaceManager = require("view/WorkspaceManager");
47+
EventDispatcher = require("utils/EventDispatcher");
4948

5049

5150
const KernalModeTrust = window.KernalModeTrust;
@@ -224,19 +223,6 @@ define(function main(require, exports, module) {
224223
}
225224
}
226225

227-
/**
228-
* this function handles escape key for live preview to hide boxes if they are visible
229-
* @param {Event} event
230-
*/
231-
function _handleLivePreviewEscapeKey(event) {
232-
// we only handle the escape keypress for live preview when its active
233-
if (MultiBrowserLiveDev.status === MultiBrowserLiveDev.STATUS_ACTIVE) {
234-
MultiBrowserLiveDev.dismissLivePreviewBoxes();
235-
}
236-
// returning false to let the editor also handle the escape key
237-
return false;
238-
}
239-
240226
// default mode means on first load for pro user we have edit mode
241227
// for free user we have highlight mode
242228
function _getDefaultMode() {
@@ -352,10 +338,6 @@ define(function main(require, exports, module) {
352338
MultiBrowserLiveDev.on(MultiBrowserLiveDev.EVENT_LIVE_PREVIEW_RELOAD, function (_event, clientDetails) {
353339
exports.trigger(exports.EVENT_LIVE_PREVIEW_RELOAD, clientDetails);
354340
});
355-
356-
// allow live preview to handle escape key event
357-
// Escape is mainly to hide boxes if they are visible
358-
WorkspaceManager.addEscapeKeyEventHandler("livePreview", _handleLivePreviewEscapeKey);
359341
});
360342

361343
function _updateConfigMode() {
@@ -421,7 +403,6 @@ define(function main(require, exports, module) {
421403
exports.getConnectionIds = MultiBrowserLiveDev.getConnectionIds;
422404
exports.getLivePreviewDetails = MultiBrowserLiveDev.getLivePreviewDetails;
423405
exports.hideHighlight = MultiBrowserLiveDev.hideHighlight;
424-
exports.dismissLivePreviewBoxes = MultiBrowserLiveDev.dismissLivePreviewBoxes;
425406
exports.setMode = setMode;
426407
exports.getCurrentMode = getCurrentMode;
427408
exports.isInPreviewMode = isInPreviewMode;

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,10 +403,6 @@ define(function (require, exports, module) {
403403
PreferencesManager.set(PREFERENCE_SHOW_RULER_LINES, !currentValue);
404404
return; // Don't dismiss highlights for this option
405405
}
406-
407-
// need to dismiss the previous highlighting and stuff
408-
LiveDevelopment.hideHighlight();
409-
LiveDevelopment.dismissLivePreviewBoxes();
410406
});
411407

412408
// Remove the button after the dropdown is hidden
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright (c) 2021 - present core.ai . All rights reserved.
3+
* Proprietary code, all rights reserved.
4+
*/
5+
6+
/*global customReturns, enableHoverListeners, dismissUIAndCleanupState*/
7+
8+
function dismissLivePreviewEditBoxes() {
9+
enableHoverListeners(); // so that if hover lock is there it will get cleared
10+
dismissUIAndCleanupState();
11+
}
12+
13+
customReturns.dismissLivePreviewEditBoxes = dismissLivePreviewEditBoxes;

src/extensionsIntegrated/phoenix-pro/browser-context/sample-remore-fn.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/extensionsIntegrated/phoenix-pro/main.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,30 @@ define(function (require, exports, module) {
1010
require("./remote-styles");
1111

1212
const AppInit = require("utils/AppInit"),
13+
WorkspaceManager = require("view/WorkspaceManager"),
14+
LiveDevMultiBrowser = require("LiveDevelopment/LiveDevMultiBrowser"),
1315
Strings = require("strings");
1416

15-
const sampleFnText = require("text!./browser-context/sample-remore-fn.js");
17+
const remoteUtilsCode = require("text!./browser-context/remote-utils.js");
1618
const LiveDevProtocol = require("LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol");
17-
LiveDevProtocol.addRemoteFunctionScript("sampleFn", sampleFnText);
19+
LiveDevProtocol.addRemoteFunctionScript("remoteUtilsCode", remoteUtilsCode);
20+
21+
22+
/**
23+
* this function handles escape key for live preview to hide boxes if they are visible
24+
* @param {Event} event
25+
*/
26+
function _handleLivePreviewEscapeKey(event) {
27+
const currLiveDoc = LiveDevMultiBrowser.getCurrentLiveDoc();
28+
if (currLiveDoc && currLiveDoc.protocol && currLiveDoc.protocol.evaluate) {
29+
currLiveDoc.protocol.evaluate("_LD.dismissLivePreviewEditBoxes()");
30+
}
31+
// returning false to let the editor also handle the escape key
32+
return false;
33+
}
34+
// allow live preview to handle escape key event
35+
// Escape is mainly to hide boxes if they are visible
36+
WorkspaceManager.addEscapeKeyEventHandler("livePreview", _handleLivePreviewEscapeKey);
1837

1938
AppInit.appReady(function () {
2039

0 commit comments

Comments
 (0)