Giter VIP home page Giter VIP logo

react-editor-js's People

Contributors

dependabot[bot] avatar jakekara avatar jungwoo-an avatar marianrick avatar semantic-release-bot avatar sqndr avatar vault-developer avatar vlzh avatar wxnet2013 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-editor-js's Issues

Support for SSR

Hello.

This module doesn't support server side rendering.
When building on Netlify or on local production, I get an error that says "'window' is not available during server side rendering", and a bunch of code that is returned from the EditorJS plugin(s).

This is how I currently fixed this:

const MyComponent = () => {
  if (typeof window !== 'undefined') {
    const Editor = require('./editor').default;

    return <Editor />;
  }

  return null;
};

Even though this works, it's very 'hacky'. Please fix this.

I'm using GatsbyJS version 2.23.12.

Not able to change css of react editor

Im not getting how to change the style of react editor . In the editor docs page they use classes in the divs but with react editor we only have a component. What is the best way to change the style of the component ?

Content data is not updating after rerendering

Hello There. I am building a text editor where user can save the content. I have successfully saved the contet in a server. But when I retireve it and update the state. Editor is successfully rerendering but the data change is not displayed.

getDataCallBack(res){
     //set set if data is not empty
     if( ! (res.data['emailJson'] === {}) ){
       // console.log(res.data['emailJson']);
       this.kidding = "Data is loaded";
       this.setState({
         data: {blocks:res.data['emailJson']}
       });
   
     }
   }

This is the call back function i use after the data has been fetched.

 componentDidMount() {
        getEmail(this.getDataCallBack);
}

This is the data fetching function

 render() {
      return (
          <div>
            <EditorJs
              instanceRef={instance => this.editorInstance = instance}
              tools={EDITOR_JS_TOOLS}
              data={this.state.data}
            />
            <Button style={{'background': 'blue', 'textAlign': 'center'}}  onClick={this.handleSave}>Save</Button>
        </div>
      );
    }

I am quite sure the rerender is happening because when i print value inside render to see the data. I can clearly see the data is updated and not the old value.
I don't know why in the rerender even though this.state.data is updated the content is not updated.

set a placeholder for each element

Hello!

Is it possible to pass a placeholder for a certain element? I saw your explanation here and I was able to set a default placeholder.

But what I mean is:

  1. I have header-level1 and a paragraph by default
    image

  2. I want this FIRST header-level1's placeholder to be "Title..." and this certain paragraph's to be "Your text..." for example
    something like this:
    image

Hope you got what I mean.
Thank you!

Infinite update on onChange

Hi,

I set enableReInitialize to true and in the onChange Method, I call the save method. It works fine at first, but as soon as I insert new data to 'data' props, it seems like the 'onChange' is triggered infinitely. Any way to break this loop?

<EditorJs instanceRef={(instance) => (editorInstance = instance)} onChange={() => handleSave(editorInstance)} data={editorData} enableReInitialize={true} tools={EDITOR_JS_TOOLS} />

const handleSave = async (instance) => { const savedData = await instance.save(); setData(savedData); };

The editorData is set to empty string at first, and later it has chances to update to new data when clicking one button, which means that I want the onChange only triggered when typing something in the editor field, and when the value of editorData is updated, the text in the editor is updated. Currently, whenever the editorData is updated, onChange is triggered like forever.

It would be so appreciated if you could offered any help.

Thanks.

Follow up:

I did a little bit debugging.
Screen Shot 2020-05-31 at 11 09 38 PM

I am not quite sure but I think it may be caused by timestamp changes.
The text in blocks[0].data.text is not changing, but as the timestamp keeps updating, the onChange is keep triggering. I am not sure if this is the issue, but if it is, is there any way to custom config onChange?

Link tool error.

Hello,

I have had everything set up with the editor, it was working well and then all of a sudden the link tool stopped working (I did not do any npm updates). I was wondering why it happened.
Updating packages helped with that by the way, but some console logs started appearing -
Editor.js 2.18.0 I18n: section "tools.linkTool" was not found in current dictionary %o
image

Keep in mind that I do have these tools included and they actually work - I can add images etc.

Is there way to set data attribute

I have a list UI scenario, where I would like to use this editor. However, I need a way to identify which instance of the editor was edited in the onChange event. Is there a way to achieve this?

Normally I use a data-index attribute on the DOM to identify which index in the state should I update.

inline Marker is not working

First of all, thank you for the react wrapper.

There is an issue with Marker @editorjs/marker simply it does not respond to highlight which is not expected (tested on both Chrome & Firefox latest versions).
The provided example have this issue as well.

Multiple EditorJs in the DOM

It seems I can only have one. I have virtual tabs where each of the sub-doms are hidden.

Only the first EditorJs shows.

package.json: `module` doesn't exist

The file mentioned in package.json's module property (./dist/react-editor-js.js) doesn't exist in the final bundle. I guess there's a .es missing in the filename?

window is not defined

When I try to use the editor I get a ReferenceError: window is not defined.

I follow your codebox example, but with no luck.

I use React with Next.js

Update Content Dynamically

I run into an infinite look when i hook into the onChange function and update the content using .blocks.render(). This behaviour is understandable,but is there anyway to update the content ?

Can't save state of EditorJS

I'm using React 16.13.1 and I can't seem to find a way to save the state.
I tried using useEffect for initialization but it didn't work. We need an update where there is a easy way to save the data with hooks.

readonly mode

Hey!

Your component is just amazing.
One thing I wanted to ask, is there a way to make the text read only?

I want to use the editor in a blog app, so that one user can write a post, but other people can just read it.

Thanks in advance!

It is possible to activate 'convert to' option in the inline block editor?

Hi! Im wondering if there is the possibility to activate the option to change block type once you have selected one.

For example, when you start writing and you select the text, the editor let you choose to change between Header and Paragraph, but once you select one of the options, this options doesn't appear anymore.

Hope these images can help to explain the question:

  1. When i write the text without selecting Header or Paragraph and mouseover:
    Captura de pantalla 2020-05-25 a las 10 54 56

  2. Once I select "Header" or "Paragraph", the convert to tool doesn't appear anymore:
    Captura de pantalla 2020-05-25 a las 10 55 05

Thanks for the good work!

Demo Different in browser and sandbox.

image

When I saw demo of react-editor-js in browser I saw the above image. It can clearly be seen that the section in which user clicks is highlighted and + icon is shown which allows addition of blocks.

But when I run the same demo in my browser then I when I click on any component the component is not highlighted and plus icon not showing. I am confused. Below you can see the image of when I click component in my browser.
image

Am I missing something?

I tried upgrading node. I am using javascript and not typescript.

editorInstance.render() gives error

When pulling saved data from my database this.editorInstance.render() gives an "cannot read property of map undefined". Would you have insight into this error?

Image Upload Error

When I try to drag and drop or Insert a URL, I don't face any issue. When I try to upload an image, i.e., when the upload image window appears, after the selection of the image, an error is shown, saying Couldn't upload Image. Try Again
Does anyone face the same issue? I observed this issue in the example SandBox too.

problem with updating the editor content

I have notes list and I have an editor and I'm trying to update the content of the editor depending on the user selection,
so if he selects the first note the editor will change the content to the first note and if the user selects the second one the content will change to second note content and goes on.
I faced two problems,
the first one if I set initial data and the user selects a note, the content never changes,
then I thought I must enable this option enableReInitialize but I got this error Uncaught (in promise) TypeError: _this.instance.destroy is not a function
so did I miss something?

this is my code
code

Embed Error

embed_error
The embed feature doesn't have any specific config, but I don't know why this is happening. I didn't have this issue previously. I don't know if this is a specific react editor issue or embed package issue. Can anyone recreate this error in their code? I uninstalled and installed the packages but of no use. The display is getting distorted. Is there any way to resolve this?

How can I set a placeholder?

I tried setting on instance but it didn't work. I tried passing as prop still no luck. Passing to instance and setting enableReInitialize to true also didnt work.

Problem with LinkInlineTool

By default in editor.js tool with name link is LinkInlineTool, but in this lib the tool link is LinkTool and i cant to use LinkInlineTool.

Where is the file data during request to server?

Good day guys,

I have a summary of my concern below

const EDITOR_JS_TOOLS = {
    image: {
        class: Image,
        config: {
            endpoints: {
                byFile: 'http://localhost:3001/api/uploads'
            },
            field: 'image',
            types: 'image/*'
        }
    }
}

const CommentEditor = () => {
    return <EditorJs tools={EDITOR_JS_TOOLS} />
}

When my react sends request to

router.post('/', async (req, res) => {
//when client use this endpoint, console.log can display a message
})

but where is the data?
I look it to req.body but empty

Thank you.

I am not able to store the data

I need to access the data when Save Button is pressed, but all the methods I tried to use are failing.
Cannot set property 'editorInstance' of undefined is the error I am getting when I try to access the Instance of EditorJS.
Can anyone who has done this, send their syntax and working?

editorInstance.save is not a function error occurs if other fields in the form are updated

Editor Component-

function Editor(props) {
  return (
    <EditorJs
      tools={EDITOR_JS_TOOLS}
      data={props.data}
      instanceRef={(instance) => props.handleInstance(instance)}
    />
  );
}

handeSave in different function-

const handleInstance = (instance) => {
    editorInstance = instance;
  };

  const handleSave = async () => {
    const value = { ...article };
    value["body"] = await editorInstance.save();
    console.log(value);
    // await saveArticle(value);
  };

Above implementation works if I only write in editor component. but if I change different fields of article form (like title, description, etc) which are not part of editor component then following error occurs-

image

Please tell me what is proper way of handling change event of editorjs and side effects.

Listening to events

Please could you provide an example of how to listen to changes in blocks via useEffect or any other method as I am having issues working out how to do this. Thanks

Allow removing of default tools

Thanks for making this great wrapper 🙌👌.

I used to work with editorjs and want to move it inside a reactjs app.

Doing this I have noticed a different behavior than the main lib. Currently it seems to be impossible to remove some of the default plugins.

As I only do offer custom plugins, it’s mandatory to disable the default ones.

To me it would be more convenient to disable them by default (except for paragraphs) as it’s done in the main lib and import/add only the necessary ones.

What’s your opinion about that? I could create a merge request with these changes, even if I am not absolutely sure how to achieve this.

readOnly mode

The library is great but i cant seem to find readOnly mode in documentation.
i want to display the data stored with proper styling without giving the reader access to toolbar or any edit options.
like 'view' only mode.

v2 using hooks

I wrote my own implementation of React container for Editor.js, and instead of creating separate package I'd like to volunteer my contributions and help here. Example use case would look like:

import { Editor, useEditorRef } from 'react-editor-js'

const MyComponent = ({ initialData }) => {
  const [ref, { save, loading /* etc. */ }] = useEditorRef()

  const onSave = useCallback(async () => {
    const values = await save()
    console.log(values)
  }, [])

  return (
    <Editor ref={ref} data={initialData} holder="editor-js" /* etc. */>
    { !loading && <button onClick={onSave}>Save</button> }
  )
}

Where useEditorRef is optional and can be replaced with standard useRef. That will allow you to access EditorJS instance with all standard methods at ref.current.

Does this sound like a good idea for this repo?

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.