Skip to content

Instantly share code, notes, and snippets.

@ichim-david
Last active September 24, 2024 16:30
Show Gist options
  • Save ichim-david/d6080afe5562c58165f5fca4f2aaa93d to your computer and use it in GitHub Desktop.
Save ichim-david/d6080afe5562c58165f5fca4f2aaa93d to your computer and use it in GitHub Desktop.
Enable Volto Slate Advanced Link plugin
import installLink from '@plone/volto-slate/editor/plugins/AdvancedLink';
const applyConfig = (config) => {
config = installLink(config);
const toolbarButtons = config.settings.slate.toolbarButtons || [];
const linkIndex = toolbarButtons.indexOf('link');
const advancedLinkIndex = toolbarButtons.indexOf('a');
// replace original link plugin with "a" advanced plugin
toolbarButtons.splice(linkIndex, 1, 'a');
toolbarButtons.splice(advancedLinkIndex, 1);
return config;
};
export default applyConfig;
diff --git a/packages/volto-slate/src/index.js b/packages/volto-slate/src/index.js
index a9ba83c2f..33e54dfa6 100644
--- a/packages/volto-slate/src/index.js
+++ b/packages/volto-slate/src/index.js
@@ -2,17 +2,19 @@ import * as slateReducers from './reducers';
import installSlate from './editor';
import installTextBlock from './blocks/Text';
+import installLink from '@plone/volto-slate/editor/plugins/AdvancedLink';
import installTableBlock from './blocks/Table';
import RichTextWidget from './widgets/RichTextWidget';
import RichTextWidgetView from './widgets/RichTextWidgetView';
import HtmlSlateWidget from './widgets/HtmlSlateWidget';
import ObjectByTypeWidget from './widgets/ObjectByTypeWidget';
-
export default function applyConfig(config) {
- config = [installSlate, installTextBlock, installTableBlock].reduce(
- (acc, apply) => apply(acc),
- config,
- );
+ config = [
+ installSlate,
+ installTextBlock,
+ installTableBlock,
+ installLink,
+ ].reduce((acc, apply) => apply(acc), config);
config.settings.defaultBlockType = 'slate';
@@ -20,7 +22,7 @@ export default function applyConfig(config) {
'bold',
'italic',
'strikethrough',
- 'link',
+ 'a',
'separator',
'heading-two',
'heading-three',
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment