@pixerate/editor-react 0.203.0 → 0.205.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/index.cjs CHANGED
@@ -45,7 +45,7 @@ __export(src_exports, {
45
45
  ContentAwareFillWorkspace: () => ContentAwareFillWorkspace,
46
46
  ControlSlider: () => ControlSlider,
47
47
  CurvesEditor: () => CurvesEditor,
48
- DirtyTracker: () => import_editor23.DirtyTracker,
48
+ DirtyTracker: () => import_editor24.DirtyTracker,
49
49
  EdgeColorPanel: () => EdgeColorPanel,
50
50
  EditorContent: () => EditorContent,
51
51
  EditorSlotsProvider: () => EditorSlotsProvider,
@@ -56,7 +56,7 @@ __export(src_exports, {
56
56
  GenerationHistory: () => GenerationHistory,
57
57
  GenerationSettings: () => GenerationSettings,
58
58
  Histogram: () => Histogram,
59
- HistoryManager: () => import_editor23.HistoryManager,
59
+ HistoryManager: () => import_editor24.HistoryManager,
60
60
  ImageCheckbox: () => ImageCheckbox,
61
61
  ImageColor: () => ImageColor,
62
62
  ImageEditor: () => ImageEditor,
@@ -102,13 +102,13 @@ __export(src_exports, {
102
102
  TypeOptionsBar: () => TypeOptionsBar,
103
103
  VariableForm: () => VariableForm,
104
104
  VectorMaskEdgesPanel: () => VectorMaskEdgesPanel,
105
- bindDirtyToHistory: () => import_editor23.bindDirtyToHistory,
106
- createDirtyTracker: () => import_editor23.createDirtyTracker,
107
- createHistoryManager: () => import_editor23.createHistoryManager,
105
+ bindDirtyToHistory: () => import_editor24.bindDirtyToHistory,
106
+ createDirtyTracker: () => import_editor24.createDirtyTracker,
107
+ createHistoryManager: () => import_editor24.createHistoryManager,
108
108
  createReactChartNodeView: () => createReactChartNodeView,
109
109
  createReactLoadingNodeView: () => createReactLoadingNodeView,
110
- defaultIsEqual: () => import_editor23.defaultIsEqual,
111
- formatCommandsFor: () => import_editor22.formatCommandsFor,
110
+ defaultIsEqual: () => import_editor24.defaultIsEqual,
111
+ formatCommandsFor: () => import_editor23.formatCommandsFor,
112
112
  useAgentPlayback: () => useAgentPlayback,
113
113
  useAgentToolProvider: () => useAgentToolProvider,
114
114
  useAutosave: () => useAutosave,
@@ -144,6 +144,7 @@ __export(src_exports, {
144
144
  usePromptEditor: () => usePromptEditor,
145
145
  useRegisterCommands: () => useRegisterCommands,
146
146
  useRichTextEditorDocument: () => useRichTextEditorDocument,
147
+ useRichTextStyleFindings: () => useRichTextStyleFindings,
147
148
  useSpreadsheetClipboard: () => useSpreadsheetClipboard,
148
149
  useSpreadsheetEditor: () => useSpreadsheetEditor,
149
150
  useSpreadsheetViewport: () => useSpreadsheetViewport,
@@ -155,7 +156,7 @@ __export(src_exports, {
155
156
  useToolBridge: () => useToolBridge,
156
157
  useToolRegistryView: () => useToolRegistryView,
157
158
  useTrackChanges: () => useTrackChanges,
158
- withoutDirty: () => import_editor23.withoutDirty
159
+ withoutDirty: () => import_editor24.withoutDirty
159
160
  });
160
161
  module.exports = __toCommonJS(src_exports);
161
162
 
@@ -257,7 +258,7 @@ function useEditor2(options = {}) {
257
258
  }
258
259
 
259
260
  // src/index.ts
260
- var import_editor22 = require("@pixerate/editor");
261
+ var import_editor23 = require("@pixerate/editor");
261
262
 
262
263
  // src/hooks/useNavigationGuard.ts
263
264
  var import_react4 = require("react");
@@ -1553,7 +1554,7 @@ var StylesGallery = ({
1553
1554
  };
1554
1555
 
1555
1556
  // src/index.ts
1556
- var import_editor23 = require("@pixerate/editor");
1557
+ var import_editor24 = require("@pixerate/editor");
1557
1558
 
1558
1559
  // src/spreadsheet/useSpreadsheetEditor.ts
1559
1560
  var import_react28 = require("react");
@@ -14547,6 +14548,7 @@ function createReactChartNodeView(options = {}) {
14547
14548
  // src/style/useStyle.ts
14548
14549
  var import_react104 = require("react");
14549
14550
  var import_tools5 = require("@pixerate/editor/tools");
14551
+ var import_editor22 = require("@pixerate/editor");
14550
14552
  var message = (error) => error instanceof Error ? error.message : String(error);
14551
14553
  function useResolverTask(styles, run, deliver, deps) {
14552
14554
  (0, import_react104.useEffect)(() => {
@@ -14585,11 +14587,11 @@ function useStyle(styles, domain) {
14585
14587
  );
14586
14588
  return result;
14587
14589
  }
14588
- function useStyleFindings(styles, domain, state) {
14590
+ function useStyleFindings(styles, domain, state, scope) {
14589
14591
  const [result, setResult] = (0, import_react104.useState)({ report: null, style: null, error: null });
14590
14592
  useResolverTask(
14591
14593
  styles,
14592
- (s) => s.check(domain, state),
14594
+ (s) => s.check(domain, state, scope !== void 0 ? { scope } : {}),
14593
14595
  ({ value, error }) => {
14594
14596
  if (!value) setResult({ report: null, style: null, error });
14595
14597
  else {
@@ -14597,7 +14599,7 @@ function useStyleFindings(styles, domain, state) {
14597
14599
  setResult({ report, style, error: null });
14598
14600
  }
14599
14601
  },
14600
- [domain, state]
14602
+ [domain, state, scope]
14601
14603
  );
14602
14604
  return result;
14603
14605
  }
@@ -14636,6 +14638,23 @@ function useStyleSwatches(styles, domain, scope) {
14636
14638
  return { colors: colors.map((c) => c.color), swatches: colors, fonts, error: state.error };
14637
14639
  }, [state]);
14638
14640
  }
14641
+ function useRichTextStyleFindings(styles, editor, scope) {
14642
+ const [doc, setDoc] = (0, import_react104.useState)(() => editor?.state.doc ?? null);
14643
+ (0, import_react104.useEffect)(() => {
14644
+ if (!editor) {
14645
+ setDoc(null);
14646
+ return;
14647
+ }
14648
+ setDoc(editor.state.doc);
14649
+ const onUpdate = () => setDoc(editor.state.doc);
14650
+ editor.on("update", onUpdate);
14651
+ return () => {
14652
+ editor.off("update", onUpdate);
14653
+ };
14654
+ }, [editor]);
14655
+ const state = (0, import_react104.useMemo)(() => doc ? (0, import_editor22.richTextStyleState)(doc) : null, [doc]);
14656
+ return useStyleFindings(state ? styles : null, "rich-text", state, scope);
14657
+ }
14639
14658
 
14640
14659
  // src/style/StyleFindings.tsx
14641
14660
  var import_jsx_runtime80 = require("react/jsx-runtime");
@@ -14805,6 +14824,7 @@ function StyleFindings({ report, onSelect, title = "House style", className = ""
14805
14824
  usePromptEditor,
14806
14825
  useRegisterCommands,
14807
14826
  useRichTextEditorDocument,
14827
+ useRichTextStyleFindings,
14808
14828
  useSpreadsheetClipboard,
14809
14829
  useSpreadsheetEditor,
14810
14830
  useSpreadsheetViewport,
package/dist/index.js CHANGED
@@ -2266,6 +2266,7 @@ function createReactChartNodeView(options = {}) {
2266
2266
  // src/style/useStyle.ts
2267
2267
  import { useCallback as useCallback9, useEffect as useEffect13, useMemo as useMemo17, useState as useState14 } from "react";
2268
2268
  import { styleSwatches } from "@pixerate/editor/tools";
2269
+ import { richTextStyleState } from "@pixerate/editor";
2269
2270
  var message = (error) => error instanceof Error ? error.message : String(error);
2270
2271
  function useResolverTask(styles, run, deliver, deps) {
2271
2272
  useEffect13(() => {
@@ -2304,11 +2305,11 @@ function useStyle(styles, domain) {
2304
2305
  );
2305
2306
  return result;
2306
2307
  }
2307
- function useStyleFindings(styles, domain, state) {
2308
+ function useStyleFindings(styles, domain, state, scope) {
2308
2309
  const [result, setResult] = useState14({ report: null, style: null, error: null });
2309
2310
  useResolverTask(
2310
2311
  styles,
2311
- (s) => s.check(domain, state),
2312
+ (s) => s.check(domain, state, scope !== void 0 ? { scope } : {}),
2312
2313
  ({ value, error }) => {
2313
2314
  if (!value) setResult({ report: null, style: null, error });
2314
2315
  else {
@@ -2316,7 +2317,7 @@ function useStyleFindings(styles, domain, state) {
2316
2317
  setResult({ report, style, error: null });
2317
2318
  }
2318
2319
  },
2319
- [domain, state]
2320
+ [domain, state, scope]
2320
2321
  );
2321
2322
  return result;
2322
2323
  }
@@ -2355,6 +2356,23 @@ function useStyleSwatches(styles, domain, scope) {
2355
2356
  return { colors: colors.map((c) => c.color), swatches: colors, fonts, error: state.error };
2356
2357
  }, [state]);
2357
2358
  }
2359
+ function useRichTextStyleFindings(styles, editor, scope) {
2360
+ const [doc, setDoc] = useState14(() => editor?.state.doc ?? null);
2361
+ useEffect13(() => {
2362
+ if (!editor) {
2363
+ setDoc(null);
2364
+ return;
2365
+ }
2366
+ setDoc(editor.state.doc);
2367
+ const onUpdate = () => setDoc(editor.state.doc);
2368
+ editor.on("update", onUpdate);
2369
+ return () => {
2370
+ editor.off("update", onUpdate);
2371
+ };
2372
+ }, [editor]);
2373
+ const state = useMemo17(() => doc ? richTextStyleState(doc) : null, [doc]);
2374
+ return useStyleFindings(state ? styles : null, "rich-text", state, scope);
2375
+ }
2358
2376
 
2359
2377
  // src/style/StyleFindings.tsx
2360
2378
  import { Fragment as Fragment2, jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
@@ -2523,6 +2541,7 @@ export {
2523
2541
  usePromptEditor,
2524
2542
  useRegisterCommands,
2525
2543
  useRichTextEditorDocument,
2544
+ useRichTextStyleFindings,
2526
2545
  useSpreadsheetClipboard,
2527
2546
  useSpreadsheetEditor,
2528
2547
  useSpreadsheetViewport,
@@ -1,3 +1,4 @@
1
+ import type { Editor } from '@tiptap/core';
1
2
  import type { ResolvedStyle, StyleCheckReport, StyleChoiceGroup, StyleChoiceResult, StyleResolver, StyleSwatch } from '@pixerate/editor/tools';
2
3
  export interface UseStyleResult {
3
4
  /** The resolved house style for the domain, or `null` before the first resolve (or without a resolver). */
@@ -19,7 +20,7 @@ export declare function useStyle(styles: StyleResolver | null | undefined, domai
19
20
  * changes by reference, the domain or resolver changes, or the resolver notifies. Results of
20
21
  * older runs that settle late are ignored. Feed `report` to `<StyleFindings>`.
21
22
  */
22
- export declare function useStyleFindings(styles: StyleResolver | null | undefined, domain: string, state: unknown): UseStyleFindingsResult;
23
+ export declare function useStyleFindings(styles: StyleResolver | null | undefined, domain: string, state: unknown, scope?: string): UseStyleFindingsResult;
23
24
  export interface UseStyleChoicesResult {
24
25
  /** The one-of-a-kind groups (a look, a theme) with the chosen skill and every option, or `null` before the first read. */
25
26
  groups: StyleChoiceGroup[] | null;
@@ -51,3 +52,10 @@ export interface UseStyleSwatchesResult {
51
52
  * `get_style` returns the same list, so people and agents choose from one set.
52
53
  */
53
54
  export declare function useStyleSwatches(styles: StyleResolver | null | undefined, domain: string, scope?: string): UseStyleSwatchesResult;
55
+ /**
56
+ * The document house-style findings for a TipTap editor (`rich-text` domain), re-checked after
57
+ * every edit. Feed `report` to `<StyleFindings>`; each finding's `target` is a `{ from, to }`
58
+ * range (with `replacement` when the fix is certain). Parity with Svelte's
59
+ * `useRichTextStyleFindings`.
60
+ */
61
+ export declare function useRichTextStyleFindings(styles: StyleResolver | null | undefined, editor: Editor | null | undefined, scope?: string): UseStyleFindingsResult;
@@ -1,3 +1,4 @@
1
+ import type { Editor } from '@tiptap/core';
1
2
  import type { ResolvedStyle, StyleCheckReport, StyleChoiceGroup, StyleChoiceResult, StyleResolver, StyleSwatch } from '@pixerate/editor/tools';
2
3
  export interface UseStyleResult {
3
4
  /** The resolved house style for the domain, or `null` before the first resolve (or without a resolver). */
@@ -19,7 +20,7 @@ export declare function useStyle(styles: StyleResolver | null | undefined, domai
19
20
  * changes by reference, the domain or resolver changes, or the resolver notifies. Results of
20
21
  * older runs that settle late are ignored. Feed `report` to `<StyleFindings>`.
21
22
  */
22
- export declare function useStyleFindings(styles: StyleResolver | null | undefined, domain: string, state: unknown): UseStyleFindingsResult;
23
+ export declare function useStyleFindings(styles: StyleResolver | null | undefined, domain: string, state: unknown, scope?: string): UseStyleFindingsResult;
23
24
  export interface UseStyleChoicesResult {
24
25
  /** The one-of-a-kind groups (a look, a theme) with the chosen skill and every option, or `null` before the first read. */
25
26
  groups: StyleChoiceGroup[] | null;
@@ -51,3 +52,10 @@ export interface UseStyleSwatchesResult {
51
52
  * `get_style` returns the same list, so people and agents choose from one set.
52
53
  */
53
54
  export declare function useStyleSwatches(styles: StyleResolver | null | undefined, domain: string, scope?: string): UseStyleSwatchesResult;
55
+ /**
56
+ * The document house-style findings for a TipTap editor (`rich-text` domain), re-checked after
57
+ * every edit. Feed `report` to `<StyleFindings>`; each finding's `target` is a `{ from, to }`
58
+ * range (with `replacement` when the fix is certain). Parity with Svelte's
59
+ * `useRichTextStyleFindings`.
60
+ */
61
+ export declare function useRichTextStyleFindings(styles: StyleResolver | null | undefined, editor: Editor | null | undefined, scope?: string): UseStyleFindingsResult;
@@ -2786,10 +2786,11 @@ function VectorPerspectivePanel({ controller, className }) {
2786
2786
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: `space-y-2 ${className ?? ""}`, "data-vector-perspective-panel": "", "aria-label": "Perspective", children: [
2787
2787
  /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
2788
2788
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "w-16 text-[11px] font-medium uppercase tracking-wide text-muted-foreground", children: "Perspective" }),
2789
- [1, 2, 3].map((n) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("button", { type: "button", className: buttonClass14, "aria-pressed": grid?.vanishingPoints.length === n, "data-vector-perspective-preset": n, title: `A ${n}-point perspective grid for the page`, onClick: () => add(n), children: [
2789
+ [1, 2, 3].map((n) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("button", { type: "button", className: buttonClass14, "aria-pressed": !grid?.isometric && grid?.vanishingPoints.length === n, "data-vector-perspective-preset": n, title: `A ${n}-point perspective grid for the page`, onClick: () => add(n), children: [
2790
2790
  n,
2791
2791
  "-pt"
2792
- ] }, n))
2792
+ ] }, n)),
2793
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: buttonClass14, "aria-pressed": !!grid?.isometric, "data-vector-perspective-preset": "isometric", title: "An isometric grid for the page: parallel lines stay parallel", onClick: () => controller.setPerspective((0, import_vector17.vectorIsometricPerspectivePreset)(state.document.width, state.document.height)), children: "Iso" })
2793
2794
  ] }),
2794
2795
  grid && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
2795
2796
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "w-16" }),
@@ -2318,7 +2318,7 @@ function VectorSymmetryPanel({ controller, className }) {
2318
2318
 
2319
2319
  // src/vector/VectorPerspectivePanel.tsx
2320
2320
  import React10 from "react";
2321
- import { vectorPerspectivePlanes, vectorPerspectivePreset } from "@pixerate/editor/vector";
2321
+ import { vectorIsometricPerspectivePreset, vectorPerspectivePlanes, vectorPerspectivePreset } from "@pixerate/editor/vector";
2322
2322
  import { jsx as jsx16, jsxs as jsxs16 } from "react/jsx-runtime";
2323
2323
  var buttonClass14 = "inline-flex h-7 min-w-7 items-center justify-center rounded-md border border-border bg-background px-1.5 text-xs font-medium text-foreground hover:bg-muted disabled:cursor-not-allowed disabled:opacity-40 aria-pressed:bg-primary aria-pressed:text-primary-foreground";
2324
2324
  var selectClass11 = "h-7 min-w-0 flex-1 rounded border border-border bg-background px-1 text-xs";
@@ -2333,10 +2333,11 @@ function VectorPerspectivePanel({ controller, className }) {
2333
2333
  return /* @__PURE__ */ jsxs16("div", { className: `space-y-2 ${className ?? ""}`, "data-vector-perspective-panel": "", "aria-label": "Perspective", children: [
2334
2334
  /* @__PURE__ */ jsxs16("div", { className: "flex flex-wrap items-center gap-1", children: [
2335
2335
  /* @__PURE__ */ jsx16("span", { className: "w-16 text-[11px] font-medium uppercase tracking-wide text-muted-foreground", children: "Perspective" }),
2336
- [1, 2, 3].map((n) => /* @__PURE__ */ jsxs16("button", { type: "button", className: buttonClass14, "aria-pressed": grid?.vanishingPoints.length === n, "data-vector-perspective-preset": n, title: `A ${n}-point perspective grid for the page`, onClick: () => add(n), children: [
2336
+ [1, 2, 3].map((n) => /* @__PURE__ */ jsxs16("button", { type: "button", className: buttonClass14, "aria-pressed": !grid?.isometric && grid?.vanishingPoints.length === n, "data-vector-perspective-preset": n, title: `A ${n}-point perspective grid for the page`, onClick: () => add(n), children: [
2337
2337
  n,
2338
2338
  "-pt"
2339
- ] }, n))
2339
+ ] }, n)),
2340
+ /* @__PURE__ */ jsx16("button", { type: "button", className: buttonClass14, "aria-pressed": !!grid?.isometric, "data-vector-perspective-preset": "isometric", title: "An isometric grid for the page: parallel lines stay parallel", onClick: () => controller.setPerspective(vectorIsometricPerspectivePreset(state.document.width, state.document.height)), children: "Iso" })
2340
2341
  ] }),
2341
2342
  grid && /* @__PURE__ */ jsxs16("div", { className: "flex flex-wrap items-center gap-1", children: [
2342
2343
  /* @__PURE__ */ jsx16("span", { className: "w-16" }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-react",
3
- "version": "0.203.0",
3
+ "version": "0.205.0",
4
4
  "description": "React bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -283,7 +283,7 @@
283
283
  "dependencies": {},
284
284
  "peerDependencies": {
285
285
  "@dagrejs/dagre": "^1.1.8",
286
- "@pixerate/editor": ">=0.301.0 <1.0.0-0",
286
+ "@pixerate/editor": ">=0.312.0 <1.0.0-0",
287
287
  "@tiptap/core": "^2.27.3",
288
288
  "@tiptap/extension-bubble-menu": "^2.27.3",
289
289
  "@tiptap/extension-placeholder": "^2.27.3",
@@ -334,7 +334,7 @@
334
334
  "tsup": "^9.0.0",
335
335
  "typescript": "^5.7.3",
336
336
  "vitest": "^5.1.0",
337
- "@pixerate/editor": "0.301.0"
337
+ "@pixerate/editor": "0.312.0"
338
338
  },
339
339
  "scripts": {
340
340
  "build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",