webmarker-js 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/main.js +4 -4
- package/dist/module.js +4 -4
- package/package.json +2 -2
- package/playwright-report/index.html +68 -0
- package/src/index.ts +4 -3
- package/chrome-extension/dist/index.d.ts +0 -72
- package/chrome-extension/dist/main.js +0 -1069
- package/chrome-extension/dist/module.js +0 -1048
package/src/index.ts
CHANGED
@@ -91,7 +91,7 @@ let cleanupFns: (() => void)[] = [];
|
|
91
91
|
function mark(options: MarkOptions = {}): Record<string, MarkedElement> {
|
92
92
|
try {
|
93
93
|
const {
|
94
|
-
selector =
|
94
|
+
selector = 'a[href], button, input:not([type="hidden"]), select, textarea, summary, [role="button"], [tabindex]:not([tabindex="-1"])',
|
95
95
|
getLabel = (_, index) => index.toString(),
|
96
96
|
markAttribute = "data-mark-label",
|
97
97
|
markPlacement = "top-start",
|
@@ -138,7 +138,7 @@ function mark(options: MarkOptions = {}): Record<string, MarkedElement> {
|
|
138
138
|
fragment.appendChild(markElement);
|
139
139
|
|
140
140
|
const boundingBoxElement = showBoundingBoxes
|
141
|
-
? createBoundingBox(element, boundingBoxStyle, label, boundingBoxClass)
|
141
|
+
? createBoundingBox(element, index, boundingBoxStyle, label, boundingBoxClass)
|
142
142
|
: undefined;
|
143
143
|
if (boundingBoxElement) {
|
144
144
|
fragment.appendChild(boundingBoxElement);
|
@@ -190,6 +190,7 @@ function createMark(
|
|
190
190
|
|
191
191
|
function createBoundingBox(
|
192
192
|
element: Element,
|
193
|
+
index: number,
|
193
194
|
style: StyleObject | StyleFunction,
|
194
195
|
label: string,
|
195
196
|
boundingBoxClass: string
|
@@ -215,7 +216,7 @@ function createBoundingBox(
|
|
215
216
|
position: "absolute",
|
216
217
|
pointerEvents: "none",
|
217
218
|
},
|
218
|
-
typeof style === "function" ? style(element,
|
219
|
+
typeof style === "function" ? style(element, index) : style
|
219
220
|
);
|
220
221
|
return boundingBoxElement;
|
221
222
|
}
|
@@ -1,72 +0,0 @@
|
|
1
|
-
type Placement = "top" | "top-start" | "top-end" | "right" | "right-start" | "right-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "left-start" | "left-end";
|
2
|
-
type StyleFunction = (element: Element, index: number) => Partial<CSSStyleDeclaration>;
|
3
|
-
type StyleObject = Partial<CSSStyleDeclaration>;
|
4
|
-
interface MarkOptions {
|
5
|
-
/**
|
6
|
-
* A CSS selector to query the elements to be marked.
|
7
|
-
*/
|
8
|
-
selector?: string;
|
9
|
-
/**
|
10
|
-
* Provide a function for generating labels.
|
11
|
-
* By default, labels are generated as numbers starting from 0.
|
12
|
-
*/
|
13
|
-
getLabel?: (element: Element, index: number) => string;
|
14
|
-
/**
|
15
|
-
* Name for the attribute added to the marked elements to store the mark label.
|
16
|
-
*
|
17
|
-
* @default 'data-mark-label'
|
18
|
-
*/
|
19
|
-
markAttribute?: string;
|
20
|
-
/**
|
21
|
-
* The placement of the mark relative to the element.
|
22
|
-
*
|
23
|
-
* @default 'top-start'
|
24
|
-
*/
|
25
|
-
markPlacement?: Placement;
|
26
|
-
/**
|
27
|
-
* A CSS style to apply to the label element.
|
28
|
-
* You can also specify a function that returns a CSS style object.
|
29
|
-
*/
|
30
|
-
markStyle?: StyleObject | StyleFunction;
|
31
|
-
/**
|
32
|
-
* A CSS style to apply to the bounding box element.
|
33
|
-
* You can also specify a function that returns a CSS style object.
|
34
|
-
* Bounding boxes are only shown if `showBoundingBoxes` is `true`.
|
35
|
-
*/
|
36
|
-
boundingBoxStyle?: StyleObject | StyleFunction;
|
37
|
-
/**
|
38
|
-
* Whether or not to show bounding boxes around the elements.
|
39
|
-
*
|
40
|
-
* @default true
|
41
|
-
*/
|
42
|
-
showBoundingBoxes?: boolean;
|
43
|
-
/**
|
44
|
-
* Provide a container element to query the elements to be marked.
|
45
|
-
* By default, the container element is `document.body`.
|
46
|
-
*/
|
47
|
-
containerElement?: Element;
|
48
|
-
/**
|
49
|
-
* Only mark elements that are visible in the current viewport
|
50
|
-
*
|
51
|
-
* @default false
|
52
|
-
*/
|
53
|
-
viewPortOnly?: boolean;
|
54
|
-
/**
|
55
|
-
* Additional class to apply to the mark elements.
|
56
|
-
*/
|
57
|
-
markClass?: string;
|
58
|
-
/**
|
59
|
-
* Additional class to apply to the bounding box elements.
|
60
|
-
*/
|
61
|
-
boundingBoxClass?: string;
|
62
|
-
}
|
63
|
-
interface MarkedElement {
|
64
|
-
element: Element;
|
65
|
-
markElement: HTMLElement;
|
66
|
-
boundingBoxElement?: HTMLElement;
|
67
|
-
}
|
68
|
-
declare function mark(options?: MarkOptions): Record<string, MarkedElement>;
|
69
|
-
declare function unmark(): void;
|
70
|
-
declare function isMarked(): boolean;
|
71
|
-
export { mark, unmark, isMarked };
|
72
|
-
export type { MarkOptions, MarkedElement, Placement };
|