- Home
- Forum
- React - EJ 2
- Support of Template Variables
Support of Template Variables
Good day,
I am interested in using the Syncfusion rich text editor, but I can't find a particular feature.
As I want to create templates (i.e., for emails), I do have the demand to insert variables, which will be in a later stage interpolated.
Something like that: https://ambassify.github.io/tinymce-variable/ or even better like this https://www.tiny.cloud/docs/tinymce/6/mergetags/
Please let me know if this can be achieved with you rich text editor component.
export class InsertSpecialCharacters extends SampleBase { rteObj; constructor(props) { super(props); this.rteSpecialCharEle = null; } selection = new NodeSelection(); range; customBtn; saveSelection; // Rich Text Editor items list items = [ 'Bold', 'Italic', 'Underline', '|', 'Formats', 'Alignments', 'OrderedList', 'UnorderedList', '|', 'CreateLink', 'Image', '|', 'SourceCode', { tooltipText: 'Insert Symbol', template: '<button class="e-tbar-btn e-btn" tabindex="-1" id="custom_tbar" style="width:100%"><div class="e-tbar-btn-text" style="font-weight: 500;">Insert Variable</div></button>', }, '|', 'Undo', 'Redo', ]; //Rich Text Editor ToolbarSettings toolbarSettings = { items: this.items, }; height = 'auto'; onCreate() { this.customBtn = document.getElementById('custom_tbar'); this.customBtn.onclick = (e) => { this.rteObj.contentModule.getEditPanel().focus(); this.rteObj.executeCommand( 'insertHTML', '<span id="act">Account ID</span>' ); }; } render() { return ( <div className="control-pane"> <div className="control-section e-rte-custom-tbar-section" id="rteCustomTool" > <div className="rte-control-section" ref={this.rteSectionRef} id="rteSection" > <RichTextEditorComponent id="specialCharRTE" ref={(scope) => { this.rteObj = scope; }} toolbarSettings={this.toolbarSettings} created={this.onCreate.bind(this)> <Inject services={[HtmlEditor, Toolbar, Link, Image, QuickToolbar]} /> </RichTextEditorComponent> </div> </div> </div> ); } } const root = createRoot(document.getElementById('sample')); root.render(<InsertSpecialCharacters />); |
Hi Vinitha,
Thanks a lot for your feedback. This is almost what I wanted. The inserting of the variable looks excellent, but if I use the backspace, then I can delete the placed variable characters. Still, I would expect more that the whole variable will be removed with one keystroke. This means that the inserted variable is treated like a badge or a block rather than single characters.
How can that be achieved?
Here is a sample, that you can damage the variables.
onCreate() { this.customBtn = document.getElementById('custom_tbar'); this.customBtn.onclick = (e) => { this.rteObj.contentModule.getEditPanel().focus(); this.rteObj.executeCommand( 'insertHTML', '<span contenteditable="false" id="act">Account ID</span>' ); }; } |
Thanks a lot Vinitha
- 5 Replies
- 2 Participants
-
SW Stefan Walter
- Oct 4, 2023 07:09 AM UTC
- Oct 9, 2023 04:55 AM UTC