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