Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor toolbar not working ? #982

Open
phongyewtong opened this issue Jun 27, 2020 · 7 comments
Open

Editor toolbar not working ? #982

phongyewtong opened this issue Jun 27, 2020 · 7 comments

Comments

@phongyewtong
Copy link

phongyewtong commented Jun 27, 2020

The toolbar is not showing all the dropdown + the text field is also not showing even I include the css.


import React, { Component, Fragment } from 'react';
import { EditorState, ContentState, convertToRaw, convertFromHTML } from 'draft-js';
import { Editor } from 'react-draft-wysiwyg';
import '../../../node_modules/react-draft-wysiwyg/dist/react-draft-wysiwyg.css';
import draftToHtml from 'draftjs-to-html';
// import htmlToDraft from 'html-to-draftjs';

class DraftEditor extends Component {
  constructor(props) {
    super(props)
    this.state = {
      editorState: EditorState.createEmpty(),
    }
  }

  componentDidMount() {
    console.log(this.props.defaultValue)
    if (this.props.defaultValue) {
      this.setState({
        editorState: EditorState.createWithContent(
          ContentState.createFromBlockArray(
            convertFromHTML(this.props.defaultValue)
          )
        )
      })
    }
  }

  onEditorStateChange = (editorState) => {
    const html = draftToHtml(convertToRaw(editorState.getCurrentContent()))
    this.setState({ editorState: editorState }, () => {
      this.props.onEditorStateChange(html)
    });
  };

  render() {
    const { editorState } = this.state;
    return (
      <Fragment>
        <Editor
          editorState={editorState}
          // wrapperClassName="demo-wrapper"
          // editorClassName="demo-editor"
          toolbarClassName="toolbarClassName"
          wrapperClassName="wrapperClassName"
          editorClassName="editorClassName"
          onEditorStateChange={this.onEditorStateChange}
        />
        {/* <textarea
          disabled
          value={draftToHtml(convertToRaw(editorState.getCurrentContent()))}
        /> */}
      </Fragment>
    );
  }
}
export default DraftEditor

Here is the video
https://www.loom.com/share/485fee2f1cf74ed7a37289b074d54139

package.json

{
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.28",
    "@fortawesome/free-solid-svg-icons": "^5.13.0",
    "@fortawesome/react-fontawesome": "^0.1.9",
    "availity-reactstrap-validation": "^2.6.0",
    "bootstrap": "^4.3.1",
    "chalk": "^2.4.1",
    "chart.js": "^2.8.0",
    "draft-js": "^0.11.5",
    "draftjs-to-html": "^0.9.1",
    "immutable": "^4.0.0-rc.12",
    "js-cookie": "^2.2.1",
    "lodash": "^4.17.15",
    "moment": "^2.24.0",
    "node-sass": "^4.12.0",
    "rc-time-picker": "^3.7.3",
    "react": "^16.8.6",
    "react-bootstrap": "^1.0.0-beta.9",
    "react-chartjs": "^1.2.0",
    "react-chartjs-2": "^2.7.6",
    "react-countup": "^4.2.0",
    "react-data-grid": "^6.1.0",
    "react-datepicker": "^2.8.0",
    "react-dom": "^16.8.6",
    "react-draft-wysiwyg": "^1.14.5",
    "react-dropzone": "^10.2.2",
    "react-dropzone-uploader": "^2.10.1",
    "react-feather": "^2.0.3",
    "react-fontawesome": "^1.6.1",
    "react-google-charts": "^3.0.14",
    "react-images-upload": "^1.2.7",
    "react-redux": "^7.1.0",
    "react-responsive-modal": "^4.0.1",
    "react-router": "^5.2.0",
    "react-router-dom": "^5.2.0",
    "react-router-scroll-4": "^1.0.0-beta.2",
    "react-scripts": "^3.0.1",
    "react-select": "^3.1.0",
    "react-slick": "^0.24.0",
    "react-smart-data-table": "^0.7.1",
    "react-star-rating-component": "^1.4.1",
    "react-switch": "^5.0.1",
    "react-table-6": "^6.11.0",
    "react-tabs": "^3.0.0",
    "react-toastify": "^5.3.2",
    "reactstrap": "^8.0.1",
    "slick-carousel": "^1.8.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "Faker": "^0.7.2"
  }
}
@danvln
Copy link

danvln commented Nov 27, 2020

It is because of the fixed position on the toolbar elements. Did you find a solution? Adding absolute could be one, but it is causing other issues.

@VladimirBlagojevic
Copy link

@phongyewtong Hi man, did u manage to solve this problem..I have the same behaviour when opened in modal..If i dont open Editor in modal all works

@aphofstede
Copy link

Does it work in a production build? We saw the image dropdown "expanded" prop get set to true and then immediately to false again.
Probably due to this: facebook/react#12856 (comment)

@Pashaqwe
Copy link

@VladimirBlagojevic Hi man, did u manage to solve this problem?

@ShaikhMohammaddanish
Copy link

if you are using next js change reactStrictMode: false in next.config.js. it will solve the issue.

@ShaikhMohammaddanish
Copy link

remove StrictMode in react

<React.StrictMode>

</React.StrictMode>,

@ShaikhMohammaddanish
Copy link

if you are using next js change reactStrictMode: false in next.config.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants