primefaces / primereact

The Most Complete React UI Component Library
https://primereact.org
MIT License
6.82k stars 1.04k forks source link

Editor: Formating of inserted HTML getting lost #7018

Closed Zinoberous closed 1 month ago

Zinoberous commented 2 months ago

Describe the bug

If I load the editor with an HTML value, the formatting gets lost.

Excample: `import React, { useState } from 'react'; import { Editor, EditorTextChangeEvent } from 'primereact/editor'; import 'primereact/resources/themes/lara-dark-cyan/theme.css';

export default function BasicDemo() { const [text, setText] = useState( '

public class Test
{
public int Id { get; init; }
public required string Name { get; set; }
}
' );

return (

{ console.log(e.htmlValue); setText(e.htmlValue); }} style={{ height: '320px' }} />

); }`

Expected: public class Test { public int Id { get; init; } public required string Name { get; set; } }

Actual: public class Test { public int Id { get; init; } public required string Name { get; set; } }

Reproducer

https://stackblitz.com/edit/dinceg-vsr25m?file=src%2FApp.tsx

System Information

PrimeReact: 10.8.2 Browser: Chrome (127.0.6533.100)

Steps to reproduce the behavior

No response

Expected behavior

No response

melloware commented 2 months ago

@avasuro can you check this i think it might be related to your fix for: https://github.com/primefaces/primereact/issues/6936

avasuro commented 1 month ago

@melloware

  1. Primereact version is outdated in this demo - old primereact version is in package-lock.json
  2. Old Quill version is used in this demo (v1, while latest primereact supports V2+)
  3. To properly show styles inside quill editor you have to import quill styles: import 'quill/dist/quill.snow.css';

After fixing all above looks like this issue no longer reproduces: https://stackblitz.com/edit/dinceg-jd5re4?file=src%2FApp.tsx

Zinoberous commented 1 month ago

Still the same Problem (I local use the right version my fail with the wrong version in the example ^^'):

Change The Text with indentations and press "Test" twice: https://stackblitz.com/edit/dinceg-orwe1p?file=src%2FApp.tsx,package.json

Before: image

After: image