json-joy
Version:
Collection of libraries for building collaborative editing apps.
30 lines (29 loc) • 1.01 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.CharOverlay = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const CharOverlay = ({ rectRef, ...rest }) => {
const ref = React.useRef(null);
// biome-ignore lint: lint/correctness/useExhaustiveDependencies
React.useEffect(() => {
rectRef.current = (rect) => {
const span = ref.current;
if (!span)
return;
const style = span.style;
if (rect) {
style.top = rect.y + 'px';
style.left = rect.x + 'px';
style.width = rect.width + 'px';
style.height = rect.height + 'px';
style.visibility = 'visible';
}
else {
style.visibility = 'hidden';
}
};
}, []);
return React.createElement("span", { ...rest, ref: ref });
};
exports.CharOverlay = CharOverlay;
;