Skip to content

Troubles using React and webpack #416

Closed
@cedricdelpoux

Description

@cedricdelpoux

Hi I tried to use AllowEditor with React but I have errors in my browser console.

Cannot read property 'add' of undefined in alloy-editor-no-react.js:12062
Cannot set property 'dir' of undefined in alloy-editor-no-react.js:237

I read I maybe have to to redefine window.ALLOYEDITOR_BASEPATH and AlloyEditor.regexBasePath but I don't know exactly what to write.
I tried this regex AlloyEditor.regexBasePath = /nodes_modules/alloyeditor/dist/alloy-editor/allow-editor-no-react-min.js/ but it does not work.

My javascript is compiled with webpack and this is the code I use to initialize it :

import "!style!file!css!alloyeditor/dist/alloy-editor/assets/alloy-editor-moono-min.css"

import React, { Component } from "react"
import AlloyEditor from "alloyeditor"

export default class Editor extends Component {
  componentDidMount() {
    this._editor = AlloyEditor.editable(this.refs.container
  }

  componentWillUnmount() {
    this._editor.destroy()
  }

  render() {
    return (
      <div ref="container">
        Test
      </div>
    )
  }
}

The initialization seems work because my container is transformed to an content editable component. But I have only a textearea.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions