@pixerate/editor-react 0.127.0 → 0.129.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.
@@ -2805,6 +2805,36 @@ var SelectionOptionsBar = ({
2805
2805
  ] })
2806
2806
  ] }),
2807
2807
  options.tool === "polygon" && /* @__PURE__ */ jsx15("p", { className: "text-muted-foreground", children: "Click to add corners (Shift for 45\xB0), drag for a free-hand stretch; double-click, Enter or a click on the first corner closes it, Backspace removes a corner, Escape cancels." }),
2808
+ options.tool === "magnetic" && /* @__PURE__ */ jsxs13("div", { "data-testid": "magnetic-lasso-options", className: "flex flex-col gap-2", children: [
2809
+ /* @__PURE__ */ jsx15("p", { className: "text-muted-foreground", children: "Click on an edge, then move along it: the outline snaps to the edge and adds points as it goes. Click to add a point; double-click, Enter or a click on the start closes it, Backspace removes the last point, Escape cancels." }),
2810
+ /* @__PURE__ */ jsxs13("label", { className: "flex flex-col gap-1", children: [
2811
+ /* @__PURE__ */ jsxs13("span", { className: "flex justify-between text-muted-foreground", children: [
2812
+ /* @__PURE__ */ jsx15("span", { children: "Width" }),
2813
+ /* @__PURE__ */ jsxs13("span", { className: "font-mono", children: [
2814
+ options.magneticWidth ?? 10,
2815
+ " px"
2816
+ ] })
2817
+ ] }),
2818
+ /* @__PURE__ */ jsx15(ImageRange, { label: "Magnetic lasso width", min: 1, max: 256, step: 1, value: options.magneticWidth ?? 10, onChange: (v) => set({ magneticWidth: v }) })
2819
+ ] }),
2820
+ /* @__PURE__ */ jsxs13("label", { className: "flex flex-col gap-1", children: [
2821
+ /* @__PURE__ */ jsxs13("span", { className: "flex justify-between text-muted-foreground", children: [
2822
+ /* @__PURE__ */ jsx15("span", { children: "Contrast" }),
2823
+ /* @__PURE__ */ jsxs13("span", { className: "font-mono", children: [
2824
+ options.magneticContrast ?? 10,
2825
+ "%"
2826
+ ] })
2827
+ ] }),
2828
+ /* @__PURE__ */ jsx15(ImageRange, { label: "Magnetic lasso contrast", min: 1, max: 100, step: 1, value: options.magneticContrast ?? 10, onChange: (v) => set({ magneticContrast: v }) })
2829
+ ] }),
2830
+ /* @__PURE__ */ jsxs13("label", { className: "flex flex-col gap-1", children: [
2831
+ /* @__PURE__ */ jsxs13("span", { className: "flex justify-between text-muted-foreground", children: [
2832
+ /* @__PURE__ */ jsx15("span", { children: "Frequency" }),
2833
+ /* @__PURE__ */ jsx15("span", { className: "font-mono", children: options.magneticFrequency ?? 57 })
2834
+ ] }),
2835
+ /* @__PURE__ */ jsx15(ImageRange, { label: "Magnetic lasso frequency", min: 0, max: 100, step: 1, value: options.magneticFrequency ?? 57, onChange: (v) => set({ magneticFrequency: v }) })
2836
+ ] })
2837
+ ] }),
2808
2838
  (options.tool === "type" || options.tool === "type-vertical") && /* @__PURE__ */ jsxs13("div", { "data-testid": "type-mask-options", className: "flex flex-col gap-2", children: [
2809
2839
  /* @__PURE__ */ jsxs13("p", { className: "text-muted-foreground", children: [
2810
2840
  options.tool === "type-vertical" ? "Click where the column starts: the letters are stacked down from there, centred on the click." : "Click where the text starts (its baseline).",
@@ -3558,9 +3588,10 @@ var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
3558
3588
 
3559
3589
  // src/image-editor/TypeOptionsBar.tsx
3560
3590
  import { useEffect as useEffect13, useState as useState16 } from "react";
3561
- import { TEXT_ALIGNS } from "@pixerate/editor/image-editor";
3591
+ import { TEXT_ALIGNS, TEXT_ORIENTATIONS } from "@pixerate/editor/image-editor";
3562
3592
  import { jsx as jsx20, jsxs as jsxs18 } from "react/jsx-runtime";
3563
3593
  var ALIGN_LABELS = { left: "Left", center: "Centre", right: "Right", justify: "Justify" };
3594
+ var ORIENTATION_LABELS = { horizontal: "Horizontal", vertical: "Vertical" };
3564
3595
  var TypeOptionsBar = ({ controller, options, onChange, session, className }) => {
3565
3596
  const [, setTick] = useState16(0);
3566
3597
  useEffect13(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
@@ -3578,6 +3609,27 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
3578
3609
  };
3579
3610
  const fonts = controller.listFonts();
3580
3611
  const missing = active?.type === "type" ? active.missingFonts ?? [] : [];
3612
+ const editedId = session?.alive ? session.layerId : typeId;
3613
+ const edited = editedId ? controller.getLayer(editedId) : null;
3614
+ const orientation = edited?.type === "type" ? edited.orientation ?? "horizontal" : options.orientation ?? "horizontal";
3615
+ const orient = (next) => {
3616
+ onChange({ ...options, orientation: next });
3617
+ try {
3618
+ setError(null);
3619
+ if (editedId) controller.setTextOrientation(editedId, next);
3620
+ } catch (e) {
3621
+ setError(e instanceof Error ? e.message : String(e));
3622
+ }
3623
+ };
3624
+ const upright = () => {
3625
+ try {
3626
+ setError(null);
3627
+ if (session?.alive) session.setStyle({ upright: !here.upright });
3628
+ else if (typeId) controller.setTextStyle(typeId, { upright: !(edited?.type === "type" && edited.runs[0]?.style.upright) });
3629
+ } catch (e) {
3630
+ setError(e instanceof Error ? e.message : String(e));
3631
+ }
3632
+ };
3581
3633
  const style = (change) => {
3582
3634
  onChange({ ...options, ...change });
3583
3635
  const s = {};
@@ -3633,7 +3685,21 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
3633
3685
  /* @__PURE__ */ jsx20(ImageColor, { label: "Text colour", value: shown.color, onChange: (color) => style({ color }) })
3634
3686
  ] }),
3635
3687
  /* @__PURE__ */ jsx20("div", { className: "flex gap-1", role: "toolbar", "aria-label": "Alignment", children: TEXT_ALIGNS.map((a) => /* @__PURE__ */ jsx20("button", { type: "button", "aria-pressed": options.align === a, className: imageChipClass(options.align === a), onClick: () => style({ align: a }), children: ALIGN_LABELS[a] }, a)) }),
3636
- /* @__PURE__ */ jsx20("p", { className: "text-[10px] text-muted-foreground", children: "Click to type point text, drag for a paragraph box, click text to edit it. Esc finishes." }),
3688
+ /* @__PURE__ */ jsxs18("div", { className: "flex gap-1", role: "toolbar", "aria-label": "Orientation", children: [
3689
+ TEXT_ORIENTATIONS.map((o) => /* @__PURE__ */ jsx20("button", { type: "button", "aria-pressed": orientation === o, className: imageChipClass(orientation === o), onClick: () => orient(o), children: ORIENTATION_LABELS[o] }, o)),
3690
+ orientation === "vertical" && editedId && /* @__PURE__ */ jsx20(
3691
+ "button",
3692
+ {
3693
+ type: "button",
3694
+ "aria-pressed": Boolean(session?.alive ? here.upright : edited?.type === "type" && edited.runs[0]?.style.upright),
3695
+ className: imageChipClass(Boolean(session?.alive ? here.upright : edited?.type === "type" && edited.runs[0]?.style.upright)),
3696
+ title: "Set Latin upright, one letter under the other (else turned sideways)",
3697
+ onClick: upright,
3698
+ children: "Upright Latin"
3699
+ }
3700
+ )
3701
+ ] }),
3702
+ /* @__PURE__ */ jsx20("p", { className: "text-[10px] text-muted-foreground", children: "Click to type point text (vertical: a column down from the click), drag for a paragraph box, click text to edit it. Esc finishes." }),
3637
3703
  missing.length > 0 && /* @__PURE__ */ jsxs18("p", { role: "status", className: "text-amber-600", "data-testid": "type-missing-fonts", children: [
3638
3704
  "Missing ",
3639
3705
  missing.length === 1 ? "font" : "fonts",
@@ -9,8 +9,8 @@ export interface TypeOptionsBarProps {
9
9
  className?: string;
10
10
  }
11
11
  /**
12
- * The type tool's options: font family (from the editor's fonts), size, bold, italic, colour and
13
- * alignment. While text is being edited they style the selection (or the whole text); with a
12
+ * The type tool's options: font family (from the editor's fonts), size, bold, italic, colour,
13
+ * alignment and orientation (horizontal or vertical type, with upright Latin in vertical text). While text is being edited they style the selection (or the whole text); with a
14
14
  * type layer active they style all of it; otherwise they set what the next text uses.
15
15
  */
16
16
  export declare const TypeOptionsBar: React.FC<TypeOptionsBarProps>;
@@ -9,8 +9,8 @@ export interface TypeOptionsBarProps {
9
9
  className?: string;
10
10
  }
11
11
  /**
12
- * The type tool's options: font family (from the editor's fonts), size, bold, italic, colour and
13
- * alignment. While text is being edited they style the selection (or the whole text); with a
12
+ * The type tool's options: font family (from the editor's fonts), size, bold, italic, colour,
13
+ * alignment and orientation (horizontal or vertical type, with upright Latin in vertical text). While text is being edited they style the selection (or the whole text); with a
14
14
  * type layer active they style all of it; otherwise they set what the next text uses.
15
15
  */
16
16
  export declare const TypeOptionsBar: React.FC<TypeOptionsBarProps>;
@@ -4736,6 +4736,36 @@ var SelectionOptionsBar = ({
4736
4736
  ] })
4737
4737
  ] }),
4738
4738
  options.tool === "polygon" && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-muted-foreground", children: "Click to add corners (Shift for 45\xB0), drag for a free-hand stretch; double-click, Enter or a click on the first corner closes it, Backspace removes a corner, Escape cancels." }),
4739
+ options.tool === "magnetic" && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { "data-testid": "magnetic-lasso-options", className: "flex flex-col gap-2", children: [
4740
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-muted-foreground", children: "Click on an edge, then move along it: the outline snaps to the edge and adds points as it goes. Click to add a point; double-click, Enter or a click on the start closes it, Backspace removes the last point, Escape cancels." }),
4741
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex flex-col gap-1", children: [
4742
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "flex justify-between text-muted-foreground", children: [
4743
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: "Width" }),
4744
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "font-mono", children: [
4745
+ options.magneticWidth ?? 10,
4746
+ " px"
4747
+ ] })
4748
+ ] }),
4749
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ImageRange, { label: "Magnetic lasso width", min: 1, max: 256, step: 1, value: options.magneticWidth ?? 10, onChange: (v) => set({ magneticWidth: v }) })
4750
+ ] }),
4751
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex flex-col gap-1", children: [
4752
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "flex justify-between text-muted-foreground", children: [
4753
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: "Contrast" }),
4754
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "font-mono", children: [
4755
+ options.magneticContrast ?? 10,
4756
+ "%"
4757
+ ] })
4758
+ ] }),
4759
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ImageRange, { label: "Magnetic lasso contrast", min: 1, max: 100, step: 1, value: options.magneticContrast ?? 10, onChange: (v) => set({ magneticContrast: v }) })
4760
+ ] }),
4761
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex flex-col gap-1", children: [
4762
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "flex justify-between text-muted-foreground", children: [
4763
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: "Frequency" }),
4764
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-mono", children: options.magneticFrequency ?? 57 })
4765
+ ] }),
4766
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ImageRange, { label: "Magnetic lasso frequency", min: 0, max: 100, step: 1, value: options.magneticFrequency ?? 57, onChange: (v) => set({ magneticFrequency: v }) })
4767
+ ] })
4768
+ ] }),
4739
4769
  (options.tool === "type" || options.tool === "type-vertical") && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { "data-testid": "type-mask-options", className: "flex flex-col gap-2", children: [
4740
4770
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("p", { className: "text-muted-foreground", children: [
4741
4771
  options.tool === "type-vertical" ? "Click where the column starts: the letters are stacked down from there, centred on the click." : "Click where the text starts (its baseline).",
@@ -5487,6 +5517,7 @@ var import_react30 = require("react");
5487
5517
  var import_image_editor19 = require("@pixerate/editor/image-editor");
5488
5518
  var import_jsx_runtime30 = require("react/jsx-runtime");
5489
5519
  var ALIGN_LABELS = { left: "Left", center: "Centre", right: "Right", justify: "Justify" };
5520
+ var ORIENTATION_LABELS = { horizontal: "Horizontal", vertical: "Vertical" };
5490
5521
  var TypeOptionsBar = ({ controller, options, onChange, session, className }) => {
5491
5522
  const [, setTick] = (0, import_react30.useState)(0);
5492
5523
  (0, import_react30.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
@@ -5504,6 +5535,27 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
5504
5535
  };
5505
5536
  const fonts = controller.listFonts();
5506
5537
  const missing = active?.type === "type" ? active.missingFonts ?? [] : [];
5538
+ const editedId = session?.alive ? session.layerId : typeId;
5539
+ const edited = editedId ? controller.getLayer(editedId) : null;
5540
+ const orientation = edited?.type === "type" ? edited.orientation ?? "horizontal" : options.orientation ?? "horizontal";
5541
+ const orient = (next) => {
5542
+ onChange({ ...options, orientation: next });
5543
+ try {
5544
+ setError(null);
5545
+ if (editedId) controller.setTextOrientation(editedId, next);
5546
+ } catch (e) {
5547
+ setError(e instanceof Error ? e.message : String(e));
5548
+ }
5549
+ };
5550
+ const upright = () => {
5551
+ try {
5552
+ setError(null);
5553
+ if (session?.alive) session.setStyle({ upright: !here.upright });
5554
+ else if (typeId) controller.setTextStyle(typeId, { upright: !(edited?.type === "type" && edited.runs[0]?.style.upright) });
5555
+ } catch (e) {
5556
+ setError(e instanceof Error ? e.message : String(e));
5557
+ }
5558
+ };
5507
5559
  const style = (change) => {
5508
5560
  onChange({ ...options, ...change });
5509
5561
  const s = {};
@@ -5559,7 +5611,21 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
5559
5611
  /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(ImageColor, { label: "Text colour", value: shown.color, onChange: (color) => style({ color }) })
5560
5612
  ] }),
5561
5613
  /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "flex gap-1", role: "toolbar", "aria-label": "Alignment", children: import_image_editor19.TEXT_ALIGNS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", "aria-pressed": options.align === a, className: imageChipClass(options.align === a), onClick: () => style({ align: a }), children: ALIGN_LABELS[a] }, a)) }),
5562
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "text-[10px] text-muted-foreground", children: "Click to type point text, drag for a paragraph box, click text to edit it. Esc finishes." }),
5614
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex gap-1", role: "toolbar", "aria-label": "Orientation", children: [
5615
+ import_image_editor19.TEXT_ORIENTATIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("button", { type: "button", "aria-pressed": orientation === o, className: imageChipClass(orientation === o), onClick: () => orient(o), children: ORIENTATION_LABELS[o] }, o)),
5616
+ orientation === "vertical" && editedId && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
5617
+ "button",
5618
+ {
5619
+ type: "button",
5620
+ "aria-pressed": Boolean(session?.alive ? here.upright : edited?.type === "type" && edited.runs[0]?.style.upright),
5621
+ className: imageChipClass(Boolean(session?.alive ? here.upright : edited?.type === "type" && edited.runs[0]?.style.upright)),
5622
+ title: "Set Latin upright, one letter under the other (else turned sideways)",
5623
+ onClick: upright,
5624
+ children: "Upright Latin"
5625
+ }
5626
+ )
5627
+ ] }),
5628
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "text-[10px] text-muted-foreground", children: "Click to type point text (vertical: a column down from the click), drag for a paragraph box, click text to edit it. Esc finishes." }),
5563
5629
  missing.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("p", { role: "status", className: "text-amber-600", "data-testid": "type-missing-fonts", children: [
5564
5630
  "Missing ",
5565
5631
  missing.length === 1 ? "font" : "fonts",
@@ -27,7 +27,7 @@ import {
27
27
  useImageEditorControls,
28
28
  useImageEffectsTools,
29
29
  useImageHistogram
30
- } from "../chunk-KNLBDEW6.js";
30
+ } from "../chunk-5XDRXZSA.js";
31
31
  import "../chunk-AJCWF6SN.js";
32
32
  import "../chunk-6BWTJ3EE.js";
33
33
  import "../chunk-5RPB4WGT.js";
package/dist/index.cjs CHANGED
@@ -8450,6 +8450,36 @@ var SelectionOptionsBar = ({
8450
8450
  ] })
8451
8451
  ] }),
8452
8452
  options.tool === "polygon" && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { className: "text-muted-foreground", children: "Click to add corners (Shift for 45\xB0), drag for a free-hand stretch; double-click, Enter or a click on the first corner closes it, Backspace removes a corner, Escape cancels." }),
8453
+ options.tool === "magnetic" && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { "data-testid": "magnetic-lasso-options", className: "flex flex-col gap-2", children: [
8454
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { className: "text-muted-foreground", children: "Click on an edge, then move along it: the outline snaps to the edge and adds points as it goes. Click to add a point; double-click, Enter or a click on the start closes it, Backspace removes the last point, Escape cancels." }),
8455
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: "flex flex-col gap-1", children: [
8456
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("span", { className: "flex justify-between text-muted-foreground", children: [
8457
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: "Width" }),
8458
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("span", { className: "font-mono", children: [
8459
+ options.magneticWidth ?? 10,
8460
+ " px"
8461
+ ] })
8462
+ ] }),
8463
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ImageRange, { label: "Magnetic lasso width", min: 1, max: 256, step: 1, value: options.magneticWidth ?? 10, onChange: (v) => set({ magneticWidth: v }) })
8464
+ ] }),
8465
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: "flex flex-col gap-1", children: [
8466
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("span", { className: "flex justify-between text-muted-foreground", children: [
8467
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: "Contrast" }),
8468
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("span", { className: "font-mono", children: [
8469
+ options.magneticContrast ?? 10,
8470
+ "%"
8471
+ ] })
8472
+ ] }),
8473
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ImageRange, { label: "Magnetic lasso contrast", min: 1, max: 100, step: 1, value: options.magneticContrast ?? 10, onChange: (v) => set({ magneticContrast: v }) })
8474
+ ] }),
8475
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: "flex flex-col gap-1", children: [
8476
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("span", { className: "flex justify-between text-muted-foreground", children: [
8477
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: "Frequency" }),
8478
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "font-mono", children: options.magneticFrequency ?? 57 })
8479
+ ] }),
8480
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ImageRange, { label: "Magnetic lasso frequency", min: 0, max: 100, step: 1, value: options.magneticFrequency ?? 57, onChange: (v) => set({ magneticFrequency: v }) })
8481
+ ] })
8482
+ ] }),
8453
8483
  (options.tool === "type" || options.tool === "type-vertical") && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { "data-testid": "type-mask-options", className: "flex flex-col gap-2", children: [
8454
8484
  /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("p", { className: "text-muted-foreground", children: [
8455
8485
  options.tool === "type-vertical" ? "Click where the column starts: the letters are stacked down from there, centred on the click." : "Click where the text starts (its baseline).",
@@ -9201,6 +9231,7 @@ var import_react66 = require("react");
9201
9231
  var import_image_editor19 = require("@pixerate/editor/image-editor");
9202
9232
  var import_jsx_runtime46 = require("react/jsx-runtime");
9203
9233
  var ALIGN_LABELS = { left: "Left", center: "Centre", right: "Right", justify: "Justify" };
9234
+ var ORIENTATION_LABELS = { horizontal: "Horizontal", vertical: "Vertical" };
9204
9235
  var TypeOptionsBar = ({ controller, options, onChange, session, className }) => {
9205
9236
  const [, setTick] = (0, import_react66.useState)(0);
9206
9237
  (0, import_react66.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
@@ -9218,6 +9249,27 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
9218
9249
  };
9219
9250
  const fonts = controller.listFonts();
9220
9251
  const missing = active?.type === "type" ? active.missingFonts ?? [] : [];
9252
+ const editedId = session?.alive ? session.layerId : typeId;
9253
+ const edited = editedId ? controller.getLayer(editedId) : null;
9254
+ const orientation = edited?.type === "type" ? edited.orientation ?? "horizontal" : options.orientation ?? "horizontal";
9255
+ const orient = (next) => {
9256
+ onChange({ ...options, orientation: next });
9257
+ try {
9258
+ setError(null);
9259
+ if (editedId) controller.setTextOrientation(editedId, next);
9260
+ } catch (e) {
9261
+ setError(e instanceof Error ? e.message : String(e));
9262
+ }
9263
+ };
9264
+ const upright = () => {
9265
+ try {
9266
+ setError(null);
9267
+ if (session?.alive) session.setStyle({ upright: !here.upright });
9268
+ else if (typeId) controller.setTextStyle(typeId, { upright: !(edited?.type === "type" && edited.runs[0]?.style.upright) });
9269
+ } catch (e) {
9270
+ setError(e instanceof Error ? e.message : String(e));
9271
+ }
9272
+ };
9221
9273
  const style = (change) => {
9222
9274
  onChange({ ...options, ...change });
9223
9275
  const s = {};
@@ -9273,7 +9325,21 @@ var TypeOptionsBar = ({ controller, options, onChange, session, className }) =>
9273
9325
  /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(ImageColor, { label: "Text colour", value: shown.color, onChange: (color) => style({ color }) })
9274
9326
  ] }),
9275
9327
  /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "flex gap-1", role: "toolbar", "aria-label": "Alignment", children: import_image_editor19.TEXT_ALIGNS.map((a) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", "aria-pressed": options.align === a, className: imageChipClass(options.align === a), onClick: () => style({ align: a }), children: ALIGN_LABELS[a] }, a)) }),
9276
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { className: "text-[10px] text-muted-foreground", children: "Click to type point text, drag for a paragraph box, click text to edit it. Esc finishes." }),
9328
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex gap-1", role: "toolbar", "aria-label": "Orientation", children: [
9329
+ import_image_editor19.TEXT_ORIENTATIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", "aria-pressed": orientation === o, className: imageChipClass(orientation === o), onClick: () => orient(o), children: ORIENTATION_LABELS[o] }, o)),
9330
+ orientation === "vertical" && editedId && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
9331
+ "button",
9332
+ {
9333
+ type: "button",
9334
+ "aria-pressed": Boolean(session?.alive ? here.upright : edited?.type === "type" && edited.runs[0]?.style.upright),
9335
+ className: imageChipClass(Boolean(session?.alive ? here.upright : edited?.type === "type" && edited.runs[0]?.style.upright)),
9336
+ title: "Set Latin upright, one letter under the other (else turned sideways)",
9337
+ onClick: upright,
9338
+ children: "Upright Latin"
9339
+ }
9340
+ )
9341
+ ] }),
9342
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { className: "text-[10px] text-muted-foreground", children: "Click to type point text (vertical: a column down from the click), drag for a paragraph box, click text to edit it. Esc finishes." }),
9277
9343
  missing.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("p", { role: "status", className: "text-amber-600", "data-testid": "type-missing-fonts", children: [
9278
9344
  "Missing ",
9279
9345
  missing.length === 1 ? "font" : "fonts",
package/dist/index.js CHANGED
@@ -51,7 +51,7 @@ import {
51
51
  useImageEditorControls,
52
52
  useImageEffectsTools,
53
53
  useImageHistogram
54
- } from "./chunk-KNLBDEW6.js";
54
+ } from "./chunk-5XDRXZSA.js";
55
55
  import "./chunk-AJCWF6SN.js";
56
56
  import "./chunk-6BWTJ3EE.js";
57
57
  import "./chunk-5RPB4WGT.js";
@@ -6,7 +6,8 @@ export interface VectorTextPanelProps {
6
6
  }
7
7
  /**
8
8
  * Character and paragraph style of text: family, weight, size, italic, underline, strike-through,
9
- * tracking, leading, alignment and point / area text. It edits the selected characters while text
9
+ * tracking, leading, alignment, horizontal / vertical orientation (with upright Latin in vertical
10
+ * text) and point / area text. It edits the selected characters while text
10
11
  * is being edited, else the selected text, else the defaults for new text. Type on a Path turns a
11
12
  * selected path into path text, and Create Outlines turns text into paths (with an outline
12
13
  * shaper). Each change is one undo step.
@@ -6,7 +6,8 @@ export interface VectorTextPanelProps {
6
6
  }
7
7
  /**
8
8
  * Character and paragraph style of text: family, weight, size, italic, underline, strike-through,
9
- * tracking, leading, alignment and point / area text. It edits the selected characters while text
9
+ * tracking, leading, alignment, horizontal / vertical orientation (with upright Latin in vertical
10
+ * text) and point / area text. It edits the selected characters while text
10
11
  * is being edited, else the selected text, else the defaults for new text. Type on a Path turns a
11
12
  * selected path into path text, and Create Outlines turns text into paths (with an outline
12
13
  * shaper). Each change is one undo step.
@@ -1699,6 +1699,42 @@ function VectorTextPanel({ controller, className }) {
1699
1699
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: buttonClass5, "aria-label": "Underline", "aria-pressed": f.underline === true, onClick: () => style({ underline: !f.underline }), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("u", { children: "U" }) }),
1700
1700
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: buttonClass5, "aria-label": "Strike through", "aria-pressed": f.strikethrough === true, onClick: () => style({ strikethrough: !f.strikethrough }), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("s", { children: "S" }) })
1701
1701
  ] }),
1702
+ panel.target !== "defaults" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-wrap items-center gap-1", role: "group", "aria-label": "Orientation", children: [
1703
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1704
+ "button",
1705
+ {
1706
+ type: "button",
1707
+ className: buttonClass5,
1708
+ "aria-pressed": panel.orientation === "horizontal",
1709
+ title: "Horizontal text: lines left to right",
1710
+ onClick: () => (0, import_vector8.applyVectorTextOrientation)(controller, "horizontal"),
1711
+ children: "Horizontal"
1712
+ }
1713
+ ),
1714
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1715
+ "button",
1716
+ {
1717
+ type: "button",
1718
+ className: buttonClass5,
1719
+ "aria-pressed": panel.orientation === "vertical",
1720
+ disabled: !panel.canOrient,
1721
+ title: panel.canOrient ? "Vertical text: columns top to bottom, right to left" : "Text on a path cannot be vertical",
1722
+ onClick: () => (0, import_vector8.applyVectorTextOrientation)(controller, "vertical"),
1723
+ children: "Vertical"
1724
+ }
1725
+ ),
1726
+ panel.orientation === "vertical" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1727
+ "button",
1728
+ {
1729
+ type: "button",
1730
+ className: buttonClass5,
1731
+ "aria-pressed": f.upright === true,
1732
+ title: "Set Latin upright, one letter under the other (else turned sideways)",
1733
+ onClick: () => style({ upright: !f.upright }),
1734
+ children: "Upright Latin"
1735
+ }
1736
+ )
1737
+ ] }),
1702
1738
  /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-1", children: [
1703
1739
  /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { className: "flex flex-1 items-center gap-1 text-xs text-foreground", title: "Tracking (1/1000 em)", children: [
1704
1740
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-[11px] text-muted-foreground", children: "VA" }),
@@ -1536,6 +1536,7 @@ import {
1536
1536
  VECTOR_FONT_WEIGHTS,
1537
1537
  VECTOR_TEXT_ALIGN_OPTIONS,
1538
1538
  applyVectorParagraphStyle,
1539
+ applyVectorTextOrientation,
1539
1540
  applyVectorTextStyle,
1540
1541
  getVectorTextPanel
1541
1542
  } from "@pixerate/editor/vector";
@@ -1612,6 +1613,42 @@ function VectorTextPanel({ controller, className }) {
1612
1613
  /* @__PURE__ */ jsx7("button", { type: "button", className: buttonClass5, "aria-label": "Underline", "aria-pressed": f.underline === true, onClick: () => style({ underline: !f.underline }), children: /* @__PURE__ */ jsx7("u", { children: "U" }) }),
1613
1614
  /* @__PURE__ */ jsx7("button", { type: "button", className: buttonClass5, "aria-label": "Strike through", "aria-pressed": f.strikethrough === true, onClick: () => style({ strikethrough: !f.strikethrough }), children: /* @__PURE__ */ jsx7("s", { children: "S" }) })
1614
1615
  ] }),
1616
+ panel.target !== "defaults" && /* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap items-center gap-1", role: "group", "aria-label": "Orientation", children: [
1617
+ /* @__PURE__ */ jsx7(
1618
+ "button",
1619
+ {
1620
+ type: "button",
1621
+ className: buttonClass5,
1622
+ "aria-pressed": panel.orientation === "horizontal",
1623
+ title: "Horizontal text: lines left to right",
1624
+ onClick: () => applyVectorTextOrientation(controller, "horizontal"),
1625
+ children: "Horizontal"
1626
+ }
1627
+ ),
1628
+ /* @__PURE__ */ jsx7(
1629
+ "button",
1630
+ {
1631
+ type: "button",
1632
+ className: buttonClass5,
1633
+ "aria-pressed": panel.orientation === "vertical",
1634
+ disabled: !panel.canOrient,
1635
+ title: panel.canOrient ? "Vertical text: columns top to bottom, right to left" : "Text on a path cannot be vertical",
1636
+ onClick: () => applyVectorTextOrientation(controller, "vertical"),
1637
+ children: "Vertical"
1638
+ }
1639
+ ),
1640
+ panel.orientation === "vertical" && /* @__PURE__ */ jsx7(
1641
+ "button",
1642
+ {
1643
+ type: "button",
1644
+ className: buttonClass5,
1645
+ "aria-pressed": f.upright === true,
1646
+ title: "Set Latin upright, one letter under the other (else turned sideways)",
1647
+ onClick: () => style({ upright: !f.upright }),
1648
+ children: "Upright Latin"
1649
+ }
1650
+ )
1651
+ ] }),
1615
1652
  /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-1", children: [
1616
1653
  /* @__PURE__ */ jsxs7("label", { className: "flex flex-1 items-center gap-1 text-xs text-foreground", title: "Tracking (1/1000 em)", children: [
1617
1654
  /* @__PURE__ */ jsx7("span", { className: "text-[11px] text-muted-foreground", children: "VA" }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-react",
3
- "version": "0.127.0",
3
+ "version": "0.129.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.192.0 <1.0.0-0",
257
+ "@pixerate/editor": ">=0.195.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.192.0"
308
+ "@pixerate/editor": "0.195.0"
309
309
  },
310
310
  "scripts": {
311
311
  "build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",