Project

General

Profile

Actions

Feature #41294

open

Partial quoting feature for Issues and Forums

Added by Katsuya HIDAKA 5 days ago. Updated 4 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:

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
Actions #2

Updated by Katsuya HIDAKA 4 days ago

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

Actions #3

Updated by Katsuya HIDAKA 4 days 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

Also available in: Atom PDF