@contentful/field-editor-rich-text 4.16.1 → 4.16.2
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 +0 -27
- package/dist/cjs/RichTextEditor.js +2 -2
- package/dist/esm/RichTextEditor.js +1 -1
- package/dist/types/internal/types/editor.d.ts +1 -1
- package/package.json +5 -5
- package/dist/cjs/editor-overrides/index.js +0 -18
- package/dist/cjs/editor-overrides/scroll-selection-into-view.js +0 -36
- package/dist/esm/editor-overrides/index.js +0 -1
- package/dist/esm/editor-overrides/scroll-selection-into-view.js +0 -21
- package/dist/types/editor-overrides/index.d.ts +0 -1
- package/dist/types/editor-overrides/scroll-selection-into-view.d.ts +0 -2
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:
|
|
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.
|
|
3
|
+
"version": "4.16.2",
|
|
4
4
|
"source": "./src/index.tsx",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -68,11 +68,11 @@
|
|
|
68
68
|
"moment": "^2.20.0",
|
|
69
69
|
"p-debounce": "^2.1.0",
|
|
70
70
|
"react-popper": "^2.3.0",
|
|
71
|
-
"
|
|
72
|
-
"slate": "0.
|
|
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.
|
|
75
|
+
"slate-react": "0.118.2"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"@lingui/core": "^5.3.0",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"publishConfig": {
|
|
92
92
|
"registry": "https://npm.pkg.github.com/"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "4f962a8f4e7f93dbfeb560062223fd4aedcae112"
|
|
95
95
|
}
|
|
@@ -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';
|