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

Setting style attribute on table makes messed up value #15269

Closed
lean-jeremy opened this issue Oct 27, 2023 · 5 comments
Closed

Setting style attribute on table makes messed up value #15269

lean-jeremy opened this issue Oct 27, 2023 · 5 comments
Labels
domain:dx This issue reports a developer experience problem or possible improvement. resolution:resolved This issue was already resolved (e.g. by another ticket). type:bug This issue reports a buggy (incorrect) behavior.

Comments

@lean-jeremy
Copy link

📝 Provide detailed reproduction steps (if any)

I use setAttribute to set both the class and style of a table.

editor.model.change ( writer => {
      writer.setAttribute("class", "test", table)
      writer.setAttribute("style", "background-color:Tomato;", table)
});

✔️ Expected result

<figure class="table test" style="background-color:Tomato;"> 
   <table>
...

❌ Actual result

The actual result has this weird string for the style value. I can see some similarity/pattern ("2:c;3:k;4:g;5:r;6:o;7:u;8:n;9:d;" = ckground?)

<figure class="table test" style="0:b;10:-;11:c;12:o;13:l;14:o;15:r;16::;17:T;18:o;19:m;1:a;20:a;21:t;22:o;23:;;2:c;3:k;4:g;5:r;6:o;7:u;8:n;9:d;"> 
   <table>
...

❓ Possible solution

Perhaps there is something wrong with the style conversion?

editor.conversion.attributeToAttribute({
    model: "style",
    view: modelAttributeValue => {
        key: "style"
        value: modelAttributeValue
    }
})

📃 Other details

  • Browser: Chrome
  • OS: Windows
  • First affected CKEditor version: 40.0.0
  • Installed CKEditor plugins:
    Alignment,
    Autoformat,
    Base64UploadAdapter,
    BlockQuote,
    Bold,
    CloudServices,
    Essentials,
    FindAndReplace,
    FontBackgroundColor,
    FontColor,
    FontFamily,
    FontSize,
    GeneralHtmlSupport,
    Heading,
    HorizontalLine,
    Image,
    ImageCaption,
    ImageStyle,
    ImageToolbar,
    ImageUpload,
    Indent,
    Italic,
    Link,
    List,
    ListProperties,
    MediaEmbed,
    PageBreak,
    Paragraph,
    PasteFromOffice,
    RemoveFormat,
    SelectAll,
    SourceEditing,
    SpecialCharacters,
    SpecialCharactersArrows,
    SpecialCharactersCurrency,
    SpecialCharactersEssentials,
    SpecialCharactersLatin,
    SpecialCharactersMathematical,
    SpecialCharactersText,
    Strikethrough,
    Style,
    Subscript,
    Superscript,
    Table,
    TableCaption,
    TableCellProperties,
    TableColumnResize,
    TableProperties,
    TableToolbar,
    TextTransformation,
    Underline

I appreciate any help 🙏

@lean-jeremy lean-jeremy added the type:bug This issue reports a buggy (incorrect) behavior. label Oct 27, 2023
@Witoso Witoso added the domain:dx This issue reports a developer experience problem or possible improvement. label Oct 30, 2023
@Reinmar

This comment was marked as outdated.

@Reinmar
Copy link
Member

Reinmar commented Nov 3, 2023

Disregard my previous comment. I didn't notice this is a model change.

I think I saw a report regarding trying to keep the entire style of an element in the model as a style attribute. It should certainly be convertible.

@Witoso
Copy link
Member

Witoso commented Nov 3, 2023

Probably you refer to this one @Reinmar: #4517.

@lean-jeremy
Copy link
Author

lean-jeremy commented Nov 3, 2023

@Reinmar @Witoso
Thank you very much for the help 🙏, I've had luck using Reinmar's workaround here.

Now the style is converted properly. This fits my goals, so this ticket can be closed but I'll leave that up to you since #4517 seems to be ongoing.

@Witoso
Copy link
Member

Witoso commented Nov 3, 2023

Glad it helped, please +1 the #4517, and I will close this one :)

@Witoso Witoso closed this as completed Nov 3, 2023
@Witoso Witoso added the resolution:resolved This issue was already resolved (e.g. by another ticket). label Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:dx This issue reports a developer experience problem or possible improvement. resolution:resolved This issue was already resolved (e.g. by another ticket). type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

No branches or pull requests

3 participants