From b33641dd0c15d0b918165d7523573ccdabcaa6ed Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Mon, 21 Sep 2020 15:27:49 -0400 Subject: [PATCH] (core) support a ?compare= option in document landing pages Summary: If a `compare` query parameter is supplied, this diff will load the difference between the referenced document and the current document into an observable in the GristDoc. Nothing is done with the comparison yet. Comparisons are not yet live - they don't get updated if either document changes. For convenience, `window.gristDocPageModel` is set as an easy way to access the DocPageModel from the browser console. Test Plan: added test Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2615 --- app/common/gristUrls.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/common/gristUrls.ts b/app/common/gristUrls.ts index fd1bcf3c..eb69d441 100644 --- a/app/common/gristUrls.ts +++ b/app/common/gristUrls.ts @@ -65,6 +65,7 @@ export interface IGristUrlState { billingTask?: BillingTask; embed?: boolean; style?: InterfaceStyle; + compare?: string; }; hash?: HashLink; // if present, this specifies an individual row within a section of a page. } @@ -256,6 +257,9 @@ export function decodeUrl(gristConfig: Partial, location: Locat // Turn on light style if no style has been specified. if (embed && !state.params!.style) { state.params!.style = 'light'; } } + if (sp.has('compare')) { + state.params!.compare = sp.get('compare')!; + } if (location.hash) { const hash = location.hash; const hashParts = hash.split('.');