Comments (11)
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.
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.
@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.
from tui.editor.
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.
from tui.editor.
Hi guys any news on that? I also noticed a bad performance once image inserted. Which solution should we pick?
from tui.editor.
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.
Yes, please, that would be great
from tui.editor.
@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.
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)
- Add URL validation for image upload by URL input HOT 1
- μλν° κ°μ΄λ° μ λ ¬ λ¬Έμ
- Drag & Drop and Paste of Images renders as Base64 without addImageBlobHook in Firefox HOT 1
- Optionally Support rendered inline math using $$.
- Numbered List Issues
- Make base64 encoded images collapsible
- Select in a cell cause error : Uncaught TypeError: Class constructor Selection cannot be invoked without 'new'
- Any fork of this project? HOT 1
- Inserted Image via URL does not show/load on WYSIWYG only editor
- WYSIWYG mode no character escaping
- Support React@18
- enhance the initial table redring
- customHTMLRenderer behavior in Markdown vs WYSIWYG mode
- ν λ΄λΆ ν μ€νΈ μμ μ ν μ, μ 체 μΈμ μ΄μ
- getHTML() Method in Toast-UI/Editor Returns Unexpected Value When Editor is Empty
- Multiline XML opening tag is not escaped
- μλν°μμ μ¬μ§ λλκ·Έ μ€ λλ λ§κΈ°.
- Specific HTML input breaks WYSIWYG usability
- Does Toast-UI Editor supports dark theme? HOT 1
- [SyntaxError: Unexpected token] on toastui-editor.css
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tui.editor.