Skip to content

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

Open
@1nsp1r3rnzt

Description

@1nsp1r3rnzt

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=">
  1. . 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.

Metadata

Metadata

Assignees

Labels

featureNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions