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:
@@ -3,6 +3,7 @@
|
||||
* the sample documents (those in the Support user's Examples & Templates workspace).
|
||||
*/
|
||||
|
||||
import {hooks} from 'app/client/Hooks';
|
||||
import {makeT} from 'app/client/lib/localization';
|
||||
import {AppModel, reportError} from 'app/client/models/AppModel';
|
||||
import {DocPageModel} from "app/client/models/DocPageModel";
|
||||
@@ -302,14 +303,14 @@ export function downloadDocModal(doc: Document, pageModel: DocPageModel) {
|
||||
),
|
||||
cssModalButtons(
|
||||
dom.domComputed(use =>
|
||||
bigPrimaryButtonLink(`Download`, {
|
||||
bigPrimaryButtonLink(`Download`, hooks.maybeModifyLinkAttrs({
|
||||
href: pageModel.appModel.api.getDocAPI(doc.id).getDownloadUrl({
|
||||
template: use(selected) === "template",
|
||||
removeHistory: use(selected) === "nohistory" || use(selected) === "template",
|
||||
}),
|
||||
target: '_blank',
|
||||
download: ''
|
||||
},
|
||||
}),
|
||||
dom.on('click', () => {
|
||||
ctl.close();
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user