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

Also available in: Atom PDF