@tiptap/react 3.0.0-next.3 → 3.0.0-next.5

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/index.d.ts CHANGED
@@ -1,26 +1,11 @@
1
- import { BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu';
2
- import * as React from 'react';
3
- import React__default, { DependencyList, ReactNode, HTMLAttributes, HTMLProps, ForwardedRef, ComponentType as ComponentType$1 } from 'react';
4
- import { EditorOptions, Editor, NodeViewRendererOptions, NodeViewProps, NodeView, NodeViewRenderer } from '@tiptap/core';
1
+ import * as react_jsx_runtime_js from 'react/jsx-runtime.js';
2
+ import { EditorOptions, Editor, MarkViewRendererOptions, MarkView, MarkViewProps, MarkViewRenderer, NodeViewRendererOptions, NodeViewProps, NodeView, NodeViewRenderer } from '@tiptap/core';
5
3
  export * from '@tiptap/core';
6
- import { FloatingMenuPluginProps } from '@tiptap/extension-floating-menu';
4
+ import * as React from 'react';
5
+ import React__default, { DependencyList, ReactNode, HTMLAttributes, HTMLProps, ForwardedRef, ComponentProps, ComponentType as ComponentType$1 } from 'react';
7
6
  import { Node } from '@tiptap/pm/model';
8
7
  import { Decoration, DecorationSource } from '@tiptap/pm/view';
9
8
 
10
- type Optional$1<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
11
- type BubbleMenuProps = Omit<Optional$1<BubbleMenuPluginProps, 'pluginKey'>, 'element' | 'editor'> & {
12
- editor: BubbleMenuPluginProps['editor'] | null;
13
- updateDelay?: number;
14
- resizeDelay?: number;
15
- options?: BubbleMenuPluginProps['options'];
16
- } & React__default.HTMLAttributes<HTMLDivElement>;
17
- declare const BubbleMenu: React__default.ForwardRefExoticComponent<Omit<Optional$1<BubbleMenuPluginProps, "pluginKey">, "editor" | "element"> & {
18
- editor: BubbleMenuPluginProps["editor"] | null;
19
- updateDelay?: number;
20
- resizeDelay?: number;
21
- options?: BubbleMenuPluginProps["options"];
22
- } & React__default.HTMLAttributes<HTMLDivElement> & React__default.RefAttributes<HTMLDivElement>>;
23
-
24
9
  /**
25
10
  * The options for the `useEditor` hook.
26
11
  */
@@ -78,7 +63,7 @@ type EditorProviderProps = {
78
63
  * It allows the editor to be accessible across the entire component tree
79
64
  * with `useCurrentEditor`.
80
65
  */
81
- declare function EditorProvider({ children, slotAfter, slotBefore, editorContainerProps, ...editorOptions }: EditorProviderProps): React__default.JSX.Element | null;
66
+ declare function EditorProvider({ children, slotAfter, slotBefore, editorContainerProps, ...editorOptions }: EditorProviderProps): react_jsx_runtime_js.JSX.Element | null;
82
67
 
83
68
  interface EditorContentProps extends HTMLProps<HTMLDivElement> {
84
69
  editor: Editor | null;
@@ -95,25 +80,14 @@ declare class PureEditorContent extends React__default.Component<EditorContentPr
95
80
  componentDidUpdate(): void;
96
81
  init(): void;
97
82
  componentWillUnmount(): void;
98
- render(): React__default.JSX.Element;
83
+ render(): react_jsx_runtime_js.JSX.Element;
99
84
  }
100
85
  declare const EditorContent: React__default.MemoExoticComponent<React__default.ForwardRefExoticComponent<Omit<EditorContentProps, "ref"> & React__default.RefAttributes<HTMLDivElement>>>;
101
86
 
102
- type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
103
- type FloatingMenuProps = Omit<Optional<FloatingMenuPluginProps, 'pluginKey'>, 'element' | 'editor'> & {
104
- editor: FloatingMenuPluginProps['editor'] | null;
105
- options?: FloatingMenuPluginProps['options'];
106
- } & React__default.HTMLAttributes<HTMLDivElement>;
107
- declare const FloatingMenu: React__default.ForwardRefExoticComponent<Omit<Optional<FloatingMenuPluginProps, "pluginKey">, "editor" | "element"> & {
108
- editor: FloatingMenuPluginProps["editor"] | null;
109
- options?: FloatingMenuPluginProps["options"];
110
- } & React__default.HTMLAttributes<HTMLDivElement> & React__default.RefAttributes<HTMLDivElement>>;
111
-
112
- interface NodeViewContentProps {
113
- [key: string]: any;
114
- as?: React__default.ElementType;
115
- }
116
- declare const NodeViewContent: React__default.FC<NodeViewContentProps>;
87
+ type NodeViewContentProps<T extends keyof React__default.JSX.IntrinsicElements = 'div'> = {
88
+ as?: NoInfer<T>;
89
+ } & ComponentProps<T>;
90
+ declare function NodeViewContent<T extends keyof React__default.JSX.IntrinsicElements = 'div'>({ as: Tag, ...props }: NodeViewContentProps<T>): react_jsx_runtime_js.JSX.Element;
117
91
 
118
92
  interface NodeViewWrapperProps {
119
93
  [key: string]: any;
@@ -158,8 +132,8 @@ type ComponentType<R, P> = React__default.ComponentClass<P> | React__default.Fun
158
132
  * },
159
133
  * as: 'span',
160
134
  * })
161
- */
162
- declare class ReactRenderer<R = unknown, P extends Record<string, any> = {}> {
135
+ */
136
+ declare class ReactRenderer<R = unknown, P extends Record<string, any> = object> {
163
137
  id: string;
164
138
  editor: Editor;
165
139
  component: any;
@@ -170,7 +144,7 @@ declare class ReactRenderer<R = unknown, P extends Record<string, any> = {}> {
170
144
  /**
171
145
  * Immediately creates element and renders the provided React component.
172
146
  */
173
- constructor(component: ComponentType<R, P>, { editor, props, as, className, }: ReactRendererOptions);
147
+ constructor(component: ComponentType<R, P>, { editor, props, as, className }: ReactRendererOptions);
174
148
  /**
175
149
  * Render the React component.
176
150
  */
@@ -189,6 +163,34 @@ declare class ReactRenderer<R = unknown, P extends Record<string, any> = {}> {
189
163
  updateAttributes(attributes: Record<string, string>): void;
190
164
  }
191
165
 
166
+ interface MarkViewContextProps {
167
+ markViewContentRef: (element: HTMLElement | null) => void;
168
+ }
169
+ declare const ReactMarkViewContext: React__default.Context<MarkViewContextProps>;
170
+ type MarkViewContentProps<T extends keyof React__default.JSX.IntrinsicElements = 'span'> = {
171
+ as?: NoInfer<T>;
172
+ } & React__default.ComponentProps<T>;
173
+ declare const MarkViewContent: React__default.FC<MarkViewContentProps>;
174
+ interface ReactMarkViewRendererOptions extends MarkViewRendererOptions {
175
+ /**
176
+ * The tag name of the element wrapping the React component.
177
+ */
178
+ as?: string;
179
+ className?: string;
180
+ attrs?: {
181
+ [key: string]: string;
182
+ };
183
+ }
184
+ declare class ReactMarkView extends MarkView<React__default.ComponentType<MarkViewProps>, ReactMarkViewRendererOptions> {
185
+ renderer: ReactRenderer;
186
+ contentDOMElement: HTMLElement | null;
187
+ didMountContentDomElement: boolean;
188
+ constructor(component: React__default.ComponentType<MarkViewProps>, props: MarkViewProps, options?: Partial<ReactMarkViewRendererOptions>);
189
+ get dom(): HTMLElement;
190
+ get contentDOM(): HTMLElement | null;
191
+ }
192
+ declare function ReactMarkViewRenderer(component: React__default.ComponentType<MarkViewProps>, options?: Partial<ReactMarkViewRendererOptions>): MarkViewRenderer;
193
+
192
194
  interface ReactNodeViewRendererOptions extends NodeViewRendererOptions {
193
195
  /**
194
196
  * This function is called when the node view is updated.
@@ -325,10 +327,19 @@ declare function useEditorState<TSelectorResult>(options: UseEditorStateOptions<
325
327
  declare function useEditorState<TSelectorResult>(options: UseEditorStateOptions<TSelectorResult, Editor | null>): TSelectorResult | null;
326
328
 
327
329
  interface ReactNodeViewContextProps {
328
- onDragStart: (event: DragEvent) => void;
329
- nodeViewContentRef: (element: HTMLElement | null) => void;
330
+ onDragStart?: (event: DragEvent) => void;
331
+ nodeViewContentRef?: (element: HTMLElement | null) => void;
332
+ /**
333
+ * This allows you to add children into the NodeViewContent component.
334
+ * This is useful when statically rendering the content of a node view.
335
+ */
336
+ nodeViewContentChildren?: ReactNode;
330
337
  }
331
- declare const ReactNodeViewContext: React.Context<Partial<ReactNodeViewContextProps>>;
332
- declare const useReactNodeView: () => Partial<ReactNodeViewContextProps>;
338
+ declare const ReactNodeViewContext: React.Context<ReactNodeViewContextProps>;
339
+ declare const ReactNodeViewContentProvider: ({ children, content }: {
340
+ children: ReactNode;
341
+ content: ReactNode;
342
+ }) => React.FunctionComponentElement<React.ProviderProps<ReactNodeViewContextProps>>;
343
+ declare const useReactNodeView: () => ReactNodeViewContextProps;
333
344
 
334
- export { BubbleMenu, type BubbleMenuProps, EditorConsumer, EditorContent, type EditorContentProps, EditorContext, type EditorContextValue, EditorProvider, type EditorProviderProps, type EditorStateSnapshot, FloatingMenu, type FloatingMenuProps, NodeViewContent, type NodeViewContentProps, NodeViewWrapper, type NodeViewWrapperProps, PureEditorContent, ReactNodeView, ReactNodeViewContext, type ReactNodeViewContextProps, ReactNodeViewRenderer, type ReactNodeViewRendererOptions, ReactRenderer, type ReactRendererOptions, type UseEditorOptions, type UseEditorStateOptions, useCurrentEditor, useEditor, useEditorState, useReactNodeView };
345
+ export { EditorConsumer, EditorContent, type EditorContentProps, EditorContext, type EditorContextValue, EditorProvider, type EditorProviderProps, type EditorStateSnapshot, MarkViewContent, type MarkViewContentProps, type MarkViewContextProps, NodeViewContent, type NodeViewContentProps, NodeViewWrapper, type NodeViewWrapperProps, PureEditorContent, ReactMarkView, ReactMarkViewContext, ReactMarkViewRenderer, type ReactMarkViewRendererOptions, ReactNodeView, ReactNodeViewContentProvider, ReactNodeViewContext, type ReactNodeViewContextProps, ReactNodeViewRenderer, type ReactNodeViewRendererOptions, ReactRenderer, type ReactRendererOptions, type UseEditorOptions, type UseEditorStateOptions, useCurrentEditor, useEditor, useEditorState, useReactNodeView };