UNPKG

@progress/kendo-angular-editor

Version:
61 lines (60 loc) 3.45 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { Directive, isDevMode } from '@angular/core'; import { ToolBarButtonComponent } from '@progress/kendo-angular-toolbar'; import { EditorCommandButton } from '../shared/editor-command-button'; import { EditorLocalizationService } from '../../localization/editor-localization.service'; import { EditorErrorMessages } from '../../common/error-messages'; import { EditorToolsService } from '../tools.service'; import { ProviderService } from '../../common/provider.service'; import * as i0 from "@angular/core"; import * as i1 from "@progress/kendo-angular-toolbar"; import * as i2 from "../../localization/editor-localization.service"; import * as i3 from "../../common/provider.service"; import * as i4 from "../tools.service"; /** * A directive which configures an existing `ToolBarButtonComponent` as an Editor **Print** tool * ([see example]({% slug toolbartools_editor %}#toc-built-in-tools)). * The directive will predefine the SVG icon and `click` event handlers of the button. * * > The Editor Print tool is supported in the default [`iframe`](https://www.telerik.com/kendo-angular-ui-develop/components/editor/api/EditorComponent/#toc-iframe) mode only. * * @example * ```html * <kendo-toolbar-button kendoEditorPrintButton></kendo-toolbar-button> * ``` */ export class EditorPrintDirective extends EditorCommandButton { constructor(button, localization, providerService, toolsService) { super('print', button, localization, providerService, toolsService); } ngAfterViewInit() { if (isDevMode) { if (!this.editor.iframe) { throw new Error(EditorErrorMessages.printTool); } } } clickHandler() { if (this.editor.iframe) { const view = this.editor.view; const dom = view && view.dom; const doc = dom && dom.ownerDocument; const editorWindow = doc && doc.defaultView; if (editorWindow) { editorWindow.print(); } } } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EditorPrintDirective, deps: [{ token: i1.ToolBarButtonComponent }, { token: i2.EditorLocalizationService }, { token: i3.ProviderService }, { token: i4.EditorToolsService }], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: EditorPrintDirective, isStandalone: true, selector: "kendo-toolbar-button[kendoEditorPrintButton]", usesInheritance: true, ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EditorPrintDirective, decorators: [{ type: Directive, args: [{ selector: 'kendo-toolbar-button[kendoEditorPrintButton]', standalone: true }] }], ctorParameters: function () { return [{ type: i1.ToolBarButtonComponent }, { type: i2.EditorLocalizationService }, { type: i3.ProviderService }, { type: i4.EditorToolsService }]; } });