Files component
<wy-files> | WyFiles
Component for file management and collaboration. Supports uploading of multiple files at once, upload using drag'n'drop and pasting files to upload. Upload progress can be monitored and aborted. The files can be downloaded individually or as a compressed archive.
Includes file picker to link files from Cloud providers such as Google Drive, Dropbox, Box and Microsoft OneDrive, which are pre-configured when using default weavy.io hosting for the Weavy environment.
Images, audio, video, documents, code, and cloud files can be previewed with the built-in previewer for 100+ formats including images, streamed audio/video, PDF, Office and Google Drive.
The list can be displayed as a table or as a grid with sorting capabilities. Files can renamed directly in the list.
Each file can be discussed with rich comments with support for attachments, mentions, embedded links and more.
File uploads are automatically versioned with possibility to preview all versions and rollback to a specific version.
Office documents and spreadsheets can be opened and edited directly in Office using built-in WebDAV integration to automatically save new version back to the app.
Each files component requires an app identifier (uid), which automatically creates a corresponding app on your Weavy environment when the component is first initialized. It's also recommended to specify a readable name of the posts app, to get better readable notifications from the app. It's often useful to base the uid on something that identifies the location where the component is rendered. Typically you would use something like a product id, page id or path.
Auto-creating an app from markup uses default settings; only
nameanddirectorycan be set this way and they can't be changed afterwards from the client (attempts result in access denied). For greater control — settingaccess,membersormetadata— use the Apps API to create or update the app server-side. See initializing apps.
Component layout
The component is block-level with pre-defined CSS styling to adapt to flex- and grid-layouts as well as traditional flow-layouts. It's usually recommended to use a proper flex-layout for the container you are placing the component in for a smooth layout integration.
The height grows with the content per default. Content is automatically loaded during scrolling when the last content becomes visible (aka infinite scrolling). If placed in a flex- or grid-layout or if an explicit height is set, the component becomes scrollable.
The content within the component is per default aligned to the edges of it's own box. It's recommended to add your default padding to the container or to the component to make it fit your design. If you want the component to go all the way to the edges of your container without any outermost roundness or padding, you can set the padding to 0 and set the --wy-border-radius-outer to 0 to make the component align nicely with the edge.
You can add additional styling using CSS Custom Properties and CSS Shadow Parts and further customization using slots.
Importing
If you added the UIKit with npm you can use the following snippet to import the component into your project.
import { WyFiles } from "@weavy/uikit-web";
Examples
Standard files component
Displays a list of files with integrated uploading, cloud picker, previews, comments and versioning.
Specifying the app identifier (uid) is required, and automatically creates a corresponding app on your Weavy environment when the component is first initialized. It's recommended to specify a readable name of the posts app, to get better readable notifications from the app.
<wy-files uid="test-files" name="Test files"></wy-files>
Files component with grid display sorted by date
Displays a grid view with miniature thumbnails for each file. Files ar sorted by updated_at in reverse order.
<wy-files
uid="test-files"
name="Test files"
view="grid"
order="{ by: 'updated_at', descending: true }"
></wy-files>
Files component without header
Displays a list of files without the header bar (header="none" attribute).
<wy-files id="files-list" uid="test-files" header="none"></wy-files>
HTML attributes
Attributes can be set when using the component in HTML. All attributes have corresponding Javascript properties.
Most attributes are optional and/or has sensible default values. Any required attributes are indicated with an asterisk (*).
Learn more about attributes and properties.
| Attribute | Value | Description |
|---|---|---|
uid* |
string, number |
Unique identifier for the app. |
annotations |
"buttons-inline", "none" |
Set the appearance of annotations. Defaults to "buttons-inline". |
contextualData |
string |
Contextual data for agents to reference. |
directory |
string |
Optional directory identifier (id or name) to associate the app with. Only applied when the app is first created and a single uid is used; the user must be a member of the directory. |
enterToSend |
"never", "modifier", "auto", "always" |
Sets whether to use enter to send in the editor. "modifier" is Enter combined with Ctrl or Cmd. Defaults to "auto". |
features |
string |
Explicit space separated list of enabled features. All default features are enabled when this property is not defined. |
generateUid |
string |
Generates a unique uid by appending user and agent identifiers to the supplied string. |
header |
"interactive", "empty", "none" |
Appearance of the file list header. Defaults to "interactive". |
highlightId |
number |
File id to load, scroll into view and highlight. |
name |
string |
Optional display name for the app (used in notifications etc.) |
order |
{ by: string, descending: boolean } |
File order in the list. Order by combined with direction. Order by "name", "updated_at" or "size". |
placeholder |
string |
Placeholder text for the comment editor input. |
reactions |
string |
Space separated string of unicode emojis to use for reactions. Defaults to reactions from the Weavy instance or <wy-context>. |
selectedId |
number |
File id that is selected. |
showTrashed |
Enable showing trashed files. | |
view |
"list", "grid" |
The view for showing the file list. |
JavaScript properties
Properties can be used in JavaScript. Some of them have corresponding HTML attributes where applicable. Any required attributes are indicated with an asterisk (*).
| Property | Type | Default | Description |
|---|---|---|---|
uid* |
string, number |
Unique identifier or app id for the Weavy component. The unique identifier should correspond to the uid of the app created using the server-to-server Web API. | |
annotations |
"buttons-inline", "none" |
"buttons-inline" |
Appearance of annotations. |
app |
AppType |
The app data. | |
contextualData |
string |
Contextual data for agents to reference. Provide descriptive data for optimal results. ### Examples | |
enterToSend |
"never", "modifier", "auto", "always" |
"auto" |
Enter-to-send keymap in the editor. "modifier" is Enter combined with Ctrl or Cmd. |
directory |
string |
Optional directory identifier (id or name) to associate the app with. Only applied when the app is first created and a single uid is used; the user must be a member of the directory. |
|
features |
string |
Config for only enabling specific features in the weavy component. | |
generateUid |
string |
Sets the uid property with automatically appended user and agent name (where applicable). | |
header |
"interactive", "static", "none" |
"interactive" |
Appearance of the file list header |
highlightId |
number |
NaN |
File id to load, scroll to and highlight. |
link |
LinkType |
Any provided link that should be loaded, shown and highlighted. | |
name |
string |
Optional display name for the app (used in notifications etc.) | |
order |
{ by: string, descending: boolean } |
{ by: "name", descending: false } |
File order in the list. Persisted in sessionStorage. |
reactions |
string |
"😍 😎 😉 😜 👍" |
A space separated string of available reaction emojis in unicode. |
placeholder |
string |
Placeholder text for the comment editor input. | |
selectedId |
number |
NaN |
File id that is selected. |
showTrashed |
boolean |
false |
Enables showing trashed files. Persisted in sessionStorage. |
view |
"grid", "list" |
"list" |
The view for showing the file list. Persisted in sessionStorage. |
JavaScript methods
Methods for the component are available in JavaScript. Methods that are async return a promise.
| Method | Returns | Description |
|---|---|---|
preview(fileId: number, options: { edit?: boolean; tab?: "comments" \| "versions" }) |
Open a file in preview/edit. Optionally opens "comment" tab or "versions" tab. | |
reset() |
Sets the component to it's initial state and resets the app state. |
|
subscribe(subscribe: boolean) |
async | Subscribes or unsubscribes to notification updates from the app. Check .app.is_subscribed to see current state. |
whenApp() |
async AppType |
Waits for app data and returns the data when available. |
whenReady() |
async | Resolves when the component has rendered the first time. |
DOM Events
The component triggers custom events that bubbles up the DOM tree. They can be listened to using the addEventListener() method.
Learn more about events.
| Event | Type | Description |
|---|---|---|
wy-app |
WyAppEventType |
Emitted when the app changes. |
wy-action |
WyActionEventType |
Emitted when an action is performed on an entity. |
wy-preview-open |
WyPreviewOpenEventType |
Emitted when preview is about to be opened. The event may be prevented. |
wy-preview-close |
WyPreviewCloseEventType |
Emitted when preview is closed. |
Slots
The slots can be used to inject elements into the component. All predefined child nodes of the slot will be replaced with the injected content.
| Slot | Description |
|---|---|
actions |
Buttons placed in the toolbar. |
To prevent child nodes from rendering before the component has loaded you can hide them using CSS.
wy-files:not(:defined) {
display: none;
}
Available features
The following features are available for the component. Configure them with a space separated list using the features attribute. Features that are available but disabled by default are indicated by parenthesis (). You can disable any features by prefixing them with negative -.
Learn more about features.
| Feature | Description |
|---|---|
attachments |
Possibility to upload local files. |
cloud_files |
Cloud file picker (Google Drive, Dropbox etc.). |
comment |
Possibility to create new comments. |
comments |
Commentary feed on entities. |
context_data |
Possibility to upload contextual data. |
embeds |
Creating embeds from urls in editor text. |
file_create |
Possibility to create new files. |
file_edit |
Possibility to edit files. |
file_rename |
Possibility to rename files. |
file_upload |
Possibility to upload files. |
follow |
Possibility to follow people. |
(google_meet) |
Google Meet video meetings. |
(meetings) |
General availability for meetings. This can be ignored if using all individual meeting feature flags, i.e. google_meet, microsoft_teams and zoom_meetings. |
mentions |
Possibility to mention other people from the current directory in the editor. |
(microsoft_teams) |
Microsoft Teams video meetings. |
polls |
Possibility to create polls in editor. |
previews |
Previews of files and attachments. |
reactions |
Possibility to add emoji reactions to a message, post or comment. Disabling this feature will enable only the thumbs up reaction. |
(report) |
Possibility to report content or a user for moderation. |
versions |
Show file versions. |
web_dav |
Links to WebDAV functionality for document files. |
(zoom_meetings) |
Zoom video meetings. |