@contentful/field-editor-rich-text 3.4.1 → 3.4.3

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.
@@ -1,11 +1,11 @@
1
1
  import { Link } from '@contentful/field-editor-reference/dist/types';
2
2
  import { BLOCKS, INLINES } from '@contentful/rich-text-types';
3
3
  import { EditorNodesOptions, ToggleNodeTypeOptions, Node, Path } from '../internal/types';
4
- import { CustomElement, PlateEditor } from '../internal/types';
4
+ import { Element, PlateEditor } from '../internal/types';
5
5
  export declare const LINK_TYPES: INLINES[];
6
6
  export declare function isBlockSelected(editor: PlateEditor, type: string): boolean;
7
7
  export declare function isRootLevel(path: Path): boolean;
8
- declare type NodeEntry = [CustomElement, Path];
8
+ declare type NodeEntry = [Element, Path];
9
9
  declare type NodeType = BLOCKS | INLINES;
10
10
  export declare function getNodeEntryFromSelection(editor: PlateEditor, nodeTypeOrTypes: NodeType | NodeType[], path?: Path): NodeEntry | [];
11
11
  export declare function isNodeTypeSelected(editor: PlateEditor | null, nodeType: BLOCKS | INLINES): boolean;
@@ -14,7 +14,7 @@ export declare function moveToTheNextChar(editor: PlateEditor): void;
14
14
  export declare function insertEmptyParagraph(editor: PlateEditor, options?: any): void;
15
15
  export declare function getElementFromCurrentSelection(editor: PlateEditor): (import("@udecode/plate-core").ENode<import("@udecode/plate-core").Value> | import("slate").Path)[];
16
16
  export declare function isList(editor?: PlateEditor): boolean;
17
- export declare function getTableSize(table: CustomElement): Record<'numRows' | 'numColumns', number> | null;
17
+ export declare function getTableSize(table: Element): Record<'numRows' | 'numColumns', number> | null;
18
18
  interface InsertLinkOptions {
19
19
  text: string;
20
20
  type: INLINES.HYPERLINK | INLINES.ENTRY_HYPERLINK | INLINES.ASSET_HYPERLINK;
@@ -32,7 +32,7 @@ export declare const isAtEndOfTextSelection: (editor: PlateEditor) => boolean;
32
32
  * This traversal strategy is unfortunately necessary because Slate doesn't
33
33
  * expose something like Node.next(editor).
34
34
  */
35
- export declare function getNextNode(editor: PlateEditor): CustomElement | null;
35
+ export declare function getNextNode(editor: PlateEditor): Element | null;
36
36
  export declare const INLINE_TYPES: string[];
37
37
  export declare const isInlineOrText: (node: Node) => boolean;
38
38
  export declare const focus: (editor: PlateEditor) => void;
@@ -1,6 +1,6 @@
1
- import { TextOrCustomElement } from '../internal/types';
1
+ import { Node } 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.
5
5
  */
6
- export declare function sanitizeIncomingSlateDoc(nodes?: TextOrCustomElement[]): TextOrCustomElement[];
6
+ export declare function sanitizeIncomingSlateDoc(nodes?: Node[]): Node[];
@@ -1 +1,4 @@
1
+ import * as p from '@udecode/plate-core';
1
2
  export declare const useReadOnly: () => boolean;
3
+ export declare const usePlateEditorRef: <V extends p.Value = p.Value, E extends p.PlateEditor<V> = p.PlateEditor<V>>(id?: string | undefined) => E | null;
4
+ export declare const usePlateEditorState: <V extends p.Value = p.Value, E extends p.PlateEditor<V> = p.PlateEditor<V>>(id?: string | undefined) => E | null;
@@ -3,7 +3,9 @@ import * as p from '@udecode/plate-core';
3
3
  import { StoreApiGet } from '@udecode/zustood';
4
4
  import * as s from 'slate';
5
5
  import type { Value, PlateEditor, PlatePlugin } from './types';
6
- export declare type CreatePlateEditorOptions = p.CreatePlateEditorOptions<Value, PlateEditor>;
6
+ export declare type CreatePlateEditorOptions = Omit<p.CreatePlateEditorOptions<Value, PlateEditor>, 'plugins'> & {
7
+ plugins?: PlatePlugin[];
8
+ };
7
9
  export declare const createPlateEditor: (options?: CreatePlateEditorOptions) => PlateEditor & Omit<s.BaseEditor, "children" | "operations" | "marks" | "isInline" | "isVoid" | "normalizeNode" | "apply" | "getFragment" | "insertFragment" | "insertNode"> & {
8
10
  children: Value;
9
11
  operations: p.TOperation<p.TDescendant>[];
@@ -27,25 +27,6 @@ export declare type ReactEditor = p.TReactEditor<Value>;
27
27
  export interface PlateEditor extends p.PlateEditor<Value> {
28
28
  tracking: TrackingPluginActions;
29
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
30
  export declare type Node = p.ElementOf<PlateEditor> | p.TextOf<PlateEditor>;
50
31
  export declare type Path = p.TPath;
51
32
  export declare type NodeEntry<T extends Node = Node> = p.TNodeEntry<T>;
@@ -1,13 +1,18 @@
1
- import { CustomRenderElementProps } from '../../internal/types';
2
- declare type LinkedEntityBlockProps = CustomRenderElementProps<{
3
- target: {
4
- sys: {
5
- id: string;
6
- linkType: 'Entry' | 'Asset';
7
- type: 'Link';
1
+ import { Element, RenderElementProps } from '../../internal/types';
2
+ declare type LinkedEntityBlockProps = {
3
+ element: Element & {
4
+ data: {
5
+ target: {
6
+ sys: {
7
+ id: string;
8
+ linkType: 'Entry' | 'Asset';
9
+ type: 'Link';
10
+ };
11
+ };
8
12
  };
9
13
  };
10
- }> & {
14
+ attributes: Pick<RenderElementProps, 'attributes'>;
15
+ children: Pick<RenderElementProps, 'children'>;
11
16
  onEntityFetchComplete: VoidFunction;
12
17
  };
13
18
  export declare function LinkedEntityBlock(props: LinkedEntityBlockProps): JSX.Element;
@@ -1,9 +1,20 @@
1
1
  import { Link } from '@contentful/app-sdk';
2
- import { CustomRenderElementProps } from '../../../internal/types';
3
- declare type HyperlinkElementProps = CustomRenderElementProps<{
4
- uri?: string;
5
- target?: Link;
6
- onEntityFetchComplete?: VoidFunction;
7
- }>;
2
+ import { Element, RenderElementProps } from '../../../internal/types';
3
+ export declare type HyperlinkElementProps = {
4
+ element: Element & {
5
+ data: {
6
+ target: {
7
+ sys: {
8
+ id: string;
9
+ linkType: 'Entry' | 'Asset';
10
+ type: 'Link';
11
+ };
12
+ };
13
+ };
14
+ };
15
+ target: Link;
16
+ attributes: Pick<RenderElementProps, 'attributes'>;
17
+ children: Pick<RenderElementProps, 'children'>;
18
+ onEntityFetchComplete: VoidFunction;
19
+ };
8
20
  export declare function EntityHyperlink(props: HyperlinkElementProps): JSX.Element | null;
9
- export {};
@@ -1,9 +1,21 @@
1
1
  import { Link } from '@contentful/app-sdk';
2
- import { CustomRenderElementProps } from '../../../internal/types';
3
- declare type HyperlinkElementProps = CustomRenderElementProps<{
4
- uri?: string;
2
+ import { Element, RenderElementProps } from '../../../internal/types';
3
+ declare type HyperlinkElementProps = {
4
+ element: Element & {
5
+ data: {
6
+ uri?: string;
7
+ target: {
8
+ sys: {
9
+ id: string;
10
+ linkType: 'Entry' | 'Asset';
11
+ type: 'Link';
12
+ };
13
+ };
14
+ };
15
+ };
5
16
  target?: Link;
6
17
  onEntityFetchComplete?: VoidFunction;
7
- }>;
18
+ children: Pick<RenderElementProps, 'children'>;
19
+ };
8
20
  export declare function UrlHyperlink(props: HyperlinkElementProps): JSX.Element;
9
21
  export {};
@@ -1,6 +1,6 @@
1
- import { Span, Location, PlateEditor } from '../../../internal/types';
1
+ import { EditorNodesOptions, PlateEditor } from '../../../internal/types';
2
2
  export declare type MoveListItemsOptions = {
3
3
  increase?: boolean;
4
- at?: Location | Span | undefined;
4
+ at?: EditorNodesOptions['at'];
5
5
  };
6
6
  export declare const moveListItems: (editor: PlateEditor, { increase, at }?: MoveListItemsOptions) => void;
@@ -1,6 +1,3 @@
1
1
  import React, { ComponentProps } from 'react';
2
- declare type WithEntityFetchProps = {
3
- onEntityFetchComplete: VoidFunction;
4
- } & JSX.IntrinsicAttributes;
5
- export declare function withLinkTracking(Component: React.ComponentType<WithEntityFetchProps>): (props: ComponentProps<typeof Component>) => JSX.Element;
6
- export {};
2
+ import { HyperlinkElementProps } from './Hyperlink/components/EntityHyperlink';
3
+ export declare function withLinkTracking(Component: React.ComponentType<HyperlinkElementProps>): (props: ComponentProps<typeof Component>) => JSX.Element;
@@ -15,5 +15,5 @@ export declare const setEditorContent: (editor: PlateEditor, nodes?: Node[] | un
15
15
  * Converts a Contentful rich text document to the corresponding slate editor
16
16
  * value
17
17
  */
18
- export declare const documentToEditorValue: (doc?: Document | undefined) => import("./internal").TextOrCustomElement[];
18
+ export declare const documentToEditorValue: (doc?: Document | undefined) => Node[];
19
19
  export declare const normalizeEditorValue: (value: Value, options?: Omit<CreatePlateEditorOptions, "id" | "editor"> | undefined) => Value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-rich-text",
3
- "version": "3.4.1",
3
+ "version": "3.4.3",
4
4
  "source": "./src/index.tsx",
5
5
  "main": "./dist/index.js",
6
6
  "module": "dist/field-editor-rich-text.esm.js",
@@ -30,7 +30,7 @@
30
30
  "@contentful/f36-icons": "^4.1.1",
31
31
  "@contentful/f36-tokens": "^4.0.0",
32
32
  "@contentful/f36-utils": "^4.19.0",
33
- "@contentful/field-editor-reference": "^5.8.1",
33
+ "@contentful/field-editor-reference": "^5.8.2",
34
34
  "@contentful/field-editor-shared": "^1.1.4",
35
35
  "@contentful/rich-text-plain-text-renderer": "^15.12.1",
36
36
  "@contentful/rich-text-types": "15.14.1",
@@ -74,5 +74,5 @@
74
74
  "@udecode/plate-test-utils": "^3.2.0",
75
75
  "react": ">=16.14.0"
76
76
  },
77
- "gitHead": "5ae95e56c59e3cab8f3a1436827764aa17b20588"
77
+ "gitHead": "0295a2cc6c8b8cc60aea370ad9afb7b6142e9471"
78
78
  }