Make sure that shown playground Prettier version always is in sync
parent
951aed47f6
commit
8ba2acadbb
|
@ -8,7 +8,7 @@ Tip! Don't write this stuff manually.
|
|||
|
||||
-->
|
||||
|
||||
**Prettier Version:** 1.6.1 / master
|
||||
**Prettier Version:** 1.6.1
|
||||
([Playground link](https://prettier.io/playground/#.....))
|
||||
|
||||
**Input:**
|
||||
|
|
|
@ -106,9 +106,6 @@ shell.sed(
|
|||
".github/ISSUE_TEMPLATE.md"
|
||||
);
|
||||
|
||||
shell.echo("Create prettier-version.js");
|
||||
pipe(`prettierVersion = "${pkg.version}";\n`).to(`${docs}/prettier-version.js`);
|
||||
|
||||
shell.echo("Copy sw-toolbox.js to docs");
|
||||
shell.cp("node_modules/sw-toolbox/sw-toolbox.js", `${docs}/sw-toolbox.js`);
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
<link rel="stylesheet" crossorigin href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.26.0/codemirror.css">
|
||||
<link rel="stylesheet" crossorigin href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.26.0/theme/neat.css">
|
||||
|
||||
<script src="/lib/prettier-version.js"></script>
|
||||
<script src="/playground.js"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.26.0/codemirror.js"></script>
|
||||
|
@ -346,9 +345,8 @@
|
|||
<footer>
|
||||
<p class="version-link">
|
||||
<a href="https://github.com/prettier/prettier">
|
||||
prettier version
|
||||
Prettier
|
||||
<span class="version"></span>
|
||||
/ master
|
||||
</a>
|
||||
</p>
|
||||
</footer>
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
prettierVersion = "1.6.1";
|
|
@ -1,6 +1,12 @@
|
|||
/* eslint-env browser */
|
||||
/* eslint no-var: off, strict: off, prefer-arrow-callback: off */
|
||||
/* global Clipboard CodeMirror prettierVersion */
|
||||
/* global Clipboard CodeMirror */
|
||||
|
||||
var prettierVersion = "?";
|
||||
var inputEditor;
|
||||
var docEditor;
|
||||
var astEditor;
|
||||
var outputEditor;
|
||||
|
||||
var state = (function loadState(hash) {
|
||||
try {
|
||||
|
@ -20,6 +26,19 @@ var state = (function loadState(hash) {
|
|||
})(decodeURIComponent(location.hash.slice(1)));
|
||||
|
||||
var worker = new Worker("/worker.js");
|
||||
|
||||
worker.onmessage = function(message) {
|
||||
if (prettierVersion === "?") {
|
||||
prettierVersion = message.data.version;
|
||||
document.querySelector(".version").textContent = prettierVersion;
|
||||
}
|
||||
if (outputEditor && docEditor && astEditor) {
|
||||
outputEditor.setValue(message.data.formatted);
|
||||
docEditor.setValue(message.data.doc || "");
|
||||
astEditor.setValue(message.data.ast || "");
|
||||
}
|
||||
};
|
||||
|
||||
// Warm up the worker (load the current parser while CodeMirror loads)
|
||||
worker.postMessage({ text: "", options: state.options });
|
||||
|
||||
|
@ -184,21 +203,23 @@ window.onload = function() {
|
|||
theme: theme,
|
||||
tabWidth: 2
|
||||
};
|
||||
var inputEditor = CodeMirror.fromTextArea(
|
||||
inputEditor = CodeMirror.fromTextArea(
|
||||
document.getElementById("input-editor"),
|
||||
editorOptions
|
||||
);
|
||||
inputEditor.on("change", formatAsync);
|
||||
|
||||
var docEditor = CodeMirror.fromTextArea(
|
||||
document.getElementById("doc-editor"),
|
||||
{ readOnly: true, lineNumbers: false, theme: theme }
|
||||
);
|
||||
var astEditor = CodeMirror.fromTextArea(
|
||||
document.getElementById("ast-editor"),
|
||||
{ readOnly: true, lineNumbers: false, theme: theme }
|
||||
);
|
||||
var outputEditor = CodeMirror.fromTextArea(
|
||||
docEditor = CodeMirror.fromTextArea(document.getElementById("doc-editor"), {
|
||||
readOnly: true,
|
||||
lineNumbers: false,
|
||||
theme: theme
|
||||
});
|
||||
astEditor = CodeMirror.fromTextArea(document.getElementById("ast-editor"), {
|
||||
readOnly: true,
|
||||
lineNumbers: false,
|
||||
theme: theme
|
||||
});
|
||||
outputEditor = CodeMirror.fromTextArea(
|
||||
document.getElementById("output-editor"),
|
||||
{ readOnly: true, lineNumbers: true, theme: theme }
|
||||
);
|
||||
|
@ -210,15 +231,8 @@ window.onload = function() {
|
|||
element.classList.remove("loading");
|
||||
});
|
||||
|
||||
worker.onmessage = function(message) {
|
||||
outputEditor.setValue(message.data.formatted);
|
||||
docEditor.setValue(message.data.doc || "");
|
||||
astEditor.setValue(message.data.ast || "");
|
||||
};
|
||||
|
||||
inputEditor.setValue(state.content);
|
||||
document.querySelector(".options-container").onchange = formatAsync;
|
||||
document.querySelector(".version").innerText = prettierVersion;
|
||||
|
||||
var clipboard = new Clipboard(".copy-markdown", {
|
||||
text: function() {
|
||||
|
@ -239,7 +253,7 @@ var util = (function() {
|
|||
var optionsString = formatCLIOptions(cliOptions);
|
||||
|
||||
return [
|
||||
"**Prettier " + version + " / master**",
|
||||
"**Prettier " + version,
|
||||
"[Playground link](" + url + ")",
|
||||
optionsString === "" ? null : codeBlock(optionsString),
|
||||
"",
|
||||
|
|
|
@ -7,7 +7,6 @@ importScripts("lib/sw-toolbox.js");
|
|||
|
||||
toolbox.precache([
|
||||
// Scripts
|
||||
"lib/prettier-version.js",
|
||||
"lib/index.js",
|
||||
"lib/parser-babylon.js",
|
||||
"lib/parser-typescript.js",
|
||||
|
|
|
@ -63,7 +63,12 @@ self.onmessage = function(message) {
|
|||
}
|
||||
}
|
||||
|
||||
self.postMessage({ formatted: formatted, doc: doc, ast: ast });
|
||||
self.postMessage({
|
||||
formatted: formatted,
|
||||
doc: doc,
|
||||
ast: ast,
|
||||
version: prettier.version
|
||||
});
|
||||
};
|
||||
|
||||
function formatCode(text, options) {
|
||||
|
|
Loading…
Reference in New Issue