zs_library 0.6.21 → 0.7.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/dist/components/desktop/config.d.ts +1 -1
- package/dist/components/desktop/context/config/hooks.d.ts +2 -0
- package/dist/components/desktop/context-menu/content.d.ts +1 -2
- package/dist/components/desktop/context-menu/sub-menu-item.d.ts +1 -1
- package/dist/components/desktop/items/item-content.d.ts +9 -0
- package/dist/components/desktop/sortable.d.ts +4 -0
- package/dist/components/desktop/types.d.ts +7 -7
- package/dist/components/index.d.ts +1 -1
- package/dist/components/tiptap-editor/simple/components/tiptap-extension/node-background-extension.d.ts +23 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-icons/arrow-left-icon.d.ts +3 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-icons/blockquote-icon.d.ts +3 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-icons/chevron-down-icon.d.ts +3 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-icons/close-icon.d.ts +3 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-icons/code-block-icon.d.ts +3 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-icons/corner-down-left-icon.d.ts +3 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-icons/external-link-icon.d.ts +3 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-icons/trash-icon.d.ts +3 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-node/horizontal-rule-node/horizontal-rule-node-extension.d.ts +2 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-node/image-node/image-node-extension.d.ts +21 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-node/image-node/image-node.d.ts +3 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-node/image-upload-node/image-upload-node-extension.d.ts +64 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-node/image-upload-node/image-upload-node.d.ts +68 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-node/image-upload-node/index.d.ts +1 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/ai-button/ai-button.d.ts +9 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/ai-button/index.d.ts +2 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/ai-button/use-ai.d.ts +38 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/blockquote-button/blockquote-button.d.ts +22 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/blockquote-button/index.d.ts +2 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/blockquote-button/use-blockquote.d.ts +80 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/code-block-button/code-block-button.d.ts +22 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/code-block-button/index.d.ts +2 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/code-block-button/use-code-block.d.ts +87 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/color-highlight-button/color-highlight-button.d.ts +45 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/color-highlight-button/index.d.ts +2 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/color-highlight-button/use-color-highlight.d.ts +82 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/color-highlight-popover/color-highlight-popover.d.ts +25 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/color-highlight-popover/index.d.ts +1 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/heading-button/heading-button.d.ts +23 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/heading-button/index.d.ts +2 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/heading-button/use-heading.d.ts +108 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/heading-dropdown-menu/heading-dropdown-menu.d.ts +20 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/heading-dropdown-menu/index.d.ts +2 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/heading-dropdown-menu/use-heading-dropdown-menu.d.ts +73 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/image-upload-button/image-upload-button.d.ts +29 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/image-upload-button/index.d.ts +2 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/image-upload-button/use-image-upload.d.ts +84 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/link-popover/index.d.ts +2 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/link-popover/link-popover.d.ts +57 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/link-popover/use-link-popover.d.ts +117 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/list-button/index.d.ts +2 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/list-button/list-button.d.ts +23 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/list-button/use-list.d.ts +97 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/list-dropdown-menu/index.d.ts +1 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/list-dropdown-menu/list-dropdown-menu.d.ts +29 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/list-dropdown-menu/use-list-dropdown-menu.d.ts +94 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/mark-button/index.d.ts +2 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/mark-button/mark-button.d.ts +23 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/mark-button/use-mark.d.ts +104 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/text-align-button/index.d.ts +2 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/text-align-button/text-align-button.d.ts +30 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/text-align-button/use-text-align.d.ts +101 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/undo-redo-button/index.d.ts +2 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/undo-redo-button/undo-redo-button.d.ts +23 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui/undo-redo-button/use-undo-redo.d.ts +90 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui-primitive/badge/badge.d.ts +8 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui-primitive/badge/index.d.ts +1 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui-primitive/button/button.d.ts +14 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui-primitive/button/index.d.ts +1 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui-primitive/card/card.d.ts +9 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui-primitive/card/index.d.ts +1 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui-primitive/dropdown-menu/dropdown-menu.d.ts +16 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui-primitive/dropdown-menu/index.d.ts +1 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui-primitive/input/index.d.ts +1 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui-primitive/input/input.d.ts +3 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui-primitive/popover/index.d.ts +1 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui-primitive/popover/popover.d.ts +6 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui-primitive/separator/index.d.ts +1 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui-primitive/separator/separator.d.ts +6 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui-primitive/spacer/index.d.ts +1 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui-primitive/spacer/spacer.d.ts +6 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui-primitive/toolbar/index.d.ts +1 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui-primitive/toolbar/toolbar.d.ts +8 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui-primitive/tooltip/index.d.ts +1 -0
- package/dist/components/tiptap-editor/simple/components/tiptap-ui-primitive/tooltip/tooltip.d.ts +28 -0
- package/dist/components/tiptap-editor/simple/hooks/use-composed-ref.d.ts +3 -0
- package/dist/components/tiptap-editor/simple/hooks/use-cursor-visibility.d.ts +20 -0
- package/dist/components/tiptap-editor/simple/hooks/use-element-rect.d.ts +35 -0
- package/dist/components/tiptap-editor/simple/hooks/use-is-breakpoint.d.ts +9 -0
- package/dist/components/tiptap-editor/simple/hooks/use-menu-navigation.d.ts +52 -0
- package/dist/components/tiptap-editor/simple/hooks/use-scrolling.d.ts +8 -0
- package/dist/components/tiptap-editor/simple/hooks/use-throttled-callback.d.ts +18 -0
- package/dist/components/tiptap-editor/simple/hooks/use-tiptap-editor.d.ts +17 -0
- package/dist/components/tiptap-editor/simple/hooks/use-unmount.d.ts +7 -0
- package/dist/components/tiptap-editor/simple/hooks/use-window-size.d.ts +35 -0
- package/dist/components/tiptap-editor/simple/i18n/en-US.json.d.ts +107 -0
- package/dist/components/tiptap-editor/simple/i18n/zh-CN.json.d.ts +107 -0
- package/dist/components/tiptap-editor/simple/index.d.ts +28 -0
- package/dist/components/tiptap-editor/simple/lib/ai-service.d.ts +15 -0
- package/dist/components/tiptap-editor/simple/lib/feature-utils.d.ts +124 -0
- package/dist/components/tiptap-editor/simple/lib/image-upload-handler.d.ts +44 -0
- package/dist/components/tiptap-editor/simple/lib/tiptap-utils.d.ts +167 -0
- package/dist/components/tiptap-editor/simple/simple-editor.d.ts +10 -0
- package/dist/components/tiptap-editor/simple/theme-toggle.d.ts +1 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7688 -4797
- package/package.json +20 -6
- package/dist/components/editor/editor.d.ts +0 -3
- package/dist/components/editor/extensions/drag-handle/clipboard-serializer.d.ts +0 -3
- package/dist/components/editor/extensions/drag-handle/index.d.ts +0 -26
- package/dist/components/editor/generative/ai-completion-command.d.ts +0 -5
- package/dist/components/editor/generative/ai-selector-commands.d.ts +0 -5
- package/dist/components/editor/generative/ai-selector.d.ts +0 -8
- package/dist/components/editor/generative/drag-handle.d.ts +0 -2
- package/dist/components/editor/generative/generative-dropdown-menu.d.ts +0 -4
- package/dist/components/editor/generative/generative-menu-switch.d.ts +0 -11
- package/dist/components/editor/image-upload.d.ts +0 -1
- package/dist/components/editor/index.d.ts +0 -13
- package/dist/components/editor/lib/colors.d.ts +0 -6
- package/dist/components/editor/lib/content.d.ts +0 -4
- package/dist/components/editor/lib/nodes.d.ts +0 -9
- package/dist/components/editor/lib/url-utils.d.ts +0 -2
- package/dist/components/editor/preview.d.ts +0 -7
- package/dist/components/editor/selectors/color-selector.d.ts +0 -6
- package/dist/components/editor/selectors/link-selector.d.ts +0 -6
- package/dist/components/editor/selectors/math-selector.d.ts +0 -1
- package/dist/components/editor/selectors/node-selector.d.ts +0 -6
- package/dist/components/editor/selectors/text-buttons.d.ts +0 -1
- package/dist/components/editor/slash-command.d.ts +0 -8
- package/dist/components/editor/type.d.ts +0 -90
- package/dist/components/editor/ui/button.d.ts +0 -13
- package/dist/components/editor/ui/command.d.ts +0 -81
- package/dist/components/editor/ui/dialog.d.ts +0 -19
- package/dist/components/editor/ui/dropdown-menu.d.ts +0 -17
- package/dist/components/editor/ui/icons/crazy-spinner.d.ts +0 -2
- package/dist/components/editor/ui/icons/font-default.d.ts +0 -3
- package/dist/components/editor/ui/icons/font-mono.d.ts +0 -3
- package/dist/components/editor/ui/icons/font-serif.d.ts +0 -3
- package/dist/components/editor/ui/icons/index.d.ts +0 -3
- package/dist/components/editor/ui/icons/loading-circle.d.ts +0 -3
- package/dist/components/editor/ui/menu.d.ts +0 -1
- package/dist/components/editor/ui/popover.d.ts +0 -6
- package/dist/components/editor/ui/scroll-area.d.ts +0 -5
- package/dist/components/editor/ui/separator.d.ts +0 -4
- package/dist/components/editor/ui/tooltip.d.ts +0 -3
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Level } from '../components/tiptap-ui/heading-button';
|
|
2
|
+
import { ListType } from '../components/tiptap-ui/list-button';
|
|
3
|
+
import { HighlightColor } from '../components/tiptap-ui/color-highlight-button';
|
|
4
|
+
import { ImageUploadProps } from './image-upload-handler';
|
|
5
|
+
import { AiCompletionOptions } from './ai-service';
|
|
6
|
+
export interface FeatureConfig<T = unknown> {
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
configure?: T;
|
|
9
|
+
}
|
|
10
|
+
export interface BaseButtonConfig {
|
|
11
|
+
text?: string;
|
|
12
|
+
showShortcut?: boolean;
|
|
13
|
+
hideWhenUnavailable?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface HeadingConfig extends BaseButtonConfig {
|
|
16
|
+
levels?: Level[];
|
|
17
|
+
}
|
|
18
|
+
export interface ListConfig extends BaseButtonConfig {
|
|
19
|
+
types?: ListType[];
|
|
20
|
+
}
|
|
21
|
+
export interface HighlightConfig extends BaseButtonConfig {
|
|
22
|
+
multicolor?: boolean;
|
|
23
|
+
colors?: HighlightColor[];
|
|
24
|
+
}
|
|
25
|
+
export interface LinkConfig extends BaseButtonConfig {
|
|
26
|
+
openOnClick?: boolean;
|
|
27
|
+
enableClickSelection?: boolean;
|
|
28
|
+
autoOpenOnLinkActive?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface TextAlignConfig extends BaseButtonConfig {
|
|
31
|
+
types?: string[];
|
|
32
|
+
alignments?: string[];
|
|
33
|
+
defaultAlignment?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ImageConfig extends BaseButtonConfig, ImageUploadProps {
|
|
36
|
+
}
|
|
37
|
+
export interface AiPreset {
|
|
38
|
+
label: string;
|
|
39
|
+
text: string;
|
|
40
|
+
icon?: React.ReactNode;
|
|
41
|
+
}
|
|
42
|
+
export interface AiConfig extends BaseButtonConfig {
|
|
43
|
+
defaultPrompt?: string;
|
|
44
|
+
defaultModel?: string;
|
|
45
|
+
systemPrompt?: string;
|
|
46
|
+
presets?: AiPreset[];
|
|
47
|
+
/**
|
|
48
|
+
* The API Key for the AI service (e.g., DeepSeek, OpenAI).
|
|
49
|
+
*/
|
|
50
|
+
apiKey?: string;
|
|
51
|
+
/**
|
|
52
|
+
* The Base URL for the AI service API.
|
|
53
|
+
* Default: "https://api.deepseek.com"
|
|
54
|
+
*/
|
|
55
|
+
baseUrl?: string;
|
|
56
|
+
/**
|
|
57
|
+
* The model to use for completion.
|
|
58
|
+
* Default: "deepseek-chat"
|
|
59
|
+
*/
|
|
60
|
+
model?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Custom request headers
|
|
63
|
+
*/
|
|
64
|
+
headers?: Record<string, string>;
|
|
65
|
+
/**
|
|
66
|
+
* Custom query parameters to append to the URL
|
|
67
|
+
*/
|
|
68
|
+
params?: Record<string, string>;
|
|
69
|
+
/**
|
|
70
|
+
* Additional body parameters to merge with the request body
|
|
71
|
+
*/
|
|
72
|
+
body?: Record<string, unknown>;
|
|
73
|
+
/**
|
|
74
|
+
* Custom request function to completely override the default behavior.
|
|
75
|
+
* If provided, it should handle the API call and return the generated text.
|
|
76
|
+
* For streaming, it should call `onUpdate` with the accumulating text.
|
|
77
|
+
*/
|
|
78
|
+
request?: (options: AiCompletionOptions) => Promise<string>;
|
|
79
|
+
/**
|
|
80
|
+
* Custom function to transform the response.
|
|
81
|
+
* Useful if using a custom `request` or if the API returns a different format.
|
|
82
|
+
* Not used if `request` is provided and handles everything, but can be used
|
|
83
|
+
* if `request` returns a raw object that needs parsing.
|
|
84
|
+
*
|
|
85
|
+
* Actually, for the default implementation, we parse OpenAI-compatible stream.
|
|
86
|
+
* If the user wants to transform the final result or chunks, this might be tricky with streaming.
|
|
87
|
+
* Let's stick to `request` override for full control.
|
|
88
|
+
* But maybe `transformResponse` is for the final string?
|
|
89
|
+
*/
|
|
90
|
+
/**
|
|
91
|
+
* Callback when the AI generation starts.
|
|
92
|
+
*/
|
|
93
|
+
onStart?: () => void;
|
|
94
|
+
/**
|
|
95
|
+
* Callback when the AI generation is successful.
|
|
96
|
+
*/
|
|
97
|
+
onSuccess?: (content: string) => void;
|
|
98
|
+
/**
|
|
99
|
+
* Callback when the AI generation fails.
|
|
100
|
+
*/
|
|
101
|
+
onError?: (error: Error) => void;
|
|
102
|
+
}
|
|
103
|
+
export interface SimpleEditorFeatures {
|
|
104
|
+
undoRedo?: boolean | FeatureConfig<BaseButtonConfig>;
|
|
105
|
+
heading?: boolean | FeatureConfig<HeadingConfig>;
|
|
106
|
+
list?: boolean | FeatureConfig<ListConfig>;
|
|
107
|
+
blockquote?: boolean | FeatureConfig<BaseButtonConfig>;
|
|
108
|
+
codeBlock?: boolean | FeatureConfig<BaseButtonConfig>;
|
|
109
|
+
bold?: boolean | FeatureConfig<BaseButtonConfig>;
|
|
110
|
+
italic?: boolean | FeatureConfig<BaseButtonConfig>;
|
|
111
|
+
strike?: boolean | FeatureConfig<BaseButtonConfig>;
|
|
112
|
+
code?: boolean | FeatureConfig<BaseButtonConfig>;
|
|
113
|
+
underline?: boolean | FeatureConfig<BaseButtonConfig>;
|
|
114
|
+
highlight?: boolean | FeatureConfig<HighlightConfig>;
|
|
115
|
+
link?: boolean | FeatureConfig<LinkConfig>;
|
|
116
|
+
subscript?: boolean | FeatureConfig<BaseButtonConfig>;
|
|
117
|
+
superscript?: boolean | FeatureConfig<BaseButtonConfig>;
|
|
118
|
+
textAlign?: boolean | FeatureConfig<TextAlignConfig>;
|
|
119
|
+
image?: boolean | FeatureConfig<ImageConfig>;
|
|
120
|
+
themeToggle?: boolean;
|
|
121
|
+
ai?: boolean | FeatureConfig<AiConfig>;
|
|
122
|
+
}
|
|
123
|
+
export declare const isEnabled: (config: boolean | FeatureConfig | undefined, defaultValue?: boolean) => boolean;
|
|
124
|
+
export declare const getConfig: <T>(config: boolean | FeatureConfig<T> | undefined) => T | undefined;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export type RequestMethod = "POST" | "PUT" | "PATCH" | "post" | "put" | "patch";
|
|
2
|
+
export interface UploadRequestOption {
|
|
3
|
+
action: string;
|
|
4
|
+
file: File;
|
|
5
|
+
headers?: Record<string, string>;
|
|
6
|
+
onError: (error: Error) => void;
|
|
7
|
+
onProgress: (event: {
|
|
8
|
+
percent: number;
|
|
9
|
+
}) => void;
|
|
10
|
+
onSuccess: (body: unknown) => void;
|
|
11
|
+
withCredentials?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface ImageUploadProps {
|
|
14
|
+
/** Upload URL */
|
|
15
|
+
action?: string | ((file: File) => Promise<string>);
|
|
16
|
+
/** HTTP method */
|
|
17
|
+
method?: RequestMethod;
|
|
18
|
+
/** Request headers */
|
|
19
|
+
headers?: Record<string, string> | ((file: File) => Record<string, string> | Promise<Record<string, string>>);
|
|
20
|
+
/** File parameter name */
|
|
21
|
+
name?: string;
|
|
22
|
+
/** Extra parameters */
|
|
23
|
+
data?: Record<string, unknown> | ((file: File) => Record<string, unknown> | Promise<Record<string, unknown>>);
|
|
24
|
+
/** Send cookies */
|
|
25
|
+
withCredentials?: boolean;
|
|
26
|
+
/** Format response to image url */
|
|
27
|
+
formatResult?: (response: unknown) => string;
|
|
28
|
+
/** Custom request implementation */
|
|
29
|
+
customRequest?: (options: UploadRequestOption) => void;
|
|
30
|
+
}
|
|
31
|
+
interface UploadHandlerParams {
|
|
32
|
+
file: File;
|
|
33
|
+
onProgress?: (event: {
|
|
34
|
+
progress: number;
|
|
35
|
+
}) => void;
|
|
36
|
+
imageProps?: ImageUploadProps;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Handles image upload logic based on provided props.
|
|
40
|
+
* Defaults to fetch for network requests if action is provided.
|
|
41
|
+
* Falls back to mock upload if no action or customRequest is provided.
|
|
42
|
+
*/
|
|
43
|
+
export declare const handleImageUploadRequest: ({ file, onProgress, imageProps, }: UploadHandlerParams) => Promise<string>;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { Node as PMNode } from '@tiptap/pm/model';
|
|
2
|
+
import { Transaction, Selection } from '@tiptap/pm/state';
|
|
3
|
+
import { Editor, NodeWithPos } from '@tiptap/react';
|
|
4
|
+
export declare const MAX_FILE_SIZE: number;
|
|
5
|
+
export declare const MAC_SYMBOLS: Record<string, string>;
|
|
6
|
+
export declare const SR_ONLY: {
|
|
7
|
+
readonly position: "absolute";
|
|
8
|
+
readonly width: "1px";
|
|
9
|
+
readonly height: "1px";
|
|
10
|
+
readonly padding: 0;
|
|
11
|
+
readonly margin: "-1px";
|
|
12
|
+
readonly overflow: "hidden";
|
|
13
|
+
readonly clip: "rect(0, 0, 0, 0)";
|
|
14
|
+
readonly whiteSpace: "nowrap";
|
|
15
|
+
readonly borderWidth: 0;
|
|
16
|
+
};
|
|
17
|
+
export declare function cn(...classes: (string | boolean | undefined | null)[]): string;
|
|
18
|
+
/**
|
|
19
|
+
* Determines if the current platform is macOS
|
|
20
|
+
* @returns boolean indicating if the current platform is Mac
|
|
21
|
+
*/
|
|
22
|
+
export declare function isMac(): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Formats a shortcut key based on the platform (Mac or non-Mac)
|
|
25
|
+
* @param key - The key to format (e.g., "ctrl", "alt", "shift")
|
|
26
|
+
* @param isMac - Boolean indicating if the platform is Mac
|
|
27
|
+
* @param capitalize - Whether to capitalize the key (default: true)
|
|
28
|
+
* @returns Formatted shortcut key symbol
|
|
29
|
+
*/
|
|
30
|
+
export declare const formatShortcutKey: (key: string, isMac: boolean, capitalize?: boolean) => string;
|
|
31
|
+
/**
|
|
32
|
+
* Parses a shortcut key string into an array of formatted key symbols
|
|
33
|
+
* @param shortcutKeys - The string of shortcut keys (e.g., "ctrl-alt-shift")
|
|
34
|
+
* @param delimiter - The delimiter used to split the keys (default: "-")
|
|
35
|
+
* @param capitalize - Whether to capitalize the keys (default: true)
|
|
36
|
+
* @returns Array of formatted shortcut key symbols
|
|
37
|
+
*/
|
|
38
|
+
export declare const parseShortcutKeys: (props: {
|
|
39
|
+
shortcutKeys: string | undefined;
|
|
40
|
+
delimiter?: string;
|
|
41
|
+
capitalize?: boolean;
|
|
42
|
+
}) => string[];
|
|
43
|
+
/**
|
|
44
|
+
* Checks if a mark exists in the editor schema
|
|
45
|
+
* @param markName - The name of the mark to check
|
|
46
|
+
* @param editor - The editor instance
|
|
47
|
+
* @returns boolean indicating if the mark exists in the schema
|
|
48
|
+
*/
|
|
49
|
+
export declare const isMarkInSchema: (markName: string, editor: Editor | null) => boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Checks if a node exists in the editor schema
|
|
52
|
+
* @param nodeName - The name of the node to check
|
|
53
|
+
* @param editor - The editor instance
|
|
54
|
+
* @returns boolean indicating if the node exists in the schema
|
|
55
|
+
*/
|
|
56
|
+
export declare const isNodeInSchema: (nodeName: string, editor: Editor | null) => boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Moves the focus to the next node in the editor
|
|
59
|
+
* @param editor - The editor instance
|
|
60
|
+
* @returns boolean indicating if the focus was moved
|
|
61
|
+
*/
|
|
62
|
+
export declare function focusNextNode(editor: Editor): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Checks if a value is a valid number (not null, undefined, or NaN)
|
|
65
|
+
* @param value - The value to check
|
|
66
|
+
* @returns boolean indicating if the value is a valid number
|
|
67
|
+
*/
|
|
68
|
+
export declare function isValidPosition(pos: number | null | undefined): pos is number;
|
|
69
|
+
/**
|
|
70
|
+
* Checks if one or more extensions are registered in the Tiptap editor.
|
|
71
|
+
* @param editor - The Tiptap editor instance
|
|
72
|
+
* @param extensionNames - A single extension name or an array of names to check
|
|
73
|
+
* @returns True if at least one of the extensions is available, false otherwise
|
|
74
|
+
*/
|
|
75
|
+
export declare function isExtensionAvailable(editor: Editor | null, extensionNames: string | string[]): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Finds a node at the specified position with error handling
|
|
78
|
+
* @param editor The Tiptap editor instance
|
|
79
|
+
* @param position The position in the document to find the node
|
|
80
|
+
* @returns The node at the specified position, or null if not found
|
|
81
|
+
*/
|
|
82
|
+
export declare function findNodeAtPosition(editor: Editor, position: number): PMNode | null;
|
|
83
|
+
/**
|
|
84
|
+
* Finds the position and instance of a node in the document
|
|
85
|
+
* @param props Object containing editor, node (optional), and nodePos (optional)
|
|
86
|
+
* @param props.editor The Tiptap editor instance
|
|
87
|
+
* @param props.node The node to find (optional if nodePos is provided)
|
|
88
|
+
* @param props.nodePos The position of the node to find (optional if node is provided)
|
|
89
|
+
* @returns An object with the position and node, or null if not found
|
|
90
|
+
*/
|
|
91
|
+
export declare function findNodePosition(props: {
|
|
92
|
+
editor: Editor | null;
|
|
93
|
+
node?: PMNode | null;
|
|
94
|
+
nodePos?: number | null;
|
|
95
|
+
}): {
|
|
96
|
+
pos: number;
|
|
97
|
+
node: PMNode;
|
|
98
|
+
} | null;
|
|
99
|
+
/**
|
|
100
|
+
* Determines whether the current selection contains a node whose type matches
|
|
101
|
+
* any of the provided node type names.
|
|
102
|
+
* @param editor Tiptap editor instance
|
|
103
|
+
* @param nodeTypeNames List of node type names to match against
|
|
104
|
+
* @param checkAncestorNodes Whether to check ancestor node types up the depth chain
|
|
105
|
+
*/
|
|
106
|
+
export declare function isNodeTypeSelected(editor: Editor | null, nodeTypeNames?: string[], checkAncestorNodes?: boolean): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Check whether the current selection is fully within nodes
|
|
109
|
+
* whose type names are in the provided `types` list.
|
|
110
|
+
*
|
|
111
|
+
* - NodeSelection → checks the selected node.
|
|
112
|
+
* - Text/AllSelection → ensures all textblocks within [from, to) are allowed.
|
|
113
|
+
*/
|
|
114
|
+
export declare function selectionWithinConvertibleTypes(editor: Editor, types?: string[]): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Handles image upload with progress tracking and abort capability
|
|
117
|
+
* @param file The file to upload
|
|
118
|
+
* @param onProgress Optional callback for tracking upload progress
|
|
119
|
+
* @param abortSignal Optional AbortSignal for cancelling the upload
|
|
120
|
+
* @returns Promise resolving to the URL of the uploaded image
|
|
121
|
+
*/
|
|
122
|
+
export declare const handleImageUpload: (file: File, onProgress?: (event: {
|
|
123
|
+
progress: number;
|
|
124
|
+
}) => void, abortSignal?: AbortSignal) => Promise<string>;
|
|
125
|
+
type ProtocolOptions = {
|
|
126
|
+
/**
|
|
127
|
+
* The protocol scheme to be registered.
|
|
128
|
+
* @default '''
|
|
129
|
+
* @example 'ftp'
|
|
130
|
+
* @example 'git'
|
|
131
|
+
*/
|
|
132
|
+
scheme: string;
|
|
133
|
+
/**
|
|
134
|
+
* If enabled, it allows optional slashes after the protocol.
|
|
135
|
+
* @default false
|
|
136
|
+
* @example true
|
|
137
|
+
*/
|
|
138
|
+
optionalSlashes?: boolean;
|
|
139
|
+
};
|
|
140
|
+
type ProtocolConfig = Array<ProtocolOptions | string>;
|
|
141
|
+
export declare function isAllowedUri(uri: string | undefined, protocols?: ProtocolConfig): true | RegExpMatchArray | null;
|
|
142
|
+
export declare function sanitizeUrl(inputUrl: string, baseUrl: string, protocols?: ProtocolConfig): string;
|
|
143
|
+
/**
|
|
144
|
+
* Update a single attribute on multiple nodes.
|
|
145
|
+
*
|
|
146
|
+
* @param tr - The transaction to mutate
|
|
147
|
+
* @param targets - Array of { node, pos }
|
|
148
|
+
* @param attrName - Attribute key to update
|
|
149
|
+
* @param next - New value OR updater function receiving previous value
|
|
150
|
+
* Pass `undefined` to remove the attribute.
|
|
151
|
+
* @returns true if at least one node was updated, false otherwise
|
|
152
|
+
*/
|
|
153
|
+
export declare function updateNodesAttr<A extends string = string, V = unknown>(tr: Transaction, targets: readonly NodeWithPos[], attrName: A, next: V | ((prev: V | undefined) => V | undefined)): boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Selects the entire content of the current block node if the selection is empty.
|
|
156
|
+
* If the selection is not empty, it does nothing.
|
|
157
|
+
* @param editor The Tiptap editor instance
|
|
158
|
+
*/
|
|
159
|
+
export declare function selectCurrentBlockContent(editor: Editor): void;
|
|
160
|
+
/**
|
|
161
|
+
* Retrieves all nodes of specified types from the current selection.
|
|
162
|
+
* @param selection The current editor selection
|
|
163
|
+
* @param allowedNodeTypes An array of node type names to look for (e.g., ["image", "table"])
|
|
164
|
+
* @returns An array of objects containing the node and its position
|
|
165
|
+
*/
|
|
166
|
+
export declare function getSelectedNodesOfType(selection: Selection, allowedNodeTypes: string[]): NodeWithPos[];
|
|
167
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JSONContent } from '@tiptap/react';
|
|
2
|
+
import { SimpleEditorFeatures } from './lib/feature-utils';
|
|
3
|
+
export interface SimpleEditorProps {
|
|
4
|
+
value?: string | JSONContent;
|
|
5
|
+
onChange?: (value: string) => void;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
features?: SimpleEditorFeatures;
|
|
9
|
+
}
|
|
10
|
+
export declare function SimpleEditor({ value, onChange, className, style, features }: SimpleEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ThemeToggle(): import("react/jsx-runtime").JSX.Element;
|