MCPcopy
hub / github.com/tinymce/tinymce / remove

Function remove

modules/tinymce/src/core/main/ts/api/EditorManager.ts:595–642  ·  view source on GitHub ↗

* Removes a editor or editors form page. * * @example * // Remove all editors bound to divs * tinymce.remove('div'); * * // Remove all editors bound to textareas * tinymce.remove('textarea'); * * // Remove all editors * tinymce.remove(); * * // Remove specific ins

(selector?: string | Editor)

Source from the content-addressed store, hash-verified

593 * @return {tinymce.Editor} The editor that got passed in will be return if it was found otherwise null.
594 */
595 remove(selector?: string | Editor): any {
596 const self = this;
597 let editor: Editor | null;
598
599 // Remove all editors
600 if (!selector) {
601 for (let i = editors.length - 1; i >= 0; i--) {
602 self.remove(editors[i]);
603 }
604
605 return;
606 }
607
608 // Remove editors by selector
609 if (Type.isString(selector)) {
610 each(DOM.select(selector), (elm) => {
611 editor = self.get(elm.id);
612
613 if (editor) {
614 self.remove(editor);
615 }
616 });
617
618 return;
619 }
620
621 // Remove specific editor
622 editor = selector;
623
624 // Not in the collection
625 if (Type.isNull(self.get(editor.id))) {
626 return null;
627 }
628
629 if (removeEditorFromList(editor)) {
630 self.dispatch('RemoveEditor', { editor });
631 }
632
633 if (editors.length === 0) {
634 window.removeEventListener('beforeunload', beforeUnloadDelegate);
635 }
636
637 editor.remove();
638
639 toggleGlobalEvents(editors.length > 0);
640
641 return editor;
642 },
643
644 /**
645 * Executes a specific command on the currently active editor.

Callers

nothing calls this directly

Calls 6

removeEditorFromListFunction · 0.85
toggleGlobalEventsFunction · 0.85
removeMethod · 0.65
getMethod · 0.65
dispatchMethod · 0.65
eachFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…