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
package/dist/overtype.cjs
CHANGED
|
@@ -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
|
|
@@ -105,6 +105,7 @@ var MarkdownParser = class {
|
|
|
105
105
|
static parseHeader(html) {
|
|
106
106
|
return html.replace(/^(#{1,3})\s(.+)$/, (match, hashes, content) => {
|
|
107
107
|
const level = hashes.length;
|
|
108
|
+
content = this.parseInlineElements(content);
|
|
108
109
|
return `<h${level}><span class="syntax-marker">${hashes} </span>${content}</h${level}>`;
|
|
109
110
|
});
|
|
110
111
|
}
|
|
@@ -136,6 +137,7 @@ var MarkdownParser = class {
|
|
|
136
137
|
*/
|
|
137
138
|
static parseBulletList(html) {
|
|
138
139
|
return html.replace(/^((?: )*)([-*+])\s(.+)$/, (match, indent, marker, content) => {
|
|
140
|
+
content = this.parseInlineElements(content);
|
|
139
141
|
return `${indent}<li class="bullet-list"><span class="syntax-marker">${marker} </span>${content}</li>`;
|
|
140
142
|
});
|
|
141
143
|
}
|
|
@@ -147,6 +149,7 @@ var MarkdownParser = class {
|
|
|
147
149
|
*/
|
|
148
150
|
static parseTaskList(html, isPreviewMode = false) {
|
|
149
151
|
return html.replace(/^((?: )*)-\s+\[([ xX])\]\s+(.+)$/, (match, indent, checked, content) => {
|
|
152
|
+
content = this.parseInlineElements(content);
|
|
150
153
|
if (isPreviewMode) {
|
|
151
154
|
const isChecked = checked.toLowerCase() === "x";
|
|
152
155
|
return `${indent}<li class="task-list"><input type="checkbox" ${isChecked ? "checked" : ""}> ${content}</li>`;
|
|
@@ -162,6 +165,7 @@ var MarkdownParser = class {
|
|
|
162
165
|
*/
|
|
163
166
|
static parseNumberedList(html) {
|
|
164
167
|
return html.replace(/^((?: )*)(\d+\.)\s(.+)$/, (match, indent, marker, content) => {
|
|
168
|
+
content = this.parseInlineElements(content);
|
|
165
169
|
return `${indent}<li class="ordered-list"><span class="syntax-marker">${marker} </span>${content}</li>`;
|
|
166
170
|
});
|
|
167
171
|
}
|
|
@@ -383,7 +387,9 @@ var MarkdownParser = class {
|
|
|
383
387
|
html = this.parseTaskList(html, isPreviewMode);
|
|
384
388
|
html = this.parseBulletList(html);
|
|
385
389
|
html = this.parseNumberedList(html);
|
|
386
|
-
html
|
|
390
|
+
if (!html.includes("<li") && !html.includes("<h")) {
|
|
391
|
+
html = this.parseInlineElements(html);
|
|
392
|
+
}
|
|
387
393
|
if (html.trim() === "") {
|
|
388
394
|
return "<div> </div>";
|
|
389
395
|
}
|
|
@@ -872,8 +878,24 @@ var solar = {
|
|
|
872
878
|
// Yale Blue - icon color
|
|
873
879
|
toolbarHover: "#f5f5f5",
|
|
874
880
|
// Light gray - hover background
|
|
875
|
-
toolbarActive: "#faf0ca"
|
|
881
|
+
toolbarActive: "#faf0ca",
|
|
876
882
|
// Lemon Chiffon - active button background
|
|
883
|
+
placeholder: "#999999"
|
|
884
|
+
// Gray - placeholder text
|
|
885
|
+
},
|
|
886
|
+
previewColors: {
|
|
887
|
+
text: "#1a1a1a",
|
|
888
|
+
h1: "#1a1a1a",
|
|
889
|
+
h2: "#2a2a2a",
|
|
890
|
+
h3: "#3a3a3a",
|
|
891
|
+
strong: "inherit",
|
|
892
|
+
em: "inherit",
|
|
893
|
+
link: "#0066cc",
|
|
894
|
+
code: "#1a1a1a",
|
|
895
|
+
codeBg: "rgba(135, 131, 120, 0.15)",
|
|
896
|
+
blockquote: "#555",
|
|
897
|
+
hr: "#ddd",
|
|
898
|
+
bg: "transparent"
|
|
877
899
|
}
|
|
878
900
|
};
|
|
879
901
|
var cave = {
|
|
@@ -936,13 +958,30 @@ var cave = {
|
|
|
936
958
|
// Light blue-gray - icon color
|
|
937
959
|
toolbarHover: "#243546",
|
|
938
960
|
// Slightly lighter charcoal - hover background
|
|
939
|
-
toolbarActive: "#2a3f52"
|
|
961
|
+
toolbarActive: "#2a3f52",
|
|
940
962
|
// Even lighter - active button background
|
|
963
|
+
placeholder: "#6a7a88"
|
|
964
|
+
// Muted blue-gray - placeholder text
|
|
965
|
+
},
|
|
966
|
+
previewColors: {
|
|
967
|
+
text: "#c5dde8",
|
|
968
|
+
h1: "#e0e0e0",
|
|
969
|
+
h2: "#d0d0d0",
|
|
970
|
+
h3: "#c0c0c0",
|
|
971
|
+
strong: "inherit",
|
|
972
|
+
em: "inherit",
|
|
973
|
+
link: "#6cb6e0",
|
|
974
|
+
code: "#c5dde8",
|
|
975
|
+
codeBg: "rgba(255, 255, 255, 0.08)",
|
|
976
|
+
blockquote: "#9aa8b4",
|
|
977
|
+
hr: "rgba(255, 255, 255, 0.15)",
|
|
978
|
+
bg: "transparent"
|
|
941
979
|
}
|
|
942
980
|
};
|
|
943
981
|
var themes = {
|
|
944
982
|
solar,
|
|
945
983
|
cave,
|
|
984
|
+
auto: solar,
|
|
946
985
|
// Aliases for backward compatibility
|
|
947
986
|
light: solar,
|
|
948
987
|
dark: cave
|
|
@@ -954,20 +993,36 @@ function getTheme(theme) {
|
|
|
954
993
|
}
|
|
955
994
|
return theme;
|
|
956
995
|
}
|
|
957
|
-
function
|
|
996
|
+
function resolveAutoTheme(themeName) {
|
|
997
|
+
if (themeName !== "auto")
|
|
998
|
+
return themeName;
|
|
999
|
+
const mq = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)");
|
|
1000
|
+
return (mq == null ? void 0 : mq.matches) ? "cave" : "solar";
|
|
1001
|
+
}
|
|
1002
|
+
function themeToCSSVars(colors, previewColors) {
|
|
958
1003
|
const vars = [];
|
|
959
1004
|
for (const [key, value] of Object.entries(colors)) {
|
|
960
1005
|
const varName = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
961
1006
|
vars.push(`--${varName}: ${value};`);
|
|
962
1007
|
}
|
|
1008
|
+
if (previewColors) {
|
|
1009
|
+
for (const [key, value] of Object.entries(previewColors)) {
|
|
1010
|
+
const varName = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
1011
|
+
vars.push(`--preview-${varName}: ${value};`);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
963
1014
|
return vars.join("\n");
|
|
964
1015
|
}
|
|
965
|
-
function mergeTheme(baseTheme, customColors = {}) {
|
|
1016
|
+
function mergeTheme(baseTheme, customColors = {}, customPreviewColors = {}) {
|
|
966
1017
|
return {
|
|
967
1018
|
...baseTheme,
|
|
968
1019
|
colors: {
|
|
969
1020
|
...baseTheme.colors,
|
|
970
1021
|
...customColors
|
|
1022
|
+
},
|
|
1023
|
+
previewColors: {
|
|
1024
|
+
...baseTheme.previewColors,
|
|
1025
|
+
...customPreviewColors
|
|
971
1026
|
}
|
|
972
1027
|
};
|
|
973
1028
|
}
|
|
@@ -994,7 +1049,7 @@ function generateStyles(options = {}) {
|
|
|
994
1049
|
}
|
|
995
1050
|
}
|
|
996
1051
|
` : "";
|
|
997
|
-
const themeVars = theme && theme.colors ? themeToCSSVars(theme.colors) : "";
|
|
1052
|
+
const themeVars = theme && theme.colors ? themeToCSSVars(theme.colors, theme.previewColors) : "";
|
|
998
1053
|
return `
|
|
999
1054
|
/* OverType Editor Styles */
|
|
1000
1055
|
|
|
@@ -1167,17 +1222,36 @@ function generateStyles(options = {}) {
|
|
|
1167
1222
|
/* Prevent mobile zoom on focus */
|
|
1168
1223
|
touch-action: manipulation !important;
|
|
1169
1224
|
|
|
1170
|
-
/* Disable autofill
|
|
1225
|
+
/* Disable autofill */
|
|
1171
1226
|
autocomplete: off !important;
|
|
1172
1227
|
autocorrect: off !important;
|
|
1173
1228
|
autocapitalize: off !important;
|
|
1174
|
-
spellcheck: false !important;
|
|
1175
1229
|
}
|
|
1176
1230
|
|
|
1177
1231
|
.overtype-wrapper .overtype-input::selection {
|
|
1178
1232
|
background-color: var(--selection, rgba(244, 211, 94, 0.4));
|
|
1179
1233
|
}
|
|
1180
1234
|
|
|
1235
|
+
/* Placeholder shim - visible when textarea is empty */
|
|
1236
|
+
.overtype-wrapper .overtype-placeholder {
|
|
1237
|
+
position: absolute !important;
|
|
1238
|
+
top: 0 !important;
|
|
1239
|
+
left: 0 !important;
|
|
1240
|
+
width: 100% !important;
|
|
1241
|
+
z-index: 0 !important;
|
|
1242
|
+
pointer-events: none !important;
|
|
1243
|
+
user-select: none !important;
|
|
1244
|
+
font-family: ${fontFamily} !important;
|
|
1245
|
+
font-size: var(--instance-font-size, ${fontSize}) !important;
|
|
1246
|
+
line-height: var(--instance-line-height, ${lineHeight}) !important;
|
|
1247
|
+
padding: var(--instance-padding, ${padding}) !important;
|
|
1248
|
+
box-sizing: border-box !important;
|
|
1249
|
+
color: var(--placeholder, #999) !important;
|
|
1250
|
+
overflow: hidden !important;
|
|
1251
|
+
white-space: nowrap !important;
|
|
1252
|
+
text-overflow: ellipsis !important;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1181
1255
|
/* Preview layer styles */
|
|
1182
1256
|
.overtype-wrapper .overtype-preview {
|
|
1183
1257
|
/* Layer positioning */
|
|
@@ -1445,6 +1519,10 @@ function generateStyles(options = {}) {
|
|
|
1445
1519
|
|
|
1446
1520
|
|
|
1447
1521
|
/* Toolbar Styles */
|
|
1522
|
+
.overtype-toolbar.overtype-toolbar-hidden {
|
|
1523
|
+
display: none !important;
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1448
1526
|
.overtype-toolbar {
|
|
1449
1527
|
display: flex !important;
|
|
1450
1528
|
align-items: center !important;
|
|
@@ -1643,27 +1721,29 @@ function generateStyles(options = {}) {
|
|
|
1643
1721
|
}
|
|
1644
1722
|
|
|
1645
1723
|
/* Headers - restore proper sizing in preview mode */
|
|
1646
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1,
|
|
1647
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2,
|
|
1724
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1,
|
|
1725
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2,
|
|
1648
1726
|
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h3 {
|
|
1649
1727
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
|
|
1650
1728
|
font-weight: 600 !important;
|
|
1651
1729
|
margin: 0 !important;
|
|
1652
1730
|
display: block !important;
|
|
1653
|
-
|
|
1654
|
-
line-height: 1 !important; /* Tight line height for headings */
|
|
1731
|
+
line-height: 1 !important;
|
|
1655
1732
|
}
|
|
1656
|
-
|
|
1657
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1 {
|
|
1658
|
-
font-size: 2em !important;
|
|
1733
|
+
|
|
1734
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1 {
|
|
1735
|
+
font-size: 2em !important;
|
|
1736
|
+
color: var(--preview-h1, #222) !important;
|
|
1659
1737
|
}
|
|
1660
|
-
|
|
1661
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2 {
|
|
1662
|
-
font-size: 1.5em !important;
|
|
1738
|
+
|
|
1739
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2 {
|
|
1740
|
+
font-size: 1.5em !important;
|
|
1741
|
+
color: var(--preview-h2, #333) !important;
|
|
1663
1742
|
}
|
|
1664
|
-
|
|
1665
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h3 {
|
|
1666
|
-
font-size: 1.17em !important;
|
|
1743
|
+
|
|
1744
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h3 {
|
|
1745
|
+
font-size: 1.17em !important;
|
|
1746
|
+
color: var(--preview-h3, #444) !important;
|
|
1667
1747
|
}
|
|
1668
1748
|
|
|
1669
1749
|
/* Lists - restore list styling in preview mode */
|
|
@@ -1713,25 +1793,20 @@ function generateStyles(options = {}) {
|
|
|
1713
1793
|
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview a {
|
|
1714
1794
|
pointer-events: auto !important;
|
|
1715
1795
|
cursor: pointer !important;
|
|
1716
|
-
color: var(--link, #0066cc) !important;
|
|
1796
|
+
color: var(--preview-link, #0066cc) !important;
|
|
1717
1797
|
text-decoration: underline !important;
|
|
1718
1798
|
}
|
|
1719
1799
|
|
|
1720
1800
|
/* Code blocks - proper pre/code styling in preview mode */
|
|
1721
1801
|
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview pre.code-block {
|
|
1722
|
-
background:
|
|
1723
|
-
color: #
|
|
1802
|
+
background: var(--preview-code-bg, rgba(135, 131, 120, 0.15)) !important;
|
|
1803
|
+
color: var(--preview-code, #333) !important;
|
|
1724
1804
|
padding: 1.2em !important;
|
|
1725
1805
|
border-radius: 3px !important;
|
|
1726
1806
|
overflow-x: auto !important;
|
|
1727
1807
|
margin: 0 !important;
|
|
1728
1808
|
display: block !important;
|
|
1729
1809
|
}
|
|
1730
|
-
|
|
1731
|
-
/* Cave theme code block background in preview mode */
|
|
1732
|
-
.overtype-container[data-theme="cave"][data-mode="preview"] .overtype-wrapper .overtype-preview pre.code-block {
|
|
1733
|
-
background: #11171F !important;
|
|
1734
|
-
}
|
|
1735
1810
|
|
|
1736
1811
|
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview pre.code-block code {
|
|
1737
1812
|
background: transparent !important;
|
|
@@ -1754,7 +1829,8 @@ function generateStyles(options = {}) {
|
|
|
1754
1829
|
/* Blockquotes - enhanced styling in preview mode */
|
|
1755
1830
|
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .blockquote {
|
|
1756
1831
|
display: block !important;
|
|
1757
|
-
border-left: 4px solid var(--blockquote, #
|
|
1832
|
+
border-left: 4px solid var(--preview-blockquote, #666) !important;
|
|
1833
|
+
color: var(--preview-blockquote, #666) !important;
|
|
1758
1834
|
padding-left: 1em !important;
|
|
1759
1835
|
margin: 1em 0 !important;
|
|
1760
1836
|
font-style: italic !important;
|
|
@@ -1765,14 +1841,16 @@ function generateStyles(options = {}) {
|
|
|
1765
1841
|
font-family: Georgia, 'Times New Roman', serif !important;
|
|
1766
1842
|
font-size: 16px !important;
|
|
1767
1843
|
line-height: 1.8 !important;
|
|
1768
|
-
color: var(--text, #333) !important;
|
|
1844
|
+
color: var(--preview-text, #333) !important;
|
|
1845
|
+
background: var(--preview-bg, transparent) !important;
|
|
1769
1846
|
}
|
|
1770
1847
|
|
|
1771
1848
|
/* Inline code in preview mode - keep monospace */
|
|
1772
1849
|
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview code {
|
|
1773
1850
|
font-family: ${fontFamily} !important;
|
|
1774
1851
|
font-size: 0.9em !important;
|
|
1775
|
-
background: rgba(135, 131, 120, 0.15) !important;
|
|
1852
|
+
background: var(--preview-code-bg, rgba(135, 131, 120, 0.15)) !important;
|
|
1853
|
+
color: var(--preview-code, #333) !important;
|
|
1776
1854
|
padding: 0.2em 0.4em !important;
|
|
1777
1855
|
border-radius: 3px !important;
|
|
1778
1856
|
}
|
|
@@ -1780,32 +1858,33 @@ function generateStyles(options = {}) {
|
|
|
1780
1858
|
/* Strong and em elements in preview mode */
|
|
1781
1859
|
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview strong {
|
|
1782
1860
|
font-weight: 700 !important;
|
|
1783
|
-
color: inherit !important;
|
|
1861
|
+
color: var(--preview-strong, inherit) !important;
|
|
1784
1862
|
}
|
|
1785
1863
|
|
|
1786
1864
|
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview em {
|
|
1787
1865
|
font-style: italic !important;
|
|
1788
|
-
color: inherit !important;
|
|
1866
|
+
color: var(--preview-em, inherit) !important;
|
|
1789
1867
|
}
|
|
1790
1868
|
|
|
1791
1869
|
/* HR in preview mode */
|
|
1792
1870
|
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .hr-marker {
|
|
1793
1871
|
display: block !important;
|
|
1794
|
-
border-top: 2px solid var(--hr, #ddd) !important;
|
|
1872
|
+
border-top: 2px solid var(--preview-hr, #ddd) !important;
|
|
1795
1873
|
text-indent: -9999px !important;
|
|
1796
1874
|
height: 2px !important;
|
|
1797
1875
|
}
|
|
1798
1876
|
|
|
1799
|
-
/* Link Tooltip
|
|
1877
|
+
/* Link Tooltip */
|
|
1800
1878
|
.overtype-link-tooltip {
|
|
1801
|
-
/* Visual styles that work for both positioning methods */
|
|
1802
1879
|
background: #333 !important;
|
|
1803
1880
|
color: white !important;
|
|
1804
1881
|
padding: 6px 10px !important;
|
|
1805
1882
|
border-radius: 16px !important;
|
|
1806
1883
|
font-size: 12px !important;
|
|
1807
1884
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
|
|
1808
|
-
display:
|
|
1885
|
+
display: flex !important;
|
|
1886
|
+
visibility: hidden !important;
|
|
1887
|
+
pointer-events: none !important;
|
|
1809
1888
|
z-index: 10000 !important;
|
|
1810
1889
|
cursor: pointer !important;
|
|
1811
1890
|
box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
|
|
@@ -1813,25 +1892,14 @@ function generateStyles(options = {}) {
|
|
|
1813
1892
|
white-space: nowrap !important;
|
|
1814
1893
|
overflow: hidden !important;
|
|
1815
1894
|
text-overflow: ellipsis !important;
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1895
|
+
position: fixed;
|
|
1896
|
+
top: 0;
|
|
1897
|
+
left: 0;
|
|
1819
1898
|
}
|
|
1820
1899
|
|
|
1821
1900
|
.overtype-link-tooltip.visible {
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
/* CSS Anchor Positioning (modern browsers only) */
|
|
1826
|
-
@supports (position-anchor: --x) and (position-area: center) {
|
|
1827
|
-
.overtype-link-tooltip {
|
|
1828
|
-
/* Only anchor positioning specific properties */
|
|
1829
|
-
position-anchor: var(--target-anchor, --link-0);
|
|
1830
|
-
position-area: block-end center;
|
|
1831
|
-
margin-top: 8px !important;
|
|
1832
|
-
position-try: most-width block-end inline-end, flip-inline, block-start center;
|
|
1833
|
-
position-visibility: anchors-visible;
|
|
1834
|
-
}
|
|
1901
|
+
visibility: visible !important;
|
|
1902
|
+
pointer-events: auto !important;
|
|
1835
1903
|
}
|
|
1836
1904
|
|
|
1837
1905
|
${mobileStyles}
|
|
@@ -2913,6 +2981,16 @@ var Toolbar = class {
|
|
|
2913
2981
|
} catch (error) {
|
|
2914
2982
|
}
|
|
2915
2983
|
}
|
|
2984
|
+
show() {
|
|
2985
|
+
if (this.container) {
|
|
2986
|
+
this.container.classList.remove("overtype-toolbar-hidden");
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
hide() {
|
|
2990
|
+
if (this.container) {
|
|
2991
|
+
this.container.classList.add("overtype-toolbar-hidden");
|
|
2992
|
+
}
|
|
2993
|
+
}
|
|
2916
2994
|
/**
|
|
2917
2995
|
* Destroy toolbar and cleanup
|
|
2918
2996
|
*/
|
|
@@ -2934,6 +3012,1203 @@ var Toolbar = class {
|
|
|
2934
3012
|
}
|
|
2935
3013
|
};
|
|
2936
3014
|
|
|
3015
|
+
// node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
|
|
3016
|
+
var min = Math.min;
|
|
3017
|
+
var max = Math.max;
|
|
3018
|
+
var round = Math.round;
|
|
3019
|
+
var createCoords = (v) => ({
|
|
3020
|
+
x: v,
|
|
3021
|
+
y: v
|
|
3022
|
+
});
|
|
3023
|
+
var oppositeSideMap = {
|
|
3024
|
+
left: "right",
|
|
3025
|
+
right: "left",
|
|
3026
|
+
bottom: "top",
|
|
3027
|
+
top: "bottom"
|
|
3028
|
+
};
|
|
3029
|
+
var oppositeAlignmentMap = {
|
|
3030
|
+
start: "end",
|
|
3031
|
+
end: "start"
|
|
3032
|
+
};
|
|
3033
|
+
function clamp(start, value, end) {
|
|
3034
|
+
return max(start, min(value, end));
|
|
3035
|
+
}
|
|
3036
|
+
function evaluate(value, param) {
|
|
3037
|
+
return typeof value === "function" ? value(param) : value;
|
|
3038
|
+
}
|
|
3039
|
+
function getSide(placement) {
|
|
3040
|
+
return placement.split("-")[0];
|
|
3041
|
+
}
|
|
3042
|
+
function getAlignment(placement) {
|
|
3043
|
+
return placement.split("-")[1];
|
|
3044
|
+
}
|
|
3045
|
+
function getOppositeAxis(axis) {
|
|
3046
|
+
return axis === "x" ? "y" : "x";
|
|
3047
|
+
}
|
|
3048
|
+
function getAxisLength(axis) {
|
|
3049
|
+
return axis === "y" ? "height" : "width";
|
|
3050
|
+
}
|
|
3051
|
+
var yAxisSides = /* @__PURE__ */ new Set(["top", "bottom"]);
|
|
3052
|
+
function getSideAxis(placement) {
|
|
3053
|
+
return yAxisSides.has(getSide(placement)) ? "y" : "x";
|
|
3054
|
+
}
|
|
3055
|
+
function getAlignmentAxis(placement) {
|
|
3056
|
+
return getOppositeAxis(getSideAxis(placement));
|
|
3057
|
+
}
|
|
3058
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
3059
|
+
if (rtl === void 0) {
|
|
3060
|
+
rtl = false;
|
|
3061
|
+
}
|
|
3062
|
+
const alignment = getAlignment(placement);
|
|
3063
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
3064
|
+
const length = getAxisLength(alignmentAxis);
|
|
3065
|
+
let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
|
|
3066
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
3067
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
3068
|
+
}
|
|
3069
|
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
3070
|
+
}
|
|
3071
|
+
function getExpandedPlacements(placement) {
|
|
3072
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
3073
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
3074
|
+
}
|
|
3075
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
3076
|
+
return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
|
|
3077
|
+
}
|
|
3078
|
+
var lrPlacement = ["left", "right"];
|
|
3079
|
+
var rlPlacement = ["right", "left"];
|
|
3080
|
+
var tbPlacement = ["top", "bottom"];
|
|
3081
|
+
var btPlacement = ["bottom", "top"];
|
|
3082
|
+
function getSideList(side, isStart, rtl) {
|
|
3083
|
+
switch (side) {
|
|
3084
|
+
case "top":
|
|
3085
|
+
case "bottom":
|
|
3086
|
+
if (rtl)
|
|
3087
|
+
return isStart ? rlPlacement : lrPlacement;
|
|
3088
|
+
return isStart ? lrPlacement : rlPlacement;
|
|
3089
|
+
case "left":
|
|
3090
|
+
case "right":
|
|
3091
|
+
return isStart ? tbPlacement : btPlacement;
|
|
3092
|
+
default:
|
|
3093
|
+
return [];
|
|
3094
|
+
}
|
|
3095
|
+
}
|
|
3096
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
3097
|
+
const alignment = getAlignment(placement);
|
|
3098
|
+
let list = getSideList(getSide(placement), direction === "start", rtl);
|
|
3099
|
+
if (alignment) {
|
|
3100
|
+
list = list.map((side) => side + "-" + alignment);
|
|
3101
|
+
if (flipAlignment) {
|
|
3102
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
return list;
|
|
3106
|
+
}
|
|
3107
|
+
function getOppositePlacement(placement) {
|
|
3108
|
+
return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
|
|
3109
|
+
}
|
|
3110
|
+
function expandPaddingObject(padding) {
|
|
3111
|
+
return {
|
|
3112
|
+
top: 0,
|
|
3113
|
+
right: 0,
|
|
3114
|
+
bottom: 0,
|
|
3115
|
+
left: 0,
|
|
3116
|
+
...padding
|
|
3117
|
+
};
|
|
3118
|
+
}
|
|
3119
|
+
function getPaddingObject(padding) {
|
|
3120
|
+
return typeof padding !== "number" ? expandPaddingObject(padding) : {
|
|
3121
|
+
top: padding,
|
|
3122
|
+
right: padding,
|
|
3123
|
+
bottom: padding,
|
|
3124
|
+
left: padding
|
|
3125
|
+
};
|
|
3126
|
+
}
|
|
3127
|
+
function rectToClientRect(rect) {
|
|
3128
|
+
const {
|
|
3129
|
+
x,
|
|
3130
|
+
y,
|
|
3131
|
+
width,
|
|
3132
|
+
height
|
|
3133
|
+
} = rect;
|
|
3134
|
+
return {
|
|
3135
|
+
width,
|
|
3136
|
+
height,
|
|
3137
|
+
top: y,
|
|
3138
|
+
left: x,
|
|
3139
|
+
right: x + width,
|
|
3140
|
+
bottom: y + height,
|
|
3141
|
+
x,
|
|
3142
|
+
y
|
|
3143
|
+
};
|
|
3144
|
+
}
|
|
3145
|
+
|
|
3146
|
+
// node_modules/@floating-ui/core/dist/floating-ui.core.mjs
|
|
3147
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
3148
|
+
let {
|
|
3149
|
+
reference,
|
|
3150
|
+
floating
|
|
3151
|
+
} = _ref;
|
|
3152
|
+
const sideAxis = getSideAxis(placement);
|
|
3153
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
3154
|
+
const alignLength = getAxisLength(alignmentAxis);
|
|
3155
|
+
const side = getSide(placement);
|
|
3156
|
+
const isVertical = sideAxis === "y";
|
|
3157
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
3158
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
3159
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
3160
|
+
let coords;
|
|
3161
|
+
switch (side) {
|
|
3162
|
+
case "top":
|
|
3163
|
+
coords = {
|
|
3164
|
+
x: commonX,
|
|
3165
|
+
y: reference.y - floating.height
|
|
3166
|
+
};
|
|
3167
|
+
break;
|
|
3168
|
+
case "bottom":
|
|
3169
|
+
coords = {
|
|
3170
|
+
x: commonX,
|
|
3171
|
+
y: reference.y + reference.height
|
|
3172
|
+
};
|
|
3173
|
+
break;
|
|
3174
|
+
case "right":
|
|
3175
|
+
coords = {
|
|
3176
|
+
x: reference.x + reference.width,
|
|
3177
|
+
y: commonY
|
|
3178
|
+
};
|
|
3179
|
+
break;
|
|
3180
|
+
case "left":
|
|
3181
|
+
coords = {
|
|
3182
|
+
x: reference.x - floating.width,
|
|
3183
|
+
y: commonY
|
|
3184
|
+
};
|
|
3185
|
+
break;
|
|
3186
|
+
default:
|
|
3187
|
+
coords = {
|
|
3188
|
+
x: reference.x,
|
|
3189
|
+
y: reference.y
|
|
3190
|
+
};
|
|
3191
|
+
}
|
|
3192
|
+
switch (getAlignment(placement)) {
|
|
3193
|
+
case "start":
|
|
3194
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
3195
|
+
break;
|
|
3196
|
+
case "end":
|
|
3197
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
3198
|
+
break;
|
|
3199
|
+
}
|
|
3200
|
+
return coords;
|
|
3201
|
+
}
|
|
3202
|
+
async function detectOverflow(state, options) {
|
|
3203
|
+
var _await$platform$isEle;
|
|
3204
|
+
if (options === void 0) {
|
|
3205
|
+
options = {};
|
|
3206
|
+
}
|
|
3207
|
+
const {
|
|
3208
|
+
x,
|
|
3209
|
+
y,
|
|
3210
|
+
platform: platform2,
|
|
3211
|
+
rects,
|
|
3212
|
+
elements,
|
|
3213
|
+
strategy
|
|
3214
|
+
} = state;
|
|
3215
|
+
const {
|
|
3216
|
+
boundary = "clippingAncestors",
|
|
3217
|
+
rootBoundary = "viewport",
|
|
3218
|
+
elementContext = "floating",
|
|
3219
|
+
altBoundary = false,
|
|
3220
|
+
padding = 0
|
|
3221
|
+
} = evaluate(options, state);
|
|
3222
|
+
const paddingObject = getPaddingObject(padding);
|
|
3223
|
+
const altContext = elementContext === "floating" ? "reference" : "floating";
|
|
3224
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
3225
|
+
const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
|
|
3226
|
+
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)),
|
|
3227
|
+
boundary,
|
|
3228
|
+
rootBoundary,
|
|
3229
|
+
strategy
|
|
3230
|
+
}));
|
|
3231
|
+
const rect = elementContext === "floating" ? {
|
|
3232
|
+
x,
|
|
3233
|
+
y,
|
|
3234
|
+
width: rects.floating.width,
|
|
3235
|
+
height: rects.floating.height
|
|
3236
|
+
} : rects.reference;
|
|
3237
|
+
const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
|
|
3238
|
+
const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
|
|
3239
|
+
x: 1,
|
|
3240
|
+
y: 1
|
|
3241
|
+
} : {
|
|
3242
|
+
x: 1,
|
|
3243
|
+
y: 1
|
|
3244
|
+
};
|
|
3245
|
+
const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
3246
|
+
elements,
|
|
3247
|
+
rect,
|
|
3248
|
+
offsetParent,
|
|
3249
|
+
strategy
|
|
3250
|
+
}) : rect);
|
|
3251
|
+
return {
|
|
3252
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
3253
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
3254
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
3255
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
3256
|
+
};
|
|
3257
|
+
}
|
|
3258
|
+
var computePosition = async (reference, floating, config) => {
|
|
3259
|
+
const {
|
|
3260
|
+
placement = "bottom",
|
|
3261
|
+
strategy = "absolute",
|
|
3262
|
+
middleware = [],
|
|
3263
|
+
platform: platform2
|
|
3264
|
+
} = config;
|
|
3265
|
+
const validMiddleware = middleware.filter(Boolean);
|
|
3266
|
+
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
|
|
3267
|
+
let rects = await platform2.getElementRects({
|
|
3268
|
+
reference,
|
|
3269
|
+
floating,
|
|
3270
|
+
strategy
|
|
3271
|
+
});
|
|
3272
|
+
let {
|
|
3273
|
+
x,
|
|
3274
|
+
y
|
|
3275
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
3276
|
+
let statefulPlacement = placement;
|
|
3277
|
+
let middlewareData = {};
|
|
3278
|
+
let resetCount = 0;
|
|
3279
|
+
for (let i = 0; i < validMiddleware.length; i++) {
|
|
3280
|
+
var _platform$detectOverf;
|
|
3281
|
+
const {
|
|
3282
|
+
name,
|
|
3283
|
+
fn
|
|
3284
|
+
} = validMiddleware[i];
|
|
3285
|
+
const {
|
|
3286
|
+
x: nextX,
|
|
3287
|
+
y: nextY,
|
|
3288
|
+
data,
|
|
3289
|
+
reset
|
|
3290
|
+
} = await fn({
|
|
3291
|
+
x,
|
|
3292
|
+
y,
|
|
3293
|
+
initialPlacement: placement,
|
|
3294
|
+
placement: statefulPlacement,
|
|
3295
|
+
strategy,
|
|
3296
|
+
middlewareData,
|
|
3297
|
+
rects,
|
|
3298
|
+
platform: {
|
|
3299
|
+
...platform2,
|
|
3300
|
+
detectOverflow: (_platform$detectOverf = platform2.detectOverflow) != null ? _platform$detectOverf : detectOverflow
|
|
3301
|
+
},
|
|
3302
|
+
elements: {
|
|
3303
|
+
reference,
|
|
3304
|
+
floating
|
|
3305
|
+
}
|
|
3306
|
+
});
|
|
3307
|
+
x = nextX != null ? nextX : x;
|
|
3308
|
+
y = nextY != null ? nextY : y;
|
|
3309
|
+
middlewareData = {
|
|
3310
|
+
...middlewareData,
|
|
3311
|
+
[name]: {
|
|
3312
|
+
...middlewareData[name],
|
|
3313
|
+
...data
|
|
3314
|
+
}
|
|
3315
|
+
};
|
|
3316
|
+
if (reset && resetCount <= 50) {
|
|
3317
|
+
resetCount++;
|
|
3318
|
+
if (typeof reset === "object") {
|
|
3319
|
+
if (reset.placement) {
|
|
3320
|
+
statefulPlacement = reset.placement;
|
|
3321
|
+
}
|
|
3322
|
+
if (reset.rects) {
|
|
3323
|
+
rects = reset.rects === true ? await platform2.getElementRects({
|
|
3324
|
+
reference,
|
|
3325
|
+
floating,
|
|
3326
|
+
strategy
|
|
3327
|
+
}) : reset.rects;
|
|
3328
|
+
}
|
|
3329
|
+
({
|
|
3330
|
+
x,
|
|
3331
|
+
y
|
|
3332
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
3333
|
+
}
|
|
3334
|
+
i = -1;
|
|
3335
|
+
}
|
|
3336
|
+
}
|
|
3337
|
+
return {
|
|
3338
|
+
x,
|
|
3339
|
+
y,
|
|
3340
|
+
placement: statefulPlacement,
|
|
3341
|
+
strategy,
|
|
3342
|
+
middlewareData
|
|
3343
|
+
};
|
|
3344
|
+
};
|
|
3345
|
+
var flip = function(options) {
|
|
3346
|
+
if (options === void 0) {
|
|
3347
|
+
options = {};
|
|
3348
|
+
}
|
|
3349
|
+
return {
|
|
3350
|
+
name: "flip",
|
|
3351
|
+
options,
|
|
3352
|
+
async fn(state) {
|
|
3353
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
3354
|
+
const {
|
|
3355
|
+
placement,
|
|
3356
|
+
middlewareData,
|
|
3357
|
+
rects,
|
|
3358
|
+
initialPlacement,
|
|
3359
|
+
platform: platform2,
|
|
3360
|
+
elements
|
|
3361
|
+
} = state;
|
|
3362
|
+
const {
|
|
3363
|
+
mainAxis: checkMainAxis = true,
|
|
3364
|
+
crossAxis: checkCrossAxis = true,
|
|
3365
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
3366
|
+
fallbackStrategy = "bestFit",
|
|
3367
|
+
fallbackAxisSideDirection = "none",
|
|
3368
|
+
flipAlignment = true,
|
|
3369
|
+
...detectOverflowOptions
|
|
3370
|
+
} = evaluate(options, state);
|
|
3371
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
3372
|
+
return {};
|
|
3373
|
+
}
|
|
3374
|
+
const side = getSide(placement);
|
|
3375
|
+
const initialSideAxis = getSideAxis(initialPlacement);
|
|
3376
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
3377
|
+
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
3378
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
3379
|
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
|
|
3380
|
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
|
3381
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
3382
|
+
}
|
|
3383
|
+
const placements2 = [initialPlacement, ...fallbackPlacements];
|
|
3384
|
+
const overflow = await platform2.detectOverflow(state, detectOverflowOptions);
|
|
3385
|
+
const overflows = [];
|
|
3386
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
3387
|
+
if (checkMainAxis) {
|
|
3388
|
+
overflows.push(overflow[side]);
|
|
3389
|
+
}
|
|
3390
|
+
if (checkCrossAxis) {
|
|
3391
|
+
const sides2 = getAlignmentSides(placement, rects, rtl);
|
|
3392
|
+
overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
|
|
3393
|
+
}
|
|
3394
|
+
overflowsData = [...overflowsData, {
|
|
3395
|
+
placement,
|
|
3396
|
+
overflows
|
|
3397
|
+
}];
|
|
3398
|
+
if (!overflows.every((side2) => side2 <= 0)) {
|
|
3399
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
3400
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
3401
|
+
const nextPlacement = placements2[nextIndex];
|
|
3402
|
+
if (nextPlacement) {
|
|
3403
|
+
const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
|
|
3404
|
+
if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
|
|
3405
|
+
// overflows the main axis.
|
|
3406
|
+
overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
|
|
3407
|
+
return {
|
|
3408
|
+
data: {
|
|
3409
|
+
index: nextIndex,
|
|
3410
|
+
overflows: overflowsData
|
|
3411
|
+
},
|
|
3412
|
+
reset: {
|
|
3413
|
+
placement: nextPlacement
|
|
3414
|
+
}
|
|
3415
|
+
};
|
|
3416
|
+
}
|
|
3417
|
+
}
|
|
3418
|
+
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;
|
|
3419
|
+
if (!resetPlacement) {
|
|
3420
|
+
switch (fallbackStrategy) {
|
|
3421
|
+
case "bestFit": {
|
|
3422
|
+
var _overflowsData$filter2;
|
|
3423
|
+
const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
|
|
3424
|
+
if (hasFallbackAxisSideDirection) {
|
|
3425
|
+
const currentSideAxis = getSideAxis(d.placement);
|
|
3426
|
+
return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
|
|
3427
|
+
// reading directions favoring greater width.
|
|
3428
|
+
currentSideAxis === "y";
|
|
3429
|
+
}
|
|
3430
|
+
return true;
|
|
3431
|
+
}).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];
|
|
3432
|
+
if (placement2) {
|
|
3433
|
+
resetPlacement = placement2;
|
|
3434
|
+
}
|
|
3435
|
+
break;
|
|
3436
|
+
}
|
|
3437
|
+
case "initialPlacement":
|
|
3438
|
+
resetPlacement = initialPlacement;
|
|
3439
|
+
break;
|
|
3440
|
+
}
|
|
3441
|
+
}
|
|
3442
|
+
if (placement !== resetPlacement) {
|
|
3443
|
+
return {
|
|
3444
|
+
reset: {
|
|
3445
|
+
placement: resetPlacement
|
|
3446
|
+
}
|
|
3447
|
+
};
|
|
3448
|
+
}
|
|
3449
|
+
}
|
|
3450
|
+
return {};
|
|
3451
|
+
}
|
|
3452
|
+
};
|
|
3453
|
+
};
|
|
3454
|
+
var originSides = /* @__PURE__ */ new Set(["left", "top"]);
|
|
3455
|
+
async function convertValueToCoords(state, options) {
|
|
3456
|
+
const {
|
|
3457
|
+
placement,
|
|
3458
|
+
platform: platform2,
|
|
3459
|
+
elements
|
|
3460
|
+
} = state;
|
|
3461
|
+
const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
|
|
3462
|
+
const side = getSide(placement);
|
|
3463
|
+
const alignment = getAlignment(placement);
|
|
3464
|
+
const isVertical = getSideAxis(placement) === "y";
|
|
3465
|
+
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
|
3466
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
3467
|
+
const rawValue = evaluate(options, state);
|
|
3468
|
+
let {
|
|
3469
|
+
mainAxis,
|
|
3470
|
+
crossAxis,
|
|
3471
|
+
alignmentAxis
|
|
3472
|
+
} = typeof rawValue === "number" ? {
|
|
3473
|
+
mainAxis: rawValue,
|
|
3474
|
+
crossAxis: 0,
|
|
3475
|
+
alignmentAxis: null
|
|
3476
|
+
} : {
|
|
3477
|
+
mainAxis: rawValue.mainAxis || 0,
|
|
3478
|
+
crossAxis: rawValue.crossAxis || 0,
|
|
3479
|
+
alignmentAxis: rawValue.alignmentAxis
|
|
3480
|
+
};
|
|
3481
|
+
if (alignment && typeof alignmentAxis === "number") {
|
|
3482
|
+
crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
|
|
3483
|
+
}
|
|
3484
|
+
return isVertical ? {
|
|
3485
|
+
x: crossAxis * crossAxisMulti,
|
|
3486
|
+
y: mainAxis * mainAxisMulti
|
|
3487
|
+
} : {
|
|
3488
|
+
x: mainAxis * mainAxisMulti,
|
|
3489
|
+
y: crossAxis * crossAxisMulti
|
|
3490
|
+
};
|
|
3491
|
+
}
|
|
3492
|
+
var offset = function(options) {
|
|
3493
|
+
if (options === void 0) {
|
|
3494
|
+
options = 0;
|
|
3495
|
+
}
|
|
3496
|
+
return {
|
|
3497
|
+
name: "offset",
|
|
3498
|
+
options,
|
|
3499
|
+
async fn(state) {
|
|
3500
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
|
3501
|
+
const {
|
|
3502
|
+
x,
|
|
3503
|
+
y,
|
|
3504
|
+
placement,
|
|
3505
|
+
middlewareData
|
|
3506
|
+
} = state;
|
|
3507
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
3508
|
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
3509
|
+
return {};
|
|
3510
|
+
}
|
|
3511
|
+
return {
|
|
3512
|
+
x: x + diffCoords.x,
|
|
3513
|
+
y: y + diffCoords.y,
|
|
3514
|
+
data: {
|
|
3515
|
+
...diffCoords,
|
|
3516
|
+
placement
|
|
3517
|
+
}
|
|
3518
|
+
};
|
|
3519
|
+
}
|
|
3520
|
+
};
|
|
3521
|
+
};
|
|
3522
|
+
var shift = function(options) {
|
|
3523
|
+
if (options === void 0) {
|
|
3524
|
+
options = {};
|
|
3525
|
+
}
|
|
3526
|
+
return {
|
|
3527
|
+
name: "shift",
|
|
3528
|
+
options,
|
|
3529
|
+
async fn(state) {
|
|
3530
|
+
const {
|
|
3531
|
+
x,
|
|
3532
|
+
y,
|
|
3533
|
+
placement,
|
|
3534
|
+
platform: platform2
|
|
3535
|
+
} = state;
|
|
3536
|
+
const {
|
|
3537
|
+
mainAxis: checkMainAxis = true,
|
|
3538
|
+
crossAxis: checkCrossAxis = false,
|
|
3539
|
+
limiter = {
|
|
3540
|
+
fn: (_ref) => {
|
|
3541
|
+
let {
|
|
3542
|
+
x: x2,
|
|
3543
|
+
y: y2
|
|
3544
|
+
} = _ref;
|
|
3545
|
+
return {
|
|
3546
|
+
x: x2,
|
|
3547
|
+
y: y2
|
|
3548
|
+
};
|
|
3549
|
+
}
|
|
3550
|
+
},
|
|
3551
|
+
...detectOverflowOptions
|
|
3552
|
+
} = evaluate(options, state);
|
|
3553
|
+
const coords = {
|
|
3554
|
+
x,
|
|
3555
|
+
y
|
|
3556
|
+
};
|
|
3557
|
+
const overflow = await platform2.detectOverflow(state, detectOverflowOptions);
|
|
3558
|
+
const crossAxis = getSideAxis(getSide(placement));
|
|
3559
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
3560
|
+
let mainAxisCoord = coords[mainAxis];
|
|
3561
|
+
let crossAxisCoord = coords[crossAxis];
|
|
3562
|
+
if (checkMainAxis) {
|
|
3563
|
+
const minSide = mainAxis === "y" ? "top" : "left";
|
|
3564
|
+
const maxSide = mainAxis === "y" ? "bottom" : "right";
|
|
3565
|
+
const min2 = mainAxisCoord + overflow[minSide];
|
|
3566
|
+
const max2 = mainAxisCoord - overflow[maxSide];
|
|
3567
|
+
mainAxisCoord = clamp(min2, mainAxisCoord, max2);
|
|
3568
|
+
}
|
|
3569
|
+
if (checkCrossAxis) {
|
|
3570
|
+
const minSide = crossAxis === "y" ? "top" : "left";
|
|
3571
|
+
const maxSide = crossAxis === "y" ? "bottom" : "right";
|
|
3572
|
+
const min2 = crossAxisCoord + overflow[minSide];
|
|
3573
|
+
const max2 = crossAxisCoord - overflow[maxSide];
|
|
3574
|
+
crossAxisCoord = clamp(min2, crossAxisCoord, max2);
|
|
3575
|
+
}
|
|
3576
|
+
const limitedCoords = limiter.fn({
|
|
3577
|
+
...state,
|
|
3578
|
+
[mainAxis]: mainAxisCoord,
|
|
3579
|
+
[crossAxis]: crossAxisCoord
|
|
3580
|
+
});
|
|
3581
|
+
return {
|
|
3582
|
+
...limitedCoords,
|
|
3583
|
+
data: {
|
|
3584
|
+
x: limitedCoords.x - x,
|
|
3585
|
+
y: limitedCoords.y - y,
|
|
3586
|
+
enabled: {
|
|
3587
|
+
[mainAxis]: checkMainAxis,
|
|
3588
|
+
[crossAxis]: checkCrossAxis
|
|
3589
|
+
}
|
|
3590
|
+
}
|
|
3591
|
+
};
|
|
3592
|
+
}
|
|
3593
|
+
};
|
|
3594
|
+
};
|
|
3595
|
+
|
|
3596
|
+
// node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
|
|
3597
|
+
function hasWindow() {
|
|
3598
|
+
return typeof window !== "undefined";
|
|
3599
|
+
}
|
|
3600
|
+
function getNodeName(node) {
|
|
3601
|
+
if (isNode(node)) {
|
|
3602
|
+
return (node.nodeName || "").toLowerCase();
|
|
3603
|
+
}
|
|
3604
|
+
return "#document";
|
|
3605
|
+
}
|
|
3606
|
+
function getWindow(node) {
|
|
3607
|
+
var _node$ownerDocument;
|
|
3608
|
+
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
3609
|
+
}
|
|
3610
|
+
function getDocumentElement(node) {
|
|
3611
|
+
var _ref;
|
|
3612
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
3613
|
+
}
|
|
3614
|
+
function isNode(value) {
|
|
3615
|
+
if (!hasWindow()) {
|
|
3616
|
+
return false;
|
|
3617
|
+
}
|
|
3618
|
+
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
3619
|
+
}
|
|
3620
|
+
function isElement(value) {
|
|
3621
|
+
if (!hasWindow()) {
|
|
3622
|
+
return false;
|
|
3623
|
+
}
|
|
3624
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
3625
|
+
}
|
|
3626
|
+
function isHTMLElement(value) {
|
|
3627
|
+
if (!hasWindow()) {
|
|
3628
|
+
return false;
|
|
3629
|
+
}
|
|
3630
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
3631
|
+
}
|
|
3632
|
+
function isShadowRoot(value) {
|
|
3633
|
+
if (!hasWindow() || typeof ShadowRoot === "undefined") {
|
|
3634
|
+
return false;
|
|
3635
|
+
}
|
|
3636
|
+
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
3637
|
+
}
|
|
3638
|
+
var invalidOverflowDisplayValues = /* @__PURE__ */ new Set(["inline", "contents"]);
|
|
3639
|
+
function isOverflowElement(element) {
|
|
3640
|
+
const {
|
|
3641
|
+
overflow,
|
|
3642
|
+
overflowX,
|
|
3643
|
+
overflowY,
|
|
3644
|
+
display
|
|
3645
|
+
} = getComputedStyle2(element);
|
|
3646
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
|
3647
|
+
}
|
|
3648
|
+
var tableElements = /* @__PURE__ */ new Set(["table", "td", "th"]);
|
|
3649
|
+
function isTableElement(element) {
|
|
3650
|
+
return tableElements.has(getNodeName(element));
|
|
3651
|
+
}
|
|
3652
|
+
var topLayerSelectors = [":popover-open", ":modal"];
|
|
3653
|
+
function isTopLayer(element) {
|
|
3654
|
+
return topLayerSelectors.some((selector) => {
|
|
3655
|
+
try {
|
|
3656
|
+
return element.matches(selector);
|
|
3657
|
+
} catch (_e) {
|
|
3658
|
+
return false;
|
|
3659
|
+
}
|
|
3660
|
+
});
|
|
3661
|
+
}
|
|
3662
|
+
var transformProperties = ["transform", "translate", "scale", "rotate", "perspective"];
|
|
3663
|
+
var willChangeValues = ["transform", "translate", "scale", "rotate", "perspective", "filter"];
|
|
3664
|
+
var containValues = ["paint", "layout", "strict", "content"];
|
|
3665
|
+
function isContainingBlock(elementOrCss) {
|
|
3666
|
+
const webkit = isWebKit();
|
|
3667
|
+
const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
|
|
3668
|
+
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));
|
|
3669
|
+
}
|
|
3670
|
+
function getContainingBlock(element) {
|
|
3671
|
+
let currentNode = getParentNode(element);
|
|
3672
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
3673
|
+
if (isContainingBlock(currentNode)) {
|
|
3674
|
+
return currentNode;
|
|
3675
|
+
} else if (isTopLayer(currentNode)) {
|
|
3676
|
+
return null;
|
|
3677
|
+
}
|
|
3678
|
+
currentNode = getParentNode(currentNode);
|
|
3679
|
+
}
|
|
3680
|
+
return null;
|
|
3681
|
+
}
|
|
3682
|
+
function isWebKit() {
|
|
3683
|
+
if (typeof CSS === "undefined" || !CSS.supports)
|
|
3684
|
+
return false;
|
|
3685
|
+
return CSS.supports("-webkit-backdrop-filter", "none");
|
|
3686
|
+
}
|
|
3687
|
+
var lastTraversableNodeNames = /* @__PURE__ */ new Set(["html", "body", "#document"]);
|
|
3688
|
+
function isLastTraversableNode(node) {
|
|
3689
|
+
return lastTraversableNodeNames.has(getNodeName(node));
|
|
3690
|
+
}
|
|
3691
|
+
function getComputedStyle2(element) {
|
|
3692
|
+
return getWindow(element).getComputedStyle(element);
|
|
3693
|
+
}
|
|
3694
|
+
function getNodeScroll(element) {
|
|
3695
|
+
if (isElement(element)) {
|
|
3696
|
+
return {
|
|
3697
|
+
scrollLeft: element.scrollLeft,
|
|
3698
|
+
scrollTop: element.scrollTop
|
|
3699
|
+
};
|
|
3700
|
+
}
|
|
3701
|
+
return {
|
|
3702
|
+
scrollLeft: element.scrollX,
|
|
3703
|
+
scrollTop: element.scrollY
|
|
3704
|
+
};
|
|
3705
|
+
}
|
|
3706
|
+
function getParentNode(node) {
|
|
3707
|
+
if (getNodeName(node) === "html") {
|
|
3708
|
+
return node;
|
|
3709
|
+
}
|
|
3710
|
+
const result = (
|
|
3711
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
3712
|
+
node.assignedSlot || // DOM Element detected.
|
|
3713
|
+
node.parentNode || // ShadowRoot detected.
|
|
3714
|
+
isShadowRoot(node) && node.host || // Fallback.
|
|
3715
|
+
getDocumentElement(node)
|
|
3716
|
+
);
|
|
3717
|
+
return isShadowRoot(result) ? result.host : result;
|
|
3718
|
+
}
|
|
3719
|
+
function getNearestOverflowAncestor(node) {
|
|
3720
|
+
const parentNode = getParentNode(node);
|
|
3721
|
+
if (isLastTraversableNode(parentNode)) {
|
|
3722
|
+
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
3723
|
+
}
|
|
3724
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
3725
|
+
return parentNode;
|
|
3726
|
+
}
|
|
3727
|
+
return getNearestOverflowAncestor(parentNode);
|
|
3728
|
+
}
|
|
3729
|
+
function getOverflowAncestors(node, list, traverseIframes) {
|
|
3730
|
+
var _node$ownerDocument2;
|
|
3731
|
+
if (list === void 0) {
|
|
3732
|
+
list = [];
|
|
3733
|
+
}
|
|
3734
|
+
if (traverseIframes === void 0) {
|
|
3735
|
+
traverseIframes = true;
|
|
3736
|
+
}
|
|
3737
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
3738
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
3739
|
+
const win = getWindow(scrollableAncestor);
|
|
3740
|
+
if (isBody) {
|
|
3741
|
+
const frameElement = getFrameElement(win);
|
|
3742
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
3743
|
+
}
|
|
3744
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
3745
|
+
}
|
|
3746
|
+
function getFrameElement(win) {
|
|
3747
|
+
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
3748
|
+
}
|
|
3749
|
+
|
|
3750
|
+
// node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
|
|
3751
|
+
function getCssDimensions(element) {
|
|
3752
|
+
const css = getComputedStyle2(element);
|
|
3753
|
+
let width = parseFloat(css.width) || 0;
|
|
3754
|
+
let height = parseFloat(css.height) || 0;
|
|
3755
|
+
const hasOffset = isHTMLElement(element);
|
|
3756
|
+
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
3757
|
+
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
3758
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
3759
|
+
if (shouldFallback) {
|
|
3760
|
+
width = offsetWidth;
|
|
3761
|
+
height = offsetHeight;
|
|
3762
|
+
}
|
|
3763
|
+
return {
|
|
3764
|
+
width,
|
|
3765
|
+
height,
|
|
3766
|
+
$: shouldFallback
|
|
3767
|
+
};
|
|
3768
|
+
}
|
|
3769
|
+
function unwrapElement(element) {
|
|
3770
|
+
return !isElement(element) ? element.contextElement : element;
|
|
3771
|
+
}
|
|
3772
|
+
function getScale(element) {
|
|
3773
|
+
const domElement = unwrapElement(element);
|
|
3774
|
+
if (!isHTMLElement(domElement)) {
|
|
3775
|
+
return createCoords(1);
|
|
3776
|
+
}
|
|
3777
|
+
const rect = domElement.getBoundingClientRect();
|
|
3778
|
+
const {
|
|
3779
|
+
width,
|
|
3780
|
+
height,
|
|
3781
|
+
$
|
|
3782
|
+
} = getCssDimensions(domElement);
|
|
3783
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
3784
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
3785
|
+
if (!x || !Number.isFinite(x)) {
|
|
3786
|
+
x = 1;
|
|
3787
|
+
}
|
|
3788
|
+
if (!y || !Number.isFinite(y)) {
|
|
3789
|
+
y = 1;
|
|
3790
|
+
}
|
|
3791
|
+
return {
|
|
3792
|
+
x,
|
|
3793
|
+
y
|
|
3794
|
+
};
|
|
3795
|
+
}
|
|
3796
|
+
var noOffsets = /* @__PURE__ */ createCoords(0);
|
|
3797
|
+
function getVisualOffsets(element) {
|
|
3798
|
+
const win = getWindow(element);
|
|
3799
|
+
if (!isWebKit() || !win.visualViewport) {
|
|
3800
|
+
return noOffsets;
|
|
3801
|
+
}
|
|
3802
|
+
return {
|
|
3803
|
+
x: win.visualViewport.offsetLeft,
|
|
3804
|
+
y: win.visualViewport.offsetTop
|
|
3805
|
+
};
|
|
3806
|
+
}
|
|
3807
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
3808
|
+
if (isFixed === void 0) {
|
|
3809
|
+
isFixed = false;
|
|
3810
|
+
}
|
|
3811
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
3812
|
+
return false;
|
|
3813
|
+
}
|
|
3814
|
+
return isFixed;
|
|
3815
|
+
}
|
|
3816
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
3817
|
+
if (includeScale === void 0) {
|
|
3818
|
+
includeScale = false;
|
|
3819
|
+
}
|
|
3820
|
+
if (isFixedStrategy === void 0) {
|
|
3821
|
+
isFixedStrategy = false;
|
|
3822
|
+
}
|
|
3823
|
+
const clientRect = element.getBoundingClientRect();
|
|
3824
|
+
const domElement = unwrapElement(element);
|
|
3825
|
+
let scale = createCoords(1);
|
|
3826
|
+
if (includeScale) {
|
|
3827
|
+
if (offsetParent) {
|
|
3828
|
+
if (isElement(offsetParent)) {
|
|
3829
|
+
scale = getScale(offsetParent);
|
|
3830
|
+
}
|
|
3831
|
+
} else {
|
|
3832
|
+
scale = getScale(element);
|
|
3833
|
+
}
|
|
3834
|
+
}
|
|
3835
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
3836
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
3837
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
3838
|
+
let width = clientRect.width / scale.x;
|
|
3839
|
+
let height = clientRect.height / scale.y;
|
|
3840
|
+
if (domElement) {
|
|
3841
|
+
const win = getWindow(domElement);
|
|
3842
|
+
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
3843
|
+
let currentWin = win;
|
|
3844
|
+
let currentIFrame = getFrameElement(currentWin);
|
|
3845
|
+
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
3846
|
+
const iframeScale = getScale(currentIFrame);
|
|
3847
|
+
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
3848
|
+
const css = getComputedStyle2(currentIFrame);
|
|
3849
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
3850
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
3851
|
+
x *= iframeScale.x;
|
|
3852
|
+
y *= iframeScale.y;
|
|
3853
|
+
width *= iframeScale.x;
|
|
3854
|
+
height *= iframeScale.y;
|
|
3855
|
+
x += left;
|
|
3856
|
+
y += top;
|
|
3857
|
+
currentWin = getWindow(currentIFrame);
|
|
3858
|
+
currentIFrame = getFrameElement(currentWin);
|
|
3859
|
+
}
|
|
3860
|
+
}
|
|
3861
|
+
return rectToClientRect({
|
|
3862
|
+
width,
|
|
3863
|
+
height,
|
|
3864
|
+
x,
|
|
3865
|
+
y
|
|
3866
|
+
});
|
|
3867
|
+
}
|
|
3868
|
+
function getWindowScrollBarX(element, rect) {
|
|
3869
|
+
const leftScroll = getNodeScroll(element).scrollLeft;
|
|
3870
|
+
if (!rect) {
|
|
3871
|
+
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
|
3872
|
+
}
|
|
3873
|
+
return rect.left + leftScroll;
|
|
3874
|
+
}
|
|
3875
|
+
function getHTMLOffset(documentElement, scroll) {
|
|
3876
|
+
const htmlRect = documentElement.getBoundingClientRect();
|
|
3877
|
+
const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
|
|
3878
|
+
const y = htmlRect.top + scroll.scrollTop;
|
|
3879
|
+
return {
|
|
3880
|
+
x,
|
|
3881
|
+
y
|
|
3882
|
+
};
|
|
3883
|
+
}
|
|
3884
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
3885
|
+
let {
|
|
3886
|
+
elements,
|
|
3887
|
+
rect,
|
|
3888
|
+
offsetParent,
|
|
3889
|
+
strategy
|
|
3890
|
+
} = _ref;
|
|
3891
|
+
const isFixed = strategy === "fixed";
|
|
3892
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
3893
|
+
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
3894
|
+
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
3895
|
+
return rect;
|
|
3896
|
+
}
|
|
3897
|
+
let scroll = {
|
|
3898
|
+
scrollLeft: 0,
|
|
3899
|
+
scrollTop: 0
|
|
3900
|
+
};
|
|
3901
|
+
let scale = createCoords(1);
|
|
3902
|
+
const offsets = createCoords(0);
|
|
3903
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
3904
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
3905
|
+
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
3906
|
+
scroll = getNodeScroll(offsetParent);
|
|
3907
|
+
}
|
|
3908
|
+
if (isHTMLElement(offsetParent)) {
|
|
3909
|
+
const offsetRect = getBoundingClientRect(offsetParent);
|
|
3910
|
+
scale = getScale(offsetParent);
|
|
3911
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
3912
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
3913
|
+
}
|
|
3914
|
+
}
|
|
3915
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
3916
|
+
return {
|
|
3917
|
+
width: rect.width * scale.x,
|
|
3918
|
+
height: rect.height * scale.y,
|
|
3919
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
|
3920
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
|
3921
|
+
};
|
|
3922
|
+
}
|
|
3923
|
+
function getClientRects(element) {
|
|
3924
|
+
return Array.from(element.getClientRects());
|
|
3925
|
+
}
|
|
3926
|
+
function getDocumentRect(element) {
|
|
3927
|
+
const html = getDocumentElement(element);
|
|
3928
|
+
const scroll = getNodeScroll(element);
|
|
3929
|
+
const body = element.ownerDocument.body;
|
|
3930
|
+
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
3931
|
+
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
3932
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
3933
|
+
const y = -scroll.scrollTop;
|
|
3934
|
+
if (getComputedStyle2(body).direction === "rtl") {
|
|
3935
|
+
x += max(html.clientWidth, body.clientWidth) - width;
|
|
3936
|
+
}
|
|
3937
|
+
return {
|
|
3938
|
+
width,
|
|
3939
|
+
height,
|
|
3940
|
+
x,
|
|
3941
|
+
y
|
|
3942
|
+
};
|
|
3943
|
+
}
|
|
3944
|
+
var SCROLLBAR_MAX = 25;
|
|
3945
|
+
function getViewportRect(element, strategy) {
|
|
3946
|
+
const win = getWindow(element);
|
|
3947
|
+
const html = getDocumentElement(element);
|
|
3948
|
+
const visualViewport = win.visualViewport;
|
|
3949
|
+
let width = html.clientWidth;
|
|
3950
|
+
let height = html.clientHeight;
|
|
3951
|
+
let x = 0;
|
|
3952
|
+
let y = 0;
|
|
3953
|
+
if (visualViewport) {
|
|
3954
|
+
width = visualViewport.width;
|
|
3955
|
+
height = visualViewport.height;
|
|
3956
|
+
const visualViewportBased = isWebKit();
|
|
3957
|
+
if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
|
|
3958
|
+
x = visualViewport.offsetLeft;
|
|
3959
|
+
y = visualViewport.offsetTop;
|
|
3960
|
+
}
|
|
3961
|
+
}
|
|
3962
|
+
const windowScrollbarX = getWindowScrollBarX(html);
|
|
3963
|
+
if (windowScrollbarX <= 0) {
|
|
3964
|
+
const doc = html.ownerDocument;
|
|
3965
|
+
const body = doc.body;
|
|
3966
|
+
const bodyStyles = getComputedStyle(body);
|
|
3967
|
+
const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
|
|
3968
|
+
const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
|
|
3969
|
+
if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
|
|
3970
|
+
width -= clippingStableScrollbarWidth;
|
|
3971
|
+
}
|
|
3972
|
+
} else if (windowScrollbarX <= SCROLLBAR_MAX) {
|
|
3973
|
+
width += windowScrollbarX;
|
|
3974
|
+
}
|
|
3975
|
+
return {
|
|
3976
|
+
width,
|
|
3977
|
+
height,
|
|
3978
|
+
x,
|
|
3979
|
+
y
|
|
3980
|
+
};
|
|
3981
|
+
}
|
|
3982
|
+
var absoluteOrFixed = /* @__PURE__ */ new Set(["absolute", "fixed"]);
|
|
3983
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
3984
|
+
const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
|
|
3985
|
+
const top = clientRect.top + element.clientTop;
|
|
3986
|
+
const left = clientRect.left + element.clientLeft;
|
|
3987
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
3988
|
+
const width = element.clientWidth * scale.x;
|
|
3989
|
+
const height = element.clientHeight * scale.y;
|
|
3990
|
+
const x = left * scale.x;
|
|
3991
|
+
const y = top * scale.y;
|
|
3992
|
+
return {
|
|
3993
|
+
width,
|
|
3994
|
+
height,
|
|
3995
|
+
x,
|
|
3996
|
+
y
|
|
3997
|
+
};
|
|
3998
|
+
}
|
|
3999
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
4000
|
+
let rect;
|
|
4001
|
+
if (clippingAncestor === "viewport") {
|
|
4002
|
+
rect = getViewportRect(element, strategy);
|
|
4003
|
+
} else if (clippingAncestor === "document") {
|
|
4004
|
+
rect = getDocumentRect(getDocumentElement(element));
|
|
4005
|
+
} else if (isElement(clippingAncestor)) {
|
|
4006
|
+
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
4007
|
+
} else {
|
|
4008
|
+
const visualOffsets = getVisualOffsets(element);
|
|
4009
|
+
rect = {
|
|
4010
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
4011
|
+
y: clippingAncestor.y - visualOffsets.y,
|
|
4012
|
+
width: clippingAncestor.width,
|
|
4013
|
+
height: clippingAncestor.height
|
|
4014
|
+
};
|
|
4015
|
+
}
|
|
4016
|
+
return rectToClientRect(rect);
|
|
4017
|
+
}
|
|
4018
|
+
function hasFixedPositionAncestor(element, stopNode) {
|
|
4019
|
+
const parentNode = getParentNode(element);
|
|
4020
|
+
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
4021
|
+
return false;
|
|
4022
|
+
}
|
|
4023
|
+
return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
|
|
4024
|
+
}
|
|
4025
|
+
function getClippingElementAncestors(element, cache) {
|
|
4026
|
+
const cachedResult = cache.get(element);
|
|
4027
|
+
if (cachedResult) {
|
|
4028
|
+
return cachedResult;
|
|
4029
|
+
}
|
|
4030
|
+
let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
|
|
4031
|
+
let currentContainingBlockComputedStyle = null;
|
|
4032
|
+
const elementIsFixed = getComputedStyle2(element).position === "fixed";
|
|
4033
|
+
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
4034
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
4035
|
+
const computedStyle = getComputedStyle2(currentNode);
|
|
4036
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
4037
|
+
if (!currentNodeIsContaining && computedStyle.position === "fixed") {
|
|
4038
|
+
currentContainingBlockComputedStyle = null;
|
|
4039
|
+
}
|
|
4040
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
4041
|
+
if (shouldDropCurrentNode) {
|
|
4042
|
+
result = result.filter((ancestor) => ancestor !== currentNode);
|
|
4043
|
+
} else {
|
|
4044
|
+
currentContainingBlockComputedStyle = computedStyle;
|
|
4045
|
+
}
|
|
4046
|
+
currentNode = getParentNode(currentNode);
|
|
4047
|
+
}
|
|
4048
|
+
cache.set(element, result);
|
|
4049
|
+
return result;
|
|
4050
|
+
}
|
|
4051
|
+
function getClippingRect(_ref) {
|
|
4052
|
+
let {
|
|
4053
|
+
element,
|
|
4054
|
+
boundary,
|
|
4055
|
+
rootBoundary,
|
|
4056
|
+
strategy
|
|
4057
|
+
} = _ref;
|
|
4058
|
+
const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
4059
|
+
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
4060
|
+
const firstClippingAncestor = clippingAncestors[0];
|
|
4061
|
+
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
4062
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
4063
|
+
accRect.top = max(rect.top, accRect.top);
|
|
4064
|
+
accRect.right = min(rect.right, accRect.right);
|
|
4065
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
4066
|
+
accRect.left = max(rect.left, accRect.left);
|
|
4067
|
+
return accRect;
|
|
4068
|
+
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
4069
|
+
return {
|
|
4070
|
+
width: clippingRect.right - clippingRect.left,
|
|
4071
|
+
height: clippingRect.bottom - clippingRect.top,
|
|
4072
|
+
x: clippingRect.left,
|
|
4073
|
+
y: clippingRect.top
|
|
4074
|
+
};
|
|
4075
|
+
}
|
|
4076
|
+
function getDimensions(element) {
|
|
4077
|
+
const {
|
|
4078
|
+
width,
|
|
4079
|
+
height
|
|
4080
|
+
} = getCssDimensions(element);
|
|
4081
|
+
return {
|
|
4082
|
+
width,
|
|
4083
|
+
height
|
|
4084
|
+
};
|
|
4085
|
+
}
|
|
4086
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
4087
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
4088
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
4089
|
+
const isFixed = strategy === "fixed";
|
|
4090
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
4091
|
+
let scroll = {
|
|
4092
|
+
scrollLeft: 0,
|
|
4093
|
+
scrollTop: 0
|
|
4094
|
+
};
|
|
4095
|
+
const offsets = createCoords(0);
|
|
4096
|
+
function setLeftRTLScrollbarOffset() {
|
|
4097
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
4098
|
+
}
|
|
4099
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
4100
|
+
if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
4101
|
+
scroll = getNodeScroll(offsetParent);
|
|
4102
|
+
}
|
|
4103
|
+
if (isOffsetParentAnElement) {
|
|
4104
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
4105
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
4106
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
4107
|
+
} else if (documentElement) {
|
|
4108
|
+
setLeftRTLScrollbarOffset();
|
|
4109
|
+
}
|
|
4110
|
+
}
|
|
4111
|
+
if (isFixed && !isOffsetParentAnElement && documentElement) {
|
|
4112
|
+
setLeftRTLScrollbarOffset();
|
|
4113
|
+
}
|
|
4114
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
4115
|
+
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
|
4116
|
+
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
|
4117
|
+
return {
|
|
4118
|
+
x,
|
|
4119
|
+
y,
|
|
4120
|
+
width: rect.width,
|
|
4121
|
+
height: rect.height
|
|
4122
|
+
};
|
|
4123
|
+
}
|
|
4124
|
+
function isStaticPositioned(element) {
|
|
4125
|
+
return getComputedStyle2(element).position === "static";
|
|
4126
|
+
}
|
|
4127
|
+
function getTrueOffsetParent(element, polyfill) {
|
|
4128
|
+
if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
|
|
4129
|
+
return null;
|
|
4130
|
+
}
|
|
4131
|
+
if (polyfill) {
|
|
4132
|
+
return polyfill(element);
|
|
4133
|
+
}
|
|
4134
|
+
let rawOffsetParent = element.offsetParent;
|
|
4135
|
+
if (getDocumentElement(element) === rawOffsetParent) {
|
|
4136
|
+
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
4137
|
+
}
|
|
4138
|
+
return rawOffsetParent;
|
|
4139
|
+
}
|
|
4140
|
+
function getOffsetParent(element, polyfill) {
|
|
4141
|
+
const win = getWindow(element);
|
|
4142
|
+
if (isTopLayer(element)) {
|
|
4143
|
+
return win;
|
|
4144
|
+
}
|
|
4145
|
+
if (!isHTMLElement(element)) {
|
|
4146
|
+
let svgOffsetParent = getParentNode(element);
|
|
4147
|
+
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
4148
|
+
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
|
4149
|
+
return svgOffsetParent;
|
|
4150
|
+
}
|
|
4151
|
+
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
4152
|
+
}
|
|
4153
|
+
return win;
|
|
4154
|
+
}
|
|
4155
|
+
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
4156
|
+
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
|
4157
|
+
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
4158
|
+
}
|
|
4159
|
+
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
|
4160
|
+
return win;
|
|
4161
|
+
}
|
|
4162
|
+
return offsetParent || getContainingBlock(element) || win;
|
|
4163
|
+
}
|
|
4164
|
+
var getElementRects = async function(data) {
|
|
4165
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
4166
|
+
const getDimensionsFn = this.getDimensions;
|
|
4167
|
+
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
4168
|
+
return {
|
|
4169
|
+
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
4170
|
+
floating: {
|
|
4171
|
+
x: 0,
|
|
4172
|
+
y: 0,
|
|
4173
|
+
width: floatingDimensions.width,
|
|
4174
|
+
height: floatingDimensions.height
|
|
4175
|
+
}
|
|
4176
|
+
};
|
|
4177
|
+
};
|
|
4178
|
+
function isRTL(element) {
|
|
4179
|
+
return getComputedStyle2(element).direction === "rtl";
|
|
4180
|
+
}
|
|
4181
|
+
var platform = {
|
|
4182
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
4183
|
+
getDocumentElement,
|
|
4184
|
+
getClippingRect,
|
|
4185
|
+
getOffsetParent,
|
|
4186
|
+
getElementRects,
|
|
4187
|
+
getClientRects,
|
|
4188
|
+
getDimensions,
|
|
4189
|
+
getScale,
|
|
4190
|
+
isElement,
|
|
4191
|
+
isRTL
|
|
4192
|
+
};
|
|
4193
|
+
var offset2 = offset;
|
|
4194
|
+
var shift2 = shift;
|
|
4195
|
+
var flip2 = flip;
|
|
4196
|
+
var computePosition2 = (reference, floating, options) => {
|
|
4197
|
+
const cache = /* @__PURE__ */ new Map();
|
|
4198
|
+
const mergedOptions = {
|
|
4199
|
+
platform,
|
|
4200
|
+
...options
|
|
4201
|
+
};
|
|
4202
|
+
const platformWithCache = {
|
|
4203
|
+
...mergedOptions.platform,
|
|
4204
|
+
_c: cache
|
|
4205
|
+
};
|
|
4206
|
+
return computePosition(reference, floating, {
|
|
4207
|
+
...mergedOptions,
|
|
4208
|
+
platform: platformWithCache
|
|
4209
|
+
});
|
|
4210
|
+
};
|
|
4211
|
+
|
|
2937
4212
|
// src/link-tooltip.js
|
|
2938
4213
|
var LinkTooltip = class {
|
|
2939
4214
|
constructor(editor) {
|
|
@@ -2942,27 +4217,10 @@ var LinkTooltip = class {
|
|
|
2942
4217
|
this.currentLink = null;
|
|
2943
4218
|
this.hideTimeout = null;
|
|
2944
4219
|
this.visibilityChangeHandler = null;
|
|
2945
|
-
this.useFloatingUI = false;
|
|
2946
|
-
this.floatingUI = null;
|
|
2947
4220
|
this.isTooltipHovered = false;
|
|
2948
4221
|
this.init();
|
|
2949
4222
|
}
|
|
2950
|
-
|
|
2951
|
-
const supportsAnchorPositioning = CSS.supports("position-anchor: --x") && CSS.supports("position-area: center");
|
|
2952
|
-
if (!supportsAnchorPositioning) {
|
|
2953
|
-
try {
|
|
2954
|
-
const importFn = new Function("url", "return import(url)");
|
|
2955
|
-
const { computePosition, offset, shift, flip } = await importFn(
|
|
2956
|
-
"https://cdn.jsdelivr.net/npm/@floating-ui/dom@1.7.4/+esm"
|
|
2957
|
-
);
|
|
2958
|
-
this.floatingUI = { computePosition, offset, shift, flip };
|
|
2959
|
-
this.useFloatingUI = true;
|
|
2960
|
-
} catch (error) {
|
|
2961
|
-
console.warn("Failed to load Floating UI fallback:", error);
|
|
2962
|
-
this.floatingUI = null;
|
|
2963
|
-
this.useFloatingUI = false;
|
|
2964
|
-
}
|
|
2965
|
-
}
|
|
4223
|
+
init() {
|
|
2966
4224
|
this.createTooltip();
|
|
2967
4225
|
this.editor.textarea.addEventListener("selectionchange", () => this.checkCursorPosition());
|
|
2968
4226
|
this.editor.textarea.addEventListener("keyup", (e) => {
|
|
@@ -2972,10 +4230,8 @@ var LinkTooltip = class {
|
|
|
2972
4230
|
});
|
|
2973
4231
|
this.editor.textarea.addEventListener("input", () => this.hide());
|
|
2974
4232
|
this.editor.textarea.addEventListener("scroll", () => {
|
|
2975
|
-
if (this.
|
|
2976
|
-
this.
|
|
2977
|
-
} else {
|
|
2978
|
-
this.hide();
|
|
4233
|
+
if (this.currentLink) {
|
|
4234
|
+
this.positionTooltip(this.currentLink);
|
|
2979
4235
|
}
|
|
2980
4236
|
});
|
|
2981
4237
|
this.editor.textarea.addEventListener("blur", () => {
|
|
@@ -3052,22 +4308,17 @@ var LinkTooltip = class {
|
|
|
3052
4308
|
}
|
|
3053
4309
|
return null;
|
|
3054
4310
|
}
|
|
3055
|
-
show(linkInfo) {
|
|
4311
|
+
async show(linkInfo) {
|
|
3056
4312
|
this.currentLink = linkInfo;
|
|
3057
4313
|
this.cancelHide();
|
|
3058
4314
|
const urlSpan = this.tooltip.querySelector(".overtype-link-tooltip-url");
|
|
3059
4315
|
urlSpan.textContent = linkInfo.url;
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
this.showWithAnchorPositioning(linkInfo);
|
|
4316
|
+
await this.positionTooltip(linkInfo);
|
|
4317
|
+
if (this.currentLink === linkInfo) {
|
|
4318
|
+
this.tooltip.classList.add("visible");
|
|
3064
4319
|
}
|
|
3065
|
-
this.tooltip.classList.add("visible");
|
|
3066
|
-
}
|
|
3067
|
-
showWithAnchorPositioning(linkInfo) {
|
|
3068
|
-
this.tooltip.style.setProperty("--target-anchor", `--link-${linkInfo.index}`);
|
|
3069
4320
|
}
|
|
3070
|
-
async
|
|
4321
|
+
async positionTooltip(linkInfo) {
|
|
3071
4322
|
const anchorElement = this.findAnchorElement(linkInfo.index);
|
|
3072
4323
|
if (!anchorElement) {
|
|
3073
4324
|
return;
|
|
@@ -3077,26 +4328,26 @@ var LinkTooltip = class {
|
|
|
3077
4328
|
return;
|
|
3078
4329
|
}
|
|
3079
4330
|
try {
|
|
3080
|
-
const { x, y } = await
|
|
4331
|
+
const { x, y } = await computePosition2(
|
|
3081
4332
|
anchorElement,
|
|
3082
4333
|
this.tooltip,
|
|
3083
4334
|
{
|
|
4335
|
+
strategy: "fixed",
|
|
3084
4336
|
placement: "bottom",
|
|
3085
4337
|
middleware: [
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
4338
|
+
offset2(8),
|
|
4339
|
+
shift2({ padding: 8 }),
|
|
4340
|
+
flip2()
|
|
3089
4341
|
]
|
|
3090
4342
|
}
|
|
3091
4343
|
);
|
|
3092
4344
|
Object.assign(this.tooltip.style, {
|
|
3093
4345
|
left: `${x}px`,
|
|
3094
4346
|
top: `${y}px`,
|
|
3095
|
-
position: "
|
|
4347
|
+
position: "fixed"
|
|
3096
4348
|
});
|
|
3097
4349
|
} catch (error) {
|
|
3098
4350
|
console.warn("Floating UI positioning failed:", error);
|
|
3099
|
-
return;
|
|
3100
4351
|
}
|
|
3101
4352
|
}
|
|
3102
4353
|
findAnchorElement(linkIndex) {
|
|
@@ -3129,8 +4380,6 @@ var LinkTooltip = class {
|
|
|
3129
4380
|
}
|
|
3130
4381
|
this.tooltip = null;
|
|
3131
4382
|
this.currentLink = null;
|
|
3132
|
-
this.floatingUI = null;
|
|
3133
|
-
this.useFloatingUI = false;
|
|
3134
4383
|
this.isTooltipHovered = false;
|
|
3135
4384
|
}
|
|
3136
4385
|
};
|
|
@@ -3193,6 +4442,11 @@ var taskListIcon = `<svg viewBox="0 0 18 18">
|
|
|
3193
4442
|
<rect stroke="currentColor" fill="none" stroke-width="1.5" x="2" y="13" width="3" height="3" rx="0.5"></rect>
|
|
3194
4443
|
<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>
|
|
3195
4444
|
</svg>`;
|
|
4445
|
+
var uploadIcon = `<svg viewBox="0 0 18 18">
|
|
4446
|
+
<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>
|
|
4447
|
+
<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>
|
|
4448
|
+
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 2.25v10.125"></path>
|
|
4449
|
+
</svg>`;
|
|
3196
4450
|
var eyeIcon = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
3197
4451
|
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" fill="none"></path>
|
|
3198
4452
|
<circle cx="12" cy="12" r="3" fill="none"></circle>
|
|
@@ -3316,6 +4570,33 @@ var toolbarButtons = {
|
|
|
3316
4570
|
editor.textarea.dispatchEvent(new Event("input", { bubbles: true }));
|
|
3317
4571
|
}
|
|
3318
4572
|
},
|
|
4573
|
+
upload: {
|
|
4574
|
+
name: "upload",
|
|
4575
|
+
actionId: "uploadFile",
|
|
4576
|
+
icon: uploadIcon,
|
|
4577
|
+
title: "Upload File",
|
|
4578
|
+
action: ({ editor }) => {
|
|
4579
|
+
var _a, _b;
|
|
4580
|
+
if (!((_a = editor.options.fileUpload) == null ? void 0 : _a.enabled))
|
|
4581
|
+
return;
|
|
4582
|
+
const input = document.createElement("input");
|
|
4583
|
+
input.type = "file";
|
|
4584
|
+
input.multiple = true;
|
|
4585
|
+
if (((_b = editor.options.fileUpload.mimeTypes) == null ? void 0 : _b.length) > 0) {
|
|
4586
|
+
input.accept = editor.options.fileUpload.mimeTypes.join(",");
|
|
4587
|
+
}
|
|
4588
|
+
input.onchange = () => {
|
|
4589
|
+
var _a2;
|
|
4590
|
+
if (!((_a2 = input.files) == null ? void 0 : _a2.length))
|
|
4591
|
+
return;
|
|
4592
|
+
const dt = new DataTransfer();
|
|
4593
|
+
for (const f of input.files)
|
|
4594
|
+
dt.items.add(f);
|
|
4595
|
+
editor._handleDataTransfer(dt);
|
|
4596
|
+
};
|
|
4597
|
+
input.click();
|
|
4598
|
+
}
|
|
4599
|
+
},
|
|
3319
4600
|
viewMode: {
|
|
3320
4601
|
name: "viewMode",
|
|
3321
4602
|
icon: eyeIcon,
|
|
@@ -3440,6 +4721,9 @@ var _OverType = class _OverType {
|
|
|
3440
4721
|
} else {
|
|
3441
4722
|
this._buildFromScratch();
|
|
3442
4723
|
}
|
|
4724
|
+
if (this.instanceTheme === "auto") {
|
|
4725
|
+
this.setTheme("auto");
|
|
4726
|
+
}
|
|
3443
4727
|
this.shortcuts = new ShortcutsManager(this);
|
|
3444
4728
|
this._rebuildActionsMap();
|
|
3445
4729
|
this.linkTooltip = new LinkTooltip(this);
|
|
@@ -3497,8 +4781,10 @@ var _OverType = class _OverType {
|
|
|
3497
4781
|
statsFormatter: null,
|
|
3498
4782
|
smartLists: true,
|
|
3499
4783
|
// Enable smart list continuation
|
|
3500
|
-
codeHighlighter: null
|
|
4784
|
+
codeHighlighter: null,
|
|
3501
4785
|
// Per-instance code highlighter
|
|
4786
|
+
spellcheck: false
|
|
4787
|
+
// Browser spellcheck (disabled by default)
|
|
3502
4788
|
};
|
|
3503
4789
|
const { theme, colors, ...cleanOptions } = options;
|
|
3504
4790
|
return {
|
|
@@ -3633,8 +4919,13 @@ var _OverType = class _OverType {
|
|
|
3633
4919
|
this.preview = document.createElement("div");
|
|
3634
4920
|
this.preview.className = "overtype-preview";
|
|
3635
4921
|
this.preview.setAttribute("aria-hidden", "true");
|
|
4922
|
+
this.placeholderEl = document.createElement("div");
|
|
4923
|
+
this.placeholderEl.className = "overtype-placeholder";
|
|
4924
|
+
this.placeholderEl.setAttribute("aria-hidden", "true");
|
|
4925
|
+
this.placeholderEl.textContent = this.options.placeholder;
|
|
3636
4926
|
this.wrapper.appendChild(this.textarea);
|
|
3637
4927
|
this.wrapper.appendChild(this.preview);
|
|
4928
|
+
this.wrapper.appendChild(this.placeholderEl);
|
|
3638
4929
|
this.container.appendChild(this.wrapper);
|
|
3639
4930
|
if (this.options.showStats) {
|
|
3640
4931
|
this.statsBar = document.createElement("div");
|
|
@@ -3657,7 +4948,7 @@ var _OverType = class _OverType {
|
|
|
3657
4948
|
this.textarea.setAttribute("autocomplete", "off");
|
|
3658
4949
|
this.textarea.setAttribute("autocorrect", "off");
|
|
3659
4950
|
this.textarea.setAttribute("autocapitalize", "off");
|
|
3660
|
-
this.textarea.setAttribute("spellcheck",
|
|
4951
|
+
this.textarea.setAttribute("spellcheck", String(this.options.spellcheck));
|
|
3661
4952
|
this.textarea.setAttribute("data-gramm", "false");
|
|
3662
4953
|
this.textarea.setAttribute("data-gramm_editor", "false");
|
|
3663
4954
|
this.textarea.setAttribute("data-enable-grammarly", "false");
|
|
@@ -3667,7 +4958,17 @@ var _OverType = class _OverType {
|
|
|
3667
4958
|
* @private
|
|
3668
4959
|
*/
|
|
3669
4960
|
_createToolbar() {
|
|
3670
|
-
|
|
4961
|
+
var _a;
|
|
4962
|
+
let toolbarButtons2 = this.options.toolbarButtons || defaultToolbarButtons;
|
|
4963
|
+
if (((_a = this.options.fileUpload) == null ? void 0 : _a.enabled) && !toolbarButtons2.some((b) => (b == null ? void 0 : b.name) === "upload")) {
|
|
4964
|
+
const viewModeIdx = toolbarButtons2.findIndex((b) => (b == null ? void 0 : b.name) === "viewMode");
|
|
4965
|
+
if (viewModeIdx !== -1) {
|
|
4966
|
+
toolbarButtons2 = [...toolbarButtons2];
|
|
4967
|
+
toolbarButtons2.splice(viewModeIdx, 0, toolbarButtons.separator, toolbarButtons.upload);
|
|
4968
|
+
} else {
|
|
4969
|
+
toolbarButtons2 = [...toolbarButtons2, toolbarButtons.separator, toolbarButtons.upload];
|
|
4970
|
+
}
|
|
4971
|
+
}
|
|
3671
4972
|
this.toolbar = new Toolbar(this, { toolbarButtons: toolbarButtons2 });
|
|
3672
4973
|
this.toolbar.create();
|
|
3673
4974
|
this._toolbarSelectionListener = () => {
|
|
@@ -3703,10 +5004,14 @@ var _OverType = class _OverType {
|
|
|
3703
5004
|
* @private
|
|
3704
5005
|
*/
|
|
3705
5006
|
_rebuildActionsMap() {
|
|
5007
|
+
var _a;
|
|
3706
5008
|
this.actionsById = buildActionsMap(defaultToolbarButtons);
|
|
3707
5009
|
if (this.options.toolbarButtons) {
|
|
3708
5010
|
Object.assign(this.actionsById, buildActionsMap(this.options.toolbarButtons));
|
|
3709
5011
|
}
|
|
5012
|
+
if ((_a = this.options.fileUpload) == null ? void 0 : _a.enabled) {
|
|
5013
|
+
Object.assign(this.actionsById, buildActionsMap([toolbarButtons.upload]));
|
|
5014
|
+
}
|
|
3710
5015
|
}
|
|
3711
5016
|
/**
|
|
3712
5017
|
* Apply options to the editor
|
|
@@ -3719,6 +5024,8 @@ var _OverType = class _OverType {
|
|
|
3719
5024
|
if (this.options.autoResize) {
|
|
3720
5025
|
if (!this.container.classList.contains("overtype-auto-resize")) {
|
|
3721
5026
|
this._setupAutoResize();
|
|
5027
|
+
} else {
|
|
5028
|
+
this._updateAutoHeight();
|
|
3722
5029
|
}
|
|
3723
5030
|
} else {
|
|
3724
5031
|
this.container.classList.remove("overtype-auto-resize");
|
|
@@ -3730,8 +5037,119 @@ var _OverType = class _OverType {
|
|
|
3730
5037
|
this.toolbar.destroy();
|
|
3731
5038
|
this.toolbar = null;
|
|
3732
5039
|
}
|
|
5040
|
+
if (this.placeholderEl) {
|
|
5041
|
+
this.placeholderEl.textContent = this.options.placeholder;
|
|
5042
|
+
}
|
|
5043
|
+
if (this.options.fileUpload && !this.fileUploadInitialized) {
|
|
5044
|
+
this._initFileUpload();
|
|
5045
|
+
} else if (!this.options.fileUpload && this.fileUploadInitialized) {
|
|
5046
|
+
this._destroyFileUpload();
|
|
5047
|
+
}
|
|
3733
5048
|
this.updatePreview();
|
|
3734
5049
|
}
|
|
5050
|
+
_initFileUpload() {
|
|
5051
|
+
const options = this.options.fileUpload;
|
|
5052
|
+
if (!options || !options.enabled)
|
|
5053
|
+
return;
|
|
5054
|
+
options.maxSize = options.maxSize || 10 * 1024 * 1024;
|
|
5055
|
+
options.mimeTypes = options.mimeTypes || [];
|
|
5056
|
+
options.batch = options.batch || false;
|
|
5057
|
+
if (!options.onInsertFile || typeof options.onInsertFile !== "function") {
|
|
5058
|
+
console.warn("OverType: fileUpload.onInsertFile callback is required for file uploads.");
|
|
5059
|
+
return;
|
|
5060
|
+
}
|
|
5061
|
+
this._fileUploadCounter = 0;
|
|
5062
|
+
this._boundHandleFilePaste = this._handleFilePaste.bind(this);
|
|
5063
|
+
this._boundHandleFileDrop = this._handleFileDrop.bind(this);
|
|
5064
|
+
this._boundHandleDragOver = this._handleDragOver.bind(this);
|
|
5065
|
+
this.textarea.addEventListener("paste", this._boundHandleFilePaste);
|
|
5066
|
+
this.textarea.addEventListener("drop", this._boundHandleFileDrop);
|
|
5067
|
+
this.textarea.addEventListener("dragover", this._boundHandleDragOver);
|
|
5068
|
+
this.fileUploadInitialized = true;
|
|
5069
|
+
}
|
|
5070
|
+
_handleFilePaste(e) {
|
|
5071
|
+
var _a, _b;
|
|
5072
|
+
if (!((_b = (_a = e == null ? void 0 : e.clipboardData) == null ? void 0 : _a.files) == null ? void 0 : _b.length))
|
|
5073
|
+
return;
|
|
5074
|
+
e.preventDefault();
|
|
5075
|
+
this._handleDataTransfer(e.clipboardData);
|
|
5076
|
+
}
|
|
5077
|
+
_handleFileDrop(e) {
|
|
5078
|
+
var _a, _b;
|
|
5079
|
+
if (!((_b = (_a = e == null ? void 0 : e.dataTransfer) == null ? void 0 : _a.files) == null ? void 0 : _b.length))
|
|
5080
|
+
return;
|
|
5081
|
+
e.preventDefault();
|
|
5082
|
+
this._handleDataTransfer(e.dataTransfer);
|
|
5083
|
+
}
|
|
5084
|
+
_handleDataTransfer(dataTransfer) {
|
|
5085
|
+
const files = [];
|
|
5086
|
+
for (const file of dataTransfer.files) {
|
|
5087
|
+
if (file.size > this.options.fileUpload.maxSize)
|
|
5088
|
+
continue;
|
|
5089
|
+
if (this.options.fileUpload.mimeTypes.length > 0 && !this.options.fileUpload.mimeTypes.includes(file.type))
|
|
5090
|
+
continue;
|
|
5091
|
+
const id = ++this._fileUploadCounter;
|
|
5092
|
+
const prefix = file.type.startsWith("image/") ? "!" : "";
|
|
5093
|
+
const placeholder = `${prefix}[Uploading ${file.name} (#${id})...]()`;
|
|
5094
|
+
this.insertAtCursor(`${placeholder}
|
|
5095
|
+
`);
|
|
5096
|
+
if (this.options.fileUpload.batch) {
|
|
5097
|
+
files.push({ file, placeholder });
|
|
5098
|
+
continue;
|
|
5099
|
+
}
|
|
5100
|
+
this.options.fileUpload.onInsertFile(file).then((text) => {
|
|
5101
|
+
this.textarea.value = this.textarea.value.replace(placeholder, text);
|
|
5102
|
+
this.textarea.dispatchEvent(new Event("input", { bubbles: true }));
|
|
5103
|
+
}, (error) => {
|
|
5104
|
+
console.error("OverType: File upload failed", error);
|
|
5105
|
+
this.textarea.value = this.textarea.value.replace(placeholder, "[Upload failed]()");
|
|
5106
|
+
this.textarea.dispatchEvent(new Event("input", { bubbles: true }));
|
|
5107
|
+
});
|
|
5108
|
+
}
|
|
5109
|
+
if (this.options.fileUpload.batch && files.length > 0) {
|
|
5110
|
+
this.options.fileUpload.onInsertFile(files.map((f) => f.file)).then((result) => {
|
|
5111
|
+
const texts = Array.isArray(result) ? result : [result];
|
|
5112
|
+
texts.forEach((text, index) => {
|
|
5113
|
+
this.textarea.value = this.textarea.value.replace(files[index].placeholder, text);
|
|
5114
|
+
});
|
|
5115
|
+
this.textarea.dispatchEvent(new Event("input", { bubbles: true }));
|
|
5116
|
+
}, (error) => {
|
|
5117
|
+
console.error("OverType: File upload failed", error);
|
|
5118
|
+
files.forEach(({ placeholder }) => {
|
|
5119
|
+
this.textarea.value = this.textarea.value.replace(placeholder, "[Upload failed]()");
|
|
5120
|
+
});
|
|
5121
|
+
this.textarea.dispatchEvent(new Event("input", { bubbles: true }));
|
|
5122
|
+
});
|
|
5123
|
+
}
|
|
5124
|
+
}
|
|
5125
|
+
_handleDragOver(e) {
|
|
5126
|
+
e.preventDefault();
|
|
5127
|
+
}
|
|
5128
|
+
_destroyFileUpload() {
|
|
5129
|
+
this.textarea.removeEventListener("paste", this._boundHandleFilePaste);
|
|
5130
|
+
this.textarea.removeEventListener("drop", this._boundHandleFileDrop);
|
|
5131
|
+
this.textarea.removeEventListener("dragover", this._boundHandleDragOver);
|
|
5132
|
+
this._boundHandleFilePaste = null;
|
|
5133
|
+
this._boundHandleFileDrop = null;
|
|
5134
|
+
this._boundHandleDragOver = null;
|
|
5135
|
+
this.fileUploadInitialized = false;
|
|
5136
|
+
}
|
|
5137
|
+
insertAtCursor(text) {
|
|
5138
|
+
const start = this.textarea.selectionStart;
|
|
5139
|
+
const end = this.textarea.selectionEnd;
|
|
5140
|
+
let inserted = false;
|
|
5141
|
+
try {
|
|
5142
|
+
inserted = document.execCommand("insertText", false, text);
|
|
5143
|
+
} catch (_) {
|
|
5144
|
+
}
|
|
5145
|
+
if (!inserted) {
|
|
5146
|
+
const before = this.textarea.value.slice(0, start);
|
|
5147
|
+
const after = this.textarea.value.slice(end);
|
|
5148
|
+
this.textarea.value = before + text + after;
|
|
5149
|
+
this.textarea.setSelectionRange(start + text.length, start + text.length);
|
|
5150
|
+
}
|
|
5151
|
+
this.textarea.dispatchEvent(new Event("input", { bubbles: true }));
|
|
5152
|
+
}
|
|
3735
5153
|
/**
|
|
3736
5154
|
* Update preview with parsed markdown
|
|
3737
5155
|
*/
|
|
@@ -3741,7 +5159,10 @@ var _OverType = class _OverType {
|
|
|
3741
5159
|
const activeLine = this._getCurrentLine(text, cursorPos);
|
|
3742
5160
|
const isPreviewMode = this.container.dataset.mode === "preview";
|
|
3743
5161
|
const html = MarkdownParser.parse(text, activeLine, this.options.showActiveLineRaw, this.options.codeHighlighter, isPreviewMode);
|
|
3744
|
-
this.preview.innerHTML = html
|
|
5162
|
+
this.preview.innerHTML = html;
|
|
5163
|
+
if (this.placeholderEl) {
|
|
5164
|
+
this.placeholderEl.style.display = text ? "none" : "";
|
|
5165
|
+
}
|
|
3745
5166
|
this._applyCodeBlockBackgrounds();
|
|
3746
5167
|
if (this.options.showStats && this.statsBar) {
|
|
3747
5168
|
this._updateStats();
|
|
@@ -3924,7 +5345,7 @@ var _OverType = class _OverType {
|
|
|
3924
5345
|
const cursorPos = this.textarea.selectionStart;
|
|
3925
5346
|
const newValue = MarkdownParser.renumberLists(value);
|
|
3926
5347
|
if (newValue !== value) {
|
|
3927
|
-
let
|
|
5348
|
+
let offset3 = 0;
|
|
3928
5349
|
const oldLines = value.split("\n");
|
|
3929
5350
|
const newLines = newValue.split("\n");
|
|
3930
5351
|
let charCount = 0;
|
|
@@ -3932,13 +5353,13 @@ var _OverType = class _OverType {
|
|
|
3932
5353
|
if (oldLines[i] !== newLines[i]) {
|
|
3933
5354
|
const diff = newLines[i].length - oldLines[i].length;
|
|
3934
5355
|
if (charCount + oldLines[i].length < cursorPos) {
|
|
3935
|
-
|
|
5356
|
+
offset3 += diff;
|
|
3936
5357
|
}
|
|
3937
5358
|
}
|
|
3938
5359
|
charCount += oldLines[i].length + 1;
|
|
3939
5360
|
}
|
|
3940
5361
|
this.textarea.value = newValue;
|
|
3941
|
-
const newCursorPos = cursorPos +
|
|
5362
|
+
const newCursorPos = cursorPos + offset3;
|
|
3942
5363
|
this.textarea.setSelectionRange(newCursorPos, newCursorPos);
|
|
3943
5364
|
this.textarea.dispatchEvent(new Event("input", { bubbles: true }));
|
|
3944
5365
|
}
|
|
@@ -4070,27 +5491,61 @@ var _OverType = class _OverType {
|
|
|
4070
5491
|
this.toolbar = null;
|
|
4071
5492
|
this._createToolbar();
|
|
4072
5493
|
}
|
|
5494
|
+
if (this.fileUploadInitialized) {
|
|
5495
|
+
this._destroyFileUpload();
|
|
5496
|
+
}
|
|
5497
|
+
if (this.options.fileUpload) {
|
|
5498
|
+
this._initFileUpload();
|
|
5499
|
+
}
|
|
4073
5500
|
this._applyOptions();
|
|
4074
5501
|
this.updatePreview();
|
|
4075
5502
|
}
|
|
5503
|
+
showToolbar() {
|
|
5504
|
+
if (this.toolbar) {
|
|
5505
|
+
this.toolbar.show();
|
|
5506
|
+
} else {
|
|
5507
|
+
this._createToolbar();
|
|
5508
|
+
}
|
|
5509
|
+
}
|
|
5510
|
+
hideToolbar() {
|
|
5511
|
+
if (this.toolbar) {
|
|
5512
|
+
this.toolbar.hide();
|
|
5513
|
+
}
|
|
5514
|
+
}
|
|
4076
5515
|
/**
|
|
4077
5516
|
* Set theme for this instance
|
|
4078
5517
|
* @param {string|Object} theme - Theme name or custom theme object
|
|
4079
5518
|
* @returns {this} Returns this for chaining
|
|
4080
5519
|
*/
|
|
4081
5520
|
setTheme(theme) {
|
|
5521
|
+
_OverType._autoInstances.delete(this);
|
|
4082
5522
|
this.instanceTheme = theme;
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
this.
|
|
5523
|
+
if (theme === "auto") {
|
|
5524
|
+
_OverType._autoInstances.add(this);
|
|
5525
|
+
_OverType._startAutoListener();
|
|
5526
|
+
this._applyResolvedTheme(resolveAutoTheme("auto"));
|
|
5527
|
+
} else {
|
|
5528
|
+
const themeObj = typeof theme === "string" ? getTheme(theme) : theme;
|
|
5529
|
+
const themeName = typeof themeObj === "string" ? themeObj : themeObj.name;
|
|
5530
|
+
if (themeName) {
|
|
5531
|
+
this.container.setAttribute("data-theme", themeName);
|
|
5532
|
+
}
|
|
5533
|
+
if (themeObj && themeObj.colors) {
|
|
5534
|
+
const cssVars = themeToCSSVars(themeObj.colors, themeObj.previewColors);
|
|
5535
|
+
this.container.style.cssText += cssVars;
|
|
5536
|
+
}
|
|
5537
|
+
this.updatePreview();
|
|
4087
5538
|
}
|
|
5539
|
+
_OverType._stopAutoListener();
|
|
5540
|
+
return this;
|
|
5541
|
+
}
|
|
5542
|
+
_applyResolvedTheme(themeName) {
|
|
5543
|
+
const themeObj = getTheme(themeName);
|
|
5544
|
+
this.container.setAttribute("data-theme", themeName);
|
|
4088
5545
|
if (themeObj && themeObj.colors) {
|
|
4089
|
-
|
|
4090
|
-
this.container.style.cssText += cssVars;
|
|
5546
|
+
this.container.style.cssText = themeToCSSVars(themeObj.colors, themeObj.previewColors);
|
|
4091
5547
|
}
|
|
4092
5548
|
this.updatePreview();
|
|
4093
|
-
return this;
|
|
4094
5549
|
}
|
|
4095
5550
|
/**
|
|
4096
5551
|
* Set instance-specific code highlighter
|
|
@@ -4244,6 +5699,11 @@ var _OverType = class _OverType {
|
|
|
4244
5699
|
* Destroy the editor instance
|
|
4245
5700
|
*/
|
|
4246
5701
|
destroy() {
|
|
5702
|
+
_OverType._autoInstances.delete(this);
|
|
5703
|
+
_OverType._stopAutoListener();
|
|
5704
|
+
if (this.fileUploadInitialized) {
|
|
5705
|
+
this._destroyFileUpload();
|
|
5706
|
+
}
|
|
4247
5707
|
this.element.overTypeInstance = null;
|
|
4248
5708
|
_OverType.instances.delete(this.element);
|
|
4249
5709
|
if (this.shortcuts) {
|
|
@@ -4286,7 +5746,7 @@ var _OverType = class _OverType {
|
|
|
4286
5746
|
options[key] = _OverType._parseDataValue(attr.value);
|
|
4287
5747
|
}
|
|
4288
5748
|
}
|
|
4289
|
-
return new _OverType(el, options);
|
|
5749
|
+
return new _OverType(el, options)[0];
|
|
4290
5750
|
});
|
|
4291
5751
|
}
|
|
4292
5752
|
/**
|
|
@@ -4349,23 +5809,35 @@ var _OverType = class _OverType {
|
|
|
4349
5809
|
* @param {Object} customColors - Optional color overrides
|
|
4350
5810
|
*/
|
|
4351
5811
|
static setTheme(theme, customColors = null) {
|
|
5812
|
+
_OverType._globalAutoTheme = false;
|
|
5813
|
+
_OverType._globalAutoCustomColors = null;
|
|
5814
|
+
if (theme === "auto") {
|
|
5815
|
+
_OverType._globalAutoTheme = true;
|
|
5816
|
+
_OverType._globalAutoCustomColors = customColors;
|
|
5817
|
+
_OverType._startAutoListener();
|
|
5818
|
+
_OverType._applyGlobalTheme(resolveAutoTheme("auto"), customColors);
|
|
5819
|
+
return;
|
|
5820
|
+
}
|
|
5821
|
+
_OverType._stopAutoListener();
|
|
5822
|
+
_OverType._applyGlobalTheme(theme, customColors);
|
|
5823
|
+
}
|
|
5824
|
+
static _applyGlobalTheme(theme, customColors = null) {
|
|
4352
5825
|
let themeObj = typeof theme === "string" ? getTheme(theme) : theme;
|
|
4353
5826
|
if (customColors) {
|
|
4354
5827
|
themeObj = mergeTheme(themeObj, customColors);
|
|
4355
5828
|
}
|
|
4356
5829
|
_OverType.currentTheme = themeObj;
|
|
4357
5830
|
_OverType.injectStyles(true);
|
|
5831
|
+
const themeName = typeof themeObj === "string" ? themeObj : themeObj.name;
|
|
4358
5832
|
document.querySelectorAll(".overtype-container").forEach((container) => {
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
container.setAttribute("data-theme", themeName2);
|
|
5833
|
+
if (themeName) {
|
|
5834
|
+
container.setAttribute("data-theme", themeName);
|
|
4362
5835
|
}
|
|
4363
5836
|
});
|
|
4364
5837
|
document.querySelectorAll(".overtype-wrapper").forEach((wrapper) => {
|
|
4365
5838
|
if (!wrapper.closest(".overtype-container")) {
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
wrapper.setAttribute("data-theme", themeName2);
|
|
5839
|
+
if (themeName) {
|
|
5840
|
+
wrapper.setAttribute("data-theme", themeName);
|
|
4369
5841
|
}
|
|
4370
5842
|
}
|
|
4371
5843
|
const instance = wrapper._instance;
|
|
@@ -4373,7 +5845,6 @@ var _OverType = class _OverType {
|
|
|
4373
5845
|
instance.updatePreview();
|
|
4374
5846
|
}
|
|
4375
5847
|
});
|
|
4376
|
-
const themeName = typeof themeObj === "string" ? themeObj : themeObj.name;
|
|
4377
5848
|
document.querySelectorAll("overtype-editor").forEach((webComponent) => {
|
|
4378
5849
|
if (themeName && typeof webComponent.setAttribute === "function") {
|
|
4379
5850
|
webComponent.setAttribute("theme", themeName);
|
|
@@ -4383,6 +5854,30 @@ var _OverType = class _OverType {
|
|
|
4383
5854
|
}
|
|
4384
5855
|
});
|
|
4385
5856
|
}
|
|
5857
|
+
static _startAutoListener() {
|
|
5858
|
+
if (_OverType._autoMediaQuery)
|
|
5859
|
+
return;
|
|
5860
|
+
if (!window.matchMedia)
|
|
5861
|
+
return;
|
|
5862
|
+
_OverType._autoMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
5863
|
+
_OverType._autoMediaListener = (e) => {
|
|
5864
|
+
const resolved = e.matches ? "cave" : "solar";
|
|
5865
|
+
if (_OverType._globalAutoTheme) {
|
|
5866
|
+
_OverType._applyGlobalTheme(resolved, _OverType._globalAutoCustomColors);
|
|
5867
|
+
}
|
|
5868
|
+
_OverType._autoInstances.forEach((inst) => inst._applyResolvedTheme(resolved));
|
|
5869
|
+
};
|
|
5870
|
+
_OverType._autoMediaQuery.addEventListener("change", _OverType._autoMediaListener);
|
|
5871
|
+
}
|
|
5872
|
+
static _stopAutoListener() {
|
|
5873
|
+
if (_OverType._autoInstances.size > 0 || _OverType._globalAutoTheme)
|
|
5874
|
+
return;
|
|
5875
|
+
if (!_OverType._autoMediaQuery)
|
|
5876
|
+
return;
|
|
5877
|
+
_OverType._autoMediaQuery.removeEventListener("change", _OverType._autoMediaListener);
|
|
5878
|
+
_OverType._autoMediaQuery = null;
|
|
5879
|
+
_OverType._autoMediaListener = null;
|
|
5880
|
+
}
|
|
4386
5881
|
/**
|
|
4387
5882
|
* Set global code highlighter for all OverType instances
|
|
4388
5883
|
* @param {Function|null} highlighter - Function that takes (code, language) and returns highlighted HTML
|
|
@@ -4484,6 +5979,11 @@ __publicField(_OverType, "instances", /* @__PURE__ */ new WeakMap());
|
|
|
4484
5979
|
__publicField(_OverType, "stylesInjected", false);
|
|
4485
5980
|
__publicField(_OverType, "globalListenersInitialized", false);
|
|
4486
5981
|
__publicField(_OverType, "instanceCount", 0);
|
|
5982
|
+
__publicField(_OverType, "_autoMediaQuery", null);
|
|
5983
|
+
__publicField(_OverType, "_autoMediaListener", null);
|
|
5984
|
+
__publicField(_OverType, "_autoInstances", /* @__PURE__ */ new Set());
|
|
5985
|
+
__publicField(_OverType, "_globalAutoTheme", false);
|
|
5986
|
+
__publicField(_OverType, "_globalAutoCustomColors", null);
|
|
4487
5987
|
var OverType = _OverType;
|
|
4488
5988
|
OverType.MarkdownParser = MarkdownParser;
|
|
4489
5989
|
OverType.ShortcutsManager = ShortcutsManager;
|