@contentful/field-editor-rich-text 4.16.1 → 4.17.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.
package/README.md CHANGED
@@ -11,33 +11,6 @@ import 'codemirror/lib/codemirror.css';
11
11
  import { RichTextEditor } from '@contentful/field-editor-rich-text';
12
12
  ```
13
13
 
14
- ## ⚠️ Important: Package Configuration
15
-
16
- Due to peer dependency resolution in npm, you must add the following to your `package.json` to ensure compatible versions are installed:
17
- This is a temporary workaround until we have upgraded the underlying rich text packages.
18
-
19
- **For npm:**
20
-
21
- ```json
22
- {
23
- "overrides": {
24
- "slate": "0.94.1",
25
- "slate-react": "0.102.0"
26
- }
27
- }
28
- ```
29
-
30
- **For yarn:**
31
-
32
- ```json
33
- {
34
- "resolutions": {
35
- "slate": "0.94.1",
36
- "slate-react": "0.102.0"
37
- }
38
- }
39
- ```
40
-
41
14
  ## Migrating to v2
42
15
 
43
16
  To bring support for Rich Text Tables we rewrote most of the internals of this package to adapt the latest version of [Slate][slate]. We are releasing this change as v2.0.0.
@@ -24,9 +24,9 @@ const _platecommon = require("@udecode/plate-common");
24
24
  const _emotion = require("emotion");
25
25
  const _fastdeepequal = /*#__PURE__*/ _interop_require_default(require("fast-deep-equal"));
26
26
  const _noop = /*#__PURE__*/ _interop_require_default(require("lodash/noop"));
27
+ const _slatereact = require("slate-react");
27
28
  const _CharConstraints = require("./CharConstraints");
28
29
  const _ContentfulEditorProvider = require("./ContentfulEditorProvider");
29
- const _editoroverrides = require("./editor-overrides");
30
30
  const _toSlateValue = require("./helpers/toSlateValue");
31
31
  const _misc = require("./internal/misc");
32
32
  const _plugins = require("./plugins");
@@ -130,7 +130,7 @@ const ConnectedRichTextEditor = (props)=>{
130
130
  id: id,
131
131
  className: classNames,
132
132
  readOnly: props.isDisabled,
133
- scrollSelectionIntoView: _editoroverrides.defaultScrollSelectionIntoView
133
+ scrollSelectionIntoView: _slatereact.defaultScrollSelectionIntoView
134
134
  }), props.withCharValidation && /*#__PURE__*/ _react.createElement(_CharConstraints.CharConstraints, null))))));
135
135
  };
136
136
  const RichTextEditor = (props)=>{
@@ -6,9 +6,9 @@ import { PlateContent, Plate } from '@udecode/plate-common';
6
6
  import { css, cx } from 'emotion';
7
7
  import deepEquals from 'fast-deep-equal';
8
8
  import noop from 'lodash/noop';
9
+ import { defaultScrollSelectionIntoView } from 'slate-react';
9
10
  import { CharConstraints } from './CharConstraints';
10
11
  import { ContentfulEditorIdProvider, getContentfulEditorId } from './ContentfulEditorProvider';
11
- import { defaultScrollSelectionIntoView } from './editor-overrides';
12
12
  import { toSlateValue } from './helpers/toSlateValue';
13
13
  import { normalizeInitialValue } from './internal/misc';
14
14
  import { getPlugins, disableCorePlugins } from './plugins';
@@ -4,8 +4,8 @@
4
4
  import { MARKS } from '@contentful/rich-text-types';
5
5
  import * as p from '@udecode/plate-common';
6
6
  import * as s from 'slate';
7
+ import { DOMRange as SlateReactDomRange } from 'slate-dom';
7
8
  import * as sr from 'slate-react';
8
- import { DOMRange as SlateReactDomRange } from 'slate-react/dist/utils/dom';
9
9
  import type { SelectionMoveOptions as SlateSelectionMoveOptions, SelectionCollapseOptions as SlateSelectionCollapseOptions } from 'slate/dist/interfaces/transforms/selection';
10
10
  import type { TextInsertTextOptions as SlateTextInsertTextOptions } from 'slate/dist/interfaces/transforms/text';
11
11
  import { TrackingPluginActions } from '../../plugins/Tracking';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-rich-text",
3
- "version": "4.16.1",
3
+ "version": "4.17.0",
4
4
  "source": "./src/index.tsx",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -68,16 +68,19 @@
68
68
  "moment": "^2.20.0",
69
69
  "p-debounce": "^2.1.0",
70
70
  "react-popper": "^2.3.0",
71
- "scroll-into-view-if-needed": "^3.1.0",
72
- "slate": "0.94.1",
71
+ "slate": "0.118.1",
72
+ "slate-dom": "0.118.1",
73
73
  "slate-history": "0.100.0",
74
74
  "slate-hyperscript": "0.77.0",
75
- "slate-react": "0.102.0"
75
+ "slate-react": "0.118.2"
76
76
  },
77
77
  "peerDependencies": {
78
78
  "@lingui/core": "^5.3.0",
79
79
  "react": ">=16.14.0",
80
- "react-dom": ">=16.14.0"
80
+ "react-dom": ">=16.14.0",
81
+ "slate": "0.118.1",
82
+ "slate-dom": "0.118.1",
83
+ "slate-react": "0.118.2"
81
84
  },
82
85
  "devDependencies": {
83
86
  "@contentful/field-editor-test-utils": "^1.7.0",
@@ -91,5 +94,5 @@
91
94
  "publishConfig": {
92
95
  "registry": "https://npm.pkg.github.com/"
93
96
  },
94
- "gitHead": "c29a501efe92281b4a990adc129b78270ce1acff"
97
+ "gitHead": "164532011d1a69f0d3e2078f8c22db34577050f0"
95
98
  }
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- _export_star(require("./scroll-selection-into-view"), exports);
6
- function _export_star(from, to) {
7
- Object.keys(from).forEach(function(k) {
8
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
9
- Object.defineProperty(to, k, {
10
- enumerable: true,
11
- get: function() {
12
- return from[k];
13
- }
14
- });
15
- }
16
- });
17
- return from;
18
- }
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "defaultScrollSelectionIntoView", {
6
- enumerable: true,
7
- get: function() {
8
- return defaultScrollSelectionIntoView;
9
- }
10
- });
11
- const _scrollintoviewifneeded = /*#__PURE__*/ _interop_require_default(require("scroll-into-view-if-needed"));
12
- const _internal = require("../internal");
13
- function _interop_require_default(obj) {
14
- return obj && obj.__esModule ? obj : {
15
- default: obj
16
- };
17
- }
18
- const defaultScrollSelectionIntoView = (editor, domRange)=>{
19
- if (domRange.getBoundingClientRect && (!editor.selection || editor.selection && _internal.Range.isCollapsed(editor.selection))) {
20
- const leafEl = domRange.startContainer.parentElement;
21
- const domRect = domRange.getBoundingClientRect();
22
- const isZeroDimensionRect = domRect.width === 0 && domRect.height === 0 && domRect.x === 0 && domRect.y === 0;
23
- if (isZeroDimensionRect) {
24
- const leafRect = leafEl.getBoundingClientRect();
25
- const leafHasDimensions = leafRect.width > 0 || leafRect.height > 0;
26
- if (leafHasDimensions) {
27
- return;
28
- }
29
- }
30
- leafEl.getBoundingClientRect = domRange.getBoundingClientRect.bind(domRange);
31
- (0, _scrollintoviewifneeded.default)(leafEl, {
32
- scrollMode: 'if-needed'
33
- });
34
- delete leafEl.getBoundingClientRect;
35
- }
36
- };
@@ -1 +0,0 @@
1
- export * from './scroll-selection-into-view';
@@ -1,21 +0,0 @@
1
- import scrollIntoView from 'scroll-into-view-if-needed';
2
- import { Range } from '../internal';
3
- export const defaultScrollSelectionIntoView = (editor, domRange)=>{
4
- if (domRange.getBoundingClientRect && (!editor.selection || editor.selection && Range.isCollapsed(editor.selection))) {
5
- const leafEl = domRange.startContainer.parentElement;
6
- const domRect = domRange.getBoundingClientRect();
7
- const isZeroDimensionRect = domRect.width === 0 && domRect.height === 0 && domRect.x === 0 && domRect.y === 0;
8
- if (isZeroDimensionRect) {
9
- const leafRect = leafEl.getBoundingClientRect();
10
- const leafHasDimensions = leafRect.width > 0 || leafRect.height > 0;
11
- if (leafHasDimensions) {
12
- return;
13
- }
14
- }
15
- leafEl.getBoundingClientRect = domRange.getBoundingClientRect.bind(domRange);
16
- scrollIntoView(leafEl, {
17
- scrollMode: 'if-needed'
18
- });
19
- delete leafEl.getBoundingClientRect;
20
- }
21
- };
@@ -1 +0,0 @@
1
- export * from './scroll-selection-into-view';
@@ -1,2 +0,0 @@
1
- import { DOMRange, ReactEditor } from '../internal';
2
- export declare const defaultScrollSelectionIntoView: (editor: ReactEditor, domRange: DOMRange) => void;