Skip to content

Commit

Permalink
chore: removed imports from volto barrel files
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliaghisini committed Dec 24, 2024
1 parent 73da1d7 commit 27db7f0
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 7 deletions.
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
"i18n": "rm -rf build/messages && NODE_ENV=production i18n -a",
"release": "release-it"
},
"dependencies": {
"react-outside-click-handler": "1.3.0"
},
"peerDependencies": {
"@plone/volto": ">=16.0.0-alpha.38",
"volto-blocks-widget": ">=3.4.0"
Expand Down
7 changes: 5 additions & 2 deletions src/components/FooterColumns.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import { useLocation } from 'react-router-dom';

import { Grid } from 'semantic-ui-react';

import { flattenHTMLToAppURL, flattenToAppURL } from '@plone/volto/helpers';
import { ConditionalLink } from '@plone/volto/components';
import {
flattenHTMLToAppURL,
flattenToAppURL,
} from '@plone/volto/helpers/Url/Url';
import ConditionalLink from '@plone/volto/components/manage/ConditionalLink/ConditionalLink';

import { getEditableFooterColumns } from '../actions';
import { getItemsByPath } from '../utils';
Expand Down
69 changes: 69 additions & 0 deletions src/widget/CustomRichTextWidget.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* CustomRichTextWidget, a slate widget variant that saves its data as HTML
*/

import React from 'react';

import { makeEditor } from '@plone/volto-slate/utils';
import deserialize from '@plone/volto-slate/editor/deserialize';

import {
createEmptyParagraph,
normalizeExternalData,
} from '@plone/volto-slate/utils';

import config from '@plone/volto/registry';

const CustomRichTextWidget = (props) => {
const {
id,
onChange,
value,
focus,
className,
block,
placeholder,
properties,
intl,
} = props;
const editor = React.useMemo(() => makeEditor(), []);

const fromHtml = React.useCallback(
(value) => {
const html = value?.data || '';

const parsed = new DOMParser().parseFromString(html, 'text/html');
const body =
parsed.getElementsByTagName('google-sheets-html-origin').length > 0
? parsed.querySelector('google-sheets-html-origin > table')
: parsed.body;
let data = deserialize(editor, body, { collapseWhitespace: false });
data = normalizeExternalData(editor, data);

// editor.children = data;
// Editor.normalize(editor);
// TODO: need to add {text: ""} placeholders between elements
const res = data.length ? data : [createEmptyParagraph()];
// console.log('from html', { html: value?.data, res });
return res;
},
[editor],
);

const _value = React.useMemo(() => {
return config.widgets.widget.slate && typeof value === 'string'
? fromHtml(value)
: value;
}, [value, fromHtml]);
let RichTextWidget = config.widgets.widget.richtext;
if (config.widgets.widget.slate) {
//there's slate in this site. Don't use widget.richtext because is html widget and cannot handle intl provider. So convert value to slate object and use config.widgets.widget.slate
RichTextWidget = config.widgets.widget.slate;
}

const editor = React.useMemo(() => makeEditor(), []);

return <RichTextWidget />;
};

export default CustomRichTextWidget;
2 changes: 1 addition & 1 deletion src/widget/FooterConfigurationForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
TextWidget,
CheckboxWidget,
ObjectBrowserWidget,
} from '@plone/volto/components';
} from '@plone/volto/components/manage/Widgets';

import config from '@plone/volto/registry';

Expand Down
2 changes: 1 addition & 1 deletion src/widget/FooterConfigurationWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Segment,
Header,
} from 'semantic-ui-react';
import { TextWidget } from '@plone/volto/components';
import { TextWidget } from '@plone/volto/components/manage/Widgets';
import { flattenToAppURL } from '@plone/volto/helpers/Url/Url';

import { FooterConfigurationForm } from './';
Expand Down

0 comments on commit 27db7f0

Please sign in to comment.