Commit e556a2ea authored by chris's avatar chris
Browse files

more files

parent 1951db0f
......@@ -60,7 +60,7 @@ const Editoria = () => {
fileUpload={file => renderImage(file)}
value={demo}
layout={layout}
onChange={source => console.log(source)}
// onChange={source => console.log(source)}
user={user}
/>
</>
......
......@@ -58,6 +58,7 @@ export default {
'CodeBlock',
'Tables',
'TrackingAndEditing',
'FullScreen',
],
},
{
......
......@@ -15,3 +15,4 @@ export { default as CreateTable } from './src/components/tables/CreateTable';
export { default as Tabs } from './src/ui/tabs/Tabs';
export { default as BlockLevelTools } from './src/ui/tabs/BlockLevelTools';
export { default as FindAndReplaceTool } from './src/components/findAndReplace/FindAndReplaceTool';
export { default as FullScreen } from './src/components/FullScreen';
/* eslint react/prop-types: 0 */
import React, { useContext, useMemo } from 'react';
import { WaxContext } from 'wax-prosemirror-core';
import MenuButton from '../ui/buttons/MenuButton';
const Button = ({ view = {}, item }) => {
const { active, enable, icon, label, onlyOnMain, run, select, title } = item;
const { active, icon, label, onlyOnMain, run, select, title } = item;
const {
view: { main },
......@@ -22,8 +21,9 @@ const Button = ({ view = {}, item }) => {
run(editorState, dispatch);
};
const isActive = active(state, activeViewId) && select(state, activeViewId);
const isActive = !!(
active(state, activeViewId) && select(state, activeViewId)
);
const isDisabled = !select(state, activeViewId, activeView);
const MenuButtonComponent = useMemo(
......
/* eslint react/prop-types: 0 */
import React, { useContext, useMemo } from 'react';
import { WaxContext } from 'wax-prosemirror-core';
import MenuButton from '../ui/buttons/MenuButton';
const Button = ({ view = {}, item }) => {
const { active, enable, icon, label, onlyOnMain, run, select, title } = item;
const {
view: { main },
activeViewId,
activeView,
} = useContext(WaxContext);
if (onlyOnMain) view = main;
const { dispatch, state } = view;
const handleMouseDown = (e, editorState, editorDispatch) => {
e.preventDefault();
run(editorState, dispatch);
};
const isActive = active(state, activeViewId) && select(state, activeViewId);
const isDisabled = !select(state, activeViewId, activeView);
const MenuButtonComponent = useMemo(
() => (
<MenuButton
active={isActive || false}
disabled={isDisabled}
iconName={icon}
label={label}
onMouseDown={e => handleMouseDown(e, view.state, view.dispatch)}
title={title}
/>
),
[isActive, isDisabled],
);
return MenuButtonComponent;
};
export default Button;
......@@ -248,4 +248,16 @@ export default {
<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z" />
</Svg>
),
fullScreen: ({ className }) => (
<Svg className={className} viewBox="0 0 24 24" fill="none">
<title> Full screen </title>
<path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" />
</Svg>
),
fullScreenExit: ({ className }) => (
<Svg className={className} viewBox="0 0 24 24" fill="none">
<title> Exit full screen </title>
<path d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z" />
</Svg>
),
};
import Service from '../Service';
import FullScreen from './FullScreen';
import FullScreenTool from './FullScreenTool';
class FullScreenService extends Service {
name = 'FullScreenService';
register() {
this.container.bind('FullScreen').to(FullScreen);
this.container.bind('FullScreenTool').to(FullScreenTool);
}
}
......
......@@ -5,7 +5,7 @@ import Tools from '../lib/Tools';
export default
@injectable()
class FullScreen extends Tools {
class FullScreenTool extends Tools {
title = 'full screen';
icon = 'image';
name = 'FullScreen';
......@@ -22,6 +22,6 @@ class FullScreen extends Tools {
renderTool(view) {
if (isEmpty(view)) return null;
return this._isDisplayed ? <span> full</span> : null;
return this._isDisplayed ? <span key="1"> full</span> : null;
}
}
......@@ -15,7 +15,7 @@ class Image extends Tools {
name = 'Image';
get run() {
return () => true;
return true;
}
select = (state, activeViewId) => {
......
......@@ -2,12 +2,12 @@ import { injectable, inject } from 'inversify';
import ToolGroup from '../../lib/ToolGroup';
@injectable()
class FullScreenTool extends ToolGroup {
class FullScreen extends ToolGroup {
tools = [];
constructor(@inject('FullScreen') fullScreen) {
constructor(@inject('FullScreenTool') fullScreenTool) {
super();
this.tools = [fullScreen];
this.tools = [fullScreenTool];
}
}
export default FullScreenTool;
export default FullScreen;
import Service from '../../Service';
import FullScreenTool from './FullScreenTool';
import FullScreen from './FullScreen';
class FullScreenToolGroupService extends Service {
register() {
this.container.bind('FullScreenTool').to(FullScreenTool);
this.container.bind('FullScreen').to(FullScreen);
}
}
......
Markdown is supported
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