Comments (20)
Fyi, nextjs should work more straightforward as part of v0.5.1: https://github.com/TypeCellOS/BlockNote/releases/tag/v0.5.1. dynamic
is no longer needed
from blocknote.
Does this work for you?
DynamicBlockNote.tsx
:
import "@blocknote/core/style.css";
import { BlockNoteView, useBlockNote } from "@blocknote/react";
function Editor() {
const editor = useBlockNote({});
return <BlockNoteView editor={editor} />;
}
export default Editor;
index.tsx
(or any other next page)
// top of file
const BlockNote = dynamic(() => import("./DynamicBlockNote"), {
ssr: false,
});
...
// in your render() function:
<div style={{ width: "500px;height:300px;background:white" }}>
<BlockNote />
</div>
from blocknote.
I tried this. It doesn't solve the problem.
from blocknote.
This demo works for me: https://github.com/YousefED/blocknote-examples-nextjs/pull/1
Are you using NPM or a different package manager?
from blocknote.
Tried it on a brand new next app using create-next-app and was able to reproduce this error. Tried main repo and running the example and I am not getting the error. In the next app I have also disabled ssr on the page this is loading using dynamic still getting this error.
So looks like next specific error.
from blocknote.
packages/core/src/shared/utils.ts
packages/react/src/utils.ts
export const isAppleOS = () => {
// FIXME: Code causing issues in SSR
// /Mac/.test(navigator.platform) ||
// (/AppleWebKit/.test(navigator.userAgent) &&
// /Mobile\/\w+/.test(navigator.userAgent));
return false;
};
from blocknote.
Running into this error as well using Next.js 13 App Router. Will investigate!
from blocknote.
Update: Still stuck on this – looks like importing with next/dynamic
does remove the error but doesn't render the actual component. Here's my code:
"use client";
import dynamic from "next/dynamic";
const BlockNoteView = dynamic(
() => import("@blocknote/react").then((mod) => mod.BlockNoteView),
{
ssr: false,
}
);
const useBlockNote = dynamic(
() => import("@blocknote/react").then((mod) => mod.useBlockNote),
{
ssr: false,
}
);
import "@blocknote/core/style.css";
export default function Editor() {
const editor = useBlockNote({
onUpdate: ({ editor }) => {
console.log(editor.getJSON());
},
});
return <BlockNoteView editor={editor} />;
}
from blocknote.
Yeah same - dynamically importing from @blocknote/react
gave me an undefined value for useBlockNote
from blocknote.
Ooooh this 0.4.6-alpha.3
version worked!! Thank you!
from blocknote.
Next.js completely broken due to the navigator error. Any fix coming? @YousefED ?
from blocknote.
Next.js completely broken due to the navigator error. Any fix coming? @YousefED ?
Have you tried the version / demo above? Are you still encountering issues?
from blocknote.
I'm closing this issue as I think NextJS should be fixed as part of 0.4.6-alpha.3
and there's a working demo @ https://github.com/YousefED/blocknote-examples-nextjs
from blocknote.
Unfortunately, I have the same issue:
ReferenceError: navigator is not defined
BlockNode: 0.5.0
NextJs: 12.2.5
from blocknote.
@Kay2dan could you share a reproducible sandbox / repo?
from blocknote.
from blocknote.
I just installed 0.5.0 in combination with "next": "13.1.2",
and also getting this error.
from blocknote.
from blocknote.
I'm using node v16.14.2 (npm v8.5.0)
. I also tried the dynamic import fix you mentioned earlier and that seems to do the trick for now!
from blocknote.
0.5.1 fixed the issue completely for me (without dynamic imports). Thank you!
from blocknote.
Related Issues (20)
- How to create a custom codeblock function with tiptap in blocknote? HOT 1
- Using Custom DragHandleMenu and SideMenu at the same time but didn't show custom DragHandleMenu HOT 2
- `BlockNoteViewProps` type is not exported HOT 1
- Support for excluding any block HOT 1
- Paste the image directly and it will automatically upload
- Google Doc like comments HOT 3
- 🐛 blockIdentifier can be null
- How can I preserve the text appearance when I replace the selected text using HTML or Markdown?
- Feedback for “Parsing HTML to Blocks”
- render sidemenucontroller when editor editable field is set to false. HOT 1
- Issue with Persistent Placeholder in Liveblocks and BlockNote when Using Multiple Clients
- New placeholders option doesn't work with multiple editors HOT 1
- Can we use @blocknote in react native ? HOT 1
- Space Disappears in Custom Block with Inline Content(Firefox) HOT 1
- The hint text is not hidden during collaboration HOT 1
- Image block editable bug
- Text centering does not apply to list item
- How to disable sideMenu at top block (index 0)
- editor.getSelectedText() - Missing whitespace between selected text segments crossing blocks boundaries
- Change font size option in Formatting Toolbar HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blocknote.