@pixerate/editor-svelte 0.107.0 → 0.108.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.
@@ -0,0 +1,64 @@
1
+ import type { ImageEditorFit } from '@pixerate/editor/image-editor';
2
+ import type { AgentPlayback, PlaybackRect, PlaybackRef } from '@pixerate/editor/tools';
3
+ import { FreeTransformTool, type SelectionToolOptions, type ShapeToolOptions, type TextEditSession, type TypeToolOptions } from '@pixerate/editor/image-editor';
4
+ import type { ReactiveImageEditor } from './imageEditorState.svelte.js';
5
+ import type { ImageEditorCanvasErrorSource, ImageEditorCanvasMode } from './canvasTypes.js';
6
+ interface Props {
7
+ /** The editor to draw and edit (`createReactiveImageEditor`). */
8
+ editor: ReactiveImageEditor;
9
+ /**
10
+ * What pointer gestures do: `crop` (crop box and its overlay, in the crop margin), `select`
11
+ * (the selection tools), `paint` (brush, eraser, move and their shortcuts), `annotate`
12
+ * (annotations, shape and type layers, by the active tool) or `none` (view only). Free
13
+ * Transform works in every mode. Default `none`.
14
+ */
15
+ mode?: ImageEditorCanvasMode;
16
+ /** How the image fits the canvas (default: the renderer's). */
17
+ fit?: ImageEditorFit;
18
+ /** Options of the selection tools (magic wand tolerance, feather, …). */
19
+ selectionOptions?: SelectionToolOptions;
20
+ /** Options of the shape tool. */
21
+ shapeOptions?: ShapeToolOptions;
22
+ /** Options of the type tool. */
23
+ typeOptions?: TypeToolOptions;
24
+ /** Colour of new annotations (default `#ef4444`). */
25
+ annotationColor?: string;
26
+ /** Stroke width of new annotations, in image pixels (default 3). */
27
+ annotationWidth?: number;
28
+ /** Aspect ratio a crop handle drag keeps (width / height), or null for free (default). */
29
+ cropRatio?: number | null;
30
+ /** A gesture failed (`message`) or recovered (`null`). */
31
+ onerror?: (source: ImageEditorCanvasErrorSource, message: string | null) => void;
32
+ /** The text being edited on the canvas (bindable). Set it to `null` to finish editing. */
33
+ typeSession?: TextEditSession | null;
34
+ /**
35
+ * The Free Transform tool (Ctrl/Cmd+T) the canvas drives and draws. Pass your own to show its
36
+ * options bar or begin transforms from your UI; by default the canvas makes one.
37
+ */
38
+ transformTool?: FreeTransformTool;
39
+ /**
40
+ * Agent playback: act out the image tools' calls on this canvas with the agent's cursor
41
+ * (default: `setAgentPlayback` above; `null` turns it off).
42
+ */
43
+ playback?: AgentPlayback | null;
44
+ /** The playback surface id (default `image`, where the image tool providers play). */
45
+ playbackId?: string;
46
+ /** Bring the canvas on screen (switch to its tab) before the agent acts. */
47
+ onplaybackreveal?: () => void | Promise<void>;
48
+ /**
49
+ * Where the default playback lookups find the editor's chrome: tabs (`[data-image-tab]`),
50
+ * sliders (`[data-control-id]`) and layer rows (`[data-layer-id]`). Default: the canvas itself.
51
+ */
52
+ chromeRoot?: () => HTMLElement | null | undefined;
53
+ /** Your own lookup for a playback ref, in document pixels (tried first). */
54
+ locate?: (ref: PlaybackRef) => PlaybackRect | null;
55
+ /** Your own element for a playback ref, anywhere on the page; its box is mapped to document pixels. */
56
+ locateElement?: (ref: PlaybackRef) => Element | null;
57
+ /** Show a panel for an `open` step (default: click its `[data-image-tab]` under `chromeRoot`). */
58
+ open?: (ref: PlaybackRef) => void | Promise<void>;
59
+ class?: string;
60
+ style?: string;
61
+ }
62
+ declare const ImageEditorCanvas: import("svelte").Component<Props, {}, "typeSession">;
63
+ type ImageEditorCanvas = ReturnType<typeof ImageEditorCanvas>;
64
+ export default ImageEditorCanvas;
@@ -0,0 +1,4 @@
1
+ /** What pointer gestures on `ImageEditorCanvas` do (and whether the crop overlay shows). */
2
+ export type ImageEditorCanvasMode = 'crop' | 'select' | 'paint' | 'annotate' | 'none';
3
+ /** Which gesture an `ImageEditorCanvas` `onerror` report comes from. */
4
+ export type ImageEditorCanvasErrorSource = 'paint' | 'select' | 'shape' | 'type';
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,7 @@
1
1
  import type { ComponentProps } from "svelte";
2
2
  import type ImageEditorComponent from "./ImageEditor.svelte";
3
+ import type ImageEditorCanvasComponent from "./ImageEditorCanvas.svelte";
4
+ import type ImageEffectControlsComponent from "./ImageEffectControls.svelte";
3
5
  import type HistogramComponent from "./Histogram.svelte";
4
6
  import type AdjustmentLayersPanelComponent from "./AdjustmentLayersPanel.svelte";
5
7
  import type CurvesEditorComponent from "./CurvesEditor.svelte";
@@ -15,6 +17,9 @@ import type ShapeOptionsBarComponent from "./ShapeOptionsBar.svelte";
15
17
  import type TypeOptionsBarComponent from "./TypeOptionsBar.svelte";
16
18
  import type ImageProviderEffectsPanelComponent from "./ImageProviderEffectsPanel.svelte";
17
19
  export { default as ImageEditor } from './ImageEditor.svelte';
20
+ export { default as ImageEditorCanvas } from './ImageEditorCanvas.svelte';
21
+ export { default as ImageEffectControls } from './ImageEffectControls.svelte';
22
+ export type { ImageEditorCanvasMode, ImageEditorCanvasErrorSource } from './canvasTypes.js';
18
23
  export { default as PaintGradientEditor } from './PaintGradientEditor.svelte';
19
24
  export { default as Histogram } from './Histogram.svelte';
20
25
  export { default as AdjustmentLayersPanel } from './AdjustmentLayersPanel.svelte';
@@ -32,6 +37,8 @@ export { default as TypeOptionsBar } from './TypeOptionsBar.svelte';
32
37
  export { default as ImageProviderEffectsPanel } from './ImageProviderEffectsPanel.svelte';
33
38
  export * from './imageEditorState.svelte.js';
34
39
  export type ImageEditorProps = ComponentProps<typeof ImageEditorComponent>;
40
+ export type ImageEditorCanvasProps = ComponentProps<typeof ImageEditorCanvasComponent>;
41
+ export type ImageEffectControlsProps = ComponentProps<typeof ImageEffectControlsComponent>;
35
42
  export type HistogramProps = ComponentProps<typeof HistogramComponent>;
36
43
  export type AdjustmentLayersPanelProps = ComponentProps<typeof AdjustmentLayersPanelComponent>;
37
44
  export type CurvesEditorProps = ComponentProps<typeof CurvesEditorComponent>;
@@ -1,4 +1,6 @@
1
1
  export { default as ImageEditor } from './ImageEditor.svelte';
2
+ export { default as ImageEditorCanvas } from './ImageEditorCanvas.svelte';
3
+ export { default as ImageEffectControls } from './ImageEffectControls.svelte';
2
4
  export { default as PaintGradientEditor } from './PaintGradientEditor.svelte';
3
5
  export { default as Histogram } from './Histogram.svelte';
4
6
  export { default as AdjustmentLayersPanel } from './AdjustmentLayersPanel.svelte';
@@ -12,10 +12,12 @@
12
12
  * (`x * zoom + viewport.x`), or a function. Default: one to one.
13
13
  */
14
14
  viewport?: { x: number; y: number; zoom: number } | ((point: Point) => Point);
15
+ /** Clip the cursors to the layer's box (default true). `false` lets a cursor visit chrome outside it. */
16
+ clip?: boolean;
15
17
  class?: string;
16
18
  }
17
19
 
18
- let { presence, viewport, class: className = '' }: Props = $props();
20
+ let { presence, viewport, clip = true, class: className = '' }: Props = $props();
19
21
  let view: PresenceState = $state.raw(untrack(() => presence.getState()));
20
22
  $effect(() => {
21
23
  view = presence.getState();
@@ -44,7 +46,7 @@
44
46
  snapshots and exports. Parity with React's `<PresenceLayer>`.
45
47
  -->
46
48
  {#if view.actors.length}
47
- <div class="pixerate-presence {className}" aria-hidden="true" data-testid="presence-layer" style="position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 50;">
49
+ <div class="pixerate-presence {className}" aria-hidden="true" data-testid="presence-layer" style="position: absolute; inset: 0; pointer-events: none; overflow: {clip ? 'hidden' : 'visible'}; z-index: 50;">
48
50
  {#each view.actors as a (a.id)}
49
51
  {#if a.focus}
50
52
  <div data-actor-focus={a.id} style="position: absolute; {ring(a.focus)} border-radius: 8px; border: 2px solid {a.color}; background: {a.color}14; transition: all 160ms ease-out;"></div>
@@ -15,6 +15,8 @@ interface Props {
15
15
  y: number;
16
16
  zoom: number;
17
17
  } | ((point: Point) => Point);
18
+ /** Clip the cursors to the layer's box (default true). `false` lets a cursor visit chrome outside it. */
19
+ clip?: boolean;
18
20
  class?: string;
19
21
  }
20
22
  declare const PresenceLayer: import("svelte").Component<Props, {}, "">;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-svelte",
3
- "version": "0.107.0",
3
+ "version": "0.108.0",
4
4
  "description": "Svelte bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",