-
-
Save soomtong/6635053 to your computer and use it in GitHub Desktop.
<!-- this version of sample is too old. it's not follow recent version of summernote api --> | |
<!-- should check new apis and examples! sorry I am. --> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<!-- include libries(jQuery, bootstrap, fontawesome) --> | |
<script src="//code.jquery.com/jquery-1.9.1.min.js"></script> | |
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.no-icons.min.css" rel="stylesheet"> | |
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> | |
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css" rel="stylesheet"> | |
<!-- include summernote css/js--> | |
<link href="build/summernote.css" / rel="stylesheet"> | |
<script src="build/summernote.min.js"></script> | |
<body> | |
<div class="summernote container"> | |
<div class="row"> | |
<div class="span12"> | |
<h2>POST DATA</h2> | |
<pre> | |
<?php print_r($_POST); ?> | |
</pre> | |
<pre> | |
<?php echo htmlspecialchars($_POST['content']); ?> | |
</pre> | |
</div> | |
</div> | |
<div class="row"> | |
<form class="span12" id="postForm" action="/summernote.php" method="POST" enctype="multipart/form-data" onsubmit="return postForm()"> | |
<fieldset> | |
<legend>Make Post</legend> | |
<p class="container"> | |
<textarea class="input-block-level" id="summernote" name="content" rows="18"> | |
</textarea> | |
</p> | |
</fieldset> | |
<button type="submit" class="btn btn-primary">Save changes</button> | |
<button type="button" id="cancel" class="btn">Cancel</button> | |
</form> | |
</div> | |
</div> | |
<script type="text/javascript"> | |
$(document).ready(function() { | |
$('#summernote').summernote({ | |
height: "500px" | |
}); | |
}); | |
var postForm = function() { | |
var content = $('textarea[name="content"]').html($('#summernote').code()); | |
} | |
</script> | |
</body> | |
</html> |
@daslicht Not sure if you still need a hand but something like this should do the trick:
file_put_contents('filename.jpg', base64_decode($base64string));
Hi, thanks for the example.
I do have one question though, how do you populate the textarea with database data containing images?
img/etc html tags inside the textarea are currently removed?
Hi, thanks a lot for the PHP example. Nevertheless, I have got the same question regarding to the html tags. Do you have a solution for this problem?
@Marks182 No, not yet. I have asked to HackerWins at summernote/summernote#59 (comment)
If I convert all the strings came from the database table using the htmlspecialchars function, summernote show me the code correctly but it is not good because all the text saved in the database Must be, in my case, as HTML code and not HTML entities.
http://jsfiddle.net/mikunos/f6vY7/12/
Seems to me that some summernote function strips the html code when a html content is within a textarea.
Any solution?
this is great, but when i run this code, I get a textarea inside the summernote area. Is there a way to get rid of this so it looks cleaner?
Thanks
My solution looks like this:
$('.note-editable').on("blur", function(){
var editor = $(this).closest('.note-editor').siblings('textarea.summernote');
editor.html(editor.code());
});
Hello,
I have some problem. I'm trying to insert an image, but I get this error: "GET http://localhost/summernote/[object%20FileList] 404 (Not Found) " Any ideas?
thanks
how can i remove
and
please ?
thanks
Blue boxes, does not resize - driving me insane.
Estimados, buenas tardes,
Por favor como hago para guardar los datos del editor en mi base de datos?
Hi im just wondering if theres a way to stop the html cleanup on save? When i use the code markup it thinks it displays it as if it was processed.
Cheers
La mejor respuesta la dio @markcanals, sito textualmente.
$('.note-editable').on("blur", function(){
var editor = $(this).closest('.note-editor').siblings('textarea.summernote');
editor.html(editor.code());
});
$('.note-editable').on("blur", function(){
$('textarea[name="content"]').html($('#summernote').code());
});
Hi there, I'm trying to get content like you do. but I'm getting this error,
Uncaught TypeError: $(...).code is not a function
using jquery 1.11.2.
use
$(...).summernote("code") instead
same code we have configure it perfectly working on the google chrome but it's not working on the mozilla firefox
can you please help what a problem ?
echo html_entity_decode($aboutcontent->aboutcontent);
use your content inside this to display the content
summernote automatically remove the textarea element and replace it with a new one therefore the existing one with the name
attribute which php can work with will be gone.
Hi, someone can help me? Im using summernote and I have 2 problems.
I have my section "NEWS". When I insert a new, my textarea works perfectly with summernote.
The input of my news (imageNews, title, description, news ) are getted with Jquery Ajax
But when I go to "EDIT NEWS", my textarea is with HTML FORMAT and summernote is not showing up. How can I fix it?
Thanks and sorry for my english
you should have a checking before you want to print out $post['content'] like
if(isset($post['content']
)) {
... print
}
otherwise you will get an error for the first time loading.
For some obvious reason <?php gets commented out.
But how can I bypass this.
I want to allow php tags in summernote
onChange: function(contents, $editable) {
editor.html( editor.summernote('code') );
},
Hi friends, I am not able to get html content value in textarea field when I clicked on edit button. Here I am using summernote editor.
here html code:-
<textarea name="description" id="summernote" cols="30" rows="10" value="{{x.description}}">{{x.description}}</textarea>
here script;-
<script> $('#summernote').summernote({ height: 300 }); </script>
Please help me.
Hello, thank you for the example !
Do I understand that correct that the image is transmitted as base64 inline string ?
How would I upload an image to my server so that I can create a thumbnail and add that to the html content.
Is there already something like this?
Cheers
Marc