(children: Descendant[])
| 129 | } |
| 130 | |
| 131 | export 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 | |
| 156 | export const getAllMentionElements = (children: Descendant[]): MentionElement[] => { |
| 157 | return children.flatMap((child) => { |
no test coverage detected