taqueci / redmine_wysiwyg_editor

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

JavaScript error in connection with the Issue templates plugin #185

Open albrechtd opened 3 months ago

albrechtd commented 3 months ago

Hi,

I use the WYSIWYG plugin together with “Redmine Issue Templates” and noticed that updating the Visual content seems to be broken since moving from Redmine 4 to 5 and/or to recent browser releases. I guess this might be related to #134…

The Firefox Javascript console prints the following error message when I try to apply a template (same with Chromium, btw.):

Uncaught (in promise) TypeError: ns.setRelatedLink is not a function
    replaceTemplateValue https://vm-dev-redmine-01[…]/redmine/plugin_assets/redmine_issue_templates/javascripts/issue_templates.js:195
    replaceTemplateValue https://vm-dev-redmine-01[…]/redmine/projects/it-support/issues/new:162
    loadTemplate https://vm-dev-redmine-01[…]/redmine/plugin_assets/redmine_issue_templates/javascripts/issue_templates.js:143
    promise callback*loadTemplate https://vm-dev-redmine-01[…]/redmine/plugin_assets/redmine_issue_templates/javascripts/issue_templates.js:112
    <anonymous> https://vm-dev-redmine-01[…]/redmine/projects/it-support/issues/new:441
issue_templates.js:195:8
    replaceTemplateValue https://vm-dev-redmine-01[…]/redmine/plugin_assets/redmine_issue_templates/javascripts/issue_templates.js:195
    replaceTemplateValue https://vm-dev-redmine-01[…]/redmine/projects/it-support/issues/new:162
    loadTemplate https://vm-dev-redmine-01[…]/redmine/plugin_assets/redmine_issue_templates/javascripts/issue_templates.js:143
    (Async: promise callback)
    loadTemplate https://vm-dev-redmine-01[…]/redmine/plugin_assets/redmine_issue_templates/javascripts/issue_templates.js:112
    <anonym> https://vm-dev-redmine-01[…]/redmine/projects/it-support/issues/new:441
    receiveMessage resource://gre/actors/SelectChild.sys.mjs:265
    receiveMessage resource://gre/actors/SelectChild.sys.mjs:467

The error does not occur if I disable (i.e. return immediately from) the function overrideIssueTemplatePluginMethods in app/views/redmine_wysiwyg_editor/_redmine_wysiwyg_editor_partial.html.erb.

My minimal Redmine configuration (on a Debian Bookworm box) to reproduce the issue:

Environment:
  Redmine version                5.0.4.stable
  Ruby version                   3.1.2-p20 (2022-04-12) [x86_64-linux-gnu]
  Rails version                  6.1.7.3
  Environment                    production
  Database adapter               PostgreSQL
Redmine plugins:
  redmine_issue_templates        1.1.2
  redmine_ssl_auth_cn            1.0.4-patched
  redmine_wysiwyg_editor         0.32.0

Thanks an advance for any insight, Albrecht.

taqueci commented 3 months ago

File assets/javascripts/issue_templates.js of master branch has been something completely different from the one tagged with v1.1.2...

https://github.com/agileware-jp/redmine_issue_templates/compare/v1.1.2...master#diff-8ec4222b279b2d70ee26cd1f63da74c82d761757406176a3034a6127d39069d3

albrechtd commented 3 months ago

File assets/javascripts/issue_templates.js of master branch has been something completely different from the one tagged with v1.1.2...

I tried with the Redmine Issue Templates master branch, and get almost the same error. The TypeError now references t.setRelatedLink, and the line numbers are different (it looks as if most newlines were removed form the latest version).

Maybe re-introducing my evil hack from #134 might give a usable result, but that doesn't feel like the proper solution (although I could live with customised plugins in my envoronment…).