rob-race / react-trix

React wrapper around Trix editor from Basecamp + some lightweight features
ISC License
213 stars 42 forks source link

Is it compatible with React 16.4? #12

Closed indapublic closed 5 years ago

indapublic commented 6 years ago

React 16.4

import React, { Component } from "react";
import { TrixEditor } from "react-trix";
import "trix/dist/trix-core";
import "trix/dist/trix";
import "trix/dist/trix.css";

export default class WysiwygEditor extends Component {
  handleEditorReady(editor) {
    // this is a reference back to the editor if you want to
    // do editing programatically
    editor.insertText("editor is ready");
  }
  handleChange(html, text) {
    // html is the new html content
    // text is the new text content
  }
  render() {
    return (
      <TrixEditor
        onChange={this.handleChange}
        onEditorReady={this.handleReady}
      />
    );
  }
}
ReferenceError: navigator is not defined
    at Object.<anonymous> (/Volumes/Data/www/code-pilots/vacancy-frontend/node_modules/trix/dist/trix-core.js:6:244)
    at Object.<anonymous> (/Volumes/Data/www/code-pilots/vacancy-frontend/node_modules/trix/dist/trix-core.js:6:343)
    at Object.<anonymous> (/Volumes/Data/www/code-pilots/vacancy-frontend/node_modules/trix/dist/trix-core.js:6:356)
    at Object.<anonymous> (/Volumes/Data/www/code-pilots/vacancy-frontend/node_modules/trix/dist/trix-core.js:11:21015)
    at Module._compile (internal/modules/cjs/loader.js:678:30)
    at Module._compile (/Volumes/Data/www/code-pilots/vacancy-frontend/node_modules/source-map-support/source-map-support.js:492:25)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
    at Module.load (internal/modules/cjs/loader.js:589:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
    at Function.Module._load (internal/modules/cjs/loader.js:520:3)
dstpierre commented 5 years ago

@indapublic I'll look into this as soon as possible, but at this moment I have difficulties reserving work hours for the project.

gopeter commented 5 years ago

I'm using it with React 16.6 and it works great. Thanks for the great wrapper! :-)

@indapublic You just have to import "trix/dist/trix";, you don't need trix-core (in fact, importing the core will throw error messages).

dstpierre commented 5 years ago

I just updated the library to use trix 1.0.0 as well and tested with React 16.7.0.

Thanks @gopeter for the fix.