@contentful/field-editor-rich-text 4.17.7 → 4.17.8

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,6 +11,33 @@ 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
+
14
41
  ## Migrating to v2
15
42
 
16
43
  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");
28
27
  const _CharConstraints = require("./CharConstraints");
29
28
  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");
@@ -131,7 +131,7 @@ const ConnectedRichTextEditor = (props)=>{
131
131
  id: id,
132
132
  className: classNames,
133
133
  readOnly: props.isDisabled,
134
- scrollSelectionIntoView: _slatereact.defaultScrollSelectionIntoView
134
+ scrollSelectionIntoView: _editoroverrides.defaultScrollSelectionIntoView
135
135
  }), props.withCharValidation && /*#__PURE__*/ _react.createElement(_CharConstraints.CharConstraints, null))))));
136
136
  };
137
137
  const RichTextEditor = (props)=>{
@@ -0,0 +1,18 @@
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
+ }
@@ -0,0 +1,36 @@
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
+ };
@@ -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';
10
9
  import { CharConstraints } from './CharConstraints';
11
10
  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';
@@ -0,0 +1 @@
1
+ export * from './scroll-selection-into-view';
@@ -0,0 +1,21 @@
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
+ };
@@ -0,0 +1 @@
1
+ export * from './scroll-selection-into-view';
@@ -0,0 +1,2 @@
1
+ import { DOMRange, ReactEditor } from '../internal';
2
+ export declare const defaultScrollSelectionIntoView: (editor: ReactEditor, domRange: DOMRange) => void;
@@ -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';
8
7
  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.17.7",
3
+ "version": "4.17.8",
4
4
  "source": "./src/index.tsx",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -68,11 +68,10 @@
68
68
  "moment": "^2.20.0",
69
69
  "p-debounce": "^2.1.0",
70
70
  "react-popper": "^2.3.0",
71
- "slate": "0.118.1",
72
- "slate-dom": "0.118.1",
71
+ "slate": "0.94.1",
73
72
  "slate-history": "0.100.0",
74
73
  "slate-hyperscript": "0.77.0",
75
- "slate-react": "0.118.2"
74
+ "slate-react": "0.102.0"
76
75
  },
77
76
  "peerDependencies": {
78
77
  "@lingui/core": "^5.3.0",
@@ -91,5 +90,5 @@
91
90
  "publishConfig": {
92
91
  "registry": "https://npm.pkg.github.com/"
93
92
  },
94
- "gitHead": "b25d0af70c82c9e29505335ce636f2e32e6cb927"
93
+ "gitHead": "07cc76255a57cad096e068688aee7fe6cf154501"
95
94
  }