Skip to content

Fix bugs initializing stretched and pasted tables.#189

Closed
btrewern wants to merge 4 commits into
editor-js:masterfrom
btrewern:master
Closed

Fix bugs initializing stretched and pasted tables.#189
btrewern wants to merge 4 commits into
editor-js:masterfrom
btrewern:master

Conversation

@btrewern

Copy link
Copy Markdown

This fixes the following:

  • Table is not initialised correctly if stretch is selected.
  • Cannot correctly stretch pasted table.

Comment thread src/plugin.js
*/
rendered() {
if (this.block) {
this.block.stretched = !!this.data.stretched;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explain why this line is needed in jsdoc, please

@btrewern btrewern Jul 23, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to fix stretch-related initialization problems for the Editor.js table tool, ensuring that tables render with the correct “stretched” state and that tune changes properly update the block UI/state.

Changes:

  • Add a rendered() lifecycle hook to apply the saved/configured stretched state after mount.
  • Centralize tune UI/state updates in _updateTunes() and trigger block change dispatch on tune toggles.
  • Initialize stretched explicitly in onPaste() data reconstruction.
Comments suppressed due to low confidence (1)

src/plugin.js:254

  • After pasting, the code re-renders by replacing this.table.wrapper with this.render(), which returns a new outer block container. That nests a new block container inside the existing one and also leaks global listeners because the old Table instance isn't destroy()ed before being orphaned. Rebuild only the Table wrapper (destroying the old instance first) and then re-apply the block stretch state so paste doesn't leave the UI/data out of sync.
      withHeadings: firstRowHeading !== null,
      stretched: false,
      content
    };


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/plugin.js
Comment on lines 249 to 253
this.data = {
withHeadings: firstRowHeading !== null,
stretched: false,
content
};

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't paste one table over another so the above seems to be irrelevant.

@btrewern btrewern closed this Jul 24, 2026
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

Successfully merging this pull request may close these issues.

3 participants