slab / quill

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

Keyboard module: no format clear for new empty lines when pressed Enter key two times #1852

Open eleave opened 6 years ago

eleave commented 6 years ago

I read documentation about Keyboard module and tried to clear blockquote format when user press Enter two times on empty lines (as it works with lists or code formats): https://quilljs.com/docs/modules/keyboard/#empty

But it does not work. New empty blockquotes in editor still here. I added console.log to watch any behavior, - no reaction. Am I do something wrong or is it a bug?

Steps for Reproduction

  1. Visit https://quilljs.com/playground/
  2. Add code below to Interactive Playground editor
  3. Type some words and make an quote, then press Enter key for two times or more.
console.log('start here - v' + Quill.version);
var quill = new Quill('#editor-container', {
  modules: {
    toolbar: [
      [{ header: [1, 2, false] }],
      ['bold', 'italic', 'underline'],
      ['image', 'code-block'],
      [{ list: 'ordered' }, 'blockquote']
    ]
  },
  placeholder: 'Compose an epic...',
  theme: 'snow'  // or 'bubble'
});

// If the user hits enter on an empty list, remove the list instead
quill.keyboard.addBinding({ key: 13 }, {
  empty: true,    // implies collapsed: true and offset: 0
  format: ['list', 'blockquote']
}, function(range, context) {
  console.log('reset format', range, context);
  this.quill.format('list', false);
  this.quill.format('blockquote', false);
});

iplaygrnd

Expected behavior: Clear blockquote format on new line as it works with lists or code-block

Actual behavior: No keyboard binding (no logs in console) blockquote format is still activated and add new empty quotes

Platforms: Chrome Version 62.0.3202.94 Windows 10

Version: v1.3.4

DmitrySkripkin commented 6 years ago

Wierd. This codePen works fine.

cmditch commented 4 years ago

There seems to be a difference between adding "Enter" bindings in the Quill config and with addBinding. The latter doesn't work.