tiptap-react.js 1012 B

12345678910111213141516171819202122
  1. // Wrapper around @tiptap/react that always sets `immediatelyRender`.
  2. //
  3. // On Next.js, `window.next` exists on the client, so @tiptap/react treats the
  4. // runtime as SSR and (if the option is omitted) creates the editor in useEffect.
  5. // We keep `false` on purpose: `true` races with TipTap's 1ms scheduleDestroy and
  6. // can null out `commandManager`.
  7. //
  8. // enriched-html hooks then see `editor === null` on the first client frame and
  9. // call `editor.on(...)`. Those hooks are wrapped by webpack shims in
  10. // next.config.js (not patch-package) so a clean Vercel install still works.
  11. //
  12. // Real module is aliased as '@tiptap-react-real' (see next.config.js).
  13. export * from '@tiptap-react-real';
  14. import { useEditor as realUseEditor } from '@tiptap-react-real';
  15. export function useEditor(options = {}, deps = []) {
  16. const opts =
  17. options && options.immediatelyRender !== undefined
  18. ? options
  19. : { ...(options || {}), immediatelyRender: false };
  20. return realUseEditor(opts, deps);
  21. }