ソースを参照

fix: shape backlinks display issue

Peng Xiao 3 年 前
コミット
161ac5d474

+ 1 - 2
src/main/frontend/extensions/tldraw.cljs

@@ -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
@@ -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]

+ 3 - 3
tldraw/apps/tldraw-logseq/src/app.tsx

@@ -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 = () => {
@@ -71,7 +71,7 @@ const AppImpl = () => {
   const components = React.useMemo(
     () => ({
       ContextBar,
-      ReferencesCount,
+      BacklinksCount,
       QuickLinks,
     }),
     []

+ 1 - 1
tldraw/apps/tldraw-logseq/src/lib/logseq-context.ts

@@ -25,7 +25,7 @@ export interface LogseqContextValue {
     BlockReference: React.FC<{
       blockId: string
     }>
-    ReferencesCount: React.FC<{
+    BacklinksCount: React.FC<{
       id: string
       className?: string
       options?: {

+ 2 - 2
tldraw/demo/src/App.jsx

@@ -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>
@@ -222,7 +222,7 @@ export default function App() {
           Block,
           Breadcrumb,
           PageName,
-          ReferencesCount,
+          BacklinksCount,
           BlockReference,
         }}
         handlers={{

+ 1 - 1
tldraw/packages/react/src/components/ReferencesCountContainer/ReferencesCountContainer.tsx → tldraw/packages/react/src/components/BacklinksCountContainer/BacklinksCountContainer.tsx

@@ -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()
 

+ 1 - 0
tldraw/packages/react/src/components/BacklinksCountContainer/index.ts

@@ -0,0 +1 @@
+export * from './BacklinksCountContainer'

+ 5 - 5
tldraw/packages/react/src/components/Canvas/Canvas.tsx

@@ -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'
@@ -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 && (

+ 0 - 0
tldraw/packages/react/src/components/ReferencesCountContainer copy/QuickLinksContainer.tsx → tldraw/packages/react/src/components/QuickLinksContainer/QuickLinksContainer.tsx


+ 0 - 0
tldraw/packages/react/src/components/ReferencesCountContainer copy/index.ts → tldraw/packages/react/src/components/QuickLinksContainer/index.ts


+ 0 - 1
tldraw/packages/react/src/components/ReferencesCountContainer/index.ts

@@ -1 +0,0 @@
-export * from './ReferencesCountContainer'

+ 4 - 4
tldraw/packages/react/src/types/component-props.ts

@@ -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> {
@@ -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