rich-input 1.2.2 → 1.4.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/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { RichInput } from './components/rich-input.js';
7
- import { parseSearchTokens, parseSearchQuery, getCaretContext, getSuggestions, applySuggestion, isDatalistValue } from './utils/query-parser.js';
7
+ import { DEFAULT_OPERATORS, normalizeOperators, DEFAULT_COMBINATORS, normalizeCombinators, DEFAULT_DELIMITERS, normalizeDelimiters, parseSearchTokens, parseSearchQuery, getCaretContext, getSuggestions, applySuggestion, isDatalistValue } from './utils/query-parser.js';
8
8
  import { highlightManager, isOpaqueRangeSupported, isHighlightSupported } from './utils/highlights.js';
9
9
  import { getCaretCoordinates, getRangeCoordinates, positionPopover, getCaretLeftWithMirrorDiv } from './utils/positioning.js';
10
10
  import { setupContentEditableAdapter, isContentEditableFallbackActive } from './utils/contenteditable-adapter.js';
@@ -17,6 +17,12 @@ if (typeof customElements !== 'undefined') {
17
17
 
18
18
  export {
19
19
  RichInput,
20
+ DEFAULT_OPERATORS,
21
+ normalizeOperators,
22
+ DEFAULT_COMBINATORS,
23
+ normalizeCombinators,
24
+ DEFAULT_DELIMITERS,
25
+ normalizeDelimiters,
20
26
  parseSearchTokens,
21
27
  parseSearchQuery,
22
28
  getCaretContext,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rich-input",
3
- "version": "1.2.2",
3
+ "version": "1.4.0",
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",
@@ -31,5 +31,8 @@
31
31
  "bugs": {
32
32
  "url": "https://github.com/bramus/rich-input/issues"
33
33
  },
34
- "homepage": "https://github.com/bramus/rich-input#readme"
34
+ "homepage": "https://github.com/bramus/rich-input#readme",
35
+ "devDependencies": {
36
+ "puppeteer": "^25.11.0"
37
+ }
35
38
  }
@@ -52,6 +52,9 @@ class HighlightRegistryManager {
52
52
  const rangesByKeyword = new Map();
53
53
  const allKeywordRanges = [];
54
54
  const allValueRanges = [];
55
+ const allOperatorRanges = [];
56
+ const allCombinatorRanges = [];
57
+ const allDelimiterRanges = [];
55
58
  const allInvalidRanges = [];
56
59
 
57
60
  for (const inst of this.instances) {
@@ -74,6 +77,27 @@ class HighlightRegistryManager {
74
77
  }
75
78
  }
76
79
 
80
+ if (typeof inst.getActiveOperatorRanges === 'function') {
81
+ const opRanges = inst.getActiveOperatorRanges();
82
+ if (opRanges && opRanges.length > 0) {
83
+ allOperatorRanges.push(...opRanges);
84
+ }
85
+ }
86
+
87
+ if (typeof inst.getActiveCombinatorRanges === 'function') {
88
+ const combRanges = inst.getActiveCombinatorRanges();
89
+ if (combRanges && combRanges.length > 0) {
90
+ allCombinatorRanges.push(...combRanges);
91
+ }
92
+ }
93
+
94
+ if (typeof inst.getActiveDelimiterRanges === 'function') {
95
+ const delimRanges = inst.getActiveDelimiterRanges();
96
+ if (delimRanges && delimRanges.length > 0) {
97
+ allDelimiterRanges.push(...delimRanges);
98
+ }
99
+ }
100
+
77
101
  if (typeof inst.getActiveInvalidRanges === 'function') {
78
102
  const invRanges = inst.getActiveInvalidRanges();
79
103
  if (invRanges && invRanges.length > 0) {
@@ -104,6 +128,57 @@ class HighlightRegistryManager {
104
128
  }
105
129
 
106
130
  // 2. Set generic highlights
131
+ let opHl = CSS.highlights.get('rich-input-operator');
132
+ if (!opHl) {
133
+ try {
134
+ opHl = new Highlight();
135
+ CSS.highlights.set('rich-input-operator', opHl);
136
+ } catch (e) {}
137
+ }
138
+ if (opHl) {
139
+ opHl.clear();
140
+ for (const r of allOperatorRanges) {
141
+ try {
142
+ if (isRangeCollapsed(r)) continue;
143
+ opHl.add(r);
144
+ } catch (e) {}
145
+ }
146
+ }
147
+
148
+ let combHl = CSS.highlights.get('rich-input-combinator');
149
+ if (!combHl) {
150
+ try {
151
+ combHl = new Highlight();
152
+ CSS.highlights.set('rich-input-combinator', combHl);
153
+ } catch (e) {}
154
+ }
155
+ if (combHl) {
156
+ combHl.clear();
157
+ for (const r of allCombinatorRanges) {
158
+ try {
159
+ if (isRangeCollapsed(r)) continue;
160
+ combHl.add(r);
161
+ } catch (e) {}
162
+ }
163
+ }
164
+
165
+ let delimHl = CSS.highlights.get('rich-input-delimiter');
166
+ if (!delimHl) {
167
+ try {
168
+ delimHl = new Highlight();
169
+ CSS.highlights.set('rich-input-delimiter', delimHl);
170
+ } catch (e) {}
171
+ }
172
+ if (delimHl) {
173
+ delimHl.clear();
174
+ for (const r of allDelimiterRanges) {
175
+ try {
176
+ if (isRangeCollapsed(r)) continue;
177
+ delimHl.add(r);
178
+ } catch (e) {}
179
+ }
180
+ }
181
+
107
182
  let kwHl = CSS.highlights.get('rich-input-keyword');
108
183
  if (!kwHl) {
109
184
  try {