Can I preset a default font style for newly entered text?
Example: I expect the newly entered text to be <p><span style="font-size: 14px; font-family: Microsoft YaHei;">some text</span></p>, not <p>some text</p>.
You probably need to make a custom blot for that.
The easier way is to override or customize the quill stylesheet file and set the font-family for the .ql-editor p selector.
Even better you can set the font-family properties on the .ql-container.
You probably need to make a custom blot for that.
The easier way is to override or customize the quill stylesheet file and set the font-family for the
.ql-editor pselector. Even better you can set the font-family properties on the.ql-container.
I expect to be able to generate inline styles because I need to be compatible with Outlook.
Ah, I see. I've only been tinkering with Quill for the past 2 weeks, so I'm not really sure how to achieve that. Making your own custom blot seems like the only way.
Another way I can think of for your use-case is injecting the <span> with it's style using javascript when the user is done writing with Quill.
@ClarkWong hi, did you find a solution for this? I ran into same issue
👍
@ClarkWong @dmitrybndar Any update on this?
@gagan-lokesh oh, it was 4 month ago :) I found then some workaround (for my case). Just looked at my code and grab this part from it, maybe it helps you.
const BlockPrototype = Quill.import("blots/block");
class CustomBlock extends BlockPrototype {
constructor(domNode, value) {
super(domNode, value);
this.format("size", "18px");
}
static tagName = "P";
format(name, value) {
if (name === "size") {
this.domNode.style.fontSize = value;
} else {
super.format(name, value);
}
}
}
Quill.register(CustomBlock, true);
Works! Thanks so much @dmitrybndar :smile:
Simply change change CSS you want in this class
.ql-editor {
padding: 12px 0;
font-size: 18px;
}
Simply change change CSS you want in this class
.ql-editor { padding: 12px 0; font-size: 18px; }
this actually works at least for me but i believe its better to add a collection of fonts for use rather than just setting one check this https://stackoverflow.com/questions/68302512/how-to-remove-or-change-the-default-font-in-quill-js
Quill 2.0 has been released (announcement post) with many changes and fixes. If this is still an issue please create a new issue after reviewing our updated Contributing guide :pray: