|
public inlineMode: object = { enable: true, onSelection: false };
public rteElement: HTMLElement;
public selection: NodeSelection = new NodeSelection();
public range: Range;
public customBtn: HTMLElement;
public dialogCtn: HTMLElement;
public saveSelection: NodeSelection;
public currentElement: HTMLElement;
public onCreate(): void {
this.rteElement =this.rteObj.inputElement as HTMLElement;
this.rteElement.onclick = (e: Event) => {
this.range = this.selection.getRange(document);
if (this.range.startContainer.nodeName === '#text') {
this.currentElement = this.range.startContainer.parentElement;
} else {
this.currentElement = this.range.startContainer as HTMLElement;
}
if (this.currentElement.tagName === "DIV") {
this.rteObj.toolbarSettings.items = ['Bold', 'Italic', 'Underline'];
} else {
this.rteObj.toolbarSettings.items = ['Formats', 'Alignments', 'OrderedList', 'UnorderedList',
'CreateLink'];
}
};
} |
|
<ejs-richtexteditor id='inlineRTE' #inlineRTE [inlineMode]='inlineMode' [toolbarSettings]='toolbarSettings'
[format]='format' (created)='onCreate()' [fontFamily]='fontFamily'>
<ng-template #valueTemplate>
<h2>Div Element</h2>
<div>This is a div element with sample content. The sample is configured with inline mode of editor. </div>
<h2>Paragraph Element</h2>
<p>The sample is configured with inline mode of editor. Initially, the editor is rendered without a
<a rel='nofollow' href="https://ej2.syncfusion.com/home/" target="_blank">toolbar</a>. The toolbar becomes
visible only when the content is selected.</p>
</ng-template>
</ejs-richtexteditor> |