editor.getEditable(bFocus)
Returns the editable root element — the body inside the editor’s iframe that actually holds the content the user types into. Reach for it when you need the container element itself: to read its children, measure it, or scope a query to just the edited content.
Syntax
editor.getEditable(bFocus)
Parameters
bFocus — optional boolean. When true, the editor is focused before the element is returned. Omit it (or pass a falsy value) to get the element without changing focus.
Returns
The editable body element.
Behavior notes
- Element, not document. This returns the body element; getDocument() returns the surrounding
Document. Both live inside the editing iframe. - Optional focus is a convenience. Passing
truesaves a separate focus() call when you are about to place a selection or start editing. - Query against it to stay scoped. A
querySelectoron the returned element only ever sees the edited content, never the surrounding page chrome.
Example usage
Read the first paragraph of the edited content:
var editor1 = new RichTextEditor("#div_editor1");
var body = editor1.getEditable();
var firstPara = body.querySelector("p");Focus the editor and get the editable in one call before setting a selection:
var body = editor1.getEditable(true); // focuses, then returns the elementRelated
- editor.getDocument()— the Document that contains this element.
- editor.focus()— move keyboard focus into the editor.
- editor.getHTMLCode()— get the content as an HTML string instead of a live element.
Calling editor.getEditable() from your app
editor.getEditable() belongs to the editor instance. Every integration below works the same way: keep the object that new RichTextEditor(...) returns, and call it on that object.
Plain JavaScript
var editor1 = new RichTextEditor("#div_editor1");
// The constructor is synchronous: the editor is ready on the next line.
editor1.getEditable(bFocus);React and Next.js
// editorRef is filled by the RichTextEditor wrapper from the React guides.
const editorRef = useRef(null);
function onClick() {
editorRef.current?.getEditable(bFocus);
}
return <RichTextEditor editorRef={editorRef} />;In Vue and Angular, the wrapper components in the guides keep the instance in a component variable (editor), so the call is the same. See the React, Vue and Angular pages, or download a tested project from the guides.
If the editor is undefined
- The call ran before the component mounted. Call it from an event handler or after the mount effect has run.
- In React development mode, Strict Mode mounts, unmounts and mounts again, so the wrapper sets
editorRef.currenttonullin between. UseeditorRef.current?.rather than storing the instance elsewhere. - The editor was destroyed (
editor.destroy()) when its component unmounted.
All methods: method reference · all events: event reference.