|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright (c) 2000 - 2023 Vaadin Ltd. |
| 4 | + * |
| 5 | + * This program is available under Vaadin Commercial License and Service Terms. |
| 6 | + * |
| 7 | + * |
| 8 | + * See https://vaadin.com/commercial-license-and-service-terms for the full |
| 9 | + * license. |
| 10 | + */ |
| 11 | +import type { Constructor } from '@open-wc/dedupe-mixin'; |
| 12 | + |
| 13 | +export interface RichTextEditorI18n { |
| 14 | + undo: string; |
| 15 | + redo: string; |
| 16 | + bold: string; |
| 17 | + italic: string; |
| 18 | + underline: string; |
| 19 | + strike: string; |
| 20 | + h1: string; |
| 21 | + h2: string; |
| 22 | + h3: string; |
| 23 | + subscript: string; |
| 24 | + superscript: string; |
| 25 | + listOrdered: string; |
| 26 | + listBullet: string; |
| 27 | + alignLeft: string; |
| 28 | + alignCenter: string; |
| 29 | + alignRight: string; |
| 30 | + image: string; |
| 31 | + link: string; |
| 32 | + blockquote: string; |
| 33 | + codeBlock: string; |
| 34 | + clean: string; |
| 35 | + linkDialogTitle: string; |
| 36 | + ok: string; |
| 37 | + cancel: string; |
| 38 | + remove: string; |
| 39 | +} |
| 40 | + |
| 41 | +/** |
| 42 | + * Fired when the `htmlValue` property changes. |
| 43 | + */ |
| 44 | +export type RichTextEditorHtmlValueChangedEvent = CustomEvent<{ value: string }>; |
| 45 | + |
| 46 | +/** |
| 47 | + * Fired when the `value` property changes. |
| 48 | + */ |
| 49 | +export type RichTextEditorValueChangedEvent = CustomEvent<{ value: string }>; |
| 50 | + |
| 51 | +export interface RichTextEditorCustomEventMap { |
| 52 | + 'html-value-changed': RichTextEditorHtmlValueChangedEvent; |
| 53 | + |
| 54 | + 'value-changed': RichTextEditorValueChangedEvent; |
| 55 | +} |
| 56 | + |
| 57 | +export declare function RichTextEditorMixin<T extends Constructor<HTMLElement>>( |
| 58 | + base: T, |
| 59 | +): Constructor<RichTextEditorMixinClass> & T; |
| 60 | + |
| 61 | +export declare class RichTextEditorMixinClass { |
| 62 | + /** |
| 63 | + * Value is a list of the operations which describe change to the document. |
| 64 | + * Each of those operations describe the change at the current index. |
| 65 | + * They can be an `insert`, `delete` or `retain`. The format is as follows: |
| 66 | + * |
| 67 | + * ```js |
| 68 | + * [ |
| 69 | + * { insert: 'Hello World' }, |
| 70 | + * { insert: '!', attributes: { bold: true }} |
| 71 | + * ] |
| 72 | + * ``` |
| 73 | + * |
| 74 | + * See also https://github.com/quilljs/delta for detailed documentation. |
| 75 | + */ |
| 76 | + value: string; |
| 77 | + |
| 78 | + /** |
| 79 | + * HTML representation of the rich text editor content. |
| 80 | + */ |
| 81 | + readonly htmlValue: string | null | undefined; |
| 82 | + |
| 83 | + /** |
| 84 | + * When true, the user can not modify, nor copy the editor content. |
| 85 | + */ |
| 86 | + disabled: boolean; |
| 87 | + |
| 88 | + /** |
| 89 | + * When true, the user can not modify the editor content, but can copy it. |
| 90 | + */ |
| 91 | + readonly: boolean; |
| 92 | + |
| 93 | + /** |
| 94 | + * An object used to localize this component. The properties are used |
| 95 | + * e.g. as the tooltips for the editor toolbar buttons. |
| 96 | + */ |
| 97 | + i18n: RichTextEditorI18n; |
| 98 | + |
| 99 | + /** |
| 100 | + * Sets content represented by HTML snippet into the editor. |
| 101 | + * The snippet is interpreted by [Quill's Clipboard matchers](https://quilljs.com/docs/modules/clipboard/#matchers), |
| 102 | + * which may not produce the exactly input HTML. |
| 103 | + * |
| 104 | + * **NOTE:** Improper handling of HTML can lead to cross site scripting (XSS) and failure to sanitize |
| 105 | + * properly is both notoriously error-prone and a leading cause of web vulnerabilities. |
| 106 | + * This method is aptly named to ensure the developer has taken the necessary precautions. |
| 107 | + */ |
| 108 | + dangerouslySetHtmlValue(htmlValue: string): void; |
| 109 | +} |
0 commit comments