taqueci / redmine_wysiwyg_editor

Redmine WYSIWYG Editor plugin
GNU General Public License v2.0
115 stars 27 forks source link

Wiki edits disappear after clicking preview, textile or save #83

Closed randylang closed 4 years ago

randylang commented 4 years ago

There are some instances when edits made in the Visual Editor disappear after saving or switching to one of the other views.

It does not happen when editing a new page.

I have tested several situations on one page to verify statement made in this issue:

Environment: Redmine version 4.1.0.stable Ruby version 2.5.7-p206 (2019-10-01) [x64-mingw32] Rails version 5.2.4.1 Environment production Database adapter Mysql2 Mailer queue ActiveJob::QueueAdapters::AsyncAdapter Mailer delivery smtp SCM: Subversion 1.10.2 Git 2.19.1 Filesystem
Redmine plugins: redmine_checklists 3.1.12 redmine_wiki_gchart_formula 0.0.5 redmine_wysiwyg_editor 0.15.0

taqueci commented 4 years ago

Note to self: Dockerfile.zip

nanego commented 4 years ago

Hello. We have the same problem here. In some occasions, modifications disappear when we switch from Visual to Textile tab. When this happens, we get this error message in our browser console:

TypeError: m is null >>> redmine_wysiwyg_editor.js:887:18

So it seems to come from this code:

      var m = node.getAttribute('href')
          .match(/\/projects\/([\w-]+)\/wiki(?:\/([^,./?;:|]+)(#.+)?)?$/);

      var proj = m[1];
      var page = m[2] ? decodeURIComponent(m[2]) : null;
taqueci commented 4 years ago

Hi @nanego

Thank you for your information. I guess wiki link causes the issue.

Could you please tell me your wiki link code which causes an error?

randylang commented 4 years ago

I assume that the dockerfile is for me? The content of the script looks Linux centric, not sure it will work on my windows installation.

After reading the comment from @nanego, I realized I should look at the browser console.

I installed 0.15.1, then looked to see if the issue was fixed. It is not, the attached file contains the error information from the browser console.

wysiwyg_editor-0.15.1-1587736281274.log

taqueci commented 4 years ago

I assume that the dockerfile is for me?

No, it is just for me.

I installed 0.15.1, then looked to see if the issue was fixed. It is not,

0.15.1 has resolved not this issue but #84.

Thank you for your console log. However, I don't know the root cause...

randylang commented 4 years ago

If there is anything I can do to help let me know. I’m not sure I can do much, I have very little knowledge about Ruby or Java.

taqueci commented 4 years ago

Hi @randylang

Could you please replace redmine_wysiwyg_editor.js with attached one and tell me the href values on console.log?

nanego commented 4 years ago

Hi @taqueci I just tried with the modified js file. Here is what I get:

// redmine_wysiwyg_editor.js:884:15
href = #1 
href = /projects/my-project/wiki/Session_timeout_
TypeError: m is null
taqueci commented 4 years ago

Hi @nanego

Thank you for your information.
I can reproduce the issue by:

h1. Wiki

[[Wiki#Wiki]]
taqueci commented 4 years ago

Hi @nanego and @randylang

Could you please try branch issue/83?

randylang commented 4 years ago

I will try it as soon as I have a chance. Thank you.

On Tue, Apr 28, 2020 at 8:57 AM taqueci notifications@github.com wrote:

Hi @nanego https://github.com/nanego and @randylang https://github.com/randylang

Could you please try branch issue/83 https://github.com/taqueci/redmine_wysiwyg_editor/tree/issue/83?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/taqueci/redmine_wysiwyg_editor/issues/83#issuecomment-620589596, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKH3IIEPBZ3QRFE3BI5ABPDRO3HEZANCNFSM4LTYBUZA .

-- Randy Lang Electrical Engineer

randy.lang@ieee.org http://www.linkedin.com/in/randylang

randylang commented 4 years ago

I don't think it worked.

I snagged the complaints from the Chrome console.

wysiwyg issue 83 chrome log tinymce verbose-1588092846055.log wysiwyg issue 83 chrome log verbose-1588092846055.log wysiwyg issue 83 chrome log-1588092846055.log wysiwyg issue 83 chrome log info-1588092846055.log

nanego commented 4 years ago

Thank you for this patch @taqueci. I tested it. Unfortunately, it does not fix the issue in my case. I still get the same errors in my browser. I will try again to isolate a minimal text in order to show you how to reproduce the error.

nanego commented 4 years ago

Actually, I just retried in wikis, and the error seems to be gone. But I still see it when I edit issues description.

randylang commented 4 years ago

I spent some time with the console, I caused the issue by adding some text to a page, then switching from visual editor to preview. I set a break at line 895.

When the errors occur, href at line 897 is: href = "/redmine/projects/aerosonic-polices-and-procedures/wiki/Software_Processes?parent=Subversion" and the match on line 892 must be failing.

When it works, href = "/redmine/projects/aerosonic-polices-and-procedures/wiki/Finding_Old_Commit_Messages" and m is an array of stuff.

I don't know if its relevant but when it fails, node = a.wiki-page.new {target: "", download: "", ping: "", rel: "", relList: DOMTokenList(0), …}

When it works, node = a.wiki-page { . . . }

My hunch is that the regular expression needs to be reworked to function when href includes the query.

The structure that was added to the page in question is like the following (shown in textile for clarity) Software Processes is an existing page. The New Text was the added content. . . .

h2. Some header . . .

taqueci commented 4 years ago

Hi @randylang

Thank you for your information.
As you have guessed, the error is caused by query parameter.

Could you please try branch issue/83a?

randylang commented 4 years ago

I believe you have fixed it.

Thank you for the help and the excellent plugin.

taqueci commented 4 years ago

The commit has been merged to the mater branch. Thank you for your cooperation.

randylang commented 4 years ago

I'm pleased that it works. I’ve been using it all day. I wish I had realized there was a debugger built into chrome sooner, I wouldn’t have wasted your time with all those log files.

taqueci commented 4 years ago

Hi @nanego

I just tried with the modified js file. Here is what I get:

// redmine_wysiwyg_editor.js:884:15
href = #1 
href = /projects/my-project/wiki/Session_timeout_
TypeError: m is null

I don't know the latest version solves your problem or not. If you still have error, please create new issue.

nanego commented 4 years ago

Hi @taqueci I still get an error with the last version. I have just created a new issue (#86) and I added details to easily reproduce the error. Thank you for your help.