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

Commit

Permalink
add advanced link in config for fise
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiggr committed Dec 15, 2022
1 parent d71739b commit 4616af9
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,27 @@ import reducers from '@eeacms/volto-forests-theme/reducers';

import './slate-styles.css';

import linkSVG from '@plone/volto/icons/link.svg';
import { makeInlineElementPlugin } from '@plone/volto-slate/elementEditor';

import { LINK } from '@plone/volto-slate/constants';
import { LinkElement } from '@plone/volto-slate/editor/plugins/AdvancedLink/render';
import { withLink } from '@plone/volto-slate/editor/plugins/AdvancedLink/extensions';
import { linkDeserializer } from '@plone/volto-slate/editor/plugins/AdvancedLink/deserialize';
import LinkEditSchema from '@plone/volto-slate/editor/plugins/AdvancedLink/schema';
import { defineMessages } from 'react-intl'; // , defineMessages

const messages = defineMessages({
edit: {
id: 'Edit link',
defaultMessage: 'Edit link',
},
delete: {
id: 'Remove link',
defaultMessage: 'Remove link',
},
});

export default function applyConfig(config) {
// Add here your project's configuration here by modifying `config` accordingly
config = [
Expand Down Expand Up @@ -130,5 +151,33 @@ export default function applyConfig(config) {
// { cssClass: 'green-block-text', label: 'Green Text' },
// { cssClass: 'underline-block-text', label: 'Underline Text' },
// ];

//advancedlink is currently not working properly/not recognized in fise, so we add it to config manually
const { slate } = config.settings;

slate.toolbarButtons = [...(slate.toolbarButtons || []), LINK];
slate.expandedToolbarButtons = [
...(slate.expandedToolbarButtons || []),
LINK,
];

slate.htmlTagsToSlate.A = linkDeserializer;

const opts = {
title: 'Link',
pluginId: LINK,
elementType: LINK,
element: LinkElement,
isInlineElement: true,
editSchema: LinkEditSchema,
extensions: [withLink],
hasValue: (formData) => !!formData.link,
toolbarButtonIcon: linkSVG,
messages,
};

const [installLinkEditor] = makeInlineElementPlugin(opts);
config = installLinkEditor(config);

return config;
}

0 comments on commit 4616af9

Please sign in to comment.