cjwirth / RichEditorView

RichEditorView is a simple, modular, drop-in UIView subclass for Rich Text Editing.
BSD 3-Clause "New" or "Revised" License
1.9k stars 445 forks source link

Add possibility for embedded images #106

Open SupaBasti opened 7 years ago

SupaBasti commented 7 years ago

I extended rich_editor.js by a function to embed images:

RE.embeddImage = function(imagedata, alt) {
    var img = document.createElement('img');
    img.setAttribute("src", "data:image/png;base64," + imagedata);
    img.setAttribute("alt", alt);
    img.setAttribute("docID", "")
    img.onload = RE.updateHeight;
    RE.insertHTML(img.outerHTML);
    RE.insertHTML('<br>');
    RE.callback("input");
};

I need flexibility to add certain attributes, e.g. the docID from the example. Is it possible to include that in official release so that I do not need to make those additions after future updates?

General question about images: how can I succeed in scrolling to bottom after image got inserted? It works for text, but images seem to get scrolled only half way down.

cjwirth commented 7 years ago

No, I'm not going to add your special attributes into an official release.

However -- it is possible to add your own scripts to the RichEditorView, so then you can include your own JS functions and do whatever you need!

how can I succeed in scrolling to bottom after image got inserted? It works for text, but images seem to get scrolled only half way down.

:confused: I don't really know, I've never encountered this, sorry!