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

fix undo redo cmd

parent 1e8127d2
No related branches found
No related tags found
1 merge request!348Multiple single
export { default as Overlay } from './src/components/Overlay'; export { default as Overlay } from './src/components/Overlay';
export { default as Button } from './src/components/Button'; export { default as Button } from './src/components/Button';
export { default as UndoRedoButton } from './src/components/UndoRedoButton';
export { default as MenuButton } from './src/ui/buttons/MenuButton'; export { default as MenuButton } from './src/ui/buttons/MenuButton';
export { default as icons } from './src/icons/icons'; export { default as icons } from './src/icons/icons';
export { default as TableDropDown } from './src/components/tables/TableDropDown'; export { default as TableDropDown } from './src/components/tables/TableDropDown';
......
...@@ -4,7 +4,7 @@ import { WaxContext } from 'wax-prosemirror-core'; ...@@ -4,7 +4,7 @@ import { WaxContext } from 'wax-prosemirror-core';
import MenuButton from '../ui/buttons/MenuButton'; import MenuButton from '../ui/buttons/MenuButton';
const Button = ({ view = {}, item }) => { const Button = ({ view = {}, item }) => {
const { active, icon, label, onlyOnMain, run, select, title } = item; const { active, icon, label, run, select, title } = item;
const { const {
view: { main }, view: { main },
...@@ -12,8 +12,6 @@ const Button = ({ view = {}, item }) => { ...@@ -12,8 +12,6 @@ const Button = ({ view = {}, item }) => {
activeView, activeView,
} = useContext(WaxContext); } = useContext(WaxContext);
if (onlyOnMain) view = main;
const isEditable = main.props.editable(editable => { const isEditable = main.props.editable(editable => {
return editable; return editable;
}); });
......
...@@ -4,7 +4,7 @@ import { WaxContext } from 'wax-prosemirror-core'; ...@@ -4,7 +4,7 @@ import { WaxContext } from 'wax-prosemirror-core';
import MenuButton from '../ui/buttons/MenuButton'; import MenuButton from '../ui/buttons/MenuButton';
const SaveButton = ({ view = {}, item }) => { const SaveButton = ({ view = {}, item }) => {
const { icon, label, onlyOnMain, select, title } = item; const { icon, label, select, title } = item;
const { const {
view: { main }, view: { main },
...@@ -12,8 +12,6 @@ const SaveButton = ({ view = {}, item }) => { ...@@ -12,8 +12,6 @@ const SaveButton = ({ view = {}, item }) => {
activeView, activeView,
} = useContext(WaxContext); } = useContext(WaxContext);
if (onlyOnMain) view = main;
const { state } = view; const { state } = view;
const [isSaving, setIsSaving] = useState(false); const [isSaving, setIsSaving] = useState(false);
...@@ -57,7 +55,9 @@ const SaveButton = ({ view = {}, item }) => { ...@@ -57,7 +55,9 @@ const SaveButton = ({ view = {}, item }) => {
disabled={isDisabled} disabled={isDisabled}
iconName={iconTodisplay} iconName={iconTodisplay}
label={label} label={label}
onMouseDown={e => handleMouseDown(e, view.state, view.dispatch)} onMouseDown={e =>
handleMouseDown(e, main.view.state, main.view.dispatch)
}
title={title} title={title}
/> />
), ),
......
...@@ -5,7 +5,7 @@ import { DocumentHelpers } from 'wax-prosemirror-utilities'; ...@@ -5,7 +5,7 @@ import { DocumentHelpers } from 'wax-prosemirror-utilities';
import MenuButton from '../ui/buttons/MenuButton'; import MenuButton from '../ui/buttons/MenuButton';
const TitleButton = ({ view = {}, item }) => { const TitleButton = ({ view = {}, item }) => {
const { active, icon, label, onlyOnMain, run, select, title } = item; const { active, icon, label, run, select, title } = item;
const { const {
app, app,
...@@ -14,8 +14,6 @@ const TitleButton = ({ view = {}, item }) => { ...@@ -14,8 +14,6 @@ const TitleButton = ({ view = {}, item }) => {
activeView, activeView,
} = useContext(WaxContext); } = useContext(WaxContext);
if (onlyOnMain) view = main;
const { dispatch, state } = view; const { dispatch, state } = view;
const titleNode = DocumentHelpers.findChildrenByType( const titleNode = DocumentHelpers.findChildrenByType(
......
...@@ -13,7 +13,7 @@ const StyledButton = styled(MenuButton)` ...@@ -13,7 +13,7 @@ const StyledButton = styled(MenuButton)`
`; `;
const LeftSideButton = ({ view = {}, item }) => { const LeftSideButton = ({ view = {}, item }) => {
const { active, icon, label, onlyOnMain, run, select, title } = item; const { active, icon, label, run, select, title } = item;
const { const {
view: { main }, view: { main },
...@@ -21,8 +21,6 @@ const LeftSideButton = ({ view = {}, item }) => { ...@@ -21,8 +21,6 @@ const LeftSideButton = ({ view = {}, item }) => {
activeView, activeView,
} = useContext(WaxContext); } = useContext(WaxContext);
if (onlyOnMain) view = main;
const isEditable = main.props.editable(editable => { const isEditable = main.props.editable(editable => {
return editable; return editable;
}); });
......
import React from 'react';
import { isEmpty } from 'lodash';
import { redo } from 'prosemirror-history'; import { redo } from 'prosemirror-history';
import { injectable } from 'inversify'; import { injectable } from 'inversify';
import { UndoRedoButton } from 'wax-prosemirror-components';
import Tools from '../../lib/Tools'; import Tools from '../../lib/Tools';
export default export default
...@@ -7,7 +10,6 @@ export default ...@@ -7,7 +10,6 @@ export default
class Redo extends Tools { class Redo extends Tools {
title = 'Redo'; title = 'Redo';
icon = 'redo'; icon = 'redo';
onlyOnMain = true;
name = 'Redo'; name = 'Redo';
get run() { get run() {
...@@ -23,4 +25,12 @@ class Redo extends Tools { ...@@ -23,4 +25,12 @@ class Redo extends Tools {
select(state) { select(state) {
return redo(state); return redo(state);
} }
renderTool(view) {
if (isEmpty(view)) return null;
// eslint-disable-next-line no-underscore-dangle
return this._isDisplayed ? (
<UndoRedoButton item={this.toJSON()} key="Redo" view={view} />
) : null;
}
} }
import React from 'react'; import React from 'react';
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
import { injectable } from 'inversify'; import { injectable } from 'inversify';
import { SaveButton, icons } from 'wax-prosemirror-components'; import { SaveButton, icons } from 'wax-prosemirror-components';
import Tools from '../../lib/Tools'; import Tools from '../../lib/Tools';
...@@ -10,7 +9,6 @@ export default ...@@ -10,7 +9,6 @@ export default
class Save extends Tools { class Save extends Tools {
title = 'Save changes'; title = 'Save changes';
icon = 'save'; icon = 'save';
onlyOnMain = true;
name = 'Save'; name = 'Save';
content = icons.save; content = icons.save;
name = 'Save'; name = 'Save';
...@@ -21,8 +19,6 @@ class Save extends Tools { ...@@ -21,8 +19,6 @@ class Save extends Tools {
}; };
} }
get enable() {}
renderTool(view) { renderTool(view) {
if (isEmpty(view)) return null; if (isEmpty(view)) return null;
// eslint-disable-next-line no-underscore-dangle // eslint-disable-next-line no-underscore-dangle
......
import React from 'react';
import { isEmpty } from 'lodash';
import { undo } from 'prosemirror-history'; import { undo } from 'prosemirror-history';
import { injectable } from 'inversify'; import { injectable } from 'inversify';
import { UndoRedoButton } from 'wax-prosemirror-components';
import Tools from '../../lib/Tools'; import Tools from '../../lib/Tools';
export default export default
...@@ -7,7 +10,6 @@ export default ...@@ -7,7 +10,6 @@ export default
class Undo extends Tools { class Undo extends Tools {
title = 'Undo'; title = 'Undo';
icon = 'undo'; icon = 'undo';
onlyOnMain = true;
name = 'Undo'; name = 'Undo';
get run() { get run() {
...@@ -23,4 +25,12 @@ class Undo extends Tools { ...@@ -23,4 +25,12 @@ class Undo extends Tools {
select(state) { select(state) {
return undo(state); return undo(state);
} }
renderTool(view) {
if (isEmpty(view)) return null;
// eslint-disable-next-line no-underscore-dangle
return this._isDisplayed ? (
<UndoRedoButton item={this.toJSON()} key="Undo" view={view} />
) : null;
}
} }
...@@ -10,7 +10,6 @@ class Tools { ...@@ -10,7 +10,6 @@ class Tools {
title = 'title'; title = 'title';
_isDisplayed = true; _isDisplayed = true;
_isHiddenInToolGroup = false; _isHiddenInToolGroup = false;
onlyOnMain = false;
config = {}; config = {};
pmplugins = {}; pmplugins = {};
name = 'name'; name = 'name';
...@@ -48,7 +47,6 @@ class Tools { ...@@ -48,7 +47,6 @@ class Tools {
run: this.run, run: this.run,
enable: this.enable, enable: this.enable,
select: this.select, select: this.select,
onlyOnMain: this.onlyOnMain,
id: this.id, id: this.id,
}; };
} }
......
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