@aglyn/besigner 1.0.0-beta.143 → 1.0.0-beta.144
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 +97 -4
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,7 +1,100 @@
|
|
|
1
|
-
# besigner
|
|
1
|
+
# @aglyn/besigner
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The logic of Besigner, Aglyn's visual editor, with no UI in it: editor app and
|
|
4
|
+
interface state, selection and hover, drag-and-drop rules, the element and
|
|
5
|
+
style clipboards, and node moves. Install it if you are building your own
|
|
6
|
+
editor UI over Aglyn's node model. If you want the editor as it ships, take
|
|
7
|
+
`@aglyn/besigner-ui`, which is built on this package.
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
> Beta. Published from the Aglyn monorepo under the `beta` dist-tag; APIs can change between beta releases.
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
npm install @aglyn/besigner@beta
|
|
14
|
+
|
|
15
|
+
Peer dependencies:
|
|
16
|
+
|
|
17
|
+
- `react` (used for ref types only; the package renders nothing)
|
|
18
|
+
|
|
19
|
+
This is the "logic only" consumer story: `@aglyn/besigner` together with
|
|
20
|
+
`@aglyn/aglyn` installs with `react` as the only peer. It needs no `next`, no
|
|
21
|
+
Firebase SDK, no MUI and no `@aglyn/besigner-ui`. The framework peers of
|
|
22
|
+
`@aglyn/aglyn` are all optional.
|
|
23
|
+
|
|
24
|
+
## What's in it
|
|
25
|
+
|
|
26
|
+
Editor app and interface state:
|
|
27
|
+
|
|
28
|
+
- `initializeBesignerApp`, `getBesignerApp`, `doesBesignerAppExist` and
|
|
29
|
+
`deleteBesignerApp` manage named editor app instances
|
|
30
|
+
(`BesignerAppController`). With no name, the default app is used.
|
|
31
|
+
- `BesignerInterfaceController` holds the editor's flags and panel state.
|
|
32
|
+
`setBesignerFlag`, `setBesignerFlags`, `setBesignerPanel` and
|
|
33
|
+
`setBesignerPanels` update it for a given app.
|
|
34
|
+
- Constants and types for that state: `InteractionModeFlag`,
|
|
35
|
+
`BesignerDeviceFlag`, `BesignerPanelViewFlag`, `BesignerPanelTabFlag`,
|
|
36
|
+
`BesignerContext` and the flag and panel key types.
|
|
37
|
+
|
|
38
|
+
Managers, which act on the canvas of `@aglyn/aglyn`:
|
|
39
|
+
|
|
40
|
+
- `focus` is the selection, hover and tree-expansion state: `setSelectedNode`,
|
|
41
|
+
`getSelected`, `rangeSelectNode`, `clearSelection`, `setHoveredNode`,
|
|
42
|
+
`expandNode`, `collapseNode` and others.
|
|
43
|
+
- `dnd` is a `DndManager` instance tracking the current drag, drop target and
|
|
44
|
+
drop region. Beside it are `confirmValidLinealRelationship`, which checks
|
|
45
|
+
whether an item may sit under a given parent (the lineal rules),
|
|
46
|
+
and the drop-region geometry helpers such as `determineDropRegion`.
|
|
47
|
+
- `clipboard` copies and pastes elements (`copyNodes`, `pasteInto`,
|
|
48
|
+
`hasContent`, `clear`), and `styleClipboard` does the same for styles. The
|
|
49
|
+
clipboard mirrors itself into `localStorage`.
|
|
50
|
+
- `moveNodeIn`, `moveNodeOut`, `canMoveNodeIn`, `canMoveNodeOut`,
|
|
51
|
+
`resolveMoveIn` and `resolveMoveOut` move a node one level into or out of
|
|
52
|
+
its neighbors.
|
|
53
|
+
- `pick` is the "pick an element on the canvas" mode: `startPick`,
|
|
54
|
+
`cancelPick`, `isPicking`, `handlePickClick`.
|
|
55
|
+
- `refs` maps node ids to their rendered DOM refs, for a UI to fill.
|
|
56
|
+
- `isTextEntryElement` and `isTextEntryFocused` tell a shortcut handler when
|
|
57
|
+
the user is typing.
|
|
58
|
+
- `devicePreviewWidth` and `isRootElementId` are small helpers.
|
|
59
|
+
|
|
60
|
+
Every file under `src/lib` is also reachable by subpath, for example
|
|
61
|
+
`@aglyn/besigner/focus-manager/focus-manager`.
|
|
62
|
+
|
|
63
|
+
## Usage
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { canvas } from '@aglyn/aglyn'
|
|
67
|
+
import {
|
|
68
|
+
canMoveNodeOut,
|
|
69
|
+
clipboard,
|
|
70
|
+
focus,
|
|
71
|
+
initializeBesignerApp,
|
|
72
|
+
moveNodeOut,
|
|
73
|
+
} from '@aglyn/besigner'
|
|
74
|
+
|
|
75
|
+
const app = initializeBesignerApp()
|
|
76
|
+
|
|
77
|
+
// `nodes` is a NodesMap loaded from a stored screen version
|
|
78
|
+
canvas.setNodes(nodes)
|
|
79
|
+
|
|
80
|
+
const [first] = canvas.rootNode.children
|
|
81
|
+
focus.setSelectedNode(first)
|
|
82
|
+
|
|
83
|
+
clipboard.copyNodes(focus.getSelected())
|
|
84
|
+
const pasted = clipboard.pasteInto(canvas.rootNode)
|
|
85
|
+
if (pasted.error) console.warn(pasted.error)
|
|
86
|
+
|
|
87
|
+
if (canMoveNodeOut(first)) moveNodeOut(first)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## How it fits
|
|
91
|
+
|
|
92
|
+
This is the `besigner` scope of the package map: the designer's logic,
|
|
93
|
+
publishable without its UI. It imports the core (`@aglyn/aglyn`) and the
|
|
94
|
+
generic `@aglyn/shared-*` packages only. It never imports the designer UI, the
|
|
95
|
+
renderer or a plugin. `@aglyn/besigner-ui` is the React surface over it, and a
|
|
96
|
+
plugin may import it too.
|
|
97
|
+
|
|
98
|
+
## License
|
|
99
|
+
|
|
100
|
+
Apache-2.0. Source: https://github.com/aglyn/aglyn/tree/main/libs/besigner/core
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/besigner",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.144",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.0.0-beta.
|
|
29
|
-
"@aglyn/shared-data-types": "1.0.0-beta.
|
|
30
|
-
"@aglyn/shared-util-logger": "1.0.0-beta.
|
|
31
|
-
"@aglyn/shared-util-tools": "1.0.0-beta.
|
|
32
|
-
"@aglyn/shared-util-vendor": "1.0.0-beta.
|
|
28
|
+
"@aglyn/aglyn": "1.0.0-beta.144",
|
|
29
|
+
"@aglyn/shared-data-types": "1.0.0-beta.144",
|
|
30
|
+
"@aglyn/shared-util-logger": "1.0.0-beta.144",
|
|
31
|
+
"@aglyn/shared-util-tools": "1.0.0-beta.144",
|
|
32
|
+
"@aglyn/shared-util-vendor": "1.0.0-beta.144",
|
|
33
33
|
"@swc/helpers": "0.5.23",
|
|
34
34
|
"lodash-es": "^4.18.1",
|
|
35
35
|
"mobx": "^6.16.1",
|