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

Jodit doesn't keep table borders #295

Open
elshobokshy opened this issue Nov 26, 2019 · 13 comments
Open

Jodit doesn't keep table borders #295

elshobokshy opened this issue Nov 26, 2019 · 13 comments

Comments

@elshobokshy
Copy link

What jodit looks like :

Jodit

The result I'm getting :

Result

Any idea how to force jodit to give me the exact same HTML I visually see with the borders and all ?

@elshobokshy
Copy link
Author

Another example is this :
Sans titre
With this result :
Sans titre

@xdan
Copy link
Owner

xdan commented Nov 26, 2019

@elshobokshy You need append some styles what you use in your site in to editor

@elshobokshy
Copy link
Author

elshobokshy commented Nov 26, 2019

@xdan isn't there a way to be able to get the exact same look without writing any custom styles ? My use of Jodit is to have the client create a table and get the exact same look. Isn't there a hacky way to get the exact same look? Like how to keep the borders and the cells width/height?

@elshobokshy
Copy link
Author

@xdan otherwise, how to add a class to every table created using jodit automatically ? Something like class="jodit-table"

@Chiragjain55551
Copy link

You get a string from jodit editor.
let it be data
so you can manipulate data in onChange function of jodit editor as:

  if (data.includes("<td>")) {
    data = data.replaceAll("<td>", `<td style="border:1px solid black">`);
  }

and then using
dangerouslySetInnerHTML={{
__html: DOMPurify.sanitize(data),
}}

you will get borders

@syedadil010
Copy link

Hey @elshobokshy,
How did you address this issue?

@elshobokshy
Copy link
Author

@syedadil010 I gave up and used tinymce v5 as it was easier :) That's why I closed the issue, I'm reopening if @xdan wants to fix this

@elshobokshy elshobokshy reopened this Jul 7, 2021
@NanTapia
Copy link

NanTapia commented Jul 10, 2021

Based on the previos comment, I solved it like this:

if (content.includes("<table>")){
content = content.replaceAll("<table>", '"<table border="1" style="border-collapse:collapse;"');
}

@yeasin-hossain
Copy link

I just added this line in CSS for jodit-react table.
it will work fine.
td {
border:solid 1px;
}

@MrArun005
Copy link

Another example is this : Sans titre With this result : Sans titre

Table itself is not adding for me and im getting node element must be in the editor it is saying. How to resolve it

@ckc2715
Copy link

ckc2715 commented Feb 16, 2024

The generated html do not have border style, i fixed it by adding style to the defaultOptions when creating attributes.

Jodit.defaultOptions.createAttributes = { table: { style: 'border:1px solid;border-collapse:collapse;width: 100%;', }, tr: { style: ' border: 1px solid;', }, td: { style: ' border: 1px solid;', }, };

@CH-Chonsu
Copy link

image
as stated from @ckc2715 I added the createAttribute option into the config using jodit-react
const config = { theme: theme, createAttributes: { table: { style: 'border:1px solid #C5C6C8FF;border-collapse:collapse;width: 100%;', }, tr: { style: ' border: 1px solid #C5C6C8FF;', }, td: { style: ' border: 1px solid #C5C6C8FF;'}}, ...}
this does indeed fix it. thanks @ckc2715
cheers 😸

@serkaneksi78
Copy link

table border must be a attribute to be applied for each cell. otherwise border-color will be useless without border.

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

10 participants