<script>
export default Vue.extend({
data: function() {
return {
methods: {
onCreate: function(e) {
this.customBtn = document.getElementById("custom_tbar");
this.$refs.dialogObj.ej2Instances.target = document.getElementById(
"rteSection"
);
var proxy = this;
this.customBtn.onclick = function(e) {
proxy.$refs.rteObj.ej2Instances.contentModule.getEditPanel().focus();
proxy.range = proxy.selection.getRange(document);
proxy.saveSelection = proxy.selection.save(proxy.range, document);
proxy.$refs.dialogObj.ej2Instances.content = document.getElementById(
"rteSpecial_char"
);
proxy.$refs.dialogObj.ej2Instances.dataBind();
proxy.$refs.dialogObj.show();
};
},
onInsert: function() {
debugger;
var insertHTMLContent;
if (this.$refs.insertMarkup.ej2Instances.value === "Markup1") {
insertHTMLContent = "<p>Markup 1 content</p>";
} else {
insertHTMLContent = "<p>Markup 2 content</p>";
}
if (insertHTMLContent !== "") {
if (
this.$refs.rteObj.ej2Instances.formatter.getUndoRedoStack().length ===
0
) {
this.$refs.rteObj.ej2Instances.formatter.saveData();
}
this.saveSelection.restore();
this.$refs.rteObj.ej2Instances.executeCommand(
"insertHTML",
insertHTMLContent
);
this.$refs.rteObj.ej2Instances.formatter.saveData();
}
this.dialogOverlay();
},
provide: {
richtexteditor: [Toolbar, Link, Image, Count, HtmlEditor, QuickToolbar]
}
});
</script>
|
// Method call on button click.
this.customBtn.onclick = function(e) {
// Get the current selection in the Editor.
proxy.range = proxy.selection.getRange(document);
// Save the retrieved selection.
proxy.saveSelection = proxy.selection.save(proxy.range, document);
};
//Method to insert the content
onInsert: function() {
// Restore the saved selection
this.saveSelection.restore();
//Inserts the content.
this.$refs.rteObj.ej2Instances.executeCommand("insertHTML", insertHTMLContent);
} |