Support » Plugin: Gutenberg » WordPress Gutenberg block plugin error

  • shahidsstute

    (@shahidsstute)


    Hi,
    I have developed a plugin that allows user to upload a custom file, read its content and paste them on the new post page. Now after Gutenberg, I’m facing issues while updating the plugin. Here are the details:

    I have created the following elements in Edit section:

    var content = props.attributes;
    function onChangeContent( newContent ) {
    props.setAttributes( { content: newContent } );

    }

    return (
    <div className={props.className}>
    <div className=”my-content”>
    Content Shown here
    </div>
    <button
    className=”add-more-file”
    onClick={() => {function to upload the file…}

    The plugin is able to import the file and show in the div above.
    The save function is also working but I’m unable to load back the contents to by block on edit post page.
    Here is the save function:

    save: function( props ) {
    return el( RichText.Content, {
    tagName: ‘div’, value: props.attributes.content,
    } );
    }

    The text is saved in the attribute named content. Please guide me as to what I’m doing wrong here.

Viewing 2 replies - 1 through 2 (of 2 total)
  • shahidsstute

    (@shahidsstute)

    can anyone reply to my question please?

    Even if you have questions, please post to me. I really need a solution to this issue ASAP.

    Hi, it sounds the editor’s live preview is showing the correct contents before you save, and then the post_content is set correctly, so that the front end works, but when you save and refresh the editor, the content is no longer shown correctly in the live preview. Is that correct?

    Can you show how onChangeContent() is being called? It’d help to have a link to the full source code, or a minimal reproducible example. It’s difficult to read source code without any formatting, and difficult to understand without the surrounding context.

    • This reply was modified 2 weeks, 6 days ago by  Ian Dunn.
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.