vue-rough-notation
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Vue Rough Notation

npm CircleCI npm bundle size GitHub

Rough Notation logo

A Vue wrapper for RoughNotation, a small JavaScript library to create and animate annotations on a web page.

Table of Contents

Demo

Demo Page

Code Sandbox

Installation

NPM:

npm install --save vue-rough-notation

To make vue-rough-notation work for Vue 2, you need to have @vue/composition-api installed:

npm install --save @vue/composition-api

Usage

Vue3

import { createApp } from 'vue'
import VueRoughNotation from 'vue-rough-notation';

const app = createApp(...);
app.use(VueRoughNotation);

Vue2

import Vue from 'vue';
import VueCompositionAPI from '@vue/composition-api';
import VueRoughNotation from 'vue-rough-notation';

Vue.use(VueCompositionAPI);
Vue.use(VueRoughNotation);

Global options

The default global options are:

{
  // Turn on/off animation when annotating.
  animate: true,
  // Duration of the animation in milliseconds.
  animationDuration: 800,
  // Representing the color of the annotation sketch.
  color: 'currentColor',
  // Width of the annotation strokes.
  strokeWidth: 1,
  // (in pixels) Padding between the element and roughly where the annotation is drawn.
  padding: 5,
  // To annotate multiline text (each line separately), set this property to true.
  multiline: false,
  // By default annotations are drawn in two iterations.
  iterations: 2,
  // When drawing a bracket, this configures which side(s) of the element to bracket.
  brackets: `right`,
}

You can change the options when install:

  • Vue3
import VueRoughNotation from 'vue-rough-notation';

app.use(VueRoughNotation, options);
  • Vue2
import VueRoughNotation from 'vue-rough-notation';

Vue.use(VueRoughNotation, options);

RoughNotation Component

Usage

<RoughNotation :is-show="isShow" type="underline">
  <span>Rough Notation is awesome</span>
</RoughNotation>

Props

type

Type: string

required: true

This is a mandatory field. It sets the annotation style. Following are the list of supported annotation types:

  • underline: This style creates a sketchy underline below an element.
  • box: This style draws a box around the element.
  • circle: This style draws a circle around the element.
  • highlight: This style creates a highlight effect as if marked by a highlighter.
  • strike-through: This style draws horizontal lines through the element.
  • crossed-off: This style draws an 'X' across the element.
  • bracket: This style draws a bracket around an element, usually a paragraph of text. By default on the right side, but can be configured to any or all of left, right, top, bottom.

isShow

Type: boolean

Required: false

Default: false

Whether draws the annotation.

animate

Type: boolean

Required: false

Default: true - You can change it when install (see above).

Turn on/off animation when annotating.

animationDuration

Type: number

Required: false

Default: 800 - You can change it when install (see above).

Duration of the animation in milliseconds.

color

Type: string

Required: false

Default: currentColor - You can change it when install (see above).

Representing the color of the annotation sketch.

strokeWidth

Type: number

Required: false

Default: 1 - You can change it when install (see above).

Width of the annotation strokes.

padding

Type: number | number[]

Required: false

Default: 5(in pixels) - You can change it when install (see above)

Padding between the element and roughly where the annotation is drawn. Default value is 5 (in pixels). If you wish to specify different top, left, right, bottom paddings, you can set the value to an array akin to CSS style padding [top, right, bottom, left] or just [top & bottom, left & right].

multiline

Type: boolean

Required: false

Default: false

This property only applies to inline text. To annotate multiline text (each line separately), set this property to true.

iterations

Type: number

Required: false

Default: 2 - You can change it when install (see above)

By default annotations are drawn in two iterations, e.g. when underlining, drawing from left to right and then back from right to left. Setting this property can let you configure the number of iterations.

brackets

Type: string | string[]

Required: false

Default: 'right'

Value could be a string or an array of strings, each string being one of these values: left, right, top, bottom. When drawing a bracket, this configures which side(s) of the element to bracket. Default value is right.

tag

Type: string

Required: false

Default: 'span'

String HTML tag name; if falsy (for example null or undefined), the component will be renderless (the content won't be wrapped in a tag), in this case, only the first child will be rendered

order

Type: number | string

Required: false

Default: 0

Works with RoughNotationGroup component, order the animation of annotations. When show is called on the group, the annotations are animated in order. For example, an annotation with order 1 will animate before order 2. Also you can pass orderAnnotations prop to RoughNotationGroup to customize the order function.

Events

init

Parameters: Annotation Object

Called when the component is initialized.

RoughNotationGroup Component

Usage

<RoughNotationGroup :is-show="isShow">
  <RoughNotation type="underline">Rough Notation</RoughNotation>
  <RoughNotation type="box">is</RoughNotation>
  <RoughNotation type="highlight">awesome</RoughNotation>
</RoughNotation>

Props

isShow

Type: boolean

Required: false

Default: false

Show/Hides the annotations

tag

Type: string

Required: false

Default: 'div'

String HTML tag name; if falsy (for example null or undefined), the component will be renderless (the content won't be wrapped in a tag), in this case, only the first child will be rendered

orderAnnotations

Type: function

Required: false

Default: (a, b) => a - b

Customize annotations order function. Order will be sorted in ascending order by default.

Contributing

CONTRIBUTING

License

MIT

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.415latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.415
1.0.32
1.0.20
1.0.10
1.0.00
0.1.119
0.1.100
0.1.90
0.1.80
0.1.70
0.1.60
0.1.50
0.1.40
0.1.31
0.1.20
0.1.11
0.1.01

Package Sidebar

Install

npm i vue-rough-notation

Weekly Downloads

22

Version

1.0.4

License

MIT

Unpacked Size

93.3 kB

Total Files

7

Last publish

Collaborators

  • leecason