Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
Cleanup, bump serializer for save fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tommoor committed Dec 14, 2018
1 parent ca32834 commit 5d6a322
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"slate-collapse-on-escape": "^0.6.1",
"slate-edit-code": "^0.15.5",
"slate-edit-list": "^0.11.3",
"slate-md-serializer": "^5.2.1",
"slate-md-serializer": "^5.2.2",
"slate-paste-linkify": "^0.5.1",
"slate-plain-serializer": "0.5.4",
"slate-prism": "^0.5.0",
Expand Down
12 changes: 5 additions & 7 deletions src/components/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,17 @@ class Image extends React.Component<Props, State> {
};

render() {
const { attributes, editor, node, readOnly } = this.props;
const { attributes, node, isSelected, readOnly } = this.props;
const loading = node.data.get("loading");
const caption = node.data.get("alt") || "";
const src = node.data.get("src");
const active =
editor.value.isFocused && editor.value.selection.hasEdgeIn(node);
const showCaption = !readOnly || caption;

return (
<CenteredImage contentEditable={false}>
{this.state.hasError ? (
<React.Fragment>
<ErrorImg as="div" active={active} />
<ErrorImg as="div" isSelected={isSelected} />
<ErrorMessage>Could not load image</ErrorMessage>
</React.Fragment>
) : (
Expand All @@ -54,7 +52,7 @@ class Image extends React.Component<Props, State> {
{...attributes}
src={src}
alt={caption}
active={active}
isSelected={isSelected}
loading={loading}
/>
) : (
Expand Down Expand Up @@ -112,8 +110,8 @@ const HiddenImg = styled.img`
const StyledImg = styled.img`
max-width: 100%;
box-shadow: ${props =>
props.active ? `0 0 0 2px ${props.theme.selected}` : "none"};
border-radius: ${props => (props.active ? `2px` : "0")};
props.isSelected ? `0 0 0 2px ${props.theme.selected}` : "none"};
border-radius: ${props => (props.isSelected ? `2px` : "0")};
opacity: ${props => (props.loading ? 0.5 : 1)};
`;

Expand Down
4 changes: 0 additions & 4 deletions src/nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ function renderNode(props: SlateNodeProps) {
return <Heading5 {...props} />;
case "heading6":
return <Heading6 {...props} />;
case "embed":
return (
<div {...attributes}>EMBED GOES HERE {props.node.data.get("href")}</div>
);
default:
return props.children;
}
Expand Down
1 change: 1 addition & 0 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type SlateNodeProps = {
editor: Editor,
node: Node,
parent: Node,
isSelected: boolean,
};

export type Plugin = {
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5591,9 +5591,9 @@ slate-edit-list@^0.11.3:
version "0.11.3"
resolved "https://registry.yarnpkg.com/slate-edit-list/-/slate-edit-list-0.11.3.tgz#d27ff2ff93a83bef49131a6a44b87a9558c9d44c"

slate-md-serializer@^5.2.1:
version "5.2.1"
resolved "https://registry.yarnpkg.com/slate-md-serializer/-/slate-md-serializer-5.2.1.tgz#b9d6d4f4f706c118274f59dc2a40b6d9a2b8ce63"
slate-md-serializer@^5.2.2:
version "5.2.2"
resolved "https://registry.yarnpkg.com/slate-md-serializer/-/slate-md-serializer-5.2.2.tgz#86003e476746af3361d6ccf61c1cb41e9494eb6e"
dependencies:
hashtag-regex "^2.0.0"

Expand Down

0 comments on commit 5d6a322

Please sign in to comment.