Skip to content
Snippets Groups Projects

Theme

Merged Christos requested to merge theme into master
3 files
+ 12
49
Compare changes
  • Side-by-side
  • Inline
Files
3
/* eslint react/prop-types: 0 */
import React, { useContext, useState } from 'react';
// import styled from 'styled-components';
// import { ButtonStyles } from 'wax-prosemirror-themes';
import { WaxContext } from 'wax-prosemirror-core';
import React, { useState } from 'react';
import MenuButton from '../../ui/buttons/MenuButton';
// const ButtonStyled = styled.button`
// ${ButtonStyles};
// opacity: ${props => (props.select ? 1 : 0.4)};
// pointer-events: ${props => (props.select ? 'default' : 'none')};
// color: ${props => (props.isActive ? 'white' : props.theme.colorButton)};
// background-color: ${props =>
// props.isActive ? props.theme.colorPrimary : 'transparent'};
// &:hover {
// background-color: ${props =>
// props.isActive ? props.theme.colorPrimary : 'transparent'};
// }
// `;
const TrackChangeEnable = ({ view = {}, item, enabled }) => {
if (item.onlyOnMain) {
const {
view: { main },
} = useContext(WaxContext);
view = main;
}
const [isEnabled, setEnabled] = useState(enabled);
// return (
// <ButtonStyled
// type="button"
// isActive={isEnabled}
// title={item.title}
// disabled={item.enable && !item.enable(view.state)}
// onMouseDown={e => {
// e.preventDefault();
// setEnabled(!isEnabled);
// item.run(view.state, view.dispatch);
// }}
// select={item.select && item.select(view.state)}
// >
// {item.content}
// </ButtonStyled>
// );
const handleMouseDown = () => {
const handleMouseDown = e => {
e.preventDefault();
setEnabled(!isEnabled);
item.run(view.state, view.dispatch);
};
@@ -55,7 +16,7 @@ const TrackChangeEnable = ({ view = {}, item, enabled }) => {
active={isEnabled}
disabled={item.enable && !item.enable(view.state)}
label="Track Changes"
onMouseDown={handleMouseDown}
onMouseDown={e => handleMouseDown(e)}
title={item.title}
/>
);