MCPcopy Index your code
hub / github.com/sourcebot-dev/sourcebot / slateContentToString

Function slateContentToString

packages/web/src/features/chat/utils.ts:131–154  ·  view source on GitHub ↗
(children: Descendant[])

Source from the content-addressed store, hash-verified

129}
130
131export const slateContentToString = (children: Descendant[]): string => {
132 return children.map((child) => {
133 if (isCustomTextElement(child)) {
134 return child.text;
135 }
136
137 else if (isMentionElement(child)) {
138 const { type } = child.data;
139
140 switch (type) {
141 case 'file':
142 return `${fileReferenceToString({ repo: child.data.repo, path: child.data.path })} `;
143 }
144 }
145
146 else if (isParagraphElement(child)) {
147 return `${slateContentToString(child.children)}\n`;
148 }
149
150 else {
151 return "";
152 }
153 }).join("");
154}
155
156export const getAllMentionElements = (children: Descendant[]): MentionElement[] => {
157 return children.flatMap((child) => {

Callers 3

useCreateNewChatThreadFunction · 0.90
ChatBoxComponentFunction · 0.90
ChatThreadFunction · 0.90

Calls 4

isCustomTextElementFunction · 0.85
fileReferenceToStringFunction · 0.85
isMentionElementFunction · 0.70
isParagraphElementFunction · 0.70

Tested by

no test coverage detected