angular - 使用tinymce(tinymce-angular)专注于textarea
问题描述
我正在使用带有角度的tinymce(tinymce-angular)。tinymce 的版本好像是 5.4.1。
页面上有几个编辑器字段/文本区域,我想关注第一个页面加载。那可能吗?在 html 或 ts 文件中。
这就是我初始化编辑器的方式:
环形...
<editor [(ngModel)]="map.get(item.id).item"
[ngModelOptions]="{standalone: true}"
(onBlur)="itemChanged(item.id)"
[initialValue]="map.get(item.id).item"
[init]="{plugins: 'link',
menubar: false,
toolbar:false,
base_url: './assets/tinymce',
suffix: '.min',
branding: false,
elementpath: false,
statusbar:false,
height:100,
tabindex:0,
auto_resize:true,
placeholder: 'Type here please',
autoresize_bottom_margin: 10}">
</editor>
解决方案
这种代码似乎有效:
var currentItem = document.getElementById(divid);
var editors = currentItem.getElementsByTagName('iframe');
if (editors !== undefined && editors.length > 0) {
var editor = editors[0];
var body = editor.contentDocument.getElementsByTagName('body');
if (body !== undefined && body.length > 0) {
body[0].focus();
}
}
推荐阅读
- java - 将 char 数组转换为字符串。爪哇
- c - 加密小于 1Kbyte 的文件时出现段错误错误
- c# - 无法将“System.Int32”类型的对象转换为“System.Boolean”类型。
- java - 在 Cucumber 报告 (.html/.json) 文件中显示每个测试场景的时间戳(开始时间/结束时间)
- laravel - Laravel Chart 不呈现图表。未定义变量:图表
- java - 有 ac# 的“int”吗?java中的等价物?
- java - Java Lambda 未编译
- r - 使用 poly() 并将预测器设置为因子时,lm() 会中断
- html - 引导标头不可见
- java - 为什么我可以在 textPersonName 中输入数字?