여러 줄을 선택해 '정형화된 텍스트' 서식을 적용할 때 인라인 서식이 적용됩니다

Priority/Severity:

Medium

Platform

Operating System

Windows 11

Browser

Google Chrome 139.0.7258.67

Discourse

dee24bd73b158ba97453f20035eabce430a1abcd

Description:

There are two styles of “preformatted text” formatting:

  • inline: for use with non-prose content within a prose passage (e.g., “call the foo function”), or a single short line of non-prose content.
  • block: for use with multiple lines of non-prose content

The user may take either of two approaches to applying formatting when using the composer:

  • proactive: the formatting mode is toggled prior to adding the content to be formatted
  • retroactive: the content is added in unformatted form, then selected and formatting applied to that selection

:bug: When using the composer in the “rich text editor” mode, applying “preformatted text” formatting retroactively when multiple lines are selected applies the inline style. This results in the post being difficult to read and the non-prose content being difficult to copy (a common requirement for shared code).

Reproducible steps:

  1. Open the composer.

  2. Place the editor mode switch in the “rich text editor” position.

  3. Add the following content to the post:

    void setup() {
      // put your setup code here, to run once:
    
    }
    
    void loop() {
      // put your main code here, to run repeatedly:
    
    }
    
  4. Select the post content.

  5. Click the </> button on the composer toolbar.

:bug: Each of the selected lines was formatted individually in the inline style:

void setup() {

// put your setup code here, to run once:

}

void loop() {

// put your main code here, to run repeatedly:

}

The correct behavior would have been to put the content in a single code block:

void setup() {

  // put your setup code here, to run once:



}



void loop() {

  // put your main code here, to run repeatedly:



}

Additional context

The Markdown editor has the correct behavior of placing the selected content in a code block when “preformatted text” formatting is applied retroactively to a multi-line selection.


I am able to reproduce the fault on try.discourse.org in “safe mode”.

5개의 좋아요

Thank you for the bug report, I can reproduce it.

We’ll work on a fix.

5개의 좋아요

편하신 시간에 다시 테스트해 주시겠어요?

이 PR에서 몇 가지 개선을 했습니다: DEV: make formatCode action more context-aware on rich editor - Pull Request #35362 - discourse/discourse - GitHub

리포트에 제시된 절차를 수행하면 게시물이 이제 예상대로 형식화되는 것을 확인했습니다.

@renato, 수정해 주셔서 정말 감사합니다. 여기에 업데이트를 게시해 주신 시간도 감사드립니다!

1개의 좋아요