npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

svg-annotator

v1.0.0

Published

A Vue2 svg annotator to comment and print any wrapped content

Downloads

23

Readme

svg-annotator

A vue2 component you can use to wrap any content to enable on-the-go annotations and pdf generation.

Features: . create shapes (rectangle, circle, arrow) . freehand drawing . add text (includes bullet points mode) . select, move, resize, copy paste, delete, group & ungroup, redo shapes . select and group shapes in one single action . save to pdf (uses html2canvas & jspdf as dependencies) . copy to clipboard (chromium browsers only) . choose print orientation . hd or low lef print

Project setup

npm i svg-annotator

Documentation

Full documentation

Implementation

import SvgAnnotator from "svg-annotator";

You need to place a single element inside the SvgAnnotator (div, section, svg or canvas), as the SvgAnnotator will base its size upon the first slotted element. This element and all its children will be part of the annotation area.

If your content contains multiple elements, place them inside a single div, section, svg or canvas element:

<SvgAnnotator>
    <div>
        ... any content you want
    </div>
</SvgAnnotator>

<SvgAnnotator>
    <section>
        ... any content you want
    </section>
</SvgAnnotator>

<SvgAnnotator>
    <svg>
        ... any content you want
    </svg>
</SvgAnnotator>

<SvgAnnotator>
    <canvas>
    </canvas>
</SvgAnnotator>

Props

   buttonSize: {
      // the toolbar buttons size
      type: Number,
      default: 28,
   },
   disableForTouchScreens: {
      //In its current version, SvgAnnotator is not suited for touchscreen devices, and best used with a mouse & keyboard. This prop hides the toolbar for touchscreen devices, basically deactivating the annotator
      type: Boolean,
      default: true,
   },
   fixedTools: {
      // if true, toolbox will be fixed to top center of your page. 
      // Ideal to use when a whole page is slotted inside the SvgAnnotator.
      type: Boolean,
      default: false,
    },
    fontFamily: {
      // The font family your slotted elements are using. 
      // In print mode, all fonts will be converted to Helvetica, so you need to provide your font here, to revert to it after print is resumed.
      type: String,
      default: "Helvetica",
    },
    iconColor: {
      // Color of the button icons & borders
      type: String,
      default: "#4a4a4a",
    },
    showPrint: {
      // Show or hide the print button in the toolbox
      type: Boolean,
      default: true,
    },
    showTooltips: {
      // Show tooltips for top buttons of toolbox
      type: Boolean,
      default: true,
    },
    translations: {
      // Translations for all labels used in the toolbox
      type: Object,
      default() {
        return {
          autoOrientation: "auto print orientation",
          clipboardFailure: "This functionality is not supported by your browser. Sorry",
          clipboardSuccess: "Image successfully copied to your clipboard.",
          color: "Color",
          colorAlpha: "Color alpha",
          dashedLines: "Dashed lines",
          filled: "Filled",
          fontSize: "Font size",
          hdPrint: "hd print",
          thickness: "Thickness",
          title: "Annotations",
          tooltipGroup: "Select & group",
          tooltipDelete: "Delete",
          tooltipMove: "Move",
          tooltipResize: "Resize",
          tooltipBringToFront: "Bring to front",
          tooltipBringToBack: "Bring to back",
          tooltipDuplicate: "Duplicate",
          tooltipRedo: "Redo last shape",
          tooltipUndo: "Undo last shape",
          tooltipUngroup: "Ungroup",
          tooltipPdf: "Save pdf",
          tooltipClipboard: "Copy to clipboard"
        };
      },
    },

Events

@toggleOpenState returns true if the toolbar is open, and false if it is closed.
@interface exposes methods to the parent (since version 0.3.7) See full documentation for an implementation example.

Caveats

  • Moving a shape too quickly can make the pointer leave the current shape and focus on another shape.
  • While the menu is open, the drawing area is above the content that was placed in the slot. User interaction with the slotted content is not possible, as all interactions will concern the SvgAnnotator.
  • During the pdf generation, all fonts will be converted to 'Helvetica', which is one of the default fonts supported by jspdf. Not providing your font in the prop 'fontFamily' will cause content to remain with 'Helvetica' after the pdf generation resumes.