PrimeNG的RTF编辑器使用羽毛笔,并通过JavaScript进行设置,可以使用以下代码禁用制表符功能:
keyboard: {
bindings: {
tab: false,
handleEnter: {
key: 13,
handler: function() {
// Do nothing
}
}
}
}
我可以使用以下方式访问Angular中的编辑器:
private quill:any;
@ViewChild(Editor) editorComponent: Editor;
ngAfterViewInit() {
this.quill = this.editorComponent.quill;
}
但是,如何使用this.quill对象将tab设置为false?有任何想法吗?
好像在Primeng中,我们没有任何方便的方法来实现这一目标。可能在那里,但我什么也没找到。所以在这里,我是我的解决方案。它可能不是最佳解决方案,但应该可以解决您的目的。
component.html
<p-editor [style]="{'height':'320px'}" (onInit)="editorcall($event)"></p-editor>
我正在使用(onInit),以便一旦编辑器加载到DOM后就可以禁用该选项卡。
component.ts
export class EditorComponent {
public tab = {
key:9,
handler: function() {
return false;
}
};
editorcall(event:any){
event.editor.keyboard.bindings[9].length = 0;
event.editor.keyboard.bindings[9].push(this.tab);
}
}
我刚刚删除了所有使用键码9的引用。这是Tab键。为什么我创建了一个新的选项卡对象并再次将其压入绑定,原因是每当您单击选项卡时,鼠标指针都不应进入任何其他HTML组件。它应该只在编辑器内部。您可以注释此行//event.editor.keyboard.bindings[9].push(this.tab);
并查看副作用。
确保这不会在任何地方破坏您的应用程序。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句