Hi Vladimir,
Thank you for the provided feedback.
Creating a custom Editor tool using the exec method and insertText command is the correct approach to achieve the desired functionality.
While the requested feature is useful in some scenarios, it is considered a custom tool that should be implemented as per project requirements due to the variety in its usage and possible configuration. Providing such a built-in tool might not cover all possible cases.
Regards,
Martin
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
I will post my solution here. it may help to someone.
import {Directive, Host, Inject, Input, OnDestroy, OnInit} from '@angular/core';
import {EditorComponent} from '@progress/kendo-angular-editor';
import {ToolBarDropDownButtonComponent} from '@progress/kendo-angular-toolbar';
import {Subscription} from 'rxjs';
import {DOCUMENT} from '@angular/common';
import {EditorInserterItem} from '@core/models/editor/editor-inserter-item';
@Directive({
// tslint:disable-next-line:directive-selector
selector: 'kendo-toolbar-dropdownbutton[kendoEditorInserter][items]"'
})
export class KendoEditorInserterDirective implements OnInit, OnDestroy {
private subscriptions: Subscription = new Subscription();
@Input() items!: EditorInserterItem[];
constructor(
private dropdown: ToolBarDropDownButtonComponent,
@Inject(DOCUMENT) private document: Document,
@Host() private editor: EditorComponent
) {
}
ngOnInit(): void {
this.dropdown.textField = 'text';
this.dropdown.data = this.items;
this.subscriptions.add(
this.dropdown.itemClick.subscribe((result: any) => {
if (result?.value) {
this.editor.exec('insertText', {text: result.value});
}
})
);
}
ngOnDestroy(): void {
this.subscriptions.unsubscribe();
}
}
<kendo-toolbar-dropdownbutton text="Placeholders" kendoEditorInserter [items]="items">
</kendo-toolbar-dropdownbutton>