From 6faef733b6f5d3908c9de291463f5372eeccc506 Mon Sep 17 00:00:00 2001 From: Steve Ruiz Date: Thu, 29 Jun 2023 15:10:54 +0100 Subject: [PATCH] [improvement] export scribble manager (#1671) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR adds the `ScribbleManager` to the exports from `@tldraw/editor`. ### Change Type - [x] `minor` — New feature ### Release Notes - [@tldraw/tldraw] Export `ScribbleManager` --- packages/editor/api-report.md | 37 +++++++++++++++++++ packages/editor/src/index.ts | 1 + .../lib/editor/managers/ScribbleManager.ts | 1 + 3 files changed, 39 insertions(+) diff --git a/packages/editor/api-report.md b/packages/editor/api-report.md index 09e2e2d38..0db9b47cc 100644 --- a/packages/editor/api-report.md +++ b/packages/editor/api-report.md @@ -1870,6 +1870,43 @@ export const runtime: { hardReset: () => void; }; +// @public (undocumented) +export class ScribbleManager implements TLScribble { + constructor(opts: { + onUpdate: (scribble: TLScribble) => void; + onComplete: () => void; + size?: TLScribble['size']; + color?: TLScribble['color']; + opacity?: TLScribble['opacity']; + delay?: TLScribble['delay']; + }); + addPoint: (x: number, y: number) => void; + // (undocumented) + color: "accent" | "black" | "laser" | "muted-1" | "selection-fill" | "selection-stroke" | "white"; + // (undocumented) + delay: number; + // (undocumented) + delayRemaining: number; + getScribble(): TLScribble; + // (undocumented) + opacity: number; + // (undocumented) + pause: () => void; + // (undocumented) + points: Vec2dModel[]; + // (undocumented) + resume: () => void; + // (undocumented) + size: number; + // (undocumented) + state: "active" | "paused" | "starting" | "stopping"; + stop: () => void; + // (undocumented) + tick: TLTickEvent; + // (undocumented) + timeoutMs: number; +} + // @internal (undocumented) export function setDefaultEditorAssetUrls(assetUrls: TLEditorAssetUrls): void; diff --git a/packages/editor/src/index.ts b/packages/editor/src/index.ts index 5a4ed9235..491f88b3f 100644 --- a/packages/editor/src/index.ts +++ b/packages/editor/src/index.ts @@ -90,6 +90,7 @@ export { ExternalContentManager as PlopManager, type TLExternalContent, } from './lib/editor/managers/ExternalContentManager' +export { ScribbleManager } from './lib/editor/managers/ScribbleManager' export { BaseBoxShapeUtil, type TLBaseBoxShape } from './lib/editor/shapes/BaseBoxShapeUtil' export { ShapeUtil, diff --git a/packages/editor/src/lib/editor/managers/ScribbleManager.ts b/packages/editor/src/lib/editor/managers/ScribbleManager.ts index a5c92c03e..cfce32077 100644 --- a/packages/editor/src/lib/editor/managers/ScribbleManager.ts +++ b/packages/editor/src/lib/editor/managers/ScribbleManager.ts @@ -2,6 +2,7 @@ import { Vec2d, VecLike } from '@tldraw/primitives' import { TLScribble, Vec2dModel } from '@tldraw/tlschema' import { TLTickEvent } from '../types/event-types' +/** @public */ export class ScribbleManager implements TLScribble { // Scribble properties state