@junbyeol/tiptap-editor 0.1.3 → 1.0.12
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 +1 -1
- package/dist/index.cjs +71 -164
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +28925 -26754
- package/dist/index.mjs.map +1 -0
- package/dist/style.css +1 -1
- package/dist/types/components/custom/blockquote-popover.d.ts +6 -0
- package/dist/types/components/custom/font-size-dropdown-menu/font-size-dropdown-menu.d.ts +9 -0
- package/dist/types/components/custom/font-size-dropdown-menu/index.d.ts +1 -0
- package/dist/types/components/custom/hr-style-popover.d.ts +6 -0
- package/dist/types/components/custom/image-bubble-menu/image-bubble-menu.d.ts +5 -0
- package/dist/types/components/custom/image-bubble-menu/image-ratio-popover.d.ts +6 -0
- package/dist/types/components/custom/image-bubble-menu/index.d.ts +1 -0
- package/dist/types/components/custom/insert-table-popover.d.ts +6 -0
- package/dist/types/components/custom/list-style-popover.d.ts +6 -0
- package/dist/types/components/custom/table-bubble-menu/index.d.ts +1 -0
- package/dist/types/components/custom/table-bubble-menu/table-bubble-menu.d.ts +5 -0
- package/dist/types/components/custom/table-cell-background-color-popover.d.ts +6 -0
- package/dist/types/components/custom/text-style-dropdown-menu/index.d.ts +4 -0
- package/dist/types/components/custom/text-style-dropdown-menu/text-style-button.d.ts +14 -0
- package/dist/types/components/custom/text-style-dropdown-menu/text-style-dropdown-menu.d.ts +20 -0
- package/dist/types/components/custom/text-style-dropdown-menu/use-text-style-dropdown-menu.d.ts +26 -0
- package/dist/types/components/custom/text-style-dropdown-menu/use-text-style.d.ts +71 -0
- package/dist/types/components/custom/uploadable-dropdown-menu/index.d.ts +2 -0
- package/dist/types/components/custom/uploadable-dropdown-menu/uploadable-button.d.ts +17 -0
- package/dist/types/components/custom/uploadable-dropdown-menu/uploadable-dropdown-menu.d.ts +19 -0
- package/dist/types/components/tiptap-icons/align-center-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/align-justify-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/align-left-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/align-right-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/bold-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/check-icon.d.ts +3 -0
- package/dist/types/components/tiptap-icons/chevron-down-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/code2-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/corner-down-left-icon.d.ts +3 -0
- package/dist/types/components/tiptap-icons/double-quotes-icon.d.ts +3 -0
- package/dist/types/components/tiptap-icons/external-link-icon.d.ts +3 -0
- package/dist/types/components/tiptap-icons/heading-five-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/heading-four-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/heading-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/heading-one-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/heading-six-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/heading-three-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/heading-two-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/image-align-center.d.ts +3 -0
- package/dist/types/components/tiptap-icons/image-align-left.d.ts +3 -0
- package/dist/types/components/tiptap-icons/image-align-right.d.ts +3 -0
- package/dist/types/components/tiptap-icons/image-caption.d.ts +3 -0
- package/dist/types/components/tiptap-icons/image-ratio.d.ts +3 -0
- package/dist/types/components/tiptap-icons/italic-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/link-icon.d.ts +3 -0
- package/dist/types/components/tiptap-icons/list-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/list-ordered-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/list-todo-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/paragraph-icon.d.ts +3 -0
- package/dist/types/components/tiptap-icons/redo2-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/separator-icon.d.ts +3 -0
- package/dist/types/components/tiptap-icons/strike-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/subscript-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/superscript-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/table-icon.d.ts +3 -0
- package/dist/types/components/tiptap-icons/trash-icon.d.ts +3 -0
- package/dist/types/components/tiptap-icons/underline-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/undo2-icon.d.ts +1 -1
- package/dist/types/components/tiptap-icons/uploadable-file-icon.d.ts +3 -0
- package/dist/types/components/tiptap-icons/uploadable-icon.d.ts +3 -0
- package/dist/types/components/tiptap-icons/uploadable-image-icon.d.ts +3 -0
- package/dist/types/components/tiptap-ui/heading-button/heading-button.d.ts +1 -1
- package/dist/types/components/tiptap-ui/heading-button/use-heading.d.ts +7 -7
- package/dist/types/components/tiptap-ui/heading-dropdown-menu/use-heading-dropdown-menu.d.ts +1 -1
- package/dist/types/components/tiptap-ui/link-popover/index.d.ts +2 -0
- package/dist/types/components/tiptap-ui/link-popover/link-popover.d.ts +57 -0
- package/dist/types/components/tiptap-ui/link-popover/use-link-popover.d.ts +117 -0
- package/dist/types/components/tiptap-ui/list-button/list-button.d.ts +1 -1
- package/dist/types/components/tiptap-ui/list-button/use-list.d.ts +4 -4
- package/dist/types/components/tiptap-ui/mark-button/mark-button.d.ts +1 -1
- package/dist/types/components/tiptap-ui/mark-button/use-mark.d.ts +8 -8
- package/dist/types/components/tiptap-ui/text-align-button/text-align-button.d.ts +1 -1
- package/dist/types/components/tiptap-ui/text-align-button/use-text-align.d.ts +5 -5
- package/dist/types/components/tiptap-ui/undo-redo-button/undo-redo-button.d.ts +1 -1
- package/dist/types/components/tiptap-ui/undo-redo-button/use-undo-redo.d.ts +3 -3
- package/dist/types/components/tiptap-ui-primitive/button/button.d.ts +0 -3
- package/dist/types/components/tiptap-ui-primitive/button-group/button-group.d.ts +10 -0
- package/dist/types/components/tiptap-ui-primitive/button-group/index.d.ts +1 -0
- package/dist/types/components/tiptap-ui-primitive/dropdown-menu/dropdown-menu.d.ts +2 -2
- package/dist/types/components/tiptap-ui-primitive/input/index.d.ts +1 -0
- package/dist/types/components/tiptap-ui-primitive/input/input.d.ts +2 -0
- package/dist/types/components/tiptap-ui-primitive/popover/popover.d.ts +3 -3
- package/dist/types/components/tiptap-ui-primitive/separator/separator.d.ts +2 -3
- package/dist/types/components/tiptap-ui-primitive/spacer/spacer.d.ts +1 -1
- package/dist/types/components/tiptap-ui-primitive/tooltip/tooltip.d.ts +1 -1
- package/dist/types/hooks/use-tiptap-editor.d.ts +1 -12
- package/dist/types/lib/index.d.ts +3 -3
- package/dist/types/lib/tiptap-utils.d.ts +6 -1
- package/dist/types/tiptap/contexts/FileHandlerContext.d.ts +7 -0
- package/dist/types/tiptap/extensions/BasicKit.d.ts +2 -0
- package/dist/types/tiptap/extensions/BlockquoteKit.d.ts +2 -0
- package/dist/types/tiptap/extensions/DefaultFileAttachmentComponent.d.ts +2 -0
- package/dist/types/tiptap/extensions/FigcaptionKit.d.ts +2 -0
- package/dist/types/tiptap/extensions/FigureKit.d.ts +16 -0
- package/dist/types/tiptap/extensions/FileAttachment.d.ts +13 -0
- package/dist/types/tiptap/extensions/FontSizeKit.d.ts +10 -0
- package/dist/types/tiptap/extensions/HrKit.d.ts +11 -0
- package/dist/types/tiptap/extensions/ImageKit.d.ts +1 -0
- package/dist/types/tiptap/extensions/Paragraph.d.ts +2 -0
- package/dist/types/tiptap/extensions/index.d.ts +8 -0
- package/dist/types/tiptap/extensions/table/index.d.ts +1 -0
- package/dist/types/tiptap/extensions/table/table-grip-menu.d.ts +13 -0
- package/dist/types/tiptap/extensions/table/table-kit.d.ts +3 -0
- package/dist/types/tiptap/extensions/table/table-row-column-utils.d.ts +16 -0
- package/dist/types/tiptap/extensions/table/table-view.d.ts +52 -0
- package/dist/types/tiptap/hooks/useFileHandler.d.ts +32 -0
- package/dist/types/tiptap/index.d.ts +10 -6
- package/dist/types/tiptap/menubar.d.ts +3 -2
- package/package.json +40 -14
- package/dist/types/tiptap/extensions/default-file-attachment.d.ts +0 -2
- package/dist/types/tiptap/extensions/file-attachment.d.ts +0 -13
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './button-group';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
2
|
-
declare function DropdownMenu({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Root>): import("react
|
|
3
|
-
declare function DropdownMenuPortal({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>): import("react
|
|
2
|
+
declare function DropdownMenu({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Root>): import("react").JSX.Element;
|
|
3
|
+
declare function DropdownMenuPortal({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>): import("react").JSX.Element;
|
|
4
4
|
declare const DropdownMenuTrigger: import('react').ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuTriggerProps & import('react').RefAttributes<HTMLButtonElement>, "ref"> & import('react').RefAttributes<HTMLButtonElement>>;
|
|
5
5
|
declare const DropdownMenuGroup: import('react').ForwardRefExoticComponent<DropdownMenuPrimitive.DropdownMenuGroupProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
6
6
|
declare const DropdownMenuSub: import('react').FC<DropdownMenuPrimitive.DropdownMenuSubProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './input';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
2
|
-
declare function Popover({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Root>): import("react
|
|
3
|
-
declare function PopoverTrigger({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Trigger>): import("react
|
|
4
|
-
declare function PopoverContent({ className, align, sideOffset, ...props }: React.ComponentProps<typeof PopoverPrimitive.Content>): import("react
|
|
2
|
+
declare function Popover({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Root>): import("react").JSX.Element;
|
|
3
|
+
declare function PopoverTrigger({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Trigger>): import("react").JSX.Element;
|
|
4
|
+
declare function PopoverContent({ className, align, sideOffset, ...props }: React.ComponentProps<typeof PopoverPrimitive.Content>): import("react").JSX.Element;
|
|
5
5
|
export { Popover, PopoverTrigger, PopoverContent };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export type Orientation = "horizontal" | "vertical";
|
|
2
|
-
export
|
|
2
|
+
export declare function Separator({ decorative, orientation, className, ...props }: React.ComponentProps<"div"> & {
|
|
3
3
|
orientation?: Orientation;
|
|
4
4
|
decorative?: boolean;
|
|
5
|
-
}
|
|
6
|
-
export declare const Separator: import('react').ForwardRefExoticComponent<SeparatorProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
5
|
+
}): import("react").JSX.Element;
|
|
@@ -3,4 +3,4 @@ export interface SpacerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
3
3
|
orientation?: SpacerOrientation;
|
|
4
4
|
size?: string | number;
|
|
5
5
|
}
|
|
6
|
-
export declare function Spacer({ orientation, size, style, ...props }: SpacerProps): import("react
|
|
6
|
+
export declare function Spacer({ orientation, size, style, ...props }: SpacerProps): import("react").JSX.Element;
|
|
@@ -19,7 +19,7 @@ interface TooltipContentProps extends Omit<React.HTMLProps<HTMLDivElement>, "ref
|
|
|
19
19
|
portal?: boolean;
|
|
20
20
|
portalProps?: Omit<React.ComponentProps<typeof FloatingPortal>, "children">;
|
|
21
21
|
}
|
|
22
|
-
export declare function Tooltip({ children, ...props }: TooltipProviderProps): import("react
|
|
22
|
+
export declare function Tooltip({ children, ...props }: TooltipProviderProps): import("react").JSX.Element;
|
|
23
23
|
export declare namespace Tooltip {
|
|
24
24
|
var displayName: string;
|
|
25
25
|
}
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
import { Editor } from '@tiptap/
|
|
2
|
-
/**
|
|
3
|
-
* Hook that provides access to a Tiptap editor instance.
|
|
4
|
-
*
|
|
5
|
-
* Accepts an optional editor instance directly, or falls back to retrieving
|
|
6
|
-
* the editor from the Tiptap context if available. This allows components
|
|
7
|
-
* to work both when given an editor directly and when used within a Tiptap
|
|
8
|
-
* editor context.
|
|
9
|
-
*
|
|
10
|
-
* @param providedEditor - Optional editor instance to use instead of the context editor
|
|
11
|
-
* @returns The provided editor or the editor from context, whichever is available
|
|
12
|
-
*/
|
|
1
|
+
import { Editor } from '@tiptap/core';
|
|
13
2
|
export declare function useTiptapEditor(providedEditor?: Editor | null): {
|
|
14
3
|
editor: Editor | null;
|
|
15
4
|
editorState?: Editor["state"];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default as TiptapEditor } from '../tiptap/index';
|
|
2
2
|
export type { TiptapProps } from '../tiptap/index';
|
|
3
|
-
export type { FileAttachmentAttributes } from '../tiptap/extensions/
|
|
4
|
-
export {
|
|
5
|
-
export { DefaultFileAttachmentComponent } from '../tiptap/extensions/
|
|
3
|
+
export type { FileAttachmentAttributes } from '../tiptap/extensions/FileAttachment';
|
|
4
|
+
export { FileAttachment, FileAttachmentNode, } from '../tiptap/extensions/FileAttachment';
|
|
5
|
+
export { DefaultFileAttachmentComponent } from '../tiptap/extensions/DefaultFileAttachmentComponent';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Node as PMNode } from '@tiptap/pm/model';
|
|
2
2
|
import { Transaction, Selection } from '@tiptap/pm/state';
|
|
3
|
+
import { ClassValue } from 'clsx';
|
|
3
4
|
import { Editor, NodeWithPos } from '@tiptap/react';
|
|
4
5
|
export declare const MAX_FILE_SIZE: number;
|
|
5
6
|
export declare const MAC_SYMBOLS: Record<string, string>;
|
|
@@ -14,7 +15,7 @@ export declare const SR_ONLY: {
|
|
|
14
15
|
readonly whiteSpace: "nowrap";
|
|
15
16
|
readonly borderWidth: 0;
|
|
16
17
|
};
|
|
17
|
-
export declare function cn(...
|
|
18
|
+
export declare function cn(...inputs: ClassValue[]): string;
|
|
18
19
|
/**
|
|
19
20
|
* Determines if the current platform is macOS
|
|
20
21
|
* @returns boolean indicating if the current platform is Mac
|
|
@@ -164,5 +165,9 @@ export declare function selectCurrentBlockContent(editor: Editor): void;
|
|
|
164
165
|
* @returns An array of objects containing the node and its position
|
|
165
166
|
*/
|
|
166
167
|
export declare function getSelectedNodesOfType(selection: Selection, allowedNodeTypes: string[]): NodeWithPos[];
|
|
168
|
+
/**
|
|
169
|
+
* Clamps a value between min and max bounds
|
|
170
|
+
*/
|
|
171
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
167
172
|
export declare function getSelectedBlockNodes(editor: Editor): PMNode[];
|
|
168
173
|
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useEditor } from '@tiptap/react';
|
|
2
|
+
export interface FileHandlerContextValue {
|
|
3
|
+
resolveFileUrl: (file: File) => Promise<string | null>;
|
|
4
|
+
insertFile: (editor: ReturnType<typeof useEditor>, file: File, url: string, pos: number) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const FileHandlerContext: import('react').Context<FileHandlerContextValue | null>;
|
|
7
|
+
export declare function useFileHandlerContext(): FileHandlerContextValue;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
export type FigureAlign = "left" | "center" | "right";
|
|
3
|
+
declare module "@tiptap/core" {
|
|
4
|
+
interface Commands<ReturnType> {
|
|
5
|
+
figure: {
|
|
6
|
+
insertFigure: (attrs: {
|
|
7
|
+
src: string;
|
|
8
|
+
alt?: string;
|
|
9
|
+
align?: FigureAlign;
|
|
10
|
+
}) => ReturnType;
|
|
11
|
+
setFigureAlign: (align: FigureAlign) => ReturnType;
|
|
12
|
+
toggleFigcaption: () => ReturnType;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export declare const FigureKit: Node<any, any>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Node, Extension } from '@tiptap/core';
|
|
2
|
+
import { ComponentType } from 'react';
|
|
3
|
+
export interface FileAttachmentAttributes {
|
|
4
|
+
name: string;
|
|
5
|
+
mimeType: string;
|
|
6
|
+
url: string;
|
|
7
|
+
size: number;
|
|
8
|
+
}
|
|
9
|
+
export interface FileAttachmentOptions {
|
|
10
|
+
component: ComponentType<FileAttachmentAttributes>;
|
|
11
|
+
}
|
|
12
|
+
export declare const FileAttachmentNode: Node<FileAttachmentOptions, any>;
|
|
13
|
+
export declare const FileAttachment: Extension<FileAttachmentOptions, any>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
declare module "@tiptap/core" {
|
|
3
|
+
interface Commands<ReturnType> {
|
|
4
|
+
fontSize: {
|
|
5
|
+
setFontSize: (size: string) => ReturnType;
|
|
6
|
+
unsetFontSize: () => ReturnType;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export declare const FontSizeKit: Extension<any, any>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type HrStyle = "thin" | "thick" | "dashed" | "short" | "dots" | "diamond" | "circle";
|
|
2
|
+
declare module "@tiptap/core" {
|
|
3
|
+
interface Commands<ReturnType> {
|
|
4
|
+
hr: {
|
|
5
|
+
setHr: (attrs?: {
|
|
6
|
+
style?: HrStyle;
|
|
7
|
+
}) => ReturnType;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export declare const Hr: import('@tiptap/core').Node<import('@tiptap/extension-horizontal-rule').HorizontalRuleOptions, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ImageKit: import('@tiptap/core').Node<import('@tiptap/extension-image').ImageOptions, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './table-kit';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EditorView } from '@tiptap/pm/view';
|
|
2
|
+
import { HoveredTableCell } from './table-row-column-utils';
|
|
3
|
+
export interface TableGripMenuHandle {
|
|
4
|
+
open: () => void;
|
|
5
|
+
}
|
|
6
|
+
export interface TableGripMenuProps {
|
|
7
|
+
view: EditorView;
|
|
8
|
+
target: "row" | "column";
|
|
9
|
+
getHovered: () => HoveredTableCell | null;
|
|
10
|
+
onOpenChange?: (open: boolean) => void;
|
|
11
|
+
onGripMouseDown?: (event: React.MouseEvent) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const TableGripMenu: import('react').ForwardRefExoticComponent<TableGripMenuProps & import('react').RefAttributes<TableGripMenuHandle>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TableMap } from '@tiptap/pm/tables';
|
|
2
|
+
import { Node as ProseMirrorNode } from '@tiptap/pm/model';
|
|
3
|
+
import { EditorView } from '@tiptap/pm/view';
|
|
4
|
+
export interface HoveredTableCell {
|
|
5
|
+
map: TableMap;
|
|
6
|
+
tableStart: number;
|
|
7
|
+
row: number;
|
|
8
|
+
col: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function findHoveredCell(view: EditorView, clientX: number, clientY: number): HoveredTableCell | null;
|
|
11
|
+
export declare function selectTableRow(view: EditorView, { map, tableStart }: HoveredTableCell, row: number): void;
|
|
12
|
+
export declare function selectTableColumn(view: EditorView, { map, tableStart }: HoveredTableCell, col: number): void;
|
|
13
|
+
export declare function moveRow(view: EditorView, { tableStart }: HoveredTableCell, from: number, to: number): void;
|
|
14
|
+
export declare function moveColumn(view: EditorView, { tableStart }: HoveredTableCell, from: number, to: number): void;
|
|
15
|
+
export declare function addTableRow(view: EditorView, table: ProseMirrorNode, contentDOM: HTMLElement): void;
|
|
16
|
+
export declare function addTableColumn(view: EditorView, table: ProseMirrorNode, contentDOM: HTMLElement): void;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { Root } from 'react-dom/client';
|
|
3
|
+
import { TableView } from '@tiptap/pm/tables';
|
|
4
|
+
import { Node as ProseMirrorNode } from '@tiptap/pm/model';
|
|
5
|
+
import { EditorView, ViewMutationRecord } from '@tiptap/pm/view';
|
|
6
|
+
import { TableGripMenuHandle } from './table-grip-menu';
|
|
7
|
+
import { HoveredTableCell } from './table-row-column-utils';
|
|
8
|
+
interface DragState {
|
|
9
|
+
target: "row" | "column";
|
|
10
|
+
startIndex: number;
|
|
11
|
+
targetIndex: number;
|
|
12
|
+
startX: number;
|
|
13
|
+
startY: number;
|
|
14
|
+
hasMoved: boolean;
|
|
15
|
+
hovered: HoveredTableCell;
|
|
16
|
+
}
|
|
17
|
+
export declare class GripTableView extends TableView {
|
|
18
|
+
view: EditorView;
|
|
19
|
+
controls: HTMLDivElement;
|
|
20
|
+
rowHandle: HTMLDivElement;
|
|
21
|
+
columnHandle: HTMLDivElement;
|
|
22
|
+
addRowButton: HTMLButtonElement;
|
|
23
|
+
addColumnButton: HTMLButtonElement;
|
|
24
|
+
dropIndicator: HTMLDivElement;
|
|
25
|
+
rowHandleRoot: Root;
|
|
26
|
+
columnHandleRoot: Root;
|
|
27
|
+
rowMenuRef: RefObject<TableGripMenuHandle | null>;
|
|
28
|
+
columnMenuRef: RefObject<TableGripMenuHandle | null>;
|
|
29
|
+
hovered: HoveredTableCell | null;
|
|
30
|
+
rowMenuOpen: boolean;
|
|
31
|
+
columnMenuOpen: boolean;
|
|
32
|
+
dragState: DragState | null;
|
|
33
|
+
constructor(node: ProseMirrorNode, cellMinWidth: number, view: EditorView);
|
|
34
|
+
private handleMouseOver;
|
|
35
|
+
private handleMouseLeave;
|
|
36
|
+
private handleRowMenuOpenChange;
|
|
37
|
+
private handleColumnMenuOpenChange;
|
|
38
|
+
private handleAddRow;
|
|
39
|
+
private handleAddColumn;
|
|
40
|
+
private startDrag;
|
|
41
|
+
private handleDragMove;
|
|
42
|
+
private handleDragEnd;
|
|
43
|
+
private findClosestRowIndex;
|
|
44
|
+
private findClosestColumnIndex;
|
|
45
|
+
private getColumnBoundaries;
|
|
46
|
+
private updateDropIndicator;
|
|
47
|
+
private positionHandles;
|
|
48
|
+
private cellIndexAtColumn;
|
|
49
|
+
ignoreMutation(record: ViewMutationRecord): boolean;
|
|
50
|
+
destroy(): void;
|
|
51
|
+
}
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useEditor } from '@tiptap/react';
|
|
2
|
+
export interface UseFileHandlerAttributes {
|
|
3
|
+
/**
|
|
4
|
+
* 제공 시: 파일을 CDN에 업로드하고 URL을 반환.
|
|
5
|
+
* 미제공 시: FileReader로 base64 변환 후 브라우저 메모리에 임시 저장.
|
|
6
|
+
*/
|
|
7
|
+
uploadFile?: (file: File) => Promise<string>;
|
|
8
|
+
/**
|
|
9
|
+
* 파일이 업로드될 때 호출되는 콜백.
|
|
10
|
+
*/
|
|
11
|
+
onUploadStart?: (file: File) => void;
|
|
12
|
+
/**
|
|
13
|
+
* 파일 업로드가 성공했을 때 호출되는 콜백.
|
|
14
|
+
*/
|
|
15
|
+
onUploadSuccess?: (file: File) => void;
|
|
16
|
+
/**
|
|
17
|
+
* 파일 업로드가 실패했을 때 호출되는 콜백.
|
|
18
|
+
*/
|
|
19
|
+
onUploadError?: (error: Error, file?: File) => void;
|
|
20
|
+
/**
|
|
21
|
+
* true 시 이미지 외 파일(PDF, Word 등)도 허용.
|
|
22
|
+
* FileAttachmentComponent가 함께 제공되어야 에디터에 렌더링됨.
|
|
23
|
+
*/
|
|
24
|
+
allowNonImageFile?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare const useFileHandler: ({ uploadFile, onUploadStart, onUploadSuccess, onUploadError, allowNonImageFile, }: UseFileHandlerAttributes) => {
|
|
27
|
+
handleDrop: (editor: import('@tiptap/core').Editor, files: File[], pos: number) => void;
|
|
28
|
+
handlePaste: (editor: import('@tiptap/core').Editor, files: File[], pasteContent?: string) => void;
|
|
29
|
+
allowedMimeTypes: string[] | undefined;
|
|
30
|
+
resolveFileUrl: (file: File) => Promise<string | null>;
|
|
31
|
+
insertFile: (currentEditor: ReturnType<typeof useEditor>, file: File, url: string, pos: number) => void;
|
|
32
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
|
-
import { FileAttachmentAttributes } from './extensions
|
|
2
|
+
import { FileAttachmentAttributes } from './extensions';
|
|
3
3
|
export interface TiptapProps {
|
|
4
4
|
/**
|
|
5
5
|
* 에디터의 초기 HTML 콘텐츠.
|
|
@@ -24,13 +24,17 @@ export interface TiptapProps {
|
|
|
24
24
|
*/
|
|
25
25
|
uploadFile?: (file: File) => Promise<string>;
|
|
26
26
|
/**
|
|
27
|
-
* 파일이
|
|
27
|
+
* 파일이 업로드될 때 호출되는 콜백.
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
onUploadStart?: (file: File) => void;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* 파일이 업로드될 때 호출되는 콜백.
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
onUploadSuccess?: (file: File) => void;
|
|
34
|
+
/**
|
|
35
|
+
* 파일이 업로드 오류 시 호출되는 콜백.
|
|
36
|
+
*/
|
|
37
|
+
onUploadError?: (error: Error) => void;
|
|
34
38
|
/**
|
|
35
39
|
* true 시 이미지 외 파일(PDF, Word 등)도 허용.
|
|
36
40
|
* FileAttachmentComponent가 함께 제공되어야 에디터에 렌더링됨.
|
|
@@ -42,5 +46,5 @@ export interface TiptapProps {
|
|
|
42
46
|
*/
|
|
43
47
|
FileAttachmentComponent?: ComponentType<FileAttachmentAttributes>;
|
|
44
48
|
}
|
|
45
|
-
declare const TiptapEditor: ({ defaultValue, onChange, minHeight, maxHeight, uploadFile,
|
|
49
|
+
declare const TiptapEditor: ({ defaultValue, onChange, minHeight, maxHeight, uploadFile, onUploadStart, onUploadSuccess, onUploadError, allowNonImageFile, FileAttachmentComponent, }: TiptapProps) => import("react").JSX.Element;
|
|
46
50
|
export default TiptapEditor;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Editor } from '@tiptap/react';
|
|
2
|
-
export
|
|
2
|
+
export type MenubarMode = "basic" | "expert";
|
|
3
|
+
export default function Menubar({ editor }: {
|
|
3
4
|
editor: Editor;
|
|
4
|
-
}): import("react
|
|
5
|
+
}): import("react").JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@junbyeol/tiptap-editor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"dev": "vite",
|
|
26
26
|
"build": "tsc -b && vite build",
|
|
27
27
|
"build:lib": "vite build --config vite.lib.config.ts",
|
|
28
|
+
"prepublishOnly": "pnpm build:lib",
|
|
28
29
|
"lint": "eslint .",
|
|
29
30
|
"preview": "vite preview",
|
|
30
31
|
"prettier": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,css,md,scss}\"",
|
|
@@ -33,33 +34,58 @@
|
|
|
33
34
|
},
|
|
34
35
|
"peerDependencies": {
|
|
35
36
|
"react": "^19.0.0",
|
|
36
|
-
"react-dom": "^19.0.0"
|
|
37
|
+
"react-dom": "^19.0.0",
|
|
38
|
+
"@tiptap/core": "^3.26.0",
|
|
39
|
+
"@tiptap/pm": "^3.26.0",
|
|
40
|
+
"@tiptap/react": "^3.26.0"
|
|
37
41
|
},
|
|
38
42
|
"dependencies": {
|
|
39
43
|
"@floating-ui/react": "^0.27.19",
|
|
40
44
|
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
|
41
45
|
"@radix-ui/react-popover": "^1.1.15",
|
|
42
46
|
"@remixicon/react": "^4.9.0",
|
|
43
|
-
"@tiptap/extension-
|
|
44
|
-
"@tiptap/extension-
|
|
45
|
-
"@tiptap/extension-
|
|
46
|
-
"@tiptap/extension-
|
|
47
|
-
"@tiptap/extension-
|
|
48
|
-
"@tiptap/extension-
|
|
49
|
-
"@tiptap/extension-
|
|
50
|
-
"@tiptap/extension-
|
|
51
|
-
"@tiptap/extension-
|
|
52
|
-
"@tiptap/
|
|
53
|
-
"@tiptap/
|
|
54
|
-
"@tiptap/
|
|
47
|
+
"@tiptap/extension-blockquote": "^3.26.0",
|
|
48
|
+
"@tiptap/extension-bold": "^3.26.0",
|
|
49
|
+
"@tiptap/extension-bubble-menu": "^3.26.0",
|
|
50
|
+
"@tiptap/extension-code": "^3.26.0",
|
|
51
|
+
"@tiptap/extension-code-block-lowlight": "^3.26.0",
|
|
52
|
+
"@tiptap/extension-details": "^3.26.0",
|
|
53
|
+
"@tiptap/extension-document": "^3.26.0",
|
|
54
|
+
"@tiptap/extension-dropcursor": "^3.26.0",
|
|
55
|
+
"@tiptap/extension-file-handler": "^3.26.0",
|
|
56
|
+
"@tiptap/extension-gapcursor": "^3.26.0",
|
|
57
|
+
"@tiptap/extension-heading": "^3.26.0",
|
|
58
|
+
"@tiptap/extension-highlight": "^3.26.0",
|
|
59
|
+
"@tiptap/extension-horizontal-rule": "^3.26.0",
|
|
60
|
+
"@tiptap/extension-image": "^3.26.0",
|
|
61
|
+
"@tiptap/extension-italic": "^3.26.0",
|
|
62
|
+
"@tiptap/extension-link": "^3.26.0",
|
|
63
|
+
"@tiptap/extension-list": "^3.26.0",
|
|
64
|
+
"@tiptap/extension-paragraph": "^3.26.0",
|
|
65
|
+
"@tiptap/extension-strike": "^3.26.0",
|
|
66
|
+
"@tiptap/extension-subscript": "^3.26.0",
|
|
67
|
+
"@tiptap/extension-superscript": "^3.26.0",
|
|
68
|
+
"@tiptap/extension-table": "^3.26.0",
|
|
69
|
+
"@tiptap/extension-text": "^3.26.0",
|
|
70
|
+
"@tiptap/extension-text-align": "^3.26.0",
|
|
71
|
+
"@tiptap/extension-text-style": "^3.26.0",
|
|
72
|
+
"@tiptap/extension-typography": "^3.26.0",
|
|
73
|
+
"@tiptap/extension-underline": "^3.26.0",
|
|
74
|
+
"@tiptap/extension-youtube": "^3.26.0",
|
|
75
|
+
"@tiptap/extensions": "^3.26.0",
|
|
76
|
+
"@tiptap/starter-kit": "^3.26.0",
|
|
77
|
+
"clsx": "^2.1.1",
|
|
78
|
+
"lowlight": "^3.3.0",
|
|
55
79
|
"react-hotkeys-hook": "^5.2.4"
|
|
56
80
|
},
|
|
57
81
|
"devDependencies": {
|
|
82
|
+
"@base-ui/react": "^1.5.0",
|
|
58
83
|
"@eslint/js": "^9.39.1",
|
|
59
84
|
"@types/node": "^25.3.5",
|
|
60
85
|
"@types/react": "^19.2.7",
|
|
61
86
|
"@types/react-dom": "^19.2.3",
|
|
62
87
|
"@vitejs/plugin-react-swc": "^4.2.2",
|
|
88
|
+
"class-variance-authority": "^0.7.1",
|
|
63
89
|
"eslint": "^9.39.1",
|
|
64
90
|
"eslint-config-prettier": "^10.1.8",
|
|
65
91
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Node } from '@tiptap/core';
|
|
2
|
-
import { ComponentType, RefObject } from 'react';
|
|
3
|
-
export interface FileAttachmentAttributes {
|
|
4
|
-
name: string;
|
|
5
|
-
mimeType: string;
|
|
6
|
-
url: string;
|
|
7
|
-
size: number;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* componentRef를 인자로 받아 FileAttachment Node 확장을 생성하는 팩토리 함수.
|
|
11
|
-
* ref 패턴을 사용하므로 컴포넌트가 동적으로 교체되어도 stale 클로저가 발생하지 않는다.
|
|
12
|
-
*/
|
|
13
|
-
export declare const createFileAttachmentExtension: (componentRef: RefObject<ComponentType<FileAttachmentAttributes> | undefined>) => Node<any, any>;
|