slab / quill

Quill is a modern WYSIWYG editor built for compatibility and extensibility
https://quilljs.com
BSD 3-Clause "New" or "Revised" License
43.5k stars 3.38k forks source link

How to disable splitting of code block in Quill? #4448

Open aerjotl opened 4 days ago

aerjotl commented 4 days ago

I am implementing a custom editor using Quill 2.0.2. I want it to act as a code editor with syntax highlighting for my own custom language.

I have added highlight.js implementation and the highlighting is working as expected. The problem is when I add multiple newlines in the editor the code block "splits" into two separate blocks. Does anyone know how to disable it? I want users to be able to edit inside the code block only.

Are there any other ideas for forcing Quill to be a code editor? I know that there are other code editors out there, but we are using Quill in several other places on our website and we would like to keep the user experience consistent.

babu-ch commented 3 days ago

try this

  const quill = new Quill('#editor', {
    modules: {
      syntax: true,
      toolbar: '#toolbar-container',
      keyboard: {
            bindings: {
              "code exit": null,
            },
      }
    },
    placeholder: 'Compose an epic...',
    theme: 'snow',
  });

Or you can adjust the binding of Enter yourself.