我正在使用EditorJS (https://editorjs.io/)
我有一个隐藏的div与编辑器在它和一个单独的按钮(添加新的ex)我需要这个div出现时,用户点击该按钮
一切都很好
但是我不能设置自动聚焦,这样用户就不会点击夹具来开始使用编辑器
我试着去做
setTimeout(function(){ $('#editor').click()}, 100);但它不起作用
发布于 2020-10-28 04:14:30
如果我正确理解了你的成长,https://editorjs.io/configuration#autofocus
有一个配置键:
const editor = new EditorJS(
autofocus: true
})发布于 2020-10-28 16:31:48
好的,下面是解决方案:
<div id="editorjs"></div>
<button id="focus">focus</button>和初始化:
const editor = new EditorJS({
holder: 'editorjs',
onReady: function () {
const btn = document.querySelector("#focus");
btn.addEventListener("click", () => editor.focus())
}
})和链接,例如:https://codepen.io/Ashley100/pen/mdEqoRY?editors=1010
https://stackoverflow.com/questions/64562119
复制相似问题