@pixerate/editor-svelte 0.109.1 → 0.110.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.
@@ -5,6 +5,7 @@
5
5
  canvasToImagePoint,
6
6
  imageToCanvasPoint,
7
7
  createImagePlaybackLocator,
8
+ agentDragDraft,
8
9
  hitTestCrop,
9
10
  getCropCursor,
10
11
  calculateCropDrag,
@@ -26,6 +27,7 @@
26
27
  type TypeToolOptions,
27
28
  } from '@pixerate/editor/image-editor';
28
29
  import { untrack } from 'svelte';
30
+ import { trackPresenceDrag } from '@pixerate/editor/tools';
29
31
  import { createPlaybackSurface, getAgentPlayback } from '../playback/playback.svelte.js';
30
32
  import PresenceLayer from '../playback/PresenceLayer.svelte';
31
33
  import type { ReactiveImageEditor } from './imageEditorState.svelte.js';
@@ -325,6 +327,35 @@
325
327
  let currentPath: ImagePoint[] = [];
326
328
  let dragStartPoint: ImagePoint | null = null;
327
329
 
330
+ // The agent's drags pull out the crop box or the marquee as it goes, like a user's drag; the call
331
+ // that follows sets the real crop or selection.
332
+ let agentDrafting = false;
333
+ $effect(() => {
334
+ const presence = agentPresence;
335
+ return untrack(() =>
336
+ presence.subscribe(
337
+ trackPresenceDrag({
338
+ onDrag: (box) => {
339
+ if (cropDragInfo || selectionGesture.active) return;
340
+ const draft = agentDragDraft(mode, box, editor.controller.getState().imageDimensions);
341
+ if (!draft) return;
342
+ agentDrafting = true;
343
+ if ('crop' in draft) draftCrop = draft.crop;
344
+ else selectionDraft = draft.selectionPath;
345
+ void renderCanvas();
346
+ },
347
+ onEnd: () => {
348
+ if (!agentDrafting) return;
349
+ agentDrafting = false;
350
+ draftCrop = null;
351
+ selectionDraft = null;
352
+ void renderCanvas();
353
+ },
354
+ }),
355
+ ),
356
+ );
357
+ });
358
+
328
359
  async function renderCanvas(overrideAnnotation?: Annotation | null, overrideCrop?: CropBox | null) {
329
360
  if (!canvasEl || !containerEl) return;
330
361
  const vpWidth = containerEl.clientWidth || 800;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-svelte",
3
- "version": "0.109.1",
3
+ "version": "0.110.0",
4
4
  "description": "Svelte bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -160,7 +160,7 @@
160
160
  "@tiptap/extension-bubble-menu": "^2.27.3",
161
161
  "@tiptap/extension-placeholder": "^2.27.3",
162
162
  "@tiptap/starter-kit": "^2.27.3",
163
- "@pixerate/editor": "0.149.0"
163
+ "@pixerate/editor": "0.150.0"
164
164
  },
165
165
  "peerDependencies": {
166
166
  "@dagrejs/dagre": "^1.1.4",