@contentful/field-editor-rich-text 3.16.15 → 3.17.1
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/RichTextEditor.js +4 -6
- package/dist/cjs/SyncEditorChanges.js +7 -9
- package/dist/cjs/internal/hooks.js +2 -2
- package/dist/cjs/plugins/List/withList.js +1 -1
- package/dist/cjs/plugins/Table/createTablePlugin.js +8 -1
- package/dist/cjs/plugins/Table/withInsertFragmentTableOverride.js +33 -0
- package/dist/esm/RichTextEditor.js +5 -7
- package/dist/esm/SyncEditorChanges.js +7 -9
- package/dist/esm/internal/hooks.js +2 -2
- package/dist/esm/plugins/List/withList.js +1 -1
- package/dist/esm/plugins/Table/createTablePlugin.js +9 -2
- package/dist/esm/plugins/Table/onKeyDownTable.js +1 -1
- package/dist/esm/plugins/Table/withInsertFragmentTableOverride.js +23 -0
- package/dist/types/internal/hooks.d.ts +29 -2
- package/dist/types/internal/misc.d.ts +26 -2
- package/dist/types/internal/queries.d.ts +1 -1
- package/dist/types/internal/transforms.d.ts +1 -1
- package/dist/types/plugins/Table/withInsertFragmentTableOverride.d.ts +5 -0
- package/dist/types/test-utils/createEditor.d.ts +25 -1
- package/package.json +15 -15
|
@@ -108,7 +108,7 @@ const ConnectedRichTextEditor = (props)=>{
|
|
|
108
108
|
}, _react.createElement("div", {
|
|
109
109
|
className: _RichTextEditorstyles.styles.root,
|
|
110
110
|
"data-test-id": "rich-text-editor"
|
|
111
|
-
}, _react.createElement(_platecommon.
|
|
111
|
+
}, _react.createElement(_platecommon.Plate, {
|
|
112
112
|
id: id,
|
|
113
113
|
initialValue: initialValue,
|
|
114
114
|
plugins: plugins,
|
|
@@ -120,12 +120,10 @@ const ConnectedRichTextEditor = (props)=>{
|
|
|
120
120
|
})), _react.createElement(_SyncEditorChanges.SyncEditorChanges, {
|
|
121
121
|
incomingValue: initialValue,
|
|
122
122
|
onChange: props.onChange
|
|
123
|
-
}), _react.createElement(_platecommon.
|
|
123
|
+
}), _react.createElement(_platecommon.PlateContent, {
|
|
124
124
|
id: id,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
readOnly: props.isDisabled
|
|
128
|
-
}
|
|
125
|
+
className: classNames,
|
|
126
|
+
readOnly: props.isDisabled
|
|
129
127
|
})))));
|
|
130
128
|
};
|
|
131
129
|
const RichTextEditor = (props)=>{
|
|
@@ -79,16 +79,14 @@ const useOnValueChanged = (onChange)=>{
|
|
|
79
79
|
const setEditorOnChange = (0, _platecommon.usePlateActions)().onChange();
|
|
80
80
|
_react.useEffect(()=>{
|
|
81
81
|
const cb = (0, _callbacks.createOnChangeCallback)(onChange);
|
|
82
|
-
setEditorOnChange({
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
cb(document);
|
|
82
|
+
setEditorOnChange((document)=>{
|
|
83
|
+
const operations = editor?.operations.filter((op)=>{
|
|
84
|
+
return op.type !== 'set_selection';
|
|
85
|
+
});
|
|
86
|
+
if (operations.length === 0) {
|
|
87
|
+
return;
|
|
91
88
|
}
|
|
89
|
+
cb(document);
|
|
92
90
|
});
|
|
93
91
|
}, [
|
|
94
92
|
editor,
|
|
@@ -70,10 +70,10 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
70
70
|
}
|
|
71
71
|
const useReadOnly = _slatereact.useReadOnly;
|
|
72
72
|
const usePlateEditorRef = (id)=>{
|
|
73
|
-
return _platecommon.
|
|
73
|
+
return _platecommon.useEditorRef(id);
|
|
74
74
|
};
|
|
75
75
|
const usePlateEditorState = (id)=>{
|
|
76
|
-
return _platecommon.
|
|
76
|
+
return _platecommon.useEditorState(id);
|
|
77
77
|
};
|
|
78
78
|
const usePlateSelectors = (id)=>{
|
|
79
79
|
return _platecommon.usePlateSelectors(id);
|
|
@@ -16,7 +16,7 @@ const validLiChildrenTypes = _richtexttypes.LIST_ITEM_BLOCKS;
|
|
|
16
16
|
const withList = (editor)=>{
|
|
17
17
|
const { deleteForward, deleteFragment } = editor;
|
|
18
18
|
editor.deleteForward = (unit)=>{
|
|
19
|
-
if ((0, _platelist.deleteForwardList)(editor)) return;
|
|
19
|
+
if ((0, _platelist.deleteForwardList)(editor, deleteForward, unit)) return;
|
|
20
20
|
deleteForward(unit);
|
|
21
21
|
};
|
|
22
22
|
editor.deleteFragment = ()=>{
|
|
@@ -22,6 +22,7 @@ const _helpers = require("./helpers");
|
|
|
22
22
|
const _insertTableFragment = require("./insertTableFragment");
|
|
23
23
|
const _onKeyDownTable = require("./onKeyDownTable");
|
|
24
24
|
const _tableTracking = require("./tableTracking");
|
|
25
|
+
const _withInsertFragmentTableOverride = require("./withInsertFragmentTableOverride");
|
|
25
26
|
const createTablePlugin = ()=>(0, _platetable.createTablePlugin)({
|
|
26
27
|
type: _richtexttypes.BLOCKS.TABLE,
|
|
27
28
|
handlers: {
|
|
@@ -29,7 +30,13 @@ const createTablePlugin = ()=>(0, _platetable.createTablePlugin)({
|
|
|
29
30
|
},
|
|
30
31
|
withOverrides: (editor, plugin)=>{
|
|
31
32
|
const { normalizeNode } = editor;
|
|
32
|
-
(0, _platetable.
|
|
33
|
+
editor = (0, _platetable.withDeleteTable)(editor);
|
|
34
|
+
editor = (0, _platetable.withGetFragmentTable)(editor);
|
|
35
|
+
editor = (0, _platetable.withInsertFragmentTable)(editor, plugin);
|
|
36
|
+
editor = (0, _withInsertFragmentTableOverride.withInsertFragmentTableOverride)(editor);
|
|
37
|
+
editor = (0, _platetable.withInsertTextTable)(editor, plugin);
|
|
38
|
+
editor = (0, _platetable.withSelectionTable)(editor);
|
|
39
|
+
editor = (0, _platetable.withSetFragmentDataTable)(editor);
|
|
33
40
|
editor.normalizeNode = normalizeNode;
|
|
34
41
|
(0, _tableTracking.addTableTrackingEvents)(editor);
|
|
35
42
|
editor.insertFragment = (0, _insertTableFragment.insertTableFragment)(editor);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "withInsertFragmentTableOverride", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return withInsertFragmentTableOverride;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _platecommon = require("@udecode/plate-common");
|
|
12
|
+
const _platetable = require("@udecode/plate-table");
|
|
13
|
+
const _internal = require("../../internal");
|
|
14
|
+
const withInsertFragmentTableOverride = (editor)=>{
|
|
15
|
+
const myEditor = (0, _platecommon.getTEditor)(editor);
|
|
16
|
+
const upstreamInsertFragment = myEditor.insertFragment;
|
|
17
|
+
myEditor.insertFragment = (fragment)=>{
|
|
18
|
+
const insertedTable = fragment.find((n)=>n.type === (0, _platecommon.getPluginType)(editor, _platetable.ELEMENT_TABLE));
|
|
19
|
+
if (insertedTable && fragment.length === 1 && fragment[0].type === _platetable.ELEMENT_TABLE) {
|
|
20
|
+
(0, _internal.insertNodes)(editor, fragment, {
|
|
21
|
+
removeEmpty: {
|
|
22
|
+
exclude: [
|
|
23
|
+
_platecommon.ELEMENT_DEFAULT
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return;
|
|
28
|
+
} else {
|
|
29
|
+
upstreamInsertFragment(fragment);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return editor;
|
|
33
|
+
};
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { EntityProvider } from '@contentful/field-editor-reference';
|
|
3
3
|
import { FieldConnector } from '@contentful/field-editor-shared';
|
|
4
4
|
import * as Contentful from '@contentful/rich-text-types';
|
|
5
|
-
import {
|
|
5
|
+
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';
|
|
@@ -44,7 +44,7 @@ export const ConnectedRichTextEditor = (props)=>{
|
|
|
44
44
|
}, React.createElement("div", {
|
|
45
45
|
className: styles.root,
|
|
46
46
|
"data-test-id": "rich-text-editor"
|
|
47
|
-
}, React.createElement(
|
|
47
|
+
}, React.createElement(Plate, {
|
|
48
48
|
id: id,
|
|
49
49
|
initialValue: initialValue,
|
|
50
50
|
plugins: plugins,
|
|
@@ -56,12 +56,10 @@ export const ConnectedRichTextEditor = (props)=>{
|
|
|
56
56
|
})), React.createElement(SyncEditorChanges, {
|
|
57
57
|
incomingValue: initialValue,
|
|
58
58
|
onChange: props.onChange
|
|
59
|
-
}), React.createElement(
|
|
59
|
+
}), React.createElement(PlateContent, {
|
|
60
60
|
id: id,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
readOnly: props.isDisabled
|
|
64
|
-
}
|
|
61
|
+
className: classNames,
|
|
62
|
+
readOnly: props.isDisabled
|
|
65
63
|
})))));
|
|
66
64
|
};
|
|
67
65
|
const RichTextEditor = (props)=>{
|
|
@@ -23,16 +23,14 @@ const useOnValueChanged = (onChange)=>{
|
|
|
23
23
|
const setEditorOnChange = usePlateActions().onChange();
|
|
24
24
|
React.useEffect(()=>{
|
|
25
25
|
const cb = createOnChangeCallback(onChange);
|
|
26
|
-
setEditorOnChange({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
cb(document);
|
|
26
|
+
setEditorOnChange((document)=>{
|
|
27
|
+
const operations = editor?.operations.filter((op)=>{
|
|
28
|
+
return op.type !== 'set_selection';
|
|
29
|
+
});
|
|
30
|
+
if (operations.length === 0) {
|
|
31
|
+
return;
|
|
35
32
|
}
|
|
33
|
+
cb(document);
|
|
36
34
|
});
|
|
37
35
|
}, [
|
|
38
36
|
editor,
|
|
@@ -2,10 +2,10 @@ import * as p from '@udecode/plate-common';
|
|
|
2
2
|
import * as sr from 'slate-react';
|
|
3
3
|
export const useReadOnly = sr.useReadOnly;
|
|
4
4
|
export const usePlateEditorRef = (id)=>{
|
|
5
|
-
return p.
|
|
5
|
+
return p.useEditorRef(id);
|
|
6
6
|
};
|
|
7
7
|
export const usePlateEditorState = (id)=>{
|
|
8
|
-
return p.
|
|
8
|
+
return p.useEditorState(id);
|
|
9
9
|
};
|
|
10
10
|
export const usePlateSelectors = (id)=>{
|
|
11
11
|
return p.usePlateSelectors(id);
|
|
@@ -6,7 +6,7 @@ const validLiChildrenTypes = LIST_ITEM_BLOCKS;
|
|
|
6
6
|
export const withList = (editor)=>{
|
|
7
7
|
const { deleteForward, deleteFragment } = editor;
|
|
8
8
|
editor.deleteForward = (unit)=>{
|
|
9
|
-
if (deleteForwardList(editor)) return;
|
|
9
|
+
if (deleteForwardList(editor, deleteForward, unit)) return;
|
|
10
10
|
deleteForward(unit);
|
|
11
11
|
};
|
|
12
12
|
editor.deleteFragment = ()=>{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BLOCKS, CONTAINERS } from '@contentful/rich-text-types';
|
|
2
|
-
import { createTablePlugin as createDefaultTablePlugin, ELEMENT_TABLE, ELEMENT_TD, ELEMENT_TH, ELEMENT_TR,
|
|
2
|
+
import { createTablePlugin as createDefaultTablePlugin, ELEMENT_TABLE, ELEMENT_TD, ELEMENT_TH, ELEMENT_TR, withDeleteTable, withGetFragmentTable, withInsertTextTable, withSelectionTable, withSetFragmentDataTable, withInsertFragmentTable } from '@udecode/plate-table';
|
|
3
3
|
import { isRootLevel } from '../../helpers/editor';
|
|
4
4
|
import { transformLift, transformParagraphs, transformWrapIn } from '../../helpers/transformers';
|
|
5
5
|
import { getParentNode, getBlockAbove, getLastChildPath, getNextPath } from '../../internal/queries';
|
|
@@ -12,6 +12,7 @@ import { createEmptyTableCells, getNoOfMissingTableCellsInRow, isNotEmpty } from
|
|
|
12
12
|
import { insertTableFragment } from './insertTableFragment';
|
|
13
13
|
import { onKeyDownTable } from './onKeyDownTable';
|
|
14
14
|
import { addTableTrackingEvents, withInvalidCellChildrenTracking } from './tableTracking';
|
|
15
|
+
import { withInsertFragmentTableOverride } from './withInsertFragmentTableOverride';
|
|
15
16
|
export const createTablePlugin = ()=>createDefaultTablePlugin({
|
|
16
17
|
type: BLOCKS.TABLE,
|
|
17
18
|
handlers: {
|
|
@@ -19,7 +20,13 @@ export const createTablePlugin = ()=>createDefaultTablePlugin({
|
|
|
19
20
|
},
|
|
20
21
|
withOverrides: (editor, plugin)=>{
|
|
21
22
|
const { normalizeNode } = editor;
|
|
22
|
-
|
|
23
|
+
editor = withDeleteTable(editor);
|
|
24
|
+
editor = withGetFragmentTable(editor);
|
|
25
|
+
editor = withInsertFragmentTable(editor, plugin);
|
|
26
|
+
editor = withInsertFragmentTableOverride(editor);
|
|
27
|
+
editor = withInsertTextTable(editor, plugin);
|
|
28
|
+
editor = withSelectionTable(editor);
|
|
29
|
+
editor = withSetFragmentDataTable(editor);
|
|
23
30
|
editor.normalizeNode = normalizeNode;
|
|
24
31
|
addTableTrackingEvents(editor);
|
|
25
32
|
editor.insertFragment = insertTableFragment(editor);
|
|
@@ -2,7 +2,7 @@ import { BLOCKS } from '@contentful/rich-text-types';
|
|
|
2
2
|
import { getTableEntries, onKeyDownTable as defaultKeyDownTable } from '@udecode/plate-table';
|
|
3
3
|
import { insertEmptyParagraph } from '../../helpers/editor';
|
|
4
4
|
import { blurEditor } from '../../internal/misc';
|
|
5
|
-
import { getAboveNode,
|
|
5
|
+
import { getAboveNode, getText, isFirstChild, isLastChildPath } from '../../internal/queries';
|
|
6
6
|
import { addRowBelow } from './actions';
|
|
7
7
|
export const onKeyDownTable = (editor, plugin)=>{
|
|
8
8
|
const defaultHandler = defaultKeyDownTable(editor, plugin);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ELEMENT_DEFAULT, getPluginType, getTEditor } from '@udecode/plate-common';
|
|
2
|
+
import { ELEMENT_TABLE } from '@udecode/plate-table';
|
|
3
|
+
import { insertNodes } from '../../internal';
|
|
4
|
+
export const withInsertFragmentTableOverride = (editor)=>{
|
|
5
|
+
const myEditor = getTEditor(editor);
|
|
6
|
+
const upstreamInsertFragment = myEditor.insertFragment;
|
|
7
|
+
myEditor.insertFragment = (fragment)=>{
|
|
8
|
+
const insertedTable = fragment.find((n)=>n.type === getPluginType(editor, ELEMENT_TABLE));
|
|
9
|
+
if (insertedTable && fragment.length === 1 && fragment[0].type === ELEMENT_TABLE) {
|
|
10
|
+
insertNodes(editor, fragment, {
|
|
11
|
+
removeEmpty: {
|
|
12
|
+
exclude: [
|
|
13
|
+
ELEMENT_DEFAULT
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return;
|
|
18
|
+
} else {
|
|
19
|
+
upstreamInsertFragment(fragment);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
return editor;
|
|
23
|
+
};
|
|
@@ -1,7 +1,34 @@
|
|
|
1
1
|
import * as p from '@udecode/plate-common';
|
|
2
|
-
import { PlateEditor
|
|
2
|
+
import { PlateEditor } from './types';
|
|
3
3
|
export declare const useReadOnly: () => boolean;
|
|
4
4
|
export declare const usePlateEditorRef: (id?: string) => PlateEditor;
|
|
5
5
|
export declare const usePlateEditorState: (id?: string) => PlateEditor;
|
|
6
|
-
export declare const usePlateSelectors: (id?: string) =>
|
|
6
|
+
export declare const usePlateSelectors: (id?: string) => {
|
|
7
|
+
id: (options?: string | import("jotai-x").UseAtomOptions | undefined) => string;
|
|
8
|
+
editor: (options?: string | import("jotai-x").UseAtomOptions | undefined) => p.PlateEditor<p.Value>;
|
|
9
|
+
rawPlugins: (options?: string | import("jotai-x").UseAtomOptions | undefined) => p.PlatePlugin<p.AnyObject, p.Value, p.PlateEditor<p.Value>>[];
|
|
10
|
+
plugins: (options?: string | import("jotai-x").UseAtomOptions | undefined) => p.WithPlatePlugin<p.AnyObject, p.Value, p.PlateEditor<p.Value>>[];
|
|
11
|
+
value: (options?: string | import("jotai-x").UseAtomOptions | undefined) => p.Value;
|
|
12
|
+
isMounted: (options?: string | import("jotai-x").UseAtomOptions | undefined) => boolean | null;
|
|
13
|
+
readOnly: (options?: string | import("jotai-x").UseAtomOptions | undefined) => boolean | null;
|
|
14
|
+
primary: (options?: string | import("jotai-x").UseAtomOptions | undefined) => boolean | null;
|
|
15
|
+
versionEditor: (options?: string | import("jotai-x").UseAtomOptions | undefined) => number | null;
|
|
16
|
+
versionSelection: (options?: string | import("jotai-x").UseAtomOptions | undefined) => number | null;
|
|
17
|
+
versionDecorate: (options?: string | import("jotai-x").UseAtomOptions | undefined) => number | null;
|
|
18
|
+
onChange: (options?: string | import("jotai-x").UseAtomOptions | undefined) => ((value: p.Value) => void) | null;
|
|
19
|
+
editorRef: (options?: string | import("jotai-x").UseAtomOptions | undefined) => React__default.ForwardedRef<p.PlateEditor<p.Value>>;
|
|
20
|
+
decorate: (options?: string | import("jotai-x").UseAtomOptions | undefined) => ((entry: p.TNodeEntry) => import("slate").BaseRange[]) | null;
|
|
21
|
+
renderElement: (options?: string | import("jotai-x").UseAtomOptions | undefined) => p.RenderElementFn | null;
|
|
22
|
+
renderLeaf: (options?: string | import("jotai-x").UseAtomOptions | undefined) => p.RenderLeafFn | null;
|
|
23
|
+
trackedEditor: (options?: string | import("jotai-x").UseAtomOptions | undefined) => {
|
|
24
|
+
editor: any;
|
|
25
|
+
version: number | null;
|
|
26
|
+
};
|
|
27
|
+
trackedSelection: (options?: string | import("jotai-x").UseAtomOptions | undefined) => {
|
|
28
|
+
selection: any;
|
|
29
|
+
version: number | null;
|
|
30
|
+
};
|
|
31
|
+
} & {
|
|
32
|
+
atom: <V>(atom: import("jotai").Atom<V>, options?: string | import("jotai-x").UseAtomOptions | undefined) => V;
|
|
33
|
+
};
|
|
7
34
|
export declare const useFocused: () => boolean;
|
|
@@ -1,10 +1,34 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import * as p from '@udecode/plate-common';
|
|
2
3
|
import * as s from 'slate';
|
|
3
4
|
import type { Value, PlateEditor, Location, PlatePlugin } from './types';
|
|
4
5
|
export type CreatePlateEditorOptions = Omit<p.CreatePlateEditorOptions<Value, PlateEditor>, 'plugins'> & {
|
|
5
6
|
plugins?: PlatePlugin[];
|
|
6
7
|
};
|
|
7
|
-
export declare const createPlateEditor: (options?: CreatePlateEditorOptions) =>
|
|
8
|
+
export declare const createPlateEditor: (options?: CreatePlateEditorOptions) => PlateEditor & Omit<s.BaseEditor, "children" | "operations" | "marks" | "apply" | "getDirtyPaths" | "getFragment" | "markableVoid" | "normalizeNode" | "insertFragment" | "insertNode" | "isInline" | "isVoid" | "id"> & {
|
|
9
|
+
id: any;
|
|
10
|
+
children: Value;
|
|
11
|
+
operations: p.TOperation<p.TDescendant>[];
|
|
12
|
+
marks: Record<string, any> | null;
|
|
13
|
+
isInline: <N extends p.TElement>(element: N) => boolean;
|
|
14
|
+
isVoid: <N_1 extends p.TElement>(element: N_1) => boolean;
|
|
15
|
+
markableVoid: <N_2 extends p.TElement>(element: N_2) => boolean;
|
|
16
|
+
normalizeNode: <N_3 extends p.TNode>(entry: p.TNodeEntry<N_3>) => void;
|
|
17
|
+
apply: <N_4 extends p.TDescendant>(operation: p.TOperation<N_4>) => void;
|
|
18
|
+
getFragment: <N_5 extends p.TDescendant>() => N_5[];
|
|
19
|
+
insertFragment: <N_6 extends p.TDescendant>(fragment: N_6[]) => void;
|
|
20
|
+
insertNode: <N_7 extends p.TDescendant>(node: N_7) => void;
|
|
21
|
+
getDirtyPaths: <N_8 extends p.TDescendant>(operation: p.TOperation<N_8>) => s.Path[];
|
|
22
|
+
} & p.UnknownObject & Pick<import("slate-history").HistoryEditor, "history" | "undo" | "redo"> & Pick<import("slate-react").ReactEditor, "insertData" | "insertFragmentData" | "insertTextData" | "setFragmentData" | "hasRange" | "hasTarget" | "hasEditableTarget" | "hasSelectableTarget" | "isTargetInsideNonReadonlyVoid"> & p.PlateEditorMethods<Value> & {
|
|
23
|
+
key: any;
|
|
24
|
+
plugins: p.WithPlatePlugin<{}, Value, p.PlateEditor<Value>>[];
|
|
25
|
+
pluginsByKey: Record<string, p.WithPlatePlugin<{}, Value, p.PlateEditor<Value>>>;
|
|
26
|
+
prevSelection: s.BaseRange | null;
|
|
27
|
+
blockFactory: (node?: Partial<p.TElement> | undefined, path?: s.Path | undefined) => p.TElement;
|
|
28
|
+
childrenFactory: () => Value;
|
|
29
|
+
isFallback: boolean;
|
|
30
|
+
currentKeyboardEvent: import("react").KeyboardEvent<Element> | null;
|
|
31
|
+
};
|
|
8
32
|
/**
|
|
9
33
|
* The only reason for this helper to exist is to run the initial normalization
|
|
10
34
|
* before mounting the Plate editor component which in turn avoids the false
|
|
@@ -34,4 +58,4 @@ export declare const fromDOMPoint: (editor: PlateEditor, domPoint: [Node, number
|
|
|
34
58
|
exactMatch: boolean;
|
|
35
59
|
suppressThrow: boolean;
|
|
36
60
|
}) => s.BasePoint | null | undefined;
|
|
37
|
-
export declare const mockPlugin: (plugin?: Partial<PlatePlugin> | undefined) => p.WithPlatePlugin<
|
|
61
|
+
export declare const mockPlugin: (plugin?: Partial<PlatePlugin> | undefined) => p.WithPlatePlugin<p.AnyObject, p.Value, p.PlateEditor<p.Value>>;
|
|
@@ -15,7 +15,7 @@ export declare const getStartPoint: (editor: PlateEditor, at: Location) => s.Bas
|
|
|
15
15
|
export declare const isNode: (value: unknown) => value is Node;
|
|
16
16
|
export declare const isSelectionAtBlockEnd: (editor: PlateEditor, options?: p.GetAboveNodeOptions<Value>) => boolean;
|
|
17
17
|
export declare const isSelectionAtBlockStart: (editor: PlateEditor, options?: p.GetAboveNodeOptions<Value>) => boolean;
|
|
18
|
-
export declare const getBlockAbove: (editor: PlateEditor, options?: p.GetAboveNodeOptions<p.Value>) => p.TNodeEntry<p.TElement | p.TEditor
|
|
18
|
+
export declare const getBlockAbove: (editor: PlateEditor, options?: p.GetAboveNodeOptions<p.Value>) => p.TNodeEntry<p.TElement | p.TEditor<p.Value>> | undefined;
|
|
19
19
|
export declare const getNodeEntry: (editor: PlateEditor, at: Location, options?: s.EditorNodeOptions) => p.TNodeEntry<p.ENode<Value>> | undefined;
|
|
20
20
|
export declare const getNodeEntries: (editor: PlateEditor, options?: p.GetNodeEntriesOptions) => Generator<p.TNodeEntry<p.ENode<p.Value>>, void, undefined>;
|
|
21
21
|
export declare const getNodeChildren: (root: Ancestor, path: s.Path, options?: s.NodeChildrenOptions | undefined) => Generator<p.TNodeEntry<Text | Element | p.TDescendant>, void, undefined>;
|
|
@@ -24,7 +24,7 @@ export declare const unwrapNodes: (editor: PlateEditor, options?: p.UnwrapNodesO
|
|
|
24
24
|
export declare const wrapNodes: (editor: PlateEditor, element: Element, options?: p.WrapNodesOptions<Value>) => void;
|
|
25
25
|
export declare const toggleNodeType: (editor: PlateEditor, options: ToggleNodeTypeOptions, editorOptions?: Omit<EditorNodesOptions, 'match'>) => void;
|
|
26
26
|
export declare const removeMark: (editor: PlateEditor, type: string, at: BaseRange) => void;
|
|
27
|
-
export declare const unhangRange: (editor: PlateEditor, range?: Path | BasePoint | BaseRange | Span | null | undefined, options?: p.UnhangRangeOptions | undefined) => s.BaseRange | undefined;
|
|
27
|
+
export declare const unhangRange: (editor: PlateEditor, range?: Path | BasePoint | BaseRange | Span | null | undefined, options?: p.UnhangRangeOptions | undefined) => s.Path | s.BasePoint | s.BaseRange | s.Span | null | undefined;
|
|
28
28
|
export declare const toggleMark: (editor: PlateEditor, options: p.ToggleMarkOptions) => void;
|
|
29
29
|
export declare const addMark: (editor: PlateEditor, type: string, value?: unknown) => void;
|
|
30
30
|
export declare const insertText: (editor: PlateEditor, text: string, options?: TextInsertTextOptions) => void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { FieldAppSDK } from '@contentful/app-sdk';
|
|
2
3
|
import { PlatePlugin } from '../internal/types';
|
|
3
4
|
import { RichTextTrackingActionHandler } from '../plugins/Tracking';
|
|
@@ -7,6 +8,29 @@ export declare const createTestEditor: (options: {
|
|
|
7
8
|
trackingHandler?: RichTextTrackingActionHandler;
|
|
8
9
|
plugins?: PlatePlugin[];
|
|
9
10
|
}) => {
|
|
10
|
-
editor:
|
|
11
|
+
editor: import("../internal").PlateEditor & Omit<import("slate").BaseEditor, "children" | "operations" | "marks" | "apply" | "getDirtyPaths" | "getFragment" | "markableVoid" | "normalizeNode" | "insertFragment" | "insertNode" | "isInline" | "isVoid" | "id"> & {
|
|
12
|
+
id: any;
|
|
13
|
+
children: import("../internal").Value;
|
|
14
|
+
operations: import("@udecode/slate").TOperation<import("@udecode/slate").TDescendant>[];
|
|
15
|
+
marks: Record<string, any> | null;
|
|
16
|
+
isInline: <N extends import("@udecode/slate").TElement>(element: N) => boolean;
|
|
17
|
+
isVoid: <N_1 extends import("@udecode/slate").TElement>(element: N_1) => boolean;
|
|
18
|
+
markableVoid: <N_2 extends import("@udecode/slate").TElement>(element: N_2) => boolean;
|
|
19
|
+
normalizeNode: <N_3 extends import("@udecode/slate").TNode>(entry: import("@udecode/slate").TNodeEntry<N_3>) => void;
|
|
20
|
+
apply: <N_4 extends import("@udecode/slate").TDescendant>(operation: import("@udecode/slate").TOperation<N_4>) => void;
|
|
21
|
+
getFragment: <N_5 extends import("@udecode/slate").TDescendant>() => N_5[];
|
|
22
|
+
insertFragment: <N_6 extends import("@udecode/slate").TDescendant>(fragment: N_6[]) => void;
|
|
23
|
+
insertNode: <N_7 extends import("@udecode/slate").TDescendant>(node: N_7) => void;
|
|
24
|
+
getDirtyPaths: <N_8 extends import("@udecode/slate").TDescendant>(operation: import("@udecode/slate").TOperation<N_8>) => import("slate").Path[];
|
|
25
|
+
} & import("@udecode/utils").UnknownObject & Pick<import("slate-history").HistoryEditor, "history" | "undo" | "redo"> & Pick<import("slate-react").ReactEditor, "insertData" | "insertFragmentData" | "insertTextData" | "setFragmentData" | "hasRange" | "hasTarget" | "hasEditableTarget" | "hasSelectableTarget" | "isTargetInsideNonReadonlyVoid"> & import("@udecode/plate-core").PlateEditorMethods<import("../internal").Value> & {
|
|
26
|
+
key: any;
|
|
27
|
+
plugins: import("@udecode/plate-core").WithPlatePlugin<{}, import("../internal").Value, import("@udecode/plate-core").PlateEditor<import("../internal").Value>>[];
|
|
28
|
+
pluginsByKey: Record<string, import("@udecode/plate-core").WithPlatePlugin<{}, import("../internal").Value, import("@udecode/plate-core").PlateEditor<import("../internal").Value>>>;
|
|
29
|
+
prevSelection: import("slate").BaseRange | null;
|
|
30
|
+
blockFactory: (node?: Partial<import("@udecode/slate").TElement> | undefined, path?: import("slate").Path | undefined) => import("@udecode/slate").TElement;
|
|
31
|
+
childrenFactory: () => import("../internal").Value;
|
|
32
|
+
isFallback: boolean;
|
|
33
|
+
currentKeyboardEvent: import("react").KeyboardEvent<Element> | null;
|
|
34
|
+
};
|
|
11
35
|
normalize: () => void;
|
|
12
36
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-rich-text",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.17.1",
|
|
4
4
|
"source": "./src/index.tsx",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -44,23 +44,23 @@
|
|
|
44
44
|
"@contentful/f36-icons": "^4.1.1",
|
|
45
45
|
"@contentful/f36-tokens": "^4.0.0",
|
|
46
46
|
"@contentful/f36-utils": "^4.19.0",
|
|
47
|
-
"@contentful/field-editor-reference": "^5.22.
|
|
47
|
+
"@contentful/field-editor-reference": "^5.22.1",
|
|
48
48
|
"@contentful/field-editor-shared": "^1.4.5",
|
|
49
49
|
"@contentful/rich-text-plain-text-renderer": "^16.0.4",
|
|
50
50
|
"@contentful/rich-text-types": "16.3.0",
|
|
51
51
|
"@popperjs/core": "^2.11.5",
|
|
52
|
-
"@udecode/plate-basic-marks": "
|
|
53
|
-
"@udecode/plate-break": "
|
|
54
|
-
"@udecode/plate-common": "
|
|
55
|
-
"@udecode/plate-core": "
|
|
56
|
-
"@udecode/plate-list": "
|
|
57
|
-
"@udecode/plate-paragraph": "
|
|
58
|
-
"@udecode/plate-reset-node": "
|
|
59
|
-
"@udecode/plate-select": "
|
|
52
|
+
"@udecode/plate-basic-marks": "30.1.2",
|
|
53
|
+
"@udecode/plate-break": "30.1.2",
|
|
54
|
+
"@udecode/plate-common": "30.1.2",
|
|
55
|
+
"@udecode/plate-core": "30.1.2",
|
|
56
|
+
"@udecode/plate-list": "30.1.2",
|
|
57
|
+
"@udecode/plate-paragraph": "30.1.2",
|
|
58
|
+
"@udecode/plate-reset-node": "30.1.2",
|
|
59
|
+
"@udecode/plate-select": "30.1.2",
|
|
60
60
|
"@udecode/plate-serializer-docx": "23.7.0",
|
|
61
|
-
"@udecode/plate-serializer-html": "
|
|
62
|
-
"@udecode/plate-table": "
|
|
63
|
-
"@udecode/plate-trailing-block": "
|
|
61
|
+
"@udecode/plate-serializer-html": "30.1.2",
|
|
62
|
+
"@udecode/plate-table": "30.1.2",
|
|
63
|
+
"@udecode/plate-trailing-block": "30.1.2",
|
|
64
64
|
"constate": "3.2.0",
|
|
65
65
|
"fast-deep-equal": "^3.1.3",
|
|
66
66
|
"is-hotkey": "^0.2.0",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"slate": "0.94.1",
|
|
70
70
|
"slate-history": "0.100.0",
|
|
71
71
|
"slate-hyperscript": "0.77.0",
|
|
72
|
-
"slate-react": "0.
|
|
72
|
+
"slate-react": "0.102.0"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"react": ">=16.14.0",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"publishConfig": {
|
|
87
87
|
"registry": "https://npm.pkg.github.com/"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "2de73d1cdb781422c76795800888a652da2d0588"
|
|
90
90
|
}
|