mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
add hooks for tweaking how downloads happen (for grist-static) (#665)
This makes three main changes:
* Adds a hook to transform download links.
* Adds a hook to add an externally created ActiveDoc to a DocManager.
* Rejiggers XLSX export code so it can be used without streaming,
which is currently tricky in a browser. Regular usage with node
continues to use streaming.
With these changes, I have a POC in hand that updates grist-static
to support downloading CSVs, XLSXs, and .grist files.
This commit is contained in:
@@ -133,6 +133,14 @@ export class DocManager extends EventEmitter {
|
||||
return this.createNamedDoc(docSession, 'Untitled');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an ActiveDoc created externally. This is a hook used by
|
||||
* grist-static.
|
||||
*/
|
||||
public addActiveDoc(docId: string, activeDoc: ActiveDoc) {
|
||||
this._activeDocs.set(docId, Promise.resolve(activeDoc));
|
||||
}
|
||||
|
||||
public async createNamedDoc(docSession: OptDocSession, docId: string): Promise<string> {
|
||||
const activeDoc: ActiveDoc = await this.createNewEmptyDoc(docSession, docId);
|
||||
await activeDoc.addInitialTable(docSession);
|
||||
|
||||
Reference in New Issue
Block a user