# Feature OP-13369 - Convert Selected Text in WYSIWYG Editor to Code Block

Project: OpenProject
Status: new
URL: https://community.openproject.org/work_packages/OP-13369

## Planning

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Target versions | Wish List |
| Sprint |  |
| Backlog bucket |  |
| Votes | 1 |
| List |  |
| Roadmap |  |
| Relevance |  |

## OPEN POINTS / FEEDBACK

_No work packages_

## Features and Chunks

_No work packages_

## Bugs and other work packages

_No work packages_

## Technical Details

| Attribute | Value |
| --- | --- |
| Module |  |
| Feature Flag |  |
| Requires doc change | No |
| Enterprise plan |  |

## Details

| Attribute | Value |
| --- | --- |
| Pull preview |  |
| Mockups |  |
| Accessibility | No |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Feature Lead |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Estimates and progress

| Attribute | Value |
| --- | --- |
| PD (min) |  |
| PD (max) |  |
| Work |  |
| Labor costs |  |

## Description

**As** an OPN user  
**I want to** *be able to convert selected text into a code block by clicking the "code block" icon*  
**so that** *the code block icon behaves similar to the "inline code" icon or other text formatting icons (quote, bold, lists, ...) and I don't need to cut the text from the editor, add the empty codeblock, and paste the text again.*

**Acceptance criteria**

  - *I select a part of text in the WYSIWYG editor.*
  - *I click the "code block" symbol bar icon.*
  - *The code block dialog is prefilled with the selected text, and the original selected text is removed from the WYSIWYG editor.*
      - *(Directly inserting the code block with default settings, skipping the popup dialog would also be fine with me.)*
  - *After confirming the dialog, the new code block with the originally selected text, now formatted as a code block, is inserted into the editor.*
      - *If the code block editor is cancelled, the editor's contents should probably stay unchanged, including the selected text.*

This would save some clicks and feel more consistent with the behaviour of the other formatting options like quotation, text highlighting, etc.

Not sure if some similar functionality would also make sense for the "add table" feature. Probably less than for code blocks.
