Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
randylang opened this issue Mar 25, 2020 · 21 comments
Closed

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

randylang opened this issue Mar 25, 2020 · 21 comments
Labels
help wanted Extra attention is needed

Comments

@randylang
Copy link

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:

  • Existing page, insert bullet item in the middle of the page, gone after saving
  • New page, add new lines, lines appear after saving
  • Existing page, add multiple lines at the end, gone after saving
  • Existing page, add content from the textile view, always present after saving
  • Existing page, add content in the middle and switch to preview, content gone
  • Existing page, add content . . . and switch to textile, content gone

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
Copy link
Owner

taqueci commented Apr 18, 2020

Note to self:
Dockerfile.zip

@nanego
Copy link
Contributor

nanego commented Apr 21, 2020

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
Copy link
Owner

taqueci commented Apr 21, 2020

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
Copy link
Author

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
Copy link
Owner

taqueci commented Apr 24, 2020

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...

@taqueci taqueci added the help wanted Extra attention is needed label Apr 24, 2020
@randylang
Copy link
Author

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
Copy link
Owner

taqueci commented Apr 26, 2020

Hi @randylang

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

@nanego
Copy link
Contributor

nanego commented Apr 27, 2020

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
Copy link
Owner

taqueci commented Apr 27, 2020

Hi @nanego

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

h1. Wiki

[[Wiki#Wiki]]

taqueci added a commit that referenced this issue Apr 28, 2020
taqueci added a commit that referenced this issue Apr 28, 2020
@taqueci
Copy link
Owner

taqueci commented Apr 28, 2020

Hi @nanego and @randylang

Could you please try branch issue/83?

@randylang
Copy link
Author

randylang commented Apr 28, 2020 via email

@nanego
Copy link
Contributor

nanego commented Apr 28, 2020

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
Copy link
Contributor

nanego commented Apr 28, 2020

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

@randylang
Copy link
Author

randylang commented Apr 30, 2020

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.
. . .

  • [[Software Processes]]
  • New text

h2. Some header
. . .

@taqueci
Copy link
Owner

taqueci commented May 2, 2020

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
Copy link
Author

I believe you have fixed it.

Thank you for the help and the excellent plugin.

@taqueci
Copy link
Owner

taqueci commented May 3, 2020

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

@taqueci taqueci closed this as completed May 3, 2020
@randylang
Copy link
Author

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
Copy link
Owner

taqueci commented May 3, 2020

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
Copy link
Contributor

nanego commented May 4, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants