gdpr audit implemented, email log, vollmachten, pdf delete cancel data privacy and vollmachten, removed message no id card in engergy car, and other contracts that are not telecom contracts, added insert counter for engery
This commit is contained in:
-730
File diff suppressed because one or more lines are too long
+977
File diff suppressed because one or more lines are too long
-1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
Vendored
+2
-2
@@ -5,8 +5,8 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>OpenCRM</title>
|
||||
<script type="module" crossorigin src="/assets/index-AsLwOxex.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-b8RXSgxB.css">
|
||||
<script type="module" crossorigin src="/assets/index-BLUL0czD.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-dzAFnrZs.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
../markdown-it/bin/markdown-it.mjs
|
||||
+748
-4
@@ -295,6 +295,31 @@
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@floating-ui/core": {
|
||||
"version": "1.7.4",
|
||||
"resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.7.4.tgz",
|
||||
"integrity": "sha512-C3HlIdsBxszvm5McXlB8PeOEWfBhcGBTZGkGlWc2U0KFY5IwG5OQEuQ8rq52DZmcHDlPLd+YFBK+cZcytwIFWg==",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"@floating-ui/utils": "^0.2.10"
|
||||
}
|
||||
},
|
||||
"node_modules/@floating-ui/dom": {
|
||||
"version": "1.7.5",
|
||||
"resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.7.5.tgz",
|
||||
"integrity": "sha512-N0bD2kIPInNHUHehXhMke1rBGs1dwqvC9O9KYMyyjK7iXt7GAhnro7UlcuYcGdS/yYOlq0MAVgrow8IbWJwyqg==",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"@floating-ui/core": "^1.7.4",
|
||||
"@floating-ui/utils": "^0.2.10"
|
||||
}
|
||||
},
|
||||
"node_modules/@floating-ui/utils": {
|
||||
"version": "0.2.10",
|
||||
"resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.10.tgz",
|
||||
"integrity": "sha512-aGTxbpbg8/b5JfU1HXSrbH3wXZuLPJcNEcZQFMxLs3oSzgtVu6nFPkbbGGUvBcUjKV2YyB9Wxxabo+HEH9tcRQ==",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/@jridgewell/gen-mapping": {
|
||||
"version": "0.3.13",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
|
||||
@@ -375,6 +400,11 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/@remirror/core-constants": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@remirror/core-constants/-/core-constants-3.0.0.tgz",
|
||||
"integrity": "sha512-42aWfPrimMfDKDi4YegyS7x+/0tlzaqwPQCULLanv3DMIlu96KTJR0fM5isWX2UViOqlGnX6YFgqWepcX+XMNg=="
|
||||
},
|
||||
"node_modules/@remix-run/router": {
|
||||
"version": "1.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.23.2.tgz",
|
||||
@@ -439,6 +469,412 @@
|
||||
"react": "^18 || ^19"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/core": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/core/-/core-3.19.0.tgz",
|
||||
"integrity": "sha512-bpqELwPW+DG8gWiD8iiFtSl4vIBooG5uVJod92Qxn3rA9nFatyXRr4kNbMJmOZ66ezUvmCjXVe/5/G4i5cyzKA==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/pm": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-blockquote": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-blockquote/-/extension-blockquote-3.19.0.tgz",
|
||||
"integrity": "sha512-y3UfqY9KD5XwWz3ndiiJ089Ij2QKeiXy/g1/tlAN/F1AaWsnkHEHMLxCP1BIqmMpwsX7rZjMLN7G5Lp7c9682A==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-bold": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-bold/-/extension-bold-3.19.0.tgz",
|
||||
"integrity": "sha512-UZgb1d0XK4J/JRIZ7jW+s4S6KjuEDT2z1PPM6ugcgofgJkWQvRZelCPbmtSFd3kwsD+zr9UPVgTh9YIuGQ8t+Q==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-bubble-menu": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-bubble-menu/-/extension-bubble-menu-3.19.0.tgz",
|
||||
"integrity": "sha512-klNVIYGCdznhFkrRokzGd6cwzoi8J7E5KbuOfZBwFwhMKZhlz/gJfKmYg9TJopeUhrr2Z9yHgWTk8dh/YIJCdQ==",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"@floating-ui/dom": "^1.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "^3.19.0",
|
||||
"@tiptap/pm": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-bullet-list": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-bullet-list/-/extension-bullet-list-3.19.0.tgz",
|
||||
"integrity": "sha512-F9uNnqd0xkJbMmRxVI5RuVxwB9JaCH/xtRqOUNQZnRBt7IdAElCY+Dvb4hMCtiNv+enGM/RFGJuFHR9TxmI7rw==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/extension-list": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-code": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-code/-/extension-code-3.19.0.tgz",
|
||||
"integrity": "sha512-2kqqQIXBXj2Or+4qeY3WoE7msK+XaHKL6EKOcKlOP2BW8eYqNTPzNSL+PfBDQ3snA7ljZQkTs/j4GYDj90vR1A==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-code-block": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-code-block/-/extension-code-block-3.19.0.tgz",
|
||||
"integrity": "sha512-b/2qR+tMn8MQb+eaFYgVk4qXnLNkkRYmwELQ8LEtEDQPxa5Vl7J3eu8+4OyoIFhZrNDZvvoEp80kHMCP8sI6rg==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "^3.19.0",
|
||||
"@tiptap/pm": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-document": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-document/-/extension-document-3.19.0.tgz",
|
||||
"integrity": "sha512-AOf0kHKSFO0ymjVgYSYDncRXTITdTcrj1tqxVazrmO60KNl1Rc2dAggDvIVTEBy5NvceF0scc7q3sE/5ZtVV7A==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-dropcursor": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-dropcursor/-/extension-dropcursor-3.19.0.tgz",
|
||||
"integrity": "sha512-sf3dEZXiLvsGqVK2maUIzXY6qtYYCvBumag7+VPTMGQ0D4hiZ1X/4ukt4+6VXDg5R2WP1CoIt/QvUetUjWNhbQ==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/extensions": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-floating-menu": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-floating-menu/-/extension-floating-menu-3.19.0.tgz",
|
||||
"integrity": "sha512-JaoEkVRkt+Slq3tySlIsxnMnCjS0L5n1CA1hctjLy0iah8edetj3XD5mVv5iKqDzE+LIjF4nwLRRVKJPc8hFBg==",
|
||||
"optional": true,
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@floating-ui/dom": "^1.0.0",
|
||||
"@tiptap/core": "^3.19.0",
|
||||
"@tiptap/pm": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-gapcursor": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-gapcursor/-/extension-gapcursor-3.19.0.tgz",
|
||||
"integrity": "sha512-w7DACS4oSZaDWjz7gropZHPc9oXqC9yERZTcjWxyORuuIh1JFf0TRYspleK+OK28plK/IftojD/yUDn1MTRhvA==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/extensions": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-hard-break": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-hard-break/-/extension-hard-break-3.19.0.tgz",
|
||||
"integrity": "sha512-lAmQraYhPS5hafvCl74xDB5+bLuNwBKIEsVoim35I0sDJj5nTrfhaZgMJ91VamMvT+6FF5f1dvBlxBxAWa8jew==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-heading": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-heading/-/extension-heading-3.19.0.tgz",
|
||||
"integrity": "sha512-uLpLlfyp086WYNOc0ekm1gIZNlEDfmzOhKzB0Hbyi6jDagTS+p9mxUNYeYOn9jPUxpFov43+Wm/4E24oY6B+TQ==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-horizontal-rule": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-horizontal-rule/-/extension-horizontal-rule-3.19.0.tgz",
|
||||
"integrity": "sha512-iqUHmgMGhMgYGwG6L/4JdelVQ5Mstb4qHcgTGd/4dkcUOepILvhdxajPle7OEdf9sRgjQO6uoAU5BVZVC26+ng==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "^3.19.0",
|
||||
"@tiptap/pm": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-italic": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-italic/-/extension-italic-3.19.0.tgz",
|
||||
"integrity": "sha512-6GffxOnS/tWyCbDkirWNZITiXRta9wrCmrfa4rh+v32wfaOL1RRQNyqo9qN6Wjyl1R42Js+yXTzTTzZsOaLMYA==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-link": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-link/-/extension-link-3.19.0.tgz",
|
||||
"integrity": "sha512-HEGDJnnCPfr7KWu7Dsq+eRRe/mBCsv6DuI+7fhOCLDJjjKzNgrX2abbo/zG3D/4lCVFaVb+qawgJubgqXR/Smw==",
|
||||
"dependencies": {
|
||||
"linkifyjs": "^4.3.2"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "^3.19.0",
|
||||
"@tiptap/pm": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-list": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-list/-/extension-list-3.19.0.tgz",
|
||||
"integrity": "sha512-N6nKbFB2VwMsPlCw67RlAtYSK48TAsAUgjnD+vd3ieSlIufdQnLXDFUP6hFKx9mwoUVUgZGz02RA6bkxOdYyTw==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "^3.19.0",
|
||||
"@tiptap/pm": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-list-item": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-list-item/-/extension-list-item-3.19.0.tgz",
|
||||
"integrity": "sha512-VsSKuJz4/Tb6ZmFkXqWpDYkRzmaLTyE6dNSEpNmUpmZ32sMqo58mt11/huADNwfBFB0Ve7siH/VnFNIJYY3xvg==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/extension-list": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-list-keymap": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-list-keymap/-/extension-list-keymap-3.19.0.tgz",
|
||||
"integrity": "sha512-bxgmAgA3RzBGA0GyTwS2CC1c+QjkJJq9hC+S6PSOWELGRiTbwDN3MANksFXLjntkTa0N5fOnL27vBHtMStURqw==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/extension-list": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-ordered-list": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-ordered-list/-/extension-ordered-list-3.19.0.tgz",
|
||||
"integrity": "sha512-cxGsINquwHYE1kmhAcLNLHAofmoDEG6jbesR5ybl7tU5JwtKVO7S/xZatll2DU1dsDAXWPWEeeMl4e/9svYjCg==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/extension-list": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-paragraph": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-paragraph/-/extension-paragraph-3.19.0.tgz",
|
||||
"integrity": "sha512-xWa6gj82l5+AzdYyrSk9P4ynySaDzg/SlR1FarXE5yPXibYzpS95IWaVR0m2Qaz7Rrk+IiYOTGxGRxcHLOelNg==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-strike": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-strike/-/extension-strike-3.19.0.tgz",
|
||||
"integrity": "sha512-xYpabHsv7PccLUBQaP8AYiFCnYbx6P93RHPd0lgNwhdOjYFd931Zy38RyoxPHAgbYVmhf1iyx7lpuLtBnhS5dA==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-text": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-text/-/extension-text-3.19.0.tgz",
|
||||
"integrity": "sha512-K95+SnbZy0h6hNFtfy23n8t/nOcTFEf69In9TSFVVmwn/Nwlke+IfiESAkqbt1/7sKJeegRXYO7WzFEmFl9Q/g==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-underline": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-underline/-/extension-underline-3.19.0.tgz",
|
||||
"integrity": "sha512-800MGEWfG49j10wQzAFiW/ele1HT04MamcL8iyuPNu7ZbjbGN2yknvdrJlRy7hZlzIrVkZMr/1tz62KN33VHIw==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extensions": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extensions/-/extensions-3.19.0.tgz",
|
||||
"integrity": "sha512-ZmGUhLbMWaGqnJh2Bry+6V4M6gMpUDYo4D1xNux5Gng/E/eYtc+PMxMZ/6F7tNTAuujLBOQKj6D+4SsSm457jw==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "^3.19.0",
|
||||
"@tiptap/pm": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/pm": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/pm/-/pm-3.19.0.tgz",
|
||||
"integrity": "sha512-789zcnM4a8OWzvbD2DL31d0wbSm9BVeO/R7PLQwLIGysDI3qzrcclyZ8yhqOEVuvPitRRwYLq+mY14jz7kY4cw==",
|
||||
"dependencies": {
|
||||
"prosemirror-changeset": "^2.3.0",
|
||||
"prosemirror-collab": "^1.3.1",
|
||||
"prosemirror-commands": "^1.6.2",
|
||||
"prosemirror-dropcursor": "^1.8.1",
|
||||
"prosemirror-gapcursor": "^1.3.2",
|
||||
"prosemirror-history": "^1.4.1",
|
||||
"prosemirror-inputrules": "^1.4.0",
|
||||
"prosemirror-keymap": "^1.2.2",
|
||||
"prosemirror-markdown": "^1.13.1",
|
||||
"prosemirror-menu": "^1.2.4",
|
||||
"prosemirror-model": "^1.24.1",
|
||||
"prosemirror-schema-basic": "^1.2.3",
|
||||
"prosemirror-schema-list": "^1.5.0",
|
||||
"prosemirror-state": "^1.4.3",
|
||||
"prosemirror-tables": "^1.6.4",
|
||||
"prosemirror-trailing-node": "^3.0.0",
|
||||
"prosemirror-transform": "^1.10.2",
|
||||
"prosemirror-view": "^1.38.1"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/react": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/react/-/react-3.19.0.tgz",
|
||||
"integrity": "sha512-GQQMUUXMpNd8tRjc1jDK3tDRXFugJO7C928EqmeBcBzTKDrFIJ3QUoZKEPxUNb6HWhZ2WL7q00fiMzsv4DNSmg==",
|
||||
"dependencies": {
|
||||
"@types/use-sync-external-store": "^0.0.6",
|
||||
"fast-equals": "^5.3.3",
|
||||
"use-sync-external-store": "^1.4.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@tiptap/extension-bubble-menu": "^3.19.0",
|
||||
"@tiptap/extension-floating-menu": "^3.19.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "^3.19.0",
|
||||
"@tiptap/pm": "^3.19.0",
|
||||
"@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
||||
"@types/react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
||||
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
||||
"react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/starter-kit": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/starter-kit/-/starter-kit-3.19.0.tgz",
|
||||
"integrity": "sha512-dTCkHEz+Y8ADxX7h+xvl6caAj+3nII/wMB1rTQchSuNKqJTOrzyUsCWm094+IoZmLT738wANE0fRIgziNHs/ug==",
|
||||
"dependencies": {
|
||||
"@tiptap/core": "^3.19.0",
|
||||
"@tiptap/extension-blockquote": "^3.19.0",
|
||||
"@tiptap/extension-bold": "^3.19.0",
|
||||
"@tiptap/extension-bullet-list": "^3.19.0",
|
||||
"@tiptap/extension-code": "^3.19.0",
|
||||
"@tiptap/extension-code-block": "^3.19.0",
|
||||
"@tiptap/extension-document": "^3.19.0",
|
||||
"@tiptap/extension-dropcursor": "^3.19.0",
|
||||
"@tiptap/extension-gapcursor": "^3.19.0",
|
||||
"@tiptap/extension-hard-break": "^3.19.0",
|
||||
"@tiptap/extension-heading": "^3.19.0",
|
||||
"@tiptap/extension-horizontal-rule": "^3.19.0",
|
||||
"@tiptap/extension-italic": "^3.19.0",
|
||||
"@tiptap/extension-link": "^3.19.0",
|
||||
"@tiptap/extension-list": "^3.19.0",
|
||||
"@tiptap/extension-list-item": "^3.19.0",
|
||||
"@tiptap/extension-list-keymap": "^3.19.0",
|
||||
"@tiptap/extension-ordered-list": "^3.19.0",
|
||||
"@tiptap/extension-paragraph": "^3.19.0",
|
||||
"@tiptap/extension-strike": "^3.19.0",
|
||||
"@tiptap/extension-text": "^3.19.0",
|
||||
"@tiptap/extension-underline": "^3.19.0",
|
||||
"@tiptap/extensions": "^3.19.0",
|
||||
"@tiptap/pm": "^3.19.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/babel__core": {
|
||||
"version": "7.20.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz",
|
||||
@@ -486,17 +922,34 @@
|
||||
"integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/linkify-it": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-5.0.0.tgz",
|
||||
"integrity": "sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q=="
|
||||
},
|
||||
"node_modules/@types/markdown-it": {
|
||||
"version": "14.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-14.1.2.tgz",
|
||||
"integrity": "sha512-promo4eFwuiW+TfGxhi+0x3czqTYJkG8qB17ZUJiVF10Xm7NLVRSLUsfRTU/6h1e24VvRnXCx+hG7li58lkzog==",
|
||||
"dependencies": {
|
||||
"@types/linkify-it": "^5",
|
||||
"@types/mdurl": "^2"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/mdurl": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-2.0.0.tgz",
|
||||
"integrity": "sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg=="
|
||||
},
|
||||
"node_modules/@types/prop-types": {
|
||||
"version": "15.7.15",
|
||||
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.15.tgz",
|
||||
"integrity": "sha512-F6bEyamV9jKGAFBEmlQnesRPGOQqS2+Uwi0Em15xenOxHaf2hv6L8YCVn3rPdPJOiJfPiCnLIRyvwVaqMY3MIw==",
|
||||
"dev": true
|
||||
"integrity": "sha512-F6bEyamV9jKGAFBEmlQnesRPGOQqS2+Uwi0Em15xenOxHaf2hv6L8YCVn3rPdPJOiJfPiCnLIRyvwVaqMY3MIw=="
|
||||
},
|
||||
"node_modules/@types/react": {
|
||||
"version": "18.3.27",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.27.tgz",
|
||||
"integrity": "sha512-cisd7gxkzjBKU2GgdYrTdtQx1SORymWyaAFhaxQPK9bYO9ot3Y5OikQRvY0VYQtvwjeQnizCINJAenh/V7MK2w==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/prop-types": "*",
|
||||
"csstype": "^3.2.2"
|
||||
@@ -506,11 +959,15 @@
|
||||
"version": "18.3.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.3.7.tgz",
|
||||
"integrity": "sha512-MEe3UeoENYVFXzoXEWsvcpg6ZvlrFNlOQ7EOsvhI3CfAXwzPfO8Qwuxd40nepsYKqyyVQnTdEfv68q91yLcKrQ==",
|
||||
"dev": true,
|
||||
"peerDependencies": {
|
||||
"@types/react": "^18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/use-sync-external-store": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.6.tgz",
|
||||
"integrity": "sha512-zFDAD+tlpf2r4asuHEj0XH6pY6i0g5NeAHPn+15wk3BV6JA69eERFXC1gyGThDkVa1zCyKr5jox1+2LbV/AMLg=="
|
||||
},
|
||||
"node_modules/@vitejs/plugin-react": {
|
||||
"version": "4.7.0",
|
||||
"resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-4.7.0.tgz",
|
||||
@@ -556,6 +1013,11 @@
|
||||
"integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/argparse": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
|
||||
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
|
||||
},
|
||||
"node_modules/asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
@@ -776,6 +1238,11 @@
|
||||
"integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/crelt": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.6.tgz",
|
||||
"integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g=="
|
||||
},
|
||||
"node_modules/cssesc": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz",
|
||||
@@ -849,6 +1316,17 @@
|
||||
"integrity": "sha512-0Drusm6MVRXSOJpGbaSVgcQsuB4hEkMpHXaVstcPmhu5LIedxs1xNK/nIxmQIU/RPC0+1/o0AVZfBTkTNJOdUw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/entities": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
|
||||
"integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",
|
||||
"engines": {
|
||||
"node": ">=0.12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/entities?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/es-define-property": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
|
||||
@@ -937,6 +1415,25 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/escape-string-regexp": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
|
||||
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/fast-equals": {
|
||||
"version": "5.4.0",
|
||||
"resolved": "https://registry.npmjs.org/fast-equals/-/fast-equals-5.4.0.tgz",
|
||||
"integrity": "sha512-jt2DW/aNFNwke7AUd+Z+e6pz39KO5rzdbbFCg2sGafS4mk13MI7Z8O5z9cADNn5lhGODIgLwug6TZO2ctf7kcw==",
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/fast-glob": {
|
||||
"version": "3.3.3",
|
||||
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz",
|
||||
@@ -1265,6 +1762,19 @@
|
||||
"integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/linkify-it": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz",
|
||||
"integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==",
|
||||
"dependencies": {
|
||||
"uc.micro": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/linkifyjs": {
|
||||
"version": "4.3.2",
|
||||
"resolved": "https://registry.npmjs.org/linkifyjs/-/linkifyjs-4.3.2.tgz",
|
||||
"integrity": "sha512-NT1CJtq3hHIreOianA8aSXn6Cw0JzYOuDQbOrSPe7gqFnCpKP++MQe3ODgO3oh2GJFORkAAdqredOa60z63GbA=="
|
||||
},
|
||||
"node_modules/loose-envify": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
|
||||
@@ -1293,6 +1803,22 @@
|
||||
"react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0-rc"
|
||||
}
|
||||
},
|
||||
"node_modules/markdown-it": {
|
||||
"version": "14.1.1",
|
||||
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.1.tgz",
|
||||
"integrity": "sha512-BuU2qnTti9YKgK5N+IeMubp14ZUKUUw7yeJbkjtosvHiP0AZ5c8IAgEMk79D0eC8F23r4Ac/q8cAIFdm2FtyoA==",
|
||||
"dependencies": {
|
||||
"argparse": "^2.0.1",
|
||||
"entities": "^4.4.0",
|
||||
"linkify-it": "^5.0.0",
|
||||
"mdurl": "^2.0.0",
|
||||
"punycode.js": "^2.3.1",
|
||||
"uc.micro": "^2.1.0"
|
||||
},
|
||||
"bin": {
|
||||
"markdown-it": "bin/markdown-it.mjs"
|
||||
}
|
||||
},
|
||||
"node_modules/math-intrinsics": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||
@@ -1301,6 +1827,11 @@
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/mdurl": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz",
|
||||
"integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w=="
|
||||
},
|
||||
"node_modules/merge2": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
|
||||
@@ -1410,6 +1941,11 @@
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/orderedmap": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/orderedmap/-/orderedmap-2.1.1.tgz",
|
||||
"integrity": "sha512-TvAWxi0nDe1j/rtMcWcIj94+Ffe6n7zhow33h40SKxmsmozs6dz/e+EajymfoFcHd7sxNn8yHM8839uixMOV6g=="
|
||||
},
|
||||
"node_modules/path-parse": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
|
||||
@@ -1608,11 +2144,196 @@
|
||||
"integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/prosemirror-changeset": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-changeset/-/prosemirror-changeset-2.4.0.tgz",
|
||||
"integrity": "sha512-LvqH2v7Q2SF6yxatuPP2e8vSUKS/L+xAU7dPDC4RMyHMhZoGDfBC74mYuyYF4gLqOEG758wajtyhNnsTkuhvng==",
|
||||
"dependencies": {
|
||||
"prosemirror-transform": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-collab": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-collab/-/prosemirror-collab-1.3.1.tgz",
|
||||
"integrity": "sha512-4SnynYR9TTYaQVXd/ieUvsVV4PDMBzrq2xPUWutHivDuOshZXqQ5rGbZM84HEaXKbLdItse7weMGOUdDVcLKEQ==",
|
||||
"dependencies": {
|
||||
"prosemirror-state": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-commands": {
|
||||
"version": "1.7.1",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-commands/-/prosemirror-commands-1.7.1.tgz",
|
||||
"integrity": "sha512-rT7qZnQtx5c0/y/KlYaGvtG411S97UaL6gdp6RIZ23DLHanMYLyfGBV5DtSnZdthQql7W+lEVbpSfwtO8T+L2w==",
|
||||
"dependencies": {
|
||||
"prosemirror-model": "^1.0.0",
|
||||
"prosemirror-state": "^1.0.0",
|
||||
"prosemirror-transform": "^1.10.2"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-dropcursor": {
|
||||
"version": "1.8.2",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-dropcursor/-/prosemirror-dropcursor-1.8.2.tgz",
|
||||
"integrity": "sha512-CCk6Gyx9+Tt2sbYk5NK0nB1ukHi2ryaRgadV/LvyNuO3ena1payM2z6Cg0vO1ebK8cxbzo41ku2DE5Axj1Zuiw==",
|
||||
"dependencies": {
|
||||
"prosemirror-state": "^1.0.0",
|
||||
"prosemirror-transform": "^1.1.0",
|
||||
"prosemirror-view": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-gapcursor": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-gapcursor/-/prosemirror-gapcursor-1.4.0.tgz",
|
||||
"integrity": "sha512-z00qvurSdCEWUIulij/isHaqu4uLS8r/Fi61IbjdIPJEonQgggbJsLnstW7Lgdk4zQ68/yr6B6bf7sJXowIgdQ==",
|
||||
"dependencies": {
|
||||
"prosemirror-keymap": "^1.0.0",
|
||||
"prosemirror-model": "^1.0.0",
|
||||
"prosemirror-state": "^1.0.0",
|
||||
"prosemirror-view": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-history": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-history/-/prosemirror-history-1.5.0.tgz",
|
||||
"integrity": "sha512-zlzTiH01eKA55UAf1MEjtssJeHnGxO0j4K4Dpx+gnmX9n+SHNlDqI2oO1Kv1iPN5B1dm5fsljCfqKF9nFL6HRg==",
|
||||
"dependencies": {
|
||||
"prosemirror-state": "^1.2.2",
|
||||
"prosemirror-transform": "^1.0.0",
|
||||
"prosemirror-view": "^1.31.0",
|
||||
"rope-sequence": "^1.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-inputrules": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-inputrules/-/prosemirror-inputrules-1.5.1.tgz",
|
||||
"integrity": "sha512-7wj4uMjKaXWAQ1CDgxNzNtR9AlsuwzHfdFH1ygEHA2KHF2DOEaXl1CJfNPAKCg9qNEh4rum975QLaCiQPyY6Fw==",
|
||||
"dependencies": {
|
||||
"prosemirror-state": "^1.0.0",
|
||||
"prosemirror-transform": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-keymap": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-keymap/-/prosemirror-keymap-1.2.3.tgz",
|
||||
"integrity": "sha512-4HucRlpiLd1IPQQXNqeo81BGtkY8Ai5smHhKW9jjPKRc2wQIxksg7Hl1tTI2IfT2B/LgX6bfYvXxEpJl7aKYKw==",
|
||||
"dependencies": {
|
||||
"prosemirror-state": "^1.0.0",
|
||||
"w3c-keyname": "^2.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-markdown": {
|
||||
"version": "1.13.4",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-markdown/-/prosemirror-markdown-1.13.4.tgz",
|
||||
"integrity": "sha512-D98dm4cQ3Hs6EmjK500TdAOew4Z03EV71ajEFiWra3Upr7diytJsjF4mPV2dW+eK5uNectiRj0xFxYI9NLXDbw==",
|
||||
"dependencies": {
|
||||
"@types/markdown-it": "^14.0.0",
|
||||
"markdown-it": "^14.0.0",
|
||||
"prosemirror-model": "^1.25.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-menu": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-menu/-/prosemirror-menu-1.2.5.tgz",
|
||||
"integrity": "sha512-qwXzynnpBIeg1D7BAtjOusR+81xCp53j7iWu/IargiRZqRjGIlQuu1f3jFi+ehrHhWMLoyOQTSRx/IWZJqOYtQ==",
|
||||
"dependencies": {
|
||||
"crelt": "^1.0.0",
|
||||
"prosemirror-commands": "^1.0.0",
|
||||
"prosemirror-history": "^1.0.0",
|
||||
"prosemirror-state": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-model": {
|
||||
"version": "1.25.4",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-model/-/prosemirror-model-1.25.4.tgz",
|
||||
"integrity": "sha512-PIM7E43PBxKce8OQeezAs9j4TP+5yDpZVbuurd1h5phUxEKIu+G2a+EUZzIC5nS1mJktDJWzbqS23n1tsAf5QA==",
|
||||
"dependencies": {
|
||||
"orderedmap": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-schema-basic": {
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-schema-basic/-/prosemirror-schema-basic-1.2.4.tgz",
|
||||
"integrity": "sha512-ELxP4TlX3yr2v5rM7Sb70SqStq5NvI15c0j9j/gjsrO5vaw+fnnpovCLEGIcpeGfifkuqJwl4fon6b+KdrODYQ==",
|
||||
"dependencies": {
|
||||
"prosemirror-model": "^1.25.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-schema-list": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-schema-list/-/prosemirror-schema-list-1.5.1.tgz",
|
||||
"integrity": "sha512-927lFx/uwyQaGwJxLWCZRkjXG0p48KpMj6ueoYiu4JX05GGuGcgzAy62dfiV8eFZftgyBUvLx76RsMe20fJl+Q==",
|
||||
"dependencies": {
|
||||
"prosemirror-model": "^1.0.0",
|
||||
"prosemirror-state": "^1.0.0",
|
||||
"prosemirror-transform": "^1.7.3"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-state": {
|
||||
"version": "1.4.4",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-state/-/prosemirror-state-1.4.4.tgz",
|
||||
"integrity": "sha512-6jiYHH2CIGbCfnxdHbXZ12gySFY/fz/ulZE333G6bPqIZ4F+TXo9ifiR86nAHpWnfoNjOb3o5ESi7J8Uz1jXHw==",
|
||||
"dependencies": {
|
||||
"prosemirror-model": "^1.0.0",
|
||||
"prosemirror-transform": "^1.0.0",
|
||||
"prosemirror-view": "^1.27.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-tables": {
|
||||
"version": "1.8.5",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-tables/-/prosemirror-tables-1.8.5.tgz",
|
||||
"integrity": "sha512-V/0cDCsHKHe/tfWkeCmthNUcEp1IVO3p6vwN8XtwE9PZQLAZJigbw3QoraAdfJPir4NKJtNvOB8oYGKRl+t0Dw==",
|
||||
"dependencies": {
|
||||
"prosemirror-keymap": "^1.2.3",
|
||||
"prosemirror-model": "^1.25.4",
|
||||
"prosemirror-state": "^1.4.4",
|
||||
"prosemirror-transform": "^1.10.5",
|
||||
"prosemirror-view": "^1.41.4"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-trailing-node": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-trailing-node/-/prosemirror-trailing-node-3.0.0.tgz",
|
||||
"integrity": "sha512-xiun5/3q0w5eRnGYfNlW1uU9W6x5MoFKWwq/0TIRgt09lv7Hcser2QYV8t4muXbEr+Fwo0geYn79Xs4GKywrRQ==",
|
||||
"dependencies": {
|
||||
"@remirror/core-constants": "3.0.0",
|
||||
"escape-string-regexp": "^4.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"prosemirror-model": "^1.22.1",
|
||||
"prosemirror-state": "^1.4.2",
|
||||
"prosemirror-view": "^1.33.8"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-transform": {
|
||||
"version": "1.11.0",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.11.0.tgz",
|
||||
"integrity": "sha512-4I7Ce4KpygXb9bkiPS3hTEk4dSHorfRw8uI0pE8IhxlK2GXsqv5tIA7JUSxtSu7u8APVOTtbUBxTmnHIxVkIJw==",
|
||||
"dependencies": {
|
||||
"prosemirror-model": "^1.21.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-view": {
|
||||
"version": "1.41.6",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-view/-/prosemirror-view-1.41.6.tgz",
|
||||
"integrity": "sha512-mxpcDG4hNQa/CPtzxjdlir5bJFDlm0/x5nGBbStB2BWX+XOQ9M8ekEG+ojqB5BcVu2Rc80/jssCMZzSstJuSYg==",
|
||||
"dependencies": {
|
||||
"prosemirror-model": "^1.20.0",
|
||||
"prosemirror-state": "^1.0.0",
|
||||
"prosemirror-transform": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/proxy-from-env": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
|
||||
},
|
||||
"node_modules/punycode.js": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz",
|
||||
"integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/queue-microtask": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
|
||||
@@ -1821,6 +2542,11 @@
|
||||
"fsevents": "~2.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/rope-sequence": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/rope-sequence/-/rope-sequence-1.3.4.tgz",
|
||||
"integrity": "sha512-UT5EDe2cu2E/6O4igUr5PSFs23nvvukicWHx6GnOPlHAiiYbzNuCRQCuiUdHJQcqKalLKlrYJnjY0ySGsXNQXQ=="
|
||||
},
|
||||
"node_modules/run-parallel": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
|
||||
@@ -2038,6 +2764,11 @@
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/uc.micro": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz",
|
||||
"integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A=="
|
||||
},
|
||||
"node_modules/update-browserslist-db": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz",
|
||||
@@ -2068,6 +2799,14 @@
|
||||
"browserslist": ">= 4.21.0"
|
||||
}
|
||||
},
|
||||
"node_modules/use-sync-external-store": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.6.0.tgz",
|
||||
"integrity": "sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w==",
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
@@ -2133,6 +2872,11 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/w3c-keyname": {
|
||||
"version": "2.2.8",
|
||||
"resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz",
|
||||
"integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ=="
|
||||
},
|
||||
"node_modules/yallist": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import {
|
||||
Link,
|
||||
index_default,
|
||||
isAllowedUri,
|
||||
pasteRegex
|
||||
} from "./chunk-MX7X7RGK.js";
|
||||
import "./chunk-YRIELJS7.js";
|
||||
import "./chunk-4MBMRILA.js";
|
||||
export {
|
||||
Link,
|
||||
index_default as default,
|
||||
isAllowedUri,
|
||||
pasteRegex
|
||||
};
|
||||
//# sourceMappingURL=@tiptap_extension-link.js.map
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": [],
|
||||
"sourcesContent": [],
|
||||
"mappings": "",
|
||||
"names": []
|
||||
}
|
||||
+1948
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+3464
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+40
-16
@@ -1,83 +1,107 @@
|
||||
{
|
||||
"hash": "b8db82d9",
|
||||
"hash": "3e94270a",
|
||||
"configHash": "c7be2068",
|
||||
"lockfileHash": "ee9bf28c",
|
||||
"browserHash": "deb47249",
|
||||
"lockfileHash": "c53fe6cb",
|
||||
"browserHash": "ee679691",
|
||||
"optimized": {
|
||||
"react": {
|
||||
"src": "../../react/index.js",
|
||||
"file": "react.js",
|
||||
"fileHash": "304f33a9",
|
||||
"fileHash": "c6967d06",
|
||||
"needsInterop": true
|
||||
},
|
||||
"react-dom": {
|
||||
"src": "../../react-dom/index.js",
|
||||
"file": "react-dom.js",
|
||||
"fileHash": "96d32bc1",
|
||||
"fileHash": "86783379",
|
||||
"needsInterop": true
|
||||
},
|
||||
"react/jsx-dev-runtime": {
|
||||
"src": "../../react/jsx-dev-runtime.js",
|
||||
"file": "react_jsx-dev-runtime.js",
|
||||
"fileHash": "6424b7ea",
|
||||
"fileHash": "d4bbc325",
|
||||
"needsInterop": true
|
||||
},
|
||||
"react/jsx-runtime": {
|
||||
"src": "../../react/jsx-runtime.js",
|
||||
"file": "react_jsx-runtime.js",
|
||||
"fileHash": "af95a7a1",
|
||||
"fileHash": "c4c48fd2",
|
||||
"needsInterop": true
|
||||
},
|
||||
"@tanstack/react-query": {
|
||||
"src": "../../@tanstack/react-query/build/modern/index.js",
|
||||
"file": "@tanstack_react-query.js",
|
||||
"fileHash": "c9459c14",
|
||||
"fileHash": "0ed0cd7e",
|
||||
"needsInterop": false
|
||||
},
|
||||
"axios": {
|
||||
"src": "../../axios/index.js",
|
||||
"file": "axios.js",
|
||||
"fileHash": "032e1913",
|
||||
"fileHash": "b14adf3a",
|
||||
"needsInterop": false
|
||||
},
|
||||
"lucide-react": {
|
||||
"src": "../../lucide-react/dist/esm/lucide-react.js",
|
||||
"file": "lucide-react.js",
|
||||
"fileHash": "341675db",
|
||||
"fileHash": "b370d795",
|
||||
"needsInterop": false
|
||||
},
|
||||
"react-dom/client": {
|
||||
"src": "../../react-dom/client.js",
|
||||
"file": "react-dom_client.js",
|
||||
"fileHash": "6520a32f",
|
||||
"fileHash": "17cccb93",
|
||||
"needsInterop": true
|
||||
},
|
||||
"react-hook-form": {
|
||||
"src": "../../react-hook-form/dist/index.esm.mjs",
|
||||
"file": "react-hook-form.js",
|
||||
"fileHash": "29e58164",
|
||||
"fileHash": "19a01ac0",
|
||||
"needsInterop": false
|
||||
},
|
||||
"react-router-dom": {
|
||||
"src": "../../react-router-dom/dist/index.js",
|
||||
"file": "react-router-dom.js",
|
||||
"fileHash": "4b5d4fdc",
|
||||
"fileHash": "427019e1",
|
||||
"needsInterop": false
|
||||
},
|
||||
"react-hot-toast": {
|
||||
"src": "../../react-hot-toast/dist/index.mjs",
|
||||
"file": "react-hot-toast.js",
|
||||
"fileHash": "7423c32d",
|
||||
"fileHash": "718bd15f",
|
||||
"needsInterop": false
|
||||
},
|
||||
"@tiptap/react": {
|
||||
"src": "../../@tiptap/react/dist/index.js",
|
||||
"file": "@tiptap_react.js",
|
||||
"fileHash": "c3b8784a",
|
||||
"needsInterop": false
|
||||
},
|
||||
"@tiptap/starter-kit": {
|
||||
"src": "../../@tiptap/starter-kit/dist/index.js",
|
||||
"file": "@tiptap_starter-kit.js",
|
||||
"fileHash": "99ec846a",
|
||||
"needsInterop": false
|
||||
},
|
||||
"@tiptap/extension-link": {
|
||||
"src": "../../@tiptap/extension-link/dist/index.js",
|
||||
"file": "@tiptap_extension-link.js",
|
||||
"fileHash": "884cdfc7",
|
||||
"needsInterop": false
|
||||
}
|
||||
},
|
||||
"chunks": {
|
||||
"chunk-S77I6LSE": {
|
||||
"file": "chunk-S77I6LSE.js"
|
||||
"chunk-MX7X7RGK": {
|
||||
"file": "chunk-MX7X7RGK.js"
|
||||
},
|
||||
"chunk-YRIELJS7": {
|
||||
"file": "chunk-YRIELJS7.js"
|
||||
},
|
||||
"chunk-WERSD76P": {
|
||||
"file": "chunk-WERSD76P.js"
|
||||
},
|
||||
"chunk-S77I6LSE": {
|
||||
"file": "chunk-S77I6LSE.js"
|
||||
},
|
||||
"chunk-3TFVT2CW": {
|
||||
"file": "chunk-3TFVT2CW.js"
|
||||
},
|
||||
|
||||
+1611
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+18528
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+20
@@ -0,0 +1,20 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021-present Floating UI contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
# @floating-ui/core
|
||||
|
||||
This is the platform-agnostic core of Floating UI, exposing the main
|
||||
`computePosition` function but no platform interface logic.
|
||||
+1
File diff suppressed because one or more lines are too long
+1184
File diff suppressed because it is too large
Load Diff
+531
@@ -0,0 +1,531 @@
|
||||
import { AlignedPlacement } from '@floating-ui/utils';
|
||||
import { Alignment } from '@floating-ui/utils';
|
||||
import { Axis } from '@floating-ui/utils';
|
||||
import { ClientRectObject } from '@floating-ui/utils';
|
||||
import { Coords } from '@floating-ui/utils';
|
||||
import { Dimensions } from '@floating-ui/utils';
|
||||
import { ElementRects } from '@floating-ui/utils';
|
||||
import { Length } from '@floating-ui/utils';
|
||||
import { Padding } from '@floating-ui/utils';
|
||||
import { Placement } from '@floating-ui/utils';
|
||||
import { Rect } from '@floating-ui/utils';
|
||||
import { rectToClientRect } from '@floating-ui/utils';
|
||||
import { Side } from '@floating-ui/utils';
|
||||
import { SideObject } from '@floating-ui/utils';
|
||||
import { Strategy } from '@floating-ui/utils';
|
||||
import { VirtualElement } from '@floating-ui/utils';
|
||||
|
||||
export { AlignedPlacement }
|
||||
|
||||
export { Alignment }
|
||||
|
||||
/**
|
||||
* Provides data to position an inner element of the floating element so that it
|
||||
* appears centered to the reference element.
|
||||
* @see https://floating-ui.com/docs/arrow
|
||||
*/
|
||||
export declare const arrow: (options: ArrowOptions | Derivable<ArrowOptions>) => Middleware;
|
||||
|
||||
export declare interface ArrowOptions {
|
||||
/**
|
||||
* The arrow element to be positioned.
|
||||
* @default undefined
|
||||
*/
|
||||
element: any;
|
||||
/**
|
||||
* The padding between the arrow element and the floating element edges.
|
||||
* Useful when the floating element has rounded corners.
|
||||
* @default 0
|
||||
*/
|
||||
padding?: Padding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by choosing the placement
|
||||
* that has the most space available automatically, without needing to specify a
|
||||
* preferred placement. Alternative to `flip`.
|
||||
* @see https://floating-ui.com/docs/autoPlacement
|
||||
*/
|
||||
export declare const autoPlacement: (options?: AutoPlacementOptions | Derivable<AutoPlacementOptions>) => Middleware;
|
||||
|
||||
export declare interface AutoPlacementOptions extends DetectOverflowOptions {
|
||||
/**
|
||||
* The axis that runs along the alignment of the floating element. Determines
|
||||
* whether to check for most space along this axis.
|
||||
* @default false
|
||||
*/
|
||||
crossAxis?: boolean;
|
||||
/**
|
||||
* Choose placements with a particular alignment.
|
||||
* @default undefined
|
||||
*/
|
||||
alignment?: Alignment | null;
|
||||
/**
|
||||
* Whether to choose placements with the opposite alignment if the preferred
|
||||
* alignment does not fit.
|
||||
* @default true
|
||||
*/
|
||||
autoAlignment?: boolean;
|
||||
/**
|
||||
* Which placements are allowed to be chosen. Placements must be within the
|
||||
* `alignment` option if explicitly set.
|
||||
* @default allPlacements (variable)
|
||||
*/
|
||||
allowedPlacements?: Array<Placement>;
|
||||
}
|
||||
|
||||
export { Axis }
|
||||
|
||||
export declare type Boundary = any;
|
||||
|
||||
export { ClientRectObject }
|
||||
|
||||
export declare type ComputePosition = (reference: unknown, floating: unknown, config: ComputePositionConfig) => Promise<ComputePositionReturn>;
|
||||
|
||||
/**
|
||||
* Computes the `x` and `y` coordinates that will place the floating element
|
||||
* next to a given reference element.
|
||||
*
|
||||
* This export does not have any `platform` interface logic. You will need to
|
||||
* write one for the platform you are using Floating UI with.
|
||||
*/
|
||||
export declare const computePosition: ComputePosition;
|
||||
|
||||
export declare interface ComputePositionConfig {
|
||||
/**
|
||||
* Object to interface with the current platform.
|
||||
*/
|
||||
platform: Platform;
|
||||
/**
|
||||
* Where to place the floating element relative to the reference element.
|
||||
*/
|
||||
placement?: Placement;
|
||||
/**
|
||||
* The strategy to use when positioning the floating element.
|
||||
*/
|
||||
strategy?: Strategy;
|
||||
/**
|
||||
* Array of middleware objects to modify the positioning or provide data for
|
||||
* rendering.
|
||||
*/
|
||||
middleware?: Array<Middleware | null | undefined | false>;
|
||||
}
|
||||
|
||||
export declare interface ComputePositionReturn extends Coords {
|
||||
/**
|
||||
* The final chosen placement of the floating element.
|
||||
*/
|
||||
placement: Placement;
|
||||
/**
|
||||
* The strategy used to position the floating element.
|
||||
*/
|
||||
strategy: Strategy;
|
||||
/**
|
||||
* Object containing data returned from all middleware, keyed by their name.
|
||||
*/
|
||||
middlewareData: MiddlewareData;
|
||||
}
|
||||
|
||||
export { Coords }
|
||||
|
||||
/**
|
||||
* Function option to derive middleware options from state.
|
||||
*/
|
||||
export declare type Derivable<T> = (state: MiddlewareState) => T;
|
||||
|
||||
/**
|
||||
* Resolves with an object of overflow side offsets that determine how much the
|
||||
* element is overflowing a given clipping boundary on each side.
|
||||
* - positive = overflowing the boundary by that number of pixels
|
||||
* - negative = how many pixels left before it will overflow
|
||||
* - 0 = lies flush with the boundary
|
||||
* @see https://floating-ui.com/docs/detectOverflow
|
||||
*/
|
||||
export declare function detectOverflow(state: MiddlewareState, options?: DetectOverflowOptions | Derivable<DetectOverflowOptions>): Promise<SideObject>;
|
||||
|
||||
export declare interface DetectOverflowOptions {
|
||||
/**
|
||||
* The clipping element(s) or area in which overflow will be checked.
|
||||
* @default 'clippingAncestors'
|
||||
*/
|
||||
boundary?: Boundary;
|
||||
/**
|
||||
* The root clipping area in which overflow will be checked.
|
||||
* @default 'viewport'
|
||||
*/
|
||||
rootBoundary?: RootBoundary;
|
||||
/**
|
||||
* The element in which overflow is being checked relative to a boundary.
|
||||
* @default 'floating'
|
||||
*/
|
||||
elementContext?: ElementContext;
|
||||
/**
|
||||
* Whether to check for overflow using the alternate element's boundary
|
||||
* (`clippingAncestors` boundary only).
|
||||
* @default false
|
||||
*/
|
||||
altBoundary?: boolean;
|
||||
/**
|
||||
* Virtual padding for the resolved overflow detection offsets.
|
||||
* @default 0
|
||||
*/
|
||||
padding?: Padding;
|
||||
}
|
||||
|
||||
export { Dimensions }
|
||||
|
||||
export declare type ElementContext = 'reference' | 'floating';
|
||||
|
||||
export { ElementRects }
|
||||
|
||||
export declare interface Elements {
|
||||
reference: ReferenceElement;
|
||||
floating: FloatingElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by flipping the `placement`
|
||||
* in order to keep it in view when the preferred placement(s) will overflow the
|
||||
* clipping boundary. Alternative to `autoPlacement`.
|
||||
* @see https://floating-ui.com/docs/flip
|
||||
*/
|
||||
export declare const flip: (options?: FlipOptions | Derivable<FlipOptions>) => Middleware;
|
||||
|
||||
export declare interface FlipOptions extends DetectOverflowOptions {
|
||||
/**
|
||||
* The axis that runs along the side of the floating element. Determines
|
||||
* whether overflow along this axis is checked to perform a flip.
|
||||
* @default true
|
||||
*/
|
||||
mainAxis?: boolean;
|
||||
/**
|
||||
* The axis that runs along the alignment of the floating element. Determines
|
||||
* whether overflow along this axis is checked to perform a flip.
|
||||
* - `true`: Whether to check cross axis overflow for both side and alignment flipping.
|
||||
* - `false`: Whether to disable all cross axis overflow checking.
|
||||
* - `'alignment'`: Whether to check cross axis overflow for alignment flipping only.
|
||||
* @default true
|
||||
*/
|
||||
crossAxis?: boolean | 'alignment';
|
||||
/**
|
||||
* Placements to try sequentially if the preferred `placement` does not fit.
|
||||
* @default [oppositePlacement] (computed)
|
||||
*/
|
||||
fallbackPlacements?: Array<Placement>;
|
||||
/**
|
||||
* What strategy to use when no placements fit.
|
||||
* @default 'bestFit'
|
||||
*/
|
||||
fallbackStrategy?: 'bestFit' | 'initialPlacement';
|
||||
/**
|
||||
* Whether to allow fallback to the perpendicular axis of the preferred
|
||||
* placement, and if so, which side direction along the axis to prefer.
|
||||
* @default 'none' (disallow fallback)
|
||||
*/
|
||||
fallbackAxisSideDirection?: 'none' | 'start' | 'end';
|
||||
/**
|
||||
* Whether to flip to placements with the opposite alignment if they fit
|
||||
* better.
|
||||
* @default true
|
||||
*/
|
||||
flipAlignment?: boolean;
|
||||
}
|
||||
|
||||
export declare type FloatingElement = any;
|
||||
|
||||
/**
|
||||
* Provides data to hide the floating element in applicable situations, such as
|
||||
* when it is not in the same clipping context as the reference element.
|
||||
* @see https://floating-ui.com/docs/hide
|
||||
*/
|
||||
export declare const hide: (options?: HideOptions | Derivable<HideOptions>) => Middleware;
|
||||
|
||||
export declare interface HideOptions extends DetectOverflowOptions {
|
||||
/**
|
||||
* The strategy used to determine when to hide the floating element.
|
||||
*/
|
||||
strategy?: 'referenceHidden' | 'escaped';
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides improved positioning for inline reference elements that can span
|
||||
* over multiple lines, such as hyperlinks or range selections.
|
||||
* @see https://floating-ui.com/docs/inline
|
||||
*/
|
||||
export declare const inline: (options?: InlineOptions | Derivable<InlineOptions>) => Middleware;
|
||||
|
||||
export declare interface InlineOptions {
|
||||
/**
|
||||
* Viewport-relative `x` coordinate to choose a `ClientRect`.
|
||||
* @default undefined
|
||||
*/
|
||||
x?: number;
|
||||
/**
|
||||
* Viewport-relative `y` coordinate to choose a `ClientRect`.
|
||||
* @default undefined
|
||||
*/
|
||||
y?: number;
|
||||
/**
|
||||
* Represents the padding around a disjoined rect when choosing it.
|
||||
* @default 2
|
||||
*/
|
||||
padding?: Padding;
|
||||
}
|
||||
|
||||
export { Length }
|
||||
|
||||
/**
|
||||
* Built-in `limiter` that will stop `shift()` at a certain point.
|
||||
*/
|
||||
export declare const limitShift: (options?: LimitShiftOptions | Derivable<LimitShiftOptions>) => {
|
||||
options: any;
|
||||
fn: (state: MiddlewareState) => Coords;
|
||||
};
|
||||
|
||||
declare type LimitShiftOffset = number | {
|
||||
/**
|
||||
* Offset the limiting of the axis that runs along the alignment of the
|
||||
* floating element.
|
||||
*/
|
||||
mainAxis?: number;
|
||||
/**
|
||||
* Offset the limiting of the axis that runs along the side of the
|
||||
* floating element.
|
||||
*/
|
||||
crossAxis?: number;
|
||||
};
|
||||
|
||||
export declare interface LimitShiftOptions {
|
||||
/**
|
||||
* Offset when limiting starts. `0` will limit when the opposite edges of the
|
||||
* reference and floating elements are aligned.
|
||||
* - positive = start limiting earlier
|
||||
* - negative = start limiting later
|
||||
*/
|
||||
offset?: LimitShiftOffset | Derivable<LimitShiftOffset>;
|
||||
/**
|
||||
* Whether to limit the axis that runs along the alignment of the floating
|
||||
* element.
|
||||
*/
|
||||
mainAxis?: boolean;
|
||||
/**
|
||||
* Whether to limit the axis that runs along the side of the floating element.
|
||||
*/
|
||||
crossAxis?: boolean;
|
||||
}
|
||||
|
||||
export declare type Middleware = {
|
||||
name: string;
|
||||
options?: any;
|
||||
fn: (state: MiddlewareState) => Promisable<MiddlewareReturn>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated use `MiddlewareState` instead.
|
||||
*/
|
||||
export declare type MiddlewareArguments = MiddlewareState;
|
||||
|
||||
export declare interface MiddlewareData {
|
||||
[key: string]: any;
|
||||
arrow?: Partial<Coords> & {
|
||||
centerOffset: number;
|
||||
alignmentOffset?: number;
|
||||
};
|
||||
autoPlacement?: {
|
||||
index?: number;
|
||||
overflows: Array<{
|
||||
placement: Placement;
|
||||
overflows: Array<number>;
|
||||
}>;
|
||||
};
|
||||
flip?: {
|
||||
index?: number;
|
||||
overflows: Array<{
|
||||
placement: Placement;
|
||||
overflows: Array<number>;
|
||||
}>;
|
||||
};
|
||||
hide?: {
|
||||
referenceHidden?: boolean;
|
||||
escaped?: boolean;
|
||||
referenceHiddenOffsets?: SideObject;
|
||||
escapedOffsets?: SideObject;
|
||||
};
|
||||
offset?: Coords & {
|
||||
placement: Placement;
|
||||
};
|
||||
shift?: Coords & {
|
||||
enabled: {
|
||||
[key in Axis]: boolean;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export declare interface MiddlewareReturn extends Partial<Coords> {
|
||||
data?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
reset?: boolean | {
|
||||
placement?: Placement;
|
||||
rects?: boolean | ElementRects;
|
||||
};
|
||||
}
|
||||
|
||||
export declare interface MiddlewareState extends Coords {
|
||||
initialPlacement: Placement;
|
||||
placement: Placement;
|
||||
strategy: Strategy;
|
||||
middlewareData: MiddlewareData;
|
||||
elements: Elements;
|
||||
rects: ElementRects;
|
||||
platform: {
|
||||
detectOverflow: typeof detectOverflow;
|
||||
} & Platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies the placement by translating the floating element along the
|
||||
* specified axes.
|
||||
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
||||
* object may be passed.
|
||||
* @see https://floating-ui.com/docs/offset
|
||||
*/
|
||||
export declare const offset: (options?: OffsetOptions) => Middleware;
|
||||
|
||||
export declare type OffsetOptions = OffsetValue | Derivable<OffsetValue>;
|
||||
|
||||
declare type OffsetValue = number | {
|
||||
/**
|
||||
* The axis that runs along the side of the floating element. Represents
|
||||
* the distance (gutter or margin) between the reference and floating
|
||||
* element.
|
||||
* @default 0
|
||||
*/
|
||||
mainAxis?: number;
|
||||
/**
|
||||
* The axis that runs along the alignment of the floating element.
|
||||
* Represents the skidding between the reference and floating element.
|
||||
* @default 0
|
||||
*/
|
||||
crossAxis?: number;
|
||||
/**
|
||||
* The same axis as `crossAxis` but applies only to aligned placements
|
||||
* and inverts the `end` alignment. When set to a number, it overrides the
|
||||
* `crossAxis` value.
|
||||
*
|
||||
* A positive number will move the floating element in the direction of
|
||||
* the opposite edge to the one that is aligned, while a negative number
|
||||
* the reverse.
|
||||
* @default null
|
||||
*/
|
||||
alignmentAxis?: number | null;
|
||||
};
|
||||
|
||||
export { Padding }
|
||||
|
||||
export { Placement }
|
||||
|
||||
/**
|
||||
* Platform interface methods to work with the current platform.
|
||||
* @see https://floating-ui.com/docs/platform
|
||||
*/
|
||||
export declare interface Platform {
|
||||
getElementRects: (args: {
|
||||
reference: ReferenceElement;
|
||||
floating: FloatingElement;
|
||||
strategy: Strategy;
|
||||
}) => Promisable<ElementRects>;
|
||||
getClippingRect: (args: {
|
||||
element: any;
|
||||
boundary: Boundary;
|
||||
rootBoundary: RootBoundary;
|
||||
strategy: Strategy;
|
||||
}) => Promisable<Rect>;
|
||||
getDimensions: (element: any) => Promisable<Dimensions>;
|
||||
convertOffsetParentRelativeRectToViewportRelativeRect?: (args: {
|
||||
elements?: Elements;
|
||||
rect: Rect;
|
||||
offsetParent: any;
|
||||
strategy: Strategy;
|
||||
}) => Promisable<Rect>;
|
||||
getOffsetParent?: (element: any) => Promisable<any>;
|
||||
isElement?: (value: any) => Promisable<boolean>;
|
||||
getDocumentElement?: (element: any) => Promisable<any>;
|
||||
getClientRects?: (element: any) => Promisable<Array<ClientRectObject>>;
|
||||
isRTL?: (element: any) => Promisable<boolean>;
|
||||
getScale?: (element: any) => Promisable<{
|
||||
x: number;
|
||||
y: number;
|
||||
}>;
|
||||
detectOverflow?: typeof detectOverflow;
|
||||
}
|
||||
|
||||
declare type Promisable<T> = T | Promise<T>;
|
||||
|
||||
export { Rect }
|
||||
|
||||
export { rectToClientRect }
|
||||
|
||||
export declare type ReferenceElement = any;
|
||||
|
||||
export declare type RootBoundary = 'viewport' | 'document' | Rect;
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by shifting it in order to
|
||||
* keep it in view when it will overflow the clipping boundary.
|
||||
* @see https://floating-ui.com/docs/shift
|
||||
*/
|
||||
export declare const shift: (options?: ShiftOptions | Derivable<ShiftOptions>) => Middleware;
|
||||
|
||||
export declare interface ShiftOptions extends DetectOverflowOptions {
|
||||
/**
|
||||
* The axis that runs along the alignment of the floating element. Determines
|
||||
* whether overflow along this axis is checked to perform shifting.
|
||||
* @default true
|
||||
*/
|
||||
mainAxis?: boolean;
|
||||
/**
|
||||
* The axis that runs along the side of the floating element. Determines
|
||||
* whether overflow along this axis is checked to perform shifting.
|
||||
* @default false
|
||||
*/
|
||||
crossAxis?: boolean;
|
||||
/**
|
||||
* Accepts a function that limits the shifting done in order to prevent
|
||||
* detachment.
|
||||
*/
|
||||
limiter?: {
|
||||
fn: (state: MiddlewareState) => Coords;
|
||||
options?: any;
|
||||
};
|
||||
}
|
||||
|
||||
export { Side }
|
||||
|
||||
export { SideObject }
|
||||
|
||||
/**
|
||||
* Provides data that allows you to change the size of the floating element —
|
||||
* for instance, prevent it from overflowing the clipping boundary or match the
|
||||
* width of the reference element.
|
||||
* @see https://floating-ui.com/docs/size
|
||||
*/
|
||||
export declare const size: (options?: SizeOptions | Derivable<SizeOptions>) => Middleware;
|
||||
|
||||
export declare interface SizeOptions extends DetectOverflowOptions {
|
||||
/**
|
||||
* Function that is called to perform style mutations to the floating element
|
||||
* to change its size.
|
||||
* @default undefined
|
||||
*/
|
||||
apply?(args: MiddlewareState & {
|
||||
availableWidth: number;
|
||||
availableHeight: number;
|
||||
}): void | Promise<void>;
|
||||
}
|
||||
|
||||
export { Strategy }
|
||||
|
||||
export { VirtualElement }
|
||||
|
||||
export { }
|
||||
+531
@@ -0,0 +1,531 @@
|
||||
import { AlignedPlacement } from '@floating-ui/utils';
|
||||
import { Alignment } from '@floating-ui/utils';
|
||||
import { Axis } from '@floating-ui/utils';
|
||||
import { ClientRectObject } from '@floating-ui/utils';
|
||||
import { Coords } from '@floating-ui/utils';
|
||||
import { Dimensions } from '@floating-ui/utils';
|
||||
import { ElementRects } from '@floating-ui/utils';
|
||||
import { Length } from '@floating-ui/utils';
|
||||
import { Padding } from '@floating-ui/utils';
|
||||
import { Placement } from '@floating-ui/utils';
|
||||
import { Rect } from '@floating-ui/utils';
|
||||
import { rectToClientRect } from '@floating-ui/utils';
|
||||
import { Side } from '@floating-ui/utils';
|
||||
import { SideObject } from '@floating-ui/utils';
|
||||
import { Strategy } from '@floating-ui/utils';
|
||||
import { VirtualElement } from '@floating-ui/utils';
|
||||
|
||||
export { AlignedPlacement }
|
||||
|
||||
export { Alignment }
|
||||
|
||||
/**
|
||||
* Provides data to position an inner element of the floating element so that it
|
||||
* appears centered to the reference element.
|
||||
* @see https://floating-ui.com/docs/arrow
|
||||
*/
|
||||
export declare const arrow: (options: ArrowOptions | Derivable<ArrowOptions>) => Middleware;
|
||||
|
||||
export declare interface ArrowOptions {
|
||||
/**
|
||||
* The arrow element to be positioned.
|
||||
* @default undefined
|
||||
*/
|
||||
element: any;
|
||||
/**
|
||||
* The padding between the arrow element and the floating element edges.
|
||||
* Useful when the floating element has rounded corners.
|
||||
* @default 0
|
||||
*/
|
||||
padding?: Padding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by choosing the placement
|
||||
* that has the most space available automatically, without needing to specify a
|
||||
* preferred placement. Alternative to `flip`.
|
||||
* @see https://floating-ui.com/docs/autoPlacement
|
||||
*/
|
||||
export declare const autoPlacement: (options?: AutoPlacementOptions | Derivable<AutoPlacementOptions>) => Middleware;
|
||||
|
||||
export declare interface AutoPlacementOptions extends DetectOverflowOptions {
|
||||
/**
|
||||
* The axis that runs along the alignment of the floating element. Determines
|
||||
* whether to check for most space along this axis.
|
||||
* @default false
|
||||
*/
|
||||
crossAxis?: boolean;
|
||||
/**
|
||||
* Choose placements with a particular alignment.
|
||||
* @default undefined
|
||||
*/
|
||||
alignment?: Alignment | null;
|
||||
/**
|
||||
* Whether to choose placements with the opposite alignment if the preferred
|
||||
* alignment does not fit.
|
||||
* @default true
|
||||
*/
|
||||
autoAlignment?: boolean;
|
||||
/**
|
||||
* Which placements are allowed to be chosen. Placements must be within the
|
||||
* `alignment` option if explicitly set.
|
||||
* @default allPlacements (variable)
|
||||
*/
|
||||
allowedPlacements?: Array<Placement>;
|
||||
}
|
||||
|
||||
export { Axis }
|
||||
|
||||
export declare type Boundary = any;
|
||||
|
||||
export { ClientRectObject }
|
||||
|
||||
export declare type ComputePosition = (reference: unknown, floating: unknown, config: ComputePositionConfig) => Promise<ComputePositionReturn>;
|
||||
|
||||
/**
|
||||
* Computes the `x` and `y` coordinates that will place the floating element
|
||||
* next to a given reference element.
|
||||
*
|
||||
* This export does not have any `platform` interface logic. You will need to
|
||||
* write one for the platform you are using Floating UI with.
|
||||
*/
|
||||
export declare const computePosition: ComputePosition;
|
||||
|
||||
export declare interface ComputePositionConfig {
|
||||
/**
|
||||
* Object to interface with the current platform.
|
||||
*/
|
||||
platform: Platform;
|
||||
/**
|
||||
* Where to place the floating element relative to the reference element.
|
||||
*/
|
||||
placement?: Placement;
|
||||
/**
|
||||
* The strategy to use when positioning the floating element.
|
||||
*/
|
||||
strategy?: Strategy;
|
||||
/**
|
||||
* Array of middleware objects to modify the positioning or provide data for
|
||||
* rendering.
|
||||
*/
|
||||
middleware?: Array<Middleware | null | undefined | false>;
|
||||
}
|
||||
|
||||
export declare interface ComputePositionReturn extends Coords {
|
||||
/**
|
||||
* The final chosen placement of the floating element.
|
||||
*/
|
||||
placement: Placement;
|
||||
/**
|
||||
* The strategy used to position the floating element.
|
||||
*/
|
||||
strategy: Strategy;
|
||||
/**
|
||||
* Object containing data returned from all middleware, keyed by their name.
|
||||
*/
|
||||
middlewareData: MiddlewareData;
|
||||
}
|
||||
|
||||
export { Coords }
|
||||
|
||||
/**
|
||||
* Function option to derive middleware options from state.
|
||||
*/
|
||||
export declare type Derivable<T> = (state: MiddlewareState) => T;
|
||||
|
||||
/**
|
||||
* Resolves with an object of overflow side offsets that determine how much the
|
||||
* element is overflowing a given clipping boundary on each side.
|
||||
* - positive = overflowing the boundary by that number of pixels
|
||||
* - negative = how many pixels left before it will overflow
|
||||
* - 0 = lies flush with the boundary
|
||||
* @see https://floating-ui.com/docs/detectOverflow
|
||||
*/
|
||||
export declare function detectOverflow(state: MiddlewareState, options?: DetectOverflowOptions | Derivable<DetectOverflowOptions>): Promise<SideObject>;
|
||||
|
||||
export declare interface DetectOverflowOptions {
|
||||
/**
|
||||
* The clipping element(s) or area in which overflow will be checked.
|
||||
* @default 'clippingAncestors'
|
||||
*/
|
||||
boundary?: Boundary;
|
||||
/**
|
||||
* The root clipping area in which overflow will be checked.
|
||||
* @default 'viewport'
|
||||
*/
|
||||
rootBoundary?: RootBoundary;
|
||||
/**
|
||||
* The element in which overflow is being checked relative to a boundary.
|
||||
* @default 'floating'
|
||||
*/
|
||||
elementContext?: ElementContext;
|
||||
/**
|
||||
* Whether to check for overflow using the alternate element's boundary
|
||||
* (`clippingAncestors` boundary only).
|
||||
* @default false
|
||||
*/
|
||||
altBoundary?: boolean;
|
||||
/**
|
||||
* Virtual padding for the resolved overflow detection offsets.
|
||||
* @default 0
|
||||
*/
|
||||
padding?: Padding;
|
||||
}
|
||||
|
||||
export { Dimensions }
|
||||
|
||||
export declare type ElementContext = 'reference' | 'floating';
|
||||
|
||||
export { ElementRects }
|
||||
|
||||
export declare interface Elements {
|
||||
reference: ReferenceElement;
|
||||
floating: FloatingElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by flipping the `placement`
|
||||
* in order to keep it in view when the preferred placement(s) will overflow the
|
||||
* clipping boundary. Alternative to `autoPlacement`.
|
||||
* @see https://floating-ui.com/docs/flip
|
||||
*/
|
||||
export declare const flip: (options?: FlipOptions | Derivable<FlipOptions>) => Middleware;
|
||||
|
||||
export declare interface FlipOptions extends DetectOverflowOptions {
|
||||
/**
|
||||
* The axis that runs along the side of the floating element. Determines
|
||||
* whether overflow along this axis is checked to perform a flip.
|
||||
* @default true
|
||||
*/
|
||||
mainAxis?: boolean;
|
||||
/**
|
||||
* The axis that runs along the alignment of the floating element. Determines
|
||||
* whether overflow along this axis is checked to perform a flip.
|
||||
* - `true`: Whether to check cross axis overflow for both side and alignment flipping.
|
||||
* - `false`: Whether to disable all cross axis overflow checking.
|
||||
* - `'alignment'`: Whether to check cross axis overflow for alignment flipping only.
|
||||
* @default true
|
||||
*/
|
||||
crossAxis?: boolean | 'alignment';
|
||||
/**
|
||||
* Placements to try sequentially if the preferred `placement` does not fit.
|
||||
* @default [oppositePlacement] (computed)
|
||||
*/
|
||||
fallbackPlacements?: Array<Placement>;
|
||||
/**
|
||||
* What strategy to use when no placements fit.
|
||||
* @default 'bestFit'
|
||||
*/
|
||||
fallbackStrategy?: 'bestFit' | 'initialPlacement';
|
||||
/**
|
||||
* Whether to allow fallback to the perpendicular axis of the preferred
|
||||
* placement, and if so, which side direction along the axis to prefer.
|
||||
* @default 'none' (disallow fallback)
|
||||
*/
|
||||
fallbackAxisSideDirection?: 'none' | 'start' | 'end';
|
||||
/**
|
||||
* Whether to flip to placements with the opposite alignment if they fit
|
||||
* better.
|
||||
* @default true
|
||||
*/
|
||||
flipAlignment?: boolean;
|
||||
}
|
||||
|
||||
export declare type FloatingElement = any;
|
||||
|
||||
/**
|
||||
* Provides data to hide the floating element in applicable situations, such as
|
||||
* when it is not in the same clipping context as the reference element.
|
||||
* @see https://floating-ui.com/docs/hide
|
||||
*/
|
||||
export declare const hide: (options?: HideOptions | Derivable<HideOptions>) => Middleware;
|
||||
|
||||
export declare interface HideOptions extends DetectOverflowOptions {
|
||||
/**
|
||||
* The strategy used to determine when to hide the floating element.
|
||||
*/
|
||||
strategy?: 'referenceHidden' | 'escaped';
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides improved positioning for inline reference elements that can span
|
||||
* over multiple lines, such as hyperlinks or range selections.
|
||||
* @see https://floating-ui.com/docs/inline
|
||||
*/
|
||||
export declare const inline: (options?: InlineOptions | Derivable<InlineOptions>) => Middleware;
|
||||
|
||||
export declare interface InlineOptions {
|
||||
/**
|
||||
* Viewport-relative `x` coordinate to choose a `ClientRect`.
|
||||
* @default undefined
|
||||
*/
|
||||
x?: number;
|
||||
/**
|
||||
* Viewport-relative `y` coordinate to choose a `ClientRect`.
|
||||
* @default undefined
|
||||
*/
|
||||
y?: number;
|
||||
/**
|
||||
* Represents the padding around a disjoined rect when choosing it.
|
||||
* @default 2
|
||||
*/
|
||||
padding?: Padding;
|
||||
}
|
||||
|
||||
export { Length }
|
||||
|
||||
/**
|
||||
* Built-in `limiter` that will stop `shift()` at a certain point.
|
||||
*/
|
||||
export declare const limitShift: (options?: LimitShiftOptions | Derivable<LimitShiftOptions>) => {
|
||||
options: any;
|
||||
fn: (state: MiddlewareState) => Coords;
|
||||
};
|
||||
|
||||
declare type LimitShiftOffset = number | {
|
||||
/**
|
||||
* Offset the limiting of the axis that runs along the alignment of the
|
||||
* floating element.
|
||||
*/
|
||||
mainAxis?: number;
|
||||
/**
|
||||
* Offset the limiting of the axis that runs along the side of the
|
||||
* floating element.
|
||||
*/
|
||||
crossAxis?: number;
|
||||
};
|
||||
|
||||
export declare interface LimitShiftOptions {
|
||||
/**
|
||||
* Offset when limiting starts. `0` will limit when the opposite edges of the
|
||||
* reference and floating elements are aligned.
|
||||
* - positive = start limiting earlier
|
||||
* - negative = start limiting later
|
||||
*/
|
||||
offset?: LimitShiftOffset | Derivable<LimitShiftOffset>;
|
||||
/**
|
||||
* Whether to limit the axis that runs along the alignment of the floating
|
||||
* element.
|
||||
*/
|
||||
mainAxis?: boolean;
|
||||
/**
|
||||
* Whether to limit the axis that runs along the side of the floating element.
|
||||
*/
|
||||
crossAxis?: boolean;
|
||||
}
|
||||
|
||||
export declare type Middleware = {
|
||||
name: string;
|
||||
options?: any;
|
||||
fn: (state: MiddlewareState) => Promisable<MiddlewareReturn>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated use `MiddlewareState` instead.
|
||||
*/
|
||||
export declare type MiddlewareArguments = MiddlewareState;
|
||||
|
||||
export declare interface MiddlewareData {
|
||||
[key: string]: any;
|
||||
arrow?: Partial<Coords> & {
|
||||
centerOffset: number;
|
||||
alignmentOffset?: number;
|
||||
};
|
||||
autoPlacement?: {
|
||||
index?: number;
|
||||
overflows: Array<{
|
||||
placement: Placement;
|
||||
overflows: Array<number>;
|
||||
}>;
|
||||
};
|
||||
flip?: {
|
||||
index?: number;
|
||||
overflows: Array<{
|
||||
placement: Placement;
|
||||
overflows: Array<number>;
|
||||
}>;
|
||||
};
|
||||
hide?: {
|
||||
referenceHidden?: boolean;
|
||||
escaped?: boolean;
|
||||
referenceHiddenOffsets?: SideObject;
|
||||
escapedOffsets?: SideObject;
|
||||
};
|
||||
offset?: Coords & {
|
||||
placement: Placement;
|
||||
};
|
||||
shift?: Coords & {
|
||||
enabled: {
|
||||
[key in Axis]: boolean;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export declare interface MiddlewareReturn extends Partial<Coords> {
|
||||
data?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
reset?: boolean | {
|
||||
placement?: Placement;
|
||||
rects?: boolean | ElementRects;
|
||||
};
|
||||
}
|
||||
|
||||
export declare interface MiddlewareState extends Coords {
|
||||
initialPlacement: Placement;
|
||||
placement: Placement;
|
||||
strategy: Strategy;
|
||||
middlewareData: MiddlewareData;
|
||||
elements: Elements;
|
||||
rects: ElementRects;
|
||||
platform: {
|
||||
detectOverflow: typeof detectOverflow;
|
||||
} & Platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies the placement by translating the floating element along the
|
||||
* specified axes.
|
||||
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
||||
* object may be passed.
|
||||
* @see https://floating-ui.com/docs/offset
|
||||
*/
|
||||
export declare const offset: (options?: OffsetOptions) => Middleware;
|
||||
|
||||
export declare type OffsetOptions = OffsetValue | Derivable<OffsetValue>;
|
||||
|
||||
declare type OffsetValue = number | {
|
||||
/**
|
||||
* The axis that runs along the side of the floating element. Represents
|
||||
* the distance (gutter or margin) between the reference and floating
|
||||
* element.
|
||||
* @default 0
|
||||
*/
|
||||
mainAxis?: number;
|
||||
/**
|
||||
* The axis that runs along the alignment of the floating element.
|
||||
* Represents the skidding between the reference and floating element.
|
||||
* @default 0
|
||||
*/
|
||||
crossAxis?: number;
|
||||
/**
|
||||
* The same axis as `crossAxis` but applies only to aligned placements
|
||||
* and inverts the `end` alignment. When set to a number, it overrides the
|
||||
* `crossAxis` value.
|
||||
*
|
||||
* A positive number will move the floating element in the direction of
|
||||
* the opposite edge to the one that is aligned, while a negative number
|
||||
* the reverse.
|
||||
* @default null
|
||||
*/
|
||||
alignmentAxis?: number | null;
|
||||
};
|
||||
|
||||
export { Padding }
|
||||
|
||||
export { Placement }
|
||||
|
||||
/**
|
||||
* Platform interface methods to work with the current platform.
|
||||
* @see https://floating-ui.com/docs/platform
|
||||
*/
|
||||
export declare interface Platform {
|
||||
getElementRects: (args: {
|
||||
reference: ReferenceElement;
|
||||
floating: FloatingElement;
|
||||
strategy: Strategy;
|
||||
}) => Promisable<ElementRects>;
|
||||
getClippingRect: (args: {
|
||||
element: any;
|
||||
boundary: Boundary;
|
||||
rootBoundary: RootBoundary;
|
||||
strategy: Strategy;
|
||||
}) => Promisable<Rect>;
|
||||
getDimensions: (element: any) => Promisable<Dimensions>;
|
||||
convertOffsetParentRelativeRectToViewportRelativeRect?: (args: {
|
||||
elements?: Elements;
|
||||
rect: Rect;
|
||||
offsetParent: any;
|
||||
strategy: Strategy;
|
||||
}) => Promisable<Rect>;
|
||||
getOffsetParent?: (element: any) => Promisable<any>;
|
||||
isElement?: (value: any) => Promisable<boolean>;
|
||||
getDocumentElement?: (element: any) => Promisable<any>;
|
||||
getClientRects?: (element: any) => Promisable<Array<ClientRectObject>>;
|
||||
isRTL?: (element: any) => Promisable<boolean>;
|
||||
getScale?: (element: any) => Promisable<{
|
||||
x: number;
|
||||
y: number;
|
||||
}>;
|
||||
detectOverflow?: typeof detectOverflow;
|
||||
}
|
||||
|
||||
declare type Promisable<T> = T | Promise<T>;
|
||||
|
||||
export { Rect }
|
||||
|
||||
export { rectToClientRect }
|
||||
|
||||
export declare type ReferenceElement = any;
|
||||
|
||||
export declare type RootBoundary = 'viewport' | 'document' | Rect;
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by shifting it in order to
|
||||
* keep it in view when it will overflow the clipping boundary.
|
||||
* @see https://floating-ui.com/docs/shift
|
||||
*/
|
||||
export declare const shift: (options?: ShiftOptions | Derivable<ShiftOptions>) => Middleware;
|
||||
|
||||
export declare interface ShiftOptions extends DetectOverflowOptions {
|
||||
/**
|
||||
* The axis that runs along the alignment of the floating element. Determines
|
||||
* whether overflow along this axis is checked to perform shifting.
|
||||
* @default true
|
||||
*/
|
||||
mainAxis?: boolean;
|
||||
/**
|
||||
* The axis that runs along the side of the floating element. Determines
|
||||
* whether overflow along this axis is checked to perform shifting.
|
||||
* @default false
|
||||
*/
|
||||
crossAxis?: boolean;
|
||||
/**
|
||||
* Accepts a function that limits the shifting done in order to prevent
|
||||
* detachment.
|
||||
*/
|
||||
limiter?: {
|
||||
fn: (state: MiddlewareState) => Coords;
|
||||
options?: any;
|
||||
};
|
||||
}
|
||||
|
||||
export { Side }
|
||||
|
||||
export { SideObject }
|
||||
|
||||
/**
|
||||
* Provides data that allows you to change the size of the floating element —
|
||||
* for instance, prevent it from overflowing the clipping boundary or match the
|
||||
* width of the reference element.
|
||||
* @see https://floating-ui.com/docs/size
|
||||
*/
|
||||
export declare const size: (options?: SizeOptions | Derivable<SizeOptions>) => Middleware;
|
||||
|
||||
export declare interface SizeOptions extends DetectOverflowOptions {
|
||||
/**
|
||||
* Function that is called to perform style mutations to the floating element
|
||||
* to change its size.
|
||||
* @default undefined
|
||||
*/
|
||||
apply?(args: MiddlewareState & {
|
||||
availableWidth: number;
|
||||
availableHeight: number;
|
||||
}): void | Promise<void>;
|
||||
}
|
||||
|
||||
export { Strategy }
|
||||
|
||||
export { VirtualElement }
|
||||
|
||||
export { }
|
||||
+1055
File diff suppressed because it is too large
Load Diff
+1055
File diff suppressed because it is too large
Load Diff
+1203
File diff suppressed because it is too large
Load Diff
+1
File diff suppressed because one or more lines are too long
+63
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "@floating-ui/core",
|
||||
"version": "1.7.4",
|
||||
"description": "Positioning library for floating elements: tooltips, popovers, dropdowns, and more",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"main": "./dist/floating-ui.core.umd.js",
|
||||
"module": "./dist/floating-ui.core.esm.js",
|
||||
"unpkg": "./dist/floating-ui.core.umd.min.js",
|
||||
"types": "./dist/floating-ui.core.d.ts",
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/floating-ui.core.d.mts",
|
||||
"default": "./dist/floating-ui.core.mjs"
|
||||
},
|
||||
"types": "./dist/floating-ui.core.d.ts",
|
||||
"module": "./dist/floating-ui.core.esm.js",
|
||||
"default": "./dist/floating-ui.core.umd.js"
|
||||
}
|
||||
},
|
||||
"sideEffects": false,
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"author": "atomiks",
|
||||
"license": "MIT",
|
||||
"bugs": "https://github.com/floating-ui/floating-ui",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/floating-ui/floating-ui.git",
|
||||
"directory": "packages/core"
|
||||
},
|
||||
"homepage": "https://floating-ui.com",
|
||||
"keywords": [
|
||||
"tooltip",
|
||||
"popover",
|
||||
"dropdown",
|
||||
"menu",
|
||||
"popup",
|
||||
"positioning"
|
||||
],
|
||||
"dependencies": {
|
||||
"@floating-ui/utils": "^0.2.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"config": "0.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest watch",
|
||||
"lint": "eslint .",
|
||||
"format": "prettier --write .",
|
||||
"clean": "rimraf dist out-tsc",
|
||||
"dev": "rollup -c -w",
|
||||
"build": "rollup -c",
|
||||
"build:api": "build-api --tsc tsconfig.lib.json",
|
||||
"publint": "publint",
|
||||
"typecheck": "tsc -b"
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021-present Floating UI contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
# @floating-ui/dom
|
||||
|
||||
This is the library to use Floating UI on the web, wrapping `@floating-ui/core`
|
||||
with DOM interface logic.
|
||||
+1
File diff suppressed because one or more lines are too long
+948
@@ -0,0 +1,948 @@
|
||||
import { rectToClientRect, arrow as arrow$1, autoPlacement as autoPlacement$1, detectOverflow as detectOverflow$1, flip as flip$1, hide as hide$1, inline as inline$1, limitShift as limitShift$1, offset as offset$1, shift as shift$1, size as size$1, computePosition as computePosition$1 } from '@floating-ui/core';
|
||||
|
||||
/**
|
||||
* Custom positioning reference element.
|
||||
* @see https://floating-ui.com/docs/virtual-elements
|
||||
*/
|
||||
|
||||
const min = Math.min;
|
||||
const max = Math.max;
|
||||
const round = Math.round;
|
||||
const floor = Math.floor;
|
||||
const createCoords = v => ({
|
||||
x: v,
|
||||
y: v
|
||||
});
|
||||
|
||||
function hasWindow() {
|
||||
return typeof window !== 'undefined';
|
||||
}
|
||||
function getNodeName(node) {
|
||||
if (isNode(node)) {
|
||||
return (node.nodeName || '').toLowerCase();
|
||||
}
|
||||
// Mocked nodes in testing environments may not be instances of Node. By
|
||||
// returning `#document` an infinite loop won't occur.
|
||||
// https://github.com/floating-ui/floating-ui/issues/2317
|
||||
return '#document';
|
||||
}
|
||||
function getWindow(node) {
|
||||
var _node$ownerDocument;
|
||||
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
||||
}
|
||||
function getDocumentElement(node) {
|
||||
var _ref;
|
||||
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
||||
}
|
||||
function isNode(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof Node || value instanceof getWindow(value).Node;
|
||||
}
|
||||
function isElement(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof Element || value instanceof getWindow(value).Element;
|
||||
}
|
||||
function isHTMLElement(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
||||
}
|
||||
function isShadowRoot(value) {
|
||||
if (!hasWindow() || typeof ShadowRoot === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
||||
}
|
||||
const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
|
||||
function isOverflowElement(element) {
|
||||
const {
|
||||
overflow,
|
||||
overflowX,
|
||||
overflowY,
|
||||
display
|
||||
} = getComputedStyle$1(element);
|
||||
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
||||
}
|
||||
const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
|
||||
function isTableElement(element) {
|
||||
return tableElements.has(getNodeName(element));
|
||||
}
|
||||
const topLayerSelectors = [':popover-open', ':modal'];
|
||||
function isTopLayer(element) {
|
||||
return topLayerSelectors.some(selector => {
|
||||
try {
|
||||
return element.matches(selector);
|
||||
} catch (_e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
|
||||
const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
|
||||
const containValues = ['paint', 'layout', 'strict', 'content'];
|
||||
function isContainingBlock(elementOrCss) {
|
||||
const webkit = isWebKit();
|
||||
const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
||||
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
||||
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));
|
||||
}
|
||||
function getContainingBlock(element) {
|
||||
let currentNode = getParentNode(element);
|
||||
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
||||
if (isContainingBlock(currentNode)) {
|
||||
return currentNode;
|
||||
} else if (isTopLayer(currentNode)) {
|
||||
return null;
|
||||
}
|
||||
currentNode = getParentNode(currentNode);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function isWebKit() {
|
||||
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
||||
return CSS.supports('-webkit-backdrop-filter', 'none');
|
||||
}
|
||||
const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
|
||||
function isLastTraversableNode(node) {
|
||||
return lastTraversableNodeNames.has(getNodeName(node));
|
||||
}
|
||||
function getComputedStyle$1(element) {
|
||||
return getWindow(element).getComputedStyle(element);
|
||||
}
|
||||
function getNodeScroll(element) {
|
||||
if (isElement(element)) {
|
||||
return {
|
||||
scrollLeft: element.scrollLeft,
|
||||
scrollTop: element.scrollTop
|
||||
};
|
||||
}
|
||||
return {
|
||||
scrollLeft: element.scrollX,
|
||||
scrollTop: element.scrollY
|
||||
};
|
||||
}
|
||||
function getParentNode(node) {
|
||||
if (getNodeName(node) === 'html') {
|
||||
return node;
|
||||
}
|
||||
const result =
|
||||
// Step into the shadow DOM of the parent of a slotted node.
|
||||
node.assignedSlot ||
|
||||
// DOM Element detected.
|
||||
node.parentNode ||
|
||||
// ShadowRoot detected.
|
||||
isShadowRoot(node) && node.host ||
|
||||
// Fallback.
|
||||
getDocumentElement(node);
|
||||
return isShadowRoot(result) ? result.host : result;
|
||||
}
|
||||
function getNearestOverflowAncestor(node) {
|
||||
const parentNode = getParentNode(node);
|
||||
if (isLastTraversableNode(parentNode)) {
|
||||
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
||||
}
|
||||
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
||||
return parentNode;
|
||||
}
|
||||
return getNearestOverflowAncestor(parentNode);
|
||||
}
|
||||
function getOverflowAncestors(node, list, traverseIframes) {
|
||||
var _node$ownerDocument2;
|
||||
if (list === void 0) {
|
||||
list = [];
|
||||
}
|
||||
if (traverseIframes === void 0) {
|
||||
traverseIframes = true;
|
||||
}
|
||||
const scrollableAncestor = getNearestOverflowAncestor(node);
|
||||
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
||||
const win = getWindow(scrollableAncestor);
|
||||
if (isBody) {
|
||||
const frameElement = getFrameElement(win);
|
||||
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
||||
}
|
||||
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
||||
}
|
||||
function getFrameElement(win) {
|
||||
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
||||
}
|
||||
|
||||
function getCssDimensions(element) {
|
||||
const css = getComputedStyle$1(element);
|
||||
// In testing environments, the `width` and `height` properties are empty
|
||||
// strings for SVG elements, returning NaN. Fallback to `0` in this case.
|
||||
let width = parseFloat(css.width) || 0;
|
||||
let height = parseFloat(css.height) || 0;
|
||||
const hasOffset = isHTMLElement(element);
|
||||
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
||||
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
||||
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
||||
if (shouldFallback) {
|
||||
width = offsetWidth;
|
||||
height = offsetHeight;
|
||||
}
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
$: shouldFallback
|
||||
};
|
||||
}
|
||||
|
||||
function unwrapElement(element) {
|
||||
return !isElement(element) ? element.contextElement : element;
|
||||
}
|
||||
|
||||
function getScale(element) {
|
||||
const domElement = unwrapElement(element);
|
||||
if (!isHTMLElement(domElement)) {
|
||||
return createCoords(1);
|
||||
}
|
||||
const rect = domElement.getBoundingClientRect();
|
||||
const {
|
||||
width,
|
||||
height,
|
||||
$
|
||||
} = getCssDimensions(domElement);
|
||||
let x = ($ ? round(rect.width) : rect.width) / width;
|
||||
let y = ($ ? round(rect.height) : rect.height) / height;
|
||||
|
||||
// 0, NaN, or Infinity should always fallback to 1.
|
||||
|
||||
if (!x || !Number.isFinite(x)) {
|
||||
x = 1;
|
||||
}
|
||||
if (!y || !Number.isFinite(y)) {
|
||||
y = 1;
|
||||
}
|
||||
return {
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
const noOffsets = /*#__PURE__*/createCoords(0);
|
||||
function getVisualOffsets(element) {
|
||||
const win = getWindow(element);
|
||||
if (!isWebKit() || !win.visualViewport) {
|
||||
return noOffsets;
|
||||
}
|
||||
return {
|
||||
x: win.visualViewport.offsetLeft,
|
||||
y: win.visualViewport.offsetTop
|
||||
};
|
||||
}
|
||||
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
||||
if (isFixed === void 0) {
|
||||
isFixed = false;
|
||||
}
|
||||
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
||||
return false;
|
||||
}
|
||||
return isFixed;
|
||||
}
|
||||
|
||||
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
||||
if (includeScale === void 0) {
|
||||
includeScale = false;
|
||||
}
|
||||
if (isFixedStrategy === void 0) {
|
||||
isFixedStrategy = false;
|
||||
}
|
||||
const clientRect = element.getBoundingClientRect();
|
||||
const domElement = unwrapElement(element);
|
||||
let scale = createCoords(1);
|
||||
if (includeScale) {
|
||||
if (offsetParent) {
|
||||
if (isElement(offsetParent)) {
|
||||
scale = getScale(offsetParent);
|
||||
}
|
||||
} else {
|
||||
scale = getScale(element);
|
||||
}
|
||||
}
|
||||
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
||||
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
||||
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
||||
let width = clientRect.width / scale.x;
|
||||
let height = clientRect.height / scale.y;
|
||||
if (domElement) {
|
||||
const win = getWindow(domElement);
|
||||
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
||||
let currentWin = win;
|
||||
let currentIFrame = getFrameElement(currentWin);
|
||||
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
||||
const iframeScale = getScale(currentIFrame);
|
||||
const iframeRect = currentIFrame.getBoundingClientRect();
|
||||
const css = getComputedStyle$1(currentIFrame);
|
||||
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
||||
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
||||
x *= iframeScale.x;
|
||||
y *= iframeScale.y;
|
||||
width *= iframeScale.x;
|
||||
height *= iframeScale.y;
|
||||
x += left;
|
||||
y += top;
|
||||
currentWin = getWindow(currentIFrame);
|
||||
currentIFrame = getFrameElement(currentWin);
|
||||
}
|
||||
}
|
||||
return rectToClientRect({
|
||||
width,
|
||||
height,
|
||||
x,
|
||||
y
|
||||
});
|
||||
}
|
||||
|
||||
// If <html> has a CSS width greater than the viewport, then this will be
|
||||
// incorrect for RTL.
|
||||
function getWindowScrollBarX(element, rect) {
|
||||
const leftScroll = getNodeScroll(element).scrollLeft;
|
||||
if (!rect) {
|
||||
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
||||
}
|
||||
return rect.left + leftScroll;
|
||||
}
|
||||
|
||||
function getHTMLOffset(documentElement, scroll) {
|
||||
const htmlRect = documentElement.getBoundingClientRect();
|
||||
const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
|
||||
const y = htmlRect.top + scroll.scrollTop;
|
||||
return {
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
||||
let {
|
||||
elements,
|
||||
rect,
|
||||
offsetParent,
|
||||
strategy
|
||||
} = _ref;
|
||||
const isFixed = strategy === 'fixed';
|
||||
const documentElement = getDocumentElement(offsetParent);
|
||||
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
||||
if (offsetParent === documentElement || topLayer && isFixed) {
|
||||
return rect;
|
||||
}
|
||||
let scroll = {
|
||||
scrollLeft: 0,
|
||||
scrollTop: 0
|
||||
};
|
||||
let scale = createCoords(1);
|
||||
const offsets = createCoords(0);
|
||||
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
||||
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
||||
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
||||
scroll = getNodeScroll(offsetParent);
|
||||
}
|
||||
if (isHTMLElement(offsetParent)) {
|
||||
const offsetRect = getBoundingClientRect(offsetParent);
|
||||
scale = getScale(offsetParent);
|
||||
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
||||
offsets.y = offsetRect.y + offsetParent.clientTop;
|
||||
}
|
||||
}
|
||||
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
||||
return {
|
||||
width: rect.width * scale.x,
|
||||
height: rect.height * scale.y,
|
||||
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
||||
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
||||
};
|
||||
}
|
||||
|
||||
function getClientRects(element) {
|
||||
return Array.from(element.getClientRects());
|
||||
}
|
||||
|
||||
// Gets the entire size of the scrollable document area, even extending outside
|
||||
// of the `<html>` and `<body>` rect bounds if horizontally scrollable.
|
||||
function getDocumentRect(element) {
|
||||
const html = getDocumentElement(element);
|
||||
const scroll = getNodeScroll(element);
|
||||
const body = element.ownerDocument.body;
|
||||
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
||||
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
||||
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
||||
const y = -scroll.scrollTop;
|
||||
if (getComputedStyle$1(body).direction === 'rtl') {
|
||||
x += max(html.clientWidth, body.clientWidth) - width;
|
||||
}
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
// Safety check: ensure the scrollbar space is reasonable in case this
|
||||
// calculation is affected by unusual styles.
|
||||
// Most scrollbars leave 15-18px of space.
|
||||
const SCROLLBAR_MAX = 25;
|
||||
function getViewportRect(element, strategy) {
|
||||
const win = getWindow(element);
|
||||
const html = getDocumentElement(element);
|
||||
const visualViewport = win.visualViewport;
|
||||
let width = html.clientWidth;
|
||||
let height = html.clientHeight;
|
||||
let x = 0;
|
||||
let y = 0;
|
||||
if (visualViewport) {
|
||||
width = visualViewport.width;
|
||||
height = visualViewport.height;
|
||||
const visualViewportBased = isWebKit();
|
||||
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
|
||||
x = visualViewport.offsetLeft;
|
||||
y = visualViewport.offsetTop;
|
||||
}
|
||||
}
|
||||
const windowScrollbarX = getWindowScrollBarX(html);
|
||||
// <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
|
||||
// visual width of the <html> but this is not considered in the size
|
||||
// of `html.clientWidth`.
|
||||
if (windowScrollbarX <= 0) {
|
||||
const doc = html.ownerDocument;
|
||||
const body = doc.body;
|
||||
const bodyStyles = getComputedStyle(body);
|
||||
const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
|
||||
const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
|
||||
if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
|
||||
width -= clippingStableScrollbarWidth;
|
||||
}
|
||||
} else if (windowScrollbarX <= SCROLLBAR_MAX) {
|
||||
// If the <body> scrollbar is on the left, the width needs to be extended
|
||||
// by the scrollbar amount so there isn't extra space on the right.
|
||||
width += windowScrollbarX;
|
||||
}
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
const absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);
|
||||
// Returns the inner client rect, subtracting scrollbars if present.
|
||||
function getInnerBoundingClientRect(element, strategy) {
|
||||
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
||||
const top = clientRect.top + element.clientTop;
|
||||
const left = clientRect.left + element.clientLeft;
|
||||
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
||||
const width = element.clientWidth * scale.x;
|
||||
const height = element.clientHeight * scale.y;
|
||||
const x = left * scale.x;
|
||||
const y = top * scale.y;
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
||||
let rect;
|
||||
if (clippingAncestor === 'viewport') {
|
||||
rect = getViewportRect(element, strategy);
|
||||
} else if (clippingAncestor === 'document') {
|
||||
rect = getDocumentRect(getDocumentElement(element));
|
||||
} else if (isElement(clippingAncestor)) {
|
||||
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
||||
} else {
|
||||
const visualOffsets = getVisualOffsets(element);
|
||||
rect = {
|
||||
x: clippingAncestor.x - visualOffsets.x,
|
||||
y: clippingAncestor.y - visualOffsets.y,
|
||||
width: clippingAncestor.width,
|
||||
height: clippingAncestor.height
|
||||
};
|
||||
}
|
||||
return rectToClientRect(rect);
|
||||
}
|
||||
function hasFixedPositionAncestor(element, stopNode) {
|
||||
const parentNode = getParentNode(element);
|
||||
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
||||
return false;
|
||||
}
|
||||
return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
|
||||
}
|
||||
|
||||
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
||||
// clipping (or hiding) child elements. This returns all clipping ancestors
|
||||
// of the given element up the tree.
|
||||
function getClippingElementAncestors(element, cache) {
|
||||
const cachedResult = cache.get(element);
|
||||
if (cachedResult) {
|
||||
return cachedResult;
|
||||
}
|
||||
let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
||||
let currentContainingBlockComputedStyle = null;
|
||||
const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
|
||||
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
||||
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
||||
const computedStyle = getComputedStyle$1(currentNode);
|
||||
const currentNodeIsContaining = isContainingBlock(currentNode);
|
||||
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
||||
currentContainingBlockComputedStyle = null;
|
||||
}
|
||||
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
||||
if (shouldDropCurrentNode) {
|
||||
// Drop non-containing blocks.
|
||||
result = result.filter(ancestor => ancestor !== currentNode);
|
||||
} else {
|
||||
// Record last containing block for next iteration.
|
||||
currentContainingBlockComputedStyle = computedStyle;
|
||||
}
|
||||
currentNode = getParentNode(currentNode);
|
||||
}
|
||||
cache.set(element, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Gets the maximum area that the element is visible in due to any number of
|
||||
// clipping ancestors.
|
||||
function getClippingRect(_ref) {
|
||||
let {
|
||||
element,
|
||||
boundary,
|
||||
rootBoundary,
|
||||
strategy
|
||||
} = _ref;
|
||||
const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
||||
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
||||
const firstClippingAncestor = clippingAncestors[0];
|
||||
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
||||
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
||||
accRect.top = max(rect.top, accRect.top);
|
||||
accRect.right = min(rect.right, accRect.right);
|
||||
accRect.bottom = min(rect.bottom, accRect.bottom);
|
||||
accRect.left = max(rect.left, accRect.left);
|
||||
return accRect;
|
||||
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
||||
return {
|
||||
width: clippingRect.right - clippingRect.left,
|
||||
height: clippingRect.bottom - clippingRect.top,
|
||||
x: clippingRect.left,
|
||||
y: clippingRect.top
|
||||
};
|
||||
}
|
||||
|
||||
function getDimensions(element) {
|
||||
const {
|
||||
width,
|
||||
height
|
||||
} = getCssDimensions(element);
|
||||
return {
|
||||
width,
|
||||
height
|
||||
};
|
||||
}
|
||||
|
||||
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
||||
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
||||
const documentElement = getDocumentElement(offsetParent);
|
||||
const isFixed = strategy === 'fixed';
|
||||
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
||||
let scroll = {
|
||||
scrollLeft: 0,
|
||||
scrollTop: 0
|
||||
};
|
||||
const offsets = createCoords(0);
|
||||
|
||||
// If the <body> scrollbar appears on the left (e.g. RTL systems). Use
|
||||
// Firefox with layout.scrollbar.side = 3 in about:config to test this.
|
||||
function setLeftRTLScrollbarOffset() {
|
||||
offsets.x = getWindowScrollBarX(documentElement);
|
||||
}
|
||||
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
||||
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
||||
scroll = getNodeScroll(offsetParent);
|
||||
}
|
||||
if (isOffsetParentAnElement) {
|
||||
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
||||
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
||||
offsets.y = offsetRect.y + offsetParent.clientTop;
|
||||
} else if (documentElement) {
|
||||
setLeftRTLScrollbarOffset();
|
||||
}
|
||||
}
|
||||
if (isFixed && !isOffsetParentAnElement && documentElement) {
|
||||
setLeftRTLScrollbarOffset();
|
||||
}
|
||||
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
||||
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
||||
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
||||
return {
|
||||
x,
|
||||
y,
|
||||
width: rect.width,
|
||||
height: rect.height
|
||||
};
|
||||
}
|
||||
|
||||
function isStaticPositioned(element) {
|
||||
return getComputedStyle$1(element).position === 'static';
|
||||
}
|
||||
|
||||
function getTrueOffsetParent(element, polyfill) {
|
||||
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
|
||||
return null;
|
||||
}
|
||||
if (polyfill) {
|
||||
return polyfill(element);
|
||||
}
|
||||
let rawOffsetParent = element.offsetParent;
|
||||
|
||||
// Firefox returns the <html> element as the offsetParent if it's non-static,
|
||||
// while Chrome and Safari return the <body> element. The <body> element must
|
||||
// be used to perform the correct calculations even if the <html> element is
|
||||
// non-static.
|
||||
if (getDocumentElement(element) === rawOffsetParent) {
|
||||
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
||||
}
|
||||
return rawOffsetParent;
|
||||
}
|
||||
|
||||
// Gets the closest ancestor positioned element. Handles some edge cases,
|
||||
// such as table ancestors and cross browser bugs.
|
||||
function getOffsetParent(element, polyfill) {
|
||||
const win = getWindow(element);
|
||||
if (isTopLayer(element)) {
|
||||
return win;
|
||||
}
|
||||
if (!isHTMLElement(element)) {
|
||||
let svgOffsetParent = getParentNode(element);
|
||||
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
||||
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
||||
return svgOffsetParent;
|
||||
}
|
||||
svgOffsetParent = getParentNode(svgOffsetParent);
|
||||
}
|
||||
return win;
|
||||
}
|
||||
let offsetParent = getTrueOffsetParent(element, polyfill);
|
||||
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
||||
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
||||
}
|
||||
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
||||
return win;
|
||||
}
|
||||
return offsetParent || getContainingBlock(element) || win;
|
||||
}
|
||||
|
||||
const getElementRects = async function (data) {
|
||||
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
||||
const getDimensionsFn = this.getDimensions;
|
||||
const floatingDimensions = await getDimensionsFn(data.floating);
|
||||
return {
|
||||
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
||||
floating: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: floatingDimensions.width,
|
||||
height: floatingDimensions.height
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
function isRTL(element) {
|
||||
return getComputedStyle$1(element).direction === 'rtl';
|
||||
}
|
||||
|
||||
const platform = {
|
||||
convertOffsetParentRelativeRectToViewportRelativeRect,
|
||||
getDocumentElement,
|
||||
getClippingRect,
|
||||
getOffsetParent,
|
||||
getElementRects,
|
||||
getClientRects,
|
||||
getDimensions,
|
||||
getScale,
|
||||
isElement,
|
||||
isRTL
|
||||
};
|
||||
|
||||
function rectsAreEqual(a, b) {
|
||||
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
||||
}
|
||||
|
||||
// https://samthor.au/2021/observing-dom/
|
||||
function observeMove(element, onMove) {
|
||||
let io = null;
|
||||
let timeoutId;
|
||||
const root = getDocumentElement(element);
|
||||
function cleanup() {
|
||||
var _io;
|
||||
clearTimeout(timeoutId);
|
||||
(_io = io) == null || _io.disconnect();
|
||||
io = null;
|
||||
}
|
||||
function refresh(skip, threshold) {
|
||||
if (skip === void 0) {
|
||||
skip = false;
|
||||
}
|
||||
if (threshold === void 0) {
|
||||
threshold = 1;
|
||||
}
|
||||
cleanup();
|
||||
const elementRectForRootMargin = element.getBoundingClientRect();
|
||||
const {
|
||||
left,
|
||||
top,
|
||||
width,
|
||||
height
|
||||
} = elementRectForRootMargin;
|
||||
if (!skip) {
|
||||
onMove();
|
||||
}
|
||||
if (!width || !height) {
|
||||
return;
|
||||
}
|
||||
const insetTop = floor(top);
|
||||
const insetRight = floor(root.clientWidth - (left + width));
|
||||
const insetBottom = floor(root.clientHeight - (top + height));
|
||||
const insetLeft = floor(left);
|
||||
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
||||
const options = {
|
||||
rootMargin,
|
||||
threshold: max(0, min(1, threshold)) || 1
|
||||
};
|
||||
let isFirstUpdate = true;
|
||||
function handleObserve(entries) {
|
||||
const ratio = entries[0].intersectionRatio;
|
||||
if (ratio !== threshold) {
|
||||
if (!isFirstUpdate) {
|
||||
return refresh();
|
||||
}
|
||||
if (!ratio) {
|
||||
// If the reference is clipped, the ratio is 0. Throttle the refresh
|
||||
// to prevent an infinite loop of updates.
|
||||
timeoutId = setTimeout(() => {
|
||||
refresh(false, 1e-7);
|
||||
}, 1000);
|
||||
} else {
|
||||
refresh(false, ratio);
|
||||
}
|
||||
}
|
||||
if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
|
||||
// It's possible that even though the ratio is reported as 1, the
|
||||
// element is not actually fully within the IntersectionObserver's root
|
||||
// area anymore. This can happen under performance constraints. This may
|
||||
// be a bug in the browser's IntersectionObserver implementation. To
|
||||
// work around this, we compare the element's bounding rect now with
|
||||
// what it was at the time we created the IntersectionObserver. If they
|
||||
// are not equal then the element moved, so we refresh.
|
||||
refresh();
|
||||
}
|
||||
isFirstUpdate = false;
|
||||
}
|
||||
|
||||
// Older browsers don't support a `document` as the root and will throw an
|
||||
// error.
|
||||
try {
|
||||
io = new IntersectionObserver(handleObserve, {
|
||||
...options,
|
||||
// Handle <iframe>s
|
||||
root: root.ownerDocument
|
||||
});
|
||||
} catch (_e) {
|
||||
io = new IntersectionObserver(handleObserve, options);
|
||||
}
|
||||
io.observe(element);
|
||||
}
|
||||
refresh(true);
|
||||
return cleanup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically updates the position of the floating element when necessary.
|
||||
* Should only be called when the floating element is mounted on the DOM or
|
||||
* visible on the screen.
|
||||
* @returns cleanup function that should be invoked when the floating element is
|
||||
* removed from the DOM or hidden from the screen.
|
||||
* @see https://floating-ui.com/docs/autoUpdate
|
||||
*/
|
||||
function autoUpdate(reference, floating, update, options) {
|
||||
if (options === void 0) {
|
||||
options = {};
|
||||
}
|
||||
const {
|
||||
ancestorScroll = true,
|
||||
ancestorResize = true,
|
||||
elementResize = typeof ResizeObserver === 'function',
|
||||
layoutShift = typeof IntersectionObserver === 'function',
|
||||
animationFrame = false
|
||||
} = options;
|
||||
const referenceEl = unwrapElement(reference);
|
||||
const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
|
||||
ancestors.forEach(ancestor => {
|
||||
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
||||
passive: true
|
||||
});
|
||||
ancestorResize && ancestor.addEventListener('resize', update);
|
||||
});
|
||||
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
||||
let reobserveFrame = -1;
|
||||
let resizeObserver = null;
|
||||
if (elementResize) {
|
||||
resizeObserver = new ResizeObserver(_ref => {
|
||||
let [firstEntry] = _ref;
|
||||
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
||||
// Prevent update loops when using the `size` middleware.
|
||||
// https://github.com/floating-ui/floating-ui/issues/1740
|
||||
resizeObserver.unobserve(floating);
|
||||
cancelAnimationFrame(reobserveFrame);
|
||||
reobserveFrame = requestAnimationFrame(() => {
|
||||
var _resizeObserver;
|
||||
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
|
||||
});
|
||||
}
|
||||
update();
|
||||
});
|
||||
if (referenceEl && !animationFrame) {
|
||||
resizeObserver.observe(referenceEl);
|
||||
}
|
||||
resizeObserver.observe(floating);
|
||||
}
|
||||
let frameId;
|
||||
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
||||
if (animationFrame) {
|
||||
frameLoop();
|
||||
}
|
||||
function frameLoop() {
|
||||
const nextRefRect = getBoundingClientRect(reference);
|
||||
if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
|
||||
update();
|
||||
}
|
||||
prevRefRect = nextRefRect;
|
||||
frameId = requestAnimationFrame(frameLoop);
|
||||
}
|
||||
update();
|
||||
return () => {
|
||||
var _resizeObserver2;
|
||||
ancestors.forEach(ancestor => {
|
||||
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
||||
ancestorResize && ancestor.removeEventListener('resize', update);
|
||||
});
|
||||
cleanupIo == null || cleanupIo();
|
||||
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
|
||||
resizeObserver = null;
|
||||
if (animationFrame) {
|
||||
cancelAnimationFrame(frameId);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves with an object of overflow side offsets that determine how much the
|
||||
* element is overflowing a given clipping boundary on each side.
|
||||
* - positive = overflowing the boundary by that number of pixels
|
||||
* - negative = how many pixels left before it will overflow
|
||||
* - 0 = lies flush with the boundary
|
||||
* @see https://floating-ui.com/docs/detectOverflow
|
||||
*/
|
||||
const detectOverflow = detectOverflow$1;
|
||||
|
||||
/**
|
||||
* Modifies the placement by translating the floating element along the
|
||||
* specified axes.
|
||||
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
||||
* object may be passed.
|
||||
* @see https://floating-ui.com/docs/offset
|
||||
*/
|
||||
const offset = offset$1;
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by choosing the placement
|
||||
* that has the most space available automatically, without needing to specify a
|
||||
* preferred placement. Alternative to `flip`.
|
||||
* @see https://floating-ui.com/docs/autoPlacement
|
||||
*/
|
||||
const autoPlacement = autoPlacement$1;
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by shifting it in order to
|
||||
* keep it in view when it will overflow the clipping boundary.
|
||||
* @see https://floating-ui.com/docs/shift
|
||||
*/
|
||||
const shift = shift$1;
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by flipping the `placement`
|
||||
* in order to keep it in view when the preferred placement(s) will overflow the
|
||||
* clipping boundary. Alternative to `autoPlacement`.
|
||||
* @see https://floating-ui.com/docs/flip
|
||||
*/
|
||||
const flip = flip$1;
|
||||
|
||||
/**
|
||||
* Provides data that allows you to change the size of the floating element —
|
||||
* for instance, prevent it from overflowing the clipping boundary or match the
|
||||
* width of the reference element.
|
||||
* @see https://floating-ui.com/docs/size
|
||||
*/
|
||||
const size = size$1;
|
||||
|
||||
/**
|
||||
* Provides data to hide the floating element in applicable situations, such as
|
||||
* when it is not in the same clipping context as the reference element.
|
||||
* @see https://floating-ui.com/docs/hide
|
||||
*/
|
||||
const hide = hide$1;
|
||||
|
||||
/**
|
||||
* Provides data to position an inner element of the floating element so that it
|
||||
* appears centered to the reference element.
|
||||
* @see https://floating-ui.com/docs/arrow
|
||||
*/
|
||||
const arrow = arrow$1;
|
||||
|
||||
/**
|
||||
* Provides improved positioning for inline reference elements that can span
|
||||
* over multiple lines, such as hyperlinks or range selections.
|
||||
* @see https://floating-ui.com/docs/inline
|
||||
*/
|
||||
const inline = inline$1;
|
||||
|
||||
/**
|
||||
* Built-in `limiter` that will stop `shift()` at a certain point.
|
||||
*/
|
||||
const limitShift = limitShift$1;
|
||||
|
||||
/**
|
||||
* Computes the `x` and `y` coordinates that will place the floating element
|
||||
* next to a given reference element.
|
||||
*/
|
||||
const computePosition = (reference, floating, options) => {
|
||||
// This caches the expensive `getClippingElementAncestors` function so that
|
||||
// multiple lifecycle resets re-use the same result. It only lives for a
|
||||
// single call. If other functions become expensive, we can add them as well.
|
||||
const cache = new Map();
|
||||
const mergedOptions = {
|
||||
platform,
|
||||
...options
|
||||
};
|
||||
const platformWithCache = {
|
||||
...mergedOptions.platform,
|
||||
_c: cache
|
||||
};
|
||||
return computePosition$1(reference, floating, {
|
||||
...mergedOptions,
|
||||
platform: platformWithCache
|
||||
});
|
||||
};
|
||||
|
||||
export { arrow, autoPlacement, autoUpdate, computePosition, detectOverflow, flip, getOverflowAncestors, hide, inline, limitShift, offset, platform, shift, size };
|
||||
+356
@@ -0,0 +1,356 @@
|
||||
import { AlignedPlacement } from '@floating-ui/core';
|
||||
import { Alignment } from '@floating-ui/core';
|
||||
import type { ArrowOptions as ArrowOptions_2 } from '@floating-ui/core';
|
||||
import type { AutoPlacementOptions as AutoPlacementOptions_2 } from '@floating-ui/core';
|
||||
import { Axis } from '@floating-ui/core';
|
||||
import { ClientRectObject } from '@floating-ui/core';
|
||||
import type { ComputePositionConfig as ComputePositionConfig_2 } from '@floating-ui/core';
|
||||
import { ComputePositionReturn } from '@floating-ui/core';
|
||||
import { Coords } from '@floating-ui/core';
|
||||
import type { DetectOverflowOptions as DetectOverflowOptions_2 } from '@floating-ui/core';
|
||||
import { Dimensions } from '@floating-ui/core';
|
||||
import { ElementContext } from '@floating-ui/core';
|
||||
import { ElementRects } from '@floating-ui/core';
|
||||
import type { FlipOptions as FlipOptions_2 } from '@floating-ui/core';
|
||||
import { getOverflowAncestors } from '@floating-ui/utils/dom';
|
||||
import type { HideOptions as HideOptions_2 } from '@floating-ui/core';
|
||||
import { InlineOptions } from '@floating-ui/core';
|
||||
import { Length } from '@floating-ui/core';
|
||||
import { LimitShiftOptions } from '@floating-ui/core';
|
||||
import type { Middleware as Middleware_2 } from '@floating-ui/core';
|
||||
import { MiddlewareData } from '@floating-ui/core';
|
||||
import { MiddlewareReturn } from '@floating-ui/core';
|
||||
import type { MiddlewareState as MiddlewareState_2 } from '@floating-ui/core';
|
||||
import { Padding } from '@floating-ui/core';
|
||||
import { Placement } from '@floating-ui/core';
|
||||
import { Rect } from '@floating-ui/core';
|
||||
import { RootBoundary } from '@floating-ui/core';
|
||||
import type { ShiftOptions as ShiftOptions_2 } from '@floating-ui/core';
|
||||
import { Side } from '@floating-ui/core';
|
||||
import { SideObject } from '@floating-ui/core';
|
||||
import type { SizeOptions as SizeOptions_2 } from '@floating-ui/core';
|
||||
import { Strategy } from '@floating-ui/core';
|
||||
|
||||
export { AlignedPlacement }
|
||||
|
||||
export { Alignment }
|
||||
|
||||
/**
|
||||
* Provides data to position an inner element of the floating element so that it
|
||||
* appears centered to the reference element.
|
||||
* @see https://floating-ui.com/docs/arrow
|
||||
*/
|
||||
export declare const arrow: (options: ArrowOptions | Derivable<ArrowOptions>) => Middleware;
|
||||
|
||||
export declare type ArrowOptions = Prettify<Omit<ArrowOptions_2, 'element'> & {
|
||||
element: Element;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by choosing the placement
|
||||
* that has the most space available automatically, without needing to specify a
|
||||
* preferred placement. Alternative to `flip`.
|
||||
* @see https://floating-ui.com/docs/autoPlacement
|
||||
*/
|
||||
export declare const autoPlacement: (options?: AutoPlacementOptions | Derivable<AutoPlacementOptions>) => Middleware;
|
||||
|
||||
export declare type AutoPlacementOptions = Prettify<Omit<AutoPlacementOptions_2, 'boundary'> & DetectOverflowOptions>;
|
||||
|
||||
/**
|
||||
* Automatically updates the position of the floating element when necessary.
|
||||
* Should only be called when the floating element is mounted on the DOM or
|
||||
* visible on the screen.
|
||||
* @returns cleanup function that should be invoked when the floating element is
|
||||
* removed from the DOM or hidden from the screen.
|
||||
* @see https://floating-ui.com/docs/autoUpdate
|
||||
*/
|
||||
export declare function autoUpdate(reference: ReferenceElement, floating: FloatingElement, update: () => void, options?: AutoUpdateOptions): () => void;
|
||||
|
||||
export declare interface AutoUpdateOptions {
|
||||
/**
|
||||
* Whether to update the position when an overflow ancestor is scrolled.
|
||||
* @default true
|
||||
*/
|
||||
ancestorScroll?: boolean;
|
||||
/**
|
||||
* Whether to update the position when an overflow ancestor is resized. This
|
||||
* uses the native `resize` event.
|
||||
* @default true
|
||||
*/
|
||||
ancestorResize?: boolean;
|
||||
/**
|
||||
* Whether to update the position when either the reference or floating
|
||||
* elements resized. This uses a `ResizeObserver`.
|
||||
* @default true
|
||||
*/
|
||||
elementResize?: boolean;
|
||||
/**
|
||||
* Whether to update the position when the reference relocated on the screen
|
||||
* due to layout shift.
|
||||
* @default true
|
||||
*/
|
||||
layoutShift?: boolean;
|
||||
/**
|
||||
* Whether to update on every animation frame if necessary. Only use if you
|
||||
* need to update the position in response to an animation using transforms.
|
||||
* @default false
|
||||
*/
|
||||
animationFrame?: boolean;
|
||||
}
|
||||
|
||||
export { Axis }
|
||||
|
||||
/**
|
||||
* The clipping boundary area of the floating element.
|
||||
*/
|
||||
export declare type Boundary = 'clippingAncestors' | Element | Array<Element> | Rect;
|
||||
|
||||
export { ClientRectObject }
|
||||
|
||||
/**
|
||||
* Computes the `x` and `y` coordinates that will place the floating element
|
||||
* next to a given reference element.
|
||||
*/
|
||||
export declare const computePosition: (reference: ReferenceElement, floating: FloatingElement, options?: Partial<ComputePositionConfig>) => Promise<ComputePositionReturn>;
|
||||
|
||||
export declare type ComputePositionConfig = Prettify<Omit<ComputePositionConfig_2, 'middleware' | 'platform'> & {
|
||||
/**
|
||||
* Array of middleware objects to modify the positioning or provide data for
|
||||
* rendering.
|
||||
*/
|
||||
middleware?: Array<Middleware | null | undefined | false>;
|
||||
/**
|
||||
* Custom or extended platform object.
|
||||
*/
|
||||
platform?: Platform;
|
||||
}>;
|
||||
|
||||
export { ComputePositionReturn }
|
||||
|
||||
export { Coords }
|
||||
|
||||
export declare type Derivable<T> = (state: MiddlewareState) => T;
|
||||
|
||||
/**
|
||||
* Resolves with an object of overflow side offsets that determine how much the
|
||||
* element is overflowing a given clipping boundary on each side.
|
||||
* - positive = overflowing the boundary by that number of pixels
|
||||
* - negative = how many pixels left before it will overflow
|
||||
* - 0 = lies flush with the boundary
|
||||
* @see https://floating-ui.com/docs/detectOverflow
|
||||
*/
|
||||
export declare const detectOverflow: (state: MiddlewareState, options?: DetectOverflowOptions | Derivable<DetectOverflowOptions>) => Promise<SideObject>;
|
||||
|
||||
export declare type DetectOverflowOptions = Prettify<Omit<DetectOverflowOptions_2, 'boundary'> & {
|
||||
boundary?: Boundary;
|
||||
}>;
|
||||
|
||||
export { Dimensions }
|
||||
|
||||
export { ElementContext }
|
||||
|
||||
export { ElementRects }
|
||||
|
||||
export declare interface Elements {
|
||||
reference: ReferenceElement;
|
||||
floating: FloatingElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by flipping the `placement`
|
||||
* in order to keep it in view when the preferred placement(s) will overflow the
|
||||
* clipping boundary. Alternative to `autoPlacement`.
|
||||
* @see https://floating-ui.com/docs/flip
|
||||
*/
|
||||
export declare const flip: (options?: FlipOptions | Derivable<FlipOptions>) => Middleware;
|
||||
|
||||
export declare type FlipOptions = Prettify<Omit<FlipOptions_2, 'boundary'> & DetectOverflowOptions>;
|
||||
|
||||
export declare type FloatingElement = HTMLElement;
|
||||
|
||||
export { getOverflowAncestors }
|
||||
|
||||
/**
|
||||
* Provides data to hide the floating element in applicable situations, such as
|
||||
* when it is not in the same clipping context as the reference element.
|
||||
* @see https://floating-ui.com/docs/hide
|
||||
*/
|
||||
export declare const hide: (options?: HideOptions | Derivable<HideOptions>) => Middleware;
|
||||
|
||||
export declare type HideOptions = Prettify<Omit<HideOptions_2, 'boundary'> & DetectOverflowOptions>;
|
||||
|
||||
/**
|
||||
* Provides improved positioning for inline reference elements that can span
|
||||
* over multiple lines, such as hyperlinks or range selections.
|
||||
* @see https://floating-ui.com/docs/inline
|
||||
*/
|
||||
export declare const inline: (options?: InlineOptions | Derivable<InlineOptions>) => Middleware;
|
||||
|
||||
export { InlineOptions }
|
||||
|
||||
export { Length }
|
||||
|
||||
/**
|
||||
* Built-in `limiter` that will stop `shift()` at a certain point.
|
||||
*/
|
||||
export declare const limitShift: (options?: LimitShiftOptions | Derivable<LimitShiftOptions>) => {
|
||||
options: any;
|
||||
fn: (state: MiddlewareState) => Coords;
|
||||
};
|
||||
|
||||
export { LimitShiftOptions }
|
||||
|
||||
export declare type Middleware = Prettify<Omit<Middleware_2, 'fn'> & {
|
||||
fn(state: MiddlewareState): Promisable<MiddlewareReturn>;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* @deprecated use `MiddlewareState` instead.
|
||||
*/
|
||||
export declare type MiddlewareArguments = MiddlewareState;
|
||||
|
||||
export { MiddlewareData }
|
||||
|
||||
export { MiddlewareReturn }
|
||||
|
||||
export declare type MiddlewareState = Prettify<Omit<MiddlewareState_2, 'elements'> & {
|
||||
elements: Elements;
|
||||
}>;
|
||||
|
||||
export declare interface NodeScroll {
|
||||
scrollLeft: number;
|
||||
scrollTop: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies the placement by translating the floating element along the
|
||||
* specified axes.
|
||||
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
||||
* object may be passed.
|
||||
* @see https://floating-ui.com/docs/offset
|
||||
*/
|
||||
export declare const offset: (options?: OffsetOptions) => Middleware;
|
||||
|
||||
export declare type OffsetOptions = OffsetValue | Derivable<OffsetValue>;
|
||||
|
||||
declare type OffsetValue = number | {
|
||||
/**
|
||||
* The axis that runs along the side of the floating element. Represents
|
||||
* the distance (gutter or margin) between the reference and floating
|
||||
* element.
|
||||
* @default 0
|
||||
*/
|
||||
mainAxis?: number;
|
||||
/**
|
||||
* The axis that runs along the alignment of the floating element.
|
||||
* Represents the skidding between the reference and floating element.
|
||||
* @default 0
|
||||
*/
|
||||
crossAxis?: number;
|
||||
/**
|
||||
* The same axis as `crossAxis` but applies only to aligned placements
|
||||
* and inverts the `end` alignment. When set to a number, it overrides the
|
||||
* `crossAxis` value.
|
||||
*
|
||||
* A positive number will move the floating element in the direction of
|
||||
* the opposite edge to the one that is aligned, while a negative number
|
||||
* the reverse.
|
||||
* @default null
|
||||
*/
|
||||
alignmentAxis?: number | null;
|
||||
};
|
||||
|
||||
export { Padding }
|
||||
|
||||
export { Placement }
|
||||
|
||||
export declare interface Platform {
|
||||
getElementRects: (args: {
|
||||
reference: ReferenceElement;
|
||||
floating: FloatingElement;
|
||||
strategy: Strategy;
|
||||
}) => Promisable<ElementRects>;
|
||||
getClippingRect: (args: {
|
||||
element: Element;
|
||||
boundary: Boundary;
|
||||
rootBoundary: RootBoundary;
|
||||
strategy: Strategy;
|
||||
}) => Promisable<Rect>;
|
||||
getDimensions: (element: Element) => Promisable<Dimensions>;
|
||||
convertOffsetParentRelativeRectToViewportRelativeRect: (args: {
|
||||
elements?: Elements;
|
||||
rect: Rect;
|
||||
offsetParent: Element;
|
||||
strategy: Strategy;
|
||||
}) => Promisable<Rect>;
|
||||
getOffsetParent: (element: Element, polyfill?: (element: HTMLElement) => Element | null) => Promisable<Element | Window>;
|
||||
isElement: (value: unknown) => Promisable<boolean>;
|
||||
getDocumentElement: (element: Element) => Promisable<HTMLElement>;
|
||||
getClientRects: (element: Element) => Promisable<Array<ClientRectObject>>;
|
||||
isRTL: (element: Element) => Promisable<boolean>;
|
||||
getScale: (element: HTMLElement) => Promisable<{
|
||||
x: number;
|
||||
y: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
export declare const platform: Platform;
|
||||
|
||||
declare type Prettify<T> = {
|
||||
[K in keyof T]: T[K];
|
||||
} & {};
|
||||
|
||||
declare type Promisable<T> = T | Promise<T>;
|
||||
|
||||
export { Rect }
|
||||
|
||||
export declare type ReferenceElement = Element | VirtualElement;
|
||||
|
||||
export { RootBoundary }
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by shifting it in order to
|
||||
* keep it in view when it will overflow the clipping boundary.
|
||||
* @see https://floating-ui.com/docs/shift
|
||||
*/
|
||||
export declare const shift: (options?: ShiftOptions | Derivable<ShiftOptions>) => Middleware;
|
||||
|
||||
export declare type ShiftOptions = Prettify<Omit<ShiftOptions_2, 'boundary'> & DetectOverflowOptions>;
|
||||
|
||||
export { Side }
|
||||
|
||||
export { SideObject }
|
||||
|
||||
/**
|
||||
* Provides data that allows you to change the size of the floating element —
|
||||
* for instance, prevent it from overflowing the clipping boundary or match the
|
||||
* width of the reference element.
|
||||
* @see https://floating-ui.com/docs/size
|
||||
*/
|
||||
export declare const size: (options?: SizeOptions | Derivable<SizeOptions>) => Middleware;
|
||||
|
||||
export declare type SizeOptions = Prettify<Omit<SizeOptions_2, 'apply' | 'boundary'> & DetectOverflowOptions & {
|
||||
/**
|
||||
* Function that is called to perform style mutations to the floating element
|
||||
* to change its size.
|
||||
* @default undefined
|
||||
*/
|
||||
apply?(args: MiddlewareState & {
|
||||
availableWidth: number;
|
||||
availableHeight: number;
|
||||
}): Promisable<void>;
|
||||
}>;
|
||||
|
||||
export { Strategy }
|
||||
|
||||
/**
|
||||
* Custom positioning reference element.
|
||||
* @see https://floating-ui.com/docs/virtual-elements
|
||||
*/
|
||||
export declare interface VirtualElement {
|
||||
getBoundingClientRect(): ClientRectObject;
|
||||
getClientRects?(): Array<ClientRectObject> | DOMRectList;
|
||||
contextElement?: Element;
|
||||
}
|
||||
|
||||
export { }
|
||||
+356
@@ -0,0 +1,356 @@
|
||||
import { AlignedPlacement } from '@floating-ui/core';
|
||||
import { Alignment } from '@floating-ui/core';
|
||||
import type { ArrowOptions as ArrowOptions_2 } from '@floating-ui/core';
|
||||
import type { AutoPlacementOptions as AutoPlacementOptions_2 } from '@floating-ui/core';
|
||||
import { Axis } from '@floating-ui/core';
|
||||
import { ClientRectObject } from '@floating-ui/core';
|
||||
import type { ComputePositionConfig as ComputePositionConfig_2 } from '@floating-ui/core';
|
||||
import { ComputePositionReturn } from '@floating-ui/core';
|
||||
import { Coords } from '@floating-ui/core';
|
||||
import type { DetectOverflowOptions as DetectOverflowOptions_2 } from '@floating-ui/core';
|
||||
import { Dimensions } from '@floating-ui/core';
|
||||
import { ElementContext } from '@floating-ui/core';
|
||||
import { ElementRects } from '@floating-ui/core';
|
||||
import type { FlipOptions as FlipOptions_2 } from '@floating-ui/core';
|
||||
import { getOverflowAncestors } from '@floating-ui/utils/dom';
|
||||
import type { HideOptions as HideOptions_2 } from '@floating-ui/core';
|
||||
import { InlineOptions } from '@floating-ui/core';
|
||||
import { Length } from '@floating-ui/core';
|
||||
import { LimitShiftOptions } from '@floating-ui/core';
|
||||
import type { Middleware as Middleware_2 } from '@floating-ui/core';
|
||||
import { MiddlewareData } from '@floating-ui/core';
|
||||
import { MiddlewareReturn } from '@floating-ui/core';
|
||||
import type { MiddlewareState as MiddlewareState_2 } from '@floating-ui/core';
|
||||
import { Padding } from '@floating-ui/core';
|
||||
import { Placement } from '@floating-ui/core';
|
||||
import { Rect } from '@floating-ui/core';
|
||||
import { RootBoundary } from '@floating-ui/core';
|
||||
import type { ShiftOptions as ShiftOptions_2 } from '@floating-ui/core';
|
||||
import { Side } from '@floating-ui/core';
|
||||
import { SideObject } from '@floating-ui/core';
|
||||
import type { SizeOptions as SizeOptions_2 } from '@floating-ui/core';
|
||||
import { Strategy } from '@floating-ui/core';
|
||||
|
||||
export { AlignedPlacement }
|
||||
|
||||
export { Alignment }
|
||||
|
||||
/**
|
||||
* Provides data to position an inner element of the floating element so that it
|
||||
* appears centered to the reference element.
|
||||
* @see https://floating-ui.com/docs/arrow
|
||||
*/
|
||||
export declare const arrow: (options: ArrowOptions | Derivable<ArrowOptions>) => Middleware;
|
||||
|
||||
export declare type ArrowOptions = Prettify<Omit<ArrowOptions_2, 'element'> & {
|
||||
element: Element;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by choosing the placement
|
||||
* that has the most space available automatically, without needing to specify a
|
||||
* preferred placement. Alternative to `flip`.
|
||||
* @see https://floating-ui.com/docs/autoPlacement
|
||||
*/
|
||||
export declare const autoPlacement: (options?: AutoPlacementOptions | Derivable<AutoPlacementOptions>) => Middleware;
|
||||
|
||||
export declare type AutoPlacementOptions = Prettify<Omit<AutoPlacementOptions_2, 'boundary'> & DetectOverflowOptions>;
|
||||
|
||||
/**
|
||||
* Automatically updates the position of the floating element when necessary.
|
||||
* Should only be called when the floating element is mounted on the DOM or
|
||||
* visible on the screen.
|
||||
* @returns cleanup function that should be invoked when the floating element is
|
||||
* removed from the DOM or hidden from the screen.
|
||||
* @see https://floating-ui.com/docs/autoUpdate
|
||||
*/
|
||||
export declare function autoUpdate(reference: ReferenceElement, floating: FloatingElement, update: () => void, options?: AutoUpdateOptions): () => void;
|
||||
|
||||
export declare interface AutoUpdateOptions {
|
||||
/**
|
||||
* Whether to update the position when an overflow ancestor is scrolled.
|
||||
* @default true
|
||||
*/
|
||||
ancestorScroll?: boolean;
|
||||
/**
|
||||
* Whether to update the position when an overflow ancestor is resized. This
|
||||
* uses the native `resize` event.
|
||||
* @default true
|
||||
*/
|
||||
ancestorResize?: boolean;
|
||||
/**
|
||||
* Whether to update the position when either the reference or floating
|
||||
* elements resized. This uses a `ResizeObserver`.
|
||||
* @default true
|
||||
*/
|
||||
elementResize?: boolean;
|
||||
/**
|
||||
* Whether to update the position when the reference relocated on the screen
|
||||
* due to layout shift.
|
||||
* @default true
|
||||
*/
|
||||
layoutShift?: boolean;
|
||||
/**
|
||||
* Whether to update on every animation frame if necessary. Only use if you
|
||||
* need to update the position in response to an animation using transforms.
|
||||
* @default false
|
||||
*/
|
||||
animationFrame?: boolean;
|
||||
}
|
||||
|
||||
export { Axis }
|
||||
|
||||
/**
|
||||
* The clipping boundary area of the floating element.
|
||||
*/
|
||||
export declare type Boundary = 'clippingAncestors' | Element | Array<Element> | Rect;
|
||||
|
||||
export { ClientRectObject }
|
||||
|
||||
/**
|
||||
* Computes the `x` and `y` coordinates that will place the floating element
|
||||
* next to a given reference element.
|
||||
*/
|
||||
export declare const computePosition: (reference: ReferenceElement, floating: FloatingElement, options?: Partial<ComputePositionConfig>) => Promise<ComputePositionReturn>;
|
||||
|
||||
export declare type ComputePositionConfig = Prettify<Omit<ComputePositionConfig_2, 'middleware' | 'platform'> & {
|
||||
/**
|
||||
* Array of middleware objects to modify the positioning or provide data for
|
||||
* rendering.
|
||||
*/
|
||||
middleware?: Array<Middleware | null | undefined | false>;
|
||||
/**
|
||||
* Custom or extended platform object.
|
||||
*/
|
||||
platform?: Platform;
|
||||
}>;
|
||||
|
||||
export { ComputePositionReturn }
|
||||
|
||||
export { Coords }
|
||||
|
||||
export declare type Derivable<T> = (state: MiddlewareState) => T;
|
||||
|
||||
/**
|
||||
* Resolves with an object of overflow side offsets that determine how much the
|
||||
* element is overflowing a given clipping boundary on each side.
|
||||
* - positive = overflowing the boundary by that number of pixels
|
||||
* - negative = how many pixels left before it will overflow
|
||||
* - 0 = lies flush with the boundary
|
||||
* @see https://floating-ui.com/docs/detectOverflow
|
||||
*/
|
||||
export declare const detectOverflow: (state: MiddlewareState, options?: DetectOverflowOptions | Derivable<DetectOverflowOptions>) => Promise<SideObject>;
|
||||
|
||||
export declare type DetectOverflowOptions = Prettify<Omit<DetectOverflowOptions_2, 'boundary'> & {
|
||||
boundary?: Boundary;
|
||||
}>;
|
||||
|
||||
export { Dimensions }
|
||||
|
||||
export { ElementContext }
|
||||
|
||||
export { ElementRects }
|
||||
|
||||
export declare interface Elements {
|
||||
reference: ReferenceElement;
|
||||
floating: FloatingElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by flipping the `placement`
|
||||
* in order to keep it in view when the preferred placement(s) will overflow the
|
||||
* clipping boundary. Alternative to `autoPlacement`.
|
||||
* @see https://floating-ui.com/docs/flip
|
||||
*/
|
||||
export declare const flip: (options?: FlipOptions | Derivable<FlipOptions>) => Middleware;
|
||||
|
||||
export declare type FlipOptions = Prettify<Omit<FlipOptions_2, 'boundary'> & DetectOverflowOptions>;
|
||||
|
||||
export declare type FloatingElement = HTMLElement;
|
||||
|
||||
export { getOverflowAncestors }
|
||||
|
||||
/**
|
||||
* Provides data to hide the floating element in applicable situations, such as
|
||||
* when it is not in the same clipping context as the reference element.
|
||||
* @see https://floating-ui.com/docs/hide
|
||||
*/
|
||||
export declare const hide: (options?: HideOptions | Derivable<HideOptions>) => Middleware;
|
||||
|
||||
export declare type HideOptions = Prettify<Omit<HideOptions_2, 'boundary'> & DetectOverflowOptions>;
|
||||
|
||||
/**
|
||||
* Provides improved positioning for inline reference elements that can span
|
||||
* over multiple lines, such as hyperlinks or range selections.
|
||||
* @see https://floating-ui.com/docs/inline
|
||||
*/
|
||||
export declare const inline: (options?: InlineOptions | Derivable<InlineOptions>) => Middleware;
|
||||
|
||||
export { InlineOptions }
|
||||
|
||||
export { Length }
|
||||
|
||||
/**
|
||||
* Built-in `limiter` that will stop `shift()` at a certain point.
|
||||
*/
|
||||
export declare const limitShift: (options?: LimitShiftOptions | Derivable<LimitShiftOptions>) => {
|
||||
options: any;
|
||||
fn: (state: MiddlewareState) => Coords;
|
||||
};
|
||||
|
||||
export { LimitShiftOptions }
|
||||
|
||||
export declare type Middleware = Prettify<Omit<Middleware_2, 'fn'> & {
|
||||
fn(state: MiddlewareState): Promisable<MiddlewareReturn>;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* @deprecated use `MiddlewareState` instead.
|
||||
*/
|
||||
export declare type MiddlewareArguments = MiddlewareState;
|
||||
|
||||
export { MiddlewareData }
|
||||
|
||||
export { MiddlewareReturn }
|
||||
|
||||
export declare type MiddlewareState = Prettify<Omit<MiddlewareState_2, 'elements'> & {
|
||||
elements: Elements;
|
||||
}>;
|
||||
|
||||
export declare interface NodeScroll {
|
||||
scrollLeft: number;
|
||||
scrollTop: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies the placement by translating the floating element along the
|
||||
* specified axes.
|
||||
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
||||
* object may be passed.
|
||||
* @see https://floating-ui.com/docs/offset
|
||||
*/
|
||||
export declare const offset: (options?: OffsetOptions) => Middleware;
|
||||
|
||||
export declare type OffsetOptions = OffsetValue | Derivable<OffsetValue>;
|
||||
|
||||
declare type OffsetValue = number | {
|
||||
/**
|
||||
* The axis that runs along the side of the floating element. Represents
|
||||
* the distance (gutter or margin) between the reference and floating
|
||||
* element.
|
||||
* @default 0
|
||||
*/
|
||||
mainAxis?: number;
|
||||
/**
|
||||
* The axis that runs along the alignment of the floating element.
|
||||
* Represents the skidding between the reference and floating element.
|
||||
* @default 0
|
||||
*/
|
||||
crossAxis?: number;
|
||||
/**
|
||||
* The same axis as `crossAxis` but applies only to aligned placements
|
||||
* and inverts the `end` alignment. When set to a number, it overrides the
|
||||
* `crossAxis` value.
|
||||
*
|
||||
* A positive number will move the floating element in the direction of
|
||||
* the opposite edge to the one that is aligned, while a negative number
|
||||
* the reverse.
|
||||
* @default null
|
||||
*/
|
||||
alignmentAxis?: number | null;
|
||||
};
|
||||
|
||||
export { Padding }
|
||||
|
||||
export { Placement }
|
||||
|
||||
export declare interface Platform {
|
||||
getElementRects: (args: {
|
||||
reference: ReferenceElement;
|
||||
floating: FloatingElement;
|
||||
strategy: Strategy;
|
||||
}) => Promisable<ElementRects>;
|
||||
getClippingRect: (args: {
|
||||
element: Element;
|
||||
boundary: Boundary;
|
||||
rootBoundary: RootBoundary;
|
||||
strategy: Strategy;
|
||||
}) => Promisable<Rect>;
|
||||
getDimensions: (element: Element) => Promisable<Dimensions>;
|
||||
convertOffsetParentRelativeRectToViewportRelativeRect: (args: {
|
||||
elements?: Elements;
|
||||
rect: Rect;
|
||||
offsetParent: Element;
|
||||
strategy: Strategy;
|
||||
}) => Promisable<Rect>;
|
||||
getOffsetParent: (element: Element, polyfill?: (element: HTMLElement) => Element | null) => Promisable<Element | Window>;
|
||||
isElement: (value: unknown) => Promisable<boolean>;
|
||||
getDocumentElement: (element: Element) => Promisable<HTMLElement>;
|
||||
getClientRects: (element: Element) => Promisable<Array<ClientRectObject>>;
|
||||
isRTL: (element: Element) => Promisable<boolean>;
|
||||
getScale: (element: HTMLElement) => Promisable<{
|
||||
x: number;
|
||||
y: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
export declare const platform: Platform;
|
||||
|
||||
declare type Prettify<T> = {
|
||||
[K in keyof T]: T[K];
|
||||
} & {};
|
||||
|
||||
declare type Promisable<T> = T | Promise<T>;
|
||||
|
||||
export { Rect }
|
||||
|
||||
export declare type ReferenceElement = Element | VirtualElement;
|
||||
|
||||
export { RootBoundary }
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by shifting it in order to
|
||||
* keep it in view when it will overflow the clipping boundary.
|
||||
* @see https://floating-ui.com/docs/shift
|
||||
*/
|
||||
export declare const shift: (options?: ShiftOptions | Derivable<ShiftOptions>) => Middleware;
|
||||
|
||||
export declare type ShiftOptions = Prettify<Omit<ShiftOptions_2, 'boundary'> & DetectOverflowOptions>;
|
||||
|
||||
export { Side }
|
||||
|
||||
export { SideObject }
|
||||
|
||||
/**
|
||||
* Provides data that allows you to change the size of the floating element —
|
||||
* for instance, prevent it from overflowing the clipping boundary or match the
|
||||
* width of the reference element.
|
||||
* @see https://floating-ui.com/docs/size
|
||||
*/
|
||||
export declare const size: (options?: SizeOptions | Derivable<SizeOptions>) => Middleware;
|
||||
|
||||
export declare type SizeOptions = Prettify<Omit<SizeOptions_2, 'apply' | 'boundary'> & DetectOverflowOptions & {
|
||||
/**
|
||||
* Function that is called to perform style mutations to the floating element
|
||||
* to change its size.
|
||||
* @default undefined
|
||||
*/
|
||||
apply?(args: MiddlewareState & {
|
||||
availableWidth: number;
|
||||
availableHeight: number;
|
||||
}): Promisable<void>;
|
||||
}>;
|
||||
|
||||
export { Strategy }
|
||||
|
||||
/**
|
||||
* Custom positioning reference element.
|
||||
* @see https://floating-ui.com/docs/virtual-elements
|
||||
*/
|
||||
export declare interface VirtualElement {
|
||||
getBoundingClientRect(): ClientRectObject;
|
||||
getClientRects?(): Array<ClientRectObject> | DOMRectList;
|
||||
contextElement?: Element;
|
||||
}
|
||||
|
||||
export { }
|
||||
+777
@@ -0,0 +1,777 @@
|
||||
import { rectToClientRect, arrow as arrow$1, autoPlacement as autoPlacement$1, detectOverflow as detectOverflow$1, flip as flip$1, hide as hide$1, inline as inline$1, limitShift as limitShift$1, offset as offset$1, shift as shift$1, size as size$1, computePosition as computePosition$1 } from '@floating-ui/core';
|
||||
import { round, createCoords, max, min, floor } from '@floating-ui/utils';
|
||||
import { getComputedStyle as getComputedStyle$1, isHTMLElement, isElement, getWindow, isWebKit, getFrameElement, getNodeScroll, getDocumentElement, isTopLayer, getNodeName, isOverflowElement, getOverflowAncestors, getParentNode, isLastTraversableNode, isContainingBlock, isTableElement, getContainingBlock } from '@floating-ui/utils/dom';
|
||||
export { getOverflowAncestors } from '@floating-ui/utils/dom';
|
||||
|
||||
function getCssDimensions(element) {
|
||||
const css = getComputedStyle$1(element);
|
||||
// In testing environments, the `width` and `height` properties are empty
|
||||
// strings for SVG elements, returning NaN. Fallback to `0` in this case.
|
||||
let width = parseFloat(css.width) || 0;
|
||||
let height = parseFloat(css.height) || 0;
|
||||
const hasOffset = isHTMLElement(element);
|
||||
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
||||
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
||||
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
||||
if (shouldFallback) {
|
||||
width = offsetWidth;
|
||||
height = offsetHeight;
|
||||
}
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
$: shouldFallback
|
||||
};
|
||||
}
|
||||
|
||||
function unwrapElement(element) {
|
||||
return !isElement(element) ? element.contextElement : element;
|
||||
}
|
||||
|
||||
function getScale(element) {
|
||||
const domElement = unwrapElement(element);
|
||||
if (!isHTMLElement(domElement)) {
|
||||
return createCoords(1);
|
||||
}
|
||||
const rect = domElement.getBoundingClientRect();
|
||||
const {
|
||||
width,
|
||||
height,
|
||||
$
|
||||
} = getCssDimensions(domElement);
|
||||
let x = ($ ? round(rect.width) : rect.width) / width;
|
||||
let y = ($ ? round(rect.height) : rect.height) / height;
|
||||
|
||||
// 0, NaN, or Infinity should always fallback to 1.
|
||||
|
||||
if (!x || !Number.isFinite(x)) {
|
||||
x = 1;
|
||||
}
|
||||
if (!y || !Number.isFinite(y)) {
|
||||
y = 1;
|
||||
}
|
||||
return {
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
const noOffsets = /*#__PURE__*/createCoords(0);
|
||||
function getVisualOffsets(element) {
|
||||
const win = getWindow(element);
|
||||
if (!isWebKit() || !win.visualViewport) {
|
||||
return noOffsets;
|
||||
}
|
||||
return {
|
||||
x: win.visualViewport.offsetLeft,
|
||||
y: win.visualViewport.offsetTop
|
||||
};
|
||||
}
|
||||
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
||||
if (isFixed === void 0) {
|
||||
isFixed = false;
|
||||
}
|
||||
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
||||
return false;
|
||||
}
|
||||
return isFixed;
|
||||
}
|
||||
|
||||
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
||||
if (includeScale === void 0) {
|
||||
includeScale = false;
|
||||
}
|
||||
if (isFixedStrategy === void 0) {
|
||||
isFixedStrategy = false;
|
||||
}
|
||||
const clientRect = element.getBoundingClientRect();
|
||||
const domElement = unwrapElement(element);
|
||||
let scale = createCoords(1);
|
||||
if (includeScale) {
|
||||
if (offsetParent) {
|
||||
if (isElement(offsetParent)) {
|
||||
scale = getScale(offsetParent);
|
||||
}
|
||||
} else {
|
||||
scale = getScale(element);
|
||||
}
|
||||
}
|
||||
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
||||
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
||||
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
||||
let width = clientRect.width / scale.x;
|
||||
let height = clientRect.height / scale.y;
|
||||
if (domElement) {
|
||||
const win = getWindow(domElement);
|
||||
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
||||
let currentWin = win;
|
||||
let currentIFrame = getFrameElement(currentWin);
|
||||
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
||||
const iframeScale = getScale(currentIFrame);
|
||||
const iframeRect = currentIFrame.getBoundingClientRect();
|
||||
const css = getComputedStyle$1(currentIFrame);
|
||||
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
||||
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
||||
x *= iframeScale.x;
|
||||
y *= iframeScale.y;
|
||||
width *= iframeScale.x;
|
||||
height *= iframeScale.y;
|
||||
x += left;
|
||||
y += top;
|
||||
currentWin = getWindow(currentIFrame);
|
||||
currentIFrame = getFrameElement(currentWin);
|
||||
}
|
||||
}
|
||||
return rectToClientRect({
|
||||
width,
|
||||
height,
|
||||
x,
|
||||
y
|
||||
});
|
||||
}
|
||||
|
||||
// If <html> has a CSS width greater than the viewport, then this will be
|
||||
// incorrect for RTL.
|
||||
function getWindowScrollBarX(element, rect) {
|
||||
const leftScroll = getNodeScroll(element).scrollLeft;
|
||||
if (!rect) {
|
||||
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
||||
}
|
||||
return rect.left + leftScroll;
|
||||
}
|
||||
|
||||
function getHTMLOffset(documentElement, scroll) {
|
||||
const htmlRect = documentElement.getBoundingClientRect();
|
||||
const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
|
||||
const y = htmlRect.top + scroll.scrollTop;
|
||||
return {
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
||||
let {
|
||||
elements,
|
||||
rect,
|
||||
offsetParent,
|
||||
strategy
|
||||
} = _ref;
|
||||
const isFixed = strategy === 'fixed';
|
||||
const documentElement = getDocumentElement(offsetParent);
|
||||
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
||||
if (offsetParent === documentElement || topLayer && isFixed) {
|
||||
return rect;
|
||||
}
|
||||
let scroll = {
|
||||
scrollLeft: 0,
|
||||
scrollTop: 0
|
||||
};
|
||||
let scale = createCoords(1);
|
||||
const offsets = createCoords(0);
|
||||
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
||||
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
||||
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
||||
scroll = getNodeScroll(offsetParent);
|
||||
}
|
||||
if (isHTMLElement(offsetParent)) {
|
||||
const offsetRect = getBoundingClientRect(offsetParent);
|
||||
scale = getScale(offsetParent);
|
||||
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
||||
offsets.y = offsetRect.y + offsetParent.clientTop;
|
||||
}
|
||||
}
|
||||
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
||||
return {
|
||||
width: rect.width * scale.x,
|
||||
height: rect.height * scale.y,
|
||||
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
||||
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
||||
};
|
||||
}
|
||||
|
||||
function getClientRects(element) {
|
||||
return Array.from(element.getClientRects());
|
||||
}
|
||||
|
||||
// Gets the entire size of the scrollable document area, even extending outside
|
||||
// of the `<html>` and `<body>` rect bounds if horizontally scrollable.
|
||||
function getDocumentRect(element) {
|
||||
const html = getDocumentElement(element);
|
||||
const scroll = getNodeScroll(element);
|
||||
const body = element.ownerDocument.body;
|
||||
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
||||
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
||||
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
||||
const y = -scroll.scrollTop;
|
||||
if (getComputedStyle$1(body).direction === 'rtl') {
|
||||
x += max(html.clientWidth, body.clientWidth) - width;
|
||||
}
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
// Safety check: ensure the scrollbar space is reasonable in case this
|
||||
// calculation is affected by unusual styles.
|
||||
// Most scrollbars leave 15-18px of space.
|
||||
const SCROLLBAR_MAX = 25;
|
||||
function getViewportRect(element, strategy) {
|
||||
const win = getWindow(element);
|
||||
const html = getDocumentElement(element);
|
||||
const visualViewport = win.visualViewport;
|
||||
let width = html.clientWidth;
|
||||
let height = html.clientHeight;
|
||||
let x = 0;
|
||||
let y = 0;
|
||||
if (visualViewport) {
|
||||
width = visualViewport.width;
|
||||
height = visualViewport.height;
|
||||
const visualViewportBased = isWebKit();
|
||||
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
|
||||
x = visualViewport.offsetLeft;
|
||||
y = visualViewport.offsetTop;
|
||||
}
|
||||
}
|
||||
const windowScrollbarX = getWindowScrollBarX(html);
|
||||
// <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
|
||||
// visual width of the <html> but this is not considered in the size
|
||||
// of `html.clientWidth`.
|
||||
if (windowScrollbarX <= 0) {
|
||||
const doc = html.ownerDocument;
|
||||
const body = doc.body;
|
||||
const bodyStyles = getComputedStyle(body);
|
||||
const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
|
||||
const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
|
||||
if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
|
||||
width -= clippingStableScrollbarWidth;
|
||||
}
|
||||
} else if (windowScrollbarX <= SCROLLBAR_MAX) {
|
||||
// If the <body> scrollbar is on the left, the width needs to be extended
|
||||
// by the scrollbar amount so there isn't extra space on the right.
|
||||
width += windowScrollbarX;
|
||||
}
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
const absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);
|
||||
// Returns the inner client rect, subtracting scrollbars if present.
|
||||
function getInnerBoundingClientRect(element, strategy) {
|
||||
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
||||
const top = clientRect.top + element.clientTop;
|
||||
const left = clientRect.left + element.clientLeft;
|
||||
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
||||
const width = element.clientWidth * scale.x;
|
||||
const height = element.clientHeight * scale.y;
|
||||
const x = left * scale.x;
|
||||
const y = top * scale.y;
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
||||
let rect;
|
||||
if (clippingAncestor === 'viewport') {
|
||||
rect = getViewportRect(element, strategy);
|
||||
} else if (clippingAncestor === 'document') {
|
||||
rect = getDocumentRect(getDocumentElement(element));
|
||||
} else if (isElement(clippingAncestor)) {
|
||||
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
||||
} else {
|
||||
const visualOffsets = getVisualOffsets(element);
|
||||
rect = {
|
||||
x: clippingAncestor.x - visualOffsets.x,
|
||||
y: clippingAncestor.y - visualOffsets.y,
|
||||
width: clippingAncestor.width,
|
||||
height: clippingAncestor.height
|
||||
};
|
||||
}
|
||||
return rectToClientRect(rect);
|
||||
}
|
||||
function hasFixedPositionAncestor(element, stopNode) {
|
||||
const parentNode = getParentNode(element);
|
||||
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
||||
return false;
|
||||
}
|
||||
return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
|
||||
}
|
||||
|
||||
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
||||
// clipping (or hiding) child elements. This returns all clipping ancestors
|
||||
// of the given element up the tree.
|
||||
function getClippingElementAncestors(element, cache) {
|
||||
const cachedResult = cache.get(element);
|
||||
if (cachedResult) {
|
||||
return cachedResult;
|
||||
}
|
||||
let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
||||
let currentContainingBlockComputedStyle = null;
|
||||
const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
|
||||
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
||||
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
||||
const computedStyle = getComputedStyle$1(currentNode);
|
||||
const currentNodeIsContaining = isContainingBlock(currentNode);
|
||||
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
||||
currentContainingBlockComputedStyle = null;
|
||||
}
|
||||
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
||||
if (shouldDropCurrentNode) {
|
||||
// Drop non-containing blocks.
|
||||
result = result.filter(ancestor => ancestor !== currentNode);
|
||||
} else {
|
||||
// Record last containing block for next iteration.
|
||||
currentContainingBlockComputedStyle = computedStyle;
|
||||
}
|
||||
currentNode = getParentNode(currentNode);
|
||||
}
|
||||
cache.set(element, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Gets the maximum area that the element is visible in due to any number of
|
||||
// clipping ancestors.
|
||||
function getClippingRect(_ref) {
|
||||
let {
|
||||
element,
|
||||
boundary,
|
||||
rootBoundary,
|
||||
strategy
|
||||
} = _ref;
|
||||
const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
||||
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
||||
const firstClippingAncestor = clippingAncestors[0];
|
||||
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
||||
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
||||
accRect.top = max(rect.top, accRect.top);
|
||||
accRect.right = min(rect.right, accRect.right);
|
||||
accRect.bottom = min(rect.bottom, accRect.bottom);
|
||||
accRect.left = max(rect.left, accRect.left);
|
||||
return accRect;
|
||||
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
||||
return {
|
||||
width: clippingRect.right - clippingRect.left,
|
||||
height: clippingRect.bottom - clippingRect.top,
|
||||
x: clippingRect.left,
|
||||
y: clippingRect.top
|
||||
};
|
||||
}
|
||||
|
||||
function getDimensions(element) {
|
||||
const {
|
||||
width,
|
||||
height
|
||||
} = getCssDimensions(element);
|
||||
return {
|
||||
width,
|
||||
height
|
||||
};
|
||||
}
|
||||
|
||||
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
||||
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
||||
const documentElement = getDocumentElement(offsetParent);
|
||||
const isFixed = strategy === 'fixed';
|
||||
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
||||
let scroll = {
|
||||
scrollLeft: 0,
|
||||
scrollTop: 0
|
||||
};
|
||||
const offsets = createCoords(0);
|
||||
|
||||
// If the <body> scrollbar appears on the left (e.g. RTL systems). Use
|
||||
// Firefox with layout.scrollbar.side = 3 in about:config to test this.
|
||||
function setLeftRTLScrollbarOffset() {
|
||||
offsets.x = getWindowScrollBarX(documentElement);
|
||||
}
|
||||
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
||||
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
||||
scroll = getNodeScroll(offsetParent);
|
||||
}
|
||||
if (isOffsetParentAnElement) {
|
||||
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
||||
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
||||
offsets.y = offsetRect.y + offsetParent.clientTop;
|
||||
} else if (documentElement) {
|
||||
setLeftRTLScrollbarOffset();
|
||||
}
|
||||
}
|
||||
if (isFixed && !isOffsetParentAnElement && documentElement) {
|
||||
setLeftRTLScrollbarOffset();
|
||||
}
|
||||
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
||||
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
||||
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
||||
return {
|
||||
x,
|
||||
y,
|
||||
width: rect.width,
|
||||
height: rect.height
|
||||
};
|
||||
}
|
||||
|
||||
function isStaticPositioned(element) {
|
||||
return getComputedStyle$1(element).position === 'static';
|
||||
}
|
||||
|
||||
function getTrueOffsetParent(element, polyfill) {
|
||||
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
|
||||
return null;
|
||||
}
|
||||
if (polyfill) {
|
||||
return polyfill(element);
|
||||
}
|
||||
let rawOffsetParent = element.offsetParent;
|
||||
|
||||
// Firefox returns the <html> element as the offsetParent if it's non-static,
|
||||
// while Chrome and Safari return the <body> element. The <body> element must
|
||||
// be used to perform the correct calculations even if the <html> element is
|
||||
// non-static.
|
||||
if (getDocumentElement(element) === rawOffsetParent) {
|
||||
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
||||
}
|
||||
return rawOffsetParent;
|
||||
}
|
||||
|
||||
// Gets the closest ancestor positioned element. Handles some edge cases,
|
||||
// such as table ancestors and cross browser bugs.
|
||||
function getOffsetParent(element, polyfill) {
|
||||
const win = getWindow(element);
|
||||
if (isTopLayer(element)) {
|
||||
return win;
|
||||
}
|
||||
if (!isHTMLElement(element)) {
|
||||
let svgOffsetParent = getParentNode(element);
|
||||
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
||||
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
||||
return svgOffsetParent;
|
||||
}
|
||||
svgOffsetParent = getParentNode(svgOffsetParent);
|
||||
}
|
||||
return win;
|
||||
}
|
||||
let offsetParent = getTrueOffsetParent(element, polyfill);
|
||||
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
||||
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
||||
}
|
||||
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
||||
return win;
|
||||
}
|
||||
return offsetParent || getContainingBlock(element) || win;
|
||||
}
|
||||
|
||||
const getElementRects = async function (data) {
|
||||
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
||||
const getDimensionsFn = this.getDimensions;
|
||||
const floatingDimensions = await getDimensionsFn(data.floating);
|
||||
return {
|
||||
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
||||
floating: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: floatingDimensions.width,
|
||||
height: floatingDimensions.height
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
function isRTL(element) {
|
||||
return getComputedStyle$1(element).direction === 'rtl';
|
||||
}
|
||||
|
||||
const platform = {
|
||||
convertOffsetParentRelativeRectToViewportRelativeRect,
|
||||
getDocumentElement,
|
||||
getClippingRect,
|
||||
getOffsetParent,
|
||||
getElementRects,
|
||||
getClientRects,
|
||||
getDimensions,
|
||||
getScale,
|
||||
isElement,
|
||||
isRTL
|
||||
};
|
||||
|
||||
function rectsAreEqual(a, b) {
|
||||
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
||||
}
|
||||
|
||||
// https://samthor.au/2021/observing-dom/
|
||||
function observeMove(element, onMove) {
|
||||
let io = null;
|
||||
let timeoutId;
|
||||
const root = getDocumentElement(element);
|
||||
function cleanup() {
|
||||
var _io;
|
||||
clearTimeout(timeoutId);
|
||||
(_io = io) == null || _io.disconnect();
|
||||
io = null;
|
||||
}
|
||||
function refresh(skip, threshold) {
|
||||
if (skip === void 0) {
|
||||
skip = false;
|
||||
}
|
||||
if (threshold === void 0) {
|
||||
threshold = 1;
|
||||
}
|
||||
cleanup();
|
||||
const elementRectForRootMargin = element.getBoundingClientRect();
|
||||
const {
|
||||
left,
|
||||
top,
|
||||
width,
|
||||
height
|
||||
} = elementRectForRootMargin;
|
||||
if (!skip) {
|
||||
onMove();
|
||||
}
|
||||
if (!width || !height) {
|
||||
return;
|
||||
}
|
||||
const insetTop = floor(top);
|
||||
const insetRight = floor(root.clientWidth - (left + width));
|
||||
const insetBottom = floor(root.clientHeight - (top + height));
|
||||
const insetLeft = floor(left);
|
||||
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
||||
const options = {
|
||||
rootMargin,
|
||||
threshold: max(0, min(1, threshold)) || 1
|
||||
};
|
||||
let isFirstUpdate = true;
|
||||
function handleObserve(entries) {
|
||||
const ratio = entries[0].intersectionRatio;
|
||||
if (ratio !== threshold) {
|
||||
if (!isFirstUpdate) {
|
||||
return refresh();
|
||||
}
|
||||
if (!ratio) {
|
||||
// If the reference is clipped, the ratio is 0. Throttle the refresh
|
||||
// to prevent an infinite loop of updates.
|
||||
timeoutId = setTimeout(() => {
|
||||
refresh(false, 1e-7);
|
||||
}, 1000);
|
||||
} else {
|
||||
refresh(false, ratio);
|
||||
}
|
||||
}
|
||||
if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
|
||||
// It's possible that even though the ratio is reported as 1, the
|
||||
// element is not actually fully within the IntersectionObserver's root
|
||||
// area anymore. This can happen under performance constraints. This may
|
||||
// be a bug in the browser's IntersectionObserver implementation. To
|
||||
// work around this, we compare the element's bounding rect now with
|
||||
// what it was at the time we created the IntersectionObserver. If they
|
||||
// are not equal then the element moved, so we refresh.
|
||||
refresh();
|
||||
}
|
||||
isFirstUpdate = false;
|
||||
}
|
||||
|
||||
// Older browsers don't support a `document` as the root and will throw an
|
||||
// error.
|
||||
try {
|
||||
io = new IntersectionObserver(handleObserve, {
|
||||
...options,
|
||||
// Handle <iframe>s
|
||||
root: root.ownerDocument
|
||||
});
|
||||
} catch (_e) {
|
||||
io = new IntersectionObserver(handleObserve, options);
|
||||
}
|
||||
io.observe(element);
|
||||
}
|
||||
refresh(true);
|
||||
return cleanup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically updates the position of the floating element when necessary.
|
||||
* Should only be called when the floating element is mounted on the DOM or
|
||||
* visible on the screen.
|
||||
* @returns cleanup function that should be invoked when the floating element is
|
||||
* removed from the DOM or hidden from the screen.
|
||||
* @see https://floating-ui.com/docs/autoUpdate
|
||||
*/
|
||||
function autoUpdate(reference, floating, update, options) {
|
||||
if (options === void 0) {
|
||||
options = {};
|
||||
}
|
||||
const {
|
||||
ancestorScroll = true,
|
||||
ancestorResize = true,
|
||||
elementResize = typeof ResizeObserver === 'function',
|
||||
layoutShift = typeof IntersectionObserver === 'function',
|
||||
animationFrame = false
|
||||
} = options;
|
||||
const referenceEl = unwrapElement(reference);
|
||||
const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
|
||||
ancestors.forEach(ancestor => {
|
||||
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
||||
passive: true
|
||||
});
|
||||
ancestorResize && ancestor.addEventListener('resize', update);
|
||||
});
|
||||
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
||||
let reobserveFrame = -1;
|
||||
let resizeObserver = null;
|
||||
if (elementResize) {
|
||||
resizeObserver = new ResizeObserver(_ref => {
|
||||
let [firstEntry] = _ref;
|
||||
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
||||
// Prevent update loops when using the `size` middleware.
|
||||
// https://github.com/floating-ui/floating-ui/issues/1740
|
||||
resizeObserver.unobserve(floating);
|
||||
cancelAnimationFrame(reobserveFrame);
|
||||
reobserveFrame = requestAnimationFrame(() => {
|
||||
var _resizeObserver;
|
||||
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
|
||||
});
|
||||
}
|
||||
update();
|
||||
});
|
||||
if (referenceEl && !animationFrame) {
|
||||
resizeObserver.observe(referenceEl);
|
||||
}
|
||||
resizeObserver.observe(floating);
|
||||
}
|
||||
let frameId;
|
||||
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
||||
if (animationFrame) {
|
||||
frameLoop();
|
||||
}
|
||||
function frameLoop() {
|
||||
const nextRefRect = getBoundingClientRect(reference);
|
||||
if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
|
||||
update();
|
||||
}
|
||||
prevRefRect = nextRefRect;
|
||||
frameId = requestAnimationFrame(frameLoop);
|
||||
}
|
||||
update();
|
||||
return () => {
|
||||
var _resizeObserver2;
|
||||
ancestors.forEach(ancestor => {
|
||||
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
||||
ancestorResize && ancestor.removeEventListener('resize', update);
|
||||
});
|
||||
cleanupIo == null || cleanupIo();
|
||||
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
|
||||
resizeObserver = null;
|
||||
if (animationFrame) {
|
||||
cancelAnimationFrame(frameId);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves with an object of overflow side offsets that determine how much the
|
||||
* element is overflowing a given clipping boundary on each side.
|
||||
* - positive = overflowing the boundary by that number of pixels
|
||||
* - negative = how many pixels left before it will overflow
|
||||
* - 0 = lies flush with the boundary
|
||||
* @see https://floating-ui.com/docs/detectOverflow
|
||||
*/
|
||||
const detectOverflow = detectOverflow$1;
|
||||
|
||||
/**
|
||||
* Modifies the placement by translating the floating element along the
|
||||
* specified axes.
|
||||
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
||||
* object may be passed.
|
||||
* @see https://floating-ui.com/docs/offset
|
||||
*/
|
||||
const offset = offset$1;
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by choosing the placement
|
||||
* that has the most space available automatically, without needing to specify a
|
||||
* preferred placement. Alternative to `flip`.
|
||||
* @see https://floating-ui.com/docs/autoPlacement
|
||||
*/
|
||||
const autoPlacement = autoPlacement$1;
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by shifting it in order to
|
||||
* keep it in view when it will overflow the clipping boundary.
|
||||
* @see https://floating-ui.com/docs/shift
|
||||
*/
|
||||
const shift = shift$1;
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by flipping the `placement`
|
||||
* in order to keep it in view when the preferred placement(s) will overflow the
|
||||
* clipping boundary. Alternative to `autoPlacement`.
|
||||
* @see https://floating-ui.com/docs/flip
|
||||
*/
|
||||
const flip = flip$1;
|
||||
|
||||
/**
|
||||
* Provides data that allows you to change the size of the floating element —
|
||||
* for instance, prevent it from overflowing the clipping boundary or match the
|
||||
* width of the reference element.
|
||||
* @see https://floating-ui.com/docs/size
|
||||
*/
|
||||
const size = size$1;
|
||||
|
||||
/**
|
||||
* Provides data to hide the floating element in applicable situations, such as
|
||||
* when it is not in the same clipping context as the reference element.
|
||||
* @see https://floating-ui.com/docs/hide
|
||||
*/
|
||||
const hide = hide$1;
|
||||
|
||||
/**
|
||||
* Provides data to position an inner element of the floating element so that it
|
||||
* appears centered to the reference element.
|
||||
* @see https://floating-ui.com/docs/arrow
|
||||
*/
|
||||
const arrow = arrow$1;
|
||||
|
||||
/**
|
||||
* Provides improved positioning for inline reference elements that can span
|
||||
* over multiple lines, such as hyperlinks or range selections.
|
||||
* @see https://floating-ui.com/docs/inline
|
||||
*/
|
||||
const inline = inline$1;
|
||||
|
||||
/**
|
||||
* Built-in `limiter` that will stop `shift()` at a certain point.
|
||||
*/
|
||||
const limitShift = limitShift$1;
|
||||
|
||||
/**
|
||||
* Computes the `x` and `y` coordinates that will place the floating element
|
||||
* next to a given reference element.
|
||||
*/
|
||||
const computePosition = (reference, floating, options) => {
|
||||
// This caches the expensive `getClippingElementAncestors` function so that
|
||||
// multiple lifecycle resets re-use the same result. It only lives for a
|
||||
// single call. If other functions become expensive, we can add them as well.
|
||||
const cache = new Map();
|
||||
const mergedOptions = {
|
||||
platform,
|
||||
...options
|
||||
};
|
||||
const platformWithCache = {
|
||||
...mergedOptions.platform,
|
||||
_c: cache
|
||||
};
|
||||
return computePosition$1(reference, floating, {
|
||||
...mergedOptions,
|
||||
platform: platformWithCache
|
||||
});
|
||||
};
|
||||
|
||||
export { arrow, autoPlacement, autoUpdate, computePosition, detectOverflow, flip, hide, inline, limitShift, offset, platform, shift, size };
|
||||
+777
@@ -0,0 +1,777 @@
|
||||
import { rectToClientRect, arrow as arrow$1, autoPlacement as autoPlacement$1, detectOverflow as detectOverflow$1, flip as flip$1, hide as hide$1, inline as inline$1, limitShift as limitShift$1, offset as offset$1, shift as shift$1, size as size$1, computePosition as computePosition$1 } from '@floating-ui/core';
|
||||
import { round, createCoords, max, min, floor } from '@floating-ui/utils';
|
||||
import { getComputedStyle as getComputedStyle$1, isHTMLElement, isElement, getWindow, isWebKit, getFrameElement, getNodeScroll, getDocumentElement, isTopLayer, getNodeName, isOverflowElement, getOverflowAncestors, getParentNode, isLastTraversableNode, isContainingBlock, isTableElement, getContainingBlock } from '@floating-ui/utils/dom';
|
||||
export { getOverflowAncestors } from '@floating-ui/utils/dom';
|
||||
|
||||
function getCssDimensions(element) {
|
||||
const css = getComputedStyle$1(element);
|
||||
// In testing environments, the `width` and `height` properties are empty
|
||||
// strings for SVG elements, returning NaN. Fallback to `0` in this case.
|
||||
let width = parseFloat(css.width) || 0;
|
||||
let height = parseFloat(css.height) || 0;
|
||||
const hasOffset = isHTMLElement(element);
|
||||
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
||||
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
||||
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
||||
if (shouldFallback) {
|
||||
width = offsetWidth;
|
||||
height = offsetHeight;
|
||||
}
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
$: shouldFallback
|
||||
};
|
||||
}
|
||||
|
||||
function unwrapElement(element) {
|
||||
return !isElement(element) ? element.contextElement : element;
|
||||
}
|
||||
|
||||
function getScale(element) {
|
||||
const domElement = unwrapElement(element);
|
||||
if (!isHTMLElement(domElement)) {
|
||||
return createCoords(1);
|
||||
}
|
||||
const rect = domElement.getBoundingClientRect();
|
||||
const {
|
||||
width,
|
||||
height,
|
||||
$
|
||||
} = getCssDimensions(domElement);
|
||||
let x = ($ ? round(rect.width) : rect.width) / width;
|
||||
let y = ($ ? round(rect.height) : rect.height) / height;
|
||||
|
||||
// 0, NaN, or Infinity should always fallback to 1.
|
||||
|
||||
if (!x || !Number.isFinite(x)) {
|
||||
x = 1;
|
||||
}
|
||||
if (!y || !Number.isFinite(y)) {
|
||||
y = 1;
|
||||
}
|
||||
return {
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
const noOffsets = /*#__PURE__*/createCoords(0);
|
||||
function getVisualOffsets(element) {
|
||||
const win = getWindow(element);
|
||||
if (!isWebKit() || !win.visualViewport) {
|
||||
return noOffsets;
|
||||
}
|
||||
return {
|
||||
x: win.visualViewport.offsetLeft,
|
||||
y: win.visualViewport.offsetTop
|
||||
};
|
||||
}
|
||||
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
||||
if (isFixed === void 0) {
|
||||
isFixed = false;
|
||||
}
|
||||
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
||||
return false;
|
||||
}
|
||||
return isFixed;
|
||||
}
|
||||
|
||||
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
||||
if (includeScale === void 0) {
|
||||
includeScale = false;
|
||||
}
|
||||
if (isFixedStrategy === void 0) {
|
||||
isFixedStrategy = false;
|
||||
}
|
||||
const clientRect = element.getBoundingClientRect();
|
||||
const domElement = unwrapElement(element);
|
||||
let scale = createCoords(1);
|
||||
if (includeScale) {
|
||||
if (offsetParent) {
|
||||
if (isElement(offsetParent)) {
|
||||
scale = getScale(offsetParent);
|
||||
}
|
||||
} else {
|
||||
scale = getScale(element);
|
||||
}
|
||||
}
|
||||
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
||||
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
||||
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
||||
let width = clientRect.width / scale.x;
|
||||
let height = clientRect.height / scale.y;
|
||||
if (domElement) {
|
||||
const win = getWindow(domElement);
|
||||
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
||||
let currentWin = win;
|
||||
let currentIFrame = getFrameElement(currentWin);
|
||||
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
||||
const iframeScale = getScale(currentIFrame);
|
||||
const iframeRect = currentIFrame.getBoundingClientRect();
|
||||
const css = getComputedStyle$1(currentIFrame);
|
||||
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
||||
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
||||
x *= iframeScale.x;
|
||||
y *= iframeScale.y;
|
||||
width *= iframeScale.x;
|
||||
height *= iframeScale.y;
|
||||
x += left;
|
||||
y += top;
|
||||
currentWin = getWindow(currentIFrame);
|
||||
currentIFrame = getFrameElement(currentWin);
|
||||
}
|
||||
}
|
||||
return rectToClientRect({
|
||||
width,
|
||||
height,
|
||||
x,
|
||||
y
|
||||
});
|
||||
}
|
||||
|
||||
// If <html> has a CSS width greater than the viewport, then this will be
|
||||
// incorrect for RTL.
|
||||
function getWindowScrollBarX(element, rect) {
|
||||
const leftScroll = getNodeScroll(element).scrollLeft;
|
||||
if (!rect) {
|
||||
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
||||
}
|
||||
return rect.left + leftScroll;
|
||||
}
|
||||
|
||||
function getHTMLOffset(documentElement, scroll) {
|
||||
const htmlRect = documentElement.getBoundingClientRect();
|
||||
const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
|
||||
const y = htmlRect.top + scroll.scrollTop;
|
||||
return {
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
||||
let {
|
||||
elements,
|
||||
rect,
|
||||
offsetParent,
|
||||
strategy
|
||||
} = _ref;
|
||||
const isFixed = strategy === 'fixed';
|
||||
const documentElement = getDocumentElement(offsetParent);
|
||||
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
||||
if (offsetParent === documentElement || topLayer && isFixed) {
|
||||
return rect;
|
||||
}
|
||||
let scroll = {
|
||||
scrollLeft: 0,
|
||||
scrollTop: 0
|
||||
};
|
||||
let scale = createCoords(1);
|
||||
const offsets = createCoords(0);
|
||||
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
||||
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
||||
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
||||
scroll = getNodeScroll(offsetParent);
|
||||
}
|
||||
if (isHTMLElement(offsetParent)) {
|
||||
const offsetRect = getBoundingClientRect(offsetParent);
|
||||
scale = getScale(offsetParent);
|
||||
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
||||
offsets.y = offsetRect.y + offsetParent.clientTop;
|
||||
}
|
||||
}
|
||||
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
||||
return {
|
||||
width: rect.width * scale.x,
|
||||
height: rect.height * scale.y,
|
||||
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
||||
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
||||
};
|
||||
}
|
||||
|
||||
function getClientRects(element) {
|
||||
return Array.from(element.getClientRects());
|
||||
}
|
||||
|
||||
// Gets the entire size of the scrollable document area, even extending outside
|
||||
// of the `<html>` and `<body>` rect bounds if horizontally scrollable.
|
||||
function getDocumentRect(element) {
|
||||
const html = getDocumentElement(element);
|
||||
const scroll = getNodeScroll(element);
|
||||
const body = element.ownerDocument.body;
|
||||
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
||||
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
||||
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
||||
const y = -scroll.scrollTop;
|
||||
if (getComputedStyle$1(body).direction === 'rtl') {
|
||||
x += max(html.clientWidth, body.clientWidth) - width;
|
||||
}
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
// Safety check: ensure the scrollbar space is reasonable in case this
|
||||
// calculation is affected by unusual styles.
|
||||
// Most scrollbars leave 15-18px of space.
|
||||
const SCROLLBAR_MAX = 25;
|
||||
function getViewportRect(element, strategy) {
|
||||
const win = getWindow(element);
|
||||
const html = getDocumentElement(element);
|
||||
const visualViewport = win.visualViewport;
|
||||
let width = html.clientWidth;
|
||||
let height = html.clientHeight;
|
||||
let x = 0;
|
||||
let y = 0;
|
||||
if (visualViewport) {
|
||||
width = visualViewport.width;
|
||||
height = visualViewport.height;
|
||||
const visualViewportBased = isWebKit();
|
||||
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
|
||||
x = visualViewport.offsetLeft;
|
||||
y = visualViewport.offsetTop;
|
||||
}
|
||||
}
|
||||
const windowScrollbarX = getWindowScrollBarX(html);
|
||||
// <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
|
||||
// visual width of the <html> but this is not considered in the size
|
||||
// of `html.clientWidth`.
|
||||
if (windowScrollbarX <= 0) {
|
||||
const doc = html.ownerDocument;
|
||||
const body = doc.body;
|
||||
const bodyStyles = getComputedStyle(body);
|
||||
const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
|
||||
const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
|
||||
if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
|
||||
width -= clippingStableScrollbarWidth;
|
||||
}
|
||||
} else if (windowScrollbarX <= SCROLLBAR_MAX) {
|
||||
// If the <body> scrollbar is on the left, the width needs to be extended
|
||||
// by the scrollbar amount so there isn't extra space on the right.
|
||||
width += windowScrollbarX;
|
||||
}
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
const absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);
|
||||
// Returns the inner client rect, subtracting scrollbars if present.
|
||||
function getInnerBoundingClientRect(element, strategy) {
|
||||
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
||||
const top = clientRect.top + element.clientTop;
|
||||
const left = clientRect.left + element.clientLeft;
|
||||
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
||||
const width = element.clientWidth * scale.x;
|
||||
const height = element.clientHeight * scale.y;
|
||||
const x = left * scale.x;
|
||||
const y = top * scale.y;
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
||||
let rect;
|
||||
if (clippingAncestor === 'viewport') {
|
||||
rect = getViewportRect(element, strategy);
|
||||
} else if (clippingAncestor === 'document') {
|
||||
rect = getDocumentRect(getDocumentElement(element));
|
||||
} else if (isElement(clippingAncestor)) {
|
||||
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
||||
} else {
|
||||
const visualOffsets = getVisualOffsets(element);
|
||||
rect = {
|
||||
x: clippingAncestor.x - visualOffsets.x,
|
||||
y: clippingAncestor.y - visualOffsets.y,
|
||||
width: clippingAncestor.width,
|
||||
height: clippingAncestor.height
|
||||
};
|
||||
}
|
||||
return rectToClientRect(rect);
|
||||
}
|
||||
function hasFixedPositionAncestor(element, stopNode) {
|
||||
const parentNode = getParentNode(element);
|
||||
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
||||
return false;
|
||||
}
|
||||
return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
|
||||
}
|
||||
|
||||
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
||||
// clipping (or hiding) child elements. This returns all clipping ancestors
|
||||
// of the given element up the tree.
|
||||
function getClippingElementAncestors(element, cache) {
|
||||
const cachedResult = cache.get(element);
|
||||
if (cachedResult) {
|
||||
return cachedResult;
|
||||
}
|
||||
let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
||||
let currentContainingBlockComputedStyle = null;
|
||||
const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
|
||||
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
||||
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
||||
const computedStyle = getComputedStyle$1(currentNode);
|
||||
const currentNodeIsContaining = isContainingBlock(currentNode);
|
||||
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
||||
currentContainingBlockComputedStyle = null;
|
||||
}
|
||||
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
||||
if (shouldDropCurrentNode) {
|
||||
// Drop non-containing blocks.
|
||||
result = result.filter(ancestor => ancestor !== currentNode);
|
||||
} else {
|
||||
// Record last containing block for next iteration.
|
||||
currentContainingBlockComputedStyle = computedStyle;
|
||||
}
|
||||
currentNode = getParentNode(currentNode);
|
||||
}
|
||||
cache.set(element, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Gets the maximum area that the element is visible in due to any number of
|
||||
// clipping ancestors.
|
||||
function getClippingRect(_ref) {
|
||||
let {
|
||||
element,
|
||||
boundary,
|
||||
rootBoundary,
|
||||
strategy
|
||||
} = _ref;
|
||||
const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
||||
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
||||
const firstClippingAncestor = clippingAncestors[0];
|
||||
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
||||
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
||||
accRect.top = max(rect.top, accRect.top);
|
||||
accRect.right = min(rect.right, accRect.right);
|
||||
accRect.bottom = min(rect.bottom, accRect.bottom);
|
||||
accRect.left = max(rect.left, accRect.left);
|
||||
return accRect;
|
||||
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
||||
return {
|
||||
width: clippingRect.right - clippingRect.left,
|
||||
height: clippingRect.bottom - clippingRect.top,
|
||||
x: clippingRect.left,
|
||||
y: clippingRect.top
|
||||
};
|
||||
}
|
||||
|
||||
function getDimensions(element) {
|
||||
const {
|
||||
width,
|
||||
height
|
||||
} = getCssDimensions(element);
|
||||
return {
|
||||
width,
|
||||
height
|
||||
};
|
||||
}
|
||||
|
||||
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
||||
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
||||
const documentElement = getDocumentElement(offsetParent);
|
||||
const isFixed = strategy === 'fixed';
|
||||
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
||||
let scroll = {
|
||||
scrollLeft: 0,
|
||||
scrollTop: 0
|
||||
};
|
||||
const offsets = createCoords(0);
|
||||
|
||||
// If the <body> scrollbar appears on the left (e.g. RTL systems). Use
|
||||
// Firefox with layout.scrollbar.side = 3 in about:config to test this.
|
||||
function setLeftRTLScrollbarOffset() {
|
||||
offsets.x = getWindowScrollBarX(documentElement);
|
||||
}
|
||||
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
||||
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
||||
scroll = getNodeScroll(offsetParent);
|
||||
}
|
||||
if (isOffsetParentAnElement) {
|
||||
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
||||
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
||||
offsets.y = offsetRect.y + offsetParent.clientTop;
|
||||
} else if (documentElement) {
|
||||
setLeftRTLScrollbarOffset();
|
||||
}
|
||||
}
|
||||
if (isFixed && !isOffsetParentAnElement && documentElement) {
|
||||
setLeftRTLScrollbarOffset();
|
||||
}
|
||||
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
||||
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
||||
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
||||
return {
|
||||
x,
|
||||
y,
|
||||
width: rect.width,
|
||||
height: rect.height
|
||||
};
|
||||
}
|
||||
|
||||
function isStaticPositioned(element) {
|
||||
return getComputedStyle$1(element).position === 'static';
|
||||
}
|
||||
|
||||
function getTrueOffsetParent(element, polyfill) {
|
||||
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
|
||||
return null;
|
||||
}
|
||||
if (polyfill) {
|
||||
return polyfill(element);
|
||||
}
|
||||
let rawOffsetParent = element.offsetParent;
|
||||
|
||||
// Firefox returns the <html> element as the offsetParent if it's non-static,
|
||||
// while Chrome and Safari return the <body> element. The <body> element must
|
||||
// be used to perform the correct calculations even if the <html> element is
|
||||
// non-static.
|
||||
if (getDocumentElement(element) === rawOffsetParent) {
|
||||
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
||||
}
|
||||
return rawOffsetParent;
|
||||
}
|
||||
|
||||
// Gets the closest ancestor positioned element. Handles some edge cases,
|
||||
// such as table ancestors and cross browser bugs.
|
||||
function getOffsetParent(element, polyfill) {
|
||||
const win = getWindow(element);
|
||||
if (isTopLayer(element)) {
|
||||
return win;
|
||||
}
|
||||
if (!isHTMLElement(element)) {
|
||||
let svgOffsetParent = getParentNode(element);
|
||||
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
||||
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
||||
return svgOffsetParent;
|
||||
}
|
||||
svgOffsetParent = getParentNode(svgOffsetParent);
|
||||
}
|
||||
return win;
|
||||
}
|
||||
let offsetParent = getTrueOffsetParent(element, polyfill);
|
||||
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
||||
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
||||
}
|
||||
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
||||
return win;
|
||||
}
|
||||
return offsetParent || getContainingBlock(element) || win;
|
||||
}
|
||||
|
||||
const getElementRects = async function (data) {
|
||||
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
||||
const getDimensionsFn = this.getDimensions;
|
||||
const floatingDimensions = await getDimensionsFn(data.floating);
|
||||
return {
|
||||
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
||||
floating: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: floatingDimensions.width,
|
||||
height: floatingDimensions.height
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
function isRTL(element) {
|
||||
return getComputedStyle$1(element).direction === 'rtl';
|
||||
}
|
||||
|
||||
const platform = {
|
||||
convertOffsetParentRelativeRectToViewportRelativeRect,
|
||||
getDocumentElement,
|
||||
getClippingRect,
|
||||
getOffsetParent,
|
||||
getElementRects,
|
||||
getClientRects,
|
||||
getDimensions,
|
||||
getScale,
|
||||
isElement,
|
||||
isRTL
|
||||
};
|
||||
|
||||
function rectsAreEqual(a, b) {
|
||||
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
||||
}
|
||||
|
||||
// https://samthor.au/2021/observing-dom/
|
||||
function observeMove(element, onMove) {
|
||||
let io = null;
|
||||
let timeoutId;
|
||||
const root = getDocumentElement(element);
|
||||
function cleanup() {
|
||||
var _io;
|
||||
clearTimeout(timeoutId);
|
||||
(_io = io) == null || _io.disconnect();
|
||||
io = null;
|
||||
}
|
||||
function refresh(skip, threshold) {
|
||||
if (skip === void 0) {
|
||||
skip = false;
|
||||
}
|
||||
if (threshold === void 0) {
|
||||
threshold = 1;
|
||||
}
|
||||
cleanup();
|
||||
const elementRectForRootMargin = element.getBoundingClientRect();
|
||||
const {
|
||||
left,
|
||||
top,
|
||||
width,
|
||||
height
|
||||
} = elementRectForRootMargin;
|
||||
if (!skip) {
|
||||
onMove();
|
||||
}
|
||||
if (!width || !height) {
|
||||
return;
|
||||
}
|
||||
const insetTop = floor(top);
|
||||
const insetRight = floor(root.clientWidth - (left + width));
|
||||
const insetBottom = floor(root.clientHeight - (top + height));
|
||||
const insetLeft = floor(left);
|
||||
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
||||
const options = {
|
||||
rootMargin,
|
||||
threshold: max(0, min(1, threshold)) || 1
|
||||
};
|
||||
let isFirstUpdate = true;
|
||||
function handleObserve(entries) {
|
||||
const ratio = entries[0].intersectionRatio;
|
||||
if (ratio !== threshold) {
|
||||
if (!isFirstUpdate) {
|
||||
return refresh();
|
||||
}
|
||||
if (!ratio) {
|
||||
// If the reference is clipped, the ratio is 0. Throttle the refresh
|
||||
// to prevent an infinite loop of updates.
|
||||
timeoutId = setTimeout(() => {
|
||||
refresh(false, 1e-7);
|
||||
}, 1000);
|
||||
} else {
|
||||
refresh(false, ratio);
|
||||
}
|
||||
}
|
||||
if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
|
||||
// It's possible that even though the ratio is reported as 1, the
|
||||
// element is not actually fully within the IntersectionObserver's root
|
||||
// area anymore. This can happen under performance constraints. This may
|
||||
// be a bug in the browser's IntersectionObserver implementation. To
|
||||
// work around this, we compare the element's bounding rect now with
|
||||
// what it was at the time we created the IntersectionObserver. If they
|
||||
// are not equal then the element moved, so we refresh.
|
||||
refresh();
|
||||
}
|
||||
isFirstUpdate = false;
|
||||
}
|
||||
|
||||
// Older browsers don't support a `document` as the root and will throw an
|
||||
// error.
|
||||
try {
|
||||
io = new IntersectionObserver(handleObserve, {
|
||||
...options,
|
||||
// Handle <iframe>s
|
||||
root: root.ownerDocument
|
||||
});
|
||||
} catch (_e) {
|
||||
io = new IntersectionObserver(handleObserve, options);
|
||||
}
|
||||
io.observe(element);
|
||||
}
|
||||
refresh(true);
|
||||
return cleanup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically updates the position of the floating element when necessary.
|
||||
* Should only be called when the floating element is mounted on the DOM or
|
||||
* visible on the screen.
|
||||
* @returns cleanup function that should be invoked when the floating element is
|
||||
* removed from the DOM or hidden from the screen.
|
||||
* @see https://floating-ui.com/docs/autoUpdate
|
||||
*/
|
||||
function autoUpdate(reference, floating, update, options) {
|
||||
if (options === void 0) {
|
||||
options = {};
|
||||
}
|
||||
const {
|
||||
ancestorScroll = true,
|
||||
ancestorResize = true,
|
||||
elementResize = typeof ResizeObserver === 'function',
|
||||
layoutShift = typeof IntersectionObserver === 'function',
|
||||
animationFrame = false
|
||||
} = options;
|
||||
const referenceEl = unwrapElement(reference);
|
||||
const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
|
||||
ancestors.forEach(ancestor => {
|
||||
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
||||
passive: true
|
||||
});
|
||||
ancestorResize && ancestor.addEventListener('resize', update);
|
||||
});
|
||||
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
||||
let reobserveFrame = -1;
|
||||
let resizeObserver = null;
|
||||
if (elementResize) {
|
||||
resizeObserver = new ResizeObserver(_ref => {
|
||||
let [firstEntry] = _ref;
|
||||
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
||||
// Prevent update loops when using the `size` middleware.
|
||||
// https://github.com/floating-ui/floating-ui/issues/1740
|
||||
resizeObserver.unobserve(floating);
|
||||
cancelAnimationFrame(reobserveFrame);
|
||||
reobserveFrame = requestAnimationFrame(() => {
|
||||
var _resizeObserver;
|
||||
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
|
||||
});
|
||||
}
|
||||
update();
|
||||
});
|
||||
if (referenceEl && !animationFrame) {
|
||||
resizeObserver.observe(referenceEl);
|
||||
}
|
||||
resizeObserver.observe(floating);
|
||||
}
|
||||
let frameId;
|
||||
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
||||
if (animationFrame) {
|
||||
frameLoop();
|
||||
}
|
||||
function frameLoop() {
|
||||
const nextRefRect = getBoundingClientRect(reference);
|
||||
if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
|
||||
update();
|
||||
}
|
||||
prevRefRect = nextRefRect;
|
||||
frameId = requestAnimationFrame(frameLoop);
|
||||
}
|
||||
update();
|
||||
return () => {
|
||||
var _resizeObserver2;
|
||||
ancestors.forEach(ancestor => {
|
||||
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
||||
ancestorResize && ancestor.removeEventListener('resize', update);
|
||||
});
|
||||
cleanupIo == null || cleanupIo();
|
||||
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
|
||||
resizeObserver = null;
|
||||
if (animationFrame) {
|
||||
cancelAnimationFrame(frameId);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves with an object of overflow side offsets that determine how much the
|
||||
* element is overflowing a given clipping boundary on each side.
|
||||
* - positive = overflowing the boundary by that number of pixels
|
||||
* - negative = how many pixels left before it will overflow
|
||||
* - 0 = lies flush with the boundary
|
||||
* @see https://floating-ui.com/docs/detectOverflow
|
||||
*/
|
||||
const detectOverflow = detectOverflow$1;
|
||||
|
||||
/**
|
||||
* Modifies the placement by translating the floating element along the
|
||||
* specified axes.
|
||||
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
||||
* object may be passed.
|
||||
* @see https://floating-ui.com/docs/offset
|
||||
*/
|
||||
const offset = offset$1;
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by choosing the placement
|
||||
* that has the most space available automatically, without needing to specify a
|
||||
* preferred placement. Alternative to `flip`.
|
||||
* @see https://floating-ui.com/docs/autoPlacement
|
||||
*/
|
||||
const autoPlacement = autoPlacement$1;
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by shifting it in order to
|
||||
* keep it in view when it will overflow the clipping boundary.
|
||||
* @see https://floating-ui.com/docs/shift
|
||||
*/
|
||||
const shift = shift$1;
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by flipping the `placement`
|
||||
* in order to keep it in view when the preferred placement(s) will overflow the
|
||||
* clipping boundary. Alternative to `autoPlacement`.
|
||||
* @see https://floating-ui.com/docs/flip
|
||||
*/
|
||||
const flip = flip$1;
|
||||
|
||||
/**
|
||||
* Provides data that allows you to change the size of the floating element —
|
||||
* for instance, prevent it from overflowing the clipping boundary or match the
|
||||
* width of the reference element.
|
||||
* @see https://floating-ui.com/docs/size
|
||||
*/
|
||||
const size = size$1;
|
||||
|
||||
/**
|
||||
* Provides data to hide the floating element in applicable situations, such as
|
||||
* when it is not in the same clipping context as the reference element.
|
||||
* @see https://floating-ui.com/docs/hide
|
||||
*/
|
||||
const hide = hide$1;
|
||||
|
||||
/**
|
||||
* Provides data to position an inner element of the floating element so that it
|
||||
* appears centered to the reference element.
|
||||
* @see https://floating-ui.com/docs/arrow
|
||||
*/
|
||||
const arrow = arrow$1;
|
||||
|
||||
/**
|
||||
* Provides improved positioning for inline reference elements that can span
|
||||
* over multiple lines, such as hyperlinks or range selections.
|
||||
* @see https://floating-ui.com/docs/inline
|
||||
*/
|
||||
const inline = inline$1;
|
||||
|
||||
/**
|
||||
* Built-in `limiter` that will stop `shift()` at a certain point.
|
||||
*/
|
||||
const limitShift = limitShift$1;
|
||||
|
||||
/**
|
||||
* Computes the `x` and `y` coordinates that will place the floating element
|
||||
* next to a given reference element.
|
||||
*/
|
||||
const computePosition = (reference, floating, options) => {
|
||||
// This caches the expensive `getClippingElementAncestors` function so that
|
||||
// multiple lifecycle resets re-use the same result. It only lives for a
|
||||
// single call. If other functions become expensive, we can add them as well.
|
||||
const cache = new Map();
|
||||
const mergedOptions = {
|
||||
platform,
|
||||
...options
|
||||
};
|
||||
const platformWithCache = {
|
||||
...mergedOptions.platform,
|
||||
_c: cache
|
||||
};
|
||||
return computePosition$1(reference, floating, {
|
||||
...mergedOptions,
|
||||
platform: platformWithCache
|
||||
});
|
||||
};
|
||||
|
||||
export { arrow, autoPlacement, autoUpdate, computePosition, detectOverflow, flip, hide, inline, limitShift, offset, platform, shift, size };
|
||||
+967
@@ -0,0 +1,967 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@floating-ui/core')) :
|
||||
typeof define === 'function' && define.amd ? define(['exports', '@floating-ui/core'], factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.FloatingUIDOM = {}, global.FloatingUICore));
|
||||
})(this, (function (exports, core) { 'use strict';
|
||||
|
||||
/**
|
||||
* Custom positioning reference element.
|
||||
* @see https://floating-ui.com/docs/virtual-elements
|
||||
*/
|
||||
|
||||
const min = Math.min;
|
||||
const max = Math.max;
|
||||
const round = Math.round;
|
||||
const floor = Math.floor;
|
||||
const createCoords = v => ({
|
||||
x: v,
|
||||
y: v
|
||||
});
|
||||
|
||||
function hasWindow() {
|
||||
return typeof window !== 'undefined';
|
||||
}
|
||||
function getNodeName(node) {
|
||||
if (isNode(node)) {
|
||||
return (node.nodeName || '').toLowerCase();
|
||||
}
|
||||
// Mocked nodes in testing environments may not be instances of Node. By
|
||||
// returning `#document` an infinite loop won't occur.
|
||||
// https://github.com/floating-ui/floating-ui/issues/2317
|
||||
return '#document';
|
||||
}
|
||||
function getWindow(node) {
|
||||
var _node$ownerDocument;
|
||||
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
||||
}
|
||||
function getDocumentElement(node) {
|
||||
var _ref;
|
||||
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
||||
}
|
||||
function isNode(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof Node || value instanceof getWindow(value).Node;
|
||||
}
|
||||
function isElement(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof Element || value instanceof getWindow(value).Element;
|
||||
}
|
||||
function isHTMLElement(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
||||
}
|
||||
function isShadowRoot(value) {
|
||||
if (!hasWindow() || typeof ShadowRoot === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
||||
}
|
||||
const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
|
||||
function isOverflowElement(element) {
|
||||
const {
|
||||
overflow,
|
||||
overflowX,
|
||||
overflowY,
|
||||
display
|
||||
} = getComputedStyle$1(element);
|
||||
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
||||
}
|
||||
const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
|
||||
function isTableElement(element) {
|
||||
return tableElements.has(getNodeName(element));
|
||||
}
|
||||
const topLayerSelectors = [':popover-open', ':modal'];
|
||||
function isTopLayer(element) {
|
||||
return topLayerSelectors.some(selector => {
|
||||
try {
|
||||
return element.matches(selector);
|
||||
} catch (_e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
|
||||
const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
|
||||
const containValues = ['paint', 'layout', 'strict', 'content'];
|
||||
function isContainingBlock(elementOrCss) {
|
||||
const webkit = isWebKit();
|
||||
const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
||||
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
||||
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));
|
||||
}
|
||||
function getContainingBlock(element) {
|
||||
let currentNode = getParentNode(element);
|
||||
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
||||
if (isContainingBlock(currentNode)) {
|
||||
return currentNode;
|
||||
} else if (isTopLayer(currentNode)) {
|
||||
return null;
|
||||
}
|
||||
currentNode = getParentNode(currentNode);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function isWebKit() {
|
||||
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
||||
return CSS.supports('-webkit-backdrop-filter', 'none');
|
||||
}
|
||||
const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
|
||||
function isLastTraversableNode(node) {
|
||||
return lastTraversableNodeNames.has(getNodeName(node));
|
||||
}
|
||||
function getComputedStyle$1(element) {
|
||||
return getWindow(element).getComputedStyle(element);
|
||||
}
|
||||
function getNodeScroll(element) {
|
||||
if (isElement(element)) {
|
||||
return {
|
||||
scrollLeft: element.scrollLeft,
|
||||
scrollTop: element.scrollTop
|
||||
};
|
||||
}
|
||||
return {
|
||||
scrollLeft: element.scrollX,
|
||||
scrollTop: element.scrollY
|
||||
};
|
||||
}
|
||||
function getParentNode(node) {
|
||||
if (getNodeName(node) === 'html') {
|
||||
return node;
|
||||
}
|
||||
const result =
|
||||
// Step into the shadow DOM of the parent of a slotted node.
|
||||
node.assignedSlot ||
|
||||
// DOM Element detected.
|
||||
node.parentNode ||
|
||||
// ShadowRoot detected.
|
||||
isShadowRoot(node) && node.host ||
|
||||
// Fallback.
|
||||
getDocumentElement(node);
|
||||
return isShadowRoot(result) ? result.host : result;
|
||||
}
|
||||
function getNearestOverflowAncestor(node) {
|
||||
const parentNode = getParentNode(node);
|
||||
if (isLastTraversableNode(parentNode)) {
|
||||
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
||||
}
|
||||
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
||||
return parentNode;
|
||||
}
|
||||
return getNearestOverflowAncestor(parentNode);
|
||||
}
|
||||
function getOverflowAncestors(node, list, traverseIframes) {
|
||||
var _node$ownerDocument2;
|
||||
if (list === void 0) {
|
||||
list = [];
|
||||
}
|
||||
if (traverseIframes === void 0) {
|
||||
traverseIframes = true;
|
||||
}
|
||||
const scrollableAncestor = getNearestOverflowAncestor(node);
|
||||
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
||||
const win = getWindow(scrollableAncestor);
|
||||
if (isBody) {
|
||||
const frameElement = getFrameElement(win);
|
||||
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
||||
}
|
||||
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
||||
}
|
||||
function getFrameElement(win) {
|
||||
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
||||
}
|
||||
|
||||
function getCssDimensions(element) {
|
||||
const css = getComputedStyle$1(element);
|
||||
// In testing environments, the `width` and `height` properties are empty
|
||||
// strings for SVG elements, returning NaN. Fallback to `0` in this case.
|
||||
let width = parseFloat(css.width) || 0;
|
||||
let height = parseFloat(css.height) || 0;
|
||||
const hasOffset = isHTMLElement(element);
|
||||
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
||||
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
||||
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
||||
if (shouldFallback) {
|
||||
width = offsetWidth;
|
||||
height = offsetHeight;
|
||||
}
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
$: shouldFallback
|
||||
};
|
||||
}
|
||||
|
||||
function unwrapElement(element) {
|
||||
return !isElement(element) ? element.contextElement : element;
|
||||
}
|
||||
|
||||
function getScale(element) {
|
||||
const domElement = unwrapElement(element);
|
||||
if (!isHTMLElement(domElement)) {
|
||||
return createCoords(1);
|
||||
}
|
||||
const rect = domElement.getBoundingClientRect();
|
||||
const {
|
||||
width,
|
||||
height,
|
||||
$
|
||||
} = getCssDimensions(domElement);
|
||||
let x = ($ ? round(rect.width) : rect.width) / width;
|
||||
let y = ($ ? round(rect.height) : rect.height) / height;
|
||||
|
||||
// 0, NaN, or Infinity should always fallback to 1.
|
||||
|
||||
if (!x || !Number.isFinite(x)) {
|
||||
x = 1;
|
||||
}
|
||||
if (!y || !Number.isFinite(y)) {
|
||||
y = 1;
|
||||
}
|
||||
return {
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
const noOffsets = /*#__PURE__*/createCoords(0);
|
||||
function getVisualOffsets(element) {
|
||||
const win = getWindow(element);
|
||||
if (!isWebKit() || !win.visualViewport) {
|
||||
return noOffsets;
|
||||
}
|
||||
return {
|
||||
x: win.visualViewport.offsetLeft,
|
||||
y: win.visualViewport.offsetTop
|
||||
};
|
||||
}
|
||||
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
||||
if (isFixed === void 0) {
|
||||
isFixed = false;
|
||||
}
|
||||
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
||||
return false;
|
||||
}
|
||||
return isFixed;
|
||||
}
|
||||
|
||||
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
||||
if (includeScale === void 0) {
|
||||
includeScale = false;
|
||||
}
|
||||
if (isFixedStrategy === void 0) {
|
||||
isFixedStrategy = false;
|
||||
}
|
||||
const clientRect = element.getBoundingClientRect();
|
||||
const domElement = unwrapElement(element);
|
||||
let scale = createCoords(1);
|
||||
if (includeScale) {
|
||||
if (offsetParent) {
|
||||
if (isElement(offsetParent)) {
|
||||
scale = getScale(offsetParent);
|
||||
}
|
||||
} else {
|
||||
scale = getScale(element);
|
||||
}
|
||||
}
|
||||
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
||||
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
||||
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
||||
let width = clientRect.width / scale.x;
|
||||
let height = clientRect.height / scale.y;
|
||||
if (domElement) {
|
||||
const win = getWindow(domElement);
|
||||
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
||||
let currentWin = win;
|
||||
let currentIFrame = getFrameElement(currentWin);
|
||||
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
||||
const iframeScale = getScale(currentIFrame);
|
||||
const iframeRect = currentIFrame.getBoundingClientRect();
|
||||
const css = getComputedStyle$1(currentIFrame);
|
||||
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
||||
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
||||
x *= iframeScale.x;
|
||||
y *= iframeScale.y;
|
||||
width *= iframeScale.x;
|
||||
height *= iframeScale.y;
|
||||
x += left;
|
||||
y += top;
|
||||
currentWin = getWindow(currentIFrame);
|
||||
currentIFrame = getFrameElement(currentWin);
|
||||
}
|
||||
}
|
||||
return core.rectToClientRect({
|
||||
width,
|
||||
height,
|
||||
x,
|
||||
y
|
||||
});
|
||||
}
|
||||
|
||||
// If <html> has a CSS width greater than the viewport, then this will be
|
||||
// incorrect for RTL.
|
||||
function getWindowScrollBarX(element, rect) {
|
||||
const leftScroll = getNodeScroll(element).scrollLeft;
|
||||
if (!rect) {
|
||||
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
||||
}
|
||||
return rect.left + leftScroll;
|
||||
}
|
||||
|
||||
function getHTMLOffset(documentElement, scroll) {
|
||||
const htmlRect = documentElement.getBoundingClientRect();
|
||||
const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
|
||||
const y = htmlRect.top + scroll.scrollTop;
|
||||
return {
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
||||
let {
|
||||
elements,
|
||||
rect,
|
||||
offsetParent,
|
||||
strategy
|
||||
} = _ref;
|
||||
const isFixed = strategy === 'fixed';
|
||||
const documentElement = getDocumentElement(offsetParent);
|
||||
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
||||
if (offsetParent === documentElement || topLayer && isFixed) {
|
||||
return rect;
|
||||
}
|
||||
let scroll = {
|
||||
scrollLeft: 0,
|
||||
scrollTop: 0
|
||||
};
|
||||
let scale = createCoords(1);
|
||||
const offsets = createCoords(0);
|
||||
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
||||
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
||||
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
||||
scroll = getNodeScroll(offsetParent);
|
||||
}
|
||||
if (isHTMLElement(offsetParent)) {
|
||||
const offsetRect = getBoundingClientRect(offsetParent);
|
||||
scale = getScale(offsetParent);
|
||||
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
||||
offsets.y = offsetRect.y + offsetParent.clientTop;
|
||||
}
|
||||
}
|
||||
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
||||
return {
|
||||
width: rect.width * scale.x,
|
||||
height: rect.height * scale.y,
|
||||
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
||||
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
||||
};
|
||||
}
|
||||
|
||||
function getClientRects(element) {
|
||||
return Array.from(element.getClientRects());
|
||||
}
|
||||
|
||||
// Gets the entire size of the scrollable document area, even extending outside
|
||||
// of the `<html>` and `<body>` rect bounds if horizontally scrollable.
|
||||
function getDocumentRect(element) {
|
||||
const html = getDocumentElement(element);
|
||||
const scroll = getNodeScroll(element);
|
||||
const body = element.ownerDocument.body;
|
||||
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
||||
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
||||
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
||||
const y = -scroll.scrollTop;
|
||||
if (getComputedStyle$1(body).direction === 'rtl') {
|
||||
x += max(html.clientWidth, body.clientWidth) - width;
|
||||
}
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
// Safety check: ensure the scrollbar space is reasonable in case this
|
||||
// calculation is affected by unusual styles.
|
||||
// Most scrollbars leave 15-18px of space.
|
||||
const SCROLLBAR_MAX = 25;
|
||||
function getViewportRect(element, strategy) {
|
||||
const win = getWindow(element);
|
||||
const html = getDocumentElement(element);
|
||||
const visualViewport = win.visualViewport;
|
||||
let width = html.clientWidth;
|
||||
let height = html.clientHeight;
|
||||
let x = 0;
|
||||
let y = 0;
|
||||
if (visualViewport) {
|
||||
width = visualViewport.width;
|
||||
height = visualViewport.height;
|
||||
const visualViewportBased = isWebKit();
|
||||
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
|
||||
x = visualViewport.offsetLeft;
|
||||
y = visualViewport.offsetTop;
|
||||
}
|
||||
}
|
||||
const windowScrollbarX = getWindowScrollBarX(html);
|
||||
// <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
|
||||
// visual width of the <html> but this is not considered in the size
|
||||
// of `html.clientWidth`.
|
||||
if (windowScrollbarX <= 0) {
|
||||
const doc = html.ownerDocument;
|
||||
const body = doc.body;
|
||||
const bodyStyles = getComputedStyle(body);
|
||||
const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
|
||||
const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
|
||||
if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
|
||||
width -= clippingStableScrollbarWidth;
|
||||
}
|
||||
} else if (windowScrollbarX <= SCROLLBAR_MAX) {
|
||||
// If the <body> scrollbar is on the left, the width needs to be extended
|
||||
// by the scrollbar amount so there isn't extra space on the right.
|
||||
width += windowScrollbarX;
|
||||
}
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
const absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);
|
||||
// Returns the inner client rect, subtracting scrollbars if present.
|
||||
function getInnerBoundingClientRect(element, strategy) {
|
||||
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
||||
const top = clientRect.top + element.clientTop;
|
||||
const left = clientRect.left + element.clientLeft;
|
||||
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
||||
const width = element.clientWidth * scale.x;
|
||||
const height = element.clientHeight * scale.y;
|
||||
const x = left * scale.x;
|
||||
const y = top * scale.y;
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
||||
let rect;
|
||||
if (clippingAncestor === 'viewport') {
|
||||
rect = getViewportRect(element, strategy);
|
||||
} else if (clippingAncestor === 'document') {
|
||||
rect = getDocumentRect(getDocumentElement(element));
|
||||
} else if (isElement(clippingAncestor)) {
|
||||
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
||||
} else {
|
||||
const visualOffsets = getVisualOffsets(element);
|
||||
rect = {
|
||||
x: clippingAncestor.x - visualOffsets.x,
|
||||
y: clippingAncestor.y - visualOffsets.y,
|
||||
width: clippingAncestor.width,
|
||||
height: clippingAncestor.height
|
||||
};
|
||||
}
|
||||
return core.rectToClientRect(rect);
|
||||
}
|
||||
function hasFixedPositionAncestor(element, stopNode) {
|
||||
const parentNode = getParentNode(element);
|
||||
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
||||
return false;
|
||||
}
|
||||
return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
|
||||
}
|
||||
|
||||
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
||||
// clipping (or hiding) child elements. This returns all clipping ancestors
|
||||
// of the given element up the tree.
|
||||
function getClippingElementAncestors(element, cache) {
|
||||
const cachedResult = cache.get(element);
|
||||
if (cachedResult) {
|
||||
return cachedResult;
|
||||
}
|
||||
let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
||||
let currentContainingBlockComputedStyle = null;
|
||||
const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
|
||||
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
||||
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
||||
const computedStyle = getComputedStyle$1(currentNode);
|
||||
const currentNodeIsContaining = isContainingBlock(currentNode);
|
||||
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
||||
currentContainingBlockComputedStyle = null;
|
||||
}
|
||||
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
||||
if (shouldDropCurrentNode) {
|
||||
// Drop non-containing blocks.
|
||||
result = result.filter(ancestor => ancestor !== currentNode);
|
||||
} else {
|
||||
// Record last containing block for next iteration.
|
||||
currentContainingBlockComputedStyle = computedStyle;
|
||||
}
|
||||
currentNode = getParentNode(currentNode);
|
||||
}
|
||||
cache.set(element, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Gets the maximum area that the element is visible in due to any number of
|
||||
// clipping ancestors.
|
||||
function getClippingRect(_ref) {
|
||||
let {
|
||||
element,
|
||||
boundary,
|
||||
rootBoundary,
|
||||
strategy
|
||||
} = _ref;
|
||||
const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
||||
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
||||
const firstClippingAncestor = clippingAncestors[0];
|
||||
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
||||
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
||||
accRect.top = max(rect.top, accRect.top);
|
||||
accRect.right = min(rect.right, accRect.right);
|
||||
accRect.bottom = min(rect.bottom, accRect.bottom);
|
||||
accRect.left = max(rect.left, accRect.left);
|
||||
return accRect;
|
||||
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
||||
return {
|
||||
width: clippingRect.right - clippingRect.left,
|
||||
height: clippingRect.bottom - clippingRect.top,
|
||||
x: clippingRect.left,
|
||||
y: clippingRect.top
|
||||
};
|
||||
}
|
||||
|
||||
function getDimensions(element) {
|
||||
const {
|
||||
width,
|
||||
height
|
||||
} = getCssDimensions(element);
|
||||
return {
|
||||
width,
|
||||
height
|
||||
};
|
||||
}
|
||||
|
||||
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
||||
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
||||
const documentElement = getDocumentElement(offsetParent);
|
||||
const isFixed = strategy === 'fixed';
|
||||
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
||||
let scroll = {
|
||||
scrollLeft: 0,
|
||||
scrollTop: 0
|
||||
};
|
||||
const offsets = createCoords(0);
|
||||
|
||||
// If the <body> scrollbar appears on the left (e.g. RTL systems). Use
|
||||
// Firefox with layout.scrollbar.side = 3 in about:config to test this.
|
||||
function setLeftRTLScrollbarOffset() {
|
||||
offsets.x = getWindowScrollBarX(documentElement);
|
||||
}
|
||||
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
||||
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
||||
scroll = getNodeScroll(offsetParent);
|
||||
}
|
||||
if (isOffsetParentAnElement) {
|
||||
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
||||
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
||||
offsets.y = offsetRect.y + offsetParent.clientTop;
|
||||
} else if (documentElement) {
|
||||
setLeftRTLScrollbarOffset();
|
||||
}
|
||||
}
|
||||
if (isFixed && !isOffsetParentAnElement && documentElement) {
|
||||
setLeftRTLScrollbarOffset();
|
||||
}
|
||||
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
||||
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
||||
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
||||
return {
|
||||
x,
|
||||
y,
|
||||
width: rect.width,
|
||||
height: rect.height
|
||||
};
|
||||
}
|
||||
|
||||
function isStaticPositioned(element) {
|
||||
return getComputedStyle$1(element).position === 'static';
|
||||
}
|
||||
|
||||
function getTrueOffsetParent(element, polyfill) {
|
||||
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
|
||||
return null;
|
||||
}
|
||||
if (polyfill) {
|
||||
return polyfill(element);
|
||||
}
|
||||
let rawOffsetParent = element.offsetParent;
|
||||
|
||||
// Firefox returns the <html> element as the offsetParent if it's non-static,
|
||||
// while Chrome and Safari return the <body> element. The <body> element must
|
||||
// be used to perform the correct calculations even if the <html> element is
|
||||
// non-static.
|
||||
if (getDocumentElement(element) === rawOffsetParent) {
|
||||
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
||||
}
|
||||
return rawOffsetParent;
|
||||
}
|
||||
|
||||
// Gets the closest ancestor positioned element. Handles some edge cases,
|
||||
// such as table ancestors and cross browser bugs.
|
||||
function getOffsetParent(element, polyfill) {
|
||||
const win = getWindow(element);
|
||||
if (isTopLayer(element)) {
|
||||
return win;
|
||||
}
|
||||
if (!isHTMLElement(element)) {
|
||||
let svgOffsetParent = getParentNode(element);
|
||||
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
||||
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
||||
return svgOffsetParent;
|
||||
}
|
||||
svgOffsetParent = getParentNode(svgOffsetParent);
|
||||
}
|
||||
return win;
|
||||
}
|
||||
let offsetParent = getTrueOffsetParent(element, polyfill);
|
||||
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
||||
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
||||
}
|
||||
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
||||
return win;
|
||||
}
|
||||
return offsetParent || getContainingBlock(element) || win;
|
||||
}
|
||||
|
||||
const getElementRects = async function (data) {
|
||||
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
||||
const getDimensionsFn = this.getDimensions;
|
||||
const floatingDimensions = await getDimensionsFn(data.floating);
|
||||
return {
|
||||
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
||||
floating: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: floatingDimensions.width,
|
||||
height: floatingDimensions.height
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
function isRTL(element) {
|
||||
return getComputedStyle$1(element).direction === 'rtl';
|
||||
}
|
||||
|
||||
const platform = {
|
||||
convertOffsetParentRelativeRectToViewportRelativeRect,
|
||||
getDocumentElement,
|
||||
getClippingRect,
|
||||
getOffsetParent,
|
||||
getElementRects,
|
||||
getClientRects,
|
||||
getDimensions,
|
||||
getScale,
|
||||
isElement,
|
||||
isRTL
|
||||
};
|
||||
|
||||
function rectsAreEqual(a, b) {
|
||||
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
||||
}
|
||||
|
||||
// https://samthor.au/2021/observing-dom/
|
||||
function observeMove(element, onMove) {
|
||||
let io = null;
|
||||
let timeoutId;
|
||||
const root = getDocumentElement(element);
|
||||
function cleanup() {
|
||||
var _io;
|
||||
clearTimeout(timeoutId);
|
||||
(_io = io) == null || _io.disconnect();
|
||||
io = null;
|
||||
}
|
||||
function refresh(skip, threshold) {
|
||||
if (skip === void 0) {
|
||||
skip = false;
|
||||
}
|
||||
if (threshold === void 0) {
|
||||
threshold = 1;
|
||||
}
|
||||
cleanup();
|
||||
const elementRectForRootMargin = element.getBoundingClientRect();
|
||||
const {
|
||||
left,
|
||||
top,
|
||||
width,
|
||||
height
|
||||
} = elementRectForRootMargin;
|
||||
if (!skip) {
|
||||
onMove();
|
||||
}
|
||||
if (!width || !height) {
|
||||
return;
|
||||
}
|
||||
const insetTop = floor(top);
|
||||
const insetRight = floor(root.clientWidth - (left + width));
|
||||
const insetBottom = floor(root.clientHeight - (top + height));
|
||||
const insetLeft = floor(left);
|
||||
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
||||
const options = {
|
||||
rootMargin,
|
||||
threshold: max(0, min(1, threshold)) || 1
|
||||
};
|
||||
let isFirstUpdate = true;
|
||||
function handleObserve(entries) {
|
||||
const ratio = entries[0].intersectionRatio;
|
||||
if (ratio !== threshold) {
|
||||
if (!isFirstUpdate) {
|
||||
return refresh();
|
||||
}
|
||||
if (!ratio) {
|
||||
// If the reference is clipped, the ratio is 0. Throttle the refresh
|
||||
// to prevent an infinite loop of updates.
|
||||
timeoutId = setTimeout(() => {
|
||||
refresh(false, 1e-7);
|
||||
}, 1000);
|
||||
} else {
|
||||
refresh(false, ratio);
|
||||
}
|
||||
}
|
||||
if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
|
||||
// It's possible that even though the ratio is reported as 1, the
|
||||
// element is not actually fully within the IntersectionObserver's root
|
||||
// area anymore. This can happen under performance constraints. This may
|
||||
// be a bug in the browser's IntersectionObserver implementation. To
|
||||
// work around this, we compare the element's bounding rect now with
|
||||
// what it was at the time we created the IntersectionObserver. If they
|
||||
// are not equal then the element moved, so we refresh.
|
||||
refresh();
|
||||
}
|
||||
isFirstUpdate = false;
|
||||
}
|
||||
|
||||
// Older browsers don't support a `document` as the root and will throw an
|
||||
// error.
|
||||
try {
|
||||
io = new IntersectionObserver(handleObserve, {
|
||||
...options,
|
||||
// Handle <iframe>s
|
||||
root: root.ownerDocument
|
||||
});
|
||||
} catch (_e) {
|
||||
io = new IntersectionObserver(handleObserve, options);
|
||||
}
|
||||
io.observe(element);
|
||||
}
|
||||
refresh(true);
|
||||
return cleanup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically updates the position of the floating element when necessary.
|
||||
* Should only be called when the floating element is mounted on the DOM or
|
||||
* visible on the screen.
|
||||
* @returns cleanup function that should be invoked when the floating element is
|
||||
* removed from the DOM or hidden from the screen.
|
||||
* @see https://floating-ui.com/docs/autoUpdate
|
||||
*/
|
||||
function autoUpdate(reference, floating, update, options) {
|
||||
if (options === void 0) {
|
||||
options = {};
|
||||
}
|
||||
const {
|
||||
ancestorScroll = true,
|
||||
ancestorResize = true,
|
||||
elementResize = typeof ResizeObserver === 'function',
|
||||
layoutShift = typeof IntersectionObserver === 'function',
|
||||
animationFrame = false
|
||||
} = options;
|
||||
const referenceEl = unwrapElement(reference);
|
||||
const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
|
||||
ancestors.forEach(ancestor => {
|
||||
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
||||
passive: true
|
||||
});
|
||||
ancestorResize && ancestor.addEventListener('resize', update);
|
||||
});
|
||||
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
||||
let reobserveFrame = -1;
|
||||
let resizeObserver = null;
|
||||
if (elementResize) {
|
||||
resizeObserver = new ResizeObserver(_ref => {
|
||||
let [firstEntry] = _ref;
|
||||
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
||||
// Prevent update loops when using the `size` middleware.
|
||||
// https://github.com/floating-ui/floating-ui/issues/1740
|
||||
resizeObserver.unobserve(floating);
|
||||
cancelAnimationFrame(reobserveFrame);
|
||||
reobserveFrame = requestAnimationFrame(() => {
|
||||
var _resizeObserver;
|
||||
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
|
||||
});
|
||||
}
|
||||
update();
|
||||
});
|
||||
if (referenceEl && !animationFrame) {
|
||||
resizeObserver.observe(referenceEl);
|
||||
}
|
||||
resizeObserver.observe(floating);
|
||||
}
|
||||
let frameId;
|
||||
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
||||
if (animationFrame) {
|
||||
frameLoop();
|
||||
}
|
||||
function frameLoop() {
|
||||
const nextRefRect = getBoundingClientRect(reference);
|
||||
if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
|
||||
update();
|
||||
}
|
||||
prevRefRect = nextRefRect;
|
||||
frameId = requestAnimationFrame(frameLoop);
|
||||
}
|
||||
update();
|
||||
return () => {
|
||||
var _resizeObserver2;
|
||||
ancestors.forEach(ancestor => {
|
||||
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
||||
ancestorResize && ancestor.removeEventListener('resize', update);
|
||||
});
|
||||
cleanupIo == null || cleanupIo();
|
||||
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
|
||||
resizeObserver = null;
|
||||
if (animationFrame) {
|
||||
cancelAnimationFrame(frameId);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves with an object of overflow side offsets that determine how much the
|
||||
* element is overflowing a given clipping boundary on each side.
|
||||
* - positive = overflowing the boundary by that number of pixels
|
||||
* - negative = how many pixels left before it will overflow
|
||||
* - 0 = lies flush with the boundary
|
||||
* @see https://floating-ui.com/docs/detectOverflow
|
||||
*/
|
||||
const detectOverflow = core.detectOverflow;
|
||||
|
||||
/**
|
||||
* Modifies the placement by translating the floating element along the
|
||||
* specified axes.
|
||||
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
||||
* object may be passed.
|
||||
* @see https://floating-ui.com/docs/offset
|
||||
*/
|
||||
const offset = core.offset;
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by choosing the placement
|
||||
* that has the most space available automatically, without needing to specify a
|
||||
* preferred placement. Alternative to `flip`.
|
||||
* @see https://floating-ui.com/docs/autoPlacement
|
||||
*/
|
||||
const autoPlacement = core.autoPlacement;
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by shifting it in order to
|
||||
* keep it in view when it will overflow the clipping boundary.
|
||||
* @see https://floating-ui.com/docs/shift
|
||||
*/
|
||||
const shift = core.shift;
|
||||
|
||||
/**
|
||||
* Optimizes the visibility of the floating element by flipping the `placement`
|
||||
* in order to keep it in view when the preferred placement(s) will overflow the
|
||||
* clipping boundary. Alternative to `autoPlacement`.
|
||||
* @see https://floating-ui.com/docs/flip
|
||||
*/
|
||||
const flip = core.flip;
|
||||
|
||||
/**
|
||||
* Provides data that allows you to change the size of the floating element —
|
||||
* for instance, prevent it from overflowing the clipping boundary or match the
|
||||
* width of the reference element.
|
||||
* @see https://floating-ui.com/docs/size
|
||||
*/
|
||||
const size = core.size;
|
||||
|
||||
/**
|
||||
* Provides data to hide the floating element in applicable situations, such as
|
||||
* when it is not in the same clipping context as the reference element.
|
||||
* @see https://floating-ui.com/docs/hide
|
||||
*/
|
||||
const hide = core.hide;
|
||||
|
||||
/**
|
||||
* Provides data to position an inner element of the floating element so that it
|
||||
* appears centered to the reference element.
|
||||
* @see https://floating-ui.com/docs/arrow
|
||||
*/
|
||||
const arrow = core.arrow;
|
||||
|
||||
/**
|
||||
* Provides improved positioning for inline reference elements that can span
|
||||
* over multiple lines, such as hyperlinks or range selections.
|
||||
* @see https://floating-ui.com/docs/inline
|
||||
*/
|
||||
const inline = core.inline;
|
||||
|
||||
/**
|
||||
* Built-in `limiter` that will stop `shift()` at a certain point.
|
||||
*/
|
||||
const limitShift = core.limitShift;
|
||||
|
||||
/**
|
||||
* Computes the `x` and `y` coordinates that will place the floating element
|
||||
* next to a given reference element.
|
||||
*/
|
||||
const computePosition = (reference, floating, options) => {
|
||||
// This caches the expensive `getClippingElementAncestors` function so that
|
||||
// multiple lifecycle resets re-use the same result. It only lives for a
|
||||
// single call. If other functions become expensive, we can add them as well.
|
||||
const cache = new Map();
|
||||
const mergedOptions = {
|
||||
platform,
|
||||
...options
|
||||
};
|
||||
const platformWithCache = {
|
||||
...mergedOptions.platform,
|
||||
_c: cache
|
||||
};
|
||||
return core.computePosition(reference, floating, {
|
||||
...mergedOptions,
|
||||
platform: platformWithCache
|
||||
});
|
||||
};
|
||||
|
||||
exports.arrow = arrow;
|
||||
exports.autoPlacement = autoPlacement;
|
||||
exports.autoUpdate = autoUpdate;
|
||||
exports.computePosition = computePosition;
|
||||
exports.detectOverflow = detectOverflow;
|
||||
exports.flip = flip;
|
||||
exports.getOverflowAncestors = getOverflowAncestors;
|
||||
exports.hide = hide;
|
||||
exports.inline = inline;
|
||||
exports.limitShift = limitShift;
|
||||
exports.offset = offset;
|
||||
exports.platform = platform;
|
||||
exports.shift = shift;
|
||||
exports.size = size;
|
||||
|
||||
}));
|
||||
+1
File diff suppressed because one or more lines are too long
+71
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"name": "@floating-ui/dom",
|
||||
"version": "1.7.5",
|
||||
"description": "Floating UI for the web",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"main": "./dist/floating-ui.dom.umd.js",
|
||||
"module": "./dist/floating-ui.dom.esm.js",
|
||||
"unpkg": "./dist/floating-ui.dom.umd.min.js",
|
||||
"types": "./dist/floating-ui.dom.d.ts",
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/floating-ui.dom.d.mts",
|
||||
"default": "./dist/floating-ui.dom.mjs"
|
||||
},
|
||||
"types": "./dist/floating-ui.dom.d.ts",
|
||||
"module": "./dist/floating-ui.dom.esm.js",
|
||||
"default": "./dist/floating-ui.dom.umd.js"
|
||||
}
|
||||
},
|
||||
"sideEffects": false,
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"author": "atomiks",
|
||||
"license": "MIT",
|
||||
"bugs": "https://github.com/floating-ui/floating-ui",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/floating-ui/floating-ui.git",
|
||||
"directory": "packages/dom"
|
||||
},
|
||||
"homepage": "https://floating-ui.com",
|
||||
"keywords": [
|
||||
"tooltip",
|
||||
"popover",
|
||||
"dropdown",
|
||||
"menu",
|
||||
"popup",
|
||||
"positioning"
|
||||
],
|
||||
"dependencies": {
|
||||
"@floating-ui/core": "^1.7.4",
|
||||
"@floating-ui/utils": "^0.2.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.3.19",
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-router-dom": "^6.21.1",
|
||||
"config": "0.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"format": "prettier --write .",
|
||||
"clean": "rimraf dist out-tsc test-results",
|
||||
"dev": "vite",
|
||||
"build": "rollup -c",
|
||||
"build:api": "build-api --tsc tsconfig.lib.json",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest watch",
|
||||
"publint": "publint",
|
||||
"playwright": "playwright test ./test/functional",
|
||||
"typecheck": "tsc -b"
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021-present Floating UI contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
# @floating-ui/utils
|
||||
|
||||
Utility functions shared across Floating UI packages. You may use these
|
||||
functions in your own projects, but are subject to breaking changes.
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
export declare type AlignedPlacement = `${Side}-${Alignment}`;
|
||||
|
||||
export declare type Alignment = 'start' | 'end';
|
||||
|
||||
export declare const alignments: Alignment[];
|
||||
|
||||
export declare type Axis = 'x' | 'y';
|
||||
|
||||
export declare function clamp(start: number, value: number, end: number): number;
|
||||
|
||||
export declare type ClientRectObject = Prettify<Rect & SideObject>;
|
||||
|
||||
export declare type Coords = {
|
||||
[key in Axis]: number;
|
||||
};
|
||||
|
||||
export declare const createCoords: (v: number) => {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
|
||||
export declare type Dimensions = {
|
||||
[key in Length]: number;
|
||||
};
|
||||
|
||||
export declare interface ElementRects {
|
||||
reference: Rect;
|
||||
floating: Rect;
|
||||
}
|
||||
|
||||
export declare function evaluate<T, P>(value: T | ((param: P) => T), param: P): T;
|
||||
|
||||
export declare function expandPaddingObject(padding: Partial<SideObject>): SideObject;
|
||||
|
||||
export declare const floor: (x: number) => number;
|
||||
|
||||
export declare function getAlignment(placement: Placement): Alignment | undefined;
|
||||
|
||||
export declare function getAlignmentAxis(placement: Placement): Axis;
|
||||
|
||||
export declare function getAlignmentSides(placement: Placement, rects: ElementRects, rtl?: boolean): [Side, Side];
|
||||
|
||||
export declare function getAxisLength(axis: Axis): Length;
|
||||
|
||||
export declare function getExpandedPlacements(placement: Placement): Array<Placement>;
|
||||
|
||||
export declare function getOppositeAlignmentPlacement<T extends string>(placement: T): T;
|
||||
|
||||
export declare function getOppositeAxis(axis: Axis): Axis;
|
||||
|
||||
export declare function getOppositeAxisPlacements(placement: Placement, flipAlignment: boolean, direction: 'none' | Alignment, rtl?: boolean): Placement[];
|
||||
|
||||
export declare function getOppositePlacement<T extends string>(placement: T): T;
|
||||
|
||||
export declare function getPaddingObject(padding: Padding): SideObject;
|
||||
|
||||
export declare function getSide(placement: Placement): Side;
|
||||
|
||||
export declare function getSideAxis(placement: Placement): Axis;
|
||||
|
||||
export declare type Length = 'width' | 'height';
|
||||
|
||||
export declare const max: (...values: number[]) => number;
|
||||
|
||||
export declare const min: (...values: number[]) => number;
|
||||
|
||||
export declare type Padding = number | Prettify<Partial<SideObject>>;
|
||||
|
||||
export declare type Placement = Prettify<Side | AlignedPlacement>;
|
||||
|
||||
export declare const placements: Placement[];
|
||||
|
||||
declare type Prettify<T> = {
|
||||
[K in keyof T]: T[K];
|
||||
} & {};
|
||||
|
||||
export declare type Rect = Prettify<Coords & Dimensions>;
|
||||
|
||||
export declare function rectToClientRect(rect: Rect): ClientRectObject;
|
||||
|
||||
export declare const round: (x: number) => number;
|
||||
|
||||
export declare type Side = 'top' | 'right' | 'bottom' | 'left';
|
||||
|
||||
export declare type SideObject = {
|
||||
[key in Side]: number;
|
||||
};
|
||||
|
||||
export declare const sides: Side[];
|
||||
|
||||
export declare type Strategy = 'absolute' | 'fixed';
|
||||
|
||||
/**
|
||||
* Custom positioning reference element.
|
||||
* @see https://floating-ui.com/docs/virtual-elements
|
||||
*/
|
||||
export declare interface VirtualElement {
|
||||
getBoundingClientRect(): ClientRectObject;
|
||||
getClientRects?(): Array<ClientRectObject>;
|
||||
contextElement?: any;
|
||||
}
|
||||
|
||||
export { }
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
export declare type AlignedPlacement = `${Side}-${Alignment}`;
|
||||
|
||||
export declare type Alignment = 'start' | 'end';
|
||||
|
||||
export declare const alignments: Alignment[];
|
||||
|
||||
export declare type Axis = 'x' | 'y';
|
||||
|
||||
export declare function clamp(start: number, value: number, end: number): number;
|
||||
|
||||
export declare type ClientRectObject = Prettify<Rect & SideObject>;
|
||||
|
||||
export declare type Coords = {
|
||||
[key in Axis]: number;
|
||||
};
|
||||
|
||||
export declare const createCoords: (v: number) => {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
|
||||
export declare type Dimensions = {
|
||||
[key in Length]: number;
|
||||
};
|
||||
|
||||
export declare interface ElementRects {
|
||||
reference: Rect;
|
||||
floating: Rect;
|
||||
}
|
||||
|
||||
export declare function evaluate<T, P>(value: T | ((param: P) => T), param: P): T;
|
||||
|
||||
export declare function expandPaddingObject(padding: Partial<SideObject>): SideObject;
|
||||
|
||||
export declare const floor: (x: number) => number;
|
||||
|
||||
export declare function getAlignment(placement: Placement): Alignment | undefined;
|
||||
|
||||
export declare function getAlignmentAxis(placement: Placement): Axis;
|
||||
|
||||
export declare function getAlignmentSides(placement: Placement, rects: ElementRects, rtl?: boolean): [Side, Side];
|
||||
|
||||
export declare function getAxisLength(axis: Axis): Length;
|
||||
|
||||
export declare function getExpandedPlacements(placement: Placement): Array<Placement>;
|
||||
|
||||
export declare function getOppositeAlignmentPlacement<T extends string>(placement: T): T;
|
||||
|
||||
export declare function getOppositeAxis(axis: Axis): Axis;
|
||||
|
||||
export declare function getOppositeAxisPlacements(placement: Placement, flipAlignment: boolean, direction: 'none' | Alignment, rtl?: boolean): Placement[];
|
||||
|
||||
export declare function getOppositePlacement<T extends string>(placement: T): T;
|
||||
|
||||
export declare function getPaddingObject(padding: Padding): SideObject;
|
||||
|
||||
export declare function getSide(placement: Placement): Side;
|
||||
|
||||
export declare function getSideAxis(placement: Placement): Axis;
|
||||
|
||||
export declare type Length = 'width' | 'height';
|
||||
|
||||
export declare const max: (...values: number[]) => number;
|
||||
|
||||
export declare const min: (...values: number[]) => number;
|
||||
|
||||
export declare type Padding = number | Prettify<Partial<SideObject>>;
|
||||
|
||||
export declare type Placement = Prettify<Side | AlignedPlacement>;
|
||||
|
||||
export declare const placements: Placement[];
|
||||
|
||||
declare type Prettify<T> = {
|
||||
[K in keyof T]: T[K];
|
||||
} & {};
|
||||
|
||||
export declare type Rect = Prettify<Coords & Dimensions>;
|
||||
|
||||
export declare function rectToClientRect(rect: Rect): ClientRectObject;
|
||||
|
||||
export declare const round: (x: number) => number;
|
||||
|
||||
export declare type Side = 'top' | 'right' | 'bottom' | 'left';
|
||||
|
||||
export declare type SideObject = {
|
||||
[key in Side]: number;
|
||||
};
|
||||
|
||||
export declare const sides: Side[];
|
||||
|
||||
export declare type Strategy = 'absolute' | 'fixed';
|
||||
|
||||
/**
|
||||
* Custom positioning reference element.
|
||||
* @see https://floating-ui.com/docs/virtual-elements
|
||||
*/
|
||||
export declare interface VirtualElement {
|
||||
getBoundingClientRect(): ClientRectObject;
|
||||
getClientRects?(): Array<ClientRectObject>;
|
||||
contextElement?: any;
|
||||
}
|
||||
|
||||
export { }
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
declare function getComputedStyle_2(element: Element): CSSStyleDeclaration;
|
||||
export { getComputedStyle_2 as getComputedStyle }
|
||||
|
||||
export declare function getContainingBlock(element: Element): HTMLElement | null;
|
||||
|
||||
export declare function getDocumentElement(node: Node | Window): HTMLElement;
|
||||
|
||||
export declare function getFrameElement(win: Window): Element | null;
|
||||
|
||||
export declare function getNearestOverflowAncestor(node: Node): HTMLElement;
|
||||
|
||||
export declare function getNodeName(node: Node | Window): string;
|
||||
|
||||
export declare function getNodeScroll(element: Element | Window): {
|
||||
scrollLeft: number;
|
||||
scrollTop: number;
|
||||
};
|
||||
|
||||
export declare function getOverflowAncestors(node: Node, list?: OverflowAncestors, traverseIframes?: boolean): OverflowAncestors;
|
||||
|
||||
export declare function getParentNode(node: Node): Node;
|
||||
|
||||
export declare function getWindow(node: any): typeof window;
|
||||
|
||||
export declare function isContainingBlock(elementOrCss: Element | CSSStyleDeclaration): boolean;
|
||||
|
||||
export declare function isElement(value: unknown): value is Element;
|
||||
|
||||
export declare function isHTMLElement(value: unknown): value is HTMLElement;
|
||||
|
||||
export declare function isLastTraversableNode(node: Node): boolean;
|
||||
|
||||
export declare function isNode(value: unknown): value is Node;
|
||||
|
||||
export declare function isOverflowElement(element: Element): boolean;
|
||||
|
||||
export declare function isShadowRoot(value: unknown): value is ShadowRoot;
|
||||
|
||||
export declare function isTableElement(element: Element): boolean;
|
||||
|
||||
export declare function isTopLayer(element: Element): boolean;
|
||||
|
||||
export declare function isWebKit(): boolean;
|
||||
|
||||
declare type OverflowAncestors = Array<Element | Window | VisualViewport>;
|
||||
|
||||
export { }
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
declare function getComputedStyle_2(element: Element): CSSStyleDeclaration;
|
||||
export { getComputedStyle_2 as getComputedStyle }
|
||||
|
||||
export declare function getContainingBlock(element: Element): HTMLElement | null;
|
||||
|
||||
export declare function getDocumentElement(node: Node | Window): HTMLElement;
|
||||
|
||||
export declare function getFrameElement(win: Window): Element | null;
|
||||
|
||||
export declare function getNearestOverflowAncestor(node: Node): HTMLElement;
|
||||
|
||||
export declare function getNodeName(node: Node | Window): string;
|
||||
|
||||
export declare function getNodeScroll(element: Element | Window): {
|
||||
scrollLeft: number;
|
||||
scrollTop: number;
|
||||
};
|
||||
|
||||
export declare function getOverflowAncestors(node: Node, list?: OverflowAncestors, traverseIframes?: boolean): OverflowAncestors;
|
||||
|
||||
export declare function getParentNode(node: Node): Node;
|
||||
|
||||
export declare function getWindow(node: any): typeof window;
|
||||
|
||||
export declare function isContainingBlock(elementOrCss: Element | CSSStyleDeclaration): boolean;
|
||||
|
||||
export declare function isElement(value: unknown): value is Element;
|
||||
|
||||
export declare function isHTMLElement(value: unknown): value is HTMLElement;
|
||||
|
||||
export declare function isLastTraversableNode(node: Node): boolean;
|
||||
|
||||
export declare function isNode(value: unknown): value is Node;
|
||||
|
||||
export declare function isOverflowElement(element: Element): boolean;
|
||||
|
||||
export declare function isShadowRoot(value: unknown): value is ShadowRoot;
|
||||
|
||||
export declare function isTableElement(element: Element): boolean;
|
||||
|
||||
export declare function isTopLayer(element: Element): boolean;
|
||||
|
||||
export declare function isWebKit(): boolean;
|
||||
|
||||
declare type OverflowAncestors = Array<Element | Window | VisualViewport>;
|
||||
|
||||
export { }
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
function hasWindow() {
|
||||
return typeof window !== 'undefined';
|
||||
}
|
||||
function getNodeName(node) {
|
||||
if (isNode(node)) {
|
||||
return (node.nodeName || '').toLowerCase();
|
||||
}
|
||||
// Mocked nodes in testing environments may not be instances of Node. By
|
||||
// returning `#document` an infinite loop won't occur.
|
||||
// https://github.com/floating-ui/floating-ui/issues/2317
|
||||
return '#document';
|
||||
}
|
||||
function getWindow(node) {
|
||||
var _node$ownerDocument;
|
||||
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
||||
}
|
||||
function getDocumentElement(node) {
|
||||
var _ref;
|
||||
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
||||
}
|
||||
function isNode(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof Node || value instanceof getWindow(value).Node;
|
||||
}
|
||||
function isElement(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof Element || value instanceof getWindow(value).Element;
|
||||
}
|
||||
function isHTMLElement(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
||||
}
|
||||
function isShadowRoot(value) {
|
||||
if (!hasWindow() || typeof ShadowRoot === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
||||
}
|
||||
const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
|
||||
function isOverflowElement(element) {
|
||||
const {
|
||||
overflow,
|
||||
overflowX,
|
||||
overflowY,
|
||||
display
|
||||
} = getComputedStyle(element);
|
||||
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
||||
}
|
||||
const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
|
||||
function isTableElement(element) {
|
||||
return tableElements.has(getNodeName(element));
|
||||
}
|
||||
const topLayerSelectors = [':popover-open', ':modal'];
|
||||
function isTopLayer(element) {
|
||||
return topLayerSelectors.some(selector => {
|
||||
try {
|
||||
return element.matches(selector);
|
||||
} catch (_e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
|
||||
const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
|
||||
const containValues = ['paint', 'layout', 'strict', 'content'];
|
||||
function isContainingBlock(elementOrCss) {
|
||||
const webkit = isWebKit();
|
||||
const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
||||
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
||||
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));
|
||||
}
|
||||
function getContainingBlock(element) {
|
||||
let currentNode = getParentNode(element);
|
||||
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
||||
if (isContainingBlock(currentNode)) {
|
||||
return currentNode;
|
||||
} else if (isTopLayer(currentNode)) {
|
||||
return null;
|
||||
}
|
||||
currentNode = getParentNode(currentNode);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function isWebKit() {
|
||||
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
||||
return CSS.supports('-webkit-backdrop-filter', 'none');
|
||||
}
|
||||
const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
|
||||
function isLastTraversableNode(node) {
|
||||
return lastTraversableNodeNames.has(getNodeName(node));
|
||||
}
|
||||
function getComputedStyle(element) {
|
||||
return getWindow(element).getComputedStyle(element);
|
||||
}
|
||||
function getNodeScroll(element) {
|
||||
if (isElement(element)) {
|
||||
return {
|
||||
scrollLeft: element.scrollLeft,
|
||||
scrollTop: element.scrollTop
|
||||
};
|
||||
}
|
||||
return {
|
||||
scrollLeft: element.scrollX,
|
||||
scrollTop: element.scrollY
|
||||
};
|
||||
}
|
||||
function getParentNode(node) {
|
||||
if (getNodeName(node) === 'html') {
|
||||
return node;
|
||||
}
|
||||
const result =
|
||||
// Step into the shadow DOM of the parent of a slotted node.
|
||||
node.assignedSlot ||
|
||||
// DOM Element detected.
|
||||
node.parentNode ||
|
||||
// ShadowRoot detected.
|
||||
isShadowRoot(node) && node.host ||
|
||||
// Fallback.
|
||||
getDocumentElement(node);
|
||||
return isShadowRoot(result) ? result.host : result;
|
||||
}
|
||||
function getNearestOverflowAncestor(node) {
|
||||
const parentNode = getParentNode(node);
|
||||
if (isLastTraversableNode(parentNode)) {
|
||||
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
||||
}
|
||||
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
||||
return parentNode;
|
||||
}
|
||||
return getNearestOverflowAncestor(parentNode);
|
||||
}
|
||||
function getOverflowAncestors(node, list, traverseIframes) {
|
||||
var _node$ownerDocument2;
|
||||
if (list === void 0) {
|
||||
list = [];
|
||||
}
|
||||
if (traverseIframes === void 0) {
|
||||
traverseIframes = true;
|
||||
}
|
||||
const scrollableAncestor = getNearestOverflowAncestor(node);
|
||||
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
||||
const win = getWindow(scrollableAncestor);
|
||||
if (isBody) {
|
||||
const frameElement = getFrameElement(win);
|
||||
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
||||
}
|
||||
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
||||
}
|
||||
function getFrameElement(win) {
|
||||
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
||||
}
|
||||
|
||||
export { getComputedStyle, getContainingBlock, getDocumentElement, getFrameElement, getNearestOverflowAncestor, getNodeName, getNodeScroll, getOverflowAncestors, getParentNode, getWindow, isContainingBlock, isElement, isHTMLElement, isLastTraversableNode, isNode, isOverflowElement, isShadowRoot, isTableElement, isTopLayer, isWebKit };
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
function hasWindow() {
|
||||
return typeof window !== 'undefined';
|
||||
}
|
||||
function getNodeName(node) {
|
||||
if (isNode(node)) {
|
||||
return (node.nodeName || '').toLowerCase();
|
||||
}
|
||||
// Mocked nodes in testing environments may not be instances of Node. By
|
||||
// returning `#document` an infinite loop won't occur.
|
||||
// https://github.com/floating-ui/floating-ui/issues/2317
|
||||
return '#document';
|
||||
}
|
||||
function getWindow(node) {
|
||||
var _node$ownerDocument;
|
||||
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
||||
}
|
||||
function getDocumentElement(node) {
|
||||
var _ref;
|
||||
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
||||
}
|
||||
function isNode(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof Node || value instanceof getWindow(value).Node;
|
||||
}
|
||||
function isElement(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof Element || value instanceof getWindow(value).Element;
|
||||
}
|
||||
function isHTMLElement(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
||||
}
|
||||
function isShadowRoot(value) {
|
||||
if (!hasWindow() || typeof ShadowRoot === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
||||
}
|
||||
const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
|
||||
function isOverflowElement(element) {
|
||||
const {
|
||||
overflow,
|
||||
overflowX,
|
||||
overflowY,
|
||||
display
|
||||
} = getComputedStyle(element);
|
||||
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
||||
}
|
||||
const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
|
||||
function isTableElement(element) {
|
||||
return tableElements.has(getNodeName(element));
|
||||
}
|
||||
const topLayerSelectors = [':popover-open', ':modal'];
|
||||
function isTopLayer(element) {
|
||||
return topLayerSelectors.some(selector => {
|
||||
try {
|
||||
return element.matches(selector);
|
||||
} catch (_e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
|
||||
const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
|
||||
const containValues = ['paint', 'layout', 'strict', 'content'];
|
||||
function isContainingBlock(elementOrCss) {
|
||||
const webkit = isWebKit();
|
||||
const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
||||
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
||||
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));
|
||||
}
|
||||
function getContainingBlock(element) {
|
||||
let currentNode = getParentNode(element);
|
||||
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
||||
if (isContainingBlock(currentNode)) {
|
||||
return currentNode;
|
||||
} else if (isTopLayer(currentNode)) {
|
||||
return null;
|
||||
}
|
||||
currentNode = getParentNode(currentNode);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function isWebKit() {
|
||||
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
||||
return CSS.supports('-webkit-backdrop-filter', 'none');
|
||||
}
|
||||
const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
|
||||
function isLastTraversableNode(node) {
|
||||
return lastTraversableNodeNames.has(getNodeName(node));
|
||||
}
|
||||
function getComputedStyle(element) {
|
||||
return getWindow(element).getComputedStyle(element);
|
||||
}
|
||||
function getNodeScroll(element) {
|
||||
if (isElement(element)) {
|
||||
return {
|
||||
scrollLeft: element.scrollLeft,
|
||||
scrollTop: element.scrollTop
|
||||
};
|
||||
}
|
||||
return {
|
||||
scrollLeft: element.scrollX,
|
||||
scrollTop: element.scrollY
|
||||
};
|
||||
}
|
||||
function getParentNode(node) {
|
||||
if (getNodeName(node) === 'html') {
|
||||
return node;
|
||||
}
|
||||
const result =
|
||||
// Step into the shadow DOM of the parent of a slotted node.
|
||||
node.assignedSlot ||
|
||||
// DOM Element detected.
|
||||
node.parentNode ||
|
||||
// ShadowRoot detected.
|
||||
isShadowRoot(node) && node.host ||
|
||||
// Fallback.
|
||||
getDocumentElement(node);
|
||||
return isShadowRoot(result) ? result.host : result;
|
||||
}
|
||||
function getNearestOverflowAncestor(node) {
|
||||
const parentNode = getParentNode(node);
|
||||
if (isLastTraversableNode(parentNode)) {
|
||||
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
||||
}
|
||||
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
||||
return parentNode;
|
||||
}
|
||||
return getNearestOverflowAncestor(parentNode);
|
||||
}
|
||||
function getOverflowAncestors(node, list, traverseIframes) {
|
||||
var _node$ownerDocument2;
|
||||
if (list === void 0) {
|
||||
list = [];
|
||||
}
|
||||
if (traverseIframes === void 0) {
|
||||
traverseIframes = true;
|
||||
}
|
||||
const scrollableAncestor = getNearestOverflowAncestor(node);
|
||||
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
||||
const win = getWindow(scrollableAncestor);
|
||||
if (isBody) {
|
||||
const frameElement = getFrameElement(win);
|
||||
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
||||
}
|
||||
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
||||
}
|
||||
function getFrameElement(win) {
|
||||
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
||||
}
|
||||
|
||||
export { getComputedStyle, getContainingBlock, getDocumentElement, getFrameElement, getNearestOverflowAncestor, getNodeName, getNodeScroll, getOverflowAncestors, getParentNode, getWindow, isContainingBlock, isElement, isHTMLElement, isLastTraversableNode, isNode, isOverflowElement, isShadowRoot, isTableElement, isTopLayer, isWebKit };
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.FloatingUIUtilsDOM = {}));
|
||||
})(this, (function (exports) { 'use strict';
|
||||
|
||||
function hasWindow() {
|
||||
return typeof window !== 'undefined';
|
||||
}
|
||||
function getNodeName(node) {
|
||||
if (isNode(node)) {
|
||||
return (node.nodeName || '').toLowerCase();
|
||||
}
|
||||
// Mocked nodes in testing environments may not be instances of Node. By
|
||||
// returning `#document` an infinite loop won't occur.
|
||||
// https://github.com/floating-ui/floating-ui/issues/2317
|
||||
return '#document';
|
||||
}
|
||||
function getWindow(node) {
|
||||
var _node$ownerDocument;
|
||||
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
||||
}
|
||||
function getDocumentElement(node) {
|
||||
var _ref;
|
||||
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
||||
}
|
||||
function isNode(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof Node || value instanceof getWindow(value).Node;
|
||||
}
|
||||
function isElement(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof Element || value instanceof getWindow(value).Element;
|
||||
}
|
||||
function isHTMLElement(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
||||
}
|
||||
function isShadowRoot(value) {
|
||||
if (!hasWindow() || typeof ShadowRoot === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
||||
}
|
||||
const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
|
||||
function isOverflowElement(element) {
|
||||
const {
|
||||
overflow,
|
||||
overflowX,
|
||||
overflowY,
|
||||
display
|
||||
} = getComputedStyle(element);
|
||||
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
||||
}
|
||||
const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
|
||||
function isTableElement(element) {
|
||||
return tableElements.has(getNodeName(element));
|
||||
}
|
||||
const topLayerSelectors = [':popover-open', ':modal'];
|
||||
function isTopLayer(element) {
|
||||
return topLayerSelectors.some(selector => {
|
||||
try {
|
||||
return element.matches(selector);
|
||||
} catch (_e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
|
||||
const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
|
||||
const containValues = ['paint', 'layout', 'strict', 'content'];
|
||||
function isContainingBlock(elementOrCss) {
|
||||
const webkit = isWebKit();
|
||||
const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
||||
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
||||
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));
|
||||
}
|
||||
function getContainingBlock(element) {
|
||||
let currentNode = getParentNode(element);
|
||||
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
||||
if (isContainingBlock(currentNode)) {
|
||||
return currentNode;
|
||||
} else if (isTopLayer(currentNode)) {
|
||||
return null;
|
||||
}
|
||||
currentNode = getParentNode(currentNode);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function isWebKit() {
|
||||
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
||||
return CSS.supports('-webkit-backdrop-filter', 'none');
|
||||
}
|
||||
const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
|
||||
function isLastTraversableNode(node) {
|
||||
return lastTraversableNodeNames.has(getNodeName(node));
|
||||
}
|
||||
function getComputedStyle(element) {
|
||||
return getWindow(element).getComputedStyle(element);
|
||||
}
|
||||
function getNodeScroll(element) {
|
||||
if (isElement(element)) {
|
||||
return {
|
||||
scrollLeft: element.scrollLeft,
|
||||
scrollTop: element.scrollTop
|
||||
};
|
||||
}
|
||||
return {
|
||||
scrollLeft: element.scrollX,
|
||||
scrollTop: element.scrollY
|
||||
};
|
||||
}
|
||||
function getParentNode(node) {
|
||||
if (getNodeName(node) === 'html') {
|
||||
return node;
|
||||
}
|
||||
const result =
|
||||
// Step into the shadow DOM of the parent of a slotted node.
|
||||
node.assignedSlot ||
|
||||
// DOM Element detected.
|
||||
node.parentNode ||
|
||||
// ShadowRoot detected.
|
||||
isShadowRoot(node) && node.host ||
|
||||
// Fallback.
|
||||
getDocumentElement(node);
|
||||
return isShadowRoot(result) ? result.host : result;
|
||||
}
|
||||
function getNearestOverflowAncestor(node) {
|
||||
const parentNode = getParentNode(node);
|
||||
if (isLastTraversableNode(parentNode)) {
|
||||
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
||||
}
|
||||
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
||||
return parentNode;
|
||||
}
|
||||
return getNearestOverflowAncestor(parentNode);
|
||||
}
|
||||
function getOverflowAncestors(node, list, traverseIframes) {
|
||||
var _node$ownerDocument2;
|
||||
if (list === void 0) {
|
||||
list = [];
|
||||
}
|
||||
if (traverseIframes === void 0) {
|
||||
traverseIframes = true;
|
||||
}
|
||||
const scrollableAncestor = getNearestOverflowAncestor(node);
|
||||
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
||||
const win = getWindow(scrollableAncestor);
|
||||
if (isBody) {
|
||||
const frameElement = getFrameElement(win);
|
||||
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
||||
}
|
||||
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
||||
}
|
||||
function getFrameElement(win) {
|
||||
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
||||
}
|
||||
|
||||
exports.getComputedStyle = getComputedStyle;
|
||||
exports.getContainingBlock = getContainingBlock;
|
||||
exports.getDocumentElement = getDocumentElement;
|
||||
exports.getFrameElement = getFrameElement;
|
||||
exports.getNearestOverflowAncestor = getNearestOverflowAncestor;
|
||||
exports.getNodeName = getNodeName;
|
||||
exports.getNodeScroll = getNodeScroll;
|
||||
exports.getOverflowAncestors = getOverflowAncestors;
|
||||
exports.getParentNode = getParentNode;
|
||||
exports.getWindow = getWindow;
|
||||
exports.isContainingBlock = isContainingBlock;
|
||||
exports.isElement = isElement;
|
||||
exports.isHTMLElement = isHTMLElement;
|
||||
exports.isLastTraversableNode = isLastTraversableNode;
|
||||
exports.isNode = isNode;
|
||||
exports.isOverflowElement = isOverflowElement;
|
||||
exports.isShadowRoot = isShadowRoot;
|
||||
exports.isTableElement = isTableElement;
|
||||
exports.isTopLayer = isTopLayer;
|
||||
exports.isWebKit = isWebKit;
|
||||
|
||||
}));
|
||||
+1
@@ -0,0 +1 @@
|
||||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).FloatingUIUtilsDOM={})}(this,(function(e){"use strict";function n(){return"undefined"!=typeof window}function t(e){return i(e)?(e.nodeName||"").toLowerCase():"#document"}function o(e){var n;return(null==e||null==(n=e.ownerDocument)?void 0:n.defaultView)||window}function r(e){var n;return null==(n=(i(e)?e.ownerDocument:e.document)||window.document)?void 0:n.documentElement}function i(e){return!!n()&&(e instanceof Node||e instanceof o(e).Node)}function c(e){return!!n()&&(e instanceof Element||e instanceof o(e).Element)}function l(e){return!!n()&&(e instanceof HTMLElement||e instanceof o(e).HTMLElement)}function s(e){return!(!n()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof o(e).ShadowRoot)}const u=new Set(["inline","contents"]);function a(e){const{overflow:n,overflowX:t,overflowY:o,display:r}=b(e);return/auto|scroll|overlay|hidden|clip/.test(n+o+t)&&!u.has(r)}const f=new Set(["table","td","th"]);const d=[":popover-open",":modal"];function m(e){return d.some((n=>{try{return e.matches(n)}catch(e){return!1}}))}const p=["transform","translate","scale","rotate","perspective"],w=["transform","translate","scale","rotate","perspective","filter"],y=["paint","layout","strict","content"];function v(e){const n=g(),t=c(e)?b(e):e;return p.some((e=>!!t[e]&&"none"!==t[e]))||!!t.containerType&&"normal"!==t.containerType||!n&&!!t.backdropFilter&&"none"!==t.backdropFilter||!n&&!!t.filter&&"none"!==t.filter||w.some((e=>(t.willChange||"").includes(e)))||y.some((e=>(t.contain||"").includes(e)))}function g(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const h=new Set(["html","body","#document"]);function S(e){return h.has(t(e))}function b(e){return o(e).getComputedStyle(e)}function T(e){if("html"===t(e))return e;const n=e.assignedSlot||e.parentNode||s(e)&&e.host||r(e);return s(n)?n.host:n}function E(e){const n=T(e);return S(n)?e.ownerDocument?e.ownerDocument.body:e.body:l(n)&&a(n)?n:E(n)}function N(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}e.getComputedStyle=b,e.getContainingBlock=function(e){let n=T(e);for(;l(n)&&!S(n);){if(v(n))return n;if(m(n))return null;n=T(n)}return null},e.getDocumentElement=r,e.getFrameElement=N,e.getNearestOverflowAncestor=E,e.getNodeName=t,e.getNodeScroll=function(e){return c(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}},e.getOverflowAncestors=function e(n,t,r){var i;void 0===t&&(t=[]),void 0===r&&(r=!0);const c=E(n),l=c===(null==(i=n.ownerDocument)?void 0:i.body),s=o(c);if(l){const n=N(s);return t.concat(s,s.visualViewport||[],a(c)?c:[],n&&r?e(n):[])}return t.concat(c,e(c,[],r))},e.getParentNode=T,e.getWindow=o,e.isContainingBlock=v,e.isElement=c,e.isHTMLElement=l,e.isLastTraversableNode=S,e.isNode=i,e.isOverflowElement=a,e.isShadowRoot=s,e.isTableElement=function(e){return f.has(t(e))},e.isTopLayer=m,e.isWebKit=g}));
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* Custom positioning reference element.
|
||||
* @see https://floating-ui.com/docs/virtual-elements
|
||||
*/
|
||||
|
||||
const sides = ['top', 'right', 'bottom', 'left'];
|
||||
const alignments = ['start', 'end'];
|
||||
const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
|
||||
const min = Math.min;
|
||||
const max = Math.max;
|
||||
const round = Math.round;
|
||||
const floor = Math.floor;
|
||||
const createCoords = v => ({
|
||||
x: v,
|
||||
y: v
|
||||
});
|
||||
const oppositeSideMap = {
|
||||
left: 'right',
|
||||
right: 'left',
|
||||
bottom: 'top',
|
||||
top: 'bottom'
|
||||
};
|
||||
const oppositeAlignmentMap = {
|
||||
start: 'end',
|
||||
end: 'start'
|
||||
};
|
||||
function clamp(start, value, end) {
|
||||
return max(start, min(value, end));
|
||||
}
|
||||
function evaluate(value, param) {
|
||||
return typeof value === 'function' ? value(param) : value;
|
||||
}
|
||||
function getSide(placement) {
|
||||
return placement.split('-')[0];
|
||||
}
|
||||
function getAlignment(placement) {
|
||||
return placement.split('-')[1];
|
||||
}
|
||||
function getOppositeAxis(axis) {
|
||||
return axis === 'x' ? 'y' : 'x';
|
||||
}
|
||||
function getAxisLength(axis) {
|
||||
return axis === 'y' ? 'height' : 'width';
|
||||
}
|
||||
const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
|
||||
function getSideAxis(placement) {
|
||||
return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
|
||||
}
|
||||
function getAlignmentAxis(placement) {
|
||||
return getOppositeAxis(getSideAxis(placement));
|
||||
}
|
||||
function getAlignmentSides(placement, rects, rtl) {
|
||||
if (rtl === void 0) {
|
||||
rtl = false;
|
||||
}
|
||||
const alignment = getAlignment(placement);
|
||||
const alignmentAxis = getAlignmentAxis(placement);
|
||||
const length = getAxisLength(alignmentAxis);
|
||||
let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
||||
if (rects.reference[length] > rects.floating[length]) {
|
||||
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
||||
}
|
||||
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
||||
}
|
||||
function getExpandedPlacements(placement) {
|
||||
const oppositePlacement = getOppositePlacement(placement);
|
||||
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
||||
}
|
||||
function getOppositeAlignmentPlacement(placement) {
|
||||
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
||||
}
|
||||
const lrPlacement = ['left', 'right'];
|
||||
const rlPlacement = ['right', 'left'];
|
||||
const tbPlacement = ['top', 'bottom'];
|
||||
const btPlacement = ['bottom', 'top'];
|
||||
function getSideList(side, isStart, rtl) {
|
||||
switch (side) {
|
||||
case 'top':
|
||||
case 'bottom':
|
||||
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
||||
return isStart ? lrPlacement : rlPlacement;
|
||||
case 'left':
|
||||
case 'right':
|
||||
return isStart ? tbPlacement : btPlacement;
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
||||
const alignment = getAlignment(placement);
|
||||
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
||||
if (alignment) {
|
||||
list = list.map(side => side + "-" + alignment);
|
||||
if (flipAlignment) {
|
||||
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
function getOppositePlacement(placement) {
|
||||
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
||||
}
|
||||
function expandPaddingObject(padding) {
|
||||
return {
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
...padding
|
||||
};
|
||||
}
|
||||
function getPaddingObject(padding) {
|
||||
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
||||
top: padding,
|
||||
right: padding,
|
||||
bottom: padding,
|
||||
left: padding
|
||||
};
|
||||
}
|
||||
function rectToClientRect(rect) {
|
||||
const {
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height
|
||||
} = rect;
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
top: y,
|
||||
left: x,
|
||||
right: x + width,
|
||||
bottom: y + height,
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
export { alignments, clamp, createCoords, evaluate, expandPaddingObject, floor, getAlignment, getAlignmentAxis, getAlignmentSides, getAxisLength, getExpandedPlacements, getOppositeAlignmentPlacement, getOppositeAxis, getOppositeAxisPlacements, getOppositePlacement, getPaddingObject, getSide, getSideAxis, max, min, placements, rectToClientRect, round, sides };
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* Custom positioning reference element.
|
||||
* @see https://floating-ui.com/docs/virtual-elements
|
||||
*/
|
||||
|
||||
const sides = ['top', 'right', 'bottom', 'left'];
|
||||
const alignments = ['start', 'end'];
|
||||
const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
|
||||
const min = Math.min;
|
||||
const max = Math.max;
|
||||
const round = Math.round;
|
||||
const floor = Math.floor;
|
||||
const createCoords = v => ({
|
||||
x: v,
|
||||
y: v
|
||||
});
|
||||
const oppositeSideMap = {
|
||||
left: 'right',
|
||||
right: 'left',
|
||||
bottom: 'top',
|
||||
top: 'bottom'
|
||||
};
|
||||
const oppositeAlignmentMap = {
|
||||
start: 'end',
|
||||
end: 'start'
|
||||
};
|
||||
function clamp(start, value, end) {
|
||||
return max(start, min(value, end));
|
||||
}
|
||||
function evaluate(value, param) {
|
||||
return typeof value === 'function' ? value(param) : value;
|
||||
}
|
||||
function getSide(placement) {
|
||||
return placement.split('-')[0];
|
||||
}
|
||||
function getAlignment(placement) {
|
||||
return placement.split('-')[1];
|
||||
}
|
||||
function getOppositeAxis(axis) {
|
||||
return axis === 'x' ? 'y' : 'x';
|
||||
}
|
||||
function getAxisLength(axis) {
|
||||
return axis === 'y' ? 'height' : 'width';
|
||||
}
|
||||
const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
|
||||
function getSideAxis(placement) {
|
||||
return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
|
||||
}
|
||||
function getAlignmentAxis(placement) {
|
||||
return getOppositeAxis(getSideAxis(placement));
|
||||
}
|
||||
function getAlignmentSides(placement, rects, rtl) {
|
||||
if (rtl === void 0) {
|
||||
rtl = false;
|
||||
}
|
||||
const alignment = getAlignment(placement);
|
||||
const alignmentAxis = getAlignmentAxis(placement);
|
||||
const length = getAxisLength(alignmentAxis);
|
||||
let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
||||
if (rects.reference[length] > rects.floating[length]) {
|
||||
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
||||
}
|
||||
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
||||
}
|
||||
function getExpandedPlacements(placement) {
|
||||
const oppositePlacement = getOppositePlacement(placement);
|
||||
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
||||
}
|
||||
function getOppositeAlignmentPlacement(placement) {
|
||||
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
||||
}
|
||||
const lrPlacement = ['left', 'right'];
|
||||
const rlPlacement = ['right', 'left'];
|
||||
const tbPlacement = ['top', 'bottom'];
|
||||
const btPlacement = ['bottom', 'top'];
|
||||
function getSideList(side, isStart, rtl) {
|
||||
switch (side) {
|
||||
case 'top':
|
||||
case 'bottom':
|
||||
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
||||
return isStart ? lrPlacement : rlPlacement;
|
||||
case 'left':
|
||||
case 'right':
|
||||
return isStart ? tbPlacement : btPlacement;
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
||||
const alignment = getAlignment(placement);
|
||||
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
||||
if (alignment) {
|
||||
list = list.map(side => side + "-" + alignment);
|
||||
if (flipAlignment) {
|
||||
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
function getOppositePlacement(placement) {
|
||||
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
||||
}
|
||||
function expandPaddingObject(padding) {
|
||||
return {
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
...padding
|
||||
};
|
||||
}
|
||||
function getPaddingObject(padding) {
|
||||
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
||||
top: padding,
|
||||
right: padding,
|
||||
bottom: padding,
|
||||
left: padding
|
||||
};
|
||||
}
|
||||
function rectToClientRect(rect) {
|
||||
const {
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height
|
||||
} = rect;
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
top: y,
|
||||
left: x,
|
||||
right: x + width,
|
||||
bottom: y + height,
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
export { alignments, clamp, createCoords, evaluate, expandPaddingObject, floor, getAlignment, getAlignmentAxis, getAlignmentSides, getAxisLength, getExpandedPlacements, getOppositeAlignmentPlacement, getOppositeAxis, getOppositeAxisPlacements, getOppositePlacement, getPaddingObject, getSide, getSideAxis, max, min, placements, rectToClientRect, round, sides };
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.FloatingUIUtils = {}));
|
||||
})(this, (function (exports) { 'use strict';
|
||||
|
||||
/**
|
||||
* Custom positioning reference element.
|
||||
* @see https://floating-ui.com/docs/virtual-elements
|
||||
*/
|
||||
|
||||
const sides = ['top', 'right', 'bottom', 'left'];
|
||||
const alignments = ['start', 'end'];
|
||||
const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
|
||||
const min = Math.min;
|
||||
const max = Math.max;
|
||||
const round = Math.round;
|
||||
const floor = Math.floor;
|
||||
const createCoords = v => ({
|
||||
x: v,
|
||||
y: v
|
||||
});
|
||||
const oppositeSideMap = {
|
||||
left: 'right',
|
||||
right: 'left',
|
||||
bottom: 'top',
|
||||
top: 'bottom'
|
||||
};
|
||||
const oppositeAlignmentMap = {
|
||||
start: 'end',
|
||||
end: 'start'
|
||||
};
|
||||
function clamp(start, value, end) {
|
||||
return max(start, min(value, end));
|
||||
}
|
||||
function evaluate(value, param) {
|
||||
return typeof value === 'function' ? value(param) : value;
|
||||
}
|
||||
function getSide(placement) {
|
||||
return placement.split('-')[0];
|
||||
}
|
||||
function getAlignment(placement) {
|
||||
return placement.split('-')[1];
|
||||
}
|
||||
function getOppositeAxis(axis) {
|
||||
return axis === 'x' ? 'y' : 'x';
|
||||
}
|
||||
function getAxisLength(axis) {
|
||||
return axis === 'y' ? 'height' : 'width';
|
||||
}
|
||||
const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
|
||||
function getSideAxis(placement) {
|
||||
return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
|
||||
}
|
||||
function getAlignmentAxis(placement) {
|
||||
return getOppositeAxis(getSideAxis(placement));
|
||||
}
|
||||
function getAlignmentSides(placement, rects, rtl) {
|
||||
if (rtl === void 0) {
|
||||
rtl = false;
|
||||
}
|
||||
const alignment = getAlignment(placement);
|
||||
const alignmentAxis = getAlignmentAxis(placement);
|
||||
const length = getAxisLength(alignmentAxis);
|
||||
let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
||||
if (rects.reference[length] > rects.floating[length]) {
|
||||
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
||||
}
|
||||
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
||||
}
|
||||
function getExpandedPlacements(placement) {
|
||||
const oppositePlacement = getOppositePlacement(placement);
|
||||
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
||||
}
|
||||
function getOppositeAlignmentPlacement(placement) {
|
||||
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
||||
}
|
||||
const lrPlacement = ['left', 'right'];
|
||||
const rlPlacement = ['right', 'left'];
|
||||
const tbPlacement = ['top', 'bottom'];
|
||||
const btPlacement = ['bottom', 'top'];
|
||||
function getSideList(side, isStart, rtl) {
|
||||
switch (side) {
|
||||
case 'top':
|
||||
case 'bottom':
|
||||
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
||||
return isStart ? lrPlacement : rlPlacement;
|
||||
case 'left':
|
||||
case 'right':
|
||||
return isStart ? tbPlacement : btPlacement;
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
||||
const alignment = getAlignment(placement);
|
||||
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
||||
if (alignment) {
|
||||
list = list.map(side => side + "-" + alignment);
|
||||
if (flipAlignment) {
|
||||
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
function getOppositePlacement(placement) {
|
||||
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
||||
}
|
||||
function expandPaddingObject(padding) {
|
||||
return {
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
...padding
|
||||
};
|
||||
}
|
||||
function getPaddingObject(padding) {
|
||||
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
||||
top: padding,
|
||||
right: padding,
|
||||
bottom: padding,
|
||||
left: padding
|
||||
};
|
||||
}
|
||||
function rectToClientRect(rect) {
|
||||
const {
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height
|
||||
} = rect;
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
top: y,
|
||||
left: x,
|
||||
right: x + width,
|
||||
bottom: y + height,
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
exports.alignments = alignments;
|
||||
exports.clamp = clamp;
|
||||
exports.createCoords = createCoords;
|
||||
exports.evaluate = evaluate;
|
||||
exports.expandPaddingObject = expandPaddingObject;
|
||||
exports.floor = floor;
|
||||
exports.getAlignment = getAlignment;
|
||||
exports.getAlignmentAxis = getAlignmentAxis;
|
||||
exports.getAlignmentSides = getAlignmentSides;
|
||||
exports.getAxisLength = getAxisLength;
|
||||
exports.getExpandedPlacements = getExpandedPlacements;
|
||||
exports.getOppositeAlignmentPlacement = getOppositeAlignmentPlacement;
|
||||
exports.getOppositeAxis = getOppositeAxis;
|
||||
exports.getOppositeAxisPlacements = getOppositeAxisPlacements;
|
||||
exports.getOppositePlacement = getOppositePlacement;
|
||||
exports.getPaddingObject = getPaddingObject;
|
||||
exports.getSide = getSide;
|
||||
exports.getSideAxis = getSideAxis;
|
||||
exports.max = max;
|
||||
exports.min = min;
|
||||
exports.placements = placements;
|
||||
exports.rectToClientRect = rectToClientRect;
|
||||
exports.round = round;
|
||||
exports.sides = sides;
|
||||
|
||||
}));
|
||||
+1
@@ -0,0 +1 @@
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).FloatingUIUtils={})}(this,(function(t){"use strict";const e=["top","right","bottom","left"],n=["start","end"],o=e.reduce(((t,e)=>t.concat(e,e+"-"+n[0],e+"-"+n[1])),[]),i=Math.min,r=Math.max,c=Math.round,u=Math.floor,f={left:"right",right:"left",bottom:"top",top:"bottom"},s={start:"end",end:"start"};function a(t){return t.split("-")[0]}function l(t){return t.split("-")[1]}function g(t){return"x"===t?"y":"x"}function p(t){return"y"===t?"height":"width"}const d=new Set(["top","bottom"]);function m(t){return d.has(a(t))?"y":"x"}function h(t){return g(m(t))}function x(t){return t.replace(/start|end/g,(t=>s[t]))}const b=["left","right"],y=["right","left"],A=["top","bottom"],O=["bottom","top"];function P(t){return t.replace(/left|right|bottom|top/g,(t=>f[t]))}function w(t){return{top:0,right:0,bottom:0,left:0,...t}}t.alignments=n,t.clamp=function(t,e,n){return r(t,i(e,n))},t.createCoords=t=>({x:t,y:t}),t.evaluate=function(t,e){return"function"==typeof t?t(e):t},t.expandPaddingObject=w,t.floor=u,t.getAlignment=l,t.getAlignmentAxis=h,t.getAlignmentSides=function(t,e,n){void 0===n&&(n=!1);const o=l(t),i=h(t),r=p(i);let c="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return e.reference[r]>e.floating[r]&&(c=P(c)),[c,P(c)]},t.getAxisLength=p,t.getExpandedPlacements=function(t){const e=P(t);return[x(t),e,x(e)]},t.getOppositeAlignmentPlacement=x,t.getOppositeAxis=g,t.getOppositeAxisPlacements=function(t,e,n,o){const i=l(t);let r=function(t,e,n){switch(t){case"top":case"bottom":return n?e?y:b:e?b:y;case"left":case"right":return e?A:O;default:return[]}}(a(t),"start"===n,o);return i&&(r=r.map((t=>t+"-"+i)),e&&(r=r.concat(r.map(x)))),r},t.getOppositePlacement=P,t.getPaddingObject=function(t){return"number"!=typeof t?w(t):{top:t,right:t,bottom:t,left:t}},t.getSide=a,t.getSideAxis=m,t.max=r,t.min=i,t.placements=o,t.rectToClientRect=function(t){const{x:e,y:n,width:o,height:i}=t;return{width:o,height:i,top:n,left:e,right:e+o,bottom:n+i,x:e,y:n}},t.round=c,t.sides=e}));
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
declare function getComputedStyle_2(element: Element): CSSStyleDeclaration;
|
||||
export { getComputedStyle_2 as getComputedStyle }
|
||||
|
||||
export declare function getContainingBlock(element: Element): HTMLElement | null;
|
||||
|
||||
export declare function getDocumentElement(node: Node | Window): HTMLElement;
|
||||
|
||||
export declare function getFrameElement(win: Window): Element | null;
|
||||
|
||||
export declare function getNearestOverflowAncestor(node: Node): HTMLElement;
|
||||
|
||||
export declare function getNodeName(node: Node | Window): string;
|
||||
|
||||
export declare function getNodeScroll(element: Element | Window): {
|
||||
scrollLeft: number;
|
||||
scrollTop: number;
|
||||
};
|
||||
|
||||
export declare function getOverflowAncestors(node: Node, list?: OverflowAncestors, traverseIframes?: boolean): OverflowAncestors;
|
||||
|
||||
export declare function getParentNode(node: Node): Node;
|
||||
|
||||
export declare function getWindow(node: any): typeof window;
|
||||
|
||||
export declare function isContainingBlock(elementOrCss: Element | CSSStyleDeclaration): boolean;
|
||||
|
||||
export declare function isElement(value: unknown): value is Element;
|
||||
|
||||
export declare function isHTMLElement(value: unknown): value is HTMLElement;
|
||||
|
||||
export declare function isLastTraversableNode(node: Node): boolean;
|
||||
|
||||
export declare function isNode(value: unknown): value is Node;
|
||||
|
||||
export declare function isOverflowElement(element: Element): boolean;
|
||||
|
||||
export declare function isShadowRoot(value: unknown): value is ShadowRoot;
|
||||
|
||||
export declare function isTableElement(element: Element): boolean;
|
||||
|
||||
export declare function isTopLayer(element: Element): boolean;
|
||||
|
||||
export declare function isWebKit(): boolean;
|
||||
|
||||
declare type OverflowAncestors = Array<Element | Window | VisualViewport>;
|
||||
|
||||
export { }
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
function hasWindow() {
|
||||
return typeof window !== 'undefined';
|
||||
}
|
||||
function getNodeName(node) {
|
||||
if (isNode(node)) {
|
||||
return (node.nodeName || '').toLowerCase();
|
||||
}
|
||||
// Mocked nodes in testing environments may not be instances of Node. By
|
||||
// returning `#document` an infinite loop won't occur.
|
||||
// https://github.com/floating-ui/floating-ui/issues/2317
|
||||
return '#document';
|
||||
}
|
||||
function getWindow(node) {
|
||||
var _node$ownerDocument;
|
||||
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
||||
}
|
||||
function getDocumentElement(node) {
|
||||
var _ref;
|
||||
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
||||
}
|
||||
function isNode(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof Node || value instanceof getWindow(value).Node;
|
||||
}
|
||||
function isElement(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof Element || value instanceof getWindow(value).Element;
|
||||
}
|
||||
function isHTMLElement(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
||||
}
|
||||
function isShadowRoot(value) {
|
||||
if (!hasWindow() || typeof ShadowRoot === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
||||
}
|
||||
const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
|
||||
function isOverflowElement(element) {
|
||||
const {
|
||||
overflow,
|
||||
overflowX,
|
||||
overflowY,
|
||||
display
|
||||
} = getComputedStyle(element);
|
||||
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
||||
}
|
||||
const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
|
||||
function isTableElement(element) {
|
||||
return tableElements.has(getNodeName(element));
|
||||
}
|
||||
const topLayerSelectors = [':popover-open', ':modal'];
|
||||
function isTopLayer(element) {
|
||||
return topLayerSelectors.some(selector => {
|
||||
try {
|
||||
return element.matches(selector);
|
||||
} catch (_e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
|
||||
const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
|
||||
const containValues = ['paint', 'layout', 'strict', 'content'];
|
||||
function isContainingBlock(elementOrCss) {
|
||||
const webkit = isWebKit();
|
||||
const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
||||
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
||||
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));
|
||||
}
|
||||
function getContainingBlock(element) {
|
||||
let currentNode = getParentNode(element);
|
||||
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
||||
if (isContainingBlock(currentNode)) {
|
||||
return currentNode;
|
||||
} else if (isTopLayer(currentNode)) {
|
||||
return null;
|
||||
}
|
||||
currentNode = getParentNode(currentNode);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function isWebKit() {
|
||||
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
||||
return CSS.supports('-webkit-backdrop-filter', 'none');
|
||||
}
|
||||
const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
|
||||
function isLastTraversableNode(node) {
|
||||
return lastTraversableNodeNames.has(getNodeName(node));
|
||||
}
|
||||
function getComputedStyle(element) {
|
||||
return getWindow(element).getComputedStyle(element);
|
||||
}
|
||||
function getNodeScroll(element) {
|
||||
if (isElement(element)) {
|
||||
return {
|
||||
scrollLeft: element.scrollLeft,
|
||||
scrollTop: element.scrollTop
|
||||
};
|
||||
}
|
||||
return {
|
||||
scrollLeft: element.scrollX,
|
||||
scrollTop: element.scrollY
|
||||
};
|
||||
}
|
||||
function getParentNode(node) {
|
||||
if (getNodeName(node) === 'html') {
|
||||
return node;
|
||||
}
|
||||
const result =
|
||||
// Step into the shadow DOM of the parent of a slotted node.
|
||||
node.assignedSlot ||
|
||||
// DOM Element detected.
|
||||
node.parentNode ||
|
||||
// ShadowRoot detected.
|
||||
isShadowRoot(node) && node.host ||
|
||||
// Fallback.
|
||||
getDocumentElement(node);
|
||||
return isShadowRoot(result) ? result.host : result;
|
||||
}
|
||||
function getNearestOverflowAncestor(node) {
|
||||
const parentNode = getParentNode(node);
|
||||
if (isLastTraversableNode(parentNode)) {
|
||||
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
||||
}
|
||||
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
||||
return parentNode;
|
||||
}
|
||||
return getNearestOverflowAncestor(parentNode);
|
||||
}
|
||||
function getOverflowAncestors(node, list, traverseIframes) {
|
||||
var _node$ownerDocument2;
|
||||
if (list === void 0) {
|
||||
list = [];
|
||||
}
|
||||
if (traverseIframes === void 0) {
|
||||
traverseIframes = true;
|
||||
}
|
||||
const scrollableAncestor = getNearestOverflowAncestor(node);
|
||||
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
||||
const win = getWindow(scrollableAncestor);
|
||||
if (isBody) {
|
||||
const frameElement = getFrameElement(win);
|
||||
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
||||
}
|
||||
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
||||
}
|
||||
function getFrameElement(win) {
|
||||
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
||||
}
|
||||
|
||||
export { getComputedStyle, getContainingBlock, getDocumentElement, getFrameElement, getNearestOverflowAncestor, getNodeName, getNodeScroll, getOverflowAncestors, getParentNode, getWindow, isContainingBlock, isElement, isHTMLElement, isLastTraversableNode, isNode, isOverflowElement, isShadowRoot, isTableElement, isTopLayer, isWebKit };
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.FloatingUIUtilsDOM = {}));
|
||||
})(this, (function (exports) { 'use strict';
|
||||
|
||||
function hasWindow() {
|
||||
return typeof window !== 'undefined';
|
||||
}
|
||||
function getNodeName(node) {
|
||||
if (isNode(node)) {
|
||||
return (node.nodeName || '').toLowerCase();
|
||||
}
|
||||
// Mocked nodes in testing environments may not be instances of Node. By
|
||||
// returning `#document` an infinite loop won't occur.
|
||||
// https://github.com/floating-ui/floating-ui/issues/2317
|
||||
return '#document';
|
||||
}
|
||||
function getWindow(node) {
|
||||
var _node$ownerDocument;
|
||||
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
||||
}
|
||||
function getDocumentElement(node) {
|
||||
var _ref;
|
||||
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
||||
}
|
||||
function isNode(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof Node || value instanceof getWindow(value).Node;
|
||||
}
|
||||
function isElement(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof Element || value instanceof getWindow(value).Element;
|
||||
}
|
||||
function isHTMLElement(value) {
|
||||
if (!hasWindow()) {
|
||||
return false;
|
||||
}
|
||||
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
||||
}
|
||||
function isShadowRoot(value) {
|
||||
if (!hasWindow() || typeof ShadowRoot === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
||||
}
|
||||
const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
|
||||
function isOverflowElement(element) {
|
||||
const {
|
||||
overflow,
|
||||
overflowX,
|
||||
overflowY,
|
||||
display
|
||||
} = getComputedStyle(element);
|
||||
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
||||
}
|
||||
const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
|
||||
function isTableElement(element) {
|
||||
return tableElements.has(getNodeName(element));
|
||||
}
|
||||
const topLayerSelectors = [':popover-open', ':modal'];
|
||||
function isTopLayer(element) {
|
||||
return topLayerSelectors.some(selector => {
|
||||
try {
|
||||
return element.matches(selector);
|
||||
} catch (_e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
|
||||
const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
|
||||
const containValues = ['paint', 'layout', 'strict', 'content'];
|
||||
function isContainingBlock(elementOrCss) {
|
||||
const webkit = isWebKit();
|
||||
const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
||||
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
||||
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));
|
||||
}
|
||||
function getContainingBlock(element) {
|
||||
let currentNode = getParentNode(element);
|
||||
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
||||
if (isContainingBlock(currentNode)) {
|
||||
return currentNode;
|
||||
} else if (isTopLayer(currentNode)) {
|
||||
return null;
|
||||
}
|
||||
currentNode = getParentNode(currentNode);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function isWebKit() {
|
||||
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
||||
return CSS.supports('-webkit-backdrop-filter', 'none');
|
||||
}
|
||||
const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
|
||||
function isLastTraversableNode(node) {
|
||||
return lastTraversableNodeNames.has(getNodeName(node));
|
||||
}
|
||||
function getComputedStyle(element) {
|
||||
return getWindow(element).getComputedStyle(element);
|
||||
}
|
||||
function getNodeScroll(element) {
|
||||
if (isElement(element)) {
|
||||
return {
|
||||
scrollLeft: element.scrollLeft,
|
||||
scrollTop: element.scrollTop
|
||||
};
|
||||
}
|
||||
return {
|
||||
scrollLeft: element.scrollX,
|
||||
scrollTop: element.scrollY
|
||||
};
|
||||
}
|
||||
function getParentNode(node) {
|
||||
if (getNodeName(node) === 'html') {
|
||||
return node;
|
||||
}
|
||||
const result =
|
||||
// Step into the shadow DOM of the parent of a slotted node.
|
||||
node.assignedSlot ||
|
||||
// DOM Element detected.
|
||||
node.parentNode ||
|
||||
// ShadowRoot detected.
|
||||
isShadowRoot(node) && node.host ||
|
||||
// Fallback.
|
||||
getDocumentElement(node);
|
||||
return isShadowRoot(result) ? result.host : result;
|
||||
}
|
||||
function getNearestOverflowAncestor(node) {
|
||||
const parentNode = getParentNode(node);
|
||||
if (isLastTraversableNode(parentNode)) {
|
||||
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
||||
}
|
||||
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
||||
return parentNode;
|
||||
}
|
||||
return getNearestOverflowAncestor(parentNode);
|
||||
}
|
||||
function getOverflowAncestors(node, list, traverseIframes) {
|
||||
var _node$ownerDocument2;
|
||||
if (list === void 0) {
|
||||
list = [];
|
||||
}
|
||||
if (traverseIframes === void 0) {
|
||||
traverseIframes = true;
|
||||
}
|
||||
const scrollableAncestor = getNearestOverflowAncestor(node);
|
||||
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
||||
const win = getWindow(scrollableAncestor);
|
||||
if (isBody) {
|
||||
const frameElement = getFrameElement(win);
|
||||
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
||||
}
|
||||
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
||||
}
|
||||
function getFrameElement(win) {
|
||||
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
||||
}
|
||||
|
||||
exports.getComputedStyle = getComputedStyle;
|
||||
exports.getContainingBlock = getContainingBlock;
|
||||
exports.getDocumentElement = getDocumentElement;
|
||||
exports.getFrameElement = getFrameElement;
|
||||
exports.getNearestOverflowAncestor = getNearestOverflowAncestor;
|
||||
exports.getNodeName = getNodeName;
|
||||
exports.getNodeScroll = getNodeScroll;
|
||||
exports.getOverflowAncestors = getOverflowAncestors;
|
||||
exports.getParentNode = getParentNode;
|
||||
exports.getWindow = getWindow;
|
||||
exports.isContainingBlock = isContainingBlock;
|
||||
exports.isElement = isElement;
|
||||
exports.isHTMLElement = isHTMLElement;
|
||||
exports.isLastTraversableNode = isLastTraversableNode;
|
||||
exports.isNode = isNode;
|
||||
exports.isOverflowElement = isOverflowElement;
|
||||
exports.isShadowRoot = isShadowRoot;
|
||||
exports.isTableElement = isTableElement;
|
||||
exports.isTopLayer = isTopLayer;
|
||||
exports.isWebKit = isWebKit;
|
||||
|
||||
}));
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"sideEffects": false,
|
||||
"main": "floating-ui.utils.dom.umd.js",
|
||||
"module": "floating-ui.utils.dom.esm.js",
|
||||
"types": "floating-ui.utils.dom.d.ts"
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"name": "@floating-ui/utils",
|
||||
"version": "0.2.10",
|
||||
"description": "Utilities for Floating UI",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"main": "./dist/floating-ui.utils.umd.js",
|
||||
"module": "./dist/floating-ui.utils.esm.js",
|
||||
"types": "./dist/floating-ui.utils.d.ts",
|
||||
"sideEffects": false,
|
||||
"files": [
|
||||
"dist",
|
||||
"dom"
|
||||
],
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/floating-ui.utils.d.mts",
|
||||
"default": "./dist/floating-ui.utils.mjs"
|
||||
},
|
||||
"types": "./dist/floating-ui.utils.d.ts",
|
||||
"module": "./dist/floating-ui.utils.esm.js",
|
||||
"default": "./dist/floating-ui.utils.umd.js"
|
||||
},
|
||||
"./dom": {
|
||||
"import": {
|
||||
"types": "./dist/floating-ui.utils.dom.d.mts",
|
||||
"default": "./dist/floating-ui.utils.dom.mjs"
|
||||
},
|
||||
"types": "./dist/floating-ui.utils.dom.d.ts",
|
||||
"module": "./dist/floating-ui.utils.dom.esm.js",
|
||||
"default": "./dist/floating-ui.utils.dom.umd.js"
|
||||
}
|
||||
},
|
||||
"author": "atomiks",
|
||||
"license": "MIT",
|
||||
"bugs": "https://github.com/floating-ui/floating-ui",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/floating-ui/floating-ui.git",
|
||||
"directory": "packages/utils"
|
||||
},
|
||||
"homepage": "https://floating-ui.com",
|
||||
"keywords": [
|
||||
"tooltip",
|
||||
"popover",
|
||||
"dropdown",
|
||||
"menu",
|
||||
"popup",
|
||||
"positioning"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@testing-library/jest-dom": "^6.1.6",
|
||||
"config": "0.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"format": "prettier --write .",
|
||||
"clean": "rimraf dist out-tsc dom react",
|
||||
"test": "vitest run --globals",
|
||||
"test:watch": "vitest watch --globals",
|
||||
"dev": "rollup -c -w",
|
||||
"build": "rollup -c",
|
||||
"build:api": "build-api --tsc tsconfig.lib.json --aec api-extractor.json --aec api-extractor.dom.json --aec api-extractor.react.json",
|
||||
"publint": "publint",
|
||||
"typecheck": "tsc -b"
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019-2022, Remirror Contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+431
@@ -0,0 +1,431 @@
|
||||
/**
|
||||
* The css class added to a node that is selected.
|
||||
*/
|
||||
export declare const SELECTED_NODE_CLASS_NAME = "ProseMirror-selectednode";
|
||||
/**
|
||||
* The css selector for a selected node.
|
||||
*/
|
||||
export declare const SELECTED_NODE_CLASS_SELECTOR: string;
|
||||
/**
|
||||
* ProseMirror uses the Unicode Character 'OBJECT REPLACEMENT CHARACTER'
|
||||
* (U+FFFC) as text representation for leaf nodes, i.e. nodes that don't have
|
||||
* any content or text property (e.g. hardBreak, emoji, mention, rule) It was
|
||||
* introduced because of https://github.com/ProseMirror/prosemirror/issues/262
|
||||
* This can be used in an input rule regex to be able to include or exclude such
|
||||
* nodes.
|
||||
*/
|
||||
export declare const LEAF_NODE_REPLACING_CHARACTER = "\uFFFC";
|
||||
/**
|
||||
* The null character.
|
||||
*
|
||||
* See {@link https://stackoverflow.com/a/6380172}
|
||||
*/
|
||||
export declare const NULL_CHARACTER = "\0";
|
||||
/**
|
||||
* Indicates that a state update was caused by an override and not via
|
||||
* transactions or user commands.
|
||||
*
|
||||
* This is the case when `setContent` is called and for all `controlled` updates
|
||||
* within a `react` editor instance.
|
||||
*/
|
||||
export declare const STATE_OVERRIDE = "__state_override__";
|
||||
/**
|
||||
* The global name for the module exported by the remirror webview bundle.
|
||||
*/
|
||||
export declare const REMIRROR_WEBVIEW_NAME = "$$__REMIRROR_WEBVIEW_BUNDLE__$$";
|
||||
/**
|
||||
* A character useful for separating inline nodes.
|
||||
*
|
||||
* @remarks
|
||||
* Typically used in decorations as follows.
|
||||
*
|
||||
* ```ts
|
||||
* document.createTextNode(ZERO_WIDTH_SPACE_CHAR);
|
||||
* ```
|
||||
*
|
||||
* This produces the html entity '8203'
|
||||
*/
|
||||
export declare const ZERO_WIDTH_SPACE_CHAR = "\u200B";
|
||||
/**
|
||||
* The non breaking space character.
|
||||
*/
|
||||
export declare const NON_BREAKING_SPACE_CHAR = "\u00A0";
|
||||
/**
|
||||
* A default empty object node. Useful for resetting the content of a
|
||||
* prosemirror document.
|
||||
*/
|
||||
export declare const EMPTY_PARAGRAPH_NODE: {
|
||||
type: string;
|
||||
content: {
|
||||
type: string;
|
||||
}[];
|
||||
};
|
||||
export declare const EMPTY_NODE: {
|
||||
type: string;
|
||||
content: never[];
|
||||
};
|
||||
/**
|
||||
* The type for the extension tags..
|
||||
*/
|
||||
export type ExtensionTag = Remirror.ExtensionTags & typeof BaseExtensionTag;
|
||||
/**
|
||||
* A method for updating the extension tags.
|
||||
*
|
||||
* ```tsx
|
||||
* import { ExtensionTag, mutateTag } from 'remirror';
|
||||
*
|
||||
* mutateTag((tag) => {
|
||||
* tag.SuperCustom = 'superCustom';
|
||||
* });
|
||||
*
|
||||
* declare global {
|
||||
* namespace Remirror {
|
||||
* interface ExtensionTag {
|
||||
* SuperCustom: 'superCustom';
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
*
|
||||
* log(ExtensionTag.SuperCustom); // This is fine ✅
|
||||
* log(ExtensionTag.NotDefined); // This will throw ❌
|
||||
* ```
|
||||
*/
|
||||
export declare function mutateTag(mutator: (Tag: ExtensionTag) => void): void;
|
||||
declare const BaseExtensionTag: {
|
||||
/**
|
||||
* Describes a node that can be used as the last node of a document and
|
||||
* doesn't need to have anything else rendered after itself.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* e.g. `paragraph`
|
||||
*/
|
||||
readonly LastNodeCompatible: "lastNodeCompatible";
|
||||
/**
|
||||
* A mark that is used to change the formatting of the node it wraps.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* e.g. `bold`, `italic`
|
||||
*/
|
||||
readonly FormattingMark: "formattingMark";
|
||||
/**
|
||||
* A node that formats text in a non-standard way.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* e.g. `codeBlock`, `heading`, `blockquote`
|
||||
*/
|
||||
readonly FormattingNode: "formattingNode";
|
||||
/**
|
||||
* Identifies a node which has problems with cursor navigation.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* When this tag is added to an extension this will be picked up by
|
||||
* behavioural extensions such as the NodeCursorExtension which makes hard to
|
||||
* reach nodes reachable using keyboard arrows.
|
||||
*/
|
||||
readonly NodeCursor: "nodeCursor";
|
||||
/**
|
||||
* Mark group for font styling (e.g. bold, italic, underline, superscript).
|
||||
*/
|
||||
readonly FontStyle: "fontStyle";
|
||||
/**
|
||||
* Mark groups for links.
|
||||
*/
|
||||
readonly Link: "link";
|
||||
/**
|
||||
* Mark groups for colors (text-color, background-color, etc).
|
||||
*/
|
||||
readonly Color: "color";
|
||||
/**
|
||||
* Mark group for alignment.
|
||||
*/
|
||||
readonly Alignment: "alignment";
|
||||
/**
|
||||
* Mark group for indentation.
|
||||
*/
|
||||
readonly Indentation: "indentation";
|
||||
/**
|
||||
* Extension which affect the behaviour of the content. Can be nodes marks or
|
||||
* plain.
|
||||
*/
|
||||
readonly Behavior: "behavior";
|
||||
/**
|
||||
* Marks and nodes which contain code.
|
||||
*/
|
||||
readonly Code: "code";
|
||||
/**
|
||||
* Whether this node is an inline node.
|
||||
*
|
||||
* - `text` is an inline node, but `paragraph` is a block node.
|
||||
*/
|
||||
readonly InlineNode: "inline";
|
||||
/**
|
||||
* This is a node that can contain list items.
|
||||
*/
|
||||
readonly ListContainerNode: "listContainer";
|
||||
/**
|
||||
* Tags the extension as a list item node which can be contained by
|
||||
* [[`ExtensionTag.ListNode`]].
|
||||
*/
|
||||
readonly ListItemNode: "listItemNode";
|
||||
/**
|
||||
* Sets this as a block level node.
|
||||
*/
|
||||
readonly Block: "block";
|
||||
/**
|
||||
* @deprecate use `ExtensionTags.Block` instead.
|
||||
*/
|
||||
readonly BlockNode: "block";
|
||||
/**
|
||||
* Set this as a text block
|
||||
*/
|
||||
readonly TextBlock: "textBlock";
|
||||
/**
|
||||
* A tag that excludes this from input rules.
|
||||
*/
|
||||
readonly ExcludeInputRules: "excludeFromInputRules";
|
||||
/**
|
||||
* A mark or node that can't be exited when at the end and beginning of the
|
||||
* document with an arrow key or backspace key.
|
||||
*/
|
||||
readonly PreventExits: "preventsExits";
|
||||
/**
|
||||
* Represents a media compatible node.
|
||||
*/
|
||||
readonly Media: "media";
|
||||
};
|
||||
/**
|
||||
* These are the default supported tag strings which help categorize different
|
||||
* behaviors that extensions can exhibit.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Any extension can register itself with multiple such behaviors and these
|
||||
* categorizations can be used by other extensions when running commands and
|
||||
* updating the document.
|
||||
*/
|
||||
export declare const ExtensionTag: ExtensionTag;
|
||||
/**
|
||||
* The string values which can be used as extension tags.
|
||||
*/
|
||||
export type ExtensionTagType = ExtensionTag[keyof ExtensionTag];
|
||||
/**
|
||||
* The identifier key which is used to check objects for whether they are a
|
||||
* certain type.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Just pretend you don't know this exists.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export declare const __INTERNAL_REMIRROR_IDENTIFIER_KEY__: unique symbol;
|
||||
/**
|
||||
* These constants are stored on the `REMIRROR_IDENTIFIER_KEY` property of
|
||||
* `remirror` related constructors and instances in order to identify them as
|
||||
* being internal to Remirror.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* This helps to prevent issues around check types via `instanceof` which can
|
||||
* lead to false negatives.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export declare enum RemirrorIdentifier {
|
||||
/**
|
||||
* Identifies `PlainExtension`s.
|
||||
*/
|
||||
PlainExtension = "RemirrorPlainExtension",
|
||||
/**
|
||||
* Identifies `NodeExtension`s.
|
||||
*/
|
||||
NodeExtension = "RemirrorNodeExtension",
|
||||
/**
|
||||
* Identifies `MarkExtension`s.
|
||||
*/
|
||||
MarkExtension = "RemirrorMarkExtension",
|
||||
/**
|
||||
* Identifies `PlainExtensionConstructor`s.
|
||||
*/
|
||||
PlainExtensionConstructor = "RemirrorPlainExtensionConstructor",
|
||||
/**
|
||||
* Identifies `NodeExtensionConstructor`s.
|
||||
*/
|
||||
NodeExtensionConstructor = "RemirrorNodeExtensionConstructor",
|
||||
/**
|
||||
* Identifies `MarkExtensionConstructor`s.
|
||||
*/
|
||||
MarkExtensionConstructor = "RemirrorMarkExtensionConstructor",
|
||||
/**
|
||||
* The string used to identify an instance of the `Manager`
|
||||
*/
|
||||
Manager = "RemirrorManager",
|
||||
/**
|
||||
* The preset type identifier.
|
||||
*/
|
||||
Preset = "RemirrorPreset",
|
||||
/**
|
||||
* The preset type identifier.
|
||||
*/
|
||||
PresetConstructor = "RemirrorPresetConstructor"
|
||||
}
|
||||
/**
|
||||
* The priority of extension which determines what order it is loaded into the
|
||||
* editor.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Higher priority extension (higher numberic value) will ensure the extension
|
||||
* has a higher preference in your editor. In the case where you load two
|
||||
* identical extensions into your editor (same name, or same constructor), the
|
||||
* extension with the higher priority is the one that will be loaded.
|
||||
*
|
||||
* The higher the numeric value the higher the priority. The priority can also
|
||||
* be passed a number but naming things in this `enum` should help provide some
|
||||
* context to the numbers.
|
||||
*
|
||||
* By default all extensions are created with a `ExtensionPriority.Default`.
|
||||
*/
|
||||
export declare enum ExtensionPriority {
|
||||
/**
|
||||
* Use this **never** 😉
|
||||
*/
|
||||
Critical = 1000000,
|
||||
/**
|
||||
* A, like super duper, high priority.
|
||||
*/
|
||||
Highest = 100000,
|
||||
/**
|
||||
* The highest priority level that should be used in a publicly shared
|
||||
* extension (to allow some wiggle room for downstream users overriding
|
||||
* priorities).
|
||||
*/
|
||||
High = 10000,
|
||||
/**
|
||||
* A medium priority extension. This is typically all you need to take
|
||||
* priority over built in extensions.
|
||||
*/
|
||||
Medium = 1000,
|
||||
/**
|
||||
* This is the **default** priority for most extensions.
|
||||
*/
|
||||
Default = 100,
|
||||
/**
|
||||
* This is the **default** priority for builtin behavior changing extensions.
|
||||
*/
|
||||
Low = 10,
|
||||
/**
|
||||
* This is useful for extensions that exist to be overridden.
|
||||
*/
|
||||
Lowest = 0
|
||||
}
|
||||
/**
|
||||
* Identifies the stage the extension manager is at.
|
||||
*/
|
||||
export declare enum ManagerPhase {
|
||||
/**
|
||||
* The initial value for the manager phase.
|
||||
*/
|
||||
None = 0,
|
||||
/**
|
||||
* When the extension manager is being created and the onCreate methods are
|
||||
* being called.
|
||||
*
|
||||
* This happens within the RemirrorManager constructor.
|
||||
*/
|
||||
Create = 1,
|
||||
/**
|
||||
* When the view is being added and all `onView` lifecycle methods are being
|
||||
* called. The view is typically added before the dom is ready for it.
|
||||
*/
|
||||
EditorView = 2,
|
||||
/**
|
||||
* The phases of creating this manager are completed and `onTransaction` is
|
||||
* called every time the state updates.
|
||||
*/
|
||||
Runtime = 3,
|
||||
/**
|
||||
* The manager is being destroyed.
|
||||
*/
|
||||
Destroy = 4
|
||||
}
|
||||
/**
|
||||
* The named shortcuts that can be used to update multiple commands.
|
||||
*/
|
||||
export declare enum NamedShortcut {
|
||||
Undo = "_|undo|_",
|
||||
Redo = "_|redo|_",
|
||||
Bold = "_|bold|_",
|
||||
Italic = "_|italic|_",
|
||||
Underline = "_|underline|_",
|
||||
Strike = "_|strike|_",
|
||||
Code = "_|code|_",
|
||||
Paragraph = "_|paragraph|_",
|
||||
H1 = "_|h1|_",
|
||||
H2 = "_|h2|_",
|
||||
H3 = "_|h3|_",
|
||||
H4 = "_|h4|_",
|
||||
H5 = "_|h5|_",
|
||||
H6 = "_|h6|_",
|
||||
TaskList = "_|task|_",
|
||||
BulletList = "_|bullet|_",
|
||||
OrderedList = "_|number|_",
|
||||
Quote = "_|quote|_",
|
||||
Divider = "_|divider|_",
|
||||
Codeblock = "_|codeblock|_",
|
||||
ClearFormatting = "_|clear|_",
|
||||
Superscript = "_|sup|_",
|
||||
Subscript = "_|sub|_",
|
||||
LeftAlignment = "_|left-align|_",
|
||||
CenterAlignment = "_|center-align|_",
|
||||
RightAlignment = "_|right-align|_",
|
||||
JustifyAlignment = "_|justify-align|_",
|
||||
InsertLink = "_|link|_",
|
||||
/** @deprecated */
|
||||
Find = "_|find|_",
|
||||
/** @deprecated */
|
||||
FindBackwards = "_|find-backwards|_",
|
||||
/** @deprecated */
|
||||
FindReplace = "_|find-replace|_",
|
||||
AddFootnote = "_|footnote|_",
|
||||
AddComment = "_|comment|_",
|
||||
ContextMenu = "_|context-menu|_",
|
||||
IncreaseFontSize = "_|inc-font-size|_",
|
||||
DecreaseFontSize = "_|dec-font-size|_",
|
||||
IncreaseIndent = "_|indent|_",
|
||||
DecreaseIndent = "_|dedent|_",
|
||||
Shortcuts = "_|shortcuts|_",
|
||||
Copy = "_|copy|_",
|
||||
Cut = "_|cut|_",
|
||||
Paste = "_|paste|_",
|
||||
PastePlain = "_|paste-plain|_",
|
||||
SelectAll = "_|select-all|_",
|
||||
/**
|
||||
* A keyboard shortcut to trigger formatting the current block.
|
||||
*
|
||||
* @defaultValue 'Alt-Shift-F' (Mac) | 'Shift-Ctrl-F' (PC)
|
||||
*/
|
||||
Format = "_|format|_"
|
||||
}
|
||||
/**
|
||||
* Helpful empty array for use when a default array value is needed.
|
||||
*
|
||||
* DO NOT MUTATE!
|
||||
*/
|
||||
export declare const EMPTY_ARRAY: never[];
|
||||
declare global {
|
||||
namespace Remirror {
|
||||
/**
|
||||
* This interface is for extending the default `ExtensionTag`'s in your
|
||||
* codebase with full type checking support.
|
||||
*/
|
||||
interface ExtensionTags {
|
||||
}
|
||||
}
|
||||
}
|
||||
export {};
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
/**
|
||||
* The error codes for errors used throughout the codebase.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* They can be removed but should never be changed since they are also used to
|
||||
* reference the errors within search engines.
|
||||
*/
|
||||
export declare enum ErrorConstant {
|
||||
/** An error happened but we're not quite sure why. */
|
||||
UNKNOWN = "RMR0001",
|
||||
/** The arguments passed to the command method were invalid. */
|
||||
INVALID_COMMAND_ARGUMENTS = "RMR0002",
|
||||
/** This is a custom error possibly thrown by an external library. */
|
||||
CUSTOM = "RMR0003",
|
||||
/**
|
||||
* An error occurred in a function called from the `@remirror/core-helpers`
|
||||
* library.
|
||||
*/
|
||||
CORE_HELPERS = "RMR0004",
|
||||
/** You have attempted to change a value that shouldn't be changed. */
|
||||
MUTATION = "RMR0005",
|
||||
/**
|
||||
* This is an error which should not occur and is internal to the remirror
|
||||
* codebase.
|
||||
*/
|
||||
INTERNAL = "RMR0006",
|
||||
/** You're editor is missing a required extension. */
|
||||
MISSING_REQUIRED_EXTENSION = "RMR0007",
|
||||
/**
|
||||
* Called a method event at the wrong time. Please make sure getter functions
|
||||
* are only called with within the scope of the returned functions. They
|
||||
* should not be called in the outer scope of your method.
|
||||
*/
|
||||
MANAGER_PHASE_ERROR = "RMR0008",
|
||||
/**
|
||||
* The user requested an invalid extension from the getExtensions method.
|
||||
* Please check the `createExtensions` return method is returning an extension
|
||||
* with the defined constructor.
|
||||
*/
|
||||
INVALID_GET_EXTENSION = "RMR0010",
|
||||
/**
|
||||
* Invalid value passed into `Manager constructor`. Only and
|
||||
* `Extensions` are supported.
|
||||
*/
|
||||
INVALID_MANAGER_ARGUMENTS = "RMR0011",
|
||||
/**
|
||||
* There is a problem with the schema or you are trying to access a node /
|
||||
* mark that doesn't exists.
|
||||
*/
|
||||
SCHEMA = "RMR0012",
|
||||
/**
|
||||
* The `helpers` method which is passed into the ``create*` method should only
|
||||
* be called within returned method since it relies on an active view (not
|
||||
* present in the outer scope).
|
||||
*/
|
||||
HELPERS_CALLED_IN_OUTER_SCOPE = "RMR0013",
|
||||
/** The user requested an invalid extension from the manager. */
|
||||
INVALID_MANAGER_EXTENSION = "RMR0014",
|
||||
/** Command method names must be unique within the editor. */
|
||||
DUPLICATE_COMMAND_NAMES = "RMR0016",
|
||||
/** Helper method names must be unique within the editor. */
|
||||
DUPLICATE_HELPER_NAMES = "RMR0017",
|
||||
/** Attempted to chain a non chainable command. */
|
||||
NON_CHAINABLE_COMMAND = "RMR0018",
|
||||
/** The provided extension is invalid. */
|
||||
INVALID_EXTENSION = "RMR0019",
|
||||
/** The content provided to the editor is not supported. */
|
||||
INVALID_CONTENT = "RMR0021",
|
||||
/** An invalid name was used for the extension. */
|
||||
INVALID_NAME = "RMR0050",
|
||||
/** An error occurred within an extension. */
|
||||
EXTENSION = "RMR0100",
|
||||
/** The spec was defined without calling the `defaults`, `parse` or `dom` methods. */
|
||||
EXTENSION_SPEC = "RMR0101",
|
||||
/** Extra attributes must either be a string or an object. */
|
||||
EXTENSION_EXTRA_ATTRIBUTES = "RMR0102",
|
||||
/** A call to `extension.setOptions` was made with invalid keys. */
|
||||
INVALID_SET_EXTENSION_OPTIONS = "RMR0103",
|
||||
/**
|
||||
* `useRemirror` was called outside of the remirror context. It can only be used
|
||||
* within an active remirror context created by the `<Remirror />`.
|
||||
*/
|
||||
REACT_PROVIDER_CONTEXT = "RMR0200",
|
||||
/**
|
||||
* `getRootProps` has been called MULTIPLE times. It should only be called ONCE during render.
|
||||
*/
|
||||
REACT_GET_ROOT_PROPS = "RMR0201",
|
||||
/**
|
||||
* A problem occurred adding the editor view to the dom.
|
||||
*/
|
||||
REACT_EDITOR_VIEW = "RMR0202",
|
||||
/**
|
||||
* There is a problem with your controlled editor setup.
|
||||
*/
|
||||
REACT_CONTROLLED = "RMR0203",
|
||||
/**
|
||||
* Something went wrong with your custom ReactNodeView Component.
|
||||
*/
|
||||
REACT_NODE_VIEW = "RMR0204",
|
||||
/**
|
||||
* You attempted to call `getContext` provided by the `useRemirror` prop
|
||||
* during the first render of the editor. This is not possible and should only
|
||||
* be after the editor first mounts.
|
||||
*/
|
||||
REACT_GET_CONTEXT = "RMR0205",
|
||||
/**
|
||||
* An error occurred when rendering the react components.
|
||||
*/
|
||||
REACT_COMPONENTS = "RMR0206",
|
||||
/**
|
||||
* An error occurred within a remirror hook.
|
||||
*/
|
||||
REACT_HOOKS = "RMR0207",
|
||||
/**
|
||||
* There is something wrong with your i18n setup.
|
||||
*/
|
||||
I18N_CONTEXT = "RMR0300"
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export * from './core-constants';
|
||||
export { ErrorConstant } from './error-constants';
|
||||
+1
File diff suppressed because one or more lines are too long
+612
@@ -0,0 +1,612 @@
|
||||
/**
|
||||
* The identifier key which is used to check objects for whether they are a
|
||||
* certain type.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Just pretend you don't know this exists.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
declare const __INTERNAL_REMIRROR_IDENTIFIER_KEY__: unique symbol;
|
||||
export { __INTERNAL_REMIRROR_IDENTIFIER_KEY__ }
|
||||
export { __INTERNAL_REMIRROR_IDENTIFIER_KEY__ as __INTERNAL_REMIRROR_IDENTIFIER_KEY___alias_1 }
|
||||
|
||||
declare const BaseExtensionTag: {
|
||||
/**
|
||||
* Describes a node that can be used as the last node of a document and
|
||||
* doesn't need to have anything else rendered after itself.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* e.g. `paragraph`
|
||||
*/
|
||||
readonly LastNodeCompatible: "lastNodeCompatible";
|
||||
/**
|
||||
* A mark that is used to change the formatting of the node it wraps.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* e.g. `bold`, `italic`
|
||||
*/
|
||||
readonly FormattingMark: "formattingMark";
|
||||
/**
|
||||
* A node that formats text in a non-standard way.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* e.g. `codeBlock`, `heading`, `blockquote`
|
||||
*/
|
||||
readonly FormattingNode: "formattingNode";
|
||||
/**
|
||||
* Identifies a node which has problems with cursor navigation.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* When this tag is added to an extension this will be picked up by
|
||||
* behavioural extensions such as the NodeCursorExtension which makes hard to
|
||||
* reach nodes reachable using keyboard arrows.
|
||||
*/
|
||||
readonly NodeCursor: "nodeCursor";
|
||||
/**
|
||||
* Mark group for font styling (e.g. bold, italic, underline, superscript).
|
||||
*/
|
||||
readonly FontStyle: "fontStyle";
|
||||
/**
|
||||
* Mark groups for links.
|
||||
*/
|
||||
readonly Link: "link";
|
||||
/**
|
||||
* Mark groups for colors (text-color, background-color, etc).
|
||||
*/
|
||||
readonly Color: "color";
|
||||
/**
|
||||
* Mark group for alignment.
|
||||
*/
|
||||
readonly Alignment: "alignment";
|
||||
/**
|
||||
* Mark group for indentation.
|
||||
*/
|
||||
readonly Indentation: "indentation";
|
||||
/**
|
||||
* Extension which affect the behaviour of the content. Can be nodes marks or
|
||||
* plain.
|
||||
*/
|
||||
readonly Behavior: "behavior";
|
||||
/**
|
||||
* Marks and nodes which contain code.
|
||||
*/
|
||||
readonly Code: "code";
|
||||
/**
|
||||
* Whether this node is an inline node.
|
||||
*
|
||||
* - `text` is an inline node, but `paragraph` is a block node.
|
||||
*/
|
||||
readonly InlineNode: "inline";
|
||||
/**
|
||||
* This is a node that can contain list items.
|
||||
*/
|
||||
readonly ListContainerNode: "listContainer";
|
||||
/**
|
||||
* Tags the extension as a list item node which can be contained by
|
||||
* [[`ExtensionTag.ListNode`]].
|
||||
*/
|
||||
readonly ListItemNode: "listItemNode";
|
||||
/**
|
||||
* Sets this as a block level node.
|
||||
*/
|
||||
readonly Block: "block";
|
||||
/**
|
||||
* @deprecate use `ExtensionTags.Block` instead.
|
||||
*/
|
||||
readonly BlockNode: "block";
|
||||
/**
|
||||
* Set this as a text block
|
||||
*/
|
||||
readonly TextBlock: "textBlock";
|
||||
/**
|
||||
* A tag that excludes this from input rules.
|
||||
*/
|
||||
readonly ExcludeInputRules: "excludeFromInputRules";
|
||||
/**
|
||||
* A mark or node that can't be exited when at the end and beginning of the
|
||||
* document with an arrow key or backspace key.
|
||||
*/
|
||||
readonly PreventExits: "preventsExits";
|
||||
/**
|
||||
* Represents a media compatible node.
|
||||
*/
|
||||
readonly Media: "media";
|
||||
};
|
||||
|
||||
/**
|
||||
* Helpful empty array for use when a default array value is needed.
|
||||
*
|
||||
* DO NOT MUTATE!
|
||||
*/
|
||||
declare const EMPTY_ARRAY: never[];
|
||||
export { EMPTY_ARRAY }
|
||||
export { EMPTY_ARRAY as EMPTY_ARRAY_alias_1 }
|
||||
|
||||
declare const EMPTY_NODE: {
|
||||
type: string;
|
||||
content: never[];
|
||||
};
|
||||
export { EMPTY_NODE }
|
||||
export { EMPTY_NODE as EMPTY_NODE_alias_1 }
|
||||
|
||||
/**
|
||||
* A default empty object node. Useful for resetting the content of a
|
||||
* prosemirror document.
|
||||
*/
|
||||
declare const EMPTY_PARAGRAPH_NODE: {
|
||||
type: string;
|
||||
content: {
|
||||
type: string;
|
||||
}[];
|
||||
};
|
||||
export { EMPTY_PARAGRAPH_NODE }
|
||||
export { EMPTY_PARAGRAPH_NODE as EMPTY_PARAGRAPH_NODE_alias_1 }
|
||||
|
||||
/**
|
||||
* The error codes for errors used throughout the codebase.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* They can be removed but should never be changed since they are also used to
|
||||
* reference the errors within search engines.
|
||||
*/
|
||||
declare enum ErrorConstant {
|
||||
/** An error happened but we're not quite sure why. */
|
||||
UNKNOWN = "RMR0001",
|
||||
/** The arguments passed to the command method were invalid. */
|
||||
INVALID_COMMAND_ARGUMENTS = "RMR0002",
|
||||
/** This is a custom error possibly thrown by an external library. */
|
||||
CUSTOM = "RMR0003",
|
||||
/**
|
||||
* An error occurred in a function called from the `@remirror/core-helpers`
|
||||
* library.
|
||||
*/
|
||||
CORE_HELPERS = "RMR0004",
|
||||
/** You have attempted to change a value that shouldn't be changed. */
|
||||
MUTATION = "RMR0005",
|
||||
/**
|
||||
* This is an error which should not occur and is internal to the remirror
|
||||
* codebase.
|
||||
*/
|
||||
INTERNAL = "RMR0006",
|
||||
/** You're editor is missing a required extension. */
|
||||
MISSING_REQUIRED_EXTENSION = "RMR0007",
|
||||
/**
|
||||
* Called a method event at the wrong time. Please make sure getter functions
|
||||
* are only called with within the scope of the returned functions. They
|
||||
* should not be called in the outer scope of your method.
|
||||
*/
|
||||
MANAGER_PHASE_ERROR = "RMR0008",
|
||||
/**
|
||||
* The user requested an invalid extension from the getExtensions method.
|
||||
* Please check the `createExtensions` return method is returning an extension
|
||||
* with the defined constructor.
|
||||
*/
|
||||
INVALID_GET_EXTENSION = "RMR0010",
|
||||
/**
|
||||
* Invalid value passed into `Manager constructor`. Only and
|
||||
* `Extensions` are supported.
|
||||
*/
|
||||
INVALID_MANAGER_ARGUMENTS = "RMR0011",
|
||||
/**
|
||||
* There is a problem with the schema or you are trying to access a node /
|
||||
* mark that doesn't exists.
|
||||
*/
|
||||
SCHEMA = "RMR0012",
|
||||
/**
|
||||
* The `helpers` method which is passed into the ``create*` method should only
|
||||
* be called within returned method since it relies on an active view (not
|
||||
* present in the outer scope).
|
||||
*/
|
||||
HELPERS_CALLED_IN_OUTER_SCOPE = "RMR0013",
|
||||
/** The user requested an invalid extension from the manager. */
|
||||
INVALID_MANAGER_EXTENSION = "RMR0014",
|
||||
/** Command method names must be unique within the editor. */
|
||||
DUPLICATE_COMMAND_NAMES = "RMR0016",
|
||||
/** Helper method names must be unique within the editor. */
|
||||
DUPLICATE_HELPER_NAMES = "RMR0017",
|
||||
/** Attempted to chain a non chainable command. */
|
||||
NON_CHAINABLE_COMMAND = "RMR0018",
|
||||
/** The provided extension is invalid. */
|
||||
INVALID_EXTENSION = "RMR0019",
|
||||
/** The content provided to the editor is not supported. */
|
||||
INVALID_CONTENT = "RMR0021",
|
||||
/** An invalid name was used for the extension. */
|
||||
INVALID_NAME = "RMR0050",
|
||||
/** An error occurred within an extension. */
|
||||
EXTENSION = "RMR0100",
|
||||
/** The spec was defined without calling the `defaults`, `parse` or `dom` methods. */
|
||||
EXTENSION_SPEC = "RMR0101",
|
||||
/** Extra attributes must either be a string or an object. */
|
||||
EXTENSION_EXTRA_ATTRIBUTES = "RMR0102",
|
||||
/** A call to `extension.setOptions` was made with invalid keys. */
|
||||
INVALID_SET_EXTENSION_OPTIONS = "RMR0103",
|
||||
/**
|
||||
* `useRemirror` was called outside of the remirror context. It can only be used
|
||||
* within an active remirror context created by the `<Remirror />`.
|
||||
*/
|
||||
REACT_PROVIDER_CONTEXT = "RMR0200",
|
||||
/**
|
||||
* `getRootProps` has been called MULTIPLE times. It should only be called ONCE during render.
|
||||
*/
|
||||
REACT_GET_ROOT_PROPS = "RMR0201",
|
||||
/**
|
||||
* A problem occurred adding the editor view to the dom.
|
||||
*/
|
||||
REACT_EDITOR_VIEW = "RMR0202",
|
||||
/**
|
||||
* There is a problem with your controlled editor setup.
|
||||
*/
|
||||
REACT_CONTROLLED = "RMR0203",
|
||||
/**
|
||||
* Something went wrong with your custom ReactNodeView Component.
|
||||
*/
|
||||
REACT_NODE_VIEW = "RMR0204",
|
||||
/**
|
||||
* You attempted to call `getContext` provided by the `useRemirror` prop
|
||||
* during the first render of the editor. This is not possible and should only
|
||||
* be after the editor first mounts.
|
||||
*/
|
||||
REACT_GET_CONTEXT = "RMR0205",
|
||||
/**
|
||||
* An error occurred when rendering the react components.
|
||||
*/
|
||||
REACT_COMPONENTS = "RMR0206",
|
||||
/**
|
||||
* An error occurred within a remirror hook.
|
||||
*/
|
||||
REACT_HOOKS = "RMR0207",
|
||||
/**
|
||||
* There is something wrong with your i18n setup.
|
||||
*/
|
||||
I18N_CONTEXT = "RMR0300"
|
||||
}
|
||||
export { ErrorConstant }
|
||||
export { ErrorConstant as ErrorConstant_alias_1 }
|
||||
|
||||
/**
|
||||
* The priority of extension which determines what order it is loaded into the
|
||||
* editor.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Higher priority extension (higher numberic value) will ensure the extension
|
||||
* has a higher preference in your editor. In the case where you load two
|
||||
* identical extensions into your editor (same name, or same constructor), the
|
||||
* extension with the higher priority is the one that will be loaded.
|
||||
*
|
||||
* The higher the numeric value the higher the priority. The priority can also
|
||||
* be passed a number but naming things in this `enum` should help provide some
|
||||
* context to the numbers.
|
||||
*
|
||||
* By default all extensions are created with a `ExtensionPriority.Default`.
|
||||
*/
|
||||
declare enum ExtensionPriority {
|
||||
/**
|
||||
* Use this **never** 😉
|
||||
*/
|
||||
Critical = 1000000,
|
||||
/**
|
||||
* A, like super duper, high priority.
|
||||
*/
|
||||
Highest = 100000,
|
||||
/**
|
||||
* The highest priority level that should be used in a publicly shared
|
||||
* extension (to allow some wiggle room for downstream users overriding
|
||||
* priorities).
|
||||
*/
|
||||
High = 10000,
|
||||
/**
|
||||
* A medium priority extension. This is typically all you need to take
|
||||
* priority over built in extensions.
|
||||
*/
|
||||
Medium = 1000,
|
||||
/**
|
||||
* This is the **default** priority for most extensions.
|
||||
*/
|
||||
Default = 100,
|
||||
/**
|
||||
* This is the **default** priority for builtin behavior changing extensions.
|
||||
*/
|
||||
Low = 10,
|
||||
/**
|
||||
* This is useful for extensions that exist to be overridden.
|
||||
*/
|
||||
Lowest = 0
|
||||
}
|
||||
export { ExtensionPriority }
|
||||
export { ExtensionPriority as ExtensionPriority_alias_1 }
|
||||
|
||||
/**
|
||||
* The type for the extension tags..
|
||||
*/
|
||||
declare type ExtensionTag = Remirror.ExtensionTags & typeof BaseExtensionTag;
|
||||
|
||||
/**
|
||||
* These are the default supported tag strings which help categorize different
|
||||
* behaviors that extensions can exhibit.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Any extension can register itself with multiple such behaviors and these
|
||||
* categorizations can be used by other extensions when running commands and
|
||||
* updating the document.
|
||||
*/
|
||||
declare const ExtensionTag: ExtensionTag;
|
||||
export { ExtensionTag }
|
||||
export { ExtensionTag as ExtensionTag_alias_1 }
|
||||
|
||||
/**
|
||||
* The string values which can be used as extension tags.
|
||||
*/
|
||||
declare type ExtensionTagType = ExtensionTag[keyof ExtensionTag];
|
||||
export { ExtensionTagType }
|
||||
export { ExtensionTagType as ExtensionTagType_alias_1 }
|
||||
|
||||
/**
|
||||
* ProseMirror uses the Unicode Character 'OBJECT REPLACEMENT CHARACTER'
|
||||
* (U+FFFC) as text representation for leaf nodes, i.e. nodes that don't have
|
||||
* any content or text property (e.g. hardBreak, emoji, mention, rule) It was
|
||||
* introduced because of https://github.com/ProseMirror/prosemirror/issues/262
|
||||
* This can be used in an input rule regex to be able to include or exclude such
|
||||
* nodes.
|
||||
*/
|
||||
declare const LEAF_NODE_REPLACING_CHARACTER = "\uFFFC";
|
||||
export { LEAF_NODE_REPLACING_CHARACTER }
|
||||
export { LEAF_NODE_REPLACING_CHARACTER as LEAF_NODE_REPLACING_CHARACTER_alias_1 }
|
||||
|
||||
/**
|
||||
* Identifies the stage the extension manager is at.
|
||||
*/
|
||||
declare enum ManagerPhase {
|
||||
/**
|
||||
* The initial value for the manager phase.
|
||||
*/
|
||||
None = 0,
|
||||
/**
|
||||
* When the extension manager is being created and the onCreate methods are
|
||||
* being called.
|
||||
*
|
||||
* This happens within the RemirrorManager constructor.
|
||||
*/
|
||||
Create = 1,
|
||||
/**
|
||||
* When the view is being added and all `onView` lifecycle methods are being
|
||||
* called. The view is typically added before the dom is ready for it.
|
||||
*/
|
||||
EditorView = 2,
|
||||
/**
|
||||
* The phases of creating this manager are completed and `onTransaction` is
|
||||
* called every time the state updates.
|
||||
*/
|
||||
Runtime = 3,
|
||||
/**
|
||||
* The manager is being destroyed.
|
||||
*/
|
||||
Destroy = 4
|
||||
}
|
||||
export { ManagerPhase }
|
||||
export { ManagerPhase as ManagerPhase_alias_1 }
|
||||
|
||||
/**
|
||||
* A method for updating the extension tags.
|
||||
*
|
||||
* ```tsx
|
||||
* import { ExtensionTag, mutateTag } from 'remirror';
|
||||
*
|
||||
* mutateTag((tag) => {
|
||||
* tag.SuperCustom = 'superCustom';
|
||||
* });
|
||||
*
|
||||
* declare global {
|
||||
* namespace Remirror {
|
||||
* interface ExtensionTag {
|
||||
* SuperCustom: 'superCustom';
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
*
|
||||
* log(ExtensionTag.SuperCustom); // This is fine ✅
|
||||
* log(ExtensionTag.NotDefined); // This will throw ❌
|
||||
* ```
|
||||
*/
|
||||
declare function mutateTag(mutator: (Tag: ExtensionTag) => void): void;
|
||||
export { mutateTag }
|
||||
export { mutateTag as mutateTag_alias_1 }
|
||||
|
||||
/**
|
||||
* The named shortcuts that can be used to update multiple commands.
|
||||
*/
|
||||
declare enum NamedShortcut {
|
||||
Undo = "_|undo|_",
|
||||
Redo = "_|redo|_",
|
||||
Bold = "_|bold|_",
|
||||
Italic = "_|italic|_",
|
||||
Underline = "_|underline|_",
|
||||
Strike = "_|strike|_",
|
||||
Code = "_|code|_",
|
||||
Paragraph = "_|paragraph|_",
|
||||
H1 = "_|h1|_",
|
||||
H2 = "_|h2|_",
|
||||
H3 = "_|h3|_",
|
||||
H4 = "_|h4|_",
|
||||
H5 = "_|h5|_",
|
||||
H6 = "_|h6|_",
|
||||
TaskList = "_|task|_",
|
||||
BulletList = "_|bullet|_",
|
||||
OrderedList = "_|number|_",
|
||||
Quote = "_|quote|_",
|
||||
Divider = "_|divider|_",
|
||||
Codeblock = "_|codeblock|_",
|
||||
ClearFormatting = "_|clear|_",
|
||||
Superscript = "_|sup|_",
|
||||
Subscript = "_|sub|_",
|
||||
LeftAlignment = "_|left-align|_",
|
||||
CenterAlignment = "_|center-align|_",
|
||||
RightAlignment = "_|right-align|_",
|
||||
JustifyAlignment = "_|justify-align|_",
|
||||
InsertLink = "_|link|_",
|
||||
/** @deprecated */
|
||||
Find = "_|find|_",
|
||||
/** @deprecated */
|
||||
FindBackwards = "_|find-backwards|_",
|
||||
/** @deprecated */
|
||||
FindReplace = "_|find-replace|_",
|
||||
AddFootnote = "_|footnote|_",
|
||||
AddComment = "_|comment|_",
|
||||
ContextMenu = "_|context-menu|_",
|
||||
IncreaseFontSize = "_|inc-font-size|_",
|
||||
DecreaseFontSize = "_|dec-font-size|_",
|
||||
IncreaseIndent = "_|indent|_",
|
||||
DecreaseIndent = "_|dedent|_",
|
||||
Shortcuts = "_|shortcuts|_",
|
||||
Copy = "_|copy|_",
|
||||
Cut = "_|cut|_",
|
||||
Paste = "_|paste|_",
|
||||
PastePlain = "_|paste-plain|_",
|
||||
SelectAll = "_|select-all|_",
|
||||
/**
|
||||
* A keyboard shortcut to trigger formatting the current block.
|
||||
*
|
||||
* @defaultValue 'Alt-Shift-F' (Mac) | 'Shift-Ctrl-F' (PC)
|
||||
*/
|
||||
Format = "_|format|_"
|
||||
}
|
||||
export { NamedShortcut }
|
||||
export { NamedShortcut as NamedShortcut_alias_1 }
|
||||
|
||||
/**
|
||||
* The non breaking space character.
|
||||
*/
|
||||
declare const NON_BREAKING_SPACE_CHAR = "\u00A0";
|
||||
export { NON_BREAKING_SPACE_CHAR }
|
||||
export { NON_BREAKING_SPACE_CHAR as NON_BREAKING_SPACE_CHAR_alias_1 }
|
||||
|
||||
/**
|
||||
* The null character.
|
||||
*
|
||||
* See {@link https://stackoverflow.com/a/6380172}
|
||||
*/
|
||||
declare const NULL_CHARACTER = "\0";
|
||||
export { NULL_CHARACTER }
|
||||
export { NULL_CHARACTER as NULL_CHARACTER_alias_1 }
|
||||
|
||||
/**
|
||||
* The global name for the module exported by the remirror webview bundle.
|
||||
*/
|
||||
declare const REMIRROR_WEBVIEW_NAME = "$$__REMIRROR_WEBVIEW_BUNDLE__$$";
|
||||
export { REMIRROR_WEBVIEW_NAME }
|
||||
export { REMIRROR_WEBVIEW_NAME as REMIRROR_WEBVIEW_NAME_alias_1 }
|
||||
|
||||
/**
|
||||
* These constants are stored on the `REMIRROR_IDENTIFIER_KEY` property of
|
||||
* `remirror` related constructors and instances in order to identify them as
|
||||
* being internal to Remirror.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* This helps to prevent issues around check types via `instanceof` which can
|
||||
* lead to false negatives.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
declare enum RemirrorIdentifier {
|
||||
/**
|
||||
* Identifies `PlainExtension`s.
|
||||
*/
|
||||
PlainExtension = "RemirrorPlainExtension",
|
||||
/**
|
||||
* Identifies `NodeExtension`s.
|
||||
*/
|
||||
NodeExtension = "RemirrorNodeExtension",
|
||||
/**
|
||||
* Identifies `MarkExtension`s.
|
||||
*/
|
||||
MarkExtension = "RemirrorMarkExtension",
|
||||
/**
|
||||
* Identifies `PlainExtensionConstructor`s.
|
||||
*/
|
||||
PlainExtensionConstructor = "RemirrorPlainExtensionConstructor",
|
||||
/**
|
||||
* Identifies `NodeExtensionConstructor`s.
|
||||
*/
|
||||
NodeExtensionConstructor = "RemirrorNodeExtensionConstructor",
|
||||
/**
|
||||
* Identifies `MarkExtensionConstructor`s.
|
||||
*/
|
||||
MarkExtensionConstructor = "RemirrorMarkExtensionConstructor",
|
||||
/**
|
||||
* The string used to identify an instance of the `Manager`
|
||||
*/
|
||||
Manager = "RemirrorManager",
|
||||
/**
|
||||
* The preset type identifier.
|
||||
*/
|
||||
Preset = "RemirrorPreset",
|
||||
/**
|
||||
* The preset type identifier.
|
||||
*/
|
||||
PresetConstructor = "RemirrorPresetConstructor"
|
||||
}
|
||||
export { RemirrorIdentifier }
|
||||
export { RemirrorIdentifier as RemirrorIdentifier_alias_1 }
|
||||
|
||||
/**
|
||||
* The css class added to a node that is selected.
|
||||
*/
|
||||
declare const SELECTED_NODE_CLASS_NAME = "ProseMirror-selectednode";
|
||||
export { SELECTED_NODE_CLASS_NAME }
|
||||
export { SELECTED_NODE_CLASS_NAME as SELECTED_NODE_CLASS_NAME_alias_1 }
|
||||
|
||||
/**
|
||||
* The css selector for a selected node.
|
||||
*/
|
||||
declare const SELECTED_NODE_CLASS_SELECTOR: string;
|
||||
export { SELECTED_NODE_CLASS_SELECTOR }
|
||||
export { SELECTED_NODE_CLASS_SELECTOR as SELECTED_NODE_CLASS_SELECTOR_alias_1 }
|
||||
|
||||
/**
|
||||
* Indicates that a state update was caused by an override and not via
|
||||
* transactions or user commands.
|
||||
*
|
||||
* This is the case when `setContent` is called and for all `controlled` updates
|
||||
* within a `react` editor instance.
|
||||
*/
|
||||
declare const STATE_OVERRIDE = "__state_override__";
|
||||
export { STATE_OVERRIDE }
|
||||
export { STATE_OVERRIDE as STATE_OVERRIDE_alias_1 }
|
||||
|
||||
/**
|
||||
* A character useful for separating inline nodes.
|
||||
*
|
||||
* @remarks
|
||||
* Typically used in decorations as follows.
|
||||
*
|
||||
* ```ts
|
||||
* document.createTextNode(ZERO_WIDTH_SPACE_CHAR);
|
||||
* ```
|
||||
*
|
||||
* This produces the html entity '8203'
|
||||
*/
|
||||
declare const ZERO_WIDTH_SPACE_CHAR = "\u200B";
|
||||
export { ZERO_WIDTH_SPACE_CHAR }
|
||||
export { ZERO_WIDTH_SPACE_CHAR as ZERO_WIDTH_SPACE_CHAR_alias_1 }
|
||||
|
||||
export { }
|
||||
|
||||
declare global {
|
||||
namespace Remirror {
|
||||
/**
|
||||
* This interface is for extending the default `ExtensionTag`'s in your
|
||||
* codebase with full type checking support.
|
||||
*/
|
||||
interface ExtensionTags {}
|
||||
}
|
||||
}
|
||||
+612
@@ -0,0 +1,612 @@
|
||||
/**
|
||||
* The identifier key which is used to check objects for whether they are a
|
||||
* certain type.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Just pretend you don't know this exists.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
declare const __INTERNAL_REMIRROR_IDENTIFIER_KEY__: unique symbol;
|
||||
export { __INTERNAL_REMIRROR_IDENTIFIER_KEY__ }
|
||||
export { __INTERNAL_REMIRROR_IDENTIFIER_KEY__ as __INTERNAL_REMIRROR_IDENTIFIER_KEY___alias_1 }
|
||||
|
||||
declare const BaseExtensionTag: {
|
||||
/**
|
||||
* Describes a node that can be used as the last node of a document and
|
||||
* doesn't need to have anything else rendered after itself.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* e.g. `paragraph`
|
||||
*/
|
||||
readonly LastNodeCompatible: "lastNodeCompatible";
|
||||
/**
|
||||
* A mark that is used to change the formatting of the node it wraps.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* e.g. `bold`, `italic`
|
||||
*/
|
||||
readonly FormattingMark: "formattingMark";
|
||||
/**
|
||||
* A node that formats text in a non-standard way.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* e.g. `codeBlock`, `heading`, `blockquote`
|
||||
*/
|
||||
readonly FormattingNode: "formattingNode";
|
||||
/**
|
||||
* Identifies a node which has problems with cursor navigation.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* When this tag is added to an extension this will be picked up by
|
||||
* behavioural extensions such as the NodeCursorExtension which makes hard to
|
||||
* reach nodes reachable using keyboard arrows.
|
||||
*/
|
||||
readonly NodeCursor: "nodeCursor";
|
||||
/**
|
||||
* Mark group for font styling (e.g. bold, italic, underline, superscript).
|
||||
*/
|
||||
readonly FontStyle: "fontStyle";
|
||||
/**
|
||||
* Mark groups for links.
|
||||
*/
|
||||
readonly Link: "link";
|
||||
/**
|
||||
* Mark groups for colors (text-color, background-color, etc).
|
||||
*/
|
||||
readonly Color: "color";
|
||||
/**
|
||||
* Mark group for alignment.
|
||||
*/
|
||||
readonly Alignment: "alignment";
|
||||
/**
|
||||
* Mark group for indentation.
|
||||
*/
|
||||
readonly Indentation: "indentation";
|
||||
/**
|
||||
* Extension which affect the behaviour of the content. Can be nodes marks or
|
||||
* plain.
|
||||
*/
|
||||
readonly Behavior: "behavior";
|
||||
/**
|
||||
* Marks and nodes which contain code.
|
||||
*/
|
||||
readonly Code: "code";
|
||||
/**
|
||||
* Whether this node is an inline node.
|
||||
*
|
||||
* - `text` is an inline node, but `paragraph` is a block node.
|
||||
*/
|
||||
readonly InlineNode: "inline";
|
||||
/**
|
||||
* This is a node that can contain list items.
|
||||
*/
|
||||
readonly ListContainerNode: "listContainer";
|
||||
/**
|
||||
* Tags the extension as a list item node which can be contained by
|
||||
* [[`ExtensionTag.ListNode`]].
|
||||
*/
|
||||
readonly ListItemNode: "listItemNode";
|
||||
/**
|
||||
* Sets this as a block level node.
|
||||
*/
|
||||
readonly Block: "block";
|
||||
/**
|
||||
* @deprecate use `ExtensionTags.Block` instead.
|
||||
*/
|
||||
readonly BlockNode: "block";
|
||||
/**
|
||||
* Set this as a text block
|
||||
*/
|
||||
readonly TextBlock: "textBlock";
|
||||
/**
|
||||
* A tag that excludes this from input rules.
|
||||
*/
|
||||
readonly ExcludeInputRules: "excludeFromInputRules";
|
||||
/**
|
||||
* A mark or node that can't be exited when at the end and beginning of the
|
||||
* document with an arrow key or backspace key.
|
||||
*/
|
||||
readonly PreventExits: "preventsExits";
|
||||
/**
|
||||
* Represents a media compatible node.
|
||||
*/
|
||||
readonly Media: "media";
|
||||
};
|
||||
|
||||
/**
|
||||
* Helpful empty array for use when a default array value is needed.
|
||||
*
|
||||
* DO NOT MUTATE!
|
||||
*/
|
||||
declare const EMPTY_ARRAY: never[];
|
||||
export { EMPTY_ARRAY }
|
||||
export { EMPTY_ARRAY as EMPTY_ARRAY_alias_1 }
|
||||
|
||||
declare const EMPTY_NODE: {
|
||||
type: string;
|
||||
content: never[];
|
||||
};
|
||||
export { EMPTY_NODE }
|
||||
export { EMPTY_NODE as EMPTY_NODE_alias_1 }
|
||||
|
||||
/**
|
||||
* A default empty object node. Useful for resetting the content of a
|
||||
* prosemirror document.
|
||||
*/
|
||||
declare const EMPTY_PARAGRAPH_NODE: {
|
||||
type: string;
|
||||
content: {
|
||||
type: string;
|
||||
}[];
|
||||
};
|
||||
export { EMPTY_PARAGRAPH_NODE }
|
||||
export { EMPTY_PARAGRAPH_NODE as EMPTY_PARAGRAPH_NODE_alias_1 }
|
||||
|
||||
/**
|
||||
* The error codes for errors used throughout the codebase.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* They can be removed but should never be changed since they are also used to
|
||||
* reference the errors within search engines.
|
||||
*/
|
||||
declare enum ErrorConstant {
|
||||
/** An error happened but we're not quite sure why. */
|
||||
UNKNOWN = "RMR0001",
|
||||
/** The arguments passed to the command method were invalid. */
|
||||
INVALID_COMMAND_ARGUMENTS = "RMR0002",
|
||||
/** This is a custom error possibly thrown by an external library. */
|
||||
CUSTOM = "RMR0003",
|
||||
/**
|
||||
* An error occurred in a function called from the `@remirror/core-helpers`
|
||||
* library.
|
||||
*/
|
||||
CORE_HELPERS = "RMR0004",
|
||||
/** You have attempted to change a value that shouldn't be changed. */
|
||||
MUTATION = "RMR0005",
|
||||
/**
|
||||
* This is an error which should not occur and is internal to the remirror
|
||||
* codebase.
|
||||
*/
|
||||
INTERNAL = "RMR0006",
|
||||
/** You're editor is missing a required extension. */
|
||||
MISSING_REQUIRED_EXTENSION = "RMR0007",
|
||||
/**
|
||||
* Called a method event at the wrong time. Please make sure getter functions
|
||||
* are only called with within the scope of the returned functions. They
|
||||
* should not be called in the outer scope of your method.
|
||||
*/
|
||||
MANAGER_PHASE_ERROR = "RMR0008",
|
||||
/**
|
||||
* The user requested an invalid extension from the getExtensions method.
|
||||
* Please check the `createExtensions` return method is returning an extension
|
||||
* with the defined constructor.
|
||||
*/
|
||||
INVALID_GET_EXTENSION = "RMR0010",
|
||||
/**
|
||||
* Invalid value passed into `Manager constructor`. Only and
|
||||
* `Extensions` are supported.
|
||||
*/
|
||||
INVALID_MANAGER_ARGUMENTS = "RMR0011",
|
||||
/**
|
||||
* There is a problem with the schema or you are trying to access a node /
|
||||
* mark that doesn't exists.
|
||||
*/
|
||||
SCHEMA = "RMR0012",
|
||||
/**
|
||||
* The `helpers` method which is passed into the ``create*` method should only
|
||||
* be called within returned method since it relies on an active view (not
|
||||
* present in the outer scope).
|
||||
*/
|
||||
HELPERS_CALLED_IN_OUTER_SCOPE = "RMR0013",
|
||||
/** The user requested an invalid extension from the manager. */
|
||||
INVALID_MANAGER_EXTENSION = "RMR0014",
|
||||
/** Command method names must be unique within the editor. */
|
||||
DUPLICATE_COMMAND_NAMES = "RMR0016",
|
||||
/** Helper method names must be unique within the editor. */
|
||||
DUPLICATE_HELPER_NAMES = "RMR0017",
|
||||
/** Attempted to chain a non chainable command. */
|
||||
NON_CHAINABLE_COMMAND = "RMR0018",
|
||||
/** The provided extension is invalid. */
|
||||
INVALID_EXTENSION = "RMR0019",
|
||||
/** The content provided to the editor is not supported. */
|
||||
INVALID_CONTENT = "RMR0021",
|
||||
/** An invalid name was used for the extension. */
|
||||
INVALID_NAME = "RMR0050",
|
||||
/** An error occurred within an extension. */
|
||||
EXTENSION = "RMR0100",
|
||||
/** The spec was defined without calling the `defaults`, `parse` or `dom` methods. */
|
||||
EXTENSION_SPEC = "RMR0101",
|
||||
/** Extra attributes must either be a string or an object. */
|
||||
EXTENSION_EXTRA_ATTRIBUTES = "RMR0102",
|
||||
/** A call to `extension.setOptions` was made with invalid keys. */
|
||||
INVALID_SET_EXTENSION_OPTIONS = "RMR0103",
|
||||
/**
|
||||
* `useRemirror` was called outside of the remirror context. It can only be used
|
||||
* within an active remirror context created by the `<Remirror />`.
|
||||
*/
|
||||
REACT_PROVIDER_CONTEXT = "RMR0200",
|
||||
/**
|
||||
* `getRootProps` has been called MULTIPLE times. It should only be called ONCE during render.
|
||||
*/
|
||||
REACT_GET_ROOT_PROPS = "RMR0201",
|
||||
/**
|
||||
* A problem occurred adding the editor view to the dom.
|
||||
*/
|
||||
REACT_EDITOR_VIEW = "RMR0202",
|
||||
/**
|
||||
* There is a problem with your controlled editor setup.
|
||||
*/
|
||||
REACT_CONTROLLED = "RMR0203",
|
||||
/**
|
||||
* Something went wrong with your custom ReactNodeView Component.
|
||||
*/
|
||||
REACT_NODE_VIEW = "RMR0204",
|
||||
/**
|
||||
* You attempted to call `getContext` provided by the `useRemirror` prop
|
||||
* during the first render of the editor. This is not possible and should only
|
||||
* be after the editor first mounts.
|
||||
*/
|
||||
REACT_GET_CONTEXT = "RMR0205",
|
||||
/**
|
||||
* An error occurred when rendering the react components.
|
||||
*/
|
||||
REACT_COMPONENTS = "RMR0206",
|
||||
/**
|
||||
* An error occurred within a remirror hook.
|
||||
*/
|
||||
REACT_HOOKS = "RMR0207",
|
||||
/**
|
||||
* There is something wrong with your i18n setup.
|
||||
*/
|
||||
I18N_CONTEXT = "RMR0300"
|
||||
}
|
||||
export { ErrorConstant }
|
||||
export { ErrorConstant as ErrorConstant_alias_1 }
|
||||
|
||||
/**
|
||||
* The priority of extension which determines what order it is loaded into the
|
||||
* editor.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Higher priority extension (higher numberic value) will ensure the extension
|
||||
* has a higher preference in your editor. In the case where you load two
|
||||
* identical extensions into your editor (same name, or same constructor), the
|
||||
* extension with the higher priority is the one that will be loaded.
|
||||
*
|
||||
* The higher the numeric value the higher the priority. The priority can also
|
||||
* be passed a number but naming things in this `enum` should help provide some
|
||||
* context to the numbers.
|
||||
*
|
||||
* By default all extensions are created with a `ExtensionPriority.Default`.
|
||||
*/
|
||||
declare enum ExtensionPriority {
|
||||
/**
|
||||
* Use this **never** 😉
|
||||
*/
|
||||
Critical = 1000000,
|
||||
/**
|
||||
* A, like super duper, high priority.
|
||||
*/
|
||||
Highest = 100000,
|
||||
/**
|
||||
* The highest priority level that should be used in a publicly shared
|
||||
* extension (to allow some wiggle room for downstream users overriding
|
||||
* priorities).
|
||||
*/
|
||||
High = 10000,
|
||||
/**
|
||||
* A medium priority extension. This is typically all you need to take
|
||||
* priority over built in extensions.
|
||||
*/
|
||||
Medium = 1000,
|
||||
/**
|
||||
* This is the **default** priority for most extensions.
|
||||
*/
|
||||
Default = 100,
|
||||
/**
|
||||
* This is the **default** priority for builtin behavior changing extensions.
|
||||
*/
|
||||
Low = 10,
|
||||
/**
|
||||
* This is useful for extensions that exist to be overridden.
|
||||
*/
|
||||
Lowest = 0
|
||||
}
|
||||
export { ExtensionPriority }
|
||||
export { ExtensionPriority as ExtensionPriority_alias_1 }
|
||||
|
||||
/**
|
||||
* The type for the extension tags..
|
||||
*/
|
||||
declare type ExtensionTag = Remirror.ExtensionTags & typeof BaseExtensionTag;
|
||||
|
||||
/**
|
||||
* These are the default supported tag strings which help categorize different
|
||||
* behaviors that extensions can exhibit.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* Any extension can register itself with multiple such behaviors and these
|
||||
* categorizations can be used by other extensions when running commands and
|
||||
* updating the document.
|
||||
*/
|
||||
declare const ExtensionTag: ExtensionTag;
|
||||
export { ExtensionTag }
|
||||
export { ExtensionTag as ExtensionTag_alias_1 }
|
||||
|
||||
/**
|
||||
* The string values which can be used as extension tags.
|
||||
*/
|
||||
declare type ExtensionTagType = ExtensionTag[keyof ExtensionTag];
|
||||
export { ExtensionTagType }
|
||||
export { ExtensionTagType as ExtensionTagType_alias_1 }
|
||||
|
||||
/**
|
||||
* ProseMirror uses the Unicode Character 'OBJECT REPLACEMENT CHARACTER'
|
||||
* (U+FFFC) as text representation for leaf nodes, i.e. nodes that don't have
|
||||
* any content or text property (e.g. hardBreak, emoji, mention, rule) It was
|
||||
* introduced because of https://github.com/ProseMirror/prosemirror/issues/262
|
||||
* This can be used in an input rule regex to be able to include or exclude such
|
||||
* nodes.
|
||||
*/
|
||||
declare const LEAF_NODE_REPLACING_CHARACTER = "\uFFFC";
|
||||
export { LEAF_NODE_REPLACING_CHARACTER }
|
||||
export { LEAF_NODE_REPLACING_CHARACTER as LEAF_NODE_REPLACING_CHARACTER_alias_1 }
|
||||
|
||||
/**
|
||||
* Identifies the stage the extension manager is at.
|
||||
*/
|
||||
declare enum ManagerPhase {
|
||||
/**
|
||||
* The initial value for the manager phase.
|
||||
*/
|
||||
None = 0,
|
||||
/**
|
||||
* When the extension manager is being created and the onCreate methods are
|
||||
* being called.
|
||||
*
|
||||
* This happens within the RemirrorManager constructor.
|
||||
*/
|
||||
Create = 1,
|
||||
/**
|
||||
* When the view is being added and all `onView` lifecycle methods are being
|
||||
* called. The view is typically added before the dom is ready for it.
|
||||
*/
|
||||
EditorView = 2,
|
||||
/**
|
||||
* The phases of creating this manager are completed and `onTransaction` is
|
||||
* called every time the state updates.
|
||||
*/
|
||||
Runtime = 3,
|
||||
/**
|
||||
* The manager is being destroyed.
|
||||
*/
|
||||
Destroy = 4
|
||||
}
|
||||
export { ManagerPhase }
|
||||
export { ManagerPhase as ManagerPhase_alias_1 }
|
||||
|
||||
/**
|
||||
* A method for updating the extension tags.
|
||||
*
|
||||
* ```tsx
|
||||
* import { ExtensionTag, mutateTag } from 'remirror';
|
||||
*
|
||||
* mutateTag((tag) => {
|
||||
* tag.SuperCustom = 'superCustom';
|
||||
* });
|
||||
*
|
||||
* declare global {
|
||||
* namespace Remirror {
|
||||
* interface ExtensionTag {
|
||||
* SuperCustom: 'superCustom';
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
*
|
||||
* log(ExtensionTag.SuperCustom); // This is fine ✅
|
||||
* log(ExtensionTag.NotDefined); // This will throw ❌
|
||||
* ```
|
||||
*/
|
||||
declare function mutateTag(mutator: (Tag: ExtensionTag) => void): void;
|
||||
export { mutateTag }
|
||||
export { mutateTag as mutateTag_alias_1 }
|
||||
|
||||
/**
|
||||
* The named shortcuts that can be used to update multiple commands.
|
||||
*/
|
||||
declare enum NamedShortcut {
|
||||
Undo = "_|undo|_",
|
||||
Redo = "_|redo|_",
|
||||
Bold = "_|bold|_",
|
||||
Italic = "_|italic|_",
|
||||
Underline = "_|underline|_",
|
||||
Strike = "_|strike|_",
|
||||
Code = "_|code|_",
|
||||
Paragraph = "_|paragraph|_",
|
||||
H1 = "_|h1|_",
|
||||
H2 = "_|h2|_",
|
||||
H3 = "_|h3|_",
|
||||
H4 = "_|h4|_",
|
||||
H5 = "_|h5|_",
|
||||
H6 = "_|h6|_",
|
||||
TaskList = "_|task|_",
|
||||
BulletList = "_|bullet|_",
|
||||
OrderedList = "_|number|_",
|
||||
Quote = "_|quote|_",
|
||||
Divider = "_|divider|_",
|
||||
Codeblock = "_|codeblock|_",
|
||||
ClearFormatting = "_|clear|_",
|
||||
Superscript = "_|sup|_",
|
||||
Subscript = "_|sub|_",
|
||||
LeftAlignment = "_|left-align|_",
|
||||
CenterAlignment = "_|center-align|_",
|
||||
RightAlignment = "_|right-align|_",
|
||||
JustifyAlignment = "_|justify-align|_",
|
||||
InsertLink = "_|link|_",
|
||||
/** @deprecated */
|
||||
Find = "_|find|_",
|
||||
/** @deprecated */
|
||||
FindBackwards = "_|find-backwards|_",
|
||||
/** @deprecated */
|
||||
FindReplace = "_|find-replace|_",
|
||||
AddFootnote = "_|footnote|_",
|
||||
AddComment = "_|comment|_",
|
||||
ContextMenu = "_|context-menu|_",
|
||||
IncreaseFontSize = "_|inc-font-size|_",
|
||||
DecreaseFontSize = "_|dec-font-size|_",
|
||||
IncreaseIndent = "_|indent|_",
|
||||
DecreaseIndent = "_|dedent|_",
|
||||
Shortcuts = "_|shortcuts|_",
|
||||
Copy = "_|copy|_",
|
||||
Cut = "_|cut|_",
|
||||
Paste = "_|paste|_",
|
||||
PastePlain = "_|paste-plain|_",
|
||||
SelectAll = "_|select-all|_",
|
||||
/**
|
||||
* A keyboard shortcut to trigger formatting the current block.
|
||||
*
|
||||
* @defaultValue 'Alt-Shift-F' (Mac) | 'Shift-Ctrl-F' (PC)
|
||||
*/
|
||||
Format = "_|format|_"
|
||||
}
|
||||
export { NamedShortcut }
|
||||
export { NamedShortcut as NamedShortcut_alias_1 }
|
||||
|
||||
/**
|
||||
* The non breaking space character.
|
||||
*/
|
||||
declare const NON_BREAKING_SPACE_CHAR = "\u00A0";
|
||||
export { NON_BREAKING_SPACE_CHAR }
|
||||
export { NON_BREAKING_SPACE_CHAR as NON_BREAKING_SPACE_CHAR_alias_1 }
|
||||
|
||||
/**
|
||||
* The null character.
|
||||
*
|
||||
* See {@link https://stackoverflow.com/a/6380172}
|
||||
*/
|
||||
declare const NULL_CHARACTER = "\0";
|
||||
export { NULL_CHARACTER }
|
||||
export { NULL_CHARACTER as NULL_CHARACTER_alias_1 }
|
||||
|
||||
/**
|
||||
* The global name for the module exported by the remirror webview bundle.
|
||||
*/
|
||||
declare const REMIRROR_WEBVIEW_NAME = "$$__REMIRROR_WEBVIEW_BUNDLE__$$";
|
||||
export { REMIRROR_WEBVIEW_NAME }
|
||||
export { REMIRROR_WEBVIEW_NAME as REMIRROR_WEBVIEW_NAME_alias_1 }
|
||||
|
||||
/**
|
||||
* These constants are stored on the `REMIRROR_IDENTIFIER_KEY` property of
|
||||
* `remirror` related constructors and instances in order to identify them as
|
||||
* being internal to Remirror.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* This helps to prevent issues around check types via `instanceof` which can
|
||||
* lead to false negatives.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
declare enum RemirrorIdentifier {
|
||||
/**
|
||||
* Identifies `PlainExtension`s.
|
||||
*/
|
||||
PlainExtension = "RemirrorPlainExtension",
|
||||
/**
|
||||
* Identifies `NodeExtension`s.
|
||||
*/
|
||||
NodeExtension = "RemirrorNodeExtension",
|
||||
/**
|
||||
* Identifies `MarkExtension`s.
|
||||
*/
|
||||
MarkExtension = "RemirrorMarkExtension",
|
||||
/**
|
||||
* Identifies `PlainExtensionConstructor`s.
|
||||
*/
|
||||
PlainExtensionConstructor = "RemirrorPlainExtensionConstructor",
|
||||
/**
|
||||
* Identifies `NodeExtensionConstructor`s.
|
||||
*/
|
||||
NodeExtensionConstructor = "RemirrorNodeExtensionConstructor",
|
||||
/**
|
||||
* Identifies `MarkExtensionConstructor`s.
|
||||
*/
|
||||
MarkExtensionConstructor = "RemirrorMarkExtensionConstructor",
|
||||
/**
|
||||
* The string used to identify an instance of the `Manager`
|
||||
*/
|
||||
Manager = "RemirrorManager",
|
||||
/**
|
||||
* The preset type identifier.
|
||||
*/
|
||||
Preset = "RemirrorPreset",
|
||||
/**
|
||||
* The preset type identifier.
|
||||
*/
|
||||
PresetConstructor = "RemirrorPresetConstructor"
|
||||
}
|
||||
export { RemirrorIdentifier }
|
||||
export { RemirrorIdentifier as RemirrorIdentifier_alias_1 }
|
||||
|
||||
/**
|
||||
* The css class added to a node that is selected.
|
||||
*/
|
||||
declare const SELECTED_NODE_CLASS_NAME = "ProseMirror-selectednode";
|
||||
export { SELECTED_NODE_CLASS_NAME }
|
||||
export { SELECTED_NODE_CLASS_NAME as SELECTED_NODE_CLASS_NAME_alias_1 }
|
||||
|
||||
/**
|
||||
* The css selector for a selected node.
|
||||
*/
|
||||
declare const SELECTED_NODE_CLASS_SELECTOR: string;
|
||||
export { SELECTED_NODE_CLASS_SELECTOR }
|
||||
export { SELECTED_NODE_CLASS_SELECTOR as SELECTED_NODE_CLASS_SELECTOR_alias_1 }
|
||||
|
||||
/**
|
||||
* Indicates that a state update was caused by an override and not via
|
||||
* transactions or user commands.
|
||||
*
|
||||
* This is the case when `setContent` is called and for all `controlled` updates
|
||||
* within a `react` editor instance.
|
||||
*/
|
||||
declare const STATE_OVERRIDE = "__state_override__";
|
||||
export { STATE_OVERRIDE }
|
||||
export { STATE_OVERRIDE as STATE_OVERRIDE_alias_1 }
|
||||
|
||||
/**
|
||||
* A character useful for separating inline nodes.
|
||||
*
|
||||
* @remarks
|
||||
* Typically used in decorations as follows.
|
||||
*
|
||||
* ```ts
|
||||
* document.createTextNode(ZERO_WIDTH_SPACE_CHAR);
|
||||
* ```
|
||||
*
|
||||
* This produces the html entity '8203'
|
||||
*/
|
||||
declare const ZERO_WIDTH_SPACE_CHAR = "\u200B";
|
||||
export { ZERO_WIDTH_SPACE_CHAR }
|
||||
export { ZERO_WIDTH_SPACE_CHAR as ZERO_WIDTH_SPACE_CHAR_alias_1 }
|
||||
|
||||
export { }
|
||||
|
||||
declare global {
|
||||
namespace Remirror {
|
||||
/**
|
||||
* This interface is for extending the default `ExtensionTag`'s in your
|
||||
* codebase with full type checking support.
|
||||
*/
|
||||
interface ExtensionTags {}
|
||||
}
|
||||
}
|
||||
+314
@@ -0,0 +1,314 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
EMPTY_ARRAY: () => EMPTY_ARRAY,
|
||||
EMPTY_NODE: () => EMPTY_NODE,
|
||||
EMPTY_PARAGRAPH_NODE: () => EMPTY_PARAGRAPH_NODE,
|
||||
ErrorConstant: () => ErrorConstant,
|
||||
ExtensionPriority: () => ExtensionPriority,
|
||||
ExtensionTag: () => ExtensionTag,
|
||||
LEAF_NODE_REPLACING_CHARACTER: () => LEAF_NODE_REPLACING_CHARACTER,
|
||||
ManagerPhase: () => ManagerPhase,
|
||||
NON_BREAKING_SPACE_CHAR: () => NON_BREAKING_SPACE_CHAR,
|
||||
NULL_CHARACTER: () => NULL_CHARACTER,
|
||||
NamedShortcut: () => NamedShortcut,
|
||||
REMIRROR_WEBVIEW_NAME: () => REMIRROR_WEBVIEW_NAME,
|
||||
RemirrorIdentifier: () => RemirrorIdentifier,
|
||||
SELECTED_NODE_CLASS_NAME: () => SELECTED_NODE_CLASS_NAME,
|
||||
SELECTED_NODE_CLASS_SELECTOR: () => SELECTED_NODE_CLASS_SELECTOR,
|
||||
STATE_OVERRIDE: () => STATE_OVERRIDE,
|
||||
ZERO_WIDTH_SPACE_CHAR: () => ZERO_WIDTH_SPACE_CHAR,
|
||||
__INTERNAL_REMIRROR_IDENTIFIER_KEY__: () => __INTERNAL_REMIRROR_IDENTIFIER_KEY__,
|
||||
mutateTag: () => mutateTag
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
|
||||
// src/core-constants.ts
|
||||
var SELECTED_NODE_CLASS_NAME = "ProseMirror-selectednode";
|
||||
var SELECTED_NODE_CLASS_SELECTOR = ".".concat(SELECTED_NODE_CLASS_NAME);
|
||||
var LEAF_NODE_REPLACING_CHARACTER = "\uFFFC";
|
||||
var NULL_CHARACTER = "\0";
|
||||
var STATE_OVERRIDE = "__state_override__";
|
||||
var REMIRROR_WEBVIEW_NAME = "$$__REMIRROR_WEBVIEW_BUNDLE__$$";
|
||||
var ZERO_WIDTH_SPACE_CHAR = "\u200B";
|
||||
var NON_BREAKING_SPACE_CHAR = "\xA0";
|
||||
var EMPTY_PARAGRAPH_NODE = {
|
||||
type: "doc",
|
||||
content: [
|
||||
{
|
||||
type: "paragraph"
|
||||
}
|
||||
]
|
||||
};
|
||||
var EMPTY_NODE = {
|
||||
type: "doc",
|
||||
content: []
|
||||
};
|
||||
function mutateTag(mutator) {
|
||||
mutator(BaseExtensionTag);
|
||||
}
|
||||
var BaseExtensionTag = {
|
||||
/**
|
||||
* Describes a node that can be used as the last node of a document and
|
||||
* doesn't need to have anything else rendered after itself.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* e.g. `paragraph`
|
||||
*/
|
||||
LastNodeCompatible: "lastNodeCompatible",
|
||||
/**
|
||||
* A mark that is used to change the formatting of the node it wraps.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* e.g. `bold`, `italic`
|
||||
*/
|
||||
FormattingMark: "formattingMark",
|
||||
/**
|
||||
* A node that formats text in a non-standard way.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* e.g. `codeBlock`, `heading`, `blockquote`
|
||||
*/
|
||||
FormattingNode: "formattingNode",
|
||||
/**
|
||||
* Identifies a node which has problems with cursor navigation.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* When this tag is added to an extension this will be picked up by
|
||||
* behavioural extensions such as the NodeCursorExtension which makes hard to
|
||||
* reach nodes reachable using keyboard arrows.
|
||||
*/
|
||||
NodeCursor: "nodeCursor",
|
||||
/**
|
||||
* Mark group for font styling (e.g. bold, italic, underline, superscript).
|
||||
*/
|
||||
FontStyle: "fontStyle",
|
||||
/**
|
||||
* Mark groups for links.
|
||||
*/
|
||||
Link: "link",
|
||||
/**
|
||||
* Mark groups for colors (text-color, background-color, etc).
|
||||
*/
|
||||
Color: "color",
|
||||
/**
|
||||
* Mark group for alignment.
|
||||
*/
|
||||
Alignment: "alignment",
|
||||
/**
|
||||
* Mark group for indentation.
|
||||
*/
|
||||
Indentation: "indentation",
|
||||
/**
|
||||
* Extension which affect the behaviour of the content. Can be nodes marks or
|
||||
* plain.
|
||||
*/
|
||||
Behavior: "behavior",
|
||||
/**
|
||||
* Marks and nodes which contain code.
|
||||
*/
|
||||
Code: "code",
|
||||
/**
|
||||
* Whether this node is an inline node.
|
||||
*
|
||||
* - `text` is an inline node, but `paragraph` is a block node.
|
||||
*/
|
||||
InlineNode: "inline",
|
||||
/**
|
||||
* This is a node that can contain list items.
|
||||
*/
|
||||
ListContainerNode: "listContainer",
|
||||
/**
|
||||
* Tags the extension as a list item node which can be contained by
|
||||
* [[`ExtensionTag.ListNode`]].
|
||||
*/
|
||||
ListItemNode: "listItemNode",
|
||||
/**
|
||||
* Sets this as a block level node.
|
||||
*/
|
||||
Block: "block",
|
||||
/**
|
||||
* @deprecate use `ExtensionTags.Block` instead.
|
||||
*/
|
||||
BlockNode: "block",
|
||||
/**
|
||||
* Set this as a text block
|
||||
*/
|
||||
TextBlock: "textBlock",
|
||||
/**
|
||||
* A tag that excludes this from input rules.
|
||||
*/
|
||||
ExcludeInputRules: "excludeFromInputRules",
|
||||
/**
|
||||
* A mark or node that can't be exited when at the end and beginning of the
|
||||
* document with an arrow key or backspace key.
|
||||
*/
|
||||
PreventExits: "preventsExits",
|
||||
/**
|
||||
* Represents a media compatible node.
|
||||
*/
|
||||
Media: "media"
|
||||
};
|
||||
var ExtensionTag = BaseExtensionTag;
|
||||
var __INTERNAL_REMIRROR_IDENTIFIER_KEY__ = Symbol.for("__remirror__");
|
||||
var RemirrorIdentifier = /* @__PURE__ */ ((RemirrorIdentifier2) => {
|
||||
RemirrorIdentifier2["PlainExtension"] = "RemirrorPlainExtension";
|
||||
RemirrorIdentifier2["NodeExtension"] = "RemirrorNodeExtension";
|
||||
RemirrorIdentifier2["MarkExtension"] = "RemirrorMarkExtension";
|
||||
RemirrorIdentifier2["PlainExtensionConstructor"] = "RemirrorPlainExtensionConstructor";
|
||||
RemirrorIdentifier2["NodeExtensionConstructor"] = "RemirrorNodeExtensionConstructor";
|
||||
RemirrorIdentifier2["MarkExtensionConstructor"] = "RemirrorMarkExtensionConstructor";
|
||||
RemirrorIdentifier2["Manager"] = "RemirrorManager";
|
||||
RemirrorIdentifier2["Preset"] = "RemirrorPreset";
|
||||
RemirrorIdentifier2["PresetConstructor"] = "RemirrorPresetConstructor";
|
||||
return RemirrorIdentifier2;
|
||||
})(RemirrorIdentifier || {});
|
||||
var ExtensionPriority = /* @__PURE__ */ ((ExtensionPriority2) => {
|
||||
ExtensionPriority2[ExtensionPriority2["Critical"] = 1e6] = "Critical";
|
||||
ExtensionPriority2[ExtensionPriority2["Highest"] = 1e5] = "Highest";
|
||||
ExtensionPriority2[ExtensionPriority2["High"] = 1e4] = "High";
|
||||
ExtensionPriority2[ExtensionPriority2["Medium"] = 1e3] = "Medium";
|
||||
ExtensionPriority2[ExtensionPriority2["Default"] = 100] = "Default";
|
||||
ExtensionPriority2[ExtensionPriority2["Low"] = 10] = "Low";
|
||||
ExtensionPriority2[ExtensionPriority2["Lowest"] = 0] = "Lowest";
|
||||
return ExtensionPriority2;
|
||||
})(ExtensionPriority || {});
|
||||
var ManagerPhase = /* @__PURE__ */ ((ManagerPhase2) => {
|
||||
ManagerPhase2[ManagerPhase2["None"] = 0] = "None";
|
||||
ManagerPhase2[ManagerPhase2["Create"] = 1] = "Create";
|
||||
ManagerPhase2[ManagerPhase2["EditorView"] = 2] = "EditorView";
|
||||
ManagerPhase2[ManagerPhase2["Runtime"] = 3] = "Runtime";
|
||||
ManagerPhase2[ManagerPhase2["Destroy"] = 4] = "Destroy";
|
||||
return ManagerPhase2;
|
||||
})(ManagerPhase || {});
|
||||
var NamedShortcut = /* @__PURE__ */ ((NamedShortcut2) => {
|
||||
NamedShortcut2["Undo"] = "_|undo|_";
|
||||
NamedShortcut2["Redo"] = "_|redo|_";
|
||||
NamedShortcut2["Bold"] = "_|bold|_";
|
||||
NamedShortcut2["Italic"] = "_|italic|_";
|
||||
NamedShortcut2["Underline"] = "_|underline|_";
|
||||
NamedShortcut2["Strike"] = "_|strike|_";
|
||||
NamedShortcut2["Code"] = "_|code|_";
|
||||
NamedShortcut2["Paragraph"] = "_|paragraph|_";
|
||||
NamedShortcut2["H1"] = "_|h1|_";
|
||||
NamedShortcut2["H2"] = "_|h2|_";
|
||||
NamedShortcut2["H3"] = "_|h3|_";
|
||||
NamedShortcut2["H4"] = "_|h4|_";
|
||||
NamedShortcut2["H5"] = "_|h5|_";
|
||||
NamedShortcut2["H6"] = "_|h6|_";
|
||||
NamedShortcut2["TaskList"] = "_|task|_";
|
||||
NamedShortcut2["BulletList"] = "_|bullet|_";
|
||||
NamedShortcut2["OrderedList"] = "_|number|_";
|
||||
NamedShortcut2["Quote"] = "_|quote|_";
|
||||
NamedShortcut2["Divider"] = "_|divider|_";
|
||||
NamedShortcut2["Codeblock"] = "_|codeblock|_";
|
||||
NamedShortcut2["ClearFormatting"] = "_|clear|_";
|
||||
NamedShortcut2["Superscript"] = "_|sup|_";
|
||||
NamedShortcut2["Subscript"] = "_|sub|_";
|
||||
NamedShortcut2["LeftAlignment"] = "_|left-align|_";
|
||||
NamedShortcut2["CenterAlignment"] = "_|center-align|_";
|
||||
NamedShortcut2["RightAlignment"] = "_|right-align|_";
|
||||
NamedShortcut2["JustifyAlignment"] = "_|justify-align|_";
|
||||
NamedShortcut2["InsertLink"] = "_|link|_";
|
||||
NamedShortcut2["Find"] = "_|find|_";
|
||||
NamedShortcut2["FindBackwards"] = "_|find-backwards|_";
|
||||
NamedShortcut2["FindReplace"] = "_|find-replace|_";
|
||||
NamedShortcut2["AddFootnote"] = "_|footnote|_";
|
||||
NamedShortcut2["AddComment"] = "_|comment|_";
|
||||
NamedShortcut2["ContextMenu"] = "_|context-menu|_";
|
||||
NamedShortcut2["IncreaseFontSize"] = "_|inc-font-size|_";
|
||||
NamedShortcut2["DecreaseFontSize"] = "_|dec-font-size|_";
|
||||
NamedShortcut2["IncreaseIndent"] = "_|indent|_";
|
||||
NamedShortcut2["DecreaseIndent"] = "_|dedent|_";
|
||||
NamedShortcut2["Shortcuts"] = "_|shortcuts|_";
|
||||
NamedShortcut2["Copy"] = "_|copy|_";
|
||||
NamedShortcut2["Cut"] = "_|cut|_";
|
||||
NamedShortcut2["Paste"] = "_|paste|_";
|
||||
NamedShortcut2["PastePlain"] = "_|paste-plain|_";
|
||||
NamedShortcut2["SelectAll"] = "_|select-all|_";
|
||||
NamedShortcut2["Format"] = "_|format|_";
|
||||
return NamedShortcut2;
|
||||
})(NamedShortcut || {});
|
||||
var EMPTY_ARRAY = [];
|
||||
|
||||
// src/error-constants.ts
|
||||
var ErrorConstant = /* @__PURE__ */ ((ErrorConstant2) => {
|
||||
ErrorConstant2["UNKNOWN"] = "RMR0001";
|
||||
ErrorConstant2["INVALID_COMMAND_ARGUMENTS"] = "RMR0002";
|
||||
ErrorConstant2["CUSTOM"] = "RMR0003";
|
||||
ErrorConstant2["CORE_HELPERS"] = "RMR0004";
|
||||
ErrorConstant2["MUTATION"] = "RMR0005";
|
||||
ErrorConstant2["INTERNAL"] = "RMR0006";
|
||||
ErrorConstant2["MISSING_REQUIRED_EXTENSION"] = "RMR0007";
|
||||
ErrorConstant2["MANAGER_PHASE_ERROR"] = "RMR0008";
|
||||
ErrorConstant2["INVALID_GET_EXTENSION"] = "RMR0010";
|
||||
ErrorConstant2["INVALID_MANAGER_ARGUMENTS"] = "RMR0011";
|
||||
ErrorConstant2["SCHEMA"] = "RMR0012";
|
||||
ErrorConstant2["HELPERS_CALLED_IN_OUTER_SCOPE"] = "RMR0013";
|
||||
ErrorConstant2["INVALID_MANAGER_EXTENSION"] = "RMR0014";
|
||||
ErrorConstant2["DUPLICATE_COMMAND_NAMES"] = "RMR0016";
|
||||
ErrorConstant2["DUPLICATE_HELPER_NAMES"] = "RMR0017";
|
||||
ErrorConstant2["NON_CHAINABLE_COMMAND"] = "RMR0018";
|
||||
ErrorConstant2["INVALID_EXTENSION"] = "RMR0019";
|
||||
ErrorConstant2["INVALID_CONTENT"] = "RMR0021";
|
||||
ErrorConstant2["INVALID_NAME"] = "RMR0050";
|
||||
ErrorConstant2["EXTENSION"] = "RMR0100";
|
||||
ErrorConstant2["EXTENSION_SPEC"] = "RMR0101";
|
||||
ErrorConstant2["EXTENSION_EXTRA_ATTRIBUTES"] = "RMR0102";
|
||||
ErrorConstant2["INVALID_SET_EXTENSION_OPTIONS"] = "RMR0103";
|
||||
ErrorConstant2["REACT_PROVIDER_CONTEXT"] = "RMR0200";
|
||||
ErrorConstant2["REACT_GET_ROOT_PROPS"] = "RMR0201";
|
||||
ErrorConstant2["REACT_EDITOR_VIEW"] = "RMR0202";
|
||||
ErrorConstant2["REACT_CONTROLLED"] = "RMR0203";
|
||||
ErrorConstant2["REACT_NODE_VIEW"] = "RMR0204";
|
||||
ErrorConstant2["REACT_GET_CONTEXT"] = "RMR0205";
|
||||
ErrorConstant2["REACT_COMPONENTS"] = "RMR0206";
|
||||
ErrorConstant2["REACT_HOOKS"] = "RMR0207";
|
||||
ErrorConstant2["I18N_CONTEXT"] = "RMR0300";
|
||||
return ErrorConstant2;
|
||||
})(ErrorConstant || {});
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
EMPTY_ARRAY,
|
||||
EMPTY_NODE,
|
||||
EMPTY_PARAGRAPH_NODE,
|
||||
ErrorConstant,
|
||||
ExtensionPriority,
|
||||
ExtensionTag,
|
||||
LEAF_NODE_REPLACING_CHARACTER,
|
||||
ManagerPhase,
|
||||
NON_BREAKING_SPACE_CHAR,
|
||||
NULL_CHARACTER,
|
||||
NamedShortcut,
|
||||
REMIRROR_WEBVIEW_NAME,
|
||||
RemirrorIdentifier,
|
||||
SELECTED_NODE_CLASS_NAME,
|
||||
SELECTED_NODE_CLASS_SELECTOR,
|
||||
STATE_OVERRIDE,
|
||||
ZERO_WIDTH_SPACE_CHAR,
|
||||
__INTERNAL_REMIRROR_IDENTIFIER_KEY__,
|
||||
mutateTag
|
||||
});
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
export { ErrorConstant_alias_1 as ErrorConstant } from './_tsup-dts-rollup';
|
||||
export { mutateTag_alias_1 as mutateTag } from './_tsup-dts-rollup';
|
||||
export { SELECTED_NODE_CLASS_NAME_alias_1 as SELECTED_NODE_CLASS_NAME } from './_tsup-dts-rollup';
|
||||
export { SELECTED_NODE_CLASS_SELECTOR_alias_1 as SELECTED_NODE_CLASS_SELECTOR } from './_tsup-dts-rollup';
|
||||
export { LEAF_NODE_REPLACING_CHARACTER_alias_1 as LEAF_NODE_REPLACING_CHARACTER } from './_tsup-dts-rollup';
|
||||
export { NULL_CHARACTER_alias_1 as NULL_CHARACTER } from './_tsup-dts-rollup';
|
||||
export { STATE_OVERRIDE_alias_1 as STATE_OVERRIDE } from './_tsup-dts-rollup';
|
||||
export { REMIRROR_WEBVIEW_NAME_alias_1 as REMIRROR_WEBVIEW_NAME } from './_tsup-dts-rollup';
|
||||
export { ZERO_WIDTH_SPACE_CHAR_alias_1 as ZERO_WIDTH_SPACE_CHAR } from './_tsup-dts-rollup';
|
||||
export { NON_BREAKING_SPACE_CHAR_alias_1 as NON_BREAKING_SPACE_CHAR } from './_tsup-dts-rollup';
|
||||
export { EMPTY_PARAGRAPH_NODE_alias_1 as EMPTY_PARAGRAPH_NODE } from './_tsup-dts-rollup';
|
||||
export { EMPTY_NODE_alias_1 as EMPTY_NODE } from './_tsup-dts-rollup';
|
||||
export { ExtensionTag_alias_1 as ExtensionTag } from './_tsup-dts-rollup';
|
||||
export { ExtensionTagType_alias_1 as ExtensionTagType } from './_tsup-dts-rollup';
|
||||
export { __INTERNAL_REMIRROR_IDENTIFIER_KEY___alias_1 as __INTERNAL_REMIRROR_IDENTIFIER_KEY__ } from './_tsup-dts-rollup';
|
||||
export { RemirrorIdentifier_alias_1 as RemirrorIdentifier } from './_tsup-dts-rollup';
|
||||
export { ExtensionPriority_alias_1 as ExtensionPriority } from './_tsup-dts-rollup';
|
||||
export { ManagerPhase_alias_1 as ManagerPhase } from './_tsup-dts-rollup';
|
||||
export { NamedShortcut_alias_1 as NamedShortcut } from './_tsup-dts-rollup';
|
||||
export { EMPTY_ARRAY_alias_1 as EMPTY_ARRAY } from './_tsup-dts-rollup';
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
export { ErrorConstant_alias_1 as ErrorConstant } from './_tsup-dts-rollup';
|
||||
export { mutateTag_alias_1 as mutateTag } from './_tsup-dts-rollup';
|
||||
export { SELECTED_NODE_CLASS_NAME_alias_1 as SELECTED_NODE_CLASS_NAME } from './_tsup-dts-rollup';
|
||||
export { SELECTED_NODE_CLASS_SELECTOR_alias_1 as SELECTED_NODE_CLASS_SELECTOR } from './_tsup-dts-rollup';
|
||||
export { LEAF_NODE_REPLACING_CHARACTER_alias_1 as LEAF_NODE_REPLACING_CHARACTER } from './_tsup-dts-rollup';
|
||||
export { NULL_CHARACTER_alias_1 as NULL_CHARACTER } from './_tsup-dts-rollup';
|
||||
export { STATE_OVERRIDE_alias_1 as STATE_OVERRIDE } from './_tsup-dts-rollup';
|
||||
export { REMIRROR_WEBVIEW_NAME_alias_1 as REMIRROR_WEBVIEW_NAME } from './_tsup-dts-rollup';
|
||||
export { ZERO_WIDTH_SPACE_CHAR_alias_1 as ZERO_WIDTH_SPACE_CHAR } from './_tsup-dts-rollup';
|
||||
export { NON_BREAKING_SPACE_CHAR_alias_1 as NON_BREAKING_SPACE_CHAR } from './_tsup-dts-rollup';
|
||||
export { EMPTY_PARAGRAPH_NODE_alias_1 as EMPTY_PARAGRAPH_NODE } from './_tsup-dts-rollup';
|
||||
export { EMPTY_NODE_alias_1 as EMPTY_NODE } from './_tsup-dts-rollup';
|
||||
export { ExtensionTag_alias_1 as ExtensionTag } from './_tsup-dts-rollup';
|
||||
export { ExtensionTagType_alias_1 as ExtensionTagType } from './_tsup-dts-rollup';
|
||||
export { __INTERNAL_REMIRROR_IDENTIFIER_KEY___alias_1 as __INTERNAL_REMIRROR_IDENTIFIER_KEY__ } from './_tsup-dts-rollup';
|
||||
export { RemirrorIdentifier_alias_1 as RemirrorIdentifier } from './_tsup-dts-rollup';
|
||||
export { ExtensionPriority_alias_1 as ExtensionPriority } from './_tsup-dts-rollup';
|
||||
export { ManagerPhase_alias_1 as ManagerPhase } from './_tsup-dts-rollup';
|
||||
export { NamedShortcut_alias_1 as NamedShortcut } from './_tsup-dts-rollup';
|
||||
export { EMPTY_ARRAY_alias_1 as EMPTY_ARRAY } from './_tsup-dts-rollup';
|
||||
+269
@@ -0,0 +1,269 @@
|
||||
// src/core-constants.ts
|
||||
var SELECTED_NODE_CLASS_NAME = "ProseMirror-selectednode";
|
||||
var SELECTED_NODE_CLASS_SELECTOR = ".".concat(SELECTED_NODE_CLASS_NAME);
|
||||
var LEAF_NODE_REPLACING_CHARACTER = "\uFFFC";
|
||||
var NULL_CHARACTER = "\0";
|
||||
var STATE_OVERRIDE = "__state_override__";
|
||||
var REMIRROR_WEBVIEW_NAME = "$$__REMIRROR_WEBVIEW_BUNDLE__$$";
|
||||
var ZERO_WIDTH_SPACE_CHAR = "\u200B";
|
||||
var NON_BREAKING_SPACE_CHAR = "\xA0";
|
||||
var EMPTY_PARAGRAPH_NODE = {
|
||||
type: "doc",
|
||||
content: [
|
||||
{
|
||||
type: "paragraph"
|
||||
}
|
||||
]
|
||||
};
|
||||
var EMPTY_NODE = {
|
||||
type: "doc",
|
||||
content: []
|
||||
};
|
||||
function mutateTag(mutator) {
|
||||
mutator(BaseExtensionTag);
|
||||
}
|
||||
var BaseExtensionTag = {
|
||||
/**
|
||||
* Describes a node that can be used as the last node of a document and
|
||||
* doesn't need to have anything else rendered after itself.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* e.g. `paragraph`
|
||||
*/
|
||||
LastNodeCompatible: "lastNodeCompatible",
|
||||
/**
|
||||
* A mark that is used to change the formatting of the node it wraps.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* e.g. `bold`, `italic`
|
||||
*/
|
||||
FormattingMark: "formattingMark",
|
||||
/**
|
||||
* A node that formats text in a non-standard way.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* e.g. `codeBlock`, `heading`, `blockquote`
|
||||
*/
|
||||
FormattingNode: "formattingNode",
|
||||
/**
|
||||
* Identifies a node which has problems with cursor navigation.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* When this tag is added to an extension this will be picked up by
|
||||
* behavioural extensions such as the NodeCursorExtension which makes hard to
|
||||
* reach nodes reachable using keyboard arrows.
|
||||
*/
|
||||
NodeCursor: "nodeCursor",
|
||||
/**
|
||||
* Mark group for font styling (e.g. bold, italic, underline, superscript).
|
||||
*/
|
||||
FontStyle: "fontStyle",
|
||||
/**
|
||||
* Mark groups for links.
|
||||
*/
|
||||
Link: "link",
|
||||
/**
|
||||
* Mark groups for colors (text-color, background-color, etc).
|
||||
*/
|
||||
Color: "color",
|
||||
/**
|
||||
* Mark group for alignment.
|
||||
*/
|
||||
Alignment: "alignment",
|
||||
/**
|
||||
* Mark group for indentation.
|
||||
*/
|
||||
Indentation: "indentation",
|
||||
/**
|
||||
* Extension which affect the behaviour of the content. Can be nodes marks or
|
||||
* plain.
|
||||
*/
|
||||
Behavior: "behavior",
|
||||
/**
|
||||
* Marks and nodes which contain code.
|
||||
*/
|
||||
Code: "code",
|
||||
/**
|
||||
* Whether this node is an inline node.
|
||||
*
|
||||
* - `text` is an inline node, but `paragraph` is a block node.
|
||||
*/
|
||||
InlineNode: "inline",
|
||||
/**
|
||||
* This is a node that can contain list items.
|
||||
*/
|
||||
ListContainerNode: "listContainer",
|
||||
/**
|
||||
* Tags the extension as a list item node which can be contained by
|
||||
* [[`ExtensionTag.ListNode`]].
|
||||
*/
|
||||
ListItemNode: "listItemNode",
|
||||
/**
|
||||
* Sets this as a block level node.
|
||||
*/
|
||||
Block: "block",
|
||||
/**
|
||||
* @deprecate use `ExtensionTags.Block` instead.
|
||||
*/
|
||||
BlockNode: "block",
|
||||
/**
|
||||
* Set this as a text block
|
||||
*/
|
||||
TextBlock: "textBlock",
|
||||
/**
|
||||
* A tag that excludes this from input rules.
|
||||
*/
|
||||
ExcludeInputRules: "excludeFromInputRules",
|
||||
/**
|
||||
* A mark or node that can't be exited when at the end and beginning of the
|
||||
* document with an arrow key or backspace key.
|
||||
*/
|
||||
PreventExits: "preventsExits",
|
||||
/**
|
||||
* Represents a media compatible node.
|
||||
*/
|
||||
Media: "media"
|
||||
};
|
||||
var ExtensionTag = BaseExtensionTag;
|
||||
var __INTERNAL_REMIRROR_IDENTIFIER_KEY__ = Symbol.for("__remirror__");
|
||||
var RemirrorIdentifier = /* @__PURE__ */ ((RemirrorIdentifier2) => {
|
||||
RemirrorIdentifier2["PlainExtension"] = "RemirrorPlainExtension";
|
||||
RemirrorIdentifier2["NodeExtension"] = "RemirrorNodeExtension";
|
||||
RemirrorIdentifier2["MarkExtension"] = "RemirrorMarkExtension";
|
||||
RemirrorIdentifier2["PlainExtensionConstructor"] = "RemirrorPlainExtensionConstructor";
|
||||
RemirrorIdentifier2["NodeExtensionConstructor"] = "RemirrorNodeExtensionConstructor";
|
||||
RemirrorIdentifier2["MarkExtensionConstructor"] = "RemirrorMarkExtensionConstructor";
|
||||
RemirrorIdentifier2["Manager"] = "RemirrorManager";
|
||||
RemirrorIdentifier2["Preset"] = "RemirrorPreset";
|
||||
RemirrorIdentifier2["PresetConstructor"] = "RemirrorPresetConstructor";
|
||||
return RemirrorIdentifier2;
|
||||
})(RemirrorIdentifier || {});
|
||||
var ExtensionPriority = /* @__PURE__ */ ((ExtensionPriority2) => {
|
||||
ExtensionPriority2[ExtensionPriority2["Critical"] = 1e6] = "Critical";
|
||||
ExtensionPriority2[ExtensionPriority2["Highest"] = 1e5] = "Highest";
|
||||
ExtensionPriority2[ExtensionPriority2["High"] = 1e4] = "High";
|
||||
ExtensionPriority2[ExtensionPriority2["Medium"] = 1e3] = "Medium";
|
||||
ExtensionPriority2[ExtensionPriority2["Default"] = 100] = "Default";
|
||||
ExtensionPriority2[ExtensionPriority2["Low"] = 10] = "Low";
|
||||
ExtensionPriority2[ExtensionPriority2["Lowest"] = 0] = "Lowest";
|
||||
return ExtensionPriority2;
|
||||
})(ExtensionPriority || {});
|
||||
var ManagerPhase = /* @__PURE__ */ ((ManagerPhase2) => {
|
||||
ManagerPhase2[ManagerPhase2["None"] = 0] = "None";
|
||||
ManagerPhase2[ManagerPhase2["Create"] = 1] = "Create";
|
||||
ManagerPhase2[ManagerPhase2["EditorView"] = 2] = "EditorView";
|
||||
ManagerPhase2[ManagerPhase2["Runtime"] = 3] = "Runtime";
|
||||
ManagerPhase2[ManagerPhase2["Destroy"] = 4] = "Destroy";
|
||||
return ManagerPhase2;
|
||||
})(ManagerPhase || {});
|
||||
var NamedShortcut = /* @__PURE__ */ ((NamedShortcut2) => {
|
||||
NamedShortcut2["Undo"] = "_|undo|_";
|
||||
NamedShortcut2["Redo"] = "_|redo|_";
|
||||
NamedShortcut2["Bold"] = "_|bold|_";
|
||||
NamedShortcut2["Italic"] = "_|italic|_";
|
||||
NamedShortcut2["Underline"] = "_|underline|_";
|
||||
NamedShortcut2["Strike"] = "_|strike|_";
|
||||
NamedShortcut2["Code"] = "_|code|_";
|
||||
NamedShortcut2["Paragraph"] = "_|paragraph|_";
|
||||
NamedShortcut2["H1"] = "_|h1|_";
|
||||
NamedShortcut2["H2"] = "_|h2|_";
|
||||
NamedShortcut2["H3"] = "_|h3|_";
|
||||
NamedShortcut2["H4"] = "_|h4|_";
|
||||
NamedShortcut2["H5"] = "_|h5|_";
|
||||
NamedShortcut2["H6"] = "_|h6|_";
|
||||
NamedShortcut2["TaskList"] = "_|task|_";
|
||||
NamedShortcut2["BulletList"] = "_|bullet|_";
|
||||
NamedShortcut2["OrderedList"] = "_|number|_";
|
||||
NamedShortcut2["Quote"] = "_|quote|_";
|
||||
NamedShortcut2["Divider"] = "_|divider|_";
|
||||
NamedShortcut2["Codeblock"] = "_|codeblock|_";
|
||||
NamedShortcut2["ClearFormatting"] = "_|clear|_";
|
||||
NamedShortcut2["Superscript"] = "_|sup|_";
|
||||
NamedShortcut2["Subscript"] = "_|sub|_";
|
||||
NamedShortcut2["LeftAlignment"] = "_|left-align|_";
|
||||
NamedShortcut2["CenterAlignment"] = "_|center-align|_";
|
||||
NamedShortcut2["RightAlignment"] = "_|right-align|_";
|
||||
NamedShortcut2["JustifyAlignment"] = "_|justify-align|_";
|
||||
NamedShortcut2["InsertLink"] = "_|link|_";
|
||||
NamedShortcut2["Find"] = "_|find|_";
|
||||
NamedShortcut2["FindBackwards"] = "_|find-backwards|_";
|
||||
NamedShortcut2["FindReplace"] = "_|find-replace|_";
|
||||
NamedShortcut2["AddFootnote"] = "_|footnote|_";
|
||||
NamedShortcut2["AddComment"] = "_|comment|_";
|
||||
NamedShortcut2["ContextMenu"] = "_|context-menu|_";
|
||||
NamedShortcut2["IncreaseFontSize"] = "_|inc-font-size|_";
|
||||
NamedShortcut2["DecreaseFontSize"] = "_|dec-font-size|_";
|
||||
NamedShortcut2["IncreaseIndent"] = "_|indent|_";
|
||||
NamedShortcut2["DecreaseIndent"] = "_|dedent|_";
|
||||
NamedShortcut2["Shortcuts"] = "_|shortcuts|_";
|
||||
NamedShortcut2["Copy"] = "_|copy|_";
|
||||
NamedShortcut2["Cut"] = "_|cut|_";
|
||||
NamedShortcut2["Paste"] = "_|paste|_";
|
||||
NamedShortcut2["PastePlain"] = "_|paste-plain|_";
|
||||
NamedShortcut2["SelectAll"] = "_|select-all|_";
|
||||
NamedShortcut2["Format"] = "_|format|_";
|
||||
return NamedShortcut2;
|
||||
})(NamedShortcut || {});
|
||||
var EMPTY_ARRAY = [];
|
||||
|
||||
// src/error-constants.ts
|
||||
var ErrorConstant = /* @__PURE__ */ ((ErrorConstant2) => {
|
||||
ErrorConstant2["UNKNOWN"] = "RMR0001";
|
||||
ErrorConstant2["INVALID_COMMAND_ARGUMENTS"] = "RMR0002";
|
||||
ErrorConstant2["CUSTOM"] = "RMR0003";
|
||||
ErrorConstant2["CORE_HELPERS"] = "RMR0004";
|
||||
ErrorConstant2["MUTATION"] = "RMR0005";
|
||||
ErrorConstant2["INTERNAL"] = "RMR0006";
|
||||
ErrorConstant2["MISSING_REQUIRED_EXTENSION"] = "RMR0007";
|
||||
ErrorConstant2["MANAGER_PHASE_ERROR"] = "RMR0008";
|
||||
ErrorConstant2["INVALID_GET_EXTENSION"] = "RMR0010";
|
||||
ErrorConstant2["INVALID_MANAGER_ARGUMENTS"] = "RMR0011";
|
||||
ErrorConstant2["SCHEMA"] = "RMR0012";
|
||||
ErrorConstant2["HELPERS_CALLED_IN_OUTER_SCOPE"] = "RMR0013";
|
||||
ErrorConstant2["INVALID_MANAGER_EXTENSION"] = "RMR0014";
|
||||
ErrorConstant2["DUPLICATE_COMMAND_NAMES"] = "RMR0016";
|
||||
ErrorConstant2["DUPLICATE_HELPER_NAMES"] = "RMR0017";
|
||||
ErrorConstant2["NON_CHAINABLE_COMMAND"] = "RMR0018";
|
||||
ErrorConstant2["INVALID_EXTENSION"] = "RMR0019";
|
||||
ErrorConstant2["INVALID_CONTENT"] = "RMR0021";
|
||||
ErrorConstant2["INVALID_NAME"] = "RMR0050";
|
||||
ErrorConstant2["EXTENSION"] = "RMR0100";
|
||||
ErrorConstant2["EXTENSION_SPEC"] = "RMR0101";
|
||||
ErrorConstant2["EXTENSION_EXTRA_ATTRIBUTES"] = "RMR0102";
|
||||
ErrorConstant2["INVALID_SET_EXTENSION_OPTIONS"] = "RMR0103";
|
||||
ErrorConstant2["REACT_PROVIDER_CONTEXT"] = "RMR0200";
|
||||
ErrorConstant2["REACT_GET_ROOT_PROPS"] = "RMR0201";
|
||||
ErrorConstant2["REACT_EDITOR_VIEW"] = "RMR0202";
|
||||
ErrorConstant2["REACT_CONTROLLED"] = "RMR0203";
|
||||
ErrorConstant2["REACT_NODE_VIEW"] = "RMR0204";
|
||||
ErrorConstant2["REACT_GET_CONTEXT"] = "RMR0205";
|
||||
ErrorConstant2["REACT_COMPONENTS"] = "RMR0206";
|
||||
ErrorConstant2["REACT_HOOKS"] = "RMR0207";
|
||||
ErrorConstant2["I18N_CONTEXT"] = "RMR0300";
|
||||
return ErrorConstant2;
|
||||
})(ErrorConstant || {});
|
||||
export {
|
||||
EMPTY_ARRAY,
|
||||
EMPTY_NODE,
|
||||
EMPTY_PARAGRAPH_NODE,
|
||||
ErrorConstant,
|
||||
ExtensionPriority,
|
||||
ExtensionTag,
|
||||
LEAF_NODE_REPLACING_CHARACTER,
|
||||
ManagerPhase,
|
||||
NON_BREAKING_SPACE_CHAR,
|
||||
NULL_CHARACTER,
|
||||
NamedShortcut,
|
||||
REMIRROR_WEBVIEW_NAME,
|
||||
RemirrorIdentifier,
|
||||
SELECTED_NODE_CLASS_NAME,
|
||||
SELECTED_NODE_CLASS_SELECTOR,
|
||||
STATE_OVERRIDE,
|
||||
ZERO_WIDTH_SPACE_CHAR,
|
||||
__INTERNAL_REMIRROR_IDENTIFIER_KEY__,
|
||||
mutateTag
|
||||
};
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "@remirror/core-constants",
|
||||
"version": "3.0.0",
|
||||
"description": "The core constants used throughout the remirror codebase",
|
||||
"homepage": "https://github.com/remirror/remirror/tree/HEAD/packages/remirror__core-constants",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remirror/remirror.git",
|
||||
"directory": "packages/remirror__core-constants"
|
||||
},
|
||||
"license": "MIT",
|
||||
"contributors": [
|
||||
"Ifiok Jr. <ifiokotung@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/remirror-core-constants.d.ts",
|
||||
"import": "./dist/remirror-core-constants.js",
|
||||
"require": "./dist/remirror-core-constants.cjs"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"main": "./dist/remirror-core-constants.cjs",
|
||||
"module": "./dist/remirror-core-constants.js",
|
||||
"types": "./dist/remirror-core-constants.d.ts",
|
||||
"files": [
|
||||
"dist",
|
||||
"dist-types"
|
||||
],
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@remirror/cli": "1.1.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"@remirror": {
|
||||
"sizeLimit": "2 KB"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "remirror-cli build"
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
# @remirror/core-constants
|
||||
|
||||
> core constants used throughout the `remirror` codebase.
|
||||
|
||||
[![Version][version]][npm] [![Weekly Downloads][downloads-badge]][npm] [![Bundled size][size-badge]][size] [![Typed Codebase][typescript]](#) [![MIT License][license]](#)
|
||||
|
||||
[version]: https://flat.badgen.net/npm/v/@remirror/core-constants
|
||||
[npm]: https://npmjs.com/package/@remirror/core-constants
|
||||
[license]: https://flat.badgen.net/badge/license/MIT/purple
|
||||
[size]: https://bundlephobia.com/result?p=@remirror/core-constants
|
||||
[size-badge]: https://flat.badgen.net/bundlephobia/minzip/@remirror/core-constants
|
||||
[typescript]: https://flat.badgen.net/badge/icon/TypeScript?icon=typescript&label
|
||||
[downloads-badge]: https://badgen.net/npm/dw/@remirror/core-constants/red?icon=npm
|
||||
|
||||
## Installation
|
||||
|
||||
This is included by default when you install the recommended `remirror` package. All exports are also available via `remirror/core/constants` and `remirror/core`.
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025, Tiptap GmbH
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
# @tiptap/core
|
||||
|
||||
[](https://www.npmjs.com/package/@tiptap/core)
|
||||
[](https://npmcharts.com/compare/tiptap?minimal=true)
|
||||
[](https://www.npmjs.com/package/@tiptap/core)
|
||||
[](https://github.com/sponsors/ueberdosis)
|
||||
|
||||
## Introduction
|
||||
|
||||
Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as _New York Times_, _The Guardian_ or _Atlassian_.
|
||||
|
||||
## Official Documentation
|
||||
|
||||
Documentation can be found on the [Tiptap website](https://tiptap.dev).
|
||||
|
||||
## License
|
||||
|
||||
Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
|
||||
+7017
File diff suppressed because it is too large
Load Diff
+1
File diff suppressed because one or more lines are too long
+4887
File diff suppressed because one or more lines are too long
+4887
File diff suppressed because one or more lines are too long
+6883
File diff suppressed because it is too large
Load Diff
+1
File diff suppressed because one or more lines are too long
+56
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/jsx-runtime.ts
|
||||
var jsx_runtime_exports = {};
|
||||
__export(jsx_runtime_exports, {
|
||||
Fragment: () => Fragment,
|
||||
createElement: () => h,
|
||||
h: () => h,
|
||||
jsx: () => h,
|
||||
jsxDEV: () => h,
|
||||
jsxs: () => h
|
||||
});
|
||||
module.exports = __toCommonJS(jsx_runtime_exports);
|
||||
function Fragment(props) {
|
||||
return props.children;
|
||||
}
|
||||
var h = (tag, attributes) => {
|
||||
if (tag === "slot") {
|
||||
return 0;
|
||||
}
|
||||
if (tag instanceof Function) {
|
||||
return tag(attributes);
|
||||
}
|
||||
const { children, ...rest } = attributes != null ? attributes : {};
|
||||
if (tag === "svg") {
|
||||
throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");
|
||||
}
|
||||
return [tag, rest, children];
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
Fragment,
|
||||
createElement,
|
||||
h,
|
||||
jsx,
|
||||
jsxDEV,
|
||||
jsxs
|
||||
});
|
||||
//# sourceMappingURL=jsx-runtime.cjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/jsx-runtime.ts"],"sourcesContent":["export type Attributes = Record<string, any>\n\nexport type DOMOutputSpecElement = 0 | Attributes | DOMOutputSpecArray\n/**\n * Better describes the output of a `renderHTML` function in prosemirror\n * @see https://prosemirror.net/docs/ref/#model.DOMOutputSpec\n */\nexport type DOMOutputSpecArray =\n | [string]\n | [string, Attributes]\n | [string, 0]\n | [string, Attributes, 0]\n | [string, Attributes, DOMOutputSpecArray | 0]\n | [string, DOMOutputSpecArray]\n\n// JSX types for Tiptap's JSX runtime\n// These types only apply when using @jsxImportSource @tiptap/core\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace JSX {\n export type Element = DOMOutputSpecArray\n export interface IntrinsicElements {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n }\n export interface ElementChildrenAttribute {\n children: unknown\n }\n}\n\nexport type JSXRenderer = (\n tag: 'slot' | string | ((props?: Attributes) => DOMOutputSpecArray | DOMOutputSpecElement),\n props?: Attributes,\n ...children: JSXRenderer[]\n) => DOMOutputSpecArray | DOMOutputSpecElement\n\nexport function Fragment(props: { children: JSXRenderer[] }) {\n return props.children\n}\n\nexport const h: JSXRenderer = (tag, attributes) => {\n // Treat the slot tag as the Prosemirror hole to render content into\n if (tag === 'slot') {\n return 0\n }\n\n // If the tag is a function, call it with the props\n if (tag instanceof Function) {\n return tag(attributes)\n }\n\n const { children, ...rest } = attributes ?? {}\n\n if (tag === 'svg') {\n throw new Error('SVG elements are not supported in the JSX syntax, use the array syntax instead')\n }\n\n // Otherwise, return the tag, attributes, and children\n return [tag, rest, children]\n}\n\n// See\n// https://esbuild.github.io/api/#jsx-import-source\n// https://www.typescriptlang.org/tsconfig/#jsxImportSource\n\nexport { h as createElement, h as jsx, h as jsxDEV, h as jsxs }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmCO,SAAS,SAAS,OAAoC;AAC3D,SAAO,MAAM;AACf;AAEO,IAAM,IAAiB,CAAC,KAAK,eAAe;AAEjD,MAAI,QAAQ,QAAQ;AAClB,WAAO;AAAA,EACT;AAGA,MAAI,eAAe,UAAU;AAC3B,WAAO,IAAI,UAAU;AAAA,EACvB;AAEA,QAAM,EAAE,UAAU,GAAG,KAAK,IAAI,kCAAc,CAAC;AAE7C,MAAI,QAAQ,OAAO;AACjB,UAAM,IAAI,MAAM,gFAAgF;AAAA,EAClG;AAGA,SAAO,CAAC,KAAK,MAAM,QAAQ;AAC7B;","names":[]}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
type Attributes = Record<string, any>;
|
||||
type DOMOutputSpecElement = 0 | Attributes | DOMOutputSpecArray;
|
||||
/**
|
||||
* Better describes the output of a `renderHTML` function in prosemirror
|
||||
* @see https://prosemirror.net/docs/ref/#model.DOMOutputSpec
|
||||
*/
|
||||
type DOMOutputSpecArray = [string] | [string, Attributes] | [string, 0] | [string, Attributes, 0] | [string, Attributes, DOMOutputSpecArray | 0] | [string, DOMOutputSpecArray];
|
||||
declare namespace JSX {
|
||||
type Element = DOMOutputSpecArray;
|
||||
interface IntrinsicElements {
|
||||
[key: string]: any;
|
||||
}
|
||||
interface ElementChildrenAttribute {
|
||||
children: unknown;
|
||||
}
|
||||
}
|
||||
type JSXRenderer = (tag: 'slot' | string | ((props?: Attributes) => DOMOutputSpecArray | DOMOutputSpecElement), props?: Attributes, ...children: JSXRenderer[]) => DOMOutputSpecArray | DOMOutputSpecElement;
|
||||
declare function Fragment(props: {
|
||||
children: JSXRenderer[];
|
||||
}): JSXRenderer[];
|
||||
declare const h: JSXRenderer;
|
||||
|
||||
export { type Attributes, type DOMOutputSpecArray, type DOMOutputSpecElement, Fragment, JSX, type JSXRenderer, h as createElement, h, h as jsx, h as jsxDEV, h as jsxs };
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
type Attributes = Record<string, any>;
|
||||
type DOMOutputSpecElement = 0 | Attributes | DOMOutputSpecArray;
|
||||
/**
|
||||
* Better describes the output of a `renderHTML` function in prosemirror
|
||||
* @see https://prosemirror.net/docs/ref/#model.DOMOutputSpec
|
||||
*/
|
||||
type DOMOutputSpecArray = [string] | [string, Attributes] | [string, 0] | [string, Attributes, 0] | [string, Attributes, DOMOutputSpecArray | 0] | [string, DOMOutputSpecArray];
|
||||
declare namespace JSX {
|
||||
type Element = DOMOutputSpecArray;
|
||||
interface IntrinsicElements {
|
||||
[key: string]: any;
|
||||
}
|
||||
interface ElementChildrenAttribute {
|
||||
children: unknown;
|
||||
}
|
||||
}
|
||||
type JSXRenderer = (tag: 'slot' | string | ((props?: Attributes) => DOMOutputSpecArray | DOMOutputSpecElement), props?: Attributes, ...children: JSXRenderer[]) => DOMOutputSpecArray | DOMOutputSpecElement;
|
||||
declare function Fragment(props: {
|
||||
children: JSXRenderer[];
|
||||
}): JSXRenderer[];
|
||||
declare const h: JSXRenderer;
|
||||
|
||||
export { type Attributes, type DOMOutputSpecArray, type DOMOutputSpecElement, Fragment, JSX, type JSXRenderer, h as createElement, h, h as jsx, h as jsxDEV, h as jsxs };
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// src/jsx-runtime.ts
|
||||
function Fragment(props) {
|
||||
return props.children;
|
||||
}
|
||||
var h = (tag, attributes) => {
|
||||
if (tag === "slot") {
|
||||
return 0;
|
||||
}
|
||||
if (tag instanceof Function) {
|
||||
return tag(attributes);
|
||||
}
|
||||
const { children, ...rest } = attributes != null ? attributes : {};
|
||||
if (tag === "svg") {
|
||||
throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");
|
||||
}
|
||||
return [tag, rest, children];
|
||||
};
|
||||
export {
|
||||
Fragment,
|
||||
h as createElement,
|
||||
h,
|
||||
h as jsx,
|
||||
h as jsxDEV,
|
||||
h as jsxs
|
||||
};
|
||||
//# sourceMappingURL=jsx-runtime.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/jsx-runtime.ts"],"sourcesContent":["export type Attributes = Record<string, any>\n\nexport type DOMOutputSpecElement = 0 | Attributes | DOMOutputSpecArray\n/**\n * Better describes the output of a `renderHTML` function in prosemirror\n * @see https://prosemirror.net/docs/ref/#model.DOMOutputSpec\n */\nexport type DOMOutputSpecArray =\n | [string]\n | [string, Attributes]\n | [string, 0]\n | [string, Attributes, 0]\n | [string, Attributes, DOMOutputSpecArray | 0]\n | [string, DOMOutputSpecArray]\n\n// JSX types for Tiptap's JSX runtime\n// These types only apply when using @jsxImportSource @tiptap/core\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace JSX {\n export type Element = DOMOutputSpecArray\n export interface IntrinsicElements {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n }\n export interface ElementChildrenAttribute {\n children: unknown\n }\n}\n\nexport type JSXRenderer = (\n tag: 'slot' | string | ((props?: Attributes) => DOMOutputSpecArray | DOMOutputSpecElement),\n props?: Attributes,\n ...children: JSXRenderer[]\n) => DOMOutputSpecArray | DOMOutputSpecElement\n\nexport function Fragment(props: { children: JSXRenderer[] }) {\n return props.children\n}\n\nexport const h: JSXRenderer = (tag, attributes) => {\n // Treat the slot tag as the Prosemirror hole to render content into\n if (tag === 'slot') {\n return 0\n }\n\n // If the tag is a function, call it with the props\n if (tag instanceof Function) {\n return tag(attributes)\n }\n\n const { children, ...rest } = attributes ?? {}\n\n if (tag === 'svg') {\n throw new Error('SVG elements are not supported in the JSX syntax, use the array syntax instead')\n }\n\n // Otherwise, return the tag, attributes, and children\n return [tag, rest, children]\n}\n\n// See\n// https://esbuild.github.io/api/#jsx-import-source\n// https://www.typescriptlang.org/tsconfig/#jsxImportSource\n\nexport { h as createElement, h as jsx, h as jsxDEV, h as jsxs }\n"],"mappings":";AAmCO,SAAS,SAAS,OAAoC;AAC3D,SAAO,MAAM;AACf;AAEO,IAAM,IAAiB,CAAC,KAAK,eAAe;AAEjD,MAAI,QAAQ,QAAQ;AAClB,WAAO;AAAA,EACT;AAGA,MAAI,eAAe,UAAU;AAC3B,WAAO,IAAI,UAAU;AAAA,EACvB;AAEA,QAAM,EAAE,UAAU,GAAG,KAAK,IAAI,kCAAc,CAAC;AAE7C,MAAI,QAAQ,OAAO;AACjB,UAAM,IAAI,MAAM,gFAAgF;AAAA,EAClG;AAGA,SAAO,CAAC,KAAK,MAAM,QAAQ;AAC7B;","names":[]}
|
||||
+1
@@ -0,0 +1 @@
|
||||
module.exports = require('../dist/jsx-runtime/jsx-runtime.cjs')
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from '../src/jsx-runtime.ts'
|
||||
+1
@@ -0,0 +1 @@
|
||||
export type * from '../src/jsx-runtime.js'
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from '../dist/jsx-runtime/jsx-runtime.js'
|
||||
+1
@@ -0,0 +1 @@
|
||||
module.exports = require('../dist/jsx-runtime/jsx-runtime.cjs')
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from '../src/jsx-runtime.ts'
|
||||
+1
@@ -0,0 +1 @@
|
||||
export type * from '../src/jsx-runtime.ts'
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from '../dist/jsx-runtime/jsx-runtime.js'
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"name": "@tiptap/core",
|
||||
"description": "headless rich text editor",
|
||||
"version": "3.19.0",
|
||||
"homepage": "https://tiptap.dev",
|
||||
"keywords": [
|
||||
"tiptap",
|
||||
"headless",
|
||||
"wysiwyg",
|
||||
"text editor",
|
||||
"prosemirror"
|
||||
],
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": {
|
||||
"import": "./dist/index.d.ts",
|
||||
"require": "./dist/index.d.cts"
|
||||
},
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"./jsx-runtime": {
|
||||
"types": {
|
||||
"import": "./jsx-runtime/index.d.ts",
|
||||
"require": "./jsx-runtime/index.d.cts"
|
||||
},
|
||||
"import": "./jsx-runtime/index.js",
|
||||
"require": "./jsx-runtime/index.cjs"
|
||||
},
|
||||
"./jsx-dev-runtime": {
|
||||
"types": {
|
||||
"import": "./jsx-dev-runtime/index.d.ts",
|
||||
"require": "./jsx-dev-runtime/index.d.cts"
|
||||
},
|
||||
"import": "./jsx-dev-runtime/index.js",
|
||||
"require": "./jsx-dev-runtime/index.cjs"
|
||||
}
|
||||
},
|
||||
"main": "dist/index.cjs",
|
||||
"module": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"src",
|
||||
"dist",
|
||||
"jsx-runtime",
|
||||
"jsx-dev-runtime"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@tiptap/pm": "^3.19.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/pm": "^3.19.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ueberdosis/tiptap",
|
||||
"directory": "packages/core"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"scripts": {
|
||||
"build": "tsup",
|
||||
"lint": "prettier ./src/ --check && eslint --cache --quiet --no-error-on-unmatched-pattern ./src/"
|
||||
}
|
||||
}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
import type { EditorState, Transaction } from '@tiptap/pm/state'
|
||||
|
||||
import type { Editor } from './Editor.js'
|
||||
import { createChainableState } from './helpers/createChainableState.js'
|
||||
import type { AnyCommands, CanCommands, ChainedCommands, CommandProps, SingleCommands } from './types.js'
|
||||
|
||||
export class CommandManager {
|
||||
editor: Editor
|
||||
|
||||
rawCommands: AnyCommands
|
||||
|
||||
customState?: EditorState
|
||||
|
||||
constructor(props: { editor: Editor; state?: EditorState }) {
|
||||
this.editor = props.editor
|
||||
this.rawCommands = this.editor.extensionManager.commands
|
||||
this.customState = props.state
|
||||
}
|
||||
|
||||
get hasCustomState(): boolean {
|
||||
return !!this.customState
|
||||
}
|
||||
|
||||
get state(): EditorState {
|
||||
return this.customState || this.editor.state
|
||||
}
|
||||
|
||||
get commands(): SingleCommands {
|
||||
const { rawCommands, editor, state } = this
|
||||
const { view } = editor
|
||||
const { tr } = state
|
||||
const props = this.buildProps(tr)
|
||||
|
||||
return Object.fromEntries(
|
||||
Object.entries(rawCommands).map(([name, command]) => {
|
||||
const method = (...args: any[]) => {
|
||||
const callback = command(...args)(props)
|
||||
|
||||
if (!tr.getMeta('preventDispatch') && !this.hasCustomState) {
|
||||
view.dispatch(tr)
|
||||
}
|
||||
|
||||
return callback
|
||||
}
|
||||
|
||||
return [name, method]
|
||||
}),
|
||||
) as unknown as SingleCommands
|
||||
}
|
||||
|
||||
get chain(): () => ChainedCommands {
|
||||
return () => this.createChain()
|
||||
}
|
||||
|
||||
get can(): () => CanCommands {
|
||||
return () => this.createCan()
|
||||
}
|
||||
|
||||
public createChain(startTr?: Transaction, shouldDispatch = true): ChainedCommands {
|
||||
const { rawCommands, editor, state } = this
|
||||
const { view } = editor
|
||||
const callbacks: boolean[] = []
|
||||
const hasStartTransaction = !!startTr
|
||||
const tr = startTr || state.tr
|
||||
|
||||
const run = () => {
|
||||
if (!hasStartTransaction && shouldDispatch && !tr.getMeta('preventDispatch') && !this.hasCustomState) {
|
||||
view.dispatch(tr)
|
||||
}
|
||||
|
||||
return callbacks.every(callback => callback === true)
|
||||
}
|
||||
|
||||
const chain = {
|
||||
...Object.fromEntries(
|
||||
Object.entries(rawCommands).map(([name, command]) => {
|
||||
const chainedCommand = (...args: never[]) => {
|
||||
const props = this.buildProps(tr, shouldDispatch)
|
||||
const callback = command(...args)(props)
|
||||
|
||||
callbacks.push(callback)
|
||||
|
||||
return chain
|
||||
}
|
||||
|
||||
return [name, chainedCommand]
|
||||
}),
|
||||
),
|
||||
run,
|
||||
} as unknown as ChainedCommands
|
||||
|
||||
return chain
|
||||
}
|
||||
|
||||
public createCan(startTr?: Transaction): CanCommands {
|
||||
const { rawCommands, state } = this
|
||||
const dispatch = false
|
||||
const tr = startTr || state.tr
|
||||
const props = this.buildProps(tr, dispatch)
|
||||
const formattedCommands = Object.fromEntries(
|
||||
Object.entries(rawCommands).map(([name, command]) => {
|
||||
return [name, (...args: never[]) => command(...args)({ ...props, dispatch: undefined })]
|
||||
}),
|
||||
) as unknown as SingleCommands
|
||||
|
||||
return {
|
||||
...formattedCommands,
|
||||
chain: () => this.createChain(tr, dispatch),
|
||||
} as CanCommands
|
||||
}
|
||||
|
||||
public buildProps(tr: Transaction, shouldDispatch = true): CommandProps {
|
||||
const { rawCommands, editor, state } = this
|
||||
const { view } = editor
|
||||
|
||||
const props: CommandProps = {
|
||||
tr,
|
||||
editor,
|
||||
view,
|
||||
state: createChainableState({
|
||||
state,
|
||||
transaction: tr,
|
||||
}),
|
||||
dispatch: shouldDispatch ? () => undefined : undefined,
|
||||
chain: () => this.createChain(tr, shouldDispatch),
|
||||
can: () => this.createCan(tr),
|
||||
get commands() {
|
||||
return Object.fromEntries(
|
||||
Object.entries(rawCommands).map(([name, command]) => {
|
||||
return [name, (...args: never[]) => command(...args)(props)]
|
||||
}),
|
||||
) as unknown as SingleCommands
|
||||
},
|
||||
}
|
||||
|
||||
return props
|
||||
}
|
||||
}
|
||||
+801
@@ -0,0 +1,801 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-object-type */
|
||||
import type { MarkType, Node as ProseMirrorNode, NodeType, Schema } from '@tiptap/pm/model'
|
||||
import type { Plugin, PluginKey, Transaction } from '@tiptap/pm/state'
|
||||
import { EditorState } from '@tiptap/pm/state'
|
||||
import { EditorView } from '@tiptap/pm/view'
|
||||
|
||||
import { CommandManager } from './CommandManager.js'
|
||||
import { EventEmitter } from './EventEmitter.js'
|
||||
import { ExtensionManager } from './ExtensionManager.js'
|
||||
import {
|
||||
ClipboardTextSerializer,
|
||||
Commands,
|
||||
Delete,
|
||||
Drop,
|
||||
Editable,
|
||||
FocusEvents,
|
||||
Keymap,
|
||||
Paste,
|
||||
Tabindex,
|
||||
TextDirection,
|
||||
} from './extensions/index.js'
|
||||
import { createDocument } from './helpers/createDocument.js'
|
||||
import { getAttributes } from './helpers/getAttributes.js'
|
||||
import { getHTMLFromFragment } from './helpers/getHTMLFromFragment.js'
|
||||
import { getText } from './helpers/getText.js'
|
||||
import { getTextSerializersFromSchema } from './helpers/getTextSerializersFromSchema.js'
|
||||
import { isActive } from './helpers/isActive.js'
|
||||
import { isNodeEmpty } from './helpers/isNodeEmpty.js'
|
||||
import { createMappablePosition, getUpdatedPosition } from './helpers/MappablePosition.js'
|
||||
import { resolveFocusPosition } from './helpers/resolveFocusPosition.js'
|
||||
import type { Storage } from './index.js'
|
||||
import { NodePos } from './NodePos.js'
|
||||
import { style } from './style.js'
|
||||
import type {
|
||||
CanCommands,
|
||||
ChainedCommands,
|
||||
DocumentType,
|
||||
EditorEvents,
|
||||
EditorOptions,
|
||||
NodeType as TNodeType,
|
||||
SingleCommands,
|
||||
TextSerializer,
|
||||
TextType as TTextType,
|
||||
Utils,
|
||||
} from './types.js'
|
||||
import { createStyleTag } from './utilities/createStyleTag.js'
|
||||
import { isFunction } from './utilities/isFunction.js'
|
||||
|
||||
export * as extensions from './extensions/index.js'
|
||||
|
||||
// @ts-ignore
|
||||
export interface TiptapEditorHTMLElement extends HTMLElement {
|
||||
editor?: Editor
|
||||
}
|
||||
|
||||
export class Editor extends EventEmitter<EditorEvents> {
|
||||
private commandManager!: CommandManager
|
||||
|
||||
public extensionManager!: ExtensionManager
|
||||
|
||||
private css: HTMLStyleElement | null = null
|
||||
|
||||
private className = 'tiptap'
|
||||
|
||||
public schema!: Schema
|
||||
|
||||
private editorView: EditorView | null = null
|
||||
|
||||
public isFocused = false
|
||||
|
||||
private editorState!: EditorState
|
||||
|
||||
/**
|
||||
* The editor is considered initialized after the `create` event has been emitted.
|
||||
*/
|
||||
public isInitialized = false
|
||||
|
||||
public extensionStorage: Storage = {} as Storage
|
||||
|
||||
/**
|
||||
* A unique ID for this editor instance.
|
||||
*/
|
||||
public instanceId = Math.random().toString(36).slice(2, 9)
|
||||
|
||||
public options: EditorOptions = {
|
||||
element: typeof document !== 'undefined' ? document.createElement('div') : null,
|
||||
content: '',
|
||||
injectCSS: true,
|
||||
injectNonce: undefined,
|
||||
extensions: [],
|
||||
autofocus: false,
|
||||
editable: true,
|
||||
textDirection: undefined,
|
||||
editorProps: {},
|
||||
parseOptions: {},
|
||||
coreExtensionOptions: {},
|
||||
enableInputRules: true,
|
||||
enablePasteRules: true,
|
||||
enableCoreExtensions: true,
|
||||
enableContentCheck: false,
|
||||
emitContentError: false,
|
||||
onBeforeCreate: () => null,
|
||||
onCreate: () => null,
|
||||
onMount: () => null,
|
||||
onUnmount: () => null,
|
||||
onUpdate: () => null,
|
||||
onSelectionUpdate: () => null,
|
||||
onTransaction: () => null,
|
||||
onFocus: () => null,
|
||||
onBlur: () => null,
|
||||
onDestroy: () => null,
|
||||
onContentError: ({ error }) => {
|
||||
throw error
|
||||
},
|
||||
onPaste: () => null,
|
||||
onDrop: () => null,
|
||||
onDelete: () => null,
|
||||
enableExtensionDispatchTransaction: true,
|
||||
}
|
||||
|
||||
constructor(options: Partial<EditorOptions> = {}) {
|
||||
super()
|
||||
this.setOptions(options)
|
||||
this.createExtensionManager()
|
||||
this.createCommandManager()
|
||||
this.createSchema()
|
||||
this.on('beforeCreate', this.options.onBeforeCreate)
|
||||
this.emit('beforeCreate', { editor: this })
|
||||
this.on('mount', this.options.onMount)
|
||||
this.on('unmount', this.options.onUnmount)
|
||||
this.on('contentError', this.options.onContentError)
|
||||
this.on('create', this.options.onCreate)
|
||||
this.on('update', this.options.onUpdate)
|
||||
this.on('selectionUpdate', this.options.onSelectionUpdate)
|
||||
this.on('transaction', this.options.onTransaction)
|
||||
this.on('focus', this.options.onFocus)
|
||||
this.on('blur', this.options.onBlur)
|
||||
this.on('destroy', this.options.onDestroy)
|
||||
this.on('drop', ({ event, slice, moved }) => this.options.onDrop(event, slice, moved))
|
||||
this.on('paste', ({ event, slice }) => this.options.onPaste(event, slice))
|
||||
this.on('delete', this.options.onDelete)
|
||||
|
||||
const initialDoc = this.createDoc()
|
||||
const selection = resolveFocusPosition(initialDoc, this.options.autofocus)
|
||||
|
||||
// Set editor state immediately, so that it's available independently from the view
|
||||
this.editorState = EditorState.create({
|
||||
doc: initialDoc,
|
||||
schema: this.schema,
|
||||
selection: selection || undefined,
|
||||
})
|
||||
|
||||
if (this.options.element) {
|
||||
this.mount(this.options.element)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach the editor to the DOM, creating a new editor view.
|
||||
*/
|
||||
public mount(el: NonNullable<EditorOptions['element']> & {}) {
|
||||
if (typeof document === 'undefined') {
|
||||
throw new Error(
|
||||
`[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.`,
|
||||
)
|
||||
}
|
||||
this.createView(el)
|
||||
this.emit('mount', { editor: this })
|
||||
|
||||
if (this.css && !document.head.contains(this.css)) {
|
||||
document.head.appendChild(this.css)
|
||||
}
|
||||
|
||||
window.setTimeout(() => {
|
||||
if (this.isDestroyed) {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.options.autofocus !== false && this.options.autofocus !== null) {
|
||||
this.commands.focus(this.options.autofocus)
|
||||
}
|
||||
this.emit('create', { editor: this })
|
||||
this.isInitialized = true
|
||||
}, 0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the editor from the DOM, but still allow remounting at a different point in time
|
||||
*/
|
||||
public unmount() {
|
||||
if (this.editorView) {
|
||||
// Cleanup our reference to prevent circular references which caused memory leaks
|
||||
// @ts-ignore
|
||||
const dom = this.editorView.dom as TiptapEditorHTMLElement
|
||||
|
||||
if (dom?.editor) {
|
||||
delete dom.editor
|
||||
}
|
||||
this.editorView.destroy()
|
||||
}
|
||||
this.editorView = null
|
||||
this.isInitialized = false
|
||||
|
||||
// Safely remove CSS element with fallback for test environments
|
||||
// Only remove CSS if no other editors exist in the document after unmount
|
||||
if (this.css && !document.querySelectorAll(`.${this.className}`).length) {
|
||||
try {
|
||||
if (typeof this.css.remove === 'function') {
|
||||
this.css.remove()
|
||||
} else if (this.css.parentNode) {
|
||||
this.css.parentNode.removeChild(this.css)
|
||||
}
|
||||
} catch (error) {
|
||||
// Silently handle any unexpected DOM removal errors in test environments
|
||||
console.warn('Failed to remove CSS element:', error)
|
||||
}
|
||||
}
|
||||
this.css = null
|
||||
this.emit('unmount', { editor: this })
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the editor storage.
|
||||
*/
|
||||
public get storage(): Storage {
|
||||
return this.extensionStorage
|
||||
}
|
||||
|
||||
/**
|
||||
* An object of all registered commands.
|
||||
*/
|
||||
public get commands(): SingleCommands {
|
||||
return this.commandManager.commands
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a command chain to call multiple commands at once.
|
||||
*/
|
||||
public chain(): ChainedCommands {
|
||||
return this.commandManager.chain()
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a command or a command chain can be executed. Without executing it.
|
||||
*/
|
||||
public can(): CanCommands {
|
||||
return this.commandManager.can()
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject CSS styles.
|
||||
*/
|
||||
private injectCSS(): void {
|
||||
if (this.options.injectCSS && typeof document !== 'undefined') {
|
||||
this.css = createStyleTag(style, this.options.injectNonce)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update editor options.
|
||||
*
|
||||
* @param options A list of options
|
||||
*/
|
||||
public setOptions(options: Partial<EditorOptions> = {}): void {
|
||||
this.options = {
|
||||
...this.options,
|
||||
...options,
|
||||
}
|
||||
|
||||
if (!this.editorView || !this.state || this.isDestroyed) {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.options.editorProps) {
|
||||
this.view.setProps(this.options.editorProps)
|
||||
}
|
||||
|
||||
this.view.updateState(this.state)
|
||||
}
|
||||
|
||||
/**
|
||||
* Update editable state of the editor.
|
||||
*/
|
||||
public setEditable(editable: boolean, emitUpdate = true): void {
|
||||
this.setOptions({ editable })
|
||||
|
||||
if (emitUpdate) {
|
||||
this.emit('update', { editor: this, transaction: this.state.tr, appendedTransactions: [] })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the editor is editable.
|
||||
*/
|
||||
public get isEditable(): boolean {
|
||||
// since plugins are applied after creating the view
|
||||
// `editable` is always `true` for one tick.
|
||||
// that’s why we also have to check for `options.editable`
|
||||
return this.options.editable && this.view && this.view.editable
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the editor state.
|
||||
*/
|
||||
public get view(): EditorView {
|
||||
if (this.editorView) {
|
||||
return this.editorView
|
||||
}
|
||||
|
||||
return new Proxy(
|
||||
{
|
||||
state: this.editorState,
|
||||
updateState: (state: EditorState): ReturnType<EditorView['updateState']> => {
|
||||
this.editorState = state
|
||||
},
|
||||
dispatch: (tr: Transaction): ReturnType<EditorView['dispatch']> => {
|
||||
this.dispatchTransaction(tr)
|
||||
},
|
||||
|
||||
// Stub some commonly accessed properties to prevent errors
|
||||
composing: false,
|
||||
dragging: null,
|
||||
editable: true,
|
||||
isDestroyed: false,
|
||||
} as EditorView,
|
||||
{
|
||||
get: (obj, key) => {
|
||||
if (this.editorView) {
|
||||
// If the editor view is available, but the caller has a stale reference to the proxy,
|
||||
// Just return what the editor view has.
|
||||
return this.editorView[key as keyof EditorView]
|
||||
}
|
||||
// Specifically always return the most recent editorState
|
||||
if (key === 'state') {
|
||||
return this.editorState
|
||||
}
|
||||
if (key in obj) {
|
||||
return Reflect.get(obj, key)
|
||||
}
|
||||
|
||||
// We throw an error here, because we know the view is not available
|
||||
throw new Error(
|
||||
`[tiptap error]: The editor view is not available. Cannot access view['${key as string}']. The editor may not be mounted yet.`,
|
||||
)
|
||||
},
|
||||
},
|
||||
) as EditorView
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the editor state.
|
||||
*/
|
||||
public get state(): EditorState {
|
||||
if (this.editorView) {
|
||||
this.editorState = this.view.state
|
||||
}
|
||||
|
||||
return this.editorState
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a ProseMirror plugin.
|
||||
*
|
||||
* @param plugin A ProseMirror plugin
|
||||
* @param handlePlugins Control how to merge the plugin into the existing plugins.
|
||||
* @returns The new editor state
|
||||
*/
|
||||
public registerPlugin(
|
||||
plugin: Plugin,
|
||||
handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[],
|
||||
): EditorState {
|
||||
const plugins = isFunction(handlePlugins)
|
||||
? handlePlugins(plugin, [...this.state.plugins])
|
||||
: [...this.state.plugins, plugin]
|
||||
|
||||
const state = this.state.reconfigure({ plugins })
|
||||
|
||||
this.view.updateState(state)
|
||||
|
||||
return state
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a ProseMirror plugin.
|
||||
*
|
||||
* @param nameOrPluginKeyToRemove The plugins name
|
||||
* @returns The new editor state or undefined if the editor is destroyed
|
||||
*/
|
||||
public unregisterPlugin(
|
||||
nameOrPluginKeyToRemove: string | PluginKey | (string | PluginKey)[],
|
||||
): EditorState | undefined {
|
||||
if (this.isDestroyed) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
const prevPlugins = this.state.plugins
|
||||
let plugins = prevPlugins
|
||||
|
||||
;([] as (string | PluginKey)[]).concat(nameOrPluginKeyToRemove).forEach(nameOrPluginKey => {
|
||||
// @ts-ignore
|
||||
const name = typeof nameOrPluginKey === 'string' ? `${nameOrPluginKey}$` : nameOrPluginKey.key
|
||||
|
||||
// @ts-ignore
|
||||
plugins = plugins.filter(plugin => !plugin.key.startsWith(name))
|
||||
})
|
||||
|
||||
if (prevPlugins.length === plugins.length) {
|
||||
// No plugin was removed, so we don’t need to update the state
|
||||
return undefined
|
||||
}
|
||||
|
||||
const state = this.state.reconfigure({
|
||||
plugins,
|
||||
})
|
||||
|
||||
this.view.updateState(state)
|
||||
|
||||
return state
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an extension manager.
|
||||
*/
|
||||
private createExtensionManager(): void {
|
||||
const coreExtensions = this.options.enableCoreExtensions
|
||||
? [
|
||||
Editable,
|
||||
ClipboardTextSerializer.configure({
|
||||
blockSeparator: this.options.coreExtensionOptions?.clipboardTextSerializer?.blockSeparator,
|
||||
}),
|
||||
Commands,
|
||||
FocusEvents,
|
||||
Keymap,
|
||||
Tabindex,
|
||||
Drop,
|
||||
Paste,
|
||||
Delete,
|
||||
TextDirection.configure({
|
||||
direction: this.options.textDirection,
|
||||
}),
|
||||
].filter(ext => {
|
||||
if (typeof this.options.enableCoreExtensions === 'object') {
|
||||
return (
|
||||
this.options.enableCoreExtensions[ext.name as keyof typeof this.options.enableCoreExtensions] !== false
|
||||
)
|
||||
}
|
||||
return true
|
||||
})
|
||||
: []
|
||||
const allExtensions = [...coreExtensions, ...this.options.extensions].filter(extension => {
|
||||
return ['extension', 'node', 'mark'].includes(extension?.type)
|
||||
})
|
||||
|
||||
this.extensionManager = new ExtensionManager(allExtensions, this)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an command manager.
|
||||
*/
|
||||
private createCommandManager(): void {
|
||||
this.commandManager = new CommandManager({
|
||||
editor: this,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a ProseMirror schema.
|
||||
*/
|
||||
private createSchema(): void {
|
||||
this.schema = this.extensionManager.schema
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the initial document.
|
||||
*/
|
||||
private createDoc(): ProseMirrorNode {
|
||||
let doc: ProseMirrorNode
|
||||
|
||||
try {
|
||||
doc = createDocument(this.options.content, this.schema, this.options.parseOptions, {
|
||||
errorOnInvalidContent: this.options.enableContentCheck,
|
||||
})
|
||||
} catch (e) {
|
||||
if (
|
||||
!(e instanceof Error) ||
|
||||
!['[tiptap error]: Invalid JSON content', '[tiptap error]: Invalid HTML content'].includes(e.message)
|
||||
) {
|
||||
// Not the content error we were expecting
|
||||
throw e
|
||||
}
|
||||
this.emit('contentError', {
|
||||
editor: this,
|
||||
error: e as Error,
|
||||
disableCollaboration: () => {
|
||||
if (
|
||||
'collaboration' in this.storage &&
|
||||
typeof this.storage.collaboration === 'object' &&
|
||||
this.storage.collaboration
|
||||
) {
|
||||
;(this.storage.collaboration as any).isDisabled = true
|
||||
}
|
||||
// To avoid syncing back invalid content, reinitialize the extensions without the collaboration extension
|
||||
this.options.extensions = this.options.extensions.filter(extension => extension.name !== 'collaboration')
|
||||
|
||||
// Restart the initialization process by recreating the extension manager with the new set of extensions
|
||||
this.createExtensionManager()
|
||||
},
|
||||
})
|
||||
|
||||
// Content is invalid, but attempt to create it anyway, stripping out the invalid parts
|
||||
doc = createDocument(this.options.content, this.schema, this.options.parseOptions, {
|
||||
errorOnInvalidContent: false,
|
||||
})
|
||||
}
|
||||
return doc
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a ProseMirror view.
|
||||
*/
|
||||
private createView(element: NonNullable<EditorOptions['element']>): void {
|
||||
const { editorProps, enableExtensionDispatchTransaction } = this.options
|
||||
// If a user provided a custom `dispatchTransaction` through `editorProps`,
|
||||
// we use that as the base dispatch function.
|
||||
// Otherwise, we use Tiptap's internal `dispatchTransaction` method.
|
||||
const baseDispatch = (editorProps as any).dispatchTransaction || this.dispatchTransaction.bind(this)
|
||||
const dispatch = enableExtensionDispatchTransaction
|
||||
? this.extensionManager.dispatchTransaction(baseDispatch)
|
||||
: baseDispatch
|
||||
|
||||
this.editorView = new EditorView(element, {
|
||||
...editorProps,
|
||||
attributes: {
|
||||
// add `role="textbox"` to the editor element
|
||||
role: 'textbox',
|
||||
...editorProps?.attributes,
|
||||
},
|
||||
dispatchTransaction: dispatch,
|
||||
state: this.editorState,
|
||||
markViews: this.extensionManager.markViews,
|
||||
nodeViews: this.extensionManager.nodeViews,
|
||||
})
|
||||
|
||||
// `editor.view` is not yet available at this time.
|
||||
// Therefore we will add all plugins and node views directly afterwards.
|
||||
const newState = this.state.reconfigure({
|
||||
plugins: this.extensionManager.plugins,
|
||||
})
|
||||
|
||||
this.view.updateState(newState)
|
||||
|
||||
this.prependClass()
|
||||
this.injectCSS()
|
||||
|
||||
// Let’s store the editor instance in the DOM element.
|
||||
// So we’ll have access to it for tests.
|
||||
// @ts-ignore
|
||||
const dom = this.view.dom as TiptapEditorHTMLElement
|
||||
|
||||
dom.editor = this
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates all node and mark views.
|
||||
*/
|
||||
public createNodeViews(): void {
|
||||
if (this.view.isDestroyed) {
|
||||
return
|
||||
}
|
||||
|
||||
this.view.setProps({
|
||||
markViews: this.extensionManager.markViews,
|
||||
nodeViews: this.extensionManager.nodeViews,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepend class name to element.
|
||||
*/
|
||||
public prependClass(): void {
|
||||
this.view.dom.className = `${this.className} ${this.view.dom.className}`
|
||||
}
|
||||
|
||||
public isCapturingTransaction = false
|
||||
|
||||
private capturedTransaction: Transaction | null = null
|
||||
|
||||
public captureTransaction(fn: () => void) {
|
||||
this.isCapturingTransaction = true
|
||||
fn()
|
||||
this.isCapturingTransaction = false
|
||||
|
||||
const tr = this.capturedTransaction
|
||||
|
||||
this.capturedTransaction = null
|
||||
|
||||
return tr
|
||||
}
|
||||
|
||||
/**
|
||||
* The callback over which to send transactions (state updates) produced by the view.
|
||||
*
|
||||
* @param transaction An editor state transaction
|
||||
*/
|
||||
private dispatchTransaction(transaction: Transaction): void {
|
||||
// if the editor / the view of the editor was destroyed
|
||||
// the transaction should not be dispatched as there is no view anymore.
|
||||
if (this.view.isDestroyed) {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.isCapturingTransaction) {
|
||||
if (!this.capturedTransaction) {
|
||||
this.capturedTransaction = transaction
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
transaction.steps.forEach(step => this.capturedTransaction?.step(step))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Apply transaction and get resulting state and transactions
|
||||
const { state, transactions } = this.state.applyTransaction(transaction)
|
||||
const selectionHasChanged = !this.state.selection.eq(state.selection)
|
||||
const rootTrWasApplied = transactions.includes(transaction)
|
||||
const prevState = this.state
|
||||
|
||||
this.emit('beforeTransaction', {
|
||||
editor: this,
|
||||
transaction,
|
||||
nextState: state,
|
||||
})
|
||||
|
||||
// If transaction was filtered out, we can return early
|
||||
if (!rootTrWasApplied) {
|
||||
return
|
||||
}
|
||||
|
||||
this.view.updateState(state)
|
||||
|
||||
// Emit transaction event with appended transactions info
|
||||
this.emit('transaction', {
|
||||
editor: this,
|
||||
transaction,
|
||||
appendedTransactions: transactions.slice(1),
|
||||
})
|
||||
|
||||
if (selectionHasChanged) {
|
||||
this.emit('selectionUpdate', {
|
||||
editor: this,
|
||||
transaction,
|
||||
})
|
||||
}
|
||||
|
||||
// Only emit the latest between focus and blur events
|
||||
const mostRecentFocusTr = transactions.findLast(tr => tr.getMeta('focus') || tr.getMeta('blur'))
|
||||
const focus = mostRecentFocusTr?.getMeta('focus')
|
||||
const blur = mostRecentFocusTr?.getMeta('blur')
|
||||
|
||||
if (focus) {
|
||||
this.emit('focus', {
|
||||
editor: this,
|
||||
event: focus.event,
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
transaction: mostRecentFocusTr!,
|
||||
})
|
||||
}
|
||||
|
||||
if (blur) {
|
||||
this.emit('blur', {
|
||||
editor: this,
|
||||
event: blur.event,
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
transaction: mostRecentFocusTr!,
|
||||
})
|
||||
}
|
||||
|
||||
// Compare states for update event
|
||||
if (
|
||||
transaction.getMeta('preventUpdate') ||
|
||||
!transactions.some(tr => tr.docChanged) ||
|
||||
prevState.doc.eq(state.doc)
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
this.emit('update', {
|
||||
editor: this,
|
||||
transaction,
|
||||
appendedTransactions: transactions.slice(1),
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attributes of the currently selected node or mark.
|
||||
*/
|
||||
public getAttributes(nameOrType: string | NodeType | MarkType): Record<string, any> {
|
||||
return getAttributes(this.state, nameOrType)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the currently selected node or mark is active.
|
||||
*
|
||||
* @param name Name of the node or mark
|
||||
* @param attributes Attributes of the node or mark
|
||||
*/
|
||||
public isActive(name: string, attributes?: {}): boolean
|
||||
public isActive(attributes: {}): boolean
|
||||
public isActive(nameOrAttributes: string, attributesOrUndefined?: {}): boolean {
|
||||
const name = typeof nameOrAttributes === 'string' ? nameOrAttributes : null
|
||||
|
||||
const attributes = typeof nameOrAttributes === 'string' ? attributesOrUndefined : nameOrAttributes
|
||||
|
||||
return isActive(this.state, name, attributes)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the document as JSON.
|
||||
*/
|
||||
public getJSON(): DocumentType<
|
||||
Record<string, any> | undefined,
|
||||
TNodeType<string, undefined | Record<string, any>, any, (TNodeType | TTextType)[]>[]
|
||||
> {
|
||||
return this.state.doc.toJSON()
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the document as HTML.
|
||||
*/
|
||||
public getHTML(): string {
|
||||
return getHTMLFromFragment(this.state.doc.content, this.schema)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the document as text.
|
||||
*/
|
||||
public getText(options?: { blockSeparator?: string; textSerializers?: Record<string, TextSerializer> }): string {
|
||||
const { blockSeparator = '\n\n', textSerializers = {} } = options || {}
|
||||
|
||||
return getText(this.state.doc, {
|
||||
blockSeparator,
|
||||
textSerializers: {
|
||||
...getTextSerializersFromSchema(this.schema),
|
||||
...textSerializers,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there is no content.
|
||||
*/
|
||||
public get isEmpty(): boolean {
|
||||
return isNodeEmpty(this.state.doc)
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the editor.
|
||||
*/
|
||||
public destroy(): void {
|
||||
this.emit('destroy')
|
||||
|
||||
this.unmount()
|
||||
|
||||
this.removeAllListeners()
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the editor is already destroyed.
|
||||
*/
|
||||
public get isDestroyed(): boolean {
|
||||
return this.editorView?.isDestroyed ?? true
|
||||
}
|
||||
|
||||
public $node(selector: string, attributes?: { [key: string]: any }): NodePos | null {
|
||||
return this.$doc?.querySelector(selector, attributes) || null
|
||||
}
|
||||
|
||||
public $nodes(selector: string, attributes?: { [key: string]: any }): NodePos[] | null {
|
||||
return this.$doc?.querySelectorAll(selector, attributes) || null
|
||||
}
|
||||
|
||||
public $pos(pos: number) {
|
||||
const $pos = this.state.doc.resolve(pos)
|
||||
|
||||
return new NodePos($pos, this)
|
||||
}
|
||||
|
||||
get $doc() {
|
||||
return this.$pos(0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of utilities for working with positions and ranges.
|
||||
*/
|
||||
public utils: Utils = {
|
||||
getUpdatedPosition,
|
||||
createMappablePosition,
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
type StringKeyOf<T> = Extract<keyof T, string>
|
||||
type CallbackType<T extends Record<string, any>, EventName extends StringKeyOf<T>> = T[EventName] extends any[]
|
||||
? T[EventName]
|
||||
: [T[EventName]]
|
||||
type CallbackFunction<T extends Record<string, any>, EventName extends StringKeyOf<T>> = (
|
||||
...props: CallbackType<T, EventName>
|
||||
) => any
|
||||
|
||||
export class EventEmitter<T extends Record<string, any>> {
|
||||
private callbacks: { [key: string]: Array<(...args: any[]) => void> } = {}
|
||||
|
||||
public on<EventName extends StringKeyOf<T>>(event: EventName, fn: CallbackFunction<T, EventName>): this {
|
||||
if (!this.callbacks[event]) {
|
||||
this.callbacks[event] = []
|
||||
}
|
||||
|
||||
this.callbacks[event].push(fn)
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
public emit<EventName extends StringKeyOf<T>>(event: EventName, ...args: CallbackType<T, EventName>): this {
|
||||
const callbacks = this.callbacks[event]
|
||||
|
||||
if (callbacks) {
|
||||
callbacks.forEach(callback => callback.apply(this, args))
|
||||
}
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
public off<EventName extends StringKeyOf<T>>(event: EventName, fn?: CallbackFunction<T, EventName>): this {
|
||||
const callbacks = this.callbacks[event]
|
||||
|
||||
if (callbacks) {
|
||||
if (fn) {
|
||||
this.callbacks[event] = callbacks.filter(callback => callback !== fn)
|
||||
} else {
|
||||
delete this.callbacks[event]
|
||||
}
|
||||
}
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
public once<EventName extends StringKeyOf<T>>(event: EventName, fn: CallbackFunction<T, EventName>): this {
|
||||
const onceFn = (...args: CallbackType<T, EventName>) => {
|
||||
this.off(event, onceFn)
|
||||
fn.apply(this, args)
|
||||
}
|
||||
|
||||
return this.on(event, onceFn)
|
||||
}
|
||||
|
||||
public removeAllListeners(): void {
|
||||
this.callbacks = {}
|
||||
}
|
||||
}
|
||||
+556
@@ -0,0 +1,556 @@
|
||||
import type { Plugin } from '@tiptap/pm/state'
|
||||
|
||||
import type { Editor } from './Editor.js'
|
||||
import { getExtensionField } from './helpers/getExtensionField.js'
|
||||
import type { ExtensionConfig, MarkConfig, NodeConfig } from './index.js'
|
||||
import type { InputRule } from './InputRule.js'
|
||||
import type { Mark } from './Mark.js'
|
||||
import type { Node } from './Node.js'
|
||||
import type { PasteRule } from './PasteRule.js'
|
||||
import type {
|
||||
AnyConfig,
|
||||
DispatchTransactionProps,
|
||||
EditorEvents,
|
||||
Extensions,
|
||||
GlobalAttributes,
|
||||
JSONContent,
|
||||
KeyboardShortcutCommand,
|
||||
MarkdownParseHelpers,
|
||||
MarkdownParseResult,
|
||||
MarkdownRendererHelpers,
|
||||
MarkdownToken,
|
||||
MarkdownTokenizer,
|
||||
ParentConfig,
|
||||
RawCommands,
|
||||
RenderContext,
|
||||
} from './types.js'
|
||||
import { callOrReturn } from './utilities/callOrReturn.js'
|
||||
import { mergeDeep } from './utilities/mergeDeep.js'
|
||||
|
||||
export interface ExtendableConfig<
|
||||
Options = any,
|
||||
Storage = any,
|
||||
Config extends
|
||||
| ExtensionConfig<Options, Storage>
|
||||
| NodeConfig<Options, Storage>
|
||||
| MarkConfig<Options, Storage>
|
||||
| ExtendableConfig<Options, Storage> = ExtendableConfig<Options, Storage, any, any>,
|
||||
PMType = any,
|
||||
> {
|
||||
/**
|
||||
* The extension name - this must be unique.
|
||||
* It will be used to identify the extension.
|
||||
*
|
||||
* @example 'myExtension'
|
||||
*/
|
||||
name: string
|
||||
|
||||
/**
|
||||
* The priority of your extension. The higher, the earlier it will be called
|
||||
* and will take precedence over other extensions with a lower priority.
|
||||
* @default 100
|
||||
* @example 101
|
||||
*/
|
||||
priority?: number
|
||||
|
||||
/**
|
||||
* This method will add options to this extension
|
||||
* @see https://tiptap.dev/docs/editor/guide/custom-extensions#settings
|
||||
* @example
|
||||
* addOptions() {
|
||||
* return {
|
||||
* myOption: 'foo',
|
||||
* myOtherOption: 10,
|
||||
* }
|
||||
*/
|
||||
addOptions?: (this: { name: string; parent: ParentConfig<Config>['addOptions'] }) => Options
|
||||
|
||||
/**
|
||||
* The default storage this extension can save data to.
|
||||
* @see https://tiptap.dev/docs/editor/guide/custom-extensions#storage
|
||||
* @example
|
||||
* defaultStorage: {
|
||||
* prefetchedUsers: [],
|
||||
* loading: false,
|
||||
* }
|
||||
*/
|
||||
addStorage?: (this: { name: string; options: Options; parent: ParentConfig<Config>['addStorage'] }) => Storage
|
||||
|
||||
/**
|
||||
* This function adds globalAttributes to specific nodes.
|
||||
* @see https://tiptap.dev/docs/editor/guide/custom-extensions#global-attributes
|
||||
* @example
|
||||
* addGlobalAttributes() {
|
||||
* return [
|
||||
* {
|
||||
// Extend the following extensions
|
||||
* types: [
|
||||
* 'heading',
|
||||
* 'paragraph',
|
||||
* ],
|
||||
* // … with those attributes
|
||||
* attributes: {
|
||||
* textAlign: {
|
||||
* default: 'left',
|
||||
* renderHTML: attributes => ({
|
||||
* style: `text-align: ${attributes.textAlign}`,
|
||||
* }),
|
||||
* parseHTML: element => element.style.textAlign || 'left',
|
||||
* },
|
||||
* },
|
||||
* },
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
addGlobalAttributes?: (this: {
|
||||
name: string
|
||||
options: Options
|
||||
storage: Storage
|
||||
extensions: (Node | Mark)[]
|
||||
parent: ParentConfig<Config>['addGlobalAttributes']
|
||||
}) => GlobalAttributes
|
||||
|
||||
/**
|
||||
* This function adds commands to the editor
|
||||
* @see https://tiptap.dev/docs/editor/guide/custom-extensions#commands
|
||||
* @example
|
||||
* addCommands() {
|
||||
* return {
|
||||
* myCommand: () => ({ chain }) => chain().setMark('type', 'foo').run(),
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
addCommands?: (this: {
|
||||
name: string
|
||||
options: Options
|
||||
storage: Storage
|
||||
editor: Editor
|
||||
type: PMType
|
||||
parent: ParentConfig<Config>['addCommands']
|
||||
}) => Partial<RawCommands>
|
||||
|
||||
/**
|
||||
* This function registers keyboard shortcuts.
|
||||
* @see https://tiptap.dev/docs/editor/guide/custom-extensions#keyboard-shortcuts
|
||||
* @example
|
||||
* addKeyboardShortcuts() {
|
||||
* return {
|
||||
* 'Mod-l': () => this.editor.commands.toggleBulletList(),
|
||||
* }
|
||||
* },
|
||||
*/
|
||||
addKeyboardShortcuts?: (this: {
|
||||
name: string
|
||||
options: Options
|
||||
storage: Storage
|
||||
editor: Editor
|
||||
type: PMType
|
||||
parent: ParentConfig<Config>['addKeyboardShortcuts']
|
||||
}) => {
|
||||
[key: string]: KeyboardShortcutCommand
|
||||
}
|
||||
|
||||
/**
|
||||
* This function adds input rules to the editor.
|
||||
* @see https://tiptap.dev/docs/editor/guide/custom-extensions#input-rules
|
||||
* @example
|
||||
* addInputRules() {
|
||||
* return [
|
||||
* markInputRule({
|
||||
* find: inputRegex,
|
||||
* type: this.type,
|
||||
* }),
|
||||
* ]
|
||||
* },
|
||||
*/
|
||||
addInputRules?: (this: {
|
||||
name: string
|
||||
options: Options
|
||||
storage: Storage
|
||||
editor: Editor
|
||||
type: PMType
|
||||
parent: ParentConfig<Config>['addInputRules']
|
||||
}) => InputRule[]
|
||||
|
||||
/**
|
||||
* This function adds paste rules to the editor.
|
||||
* @see https://tiptap.dev/docs/editor/guide/custom-extensions#paste-rules
|
||||
* @example
|
||||
* addPasteRules() {
|
||||
* return [
|
||||
* markPasteRule({
|
||||
* find: pasteRegex,
|
||||
* type: this.type,
|
||||
* }),
|
||||
* ]
|
||||
* },
|
||||
*/
|
||||
addPasteRules?: (this: {
|
||||
name: string
|
||||
options: Options
|
||||
storage: Storage
|
||||
editor: Editor
|
||||
type: PMType
|
||||
parent: ParentConfig<Config>['addPasteRules']
|
||||
}) => PasteRule[]
|
||||
|
||||
/**
|
||||
* This function adds Prosemirror plugins to the editor
|
||||
* @see https://tiptap.dev/docs/editor/guide/custom-extensions#prosemirror-plugins
|
||||
* @example
|
||||
* addProseMirrorPlugins() {
|
||||
* return [
|
||||
* customPlugin(),
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
addProseMirrorPlugins?: (this: {
|
||||
name: string
|
||||
options: Options
|
||||
storage: Storage
|
||||
editor: Editor
|
||||
type: PMType
|
||||
parent: ParentConfig<Config>['addProseMirrorPlugins']
|
||||
}) => Plugin[]
|
||||
|
||||
/**
|
||||
* This function adds additional extensions to the editor. This is useful for
|
||||
* building extension kits.
|
||||
* @example
|
||||
* addExtensions() {
|
||||
* return [
|
||||
* BulletList,
|
||||
* OrderedList,
|
||||
* ListItem
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
addExtensions?: (this: {
|
||||
name: string
|
||||
options: Options
|
||||
storage: Storage
|
||||
parent: ParentConfig<Config>['addExtensions']
|
||||
}) => Extensions
|
||||
|
||||
/**
|
||||
* The markdown token name
|
||||
*
|
||||
* This is the name of the token that this extension uses to parse and render markdown and comes from the Marked Lexer.
|
||||
*
|
||||
* @see https://github.com/markedjs/marked/blob/master/src/Tokens.ts
|
||||
*
|
||||
*/
|
||||
markdownTokenName?: string
|
||||
|
||||
/**
|
||||
* The parse function used by the markdown parser to convert markdown tokens to ProseMirror nodes.
|
||||
*/
|
||||
parseMarkdown?: (token: MarkdownToken, helpers: MarkdownParseHelpers) => MarkdownParseResult
|
||||
|
||||
/**
|
||||
* The serializer function used by the markdown serializer to convert ProseMirror nodes to markdown tokens.
|
||||
*/
|
||||
renderMarkdown?: (node: JSONContent, helpers: MarkdownRendererHelpers, ctx: RenderContext) => string
|
||||
|
||||
/**
|
||||
* The markdown tokenizer responsible for turning a markdown string into tokens
|
||||
*
|
||||
* Custom tokenizers are only needed when you want to parse non-standard markdown token.
|
||||
*/
|
||||
markdownTokenizer?: MarkdownTokenizer
|
||||
|
||||
/**
|
||||
* Optional markdown options for indentation
|
||||
*/
|
||||
markdownOptions?: {
|
||||
/**
|
||||
* Defines if this markdown element should indent it's child elements
|
||||
*/
|
||||
indentsContent?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* This function extends the schema of the node.
|
||||
* @example
|
||||
* extendNodeSchema() {
|
||||
* return {
|
||||
* group: 'inline',
|
||||
* selectable: false,
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
extendNodeSchema?:
|
||||
| ((
|
||||
this: {
|
||||
name: string
|
||||
options: Options
|
||||
storage: Storage
|
||||
parent: ParentConfig<Config>['extendNodeSchema']
|
||||
},
|
||||
extension: Node,
|
||||
) => Record<string, any>)
|
||||
| null
|
||||
|
||||
/**
|
||||
* This function extends the schema of the mark.
|
||||
* @example
|
||||
* extendMarkSchema() {
|
||||
* return {
|
||||
* group: 'inline',
|
||||
* selectable: false,
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
extendMarkSchema?:
|
||||
| ((
|
||||
this: {
|
||||
name: string
|
||||
options: Options
|
||||
storage: Storage
|
||||
parent: ParentConfig<Config>['extendMarkSchema']
|
||||
},
|
||||
extension: Mark,
|
||||
) => Record<string, any>)
|
||||
| null
|
||||
|
||||
/**
|
||||
* The editor is not ready yet.
|
||||
*/
|
||||
onBeforeCreate?:
|
||||
| ((
|
||||
this: {
|
||||
name: string
|
||||
options: Options
|
||||
storage: Storage
|
||||
editor: Editor
|
||||
type: PMType
|
||||
parent: ParentConfig<Config>['onBeforeCreate']
|
||||
},
|
||||
event: EditorEvents['beforeCreate'],
|
||||
) => void)
|
||||
| null
|
||||
|
||||
/**
|
||||
* The editor is ready.
|
||||
*/
|
||||
onCreate?:
|
||||
| ((
|
||||
this: {
|
||||
name: string
|
||||
options: Options
|
||||
storage: Storage
|
||||
editor: Editor
|
||||
type: PMType
|
||||
parent: ParentConfig<Config>['onCreate']
|
||||
},
|
||||
event: EditorEvents['create'],
|
||||
) => void)
|
||||
| null
|
||||
|
||||
/**
|
||||
* The content has changed.
|
||||
*/
|
||||
onUpdate?:
|
||||
| ((
|
||||
this: {
|
||||
name: string
|
||||
options: Options
|
||||
storage: Storage
|
||||
editor: Editor
|
||||
type: PMType
|
||||
parent: ParentConfig<Config>['onUpdate']
|
||||
},
|
||||
event: EditorEvents['update'],
|
||||
) => void)
|
||||
| null
|
||||
|
||||
/**
|
||||
* The selection has changed.
|
||||
*/
|
||||
onSelectionUpdate?:
|
||||
| ((
|
||||
this: {
|
||||
name: string
|
||||
options: Options
|
||||
storage: Storage
|
||||
editor: Editor
|
||||
type: PMType
|
||||
parent: ParentConfig<Config>['onSelectionUpdate']
|
||||
},
|
||||
event: EditorEvents['selectionUpdate'],
|
||||
) => void)
|
||||
| null
|
||||
|
||||
/**
|
||||
* The editor state has changed.
|
||||
*/
|
||||
onTransaction?:
|
||||
| ((
|
||||
this: {
|
||||
name: string
|
||||
options: Options
|
||||
storage: Storage
|
||||
editor: Editor
|
||||
type: PMType
|
||||
parent: ParentConfig<Config>['onTransaction']
|
||||
},
|
||||
event: EditorEvents['transaction'],
|
||||
) => void)
|
||||
| null
|
||||
|
||||
/**
|
||||
* The editor is focused.
|
||||
*/
|
||||
onFocus?:
|
||||
| ((
|
||||
this: {
|
||||
name: string
|
||||
options: Options
|
||||
storage: Storage
|
||||
editor: Editor
|
||||
type: PMType
|
||||
parent: ParentConfig<Config>['onFocus']
|
||||
},
|
||||
event: EditorEvents['focus'],
|
||||
) => void)
|
||||
| null
|
||||
|
||||
/**
|
||||
* The editor isn’t focused anymore.
|
||||
*/
|
||||
onBlur?:
|
||||
| ((
|
||||
this: {
|
||||
name: string
|
||||
options: Options
|
||||
storage: Storage
|
||||
editor: Editor
|
||||
type: PMType
|
||||
parent: ParentConfig<Config>['onBlur']
|
||||
},
|
||||
event: EditorEvents['blur'],
|
||||
) => void)
|
||||
| null
|
||||
|
||||
/**
|
||||
* The editor is destroyed.
|
||||
*/
|
||||
onDestroy?:
|
||||
| ((
|
||||
this: {
|
||||
name: string
|
||||
options: Options
|
||||
storage: Storage
|
||||
editor: Editor
|
||||
type: PMType
|
||||
parent: ParentConfig<Config>['onDestroy']
|
||||
},
|
||||
event: EditorEvents['destroy'],
|
||||
) => void)
|
||||
| null
|
||||
|
||||
/**
|
||||
* This hook allows you to intercept and modify transactions before they are dispatched.
|
||||
*
|
||||
* Example
|
||||
* ```ts
|
||||
* dispatchTransaction({ transaction, next }) {
|
||||
* console.log('Dispatching transaction:', transaction)
|
||||
* next(transaction)
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @param props - The dispatch transaction props
|
||||
*/
|
||||
dispatchTransaction?:
|
||||
| ((
|
||||
this: {
|
||||
name: string
|
||||
options: Options
|
||||
storage: Storage
|
||||
editor: Editor
|
||||
type: PMType
|
||||
parent: ParentConfig<Config>['dispatchTransaction']
|
||||
},
|
||||
props: DispatchTransactionProps,
|
||||
) => void)
|
||||
| null
|
||||
}
|
||||
|
||||
export class Extendable<
|
||||
Options = any,
|
||||
Storage = any,
|
||||
Config = ExtensionConfig<Options, Storage> | NodeConfig<Options, Storage> | MarkConfig<Options, Storage>,
|
||||
> {
|
||||
type = 'extendable'
|
||||
parent: Extendable | null = null
|
||||
|
||||
child: Extendable | null = null
|
||||
|
||||
name = ''
|
||||
|
||||
config: Config = {
|
||||
name: this.name,
|
||||
} as Config
|
||||
|
||||
constructor(config: Partial<Config> = {}) {
|
||||
this.config = {
|
||||
...this.config,
|
||||
...config,
|
||||
}
|
||||
|
||||
this.name = (this.config as any).name
|
||||
}
|
||||
|
||||
get options(): Options {
|
||||
return {
|
||||
...(callOrReturn(
|
||||
getExtensionField<AnyConfig['addOptions']>(this as any, 'addOptions', {
|
||||
name: this.name,
|
||||
}),
|
||||
) || {}),
|
||||
}
|
||||
}
|
||||
|
||||
get storage(): Readonly<Storage> {
|
||||
return {
|
||||
...(callOrReturn(
|
||||
getExtensionField<AnyConfig['addStorage']>(this as any, 'addStorage', {
|
||||
name: this.name,
|
||||
options: this.options,
|
||||
}),
|
||||
) || {}),
|
||||
}
|
||||
}
|
||||
|
||||
configure(options: Partial<Options> = {}) {
|
||||
const extension = this.extend<Options, Storage, Config>({
|
||||
...this.config,
|
||||
addOptions: () => {
|
||||
return mergeDeep(this.options as Record<string, any>, options) as Options
|
||||
},
|
||||
})
|
||||
|
||||
extension.name = this.name
|
||||
extension.parent = this.parent
|
||||
|
||||
return extension
|
||||
}
|
||||
|
||||
extend<
|
||||
ExtendedOptions = Options,
|
||||
ExtendedStorage = Storage,
|
||||
ExtendedConfig =
|
||||
| ExtensionConfig<ExtendedOptions, ExtendedStorage>
|
||||
| NodeConfig<ExtendedOptions, ExtendedStorage>
|
||||
| MarkConfig<ExtendedOptions, ExtendedStorage>,
|
||||
>(extendedConfig: Partial<ExtendedConfig> = {}): Extendable<ExtendedOptions, ExtendedStorage> {
|
||||
const extension = new (this.constructor as any)({ ...this.config, ...extendedConfig })
|
||||
|
||||
extension.parent = this
|
||||
this.child = extension
|
||||
extension.name = 'name' in extendedConfig ? extendedConfig.name : extension.parent.name
|
||||
|
||||
return extension
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
import type { Editor } from './Editor.js'
|
||||
import { type ExtendableConfig, Extendable } from './Extendable.js'
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
||||
export interface ExtensionConfig<Options = any, Storage = any>
|
||||
extends ExtendableConfig<Options, Storage, ExtensionConfig<Options, Storage>, null> {}
|
||||
|
||||
/**
|
||||
* The Extension class is the base class for all extensions.
|
||||
* @see https://tiptap.dev/api/extensions#create-a-new-extension
|
||||
*/
|
||||
export class Extension<Options = any, Storage = any> extends Extendable<
|
||||
Options,
|
||||
Storage,
|
||||
ExtensionConfig<Options, Storage>
|
||||
> {
|
||||
type = 'extension'
|
||||
|
||||
/**
|
||||
* Create a new Extension instance
|
||||
* @param config - Extension configuration object or a function that returns a configuration object
|
||||
*/
|
||||
static create<O = any, S = any>(
|
||||
config: Partial<ExtensionConfig<O, S>> | (() => Partial<ExtensionConfig<O, S>>) = {},
|
||||
) {
|
||||
// If the config is a function, execute it to get the configuration object
|
||||
const resolvedConfig = typeof config === 'function' ? config() : config
|
||||
return new Extension<O, S>(resolvedConfig)
|
||||
}
|
||||
|
||||
configure(options?: Partial<Options>) {
|
||||
return super.configure(options) as Extension<Options, Storage>
|
||||
}
|
||||
|
||||
extend<
|
||||
ExtendedOptions = Options,
|
||||
ExtendedStorage = Storage,
|
||||
ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage>,
|
||||
>(
|
||||
extendedConfig?:
|
||||
| (() => Partial<ExtendedConfig>)
|
||||
| (Partial<ExtendedConfig> &
|
||||
ThisType<{
|
||||
name: string
|
||||
options: ExtendedOptions
|
||||
storage: ExtendedStorage
|
||||
editor: Editor
|
||||
type: null
|
||||
}>),
|
||||
): Extension<ExtendedOptions, ExtendedStorage> {
|
||||
// If the extended config is a function, execute it to get the configuration object
|
||||
const resolvedConfig = typeof extendedConfig === 'function' ? extendedConfig() : extendedConfig
|
||||
return super.extend(resolvedConfig) as Extension<ExtendedOptions, ExtendedStorage>
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user