@opentiny/fluent-editor
Version:
A rich text editor based on Quill 2.0, which extends rich modules and formats on the basis of Quill. It's powerful and out-of-the-box.
55 lines (54 loc) • 1.92 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
function css(domNode, rules) {
if (typeof rules === "object") {
for (const prop in rules) {
if (prop) {
if (Array.isArray(rules[prop])) {
rules[prop].forEach((val) => {
domNode.style[prop] = val;
});
} else {
domNode.style[prop] = rules[prop];
}
}
}
}
}
function getRelativeRect(targetRect, container) {
const containerRect = container.getBoundingClientRect();
return {
// ie浏览器中getBoundingClientRect输出为left、right、top、bottom,与chrome的x、y不同
x: (targetRect.x || targetRect.left) - (containerRect.x || containerRect.left) - container.scrollLeft,
y: (targetRect.y || targetRect.top) - (containerRect.y || containerRect.top) - container.scrollTop,
x1: (targetRect.x || targetRect.left) - (containerRect.x || containerRect.left) - container.scrollLeft + targetRect.width,
y1: (targetRect.y || targetRect.top) - (containerRect.y || containerRect.top) - container.scrollTop + targetRect.height,
width: targetRect.width,
height: targetRect.height
};
}
const elementRemove = function(node) {
node && node.parentNode && node.parentNode.removeChild(node);
};
const arrayFrom = function(arrayLike, mapFn, thisArg) {
if (!arrayLike) {
throw new TypeError(
"Array.from requires an array-like object - not null or undefined"
);
}
const length = arrayLike.length;
const resArray = [];
for (let i = 0; i < length; i++) {
if (typeof mapFn === "function") {
resArray.push(mapFn.call(thisArg, arrayLike[i]));
} else {
resArray.push(arrayLike[i]);
}
}
return resArray;
};
exports.arrayFrom = arrayFrom;
exports.css = css;
exports.elementRemove = elementRemove;
exports.getRelativeRect = getRelativeRect;
//# sourceMappingURL=index.cjs.js.map