1nsp1r3rnzt / chrome-anki-quick-adder

This chrome extension provides the ability to create Anki cards directly from Google Chrome on your Anki Desktop.
https://chrome.google.com/webstore/detail/anki-quick-adder/gpbcbbajoagdgnokieocaplbhkiidmmb
MIT License
182 stars 27 forks source link

Support rich HTML while copying and pasting or adding from chrome menu. #2

Open 1nsp1r3rnzt opened 6 years ago

1nsp1r3rnzt commented 6 years ago

This idea is by brumar Currently, images are not supported and selected text is cleaned while adding from chrome menu.

The goal is to allow user to send image along with text.

Images

If you drag and drop an image, it is base64 encoded by the medium editor and displayed as

concept

Adding images to Anki

Anki stores all images in media folder and these are sent in a separate request using ankiConnect. The sample request is

{
    "action": "storeMediaFile",
    "version": 6,
    "params": {
        "filename": "_hello.txt",
        "data": "SGVsbG8sIHdvcmxkIQ=="
    }
}

The result is standard like any other request to ankiConnect.

{
    "result": null,
    "error": null
}

process

Before Submitting data.

  1. parse body of each field data. sample of 1px black base64 encode image
    <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=">
  2. . if imageFound, Generate a random file name based + extension based on image/gif or png or jpg. submit the request to ankiConnect
    sendRequest
    "params": {
        "filename": "image992.png",
        "data": "SGVsbG8sIHdvcmxkIQ=="
    }

    If successful, replace the image source in the note with the filename else delete the image from note body.

Marviel commented 5 years ago

Hey @1nsp1r3rnzt this project is awesome, thank you! I don't know if you're still planning on tackling this particular feature, but I would find it most helpful -- so much so that I may be willing to put in some effort to make it happen if my skills happen to align.

Did you manage to make any progress on this feature, and is the above still an accurate representation of the body of work you think is required to make it happen?