@quickbuilder.io/rich-text 0.0.0-stage → 1.0.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.
Files changed (105) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +122 -2
  3. package/adapters.d.ts +1 -0
  4. package/adapters.js +1 -0
  5. package/collaboration.d.ts +1 -0
  6. package/collaboration.js +1 -0
  7. package/commands.d.ts +1 -0
  8. package/commands.js +1 -0
  9. package/content.d.ts +1 -0
  10. package/content.js +1 -0
  11. package/contracts.d.ts +1 -0
  12. package/contracts.js +1 -0
  13. package/dist/adapters.d.mts +11 -0
  14. package/dist/adapters.d.ts +11 -0
  15. package/dist/adapters.js +564 -0
  16. package/dist/adapters.js.map +1 -0
  17. package/dist/adapters.mjs +557 -0
  18. package/dist/adapters.mjs.map +1 -0
  19. package/dist/collaboration.d.mts +29 -0
  20. package/dist/collaboration.d.ts +29 -0
  21. package/dist/collaboration.js +758 -0
  22. package/dist/collaboration.js.map +1 -0
  23. package/dist/collaboration.mjs +733 -0
  24. package/dist/collaboration.mjs.map +1 -0
  25. package/dist/commands.d.mts +8 -0
  26. package/dist/commands.d.ts +8 -0
  27. package/dist/commands.js +42 -0
  28. package/dist/commands.js.map +1 -0
  29. package/dist/commands.mjs +38 -0
  30. package/dist/commands.mjs.map +1 -0
  31. package/dist/content-types-CYHsrMrs.d.mts +27 -0
  32. package/dist/content-types-CYHsrMrs.d.ts +27 -0
  33. package/dist/content.d.mts +19 -0
  34. package/dist/content.d.ts +19 -0
  35. package/dist/content.js +785 -0
  36. package/dist/content.js.map +1 -0
  37. package/dist/content.mjs +775 -0
  38. package/dist/content.mjs.map +1 -0
  39. package/dist/contracts.d.mts +199 -0
  40. package/dist/contracts.d.ts +199 -0
  41. package/dist/contracts.js +4 -0
  42. package/dist/contracts.js.map +1 -0
  43. package/dist/contracts.mjs +3 -0
  44. package/dist/contracts.mjs.map +1 -0
  45. package/dist/extensions.d.mts +363 -0
  46. package/dist/extensions.d.ts +363 -0
  47. package/dist/extensions.js +153 -0
  48. package/dist/extensions.js.map +1 -0
  49. package/dist/extensions.mjs +142 -0
  50. package/dist/extensions.mjs.map +1 -0
  51. package/dist/history.d.mts +12 -0
  52. package/dist/history.d.ts +12 -0
  53. package/dist/history.js +464 -0
  54. package/dist/history.js.map +1 -0
  55. package/dist/history.mjs +459 -0
  56. package/dist/history.mjs.map +1 -0
  57. package/dist/index.d.mts +12 -0
  58. package/dist/index.d.ts +12 -0
  59. package/dist/index.js +1438 -0
  60. package/dist/index.js.map +1 -0
  61. package/dist/index.mjs +1372 -0
  62. package/dist/index.mjs.map +1 -0
  63. package/dist/markdown.d.mts +32 -0
  64. package/dist/markdown.d.ts +32 -0
  65. package/dist/markdown.js +739 -0
  66. package/dist/markdown.js.map +1 -0
  67. package/dist/markdown.mjs +735 -0
  68. package/dist/markdown.mjs.map +1 -0
  69. package/dist/runtime/dom.d.mts +148 -0
  70. package/dist/runtime/dom.d.ts +148 -0
  71. package/dist/runtime/dom.js +2145 -0
  72. package/dist/runtime/dom.js.map +1 -0
  73. package/dist/runtime/dom.mjs +2084 -0
  74. package/dist/runtime/dom.mjs.map +1 -0
  75. package/dist/schema.d.mts +23 -0
  76. package/dist/schema.d.ts +23 -0
  77. package/dist/schema.js +157 -0
  78. package/dist/schema.js.map +1 -0
  79. package/dist/schema.mjs +137 -0
  80. package/dist/schema.mjs.map +1 -0
  81. package/dist/serializer.d.mts +38 -0
  82. package/dist/serializer.d.ts +38 -0
  83. package/dist/serializer.js +504 -0
  84. package/dist/serializer.js.map +1 -0
  85. package/dist/serializer.mjs +491 -0
  86. package/dist/serializer.mjs.map +1 -0
  87. package/dist/svg-export-BtI8x_mG.d.mts +15 -0
  88. package/dist/svg-export-BtI8x_mG.d.ts +15 -0
  89. package/dist/transactions.d.mts +16 -0
  90. package/dist/transactions.d.ts +16 -0
  91. package/dist/transactions.js +637 -0
  92. package/dist/transactions.js.map +1 -0
  93. package/dist/transactions.mjs +631 -0
  94. package/dist/transactions.mjs.map +1 -0
  95. package/extensions.d.ts +1 -0
  96. package/extensions.js +1 -0
  97. package/history.d.ts +1 -0
  98. package/history.js +1 -0
  99. package/package.json +352 -4
  100. package/schema.d.ts +1 -0
  101. package/schema.js +1 -0
  102. package/serializer.d.ts +1 -0
  103. package/serializer.js +1 -0
  104. package/transactions.d.ts +1 -0
  105. package/transactions.js +1 -0
package/dist/schema.js ADDED
@@ -0,0 +1,157 @@
1
+ 'use strict';
2
+
3
+ // src/schema.ts
4
+ var QUICK_BUILDER_RICH_TEXT_SCHEMA_VERSION = 2;
5
+ var richTextAllowedTags = [
6
+ "a",
7
+ "b",
8
+ "blockquote",
9
+ "br",
10
+ "code",
11
+ "em",
12
+ "h1",
13
+ "h2",
14
+ "h3",
15
+ "h4",
16
+ "h5",
17
+ "h6",
18
+ "hr",
19
+ "i",
20
+ "img",
21
+ "input",
22
+ "label",
23
+ "li",
24
+ "mark",
25
+ "ol",
26
+ "p",
27
+ "pre",
28
+ "qb-video",
29
+ "s",
30
+ "span",
31
+ "sub",
32
+ "sup",
33
+ "strong",
34
+ "table",
35
+ "tbody",
36
+ "td",
37
+ "tfoot",
38
+ "th",
39
+ "thead",
40
+ "tr",
41
+ "u",
42
+ "ul"
43
+ ];
44
+ var richTextVoidTags = ["br", "hr", "img", "input"];
45
+ var richTextAllowedTargets = ["_blank", "_self", "_parent", "_top"];
46
+ var richTextAlignmentTags = [
47
+ "blockquote",
48
+ "h1",
49
+ "h2",
50
+ "h3",
51
+ "h4",
52
+ "h5",
53
+ "h6",
54
+ "li",
55
+ "ol",
56
+ "p",
57
+ "pre",
58
+ "td",
59
+ "th",
60
+ "ul"
61
+ ];
62
+ var richTextAllowedAlignments = ["left", "center", "right", "justify"];
63
+ var richTextAllowedFontFamilies = [
64
+ "default",
65
+ "carlito",
66
+ "source-sans-3",
67
+ "noto-sans",
68
+ "arimo",
69
+ "tinos",
70
+ "cousine"
71
+ ];
72
+ var richTextAllowedFontSizes = [
73
+ "default",
74
+ "8",
75
+ "9",
76
+ "10",
77
+ "11",
78
+ "12",
79
+ "14",
80
+ "16",
81
+ "18",
82
+ "24",
83
+ "30",
84
+ "36",
85
+ "48",
86
+ "60",
87
+ "72",
88
+ "96"
89
+ ];
90
+ var richTextAllowedLineHeights = ["1", "1.15", "1.5", "2"];
91
+ var richTextAllowedColors = [
92
+ "default",
93
+ "gray",
94
+ "brown",
95
+ "orange",
96
+ "yellow",
97
+ "green",
98
+ "blue",
99
+ "purple",
100
+ "pink",
101
+ "red"
102
+ ];
103
+ var richTextBlockSelector = "p,h1,h2,h3,pre,blockquote,li,ul,ol,td,th";
104
+ var richTextBlockFormatByTagName = {
105
+ p: "paragraph",
106
+ h1: "heading1",
107
+ h2: "heading2",
108
+ h3: "heading3",
109
+ pre: "codeBlock"
110
+ };
111
+ var richTextBlockFormats = [
112
+ { value: "paragraph", tagName: "p" },
113
+ { value: "heading1", tagName: "h1" },
114
+ { value: "heading2", tagName: "h2" },
115
+ { value: "heading3", tagName: "h3" },
116
+ { value: "codeBlock", tagName: "pre" }
117
+ ];
118
+ function isRichTextAlignment(value) {
119
+ return richTextAllowedAlignments.includes(value);
120
+ }
121
+ function isRichTextFontFamily(value) {
122
+ return richTextAllowedFontFamilies.includes(value);
123
+ }
124
+ function isRichTextFontSize(value) {
125
+ return richTextAllowedFontSizes.includes(value);
126
+ }
127
+ function isRichTextLineHeight(value) {
128
+ return richTextAllowedLineHeights.includes(value);
129
+ }
130
+ function isRichTextColor(value) {
131
+ return richTextAllowedColors.includes(value);
132
+ }
133
+ function isRichTextBlockTag(value) {
134
+ return value === "p" || value === "h1" || value === "h2" || value === "h3" || value === "pre" || value === "blockquote";
135
+ }
136
+
137
+ exports.QUICK_BUILDER_RICH_TEXT_SCHEMA_VERSION = QUICK_BUILDER_RICH_TEXT_SCHEMA_VERSION;
138
+ exports.isRichTextAlignment = isRichTextAlignment;
139
+ exports.isRichTextBlockTag = isRichTextBlockTag;
140
+ exports.isRichTextColor = isRichTextColor;
141
+ exports.isRichTextFontFamily = isRichTextFontFamily;
142
+ exports.isRichTextFontSize = isRichTextFontSize;
143
+ exports.isRichTextLineHeight = isRichTextLineHeight;
144
+ exports.richTextAlignmentTags = richTextAlignmentTags;
145
+ exports.richTextAllowedAlignments = richTextAllowedAlignments;
146
+ exports.richTextAllowedColors = richTextAllowedColors;
147
+ exports.richTextAllowedFontFamilies = richTextAllowedFontFamilies;
148
+ exports.richTextAllowedFontSizes = richTextAllowedFontSizes;
149
+ exports.richTextAllowedLineHeights = richTextAllowedLineHeights;
150
+ exports.richTextAllowedTags = richTextAllowedTags;
151
+ exports.richTextAllowedTargets = richTextAllowedTargets;
152
+ exports.richTextBlockFormatByTagName = richTextBlockFormatByTagName;
153
+ exports.richTextBlockFormats = richTextBlockFormats;
154
+ exports.richTextBlockSelector = richTextBlockSelector;
155
+ exports.richTextVoidTags = richTextVoidTags;
156
+ //# sourceMappingURL=schema.js.map
157
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schema.ts"],"names":[],"mappings":";;;AAWO,IAAM,sCAAA,GAAyC;AAE/C,IAAM,mBAAA,GAAsB;AAAA,EACjC,GAAA;AAAA,EACA,GAAA;AAAA,EACA,YAAA;AAAA,EACA,IAAA;AAAA,EACA,MAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,GAAA;AAAA,EACA,KAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AAAA,EACA,MAAA;AAAA,EACA,IAAA;AAAA,EACA,GAAA;AAAA,EACA,KAAA;AAAA,EACA,UAAA;AAAA,EACA,GAAA;AAAA,EACA,MAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA,OA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KAAU,IAAA,IAAQ,KAAA,KAAU,KAAA,IAAS,KAAA,KAAU,YAAA;AAC7G","file":"schema.js","sourcesContent":["import type {\n RichTextAlignment,\n RichTextBlockFormat,\n RichTextBlockFormatDefinition,\n RichTextBlockTag,\n RichTextColor,\n RichTextFontFamily,\n RichTextFontSize,\n RichTextLineHeight,\n} from './content-types';\n\nexport const QUICK_BUILDER_RICH_TEXT_SCHEMA_VERSION = 2;\n\nexport const richTextAllowedTags = [\n 'a',\n 'b',\n 'blockquote',\n 'br',\n 'code',\n 'em',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'hr',\n 'i',\n 'img',\n 'input',\n 'label',\n 'li',\n 'mark',\n 'ol',\n 'p',\n 'pre',\n 'qb-video',\n 's',\n 'span',\n 'sub',\n 'sup',\n 'strong',\n 'table',\n 'tbody',\n 'td',\n 'tfoot',\n 'th',\n 'thead',\n 'tr',\n 'u',\n 'ul',\n] as const;\n\nexport const richTextVoidTags = ['br', 'hr', 'img', 'input'] as const;\n\nexport const richTextAllowedTargets = ['_blank', '_self', '_parent', '_top'] as const;\n\nexport const richTextAlignmentTags = [\n 'blockquote',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'li',\n 'ol',\n 'p',\n 'pre',\n 'td',\n 'th',\n 'ul',\n] as const;\n\nexport const richTextAllowedAlignments = ['left', 'center', 'right', 'justify'] as const;\n\nexport const richTextAllowedFontFamilies = [\n 'default',\n 'carlito',\n 'source-sans-3',\n 'noto-sans',\n 'arimo',\n 'tinos',\n 'cousine',\n] as const satisfies readonly RichTextFontFamily[];\n\nexport const richTextAllowedFontSizes = [\n 'default',\n '8',\n '9',\n '10',\n '11',\n '12',\n '14',\n '16',\n '18',\n '24',\n '30',\n '36',\n '48',\n '60',\n '72',\n '96',\n] as const satisfies readonly RichTextFontSize[];\n\nexport const richTextAllowedLineHeights = ['1', '1.15', '1.5', '2'] as const satisfies readonly RichTextLineHeight[];\n\nexport const richTextAllowedColors = [\n 'default',\n 'gray',\n 'brown',\n 'orange',\n 'yellow',\n 'green',\n 'blue',\n 'purple',\n 'pink',\n 'red',\n] as const satisfies readonly RichTextColor[];\n\nexport const richTextBlockSelector = 'p,h1,h2,h3,pre,blockquote,li,ul,ol,td,th';\n\nexport const richTextBlockFormatByTagName: Partial<Record<string, RichTextBlockFormat>> = {\n p: 'paragraph',\n h1: 'heading1',\n h2: 'heading2',\n h3: 'heading3',\n pre: 'codeBlock',\n};\n\nexport const richTextBlockFormats: RichTextBlockFormatDefinition[] = [\n { value: 'paragraph', tagName: 'p' },\n { value: 'heading1', tagName: 'h1' },\n { value: 'heading2', tagName: 'h2' },\n { value: 'heading3', tagName: 'h3' },\n { value: 'codeBlock', tagName: 'pre' },\n];\n\nexport function isRichTextAlignment(value: unknown): value is RichTextAlignment {\n return richTextAllowedAlignments.includes(value as RichTextAlignment);\n}\n\nexport function isRichTextFontFamily(value: unknown): value is RichTextFontFamily {\n return richTextAllowedFontFamilies.includes(value as RichTextFontFamily);\n}\n\nexport function isRichTextFontSize(value: unknown): value is RichTextFontSize {\n return richTextAllowedFontSizes.includes(value as RichTextFontSize);\n}\n\nexport function isRichTextLineHeight(value: unknown): value is RichTextLineHeight {\n return richTextAllowedLineHeights.includes(value as RichTextLineHeight);\n}\n\nexport function isRichTextColor(value: unknown): value is RichTextColor {\n return richTextAllowedColors.includes(value as RichTextColor);\n}\n\nexport function isRichTextBlockTag(value: unknown): value is RichTextBlockTag {\n return value === 'p' || value === 'h1' || value === 'h2' || value === 'h3' || value === 'pre' || value === 'blockquote';\n}\n"]}
@@ -0,0 +1,137 @@
1
+ // src/schema.ts
2
+ var QUICK_BUILDER_RICH_TEXT_SCHEMA_VERSION = 2;
3
+ var richTextAllowedTags = [
4
+ "a",
5
+ "b",
6
+ "blockquote",
7
+ "br",
8
+ "code",
9
+ "em",
10
+ "h1",
11
+ "h2",
12
+ "h3",
13
+ "h4",
14
+ "h5",
15
+ "h6",
16
+ "hr",
17
+ "i",
18
+ "img",
19
+ "input",
20
+ "label",
21
+ "li",
22
+ "mark",
23
+ "ol",
24
+ "p",
25
+ "pre",
26
+ "qb-video",
27
+ "s",
28
+ "span",
29
+ "sub",
30
+ "sup",
31
+ "strong",
32
+ "table",
33
+ "tbody",
34
+ "td",
35
+ "tfoot",
36
+ "th",
37
+ "thead",
38
+ "tr",
39
+ "u",
40
+ "ul"
41
+ ];
42
+ var richTextVoidTags = ["br", "hr", "img", "input"];
43
+ var richTextAllowedTargets = ["_blank", "_self", "_parent", "_top"];
44
+ var richTextAlignmentTags = [
45
+ "blockquote",
46
+ "h1",
47
+ "h2",
48
+ "h3",
49
+ "h4",
50
+ "h5",
51
+ "h6",
52
+ "li",
53
+ "ol",
54
+ "p",
55
+ "pre",
56
+ "td",
57
+ "th",
58
+ "ul"
59
+ ];
60
+ var richTextAllowedAlignments = ["left", "center", "right", "justify"];
61
+ var richTextAllowedFontFamilies = [
62
+ "default",
63
+ "carlito",
64
+ "source-sans-3",
65
+ "noto-sans",
66
+ "arimo",
67
+ "tinos",
68
+ "cousine"
69
+ ];
70
+ var richTextAllowedFontSizes = [
71
+ "default",
72
+ "8",
73
+ "9",
74
+ "10",
75
+ "11",
76
+ "12",
77
+ "14",
78
+ "16",
79
+ "18",
80
+ "24",
81
+ "30",
82
+ "36",
83
+ "48",
84
+ "60",
85
+ "72",
86
+ "96"
87
+ ];
88
+ var richTextAllowedLineHeights = ["1", "1.15", "1.5", "2"];
89
+ var richTextAllowedColors = [
90
+ "default",
91
+ "gray",
92
+ "brown",
93
+ "orange",
94
+ "yellow",
95
+ "green",
96
+ "blue",
97
+ "purple",
98
+ "pink",
99
+ "red"
100
+ ];
101
+ var richTextBlockSelector = "p,h1,h2,h3,pre,blockquote,li,ul,ol,td,th";
102
+ var richTextBlockFormatByTagName = {
103
+ p: "paragraph",
104
+ h1: "heading1",
105
+ h2: "heading2",
106
+ h3: "heading3",
107
+ pre: "codeBlock"
108
+ };
109
+ var richTextBlockFormats = [
110
+ { value: "paragraph", tagName: "p" },
111
+ { value: "heading1", tagName: "h1" },
112
+ { value: "heading2", tagName: "h2" },
113
+ { value: "heading3", tagName: "h3" },
114
+ { value: "codeBlock", tagName: "pre" }
115
+ ];
116
+ function isRichTextAlignment(value) {
117
+ return richTextAllowedAlignments.includes(value);
118
+ }
119
+ function isRichTextFontFamily(value) {
120
+ return richTextAllowedFontFamilies.includes(value);
121
+ }
122
+ function isRichTextFontSize(value) {
123
+ return richTextAllowedFontSizes.includes(value);
124
+ }
125
+ function isRichTextLineHeight(value) {
126
+ return richTextAllowedLineHeights.includes(value);
127
+ }
128
+ function isRichTextColor(value) {
129
+ return richTextAllowedColors.includes(value);
130
+ }
131
+ function isRichTextBlockTag(value) {
132
+ return value === "p" || value === "h1" || value === "h2" || value === "h3" || value === "pre" || value === "blockquote";
133
+ }
134
+
135
+ export { QUICK_BUILDER_RICH_TEXT_SCHEMA_VERSION, isRichTextAlignment, isRichTextBlockTag, isRichTextColor, isRichTextFontFamily, isRichTextFontSize, isRichTextLineHeight, richTextAlignmentTags, richTextAllowedAlignments, richTextAllowedColors, richTextAllowedFontFamilies, richTextAllowedFontSizes, richTextAllowedLineHeights, richTextAllowedTags, richTextAllowedTargets, richTextBlockFormatByTagName, richTextBlockFormats, richTextBlockSelector, richTextVoidTags };
136
+ //# sourceMappingURL=schema.mjs.map
137
+ //# sourceMappingURL=schema.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schema.ts"],"names":[],"mappings":";AAWO,IAAM,sCAAA,GAAyC;AAE/C,IAAM,mBAAA,GAAsB;AAAA,EACjC,GAAA;AAAA,EACA,GAAA;AAAA,EACA,YAAA;AAAA,EACA,IAAA;AAAA,EACA,MAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,G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,CAA2B,SAAS,KAA2B,CAAA;AACxE;AAEO,SAAS,gBAAgB,KAAA,EAAwC;AACtE,EAAA,OAAO,qBAAA,CAAsB,SAAS,KAAsB,CAAA;AAC9D;AAEO,SAAS,mBAAmB,KAAA,EAA2C;AAC5E,EAAA,OAAO,KAAA,KAAU,GAAA,IAAO,KAAA,KAAU,IAAA,IAAQ,KAAA,KAAU,QAAQ,KAAA,KAAU,IAAA,IAAQ,KAAA,KAAU,KAAA,IAAS,KAAA,KAAU,YAAA;AAC7G","file":"schema.mjs","sourcesContent":["import type {\n RichTextAlignment,\n RichTextBlockFormat,\n RichTextBlockFormatDefinition,\n RichTextBlockTag,\n RichTextColor,\n RichTextFontFamily,\n RichTextFontSize,\n RichTextLineHeight,\n} from './content-types';\n\nexport const QUICK_BUILDER_RICH_TEXT_SCHEMA_VERSION = 2;\n\nexport const richTextAllowedTags = [\n 'a',\n 'b',\n 'blockquote',\n 'br',\n 'code',\n 'em',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'hr',\n 'i',\n 'img',\n 'input',\n 'label',\n 'li',\n 'mark',\n 'ol',\n 'p',\n 'pre',\n 'qb-video',\n 's',\n 'span',\n 'sub',\n 'sup',\n 'strong',\n 'table',\n 'tbody',\n 'td',\n 'tfoot',\n 'th',\n 'thead',\n 'tr',\n 'u',\n 'ul',\n] as const;\n\nexport const richTextVoidTags = ['br', 'hr', 'img', 'input'] as const;\n\nexport const richTextAllowedTargets = ['_blank', '_self', '_parent', '_top'] as const;\n\nexport const richTextAlignmentTags = [\n 'blockquote',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'li',\n 'ol',\n 'p',\n 'pre',\n 'td',\n 'th',\n 'ul',\n] as const;\n\nexport const richTextAllowedAlignments = ['left', 'center', 'right', 'justify'] as const;\n\nexport const richTextAllowedFontFamilies = [\n 'default',\n 'carlito',\n 'source-sans-3',\n 'noto-sans',\n 'arimo',\n 'tinos',\n 'cousine',\n] as const satisfies readonly RichTextFontFamily[];\n\nexport const richTextAllowedFontSizes = [\n 'default',\n '8',\n '9',\n '10',\n '11',\n '12',\n '14',\n '16',\n '18',\n '24',\n '30',\n '36',\n '48',\n '60',\n '72',\n '96',\n] as const satisfies readonly RichTextFontSize[];\n\nexport const richTextAllowedLineHeights = ['1', '1.15', '1.5', '2'] as const satisfies readonly RichTextLineHeight[];\n\nexport const richTextAllowedColors = [\n 'default',\n 'gray',\n 'brown',\n 'orange',\n 'yellow',\n 'green',\n 'blue',\n 'purple',\n 'pink',\n 'red',\n] as const satisfies readonly RichTextColor[];\n\nexport const richTextBlockSelector = 'p,h1,h2,h3,pre,blockquote,li,ul,ol,td,th';\n\nexport const richTextBlockFormatByTagName: Partial<Record<string, RichTextBlockFormat>> = {\n p: 'paragraph',\n h1: 'heading1',\n h2: 'heading2',\n h3: 'heading3',\n pre: 'codeBlock',\n};\n\nexport const richTextBlockFormats: RichTextBlockFormatDefinition[] = [\n { value: 'paragraph', tagName: 'p' },\n { value: 'heading1', tagName: 'h1' },\n { value: 'heading2', tagName: 'h2' },\n { value: 'heading3', tagName: 'h3' },\n { value: 'codeBlock', tagName: 'pre' },\n];\n\nexport function isRichTextAlignment(value: unknown): value is RichTextAlignment {\n return richTextAllowedAlignments.includes(value as RichTextAlignment);\n}\n\nexport function isRichTextFontFamily(value: unknown): value is RichTextFontFamily {\n return richTextAllowedFontFamilies.includes(value as RichTextFontFamily);\n}\n\nexport function isRichTextFontSize(value: unknown): value is RichTextFontSize {\n return richTextAllowedFontSizes.includes(value as RichTextFontSize);\n}\n\nexport function isRichTextLineHeight(value: unknown): value is RichTextLineHeight {\n return richTextAllowedLineHeights.includes(value as RichTextLineHeight);\n}\n\nexport function isRichTextColor(value: unknown): value is RichTextColor {\n return richTextAllowedColors.includes(value as RichTextColor);\n}\n\nexport function isRichTextBlockTag(value: unknown): value is RichTextBlockTag {\n return value === 'p' || value === 'h1' || value === 'h2' || value === 'h3' || value === 'pre' || value === 'blockquote';\n}\n"]}
@@ -0,0 +1,38 @@
1
+ declare const richTextMaximumUrlLength = 4096;
2
+ declare const richTextMaximumImageTextLength = 512;
3
+ interface RichTextVideo {
4
+ src: string;
5
+ title: string;
6
+ }
7
+ declare function validateRichTextVideo(src: string, title: string): RichTextVideo | undefined;
8
+ declare function splitRichTextVideoBlocks(html: string): (string | RichTextVideo)[];
9
+ declare function stripActiveMarkup(value: string): string;
10
+ interface RichTextSanitizationOptions {
11
+ /** Resolve an untrusted image source to an approved URL, or remove it with null. */
12
+ resolveImageSource?: (source: string) => string | null;
13
+ /** Disable video blocks for content whose host does not authorize embedded media. */
14
+ allowVideos?: boolean;
15
+ /** Render governed videos as links when the destination cannot embed a player. */
16
+ videoPresentation?: 'embed' | 'link';
17
+ /** Retain bounded cid: image references for an explicitly selected email transport. */
18
+ allowContentIdImages?: boolean;
19
+ /** Select anonymous cross-origin requests globally or by the final approved source. */
20
+ imageCrossOrigin?: 'anonymous' | ((source: string) => 'anonymous' | undefined);
21
+ }
22
+ declare function sanitizeRichTextMarkup(value: string, options?: RichTextSanitizationOptions): string;
23
+ /** Rebind persisted image URLs without modifying text, block identity or other links. */
24
+ declare function rewriteRichTextImageSources(value: string, rewrite: (source: string) => string): string;
25
+ /** Converts explicitly plain text to the canonical HTML document without interpreting markup. */
26
+ declare function plainTextToRichTextHtml(value: string): string;
27
+ declare function normalizeRichTextHtml(value: string): string;
28
+ declare function richTextHtmlToPlainText(html: string): string;
29
+ /**
30
+ * Returns whether a link target is accepted by the governed rich-text schema.
31
+ * Relative URLs and document fragments are supported. Absolute URLs must use
32
+ * an explicitly approved protocol so custom application schemes cannot leak
33
+ * through authored content.
34
+ */
35
+ declare function isSafeRichTextHref(value: string): boolean;
36
+ declare function isSafeRichTextImageSrc(value: string): boolean;
37
+
38
+ export { type RichTextSanitizationOptions, type RichTextVideo, isSafeRichTextHref, isSafeRichTextImageSrc, normalizeRichTextHtml, plainTextToRichTextHtml, rewriteRichTextImageSources, richTextHtmlToPlainText, richTextMaximumImageTextLength, richTextMaximumUrlLength, sanitizeRichTextMarkup, splitRichTextVideoBlocks, stripActiveMarkup, validateRichTextVideo };
@@ -0,0 +1,38 @@
1
+ declare const richTextMaximumUrlLength = 4096;
2
+ declare const richTextMaximumImageTextLength = 512;
3
+ interface RichTextVideo {
4
+ src: string;
5
+ title: string;
6
+ }
7
+ declare function validateRichTextVideo(src: string, title: string): RichTextVideo | undefined;
8
+ declare function splitRichTextVideoBlocks(html: string): (string | RichTextVideo)[];
9
+ declare function stripActiveMarkup(value: string): string;
10
+ interface RichTextSanitizationOptions {
11
+ /** Resolve an untrusted image source to an approved URL, or remove it with null. */
12
+ resolveImageSource?: (source: string) => string | null;
13
+ /** Disable video blocks for content whose host does not authorize embedded media. */
14
+ allowVideos?: boolean;
15
+ /** Render governed videos as links when the destination cannot embed a player. */
16
+ videoPresentation?: 'embed' | 'link';
17
+ /** Retain bounded cid: image references for an explicitly selected email transport. */
18
+ allowContentIdImages?: boolean;
19
+ /** Select anonymous cross-origin requests globally or by the final approved source. */
20
+ imageCrossOrigin?: 'anonymous' | ((source: string) => 'anonymous' | undefined);
21
+ }
22
+ declare function sanitizeRichTextMarkup(value: string, options?: RichTextSanitizationOptions): string;
23
+ /** Rebind persisted image URLs without modifying text, block identity or other links. */
24
+ declare function rewriteRichTextImageSources(value: string, rewrite: (source: string) => string): string;
25
+ /** Converts explicitly plain text to the canonical HTML document without interpreting markup. */
26
+ declare function plainTextToRichTextHtml(value: string): string;
27
+ declare function normalizeRichTextHtml(value: string): string;
28
+ declare function richTextHtmlToPlainText(html: string): string;
29
+ /**
30
+ * Returns whether a link target is accepted by the governed rich-text schema.
31
+ * Relative URLs and document fragments are supported. Absolute URLs must use
32
+ * an explicitly approved protocol so custom application schemes cannot leak
33
+ * through authored content.
34
+ */
35
+ declare function isSafeRichTextHref(value: string): boolean;
36
+ declare function isSafeRichTextImageSrc(value: string): boolean;
37
+
38
+ export { type RichTextSanitizationOptions, type RichTextVideo, isSafeRichTextHref, isSafeRichTextImageSrc, normalizeRichTextHtml, plainTextToRichTextHtml, rewriteRichTextImageSources, richTextHtmlToPlainText, richTextMaximumImageTextLength, richTextMaximumUrlLength, sanitizeRichTextMarkup, splitRichTextVideoBlocks, stripActiveMarkup, validateRichTextVideo };