svelte-rtf-editor 1.12.0 → 1.15.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/README.md +197 -20
- package/dist/RtfViewer.svelte +41 -5
- package/dist/RtfViewer.svelte.d.ts +1 -0
- package/dist/components/ImageOverlay.svelte +153 -17
- package/dist/components/ImageOverlay.svelte.d.ts +23 -2
- package/dist/components/InkEditor.svelte +1878 -307
- package/dist/components/InkEditor.svelte.d.ts +16 -0
- package/dist/components/Modal.svelte +9 -13
- package/dist/components/Toolbar.svelte +141 -18
- package/dist/components/Toolbar.svelte.d.ts +23 -0
- package/dist/history.d.ts +49 -0
- package/dist/history.js +329 -0
- package/dist/list-markers.d.ts +64 -0
- package/dist/list-markers.js +211 -0
- package/dist/lists.d.ts +48 -0
- package/dist/lists.js +576 -0
- package/dist/paste-pictures.d.ts +22 -0
- package/dist/paste-pictures.js +57 -0
- package/dist/picture-rows.d.ts +49 -0
- package/dist/picture-rows.js +109 -0
- package/dist/rtf-parser.d.ts +23 -0
- package/dist/rtf-parser.js +460 -39
- package/dist/rtf-writer.d.ts +65 -3
- package/dist/rtf-writer.js +509 -58
- package/dist/sanitize.d.ts +36 -0
- package/dist/sanitize.js +162 -6
- package/dist/utils.js +62 -3
- package/package.json +1 -1
package/dist/rtf-writer.d.ts
CHANGED
|
@@ -12,18 +12,33 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Background color is intentionally not written — RTF highlight support
|
|
14
14
|
* is inconsistent across viewers (TextEdit uses \AppleHighlight, not \highlight).
|
|
15
|
+
* So a text color that can be read only on its background is not written either: see
|
|
16
|
+
* lostWithoutItsBackground.
|
|
15
17
|
*/
|
|
18
|
+
interface RGB {
|
|
19
|
+
r: number;
|
|
20
|
+
g: number;
|
|
21
|
+
b: number;
|
|
22
|
+
}
|
|
16
23
|
/** Options for htmlToRtf. */
|
|
17
24
|
export interface RtfWriteOptions {
|
|
18
25
|
/**
|
|
19
26
|
* Font for the whole document: body text, headings, lists and tables.
|
|
20
|
-
* Code keeps a monospace font. Default: DEFAULT_FONT_FAMILY.
|
|
27
|
+
* Code keeps a monospace font. Default: DEFAULT_FONT_FAMILY. Given a CSS list, the first
|
|
28
|
+
* family is the font written; the rest is for a screen (see cssFontFamily).
|
|
21
29
|
*/
|
|
22
30
|
fontFamily?: string;
|
|
23
31
|
/**
|
|
24
32
|
* Body text size in points. Headings scale from it. Default: 12.
|
|
25
33
|
*/
|
|
26
34
|
fontSize?: number;
|
|
35
|
+
/**
|
|
36
|
+
* The fonts text may be set in, beside the document's own: the editor's `fonts`. Text in one
|
|
37
|
+
* of them is written in it (a font of its own in the font table); a font that is not named
|
|
38
|
+
* here is not written, and its text is in the document font. Each is a font name, or a CSS
|
|
39
|
+
* list whose first family is the name. Default: none, and every font is the document's.
|
|
40
|
+
*/
|
|
41
|
+
fonts?: readonly string[];
|
|
27
42
|
}
|
|
28
43
|
/**
|
|
29
44
|
* Font used when no fontFamily is given: what the editor and the viewer show, and what the RTF
|
|
@@ -58,6 +73,13 @@ export declare const LINK_COLOR: {
|
|
|
58
73
|
readonly g: 0;
|
|
59
74
|
readonly b: 255;
|
|
60
75
|
};
|
|
76
|
+
export declare function parseColor(colorStr: string): RGB | null;
|
|
77
|
+
/** The contrast of two colors as WCAG counts it: 1 for the same color, 21 for black on white. */
|
|
78
|
+
export declare function colorContrast(a: RGB, b: RGB): number;
|
|
79
|
+
/** Whether words in a color are hard to read on a white page. */
|
|
80
|
+
export declare function hardToReadOnWhite(color: RGB): boolean;
|
|
81
|
+
/** A background that shows nothing: none, or one with no opacity. */
|
|
82
|
+
export declare const NO_BACKGROUND: RegExp;
|
|
61
83
|
/**
|
|
62
84
|
* Size htmlToRtf would produce, without doing the conversion.
|
|
63
85
|
*
|
|
@@ -88,6 +110,32 @@ export declare function estimateRtfBytes(editorEl: HTMLElement, options?: RtfWri
|
|
|
88
110
|
export declare function linkTarget(url: string): string | null;
|
|
89
111
|
/** Whether a link address is an absolute web, mail or phone address (see linkTarget). */
|
|
90
112
|
export declare function isSafeLinkUrl(url: string): boolean;
|
|
113
|
+
/** A font an application offers for text (the editor's `fonts`). */
|
|
114
|
+
export interface FontChoice {
|
|
115
|
+
/** Its name, as the toolbar and the RTF's font table give it: "Calibri". */
|
|
116
|
+
name: string;
|
|
117
|
+
/** What text set in it carries in the HTML: the name and what to show where it is missing. */
|
|
118
|
+
css: string;
|
|
119
|
+
/** The name as it is looked up by: without regard to capitals. */
|
|
120
|
+
key: string;
|
|
121
|
+
}
|
|
122
|
+
/** Whether two font values name the same families in the same order, however they are written. */
|
|
123
|
+
export declare function sameFontList(a: unknown, b: unknown): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* The name a font value is looked up by: its first family, without quotes and without regard to
|
|
126
|
+
* capitals. '' where there is none.
|
|
127
|
+
*/
|
|
128
|
+
export declare function fontKey(value: unknown): string;
|
|
129
|
+
/**
|
|
130
|
+
* The fonts an application offers, as the editor, the sanitizer, the writer and the reader use
|
|
131
|
+
* them. Each is given as a name ("Calibri") or as a CSS list whose first family is the name
|
|
132
|
+
* ("Calibri, Carlito, sans-serif"): the rest of the list is what a screen without that font
|
|
133
|
+
* shows the text in. A name alone is given the generic family that suits it, so that such a
|
|
134
|
+
* screen does not fall back to the browser's own font. A name that could not be written in a
|
|
135
|
+
* font table or a style (it has a brace, a semicolon, a bracket) is left out, and so is a
|
|
136
|
+
* generic family by itself and a name given twice.
|
|
137
|
+
*/
|
|
138
|
+
export declare function fontChoices(fonts: unknown): FontChoice[];
|
|
91
139
|
/**
|
|
92
140
|
* Whether a font name is a monospace font's: Courier New, Consolas, Menlo, a "… Mono" family
|
|
93
141
|
* (Roboto Mono, DejaVu Sans Mono), and their PostScript names (CourierNewPSMT, SFMono-Regular).
|
|
@@ -95,8 +143,14 @@ export declare function isSafeLinkUrl(url: string): boolean;
|
|
|
95
143
|
*/
|
|
96
144
|
export declare function isMonospaceFontName(name: string): boolean;
|
|
97
145
|
/**
|
|
98
|
-
* CSS font-family value for
|
|
99
|
-
*
|
|
146
|
+
* CSS font-family value for the document font: the name, with the generic fallback that matches
|
|
147
|
+
* it, e.g. "Arial", sans-serif.
|
|
148
|
+
*
|
|
149
|
+
* Given a CSS list, the first family is the font (the one the RTF names) and the rest is what a
|
|
150
|
+
* screen without that font shows the document in, in that order: "Segoe UI, Selawik, sans-serif"
|
|
151
|
+
* is Segoe UI where it is installed and Selawik where the page has loaded that. A list that does
|
|
152
|
+
* not end in a generic family is given the one that matches the font. A family that is no font
|
|
153
|
+
* name (it has a brace, a semicolon, a bracket) is left out.
|
|
100
154
|
*/
|
|
101
155
|
export declare function cssFontFamily(name: string | undefined): string;
|
|
102
156
|
/**
|
|
@@ -107,3 +161,11 @@ export declare function cssFontFamily(name: string | undefined): string;
|
|
|
107
161
|
*/
|
|
108
162
|
export declare function normalizeFontSize(fontSize: number | undefined): number;
|
|
109
163
|
export declare function htmlToRtf(editorEl: HTMLElement, options?: RtfWriteOptions): string;
|
|
164
|
+
/**
|
|
165
|
+
* The least a line is spaced by, as a share of the height of its text. Lines closer than this
|
|
166
|
+
* are printed over each other: two lines of a diagnosis, there to be selected and not to be
|
|
167
|
+
* read. A line height below it is no spacing a document has, and is not written (nor read, nor
|
|
168
|
+
* kept by the sanitizer, nor set by the editor).
|
|
169
|
+
*/
|
|
170
|
+
export declare const LEAST_LINES = 0.8;
|
|
171
|
+
export {};
|