Automattic / isolated-block-editor

Repackages Gutenberg's editor playground as a full-featured multi-instance editor that does not require WordPress.
337 stars 50 forks source link

How to Enable Image upload option from our local gallery #243

Open harshc99 opened 1 year ago

harshc99 commented 1 year ago

hey Can anybody help me how should i upload image from my local machine gallery right now i can upload via Image URL but i want to upload the image from gallery please help me to figure it out and if possible share me the code

here is my code :

import React from "react"; import IsolatedBlockEditor, { EditorLoaded } from "@automattic/isolated-block-editor"; import reducer from "@wordpress/preferences/build-module/store/reducer"; import as selectors from "@wordpress/preferences/build-module/store/selectors"; import as actions from "@wordpress/preferences/build-module/store/actions"; import "./custom.css"; import "@automattic/isolated-block-editor/build-browser/core.css"; import { addFilter } from "@wordpress/hooks"; import { MediaUpload } from "@wordpress/media-utils"; import { mediaUpload } from "@wordpress/editor";

const CustomEditor = () => { const settings = { iso: { moreMenu: false, customStores: [ { name: "core/preferences", config: { reducer: reducer, selectors: selectors, actions: actions, }, }, ], }, };

settings.editor.mediaUpload = mediaUpload;

if (settings?.editor?.hasUploadPermissions) { // Connect the media uploader if it's enabled settings.editor.mediaUpload = mediaUpload; addFilter( "editor.MediaUpload", "blocks-everywhere/media-upload", () => MediaUpload ); } else { settings.editor.mediaUpload = null; }

return (

Editor!

{ console.log("parser: ", parser); console.log("rawHandler: ", rawHandler); }} onSaveContent={(content) => { console.log("onContentSave", content); }} onError={() => { console.log("error"); }} > console.log(container)} />

); };

export default CustomEditor;

image

johngodley commented 1 year ago

The response in https://github.com/Automattic/isolated-block-editor/issues/242 still applies. Take a look at Blocks Everywhere to see how it is doing media uploads.

harshc99 commented 1 year ago

i already check out this Blocks Everywhere editor but i didnt find the proper solution please help me to figure this out and if possible can you share the code also