@firecms/editor 3.0.0-canary.99 → 3.0.0-rc.2

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,7 +1,10 @@
1
- import { type BubbleMenuProps } from "@tiptap/react";
2
1
  import { type ReactNode } from "react";
2
+ import { type BubbleMenuProps } from "@tiptap/react/menus";
3
3
  export interface EditorBubbleProps extends Omit<BubbleMenuProps, "editor"> {
4
4
  children: ReactNode;
5
+ tippyOptions?: {
6
+ placement?: any;
7
+ };
5
8
  }
6
- export declare const EditorBubble: import("react").ForwardRefExoticComponent<EditorBubbleProps & import("react").RefAttributes<HTMLDivElement>>;
9
+ export declare const EditorBubble: import("react").ForwardRefExoticComponent<Omit<EditorBubbleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
7
10
  export default EditorBubble;
@@ -1,8 +1,5 @@
1
1
  export { useCurrentEditor as useEditor } from "@tiptap/react";
2
2
  export { type Editor } from "@tiptap/core";
3
3
  export type { JSONContent } from "@tiptap/react";
4
- export { EditorRoot } from "./editor";
5
4
  export { EditorBubble } from "./editor-bubble";
6
5
  export { EditorBubbleItem } from "./editor-bubble-item";
7
- export { EditorCommand } from "./editor-command";
8
- export { EditorCommandItem, EditorCommandEmpty } from "./editor-command-item";
package/dist/editor.d.ts CHANGED
@@ -1,9 +1,25 @@
1
+ import React from "react";
1
2
  import { type JSONContent } from "./components";
3
+ import { EditorAIController } from "./types";
4
+ export type FireCMSEditorTextSize = "sm" | "base" | "lg";
2
5
  export type FireCMSEditorProps = {
3
- initialContent?: JSONContent | string;
6
+ content?: JSONContent | string;
4
7
  onMarkdownContentChange?: (content: string) => void;
5
8
  onJsonContentChange?: (content: JSONContent | null) => void;
6
9
  onHtmlContentChange?: (content: string) => void;
7
10
  handleImageUpload: (file: File) => Promise<string>;
11
+ version?: number;
12
+ textSize?: FireCMSEditorTextSize;
13
+ highlight?: {
14
+ from: number;
15
+ to: number;
16
+ };
17
+ aiController?: EditorAIController;
18
+ customComponents?: CustomEditorComponent[];
19
+ disabled?: boolean;
8
20
  };
9
- export declare const FireCMSEditor: ({ handleImageUpload, initialContent, onJsonContentChange, onHtmlContentChange, onMarkdownContentChange }: FireCMSEditorProps) => import("react/jsx-runtime").JSX.Element | null;
21
+ export type CustomEditorComponent = {
22
+ name: string;
23
+ component: React.FC;
24
+ };
25
+ export declare const FireCMSEditor: ({ content, onJsonContentChange, onHtmlContentChange, onMarkdownContentChange, version, textSize, highlight, handleImageUpload, aiController, disabled }: FireCMSEditorProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,12 @@
1
- export declare const placeholder: import("@tiptap/core").Extension<import("@tiptap/extension-placeholder").PlaceholderOptions, any>;
1
+ export declare const placeholder: import("@tiptap/core").Extension<import("@tiptap/extensions").PlaceholderOptions, any>;
2
2
  export declare const tiptapLink: import("@tiptap/core").Mark<import("@tiptap/extension-link").LinkOptions, any>;
3
- export declare const taskList: import("@tiptap/core").Node<import("@tiptap/extension-task-list").TaskListOptions, any>;
4
- export declare const taskItem: import("@tiptap/core").Node<import("@tiptap/extension-task-item").TaskItemOptions, any>;
3
+ export declare const taskList: import("@tiptap/core").Node<import("@tiptap/extension-list").TaskListOptions, any>;
4
+ export declare const taskItem: import("@tiptap/core").Node<import("@tiptap/extension-list").TaskItemOptions, any>;
5
5
  export declare const horizontalRule: import("@tiptap/core").Node<import("@tiptap/extension-horizontal-rule").HorizontalRuleOptions, any>;
6
+ export declare const bulletList: import("@tiptap/core").Node<import("@tiptap/extension-list").BulletListOptions, any>;
7
+ export declare const orderedList: import("@tiptap/core").Node<import("@tiptap/extension-list").OrderedListOptions, any>;
8
+ export declare const listItem: import("@tiptap/core").Node<import("@tiptap/extension-list").ListItemOptions, any>;
9
+ export declare const blockquote: import("@tiptap/core").Node<import("@tiptap/extension-blockquote").BlockquoteOptions, any>;
10
+ export declare const codeBlock: import("@tiptap/core").Node<import("@tiptap/extension-code-block").CodeBlockOptions, any>;
11
+ export declare const code: import("@tiptap/core").Mark<import("@tiptap/extension-code").CodeOptions, any>;
6
12
  export declare const starterKit: import("@tiptap/core").Extension<import("@tiptap/starter-kit").StarterKitOptions, any>;
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { Node } from "@tiptap/core";
3
+ import { ReactNodeViewProps } from "@tiptap/react";
4
+ export interface CustomBlockOptions {
5
+ component: React.ComponentType<ReactNodeViewProps> | null;
6
+ delimiter?: string;
7
+ }
8
+ export declare const CustomBlock: Node<CustomBlockOptions, any>;
@@ -0,0 +1,35 @@
1
+ import { Extension } from "@tiptap/core";
2
+ import { PluginKey } from "@tiptap/pm/state";
3
+ import { DecorationSet } from "@tiptap/pm/view";
4
+ declare module "@tiptap/core" {
5
+ interface Commands<ReturnType> {
6
+ highlightDecoration: {
7
+ toggleAutocompleteHighlight: (range?: {
8
+ from: number;
9
+ to: number;
10
+ }) => ReturnType;
11
+ removeAutocompleteHighlight: () => ReturnType;
12
+ };
13
+ }
14
+ }
15
+ export interface HighlightRange {
16
+ from: number;
17
+ to: number;
18
+ }
19
+ interface AutocompleteHighlightState {
20
+ highlight?: HighlightRange;
21
+ decorationSet?: DecorationSet;
22
+ }
23
+ export interface HighlightDecorationOptions {
24
+ pluginKey: PluginKey<AutocompleteHighlightState>;
25
+ highlight?: {
26
+ from: number;
27
+ to: number;
28
+ };
29
+ }
30
+ /**
31
+ * This plugin is used to highlight the current autocomplete suggestion.
32
+ * It allows to set a range and remove it.
33
+ */
34
+ export declare const HighlightDecorationExtension: (initialHighlight?: HighlightRange) => Extension<HighlightDecorationOptions, any>;
35
+ export {};
@@ -1,4 +1,7 @@
1
- import { Plugin } from "prosemirror-state";
1
+ import { EditorView } from "@tiptap/pm/view";
2
+ import { Plugin, PluginKey } from "@tiptap/pm/state";
2
3
  export type UploadFn = (image: File) => Promise<string>;
3
- export declare const dropImagePlugin: (upload: UploadFn) => Plugin<any>;
4
- export declare const createImageExtension: (uploadFn: UploadFn) => import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any>;
4
+ export declare function onFileRead(view: EditorView, readerEvent: ProgressEvent<FileReader>, pos: number, upload: UploadFn, image: File): Promise<void>;
5
+ export declare const ImagePluginKey: PluginKey<any>;
6
+ export declare const createDropImagePlugin: (upload: UploadFn) => Plugin;
7
+ export declare const createImageExtension: (dropImagePlugin: Plugin) => import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any>;
@@ -0,0 +1,7 @@
1
+ import { Node } from "@tiptap/core";
2
+ export declare const AutocompleteExtension: Node<{
3
+ suggestionDebounce: number;
4
+ }, {
5
+ getSuggestion: ((previousText: string, cb: (suggestion: string | null) => void) => void) | undefined;
6
+ suggestion: string | null;
7
+ }>;
@@ -0,0 +1,18 @@
1
+ import { PluginKey } from "@tiptap/pm/state";
2
+ import { DecorationSet } from "@tiptap/pm/view";
3
+ import { Extension } from "@tiptap/core";
4
+ declare module "@tiptap/core" {
5
+ interface Commands<ReturnType> {
6
+ textLoadingDecoration: {
7
+ toggleLoadingDecoration: (loadingHtml?: string) => ReturnType;
8
+ removeLoadingDecoration: () => ReturnType;
9
+ };
10
+ }
11
+ }
12
+ export declare const loadingDecorationKey: PluginKey<LoadingDecorationState>;
13
+ interface LoadingDecorationState {
14
+ decorationSet: DecorationSet;
15
+ hasDecoration: boolean;
16
+ }
17
+ declare const TextLoadingDecorationExtension: Extension<any, any>;
18
+ export default TextLoadingDecorationExtension;
@@ -0,0 +1,7 @@
1
+ import { Slice } from "@tiptap/pm/model";
2
+ import { EditorView } from "@tiptap/pm/view";
3
+ export declare function serializeForClipboard(view: EditorView, slice: Slice): {
4
+ dom: HTMLDivElement;
5
+ text: string;
6
+ slice: Slice;
7
+ };
@@ -4,8 +4,7 @@ import TiptapImage from "@tiptap/extension-image";
4
4
  import { TaskItem } from "@tiptap/extension-task-item";
5
5
  import { TaskList } from "@tiptap/extension-task-list";
6
6
  import { InputRule } from "@tiptap/core";
7
- declare const PlaceholderExtension: import("@tiptap/core").Extension<import("@tiptap/extension-placeholder").PlaceholderOptions, any>;
7
+ declare const PlaceholderExtension: import("@tiptap/core").Extension<import("@tiptap/extensions").PlaceholderOptions, any>;
8
8
  declare const Horizontal: import("@tiptap/core").Node<import("@tiptap/extension-horizontal-rule").HorizontalRuleOptions, any>;
9
- export { PlaceholderExtension as Placeholder, StarterKit, Horizontal as HorizontalRule, TiptapLink, TiptapImage, TaskItem, TaskList, InputRule, };
10
- export * from "./slash-command";
9
+ export { PlaceholderExtension as Placeholder, StarterKit, Horizontal as HorizontalRule, TiptapLink, TiptapImage, TaskItem, TaskList, InputRule };
11
10
  export { getPrevText } from "../utils/utils";
@@ -0,0 +1,91 @@
1
+ import React, { ReactNode } from "react";
2
+ import { Editor, Node, Range } from "@tiptap/core";
3
+ import { DOMOutputSpec, Node as ProseMirrorNode } from "@tiptap/pm/model";
4
+ import { PluginKey } from "@tiptap/pm/state";
5
+ import { SuggestionOptions } from "@tiptap/suggestion";
6
+ import { UploadFn } from "./Image";
7
+ import { EditorAIController } from "../types";
8
+ export interface CommandNodeAttrs {
9
+ /**
10
+ * The identifier for the selected item that was mentioned, stored as a `data-id`
11
+ * attribute.
12
+ */
13
+ id: string | null;
14
+ /**
15
+ * The label to be rendered by the editor as the displayed text for this mentioned
16
+ * item, if provided. Stored as a `data-label` attribute. See `renderLabel`.
17
+ */
18
+ label?: string | null;
19
+ }
20
+ export type CommandOptions<SuggestionItem = any, Attrs extends Record<string, any> = CommandNodeAttrs> = {
21
+ /**
22
+ * The HTML attributes for a command node.
23
+ * @default {}
24
+ * @example { class: 'foo' }
25
+ */
26
+ HTMLAttributes: Record<string, any>;
27
+ /**
28
+ * A function to render the label of a command.
29
+ * @deprecated use renderText and renderHTML instead
30
+ * @param props The render props
31
+ * @returns The label
32
+ * @example ({ options, node }) => `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`
33
+ */
34
+ renderLabel?: (props: {
35
+ options: CommandOptions<SuggestionItem, Attrs>;
36
+ node: ProseMirrorNode;
37
+ }) => string;
38
+ /**
39
+ * A function to render the text of a command.
40
+ * @param props The render props
41
+ * @returns The text
42
+ * @example ({ options, node }) => `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`
43
+ */
44
+ renderText: (props: {
45
+ options: CommandOptions<SuggestionItem, Attrs>;
46
+ node: ProseMirrorNode;
47
+ }) => string;
48
+ /**
49
+ * A function to render the HTML of a command.
50
+ * @param props The render props
51
+ * @returns The HTML as a ProseMirror DOM Output Spec
52
+ * @example ({ options, node }) => ['span', { 'data-type': 'command' }, `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`]
53
+ */
54
+ renderHTML: (props: {
55
+ options: CommandOptions<SuggestionItem, Attrs>;
56
+ node: ProseMirrorNode;
57
+ }) => DOMOutputSpec;
58
+ /**
59
+ * Whether to delete the trigger character with backspace.
60
+ * @default false
61
+ */
62
+ deleteTriggerWithBackspace: boolean;
63
+ /**
64
+ * The suggestion options.
65
+ * @default {}
66
+ * @example { char: '@', pluginKey: CommandPluginKey, command: ({ editor, range, props }) => { ... } }
67
+ */
68
+ suggestion: Omit<SuggestionOptions<SuggestionItem, Attrs>, "editor">;
69
+ };
70
+ /**
71
+ * The plugin key for the command plugin.
72
+ * @default 'command'
73
+ */
74
+ export declare const CommandPluginKey: PluginKey<any>;
75
+ export declare const SlashCommand: Node<CommandOptions<any, CommandNodeAttrs>, any>;
76
+ export interface SuggestionItem {
77
+ title: string;
78
+ description: string;
79
+ icon: ReactNode;
80
+ searchTerms?: string[];
81
+ command?: (props: {
82
+ editor: Editor;
83
+ range: Range;
84
+ upload: UploadFn;
85
+ aiController?: EditorAIController;
86
+ }) => void;
87
+ }
88
+ export declare const suggestion: (ref: React.MutableRefObject<any>, { upload, aiController }: {
89
+ upload: UploadFn;
90
+ aiController?: EditorAIController;
91
+ }) => Omit<SuggestionOptions<SuggestionItem, any>, "editor">;