@pixerate/editor-react 0.115.0 → 0.116.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/{chunk-2KXZLZAS.js → chunk-ZQ54FEXL.js} +125 -22
- package/dist/image-editor/ImageProviderEffectsPanel.d.cts +5 -4
- package/dist/image-editor/ImageProviderEffectsPanel.d.ts +5 -4
- package/dist/image-editor/LayerEffectsPanel.d.cts +5 -0
- package/dist/image-editor/LayerEffectsPanel.d.ts +5 -0
- package/dist/image-editor/index.cjs +119 -16
- package/dist/image-editor/index.js +1 -1
- package/dist/index.cjs +119 -16
- package/dist/index.js +1 -1
- package/package.json +3 -3
|
@@ -190,7 +190,7 @@ function useImageEffectsTools(registry, controller, options = {}) {
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
// src/image-editor/ImageEditor.tsx
|
|
193
|
-
import React15, { useRef as
|
|
193
|
+
import React15, { useRef as useRef7, useEffect as useEffect13, useState as useState16 } from "react";
|
|
194
194
|
import {
|
|
195
195
|
normalizeProcessVersion,
|
|
196
196
|
LATEST_PROCESS_VERSION,
|
|
@@ -1451,7 +1451,7 @@ import { useEffect as useEffect6, useRef as useRef5, useState as useState7 } fro
|
|
|
1451
1451
|
import { useEffect as useEffect5, useRef as useRef4, useState as useState6 } from "react";
|
|
1452
1452
|
import { LAYER_EFFECT_MENU, effectControlChange, layerEffectControls, layerEffectsPanel } from "@pixerate/editor/image-editor";
|
|
1453
1453
|
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1454
|
-
var LayerEffectsPanel = ({ controller, layerId, className }) => {
|
|
1454
|
+
var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) => {
|
|
1455
1455
|
const [, setTick] = useState6(0);
|
|
1456
1456
|
useEffect5(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
1457
1457
|
const [open, setOpen] = useState6(null);
|
|
@@ -1535,7 +1535,7 @@ var LayerEffectsPanel = ({ controller, layerId, className }) => {
|
|
|
1535
1535
|
};
|
|
1536
1536
|
return /* @__PURE__ */ jsxs7("div", { className: `flex flex-col gap-1.5 text-xs text-foreground ${className ?? ""}`, "data-testid": "layer-effects", "aria-label": "Layer effects", role: "group", children: [
|
|
1537
1537
|
/* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1538
|
-
/* @__PURE__ */ jsx7("span", { className: "font-semibold text-foreground", children: "fx Effects" }),
|
|
1538
|
+
/* @__PURE__ */ jsx7("span", { className: "font-semibold text-foreground", children: heading ? "fx Effects" : "Styles" }),
|
|
1539
1539
|
/* @__PURE__ */ jsxs7("label", { className: "flex items-center gap-1 text-foreground", children: [
|
|
1540
1540
|
/* @__PURE__ */ jsx7(ImageCheckbox, { label: "Effects on", checked: model.enabled, disabled: model.readOnly, onChange: (on) => attempt(() => controller.setLayerEffectsEnabled(id, on)) }),
|
|
1541
1541
|
"On"
|
|
@@ -1561,7 +1561,7 @@ var LayerEffectsPanel = ({ controller, layerId, className }) => {
|
|
|
1561
1561
|
),
|
|
1562
1562
|
"%"
|
|
1563
1563
|
] }),
|
|
1564
|
-
/* @__PURE__ */ jsx7(
|
|
1564
|
+
heading && /* @__PURE__ */ jsx7(
|
|
1565
1565
|
ImageSelect,
|
|
1566
1566
|
{
|
|
1567
1567
|
label: "Add effect",
|
|
@@ -2046,8 +2046,8 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
|
|
|
2046
2046
|
};
|
|
2047
2047
|
|
|
2048
2048
|
// src/image-editor/ImageProviderEffectsPanel.tsx
|
|
2049
|
-
import
|
|
2050
|
-
import { EFFECT_LAYER_USES, findLayer } from "@pixerate/editor/image-editor";
|
|
2049
|
+
import { useEffect as useEffect7, useRef as useRef6, useState as useState8 } from "react";
|
|
2050
|
+
import { EFFECT_LAYER_USES, LAYER_EFFECT_MENU as LAYER_EFFECT_MENU2, effectLayerTiming, findLayer, layerEffectsPanel as layerEffectsPanel2 } from "@pixerate/editor/image-editor";
|
|
2051
2051
|
|
|
2052
2052
|
// src/image-editor/controls/parameterControls.tsx
|
|
2053
2053
|
import { matchParameterOptionValue } from "@pixerate/editor/parameters";
|
|
@@ -2125,12 +2125,14 @@ function ImageEffectControls({ provider, effect, name, values, onChange, onPrese
|
|
|
2125
2125
|
|
|
2126
2126
|
// src/image-editor/ImageProviderEffectsPanel.tsx
|
|
2127
2127
|
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2128
|
+
var fmt = (ms) => `${(ms / 1e3).toFixed(ms < 1e4 ? 2 : 1)} s`;
|
|
2128
2129
|
function ImageProviderEffectsPanel({ controller, className = "", components }) {
|
|
2129
2130
|
const [, setTick] = useState8(0);
|
|
2130
2131
|
useEffect7(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
2131
2132
|
const [browse, setBrowse] = useState8(null);
|
|
2132
2133
|
const [message, setMessage] = useState8(null);
|
|
2133
2134
|
const [open, setOpen] = useState8(null);
|
|
2135
|
+
const [scrubbed, setScrubbed] = useState8(null);
|
|
2134
2136
|
const provider = controller.effectsProvider;
|
|
2135
2137
|
const state = controller.getState();
|
|
2136
2138
|
const layer = state.activeLayerId ? findLayer(state.layers, state.activeLayerId)?.layer ?? null : null;
|
|
@@ -2138,7 +2140,7 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
|
|
|
2138
2140
|
setMessage(null);
|
|
2139
2141
|
Promise.resolve().then(work).catch((e) => setMessage(e instanceof Error ? e.message : String(e)));
|
|
2140
2142
|
};
|
|
2141
|
-
const drags =
|
|
2143
|
+
const drags = useRef6(/* @__PURE__ */ new Set());
|
|
2142
2144
|
const commit = (gesture) => {
|
|
2143
2145
|
if (gesture) {
|
|
2144
2146
|
if (!drags.current.has(gesture)) {
|
|
@@ -2152,20 +2154,114 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
|
|
|
2152
2154
|
const filters = layer?.type === "smart" ? (layer.smartFilters?.filters ?? []).filter((f) => f.kind === "effect") : [];
|
|
2153
2155
|
const generator = layer?.type === "pixel" ? layer.generator : void 0;
|
|
2154
2156
|
const canFilter = !!layer && layer.type !== "adjustment" && layer.type !== "annotation";
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2157
|
+
const styles = layerEffectsPanel2(layer);
|
|
2158
|
+
const { description } = useEffectDescription(provider, generator?.effect);
|
|
2159
|
+
const timing = generator ? effectLayerTiming(generator, description) : null;
|
|
2160
|
+
const addOptions = [
|
|
2161
|
+
...provider && canFilter ? [{ value: "filter", label: "Filter\u2026" }] : [],
|
|
2162
|
+
...styles.available && !styles.readOnly ? LAYER_EFFECT_MENU2.map((m) => ({ value: `style:${m.kind}`, label: m.label })) : []
|
|
2163
|
+
];
|
|
2164
|
+
const add = (value) => {
|
|
2165
|
+
if (!value || !layer) return;
|
|
2166
|
+
if (value === "filter") setBrowse(browse === "filter" ? null : "filter");
|
|
2167
|
+
else run(() => controller.addLayerEffect(layer.id, value.slice("style:".length)));
|
|
2168
|
+
};
|
|
2169
|
+
const scrub = useRef6({ next: null, busy: false, gesture: null });
|
|
2170
|
+
const scrubTo = (layerId, time) => {
|
|
2171
|
+
const s = scrub.current;
|
|
2172
|
+
setScrubbed(time);
|
|
2173
|
+
s.next = { layerId, time, commit: commit(s.gesture) };
|
|
2174
|
+
if (s.busy) return;
|
|
2175
|
+
s.busy = true;
|
|
2176
|
+
const step = () => {
|
|
2177
|
+
const n = s.next;
|
|
2178
|
+
s.next = null;
|
|
2179
|
+
if (!n) return Promise.resolve();
|
|
2180
|
+
return controller.updateEffectLayer(n.layerId, { time: n.time }, n.commit).then(step);
|
|
2181
|
+
};
|
|
2182
|
+
step().catch((e) => setMessage(e instanceof Error ? e.message : String(e))).finally(() => {
|
|
2183
|
+
s.busy = false;
|
|
2184
|
+
setScrubbed(null);
|
|
2185
|
+
});
|
|
2186
|
+
};
|
|
2187
|
+
const shown = scrubbed ?? timing?.time ?? 0;
|
|
2188
|
+
return /* @__PURE__ */ jsxs10("section", { className: `flex flex-col gap-2 text-xs ${className}`, "aria-label": "Effects", "data-image-provider-effects": "", children: [
|
|
2161
2189
|
!provider && /* @__PURE__ */ jsx11("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider is registered. Effects in the document are kept." }),
|
|
2162
|
-
|
|
2163
|
-
browse === "layer" && /* @__PURE__ */ jsx11(EffectsBrowser, { provider, uses: EFFECT_LAYER_USES, title: "Generators and overlays", onPick: (e) => (setBrowse(null), run(() => controller.addEffectLayer(e.id))) }),
|
|
2164
|
-
generator && layer && /* @__PURE__ */ jsxs10("div", { className: "space-y-1", "data-effect-part": "generator", children: [
|
|
2190
|
+
generator && layer && /* @__PURE__ */ jsxs10("div", { className: "space-y-2", "data-effect-part": "generator", children: [
|
|
2165
2191
|
/* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-1", children: [
|
|
2166
|
-
/* @__PURE__ */ jsx11("span", { className: "flex-1 font-medium text-foreground", children: generator.name ?? generator.effect }),
|
|
2192
|
+
/* @__PURE__ */ jsx11("span", { className: "min-w-0 flex-1 truncate font-medium text-foreground", title: generator.name ?? generator.effect, children: generator.name ?? generator.effect }),
|
|
2193
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: imageOutlineButtonClass, disabled: !provider, "aria-pressed": browse === "change", onClick: () => setBrowse(browse === "change" ? null : "change"), children: "Change\u2026" }),
|
|
2167
2194
|
/* @__PURE__ */ jsx11("button", { type: "button", className: imageOutlineButtonClass, title: "Keep the pixels as a plain layer", onClick: () => run(() => controller.rasterizeEffectLayer(layer.id)), children: "Rasterize" })
|
|
2168
2195
|
] }),
|
|
2196
|
+
browse === "change" && /* @__PURE__ */ jsx11(EffectsBrowser, { provider, uses: EFFECT_LAYER_USES, title: "Change the effect to", onPick: (e) => (setBrowse(null), run(() => controller.updateEffectLayer(layer.id, { effect: e.id }))) }),
|
|
2197
|
+
timing && /* @__PURE__ */ jsxs10("div", { className: "space-y-1.5 rounded border border-border p-1.5", "data-effect-part": "timing", role: "group", "aria-label": "Frames", children: [
|
|
2198
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex gap-1", role: "radiogroup", "aria-label": "Output", children: [
|
|
2199
|
+
/* @__PURE__ */ jsx11(
|
|
2200
|
+
"button",
|
|
2201
|
+
{
|
|
2202
|
+
type: "button",
|
|
2203
|
+
role: "radio",
|
|
2204
|
+
"aria-checked": timing.mode === "still",
|
|
2205
|
+
className: `${imageOutlineButtonClass} flex-1 ${timing.mode === "still" ? "bg-accent text-accent-foreground" : ""}`,
|
|
2206
|
+
onClick: () => run(() => controller.updateEffectLayer(layer.id, { animate: null })),
|
|
2207
|
+
children: "Still frame"
|
|
2208
|
+
}
|
|
2209
|
+
),
|
|
2210
|
+
/* @__PURE__ */ jsx11(
|
|
2211
|
+
"button",
|
|
2212
|
+
{
|
|
2213
|
+
type: "button",
|
|
2214
|
+
role: "radio",
|
|
2215
|
+
"aria-checked": timing.mode === "animate",
|
|
2216
|
+
className: `${imageOutlineButtonClass} flex-1 ${timing.mode === "animate" ? "bg-accent text-accent-foreground" : ""}`,
|
|
2217
|
+
onClick: () => run(() => controller.updateEffectLayer(layer.id, { animate: { duration: timing.duration } })),
|
|
2218
|
+
children: "Animate"
|
|
2219
|
+
}
|
|
2220
|
+
)
|
|
2221
|
+
] }),
|
|
2222
|
+
/* @__PURE__ */ jsxs10("label", { className: "flex items-center gap-1.5", children: [
|
|
2223
|
+
/* @__PURE__ */ jsx11("span", { className: "w-16 shrink-0 text-[11px] text-foreground", children: timing.mode === "still" ? "Frame" : "Starts at" }),
|
|
2224
|
+
/* @__PURE__ */ jsx11(
|
|
2225
|
+
ImageRange,
|
|
2226
|
+
{
|
|
2227
|
+
min: 0,
|
|
2228
|
+
max: timing.range,
|
|
2229
|
+
step: Math.max(1, Math.round(timing.range / 200)),
|
|
2230
|
+
className: "flex-1",
|
|
2231
|
+
value: shown,
|
|
2232
|
+
label: timing.mode === "still" ? "Frame" : "Starts at",
|
|
2233
|
+
onStart: () => scrub.current.gesture = `time:${Date.now()}`,
|
|
2234
|
+
onEnd: () => scrub.current.gesture = null,
|
|
2235
|
+
onChange: (t) => scrubTo(layer.id, t)
|
|
2236
|
+
}
|
|
2237
|
+
),
|
|
2238
|
+
/* @__PURE__ */ jsx11("span", { className: "w-12 shrink-0 text-right tabular-nums text-muted-foreground", children: fmt(shown) })
|
|
2239
|
+
] }),
|
|
2240
|
+
timing.mode === "animate" && /* @__PURE__ */ jsxs10("label", { className: "flex items-center gap-1.5", children: [
|
|
2241
|
+
/* @__PURE__ */ jsx11("span", { className: "w-16 shrink-0 text-[11px] text-foreground", children: "Length" }),
|
|
2242
|
+
/* @__PURE__ */ jsx11(
|
|
2243
|
+
"input",
|
|
2244
|
+
{
|
|
2245
|
+
type: "number",
|
|
2246
|
+
"aria-label": "Animation length in seconds",
|
|
2247
|
+
min: 0.1,
|
|
2248
|
+
max: 60,
|
|
2249
|
+
step: 0.1,
|
|
2250
|
+
defaultValue: Math.round(timing.duration / 100) / 10,
|
|
2251
|
+
className: "w-16 rounded border border-border bg-muted px-1 text-foreground",
|
|
2252
|
+
onBlur: (e) => {
|
|
2253
|
+
const s = Number(e.currentTarget.value);
|
|
2254
|
+
if (s > 0 && s * 1e3 !== timing.duration) run(() => controller.updateEffectLayer(layer.id, { animate: { duration: Math.min(60, s) * 1e3 } }));
|
|
2255
|
+
}
|
|
2256
|
+
},
|
|
2257
|
+
timing.duration
|
|
2258
|
+
),
|
|
2259
|
+
/* @__PURE__ */ jsxs10("span", { className: "text-muted-foreground", children: [
|
|
2260
|
+
"s",
|
|
2261
|
+
timing.loops ? ` \xB7 loops every ${fmt(timing.range)}` : ""
|
|
2262
|
+
] })
|
|
2263
|
+
] })
|
|
2264
|
+
] }),
|
|
2169
2265
|
/* @__PURE__ */ jsx11(
|
|
2170
2266
|
ImageEffectControls,
|
|
2171
2267
|
{
|
|
@@ -2179,7 +2275,12 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
|
|
|
2179
2275
|
}
|
|
2180
2276
|
)
|
|
2181
2277
|
] }),
|
|
2182
|
-
|
|
2278
|
+
layer && canFilter && /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-1", "data-effect-part": "applied", children: [
|
|
2279
|
+
/* @__PURE__ */ jsx11("span", { className: "flex-1 font-semibold uppercase tracking-wider text-[11px] text-foreground", children: generator ? "On this layer" : "Effects" }),
|
|
2280
|
+
addOptions.length > 0 && /* @__PURE__ */ jsx11(ImageSelect, { label: "Add effect", value: "", placeholder: "Add\u2026", options: addOptions, onChange: add })
|
|
2281
|
+
] }),
|
|
2282
|
+
browse === "filter" && layer && /* @__PURE__ */ jsx11(EffectsBrowser, { provider, uses: ["filter"], title: "Filters", onPick: (e) => (setBrowse(null), run(() => controller.applyEffectFilter(layer.id, e.id))) }),
|
|
2283
|
+
filters.length > 0 && layer && /* @__PURE__ */ jsx11("ol", { className: "space-y-1", "data-effect-part": "filters", "aria-label": "Filters", children: filters.map((f) => {
|
|
2183
2284
|
const label = f.kind === "effect" ? f.name ?? f.effect : f.kind;
|
|
2184
2285
|
const all = layer.smartFilters.filters;
|
|
2185
2286
|
const index = all.indexOf(f);
|
|
@@ -2230,6 +2331,8 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
|
|
|
2230
2331
|
] })
|
|
2231
2332
|
] }, f.id);
|
|
2232
2333
|
}) }),
|
|
2334
|
+
layer && styles.available && styles.rows.length > 0 && /* @__PURE__ */ jsx11(LayerEffectsPanel, { controller, layerId: layer.id, heading: false }),
|
|
2335
|
+
layer && canFilter && !generator && filters.length === 0 && styles.rows.length === 0 && /* @__PURE__ */ jsx11("p", { className: "text-[11px] text-muted-foreground", children: "No effects yet. Add a filter, or a style such as a drop shadow. New effect layers are added from the layers panel." }),
|
|
2233
2336
|
!layer && /* @__PURE__ */ jsx11("p", { className: "text-[11px] text-muted-foreground", children: "Select a layer to apply effects to it." }),
|
|
2234
2337
|
message && /* @__PURE__ */ jsx11("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
|
|
2235
2338
|
] });
|
|
@@ -3089,9 +3192,9 @@ var ImageEditor = ({
|
|
|
3089
3192
|
});
|
|
3090
3193
|
const legacyProcess = normalizeProcessVersion(state.adjustments.process) < LATEST_PROCESS_VERSION;
|
|
3091
3194
|
const [activeTab, setActiveTab] = useState16("crop");
|
|
3092
|
-
const rootRef =
|
|
3195
|
+
const rootRef = useRef7(null);
|
|
3093
3196
|
const canvasMode = activeTab === "crop" || activeTab === "select" || activeTab === "paint" || activeTab === "annotate" ? activeTab : "none";
|
|
3094
|
-
const activeTabRef =
|
|
3197
|
+
const activeTabRef = useRef7(activeTab);
|
|
3095
3198
|
activeTabRef.current = activeTab;
|
|
3096
3199
|
const openPanel = async (ref) => {
|
|
3097
3200
|
if (ref.kind !== "panel" || activeTabRef.current === ref.id) return;
|
|
@@ -3112,8 +3215,8 @@ var ImageEditor = ({
|
|
|
3112
3215
|
else setShapeTypeError(message);
|
|
3113
3216
|
};
|
|
3114
3217
|
const finishTyping = () => setTypeSession(null);
|
|
3115
|
-
const transformToolRef =
|
|
3116
|
-
const transformControllerRef =
|
|
3218
|
+
const transformToolRef = useRef7(null);
|
|
3219
|
+
const transformControllerRef = useRef7(controller);
|
|
3117
3220
|
if (!transformToolRef.current || transformControllerRef.current !== controller) {
|
|
3118
3221
|
transformToolRef.current?.cancel();
|
|
3119
3222
|
transformToolRef.current = new FreeTransformTool2(controller, {
|
|
@@ -8,9 +8,10 @@ export interface ImageProviderEffectsPanelProps {
|
|
|
8
8
|
components?: ParameterComponents;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* smart object in the same undo step
|
|
11
|
+
* Effects for the active layer, in one place. An effect layer first: its effect (change it or
|
|
12
|
+
* rasterize it), a still frame or an animation for an effect that moves, and its controls. Then
|
|
13
|
+
* what is applied to any layer: provider filters (smart filters; applying one converts a pixel
|
|
14
|
+
* layer to a smart object in the same undo step) and layer styles, added from one menu. New
|
|
15
|
+
* effect layers come from the layers panel. Without a provider it says why nothing can be added.
|
|
15
16
|
*/
|
|
16
17
|
export declare function ImageProviderEffectsPanel({ controller, className, components }: ImageProviderEffectsPanelProps): React.JSX.Element;
|
|
@@ -8,9 +8,10 @@ export interface ImageProviderEffectsPanelProps {
|
|
|
8
8
|
components?: ParameterComponents;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* smart object in the same undo step
|
|
11
|
+
* Effects for the active layer, in one place. An effect layer first: its effect (change it or
|
|
12
|
+
* rasterize it), a still frame or an animation for an effect that moves, and its controls. Then
|
|
13
|
+
* what is applied to any layer: provider filters (smart filters; applying one converts a pixel
|
|
14
|
+
* layer to a smart object in the same undo step) and layer styles, added from one menu. New
|
|
15
|
+
* effect layers come from the layers panel. Without a provider it says why nothing can be added.
|
|
15
16
|
*/
|
|
16
17
|
export declare function ImageProviderEffectsPanel({ controller, className, components }: ImageProviderEffectsPanelProps): React.JSX.Element;
|
|
@@ -4,6 +4,11 @@ export interface LayerEffectsPanelProps {
|
|
|
4
4
|
controller: ImageEditorController;
|
|
5
5
|
/** The layer whose effects to show (default: the active layer). */
|
|
6
6
|
layerId?: string | null;
|
|
7
|
+
/**
|
|
8
|
+
* Show the "fx Effects" title and the "Add effect" menu (default true). Without them (inside a
|
|
9
|
+
* panel that adds styles from its own menu) the master switch and Scale stay.
|
|
10
|
+
*/
|
|
11
|
+
heading?: boolean;
|
|
7
12
|
className?: string;
|
|
8
13
|
}
|
|
9
14
|
/**
|
|
@@ -4,6 +4,11 @@ export interface LayerEffectsPanelProps {
|
|
|
4
4
|
controller: ImageEditorController;
|
|
5
5
|
/** The layer whose effects to show (default: the active layer). */
|
|
6
6
|
layerId?: string | null;
|
|
7
|
+
/**
|
|
8
|
+
* Show the "fx Effects" title and the "Add effect" menu (default true). Without them (inside a
|
|
9
|
+
* panel that adds styles from its own menu) the master switch and Scale stay.
|
|
10
|
+
*/
|
|
11
|
+
heading?: boolean;
|
|
7
12
|
className?: string;
|
|
8
13
|
}
|
|
9
14
|
/**
|
|
@@ -1536,7 +1536,7 @@ var import_react11 = require("react");
|
|
|
1536
1536
|
var import_react10 = require("react");
|
|
1537
1537
|
var import_image_editor7 = require("@pixerate/editor/image-editor");
|
|
1538
1538
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1539
|
-
var LayerEffectsPanel = ({ controller, layerId, className }) => {
|
|
1539
|
+
var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) => {
|
|
1540
1540
|
const [, setTick] = (0, import_react10.useState)(0);
|
|
1541
1541
|
(0, import_react10.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
1542
1542
|
const [open, setOpen] = (0, import_react10.useState)(null);
|
|
@@ -1620,7 +1620,7 @@ var LayerEffectsPanel = ({ controller, layerId, className }) => {
|
|
|
1620
1620
|
};
|
|
1621
1621
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `flex flex-col gap-1.5 text-xs text-foreground ${className ?? ""}`, "data-testid": "layer-effects", "aria-label": "Layer effects", role: "group", children: [
|
|
1622
1622
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1623
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "font-semibold text-foreground", children: "fx Effects" }),
|
|
1623
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "font-semibold text-foreground", children: heading ? "fx Effects" : "Styles" }),
|
|
1624
1624
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { className: "flex items-center gap-1 text-foreground", children: [
|
|
1625
1625
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ImageCheckbox, { label: "Effects on", checked: model.enabled, disabled: model.readOnly, onChange: (on) => attempt(() => controller.setLayerEffectsEnabled(id, on)) }),
|
|
1626
1626
|
"On"
|
|
@@ -1646,7 +1646,7 @@ var LayerEffectsPanel = ({ controller, layerId, className }) => {
|
|
|
1646
1646
|
),
|
|
1647
1647
|
"%"
|
|
1648
1648
|
] }),
|
|
1649
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1649
|
+
heading && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1650
1650
|
ImageSelect,
|
|
1651
1651
|
{
|
|
1652
1652
|
label: "Add effect",
|
|
@@ -2116,7 +2116,7 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
|
|
|
2116
2116
|
};
|
|
2117
2117
|
|
|
2118
2118
|
// src/image-editor/ImageProviderEffectsPanel.tsx
|
|
2119
|
-
var import_react21 =
|
|
2119
|
+
var import_react21 = require("react");
|
|
2120
2120
|
var import_image_editor9 = require("@pixerate/editor/image-editor");
|
|
2121
2121
|
|
|
2122
2122
|
// src/effects/useEffects.ts
|
|
@@ -3961,12 +3961,14 @@ function ImageEffectControls({ provider, effect, name, values, onChange, onPrese
|
|
|
3961
3961
|
|
|
3962
3962
|
// src/image-editor/ImageProviderEffectsPanel.tsx
|
|
3963
3963
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
3964
|
+
var fmt = (ms) => `${(ms / 1e3).toFixed(ms < 1e4 ? 2 : 1)} s`;
|
|
3964
3965
|
function ImageProviderEffectsPanel({ controller, className = "", components }) {
|
|
3965
3966
|
const [, setTick] = (0, import_react21.useState)(0);
|
|
3966
3967
|
(0, import_react21.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
3967
3968
|
const [browse, setBrowse] = (0, import_react21.useState)(null);
|
|
3968
3969
|
const [message, setMessage] = (0, import_react21.useState)(null);
|
|
3969
3970
|
const [open, setOpen] = (0, import_react21.useState)(null);
|
|
3971
|
+
const [scrubbed, setScrubbed] = (0, import_react21.useState)(null);
|
|
3970
3972
|
const provider = controller.effectsProvider;
|
|
3971
3973
|
const state = controller.getState();
|
|
3972
3974
|
const layer = state.activeLayerId ? (0, import_image_editor9.findLayer)(state.layers, state.activeLayerId)?.layer ?? null : null;
|
|
@@ -3974,7 +3976,7 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
|
|
|
3974
3976
|
setMessage(null);
|
|
3975
3977
|
Promise.resolve().then(work).catch((e) => setMessage(e instanceof Error ? e.message : String(e)));
|
|
3976
3978
|
};
|
|
3977
|
-
const drags = import_react21.
|
|
3979
|
+
const drags = (0, import_react21.useRef)(/* @__PURE__ */ new Set());
|
|
3978
3980
|
const commit = (gesture) => {
|
|
3979
3981
|
if (gesture) {
|
|
3980
3982
|
if (!drags.current.has(gesture)) {
|
|
@@ -3988,20 +3990,114 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
|
|
|
3988
3990
|
const filters = layer?.type === "smart" ? (layer.smartFilters?.filters ?? []).filter((f) => f.kind === "effect") : [];
|
|
3989
3991
|
const generator = layer?.type === "pixel" ? layer.generator : void 0;
|
|
3990
3992
|
const canFilter = !!layer && layer.type !== "adjustment" && layer.type !== "annotation";
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3993
|
+
const styles = (0, import_image_editor9.layerEffectsPanel)(layer);
|
|
3994
|
+
const { description } = useEffectDescription(provider, generator?.effect);
|
|
3995
|
+
const timing = generator ? (0, import_image_editor9.effectLayerTiming)(generator, description) : null;
|
|
3996
|
+
const addOptions = [
|
|
3997
|
+
...provider && canFilter ? [{ value: "filter", label: "Filter\u2026" }] : [],
|
|
3998
|
+
...styles.available && !styles.readOnly ? import_image_editor9.LAYER_EFFECT_MENU.map((m) => ({ value: `style:${m.kind}`, label: m.label })) : []
|
|
3999
|
+
];
|
|
4000
|
+
const add = (value) => {
|
|
4001
|
+
if (!value || !layer) return;
|
|
4002
|
+
if (value === "filter") setBrowse(browse === "filter" ? null : "filter");
|
|
4003
|
+
else run(() => controller.addLayerEffect(layer.id, value.slice("style:".length)));
|
|
4004
|
+
};
|
|
4005
|
+
const scrub = (0, import_react21.useRef)({ next: null, busy: false, gesture: null });
|
|
4006
|
+
const scrubTo = (layerId, time) => {
|
|
4007
|
+
const s = scrub.current;
|
|
4008
|
+
setScrubbed(time);
|
|
4009
|
+
s.next = { layerId, time, commit: commit(s.gesture) };
|
|
4010
|
+
if (s.busy) return;
|
|
4011
|
+
s.busy = true;
|
|
4012
|
+
const step = () => {
|
|
4013
|
+
const n = s.next;
|
|
4014
|
+
s.next = null;
|
|
4015
|
+
if (!n) return Promise.resolve();
|
|
4016
|
+
return controller.updateEffectLayer(n.layerId, { time: n.time }, n.commit).then(step);
|
|
4017
|
+
};
|
|
4018
|
+
step().catch((e) => setMessage(e instanceof Error ? e.message : String(e))).finally(() => {
|
|
4019
|
+
s.busy = false;
|
|
4020
|
+
setScrubbed(null);
|
|
4021
|
+
});
|
|
4022
|
+
};
|
|
4023
|
+
const shown = scrubbed ?? timing?.time ?? 0;
|
|
4024
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("section", { className: `flex flex-col gap-2 text-xs ${className}`, "aria-label": "Effects", "data-image-provider-effects": "", children: [
|
|
3997
4025
|
!provider && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider is registered. Effects in the document are kept." }),
|
|
3998
|
-
|
|
3999
|
-
browse === "layer" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(EffectsBrowser, { provider, uses: import_image_editor9.EFFECT_LAYER_USES, title: "Generators and overlays", onPick: (e) => (setBrowse(null), run(() => controller.addEffectLayer(e.id))) }),
|
|
4000
|
-
generator && layer && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "space-y-1", "data-effect-part": "generator", children: [
|
|
4026
|
+
generator && layer && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "space-y-2", "data-effect-part": "generator", children: [
|
|
4001
4027
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
4002
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "flex-1 font-medium text-foreground", children: generator.name ?? generator.effect }),
|
|
4028
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "min-w-0 flex-1 truncate font-medium text-foreground", title: generator.name ?? generator.effect, children: generator.name ?? generator.effect }),
|
|
4029
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: imageOutlineButtonClass, disabled: !provider, "aria-pressed": browse === "change", onClick: () => setBrowse(browse === "change" ? null : "change"), children: "Change\u2026" }),
|
|
4003
4030
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: imageOutlineButtonClass, title: "Keep the pixels as a plain layer", onClick: () => run(() => controller.rasterizeEffectLayer(layer.id)), children: "Rasterize" })
|
|
4004
4031
|
] }),
|
|
4032
|
+
browse === "change" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(EffectsBrowser, { provider, uses: import_image_editor9.EFFECT_LAYER_USES, title: "Change the effect to", onPick: (e) => (setBrowse(null), run(() => controller.updateEffectLayer(layer.id, { effect: e.id }))) }),
|
|
4033
|
+
timing && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "space-y-1.5 rounded border border-border p-1.5", "data-effect-part": "timing", role: "group", "aria-label": "Frames", children: [
|
|
4034
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex gap-1", role: "radiogroup", "aria-label": "Output", children: [
|
|
4035
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
4036
|
+
"button",
|
|
4037
|
+
{
|
|
4038
|
+
type: "button",
|
|
4039
|
+
role: "radio",
|
|
4040
|
+
"aria-checked": timing.mode === "still",
|
|
4041
|
+
className: `${imageOutlineButtonClass} flex-1 ${timing.mode === "still" ? "bg-accent text-accent-foreground" : ""}`,
|
|
4042
|
+
onClick: () => run(() => controller.updateEffectLayer(layer.id, { animate: null })),
|
|
4043
|
+
children: "Still frame"
|
|
4044
|
+
}
|
|
4045
|
+
),
|
|
4046
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
4047
|
+
"button",
|
|
4048
|
+
{
|
|
4049
|
+
type: "button",
|
|
4050
|
+
role: "radio",
|
|
4051
|
+
"aria-checked": timing.mode === "animate",
|
|
4052
|
+
className: `${imageOutlineButtonClass} flex-1 ${timing.mode === "animate" ? "bg-accent text-accent-foreground" : ""}`,
|
|
4053
|
+
onClick: () => run(() => controller.updateEffectLayer(layer.id, { animate: { duration: timing.duration } })),
|
|
4054
|
+
children: "Animate"
|
|
4055
|
+
}
|
|
4056
|
+
)
|
|
4057
|
+
] }),
|
|
4058
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
4059
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "w-16 shrink-0 text-[11px] text-foreground", children: timing.mode === "still" ? "Frame" : "Starts at" }),
|
|
4060
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
4061
|
+
ImageRange,
|
|
4062
|
+
{
|
|
4063
|
+
min: 0,
|
|
4064
|
+
max: timing.range,
|
|
4065
|
+
step: Math.max(1, Math.round(timing.range / 200)),
|
|
4066
|
+
className: "flex-1",
|
|
4067
|
+
value: shown,
|
|
4068
|
+
label: timing.mode === "still" ? "Frame" : "Starts at",
|
|
4069
|
+
onStart: () => scrub.current.gesture = `time:${Date.now()}`,
|
|
4070
|
+
onEnd: () => scrub.current.gesture = null,
|
|
4071
|
+
onChange: (t) => scrubTo(layer.id, t)
|
|
4072
|
+
}
|
|
4073
|
+
),
|
|
4074
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "w-12 shrink-0 text-right tabular-nums text-muted-foreground", children: fmt(shown) })
|
|
4075
|
+
] }),
|
|
4076
|
+
timing.mode === "animate" && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
4077
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "w-16 shrink-0 text-[11px] text-foreground", children: "Length" }),
|
|
4078
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
4079
|
+
"input",
|
|
4080
|
+
{
|
|
4081
|
+
type: "number",
|
|
4082
|
+
"aria-label": "Animation length in seconds",
|
|
4083
|
+
min: 0.1,
|
|
4084
|
+
max: 60,
|
|
4085
|
+
step: 0.1,
|
|
4086
|
+
defaultValue: Math.round(timing.duration / 100) / 10,
|
|
4087
|
+
className: "w-16 rounded border border-border bg-muted px-1 text-foreground",
|
|
4088
|
+
onBlur: (e) => {
|
|
4089
|
+
const s = Number(e.currentTarget.value);
|
|
4090
|
+
if (s > 0 && s * 1e3 !== timing.duration) run(() => controller.updateEffectLayer(layer.id, { animate: { duration: Math.min(60, s) * 1e3 } }));
|
|
4091
|
+
}
|
|
4092
|
+
},
|
|
4093
|
+
timing.duration
|
|
4094
|
+
),
|
|
4095
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
4096
|
+
"s",
|
|
4097
|
+
timing.loops ? ` \xB7 loops every ${fmt(timing.range)}` : ""
|
|
4098
|
+
] })
|
|
4099
|
+
] })
|
|
4100
|
+
] }),
|
|
4005
4101
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
4006
4102
|
ImageEffectControls,
|
|
4007
4103
|
{
|
|
@@ -4015,7 +4111,12 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
|
|
|
4015
4111
|
}
|
|
4016
4112
|
)
|
|
4017
4113
|
] }),
|
|
4018
|
-
|
|
4114
|
+
layer && canFilter && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-1", "data-effect-part": "applied", children: [
|
|
4115
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "flex-1 font-semibold uppercase tracking-wider text-[11px] text-foreground", children: generator ? "On this layer" : "Effects" }),
|
|
4116
|
+
addOptions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ImageSelect, { label: "Add effect", value: "", placeholder: "Add\u2026", options: addOptions, onChange: add })
|
|
4117
|
+
] }),
|
|
4118
|
+
browse === "filter" && layer && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(EffectsBrowser, { provider, uses: ["filter"], title: "Filters", onPick: (e) => (setBrowse(null), run(() => controller.applyEffectFilter(layer.id, e.id))) }),
|
|
4119
|
+
filters.length > 0 && layer && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("ol", { className: "space-y-1", "data-effect-part": "filters", "aria-label": "Filters", children: filters.map((f) => {
|
|
4019
4120
|
const label = f.kind === "effect" ? f.name ?? f.effect : f.kind;
|
|
4020
4121
|
const all = layer.smartFilters.filters;
|
|
4021
4122
|
const index = all.indexOf(f);
|
|
@@ -4066,6 +4167,8 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
|
|
|
4066
4167
|
] })
|
|
4067
4168
|
] }, f.id);
|
|
4068
4169
|
}) }),
|
|
4170
|
+
layer && styles.available && styles.rows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(LayerEffectsPanel, { controller, layerId: layer.id, heading: false }),
|
|
4171
|
+
layer && canFilter && !generator && filters.length === 0 && styles.rows.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects yet. Add a filter, or a style such as a drop shadow. New effect layers are added from the layers panel." }),
|
|
4069
4172
|
!layer && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Select a layer to apply effects to it." }),
|
|
4070
4173
|
message && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
|
|
4071
4174
|
] });
|
package/dist/index.cjs
CHANGED
|
@@ -5250,7 +5250,7 @@ var import_react47 = require("react");
|
|
|
5250
5250
|
var import_react46 = require("react");
|
|
5251
5251
|
var import_image_editor7 = require("@pixerate/editor/image-editor");
|
|
5252
5252
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
5253
|
-
var LayerEffectsPanel = ({ controller, layerId, className }) => {
|
|
5253
|
+
var LayerEffectsPanel = ({ controller, layerId, heading = true, className }) => {
|
|
5254
5254
|
const [, setTick] = (0, import_react46.useState)(0);
|
|
5255
5255
|
(0, import_react46.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
5256
5256
|
const [open, setOpen] = (0, import_react46.useState)(null);
|
|
@@ -5334,7 +5334,7 @@ var LayerEffectsPanel = ({ controller, layerId, className }) => {
|
|
|
5334
5334
|
};
|
|
5335
5335
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: `flex flex-col gap-1.5 text-xs text-foreground ${className ?? ""}`, "data-testid": "layer-effects", "aria-label": "Layer effects", role: "group", children: [
|
|
5336
5336
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
5337
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-semibold text-foreground", children: "fx Effects" }),
|
|
5337
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-semibold text-foreground", children: heading ? "fx Effects" : "Styles" }),
|
|
5338
5338
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex items-center gap-1 text-foreground", children: [
|
|
5339
5339
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ImageCheckbox, { label: "Effects on", checked: model.enabled, disabled: model.readOnly, onChange: (on) => attempt(() => controller.setLayerEffectsEnabled(id, on)) }),
|
|
5340
5340
|
"On"
|
|
@@ -5360,7 +5360,7 @@ var LayerEffectsPanel = ({ controller, layerId, className }) => {
|
|
|
5360
5360
|
),
|
|
5361
5361
|
"%"
|
|
5362
5362
|
] }),
|
|
5363
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
5363
|
+
heading && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
5364
5364
|
ImageSelect,
|
|
5365
5365
|
{
|
|
5366
5366
|
label: "Add effect",
|
|
@@ -5830,7 +5830,7 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
|
|
|
5830
5830
|
};
|
|
5831
5831
|
|
|
5832
5832
|
// src/image-editor/ImageProviderEffectsPanel.tsx
|
|
5833
|
-
var import_react57 =
|
|
5833
|
+
var import_react57 = require("react");
|
|
5834
5834
|
var import_image_editor9 = require("@pixerate/editor/image-editor");
|
|
5835
5835
|
|
|
5836
5836
|
// src/effects/useEffects.ts
|
|
@@ -7675,12 +7675,14 @@ function ImageEffectControls({ provider, effect, name, values, onChange, onPrese
|
|
|
7675
7675
|
|
|
7676
7676
|
// src/image-editor/ImageProviderEffectsPanel.tsx
|
|
7677
7677
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
7678
|
+
var fmt = (ms) => `${(ms / 1e3).toFixed(ms < 1e4 ? 2 : 1)} s`;
|
|
7678
7679
|
function ImageProviderEffectsPanel({ controller, className = "", components }) {
|
|
7679
7680
|
const [, setTick] = (0, import_react57.useState)(0);
|
|
7680
7681
|
(0, import_react57.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
7681
7682
|
const [browse, setBrowse] = (0, import_react57.useState)(null);
|
|
7682
7683
|
const [message2, setMessage] = (0, import_react57.useState)(null);
|
|
7683
7684
|
const [open, setOpen] = (0, import_react57.useState)(null);
|
|
7685
|
+
const [scrubbed, setScrubbed] = (0, import_react57.useState)(null);
|
|
7684
7686
|
const provider = controller.effectsProvider;
|
|
7685
7687
|
const state = controller.getState();
|
|
7686
7688
|
const layer = state.activeLayerId ? (0, import_image_editor9.findLayer)(state.layers, state.activeLayerId)?.layer ?? null : null;
|
|
@@ -7688,7 +7690,7 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
|
|
|
7688
7690
|
setMessage(null);
|
|
7689
7691
|
Promise.resolve().then(work).catch((e) => setMessage(e instanceof Error ? e.message : String(e)));
|
|
7690
7692
|
};
|
|
7691
|
-
const drags = import_react57.
|
|
7693
|
+
const drags = (0, import_react57.useRef)(/* @__PURE__ */ new Set());
|
|
7692
7694
|
const commit = (gesture) => {
|
|
7693
7695
|
if (gesture) {
|
|
7694
7696
|
if (!drags.current.has(gesture)) {
|
|
@@ -7702,20 +7704,114 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
|
|
|
7702
7704
|
const filters = layer?.type === "smart" ? (layer.smartFilters?.filters ?? []).filter((f) => f.kind === "effect") : [];
|
|
7703
7705
|
const generator = layer?.type === "pixel" ? layer.generator : void 0;
|
|
7704
7706
|
const canFilter = !!layer && layer.type !== "adjustment" && layer.type !== "annotation";
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7707
|
+
const styles = (0, import_image_editor9.layerEffectsPanel)(layer);
|
|
7708
|
+
const { description } = useEffectDescription(provider, generator?.effect);
|
|
7709
|
+
const timing = generator ? (0, import_image_editor9.effectLayerTiming)(generator, description) : null;
|
|
7710
|
+
const addOptions = [
|
|
7711
|
+
...provider && canFilter ? [{ value: "filter", label: "Filter\u2026" }] : [],
|
|
7712
|
+
...styles.available && !styles.readOnly ? import_image_editor9.LAYER_EFFECT_MENU.map((m) => ({ value: `style:${m.kind}`, label: m.label })) : []
|
|
7713
|
+
];
|
|
7714
|
+
const add = (value) => {
|
|
7715
|
+
if (!value || !layer) return;
|
|
7716
|
+
if (value === "filter") setBrowse(browse === "filter" ? null : "filter");
|
|
7717
|
+
else run(() => controller.addLayerEffect(layer.id, value.slice("style:".length)));
|
|
7718
|
+
};
|
|
7719
|
+
const scrub = (0, import_react57.useRef)({ next: null, busy: false, gesture: null });
|
|
7720
|
+
const scrubTo = (layerId, time) => {
|
|
7721
|
+
const s = scrub.current;
|
|
7722
|
+
setScrubbed(time);
|
|
7723
|
+
s.next = { layerId, time, commit: commit(s.gesture) };
|
|
7724
|
+
if (s.busy) return;
|
|
7725
|
+
s.busy = true;
|
|
7726
|
+
const step = () => {
|
|
7727
|
+
const n = s.next;
|
|
7728
|
+
s.next = null;
|
|
7729
|
+
if (!n) return Promise.resolve();
|
|
7730
|
+
return controller.updateEffectLayer(n.layerId, { time: n.time }, n.commit).then(step);
|
|
7731
|
+
};
|
|
7732
|
+
step().catch((e) => setMessage(e instanceof Error ? e.message : String(e))).finally(() => {
|
|
7733
|
+
s.busy = false;
|
|
7734
|
+
setScrubbed(null);
|
|
7735
|
+
});
|
|
7736
|
+
};
|
|
7737
|
+
const shown = scrubbed ?? timing?.time ?? 0;
|
|
7738
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("section", { className: `flex flex-col gap-2 text-xs ${className}`, "aria-label": "Effects", "data-image-provider-effects": "", children: [
|
|
7711
7739
|
!provider && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider is registered. Effects in the document are kept." }),
|
|
7712
|
-
|
|
7713
|
-
browse === "layer" && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(EffectsBrowser, { provider, uses: import_image_editor9.EFFECT_LAYER_USES, title: "Generators and overlays", onPick: (e) => (setBrowse(null), run(() => controller.addEffectLayer(e.id))) }),
|
|
7714
|
-
generator && layer && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "space-y-1", "data-effect-part": "generator", children: [
|
|
7740
|
+
generator && layer && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "space-y-2", "data-effect-part": "generator", children: [
|
|
7715
7741
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
7716
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "flex-1 font-medium text-foreground", children: generator.name ?? generator.effect }),
|
|
7742
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "min-w-0 flex-1 truncate font-medium text-foreground", title: generator.name ?? generator.effect, children: generator.name ?? generator.effect }),
|
|
7743
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("button", { type: "button", className: imageOutlineButtonClass, disabled: !provider, "aria-pressed": browse === "change", onClick: () => setBrowse(browse === "change" ? null : "change"), children: "Change\u2026" }),
|
|
7717
7744
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("button", { type: "button", className: imageOutlineButtonClass, title: "Keep the pixels as a plain layer", onClick: () => run(() => controller.rasterizeEffectLayer(layer.id)), children: "Rasterize" })
|
|
7718
7745
|
] }),
|
|
7746
|
+
browse === "change" && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(EffectsBrowser, { provider, uses: import_image_editor9.EFFECT_LAYER_USES, title: "Change the effect to", onPick: (e) => (setBrowse(null), run(() => controller.updateEffectLayer(layer.id, { effect: e.id }))) }),
|
|
7747
|
+
timing && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "space-y-1.5 rounded border border-border p-1.5", "data-effect-part": "timing", role: "group", "aria-label": "Frames", children: [
|
|
7748
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex gap-1", role: "radiogroup", "aria-label": "Output", children: [
|
|
7749
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7750
|
+
"button",
|
|
7751
|
+
{
|
|
7752
|
+
type: "button",
|
|
7753
|
+
role: "radio",
|
|
7754
|
+
"aria-checked": timing.mode === "still",
|
|
7755
|
+
className: `${imageOutlineButtonClass} flex-1 ${timing.mode === "still" ? "bg-accent text-accent-foreground" : ""}`,
|
|
7756
|
+
onClick: () => run(() => controller.updateEffectLayer(layer.id, { animate: null })),
|
|
7757
|
+
children: "Still frame"
|
|
7758
|
+
}
|
|
7759
|
+
),
|
|
7760
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7761
|
+
"button",
|
|
7762
|
+
{
|
|
7763
|
+
type: "button",
|
|
7764
|
+
role: "radio",
|
|
7765
|
+
"aria-checked": timing.mode === "animate",
|
|
7766
|
+
className: `${imageOutlineButtonClass} flex-1 ${timing.mode === "animate" ? "bg-accent text-accent-foreground" : ""}`,
|
|
7767
|
+
onClick: () => run(() => controller.updateEffectLayer(layer.id, { animate: { duration: timing.duration } })),
|
|
7768
|
+
children: "Animate"
|
|
7769
|
+
}
|
|
7770
|
+
)
|
|
7771
|
+
] }),
|
|
7772
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
7773
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "w-16 shrink-0 text-[11px] text-foreground", children: timing.mode === "still" ? "Frame" : "Starts at" }),
|
|
7774
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7775
|
+
ImageRange,
|
|
7776
|
+
{
|
|
7777
|
+
min: 0,
|
|
7778
|
+
max: timing.range,
|
|
7779
|
+
step: Math.max(1, Math.round(timing.range / 200)),
|
|
7780
|
+
className: "flex-1",
|
|
7781
|
+
value: shown,
|
|
7782
|
+
label: timing.mode === "still" ? "Frame" : "Starts at",
|
|
7783
|
+
onStart: () => scrub.current.gesture = `time:${Date.now()}`,
|
|
7784
|
+
onEnd: () => scrub.current.gesture = null,
|
|
7785
|
+
onChange: (t) => scrubTo(layer.id, t)
|
|
7786
|
+
}
|
|
7787
|
+
),
|
|
7788
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "w-12 shrink-0 text-right tabular-nums text-muted-foreground", children: fmt(shown) })
|
|
7789
|
+
] }),
|
|
7790
|
+
timing.mode === "animate" && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
7791
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "w-16 shrink-0 text-[11px] text-foreground", children: "Length" }),
|
|
7792
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7793
|
+
"input",
|
|
7794
|
+
{
|
|
7795
|
+
type: "number",
|
|
7796
|
+
"aria-label": "Animation length in seconds",
|
|
7797
|
+
min: 0.1,
|
|
7798
|
+
max: 60,
|
|
7799
|
+
step: 0.1,
|
|
7800
|
+
defaultValue: Math.round(timing.duration / 100) / 10,
|
|
7801
|
+
className: "w-16 rounded border border-border bg-muted px-1 text-foreground",
|
|
7802
|
+
onBlur: (e) => {
|
|
7803
|
+
const s = Number(e.currentTarget.value);
|
|
7804
|
+
if (s > 0 && s * 1e3 !== timing.duration) run(() => controller.updateEffectLayer(layer.id, { animate: { duration: Math.min(60, s) * 1e3 } }));
|
|
7805
|
+
}
|
|
7806
|
+
},
|
|
7807
|
+
timing.duration
|
|
7808
|
+
),
|
|
7809
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
7810
|
+
"s",
|
|
7811
|
+
timing.loops ? ` \xB7 loops every ${fmt(timing.range)}` : ""
|
|
7812
|
+
] })
|
|
7813
|
+
] })
|
|
7814
|
+
] }),
|
|
7719
7815
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7720
7816
|
ImageEffectControls,
|
|
7721
7817
|
{
|
|
@@ -7729,7 +7825,12 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
|
|
|
7729
7825
|
}
|
|
7730
7826
|
)
|
|
7731
7827
|
] }),
|
|
7732
|
-
|
|
7828
|
+
layer && canFilter && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex items-center gap-1", "data-effect-part": "applied", children: [
|
|
7829
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "flex-1 font-semibold uppercase tracking-wider text-[11px] text-foreground", children: generator ? "On this layer" : "Effects" }),
|
|
7830
|
+
addOptions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ImageSelect, { label: "Add effect", value: "", placeholder: "Add\u2026", options: addOptions, onChange: add })
|
|
7831
|
+
] }),
|
|
7832
|
+
browse === "filter" && layer && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(EffectsBrowser, { provider, uses: ["filter"], title: "Filters", onPick: (e) => (setBrowse(null), run(() => controller.applyEffectFilter(layer.id, e.id))) }),
|
|
7833
|
+
filters.length > 0 && layer && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("ol", { className: "space-y-1", "data-effect-part": "filters", "aria-label": "Filters", children: filters.map((f) => {
|
|
7733
7834
|
const label = f.kind === "effect" ? f.name ?? f.effect : f.kind;
|
|
7734
7835
|
const all = layer.smartFilters.filters;
|
|
7735
7836
|
const index = all.indexOf(f);
|
|
@@ -7780,6 +7881,8 @@ function ImageProviderEffectsPanel({ controller, className = "", components }) {
|
|
|
7780
7881
|
] })
|
|
7781
7882
|
] }, f.id);
|
|
7782
7883
|
}) }),
|
|
7884
|
+
layer && styles.available && styles.rows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(LayerEffectsPanel, { controller, layerId: layer.id, heading: false }),
|
|
7885
|
+
layer && canFilter && !generator && filters.length === 0 && styles.rows.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects yet. Add a filter, or a style such as a drop shadow. New effect layers are added from the layers panel." }),
|
|
7783
7886
|
!layer && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Select a layer to apply effects to it." }),
|
|
7784
7887
|
message2 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message2 })
|
|
7785
7888
|
] });
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.116.0",
|
|
4
4
|
"description": "React bindings and prompt/rich-text components for @pixerate/editor",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -254,7 +254,7 @@
|
|
|
254
254
|
"dependencies": {},
|
|
255
255
|
"peerDependencies": {
|
|
256
256
|
"@dagrejs/dagre": "^1.1.8",
|
|
257
|
-
"@pixerate/editor": ">=0.
|
|
257
|
+
"@pixerate/editor": ">=0.176.0 <1.0.0-0",
|
|
258
258
|
"@tiptap/core": "^2.27.3",
|
|
259
259
|
"@tiptap/extension-bubble-menu": "^2.27.3",
|
|
260
260
|
"@tiptap/extension-placeholder": "^2.27.3",
|
|
@@ -305,7 +305,7 @@
|
|
|
305
305
|
"tsup": "^9.0.0",
|
|
306
306
|
"typescript": "^5.7.3",
|
|
307
307
|
"vitest": "^5.0.5",
|
|
308
|
-
"@pixerate/editor": "0.
|
|
308
|
+
"@pixerate/editor": "0.176.0"
|
|
309
309
|
},
|
|
310
310
|
"scripts": {
|
|
311
311
|
"build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",
|