nodeEditor.ts 907 B

12345678910111213141516171819202122232425262728293031323334
  1. import * as React from "react";
  2. import * as ReactDOM from "react-dom";
  3. import { GlobalState } from './globalState';
  4. import { GraphEditor } from './components/graphEditor';
  5. /**
  6. * Interface used to specify creation options for the node editor
  7. */
  8. export interface INodeEditorOptions {
  9. /**
  10. * Defines the DOM element that will host the node editor
  11. */
  12. hostElement: HTMLDivElement
  13. }
  14. /**
  15. * Class used to create a node editor
  16. */
  17. export class NodeEditor {
  18. /**
  19. * Show the node editor
  20. * @param options defines the options to use to configure the node editor
  21. */
  22. public static Show(options: INodeEditorOptions) {
  23. let globalState = new GlobalState();
  24. const graphEditor = React.createElement(GraphEditor, {
  25. globalState: globalState
  26. });
  27. ReactDOM.render(graphEditor, options.hostElement);
  28. }
  29. }