Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.quill.root.addEventListener('keydown', (evt) => {
if (evt.defaultPrevented) return;
let which = evt.which || evt.keyCode;
let bindings = (this.bindings[which] || []).filter(function(binding) {
return Keyboard.match(evt, binding);
});
if (bindings.length === 0) return;
let range = this.quill.getSelection();
if (range == null || !this.quill.hasFocus()) return;
let [line, offset] = this.quill.scroll.line(range.index);
let [leafStart, offsetStart] = this.quill.scroll.leaf(range.index);
let [leafEnd, offsetEnd] = range.length === 0 ? [leafStart, offsetStart] : this.quill.scroll.leaf(range.index + range.length);
let prefixText = leafStart instanceof Parchment.Text ? leafStart.value().slice(0, offsetStart) : '';
let suffixText = leafEnd instanceof Parchment.Text ? leafEnd.value().slice(offsetEnd) : '';
let curContext = {
collapsed: range.length === 0,
empty: range.length === 0 && line.length() <= 1,
format: this.quill.getFormat(range),
offset: offset,
prefix: prefixText,
suffix: suffixText
};
let prevented = bindings.some((binding) => {
if (binding.collapsed != null && binding.collapsed !== curContext.collapsed) return false;
if (binding.empty != null && binding.empty !== curContext.empty) return false;
if (binding.offset != null && binding.offset !== curContext.offset) return false;
if (Array.isArray(binding.format)) {
// any format is present
if (binding.format.every(function(name) {
this.quill.root.addEventListener('keydown', (evt) => {
if (evt.defaultPrevented) return;
let which = evt.which || evt.keyCode;
let bindings = (this.bindings[which] || []).filter(function(binding) {
return Keyboard.match(evt, binding);
});
if (bindings.length === 0) return;
let range = this.quill.getSelection();
if (range == null || !this.quill.hasFocus()) return;
let [line, offset] = this.quill.getLine(range.index);
let [leafStart, offsetStart] = this.quill.getLeaf(range.index);
let [leafEnd, offsetEnd] = range.length === 0 ? [leafStart, offsetStart] : this.quill.getLeaf(range.index + range.length);
let prefixText = leafStart instanceof Parchment.Text ? leafStart.value().slice(0, offsetStart) : '';
let suffixText = leafEnd instanceof Parchment.Text ? leafEnd.value().slice(offsetEnd) : '';
let curContext = {
collapsed: range.length === 0,
empty: range.length === 0 && line.length() <= 1,
format: this.quill.getFormat(range),
offset: offset,
prefix: prefixText,
suffix: suffixText
};
let prevented = bindings.some((binding) => {
if (binding.collapsed != null && binding.collapsed !== curContext.collapsed) return false;
if (binding.empty != null && binding.empty !== curContext.empty) return false;
if (binding.offset != null && binding.offset !== curContext.offset) return false;
if (Array.isArray(binding.format)) {
// any format is present
if (binding.format.every(function(name) {
this.quill.root.addEventListener('keydown', (evt) => {
if (evt.defaultPrevented) return;
let which = evt.which || evt.keyCode;
let bindings = (this.bindings[which] || []).filter(function(binding) {
return Keyboard.match(evt, binding);
});
if (bindings.length === 0) return;
let range = this.quill.getSelection();
if (range == null || !this.quill.hasFocus()) return;
let [line, offset] = this.quill.getLine(range.index);
let [leafStart, offsetStart] = this.quill.getLeaf(range.index);
let [leafEnd, offsetEnd] = range.length === 0 ? [leafStart, offsetStart] : this.quill.getLeaf(range.index + range.length);
let prefixText = leafStart instanceof Parchment.Text ? leafStart.value().slice(0, offsetStart) : '';
let suffixText = leafEnd instanceof Parchment.Text ? leafEnd.value().slice(offsetEnd) : '';
let curContext = {
collapsed: range.length === 0,
empty: range.length === 0 && line.length() <= 1,
format: this.quill.getFormat(range),
offset: offset,
prefix: prefixText,
suffix: suffixText
};
let prevented = bindings.some((binding) => {
if (binding.collapsed != null && binding.collapsed !== curContext.collapsed) return false;
if (binding.empty != null && binding.empty !== curContext.empty) return false;
if (binding.offset != null && binding.offset !== curContext.offset) return false;
if (Array.isArray(binding.format)) {
// any format is present
if (binding.format.every(function(name) {
return curContext.format[name] == null;
this.quill.root.addEventListener('keydown', (evt) => {
if (evt.defaultPrevented) return;
let which = evt.which || evt.keyCode;
let bindings = (this.bindings[which] || []).filter(function(binding) {
return Keyboard.match(evt, binding);
});
if (bindings.length === 0) return;
let range = this.quill.getSelection();
if (range == null || !this.quill.hasFocus()) return;
let [line, offset] = this.quill.scroll.line(range.index);
let [leafStart, offsetStart] = this.quill.scroll.leaf(range.index);
let [leafEnd, offsetEnd] = range.length === 0 ? [leafStart, offsetStart] : this.quill.scroll.leaf(range.index + range.length);
let prefixText = leafStart instanceof Parchment.Text ? leafStart.value().slice(0, offsetStart) : '';
let suffixText = leafEnd instanceof Parchment.Text ? leafEnd.value().slice(offsetEnd) : '';
let curContext = {
collapsed: range.length === 0,
empty: range.length === 0 && line.length() <= 1,
format: this.quill.getFormat(range),
offset: offset,
prefix: prefixText,
suffix: suffixText
};
let prevented = bindings.some((binding) => {
if (binding.collapsed != null && binding.collapsed !== curContext.collapsed) return false;
if (binding.empty != null && binding.empty !== curContext.empty) return false;
if (binding.offset != null && binding.offset !== curContext.offset) return false;
if (Array.isArray(binding.format)) {
// any format is present
if (binding.format.every(function(name) {
return curContext.format[name] == null;