diff --git a/packages/volto-slate/src/actions/content.js b/packages/volto-slate/src/actions/content.js index ea00e9f155..39aea1d5c7 100644 --- a/packages/volto-slate/src/actions/content.js +++ b/packages/volto-slate/src/actions/content.js @@ -1,4 +1,4 @@ -import { nestContent } from '@plone/volto/helpers'; +import { nestContent } from '@plone/volto/helpers/Content/Content'; import { UPLOAD_CONTENT } from '@plone/volto-slate/constants'; // TODO: the PR has been merged into Volto, so this should be cleaned up diff --git a/packages/volto-slate/src/blocks/Table/TableBlockEdit.jsx b/packages/volto-slate/src/blocks/Table/TableBlockEdit.jsx index 96a493e9aa..cc6b381b80 100644 --- a/packages/volto-slate/src/blocks/Table/TableBlockEdit.jsx +++ b/packages/volto-slate/src/blocks/Table/TableBlockEdit.jsx @@ -5,13 +5,16 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import { isEmpty, map, remove } from 'lodash'; +import isEmpty from 'lodash/isEmpty'; +import map from 'lodash/map'; +import remove from 'lodash/remove'; import { Button, Table } from 'semantic-ui-react'; import cx from 'classnames'; import { defineMessages, injectIntl } from 'react-intl'; import Cell from './Cell'; -import { Icon, SidebarPortal } from '@plone/volto/components'; +import Icon from '@plone/volto/components/theme/Icon/Icon'; +import SidebarPortal from '@plone/volto/components/manage/Sidebar/SidebarPortal'; import { BlockDataForm } from '@plone/volto/components/manage/Form'; import TableSchema from './schema'; diff --git a/packages/volto-slate/src/blocks/Table/TableBlockView.jsx b/packages/volto-slate/src/blocks/Table/TableBlockView.jsx index 4e10c84dcc..6709862008 100644 --- a/packages/volto-slate/src/blocks/Table/TableBlockView.jsx +++ b/packages/volto-slate/src/blocks/Table/TableBlockView.jsx @@ -6,7 +6,7 @@ import React, { useState, useMemo } from 'react'; import PropTypes from 'prop-types'; import { Table } from 'semantic-ui-react'; -import { map } from 'lodash'; +import map from 'lodash/map'; import { serializeNodes, serializeNodesToText, diff --git a/packages/volto-slate/src/blocks/Text/DefaultTextBlockEditor.jsx b/packages/volto-slate/src/blocks/Text/DefaultTextBlockEditor.jsx index eeb1450dd9..385cc84a65 100644 --- a/packages/volto-slate/src/blocks/Text/DefaultTextBlockEditor.jsx +++ b/packages/volto-slate/src/blocks/Text/DefaultTextBlockEditor.jsx @@ -6,22 +6,20 @@ import { defineMessages, useIntl } from 'react-intl'; import { useInView } from 'react-intersection-observer'; import { Dimmer, Loader, Message, Segment } from 'semantic-ui-react'; -import { - flattenToAppURL, - getBaseUrl, - validateFileUploadSize, -} from '@plone/volto/helpers'; +import { flattenToAppURL, getBaseUrl } from '@plone/volto/helpers/Url/Url'; +import { validateFileUploadSize } from '@plone/volto/helpers/FormValidation/FormValidation'; import config from '@plone/volto/registry'; -import { SidebarPortal, BlockChooserButton } from '@plone/volto/components'; +import SidebarPortal from '@plone/volto/components/manage/Sidebar/SidebarPortal'; +import BlockChooserButton from '@plone/volto/components/manage/BlockChooser/BlockChooserButton'; import { BlockDataForm } from '@plone/volto/components/manage/Form'; import { SlateEditor } from '@plone/volto-slate/editor'; import { serializeNodesToText } from '@plone/volto-slate/editor/render'; import { createImageBlock, - parseDefaultSelection, deconstructToVoltoBlocks, -} from '@plone/volto-slate/utils'; +} from '@plone/volto-slate/utils/volto-blocks'; +import { parseDefaultSelection } from '@plone/volto-slate/utils/selection'; import { Transforms } from 'slate'; import PersistentSlashMenu from './SlashMenu'; diff --git a/packages/volto-slate/src/blocks/Text/SlashMenu.jsx b/packages/volto-slate/src/blocks/Text/SlashMenu.jsx index 9ec1612304..d9e2882108 100644 --- a/packages/volto-slate/src/blocks/Text/SlashMenu.jsx +++ b/packages/volto-slate/src/blocks/Text/SlashMenu.jsx @@ -1,10 +1,11 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { filter, isEmpty } from 'lodash'; +import filter from 'lodash/filter'; +import isEmpty from 'lodash/isEmpty'; import { Menu } from 'semantic-ui-react'; import { useIntl, FormattedMessage } from 'react-intl'; -import { Icon } from '@plone/volto/components'; -import { useUser } from '@plone/volto/hooks'; +import Icon from '@plone/volto/components/theme/Icon/Icon'; +import useUser from '@plone/volto/hooks/user/useUser'; const emptySlateBlock = () => ({ value: [ diff --git a/packages/volto-slate/src/blocks/Text/TextBlockEdit.jsx b/packages/volto-slate/src/blocks/Text/TextBlockEdit.jsx index 7a37884875..0c91b4c56e 100644 --- a/packages/volto-slate/src/blocks/Text/TextBlockEdit.jsx +++ b/packages/volto-slate/src/blocks/Text/TextBlockEdit.jsx @@ -2,10 +2,8 @@ import React from 'react'; import { connect } from 'react-redux'; -import { - uploadContent, - saveSlateBlockSelection, -} from '@plone/volto-slate/actions'; +import { uploadContent } from '@plone/volto-slate/actions/content'; +import saveSlateBlockSelection from '@plone/volto-slate/actions/selection'; import DefaultTextBlockEditor from './DefaultTextBlockEditor'; import DetachedTextBlockEditor from './DetachedTextBlockEditor'; diff --git a/packages/volto-slate/src/blocks/Text/TextBlockView.jsx b/packages/volto-slate/src/blocks/Text/TextBlockView.jsx index e25e603093..e78ea9d431 100644 --- a/packages/volto-slate/src/blocks/Text/TextBlockView.jsx +++ b/packages/volto-slate/src/blocks/Text/TextBlockView.jsx @@ -3,9 +3,9 @@ import { serializeNodesToText, } from '@plone/volto-slate/editor/render'; import config from '@plone/volto/registry'; -import { isEqual } from 'lodash'; +import isEqual from 'lodash/isEqual'; import Slugger from 'github-slugger'; -import { normalizeString } from '@plone/volto/helpers'; +import { normalizeString } from '@plone/volto/helpers/Utils/Utils'; const TextBlockView = (props) => { const { id, data, styling = {} } = props; diff --git a/packages/volto-slate/src/blocks/Text/extensions/breakList.js b/packages/volto-slate/src/blocks/Text/extensions/breakList.js index 81f0efd221..515b8c4c67 100644 --- a/packages/volto-slate/src/blocks/Text/extensions/breakList.js +++ b/packages/volto-slate/src/blocks/Text/extensions/breakList.js @@ -1,13 +1,11 @@ import { Editor, Range, Transforms } from 'slate'; import config from '@plone/volto/registry'; -import { - isCursorAtBlockEnd, - splitEditorInTwoFragments, - setEditorContent, - createAndSelectNewBlockAfter, - getCurrentListItem, - createEmptyParagraph, -} from '@plone/volto-slate/utils'; +import { isCursorAtBlockEnd } from '@plone/volto-slate/utils/selection'; +import { splitEditorInTwoFragments } from '@plone/volto-slate/utils/ops'; +import { setEditorContent } from '@plone/volto-slate/utils/editor'; +import { createAndSelectNewBlockAfter } from '@plone/volto-slate/utils/volto-blocks'; +import { getCurrentListItem } from '@plone/volto-slate/utils/lists'; +import { createEmptyParagraph } from '@plone/volto-slate/utils/blocks'; /** * Handles `Enter` key on empty and non-empty list items. diff --git a/packages/volto-slate/src/blocks/Text/extensions/insertBreak.js b/packages/volto-slate/src/blocks/Text/extensions/insertBreak.js index c7ffae1a23..91846daf3e 100644 --- a/packages/volto-slate/src/blocks/Text/extensions/insertBreak.js +++ b/packages/volto-slate/src/blocks/Text/extensions/insertBreak.js @@ -1,13 +1,10 @@ import ReactDOM from 'react-dom'; import { Editor } from 'slate'; // import { ReactEditor } from 'slate-react'; -import { - splitEditorInTwoFragments, - setEditorContent, - createAndSelectNewBlockAfter, - rangeIsInSplittableNode, - // deconstructToVoltoBlocks, -} from '@plone/volto-slate/utils'; +import { splitEditorInTwoFragments } from '@plone/volto-slate/utils/ops'; +import { setEditorContent } from '@plone/volto-slate/utils/editor'; +import { createAndSelectNewBlockAfter } from '@plone/volto-slate/utils/volto-blocks'; +import { rangeIsInSplittableNode } from '@plone/volto-slate/utils/internals'; /** * @param {Editor} editor The Slate editor object to extend. diff --git a/packages/volto-slate/src/blocks/Text/extensions/withDeserializers.js b/packages/volto-slate/src/blocks/Text/extensions/withDeserializers.js index dc994f80a8..e22e35b4d1 100644 --- a/packages/volto-slate/src/blocks/Text/extensions/withDeserializers.js +++ b/packages/volto-slate/src/blocks/Text/extensions/withDeserializers.js @@ -1,7 +1,8 @@ import isUrl from 'is-url'; import imageExtensions from 'image-extensions'; import { blockTagDeserializer } from '@plone/volto-slate/editor/deserialize'; -import { getBaseUrl, validateFileUploadSize } from '@plone/volto/helpers'; +import { getBaseUrl } from '@plone/volto/helpers/Url/Url'; +import { validateFileUploadSize } from '@plone/volto/helpers/FormValidation/FormValidation'; import { v4 as uuid } from 'uuid'; import { Transforms } from 'slate'; diff --git a/packages/volto-slate/src/blocks/Text/index.jsx b/packages/volto-slate/src/blocks/Text/index.jsx index 61ba8b500d..64c0a8017f 100644 --- a/packages/volto-slate/src/blocks/Text/index.jsx +++ b/packages/volto-slate/src/blocks/Text/index.jsx @@ -2,7 +2,7 @@ import React from 'react'; import TextBlockView from './TextBlockView'; import TextBlockEdit from './TextBlockEdit'; import TextBlockSchema from './TextBlockSchema'; -import { cloneDeep } from 'lodash'; +import cloneDeep from 'lodash/cloneDeep'; import { goDown, diff --git a/packages/volto-slate/src/blocks/Text/keyboard/backspaceInList.js b/packages/volto-slate/src/blocks/Text/keyboard/backspaceInList.js index 2fe86e2e09..dddbfea2ee 100644 --- a/packages/volto-slate/src/blocks/Text/keyboard/backspaceInList.js +++ b/packages/volto-slate/src/blocks/Text/keyboard/backspaceInList.js @@ -3,8 +3,8 @@ import config from '@plone/volto/registry'; import { isCursorInList, isCursorAtListBlockStart, - deconstructToVoltoBlocks, -} from '@plone/volto-slate/utils'; +} from '@plone/volto-slate/utils/lists'; +import { deconstructToVoltoBlocks } from '@plone/volto-slate/utils/volto-blocks'; /** * Handle the new Volto blocks created by `deconstructToVoltoBlocks`. diff --git a/packages/volto-slate/src/blocks/Text/keyboard/indentListItems.js b/packages/volto-slate/src/blocks/Text/keyboard/indentListItems.js index 4f9f81cba2..d137d9a1fb 100644 --- a/packages/volto-slate/src/blocks/Text/keyboard/indentListItems.js +++ b/packages/volto-slate/src/blocks/Text/keyboard/indentListItems.js @@ -1,11 +1,11 @@ import { Editor, Path, Transforms } from 'slate'; import { isCursorInList, - deconstructToVoltoBlocks, getCurrentListItem, mergeWithNextList, mergeWithPreviousList, -} from '@plone/volto-slate/utils'; +} from '@plone/volto-slate/utils/lists'; +import { deconstructToVoltoBlocks } from '@plone/volto-slate/utils/volto-blocks'; import config from '@plone/volto/registry'; /** diff --git a/packages/volto-slate/src/blocks/Text/keyboard/joinBlocks.js b/packages/volto-slate/src/blocks/Text/keyboard/joinBlocks.js index 4dbf7bc03a..8c166f8c0f 100644 --- a/packages/volto-slate/src/blocks/Text/keyboard/joinBlocks.js +++ b/packages/volto-slate/src/blocks/Text/keyboard/joinBlocks.js @@ -1,22 +1,24 @@ import ReactDOM from 'react-dom'; -import { cloneDeep } from 'lodash'; +import cloneDeep from 'lodash/cloneDeep'; import { serializeNodesToText } from '@plone/volto-slate/editor/render'; import { Editor } from 'slate'; import { getPreviousVoltoBlock, getNextVoltoBlock, - isCursorAtBlockStart, - isCursorAtBlockEnd, mergeSlateWithBlockBackward, mergeSlateWithBlockForward, - makeEditor, -} from '@plone/volto-slate/utils'; +} from '@plone/volto-slate/utils/volto-blocks'; +import { + isCursorAtBlockStart, + isCursorAtBlockEnd, +} from '@plone/volto-slate/utils/selection'; +import { makeEditor } from '@plone/volto-slate/utils/editor'; import { changeBlock, deleteBlock, getBlocksFieldname, getBlocksLayoutFieldname, -} from '@plone/volto/helpers'; +} from '@plone/volto/helpers/Blocks/Blocks'; /** * Joins the current block (which has an active Slate Editor) * with the previous block, to make a single block. diff --git a/packages/volto-slate/src/blocks/Text/keyboard/moveListItems.js b/packages/volto-slate/src/blocks/Text/keyboard/moveListItems.js index 1d977bedab..6f325e09b9 100644 --- a/packages/volto-slate/src/blocks/Text/keyboard/moveListItems.js +++ b/packages/volto-slate/src/blocks/Text/keyboard/moveListItems.js @@ -1,5 +1,8 @@ import { Editor, Path, Transforms, Node } from 'slate'; -import { isCursorInList, getCurrentListItem } from '@plone/volto-slate/utils'; +import { + isCursorInList, + getCurrentListItem, +} from '@plone/volto-slate/utils/lists'; import config from '@plone/volto/registry'; /** diff --git a/packages/volto-slate/src/blocks/Text/keyboard/traverseBlocks.js b/packages/volto-slate/src/blocks/Text/keyboard/traverseBlocks.js index 88ee26298f..f29abfba28 100644 --- a/packages/volto-slate/src/blocks/Text/keyboard/traverseBlocks.js +++ b/packages/volto-slate/src/blocks/Text/keyboard/traverseBlocks.js @@ -2,10 +2,12 @@ import { Node } from 'slate'; import { isCursorAtBlockStart, isCursorAtBlockEnd, +} from '@plone/volto-slate/utils/selection'; +import { getNextVoltoBlock, getPreviousVoltoBlock, - createDefaultBlock, -} from '@plone/volto-slate/utils'; +} from '@plone/volto-slate/utils/volto-blocks'; +import { createDefaultBlock } from '@plone/volto-slate/utils/blocks'; /** * goUp. diff --git a/packages/volto-slate/src/editor/SlateEditor.jsx b/packages/volto-slate/src/editor/SlateEditor.jsx index fe8457b191..6327abb883 100644 --- a/packages/volto-slate/src/editor/SlateEditor.jsx +++ b/packages/volto-slate/src/editor/SlateEditor.jsx @@ -1,6 +1,6 @@ import ReactDOM from 'react-dom'; import cx from 'classnames'; -import { isEqual } from 'lodash'; +import isEqual from 'lodash/isEqual'; import { Transforms, Editor } from 'slate'; // , Transforms import { Slate, Editable, ReactEditor } from 'slate-react'; import React, { Component } from 'react'; // , useState @@ -11,12 +11,10 @@ import config from '@plone/volto/registry'; import { Element, Leaf } from './render'; import withTestingFeatures from './extensions/withTestingFeatures'; -import { - makeEditor, - toggleInlineFormat, - toggleMark, - parseDefaultSelection, -} from '@plone/volto-slate/utils'; +import { makeEditor } from '@plone/volto-slate/utils/editor'; +import { toggleInlineFormat } from '@plone/volto-slate/utils/blocks'; +import { toggleMark } from '@plone/volto-slate/utils/marks'; +import { parseDefaultSelection } from '@plone/volto-slate/utils/selection'; import { InlineToolbar } from './ui'; import EditorContext from './EditorContext'; diff --git a/packages/volto-slate/src/editor/config.jsx b/packages/volto-slate/src/editor/config.jsx index d310812f7e..b52d6df413 100644 --- a/packages/volto-slate/src/editor/config.jsx +++ b/packages/volto-slate/src/editor/config.jsx @@ -15,7 +15,7 @@ import strikethroughIcon from '@plone/volto/icons/strikethrough.svg'; import subindexIcon from '@plone/volto/icons/subindex.svg'; import superindexIcon from '@plone/volto/icons/superindex.svg'; -import { createEmptyParagraph } from '@plone/volto-slate/utils'; +import { createEmptyParagraph } from '@plone/volto-slate/utils/blocks'; import { MarkElementButton, diff --git a/packages/volto-slate/src/editor/extensions/insertData.js b/packages/volto-slate/src/editor/extensions/insertData.js index 48c9a05f9b..ce95c3f91f 100644 --- a/packages/volto-slate/src/editor/extensions/insertData.js +++ b/packages/volto-slate/src/editor/extensions/insertData.js @@ -3,9 +3,9 @@ import { deserialize } from '@plone/volto-slate/editor/deserialize'; import { createBlock, createDefaultBlock, - MIMETypeName, normalizeExternalData, -} from '@plone/volto-slate/utils'; +} from '@plone/volto-slate/utils/blocks'; +import { MIMETypeName } from '@plone/volto-slate/utils/mime-types'; import { isBlockActive } from '../../utils/blocks'; export const insertData = (editor) => { diff --git a/packages/volto-slate/src/editor/extensions/normalizeExternalData.js b/packages/volto-slate/src/editor/extensions/normalizeExternalData.js index d04c1d1255..a225372877 100644 --- a/packages/volto-slate/src/editor/extensions/normalizeExternalData.js +++ b/packages/volto-slate/src/editor/extensions/normalizeExternalData.js @@ -1,4 +1,4 @@ -import { normalizeExternalData as normalize } from '@plone/volto-slate/utils'; +import { normalizeExternalData as normalize } from '@plone/volto-slate/utils/blocks'; export function normalizeExternalData(editor) { editor.normalizeExternalData = (fragment) => { diff --git a/packages/volto-slate/src/editor/extensions/withTestingFeatures.jsx b/packages/volto-slate/src/editor/extensions/withTestingFeatures.jsx index 914092b788..3565c8fbf5 100644 --- a/packages/volto-slate/src/editor/extensions/withTestingFeatures.jsx +++ b/packages/volto-slate/src/editor/extensions/withTestingFeatures.jsx @@ -1,6 +1,6 @@ import React, { useMemo } from 'react'; import { ReactEditor } from 'slate-react'; -import { omit } from 'lodash'; +import omit from 'lodash/omit'; const withTestingFeatures = (WrappedComponent) => { return (props) => { diff --git a/packages/volto-slate/src/editor/plugins/AdvancedLink/deserialize.js b/packages/volto-slate/src/editor/plugins/AdvancedLink/deserialize.js index 2359e452c8..8ce874b129 100644 --- a/packages/volto-slate/src/editor/plugins/AdvancedLink/deserialize.js +++ b/packages/volto-slate/src/editor/plugins/AdvancedLink/deserialize.js @@ -1,7 +1,7 @@ import { jsx } from 'slate-hyperscript'; import { LINK } from '@plone/volto-slate/constants'; import { deserialize } from '@plone/volto-slate/editor/deserialize'; -import { isEmpty } from 'lodash'; +import isEmpty from 'lodash/isEmpty'; // import { Editor } from 'slate'; /** diff --git a/packages/volto-slate/src/editor/plugins/AdvancedLink/render.jsx b/packages/volto-slate/src/editor/plugins/AdvancedLink/render.jsx index 2af0400b94..12d9591d0d 100644 --- a/packages/volto-slate/src/editor/plugins/AdvancedLink/render.jsx +++ b/packages/volto-slate/src/editor/plugins/AdvancedLink/render.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { UniversalLink } from '@plone/volto/components'; +import UniversalLink from '@plone/volto/components/manage/UniversalLink/UniversalLink'; import './styles.less'; export const LinkElement = ({ attributes, children, element, mode }) => { diff --git a/packages/volto-slate/src/editor/plugins/Link/index.jsx b/packages/volto-slate/src/editor/plugins/Link/index.jsx index c21296f75d..3035c1c4b0 100644 --- a/packages/volto-slate/src/editor/plugins/Link/index.jsx +++ b/packages/volto-slate/src/editor/plugins/Link/index.jsx @@ -12,12 +12,12 @@ import { import { SIMPLELINK, LINK } from '@plone/volto-slate/constants'; import { LinkElement } from './render'; import { simpleLinkDeserializer, withSimpleLink } from './extensions'; -import { setPluginOptions } from '@plone/volto-slate/actions'; +import { setPluginOptions } from '@plone/volto-slate/actions/plugins'; import { ToolbarButton as UIToolbarButton, PositionedToolbar, } from '@plone/volto-slate/editor/ui'; -import { useSelectionPosition } from '@plone/volto-slate/hooks'; +import { useSelectionPosition } from '@plone/volto-slate/hooks/useSelectionPosition'; import linkSVG from '@plone/volto/icons/link.svg'; import unlinkSVG from '@plone/volto/icons/unlink.svg'; diff --git a/packages/volto-slate/src/editor/plugins/Link/render.jsx b/packages/volto-slate/src/editor/plugins/Link/render.jsx index 06174d5920..7df5fdd9bb 100644 --- a/packages/volto-slate/src/editor/plugins/Link/render.jsx +++ b/packages/volto-slate/src/editor/plugins/Link/render.jsx @@ -1,8 +1,8 @@ import React from 'react'; import cx from 'classnames'; -import { UniversalLink } from '@plone/volto/components'; +import UniversalLink from '@plone/volto/components/manage/UniversalLink/UniversalLink'; import config from '@plone/volto/registry'; -import { isInternalURL, flattenToAppURL } from '@plone/volto/helpers'; +import { isInternalURL, flattenToAppURL } from '@plone/volto/helpers/Url/Url'; const ViewLink = ({ url, target, download, children }) => { const { openExternalLinkInNewTab } = config.settings; diff --git a/packages/volto-slate/src/editor/plugins/Markdown/constants.js b/packages/volto-slate/src/editor/plugins/Markdown/constants.js index 4798b26be3..125e7ab0b0 100644 --- a/packages/volto-slate/src/editor/plugins/Markdown/constants.js +++ b/packages/volto-slate/src/editor/plugins/Markdown/constants.js @@ -1,5 +1,5 @@ import { toggleList } from './utils'; -import { isBlockActive } from '@plone/volto-slate/utils'; +import { isBlockActive } from '@plone/volto-slate/utils/blocks'; import { UL, OL, LI, H2, H3, BLOCKQUOTE } from '@plone/volto-slate/constants'; /** diff --git a/packages/volto-slate/src/editor/plugins/Markdown/extensions.js b/packages/volto-slate/src/editor/plugins/Markdown/extensions.js index 0c40c05d11..fc7d2ed211 100644 --- a/packages/volto-slate/src/editor/plugins/Markdown/extensions.js +++ b/packages/volto-slate/src/editor/plugins/Markdown/extensions.js @@ -1,4 +1,5 @@ -import { castArray, map } from 'lodash'; +import castArray from 'lodash/castArray'; +import map from 'lodash/map'; import { Editor, Path, Point, Range, Transforms } from 'slate'; /** diff --git a/packages/volto-slate/src/editor/plugins/Markdown/utils.js b/packages/volto-slate/src/editor/plugins/Markdown/utils.js index db29e30a20..0151400256 100644 --- a/packages/volto-slate/src/editor/plugins/Markdown/utils.js +++ b/packages/volto-slate/src/editor/plugins/Markdown/utils.js @@ -3,7 +3,7 @@ import { getMaxRange, selectAll, getSelectionNodesArrayByType, -} from '@plone/volto-slate/utils'; +} from '@plone/volto-slate/utils/selection'; import { P, LI, UL, OL } from '@plone/volto-slate/constants'; export function unwrapNodesByType(editor, types, options = {}) { diff --git a/packages/volto-slate/src/editor/plugins/StyleMenu/StyleMenu.jsx b/packages/volto-slate/src/editor/plugins/StyleMenu/StyleMenu.jsx index 2771759873..2df03288de 100644 --- a/packages/volto-slate/src/editor/plugins/StyleMenu/StyleMenu.jsx +++ b/packages/volto-slate/src/editor/plugins/StyleMenu/StyleMenu.jsx @@ -3,7 +3,7 @@ import { useSlate } from 'slate-react'; import { Dropdown } from 'semantic-ui-react'; import { useIntl, defineMessages } from 'react-intl'; import cx from 'classnames'; -import { omit } from 'lodash'; +import omit from 'lodash/omit'; import { isBlockStyleActive, isInlineStyleActive, toggleStyle } from './utils'; import config from '@plone/volto/registry'; import { ToolbarButton } from '@plone/volto-slate/editor/ui'; diff --git a/packages/volto-slate/src/editor/plugins/StyleMenu/utils.js b/packages/volto-slate/src/editor/plugins/StyleMenu/utils.js index 4090c8d750..04d76d0673 100644 --- a/packages/volto-slate/src/editor/plugins/StyleMenu/utils.js +++ b/packages/volto-slate/src/editor/plugins/StyleMenu/utils.js @@ -1,6 +1,6 @@ /* eslint no-console: ["error", { allow: ["warn", "error"] }] */ import { Editor, Transforms } from 'slate'; -import { isBlockActive } from '@plone/volto-slate/utils'; +import { isBlockActive } from '@plone/volto-slate/utils/blocks'; import config from '@plone/volto/registry'; /** diff --git a/packages/volto-slate/src/editor/render.jsx b/packages/volto-slate/src/editor/render.jsx index 2d3aad41ad..ce73119d1b 100644 --- a/packages/volto-slate/src/editor/render.jsx +++ b/packages/volto-slate/src/editor/render.jsx @@ -6,9 +6,12 @@ import { useIntl } from 'react-intl'; import { useSelector } from 'react-redux'; import { Node, Text } from 'slate'; import cx from 'classnames'; -import { isEmpty, omit } from 'lodash'; -import { UniversalLink, Toast } from '@plone/volto/components'; -import { messages, addAppURL } from '@plone/volto/helpers'; +import isEmpty from 'lodash/isEmpty'; +import omit from 'lodash/omit'; +import UniversalLink from '@plone/volto/components/manage/UniversalLink/UniversalLink'; +import Toast from '@plone/volto/components/manage/Toast/Toast'; +import { messages } from '@plone/volto/helpers/MessageLabels/MessageLabels'; +import { addAppURL } from '@plone/volto/helpers/Url/Url'; import useClipboard from '@plone/volto/hooks/clipboard/useClipboard'; import config from '@plone/volto/registry'; import linkSVG from '@plone/volto/icons/link.svg'; diff --git a/packages/volto-slate/src/editor/ui/BlockButton.jsx b/packages/volto-slate/src/editor/ui/BlockButton.jsx index ee03fbbed6..cdc70b6b0d 100644 --- a/packages/volto-slate/src/editor/ui/BlockButton.jsx +++ b/packages/volto-slate/src/editor/ui/BlockButton.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { useSlate } from 'slate-react'; -import { isBlockActive, toggleBlock } from '@plone/volto-slate/utils'; +import { isBlockActive, toggleBlock } from '@plone/volto-slate/utils/blocks'; import ToolbarButton from './ToolbarButton'; diff --git a/packages/volto-slate/src/editor/ui/ClearFormattingButton.jsx b/packages/volto-slate/src/editor/ui/ClearFormattingButton.jsx index c1b6f234a9..5708963f68 100644 --- a/packages/volto-slate/src/editor/ui/ClearFormattingButton.jsx +++ b/packages/volto-slate/src/editor/ui/ClearFormattingButton.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { useSlate } from 'slate-react'; -import { clearFormatting } from '@plone/volto-slate/utils'; +import { clearFormatting } from '@plone/volto-slate/utils/blocks'; import ToolbarButton from './ToolbarButton'; diff --git a/packages/volto-slate/src/editor/ui/InlineToolbar.jsx b/packages/volto-slate/src/editor/ui/InlineToolbar.jsx index 0567645f91..ea1d501b51 100644 --- a/packages/volto-slate/src/editor/ui/InlineToolbar.jsx +++ b/packages/volto-slate/src/editor/ui/InlineToolbar.jsx @@ -2,7 +2,7 @@ import React from 'react'; // , useState import SlateToolbar from './SlateToolbar'; import SlateContextToolbar from './SlateContextToolbar'; import config from '@plone/volto/registry'; -import { hasRangeSelection } from '@plone/volto-slate/utils'; +import { hasRangeSelection } from '@plone/volto-slate/utils/selection'; import { ReactEditor } from 'slate-react'; import cx from 'classnames'; diff --git a/packages/volto-slate/src/editor/ui/MarkButton.jsx b/packages/volto-slate/src/editor/ui/MarkButton.jsx index d3433d50ab..affd3118d2 100644 --- a/packages/volto-slate/src/editor/ui/MarkButton.jsx +++ b/packages/volto-slate/src/editor/ui/MarkButton.jsx @@ -1,7 +1,7 @@ import React from 'react'; import { useSlate } from 'slate-react'; -import { isMarkActive, toggleMark } from '@plone/volto-slate/utils'; +import { isMarkActive, toggleMark } from '@plone/volto-slate/utils/marks'; import ToolbarButton from './ToolbarButton'; const MarkButton = ({ format, icon, ...props }) => { diff --git a/packages/volto-slate/src/editor/ui/MarkElementButton.jsx b/packages/volto-slate/src/editor/ui/MarkElementButton.jsx index 87c6ba4b21..f18c53c0ae 100644 --- a/packages/volto-slate/src/editor/ui/MarkElementButton.jsx +++ b/packages/volto-slate/src/editor/ui/MarkElementButton.jsx @@ -1,6 +1,9 @@ import React from 'react'; import { useSlate } from 'slate-react'; -import { isBlockActive, toggleInlineFormat } from '@plone/volto-slate/utils'; +import { + isBlockActive, + toggleInlineFormat, +} from '@plone/volto-slate/utils/blocks'; import ToolbarButton from './ToolbarButton'; diff --git a/packages/volto-slate/src/editor/ui/ToolbarButton.jsx b/packages/volto-slate/src/editor/ui/ToolbarButton.jsx index 11754d2937..ef13c3f285 100644 --- a/packages/volto-slate/src/editor/ui/ToolbarButton.jsx +++ b/packages/volto-slate/src/editor/ui/ToolbarButton.jsx @@ -1,6 +1,6 @@ import cx from 'classnames'; import React from 'react'; -import { Icon } from '@plone/volto/components'; +import Icon from '@plone/volto/components/theme/Icon/Icon'; import { Button } from 'semantic-ui-react'; import { useIntl } from 'react-intl'; diff --git a/packages/volto-slate/src/elementEditor/ContextButtons.jsx b/packages/volto-slate/src/elementEditor/ContextButtons.jsx index 65895888a8..9902caed0f 100644 --- a/packages/volto-slate/src/elementEditor/ContextButtons.jsx +++ b/packages/volto-slate/src/elementEditor/ContextButtons.jsx @@ -5,7 +5,7 @@ import { useIntl } from 'react-intl'; // , defineMessages import clearSVG from '@plone/volto/icons/delete.svg'; import { ToolbarButton } from '@plone/volto-slate/editor/ui'; -import { setPluginOptions } from '@plone/volto-slate/actions'; +import { setPluginOptions } from '@plone/volto-slate/actions/plugins'; /* * Note: this is a weirder component, it should be called as a native function diff --git a/packages/volto-slate/src/elementEditor/PluginEditor.jsx b/packages/volto-slate/src/elementEditor/PluginEditor.jsx index e33b87ec27..d820c19851 100644 --- a/packages/volto-slate/src/elementEditor/PluginEditor.jsx +++ b/packages/volto-slate/src/elementEditor/PluginEditor.jsx @@ -1,11 +1,11 @@ /* eslint no-console: ["error", { allow: ["error"] }] */ -import { isEqual } from 'lodash'; +import isEqual from 'lodash/isEqual'; import React from 'react'; import { useDispatch } from 'react-redux'; import { ReactEditor } from 'slate-react'; -import { Icon as VoltoIcon } from '@plone/volto/components'; +import VoltoIcon from '@plone/volto/components/theme/Icon/Icon'; import { BlockDataForm } from '@plone/volto/components/manage/Form'; -import { setPluginOptions } from '@plone/volto-slate/actions'; +import { setPluginOptions } from '@plone/volto-slate/actions/plugins'; import BaseSchemaProvider from './SchemaProvider'; import briefcaseSVG from '@plone/volto/icons/briefcase.svg'; diff --git a/packages/volto-slate/src/elementEditor/SidebarEditor.jsx b/packages/volto-slate/src/elementEditor/SidebarEditor.jsx index f91bef80de..bea02391c6 100644 --- a/packages/volto-slate/src/elementEditor/SidebarEditor.jsx +++ b/packages/volto-slate/src/elementEditor/SidebarEditor.jsx @@ -5,8 +5,8 @@ */ import React from 'react'; import { useSelector, useDispatch } from 'react-redux'; -import { SidebarPopup } from '@plone/volto/components'; -import { setPluginOptions } from '@plone/volto-slate/actions'; +import SidebarPopup from '@plone/volto/components/manage/Sidebar/SidebarPopup'; +import { setPluginOptions } from '@plone/volto-slate/actions/plugins'; const SidebarEditor = (props) => { const { editor, pluginId, getActiveElement, pluginEditor } = props; diff --git a/packages/volto-slate/src/elementEditor/ToolbarButton.jsx b/packages/volto-slate/src/elementEditor/ToolbarButton.jsx index 3f26d6e73f..4c3f69c802 100644 --- a/packages/volto-slate/src/elementEditor/ToolbarButton.jsx +++ b/packages/volto-slate/src/elementEditor/ToolbarButton.jsx @@ -4,11 +4,11 @@ import React from 'react'; import { useSlate } from 'slate-react'; import { useDispatch } from 'react-redux'; -import { omit } from 'lodash'; +import omit from 'lodash/omit'; import { ToolbarButton } from '@plone/volto-slate/editor/ui'; -import { hasRangeSelection } from '@plone/volto-slate/utils'; -import { setPluginOptions } from '@plone/volto-slate/actions'; +import { hasRangeSelection } from '@plone/volto-slate/utils/selection'; +import { setPluginOptions } from '@plone/volto-slate/actions/plugins'; const ElementToolbarButton = (props) => { const { isActiveElement, insertElement, pluginId, toolbarButtonIcon } = props; diff --git a/packages/volto-slate/src/elementEditor/makeInlineElementPlugin.js b/packages/volto-slate/src/elementEditor/makeInlineElementPlugin.js index 0cf45e3d0e..65fde10cd4 100644 --- a/packages/volto-slate/src/elementEditor/makeInlineElementPlugin.js +++ b/packages/volto-slate/src/elementEditor/makeInlineElementPlugin.js @@ -11,7 +11,7 @@ import { import messages from './messages'; import ToolbarButton from './ToolbarButton'; import SchemaProvider from './SchemaProvider'; -import { omit } from 'lodash'; +import omit from 'lodash/omit'; import tagSVG from '@plone/volto/icons/tag.svg'; diff --git a/packages/volto-slate/src/utils/blocks.js b/packages/volto-slate/src/utils/blocks.js index 4175ebeddb..648314b6ce 100644 --- a/packages/volto-slate/src/utils/blocks.js +++ b/packages/volto-slate/src/utils/blocks.js @@ -4,8 +4,11 @@ import config from '@plone/volto/registry'; import { getBlocksFieldname, getBlocksLayoutFieldname, -} from '@plone/volto/helpers'; -import _ from 'lodash'; +} from '@plone/volto/helpers/Blocks/Blocks'; +import find from 'lodash/find'; +import includes from 'lodash/includes'; +import some from 'lodash/some'; +import first from 'lodash/first'; import { makeEditor } from './editor'; // case sensitive; first in an inner array is the default and preffered format @@ -145,10 +148,10 @@ export const isSingleBlockTypeActive = (editor, format) => { }; export const isBlockActive = (editor, format) => { - const aliasList = _.find(formatAliases, (x) => _.includes(x, format)); + const aliasList = find(formatAliases, (x) => includes(x, format)); if (aliasList) { - const aliasFound = _.some(aliasList, (y) => { + const aliasFound = some(aliasList, (y) => { return isSingleBlockTypeActive(editor, y); }); @@ -163,17 +166,17 @@ export const isBlockActive = (editor, format) => { export const getBlockTypeContextData = (editor, format) => { let isActive, defaultFormat, matcher; - const aliasList = _.find(formatAliases, (x) => _.includes(x, format)); + const aliasList = find(formatAliases, (x) => includes(x, format)); if (aliasList) { - const aliasFound = _.some(aliasList, (y) => { + const aliasFound = some(aliasList, (y) => { return isSingleBlockTypeActive(editor, y); }); if (aliasFound) { isActive = true; - defaultFormat = _.first(aliasList); - matcher = (n) => _.includes(aliasList, n.type); + defaultFormat = first(aliasList); + matcher = (n) => includes(aliasList, n.type); return { isActive, defaultFormat, matcher }; } diff --git a/packages/volto-slate/src/utils/selection.js b/packages/volto-slate/src/utils/selection.js index 71e78b262d..8fea1e3824 100644 --- a/packages/volto-slate/src/utils/selection.js +++ b/packages/volto-slate/src/utils/selection.js @@ -1,7 +1,9 @@ -import { castArray, cloneDeep } from 'lodash'; +import castArray from 'lodash/castArray'; +import cloneDeep from 'lodash/cloneDeep'; import { Editor, Transforms, Range, Node } from 'slate'; import { ReactEditor } from 'slate-react'; -import { isCursorInList, makeEditor } from '@plone/volto-slate/utils'; +import { isCursorInList } from '@plone/volto-slate/utils/lists'; +import { makeEditor } from '@plone/volto-slate/utils/editor'; import { LI } from '@plone/volto-slate/constants'; import config from '@plone/volto/registry'; diff --git a/packages/volto-slate/src/utils/volto-blocks.js b/packages/volto-slate/src/utils/volto-blocks.js index 55367223e6..e01a40cc68 100644 --- a/packages/volto-slate/src/utils/volto-blocks.js +++ b/packages/volto-slate/src/utils/volto-blocks.js @@ -7,10 +7,10 @@ import { blockHasValue, getBlocksFieldname, getBlocksLayoutFieldname, -} from '@plone/volto/helpers'; +} from '@plone/volto/helpers/Blocks/Blocks'; import { Transforms, Editor, Node, Text, Path } from 'slate'; import { serializeNodesToText } from '@plone/volto-slate/editor/render'; -import { omit } from 'lodash'; +import omit from 'lodash/omit'; import config from '@plone/volto/registry'; function fromEntries(pairs) { diff --git a/packages/volto-slate/src/widgets/HtmlSlateWidget.jsx b/packages/volto-slate/src/widgets/HtmlSlateWidget.jsx index ba7367ccd9..cdd37527ea 100644 --- a/packages/volto-slate/src/widgets/HtmlSlateWidget.jsx +++ b/packages/volto-slate/src/widgets/HtmlSlateWidget.jsx @@ -12,7 +12,7 @@ import { defineMessages, injectIntl } from 'react-intl'; import { FormFieldWrapper } from '@plone/volto/components/manage/Widgets'; import SlateEditor from '@plone/volto-slate/editor/SlateEditor'; import { serializeNodes } from '@plone/volto-slate/editor/render'; -import { makeEditor } from '@plone/volto-slate/utils'; +import { makeEditor } from '@plone/volto-slate/utils/editor'; import deserialize from '@plone/volto-slate/editor/deserialize'; import { diff --git a/packages/volto-slate/src/widgets/ObjectByTypeWidget.jsx b/packages/volto-slate/src/widgets/ObjectByTypeWidget.jsx index a97f3c28de..f736fd28af 100644 --- a/packages/volto-slate/src/widgets/ObjectByTypeWidget.jsx +++ b/packages/volto-slate/src/widgets/ObjectByTypeWidget.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { Menu, Tab } from 'semantic-ui-react'; -import { Icon } from '@plone/volto/components'; +import Icon from '@plone/volto/components/theme/Icon/Icon'; import { ObjectWidget } from '@plone/volto/components/manage/Widgets'; export const ObjectByTypeWidget = (props) => {