[英]Display text in Quill editor
當我嘗試設置包含“ \\ n”的文本時。 它顯示錯誤- 未捕獲的SyntaxError:瀏覽器控制台中出現意外的令牌ILLEGAL
在Java腳本控制台中,我得到如下文本。
<script type="text/javascript">
var toolbarOptions = [
[{ 'font': [] }],
[{ 'size': ['small', false, 'large', 'huge'] }], // custom dropdown
['bold', 'italic', 'underline', 'strike'], // toggled buttons
//['blockquote', 'code-block'],
[{ 'header': 1 }, { 'header': 2 }], // custom button values
[{ 'list': 'ordered'}, { 'list': 'bullet' }],
//[{ 'script': 'sub'}, { 'script': 'super' }], // superscript/subscript
[{ 'indent': '-1'}, { 'indent': '+1' }], // outdent/indent
//[{ 'direction': 'rtl' }], // text direction
[{ 'color': [] }, { 'background': [] }], // dropdown with defaults from theme
[{ 'align': [] }],
['clean'] // remove formatting button
];
var quill = new Quill('#standalone-container', {
modules: {
toolbar: toolbarOptions
},
theme: 'snow'
});
var quill1 = new Quill('#standalone-container1', {
modules: {
toolbar: toolbarOptions
},
theme: 'snow'
});
$(".tacti_note_txt").click(function(){
$("#order_video_01").get(0).pause();
})
$(".tech_note_txt").click(function(){
$("#order_video_02").get(0).pause();
})
$(document).ready(function(){
// my element which display errors
var technical_notes = '<%= raw @review.technical_notes %>';
quill.setText(technical_notes);
var tactical_notes = '<%= @review.tactical_notes.to_s %>';
quill1.setText(tactical_notes);
});
</script>
我想在編輯器中顯示以下文本:
'Rails
and
quill
editor
;
這只是一個猜測,但您可能需要使用轉義字符\\
因此請嘗試"\\\\n"
編輯:
使用"<br/>"
標簽代替"\\n"
ActiveSupport :: JSON.encode(my_string) -為我工作。
由於它用\\ n和\\ t保留了我的字符串,因此羽毛筆編輯器以正確的格式將其顯示為:
'Rails
and
quill
editor
;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.