Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

chore(new-channels): copy paste media (#2055)

teof4f800bb6947
diff --git a/js/app/packages/channel/Input/ChannelInput.tsx b/js/app/packages/channel/Input/ChannelInput.tsx
index 438f9e9eae..2b78714ef5 100644
--- a/js/app/packages/channel/Input/ChannelInput.tsx
+++ b/js/app/packages/channel/Input/ChannelInput.tsx
@@ -6,7 +6,11 @@ import { createConfiguredChannelMarkdownEditor } from './configured-markdown-edi
import { createInputAttachmentTracker } from './attachment-tracker';
import { createInputState } from './create-input-state';
import { createMentionsTracker } from './mentions-tracker';
-import { chatRuleset, uploadFile } from '@core/util/upload';
+import {
+ chatRuleset,
+ handleFileFolderDrop,
+ uploadFile,
+} from '@core/util/upload';
import { uploadInputAttachments } from './upload-attachments';
import type {
InputAttachmentTracker,
@@ -98,6 +102,11 @@ export function ChannelInput(props: ChannelInputProps) {
inputState.commands.send();
return true;
},
+ onPasteFilesAndDirs: (files, directories) => {
+ void handleFileFolderDrop(files, directories, (entries) =>
+ inputState.commands.attachFiles(entries.map((entry) => entry.file))
+ );
+ },
});
clearComposer = () => markdownEditor.controls.clear();
diff --git a/js/app/packages/channel/Input/configured-markdown-editor.ts b/js/app/packages/channel/Input/configured-markdown-editor.ts
index 2264f72872..6694b927d4 100644
--- a/js/app/packages/channel/Input/configured-markdown-editor.ts
+++ b/js/app/packages/channel/Input/configured-markdown-editor.ts
@@ -14,6 +14,10 @@ type CreateConfiguredChannelMarkdownEditorOptions = {
onMentionRemove?: (mention: ItemMention) => void;
onChange?: (markdown: string) => void;
onEnter?: (event: KeyboardEvent, markdown: string) => boolean;
+ onPasteFilesAndDirs?: (
+ files: FileSystemFileEntry[],
+ directories: FileSystemDirectoryEntry[]
+ ) => void;
};
export function createConfiguredChannelMarkdownEditor(
@@ -28,6 +32,12 @@ export function createConfiguredChannelMarkdownEditor(
});
}
+ if (options.onPasteFilesAndDirs) {
+ editor.withFilePaste({
+ onPasteFilesAndDirs: options.onPasteFilesAndDirs,
+ });
+ }
+
return editor
.withEmojis()
.withLinks({ floatingMenu: true })
diff --git a/js/app/packages/channel/Input/tests/input-slots.test.tsx b/js/app/packages/channel/Input/tests/input-slots.test.tsx
index 3ee00f555f..c82784596e 100644
--- a/js/app/packages/channel/Input/tests/input-slots.test.tsx
+++ b/js/app/packages/channel/Input/tests/input-slots.test.tsx
@@ -93,6 +93,7 @@ vi.mock(
withLinks: () => builder,
withHistory: () => builder,
withCode: () => builder,
+ withFilePaste: () => builder,
withRestoreFocus: () => builder,
withSelectionData: () => builder,
use: () => builder,