Project

General

Profile

Actions

Feature #41294

closed

Partial quoting feature for Issues and Forums

Added by Katsuya HIDAKA about 2 months ago. Updated 22 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
UI
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed

Description

Background/Purpose

Currently, Redmine allows quoting entire messages in issues and forums. However, it is inconvenient when users want to quote only a portion of a long message

This patch introduces the ability to quote only selected parts of messages, improving usability when handling long texts.

Features

Quoting selected text

  • When the user selects the text they want to quote and clicks the quote button, only the selected portion will be inserted into the comment field as a quote. If no text is selected, the entire message will be quoted, just like the current behavior.
  • If multiple parts of the message are selected (currently supported only in Firefox as of 2024), only the first selected part is quoted.

Preserving original message format in CommonMark Markdown only

  • The original message format will be preserved during quoting only if the text format is set to CommonMark Markdown. For other text formats, the message will be quoted as plain text without retaining its original formatting.
  • Some formats will not be fully supported:
    • Table formatting will be quoted as plain text.
    • Redmine-specific link formatting will be quoted as standard Markdown links. For example, #12 becomes [#12](/issues/12)

Implementation

This feature is implemented as follows.

  • When the quote button is pressed, the HTML of the selected text is retrieved and converted into CommonMark Markdown.
  • The conversion from HTML to CommonMark Markdown is done using the turndown library (MIT license).
  • Use only JavaScript APIs that are widely supported by browsers wherever possible.
  • Since turndown does not offer a minified version of its source code, I compressed it using uglify v3.19.3.
    uglify --compress --mangle --output=app/assets/javascripts/turndown-7.2.0.min.js -- turndown.js
    

Testing

This patch was tested on the Redmine trunk using the following browsers:

  • Chrome (macOS, Ubuntu)
  • Firefox (macOS, Ubuntu)
  • Safari
  • MSEdge (macOS)

Additional notes

When reviewing, it will be easier to understand if you check the commits (patches) in order. The commits are split to help clarify how the feature was implemented. Please combine them into one commit when merging this feature.

Screenshots

When using CommonMark Markdown, the original message format is almost preserved:

When using Textile, the original message format is not preserved:


Files

screenshot1-1.png (20.9 KB) screenshot1-1.png Katsuya HIDAKA, 2024-09-22 12:57
screenshot1-2.png (21.9 KB) screenshot1-2.png Katsuya HIDAKA, 2024-09-22 12:57
screenshot3-2.png (21.9 KB) screenshot3-2.png Katsuya HIDAKA, 2024-09-22 12:57
screenshot2-2.png (71.3 KB) screenshot2-2.png Katsuya HIDAKA, 2024-09-22 12:57
screenshot3-1.png (20.8 KB) screenshot3-1.png Katsuya HIDAKA, 2024-09-22 12:57
screenshot2-1.png (64.5 KB) screenshot2-1.png Katsuya HIDAKA, 2024-09-22 12:57
0001-Add-system-tests-for-the-current-behavior.patch (4.5 KB) 0001-Add-system-tests-for-the-current-behavior.patch Katsuya HIDAKA, 2024-09-22 13:00
0002-Implement-and-use-JS-function-to-handle-quote-reply.patch (6.93 KB) 0002-Implement-and-use-JS-function-to-handle-quote-reply.patch Katsuya HIDAKA, 2024-09-22 13:01
0003-Add-the-ability-to-quote-partial-text.patch (14.3 KB) 0003-Add-the-ability-to-quote-partial-text.patch Katsuya HIDAKA, 2024-09-22 13:01
0004-Separate-the-quote-reply-implementation-into-quote_reply.js.patch (4.98 KB) 0004-Separate-the-quote-reply-implementation-into-quote_reply.js.patch Katsuya HIDAKA, 2024-09-22 13:01
0005-Separate-helpers-for-the-quote-reply-into-the-Redmine-QuoteReply.patch (9.4 KB) 0005-Separate-helpers-for-the-quote-reply-into-the-Redmine-QuoteReply.patch Katsuya HIDAKA, 2024-09-22 13:01
0006-Separate-the-implementation-for-building-a-quote-into-Redmine-QuoteReply.patch (4.9 KB) 0006-Separate-the-implementation-for-building-a-quote-into-Redmine-QuoteReply.patch Katsuya HIDAKA, 2024-09-22 13:01
0007-Allow-replying-qith-quotes-in-CommonMark-format.patch (32.9 KB) 0007-Allow-replying-qith-quotes-in-CommonMark-format.patch Katsuya HIDAKA, 2024-09-22 13:01
0008-Modified-to-simpler-implementation-and-improved-code-comments.patch (2.21 KB) 0008-Modified-to-simpler-implementation-and-improved-code-comments.patch Katsuya HIDAKA, 2024-09-22 19:26
Partial-quoting-feature-for-Issues-and-Forums.patch (47.8 KB) Partial-quoting-feature-for-Issues-and-Forums.patch A patch file that combines all patch files (0001...0008-*.patch) Katsuya HIDAKA, 2024-09-23 07:29
screencast-in-commonmark-short.gif (580 KB) screencast-in-commonmark-short.gif Katsuya HIDAKA, 2024-09-28 07:55
Fixed-tests-for-the-partial-quoting-feature-that-randomly-fail.patch (2.39 KB) Fixed-tests-for-the-partial-quoting-feature-that-randomly-fail.patch Katsuya HIDAKA, 2024-10-25 12:52
Actions #2

Updated by Katsuya HIDAKA about 2 months ago

I have added a patch file to simplify the implementation and improve some code comments.

Actions #3

Updated by Katsuya HIDAKA about 2 months ago

To make it easier to try and test this feature in your environment, I have added the patch file that combines all patch files (0001...0008-*.patch).

Actions #4

Updated by Katsuya HIDAKA about 2 months ago

Below is a short screencast demonstrating the functionality: Text formatting is set to CommonMark Markdown.

Also, this patch adds new functionality to the existing quote reply feature but does not change its current behavior, so even after this patch is integrated, the current quote reply functionality that quotes the entire message will continue to work as before.

Please let me know your thoughts on this feature. Any feedback is greatly appreciated.

Actions #5

Updated by Go MAEDA about 1 month ago

  • Category set to UI
  • Target version set to Candidate for next major release

I have been using Redmine for user support for long years, and I have always wanted the ability to partially quote issue descprion or notes. After trying this patch, I found that it works exactly I expected. Additionally, it is especially great when the text formatter is CommonMark Markdown, as the markup is preserved in the quoted text.

Redmine 6.0.0 will introduce several UI improvements such as #23980, #41321, and #41298, and I belive this partial quoting feature would be a great addition to those improvements.

Actions #6

Updated by Go MAEDA about 1 month ago

  • Target version changed from Candidate for next major release to 6.0.0

Setting the target version to 6.0.0.

Actions #7

Updated by Go MAEDA about 1 month ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch in r23107.
Thank you for your contribution.

Actions #8

Updated by Katsuya HIDAKA 22 days ago

I found that some tests for this feature have been failing randomly, so I have attached a patch to fix it. Please review and commit the patch.

Actions #9

Updated by Go MAEDA 22 days ago

Katsuya HIDAKA wrote in #note-8:

I found that some tests for this feature have been failing randomly, so I have attached a patch to fix it. Please review and commit the patch.

Committed the fix in r23162. Thank you.

Actions

Also available in: Atom PDF