|
@@ -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 <span className='p-2'>Invalid reference. Did you remove it?</span>
|
|
|
+ return <span className="p-2">Invalid reference. Did you remove it?</span>
|
|
|
}
|
|
|
|
|
|
+ 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 (
|
|
|
<button
|
|
|
className="inline-flex gap-1 items-center w-full"
|
|
@@ -49,8 +61,8 @@ export const BlockLink = ({ id }: { id: string }) => {
|
|
|
<PageName pageName={id} />
|
|
|
) : (
|
|
|
<>
|
|
|
- <Breadcrumb levelLimit={1} blockId={id} endSeparator />
|
|
|
- <BlockReference blockId={id} />
|
|
|
+ <Breadcrumb levelLimit={1} blockId={id} endSeparator={showReferenceContent} />
|
|
|
+ {showReferenceContent && slicedContent}
|
|
|
</>
|
|
|
)}
|
|
|
</span>
|