简体   繁体   English

在 Quill Rich Editor 中包含标题

[英]Include Headings in Quill Rich Editor

I am working on quill rich editor, i need all headings (h1....h6).我正在使用 quill 丰富的编辑器,我需要所有标题 (h1....h6)。 I have tried different ways but it just shows (h1 and h2) and sometimes it show 3 headings.我尝试了不同的方法,但它只显示(h1 和 h2),有时显示 3 个标题。

Html code: html代码:

<div id="standalone-container">
    <div id="toolbar-container">
        <span class="ql-formats">
          <select class="ql-font"></select>
          <select class="ql-header"></select>
        </span>
        <span class="ql-formats">
          <button class="ql-bold"></button>
          <button class="ql-italic"></button>
          <button class="ql-underline"></button>
          <button class="ql-strike"></button>
        </span>
        <span class="ql-formats">
          <select class="ql-color"></select>
          <select class="ql-background"></select>
        </span>
        <span class="ql-formats">
          <button class="ql-script" value="sub"></button>
          <button class="ql-script" value="super"></button>
        </span>
        <span class="ql-formats">
          <button class="ql-blockquote"></button>
          <button class="ql-code-block"></button>
        </span>
    </div>
    <div id="editor-container" style="height: 400px;"> </div>
    <input type="hidden" value="" name="blog_description" id="blog_description" required="">
</div>

JS Code: JS代码:

<script src="{{url('quill/quill.min.js')}}"></script>
<script>           
    var quill = new Quill('#editor-container', {
        modules: {
          // formula: true,
          // syntax: true,
          toolbar: '#toolbar-container'
        },
        placeholder: 'Compose an epic...',
        theme: 'snow'
      });
 </script>

How can i display all headings in quill editor?如何在羽毛笔编辑器中显示所有标题? I would appreciate if anypne guide me through this.如果有任何人指导我完成此操作,我将不胜感激。 Thanks,谢谢,

Try the following ( copy paste gives new line ):尝试以下操作( 复制粘贴给出新行):

 //#region Fix for copy paste giving new line var Block = Quill.import('blots/block'); Block.tagName = 'div'; Quill.register(Block); //#endregion var quill = new Quill('#editor-container', { modules: { // formula: true, // syntax: true, toolbar: '#toolbar-container' }, placeholder: 'Compose an epic...', theme: 'snow' });
 p { margin-top: 0; margin-bottom: 0; }
 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/quill/1.3.6/quill.snow.min.css" type="text/css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/quill/1.3.6/quill.min.js"></script> <div id="standalone-container"> <div id="toolbar-container"> <span class="ql-formats"> <select class="ql-font"></select> <select class="ql-header"> <option value="1">Heading 1</option> <option value="2">Heading 2</option> <option value="3">Heading 3</option> <option value="4">Heading 4</option> <option value="5">Heading 5</option> <option value="6">Heading 6</option> <option value="">Normal</option> </select> </span> <span class="ql-formats"> <button class="ql-bold"></button> <button class="ql-italic"></button> <button class="ql-underline"></button> <button class="ql-strike"></button> </span> <span class="ql-formats"> <select class="ql-color"></select> <select class="ql-background"></select> </span> <span class="ql-formats"> <button class="ql-script" value="sub"></button> <button class="ql-script" value="super"></button> </span> <span class="ql-formats"> <button class="ql-blockquote"></button> <button class="ql-code-block"></button> </span> </div> <div id="editor-container" style="height: 400px;"> </div> <input type="hidden" value="" name="blog_description" id="blog_description" required=""> </div>

As reported in the documentation, the Normal should be selected , in order to be highlighted.如文档中所述,应selected Normal ,以便突出显示。 Also the value should not be there or the editor will wrap the Blot with an undefined tag.此外,该值不应该存在,否则编辑器将使用undefined标签包装 Blot。

The ql-toolbar class will be added to the toolbar container and Quill attach appropriate handlers to <button> and <select> elements with a class name in the form ql-${format} . ql-toolbar类将被添加到工具栏容器中,Quill 将适当的处理程序附加到<button><select>元素,其类名称为ql-${format} Buttons element may optionally have a custom value attribute. Buttons 元素可以选择有一个自定义value属性。

  <select class="ql-size">
    <option value="small"></option>
    <!-- Note a missing, thus falsy value, is used to reset to default -->
    <option selected></option>
    <option value="large"></option>
    <option value="huge"></option>
  </select>

So applied in the heading case:因此适用于标题情况:

      <select class="ql-header">
        <option value="1">Heading 1</option>
        <option value="2">Heading 2</option>
        <option value="3">Heading 3</option>
        <option value="4">Heading 4</option>
        <option value="5">Heading 5</option>
        <option value="6">Heading 6</option>
        <option selected>Normal</option>
      </select>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 需要在表单中添加 Quill 富文本编辑器 - need to add Quill Rich Text Editor into form Quill JavaScript Rich Text Editor 限制标签 - Quill JavaScript Rich Text Editor restrict tags 使用 Quill 富文本编辑器提交表单值不会转换为 HTML - Submit Form Value with Quill Rich Text Editor does not translate into HTML 如何在 Quill(富文本编辑器)中检测和修剪前导/尾随空格? - How to detect and trim leading/trailing whitespace in Quill (rich text editor)? 如何捕获在富文本编辑器 div 中键入的内容 - Quill 富文本编辑器 - How to capture content typed in a rich text editor div - Quill rich editor Quill 富文本编辑器:如何将文件输入按钮附加到工具栏并嵌入到编辑器 - Quill rich text editor: How to Attach a button for file input to toolbar and embed to the editor 如何通过 quil-image-uploader 模块将图像上传到 Quill 富文本编辑器 - How to upload an image to Quill rich text editor via quil-image-uploader module Quill 富文本编辑器调整图像大小仅适用于 IE,但不适用于 Chrome 或 Edge - Quill rich text editor resize image only works in IE but not in Chrome or Edge 如何结合Quill Rich Text Editor和socket.io来交换Deltas - How to combine Quill Rich Text Editor and socket.io to exchange Deltas 如何使用 Next.js 实现富文本编辑器,例如 Quill 或 Draft.js? - How to implement a rich text editor such as Quill or Draft.js with Next.js?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM