@contentful/field-editor-rich-text 3.26.0 → 3.26.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.
@@ -12,6 +12,7 @@ const _richtexttypes = require("@contentful/rich-text-types");
12
12
  const _editor = require("../../helpers/editor");
13
13
  const _transformers = require("../../helpers/transformers");
14
14
  const _queries = require("../../internal/queries");
15
+ const _transforms = require("../../internal/transforms");
15
16
  const isInline = (node)=>_editor.INLINE_TYPES.includes(node.type);
16
17
  const isTextContainer = (node)=>_richtexttypes.TEXT_CONTAINERS.includes(node.type);
17
18
  const baseRules = [
@@ -34,5 +35,14 @@ const baseRules = [
34
35
  return !!parent && isTextContainer(parent);
35
36
  },
36
37
  transform: (0, _transformers.transformWrapIn)(_richtexttypes.BLOCKS.PARAGRAPH)
38
+ },
39
+ {
40
+ match: _queries.isText,
41
+ validNode: (_editor, [node])=>typeof node.text === 'string' && !node.text.includes('\r'),
42
+ transform: (editor, [node, path])=>{
43
+ return (0, _transforms.insertText)(editor, node.text.replace(/\r/g, ''), {
44
+ at: path
45
+ });
46
+ }
37
47
  }
38
48
  ];
@@ -2,6 +2,7 @@ import { BLOCKS, TEXT_CONTAINERS } from '@contentful/rich-text-types';
2
2
  import { INLINE_TYPES } from '../../helpers/editor';
3
3
  import { transformWrapIn } from '../../helpers/transformers';
4
4
  import { getParentNode, isText } from '../../internal/queries';
5
+ import { insertText } from '../../internal/transforms';
5
6
  const isInline = (node)=>INLINE_TYPES.includes(node.type);
6
7
  const isTextContainer = (node)=>TEXT_CONTAINERS.includes(node.type);
7
8
  export const baseRules = [
@@ -24,5 +25,14 @@ export const baseRules = [
24
25
  return !!parent && isTextContainer(parent);
25
26
  },
26
27
  transform: transformWrapIn(BLOCKS.PARAGRAPH)
28
+ },
29
+ {
30
+ match: isText,
31
+ validNode: (_editor, [node])=>typeof node.text === 'string' && !node.text.includes('\r'),
32
+ transform: (editor, [node, path])=>{
33
+ return insertText(editor, node.text.replace(/\r/g, ''), {
34
+ at: path
35
+ });
36
+ }
27
37
  }
28
38
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-rich-text",
3
- "version": "3.26.0",
3
+ "version": "3.26.2",
4
4
  "source": "./src/index.tsx",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -44,7 +44,7 @@
44
44
  "@contentful/f36-icons": "^4.28.2",
45
45
  "@contentful/f36-tokens": "^4.0.5",
46
46
  "@contentful/f36-utils": "^4.24.3",
47
- "@contentful/field-editor-reference": "^5.30.2",
47
+ "@contentful/field-editor-reference": "^5.30.3",
48
48
  "@contentful/field-editor-shared": "^1.6.0",
49
49
  "@contentful/rich-text-plain-text-renderer": "^16.0.4",
50
50
  "@contentful/rich-text-types": "16.7.0",
@@ -86,5 +86,5 @@
86
86
  "publishConfig": {
87
87
  "registry": "https://npm.pkg.github.com/"
88
88
  },
89
- "gitHead": "1e60c3ab6e5fdbe7b3694fcf55854fe209837751"
89
+ "gitHead": "759fde7b73a0ae4380021335304b3f387ceedce5"
90
90
  }