@maliardic/ma-ui 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,457 +1,272 @@
1
- import * as i0 from "@angular/core";
2
- import { ChangeDetectionStrategy, Component, ElementRef, booleanAttribute, computed, effect, inject, input, output, signal, viewChild } from "@angular/core";
3
- import { Editor } from "@tiptap/core";
4
- import StarterKit from "@tiptap/starter-kit";
5
- import Placeholder from "@tiptap/extension-placeholder";
6
- import Link from "@tiptap/extension-link";
7
- import { noopTouched, provideValueAccessor } from "@maliardic/ma-ui";
8
- var MEditor = class MEditor {
9
- elementRef = inject(ElementRef);
10
- editorElement = viewChild("editorContainer", ...ngDevMode ? [{ debugName: "editorElement" }] : /* istanbul ignore next */ []);
11
- editor = null;
12
- placeholder = input("Write something...", ...ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []);
13
- value = input("", ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
14
- size = input("md", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
15
- height = input("", ...ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []);
16
- minHeight = input("150px", ...ngDevMode ? [{ debugName: "minHeight" }] : /* istanbul ignore next */ []);
17
- maxHeight = input("500px", ...ngDevMode ? [{ debugName: "maxHeight" }] : /* istanbul ignore next */ []);
18
- toolbar = input(true, {
19
- ...ngDevMode ? { debugName: "toolbar" } : /* istanbul ignore next */ {},
20
- transform: booleanAttribute
21
- });
22
- disabled = input(false, {
23
- ...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
24
- transform: booleanAttribute
25
- });
26
- readOnly = input(false, {
27
- ...ngDevMode ? { debugName: "readOnly" } : /* istanbul ignore next */ {},
28
- alias: "readonly",
29
- transform: booleanAttribute
30
- });
31
- outputFormat = input("html", ...ngDevMode ? [{ debugName: "outputFormat" }] : /* istanbul ignore next */ []);
32
- valueChange = output();
33
- onChange = output();
34
- focus = output();
35
- blur = output();
36
- disabledFromControl = signal(false, ...ngDevMode ? [{ debugName: "disabledFromControl" }] : /* istanbul ignore next */ []);
37
- isFocused = signal(false, ...ngDevMode ? [{ debugName: "isFocused" }] : /* istanbul ignore next */ []);
38
- isDisabled = computed(() => this.disabled() || this.readOnly() || this.disabledFromControl(), ...ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []);
39
- isBold = signal(false, ...ngDevMode ? [{ debugName: "isBold" }] : /* istanbul ignore next */ []);
40
- isItalic = signal(false, ...ngDevMode ? [{ debugName: "isItalic" }] : /* istanbul ignore next */ []);
41
- isStrike = signal(false, ...ngDevMode ? [{ debugName: "isStrike" }] : /* istanbul ignore next */ []);
42
- isCode = signal(false, ...ngDevMode ? [{ debugName: "isCode" }] : /* istanbul ignore next */ []);
43
- isHeading1 = signal(false, ...ngDevMode ? [{ debugName: "isHeading1" }] : /* istanbul ignore next */ []);
44
- isHeading2 = signal(false, ...ngDevMode ? [{ debugName: "isHeading2" }] : /* istanbul ignore next */ []);
45
- isHeading3 = signal(false, ...ngDevMode ? [{ debugName: "isHeading3" }] : /* istanbul ignore next */ []);
46
- isBulletList = signal(false, ...ngDevMode ? [{ debugName: "isBulletList" }] : /* istanbul ignore next */ []);
47
- isOrderedList = signal(false, ...ngDevMode ? [{ debugName: "isOrderedList" }] : /* istanbul ignore next */ []);
48
- isBlockquote = signal(false, ...ngDevMode ? [{ debugName: "isBlockquote" }] : /* istanbul ignore next */ []);
49
- isCodeBlock = signal(false, ...ngDevMode ? [{ debugName: "isCodeBlock" }] : /* istanbul ignore next */ []);
50
- isLink = signal(false, ...ngDevMode ? [{ debugName: "isLink" }] : /* istanbul ignore next */ []);
51
- usingValueAccessor = false;
52
- onControlChange = () => void 0;
53
- onTouched = noopTouched;
54
- initialValuePending = null;
55
- constructor() {
56
- effect(() => {
57
- const val = this.value();
58
- if (!this.usingValueAccessor && this.editor) this.setContent(val);
59
- });
60
- effect(() => {
61
- const disabled = this.isDisabled();
62
- if (this.editor) this.editor.setEditable(!disabled);
63
- });
64
- }
65
- ngAfterViewInit() {
66
- const container = this.editorElement()?.nativeElement;
67
- if (!container) return;
68
- this.editor = new Editor({
69
- element: container,
70
- editable: !this.isDisabled(),
71
- extensions: [
72
- StarterKit,
73
- Placeholder.configure({ placeholder: () => this.placeholder() }),
74
- Link.configure({
75
- openOnClick: false,
76
- HTMLAttributes: {
77
- rel: "noopener noreferrer",
78
- target: "_blank"
79
- }
80
- })
81
- ],
82
- content: this.initialValuePending ?? this.value() ?? "",
83
- onUpdate: () => {
84
- this.updateActiveStates();
85
- this.emitChanges();
86
- },
87
- onSelectionUpdate: () => {
88
- this.updateActiveStates();
89
- },
90
- onTransaction: () => {
91
- this.updateActiveStates();
92
- },
93
- onFocus: ({ event }) => {
94
- this.isFocused.set(true);
95
- this.focus.emit(event);
96
- },
97
- onBlur: ({ event }) => {
98
- this.isFocused.set(false);
99
- this.onTouched();
100
- this.blur.emit(event);
101
- }
102
- });
103
- this.updateActiveStates();
104
- }
105
- ngOnDestroy() {
106
- if (this.editor) {
107
- this.editor.destroy();
108
- this.editor = null;
109
- }
110
- }
111
- writeValue(value) {
112
- this.usingValueAccessor = true;
113
- const content = value ?? "";
114
- if (this.editor) this.setContent(content);
115
- else this.initialValuePending = content;
116
- }
117
- registerOnChange(fn) {
118
- this.usingValueAccessor = true;
119
- this.onControlChange = fn;
120
- }
121
- registerOnTouched(fn) {
122
- this.onTouched = fn;
123
- }
124
- setDisabledState(disabled) {
125
- this.disabledFromControl.set(disabled);
126
- }
127
- toggleBold() {
128
- this.editor?.chain().focus().toggleBold().run();
129
- }
130
- toggleItalic() {
131
- this.editor?.chain().focus().toggleItalic().run();
132
- }
133
- toggleStrike() {
134
- this.editor?.chain().focus().toggleStrike().run();
135
- }
136
- toggleCode() {
137
- this.editor?.chain().focus().toggleCode().run();
138
- }
139
- toggleHeading(level) {
140
- this.editor?.chain().focus().toggleHeading({ level }).run();
141
- }
142
- toggleBulletList() {
143
- this.editor?.chain().focus().toggleBulletList().run();
144
- }
145
- toggleOrderedList() {
146
- this.editor?.chain().focus().toggleOrderedList().run();
147
- }
148
- toggleBlockquote() {
149
- this.editor?.chain().focus().toggleBlockquote().run();
150
- }
151
- toggleCodeBlock() {
152
- this.editor?.chain().focus().toggleCodeBlock().run();
153
- }
154
- addLink() {
155
- if (!this.editor) return;
156
- const previousUrl = this.editor.getAttributes("link")["href"];
157
- const url = window.prompt("URL giriniz:", previousUrl);
158
- if (url === null) return;
159
- if (url === "") {
160
- this.editor.chain().focus().extendMarkRange("link").unsetLink().run();
161
- return;
162
- }
163
- this.editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();
164
- }
165
- unsetLink() {
166
- this.editor?.chain().focus().unsetLink().run();
167
- }
168
- setHorizontalRule() {
169
- this.editor?.chain().focus().setHorizontalRule().run();
170
- }
171
- undo() {
172
- this.editor?.chain().focus().undo().run();
173
- }
174
- redo() {
175
- this.editor?.chain().focus().redo().run();
176
- }
177
- clearFormatting() {
178
- this.editor?.chain().focus().unsetAllMarks().clearNodes().run();
179
- }
180
- setContent(content) {
181
- if (!this.editor) return;
182
- if (this.editor.getHTML() !== content) {
183
- this.editor.commands.setContent(content);
184
- this.updateActiveStates();
185
- }
186
- }
187
- updateActiveStates() {
188
- if (!this.editor) return;
189
- this.isBold.set(this.editor.isActive("bold"));
190
- this.isItalic.set(this.editor.isActive("italic"));
191
- this.isStrike.set(this.editor.isActive("strike"));
192
- this.isCode.set(this.editor.isActive("code"));
193
- this.isHeading1.set(this.editor.isActive("heading", { level: 1 }));
194
- this.isHeading2.set(this.editor.isActive("heading", { level: 2 }));
195
- this.isHeading3.set(this.editor.isActive("heading", { level: 3 }));
196
- this.isBulletList.set(this.editor.isActive("bulletList"));
197
- this.isOrderedList.set(this.editor.isActive("orderedList"));
198
- this.isBlockquote.set(this.editor.isActive("blockquote"));
199
- this.isCodeBlock.set(this.editor.isActive("codeBlock"));
200
- this.isLink.set(this.editor.isActive("link"));
201
- }
202
- emitChanges() {
203
- if (!this.editor) return;
204
- const html = this.editor.getHTML();
205
- const json = this.editor.getJSON();
206
- const emitVal = this.outputFormat() === "json" ? JSON.stringify(json) : html;
207
- this.valueChange.emit(emitVal);
208
- this.onControlChange(emitVal);
209
- this.onChange.emit({
210
- html,
211
- json
212
- });
213
- }
214
- static ɵfac = i0.ɵɵngDeclareFactory({
215
- minVersion: "12.0.0",
216
- version: "22.2.0",
217
- ngImport: i0,
218
- type: MEditor,
219
- deps: [],
220
- target: i0.ɵɵFactoryTarget.Component
221
- });
222
- static ɵcmp = i0.ɵɵngDeclareComponent({
223
- minVersion: "17.0.0",
224
- version: "22.2.0",
225
- type: MEditor,
226
- isStandalone: true,
227
- selector: "m-editor",
228
- inputs: {
229
- placeholder: {
230
- classPropertyName: "placeholder",
231
- publicName: "placeholder",
232
- isSignal: true,
233
- isRequired: false,
234
- transformFunction: null
235
- },
236
- value: {
237
- classPropertyName: "value",
238
- publicName: "value",
239
- isSignal: true,
240
- isRequired: false,
241
- transformFunction: null
242
- },
243
- size: {
244
- classPropertyName: "size",
245
- publicName: "size",
246
- isSignal: true,
247
- isRequired: false,
248
- transformFunction: null
249
- },
250
- height: {
251
- classPropertyName: "height",
252
- publicName: "height",
253
- isSignal: true,
254
- isRequired: false,
255
- transformFunction: null
256
- },
257
- minHeight: {
258
- classPropertyName: "minHeight",
259
- publicName: "minHeight",
260
- isSignal: true,
261
- isRequired: false,
262
- transformFunction: null
263
- },
264
- maxHeight: {
265
- classPropertyName: "maxHeight",
266
- publicName: "maxHeight",
267
- isSignal: true,
268
- isRequired: false,
269
- transformFunction: null
270
- },
271
- toolbar: {
272
- classPropertyName: "toolbar",
273
- publicName: "toolbar",
274
- isSignal: true,
275
- isRequired: false,
276
- transformFunction: null
277
- },
278
- disabled: {
279
- classPropertyName: "disabled",
280
- publicName: "disabled",
281
- isSignal: true,
282
- isRequired: false,
283
- transformFunction: null
284
- },
285
- readOnly: {
286
- classPropertyName: "readOnly",
287
- publicName: "readonly",
288
- isSignal: true,
289
- isRequired: false,
290
- transformFunction: null
291
- },
292
- outputFormat: {
293
- classPropertyName: "outputFormat",
294
- publicName: "outputFormat",
295
- isSignal: true,
296
- isRequired: false,
297
- transformFunction: null
298
- }
299
- },
300
- outputs: {
301
- valueChange: "valueChange",
302
- onChange: "onChange",
303
- focus: "focus",
304
- blur: "blur"
305
- },
306
- host: {
307
- properties: {
308
- "class.m-editor-host--sm": "size() === 'sm'",
309
- "class.m-editor-host--md": "size() === 'md'",
310
- "class.m-editor-host--lg": "size() === 'lg'",
311
- "class.m-editor-host--disabled": "isDisabled()",
312
- "class.m-editor-host--focused": "isFocused()"
313
- },
314
- classAttribute: "m-editor-host"
315
- },
316
- providers: [provideValueAccessor(() => MEditor)],
317
- viewQueries: [{
318
- propertyName: "editorElement",
319
- first: true,
320
- predicate: ["editorContainer"],
321
- descendants: true,
322
- isSignal: true
323
- }],
324
- ngImport: i0,
325
- template: "<div class=\"m-editor-container\">\n @if (toolbar()) {\n <div class=\"m-editor-toolbar\">\n <div class=\"m-editor-toolbar__group\">\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isBold()\"\n [disabled]=\"isDisabled()\"\n title=\"Bold (Ctrl+B)\"\n (click)=\"toggleBold()\"\n >\n <i class=\"fas fa-bold\" aria-hidden=\"true\"></i>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isItalic()\"\n [disabled]=\"isDisabled()\"\n title=\"Italic (Ctrl+I)\"\n (click)=\"toggleItalic()\"\n >\n <i class=\"fas fa-italic\" aria-hidden=\"true\"></i>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isStrike()\"\n [disabled]=\"isDisabled()\"\n title=\"Strikethrough\"\n (click)=\"toggleStrike()\"\n >\n <i class=\"fas fa-strikethrough\" aria-hidden=\"true\"></i>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isCode()\"\n [disabled]=\"isDisabled()\"\n title=\"Inline Code\"\n (click)=\"toggleCode()\"\n >\n <i class=\"fas fa-code\" aria-hidden=\"true\"></i>\n </button>\n </div>\n\n <span class=\"m-editor-toolbar__divider\"></span>\n\n <div class=\"m-editor-toolbar__group\">\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isHeading1()\"\n [disabled]=\"isDisabled()\"\n title=\"Heading 1\"\n (click)=\"toggleHeading(1)\"\n >\n <span class=\"m-editor-btn__text\">H1</span>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isHeading2()\"\n [disabled]=\"isDisabled()\"\n title=\"Heading 2\"\n (click)=\"toggleHeading(2)\"\n >\n <span class=\"m-editor-btn__text\">H2</span>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isHeading3()\"\n [disabled]=\"isDisabled()\"\n title=\"Heading 3\"\n (click)=\"toggleHeading(3)\"\n >\n <span class=\"m-editor-btn__text\">H3</span>\n </button>\n </div>\n\n <span class=\"m-editor-toolbar__divider\"></span>\n\n <div class=\"m-editor-toolbar__group\">\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isBulletList()\"\n [disabled]=\"isDisabled()\"\n title=\"Bullet List\"\n (click)=\"toggleBulletList()\"\n >\n <i class=\"fas fa-list-ul\" aria-hidden=\"true\"></i>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isOrderedList()\"\n [disabled]=\"isDisabled()\"\n title=\"Ordered List\"\n (click)=\"toggleOrderedList()\"\n >\n <i class=\"fas fa-list-ol\" aria-hidden=\"true\"></i>\n </button>\n </div>\n\n <span class=\"m-editor-toolbar__divider\"></span>\n\n <div class=\"m-editor-toolbar__group\">\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isBlockquote()\"\n [disabled]=\"isDisabled()\"\n title=\"Blockquote\"\n (click)=\"toggleBlockquote()\"\n >\n <i class=\"fas fa-quote-left\" aria-hidden=\"true\"></i>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isCodeBlock()\"\n [disabled]=\"isDisabled()\"\n title=\"Code Block\"\n (click)=\"toggleCodeBlock()\"\n >\n <i class=\"fas fa-file-code\" aria-hidden=\"true\"></i>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isLink()\"\n [disabled]=\"isDisabled()\"\n title=\"Add / Edit Link\"\n (click)=\"addLink()\"\n >\n <i class=\"fas fa-link\" aria-hidden=\"true\"></i>\n </button>\n @if (isLink()) {\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [disabled]=\"isDisabled()\"\n title=\"Remove Link\"\n (click)=\"unsetLink()\"\n >\n <i class=\"fas fa-link-slash\" aria-hidden=\"true\"></i>\n </button>\n }\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [disabled]=\"isDisabled()\"\n title=\"Horizontal Line\"\n (click)=\"setHorizontalRule()\"\n >\n <i class=\"fas fa-minus\" aria-hidden=\"true\"></i>\n </button>\n </div>\n\n <span class=\"m-editor-toolbar__divider\"></span>\n\n <div class=\"m-editor-toolbar__group\">\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [disabled]=\"isDisabled()\"\n title=\"Undo (Ctrl+Z)\"\n (click)=\"undo()\"\n >\n <i class=\"fas fa-rotate-left\" aria-hidden=\"true\"></i>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [disabled]=\"isDisabled()\"\n title=\"Redo (Ctrl+Y)\"\n (click)=\"redo()\"\n >\n <i class=\"fas fa-rotate-right\" aria-hidden=\"true\"></i>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [disabled]=\"isDisabled()\"\n title=\"Clear Formatting\"\n (click)=\"clearFormatting()\"\n >\n <i class=\"fas fa-eraser\" aria-hidden=\"true\"></i>\n </button>\n </div>\n </div>\n }\n\n <div\n #editorContainer\n class=\"m-editor-content\"\n [style.height]=\"height() || null\"\n [style.min-height]=\"minHeight()\"\n [style.max-height]=\"maxHeight()\"\n ></div>\n</div>\n",
326
- changeDetection: i0.ChangeDetectionStrategy.Eager
327
- });
328
- };
329
- i0.ɵɵngDeclareClassMetadata({
330
- minVersion: "12.0.0",
331
- version: "22.2.0",
332
- ngImport: i0,
333
- type: MEditor,
334
- decorators: [{
335
- type: Component,
336
- args: [{
337
- selector: "m-editor",
338
- providers: [provideValueAccessor(() => MEditor)],
339
- changeDetection: ChangeDetectionStrategy.Eager,
340
- host: {
341
- class: "m-editor-host",
342
- "[class.m-editor-host--sm]": "size() === 'sm'",
343
- "[class.m-editor-host--md]": "size() === 'md'",
344
- "[class.m-editor-host--lg]": "size() === 'lg'",
345
- "[class.m-editor-host--disabled]": "isDisabled()",
346
- "[class.m-editor-host--focused]": "isFocused()"
347
- },
348
- template: "<div class=\"m-editor-container\">\n @if (toolbar()) {\n <div class=\"m-editor-toolbar\">\n <div class=\"m-editor-toolbar__group\">\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isBold()\"\n [disabled]=\"isDisabled()\"\n title=\"Bold (Ctrl+B)\"\n (click)=\"toggleBold()\"\n >\n <i class=\"fas fa-bold\" aria-hidden=\"true\"></i>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isItalic()\"\n [disabled]=\"isDisabled()\"\n title=\"Italic (Ctrl+I)\"\n (click)=\"toggleItalic()\"\n >\n <i class=\"fas fa-italic\" aria-hidden=\"true\"></i>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isStrike()\"\n [disabled]=\"isDisabled()\"\n title=\"Strikethrough\"\n (click)=\"toggleStrike()\"\n >\n <i class=\"fas fa-strikethrough\" aria-hidden=\"true\"></i>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isCode()\"\n [disabled]=\"isDisabled()\"\n title=\"Inline Code\"\n (click)=\"toggleCode()\"\n >\n <i class=\"fas fa-code\" aria-hidden=\"true\"></i>\n </button>\n </div>\n\n <span class=\"m-editor-toolbar__divider\"></span>\n\n <div class=\"m-editor-toolbar__group\">\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isHeading1()\"\n [disabled]=\"isDisabled()\"\n title=\"Heading 1\"\n (click)=\"toggleHeading(1)\"\n >\n <span class=\"m-editor-btn__text\">H1</span>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isHeading2()\"\n [disabled]=\"isDisabled()\"\n title=\"Heading 2\"\n (click)=\"toggleHeading(2)\"\n >\n <span class=\"m-editor-btn__text\">H2</span>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isHeading3()\"\n [disabled]=\"isDisabled()\"\n title=\"Heading 3\"\n (click)=\"toggleHeading(3)\"\n >\n <span class=\"m-editor-btn__text\">H3</span>\n </button>\n </div>\n\n <span class=\"m-editor-toolbar__divider\"></span>\n\n <div class=\"m-editor-toolbar__group\">\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isBulletList()\"\n [disabled]=\"isDisabled()\"\n title=\"Bullet List\"\n (click)=\"toggleBulletList()\"\n >\n <i class=\"fas fa-list-ul\" aria-hidden=\"true\"></i>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isOrderedList()\"\n [disabled]=\"isDisabled()\"\n title=\"Ordered List\"\n (click)=\"toggleOrderedList()\"\n >\n <i class=\"fas fa-list-ol\" aria-hidden=\"true\"></i>\n </button>\n </div>\n\n <span class=\"m-editor-toolbar__divider\"></span>\n\n <div class=\"m-editor-toolbar__group\">\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isBlockquote()\"\n [disabled]=\"isDisabled()\"\n title=\"Blockquote\"\n (click)=\"toggleBlockquote()\"\n >\n <i class=\"fas fa-quote-left\" aria-hidden=\"true\"></i>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isCodeBlock()\"\n [disabled]=\"isDisabled()\"\n title=\"Code Block\"\n (click)=\"toggleCodeBlock()\"\n >\n <i class=\"fas fa-file-code\" aria-hidden=\"true\"></i>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isLink()\"\n [disabled]=\"isDisabled()\"\n title=\"Add / Edit Link\"\n (click)=\"addLink()\"\n >\n <i class=\"fas fa-link\" aria-hidden=\"true\"></i>\n </button>\n @if (isLink()) {\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [disabled]=\"isDisabled()\"\n title=\"Remove Link\"\n (click)=\"unsetLink()\"\n >\n <i class=\"fas fa-link-slash\" aria-hidden=\"true\"></i>\n </button>\n }\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [disabled]=\"isDisabled()\"\n title=\"Horizontal Line\"\n (click)=\"setHorizontalRule()\"\n >\n <i class=\"fas fa-minus\" aria-hidden=\"true\"></i>\n </button>\n </div>\n\n <span class=\"m-editor-toolbar__divider\"></span>\n\n <div class=\"m-editor-toolbar__group\">\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [disabled]=\"isDisabled()\"\n title=\"Undo (Ctrl+Z)\"\n (click)=\"undo()\"\n >\n <i class=\"fas fa-rotate-left\" aria-hidden=\"true\"></i>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [disabled]=\"isDisabled()\"\n title=\"Redo (Ctrl+Y)\"\n (click)=\"redo()\"\n >\n <i class=\"fas fa-rotate-right\" aria-hidden=\"true\"></i>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [disabled]=\"isDisabled()\"\n title=\"Clear Formatting\"\n (click)=\"clearFormatting()\"\n >\n <i class=\"fas fa-eraser\" aria-hidden=\"true\"></i>\n </button>\n </div>\n </div>\n }\n\n <div\n #editorContainer\n class=\"m-editor-content\"\n [style.height]=\"height() || null\"\n [style.min-height]=\"minHeight()\"\n [style.max-height]=\"maxHeight()\"\n ></div>\n</div>\n"
349
- }]
350
- }],
351
- ctorParameters: () => [],
352
- propDecorators: {
353
- editorElement: [{
354
- type: i0.ViewChild,
355
- args: ["editorContainer", { isSignal: true }]
356
- }],
357
- placeholder: [{
358
- type: i0.Input,
359
- args: [{
360
- isSignal: true,
361
- alias: "placeholder",
362
- required: false
363
- }]
364
- }],
365
- value: [{
366
- type: i0.Input,
367
- args: [{
368
- isSignal: true,
369
- alias: "value",
370
- required: false
371
- }]
372
- }],
373
- size: [{
374
- type: i0.Input,
375
- args: [{
376
- isSignal: true,
377
- alias: "size",
378
- required: false
379
- }]
380
- }],
381
- height: [{
382
- type: i0.Input,
383
- args: [{
384
- isSignal: true,
385
- alias: "height",
386
- required: false
387
- }]
388
- }],
389
- minHeight: [{
390
- type: i0.Input,
391
- args: [{
392
- isSignal: true,
393
- alias: "minHeight",
394
- required: false
395
- }]
396
- }],
397
- maxHeight: [{
398
- type: i0.Input,
399
- args: [{
400
- isSignal: true,
401
- alias: "maxHeight",
402
- required: false
403
- }]
404
- }],
405
- toolbar: [{
406
- type: i0.Input,
407
- args: [{
408
- isSignal: true,
409
- alias: "toolbar",
410
- required: false
411
- }]
412
- }],
413
- disabled: [{
414
- type: i0.Input,
415
- args: [{
416
- isSignal: true,
417
- alias: "disabled",
418
- required: false
419
- }]
420
- }],
421
- readOnly: [{
422
- type: i0.Input,
423
- args: [{
424
- isSignal: true,
425
- alias: "readonly",
426
- required: false
427
- }]
428
- }],
429
- outputFormat: [{
430
- type: i0.Input,
431
- args: [{
432
- isSignal: true,
433
- alias: "outputFormat",
434
- required: false
435
- }]
436
- }],
437
- valueChange: [{
438
- type: i0.Output,
439
- args: ["valueChange"]
440
- }],
441
- onChange: [{
442
- type: i0.Output,
443
- args: ["onChange"]
444
- }],
445
- focus: [{
446
- type: i0.Output,
447
- args: ["focus"]
448
- }],
449
- blur: [{
450
- type: i0.Output,
451
- args: ["blur"]
452
- }]
453
- }
454
- });
455
- export { MEditor };
1
+ import * as i0 from '@angular/core';
2
+ import { inject, ElementRef, viewChild, input, booleanAttribute, output, signal, computed, effect, ChangeDetectionStrategy, Component } from '@angular/core';
3
+ import { Editor } from '@tiptap/core';
4
+ import StarterKit from '@tiptap/starter-kit';
5
+ import Placeholder from '@tiptap/extension-placeholder';
6
+ import Link from '@tiptap/extension-link';
7
+ import { noopTouched, MIcon, provideValueAccessor } from '@maliardic/ma-ui';
8
+
9
+ class MEditor {
10
+ elementRef = inject(ElementRef);
11
+ editorElement = viewChild("editorContainer", /* @ts-ignore */
12
+ ...(ngDevMode ? [{ debugName: "editorElement" }] : /* istanbul ignore next */ []));
13
+ editor = null;
14
+ placeholder = input("Write something...", /* @ts-ignore */
15
+ ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
16
+ value = input("", /* @ts-ignore */
17
+ ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
18
+ size = input("md", /* @ts-ignore */
19
+ ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
20
+ height = input("", /* @ts-ignore */
21
+ ...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
22
+ minHeight = input("150px", /* @ts-ignore */
23
+ ...(ngDevMode ? [{ debugName: "minHeight" }] : /* istanbul ignore next */ []));
24
+ maxHeight = input("500px", /* @ts-ignore */
25
+ ...(ngDevMode ? [{ debugName: "maxHeight" }] : /* istanbul ignore next */ []));
26
+ toolbar = input(true, { ...(ngDevMode ? { debugName: "toolbar" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
27
+ disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
28
+ readOnly = input(false, { ...(ngDevMode ? { debugName: "readOnly" } : /* istanbul ignore next */ {}), alias: "readonly",
29
+ transform: booleanAttribute });
30
+ outputFormat = input("html", /* @ts-ignore */
31
+ ...(ngDevMode ? [{ debugName: "outputFormat" }] : /* istanbul ignore next */ []));
32
+ valueChange = output();
33
+ onChange = output();
34
+ focus = output();
35
+ blur = output();
36
+ disabledFromControl = signal(false, /* @ts-ignore */
37
+ ...(ngDevMode ? [{ debugName: "disabledFromControl" }] : /* istanbul ignore next */ []));
38
+ isFocused = signal(false, /* @ts-ignore */
39
+ ...(ngDevMode ? [{ debugName: "isFocused" }] : /* istanbul ignore next */ []));
40
+ isDisabled = computed(() => this.disabled() || this.readOnly() || this.disabledFromControl(), /* @ts-ignore */
41
+ ...(ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []));
42
+ // Active toolbar states
43
+ isBold = signal(false, /* @ts-ignore */
44
+ ...(ngDevMode ? [{ debugName: "isBold" }] : /* istanbul ignore next */ []));
45
+ isItalic = signal(false, /* @ts-ignore */
46
+ ...(ngDevMode ? [{ debugName: "isItalic" }] : /* istanbul ignore next */ []));
47
+ isStrike = signal(false, /* @ts-ignore */
48
+ ...(ngDevMode ? [{ debugName: "isStrike" }] : /* istanbul ignore next */ []));
49
+ isCode = signal(false, /* @ts-ignore */
50
+ ...(ngDevMode ? [{ debugName: "isCode" }] : /* istanbul ignore next */ []));
51
+ isHeading1 = signal(false, /* @ts-ignore */
52
+ ...(ngDevMode ? [{ debugName: "isHeading1" }] : /* istanbul ignore next */ []));
53
+ isHeading2 = signal(false, /* @ts-ignore */
54
+ ...(ngDevMode ? [{ debugName: "isHeading2" }] : /* istanbul ignore next */ []));
55
+ isHeading3 = signal(false, /* @ts-ignore */
56
+ ...(ngDevMode ? [{ debugName: "isHeading3" }] : /* istanbul ignore next */ []));
57
+ isBulletList = signal(false, /* @ts-ignore */
58
+ ...(ngDevMode ? [{ debugName: "isBulletList" }] : /* istanbul ignore next */ []));
59
+ isOrderedList = signal(false, /* @ts-ignore */
60
+ ...(ngDevMode ? [{ debugName: "isOrderedList" }] : /* istanbul ignore next */ []));
61
+ isBlockquote = signal(false, /* @ts-ignore */
62
+ ...(ngDevMode ? [{ debugName: "isBlockquote" }] : /* istanbul ignore next */ []));
63
+ isCodeBlock = signal(false, /* @ts-ignore */
64
+ ...(ngDevMode ? [{ debugName: "isCodeBlock" }] : /* istanbul ignore next */ []));
65
+ isLink = signal(false, /* @ts-ignore */
66
+ ...(ngDevMode ? [{ debugName: "isLink" }] : /* istanbul ignore next */ []));
67
+ usingValueAccessor = false;
68
+ onControlChange = () => undefined;
69
+ onTouched = noopTouched;
70
+ initialValuePending = null;
71
+ constructor() {
72
+ effect(() => {
73
+ const val = this.value();
74
+ if (!this.usingValueAccessor && this.editor) {
75
+ this.setContent(val);
76
+ }
77
+ });
78
+ effect(() => {
79
+ const disabled = this.isDisabled();
80
+ if (this.editor) {
81
+ this.editor.setEditable(!disabled);
82
+ }
83
+ });
84
+ }
85
+ ngAfterViewInit() {
86
+ const container = this.editorElement()?.nativeElement;
87
+ if (!container)
88
+ return;
89
+ this.editor = new Editor({
90
+ element: container,
91
+ editable: !this.isDisabled(),
92
+ extensions: [
93
+ StarterKit,
94
+ Placeholder.configure({
95
+ placeholder: () => this.placeholder(),
96
+ }),
97
+ Link.configure({
98
+ openOnClick: false,
99
+ HTMLAttributes: {
100
+ rel: "noopener noreferrer",
101
+ target: "_blank",
102
+ },
103
+ }),
104
+ ],
105
+ content: this.initialValuePending ?? this.value() ?? "",
106
+ onUpdate: () => {
107
+ this.updateActiveStates();
108
+ this.emitChanges();
109
+ },
110
+ onSelectionUpdate: () => {
111
+ this.updateActiveStates();
112
+ },
113
+ onTransaction: () => {
114
+ this.updateActiveStates();
115
+ },
116
+ onFocus: ({ event }) => {
117
+ this.isFocused.set(true);
118
+ this.focus.emit(event);
119
+ },
120
+ onBlur: ({ event }) => {
121
+ this.isFocused.set(false);
122
+ this.onTouched();
123
+ this.blur.emit(event);
124
+ },
125
+ });
126
+ this.updateActiveStates();
127
+ }
128
+ ngOnDestroy() {
129
+ if (this.editor) {
130
+ this.editor.destroy();
131
+ this.editor = null;
132
+ }
133
+ }
134
+ // ControlValueAccessor implementation
135
+ writeValue(value) {
136
+ this.usingValueAccessor = true;
137
+ const content = value ?? "";
138
+ if (this.editor) {
139
+ this.setContent(content);
140
+ }
141
+ else {
142
+ this.initialValuePending = content;
143
+ }
144
+ }
145
+ registerOnChange(fn) {
146
+ this.usingValueAccessor = true;
147
+ this.onControlChange = fn;
148
+ }
149
+ registerOnTouched(fn) {
150
+ this.onTouched = fn;
151
+ }
152
+ setDisabledState(disabled) {
153
+ this.disabledFromControl.set(disabled);
154
+ }
155
+ // Toolbar Actions
156
+ toggleBold() {
157
+ this.editor?.chain().focus().toggleBold().run();
158
+ }
159
+ toggleItalic() {
160
+ this.editor?.chain().focus().toggleItalic().run();
161
+ }
162
+ toggleStrike() {
163
+ this.editor?.chain().focus().toggleStrike().run();
164
+ }
165
+ toggleCode() {
166
+ this.editor?.chain().focus().toggleCode().run();
167
+ }
168
+ toggleHeading(level) {
169
+ this.editor?.chain().focus().toggleHeading({ level }).run();
170
+ }
171
+ toggleBulletList() {
172
+ this.editor?.chain().focus().toggleBulletList().run();
173
+ }
174
+ toggleOrderedList() {
175
+ this.editor?.chain().focus().toggleOrderedList().run();
176
+ }
177
+ toggleBlockquote() {
178
+ this.editor?.chain().focus().toggleBlockquote().run();
179
+ }
180
+ toggleCodeBlock() {
181
+ this.editor?.chain().focus().toggleCodeBlock().run();
182
+ }
183
+ addLink() {
184
+ if (!this.editor)
185
+ return;
186
+ const previousUrl = this.editor.getAttributes("link")["href"];
187
+ const url = window.prompt("URL giriniz:", previousUrl);
188
+ if (url === null)
189
+ return;
190
+ if (url === "") {
191
+ this.editor.chain().focus().extendMarkRange("link").unsetLink().run();
192
+ return;
193
+ }
194
+ this.editor
195
+ .chain()
196
+ .focus()
197
+ .extendMarkRange("link")
198
+ .setLink({ href: url })
199
+ .run();
200
+ }
201
+ unsetLink() {
202
+ this.editor?.chain().focus().unsetLink().run();
203
+ }
204
+ setHorizontalRule() {
205
+ this.editor?.chain().focus().setHorizontalRule().run();
206
+ }
207
+ undo() {
208
+ this.editor?.chain().focus().undo().run();
209
+ }
210
+ redo() {
211
+ this.editor?.chain().focus().redo().run();
212
+ }
213
+ clearFormatting() {
214
+ this.editor?.chain().focus().unsetAllMarks().clearNodes().run();
215
+ }
216
+ setContent(content) {
217
+ if (!this.editor)
218
+ return;
219
+ const currentHtml = this.editor.getHTML();
220
+ if (currentHtml !== content) {
221
+ this.editor.commands.setContent(content);
222
+ this.updateActiveStates();
223
+ }
224
+ }
225
+ updateActiveStates() {
226
+ if (!this.editor)
227
+ return;
228
+ this.isBold.set(this.editor.isActive("bold"));
229
+ this.isItalic.set(this.editor.isActive("italic"));
230
+ this.isStrike.set(this.editor.isActive("strike"));
231
+ this.isCode.set(this.editor.isActive("code"));
232
+ this.isHeading1.set(this.editor.isActive("heading", { level: 1 }));
233
+ this.isHeading2.set(this.editor.isActive("heading", { level: 2 }));
234
+ this.isHeading3.set(this.editor.isActive("heading", { level: 3 }));
235
+ this.isBulletList.set(this.editor.isActive("bulletList"));
236
+ this.isOrderedList.set(this.editor.isActive("orderedList"));
237
+ this.isBlockquote.set(this.editor.isActive("blockquote"));
238
+ this.isCodeBlock.set(this.editor.isActive("codeBlock"));
239
+ this.isLink.set(this.editor.isActive("link"));
240
+ }
241
+ emitChanges() {
242
+ if (!this.editor)
243
+ return;
244
+ const html = this.editor.getHTML();
245
+ const json = this.editor.getJSON();
246
+ const isFormatJson = this.outputFormat() === "json";
247
+ const emitVal = isFormatJson ? JSON.stringify(json) : html;
248
+ this.valueChange.emit(emitVal);
249
+ this.onControlChange(emitVal);
250
+ this.onChange.emit({ html, json });
251
+ }
252
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: MEditor, deps: [], target: i0.ɵɵFactoryTarget.Component });
253
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.0", type: MEditor, isStandalone: true, selector: "m-editor", inputs: { placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, minHeight: { classPropertyName: "minHeight", publicName: "minHeight", isSignal: true, isRequired: false, transformFunction: null }, maxHeight: { classPropertyName: "maxHeight", publicName: "maxHeight", isSignal: true, isRequired: false, transformFunction: null }, toolbar: { classPropertyName: "toolbar", publicName: "toolbar", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, readOnly: { classPropertyName: "readOnly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, outputFormat: { classPropertyName: "outputFormat", publicName: "outputFormat", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange", onChange: "onChange", focus: "focus", blur: "blur" }, host: { properties: { "class.m-editor-host--sm": "size() === 'sm'", "class.m-editor-host--md": "size() === 'md'", "class.m-editor-host--lg": "size() === 'lg'", "class.m-editor-host--disabled": "isDisabled()", "class.m-editor-host--focused": "isFocused()" }, classAttribute: "m-editor-host" }, providers: [provideValueAccessor(() => MEditor)], viewQueries: [{ propertyName: "editorElement", first: true, predicate: ["editorContainer"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"m-editor-container\">\n @if (toolbar()) {\n <div class=\"m-editor-toolbar\">\n <div class=\"m-editor-toolbar__group\">\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isBold()\"\n [disabled]=\"isDisabled()\"\n title=\"Bold (Ctrl+B)\"\n (click)=\"toggleBold()\"\n >\n <m-icon name=\"bold\" />\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isItalic()\"\n [disabled]=\"isDisabled()\"\n title=\"Italic (Ctrl+I)\"\n (click)=\"toggleItalic()\"\n >\n <m-icon name=\"italic\" />\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isStrike()\"\n [disabled]=\"isDisabled()\"\n title=\"Strikethrough\"\n (click)=\"toggleStrike()\"\n >\n <m-icon name=\"strikethrough\" />\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isCode()\"\n [disabled]=\"isDisabled()\"\n title=\"Inline Code\"\n (click)=\"toggleCode()\"\n >\n <m-icon name=\"code\" />\n </button>\n </div>\n\n <span class=\"m-editor-toolbar__divider\"></span>\n\n <div class=\"m-editor-toolbar__group\">\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isHeading1()\"\n [disabled]=\"isDisabled()\"\n title=\"Heading 1\"\n (click)=\"toggleHeading(1)\"\n >\n <span class=\"m-editor-btn__text\">H1</span>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isHeading2()\"\n [disabled]=\"isDisabled()\"\n title=\"Heading 2\"\n (click)=\"toggleHeading(2)\"\n >\n <span class=\"m-editor-btn__text\">H2</span>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isHeading3()\"\n [disabled]=\"isDisabled()\"\n title=\"Heading 3\"\n (click)=\"toggleHeading(3)\"\n >\n <span class=\"m-editor-btn__text\">H3</span>\n </button>\n </div>\n\n <span class=\"m-editor-toolbar__divider\"></span>\n\n <div class=\"m-editor-toolbar__group\">\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isBulletList()\"\n [disabled]=\"isDisabled()\"\n title=\"Bullet List\"\n (click)=\"toggleBulletList()\"\n >\n <m-icon name=\"list\" />\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isOrderedList()\"\n [disabled]=\"isDisabled()\"\n title=\"Ordered List\"\n (click)=\"toggleOrderedList()\"\n >\n <m-icon name=\"list-numbers\" />\n </button>\n </div>\n\n <span class=\"m-editor-toolbar__divider\"></span>\n\n <div class=\"m-editor-toolbar__group\">\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isBlockquote()\"\n [disabled]=\"isDisabled()\"\n title=\"Blockquote\"\n (click)=\"toggleBlockquote()\"\n >\n <m-icon name=\"quote\" />\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isCodeBlock()\"\n [disabled]=\"isDisabled()\"\n title=\"Code Block\"\n (click)=\"toggleCodeBlock()\"\n >\n <m-icon name=\"code-block\" />\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isLink()\"\n [disabled]=\"isDisabled()\"\n title=\"Add / Edit Link\"\n (click)=\"addLink()\"\n >\n <m-icon name=\"link\" />\n </button>\n @if (isLink()) {\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [disabled]=\"isDisabled()\"\n title=\"Remove Link\"\n (click)=\"unsetLink()\"\n >\n <m-icon name=\"link-off\" />\n </button>\n }\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [disabled]=\"isDisabled()\"\n title=\"Horizontal Line\"\n (click)=\"setHorizontalRule()\"\n >\n <m-icon name=\"minus\" />\n </button>\n </div>\n\n <span class=\"m-editor-toolbar__divider\"></span>\n\n <div class=\"m-editor-toolbar__group\">\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [disabled]=\"isDisabled()\"\n title=\"Undo (Ctrl+Z)\"\n (click)=\"undo()\"\n >\n <m-icon name=\"undo\" />\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [disabled]=\"isDisabled()\"\n title=\"Redo (Ctrl+Y)\"\n (click)=\"redo()\"\n >\n <m-icon name=\"redo\" />\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [disabled]=\"isDisabled()\"\n title=\"Clear Formatting\"\n (click)=\"clearFormatting()\"\n >\n <m-icon name=\"eraser\" />\n </button>\n </div>\n </div>\n }\n\n <div\n #editorContainer\n class=\"m-editor-content\"\n [style.height]=\"height() || null\"\n [style.min-height]=\"minHeight()\"\n [style.max-height]=\"maxHeight()\"\n ></div>\n</div>\n", dependencies: [{ kind: "component", type: MIcon, selector: "m-icon", inputs: ["name", "label"] }], changeDetection: i0.ChangeDetectionStrategy.Eager });
254
+ }
255
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: MEditor, decorators: [{
256
+ type: Component,
257
+ args: [{ imports: [MIcon], selector: "m-editor", providers: [provideValueAccessor(() => MEditor)], changeDetection: ChangeDetectionStrategy.Eager, host: {
258
+ class: "m-editor-host",
259
+ "[class.m-editor-host--sm]": "size() === 'sm'",
260
+ "[class.m-editor-host--md]": "size() === 'md'",
261
+ "[class.m-editor-host--lg]": "size() === 'lg'",
262
+ "[class.m-editor-host--disabled]": "isDisabled()",
263
+ "[class.m-editor-host--focused]": "isFocused()",
264
+ }, template: "<div class=\"m-editor-container\">\n @if (toolbar()) {\n <div class=\"m-editor-toolbar\">\n <div class=\"m-editor-toolbar__group\">\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isBold()\"\n [disabled]=\"isDisabled()\"\n title=\"Bold (Ctrl+B)\"\n (click)=\"toggleBold()\"\n >\n <m-icon name=\"bold\" />\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isItalic()\"\n [disabled]=\"isDisabled()\"\n title=\"Italic (Ctrl+I)\"\n (click)=\"toggleItalic()\"\n >\n <m-icon name=\"italic\" />\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isStrike()\"\n [disabled]=\"isDisabled()\"\n title=\"Strikethrough\"\n (click)=\"toggleStrike()\"\n >\n <m-icon name=\"strikethrough\" />\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isCode()\"\n [disabled]=\"isDisabled()\"\n title=\"Inline Code\"\n (click)=\"toggleCode()\"\n >\n <m-icon name=\"code\" />\n </button>\n </div>\n\n <span class=\"m-editor-toolbar__divider\"></span>\n\n <div class=\"m-editor-toolbar__group\">\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isHeading1()\"\n [disabled]=\"isDisabled()\"\n title=\"Heading 1\"\n (click)=\"toggleHeading(1)\"\n >\n <span class=\"m-editor-btn__text\">H1</span>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isHeading2()\"\n [disabled]=\"isDisabled()\"\n title=\"Heading 2\"\n (click)=\"toggleHeading(2)\"\n >\n <span class=\"m-editor-btn__text\">H2</span>\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isHeading3()\"\n [disabled]=\"isDisabled()\"\n title=\"Heading 3\"\n (click)=\"toggleHeading(3)\"\n >\n <span class=\"m-editor-btn__text\">H3</span>\n </button>\n </div>\n\n <span class=\"m-editor-toolbar__divider\"></span>\n\n <div class=\"m-editor-toolbar__group\">\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isBulletList()\"\n [disabled]=\"isDisabled()\"\n title=\"Bullet List\"\n (click)=\"toggleBulletList()\"\n >\n <m-icon name=\"list\" />\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isOrderedList()\"\n [disabled]=\"isDisabled()\"\n title=\"Ordered List\"\n (click)=\"toggleOrderedList()\"\n >\n <m-icon name=\"list-numbers\" />\n </button>\n </div>\n\n <span class=\"m-editor-toolbar__divider\"></span>\n\n <div class=\"m-editor-toolbar__group\">\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isBlockquote()\"\n [disabled]=\"isDisabled()\"\n title=\"Blockquote\"\n (click)=\"toggleBlockquote()\"\n >\n <m-icon name=\"quote\" />\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isCodeBlock()\"\n [disabled]=\"isDisabled()\"\n title=\"Code Block\"\n (click)=\"toggleCodeBlock()\"\n >\n <m-icon name=\"code-block\" />\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [class.m-editor-btn--active]=\"isLink()\"\n [disabled]=\"isDisabled()\"\n title=\"Add / Edit Link\"\n (click)=\"addLink()\"\n >\n <m-icon name=\"link\" />\n </button>\n @if (isLink()) {\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [disabled]=\"isDisabled()\"\n title=\"Remove Link\"\n (click)=\"unsetLink()\"\n >\n <m-icon name=\"link-off\" />\n </button>\n }\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [disabled]=\"isDisabled()\"\n title=\"Horizontal Line\"\n (click)=\"setHorizontalRule()\"\n >\n <m-icon name=\"minus\" />\n </button>\n </div>\n\n <span class=\"m-editor-toolbar__divider\"></span>\n\n <div class=\"m-editor-toolbar__group\">\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [disabled]=\"isDisabled()\"\n title=\"Undo (Ctrl+Z)\"\n (click)=\"undo()\"\n >\n <m-icon name=\"undo\" />\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [disabled]=\"isDisabled()\"\n title=\"Redo (Ctrl+Y)\"\n (click)=\"redo()\"\n >\n <m-icon name=\"redo\" />\n </button>\n <button\n class=\"m-editor-btn\"\n type=\"button\"\n [disabled]=\"isDisabled()\"\n title=\"Clear Formatting\"\n (click)=\"clearFormatting()\"\n >\n <m-icon name=\"eraser\" />\n </button>\n </div>\n </div>\n }\n\n <div\n #editorContainer\n class=\"m-editor-content\"\n [style.height]=\"height() || null\"\n [style.min-height]=\"minHeight()\"\n [style.max-height]=\"maxHeight()\"\n ></div>\n</div>\n" }]
265
+ }], ctorParameters: () => [], propDecorators: { editorElement: [{ type: i0.ViewChild, args: ["editorContainer", { isSignal: true }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], minHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "minHeight", required: false }] }], maxHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxHeight", required: false }] }], toolbar: [{ type: i0.Input, args: [{ isSignal: true, alias: "toolbar", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], readOnly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], outputFormat: [{ type: i0.Input, args: [{ isSignal: true, alias: "outputFormat", required: false }] }], valueChange: [{ type: i0.Output, args: ["valueChange"] }], onChange: [{ type: i0.Output, args: ["onChange"] }], focus: [{ type: i0.Output, args: ["focus"] }], blur: [{ type: i0.Output, args: ["blur"] }] } });
456
266
 
457
- //# sourceMappingURL=maliardic-ma-ui-editor.mjs.map
267
+ /**
268
+ * Generated bundle index. Do not edit.
269
+ */
270
+
271
+ export { MEditor };
272
+ //# sourceMappingURL=maliardic-ma-ui-editor.mjs.map