@firecms/editor 3.0.0-beta.7 → 3.0.0-beta.9
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/LICENSE +3 -2
- package/dist/components/index.d.ts +0 -3
- package/dist/editor.d.ts +12 -2
- package/dist/editor_extensions.d.ts +1 -0
- package/dist/extensions/HighlightDecorationExtension.d.ts +35 -0
- package/dist/extensions/Image.d.ts +6 -3
- package/dist/extensions/InlineAutocomplete.d.ts +7 -0
- package/dist/extensions/TextLoadingDecorationExtension.d.ts +18 -0
- package/dist/extensions/_image-resizer.d.ts +0 -1
- package/dist/extensions/index.d.ts +0 -1
- package/dist/extensions/slashCommand.d.ts +92 -0
- package/dist/index.es.js +1360 -703
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1613 -8
- package/dist/index.umd.js.map +1 -1
- package/dist/selectors/node-selector.d.ts +2 -1
- package/dist/types.d.ts +3 -0
- package/package.json +23 -26
- package/dist/components/editor-command-item.d.ts +0 -20
- package/dist/components/editor-command.d.ts +0 -24
- package/dist/components/editor.d.ts +0 -43
- package/dist/extensions/slash-command.d.ts +0 -29
- package/dist/extensions/updated-image.d.ts +0 -2
package/LICENSE
CHANGED
|
@@ -3,12 +3,13 @@ Business Source License 1.1
|
|
|
3
3
|
Parameters
|
|
4
4
|
|
|
5
5
|
Licensor: Firecms S.L.
|
|
6
|
-
Licensed Work: Firecms CMS packages:
|
|
6
|
+
Licensed Work: Firecms CMS packages:
|
|
7
7
|
cli
|
|
8
8
|
collection_editor
|
|
9
9
|
collection_editor_firebase
|
|
10
10
|
data_enhancement
|
|
11
|
-
|
|
11
|
+
data_export
|
|
12
|
+
data_export
|
|
12
13
|
editor
|
|
13
14
|
firecms_cloud
|
|
14
15
|
schema_inference
|
|
@@ -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,19 @@
|
|
|
1
1
|
import { type JSONContent } from "./components";
|
|
2
|
+
import { EditorAIController } from "./types";
|
|
3
|
+
export type FireCMSEditorTextSize = "sm" | "base" | "lg";
|
|
2
4
|
export type FireCMSEditorProps = {
|
|
3
|
-
|
|
5
|
+
content?: JSONContent | string;
|
|
4
6
|
onMarkdownContentChange?: (content: string) => void;
|
|
5
7
|
onJsonContentChange?: (content: JSONContent | null) => void;
|
|
6
8
|
onHtmlContentChange?: (content: string) => void;
|
|
7
9
|
handleImageUpload: (file: File) => Promise<string>;
|
|
10
|
+
version?: number;
|
|
11
|
+
textSize?: FireCMSEditorTextSize;
|
|
12
|
+
highlight?: {
|
|
13
|
+
from: number;
|
|
14
|
+
to: number;
|
|
15
|
+
};
|
|
16
|
+
aiController?: EditorAIController;
|
|
17
|
+
onDisabledAutocompleteClick?: () => void;
|
|
8
18
|
};
|
|
9
|
-
export declare const FireCMSEditor: ({
|
|
19
|
+
export declare const FireCMSEditor: ({ content, onJsonContentChange, onHtmlContentChange, onMarkdownContentChange, version, textSize, highlight, handleImageUpload, aiController, onDisabledAutocompleteClick }: FireCMSEditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,5 +2,6 @@ export declare const placeholder: import("@tiptap/core").Extension<import("@tipt
|
|
|
2
2
|
export declare const tiptapLink: import("@tiptap/core").Mark<import("@tiptap/extension-link").LinkOptions, any>;
|
|
3
3
|
export declare const taskList: import("@tiptap/core").Node<import("@tiptap/extension-task-list").TaskListOptions, any>;
|
|
4
4
|
export declare const taskItem: import("@tiptap/core").Node<import("@tiptap/extension-task-item").TaskItemOptions, any>;
|
|
5
|
+
export declare const markdownExtension: import("@tiptap/core").Extension<import("tiptap-markdown").MarkdownOptions, import("tiptap-markdown").MarkdownStorage>;
|
|
5
6
|
export declare const horizontalRule: import("@tiptap/core").Node<import("@tiptap/extension-horizontal-rule").HorizontalRuleOptions, any>;
|
|
6
7
|
export declare const starterKit: import("@tiptap/core").Extension<import("@tiptap/starter-kit").StarterKitOptions, 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 {
|
|
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
|
|
4
|
-
export declare const
|
|
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,18 @@
|
|
|
1
|
+
import { PluginKey } from "prosemirror-state";
|
|
2
|
+
import { DecorationSet } from "prosemirror-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;
|
|
@@ -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,92 @@
|
|
|
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
|
+
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, onDisabledAutocompleteClick, aiController }: {
|
|
89
|
+
upload: UploadFn;
|
|
90
|
+
onDisabledAutocompleteClick?: () => void;
|
|
91
|
+
aiController?: EditorAIController;
|
|
92
|
+
}) => Omit<SuggestionOptions<SuggestionItem, any>, "editor">;
|