Skip to content

Commit

Permalink
close #36
Browse files Browse the repository at this point in the history
  • Loading branch information
amay077 committed Mar 5, 2023
1 parent b4fc062 commit 6b31234
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/app/ui/main/main.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,16 @@ export class MainComponent implements OnInit, OnDestroy {
) {
this.isMobile = isSmartPhone();

const preview = route.snapshot.queryParamMap.get('preview');
if (!this.isMobile) {
this.options.showPreviewPanel = true;
const defayltPreview = (preview ?? 'true') === 'true';
this.options.showPreviewPanel = defayltPreview;
this.options = Object.assign({}, this.options);
this.showPreview = true;
this.showPreview = defayltPreview;
} else {
const defayltPreview = (preview ?? 'false') === 'true';
this.mode = defayltPreview ? "preview" : 'editor';
this.showPreview = defayltPreview;
}

const matter = settings.frontMatter;
Expand Down Expand Up @@ -133,6 +139,15 @@ ${rendered}
this.options = Object.assign({}, this.options);
}
this.showPreview = !this.showPreview;

const url = new URL(window.location.href);
let hash = url.hash;
const queryParamsPos = hash.indexOf('?');
if (queryParamsPos > 0) {
hash = hash.substring(0, queryParamsPos);
}
url.hash = `${hash}?preview=${this.showPreview}`;
window.history.replaceState('', '', url);
}

toggleShowPreviewPanel() {
Expand Down

0 comments on commit 6b31234

Please sign in to comment.