@plone/volto-slate 18.0.1 → 18.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/.eslintrc.js +7 -0
  2. package/CHANGELOG.md +12 -0
  3. package/package.json +1 -1
  4. package/src/actions/content.js +1 -1
  5. package/src/blocks/Table/TableBlockEdit.jsx +5 -2
  6. package/src/blocks/Table/TableBlockView.jsx +1 -1
  7. package/src/blocks/Text/DefaultTextBlockEditor.jsx +6 -8
  8. package/src/blocks/Text/SlashMenu.jsx +4 -3
  9. package/src/blocks/Text/TextBlockEdit.jsx +2 -4
  10. package/src/blocks/Text/TextBlockView.jsx +2 -2
  11. package/src/blocks/Text/extensions/breakList.js +6 -8
  12. package/src/blocks/Text/extensions/insertBreak.js +4 -7
  13. package/src/blocks/Text/extensions/withDeserializers.js +2 -1
  14. package/src/blocks/Text/index.jsx +1 -1
  15. package/src/blocks/Text/keyboard/backspaceInList.js +2 -2
  16. package/src/blocks/Text/keyboard/indentListItems.js +2 -2
  17. package/src/blocks/Text/keyboard/joinBlocks.js +8 -6
  18. package/src/blocks/Text/keyboard/moveListItems.js +4 -1
  19. package/src/blocks/Text/keyboard/traverseBlocks.js +4 -2
  20. package/src/editor/SlateEditor.jsx +5 -7
  21. package/src/editor/config.jsx +1 -1
  22. package/src/editor/extensions/insertData.js +2 -2
  23. package/src/editor/extensions/normalizeExternalData.js +1 -1
  24. package/src/editor/extensions/withTestingFeatures.jsx +1 -1
  25. package/src/editor/plugins/AdvancedLink/deserialize.js +1 -1
  26. package/src/editor/plugins/AdvancedLink/render.jsx +1 -1
  27. package/src/editor/plugins/Blockquote/index.jsx +1 -1
  28. package/src/editor/plugins/Callout/index.jsx +1 -1
  29. package/src/editor/plugins/Link/index.jsx +4 -6
  30. package/src/editor/plugins/Link/render.jsx +2 -2
  31. package/src/editor/plugins/Markdown/constants.js +1 -1
  32. package/src/editor/plugins/Markdown/extensions.js +2 -1
  33. package/src/editor/plugins/Markdown/utils.js +1 -1
  34. package/src/editor/plugins/StyleMenu/StyleMenu.jsx +2 -2
  35. package/src/editor/plugins/StyleMenu/utils.js +1 -1
  36. package/src/editor/plugins/Table/TableButton.jsx +1 -1
  37. package/src/editor/plugins/Table/index.jsx +1 -1
  38. package/src/editor/render.jsx +6 -3
  39. package/src/editor/ui/BlockButton.jsx +1 -1
  40. package/src/editor/ui/ClearFormattingButton.jsx +1 -1
  41. package/src/editor/ui/InlineToolbar.jsx +1 -1
  42. package/src/editor/ui/MarkButton.jsx +1 -1
  43. package/src/editor/ui/MarkElementButton.jsx +4 -1
  44. package/src/editor/ui/ToolbarButton.jsx +1 -1
  45. package/src/elementEditor/ContextButtons.jsx +2 -2
  46. package/src/elementEditor/PluginEditor.jsx +3 -3
  47. package/src/elementEditor/SidebarEditor.jsx +2 -2
  48. package/src/elementEditor/ToolbarButton.jsx +4 -4
  49. package/src/elementEditor/{makeInlineElementPlugin.js → makeInlineElementPlugin.jsx} +1 -1
  50. package/src/utils/blocks.js +11 -8
  51. package/src/utils/selection.js +4 -2
  52. package/src/utils/volto-blocks.js +2 -2
  53. package/src/widgets/HtmlSlateWidget.jsx +1 -1
  54. package/src/widgets/ObjectByTypeWidget.jsx +1 -1
  55. /package/src/blocks/Table/{Cell.test.js → Cell.test.jsx} +0 -0
  56. /package/src/blocks/Table/{TableBlockEdit.test.js → TableBlockEdit.test.jsx} +0 -0
  57. /package/src/blocks/Table/{TableBlockView.test.js → TableBlockView.test.jsx} +0 -0
  58. /package/src/blocks/Text/{TextBlockEdit.test.js → TextBlockEdit.test.jsx} +0 -0
  59. /package/src/editor/ui/{ToolbarButton.test.js → ToolbarButton.test.jsx} +0 -0
package/.eslintrc.js CHANGED
@@ -3,4 +3,11 @@ module.exports = {
3
3
  rules: {
4
4
  'import/no-unresolved': 0,
5
5
  },
6
+ settings: {
7
+ 'import/resolver': {
8
+ alias: {
9
+ map: [['@plone/volto-slate', './src']],
10
+ },
11
+ },
12
+ },
6
13
  };
package/CHANGELOG.md CHANGED
@@ -8,6 +8,18 @@
8
8
 
9
9
  <!-- towncrier release notes start -->
10
10
 
11
+ ## 18.0.3 (2024-12-09)
12
+
13
+ ### Internal
14
+
15
+ - Fix extension in files containing JSX. @sneridagh [#6520](https://github.com/plone/volto/issues/6520)
16
+
17
+ ## 18.0.2 (2024-12-08)
18
+
19
+ ### Internal
20
+
21
+ - Removed all imports from barrel files for components, actions, helpers, hooks and lodash. @pnicolli [#6509](https://github.com/plone/volto/issues/6509)
22
+
11
23
  ## 18.0.1 (2024-11-11)
12
24
 
13
25
  ### Feature
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plone/volto-slate",
3
- "version": "18.0.1",
3
+ "version": "18.0.3",
4
4
  "description": "Slate.js integration with Volto",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -1,4 +1,4 @@
1
- import { nestContent } from '@plone/volto/helpers';
1
+ import { nestContent } from '@plone/volto/helpers/Content/Content';
2
2
  import { UPLOAD_CONTENT } from '@plone/volto-slate/constants';
3
3
 
4
4
  // TODO: the PR has been merged into Volto, so this should be cleaned up
@@ -5,13 +5,16 @@
5
5
 
6
6
  import React, { Component } from 'react';
7
7
  import PropTypes from 'prop-types';
8
- import { isEmpty, map, remove } from 'lodash';
8
+ import isEmpty from 'lodash/isEmpty';
9
+ import map from 'lodash/map';
10
+ import remove from 'lodash/remove';
9
11
  import { Button, Table } from 'semantic-ui-react';
10
12
  import cx from 'classnames';
11
13
  import { defineMessages, injectIntl } from 'react-intl';
12
14
 
13
15
  import Cell from './Cell';
14
- import { Icon, SidebarPortal } from '@plone/volto/components';
16
+ import Icon from '@plone/volto/components/theme/Icon/Icon';
17
+ import SidebarPortal from '@plone/volto/components/manage/Sidebar/SidebarPortal';
15
18
  import { BlockDataForm } from '@plone/volto/components/manage/Form';
16
19
  import TableSchema from './schema';
17
20
 
@@ -6,7 +6,7 @@
6
6
  import React, { useState, useMemo } from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import { Table } from 'semantic-ui-react';
9
- import { map } from 'lodash';
9
+ import map from 'lodash/map';
10
10
  import {
11
11
  serializeNodes,
12
12
  serializeNodesToText,
@@ -6,22 +6,20 @@ import { defineMessages, useIntl } from 'react-intl';
6
6
  import { useInView } from 'react-intersection-observer';
7
7
  import { Dimmer, Loader, Message, Segment } from 'semantic-ui-react';
8
8
 
9
- import {
10
- flattenToAppURL,
11
- getBaseUrl,
12
- validateFileUploadSize,
13
- } from '@plone/volto/helpers';
9
+ import { flattenToAppURL, getBaseUrl } from '@plone/volto/helpers/Url/Url';
10
+ import { validateFileUploadSize } from '@plone/volto/helpers/FormValidation/FormValidation';
14
11
  import config from '@plone/volto/registry';
15
- import { SidebarPortal, BlockChooserButton } from '@plone/volto/components';
12
+ import SidebarPortal from '@plone/volto/components/manage/Sidebar/SidebarPortal';
13
+ import BlockChooserButton from '@plone/volto/components/manage/BlockChooser/BlockChooserButton';
16
14
  import { BlockDataForm } from '@plone/volto/components/manage/Form';
17
15
 
18
16
  import { SlateEditor } from '@plone/volto-slate/editor';
19
17
  import { serializeNodesToText } from '@plone/volto-slate/editor/render';
20
18
  import {
21
19
  createImageBlock,
22
- parseDefaultSelection,
23
20
  deconstructToVoltoBlocks,
24
- } from '@plone/volto-slate/utils';
21
+ } from '@plone/volto-slate/utils/volto-blocks';
22
+ import { parseDefaultSelection } from '@plone/volto-slate/utils/selection';
25
23
  import { Transforms } from 'slate';
26
24
 
27
25
  import PersistentSlashMenu from './SlashMenu';
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { filter, isEmpty } from 'lodash';
3
+ import filter from 'lodash/filter';
4
+ import isEmpty from 'lodash/isEmpty';
4
5
  import { Menu } from 'semantic-ui-react';
5
6
  import { useIntl, FormattedMessage } from 'react-intl';
6
- import { Icon } from '@plone/volto/components';
7
- import { useUser } from '@plone/volto/hooks';
7
+ import Icon from '@plone/volto/components/theme/Icon/Icon';
8
+ import useUser from '@plone/volto/hooks/user/useUser';
8
9
 
9
10
  const emptySlateBlock = () => ({
10
11
  value: [
@@ -2,10 +2,8 @@ import React from 'react';
2
2
 
3
3
  import { connect } from 'react-redux';
4
4
 
5
- import {
6
- uploadContent,
7
- saveSlateBlockSelection,
8
- } from '@plone/volto-slate/actions';
5
+ import { uploadContent } from '@plone/volto-slate/actions/content';
6
+ import saveSlateBlockSelection from '@plone/volto-slate/actions/selection';
9
7
 
10
8
  import DefaultTextBlockEditor from './DefaultTextBlockEditor';
11
9
  import DetachedTextBlockEditor from './DetachedTextBlockEditor';
@@ -3,9 +3,9 @@ import {
3
3
  serializeNodesToText,
4
4
  } from '@plone/volto-slate/editor/render';
5
5
  import config from '@plone/volto/registry';
6
- import { isEqual } from 'lodash';
6
+ import isEqual from 'lodash/isEqual';
7
7
  import Slugger from 'github-slugger';
8
- import { normalizeString } from '@plone/volto/helpers';
8
+ import { normalizeString } from '@plone/volto/helpers/Utils/Utils';
9
9
 
10
10
  const TextBlockView = (props) => {
11
11
  const { id, data, styling = {} } = props;
@@ -1,13 +1,11 @@
1
1
  import { Editor, Range, Transforms } from 'slate';
2
2
  import config from '@plone/volto/registry';
3
- import {
4
- isCursorAtBlockEnd,
5
- splitEditorInTwoFragments,
6
- setEditorContent,
7
- createAndSelectNewBlockAfter,
8
- getCurrentListItem,
9
- createEmptyParagraph,
10
- } from '@plone/volto-slate/utils';
3
+ import { isCursorAtBlockEnd } from '@plone/volto-slate/utils/selection';
4
+ import { splitEditorInTwoFragments } from '@plone/volto-slate/utils/ops';
5
+ import { setEditorContent } from '@plone/volto-slate/utils/editor';
6
+ import { createAndSelectNewBlockAfter } from '@plone/volto-slate/utils/volto-blocks';
7
+ import { getCurrentListItem } from '@plone/volto-slate/utils/lists';
8
+ import { createEmptyParagraph } from '@plone/volto-slate/utils/blocks';
11
9
 
12
10
  /**
13
11
  * Handles `Enter` key on empty and non-empty list items.
@@ -1,13 +1,10 @@
1
1
  import ReactDOM from 'react-dom';
2
2
  import { Editor } from 'slate';
3
3
  // import { ReactEditor } from 'slate-react';
4
- import {
5
- splitEditorInTwoFragments,
6
- setEditorContent,
7
- createAndSelectNewBlockAfter,
8
- rangeIsInSplittableNode,
9
- // deconstructToVoltoBlocks,
10
- } from '@plone/volto-slate/utils';
4
+ import { splitEditorInTwoFragments } from '@plone/volto-slate/utils/ops';
5
+ import { setEditorContent } from '@plone/volto-slate/utils/editor';
6
+ import { createAndSelectNewBlockAfter } from '@plone/volto-slate/utils/volto-blocks';
7
+ import { rangeIsInSplittableNode } from '@plone/volto-slate/utils/internals';
11
8
 
12
9
  /**
13
10
  * @param {Editor} editor The Slate editor object to extend.
@@ -1,7 +1,8 @@
1
1
  import isUrl from 'is-url';
2
2
  import imageExtensions from 'image-extensions';
3
3
  import { blockTagDeserializer } from '@plone/volto-slate/editor/deserialize';
4
- import { getBaseUrl, validateFileUploadSize } from '@plone/volto/helpers';
4
+ import { getBaseUrl } from '@plone/volto/helpers/Url/Url';
5
+ import { validateFileUploadSize } from '@plone/volto/helpers/FormValidation/FormValidation';
5
6
  import { v4 as uuid } from 'uuid';
6
7
  import { Transforms } from 'slate';
7
8
 
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import TextBlockView from './TextBlockView';
3
3
  import TextBlockEdit from './TextBlockEdit';
4
4
  import TextBlockSchema from './TextBlockSchema';
5
- import { cloneDeep } from 'lodash';
5
+ import cloneDeep from 'lodash/cloneDeep';
6
6
 
7
7
  import {
8
8
  goDown,
@@ -3,8 +3,8 @@ import config from '@plone/volto/registry';
3
3
  import {
4
4
  isCursorInList,
5
5
  isCursorAtListBlockStart,
6
- deconstructToVoltoBlocks,
7
- } from '@plone/volto-slate/utils';
6
+ } from '@plone/volto-slate/utils/lists';
7
+ import { deconstructToVoltoBlocks } from '@plone/volto-slate/utils/volto-blocks';
8
8
 
9
9
  /**
10
10
  * Handle the new Volto blocks created by `deconstructToVoltoBlocks`.
@@ -1,11 +1,11 @@
1
1
  import { Editor, Path, Transforms } from 'slate';
2
2
  import {
3
3
  isCursorInList,
4
- deconstructToVoltoBlocks,
5
4
  getCurrentListItem,
6
5
  mergeWithNextList,
7
6
  mergeWithPreviousList,
8
- } from '@plone/volto-slate/utils';
7
+ } from '@plone/volto-slate/utils/lists';
8
+ import { deconstructToVoltoBlocks } from '@plone/volto-slate/utils/volto-blocks';
9
9
  import config from '@plone/volto/registry';
10
10
 
11
11
  /**
@@ -1,22 +1,24 @@
1
1
  import ReactDOM from 'react-dom';
2
- import { cloneDeep } from 'lodash';
2
+ import cloneDeep from 'lodash/cloneDeep';
3
3
  import { serializeNodesToText } from '@plone/volto-slate/editor/render';
4
4
  import { Editor } from 'slate';
5
5
  import {
6
6
  getPreviousVoltoBlock,
7
7
  getNextVoltoBlock,
8
- isCursorAtBlockStart,
9
- isCursorAtBlockEnd,
10
8
  mergeSlateWithBlockBackward,
11
9
  mergeSlateWithBlockForward,
12
- makeEditor,
13
- } from '@plone/volto-slate/utils';
10
+ } from '@plone/volto-slate/utils/volto-blocks';
11
+ import {
12
+ isCursorAtBlockStart,
13
+ isCursorAtBlockEnd,
14
+ } from '@plone/volto-slate/utils/selection';
15
+ import { makeEditor } from '@plone/volto-slate/utils/editor';
14
16
  import {
15
17
  changeBlock,
16
18
  deleteBlock,
17
19
  getBlocksFieldname,
18
20
  getBlocksLayoutFieldname,
19
- } from '@plone/volto/helpers';
21
+ } from '@plone/volto/helpers/Blocks/Blocks';
20
22
  /**
21
23
  * Joins the current block (which has an active Slate Editor)
22
24
  * with the previous block, to make a single block.
@@ -1,5 +1,8 @@
1
1
  import { Editor, Path, Transforms, Node } from 'slate';
2
- import { isCursorInList, getCurrentListItem } from '@plone/volto-slate/utils';
2
+ import {
3
+ isCursorInList,
4
+ getCurrentListItem,
5
+ } from '@plone/volto-slate/utils/lists';
3
6
  import config from '@plone/volto/registry';
4
7
 
5
8
  /**
@@ -2,10 +2,12 @@ import { Node } from 'slate';
2
2
  import {
3
3
  isCursorAtBlockStart,
4
4
  isCursorAtBlockEnd,
5
+ } from '@plone/volto-slate/utils/selection';
6
+ import {
5
7
  getNextVoltoBlock,
6
8
  getPreviousVoltoBlock,
7
- createDefaultBlock,
8
- } from '@plone/volto-slate/utils';
9
+ } from '@plone/volto-slate/utils/volto-blocks';
10
+ import { createDefaultBlock } from '@plone/volto-slate/utils/blocks';
9
11
 
10
12
  /**
11
13
  * goUp.
@@ -1,6 +1,6 @@
1
1
  import ReactDOM from 'react-dom';
2
2
  import cx from 'classnames';
3
- import { isEqual } from 'lodash';
3
+ import isEqual from 'lodash/isEqual';
4
4
  import { Transforms, Editor } from 'slate'; // , Transforms
5
5
  import { Slate, Editable, ReactEditor } from 'slate-react';
6
6
  import React, { Component } from 'react'; // , useState
@@ -11,12 +11,10 @@ import config from '@plone/volto/registry';
11
11
  import { Element, Leaf } from './render';
12
12
 
13
13
  import withTestingFeatures from './extensions/withTestingFeatures';
14
- import {
15
- makeEditor,
16
- toggleInlineFormat,
17
- toggleMark,
18
- parseDefaultSelection,
19
- } from '@plone/volto-slate/utils';
14
+ import { makeEditor } from '@plone/volto-slate/utils/editor';
15
+ import { toggleInlineFormat } from '@plone/volto-slate/utils/blocks';
16
+ import { toggleMark } from '@plone/volto-slate/utils/marks';
17
+ import { parseDefaultSelection } from '@plone/volto-slate/utils/selection';
20
18
  import { InlineToolbar } from './ui';
21
19
  import EditorContext from './EditorContext';
22
20
 
@@ -15,7 +15,7 @@ import strikethroughIcon from '@plone/volto/icons/strikethrough.svg';
15
15
  import subindexIcon from '@plone/volto/icons/subindex.svg';
16
16
  import superindexIcon from '@plone/volto/icons/superindex.svg';
17
17
 
18
- import { createEmptyParagraph } from '@plone/volto-slate/utils';
18
+ import { createEmptyParagraph } from '@plone/volto-slate/utils/blocks';
19
19
 
20
20
  import {
21
21
  MarkElementButton,
@@ -3,9 +3,9 @@ import { deserialize } from '@plone/volto-slate/editor/deserialize';
3
3
  import {
4
4
  createBlock,
5
5
  createDefaultBlock,
6
- MIMETypeName,
7
6
  normalizeExternalData,
8
- } from '@plone/volto-slate/utils';
7
+ } from '@plone/volto-slate/utils/blocks';
8
+ import { MIMETypeName } from '@plone/volto-slate/utils/mime-types';
9
9
  import { isBlockActive } from '../../utils/blocks';
10
10
 
11
11
  export const insertData = (editor) => {
@@ -1,4 +1,4 @@
1
- import { normalizeExternalData as normalize } from '@plone/volto-slate/utils';
1
+ import { normalizeExternalData as normalize } from '@plone/volto-slate/utils/blocks';
2
2
 
3
3
  export function normalizeExternalData(editor) {
4
4
  editor.normalizeExternalData = (fragment) => {
@@ -1,6 +1,6 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import { ReactEditor } from 'slate-react';
3
- import { omit } from 'lodash';
3
+ import omit from 'lodash/omit';
4
4
 
5
5
  const withTestingFeatures = (WrappedComponent) => {
6
6
  return (props) => {
@@ -1,7 +1,7 @@
1
1
  import { jsx } from 'slate-hyperscript';
2
2
  import { LINK } from '@plone/volto-slate/constants';
3
3
  import { deserialize } from '@plone/volto-slate/editor/deserialize';
4
- import { isEmpty } from 'lodash';
4
+ import isEmpty from 'lodash/isEmpty';
5
5
  // import { Editor } from 'slate';
6
6
 
7
7
  /**
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { UniversalLink } from '@plone/volto/components';
2
+ import UniversalLink from '@plone/volto/components/manage/UniversalLink/UniversalLink';
3
3
  import './styles.less';
4
4
 
5
5
  export const LinkElement = ({ attributes, children, element, mode }) => {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { BlockButton } from '@plone/volto-slate/editor/ui';
2
+ import BlockButton from '@plone/volto-slate/editor/ui/BlockButton';
3
3
  import quoteIcon from '@plone/volto/icons/quote.svg';
4
4
 
5
5
  // TODO: this needs to use constants for el type
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { BlockButton } from '@plone/volto-slate/editor/ui';
2
+ import BlockButton from '@plone/volto-slate/editor/ui/BlockButton';
3
3
  import calloutSVG from '@plone/volto/icons/megaphone.svg';
4
4
 
5
5
  // TODO: this needs to use constants for el type
@@ -12,12 +12,10 @@ import {
12
12
  import { SIMPLELINK, LINK } from '@plone/volto-slate/constants';
13
13
  import { LinkElement } from './render';
14
14
  import { simpleLinkDeserializer, withSimpleLink } from './extensions';
15
- import { setPluginOptions } from '@plone/volto-slate/actions';
16
- import {
17
- ToolbarButton as UIToolbarButton,
18
- PositionedToolbar,
19
- } from '@plone/volto-slate/editor/ui';
20
- import { useSelectionPosition } from '@plone/volto-slate/hooks';
15
+ import { setPluginOptions } from '@plone/volto-slate/actions/plugins';
16
+ import UIToolbarButton from '@plone/volto-slate/editor/ui/ToolbarButton';
17
+ import PositionedToolbar from '@plone/volto-slate/editor/ui/PositionedToolbar';
18
+ import { useSelectionPosition } from '@plone/volto-slate/hooks/useSelectionPosition';
21
19
 
22
20
  import linkSVG from '@plone/volto/icons/link.svg';
23
21
  import unlinkSVG from '@plone/volto/icons/unlink.svg';
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import cx from 'classnames';
3
- import { UniversalLink } from '@plone/volto/components';
3
+ import UniversalLink from '@plone/volto/components/manage/UniversalLink/UniversalLink';
4
4
  import config from '@plone/volto/registry';
5
- import { isInternalURL, flattenToAppURL } from '@plone/volto/helpers';
5
+ import { isInternalURL, flattenToAppURL } from '@plone/volto/helpers/Url/Url';
6
6
 
7
7
  const ViewLink = ({ url, target, download, children }) => {
8
8
  const { openExternalLinkInNewTab } = config.settings;
@@ -1,5 +1,5 @@
1
1
  import { toggleList } from './utils';
2
- import { isBlockActive } from '@plone/volto-slate/utils';
2
+ import { isBlockActive } from '@plone/volto-slate/utils/blocks';
3
3
  import { UL, OL, LI, H2, H3, BLOCKQUOTE } from '@plone/volto-slate/constants';
4
4
 
5
5
  /**
@@ -1,4 +1,5 @@
1
- import { castArray, map } from 'lodash';
1
+ import castArray from 'lodash/castArray';
2
+ import map from 'lodash/map';
2
3
  import { Editor, Path, Point, Range, Transforms } from 'slate';
3
4
 
4
5
  /**
@@ -3,7 +3,7 @@ import {
3
3
  getMaxRange,
4
4
  selectAll,
5
5
  getSelectionNodesArrayByType,
6
- } from '@plone/volto-slate/utils';
6
+ } from '@plone/volto-slate/utils/selection';
7
7
  import { P, LI, UL, OL } from '@plone/volto-slate/constants';
8
8
 
9
9
  export function unwrapNodesByType(editor, types, options = {}) {
@@ -3,10 +3,10 @@ import { useSlate } from 'slate-react';
3
3
  import { Dropdown } from 'semantic-ui-react';
4
4
  import { useIntl, defineMessages } from 'react-intl';
5
5
  import cx from 'classnames';
6
- import { omit } from 'lodash';
6
+ import omit from 'lodash/omit';
7
7
  import { isBlockStyleActive, isInlineStyleActive, toggleStyle } from './utils';
8
8
  import config from '@plone/volto/registry';
9
- import { ToolbarButton } from '@plone/volto-slate/editor/ui';
9
+ import ToolbarButton from '@plone/volto-slate/editor/ui/ToolbarButton';
10
10
  import paintSVG from '@plone/volto/icons/paint.svg';
11
11
 
12
12
  const messages = defineMessages({
@@ -1,6 +1,6 @@
1
1
  /* eslint no-console: ["error", { allow: ["warn", "error"] }] */
2
2
  import { Editor, Transforms } from 'slate';
3
- import { isBlockActive } from '@plone/volto-slate/utils';
3
+ import { isBlockActive } from '@plone/volto-slate/utils/blocks';
4
4
  import config from '@plone/volto/registry';
5
5
 
6
6
  /**
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { useSlate } from 'slate-react';
3
3
  import { Dropdown } from 'semantic-ui-react';
4
- import { ToolbarButton } from '@plone/volto-slate/editor/ui';
4
+ import ToolbarButton from '@plone/volto-slate/editor/ui/ToolbarButton';
5
5
 
6
6
  import tableSVG from '@plone/volto/icons/table.svg';
7
7
  import TableContainer from './TableContainer';
@@ -12,7 +12,7 @@ import colAfterSVG from '@plone/volto/icons/column-after.svg';
12
12
  import rowDeleteSVG from '@plone/volto/icons/row-delete.svg';
13
13
  import colDeleteSVG from '@plone/volto/icons/column-delete.svg';
14
14
 
15
- import { ToolbarButton } from '@plone/volto-slate/editor/ui';
15
+ import ToolbarButton from '@plone/volto-slate/editor/ui/ToolbarButton';
16
16
  import { Range, Transforms, Editor, Path } from 'slate';
17
17
  import { defineMessages, useIntl } from 'react-intl';
18
18
  import { TABLE, TR, P, TD, TH } from '@plone/volto-slate/constants';
@@ -6,9 +6,12 @@ import { useIntl } from 'react-intl';
6
6
  import { useSelector } from 'react-redux';
7
7
  import { Node, Text } from 'slate';
8
8
  import cx from 'classnames';
9
- import { isEmpty, omit } from 'lodash';
10
- import { UniversalLink, Toast } from '@plone/volto/components';
11
- import { messages, addAppURL } from '@plone/volto/helpers';
9
+ import isEmpty from 'lodash/isEmpty';
10
+ import omit from 'lodash/omit';
11
+ import UniversalLink from '@plone/volto/components/manage/UniversalLink/UniversalLink';
12
+ import Toast from '@plone/volto/components/manage/Toast/Toast';
13
+ import { messages } from '@plone/volto/helpers/MessageLabels/MessageLabels';
14
+ import { addAppURL } from '@plone/volto/helpers/Url/Url';
12
15
  import useClipboard from '@plone/volto/hooks/clipboard/useClipboard';
13
16
  import config from '@plone/volto/registry';
14
17
  import linkSVG from '@plone/volto/icons/link.svg';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { useSlate } from 'slate-react';
3
- import { isBlockActive, toggleBlock } from '@plone/volto-slate/utils';
3
+ import { isBlockActive, toggleBlock } from '@plone/volto-slate/utils/blocks';
4
4
 
5
5
  import ToolbarButton from './ToolbarButton';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { useSlate } from 'slate-react';
3
- import { clearFormatting } from '@plone/volto-slate/utils';
3
+ import { clearFormatting } from '@plone/volto-slate/utils/blocks';
4
4
 
5
5
  import ToolbarButton from './ToolbarButton';
6
6
 
@@ -2,7 +2,7 @@ import React from 'react'; // , useState
2
2
  import SlateToolbar from './SlateToolbar';
3
3
  import SlateContextToolbar from './SlateContextToolbar';
4
4
  import config from '@plone/volto/registry';
5
- import { hasRangeSelection } from '@plone/volto-slate/utils';
5
+ import { hasRangeSelection } from '@plone/volto-slate/utils/selection';
6
6
  import { ReactEditor } from 'slate-react';
7
7
  import cx from 'classnames';
8
8
 
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { useSlate } from 'slate-react';
3
3
 
4
- import { isMarkActive, toggleMark } from '@plone/volto-slate/utils';
4
+ import { isMarkActive, toggleMark } from '@plone/volto-slate/utils/marks';
5
5
  import ToolbarButton from './ToolbarButton';
6
6
 
7
7
  const MarkButton = ({ format, icon, ...props }) => {
@@ -1,6 +1,9 @@
1
1
  import React from 'react';
2
2
  import { useSlate } from 'slate-react';
3
- import { isBlockActive, toggleInlineFormat } from '@plone/volto-slate/utils';
3
+ import {
4
+ isBlockActive,
5
+ toggleInlineFormat,
6
+ } from '@plone/volto-slate/utils/blocks';
4
7
 
5
8
  import ToolbarButton from './ToolbarButton';
6
9
 
@@ -1,6 +1,6 @@
1
1
  import cx from 'classnames';
2
2
  import React from 'react';
3
- import { Icon } from '@plone/volto/components';
3
+ import Icon from '@plone/volto/components/theme/Icon/Icon';
4
4
  import { Button } from 'semantic-ui-react';
5
5
  import { useIntl } from 'react-intl';
6
6
 
@@ -4,8 +4,8 @@ import { useIntl } from 'react-intl'; // , defineMessages
4
4
 
5
5
  import clearSVG from '@plone/volto/icons/delete.svg';
6
6
 
7
- import { ToolbarButton } from '@plone/volto-slate/editor/ui';
8
- import { setPluginOptions } from '@plone/volto-slate/actions';
7
+ import ToolbarButton from '@plone/volto-slate/editor/ui/ToolbarButton';
8
+ import { setPluginOptions } from '@plone/volto-slate/actions/plugins';
9
9
 
10
10
  /*
11
11
  * Note: this is a weirder component, it should be called as a native function
@@ -1,11 +1,11 @@
1
1
  /* eslint no-console: ["error", { allow: ["error"] }] */
2
- import { isEqual } from 'lodash';
2
+ import isEqual from 'lodash/isEqual';
3
3
  import React from 'react';
4
4
  import { useDispatch } from 'react-redux';
5
5
  import { ReactEditor } from 'slate-react';
6
- import { Icon as VoltoIcon } from '@plone/volto/components';
6
+ import VoltoIcon from '@plone/volto/components/theme/Icon/Icon';
7
7
  import { BlockDataForm } from '@plone/volto/components/manage/Form';
8
- import { setPluginOptions } from '@plone/volto-slate/actions';
8
+ import { setPluginOptions } from '@plone/volto-slate/actions/plugins';
9
9
  import BaseSchemaProvider from './SchemaProvider';
10
10
 
11
11
  import briefcaseSVG from '@plone/volto/icons/briefcase.svg';
@@ -5,8 +5,8 @@
5
5
  */
6
6
  import React from 'react';
7
7
  import { useSelector, useDispatch } from 'react-redux';
8
- import { SidebarPopup } from '@plone/volto/components';
9
- import { setPluginOptions } from '@plone/volto-slate/actions';
8
+ import SidebarPopup from '@plone/volto/components/manage/Sidebar/SidebarPopup';
9
+ import { setPluginOptions } from '@plone/volto-slate/actions/plugins';
10
10
 
11
11
  const SidebarEditor = (props) => {
12
12
  const { editor, pluginId, getActiveElement, pluginEditor } = props;
@@ -4,11 +4,11 @@
4
4
  import React from 'react';
5
5
  import { useSlate } from 'slate-react';
6
6
  import { useDispatch } from 'react-redux';
7
- import { omit } from 'lodash';
7
+ import omit from 'lodash/omit';
8
8
 
9
- import { ToolbarButton } from '@plone/volto-slate/editor/ui';
10
- import { hasRangeSelection } from '@plone/volto-slate/utils';
11
- import { setPluginOptions } from '@plone/volto-slate/actions';
9
+ import ToolbarButton from '@plone/volto-slate/editor/ui/ToolbarButton';
10
+ import { hasRangeSelection } from '@plone/volto-slate/utils/selection';
11
+ import { setPluginOptions } from '@plone/volto-slate/actions/plugins';
12
12
 
13
13
  const ElementToolbarButton = (props) => {
14
14
  const { isActiveElement, insertElement, pluginId, toolbarButtonIcon } = props;
@@ -11,7 +11,7 @@ import {
11
11
  import messages from './messages';
12
12
  import ToolbarButton from './ToolbarButton';
13
13
  import SchemaProvider from './SchemaProvider';
14
- import { omit } from 'lodash';
14
+ import omit from 'lodash/omit';
15
15
 
16
16
  import tagSVG from '@plone/volto/icons/tag.svg';
17
17
 
@@ -4,8 +4,11 @@ import config from '@plone/volto/registry';
4
4
  import {
5
5
  getBlocksFieldname,
6
6
  getBlocksLayoutFieldname,
7
- } from '@plone/volto/helpers';
8
- import _ from 'lodash';
7
+ } from '@plone/volto/helpers/Blocks/Blocks';
8
+ import find from 'lodash/find';
9
+ import includes from 'lodash/includes';
10
+ import some from 'lodash/some';
11
+ import first from 'lodash/first';
9
12
  import { makeEditor } from './editor';
10
13
 
11
14
  // case sensitive; first in an inner array is the default and preffered format
@@ -145,10 +148,10 @@ export const isSingleBlockTypeActive = (editor, format) => {
145
148
  };
146
149
 
147
150
  export const isBlockActive = (editor, format) => {
148
- const aliasList = _.find(formatAliases, (x) => _.includes(x, format));
151
+ const aliasList = find(formatAliases, (x) => includes(x, format));
149
152
 
150
153
  if (aliasList) {
151
- const aliasFound = _.some(aliasList, (y) => {
154
+ const aliasFound = some(aliasList, (y) => {
152
155
  return isSingleBlockTypeActive(editor, y);
153
156
  });
154
157
 
@@ -163,17 +166,17 @@ export const isBlockActive = (editor, format) => {
163
166
  export const getBlockTypeContextData = (editor, format) => {
164
167
  let isActive, defaultFormat, matcher;
165
168
 
166
- const aliasList = _.find(formatAliases, (x) => _.includes(x, format));
169
+ const aliasList = find(formatAliases, (x) => includes(x, format));
167
170
 
168
171
  if (aliasList) {
169
- const aliasFound = _.some(aliasList, (y) => {
172
+ const aliasFound = some(aliasList, (y) => {
170
173
  return isSingleBlockTypeActive(editor, y);
171
174
  });
172
175
 
173
176
  if (aliasFound) {
174
177
  isActive = true;
175
- defaultFormat = _.first(aliasList);
176
- matcher = (n) => _.includes(aliasList, n.type);
178
+ defaultFormat = first(aliasList);
179
+ matcher = (n) => includes(aliasList, n.type);
177
180
 
178
181
  return { isActive, defaultFormat, matcher };
179
182
  }
@@ -1,7 +1,9 @@
1
- import { castArray, cloneDeep } from 'lodash';
1
+ import castArray from 'lodash/castArray';
2
+ import cloneDeep from 'lodash/cloneDeep';
2
3
  import { Editor, Transforms, Range, Node } from 'slate';
3
4
  import { ReactEditor } from 'slate-react';
4
- import { isCursorInList, makeEditor } from '@plone/volto-slate/utils';
5
+ import { isCursorInList } from '@plone/volto-slate/utils/lists';
6
+ import { makeEditor } from '@plone/volto-slate/utils/editor';
5
7
  import { LI } from '@plone/volto-slate/constants';
6
8
  import config from '@plone/volto/registry';
7
9
 
@@ -7,10 +7,10 @@ import {
7
7
  blockHasValue,
8
8
  getBlocksFieldname,
9
9
  getBlocksLayoutFieldname,
10
- } from '@plone/volto/helpers';
10
+ } from '@plone/volto/helpers/Blocks/Blocks';
11
11
  import { Transforms, Editor, Node, Text, Path } from 'slate';
12
12
  import { serializeNodesToText } from '@plone/volto-slate/editor/render';
13
- import { omit } from 'lodash';
13
+ import omit from 'lodash/omit';
14
14
  import config from '@plone/volto/registry';
15
15
 
16
16
  function fromEntries(pairs) {
@@ -12,7 +12,7 @@ import { defineMessages, injectIntl } from 'react-intl';
12
12
  import { FormFieldWrapper } from '@plone/volto/components/manage/Widgets';
13
13
  import SlateEditor from '@plone/volto-slate/editor/SlateEditor';
14
14
  import { serializeNodes } from '@plone/volto-slate/editor/render';
15
- import { makeEditor } from '@plone/volto-slate/utils';
15
+ import { makeEditor } from '@plone/volto-slate/utils/editor';
16
16
  import deserialize from '@plone/volto-slate/editor/deserialize';
17
17
 
18
18
  import {
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Menu, Tab } from 'semantic-ui-react';
3
- import { Icon } from '@plone/volto/components';
3
+ import Icon from '@plone/volto/components/theme/Icon/Icon';
4
4
  import { ObjectWidget } from '@plone/volto/components/manage/Widgets';
5
5
 
6
6
  export const ObjectByTypeWidget = (props) => {