Skip to content
Snippets Groups Projects
Commit 1296cd75 authored by chris's avatar chris
Browse files

rest of current components

parent 696bb4f6
No related branches found
No related tags found
1 merge request!188Fix tool rerenders
/* eslint react/prop-types: 0 */
import React, { useContext, useRef } from 'react';
import React, { useContext, useRef, useMemo } from 'react';
import { WaxContext } from 'wax-prosemirror-core';
import styled from 'styled-components';
......@@ -17,25 +17,30 @@ const ImageUpload = ({ item, fileUpload, view }) => {
const inputRef = useRef(null);
const handleMouseDown = () => inputRef.current.click();
return (
<Wrapper>
<label htmlFor="file-upload">
<MenuButton
active={false}
disabled={!(item.select && item.select(view.state, activeViewId))}
iconName={item.icon}
onMouseDown={handleMouseDown}
title="Upload Image"
/>
const ImageUploadComponent = useMemo(
() => (
<Wrapper>
<label htmlFor="file-upload">
<MenuButton
active={false}
disabled={!(item.select && item.select(view.state, activeViewId))}
iconName={item.icon}
onMouseDown={handleMouseDown}
title="Upload Image"
/>
<input
id="file-upload"
ref={inputRef}
onChange={e => fileUpload(e.target.files[0])}
type="file"
/>
</label>
</Wrapper>
<input
id="file-upload"
ref={inputRef}
onChange={e => fileUpload(e.target.files[0])}
type="file"
/>
</label>
</Wrapper>
),
[],
);
return ImageUploadComponent;
};
export default ImageUpload;
......@@ -11,7 +11,7 @@ const TrackChangeEnable = ({ view = {}, item, enabled }) => {
item.run(view.state, view.dispatch);
};
const MenuButtonComponent = useMemo(
const TrackChangeEnableComponent = useMemo(
() => (
<MenuButton
active={isEnabled}
......@@ -21,10 +21,10 @@ const TrackChangeEnable = ({ view = {}, item, enabled }) => {
title={item.title}
/>
),
[],
[isEnabled],
);
return MenuButtonComponent;
return TrackChangeEnableComponent;
};
export default TrackChangeEnable;
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment