0.4.5 • Published 4 years ago

vuerd-plugin-erd v0.4.5

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

vuerd-plugin-erd

vuerd-core plugin ERD Editor

npm version VS Marketplace version GitHub

vuerd-info

Multiple selection

multiple-selection

SQL DDL

sql-ddl

Generator Code

generator-code

Document

Prop

NameTypeDescribe
valueStringeditor data
widthNumberwidth
heightNumberheight
focusBooleancurrent focus
undoBooleanundo status
redoBooleanredo status

Emit

EventTypeDescribe
changeStringeditor data
undoundo execute
redoredo execute

Component

Install

$ yarn add vuerd-plugin-erd
$ yarn add undo-manager
or
$ npm install vuerd-plugin-erd
$ npm install undo-manager

Usage

// main.js or main.ts
import Vue from 'vue';
import {Vuerd} from 'vuerd-plugin-erd';
import 'vuerd-plugin-erd/dist/vuerd-plugin-erd.css';
Vue.component('Vuerd', Vuerd);
<template>
  <div class="workspace-vuerd">
    <vuerd
      :focus="true"
      :undo="undo"
      :redo="redo"
      :width="width"
      :height="height"
      :value="value"
      @change="onChange"
      @undo="onUndo"
      @redo="onRedo"
    />
  </div>
</template>

<script>
  import UndoManager from 'undo-manager'

  export default {
    name: 'DemoVuerd',
    data: () => ({
      width: 2000,
      height: 2000,
      value: '',
      undo: false,
      redo: false,
      undoManager: null
    }),
    methods: {
      onResize() {
        this.width = window.innerWidth
        this.height = window.innerHeight
      },
      callback() {
        this.undo = this.undoManager.hasUndo();
        this.redo = this.undoManager.hasRedo();
      },
      onChange(value) {
        if (this.value !== value) {
          const oldValue = this.value
          this.undoManager.add({
            undo: () => {
              this.value = oldValue
            },
            redo: () => {
              this.value = value
            },
          })
        }
        this.value = value
      },
      onUndo() {
        this.undoManager.undo()
      },
      onRedo() {
        this.undoManager.redo()
      },
    },
    created() {
      this.undoManager = new UndoManager()
      this.undoManager.setCallback(this.callback)
    },
    mounted() {
      window.addEventListener('resize', this.onResize)
      window.dispatchEvent(new Event('resize'))
      // save data load
      this.value = ''
    },
    destroyed() {
      window.removeEventListener('resize', this.onResize)
    }
  }
</script>

<style scoped>
  body {
    margin: 0;
  }
  .workspace-vuerd {
    overflow: hidden;
    height: 100vh;
  }
</style>

CDN Quick Start

<!DOCTYPE html>
<html>
<head>
  <title>vuerd-core demo</title>
  <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/vuerd-plugin-erd/dist/vuerd-plugin-erd.css">
  <style>
    body {
      margin: 0;
    }
    #app {
      overflow: hidden;
      height: 100vh;    
    } 
  </style>
</head>
<body>
  <div id="app">
    <vuerd
      :focus="true"
      :width="width"
      :height="height"
      :value="value"
      @change="onChange"
     />
  </div>
  <script src="https://cdn.jsdelivr.net/npm/vue"></script>
  <script src="https://cdn.jsdelivr.net/npm/vuerd-plugin-erd/dist/vuerd-plugin-erd.umd.min.js"></script>
  <script>
    const Vuerd = window['vuerd-plugin-erd'].Vuerd
    Vue.component('Vuerd', Vuerd)
    new Vue({
      el: '#app',
      data: () => ({
        width: 2000,
        height: 2000,
        value: ''
      }),
      methods: {
        onResize() {
          this.width = window.innerWidth
          this.height = window.innerHeight
        },
        onChange(value) {
          this.value = value
          // data save
        }
      },
      mounted() {
        window.addEventListener('resize', this.onResize)
        window.dispatchEvent(new Event('resize'))
        // save data load
        this.value = ''
      },
      destroyed() {
        window.removeEventListener('resize', this.onResize)
      }
     })
  </script>
</body>
</html>

vuerd-core plugin

Install

$ yarn add vuerd-core
$ yarn add vuerd-plugin-erd
or
$ npm install vuerd-core
$ npm install vuerd-plugin-erd

Usage

// main.js or main.ts
import Vue from 'vue';
import VuerdCore from 'vuerd-core';
import ERD from 'vuerd-plugin-erd';
import 'vuerd-core/dist/vuerd-core.css';
import 'vuerd-plugin-erd/dist/vuerd-plugin-erd.css';
VuerdCore.use(ERD, /* option */);
Vue.use(VuerdCore);
<vuerd-core />

CDN Quick Start

<!DOCTYPE html>
<html>
<head>
  <title>vuerd-core demo</title>
  <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/vuerd-core/dist/vuerd-core.css">
  <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/vuerd-plugin-erd/dist/vuerd-plugin-erd.css">
</head>
<body>
  <div id="app">
    <vuerd-core />
  </div>
  <script src="https://cdn.jsdelivr.net/npm/vue"></script>
  <script src="https://cdn.jsdelivr.net/npm/vuerd-core/dist/vuerd-core.umd.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/vuerd-plugin-erd/dist/vuerd-plugin-erd.umd.min.js"></script>
  <script>
    const VuerdCore = window['vuerd-core'].default
    const ERD = window['vuerd-plugin-erd'].default
    VuerdCore.use(ERD)
    Vue.use(VuerdCore)
    new Vue({
      el: '#app'
    })
  </script>
</body>
</html>

Option interface

export interface Option {
  scope?: string[] | RegExp[];
  exclude?: string[] | RegExp[];
}

Option

NameTypeDefaultDescribe
scopeString | RegExp"vuerd"file designation(string extension)
excludeString | RegExpexception file designation(string extension)

Editor Action

NameAction
Multiple selection(table, memo)Ctrl + Drag, Ctrl + Click, Ctrl + A
Multi-movement(table, memo)Ctrl + Drag
Column shiftDrag
Multiple selection(column)Ctrl + Click, Shift + Click, Shift + Arrow key(up, down)
Copy&Paste(column)Ctrl + C, Ctrl + V
ContextmenuRight-click
New TableAlt + N
New MemoAlt + M
New ColumnAlt + Enter
Delete(table, memo)Ctrl + Delete
Delete(column)Alt + Delete
Select DataType HintArrow key(right), Click
Move DataType HintArrow key(up, down)
Relationship ZeroOneAlt + 1
Relationship ZeroOneNAlt + 2
Primary KeyAlt + K
UndoCtrl + Z
RedoCtrl + Shift + Z
EditingEnter, dblclick
All Action StopESC

License

MIT

0.4.5

4 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.8

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.18

4 years ago

0.2.17

4 years ago

0.2.16

4 years ago

0.2.15

4 years ago

0.2.14

4 years ago

0.2.13

4 years ago

0.2.12

4 years ago

0.2.11

4 years ago

0.2.10

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago