@und-ui/richtext 0.0.0-stage → 0.3.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.
@@ -0,0 +1,160 @@
1
+ import { type PropertyValues, type TemplateResult } from 'lit';
2
+ import { UndElement } from '@und-ui/core/base/UndElement';
3
+ export interface RichTextStrings {
4
+ toolbar: string;
5
+ bold: string;
6
+ italic: string;
7
+ underline: string;
8
+ strike: string;
9
+ code: string;
10
+ link: string;
11
+ heading2: string;
12
+ heading3: string;
13
+ bulletList: string;
14
+ numberedList: string;
15
+ quote: string;
16
+ linkUrl: string;
17
+ apply: string;
18
+ removeLink: string;
19
+ cancel: string;
20
+ invalidUrl: string;
21
+ required: string;
22
+ }
23
+ /** Replaces some built-in English strings of `und-rich-text-editor`. Unknown keys and non-strings are ignored. */
24
+ export declare function setRichTextStrings(next: Partial<RichTextStrings>): void;
25
+ /**
26
+ * A small rich text editor: a formatting toolbar (bold, italic, underline,
27
+ * strikethrough, inline code, link, headings, quote, lists), Markdown
28
+ * shortcuts as you type (`## `, `- `, `1. `, `> `, `**bold**`, `` `code` ``),
29
+ * autolinked URLs and native undo.
30
+ *
31
+ * Security first: pasted, dropped and assigned HTML goes through an
32
+ * allowlist sanitizer that rebuilds clean nodes (no HTML-string sinks, safe
33
+ * link URLs only, Trusted Types friendly), and `value` is always sanitized
34
+ * HTML. The editable area is light DOM (ADR 0002), so selection, spell
35
+ * checking and assistive technology work as in a plain contenteditable.
36
+ *
37
+ * Form-associated: submits the sanitized HTML under `name`, and the Markdown
38
+ * under `markdown-name` when set.
39
+ *
40
+ * @summary A small, security-first rich text editor with Markdown shortcuts.
41
+ * @tag und-rich-text-editor
42
+ *
43
+ * @csspart toolbar - The formatting toolbar.
44
+ * @csspart button - Each toolbar button.
45
+ * @csspart link-form - The link address form.
46
+ *
47
+ * @cssprop [--und-rich-text-min-height] - Minimum block size of the editing area (default 8rem).
48
+ * @cssprop [--und-rich-text-max-height] - Maximum block size before the editing area scrolls.
49
+ *
50
+ * @fires input - The content changed.
51
+ * @fires change - The content changed and the editor lost focus.
52
+ */
53
+ export declare class UndRichTextEditor extends UndElement {
54
+ #private;
55
+ static tagName: string;
56
+ static formAssociated: boolean;
57
+ static styles: import("lit").CSSResult;
58
+ static properties: {
59
+ label: {};
60
+ placeholder: {};
61
+ name: {
62
+ reflect: boolean;
63
+ };
64
+ markdownName: {
65
+ attribute: string;
66
+ };
67
+ value: {
68
+ noAccessor: boolean;
69
+ };
70
+ disabled: {
71
+ type: BooleanConstructor;
72
+ reflect: boolean;
73
+ };
74
+ readOnly: {
75
+ type: BooleanConstructor;
76
+ attribute: string;
77
+ reflect: boolean;
78
+ };
79
+ required: {
80
+ type: BooleanConstructor;
81
+ reflect: boolean;
82
+ };
83
+ noToolbar: {
84
+ type: BooleanConstructor;
85
+ attribute: string;
86
+ };
87
+ };
88
+ /**
89
+ * Accessible name (and visible label) of the editing area.
90
+ * @attr label
91
+ */
92
+ label: string | undefined;
93
+ /**
94
+ * Text shown while the editor is empty.
95
+ * @attr placeholder
96
+ */
97
+ placeholder: string | undefined;
98
+ /**
99
+ * Form field name for the sanitized HTML.
100
+ * @attr name
101
+ */
102
+ name: string | undefined;
103
+ /**
104
+ * Form field name for the Markdown version (optional).
105
+ * @attr markdown-name
106
+ */
107
+ markdownName: string | undefined;
108
+ /**
109
+ * Disables editing and the toolbar. A disabled ancestor fieldset also disables it.
110
+ * @attr disabled
111
+ */
112
+ disabled: boolean;
113
+ /**
114
+ * Shows the content without allowing edits.
115
+ * @attr readonly
116
+ */
117
+ readOnly: boolean;
118
+ /**
119
+ * Requires some text before the form submits.
120
+ * @attr required
121
+ */
122
+ required: boolean;
123
+ /**
124
+ * Hides the toolbar (keyboard shortcuts and Markdown shortcuts still work).
125
+ * @attr no-toolbar
126
+ */
127
+ noToolbar: boolean;
128
+ constructor();
129
+ /**
130
+ * The content as sanitized HTML. Setting it sanitizes the input (never
131
+ * trust it), so assigning user or server HTML is safe.
132
+ * @attr value
133
+ */
134
+ get value(): string;
135
+ set value(next: string | null | undefined);
136
+ /** The content as Markdown (CommonMark plus `~~strikethrough~~`). */
137
+ get markdown(): string;
138
+ /** The form the editor belongs to. */
139
+ get form(): HTMLFormElement | null;
140
+ /** The editable element (light DOM). */
141
+ get editor(): HTMLElement | undefined;
142
+ focus(options?: FocusOptions): void;
143
+ connectedCallback(): void;
144
+ disconnectedCallback(): void;
145
+ protected updated(changed: PropertyValues<this>): void;
146
+ formResetCallback(): void;
147
+ formDisabledCallback(disabled: boolean): void;
148
+ formStateRestoreCallback(state: string | FormData | null): void;
149
+ /** Whether the editor's value satisfies its constraints. */
150
+ checkValidity(): boolean;
151
+ /** Like `checkValidity()`, and shows the browser's message when invalid. */
152
+ reportValidity(): boolean;
153
+ protected render(): TemplateResult;
154
+ }
155
+ declare global {
156
+ interface HTMLElementTagNameMap {
157
+ 'und-rich-text-editor': UndRichTextEditor;
158
+ }
159
+ }
160
+ //# sourceMappingURL=rich-text-editor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rich-text-editor.d.ts","sourceRoot":"","sources":["../../../src/components/rich-text-editor/rich-text-editor.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAa1D,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,KAA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