@contentful/field-editor-rich-text 6.4.5-canary.4 → 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.
- package/dist/cjs/plugins/index.js +0 -2
- package/dist/esm/plugins/index.js +0 -2
- package/dist/types/plugins/Hyperlink/components/LinkPopover.d.ts +1 -1
- package/package.json +13 -6
- package/dist/cjs/plugins/createSelectionSyncPlugin.js +0 -52
- package/dist/esm/plugins/createSelectionSyncPlugin.js +0 -42
- package/dist/types/plugins/createSelectionSyncPlugin.d.ts +0 -2
|
@@ -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
|
|
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.
|
|
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
|
|
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.
|
|
49
|
-
"@contentful/field-editor-shared": "^4.
|
|
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.
|
|
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
|
-
"
|
|
98
|
+
"lint-staged": {
|
|
99
|
+
"*.{js,jsx,ts,tsx}": [
|
|
100
|
+
"eslint --fix --prune-suppressions",
|
|
101
|
+
"prettier --write"
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
"gitHead": "a7a2e12bb51918f63bb2ee43a7039c6a26983308"
|
|
98
105
|
}
|
|
@@ -1,52 +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
|
-
const range = (0, _platecommon.toSlateRange)(editor, selection, {
|
|
18
|
-
exactMatch: false,
|
|
19
|
-
suppressThrow: true
|
|
20
|
-
});
|
|
21
|
-
if (range && !(0, _platecommon.getVoidNode)(editor, {
|
|
22
|
-
at: range.anchor
|
|
23
|
-
}) && !(0, _platecommon.getVoidNode)(editor, {
|
|
24
|
-
at: range.focus
|
|
25
|
-
})) (0, _platecommon.select)(editor, range);
|
|
26
|
-
};
|
|
27
|
-
const createSelectionSyncPlugin = ()=>({
|
|
28
|
-
key: 'selectionSync',
|
|
29
|
-
handlers: {
|
|
30
|
-
onMouseUp: (editor)=>()=>{
|
|
31
|
-
if (!(0, _platecommon.isComposing)(editor)) syncSelection(editor);
|
|
32
|
-
},
|
|
33
|
-
onKeyDown: (editor)=>(event)=>{
|
|
34
|
-
if ([
|
|
35
|
-
'ArrowLeft',
|
|
36
|
-
'ArrowRight',
|
|
37
|
-
'Backspace',
|
|
38
|
-
'Delete'
|
|
39
|
-
].includes(event.key) && !(!(0, _platecommon.isEditorFocused)(editor) && editor.selection && (0, _platecommon.getVoidNode)(editor, {
|
|
40
|
-
at: editor.selection.focus
|
|
41
|
-
})) && !event.nativeEvent.isComposing && !(0, _platecommon.isComposing)(editor)) syncSelection(editor);
|
|
42
|
-
},
|
|
43
|
-
onCompositionStart: (editor)=>()=>{
|
|
44
|
-
if (!(0, _platecommon.isComposing)(editor)) syncSelection(editor);
|
|
45
|
-
},
|
|
46
|
-
onDOMBeforeInput: (editor)=>(event)=>{
|
|
47
|
-
const input = 'nativeEvent' in event ? event.nativeEvent : event;
|
|
48
|
-
if (input.inputType !== 'insertText' && !input.inputType.startsWith('delete') || input.isComposing || (0, _platecommon.isComposing)(editor)) return;
|
|
49
|
-
syncSelection(editor);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { getEditorWindow, getVoidNode, hasEditorTarget, isComposing, isEditorFocused, select, 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
|
-
const range = toSlateRange(editor, selection, {
|
|
8
|
-
exactMatch: false,
|
|
9
|
-
suppressThrow: true
|
|
10
|
-
});
|
|
11
|
-
if (range && !getVoidNode(editor, {
|
|
12
|
-
at: range.anchor
|
|
13
|
-
}) && !getVoidNode(editor, {
|
|
14
|
-
at: range.focus
|
|
15
|
-
})) select(editor, range);
|
|
16
|
-
};
|
|
17
|
-
export const createSelectionSyncPlugin = ()=>({
|
|
18
|
-
key: 'selectionSync',
|
|
19
|
-
handlers: {
|
|
20
|
-
onMouseUp: (editor)=>()=>{
|
|
21
|
-
if (!isComposing(editor)) syncSelection(editor);
|
|
22
|
-
},
|
|
23
|
-
onKeyDown: (editor)=>(event)=>{
|
|
24
|
-
if ([
|
|
25
|
-
'ArrowLeft',
|
|
26
|
-
'ArrowRight',
|
|
27
|
-
'Backspace',
|
|
28
|
-
'Delete'
|
|
29
|
-
].includes(event.key) && !(!isEditorFocused(editor) && editor.selection && getVoidNode(editor, {
|
|
30
|
-
at: editor.selection.focus
|
|
31
|
-
})) && !event.nativeEvent.isComposing && !isComposing(editor)) syncSelection(editor);
|
|
32
|
-
},
|
|
33
|
-
onCompositionStart: (editor)=>()=>{
|
|
34
|
-
if (!isComposing(editor)) syncSelection(editor);
|
|
35
|
-
},
|
|
36
|
-
onDOMBeforeInput: (editor)=>(event)=>{
|
|
37
|
-
const input = 'nativeEvent' in event ? event.nativeEvent : event;
|
|
38
|
-
if (input.inputType !== 'insertText' && !input.inputType.startsWith('delete') || input.isComposing || isComposing(editor)) return;
|
|
39
|
-
syncSelection(editor);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
});
|