rich-input 1.2.0 → 1.2.1
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 +7 -2
- package/package.json +1 -1
- package/utils/query-parser.js +8 -9
package/README.md
CHANGED
|
@@ -86,6 +86,7 @@ Nest `<datalist>` elements inside `<rich-input>` to configure keywords and autoc
|
|
|
86
86
|
<option value="Kranky"></option>
|
|
87
87
|
<option value="Madhouse Records"></option>
|
|
88
88
|
<option value="Ninja Tune"></option>
|
|
89
|
+
<option value="Warp Records"></option>
|
|
89
90
|
<option value="We Play House Recordings"></option>
|
|
90
91
|
<option value="XL Recordings"></option>
|
|
91
92
|
</datalist>
|
|
@@ -149,6 +150,10 @@ Datalists can be added, updated, or removed dynamically at runtime; `<rich-input
|
|
|
149
150
|
<img src="assets/ninja-tune.jpg" height="50" width="50" alt="Ninja Tune Logo">
|
|
150
151
|
Ninja Tune
|
|
151
152
|
</option>
|
|
153
|
+
<option value="Warp Records">
|
|
154
|
+
<img src="assets/warp-records.png" height="50" width="50" alt="Warp Records Logo">
|
|
155
|
+
Warp Records
|
|
156
|
+
</option>
|
|
152
157
|
<option value="We Play House Recordings">
|
|
153
158
|
<img src="assets/we-play-house-recordings.jpg" height="50" width="50" alt="We Play House Recordings Logo">
|
|
154
159
|
We Play House Recordings
|
|
@@ -245,7 +250,7 @@ In browsers without `OpaqueRange` that support the CSS Custom Highlight API (suc
|
|
|
245
250
|
Values corresponding to configured keywords are registered into the global `CSS.highlights` registry and styled using standard CSS `::highlight(keyword)` pseudo-elements in your stylesheet:
|
|
246
251
|
|
|
247
252
|
```css
|
|
248
|
-
/* Style the value set in label:"
|
|
253
|
+
/* Style the value set in label:"Warp Records" */
|
|
249
254
|
::highlight(label) {
|
|
250
255
|
background-color: oklch(0.92 0.08 240);
|
|
251
256
|
color: oklch(0.28 0.14 240);
|
|
@@ -282,7 +287,7 @@ In browsers using the `[contenteditable]` fallback inside Shadow DOM (such as Sa
|
|
|
282
287
|
For self-contained widgets or instance-specific style overrides, `<rich-input>` also supports an optional embedded `<style>` block as a direct child, which is automatically injected into the shadow root:
|
|
283
288
|
|
|
284
289
|
```html
|
|
285
|
-
<rich-input value='artist:"Aphex Twin" label:"
|
|
290
|
+
<rich-input value='artist:"Aphex Twin" label:"Warp Records"'>
|
|
286
291
|
<style>
|
|
287
292
|
::highlight(label) {
|
|
288
293
|
background-color: #dbeafe;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rich-input",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "A rich input field with keyword-based autocomplete and in-input highlighting powered by <datalist>, OpaqueRange, and the Custom Highlight API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
package/utils/query-parser.js
CHANGED
|
@@ -181,8 +181,8 @@ export function getCaretContext(inputStr, caretPos, configuredKeywords) {
|
|
|
181
181
|
// 1. Caret is within a keyword token
|
|
182
182
|
if (activeToken.type === 'keyword') {
|
|
183
183
|
if (caretPos <= activeToken.colonIndex) {
|
|
184
|
-
// User is editing the keyword name
|
|
185
|
-
const query =
|
|
184
|
+
// User is editing the keyword name (filter based on full keyword name, not caret position)
|
|
185
|
+
const query = activeToken.keyword;
|
|
186
186
|
return {
|
|
187
187
|
mode: 'keyword',
|
|
188
188
|
query,
|
|
@@ -193,17 +193,16 @@ export function getCaretContext(inputStr, caretPos, configuredKeywords) {
|
|
|
193
193
|
tokens,
|
|
194
194
|
};
|
|
195
195
|
} else {
|
|
196
|
-
// User is editing the keyword value
|
|
196
|
+
// User is editing the keyword value (filter based on full value string, not caret position)
|
|
197
197
|
const isQuoted = activeToken.quoted;
|
|
198
|
-
const
|
|
199
|
-
const innerEnd = activeToken.innerEnd;
|
|
200
|
-
const valuePrefix = inputStr.slice(innerStart, Math.min(caretPos, innerEnd));
|
|
198
|
+
const value = activeToken.innerValue;
|
|
201
199
|
|
|
202
200
|
return {
|
|
203
201
|
mode: 'value',
|
|
204
202
|
keyword: activeToken.keyword,
|
|
205
203
|
keywordLower: activeToken.keywordLower,
|
|
206
|
-
valuePrefix,
|
|
204
|
+
valuePrefix: value,
|
|
205
|
+
query: value,
|
|
207
206
|
quoted: isQuoted,
|
|
208
207
|
quoteChar: activeToken.quoteChar || '"',
|
|
209
208
|
isClosed: activeToken.isClosed,
|
|
@@ -216,9 +215,9 @@ export function getCaretContext(inputStr, caretPos, configuredKeywords) {
|
|
|
216
215
|
}
|
|
217
216
|
}
|
|
218
217
|
|
|
219
|
-
// 2. Caret is within a plain text token
|
|
218
|
+
// 2. Caret is within a plain text token (filter based on full word, not caret position)
|
|
220
219
|
if (activeToken.type === 'text') {
|
|
221
|
-
const query =
|
|
220
|
+
const query = activeToken.raw;
|
|
222
221
|
return {
|
|
223
222
|
mode: 'keyword',
|
|
224
223
|
query,
|