@tldraw/tlschema
Version:
tldraw infinite canvas SDK (schema).
30 lines (29 loc) • 564 B
JavaScript
import { T } from "@tldraw/validate";
const richTextValidator = T.object({
type: T.string,
content: T.arrayOf(T.unknown),
attrs: T.any.optional()
});
function toRichText(text) {
const lines = text.split("\n");
const content = lines.map((text2) => {
if (!text2) {
return {
type: "paragraph"
};
}
return {
type: "paragraph",
content: [{ type: "text", text: text2 }]
};
});
return {
type: "doc",
content
};
}
export {
richTextValidator,
toRichText
};
//# sourceMappingURL=TLRichText.mjs.map