Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot assign to read only property 'caption' #219

Open
rocketana opened this issue Apr 14, 2023 · 5 comments
Open

Cannot assign to read only property 'caption' #219

rocketana opened this issue Apr 14, 2023 · 5 comments

Comments

@rocketana
Copy link

rocketana commented Apr 14, 2023

A copy of the closed for any weird reason issue #179. The problem is still here.

The following error occurs after image uploading:
Saving failed due to the Error TypeError: Cannot assign to read only property 'caption' of object '#<Object>'

As soon as any image added to the editor, the whole saving process is broken, no changed to other blocks can be saved due to the error.

The error comes from here:

{
    key: "save",
    value: function() {
        var e = this.ui.nodes.caption;
        return this._data.caption = e.innerHTML,  <--------- error
        this.data
    }
}

The problem may come from here :

# src/ui.js
caption: make('div', [this.CSS.input, this.CSS.caption], {
   contentEditable: !this.readOnly,
}),

But setting readOnly: false in the EditorJS config or the tool's config doesn't change anything.

Also, I see that the caption node is rendered correctly in the DOM:

<div class="cdx-input image-tool__caption" contenteditable="true" data-placeholder=""></div>

An ugly and absolutely not recommended solution that I used for now to make the editor work again - I changed the caption assignment in bundle. js. This way saving of the caption works as expected as well as all other data.

{
    key: "save",
    value: function() {
        var e = this.ui.nodes.caption;
        this._data = {...this._data, caption: e.innerHTML};
        return this._data, this.data
    }
}

Hopefully, I'll find another solution later as the the author of this tool seemed abandoned the project and is not going to fix issues.

@yaroslavx
Copy link

@rocketana have you found a solution for that problem? i have the same, and would be happy to fix it)

@Verickg
Copy link

Verickg commented May 8, 2024

Same problem with image caption, attached title and embed, any alternative?

@Ajith-M-001
Copy link

i have the same propblem

@Rodina2016
Copy link

I have the same propblem

@dependentmadani
Copy link
Contributor

Hi,

Could you please provide detailed reproduction steps for this issue? Specifically, I would like to know:
How you are adding the image to the editor.
Any specific configurations or settings you are using.
Any additional steps or actions taken before encountering the error.
Thank you!
@Rodina2016 @Ajith-M-001

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

No branches or pull requests

6 participants