Skip to content

FileSource

Somewhere files are opened from and saved to, such as a cloud drive.

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
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.

Parameter Type
origin FileOrigin

Promise< | RemoteFile | null>


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.

FileOrigin[]


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.

Promise< | RemoteFile | null>


optional preload(): void;

Called when a menu holding the source opens: load an SDK here, so pick can open a popup inside the click.

void


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.

Parameter Type
file SavedWorkbook
origin FileOrigin

Promise<FileOrigin>


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.

Parameter Type
file SavedWorkbook

Promise< | FileOrigin | null>