@contentful/field-editor-rich-text 4.20.14 → 5.0.0

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 (75) hide show
  1. package/dist/cjs/CharConstraints.js +4 -4
  2. package/dist/cjs/RichTextEditor.js +3 -3
  3. package/dist/cjs/RichTextEditor.styles.js +8 -8
  4. package/dist/cjs/Toolbar/components/StickyToolbarWrapper.js +2 -2
  5. package/dist/cjs/Toolbar/index.js +6 -6
  6. package/dist/cjs/dialogs/HypelinkDialog/HyperlinkDialog.js +3 -3
  7. package/dist/cjs/plugins/CommandPalette/components/CommandList.js +4 -6
  8. package/dist/cjs/plugins/CommandPalette/components/CommandList.styles.js +12 -12
  9. package/dist/cjs/plugins/CommandPalette/components/CommandPrompt.js +2 -2
  10. package/dist/cjs/plugins/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.js +2 -2
  11. package/dist/cjs/plugins/Heading/components/Heading.js +17 -17
  12. package/dist/cjs/plugins/Heading/components/ToolbarHeadingButton.js +11 -11
  13. package/dist/cjs/plugins/Hr/index.js +5 -5
  14. package/dist/cjs/plugins/Hyperlink/HyperlinkModal.js +2 -2
  15. package/dist/cjs/plugins/Hyperlink/components/styles.js +6 -6
  16. package/dist/cjs/plugins/List/components/List.js +5 -5
  17. package/dist/cjs/plugins/List/components/ListItem.js +2 -2
  18. package/dist/cjs/plugins/Marks/Bold.js +2 -2
  19. package/dist/cjs/plugins/Marks/Code.js +2 -2
  20. package/dist/cjs/plugins/Marks/Italic.js +2 -2
  21. package/dist/cjs/plugins/Marks/Strikethrough.js +2 -2
  22. package/dist/cjs/plugins/Marks/Subscript.js +5 -3
  23. package/dist/cjs/plugins/Marks/Superscript.js +2 -2
  24. package/dist/cjs/plugins/Marks/components/MarkToolbarButton.js +3 -3
  25. package/dist/cjs/plugins/Paragraph/Paragraph.js +2 -2
  26. package/dist/cjs/plugins/Quote/components/Quote.js +2 -2
  27. package/dist/cjs/plugins/Table/components/Cell.js +2 -2
  28. package/dist/cjs/plugins/Table/components/HeaderCell.js +2 -2
  29. package/dist/cjs/plugins/Table/components/Row.js +2 -2
  30. package/dist/cjs/plugins/Table/components/Table.js +2 -2
  31. package/dist/cjs/plugins/Table/components/TableActions.js +2 -2
  32. package/dist/cjs/plugins/shared/EmbeddedBlockToolbarIcon.js +2 -2
  33. package/dist/cjs/plugins/shared/EmbeddedInlineToolbarIcon.js +3 -3
  34. package/dist/cjs/plugins/shared/LinkedBlockWrapper.js +3 -3
  35. package/dist/cjs/plugins/shared/LinkedInlineWrapper.js +3 -3
  36. package/dist/cjs/plugins/shared/ToolbarButton.js +37 -17
  37. package/dist/esm/CharConstraints.js +1 -1
  38. package/dist/esm/RichTextEditor.js +1 -1
  39. package/dist/esm/RichTextEditor.styles.js +1 -1
  40. package/dist/esm/Toolbar/components/StickyToolbarWrapper.js +1 -1
  41. package/dist/esm/Toolbar/index.js +1 -1
  42. package/dist/esm/dialogs/HypelinkDialog/HyperlinkDialog.js +1 -1
  43. package/dist/esm/plugins/CommandPalette/components/CommandList.js +1 -3
  44. package/dist/esm/plugins/CommandPalette/components/CommandList.styles.js +1 -1
  45. package/dist/esm/plugins/CommandPalette/components/CommandPrompt.js +1 -1
  46. package/dist/esm/plugins/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.js +1 -1
  47. package/dist/esm/plugins/Heading/components/Heading.js +1 -1
  48. package/dist/esm/plugins/Heading/components/ToolbarHeadingButton.js +1 -1
  49. package/dist/esm/plugins/Hr/index.js +1 -1
  50. package/dist/esm/plugins/Hyperlink/HyperlinkModal.js +1 -1
  51. package/dist/esm/plugins/Hyperlink/components/styles.js +1 -1
  52. package/dist/esm/plugins/List/components/List.js +1 -1
  53. package/dist/esm/plugins/List/components/ListItem.js +1 -1
  54. package/dist/esm/plugins/Marks/Bold.js +1 -1
  55. package/dist/esm/plugins/Marks/Code.js +1 -1
  56. package/dist/esm/plugins/Marks/Italic.js +1 -1
  57. package/dist/esm/plugins/Marks/Strikethrough.js +1 -1
  58. package/dist/esm/plugins/Marks/Subscript.js +4 -2
  59. package/dist/esm/plugins/Marks/Superscript.js +1 -1
  60. package/dist/esm/plugins/Marks/components/MarkToolbarButton.js +1 -1
  61. package/dist/esm/plugins/Paragraph/Paragraph.js +1 -1
  62. package/dist/esm/plugins/Quote/components/Quote.js +1 -1
  63. package/dist/esm/plugins/Table/components/Cell.js +1 -1
  64. package/dist/esm/plugins/Table/components/HeaderCell.js +1 -1
  65. package/dist/esm/plugins/Table/components/Row.js +1 -1
  66. package/dist/esm/plugins/Table/components/Table.js +1 -1
  67. package/dist/esm/plugins/Table/components/TableActions.js +1 -1
  68. package/dist/esm/plugins/shared/EmbeddedBlockToolbarIcon.js +1 -1
  69. package/dist/esm/plugins/shared/EmbeddedInlineToolbarIcon.js +1 -1
  70. package/dist/esm/plugins/shared/LinkedBlockWrapper.js +1 -1
  71. package/dist/esm/plugins/shared/LinkedInlineWrapper.js +1 -1
  72. package/dist/esm/plugins/shared/ToolbarButton.js +35 -15
  73. package/dist/types/plugins/Hyperlink/components/LinkPopover.d.ts +1 -1
  74. package/dist/types/plugins/shared/ToolbarButton.d.ts +1 -1
  75. package/package.json +12 -10
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import tokens from '@contentful/f36-tokens';
3
3
  import { BLOCKS } from '@contentful/rich-text-types';
4
- import { css, cx } from 'emotion';
4
+ import { css, cx } from '@emotion/css';
5
5
  const baseStyle = css`
6
6
  padding: 0;
7
7
  margin: 0 0 1.25rem 1.25rem;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import tokens from '@contentful/f36-tokens';
3
- import { css } from 'emotion';
3
+ import { css } from '@emotion/css';
4
4
  const style = css`
5
5
  margin: 0;
6
6
  list-style: inherit;
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { TextBIcon } from '@contentful/f36-icons';
3
3
  import { MARKS } from '@contentful/rich-text-types';
4
+ import { css } from '@emotion/css';
4
5
  import { createBoldPlugin as createDefaultBoldPlugin } from '@udecode/plate-basic-marks';
5
- import { css } from 'emotion';
6
6
  import { someHtmlElement } from '../../internal/queries';
7
7
  import { createMarkToolbarButton } from './components/MarkToolbarButton';
8
8
  import { buildMarkEventHandler } from './helpers';
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { CodeSimpleIcon } from '@contentful/f36-icons';
3
3
  import { MARKS } from '@contentful/rich-text-types';
4
+ import { css } from '@emotion/css';
4
5
  import { createCodePlugin as createDefaultCodePlugin } from '@udecode/plate-basic-marks';
5
- import { css } from 'emotion';
6
6
  import { createMarkToolbarButton } from './components/MarkToolbarButton';
7
7
  import { buildMarkEventHandler } from './helpers';
8
8
  export const ToolbarCodeButton = createMarkToolbarButton({
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { TextItalicIcon } from '@contentful/f36-icons';
3
3
  import { MARKS } from '@contentful/rich-text-types';
4
+ import { css } from '@emotion/css';
4
5
  import { createItalicPlugin as createDefaultItalicPlugin } from '@udecode/plate-basic-marks';
5
- import { css } from 'emotion';
6
6
  import { someHtmlElement } from '../../internal/queries';
7
7
  import { createMarkToolbarButton } from './components/MarkToolbarButton';
8
8
  import { buildMarkEventHandler } from './helpers';
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { TextStrikethroughIcon } from '@contentful/f36-icons';
3
3
  import { MARKS } from '@contentful/rich-text-types';
4
+ import { css } from '@emotion/css';
4
5
  import { createStrikethroughPlugin as createDefaultStrikethroughPlugin } from '@udecode/plate-basic-marks';
5
- import { css } from 'emotion';
6
6
  import { createMarkToolbarButton } from './components/MarkToolbarButton';
7
7
  import { buildMarkEventHandler } from './helpers';
8
8
  const styles = {
@@ -1,8 +1,9 @@
1
1
  import * as React from 'react';
2
+ import { Icon } from '@contentful/f36-icon';
2
3
  import { TextSubscriptIcon } from '@contentful/f36-icons';
3
4
  import { MARKS } from '@contentful/rich-text-types';
5
+ import { css } from '@emotion/css';
4
6
  import { createSubscriptPlugin as createDefaultSubscriptPlugin } from '@udecode/plate-basic-marks';
5
- import { css } from 'emotion';
6
7
  import { createMarkToolbarButton } from './components/MarkToolbarButton';
7
8
  import { buildMarkEventHandler } from './helpers';
8
9
  const styles = {
@@ -14,7 +15,8 @@ const styles = {
14
15
  export const ToolbarSubscriptButton = createMarkToolbarButton({
15
16
  title: 'Subscript',
16
17
  mark: MARKS.SUBSCRIPT,
17
- icon: /*#__PURE__*/ React.createElement(TextSubscriptIcon, {
18
+ icon: /*#__PURE__*/ React.createElement(Icon, {
19
+ as: TextSubscriptIcon,
18
20
  viewBox: "0 0 23 18"
19
21
  })
20
22
  });
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { TextSuperscriptIcon } from '@contentful/f36-icons';
3
3
  import { MARKS } from '@contentful/rich-text-types';
4
+ import { css } from '@emotion/css';
4
5
  import { createSuperscriptPlugin as createDefaultSuperscriptPlugin } from '@udecode/plate-basic-marks';
5
- import { css } from 'emotion';
6
6
  import { createMarkToolbarButton } from './components/MarkToolbarButton';
7
7
  import { buildMarkEventHandler } from './helpers';
8
8
  const styles = {
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { Menu } from '@contentful/f36-components';
3
3
  import tokens from '@contentful/f36-tokens';
4
- import { css, cx } from 'emotion';
4
+ import { css, cx } from '@emotion/css';
5
5
  import { useContentfulEditor } from '../../../ContentfulEditorProvider';
6
6
  import { focus } from '../../../helpers/editor';
7
7
  import { isMarkActive } from '../../../internal/queries';
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import tokens from '@contentful/f36-tokens';
3
3
  import { BLOCKS } from '@contentful/rich-text-types';
4
- import { css } from 'emotion';
4
+ import { css } from '@emotion/css';
5
5
  const styles = {
6
6
  [BLOCKS.PARAGRAPH]: css`
7
7
  line-height: ${tokens.lineHeightDefault};
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import tokens from '@contentful/f36-tokens';
3
- import { css } from 'emotion';
3
+ import { css } from '@emotion/css';
4
4
  const style = css({
5
5
  margin: '0 0 1.3125rem',
6
6
  borderLeft: `6px solid ${tokens.gray200}`,
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import tokens from '@contentful/f36-tokens';
3
- import { css } from 'emotion';
3
+ import { css } from '@emotion/css';
4
4
  import { useSelected } from 'slate-react';
5
5
  import { TableActions } from './TableActions';
6
6
  const style = css`
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import tokens from '@contentful/f36-tokens';
3
- import { css } from 'emotion';
3
+ import { css } from '@emotion/css';
4
4
  import { useSelected } from 'slate-react';
5
5
  import { TableActions } from './TableActions';
6
6
  const style = css`
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import tokens from '@contentful/f36-tokens';
3
- import { css } from 'emotion';
3
+ import { css } from '@emotion/css';
4
4
  const style = css`
5
5
  border: 1px solid ${tokens.gray400};
6
6
  border-collapse: collapse;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import tokens from '@contentful/f36-tokens';
3
3
  import { BLOCKS } from '@contentful/rich-text-types';
4
- import { css } from 'emotion';
4
+ import { css } from '@emotion/css';
5
5
  const style = css`
6
6
  margin-bottom: 1.5em;
7
7
  border-collapse: collapse;
@@ -2,8 +2,8 @@ import * as React from 'react';
2
2
  import { IconButton, Menu } from '@contentful/f36-components';
3
3
  import { CaretDownIcon } from '@contentful/f36-icons';
4
4
  import { BLOCKS } from '@contentful/rich-text-types';
5
+ import { css } from '@emotion/css';
5
6
  import { deleteColumn, deleteRow, deleteTable } from '@udecode/plate-table';
6
- import { css } from 'emotion';
7
7
  import { useContentfulEditor } from '../../../ContentfulEditorProvider';
8
8
  import { getNodeEntryFromSelection, getTableSize } from '../../../helpers/editor';
9
9
  import { withoutNormalizing } from '../../../internal';
@@ -4,7 +4,7 @@ import { Icon } from '@contentful/f36-components';
4
4
  import { ImageSquareIcon, EmbeddedBlockIcon } from '@contentful/f36-icons';
5
5
  import tokens from '@contentful/f36-tokens';
6
6
  import { BLOCKS } from '@contentful/rich-text-types';
7
- import { css } from 'emotion';
7
+ import { css } from '@emotion/css';
8
8
  import { useContentfulEditor } from '../../ContentfulEditorProvider';
9
9
  import { useSdkContext } from '../../SdkProvider';
10
10
  import { selectEntityAndInsert, selectResourceEntityAndInsert } from '../shared/EmbeddedBlockUtil';
@@ -3,7 +3,7 @@ import { Menu, Flex } from '@contentful/f36-components';
3
3
  import { EmbeddedLineIcon } from '@contentful/f36-icons';
4
4
  import tokens from '@contentful/f36-tokens';
5
5
  import { INLINES } from '@contentful/rich-text-types';
6
- import { css } from 'emotion';
6
+ import { css } from '@emotion/css';
7
7
  import { useContentfulEditor } from '../../ContentfulEditorProvider';
8
8
  import { moveToTheNextChar } from '../../helpers/editor';
9
9
  import { useSdkContext } from '../../SdkProvider';
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { css } from 'emotion';
2
+ import { css } from '@emotion/css';
3
3
  import { IS_CHROME } from '../../helpers/environment';
4
4
  import { getLinkEntityId } from './utils';
5
5
  const styles = {
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import tokens from '@contentful/f36-tokens';
3
- import { css } from 'emotion';
3
+ import { css } from '@emotion/css';
4
4
  import { IS_CHROME } from '../../helpers/environment';
5
5
  import { getLinkEntityId } from './utils';
6
6
  const styles = {
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
- import { Button, Tooltip } from '@contentful/f36-components';
2
+ import { IconButton } from '@contentful/f36-components';
3
3
  import tokens from '@contentful/f36-tokens';
4
- import { css, cx } from 'emotion';
4
+ import { css, cx } from '@emotion/css';
5
5
  const styles = {
6
6
  button: css({
7
7
  height: '30px',
@@ -10,30 +10,50 @@ const styles = {
10
10
  marginRight: tokens.spacing2Xs
11
11
  }),
12
12
  tooltip: css({
13
- zIndex: Number(tokens.zIndexTooltip)
13
+ zIndex: Number(tokens.zIndexTooltip),
14
+ pointerEvents: 'none'
14
15
  })
15
16
  };
16
17
  export function ToolbarButton(props) {
17
18
  const { title, testId, isActive, children, className, isDisabled = false } = props;
18
- const handleClick = (event)=>{
19
+ const pointerTriggeredRef = React.useRef(false);
20
+ const handlePointerDown = React.useCallback((event)=>{
21
+ if (isDisabled || event.button !== 0) {
22
+ return;
23
+ }
19
24
  event.preventDefault();
25
+ pointerTriggeredRef.current = true;
20
26
  props.onClick();
21
- };
22
- const button = /*#__PURE__*/ React.createElement(Button, {
27
+ }, [
28
+ isDisabled,
29
+ props
30
+ ]);
31
+ const handleClick = React.useCallback((event)=>{
32
+ if (pointerTriggeredRef.current) {
33
+ pointerTriggeredRef.current = false;
34
+ return;
35
+ }
36
+ event.preventDefault();
37
+ props.onClick();
38
+ }, [
39
+ props
40
+ ]);
41
+ return /*#__PURE__*/ React.createElement(IconButton, {
23
42
  className: cx(styles.button, className),
24
43
  isDisabled: isDisabled,
25
- startIcon: children,
44
+ onMouseDown: handlePointerDown,
26
45
  onClick: handleClick,
27
46
  testId: testId,
28
47
  variant: isActive ? 'secondary' : 'transparent',
29
- size: "small"
30
- });
31
- if (title) {
32
- return /*#__PURE__*/ React.createElement(Tooltip, {
48
+ size: "small",
49
+ icon: children,
50
+ "aria-label": title,
51
+ withTooltip: !!title,
52
+ tooltipProps: {
33
53
  className: styles.tooltip,
34
- placement: "bottom",
54
+ usePortal: true,
55
+ placement: 'bottom',
35
56
  content: title
36
- }, button);
37
- }
38
- return button;
57
+ }
58
+ });
39
59
  }
@@ -4,7 +4,7 @@ type LinkPopoverProps = {
4
4
  popoverText: React.ReactNode | ((closePopover: () => void) => React.ReactNode);
5
5
  handleEditLink: () => void;
6
6
  handleRemoveLink: () => void;
7
- children: React.ReactNode;
7
+ children: React.ReactElement;
8
8
  handleCopyLink?: () => void;
9
9
  isEditorFocused: boolean;
10
10
  };
@@ -3,7 +3,7 @@ interface ToolbarButtonProps {
3
3
  onClick: () => void;
4
4
  isActive?: boolean;
5
5
  isDisabled?: boolean;
6
- children: any;
6
+ children: React.ReactElement;
7
7
  title: string;
8
8
  className?: string;
9
9
  testId?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-rich-text",
3
- "version": "4.20.14",
3
+ "version": "5.0.0",
4
4
  "source": "./src/index.tsx",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -40,14 +40,16 @@
40
40
  "dependencies": {
41
41
  "@contentful/app-sdk": "^4.42.0",
42
42
  "@contentful/contentful-slatejs-adapter": "^16.1.6",
43
- "@contentful/f36-components": "^5.4.1",
44
- "@contentful/f36-icons": "^5.4.1",
45
- "@contentful/f36-tokens": "^5.1.0",
46
- "@contentful/f36-utils": "^5.1.0",
47
- "@contentful/field-editor-reference": "^7.0.1",
48
- "@contentful/field-editor-shared": "^3.0.1",
43
+ "@contentful/f36-components": "^6.7.1",
44
+ "@contentful/f36-icon": "^6.7.1",
45
+ "@contentful/f36-icons": "^6.7.1",
46
+ "@contentful/f36-tokens": "^6.1.2",
47
+ "@contentful/f36-utils": "^6.1.0",
48
+ "@contentful/field-editor-reference": "^7.0.0",
49
+ "@contentful/field-editor-shared": "^3.0.0",
49
50
  "@contentful/rich-text-plain-text-renderer": "^17.0.0",
50
51
  "@contentful/rich-text-types": "^17.2.5",
52
+ "@emotion/css": "^11.13.5",
51
53
  "@popperjs/core": "^2.11.5",
52
54
  "@udecode/plate-basic-marks": "36.0.0",
53
55
  "@udecode/plate-break": "36.0.0",
@@ -77,8 +79,8 @@
77
79
  "peerDependencies": {
78
80
  "@lingui/core": "^5.3.0",
79
81
  "@tanstack/react-query": "^4.3.9",
80
- "react": ">=16.14.0",
81
- "react-dom": ">=16.14.0"
82
+ "react": ">=18.3.1",
83
+ "react-dom": ">=18.3.1"
82
84
  },
83
85
  "devDependencies": {
84
86
  "@contentful/field-editor-test-utils": "^2.0.0",
@@ -92,5 +94,5 @@
92
94
  "publishConfig": {
93
95
  "registry": "https://npm.pkg.github.com/"
94
96
  },
95
- "gitHead": "79ea20201fece746a4835e16854024616b81e184"
97
+ "gitHead": "4e13dec4455366c7012c2b1c88f47a269a20b5b4"
96
98
  }