How to use the quill.sources function in quill

To help you get started, we’ve selected a few quill 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 sillsdev / web-languageforge / src / angular-app / bellows / apps / translate / editor / quill / suggestions-theme.ts View on Github external
}
        } else {
          const button = input as HTMLButtonElement;
          if (button.classList.contains('ql-active')) {
            value = false;
          } else {
            value = button.value || !input.hasAttribute('value');
          }
          e.preventDefault();
        }
        this.quill.focus();
        const range = this.quill.getSelection();
        if (this.handlers[format] != null) {
          this.handlers[format].call(this, value);
        } else {
          this.quill.format(format, value, Quill.sources.USER);
        }
        this.update(range);
      });
      // TODO use weakmap
github yunlzhang / lcddjmwebsite / src / components / Edit.vue View on Github external
onPaste (e) {
        
        if (e.defaultPrevented || !this.quill.isEnabled()) return;
        let range = this.quill.getSelection()
        let delta = new Delta().retain(range.index)
        let containerHeight = this.quill.container.offsetHeight;
        if (e && e.clipboardData && e.clipboardData.types && e.clipboardData.getData) {
            let text = (e.originalEvent || e).clipboardData.getData('text/plain')
            let cleanedText = this.convert(text)
            // Stop the data from actually being pasted
            e.stopPropagation()
            e.preventDefault()

            // Process cleaned text
            delta = delta.concat(cleanedText).delete(range.length)
            this.quill.updateContents(delta, Quill.sources.USER)
            // range.length contributes to delta.length()
            this.quill.setSelection(delta.length() - range.length, Quill.sources.SILENT)
            document.documentElement.scrollTop += this.quill.container.offsetHeight - containerHeight;
            return false
        }
    }
}
github ximing / weditor / src / lib / initQuill.js View on Github external
setTimeout(() => {
            delta = delta.concat(this.convert()).delete(range.length);
            this.quill.updateContents(delta, Quill.sources.USER);
            // range.length contributes to delta.length()
            this.quill.setSelection(delta.length() - range.length, Quill.sources.SILENT);
            this.quill.scrollingContainer.scrollTop = scrollTop;
            this.quill.focus();
        }, 1);
    }
github morishjs / quill-markdown-toolbar / src / index.js View on Github external
action: (text, pattern, lineStart) => {
          this.quill.deleteText(lineStart, text.length);
          this.quill.insertEmbed(lineStart + 1, 'hr', true, Quill.sources.USER);
          this.quill.insertText(lineStart + 2, "\n", Quill.sources.SILENT);
        }
      },
github contentco / quill-emoji / src / module-emoji.js View on Github external
close(value, trailingDelete = 0) {
    this.quill.enable();
    this.container.style.display = "none";
    while (this.container.firstChild) this.container.removeChild(this.container.firstChild);
    this.quill.off('selection-change', this.onSelectionChange);
    this.quill.off('text-change', this.onTextChange);
    if (value) {
      this.quill.deleteText(this.atIndex, this.query.length + 1 + trailingDelete, Quill.sources.USER);
      this.quill.insertEmbed(this.atIndex, 'emoji', value, Quill.sources.USER);
      setTimeout(() => this.quill.setSelection(this.atIndex + 1), 0);
    }
    this.quill.focus();
    this.open = false;
    this.onClose && this.onClose(value);
  }
}
github davidroyer / vue2-editor / dist / vue2-editor.esm.js View on Github external
setTimeout(function () {
          _this.quill.deleteText(startIndex, text.length);

          _this.quill.insertEmbed(startIndex + 1, "hr", true, Quill.sources.USER);

          _this.quill.insertText(startIndex + 2, "\n", Quill.sources.SILENT);

          _this.quill.setSelection(startIndex + 2, Quill.sources.SILENT);
        }, 0);
      }
github sillsdev / web-languageforge / src / angular-app / bellows / apps / translate / editor / editor.component.ts View on Github external
this.$scope.$applyAsync(() => {
      let index = quill.getSelection(true).index || quill.getLength();
      if (DocumentEditor.isTextEmpty(quill.getText())) {
        index = 0;
      }

      quill.clipboard.dangerouslyPasteHTML(index, html, Quill.sources.USER);
    });
  }
github Graphite-Docs / graphite / src / components / YjsQuill.js View on Github external
setTimeout(() => {
            this.quill.selection.update(Quill.sources.SILENT);
            delta = delta.concat(this.convert()).delete(range.length);
            this.quill.updateContents(delta, Quill.sources.USER);
            this.quill.setSelection(delta.length() - range.length, Quill.sources.SILENT);
            let bounds = this.quill.getBounds(delta.length() - range.length, Quill.sources.SILENT);
            this.quill.scrollingContainer.scrollTop = bounds.top;
          }, 1);
        }
github soccerloway / quill-better-table / src / modules / table-operation-menu.js View on Github external
this.columnToolCells,
        this.boundary,
        (cellRect, boundary) => {
          return Math.abs(cellRect.x + cellRect.width - boundary.x1) <= ERROR_LIMIT
        },
        this.quill.root.parentNode
      )

      const newColumn = tableContainer.insertColumn(
        this.boundary,
        colIndex,
        true,
        this.quill.root.parentNode)

      this.tableColumnTool.updateToolCells()
      this.quill.update(Quill.sources.USER)
      this.quill.setSelection(
        this.quill.getIndex(newColumn[0]),
        0,
        Quill.sources.SILENT
      )
      this.tableSelection.setSelection(
        newColumn[0].domNode.getBoundingClientRect(),
        newColumn[0].domNode.getBoundingClientRect()
      )
    }
  },