@openpicker/sdk 0.2.3 → 0.2.5
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 +27 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @openpicker/sdk
|
|
2
2
|
|
|
3
|
-
SDK for invoking the [
|
|
3
|
+
SDK for invoking the [OpenPicker](https://openpicker.dev) browser extension to pick a CSS selector
|
|
4
4
|
on any page. Website: [openpicker.dev](https://openpicker.dev) · Docs:
|
|
5
5
|
[docs.openpicker.dev](https://docs.openpicker.dev) · Live demo:
|
|
6
6
|
[demo.openpicker.dev](https://demo.openpicker.dev)
|
|
@@ -23,7 +23,7 @@ if (await op.isAvailable()) {
|
|
|
23
23
|
})
|
|
24
24
|
console.log(selector, matchCount, element)
|
|
25
25
|
} else {
|
|
26
|
-
// Prompt the user to install the
|
|
26
|
+
// Prompt the user to install the OpenPicker extension.
|
|
27
27
|
}
|
|
28
28
|
```
|
|
29
29
|
|
|
@@ -61,8 +61,31 @@ if (!matchesSelectorConfig(selector, config)) {
|
|
|
61
61
|
}
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
The picker won't return a selector that violates the active rules — it offers a conforming one or
|
|
65
|
+
none. See [Configuring selectors](https://docs.openpicker.dev/guide/configuring-selectors) for the
|
|
66
|
+
full model.
|
|
67
|
+
|
|
68
|
+
## Restrict which element can be picked
|
|
69
|
+
|
|
70
|
+
`selector` shapes **how** a selector is built; `mustMatch` controls **which** element can be picked.
|
|
71
|
+
Pass a CSS selector and only matching elements are selectable (hovering a descendant snaps to the
|
|
72
|
+
nearest matching ancestor; non-matching elements aren't selectable):
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
op.pick({ url, mustMatch: "input, textarea, select, [contenteditable]" })
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The two axes are independent and compose — e.g. "only inputs, identified by id":
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
op.pick({
|
|
82
|
+
url,
|
|
83
|
+
mustMatch: "input, textarea, select, [contenteditable]",
|
|
84
|
+
selector: { class: { enabled: false }, attr: { enabled: false }, tag: { enabled: false } },
|
|
85
|
+
})
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
An invalid `mustMatch` rejects the pick with `invalid_params`.
|
|
66
89
|
|
|
67
90
|
## More
|
|
68
91
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpicker/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Open-source CSS element picker — SDK for invoking the openpicker browser extension.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Usertour (https://www.usertour.io)",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"registry": "https://registry.npmjs.org/"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@openpicker/protocol": "^0.1.
|
|
46
|
+
"@openpicker/protocol": "^0.1.3"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"tsup": "^8.5.0",
|