@pixerate/editor-svelte 0.125.0 → 0.127.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.
|
@@ -93,6 +93,11 @@
|
|
|
93
93
|
open?: (ref: PlaybackRef) => void | Promise<void>;
|
|
94
94
|
/** Whether wheel zoom and middle/space drag panning are enabled (default true). */
|
|
95
95
|
viewportGestures?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Pan mode (a host's hand tool): a primary drag pans the view in every mode, as holding Space
|
|
98
|
+
* does, and the canvas's own gestures pause. Needs `viewportGestures`. Default false.
|
|
99
|
+
*/
|
|
100
|
+
panMode?: boolean;
|
|
96
101
|
class?: string;
|
|
97
102
|
style?: string;
|
|
98
103
|
}
|
|
@@ -118,6 +123,7 @@
|
|
|
118
123
|
locateElement,
|
|
119
124
|
open,
|
|
120
125
|
viewportGestures = true,
|
|
126
|
+
panMode = false,
|
|
121
127
|
class: className = '',
|
|
122
128
|
style = '',
|
|
123
129
|
}: Props = $props();
|
|
@@ -200,6 +206,8 @@
|
|
|
200
206
|
|
|
201
207
|
let isSpacePressed = $state(false);
|
|
202
208
|
let isPanning = $state(false);
|
|
209
|
+
// A primary drag pans: Space held, or the host's pan mode.
|
|
210
|
+
const panning = $derived(viewportGestures && (isSpacePressed || panMode));
|
|
203
211
|
let panStartPoint: { clientX: number; clientY: number } | null = null;
|
|
204
212
|
let panStartOffset: { x: number; y: number } = { x: 0, y: 0 };
|
|
205
213
|
|
|
@@ -373,7 +381,7 @@
|
|
|
373
381
|
function handleFramePointerDown(e: PointerEvent): boolean {
|
|
374
382
|
if (mode !== 'transform' || transformTool.active || !canvasEl) return false;
|
|
375
383
|
// Middle-button and Space drags pan (see handleMouseDown).
|
|
376
|
-
if (e.button !== 0 ||
|
|
384
|
+
if (e.button !== 0 || panning) return false;
|
|
377
385
|
const c = editor.controller;
|
|
378
386
|
const { pt, tolerance } = transformPoint(e);
|
|
379
387
|
const frame = layerFrame();
|
|
@@ -498,6 +506,7 @@
|
|
|
498
506
|
viewportWidth: viewport.width,
|
|
499
507
|
viewportHeight: viewport.height,
|
|
500
508
|
pixelRatio: viewport.pixelRatio,
|
|
509
|
+
hostScale: viewport.hostScale,
|
|
501
510
|
fit,
|
|
502
511
|
showCropOverlay: mode === 'crop',
|
|
503
512
|
showSelectionOverlay: true,
|
|
@@ -528,6 +537,8 @@
|
|
|
528
537
|
}));
|
|
529
538
|
}
|
|
530
539
|
function handlePaintPointerDown(e: PointerEvent) {
|
|
540
|
+
// Panning: the drag moves the view (handleMouseDown), not the document.
|
|
541
|
+
if (panning && e.button === 0) return;
|
|
531
542
|
if (handleTransformPointerDown(e)) return;
|
|
532
543
|
if (handleFramePointerDown(e)) return;
|
|
533
544
|
if (mode !== 'paint' || e.button !== 0 || !canvasEl) return;
|
|
@@ -540,6 +551,7 @@
|
|
|
540
551
|
report('paint', paintGesture.down({ ...paintSamples(e)[0], altKey: e.altKey }));
|
|
541
552
|
}
|
|
542
553
|
function handlePaintPointerMove(e: PointerEvent) {
|
|
554
|
+
if (panning && !transformTool.active) return;
|
|
543
555
|
if (handleTransformPointerMove(e)) return;
|
|
544
556
|
if (mode === 'transform' && canvasEl) {
|
|
545
557
|
const { pt, tolerance } = transformPoint(e);
|
|
@@ -614,7 +626,7 @@
|
|
|
614
626
|
function handleMouseDown(e: MouseEvent) {
|
|
615
627
|
if (!canvasEl) return;
|
|
616
628
|
|
|
617
|
-
if (viewportGestures && (e.button === 1 || (e.button === 0 &&
|
|
629
|
+
if (viewportGestures && (e.button === 1 || (e.button === 0 && panning))) {
|
|
618
630
|
e.preventDefault();
|
|
619
631
|
isPanning = true;
|
|
620
632
|
panStartPoint = { clientX: e.clientX, clientY: e.clientY };
|
|
@@ -729,8 +741,9 @@
|
|
|
729
741
|
return;
|
|
730
742
|
}
|
|
731
743
|
|
|
732
|
-
if (
|
|
744
|
+
if (panning) {
|
|
733
745
|
canvasEl.style.cursor = 'grab';
|
|
746
|
+
return;
|
|
734
747
|
}
|
|
735
748
|
|
|
736
749
|
if (transformTool.active) return;
|
|
@@ -1013,7 +1026,7 @@
|
|
|
1013
1026
|
endFrameDrag(true);
|
|
1014
1027
|
}}
|
|
1015
1028
|
data-testid="image-editor-canvas"
|
|
1016
|
-
style="width: 100%; height: 100%;{transformActive || mode === 'transform' ? ` cursor: ${transformCursor};` : ''}"
|
|
1029
|
+
style="width: 100%; height: 100%;{panning ? ` cursor: ${isPanning ? 'grabbing' : 'grab'};` : transformActive || mode === 'transform' ? ` cursor: ${transformCursor};` : ''}"
|
|
1017
1030
|
class="absolute inset-0 w-full h-full block {transformActive || mode === 'transform' ? 'touch-none' : mode === 'paint' ? 'touch-none cursor-crosshair' : mode === 'annotate' && editor.state.activeTool === 'type' ? 'cursor-text' : mode === 'annotate' && editor.state.activeTool === 'shape' ? 'cursor-crosshair' : ''}"
|
|
1018
1031
|
></canvas>
|
|
1019
1032
|
{#if typeSession}
|
|
@@ -58,6 +58,11 @@ interface Props {
|
|
|
58
58
|
open?: (ref: PlaybackRef) => void | Promise<void>;
|
|
59
59
|
/** Whether wheel zoom and middle/space drag panning are enabled (default true). */
|
|
60
60
|
viewportGestures?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Pan mode (a host's hand tool): a primary drag pans the view in every mode, as holding Space
|
|
63
|
+
* does, and the canvas's own gestures pause. Needs `viewportGestures`. Default false.
|
|
64
|
+
*/
|
|
65
|
+
panMode?: boolean;
|
|
61
66
|
class?: string;
|
|
62
67
|
style?: string;
|
|
63
68
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { imageOutlineButtonClass } from './styles.js';
|
|
3
|
-
import { findLayer, type ImageEditorController, type ImageLayer, type SmartObjectLayer } from '@pixerate/editor/image-editor';
|
|
3
|
+
import { EFFECT_LAYER_USES, findLayer, type ImageEditorController, type ImageLayer, type SmartObjectLayer } from '@pixerate/editor/image-editor';
|
|
4
4
|
import { untrack } from 'svelte';
|
|
5
5
|
import EffectsBrowser from '../effects/EffectsBrowser.svelte';
|
|
6
6
|
import ImageEffectControls from './ImageEffectControls.svelte';
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
<EffectsBrowser {provider} uses={['filter']} title="Filters" onpick={(e) => ((browse = null), run(() => controller.applyEffectFilter(id, e.id)))} />
|
|
65
65
|
{/if}
|
|
66
66
|
{#if browse === 'layer'}
|
|
67
|
-
<EffectsBrowser {provider} uses={
|
|
67
|
+
<EffectsBrowser {provider} uses={EFFECT_LAYER_USES} title="Generators and overlays" onpick={(e) => ((browse = null), run(() => controller.addEffectLayer(e.id)))} />
|
|
68
68
|
{/if}
|
|
69
69
|
{#if generator && layer}
|
|
70
70
|
{@const id = layer.id}
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
import TypeOptionsBar from './TypeOptionsBar.svelte';
|
|
16
16
|
import AdjustmentLayersPanel from './AdjustmentLayersPanel.svelte';
|
|
17
17
|
import SelectionOptionsBar from './SelectionOptionsBar.svelte';
|
|
18
|
+
import ImageProviderEffectsPanel from './ImageProviderEffectsPanel.svelte';
|
|
18
19
|
|
|
19
20
|
interface Props {
|
|
20
21
|
controller: ImageEditorController;
|
|
@@ -98,6 +99,8 @@
|
|
|
98
99
|
<div class="font-medium text-sm text-foreground">Smart Filters</div>
|
|
99
100
|
<LayerEffectsPanel {controller} />
|
|
100
101
|
</div>
|
|
102
|
+
{:else if panelId === 'provider-effects'}
|
|
103
|
+
<ImageProviderEffectsPanel {controller} />
|
|
101
104
|
{:else if panelId === 'selection'}
|
|
102
105
|
<div class="flex flex-col gap-3">
|
|
103
106
|
<div class="font-medium text-sm text-foreground">Selection</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.127.0",
|
|
4
4
|
"description": "Svelte bindings and prompt/rich-text components for @pixerate/editor",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -168,7 +168,7 @@
|
|
|
168
168
|
"@tiptap/extension-bubble-menu": "^2.27.3",
|
|
169
169
|
"@tiptap/extension-placeholder": "^2.27.3",
|
|
170
170
|
"@tiptap/starter-kit": "^2.27.3",
|
|
171
|
-
"@pixerate/editor": "0.
|
|
171
|
+
"@pixerate/editor": "0.171.0"
|
|
172
172
|
},
|
|
173
173
|
"peerDependencies": {
|
|
174
174
|
"@dagrejs/dagre": "^1.1.4",
|