Skip to content

Commit 035c19d

Browse files
committed
deploy: 0b2f639
1 parent ce10f76 commit 035c19d

File tree

38 files changed

+197
-170
lines changed

38 files changed

+197
-170
lines changed

LiveDevelopment/MultiBrowserImpl/documents/LiveHTMLDocument.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ define(function (require, exports, module) {
185185
// TODO: Not implemented.
186186
};
187187

188+
function _isSamePos(position, line, char) {
189+
return position.line === line && position.ch === char;
190+
}
191+
188192
/**
189193
* @private
190194
* Handles edits to the document. Determines what's changed in the source and sends DOM diffs to the browser.
@@ -212,13 +216,21 @@ define(function (require, exports, module) {
212216
applyEditsPromise;
213217

214218
if (result.edits) {
215-
applyEditsPromise = this.protocol.evaluate("_LD.applyDOMEdits(" + JSON.stringify(result.edits) + ")");
216-
217-
applyEditsPromise.always(function () {
218-
if (!isNestedTimer) {
219-
PerfUtils.addMeasurement(perfTimerName);
220-
}
221-
});
219+
let changedLineCount = change.length === 1 ? (change[0].to.line - change[0].from.line + 1) : null;
220+
if(changedLineCount && changedLineCount > 1 && changedLineCount === change[0].removed.length
221+
&& _isSamePos( change[0].from, 0, 0)){
222+
// whole file change.
223+
this.protocol.reload();
224+
PerfUtils.addMeasurement(perfTimerName);
225+
} else {
226+
applyEditsPromise = this.protocol.evaluate("_LD.applyDOMEdits(" + JSON.stringify(result.edits) + ")");
227+
228+
applyEditsPromise.always(function () {
229+
if (!isNestedTimer) {
230+
PerfUtils.addMeasurement(perfTimerName);
231+
}
232+
});
233+
}
222234
}
223235

224236
this.errors = result.errors || [];

LiveDevelopment/MultiBrowserImpl/language/HTMLInstrumentation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,10 +561,10 @@ define(function (require, exports, module) {
561561
* more information on the format of these edits.
562562
*/
563563
function getUnappliedEditList(editor, changeList) {
564-
var cachedValue = _cachedValues[editor.document.file.fullPath];
564+
const cachedValue = _cachedValues[editor.document.file.fullPath];
565565

566566
// We might not have a previous DOM if the document was empty before this edit.
567-
if (!cachedValue || !cachedValue.dom || _cachedValues[editor.document.file.fullPath].invalid) {
567+
if (!cachedValue || !cachedValue.dom || cachedValue.invalid) {
568568
// We were in an invalid state, so do a full rebuild.
569569
changeList = null;
570570
}

LiveDevelopment/pageLoader.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
broadcastChannel: params.broadcastChannel,
5151
clientID});
5252
if(params.URL){
53-
document.getElementById("contentFrame").src = params.URL;
53+
document.getElementById("contentFrame").src = decodeURIComponent(params.URL);
5454
const path = params.URL.replace(/\/$/, "").split("/");
5555
document.title = path[path.length -1];
5656
}

assets/default-project/en.zip

0 Bytes
Binary file not shown.

assets/phoenix-splash/no-preview.html

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,24 @@
33
<head>
44
<title>Phoenix Live Preview</title>
55
<link rel="stylesheet" href="styles.css">
6+
<script>
7+
function translate() {
8+
const urlParams = new URLSearchParams(window.location.search || "");
9+
if(urlParams.get('jsonInput')){
10+
let input = JSON.parse(decodeURIComponent(urlParams.get('jsonInput')));
11+
document.getElementById("heading").textContent = input.heading;
12+
document.getElementById("details").textContent = input.details;
13+
}
14+
}
15+
</script>
616
</head>
717

8-
<body>
18+
<body onload="translate()">
919
<img id="starsLeft" src="images/stars-left.svg"/>
1020
<div id="mainDiv" style="top: 50%">
1121
<div id="MainText">
12-
<h1>Nothing to preview</h1>
22+
<h1 id="heading">Nothing to preview!</h1>
23+
<p id="details">Please select an HTML file to preview</p>
1324
</div>
1425
</div>
1526
<img id="cloudLeftTop" src="images/vector-top-left.png"/>

assets/sample-projects/HTML5.zip

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

assets/sample-projects/explore.zip

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)