Skip to content
Snippets Groups Projects
Commit d7d63d38 authored by chris's avatar chris
Browse files

position

parent c86a1533
No related branches found
No related tags found
1 merge request!413Image alt text
......@@ -16,18 +16,39 @@ export default ({ setPosition, position }) => {
const readOnly = !isEditable;
const StyledInputAlt = styled.input`
background: #e2ebff;
border: none;
box-sizing: border-box;
width: 240px;
min-height: 20px;
padding: 4px;
&:focus {
outline: none;
}
&::placeholder {
color: black;
font-weight: bold;
}
`;
useLayoutEffect(() => {
const WaxSurface = activeView.dom.getBoundingClientRect();
const { selection } = activeView.state;
if (!selection || !selection.node || !selection.node.attrs.id) return;
const imageId = selection.node.attrs.id;
const image = document.querySelector(`[data-id='${imageId}']`);
const imagePosition = image.getBoundingClientRect();
const left = imagePosition.left - WaxSurface.left;
const top = imagePosition.bottom - WaxSurface.top + 10;
const top = imagePosition.bottom - WaxSurface.top - 22;
setPosition({ ...position, left, top });
console.log(position);
}, [position.left]);
if (!readOnly) {
return <input type="text" />;
return <StyledInputAlt placeholder="Alt Text" type="text" />;
}
};
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment