@kabel-project/kabel 1.0.7 → 1.0.9
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/dist/comment-renderer/renderer.d.ts +32 -0
- package/dist/comment-renderer/renderer.d.ts.map +1 -0
- package/dist/controllers/base.d.ts +39 -0
- package/dist/controllers/base.d.ts.map +1 -0
- package/dist/controllers/wasd.d.ts +33 -0
- package/dist/controllers/wasd.d.ts.map +1 -0
- package/dist/events/comment-drag-handle.d.ts +2 -0
- package/dist/events/comment-drag-handle.d.ts.map +1 -0
- package/dist/events/comment-input.d.ts +4 -0
- package/dist/events/comment-input.d.ts.map +1 -0
- package/dist/events/connection-line.d.ts +2 -0
- package/dist/events/connection-line.d.ts.map +1 -0
- package/dist/events/connector.d.ts +2 -0
- package/dist/events/connector.d.ts.map +1 -0
- package/dist/events/draggable.d.ts +2 -0
- package/dist/events/draggable.d.ts.map +1 -0
- package/{events/events.ts → dist/events/events.d.ts} +8 -7
- package/dist/events/events.d.ts.map +1 -0
- package/dist/events/input-box.d.ts +2 -0
- package/dist/events/input-box.d.ts.map +1 -0
- package/dist/events/node-x-btn.d.ts +2 -0
- package/dist/events/node-x-btn.d.ts.map +1 -0
- package/dist/kabel.js +2 -0
- package/dist/kabel.js.map +1 -0
- package/dist/renderers/apollo/apollo.d.ts +12 -0
- package/dist/renderers/apollo/apollo.d.ts.map +1 -0
- package/dist/renderers/apollo/constants.d.ts +21 -0
- package/dist/renderers/apollo/constants.d.ts.map +1 -0
- package/dist/renderers/apollo/renderer.d.ts +97 -0
- package/dist/renderers/apollo/renderer.d.ts.map +1 -0
- package/{renderers/atlas/atlas.ts → dist/renderers/atlas/atlas.d.ts} +6 -15
- package/dist/renderers/atlas/atlas.d.ts.map +1 -0
- package/dist/renderers/constants.d.ts +51 -0
- package/dist/renderers/constants.d.ts.map +1 -0
- package/dist/renderers/renderer.d.ts +470 -0
- package/dist/renderers/renderer.d.ts.map +1 -0
- package/dist/renderers/representer-node.d.ts +27 -0
- package/dist/renderers/representer-node.d.ts.map +1 -0
- package/dist/renderers/representer.d.ts +13 -0
- package/dist/renderers/representer.d.ts.map +1 -0
- package/dist/src/category.d.ts +48 -0
- package/dist/src/category.d.ts.map +1 -0
- package/{src/colors.ts → dist/src/colors.d.ts} +21 -20
- package/dist/src/colors.d.ts.map +1 -0
- package/dist/src/comment.d.ts +88 -0
- package/dist/src/comment.d.ts.map +1 -0
- package/dist/src/connection.d.ts +52 -0
- package/dist/src/connection.d.ts.map +1 -0
- package/dist/src/context-menu.d.ts +76 -0
- package/dist/src/context-menu.d.ts.map +1 -0
- package/dist/src/coordinates.d.ts +52 -0
- package/dist/src/coordinates.d.ts.map +1 -0
- package/dist/src/core.d.ts +153 -0
- package/dist/src/core.d.ts.map +1 -0
- package/dist/src/ctx-menu-registry.d.ts +22 -0
- package/dist/src/ctx-menu-registry.d.ts.map +1 -0
- package/dist/src/dropdown-menu.d.ts +87 -0
- package/dist/src/dropdown-menu.d.ts.map +1 -0
- package/dist/src/field.d.ts +305 -0
- package/dist/src/field.d.ts.map +1 -0
- package/dist/src/flyout.d.ts +41 -0
- package/dist/src/flyout.d.ts.map +1 -0
- package/dist/src/fonts-manager.d.ts +6 -0
- package/dist/src/fonts-manager.d.ts.map +1 -0
- package/dist/src/grid.d.ts +60 -0
- package/dist/src/grid.d.ts.map +1 -0
- package/dist/src/headless-node.d.ts +11 -0
- package/dist/src/headless-node.d.ts.map +1 -0
- package/dist/src/index.d.ts +38 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/inject-headless.d.ts +4 -0
- package/dist/src/inject-headless.d.ts.map +1 -0
- package/{src/inject.ts → dist/src/inject.d.ts} +142 -213
- package/dist/src/inject.d.ts.map +1 -0
- package/{src/main-workspace.ts → dist/src/main-workspace.d.ts} +31 -51
- package/dist/src/main-workspace.d.ts.map +1 -0
- package/dist/src/mutator.d.ts +2 -0
- package/dist/src/mutator.d.ts.map +1 -0
- package/{src/node-types.ts → dist/src/node-types.d.ts} +26 -27
- package/dist/src/node-types.d.ts.map +1 -0
- package/dist/src/nodesvg.d.ts +266 -0
- package/dist/src/nodesvg.d.ts.map +1 -0
- package/{src/prototypes.ts → dist/src/prototypes.d.ts} +10 -9
- package/dist/src/prototypes.d.ts.map +1 -0
- package/{src/renderer-map.ts → dist/src/renderer-map.d.ts} +51 -86
- package/dist/src/renderer-map.d.ts.map +1 -0
- package/dist/src/toolbox.d.ts +51 -0
- package/dist/src/toolbox.d.ts.map +1 -0
- package/{src/types.ts → dist/src/types.d.ts} +159 -205
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/undo-redo.d.ts +15 -0
- package/dist/src/undo-redo.d.ts.map +1 -0
- package/{src/visual-types.ts → dist/src/visual-types.d.ts} +34 -29
- package/dist/src/visual-types.d.ts.map +1 -0
- package/dist/src/widget-prototypes.d.ts +10 -0
- package/dist/src/widget-prototypes.d.ts.map +1 -0
- package/dist/src/widget.d.ts +62 -0
- package/dist/src/widget.d.ts.map +1 -0
- package/{src/workspace-coords.ts → dist/src/workspace-coords.d.ts} +10 -14
- package/dist/src/workspace-coords.d.ts.map +1 -0
- package/dist/src/workspace-svg.d.ts +371 -0
- package/dist/src/workspace-svg.d.ts.map +1 -0
- package/dist/src/workspace.d.ts +50 -0
- package/dist/src/workspace.d.ts.map +1 -0
- package/dist/themes/dark.d.ts +4 -0
- package/dist/themes/dark.d.ts.map +1 -0
- package/dist/themes/default.d.ts +4 -0
- package/dist/themes/default.d.ts.map +1 -0
- package/dist/themes/themes.d.ts +6 -0
- package/dist/themes/themes.d.ts.map +1 -0
- package/dist/util/emitter.d.ts +10 -0
- package/dist/util/emitter.d.ts.map +1 -0
- package/dist/util/env.d.ts +7 -0
- package/dist/util/env.d.ts.map +1 -0
- package/{util/escape-html.ts → dist/util/escape-html.d.ts} +16 -22
- package/dist/util/escape-html.d.ts.map +1 -0
- package/dist/util/eventer.d.ts +29 -0
- package/dist/util/eventer.d.ts.map +1 -0
- package/dist/util/has-prop.d.ts +2 -0
- package/dist/util/has-prop.d.ts.map +1 -0
- package/dist/util/parse-color.d.ts +6 -0
- package/dist/util/parse-color.d.ts.map +1 -0
- package/dist/util/path.d.ts +25 -0
- package/dist/util/path.d.ts.map +1 -0
- package/dist/util/styler.d.ts +12 -0
- package/dist/util/styler.d.ts.map +1 -0
- package/dist/util/uid.d.ts +42 -0
- package/dist/util/uid.d.ts.map +1 -0
- package/{util/unescape-html.ts → dist/util/unescape-html.d.ts} +16 -22
- package/dist/util/unescape-html.d.ts.map +1 -0
- package/dist/util/user-state.d.ts +37 -0
- package/dist/util/user-state.d.ts.map +1 -0
- package/{util/wait-anim-frames.ts → dist/util/wait-anim-frames.d.ts} +11 -24
- package/dist/util/wait-anim-frames.d.ts.map +1 -0
- package/dist/util/window-listeners.d.ts +8 -0
- package/dist/util/window-listeners.d.ts.map +1 -0
- package/package.json +5 -2
- package/(1.0.7)kabel.md +0 -18
- package/_READ_ME_MEDIA_/documentation/docs.md +0 -293
- package/_READ_ME_MEDIA_/workspace.png +0 -0
- package/comment-renderer/renderer.ts +0 -228
- package/controllers/base.ts +0 -186
- package/controllers/wasd.ts +0 -132
- package/docs/README.md +0 -98
- package/docs/_media/docs.md +0 -289
- package/docs/_media/workspace.png +0 -0
- package/docs/classes/CommentModel.md +0 -271
- package/docs/classes/CommentRenderer.md +0 -457
- package/docs/classes/ConnectableField.md +0 -597
- package/docs/classes/Connection.md +0 -191
- package/docs/classes/ContextMenuHTML.md +0 -163
- package/docs/classes/Coordinates.md +0 -187
- package/docs/classes/DropdownContainer.md +0 -300
- package/docs/classes/DummyField.md +0 -393
- package/docs/classes/Eventer.md +0 -185
- package/docs/classes/Field.md +0 -461
- package/docs/classes/InjectMsg.md +0 -85
- package/docs/classes/NodeSvg.md +0 -1011
- package/docs/classes/NumberField.md +0 -559
- package/docs/classes/OptConnectField.md +0 -624
- package/docs/classes/Renderer.md +0 -1636
- package/docs/classes/RendererConstants.md +0 -343
- package/docs/classes/Representer.md +0 -95
- package/docs/classes/RepresenterNode.md +0 -175
- package/docs/classes/TextField.md +0 -559
- package/docs/classes/Toolbox.md +0 -172
- package/docs/classes/WASDController.md +0 -616
- package/docs/classes/Widget.md +0 -195
- package/docs/classes/WorkspaceController.md +0 -385
- package/docs/classes/WorkspaceCoords.md +0 -218
- package/docs/classes/WorkspaceSvg.md +0 -1380
- package/docs/functions/clearMainWorkspace.md +0 -20
- package/docs/functions/getMainWorkspace.md +0 -19
- package/docs/functions/inject.md +0 -35
- package/docs/functions/setMainWorkspace.md +0 -28
- package/docs/globals.md +0 -95
- package/docs/interfaces/ColorStyle.md +0 -43
- package/docs/interfaces/ConnectorToFrom.md +0 -57
- package/docs/interfaces/DrawState.md +0 -81
- package/docs/interfaces/FieldConnectionData.md +0 -25
- package/docs/interfaces/FieldOptions.md +0 -63
- package/docs/interfaces/FieldRawBoxData.md +0 -25
- package/docs/interfaces/FieldVisualInfo.md +0 -65
- package/docs/interfaces/GridOptions.md +0 -61
- package/docs/interfaces/InjectOptions.md +0 -133
- package/docs/interfaces/InputFieldJson.md +0 -50
- package/docs/interfaces/KabelCommentRendering.md +0 -31
- package/docs/interfaces/KabelInterface.md +0 -469
- package/docs/interfaces/KabelNodeRendering.md +0 -77
- package/docs/interfaces/KabelUIX.md +0 -105
- package/docs/interfaces/KabelUtils.md +0 -215
- package/docs/interfaces/NodeEvents.md +0 -42
- package/docs/interfaces/NodeJson.md +0 -104
- package/docs/interfaces/NodePrototype.md +0 -82
- package/docs/interfaces/RegisteredEl.md +0 -53
- package/docs/interfaces/SerializedNode.md +0 -128
- package/docs/interfaces/TblxCategoryStruct.md +0 -41
- package/docs/interfaces/TblxFieldStruct.md +0 -28
- package/docs/interfaces/TblxNodeStruct.md +0 -35
- package/docs/interfaces/WidgetOptions.md +0 -115
- package/docs/interfaces/WidgetPrototypeList.md +0 -15
- package/docs/type-aliases/AnyField.md +0 -13
- package/docs/type-aliases/AnyFieldCls.md +0 -13
- package/docs/type-aliases/Color.md +0 -13
- package/docs/type-aliases/Connectable.md +0 -13
- package/docs/type-aliases/EventArgs.md +0 -11
- package/docs/type-aliases/EventSetupFn.md +0 -25
- package/docs/type-aliases/Hex.md +0 -13
- package/docs/type-aliases/RGBObject.md +0 -37
- package/docs/type-aliases/RGBString.md +0 -13
- package/docs/type-aliases/RGBTuple.md +0 -13
- package/docs/type-aliases/TblxObjStruct.md +0 -52
- package/docs/variables/CategoryColors.md +0 -29
- package/docs/variables/FieldMap.md +0 -41
- package/docs/variables/NodePrototypes.md +0 -18
- package/docs/variables/default.md +0 -11
- package/events/comment-drag-handle.ts +0 -61
- package/events/comment-input.ts +0 -291
- package/events/connection-line.ts +0 -68
- package/events/connector.ts +0 -116
- package/events/draggable.ts +0 -119
- package/events/input-box.ts +0 -213
- package/events/node-x-btn.ts +0 -25
- package/index.d.ts +0 -4
- package/renderers/apollo/apollo.ts +0 -21
- package/renderers/apollo/constants.ts +0 -40
- package/renderers/apollo/renderer.ts +0 -331
- package/renderers/constants.ts +0 -87
- package/renderers/renderer.ts +0 -1288
- package/renderers/representer-node.ts +0 -52
- package/renderers/representer.ts +0 -25
- package/src/category.ts +0 -107
- package/src/comment.ts +0 -142
- package/src/connection.ts +0 -114
- package/src/context-menu.ts +0 -194
- package/src/coordinates.ts +0 -74
- package/src/core.ts +0 -202
- package/src/ctx-menu-registry.ts +0 -143
- package/src/dropdown-menu.ts +0 -215
- package/src/field.ts +0 -595
- package/src/flyout.ts +0 -165
- package/src/fonts-manager.ts +0 -38
- package/src/grid.ts +0 -162
- package/src/headless-node.ts +0 -27
- package/src/index.ts +0 -115
- package/src/inject-headless.ts +0 -18
- package/src/mutator.ts +0 -40
- package/src/nodesvg.ts +0 -756
- package/src/styles.css +0 -224
- package/src/toolbox.ts +0 -125
- package/src/undo-redo.ts +0 -87
- package/src/widget-prototypes.ts +0 -11
- package/src/widget.ts +0 -139
- package/src/workspace-svg.ts +0 -736
- package/src/workspace.ts +0 -155
- package/test-server.js +0 -61
- package/themes/dark.ts +0 -32
- package/themes/default.ts +0 -28
- package/themes/themes.ts +0 -9
- package/tsconfig.json +0 -25
- package/typedoc.json +0 -10
- package/util/emitter.ts +0 -33
- package/util/env.ts +0 -11
- package/util/eventer.ts +0 -108
- package/util/has-prop.ts +0 -4
- package/util/parse-color.ts +0 -42
- package/util/path.ts +0 -99
- package/util/styler.ts +0 -41
- package/util/uid.ts +0 -184
- package/util/user-state.ts +0 -68
- package/util/window-listeners.ts +0 -62
- package/webpack.config.js +0 -80
- /package/{docs/_media → dist}/index.html +0 -0
package/docs/_media/docs.md
DELETED
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# Kabel Documentation
|
|
3
|
-
|
|
4
|
-
**Kabel** is a node-based visual programming editor for building interactive, logic-driven UIs in the browser. It’s built around JavaScript and uses SVG for rendering. Kabel supports node creation, custom fields, widgets, toolboxes, and smooth workspace controls.
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Table of Contents
|
|
9
|
-
|
|
10
|
-
1. Getting Started
|
|
11
|
-
2. Setting Up Your First Workspace
|
|
12
|
-
3. Creating Your First Node Prototype
|
|
13
|
-
4. Creating a Toolbox
|
|
14
|
-
5. Manipulating Nodes
|
|
15
|
-
6. Serializing & Deserializing Nodes
|
|
16
|
-
7. Finishing Up
|
|
17
|
-
|
|
18
|
-
## In-depth Docs
|
|
19
|
-
[Kabel API Documentation](../../docs/globals.md)
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## 1. Getting Started
|
|
24
|
-
|
|
25
|
-
You can include Kabel either via a script tag or import it as a module:
|
|
26
|
-
|
|
27
|
-
```html
|
|
28
|
-
<script src="./kabel.js"></script>
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
Once loaded:
|
|
32
|
-
|
|
33
|
-
```js
|
|
34
|
-
if (typeof Kabel !== 'undefined') {
|
|
35
|
-
console.log('Kabel is ready!');
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
That’s all you need to confirm it’s available before initializing a workspace.
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## 2. Setting Up Your First Workspace
|
|
44
|
-
|
|
45
|
-
The **workspace** is where nodes live and interact. Start by creating an HTML container:
|
|
46
|
-
|
|
47
|
-
```js
|
|
48
|
-
const el = document.createElement('div');
|
|
49
|
-
Object.assign(el.style, {
|
|
50
|
-
width: '100vw',
|
|
51
|
-
height: '100vh',
|
|
52
|
-
background: '#f0f0f0'
|
|
53
|
-
});
|
|
54
|
-
document.body.appendChild(el);
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Then inject Kabel into that container:
|
|
58
|
-
|
|
59
|
-
```js
|
|
60
|
-
const ws = Kabel.inject(el, {
|
|
61
|
-
moveSpeed: 6,
|
|
62
|
-
controls: {
|
|
63
|
-
wasd: true,
|
|
64
|
-
wasdSmooth: true,
|
|
65
|
-
wasdAccelerate: 1,
|
|
66
|
-
wasdFriction: 0.9
|
|
67
|
-
},
|
|
68
|
-
toolbox: { /* defined later */ }
|
|
69
|
-
});
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
This gives you a fullscreen workspace with smooth WASD movement controls.
|
|
73
|
-
|
|
74
|
-
---
|
|
75
|
-
|
|
76
|
-
## 3. Creating Your First Node Prototype
|
|
77
|
-
|
|
78
|
-
Nodes are defined once as **prototypes** under `Kabel.Nodes`. Here’s an example:
|
|
79
|
-
|
|
80
|
-
```js
|
|
81
|
-
Kabel.Nodes['my_node'] = {
|
|
82
|
-
init() {
|
|
83
|
-
this.jsonInit({
|
|
84
|
-
previousConnection: true,
|
|
85
|
-
nextConnection: true,
|
|
86
|
-
labelText: 'TopbarText',
|
|
87
|
-
type: 'my_node',
|
|
88
|
-
primaryColor: '#cc0c00',
|
|
89
|
-
tertiaryColor: '#660500',
|
|
90
|
-
arguments: [
|
|
91
|
-
{ name: 'FLD', type: 'field_str', label: 'LabelText: ', value: 'ValueText' },
|
|
92
|
-
{ name: 'Dummy', type: 'field_dummy', label: 'Label with no input!' },
|
|
93
|
-
{ name: 'Conn', type: 'connection', label: 'Label!' },
|
|
94
|
-
{ name: 'Conn2', type: 'field_both', label: 'lowk: ', value: 'lowk' },
|
|
95
|
-
{
|
|
96
|
-
name: 'Dropdown',
|
|
97
|
-
type: 'dropdown',
|
|
98
|
-
label: 'lowk dropdown?: ',
|
|
99
|
-
options: ['Oooo option', { text: 'Opt', value: 'opt' }]
|
|
100
|
-
}
|
|
101
|
-
]
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
**Key options:**
|
|
108
|
-
|
|
109
|
-
* `previousConnection` / `nextConnection` → Whether the node can chain with others.
|
|
110
|
-
* `arguments` → Defines fields, inputs, and connection points.
|
|
111
|
-
* `jsonInit()` → Initializes node configuration.
|
|
112
|
-
|
|
113
|
-
---
|
|
114
|
-
|
|
115
|
-
## 4. Creating a Toolbox
|
|
116
|
-
|
|
117
|
-
Toolboxes organize your available nodes:
|
|
118
|
-
|
|
119
|
-
```js
|
|
120
|
-
toolbox: {
|
|
121
|
-
type: 'category',
|
|
122
|
-
contents: [{
|
|
123
|
-
name: 'Cat',
|
|
124
|
-
color: '#cc0c00',
|
|
125
|
-
contents: [{
|
|
126
|
-
type: 'my_node',
|
|
127
|
-
arguments: {}
|
|
128
|
-
}]
|
|
129
|
-
}]
|
|
130
|
-
}
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
**Toolbox types:**
|
|
134
|
-
|
|
135
|
-
* `'category'` → Groups nodes visually into collapsible sections.
|
|
136
|
-
* `'flyout'` → Displays all nodes in one scrollable list.
|
|
137
|
-
|
|
138
|
-
**Category JSON fields:**
|
|
139
|
-
|
|
140
|
-
* `name`: The category name.
|
|
141
|
-
* `color`: The display color.
|
|
142
|
-
* `contents`: Array of node definitions.
|
|
143
|
-
|
|
144
|
-
> Currently, categories and flyouts can only contain nodes. Support for buttons or UI elements may be added later.
|
|
145
|
-
|
|
146
|
-
---
|
|
147
|
-
|
|
148
|
-
## 5. Manipulating Node Properties
|
|
149
|
-
|
|
150
|
-
Once a node is created, you can move, modify, or connect it programmatically:
|
|
151
|
-
|
|
152
|
-
```js
|
|
153
|
-
const node = new Kabel.NodeSvg(Kabel.Nodes['my_node'], ws);
|
|
154
|
-
node.init();
|
|
155
|
-
|
|
156
|
-
const node2 = new Kabel.NodeSvg(Kabel.Nodes['my_node'], ws);
|
|
157
|
-
node2.init();
|
|
158
|
-
node2.relativeCoords.set(20, 0);
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
Connect them:
|
|
162
|
-
|
|
163
|
-
```js
|
|
164
|
-
node.nextConnection.to = node2;
|
|
165
|
-
node2.previousConnection.from = node;
|
|
166
|
-
ws.redraw();
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
You can also manipulate the SVG directly (temporary, not saved across rerenders):
|
|
170
|
-
|
|
171
|
-
```js
|
|
172
|
-
node.svg.highlight('#ff0');
|
|
173
|
-
node.svg.setScale(1);
|
|
174
|
-
node.svg.moveTo(0, 1);
|
|
175
|
-
node.svg.applyTransform('translate(0, 1)');
|
|
176
|
-
node.svg.getRaw(); // Returns the svg.js G element
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
---
|
|
180
|
-
|
|
181
|
-
### Optional: Widgets
|
|
182
|
-
|
|
183
|
-
**Widgets** are custom UI overlays within the workspace:
|
|
184
|
-
|
|
185
|
-
```js
|
|
186
|
-
Kabel.Widgets['testWidget'] = {
|
|
187
|
-
name: 'Test Widget',
|
|
188
|
-
width: 150,
|
|
189
|
-
height: 100,
|
|
190
|
-
coords: new Kabel.Coordinates(50, 50),
|
|
191
|
-
html: '<button id="counterBtn">Count: 0</button>',
|
|
192
|
-
init(widget, container) {
|
|
193
|
-
let count = 0;
|
|
194
|
-
const btn = container.querySelector('#counterBtn');
|
|
195
|
-
if (btn) {
|
|
196
|
-
btn.addEventListener('click', () => {
|
|
197
|
-
count++;
|
|
198
|
-
btn.textContent = 'Count: ' + count;
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
const myWidget = ws.newWidget('testWidget');
|
|
205
|
-
if (myWidget) myWidget.show();
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
Widgets let you add custom interactivity or information panels.
|
|
209
|
-
|
|
210
|
-
---
|
|
211
|
-
|
|
212
|
-
## 6. Serializing Nodes
|
|
213
|
-
|
|
214
|
-
Kabel supports both **circular** and **non-circular** JSON serialization.
|
|
215
|
-
|
|
216
|
-
### Circular Serialization
|
|
217
|
-
|
|
218
|
-
Contains live object references (not exportable as plain JSON, but usable within JS).
|
|
219
|
-
|
|
220
|
-
```js
|
|
221
|
-
const circular = node.serialize();
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
Example (simplified):
|
|
225
|
-
|
|
226
|
-
```json
|
|
227
|
-
{
|
|
228
|
-
"id": "sisDG24Gp6lc7*S#m#I9c",
|
|
229
|
-
"type": "my_node",
|
|
230
|
-
"nextConnection": {
|
|
231
|
-
"node": "[CircularNodeRef]"
|
|
232
|
-
},
|
|
233
|
-
"fields": [...]
|
|
234
|
-
}
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
---
|
|
238
|
-
|
|
239
|
-
### Non-Circular Serialization
|
|
240
|
-
|
|
241
|
-
Safe for exporting or saving to files:
|
|
242
|
-
|
|
243
|
-
```js
|
|
244
|
-
const nonCircular = node.toJson();
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
Example:
|
|
248
|
-
|
|
249
|
-
```json
|
|
250
|
-
{
|
|
251
|
-
"7f7#2Rrt16uFuH^2f2^ad": {
|
|
252
|
-
"id": "7f7#2Rrt16uFuH^2f2^ad",
|
|
253
|
-
"type": "my_node",
|
|
254
|
-
"colors": { "primary": "#cc0c00", "tertiary": "#660500" },
|
|
255
|
-
"label": "TopbarText",
|
|
256
|
-
"nextConnection": { "node": "jX^$kh)yHW5p^bx98vD#s" },
|
|
257
|
-
"fields": [...]
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
---
|
|
263
|
-
|
|
264
|
-
### Workspace Serialization
|
|
265
|
-
|
|
266
|
-
```js
|
|
267
|
-
// Serialize
|
|
268
|
-
const data = workspace.toJson(false); // false = non-circular
|
|
269
|
-
|
|
270
|
-
// Deserialize
|
|
271
|
-
workspace.fromJson(data);
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
The serialization format automatically includes the circular/non-circular flag internally.
|
|
275
|
-
|
|
276
|
-
---
|
|
277
|
-
|
|
278
|
-
## 7. Finishing Up
|
|
279
|
-
|
|
280
|
-
You can expose internals for quick debugging:
|
|
281
|
-
|
|
282
|
-
```js
|
|
283
|
-
window.ws = ws;
|
|
284
|
-
window.nodes = [node, node2];
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
That’s it — you now have a working Kabel workspace with nodes, a toolbox, and serialization support.
|
|
288
|
-
|
|
289
|
-
---
|
|
Binary file
|
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
[**Kabel Project Docs v1.0.6**](../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[Kabel Project Docs](../globals.md) / CommentModel
|
|
6
|
-
|
|
7
|
-
# Class: CommentModel
|
|
8
|
-
|
|
9
|
-
Defined in: [src/comment.ts:18](https://github.com/FentFentFent/Kabel/blob/6a658c7afa967c18ecfb5cdff24af90b7d7319c3/src/comment.ts#L18)
|
|
10
|
-
|
|
11
|
-
Represents a comment attached to either a NodeSvg or a WorkspaceSvg.
|
|
12
|
-
|
|
13
|
-
## Constructors
|
|
14
|
-
|
|
15
|
-
### Constructor
|
|
16
|
-
|
|
17
|
-
> **new CommentModel**(`parent`): `CommentModel`
|
|
18
|
-
|
|
19
|
-
Defined in: [src/comment.ts:47](https://github.com/FentFentFent/Kabel/blob/6a658c7afa967c18ecfb5cdff24af90b7d7319c3/src/comment.ts#L47)
|
|
20
|
-
|
|
21
|
-
Creates a new comment attached to a node or workspace.
|
|
22
|
-
|
|
23
|
-
#### Parameters
|
|
24
|
-
|
|
25
|
-
##### parent
|
|
26
|
-
|
|
27
|
-
NodeSvg or WorkspaceSvg this comment belongs to
|
|
28
|
-
|
|
29
|
-
[`NodeSvg`](NodeSvg.md) | [`WorkspaceSvg`](WorkspaceSvg.md) | `Workspace`
|
|
30
|
-
|
|
31
|
-
#### Returns
|
|
32
|
-
|
|
33
|
-
`CommentModel`
|
|
34
|
-
|
|
35
|
-
## Properties
|
|
36
|
-
|
|
37
|
-
### \_isWorkspaceComment
|
|
38
|
-
|
|
39
|
-
> **\_isWorkspaceComment**: `boolean`
|
|
40
|
-
|
|
41
|
-
Defined in: [src/comment.ts:23](https://github.com/FentFentFent/Kabel/blob/6a658c7afa967c18ecfb5cdff24af90b7d7319c3/src/comment.ts#L23)
|
|
42
|
-
|
|
43
|
-
True if this comment belongs to the workspace instead of a node
|
|
44
|
-
|
|
45
|
-
***
|
|
46
|
-
|
|
47
|
-
### \_parent
|
|
48
|
-
|
|
49
|
-
> **\_parent**: [`NodeSvg`](NodeSvg.md) \| [`WorkspaceSvg`](WorkspaceSvg.md) \| `Workspace`
|
|
50
|
-
|
|
51
|
-
Defined in: [src/comment.ts:26](https://github.com/FentFentFent/Kabel/blob/6a658c7afa967c18ecfb5cdff24af90b7d7319c3/src/comment.ts#L26)
|
|
52
|
-
|
|
53
|
-
Parent NodeSvg or WorkspaceSvg to which this comment belongs
|
|
54
|
-
|
|
55
|
-
***
|
|
56
|
-
|
|
57
|
-
### \_tempInputBBox?
|
|
58
|
-
|
|
59
|
-
> `optional` **\_tempInputBBox**: `object`
|
|
60
|
-
|
|
61
|
-
Defined in: [src/comment.ts:38](https://github.com/FentFentFent/Kabel/blob/6a658c7afa967c18ecfb5cdff24af90b7d7319c3/src/comment.ts#L38)
|
|
62
|
-
|
|
63
|
-
Temporary bounding box info for input handling
|
|
64
|
-
|
|
65
|
-
#### height
|
|
66
|
-
|
|
67
|
-
> **height**: `number`
|
|
68
|
-
|
|
69
|
-
#### textX
|
|
70
|
-
|
|
71
|
-
> **textX**: `number`
|
|
72
|
-
|
|
73
|
-
#### textY
|
|
74
|
-
|
|
75
|
-
> **textY**: `number`
|
|
76
|
-
|
|
77
|
-
#### width
|
|
78
|
-
|
|
79
|
-
> **width**: `number`
|
|
80
|
-
|
|
81
|
-
***
|
|
82
|
-
|
|
83
|
-
### \_text
|
|
84
|
-
|
|
85
|
-
> **\_text**: `string`
|
|
86
|
-
|
|
87
|
-
Defined in: [src/comment.ts:20](https://github.com/FentFentFent/Kabel/blob/6a658c7afa967c18ecfb5cdff24af90b7d7319c3/src/comment.ts#L20)
|
|
88
|
-
|
|
89
|
-
The comment text
|
|
90
|
-
|
|
91
|
-
***
|
|
92
|
-
|
|
93
|
-
### id
|
|
94
|
-
|
|
95
|
-
> **id**: `string`
|
|
96
|
-
|
|
97
|
-
Defined in: [src/comment.ts:41](https://github.com/FentFentFent/Kabel/blob/6a658c7afa967c18ecfb5cdff24af90b7d7319c3/src/comment.ts#L41)
|
|
98
|
-
|
|
99
|
-
Unique identifier for this comment
|
|
100
|
-
|
|
101
|
-
***
|
|
102
|
-
|
|
103
|
-
### relativeCoords
|
|
104
|
-
|
|
105
|
-
> **relativeCoords**: [`Coordinates`](Coordinates.md)
|
|
106
|
-
|
|
107
|
-
Defined in: [src/comment.ts:32](https://github.com/FentFentFent/Kabel/blob/6a658c7afa967c18ecfb5cdff24af90b7d7319c3/src/comment.ts#L32)
|
|
108
|
-
|
|
109
|
-
Coordinates relative to parent
|
|
110
|
-
|
|
111
|
-
***
|
|
112
|
-
|
|
113
|
-
### svgGroup?
|
|
114
|
-
|
|
115
|
-
> `optional` **svgGroup**: `G`
|
|
116
|
-
|
|
117
|
-
Defined in: [src/comment.ts:29](https://github.com/FentFentFent/Kabel/blob/6a658c7afa967c18ecfb5cdff24af90b7d7319c3/src/comment.ts#L29)
|
|
118
|
-
|
|
119
|
-
SVG group representing this comment in the DOM
|
|
120
|
-
|
|
121
|
-
***
|
|
122
|
-
|
|
123
|
-
### svgLine?
|
|
124
|
-
|
|
125
|
-
> `optional` **svgLine**: `Line`
|
|
126
|
-
|
|
127
|
-
Defined in: [src/comment.ts:35](https://github.com/FentFentFent/Kabel/blob/6a658c7afa967c18ecfb5cdff24af90b7d7319c3/src/comment.ts#L35)
|
|
128
|
-
|
|
129
|
-
Optional SVG line connecting the comment to its node
|
|
130
|
-
|
|
131
|
-
## Methods
|
|
132
|
-
|
|
133
|
-
### getText()
|
|
134
|
-
|
|
135
|
-
> **getText**(): `string`
|
|
136
|
-
|
|
137
|
-
Defined in: [src/comment.ts:70](https://github.com/FentFentFent/Kabel/blob/6a658c7afa967c18ecfb5cdff24af90b7d7319c3/src/comment.ts#L70)
|
|
138
|
-
|
|
139
|
-
Retrieves the current text of the comment.
|
|
140
|
-
|
|
141
|
-
#### Returns
|
|
142
|
-
|
|
143
|
-
`string`
|
|
144
|
-
|
|
145
|
-
The comment text
|
|
146
|
-
|
|
147
|
-
***
|
|
148
|
-
|
|
149
|
-
### getWorkspace()
|
|
150
|
-
|
|
151
|
-
> **getWorkspace**(): [`WorkspaceSvg`](WorkspaceSvg.md)
|
|
152
|
-
|
|
153
|
-
Defined in: [src/comment.ts:104](https://github.com/FentFentFent/Kabel/blob/6a658c7afa967c18ecfb5cdff24af90b7d7319c3/src/comment.ts#L104)
|
|
154
|
-
|
|
155
|
-
Gets the workspace that owns this comment.
|
|
156
|
-
|
|
157
|
-
#### Returns
|
|
158
|
-
|
|
159
|
-
[`WorkspaceSvg`](WorkspaceSvg.md)
|
|
160
|
-
|
|
161
|
-
***
|
|
162
|
-
|
|
163
|
-
### isNodeComment()
|
|
164
|
-
|
|
165
|
-
> **isNodeComment**(): `boolean`
|
|
166
|
-
|
|
167
|
-
Defined in: [src/comment.ts:90](https://github.com/FentFentFent/Kabel/blob/6a658c7afa967c18ecfb5cdff24af90b7d7319c3/src/comment.ts#L90)
|
|
168
|
-
|
|
169
|
-
Returns true if this comment is attached to a node.
|
|
170
|
-
|
|
171
|
-
#### Returns
|
|
172
|
-
|
|
173
|
-
`boolean`
|
|
174
|
-
|
|
175
|
-
***
|
|
176
|
-
|
|
177
|
-
### isWorkspaceComment()
|
|
178
|
-
|
|
179
|
-
> **isWorkspaceComment**(): `boolean`
|
|
180
|
-
|
|
181
|
-
Defined in: [src/comment.ts:97](https://github.com/FentFentFent/Kabel/blob/6a658c7afa967c18ecfb5cdff24af90b7d7319c3/src/comment.ts#L97)
|
|
182
|
-
|
|
183
|
-
Returns true if this comment is attached to the workspace.
|
|
184
|
-
|
|
185
|
-
#### Returns
|
|
186
|
-
|
|
187
|
-
`boolean`
|
|
188
|
-
|
|
189
|
-
***
|
|
190
|
-
|
|
191
|
-
### setText()
|
|
192
|
-
|
|
193
|
-
> **setText**(`value`): `string`
|
|
194
|
-
|
|
195
|
-
Defined in: [src/comment.ts:79](https://github.com/FentFentFent/Kabel/blob/6a658c7afa967c18ecfb5cdff24af90b7d7319c3/src/comment.ts#L79)
|
|
196
|
-
|
|
197
|
-
Sets the text of the comment and triggers a redraw of all comments in the workspace.
|
|
198
|
-
|
|
199
|
-
#### Parameters
|
|
200
|
-
|
|
201
|
-
##### value
|
|
202
|
-
|
|
203
|
-
`string`
|
|
204
|
-
|
|
205
|
-
New text content
|
|
206
|
-
|
|
207
|
-
#### Returns
|
|
208
|
-
|
|
209
|
-
`string`
|
|
210
|
-
|
|
211
|
-
The updated text
|
|
212
|
-
|
|
213
|
-
***
|
|
214
|
-
|
|
215
|
-
### setTextNoRedraw()
|
|
216
|
-
|
|
217
|
-
> **setTextNoRedraw**(`value`): `string`
|
|
218
|
-
|
|
219
|
-
Defined in: [src/comment.ts:62](https://github.com/FentFentFent/Kabel/blob/6a658c7afa967c18ecfb5cdff24af90b7d7319c3/src/comment.ts#L62)
|
|
220
|
-
|
|
221
|
-
Sets the text of the comment without triggering a comment redraw.
|
|
222
|
-
|
|
223
|
-
#### Parameters
|
|
224
|
-
|
|
225
|
-
##### value
|
|
226
|
-
|
|
227
|
-
`string`
|
|
228
|
-
|
|
229
|
-
New text content
|
|
230
|
-
|
|
231
|
-
#### Returns
|
|
232
|
-
|
|
233
|
-
`string`
|
|
234
|
-
|
|
235
|
-
The updated text
|
|
236
|
-
|
|
237
|
-
***
|
|
238
|
-
|
|
239
|
-
### toJson()
|
|
240
|
-
|
|
241
|
-
> **toJson**(): `CommentSerialized`
|
|
242
|
-
|
|
243
|
-
Defined in: [src/comment.ts:114](https://github.com/FentFentFent/Kabel/blob/6a658c7afa967c18ecfb5cdff24af90b7d7319c3/src/comment.ts#L114)
|
|
244
|
-
|
|
245
|
-
Convert to JSON structure holding all important data.
|
|
246
|
-
|
|
247
|
-
#### Returns
|
|
248
|
-
|
|
249
|
-
`CommentSerialized`
|
|
250
|
-
|
|
251
|
-
***
|
|
252
|
-
|
|
253
|
-
### fromJson()
|
|
254
|
-
|
|
255
|
-
> `static` **fromJson**(`data`): `CommentModel`
|
|
256
|
-
|
|
257
|
-
Defined in: [src/comment.ts:129](https://github.com/FentFentFent/Kabel/blob/6a658c7afa967c18ecfb5cdff24af90b7d7319c3/src/comment.ts#L129)
|
|
258
|
-
|
|
259
|
-
Creates a CommentModel from serialized data.
|
|
260
|
-
|
|
261
|
-
#### Parameters
|
|
262
|
-
|
|
263
|
-
##### data
|
|
264
|
-
|
|
265
|
-
`CommentSerialized`
|
|
266
|
-
|
|
267
|
-
The serialized comment
|
|
268
|
-
|
|
269
|
-
#### Returns
|
|
270
|
-
|
|
271
|
-
`CommentModel`
|