The following functions allow you to share data between files without the need to use the REST API. While it suffers from some drawbacks (like managing duplicate files), it offers an almost frictionless experience for users.
When a user opens a file with your plugin the file is added to a list in clientStorage with a unique ID. When the user visits another file all previously visited files are be accessible from the clientStorage. Used in combination with a list which is stored on each file, it's possible to keep a record of remote files your plugin is using for a given file. The data for each file can contain any keys or information you need to access or import data from remote files.
-
Returns a list of recent files excluding the current file. Pass
fileData
to the function to add the current file and its data to the list of files.Files are automatically ordered by last visited.
opts
- expire - the time in milliseconds when a file should be automatically removed since the user last visited it with the plugin
-
Returns a list of remote files used by the plugin in this file. Used in combination with
getRecentFilesAsync
you can get the id of certain file and add it to the list of remote files by passing in thefileId
. When ever this function is called, it keeps the information for each file up to date. -
Removes the specified file from the list of remote files.
- UserA visits File1
- User opens the plugin
- The plugin saves some data from this file into clientStorage (
getRecentFilesAsync(fileData)
) - UserA visits File2
- The plugin asks user if they would like to use data from another file (
getRecentFilesAsync()
) - User tells plugin to use File1
- Plugin saves File1 to remoteFiles stored on the document node data (
getRemoteFilesAsync(fileId)
) - UserB visits File2
- User can now see data from File1
(getRemoteFilesAsync()
)