Skip to content

Commit

Permalink
Fixed issues with cursor navigation in codeblocks (#915)
Browse files Browse the repository at this point in the history
* Fixed issues with cursor navigation in codeblocks

* Updated styles

* Updated styles
  • Loading branch information
gaagul authored Oct 25, 2023
1 parent bbc2f57 commit 147701d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { SORTED_LANGUAGE_LIST } from "./constants";

const { Menu, MenuItem } = Dropdown;

const CodeBlockComponent = ({ node, updateAttributes }) => {
const CodeBlockComponent = ({ node, editor, updateAttributes }) => {
const [keyword, setKeyword] = useState("");

const { t } = useTranslation();
Expand All @@ -23,6 +23,7 @@ const CodeBlockComponent = ({ node, updateAttributes }) => {
const handleLanguageSelect = language => {
updateAttributes({ language });
setKeyword("");
editor?.commands?.focus();
};

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import CodeBlockComponent from "./CodeBlockComponent";

export default CodeBlockLowlight.extend({
addNodeView() {
return new ReactNodeViewRenderer(CodeBlockComponent);
return ReactNodeViewRenderer(CodeBlockComponent);
},
}).configure({ lowlight });
13 changes: 12 additions & 1 deletion src/styles/editor/_editor-content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,14 @@

.neeto-editor-codeblock-options {
position: absolute;
display: flex;
display: none;
gap: 4px;
align-items: center;
top: 4px;
right: 4px;
transition: opacity 150ms ease-in-out, transform 150ms ease-in-out;
transform: scale(0);
transition-delay: 50ms;

&__menu {
display: flex;
Expand All @@ -110,6 +113,14 @@
margin: 4px 4px;
}
}

&:hover {
.neeto-editor-codeblock-options {
display: flex;
opacity: 1;
transform: scale(1);
}
}
}

pre > code {
Expand Down

0 comments on commit 147701d

Please sign in to comment.