{"id":13457757,"url":"https://github.com/rough-stuff/rough-notation","last_synced_at":"2025-05-14T03:07:22.278Z","repository":{"id":37317490,"uuid":"266702263","full_name":"rough-stuff/rough-notation","owner":"rough-stuff","description":"Create and animate hand-drawn annotations on a web page","archived":false,"fork":false,"pushed_at":"2024-03-18T05:16:12.000Z","size":69,"stargazers_count":8996,"open_issues_count":29,"forks_count":216,"subscribers_count":48,"default_branch":"master","last_synced_at":"2025-05-08T01:25:47.337Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://roughnotation.com/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rough-stuff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"pshihn","open_collective":"rough"}},"created_at":"2020-05-25T06:34:03.000Z","updated_at":"2025-05-07T09:25:58.000Z","dependencies_parsed_at":"2024-04-15T00:41:03.007Z","dependency_job_id":"6aa27db3-4b24-429f-bc35-6363393c3718","html_url":"https://github.com/rough-stuff/rough-notation","commit_stats":{"total_commits":64,"total_committers":15,"mean_commits":4.266666666666667,"dds":0.53125,"last_synced_commit":"668ba82ac89c903d6f59c9351b9b85855da9882c"},"previous_names":["pshihn/rough-notation"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rough-stuff%2Frough-notation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rough-stuff%2Frough-notation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rough-stuff%2Frough-notation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rough-stuff%2Frough-notation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rough-stuff","download_url":"https://codeload.github.com/rough-stuff/rough-notation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253726950,"owners_count":21954106,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T09:00:35.758Z","updated_at":"2025-05-14T03:07:22.233Z","avatar_url":"https://github.com/rough-stuff.png","language":"TypeScript","funding_links":["https://github.com/sponsors/pshihn","https://opencollective.com/rough","https://opencollective.com/rough/contribute","https://opencollective.com/rough/organization/0/website","https://opencollective.com/rough/organization/1/website","https://opencollective.com/rough/organization/2/website","https://opencollective.com/rough/organization/3/website","https://opencollective.com/rough/organization/4/website","https://opencollective.com/rough/organization/5/website","https://opencollective.com/rough/organization/6/website","https://opencollective.com/rough/organization/7/website","https://opencollective.com/rough/organization/8/website","https://opencollective.com/rough/organization/9/website"],"categories":["TypeScript","对打造产品有帮助","others","Framework agnostic packages"],"sub_categories":["General utilities"],"readme":"![Rough Notation logo](https://roughnotation.com/images/social.png)\n\n# Rough Notation\n\nA small JavaScript library to create and animate annotations on a web page.\n\nRough Notation uses [RoughJS](https://roughjs.com) to create a hand-drawn look and feel. Elements can be annotated in a number of different styles. Animation duration can be configured, or just turned off.\n\nRough Notation is 3.83kb in size when gzipped.\n\n[Visit website to see it in action](https://roughnotation.com/) and check out the [source code](https://github.com/pshihn/rough-notation-web) for the website\n\n## Installation\n\nYou can add rough-notation to your project via npm\n\n```\nnpm install --save rough-notation\n```\n\nOr load the ES module directly\n\n```html\n\u003cscript type=\"module\" src=\"https://unpkg.com/rough-notation?module\"\u003e\u003c/script\u003e\n```\n\nOr load the IIFE version which created a `RoughNotation` object in your scope.\n\n```html\n\u003cscript src=\"https://unpkg.com/rough-notation/lib/rough-notation.iife.js\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\nCreate an `annotation` object by passing the element to annotate, and a config to describe the annotation style. \nOnce you have the annotation object, you can call `show()` on it to show the annotation\n\n```javascript\nimport { annotate } from 'rough-notation';\n// Or using unpkg\n// import { annotate } from 'https://unpkg.com/rough-notation?module';\n\nconst e = document.querySelector('#myElement');\nconst annotation = annotate(e, { type: 'underline' });\nannotation.show();\n```\n\n*Note: This will add an SVG element as a sibling to the element, which may be troublesome in certain situations like in a `\u003ctable\u003e`. You may want to create an inner `\u003cspan\u003e` or `\u003cdiv\u003e` for the content to annotate.*\n\n## Annotation Group\n\nrough-notation provides a way to order the animation of annotations by creating an annotation-group. Pass the list of annotations to create a group. When show is called on the group, the annotations are animated in order.\n\n```javascript\nimport { annotate, annotationGroup } from 'rough-notation';\n\nconst a1 = annotate(document.querySelector('#e1'), { type: 'underline' });\nconst a2 = annotate(document.querySelector('#e3'), { type: 'box' });\nconst a3 = annotate(document.querySelector('#e3'), { type: 'circle' });\n\nconst ag = annotationGroup([a3, a1, a2]);\nag.show();\n```\n\n## Live examples\nI have created some basic examples on Glitch for you to remix and play with the code:\n\n[Basic demo](https://glitch.com/~basic-rough-notation)\n\n[Annotation group demo](https://glitch.com/~annotation-group)\n\n## Configuring the Annotation\n\nWhen you create an annotation object, you pass in a config. The config only has one mandatory field, which is the `type` of the annotation. But you can configure the annotation in many ways. \n\n#### type\nThis is a mandatory field. It sets the annotation style. Following are the list of supported annotation types:\n\n* __underline__: This style creates a sketchy underline below an element.\n* __box__: This style draws a box around the element.\n* __circle__: This style draws a circle around the element.\n* __highlight__: This style creates a highlight effect as if marked by a highlighter.\n* __strike-through__: This style draws horizontal lines through the element.\n* __crossed-off__: This style draws an 'X' across the element.\n* __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*.\n\n#### animate\nBoolean property to turn on/off animation when annotating. Default value is `true`.\n\n#### animationDuration\nDuration of the animation in milliseconds. Default is `800ms`.\n\n#### color\nString value representing the color of the annotation sketch. Default value is `currentColor`.\n\n#### strokeWidth\nWidth of the annotation strokes. Default value is `1`. \n\n#### padding\nPadding between the element and roughly where the annotation is drawn. Default value is `5` (in pixels).\nIf 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 \u0026 bottom, left \u0026 right]`.\n\n#### multiline\nThis property only applies to inline text. To annotate multiline text (each line separately), set this property to `true`. \n\n#### iterations\nBy 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. \n\n#### brackets\nValue 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`.\n\n#### rtl\nBy default annotations are drawn from left to right. To start with right to left, set this property to `true`. \n\n## Annotation Object\n\nWhen you call the `annotate` function, you get back an annotation object, which has the following methods:\n\n#### isShowing(): boolean\nReturns if the annotation is showing\n\n#### show()\nDraws the annotation. If the annotation is set to animate (default), it will animate the drawing. If called again, it will re-render the annotation, updating any size or location changes. \n\n*Note: to reanimate the annotation, call `hide()` and then `show()` again.\n\n#### hide()\nHides the annotation if showing. This is not animated. \n\n#### remove()\nUnlinks the annotation from the element. \n\n#### Updating styles\nAll the properties in the configuration are also exposed in this object. e.g. if you'd like to change the color, you can do that after the annotation has been drawn.\n\n```javascript\nconst e = document.querySelector('#myElement');\nconst annotation = annotate(e, { type: 'underline', color: 'red' });\nannotation.show();\nannotation.color = 'green';\n```\n\n*Note: the type of the annotation cannot be changed. Create a new annotation for that.*\n\n## Annotation Group Object\n\nWhen you call the `annotationGroup` function, you get back an annotation group object, which has the following methods:\n\n#### show()\nDraws all the annotations in order. If the annotation is set to animate (default), it will animate the drawing. \n\n#### hide()\nHides all the annotations if showing. This is not animated.\n\n## Wrappers\n\nOthers have created handy Rough Notation wrappers for multiple libraries and frameworks:\n\n-   [React Rough Notation](https://github.com/linkstrifer/react-rough-notation)\n-   [Svelte Rough Notation](https://github.com/dimfeld/svelte-rough-notation)\n-   [Vue Rough Notation](https://github.com/Leecason/vue-rough-notation)\n-   [Web Component Rough Notation](https://github.com/Matsuuu/vanilla-rough-notation)\n-   [Angular Rough Notation](https://github.com/mikyaj/ngx-rough-notation)\n\n## Contributors\n\n### Financial Contributors\n\nBecome a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/rough/contribute)]\n\n#### Individuals\n\n\u003ca href=\"https://opencollective.com/rough\"\u003e\u003cimg src=\"https://opencollective.com/rough/individuals.svg?width=890\"\u003e\u003c/a\u003e\n\n#### Organizations\n\nSupport this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/rough/contribute)]\n\n\u003ca href=\"https://opencollective.com/rough/organization/0/website\"\u003e\u003cimg src=\"https://opencollective.com/rough/organization/0/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rough/organization/1/website\"\u003e\u003cimg src=\"https://opencollective.com/rough/organization/1/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rough/organization/2/website\"\u003e\u003cimg src=\"https://opencollective.com/rough/organization/2/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rough/organization/3/website\"\u003e\u003cimg src=\"https://opencollective.com/rough/organization/3/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rough/organization/4/website\"\u003e\u003cimg src=\"https://opencollective.com/rough/organization/4/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rough/organization/5/website\"\u003e\u003cimg src=\"https://opencollective.com/rough/organization/5/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rough/organization/6/website\"\u003e\u003cimg src=\"https://opencollective.com/rough/organization/6/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rough/organization/7/website\"\u003e\u003cimg src=\"https://opencollective.com/rough/organization/7/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rough/organization/8/website\"\u003e\u003cimg src=\"https://opencollective.com/rough/organization/8/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rough/organization/9/website\"\u003e\u003cimg src=\"https://opencollective.com/rough/organization/9/avatar.svg\"\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frough-stuff%2Frough-notation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frough-stuff%2Frough-notation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frough-stuff%2Frough-notation/lists"}