BlueGreenMagick / Edit-Field-During-Review-Cloze

Code for the Anki addon Edit Field During Review Cloze
https://ankiweb.net/shared/info/385888438
Other
18 stars 3 forks source link

New formatting; Headings and Subheadings (h1, h2, h3...) #122

Open DerIshmaelite opened 3 months ago

DerIshmaelite commented 3 months ago

A nice addition to the already present set of formats inside the addon would be the ability to make turn a highlighted text into headings (H1, H2...), each being gradually smaller in size.

BlueGreenMagick commented 3 months ago

It's not documented, but you can already do it by editing the add-on config raw JSON.

  1. Open the add-on config, click 'Advanced'.

  2. Find the following line:

    "special_formatting": {
  3. Copy paste the following lines to just below that line, to add shortcut for 'h1'.

        "header1": {
            "arg": {
                "type": "text",
                "value": "h1"
            },
            "command": "formatBlock",
            "enabled": true,
            "shortcut": "Ctrl+Shift+1"
        },

It will result in the JSON looking like this:

...
    "special_formatting": {
        "header1": {
            "arg": {
                "type": "text",
                "value": "h1"
            },
            "command": "formatBlock",
            "enabled": true,
            "shortcut": "Ctrl+Shift+1"
        },
        "fontcolor": {
            "arg": {
                "type": "color",
                "value": "#00f"
            },
            "command": "foreColor",
            "enabled": true,
            "shortcut": "F7"
        },
...

You can change the lines to 'header2' and 'h2', etc. and copy paste, to add shortcuts for other headers.

DerIshmaelite commented 3 months ago

Thank you!!! Is there also a shortcut to format back to normal. The remove format shortcut doesn't work...

BlueGreenMagick commented 3 months ago

If Ctrl+R doesn't work, I don't think there is a simple way to do it.

If you are experienced with Javascript, you could write some code to achieve it.

https://github.com/BlueGreenMagick/Edit-Field-During-Review-Cloze/blob/master/FAQ.md#how-to-add-a-custom-shortcut-action