Icard/angular-clarity-master(work.../node_modules/ng2-ckeditor/esm2020/ckbutton.directive.mjs

59 lines
5.6 KiB
JavaScript

import { Directive, EventEmitter, Output, Input } from '@angular/core';
import * as i0 from "@angular/core";
/**
* CKGroup component
* Usage :
* <ckeditor [(ngModel)]="data" [config]="{...}" debounce="500">
* <ckbutton [name]="'SaveButton'" [command]="'saveCommand'" (click)="save($event)"
* [icon]="'/save.png'" [toolbar]="'customGroup,1'" [label]="'Save'">
* </ckbutton>
* </ckeditor>
*/
export class CKButtonDirective {
constructor() {
this.click = new EventEmitter();
}
initialize(editor) {
editor.instance.addCommand(this.command, {
exec: (edit) => {
this.click.emit(edit);
return true;
},
});
editor.instance.ui.addButton(this.name, {
label: this.label,
command: this.command,
toolbar: this.toolbar,
icon: this.icon,
});
}
ngOnInit() {
if (!this.name) {
throw new Error('Attribute "name" is required on <ckbutton>');
}
if (!this.command) {
throw new Error('Attribute "command" is required on <ckbutton>');
}
}
}
CKButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: CKButtonDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
CKButtonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.2", type: CKButtonDirective, selector: "ckbutton", inputs: { label: "label", command: "command", toolbar: "toolbar", name: "name", icon: "icon" }, outputs: { click: "click" }, ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.2", ngImport: i0, type: CKButtonDirective, decorators: [{
type: Directive,
args: [{
selector: 'ckbutton',
}]
}], propDecorators: { click: [{
type: Output
}], label: [{
type: Input
}], command: [{
type: Input
}], toolbar: [{
type: Input
}], name: [{
type: Input
}], icon: [{
type: Input
}] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2tidXR0b24uZGlyZWN0aXZlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOl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