-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathcreate-file.ts
More file actions
29 lines (27 loc) · 1 KB
/
create-file.ts
File metadata and controls
29 lines (27 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { FileActionExtension } from '@osf/shared/tokens/file-action-extensions.token';
import { OnlyOfficeConfig } from './edit-by-onlyoffice';
/**
* Factory function for Create File toolbar extension.
* Adds a "Create File" button that opens OnlyOffice to create a new document.
*
* NOTE: This is a dummy implementation for demonstration purposes.
* The actual OnlyOffice integration requires a running OnlyOffice Document Server.
*/
export function createFileExtensionFactory(config: OnlyOfficeConfig): FileActionExtension[] {
return [
{
id: 'create-file-onlyoffice',
label: 'Create File',
icon: 'fas fa-file-circle-plus',
command: (ctx) => {
const params = new URLSearchParams({
new: 'true',
path: ctx.target.path!,
});
window.open(`${config.editorUrl}?${params}`, '_blank');
},
position: 'end',
visible: (ctx) => ctx.location === 'file-list' && ctx.target.kind === 'folder' && !ctx.isViewOnly && ctx.canWrite,
},
];
}