-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add check icon to indicate current line spacing of selection
- Loading branch information
1 parent
702ee66
commit 0f62b36
Showing
4 changed files
with
65 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from "react" | ||
import SvgIcon from "@material-ui/core/SvgIcon" | ||
|
||
const CheckIcon = () => { | ||
return ( | ||
<SvgIcon> | ||
<path d="M0 0h24v24H0z" fill="none" /> | ||
<path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z" /> | ||
</SvgIcon> | ||
) | ||
} | ||
|
||
export default CheckIcon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Editor, Path, Node } from "slate" | ||
|
||
/** | ||
* getLineSpacing is a helper function that finds the line spacing for the currently | ||
* selected node. | ||
*/ | ||
const getLineSpacing = (editor: Editor) => { | ||
if (!editor.selection) { | ||
return "1.5" | ||
} | ||
|
||
// need to get the parent path in order to get the parent node above this selection | ||
const currentPath = editor.selection.anchor.path | ||
const parentPath = Path.parent(currentPath) | ||
const node = Node.get(editor, parentPath) | ||
|
||
return node.lineSpacing || "1.5" | ||
} | ||
|
||
export default getLineSpacing |