GithubHelp home page GithubHelp logo

ddling1216 / dag-editor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hustliucn/dag-editor

0.0 2.0 0.0 592 KB

a simple canvas lib for mind-map-painting & dag-painting-editor

Home Page: https://stillbold.com

JavaScript 64.14% CSS 3.91% TypeScript 31.95%

dag-editor's Introduction

a simple dag editor tool for web

Demo

GitHub

usage

install

yarn add simple-dag-editor

init

import { Editor } from 'simple-dag-editor'

const editor = new Editor({
  container: string, // editor container dom selector
  page: string,  // editor canvas page container dom selector
  itempanel: string,  // editor items panel container dom selector
})

register shape

editor.registerShape(shapeName, shape)

interface IShape {
  shape: string,  // shape name
  w: number,  // width
  h: number,  // height
  name: string, // node-item shown text
  anchors: IAnchor,
  [customProp: string]: any,  // any custom define property
}
interface IAnchor {
  input?: number,     // input count
  output?: number,    // output count
}

callback

interface INode extends IShape {
  x: number,  // canvas position
  y: number,  // canvas postion
}

interface IEdge {
  id: string,
  source: string,   // source node id
  sourceAnchorIndex: number,    // source node output anchor index
  target: string,   // target node id
  targetAnchorIndex: number,    // target node input anchor index
}
interface callback {
  selectedNodeChange: (node: INode) => void,
  nodeAdded: (node: INode) => void,
  nodeDeleted: (nodeId: string) => void,
  edgeAdded: (edge: IEdge) => void,
  edgeDeleted: (edge: IEdge) => void,
}

editor.on(`${callbackEventName}`, callback)

TODO

  • nodeDeleted
  • nodeAdded
  • select edge
  • delete edge
  • edgeAdded & edgeDeleted callback
  • drag canvas
  • scale
  • editor.update()

dag-editor's People

Contributors

hustliucn avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.