From 219e885ce96f5ba08046c7e6287191fcd6edf3a6 Mon Sep 17 00:00:00 2001 From: celine Date: Thu, 8 Jan 2026 19:05:15 -0500 Subject: [PATCH] preserve text size when blocks are copy pasted into leaflet --- components/Blocks/TextBlock/RenderYJSFragment.tsx | 2 +- components/Blocks/TextBlock/useHandlePaste.ts | 11 +++++++++++ src/utils/getBlocksAsHTML.tsx | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/components/Blocks/TextBlock/RenderYJSFragment.tsx b/components/Blocks/TextBlock/RenderYJSFragment.tsx index 89d48d03..35c97cad 100644 --- a/components/Blocks/TextBlock/RenderYJSFragment.tsx +++ b/components/Blocks/TextBlock/RenderYJSFragment.tsx @@ -8,7 +8,7 @@ import { AtMentionLink } from "components/AtMentionLink"; import { Delta } from "src/utils/yjsFragmentToString"; import { ProfilePopover } from "components/ProfilePopover"; -type BlockElements = "h1" | "h2" | "h3" | null | "blockquote" | "p"; +type BlockElements = "h1" | "h2" | "h3" | null | "blockquote" | "p" | "small"; export function RenderYJSFragment({ value, wrapper, diff --git a/components/Blocks/TextBlock/useHandlePaste.ts b/components/Blocks/TextBlock/useHandlePaste.ts index 4ad4d5d3..1e50bc5d 100644 --- a/components/Blocks/TextBlock/useHandlePaste.ts +++ b/components/Blocks/TextBlock/useHandlePaste.ts @@ -299,6 +299,17 @@ const createBlockFromHTML = ( }, }); } + let textSize = child.getAttribute("data-text-size"); + if (textSize && ["default", "small", "large"].includes(textSize)) { + rep.mutate.assertFact({ + entity: entityID, + attribute: "block/text-size", + data: { + type: "text-size-union", + value: textSize as "default" | "small" | "large", + }, + }); + } if (child.tagName === "A") { let href = child.getAttribute("href"); let dataType = child.getAttribute("data-type"); diff --git a/src/utils/getBlocksAsHTML.tsx b/src/utils/getBlocksAsHTML.tsx index 0f2c4003..98bf380a 100644 --- a/src/utils/getBlocksAsHTML.tsx +++ b/src/utils/getBlocksAsHTML.tsx @@ -172,6 +172,7 @@ const BlockTypeToHTML: { text: async (b, tx, a) => { let [value] = await scanIndex(tx).eav(b.value, "block/text"); let [textSize] = await scanIndex(tx).eav(b.value, "block/text-size"); + return (