@kelsoncm/tiptap-ng 0.0.0-stage → 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 kelsoncm
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,49 @@
1
- # Temporary Holding Version
1
+ # @kelsoncm/tiptap-ng
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Componente Angular (`<kt-editor>`) de editor de texto rico sobre o
4
+ [@kelsoncm/tiptap-core](https://www.npmjs.com/package/@kelsoncm/tiptap-core). Integra com Reactive Forms e
5
+ `ngModel` (valor = HTML) e, se presente, com o ngx-translate.
6
+
7
+ Exemplos ao vivo e documentação: <https://tiptap-by-kelsoncm.github.io/tiptap-core/docs/angular.html>
8
+
9
+ ## Instalação
10
+
11
+ ```bash
12
+ npm install @kelsoncm/tiptap-ng @kelsoncm/tiptap-core @tiptap/core @tiptap/pm @ngx-translate/core
13
+ ```
14
+
15
+ Requer Angular 22. O pacote `@ngx-translate/core` precisa estar instalado, mas configurar o provider é
16
+ opcional: sem ele, o core traduz a interface sozinho.
17
+
18
+ Inclua o CSS do core (por exemplo, em `styles` do `angular.json`):
19
+
20
+ ```json
21
+ "styles": ["node_modules/@kelsoncm/tiptap-core/dist/styles/kelson-editor.css", "src/styles.scss"]
22
+ ```
23
+
24
+ Os ícones padrão são classes do Font Awesome; troque por outros com `[options]="{ renderIcon }"`.
25
+
26
+ ## Uso
27
+
28
+ ```ts
29
+ import { Component } from "@angular/core";
30
+ import { FormControl, ReactiveFormsModule } from "@angular/forms";
31
+ import { EditorComponent } from "@kelsoncm/tiptap-ng";
32
+
33
+ @Component({
34
+ selector: "app-root",
35
+ imports: [ReactiveFormsModule, EditorComponent],
36
+ template: `<kt-editor [formControl]="body" toolbarPreset="full" [wordLimit]="200"></kt-editor>`,
37
+ })
38
+ export class AppComponent {
39
+ body = new FormControl("<p>Olá</p>");
40
+ }
41
+ ```
42
+
43
+ O seletor `<app-editor>` também funciona, para apps escritos antes da biblioteca.
44
+
45
+ Inputs, outputs e idioma: veja o [README do repositório](https://github.com/tiptap-by-kelsoncm/tiptap-ng#readme).
46
+
47
+ ## Licença
48
+
49
+ [MIT](https://github.com/tiptap-by-kelsoncm/tiptap-ng/blob/main/LICENSE)
@@ -0,0 +1,434 @@
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectionStrategy, Component, EventEmitter, Input, NgZone, Output, ViewChild, ViewEncapsulation, forwardRef, inject } from "@angular/core";
3
+ import { NG_VALUE_ACCESSOR } from "@angular/forms";
4
+ import { BALLOON_PRESET, TOOLBAR_PRESETS, createEditorUI, defaultIconRenderer } from "@kelsoncm/tiptap-core";
5
+ import { TranslateService } from "@ngx-translate/core";
6
+ const FONT_AWESOME = {
7
+ undo: "fa-solid fa-rotate-left",
8
+ redo: "fa-solid fa-rotate-right",
9
+ bold: "fa-solid fa-bold",
10
+ italic: "fa-solid fa-italic",
11
+ underline: "fa-solid fa-underline",
12
+ strikethrough: "fa-solid fa-strikethrough",
13
+ code: "fa-solid fa-code",
14
+ "code-block": "fa-solid fa-file-code",
15
+ subscript: "fa-solid fa-subscript",
16
+ superscript: "fa-solid fa-superscript",
17
+ "remove-format": "fa-solid fa-text-slash",
18
+ quote: "fa-solid fa-quote-left",
19
+ "list-ul": "fa-solid fa-list-ul",
20
+ "list-ol": "fa-solid fa-list-ol",
21
+ "task-list": "fa-solid fa-list-check",
22
+ indent: "fa-solid fa-indent",
23
+ outdent: "fa-solid fa-outdent",
24
+ "align-left": "fa-solid fa-align-left",
25
+ "align-center": "fa-solid fa-align-center",
26
+ "align-right": "fa-solid fa-align-right",
27
+ "align-justify": "fa-solid fa-align-justify",
28
+ table: "fa-solid fa-table",
29
+ "horizontal-rule": "fa-solid fa-minus",
30
+ "page-break": "fa-solid fa-scissors",
31
+ link: "fa-solid fa-link",
32
+ unlink: "fa-solid fa-link-slash",
33
+ "open-link": "fa-solid fa-arrow-up-right-from-square",
34
+ anchor: "fa-solid fa-anchor",
35
+ image: "fa-solid fa-image",
36
+ upload: "fa-solid fa-upload",
37
+ gallery: "fa-solid fa-images",
38
+ attach: "fa-solid fa-paperclip",
39
+ media: "fa-solid fa-photo-film",
40
+ mention: "fa-solid fa-at",
41
+ emoji: "fa-regular fa-face-smile",
42
+ chart: "fa-solid fa-chart-column",
43
+ search: "fa-solid fa-magnifying-glass",
44
+ print: "fa-solid fa-print",
45
+ fullscreen: "fa-solid fa-expand",
46
+ source: "fa-solid fa-code",
47
+ comment: "fa-regular fa-comment",
48
+ "format-painter": "fa-solid fa-paintbrush",
49
+ mic: "fa-solid fa-microphone",
50
+ language: "fa-solid fa-language",
51
+ a11y: "fa-solid fa-universal-access"
52
+ };
53
+ const fontAwesomeIcon = (icon, commandId) => {
54
+ const classes = FONT_AWESOME[icon];
55
+ if (!classes) return defaultIconRenderer(icon, commandId);
56
+ const element = document.createElement("i");
57
+ element.className = classes;
58
+ element.setAttribute("aria-hidden", "true");
59
+ return element;
60
+ };
61
+ const toCoreLocale = (lang) => (lang ?? "pt-BR").replace("_", "-").replace(/-(\w+)$/, (_m, region) => `-${region.toUpperCase()}`);
62
+ const COMMANDS_BY_INPUT = {
63
+ enableBold: ["bold"],
64
+ enableItalic: ["italic"],
65
+ enableStrike: ["strike"],
66
+ enableCode: ["code", "codeBlock"],
67
+ enableMention: ["mention"]
68
+ };
69
+ function cleanListParagraphs(html) {
70
+ let previous;
71
+ let current = html;
72
+ const pattern = /(<li\b[^>]*>)\s*<p\b[^>]*>([\s\S]*?)<\/p>\s*(<\/li>)/gi;
73
+ let guard = 0;
74
+ do {
75
+ previous = current;
76
+ current = current.replace(pattern, (_m, start, inner, end) => `${start}${inner}${end}`);
77
+ guard++;
78
+ } while (current !== previous && guard < 10);
79
+ return current;
80
+ }
81
+ var EditorComponent = class EditorComponent {
82
+ constructor() {
83
+ this.placeholder = "editor.placeholders.default";
84
+ this.minHeight = "200px";
85
+ this.toolbarPreset = "full";
86
+ this.mode = "toolbar";
87
+ this.readonly = false;
88
+ this.enableHeading = true;
89
+ this.enableBold = true;
90
+ this.enableItalic = true;
91
+ this.enableStrike = true;
92
+ this.enableCode = true;
93
+ this.enableMention = true;
94
+ this.enableSubscript = true;
95
+ this.enableSuperscript = true;
96
+ this.enableLineHeight = true;
97
+ this.enableFontFamily = true;
98
+ this.enableFontSize = true;
99
+ this.enableTextColor = true;
100
+ this.enableHighlight = true;
101
+ this.enableTextAlign = true;
102
+ this.enableTable = true;
103
+ this.enableBalloonMenu = true;
104
+ this.enablePageBreak = true;
105
+ this.enableTableOfContents = false;
106
+ this.mentionItems = [
107
+ {
108
+ id: "inicioEdital",
109
+ label: "inicioEdital"
110
+ },
111
+ {
112
+ id: "fimEdital",
113
+ label: "fimEdital"
114
+ },
115
+ {
116
+ id: "nomeEdital",
117
+ label: "nomeEdital"
118
+ },
119
+ {
120
+ id: "descricaoEdital",
121
+ label: "descricaoEdital"
122
+ }
123
+ ];
124
+ this.showFooter = true;
125
+ this.cleanListParagraphs = true;
126
+ this.options = {};
127
+ this.jsonChange = new EventEmitter();
128
+ this.htmlChange = new EventEmitter();
129
+ this.focus = new EventEmitter();
130
+ this.blur = new EventEmitter();
131
+ this.ready = new EventEmitter();
132
+ this.zone = inject(NgZone);
133
+ this.translate = inject(TranslateService, { optional: true });
134
+ this.ui = null;
135
+ this.value = "";
136
+ this.disabled = false;
137
+ this.onChange = () => void 0;
138
+ this.onTouched = () => void 0;
139
+ this.handleUpdate = () => {
140
+ const html = this.html();
141
+ const json = this.ui?.editor.getJSON();
142
+ this.zone.run(() => {
143
+ this.value = html;
144
+ this.onChange(html);
145
+ this.htmlChange.emit(html);
146
+ if (json) this.jsonChange.emit(json);
147
+ });
148
+ };
149
+ this.handleFocus = () => {
150
+ this.zone.run(() => this.focus.emit());
151
+ };
152
+ this.handleBlur = () => {
153
+ this.zone.run(() => {
154
+ this.onTouched();
155
+ this.blur.emit();
156
+ });
157
+ };
158
+ }
159
+ get editor() {
160
+ return this.ui;
161
+ }
162
+ ngAfterViewInit() {
163
+ this.create();
164
+ this.langSubscription = this.translate?.onLangChange.subscribe(({ lang }) => this.ui?.i18n.setLocale(toCoreLocale(lang)));
165
+ }
166
+ ngOnChanges(changes) {
167
+ if (!this.ui) return;
168
+ if (Object.keys(changes).every((key) => key === "mode" || key === "readonly")) {
169
+ this.applyMode();
170
+ return;
171
+ }
172
+ this.value = this.html();
173
+ this.destroy();
174
+ this.create();
175
+ }
176
+ ngOnDestroy() {
177
+ this.langSubscription?.unsubscribe();
178
+ this.destroy();
179
+ }
180
+ writeValue(value) {
181
+ this.value = value ?? "";
182
+ this.ui?.editor.commands.setContent(this.value, { emitUpdate: false });
183
+ }
184
+ registerOnChange(fn) {
185
+ this.onChange = fn;
186
+ }
187
+ registerOnTouched(fn) {
188
+ this.onTouched = fn;
189
+ }
190
+ setDisabledState(disabled) {
191
+ this.disabled = disabled;
192
+ this.applyMode();
193
+ }
194
+ features() {
195
+ return {
196
+ subscript: this.enableSubscript,
197
+ superscript: this.enableSuperscript,
198
+ lineHeight: this.enableLineHeight,
199
+ fontFamily: this.enableFontFamily,
200
+ fontSize: this.enableFontSize,
201
+ textColor: this.enableTextColor,
202
+ highlight: this.enableHighlight,
203
+ textAlign: this.enableTextAlign,
204
+ table: this.enableTable,
205
+ pageBreak: this.enablePageBreak,
206
+ tableOfContents: this.enableTableOfContents
207
+ };
208
+ }
209
+ limits() {
210
+ const limits = {};
211
+ if (this.characterLimit !== void 0) limits.maxCharacters = this.characterLimit;
212
+ if (this.characterMinimum !== void 0) limits.minCharacters = this.characterMinimum;
213
+ if (this.wordLimit !== void 0) limits.maxWords = this.wordLimit;
214
+ if (this.wordMinimum !== void 0) limits.minWords = this.wordMinimum;
215
+ if (this.paragraphLimit !== void 0) limits.maxParagraphs = this.paragraphLimit;
216
+ if (this.paragraphMinimum !== void 0) limits.minParagraphs = this.paragraphMinimum;
217
+ return limits;
218
+ }
219
+ filterItems(items) {
220
+ const hidden = new Set(Object.entries(COMMANDS_BY_INPUT).filter(([input]) => !this[input]).flatMap(([, commands]) => commands));
221
+ if (!this.enableHeading) hidden.add("heading");
222
+ return items.filter((item) => {
223
+ if (typeof item === "string") return !hidden.has(item) && !(item.startsWith("heading-") && hidden.has("heading"));
224
+ if (item.type === "commands") return !(hidden.has("heading") && item.commands.some((c) => c.startsWith("heading-")));
225
+ return true;
226
+ });
227
+ }
228
+ create() {
229
+ const element = this.host.nativeElement;
230
+ const placeholder = this.translate?.instant(this.placeholder) ?? this.placeholder;
231
+ this.zone.runOutsideAngular(() => {
232
+ this.ui = createEditorUI(element, {
233
+ ...this.options,
234
+ content: this.value,
235
+ mode: this.mode,
236
+ toolbar: this.filterItems(TOOLBAR_PRESETS[this.toolbarPreset] ?? TOOLBAR_PRESETS.full),
237
+ balloon: this.enableBalloonMenu ? this.filterItems(BALLOON_PRESET) : false,
238
+ placeholder,
239
+ minHeight: this.minHeight,
240
+ ...this.maxHeight ? { maxHeight: this.maxHeight } : {},
241
+ statusBar: this.showFooter,
242
+ limits: {
243
+ ...this.limits(),
244
+ ...this.options.limits
245
+ },
246
+ features: {
247
+ ...this.features(),
248
+ ...this.options.features
249
+ },
250
+ ...this.enableHeading ? {} : { starterKit: {
251
+ heading: false,
252
+ ...this.options.starterKit
253
+ } },
254
+ ...this.enableMention && this.mentionItems.length && !this.options.mentions ? { mentions: { items: this.mentionItems } } : {},
255
+ i18n: this.options.i18n ?? { locale: toCoreLocale(this.translate?.getCurrentLang() ?? void 0) },
256
+ renderIcon: this.options.renderIcon ?? fontAwesomeIcon
257
+ });
258
+ });
259
+ const ui = this.ui;
260
+ if (!ui) return;
261
+ ui.editor.on("update", this.handleUpdate);
262
+ ui.editor.on("focus", this.handleFocus);
263
+ ui.editor.on("blur", this.handleBlur);
264
+ this.applyMode();
265
+ this.ready.emit(ui);
266
+ }
267
+ destroy() {
268
+ if (!this.ui) return;
269
+ this.ui.editor.off("update", this.handleUpdate);
270
+ this.ui.editor.off("focus", this.handleFocus);
271
+ this.ui.editor.off("blur", this.handleBlur);
272
+ this.ui.destroy();
273
+ this.ui = null;
274
+ }
275
+ applyMode() {
276
+ this.ui?.setMode(this.readonly || this.disabled ? "readonly" : this.mode);
277
+ }
278
+ html() {
279
+ if (!this.ui || this.ui.editor.isEmpty) return "";
280
+ const html = this.ui.editor.getHTML().replace(/(?:<p><\/p>)+$/, "");
281
+ return this.cleanListParagraphs ? cleanListParagraphs(html) : html;
282
+ }
283
+ static {
284
+ this.ɵfac = i0.ɵɵngDeclareFactory({
285
+ minVersion: "12.0.0",
286
+ version: "22.3.0",
287
+ ngImport: i0,
288
+ type: EditorComponent,
289
+ deps: [],
290
+ target: i0.ɵɵFactoryTarget.Component
291
+ });
292
+ }
293
+ static {
294
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
295
+ minVersion: "14.0.0",
296
+ version: "22.3.0",
297
+ type: EditorComponent,
298
+ isStandalone: true,
299
+ selector: "kt-editor, app-editor",
300
+ inputs: {
301
+ placeholder: "placeholder",
302
+ minHeight: "minHeight",
303
+ maxHeight: "maxHeight",
304
+ toolbarPreset: "toolbarPreset",
305
+ mode: "mode",
306
+ readonly: "readonly",
307
+ enableHeading: "enableHeading",
308
+ enableBold: "enableBold",
309
+ enableItalic: "enableItalic",
310
+ enableStrike: "enableStrike",
311
+ enableCode: "enableCode",
312
+ enableMention: "enableMention",
313
+ enableSubscript: "enableSubscript",
314
+ enableSuperscript: "enableSuperscript",
315
+ enableLineHeight: "enableLineHeight",
316
+ enableFontFamily: "enableFontFamily",
317
+ enableFontSize: "enableFontSize",
318
+ enableTextColor: "enableTextColor",
319
+ enableHighlight: "enableHighlight",
320
+ enableTextAlign: "enableTextAlign",
321
+ enableTable: "enableTable",
322
+ enableBalloonMenu: "enableBalloonMenu",
323
+ enablePageBreak: "enablePageBreak",
324
+ enableTableOfContents: "enableTableOfContents",
325
+ mentionItems: "mentionItems",
326
+ showFooter: "showFooter",
327
+ characterLimit: "characterLimit",
328
+ characterMinimum: "characterMinimum",
329
+ wordLimit: "wordLimit",
330
+ wordMinimum: "wordMinimum",
331
+ paragraphLimit: "paragraphLimit",
332
+ paragraphMinimum: "paragraphMinimum",
333
+ cleanListParagraphs: "cleanListParagraphs",
334
+ options: "options"
335
+ },
336
+ outputs: {
337
+ jsonChange: "jsonChange",
338
+ htmlChange: "htmlChange",
339
+ focus: "focus",
340
+ blur: "blur",
341
+ ready: "ready"
342
+ },
343
+ providers: [{
344
+ provide: NG_VALUE_ACCESSOR,
345
+ useExisting: forwardRef(() => EditorComponent),
346
+ multi: true
347
+ }],
348
+ viewQueries: [{
349
+ propertyName: "host",
350
+ first: true,
351
+ predicate: ["host"],
352
+ descendants: true,
353
+ static: true
354
+ }],
355
+ usesOnChanges: true,
356
+ ngImport: i0,
357
+ template: "<div #host class=\"app-editor-host\"></div>",
358
+ isInline: true,
359
+ styles: ["app-editor{display:block}app-editor .kt-editor{--kt-accent: var(--interactive, #1351b4);--kt-active-bg: var(--blue-warm-vivid-5, #dbe8fb)}\n"],
360
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
361
+ encapsulation: i0.ViewEncapsulation.None
362
+ });
363
+ }
364
+ };
365
+ i0.ɵɵngDeclareClassMetadata({
366
+ minVersion: "12.0.0",
367
+ version: "22.3.0",
368
+ ngImport: i0,
369
+ type: EditorComponent,
370
+ decorators: [{
371
+ type: Component,
372
+ args: [{
373
+ selector: "kt-editor, app-editor",
374
+ standalone: true,
375
+ template: "<div #host class=\"app-editor-host\"></div>",
376
+ encapsulation: ViewEncapsulation.None,
377
+ changeDetection: ChangeDetectionStrategy.OnPush,
378
+ providers: [{
379
+ provide: NG_VALUE_ACCESSOR,
380
+ useExisting: forwardRef(() => EditorComponent),
381
+ multi: true
382
+ }],
383
+ styles: ["app-editor{display:block}app-editor .kt-editor{--kt-accent: var(--interactive, #1351b4);--kt-active-bg: var(--blue-warm-vivid-5, #dbe8fb)}\n"]
384
+ }]
385
+ }],
386
+ propDecorators: {
387
+ host: [{
388
+ type: ViewChild,
389
+ args: ["host", { static: true }]
390
+ }],
391
+ placeholder: [{ type: Input }],
392
+ minHeight: [{ type: Input }],
393
+ maxHeight: [{ type: Input }],
394
+ toolbarPreset: [{ type: Input }],
395
+ mode: [{ type: Input }],
396
+ readonly: [{ type: Input }],
397
+ enableHeading: [{ type: Input }],
398
+ enableBold: [{ type: Input }],
399
+ enableItalic: [{ type: Input }],
400
+ enableStrike: [{ type: Input }],
401
+ enableCode: [{ type: Input }],
402
+ enableMention: [{ type: Input }],
403
+ enableSubscript: [{ type: Input }],
404
+ enableSuperscript: [{ type: Input }],
405
+ enableLineHeight: [{ type: Input }],
406
+ enableFontFamily: [{ type: Input }],
407
+ enableFontSize: [{ type: Input }],
408
+ enableTextColor: [{ type: Input }],
409
+ enableHighlight: [{ type: Input }],
410
+ enableTextAlign: [{ type: Input }],
411
+ enableTable: [{ type: Input }],
412
+ enableBalloonMenu: [{ type: Input }],
413
+ enablePageBreak: [{ type: Input }],
414
+ enableTableOfContents: [{ type: Input }],
415
+ mentionItems: [{ type: Input }],
416
+ showFooter: [{ type: Input }],
417
+ characterLimit: [{ type: Input }],
418
+ characterMinimum: [{ type: Input }],
419
+ wordLimit: [{ type: Input }],
420
+ wordMinimum: [{ type: Input }],
421
+ paragraphLimit: [{ type: Input }],
422
+ paragraphMinimum: [{ type: Input }],
423
+ cleanListParagraphs: [{ type: Input }],
424
+ options: [{ type: Input }],
425
+ jsonChange: [{ type: Output }],
426
+ htmlChange: [{ type: Output }],
427
+ focus: [{ type: Output }],
428
+ blur: [{ type: Output }],
429
+ ready: [{ type: Output }]
430
+ }
431
+ });
432
+ export { EditorComponent, cleanListParagraphs, fontAwesomeIcon, toCoreLocale };
433
+
434
+ //# sourceMappingURL=kelsoncm-tiptap-ng.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kelsoncm-tiptap-ng.mjs","names":[],"sources":["../../../projects/tiptap-ng/src/lib/icons.ts","../../../projects/tiptap-ng/src/lib/editor.component.ts"],"sourcesContent":["import { defaultIconRenderer, type IconRenderer } from '@kelsoncm/tiptap-core';\n\n/** Core icon names -> Font Awesome 7 classes. Unknown icons fall back to the core text icons. */\nconst FONT_AWESOME: Readonly<Record<string, string>> = {\n undo: 'fa-solid fa-rotate-left',\n redo: 'fa-solid fa-rotate-right',\n bold: 'fa-solid fa-bold',\n italic: 'fa-solid fa-italic',\n underline: 'fa-solid fa-underline',\n strikethrough: 'fa-solid fa-strikethrough',\n code: 'fa-solid fa-code',\n 'code-block': 'fa-solid fa-file-code',\n subscript: 'fa-solid fa-subscript',\n superscript: 'fa-solid fa-superscript',\n 'remove-format': 'fa-solid fa-text-slash',\n quote: 'fa-solid fa-quote-left',\n 'list-ul': 'fa-solid fa-list-ul',\n 'list-ol': 'fa-solid fa-list-ol',\n 'task-list': 'fa-solid fa-list-check',\n indent: 'fa-solid fa-indent',\n outdent: 'fa-solid fa-outdent',\n 'align-left': 'fa-solid fa-align-left',\n 'align-center': 'fa-solid fa-align-center',\n 'align-right': 'fa-solid fa-align-right',\n 'align-justify': 'fa-solid fa-align-justify',\n table: 'fa-solid fa-table',\n 'horizontal-rule': 'fa-solid fa-minus',\n 'page-break': 'fa-solid fa-scissors',\n link: 'fa-solid fa-link',\n unlink: 'fa-solid fa-link-slash',\n 'open-link': 'fa-solid fa-arrow-up-right-from-square',\n anchor: 'fa-solid fa-anchor',\n image: 'fa-solid fa-image',\n upload: 'fa-solid fa-upload',\n gallery: 'fa-solid fa-images',\n attach: 'fa-solid fa-paperclip',\n media: 'fa-solid fa-photo-film',\n mention: 'fa-solid fa-at',\n emoji: 'fa-regular fa-face-smile',\n chart: 'fa-solid fa-chart-column',\n search: 'fa-solid fa-magnifying-glass',\n print: 'fa-solid fa-print',\n fullscreen: 'fa-solid fa-expand',\n source: 'fa-solid fa-code',\n comment: 'fa-regular fa-comment',\n 'format-painter': 'fa-solid fa-paintbrush',\n mic: 'fa-solid fa-microphone',\n language: 'fa-solid fa-language',\n a11y: 'fa-solid fa-universal-access',\n};\n\nexport const fontAwesomeIcon: IconRenderer = (icon, commandId) => {\n const classes = FONT_AWESOME[icon];\n if (!classes) return defaultIconRenderer(icon, commandId);\n const element = document.createElement('i');\n element.className = classes;\n element.setAttribute('aria-hidden', 'true');\n return element;\n};\n","import {\n AfterViewInit,\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n EventEmitter,\n forwardRef,\n inject,\n Input,\n NgZone,\n OnChanges,\n OnDestroy,\n Output,\n SimpleChanges,\n ViewChild,\n ViewEncapsulation,\n} from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport {\n BALLOON_PRESET,\n createEditorUI,\n TOOLBAR_PRESETS,\n type DocumentLimits,\n type EditorFeatures,\n type EditorMode,\n type EditorUI,\n type EditorUIOptions,\n type MentionItem,\n type ToolbarItem,\n} from '@kelsoncm/tiptap-core';\nimport type { JSONContent } from '@tiptap/core';\nimport { TranslateService } from '@ngx-translate/core';\nimport { Subscription } from 'rxjs';\n\nimport { fontAwesomeIcon } from './icons';\n\n/** ngx-translate language codes (pt_br) -> core locales (pt-BR). */\nexport const toCoreLocale = (lang: string | undefined): string =>\n (lang ?? 'pt-BR').replace('_', '-').replace(/-(\\w+)$/, (_m, region: string) => `-${region.toUpperCase()}`);\n\n/** Toolbar commands hidden by each `enable*` input. */\nconst COMMANDS_BY_INPUT: Record<string, readonly string[]> = {\n enableBold: ['bold'],\n enableItalic: ['italic'],\n enableStrike: ['strike'],\n enableCode: ['code', 'codeBlock'],\n enableMention: ['mention'],\n};\n\n/** Removes `<p>` wrappers directly inside `<li>` (format kept from the first tiptap-ng). */\nexport function cleanListParagraphs(html: string): string {\n let previous: string;\n let current = html;\n const pattern = /(<li\\b[^>]*>)\\s*<p\\b[^>]*>([\\s\\S]*?)<\\/p>\\s*(<\\/li>)/gi;\n let guard = 0;\n do {\n previous = current;\n current = current.replace(pattern, (_m, start: string, inner: string, end: string) => `${start}${inner}${end}`);\n guard++;\n } while (current !== previous && guard < 10);\n return current;\n}\n\n/**\n * `<kt-editor>`: Angular wrapper of `createEditorUI` from `@kelsoncm/tiptap-core`, usable\n * with reactive forms and `ngModel` (value = HTML). `<app-editor>` is kept for apps written\n * before the library existed.\n */\n@Component({\n selector: 'kt-editor, app-editor',\n standalone: true,\n template: '<div #host class=\"app-editor-host\"></div>',\n styleUrl: './editor.component.scss',\n encapsulation: ViewEncapsulation.None,\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => EditorComponent), multi: true }],\n})\nexport class EditorComponent implements AfterViewInit, OnChanges, OnDestroy, ControlValueAccessor {\n @ViewChild('host', { static: true }) host!: ElementRef<HTMLDivElement>;\n\n // ---- appearance and mode\n /** i18n key (resolved by the core or ngx-translate) or literal text. */\n @Input() placeholder = 'editor.placeholders.default';\n @Input() minHeight = '200px';\n @Input() maxHeight?: string;\n @Input() toolbarPreset: 'minimal' | 'basic' | 'full' = 'full';\n @Input() mode: EditorMode = 'toolbar';\n @Input() readonly = false;\n\n // ---- features (same names as the first tiptap-ng)\n @Input() enableHeading = true;\n @Input() enableBold = true;\n @Input() enableItalic = true;\n @Input() enableStrike = true;\n @Input() enableCode = true;\n @Input() enableMention = true;\n @Input() enableSubscript = true;\n @Input() enableSuperscript = true;\n @Input() enableLineHeight = true;\n @Input() enableFontFamily = true;\n @Input() enableFontSize = true;\n @Input() enableTextColor = true;\n @Input() enableHighlight = true;\n @Input() enableTextAlign = true;\n @Input() enableTable = true;\n @Input() enableBalloonMenu = true;\n @Input() enablePageBreak = true;\n @Input() enableTableOfContents = false;\n @Input() mentionItems: MentionItem[] = [\n { id: 'inicioEdital', label: 'inicioEdital' },\n { id: 'fimEdital', label: 'fimEdital' },\n { id: 'nomeEdital', label: 'nomeEdital' },\n { id: 'descricaoEdital', label: 'descricaoEdital' },\n ];\n\n // ---- footer and limits\n @Input() showFooter = true;\n @Input() characterLimit?: number;\n @Input() characterMinimum?: number;\n @Input() wordLimit?: number;\n @Input() wordMinimum?: number;\n @Input() paragraphLimit?: number;\n @Input() paragraphMinimum?: number;\n\n /** Keep the original `<li>text</li>` HTML (no `<p>` inside list items). */\n @Input() cleanListParagraphs = true;\n /** Any other `createEditorUI` option (media, revision, checkers, plugins...). */\n @Input() options: Partial<EditorUIOptions> = {};\n\n @Output() jsonChange = new EventEmitter<JSONContent>();\n @Output() htmlChange = new EventEmitter<string>();\n // eslint-disable-next-line @angular-eslint/no-output-native\n @Output() focus = new EventEmitter<void>();\n // eslint-disable-next-line @angular-eslint/no-output-native\n @Output() blur = new EventEmitter<void>();\n @Output() ready = new EventEmitter<EditorUI>();\n\n private readonly zone = inject(NgZone);\n private readonly translate = inject(TranslateService, { optional: true });\n private ui: EditorUI | null = null;\n private value = '';\n private disabled = false;\n private langSubscription?: Subscription;\n private onChange: (value: string) => void = () => undefined;\n private onTouched: () => void = () => undefined;\n\n /** The core editor (commands, i18n, Tiptap instance). */\n get editor(): EditorUI | null {\n return this.ui;\n }\n\n ngAfterViewInit(): void {\n this.create();\n this.langSubscription = this.translate?.onLangChange.subscribe(({ lang }) =>\n this.ui?.i18n.setLocale(toCoreLocale(lang)),\n );\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n if (!this.ui) return;\n const keys = Object.keys(changes);\n if (keys.every((key) => key === 'mode' || key === 'readonly')) {\n this.applyMode();\n return;\n }\n // Structural options: rebuild keeping the content.\n this.value = this.html();\n this.destroy();\n this.create();\n }\n\n ngOnDestroy(): void {\n this.langSubscription?.unsubscribe();\n this.destroy();\n }\n\n // ---- ControlValueAccessor\n writeValue(value: string | null): void {\n this.value = value ?? '';\n this.ui?.editor.commands.setContent(this.value, { emitUpdate: false });\n }\n\n registerOnChange(fn: (value: string) => void): void {\n this.onChange = fn;\n }\n\n registerOnTouched(fn: () => void): void {\n this.onTouched = fn;\n }\n\n setDisabledState(disabled: boolean): void {\n this.disabled = disabled;\n this.applyMode();\n }\n\n // ---- internals\n private features(): Partial<EditorFeatures> {\n return {\n subscript: this.enableSubscript,\n superscript: this.enableSuperscript,\n lineHeight: this.enableLineHeight,\n fontFamily: this.enableFontFamily,\n fontSize: this.enableFontSize,\n textColor: this.enableTextColor,\n highlight: this.enableHighlight,\n textAlign: this.enableTextAlign,\n table: this.enableTable,\n pageBreak: this.enablePageBreak,\n tableOfContents: this.enableTableOfContents,\n };\n }\n\n private limits(): DocumentLimits {\n const limits: DocumentLimits = {};\n if (this.characterLimit !== undefined) limits.maxCharacters = this.characterLimit;\n if (this.characterMinimum !== undefined) limits.minCharacters = this.characterMinimum;\n if (this.wordLimit !== undefined) limits.maxWords = this.wordLimit;\n if (this.wordMinimum !== undefined) limits.minWords = this.wordMinimum;\n if (this.paragraphLimit !== undefined) limits.maxParagraphs = this.paragraphLimit;\n if (this.paragraphMinimum !== undefined) limits.minParagraphs = this.paragraphMinimum;\n return limits;\n }\n\n /** Preset minus the commands disabled by `enable*` inputs. */\n private filterItems(items: readonly ToolbarItem[]): ToolbarItem[] {\n const hidden = new Set(\n Object.entries(COMMANDS_BY_INPUT)\n .filter(([input]) => !(this as unknown as Record<string, boolean>)[input])\n .flatMap(([, commands]) => commands),\n );\n if (!this.enableHeading) hidden.add('heading');\n return items.filter((item) => {\n if (typeof item === 'string') return !hidden.has(item) && !(item.startsWith('heading-') && hidden.has('heading'));\n if (item.type === 'commands') return !(hidden.has('heading') && item.commands.some((c) => c.startsWith('heading-')));\n return true;\n });\n }\n\n private create(): void {\n const element = this.host.nativeElement;\n const placeholder = this.translate?.instant(this.placeholder) ?? this.placeholder;\n this.zone.runOutsideAngular(() => {\n this.ui = createEditorUI(element, {\n ...this.options,\n content: this.value,\n mode: this.mode,\n toolbar: this.filterItems(TOOLBAR_PRESETS[this.toolbarPreset] ?? TOOLBAR_PRESETS.full),\n balloon: this.enableBalloonMenu ? this.filterItems(BALLOON_PRESET) : false,\n placeholder,\n minHeight: this.minHeight,\n ...(this.maxHeight ? { maxHeight: this.maxHeight } : {}),\n statusBar: this.showFooter,\n limits: { ...this.limits(), ...this.options.limits },\n features: { ...this.features(), ...this.options.features },\n ...(this.enableHeading ? {} : { starterKit: { heading: false, ...this.options.starterKit } }),\n ...(this.enableMention && this.mentionItems.length && !this.options.mentions\n ? { mentions: { items: this.mentionItems } }\n : {}),\n i18n: this.options.i18n ?? { locale: toCoreLocale(this.translate?.getCurrentLang() ?? undefined) },\n renderIcon: this.options.renderIcon ?? fontAwesomeIcon,\n });\n });\n const ui = this.ui as EditorUI | null;\n if (!ui) return;\n ui.editor.on('update', this.handleUpdate);\n ui.editor.on('focus', this.handleFocus);\n ui.editor.on('blur', this.handleBlur);\n this.applyMode();\n this.ready.emit(ui);\n }\n\n private destroy(): void {\n if (!this.ui) return;\n this.ui.editor.off('update', this.handleUpdate);\n this.ui.editor.off('focus', this.handleFocus);\n this.ui.editor.off('blur', this.handleBlur);\n this.ui.destroy();\n this.ui = null;\n }\n\n private applyMode(): void {\n this.ui?.setMode(this.readonly || this.disabled ? 'readonly' : this.mode);\n }\n\n private html(): string {\n if (!this.ui || this.ui.editor.isEmpty) return '';\n // The empty paragraph the editor keeps after tables/lists is an editing aid, not content.\n const html = this.ui.editor.getHTML().replace(/(?:<p><\\/p>)+$/, '');\n return this.cleanListParagraphs ? cleanListParagraphs(html) : html;\n }\n\n private handleUpdate = (): void => {\n const html = this.html();\n const json = this.ui?.editor.getJSON();\n this.zone.run(() => {\n this.value = html;\n this.onChange(html);\n this.htmlChange.emit(html);\n if (json) this.jsonChange.emit(json);\n });\n };\n\n private handleFocus = (): void => {\n this.zone.run(() => this.focus.emit());\n };\n\n private handleBlur = (): void => {\n this.zone.run(() => {\n this.onTouched();\n this.blur.emit();\n });\n };\n}\n"],"mappings":";;;;;AAGA,MAAM,eAAiD;CACrD,MAAM;CACN,MAAM;CACN,MAAM;CACN,QAAQ;CACR,WAAW;CACX,eAAe;CACf,MAAM;CACN,cAAc;CACd,WAAW;CACX,aAAa;CACb,iBAAiB;CACjB,OAAO;CACP,WAAW;CACX,WAAW;CACX,aAAa;CACb,QAAQ;CACR,SAAS;CACT,cAAc;CACd,gBAAgB;CAChB,eAAe;CACf,iBAAiB;CACjB,OAAO;CACP,mBAAmB;CACnB,cAAc;CACd,MAAM;CACN,QAAQ;CACR,aAAa;CACb,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,OAAO;CACP,SAAS;CACT,OAAO;CACP,OAAO;CACP,QAAQ;CACR,OAAO;CACP,YAAY;CACZ,QAAQ;CACR,SAAS;CACT,kBAAkB;CAClB,KAAK;CACL,UAAU;CACV,MAAM;AACP;AAED,MAAa,mBAAiC,MAAM,cAAa;CAC/D,MAAM,UAAU,aAAa;CAC7B,IAAI,CAAC,SAAS,OAAO,oBAAoB,M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,M;E,kBACA,MAAA,M;E,oBACA,MAAA,M;E,sBACA,MAAA,M;E,qBACA,MAAA,M;E,qBACA,MAAA,M;E,mBACA,MAAA,M;E,oBACA,MAAA,M;E,oBACA,MAAA,M;E,oBACA,MAAA,M;E,gBACA,MAAA,M;E,sBACA,MAAA,M;E,oBACA,MAAA,M;E,0BACA,MAAA,M;E,iBACA,MAAA,M;E,eAQA,MAAA,M;E,mBACA,MAAA,M;E,qBACA,MAAA,M;E,cACA,MAAA,M;E,gBACA,MAAA,M;E,mBACA,MAAA,M;E,qBACA,MAAA,M;E,wBAGA,MAAA,M;E,YAEA,MAAA,M;E,eAEA,MAAA,O;E,eACA,MAAA,O;E,UAEA,MAAA,O;E,SAEA,MAAA,O;E,UACA,MAAA,O"}
package/package.json CHANGED
@@ -1,6 +1,49 @@
1
1
  {
2
+ "description": "Componente Angular (<kt-editor>) de editor de texto rico sobre @kelsoncm/tiptap-core, com Reactive Forms, ngModel e ngx-translate.",
3
+ "license": "MIT",
4
+ "author": "Kelson da Costa Medeiros <kelsoncm@gmail.com>",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/tiptap-by-kelsoncm/tiptap-ng.git",
8
+ "directory": "projects/tiptap-ng"
9
+ },
10
+ "homepage": "https://tiptap-by-kelsoncm.github.io/tiptap-core/docs/angular.html",
11
+ "bugs": "https://github.com/tiptap-by-kelsoncm/tiptap-ng/issues",
12
+ "keywords": [
13
+ "angular",
14
+ "tiptap",
15
+ "prosemirror",
16
+ "wysiwyg",
17
+ "editor",
18
+ "rich-text"
19
+ ],
20
+ "peerDependencies": {
21
+ "@angular/common": "^22.3.0",
22
+ "@angular/core": "^22.3.0",
23
+ "@angular/forms": "^22.3.0",
24
+ "@kelsoncm/tiptap-core": "^0.18.2",
25
+ "@ngx-translate/core": "^18.1.0",
26
+ "@tiptap/core": "^3.35.0",
27
+ "rxjs": "~7.8.0"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "sideEffects": false,
2
33
  "name": "@kelsoncm/tiptap-ng",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
34
+ "type": "module",
35
+ "main": "./fesm2022/kelsoncm-tiptap-ng.mjs",
36
+ "module": "./fesm2022/kelsoncm-tiptap-ng.mjs",
37
+ "typings": "./types/kelsoncm-tiptap-ng.d.ts",
38
+ "types": "./types/kelsoncm-tiptap-ng.d.ts",
39
+ "exports": {
40
+ ".": {
41
+ "types": "./types/kelsoncm-tiptap-ng.d.ts",
42
+ "default": "./fesm2022/kelsoncm-tiptap-ng.mjs"
43
+ },
44
+ "./package.json": {
45
+ "default": "./package.json"
46
+ }
47
+ },
48
+ "version": "0.2.0"
49
+ }
@@ -0,0 +1,233 @@
1
+ import * as i0 from "@angular/core";
2
+ import { AfterViewInit, ElementRef, EventEmitter, OnChanges, OnDestroy, SimpleChanges } from "@angular/core";
3
+ import { ControlValueAccessor } from "@angular/forms";
4
+ import { EditorMode, EditorUI, EditorUIOptions, IconRenderer, MentionItem } from "@kelsoncm/tiptap-core";
5
+ import { JSONContent } from "@tiptap/core";
6
+ /** ngx-translate language codes (pt_br) -> core locales (pt-BR). */
7
+ export declare const toCoreLocale: (lang: string | undefined) => string;
8
+ /** Removes `<p>` wrappers directly inside `<li>` (format kept from the first tiptap-ng). */
9
+ export declare function cleanListParagraphs(html: string): string;
10
+ /**
11
+ * `<kt-editor>`: Angular wrapper of `createEditorUI` from `@kelsoncm/tiptap-core`, usable
12
+ * with reactive forms and `ngModel` (value = HTML). `<app-editor>` is kept for apps written
13
+ * before the library existed.
14
+ */
15
+ export declare class EditorComponent implements AfterViewInit, OnChanges, OnDestroy, ControlValueAccessor {
16
+ host: ElementRef<HTMLDivElement>;
17
+ /** i18n key (resolved by the core or ngx-translate) or literal text. */
18
+ placeholder: string;
19
+ minHeight: string;
20
+ maxHeight?: string;
21
+ toolbarPreset: 'minimal' | 'basic' | 'full';
22
+ mode: EditorMode;
23
+ readonly: boolean;
24
+ enableHeading: boolean;
25
+ enableBold: boolean;
26
+ enableItalic: boolean;
27
+ enableStrike: boolean;
28
+ enableCode: boolean;
29
+ enableMention: boolean;
30
+ enableSubscript: boolean;
31
+ enableSuperscript: boolean;
32
+ enableLineHeight: boolean;
33
+ enableFontFamily: boolean;
34
+ enableFontSize: boolean;
35
+ enableTextColor: boolean;
36
+ enableHighlight: boolean;
37
+ enableTextAlign: boolean;
38
+ enableTable: boolean;
39
+ enableBalloonMenu: boolean;
40
+ enablePageBreak: boolean;
41
+ enableTableOfContents: boolean;
42
+ mentionItems: MentionItem[];
43
+ showFooter: boolean;
44
+ characterLimit?: number;
45
+ characterMinimum?: number;
46
+ wordLimit?: number;
47
+ wordMinimum?: number;
48
+ paragraphLimit?: number;
49
+ paragraphMinimum?: number;
50
+ /** Keep the original `<li>text</li>` HTML (no `<p>` inside list items). */
51
+ cleanListParagraphs: boolean;
52
+ /** Any other `createEditorUI` option (media, revision, checkers, plugins...). */
53
+ options: Partial<EditorUIOptions>;
54
+ jsonChange: EventEmitter<JSONContent>;
55
+ htmlChange: EventEmitter<string>;
56
+ focus: EventEmitter<void>;
57
+ blur: EventEmitter<void>;
58
+ ready: EventEmitter<EditorUI>;
59
+ private readonly zone;
60
+ private readonly translate;
61
+ private ui;
62
+ private value;
63
+ private disabled;
64
+ private langSubscription?;
65
+ private onChange;
66
+ private onTouched;
67
+ /** The core editor (commands, i18n, Tiptap instance). */
68
+ get editor(): EditorUI | null;
69
+ ngAfterViewInit(): void;
70
+ ngOnChanges(changes: SimpleChanges): void;
71
+ ngOnDestroy(): void;
72
+ writeValue(value: string | null): void;
73
+ registerOnChange(fn: (value: string) => void): void;
74
+ registerOnTouched(fn: () => void): void;
75
+ setDisabledState(disabled: boolean): void;
76
+ private features;
77
+ private limits;
78
+ /** Preset minus the commands disabled by `enable*` inputs. */
79
+ private filterItems;
80
+ private create;
81
+ private destroy;
82
+ private applyMode;
83
+ private html;
84
+ private handleUpdate;
85
+ private handleFocus;
86
+ private handleBlur;
87
+ static ɵfac: i0.ɵɵFactoryDeclaration<EditorComponent, never>;
88
+ static ɵcmp: i0.ɵɵComponentDeclaration<EditorComponent, "kt-editor, app-editor", never, {
89
+ "placeholder": {
90
+ "alias": "placeholder";
91
+ "required": false;
92
+ };
93
+ "minHeight": {
94
+ "alias": "minHeight";
95
+ "required": false;
96
+ };
97
+ "maxHeight": {
98
+ "alias": "maxHeight";
99
+ "required": false;
100
+ };
101
+ "toolbarPreset": {
102
+ "alias": "toolbarPreset";
103
+ "required": false;
104
+ };
105
+ "mode": {
106
+ "alias": "mode";
107
+ "required": false;
108
+ };
109
+ "readonly": {
110
+ "alias": "readonly";
111
+ "required": false;
112
+ };
113
+ "enableHeading": {
114
+ "alias": "enableHeading";
115
+ "required": false;
116
+ };
117
+ "enableBold": {
118
+ "alias": "enableBold";
119
+ "required": false;
120
+ };
121
+ "enableItalic": {
122
+ "alias": "enableItalic";
123
+ "required": false;
124
+ };
125
+ "enableStrike": {
126
+ "alias": "enableStrike";
127
+ "required": false;
128
+ };
129
+ "enableCode": {
130
+ "alias": "enableCode";
131
+ "required": false;
132
+ };
133
+ "enableMention": {
134
+ "alias": "enableMention";
135
+ "required": false;
136
+ };
137
+ "enableSubscript": {
138
+ "alias": "enableSubscript";
139
+ "required": false;
140
+ };
141
+ "enableSuperscript": {
142
+ "alias": "enableSuperscript";
143
+ "required": false;
144
+ };
145
+ "enableLineHeight": {
146
+ "alias": "enableLineHeight";
147
+ "required": false;
148
+ };
149
+ "enableFontFamily": {
150
+ "alias": "enableFontFamily";
151
+ "required": false;
152
+ };
153
+ "enableFontSize": {
154
+ "alias": "enableFontSize";
155
+ "required": false;
156
+ };
157
+ "enableTextColor": {
158
+ "alias": "enableTextColor";
159
+ "required": false;
160
+ };
161
+ "enableHighlight": {
162
+ "alias": "enableHighlight";
163
+ "required": false;
164
+ };
165
+ "enableTextAlign": {
166
+ "alias": "enableTextAlign";
167
+ "required": false;
168
+ };
169
+ "enableTable": {
170
+ "alias": "enableTable";
171
+ "required": false;
172
+ };
173
+ "enableBalloonMenu": {
174
+ "alias": "enableBalloonMenu";
175
+ "required": false;
176
+ };
177
+ "enablePageBreak": {
178
+ "alias": "enablePageBreak";
179
+ "required": false;
180
+ };
181
+ "enableTableOfContents": {
182
+ "alias": "enableTableOfContents";
183
+ "required": false;
184
+ };
185
+ "mentionItems": {
186
+ "alias": "mentionItems";
187
+ "required": false;
188
+ };
189
+ "showFooter": {
190
+ "alias": "showFooter";
191
+ "required": false;
192
+ };
193
+ "characterLimit": {
194
+ "alias": "characterLimit";
195
+ "required": false;
196
+ };
197
+ "characterMinimum": {
198
+ "alias": "characterMinimum";
199
+ "required": false;
200
+ };
201
+ "wordLimit": {
202
+ "alias": "wordLimit";
203
+ "required": false;
204
+ };
205
+ "wordMinimum": {
206
+ "alias": "wordMinimum";
207
+ "required": false;
208
+ };
209
+ "paragraphLimit": {
210
+ "alias": "paragraphLimit";
211
+ "required": false;
212
+ };
213
+ "paragraphMinimum": {
214
+ "alias": "paragraphMinimum";
215
+ "required": false;
216
+ };
217
+ "cleanListParagraphs": {
218
+ "alias": "cleanListParagraphs";
219
+ "required": false;
220
+ };
221
+ "options": {
222
+ "alias": "options";
223
+ "required": false;
224
+ };
225
+ }, {
226
+ "jsonChange": "jsonChange";
227
+ "htmlChange": "htmlChange";
228
+ "focus": "focus";
229
+ "blur": "blur";
230
+ "ready": "ready";
231
+ }, never, never, true, never>;
232
+ }
233
+ export declare const fontAwesomeIcon: IconRenderer;