Skip to content

Commit fed3682

Browse files
committed
deploy: 84352e3
1 parent 23de96a commit fed3682

File tree

505 files changed

+45307
-7792
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

505 files changed

+45307
-7792
lines changed

LiveDevelopment/BrowserScripts/LiveDevProtocolRemote.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,27 @@
361361
ProtocolManager.enable();
362362
});
363363

364+
function _getAllInheritedSelectorsInOrder(element) {
365+
let selectorsFound= new Map();
366+
const selectorsList = [];
367+
while (element) {
368+
if(element.id){
369+
selectorsList.push(`#${element.id}`);
370+
}
371+
if (element.classList) {
372+
element.classList.forEach(cls => {
373+
if(!selectorsFound.get(cls)){
374+
selectorsFound.set(cls, true);
375+
selectorsList.push(`.${cls}`);
376+
}
377+
});
378+
}
379+
element = element.parentElement; // Move up to the next parent element
380+
}
381+
return selectorsList;
382+
}
383+
384+
364385
/**
365386
* Sends the message containing tagID which is being clicked
366387
* to the editor in order to change the cursor position to
@@ -381,7 +402,10 @@
381402
if (element && element.hasAttribute('data-brackets-id')) {
382403
MessageBroker.send({
383404
"tagId": element.getAttribute('data-brackets-id'),
405+
"nodeID": element.id,
406+
"nodeClassList": element.classList,
384407
"nodeName": element.nodeName,
408+
"allSelectors": _getAllInheritedSelectorsInOrder(element),
385409
"contentEditable": element.contentEditable === 'true',
386410
"clicked": true
387411
});

LiveDevelopment/LiveDevMultiBrowser.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
* - "navigated_away" (The browser changed to a location outside of the project)
5555
* - "detached_target_closed" (The tab or window was closed)
5656
*/
57+
58+
/*global jsPromise */
59+
5760
define(function (require, exports, module) {
5861

5962

@@ -521,24 +524,18 @@ define(function (require, exports, module) {
521524
isViewable = _server && _server.canServe(doc.file.fullPath);
522525

523526
if (_liveDocument && _liveDocument.doc.url !== docUrl && isViewable) {
524-
// clear live doc and related docs
525-
_closeDocuments();
526-
// create new live doc
527-
_createLiveDocumentForFrame(doc);
528-
_setStatus(STATUS_RESTARTING);
529-
_open(doc);
530-
527+
open();
531528
}
532529
}
533530

534531

535532
/**
536533
* Open a live preview on the current docuemnt.
537534
*/
538-
function open() {
535+
async function open() {
539536
let doc = DocumentManager.getCurrentDocument();
540537
if(livePreviewUrlPinned){
541-
doc = DocumentManager.getDocumentForPath(currentPreviewFilePath);
538+
doc = await jsPromise(DocumentManager.getDocumentForPath(currentPreviewFilePath));
542539
}
543540

544541
// wait for server (StaticServer, Base URL or file:)
@@ -548,6 +545,9 @@ define(function (require, exports, module) {
548545
return;
549546
}
550547
_setStatus(STATUS_CONNECTING);
548+
// clear live doc and related docs
549+
_closeDocuments();
550+
// create new live doc
551551
doc && _createLiveDocumentForFrame(doc);
552552
if(_server.isActive()){
553553
doc && _open(doc);
@@ -604,7 +604,7 @@ define(function (require, exports, module) {
604604
* @param {Document} doc
605605
*/
606606
function _onDirtyFlagChange(event, doc) {
607-
if (!isActive() || !_server || !_liveDocument) {
607+
if (!isActive() || !_server || !_liveDocument || !_liveDocument.isRelated) {
608608
return;
609609
}
610610

LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js

Lines changed: 84 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ define(function (require, exports, module) {
4444
// Text of the script we'll inject into the browser that handles protocol requests.
4545
const LiveDevProtocolRemote = require("text!LiveDevelopment/BrowserScripts/LiveDevProtocolRemote.js"),
4646
DocumentObserver = require("text!LiveDevelopment/BrowserScripts/DocumentObserver.js"),
47+
LanguageManager = require("language/LanguageManager"),
4748
RemoteFunctions = require("text!LiveDevelopment/BrowserScripts/RemoteFunctions.js"),
4849
EditorManager = require("editor/EditorManager"),
4950
LiveDevMultiBrowser = require("LiveDevelopment/LiveDevMultiBrowser"),
5051
PreferencesManager = require("preferences/PreferencesManager"),
5152
HTMLInstrumentation = require("LiveDevelopment/MultiBrowserImpl/language/HTMLInstrumentation"),
5253
StringUtils = require("utils/StringUtils"),
53-
FileViewController = require("project/FileViewController");
54+
FileViewController = require("project/FileViewController"),
55+
MainViewManager = require("view/MainViewManager");
5456

5557
const LIVE_DEV_REMOTE_SCRIPTS_FILE_NAME = `phoenix_live_preview_scripts_instrumented_${StringUtils.randomString(8)}.js`;
5658
const LIVE_DEV_REMOTE_WORKER_SCRIPTS_FILE_NAME = `pageLoaderWorker_${StringUtils.randomString(8)}.js`;
@@ -107,38 +109,96 @@ define(function (require, exports, module) {
107109
editor.focus();
108110
}
109111

110-
function _tagSelectedInLivePreview(tagId, nodeName, contentEditable) {
112+
const cssLangIDS = ["css", "scss", "sass", "less"];
113+
const lessLangIDS = ["scss", "sass", "less"];
114+
function _isLessOrSCSS(editor) {
115+
if(!editor){
116+
return false;
117+
}
118+
const language = LanguageManager.getLanguageForPath(editor.document.file.fullPath);
119+
return language && lessLangIDS.includes(language.getId());
120+
}
121+
122+
function _searchAndCursorIfCSS(editor, allSelectors, nodeName) {
123+
const codeMirror = editor._codeMirror;
124+
const language = LanguageManager.getLanguageForPath(editor.document.file.fullPath);
125+
if(!language || !cssLangIDS.includes(language.getId())){
126+
return;
127+
}
128+
129+
// this is a css file
130+
if(allSelectors && allSelectors.length){
131+
// check if we can find a class selector
132+
for(let selector of allSelectors){
133+
const cursor = codeMirror.getSearchCursor(selector);
134+
const found = cursor.findNext();
135+
if (found) {
136+
editor.setCursorPos(cursor.from().line, cursor.from().ch, true);
137+
return;
138+
}
139+
}
140+
}
141+
// check if we can do tag matching, html tag selectors are not case-sensitive
142+
const htmlTagSearch = new RegExp(nodeName, "i");
143+
const cursor = codeMirror.getSearchCursor(htmlTagSearch);
144+
const found = cursor.findNext();
145+
if (found) {
146+
editor.setCursorPos(cursor.from().line, cursor.from().ch, true);
147+
}
148+
}
149+
150+
function _tagSelectedInLivePreview(tagId, nodeName, contentEditable, allSelectors) {
111151
const highlightPref = PreferencesManager.getViewState("livedevHighlight");
112152
if(!highlightPref){
113153
// live preview highlight and reverse highlight feature is disabled
114154
return;
115155
}
116156
const liveDoc = LiveDevMultiBrowser.getCurrentLiveDoc(),
117-
editor = EditorManager.getActiveEditor();
157+
activeEditor = EditorManager.getActiveEditor(), // this can be an inline editor
158+
activeFullEditor = EditorManager.getCurrentFullEditor();
118159
const liveDocPath = liveDoc ? liveDoc.doc.file.fullPath : null,
119-
activeEditorDocPath = editor ? editor.document.file.fullPath : null;
120-
function selectInActiveDocument() {
121-
// activeEditor can be either a full or inline(Eg. css inline within html) editor
122-
const activeEditor = EditorManager.getActiveEditor();
123-
const activeFullEditor = EditorManager.getCurrentFullEditor(); // always full editor
124-
const position = HTMLInstrumentation.getPositionFromTagId(activeFullEditor, parseInt(tagId, 10));
125-
// should we scan all editors for the file path and update selections on every editor?
126-
// currently we do it only for active / full editor.
127-
if(position &&
128-
activeEditor && activeEditor.document.file.fullPath === activeFullEditor.document.file.fullPath) {
129-
activeEditor.setCursorPos(position.line, position.ch, true);
130-
_focusEditorIfNeeded(activeEditor, nodeName, contentEditable);
131-
}
132-
if(position && activeFullEditor) {
133-
activeFullEditor.setCursorPos(position.line, position.ch, true);
134-
_focusEditorIfNeeded(activeFullEditor, nodeName, contentEditable);
160+
activeEditorPath = activeEditor ? activeEditor.document.file.fullPath : null,
161+
activeFullEditorPath = activeFullEditor ? activeFullEditor.document.file.fullPath : null;
162+
if(!liveDocPath){
163+
activeEditor && activeEditor.focus(); // restore focus from live preview
164+
return;
165+
}
166+
const openFullEditors = MainViewManager.findInOpenPane(liveDocPath);
167+
const openLiveDocEditor = openFullEditors.length ? openFullEditors[0].editor : null;
168+
function selectInHTMLEditor(fullHtmlEditor) {
169+
const position = HTMLInstrumentation.getPositionFromTagId(fullHtmlEditor, parseInt(tagId, 10));
170+
if(position && fullHtmlEditor) {
171+
const masterEditor = fullHtmlEditor.document._masterEditor || fullHtmlEditor;
172+
masterEditor.setCursorPos(position.line, position.ch, true);
173+
_focusEditorIfNeeded(masterEditor, nodeName, contentEditable);
135174
}
136175
}
137-
if(liveDocPath && liveDocPath !== activeEditorDocPath) {
138-
FileViewController.openAndSelectDocument(liveDocPath, FileViewController.PROJECT_MANAGER)
139-
.done(selectInActiveDocument);
176+
if(liveDocPath === activeFullEditorPath) {
177+
// if the active pane is the html being live previewed, select that.
178+
selectInHTMLEditor(activeFullEditor);
179+
} else if(liveDoc.isRelated(activeEditorPath) || _isLessOrSCSS(activeEditor)) {
180+
// the active editor takes the priority in the workflow. If a css related file is active,
181+
// then we dont need to open the html live doc. For less files, we dont check if its related as
182+
// its not directly linked usually and needs a compile step. so we just do a fuzzy search.
183+
activeEditor.focus();
184+
_searchAndCursorIfCSS(activeEditor, allSelectors, nodeName);
185+
// in this case, see if we need to do any css reverse highlight magic here
186+
} else if(openLiveDocEditor) {
187+
// If we are on multi pane mode, the html doc was open in an inactive unfocused editor.
188+
selectInHTMLEditor(openLiveDocEditor);
140189
} else {
141-
selectInActiveDocument();
190+
// no open editor for the live doc in panes, check if there is one in the working set.
191+
const foundInWorkingSetPane = MainViewManager.findInAllWorkingSets(liveDocPath);
192+
const paneToUse = foundInWorkingSetPane.length ?
193+
foundInWorkingSetPane[0].paneId:
194+
MainViewManager.ACTIVE_PANE; // if pane id is active pane, then the file is not open in working set
195+
const viewToUse = (paneToUse === MainViewManager.ACTIVE_PANE) ?
196+
FileViewController.PROJECT_MANAGER:
197+
FileViewController.WORKING_SET_VIEW;
198+
FileViewController.openAndSelectDocument(liveDocPath, viewToUse, paneToUse)
199+
.done(()=>{
200+
selectInHTMLEditor(EditorManager.getActiveEditor());
201+
});
142202
}
143203
}
144204

@@ -168,7 +228,7 @@ define(function (require, exports, module) {
168228
}
169229
}
170230
} else if (msg.clicked && msg.tagId) {
171-
_tagSelectedInLivePreview(msg.tagId, msg.nodeName, msg.contentEditable);
231+
_tagSelectedInLivePreview(msg.tagId, msg.nodeName, msg.contentEditable, msg.allSelectors);
172232
exports.trigger(EVENT_LIVE_PREVIEW_CLICKED, msg);
173233
} else {
174234
// enrich received message with clientId

LiveDevelopment/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ define(function main(require, exports, module) {
130130
MultiBrowserLiveDev.close();
131131
}
132132

133-
function openLivePreview() {
133+
function openLivePreview(doc) {
134134
if (!Phoenix.isTestWindow) {
135-
MultiBrowserLiveDev.open();
135+
MultiBrowserLiveDev.open(doc);
136136
}
137137
}
138138

appConfig.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ window.AppConfig = {
2424
"app_notification_url": "assets/notifications/dev/",
2525
"app_update_url": "https://updates.phcode.io/tauri/update-latest-experimental-build.json",
2626
"linting.enabled_by_default": true,
27-
"build_timestamp": "2024-03-27T12:21:46.110Z",
27+
"build_timestamp": "2024-04-29T14:28:38.757Z",
2828
"googleAnalyticsID": "G-P4HJFPDB76",
2929
"googleAnalyticsIDDesktop": "G-VE5BXWJ0HF",
3030
"mixPanelID": "49c4d164b592be2350fc7af06a259bf3",
@@ -36,8 +36,8 @@ window.AppConfig = {
3636
"bugsnagEnv": "development"
3737
},
3838
"name": "Phoenix Code",
39-
"version": "3.6.0-20073",
40-
"apiVersion": "3.6.0",
39+
"version": "3.6.5-20225",
40+
"apiVersion": "3.6.5",
4141
"homepage": "https://core.ai",
4242
"issues": {
4343
"url": "https://github.com/phcode-dev/phoenix/issues"

assets/default-project/en.zip

363 Bytes
Binary file not shown.

assets/default-project/en/Newly_added_features.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,40 @@ We are continuously adding features every week to improve the life of web develo
66
<a href="https://github.com/phcode-dev/phoenix/releases" target="_blank">Check out our release page!</a>
77

88
Here's a list of top features recently added to Phoenix:
9+
<h2><a target="_blank" href="https://docs.phcode.dev/docs/Features/live-preview-settings/">Custom Live Preview Servers</a></h2>
910

10-
<h2><a target="_blank" href="https://docs.phcode.dev/docs/find-in-files/">Search Filters - Advanced find in files</a></h2>
11+
`Added on April, 2024`
12+
13+
Preview PHP, React, and other dynamically rendered files with the
14+
new server settings dialog.
15+
16+
![Screenshot from 2024-04-12 13-08-34](https://github.com/phcode-dev/phoenix/assets/5336369/69fa0ee4-7262-42af-97d2-26154ec4a3b9)
17+
18+
19+
## Advanced HTML/CSS/LESS/SCSS Code Intelligence
20+
21+
`Added on April, 2024`
22+
23+
CSS class hints are now shown within the HTML file's class attribute.
24+
25+
![image](https://github.com/phcode-dev/phoenix/assets/5336369/112ad909-8fd0-4fc4-8042-041ecade9481)
26+
27+
Support for the latest CSS/LESS/SCSS syntax. Code intelligence and error
28+
detection for CSS, SCSS, and LESS files.
29+
30+
![image](https://github.com/phcode-dev/phoenix/assets/5336369/9c083bd3-9e34-418d-a1c8-c152393c37b2)
31+
32+
33+
<h2><a target="_blank" href="https://docs.phcode.dev/docs/Features/editor-rulers/">Editor Rulers</a></h2>
34+
35+
`Added on April, 2024`
36+
37+
Add multiple, color-customizable rulers in the editor to better visualize line
38+
lengths.
39+
40+
![image](https://github.com/phcode-dev/phoenix/assets/5336369/71b8b04c-d2ca-47b8-84bb-53cd0fb4593c)
41+
42+
<h2><a target="_blank" href="https://docs.phcode.dev/docs/Features/find-in-files/">Search Filters - Advanced find in files</a></h2>
1143

1244
`Added on March, 2024`
1345

assets/default-project/en/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<img id="logo" alt="logo" src="images/phoenix-logo.svg" />
1313
<div id="MainText">
1414
<h1>Phoenix Code</h1>
15-
<span>Code Creatively: Visual Editing Tailored for Developers<br /></span><br />
15+
<span>CLICK_HERE<br /></span><br />
1616
</div>
1717
<div class="video-container">
1818
<a

assets/default-project/en/styles.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ img {
1313

1414
#starsLeft {
1515
position: absolute;
16-
left: 0px;
16+
left: 0;
1717
top: 5%;
1818
opacity: 0.7;
1919
z-index: 2;
@@ -22,7 +22,7 @@ img {
2222
#starsRight {
2323
position: absolute;
2424
z-index: 2;
25-
right: 0px;
25+
right: 0;
2626
top: 5%;
2727
opacity: 0.7;
2828
}

assets/new-project/assets/js/new-project-from-url.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ function _setupNavigation() {
165165

166166
function initNewProjectFromURL() {
167167
_setupNavigation();
168-
if(window.parent.Phoenix.browser.isTauri){ // desktop builds
168+
if(window.parent.Phoenix.isNativeApp){ // desktop builds
169169
projectLocation = newProjectExtension.getLocalProjectsPath();
170170
projectName = PARAM_SUGGESTED_NAME;
171171
$(document.getElementById("createProjectBtn")).addClass("forced-inVisible");

0 commit comments

Comments
 (0)