Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor: Newline added (core QuillJS Issue) #6318

Closed
Zinoberous opened this issue Apr 6, 2024 · 3 comments
Closed

Editor: Newline added (core QuillJS Issue) #6318

Zinoberous opened this issue Apr 6, 2024 · 3 comments
Labels
Resolution: Duplicate Issue has already been reported or a pull request related to same issue has already been submitted

Comments

@Zinoberous
Copy link

Describe the bug

I've identified a persistent issue with the PrimeReact Editor, which seems to stem from its underlying use of Quill, similar to an issue reported for ngx-quill (see KillerCodeMonkey/ngx-quill#357). When I insert an HTML string that combines text and a list into the editor's value, Quill automatically inserts an extra newline between the text and the list. Subsequently, editing and saving this content results in the newline being included in the onTextChanged event's output. This leads to an accumulation of newlines with each save and reload cycle, increasing the space between the text and list unnecessarily. This behavior persists and compounds, adding one additional newline with every save and load operation

Reproducer

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

PrimeReact version

latest

React version

18.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

import React, { useState } from 'react';
import { Editor, EditorTextChangeEvent } from 'primereact/editor';

export default function BasicDemo() {
  const [text, setText] = useState<string>('<p>Test</p><ul><li>a</li><li>b</li></ul>');

  return (
    <div className="card">
      <Editor
        value={text} // gets interpreted as <p>Test</p><p><br/></p><ul><li>a</li><li>b</li></ul>
        onTextChange={(e: EditorTextChangeEvent) => {
          console.log(e);
          setText(e.htmlValue);
        }}
        style={{ height: '320px' }}
      />
    </div>
  );
}

Expected behavior

No response

@Zinoberous Zinoberous added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Apr 6, 2024
@melloware
Copy link
Member

melloware commented Apr 6, 2024

I assume this is a Quill issue not a PrimeReact issue?

@melloware melloware added Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Apr 6, 2024
@melloware melloware changed the title Newline added to Editor Editor: Newline added (core QuillJS Issue) Apr 6, 2024
@Zinoberous
Copy link
Author

After conducting several tests, I have determined that the issue stems from the 1.x version series of Quill. However, I'm facing challenges with integrating the pre-release 2.x version of Quill into PrimeReact. Specifically, the main problem is that I can no longer set the 'value' property of the PrimeReact Editor when using Quill v2.x. I'm unsure if this integration is feasible or how to proceed with it.

Quill v1.x:

Playground => https://v1.quilljs.com/playground/

var quill = new Quill('#editor-container', {
  modules: {
    toolbar: [
      [{ header: [1, 2, false] }],
      ['bold', 'italic', 'underline'],
      ['image', 'code-block']
    ]
  },
  placeholder: 'Compose an epic...',
  theme: 'snow'  // or 'bubble'
});

const value = '<div>test</div><ul><li>1</li><li>2</li></ul>';

const delta = quill.clipboard.convert(value);

console.log(delta)

quill.setContents(delta, 'silent');

image

Qull v2.x:

Playground => https://quilljs.com/playground/snow

const quill = new Quill('#editor', {
  modules: {
    toolbar: [
      [{ header: [1, 2, false] }],
      ['bold', 'italic', 'underline'],
      ['image', 'code-block'],
    ],
  },
  placeholder: 'Compose an epic...',
  theme: 'snow', // or 'bubble'
});

const value = '<div>test</div><ul><li>1</li><li>2</li></ul>';

const delta = quill.clipboard.convert({ html: value });

console.log(delta)

quill.setContents(delta, 'silent');

image

@melloware
Copy link
Member

See #5960

@melloware melloware added Resolution: Duplicate Issue has already been reported or a pull request related to same issue has already been submitted and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Apr 6, 2024
@melloware melloware closed this as not planned Won't fix, can't repro, duplicate, stale Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Duplicate Issue has already been reported or a pull request related to same issue has already been submitted
Projects
None yet
Development

No branches or pull requests

2 participants