Set focus on div contenteditable element

后端 未结 9 2077
深忆病人
深忆病人 2020-11-29 01:51

I have a

where I define by a WYSIWYG some elements. For example

,

, etc. I would l

9条回答
  •  失恋的感觉
    2020-11-29 02:18

    In case someone, who uses MediumEditor that manages contenteditable element, stumbles upon this issue, the following has worked for me:

    editor.selectElement(editorDOMNode);
    
    1. editor is an instance of MediumEditor.
    2. editorDOMNode is a reference to the actual contenteditable DOM node.
    3. It is also possible to focus on a specific child node within the editor as follows:

      editor.selectElement(editorDOMNode.childNodes[0]);
      

提交回复
热议问题