Html Summernote onkeyup函数替换特殊字符
我需要在summernote文本区域中键入或粘贴到其他内容时替换一些特殊字符 这在onkeypup功能中不起作用:Html Summernote onkeyup函数替换特殊字符,html,node.js,summernote,Html,Node.js,Summernote,我需要在summernote文本区域中键入或粘贴到其他内容时替换一些特殊字符 这在onkeypup功能中不起作用: <script> $(document).ready(function() { $('#content').summernote({ placeholder: 'Treść...', tabsize: 2, //height: 300,
<script>
$(document).ready(function() {
$('#content').summernote({
placeholder: 'Treść...',
tabsize: 2,
//height: 300,
lang: 'pl-PL', // default: 'en-US'
toolbar: [
['style', ['style']],
['font', ['bold', 'underline', 'clear']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']],
['insert', ['link', 'picture']],
['view', ['fullscreen', 'codeview']]
],
callbacks: {
onKeyup: function(e) {
setTimeout(function(){
// $("#result").html($('.description').val());
var y = $('#content').summernote("code");
console.log("y: ",y);
var x = y.replaceAll(/[^]/g, '');
console.log("x: ",x);
},200);
},
onPaste: function (e) {
var bufferText = ((e.originalEvent || e).clipboardData || window.clipboardData).getData('Text');
e.preventDefault();
document.execCommand('insertText', false, bufferText);
}
}
});
});
</script>
$(文档).ready(函数(){
$(“#内容”)。请注意({
占位符:“Treść…”,
tabsize:2,
//身高:300,
lang:'pl',//默认值:'en US'
工具栏:[
['style',['style']],
['font',['bold','下划线','清除']],
['color',['color']],
[para',[ul',ol',段落]],
['table',['table']],
[“插入”,“链接”,“图片”],
['view'、['fullscreen'、'codeview']]
],
回调:{
onKeyup:函数(e){
setTimeout(函数(){
//$(“#result”).html($('.description').val());
变量y=$(“#内容”).summernote(“代码”);
console.log(“y:,y”);
var x=y.replaceAll(/[^]/g',);
console.log(“x:,x”);
},200);
},
onPaste:函数(e){
var bufferText=((e.originalEvent | | e).clipboardData | | window.clipboardData.getData('Text');
e、 预防默认值();
document.execCommand('insertText',false,bufferText);
}
}
});
});
html:
我也试过这样做:
onKeyup: function(e) {
$('#summernote').code().replace(/(<([^]+)>);/ig, '');
},
onKeyup:函数(e){
$(“#summernote”).code().replace(/();/ig,”);
},
如何将任何^
更改为无、空、空
编辑:
也许小提琴会有帮助
edit2:fiddle更新,仅替换不起作用的附加
。此。
在$(“#summernote”)。this.value=
看起来可疑我希望this.value=this.value.replaceAll(“^”,“”)代码>它在没有summernote的简单输入中工作:)也给summernote一毫秒不要使用setTimeout
,.replaceAll(“^”和“)代码>
onKeyup: function(e) {
$('#summernote').code().replace(/(<([^]+)>);/ig, '');
},