diff --git a/website/src/website/pages/playground/PlaygroundModel.ts b/website/src/website/pages/playground/PlaygroundModel.ts index 15ae15f8..5f8bdc15 100644 --- a/website/src/website/pages/playground/PlaygroundModel.ts +++ b/website/src/website/pages/playground/PlaygroundModel.ts @@ -56,7 +56,7 @@ export class PlaygroundModel { public readonly serializer = new StateUrlSerializer(this); - reload(): void { + public reload(): void { this.reloadKey++; } @@ -127,12 +127,29 @@ export class PlaygroundModel { private readonly debouncer = new Debouncer(250); + @observable + public isDirty = false; + constructor() { + let lastState = this.state; + this.dispose.track({ dispose: reaction( () => ({ state: this.state }), ({ state }) => { + if (!this.settings.autoReload) { + if ( + JSON.stringify(state.monacoSetup) === + JSON.stringify(lastState.monacoSetup) && + state.key === lastState.key + ) { + this.isDirty = true; + return; + } + } this.debouncer.run(() => { + this.isDirty = false; + lastState = state; for (const handler of this._previewHandlers) { handler.handlePreview(state); } diff --git a/website/src/website/pages/playground/PlaygroundPageContent.tsx b/website/src/website/pages/playground/PlaygroundPageContent.tsx index 7968b323..20eca186 100644 --- a/website/src/website/pages/playground/PlaygroundPageContent.tsx +++ b/website/src/website/pages/playground/PlaygroundPageContent.tsx @@ -18,7 +18,7 @@ import { PlaygroundModel } from "./PlaygroundModel"; import { Preview } from "./Preview"; import { SettingsDialog } from "./SettingsDialog"; import { Button, Col, Row, Stack } from "../../components/bootstrap"; -import { ButtonGroup } from "react-bootstrap"; +import { ButtonGroup, FormCheck } from "react-bootstrap"; @hotComponent(module) @observer @@ -114,11 +114,29 @@ export class PlaygroundPageContent extends React.Component< titleBarItems={