Skip to content

Commit

Permalink
Add helpers functions
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanMiu committed Jun 9, 2022
1 parent 617bfe2 commit 353581c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Blocks/Item/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import SlateEditor from 'volto-slate/editor/SlateEditor';
import { handleKey } from 'volto-slate/blocks/Text/keyboard';
import { uploadContent, saveSlateBlockSelection } from 'volto-slate/actions';

import { createSlateParagraph } from '@eeacms/volto-quote-block/helpers';
import { createSlateParagraph } from '@eeacms/volto-eea-website-policy/helpers';

import Item from './Item';
import getSchema from './schema';
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/Item/Item.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cx from 'classnames';
import { Item as UiItem, Icon } from 'semantic-ui-react';
import { serializeText } from '@eeacms/volto-quote-block/helpers';
import { serializeText } from '@eeacms/volto-eea-website-policy/helpers';

function Item({
assetType,
Expand Down
11 changes: 11 additions & 0 deletions src/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { isArray } from 'lodash';
import config from '@plone/volto/registry';
import { serializeNodes } from 'volto-slate/editor/render';

export const createSlateParagraph = (text) => {
return isArray(text) ? text : config.settings.slate.defaultValue();
};

export const serializeText = (text) => {
return isArray(text) ? serializeNodes(text) : text;
};

0 comments on commit 353581c

Please sign in to comment.