FileSource
Somewhere files are opened from and saved to, such as a cloud drive.
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
icon? |
string |
- |
id |
string |
Unique within the plugin; FileOrigin.source names it. |
label |
PluginText |
Shown in the Open menu, as “Save to |
Methods
Section titled “Methods”fetch()?
Section titled “fetch()?”optional fetch(origin): Promise< | RemoteFile| null>;Fetches the file an origin names again, as it is now, for opening it
without pick: from a list of recent files, or a link. The origin may
be old, so resolve with the file’s current one. Resolves null when the
person cancels (a sign-in they close). Without it, files from this
source can only be opened by picking them.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
origin |
FileOrigin |
Returns
Section titled “Returns”Promise<
| RemoteFile
| null>
items()?
Section titled “items()?”optional items(): FileOrigin[];Files to offer by name, read each time the Open menu opens: recent ones,
or favourites. With some, the source’s entry in the Open menu is a
submenu of them (then “Browse…” for pick, if it has one), and choosing
one fetches it through fetch, of the source its origin names, inside
the click. A source needs items or pick.
Returns
Section titled “Returns”pick()?
Section titled “pick()?”optional pick(): Promise< | RemoteFile| null>;Lets the person choose a file, and fetches it. Resolves null when they
cancel. An error thrown here, or from save or saveAs, is shown with
its text when it has one (any PluginText, so it can be translated),
otherwise its message.
Returns
Section titled “Returns”Promise<
| RemoteFile
| null>
preload()?
Section titled “preload()?”optional preload(): void;Called when a menu holding the source opens: load an SDK here, so pick can open a popup inside the click.
Returns
Section titled “Returns”void
save()?
Section titled “save()?”optional save(file, origin): Promise<FileOrigin>;Writes the workbook back over the file it was opened from, resolving
with its origin as now saved. Throw an error named “SaveConflictError”
(SaveConflictError from @ruled/sheet is one) when it changed since.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
file |
SavedWorkbook |
origin |
FileOrigin |
Returns
Section titled “Returns”Promise<FileOrigin>
saveAs()?
Section titled “saveAs()?”optional saveAs(file): Promise< | FileOrigin| null>;Writes the workbook as a new file, letting the person choose where and what to call it. Resolves null when they cancel.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
file |
SavedWorkbook |
Returns
Section titled “Returns”Promise<
| FileOrigin
| null>