@firecms/editor 3.0.0-canary.23 → 3.0.0-canary.231
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 +114 -21
- package/dist/SampleCustomComponent.d.ts +10 -0
- package/dist/components/index.d.ts +0 -3
- package/dist/editor.d.ts +18 -2
- package/dist/editor_extensions.d.ts +6 -0
- package/dist/extensions/CustomBlockComponent.d.ts +7 -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 +1 -2
- package/dist/extensions/slashCommand.d.ts +91 -0
- package/dist/index.es.js +1847 -859
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1934 -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/dist/utils/utils.d.ts +1 -1
- package/package.json +49 -33
- 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 -51
- package/dist/extensions/slash-command.d.ts +0 -29
- package/dist/extensions/updated-image.d.ts +0 -2
package/LICENSE
CHANGED
@@ -1,21 +1,114 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
1
|
+
Business Source License 1.1
|
2
|
+
|
3
|
+
Parameters
|
4
|
+
|
5
|
+
Licensor: Firecms S.L.
|
6
|
+
Licensed Work: Firecms CMS packages:
|
7
|
+
cli
|
8
|
+
collection_editor
|
9
|
+
collection_editor_firebase
|
10
|
+
data_enhancement
|
11
|
+
data_export
|
12
|
+
data_export
|
13
|
+
editor
|
14
|
+
firecms_cloud
|
15
|
+
schema_inference
|
16
|
+
user_management
|
17
|
+
|
18
|
+
The Licensed Work is (c) 2024 Firecms S.L
|
19
|
+
Additional Use Grant: You may make use of the Licensed Work, provided that
|
20
|
+
you may not use the Licensed Work for a CMS Data Enhancement
|
21
|
+
Service.
|
22
|
+
|
23
|
+
A “CMS package” is a commercial offering that
|
24
|
+
allows third parties (other than your employees and
|
25
|
+
contractors) to access the functionality of the
|
26
|
+
Licensed Work by using software to extend the base features of
|
27
|
+
content management system controlled by such third parties.
|
28
|
+
|
29
|
+
Change Date: Four years from the date the Licensed Work is published.
|
30
|
+
|
31
|
+
Change License: MIT
|
32
|
+
|
33
|
+
For information about alternative licensing arrangements for the Software,
|
34
|
+
please visit: https://firecms.co
|
35
|
+
|
36
|
+
Notice
|
37
|
+
|
38
|
+
The Business Source License (this document, or the “License”) is not an Open
|
39
|
+
Source license. However, the Licensed Work will eventually be made available
|
40
|
+
under an Open Source License, as stated in this License.
|
41
|
+
|
42
|
+
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
|
43
|
+
“Business Source License” is a trademark of MariaDB Corporation Ab.
|
44
|
+
|
45
|
+
-----------------------------------------------------------------------------
|
46
|
+
|
47
|
+
Business Source License 1.1
|
48
|
+
|
49
|
+
Terms
|
50
|
+
|
51
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
52
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
53
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
54
|
+
production use.
|
55
|
+
|
56
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
57
|
+
available distribution of a specific version of the Licensed Work under this
|
58
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
59
|
+
the terms of the Change License, and the rights granted in the paragraph
|
60
|
+
above terminate.
|
61
|
+
|
62
|
+
If your use of the Licensed Work does not comply with the requirements
|
63
|
+
currently in effect as described in this License, you must purchase a
|
64
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
65
|
+
resellers, or you must refrain from using the Licensed Work.
|
66
|
+
|
67
|
+
All copies of the original and modified Licensed Work, and derivative works
|
68
|
+
of the Licensed Work, are subject to this License. This License applies
|
69
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
70
|
+
for each version of the Licensed Work released by Licensor.
|
71
|
+
|
72
|
+
You must conspicuously display this License on each original or modified copy
|
73
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
74
|
+
modified form from a third party, the terms and conditions set forth in this
|
75
|
+
License apply to your use of that work.
|
76
|
+
|
77
|
+
Any use of the Licensed Work in violation of this License will automatically
|
78
|
+
terminate your rights under this License for the current and all other
|
79
|
+
versions of the Licensed Work.
|
80
|
+
|
81
|
+
This License does not grant you any right in any trademark or logo of
|
82
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
83
|
+
Licensor as expressly required by this License).
|
84
|
+
|
85
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
86
|
+
AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
87
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
88
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
89
|
+
TITLE.
|
90
|
+
|
91
|
+
MariaDB hereby grants you permission to use this License’s text to license
|
92
|
+
your works, and to refer to it using the trademark “Business Source License”,
|
93
|
+
as long as you comply with the Covenants of Licensor below.
|
94
|
+
|
95
|
+
Covenants of Licensor
|
96
|
+
|
97
|
+
In consideration of the right to use this License’s text and the “Business
|
98
|
+
Source License” name and trademark, Licensor covenants to MariaDB, and to all
|
99
|
+
other recipients of the licensed work to be provided by Licensor:
|
100
|
+
|
101
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
102
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
103
|
+
where “compatible” means that software provided under the Change License can
|
104
|
+
be included in a program with software provided under GPL Version 2.0 or a
|
105
|
+
later version. Licensor may specify additional Change Licenses without
|
106
|
+
limitation.
|
107
|
+
|
108
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
109
|
+
impose any additional restriction on the right granted in this License, as
|
110
|
+
the Additional Use Grant; or (b) insert the text “None”.
|
111
|
+
|
112
|
+
3. To specify a Change Date.
|
113
|
+
|
114
|
+
4. Not to modify this License in any other way.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { Editor } from "@tiptap/react";
|
3
|
+
import { Node as ProseMirrorNode } from "prosemirror-model";
|
4
|
+
export interface CustomBlockComponentProps {
|
5
|
+
node: ProseMirrorNode;
|
6
|
+
updateAttributes: (attrs: Record<string, any>) => void;
|
7
|
+
getPos: () => number;
|
8
|
+
editor: Editor;
|
9
|
+
}
|
10
|
+
export declare const CustomComponent: React.FC<CustomBlockComponentProps>;
|
@@ -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
|
-
|
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
|
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;
|
@@ -3,4 +3,10 @@ export declare const tiptapLink: import("@tiptap/core").Mark<import("@tiptap/ext
|
|
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
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-bullet-list").BulletListOptions, any>;
|
7
|
+
export declare const orderedList: import("@tiptap/core").Node<import("@tiptap/extension-ordered-list").OrderedListOptions, any>;
|
8
|
+
export declare const listItem: import("@tiptap/core").Node<import("@tiptap/extension-list-item").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,7 @@
|
|
1
|
+
import { Node, NodeViewProps } from "@tiptap/core";
|
2
|
+
export type CustomBlockComponentProps = NodeViewProps;
|
3
|
+
export interface CustomBlockOptions {
|
4
|
+
component: React.ComponentType<CustomBlockComponentProps> | null;
|
5
|
+
delimiter?: string;
|
6
|
+
}
|
7
|
+
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 {
|
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;
|
@@ -6,6 +6,5 @@ import { TaskList } from "@tiptap/extension-task-list";
|
|
6
6
|
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
|
-
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/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, aiController }: {
|
89
|
+
upload: UploadFn;
|
90
|
+
aiController?: EditorAIController;
|
91
|
+
}) => Omit<SuggestionOptions<SuggestionItem, any>, "editor">;
|