Skip to content

Commit

Permalink
feat(editor): add button on hover
Browse files Browse the repository at this point in the history
  • Loading branch information
akiva10b committed Jul 25, 2023
1 parent aa88990 commit 7e17efb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions static/css/s2.css
Original file line number Diff line number Diff line change
Expand Up @@ -9500,6 +9500,7 @@ span.purim-emoji img{
position: relative;
pointer-events:none;
background-color: transparent;
margin-left: 50px;
}
.editorAddInterface:before {
content: "";
Expand Down
10 changes: 8 additions & 2 deletions static/js/Editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1062,12 +1062,14 @@ const AddInterface = ({ attributes, children, element }) => {

const Element = (props) => {
const { attributes, children, element } = props;
const [isHovering, setIsHovering] = useState(false);
const sheetItemClasses = {
sheetItem: 1,
empty: !(Node.string(element)),
highlight: (useSlate().highlightedNode === (element.node ? element.node.toString() : null))
};


switch (element.type) {
case 'spacer':
const spacerSelected = useSelected();
Expand All @@ -1077,8 +1079,12 @@ const Element = (props) => {
empty: 1
}
return (
<div className={classNames(spacerClasses)} {...attributes}>
{spacerSelected && document.getSelection().isCollapsed ? <AddInterface {...props} /> : <>{children}</>}
<div className={classNames(spacerClasses)}
onMouseEnter={() => setIsHovering(true)}
onMouseLeave={() => setIsHovering(false)}
{...attributes}>
{isHovering && <AddInterface {...props} />}
{children}
</div>
);
case 'SheetSource':
Expand Down
2 changes: 1 addition & 1 deletion static/test/linker_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<p dir="rtl">השתדרות ד פועל</p>
<p dir="rtl">Hebrew Ranges</p>
<p dir="rtl">שמות, כ"ד, יג - יד</p>
<p dir="rtl">שמות, כ"ד, יג-יד</p>
<p dir="rtl">שמות, כ"ד, יג-יד</p>
<p dir="rtl">במדבר, כ"ז, טו - כג</p>
<p dir="rtl">בראשית א לא - ב ו</p>
<p dir="rtl">(en dash) בראשית א לא – ב ו</p>
Expand Down

0 comments on commit 7e17efb

Please sign in to comment.