@pixerate/editor-svelte 0.16.0 → 0.16.1
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 +83 -0
- package/package.json +2 -2
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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor-svelte",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.1",
|
|
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.
|
|
57
|
+
"@pixerate/editor": "0.14.3"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@xyflow/svelte": "^1.6.0",
|