@contentful/field-editor-rich-text 3.3.5 → 3.4.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.
Files changed (100) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/ContentfulEditorProvider.d.ts +3 -3
  3. package/dist/field-editor-rich-text.cjs.development.js +803 -468
  4. package/dist/field-editor-rich-text.cjs.development.js.map +1 -1
  5. package/dist/field-editor-rich-text.cjs.production.min.js +1 -1
  6. package/dist/field-editor-rich-text.cjs.production.min.js.map +1 -1
  7. package/dist/field-editor-rich-text.esm.js +745 -410
  8. package/dist/field-editor-rich-text.esm.js.map +1 -1
  9. package/dist/helpers/editor.d.ts +15 -16
  10. package/dist/helpers/extractNodes.d.ts +2 -3
  11. package/dist/helpers/sanitizeIncomingSlateDoc.d.ts +1 -1
  12. package/dist/helpers/transformers.d.ts +6 -7
  13. package/dist/internal/constants.d.ts +1 -0
  14. package/dist/internal/hooks.d.ts +1 -0
  15. package/dist/internal/index.d.ts +4 -0
  16. package/dist/internal/misc.d.ts +35 -0
  17. package/dist/internal/queries.d.ts +78 -0
  18. package/dist/internal/transforms.d.ts +33 -0
  19. package/dist/internal/types/editor.d.ts +70 -0
  20. package/dist/internal/types/index.d.ts +2 -0
  21. package/dist/internal/types/plugins.d.ts +12 -0
  22. package/dist/plugins/Break/createExitBreakPlugin.d.ts +2 -2
  23. package/dist/plugins/Break/createResetNodePlugin.d.ts +2 -2
  24. package/dist/plugins/Break/createSoftBreakPlugin.d.ts +2 -2
  25. package/dist/plugins/CommandPalette/components/CommandList.d.ts +2 -2
  26. package/dist/plugins/CommandPalette/components/CommandList.styles.d.ts +1 -0
  27. package/dist/plugins/CommandPalette/components/CommandPrompt.d.ts +4 -2
  28. package/dist/plugins/CommandPalette/createCommandPalettePlugin.d.ts +2 -2
  29. package/dist/plugins/CommandPalette/onKeyDown.d.ts +2 -3
  30. package/dist/plugins/CommandPalette/useCommands.d.ts +2 -2
  31. package/dist/plugins/DragAndDrop/index.d.ts +2 -2
  32. package/dist/plugins/EmbeddedEntityBlock/LinkedEntityBlock.d.ts +1 -1
  33. package/dist/plugins/EmbeddedEntityBlock/Util.d.ts +2 -1
  34. package/dist/plugins/EmbeddedEntityBlock/index.d.ts +3 -3
  35. package/dist/plugins/EmbeddedEntityInline/index.d.ts +2 -2
  36. package/dist/plugins/Heading/createHeadingPlugin.d.ts +2 -2
  37. package/dist/plugins/Hr/index.d.ts +3 -3
  38. package/dist/plugins/Hyperlink/HyperlinkModal.d.ts +2 -3
  39. package/dist/plugins/Hyperlink/components/EntityHyperlink.d.ts +1 -1
  40. package/dist/plugins/Hyperlink/components/UrlHyperlink.d.ts +1 -1
  41. package/dist/plugins/Hyperlink/createHyperlinkPlugin.d.ts +2 -2
  42. package/dist/plugins/Hyperlink/utils.d.ts +3 -3
  43. package/dist/plugins/List/createListPlugin.d.ts +2 -2
  44. package/dist/plugins/List/insertListBreak.d.ts +2 -2
  45. package/dist/plugins/List/insertListFragment.d.ts +2 -3
  46. package/dist/plugins/List/onKeyDownList.d.ts +3 -3
  47. package/dist/plugins/List/transforms/deleteBackwardList.d.ts +2 -2
  48. package/dist/plugins/List/transforms/insertListItem.d.ts +2 -2
  49. package/dist/plugins/List/transforms/moveListItemDown.d.ts +3 -8
  50. package/dist/plugins/List/transforms/moveListItems.d.ts +2 -6
  51. package/dist/plugins/List/transforms/toggleList.d.ts +2 -2
  52. package/dist/plugins/List/transforms/unwrapList.d.ts +2 -3
  53. package/dist/plugins/List/utils.d.ts +8 -9
  54. package/dist/plugins/List/withList.d.ts +2 -4
  55. package/dist/plugins/Marks/Bold.d.ts +3 -4
  56. package/dist/plugins/Marks/Code.d.ts +3 -4
  57. package/dist/plugins/Marks/Italic.d.ts +3 -4
  58. package/dist/plugins/Marks/Subscript.d.ts +3 -4
  59. package/dist/plugins/Marks/Superscript.d.ts +3 -4
  60. package/dist/plugins/Marks/Underline.d.ts +3 -4
  61. package/dist/plugins/Marks/helpers.d.ts +3 -5
  62. package/dist/plugins/Marks/index.d.ts +2 -2
  63. package/dist/plugins/Normalizer/createNormalizerPlugin.d.ts +2 -2
  64. package/dist/plugins/Normalizer/types.d.ts +3 -5
  65. package/dist/plugins/Normalizer/utils.d.ts +0 -3
  66. package/dist/plugins/Normalizer/withNormalizer.d.ts +2 -2
  67. package/dist/plugins/Paragraph/Paragraph.d.ts +1 -1
  68. package/dist/plugins/Paragraph/createParagraphPlugin.d.ts +2 -2
  69. package/dist/plugins/PasteHTML/createPasteHTMLPlugin.d.ts +2 -2
  70. package/dist/plugins/Quote/components/Quote.d.ts +1 -1
  71. package/dist/plugins/Quote/createQuotePlugin.d.ts +2 -2
  72. package/dist/plugins/Quote/shouldResetQuote.d.ts +1 -1
  73. package/dist/plugins/Quote/toggleQuote.d.ts +2 -3
  74. package/dist/plugins/Quote/withQuote.d.ts +2 -3
  75. package/dist/plugins/SelectOnBackspace/createSelectOnBackspacePlugin.d.ts +2 -2
  76. package/dist/plugins/Table/actions/addColumn.d.ts +7 -4
  77. package/dist/plugins/Table/actions/addRow.d.ts +3 -3
  78. package/dist/plugins/Table/actions/setHeader.d.ts +2 -2
  79. package/dist/plugins/Table/components/Cell.d.ts +2 -2
  80. package/dist/plugins/Table/components/HeaderCell.d.ts +2 -2
  81. package/dist/plugins/Table/createTablePlugin.d.ts +2 -2
  82. package/dist/plugins/Table/helpers.d.ts +8 -9
  83. package/dist/plugins/Table/insertTableFragment.d.ts +3 -3
  84. package/dist/plugins/Table/onKeyDownTable.d.ts +2 -3
  85. package/dist/plugins/Table/tableTracking.d.ts +2 -2
  86. package/dist/plugins/Text/createTextPlugin.d.ts +2 -2
  87. package/dist/plugins/Tracking/createTrackingPlugin.d.ts +2 -2
  88. package/dist/plugins/Tracking/utils.d.ts +2 -2
  89. package/dist/plugins/TrailingParagraph/index.d.ts +2 -2
  90. package/dist/plugins/Voids/createVoidsPlugin.d.ts +2 -2
  91. package/dist/plugins/Voids/transformVoid.d.ts +2 -3
  92. package/dist/plugins/index.d.ts +2 -2
  93. package/dist/prepareDocument.d.ts +5 -6
  94. package/dist/test-utils/assertOutput.d.ts +2 -2
  95. package/dist/test-utils/createEditor.d.ts +22 -4
  96. package/dist/test-utils/jsx.d.ts +1 -1
  97. package/dist/test-utils/mockPlugin.d.ts +2 -2
  98. package/dist/test-utils/setEmptyDataAttribute.d.ts +2 -2
  99. package/package.json +17 -16
  100. package/dist/types.d.ts +0 -52
@@ -1,20 +1,19 @@
1
1
  import { Link } from '@contentful/field-editor-reference/dist/types';
2
2
  import { BLOCKS, INLINES } from '@contentful/rich-text-types';
3
- import { EditorNodesOptions, PlateEditor, ToggleNodeTypeOptions } from '@udecode/plate-core';
4
- import { Path, Node } from 'slate';
5
- import { CustomElement, RichTextEditor } from '../types';
3
+ import { EditorNodesOptions, ToggleNodeTypeOptions, Node, Path } from '../internal/types';
4
+ import { CustomElement, PlateEditor } from '../internal/types';
6
5
  export declare const LINK_TYPES: INLINES[];
7
6
  export declare function isBlockSelected(editor: PlateEditor, type: string): boolean;
8
7
  export declare function isRootLevel(path: Path): boolean;
9
8
  declare type NodeEntry = [CustomElement, Path];
10
9
  declare type NodeType = BLOCKS | INLINES;
11
- export declare function getNodeEntryFromSelection(editor: RichTextEditor, nodeTypeOrTypes: NodeType | NodeType[], path?: Path): NodeEntry | [];
12
- export declare function isNodeTypeSelected(editor: RichTextEditor, nodeType: BLOCKS | INLINES): boolean;
13
- export declare function moveToTheNextLine(editor: RichTextEditor): void;
14
- export declare function moveToTheNextChar(editor: RichTextEditor): void;
15
- export declare function insertEmptyParagraph(editor: RichTextEditor, options?: any): void;
16
- export declare function getElementFromCurrentSelection(editor: RichTextEditor): (Node | Path)[];
17
- export declare function isList(editor?: RichTextEditor): boolean;
10
+ export declare function getNodeEntryFromSelection(editor: PlateEditor, nodeTypeOrTypes: NodeType | NodeType[], path?: Path): NodeEntry | [];
11
+ export declare function isNodeTypeSelected(editor: PlateEditor | null, nodeType: BLOCKS | INLINES): boolean;
12
+ export declare function moveToTheNextLine(editor: PlateEditor): void;
13
+ export declare function moveToTheNextChar(editor: PlateEditor): void;
14
+ export declare function insertEmptyParagraph(editor: PlateEditor, options?: any): void;
15
+ export declare function getElementFromCurrentSelection(editor: PlateEditor): (import("@udecode/plate-core").ENode<import("@udecode/plate-core").Value> | import("slate").Path)[];
16
+ export declare function isList(editor?: PlateEditor): boolean;
18
17
  export declare function getTableSize(table: CustomElement): Record<'numRows' | 'numColumns', number> | null;
19
18
  interface InsertLinkOptions {
20
19
  text: string;
@@ -24,18 +23,18 @@ interface InsertLinkOptions {
24
23
  path?: Path;
25
24
  }
26
25
  export declare function insertLink(editor: any, options: InsertLinkOptions): void;
27
- export declare function isLinkActive(editor?: RichTextEditor): boolean;
26
+ export declare function isLinkActive(editor?: PlateEditor | null): boolean;
28
27
  export declare function unwrapLink(editor: any): void;
29
28
  export declare function wrapLink(editor: any, { text, url, target, type, path }: InsertLinkOptions): void;
30
- export declare function getAncestorPathFromSelection(editor: RichTextEditor): Path | undefined;
31
- export declare const isAtEndOfTextSelection: (editor: RichTextEditor) => boolean;
29
+ export declare function getAncestorPathFromSelection(editor: PlateEditor): import("slate").Path | undefined;
30
+ export declare const isAtEndOfTextSelection: (editor: PlateEditor) => boolean;
32
31
  /**
33
32
  * This traversal strategy is unfortunately necessary because Slate doesn't
34
33
  * expose something like Node.next(editor).
35
34
  */
36
- export declare function getNextNode(editor: RichTextEditor): CustomElement | null;
35
+ export declare function getNextNode(editor: PlateEditor): CustomElement | null;
37
36
  export declare const INLINE_TYPES: string[];
38
37
  export declare const isInlineOrText: (node: Node) => boolean;
39
- export declare const focus: (editor: RichTextEditor) => void;
40
- export declare function toggleElement(editor: RichTextEditor, options: ToggleNodeTypeOptions, editorOptions?: Omit<EditorNodesOptions, 'match'>): void;
38
+ export declare const focus: (editor: PlateEditor) => void;
39
+ export declare function toggleElement(editor: PlateEditor, options: ToggleNodeTypeOptions, editorOptions?: EditorNodesOptions): void;
41
40
  export {};
@@ -1,6 +1,5 @@
1
- import { Path } from 'slate';
2
- import { CustomElement, RichTextEditor } from '../types';
1
+ import { PlateEditor, Node, Path } from '../internal/types';
3
2
  /**
4
3
  * It filters out all paragraphs and headings from a path and convert them into paragraphs.
5
4
  */
6
- export declare function extractParagraphs(editor: RichTextEditor, path: Path): CustomElement[];
5
+ export declare function extractParagraphs(editor: PlateEditor, path: Path): Node[];
@@ -1,4 +1,4 @@
1
- import { TextOrCustomElement } from '../types';
1
+ import { TextOrCustomElement } from '../internal/types';
2
2
  /**
3
3
  * Ensures all nodes have a child leaf text element. This should be handled by
4
4
  * Slate but its behavior has proven to be buggy and unpredictable.
@@ -1,8 +1,7 @@
1
1
  import { BLOCKS, INLINES } from '@contentful/rich-text-types';
2
- import { NodeEntry } from 'slate';
3
- import { RichTextEditor } from '../types';
4
- export declare const transformRemove: (editor: RichTextEditor, [, path]: NodeEntry<import("slate").Node>) => void;
5
- export declare const transformParagraphs: (editor: RichTextEditor, entry: NodeEntry<import("slate").Node>) => void;
6
- export declare const transformUnwrap: (editor: RichTextEditor, [, path]: NodeEntry<import("slate").Node>) => void;
7
- export declare const transformWrapIn: (type: BLOCKS | INLINES) => (editor: RichTextEditor, [, path]: NodeEntry<import("slate").Node>) => void;
8
- export declare const transformLift: (editor: RichTextEditor, [, path]: NodeEntry<import("slate").Node>) => void;
2
+ import { PlateEditor, NodeEntry } from '../internal/types';
3
+ export declare const transformRemove: (editor: PlateEditor, [, path]: NodeEntry<import("../internal/types").Node>) => void;
4
+ export declare const transformParagraphs: (editor: PlateEditor, entry: NodeEntry<import("../internal/types").Node>) => void;
5
+ export declare const transformUnwrap: (editor: PlateEditor, [, path]: NodeEntry<import("../internal/types").Node>) => void;
6
+ export declare const transformWrapIn: (type: BLOCKS | INLINES) => (editor: PlateEditor, [, path]: NodeEntry<import("../internal/types").Node>) => void;
7
+ export declare const transformLift: (editor: PlateEditor, [, path]: NodeEntry<import("../internal/types").Node>) => void;
@@ -0,0 +1 @@
1
+ export declare const ELEMENT_DEFAULT = "p";
@@ -0,0 +1 @@
1
+ export declare const useReadOnly: () => boolean;
@@ -0,0 +1,4 @@
1
+ export * from './queries';
2
+ export * from './types';
3
+ export * from './misc';
4
+ export * from './transforms';
@@ -0,0 +1,35 @@
1
+ /// <reference types="react" />
2
+ import * as p from '@udecode/plate-core';
3
+ import { StoreApiGet } from '@udecode/zustood';
4
+ import * as s from 'slate';
5
+ import type { Value, PlateEditor, PlatePlugin } from './types';
6
+ export declare type CreatePlateEditorOptions = p.CreatePlateEditorOptions<Value, PlateEditor>;
7
+ export declare const createPlateEditor: (options?: CreatePlateEditorOptions) => PlateEditor & Omit<s.BaseEditor, "children" | "operations" | "marks" | "isInline" | "isVoid" | "normalizeNode" | "apply" | "getFragment" | "insertFragment" | "insertNode"> & {
8
+ children: Value;
9
+ operations: p.TOperation<p.TDescendant>[];
10
+ marks: Record<string, any> | null;
11
+ isInline: <N extends p.TElement>(element: N) => boolean;
12
+ isVoid: <N_1 extends p.TElement>(element: N_1) => boolean;
13
+ normalizeNode: <N_2 extends p.TNode>(entry: p.TNodeEntry<N_2>) => void;
14
+ apply: <N_3 extends p.TDescendant>(operation: p.TOperation<N_3>) => void;
15
+ getFragment: <N_4 extends p.TDescendant>() => N_4[];
16
+ insertFragment: <N_5 extends p.TDescendant>(fragment: N_5[]) => void;
17
+ insertNode: <N_6 extends p.TDescendant>(node: N_6 | N_6[]) => void;
18
+ } & p.UnknownObject & Pick<import("slate-history").HistoryEditor, "history" | "undo" | "redo"> & Pick<import("slate-react").ReactEditor, "insertData" | "insertFragmentData" | "setFragmentData" | "insertTextData" | "hasRange"> & {
19
+ key: any;
20
+ id: string;
21
+ plugins: p.WithPlatePlugin<{}, Value, p.PlateEditor<Value>>[];
22
+ pluginsByKey: Record<string, p.WithPlatePlugin<{}, Value, p.PlateEditor<Value>>>;
23
+ prevSelection: s.BaseRange | null;
24
+ currentKeyboardEvent: import("react").KeyboardEvent<Element> | null;
25
+ };
26
+ export declare const withoutNormalizing: (editor: PlateEditor, fn: () => boolean | void) => boolean;
27
+ export declare const focusEditor: (editor: PlateEditor, target?: s.Location | undefined) => void;
28
+ export declare const blurEditor: (editor: PlateEditor) => void;
29
+ export declare const selectEditor: (editor: PlateEditor, opts: p.SelectEditorOptions) => void;
30
+ export declare const fromDOMPoint: (editor: PlateEditor, domPoint: [Node, number], opts?: {
31
+ exactMatch: boolean;
32
+ suppressThrow: boolean;
33
+ }) => s.BasePoint | null | undefined;
34
+ export declare const mockPlugin: (plugin?: Partial<PlatePlugin> | undefined) => p.WithPlatePlugin<p.AnyObject, p.Value, p.PlateEditor<p.Value>>;
35
+ export declare const getPlateSelectors: (id?: string | undefined) => StoreApiGet<p.PlateStoreState<Value, PlateEditor>, {}>;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Re-exporting Plate/Slate queries (aka selectors) to reduce
3
+ * the blast radius of version upgrades
4
+ */
5
+ import * as p from '@udecode/plate-core';
6
+ import * as s from 'slate';
7
+ import type { Value, PlateEditor, Location, Node, NodeEntry, BaseRange, Element, Text, Ancestor, BasePoint } from './types';
8
+ /**
9
+ * Get text content at location
10
+ */
11
+ export declare const getText: (editor: PlateEditor, at?: s.Location | undefined) => string;
12
+ export declare const isText: (value: unknown) => value is Text;
13
+ export declare const getEndPoint: (editor: PlateEditor, at: Location) => s.BasePoint;
14
+ export declare const getStartPoint: (editor: PlateEditor, at: Location) => s.BasePoint;
15
+ export declare const isNode: (value: unknown) => value is Node;
16
+ export declare const isSelectionAtBlockEnd: (editor: PlateEditor, options?: p.GetAboveNodeOptions<Value> | undefined) => boolean;
17
+ export declare const isSelectionAtBlockStart: (editor: PlateEditor, options?: p.GetAboveNodeOptions<Value> | undefined) => boolean;
18
+ export declare const getBlockAbove: (editor: PlateEditor, options?: p.GetAboveNodeOptions<p.Value> | undefined) => p.TNodeEntry<p.TEditor<p.Value> | p.TElement> | undefined;
19
+ export declare const getNodeEntry: (editor: PlateEditor, at: Location, options?: s.EditorNodeOptions | undefined) => p.TNodeEntry<p.ENode<Value>>;
20
+ export declare const getNodeEntries: (editor: PlateEditor, options?: p.GetNodeEntriesOptions<p.Value> | undefined) => Generator<p.TNodeEntry<p.ENode<p.Value>>, void, undefined>;
21
+ export declare const getNodeChildren: (root: Ancestor, path: s.Path, options?: s.NodeChildrenOptions | undefined) => Generator<p.TNodeEntry<Text | Element | p.TDescendant>, void, undefined>;
22
+ export declare const getParentNode: (editor: PlateEditor, at: Location, options?: s.EditorParentOptions | undefined) => NodeEntry<Node> | undefined;
23
+ export declare const someNode: (editor: PlateEditor, options: p.FindNodeOptions) => boolean;
24
+ export declare const getChildren: (entry: NodeEntry<Node>) => NodeEntry<Node>[];
25
+ export declare const isFirstChild: (path: s.Path) => boolean;
26
+ export declare const getDescendantNodeByPath: (root: Node, path: s.Path) => Node;
27
+ export declare const getNodeDescendants: (root: PlateEditor | Node, options?: s.NodeDescendantsOptions | undefined) => Generator<p.TNodeEntry<p.TText | p.TElement | Element>, void, undefined>;
28
+ export declare const isRangeCollapsed: (range?: s.BaseRange | undefined) => boolean;
29
+ export declare const isRangeAcrossBlocks: (editor: p.TEditor<p.Value>, options?: (Omit<p.GetAboveNodeOptions<p.Value>, 'at'> & {
30
+ at?: s.BaseRange | null | undefined;
31
+ }) | undefined) => boolean | undefined;
32
+ export declare const isRangeExpanded: (range?: s.BaseRange | undefined) => boolean;
33
+ export declare const getRange: (editor: PlateEditor, at: Location, to?: s.Location | undefined) => s.BaseRange;
34
+ export declare const getRangeEdges: (range: BaseRange) => [s.BasePoint, s.BasePoint];
35
+ export declare const getRangeStart: (range: BaseRange) => s.BasePoint;
36
+ export declare const getRangeEnd: (range: BaseRange) => s.BasePoint;
37
+ export declare const getAboveNode: (editor: PlateEditor, opts?: p.GetAboveNodeOptions<Value> | undefined) => NodeEntry<Node> | undefined;
38
+ export declare const getNextNode: (editor: PlateEditor, opts?: p.GetNextNodeOptions<Value> | undefined) => NodeEntry<Node> | undefined;
39
+ export declare const getCommonNode: (root: PlateEditor | Node, path: s.Path, another: s.Path) => NodeEntry<Node>;
40
+ export declare const getNodeTexts: (root: Node, opts?: {
41
+ from?: s.Path | undefined;
42
+ to?: s.Path | undefined;
43
+ pass?: ((ne: NodeEntry<Node>) => boolean) | undefined;
44
+ reverse?: boolean | undefined;
45
+ } | undefined) => Generator<p.TNodeEntry<p.TText>, void, undefined>;
46
+ export declare const findNode: (editor: PlateEditor, options?: p.FindNodeOptions<p.Value> | undefined) => p.TNodeEntry<p.ENode<p.Value>> | undefined;
47
+ export declare const isMarkActive: (editor: PlateEditor, type: string) => boolean;
48
+ export declare const getMarks: (editor: PlateEditor) => Partial<{
49
+ [x: string]: unknown;
50
+ [x: number]: unknown;
51
+ }> | null;
52
+ export declare const isEditor: (value: unknown) => value is PlateEditor;
53
+ export declare const isEditorReadOnly: (editor: PlateEditor) => boolean;
54
+ export declare const isElement: (value: unknown) => value is Element;
55
+ export declare const isBlockNode: (editor: PlateEditor, value: unknown) => value is Element;
56
+ export declare const findNodePath: (editor: PlateEditor, node: Node) => s.Path | undefined;
57
+ export declare const isAncestorPath: (path: s.Path, another: s.Path) => boolean;
58
+ export declare const isAncestorEmpty: (editor: PlateEditor, node: Ancestor) => boolean;
59
+ export declare const getParentPath: (path: s.Path) => s.Path;
60
+ export declare const getNextPath: (path: s.Path) => s.Path;
61
+ export declare const getPreviousPath: (path: s.Path) => s.Path;
62
+ export declare const getLastChildPath: (nodeEntry: NodeEntry<Node>) => s.Path;
63
+ export declare const getPathLevels: (path: s.Path, options?: s.PathLevelsOptions | undefined) => s.Path[];
64
+ export declare const isCommonPath: (path: s.Path, anotherPath: s.Path) => boolean;
65
+ export declare const isFirstChildPath: (path: s.Path) => boolean;
66
+ export declare const isLastChildPath: (entry: NodeEntry<Node>, childPath: s.Path) => boolean;
67
+ export declare const isChildPath: (path: s.Path, another: s.Path) => boolean;
68
+ export declare const matchNode: (node: Node, path: s.Path, fn: p.Predicate<PlateEditor | Node>) => boolean;
69
+ export declare const someHtmlElement: (rootNode: globalThis.Node, predicate: (node: HTMLElement) => boolean) => boolean;
70
+ export declare const getPointBefore: (editor: PlateEditor, at: Location, options?: s.EditorBeforeOptions | undefined) => s.BasePoint | undefined;
71
+ export declare const getPointAfter: (editor: PlateEditor, at: Location, options?: s.EditorAfterOptions | undefined) => s.BasePoint | undefined;
72
+ export declare const isEndPoint: (editor: PlateEditor, point: BasePoint | null | undefined, at: Location) => boolean;
73
+ export declare const isInline: (editor: PlateEditor, value: unknown) => boolean;
74
+ export declare const queryNode: (entry?: NodeEntry<Node> | undefined, options?: p.QueryNodeOptions | undefined) => boolean;
75
+ export declare const getPluginType: (editor: PlateEditor, key: string) => string;
76
+ export declare const createPathRef: (editor: PlateEditor, at: s.Path) => s.PathRef;
77
+ export declare const match: (obj: Node, path: s.Path, predicate?: p.Predicate<Node> | undefined) => boolean;
78
+ export declare const getLastNodeByLevel: (editor: PlateEditor, level: number) => NodeEntry | undefined;
@@ -0,0 +1,33 @@
1
+ import * as p from '@udecode/plate-core';
2
+ import * as s from 'slate';
3
+ import { Except } from 'type-fest';
4
+ import { PlateEditor, Node, ToggleNodeTypeOptions, EditorNodesOptions, BaseRange, Value, Element, Path, Span, BasePoint, Location } from './types';
5
+ /**
6
+ * Apply editor normalization rules
7
+ */
8
+ export declare const normalize: (editor: PlateEditor, options?: s.EditorNormalizeOptions) => void;
9
+ /**
10
+ * Set the selection to a location
11
+ */
12
+ export declare const setSelection: (editor: PlateEditor, props: Partial<BaseRange>) => void;
13
+ export declare const select: (editor: PlateEditor, location: Location) => void;
14
+ export declare const moveSelection: (editor: PlateEditor, options?: import("slate/dist/transforms/selection").SelectionMoveOptions | undefined) => void;
15
+ export declare const moveChildren: (editor: PlateEditor, options: p.MoveChildrenOptions<Value>) => number;
16
+ export declare const collapseSelection: (editor: PlateEditor, options?: import("slate/dist/transforms/selection").SelectionCollapseOptions | undefined) => void;
17
+ export declare const setNodes: (editor: PlateEditor, attrs: Partial<Except<Node, 'children' | 'text'>>, opts?: p.SetNodesOptions<Value> | undefined) => void;
18
+ export declare const unsetNodes: (editor: PlateEditor, props: string | number | (string | number)[], options?: p.UnsetNodesOptions<Value> | undefined) => void;
19
+ export declare const insertNodes: (editor: PlateEditor, nodes: Node | Node[], opts?: p.InsertNodesOptions<p.Value> | undefined) => void;
20
+ export declare const splitNodes: (editor: PlateEditor, options?: p.SplitNodesOptions<Value> | undefined) => void;
21
+ export declare const liftNodes: (editor: PlateEditor, options?: p.LiftNodesOptions<Value> | undefined) => void;
22
+ export declare const unwrapNodes: (editor: PlateEditor, options?: p.UnwrapNodesOptions<Value> | undefined) => void;
23
+ export declare const wrapNodes: (editor: PlateEditor, element: Element, options?: p.WrapNodesOptions<Value> | undefined) => void;
24
+ export declare const toggleNodeType: (editor: PlateEditor, options: ToggleNodeTypeOptions, editorOptions?: Omit<EditorNodesOptions, "match"> | undefined) => void;
25
+ export declare const removeMark: (editor: PlateEditor, type: string, at: BaseRange) => void;
26
+ export declare const unhangRange: (editor: PlateEditor, range?: Path | BasePoint | BaseRange | Span | null | undefined, options?: p.UnhangRangeOptions | undefined) => s.BaseRange | undefined;
27
+ export declare const toggleMark: (editor: PlateEditor, options: p.ToggleMarkOptions<Value, keyof p.TText>) => void;
28
+ export declare const addMark: (editor: PlateEditor, type: string, value?: unknown) => void;
29
+ export declare const insertText: (editor: PlateEditor, text: string, options?: import("slate/dist/transforms/text").TextInsertTextOptions | undefined) => void;
30
+ export declare const deleteText: (editor: PlateEditor, opts?: Parameters<typeof p.deleteText>['1']) => void;
31
+ export declare const removeNodes: (editor: PlateEditor, opts?: p.RemoveNodesOptions<Value> | undefined) => void;
32
+ export declare const moveNodes: (editor: PlateEditor, opts?: p.MoveNodesOptions<Value> | undefined) => void;
33
+ export declare const deleteFragment: (editor: PlateEditor, options?: s.EditorFragmentDeletionOptions | undefined) => void;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * https://plate.udecode.io/docs/typescript
3
+ */
4
+ import { MARKS } from '@contentful/rich-text-types';
5
+ import * as p from '@udecode/plate-core';
6
+ import * as s from 'slate';
7
+ import * as sr from 'slate-react';
8
+ import { SelectionMoveOptions as SlateSelectionMoveOptions, SelectionCollapseOptions as SlateSelectionCollapseOptions } from 'slate/dist/transforms/selection';
9
+ import { TextInsertTextOptions as SlateTextInsertTextOptions } from 'slate/dist/transforms/text';
10
+ import { TrackingPluginActions } from '../../plugins/Tracking';
11
+ export interface Text extends p.TText {
12
+ [MARKS.BOLD]?: boolean;
13
+ [MARKS.CODE]?: boolean;
14
+ [MARKS.ITALIC]?: boolean;
15
+ [MARKS.UNDERLINE]?: boolean;
16
+ [MARKS.SUPERSCRIPT]?: boolean;
17
+ [MARKS.SUBSCRIPT]?: boolean;
18
+ }
19
+ export interface Element extends p.TElement {
20
+ type: string;
21
+ data?: Record<string, unknown>;
22
+ isVoid?: boolean;
23
+ children: (Text | Element)[];
24
+ }
25
+ export declare type Value = Element[];
26
+ export declare type ReactEditor = p.TReactEditor<Value>;
27
+ export interface PlateEditor extends p.PlateEditor<Value> {
28
+ tracking: TrackingPluginActions;
29
+ }
30
+ export declare type CustomText = {
31
+ text: string;
32
+ [MARKS.BOLD]?: boolean;
33
+ [MARKS.CODE]?: boolean;
34
+ [MARKS.ITALIC]?: boolean;
35
+ [MARKS.UNDERLINE]?: boolean;
36
+ [MARKS.SUPERSCRIPT]?: boolean;
37
+ [MARKS.SUBSCRIPT]?: boolean;
38
+ };
39
+ export declare type TextOrCustomElement = CustomElement | CustomText;
40
+ export declare type CustomElement<T = unknown> = {
41
+ type: string;
42
+ children: TextOrCustomElement[];
43
+ data: T;
44
+ isVoid?: boolean;
45
+ };
46
+ export declare type CustomRenderElementProps<T = any, O = any> = Omit<RenderElementProps, 'element'> & {
47
+ element: CustomElement<T>;
48
+ } & O;
49
+ export declare type Node = p.ElementOf<PlateEditor> | p.TextOf<PlateEditor>;
50
+ export declare type Path = p.TPath;
51
+ export declare type NodeEntry<T extends Node = Node> = p.TNodeEntry<T>;
52
+ export declare type NodeMatch = p.ENodeMatch<Node>;
53
+ export declare type Ancestor = p.AncestorOf<PlateEditor>;
54
+ export declare type Descendant = p.DescendantOf<PlateEditor>;
55
+ export declare type Operation = p.TOperation<Descendant>;
56
+ export declare type Location = p.TLocation;
57
+ export declare type BaseRange = p.TRange;
58
+ export declare type ToggleNodeTypeOptions = p.ToggleNodeTypeOptions;
59
+ export declare type EditorNodesOptions = Omit<p.GetNodeEntriesOptions<Value>, 'match'>;
60
+ export declare type WithOverride<P = p.AnyObject> = p.WithOverride<P, Value, PlateEditor>;
61
+ export declare type SelectionMoveOptions = SlateSelectionMoveOptions;
62
+ export declare type TextInsertTextOptions = SlateTextInsertTextOptions;
63
+ export declare type SelectionCollapseOptions = SlateSelectionCollapseOptions;
64
+ export declare type HotkeyPlugin = p.HotkeyPlugin;
65
+ export declare type RenderLeafProps = sr.RenderLeafProps;
66
+ export declare type RenderElementProps = sr.RenderElementProps;
67
+ export declare type Span = p.TSpan;
68
+ export declare type BasePoint = s.BasePoint;
69
+ export declare type BaseSelection = s.BaseSelection;
70
+ export declare type PathRef = s.PathRef;
@@ -0,0 +1,2 @@
1
+ export * from './editor';
2
+ export * from './plugins';
@@ -0,0 +1,12 @@
1
+ import { SoftBreakRule, ExitBreakRule } from '@udecode/plate-break';
2
+ import * as p from '@udecode/plate-core';
3
+ import { ResetNodePluginRule } from '@udecode/plate-reset-node';
4
+ import type { NormalizerRule } from '../../plugins/Normalizer';
5
+ import { Value, PlateEditor } from './editor';
6
+ export declare type KeyboardHandler<P = p.PluginOptions> = p.KeyboardHandler<P, Value, PlateEditor>;
7
+ export interface PlatePlugin extends p.PlatePlugin<p.AnyObject, Value, PlateEditor> {
8
+ softBreak?: SoftBreakRule[];
9
+ exitBreak?: ExitBreakRule[];
10
+ resetNode?: ResetNodePluginRule<Value, PlateEditor>[];
11
+ normalizer?: NormalizerRule[];
12
+ }
@@ -1,2 +1,2 @@
1
- import { RichTextPlugin } from '../../types';
2
- export declare const createExitBreakPlugin: () => RichTextPlugin;
1
+ import { PlatePlugin } from '../../internal/types';
2
+ export declare const createExitBreakPlugin: () => PlatePlugin;
@@ -1,2 +1,2 @@
1
- import { RichTextPlugin } from '../../types';
2
- export declare const createResetNodePlugin: () => RichTextPlugin;
1
+ import { PlatePlugin } from '../../internal/types';
2
+ export declare const createResetNodePlugin: () => PlatePlugin;
@@ -1,2 +1,2 @@
1
- import { RichTextPlugin } from '../../types';
2
- export declare const createSoftBreakPlugin: () => RichTextPlugin;
1
+ import { PlatePlugin } from '../../internal/types';
2
+ export declare const createSoftBreakPlugin: () => PlatePlugin;
@@ -1,7 +1,7 @@
1
- import { RichTextEditor } from '../../../types';
1
+ import { PlateEditor } from '../../../internal/types';
2
2
  export interface CommandListProps {
3
3
  query: string;
4
- editor: RichTextEditor;
4
+ editor: PlateEditor;
5
5
  textContainer?: HTMLSpanElement;
6
6
  }
7
7
  export declare const CommandList: ({ query, editor, textContainer }: CommandListProps) => JSX.Element | null;
@@ -1,5 +1,6 @@
1
1
  declare const styles: {
2
2
  container: string;
3
+ menuPoper: string;
3
4
  menuContent: string;
4
5
  menuList: string;
5
6
  menuItem: string;
@@ -1,2 +1,4 @@
1
- import { PlateRenderLeafProps } from '@udecode/plate-core';
2
- export declare const CommandPrompt: (props: PlateRenderLeafProps) => JSX.Element;
1
+ import { PlateEditor, RenderLeafProps } from '../../../internal/types';
2
+ export declare const CommandPrompt: (props: RenderLeafProps & {
3
+ editor: PlateEditor;
4
+ }) => JSX.Element;
@@ -1,4 +1,4 @@
1
- import { RichTextPlugin } from '../../types';
1
+ import { PlatePlugin } from '../../internal/types';
2
2
  /**
3
3
  * A command palette plugin (aka slash commands)
4
4
  *
@@ -10,4 +10,4 @@ import { RichTextPlugin } from '../../types';
10
10
  * * When the user presses a letter, number, or space, the command palette will show the command suggestions
11
11
  * * When the user presses backspace, the command palette will remove the last character from the command string
12
12
  */
13
- export declare const createCommandPalettePlugin: () => RichTextPlugin;
13
+ export declare const createCommandPalettePlugin: () => PlatePlugin;
@@ -1,3 +1,2 @@
1
- import { KeyboardHandler } from '@udecode/plate-core';
2
- import { RichTextEditor } from '../../types';
3
- export declare const createOnKeyDown: () => KeyboardHandler<RichTextEditor>;
1
+ import { KeyboardHandler } from '../../internal/types';
2
+ export declare const createOnKeyDown: () => KeyboardHandler;
@@ -1,5 +1,5 @@
1
1
  import { FieldExtensionSDK } from '@contentful/app-sdk';
2
- import { RichTextEditor } from 'types';
2
+ import { PlateEditor } from '../../internal/types';
3
3
  export interface Command {
4
4
  id: string;
5
5
  thumbnail?: string;
@@ -11,4 +11,4 @@ export interface CommandGroup {
11
11
  commands: Command[];
12
12
  }
13
13
  export declare type CommandList = (Command | CommandGroup)[];
14
- export declare const useCommands: (sdk: FieldExtensionSDK, query: string, editor: RichTextEditor) => CommandList;
14
+ export declare const useCommands: (sdk: FieldExtensionSDK, query: string, editor: PlateEditor) => CommandList;
@@ -1,2 +1,2 @@
1
- import { RichTextPlugin } from '../../types';
2
- export declare function createDragAndDropPlugin(): RichTextPlugin;
1
+ import { PlatePlugin } from '../../internal/types';
2
+ export declare function createDragAndDropPlugin(): PlatePlugin;
@@ -1,4 +1,4 @@
1
- import { CustomRenderElementProps } from '../../types';
1
+ import { CustomRenderElementProps } from '../../internal/types';
2
2
  declare type LinkedEntityBlockProps = CustomRenderElementProps<{
3
3
  target: {
4
4
  sys: {
@@ -1,3 +1,4 @@
1
+ import { PlateEditor } from '../../internal/types';
1
2
  import { TrackingPluginActions } from '../../plugins/Tracking';
2
3
  export declare function selectEntityAndInsert(nodeType: any, sdk: any, editor: any, logAction: TrackingPluginActions['onToolbarAction'] | TrackingPluginActions['onShortcutAction']): Promise<void>;
3
- export declare function insertBlock(editor: any, nodeType: any, entity: any): void;
4
+ export declare function insertBlock(editor: PlateEditor, nodeType: string, entity: any): void;
@@ -1,5 +1,5 @@
1
1
  import { FieldExtensionSDK } from '@contentful/app-sdk';
2
- import { RichTextPlugin } from '../../types';
2
+ import { PlatePlugin } from '../../internal/types';
3
3
  export { EmbeddedEntityBlockToolbarIcon as ToolbarIcon } from './ToolbarIcon';
4
- export declare const createEmbeddedEntryBlockPlugin: (sdk: FieldExtensionSDK) => RichTextPlugin;
5
- export declare const createEmbeddedAssetBlockPlugin: (sdk: FieldExtensionSDK) => RichTextPlugin;
4
+ export declare const createEmbeddedEntryBlockPlugin: (sdk: FieldExtensionSDK) => PlatePlugin;
5
+ export declare const createEmbeddedAssetBlockPlugin: (sdk: FieldExtensionSDK) => PlatePlugin;
@@ -1,9 +1,9 @@
1
1
  import { FieldExtensionSDK } from '@contentful/app-sdk';
2
- import { RichTextPlugin } from '../../types';
2
+ import { PlatePlugin } from '../../internal/types';
3
3
  interface ToolbarEmbeddedEntityInlineButtonProps {
4
4
  onClose: () => void;
5
5
  isDisabled: boolean;
6
6
  }
7
7
  export declare function ToolbarEmbeddedEntityInlineButton(props: ToolbarEmbeddedEntityInlineButtonProps): JSX.Element;
8
- export declare function createEmbeddedEntityInlinePlugin(sdk: FieldExtensionSDK): RichTextPlugin;
8
+ export declare function createEmbeddedEntityInlinePlugin(sdk: FieldExtensionSDK): PlatePlugin;
9
9
  export {};
@@ -1,2 +1,2 @@
1
- import { RichTextPlugin } from '../../types';
2
- export declare const createHeadingPlugin: () => RichTextPlugin;
1
+ import { PlatePlugin } from '../../internal/types';
2
+ export declare const createHeadingPlugin: () => PlatePlugin;
@@ -1,11 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import * as Slate from 'slate-react';
3
- import { RichTextEditor, RichTextPlugin } from '../../types';
3
+ import { PlatePlugin, PlateEditor } from '../../internal/types';
4
4
  interface ToolbarHrButtonProps {
5
5
  isDisabled?: boolean;
6
6
  }
7
- export declare function withHrEvents(editor: RichTextEditor): (event: React.KeyboardEvent) => void;
7
+ export declare function withHrEvents(editor: PlateEditor): (event: React.KeyboardEvent) => void;
8
8
  export declare function ToolbarHrButton(props: ToolbarHrButtonProps): JSX.Element | null;
9
9
  export declare function Hr(props: Slate.RenderLeafProps): JSX.Element;
10
- export declare const createHrPlugin: () => RichTextPlugin;
10
+ export declare const createHrPlugin: () => PlatePlugin;
11
11
  export {};
@@ -1,8 +1,7 @@
1
1
  import { Link } from '@contentful/field-editor-reference/dist/types';
2
2
  import { FieldExtensionSDK } from '@contentful/field-editor-shared';
3
- import { Path } from 'slate';
3
+ import { PlateEditor, Path } from '../../internal/types';
4
4
  import { TrackingPluginActions } from '../../plugins/Tracking';
5
- import { RichTextEditor } from '../../types';
6
5
  interface HyperlinkModalProps {
7
6
  linkText?: string;
8
7
  linkType?: string;
@@ -13,5 +12,5 @@ interface HyperlinkModalProps {
13
12
  readonly: boolean;
14
13
  }
15
14
  export declare function HyperlinkModal(props: HyperlinkModalProps): JSX.Element;
16
- export declare function addOrEditLink(editor: RichTextEditor, sdk: FieldExtensionSDK, logAction: TrackingPluginActions['onToolbarAction'] | TrackingPluginActions['onShortcutAction'] | TrackingPluginActions['onViewportAction'], targetPath?: Path): Promise<void>;
15
+ export declare function addOrEditLink(editor: PlateEditor, sdk: FieldExtensionSDK, logAction: TrackingPluginActions['onToolbarAction'] | TrackingPluginActions['onShortcutAction'] | TrackingPluginActions['onViewportAction'], targetPath?: Path): Promise<void>;
17
16
  export {};
@@ -1,5 +1,5 @@
1
1
  import { Link } from '@contentful/app-sdk';
2
- import { CustomRenderElementProps } from '../../../types';
2
+ import { CustomRenderElementProps } from '../../../internal/types';
3
3
  declare type HyperlinkElementProps = CustomRenderElementProps<{
4
4
  uri?: string;
5
5
  target?: Link;
@@ -1,5 +1,5 @@
1
1
  import { Link } from '@contentful/app-sdk';
2
- import { CustomRenderElementProps } from '../../../types';
2
+ import { CustomRenderElementProps } from '../../../internal/types';
3
3
  declare type HyperlinkElementProps = CustomRenderElementProps<{
4
4
  uri?: string;
5
5
  target?: Link;
@@ -1,3 +1,3 @@
1
1
  import { FieldExtensionSDK } from '@contentful/app-sdk';
2
- import { RichTextPlugin } from '../../types';
3
- export declare const createHyperlinkPlugin: (sdk: FieldExtensionSDK) => RichTextPlugin;
2
+ import { PlatePlugin } from '../../internal/types';
3
+ export declare const createHyperlinkPlugin: (sdk: FieldExtensionSDK) => PlatePlugin;
@@ -1,5 +1,5 @@
1
- import { NodeEntry, Node } from 'slate';
2
- import { RichTextEditor } from '../../types';
1
+ import { NodeEntry } from '../../internal/types';
2
+ import { PlateEditor } from '../../internal/types';
3
3
  import { FetchedEntityData } from './useEntityInfo';
4
- export declare const hasText: (editor: RichTextEditor, entry: NodeEntry<Node>) => boolean;
4
+ export declare const hasText: (editor: PlateEditor, entry: NodeEntry<import("../../internal/types").Node>) => boolean;
5
5
  export declare function getEntityInfo(data?: FetchedEntityData): string;
@@ -1,2 +1,2 @@
1
- import { RichTextPlugin } from '../../types';
2
- export declare const createListPlugin: () => RichTextPlugin;
1
+ import { PlatePlugin } from '../../internal/types';
2
+ export declare const createListPlugin: () => PlatePlugin;
@@ -1,2 +1,2 @@
1
- import { RichTextEditor } from '../../types';
2
- export declare const insertListBreak: (editor: RichTextEditor) => () => void;
1
+ import { PlateEditor } from '../../internal/types';
2
+ export declare const insertListBreak: (editor: PlateEditor) => () => void;
@@ -1,3 +1,2 @@
1
- import { TDescendant } from '@udecode/plate-core';
2
- import { RichTextEditor } from '../../types';
3
- export declare const insertListFragment: (editor: RichTextEditor) => (fragment: TDescendant[]) => void;
1
+ import { PlateEditor, Node } from '../../internal/types';
2
+ export declare const insertListFragment: (editor: PlateEditor) => (fragment: Node[]) => void;
@@ -2,6 +2,6 @@
2
2
  * Credit: Modified version of Plate's list plugin
3
3
  * See: https://github.com/udecode/plate/blob/main/packages/nodes/list
4
4
  */
5
- import { HotkeyPlugin, KeyboardHandler } from '@udecode/plate-core';
6
- import { RichTextEditor } from '../../types';
7
- export declare const onKeyDownList: KeyboardHandler<RichTextEditor, HotkeyPlugin>;
5
+ import { HotkeyPlugin } from '@udecode/plate-core';
6
+ import { KeyboardHandler } from '../../internal/types';
7
+ export declare const onKeyDownList: KeyboardHandler<HotkeyPlugin>;
@@ -1,2 +1,2 @@
1
- import { RichTextEditor } from '../../../types';
2
- export declare const deleteBackwardList: (editor: RichTextEditor, unit: 'character' | 'word' | 'line' | 'block') => boolean;
1
+ import { PlateEditor } from '../../../internal/types';
2
+ export declare const deleteBackwardList: (editor: PlateEditor, unit: 'character' | 'word' | 'line' | 'block') => boolean;
@@ -1,5 +1,5 @@
1
- import { RichTextEditor } from '../../../types';
1
+ import { PlateEditor } from '../../../internal/types';
2
2
  /**
3
3
  * Insert list item if selection is in li>p.
4
4
  */
5
- export declare const insertListItem: (editor: RichTextEditor) => boolean;
5
+ export declare const insertListItem: (editor: PlateEditor) => boolean;
@@ -1,11 +1,6 @@
1
- /**
2
- * Credit: Modified version of Plate's list plugin
3
- * See: https://github.com/udecode/plate/blob/main/packages/nodes/list
4
- */
5
- import { PlateEditor, TElement } from '@udecode/plate-core';
6
- import { NodeEntry } from 'slate';
1
+ import { NodeEntry, PlateEditor } from '../../../internal/types';
7
2
  export interface MoveListItemDownOptions {
8
- list: NodeEntry<TElement>;
9
- listItem: NodeEntry<TElement>;
3
+ list: NodeEntry;
4
+ listItem: NodeEntry;
10
5
  }
11
6
  export declare const moveListItemDown: (editor: PlateEditor, { list, listItem }: MoveListItemDownOptions) => void;