MCPcopy
hub / github.com/udecode/plate / pipeRenderTextStatic

Function pipeRenderTextStatic

packages/core/src/static/pluginRenderTextStatic.tsx:50–127  ·  view source on GitHub ↗
(
  editor: SlateEditor,
  { renderText: renderTextProp }: { renderText?: SlateRenderText } = {}
)

Source from the content-addressed store, hash-verified

48
49/** @see {@link RenderText} */
50export const pipeRenderTextStatic = (
51 editor: SlateEditor,
52 { renderText: renderTextProp }: { renderText?: SlateRenderText } = {}
53): SlateRenderText => {
54 const renderTexts: SlateRenderText[] = [];
55 const textPropsPlugins: SlatePlugin[] = [];
56
57 editor.meta.pluginCache.node.isText.forEach((key) => {
58 const plugin = editor.getPlugin({ key });
59
60 if (plugin) {
61 renderTexts.push(pluginRenderTextStatic(editor, plugin as any));
62 }
63 });
64
65 editor.meta.pluginCache.node.textProps.forEach((key) => {
66 const plugin = editor.getPlugin({ key });
67 if (plugin) {
68 textPropsPlugins.push(plugin as any);
69 }
70 });
71
72 return function render({ attributes, ...props }) {
73 renderTexts.forEach((render) => {
74 const newChildren = render(props as any);
75
76 if (newChildren !== undefined) {
77 props.children = newChildren;
78 }
79 });
80
81 textPropsPlugins.forEach((plugin) => {
82 if (props.text[plugin.node.type ?? plugin.key]) {
83 const pluginTextProps =
84 typeof plugin.node.textProps === 'function'
85 ? plugin.node.textProps(props as any)
86 : (plugin.node.textProps ?? {});
87
88 if (pluginTextProps.className) {
89 pluginTextProps.className = clsx(
90 (props as any).className,
91 pluginTextProps.className
92 );
93 }
94
95 attributes = {
96 ...attributes,
97 ...pluginTextProps,
98 };
99 }
100 });
101
102 if (renderTextProp) {
103 return renderTextProp({ attributes, ...props });
104 }
105
106 const ctxProps = getRenderNodeStaticProps({
107 editor,

Callers 2

BaseLeafStaticFunction · 0.90

Calls 3

getRenderNodeStaticPropsFunction · 0.90
getNodeDataAttributesFunction · 0.90
pluginRenderTextStaticFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…