首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ngx-quill无法显示下拉标签

ngx-quill无法显示下拉标签
EN

Stack Overflow用户
提问于 2018-10-19 15:29:42
回答 1查看 554关注 0票数 1

我在quill中创建了一个自定义的下拉菜单。我用羊皮纸

代码语言:javascript
复制
var Parchment = Quill.import('parchment');
    var lineHeightConfig = {
      scope: Parchment.Scope.INLINE,
      whitelist: [
        '1.0',
        '5.0',
        '10.0'
      ]
    };
    var lineHeightClass = new Parchment.Attributor.Class('lineheight', 'ql-line-height', lineHeightConfig);
    var lineHeightStyle = new Parchment.Attributor.Style('lineheight', 'line-height', lineHeightConfig);
    Parchment.register(lineHeightClass);
    Parchment.register(lineHeightStyle);

我在视图中定义了我的编辑器:

代码语言:javascript
复制
<quill-editor #editor >
<div quill-editor-toolbar>
          <!-- Basic buttons -->
          <span class="ql-formats">
            <button class="ql-bold" [title]="'Bold'"></button>
            <button class="ql-italic" [title]="'Italic'"></button>
            <button class="ql-underline" [title]="'Underline'"></button>
          </span>

          <span class="ql-formats">
            <select class="ql-lineheight" [title]="'Line Height'">
              <option selected></option>
              <option value="1.0"></option>
              <option value="5.0"></option>
              <option value="10.0"></option>
            </select>      
          </span>          
    </div>

</quill-editor>

我添加了一些css定义:

代码语言:javascript
复制
.ql-snow .ql-picker.ql-lineheight{
  width: 58px;

}

.ql-snow .ql-picker.ql-lineheight .ql-picker-item[data-value="1.0"]::before {content: "1.0";}
.ql-snow .ql-picker.ql-lineheight .ql-picker-label[data-value='1.0']::before {content: '1.0' !important;}

.ql-snow .ql-picker.ql-lineheight .ql-picker-item[data-value='5.0']::before {content: '5.0';}
.ql-snow .ql-picker.ql-lineheight .ql-picker-label[data-value='5.0']::before {content: '5.0' !important;}

.ql-snow .ql-picker.ql-lineheight .ql-picker-item[data-value='10.0']::before {content: '10.0';}
.ql-snow .ql-picker.ql-lineheight .ql-picker-label[data-value='10.0']::before {content: '10.0' !important;}

新的下拉列表将显示并正常工作,但标签仍为空。

这里是一个stackblitz

EN

回答 1

Stack Overflow用户

发布于 2018-10-19 17:13:36

我不确定这是不是正确的执行方式...我使用了AfterViewInit

代码语言:javascript
复制
  ngAfterViewInit() {
    var lineheightToolbarButton = document.querySelector('.ql-lineheight');
    var lineheightButtonLabel = document.getElementsByClassName('ql-picker-label')[0]
    lineheightButtonLabel.innerHTML = "line height"+lineheightButtonLabel.innerHTML
    var lineheightItems = document.getElementsByClassName('ql-picker-item')

    for (var i = 0; i < lineheightItems.length; i++) {
       lineheightItems[i].innerHTML = lineheightItems[i].getAttribute('data-value')
    }
  }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52887661

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档