3.0.4 • Published 1 day ago

ng-whiteboard v3.0.4

Weekly downloads
69
License
MIT
Repository
github
Last release
1 day ago

ng-whiteboard

Lightweight angular whiteboard

Build Status npm version License: MIT Downloads codecov

Demo

https://mostafazke.github.io/ng-whiteboard

Features

  • Supports touch.
  • Highly Customizable.
  • Lightweight.
  • Easy to use.
  • Custom colors.
  • Custom background colors.
  • (Brush | Image | Line | Rect | Ellipse | Text | Eraser) Tools.
  • Custom stroke size.
  • Save drawn as (svg | png | jpeg | base64) images.
  • Undo - Redo.

And more to come...

Installation

  1. Install ng-whiteboard via:

    yarn add ng-whiteboard --save

    or

    npm install ng-whiteboard --save
  2. Add the module to your project

    import { NgWhiteboardModule } from 'ng-whiteboard';
    ...
    
    @NgModule({
        imports: [
            ...
            NgWhiteboardModule
        ]
        ...
    )}
  3. Insert the Whiteboard Component element in the html.

    <ng-whiteboard></ng-whiteboard>

Options

InputTypeDefaultDescription
data[WhiteboardElement][]The whiteboard data
optionsWhiteboardOptionsnullcomponent configuration object, properties described below
drawingEnabledbooleantrueEnable mouse/touch interactions
selectedToolToolsEnumToolsEnum.BRUSHThe current selected tool
canvasWidthnumber800The width of whiteboard canvas
canvasHeightnumber600The height of whiteboard canvas
fullScreenbooleantrueif true change (canvasWidth, canvasHeight) to fit the parentainer
strokeColorstring#000000The default stroke color
backgroundColorstring#FFFFFFThe default background color
fillstring#333333The default fill color
strokeWidthnumber2The default stroke width
zoomnumber1Zoom level
fontFamilystringsans-serifThe default font family
fontSizenumber24The default font size
centerbooleantrueCenter the canvas in parent component, works with fullScreen: false
xnumber0if center is false, set the X axis
ynumber0if center is false, set the Y axis
enableGridbooleanfalseEnable the grid pattern
gridSizenumber10Set the grid inner boxes size
snapToGridbooleanfalseEnable snaping to grid
lineJoinLineJoinEnum .ROUNDLineJoinEnumThe default Line join
lineCapLineCapEnum .ROUNDLineCapEnumThe default Line cap
dasharraystring''The default dash-array
dashoffsetnumber0The default dash-offset

Outputs

NameDescriptionArguments
(ready)Emitted when the component is readyNone
(dataChange)Emitted when the data is changedWhiteboardElement[]
(clear)Emitted when the canvas is clearedNone
(undo)Emitted when the user undo an actionNone
(redo)Emitted when the user redo an actionNone
(imageAdded)Emitted when the user add an image to the canvasNone
(save)Emitted when the user save the canvasbase64 image
(selectElement)Emitted when the user select/deselect an elementWhiteboardElement / null
(deleteElement)Emitted when the user delete an elementWhiteboardElement
(toolChanged)Emitted when the user change the toolToolsEnum

Methods

NameDescriptionArgumentsDefaults
saveSave the current boardformat: string, name: stringformat: 'base64', name: 'New board'
addImageAdd images to the boardimage: (string; ArrayBuffer)None
eraseClean the whiteboardNoneNone
undoUndo last actionNoneNone
redoRedo last actionNoneNone

to use these Methods inject NgWhiteboardService in your project

import { NgWhiteboardService, FormatType } from 'ng-whiteboard';
...

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
   styleUrls: ['./app.component.scss']
   ...
)}

  constructor(private whiteboardService: NgWhiteboardService) {
   this.whiteboardService.save(FormatType.Base64);
  }

Contributing

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

3.0.4

1 day ago

3.0.3

5 months ago

3.0.2

7 months ago

3.0.1

7 months ago

3.0.0

7 months ago

2.0.22

7 months ago

2.0.20

8 months ago

2.0.19

9 months ago

2.0.17

11 months ago

2.0.18

9 months ago

2.0.15

1 year ago

2.0.16

1 year ago

2.0.13

1 year ago

2.0.14

1 year ago

2.0.11

1 year ago

2.0.12

1 year ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.9

1 year ago

2.0.10

1 year ago

2.0.8

2 years ago

2.0.3

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.5.7

2 years ago

1.5.0

3 years ago

1.4.6

3 years ago

1.4.5

4 years ago

1.4.4

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago