forked from gristlabs/grist-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add hooks for tweaking how downloads happen (for grist-static) (grist…
…labs#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.
- Loading branch information
Showing
8 changed files
with
94 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
import { UrlTweaks } from 'app/common/gristUrls'; | ||
import { IAttrObj } from 'grainjs'; | ||
|
||
export interface IHooks { | ||
iframeAttributes?: Record<string, any>, | ||
fetch?: typeof fetch, | ||
baseURI?: string, | ||
urlTweaks?: UrlTweaks, | ||
|
||
/** | ||
* Modify the attributes of an <a> dom element. | ||
* Convenient in grist-static to directly hook up a | ||
* download link with the function that provides the data. | ||
*/ | ||
maybeModifyLinkAttrs(attrs: IAttrObj): IAttrObj; | ||
} | ||
|
||
export const defaultHooks: IHooks = { | ||
maybeModifyLinkAttrs(attrs: IAttrObj) { | ||
return attrs; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters