@yuzhouu/canvas-kit 0.1.20 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -67,7 +67,7 @@ function SelectionToolbar() {
67
67
 
68
68
  Pass a `chromeRenderer` to `CanvasKitRoot`. The renderer receives the same `CanvasKit` available from `useCanvasKit()`. Product components subscribe only to the capability they render, for example `useCanvasValue(canvas.pages.state)` or `useCanvasValue(canvas.history.state)`.
69
69
 
70
- Zen and Professional build separate React trees and CSS from that facade. Feature controls call `canvas.api(token)` directly. Packaging UI therefore remains in Professional, while Connector is part of the standard plugin graph.
70
+ Zen and Professional build separate React trees and CSS from that facade. Feature controls call `canvas.api(token)` directly. Packaging UI therefore remains in Professional, while Zen composes Connector alongside Standard. Arrow, Connector and Packaging remain standalone opt-in plugins.
71
71
 
72
72
  ## Plugins and React composition
73
73
 
@@ -45,6 +45,8 @@ export interface EditorOptions {
45
45
  onUnhandledError?: (error: unknown) => void;
46
46
  snapDiagnostics?: SnapDiagnostics;
47
47
  cameraAnimationScheduler?: CameraAnimationScheduler;
48
+ minZoom?: number;
49
+ maxZoom?: number;
48
50
  }
49
51
  export interface CenterOnShapeOptions {
50
52
  source?: ChangeSource;
@@ -69,6 +71,7 @@ export declare class Editor {
69
71
  readonly inputs: InputsManager;
70
72
  readonly tools: ToolManager;
71
73
  private readonly cameraManager;
74
+ private readonly zoomLimits;
72
75
  readonly editing: ShapeEditingManager;
73
76
  readonly shapeUtils: ShapeUtilRegistry;
74
77
  readonly shapeSvgExporters: ShapeSvgExporterRegistry;
@@ -97,11 +100,13 @@ export declare class Editor {
97
100
  private readonly _shapeDefaultPropsByTypeSignal;
98
101
  private assetUrlResolver;
99
102
  private readonly _readonlySignal;
103
+ private readonly _documentLockedSignal;
100
104
  private writesClosed;
101
105
  readonly document: {
102
106
  readonly getMetadata: () => DocumentMetadataRecord | undefined;
103
107
  readonly updateMetadata: (patch: Record<string, unknown>, source?: ChangeSource) => DocumentMetadataRecord;
104
108
  readonly setReadonly: (readonly: boolean) => void;
109
+ readonly setLocked: (isLocked: boolean) => void;
105
110
  };
106
111
  readonly session: {
107
112
  readonly get: () => SessionRecord;
@@ -286,6 +291,7 @@ export declare class Editor {
286
291
  readonly resolveTerminal: (input: TerminalBindingResolverInput) => ResolvedTerminalBinding;
287
292
  };
288
293
  readonly viewport: {
294
+ readonly clampZoom: (zoom: number) => number;
289
295
  readonly getCamera: (pageId?: PageId) => Camera;
290
296
  readonly pageToScreen: (point: Vec, pageId?: PageId) => Vec;
291
297
  readonly screenToPage: (point: Vec, pageId?: PageId) => Vec;
@@ -305,6 +311,15 @@ export declare class Editor {
305
311
  }) => void;
306
312
  readonly stopCameraAnimation: () => void;
307
313
  readonly getCurrentPageBounds: (pageId?: PageId) => Box | null;
314
+ readonly centerOnPoint: (point: {
315
+ x: number;
316
+ y: number;
317
+ }, options?: {
318
+ source?: ChangeSource;
319
+ animation?: {
320
+ durationMs: number;
321
+ };
322
+ }) => boolean;
308
323
  readonly centerOnShape: (shapeId: ShapeId, options?: CenterOnShapeOptions) => boolean;
309
324
  readonly zoomToBounds: (bounds: Box, options?: {
310
325
  padding?: number;
@@ -352,6 +367,7 @@ export declare class Editor {
352
367
  };
353
368
  constructor(options?: EditorOptions);
354
369
  closeWrites(): void;
370
+ private setDocumentReadonlyFlag;
355
371
  assertDocumentWriteAllowed(): void;
356
372
  private assertStoreChangeAllowed;
357
373
  private registerBuiltInInteractions;
@@ -2,7 +2,10 @@ import { type ChangeSource } from "../../../store/index";
2
2
  import { type EditorRecord } from "../../schema/records";
3
3
  import { type DocumentSnapshot, type SessionSnapshot } from "../../schema/snapshots";
4
4
  import type { Editor } from "../editor";
5
- export declare function createInitialEditorRecords(documentMeta?: Record<string, unknown>): EditorRecord[];
5
+ export declare function createInitialEditorRecords({ documentMeta, initialZoom, }: {
6
+ documentMeta?: Record<string, unknown>;
7
+ initialZoom: number;
8
+ }): EditorRecord[];
6
9
  export declare function getEditorDocumentSnapshot(editor: Editor): DocumentSnapshot;
7
10
  export declare function getEditorSessionSnapshot(editor: Editor): SessionSnapshot;
8
11
  export declare function loadEditorDocumentSnapshot(editor: Editor, snapshot: unknown, options?: {
@@ -4,6 +4,7 @@ import type { ShapeSelectionHandleAnchors, ShapeSelectionPathStyle } from "../..
4
4
  import type { SelectionBindingMiddleHandle, SelectionBindingSegment, SelectionBindingTerminalHandle, SelectionCustomHandle, SelectionFrame, SelectionOverlayHandleAnchorsState, SelectionResizeHandle, SelectionResizeHandleId, SelectionRotateHandle } from "./selection";
5
5
  export interface SelectedShapeOverlayItem {
6
6
  id: ShapeId;
7
+ frameCorners: Vec[];
7
8
  usesSelectionPathOverlay: boolean;
8
9
  startPagePoint: Vec | null;
9
10
  endPagePoint: Vec | null;
@@ -11,6 +11,7 @@ import type { RenderItem } from "../viewport/renderWindow";
11
11
  import type { EditorSelectionMetadata, EditorSelectionState, EditorShapeEditingState, EditorToolState, ShapeTreeSnapshotEntry } from "./editorReadModels";
12
12
  export interface EditorStateSignals {
13
13
  readonly readonly: Signal<boolean>;
14
+ readonly documentLocked: Signal<boolean>;
14
15
  readonly session: Signal<SessionRecord>;
15
16
  readonly pages: Signal<PageRecord[]>;
16
17
  readonly currentPageId: Signal<PageId>;
@@ -1,3 +1,6 @@
1
- export declare const CAMERA_MIN_ZOOM = 0.1;
2
- export declare const CAMERA_MAX_ZOOM = 8;
3
- export declare function clampCameraZoom(zoom: number): number;
1
+ export interface CameraZoomLimits {
2
+ readonly minZoom: number;
3
+ readonly maxZoom: number;
4
+ }
5
+ export declare function resolveCameraZoomLimits({ minZoom, maxZoom, }: Partial<CameraZoomLimits>): CameraZoomLimits;
6
+ export declare function clampCameraZoom(zoom: number, limits: CameraZoomLimits): number;
@@ -1,12 +1,17 @@
1
- import type { Editor, ShapeRecord } from "../../../canvas-core/index";
1
+ import { type Editor, type ShapeId, type ShapeRecord } from "../../../canvas-core/index";
2
2
  import { type AnyRegisteredShapeRenderer, type ShapeRendererProps } from "../../host/canvasRenderPlugin";
3
+ import type { ShapeFrame } from "./shapeFrame";
3
4
  interface MemoizedShapeRendererProps extends ShapeRendererProps {
4
5
  Component: AnyRegisteredShapeRenderer["component"];
5
6
  }
6
7
  export declare const MemoizedShapeRenderer: import("react").NamedExoticComponent<MemoizedShapeRendererProps>;
7
- export declare function ShapeHoverDecoration({ Component, editor, shape, }: {
8
+ export declare function ShapeHoverDecoration({ Component, editor, shape, frame, clipAncestorIds, opacity, stackingOrder, }: {
8
9
  Component: NonNullable<AnyRegisteredShapeRenderer["hoverComponent"]>;
9
10
  editor: Editor;
10
11
  shape: ShapeRecord;
11
- }): import("react/jsx-runtime").JSX.Element;
12
+ frame: ShapeFrame;
13
+ clipAncestorIds: readonly ShapeId[];
14
+ opacity: number;
15
+ stackingOrder: number;
16
+ }): import("react/jsx-runtime").JSX.Element | null;
12
17
  export {};
@@ -25,11 +25,10 @@ export interface ShapeHeadingControlProps<S extends ShapeRecordBase = ShapeRecor
25
25
  readonly color?: string;
26
26
  readonly offsetX?: number;
27
27
  readonly editable?: boolean;
28
- readonly showBackground?: boolean;
29
28
  readonly showDragHandle?: boolean;
30
29
  }
31
30
  export declare function createShapeHeadingDomEventGuard({ id, selector, }: {
32
31
  id: string;
33
32
  selector: string;
34
33
  }): CanvasDomEventGuard;
35
- export declare function ShapeHeadingControl<S extends ShapeRecordBase>({ editor, shape, isEditing, value, fallback, bodyWidth, bodyHeight, renderHeight, operationKind, editAriaLabel, inputAriaLabel, dataUi, onValueChange, leading, color, offsetX, editable, showBackground, showDragHandle, }: ShapeHeadingControlProps<S>): import("react/jsx-runtime").JSX.Element;
34
+ export declare function ShapeHeadingControl<S extends ShapeRecordBase>({ editor, shape, isEditing, value, fallback, bodyWidth, bodyHeight, renderHeight, operationKind, editAriaLabel, inputAriaLabel, dataUi, onValueChange, leading, color, offsetX, editable, showDragHandle, }: ShapeHeadingControlProps<S>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ export declare function ShapeHoverRect({ dataUi, width, height, x, y, radius, strokeWidth, }: {
2
+ dataUi: string;
3
+ width: number;
4
+ height: number;
5
+ x?: number;
6
+ y?: number;
7
+ radius?: number;
8
+ strokeWidth: number;
9
+ }): import("react/jsx-runtime").JSX.Element;
@@ -7,13 +7,14 @@ export interface ShapeRendererProps<S extends ShapeRecordBase = ShapeRecordBase>
7
7
  shapeEditingSession: ShapeEditingSession | null;
8
8
  }
9
9
  /**
10
- * Rendered inside the shape's render-bounds host. SVG coordinates should match
11
- * the shape util's `getRenderBounds()` coordinate space.
10
+ * Rendered inside an SVG hover host that handles shape and ancestor transforms.
11
+ * Return SVG content with non-scaling strokes. Nested SVG coordinates should
12
+ * match the shape util's `getRenderBounds()` coordinate space; use x/y for offsets.
12
13
  */
13
14
  export interface ShapeHoverRendererProps<S extends ShapeRecordBase = ShapeRecordBase> {
14
15
  shape: S;
15
16
  editor: Editor;
16
- /** Local-space width that renders as the standard hover width on screen. */
17
+ /** Zoom-adjusted SVG non-scaling stroke width, independent of shape scale. */
17
18
  strokeWidth: number;
18
19
  }
19
20
  export declare const SHAPE_HOVER_STROKE = "var(--land-shape-hover, var(--land-selection, #2563eb))";
@@ -2,6 +2,7 @@ export { CanvasRenderBindingsContext, useCanvasOverlays, useCanvasRenderBindings
2
2
  export type { CanvasDomEventGuards, CanvasOverlayLookup, CanvasRendererLookup, } from "./canvasRenderBindings";
3
3
  export type { AnyRegisteredSelectionCustomHandleRenderer, AnyRegisteredShapeRenderer, CanvasOverlayContribution, CanvasDomEventGuard, CanvasDomEventGuardCursorInput, CanvasDomEventGuardDecision, CanvasDomEventGuardInput, CanvasDomEventGuardName, CanvasRenderPluginComponent, CanvasRenderPlugin, RegisteredSelectionCustomHandleRenderer, RegisteredShapeDecoration, RegisteredShapeRenderer, SelectionCustomHandleRendererProps, ShapeHoverRendererProps, ShapeRendererProps, ShapeOpacityModifier, } from "./canvasRenderPlugin";
4
4
  export { SHAPE_HOVER_STROKE, SHAPE_HOVER_STROKE_WIDTH, } from "./canvasRenderPlugin";
5
+ export { ShapeHoverRect } from "./ShapeHoverRect";
5
6
  export { ShapeHeadingControl, createShapeHeadingDomEventGuard, } from "./ShapeHeadingControl";
6
7
  export type { ShapeHeadingControlProps, ShapeHeadingDataUi, } from "./ShapeHeadingControl";
7
8
  export { createCanvasRenderBindings, type CanvasRenderBindings, } from "./canvasRenderBindings";
@@ -3,3 +3,4 @@ export type { CanvasContextMenuRequest, CanvasContextMenuTarget, } from "./conte
3
3
  export { CANVAS_SURFACE_DATA_UI, CANVAS_SURFACE_SELECTOR, forwardWheelEventToCanvasSurface, getCanvasSurfaceElement, getCanvasSurfaceElementForNode, getCanvasSurfacePagePoint, getCanvasSurfaceScreenPoint, getEditableEventTarget, isEditableEventTarget, } from "./dom";
4
4
  export { useEditor, EditorContext } from "./hooks/useEditor";
5
5
  export { useValue } from "./hooks/useValue";
6
+ export { BindingSegmentsOverlay } from "./components/overlays/SelectionPathOverlay";