How to use the quill-delta/lib/op.attributes function in quill-delta

To help you get started, we’ve selected a few quill-delta examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dost / quilljs-table / quilljs-source-code / modules / keyboard.js View on Github external
function handleBackspace(range, context) {
  if (handleTables(range, this.quill)) return true; // handle tables
  if (range.index === 0) return;
  let [line, ] = this.quill.getLine(range.index);
  let formats = {};
  if (context.offset === 0) {
    let curFormats = line.formats();
    let prevFormats = this.quill.getFormat(range.index-1, 1);
    formats = DeltaOp.attributes.diff(curFormats, prevFormats) || {};
  }
  // Check for astral symbols
  let length = /[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(context.prefix) ? 2 : 1;
  this.quill.deleteText(range.index-length, length, Quill.sources.USER);
  if (Object.keys(formats).length > 0) {
    this.quill.formatLine(range.index-length, length, formats, Quill.sources.USER);
  }
  this.quill.selection.scrollIntoView();
}
github quilljs / quill / modules / keyboard.js View on Github external
function handleDeleteRange(range) {
  const lines = this.quill.getLines(range);
  let formats = {};
  if (lines.length > 1) {
    const firstFormats = lines[0].formats();
    const lastFormats = lines[lines.length - 1].formats();
    formats = DeltaOp.attributes.diff(lastFormats, firstFormats) || {};
  }
  this.quill.deleteText(range, Quill.sources.USER);
  if (Object.keys(formats).length > 0) {
    this.quill.formatLine(range.index, 1, formats, Quill.sources.USER);
  }
  this.quill.setSelection(range.index, Quill.sources.SILENT);
  this.quill.focus();
}
github webiny / Webiny / Js / Webiny / Assets / node_modules / quill / modules / keyboard.js View on Github external
function handleBackspace(range, context) {
  if (range.index === 0) return;
  let [line, ] = this.quill.scroll.line(range.index);
  let formats = {};
  if (context.offset === 0) {
    let curFormats = line.formats();
    let prevFormats = this.quill.getFormat(range.index-1, 1);
    formats = DeltaOp.attributes.diff(curFormats, prevFormats) || {};
  }
  this.quill.deleteText(range.index-1, 1, Quill.sources.USER);
  if (Object.keys(formats).length > 0) {
    this.quill.formatLine(range.index-1, 1, formats, Quill.sources.USER);
  }
  this.quill.selection.scrollIntoView();
}

quill-delta

Format for representing rich text documents and changes.

BSD-3-Clause
Latest version published 2 years ago

Package Health Score

74 / 100
Full package analysis