Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Join RichTextAPI and RichTextContextAPI + Expose anki/RichTextInput #1918

Merged
merged 14 commits into from Jun 20, 2022

Conversation

hgiesel
Copy link
Contributor

@hgiesel hgiesel commented Jun 20, 2022

After this PR, setting custom CSS will be very easy:

// This uses onMount, so it will only affect rich text inputs which are newly mounted.
// To affect already mounted rich text inputs, you need to iterate over `require(...).instances`.
require("anki/RichTextInput").lifecycle.onMount(async ({ customStyles }) => {
    const { addStyleTag } = await customStyles; 
    const { element } = await addStyleTag('myStyles');
    // element is a <style> element, which gives you access to a CSSStyleSheet
    element.sheet.addRule('anki-editable', 'color: red');
});

@hgiesel hgiesel changed the title Stylesexport Join RichTextAPI and RichTextContextAPI + Expose anki/RichTextInput Jun 20, 2022
@dae
Copy link
Member

dae commented Jun 20, 2022

I presume you're happy for this to be included in the next rc?

@hgiesel
Copy link
Contributor Author

hgiesel commented Jun 20, 2022

Yes, that would be nice. This does modify an external API, but I'm pretty quite sure this has not been used by add-ons yet.

I personally want to use the functionality to restore anki__editor__apply__font_color__background_color__custom_class__custom_style. for 2.1.50+.

@dae
Copy link
Member

dae commented Jun 20, 2022

Thanks Henrik!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants