Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
format(format, value) {
this.scroll.update();
const nativeRange = this.getNativeRange();
if (
nativeRange == null ||
!nativeRange.native.collapsed ||
this.scroll.query(format, Scope.BLOCK)
)
return;
if (nativeRange.start.node !== this.cursor.textNode) {
const blot = this.scroll.find(nativeRange.start.node, false);
if (blot == null) return;
// TODO Give blot ability to not split
if (blot instanceof LeafBlot) {
const after = blot.split(nativeRange.start.offset);
blot.parent.insertBefore(this.cursor, after);
} else {
blot.insertBefore(this.cursor, nativeRange.start.node); // Should never happen
}
this.cursor.attach();
}
this.cursor.format(format, value);
this.scroll.optimize();
(formats, format) => {
if (
this.quill.scroll.query(format, Scope.BLOCK) &&
!Array.isArray(context.format[format])
) {
formats[format] = context.format[format];
}
return formats;
},
{},
return Object.keys(lastOp.attributes).some(attr => {
return scroll.query(attr, Scope.BLOCK) != null;
});
}
return Object.keys(lastOp.attributes).some(attr => {
return scroll.query(attr, Scope.BLOCK) != null;
});
}
insertAt(index, value, def) {
if (index >= this.length()) {
if (def == null || this.scroll.query(value, Scope.BLOCK) == null) {
const blot = this.scroll.create(this.statics.defaultChild.blotName);
this.appendChild(blot);
if (def == null && value.endsWith('\n')) {
blot.insertAt(0, value.slice(0, -1), def);
} else {
blot.insertAt(0, value, def);
}
} else {
const embed = this.scroll.create(value, def);
this.appendChild(embed);
}
} else {
super.insertAt(index, value, def);
}
this.optimize();
}
(formats, format) => {
if (
this.quill.scroll.query(format, Scope.BLOCK) &&
!Array.isArray(context.format[format])
) {
formats[format] = context.format[format];
}
return formats;
},
{},
formatAt(index, length, name, value) {
if (length <= 0) return;
if (this.scroll.query(name, Scope.BLOCK)) {
if (index + length === this.length()) {
this.format(name, value);
}
} else {
super.formatAt(
index,
Math.min(length, this.length() - index - 1),
name,
value,
);
}
this.cache = {};
}