overtype 1.1.0 → 1.1.3
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 +28 -0
- package/dist/overtype.esm.js +203 -1327
- package/dist/overtype.esm.js.map +4 -4
- package/dist/overtype.js +203 -1327
- package/dist/overtype.js.map +4 -4
- package/dist/overtype.min.js +112 -90
- package/package.json +1 -2
- package/src/link-tooltip.js +75 -149
- package/src/overtype.js +147 -13
- package/src/parser.js +20 -2
- package/src/styles.js +29 -20
package/dist/overtype.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OverType v1.1.
|
|
2
|
+
* OverType v1.1.3
|
|
3
3
|
* A lightweight markdown editor library with perfect WYSIWYG alignment
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @author Demo User
|
|
@@ -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
|
|
@@ -123,7 +129,7 @@ var OverType = (() => {
|
|
|
123
129
|
* @returns {string|null} Parsed code fence or null
|
|
124
130
|
*/
|
|
125
131
|
static parseCodeBlock(html) {
|
|
126
|
-
if (html.
|
|
132
|
+
if (html.match(/^```(\s*|\w*)$/)) {
|
|
127
133
|
return `<div><span class="code-fence">${html}</span></div>`;
|
|
128
134
|
}
|
|
129
135
|
return null;
|
|
@@ -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;
|
|
@@ -1306,7 +1318,7 @@ ${blockSuffix}` : suffix;
|
|
|
1306
1318
|
const {
|
|
1307
1319
|
fontSize = "14px",
|
|
1308
1320
|
lineHeight = 1.6,
|
|
1309
|
-
fontFamily = "
|
|
1321
|
+
fontFamily = '"SF Mono", SFMono-Regular, Menlo, Monaco, "Cascadia Code", Consolas, "Roboto Mono", "Noto Sans Mono", "Droid Sans Mono", "Ubuntu Mono", "DejaVu Sans Mono", "Liberation Mono", "Courier New", Courier, monospace',
|
|
1310
1322
|
padding = "20px",
|
|
1311
1323
|
theme = null,
|
|
1312
1324
|
mobile = {}
|
|
@@ -1326,7 +1338,8 @@ ${blockSuffix}` : suffix;
|
|
|
1326
1338
|
return `
|
|
1327
1339
|
/* OverType Editor Styles */
|
|
1328
1340
|
.overtype-container {
|
|
1329
|
-
|
|
1341
|
+
display: grid !important;
|
|
1342
|
+
grid-template-rows: auto 1fr auto !important;
|
|
1330
1343
|
width: 100% !important;
|
|
1331
1344
|
height: 100% !important;
|
|
1332
1345
|
${themeVars ? `
|
|
@@ -1334,12 +1347,26 @@ ${blockSuffix}` : suffix;
|
|
|
1334
1347
|
${themeVars}` : ""}
|
|
1335
1348
|
}
|
|
1336
1349
|
|
|
1350
|
+
/* Auto-resize mode styles */
|
|
1351
|
+
.overtype-container.overtype-auto-resize {
|
|
1352
|
+
height: auto !important;
|
|
1353
|
+
grid-template-rows: auto auto auto !important;
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
.overtype-container.overtype-auto-resize .overtype-wrapper {
|
|
1357
|
+
height: auto !important;
|
|
1358
|
+
min-height: 60px !important;
|
|
1359
|
+
overflow: visible !important;
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1337
1362
|
.overtype-wrapper {
|
|
1338
1363
|
position: relative !important;
|
|
1339
1364
|
width: 100% !important;
|
|
1340
|
-
height: 100% !important;
|
|
1365
|
+
height: 100% !important; /* Take full height of grid cell */
|
|
1366
|
+
min-height: 60px !important; /* Minimum usable height */
|
|
1341
1367
|
overflow: hidden !important;
|
|
1342
1368
|
background: var(--bg-secondary, #ffffff) !important;
|
|
1369
|
+
grid-row: 2 !important; /* Always second row in grid */
|
|
1343
1370
|
}
|
|
1344
1371
|
|
|
1345
1372
|
/* Critical alignment styles - must be identical for both layers */
|
|
@@ -1354,6 +1381,8 @@ ${blockSuffix}` : suffix;
|
|
|
1354
1381
|
|
|
1355
1382
|
/* Font properties - any difference breaks alignment */
|
|
1356
1383
|
font-family: ${fontFamily} !important;
|
|
1384
|
+
font-synthesis: none !important; /* no faux bold/italic width drift */
|
|
1385
|
+
font-variant-ligatures: none !important; /* keep metrics stable for code */
|
|
1357
1386
|
font-size: var(--instance-font-size, ${fontSize}) !important;
|
|
1358
1387
|
line-height: var(--instance-line-height, ${lineHeight}) !important;
|
|
1359
1388
|
font-weight: normal !important;
|
|
@@ -1620,15 +1649,9 @@ ${blockSuffix}` : suffix;
|
|
|
1620
1649
|
}
|
|
1621
1650
|
|
|
1622
1651
|
/* Stats bar */
|
|
1623
|
-
.overtype-wrapper.with-stats {
|
|
1624
|
-
padding-bottom: 40px !important;
|
|
1625
|
-
}
|
|
1626
1652
|
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
bottom: 0 !important;
|
|
1630
|
-
left: 0 !important;
|
|
1631
|
-
right: 0 !important;
|
|
1653
|
+
/* Stats bar - positioned by grid, not absolute */
|
|
1654
|
+
.overtype-stats {
|
|
1632
1655
|
height: 40px !important;
|
|
1633
1656
|
padding: 0 20px !important;
|
|
1634
1657
|
background: #f8f9fa !important;
|
|
@@ -1639,24 +1662,24 @@ ${blockSuffix}` : suffix;
|
|
|
1639
1662
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
|
|
1640
1663
|
font-size: 0.85rem !important;
|
|
1641
1664
|
color: #666 !important;
|
|
1642
|
-
|
|
1665
|
+
grid-row: 3 !important; /* Always third row in grid */
|
|
1643
1666
|
}
|
|
1644
1667
|
|
|
1645
1668
|
/* Dark theme stats bar */
|
|
1646
|
-
.overtype-
|
|
1669
|
+
.overtype-container[data-theme="cave"] .overtype-stats {
|
|
1647
1670
|
background: var(--bg-secondary, #1D2D3E) !important;
|
|
1648
1671
|
border-top: 1px solid rgba(197, 221, 232, 0.1) !important;
|
|
1649
1672
|
color: var(--text, #c5dde8) !important;
|
|
1650
1673
|
}
|
|
1651
1674
|
|
|
1652
|
-
.overtype-
|
|
1675
|
+
.overtype-stats .overtype-stat {
|
|
1653
1676
|
display: flex !important;
|
|
1654
1677
|
align-items: center !important;
|
|
1655
1678
|
gap: 5px !important;
|
|
1656
1679
|
white-space: nowrap !important;
|
|
1657
1680
|
}
|
|
1658
1681
|
|
|
1659
|
-
.overtype-
|
|
1682
|
+
.overtype-stats .live-dot {
|
|
1660
1683
|
width: 8px !important;
|
|
1661
1684
|
height: 8px !important;
|
|
1662
1685
|
background: #4caf50 !important;
|
|
@@ -1669,11 +1692,6 @@ ${blockSuffix}` : suffix;
|
|
|
1669
1692
|
50% { opacity: 0.6; transform: scale(1.2); }
|
|
1670
1693
|
}
|
|
1671
1694
|
|
|
1672
|
-
/* Adjust textarea and preview for stats bar */
|
|
1673
|
-
.overtype-wrapper.with-stats .overtype-input,
|
|
1674
|
-
.overtype-wrapper.with-stats .overtype-preview {
|
|
1675
|
-
height: calc(100% - 40px) !important;
|
|
1676
|
-
}
|
|
1677
1695
|
|
|
1678
1696
|
/* Toolbar Styles */
|
|
1679
1697
|
.overtype-toolbar {
|
|
@@ -1684,6 +1702,9 @@ ${blockSuffix}` : suffix;
|
|
|
1684
1702
|
background: var(--toolbar-bg, var(--bg-primary, #f8f9fa));
|
|
1685
1703
|
overflow-x: auto;
|
|
1686
1704
|
-webkit-overflow-scrolling: touch;
|
|
1705
|
+
flex-shrink: 0;
|
|
1706
|
+
height: auto !important;
|
|
1707
|
+
grid-row: 1 !important; /* Always first row in grid */
|
|
1687
1708
|
}
|
|
1688
1709
|
|
|
1689
1710
|
.overtype-toolbar-button {
|
|
@@ -1997,1190 +2018,6 @@ ${blockSuffix}` : suffix;
|
|
|
1997
2018
|
}
|
|
1998
2019
|
};
|
|
1999
2020
|
|
|
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
2021
|
// src/link-tooltip.js
|
|
3185
2022
|
var LinkTooltip = class {
|
|
3186
2023
|
constructor(editor) {
|
|
@@ -3188,51 +2025,62 @@ ${blockSuffix}` : suffix;
|
|
|
3188
2025
|
this.tooltip = null;
|
|
3189
2026
|
this.currentLink = null;
|
|
3190
2027
|
this.hideTimeout = null;
|
|
3191
|
-
this.isMouseInTooltip = false;
|
|
3192
|
-
this.isMouseInLink = false;
|
|
3193
2028
|
this.init();
|
|
3194
2029
|
}
|
|
3195
2030
|
init() {
|
|
2031
|
+
const supportsAnchor = CSS.supports("position-anchor: --x") && CSS.supports("position-area: center");
|
|
2032
|
+
if (!supportsAnchor) {
|
|
2033
|
+
return;
|
|
2034
|
+
}
|
|
3196
2035
|
this.createTooltip();
|
|
3197
2036
|
this.editor.textarea.addEventListener("selectionchange", () => this.checkCursorPosition());
|
|
3198
|
-
this.editor.textarea.addEventListener("input", () => this.checkCursorPosition());
|
|
3199
2037
|
this.editor.textarea.addEventListener("keyup", (e) => {
|
|
3200
|
-
if (e.key.includes("Arrow")) {
|
|
2038
|
+
if (e.key.includes("Arrow") || e.key === "Home" || e.key === "End") {
|
|
3201
2039
|
this.checkCursorPosition();
|
|
3202
2040
|
}
|
|
3203
2041
|
});
|
|
2042
|
+
this.editor.textarea.addEventListener("input", () => this.hide());
|
|
3204
2043
|
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
|
-
});
|
|
2044
|
+
this.tooltip.addEventListener("mouseenter", () => this.cancelHide());
|
|
2045
|
+
this.tooltip.addEventListener("mouseleave", () => this.scheduleHide());
|
|
3213
2046
|
}
|
|
3214
2047
|
createTooltip() {
|
|
3215
2048
|
this.tooltip = document.createElement("div");
|
|
3216
2049
|
this.tooltip.className = "overtype-link-tooltip";
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
2050
|
+
const tooltipStyles = document.createElement("style");
|
|
2051
|
+
tooltipStyles.textContent = `
|
|
2052
|
+
@supports (position-anchor: --x) and (position-area: center) {
|
|
2053
|
+
.overtype-link-tooltip {
|
|
2054
|
+
position: absolute;
|
|
2055
|
+
position-anchor: var(--target-anchor, --link-0);
|
|
2056
|
+
position-area: block-end center;
|
|
2057
|
+
margin-top: 8px;
|
|
2058
|
+
|
|
2059
|
+
background: #333;
|
|
2060
|
+
color: white;
|
|
2061
|
+
padding: 6px 10px;
|
|
2062
|
+
border-radius: 16px;
|
|
2063
|
+
font-size: 12px;
|
|
2064
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
2065
|
+
display: none;
|
|
2066
|
+
z-index: 10000;
|
|
2067
|
+
cursor: pointer;
|
|
2068
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.3);
|
|
2069
|
+
max-width: 300px;
|
|
2070
|
+
white-space: nowrap;
|
|
2071
|
+
overflow: hidden;
|
|
2072
|
+
text-overflow: ellipsis;
|
|
2073
|
+
|
|
2074
|
+
position-try: most-width block-end inline-end, flip-inline, block-start center;
|
|
2075
|
+
position-visibility: anchors-visible;
|
|
2076
|
+
}
|
|
2077
|
+
|
|
2078
|
+
.overtype-link-tooltip.visible {
|
|
2079
|
+
display: flex;
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
3235
2082
|
`;
|
|
2083
|
+
document.head.appendChild(tooltipStyles);
|
|
3236
2084
|
this.tooltip.innerHTML = `
|
|
3237
2085
|
<span style="display: flex; align-items: center; gap: 6px;">
|
|
3238
2086
|
<svg width="12" height="12" viewBox="0 0 20 20" fill="currentColor" style="flex-shrink: 0;">
|
|
@@ -3250,119 +2098,55 @@ ${blockSuffix}` : suffix;
|
|
|
3250
2098
|
this.hide();
|
|
3251
2099
|
}
|
|
3252
2100
|
});
|
|
3253
|
-
|
|
2101
|
+
this.editor.container.appendChild(this.tooltip);
|
|
3254
2102
|
}
|
|
3255
2103
|
checkCursorPosition() {
|
|
3256
2104
|
const cursorPos = this.editor.textarea.selectionStart;
|
|
3257
2105
|
const text = this.editor.textarea.value;
|
|
3258
|
-
const
|
|
3259
|
-
if (
|
|
3260
|
-
this.
|
|
3261
|
-
|
|
3262
|
-
this.show(link);
|
|
2106
|
+
const linkInfo = this.findLinkAtPosition(text, cursorPos);
|
|
2107
|
+
if (linkInfo) {
|
|
2108
|
+
if (!this.currentLink || this.currentLink.url !== linkInfo.url || this.currentLink.index !== linkInfo.index) {
|
|
2109
|
+
this.show(linkInfo);
|
|
3263
2110
|
}
|
|
3264
2111
|
} else {
|
|
3265
|
-
this.isMouseInLink = false;
|
|
3266
2112
|
this.scheduleHide();
|
|
3267
2113
|
}
|
|
3268
2114
|
}
|
|
3269
2115
|
findLinkAtPosition(text, position) {
|
|
3270
2116
|
const linkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
3271
2117
|
let match;
|
|
2118
|
+
let linkIndex = 0;
|
|
3272
2119
|
while ((match = linkRegex.exec(text)) !== null) {
|
|
3273
2120
|
const start = match.index;
|
|
3274
2121
|
const end = match.index + match[0].length;
|
|
3275
2122
|
if (position >= start && position <= end) {
|
|
3276
2123
|
return {
|
|
3277
|
-
start,
|
|
3278
|
-
end,
|
|
3279
2124
|
text: match[1],
|
|
3280
2125
|
url: match[2],
|
|
3281
|
-
|
|
2126
|
+
index: linkIndex,
|
|
2127
|
+
start,
|
|
2128
|
+
end
|
|
3282
2129
|
};
|
|
3283
2130
|
}
|
|
2131
|
+
linkIndex++;
|
|
3284
2132
|
}
|
|
3285
2133
|
return null;
|
|
3286
2134
|
}
|
|
3287
|
-
|
|
3288
|
-
this.currentLink =
|
|
2135
|
+
show(linkInfo) {
|
|
2136
|
+
this.currentLink = linkInfo;
|
|
3289
2137
|
this.cancelHide();
|
|
3290
2138
|
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
|
-
});
|
|
2139
|
+
urlSpan.textContent = linkInfo.url;
|
|
2140
|
+
this.tooltip.style.setProperty("--target-anchor", `--link-${linkInfo.index}`);
|
|
2141
|
+
this.tooltip.classList.add("visible");
|
|
3349
2142
|
}
|
|
3350
2143
|
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);
|
|
2144
|
+
this.tooltip.classList.remove("visible");
|
|
2145
|
+
this.currentLink = null;
|
|
3358
2146
|
}
|
|
3359
2147
|
scheduleHide() {
|
|
3360
2148
|
this.cancelHide();
|
|
3361
|
-
this.hideTimeout = setTimeout(() =>
|
|
3362
|
-
if (!this.isMouseInTooltip && !this.isMouseInLink) {
|
|
3363
|
-
this.hide();
|
|
3364
|
-
}
|
|
3365
|
-
}, 300);
|
|
2149
|
+
this.hideTimeout = setTimeout(() => this.hide(), 300);
|
|
3366
2150
|
}
|
|
3367
2151
|
cancelHide() {
|
|
3368
2152
|
if (this.hideTimeout) {
|
|
@@ -3472,8 +2256,16 @@ ${blockSuffix}` : suffix;
|
|
|
3472
2256
|
padding: "12px",
|
|
3473
2257
|
lineHeight: 1.5
|
|
3474
2258
|
},
|
|
2259
|
+
// Native textarea properties
|
|
2260
|
+
textareaProps: {},
|
|
3475
2261
|
// Behavior
|
|
3476
2262
|
autofocus: false,
|
|
2263
|
+
autoResize: false,
|
|
2264
|
+
// Auto-expand height with content
|
|
2265
|
+
minHeight: "100px",
|
|
2266
|
+
// Minimum height for autoResize mode
|
|
2267
|
+
maxHeight: null,
|
|
2268
|
+
// Maximum height for autoResize mode (null = unlimited)
|
|
3477
2269
|
placeholder: "Start typing...",
|
|
3478
2270
|
value: "",
|
|
3479
2271
|
// Callbacks
|
|
@@ -3590,9 +2382,6 @@ ${blockSuffix}` : suffix;
|
|
|
3590
2382
|
}
|
|
3591
2383
|
this.wrapper = document.createElement("div");
|
|
3592
2384
|
this.wrapper.className = "overtype-wrapper";
|
|
3593
|
-
if (this.options.showStats) {
|
|
3594
|
-
this.wrapper.classList.add("with-stats");
|
|
3595
|
-
}
|
|
3596
2385
|
if (this.options.fontSize) {
|
|
3597
2386
|
this.wrapper.style.setProperty("--instance-font-size", this.options.fontSize);
|
|
3598
2387
|
}
|
|
@@ -3607,19 +2396,47 @@ ${blockSuffix}` : suffix;
|
|
|
3607
2396
|
this.textarea.className = "overtype-input";
|
|
3608
2397
|
this.textarea.placeholder = this.options.placeholder;
|
|
3609
2398
|
this._configureTextarea();
|
|
2399
|
+
if (this.options.textareaProps) {
|
|
2400
|
+
Object.entries(this.options.textareaProps).forEach(([key, value]) => {
|
|
2401
|
+
if (key === "className" || key === "class") {
|
|
2402
|
+
this.textarea.className += " " + value;
|
|
2403
|
+
} else if (key === "style" && typeof value === "object") {
|
|
2404
|
+
Object.assign(this.textarea.style, value);
|
|
2405
|
+
} else {
|
|
2406
|
+
this.textarea.setAttribute(key, value);
|
|
2407
|
+
}
|
|
2408
|
+
});
|
|
2409
|
+
}
|
|
3610
2410
|
this.preview = document.createElement("div");
|
|
3611
2411
|
this.preview.className = "overtype-preview";
|
|
3612
2412
|
this.preview.setAttribute("aria-hidden", "true");
|
|
3613
2413
|
this.wrapper.appendChild(this.textarea);
|
|
3614
2414
|
this.wrapper.appendChild(this.preview);
|
|
2415
|
+
this.container.appendChild(this.wrapper);
|
|
3615
2416
|
if (this.options.showStats) {
|
|
3616
2417
|
this.statsBar = document.createElement("div");
|
|
3617
2418
|
this.statsBar.className = "overtype-stats";
|
|
3618
|
-
this.
|
|
2419
|
+
this.container.appendChild(this.statsBar);
|
|
3619
2420
|
this._updateStats();
|
|
3620
2421
|
}
|
|
3621
|
-
this.container.appendChild(this.wrapper);
|
|
3622
2422
|
this.element.appendChild(this.container);
|
|
2423
|
+
if (window.location.pathname.includes("demo.html")) {
|
|
2424
|
+
console.log("_createDOM completed:", {
|
|
2425
|
+
elementId: this.element.id,
|
|
2426
|
+
autoResize: this.options.autoResize,
|
|
2427
|
+
containerClasses: this.container.className,
|
|
2428
|
+
hasStats: !!this.statsBar,
|
|
2429
|
+
hasToolbar: this.options.toolbar
|
|
2430
|
+
});
|
|
2431
|
+
}
|
|
2432
|
+
if (this.options.autoResize) {
|
|
2433
|
+
this._setupAutoResize();
|
|
2434
|
+
} else {
|
|
2435
|
+
this.container.classList.remove("overtype-auto-resize");
|
|
2436
|
+
if (window.location.pathname.includes("demo.html")) {
|
|
2437
|
+
console.log("Removed auto-resize class from:", this.element.id);
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
3623
2440
|
}
|
|
3624
2441
|
/**
|
|
3625
2442
|
* Configure textarea attributes
|
|
@@ -3642,6 +2459,13 @@ ${blockSuffix}` : suffix;
|
|
|
3642
2459
|
if (this.options.autofocus) {
|
|
3643
2460
|
this.textarea.focus();
|
|
3644
2461
|
}
|
|
2462
|
+
if (this.options.autoResize) {
|
|
2463
|
+
if (!this.container.classList.contains("overtype-auto-resize")) {
|
|
2464
|
+
this._setupAutoResize();
|
|
2465
|
+
}
|
|
2466
|
+
} else {
|
|
2467
|
+
this.container.classList.remove("overtype-auto-resize");
|
|
2468
|
+
}
|
|
3645
2469
|
this.updatePreview();
|
|
3646
2470
|
}
|
|
3647
2471
|
/**
|
|
@@ -3766,6 +2590,9 @@ ${blockSuffix}` : suffix;
|
|
|
3766
2590
|
setValue(value) {
|
|
3767
2591
|
this.textarea.value = value;
|
|
3768
2592
|
this.updatePreview();
|
|
2593
|
+
if (this.options.autoResize) {
|
|
2594
|
+
this._updateAutoHeight();
|
|
2595
|
+
}
|
|
3769
2596
|
}
|
|
3770
2597
|
/**
|
|
3771
2598
|
* Focus the editor
|
|
@@ -3829,6 +2656,57 @@ ${blockSuffix}` : suffix;
|
|
|
3829
2656
|
`;
|
|
3830
2657
|
}
|
|
3831
2658
|
}
|
|
2659
|
+
/**
|
|
2660
|
+
* Setup auto-resize functionality
|
|
2661
|
+
* @private
|
|
2662
|
+
*/
|
|
2663
|
+
_setupAutoResize() {
|
|
2664
|
+
this.container.classList.add("overtype-auto-resize");
|
|
2665
|
+
this.previousHeight = null;
|
|
2666
|
+
this._updateAutoHeight();
|
|
2667
|
+
this.textarea.addEventListener("input", () => this._updateAutoHeight());
|
|
2668
|
+
window.addEventListener("resize", () => this._updateAutoHeight());
|
|
2669
|
+
}
|
|
2670
|
+
/**
|
|
2671
|
+
* Update height based on scrollHeight
|
|
2672
|
+
* @private
|
|
2673
|
+
*/
|
|
2674
|
+
_updateAutoHeight() {
|
|
2675
|
+
if (!this.options.autoResize)
|
|
2676
|
+
return;
|
|
2677
|
+
const textarea = this.textarea;
|
|
2678
|
+
const preview = this.preview;
|
|
2679
|
+
const wrapper = this.wrapper;
|
|
2680
|
+
const computed = window.getComputedStyle(textarea);
|
|
2681
|
+
const paddingTop = parseFloat(computed.paddingTop);
|
|
2682
|
+
const paddingBottom = parseFloat(computed.paddingBottom);
|
|
2683
|
+
const scrollTop = textarea.scrollTop;
|
|
2684
|
+
textarea.style.setProperty("height", "auto", "important");
|
|
2685
|
+
let newHeight = textarea.scrollHeight;
|
|
2686
|
+
if (this.options.minHeight) {
|
|
2687
|
+
const minHeight = parseInt(this.options.minHeight);
|
|
2688
|
+
newHeight = Math.max(newHeight, minHeight);
|
|
2689
|
+
}
|
|
2690
|
+
let overflow = "hidden";
|
|
2691
|
+
if (this.options.maxHeight) {
|
|
2692
|
+
const maxHeight = parseInt(this.options.maxHeight);
|
|
2693
|
+
if (newHeight > maxHeight) {
|
|
2694
|
+
newHeight = maxHeight;
|
|
2695
|
+
overflow = "auto";
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
const heightPx = newHeight + "px";
|
|
2699
|
+
textarea.style.setProperty("height", heightPx, "important");
|
|
2700
|
+
textarea.style.setProperty("overflow-y", overflow, "important");
|
|
2701
|
+
preview.style.setProperty("height", heightPx, "important");
|
|
2702
|
+
preview.style.setProperty("overflow-y", overflow, "important");
|
|
2703
|
+
wrapper.style.setProperty("height", heightPx, "important");
|
|
2704
|
+
textarea.scrollTop = scrollTop;
|
|
2705
|
+
preview.scrollTop = scrollTop;
|
|
2706
|
+
if (this.previousHeight !== newHeight) {
|
|
2707
|
+
this.previousHeight = newHeight;
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
3832
2710
|
/**
|
|
3833
2711
|
* Show or hide stats bar
|
|
3834
2712
|
* @param {boolean} show - Whether to show stats
|
|
@@ -3838,13 +2716,11 @@ ${blockSuffix}` : suffix;
|
|
|
3838
2716
|
if (show && !this.statsBar) {
|
|
3839
2717
|
this.statsBar = document.createElement("div");
|
|
3840
2718
|
this.statsBar.className = "overtype-stats";
|
|
3841
|
-
this.
|
|
3842
|
-
this.wrapper.classList.add("with-stats");
|
|
2719
|
+
this.container.appendChild(this.statsBar);
|
|
3843
2720
|
this._updateStats();
|
|
3844
2721
|
} else if (!show && this.statsBar) {
|
|
3845
2722
|
this.statsBar.remove();
|
|
3846
2723
|
this.statsBar = null;
|
|
3847
|
-
this.wrapper.classList.remove("with-stats");
|
|
3848
2724
|
}
|
|
3849
2725
|
}
|
|
3850
2726
|
/**
|