<script>
document.getElementById('btn').addEventListener('click', function () {
var el = document.createElement("img");
el.src = "https://ej2.syncfusion.com/demos/src/rich-text-editor/images/RTEImage-Feather.png";
defaultRTE.focusIn();
let selection = new NodeSelection();
let range = selection.getRange(defaultRTE.contentModule.getDocument());
selection.save(range, defaultRTE.contentModule.getDocument());
defaultRTE.executeCommand("insertImage", el);
});
</script> |
<script>
document.getElementById('btn').addEventListener('click', function () {
var el = document.createElement("img");
el.src = "https://ej2.syncfusion.com/demos/src/rich-text-editor/images/RTEImage-Feather.png";
defaultRTE.focusIn();
var selection = new ej.richtexteditor.NodeSelection();
var range = selection.getRange(defaultRTE.contentModule.getDocument());
selection.save(range, defaultRTE.contentModule.getDocument());
defaultRTE.executeCommand("insertImage", el);
});
</script> |
document.getElementById('btn').addEventListener('click', function () {
var el = document.createElement("img");
el.src = "https://ej2.syncfusion.com/demos/src/rich-text-editor/images/RTEImage-Feather.png";
defaultRTE.focusIn();
var selection = defaultRTE.formatter.editorManager.nodeSelection;
var range = selection.getRange(defaultRTE.contentModule.getDocument());
selection.save(range, defaultRTE.contentModule.getDocument());
defaultRTE.executeCommand("insertImage", el);
}); |
var selection;
var defaultRTE = new ej.richtexteditor.RichTextEditor({
blur: function () {
selection = defaultRTE.formatter.editorManager.nodeSelection;
var range = selection.getRange(defaultRTE.contentModule.getDocument());
selection.save(range, defaultRTE.contentModule.getDocument());
}
});
defaultRTE.appendTo("#defaultRTE");
document.getElementById('btn').addEventListener('click', function () {
var el = document.createElement("img");
el.src = "https://ej2.syncfusion.com/demos/src/rich-text-editor/images/RTEImage-Feather.png";
selection.restore();
defaultRTE.executeCommand("insertImage", el);
}); |