1.0.1 • Published 1 year ago

wc-svg-annotator v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

svg-annotator web component

A web component to select any area on a web page, annotate it and save the result to pdf.

Features:

  • adds a button on the page, to enable the selection and annotation of its content
  • after selecting by dragging the mouse, a modal will display a canvas copy of the selection area, along with annotation tools
  • generate a pdf of the annotated content

Annotation tools:

  • create shapes (rectangle, circle, arrow)
  • freehand drawing
  • add text (includes bullet points mode)
  • select, move, resize, copy paste, delete, group & ungroup, redo shapes
  • save to pdf (uses html2canvas & jspdf as dependencies)
  • choose printing orientation
  • choose hd or low def print

Project setup

npm i wc-svg-annotator

Place the web component on the desired page:

<html>
  <!-- your content -->
  <svg-annotator />
</html>

Props

PropDescriptionDefaultOptions
button-positionPlacement of the fixed starter button on the page"mr" (middle right)"tr", "mr", "br", "tl", "ml", "bl"
button-sizeSize of the annotation toolbar buttons28-
font-familyFont family of the annotator"Helvetica"-
icon-colorColor of the icons and borders of the annotator buttons"#4a4a4a"-
show-printEnable / Disable pdf functionalitytruetrue, false
show-tooltipsShow / Hide tooltipstruetrue, false
translation-auto-orientationLabel for the auto print orientation checkbox"auto print orientation"-
translation-clipboard-failureLabel for the error message if the image copy to clipboard feature is not supported by the client's browser"This functionality is not supported by your browser. Sorry"-
translation-clipboard-successLabel for the success message after copying to clipboard"Image successfully copied to your clipboard."-
translation-colorLabel for the color picker input"Color"-
translation-color-alphaLabel for the color alpha slider input"Color alpha"-
translation-dashed-linesLabel for the dashed lines checkbox"Dashed lines"-
translation-filledLabel for the filled shape checkbox"Filled"-
translation-hd-printLabel for the hd print checkbox"hd print"-
translation-font-sizeLabel for the font size input"Font size"-
translation-thicknessLabel for the line thickness input"Thickness"-
translation-titleTitle of the annotator summary"Annotations"-
translation-tooltip-groupTooltip for the group button"Select & Group"-
translation-tooltip-deleteTooltip for the delete button"Delete"-
translation-tooltip-moveTooltip for the move button"Move"-
translation-tooltip-resizeTooltip for the resize button"Resize"-
translation-tooltip-bring-to-frontTooltip for the bring to front button"Bring to front"-
translation-tooltip-bring-to-backTooltip for the bring to back button"Bring to back"-
translation-tooltip-duplicateTooltip for the duplicate button"Duplicate"-
translation-tooltip-redoTooltip for the redo button"Redo last shape"-
translation-tooltip-undoTooltip for the undo button"Undo last shape"-
translation-tooltip-ungroupTooltip for the ungroup button"Ungroup"-
translation-tooltip-pdfTooltip for the save pdf button"Save pdf"-
translation-tooltip-clipboardTooltip for the copy to clipboard button"Copy to clipboard"-

Here is the syntax to use all the props in your HTML. If you don't add props, these will be used by default:

<html>
  <svg-annotator
    button-position="mr"
    button-size="28"
    font-family="Helvetica"
    icon-color="#4a4a4a"
    show-print="true"
    show-tooltips="true"
    translation-auto-orientation="auto print orientation"
    translation-clipboard-failure="This functionality is not supported by your browser. Sorry"
    translation-clipboard-success="Image successfully copied to your clipboard."
    translation-color="Color"
    translation-color-alpha="Color alpha"
    translation-dashed-lines="Dashed lines"
    translation-filled="Filled"
    translation-font-size="Font size"
    translation-hd-print="hd print"
    translation-thickness="Thickness"
    translation-title="Annotations"
    translation-tooltip-group="Select & Group"
    translation-tooltip-delete="Delete"
    translation-tooltip-move="Move"
    translation-tooltip-resize="Resize"
    translation-tooltip-bring-to-front="Bring to front"
    translation-tooltip-bring-to-back="Bring to back"
    translation-tooltip-duplicate="Duplicate"
    translation-tooltip-redo="Redo last shape"
    translation-tooltip-undo="Undo last shape"
    translation-tooltip-ungroup="Ungroup"
    translation-tooltip-pdf="Save pdf"
    translation-tooltip-clipboard="Copy to clipboard"
  />
</html>

Caveats

  • The copy to clipboard funtionality only works on chromium-based browsers at this stage. In case the browser does not support this functionality, the copy to clipboard button will simply not show.
1.0.1

1 year ago

1.0.0

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.2.6

1 year ago

0.1.9

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago