@pixerate/editor-svelte 0.76.2 → 0.77.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.
Files changed (38) hide show
  1. package/README.md +1 -0
  2. package/dist/paint-editor/BrushPanel.svelte +96 -0
  3. package/dist/paint-editor/BrushPanel.svelte.d.ts +11 -0
  4. package/dist/paint-editor/BrushPanel.svelte.d.ts.map +1 -0
  5. package/dist/paint-editor/ColorPanel.svelte +175 -0
  6. package/dist/paint-editor/ColorPanel.svelte.d.ts +13 -0
  7. package/dist/paint-editor/ColorPanel.svelte.d.ts.map +1 -0
  8. package/dist/paint-editor/PaintCanvas.svelte +163 -0
  9. package/dist/paint-editor/PaintCanvas.svelte.d.ts +17 -0
  10. package/dist/paint-editor/PaintCanvas.svelte.d.ts.map +1 -0
  11. package/dist/paint-editor/PaintEditor.svelte +45 -0
  12. package/dist/paint-editor/PaintEditor.svelte.d.ts +13 -0
  13. package/dist/paint-editor/PaintEditor.svelte.d.ts.map +1 -0
  14. package/dist/paint-editor/PaintLayersPanel.svelte +108 -0
  15. package/dist/paint-editor/PaintLayersPanel.svelte.d.ts +9 -0
  16. package/dist/paint-editor/PaintLayersPanel.svelte.d.ts.map +1 -0
  17. package/dist/paint-editor/PaintSlider.svelte +41 -0
  18. package/dist/paint-editor/PaintSlider.svelte.d.ts +13 -0
  19. package/dist/paint-editor/PaintSlider.svelte.d.ts.map +1 -0
  20. package/dist/paint-editor/PaintToolbar.svelte +132 -0
  21. package/dist/paint-editor/PaintToolbar.svelte.d.ts +13 -0
  22. package/dist/paint-editor/PaintToolbar.svelte.d.ts.map +1 -0
  23. package/dist/paint-editor/PaperPanel.svelte +54 -0
  24. package/dist/paint-editor/PaperPanel.svelte.d.ts +9 -0
  25. package/dist/paint-editor/PaperPanel.svelte.d.ts.map +1 -0
  26. package/dist/paint-editor/PixelCanvas.svelte +22 -0
  27. package/dist/paint-editor/PixelCanvas.svelte.d.ts +14 -0
  28. package/dist/paint-editor/PixelCanvas.svelte.d.ts.map +1 -0
  29. package/dist/paint-editor/ReferencePanel.svelte +51 -0
  30. package/dist/paint-editor/ReferencePanel.svelte.d.ts +9 -0
  31. package/dist/paint-editor/ReferencePanel.svelte.d.ts.map +1 -0
  32. package/dist/paint-editor/index.d.ts +25 -0
  33. package/dist/paint-editor/index.d.ts.map +1 -0
  34. package/dist/paint-editor/index.js +9 -0
  35. package/dist/paint-editor/paintEditorRune.svelte.d.ts +20 -0
  36. package/dist/paint-editor/paintEditorRune.svelte.d.ts.map +1 -0
  37. package/dist/paint-editor/paintEditorRune.svelte.js +61 -0
  38. package/package.json +10 -2
@@ -0,0 +1,61 @@
1
+ import { untrack } from 'svelte';
2
+ import { PaintEditorController } from '@pixerate/editor/paint-editor';
3
+ /**
4
+ * A `PaintEditorController` (created from `options`, or the one given) with its state as a
5
+ * rune: `editor.state` updates after every change. Call `destroy()` to unsubscribe.
6
+ */
7
+ export function createReactivePaintEditor(options = {}) {
8
+ const controller = options instanceof PaintEditorController ? options : new PaintEditorController(options);
9
+ let snapshot = $state.raw(controller.getState());
10
+ const unsubscribe = controller.subscribe(() => {
11
+ snapshot = controller.getState();
12
+ });
13
+ return {
14
+ get controller() {
15
+ return controller;
16
+ },
17
+ get state() {
18
+ return snapshot;
19
+ },
20
+ destroy() {
21
+ unsubscribe();
22
+ },
23
+ };
24
+ }
25
+ /** The controller's state as a rune, for components (subscribe in an effect, see GOTCHAS). */
26
+ export function paintEditorState(controller) {
27
+ let snapshot = $state.raw(controller().getState());
28
+ $effect(() => {
29
+ const c = controller();
30
+ // Untracked, so the effect never depends on the state its listener writes (see GOTCHAS).
31
+ return untrack(() => {
32
+ snapshot = c.getState();
33
+ const off = c.subscribe(() => {
34
+ snapshot = c.getState();
35
+ });
36
+ return () => {
37
+ off();
38
+ };
39
+ });
40
+ });
41
+ return {
42
+ get current() {
43
+ return snapshot;
44
+ },
45
+ };
46
+ }
47
+ export const chip = (on) => `px-2 py-1 rounded text-[11px] ${on ? 'bg-indigo-600 text-white' : 'bg-slate-800 text-slate-300 hover:text-white'}`;
48
+ export const button = 'px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700 disabled:opacity-40';
49
+ export const panel = 'flex flex-col gap-2 text-xs text-slate-200';
50
+ /** Runs `fn` and returns the error message it threw (or a rejected promise's, through `onAsync`). */
51
+ export function attempt(fn, onError) {
52
+ try {
53
+ onError(null);
54
+ const r = fn();
55
+ if (r && typeof r.catch === 'function')
56
+ r.catch((e) => onError(e instanceof Error ? e.message : String(e)));
57
+ }
58
+ catch (e) {
59
+ onError(e instanceof Error ? e.message : String(e));
60
+ }
61
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-svelte",
3
- "version": "0.76.2",
3
+ "version": "0.77.0",
4
4
  "description": "Svelte bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -33,6 +33,11 @@
33
33
  "svelte": "./dist/image-editor/index.js",
34
34
  "default": "./dist/image-editor/index.js"
35
35
  },
36
+ "./paint-editor": {
37
+ "types": "./dist/paint-editor/index.d.ts",
38
+ "svelte": "./dist/paint-editor/index.js",
39
+ "default": "./dist/paint-editor/index.js"
40
+ },
36
41
  "./commands": {
37
42
  "types": "./dist/commands/index.d.ts",
38
43
  "svelte": "./dist/commands/index.js",
@@ -91,6 +96,9 @@
91
96
  "image-editor": [
92
97
  "./dist/image-editor/index.d.ts"
93
98
  ],
99
+ "paint-editor": [
100
+ "./dist/paint-editor/index.d.ts"
101
+ ],
94
102
  "commands": [
95
103
  "./dist/commands/index.d.ts"
96
104
  ],
@@ -131,7 +139,7 @@
131
139
  "@tiptap/extension-bubble-menu": "^2.11.5",
132
140
  "@tiptap/extension-placeholder": "^2.11.5",
133
141
  "@tiptap/starter-kit": "^2.11.5",
134
- "@pixerate/editor": "0.103.0"
142
+ "@pixerate/editor": "0.105.0"
135
143
  },
136
144
  "peerDependencies": {
137
145
  "@dagrejs/dagre": "^1.1.4",