Skip to content

Commit 49879e5

Browse files
BHulovatyiom-ukrcabella-dot
authored
Axon 1943 issue with tasks descriptions having inconsistent format (#1657)
* AXON-1943: Fixed link display in edit mode * AXON-1943: Fixed issue description losing line breaks * AXON-1943: Update solution, added @atlaskit/editor-markdown-transformer * AXON-1943: Update solution, remove @atlaskit/editor-markdown-transformer * AXON-1943: added JSONTransformer * AXON-1943: clean code * fix changelog --------- Co-authored-by: Oleksandr Mazepa <omazepa@atlassian.com> Co-authored-by: Christian Abella <cabella@atlassian.com>
1 parent 2093ee3 commit 49879e5

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
### [Report an Issue](https://github.com/atlassian/atlascode/issues)
22

3+
## What's new in 4.0.21
4+
5+
### Bug fixes
6+
7+
- Fixed issue description losing line breaks and formatting in edit mode after save (HTML-to-ADF conversion now preserves line breaks as hardBreak nodes)
8+
39
## What's new in 4.0.20
410

511
### Features

src/webviews/components/issue/common/adfToWikimarkup.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { JSONTransformer } from '@atlaskit/editor-json-transformer';
12
import { WikiMarkupTransformer } from '@atlaskit/editor-wikimarkup-transformer';
23

34
// ADF (Atlassian Document Format) node structure
@@ -85,17 +86,15 @@ export function convertAdfToWikimarkup(adf: AdfNode | string | null | undefined)
8586
// Check if it's valid ADF
8687
if (adfDoc && adfDoc.type === 'doc' && adfDoc.version === 1) {
8788
try {
88-
// Validate ADF structure before transformation
8989
if (!adfDoc.content || !Array.isArray(adfDoc.content)) {
9090
console.warn('Invalid ADF structure: missing or invalid content array');
9191
return extractPlainTextFromAdf(adfDoc);
9292
}
9393

94-
// WikiMarkupTransformer provides its own schema
95-
const transformer = new WikiMarkupTransformer();
96-
// Convert ADF to WikiMarkup
97-
const wikimarkup = transformer.encode(adfDoc);
98-
return wikimarkup;
94+
const jsonTransformer = new JSONTransformer();
95+
const pmNode = jsonTransformer.parse(adfDoc);
96+
const wikiTransformer = new WikiMarkupTransformer();
97+
return wikiTransformer.encode(pmNode);
9998
} catch (transformError) {
10099
console.warn('WikiMarkup transformer failed, falling back to plain text extraction:', transformError);
101100
// Fallback to plain text extraction

src/webviews/components/issue/view-issue-screen/mainpanel/IssueMainPanel.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,20 @@ const IssueMainPanel: React.FC<Props> = ({
9292

9393
// Use centralized editor state
9494
const { openEditor, closeEditor, isEditorActive } = useEditorState();
95-
// Handle descriptionText - convert ADF object to appropriate format for editor
95+
// Use raw description (ADF or string) for the editor; no HTML→ADF conversion.
9696
const getDescriptionTextForEditor = React.useCallback(() => {
9797
if (
9898
typeof defaultDescription === 'object' &&
99+
defaultDescription !== null &&
99100
defaultDescription.version === 1 &&
100101
defaultDescription.type === 'doc'
101102
) {
102-
// For new Atlaskit editor: convert ADF to JSON string
103103
if (isAtlaskitEditorEnabled) {
104104
return JSON.stringify(defaultDescription);
105105
}
106-
// For legacy editor: convert ADF to WikiMarkup
107106
return convertAdfToWikimarkup(defaultDescription);
108107
}
109-
return defaultDescription || '';
108+
return typeof defaultDescription === 'string' ? defaultDescription : '';
110109
}, [defaultDescription, isAtlaskitEditorEnabled]);
111110

112111
const [descriptionText, setDescriptionText] = React.useState(() => getDescriptionTextForEditor());

0 commit comments

Comments
 (0)