首页 > 解决方案 > 返回 Time New Roman 字体而不是 quill 编辑器内容字体

问题描述

无论我们在羽毛笔编辑器中粘贴什么格式,它都会自动转换为 Arial,当按下提交按钮以显示编辑器的内容时​​,输出文本将采用 Time New Roman 格式,我该怎么办?请给我一些解决方案。

HTML!

<!DOCTYPE html>
<html>
<title>Text Editor</title>
<head>
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
</head>
<h2>Text Editor</h2>

<div id="editor">
</div>
<button id="click">Submit</button>
<div id ="output"><p  style="display: none;"></p></div>

这是JS代码!

<script>
            var toolbarOptions = [
                ['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

                [{ 'size': ['small', false, 'large', 'huge'] }],  // custom dropdown
                [{ 'header': [1, 2, 3, 4, 5, 6, false] }],
                [ 'link', 'image', 'video', 'formula' ],          // add's image support
                [{ 'color': [] }, { 'background': [] }],          // dropdown with defaults from theme
                [{ 'font': [] }],
                [{ 'align': [] }],

                ['clean']                                         // remove formatting button
            ];

        var quill = new Quill('#editor', {
            modules: {
                toolbar: toolbarOptions
            },

            theme: 'snow'
        });

阿贾克斯!

 $(document).ready(function() {

            $("#output p").hide();
            $("#click").click(function() {
                $("#output p").hide();
                var get_html=quill.container.firstChild.innerHTML;
                console.log(get_html);
                var text1 = quill.getText();
                $.ajax({
                    type: "POST",
                    url: 'save.php',
                    data: {
                        editor_data:get_html
                    },
                    success: function(data)
                    {

                            $("#output p").html(get_html);
                            $("#output p").show();

                    }
                });
            });
        });

当我单击提交按钮时,它总是返回 Time New Roman。我想要什么类型的字体我粘贴到 Quill 编辑器中,它总是在提交单击时返回相同的字体类型。

标签: javascriptajaxquill

解决方案


推荐阅读