@uniformdev/richtext
Advanced tools
Comparing version 19.173.2-alpha.8 to 19.173.2-alpha.210
@@ -23,4 +23,6 @@ "use strict"; | ||
__export(src_exports, { | ||
emptyRichTextValue: () => emptyRichTextValue, | ||
getLabelForElement: () => getLabelForElement, | ||
getLabelForFormat: () => getLabelForFormat, | ||
getRichTextTagFromTableCellHeaderState: () => getRichTextTagFromTableCellHeaderState, | ||
getRichTextTagsFromTextFormat: () => getRichTextTagsFromTextFormat, | ||
@@ -52,2 +54,5 @@ hasChildren: () => hasChildren, | ||
rootHtmlRenderer: () => rootHtmlRenderer, | ||
tableHtmlRenderer: () => tableHtmlRenderer, | ||
tablecellHtmlRenderer: () => tablecellHtmlRenderer, | ||
tablerowHtmlRenderer: () => tablerowHtmlRenderer, | ||
textHtmlRenderer: () => textHtmlRenderer, | ||
@@ -215,2 +220,36 @@ walkRichTextTree: () => walkRichTextTree | ||
// src/nodes/table.ts | ||
var tableHtmlRenderer = ({ context, renderChildren }) => { | ||
return ["table", "tbody"].reduceRight((children, tag) => { | ||
return renderHtmlElement(tag, null, children); | ||
}, renderChildren(context.currentNode.children)); | ||
}; | ||
var tableTextRenderer = ({ context, renderChildren }) => { | ||
return hasChildren(context.currentNode) ? `${renderChildren(context.currentNode.children)} ` : ""; | ||
}; | ||
// src/nodes/tablecell.ts | ||
var tablecellHtmlRenderer = ({ context, renderChildren }) => { | ||
const node = context.currentNode; | ||
const tag = getRichTextTagFromTableCellHeaderState(node.headerState); | ||
return renderHtmlElement(tag, null, renderChildren(context.currentNode.children)); | ||
}; | ||
var tablecellTextRenderer = ({ context, renderChildren }) => { | ||
return hasChildren(context.currentNode) ? `${renderChildren(context.currentNode.children)} ` : ""; | ||
}; | ||
function getRichTextTagFromTableCellHeaderState(headerState) { | ||
if (headerState === 0) { | ||
return "td"; | ||
} | ||
return "th"; | ||
} | ||
// src/nodes/tablerow.ts | ||
var tablerowHtmlRenderer = ({ context, renderChildren }) => { | ||
return renderHtmlElement("tr", null, renderChildren(context.currentNode.children)); | ||
}; | ||
var tablerowTextRenderer = ({ context, renderChildren }) => { | ||
return hasChildren(context.currentNode) ? `${renderChildren(context.currentNode.children)} ` : ""; | ||
}; | ||
// src/nodes/text.ts | ||
@@ -272,3 +311,6 @@ var textHtmlRenderer = ({ context }) => { | ||
["text", textHtmlRenderer], | ||
["tab", tabHtmlRenderer] | ||
["tab", tabHtmlRenderer], | ||
["table", tableHtmlRenderer], | ||
["tablecell", tablecellHtmlRenderer], | ||
["tablerow", tablerowHtmlRenderer] | ||
]); | ||
@@ -341,3 +383,6 @@ var resolveDefaultRenderer = (context) => { | ||
["listitem", listitemTextRenderer], | ||
["heading", headingTextRenderer] | ||
["heading", headingTextRenderer], | ||
["table", tableTextRenderer], | ||
["tablecell", tablecellTextRenderer], | ||
["tablerow", tablerowTextRenderer] | ||
]); | ||
@@ -446,2 +491,6 @@ var resolveDefaultRenderer2 = (context) => { | ||
{ | ||
label: "Table", | ||
type: "table" | ||
}, | ||
{ | ||
label: "Dynamic Token", | ||
@@ -494,6 +543,29 @@ type: "variable" | ||
}; | ||
var emptyRichTextValue = { | ||
root: { | ||
type: "root", | ||
version: 1, | ||
direction: null, | ||
format: "", | ||
indent: 0, | ||
children: [ | ||
{ | ||
type: "paragraph", | ||
version: 1, | ||
format: "start", | ||
indent: 0, | ||
direction: null, | ||
children: [], | ||
textFormat: 0, | ||
textStyle: "" | ||
} | ||
] | ||
} | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
emptyRichTextValue, | ||
getLabelForElement, | ||
getLabelForFormat, | ||
getRichTextTagFromTableCellHeaderState, | ||
getRichTextTagsFromTextFormat, | ||
@@ -525,4 +597,7 @@ hasChildren, | ||
rootHtmlRenderer, | ||
tableHtmlRenderer, | ||
tablecellHtmlRenderer, | ||
tablerowHtmlRenderer, | ||
textHtmlRenderer, | ||
walkRichTextTree | ||
}); |
@@ -1,2 +0,2 @@ | ||
import { LinkParamValue, RichTextParamValue, RichTextBuiltInElement, RichTextBuiltInFormat } from '@uniformdev/canvas'; | ||
import { SerializedEditorState, SerializedParagraphNode } from 'lexical'; | ||
@@ -27,5 +27,5 @@ declare function purifyText(text: string): string; | ||
type NodeStringRenderer = (props: NodeStringRendererProps) => string; | ||
type ParameterRichTextValue = { | ||
root: RichTextNode; | ||
} | undefined; | ||
type ParameterRichTextValue = SerializedEditorState | undefined | null; | ||
type RichTextBuiltInFormat = 'code' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'superscript' | 'subscript'; | ||
type RichTextBuiltInElement = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'unorderedList' | 'orderedList' | 'link' | 'quote' | 'code' | 'variable' | 'table'; | ||
@@ -41,2 +41,15 @@ interface HeadingNode extends RichTextNode { | ||
declare const linkHtmlRenderer: NodeStringRenderer; | ||
type LinkParameterType = 'projectMapNode' | 'url' | 'tel' | 'email'; | ||
type ProjectMapLinkParamValue = { | ||
type: 'projectMapNode'; | ||
projectMapId: string; | ||
nodeId: string; | ||
path: string; | ||
dynamicInputValues?: Record<string, string>; | ||
}; | ||
type NonProjectMapLinkParamValue = { | ||
type: Exclude<LinkParameterType, 'projectMapNode'>; | ||
path: string; | ||
}; | ||
type LinkParamValue = ProjectMapLinkParamValue | NonProjectMapLinkParamValue | undefined; | ||
declare function linkParamValueToHref(link: LinkParamValue): string | undefined; | ||
@@ -63,2 +76,26 @@ | ||
interface TableNode extends RichTextNode { | ||
} | ||
declare const tableHtmlRenderer: NodeStringRenderer; | ||
interface TableCellNode extends RichTextNode { | ||
/** | ||
* headerState: | ||
* 0: no header | ||
* 1: row header | ||
* 2: column header | ||
* 3: row and column header | ||
*/ | ||
headerState: number; | ||
} | ||
declare const tablecellHtmlRenderer: NodeStringRenderer; | ||
/** | ||
* Convert headerState into relevant tag | ||
*/ | ||
declare function getRichTextTagFromTableCellHeaderState(headerState: number): "td" | "th"; | ||
interface TableRowNode extends RichTextNode { | ||
} | ||
declare const tablerowHtmlRenderer: NodeStringRenderer; | ||
interface TextNode extends RichTextNode { | ||
@@ -88,3 +125,3 @@ /** | ||
declare function isRichTextNode(node: unknown): node is RichTextNode; | ||
declare function isRichTextValue(value: unknown): value is NonNullable<RichTextParamValue>; | ||
declare function isRichTextValue(value: unknown): value is NonNullable<ParameterRichTextValue>; | ||
declare function isRichTextNodeType(node: unknown, type: 'heading'): node is HeadingNode; | ||
@@ -97,3 +134,3 @@ declare function isRichTextNodeType(node: unknown, type: 'paragraph'): node is ParagraphNode; | ||
declare function isRichTextNodeType(node: unknown, type: string): node is RichTextNode; | ||
declare function isRichTextValueConsideredEmpty(value: RichTextParamValue): boolean; | ||
declare function isRichTextValueConsideredEmpty(value: ParameterRichTextValue): boolean; | ||
declare function hasChildren<TRichTextNode extends RichTextNode>(node: TRichTextNode): node is TRichTextNode & { | ||
@@ -152,13 +189,23 @@ children: RichTextNode[]; | ||
declare const walkRichTextTree: (node: RichTextNode, callback: (node: RichTextNode, parent: RichTextNode | undefined) => void, parent?: RichTextNode) => void; | ||
declare const richTextBuiltInElements: { | ||
declare const richTextBuiltInElements: Array<{ | ||
label: string; | ||
type: RichTextBuiltInElement; | ||
}[]; | ||
declare const richTextBuiltInFormats: { | ||
}>; | ||
declare const richTextBuiltInFormats: Array<{ | ||
label: string; | ||
type: RichTextBuiltInFormat; | ||
}[]; | ||
}>; | ||
declare const getLabelForElement: (type: string) => string; | ||
declare const getLabelForFormat: (type: string) => string; | ||
declare const emptyRichTextValue: { | ||
root: { | ||
type: string; | ||
version: number; | ||
direction: null; | ||
format: ""; | ||
indent: number; | ||
children: SerializedParagraphNode[]; | ||
}; | ||
}; | ||
export { type HeadingNode, type LinkNode, type ListItemNode, type ListNode, type NodeStringRenderer, type NodeStringRendererProps, type ParagraphNode, type ParameterRichTextValue, type ResolveStringRenderer, type RichTextNode, type RichTextNodeWithChildren, type StringRenderContext, type TextNode, getLabelForElement, getLabelForFormat, 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, textHtmlRenderer, walkRichTextTree }; | ||
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 }; |
@@ -158,2 +158,36 @@ // src/elements.ts | ||
// src/nodes/table.ts | ||
var tableHtmlRenderer = ({ context, renderChildren }) => { | ||
return ["table", "tbody"].reduceRight((children, tag) => { | ||
return renderHtmlElement(tag, null, children); | ||
}, renderChildren(context.currentNode.children)); | ||
}; | ||
var tableTextRenderer = ({ context, renderChildren }) => { | ||
return hasChildren(context.currentNode) ? `${renderChildren(context.currentNode.children)} ` : ""; | ||
}; | ||
// src/nodes/tablecell.ts | ||
var tablecellHtmlRenderer = ({ context, renderChildren }) => { | ||
const node = context.currentNode; | ||
const tag = getRichTextTagFromTableCellHeaderState(node.headerState); | ||
return renderHtmlElement(tag, null, renderChildren(context.currentNode.children)); | ||
}; | ||
var tablecellTextRenderer = ({ context, renderChildren }) => { | ||
return hasChildren(context.currentNode) ? `${renderChildren(context.currentNode.children)} ` : ""; | ||
}; | ||
function getRichTextTagFromTableCellHeaderState(headerState) { | ||
if (headerState === 0) { | ||
return "td"; | ||
} | ||
return "th"; | ||
} | ||
// src/nodes/tablerow.ts | ||
var tablerowHtmlRenderer = ({ context, renderChildren }) => { | ||
return renderHtmlElement("tr", null, renderChildren(context.currentNode.children)); | ||
}; | ||
var tablerowTextRenderer = ({ context, renderChildren }) => { | ||
return hasChildren(context.currentNode) ? `${renderChildren(context.currentNode.children)} ` : ""; | ||
}; | ||
// src/nodes/text.ts | ||
@@ -215,3 +249,6 @@ var textHtmlRenderer = ({ context }) => { | ||
["text", textHtmlRenderer], | ||
["tab", tabHtmlRenderer] | ||
["tab", tabHtmlRenderer], | ||
["table", tableHtmlRenderer], | ||
["tablecell", tablecellHtmlRenderer], | ||
["tablerow", tablerowHtmlRenderer] | ||
]); | ||
@@ -284,3 +321,6 @@ var resolveDefaultRenderer = (context) => { | ||
["listitem", listitemTextRenderer], | ||
["heading", headingTextRenderer] | ||
["heading", headingTextRenderer], | ||
["table", tableTextRenderer], | ||
["tablecell", tablecellTextRenderer], | ||
["tablerow", tablerowTextRenderer] | ||
]); | ||
@@ -389,2 +429,6 @@ var resolveDefaultRenderer2 = (context) => { | ||
{ | ||
label: "Table", | ||
type: "table" | ||
}, | ||
{ | ||
label: "Dynamic Token", | ||
@@ -437,5 +481,28 @@ type: "variable" | ||
}; | ||
var emptyRichTextValue = { | ||
root: { | ||
type: "root", | ||
version: 1, | ||
direction: null, | ||
format: "", | ||
indent: 0, | ||
children: [ | ||
{ | ||
type: "paragraph", | ||
version: 1, | ||
format: "start", | ||
indent: 0, | ||
direction: null, | ||
children: [], | ||
textFormat: 0, | ||
textStyle: "" | ||
} | ||
] | ||
} | ||
}; | ||
export { | ||
emptyRichTextValue, | ||
getLabelForElement, | ||
getLabelForFormat, | ||
getRichTextTagFromTableCellHeaderState, | ||
getRichTextTagsFromTextFormat, | ||
@@ -467,4 +534,7 @@ hasChildren, | ||
rootHtmlRenderer, | ||
tableHtmlRenderer, | ||
tablecellHtmlRenderer, | ||
tablerowHtmlRenderer, | ||
textHtmlRenderer, | ||
walkRichTextTree | ||
}; |
@@ -23,4 +23,6 @@ "use strict"; | ||
__export(src_exports, { | ||
emptyRichTextValue: () => emptyRichTextValue, | ||
getLabelForElement: () => getLabelForElement, | ||
getLabelForFormat: () => getLabelForFormat, | ||
getRichTextTagFromTableCellHeaderState: () => getRichTextTagFromTableCellHeaderState, | ||
getRichTextTagsFromTextFormat: () => getRichTextTagsFromTextFormat, | ||
@@ -52,2 +54,5 @@ hasChildren: () => hasChildren, | ||
rootHtmlRenderer: () => rootHtmlRenderer, | ||
tableHtmlRenderer: () => tableHtmlRenderer, | ||
tablecellHtmlRenderer: () => tablecellHtmlRenderer, | ||
tablerowHtmlRenderer: () => tablerowHtmlRenderer, | ||
textHtmlRenderer: () => textHtmlRenderer, | ||
@@ -215,2 +220,36 @@ walkRichTextTree: () => walkRichTextTree | ||
// src/nodes/table.ts | ||
var tableHtmlRenderer = ({ context, renderChildren }) => { | ||
return ["table", "tbody"].reduceRight((children, tag) => { | ||
return renderHtmlElement(tag, null, children); | ||
}, renderChildren(context.currentNode.children)); | ||
}; | ||
var tableTextRenderer = ({ context, renderChildren }) => { | ||
return hasChildren(context.currentNode) ? `${renderChildren(context.currentNode.children)} ` : ""; | ||
}; | ||
// src/nodes/tablecell.ts | ||
var tablecellHtmlRenderer = ({ context, renderChildren }) => { | ||
const node = context.currentNode; | ||
const tag = getRichTextTagFromTableCellHeaderState(node.headerState); | ||
return renderHtmlElement(tag, null, renderChildren(context.currentNode.children)); | ||
}; | ||
var tablecellTextRenderer = ({ context, renderChildren }) => { | ||
return hasChildren(context.currentNode) ? `${renderChildren(context.currentNode.children)} ` : ""; | ||
}; | ||
function getRichTextTagFromTableCellHeaderState(headerState) { | ||
if (headerState === 0) { | ||
return "td"; | ||
} | ||
return "th"; | ||
} | ||
// src/nodes/tablerow.ts | ||
var tablerowHtmlRenderer = ({ context, renderChildren }) => { | ||
return renderHtmlElement("tr", null, renderChildren(context.currentNode.children)); | ||
}; | ||
var tablerowTextRenderer = ({ context, renderChildren }) => { | ||
return hasChildren(context.currentNode) ? `${renderChildren(context.currentNode.children)} ` : ""; | ||
}; | ||
// src/nodes/text.ts | ||
@@ -272,3 +311,6 @@ var textHtmlRenderer = ({ context }) => { | ||
["text", textHtmlRenderer], | ||
["tab", tabHtmlRenderer] | ||
["tab", tabHtmlRenderer], | ||
["table", tableHtmlRenderer], | ||
["tablecell", tablecellHtmlRenderer], | ||
["tablerow", tablerowHtmlRenderer] | ||
]); | ||
@@ -341,3 +383,6 @@ var resolveDefaultRenderer = (context) => { | ||
["listitem", listitemTextRenderer], | ||
["heading", headingTextRenderer] | ||
["heading", headingTextRenderer], | ||
["table", tableTextRenderer], | ||
["tablecell", tablecellTextRenderer], | ||
["tablerow", tablerowTextRenderer] | ||
]); | ||
@@ -446,2 +491,6 @@ var resolveDefaultRenderer2 = (context) => { | ||
{ | ||
label: "Table", | ||
type: "table" | ||
}, | ||
{ | ||
label: "Dynamic Token", | ||
@@ -494,6 +543,29 @@ type: "variable" | ||
}; | ||
var emptyRichTextValue = { | ||
root: { | ||
type: "root", | ||
version: 1, | ||
direction: null, | ||
format: "", | ||
indent: 0, | ||
children: [ | ||
{ | ||
type: "paragraph", | ||
version: 1, | ||
format: "start", | ||
indent: 0, | ||
direction: null, | ||
children: [], | ||
textFormat: 0, | ||
textStyle: "" | ||
} | ||
] | ||
} | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
emptyRichTextValue, | ||
getLabelForElement, | ||
getLabelForFormat, | ||
getRichTextTagFromTableCellHeaderState, | ||
getRichTextTagsFromTextFormat, | ||
@@ -525,4 +597,7 @@ hasChildren, | ||
rootHtmlRenderer, | ||
tableHtmlRenderer, | ||
tablecellHtmlRenderer, | ||
tablerowHtmlRenderer, | ||
textHtmlRenderer, | ||
walkRichTextTree | ||
}); |
{ | ||
"name": "@uniformdev/richtext", | ||
"version": "19.173.2-alpha.8+7b0bc70fd5", | ||
"version": "19.173.2-alpha.210+4f0f6ff104", | ||
"description": "Common functionality and types for Uniform Rich Text parameters", | ||
@@ -43,9 +43,8 @@ "license": "SEE LICENSE IN LICENSE.txt", | ||
"devDependencies": { | ||
"@lexical/headless": "0.16.1", | ||
"@lexical/html": "0.16.1", | ||
"@lexical/link": "0.16.1", | ||
"@lexical/list": "0.16.1", | ||
"@lexical/rich-text": "0.16.1", | ||
"@uniformdev/canvas": "^19.173.2-alpha.8+7b0bc70fd5", | ||
"lexical": "0.16.1" | ||
"@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", | ||
"lexical": "0.17.1" | ||
}, | ||
@@ -58,3 +57,3 @@ "files": [ | ||
}, | ||
"gitHead": "7b0bc70fd58912415a860667c266cb339fa8133a" | ||
"gitHead": "4f0f6ff104f46349c338fde461f063f22f04ce0e" | ||
} |
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
84107
6
2382