New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pasteHTML auto add unused <p><br></p> #3370
Comments
Ok, firstly, what you are referring to as "Chrome Console", is not a Console where you can execute commands, it is a source code editor. When you paste things like you are doing, the Summernote API tries to sanitize the input and uses it's best guess, what you are seeing is that guess. |
i'm having the same problem. |
This is an annoying behavior. If I load in HTML content, then simply save it, it wraps the content in |
Latest build available? or you built the project and used the resulting files from the |
In my exam le it was with last build available provided by you in another issue. |
This was the Bootstrap version that I took from the dist/ folder in the archive. |
The workaround for this is to avoid using pasteHTML for loading content. So, when I want to load new content from the server, I first reset and destroy the existing summernote object. Then load the div with the content, then reinitialize a new summernote editor object. This technique works well to leave the content untouched upon loading. |
@Budsy Could you elaborate in code what you did? |
Alright, just implemented the workaround based on Budsy's comment using jquery to insert myHTML (a html string). pasteHTML remains broken. Replaces existing summernote with new replica summernote.
|
I do my content loading with jQuery ajax. Basically, the workaround is to avoid pasteHtml and simply instantiate a new summernote object and load html into the summernote object's content div:
|
pasteHTML works if you set the isNotSplitEdgePoint in the function splitPoint()
But I don't know what else it will break... |
v0.8.14 is released. please use it. |
This one is still a problem in v0.8.14 The |
Still reproducible. |
@easylogic This is still an ongoing issue, I just tried with a curent built from source, and with |
same here, using 0.8.16 |
Same issue for me in 0.8.16 as well. Also tried downgrading to 0.8.14 and using |
Am using 0.8.18 an experiencing same issue. |
v. 0.8.18 Has any progress been made as to a solution for this very problematic bug? |
Out of about 6 HTML Editors, I choose to evaluate summernote first. I slammed straight into this bug. I tried several workarounds. This is the sort of problem that you would expect to see in an alpha release; not something that appears somewhat mature. So I jumped over to https://quilljs.com/ and go it working and integrated in no time at all. |
Hi, I played around with this |
A PR would be most welcome. |
It seems that this topic has been of interest to some people for a long time. Can I post this somewhere so it's easy to find? Please tell me where it is better to do it. |
I am going to assume you don't have git installed or know how to use it. If you want to post here the functions that you changed I can make the changes, test, and do the PR. However, if you do know how to clone the repo, make the changes to the file in |
Yes, I'm new to git, never used it, so it will be better if you do all this stuff. But I want to get familiar with git. Some time ago I started a project that I can't seem to handle alone. It's a micro LMS (learning managment system) with a simple constructor for small courses and master classes. I decided to use summernote in this project, so I want this editor to work the way the end user needs.
|
Oops! It looks like the removal of this |
This has been added to the Projects List, you can check the progress here https://github.com/summernote/summernote/projects/3 |
For me, it worked with just this code:
|
The method suggested by a few including neil-viralmd and Budsy didn't work for me, but I got it to work this way:
|
This issue is also bothering me and the latest release still has this issue. The card in projects has been opened for years. Is there intention to fix it? |
@sigurdne It works, thanks |
Any updates here? The solutions I'm seeing are for replacing the entire div and not related to the original question of pasting html (pasteHTML) at the cursor position. A paragraph and break are still being added. Any help would be greatly appreciated! |
- don't add paragraph if inserting nodes that are not isInline
- update solution to only affect pasteHTML - add doNotInsertPara boolean in insertNode parameter. If true then remove added empty paragraph otherwise only remove the added paragraph if the inserted node is a paragraph (as per original code) - pasteHTML to set doNotInsertPara if the node to be inserted is not an isInline node - revert test change on insertHorizontalRule and insertTable
- update solution to only affect pasteHTML - add doNotInsertPara boolean in insertNode parameter. If true then remove added empty paragraph otherwise only remove the added paragraph if the inserted node is a paragraph (as per original code) - pasteHTML to set doNotInsertPara if the node to be inserted is not an isInline node - revert test change on insertHorizontalRule and insertTable
pasteHTML auto add unused <p><br></p> #3370
Before submitting an issue, please make sure to search for already open issues, and add to that. This way we can track issues more easily. Thank you, and Thanks for using Summernote.
Description of your Issue or Request:
I want to paste html , but it add many
<p><br></p>
.steps to reproduce (Add more if necessary):
go to https://summernote.org/
in chrome console exec
$('#summernote').summernote('pasteHTML', '<p>1</p>');
in code view
<p><br></p><p>1</p><p><br></p>
, why has<p><br></p>
. Is it has solution not add<p><br></p>
when call pasteHTML methodWhat is your Operating System, Browser and Version and Summernote Version you are using:
This can help find and resolve any issues.
Operating System: Windows 10
Browser and Version: Chrome 76.0.3809.100
Summernote Version: 0.8.12
Bootstrap Version or Lite: bootstrap3
screenshot of issue
Add screenshot which shows your issue(if needed).
You can make gif from Recordit.
If you can make the issue using jsfiddle(https://jsfiddle.net/), We can save time to reproduce the problem.
The text was updated successfully, but these errors were encountered: