ueberdosis / tiptap

The headless rich text editor framework for web artisans.
https://tiptap.dev
MIT License
27.37k stars 2.27k forks source link

Does tiptap has a method to get fontSize value? Or how can I do it? #3520

Closed Daniyar111 closed 1 year ago

Daniyar111 commented 1 year ago

What problem are you facing?

I wrote the extension which setFontSize(value), but I need the function which gives fontSize getFontSize.. I found someone has been already asked this question, but no any correct answer

What’s the solution you would like to see?

Is there any idea to make it like:

this.editor.getActiveByAttribute('textStyle', 'fontSize');

What alternatives did you consider?

I found just this solution -> this.editor.isActive('textStyle', { fontSize: 14 }), but this is not what I need

Anything to add? (optional)

No response

Are you sponsoring us?

svenadlung commented 1 year ago

I'm not sure if it's what you were asking for but to get the font size, if it's set as text style, use editor.getAttributes('textStyle').fontSize.

Please let me know if this is not the answer you are looking for.

ankit-sapkota commented 7 months ago

In my case the, font size is set as a style but when i try to get it by the following query editor?.getAttributes("style") It returns {}.

Any update on this?

aoleksyshyn-spscommerce commented 2 months ago

In my case the, font size is set as a style but when i try to get it by the following query editor?.getAttributes("style") It returns {}.

Any update on this?

The getAttributes method expects a NodeType or MarkType as an argument (https://tiptap.dev/docs/editor/api/editor#getattributes). That's why your query does not work, there is no such NodeType/MarkType as "style". Please check the previous answer, it should work for you.