@elicdavis/node-flow 0.1.11 → 0.1.12
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 +10 -0
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -0
- package/dist/index.mjs.map +1 -1
- package/dist/web/NodeFlow.js +8 -0
- package/dist/web/NodeFlow.js.map +7 -0
- package/package.json +1 -1
- package/src/graph.ts +12 -0
- package/src/index.ts +11 -2
- package/src/notes/subsystem.ts +17 -0
- package/src/utils/string.ts +3 -3
package/package.json
CHANGED
package/src/graph.ts
CHANGED
|
@@ -404,6 +404,18 @@ export class NodeFlowGraph {
|
|
|
404
404
|
this.#mainNoteSubsystem.addNote(note);
|
|
405
405
|
}
|
|
406
406
|
|
|
407
|
+
removeNote(note: FlowNote): void {
|
|
408
|
+
this.#mainNoteSubsystem.removeNote(note);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
removeAllNotes(): void {
|
|
412
|
+
this.#mainNoteSubsystem.removeAllNotes();
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
getNotes(): Array<FlowNote> {
|
|
416
|
+
return this.#mainNoteSubsystem.getNotes();
|
|
417
|
+
}
|
|
418
|
+
|
|
407
419
|
public addOnNodeCreatedListener(callback: NodeCreatedCallback): void {
|
|
408
420
|
this.#mainNodeSubsystem.addOnNodeCreatedListener(callback);
|
|
409
421
|
}
|
package/src/index.ts
CHANGED
|
@@ -7,8 +7,17 @@ export { Theme };
|
|
|
7
7
|
import { Publisher, PublisherConfig } from './nodes/publisher';
|
|
8
8
|
export { Publisher, PublisherConfig };
|
|
9
9
|
|
|
10
|
-
import { FlowNote } from './notes/note';
|
|
11
|
-
export { FlowNote };
|
|
10
|
+
import { FlowNote, FlowNoteConfig, NoteContentChangeCallback, NoteWidthChangeCallback } from './notes/note';
|
|
11
|
+
export { FlowNote, FlowNoteConfig, NoteContentChangeCallback, NoteWidthChangeCallback };
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
NoteAddedCallback, NoteDragStartCallback, NoteDragStopCallback,
|
|
15
|
+
NoteRemovedCallback, NoteSubsystemConfig
|
|
16
|
+
} from './notes/subsystem';
|
|
17
|
+
export {
|
|
18
|
+
NoteAddedCallback, NoteDragStartCallback, NoteDragStopCallback,
|
|
19
|
+
NoteRemovedCallback, NoteSubsystemConfig
|
|
20
|
+
};
|
|
12
21
|
|
|
13
22
|
// Widgets
|
|
14
23
|
import { NumberWidget } from './widgets/number';
|
package/src/notes/subsystem.ts
CHANGED
|
@@ -86,6 +86,10 @@ export class NoteSubsystem {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
getNotes(): Array<FlowNote> {
|
|
90
|
+
return this.#notes;
|
|
91
|
+
}
|
|
92
|
+
|
|
89
93
|
public addNoteAddedListener(callback: NoteAddedCallback): void {
|
|
90
94
|
if (callback === null || callback === undefined) {
|
|
91
95
|
return;
|
|
@@ -227,6 +231,19 @@ export class NoteSubsystem {
|
|
|
227
231
|
}
|
|
228
232
|
}
|
|
229
233
|
|
|
234
|
+
removeAllNotes(): void {
|
|
235
|
+
const notes = this.#notes;
|
|
236
|
+
this.#notes = [];
|
|
237
|
+
this.#noteHovering = null;
|
|
238
|
+
this.#noteSelected = null;
|
|
239
|
+
|
|
240
|
+
for (let i = 0; i < notes.length; i++) {
|
|
241
|
+
for (let j = 0; j < this.#onNoteRemovedCallbacks.length; j++) {
|
|
242
|
+
this.#onNoteRemovedCallbacks[j](notes[i]);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
230
247
|
render(ctx: CanvasRenderingContext2D, camera: Camera, mousePosition: Vector2 | undefined): RenderResults | undefined {
|
|
231
248
|
this.#noteHovering = null;
|
|
232
249
|
this.#hoveringHandle = DragHandle.None;
|
package/src/utils/string.ts
CHANGED
|
@@ -23,7 +23,7 @@ export function fitString(ctx: CanvasRenderingContext2D, str: string, maxWidth:
|
|
|
23
23
|
|
|
24
24
|
const index = binarySearch({
|
|
25
25
|
max: str.length,
|
|
26
|
-
getValue: guess => ctx.measureText(str.substring(0, guess)).width,
|
|
26
|
+
getValue: (guess: number) => ctx.measureText(str.substring(0, guess)).width,
|
|
27
27
|
match: maxWidth - ellipsisWidth,
|
|
28
28
|
});
|
|
29
29
|
|
|
@@ -38,7 +38,7 @@ export function splitString(ctx: CanvasRenderingContext2D, str: string, maxWidth
|
|
|
38
38
|
|
|
39
39
|
let index = binarySearch({
|
|
40
40
|
max: str.length,
|
|
41
|
-
getValue: guess => ctx.measureText(str.substring(0, guess)).width,
|
|
41
|
+
getValue: (guess: number) => ctx.measureText(str.substring(0, guess)).width,
|
|
42
42
|
match: maxWidth,
|
|
43
43
|
});
|
|
44
44
|
|
|
@@ -64,7 +64,7 @@ export function splitStringIntoLines(ctx: CanvasRenderingContext2D, str: string,
|
|
|
64
64
|
while (remaining !== "") {
|
|
65
65
|
let index = binarySearch({
|
|
66
66
|
max: remaining.length,
|
|
67
|
-
getValue: guess => ctx.measureText(remaining.substring(0, guess)).width,
|
|
67
|
+
getValue: (guess: number) => ctx.measureText(remaining.substring(0, guess)).width,
|
|
68
68
|
match: maxWidth,
|
|
69
69
|
});
|
|
70
70
|
|