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

Toggling Header Styles #11

Closed
KAUSHIKTECHIE opened this issue Aug 25, 2020 · 4 comments
Closed

Toggling Header Styles #11

KAUSHIKTECHIE opened this issue Aug 25, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@KAUSHIKTECHIE
Copy link

How can we make the headers to toggle like the bold,italics meaning how to remove heading when clicked for second time.
The header/size buttons should also be a toggle; doesn’t allow to toggle back to default size.

@markosrx
Copy link

+1

@Andrew-Chen-Wang Andrew-Chen-Wang added the enhancement New feature or request label Mar 12, 2021
@Andrew-Chen-Wang
Copy link
Owner

Andrew-Chen-Wang commented Apr 27, 2021

Hopefully this helps!:

RE.setHeading = function(heading) {
    var sel = document.getSelection().getRangeAt(0).startContainer.parentNode;
    document.execCommand('formatBlock', false, sel.tagName === `H${heading}` ? '<p>' : `<h${heading}>`);
};

Note to self: document.execCommand is deprecated, but there's literally no alternative... we'll have to see what happens after finals.

Other notes for future me The sister repo also doesn't seem to have a solution unfortunately... https://github.com/wasabeef/richeditor-android/blob/ce152b910a59c66863baa68b007ac67e6b9de671/richeditor/src/main/assets/rich_editor.js#L155-L157

@Andrew-Chen-Wang
Copy link
Owner

Any ideas where else I can add this besides the heading?

@Andrew-Chen-Wang Andrew-Chen-Wang changed the title Header Styles Toggling Header Styles Apr 27, 2021
@Andrew-Chen-Wang
Copy link
Owner

Fixed in ed734f6

Resuscitation automation moved this from To do to Done Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

3 participants