From 7e17efbeb5e4713c58b4603f8d96b351dd2d0272 Mon Sep 17 00:00:00 2001 From: Akiva Berger Date: Tue, 25 Jul 2023 12:41:44 +0300 Subject: [PATCH] feat(editor): add button on hover --- static/css/s2.css | 1 + static/js/Editor.jsx | 10 ++++++++-- static/test/linker_test.html | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/static/css/s2.css b/static/css/s2.css index 1f147ac52c..0d48648d9a 100644 --- a/static/css/s2.css +++ b/static/css/s2.css @@ -9500,6 +9500,7 @@ span.purim-emoji img{ position: relative; pointer-events:none; background-color: transparent; + margin-left: 50px; } .editorAddInterface:before { content: ""; diff --git a/static/js/Editor.jsx b/static/js/Editor.jsx index f5cba6c6a8..344ec63835 100644 --- a/static/js/Editor.jsx +++ b/static/js/Editor.jsx @@ -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(); @@ -1077,8 +1079,12 @@ const Element = (props) => { empty: 1 } return ( -
- {spacerSelected && document.getSelection().isCollapsed ? : <>{children}} +
setIsHovering(true)} + onMouseLeave={() => setIsHovering(false)} + {...attributes}> + {isHovering && } + {children}
); case 'SheetSource': diff --git a/static/test/linker_test.html b/static/test/linker_test.html index 0b318e8040..49f49e0515 100644 --- a/static/test/linker_test.html +++ b/static/test/linker_test.html @@ -96,7 +96,7 @@

השתדרות ד פועל

Hebrew Ranges

שמות, כ"ד, יג - יד

-

שמות, כ"ד, יג-יד


 +

שמות, כ"ד, יג-יד

במדבר, כ"ז, טו - כג

בראשית א לא - ב ו

(en dash) בראשית א לא – ב ו