@firecms/editor 3.0.0-canary.102 → 3.0.0-canary.103

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,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,16 @@
1
1
  import { type JSONContent } from "./components";
2
+ export type FireCMSEditorTextSize = "sm" | "base" | "lg";
2
3
  export type FireCMSEditorProps = {
3
- initialContent?: JSONContent | string;
4
+ content?: JSONContent | string;
4
5
  onMarkdownContentChange?: (content: string) => void;
5
6
  onJsonContentChange?: (content: JSONContent | null) => void;
6
7
  onHtmlContentChange?: (content: string) => void;
7
8
  handleImageUpload: (file: File) => Promise<string>;
9
+ version?: number;
10
+ textSize?: FireCMSEditorTextSize;
11
+ highlight?: {
12
+ from: number;
13
+ to: number;
14
+ };
8
15
  };
9
- export declare const FireCMSEditor: ({ handleImageUpload, initialContent, onJsonContentChange, onHtmlContentChange, onMarkdownContentChange }: FireCMSEditorProps) => import("react/jsx-runtime").JSX.Element | null;
16
+ export declare const FireCMSEditor: ({ handleImageUpload, content, onJsonContentChange, onHtmlContentChange, onMarkdownContentChange, version, textSize, highlight }: FireCMSEditorProps) => import("react/jsx-runtime").JSX.Element;
@@ -7,5 +7,4 @@ import { InputRule } from "@tiptap/core";
7
7
  declare const PlaceholderExtension: import("@tiptap/core").Extension<import("@tiptap/extension-placeholder").PlaceholderOptions, any>;
8
8
  declare const Horizontal: import("@tiptap/core").Node<import("@tiptap/extension-horizontal-rule").HorizontalRuleOptions, any>;
9
9
  export { PlaceholderExtension as Placeholder, StarterKit, Horizontal as HorizontalRule, TiptapLink, TiptapImage, TaskItem, TaskList, InputRule, };
10
- export * from "./slash-command";
11
10
  export { getPrevText } from "../utils/utils";
@@ -0,0 +1,84 @@
1
+ import React, { ReactNode } from "react";
2
+ import { Editor, Node, Range } from "@tiptap/react";
3
+ import { DOMOutputSpec, Node as ProseMirrorNode } from "@tiptap/pm/model";
4
+ import { PluginKey } from "@tiptap/pm/state";
5
+ import { SuggestionOptions } from "@tiptap/suggestion";
6
+ export interface CommandNodeAttrs {
7
+ /**
8
+ * The identifier for the selected item that was mentioned, stored as a `data-id`
9
+ * attribute.
10
+ */
11
+ id: string | null;
12
+ /**
13
+ * The label to be rendered by the editor as the displayed text for this mentioned
14
+ * item, if provided. Stored as a `data-label` attribute. See `renderLabel`.
15
+ */
16
+ label?: string | null;
17
+ }
18
+ export type CommandOptions<SuggestionItem = any, Attrs extends Record<string, any> = CommandNodeAttrs> = {
19
+ /**
20
+ * The HTML attributes for a command node.
21
+ * @default {}
22
+ * @example { class: 'foo' }
23
+ */
24
+ HTMLAttributes: Record<string, any>;
25
+ /**
26
+ * A function to render the label of a command.
27
+ * @deprecated use renderText and renderHTML instead
28
+ * @param props The render props
29
+ * @returns The label
30
+ * @example ({ options, node }) => `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`
31
+ */
32
+ renderLabel?: (props: {
33
+ options: CommandOptions<SuggestionItem, Attrs>;
34
+ node: ProseMirrorNode;
35
+ }) => string;
36
+ /**
37
+ * A function to render the text of a command.
38
+ * @param props The render props
39
+ * @returns The text
40
+ * @example ({ options, node }) => `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`
41
+ */
42
+ renderText: (props: {
43
+ options: CommandOptions<SuggestionItem, Attrs>;
44
+ node: ProseMirrorNode;
45
+ }) => string;
46
+ /**
47
+ * A function to render the HTML of a command.
48
+ * @param props The render props
49
+ * @returns The HTML as a ProseMirror DOM Output Spec
50
+ * @example ({ options, node }) => ['span', { 'data-type': 'command' }, `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`]
51
+ */
52
+ renderHTML: (props: {
53
+ options: CommandOptions<SuggestionItem, Attrs>;
54
+ node: ProseMirrorNode;
55
+ }) => DOMOutputSpec;
56
+ /**
57
+ * Whether to delete the trigger character with backspace.
58
+ * @default false
59
+ */
60
+ deleteTriggerWithBackspace: boolean;
61
+ /**
62
+ * The suggestion options.
63
+ * @default {}
64
+ * @example { char: '@', pluginKey: CommandPluginKey, command: ({ editor, range, props }) => { ... } }
65
+ */
66
+ suggestion: Omit<SuggestionOptions<SuggestionItem, Attrs>, "editor">;
67
+ };
68
+ /**
69
+ * The plugin key for the command plugin.
70
+ * @default 'command'
71
+ */
72
+ export declare const CommandPluginKey: PluginKey<any>;
73
+ export declare const SlashCommand: Node<CommandOptions<any, CommandNodeAttrs>, any>;
74
+ export interface SuggestionItem {
75
+ title: string;
76
+ description: string;
77
+ icon: ReactNode;
78
+ searchTerms?: string[];
79
+ command?: (props: {
80
+ editor: Editor;
81
+ range: Range;
82
+ }) => void;
83
+ }
84
+ export declare const suggestion: (ref: React.MutableRefObject<any>) => Omit<SuggestionOptions<SuggestionItem, any>, "editor">;