Skip to content
This repository has been archived by the owner on May 24, 2021. It is now read-only.

Handle image deletion #189

Open
ittaboba opened this issue Nov 25, 2019 · 2 comments
Open

Handle image deletion #189

ittaboba opened this issue Nov 25, 2019 · 2 comments

Comments

@ittaboba
Copy link

Hi @michelson thank you for this amazing library!!
I am succesfully uploading images using ImageBlockConfig and getting back the url.
However, it's not clear to me how to detect the image deletion from the editor in order to remove it from the storage.
Thank you very much
Lorenzo

@michelson
Copy link
Owner

michelson commented Nov 25, 2019 via email

@ittaboba
Copy link
Author

Hi Miguel, thank you for your answer.

I am trying to reproduce the behavior inside my code:

const getCurrentBlock = (editorState: any) => {
        const selectionState = editorState.getSelection();
        const contentState = editorState.getCurrentContent();
        const block = contentState.getBlockForKey(selectionState.getStartKey());
        return block;
    };

    return(
        <div>
            <Dante
                content={content}
                onChange={(editor: any) => {
                    let block = getCurrentBlock(editor.getEditorState())
                    let config_block = editor.getDataBlock(block)
                }} 
            />
        </div>
    )

Right now I get the block but then config_block is undefined
Do you think this is the right approach? What I am missing?

Thank you

Lorenzo

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants