vite-plugin-ai-annotator 1.2.1 → 1.2.2
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/annotator/selection.d.ts +1 -0
- package/dist/annotator-toolbar.js +13 -117
- package/package.json +1 -1
|
@@ -20,6 +20,7 @@ export interface ElementSelectionManager {
|
|
|
20
20
|
findSelectedChildren(element: Element): Element[];
|
|
21
21
|
buildHierarchicalStructure(componentFinder?: ComponentFinder, imagePaths?: Map<Element, string>): ElementData[];
|
|
22
22
|
setOnEditClick(callback: (element: Element) => void): void;
|
|
23
|
+
getBadgeForElement(element: Element): HTMLElement | null;
|
|
23
24
|
}
|
|
24
25
|
export declare function createElementSelectionManager(): ElementSelectionManager;
|
|
25
26
|
export {};
|
|
@@ -4816,9 +4816,6 @@
|
|
|
4816
4816
|
}
|
|
4817
4817
|
|
|
4818
4818
|
// node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
|
|
4819
|
-
var sides = ["top", "right", "bottom", "left"];
|
|
4820
|
-
var alignments = ["start", "end"];
|
|
4821
|
-
var placements = /* @__PURE__ */ sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
|
|
4822
4819
|
var min = Math.min;
|
|
4823
4820
|
var max = Math.max;
|
|
4824
4821
|
var round = Math.round;
|
|
@@ -5144,102 +5141,6 @@
|
|
|
5144
5141
|
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
5145
5142
|
};
|
|
5146
5143
|
}
|
|
5147
|
-
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
|
|
5148
|
-
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter((placement) => getAlignment(placement) === alignment), ...allowedPlacements.filter((placement) => getAlignment(placement) !== alignment)] : allowedPlacements.filter((placement) => getSide(placement) === placement);
|
|
5149
|
-
return allowedPlacementsSortedByAlignment.filter((placement) => {
|
|
5150
|
-
if (alignment) {
|
|
5151
|
-
return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
|
|
5152
|
-
}
|
|
5153
|
-
return true;
|
|
5154
|
-
});
|
|
5155
|
-
}
|
|
5156
|
-
var autoPlacement = function(options) {
|
|
5157
|
-
if (options === void 0) {
|
|
5158
|
-
options = {};
|
|
5159
|
-
}
|
|
5160
|
-
return {
|
|
5161
|
-
name: "autoPlacement",
|
|
5162
|
-
options,
|
|
5163
|
-
async fn(state) {
|
|
5164
|
-
var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
|
|
5165
|
-
const {
|
|
5166
|
-
rects,
|
|
5167
|
-
middlewareData,
|
|
5168
|
-
placement,
|
|
5169
|
-
platform: platform2,
|
|
5170
|
-
elements
|
|
5171
|
-
} = state;
|
|
5172
|
-
const {
|
|
5173
|
-
crossAxis = false,
|
|
5174
|
-
alignment,
|
|
5175
|
-
allowedPlacements = placements,
|
|
5176
|
-
autoAlignment = true,
|
|
5177
|
-
...detectOverflowOptions
|
|
5178
|
-
} = evaluate(options, state);
|
|
5179
|
-
const placements$1 = alignment !== void 0 || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
|
|
5180
|
-
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
5181
|
-
const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
|
|
5182
|
-
const currentPlacement = placements$1[currentIndex];
|
|
5183
|
-
if (currentPlacement == null) {
|
|
5184
|
-
return {};
|
|
5185
|
-
}
|
|
5186
|
-
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)));
|
|
5187
|
-
if (placement !== currentPlacement) {
|
|
5188
|
-
return {
|
|
5189
|
-
reset: {
|
|
5190
|
-
placement: placements$1[0]
|
|
5191
|
-
}
|
|
5192
|
-
};
|
|
5193
|
-
}
|
|
5194
|
-
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
|
|
5195
|
-
const allOverflows = [...((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || [], {
|
|
5196
|
-
placement: currentPlacement,
|
|
5197
|
-
overflows: currentOverflows
|
|
5198
|
-
}];
|
|
5199
|
-
const nextPlacement = placements$1[currentIndex + 1];
|
|
5200
|
-
if (nextPlacement) {
|
|
5201
|
-
return {
|
|
5202
|
-
data: {
|
|
5203
|
-
index: currentIndex + 1,
|
|
5204
|
-
overflows: allOverflows
|
|
5205
|
-
},
|
|
5206
|
-
reset: {
|
|
5207
|
-
placement: nextPlacement
|
|
5208
|
-
}
|
|
5209
|
-
};
|
|
5210
|
-
}
|
|
5211
|
-
const placementsSortedByMostSpace = allOverflows.map((d3) => {
|
|
5212
|
-
const alignment2 = getAlignment(d3.placement);
|
|
5213
|
-
return [d3.placement, alignment2 && crossAxis ? (
|
|
5214
|
-
// Check along the mainAxis and main crossAxis side.
|
|
5215
|
-
d3.overflows.slice(0, 2).reduce((acc, v2) => acc + v2, 0)
|
|
5216
|
-
) : (
|
|
5217
|
-
// Check only the mainAxis.
|
|
5218
|
-
d3.overflows[0]
|
|
5219
|
-
), d3.overflows];
|
|
5220
|
-
}).sort((a3, b3) => a3[1] - b3[1]);
|
|
5221
|
-
const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter((d3) => d3[2].slice(
|
|
5222
|
-
0,
|
|
5223
|
-
// Aligned placements should not check their opposite crossAxis
|
|
5224
|
-
// side.
|
|
5225
|
-
getAlignment(d3[0]) ? 2 : 3
|
|
5226
|
-
).every((v2) => v2 <= 0));
|
|
5227
|
-
const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
|
|
5228
|
-
if (resetPlacement !== placement) {
|
|
5229
|
-
return {
|
|
5230
|
-
data: {
|
|
5231
|
-
index: currentIndex + 1,
|
|
5232
|
-
overflows: allOverflows
|
|
5233
|
-
},
|
|
5234
|
-
reset: {
|
|
5235
|
-
placement: resetPlacement
|
|
5236
|
-
}
|
|
5237
|
-
};
|
|
5238
|
-
}
|
|
5239
|
-
return {};
|
|
5240
|
-
}
|
|
5241
|
-
};
|
|
5242
|
-
};
|
|
5243
5144
|
var flip = function(options) {
|
|
5244
5145
|
if (options === void 0) {
|
|
5245
5146
|
options = {};
|
|
@@ -6232,7 +6133,6 @@
|
|
|
6232
6133
|
};
|
|
6233
6134
|
}
|
|
6234
6135
|
var offset2 = offset;
|
|
6235
|
-
var autoPlacement2 = autoPlacement;
|
|
6236
6136
|
var shift2 = shift;
|
|
6237
6137
|
var flip2 = flip;
|
|
6238
6138
|
var computePosition2 = (reference, floating, options) => {
|
|
@@ -6731,6 +6631,10 @@
|
|
|
6731
6631
|
setOnEditClick(callback) {
|
|
6732
6632
|
onEditClickCallback = callback;
|
|
6733
6633
|
},
|
|
6634
|
+
getBadgeForElement(element) {
|
|
6635
|
+
const group = selectionGroups.get(element);
|
|
6636
|
+
return group?.badge || null;
|
|
6637
|
+
},
|
|
6734
6638
|
buildHierarchicalStructure(componentFinder, imagePaths) {
|
|
6735
6639
|
const rootElements = [];
|
|
6736
6640
|
selectedElements.forEach((_2, element) => {
|
|
@@ -7982,25 +7886,17 @@
|
|
|
7982
7886
|
if (!popoverEl || !element) return;
|
|
7983
7887
|
if (textareaEl) {
|
|
7984
7888
|
textareaEl.focus();
|
|
7985
|
-
this.autoResizeTextarea(textareaEl
|
|
7986
|
-
}
|
|
7987
|
-
const
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
const y3 = Math.max(rect.top, 16);
|
|
7992
|
-
return new DOMRect(x2, y3, 0, 0);
|
|
7993
|
-
}
|
|
7994
|
-
};
|
|
7995
|
-
this.popoverCleanup = autoUpdate(element, popoverEl, () => {
|
|
7996
|
-
computePosition2(virtualRef, popoverEl, {
|
|
7889
|
+
this.autoResizeTextarea(textareaEl);
|
|
7890
|
+
}
|
|
7891
|
+
const badge = this.selectionManager?.getBadgeForElement(element);
|
|
7892
|
+
const referenceEl = badge || element;
|
|
7893
|
+
this.popoverCleanup = autoUpdate(referenceEl, popoverEl, () => {
|
|
7894
|
+
computePosition2(referenceEl, popoverEl, {
|
|
7997
7895
|
strategy: "fixed",
|
|
7896
|
+
placement: "bottom-start",
|
|
7998
7897
|
middleware: [
|
|
7999
|
-
offset2(
|
|
8000
|
-
|
|
8001
|
-
alignment: "start",
|
|
8002
|
-
allowedPlacements: ["bottom-start", "bottom-end", "top-start", "top-end"]
|
|
8003
|
-
}),
|
|
7898
|
+
offset2(6),
|
|
7899
|
+
flip2({ fallbackPlacements: ["bottom-end", "top-start", "top-end"] }),
|
|
8004
7900
|
shift2({ padding: 8 })
|
|
8005
7901
|
]
|
|
8006
7902
|
}).then(({ x: x2, y: y3 }) => {
|
package/package.json
CHANGED