GithubHelp home page GithubHelp logo

Comments (5)

gohabereg avatar gohabereg commented on June 8, 2024 1

Hi,
According to the log, the code is running in the NodeJS environment where Element is not defined as well as other browser APIs.
EditorJS is a client library, so you need to set up your project to not run EditorJS code on the server.

Closing the issue as it is not an EditorJS bug

from editor.js.

fzsf163 avatar fzsf163 commented on June 8, 2024 1

@fzsf163 Could you share your solution?

yes sure.
the components that require to be rendered on client must be inside <ClientOnly/>, And if you have say a file named Component.tsx that has imports (like say editor js) that needs to be rendered on client, you simply name it Component.client.tsx, this *.client.tsx forces remix to render that components entirely on client side. To make it render only server side just change the *.client.tsx to *.server.tsx. Then when you call that component on any file and put that inside <ClientOnly>{ ()=> (<Component/>) }<ClientOnly/>. Install remix-utls to get client-only component.

Example :

Editor.client.tsx

import EditorJS from "@editorjs/editorjs";

export default function Editor() {
  const editor = new EditorJS({
    /**
     * Id of Element that should contain the Editor
     */
    holder: "editorjs",

    /**
     * Available Tools list.
     * Pass Tool's class or Settings object for each Tool you want to use
     */
  });
  return <div id="editorjs"></div>;
}

then I <Editor/> inside Blog-Page.tsx route

import { ClientOnly } from "remix-utils/client-only";
import Editor from "~/components/EditorJS.client"

  <ClientOnly fallback={<p>Loading Editor Please Wait...</p>}>
          {() => (
              <Editor></Editor> 
          )}
   </ClientOnly>

from editor.js.

fzsf163 avatar fzsf163 commented on June 8, 2024

Hi, According to the log, the code is running in the NodeJS environment where Element is not defined as well as other browser APIs. EditorJS is a client library, so you need to set up your project to not run EditorJS code on the server.

Closing the issue as it is not an EditorJS bug

thank you sir, I will look into it.

from editor.js.

fzsf163 avatar fzsf163 commented on June 8, 2024

I fixed it. Now it renders.

from editor.js.

jsgv avatar jsgv commented on June 8, 2024

@fzsf163 Could you share your solution?

from editor.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.