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

BlockTunes API should remove "undefined" tune data #1683

Open
christoph-kluge opened this issue May 14, 2021 · 0 comments
Open

BlockTunes API should remove "undefined" tune data #1683

christoph-kluge opened this issue May 14, 2021 · 0 comments

Comments

@christoph-kluge
Copy link

@christoph-kluge christoph-kluge commented May 14, 2021

While upgrading from 2.18.1 to 2.21.0 I have discovered that tunes is always set and I could have tunes which are undefined or empty objects depending on their state. This can be easily reproduced with:

export default class DisableBlockTune {
  save() {
    if (this.isDefaultState) {
          return;
    }
    return this.data; // whatever this could be: boolean, string with min length of 1 or an abject with at least one property
  }
}

I think if a block-tune is in "default" state it should not be added to the tunes array. What do you think?

The relevant code-part is here: https://github.com/codex-team/editor.js/pull/1596/files#diff-3a2e107229dbebf0e0b7e00160e7faec0cf71e6baf51872078e031789692c8b5R559

My expectation would be:

tuneData = tune.save();
if (tuneData) {
    tunesData[name] = tuneData;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants