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

SHIFT + ENTER to make new line? #103

Open
intaek-h opened this issue Oct 20, 2022 · 8 comments
Open

SHIFT + ENTER to make new line? #103

intaek-h opened this issue Oct 20, 2022 · 8 comments

Comments

@intaek-h
Copy link

intaek-h commented Oct 20, 2022

Inside a table cell, I press shift + enter to create a new line. It displays fine. However in JSON, the new line is not saved, therefore not printed.
Any ideas on keeping the style in JSON?
스크린샷 2022-10-20 오후 5 42 08
스크린샷 2022-10-20 오후 5 42 19

@KevinBeckers
Copy link

I'm running into the same problem.

@KevinBeckers
Copy link

Looks like the issue is caused by cell.textContent.trim()); at:

const isEmptyRow = cells.every(cell => !cell.textContent.trim());

@intaek-h
Copy link
Author

intaek-h commented Oct 21, 2022

@KevinBeckers May I ask why your merge request was blocked? And did you solve the issue by removing trim()?

+edit) Oh, your pr isn't reviewed yet ;)

@KevinBeckers
Copy link

After more research, the problem seems to vary by browser. Different browsers have different behavior in a 'contentEditable DIV'. Safari for example, which places a new div. Chrome adds a new line and Firefox ads a

@evanshabsove
Copy link

Just adding that I am having the same problem. It would be great if this could be supported somehow! Even with these browsers handling everything differently

@Thimows
Copy link

Thimows commented Jan 25, 2023

I have the same issue. Would be great if we could find a solution. @KevinBeckers Did you by any chance find something that worked?

@manh-gntvn
Copy link

manh-gntvn commented Feb 28, 2023

@intaek-h @KevinBeckers @evanshabsove @Thimows

The reason is that br is not an allowed inline tag, which will then be removed when the Editor calls it a sanitization function.

Just extend this plugin, then add a sanitization configuration, like this:

import Table from '@editorjs/table'

export default class TablePlugin extends Table {
  static get sanitize(){
    return {
      br: {},
      // ... other configs
    }
  }
}

@abidfs
Copy link

abidfs commented Feb 7, 2024

Thanks @manh-gntvn the suggested approach works
I am using following code to support bold, italic and links alongside newlines in table cells

import Table from '@editorjs/table'

export default class TablePlugin extends Table {
  static get sanitize() {
    return {
      b: true,
      a: {
        href: true,
      },
      i: true,
      br: {},
    };
  }
}

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