Enable task list items for Common Mark text formatting (#35742).

git-svn-id: http://svn.redmine.org/redmine/trunk@21383 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Marius Balteanu
2022-01-22 09:24:43 +00:00
parent 8c147ca2b1
commit 380a3b0345
7 changed files with 48 additions and 0 deletions

View File

@@ -49,6 +49,7 @@ group :common_mark do
gem "html-pipeline", "~> 2.13.2"
gem "commonmarker", (Gem.ruby_version < Gem::Version.new('2.6.0') ? '0.21.0' : '0.23.1')
gem "sanitize", "~> 6.0"
gem 'deckar01-task_list', '2.3.2'
end
# Include database gems for the adapters found in the database

View File

@@ -18,6 +18,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'html/pipeline'
require 'task_list/filter'
module Redmine
module WikiFormatting
@@ -57,6 +58,7 @@ module Redmine
SyntaxHighlightFilter,
FixupAutoLinksFilter,
ExternalLinksFilter,
TaskList::Filter
], PIPELINE_CONFIG
class Formatter < Redmine::WikiFormatting::Markdown::Formatter

BIN
public/images/bt_tl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

View File

@@ -132,6 +132,20 @@ jsToolBar.prototype.elements.ol = {
}
}
// tl
jsToolBar.prototype.elements.tl = {
type: 'button',
title: 'Task list',
fn: {
wiki: function() {
this.encloseLineSelection('','',function(str) {
str = str.replace(/\r/g,'');
return str.replace(/(\n|^)[*-]?\s*/g,"$1* [ ] ");
});
}
}
}
// spacer
jsToolBar.prototype.elements.space3 = {type: 'space'}

View File

@@ -1314,6 +1314,13 @@ a.wiki-anchor:hover { color: #aaa !important; text-decoration: none; }
h1:hover a.wiki-anchor, h2:hover a.wiki-anchor, h3:hover a.wiki-anchor, h4:hover a.wiki-anchor, h5:hover a.wiki-anchor, h6:hover a.wiki-anchor { display: inline; color: #ddd; }
div.wiki img {vertical-align:middle; max-width:100%;}
div.wiki .task-list {
list-style-type: none;
padding-left: 0px;
}
div.wiki .task-list input.task-list-item-checkbox {
height: initial;
}
/***** My page layout *****/
.block-receiver {

View File

@@ -128,6 +128,9 @@
.jstb_ol {
background-image: url(../images/jstoolbar/bt_ol.png);
}
.jstb_tl {
background-image: url(../images/jstoolbar/bt_tl.png);
}
.jstb_bq {
background-image: url(../images/jstoolbar/bt_bq.png);
}

View File

@@ -263,6 +263,27 @@ class Redmine::WikiFormatting::CommonMark::FormatterTest < ActionView::TestCase
end
end
def test_should_support_task_list
text = <<~STR
Task list:
* [ ] Task 1
* [x] Task 2
STR
expected = <<~EXPECTED
<p>Task list:</p>
<ul class="task-list">
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Task 1
</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" checked disabled> Task 2</li>
</ul>
EXPECTED
assert_equal expected.gsub(%r{[\r\n\t]}, ''), format(text).gsub(%r{[\r\n\t]}, '').rstrip
end
private
def assert_section_with_hash(expected, text, index)