import { Doc, applyUpdate, XmlElement, XmlHook, XmlText } from "yjs";
import { nodes, marks } from "prosemirror-schema-basic";
import { CSSProperties, Fragment } from "react";
import { theme } from "tailwind.config";
import * as base64 from "base64-js";
import { didToBlueskyUrl } from "src/utils/mentionUtils";
import { AtMentionLink } from "components/AtMentionLink";
import { Delta } from "src/utils/yjsFragmentToString";
type BlockElements = "h1" | "h2" | "h3" | null | "blockquote" | "p";
export function RenderYJSFragment({
value,
wrapper,
attrs,
}: {
value: string;
wrapper: BlockElements;
attrs?: { [k: string]: any };
}) {
if (!value)
return
) : (
node.toArray().map((node, index) => {
if (node.constructor === XmlText) {
let deltas = node.toDelta() as Delta[];
if (deltas.length === 0) return
;
return (
;
}
// Handle didMention inline nodes
if (node.constructor === XmlElement && node.nodeName === "didMention") {
const did = node.getAttribute("did") || "";
const text = node.getAttribute("text") || "";
return (
{text}
);
}
// Handle atMention inline nodes
if (node.constructor === XmlElement && node.nodeName === "atMention") {
const atURI = node.getAttribute("atURI") || "";
const text = node.getAttribute("text") || "";
return (
{props.children}
; case "blockquote": return{props.children}; case "h1": return