Activity editor add File block (#3146)

* - added file block

* fised auth useeffect

* - add cmd v for file block

* remove feature flag for attachment upload in blockeditor

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
brendanlaschke
2024-01-05 17:42:50 +01:00
committed by GitHub
parent 81a1666946
commit 9def3d5b57
8 changed files with 245 additions and 25 deletions

View File

@ -0,0 +1,49 @@
import {
BlockNoteEditor,
InlineContentSchema,
StyleSchema,
} from '@blocknote/core';
import { getDefaultReactSlashMenuItems } from '@blocknote/react';
import { IconFile } from '@/ui/display/icon';
import { blockSchema } from './schema';
export const getSlashMenu = (imagesActivated: boolean) => {
let items = [
...getDefaultReactSlashMenuItems(blockSchema),
{
name: 'File',
aliases: ['file', 'folder'],
group: 'Media',
icon: <IconFile size={16} />,
hint: 'Insert a file',
execute: (
editor: BlockNoteEditor<
typeof blockSchema,
InlineContentSchema,
StyleSchema
>,
) => {
editor.insertBlocks(
[
{
type: 'file',
props: {
url: undefined,
},
},
],
editor.getTextCursorPosition().block,
'before',
);
},
},
];
if (!imagesActivated) {
items = items.filter((x) => x.name != 'Image');
}
return items;
};