@uniformdev/richtext 20.72.2 → 20.72.3-alpha.14
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/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.esm.js +21 -3
- package/dist/index.js +22 -3
- package/dist/index.mjs +21 -3
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -111,6 +111,12 @@ declare function isDangerousLinkAttributeKey(key: string): boolean;
|
|
|
111
111
|
* `rel="noopener noreferrer"` for any case variant of `target="_blank"`.
|
|
112
112
|
*/
|
|
113
113
|
declare function linkParamValueToHtmlAttributes(link: LinkParamValue): Record<string, string>;
|
|
114
|
+
/**
|
|
115
|
+
* Converts a link parameter value into a React-compatible anchor prop bag.
|
|
116
|
+
* Delegates to `linkParamValueToHtmlAttributes` for the security denylist /
|
|
117
|
+
* auto-rel logic, then renames the literal `class` key to `className` for React.
|
|
118
|
+
*/
|
|
119
|
+
declare function linkParamValueToAnchorProps(link: LinkParamValue): Record<string, string>;
|
|
114
120
|
/** Derives the href string from a link parameter value. */
|
|
115
121
|
declare function linkParamValueToHref(link: LinkParamValue): string | undefined;
|
|
116
122
|
|
|
@@ -264,4 +270,4 @@ declare const emptyRichTextValue: {
|
|
|
264
270
|
};
|
|
265
271
|
declare const defaultParameterConfiguration: RichTextParamConfiguration;
|
|
266
272
|
|
|
267
|
-
export { type AssetNode, type HeadingNode, type LinkAttrConfig, type LinkAttributesConfiguration, type LinkNode, type ListItemNode, type ListNode, type NodeStringRenderer, type NodeStringRendererProps, type ParagraphNode, type ParameterRichTextValue, type ResolveStringRenderer, type RichTextBuiltInElement, type RichTextBuiltInFormat, type RichTextNode, type RichTextNodeWithChildren, type RichTextParamConfiguration, type StringRenderContext, type TableCellNode, type TableNode, type TableRowNode, type TextNode, assetHtmlRenderer, defaultParameterConfiguration, emptyRichTextValue, getLabelForElement, getLabelForFormat, getRichTextTagFromTableCellHeaderState, getRichTextTagsFromTextFormat, hasChildren, headingHtmlRenderer, isArrayWithLength, isDangerousLinkAttributeKey, isPureDirection, isPureTextAlign, isRichTextNode, isRichTextNodeType, isRichTextValue, isRichTextValueConsideredEmpty, linkHtmlRenderer, linkParamValueToHref, linkParamValueToHtmlAttributes, listHtmlRenderer, listitemHtmlRenderer, paragraphHtmlRenderer, purifyText, renderChildrenToHtml, renderChildrenToText, renderHtmlElement, renderToHtml, renderToText, resolveDefaultRenderer$1 as resolveDefaultHtmlRenderer, resolveDefaultRenderer as resolveDefaultTextRenderer, resolveLinkAttrConfig, richTextBuiltInElements, richTextBuiltInFormats, rootHtmlRenderer, tableHtmlRenderer, tablecellHtmlRenderer, tablerowHtmlRenderer, textHtmlRenderer, walkRichTextTree };
|
|
273
|
+
export { type AssetNode, type HeadingNode, type LinkAttrConfig, type LinkAttributesConfiguration, type LinkNode, type ListItemNode, type ListNode, type NodeStringRenderer, type NodeStringRendererProps, type ParagraphNode, type ParameterRichTextValue, type ResolveStringRenderer, type RichTextBuiltInElement, type RichTextBuiltInFormat, type RichTextNode, type RichTextNodeWithChildren, type RichTextParamConfiguration, type StringRenderContext, type TableCellNode, type TableNode, type TableRowNode, type TextNode, assetHtmlRenderer, defaultParameterConfiguration, emptyRichTextValue, getLabelForElement, getLabelForFormat, getRichTextTagFromTableCellHeaderState, getRichTextTagsFromTextFormat, hasChildren, headingHtmlRenderer, isArrayWithLength, isDangerousLinkAttributeKey, isPureDirection, isPureTextAlign, isRichTextNode, isRichTextNodeType, isRichTextValue, isRichTextValueConsideredEmpty, linkHtmlRenderer, linkParamValueToAnchorProps, linkParamValueToHref, linkParamValueToHtmlAttributes, listHtmlRenderer, listitemHtmlRenderer, paragraphHtmlRenderer, purifyText, renderChildrenToHtml, renderChildrenToText, renderHtmlElement, renderToHtml, renderToText, resolveDefaultRenderer$1 as resolveDefaultHtmlRenderer, resolveDefaultRenderer as resolveDefaultTextRenderer, resolveLinkAttrConfig, richTextBuiltInElements, richTextBuiltInFormats, rootHtmlRenderer, tableHtmlRenderer, tablecellHtmlRenderer, tablerowHtmlRenderer, textHtmlRenderer, walkRichTextTree };
|
package/dist/index.d.ts
CHANGED
|
@@ -111,6 +111,12 @@ declare function isDangerousLinkAttributeKey(key: string): boolean;
|
|
|
111
111
|
* `rel="noopener noreferrer"` for any case variant of `target="_blank"`.
|
|
112
112
|
*/
|
|
113
113
|
declare function linkParamValueToHtmlAttributes(link: LinkParamValue): Record<string, string>;
|
|
114
|
+
/**
|
|
115
|
+
* Converts a link parameter value into a React-compatible anchor prop bag.
|
|
116
|
+
* Delegates to `linkParamValueToHtmlAttributes` for the security denylist /
|
|
117
|
+
* auto-rel logic, then renames the literal `class` key to `className` for React.
|
|
118
|
+
*/
|
|
119
|
+
declare function linkParamValueToAnchorProps(link: LinkParamValue): Record<string, string>;
|
|
114
120
|
/** Derives the href string from a link parameter value. */
|
|
115
121
|
declare function linkParamValueToHref(link: LinkParamValue): string | undefined;
|
|
116
122
|
|
|
@@ -264,4 +270,4 @@ declare const emptyRichTextValue: {
|
|
|
264
270
|
};
|
|
265
271
|
declare const defaultParameterConfiguration: RichTextParamConfiguration;
|
|
266
272
|
|
|
267
|
-
export { type AssetNode, type HeadingNode, type LinkAttrConfig, type LinkAttributesConfiguration, type LinkNode, type ListItemNode, type ListNode, type NodeStringRenderer, type NodeStringRendererProps, type ParagraphNode, type ParameterRichTextValue, type ResolveStringRenderer, type RichTextBuiltInElement, type RichTextBuiltInFormat, type RichTextNode, type RichTextNodeWithChildren, type RichTextParamConfiguration, type StringRenderContext, type TableCellNode, type TableNode, type TableRowNode, type TextNode, assetHtmlRenderer, defaultParameterConfiguration, emptyRichTextValue, getLabelForElement, getLabelForFormat, getRichTextTagFromTableCellHeaderState, getRichTextTagsFromTextFormat, hasChildren, headingHtmlRenderer, isArrayWithLength, isDangerousLinkAttributeKey, isPureDirection, isPureTextAlign, isRichTextNode, isRichTextNodeType, isRichTextValue, isRichTextValueConsideredEmpty, linkHtmlRenderer, linkParamValueToHref, linkParamValueToHtmlAttributes, listHtmlRenderer, listitemHtmlRenderer, paragraphHtmlRenderer, purifyText, renderChildrenToHtml, renderChildrenToText, renderHtmlElement, renderToHtml, renderToText, resolveDefaultRenderer$1 as resolveDefaultHtmlRenderer, resolveDefaultRenderer as resolveDefaultTextRenderer, resolveLinkAttrConfig, richTextBuiltInElements, richTextBuiltInFormats, rootHtmlRenderer, tableHtmlRenderer, tablecellHtmlRenderer, tablerowHtmlRenderer, textHtmlRenderer, walkRichTextTree };
|
|
273
|
+
export { type AssetNode, type HeadingNode, type LinkAttrConfig, type LinkAttributesConfiguration, type LinkNode, type ListItemNode, type ListNode, type NodeStringRenderer, type NodeStringRendererProps, type ParagraphNode, type ParameterRichTextValue, type ResolveStringRenderer, type RichTextBuiltInElement, type RichTextBuiltInFormat, type RichTextNode, type RichTextNodeWithChildren, type RichTextParamConfiguration, type StringRenderContext, type TableCellNode, type TableNode, type TableRowNode, type TextNode, assetHtmlRenderer, defaultParameterConfiguration, emptyRichTextValue, getLabelForElement, getLabelForFormat, getRichTextTagFromTableCellHeaderState, getRichTextTagsFromTextFormat, hasChildren, headingHtmlRenderer, isArrayWithLength, isDangerousLinkAttributeKey, isPureDirection, isPureTextAlign, isRichTextNode, isRichTextNodeType, isRichTextValue, isRichTextValueConsideredEmpty, linkHtmlRenderer, linkParamValueToAnchorProps, linkParamValueToHref, linkParamValueToHtmlAttributes, listHtmlRenderer, listitemHtmlRenderer, paragraphHtmlRenderer, purifyText, renderChildrenToHtml, renderChildrenToText, renderHtmlElement, renderToHtml, renderToText, resolveDefaultRenderer$1 as resolveDefaultHtmlRenderer, resolveDefaultRenderer as resolveDefaultTextRenderer, resolveLinkAttrConfig, richTextBuiltInElements, richTextBuiltInFormats, rootHtmlRenderer, tableHtmlRenderer, tablecellHtmlRenderer, tablerowHtmlRenderer, textHtmlRenderer, walkRichTextTree };
|
package/dist/index.esm.js
CHANGED
|
@@ -118,7 +118,7 @@ function linkParamValueToHtmlAttributes(link) {
|
|
|
118
118
|
var _a;
|
|
119
119
|
const result = {};
|
|
120
120
|
const href = linkParamValueToHref(link);
|
|
121
|
-
if (href
|
|
121
|
+
if (href) {
|
|
122
122
|
result.href = href;
|
|
123
123
|
}
|
|
124
124
|
if (!(link == null ? void 0 : link.attributes)) {
|
|
@@ -142,11 +142,25 @@ function linkParamValueToHtmlAttributes(link) {
|
|
|
142
142
|
}
|
|
143
143
|
result[key] = value;
|
|
144
144
|
}
|
|
145
|
-
|
|
145
|
+
const targetEntry = Object.entries(result).find(([key]) => key.toLowerCase() === "target");
|
|
146
|
+
const hasRel = Object.keys(result).some((key) => key.toLowerCase() === "rel");
|
|
147
|
+
if (((_a = targetEntry == null ? void 0 : targetEntry[1]) == null ? void 0 : _a.toLowerCase()) === "_blank" && !hasRel) {
|
|
146
148
|
result.rel = "noopener noreferrer";
|
|
147
149
|
}
|
|
148
150
|
return result;
|
|
149
151
|
}
|
|
152
|
+
function linkParamValueToAnchorProps(link) {
|
|
153
|
+
const raw = linkParamValueToHtmlAttributes(link);
|
|
154
|
+
const result = {};
|
|
155
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
156
|
+
if (key === "class") {
|
|
157
|
+
result["className"] = value;
|
|
158
|
+
} else {
|
|
159
|
+
result[key] = value;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
150
164
|
function linkParamValueToHref(link) {
|
|
151
165
|
switch (link == null ? void 0 : link.type) {
|
|
152
166
|
case "email":
|
|
@@ -154,8 +168,11 @@ function linkParamValueToHref(link) {
|
|
|
154
168
|
case "tel":
|
|
155
169
|
return `tel:${link.path}`;
|
|
156
170
|
case "url":
|
|
157
|
-
return link.path;
|
|
158
171
|
case "projectMapNode":
|
|
172
|
+
if (hasDangerousScheme(link.path)) {
|
|
173
|
+
console.warn(`[richtext] Dropped disallowed link URL scheme: "${link.path}"`);
|
|
174
|
+
return void 0;
|
|
175
|
+
}
|
|
159
176
|
return link.path;
|
|
160
177
|
}
|
|
161
178
|
}
|
|
@@ -608,6 +625,7 @@ export {
|
|
|
608
625
|
isRichTextValue,
|
|
609
626
|
isRichTextValueConsideredEmpty,
|
|
610
627
|
linkHtmlRenderer,
|
|
628
|
+
linkParamValueToAnchorProps,
|
|
611
629
|
linkParamValueToHref,
|
|
612
630
|
linkParamValueToHtmlAttributes,
|
|
613
631
|
listHtmlRenderer,
|
package/dist/index.js
CHANGED
|
@@ -38,6 +38,7 @@ __export(index_exports, {
|
|
|
38
38
|
isRichTextValue: () => isRichTextValue,
|
|
39
39
|
isRichTextValueConsideredEmpty: () => isRichTextValueConsideredEmpty,
|
|
40
40
|
linkHtmlRenderer: () => linkHtmlRenderer,
|
|
41
|
+
linkParamValueToAnchorProps: () => linkParamValueToAnchorProps,
|
|
41
42
|
linkParamValueToHref: () => linkParamValueToHref,
|
|
42
43
|
linkParamValueToHtmlAttributes: () => linkParamValueToHtmlAttributes,
|
|
43
44
|
listHtmlRenderer: () => listHtmlRenderer,
|
|
@@ -183,7 +184,7 @@ function linkParamValueToHtmlAttributes(link) {
|
|
|
183
184
|
var _a;
|
|
184
185
|
const result = {};
|
|
185
186
|
const href = linkParamValueToHref(link);
|
|
186
|
-
if (href
|
|
187
|
+
if (href) {
|
|
187
188
|
result.href = href;
|
|
188
189
|
}
|
|
189
190
|
if (!(link == null ? void 0 : link.attributes)) {
|
|
@@ -207,11 +208,25 @@ function linkParamValueToHtmlAttributes(link) {
|
|
|
207
208
|
}
|
|
208
209
|
result[key] = value;
|
|
209
210
|
}
|
|
210
|
-
|
|
211
|
+
const targetEntry = Object.entries(result).find(([key]) => key.toLowerCase() === "target");
|
|
212
|
+
const hasRel = Object.keys(result).some((key) => key.toLowerCase() === "rel");
|
|
213
|
+
if (((_a = targetEntry == null ? void 0 : targetEntry[1]) == null ? void 0 : _a.toLowerCase()) === "_blank" && !hasRel) {
|
|
211
214
|
result.rel = "noopener noreferrer";
|
|
212
215
|
}
|
|
213
216
|
return result;
|
|
214
217
|
}
|
|
218
|
+
function linkParamValueToAnchorProps(link) {
|
|
219
|
+
const raw = linkParamValueToHtmlAttributes(link);
|
|
220
|
+
const result = {};
|
|
221
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
222
|
+
if (key === "class") {
|
|
223
|
+
result["className"] = value;
|
|
224
|
+
} else {
|
|
225
|
+
result[key] = value;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return result;
|
|
229
|
+
}
|
|
215
230
|
function linkParamValueToHref(link) {
|
|
216
231
|
switch (link == null ? void 0 : link.type) {
|
|
217
232
|
case "email":
|
|
@@ -219,8 +234,11 @@ function linkParamValueToHref(link) {
|
|
|
219
234
|
case "tel":
|
|
220
235
|
return `tel:${link.path}`;
|
|
221
236
|
case "url":
|
|
222
|
-
return link.path;
|
|
223
237
|
case "projectMapNode":
|
|
238
|
+
if (hasDangerousScheme(link.path)) {
|
|
239
|
+
console.warn(`[richtext] Dropped disallowed link URL scheme: "${link.path}"`);
|
|
240
|
+
return void 0;
|
|
241
|
+
}
|
|
224
242
|
return link.path;
|
|
225
243
|
}
|
|
226
244
|
}
|
|
@@ -674,6 +692,7 @@ var defaultParameterConfiguration = {
|
|
|
674
692
|
isRichTextValue,
|
|
675
693
|
isRichTextValueConsideredEmpty,
|
|
676
694
|
linkHtmlRenderer,
|
|
695
|
+
linkParamValueToAnchorProps,
|
|
677
696
|
linkParamValueToHref,
|
|
678
697
|
linkParamValueToHtmlAttributes,
|
|
679
698
|
listHtmlRenderer,
|
package/dist/index.mjs
CHANGED
|
@@ -118,7 +118,7 @@ function linkParamValueToHtmlAttributes(link) {
|
|
|
118
118
|
var _a;
|
|
119
119
|
const result = {};
|
|
120
120
|
const href = linkParamValueToHref(link);
|
|
121
|
-
if (href
|
|
121
|
+
if (href) {
|
|
122
122
|
result.href = href;
|
|
123
123
|
}
|
|
124
124
|
if (!(link == null ? void 0 : link.attributes)) {
|
|
@@ -142,11 +142,25 @@ function linkParamValueToHtmlAttributes(link) {
|
|
|
142
142
|
}
|
|
143
143
|
result[key] = value;
|
|
144
144
|
}
|
|
145
|
-
|
|
145
|
+
const targetEntry = Object.entries(result).find(([key]) => key.toLowerCase() === "target");
|
|
146
|
+
const hasRel = Object.keys(result).some((key) => key.toLowerCase() === "rel");
|
|
147
|
+
if (((_a = targetEntry == null ? void 0 : targetEntry[1]) == null ? void 0 : _a.toLowerCase()) === "_blank" && !hasRel) {
|
|
146
148
|
result.rel = "noopener noreferrer";
|
|
147
149
|
}
|
|
148
150
|
return result;
|
|
149
151
|
}
|
|
152
|
+
function linkParamValueToAnchorProps(link) {
|
|
153
|
+
const raw = linkParamValueToHtmlAttributes(link);
|
|
154
|
+
const result = {};
|
|
155
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
156
|
+
if (key === "class") {
|
|
157
|
+
result["className"] = value;
|
|
158
|
+
} else {
|
|
159
|
+
result[key] = value;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
150
164
|
function linkParamValueToHref(link) {
|
|
151
165
|
switch (link == null ? void 0 : link.type) {
|
|
152
166
|
case "email":
|
|
@@ -154,8 +168,11 @@ function linkParamValueToHref(link) {
|
|
|
154
168
|
case "tel":
|
|
155
169
|
return `tel:${link.path}`;
|
|
156
170
|
case "url":
|
|
157
|
-
return link.path;
|
|
158
171
|
case "projectMapNode":
|
|
172
|
+
if (hasDangerousScheme(link.path)) {
|
|
173
|
+
console.warn(`[richtext] Dropped disallowed link URL scheme: "${link.path}"`);
|
|
174
|
+
return void 0;
|
|
175
|
+
}
|
|
159
176
|
return link.path;
|
|
160
177
|
}
|
|
161
178
|
}
|
|
@@ -608,6 +625,7 @@ export {
|
|
|
608
625
|
isRichTextValue,
|
|
609
626
|
isRichTextValueConsideredEmpty,
|
|
610
627
|
linkHtmlRenderer,
|
|
628
|
+
linkParamValueToAnchorProps,
|
|
611
629
|
linkParamValueToHref,
|
|
612
630
|
linkParamValueToHtmlAttributes,
|
|
613
631
|
listHtmlRenderer,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/richtext",
|
|
3
|
-
"version": "20.72.
|
|
3
|
+
"version": "20.72.3-alpha.14+1e232e59cd",
|
|
4
4
|
"description": "Common functionality and types for Uniform Rich Text parameters",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@lexical/link": "0.45.0",
|
|
45
45
|
"@lexical/list": "0.45.0",
|
|
46
46
|
"@lexical/rich-text": "0.45.0",
|
|
47
|
-
"@uniformdev/assets": "20.72.
|
|
47
|
+
"@uniformdev/assets": "20.72.3-alpha.14+1e232e59cd",
|
|
48
48
|
"lexical": "0.45.0"
|
|
49
49
|
},
|
|
50
50
|
"files": [
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "1e232e59cd3ded97b85b063986cc95e954b8c937"
|
|
57
57
|
}
|