cosmocode / dokuwiki-plugin-prosemirror

A modern WYSIWYG editor for DokuWiki
https://wysiwyg.wiki.cosmocode.de/
54 stars 20 forks source link

Dokuwiki Prosemirror - Fails with Uncaught TypeError: window.Prosemirror is undefined #141

Closed rb-oscu closed 3 years ago

rb-oscu commented 3 years ago

I have a new install of dokuwiki that seems to be working great, but I cannot get the prosemirror plugin to work correctly. When I click on "Toggle WYSIWYG editor" it does not load and says "There was an error in the WYSIWYG editor".

Edge Chromium developer tools shows this when the issue happens:

Uncaught TypeError: Cannot read property 'enableProsemirror' of undefined at showProsemirror (js.php?t=dokuwiki&tseed=efed69add6c51c7ac07c7df3cbebdee9:1) at handleEditSession (js.php?t=dokuwiki&tseed=efed69add6c51c7ac07c7df3cbebdee9:1) at HTMLDocument. (js.php?t=dokuwiki&tseed=efed69add6c51c7ac07c7df3cbebdee9:1) at e (jquery.php?tseed=34a552433bc33cc9c3bc32527289a0b2:2) at t (jquery.php?tseed=34a552433bc33cc9c3bc32527289a0b2:2) showProsemirror @ js.php?t=dokuwiki&tseed=efed69add6c51c7ac07c7df3cbebdee9:1 2js.php?t=dokuwiki&tseed=efed69add6c51c7ac07c7df3cbebdee9:1 Uncaught TypeError: Cannot read property 'destroyProsemirror' of undefined at showDefaultEditor (js.php?t=dokuwiki&tseed=efed69add6c51c7ac07c7df3cbebdee9:1) at Object.handleSwitchEditorResponse (js.php?t=dokuwiki&tseed=efed69add6c51c7ac07c7df3cbebdee9:1) at c (jquery.php?tseed=34a552433bc33cc9c3bc32527289a0b2:2) at Object.fireWith [as resolveWith] (jquery.php?tseed=34a552433bc33cc9c3bc32527289a0b2:2) at l (jquery.php?tseed=34a552433bc33cc9c3bc32527289a0b2:2) at XMLHttpRequest. (jquery.php?tseed=34a552433bc33cc9c3bc32527289a0b2:2)

Firefox developer tools shows this:

Uncaught TypeError: window.Prosemirror is undefined


Dokuwiki 2020-07-29 "Hogfather" Prosemirror 2021-05-06 PHP 7.3.19 IIS - Windows 2019

TheManchineel commented 3 years ago

@rb-oscu, I get the same on Ubuntu 20.04 LTS, NGINX, PHP 7.4 FPM, freshly installed Dokuwiki 2020-07-29 "Hogfather", no plugins aside from Prosemirror and the default extra ones (Wrap, Gallery etc.). Tested on Firefox and Safari, latest releases of each.

What's so interesting is that this only seems to occur on new wiki installations like yours and mine. I recently set up a new wiki and tried to replicate the existing setup on two OTHER Dokuwiki instances of mine, both of which have no issues with Prosemirror, and both of which are on Hogfather. This led me to thinking that the repository was serving a bad version of the addon but it's actually the exact same I have installed and functional on two other wikis. I even manually copied the plugin files over just for the sake of double-checking. No dice, zero, nada.

TL;DR: I already have this setup functional on two other wikis, both with the Bootstrap3 template and a bunch of other plugins. And yet, as of today 2021-07-19, I can't replicate the setup working on a fresh instance. This might be worth looking into, @splitbrain. Thanks for this software btw :)

splitbrain commented 3 years ago

How exactly have you installed the plugin? Search and install via the extension manager?

BlackDex commented 3 years ago

I have exactly the same issue. I'm just testing out DokuWiki and using the Bitnami docker container. Installed it via the search and install. The CKEditor does seem to work though.

WebFreak001 commented 3 years ago

Same issue here on the linuxserver/docker-dokuwiki docker container. Installed via the usual plugin manager. Also CKEditor working here.

Error in UI: grafik

Also for the users changing back to the default editor with the button or reloading then doesn't work anymore either, though aborting and editing again seems to work. Errors should probably not prevent the switch back button.

Not seeing any error messages on the server, the client only contains the error that Prosemirror is not defined.

rb-oscu commented 3 years ago

How exactly have you installed the plugin? Search and install via the extension manager?

Searched and installed using the extension manager. However, I also tried installing it manually and had the same results.

TheManchineel commented 3 years ago

How exactly have you installed the plugin? Search and install via the extension manager?

@splitbrain yes, installed through the extension manager. For what it's worth, there is no difference even doing a manually install from this repo.

PowerKiKi commented 3 years ago

Workaround

cd lib/plugins/
rm -rf prosemirror/ # delete previously installed plugin
git clone https://github.com/cosmocode/dokuwiki-plugin-prosemirror prosemirror # clone plugin via git
cd prosemirror/
yarn && yarn build # Build plugin

Explanation

This plugin use DOKUWIKI:include to include the file lib/bundle.js:

https://github.com/cosmocode/dokuwiki-plugin-prosemirror/blob/eaf8f305e08d0e8115e140695286973846792048/script.js#L79

But that file does not exist in the git repository, and because DokuWiki use the git release tarball, that file also does not exist when installing with "Search and install" via the extension manager. So DokuWiki fails to include the non-existing file (that contains ProseMirror itself).

IMHO DokuWiki should crash if a file does not exist, instead of silently entering an indeterminate state that lead to errors much later. Or at the very least it should log an error somewhere.

Also this plugin should include lib/bundle.js as part of the git repository.

rolfik commented 3 years ago

Yes @PowerKiKi that is what I have found as well and wanted to write here as a solution. But the fix should be done in dokuwiki prosemirror git repository by adding compiled lib/bundle.js there.

PowerKiKi commented 3 years ago

@splitbrain fixed this via https://github.com/cosmocode/dokuwiki-plugin-prosemirror/pull/142#issuecomment-887291792 by re-configuring the plugin. Users should "re-install" the plugin from the Extension Manager.

This issue should be closed as resolved now.