From 9daec097a62d5edbbb8fc901d888c413cab5f611 Mon Sep 17 00:00:00 2001 From: Peng Xiao Date: Sun, 27 Nov 2022 19:42:37 +0800 Subject: [PATCH] fix: optimize block link reference display in whiteboard --- .../src/components/BlockLink/BlockLink.tsx | 20 +++++++++++++++---- .../src/components/QuickLinks/QuickLinks.tsx | 14 ++++++++----- .../src/components/inputs/ShapeLinksInput.tsx | 5 ++++- tldraw/packages/core/src/lib/TLSettings.ts | 1 - 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/tldraw/apps/tldraw-logseq/src/components/BlockLink/BlockLink.tsx b/tldraw/apps/tldraw-logseq/src/components/BlockLink/BlockLink.tsx index a7b1607162..1e5701a867 100644 --- a/tldraw/apps/tldraw-logseq/src/components/BlockLink/BlockLink.tsx +++ b/tldraw/apps/tldraw-logseq/src/components/BlockLink/BlockLink.tsx @@ -3,7 +3,13 @@ import React from 'react' import { LogseqContext } from '../../lib/logseq-context' import { TablerIcon } from '../icons' -export const BlockLink = ({ id }: { id: string }) => { +export const BlockLink = ({ + id, + showReferenceContent = false, +}: { + id: string + showReferenceContent?: boolean +}) => { const { handlers: { isWhiteboardPage, redirectToPage, sidebarAddBlock, queryBlockByUUID }, renderers: { Breadcrumb, PageName, BlockReference }, @@ -11,13 +17,16 @@ export const BlockLink = ({ id }: { id: string }) => { let iconName = '' let linkType = validUUID(id) ? 'B' : 'P' + let blockContent = '' if (validUUID(id)) { const block = queryBlockByUUID(id) if (!block) { - return Invalid reference. Did you remove it? + return Invalid reference. Did you remove it? } + blockContent = block.content + if (block.properties?.['ls-type'] === 'whiteboard-shape') { iconName = 'link-to-whiteboard' } else { @@ -31,6 +40,9 @@ export const BlockLink = ({ id }: { id: string }) => { } } + const slicedContent = + blockContent && blockContent.length > 23 ? blockContent.slice(0, 20) + '...' : blockContent + return (