如果我超过字符长度,光标应换行

时间:2019-05-10 09:35:35

标签: html angular typescript quill

我正在尝试使用Quill编辑器,以便当我在一行中超过50个字符时,光标会直接移到新行。

但是我的光标没有移到新行。

下面是我的代码。

HTML

    <quill-editor class="editor" [(ngModel)]="currentStep.Description" id="description" (onContentChanged)="textChanged($event)">
        <div quill-editor-toolbar>
            <span class="ql-formats">
                <button class="ql-bold" [title]="'Bold'"></button>
            </span>
            <span class="ql-formats">
                <button class="ql-italic" [title]="'Italic'"></button>
            </span>
            <span class="ql-formats">
                <button class="ql-underline" [title]="'Underline'"></button>
            </span>
            <span class="ql-formats">
                <button class="ql-strike" [title]="'Strike'"></button>
            </span>

        </div>
    </quill-editor>

TS

textChanged($event: any) {
    if ($event.editor.getLength() > this.MAX_LENGTH) {
        this.currentStep.Description = $event.editor.getText();
        this.currentStep.Description = this.currentStep.Description + '\n';
        console.log(this.currentStep.Description);

        $event.editor.deleteText(this.MAX_LENGTH, $event.editor.getLength());
        // console.log($event.editor.deleteText(this.MAX_LENGTH, $event.editor.getLength()));
    }
}

有人可以帮我把光标移到新行吗?

0 个答案:

没有答案