Add support for bullet list hotkey

This commit is contained in:
Ilia Ross
2023-10-03 18:55:38 +03:00
parent 51bdd0d07e
commit e087bb718c

View File

@@ -277,24 +277,36 @@ my $html_editor_init_script =
theme: 'snow'
});
// Google Mail editor like keybind for quoting
// Google Mail like key bind for creating bullet list (Ctrl+Shift+8)
editor.keyboard.addBinding({
key: '9',
shiftKey: true,
ctrlKey: !isMac,
metaKey: isMac,
format: ['blockquote'],
key: '8',
shiftKey: true,
ctrlKey: !isMac,
metaKey: isMac,
}, function(range, context) {
this.quill.format('blockquote', false);
const currentFormat = this.quill.getFormat(range.index);
if (currentFormat.list === 'bullet') {
this.quill.format('list', false);
} else {
this.quill.format('list', 'bullet');
}
});
// Google Mail like key bind for creating blockquote (Ctrl+Shift+9)
editor.keyboard.addBinding({
key: '9',
shiftKey: true,
ctrlKey: !isMac,
metaKey: isMac,
key: '9',
shiftKey: true,
ctrlKey: !isMac,
metaKey: isMac,
}, function(range, context) {
this.quill.format('blockquote', true);
const currentFormat = this.quill.getFormat(range.index);
if (currentFormat.blockquote) {
this.quill.format('blockquote', false);
} else {
this.quill.format('blockquote', true);
}
});
editor.on('text-change', function() {
// This should most probably go to onSubmit event
targ.value = editor.root.innerHTML + "<br>";