svelte-rtf-editor 1.8.3 → 1.10.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.
@@ -2,11 +2,13 @@
2
2
  * HTML to RTF converter
3
3
  *
4
4
  * Walks a contenteditable DOM tree and produces a valid RTF 1.x string.
5
- * Supports: a document font and body size (Arial 12 pt by default, set with
6
- * RtfWriteOptions), bold, italic, underline, strikethrough, font sizes (h1–h3),
7
- * foreground colors (\cf), paragraphs, bullet/numbered lists, blockquotes,
8
- * code blocks, hyperlinks, images (embedded as \pict picture groups with
9
- * their captions), horizontal rules, line breaks, and Unicode characters.
5
+ * Supports: a document font and body size (DEFAULT_FONT_FAMILY at DEFAULT_FONT_SIZE
6
+ * points by default, set with RtfWriteOptions), bold, italic, underline, strikethrough, font sizes, headings
7
+ * (h1–h6), foreground colors (\cf), paragraphs with their alignment and indents,
8
+ * bullet/numbered lists and lists inside them, blockquotes, code blocks,
9
+ * hyperlinks, tables with merged cells, images (embedded as \pict picture groups
10
+ * with their captions), horizontal rules, page breaks, line breaks, and Unicode
11
+ * characters.
10
12
  *
11
13
  * Background color is intentionally not written — RTF highlight support
12
14
  * is inconsistent across viewers (TextEdit uses \AppleHighlight, not \highlight).
@@ -15,7 +17,7 @@
15
17
  export interface RtfWriteOptions {
16
18
  /**
17
19
  * Font for the whole document: body text, headings, lists and tables.
18
- * Code keeps a monospace font. Default: Arial.
20
+ * Code keeps a monospace font. Default: DEFAULT_FONT_FAMILY.
19
21
  */
20
22
  fontFamily?: string;
21
23
  /**
@@ -23,8 +25,13 @@ export interface RtfWriteOptions {
23
25
  */
24
26
  fontSize?: number;
25
27
  }
26
- /** Font used when no fontFamily is given. */
27
- export declare const DEFAULT_FONT_FAMILY = "Arial";
28
+ /**
29
+ * Font used when no fontFamily is given: what the editor and the viewer show, and what the RTF
30
+ * names. This is the one place the default is named; the size estimate, the components and the
31
+ * tests follow it. An application that wants another font does not change this: it passes
32
+ * `fontFamily` to the editor, to the viewer and to htmlToRtf.
33
+ */
34
+ export declare const DEFAULT_FONT_FAMILY = "Segoe UI";
28
35
  /** Body text size, in points, used when no fontSize is given. */
29
36
  export declare const DEFAULT_FONT_SIZE = 12;
30
37
  /**
@@ -36,6 +43,21 @@ export declare const HEADING_SCALE: {
36
43
  readonly h2: 1.5;
37
44
  readonly h3: number;
38
45
  };
46
+ /**
47
+ * Code blocks are set slightly smaller than the body: 10 pt at 12 pt. The parser reads a code
48
+ * block back by the same ratio.
49
+ */
50
+ export declare const PRE_SCALE: number;
51
+ /**
52
+ * The color of link text. A document with a link carries it as the first entry of its color
53
+ * table, so a link can be told from underlined text; the parser drops it again inside a link,
54
+ * where the <a> already says it.
55
+ */
56
+ export declare const LINK_COLOR: {
57
+ readonly r: 0;
58
+ readonly g: 0;
59
+ readonly b: 255;
60
+ };
39
61
  /**
40
62
  * Size htmlToRtf would produce, without doing the conversion.
41
63
  *
@@ -48,8 +70,11 @@ export declare const HEADING_SCALE: {
48
70
  * is negligible precisely when the number matters, and never more than a few
49
71
  * hundred bytes even when it does not. The output is ASCII, so bytes and
50
72
  * characters are the same number.
73
+ *
74
+ * Give it the options htmlToRtf is called with: a longer font name is part of the size, and so
75
+ * are the extra digits of a large body size.
51
76
  */
52
- export declare function estimateRtfBytes(editorEl: HTMLElement): number;
77
+ export declare function estimateRtfBytes(editorEl: HTMLElement, options?: RtfWriteOptions): number;
53
78
  /**
54
79
  * The address a link should carry in the RTF, or null if it should not be a link.
55
80
  *
@@ -63,6 +88,12 @@ export declare function estimateRtfBytes(editorEl: HTMLElement): number;
63
88
  export declare function linkTarget(url: string): string | null;
64
89
  /** Whether a link address is an absolute web, mail or phone address (see linkTarget). */
65
90
  export declare function isSafeLinkUrl(url: string): boolean;
91
+ /**
92
+ * Whether a font name is a monospace font's: Courier New, Consolas, Menlo, a "… Mono" family
93
+ * (Roboto Mono, DejaVu Sans Mono), and their PostScript names (CourierNewPSMT, SFMono-Regular).
94
+ * Monotype Corsiva is not one, and neither is American Typewriter, which is proportional.
95
+ */
96
+ export declare function isMonospaceFontName(name: string): boolean;
66
97
  /**
67
98
  * CSS font-family value for a font name, with the generic fallback that
68
99
  * matches it, e.g. "Arial", sans-serif.