@mocanvas/editor 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Symbio Digital
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # @mocanvas/editor
2
+
3
+ The editor core of [mocanvas](https://github.com/SYMBIO/mocanvas), without the
4
+ default shapes, tools and UI: the `Editor` facade, `ShapeUtil` and
5
+ `BindingUtil`, the `StateNode` tool state machine, geometry, snapping, history,
6
+ textures, and the `<Canvas />` React renderer with its WebGL2 backend.
7
+
8
+ Use this package when you want to build your own shape set and UI. If you want
9
+ a canvas that works out of the box, use `mocanvas`.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @mocanvas/editor react react-dom
15
+ ```
16
+
17
+ `react` and `react-dom` (>= 18) are peer dependencies.
18
+
19
+ ## Use
20
+
21
+ ```tsx
22
+ import { Canvas, Editor, createStore, loadEngine } from "@mocanvas/editor"
23
+ import { useEffect, useRef, useState } from "react"
24
+
25
+ export function MyCanvas() {
26
+ const container = useRef<HTMLDivElement>(null)
27
+ const [editor, setEditor] = useState<Editor | null>(null)
28
+
29
+ useEffect(() => {
30
+ let disposed = false
31
+ loadEngine().then((engine) => {
32
+ if (disposed) return engine.dispose()
33
+ setEditor(
34
+ new Editor({
35
+ store: createStore(),
36
+ shapeUtils: [], // your ShapeUtils
37
+ tools: [], // your StateNodes
38
+ engine,
39
+ getContainer: () => container.current!,
40
+ }),
41
+ )
42
+ })
43
+ return () => {
44
+ disposed = true
45
+ }
46
+ }, [])
47
+
48
+ return (
49
+ <div ref={container} style={{ position: "absolute", inset: 0 }}>
50
+ {editor && <Canvas editor={editor} />}
51
+ </div>
52
+ )
53
+ }
54
+ ```
55
+
56
+ Writing a shape util and its tool is covered in
57
+ [docs/CUSTOM_SHAPES.md](https://github.com/SYMBIO/mocanvas/blob/main/docs/CUSTOM_SHAPES.md).
58
+
59
+ ESM only. The WebAssembly engine is loaded from `@mocanvas/wasm`; see that
60
+ package's README for how the `.wasm` file is resolved by your bundler.
61
+
62
+ ## License
63
+
64
+ MIT