有没有人成功使用过Menote的Summernote编辑器?
见http://hackerwins.github.io/summernote/
我在模板中包含了以下div:
<div id="summernote">Hello Summernote</div>
Run Code Online (Sandbox Code Playgroud)
我实例化如下:
Template.sometemplate.rendered = function(){
$('#summernote').summernote({
height: 200, //set editable area's height
focus: true //set focus editable area after Initialize summernote
});
}
Run Code Online (Sandbox Code Playgroud)
控制台中的错误消息:
Resource interpreted as Script but transferred with MIME type text/html:
"http://localhost:3000/summernote.min.js". newcontentlayout:138
Uncaught SyntaxError: Unexpected token < summernote.min.js:1
Exception from Deps afterFlush function function: TypeError: undefined is not a function
at Object.Template.contentLayoutNew.rendered (http://localhost:3000/client/views/contentlayouts/contentlayout_new.js?cb9b5cd577322a6aec6c2ac6819121e7f43b8dc2:6:22)
at http://localhost:3000/packages/ui.js?f0696b7e9407b8f11e5838e7e7820e9b6d7fc92f:426:23
at _assign.flush (http://localhost:3000/packages/deps.js?91f1235baecd83915f7d3a7328526dbba41482be:345:13) debug.js:41
event.returnValue is deprecated. Please use the standard event.preventDefault() instead.
Run Code Online (Sandbox Code Playgroud)
任何想法赞赏?
如何将maxlength应用于Summernote?将maxlength应用于textarea在此处不起作用.
https://github.com/summernote/summernote
$("#textareaid").summernote({
toolbar:[
['style', ['style']],
['font', ['bold', 'italic', 'underline', 'superscript', 'subscript', 'strikethrough', 'clear']],
['fontname', ['fontname']],
['fontsize', ['fontsize']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['height', ['height']],
['table', ['table']],
['insert', ['link', 'picture', 'video', 'hr']],
['view', ['fullscreen', 'codeview']],
['help', ['help']]
],
height: 250,
focus: true
});
$("#summernotediv").code("");
$('.note-help-dialog .row-fluid >p').hide();
$('.note-editable').css('overflow','auto');
$('.note-image-input').prev('h5').remove();
$('.note-image-input').remove();
Run Code Online (Sandbox Code Playgroud) 我想知道如何清除Summernote.这是一个bootstrap Summernote的链接
我尝试使用
$('#MyForm').delay(1000).resetForm(1000);
Run Code Online (Sandbox Code Playgroud)
和
$('#MyForm').trigger("reset");
Run Code Online (Sandbox Code Playgroud)
我也试过了
$('#SummernoteTxt').val('');
Run Code Online (Sandbox Code Playgroud)
前两个代码正确地覆盖了整个表单,但似乎没有清除Summernote编辑器.任何人都可以指出我如何做到这一点.
我正在尝试summernote
在我的应用程序中使用编辑器.我使用高度/ minheight,maxheigh,我想修改编辑器,不允许它可以调整大小.
这是我正在处理的代码:
$('#content').summernote({
height: 400,
minHeight: 400,
maxHeight: 600,
});
Run Code Online (Sandbox Code Playgroud) 我正在使用名为summernote的wysiwyg,我发送给服务器的值,我用HTML Purifier净化它.之后我将它保存到DB(mysql).然后我需要在wysiwyg中显示纯化的html,因此将其写为textarea值(textarea在js中与summernote链接).但它显示转义的html而不是格式化文本.编辑器正常工作,js控制台显示没有错误.
Javascript我用来初始化summernote
$('.summernote').summernote({
lang: 'cs-CZ',
height: 100,
airMode: true,
prettifyHtml: true
});
Run Code Online (Sandbox Code Playgroud)
这是wysiwyg的屏幕截图(在空中模式下,因此未显示工具),控制台检查其值.
所见即所得的拿铁模板:
<textarea name="{$key}" class="summernote form-control" >{$value->value|noescape}</textarea>
Run Code Online (Sandbox Code Playgroud) 我想在我的网站上使用Summernote WYSIWYG编辑器,我正在使用Laravel 5.2,但是,这里有一个问题:当我提交表单时,我会用HTML编写所有代码.因此,我无法逃避我的HTML,因为所有样式都不起作用,但如果我不逃避HTML,我的网站将容易受到XSS的攻击.我该怎么办?
谢谢你的帮助.
在所见即所得的文本编辑器源代码视图中,我有这个简单的html:
<span style="font-family: Moul;" {%if loop.first=='first'%} first="" {%endif%}>Hello Text</span>
Run Code Online (Sandbox Code Playgroud)
但是,当我从源视图切换到可视视图时,wysiwyg将我的html代码更改为:
<span style="font-family: Moul;" {%if="" loop.first="='first'%}" {%endif%}="">Hello Text</span>
Run Code Online (Sandbox Code Playgroud)
但是,我想保留我的html,而不是通过文本编辑器更改.
$('#summernote').summernote({
height: 300
});
Run Code Online (Sandbox Code Playgroud)
body {
padding: 40px;
}
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css">
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.5.0/summernote.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.5.0/summernote.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.5.0/summernote-bs3.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.0.3/css/font-awesome.min.css">
<textarea name="summernote" id="summernote" cols="30" rows="10">
</textarea>
Run Code Online (Sandbox Code Playgroud)
事实上,wysiwyg将单个html属性转换为附加"="和双引号" "
.我测试了<input type="checkbox" checked>
在wysiwyg的源视图中写入,它将被转换属性检查为这样:因为wysiwyg将单个属性视为无效属性,因此它附加等号"="并双引号""输出<input type="checkbox" checked="">
.您可以在上面的代码段中测试它.因此,这是我的jinja2
上面的语法附加,=
并" "
在运行时导致语法错误异常.
我试图使用正则表达式来帮助让wysiwyg改变我的html,如下所示:
codeview = $('summernote').summernote('code');
console.log(codeview);
Regx = /(\<.*\s*\{\%[^}]*\%\}.*\s*\>)/g;
codeview.replace(Regx,'$1'); …
Run Code Online (Sandbox Code Playgroud) 我正在尝试隐秘用Php字格式化的HTML。
我用summernote创建了一个html表单。Summernote允许用户设置文本格式。此文本使用html标记保存到数据库。
接下来使用phpWord,我想将捕获的信息输出到word文档中。请参见下面的代码:
$rational = DB::table('rationals')->where('qualificationheader_id',$qualId)->value('rational');
$wordTest = new \PhpOffice\PhpWord\PhpWord();
$newSection = $wordTest->addSection();
$newSection->getStyle()->setPageNumberingStart(1);
\PhpOffice\PhpWord\Shared\Html::addHtml($newSection,$rational);
$footer = $newSection->addFooter();
$footer->addText($curriculum->curriculum_code.'-'.$curriculum->curriculum_title);
$objectWriter = \PhpOffice\PhpWord\IOFactory::createWriter($wordTest,'Word2007');
try {
$objectWriter->save(storage_path($curriculum->curriculum_code.'-'.$curriculum->curriculum_title.'.docx'));
} catch (Exception $e) {
}
return response()->download(storage_path($curriculum->curriculum_code.'-'.$curriculum->curriculum_title.'.docx'));
Run Code Online (Sandbox Code Playgroud)
保存在数据库中的文本如下所示:
<p class="MsoNormal"><span lang="EN-GB" style="background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;"><span style="font-family: Arial;">The want for this qualification originated from the energy crisis in
South Africa in 2008 together with the fact that no existing qualifications
currently focuses on energy efficiency …
Run Code Online (Sandbox Code Playgroud) fontfamily选项在summernote中不起作用我试过了
$("#divCalltoactiontitle").summernote({
toolbar: [
['font', ['bold', 'italic', 'underline', 'clear']],
['fontsize', ['fontsize']],
],
fontNames: [
'Serif', 'Sans', 'Arial', 'Arial Black', 'Courier',
'Courier New', 'Comic Sans MS', 'Helvetica', 'Impact', 'Lucida Grande',
'Sacramento'
],
} );
Run Code Online (Sandbox Code Playgroud) 我需要帮助上传照片(以及在编辑器中插入的其他数据),但仅当点击提交按钮时。我搜索了论坛,并用谷歌搜索但没有运气:(
我正在使用的代码用于上传图像并将文本保存到数据库,但是当我将其添加到编辑器时,它会立即上传图像。这对我来说不是理想的行为,因为如果用户将图像添加到编辑器然后决定关闭选项卡/关闭浏览器或转到另一个地址,图像将存储在服务器上 - 所以我希望有人帮助我只上传图像当提交按钮被按下时(在那之前,它只会作为预览出现)。这是我的代码:
$('#summernote').summernote({
//placeholder: 'your Message',
height: 200,
toolbar: [
['style', ['style']],
['font', ['bold', 'italic', 'underline', 'clear']],
['fontname', ['fontname']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['height', ['height']],
['table', ['table']],
['insert', ['link', 'picture', 'hr']],
['view', ['fullscreen', 'codeview', 'help']],
['save-button', ['save']]
],
callbacks : {
onImageUpload: function(image) {
uploadImage(image[0]);
}
}
});
function uploadImage(image) {
var slika = new FormData();
slika.append("image",image);
$.ajax ({
data: slika,
type: "POST",
url: "url - upload image script",// this file uploads the picture and
// …
Run Code Online (Sandbox Code Playgroud) summernote ×10
jquery ×4
javascript ×3
html ×2
laravel ×2
php ×2
ajax ×1
htmlpurifier ×1
jinja2 ×1
meteor ×1
nette ×1
phpword ×1
wysiwyg ×1