0.1.6 • Published 4 years ago

@beauagst/vue-whiteboard v0.1.6

Weekly downloads
-
License
-
Repository
github
Last release
4 years ago

vue-whiteboard

Built using Vue 3, based upon the fantastic ng-whiteboard

This library has no styles. It simply acts as a wrapper for the basic whiteboard functionality.

vue-whiteboard in action

Lightweight Vue whiteboard

Features:

  • Supports touch.
  • Custom colors.
  • Custom background colors.
  • Custom stroke size.
  • Export as PNG
  • Undo & Redo

Install

  1. Install npm module:

    npm i @beauagst/vue-whiteboard
  2. Add the module to your project

    import VueWhiteboard from 'vue-whiteboard'
    ...
    
    export default {
      ...
      components: {
        VueWhiteboard
      }
      ...
    }
  3. Insert the Whiteboard Component element into your template.

    <template>
      <vue-whiteboard />
    </template>

Props

InputTypeDefaultRequiredDescription
colorstring#000000falseSet brush color
backgroundColorstring#fffffffalseSet whiteboard background color
sizestring5pxfalseSet brush size
linejoinstringroundfalseDefine the shape of two lines when joined together ('miter' , 'round' , 'bevel' , 'miter-clip' , 'arcs')
linecapstringroundfalseDefine start and end shape of line ('butt', 'square', 'round')
lineStylesObject{}falseAny extra line styles you'd like to apply. Will be inlined with the rest.

Events

NameDescriptionPayload
initOn component initializationd3 Selection
undoOn undo last lineundefined
redoOn repaint last lineundefined
saveOn saveundefined
clearOn clearundefined
dragstartOnce dragging starts within SVG{ coordinates: [X, Y], node: Path }
dragContinuing dragging{ coordinates: [X, Y], node: Path }
dragendOnce dragging has ended{ coordinates: [X, Y], node: Path }

Methods

Methods can be accessed from the component.

<template>
  <vue-whiteboard ref="whiteboard" />
</template>
export default {
  ...
  methods: {
    save() {
      const res = await this.$refs.whiteboard.save()
    }
  }
}
NameDescription
undoUndo last line
redoRepaint last line
saveReturn base64-formatted PNG of whiteboard
clearClear the whiteboard

Contributing

The project is open for contributors! Please file an issue or make a PR :)

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago