Skip to content

Commit 042c34e

Browse files
committed
feat: move all the strings to strings.js file
1 parent 4ac5b10 commit 042c34e

File tree

4 files changed

+35
-20
lines changed

4 files changed

+35
-20
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ function RemoteFunctions(config) {
11801180
let content = `<div class="node-options">`;
11811181

11821182
// not sure if we need to hide/show the AI icon, right now showing always
1183-
content += `<span data-action="ai" title="Phoenix AI">
1183+
content += `<span data-action="ai" title="${config.strings.ai}">
11841184
${ICONS.ai}
11851185
</span>`;
11861186

@@ -1681,7 +1681,7 @@ function RemoteFunctions(config) {
16811681
<div class="phoenix-ai-prompt-input-container">
16821682
<textarea
16831683
class="phoenix-ai-prompt-textarea"
1684-
placeholder="Ask Phoenix AI to modify this element..."
1684+
placeholder="${config.strings.aiPromptPlaceholder}"
16851685
></textarea>
16861686
<button class="phoenix-ai-prompt-send-button" disabled>
16871687
@@ -2145,6 +2145,11 @@ function RemoteFunctions(config) {
21452145
return;
21462146
}
21472147

2148+
// if _hoverHighlight is uninitialized, initialize it
2149+
if (!_hoverHighlight && config.isLPEditFeaturesActive && shouldShowHighlightOnHover()) {
2150+
_hoverHighlight = new Highlight("#c8f9c5", true);
2151+
}
2152+
21482153
// this is to check the user's settings, if they want to show the elements highlights on hover or click
21492154
if (_hoverHighlight && config.isLPEditFeaturesActive && shouldShowHighlightOnHover()) {
21502155
_hoverHighlight.clear();

src/LiveDevelopment/main.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ define(function main(require, exports, module) {
7474
selectParent: Strings.LIVE_DEV_MORE_OPTIONS_SELECT_PARENT,
7575
editText: Strings.LIVE_DEV_MORE_OPTIONS_EDIT_TEXT,
7676
duplicate: Strings.LIVE_DEV_MORE_OPTIONS_DUPLICATE,
77-
delete: Strings.LIVE_DEV_MORE_OPTIONS_DELETE
77+
delete: Strings.LIVE_DEV_MORE_OPTIONS_DELETE,
78+
ai: Strings.LIVE_DEV_MORE_OPTIONS_AI,
79+
aiPromptPlaceholder: Strings.LIVE_DEV_AI_PROMPT_PLACEHOLDER
7880
}
7981
};
8082
// Status labels/styles are ordered: error, not connected, progress1, progress2, connected.

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

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ define(function (require, exports, module) {
8888

8989
// live preview mode pref
9090
const PREFERENCE_LIVE_PREVIEW_MODE = "livePreviewMode";
91-
const DEFAULT_LIVE_PREVIEW_MODE = "preview"; // preview, inspect or edit
91+
const DEFAULT_LIVE_PREVIEW_MODE = "preview"; // preview, highlight or edit
9292
// define the live preview mode preference
9393
PreferencesManager.definePreference(PREFERENCE_LIVE_PREVIEW_MODE, "string", DEFAULT_LIVE_PREVIEW_MODE, {
94-
description: "Default live preview mode on startup (preview, inspect, edit)",
95-
values: ["preview", "inspect", "edit"]
94+
description: StringUtils.format(Strings.LIVE_PREVIEW_MODE_PREFERENCE, "'preview'", "'highlight'", "'edit'"),
95+
values: ["preview", "highlight", "edit"]
9696
});
9797

9898
const LIVE_PREVIEW_PANEL_ID = "live-preview-panel";
@@ -167,18 +167,18 @@ define(function (require, exports, module) {
167167
}
168168

169169
/**
170-
* Live Preview 'Inspect Mode'. in this mode only the live preview matching with the source code is active
170+
* Live Preview 'Highlight Mode'. in this mode only the live preview matching with the source code is active
171171
* Meaning that if user clicks on some element that element's source code will be highlighted and vice versa
172172
*/
173-
function _LPInspectMode() {
173+
function _LPHighlightMode() {
174174
LiveDevelopment.setLivePreviewEditFeaturesActive(false);
175175
if(!_isLiveHighlightEnabled()) {
176176
LiveDevelopment.togglePreviewHighlight();
177177
}
178178
}
179179

180180
/**
181-
* Live Preview 'Edit Mode'. this is the most interactive mode, in here the inspect features are available
181+
* Live Preview 'Edit Mode'. this is the most interactive mode, in here the highlight features are available
182182
* along with that we also show element's highlighted boxes and such
183183
*/
184184
function _LPEditMode() {
@@ -190,16 +190,16 @@ define(function (require, exports, module) {
190190

191191
/**
192192
* update the mode button text in the live preview toolbar UI based on the current mode
193-
* @param {String} mode - The current mode ("preview", "inspect", or "edit")
193+
* @param {String} mode - The current mode ("preview", "highlight", or "edit")
194194
*/
195195
function _updateModeButton(mode) {
196196
if ($modeBtn) {
197-
if (mode === "inspect") {
198-
$modeBtn[0].textContent = "Inspect Mode";
197+
if (mode === "highlight") {
198+
$modeBtn[0].textContent = Strings.LIVE_PREVIEW_MODE_HIGHLIGHT;
199199
} else if (mode === "edit") {
200-
$modeBtn[0].textContent = "Edit Mode";
200+
$modeBtn[0].textContent = Strings.LIVE_PREVIEW_MODE_EDIT;
201201
} else {
202-
$modeBtn[0].textContent = "Preview Mode";
202+
$modeBtn[0].textContent = Strings.LIVE_PREVIEW_MODE_PREVIEW;
203203
}
204204
}
205205
}
@@ -211,8 +211,8 @@ define(function (require, exports, module) {
211211
const savedMode = PreferencesManager.get(PREFERENCE_LIVE_PREVIEW_MODE) || "preview";
212212

213213
// apply the saved
214-
if (savedMode === "inspect") {
215-
_LPInspectMode();
214+
if (savedMode === "highlight") {
215+
_LPHighlightMode();
216216
} else if (savedMode === "edit") {
217217
_LPEditMode();
218218
} else {
@@ -223,7 +223,9 @@ define(function (require, exports, module) {
223223
}
224224

225225
function _showModeSelectionDropdown(event) {
226-
const items = ["Preview Mode", "Inspect Mode", "Edit Mode"];
226+
const items = [
227+
Strings.LIVE_PREVIEW_MODE_PREVIEW, Strings.LIVE_PREVIEW_MODE_HIGHLIGHT, Strings.LIVE_PREVIEW_MODE_EDIT
228+
];
227229

228230
const dropdown = new DropdownButton.DropdownButton("", items);
229231

@@ -252,7 +254,7 @@ define(function (require, exports, module) {
252254
if (index === 0) {
253255
PreferencesManager.set(PREFERENCE_LIVE_PREVIEW_MODE, "preview");
254256
} else if (index === 1) {
255-
PreferencesManager.set(PREFERENCE_LIVE_PREVIEW_MODE, "inspect");
257+
PreferencesManager.set(PREFERENCE_LIVE_PREVIEW_MODE, "highlight");
256258
} else if (index === 2) {
257259
PreferencesManager.set(PREFERENCE_LIVE_PREVIEW_MODE, "edit");
258260
}
@@ -947,8 +949,8 @@ define(function (require, exports, module) {
947949
// Get the current preference value directly
948950
const newMode = PreferencesManager.get(PREFERENCE_LIVE_PREVIEW_MODE);
949951

950-
if (newMode === "inspect") {
951-
_LPInspectMode();
952+
if (newMode === "highlight") {
953+
_LPHighlightMode();
952954
} else if (newMode === "edit") {
953955
_LPEditMode();
954956
} else {

src/nls/root/strings.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,13 @@ define({
187187
"LIVE_DEV_MORE_OPTIONS_EDIT_TEXT": "Edit Text",
188188
"LIVE_DEV_MORE_OPTIONS_DUPLICATE": "Duplicate",
189189
"LIVE_DEV_MORE_OPTIONS_DELETE": "Delete",
190+
"LIVE_DEV_MORE_OPTIONS_AI": "Edit with AI",
191+
"LIVE_DEV_AI_PROMPT_PLACEHOLDER": "Ask Phoenix AI to modify this element...",
190192
"LIVE_PREVIEW_CUSTOM_SERVER_BANNER": "Getting preview from your custom server {0}",
193+
"LIVE_PREVIEW_MODE_PREVIEW": "Preview Mode",
194+
"LIVE_PREVIEW_MODE_HIGHLIGHT": "Highlight Mode",
195+
"LIVE_PREVIEW_MODE_EDIT": "Edit Mode",
196+
"LIVE_PREVIEW_MODE_PREFERENCE": "{0} shows only the webpage, {1} connects the webpage to your code - click on elements to jump to their code and vice versa, {2} provides highlighting along with advanced element manipulation",
191197

192198
"LIVE_DEV_DETACHED_REPLACED_WITH_DEVTOOLS": "Live Preview was canceled because the browser's developer tools were opened",
193199
"LIVE_DEV_DETACHED_TARGET_CLOSED": "Live Preview was canceled because the page was closed in the browser",

0 commit comments

Comments
 (0)