diff options
| author | codetorso <[email protected]> | 2024-07-25 21:51:58 +0530 |
|---|---|---|
| committer | codetorso <[email protected]> | 2024-07-25 21:51:58 +0530 |
| commit | 3c91c188a4667e15486e18c909f615f8eebaf8bb (patch) | |
| tree | 6ea8b830dacb402ca91dd8d0e19cdd1230bbb6a1 /apps/web/lib | |
| parent | let's go boys!! canvas (diff) | |
| download | supermemory-3c91c188a4667e15486e18c909f615f8eebaf8bb.tar.xz supermemory-3c91c188a4667e15486e18c909f615f8eebaf8bb.zip | |
fix error on drop
Diffstat (limited to 'apps/web/lib')
| -rw-r--r-- | apps/web/lib/ExternalDroppedContent.ts | 58 |
1 files changed, 22 insertions, 36 deletions
diff --git a/apps/web/lib/ExternalDroppedContent.ts b/apps/web/lib/ExternalDroppedContent.ts index 75ca8b6f..c1f35b36 100644 --- a/apps/web/lib/ExternalDroppedContent.ts +++ b/apps/web/lib/ExternalDroppedContent.ts @@ -160,10 +160,11 @@ function formatTextToRatio(text: string): { height: number; width: number } { } type CardData = { - type: string; title: string; + type: string; + source: string; content: string; - url: string; + numChunks: string; }; type DroppedData = CardData | string | { imageUrl: string }; @@ -183,47 +184,32 @@ export function handleExternalDroppedContent({ const processedURL = processURL(droppedData); if (processedURL) { createEmbedsFromUrl({ editor, url: processedURL }); - return; } else { - const { height, width } = formatTextToRatio(droppedData); - editor.createShape({ - type: "Textcard", - x: position.x - width / 2, - y: position.y - height / 2, - props: { - content: "", - extrainfo: droppedData, - type: "note", - w: 300, - h: 200, - }, - }); + createTextCard(editor, position, droppedData, "String Content"); } } else if ("imageUrl" in droppedData) { + // Handle image URL (implementation not provided in original code) } else { - const { content, title, url, type } = droppedData; - const processedURL = processURL(url); - if (processedURL) { - createEmbedsFromUrl({ editor, url: processedURL }); - return; - } - const { height, width } = formatTextToRatio(content); - - editor.createShape({ - type: "Textcard", - x: position.x - 250, - y: position.y - 150, - props: { - type, - content: title, - extrainfo: content, - w: height, - h: width, - }, - }); + const { content, title, source, type } = droppedData; + const processedURL = processURL(source); + // if (processedURL) { + // createEmbedsFromUrl({ editor, url: processedURL }); + // } else { + // } + createTextCard(editor, position, title, type, content); } } +function createTextCard(editor: Editor, position: { x: number; y: number }, content: string, type: string, extraInfo: string = "") { + const { height, width } = formatTextToRatio(content); + editor.createShape({ + type: "Textcard", + x: position.x - width / 2, + y: position.y - height / 2, + props: { content, type, extrainfo: extraInfo, h: 200, w: 400 }, + }); +} + function centerSelectionAroundPoint(editor: Editor, position: VecLike) { // Re-position shapes so that the center of the group is at the provided point const viewportPageBounds = editor.getViewportPageBounds(); |