@critique.work/agentation 2.3.0 → 2.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/dist/index.d.mts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +46 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -33,6 +33,9 @@ type Annotation = {
|
|
|
33
33
|
}>;
|
|
34
34
|
drawingIndex?: number;
|
|
35
35
|
strokeId?: string;
|
|
36
|
+
lineText?: string;
|
|
37
|
+
contextBefore?: string[];
|
|
38
|
+
contextAfter?: string[];
|
|
36
39
|
sessionId?: string;
|
|
37
40
|
url?: string;
|
|
38
41
|
intent?: AnnotationIntent;
|
|
@@ -273,6 +276,21 @@ declare function identifyElement(target: HTMLElement): {
|
|
|
273
276
|
* Gets text content from element and siblings for context
|
|
274
277
|
*/
|
|
275
278
|
declare function getNearbyText(element: HTMLElement): string;
|
|
279
|
+
/**
|
|
280
|
+
* Surrounding context from sibling nodes in a repeated structure.
|
|
281
|
+
* Walks up the DOM to find the nearest ancestor that is one of many
|
|
282
|
+
* siblings (e.g. lines in a diff, rows in a table, items in a list),
|
|
283
|
+
* then collects text from N siblings before and after.
|
|
284
|
+
*/
|
|
285
|
+
interface SurroundingContext {
|
|
286
|
+
/** Text of the node the annotation is on */
|
|
287
|
+
lineText: string;
|
|
288
|
+
/** Text of preceding sibling nodes (oldest first) */
|
|
289
|
+
contextBefore: string[];
|
|
290
|
+
/** Text of following sibling nodes (closest first) */
|
|
291
|
+
contextAfter: string[];
|
|
292
|
+
}
|
|
293
|
+
declare function getSurroundingNodes(element: HTMLElement, radius?: number): SurroundingContext | null;
|
|
276
294
|
/**
|
|
277
295
|
* Simplified element identifier for animation feedback (less verbose)
|
|
278
296
|
*/
|
|
@@ -286,4 +304,4 @@ declare function getStorageKey(pathname: string): string;
|
|
|
286
304
|
declare function loadAnnotations<T = Annotation>(pathname: string): T[];
|
|
287
305
|
declare function saveAnnotations<T = Annotation>(pathname: string, annotations: T[]): void;
|
|
288
306
|
|
|
289
|
-
export { PageFeedbackToolbarCSS as Agentation, type AgentationProps, AnimatedBunny, type Annotation, AnnotationPopupCSS, type AnnotationPopupCSSHandle, type AnnotationPopupCSSProps, type DemoAnnotation, IconChatEllipsis, IconCheck, IconCheckSmall, IconCheckSmallAnimated, IconCheckmark, IconCheckmarkCircle, IconCheckmarkLarge, IconChevronLeft, IconChevronRight, IconClose, IconCopyAlt, IconCopyAnimated, IconEdit, IconEye, IconEyeAlt, IconEyeAnimated, IconEyeClosed, IconEyeMinus, IconGear, IconHelp, IconListSparkle, IconMoon, IconPause, IconPauseAlt, IconPausePlayAnimated, IconPencil, IconPlayAlt, IconPlus, IconSendAnimated, IconSendArrow, IconSun, IconTrash, IconTrashAlt, IconXmark, IconXmarkLarge, PageFeedbackToolbarCSS, closestCrossingShadow, getElementClasses, getElementPath, getNearbyText, getShadowHost, getStorageKey, identifyAnimationElement, identifyElement, isInShadowDOM, loadAnnotations, saveAnnotations };
|
|
307
|
+
export { PageFeedbackToolbarCSS as Agentation, type AgentationProps, AnimatedBunny, type Annotation, AnnotationPopupCSS, type AnnotationPopupCSSHandle, type AnnotationPopupCSSProps, type DemoAnnotation, IconChatEllipsis, IconCheck, IconCheckSmall, IconCheckSmallAnimated, IconCheckmark, IconCheckmarkCircle, IconCheckmarkLarge, IconChevronLeft, IconChevronRight, IconClose, IconCopyAlt, IconCopyAnimated, IconEdit, IconEye, IconEyeAlt, IconEyeAnimated, IconEyeClosed, IconEyeMinus, IconGear, IconHelp, IconListSparkle, IconMoon, IconPause, IconPauseAlt, IconPausePlayAnimated, IconPencil, IconPlayAlt, IconPlus, IconSendAnimated, IconSendArrow, IconSun, IconTrash, IconTrashAlt, IconXmark, IconXmarkLarge, PageFeedbackToolbarCSS, type SurroundingContext, closestCrossingShadow, getElementClasses, getElementPath, getNearbyText, getShadowHost, getStorageKey, getSurroundingNodes, identifyAnimationElement, identifyElement, isInShadowDOM, loadAnnotations, saveAnnotations };
|
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,9 @@ type Annotation = {
|
|
|
33
33
|
}>;
|
|
34
34
|
drawingIndex?: number;
|
|
35
35
|
strokeId?: string;
|
|
36
|
+
lineText?: string;
|
|
37
|
+
contextBefore?: string[];
|
|
38
|
+
contextAfter?: string[];
|
|
36
39
|
sessionId?: string;
|
|
37
40
|
url?: string;
|
|
38
41
|
intent?: AnnotationIntent;
|
|
@@ -273,6 +276,21 @@ declare function identifyElement(target: HTMLElement): {
|
|
|
273
276
|
* Gets text content from element and siblings for context
|
|
274
277
|
*/
|
|
275
278
|
declare function getNearbyText(element: HTMLElement): string;
|
|
279
|
+
/**
|
|
280
|
+
* Surrounding context from sibling nodes in a repeated structure.
|
|
281
|
+
* Walks up the DOM to find the nearest ancestor that is one of many
|
|
282
|
+
* siblings (e.g. lines in a diff, rows in a table, items in a list),
|
|
283
|
+
* then collects text from N siblings before and after.
|
|
284
|
+
*/
|
|
285
|
+
interface SurroundingContext {
|
|
286
|
+
/** Text of the node the annotation is on */
|
|
287
|
+
lineText: string;
|
|
288
|
+
/** Text of preceding sibling nodes (oldest first) */
|
|
289
|
+
contextBefore: string[];
|
|
290
|
+
/** Text of following sibling nodes (closest first) */
|
|
291
|
+
contextAfter: string[];
|
|
292
|
+
}
|
|
293
|
+
declare function getSurroundingNodes(element: HTMLElement, radius?: number): SurroundingContext | null;
|
|
276
294
|
/**
|
|
277
295
|
* Simplified element identifier for animation feedback (less verbose)
|
|
278
296
|
*/
|
|
@@ -286,4 +304,4 @@ declare function getStorageKey(pathname: string): string;
|
|
|
286
304
|
declare function loadAnnotations<T = Annotation>(pathname: string): T[];
|
|
287
305
|
declare function saveAnnotations<T = Annotation>(pathname: string, annotations: T[]): void;
|
|
288
306
|
|
|
289
|
-
export { PageFeedbackToolbarCSS as Agentation, type AgentationProps, AnimatedBunny, type Annotation, AnnotationPopupCSS, type AnnotationPopupCSSHandle, type AnnotationPopupCSSProps, type DemoAnnotation, IconChatEllipsis, IconCheck, IconCheckSmall, IconCheckSmallAnimated, IconCheckmark, IconCheckmarkCircle, IconCheckmarkLarge, IconChevronLeft, IconChevronRight, IconClose, IconCopyAlt, IconCopyAnimated, IconEdit, IconEye, IconEyeAlt, IconEyeAnimated, IconEyeClosed, IconEyeMinus, IconGear, IconHelp, IconListSparkle, IconMoon, IconPause, IconPauseAlt, IconPausePlayAnimated, IconPencil, IconPlayAlt, IconPlus, IconSendAnimated, IconSendArrow, IconSun, IconTrash, IconTrashAlt, IconXmark, IconXmarkLarge, PageFeedbackToolbarCSS, closestCrossingShadow, getElementClasses, getElementPath, getNearbyText, getShadowHost, getStorageKey, identifyAnimationElement, identifyElement, isInShadowDOM, loadAnnotations, saveAnnotations };
|
|
307
|
+
export { PageFeedbackToolbarCSS as Agentation, type AgentationProps, AnimatedBunny, type Annotation, AnnotationPopupCSS, type AnnotationPopupCSSHandle, type AnnotationPopupCSSProps, type DemoAnnotation, IconChatEllipsis, IconCheck, IconCheckSmall, IconCheckSmallAnimated, IconCheckmark, IconCheckmarkCircle, IconCheckmarkLarge, IconChevronLeft, IconChevronRight, IconClose, IconCopyAlt, IconCopyAnimated, IconEdit, IconEye, IconEyeAlt, IconEyeAnimated, IconEyeClosed, IconEyeMinus, IconGear, IconHelp, IconListSparkle, IconMoon, IconPause, IconPauseAlt, IconPausePlayAnimated, IconPencil, IconPlayAlt, IconPlus, IconSendAnimated, IconSendArrow, IconSun, IconTrash, IconTrashAlt, IconXmark, IconXmarkLarge, PageFeedbackToolbarCSS, type SurroundingContext, closestCrossingShadow, getElementClasses, getElementPath, getNearbyText, getShadowHost, getStorageKey, getSurroundingNodes, identifyAnimationElement, identifyElement, isInShadowDOM, loadAnnotations, saveAnnotations };
|
package/dist/index.js
CHANGED
|
@@ -66,6 +66,7 @@ __export(index_exports, {
|
|
|
66
66
|
getNearbyText: () => getNearbyText,
|
|
67
67
|
getShadowHost: () => getShadowHost,
|
|
68
68
|
getStorageKey: () => getStorageKey,
|
|
69
|
+
getSurroundingNodes: () => getSurroundingNodes,
|
|
69
70
|
identifyAnimationElement: () => identifyAnimationElement,
|
|
70
71
|
identifyElement: () => identifyElement,
|
|
71
72
|
isInShadowDOM: () => isInShadowDOM,
|
|
@@ -2230,6 +2231,32 @@ function getNearbyText(element) {
|
|
|
2230
2231
|
}
|
|
2231
2232
|
return texts.join(" ");
|
|
2232
2233
|
}
|
|
2234
|
+
var MIN_SIBLINGS = 3;
|
|
2235
|
+
function getSurroundingNodes(element, radius = 3) {
|
|
2236
|
+
let node = element;
|
|
2237
|
+
while (node) {
|
|
2238
|
+
const parent = node.parentElement;
|
|
2239
|
+
if (parent && parent.children.length >= MIN_SIBLINGS) break;
|
|
2240
|
+
node = node.parentElement;
|
|
2241
|
+
}
|
|
2242
|
+
if (!node) return null;
|
|
2243
|
+
const lineText = (node.textContent ?? "").replace(/\n/g, " ").trim();
|
|
2244
|
+
const contextBefore = [];
|
|
2245
|
+
let prev = node.previousElementSibling;
|
|
2246
|
+
for (let i3 = 0; i3 < radius && prev; i3++) {
|
|
2247
|
+
const text = (prev.textContent ?? "").replace(/\n/g, " ").trim();
|
|
2248
|
+
if (text) contextBefore.unshift(text);
|
|
2249
|
+
prev = prev.previousElementSibling;
|
|
2250
|
+
}
|
|
2251
|
+
const contextAfter = [];
|
|
2252
|
+
let next = node.nextElementSibling;
|
|
2253
|
+
for (let i3 = 0; i3 < radius && next; i3++) {
|
|
2254
|
+
const text = (next.textContent ?? "").replace(/\n/g, " ").trim();
|
|
2255
|
+
if (text) contextAfter.push(text);
|
|
2256
|
+
next = next.nextElementSibling;
|
|
2257
|
+
}
|
|
2258
|
+
return { lineText, contextBefore, contextAfter };
|
|
2259
|
+
}
|
|
2233
2260
|
function identifyAnimationElement(target) {
|
|
2234
2261
|
if (target.dataset.element) return target.dataset.element;
|
|
2235
2262
|
const tag = target.tagName.toLowerCase();
|
|
@@ -4010,7 +4037,8 @@ function PageFeedbackToolbarCSS({
|
|
|
4010
4037
|
nearbyElements: getNearbyElements(firstEl),
|
|
4011
4038
|
cssClasses: getElementClasses(firstEl),
|
|
4012
4039
|
nearbyText: getNearbyText(firstEl),
|
|
4013
|
-
reactComponents: firstItem.reactComponents
|
|
4040
|
+
reactComponents: firstItem.reactComponents,
|
|
4041
|
+
...getSurroundingNodes(firstEl)
|
|
4014
4042
|
});
|
|
4015
4043
|
} else {
|
|
4016
4044
|
const bounds = {
|
|
@@ -4057,7 +4085,8 @@ function PageFeedbackToolbarCSS({
|
|
|
4057
4085
|
computedStylesObj: getDetailedComputedStyles(firstEl),
|
|
4058
4086
|
nearbyElements: getNearbyElements(firstEl),
|
|
4059
4087
|
cssClasses: getElementClasses(firstEl),
|
|
4060
|
-
nearbyText: getNearbyText(firstEl)
|
|
4088
|
+
nearbyText: getNearbyText(firstEl),
|
|
4089
|
+
...getSurroundingNodes(firstEl)
|
|
4061
4090
|
});
|
|
4062
4091
|
}
|
|
4063
4092
|
setPendingMultiSelectElements([]);
|
|
@@ -4297,7 +4326,8 @@ function PageFeedbackToolbarCSS({
|
|
|
4297
4326
|
reactComponents: reactComponents2 ?? void 0,
|
|
4298
4327
|
targetElement: elementUnder2 ?? void 0,
|
|
4299
4328
|
drawingIndex: strokeIdx,
|
|
4300
|
-
strokeId: stroke.id
|
|
4329
|
+
strokeId: stroke.id,
|
|
4330
|
+
...elementUnder2 ? getSurroundingNodes(elementUnder2) : {}
|
|
4301
4331
|
});
|
|
4302
4332
|
setHoverInfo(null);
|
|
4303
4333
|
setHoveredDrawingIdx(null);
|
|
@@ -4399,8 +4429,9 @@ function PageFeedbackToolbarCSS({
|
|
|
4399
4429
|
computedStylesObj,
|
|
4400
4430
|
nearbyElements: getNearbyElements(elementUnder),
|
|
4401
4431
|
reactComponents: reactComponents ?? void 0,
|
|
4402
|
-
targetElement: elementUnder
|
|
4432
|
+
targetElement: elementUnder,
|
|
4403
4433
|
// Store for live position queries
|
|
4434
|
+
...getSurroundingNodes(elementUnder)
|
|
4404
4435
|
});
|
|
4405
4436
|
setHoverInfo(null);
|
|
4406
4437
|
};
|
|
@@ -4717,7 +4748,8 @@ function PageFeedbackToolbarCSS({
|
|
|
4717
4748
|
computedStylesObj: firstElementComputedStyles,
|
|
4718
4749
|
nearbyElements: getNearbyElements(firstElement),
|
|
4719
4750
|
cssClasses: getElementClasses(firstElement),
|
|
4720
|
-
nearbyText: getNearbyText(firstElement)
|
|
4751
|
+
nearbyText: getNearbyText(firstElement),
|
|
4752
|
+
...getSurroundingNodes(firstElement)
|
|
4721
4753
|
});
|
|
4722
4754
|
} else {
|
|
4723
4755
|
const width = Math.abs(right - left);
|
|
@@ -4921,7 +4953,8 @@ function PageFeedbackToolbarCSS({
|
|
|
4921
4953
|
reactComponents: reactComponents ?? void 0,
|
|
4922
4954
|
targetElement: elementUnder ?? void 0,
|
|
4923
4955
|
drawingIndex: strokeIdx,
|
|
4924
|
-
strokeId: stroke.id
|
|
4956
|
+
strokeId: stroke.id,
|
|
4957
|
+
...elementUnder ? getSurroundingNodes(elementUnder) : {}
|
|
4925
4958
|
});
|
|
4926
4959
|
setHoverInfo(null);
|
|
4927
4960
|
setHoveredDrawingIdx(null);
|
|
@@ -5024,7 +5057,8 @@ function PageFeedbackToolbarCSS({
|
|
|
5024
5057
|
reactComponents: reactComponents ?? void 0,
|
|
5025
5058
|
targetElement: centerEl ?? void 0,
|
|
5026
5059
|
drawingIndex: newStrokeIdx,
|
|
5027
|
-
strokeId: newStrokeId
|
|
5060
|
+
strokeId: newStrokeId,
|
|
5061
|
+
...centerEl ? getSurroundingNodes(centerEl) : {}
|
|
5028
5062
|
});
|
|
5029
5063
|
setHoverInfo(null);
|
|
5030
5064
|
}
|
|
@@ -5151,6 +5185,9 @@ function PageFeedbackToolbarCSS({
|
|
|
5151
5185
|
elementBoundingBoxes: pendingAnnotation.elementBoundingBoxes,
|
|
5152
5186
|
drawingIndex: pendingAnnotation.drawingIndex,
|
|
5153
5187
|
strokeId: pendingAnnotation.strokeId,
|
|
5188
|
+
lineText: pendingAnnotation.lineText,
|
|
5189
|
+
contextBefore: pendingAnnotation.contextBefore,
|
|
5190
|
+
contextAfter: pendingAnnotation.contextAfter,
|
|
5154
5191
|
// Protocol fields for server sync
|
|
5155
5192
|
...endpoint && currentSessionId ? {
|
|
5156
5193
|
sessionId: currentSessionId,
|
|
@@ -6109,7 +6146,7 @@ function PageFeedbackToolbarCSS({
|
|
|
6109
6146
|
] }),
|
|
6110
6147
|
/* @__PURE__ */ u3("span", { className: styles_module_default2.settingsVersion, children: [
|
|
6111
6148
|
"v",
|
|
6112
|
-
"2.
|
|
6149
|
+
"2.4.0"
|
|
6113
6150
|
] }),
|
|
6114
6151
|
/* @__PURE__ */ u3(
|
|
6115
6152
|
"button",
|
|
@@ -7102,6 +7139,7 @@ function PageFeedbackToolbarCSS({
|
|
|
7102
7139
|
getNearbyText,
|
|
7103
7140
|
getShadowHost,
|
|
7104
7141
|
getStorageKey,
|
|
7142
|
+
getSurroundingNodes,
|
|
7105
7143
|
identifyAnimationElement,
|
|
7106
7144
|
identifyElement,
|
|
7107
7145
|
isInShadowDOM,
|