@uniformdev/richtext
Advanced tools
Comparing version 19.184.3-alpha.32 to 19.185.1-alpha.8
@@ -23,2 +23,3 @@ "use strict"; | ||
__export(src_exports, { | ||
assetHtmlRenderer: () => assetHtmlRenderer, | ||
emptyRichTextValue: () => emptyRichTextValue, | ||
@@ -130,2 +131,23 @@ getLabelForElement: () => getLabelForElement, | ||
// src/nodes/asset.ts | ||
var ASSETS_SOURCE_UNIFORM = "uniform-assets"; | ||
var assetHtmlRenderer = ({ context }) => { | ||
var _a, _b; | ||
const node = context.currentNode; | ||
if (node.__asset === void 0) { | ||
return ""; | ||
} | ||
if (node.__asset.type !== "image" || node.__asset._source !== ASSETS_SOURCE_UNIFORM) { | ||
return ""; | ||
} | ||
const imgAttributes = /* @__PURE__ */ new Map(); | ||
imgAttributes.set("src", node.__asset.fields.url.value); | ||
if ((_a = node.__asset.fields.title) == null ? void 0 : _a.value) { | ||
imgAttributes.set("alt", node.__asset.fields.title.value); | ||
} | ||
const img = renderHtmlElement("img", imgAttributes); | ||
const figcaption = ((_b = node.__asset.fields.description) == null ? void 0 : _b.value) ? renderHtmlElement("figcaption", null, node.__asset.fields.description.value) : ""; | ||
return renderHtmlElement("figure", null, `${img}${figcaption}`); | ||
}; | ||
// src/nodes/heading.ts | ||
@@ -313,3 +335,4 @@ var headingHtmlRenderer = ({ context, renderChildren }) => { | ||
["tablecell", tablecellHtmlRenderer], | ||
["tablerow", tablerowHtmlRenderer] | ||
["tablerow", tablerowHtmlRenderer], | ||
["asset", assetHtmlRenderer] | ||
]); | ||
@@ -493,2 +516,6 @@ var resolveDefaultRenderer = (context) => { | ||
{ | ||
label: "Asset", | ||
type: "asset" | ||
}, | ||
{ | ||
label: "Dynamic Token", | ||
@@ -564,2 +591,3 @@ type: "variable" | ||
0 && (module.exports = { | ||
assetHtmlRenderer, | ||
emptyRichTextValue, | ||
@@ -566,0 +594,0 @@ getLabelForElement, |
@@ -0,1 +1,2 @@ | ||
import { AssetParamValueItem } from '@uniformdev/assets'; | ||
import { SerializedEditorState, SerializedParagraphNode } from 'lexical'; | ||
@@ -29,4 +30,9 @@ | ||
type RichTextBuiltInFormat = 'code' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'superscript' | 'subscript'; | ||
type RichTextBuiltInElement = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'unorderedList' | 'orderedList' | 'link' | 'quote' | 'code' | 'variable' | 'table'; | ||
type RichTextBuiltInElement = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'unorderedList' | 'orderedList' | 'link' | 'quote' | 'code' | 'variable' | 'table' | 'asset'; | ||
interface AssetNode extends RichTextNode { | ||
__asset?: NonNullable<AssetParamValueItem>; | ||
} | ||
declare const assetHtmlRenderer: NodeStringRenderer; | ||
interface HeadingNode extends RichTextNode { | ||
@@ -130,2 +136,3 @@ tag: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'; | ||
declare function isRichTextNodeType(node: unknown, type: 'link'): node is LinkNode; | ||
declare function isRichTextNodeType(node: unknown, type: 'asset'): node is AssetNode; | ||
declare function isRichTextNodeType(node: unknown, type: string): node is RichTextNode; | ||
@@ -207,2 +214,2 @@ declare function isRichTextValueConsideredEmpty(value: ParameterRichTextValue): boolean; | ||
export { type HeadingNode, 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 StringRenderContext, type TableCellNode, type TableNode, type TableRowNode, type TextNode, emptyRichTextValue, getLabelForElement, getLabelForFormat, getRichTextTagFromTableCellHeaderState, getRichTextTagsFromTextFormat, hasChildren, headingHtmlRenderer, isArrayWithLength, isPureDirection, isPureTextAlign, isRichTextNode, isRichTextNodeType, isRichTextValue, isRichTextValueConsideredEmpty, linkHtmlRenderer, linkParamValueToHref, listHtmlRenderer, listitemHtmlRenderer, paragraphHtmlRenderer, purifyText, renderChildrenToHtml, renderChildrenToText, renderHtmlElement, renderToHtml, renderToText, resolveDefaultRenderer$1 as resolveDefaultHtmlRenderer, resolveDefaultRenderer as resolveDefaultTextRenderer, richTextBuiltInElements, richTextBuiltInFormats, rootHtmlRenderer, tableHtmlRenderer, tablecellHtmlRenderer, tablerowHtmlRenderer, textHtmlRenderer, walkRichTextTree }; | ||
export { type AssetNode, type HeadingNode, 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 StringRenderContext, type TableCellNode, type TableNode, type TableRowNode, type TextNode, assetHtmlRenderer, emptyRichTextValue, getLabelForElement, getLabelForFormat, getRichTextTagFromTableCellHeaderState, getRichTextTagsFromTextFormat, hasChildren, headingHtmlRenderer, isArrayWithLength, isPureDirection, isPureTextAlign, isRichTextNode, isRichTextNodeType, isRichTextValue, isRichTextValueConsideredEmpty, linkHtmlRenderer, linkParamValueToHref, listHtmlRenderer, listitemHtmlRenderer, paragraphHtmlRenderer, purifyText, renderChildrenToHtml, renderChildrenToText, renderHtmlElement, renderToHtml, renderToText, resolveDefaultRenderer$1 as resolveDefaultHtmlRenderer, resolveDefaultRenderer as resolveDefaultTextRenderer, richTextBuiltInElements, richTextBuiltInFormats, rootHtmlRenderer, tableHtmlRenderer, tablecellHtmlRenderer, tablerowHtmlRenderer, textHtmlRenderer, walkRichTextTree }; |
@@ -69,2 +69,23 @@ // src/elements.ts | ||
// src/nodes/asset.ts | ||
var ASSETS_SOURCE_UNIFORM = "uniform-assets"; | ||
var assetHtmlRenderer = ({ context }) => { | ||
var _a, _b; | ||
const node = context.currentNode; | ||
if (node.__asset === void 0) { | ||
return ""; | ||
} | ||
if (node.__asset.type !== "image" || node.__asset._source !== ASSETS_SOURCE_UNIFORM) { | ||
return ""; | ||
} | ||
const imgAttributes = /* @__PURE__ */ new Map(); | ||
imgAttributes.set("src", node.__asset.fields.url.value); | ||
if ((_a = node.__asset.fields.title) == null ? void 0 : _a.value) { | ||
imgAttributes.set("alt", node.__asset.fields.title.value); | ||
} | ||
const img = renderHtmlElement("img", imgAttributes); | ||
const figcaption = ((_b = node.__asset.fields.description) == null ? void 0 : _b.value) ? renderHtmlElement("figcaption", null, node.__asset.fields.description.value) : ""; | ||
return renderHtmlElement("figure", null, `${img}${figcaption}`); | ||
}; | ||
// src/nodes/heading.ts | ||
@@ -252,3 +273,4 @@ var headingHtmlRenderer = ({ context, renderChildren }) => { | ||
["tablecell", tablecellHtmlRenderer], | ||
["tablerow", tablerowHtmlRenderer] | ||
["tablerow", tablerowHtmlRenderer], | ||
["asset", assetHtmlRenderer] | ||
]); | ||
@@ -432,2 +454,6 @@ var resolveDefaultRenderer = (context) => { | ||
{ | ||
label: "Asset", | ||
type: "asset" | ||
}, | ||
{ | ||
label: "Dynamic Token", | ||
@@ -502,2 +528,3 @@ type: "variable" | ||
export { | ||
assetHtmlRenderer, | ||
emptyRichTextValue, | ||
@@ -504,0 +531,0 @@ getLabelForElement, |
@@ -23,2 +23,3 @@ "use strict"; | ||
__export(src_exports, { | ||
assetHtmlRenderer: () => assetHtmlRenderer, | ||
emptyRichTextValue: () => emptyRichTextValue, | ||
@@ -130,2 +131,23 @@ getLabelForElement: () => getLabelForElement, | ||
// src/nodes/asset.ts | ||
var ASSETS_SOURCE_UNIFORM = "uniform-assets"; | ||
var assetHtmlRenderer = ({ context }) => { | ||
var _a, _b; | ||
const node = context.currentNode; | ||
if (node.__asset === void 0) { | ||
return ""; | ||
} | ||
if (node.__asset.type !== "image" || node.__asset._source !== ASSETS_SOURCE_UNIFORM) { | ||
return ""; | ||
} | ||
const imgAttributes = /* @__PURE__ */ new Map(); | ||
imgAttributes.set("src", node.__asset.fields.url.value); | ||
if ((_a = node.__asset.fields.title) == null ? void 0 : _a.value) { | ||
imgAttributes.set("alt", node.__asset.fields.title.value); | ||
} | ||
const img = renderHtmlElement("img", imgAttributes); | ||
const figcaption = ((_b = node.__asset.fields.description) == null ? void 0 : _b.value) ? renderHtmlElement("figcaption", null, node.__asset.fields.description.value) : ""; | ||
return renderHtmlElement("figure", null, `${img}${figcaption}`); | ||
}; | ||
// src/nodes/heading.ts | ||
@@ -313,3 +335,4 @@ var headingHtmlRenderer = ({ context, renderChildren }) => { | ||
["tablecell", tablecellHtmlRenderer], | ||
["tablerow", tablerowHtmlRenderer] | ||
["tablerow", tablerowHtmlRenderer], | ||
["asset", assetHtmlRenderer] | ||
]); | ||
@@ -493,2 +516,6 @@ var resolveDefaultRenderer = (context) => { | ||
{ | ||
label: "Asset", | ||
type: "asset" | ||
}, | ||
{ | ||
label: "Dynamic Token", | ||
@@ -564,2 +591,3 @@ type: "variable" | ||
0 && (module.exports = { | ||
assetHtmlRenderer, | ||
emptyRichTextValue, | ||
@@ -566,0 +594,0 @@ getLabelForElement, |
{ | ||
"name": "@uniformdev/richtext", | ||
"version": "19.184.3-alpha.32+637f1f5303", | ||
"version": "19.185.1-alpha.8+53f7f96124", | ||
"description": "Common functionality and types for Uniform Rich Text parameters", | ||
@@ -43,8 +43,9 @@ "license": "SEE LICENSE IN LICENSE.txt", | ||
"devDependencies": { | ||
"@lexical/headless": "0.17.0", | ||
"@lexical/html": "0.17.0", | ||
"@lexical/link": "0.17.0", | ||
"@lexical/list": "0.17.0", | ||
"@lexical/rich-text": "0.17.0", | ||
"lexical": "0.17.0" | ||
"@lexical/headless": "0.17.1", | ||
"@lexical/html": "0.17.1", | ||
"@lexical/link": "0.17.1", | ||
"@lexical/list": "0.17.1", | ||
"@lexical/rich-text": "0.17.1", | ||
"@uniformdev/assets": "19.185.1-alpha.8+53f7f96124", | ||
"lexical": "0.17.1" | ||
}, | ||
@@ -57,3 +58,3 @@ "files": [ | ||
}, | ||
"gitHead": "637f1f5303933370e09fec676814bee7a9e26876" | ||
"gitHead": "53f7f961242f3518b103e55337ada7ad91c18dd7" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
88802
2494
7