@progress/kendo-angular-editor
Version:
Kendo UI Editor for Angular
79 lines (78 loc) • 3.9 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the project root for more information
*-------------------------------------------------------------------------------------------*/
import { ToolBarButtonComponent } from '@progress/kendo-angular-toolbar';
import { commandIcons, commandSVGIcons } from '../../config/command-icons';
import { LocalizationService } from '@progress/kendo-angular-l10n';
import { ProviderService } from '../../common/provider.service';
import { Directive, Inject, InjectionToken } from '@angular/core';
import { EditorToolsService } from '../tools.service';
import * as i0 from "@angular/core";
import * as i1 from "@progress/kendo-angular-toolbar";
import * as i2 from "@progress/kendo-angular-l10n";
import * as i3 from "../../common/provider.service";
import * as i4 from "../tools.service";
const MY_TOKEN = new InjectionToken('COMMAND_TOKEN');
/**
* @hidden
*/
export class EditorCommandBaseDirective {
command;
button;
localization;
toolsService;
subs;
editor;
constructor(command, button, localization, providerService, toolsService) {
this.command = command;
this.button = button;
this.localization = localization;
this.toolsService = toolsService;
this.editor = providerService.editor;
this.toolsService.zone.runOutsideAngular(() => {
setTimeout(() => {
const text = this.localization.get(this.command);
if (text) {
this.button.showText = 'overflow';
this.button.showIcon = 'both';
this.button.text = text;
}
if (!this.button.toolbarOptions.icon) {
this.button.icon = commandIcons[this.command];
}
if (!this.button.toolbarOptions.svgIcon) {
this.button.svgIcon = commandSVGIcons[this.command];
}
this.button.title = text;
this.toolsService.zone.run(() => {
this.toolsService.needsCheck.next();
});
});
});
}
ngOnInit() {
this.subs = this.editor.stateChange.subscribe(this.onStateChange.bind(this));
this.subs.add(this.button.click.subscribe((this.clickHandler.bind(this))));
this.subs.add(this.button.pointerdown.subscribe((this.pointerdownHandler.bind(this))));
}
ngOnDestroy() {
if (this.subs) {
this.subs.unsubscribe();
}
}
clickHandler() { }
pointerdownHandler(_event) { }
onStateChange(_toolBarState) { }
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EditorCommandBaseDirective, deps: [{ token: MY_TOKEN }, { token: i1.ToolBarButtonComponent }, { token: i2.LocalizationService }, { token: i3.ProviderService }, { token: i4.EditorToolsService }], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: EditorCommandBaseDirective, selector: "[kendoEditorCommandBase]", ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EditorCommandBaseDirective, decorators: [{
type: Directive,
args: [{
selector: '[kendoEditorCommandBase]'
}]
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
type: Inject,
args: [MY_TOKEN]
}] }, { type: i1.ToolBarButtonComponent }, { type: i2.LocalizationService }, { type: i3.ProviderService }, { type: i4.EditorToolsService }]; } });