nnhubbard / ZSSRichTextEditor

A beautiful rich text WYSIWYG editor for iOS with a syntax highlighted source view
MIT License
3.78k stars 584 forks source link

Image is not displayed #272

Open m-calapatapu opened 4 years ago

m-calapatapu commented 4 years ago

Image is not displayed when the html string contains the image url with alt when loading into editorView. but when I to manually insert image with URL and Alt from tool bar able to see the image. Please give a solution on this ASAP

m-calapatapu commented 4 years ago

Can anyone please respond why? WkWebview is not loading below image img alt="Sample" src="https://docint0.blob.core.windows.net/publicfilescontainer02/" width="582" style="padding-bottom: 0px; vertical-align: bottom; border: 0px; outline: none; text-decoration: none; display: inline;" class="gmail-m_4922265757032371696mcnImage

yegail commented 4 years ago

https://docint0.blob.core.windows.net/publicfilescontainer02/ this image not accessible

m-calapatapu commented 4 years ago

https://docint0.blob.core.windows.net/publicfilescontainer02/ this image not accessible

For security reason I edited the URL. not to access. you can use any image URL in that place. The real image works when used in browser. Please give some solution on this issue

nnhubbard commented 4 years ago

If you toggle the source view, it seems iOS is inserting smart quotes. Not sure why, don't have a chance to investigate.

m-calapatapu commented 4 years ago

Can you please give me a solution to handle it. As displaying the image is the major part in my App.

m-calapatapu commented 4 years ago

I am able to display the image by changing the code of method removeQuotesFromHTML in ZSSRichTextEditor.m as below -(NSString )removeQuotesFromHTML:(NSString )html { html = [html stringByReplacingOccurrencesOfString:@"\"" withString:@"\\""]; html = [html stringByReplacingOccurrencesOfString:@"“" withString:@""]; html = [html stringByReplacingOccurrencesOfString:@"”" withString:@""]; html = [html stringByReplacingOccurrencesOfString:@"\r" withString:@"\r"]; html = [html stringByReplacingOccurrencesOfString:@"\n" withString:@"\n"]; return html; } Don't know whether the fix is correct or not.

AriqAhmad commented 4 years ago

I used the following and it's working for me:

 -(NSString *)removeQuotesFromHTML:(NSString *)html {
    html = [html stringByReplacingOccurrencesOfString:@"\'" withString:@"\\\'"];
    html = [html stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""];
    html = [html stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"];
    html = [html stringByReplacingOccurrencesOfString:@"\r" withString:@""];
    return html;
}