overtype 2.1.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -23
- package/dist/overtype-webcomponent.esm.js +1647 -120
- package/dist/overtype-webcomponent.esm.js.map +4 -4
- package/dist/overtype-webcomponent.js +1647 -120
- package/dist/overtype-webcomponent.js.map +4 -4
- package/dist/overtype-webcomponent.min.js +129 -111
- package/dist/overtype.cjs +1617 -117
- package/dist/overtype.cjs.map +4 -4
- package/dist/overtype.d.ts +33 -0
- package/dist/overtype.esm.js +1617 -117
- package/dist/overtype.esm.js.map +4 -4
- package/dist/overtype.js +1617 -117
- package/dist/overtype.js.map +4 -4
- package/dist/overtype.min.js +132 -114
- package/package.json +4 -4
- package/src/icons.js +6 -0
- package/src/link-tooltip.js +22 -67
- package/src/overtype-webcomponent.js +32 -3
- package/src/overtype.d.ts +33 -0
- package/src/overtype.js +272 -36
- package/src/parser.js +9 -3
- package/src/styles.js +62 -49
- package/src/themes.js +54 -3
- package/src/toolbar-buttons.js +23 -0
- package/src/toolbar.js +12 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OverType v2.
|
|
2
|
+
* OverType v2.3.0
|
|
3
3
|
* A lightweight markdown editor library with perfect WYSIWYG alignment
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @author David Miranda
|
|
@@ -79,6 +79,7 @@ var MarkdownParser = class {
|
|
|
79
79
|
static parseHeader(html) {
|
|
80
80
|
return html.replace(/^(#{1,3})\s(.+)$/, (match, hashes, content) => {
|
|
81
81
|
const level = hashes.length;
|
|
82
|
+
content = this.parseInlineElements(content);
|
|
82
83
|
return `<h${level}><span class="syntax-marker">${hashes} </span>${content}</h${level}>`;
|
|
83
84
|
});
|
|
84
85
|
}
|
|
@@ -110,6 +111,7 @@ var MarkdownParser = class {
|
|
|
110
111
|
*/
|
|
111
112
|
static parseBulletList(html) {
|
|
112
113
|
return html.replace(/^((?: )*)([-*+])\s(.+)$/, (match, indent, marker, content) => {
|
|
114
|
+
content = this.parseInlineElements(content);
|
|
113
115
|
return `${indent}<li class="bullet-list"><span class="syntax-marker">${marker} </span>${content}</li>`;
|
|
114
116
|
});
|
|
115
117
|
}
|
|
@@ -121,6 +123,7 @@ var MarkdownParser = class {
|
|
|
121
123
|
*/
|
|
122
124
|
static parseTaskList(html, isPreviewMode = false) {
|
|
123
125
|
return html.replace(/^((?: )*)-\s+\[([ xX])\]\s+(.+)$/, (match, indent, checked, content) => {
|
|
126
|
+
content = this.parseInlineElements(content);
|
|
124
127
|
if (isPreviewMode) {
|
|
125
128
|
const isChecked = checked.toLowerCase() === "x";
|
|
126
129
|
return `${indent}<li class="task-list"><input type="checkbox" ${isChecked ? "checked" : ""}> ${content}</li>`;
|
|
@@ -136,6 +139,7 @@ var MarkdownParser = class {
|
|
|
136
139
|
*/
|
|
137
140
|
static parseNumberedList(html) {
|
|
138
141
|
return html.replace(/^((?: )*)(\d+\.)\s(.+)$/, (match, indent, marker, content) => {
|
|
142
|
+
content = this.parseInlineElements(content);
|
|
139
143
|
return `${indent}<li class="ordered-list"><span class="syntax-marker">${marker} </span>${content}</li>`;
|
|
140
144
|
});
|
|
141
145
|
}
|
|
@@ -357,7 +361,9 @@ var MarkdownParser = class {
|
|
|
357
361
|
html = this.parseTaskList(html, isPreviewMode);
|
|
358
362
|
html = this.parseBulletList(html);
|
|
359
363
|
html = this.parseNumberedList(html);
|
|
360
|
-
html
|
|
364
|
+
if (!html.includes("<li") && !html.includes("<h")) {
|
|
365
|
+
html = this.parseInlineElements(html);
|
|
366
|
+
}
|
|
361
367
|
if (html.trim() === "") {
|
|
362
368
|
return "<div> </div>";
|
|
363
369
|
}
|
|
@@ -846,8 +852,24 @@ var solar = {
|
|
|
846
852
|
// Yale Blue - icon color
|
|
847
853
|
toolbarHover: "#f5f5f5",
|
|
848
854
|
// Light gray - hover background
|
|
849
|
-
toolbarActive: "#faf0ca"
|
|
855
|
+
toolbarActive: "#faf0ca",
|
|
850
856
|
// Lemon Chiffon - active button background
|
|
857
|
+
placeholder: "#999999"
|
|
858
|
+
// Gray - placeholder text
|
|
859
|
+
},
|
|
860
|
+
previewColors: {
|
|
861
|
+
text: "#1a1a1a",
|
|
862
|
+
h1: "#1a1a1a",
|
|
863
|
+
h2: "#2a2a2a",
|
|
864
|
+
h3: "#3a3a3a",
|
|
865
|
+
strong: "inherit",
|
|
866
|
+
em: "inherit",
|
|
867
|
+
link: "#0066cc",
|
|
868
|
+
code: "#1a1a1a",
|
|
869
|
+
codeBg: "rgba(135, 131, 120, 0.15)",
|
|
870
|
+
blockquote: "#555",
|
|
871
|
+
hr: "#ddd",
|
|
872
|
+
bg: "transparent"
|
|
851
873
|
}
|
|
852
874
|
};
|
|
853
875
|
var cave = {
|
|
@@ -910,13 +932,30 @@ var cave = {
|
|
|
910
932
|
// Light blue-gray - icon color
|
|
911
933
|
toolbarHover: "#243546",
|
|
912
934
|
// Slightly lighter charcoal - hover background
|
|
913
|
-
toolbarActive: "#2a3f52"
|
|
935
|
+
toolbarActive: "#2a3f52",
|
|
914
936
|
// Even lighter - active button background
|
|
937
|
+
placeholder: "#6a7a88"
|
|
938
|
+
// Muted blue-gray - placeholder text
|
|
939
|
+
},
|
|
940
|
+
previewColors: {
|
|
941
|
+
text: "#c5dde8",
|
|
942
|
+
h1: "#e0e0e0",
|
|
943
|
+
h2: "#d0d0d0",
|
|
944
|
+
h3: "#c0c0c0",
|
|
945
|
+
strong: "inherit",
|
|
946
|
+
em: "inherit",
|
|
947
|
+
link: "#6cb6e0",
|
|
948
|
+
code: "#c5dde8",
|
|
949
|
+
codeBg: "rgba(255, 255, 255, 0.08)",
|
|
950
|
+
blockquote: "#9aa8b4",
|
|
951
|
+
hr: "rgba(255, 255, 255, 0.15)",
|
|
952
|
+
bg: "transparent"
|
|
915
953
|
}
|
|
916
954
|
};
|
|
917
955
|
var themes = {
|
|
918
956
|
solar,
|
|
919
957
|
cave,
|
|
958
|
+
auto: solar,
|
|
920
959
|
// Aliases for backward compatibility
|
|
921
960
|
light: solar,
|
|
922
961
|
dark: cave
|
|
@@ -928,20 +967,36 @@ function getTheme(theme) {
|
|
|
928
967
|
}
|
|
929
968
|
return theme;
|
|
930
969
|
}
|
|
931
|
-
function
|
|
970
|
+
function resolveAutoTheme(themeName) {
|
|
971
|
+
if (themeName !== "auto")
|
|
972
|
+
return themeName;
|
|
973
|
+
const mq = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)");
|
|
974
|
+
return (mq == null ? void 0 : mq.matches) ? "cave" : "solar";
|
|
975
|
+
}
|
|
976
|
+
function themeToCSSVars(colors, previewColors) {
|
|
932
977
|
const vars = [];
|
|
933
978
|
for (const [key, value] of Object.entries(colors)) {
|
|
934
979
|
const varName = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
935
980
|
vars.push(`--${varName}: ${value};`);
|
|
936
981
|
}
|
|
982
|
+
if (previewColors) {
|
|
983
|
+
for (const [key, value] of Object.entries(previewColors)) {
|
|
984
|
+
const varName = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
985
|
+
vars.push(`--preview-${varName}: ${value};`);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
937
988
|
return vars.join("\n");
|
|
938
989
|
}
|
|
939
|
-
function mergeTheme(baseTheme, customColors = {}) {
|
|
990
|
+
function mergeTheme(baseTheme, customColors = {}, customPreviewColors = {}) {
|
|
940
991
|
return {
|
|
941
992
|
...baseTheme,
|
|
942
993
|
colors: {
|
|
943
994
|
...baseTheme.colors,
|
|
944
995
|
...customColors
|
|
996
|
+
},
|
|
997
|
+
previewColors: {
|
|
998
|
+
...baseTheme.previewColors,
|
|
999
|
+
...customPreviewColors
|
|
945
1000
|
}
|
|
946
1001
|
};
|
|
947
1002
|
}
|
|
@@ -968,7 +1023,7 @@ function generateStyles(options = {}) {
|
|
|
968
1023
|
}
|
|
969
1024
|
}
|
|
970
1025
|
` : "";
|
|
971
|
-
const themeVars = theme && theme.colors ? themeToCSSVars(theme.colors) : "";
|
|
1026
|
+
const themeVars = theme && theme.colors ? themeToCSSVars(theme.colors, theme.previewColors) : "";
|
|
972
1027
|
return `
|
|
973
1028
|
/* OverType Editor Styles */
|
|
974
1029
|
|
|
@@ -1141,17 +1196,36 @@ function generateStyles(options = {}) {
|
|
|
1141
1196
|
/* Prevent mobile zoom on focus */
|
|
1142
1197
|
touch-action: manipulation !important;
|
|
1143
1198
|
|
|
1144
|
-
/* Disable autofill
|
|
1199
|
+
/* Disable autofill */
|
|
1145
1200
|
autocomplete: off !important;
|
|
1146
1201
|
autocorrect: off !important;
|
|
1147
1202
|
autocapitalize: off !important;
|
|
1148
|
-
spellcheck: false !important;
|
|
1149
1203
|
}
|
|
1150
1204
|
|
|
1151
1205
|
.overtype-wrapper .overtype-input::selection {
|
|
1152
1206
|
background-color: var(--selection, rgba(244, 211, 94, 0.4));
|
|
1153
1207
|
}
|
|
1154
1208
|
|
|
1209
|
+
/* Placeholder shim - visible when textarea is empty */
|
|
1210
|
+
.overtype-wrapper .overtype-placeholder {
|
|
1211
|
+
position: absolute !important;
|
|
1212
|
+
top: 0 !important;
|
|
1213
|
+
left: 0 !important;
|
|
1214
|
+
width: 100% !important;
|
|
1215
|
+
z-index: 0 !important;
|
|
1216
|
+
pointer-events: none !important;
|
|
1217
|
+
user-select: none !important;
|
|
1218
|
+
font-family: ${fontFamily} !important;
|
|
1219
|
+
font-size: var(--instance-font-size, ${fontSize}) !important;
|
|
1220
|
+
line-height: var(--instance-line-height, ${lineHeight}) !important;
|
|
1221
|
+
padding: var(--instance-padding, ${padding}) !important;
|
|
1222
|
+
box-sizing: border-box !important;
|
|
1223
|
+
color: var(--placeholder, #999) !important;
|
|
1224
|
+
overflow: hidden !important;
|
|
1225
|
+
white-space: nowrap !important;
|
|
1226
|
+
text-overflow: ellipsis !important;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1155
1229
|
/* Preview layer styles */
|
|
1156
1230
|
.overtype-wrapper .overtype-preview {
|
|
1157
1231
|
/* Layer positioning */
|
|
@@ -1419,6 +1493,10 @@ function generateStyles(options = {}) {
|
|
|
1419
1493
|
|
|
1420
1494
|
|
|
1421
1495
|
/* Toolbar Styles */
|
|
1496
|
+
.overtype-toolbar.overtype-toolbar-hidden {
|
|
1497
|
+
display: none !important;
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1422
1500
|
.overtype-toolbar {
|
|
1423
1501
|
display: flex !important;
|
|
1424
1502
|
align-items: center !important;
|
|
@@ -1617,27 +1695,29 @@ function generateStyles(options = {}) {
|
|
|
1617
1695
|
}
|
|
1618
1696
|
|
|
1619
1697
|
/* Headers - restore proper sizing in preview mode */
|
|
1620
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1,
|
|
1621
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2,
|
|
1698
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1,
|
|
1699
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2,
|
|
1622
1700
|
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h3 {
|
|
1623
1701
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
|
|
1624
1702
|
font-weight: 600 !important;
|
|
1625
1703
|
margin: 0 !important;
|
|
1626
1704
|
display: block !important;
|
|
1627
|
-
|
|
1628
|
-
line-height: 1 !important; /* Tight line height for headings */
|
|
1705
|
+
line-height: 1 !important;
|
|
1629
1706
|
}
|
|
1630
|
-
|
|
1631
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1 {
|
|
1632
|
-
font-size: 2em !important;
|
|
1707
|
+
|
|
1708
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1 {
|
|
1709
|
+
font-size: 2em !important;
|
|
1710
|
+
color: var(--preview-h1, #222) !important;
|
|
1633
1711
|
}
|
|
1634
|
-
|
|
1635
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2 {
|
|
1636
|
-
font-size: 1.5em !important;
|
|
1712
|
+
|
|
1713
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2 {
|
|
1714
|
+
font-size: 1.5em !important;
|
|
1715
|
+
color: var(--preview-h2, #333) !important;
|
|
1637
1716
|
}
|
|
1638
|
-
|
|
1639
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h3 {
|
|
1640
|
-
font-size: 1.17em !important;
|
|
1717
|
+
|
|
1718
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h3 {
|
|
1719
|
+
font-size: 1.17em !important;
|
|
1720
|
+
color: var(--preview-h3, #444) !important;
|
|
1641
1721
|
}
|
|
1642
1722
|
|
|
1643
1723
|
/* Lists - restore list styling in preview mode */
|
|
@@ -1687,25 +1767,20 @@ function generateStyles(options = {}) {
|
|
|
1687
1767
|
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview a {
|
|
1688
1768
|
pointer-events: auto !important;
|
|
1689
1769
|
cursor: pointer !important;
|
|
1690
|
-
color: var(--link, #0066cc) !important;
|
|
1770
|
+
color: var(--preview-link, #0066cc) !important;
|
|
1691
1771
|
text-decoration: underline !important;
|
|
1692
1772
|
}
|
|
1693
1773
|
|
|
1694
1774
|
/* Code blocks - proper pre/code styling in preview mode */
|
|
1695
1775
|
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview pre.code-block {
|
|
1696
|
-
background:
|
|
1697
|
-
color: #
|
|
1776
|
+
background: var(--preview-code-bg, rgba(135, 131, 120, 0.15)) !important;
|
|
1777
|
+
color: var(--preview-code, #333) !important;
|
|
1698
1778
|
padding: 1.2em !important;
|
|
1699
1779
|
border-radius: 3px !important;
|
|
1700
1780
|
overflow-x: auto !important;
|
|
1701
1781
|
margin: 0 !important;
|
|
1702
1782
|
display: block !important;
|
|
1703
1783
|
}
|
|
1704
|
-
|
|
1705
|
-
/* Cave theme code block background in preview mode */
|
|
1706
|
-
.overtype-container[data-theme="cave"][data-mode="preview"] .overtype-wrapper .overtype-preview pre.code-block {
|
|
1707
|
-
background: #11171F !important;
|
|
1708
|
-
}
|
|
1709
1784
|
|
|
1710
1785
|
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview pre.code-block code {
|
|
1711
1786
|
background: transparent !important;
|
|
@@ -1728,7 +1803,8 @@ function generateStyles(options = {}) {
|
|
|
1728
1803
|
/* Blockquotes - enhanced styling in preview mode */
|
|
1729
1804
|
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .blockquote {
|
|
1730
1805
|
display: block !important;
|
|
1731
|
-
border-left: 4px solid var(--blockquote, #
|
|
1806
|
+
border-left: 4px solid var(--preview-blockquote, #666) !important;
|
|
1807
|
+
color: var(--preview-blockquote, #666) !important;
|
|
1732
1808
|
padding-left: 1em !important;
|
|
1733
1809
|
margin: 1em 0 !important;
|
|
1734
1810
|
font-style: italic !important;
|
|
@@ -1739,14 +1815,16 @@ function generateStyles(options = {}) {
|
|
|
1739
1815
|
font-family: Georgia, 'Times New Roman', serif !important;
|
|
1740
1816
|
font-size: 16px !important;
|
|
1741
1817
|
line-height: 1.8 !important;
|
|
1742
|
-
color: var(--text, #333) !important;
|
|
1818
|
+
color: var(--preview-text, #333) !important;
|
|
1819
|
+
background: var(--preview-bg, transparent) !important;
|
|
1743
1820
|
}
|
|
1744
1821
|
|
|
1745
1822
|
/* Inline code in preview mode - keep monospace */
|
|
1746
1823
|
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview code {
|
|
1747
1824
|
font-family: ${fontFamily} !important;
|
|
1748
1825
|
font-size: 0.9em !important;
|
|
1749
|
-
background: rgba(135, 131, 120, 0.15) !important;
|
|
1826
|
+
background: var(--preview-code-bg, rgba(135, 131, 120, 0.15)) !important;
|
|
1827
|
+
color: var(--preview-code, #333) !important;
|
|
1750
1828
|
padding: 0.2em 0.4em !important;
|
|
1751
1829
|
border-radius: 3px !important;
|
|
1752
1830
|
}
|
|
@@ -1754,32 +1832,33 @@ function generateStyles(options = {}) {
|
|
|
1754
1832
|
/* Strong and em elements in preview mode */
|
|
1755
1833
|
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview strong {
|
|
1756
1834
|
font-weight: 700 !important;
|
|
1757
|
-
color: inherit !important;
|
|
1835
|
+
color: var(--preview-strong, inherit) !important;
|
|
1758
1836
|
}
|
|
1759
1837
|
|
|
1760
1838
|
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview em {
|
|
1761
1839
|
font-style: italic !important;
|
|
1762
|
-
color: inherit !important;
|
|
1840
|
+
color: var(--preview-em, inherit) !important;
|
|
1763
1841
|
}
|
|
1764
1842
|
|
|
1765
1843
|
/* HR in preview mode */
|
|
1766
1844
|
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .hr-marker {
|
|
1767
1845
|
display: block !important;
|
|
1768
|
-
border-top: 2px solid var(--hr, #ddd) !important;
|
|
1846
|
+
border-top: 2px solid var(--preview-hr, #ddd) !important;
|
|
1769
1847
|
text-indent: -9999px !important;
|
|
1770
1848
|
height: 2px !important;
|
|
1771
1849
|
}
|
|
1772
1850
|
|
|
1773
|
-
/* Link Tooltip
|
|
1851
|
+
/* Link Tooltip */
|
|
1774
1852
|
.overtype-link-tooltip {
|
|
1775
|
-
/* Visual styles that work for both positioning methods */
|
|
1776
1853
|
background: #333 !important;
|
|
1777
1854
|
color: white !important;
|
|
1778
1855
|
padding: 6px 10px !important;
|
|
1779
1856
|
border-radius: 16px !important;
|
|
1780
1857
|
font-size: 12px !important;
|
|
1781
1858
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
|
|
1782
|
-
display:
|
|
1859
|
+
display: flex !important;
|
|
1860
|
+
visibility: hidden !important;
|
|
1861
|
+
pointer-events: none !important;
|
|
1783
1862
|
z-index: 10000 !important;
|
|
1784
1863
|
cursor: pointer !important;
|
|
1785
1864
|
box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
|
|
@@ -1787,25 +1866,14 @@ function generateStyles(options = {}) {
|
|
|
1787
1866
|
white-space: nowrap !important;
|
|
1788
1867
|
overflow: hidden !important;
|
|
1789
1868
|
text-overflow: ellipsis !important;
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1869
|
+
position: fixed;
|
|
1870
|
+
top: 0;
|
|
1871
|
+
left: 0;
|
|
1793
1872
|
}
|
|
1794
1873
|
|
|
1795
1874
|
.overtype-link-tooltip.visible {
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
/* CSS Anchor Positioning (modern browsers only) */
|
|
1800
|
-
@supports (position-anchor: --x) and (position-area: center) {
|
|
1801
|
-
.overtype-link-tooltip {
|
|
1802
|
-
/* Only anchor positioning specific properties */
|
|
1803
|
-
position-anchor: var(--target-anchor, --link-0);
|
|
1804
|
-
position-area: block-end center;
|
|
1805
|
-
margin-top: 8px !important;
|
|
1806
|
-
position-try: most-width block-end inline-end, flip-inline, block-start center;
|
|
1807
|
-
position-visibility: anchors-visible;
|
|
1808
|
-
}
|
|
1875
|
+
visibility: visible !important;
|
|
1876
|
+
pointer-events: auto !important;
|
|
1809
1877
|
}
|
|
1810
1878
|
|
|
1811
1879
|
${mobileStyles}
|
|
@@ -2887,6 +2955,16 @@ var Toolbar = class {
|
|
|
2887
2955
|
} catch (error) {
|
|
2888
2956
|
}
|
|
2889
2957
|
}
|
|
2958
|
+
show() {
|
|
2959
|
+
if (this.container) {
|
|
2960
|
+
this.container.classList.remove("overtype-toolbar-hidden");
|
|
2961
|
+
}
|
|
2962
|
+
}
|
|
2963
|
+
hide() {
|
|
2964
|
+
if (this.container) {
|
|
2965
|
+
this.container.classList.add("overtype-toolbar-hidden");
|
|
2966
|
+
}
|
|
2967
|
+
}
|
|
2890
2968
|
/**
|
|
2891
2969
|
* Destroy toolbar and cleanup
|
|
2892
2970
|
*/
|
|
@@ -2908,6 +2986,1203 @@ var Toolbar = class {
|
|
|
2908
2986
|
}
|
|
2909
2987
|
};
|
|
2910
2988
|
|
|
2989
|
+
// node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
|
|
2990
|
+
var min = Math.min;
|
|
2991
|
+
var max = Math.max;
|
|
2992
|
+
var round = Math.round;
|
|
2993
|
+
var createCoords = (v) => ({
|
|
2994
|
+
x: v,
|
|
2995
|
+
y: v
|
|
2996
|
+
});
|
|
2997
|
+
var oppositeSideMap = {
|
|
2998
|
+
left: "right",
|
|
2999
|
+
right: "left",
|
|
3000
|
+
bottom: "top",
|
|
3001
|
+
top: "bottom"
|
|
3002
|
+
};
|
|
3003
|
+
var oppositeAlignmentMap = {
|
|
3004
|
+
start: "end",
|
|
3005
|
+
end: "start"
|
|
3006
|
+
};
|
|
3007
|
+
function clamp(start, value, end) {
|
|
3008
|
+
return max(start, min(value, end));
|
|
3009
|
+
}
|
|
3010
|
+
function evaluate(value, param) {
|
|
3011
|
+
return typeof value === "function" ? value(param) : value;
|
|
3012
|
+
}
|
|
3013
|
+
function getSide(placement) {
|
|
3014
|
+
return placement.split("-")[0];
|
|
3015
|
+
}
|
|
3016
|
+
function getAlignment(placement) {
|
|
3017
|
+
return placement.split("-")[1];
|
|
3018
|
+
}
|
|
3019
|
+
function getOppositeAxis(axis) {
|
|
3020
|
+
return axis === "x" ? "y" : "x";
|
|
3021
|
+
}
|
|
3022
|
+
function getAxisLength(axis) {
|
|
3023
|
+
return axis === "y" ? "height" : "width";
|
|
3024
|
+
}
|
|
3025
|
+
var yAxisSides = /* @__PURE__ */ new Set(["top", "bottom"]);
|
|
3026
|
+
function getSideAxis(placement) {
|
|
3027
|
+
return yAxisSides.has(getSide(placement)) ? "y" : "x";
|
|
3028
|
+
}
|
|
3029
|
+
function getAlignmentAxis(placement) {
|
|
3030
|
+
return getOppositeAxis(getSideAxis(placement));
|
|
3031
|
+
}
|
|
3032
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
3033
|
+
if (rtl === void 0) {
|
|
3034
|
+
rtl = false;
|
|
3035
|
+
}
|
|
3036
|
+
const alignment = getAlignment(placement);
|
|
3037
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
3038
|
+
const length = getAxisLength(alignmentAxis);
|
|
3039
|
+
let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
|
|
3040
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
3041
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
3042
|
+
}
|
|
3043
|
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
3044
|
+
}
|
|
3045
|
+
function getExpandedPlacements(placement) {
|
|
3046
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
3047
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
3048
|
+
}
|
|
3049
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
3050
|
+
return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
|
|
3051
|
+
}
|
|
3052
|
+
var lrPlacement = ["left", "right"];
|
|
3053
|
+
var rlPlacement = ["right", "left"];
|
|
3054
|
+
var tbPlacement = ["top", "bottom"];
|
|
3055
|
+
var btPlacement = ["bottom", "top"];
|
|
3056
|
+
function getSideList(side, isStart, rtl) {
|
|
3057
|
+
switch (side) {
|
|
3058
|
+
case "top":
|
|
3059
|
+
case "bottom":
|
|
3060
|
+
if (rtl)
|
|
3061
|
+
return isStart ? rlPlacement : lrPlacement;
|
|
3062
|
+
return isStart ? lrPlacement : rlPlacement;
|
|
3063
|
+
case "left":
|
|
3064
|
+
case "right":
|
|
3065
|
+
return isStart ? tbPlacement : btPlacement;
|
|
3066
|
+
default:
|
|
3067
|
+
return [];
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
3071
|
+
const alignment = getAlignment(placement);
|
|
3072
|
+
let list = getSideList(getSide(placement), direction === "start", rtl);
|
|
3073
|
+
if (alignment) {
|
|
3074
|
+
list = list.map((side) => side + "-" + alignment);
|
|
3075
|
+
if (flipAlignment) {
|
|
3076
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
3077
|
+
}
|
|
3078
|
+
}
|
|
3079
|
+
return list;
|
|
3080
|
+
}
|
|
3081
|
+
function getOppositePlacement(placement) {
|
|
3082
|
+
return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
|
|
3083
|
+
}
|
|
3084
|
+
function expandPaddingObject(padding) {
|
|
3085
|
+
return {
|
|
3086
|
+
top: 0,
|
|
3087
|
+
right: 0,
|
|
3088
|
+
bottom: 0,
|
|
3089
|
+
left: 0,
|
|
3090
|
+
...padding
|
|
3091
|
+
};
|
|
3092
|
+
}
|
|
3093
|
+
function getPaddingObject(padding) {
|
|
3094
|
+
return typeof padding !== "number" ? expandPaddingObject(padding) : {
|
|
3095
|
+
top: padding,
|
|
3096
|
+
right: padding,
|
|
3097
|
+
bottom: padding,
|
|
3098
|
+
left: padding
|
|
3099
|
+
};
|
|
3100
|
+
}
|
|
3101
|
+
function rectToClientRect(rect) {
|
|
3102
|
+
const {
|
|
3103
|
+
x,
|
|
3104
|
+
y,
|
|
3105
|
+
width,
|
|
3106
|
+
height
|
|
3107
|
+
} = rect;
|
|
3108
|
+
return {
|
|
3109
|
+
width,
|
|
3110
|
+
height,
|
|
3111
|
+
top: y,
|
|
3112
|
+
left: x,
|
|
3113
|
+
right: x + width,
|
|
3114
|
+
bottom: y + height,
|
|
3115
|
+
x,
|
|
3116
|
+
y
|
|
3117
|
+
};
|
|
3118
|
+
}
|
|
3119
|
+
|
|
3120
|
+
// node_modules/@floating-ui/core/dist/floating-ui.core.mjs
|
|
3121
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
3122
|
+
let {
|
|
3123
|
+
reference,
|
|
3124
|
+
floating
|
|
3125
|
+
} = _ref;
|
|
3126
|
+
const sideAxis = getSideAxis(placement);
|
|
3127
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
3128
|
+
const alignLength = getAxisLength(alignmentAxis);
|
|
3129
|
+
const side = getSide(placement);
|
|
3130
|
+
const isVertical = sideAxis === "y";
|
|
3131
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
3132
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
3133
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
3134
|
+
let coords;
|
|
3135
|
+
switch (side) {
|
|
3136
|
+
case "top":
|
|
3137
|
+
coords = {
|
|
3138
|
+
x: commonX,
|
|
3139
|
+
y: reference.y - floating.height
|
|
3140
|
+
};
|
|
3141
|
+
break;
|
|
3142
|
+
case "bottom":
|
|
3143
|
+
coords = {
|
|
3144
|
+
x: commonX,
|
|
3145
|
+
y: reference.y + reference.height
|
|
3146
|
+
};
|
|
3147
|
+
break;
|
|
3148
|
+
case "right":
|
|
3149
|
+
coords = {
|
|
3150
|
+
x: reference.x + reference.width,
|
|
3151
|
+
y: commonY
|
|
3152
|
+
};
|
|
3153
|
+
break;
|
|
3154
|
+
case "left":
|
|
3155
|
+
coords = {
|
|
3156
|
+
x: reference.x - floating.width,
|
|
3157
|
+
y: commonY
|
|
3158
|
+
};
|
|
3159
|
+
break;
|
|
3160
|
+
default:
|
|
3161
|
+
coords = {
|
|
3162
|
+
x: reference.x,
|
|
3163
|
+
y: reference.y
|
|
3164
|
+
};
|
|
3165
|
+
}
|
|
3166
|
+
switch (getAlignment(placement)) {
|
|
3167
|
+
case "start":
|
|
3168
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
3169
|
+
break;
|
|
3170
|
+
case "end":
|
|
3171
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
3172
|
+
break;
|
|
3173
|
+
}
|
|
3174
|
+
return coords;
|
|
3175
|
+
}
|
|
3176
|
+
async function detectOverflow(state, options) {
|
|
3177
|
+
var _await$platform$isEle;
|
|
3178
|
+
if (options === void 0) {
|
|
3179
|
+
options = {};
|
|
3180
|
+
}
|
|
3181
|
+
const {
|
|
3182
|
+
x,
|
|
3183
|
+
y,
|
|
3184
|
+
platform: platform2,
|
|
3185
|
+
rects,
|
|
3186
|
+
elements,
|
|
3187
|
+
strategy
|
|
3188
|
+
} = state;
|
|
3189
|
+
const {
|
|
3190
|
+
boundary = "clippingAncestors",
|
|
3191
|
+
rootBoundary = "viewport",
|
|
3192
|
+
elementContext = "floating",
|
|
3193
|
+
altBoundary = false,
|
|
3194
|
+
padding = 0
|
|
3195
|
+
} = evaluate(options, state);
|
|
3196
|
+
const paddingObject = getPaddingObject(padding);
|
|
3197
|
+
const altContext = elementContext === "floating" ? "reference" : "floating";
|
|
3198
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
3199
|
+
const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
|
|
3200
|
+
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)),
|
|
3201
|
+
boundary,
|
|
3202
|
+
rootBoundary,
|
|
3203
|
+
strategy
|
|
3204
|
+
}));
|
|
3205
|
+
const rect = elementContext === "floating" ? {
|
|
3206
|
+
x,
|
|
3207
|
+
y,
|
|
3208
|
+
width: rects.floating.width,
|
|
3209
|
+
height: rects.floating.height
|
|
3210
|
+
} : rects.reference;
|
|
3211
|
+
const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
|
|
3212
|
+
const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
|
|
3213
|
+
x: 1,
|
|
3214
|
+
y: 1
|
|
3215
|
+
} : {
|
|
3216
|
+
x: 1,
|
|
3217
|
+
y: 1
|
|
3218
|
+
};
|
|
3219
|
+
const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
3220
|
+
elements,
|
|
3221
|
+
rect,
|
|
3222
|
+
offsetParent,
|
|
3223
|
+
strategy
|
|
3224
|
+
}) : rect);
|
|
3225
|
+
return {
|
|
3226
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
3227
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
3228
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
3229
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
3230
|
+
};
|
|
3231
|
+
}
|
|
3232
|
+
var computePosition = async (reference, floating, config) => {
|
|
3233
|
+
const {
|
|
3234
|
+
placement = "bottom",
|
|
3235
|
+
strategy = "absolute",
|
|
3236
|
+
middleware = [],
|
|
3237
|
+
platform: platform2
|
|
3238
|
+
} = config;
|
|
3239
|
+
const validMiddleware = middleware.filter(Boolean);
|
|
3240
|
+
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
|
|
3241
|
+
let rects = await platform2.getElementRects({
|
|
3242
|
+
reference,
|
|
3243
|
+
floating,
|
|
3244
|
+
strategy
|
|
3245
|
+
});
|
|
3246
|
+
let {
|
|
3247
|
+
x,
|
|
3248
|
+
y
|
|
3249
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
3250
|
+
let statefulPlacement = placement;
|
|
3251
|
+
let middlewareData = {};
|
|
3252
|
+
let resetCount = 0;
|
|
3253
|
+
for (let i = 0; i < validMiddleware.length; i++) {
|
|
3254
|
+
var _platform$detectOverf;
|
|
3255
|
+
const {
|
|
3256
|
+
name,
|
|
3257
|
+
fn
|
|
3258
|
+
} = validMiddleware[i];
|
|
3259
|
+
const {
|
|
3260
|
+
x: nextX,
|
|
3261
|
+
y: nextY,
|
|
3262
|
+
data,
|
|
3263
|
+
reset
|
|
3264
|
+
} = await fn({
|
|
3265
|
+
x,
|
|
3266
|
+
y,
|
|
3267
|
+
initialPlacement: placement,
|
|
3268
|
+
placement: statefulPlacement,
|
|
3269
|
+
strategy,
|
|
3270
|
+
middlewareData,
|
|
3271
|
+
rects,
|
|
3272
|
+
platform: {
|
|
3273
|
+
...platform2,
|
|
3274
|
+
detectOverflow: (_platform$detectOverf = platform2.detectOverflow) != null ? _platform$detectOverf : detectOverflow
|
|
3275
|
+
},
|
|
3276
|
+
elements: {
|
|
3277
|
+
reference,
|
|
3278
|
+
floating
|
|
3279
|
+
}
|
|
3280
|
+
});
|
|
3281
|
+
x = nextX != null ? nextX : x;
|
|
3282
|
+
y = nextY != null ? nextY : y;
|
|
3283
|
+
middlewareData = {
|
|
3284
|
+
...middlewareData,
|
|
3285
|
+
[name]: {
|
|
3286
|
+
...middlewareData[name],
|
|
3287
|
+
...data
|
|
3288
|
+
}
|
|
3289
|
+
};
|
|
3290
|
+
if (reset && resetCount <= 50) {
|
|
3291
|
+
resetCount++;
|
|
3292
|
+
if (typeof reset === "object") {
|
|
3293
|
+
if (reset.placement) {
|
|
3294
|
+
statefulPlacement = reset.placement;
|
|
3295
|
+
}
|
|
3296
|
+
if (reset.rects) {
|
|
3297
|
+
rects = reset.rects === true ? await platform2.getElementRects({
|
|
3298
|
+
reference,
|
|
3299
|
+
floating,
|
|
3300
|
+
strategy
|
|
3301
|
+
}) : reset.rects;
|
|
3302
|
+
}
|
|
3303
|
+
({
|
|
3304
|
+
x,
|
|
3305
|
+
y
|
|
3306
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
3307
|
+
}
|
|
3308
|
+
i = -1;
|
|
3309
|
+
}
|
|
3310
|
+
}
|
|
3311
|
+
return {
|
|
3312
|
+
x,
|
|
3313
|
+
y,
|
|
3314
|
+
placement: statefulPlacement,
|
|
3315
|
+
strategy,
|
|
3316
|
+
middlewareData
|
|
3317
|
+
};
|
|
3318
|
+
};
|
|
3319
|
+
var flip = function(options) {
|
|
3320
|
+
if (options === void 0) {
|
|
3321
|
+
options = {};
|
|
3322
|
+
}
|
|
3323
|
+
return {
|
|
3324
|
+
name: "flip",
|
|
3325
|
+
options,
|
|
3326
|
+
async fn(state) {
|
|
3327
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
3328
|
+
const {
|
|
3329
|
+
placement,
|
|
3330
|
+
middlewareData,
|
|
3331
|
+
rects,
|
|
3332
|
+
initialPlacement,
|
|
3333
|
+
platform: platform2,
|
|
3334
|
+
elements
|
|
3335
|
+
} = state;
|
|
3336
|
+
const {
|
|
3337
|
+
mainAxis: checkMainAxis = true,
|
|
3338
|
+
crossAxis: checkCrossAxis = true,
|
|
3339
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
3340
|
+
fallbackStrategy = "bestFit",
|
|
3341
|
+
fallbackAxisSideDirection = "none",
|
|
3342
|
+
flipAlignment = true,
|
|
3343
|
+
...detectOverflowOptions
|
|
3344
|
+
} = evaluate(options, state);
|
|
3345
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
3346
|
+
return {};
|
|
3347
|
+
}
|
|
3348
|
+
const side = getSide(placement);
|
|
3349
|
+
const initialSideAxis = getSideAxis(initialPlacement);
|
|
3350
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
3351
|
+
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
3352
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
3353
|
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
|
|
3354
|
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
|
3355
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
3356
|
+
}
|
|
3357
|
+
const placements2 = [initialPlacement, ...fallbackPlacements];
|
|
3358
|
+
const overflow = await platform2.detectOverflow(state, detectOverflowOptions);
|
|
3359
|
+
const overflows = [];
|
|
3360
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
3361
|
+
if (checkMainAxis) {
|
|
3362
|
+
overflows.push(overflow[side]);
|
|
3363
|
+
}
|
|
3364
|
+
if (checkCrossAxis) {
|
|
3365
|
+
const sides2 = getAlignmentSides(placement, rects, rtl);
|
|
3366
|
+
overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
|
|
3367
|
+
}
|
|
3368
|
+
overflowsData = [...overflowsData, {
|
|
3369
|
+
placement,
|
|
3370
|
+
overflows
|
|
3371
|
+
}];
|
|
3372
|
+
if (!overflows.every((side2) => side2 <= 0)) {
|
|
3373
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
3374
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
3375
|
+
const nextPlacement = placements2[nextIndex];
|
|
3376
|
+
if (nextPlacement) {
|
|
3377
|
+
const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
|
|
3378
|
+
if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
|
|
3379
|
+
// overflows the main axis.
|
|
3380
|
+
overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
|
|
3381
|
+
return {
|
|
3382
|
+
data: {
|
|
3383
|
+
index: nextIndex,
|
|
3384
|
+
overflows: overflowsData
|
|
3385
|
+
},
|
|
3386
|
+
reset: {
|
|
3387
|
+
placement: nextPlacement
|
|
3388
|
+
}
|
|
3389
|
+
};
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
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;
|
|
3393
|
+
if (!resetPlacement) {
|
|
3394
|
+
switch (fallbackStrategy) {
|
|
3395
|
+
case "bestFit": {
|
|
3396
|
+
var _overflowsData$filter2;
|
|
3397
|
+
const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
|
|
3398
|
+
if (hasFallbackAxisSideDirection) {
|
|
3399
|
+
const currentSideAxis = getSideAxis(d.placement);
|
|
3400
|
+
return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
|
|
3401
|
+
// reading directions favoring greater width.
|
|
3402
|
+
currentSideAxis === "y";
|
|
3403
|
+
}
|
|
3404
|
+
return true;
|
|
3405
|
+
}).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];
|
|
3406
|
+
if (placement2) {
|
|
3407
|
+
resetPlacement = placement2;
|
|
3408
|
+
}
|
|
3409
|
+
break;
|
|
3410
|
+
}
|
|
3411
|
+
case "initialPlacement":
|
|
3412
|
+
resetPlacement = initialPlacement;
|
|
3413
|
+
break;
|
|
3414
|
+
}
|
|
3415
|
+
}
|
|
3416
|
+
if (placement !== resetPlacement) {
|
|
3417
|
+
return {
|
|
3418
|
+
reset: {
|
|
3419
|
+
placement: resetPlacement
|
|
3420
|
+
}
|
|
3421
|
+
};
|
|
3422
|
+
}
|
|
3423
|
+
}
|
|
3424
|
+
return {};
|
|
3425
|
+
}
|
|
3426
|
+
};
|
|
3427
|
+
};
|
|
3428
|
+
var originSides = /* @__PURE__ */ new Set(["left", "top"]);
|
|
3429
|
+
async function convertValueToCoords(state, options) {
|
|
3430
|
+
const {
|
|
3431
|
+
placement,
|
|
3432
|
+
platform: platform2,
|
|
3433
|
+
elements
|
|
3434
|
+
} = state;
|
|
3435
|
+
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
3436
|
+
const side = getSide(placement);
|
|
3437
|
+
const alignment = getAlignment(placement);
|
|
3438
|
+
const isVertical = getSideAxis(placement) === "y";
|
|
3439
|
+
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
|
3440
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
3441
|
+
const rawValue = evaluate(options, state);
|
|
3442
|
+
let {
|
|
3443
|
+
mainAxis,
|
|
3444
|
+
crossAxis,
|
|
3445
|
+
alignmentAxis
|
|
3446
|
+
} = typeof rawValue === "number" ? {
|
|
3447
|
+
mainAxis: rawValue,
|
|
3448
|
+
crossAxis: 0,
|
|
3449
|
+
alignmentAxis: null
|
|
3450
|
+
} : {
|
|
3451
|
+
mainAxis: rawValue.mainAxis || 0,
|
|
3452
|
+
crossAxis: rawValue.crossAxis || 0,
|
|
3453
|
+
alignmentAxis: rawValue.alignmentAxis
|
|
3454
|
+
};
|
|
3455
|
+
if (alignment && typeof alignmentAxis === "number") {
|
|
3456
|
+
crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
|
|
3457
|
+
}
|
|
3458
|
+
return isVertical ? {
|
|
3459
|
+
x: crossAxis * crossAxisMulti,
|
|
3460
|
+
y: mainAxis * mainAxisMulti
|
|
3461
|
+
} : {
|
|
3462
|
+
x: mainAxis * mainAxisMulti,
|
|
3463
|
+
y: crossAxis * crossAxisMulti
|
|
3464
|
+
};
|
|
3465
|
+
}
|
|
3466
|
+
var offset = function(options) {
|
|
3467
|
+
if (options === void 0) {
|
|
3468
|
+
options = 0;
|
|
3469
|
+
}
|
|
3470
|
+
return {
|
|
3471
|
+
name: "offset",
|
|
3472
|
+
options,
|
|
3473
|
+
async fn(state) {
|
|
3474
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
|
3475
|
+
const {
|
|
3476
|
+
x,
|
|
3477
|
+
y,
|
|
3478
|
+
placement,
|
|
3479
|
+
middlewareData
|
|
3480
|
+
} = state;
|
|
3481
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
3482
|
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
3483
|
+
return {};
|
|
3484
|
+
}
|
|
3485
|
+
return {
|
|
3486
|
+
x: x + diffCoords.x,
|
|
3487
|
+
y: y + diffCoords.y,
|
|
3488
|
+
data: {
|
|
3489
|
+
...diffCoords,
|
|
3490
|
+
placement
|
|
3491
|
+
}
|
|
3492
|
+
};
|
|
3493
|
+
}
|
|
3494
|
+
};
|
|
3495
|
+
};
|
|
3496
|
+
var shift = function(options) {
|
|
3497
|
+
if (options === void 0) {
|
|
3498
|
+
options = {};
|
|
3499
|
+
}
|
|
3500
|
+
return {
|
|
3501
|
+
name: "shift",
|
|
3502
|
+
options,
|
|
3503
|
+
async fn(state) {
|
|
3504
|
+
const {
|
|
3505
|
+
x,
|
|
3506
|
+
y,
|
|
3507
|
+
placement,
|
|
3508
|
+
platform: platform2
|
|
3509
|
+
} = state;
|
|
3510
|
+
const {
|
|
3511
|
+
mainAxis: checkMainAxis = true,
|
|
3512
|
+
crossAxis: checkCrossAxis = false,
|
|
3513
|
+
limiter = {
|
|
3514
|
+
fn: (_ref) => {
|
|
3515
|
+
let {
|
|
3516
|
+
x: x2,
|
|
3517
|
+
y: y2
|
|
3518
|
+
} = _ref;
|
|
3519
|
+
return {
|
|
3520
|
+
x: x2,
|
|
3521
|
+
y: y2
|
|
3522
|
+
};
|
|
3523
|
+
}
|
|
3524
|
+
},
|
|
3525
|
+
...detectOverflowOptions
|
|
3526
|
+
} = evaluate(options, state);
|
|
3527
|
+
const coords = {
|
|
3528
|
+
x,
|
|
3529
|
+
y
|
|
3530
|
+
};
|
|
3531
|
+
const overflow = await platform2.detectOverflow(state, detectOverflowOptions);
|
|
3532
|
+
const crossAxis = getSideAxis(getSide(placement));
|
|
3533
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
3534
|
+
let mainAxisCoord = coords[mainAxis];
|
|
3535
|
+
let crossAxisCoord = coords[crossAxis];
|
|
3536
|
+
if (checkMainAxis) {
|
|
3537
|
+
const minSide = mainAxis === "y" ? "top" : "left";
|
|
3538
|
+
const maxSide = mainAxis === "y" ? "bottom" : "right";
|
|
3539
|
+
const min2 = mainAxisCoord + overflow[minSide];
|
|
3540
|
+
const max2 = mainAxisCoord - overflow[maxSide];
|
|
3541
|
+
mainAxisCoord = clamp(min2, mainAxisCoord, max2);
|
|
3542
|
+
}
|
|
3543
|
+
if (checkCrossAxis) {
|
|
3544
|
+
const minSide = crossAxis === "y" ? "top" : "left";
|
|
3545
|
+
const maxSide = crossAxis === "y" ? "bottom" : "right";
|
|
3546
|
+
const min2 = crossAxisCoord + overflow[minSide];
|
|
3547
|
+
const max2 = crossAxisCoord - overflow[maxSide];
|
|
3548
|
+
crossAxisCoord = clamp(min2, crossAxisCoord, max2);
|
|
3549
|
+
}
|
|
3550
|
+
const limitedCoords = limiter.fn({
|
|
3551
|
+
...state,
|
|
3552
|
+
[mainAxis]: mainAxisCoord,
|
|
3553
|
+
[crossAxis]: crossAxisCoord
|
|
3554
|
+
});
|
|
3555
|
+
return {
|
|
3556
|
+
...limitedCoords,
|
|
3557
|
+
data: {
|
|
3558
|
+
x: limitedCoords.x - x,
|
|
3559
|
+
y: limitedCoords.y - y,
|
|
3560
|
+
enabled: {
|
|
3561
|
+
[mainAxis]: checkMainAxis,
|
|
3562
|
+
[crossAxis]: checkCrossAxis
|
|
3563
|
+
}
|
|
3564
|
+
}
|
|
3565
|
+
};
|
|
3566
|
+
}
|
|
3567
|
+
};
|
|
3568
|
+
};
|
|
3569
|
+
|
|
3570
|
+
// node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
|
|
3571
|
+
function hasWindow() {
|
|
3572
|
+
return typeof window !== "undefined";
|
|
3573
|
+
}
|
|
3574
|
+
function getNodeName(node) {
|
|
3575
|
+
if (isNode(node)) {
|
|
3576
|
+
return (node.nodeName || "").toLowerCase();
|
|
3577
|
+
}
|
|
3578
|
+
return "#document";
|
|
3579
|
+
}
|
|
3580
|
+
function getWindow(node) {
|
|
3581
|
+
var _node$ownerDocument;
|
|
3582
|
+
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
3583
|
+
}
|
|
3584
|
+
function getDocumentElement(node) {
|
|
3585
|
+
var _ref;
|
|
3586
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
3587
|
+
}
|
|
3588
|
+
function isNode(value) {
|
|
3589
|
+
if (!hasWindow()) {
|
|
3590
|
+
return false;
|
|
3591
|
+
}
|
|
3592
|
+
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
3593
|
+
}
|
|
3594
|
+
function isElement(value) {
|
|
3595
|
+
if (!hasWindow()) {
|
|
3596
|
+
return false;
|
|
3597
|
+
}
|
|
3598
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
3599
|
+
}
|
|
3600
|
+
function isHTMLElement(value) {
|
|
3601
|
+
if (!hasWindow()) {
|
|
3602
|
+
return false;
|
|
3603
|
+
}
|
|
3604
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
3605
|
+
}
|
|
3606
|
+
function isShadowRoot(value) {
|
|
3607
|
+
if (!hasWindow() || typeof ShadowRoot === "undefined") {
|
|
3608
|
+
return false;
|
|
3609
|
+
}
|
|
3610
|
+
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
3611
|
+
}
|
|
3612
|
+
var invalidOverflowDisplayValues = /* @__PURE__ */ new Set(["inline", "contents"]);
|
|
3613
|
+
function isOverflowElement(element) {
|
|
3614
|
+
const {
|
|
3615
|
+
overflow,
|
|
3616
|
+
overflowX,
|
|
3617
|
+
overflowY,
|
|
3618
|
+
display
|
|
3619
|
+
} = getComputedStyle2(element);
|
|
3620
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
|
3621
|
+
}
|
|
3622
|
+
var tableElements = /* @__PURE__ */ new Set(["table", "td", "th"]);
|
|
3623
|
+
function isTableElement(element) {
|
|
3624
|
+
return tableElements.has(getNodeName(element));
|
|
3625
|
+
}
|
|
3626
|
+
var topLayerSelectors = [":popover-open", ":modal"];
|
|
3627
|
+
function isTopLayer(element) {
|
|
3628
|
+
return topLayerSelectors.some((selector) => {
|
|
3629
|
+
try {
|
|
3630
|
+
return element.matches(selector);
|
|
3631
|
+
} catch (_e) {
|
|
3632
|
+
return false;
|
|
3633
|
+
}
|
|
3634
|
+
});
|
|
3635
|
+
}
|
|
3636
|
+
var transformProperties = ["transform", "translate", "scale", "rotate", "perspective"];
|
|
3637
|
+
var willChangeValues = ["transform", "translate", "scale", "rotate", "perspective", "filter"];
|
|
3638
|
+
var containValues = ["paint", "layout", "strict", "content"];
|
|
3639
|
+
function isContainingBlock(elementOrCss) {
|
|
3640
|
+
const webkit = isWebKit();
|
|
3641
|
+
const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
|
|
3642
|
+
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));
|
|
3643
|
+
}
|
|
3644
|
+
function getContainingBlock(element) {
|
|
3645
|
+
let currentNode = getParentNode(element);
|
|
3646
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
3647
|
+
if (isContainingBlock(currentNode)) {
|
|
3648
|
+
return currentNode;
|
|
3649
|
+
} else if (isTopLayer(currentNode)) {
|
|
3650
|
+
return null;
|
|
3651
|
+
}
|
|
3652
|
+
currentNode = getParentNode(currentNode);
|
|
3653
|
+
}
|
|
3654
|
+
return null;
|
|
3655
|
+
}
|
|
3656
|
+
function isWebKit() {
|
|
3657
|
+
if (typeof CSS === "undefined" || !CSS.supports)
|
|
3658
|
+
return false;
|
|
3659
|
+
return CSS.supports("-webkit-backdrop-filter", "none");
|
|
3660
|
+
}
|
|
3661
|
+
var lastTraversableNodeNames = /* @__PURE__ */ new Set(["html", "body", "#document"]);
|
|
3662
|
+
function isLastTraversableNode(node) {
|
|
3663
|
+
return lastTraversableNodeNames.has(getNodeName(node));
|
|
3664
|
+
}
|
|
3665
|
+
function getComputedStyle2(element) {
|
|
3666
|
+
return getWindow(element).getComputedStyle(element);
|
|
3667
|
+
}
|
|
3668
|
+
function getNodeScroll(element) {
|
|
3669
|
+
if (isElement(element)) {
|
|
3670
|
+
return {
|
|
3671
|
+
scrollLeft: element.scrollLeft,
|
|
3672
|
+
scrollTop: element.scrollTop
|
|
3673
|
+
};
|
|
3674
|
+
}
|
|
3675
|
+
return {
|
|
3676
|
+
scrollLeft: element.scrollX,
|
|
3677
|
+
scrollTop: element.scrollY
|
|
3678
|
+
};
|
|
3679
|
+
}
|
|
3680
|
+
function getParentNode(node) {
|
|
3681
|
+
if (getNodeName(node) === "html") {
|
|
3682
|
+
return node;
|
|
3683
|
+
}
|
|
3684
|
+
const result = (
|
|
3685
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
3686
|
+
node.assignedSlot || // DOM Element detected.
|
|
3687
|
+
node.parentNode || // ShadowRoot detected.
|
|
3688
|
+
isShadowRoot(node) && node.host || // Fallback.
|
|
3689
|
+
getDocumentElement(node)
|
|
3690
|
+
);
|
|
3691
|
+
return isShadowRoot(result) ? result.host : result;
|
|
3692
|
+
}
|
|
3693
|
+
function getNearestOverflowAncestor(node) {
|
|
3694
|
+
const parentNode = getParentNode(node);
|
|
3695
|
+
if (isLastTraversableNode(parentNode)) {
|
|
3696
|
+
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
3697
|
+
}
|
|
3698
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
3699
|
+
return parentNode;
|
|
3700
|
+
}
|
|
3701
|
+
return getNearestOverflowAncestor(parentNode);
|
|
3702
|
+
}
|
|
3703
|
+
function getOverflowAncestors(node, list, traverseIframes) {
|
|
3704
|
+
var _node$ownerDocument2;
|
|
3705
|
+
if (list === void 0) {
|
|
3706
|
+
list = [];
|
|
3707
|
+
}
|
|
3708
|
+
if (traverseIframes === void 0) {
|
|
3709
|
+
traverseIframes = true;
|
|
3710
|
+
}
|
|
3711
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
3712
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
3713
|
+
const win = getWindow(scrollableAncestor);
|
|
3714
|
+
if (isBody) {
|
|
3715
|
+
const frameElement = getFrameElement(win);
|
|
3716
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
3717
|
+
}
|
|
3718
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
3719
|
+
}
|
|
3720
|
+
function getFrameElement(win) {
|
|
3721
|
+
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
3722
|
+
}
|
|
3723
|
+
|
|
3724
|
+
// node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
|
|
3725
|
+
function getCssDimensions(element) {
|
|
3726
|
+
const css = getComputedStyle2(element);
|
|
3727
|
+
let width = parseFloat(css.width) || 0;
|
|
3728
|
+
let height = parseFloat(css.height) || 0;
|
|
3729
|
+
const hasOffset = isHTMLElement(element);
|
|
3730
|
+
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
3731
|
+
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
3732
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
3733
|
+
if (shouldFallback) {
|
|
3734
|
+
width = offsetWidth;
|
|
3735
|
+
height = offsetHeight;
|
|
3736
|
+
}
|
|
3737
|
+
return {
|
|
3738
|
+
width,
|
|
3739
|
+
height,
|
|
3740
|
+
$: shouldFallback
|
|
3741
|
+
};
|
|
3742
|
+
}
|
|
3743
|
+
function unwrapElement(element) {
|
|
3744
|
+
return !isElement(element) ? element.contextElement : element;
|
|
3745
|
+
}
|
|
3746
|
+
function getScale(element) {
|
|
3747
|
+
const domElement = unwrapElement(element);
|
|
3748
|
+
if (!isHTMLElement(domElement)) {
|
|
3749
|
+
return createCoords(1);
|
|
3750
|
+
}
|
|
3751
|
+
const rect = domElement.getBoundingClientRect();
|
|
3752
|
+
const {
|
|
3753
|
+
width,
|
|
3754
|
+
height,
|
|
3755
|
+
$
|
|
3756
|
+
} = getCssDimensions(domElement);
|
|
3757
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
3758
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
3759
|
+
if (!x || !Number.isFinite(x)) {
|
|
3760
|
+
x = 1;
|
|
3761
|
+
}
|
|
3762
|
+
if (!y || !Number.isFinite(y)) {
|
|
3763
|
+
y = 1;
|
|
3764
|
+
}
|
|
3765
|
+
return {
|
|
3766
|
+
x,
|
|
3767
|
+
y
|
|
3768
|
+
};
|
|
3769
|
+
}
|
|
3770
|
+
var noOffsets = /* @__PURE__ */ createCoords(0);
|
|
3771
|
+
function getVisualOffsets(element) {
|
|
3772
|
+
const win = getWindow(element);
|
|
3773
|
+
if (!isWebKit() || !win.visualViewport) {
|
|
3774
|
+
return noOffsets;
|
|
3775
|
+
}
|
|
3776
|
+
return {
|
|
3777
|
+
x: win.visualViewport.offsetLeft,
|
|
3778
|
+
y: win.visualViewport.offsetTop
|
|
3779
|
+
};
|
|
3780
|
+
}
|
|
3781
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
3782
|
+
if (isFixed === void 0) {
|
|
3783
|
+
isFixed = false;
|
|
3784
|
+
}
|
|
3785
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
3786
|
+
return false;
|
|
3787
|
+
}
|
|
3788
|
+
return isFixed;
|
|
3789
|
+
}
|
|
3790
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
3791
|
+
if (includeScale === void 0) {
|
|
3792
|
+
includeScale = false;
|
|
3793
|
+
}
|
|
3794
|
+
if (isFixedStrategy === void 0) {
|
|
3795
|
+
isFixedStrategy = false;
|
|
3796
|
+
}
|
|
3797
|
+
const clientRect = element.getBoundingClientRect();
|
|
3798
|
+
const domElement = unwrapElement(element);
|
|
3799
|
+
let scale = createCoords(1);
|
|
3800
|
+
if (includeScale) {
|
|
3801
|
+
if (offsetParent) {
|
|
3802
|
+
if (isElement(offsetParent)) {
|
|
3803
|
+
scale = getScale(offsetParent);
|
|
3804
|
+
}
|
|
3805
|
+
} else {
|
|
3806
|
+
scale = getScale(element);
|
|
3807
|
+
}
|
|
3808
|
+
}
|
|
3809
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
3810
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
3811
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
3812
|
+
let width = clientRect.width / scale.x;
|
|
3813
|
+
let height = clientRect.height / scale.y;
|
|
3814
|
+
if (domElement) {
|
|
3815
|
+
const win = getWindow(domElement);
|
|
3816
|
+
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
3817
|
+
let currentWin = win;
|
|
3818
|
+
let currentIFrame = getFrameElement(currentWin);
|
|
3819
|
+
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
3820
|
+
const iframeScale = getScale(currentIFrame);
|
|
3821
|
+
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
3822
|
+
const css = getComputedStyle2(currentIFrame);
|
|
3823
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
3824
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
3825
|
+
x *= iframeScale.x;
|
|
3826
|
+
y *= iframeScale.y;
|
|
3827
|
+
width *= iframeScale.x;
|
|
3828
|
+
height *= iframeScale.y;
|
|
3829
|
+
x += left;
|
|
3830
|
+
y += top;
|
|
3831
|
+
currentWin = getWindow(currentIFrame);
|
|
3832
|
+
currentIFrame = getFrameElement(currentWin);
|
|
3833
|
+
}
|
|
3834
|
+
}
|
|
3835
|
+
return rectToClientRect({
|
|
3836
|
+
width,
|
|
3837
|
+
height,
|
|
3838
|
+
x,
|
|
3839
|
+
y
|
|
3840
|
+
});
|
|
3841
|
+
}
|
|
3842
|
+
function getWindowScrollBarX(element, rect) {
|
|
3843
|
+
const leftScroll = getNodeScroll(element).scrollLeft;
|
|
3844
|
+
if (!rect) {
|
|
3845
|
+
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
|
3846
|
+
}
|
|
3847
|
+
return rect.left + leftScroll;
|
|
3848
|
+
}
|
|
3849
|
+
function getHTMLOffset(documentElement, scroll) {
|
|
3850
|
+
const htmlRect = documentElement.getBoundingClientRect();
|
|
3851
|
+
const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
|
|
3852
|
+
const y = htmlRect.top + scroll.scrollTop;
|
|
3853
|
+
return {
|
|
3854
|
+
x,
|
|
3855
|
+
y
|
|
3856
|
+
};
|
|
3857
|
+
}
|
|
3858
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
3859
|
+
let {
|
|
3860
|
+
elements,
|
|
3861
|
+
rect,
|
|
3862
|
+
offsetParent,
|
|
3863
|
+
strategy
|
|
3864
|
+
} = _ref;
|
|
3865
|
+
const isFixed = strategy === "fixed";
|
|
3866
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
3867
|
+
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
3868
|
+
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
3869
|
+
return rect;
|
|
3870
|
+
}
|
|
3871
|
+
let scroll = {
|
|
3872
|
+
scrollLeft: 0,
|
|
3873
|
+
scrollTop: 0
|
|
3874
|
+
};
|
|
3875
|
+
let scale = createCoords(1);
|
|
3876
|
+
const offsets = createCoords(0);
|
|
3877
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
3878
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
3879
|
+
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
3880
|
+
scroll = getNodeScroll(offsetParent);
|
|
3881
|
+
}
|
|
3882
|
+
if (isHTMLElement(offsetParent)) {
|
|
3883
|
+
const offsetRect = getBoundingClientRect(offsetParent);
|
|
3884
|
+
scale = getScale(offsetParent);
|
|
3885
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
3886
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
3887
|
+
}
|
|
3888
|
+
}
|
|
3889
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
3890
|
+
return {
|
|
3891
|
+
width: rect.width * scale.x,
|
|
3892
|
+
height: rect.height * scale.y,
|
|
3893
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
|
3894
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
|
3895
|
+
};
|
|
3896
|
+
}
|
|
3897
|
+
function getClientRects(element) {
|
|
3898
|
+
return Array.from(element.getClientRects());
|
|
3899
|
+
}
|
|
3900
|
+
function getDocumentRect(element) {
|
|
3901
|
+
const html = getDocumentElement(element);
|
|
3902
|
+
const scroll = getNodeScroll(element);
|
|
3903
|
+
const body = element.ownerDocument.body;
|
|
3904
|
+
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
3905
|
+
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
3906
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
3907
|
+
const y = -scroll.scrollTop;
|
|
3908
|
+
if (getComputedStyle2(body).direction === "rtl") {
|
|
3909
|
+
x += max(html.clientWidth, body.clientWidth) - width;
|
|
3910
|
+
}
|
|
3911
|
+
return {
|
|
3912
|
+
width,
|
|
3913
|
+
height,
|
|
3914
|
+
x,
|
|
3915
|
+
y
|
|
3916
|
+
};
|
|
3917
|
+
}
|
|
3918
|
+
var SCROLLBAR_MAX = 25;
|
|
3919
|
+
function getViewportRect(element, strategy) {
|
|
3920
|
+
const win = getWindow(element);
|
|
3921
|
+
const html = getDocumentElement(element);
|
|
3922
|
+
const visualViewport = win.visualViewport;
|
|
3923
|
+
let width = html.clientWidth;
|
|
3924
|
+
let height = html.clientHeight;
|
|
3925
|
+
let x = 0;
|
|
3926
|
+
let y = 0;
|
|
3927
|
+
if (visualViewport) {
|
|
3928
|
+
width = visualViewport.width;
|
|
3929
|
+
height = visualViewport.height;
|
|
3930
|
+
const visualViewportBased = isWebKit();
|
|
3931
|
+
if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
|
|
3932
|
+
x = visualViewport.offsetLeft;
|
|
3933
|
+
y = visualViewport.offsetTop;
|
|
3934
|
+
}
|
|
3935
|
+
}
|
|
3936
|
+
const windowScrollbarX = getWindowScrollBarX(html);
|
|
3937
|
+
if (windowScrollbarX <= 0) {
|
|
3938
|
+
const doc = html.ownerDocument;
|
|
3939
|
+
const body = doc.body;
|
|
3940
|
+
const bodyStyles = getComputedStyle(body);
|
|
3941
|
+
const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
|
|
3942
|
+
const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
|
|
3943
|
+
if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
|
|
3944
|
+
width -= clippingStableScrollbarWidth;
|
|
3945
|
+
}
|
|
3946
|
+
} else if (windowScrollbarX <= SCROLLBAR_MAX) {
|
|
3947
|
+
width += windowScrollbarX;
|
|
3948
|
+
}
|
|
3949
|
+
return {
|
|
3950
|
+
width,
|
|
3951
|
+
height,
|
|
3952
|
+
x,
|
|
3953
|
+
y
|
|
3954
|
+
};
|
|
3955
|
+
}
|
|
3956
|
+
var absoluteOrFixed = /* @__PURE__ */ new Set(["absolute", "fixed"]);
|
|
3957
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
3958
|
+
const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
|
|
3959
|
+
const top = clientRect.top + element.clientTop;
|
|
3960
|
+
const left = clientRect.left + element.clientLeft;
|
|
3961
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
3962
|
+
const width = element.clientWidth * scale.x;
|
|
3963
|
+
const height = element.clientHeight * scale.y;
|
|
3964
|
+
const x = left * scale.x;
|
|
3965
|
+
const y = top * scale.y;
|
|
3966
|
+
return {
|
|
3967
|
+
width,
|
|
3968
|
+
height,
|
|
3969
|
+
x,
|
|
3970
|
+
y
|
|
3971
|
+
};
|
|
3972
|
+
}
|
|
3973
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
3974
|
+
let rect;
|
|
3975
|
+
if (clippingAncestor === "viewport") {
|
|
3976
|
+
rect = getViewportRect(element, strategy);
|
|
3977
|
+
} else if (clippingAncestor === "document") {
|
|
3978
|
+
rect = getDocumentRect(getDocumentElement(element));
|
|
3979
|
+
} else if (isElement(clippingAncestor)) {
|
|
3980
|
+
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
3981
|
+
} else {
|
|
3982
|
+
const visualOffsets = getVisualOffsets(element);
|
|
3983
|
+
rect = {
|
|
3984
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
3985
|
+
y: clippingAncestor.y - visualOffsets.y,
|
|
3986
|
+
width: clippingAncestor.width,
|
|
3987
|
+
height: clippingAncestor.height
|
|
3988
|
+
};
|
|
3989
|
+
}
|
|
3990
|
+
return rectToClientRect(rect);
|
|
3991
|
+
}
|
|
3992
|
+
function hasFixedPositionAncestor(element, stopNode) {
|
|
3993
|
+
const parentNode = getParentNode(element);
|
|
3994
|
+
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
3995
|
+
return false;
|
|
3996
|
+
}
|
|
3997
|
+
return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
|
|
3998
|
+
}
|
|
3999
|
+
function getClippingElementAncestors(element, cache) {
|
|
4000
|
+
const cachedResult = cache.get(element);
|
|
4001
|
+
if (cachedResult) {
|
|
4002
|
+
return cachedResult;
|
|
4003
|
+
}
|
|
4004
|
+
let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
|
|
4005
|
+
let currentContainingBlockComputedStyle = null;
|
|
4006
|
+
const elementIsFixed = getComputedStyle2(element).position === "fixed";
|
|
4007
|
+
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
4008
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
4009
|
+
const computedStyle = getComputedStyle2(currentNode);
|
|
4010
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
4011
|
+
if (!currentNodeIsContaining && computedStyle.position === "fixed") {
|
|
4012
|
+
currentContainingBlockComputedStyle = null;
|
|
4013
|
+
}
|
|
4014
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
4015
|
+
if (shouldDropCurrentNode) {
|
|
4016
|
+
result = result.filter((ancestor) => ancestor !== currentNode);
|
|
4017
|
+
} else {
|
|
4018
|
+
currentContainingBlockComputedStyle = computedStyle;
|
|
4019
|
+
}
|
|
4020
|
+
currentNode = getParentNode(currentNode);
|
|
4021
|
+
}
|
|
4022
|
+
cache.set(element, result);
|
|
4023
|
+
return result;
|
|
4024
|
+
}
|
|
4025
|
+
function getClippingRect(_ref) {
|
|
4026
|
+
let {
|
|
4027
|
+
element,
|
|
4028
|
+
boundary,
|
|
4029
|
+
rootBoundary,
|
|
4030
|
+
strategy
|
|
4031
|
+
} = _ref;
|
|
4032
|
+
const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
4033
|
+
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
4034
|
+
const firstClippingAncestor = clippingAncestors[0];
|
|
4035
|
+
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
4036
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
4037
|
+
accRect.top = max(rect.top, accRect.top);
|
|
4038
|
+
accRect.right = min(rect.right, accRect.right);
|
|
4039
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
4040
|
+
accRect.left = max(rect.left, accRect.left);
|
|
4041
|
+
return accRect;
|
|
4042
|
+
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
4043
|
+
return {
|
|
4044
|
+
width: clippingRect.right - clippingRect.left,
|
|
4045
|
+
height: clippingRect.bottom - clippingRect.top,
|
|
4046
|
+
x: clippingRect.left,
|
|
4047
|
+
y: clippingRect.top
|
|
4048
|
+
};
|
|
4049
|
+
}
|
|
4050
|
+
function getDimensions(element) {
|
|
4051
|
+
const {
|
|
4052
|
+
width,
|
|
4053
|
+
height
|
|
4054
|
+
} = getCssDimensions(element);
|
|
4055
|
+
return {
|
|
4056
|
+
width,
|
|
4057
|
+
height
|
|
4058
|
+
};
|
|
4059
|
+
}
|
|
4060
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
4061
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
4062
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
4063
|
+
const isFixed = strategy === "fixed";
|
|
4064
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
4065
|
+
let scroll = {
|
|
4066
|
+
scrollLeft: 0,
|
|
4067
|
+
scrollTop: 0
|
|
4068
|
+
};
|
|
4069
|
+
const offsets = createCoords(0);
|
|
4070
|
+
function setLeftRTLScrollbarOffset() {
|
|
4071
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
4072
|
+
}
|
|
4073
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
4074
|
+
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
4075
|
+
scroll = getNodeScroll(offsetParent);
|
|
4076
|
+
}
|
|
4077
|
+
if (isOffsetParentAnElement) {
|
|
4078
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
4079
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
4080
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
4081
|
+
} else if (documentElement) {
|
|
4082
|
+
setLeftRTLScrollbarOffset();
|
|
4083
|
+
}
|
|
4084
|
+
}
|
|
4085
|
+
if (isFixed && !isOffsetParentAnElement && documentElement) {
|
|
4086
|
+
setLeftRTLScrollbarOffset();
|
|
4087
|
+
}
|
|
4088
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
4089
|
+
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
|
4090
|
+
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
|
4091
|
+
return {
|
|
4092
|
+
x,
|
|
4093
|
+
y,
|
|
4094
|
+
width: rect.width,
|
|
4095
|
+
height: rect.height
|
|
4096
|
+
};
|
|
4097
|
+
}
|
|
4098
|
+
function isStaticPositioned(element) {
|
|
4099
|
+
return getComputedStyle2(element).position === "static";
|
|
4100
|
+
}
|
|
4101
|
+
function getTrueOffsetParent(element, polyfill) {
|
|
4102
|
+
if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
|
|
4103
|
+
return null;
|
|
4104
|
+
}
|
|
4105
|
+
if (polyfill) {
|
|
4106
|
+
return polyfill(element);
|
|
4107
|
+
}
|
|
4108
|
+
let rawOffsetParent = element.offsetParent;
|
|
4109
|
+
if (getDocumentElement(element) === rawOffsetParent) {
|
|
4110
|
+
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
4111
|
+
}
|
|
4112
|
+
return rawOffsetParent;
|
|
4113
|
+
}
|
|
4114
|
+
function getOffsetParent(element, polyfill) {
|
|
4115
|
+
const win = getWindow(element);
|
|
4116
|
+
if (isTopLayer(element)) {
|
|
4117
|
+
return win;
|
|
4118
|
+
}
|
|
4119
|
+
if (!isHTMLElement(element)) {
|
|
4120
|
+
let svgOffsetParent = getParentNode(element);
|
|
4121
|
+
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
4122
|
+
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
|
4123
|
+
return svgOffsetParent;
|
|
4124
|
+
}
|
|
4125
|
+
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
4126
|
+
}
|
|
4127
|
+
return win;
|
|
4128
|
+
}
|
|
4129
|
+
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
4130
|
+
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
|
4131
|
+
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
4132
|
+
}
|
|
4133
|
+
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
|
4134
|
+
return win;
|
|
4135
|
+
}
|
|
4136
|
+
return offsetParent || getContainingBlock(element) || win;
|
|
4137
|
+
}
|
|
4138
|
+
var getElementRects = async function(data) {
|
|
4139
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
4140
|
+
const getDimensionsFn = this.getDimensions;
|
|
4141
|
+
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
4142
|
+
return {
|
|
4143
|
+
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
4144
|
+
floating: {
|
|
4145
|
+
x: 0,
|
|
4146
|
+
y: 0,
|
|
4147
|
+
width: floatingDimensions.width,
|
|
4148
|
+
height: floatingDimensions.height
|
|
4149
|
+
}
|
|
4150
|
+
};
|
|
4151
|
+
};
|
|
4152
|
+
function isRTL(element) {
|
|
4153
|
+
return getComputedStyle2(element).direction === "rtl";
|
|
4154
|
+
}
|
|
4155
|
+
var platform = {
|
|
4156
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
4157
|
+
getDocumentElement,
|
|
4158
|
+
getClippingRect,
|
|
4159
|
+
getOffsetParent,
|
|
4160
|
+
getElementRects,
|
|
4161
|
+
getClientRects,
|
|
4162
|
+
getDimensions,
|
|
4163
|
+
getScale,
|
|
4164
|
+
isElement,
|
|
4165
|
+
isRTL
|
|
4166
|
+
};
|
|
4167
|
+
var offset2 = offset;
|
|
4168
|
+
var shift2 = shift;
|
|
4169
|
+
var flip2 = flip;
|
|
4170
|
+
var computePosition2 = (reference, floating, options) => {
|
|
4171
|
+
const cache = /* @__PURE__ */ new Map();
|
|
4172
|
+
const mergedOptions = {
|
|
4173
|
+
platform,
|
|
4174
|
+
...options
|
|
4175
|
+
};
|
|
4176
|
+
const platformWithCache = {
|
|
4177
|
+
...mergedOptions.platform,
|
|
4178
|
+
_c: cache
|
|
4179
|
+
};
|
|
4180
|
+
return computePosition(reference, floating, {
|
|
4181
|
+
...mergedOptions,
|
|
4182
|
+
platform: platformWithCache
|
|
4183
|
+
});
|
|
4184
|
+
};
|
|
4185
|
+
|
|
2911
4186
|
// src/link-tooltip.js
|
|
2912
4187
|
var LinkTooltip = class {
|
|
2913
4188
|
constructor(editor) {
|
|
@@ -2916,27 +4191,10 @@ var LinkTooltip = class {
|
|
|
2916
4191
|
this.currentLink = null;
|
|
2917
4192
|
this.hideTimeout = null;
|
|
2918
4193
|
this.visibilityChangeHandler = null;
|
|
2919
|
-
this.useFloatingUI = false;
|
|
2920
|
-
this.floatingUI = null;
|
|
2921
4194
|
this.isTooltipHovered = false;
|
|
2922
4195
|
this.init();
|
|
2923
4196
|
}
|
|
2924
|
-
|
|
2925
|
-
const supportsAnchorPositioning = CSS.supports("position-anchor: --x") && CSS.supports("position-area: center");
|
|
2926
|
-
if (!supportsAnchorPositioning) {
|
|
2927
|
-
try {
|
|
2928
|
-
const importFn = new Function("url", "return import(url)");
|
|
2929
|
-
const { computePosition, offset, shift, flip } = await importFn(
|
|
2930
|
-
"https://cdn.jsdelivr.net/npm/@floating-ui/dom@1.7.4/+esm"
|
|
2931
|
-
);
|
|
2932
|
-
this.floatingUI = { computePosition, offset, shift, flip };
|
|
2933
|
-
this.useFloatingUI = true;
|
|
2934
|
-
} catch (error) {
|
|
2935
|
-
console.warn("Failed to load Floating UI fallback:", error);
|
|
2936
|
-
this.floatingUI = null;
|
|
2937
|
-
this.useFloatingUI = false;
|
|
2938
|
-
}
|
|
2939
|
-
}
|
|
4197
|
+
init() {
|
|
2940
4198
|
this.createTooltip();
|
|
2941
4199
|
this.editor.textarea.addEventListener("selectionchange", () => this.checkCursorPosition());
|
|
2942
4200
|
this.editor.textarea.addEventListener("keyup", (e) => {
|
|
@@ -2946,10 +4204,8 @@ var LinkTooltip = class {
|
|
|
2946
4204
|
});
|
|
2947
4205
|
this.editor.textarea.addEventListener("input", () => this.hide());
|
|
2948
4206
|
this.editor.textarea.addEventListener("scroll", () => {
|
|
2949
|
-
if (this.
|
|
2950
|
-
this.
|
|
2951
|
-
} else {
|
|
2952
|
-
this.hide();
|
|
4207
|
+
if (this.currentLink) {
|
|
4208
|
+
this.positionTooltip(this.currentLink);
|
|
2953
4209
|
}
|
|
2954
4210
|
});
|
|
2955
4211
|
this.editor.textarea.addEventListener("blur", () => {
|
|
@@ -3026,22 +4282,17 @@ var LinkTooltip = class {
|
|
|
3026
4282
|
}
|
|
3027
4283
|
return null;
|
|
3028
4284
|
}
|
|
3029
|
-
show(linkInfo) {
|
|
4285
|
+
async show(linkInfo) {
|
|
3030
4286
|
this.currentLink = linkInfo;
|
|
3031
4287
|
this.cancelHide();
|
|
3032
4288
|
const urlSpan = this.tooltip.querySelector(".overtype-link-tooltip-url");
|
|
3033
4289
|
urlSpan.textContent = linkInfo.url;
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
this.showWithAnchorPositioning(linkInfo);
|
|
4290
|
+
await this.positionTooltip(linkInfo);
|
|
4291
|
+
if (this.currentLink === linkInfo) {
|
|
4292
|
+
this.tooltip.classList.add("visible");
|
|
3038
4293
|
}
|
|
3039
|
-
this.tooltip.classList.add("visible");
|
|
3040
|
-
}
|
|
3041
|
-
showWithAnchorPositioning(linkInfo) {
|
|
3042
|
-
this.tooltip.style.setProperty("--target-anchor", `--link-${linkInfo.index}`);
|
|
3043
4294
|
}
|
|
3044
|
-
async
|
|
4295
|
+
async positionTooltip(linkInfo) {
|
|
3045
4296
|
const anchorElement = this.findAnchorElement(linkInfo.index);
|
|
3046
4297
|
if (!anchorElement) {
|
|
3047
4298
|
return;
|
|
@@ -3051,26 +4302,26 @@ var LinkTooltip = class {
|
|
|
3051
4302
|
return;
|
|
3052
4303
|
}
|
|
3053
4304
|
try {
|
|
3054
|
-
const { x, y } = await
|
|
4305
|
+
const { x, y } = await computePosition2(
|
|
3055
4306
|
anchorElement,
|
|
3056
4307
|
this.tooltip,
|
|
3057
4308
|
{
|
|
4309
|
+
strategy: "fixed",
|
|
3058
4310
|
placement: "bottom",
|
|
3059
4311
|
middleware: [
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
4312
|
+
offset2(8),
|
|
4313
|
+
shift2({ padding: 8 }),
|
|
4314
|
+
flip2()
|
|
3063
4315
|
]
|
|
3064
4316
|
}
|
|
3065
4317
|
);
|
|
3066
4318
|
Object.assign(this.tooltip.style, {
|
|
3067
4319
|
left: `${x}px`,
|
|
3068
4320
|
top: `${y}px`,
|
|
3069
|
-
position: "
|
|
4321
|
+
position: "fixed"
|
|
3070
4322
|
});
|
|
3071
4323
|
} catch (error) {
|
|
3072
4324
|
console.warn("Floating UI positioning failed:", error);
|
|
3073
|
-
return;
|
|
3074
4325
|
}
|
|
3075
4326
|
}
|
|
3076
4327
|
findAnchorElement(linkIndex) {
|
|
@@ -3103,8 +4354,6 @@ var LinkTooltip = class {
|
|
|
3103
4354
|
}
|
|
3104
4355
|
this.tooltip = null;
|
|
3105
4356
|
this.currentLink = null;
|
|
3106
|
-
this.floatingUI = null;
|
|
3107
|
-
this.useFloatingUI = false;
|
|
3108
4357
|
this.isTooltipHovered = false;
|
|
3109
4358
|
}
|
|
3110
4359
|
};
|
|
@@ -3167,6 +4416,11 @@ var taskListIcon = `<svg viewBox="0 0 18 18">
|
|
|
3167
4416
|
<rect stroke="currentColor" fill="none" stroke-width="1.5" x="2" y="13" width="3" height="3" rx="0.5"></rect>
|
|
3168
4417
|
<polyline stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" points="2.65 9.5 3.5 10.5 5 8.5"></polyline>
|
|
3169
4418
|
</svg>`;
|
|
4419
|
+
var uploadIcon = `<svg viewBox="0 0 18 18">
|
|
4420
|
+
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.25 12.375v1.688A1.688 1.688 0 0 0 3.938 15.75h10.124a1.688 1.688 0 0 0 1.688-1.688V12.375"></path>
|
|
4421
|
+
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5.063 6.188L9 2.25l3.938 3.938"></path>
|
|
4422
|
+
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 2.25v10.125"></path>
|
|
4423
|
+
</svg>`;
|
|
3170
4424
|
var eyeIcon = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
3171
4425
|
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" fill="none"></path>
|
|
3172
4426
|
<circle cx="12" cy="12" r="3" fill="none"></circle>
|
|
@@ -3290,6 +4544,33 @@ var toolbarButtons = {
|
|
|
3290
4544
|
editor.textarea.dispatchEvent(new Event("input", { bubbles: true }));
|
|
3291
4545
|
}
|
|
3292
4546
|
},
|
|
4547
|
+
upload: {
|
|
4548
|
+
name: "upload",
|
|
4549
|
+
actionId: "uploadFile",
|
|
4550
|
+
icon: uploadIcon,
|
|
4551
|
+
title: "Upload File",
|
|
4552
|
+
action: ({ editor }) => {
|
|
4553
|
+
var _a, _b;
|
|
4554
|
+
if (!((_a = editor.options.fileUpload) == null ? void 0 : _a.enabled))
|
|
4555
|
+
return;
|
|
4556
|
+
const input = document.createElement("input");
|
|
4557
|
+
input.type = "file";
|
|
4558
|
+
input.multiple = true;
|
|
4559
|
+
if (((_b = editor.options.fileUpload.mimeTypes) == null ? void 0 : _b.length) > 0) {
|
|
4560
|
+
input.accept = editor.options.fileUpload.mimeTypes.join(",");
|
|
4561
|
+
}
|
|
4562
|
+
input.onchange = () => {
|
|
4563
|
+
var _a2;
|
|
4564
|
+
if (!((_a2 = input.files) == null ? void 0 : _a2.length))
|
|
4565
|
+
return;
|
|
4566
|
+
const dt = new DataTransfer();
|
|
4567
|
+
for (const f of input.files)
|
|
4568
|
+
dt.items.add(f);
|
|
4569
|
+
editor._handleDataTransfer(dt);
|
|
4570
|
+
};
|
|
4571
|
+
input.click();
|
|
4572
|
+
}
|
|
4573
|
+
},
|
|
3293
4574
|
viewMode: {
|
|
3294
4575
|
name: "viewMode",
|
|
3295
4576
|
icon: eyeIcon,
|
|
@@ -3414,6 +4695,9 @@ var _OverType = class _OverType {
|
|
|
3414
4695
|
} else {
|
|
3415
4696
|
this._buildFromScratch();
|
|
3416
4697
|
}
|
|
4698
|
+
if (this.instanceTheme === "auto") {
|
|
4699
|
+
this.setTheme("auto");
|
|
4700
|
+
}
|
|
3417
4701
|
this.shortcuts = new ShortcutsManager(this);
|
|
3418
4702
|
this._rebuildActionsMap();
|
|
3419
4703
|
this.linkTooltip = new LinkTooltip(this);
|
|
@@ -3471,8 +4755,10 @@ var _OverType = class _OverType {
|
|
|
3471
4755
|
statsFormatter: null,
|
|
3472
4756
|
smartLists: true,
|
|
3473
4757
|
// Enable smart list continuation
|
|
3474
|
-
codeHighlighter: null
|
|
4758
|
+
codeHighlighter: null,
|
|
3475
4759
|
// Per-instance code highlighter
|
|
4760
|
+
spellcheck: false
|
|
4761
|
+
// Browser spellcheck (disabled by default)
|
|
3476
4762
|
};
|
|
3477
4763
|
const { theme, colors, ...cleanOptions } = options;
|
|
3478
4764
|
return {
|
|
@@ -3607,8 +4893,13 @@ var _OverType = class _OverType {
|
|
|
3607
4893
|
this.preview = document.createElement("div");
|
|
3608
4894
|
this.preview.className = "overtype-preview";
|
|
3609
4895
|
this.preview.setAttribute("aria-hidden", "true");
|
|
4896
|
+
this.placeholderEl = document.createElement("div");
|
|
4897
|
+
this.placeholderEl.className = "overtype-placeholder";
|
|
4898
|
+
this.placeholderEl.setAttribute("aria-hidden", "true");
|
|
4899
|
+
this.placeholderEl.textContent = this.options.placeholder;
|
|
3610
4900
|
this.wrapper.appendChild(this.textarea);
|
|
3611
4901
|
this.wrapper.appendChild(this.preview);
|
|
4902
|
+
this.wrapper.appendChild(this.placeholderEl);
|
|
3612
4903
|
this.container.appendChild(this.wrapper);
|
|
3613
4904
|
if (this.options.showStats) {
|
|
3614
4905
|
this.statsBar = document.createElement("div");
|
|
@@ -3631,7 +4922,7 @@ var _OverType = class _OverType {
|
|
|
3631
4922
|
this.textarea.setAttribute("autocomplete", "off");
|
|
3632
4923
|
this.textarea.setAttribute("autocorrect", "off");
|
|
3633
4924
|
this.textarea.setAttribute("autocapitalize", "off");
|
|
3634
|
-
this.textarea.setAttribute("spellcheck",
|
|
4925
|
+
this.textarea.setAttribute("spellcheck", String(this.options.spellcheck));
|
|
3635
4926
|
this.textarea.setAttribute("data-gramm", "false");
|
|
3636
4927
|
this.textarea.setAttribute("data-gramm_editor", "false");
|
|
3637
4928
|
this.textarea.setAttribute("data-enable-grammarly", "false");
|
|
@@ -3641,7 +4932,17 @@ var _OverType = class _OverType {
|
|
|
3641
4932
|
* @private
|
|
3642
4933
|
*/
|
|
3643
4934
|
_createToolbar() {
|
|
3644
|
-
|
|
4935
|
+
var _a;
|
|
4936
|
+
let toolbarButtons2 = this.options.toolbarButtons || defaultToolbarButtons;
|
|
4937
|
+
if (((_a = this.options.fileUpload) == null ? void 0 : _a.enabled) && !toolbarButtons2.some((b) => (b == null ? void 0 : b.name) === "upload")) {
|
|
4938
|
+
const viewModeIdx = toolbarButtons2.findIndex((b) => (b == null ? void 0 : b.name) === "viewMode");
|
|
4939
|
+
if (viewModeIdx !== -1) {
|
|
4940
|
+
toolbarButtons2 = [...toolbarButtons2];
|
|
4941
|
+
toolbarButtons2.splice(viewModeIdx, 0, toolbarButtons.separator, toolbarButtons.upload);
|
|
4942
|
+
} else {
|
|
4943
|
+
toolbarButtons2 = [...toolbarButtons2, toolbarButtons.separator, toolbarButtons.upload];
|
|
4944
|
+
}
|
|
4945
|
+
}
|
|
3645
4946
|
this.toolbar = new Toolbar(this, { toolbarButtons: toolbarButtons2 });
|
|
3646
4947
|
this.toolbar.create();
|
|
3647
4948
|
this._toolbarSelectionListener = () => {
|
|
@@ -3677,10 +4978,14 @@ var _OverType = class _OverType {
|
|
|
3677
4978
|
* @private
|
|
3678
4979
|
*/
|
|
3679
4980
|
_rebuildActionsMap() {
|
|
4981
|
+
var _a;
|
|
3680
4982
|
this.actionsById = buildActionsMap(defaultToolbarButtons);
|
|
3681
4983
|
if (this.options.toolbarButtons) {
|
|
3682
4984
|
Object.assign(this.actionsById, buildActionsMap(this.options.toolbarButtons));
|
|
3683
4985
|
}
|
|
4986
|
+
if ((_a = this.options.fileUpload) == null ? void 0 : _a.enabled) {
|
|
4987
|
+
Object.assign(this.actionsById, buildActionsMap([toolbarButtons.upload]));
|
|
4988
|
+
}
|
|
3684
4989
|
}
|
|
3685
4990
|
/**
|
|
3686
4991
|
* Apply options to the editor
|
|
@@ -3693,6 +4998,8 @@ var _OverType = class _OverType {
|
|
|
3693
4998
|
if (this.options.autoResize) {
|
|
3694
4999
|
if (!this.container.classList.contains("overtype-auto-resize")) {
|
|
3695
5000
|
this._setupAutoResize();
|
|
5001
|
+
} else {
|
|
5002
|
+
this._updateAutoHeight();
|
|
3696
5003
|
}
|
|
3697
5004
|
} else {
|
|
3698
5005
|
this.container.classList.remove("overtype-auto-resize");
|
|
@@ -3704,8 +5011,119 @@ var _OverType = class _OverType {
|
|
|
3704
5011
|
this.toolbar.destroy();
|
|
3705
5012
|
this.toolbar = null;
|
|
3706
5013
|
}
|
|
5014
|
+
if (this.placeholderEl) {
|
|
5015
|
+
this.placeholderEl.textContent = this.options.placeholder;
|
|
5016
|
+
}
|
|
5017
|
+
if (this.options.fileUpload && !this.fileUploadInitialized) {
|
|
5018
|
+
this._initFileUpload();
|
|
5019
|
+
} else if (!this.options.fileUpload && this.fileUploadInitialized) {
|
|
5020
|
+
this._destroyFileUpload();
|
|
5021
|
+
}
|
|
3707
5022
|
this.updatePreview();
|
|
3708
5023
|
}
|
|
5024
|
+
_initFileUpload() {
|
|
5025
|
+
const options = this.options.fileUpload;
|
|
5026
|
+
if (!options || !options.enabled)
|
|
5027
|
+
return;
|
|
5028
|
+
options.maxSize = options.maxSize || 10 * 1024 * 1024;
|
|
5029
|
+
options.mimeTypes = options.mimeTypes || [];
|
|
5030
|
+
options.batch = options.batch || false;
|
|
5031
|
+
if (!options.onInsertFile || typeof options.onInsertFile !== "function") {
|
|
5032
|
+
console.warn("OverType: fileUpload.onInsertFile callback is required for file uploads.");
|
|
5033
|
+
return;
|
|
5034
|
+
}
|
|
5035
|
+
this._fileUploadCounter = 0;
|
|
5036
|
+
this._boundHandleFilePaste = this._handleFilePaste.bind(this);
|
|
5037
|
+
this._boundHandleFileDrop = this._handleFileDrop.bind(this);
|
|
5038
|
+
this._boundHandleDragOver = this._handleDragOver.bind(this);
|
|
5039
|
+
this.textarea.addEventListener("paste", this._boundHandleFilePaste);
|
|
5040
|
+
this.textarea.addEventListener("drop", this._boundHandleFileDrop);
|
|
5041
|
+
this.textarea.addEventListener("dragover", this._boundHandleDragOver);
|
|
5042
|
+
this.fileUploadInitialized = true;
|
|
5043
|
+
}
|
|
5044
|
+
_handleFilePaste(e) {
|
|
5045
|
+
var _a, _b;
|
|
5046
|
+
if (!((_b = (_a = e == null ? void 0 : e.clipboardData) == null ? void 0 : _a.files) == null ? void 0 : _b.length))
|
|
5047
|
+
return;
|
|
5048
|
+
e.preventDefault();
|
|
5049
|
+
this._handleDataTransfer(e.clipboardData);
|
|
5050
|
+
}
|
|
5051
|
+
_handleFileDrop(e) {
|
|
5052
|
+
var _a, _b;
|
|
5053
|
+
if (!((_b = (_a = e == null ? void 0 : e.dataTransfer) == null ? void 0 : _a.files) == null ? void 0 : _b.length))
|
|
5054
|
+
return;
|
|
5055
|
+
e.preventDefault();
|
|
5056
|
+
this._handleDataTransfer(e.dataTransfer);
|
|
5057
|
+
}
|
|
5058
|
+
_handleDataTransfer(dataTransfer) {
|
|
5059
|
+
const files = [];
|
|
5060
|
+
for (const file of dataTransfer.files) {
|
|
5061
|
+
if (file.size > this.options.fileUpload.maxSize)
|
|
5062
|
+
continue;
|
|
5063
|
+
if (this.options.fileUpload.mimeTypes.length > 0 && !this.options.fileUpload.mimeTypes.includes(file.type))
|
|
5064
|
+
continue;
|
|
5065
|
+
const id = ++this._fileUploadCounter;
|
|
5066
|
+
const prefix = file.type.startsWith("image/") ? "!" : "";
|
|
5067
|
+
const placeholder = `${prefix}[Uploading ${file.name} (#${id})...]()`;
|
|
5068
|
+
this.insertAtCursor(`${placeholder}
|
|
5069
|
+
`);
|
|
5070
|
+
if (this.options.fileUpload.batch) {
|
|
5071
|
+
files.push({ file, placeholder });
|
|
5072
|
+
continue;
|
|
5073
|
+
}
|
|
5074
|
+
this.options.fileUpload.onInsertFile(file).then((text) => {
|
|
5075
|
+
this.textarea.value = this.textarea.value.replace(placeholder, text);
|
|
5076
|
+
this.textarea.dispatchEvent(new Event("input", { bubbles: true }));
|
|
5077
|
+
}, (error) => {
|
|
5078
|
+
console.error("OverType: File upload failed", error);
|
|
5079
|
+
this.textarea.value = this.textarea.value.replace(placeholder, "[Upload failed]()");
|
|
5080
|
+
this.textarea.dispatchEvent(new Event("input", { bubbles: true }));
|
|
5081
|
+
});
|
|
5082
|
+
}
|
|
5083
|
+
if (this.options.fileUpload.batch && files.length > 0) {
|
|
5084
|
+
this.options.fileUpload.onInsertFile(files.map((f) => f.file)).then((result) => {
|
|
5085
|
+
const texts = Array.isArray(result) ? result : [result];
|
|
5086
|
+
texts.forEach((text, index) => {
|
|
5087
|
+
this.textarea.value = this.textarea.value.replace(files[index].placeholder, text);
|
|
5088
|
+
});
|
|
5089
|
+
this.textarea.dispatchEvent(new Event("input", { bubbles: true }));
|
|
5090
|
+
}, (error) => {
|
|
5091
|
+
console.error("OverType: File upload failed", error);
|
|
5092
|
+
files.forEach(({ placeholder }) => {
|
|
5093
|
+
this.textarea.value = this.textarea.value.replace(placeholder, "[Upload failed]()");
|
|
5094
|
+
});
|
|
5095
|
+
this.textarea.dispatchEvent(new Event("input", { bubbles: true }));
|
|
5096
|
+
});
|
|
5097
|
+
}
|
|
5098
|
+
}
|
|
5099
|
+
_handleDragOver(e) {
|
|
5100
|
+
e.preventDefault();
|
|
5101
|
+
}
|
|
5102
|
+
_destroyFileUpload() {
|
|
5103
|
+
this.textarea.removeEventListener("paste", this._boundHandleFilePaste);
|
|
5104
|
+
this.textarea.removeEventListener("drop", this._boundHandleFileDrop);
|
|
5105
|
+
this.textarea.removeEventListener("dragover", this._boundHandleDragOver);
|
|
5106
|
+
this._boundHandleFilePaste = null;
|
|
5107
|
+
this._boundHandleFileDrop = null;
|
|
5108
|
+
this._boundHandleDragOver = null;
|
|
5109
|
+
this.fileUploadInitialized = false;
|
|
5110
|
+
}
|
|
5111
|
+
insertAtCursor(text) {
|
|
5112
|
+
const start = this.textarea.selectionStart;
|
|
5113
|
+
const end = this.textarea.selectionEnd;
|
|
5114
|
+
let inserted = false;
|
|
5115
|
+
try {
|
|
5116
|
+
inserted = document.execCommand("insertText", false, text);
|
|
5117
|
+
} catch (_) {
|
|
5118
|
+
}
|
|
5119
|
+
if (!inserted) {
|
|
5120
|
+
const before = this.textarea.value.slice(0, start);
|
|
5121
|
+
const after = this.textarea.value.slice(end);
|
|
5122
|
+
this.textarea.value = before + text + after;
|
|
5123
|
+
this.textarea.setSelectionRange(start + text.length, start + text.length);
|
|
5124
|
+
}
|
|
5125
|
+
this.textarea.dispatchEvent(new Event("input", { bubbles: true }));
|
|
5126
|
+
}
|
|
3709
5127
|
/**
|
|
3710
5128
|
* Update preview with parsed markdown
|
|
3711
5129
|
*/
|
|
@@ -3715,7 +5133,10 @@ var _OverType = class _OverType {
|
|
|
3715
5133
|
const activeLine = this._getCurrentLine(text, cursorPos);
|
|
3716
5134
|
const isPreviewMode = this.container.dataset.mode === "preview";
|
|
3717
5135
|
const html = MarkdownParser.parse(text, activeLine, this.options.showActiveLineRaw, this.options.codeHighlighter, isPreviewMode);
|
|
3718
|
-
this.preview.innerHTML = html
|
|
5136
|
+
this.preview.innerHTML = html;
|
|
5137
|
+
if (this.placeholderEl) {
|
|
5138
|
+
this.placeholderEl.style.display = text ? "none" : "";
|
|
5139
|
+
}
|
|
3719
5140
|
this._applyCodeBlockBackgrounds();
|
|
3720
5141
|
if (this.options.showStats && this.statsBar) {
|
|
3721
5142
|
this._updateStats();
|
|
@@ -3898,7 +5319,7 @@ var _OverType = class _OverType {
|
|
|
3898
5319
|
const cursorPos = this.textarea.selectionStart;
|
|
3899
5320
|
const newValue = MarkdownParser.renumberLists(value);
|
|
3900
5321
|
if (newValue !== value) {
|
|
3901
|
-
let
|
|
5322
|
+
let offset3 = 0;
|
|
3902
5323
|
const oldLines = value.split("\n");
|
|
3903
5324
|
const newLines = newValue.split("\n");
|
|
3904
5325
|
let charCount = 0;
|
|
@@ -3906,13 +5327,13 @@ var _OverType = class _OverType {
|
|
|
3906
5327
|
if (oldLines[i] !== newLines[i]) {
|
|
3907
5328
|
const diff = newLines[i].length - oldLines[i].length;
|
|
3908
5329
|
if (charCount + oldLines[i].length < cursorPos) {
|
|
3909
|
-
|
|
5330
|
+
offset3 += diff;
|
|
3910
5331
|
}
|
|
3911
5332
|
}
|
|
3912
5333
|
charCount += oldLines[i].length + 1;
|
|
3913
5334
|
}
|
|
3914
5335
|
this.textarea.value = newValue;
|
|
3915
|
-
const newCursorPos = cursorPos +
|
|
5336
|
+
const newCursorPos = cursorPos + offset3;
|
|
3916
5337
|
this.textarea.setSelectionRange(newCursorPos, newCursorPos);
|
|
3917
5338
|
this.textarea.dispatchEvent(new Event("input", { bubbles: true }));
|
|
3918
5339
|
}
|
|
@@ -4044,27 +5465,61 @@ var _OverType = class _OverType {
|
|
|
4044
5465
|
this.toolbar = null;
|
|
4045
5466
|
this._createToolbar();
|
|
4046
5467
|
}
|
|
5468
|
+
if (this.fileUploadInitialized) {
|
|
5469
|
+
this._destroyFileUpload();
|
|
5470
|
+
}
|
|
5471
|
+
if (this.options.fileUpload) {
|
|
5472
|
+
this._initFileUpload();
|
|
5473
|
+
}
|
|
4047
5474
|
this._applyOptions();
|
|
4048
5475
|
this.updatePreview();
|
|
4049
5476
|
}
|
|
5477
|
+
showToolbar() {
|
|
5478
|
+
if (this.toolbar) {
|
|
5479
|
+
this.toolbar.show();
|
|
5480
|
+
} else {
|
|
5481
|
+
this._createToolbar();
|
|
5482
|
+
}
|
|
5483
|
+
}
|
|
5484
|
+
hideToolbar() {
|
|
5485
|
+
if (this.toolbar) {
|
|
5486
|
+
this.toolbar.hide();
|
|
5487
|
+
}
|
|
5488
|
+
}
|
|
4050
5489
|
/**
|
|
4051
5490
|
* Set theme for this instance
|
|
4052
5491
|
* @param {string|Object} theme - Theme name or custom theme object
|
|
4053
5492
|
* @returns {this} Returns this for chaining
|
|
4054
5493
|
*/
|
|
4055
5494
|
setTheme(theme) {
|
|
5495
|
+
_OverType._autoInstances.delete(this);
|
|
4056
5496
|
this.instanceTheme = theme;
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
this.
|
|
5497
|
+
if (theme === "auto") {
|
|
5498
|
+
_OverType._autoInstances.add(this);
|
|
5499
|
+
_OverType._startAutoListener();
|
|
5500
|
+
this._applyResolvedTheme(resolveAutoTheme("auto"));
|
|
5501
|
+
} else {
|
|
5502
|
+
const themeObj = typeof theme === "string" ? getTheme(theme) : theme;
|
|
5503
|
+
const themeName = typeof themeObj === "string" ? themeObj : themeObj.name;
|
|
5504
|
+
if (themeName) {
|
|
5505
|
+
this.container.setAttribute("data-theme", themeName);
|
|
5506
|
+
}
|
|
5507
|
+
if (themeObj && themeObj.colors) {
|
|
5508
|
+
const cssVars = themeToCSSVars(themeObj.colors, themeObj.previewColors);
|
|
5509
|
+
this.container.style.cssText += cssVars;
|
|
5510
|
+
}
|
|
5511
|
+
this.updatePreview();
|
|
4061
5512
|
}
|
|
5513
|
+
_OverType._stopAutoListener();
|
|
5514
|
+
return this;
|
|
5515
|
+
}
|
|
5516
|
+
_applyResolvedTheme(themeName) {
|
|
5517
|
+
const themeObj = getTheme(themeName);
|
|
5518
|
+
this.container.setAttribute("data-theme", themeName);
|
|
4062
5519
|
if (themeObj && themeObj.colors) {
|
|
4063
|
-
|
|
4064
|
-
this.container.style.cssText += cssVars;
|
|
5520
|
+
this.container.style.cssText = themeToCSSVars(themeObj.colors, themeObj.previewColors);
|
|
4065
5521
|
}
|
|
4066
5522
|
this.updatePreview();
|
|
4067
|
-
return this;
|
|
4068
5523
|
}
|
|
4069
5524
|
/**
|
|
4070
5525
|
* Set instance-specific code highlighter
|
|
@@ -4218,6 +5673,11 @@ var _OverType = class _OverType {
|
|
|
4218
5673
|
* Destroy the editor instance
|
|
4219
5674
|
*/
|
|
4220
5675
|
destroy() {
|
|
5676
|
+
_OverType._autoInstances.delete(this);
|
|
5677
|
+
_OverType._stopAutoListener();
|
|
5678
|
+
if (this.fileUploadInitialized) {
|
|
5679
|
+
this._destroyFileUpload();
|
|
5680
|
+
}
|
|
4221
5681
|
this.element.overTypeInstance = null;
|
|
4222
5682
|
_OverType.instances.delete(this.element);
|
|
4223
5683
|
if (this.shortcuts) {
|
|
@@ -4260,7 +5720,7 @@ var _OverType = class _OverType {
|
|
|
4260
5720
|
options[key] = _OverType._parseDataValue(attr.value);
|
|
4261
5721
|
}
|
|
4262
5722
|
}
|
|
4263
|
-
return new _OverType(el, options);
|
|
5723
|
+
return new _OverType(el, options)[0];
|
|
4264
5724
|
});
|
|
4265
5725
|
}
|
|
4266
5726
|
/**
|
|
@@ -4323,23 +5783,35 @@ var _OverType = class _OverType {
|
|
|
4323
5783
|
* @param {Object} customColors - Optional color overrides
|
|
4324
5784
|
*/
|
|
4325
5785
|
static setTheme(theme, customColors = null) {
|
|
5786
|
+
_OverType._globalAutoTheme = false;
|
|
5787
|
+
_OverType._globalAutoCustomColors = null;
|
|
5788
|
+
if (theme === "auto") {
|
|
5789
|
+
_OverType._globalAutoTheme = true;
|
|
5790
|
+
_OverType._globalAutoCustomColors = customColors;
|
|
5791
|
+
_OverType._startAutoListener();
|
|
5792
|
+
_OverType._applyGlobalTheme(resolveAutoTheme("auto"), customColors);
|
|
5793
|
+
return;
|
|
5794
|
+
}
|
|
5795
|
+
_OverType._stopAutoListener();
|
|
5796
|
+
_OverType._applyGlobalTheme(theme, customColors);
|
|
5797
|
+
}
|
|
5798
|
+
static _applyGlobalTheme(theme, customColors = null) {
|
|
4326
5799
|
let themeObj = typeof theme === "string" ? getTheme(theme) : theme;
|
|
4327
5800
|
if (customColors) {
|
|
4328
5801
|
themeObj = mergeTheme(themeObj, customColors);
|
|
4329
5802
|
}
|
|
4330
5803
|
_OverType.currentTheme = themeObj;
|
|
4331
5804
|
_OverType.injectStyles(true);
|
|
5805
|
+
const themeName = typeof themeObj === "string" ? themeObj : themeObj.name;
|
|
4332
5806
|
document.querySelectorAll(".overtype-container").forEach((container) => {
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
container.setAttribute("data-theme", themeName2);
|
|
5807
|
+
if (themeName) {
|
|
5808
|
+
container.setAttribute("data-theme", themeName);
|
|
4336
5809
|
}
|
|
4337
5810
|
});
|
|
4338
5811
|
document.querySelectorAll(".overtype-wrapper").forEach((wrapper) => {
|
|
4339
5812
|
if (!wrapper.closest(".overtype-container")) {
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
wrapper.setAttribute("data-theme", themeName2);
|
|
5813
|
+
if (themeName) {
|
|
5814
|
+
wrapper.setAttribute("data-theme", themeName);
|
|
4343
5815
|
}
|
|
4344
5816
|
}
|
|
4345
5817
|
const instance = wrapper._instance;
|
|
@@ -4347,7 +5819,6 @@ var _OverType = class _OverType {
|
|
|
4347
5819
|
instance.updatePreview();
|
|
4348
5820
|
}
|
|
4349
5821
|
});
|
|
4350
|
-
const themeName = typeof themeObj === "string" ? themeObj : themeObj.name;
|
|
4351
5822
|
document.querySelectorAll("overtype-editor").forEach((webComponent) => {
|
|
4352
5823
|
if (themeName && typeof webComponent.setAttribute === "function") {
|
|
4353
5824
|
webComponent.setAttribute("theme", themeName);
|
|
@@ -4357,6 +5828,30 @@ var _OverType = class _OverType {
|
|
|
4357
5828
|
}
|
|
4358
5829
|
});
|
|
4359
5830
|
}
|
|
5831
|
+
static _startAutoListener() {
|
|
5832
|
+
if (_OverType._autoMediaQuery)
|
|
5833
|
+
return;
|
|
5834
|
+
if (!window.matchMedia)
|
|
5835
|
+
return;
|
|
5836
|
+
_OverType._autoMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
5837
|
+
_OverType._autoMediaListener = (e) => {
|
|
5838
|
+
const resolved = e.matches ? "cave" : "solar";
|
|
5839
|
+
if (_OverType._globalAutoTheme) {
|
|
5840
|
+
_OverType._applyGlobalTheme(resolved, _OverType._globalAutoCustomColors);
|
|
5841
|
+
}
|
|
5842
|
+
_OverType._autoInstances.forEach((inst) => inst._applyResolvedTheme(resolved));
|
|
5843
|
+
};
|
|
5844
|
+
_OverType._autoMediaQuery.addEventListener("change", _OverType._autoMediaListener);
|
|
5845
|
+
}
|
|
5846
|
+
static _stopAutoListener() {
|
|
5847
|
+
if (_OverType._autoInstances.size > 0 || _OverType._globalAutoTheme)
|
|
5848
|
+
return;
|
|
5849
|
+
if (!_OverType._autoMediaQuery)
|
|
5850
|
+
return;
|
|
5851
|
+
_OverType._autoMediaQuery.removeEventListener("change", _OverType._autoMediaListener);
|
|
5852
|
+
_OverType._autoMediaQuery = null;
|
|
5853
|
+
_OverType._autoMediaListener = null;
|
|
5854
|
+
}
|
|
4360
5855
|
/**
|
|
4361
5856
|
* Set global code highlighter for all OverType instances
|
|
4362
5857
|
* @param {Function|null} highlighter - Function that takes (code, language) and returns highlighted HTML
|
|
@@ -4458,6 +5953,11 @@ __publicField(_OverType, "instances", /* @__PURE__ */ new WeakMap());
|
|
|
4458
5953
|
__publicField(_OverType, "stylesInjected", false);
|
|
4459
5954
|
__publicField(_OverType, "globalListenersInitialized", false);
|
|
4460
5955
|
__publicField(_OverType, "instanceCount", 0);
|
|
5956
|
+
__publicField(_OverType, "_autoMediaQuery", null);
|
|
5957
|
+
__publicField(_OverType, "_autoMediaListener", null);
|
|
5958
|
+
__publicField(_OverType, "_autoInstances", /* @__PURE__ */ new Set());
|
|
5959
|
+
__publicField(_OverType, "_globalAutoTheme", false);
|
|
5960
|
+
__publicField(_OverType, "_globalAutoCustomColors", null);
|
|
4461
5961
|
var OverType = _OverType;
|
|
4462
5962
|
OverType.MarkdownParser = MarkdownParser;
|
|
4463
5963
|
OverType.ShortcutsManager = ShortcutsManager;
|
|
@@ -4484,7 +5984,8 @@ var OBSERVED_ATTRIBUTES = [
|
|
|
4484
5984
|
"autofocus",
|
|
4485
5985
|
"show-stats",
|
|
4486
5986
|
"smart-lists",
|
|
4487
|
-
"readonly"
|
|
5987
|
+
"readonly",
|
|
5988
|
+
"spellcheck"
|
|
4488
5989
|
];
|
|
4489
5990
|
var OverTypeEditor = class extends HTMLElement {
|
|
4490
5991
|
constructor() {
|
|
@@ -4667,6 +6168,7 @@ var OverTypeEditor = class extends HTMLElement {
|
|
|
4667
6168
|
autoResize: this.hasAttribute("auto-resize"),
|
|
4668
6169
|
showStats: this.hasAttribute("show-stats"),
|
|
4669
6170
|
smartLists: !this.hasAttribute("smart-lists") || this.getAttribute("smart-lists") !== "false",
|
|
6171
|
+
spellcheck: this.hasAttribute("spellcheck") && this.getAttribute("spellcheck") !== "false",
|
|
4670
6172
|
onChange: this._handleChange,
|
|
4671
6173
|
onKeydown: this._handleKeydown
|
|
4672
6174
|
};
|
|
@@ -4722,8 +6224,14 @@ var OverTypeEditor = class extends HTMLElement {
|
|
|
4722
6224
|
}
|
|
4723
6225
|
break;
|
|
4724
6226
|
case "placeholder":
|
|
4725
|
-
if (this._editor
|
|
4726
|
-
this._editor.
|
|
6227
|
+
if (this._editor) {
|
|
6228
|
+
this._editor.options.placeholder = value || "";
|
|
6229
|
+
if (this._editor.textarea) {
|
|
6230
|
+
this._editor.textarea.placeholder = value || "";
|
|
6231
|
+
}
|
|
6232
|
+
if (this._editor.placeholderEl) {
|
|
6233
|
+
this._editor.placeholderEl.textContent = value || "";
|
|
6234
|
+
}
|
|
4727
6235
|
}
|
|
4728
6236
|
break;
|
|
4729
6237
|
case "readonly":
|
|
@@ -4773,6 +6281,15 @@ var OverTypeEditor = class extends HTMLElement {
|
|
|
4773
6281
|
this._reinitializeEditor();
|
|
4774
6282
|
break;
|
|
4775
6283
|
}
|
|
6284
|
+
case "spellcheck":
|
|
6285
|
+
if (this._editor) {
|
|
6286
|
+
const enabled = this.hasAttribute("spellcheck") && this.getAttribute("spellcheck") !== "false";
|
|
6287
|
+
this._editor.options.spellcheck = enabled;
|
|
6288
|
+
if (this._editor.textarea) {
|
|
6289
|
+
this._editor.textarea.setAttribute("spellcheck", String(enabled));
|
|
6290
|
+
}
|
|
6291
|
+
}
|
|
6292
|
+
break;
|
|
4776
6293
|
}
|
|
4777
6294
|
}
|
|
4778
6295
|
/**
|
|
@@ -5016,6 +6533,16 @@ var OverTypeEditor = class extends HTMLElement {
|
|
|
5016
6533
|
getEditor() {
|
|
5017
6534
|
return this._editor;
|
|
5018
6535
|
}
|
|
6536
|
+
showToolbar() {
|
|
6537
|
+
if (this._editor) {
|
|
6538
|
+
this._editor.showToolbar();
|
|
6539
|
+
}
|
|
6540
|
+
}
|
|
6541
|
+
hideToolbar() {
|
|
6542
|
+
if (this._editor) {
|
|
6543
|
+
this._editor.hideToolbar();
|
|
6544
|
+
}
|
|
6545
|
+
}
|
|
5019
6546
|
};
|
|
5020
6547
|
if (!customElements.get("overtype-editor")) {
|
|
5021
6548
|
customElements.define("overtype-editor", OverTypeEditor);
|