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

Desktop: Fixes #10562: Preserve table customization made on RTE #10927

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

pedr
Copy link
Collaborator

@pedr pedr commented Aug 23, 2024

Fixes #10562

Summary

Tables created on RTE and modified would lose its configuration when the user opened the note on Markdown editor.

Now the values should be kept when the user toggles between the two editors.

To fix this I'm checking if some style properties exist that modify the table:

  • background-color: changes the background color of the cell
  • float, margin-left, margin-right: changes the alignment of the table

I'm ignoring these properties (changing them doesn't preserve the table):

  • width, height: I think if we preserve the HTML table if they are modified we would have to convert even simple tables.
  • border, cell spacing, cell padding: desktop has a default style that overrides the one set in the options, so even if set there is no visual change (should this be changed?)

Testing

I added some tests on app-cli, trying to follow the pattern we already have there.

@laurent22
Copy link
Owner

There's a regression. I've created a simple table:

image

And it converted it to HTML:

image

Comment on lines 190 to 194
// Deskotp app table have, by default, border-collapse style,
// so we need one more to know if the table is modified
const isModifiedRTETable = (tableNode) => {
return tableNode.style.length > 1;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Currently, this could break if the renderer package is updated to apply different default styles to tables. Here are some ideas to prevent regressions:

  • Add a test that verifies that a table rendered with the latest version of the renderer package is converted back to Markdown (with preserveNestedTables: true).
  • Would it be possible to check for the presence of specific style attributes? For example, convert to HTML if ['background-color', 'border-color', 'border'] includes one of the style properties.

Thank you for working on this!

@pedr
Copy link
Collaborator Author

pedr commented Sep 13, 2024

We might want to rethink the way the "resizing check" is implemented:
a396446

The issue is that the only way to know if the column/row was resized is by checking each column and each row and comparing its values.

wasResized(tableNode)
);
}

Copy link
Owner

Choose a reason for hiding this comment

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

We had this function - tableShouldBeHtml() which clearly tells if a table should be html or not. Wasn't it possible to extend this function?

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.

Table properties are not saved in RTE
3 participants