react-email-editor icon indicating copy to clipboard operation
react-email-editor copied to clipboard

Can't make the custom tool work

Open Ablomis opened this issue 3 years ago • 2 comments

Following this tutorial: https://examples.unlayer.com/custom_tools/react-custom-tool

This is what I have in the component.js:

const React = window.unlayer.React

const Viewer = () => {
  return <div>I am a custom tool.</div>
}

// Custom Property Editor


unlayer.registerTool({
  type: "whatever",
  category: "contents",
  label: "Test Tool",
  icon: "fa-smile",
  values: {},
  options: { },
  renderer: {
    Viewer: Viewer,
    exporters: {
      web: function () {},
      email: function () {}
    }
  }
});

My editor page:

        <EmailEditor
          ref={emailEditorRef}
          projectId={85626}
          options={{
            customJS: [
              `https://app.dev.localhost/custom.js`,
            ]
          }}
        /> 

The error I have: custom.js:9 Uncaught SyntaxError: Unexpected token '<' (at custom.js:9:12)

What am I doing wrong?

Ablomis avatar Jun 20 '22 21:06 Ablomis

Isn't it because it's not expecting JSX code because you provided a .js extension for a file?

agnieszkaac avatar Feb 01 '23 12:02 agnieszkaac

@lucasbesen @umairsiddique @adeelraza

Any thoughts on this? Following the tutorial precisely leads to the error that is posted above!

I reckon it may be caused by the type attribute of the script tag being set to text/javascript instead of text/jsx. Is there any way to control the script type used for each custom tool?

sorsaffari avatar Oct 16 '23 15:10 sorsaffari