From b7a4571dbbb55c2b49b51798a2564826d2930b42 Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Tue, 3 Nov 2026 11:29:24 +0900 Subject: [PATCH 4/5] Let text formatters without toolbar buttons render their own editor Text formatter plugins that provide their own editor define wikitoolbar_for in their helper, which core views used to call after the textarea. Since the views render the textarea with wiki_toolbar, that method was no longer called and only a plain textarea was rendered. wiki_toolbar now calls it when the formatter does not define toolbar buttons. Co-Authored-By: Claude Opus 5.5 --- app/helpers/wiki_toolbar_helper.rb | 5 ++++- test/helpers/wiki_toolbar_helper_test.rb | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/helpers/wiki_toolbar_helper.rb b/app/helpers/wiki_toolbar_helper.rb index 9627fccd0..416f2bb15 100644 --- a/app/helpers/wiki_toolbar_helper.rb +++ b/app/helpers/wiki_toolbar_helper.rb @@ -37,7 +37,10 @@ module WikiToolbarHelper # #wiki_textarea_options. def wiki_toolbar(field_id, preview_url: preview_text_path, &) field = capture(&) - return field unless Redmine::WikiToolbar.buttons(Setting.text_formatting) + unless Redmine::WikiToolbar.buttons(Setting.text_formatting) + # Text formatters that don't use the toolbar can provide their own editor + return field + wikitoolbar_for(field_id, preview_url).to_s + end heads_for_wiki_formatter render(partial: 'wiki_toolbar/toolbar', locals: {field_id: field_id, field: field, preview_url: preview_url}) diff --git a/test/helpers/wiki_toolbar_helper_test.rb b/test/helpers/wiki_toolbar_helper_test.rb index 46495ec3e..8510b7e3c 100644 --- a/test/helpers/wiki_toolbar_helper_test.rb +++ b/test/helpers/wiki_toolbar_helper_test.rb @@ -56,6 +56,19 @@ class WikiToolbarHelperTest < Redmine::HelperTest end end + def test_wiki_textarea_tag_should_render_the_editor_of_a_formatter_without_toolbar_buttons + helper = Module.new do + def wikitoolbar_for(field_id, preview_url) + tag.div(:id => "editor-for-#{field_id}") + end + end + Redmine::WikiFormatting.stubs(:helper_for).returns(helper) + + html = render_erb("<%= wiki_textarea_tag('notes') %>") + assert_select_in html, 'textarea#notes + div#editor-for-notes' + assert_select_in html, 'div.jstBlock', 0 + end + def test_wiki_textarea_tag_should_not_duplicate_the_wiki_edit_class with_settings :text_formatting => 'textile' do html = render_erb("<%= wiki_textarea_tag('notes', '', :class => 'wiki-edit other') %>") -- 2.55.0