@contentful/field-editor-rich-text 6.4.5-canary.5 → 6.5.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.
@@ -20,7 +20,6 @@ const _Break = require("./Break");
20
20
  const _CharCounter = require("./CharCounter");
21
21
  const _CommandPalette = require("./CommandPalette");
22
22
  const _useCommands = require("./CommandPalette/useCommands");
23
- const _createSelectionSyncPlugin = require("./createSelectionSyncPlugin");
24
23
  const _DeserializeDocx = require("./DeserializeDocx");
25
24
  const _DragAndDrop = require("./DragAndDrop");
26
25
  const _EmbeddedEntityBlock = require("./EmbeddedEntityBlock");
@@ -45,7 +44,6 @@ const _Voids = require("./Voids");
45
44
  const getPlugins = (sdk, onAction, restrictedMarks, withCharValidation)=>[
46
45
  (0, _DeserializeDocx.createDeserializeDocxPlugin)(),
47
46
  (0, _Tracking.createTrackingPlugin)(onAction),
48
- (0, _createSelectionSyncPlugin.createSelectionSyncPlugin)(),
49
47
  (0, _DragAndDrop.createDragAndDropPlugin)(),
50
48
  ...Object.values((0, _useCommands.isCommandPromptPluginEnabled)(sdk)).some(Boolean) ? [
51
49
  (0, _CommandPalette.createCommandPalettePlugin)()
@@ -2,7 +2,6 @@ import { createSoftBreakPlugin, createExitBreakPlugin, createResetNodePlugin } f
2
2
  import { createCharCounterPlugin } from './CharCounter';
3
3
  import { createCommandPalettePlugin } from './CommandPalette';
4
4
  import { isCommandPromptPluginEnabled } from './CommandPalette/useCommands';
5
- import { createSelectionSyncPlugin } from './createSelectionSyncPlugin';
6
5
  import { createDeserializeDocxPlugin } from './DeserializeDocx';
7
6
  import { createDragAndDropPlugin } from './DragAndDrop';
8
7
  import { createEmbeddedAssetBlockPlugin, createEmbeddedEntryBlockPlugin } from './EmbeddedEntityBlock';
@@ -27,7 +26,6 @@ import { createVoidsPlugin } from './Voids';
27
26
  export const getPlugins = (sdk, onAction, restrictedMarks, withCharValidation)=>[
28
27
  createDeserializeDocxPlugin(),
29
28
  createTrackingPlugin(onAction),
30
- createSelectionSyncPlugin(),
31
29
  createDragAndDropPlugin(),
32
30
  ...Object.values(isCommandPromptPluginEnabled(sdk)).some(Boolean) ? [
33
31
  createCommandPalettePlugin()
@@ -8,5 +8,5 @@ type LinkPopoverProps = {
8
8
  handleCopyLink?: () => void;
9
9
  isEditorFocused: boolean;
10
10
  };
11
- export declare const LinkPopover: ({ isLinkFocused, popoverText, handleEditLink, handleRemoveLink, children, handleCopyLink, isEditorFocused, }: LinkPopoverProps) => React.JSX.Element;
11
+ export declare const LinkPopover: ({ isLinkFocused, popoverText, handleEditLink, handleRemoveLink, children, handleCopyLink, isEditorFocused }: LinkPopoverProps) => React.JSX.Element;
12
12
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-rich-text",
3
- "version": "6.4.5-canary.5+17557610",
3
+ "version": "6.5.0",
4
4
  "source": "./src/index.tsx",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -35,7 +35,8 @@
35
35
  "test": "vitest",
36
36
  "test:ci": "vitest run",
37
37
  "tsc": "tsc -p ./ --noEmit",
38
- "lint": "eslint ./src --ext .js,.jsx,.ts,.tsx"
38
+ "lint": "eslint src",
39
+ "lint-staged": "lint-staged"
39
40
  },
40
41
  "dependencies": {
41
42
  "@contentful/app-sdk": "^4.42.0",
@@ -45,8 +46,8 @@
45
46
  "@contentful/f36-icons": "^6.7.1",
46
47
  "@contentful/f36-tokens": "^6.1.2",
47
48
  "@contentful/f36-utils": "^6.1.0",
48
- "@contentful/field-editor-reference": "^8.4.2",
49
- "@contentful/field-editor-shared": "^4.5.2",
49
+ "@contentful/field-editor-reference": "^8.5.0",
50
+ "@contentful/field-editor-shared": "^4.6.0",
50
51
  "@contentful/rich-text-plain-text-renderer": "^17.0.0",
51
52
  "@contentful/rich-text-types": "^17.2.5",
52
53
  "@emotion/css": "^11.13.5",
@@ -83,7 +84,7 @@
83
84
  "react-dom": ">=18.3.1"
84
85
  },
85
86
  "devDependencies": {
86
- "@contentful/field-editor-test-utils": "^3.1.2",
87
+ "@contentful/field-editor-test-utils": "^3.2.0",
87
88
  "@contentful/rich-text-react-renderer": "^16.0.0",
88
89
  "@lingui/core": "5.3.0",
89
90
  "@types/is-hotkey": "^0.1.6",
@@ -94,5 +95,11 @@
94
95
  "publishConfig": {
95
96
  "registry": "https://npm.pkg.github.com/"
96
97
  },
97
- "gitHead": "17557610f17d9d8aefe463488408e173e71e8352"
98
+ "lint-staged": {
99
+ "*.{js,jsx,ts,tsx}": [
100
+ "eslint --fix --prune-suppressions",
101
+ "prettier --write"
102
+ ]
103
+ },
104
+ "gitHead": "a7a2e12bb51918f63bb2ee43a7039c6a26983308"
98
105
  }
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "createSelectionSyncPlugin", {
6
- enumerable: true,
7
- get: function() {
8
- return createSelectionSyncPlugin;
9
- }
10
- });
11
- const _platecommon = require("@udecode/plate-common");
12
- const syncSelection = (editor)=>{
13
- const selection = (0, _platecommon.getEditorWindow)(editor)?.getSelection();
14
- if (!selection || !(0, _platecommon.hasEditorTarget)(editor, selection.anchorNode) || !(0, _platecommon.hasEditorTarget)(editor, selection.focusNode)) {
15
- return;
16
- }
17
- if (selection.rangeCount === 1 && selection.isCollapsed && editor.selection && (0, _platecommon.isCollapsed)(editor.selection) && selection.anchorNode?.nodeType === Node.TEXT_NODE && selection.anchorNode.parentElement?.hasAttribute('data-slate-string') && selection.anchorOffset === editor.selection.anchor.offset) {
18
- const node = (0, _platecommon.getNode)(editor, editor.selection.anchor.path);
19
- if (node && 'text' in node && node.text === selection.anchorNode.textContent && node === (0, _platecommon.toSlateNode)(editor, selection.anchorNode)) return;
20
- }
21
- const range = (0, _platecommon.toSlateRange)(editor, selection, {
22
- exactMatch: false,
23
- suppressThrow: true
24
- });
25
- if (range && !(0, _platecommon.getVoidNode)(editor, {
26
- at: range.anchor
27
- }) && !(0, _platecommon.getVoidNode)(editor, {
28
- at: range.focus
29
- })) (0, _platecommon.select)(editor, range);
30
- };
31
- const createSelectionSyncPlugin = ()=>({
32
- key: 'selectionSync',
33
- handlers: {
34
- onMouseUp: (editor)=>()=>{
35
- if (!(0, _platecommon.isComposing)(editor)) syncSelection(editor);
36
- },
37
- onKeyDown: (editor)=>(event)=>{
38
- if ([
39
- 'ArrowLeft',
40
- 'ArrowRight',
41
- 'Backspace',
42
- 'Delete',
43
- 'Enter'
44
- ].includes(event.key) && !(!(0, _platecommon.isEditorFocused)(editor) && editor.selection && (0, _platecommon.getVoidNode)(editor, {
45
- at: editor.selection.focus
46
- })) && !event.nativeEvent.isComposing && !(0, _platecommon.isComposing)(editor)) syncSelection(editor);
47
- },
48
- onCompositionStart: (editor)=>()=>{
49
- if (!(0, _platecommon.isComposing)(editor)) syncSelection(editor);
50
- },
51
- onDOMBeforeInput: (editor)=>(event)=>{
52
- const input = 'nativeEvent' in event ? event.nativeEvent : event;
53
- if (![
54
- 'insertText',
55
- 'insertParagraph',
56
- 'insertLineBreak'
57
- ].includes(input.inputType) && !input.inputType.startsWith('delete') || input.isComposing || (0, _platecommon.isComposing)(editor)) return;
58
- syncSelection(editor);
59
- }
60
- }
61
- });
@@ -1,51 +0,0 @@
1
- import { getEditorWindow, getNode, getVoidNode, hasEditorTarget, isCollapsed, isComposing, isEditorFocused, select, toSlateNode, toSlateRange } from '@udecode/plate-common';
2
- const syncSelection = (editor)=>{
3
- const selection = getEditorWindow(editor)?.getSelection();
4
- if (!selection || !hasEditorTarget(editor, selection.anchorNode) || !hasEditorTarget(editor, selection.focusNode)) {
5
- return;
6
- }
7
- if (selection.rangeCount === 1 && selection.isCollapsed && editor.selection && isCollapsed(editor.selection) && selection.anchorNode?.nodeType === Node.TEXT_NODE && selection.anchorNode.parentElement?.hasAttribute('data-slate-string') && selection.anchorOffset === editor.selection.anchor.offset) {
8
- const node = getNode(editor, editor.selection.anchor.path);
9
- if (node && 'text' in node && node.text === selection.anchorNode.textContent && node === toSlateNode(editor, selection.anchorNode)) return;
10
- }
11
- const range = toSlateRange(editor, selection, {
12
- exactMatch: false,
13
- suppressThrow: true
14
- });
15
- if (range && !getVoidNode(editor, {
16
- at: range.anchor
17
- }) && !getVoidNode(editor, {
18
- at: range.focus
19
- })) select(editor, range);
20
- };
21
- export const createSelectionSyncPlugin = ()=>({
22
- key: 'selectionSync',
23
- handlers: {
24
- onMouseUp: (editor)=>()=>{
25
- if (!isComposing(editor)) syncSelection(editor);
26
- },
27
- onKeyDown: (editor)=>(event)=>{
28
- if ([
29
- 'ArrowLeft',
30
- 'ArrowRight',
31
- 'Backspace',
32
- 'Delete',
33
- 'Enter'
34
- ].includes(event.key) && !(!isEditorFocused(editor) && editor.selection && getVoidNode(editor, {
35
- at: editor.selection.focus
36
- })) && !event.nativeEvent.isComposing && !isComposing(editor)) syncSelection(editor);
37
- },
38
- onCompositionStart: (editor)=>()=>{
39
- if (!isComposing(editor)) syncSelection(editor);
40
- },
41
- onDOMBeforeInput: (editor)=>(event)=>{
42
- const input = 'nativeEvent' in event ? event.nativeEvent : event;
43
- if (![
44
- 'insertText',
45
- 'insertParagraph',
46
- 'insertLineBreak'
47
- ].includes(input.inputType) && !input.inputType.startsWith('delete') || input.isComposing || isComposing(editor)) return;
48
- syncSelection(editor);
49
- }
50
- }
51
- });
@@ -1,2 +0,0 @@
1
- import { PlatePlugin } from '../internal/types';
2
- export declare const createSelectionSyncPlugin: () => PlatePlugin;