Closed Vituli closed 1 month ago
@Vituli The way the FontSize
extension works is that if you choose a specific font size, it will set it on the node in Tiptap. If you return to "Default" (or unset), it removes that specific font size and reverts to whatever the default style is for that node. So the default font size is whatever font-size
style is in effect where you're rendering your editor, for the given node (e.g., it's different for a Heading 1 than a Paragraph body node).
mui-tiptap sets the default font in the editor (which is used for non-headings) based on the body1
typography from your MUI theme (font family, font size, font weight, letter spacing):
https://github.com/sjdemartini/mui-tiptap/blob/597a540df2c09e037c5754b197a766d9f3dfff5a/src/styles.ts#L42-L44
So you can override the default font size by applying your own CSS where you're rendering your editor, or by tweaking your MUI theme (e.g. just around the editor like this). There's an example of the former (which is what I'd probably recommend) in the demo in this repo and in the CodeSandbox linked from the README which uses the Box
component from MUI: https://github.com/sjdemartini/mui-tiptap/blob/5495076960f5717f99f820f7ae0f0019896dd5ad/src/demo/Editor.tsx#L127-L140
If you wanted to do something similar for font-size, it could look like:
<Box
sx={{
"&& .ProseMirror": {
fontSize: "20px",
},
}}
>
<RichTextEditor
...
/>
</Box>
Note that I'm using &&
and not just &
to increase specificity and ensure this style takes precedence over the default font styles set in mui-tiptap.
Hope that helps! I'll close this out but let me know if there's further need to reopen.
I’m using the mui-tiptap package along with the FontSize extension and TextStyle to manage font sizes in my editor. However, I’m having trouble overriding the default font size. I tried setting the default size through the FontSize extension configuration.
What’s the correct way to ensure the font size can be overridden by default in mui-tiptap, and how do I set it programmatically or via user selection? Here’s my current code setup: