@pixerate/editor-svelte 0.16.0 → 0.16.2

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/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # @pixerate/editor-svelte
2
+
3
+ Svelte 5 bindings for [`@pixerate/editor`](https://www.npmjs.com/package/@pixerate/editor): a rich-text editor component, bubble menu, read-only token renderer, plus spreadsheet and image editor components and rune-based node-graph canvas helpers.
4
+
5
+ ```bash
6
+ npm install @pixerate/editor-svelte @pixerate/editor svelte
7
+ # only if you use @pixerate/editor-svelte/canvas:
8
+ npm install @xyflow/svelte
9
+ ```
10
+
11
+ Requires **Svelte 5** (the components use runes). Components ship as `.svelte` sources, so they are compiled by your bundler and work with SvelteKit SSR.
12
+
13
+ ## Rich text editor
14
+
15
+ ```svelte
16
+ <script lang="ts">
17
+ import type { Editor } from "@tiptap/core";
18
+ import { EditableTextNodeEditor, BubbleMenu } from "@pixerate/editor-svelte";
19
+
20
+ let editor = $state<Editor>();
21
+ let html = $state("<p>Start editing…</p>");
22
+ </script>
23
+
24
+ <EditableTextNodeEditor
25
+ bind:editor
26
+ content={html}
27
+ placeholder="Type anything…"
28
+ onUpdate={() => (html = editor?.getHTML() ?? html)}
29
+ />
30
+
31
+ {#if editor}
32
+ <BubbleMenu {editor}><!-- your formatting buttons --></BubbleMenu>
33
+ {/if}
34
+ ```
35
+
36
+ `content` sets the initial document. Read later changes from the bound `editor` (for example in `onUpdate`), as above. The editor is preloaded with `createRichTextPreset()`. Pass `markdown`, `image`, `uploadImage`, `extensions` or `richTextOptions` to configure it.
37
+
38
+ ## Read-only token renderer
39
+
40
+ ```svelte
41
+ <script lang="ts">
42
+ import { TemplateRenderer } from "@pixerate/editor-svelte";
43
+ const templates = [{ name: "golden_hour", body: "warm 35mm volumetric lighting" }];
44
+ </script>
45
+
46
+ <TemplateRenderer content={"A photo of {subject} in {{golden_hour}}"} {templates} resolve />
47
+ ```
48
+
49
+ ## More exports
50
+
51
+ | Import | Exports |
52
+ | :--- | :--- |
53
+ | `@pixerate/editor-svelte` | `EditableTextNodeEditor`, `BubbleMenu`, `TemplateRenderer`, `initiateEditor`, `createReactiveEditor`, `createHistory`, `createHistoryShortcuts`, `navigationGuard` (action), `createNavigationGuard`, `SpreadsheetEditor`, `FormulaBar`, `createReactiveSpreadsheet`, `DirtyTracker` |
54
+ | `@pixerate/editor-svelte/image-editor` | `ImageEditor`, `createReactiveImageEditor`: crop, rotate/flip, adjustments, annotations, depth masks, and `onInpaint` / `onRemoveBackground` AI hooks |
55
+ | `@pixerate/editor-svelte/canvas` | Runes for `@xyflow/svelte`: `createCanvasGraph`, `createCanvasClipboard`, `createCanvasDocking`, `createCanvasShortcuts`, `createCanvasInteractions`, `createCanvasExplosion`, `createCanvasNodeSync`, `createCanvasMultiDrag`, `createStreamingCanvas`, `AgentPresenceLayer`, `FloatingHorizontalScrollbar`, plus layout helpers |
56
+
57
+ Prop types are exported alongside each component, for example `EditableTextNodeEditorProps`, `BubbleMenuProps`, `ImageEditorProps` and `SpreadsheetEditorProps`.
58
+
59
+ ## Styling (Tailwind CSS required)
60
+
61
+ The components are styled with [Tailwind CSS](https://tailwindcss.com) utility classes and ship no global stylesheet. To style them:
62
+
63
+ 1. **Let Tailwind scan the package**, or the classes will be purged.
64
+
65
+ Tailwind v4, in your CSS:
66
+
67
+ ```css
68
+ @source "../node_modules/@pixerate/editor-svelte/dist";
69
+ ```
70
+
71
+ Tailwind v3, in `tailwind.config.js`:
72
+
73
+ ```js
74
+ content: ["./src/**/*.{svelte,ts}", "./node_modules/@pixerate/editor-svelte/dist/**/*.{svelte,js}"],
75
+ ```
76
+
77
+ 2. **Define the theme colors.** `SpreadsheetEditor`, `FormulaBar`, `TemplateRenderer` and the editor use [shadcn-svelte](https://www.shadcn-svelte.com)-style tokens: `background`, `foreground`, `muted`, `muted-foreground`, `border`, `input`, `primary`, `popover`, `popover-foreground` and `destructive`. Projects already using shadcn-svelte have these. Otherwise, define them as colors in your Tailwind theme.
78
+
79
+ `ImageEditor` uses a fixed dark (slate) palette and only needs step 1. Component-scoped styles, such as the editor placeholder, are included automatically.
80
+
81
+ ## License
82
+
83
+ MIT
@@ -9,14 +9,14 @@
9
9
  InpaintHook,
10
10
  RemoveBackgroundHook,
11
11
  ImageEditorAIHooks,
12
- } from '@pixerate/editor';
12
+ } from '@pixerate/editor/image-editor';
13
13
  import {
14
14
  canvasToImagePoint,
15
15
  hitTestCrop,
16
16
  getCropCursor,
17
17
  calculateCropDrag,
18
18
  hitTestAnnotation,
19
- } from '@pixerate/editor';
19
+ } from '@pixerate/editor/image-editor';
20
20
  import { createReactiveImageEditor, type ReactiveImageEditor } from './imageEditorState.svelte.js';
21
21
 
22
22
  interface Props {
@@ -1,4 +1,4 @@
1
- import type { ExportOptions, InpaintHook, RemoveBackgroundHook, ImageEditorAIHooks } from '@pixerate/editor';
1
+ import type { ExportOptions, InpaintHook, RemoveBackgroundHook, ImageEditorAIHooks } from '@pixerate/editor/image-editor';
2
2
  import { type ReactiveImageEditor } from './imageEditorState.svelte.js';
3
3
  interface Props {
4
4
  editor?: ReactiveImageEditor;
@@ -1 +1 @@
1
- {"version":3,"file":"ImageEditor.svelte.d.ts","sourceRoot":"","sources":["../../src/image-editor/ImageEditor.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAIR,aAAa,EAGb,WAAW,EACX,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAQ5B,OAAO,EAA6B,KAAK,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGjG,UAAU,KAAK;IACb,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,kBAAkB,CAAC,EAAE,oBAAoB,CAAC;IAC1C,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAohCH,QAAA,MAAM,WAAW,2CAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"ImageEditor.svelte.d.ts","sourceRoot":"","sources":["../../src/image-editor/ImageEditor.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAIR,aAAa,EAGb,WAAW,EACX,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,+BAA+B,CAAC;AAQzC,OAAO,EAA6B,KAAK,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGjG,UAAU,KAAK;IACb,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,kBAAkB,CAAC,EAAE,oBAAoB,CAAC;IAC1C,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAohCH,QAAA,MAAM,WAAW,2CAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
@@ -1,4 +1,4 @@
1
- import { ImageEditorController, type ImageEditorOptions, type ImageEditorState, type ImageEditorTool, type CropBox, type AspectRatio, type ImageAdjustments, type DepthMaskOptions, type Annotation, type CreateAnnotationPayload, type ExportOptions, type SerializedImageEditorState, type ImagePoint } from '@pixerate/editor';
1
+ import { ImageEditorController, type ImageEditorOptions, type ImageEditorState, type ImageEditorTool, type CropBox, type AspectRatio, type ImageAdjustments, type DepthMaskOptions, type Annotation, type CreateAnnotationPayload, type ExportOptions, type SerializedImageEditorState, type ImagePoint } from '@pixerate/editor/image-editor';
2
2
  export declare function createReactiveImageEditor(options?: ImageEditorOptions): {
3
3
  readonly controller: ImageEditorController;
4
4
  readonly state: ImageEditorState;
@@ -1 +1 @@
1
- {"version":3,"file":"imageEditorState.svelte.d.ts","sourceRoot":"","sources":["../../src/image-editor/imageEditorState.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,0BAA0B,EAC/B,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AAE1B,wBAAgB,yBAAyB,CAAC,OAAO,GAAE,kBAAuB;;;;;kBA0BxD,eAAe;kBAGf,OAAO,GAAG,IAAI;2BAGL,WAAW;;oBAMlB,MAAM;yBAGD,MAAM;;;4BASH,OAAO,CAAC,gBAAgB,CAAC;;0BAM3B,OAAO,CAAC,gBAAgB,CAAC;;uBAM5B,uBAAuB;yBAGrB,MAAM,WAAW,OAAO,CAAC,UAAU,CAAC;yBAGpC,MAAM;;yBAMN,MAAM,GAAG,IAAI;;;;oBAYlB,MAAM;qBAGL,MAAM;;kBAMT,MAAM;gBAGR,UAAU;4BAGE,OAAO;mBAGhB,MAAM,GAAG,gBAAgB;qBAGvB,aAAa;kBAGhB,aAAa;;mBAMZ,0BAA0B;sBAGvB;QAAE,cAAc,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE;yBAG5C;QAAE,cAAc,CAAC,EAAE,OAAO,CA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AAU,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { ImageEditorController, } from '@pixerate/editor';
1
+ import { ImageEditorController, } from '@pixerate/editor/image-editor';
2
2
  export function createReactiveImageEditor(options = {}) {
3
3
  const controller = new ImageEditorController(options);
4
4
  let state = $state(controller.getState());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-svelte",
3
- "version": "0.16.0",
3
+ "version": "0.16.2",
4
4
  "description": "Svelte bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -54,7 +54,7 @@
54
54
  "@tiptap/extension-placeholder": "^2.11.5",
55
55
  "@tiptap/pm": "^2.11.5",
56
56
  "@tiptap/starter-kit": "^2.11.5",
57
- "@pixerate/editor": "0.14.2"
57
+ "@pixerate/editor": "0.15.0"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "@xyflow/svelte": "^1.6.0",