import { Provider, ElementRef } from "@angular/core"; import { MatSnackBar } from '@angular/material/snack-bar'; import { Subject } from 'rxjs'; import { DiazoContext, DiazoNodeContext, DiazoValueType, Position } from '@diazo/model'; import { GraphComponent } from '../graph/graph.component'; import { DiazoGraph, DiazoNodeSet, DiazoNode, DiazoPropertySet, DiazoPropertyOptionGroup, DiazoCustomPropertyType, DiazoProperty } from '@diazo/model'; import * as i0 from "@angular/core"; /** * Provides a full-featured Diazo editor, including a searchable * New Node list and a powerful property sheet implementation. * * ```html * * ``` * * Here, * - `[graph]` is the graph that should be rendered. Any changes made by the user will * be applied to the bound object. * - `[availableNodes]` is an array of {@linkcode DiazoNode} objects made available * to the user in the New Node menu * * See More * - {@linkcode DiazoGraph} - Represents a graph, composed of its nodes and edges * - {@linkcode DiazoValueType} - Edges are "values", and their types are represented by "value types" * - {@linkcode DiazoContext} - Most useful instrumentation of the Diazo editor is done * via the Context layer * * @category Entrypoint */ export declare class EditorComponent { private matSnackBar; private elementRef; /** * @hidden */ constructor(matSnackBar: MatSnackBar, elementRef: ElementRef); /** * @hidden */ ngOnInit(): void; /** * @hidden */ ngOnDestroy(): void; private windowResizeHandler; private _propertySearch; private _nodeSearch; private _showProperties; private _showPropertiesByDefault; private _graph; private _availableNodes; private accessor; private labelCache; nodeMenuPosition: Position; newNodePosition: Position; /** * A proxy object which is capable of getting or setting property * values across the nodes that are currently selected in the editor. * The keys of this object are interpreted as either JSONPath (when the * key starts with '$') or Diazo's custom object path format (otherwise). */ propertyManipulator: any; /** * Stores the current graph context object. This represents the state * logic for the graph being edited within the Diazo editor */ graphContext: DiazoContext; /** * Get the currently selected node context (the first one * if multiple nodes are currently selected) */ selectedNodeContext: DiazoNodeContext; /** * Get the currently selected node-contexts */ selectedNodeContexts: DiazoNodeContext[]; /** * Provides the PropertySets which are currently visible * subject to the search query entered by the user. */ selectedPropertySets: DiazoPropertySet[]; /** * Provides the NodeSets which are currently visible * in the New Node menu, subject to the search query * entered by the user. */ matchingNodeSets: DiazoNodeSet[]; /** * Provides the Nodes which are currently visible * in the New Node menu, subject to the search query * entered by the user. This is a flattening of the nodes * found in `matchingNodeSets`. */ matchingNodes: DiazoNode[]; /** * When true, the Node Menu is in keyboard mode, and certain * keystrokes (up/down/enter) can be used to select and insert * a node visible in the menu, This works in concert with * `matchingNodes`. */ nodeMenuKeyboardMode: boolean; /** * The index of a node in the New Node menu that the user has * selected via Keyboard Mode. */ selectedMatchingNodeIndex: number; /** * The text the user has entered into the Property Sheet's * Search box. */ get propertySearch(): string; set propertySearch(value: string); /** * The text the user has entered into the Node Menu's * Search box. */ get nodeSearch(): string; set nodeSearch(value: string); /** * True when the user has made the Properties sidebar visible. * False when the user has hidden it. This also has special behavior * if the user has not yet shown/hidden the sidebar -- if the * screen size is small enough to be considered "mobile", then this * will return false. Otherwise it will be true. */ get showProperties(): boolean; set showProperties(value: boolean); /** * Options used for Monaco when editing JSON. */ jsonMonacoOptions: { theme: string; language: string; automaticLayout: boolean; }; /** * Options used for Monaco when editing Markdown. */ markdownMonacoOptions: { theme: string; language: string; automaticLayout: boolean; }; /** * Options used for Monaco when editing TypeScript. */ tsMonacoOptions: { theme: string; language: string; automaticLayout: boolean; }; /** * Fired when the DiazoContext has been acquired from the underlying * Diazo component. DiazoContext represents the operating state * (model) of the Diazo editor. */ contextChanged: Subject; /** * Fired when the graph has been changed by the user. More technically * this is fired when a change transaction is "committed" to the Diazo * Context. These change transactions underpin Diazo's support for Undo/Redo. */ graphChanged: Subject; /** * If true, the Diazo editor will be placed in Read Only mode. The user * can still move nodes around, but new nodes cannot be created, existing nodes * cannot be removed, and edges cannot be changed. */ readonly: boolean; /** * If true, the Diazo editor will allow no changes to the graph whatsoever. * When this is true, `readonly` is also considered to be true. The difference * between `locked` and `readonly` is mainly that the nodes cannot be moved around * by the user. */ locked: boolean; /** * Allows the consumer to pass in a set of dependency injection providers * which will be used whenever a custom property editor or custom node is * created. Use this to pass in services needed by your custom controls. */ providers: Provider[]; /** * Provides access to the underlying component which * implements the Diazo renderer. */ container: GraphComponent; /** * Specify an array of PropertySets which will be shown for all nodes that * exist in the graph. These PropertySets will be shown after the ones defined * on the node itself. */ universalPropertySets: DiazoPropertySet[]; /** * When true, the edges of the graph will be rendered with a flow animation. * Use this to indicate that the graph is currently "running". */ active: boolean; /** * Allows the consumer to pass in the set of nodes that will be available * for the user to add to the graph via the New Node menu (right click). */ get availableNodes(): DiazoNodeSet[]; set availableNodes(value: DiazoNodeSet[]); private nodeRegistry; /** * Allows the consumer to specify dynamic option sources for use with * properties of type "select". Since properties are static declarations, * it is generally not possible to dynamically populate the options of a * "select" property. The "optionSources" system provides a good way to * do this. To use it, define a property such as {type: "select", optionSource: "mySource"} * and specify "optionSources" as { mySource: { option1: "Option 1", option2: "Option 2"}}. * The Diazo editor will automatically populate these options into the select * box in the Properties panel. */ optionSources: Record>; /** * Specify a set of custom components that will be used to render specific types of * nodes. The key of this map should match the "$.type" property of a node you wish * to use a custom component with. The value is the Angular component class. * * The custom component can inject the `DiazoNodeContext` instance in order * to interact with the node state. */ nodeTypeMap: Record; /** * Specify a set of custom components that will be used to render specific types of * properties. Each custom property type specifies a "namespace" and an "id". * You use this custom type in the `properties` declaration on a node (or via * universalPropertySets) by specifying `property.type = "namespace:id"` * (for example). */ customPropertyTypes: DiazoCustomPropertyType[]; /** * Specify a set of "value types" which are used to declare the types of * edges that can be created within the graph. The value type system * supports compatibility by class heirarchy by default, and custom value * type classes can even redefine the notion of compatibility however they want. * Compatibility here refers to whether a slot with one "value" is allowed to be * connected to a slot with another "value". * * Value types also define the color and appearance of the edge when rendered * within Diazo. */ valueTypes: { new (): DiazoValueType; }[]; /** * Specify the Diazo object that this editor should work with. * The object is passed by reference here, and the object will be * modified by the Diazo editor *in place*. Note that you can * also receive immutable snapshots of the graph via the * `graphChanged` event. */ get graph(): DiazoGraph; set graph(value: DiazoGraph); /** * Bind to this event to receive Save events from the user * (Diazo Editor does not do anything special with a Save * request by default, that is up to the consumer). This fires * when the user presses Ctrl+S / Cmd+S. */ saveRequested: Subject; /** * This is true if the selection of nodes is considered "readonly". * The selection is considered readonly if any selected node is * marked as "readonly". */ get selectionReadOnly(): boolean; /** * Provides (for convenience) the "MULTIPLE_VALUES" special token * value. This is used to represent that among the nodes selected * within the editor, the values of a specific property differ between * them. In the editor, this will show up as "Multiple values" in the * property sheet, which typically prevents you from editing the property. * @hidden */ get MULTIPLE_VALUES(): symbol; /** * Get the currently selected DiazoNode (the first one if there are multiple * nodes selected) */ get selectedNode(): DiazoNode; /** * Get the currently selected DiazoNodes. */ get selectedNodes(): DiazoNode[]; /** * Specify where a new node should be inserted. This is used * by the New Node menu to determine where a node should be * placed when it is not dragged into the view. * @hidden */ setNewNodePosition(position: Position): void; /** * Hide the node menu if it is currently visible. */ hideNodeMenu(): void; /** * Show the node menu if it is not currently visible. */ showNodeMenu(): void; /** * Insert the node that is currently selected in the New Node menu. * This is used by the Keyboard Mode of the node menu to insert the * node upon pressing "Enter". * @hidden */ insertSelectedNode(): void; /** * Return true if the given Property Type is a custom type. * This is determined by looking up the type using the `customPropertyTypes` * field. * @hidden */ isCustomPropertyType(type: string): boolean; /** * Get a custom property type from the `customPropertyTypes` field. * The passed string should be in the form "namespace:id" * @hidden */ getCustomPropertyType(type: string): DiazoCustomPropertyType; /** * @hidden */ numericRange(min: any, max: any, step?: number): any[]; /** * @hidden */ onGraphChanged(graph: DiazoGraph): void; /** * Locate the given dynamic option source with the given name from `optionSources`. * Used to support dynamic options sources for "select" properties. * @hidden */ getOptionsFromSource(sourceDescriptor: string): DiazoPropertyOptionGroup[]; /** * Returns true if the given property would have any enabled options within * the standard property menu (shown to the right of the property view). * If false, the editor will hide the menu entirely. * @hidden */ propertyNeedsMenu(prop: DiazoProperty): boolean; /** * Annotate all nodes in the given graph with the properties specified * within the `availableNodes` setting. It is typical for consumers of * Diazo to strip the `properties` part of all nodes in a graph for * space efficiency, because for some domains the amount of properties * on a node can be substantial. Furthermore, the properties specified * within `availableNodes` may have changed since the graph object was * originally created. This inflation process automatically * re-adds the necessary property definitions onto the graph nodes * ensuring that the available properties are always up to date with * those defined by your application. * @hidden */ inflateGraph(graph: DiazoGraph): void; /** * Find a node within `availableNodes` which matches the given node. * This is used to implement graph inflation (see `inflateGraph`) whereby * we update the `properties` section of all nodes in the graph. * @hidden */ findTemplateNode(node: DiazoNode): DiazoNode; /** * Determine the label to use for the given node. * @hidden */ labelForNode(node: DiazoNode): any; /** * Get the index of the given node within the `matchingNodes` array. * This is used to annotate the DOM nodes found within the Node Menu * in support of its keyboard selection mode. * @hidden */ getIndexOfMatchingNode(node: DiazoNode): number; /** * Special handling for keyboard input when the user is focused on the Search * box in the New Node menu. * @hidden */ onNodeMenuSearchKeyDown(event: KeyboardEvent): void; /** * Update the set of visible node sets based on the search query entered * into the New Node menu's Search box by the user (`nodeSearch`). * @hidden */ updateSelectedNodeSets(): void; /** * Update the set of visible property sets based on the search query * entered into the Properties sidebar Search box by the user (`propertySearch`) * @hidden */ updateSelectedPropertySets(): void; /** * trackBy v.path * @hidden */ path(v: any): any; /** * trackBy v.id * @hidden */ identity(v: any): any; /** * trackBy v.value * @hidden */ value(v: any): any; /** * Bound to 's `contextChanged` event * @hidden */ acquireGraphContext(context: DiazoContext): void; /** * Used with cdkDrag to implement reorderable slots within the Properties sidebar. * @hidden */ reorderSlots(event: any): void; /** * Returns true if the given property has been converted into a * Property Slot. * @hidden */ isPropSlotted(prop: DiazoProperty): boolean; /** * Removes property slots related to the given property from the * nodes that are currently selected. * @hidden */ removePropertySlot(property: DiazoProperty): void; /** * Creates new property slots related to the given property on all selected * nodes. * @hidden */ createPropertySlot(property: DiazoProperty): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; }