From 764f26007f8909b6fafdaa64cb076718f788593a Mon Sep 17 00:00:00 2001 From: David Sheldrick Date: Sun, 16 Jun 2024 18:12:04 +0300 Subject: [PATCH] Make ArrowBindingUtil public (#3913) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I wanted to extend the arrow binding util to adapt holograph for the bindings api, but it wasn't being exported like all the shape utils were. I could have plucked it from the `defaultBindingUtils` array but that felt dirty. What do you think @SomeHats ? ### Change Type - [x] `sdk` — Changes the tldraw SDK - [ ] `dotcom` — Changes the tldraw.com web app - [ ] `docs` — Changes to the documentation, examples, or templates. - [ ] `vs code` — Changes to the vscode plugin - [ ] `internal` — Does not affect user-facing stuff - [ ] `bugfix` — Bug fix - [x] `feature` — New feature - [ ] `improvement` — Improving existing features - [ ] `chore` — Updating dependencies, other boring stuff - [ ] `galaxy brain` — Architectural changes - [ ] `tests` — Changes to any test code - [ ] `tools` — Changes to infrastructure, CI, internal scripts, debugging tools, etc. - [ ] `dunno` — I don't know ### Test Plan 1. Add a step-by-step description of how to test your PR here. 2. - [ ] Unit Tests - [ ] End to end tests ### Release Notes - Add a brief release note for your PR here. --- packages/tldraw/api-report.md | 29 +++++++++++++++++++ packages/tldraw/src/index.ts | 1 + .../lib/bindings/arrow/ArrowBindingUtil.ts | 3 ++ 3 files changed, 33 insertions(+) diff --git a/packages/tldraw/api-report.md b/packages/tldraw/api-report.md index 0962a3756..1394ab6a9 100644 --- a/packages/tldraw/api-report.md +++ b/packages/tldraw/api-report.md @@ -9,6 +9,11 @@ import { ArrayOfValidator } from '@tldraw/editor'; import { BaseBoxShapeTool } from '@tldraw/editor'; import { BaseBoxShapeUtil } from '@tldraw/editor'; +import { BindingOnChangeOptions } from '@tldraw/editor'; +import { BindingOnCreateOptions } from '@tldraw/editor'; +import { BindingOnShapeChangeOptions } from '@tldraw/editor'; +import { BindingOnShapeIsolateOptions } from '@tldraw/editor'; +import { BindingUtil } from '@tldraw/editor'; import { Box } from '@tldraw/editor'; import { Circle2d } from '@tldraw/editor'; import { ComponentType } from 'react'; @@ -37,6 +42,7 @@ import { default as React_3 } from 'react'; import { ReactElement } from 'react'; import { ReactNode } from 'react'; import { ReadonlySharedStyleMap } from '@tldraw/editor'; +import { RecordProps } from '@tldraw/editor'; import { Rectangle2d } from '@tldraw/editor'; import { RecursivePartial } from '@tldraw/editor'; import { Result } from '@tldraw/editor'; @@ -50,6 +56,7 @@ import { T } from '@tldraw/editor'; import { TLAnyBindingUtilConstructor } from '@tldraw/editor'; import { TLAnyShapeUtilConstructor } from '@tldraw/editor'; import { TLArrowBinding } from '@tldraw/editor'; +import { TLArrowBindingProps } from '@tldraw/editor'; import { TLArrowShape } from '@tldraw/editor'; import { TLArrowShapeArrowheadStyle } from '@tldraw/editor'; import { TLAssetId } from '@tldraw/editor'; @@ -130,6 +137,28 @@ export function AlignMenuItems(): JSX_2.Element; // @public (undocumented) export function ArrangeMenuSubmenu(): JSX_2.Element | null; +// @public (undocumented) +export class ArrowBindingUtil extends BindingUtil { + // (undocumented) + getDefaultProps(): Partial; + // (undocumented) + static migrations: TLPropsMigrations; + // (undocumented) + onAfterChange({ bindingAfter }: BindingOnChangeOptions): void; + // (undocumented) + onAfterChangeFromShape({ shapeAfter, }: BindingOnShapeChangeOptions): void; + // (undocumented) + onAfterChangeToShape({ binding }: BindingOnShapeChangeOptions): void; + // (undocumented) + onAfterCreate({ binding }: BindingOnCreateOptions): void; + // (undocumented) + onBeforeIsolateFromShape({ binding, }: BindingOnShapeIsolateOptions): void; + // (undocumented) + static props: RecordProps; + // (undocumented) + static type: string; +} + // @public (undocumented) export function ArrowDownToolbarItem(): JSX_2.Element; diff --git a/packages/tldraw/src/index.ts b/packages/tldraw/src/index.ts index 519575acf..5ce07daa8 100644 --- a/packages/tldraw/src/index.ts +++ b/packages/tldraw/src/index.ts @@ -5,6 +5,7 @@ export * from '@tldraw/editor' export { getAssetFromIndexedDb, storeAssetInIndexedDb } from './lib/AssetBlobStore' export { Tldraw, type TLComponents, type TldrawProps } from './lib/Tldraw' export { TldrawImage, type TldrawImageProps } from './lib/TldrawImage' +export { ArrowBindingUtil } from './lib/bindings/arrow/ArrowBindingUtil' export { TldrawHandles } from './lib/canvas/TldrawHandles' export { TldrawScribble } from './lib/canvas/TldrawScribble' export { TldrawSelectionBackground } from './lib/canvas/TldrawSelectionBackground' diff --git a/packages/tldraw/src/lib/bindings/arrow/ArrowBindingUtil.ts b/packages/tldraw/src/lib/bindings/arrow/ArrowBindingUtil.ts index 2ccef16a6..ee457b5e9 100644 --- a/packages/tldraw/src/lib/bindings/arrow/ArrowBindingUtil.ts +++ b/packages/tldraw/src/lib/bindings/arrow/ArrowBindingUtil.ts @@ -24,6 +24,9 @@ import { } from '@tldraw/editor' import { getArrowBindings, getArrowInfo, removeArrowBinding } from '../../shapes/arrow/shared' +/** + * @public + */ export class ArrowBindingUtil extends BindingUtil { static override type = 'arrow'