Skip to content

Commit 5da1d74

Browse files
committed
feat: add support to get started with live preview from a blank page
1 parent 05fa172 commit 5da1d74

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/LiveDevelopment/MultiBrowserImpl/documents/LiveHTMLDocument.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,21 @@ define(function (require, exports, module) {
127127
body = HTMLInstrumentation.generateInstrumentedHTML(this.editor, this.protocol.getRemoteScript());
128128
}
129129

130+
if (!body) {
131+
// generateInstrumentedHTML() returns null when the document is empty or its
132+
// HTML cannot be parsed into a DOM (no instrumentable content). In that case it
133+
// also never injected the remote <script>, so without help the served page would
134+
// have no live-preview runtime at all — a blank page with no way to connect back
135+
// or start editing. Fall back to the raw text but still inject the remote script
136+
// so the runtime always loads, even for a completely empty page.
137+
body = this.doc.getText();
138+
if (this._instrumentationEnabled) {
139+
body += this.protocol.getRemoteScript();
140+
}
141+
}
142+
130143
return {
131-
body: body || this.doc.getText()
144+
body: body
132145
};
133146
};
134147

src/nls/root/strings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ define({
206206
"LIVE_DEV_INSERT_SEARCH_PLACEHOLDER": "Search elements\u2026",
207207
"LIVE_DEV_INSERT_COMMON": "Common",
208208
"LIVE_DEV_INSERT_NO_RESULTS": "No matching elements",
209-
"LIVE_DEV_INSERT_SEE_MORE": "See more",
209+
"LIVE_DEV_INSERT_SHOW_MORE": "Show more",
210210
"LIVE_DEV_INSERT_SHOW_LESS": "Show less",
211211
"LIVE_DEV_INSERT_CREATE": "Create",
212212
"LIVE_DEV_EDIT_ONBOARD_TITLE": "Two new ways to edit",

0 commit comments

Comments
 (0)