Giter Site home page Giter Site logo

Comments (11)

kyuwoo-choi avatar kyuwoo-choi commented on May 2, 2024 2

actual markdown text

![image.png](data:image/png;base64,long-base64-encoded-image-blahblah==)

shown on markdown editor

![image.png](shortened-image-mark-element)

by doing

codemirrorDoc.markText(from, to, { repalceWith: shortened-image-mark-element });

it covers only presentation on codemirror, doesn't actually modify codemirror document.
so copy/paste to/from clipboard, switching mode will work smoothly.

html in wysiwyg

<img src="data:image/png;base64,long-base64-encoded-image-blahblah==" />

as codemirror document has never been changed actually.

from tui.editor.

CosmoMyzrailGorynych avatar CosmoMyzrailGorynych commented on May 2, 2024 1

You can't save window blobs to a persistent storage. Either these blobs should be immediately replaced to links to actual files (e.g. after uploading them to an image server or a direct link in desktop apps), or they should be base64-encoded. Otherwise the built-in function to upload images is just pointless.

from tui.editor.

kyuwoo-choi avatar kyuwoo-choi commented on May 2, 2024

@abruzzihraig NICE! πŸŽ‰
That's an amazing idea. I haven't thought about it.
I'm sure it'll make markdown editor much better.

If you(or somebody) are interested in help, check out below code.
I'd like to wait for few days πŸ˜‰
https://github.com/nhnent/tui.editor/blob/4aed6917860f4123c047e42932855a0be7ba6c66/src/js/importManager.js#L126-L136

and some code in importManager.spec.js for test.

Please feel free to make a PR for it. πŸ‘

from tui.editor.

abruzzihraig avatar abruzzihraig commented on May 2, 2024

from tui.editor.

kyuwoo-choi avatar kyuwoo-choi commented on May 2, 2024

I got a tip from @Vnthf
They mark base64 string on codemirror using codemirror markText()

It'll style verbose base64 text to a nice short text.
It only affect it's style, so It doesn't manipulate text data.

from tui.editor.

abruzzihraig avatar abruzzihraig commented on May 2, 2024

from tui.editor.

bora89 avatar bora89 commented on May 2, 2024

Hi guys any news on that? I also noticed a bad performance once image inserted. Which solution should we pick?

from tui.editor.

kyuwoo-choi avatar kyuwoo-choi commented on May 2, 2024

The solution I had posted is already shipped in Dooray editor and It works well.
I'll ask @Vnthf to contribute, or I'll try to adopt some code from there.

from tui.editor.

bora89 avatar bora89 commented on May 2, 2024

Yes, please, that would be great

from tui.editor.

karthiikselvam avatar karthiikselvam commented on May 2, 2024

@kyuwoo-choi This is how i achieved.
1.Grab the base64 data.
2.Make a Ajax call to a web api that converts base64 into image and save it on the server.
3.Return the url as required and pass it to emit function.

$.ajax({ url: 'Home/Index', type: 'POST', dataType: 'text', data: { capture: reader.result }, success: function (data) { editor.importManager.eventManager.emit('command', 'AddImage', { imageUrl: data, altText: 'image' }); }, error: function () { alert('error'); }, }) ;

Webapi Code.

` [HttpPost]
public String Index(String capture)
{
string base64String = capture.Replace("data:image/png;base64,", "");

        byte[] imageBytes = Convert.FromBase64String(base64String);
        MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length);

        // Convert byte[] to Image
        ms.Write(imageBytes, 0, imageBytes.Length);
        Image image = Image.FromStream(ms, true);
        string spath = System.Web.HttpContext.Current.Server.MapPath("~/Upload");
        string path = spath + "/Myimage.jpg";
        image.Save(path, System.Drawing.Imaging.ImageFormat.Jpeg);

        string imagePath = path.Remove(0, 57);
        return imagePath;
    }`

from tui.editor.

lmikoto avatar lmikoto commented on May 2, 2024

actual markdown text

![image.png](data:image/png;base64,long-base64-encoded-image-blahblah==)

shown on markdown editor

![image.png](shortened-image-mark-element)

by doing

codemirrorDoc.markText(from, to, { repalceWith: shortened-image-mark-element });

it covers only presentation on codemirror, doesn't actually modify codemirror document.
so copy/paste to/from clipboard, switching mode will work smoothly.

html in wysiwyg

<img src="data:image/png;base64,long-base64-encoded-image-blahblah==" />

as codemirror document has never been changed actually.

thanks first, but how can i init it,when reopen the doc

from tui.editor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.