Skip to content
Snippets Groups Projects
Commit f7eace14 authored by Christos's avatar Christos
Browse files

Merge branch 'buttons' into 'master'

Buttons

See merge request !171
parents ec53fcff 83ef309a
No related branches found
No related tags found
1 merge request!171Buttons
Showing
with 268 additions and 222 deletions
import React from 'react';
import PropTypes from 'prop-types';
import styled, { css } from 'styled-components';
import Icon from './Icon';
const activeStyles = css`
background: gray;
color: white;
> svg {
fill: white;
}
&:hover {
background: gray;
}
`;
const disabledStyles = css`
cursor: not-allowed;
> svg {
fill: gainsboro;
}
&:hover {
background: none;
}
`;
const Wrapper = styled.button.attrs(props => ({
title: props.title,
type: 'button',
}))`
background: none;
border: none;
border-radius: 2px;
cursor: pointer;
height: 28px;
outline: none;
padding: 2px;
transition: all 0.1s ease-in;
> svg {
transition: all 0.1s ease-in;
}
&:hover {
background: gainsboro;
}
${props => props.active && activeStyles}
${props => props.disabled && disabledStyles}
`;
const StyledIcon = styled(Icon)`
height: 24px;
width: 24px;
`;
const Label = styled.span`
margin: 0 8px;
${props => props.hasIcon && `margin: 0 8px 0 4px;`}
`;
const MenuButton = props => {
const {
active,
className,
disabled,
iconName,
label,
title,
onMouseDown,
} = props;
return (
<Wrapper
active={active}
className={className}
disabled={disabled}
onMouseDown={onMouseDown}
title={title}
>
{iconName && (
<StyledIcon active={active} disabled={disabled} name={iconName} />
)}
{label && <Label hasIcon={!!iconName}>{label}</Label>}
</Wrapper>
);
};
MenuButton.propTypes = {
active: PropTypes.bool.isRequired,
disabled: PropTypes.bool.isRequired,
iconName: PropTypes.string,
label: PropTypes.string,
title: PropTypes.string,
};
MenuButton.defaultProps = {
iconName: null,
label: null,
title: null,
};
export default MenuButton;
...@@ -14,22 +14,22 @@ const Box = styled.div` ...@@ -14,22 +14,22 @@ const Box = styled.div`
background: gray; background: gray;
`; `;
const Label = styled(Button)``; const StyledButton = styled(Button)``;
const BlockElement = props => { const BlockElement = props => {
const { item, onClick } = props; const { item, onClick, view } = props;
return ( return (
<Wrapper onClick={onClick}> <Wrapper onClick={onClick}>
<Box /> <Box />
<Label item={item} /> <StyledButton item={item} view={view} />
</Wrapper> </Wrapper>
); );
}; };
BlockElement.propTypes = { BlockElement.propTypes = {
item: PropTypes.shape({ item: PropTypes.shape({
content: PropTypes.string, label: PropTypes.string,
}).isRequired, }).isRequired,
}; };
......
...@@ -4,15 +4,32 @@ import styled from 'styled-components'; ...@@ -4,15 +4,32 @@ import styled from 'styled-components';
import BlockElement from './BlockElement'; import BlockElement from './BlockElement';
const Wrapper = styled.div``; const Wrapper = styled.div``;
const GroupName = styled.div``;
const GroupName = styled.div`
margin-bottom: 4px;
font-size: 14px;
text-transform: uppercase;
`;
const ListWrapper = styled.div`
> div:not(:last-child) {
margin-bottom: 4px;
}
`;
const BlockElementGroup = props => { const BlockElementGroup = props => {
const { groupName, items } = props; const { groupName, items, view } = props;
return ( return (
<Wrapper> <Wrapper>
<GroupName>{groupName}</GroupName> <GroupName>{groupName}</GroupName>
{items && items.map(item => <BlockElement item={item} />)}
<ListWrapper>
{items &&
items.map(item => (
<BlockElement key={item.name} item={item} view={view} />
))}
</ListWrapper>
</Wrapper> </Wrapper>
); );
}; };
......
...@@ -5,19 +5,26 @@ import styled from 'styled-components'; ...@@ -5,19 +5,26 @@ import styled from 'styled-components';
import BlockElementGroup from './BlockElementGroup'; import BlockElementGroup from './BlockElementGroup';
const Wrapper = styled.div` const Wrapper = styled.div`
padding: 8px;
> div:not(:last-child) { > div:not(:last-child) {
margin-bottom: 8px; margin-bottom: 8px;
} }
`; `;
const BlockLevelTools = props => { const BlockLevelTools = props => {
const { groups } = props; const { groups, view } = props;
return ( return (
<Wrapper> <Wrapper>
{groups && {groups &&
groups.map(group => ( groups.map(group => (
<BlockElementGroup groupName={group.groupName} items={group.items} /> <BlockElementGroup
groupName={group.groupName}
key={group.groupName}
items={group.items}
view={view}
/>
))} ))}
</Wrapper> </Wrapper>
); );
...@@ -29,7 +36,7 @@ BlockLevelTools.propTypes = { ...@@ -29,7 +36,7 @@ BlockLevelTools.propTypes = {
groupName: PropTypes.string, groupName: PropTypes.string,
items: PropTypes.arrayOf( items: PropTypes.arrayOf(
PropTypes.shape({ PropTypes.shape({
content: PropTypes.string, label: PropTypes.string,
}), }),
), ),
}), }),
......
import React, { useState } from 'react'; import React, { useState } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import styled, { css } from 'styled-components'; import styled, { css } from 'styled-components';
import Icon from '../buttons/Icon';
const Wrapper = styled.div` const Wrapper = styled.div`
display: flex; display: flex;
...@@ -10,7 +11,6 @@ const Wrapper = styled.div` ...@@ -10,7 +11,6 @@ const Wrapper = styled.div`
const Tabs = styled.div` const Tabs = styled.div`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
margin-right: 10px;
`; `;
const activeTab = css` const activeTab = css`
...@@ -18,23 +18,26 @@ const activeTab = css` ...@@ -18,23 +18,26 @@ const activeTab = css`
`; `;
const Tab = styled.div` const Tab = styled.div`
height: 50px; background: gainsboro;
width: 50px; padding: 8px;
background: papayawhip; margin: 0 4px 4px 4px;
margin-bottom: 5px;
cursor: pointer; cursor: pointer;
&:first-child {
margin-top: 4px;
}
${props => props.active && activeTab} ${props => props.active && activeTab}
&:hover { &:hover {
background: gray; background: silver;
} }
`; `;
const Content = styled.div` const Content = styled.div`
width: 100%; width: 100%;
height: 100%; height: 100%;
border: 1px solid gray; background: gainsboro;
`; `;
const TabsPane = props => { const TabsPane = props => {
...@@ -52,7 +55,7 @@ const TabsPane = props => { ...@@ -52,7 +55,7 @@ const TabsPane = props => {
key={tab.id} key={tab.id}
onClick={() => setTabDisplay(tab.id)} onClick={() => setTabDisplay(tab.id)}
> >
{tab.displayName} <Icon name={tab.icon} />
</Tab> </Tab>
))} ))}
</Tabs> </Tabs>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"version": "0.0.19", "version": "0.0.19",
"description": "Wax prosemirror core", "description": "Wax prosemirror core",
"license": "MIT", "license": "MIT",
"main": "dist/index.js", "main": "index.js",
"files": [ "files": [
"dist" "dist"
], ],
......
/* eslint react/prop-types: 0 */ /* eslint react/prop-types: 0 */
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import debounce from 'lodash/debounce'; import debounce from 'lodash/debounce';
import styled from 'styled-components';
import { DOMSerializer, DOMParser } from 'prosemirror-model'; import { DOMSerializer, DOMParser } from 'prosemirror-model';
...@@ -43,12 +42,6 @@ const createPlaceholder = placeholder => { ...@@ -43,12 +42,6 @@ const createPlaceholder = placeholder => {
return Placeholder({ content: placeholder }); return Placeholder({ content: placeholder });
}; };
const LayoutWrapper = styled.div`
display: flex;
flex-direction: column;
height: 99%;
`;
const Wax = props => { const Wax = props => {
let finalPlugins = []; let finalPlugins = [];
const [application, setApplication] = useState(); const [application, setApplication] = useState();
...@@ -125,24 +118,23 @@ const Wax = props => { ...@@ -125,24 +118,23 @@ const Wax = props => {
const WaxRender = Layout.layoutComponent; const WaxRender = Layout.layoutComponent;
return ( return (
<LayoutWrapper className={`${className}`}> <WaxProvider app={application}>
<WaxProvider app={application}> <WaxView
<WaxView autoFocus={autoFocus}
autoFocus={autoFocus} readonly={readonly}
readonly={readonly} options={WaxOptions}
options={WaxOptions} placeholder={placeholder}
placeholder={placeholder} fileUpload={fileUpload}
fileUpload={fileUpload} onBlur={onBlur || (v => true)}
onBlur={onBlur || (v => true)} onChange={finalOnChange || (v => true)}
onChange={finalOnChange || (v => true)} debug={debug}
debug={debug} TrackChange={TrackChange}
TrackChange={TrackChange} user={user}
user={user} >
> {({ editor }) => <WaxRender className={className} editor={editor} />}
{({ editor }) => <WaxRender editor={editor} />} </WaxView>
</WaxView> </WaxProvider>
</WaxProvider>
</LayoutWrapper>
); );
}; };
export default Wax; export default Wax;
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"version": "0.0.19", "version": "0.0.19",
"description": "Wax prosemirror layouts", "description": "Wax prosemirror layouts",
"license": "MIT", "license": "MIT",
"main": "dist/index.js", "main": "index.js",
"files": [ "files": [
"dist" "dist"
], ],
......
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import styled, { ThemeProvider } from 'styled-components'; import styled, { css, ThemeProvider } from 'styled-components';
import PanelGroup from 'react-panelgroup'; import PanelGroup from 'react-panelgroup';
import { InfoArea } from 'wax-prosemirror-components'; import { InfoArea } from 'wax-prosemirror-components';
import { componentPlugin } from 'wax-prosemirror-services'; import { componentPlugin } from 'wax-prosemirror-services';
...@@ -8,12 +8,7 @@ import { DocumentHelpers } from 'wax-prosemirror-utilities'; ...@@ -8,12 +8,7 @@ import { DocumentHelpers } from 'wax-prosemirror-utilities';
import { WaxContext } from 'wax-prosemirror-core'; import { WaxContext } from 'wax-prosemirror-core';
import EditorElements from './EditorElements'; import EditorElements from './EditorElements';
const LayoutWrapper = styled.div` const divider = css`
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
overflow: hidden;
.divider { .divider {
&:before { &:before {
content: 'Notes'; content: 'Notes';
...@@ -61,124 +56,71 @@ const LayoutWrapper = styled.div` ...@@ -61,124 +56,71 @@ const LayoutWrapper = styled.div`
} }
`; `;
const LeftMenuSurfaceContainer = styled.div` const Wrapper = styled.div`
display: flex; display: flex;
flex-direction: row; flex-direction: column;
height: 100%; height: 100%;
width: 100%; width: 100%;
overflow: hidden;
${divider}
`; `;
const WaxSurfaceContainer = styled.div` const Main = styled.div`
flex: 1;
position: relative;
z-index: 1;
display: flex; display: flex;
flex-direction: column; flex-grow: 1;
height: 100%;
width: 100%;
`; `;
const EditorContainer = styled.div` const TopMenu = styled.div`
width: 65%; display: flex;
height: 100%; justify-content: center;
.ProseMirror { min-height: 40px;
-moz-box-shadow: 0 0 8px #ecedf1; user-select: none;
-webkit-box-shadow: 0 0 8px #ecedf1; border-bottom: 2px solid #ecedf1;
box-shadow: 0 0 8px #ecedf1;
min-height: 90%; > div:not(:last-child) {
padding: 30px 30px 30px 30px; border-right: 1px solid #ecedf1;
@media (max-width: 600px) {
padding: 65px 10px 10px 10px;
}
}
@media (max-width: 600px) {
width: 95%;
} }
`; `;
const SideMenu = styled.div`
border-right: 1px solid #ecedf1;
min-width: 250px;
height: 100%;
`;
const EditorArea = styled.div`
flex-grow: 1;
`;
const WaxSurfaceScroll = styled.div` const WaxSurfaceScroll = styled.div`
bottom: 0; overflow-y: auto;
left: 0;
overflow: auto;
position: absolute;
display: flex; display: flex;
right: 0;
top: 0;
box-sizing: border-box; box-sizing: border-box;
padding: 0 2px 2px 2px; padding: 0 2px 2px 2px;
height: 100%; height: 100%;
width: 100%;
${EditorElements}; ${EditorElements};
`; `;
const MainMenuContainer = styled.div` const EditorContainer = styled.div`
background: #fff; width: 65%;
min-height: 52px;
line-height: 32px;
position: relative;
width: 100%;
user-select: none;
border-bottom: 2px solid #ecedf1;
@media (max-width: 600px) {
position: absolute;
/* width: 100%; */
font-size: 10px;
min-height: 72px;
line-height: 0px;
}
`;
const MainMenuInner = styled.div`
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
flex-direction: column;
left: 0;
position: absolute;
right: 0;
top: 0;
height: 100%; height: 100%;
background: #fff;
z-index: 9999;
div {
align-items: center;
justify-content: center;
@media (max-width: 600px) {
justify-content: start;
}
}
`;
const SideMenuContainer = styled.div` .ProseMirror {
display: flex; box-shadow: 0 0 8px #ecedf1;
flex-direction: column; min-height: 90%;
overflow-y: auto; padding: 40px;
width: 14%;
height: 98%;
@media (max-width: 600px) {
display: none;
} }
`; `;
const SideMenuInner = styled.div` const CommentsContainer = styled.div`
display: flex; display: flex;
width: 100%; flex-direction: column;
> div { width: 35%;
flex: 1; height: 100%;
display: flex;
flex-direction: column;
justify-content: flex-start;
margin-top: 35px;
button {
display: flex;
flex-direction: column;
font-family: ${props => props.theme.fontInterface};
margin-left: 5%;
width: 90%;
}
[data-name='Display'] {
border-right: none;
}
}
`; `;
const NotesAreaContainer = styled.div` const NotesAreaContainer = styled.div`
...@@ -198,19 +140,6 @@ const NotesContainer = styled.div` ...@@ -198,19 +140,6 @@ const NotesContainer = styled.div`
height: 100%; height: 100%;
width: 65%; width: 65%;
position: relative; position: relative;
@media (max-width: 600px) {
width: 100%;
}
`;
const CommentsContainer = styled.div`
display: flex;
flex-direction: column;
width: 35%;
height: 100%;
@media (max-width: 600px) {
width: auto;
}
`; `;
let surfaceHeight = 700; let surfaceHeight = 700;
...@@ -231,75 +160,65 @@ const hasNotes = main => { ...@@ -231,75 +160,65 @@ const hasNotes = main => {
}; };
const LeftSideBar = componentPlugin('leftSideBar'); const LeftSideBar = componentPlugin('leftSideBar');
const RightSideBar = componentPlugin('rightSideBar'); // const RightSideBar = componentPlugin('rightSideBar');
const TopBar = componentPlugin('topBar'); const TopBar = componentPlugin('topBar');
const NotesArea = componentPlugin('notesArea'); const NotesArea = componentPlugin('notesArea');
const RightArea = componentPlugin('rightArea'); const RightArea = componentPlugin('rightArea');
const WaxOverlays = componentPlugin('waxOverlays'); const WaxOverlays = componentPlugin('waxOverlays');
const withNotes = () => {
return (
<NotesAreaContainer>
<NotesContainer id="notes-container">
<NotesArea />
</NotesContainer>
<CommentsContainer>
<RightArea area="notes" />
</CommentsContainer>
</NotesAreaContainer>
);
};
const EditoriaLayout = ({ editor }) => { const EditoriaLayout = ({ editor }) => {
const { const {
view: { main }, view: { main },
} = useContext(WaxContext); } = useContext(WaxContext);
let AreasWithNotes = null;
if (main) { const notes = main && hasNotes(main);
const notes = hasNotes(main); const showNotes = notes && !!notes.length && notes.length > 0;
if (notes.length) AreasWithNotes = withNotes();
}
return ( return (
<ThemeProvider theme={cokoTheme}> <ThemeProvider theme={cokoTheme}>
<LayoutWrapper> <Wrapper>
<MainMenuContainer> <TopMenu>
<MainMenuInner> <TopBar />
<TopBar /> </TopMenu>
</MainMenuInner>
</MainMenuContainer> <Main>
<SideMenu>
<LeftMenuSurfaceContainer> <LeftSideBar />
<SideMenuContainer> </SideMenu>
<SideMenuInner>
<LeftSideBar /> <EditorArea>
</SideMenuInner> <PanelGroup
</SideMenuContainer> direction="column"
panelWidths={[
<PanelGroup { size: surfaceHeight, resize: 'stretch' },
direction="column" { size: notesHeight, resize: 'stretch' },
panelWidths={[ ]}
{ size: surfaceHeight, resize: 'dynamic' }, onResizeEnd={onResizeEnd}
{ size: notesHeight, resize: 'stretch' }, >
]} <WaxSurfaceScroll>
onResizeEnd={onResizeEnd}
>
<WaxSurfaceContainer>
<WaxSurfaceScroll className="wax-surface-scroll">
<EditorContainer>{editor}</EditorContainer> <EditorContainer>{editor}</EditorContainer>
<CommentsContainer> <CommentsContainer>
<RightArea area="main" /> <RightArea area="main" />
</CommentsContainer> </CommentsContainer>
</WaxSurfaceScroll> </WaxSurfaceScroll>
<RightSideBar />
</WaxSurfaceContainer> {showNotes && (
{AreasWithNotes} <NotesAreaContainer>
</PanelGroup> <NotesContainer id="notes-container">
</LeftMenuSurfaceContainer> <NotesArea />
</NotesContainer>
<CommentsContainer>
<RightArea area="notes" />
</CommentsContainer>
</NotesAreaContainer>
)}
</PanelGroup>
</EditorArea>
</Main>
<InfoArea /> <InfoArea />
<WaxOverlays /> <WaxOverlays />
</LayoutWrapper> </Wrapper>
</ThemeProvider> </ThemeProvider>
); );
}; };
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"version": "0.0.19", "version": "0.0.19",
"description": "Wax prosemirror plugins", "description": "Wax prosemirror plugins",
"license": "MIT", "license": "MIT",
"main": "dist/index.js", "main": "index.js",
"files": [ "files": [
"dist" "dist"
], ],
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"version": "0.0.19", "version": "0.0.19",
"description": "Wax prosemirror schema", "description": "Wax prosemirror schema",
"license": "MIT", "license": "MIT",
"main": "dist/index.js", "main": "index.js",
"files": [ "files": [
"dist" "dist"
], ],
......
...@@ -41,3 +41,5 @@ export { default as TextToolGroupService } from './src/WaxToolGroups/TextToolGro ...@@ -41,3 +41,5 @@ export { default as TextToolGroupService } from './src/WaxToolGroups/TextToolGro
export { default as NoteToolGroupService } from './src/WaxToolGroups/NoteToolGroupService/NoteToolGroupService'; export { default as NoteToolGroupService } from './src/WaxToolGroups/NoteToolGroupService/NoteToolGroupService';
export { default as CodeBlockToolGroupService } from './src/WaxToolGroups/CodeBlockToolGroupService/CodeBlockToolGroupService'; export { default as CodeBlockToolGroupService } from './src/WaxToolGroups/CodeBlockToolGroupService/CodeBlockToolGroupService';
export { default as TrackChangeToolGroupService } from './src/WaxToolGroups/TrackChangeToolGroupService/TrackChangeToolGroupService'; export { default as TrackChangeToolGroupService } from './src/WaxToolGroups/TrackChangeToolGroupService/TrackChangeToolGroupService';
export { default as DisplayTextToolGroupService } from './src/WaxToolGroups/DisplayTextToolGroupService/DisplayTextToolGroupService';
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"version": "0.0.19", "version": "0.0.19",
"description": "Wax prosemirror services", "description": "Wax prosemirror services",
"license": "MIT", "license": "MIT",
"main": "dist/index.js", "main": "index.js",
"files": [ "files": [
"dist" "dist"
], ],
......
import { redo } from 'prosemirror-history'; import { redo } from 'prosemirror-history';
import { injectable } from 'inversify'; import { injectable } from 'inversify';
import { icons } from 'wax-prosemirror-components';
import Tools from '../../lib/Tools'; import Tools from '../../lib/Tools';
export default export default
@injectable() @injectable()
class Redo extends Tools { class Redo extends Tools {
title = 'Redo last undone change'; title = 'Redo';
content = icons.redo; icon = 'redo';
onlyOnMain = true; onlyOnMain = true;
name = 'Redo'; name = 'Redo';
......
import { undo } from 'prosemirror-history'; import { undo } from 'prosemirror-history';
import { injectable } from 'inversify'; import { injectable } from 'inversify';
import { icons } from 'wax-prosemirror-components';
import Tools from '../../lib/Tools'; import Tools from '../../lib/Tools';
export default export default
@injectable() @injectable()
class Undo extends Tools { class Undo extends Tools {
title = 'Undo last change'; title = 'Undo';
content = icons.undo; icon = 'undo';
onlyOnMain = true; onlyOnMain = true;
name = 'Undo'; name = 'Undo';
......
import { injectable } from 'inversify'; import { injectable } from 'inversify';
import { icons } from 'wax-prosemirror-components';
import { setBlockType } from 'prosemirror-commands'; import { setBlockType } from 'prosemirror-commands';
import Tools from '../lib/Tools'; import Tools from '../lib/Tools';
@injectable() @injectable()
class CodeBlockTool extends Tools { class CodeBlockTool extends Tools {
title = 'Insert Code Block'; title = 'Insert Code Block';
content = icons.code_block; icon = 'codeBlock';
name = 'CodeBlockTool'; name = 'CodeBlockTool';
get run() { get run() {
......
...@@ -5,7 +5,7 @@ import Tools from '../../lib/Tools'; ...@@ -5,7 +5,7 @@ import Tools from '../../lib/Tools';
@injectable() @injectable()
class Author extends Tools { class Author extends Tools {
title = 'Change to Author'; title = 'Change to Author';
content = 'Author'; label = 'Author';
name = 'Author'; name = 'Author';
get run() { get run() {
......
...@@ -5,7 +5,7 @@ import Tools from '../../lib/Tools'; ...@@ -5,7 +5,7 @@ import Tools from '../../lib/Tools';
@injectable() @injectable()
class EpigraphPoetry extends Tools { class EpigraphPoetry extends Tools {
title = 'Change to Epigraph Poetry'; title = 'Change to Epigraph Poetry';
content = 'Epigraph Poetry'; label = 'Epigraph Poetry';
name = 'EpigraphPoetry'; name = 'EpigraphPoetry';
get run() { get run() {
......
...@@ -6,7 +6,7 @@ export default ...@@ -6,7 +6,7 @@ export default
@injectable() @injectable()
class EpigraphProse extends Tools { class EpigraphProse extends Tools {
title = 'Change to Epigraph Prose'; title = 'Change to Epigraph Prose';
content = 'Epigraph Prose'; label = 'Epigraph Prose';
name = 'EpigraphProse'; name = 'EpigraphProse';
get run() { get run() {
......
...@@ -6,7 +6,7 @@ export default ...@@ -6,7 +6,7 @@ export default
@injectable() @injectable()
class Heading1 extends Tools { class Heading1 extends Tools {
title = 'Change to heading level 1'; title = 'Change to heading level 1';
content = 'Heading 1'; label = 'Heading 1';
name = 'Heading1'; name = 'Heading1';
get run() { get run() {
......
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