@progress/kendo-angular-editor
Version:
Kendo UI Editor for Angular
113 lines (112 loc) • 5.78 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 { Component, ViewChild, Input } from '@angular/core';
import { DialogRef, DialogContentBase, DialogActionsComponent, DialogTitleBarComponent } from '@progress/kendo-angular-dialog';
import { TextAreaComponent } from '@progress/kendo-angular-inputs';
import { EditorLocalizationService } from '../localization/editor-localization.service';
import { ButtonComponent } from '@progress/kendo-angular-buttons';
import * as i0 from "@angular/core";
import * as i1 from "@progress/kendo-angular-dialog";
import * as i2 from "../localization/editor-localization.service";
/**
* @hidden
*/
export class SourceDialogComponent extends DialogContentBase {
dialog;
localization;
editor;
textarea;
data = '';
constructor(dialog, localization) {
super(dialog);
this.dialog = dialog;
this.localization = localization;
}
onCancelAction() {
this.dialog.close();
}
onConfirmAction() {
this.editor.exec('setHTML', this.getData());
this.dialog.close();
this.editor.view.focus();
}
getData() {
return this.textarea.value;
}
setData() {
this.data = this.indent(this.editor.getSource());
}
textFor(key) {
return this.localization.get(key);
}
indent(content) {
return content
.replace(/<\/(p|li|ul|ol|h[1-6]|table|tr|td|th)>/gi, '</$1>\n')
.replace(/<(ul|ol)([^>]*)><li/gi, '<$1$2>\n<li')
.replace(/<br \/>/gi, '<br />\n')
.replace(/\n$/, '');
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SourceDialogComponent, deps: [{ token: i1.DialogRef }, { token: i2.EditorLocalizationService }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: SourceDialogComponent, isStandalone: true, selector: "ng-component", inputs: { editor: "editor" }, viewQueries: [{ propertyName: "textarea", first: true, predicate: ["textarea"], descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: `
<kendo-dialog-titlebar (close)="onCancelAction()">
{{ textFor('viewSource') }}
</kendo-dialog-titlebar>
<kendo-textarea
#textarea
class="k-editor-textarea"
flow="horizontal"
resizable="none"
[value]="data"
[style.height.%]="100"
></kendo-textarea>
<kendo-dialog-actions layout="start">
<button
kendoButton
[primary]="true"
(click)="onConfirmAction()"
>{{ textFor('dialogUpdate') }}</button>
<button
kendoButton
(click)="onCancelAction()"
>{{ textFor('dialogCancel') }}</button>
</kendo-dialog-actions>
`, isInline: true, dependencies: [{ kind: "component", type: DialogTitleBarComponent, selector: "kendo-dialog-titlebar", inputs: ["id", "closeTitle"], outputs: ["close"] }, { kind: "component", type: TextAreaComponent, selector: "kendo-textarea", inputs: ["focusableId", "flow", "inputAttributes", "adornmentsOrientation", "rows", "cols", "maxlength", "maxResizableRows", "tabindex", "tabIndex", "resizable", "size", "rounded", "fillMode", "showPrefixSeparator", "showSuffixSeparator"], outputs: ["focus", "blur", "valueChange"], exportAs: ["kendoTextArea"] }, { kind: "component", type: DialogActionsComponent, selector: "kendo-dialog-actions", inputs: ["actions", "layout"], outputs: ["action"] }, { kind: "component", type: ButtonComponent, selector: "button[kendoButton]", inputs: ["arrowIcon", "toggleable", "togglable", "selected", "tabIndex", "imageUrl", "iconClass", "icon", "disabled", "size", "rounded", "fillMode", "themeColor", "svgIcon", "primary", "look"], outputs: ["selectedChange", "click"], exportAs: ["kendoButton"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SourceDialogComponent, decorators: [{
type: Component,
args: [{
template: `
<kendo-dialog-titlebar (close)="onCancelAction()">
{{ textFor('viewSource') }}
</kendo-dialog-titlebar>
<kendo-textarea
#textarea
class="k-editor-textarea"
flow="horizontal"
resizable="none"
[value]="data"
[style.height.%]="100"
></kendo-textarea>
<kendo-dialog-actions layout="start">
<button
kendoButton
[primary]="true"
(click)="onConfirmAction()"
>{{ textFor('dialogUpdate') }}</button>
<button
kendoButton
(click)="onCancelAction()"
>{{ textFor('dialogCancel') }}</button>
</kendo-dialog-actions>
`,
standalone: true,
imports: [DialogTitleBarComponent, TextAreaComponent, DialogActionsComponent, ButtonComponent]
}]
}], ctorParameters: function () { return [{ type: i1.DialogRef }, { type: i2.EditorLocalizationService }]; }, propDecorators: { editor: [{
type: Input
}], textarea: [{
type: ViewChild,
args: ['textarea', { static: true }]
}] } });