Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else {
value = selected.value || false;
}
} else {
if (input.classList.contains('ql-active')) {
value = false;
} else {
value = input.value || !input.hasAttribute('value');
}
e.preventDefault();
}
this.quill.focus();
let [range, ] = this.quill.selection.getRange();
if (this.handlers[format] != null) {
this.handlers[format].call(this, value);
} else if (Parchment.query(format).prototype instanceof Parchment.Embed) {
value = prompt(`Enter ${format}`);
if (!value) return;
this.quill.updateContents(new Delta()
.retain(range.index)
.delete(range.length)
.insert({ [format]: value })
, Quill.sources.USER);
} else {
this.quill.format(format, value, Quill.sources.USER);
}
this.update(range);
});
// TODO use weakmap
} else {
value = selected.value || false;
}
} else {
if (input.classList.contains('ql-active')) {
value = false;
} else {
value = input.value || !input.hasAttribute('value');
}
e.preventDefault();
}
this.quill.focus();
let [range, ] = this.quill.selection.getRange();
if (this.handlers[format] != null) {
this.handlers[format].call(this, value);
} else if (Parchment.query(format).prototype instanceof Parchment.Embed) {
value = prompt(`Enter ${format}`);
if (!value) return;
this.quill.updateContents(new Delta()
.retain(range.index)
.delete(range.length)
.insert({ [format]: value })
, Quill.sources.USER);
} else {
this.quill.format(format, value, Quill.sources.USER);
}
this.update(range);
});
// TODO use weakmap
} else {
value = selected.value || false;
}
} else {
if (input.classList.contains('ql-active')) {
value = false;
} else {
value = input.value || !input.hasAttribute('value');
}
e.preventDefault();
}
this.quill.focus();
const [range] = this.quill.selection.getRange();
if (this.handlers[format] != null) {
this.handlers[format].call(this, value);
} else if (Parchment.query(format).prototype instanceof Parchment.Embed) {
value = prompt(`Enter ${format}`); // eslint-disable-line no-alert
if (!value) return;
this.quill.updateContents(
new Delta()
.retain(range.index)
.delete(range.length)
.insert({ [format]: value }),
Quill.sources.USER,
);
} else {
this.quill.format(format, value, Quill.sources.USER);
}
this.update(range);
});
this.controls.push([format, input]);
} else {
value = selected.value || false;
}
} else {
if (input.classList.contains('ql-active')) {
value = false;
} else {
value = input.value || !input.hasAttribute('value');
}
e.preventDefault();
}
this.quill.focus();
let [range, ] = this.quill.selection.getRange();
if (this.handlers[format] != null) {
this.handlers[format].call(this, value);
} else if (Parchment.query(format).prototype instanceof Parchment.Embed && Parchment.query(format).blotName != 'table' && Parchment.query(format).blotName != 'embed_table') {
value = prompt(`Enter ${format}`);
if (!value) return;
this.quill.updateContents(new Delta()
.retain(range.index)
.delete(range.length)
.insert({ [format]: value })
, Quill.sources.USER);
} else {
this.quill.format(format, value, Quill.sources.USER);
}
this.update(range);
});
// TODO use weakmap
[].slice.call(this.domNode.querySelectorAll('*')).forEach(function(node) {
let blot = Parchment.find(node);
if (blot == null) {
node.parentNode.removeChild(node);
} else if (blot instanceof Parchment.Embed) {
blot.remove();
} else {
blot.unwrap();
}
});
}
import Parchment from 'parchment';
import TextBlot from './text';
const GUARD_TEXT = "\uFEFF";
class Embed extends Parchment.Embed {
constructor(node) {
super(node);
this.contentNode = document.createElement('span');
this.contentNode.setAttribute('contenteditable', false);
[].slice.call(this.domNode.childNodes).forEach((childNode) => {
this.contentNode.appendChild(childNode);
});
this.leftGuard = document.createTextNode(GUARD_TEXT);
this.rightGuard = document.createTextNode(GUARD_TEXT);
this.domNode.appendChild(this.leftGuard);
this.domNode.appendChild(this.contentNode);
this.domNode.appendChild(this.rightGuard);
}
index(node, offset) {
if (node === this.leftGuard) return 0;
Image.create = function(value) {
let node = Parchment.Embed.create.call(Image);
if (typeof value === 'string') {
node.setAttribute('src', value);
}
return node;
};
function matchBlot(node, delta) {
let match = Parchment.query(node);
if (match == null) return delta;
if (match.prototype instanceof Parchment.Embed) {
let embed = {};
let value = match.value(node);
if (value != null) {
embed[match.blotName] = value;
delta = new Delta().insert(embed, match.formats(node));
}
} else if (typeof match.formats === 'function') {
let formats = { [match.blotName]: match.formats(node) };
delta = delta.compose(new Delta().retain(delta.length(), formats));
}
return delta;
}
import Parchment from 'parchment';
class Break extends Parchment.Embed {
static value() {
return undefined;
}
insertInto(parent, ref) {
if (parent.children.length === 0) {
super.insertInto(parent, ref);
} else {
this.remove();
}
}
length() {
return 0;
}
import Parchment from 'parchment';
import logger from '../core/logger';
let debug = logger('quill:embed');
class Embed extends Parchment.Embed {
format(name, value) {
debug.warn('Ignoring formatting embed with', name, value);
}
formats() {
return {};
}
}
export default Embed;