Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
Fix tableButton profile to enable/disable only table button
Browse files Browse the repository at this point in the history
  • Loading branch information
avoinea committed Sep 23, 2021
1 parent 4635fc2 commit 20887a7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/editor/plugins/Table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ export default function install(config) {
...tableElements,
};

return config;
}

export const installTableButton = (config) => {
const { slate } = config.settings;
slate.buttons.table = (props) => <TableButton {...props} title="Table" />;
slate.toolbarButtons = [...(slate.toolbarButtons || []), 'table'];
slate.expandedToolbarButtons = [
...(slate.expandedToolbarButtons || []),
'table',
];

return config;
}
};
2 changes: 2 additions & 0 deletions src/editor/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import installBlockQuotePlugin from './Blockquote';
import installImage from './Image';
import installLinkPlugin from './Link';
import installMarkdown from './Markdown';
import installTable from './Table';
import installStyleMenu from './StyleMenu';

export default function install(config) {
Expand All @@ -10,6 +11,7 @@ export default function install(config) {
installLinkPlugin,
installMarkdown,
installImage,
installTable,
installStyleMenu,
].reduce((acc, apply) => apply(acc), config);
}
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import RichTextWidgetView from './widgets/RichTextWidgetView';
import { BlocksBrowserWidget } from './widgets/BlocksBrowser';
import HashLink from './editor/plugins/Link/AppExtras/HashLink';
import installCallout from './editor/plugins/Callout';
import installTable from './editor/plugins/Table';
import { installTableButton } from './editor/plugins/Table';
import installSimpleLink from './editor/plugins/SimpleLink';
import HtmlSlateWidget from './widgets/HtmlSlateWidget';
import DefaultSlateView from './components/themes/View/DefaultSlateView';
Expand Down Expand Up @@ -78,7 +78,7 @@ export function simpleLink(config) {
}

export function tableButton(config) {
return installTable(config);
return installTableButton(config);
}

export function asDefaultBlock(config) {
Expand Down

0 comments on commit 20887a7

Please sign in to comment.