overtype 1.1.0 → 1.1.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/dist/overtype.esm.js +72 -1297
- package/dist/overtype.esm.js.map +4 -4
- package/dist/overtype.js +72 -1297
- package/dist/overtype.js.map +4 -4
- package/dist/overtype.min.js +83 -70
- package/package.json +1 -2
- package/src/link-tooltip.js +75 -149
- package/src/parser.js +17 -1
package/dist/overtype.js
CHANGED
|
@@ -38,6 +38,12 @@ var OverType = (() => {
|
|
|
38
38
|
|
|
39
39
|
// src/parser.js
|
|
40
40
|
var MarkdownParser = class {
|
|
41
|
+
/**
|
|
42
|
+
* Reset link index (call before parsing a new document)
|
|
43
|
+
*/
|
|
44
|
+
static resetLinkIndex() {
|
|
45
|
+
this.linkIndex = 0;
|
|
46
|
+
}
|
|
41
47
|
/**
|
|
42
48
|
* Escape HTML special characters
|
|
43
49
|
* @param {string} text - Raw text to escape
|
|
@@ -163,7 +169,10 @@ var OverType = (() => {
|
|
|
163
169
|
* @returns {string} HTML with link styling
|
|
164
170
|
*/
|
|
165
171
|
static parseLinks(html) {
|
|
166
|
-
return html.replace(/\[(.+?)\]\((.+?)\)/g,
|
|
172
|
+
return html.replace(/\[(.+?)\]\((.+?)\)/g, (match, text, url) => {
|
|
173
|
+
const anchorName = `--link-${this.linkIndex++}`;
|
|
174
|
+
return `<a href="${url}" style="anchor-name: ${anchorName}"><span class="syntax-marker">[</span>${text}<span class="syntax-marker">](</span><span class="syntax-marker">${url}</span><span class="syntax-marker">)</span></a>`;
|
|
175
|
+
});
|
|
167
176
|
}
|
|
168
177
|
/**
|
|
169
178
|
* Parse all inline elements in correct order
|
|
@@ -219,6 +228,7 @@ var OverType = (() => {
|
|
|
219
228
|
* @returns {string} Parsed HTML
|
|
220
229
|
*/
|
|
221
230
|
static parse(text, activeLine = -1, showActiveLineRaw = false) {
|
|
231
|
+
this.resetLinkIndex();
|
|
222
232
|
const lines = text.split("\n");
|
|
223
233
|
const parsedLines = lines.map((line, index) => {
|
|
224
234
|
if (showActiveLineRaw && index === activeLine) {
|
|
@@ -230,6 +240,8 @@ var OverType = (() => {
|
|
|
230
240
|
return parsedLines.join("");
|
|
231
241
|
}
|
|
232
242
|
};
|
|
243
|
+
// Track link index for anchor naming
|
|
244
|
+
__publicField(MarkdownParser, "linkIndex", 0);
|
|
233
245
|
|
|
234
246
|
// node_modules/markdown-actions/dist/markdown-actions.esm.js
|
|
235
247
|
var __defProp2 = Object.defineProperty;
|
|
@@ -1997,1190 +2009,6 @@ ${blockSuffix}` : suffix;
|
|
|
1997
2009
|
}
|
|
1998
2010
|
};
|
|
1999
2011
|
|
|
2000
|
-
// node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
|
|
2001
|
-
var min = Math.min;
|
|
2002
|
-
var max = Math.max;
|
|
2003
|
-
var round = Math.round;
|
|
2004
|
-
var createCoords = (v) => ({
|
|
2005
|
-
x: v,
|
|
2006
|
-
y: v
|
|
2007
|
-
});
|
|
2008
|
-
var oppositeSideMap = {
|
|
2009
|
-
left: "right",
|
|
2010
|
-
right: "left",
|
|
2011
|
-
bottom: "top",
|
|
2012
|
-
top: "bottom"
|
|
2013
|
-
};
|
|
2014
|
-
var oppositeAlignmentMap = {
|
|
2015
|
-
start: "end",
|
|
2016
|
-
end: "start"
|
|
2017
|
-
};
|
|
2018
|
-
function clamp(start, value, end) {
|
|
2019
|
-
return max(start, min(value, end));
|
|
2020
|
-
}
|
|
2021
|
-
function evaluate(value, param) {
|
|
2022
|
-
return typeof value === "function" ? value(param) : value;
|
|
2023
|
-
}
|
|
2024
|
-
function getSide(placement) {
|
|
2025
|
-
return placement.split("-")[0];
|
|
2026
|
-
}
|
|
2027
|
-
function getAlignment(placement) {
|
|
2028
|
-
return placement.split("-")[1];
|
|
2029
|
-
}
|
|
2030
|
-
function getOppositeAxis(axis) {
|
|
2031
|
-
return axis === "x" ? "y" : "x";
|
|
2032
|
-
}
|
|
2033
|
-
function getAxisLength(axis) {
|
|
2034
|
-
return axis === "y" ? "height" : "width";
|
|
2035
|
-
}
|
|
2036
|
-
var yAxisSides = /* @__PURE__ */ new Set(["top", "bottom"]);
|
|
2037
|
-
function getSideAxis(placement) {
|
|
2038
|
-
return yAxisSides.has(getSide(placement)) ? "y" : "x";
|
|
2039
|
-
}
|
|
2040
|
-
function getAlignmentAxis(placement) {
|
|
2041
|
-
return getOppositeAxis(getSideAxis(placement));
|
|
2042
|
-
}
|
|
2043
|
-
function getAlignmentSides(placement, rects, rtl) {
|
|
2044
|
-
if (rtl === void 0) {
|
|
2045
|
-
rtl = false;
|
|
2046
|
-
}
|
|
2047
|
-
const alignment = getAlignment(placement);
|
|
2048
|
-
const alignmentAxis = getAlignmentAxis(placement);
|
|
2049
|
-
const length = getAxisLength(alignmentAxis);
|
|
2050
|
-
let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
|
|
2051
|
-
if (rects.reference[length] > rects.floating[length]) {
|
|
2052
|
-
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
2053
|
-
}
|
|
2054
|
-
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
2055
|
-
}
|
|
2056
|
-
function getExpandedPlacements(placement) {
|
|
2057
|
-
const oppositePlacement = getOppositePlacement(placement);
|
|
2058
|
-
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
2059
|
-
}
|
|
2060
|
-
function getOppositeAlignmentPlacement(placement) {
|
|
2061
|
-
return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
|
|
2062
|
-
}
|
|
2063
|
-
var lrPlacement = ["left", "right"];
|
|
2064
|
-
var rlPlacement = ["right", "left"];
|
|
2065
|
-
var tbPlacement = ["top", "bottom"];
|
|
2066
|
-
var btPlacement = ["bottom", "top"];
|
|
2067
|
-
function getSideList(side, isStart, rtl) {
|
|
2068
|
-
switch (side) {
|
|
2069
|
-
case "top":
|
|
2070
|
-
case "bottom":
|
|
2071
|
-
if (rtl)
|
|
2072
|
-
return isStart ? rlPlacement : lrPlacement;
|
|
2073
|
-
return isStart ? lrPlacement : rlPlacement;
|
|
2074
|
-
case "left":
|
|
2075
|
-
case "right":
|
|
2076
|
-
return isStart ? tbPlacement : btPlacement;
|
|
2077
|
-
default:
|
|
2078
|
-
return [];
|
|
2079
|
-
}
|
|
2080
|
-
}
|
|
2081
|
-
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
2082
|
-
const alignment = getAlignment(placement);
|
|
2083
|
-
let list = getSideList(getSide(placement), direction === "start", rtl);
|
|
2084
|
-
if (alignment) {
|
|
2085
|
-
list = list.map((side) => side + "-" + alignment);
|
|
2086
|
-
if (flipAlignment) {
|
|
2087
|
-
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
2088
|
-
}
|
|
2089
|
-
}
|
|
2090
|
-
return list;
|
|
2091
|
-
}
|
|
2092
|
-
function getOppositePlacement(placement) {
|
|
2093
|
-
return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
|
|
2094
|
-
}
|
|
2095
|
-
function expandPaddingObject(padding) {
|
|
2096
|
-
return {
|
|
2097
|
-
top: 0,
|
|
2098
|
-
right: 0,
|
|
2099
|
-
bottom: 0,
|
|
2100
|
-
left: 0,
|
|
2101
|
-
...padding
|
|
2102
|
-
};
|
|
2103
|
-
}
|
|
2104
|
-
function getPaddingObject(padding) {
|
|
2105
|
-
return typeof padding !== "number" ? expandPaddingObject(padding) : {
|
|
2106
|
-
top: padding,
|
|
2107
|
-
right: padding,
|
|
2108
|
-
bottom: padding,
|
|
2109
|
-
left: padding
|
|
2110
|
-
};
|
|
2111
|
-
}
|
|
2112
|
-
function rectToClientRect(rect) {
|
|
2113
|
-
const {
|
|
2114
|
-
x,
|
|
2115
|
-
y,
|
|
2116
|
-
width,
|
|
2117
|
-
height
|
|
2118
|
-
} = rect;
|
|
2119
|
-
return {
|
|
2120
|
-
width,
|
|
2121
|
-
height,
|
|
2122
|
-
top: y,
|
|
2123
|
-
left: x,
|
|
2124
|
-
right: x + width,
|
|
2125
|
-
bottom: y + height,
|
|
2126
|
-
x,
|
|
2127
|
-
y
|
|
2128
|
-
};
|
|
2129
|
-
}
|
|
2130
|
-
|
|
2131
|
-
// node_modules/@floating-ui/core/dist/floating-ui.core.mjs
|
|
2132
|
-
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
2133
|
-
let {
|
|
2134
|
-
reference,
|
|
2135
|
-
floating
|
|
2136
|
-
} = _ref;
|
|
2137
|
-
const sideAxis = getSideAxis(placement);
|
|
2138
|
-
const alignmentAxis = getAlignmentAxis(placement);
|
|
2139
|
-
const alignLength = getAxisLength(alignmentAxis);
|
|
2140
|
-
const side = getSide(placement);
|
|
2141
|
-
const isVertical = sideAxis === "y";
|
|
2142
|
-
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
2143
|
-
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
2144
|
-
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
2145
|
-
let coords;
|
|
2146
|
-
switch (side) {
|
|
2147
|
-
case "top":
|
|
2148
|
-
coords = {
|
|
2149
|
-
x: commonX,
|
|
2150
|
-
y: reference.y - floating.height
|
|
2151
|
-
};
|
|
2152
|
-
break;
|
|
2153
|
-
case "bottom":
|
|
2154
|
-
coords = {
|
|
2155
|
-
x: commonX,
|
|
2156
|
-
y: reference.y + reference.height
|
|
2157
|
-
};
|
|
2158
|
-
break;
|
|
2159
|
-
case "right":
|
|
2160
|
-
coords = {
|
|
2161
|
-
x: reference.x + reference.width,
|
|
2162
|
-
y: commonY
|
|
2163
|
-
};
|
|
2164
|
-
break;
|
|
2165
|
-
case "left":
|
|
2166
|
-
coords = {
|
|
2167
|
-
x: reference.x - floating.width,
|
|
2168
|
-
y: commonY
|
|
2169
|
-
};
|
|
2170
|
-
break;
|
|
2171
|
-
default:
|
|
2172
|
-
coords = {
|
|
2173
|
-
x: reference.x,
|
|
2174
|
-
y: reference.y
|
|
2175
|
-
};
|
|
2176
|
-
}
|
|
2177
|
-
switch (getAlignment(placement)) {
|
|
2178
|
-
case "start":
|
|
2179
|
-
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
2180
|
-
break;
|
|
2181
|
-
case "end":
|
|
2182
|
-
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
2183
|
-
break;
|
|
2184
|
-
}
|
|
2185
|
-
return coords;
|
|
2186
|
-
}
|
|
2187
|
-
var computePosition = async (reference, floating, config) => {
|
|
2188
|
-
const {
|
|
2189
|
-
placement = "bottom",
|
|
2190
|
-
strategy = "absolute",
|
|
2191
|
-
middleware = [],
|
|
2192
|
-
platform: platform2
|
|
2193
|
-
} = config;
|
|
2194
|
-
const validMiddleware = middleware.filter(Boolean);
|
|
2195
|
-
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
|
|
2196
|
-
let rects = await platform2.getElementRects({
|
|
2197
|
-
reference,
|
|
2198
|
-
floating,
|
|
2199
|
-
strategy
|
|
2200
|
-
});
|
|
2201
|
-
let {
|
|
2202
|
-
x,
|
|
2203
|
-
y
|
|
2204
|
-
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
2205
|
-
let statefulPlacement = placement;
|
|
2206
|
-
let middlewareData = {};
|
|
2207
|
-
let resetCount = 0;
|
|
2208
|
-
for (let i = 0; i < validMiddleware.length; i++) {
|
|
2209
|
-
const {
|
|
2210
|
-
name,
|
|
2211
|
-
fn
|
|
2212
|
-
} = validMiddleware[i];
|
|
2213
|
-
const {
|
|
2214
|
-
x: nextX,
|
|
2215
|
-
y: nextY,
|
|
2216
|
-
data,
|
|
2217
|
-
reset
|
|
2218
|
-
} = await fn({
|
|
2219
|
-
x,
|
|
2220
|
-
y,
|
|
2221
|
-
initialPlacement: placement,
|
|
2222
|
-
placement: statefulPlacement,
|
|
2223
|
-
strategy,
|
|
2224
|
-
middlewareData,
|
|
2225
|
-
rects,
|
|
2226
|
-
platform: platform2,
|
|
2227
|
-
elements: {
|
|
2228
|
-
reference,
|
|
2229
|
-
floating
|
|
2230
|
-
}
|
|
2231
|
-
});
|
|
2232
|
-
x = nextX != null ? nextX : x;
|
|
2233
|
-
y = nextY != null ? nextY : y;
|
|
2234
|
-
middlewareData = {
|
|
2235
|
-
...middlewareData,
|
|
2236
|
-
[name]: {
|
|
2237
|
-
...middlewareData[name],
|
|
2238
|
-
...data
|
|
2239
|
-
}
|
|
2240
|
-
};
|
|
2241
|
-
if (reset && resetCount <= 50) {
|
|
2242
|
-
resetCount++;
|
|
2243
|
-
if (typeof reset === "object") {
|
|
2244
|
-
if (reset.placement) {
|
|
2245
|
-
statefulPlacement = reset.placement;
|
|
2246
|
-
}
|
|
2247
|
-
if (reset.rects) {
|
|
2248
|
-
rects = reset.rects === true ? await platform2.getElementRects({
|
|
2249
|
-
reference,
|
|
2250
|
-
floating,
|
|
2251
|
-
strategy
|
|
2252
|
-
}) : reset.rects;
|
|
2253
|
-
}
|
|
2254
|
-
({
|
|
2255
|
-
x,
|
|
2256
|
-
y
|
|
2257
|
-
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
2258
|
-
}
|
|
2259
|
-
i = -1;
|
|
2260
|
-
}
|
|
2261
|
-
}
|
|
2262
|
-
return {
|
|
2263
|
-
x,
|
|
2264
|
-
y,
|
|
2265
|
-
placement: statefulPlacement,
|
|
2266
|
-
strategy,
|
|
2267
|
-
middlewareData
|
|
2268
|
-
};
|
|
2269
|
-
};
|
|
2270
|
-
async function detectOverflow(state, options) {
|
|
2271
|
-
var _await$platform$isEle;
|
|
2272
|
-
if (options === void 0) {
|
|
2273
|
-
options = {};
|
|
2274
|
-
}
|
|
2275
|
-
const {
|
|
2276
|
-
x,
|
|
2277
|
-
y,
|
|
2278
|
-
platform: platform2,
|
|
2279
|
-
rects,
|
|
2280
|
-
elements,
|
|
2281
|
-
strategy
|
|
2282
|
-
} = state;
|
|
2283
|
-
const {
|
|
2284
|
-
boundary = "clippingAncestors",
|
|
2285
|
-
rootBoundary = "viewport",
|
|
2286
|
-
elementContext = "floating",
|
|
2287
|
-
altBoundary = false,
|
|
2288
|
-
padding = 0
|
|
2289
|
-
} = evaluate(options, state);
|
|
2290
|
-
const paddingObject = getPaddingObject(padding);
|
|
2291
|
-
const altContext = elementContext === "floating" ? "reference" : "floating";
|
|
2292
|
-
const element = elements[altBoundary ? altContext : elementContext];
|
|
2293
|
-
const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
|
|
2294
|
-
element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
|
|
2295
|
-
boundary,
|
|
2296
|
-
rootBoundary,
|
|
2297
|
-
strategy
|
|
2298
|
-
}));
|
|
2299
|
-
const rect = elementContext === "floating" ? {
|
|
2300
|
-
x,
|
|
2301
|
-
y,
|
|
2302
|
-
width: rects.floating.width,
|
|
2303
|
-
height: rects.floating.height
|
|
2304
|
-
} : rects.reference;
|
|
2305
|
-
const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
|
|
2306
|
-
const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
|
|
2307
|
-
x: 1,
|
|
2308
|
-
y: 1
|
|
2309
|
-
} : {
|
|
2310
|
-
x: 1,
|
|
2311
|
-
y: 1
|
|
2312
|
-
};
|
|
2313
|
-
const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
2314
|
-
elements,
|
|
2315
|
-
rect,
|
|
2316
|
-
offsetParent,
|
|
2317
|
-
strategy
|
|
2318
|
-
}) : rect);
|
|
2319
|
-
return {
|
|
2320
|
-
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
2321
|
-
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
2322
|
-
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
2323
|
-
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
2324
|
-
};
|
|
2325
|
-
}
|
|
2326
|
-
var flip = function(options) {
|
|
2327
|
-
if (options === void 0) {
|
|
2328
|
-
options = {};
|
|
2329
|
-
}
|
|
2330
|
-
return {
|
|
2331
|
-
name: "flip",
|
|
2332
|
-
options,
|
|
2333
|
-
async fn(state) {
|
|
2334
|
-
var _middlewareData$arrow, _middlewareData$flip;
|
|
2335
|
-
const {
|
|
2336
|
-
placement,
|
|
2337
|
-
middlewareData,
|
|
2338
|
-
rects,
|
|
2339
|
-
initialPlacement,
|
|
2340
|
-
platform: platform2,
|
|
2341
|
-
elements
|
|
2342
|
-
} = state;
|
|
2343
|
-
const {
|
|
2344
|
-
mainAxis: checkMainAxis = true,
|
|
2345
|
-
crossAxis: checkCrossAxis = true,
|
|
2346
|
-
fallbackPlacements: specifiedFallbackPlacements,
|
|
2347
|
-
fallbackStrategy = "bestFit",
|
|
2348
|
-
fallbackAxisSideDirection = "none",
|
|
2349
|
-
flipAlignment = true,
|
|
2350
|
-
...detectOverflowOptions
|
|
2351
|
-
} = evaluate(options, state);
|
|
2352
|
-
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
2353
|
-
return {};
|
|
2354
|
-
}
|
|
2355
|
-
const side = getSide(placement);
|
|
2356
|
-
const initialSideAxis = getSideAxis(initialPlacement);
|
|
2357
|
-
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
2358
|
-
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
2359
|
-
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
2360
|
-
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
|
|
2361
|
-
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
|
2362
|
-
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
2363
|
-
}
|
|
2364
|
-
const placements2 = [initialPlacement, ...fallbackPlacements];
|
|
2365
|
-
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
2366
|
-
const overflows = [];
|
|
2367
|
-
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
2368
|
-
if (checkMainAxis) {
|
|
2369
|
-
overflows.push(overflow[side]);
|
|
2370
|
-
}
|
|
2371
|
-
if (checkCrossAxis) {
|
|
2372
|
-
const sides2 = getAlignmentSides(placement, rects, rtl);
|
|
2373
|
-
overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
|
|
2374
|
-
}
|
|
2375
|
-
overflowsData = [...overflowsData, {
|
|
2376
|
-
placement,
|
|
2377
|
-
overflows
|
|
2378
|
-
}];
|
|
2379
|
-
if (!overflows.every((side2) => side2 <= 0)) {
|
|
2380
|
-
var _middlewareData$flip2, _overflowsData$filter;
|
|
2381
|
-
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
2382
|
-
const nextPlacement = placements2[nextIndex];
|
|
2383
|
-
if (nextPlacement) {
|
|
2384
|
-
const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
|
|
2385
|
-
if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
|
|
2386
|
-
// overflows the main axis.
|
|
2387
|
-
overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
|
|
2388
|
-
return {
|
|
2389
|
-
data: {
|
|
2390
|
-
index: nextIndex,
|
|
2391
|
-
overflows: overflowsData
|
|
2392
|
-
},
|
|
2393
|
-
reset: {
|
|
2394
|
-
placement: nextPlacement
|
|
2395
|
-
}
|
|
2396
|
-
};
|
|
2397
|
-
}
|
|
2398
|
-
}
|
|
2399
|
-
let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
|
2400
|
-
if (!resetPlacement) {
|
|
2401
|
-
switch (fallbackStrategy) {
|
|
2402
|
-
case "bestFit": {
|
|
2403
|
-
var _overflowsData$filter2;
|
|
2404
|
-
const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
|
|
2405
|
-
if (hasFallbackAxisSideDirection) {
|
|
2406
|
-
const currentSideAxis = getSideAxis(d.placement);
|
|
2407
|
-
return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
|
|
2408
|
-
// reading directions favoring greater width.
|
|
2409
|
-
currentSideAxis === "y";
|
|
2410
|
-
}
|
|
2411
|
-
return true;
|
|
2412
|
-
}).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
|
2413
|
-
if (placement2) {
|
|
2414
|
-
resetPlacement = placement2;
|
|
2415
|
-
}
|
|
2416
|
-
break;
|
|
2417
|
-
}
|
|
2418
|
-
case "initialPlacement":
|
|
2419
|
-
resetPlacement = initialPlacement;
|
|
2420
|
-
break;
|
|
2421
|
-
}
|
|
2422
|
-
}
|
|
2423
|
-
if (placement !== resetPlacement) {
|
|
2424
|
-
return {
|
|
2425
|
-
reset: {
|
|
2426
|
-
placement: resetPlacement
|
|
2427
|
-
}
|
|
2428
|
-
};
|
|
2429
|
-
}
|
|
2430
|
-
}
|
|
2431
|
-
return {};
|
|
2432
|
-
}
|
|
2433
|
-
};
|
|
2434
|
-
};
|
|
2435
|
-
var originSides = /* @__PURE__ */ new Set(["left", "top"]);
|
|
2436
|
-
async function convertValueToCoords(state, options) {
|
|
2437
|
-
const {
|
|
2438
|
-
placement,
|
|
2439
|
-
platform: platform2,
|
|
2440
|
-
elements
|
|
2441
|
-
} = state;
|
|
2442
|
-
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
2443
|
-
const side = getSide(placement);
|
|
2444
|
-
const alignment = getAlignment(placement);
|
|
2445
|
-
const isVertical = getSideAxis(placement) === "y";
|
|
2446
|
-
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
|
2447
|
-
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
2448
|
-
const rawValue = evaluate(options, state);
|
|
2449
|
-
let {
|
|
2450
|
-
mainAxis,
|
|
2451
|
-
crossAxis,
|
|
2452
|
-
alignmentAxis
|
|
2453
|
-
} = typeof rawValue === "number" ? {
|
|
2454
|
-
mainAxis: rawValue,
|
|
2455
|
-
crossAxis: 0,
|
|
2456
|
-
alignmentAxis: null
|
|
2457
|
-
} : {
|
|
2458
|
-
mainAxis: rawValue.mainAxis || 0,
|
|
2459
|
-
crossAxis: rawValue.crossAxis || 0,
|
|
2460
|
-
alignmentAxis: rawValue.alignmentAxis
|
|
2461
|
-
};
|
|
2462
|
-
if (alignment && typeof alignmentAxis === "number") {
|
|
2463
|
-
crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
|
|
2464
|
-
}
|
|
2465
|
-
return isVertical ? {
|
|
2466
|
-
x: crossAxis * crossAxisMulti,
|
|
2467
|
-
y: mainAxis * mainAxisMulti
|
|
2468
|
-
} : {
|
|
2469
|
-
x: mainAxis * mainAxisMulti,
|
|
2470
|
-
y: crossAxis * crossAxisMulti
|
|
2471
|
-
};
|
|
2472
|
-
}
|
|
2473
|
-
var offset = function(options) {
|
|
2474
|
-
if (options === void 0) {
|
|
2475
|
-
options = 0;
|
|
2476
|
-
}
|
|
2477
|
-
return {
|
|
2478
|
-
name: "offset",
|
|
2479
|
-
options,
|
|
2480
|
-
async fn(state) {
|
|
2481
|
-
var _middlewareData$offse, _middlewareData$arrow;
|
|
2482
|
-
const {
|
|
2483
|
-
x,
|
|
2484
|
-
y,
|
|
2485
|
-
placement,
|
|
2486
|
-
middlewareData
|
|
2487
|
-
} = state;
|
|
2488
|
-
const diffCoords = await convertValueToCoords(state, options);
|
|
2489
|
-
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
2490
|
-
return {};
|
|
2491
|
-
}
|
|
2492
|
-
return {
|
|
2493
|
-
x: x + diffCoords.x,
|
|
2494
|
-
y: y + diffCoords.y,
|
|
2495
|
-
data: {
|
|
2496
|
-
...diffCoords,
|
|
2497
|
-
placement
|
|
2498
|
-
}
|
|
2499
|
-
};
|
|
2500
|
-
}
|
|
2501
|
-
};
|
|
2502
|
-
};
|
|
2503
|
-
var shift = function(options) {
|
|
2504
|
-
if (options === void 0) {
|
|
2505
|
-
options = {};
|
|
2506
|
-
}
|
|
2507
|
-
return {
|
|
2508
|
-
name: "shift",
|
|
2509
|
-
options,
|
|
2510
|
-
async fn(state) {
|
|
2511
|
-
const {
|
|
2512
|
-
x,
|
|
2513
|
-
y,
|
|
2514
|
-
placement
|
|
2515
|
-
} = state;
|
|
2516
|
-
const {
|
|
2517
|
-
mainAxis: checkMainAxis = true,
|
|
2518
|
-
crossAxis: checkCrossAxis = false,
|
|
2519
|
-
limiter = {
|
|
2520
|
-
fn: (_ref) => {
|
|
2521
|
-
let {
|
|
2522
|
-
x: x2,
|
|
2523
|
-
y: y2
|
|
2524
|
-
} = _ref;
|
|
2525
|
-
return {
|
|
2526
|
-
x: x2,
|
|
2527
|
-
y: y2
|
|
2528
|
-
};
|
|
2529
|
-
}
|
|
2530
|
-
},
|
|
2531
|
-
...detectOverflowOptions
|
|
2532
|
-
} = evaluate(options, state);
|
|
2533
|
-
const coords = {
|
|
2534
|
-
x,
|
|
2535
|
-
y
|
|
2536
|
-
};
|
|
2537
|
-
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
2538
|
-
const crossAxis = getSideAxis(getSide(placement));
|
|
2539
|
-
const mainAxis = getOppositeAxis(crossAxis);
|
|
2540
|
-
let mainAxisCoord = coords[mainAxis];
|
|
2541
|
-
let crossAxisCoord = coords[crossAxis];
|
|
2542
|
-
if (checkMainAxis) {
|
|
2543
|
-
const minSide = mainAxis === "y" ? "top" : "left";
|
|
2544
|
-
const maxSide = mainAxis === "y" ? "bottom" : "right";
|
|
2545
|
-
const min2 = mainAxisCoord + overflow[minSide];
|
|
2546
|
-
const max2 = mainAxisCoord - overflow[maxSide];
|
|
2547
|
-
mainAxisCoord = clamp(min2, mainAxisCoord, max2);
|
|
2548
|
-
}
|
|
2549
|
-
if (checkCrossAxis) {
|
|
2550
|
-
const minSide = crossAxis === "y" ? "top" : "left";
|
|
2551
|
-
const maxSide = crossAxis === "y" ? "bottom" : "right";
|
|
2552
|
-
const min2 = crossAxisCoord + overflow[minSide];
|
|
2553
|
-
const max2 = crossAxisCoord - overflow[maxSide];
|
|
2554
|
-
crossAxisCoord = clamp(min2, crossAxisCoord, max2);
|
|
2555
|
-
}
|
|
2556
|
-
const limitedCoords = limiter.fn({
|
|
2557
|
-
...state,
|
|
2558
|
-
[mainAxis]: mainAxisCoord,
|
|
2559
|
-
[crossAxis]: crossAxisCoord
|
|
2560
|
-
});
|
|
2561
|
-
return {
|
|
2562
|
-
...limitedCoords,
|
|
2563
|
-
data: {
|
|
2564
|
-
x: limitedCoords.x - x,
|
|
2565
|
-
y: limitedCoords.y - y,
|
|
2566
|
-
enabled: {
|
|
2567
|
-
[mainAxis]: checkMainAxis,
|
|
2568
|
-
[crossAxis]: checkCrossAxis
|
|
2569
|
-
}
|
|
2570
|
-
}
|
|
2571
|
-
};
|
|
2572
|
-
}
|
|
2573
|
-
};
|
|
2574
|
-
};
|
|
2575
|
-
|
|
2576
|
-
// node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
|
|
2577
|
-
function hasWindow() {
|
|
2578
|
-
return typeof window !== "undefined";
|
|
2579
|
-
}
|
|
2580
|
-
function getNodeName(node) {
|
|
2581
|
-
if (isNode(node)) {
|
|
2582
|
-
return (node.nodeName || "").toLowerCase();
|
|
2583
|
-
}
|
|
2584
|
-
return "#document";
|
|
2585
|
-
}
|
|
2586
|
-
function getWindow(node) {
|
|
2587
|
-
var _node$ownerDocument;
|
|
2588
|
-
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
2589
|
-
}
|
|
2590
|
-
function getDocumentElement(node) {
|
|
2591
|
-
var _ref;
|
|
2592
|
-
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
2593
|
-
}
|
|
2594
|
-
function isNode(value) {
|
|
2595
|
-
if (!hasWindow()) {
|
|
2596
|
-
return false;
|
|
2597
|
-
}
|
|
2598
|
-
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
2599
|
-
}
|
|
2600
|
-
function isElement(value) {
|
|
2601
|
-
if (!hasWindow()) {
|
|
2602
|
-
return false;
|
|
2603
|
-
}
|
|
2604
|
-
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
2605
|
-
}
|
|
2606
|
-
function isHTMLElement(value) {
|
|
2607
|
-
if (!hasWindow()) {
|
|
2608
|
-
return false;
|
|
2609
|
-
}
|
|
2610
|
-
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
2611
|
-
}
|
|
2612
|
-
function isShadowRoot(value) {
|
|
2613
|
-
if (!hasWindow() || typeof ShadowRoot === "undefined") {
|
|
2614
|
-
return false;
|
|
2615
|
-
}
|
|
2616
|
-
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
2617
|
-
}
|
|
2618
|
-
var invalidOverflowDisplayValues = /* @__PURE__ */ new Set(["inline", "contents"]);
|
|
2619
|
-
function isOverflowElement(element) {
|
|
2620
|
-
const {
|
|
2621
|
-
overflow,
|
|
2622
|
-
overflowX,
|
|
2623
|
-
overflowY,
|
|
2624
|
-
display
|
|
2625
|
-
} = getComputedStyle(element);
|
|
2626
|
-
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
|
2627
|
-
}
|
|
2628
|
-
var tableElements = /* @__PURE__ */ new Set(["table", "td", "th"]);
|
|
2629
|
-
function isTableElement(element) {
|
|
2630
|
-
return tableElements.has(getNodeName(element));
|
|
2631
|
-
}
|
|
2632
|
-
var topLayerSelectors = [":popover-open", ":modal"];
|
|
2633
|
-
function isTopLayer(element) {
|
|
2634
|
-
return topLayerSelectors.some((selector) => {
|
|
2635
|
-
try {
|
|
2636
|
-
return element.matches(selector);
|
|
2637
|
-
} catch (_e) {
|
|
2638
|
-
return false;
|
|
2639
|
-
}
|
|
2640
|
-
});
|
|
2641
|
-
}
|
|
2642
|
-
var transformProperties = ["transform", "translate", "scale", "rotate", "perspective"];
|
|
2643
|
-
var willChangeValues = ["transform", "translate", "scale", "rotate", "perspective", "filter"];
|
|
2644
|
-
var containValues = ["paint", "layout", "strict", "content"];
|
|
2645
|
-
function isContainingBlock(elementOrCss) {
|
|
2646
|
-
const webkit = isWebKit();
|
|
2647
|
-
const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
|
|
2648
|
-
return transformProperties.some((value) => css[value] ? css[value] !== "none" : false) || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || willChangeValues.some((value) => (css.willChange || "").includes(value)) || containValues.some((value) => (css.contain || "").includes(value));
|
|
2649
|
-
}
|
|
2650
|
-
function getContainingBlock(element) {
|
|
2651
|
-
let currentNode = getParentNode(element);
|
|
2652
|
-
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
2653
|
-
if (isContainingBlock(currentNode)) {
|
|
2654
|
-
return currentNode;
|
|
2655
|
-
} else if (isTopLayer(currentNode)) {
|
|
2656
|
-
return null;
|
|
2657
|
-
}
|
|
2658
|
-
currentNode = getParentNode(currentNode);
|
|
2659
|
-
}
|
|
2660
|
-
return null;
|
|
2661
|
-
}
|
|
2662
|
-
function isWebKit() {
|
|
2663
|
-
if (typeof CSS === "undefined" || !CSS.supports)
|
|
2664
|
-
return false;
|
|
2665
|
-
return CSS.supports("-webkit-backdrop-filter", "none");
|
|
2666
|
-
}
|
|
2667
|
-
var lastTraversableNodeNames = /* @__PURE__ */ new Set(["html", "body", "#document"]);
|
|
2668
|
-
function isLastTraversableNode(node) {
|
|
2669
|
-
return lastTraversableNodeNames.has(getNodeName(node));
|
|
2670
|
-
}
|
|
2671
|
-
function getComputedStyle(element) {
|
|
2672
|
-
return getWindow(element).getComputedStyle(element);
|
|
2673
|
-
}
|
|
2674
|
-
function getNodeScroll(element) {
|
|
2675
|
-
if (isElement(element)) {
|
|
2676
|
-
return {
|
|
2677
|
-
scrollLeft: element.scrollLeft,
|
|
2678
|
-
scrollTop: element.scrollTop
|
|
2679
|
-
};
|
|
2680
|
-
}
|
|
2681
|
-
return {
|
|
2682
|
-
scrollLeft: element.scrollX,
|
|
2683
|
-
scrollTop: element.scrollY
|
|
2684
|
-
};
|
|
2685
|
-
}
|
|
2686
|
-
function getParentNode(node) {
|
|
2687
|
-
if (getNodeName(node) === "html") {
|
|
2688
|
-
return node;
|
|
2689
|
-
}
|
|
2690
|
-
const result = (
|
|
2691
|
-
// Step into the shadow DOM of the parent of a slotted node.
|
|
2692
|
-
node.assignedSlot || // DOM Element detected.
|
|
2693
|
-
node.parentNode || // ShadowRoot detected.
|
|
2694
|
-
isShadowRoot(node) && node.host || // Fallback.
|
|
2695
|
-
getDocumentElement(node)
|
|
2696
|
-
);
|
|
2697
|
-
return isShadowRoot(result) ? result.host : result;
|
|
2698
|
-
}
|
|
2699
|
-
function getNearestOverflowAncestor(node) {
|
|
2700
|
-
const parentNode = getParentNode(node);
|
|
2701
|
-
if (isLastTraversableNode(parentNode)) {
|
|
2702
|
-
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
2703
|
-
}
|
|
2704
|
-
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
2705
|
-
return parentNode;
|
|
2706
|
-
}
|
|
2707
|
-
return getNearestOverflowAncestor(parentNode);
|
|
2708
|
-
}
|
|
2709
|
-
function getOverflowAncestors(node, list, traverseIframes) {
|
|
2710
|
-
var _node$ownerDocument2;
|
|
2711
|
-
if (list === void 0) {
|
|
2712
|
-
list = [];
|
|
2713
|
-
}
|
|
2714
|
-
if (traverseIframes === void 0) {
|
|
2715
|
-
traverseIframes = true;
|
|
2716
|
-
}
|
|
2717
|
-
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
2718
|
-
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
2719
|
-
const win = getWindow(scrollableAncestor);
|
|
2720
|
-
if (isBody) {
|
|
2721
|
-
const frameElement = getFrameElement(win);
|
|
2722
|
-
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
2723
|
-
}
|
|
2724
|
-
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
2725
|
-
}
|
|
2726
|
-
function getFrameElement(win) {
|
|
2727
|
-
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
2728
|
-
}
|
|
2729
|
-
|
|
2730
|
-
// node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
|
|
2731
|
-
function getCssDimensions(element) {
|
|
2732
|
-
const css = getComputedStyle(element);
|
|
2733
|
-
let width = parseFloat(css.width) || 0;
|
|
2734
|
-
let height = parseFloat(css.height) || 0;
|
|
2735
|
-
const hasOffset = isHTMLElement(element);
|
|
2736
|
-
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
2737
|
-
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
2738
|
-
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
2739
|
-
if (shouldFallback) {
|
|
2740
|
-
width = offsetWidth;
|
|
2741
|
-
height = offsetHeight;
|
|
2742
|
-
}
|
|
2743
|
-
return {
|
|
2744
|
-
width,
|
|
2745
|
-
height,
|
|
2746
|
-
$: shouldFallback
|
|
2747
|
-
};
|
|
2748
|
-
}
|
|
2749
|
-
function unwrapElement(element) {
|
|
2750
|
-
return !isElement(element) ? element.contextElement : element;
|
|
2751
|
-
}
|
|
2752
|
-
function getScale(element) {
|
|
2753
|
-
const domElement = unwrapElement(element);
|
|
2754
|
-
if (!isHTMLElement(domElement)) {
|
|
2755
|
-
return createCoords(1);
|
|
2756
|
-
}
|
|
2757
|
-
const rect = domElement.getBoundingClientRect();
|
|
2758
|
-
const {
|
|
2759
|
-
width,
|
|
2760
|
-
height,
|
|
2761
|
-
$
|
|
2762
|
-
} = getCssDimensions(domElement);
|
|
2763
|
-
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
2764
|
-
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
2765
|
-
if (!x || !Number.isFinite(x)) {
|
|
2766
|
-
x = 1;
|
|
2767
|
-
}
|
|
2768
|
-
if (!y || !Number.isFinite(y)) {
|
|
2769
|
-
y = 1;
|
|
2770
|
-
}
|
|
2771
|
-
return {
|
|
2772
|
-
x,
|
|
2773
|
-
y
|
|
2774
|
-
};
|
|
2775
|
-
}
|
|
2776
|
-
var noOffsets = /* @__PURE__ */ createCoords(0);
|
|
2777
|
-
function getVisualOffsets(element) {
|
|
2778
|
-
const win = getWindow(element);
|
|
2779
|
-
if (!isWebKit() || !win.visualViewport) {
|
|
2780
|
-
return noOffsets;
|
|
2781
|
-
}
|
|
2782
|
-
return {
|
|
2783
|
-
x: win.visualViewport.offsetLeft,
|
|
2784
|
-
y: win.visualViewport.offsetTop
|
|
2785
|
-
};
|
|
2786
|
-
}
|
|
2787
|
-
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
2788
|
-
if (isFixed === void 0) {
|
|
2789
|
-
isFixed = false;
|
|
2790
|
-
}
|
|
2791
|
-
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
2792
|
-
return false;
|
|
2793
|
-
}
|
|
2794
|
-
return isFixed;
|
|
2795
|
-
}
|
|
2796
|
-
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
2797
|
-
if (includeScale === void 0) {
|
|
2798
|
-
includeScale = false;
|
|
2799
|
-
}
|
|
2800
|
-
if (isFixedStrategy === void 0) {
|
|
2801
|
-
isFixedStrategy = false;
|
|
2802
|
-
}
|
|
2803
|
-
const clientRect = element.getBoundingClientRect();
|
|
2804
|
-
const domElement = unwrapElement(element);
|
|
2805
|
-
let scale = createCoords(1);
|
|
2806
|
-
if (includeScale) {
|
|
2807
|
-
if (offsetParent) {
|
|
2808
|
-
if (isElement(offsetParent)) {
|
|
2809
|
-
scale = getScale(offsetParent);
|
|
2810
|
-
}
|
|
2811
|
-
} else {
|
|
2812
|
-
scale = getScale(element);
|
|
2813
|
-
}
|
|
2814
|
-
}
|
|
2815
|
-
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
2816
|
-
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
2817
|
-
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
2818
|
-
let width = clientRect.width / scale.x;
|
|
2819
|
-
let height = clientRect.height / scale.y;
|
|
2820
|
-
if (domElement) {
|
|
2821
|
-
const win = getWindow(domElement);
|
|
2822
|
-
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
2823
|
-
let currentWin = win;
|
|
2824
|
-
let currentIFrame = getFrameElement(currentWin);
|
|
2825
|
-
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
2826
|
-
const iframeScale = getScale(currentIFrame);
|
|
2827
|
-
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
2828
|
-
const css = getComputedStyle(currentIFrame);
|
|
2829
|
-
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
2830
|
-
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
2831
|
-
x *= iframeScale.x;
|
|
2832
|
-
y *= iframeScale.y;
|
|
2833
|
-
width *= iframeScale.x;
|
|
2834
|
-
height *= iframeScale.y;
|
|
2835
|
-
x += left;
|
|
2836
|
-
y += top;
|
|
2837
|
-
currentWin = getWindow(currentIFrame);
|
|
2838
|
-
currentIFrame = getFrameElement(currentWin);
|
|
2839
|
-
}
|
|
2840
|
-
}
|
|
2841
|
-
return rectToClientRect({
|
|
2842
|
-
width,
|
|
2843
|
-
height,
|
|
2844
|
-
x,
|
|
2845
|
-
y
|
|
2846
|
-
});
|
|
2847
|
-
}
|
|
2848
|
-
function getWindowScrollBarX(element, rect) {
|
|
2849
|
-
const leftScroll = getNodeScroll(element).scrollLeft;
|
|
2850
|
-
if (!rect) {
|
|
2851
|
-
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
|
2852
|
-
}
|
|
2853
|
-
return rect.left + leftScroll;
|
|
2854
|
-
}
|
|
2855
|
-
function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
|
|
2856
|
-
if (ignoreScrollbarX === void 0) {
|
|
2857
|
-
ignoreScrollbarX = false;
|
|
2858
|
-
}
|
|
2859
|
-
const htmlRect = documentElement.getBoundingClientRect();
|
|
2860
|
-
const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 : (
|
|
2861
|
-
// RTL <body> scrollbar.
|
|
2862
|
-
getWindowScrollBarX(documentElement, htmlRect)
|
|
2863
|
-
));
|
|
2864
|
-
const y = htmlRect.top + scroll.scrollTop;
|
|
2865
|
-
return {
|
|
2866
|
-
x,
|
|
2867
|
-
y
|
|
2868
|
-
};
|
|
2869
|
-
}
|
|
2870
|
-
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
2871
|
-
let {
|
|
2872
|
-
elements,
|
|
2873
|
-
rect,
|
|
2874
|
-
offsetParent,
|
|
2875
|
-
strategy
|
|
2876
|
-
} = _ref;
|
|
2877
|
-
const isFixed = strategy === "fixed";
|
|
2878
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
2879
|
-
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
2880
|
-
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
2881
|
-
return rect;
|
|
2882
|
-
}
|
|
2883
|
-
let scroll = {
|
|
2884
|
-
scrollLeft: 0,
|
|
2885
|
-
scrollTop: 0
|
|
2886
|
-
};
|
|
2887
|
-
let scale = createCoords(1);
|
|
2888
|
-
const offsets = createCoords(0);
|
|
2889
|
-
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
2890
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
2891
|
-
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
2892
|
-
scroll = getNodeScroll(offsetParent);
|
|
2893
|
-
}
|
|
2894
|
-
if (isHTMLElement(offsetParent)) {
|
|
2895
|
-
const offsetRect = getBoundingClientRect(offsetParent);
|
|
2896
|
-
scale = getScale(offsetParent);
|
|
2897
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
2898
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
2899
|
-
}
|
|
2900
|
-
}
|
|
2901
|
-
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
|
|
2902
|
-
return {
|
|
2903
|
-
width: rect.width * scale.x,
|
|
2904
|
-
height: rect.height * scale.y,
|
|
2905
|
-
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
|
2906
|
-
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
|
2907
|
-
};
|
|
2908
|
-
}
|
|
2909
|
-
function getClientRects(element) {
|
|
2910
|
-
return Array.from(element.getClientRects());
|
|
2911
|
-
}
|
|
2912
|
-
function getDocumentRect(element) {
|
|
2913
|
-
const html = getDocumentElement(element);
|
|
2914
|
-
const scroll = getNodeScroll(element);
|
|
2915
|
-
const body = element.ownerDocument.body;
|
|
2916
|
-
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
2917
|
-
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
2918
|
-
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
2919
|
-
const y = -scroll.scrollTop;
|
|
2920
|
-
if (getComputedStyle(body).direction === "rtl") {
|
|
2921
|
-
x += max(html.clientWidth, body.clientWidth) - width;
|
|
2922
|
-
}
|
|
2923
|
-
return {
|
|
2924
|
-
width,
|
|
2925
|
-
height,
|
|
2926
|
-
x,
|
|
2927
|
-
y
|
|
2928
|
-
};
|
|
2929
|
-
}
|
|
2930
|
-
function getViewportRect(element, strategy) {
|
|
2931
|
-
const win = getWindow(element);
|
|
2932
|
-
const html = getDocumentElement(element);
|
|
2933
|
-
const visualViewport = win.visualViewport;
|
|
2934
|
-
let width = html.clientWidth;
|
|
2935
|
-
let height = html.clientHeight;
|
|
2936
|
-
let x = 0;
|
|
2937
|
-
let y = 0;
|
|
2938
|
-
if (visualViewport) {
|
|
2939
|
-
width = visualViewport.width;
|
|
2940
|
-
height = visualViewport.height;
|
|
2941
|
-
const visualViewportBased = isWebKit();
|
|
2942
|
-
if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
|
|
2943
|
-
x = visualViewport.offsetLeft;
|
|
2944
|
-
y = visualViewport.offsetTop;
|
|
2945
|
-
}
|
|
2946
|
-
}
|
|
2947
|
-
return {
|
|
2948
|
-
width,
|
|
2949
|
-
height,
|
|
2950
|
-
x,
|
|
2951
|
-
y
|
|
2952
|
-
};
|
|
2953
|
-
}
|
|
2954
|
-
var absoluteOrFixed = /* @__PURE__ */ new Set(["absolute", "fixed"]);
|
|
2955
|
-
function getInnerBoundingClientRect(element, strategy) {
|
|
2956
|
-
const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
|
|
2957
|
-
const top = clientRect.top + element.clientTop;
|
|
2958
|
-
const left = clientRect.left + element.clientLeft;
|
|
2959
|
-
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
2960
|
-
const width = element.clientWidth * scale.x;
|
|
2961
|
-
const height = element.clientHeight * scale.y;
|
|
2962
|
-
const x = left * scale.x;
|
|
2963
|
-
const y = top * scale.y;
|
|
2964
|
-
return {
|
|
2965
|
-
width,
|
|
2966
|
-
height,
|
|
2967
|
-
x,
|
|
2968
|
-
y
|
|
2969
|
-
};
|
|
2970
|
-
}
|
|
2971
|
-
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
2972
|
-
let rect;
|
|
2973
|
-
if (clippingAncestor === "viewport") {
|
|
2974
|
-
rect = getViewportRect(element, strategy);
|
|
2975
|
-
} else if (clippingAncestor === "document") {
|
|
2976
|
-
rect = getDocumentRect(getDocumentElement(element));
|
|
2977
|
-
} else if (isElement(clippingAncestor)) {
|
|
2978
|
-
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
2979
|
-
} else {
|
|
2980
|
-
const visualOffsets = getVisualOffsets(element);
|
|
2981
|
-
rect = {
|
|
2982
|
-
x: clippingAncestor.x - visualOffsets.x,
|
|
2983
|
-
y: clippingAncestor.y - visualOffsets.y,
|
|
2984
|
-
width: clippingAncestor.width,
|
|
2985
|
-
height: clippingAncestor.height
|
|
2986
|
-
};
|
|
2987
|
-
}
|
|
2988
|
-
return rectToClientRect(rect);
|
|
2989
|
-
}
|
|
2990
|
-
function hasFixedPositionAncestor(element, stopNode) {
|
|
2991
|
-
const parentNode = getParentNode(element);
|
|
2992
|
-
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
2993
|
-
return false;
|
|
2994
|
-
}
|
|
2995
|
-
return getComputedStyle(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
|
|
2996
|
-
}
|
|
2997
|
-
function getClippingElementAncestors(element, cache) {
|
|
2998
|
-
const cachedResult = cache.get(element);
|
|
2999
|
-
if (cachedResult) {
|
|
3000
|
-
return cachedResult;
|
|
3001
|
-
}
|
|
3002
|
-
let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
|
|
3003
|
-
let currentContainingBlockComputedStyle = null;
|
|
3004
|
-
const elementIsFixed = getComputedStyle(element).position === "fixed";
|
|
3005
|
-
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
3006
|
-
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
3007
|
-
const computedStyle = getComputedStyle(currentNode);
|
|
3008
|
-
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
3009
|
-
if (!currentNodeIsContaining && computedStyle.position === "fixed") {
|
|
3010
|
-
currentContainingBlockComputedStyle = null;
|
|
3011
|
-
}
|
|
3012
|
-
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
3013
|
-
if (shouldDropCurrentNode) {
|
|
3014
|
-
result = result.filter((ancestor) => ancestor !== currentNode);
|
|
3015
|
-
} else {
|
|
3016
|
-
currentContainingBlockComputedStyle = computedStyle;
|
|
3017
|
-
}
|
|
3018
|
-
currentNode = getParentNode(currentNode);
|
|
3019
|
-
}
|
|
3020
|
-
cache.set(element, result);
|
|
3021
|
-
return result;
|
|
3022
|
-
}
|
|
3023
|
-
function getClippingRect(_ref) {
|
|
3024
|
-
let {
|
|
3025
|
-
element,
|
|
3026
|
-
boundary,
|
|
3027
|
-
rootBoundary,
|
|
3028
|
-
strategy
|
|
3029
|
-
} = _ref;
|
|
3030
|
-
const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
3031
|
-
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
3032
|
-
const firstClippingAncestor = clippingAncestors[0];
|
|
3033
|
-
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
3034
|
-
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
3035
|
-
accRect.top = max(rect.top, accRect.top);
|
|
3036
|
-
accRect.right = min(rect.right, accRect.right);
|
|
3037
|
-
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
3038
|
-
accRect.left = max(rect.left, accRect.left);
|
|
3039
|
-
return accRect;
|
|
3040
|
-
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
3041
|
-
return {
|
|
3042
|
-
width: clippingRect.right - clippingRect.left,
|
|
3043
|
-
height: clippingRect.bottom - clippingRect.top,
|
|
3044
|
-
x: clippingRect.left,
|
|
3045
|
-
y: clippingRect.top
|
|
3046
|
-
};
|
|
3047
|
-
}
|
|
3048
|
-
function getDimensions(element) {
|
|
3049
|
-
const {
|
|
3050
|
-
width,
|
|
3051
|
-
height
|
|
3052
|
-
} = getCssDimensions(element);
|
|
3053
|
-
return {
|
|
3054
|
-
width,
|
|
3055
|
-
height
|
|
3056
|
-
};
|
|
3057
|
-
}
|
|
3058
|
-
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
3059
|
-
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
3060
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
3061
|
-
const isFixed = strategy === "fixed";
|
|
3062
|
-
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
3063
|
-
let scroll = {
|
|
3064
|
-
scrollLeft: 0,
|
|
3065
|
-
scrollTop: 0
|
|
3066
|
-
};
|
|
3067
|
-
const offsets = createCoords(0);
|
|
3068
|
-
function setLeftRTLScrollbarOffset() {
|
|
3069
|
-
offsets.x = getWindowScrollBarX(documentElement);
|
|
3070
|
-
}
|
|
3071
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
3072
|
-
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
3073
|
-
scroll = getNodeScroll(offsetParent);
|
|
3074
|
-
}
|
|
3075
|
-
if (isOffsetParentAnElement) {
|
|
3076
|
-
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
3077
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
3078
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
3079
|
-
} else if (documentElement) {
|
|
3080
|
-
setLeftRTLScrollbarOffset();
|
|
3081
|
-
}
|
|
3082
|
-
}
|
|
3083
|
-
if (isFixed && !isOffsetParentAnElement && documentElement) {
|
|
3084
|
-
setLeftRTLScrollbarOffset();
|
|
3085
|
-
}
|
|
3086
|
-
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
3087
|
-
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
|
3088
|
-
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
|
3089
|
-
return {
|
|
3090
|
-
x,
|
|
3091
|
-
y,
|
|
3092
|
-
width: rect.width,
|
|
3093
|
-
height: rect.height
|
|
3094
|
-
};
|
|
3095
|
-
}
|
|
3096
|
-
function isStaticPositioned(element) {
|
|
3097
|
-
return getComputedStyle(element).position === "static";
|
|
3098
|
-
}
|
|
3099
|
-
function getTrueOffsetParent(element, polyfill) {
|
|
3100
|
-
if (!isHTMLElement(element) || getComputedStyle(element).position === "fixed") {
|
|
3101
|
-
return null;
|
|
3102
|
-
}
|
|
3103
|
-
if (polyfill) {
|
|
3104
|
-
return polyfill(element);
|
|
3105
|
-
}
|
|
3106
|
-
let rawOffsetParent = element.offsetParent;
|
|
3107
|
-
if (getDocumentElement(element) === rawOffsetParent) {
|
|
3108
|
-
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
3109
|
-
}
|
|
3110
|
-
return rawOffsetParent;
|
|
3111
|
-
}
|
|
3112
|
-
function getOffsetParent(element, polyfill) {
|
|
3113
|
-
const win = getWindow(element);
|
|
3114
|
-
if (isTopLayer(element)) {
|
|
3115
|
-
return win;
|
|
3116
|
-
}
|
|
3117
|
-
if (!isHTMLElement(element)) {
|
|
3118
|
-
let svgOffsetParent = getParentNode(element);
|
|
3119
|
-
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
3120
|
-
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
|
3121
|
-
return svgOffsetParent;
|
|
3122
|
-
}
|
|
3123
|
-
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
3124
|
-
}
|
|
3125
|
-
return win;
|
|
3126
|
-
}
|
|
3127
|
-
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
3128
|
-
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
|
3129
|
-
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
3130
|
-
}
|
|
3131
|
-
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
|
3132
|
-
return win;
|
|
3133
|
-
}
|
|
3134
|
-
return offsetParent || getContainingBlock(element) || win;
|
|
3135
|
-
}
|
|
3136
|
-
var getElementRects = async function(data) {
|
|
3137
|
-
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
3138
|
-
const getDimensionsFn = this.getDimensions;
|
|
3139
|
-
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
3140
|
-
return {
|
|
3141
|
-
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
3142
|
-
floating: {
|
|
3143
|
-
x: 0,
|
|
3144
|
-
y: 0,
|
|
3145
|
-
width: floatingDimensions.width,
|
|
3146
|
-
height: floatingDimensions.height
|
|
3147
|
-
}
|
|
3148
|
-
};
|
|
3149
|
-
};
|
|
3150
|
-
function isRTL(element) {
|
|
3151
|
-
return getComputedStyle(element).direction === "rtl";
|
|
3152
|
-
}
|
|
3153
|
-
var platform = {
|
|
3154
|
-
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
3155
|
-
getDocumentElement,
|
|
3156
|
-
getClippingRect,
|
|
3157
|
-
getOffsetParent,
|
|
3158
|
-
getElementRects,
|
|
3159
|
-
getClientRects,
|
|
3160
|
-
getDimensions,
|
|
3161
|
-
getScale,
|
|
3162
|
-
isElement,
|
|
3163
|
-
isRTL
|
|
3164
|
-
};
|
|
3165
|
-
var offset2 = offset;
|
|
3166
|
-
var shift2 = shift;
|
|
3167
|
-
var flip2 = flip;
|
|
3168
|
-
var computePosition2 = (reference, floating, options) => {
|
|
3169
|
-
const cache = /* @__PURE__ */ new Map();
|
|
3170
|
-
const mergedOptions = {
|
|
3171
|
-
platform,
|
|
3172
|
-
...options
|
|
3173
|
-
};
|
|
3174
|
-
const platformWithCache = {
|
|
3175
|
-
...mergedOptions.platform,
|
|
3176
|
-
_c: cache
|
|
3177
|
-
};
|
|
3178
|
-
return computePosition(reference, floating, {
|
|
3179
|
-
...mergedOptions,
|
|
3180
|
-
platform: platformWithCache
|
|
3181
|
-
});
|
|
3182
|
-
};
|
|
3183
|
-
|
|
3184
2012
|
// src/link-tooltip.js
|
|
3185
2013
|
var LinkTooltip = class {
|
|
3186
2014
|
constructor(editor) {
|
|
@@ -3188,51 +2016,62 @@ ${blockSuffix}` : suffix;
|
|
|
3188
2016
|
this.tooltip = null;
|
|
3189
2017
|
this.currentLink = null;
|
|
3190
2018
|
this.hideTimeout = null;
|
|
3191
|
-
this.isMouseInTooltip = false;
|
|
3192
|
-
this.isMouseInLink = false;
|
|
3193
2019
|
this.init();
|
|
3194
2020
|
}
|
|
3195
2021
|
init() {
|
|
2022
|
+
const supportsAnchor = CSS.supports("position-anchor: --x") && CSS.supports("position-area: center");
|
|
2023
|
+
if (!supportsAnchor) {
|
|
2024
|
+
return;
|
|
2025
|
+
}
|
|
3196
2026
|
this.createTooltip();
|
|
3197
2027
|
this.editor.textarea.addEventListener("selectionchange", () => this.checkCursorPosition());
|
|
3198
|
-
this.editor.textarea.addEventListener("input", () => this.checkCursorPosition());
|
|
3199
2028
|
this.editor.textarea.addEventListener("keyup", (e) => {
|
|
3200
|
-
if (e.key.includes("Arrow")) {
|
|
2029
|
+
if (e.key.includes("Arrow") || e.key === "Home" || e.key === "End") {
|
|
3201
2030
|
this.checkCursorPosition();
|
|
3202
2031
|
}
|
|
3203
2032
|
});
|
|
2033
|
+
this.editor.textarea.addEventListener("input", () => this.hide());
|
|
3204
2034
|
this.editor.textarea.addEventListener("scroll", () => this.hide());
|
|
3205
|
-
this.tooltip.addEventListener("mouseenter", () =>
|
|
3206
|
-
|
|
3207
|
-
this.cancelHide();
|
|
3208
|
-
});
|
|
3209
|
-
this.tooltip.addEventListener("mouseleave", () => {
|
|
3210
|
-
this.isMouseInTooltip = false;
|
|
3211
|
-
this.scheduleHide();
|
|
3212
|
-
});
|
|
2035
|
+
this.tooltip.addEventListener("mouseenter", () => this.cancelHide());
|
|
2036
|
+
this.tooltip.addEventListener("mouseleave", () => this.scheduleHide());
|
|
3213
2037
|
}
|
|
3214
2038
|
createTooltip() {
|
|
3215
2039
|
this.tooltip = document.createElement("div");
|
|
3216
2040
|
this.tooltip.className = "overtype-link-tooltip";
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
2041
|
+
const tooltipStyles = document.createElement("style");
|
|
2042
|
+
tooltipStyles.textContent = `
|
|
2043
|
+
@supports (position-anchor: --x) and (position-area: center) {
|
|
2044
|
+
.overtype-link-tooltip {
|
|
2045
|
+
position: absolute;
|
|
2046
|
+
position-anchor: var(--target-anchor, --link-0);
|
|
2047
|
+
position-area: block-end center;
|
|
2048
|
+
margin-top: 8px;
|
|
2049
|
+
|
|
2050
|
+
background: #333;
|
|
2051
|
+
color: white;
|
|
2052
|
+
padding: 6px 10px;
|
|
2053
|
+
border-radius: 16px;
|
|
2054
|
+
font-size: 12px;
|
|
2055
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
2056
|
+
display: none;
|
|
2057
|
+
z-index: 10000;
|
|
2058
|
+
cursor: pointer;
|
|
2059
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.3);
|
|
2060
|
+
max-width: 300px;
|
|
2061
|
+
white-space: nowrap;
|
|
2062
|
+
overflow: hidden;
|
|
2063
|
+
text-overflow: ellipsis;
|
|
2064
|
+
|
|
2065
|
+
position-try: most-width block-end inline-end, flip-inline, block-start center;
|
|
2066
|
+
position-visibility: anchors-visible;
|
|
2067
|
+
}
|
|
2068
|
+
|
|
2069
|
+
.overtype-link-tooltip.visible {
|
|
2070
|
+
display: flex;
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
3235
2073
|
`;
|
|
2074
|
+
document.head.appendChild(tooltipStyles);
|
|
3236
2075
|
this.tooltip.innerHTML = `
|
|
3237
2076
|
<span style="display: flex; align-items: center; gap: 6px;">
|
|
3238
2077
|
<svg width="12" height="12" viewBox="0 0 20 20" fill="currentColor" style="flex-shrink: 0;">
|
|
@@ -3250,119 +2089,55 @@ ${blockSuffix}` : suffix;
|
|
|
3250
2089
|
this.hide();
|
|
3251
2090
|
}
|
|
3252
2091
|
});
|
|
3253
|
-
|
|
2092
|
+
this.editor.container.appendChild(this.tooltip);
|
|
3254
2093
|
}
|
|
3255
2094
|
checkCursorPosition() {
|
|
3256
2095
|
const cursorPos = this.editor.textarea.selectionStart;
|
|
3257
2096
|
const text = this.editor.textarea.value;
|
|
3258
|
-
const
|
|
3259
|
-
if (
|
|
3260
|
-
this.
|
|
3261
|
-
|
|
3262
|
-
this.show(link);
|
|
2097
|
+
const linkInfo = this.findLinkAtPosition(text, cursorPos);
|
|
2098
|
+
if (linkInfo) {
|
|
2099
|
+
if (!this.currentLink || this.currentLink.url !== linkInfo.url || this.currentLink.index !== linkInfo.index) {
|
|
2100
|
+
this.show(linkInfo);
|
|
3263
2101
|
}
|
|
3264
2102
|
} else {
|
|
3265
|
-
this.isMouseInLink = false;
|
|
3266
2103
|
this.scheduleHide();
|
|
3267
2104
|
}
|
|
3268
2105
|
}
|
|
3269
2106
|
findLinkAtPosition(text, position) {
|
|
3270
2107
|
const linkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
3271
2108
|
let match;
|
|
2109
|
+
let linkIndex = 0;
|
|
3272
2110
|
while ((match = linkRegex.exec(text)) !== null) {
|
|
3273
2111
|
const start = match.index;
|
|
3274
2112
|
const end = match.index + match[0].length;
|
|
3275
2113
|
if (position >= start && position <= end) {
|
|
3276
2114
|
return {
|
|
3277
|
-
start,
|
|
3278
|
-
end,
|
|
3279
2115
|
text: match[1],
|
|
3280
2116
|
url: match[2],
|
|
3281
|
-
|
|
2117
|
+
index: linkIndex,
|
|
2118
|
+
start,
|
|
2119
|
+
end
|
|
3282
2120
|
};
|
|
3283
2121
|
}
|
|
2122
|
+
linkIndex++;
|
|
3284
2123
|
}
|
|
3285
2124
|
return null;
|
|
3286
2125
|
}
|
|
3287
|
-
|
|
3288
|
-
this.currentLink =
|
|
2126
|
+
show(linkInfo) {
|
|
2127
|
+
this.currentLink = linkInfo;
|
|
3289
2128
|
this.cancelHide();
|
|
3290
2129
|
const urlSpan = this.tooltip.querySelector(".overtype-link-tooltip-url");
|
|
3291
|
-
urlSpan.textContent =
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
await this.positionTooltip(linkElement);
|
|
3295
|
-
} else {
|
|
3296
|
-
await this.positionTooltipAtCursor(link);
|
|
3297
|
-
}
|
|
3298
|
-
this.tooltip.style.display = "block";
|
|
3299
|
-
this.tooltip.offsetHeight;
|
|
3300
|
-
this.tooltip.style.opacity = "1";
|
|
3301
|
-
}
|
|
3302
|
-
findLinkElementInPreview(link) {
|
|
3303
|
-
const links = this.editor.preview.querySelectorAll("a");
|
|
3304
|
-
for (const linkEl of links) {
|
|
3305
|
-
const urlSpans = linkEl.querySelectorAll(".syntax-marker");
|
|
3306
|
-
for (const span of urlSpans) {
|
|
3307
|
-
if (span.textContent === link.url) {
|
|
3308
|
-
return linkEl;
|
|
3309
|
-
}
|
|
3310
|
-
}
|
|
3311
|
-
}
|
|
3312
|
-
return null;
|
|
3313
|
-
}
|
|
3314
|
-
async positionTooltip(referenceEl) {
|
|
3315
|
-
const { x, y } = await computePosition2(referenceEl, this.tooltip, {
|
|
3316
|
-
placement: "bottom",
|
|
3317
|
-
middleware: [
|
|
3318
|
-
offset2(6),
|
|
3319
|
-
flip2(),
|
|
3320
|
-
shift2({ padding: 10 })
|
|
3321
|
-
]
|
|
3322
|
-
});
|
|
3323
|
-
Object.assign(this.tooltip.style, {
|
|
3324
|
-
left: `${x}px`,
|
|
3325
|
-
top: `${y}px`
|
|
3326
|
-
});
|
|
3327
|
-
}
|
|
3328
|
-
async positionTooltipAtCursor(link) {
|
|
3329
|
-
const textarea = this.editor.textarea;
|
|
3330
|
-
const measurer = document.createElement("div");
|
|
3331
|
-
measurer.style.cssText = window.getComputedStyle(textarea).cssText;
|
|
3332
|
-
measurer.style.position = "absolute";
|
|
3333
|
-
measurer.style.visibility = "hidden";
|
|
3334
|
-
measurer.style.whiteSpace = "pre-wrap";
|
|
3335
|
-
measurer.style.wordWrap = "break-word";
|
|
3336
|
-
const textBeforeCursor = textarea.value.substring(0, link.start + link.fullMatch.length / 2);
|
|
3337
|
-
measurer.textContent = textBeforeCursor;
|
|
3338
|
-
document.body.appendChild(measurer);
|
|
3339
|
-
const textHeight = measurer.offsetHeight;
|
|
3340
|
-
document.body.removeChild(measurer);
|
|
3341
|
-
const rect = textarea.getBoundingClientRect();
|
|
3342
|
-
const x = rect.left + rect.width / 2;
|
|
3343
|
-
const y = rect.top + Math.min(textHeight, rect.height - 50);
|
|
3344
|
-
Object.assign(this.tooltip.style, {
|
|
3345
|
-
left: `${x}px`,
|
|
3346
|
-
top: `${y}px`,
|
|
3347
|
-
transform: "translateX(-50%)"
|
|
3348
|
-
});
|
|
2130
|
+
urlSpan.textContent = linkInfo.url;
|
|
2131
|
+
this.tooltip.style.setProperty("--target-anchor", `--link-${linkInfo.index}`);
|
|
2132
|
+
this.tooltip.classList.add("visible");
|
|
3349
2133
|
}
|
|
3350
2134
|
hide() {
|
|
3351
|
-
this.tooltip.
|
|
3352
|
-
|
|
3353
|
-
if (this.tooltip.style.opacity === "0") {
|
|
3354
|
-
this.tooltip.style.display = "none";
|
|
3355
|
-
this.currentLink = null;
|
|
3356
|
-
}
|
|
3357
|
-
}, 200);
|
|
2135
|
+
this.tooltip.classList.remove("visible");
|
|
2136
|
+
this.currentLink = null;
|
|
3358
2137
|
}
|
|
3359
2138
|
scheduleHide() {
|
|
3360
2139
|
this.cancelHide();
|
|
3361
|
-
this.hideTimeout = setTimeout(() =>
|
|
3362
|
-
if (!this.isMouseInTooltip && !this.isMouseInLink) {
|
|
3363
|
-
this.hide();
|
|
3364
|
-
}
|
|
3365
|
-
}, 300);
|
|
2140
|
+
this.hideTimeout = setTimeout(() => this.hide(), 300);
|
|
3366
2141
|
}
|
|
3367
2142
|
cancelHide() {
|
|
3368
2143
|
if (this.hideTimeout) {
|