share.tsx 813 B

123456789101112131415161718192021222324252627282930313233343536
  1. import './public-path';
  2. import { createRoot } from 'react-dom/client';
  3. import { start } from '../mastodon/common';
  4. import ComposeContainer from '../mastodon/containers/compose_container';
  5. import { loadPolyfills } from '../mastodon/polyfills';
  6. import ready from '../mastodon/ready';
  7. start();
  8. function loaded() {
  9. const mountNode = document.getElementById('mastodon-compose');
  10. if (mountNode) {
  11. const attr = mountNode.getAttribute('data-props');
  12. if (!attr) return;
  13. const props = JSON.parse(attr) as object;
  14. const root = createRoot(mountNode);
  15. root.render(<ComposeContainer {...props} />);
  16. }
  17. }
  18. function main() {
  19. ready(loaded).catch((error: unknown) => {
  20. console.error(error);
  21. });
  22. }
  23. loadPolyfills()
  24. .then(main)
  25. .catch((error: unknown) => {
  26. console.error(error);
  27. });