@pixerate/editor-svelte 0.36.0 → 0.37.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.
- package/dist/vector/VectorCanvas.svelte +11 -0
- package/dist/vector/VectorCanvas.svelte.d.ts.map +1 -1
- package/dist/vector/VectorWidthPointEditor.svelte +99 -0
- package/dist/vector/VectorWidthPointEditor.svelte.d.ts +14 -0
- package/dist/vector/VectorWidthPointEditor.svelte.d.ts.map +1 -0
- package/dist/vector/index.d.ts +1 -0
- package/dist/vector/index.d.ts.map +1 -1
- package/dist/vector/index.js +1 -0
- package/package.json +2 -2
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
} from '@pixerate/editor/vector';
|
|
18
18
|
import VectorGradientDefs from './VectorGradientDefs.svelte';
|
|
19
19
|
import VectorSceneNodes from './VectorSceneNodes.svelte';
|
|
20
|
+
import VectorWidthPointEditor from './VectorWidthPointEditor.svelte';
|
|
20
21
|
import { vectorStateOf } from './subscribe.svelte.js';
|
|
21
22
|
|
|
22
23
|
interface Props {
|
|
@@ -54,6 +55,8 @@
|
|
|
54
55
|
const scene = $derived(getVectorSceneRenderData(view, { idPrefix }));
|
|
55
56
|
const overlay = $derived(getVectorOverlayRenderData(view));
|
|
56
57
|
const box = $derived(overlay.selectionBox);
|
|
58
|
+
const edit = $derived(view.widthPointEdit);
|
|
59
|
+
const editAt = $derived(edit ? { x: edit.point.x * view.viewport.zoom + view.viewport.x, y: edit.point.y * view.viewport.zoom + view.viewport.y } : null);
|
|
57
60
|
const closing = $derived(view.tool === 'pen' ? overlay.anchors.find((a) => a.closes && a.hovered) : undefined);
|
|
58
61
|
const hs = THEME.transformHandleSize;
|
|
59
62
|
const as = THEME.anchorSize;
|
|
@@ -337,4 +340,12 @@
|
|
|
337
340
|
<text data-vector-status="" x="8" y="100%" dy="-8" font-size="11" fill={accentColor} style="font-family:system-ui,sans-serif">{overlay.status}</text>
|
|
338
341
|
{/if}
|
|
339
342
|
</g>
|
|
343
|
+
{#if edit && editAt}
|
|
344
|
+
<!-- Width Point Edit (double-click with the width tool), beside the point. -->
|
|
345
|
+
<foreignObject data-vector-width-point-edit="" x={editAt.x + 12} y={editAt.y + 12} width="180" height="140" style="overflow:visible">
|
|
346
|
+
{#key `${edit.nodeId}:${edit.index}:${edit.t}`}
|
|
347
|
+
<VectorWidthPointEditor {controller} {edit} {accentColor} />
|
|
348
|
+
{/key}
|
|
349
|
+
</foreignObject>
|
|
350
|
+
{/if}
|
|
340
351
|
</svg>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VectorCanvas.svelte.d.ts","sourceRoot":"","sources":["../../src/vector/VectorCanvas.svelte.ts"],"names":[],"mappings":"AAQA,OAAO,EAQH,KAAK,sBAAsB,EAC5B,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"VectorCanvas.svelte.d.ts","sourceRoot":"","sources":["../../src/vector/VectorCanvas.svelte.ts"],"names":[],"mappings":"AAQA,OAAO,EAQH,KAAK,sBAAsB,EAC5B,MAAM,yBAAyB,CAAC;AAOjC,UAAU,KAAK;IACb,UAAU,EAAE,sBAAsB,CAAC;IACnC,mFAAmF;IACnF,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,0EAA0E;IAC1E,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gDAAgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAkPH,QAAA,MAAM,YAAY,2CAAwC,CAAC;AAC3D,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Width Point Edit: the position (percent along the path) and the left / right side widths
|
|
3
|
+
(document units) of the width point a width-tool double-click opened. Apply (or Enter) sets
|
|
4
|
+
them with `commitWidthPointEdit`; Cancel or Escape closes it. `<VectorCanvas>` shows it next
|
|
5
|
+
to the point; use it on its own to place it elsewhere.
|
|
6
|
+
-->
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
import { VECTOR_OVERLAY_THEME as THEME, type VectorEditorController, type VectorWidthPointEdit } from '@pixerate/editor/vector';
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
controller: VectorEditorController;
|
|
12
|
+
/** The point being edited (`state.widthPointEdit`). */
|
|
13
|
+
edit: VectorWidthPointEdit;
|
|
14
|
+
/** Accent colour of the Apply button (default sky blue). */
|
|
15
|
+
accentColor?: string;
|
|
16
|
+
class?: string;
|
|
17
|
+
style?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let { controller, edit, accentColor = THEME.accent, class: className = '', style = '' }: Props = $props();
|
|
21
|
+
|
|
22
|
+
const round = (v: number, digits: number) => String(Math.round(v * 10 ** digits) / 10 ** digits);
|
|
23
|
+
// The fields start from the point; the canvas re-keys the editor when it opens on another one.
|
|
24
|
+
// svelte-ignore state_referenced_locally
|
|
25
|
+
let position = $state<string | number | null>(round(edit.t * 100, 2));
|
|
26
|
+
// svelte-ignore state_referenced_locally
|
|
27
|
+
let left = $state<string | number | null>(round(edit.left, 3));
|
|
28
|
+
// svelte-ignore state_referenced_locally
|
|
29
|
+
let right = $state<string | number | null>(round(edit.right, 3));
|
|
30
|
+
let form: HTMLFormElement | undefined = $state();
|
|
31
|
+
|
|
32
|
+
const num = (v: unknown) => (String(v ?? '').trim() !== '' && Number.isFinite(Number(v)) ? Number(v) : undefined);
|
|
33
|
+
|
|
34
|
+
// Hand the keyboard back to the canvas around it.
|
|
35
|
+
function refocus() {
|
|
36
|
+
(form?.closest('svg') as SVGSVGElement | null)?.focus?.({ preventScroll: true });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function close() {
|
|
40
|
+
refocus();
|
|
41
|
+
controller.closeWidthPointEdit();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function apply(e: SubmitEvent) {
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
const t = num(position);
|
|
47
|
+
refocus();
|
|
48
|
+
controller.commitWidthPointEdit({ t: t === undefined ? undefined : Math.min(Math.max(t, 0), 100) / 100, left: num(left), right: num(right) });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function onKeyDown(e: KeyboardEvent) {
|
|
52
|
+
e.stopPropagation();
|
|
53
|
+
if (e.key === 'Escape') {
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
close();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const stop = (e: Event) => e.stopPropagation();
|
|
60
|
+
const fieldStyle = 'display:flex;align-items:center;justify-content:space-between;gap:6px';
|
|
61
|
+
const inputStyle = 'width:72px;font:inherit;padding:1px 4px';
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<!-- Keep the canvas from treating clicks, keys and clipboard use in here as editing gestures. -->
|
|
65
|
+
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
66
|
+
<form
|
|
67
|
+
bind:this={form}
|
|
68
|
+
data-vector-width-point-editor=""
|
|
69
|
+
aria-label="Width point"
|
|
70
|
+
class={className}
|
|
71
|
+
style="display:grid;gap:4px;padding:8px;background:#ffffff;border:1px solid rgba(0,0,0,0.15);border-radius:6px;box-shadow:0 2px 8px rgba(0,0,0,0.15);font:12px system-ui,sans-serif;color:#18181b;{style}"
|
|
72
|
+
onpointerdown={stop}
|
|
73
|
+
onpointermove={stop}
|
|
74
|
+
onpointerup={stop}
|
|
75
|
+
ondblclick={stop}
|
|
76
|
+
oncopy={stop}
|
|
77
|
+
oncut={stop}
|
|
78
|
+
onpaste={stop}
|
|
79
|
+
onkeydown={onKeyDown}
|
|
80
|
+
onsubmit={apply}
|
|
81
|
+
>
|
|
82
|
+
<label style={fieldStyle}>
|
|
83
|
+
Position %
|
|
84
|
+
<!-- svelte-ignore a11y_autofocus -->
|
|
85
|
+
<input aria-label="Width point position" type="number" min="0" max="100" step="any" bind:value={position} style={inputStyle} autofocus />
|
|
86
|
+
</label>
|
|
87
|
+
<label style={fieldStyle}>
|
|
88
|
+
Left
|
|
89
|
+
<input aria-label="Width point left side" type="number" min="0" step="any" bind:value={left} style={inputStyle} />
|
|
90
|
+
</label>
|
|
91
|
+
<label style={fieldStyle}>
|
|
92
|
+
Right
|
|
93
|
+
<input aria-label="Width point right side" type="number" min="0" step="any" bind:value={right} style={inputStyle} />
|
|
94
|
+
</label>
|
|
95
|
+
<div style="display:flex;justify-content:flex-end;gap:4px;margin-top:2px">
|
|
96
|
+
<button type="button" onclick={close}>Cancel</button>
|
|
97
|
+
<button type="submit" style="background:{accentColor};color:#ffffff;border:none;border-radius:4px;padding:2px 8px">{edit.index === null ? 'Add' : 'Apply'}</button>
|
|
98
|
+
</div>
|
|
99
|
+
</form>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type VectorEditorController, type VectorWidthPointEdit } from '@pixerate/editor/vector';
|
|
2
|
+
interface Props {
|
|
3
|
+
controller: VectorEditorController;
|
|
4
|
+
/** The point being edited (`state.widthPointEdit`). */
|
|
5
|
+
edit: VectorWidthPointEdit;
|
|
6
|
+
/** Accent colour of the Apply button (default sky blue). */
|
|
7
|
+
accentColor?: string;
|
|
8
|
+
class?: string;
|
|
9
|
+
style?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const VectorWidthPointEditor: import("svelte").Component<Props, {}, "">;
|
|
12
|
+
type VectorWidthPointEditor = ReturnType<typeof VectorWidthPointEditor>;
|
|
13
|
+
export default VectorWidthPointEditor;
|
|
14
|
+
//# sourceMappingURL=VectorWidthPointEditor.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VectorWidthPointEditor.svelte.d.ts","sourceRoot":"","sources":["../../src/vector/VectorWidthPointEditor.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiC,KAAK,sBAAsB,EAAE,KAAK,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAG9H,UAAU,KAAK;IACb,UAAU,EAAE,sBAAsB,CAAC;IACnC,uDAAuD;IACvD,IAAI,EAAE,oBAAoB,CAAC;IAC3B,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA0EH,QAAA,MAAM,sBAAsB,2CAAwC,CAAC;AACrE,KAAK,sBAAsB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACxE,eAAe,sBAAsB,CAAC"}
|
package/dist/vector/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type VectorCanvasComponent from "./VectorCanvas.svelte";
|
|
|
3
3
|
import type VectorEditorComponent from "./VectorEditor.svelte";
|
|
4
4
|
export { default as VectorEditor } from "./VectorEditor.svelte";
|
|
5
5
|
export { default as VectorCanvas } from "./VectorCanvas.svelte";
|
|
6
|
+
export { default as VectorWidthPointEditor } from "./VectorWidthPointEditor.svelte";
|
|
6
7
|
export { default as VectorToolbar } from "./VectorToolbar.svelte";
|
|
7
8
|
export { default as VectorStylePanel } from "./VectorStylePanel.svelte";
|
|
8
9
|
export { default as VectorSceneNodes } from "./VectorSceneNodes.svelte";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vector/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,qBAAqB,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,qBAAqB,MAAM,uBAAuB,CAAC;AAE/D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B,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,cAAc,aAAa,CAAC;AAE5B,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAC7E,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
package/dist/vector/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as VectorEditor } from "./VectorEditor.svelte";
|
|
2
2
|
export { default as VectorCanvas } from "./VectorCanvas.svelte";
|
|
3
|
+
export { default as VectorWidthPointEditor } from "./VectorWidthPointEditor.svelte";
|
|
3
4
|
export { default as VectorToolbar } from "./VectorToolbar.svelte";
|
|
4
5
|
export { default as VectorStylePanel } from "./VectorStylePanel.svelte";
|
|
5
6
|
export { default as VectorSceneNodes } from "./VectorSceneNodes.svelte";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "Svelte bindings and prompt/rich-text components for @pixerate/editor",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"@tiptap/extension-bubble-menu": "^2.11.5",
|
|
108
108
|
"@tiptap/extension-placeholder": "^2.11.5",
|
|
109
109
|
"@tiptap/starter-kit": "^2.11.5",
|
|
110
|
-
"@pixerate/editor": "0.
|
|
110
|
+
"@pixerate/editor": "0.40.0"
|
|
111
111
|
},
|
|
112
112
|
"peerDependencies": {
|
|
113
113
|
"@dagrejs/dagre": "^1.1.4",
|