Skip to content

Commit

Permalink
fix: shape backlinks display issue
Browse files Browse the repository at this point in the history
  • Loading branch information
pengx17 authored and tiensonqin committed Nov 23, 2022
1 parent e2e5ba8 commit 161ac5d
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 19 deletions.
3 changes: 1 addition & 2 deletions src/main/frontend/extensions/tldraw.cljs
Expand Up @@ -39,7 +39,6 @@

(rum/defc block-reference
[props]
(println "page-name-linkpage-name-linkpage-name-linkpage-name-link" props)
(block/block-reference {} (gobj/get props "blockId") nil))

(rum/defc page-name-link
Expand Down Expand Up @@ -73,7 +72,7 @@
:Block block-cp
:Breadcrumb breadcrumb
:PageName page-name-link
:ReferencesCount references-count
:BacklinksCount references-count
:BlockReference block-reference})

(defn get-tldraw-handlers [current-whiteboard-name]
Expand Down
6 changes: 3 additions & 3 deletions tldraw/apps/tldraw-logseq/src/app.tsx
Expand Up @@ -57,12 +57,12 @@ interface LogseqTldrawProps {
onPersist?: TLReactCallbacks<Shape>['onPersist']
}

const ReferencesCount: LogseqContextValue['renderers']['ReferencesCount'] = props => {
const BacklinksCount: LogseqContextValue['renderers']['BacklinksCount'] = props => {
const { renderers } = React.useContext(LogseqContext)

const options = { 'portal?': false }

return <renderers.ReferencesCount {...props} options={options} />
return <renderers.BacklinksCount {...props} options={options} />
}

const AppImpl = () => {
Expand All @@ -71,7 +71,7 @@ const AppImpl = () => {
const components = React.useMemo(
() => ({
ContextBar,
ReferencesCount,
BacklinksCount,
QuickLinks,
}),
[]
Expand Down
2 changes: 1 addition & 1 deletion tldraw/apps/tldraw-logseq/src/lib/logseq-context.ts
Expand Up @@ -25,7 +25,7 @@ export interface LogseqContextValue {
BlockReference: React.FC<{
blockId: string
}>
ReferencesCount: React.FC<{
BacklinksCount: React.FC<{
id: string
className?: string
options?: {
Expand Down
4 changes: 2 additions & 2 deletions tldraw/demo/src/App.jsx
Expand Up @@ -87,7 +87,7 @@ const PageName = props => {
)
}

const ReferencesCount = props => {
const BacklinksCount = props => {
return (
<div className={props.className}>
<div className={'open-page-ref-link rounded bg-gray-400 p-0.5 '}>3</div>
Expand Down Expand Up @@ -222,7 +222,7 @@ export default function App() {
Block,
Breadcrumb,
PageName,
ReferencesCount,
BacklinksCount,
BlockReference,
}}
handlers={{
Expand Down
Expand Up @@ -24,7 +24,7 @@ export const BacklinksCountContainer = observer(function BacklinksCountContainer

const app = useApp<S>()

if (!BacklinksCount) throw Error('Expected a ReferencesCount component.')
if (!BacklinksCount) throw Error('Expected a BacklinksCount component.')

const stop: React.EventHandler<any> = e => e.stopPropagation()

Expand Down
@@ -0,0 +1 @@
export * from './BacklinksCountContainer'
10 changes: 5 additions & 5 deletions tldraw/packages/react/src/components/Canvas/Canvas.tsx
Expand Up @@ -22,8 +22,8 @@ import { Container } from '../Container'
import { ContextBarContainer } from '../ContextBarContainer'
import { HTMLLayer } from '../HTMLLayer'
import { Indicator } from '../Indicator'
import { QuickLinksContainer } from '../ReferencesCountContainer copy'
import { BacklinksCountContainer } from '../ReferencesCountContainer'
import { QuickLinksContainer } from '../QuickLinksContainer'
import { BacklinksCountContainer } from '../BacklinksCountContainer'
import { SelectionDetailContainer } from '../SelectionDetailContainer'
import { Shape } from '../Shape'
import { SVGContainer } from '../SVGContainer'
Expand Down Expand Up @@ -158,11 +158,11 @@ export const Canvas = observer(function Renderer<S extends TLReactShape>({
{hoveredShape && (
<Indicator key={'hovered_indicator_' + hoveredShape.id} shape={hoveredShape} />
)}
{selectedOrHooveredShape && components.BacklinksCount && (
{singleSelectedShape && components.BacklinksCount && (
<BacklinksCountContainer
hidden={false}
bounds={selectedOrHooveredShape.bounds}
shape={selectedOrHooveredShape}
bounds={singleSelectedShape.bounds}
shape={singleSelectedShape}
/>
)}
{hoveredShape && hoveredShape !== singleSelectedShape && components.QuickLinks && (
Expand Down

This file was deleted.

8 changes: 4 additions & 4 deletions tldraw/packages/react/src/types/component-props.ts
Expand Up @@ -72,14 +72,14 @@ export type TLHandleComponent<
H extends TLHandle = TLHandle
> = (props: TLHandleComponentProps<S, H>) => JSX.Element | null

export interface TLReferencesCountComponentProps<S extends TLReactShape = TLReactShape> {
export interface TLBacklinksCountComponentProps<S extends TLReactShape = TLReactShape> {
shape: S
id: string
className?: string
}

export type TLReferencesCountComponent<S extends TLReactShape = TLReactShape> = (
props: TLReferencesCountComponentProps<S>
export type TLBacklinksCountComponent<S extends TLReactShape = TLReactShape> = (
props: TLBacklinksCountComponentProps<S>
) => JSX.Element | null

export interface TLQuickLinksComponentProps<S extends TLReactShape = TLReactShape> {
Expand All @@ -102,7 +102,7 @@ export type TLReactComponents<S extends TLReactShape = TLReactShape> = {
SelectionBackground?: TLBoundsComponent<S> | null
SelectionForeground?: TLBoundsComponent<S> | null
SelectionDetail?: TLSelectionDetailComponent<S> | null
BacklinksCount?: TLReferencesCountComponent<S> | null
BacklinksCount?: TLBacklinksCountComponent<S> | null
QuickLinks?: TLQuickLinksComponent<S> | null
DirectionIndicator?: TLDirectionIndicatorComponent<S> | null
Handle?: TLHandleComponent<S> | null
Expand Down

0 comments on commit 161ac5d

Please sign in to comment.