
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
react-svg-annotation
Advanced tools
The SVG Annotation Tool
Checkout Storybook Demo to get more information!
# use yarn
yarn add react-svg-annotation
# use npm
npm install react-svg-annotation
import { SvgAnnotation } from "react-svg-annotation";
const Example = () => {
return <SvgAnnotation width={400} height={400} />;
};
export default Example;
If SvgAnnotation
Component is not suitable for your use case, you may combine useSvgAnnotation
and SvgRenderer
to make your own component
import { useSvgAnnotation, SvgRenderer } from "react-svg-annotation";
const Example = () => {
const { svgProps, changeTool, tool } = useSvgAnnotation({
styleOption: {
color: "black",
fillColor: "transparent",
lineWidth: 5,
},
});
return (
<div>
<div>{/* Custom Control Component */}</div>
<SvgRenderer {...svgProps} width={400} height={400} />
</div>
);
};
export default Example;
Annotation
type Annotation = Array<SVGObject>; // list of SVG Object
SVGStyleOption
type SVGStyleOption = Partial<{
color: string;
lineWidth: number;
fillColor: string;
}>;
Property | Type | Description | Default Value |
---|---|---|---|
color | string | stroke color of svg element | black |
fillColor | string | fill color of svg element | transparent |
lineWidth | number | stroke width of svg element | 5 |
SvgAnnotation
Componentinterface SvgAnnotationProps extends SVGStyleOption {
backgroundImage?: string;
width?: number;
height?: number;
value?: Annotation;
onChange?: (value: Annotation) => void;
}
Property | Type | Description | Default Value |
---|---|---|---|
backgroundImage | string | custom background image url | NA |
width | number | width of svg | 400 |
height | number | height of svg | 400 |
value | Annotation | Annotation Object | undefined |
onChange | (value: Annotation) => void | handle change function | undefined |
useSvgAnnotation
hooktype UseSvgAnnotationParams = {
styleOption?: SVGStyleOption;
value?: Annotation;
onChange?: (value: Annotation) => void;
};
type UseSvgAnnotation<T extends SVGSVGElement> = (options?: UseSvgAnnotationParams) => {
svgProps: SvgRendererProps;
tool: Tools;
changeTool: (value: Tools) => void;
download: (type: ImageType) => void;
toSvgString: () => string | null;
};
SvgRenderer
Componentinterface SvgRendererProps extends SVGAttributes<SVGSVGElement> {
tool: Tools;
annotation: Annotation;
currentSVGObject: SVGObject | null;
shapeControl: ShapeControl | null;
}
FAQs
SVG Annotation Component
The npm package react-svg-annotation receives a total of 7 weekly downloads. As such, react-svg-annotation popularity was classified as not popular.
We found that react-svg-annotation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.