From edf02b4315e90d525f8abf5a32ec01b1411b3e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20B=C4=82LTEANU?= Date: Sat, 5 Dec 2026 17:11:38 +0200 Subject: [PATCH] Introduce semantic wiki-toolbar CSS classes and deprecate jst* classes (#43259). --- app/assets/stylesheets/application.css | 18 ++--- app/assets/stylesheets/jstoolbar.css | 78 ++++++++++--------- .../controllers/wiki_toolbar_controller.js | 2 +- app/views/wiki_toolbar/_buttons.html.erb | 7 +- app/views/wiki_toolbar/_menus.html.erb | 2 +- app/views/wiki_toolbar/_toolbar.html.erb | 9 ++- test/helpers/wiki_toolbar_helper_test.rb | 16 ++-- 7 files changed, 68 insertions(+), 64 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index d18a6aceb..437b0b81e 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -1379,7 +1379,7 @@ label.block { color: var(--oc-red-9); } -.tabular label.error + *:not(#issue_description_and_toolbar), .tabular label.error + div#issue_description_and_toolbar div.jstBlock { +.tabular label.error + *:not(#issue_description_and_toolbar), .tabular label.error + div#issue_description_and_toolbar div.wiki-toolbar { border: 1px solid var(--oc-red-9); } @@ -1393,15 +1393,15 @@ label.no-css { input#time_entry_comments { inline-size: 90%;} input#months { inline-size: 46px; } -.jstBlock .jstTabs, .jstBlock .wiki-preview { inline-size: 99%; } +.wiki-toolbar .wiki-toolbar-tabs, .wiki-toolbar .wiki-preview { inline-size: 99%; } -.jstBlock .jstTabs { padding-inline-end: 6px; } -.jstBlock .wiki-preview { padding: 2px; } -.jstBlock .wiki-preview > p:first-child { padding-block-start: 0 !important; margin-block-start: 0 !important;} -.jstBlock .wiki-preview > p:last-child { padding-block-end: 0 !important; margin-block-end: 0 !important;} +.wiki-toolbar .wiki-toolbar-tabs { padding-inline-end: 6px; } +.wiki-toolbar .wiki-preview { padding: 2px; } +.wiki-toolbar .wiki-preview > p:first-child { padding-block-start: 0 !important; margin-block-start: 0 !important;} +.wiki-toolbar .wiki-preview > p:last-child { padding-block-end: 0 !important; margin-block-end: 0 !important;} -.tabular .wiki-preview, .tabular .jstTabs {inline-size: 95%;} -.tabular.settings .wiki-preview, .tabular.settings .jstTabs { inline-size: 99%; } +.tabular .wiki-preview, .tabular .wiki-toolbar-tabs {inline-size: 95%;} +.tabular.settings .wiki-preview, .tabular.settings .wiki-toolbar-tabs { inline-size: 99%; } .tabular.settings .wiki-preview p {padding-inline-start: 0 !important} .tabular .wiki-preview p { min-block-size: initial; @@ -1410,7 +1410,7 @@ input#months { inline-size: 46px; } .tabular.settings p, .tabular.settings div.form-field { padding-inline-start: 300px; font-size: 93%; } .tabular.settings label{ margin-inline-start: -300px; inline-size: 295px; } -.tabular.settings textarea, .tabular.settings .wiki-preview, .tabular.settings .jstTabs { inline-size: 99%; } +.tabular.settings textarea, .tabular.settings .wiki-preview, .tabular.settings .wiki-toolbar-tabs { inline-size: 99%; } .settings.enabled_scm table {width:100%} .settings.enabled_scm td.scm_name{ font-weight: bold; } diff --git a/app/assets/stylesheets/jstoolbar.css b/app/assets/stylesheets/jstoolbar.css index 02b49bdb4..ea18c901c 100644 --- a/app/assets/stylesheets/jstoolbar.css +++ b/app/assets/stylesheets/jstoolbar.css @@ -4,13 +4,15 @@ * This code is released under the GNU General Public License. */ -.jstBlock .hidden { +/* Deprecated jst* aliases (jstBlock, jstTabs, jstEditor, jstElements, jstSpacer, jstMenu, jstb_*) + * are still emitted in HTML for third-party theme/plugin compatibility. */ +.wiki-toolbar .hidden { display: none; } -.jstEditor { +.wiki-toolbar-editor { padding-inline-start: 0px; } -.jstEditor textarea, .jstEditor iframe { +.wiki-toolbar-editor textarea, .wiki-toolbar-editor iframe { margin: 0; } .jstHandle { @@ -19,26 +21,26 @@ cursor: s-resize; /*background: transparent url(img/resizer.png) no-repeat 45% 50%;*/ } -#content .jstTabs.tabs { +#content .wiki-toolbar-tabs.tabs { margin-block-end: -1px; } -#content .jstTabs.tabs ul {border-block-end: 0;} -#content .jstTabs.tabs li { +#content .wiki-toolbar-tabs.tabs ul {border-block-end: 0;} +#content .wiki-toolbar-tabs.tabs li { block-size: 42px; } -#content .jstTabs.tabs li:before{ +#content .wiki-toolbar-tabs.tabs li:before{ content: ''; display: inline-block; vertical-align: middle; block-size: 100%; } -#content .jstTabs.tabs li a { +#content .wiki-toolbar-tabs.tabs li a { display: inline-block; vertical-align: bottom; line-height: 19px; border-block-end: 1px solid transparent; } -.jstElements { +.wiki-toolbar-buttons { display: inline-block; vertical-align: bottom; padding-inline-start: 6px; @@ -52,7 +54,7 @@ } .wiki-preview p.empty-preview {color: var(--color-text-muted); font-style: italic; margin-block-start: 1em; text-align: center;} -.jstElements button { +.wiki-toolbar-buttons button { margin-inline-end: 2px; inline-size : 24px; block-size: 24px; @@ -66,26 +68,26 @@ cursor:pointer; opacity:0.7; } -.jstElements button:hover { +.wiki-toolbar-buttons button:hover { border-color: var(--oc-gray-5); background-color: var(--oc-gray-3); opacity:1; } -.jstElements button span { +.wiki-toolbar-buttons button span { display : none; } -.jstElements span { +.wiki-toolbar-buttons span { display : inline; } -.jstSpacer { +.wiki-toolbar-spacer { inline-size : 0px; font-size: 1px; margin-inline-end: 6px; } -.jstElements .help { float: inline-end; margin-inline-end: 0.5em; padding-block-start: 8px; font-size: 0.9em; } -.jstElements .help a {padding-block: 2px; padding-inline-start: 20px; padding-inline-end: 0; background: url(./help.png) no-repeat 0 50%;} +.wiki-toolbar-buttons .help { float: inline-end; margin-inline-end: 0.5em; padding-block-start: 8px; font-size: 0.9em; } +.wiki-toolbar-buttons .help a {padding-block: 2px; padding-inline-start: 20px; padding-inline-end: 0; background: url(./help.png) no-repeat 0 50%;} .table-generator td { border: 1px solid var(--oc-gray-4); @@ -110,14 +112,14 @@ } /* Menus opened by the toolbar buttons, positioned by wiki_toolbar_controller.js */ -.jstBlock > [popover] { +.wiki-toolbar > [popover] { position: absolute; inset: auto; margin: 0; } /* Resets the user agent styles of popovers without overriding the menu styles */ -:where(.jstBlock > [popover]) { +:where(.wiki-toolbar > [popover]) { padding: 0; border: 0; overflow: visible; @@ -132,7 +134,7 @@ padding-inline: 4px; /* .dropdown-content sets the block padding */ } -.jstMenu { +.wiki-toolbar-menu { max-block-size: 300px; overflow-y: auto; /* Same as the context menu, regardless of the line height of the form (e.g. .box) */ @@ -142,63 +144,63 @@ /* Buttons -------------------------------------------------------- */ -.jstb_strong { +.wiki-toolbar-button-strong { background-image: url(/jstoolbar/bold.svg); } -.jstb_em { +.wiki-toolbar-button-em { background-image: url(/jstoolbar/italic.svg); } -.jstb_ins { +.wiki-toolbar-button-ins { background-image: url(/jstoolbar/underline.svg); } -.jstb_del { +.wiki-toolbar-button-del { background-image: url(/jstoolbar/strikethrough.svg); } -.jstb_code { +.wiki-toolbar-button-code { background-image: url(/jstoolbar/letter-c.svg); } -.jstb_h1 { +.wiki-toolbar-button-h1 { background-image: url(/jstoolbar/h1.svg); } -.jstb_h2 { +.wiki-toolbar-button-h2 { background-image: url(/jstoolbar/h2.svg); } -.jstb_h3 { +.wiki-toolbar-button-h3 { background-image: url(/jstoolbar/h3.svg); } -.jstb_ul { +.wiki-toolbar-button-ul { background-image: url(/jstoolbar/list.svg); } -.jstb_ol { +.wiki-toolbar-button-ol { background-image: url(/jstoolbar/list-numbers.svg); } -.jstb_tl { +.wiki-toolbar-button-tl { background-image: url(/jstoolbar/list-check.svg); } -.jstb_bq { +.wiki-toolbar-button-bq { background-image: url(/jstoolbar/indent-increase.svg); } -.jstb_unbq { +.wiki-toolbar-button-unbq { background-image: url(/jstoolbar/indent-decrease.svg); } -.jstb_pre::before { +.wiki-toolbar-button-pre::before { content: "pre"; font-size: 10px; color: var(--oc-gray-9); font-weight: 700 } -.jstb_precode { +.wiki-toolbar-button-precode { background-image: url(/jstoolbar/code.svg); } -.jstb_link { +.wiki-toolbar-button-link { background-image: url(/jstoolbar/wiki_link.svg); } -.jstb_img { +.wiki-toolbar-button-img { background-image: url(/jstoolbar/image.svg); } -.jstb_table { +.wiki-toolbar-button-table { background-image: url(/jstoolbar/table.svg); } -.jstb_help { +.wiki-toolbar-button-help { background-image: url(/jstoolbar/help.svg); } diff --git a/app/javascript/controllers/wiki_toolbar_controller.js b/app/javascript/controllers/wiki_toolbar_controller.js index ae8375a3e..1fa5b9a57 100644 --- a/app/javascript/controllers/wiki_toolbar_controller.js +++ b/app/javascript/controllers/wiki_toolbar_controller.js @@ -131,7 +131,7 @@ export default class extends Controller { if (event.target === this.field) { event.preventDefault() this.preview() - } else if (this.constructor.lastPreviewed === this && !event.target.closest?.('.jstEditor')) { + } else if (this.constructor.lastPreviewed === this && !event.target.closest?.('.wiki-toolbar-editor, .jstEditor')) { event.preventDefault() this.constructor.lastPreviewed = null this.edit() diff --git a/app/views/wiki_toolbar/_buttons.html.erb b/app/views/wiki_toolbar/_buttons.html.erb index da365b945..f2a4dd5d7 100644 --- a/app/views/wiki_toolbar/_buttons.html.erb +++ b/app/views/wiki_toolbar/_buttons.html.erb @@ -1,11 +1,12 @@ +<%# The jst* classes (jstElements, jstSpacer, jstb_*) are deprecated and kept for theme/plugin compatibility. %> <% buttons = Redmine::WikiToolbar.buttons(Setting.text_formatting) %> <% cache ['wiki_toolbar_buttons', Setting.text_formatting, current_language, buttons] do %> -
+
<% buttons.each_with_index do |names, index| %> - <% if index > 0 %> <% end %> + <% if index > 0 %> <% end %> <% names.each do |name| %> <% title = l(Redmine::WikiToolbar.label_for(name)) %> - <%= tag.button tag.span(title), type: 'button', class: "jstb_#{name}", title: title, tabindex: 200, + <%= tag.button tag.span(title), type: 'button', class: "wiki-toolbar-button-#{name} jstb_#{name}", title: title, tabindex: 200, aria: ({haspopup: true, expanded: false} if Redmine::WikiToolbar.menus.include?(name)), data: wiki_toolbar_button_data(name) %> <% end %> diff --git a/app/views/wiki_toolbar/_menus.html.erb b/app/views/wiki_toolbar/_menus.html.erb index 7882e81f4..8c1e3148e 100644 --- a/app/views/wiki_toolbar/_menus.html.erb +++ b/app/views/wiki_toolbar/_menus.html.erb @@ -1,7 +1,7 @@ <% languages = User.current.pref.toolbar_language_options.to_s.split(',') %> <% cache ['wiki_toolbar_menus', languages] do %>