Open dkani opened 9 months ago
@dkani add this in your config TextStyle.extend({ addAttributes() { return { style: { default: this.options.HTMLAttributes.style } } }, }),
@kishanindegene Thank you for the suggestion, it works.
But do you know how this works overall - like it removes the style
attribute from span but allows the color
attribute if you have Color extension , is it because the extension adds a global attribute here?
Yes @dkani the color attribute is retained because of the color extension
@kishanindegene Still I see an issue that it adds an empty span, do you know the reason:
<span style='text-align: center;'>Hello</span>
will be changed to:
<span><span style='text-align: center;'>Hello</span></span>
Also, if I have multiple spans it will merge them into one:
<span>Text 1</span><span>Text 2</span><span>Text 3</span>
will be changed to:
<span><span>Text1Text2Text3</span></span>
我仍然看到一个问题,它增加了一个空的跨度,你知道原因吗:
<span style='text-align: center;'>Hello</span>
将更改为:
<span><span style='text-align: center;'>Hello</span></span>
此外,如果我有多个跨度,它会将它们合并为一个:
<span>Text 1</span><span>Text 2</span><span>Text 3</span>
将更改为:
<span><span>Text1Text2Text3</span></span>
any progress? @dkani
Which packages did you experience the bug in?
TextStyle, TextAlign, Custom
What Tiptap version are you using?
2.1.13
What’s the bug you are facing?
For my requirement I need inline elements instead of block elements to be default so I extended the paragraph extension to return
span
instead ofp
but that's conflicting with theTextStyle
extension, when I try to change the text alignment it looks good but if I save and reload the page it removes the style attribute and instead adds a parentspan
. For example, if I have this saved in DB:It will be converted to:
If I remove the
TextStyle
extension it works fine. I know text-align would have no affect on span but I am addingdisplay: block
and this is just an example.What browser are you using?
Chrome
Code example
https://codesandbox.io/p/sandbox/eloquent-wilson-7n77ys?file=%2Fsrc%2Findex.js
What did you expect to happen?
To not remove the style attribute from span.
Anything to add? (optional)
No response
Did you update your dependencies?
Are you sponsoring us?