mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-27 00:38:12 +08:00
Add a dropdown for resource selection and adopt it in the 'Image' node (#4543)
* Add a dropdown for resource selection and adopt it in the Image node * Route every image upload through a new ResourceUpload handler with desktop support and migrate wired 'Image' node inputs * Show each resource's user count in the resource picker dropdown * Send a picked resource file to the document that requested it, list every non-font resource in the picker, and link sibling message docs
This commit is contained in:
@@ -85,9 +85,13 @@ export async function pasteFile(item: DataTransferItem, editor: EditorWrapper, m
|
||||
const file = item.getAsFile();
|
||||
if (!file) return;
|
||||
|
||||
const extension = file.name.split(".").pop()?.toLowerCase() ?? "";
|
||||
if (file.type.startsWith("image/svg")) {
|
||||
const svg = await file.text();
|
||||
editor.pasteSvg(file.name, svg, mouse?.[0], mouse?.[1], insertParentId, insertIndex);
|
||||
} else if (editor.rasterImageExtensions().includes(extension)) {
|
||||
// Formats the editor decodes itself keep their original bytes instead of being rasterized by the browser
|
||||
editor.pasteImageFile(file.name, await file.bytes(), mouse?.[0], mouse?.[1], insertParentId, insertIndex);
|
||||
} else if (file.type.startsWith("image/")) {
|
||||
const imageData = await extractPixelData(file);
|
||||
editor.pasteImage(file.name, new Uint8Array(imageData.data), imageData.width, imageData.height, mouse?.[0], mouse?.[1], insertParentId, insertIndex);
|
||||
|
||||
Reference in New Issue
Block a user