stckme / tiptapy

Library that generates HTML output from JSON export of tiptap editor
MIT License
40 stars 12 forks source link

Others Attrs and Style #79

Open linspw opened 1 year ago

linspw commented 1 year ago

Hello everything is fine? Very cool library!

Is there any option to pass all the attributes that are in the node to the attr of the html or style?

For example:

Transforming:

  {
      "type": "paragraph",
      "content": [{"type": "text", "text": "Hello"}],
      "attrs": {"textAlign": "left"},
  }

To:

<p style="text-align: left">Hello</p>

I thank the attention

rajatsingla commented 3 months ago

Hello,

how about below?

Transforming:

  {
      "type": "paragraph",
      "content": [{"type": "text", "text": "Hello"}],
      "attrs": {"style": {"textAlign": "left"}},
  }

To:

<p style="text-align: left">Hello</p>

Side note: For style change you might wanna use mark instead of attrs, in this particular case maybe a new mark can be introduced called left or align_left.