DCsunset / vuetify-markdown-editor

A Vue.js Component for editing and previewing markdown using Vuetify.js
MIT License
63 stars 17 forks source link

"invalid regular expression flag s" #3

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hi,

npm v 6.14.4

node v 13.12.0

Git cloned repo

ran npm i && npm run serve

Nothing works either by using the git or by importing the module to another project,

Screen hangs and I get a console error:

[Vue warn]: Error in getter for watcher "compiled": "SyntaxError: invalid regular expression flag s"

found in

---> at src/components/MarkdownEditor.vue

at src/App.vue

Seems to point to line 226 in MarkdownEditor component:

let compiled = render(
                this.value,
                this.renderOptions,
                _.merge(this.renderConfig, copyConfig),
                cache
            );

anyone knows how to fix this?

ghost commented 4 years ago

Umm doing global search for "new RegExp(" and removing the "s" regex flags seems to have fixed it..

But not when you use it as a module.. in which case you need to modify another use of "s" flag at /node_modules/vuetify-markdown-editor/dist/vuetify-markdown-editor.umd.js:124724

DCsunset commented 4 years ago

It's strange because I don't have this problem after repeating your steps. Maybe you could try to delete the node_modules directory and run npm i again?

ghost commented 4 years ago

Done, same errors occur again. Maybe it's because I'm using it from a nuxt project?

DCsunset commented 4 years ago

I have set up a project using nuxt.js: https://github.com/DCsunset/vuetify-markdown-editor-demo. But still, this error doesn't occur. It would be easier to debug if you could set up a demo project to reproduce it.

ghost commented 4 years ago

Can you try opening a project with npx create-nuxt-app and use you're editor anywhere? Fixing the "S" flags was ok for development, but now in a nuxt build the object doesn't even show up!

ghost commented 4 years ago

The demo you linked does not work for me, same issues as I've described.

jusantana commented 4 years ago

I'm having the same issue also. New to vue and vuetify, not sure how to fix this.

ghost commented 4 years ago

I ended up just using vue-simplemde which is a bit less pretty but surely does the job

DCsunset commented 4 years ago

After some tests, I have found the error. It's because the regex uses a feature not compatible with some browsers. Now the lastest commit should fix this error.

If it is fixed in your environment, I could publish a new version of this package.

ghost commented 4 years ago

Works good in chrome, same errors in firefox on mac also, if you plan to leave the nuxt example, make sure it's inside tags, since it's not working if SSR'd (no document)

DCsunset commented 4 years ago

@tomelic The latest commit in the master branch should already fix this issue even in Firefox, because there's no flag 's' anymore.

DCsunset commented 4 years ago

Feel free to open the issue if this error occurs again.