mweiss / elm-rte-toolkit

A toolkit for creating rich text editors in Elm
https://mweiss.github.io/elm-rte-toolkit/
BSD 3-Clause "New" or "Revised" License
149 stars 14 forks source link

TypeError: HTMLElement constructor: 'new' is required #18

Closed tgelu closed 4 years ago

tgelu commented 4 years ago

I get above runtime exception from elmEditor.js. The complaint seems to be on line 364 on .call(this):

var _this2 = _possibleConstructorReturn(this, (ElmEditor.__proto__ || Object.getPrototypeOf(ElmEditor)).call(this));

I am just trying out the package and I am not doing anything more than trying to render a paragraph with the below Editor.Config. But the render seems to work just fine even given the above error.

        { decorations = Decorations.emptyDecorations
        , spec = Definitions.markdown
        , commandMap = Command.emptyCommandMap
        , toMsg = EditorMsg
        }
mweiss commented 4 years ago

I believe that error is due to not having the es5 shim for custom elements when importing the npm module. Have you done the following?

npm install --save @webcomponents/webcomponentsjs
npm install --save elm-rte-toolkit

And in your javascript:

import '@webcomponents/webcomponentsjs/webcomponents-bundle.js'
import '@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js'
import 'elm-rte-toolkit';

Here's an example with the demo from this repo as a standalone application importing with npm: https://github.com/mweiss/elm-rte-package-example

tgelu commented 4 years ago

oh, I will try that. Thank you for the quick response! I simply assumed it wasn't necessary in a modern browser (for playing around) :)

tgelu commented 4 years ago

that worked, thank you for this great package!