From 58375e6e3dc6f5e6895776a7f3f4b988eeeabe8a Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Wed, 21 Feb 2024 11:43:53 +0100 Subject: [PATCH] feat: support custom class --- src/rough-notation.ts | 2 +- src/types.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rough-notation.ts b/src/rough-notation.ts index 36fa4a9..88dbc36 100644 --- a/src/rough-notation.ts +++ b/src/rough-notation.ts @@ -74,7 +74,7 @@ class RoughAnnotationImpl implements RoughAnnotation { if (this._state === 'unattached' && this._e.parentElement) { ensureKeyframes(); const svg = this._svg = document.createElementNS(SVG_NS, 'svg'); - svg.setAttribute('class', 'rough-annotation'); + svg.setAttribute('class', ['rough-annotation', this._config.class || ''].filter(Boolean).join(' ')); const style = svg.style; style.position = 'absolute'; style.top = '0'; diff --git a/src/types.ts b/src/types.ts index 2649f4c..ce3b730 100644 --- a/src/types.ts +++ b/src/types.ts @@ -24,6 +24,8 @@ export interface RoughAnnotationConfigBase { padding?: RoughPadding; // defaults to 5px iterations?: number; // defaults to 2 brackets?: BracketType | BracketType[]; // defaults to 'right' + // Additional class added to the annotation + class?: string } export interface RoughAnnotation extends RoughAnnotationConfigBase {