@selenite/graph-editor
Version:
A graph editor for visual programming, based on rete and svelte.
55 lines (54 loc) • 2.22 kB
TypeScript
import { type Setup } from '../setup/Setup';
import { NodeFactory } from '../editor';
import { Node } from '../nodes';
import type { Position } from '../common';
import '../nodes';
import type { Control, Socket } from '../socket';
import { type XmlConfig } from '../nodes/XML';
import { XmlSchema, type ShowContextMenu, type MenuItem } from '@selenite/commons';
export type NodeMenuItem<NC extends typeof Node = typeof Node> = {
/** Label of the node. */
label: string;
/** Function that creates the node. */
nodeClass: NC;
params: ConstructorParameters<NC>[0];
/** Menu path of the node. */
path: string[];
/** Search tags of the node. */
tags: string[];
/** Description of the node. */
description: string;
inputTypes: Node['inputTypes'];
outputTypes: Node['outputTypes'];
};
type Ins = Record<string, Socket>;
type Outs = Record<string, Socket>;
type Controls = Record<string, Control>;
type State = Record<string, unknown>;
type Params = Record<string, unknown>;
export declare function nodeItem<I extends Ins, O extends Outs, C extends Controls, S extends State, P extends Params, N extends typeof Node<I, O, C, S, P>>(item: NodeMenuItem<I, O, C, S, P, N>): NodeMenuItem;
export declare function xmlItem({ label, xmlConfig }: {
label?: string;
xmlConfig: XmlConfig;
}): NodeMenuItem<typeof Node>;
export declare function xmlNodeItems({ schema, basePath, priorities }: {
schema: XmlSchema;
basePath?: string[];
priorities?: Record<string, Record<string, number>>;
}): NodeMenuItem[];
export declare let baseNodeMenuItems: NodeMenuItem[];
export declare function getMenuItemsFromNodeItems({ factory, pos, nodeItems, action }: {
factory: NodeFactory;
pos: Position;
nodeItems: NodeMenuItem[];
action?: (n: Node) => void;
}): MenuItem[];
export declare function createNodeMenuItem(params: Partial<Omit<NodeMenuItem, 'nodeClass' | 'params'>> & {
nodeClass: NodeMenuItem['nodeClass'];
params: NodeMenuItem['params'];
}): NodeMenuItem;
export declare function contextMenuSetup({ showContextMenu, additionalNodeItems }: {
showContextMenu: ShowContextMenu;
additionalNodeItems?: NodeMenuItem[];
}): Setup;
export {};