@handlewithcare/react-prosemirror 2.9.0-tiptap.24 → 3.0.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/README.md +140 -75
- package/dist/cjs/StaticEditorView.js +0 -3
- package/dist/cjs/components/ChildNodeViews.js +4 -4
- package/dist/cjs/components/NativeWidgetView.js +2 -2
- package/dist/cjs/components/OutputSpec.js +10 -3
- package/dist/cjs/components/ProseMirror.js +11 -17
- package/dist/cjs/components/SeparatorHackView.js +2 -2
- package/dist/cjs/components/TrailingHackView.js +2 -2
- package/dist/cjs/components/WidgetView.js +2 -2
- package/dist/cjs/components/marks/DefaultMarkView.js +2 -1
- package/dist/cjs/components/marks/MarkView.js +2 -2
- package/dist/cjs/components/marks/{CustomMarkView.js → MarkViewConstructorView.js} +16 -7
- package/dist/cjs/components/marks/ReactMarkView.js +26 -6
- package/dist/cjs/components/nodes/DefaultNodeView.js +3 -2
- package/dist/cjs/components/nodes/DocNodeView.js +7 -6
- package/dist/cjs/components/nodes/NodeView.js +17 -6
- package/dist/cjs/components/nodes/{CustomNodeView.js → NodeViewConstructorView.js} +22 -9
- package/dist/cjs/components/nodes/ReactNodeView.js +59 -17
- package/dist/cjs/contexts/{ChildDescriptorsContext.js → ChildDescriptionsContext.js} +3 -3
- package/dist/cjs/hooks/useEditor.js +0 -4
- package/dist/cjs/hooks/useEditorEventCallback.js +1 -1
- package/dist/cjs/hooks/useMarkViewDescription.js +24 -21
- package/dist/cjs/hooks/useNodePos.js +18 -0
- package/dist/cjs/hooks/{useNodeViewDescriptor.js → useNodeViewDescription.js} +30 -25
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/refs.js +28 -0
- package/dist/cjs/viewdesc.js +18 -5
- package/dist/esm/StaticEditorView.js +0 -3
- package/dist/esm/components/ChildNodeViews.js +4 -4
- package/dist/esm/components/NativeWidgetView.js +2 -2
- package/dist/esm/components/OutputSpec.js +10 -3
- package/dist/esm/components/ProseMirror.js +11 -17
- package/dist/esm/components/SeparatorHackView.js +2 -2
- package/dist/esm/components/TrailingHackView.js +2 -2
- package/dist/esm/components/WidgetView.js +2 -2
- package/dist/esm/components/marks/DefaultMarkView.js +2 -1
- package/dist/esm/components/marks/MarkView.js +2 -2
- package/dist/esm/components/marks/{CustomMarkView.js → MarkViewConstructorView.js} +14 -5
- package/dist/esm/components/marks/ReactMarkView.js +26 -6
- package/dist/esm/components/nodes/DefaultNodeView.js +3 -2
- package/dist/esm/components/nodes/DocNodeView.js +8 -7
- package/dist/esm/components/nodes/NodeView.js +7 -4
- package/dist/esm/components/nodes/{CustomNodeView.js → NodeViewConstructorView.js} +20 -7
- package/dist/esm/components/nodes/ReactNodeView.js +59 -17
- package/dist/esm/contexts/{ChildDescriptorsContext.js → ChildDescriptionsContext.js} +1 -1
- package/dist/esm/hooks/useEditor.js +0 -4
- package/dist/esm/hooks/useEditorEffect.js +0 -4
- package/dist/esm/hooks/useEditorEventCallback.js +6 -4
- package/dist/esm/hooks/useMarkViewDescription.js +26 -23
- package/dist/esm/hooks/useNodePos.js +15 -0
- package/dist/esm/hooks/{useNodeViewDescriptor.js → useNodeViewDescription.js} +29 -24
- package/dist/esm/index.js +2 -0
- package/dist/esm/refs.js +18 -0
- package/dist/esm/viewdesc.js +13 -6
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/AbstractEditorView.d.ts +0 -1
- package/dist/types/StaticEditorView.d.ts +0 -1
- package/dist/types/components/OutputSpec.d.ts +2 -1
- package/dist/types/components/ProseMirror.d.ts +3 -11
- package/dist/types/components/ProseMirrorDoc.d.ts +2 -2
- package/dist/types/components/marks/DefaultMarkView.d.ts +1 -1
- package/dist/types/components/marks/MarkViewComponentProps.d.ts +4 -3
- package/dist/types/components/marks/{CustomMarkView.d.ts → MarkViewConstructorView.d.ts} +1 -1
- package/dist/types/components/nodes/DefaultNodeView.d.ts +1 -1
- package/dist/types/components/nodes/DocNodeView.d.ts +2 -2
- package/dist/types/components/nodes/NodeView.d.ts +1 -0
- package/dist/types/components/nodes/NodeViewComponentProps.d.ts +4 -3
- package/dist/types/components/{CustomNodeView.d.ts → nodes/NodeViewConstructorView.d.ts} +1 -1
- package/dist/types/constants.d.ts +1 -1
- package/dist/types/contexts/{ChildDescriptorsContext.d.ts → ChildDescriptionsContext.d.ts} +1 -1
- package/dist/types/hooks/useEditorEffect.d.ts +0 -4
- package/dist/types/hooks/useEditorEventCallback.d.ts +6 -4
- package/dist/types/hooks/useMarkViewDescription.d.ts +6 -9
- package/dist/types/hooks/useNodePos.d.ts +9 -0
- package/dist/types/hooks/{useNodeViewDescriptor.d.ts → useNodeViewDescription.d.ts} +5 -9
- package/dist/types/index.d.ts +2 -0
- package/dist/types/props.d.ts +26 -26
- package/dist/types/refs.d.ts +2 -0
- package/dist/types/viewdesc.d.ts +4 -0
- package/package.json +12 -20
- package/dist/cjs/components/CustomNodeView.js +0 -132
- package/dist/cjs/components/DefaultNodeView.js +0 -67
- package/dist/cjs/components/DocNodeView.js +0 -96
- package/dist/cjs/components/MarkView.js +0 -119
- package/dist/cjs/components/NodeView.js +0 -86
- package/dist/cjs/components/NodeViewComponentProps.js +0 -4
- package/dist/cjs/components/ReactNodeView.js +0 -174
- package/dist/cjs/components/marks/OldMarkView.js +0 -120
- package/dist/cjs/tiptap/ReactProseMirrorNodeView.js +0 -26
- package/dist/cjs/tiptap/TiptapEditor.js +0 -34
- package/dist/cjs/tiptap/TiptapEditorContent.js +0 -142
- package/dist/cjs/tiptap/TiptapEditorView.js +0 -118
- package/dist/cjs/tiptap/TiptapNodeView.js +0 -26
- package/dist/cjs/tiptap/contexts/TiptapEditorContext.js +0 -12
- package/dist/cjs/tiptap/extensions/ReactProseMirror.js +0 -40
- package/dist/cjs/tiptap/hooks/useIsInReactProseMirror.js +0 -15
- package/dist/cjs/tiptap/hooks/useTiptapEditor.js +0 -43
- package/dist/cjs/tiptap/hooks/useTiptapEditorEffect.js +0 -35
- package/dist/cjs/tiptap/hooks/useTiptapEditorEventCallback.js +0 -35
- package/dist/cjs/tiptap/index.js +0 -48
- package/dist/cjs/tiptap/tiptapNodeView.js +0 -237
- package/dist/esm/components/CustomNodeView.js +0 -81
- package/dist/esm/components/DefaultNodeView.js +0 -16
- package/dist/esm/components/DocNodeView.js +0 -45
- package/dist/esm/components/MarkView.js +0 -68
- package/dist/esm/components/NodeView.js +0 -35
- package/dist/esm/components/NodeViewComponentProps.js +0 -1
- package/dist/esm/components/ReactNodeView.js +0 -123
- package/dist/esm/components/marks/OldMarkView.js +0 -69
- package/dist/esm/tiptap/ReactProseMirrorNodeView.js +0 -22
- package/dist/esm/tiptap/TiptapEditor.js +0 -24
- package/dist/esm/tiptap/TiptapEditorContent.js +0 -91
- package/dist/esm/tiptap/TiptapEditorView.js +0 -69
- package/dist/esm/tiptap/TiptapNodeView.js +0 -22
- package/dist/esm/tiptap/contexts/TiptapEditorContext.js +0 -2
- package/dist/esm/tiptap/extensions/ReactProseMirror.js +0 -30
- package/dist/esm/tiptap/hooks/useIsInReactProseMirror.js +0 -5
- package/dist/esm/tiptap/hooks/useTiptapEditor.js +0 -33
- package/dist/esm/tiptap/hooks/useTiptapEditorEffect.js +0 -42
- package/dist/esm/tiptap/hooks/useTiptapEditorEventCallback.js +0 -35
- package/dist/esm/tiptap/index.js +0 -9
- package/dist/esm/tiptap/tiptapNodeView.js +0 -205
- package/dist/types/components/DefaultNodeView.d.ts +0 -3
- package/dist/types/components/DocNodeView.d.ts +0 -12
- package/dist/types/components/MarkView.d.ts +0 -9
- package/dist/types/components/NodeView.d.ts +0 -11
- package/dist/types/components/NodeViewComponentProps.d.ts +0 -12
- package/dist/types/components/ReactNodeView.d.ts +0 -13
- package/dist/types/components/marks/OldMarkView.d.ts +0 -10
- package/dist/types/components/nodes/CustomNodeView.d.ts +0 -12
- package/dist/types/tiptap/ReactProseMirrorNodeView.d.ts +0 -15
- package/dist/types/tiptap/TiptapEditor.d.ts +0 -6
- package/dist/types/tiptap/TiptapEditorContent.d.ts +0 -19
- package/dist/types/tiptap/TiptapEditorView.d.ts +0 -16
- package/dist/types/tiptap/TiptapNodeView.d.ts +0 -15
- package/dist/types/tiptap/contexts/TiptapEditorContext.d.ts +0 -6
- package/dist/types/tiptap/extensions/ReactProseMirror.d.ts +0 -9
- package/dist/types/tiptap/hooks/useIsInReactProseMirror.d.ts +0 -1
- package/dist/types/tiptap/hooks/useTiptapEditor.d.ts +0 -4
- package/dist/types/tiptap/hooks/useTiptapEditorEffect.d.ts +0 -21
- package/dist/types/tiptap/hooks/useTiptapEditorEventCallback.d.ts +0 -13
- package/dist/types/tiptap/index.d.ts +0 -9
- package/dist/types/tiptap/tiptapNodeView.d.ts +0 -50
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Mark } from "prosemirror-model";
|
|
2
|
-
import React, { ReactNode } from "react";
|
|
3
|
-
type Props = {
|
|
4
|
-
mark: Mark;
|
|
5
|
-
getPos: () => number;
|
|
6
|
-
children: ReactNode;
|
|
7
|
-
inline?: boolean;
|
|
8
|
-
};
|
|
9
|
-
export declare const MarkView: React.MemoExoticComponent<React.ForwardRefExoticComponent<Props & React.RefAttributes<unknown>>>;
|
|
10
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Node } from "prosemirror-model";
|
|
2
|
-
import { Decoration, DecorationSource, NodeViewConstructor } from "prosemirror-view";
|
|
3
|
-
import React from "react";
|
|
4
|
-
interface Props {
|
|
5
|
-
constructor: NodeViewConstructor;
|
|
6
|
-
node: Node;
|
|
7
|
-
getPos: () => number;
|
|
8
|
-
innerDeco: DecorationSource;
|
|
9
|
-
outerDeco: readonly Decoration[];
|
|
10
|
-
}
|
|
11
|
-
export declare const CustomNodeView: React.NamedExoticComponent<Props>;
|
|
12
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Editor, NodeView, NodeViewRendererOptions, NodeViewRendererProps } from "@tiptap/core";
|
|
2
|
-
/**
|
|
3
|
-
* Subclass of Tiptap's NodeView to be used in tiptapNodeView.
|
|
4
|
-
*
|
|
5
|
-
* Allows us to pass in an existing dom and contentODM from React ProseMirror's
|
|
6
|
-
* ViewDesc, so that we can call Tiptap's default stopEvent and ignoreMutation
|
|
7
|
-
* methods
|
|
8
|
-
*/
|
|
9
|
-
export declare class ReactProseMirrorNodeView<Component, NodeEditor extends Editor = Editor, Options extends NodeViewRendererOptions = NodeViewRendererOptions> extends NodeView<Component, NodeEditor, Options> {
|
|
10
|
-
private _dom;
|
|
11
|
-
private _contentDOM;
|
|
12
|
-
constructor(component: Component, props: NodeViewRendererProps, dom: HTMLElement, contentDOM: HTMLElement | null, options?: Partial<Options>);
|
|
13
|
-
get dom(): HTMLElement;
|
|
14
|
-
get contentDOM(): HTMLElement | null;
|
|
15
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Editor } from "@tiptap/core";
|
|
2
|
-
import { ReactRenderer } from "@tiptap/react";
|
|
3
|
-
import React, { ForwardedRef, HTMLProps, ReactPortal } from "react";
|
|
4
|
-
export type ContentComponent = {
|
|
5
|
-
setRenderer(id: string, renderer: ReactRenderer): void;
|
|
6
|
-
removeRenderer(id: string): void;
|
|
7
|
-
subscribe: (callback: () => void) => () => void;
|
|
8
|
-
getSnapshot: () => Record<string, ReactPortal>;
|
|
9
|
-
getServerSnapshot: () => Record<string, ReactPortal>;
|
|
10
|
-
};
|
|
11
|
-
export interface EditorContentProps extends HTMLProps<HTMLDivElement> {
|
|
12
|
-
editor: Editor | null;
|
|
13
|
-
innerRef?: ForwardedRef<HTMLDivElement | null>;
|
|
14
|
-
}
|
|
15
|
-
interface Props extends Omit<HTMLProps<HTMLElement>, "as"> {
|
|
16
|
-
editor: Editor;
|
|
17
|
-
}
|
|
18
|
-
export declare function TiptapEditorContent({ editor: editorProp, ...props }: Props): React.JSX.Element;
|
|
19
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Editor } from "@tiptap/core";
|
|
2
|
-
import React, { ComponentType, ReactNode } from "react";
|
|
3
|
-
import { MarkViewComponentProps } from "../components/marks/MarkViewComponentProps.js";
|
|
4
|
-
import { NodeViewComponentProps } from "../components/nodes/NodeViewComponentProps.js";
|
|
5
|
-
interface Props {
|
|
6
|
-
editor: Editor;
|
|
7
|
-
nodeViews?: Record<string, ComponentType<NodeViewComponentProps>>;
|
|
8
|
-
markViews?: Record<string, ComponentType<MarkViewComponentProps>>;
|
|
9
|
-
children?: ReactNode;
|
|
10
|
-
static?: boolean;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Render a Tiptap-compatible React ProseMirror editor.
|
|
14
|
-
*/
|
|
15
|
-
export declare function TiptapEditorView({ editor, nodeViews, markViews, children, static: isStatic, }: Props): React.JSX.Element;
|
|
16
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Editor, NodeView, NodeViewRendererOptions, NodeViewRendererProps } from "@tiptap/core";
|
|
2
|
-
/**
|
|
3
|
-
* Subclass of Tiptap's NodeView to be used in tiptapNodeView.
|
|
4
|
-
*
|
|
5
|
-
* Allows us to pass in an existing dom and contentODM from React ProseMirror's
|
|
6
|
-
* ViewDesc, so that we can call Tiptap's default stopEvent and ignoreMutation
|
|
7
|
-
* methods
|
|
8
|
-
*/
|
|
9
|
-
export declare class ReactProseMirrorNodeView<Component, NodeEditor extends Editor = Editor, Options extends NodeViewRendererOptions = NodeViewRendererOptions> extends NodeView<Component, NodeEditor, Options> {
|
|
10
|
-
private _dom;
|
|
11
|
-
private _contentDOM;
|
|
12
|
-
constructor(component: Component, props: NodeViewRendererProps, dom: HTMLElement, contentDOM: HTMLElement | null, options?: Partial<Options>);
|
|
13
|
-
get dom(): HTMLElement;
|
|
14
|
-
get contentDOM(): HTMLElement | null;
|
|
15
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Extension } from "@tiptap/core";
|
|
2
|
-
declare module "@tiptap/core" {
|
|
3
|
-
interface Commands<ReturnType> {
|
|
4
|
-
reactProseMirrorCommands: {
|
|
5
|
-
reorderSiblings: (pos: number, order: number[]) => ReturnType;
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export declare const ReactProseMirror: Extension<any, any>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useIsInReactProseMirror(): boolean;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { useEditor } from "@tiptap/react";
|
|
2
|
-
import { DependencyList } from "react";
|
|
3
|
-
export type UseTiptapEditorOptions = Omit<Parameters<typeof useEditor>[0], "element">;
|
|
4
|
-
export declare function useTiptapEditor(options: UseTiptapEditorOptions, deps?: DependencyList): import("@tiptap/core").Editor;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Editor } from "@tiptap/core";
|
|
2
|
-
import { DependencyList } from "react";
|
|
3
|
-
/**
|
|
4
|
-
* Registers a layout effect to run after the EditorView has
|
|
5
|
-
* been updated with the latest EditorState and Decorations.
|
|
6
|
-
*
|
|
7
|
-
* Effects can take a Tiptap Editor instance as an argument.
|
|
8
|
-
* This hook should be used to execute layout effects that
|
|
9
|
-
* depend on the Editor, such as for positioning DOM
|
|
10
|
-
* nodes based on ProseMirror positions.
|
|
11
|
-
*
|
|
12
|
-
* Layout effects registered with this hook still fire
|
|
13
|
-
* synchronously after all DOM mutations, but they do so
|
|
14
|
-
* _after_ the Editor has been updated, even when the
|
|
15
|
-
* Editor lives in an ancestor component.
|
|
16
|
-
*
|
|
17
|
-
* This hook can only be used in a component that is mounted
|
|
18
|
-
* as a child of the TiptapEditorView component, including
|
|
19
|
-
* React node view components.
|
|
20
|
-
*/
|
|
21
|
-
export declare function useTiptapEditorEffect(effect: (editor: Editor) => void | (() => void), dependencies?: DependencyList): void;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Editor } from "@tiptap/core";
|
|
2
|
-
/**
|
|
3
|
-
* Returns a stable function reference to be used as an
|
|
4
|
-
* event handler callback.
|
|
5
|
-
*
|
|
6
|
-
* The callback will be called with the Tiptap Editor instance
|
|
7
|
-
* as its first argument.
|
|
8
|
-
*
|
|
9
|
-
* This hook can only be used in a component that is mounted
|
|
10
|
-
* as a child of the TiptapEditorView component, including
|
|
11
|
-
* React node view components.
|
|
12
|
-
*/
|
|
13
|
-
export declare function useTiptapEditorEventCallback<T extends unknown[], R>(callback: (editor: Editor, ...args: T) => R): (...args: T) => R;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { tiptapNodeView } from "./tiptapNodeView.js";
|
|
2
|
-
export { TiptapEditorView } from "./TiptapEditorView.js";
|
|
3
|
-
export { TiptapEditorContent } from "./TiptapEditorContent.js";
|
|
4
|
-
export { useTiptapEditorEffect } from "./hooks/useTiptapEditorEffect.js";
|
|
5
|
-
export { useIsInReactProseMirror } from "./hooks/useIsInReactProseMirror.js";
|
|
6
|
-
export { useTiptapEditorEventCallback } from "./hooks/useTiptapEditorEventCallback.js";
|
|
7
|
-
export { TiptapEditor } from "./TiptapEditor.js";
|
|
8
|
-
export { type UseTiptapEditorOptions, useTiptapEditor, } from "./hooks/useTiptapEditor.js";
|
|
9
|
-
export { ReactProseMirror } from "./extensions/ReactProseMirror.js";
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { type ReactNodeViewProps } from "@tiptap/react";
|
|
2
|
-
import { type Node as ProseMirrorNode } from "prosemirror-model";
|
|
3
|
-
import { ViewMutationRecord } from "prosemirror-view";
|
|
4
|
-
import React, { type ComponentType, ElementType, Ref } from "react";
|
|
5
|
-
import { NodeViewComponentProps } from "../components/nodes/NodeViewComponentProps.js";
|
|
6
|
-
export interface TiptapNodeViewProps {
|
|
7
|
-
component: ComponentType<Omit<ReactNodeViewProps, "ref"> & {
|
|
8
|
-
ref?: Ref<HTMLElement | null>;
|
|
9
|
-
}>;
|
|
10
|
-
extension: ReactNodeViewProps["extension"];
|
|
11
|
-
className?: string | undefined;
|
|
12
|
-
attrs?: Record<string, string> | ((props: {
|
|
13
|
-
node: ProseMirrorNode;
|
|
14
|
-
HTMLAttributes: Record<string, unknown>;
|
|
15
|
-
}) => Record<string, string>) | undefined;
|
|
16
|
-
as?: ElementType | undefined;
|
|
17
|
-
stopEvent?: ((props: {
|
|
18
|
-
event: Event;
|
|
19
|
-
}) => boolean) | null;
|
|
20
|
-
ignoreMutation?: ((props: {
|
|
21
|
-
mutation: ViewMutationRecord;
|
|
22
|
-
}) => boolean) | null;
|
|
23
|
-
contentDOMElementTag?: ElementType | undefined;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Convert a Tiptap node view component to a React ProseMirror node view component
|
|
27
|
-
*
|
|
28
|
-
* Given a Tiptap-compatible React component and a Tiptap extension, returns
|
|
29
|
-
* a React component that can be passed to React ProseMirror as a custom node view.
|
|
30
|
-
*
|
|
31
|
-
* Example:
|
|
32
|
-
*
|
|
33
|
-
* ```tsx
|
|
34
|
-
* const nodeViews = {
|
|
35
|
-
* codeBlock: nodeView({
|
|
36
|
-
* component: function CodeBlock(nodeViewProps) {
|
|
37
|
-
* return (
|
|
38
|
-
* <AnnotatableNodeViewWrapper {...nodeViewProps}>
|
|
39
|
-
* <pre>
|
|
40
|
-
* <NodeViewContent as="code" />
|
|
41
|
-
* </pre>
|
|
42
|
-
* </AnnotatableNodeViewWrapper>
|
|
43
|
-
* )
|
|
44
|
-
* },
|
|
45
|
-
* extension: CodeBlockExtension,
|
|
46
|
-
* }),
|
|
47
|
-
* }
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
export declare function tiptapNodeView({ component: WrappedComponent, extension, as, className, attrs, contentDOMElementTag: InnerTag, stopEvent, ignoreMutation, }: TiptapNodeViewProps): React.MemoExoticComponent<React.ForwardRefExoticComponent<Omit<NodeViewComponentProps, "ref"> & React.RefAttributes<HTMLElement | null>>>;
|