【问题标题】:PrimeNG Quill editor max lengthPrimeNG Quill 编辑器最大长度
【发布时间】:2017-03-29 08:28:03
【问题描述】:

我正在尝试为编辑器实现最大长度。我的代码是这样的:

this.editorTextChange$$ = this.quillEditor.onTextChange.asObservable()
  .subscribe((ev) => {
    const limit = this.maxLength;
    // last char is \n, so don't count it
    if (ev.textValue.length > limit) {
      this.quillEditor.quill.deleteText(limit, ev.textValue.length);
    }
    // last char is \n, so don't count it
    this.currentLength = this.quillEditor.quill.getLength() - 1;
  });
<p-editor
    #quill
    [(ngModel)] = htmlValue>
    <p-header>
      <span>
        <button title="Bold" class = "ql-bold"></button>
        <button title="Italic" class = "ql-italic"></button>
        <button title="Underline" class = "ql-underline"></button>
        <button title="Link" class = "ql-link"></button>
      </span>
    </p-header>
  </p-editor>

问题是编辑器在视图上得到更新,但模型保持不变。

如何更新?

谢谢!

【问题讨论】:

  • 我们最终决定在更新产品规格后该功能将无用,但我仍然认为这对于想要从控制器更新文本的人来说可能很重要

标签: angular primeng quill


【解决方案1】:

this.quillEditor.quill.deleteText(limit, ev.textValue.length);之后, 添加以下代码

this.quillEditor.onModelChange(this.quillEditor.root.innerHTML); this.quillEditor..onModelTouched();

【讨论】:

    猜你喜欢
    • 2018-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-05
    • 1970-01-01
    相关资源
    最近更新 更多