Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
} 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
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
}
}
}
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);
}
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);
}
},
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);
}
}
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);
}
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);
});
}
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);
}
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()
)
}
},