feat: rewrite d2c to not require token (#8269)

This commit is contained in:
David Luzar
2024-08-20 18:06:22 +02:00
committed by GitHub
parent fb4bb29aa5
commit b5d7f5b4ba
19 changed files with 282 additions and 564 deletions
@@ -886,3 +886,19 @@ export const getMinTextElementWidth = (
) => {
return measureText("", font, lineHeight).width + BOUND_TEXT_PADDING * 2;
};
/** retrieves text from text elements and concatenates to a single string */
export const getTextFromElements = (
elements: readonly ExcalidrawElement[],
separator = "\n\n",
) => {
const text = elements
.reduce((acc: string[], element) => {
if (isTextElement(element)) {
acc.push(element.text);
}
return acc;
}, [])
.join(separator);
return text;
};