@pixerate/editor-react 0.176.0 → 0.178.0

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.
@@ -1673,6 +1673,7 @@ function useCanvasDraw(options) {
1673
1673
  drawOptions: options.drawOptions,
1674
1674
  generateNodeId: options.generateNodeId,
1675
1675
  brushLibrary: options.brushLibrary,
1676
+ colorScheme: options.colorScheme,
1676
1677
  onToolChange: setToolState,
1677
1678
  onStyleChange: (s) => setStyleState(s),
1678
1679
  onActiveStrokeChange: setActiveStroke,
@@ -1687,6 +1688,9 @@ function useCanvasDraw(options) {
1687
1688
  controller.setTool(options.initialTool);
1688
1689
  }
1689
1690
  }, [options.initialTool, controller]);
1691
+ (0, import_react17.useEffect)(() => {
1692
+ controller.setColorScheme(options.colorScheme ?? "light");
1693
+ }, [options.colorScheme, controller]);
1690
1694
  return (0, import_react17.useMemo)(
1691
1695
  () => ({
1692
1696
  tool,
@@ -1702,7 +1706,8 @@ function useCanvasDraw(options) {
1702
1706
  eraseAt: controller.eraseAt,
1703
1707
  drawStroke: controller.drawStroke,
1704
1708
  nodeBounds: controller.nodeBounds,
1705
- listBrushes: controller.listBrushes
1709
+ listBrushes: controller.listBrushes,
1710
+ selectBrush: controller.selectBrush
1706
1711
  }),
1707
1712
  [tool, style, activeStroke, controller]
1708
1713
  );
@@ -1214,6 +1214,7 @@ function useCanvasDraw(options) {
1214
1214
  drawOptions: options.drawOptions,
1215
1215
  generateNodeId: options.generateNodeId,
1216
1216
  brushLibrary: options.brushLibrary,
1217
+ colorScheme: options.colorScheme,
1217
1218
  onToolChange: setToolState,
1218
1219
  onStyleChange: (s) => setStyleState(s),
1219
1220
  onActiveStrokeChange: setActiveStroke,
@@ -1228,6 +1229,9 @@ function useCanvasDraw(options) {
1228
1229
  controller.setTool(options.initialTool);
1229
1230
  }
1230
1231
  }, [options.initialTool, controller]);
1232
+ useEffect7(() => {
1233
+ controller.setColorScheme(options.colorScheme ?? "light");
1234
+ }, [options.colorScheme, controller]);
1231
1235
  return useMemo7(
1232
1236
  () => ({
1233
1237
  tool,
@@ -1243,7 +1247,8 @@ function useCanvasDraw(options) {
1243
1247
  eraseAt: controller.eraseAt,
1244
1248
  drawStroke: controller.drawStroke,
1245
1249
  nodeBounds: controller.nodeBounds,
1246
- listBrushes: controller.listBrushes
1250
+ listBrushes: controller.listBrushes,
1251
+ selectBrush: controller.selectBrush
1247
1252
  }),
1248
1253
  [tool, style, activeStroke, controller]
1249
1254
  );
@@ -9,6 +9,8 @@ export interface UseCanvasDrawOptions<TNode extends CanvasNode = CanvasNode> {
9
9
  generateNodeId?: () => string;
10
10
  /** The brush library whose saved brushes strokes may use besides the presets (the canvas profile decides which); read once, on mount. */
11
11
  brushLibrary?: CanvasDrawControllerOptions<TNode>['brushLibrary'];
12
+ /** The app's colour scheme, which picks the side of a brush's light / dark default colour (default light). */
13
+ colorScheme?: 'light' | 'dark';
12
14
  onStrokeComplete?: (node: TNode) => void;
13
15
  onNodesErase?: (erasedNodes: TNode[]) => void;
14
16
  }
@@ -38,6 +40,13 @@ export interface CanvasDrawActions<TNode extends CanvasNode = CanvasNode> {
38
40
  } | undefined;
39
41
  /** The presets and saved brushes `style.brush` accepts (loads the paint engine). */
40
42
  listBrushes: () => Promise<CanvasBrushPreset[]>;
43
+ /**
44
+ * Picks a brush (`null`: plain pen) with its size, and its default colour unless `keepColour`.
45
+ * Resolves to the preset; rejects for a brush the canvas can't paint.
46
+ */
47
+ selectBrush: (id: string | null, choice?: {
48
+ keepColour?: boolean;
49
+ }) => Promise<CanvasBrushPreset | null>;
41
50
  }
42
51
  export type CanvasDraw<TNode extends CanvasNode = CanvasNode> = CanvasDrawState & CanvasDrawActions<TNode>;
43
52
  /**
@@ -9,6 +9,8 @@ export interface UseCanvasDrawOptions<TNode extends CanvasNode = CanvasNode> {
9
9
  generateNodeId?: () => string;
10
10
  /** The brush library whose saved brushes strokes may use besides the presets (the canvas profile decides which); read once, on mount. */
11
11
  brushLibrary?: CanvasDrawControllerOptions<TNode>['brushLibrary'];
12
+ /** The app's colour scheme, which picks the side of a brush's light / dark default colour (default light). */
13
+ colorScheme?: 'light' | 'dark';
12
14
  onStrokeComplete?: (node: TNode) => void;
13
15
  onNodesErase?: (erasedNodes: TNode[]) => void;
14
16
  }
@@ -38,6 +40,13 @@ export interface CanvasDrawActions<TNode extends CanvasNode = CanvasNode> {
38
40
  } | undefined;
39
41
  /** The presets and saved brushes `style.brush` accepts (loads the paint engine). */
40
42
  listBrushes: () => Promise<CanvasBrushPreset[]>;
43
+ /**
44
+ * Picks a brush (`null`: plain pen) with its size, and its default colour unless `keepColour`.
45
+ * Resolves to the preset; rejects for a brush the canvas can't paint.
46
+ */
47
+ selectBrush: (id: string | null, choice?: {
48
+ keepColour?: boolean;
49
+ }) => Promise<CanvasBrushPreset | null>;
41
50
  }
42
51
  export type CanvasDraw<TNode extends CanvasNode = CanvasNode> = CanvasDrawState & CanvasDrawActions<TNode>;
43
52
  /**
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { type PaintEditorController } from '@pixerate/editor/paint-editor';
3
+ export interface PathStrokePanelProps {
4
+ controller: PaintEditorController;
5
+ className?: string;
6
+ }
7
+ /**
8
+ * Brush a path: paste SVG path data (document pixels, e.g. from a vector tool) and brush it on
9
+ * the active layer with the active brush and colour, as if drawn by hand along it, with an even
10
+ * pressure or a taper. One undo step, as the `stroke_path` agent tool.
11
+ */
12
+ export declare const PathStrokePanel: React.FC<PathStrokePanelProps>;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { type PaintEditorController } from '@pixerate/editor/paint-editor';
3
+ export interface PathStrokePanelProps {
4
+ controller: PaintEditorController;
5
+ className?: string;
6
+ }
7
+ /**
8
+ * Brush a path: paste SVG path data (document pixels, e.g. from a vector tool) and brush it on
9
+ * the active layer with the active brush and colour, as if drawn by hand along it, with an even
10
+ * pressure or a taper. One undo step, as the `stroke_path` agent tool.
11
+ */
12
+ export declare const PathStrokePanel: React.FC<PathStrokePanelProps>;