///
import { Editor } from '@tiptap/core';
import { Extension } from '@tiptap/react';
import { JSX as JSX_2 } from 'react/jsx-runtime';
import { Mark } from '@tiptap/react';
import { MarkdownParser } from '../../../node_modules/tiptap-markdown/src/parse/MarkdownParser';
import { Node as Node_2 } from '@tiptap/react';
import { Node as Node_3 } from '@tiptap/core';
import { Range as Range_2 } from '@tiptap/core';
import { default as React_2 } from 'react';
import { Selection as Selection_2 } from 'prosemirror-state';
import { TextStyleOptions } from '@tiptap/extension-text-style';
export declare function actionPosition(action: PromptAction, selection: Selection_2): Range_2;
export declare interface Advice {
id: string;
content: string;
replies: Advice[];
createdAt: Date;
}
export declare const AdviceExtension: Mark;
export declare class AdviceManager {
private static instance;
static getInstance(): AdviceManager;
private constructor();
private advices;
private handlers;
on(event: string, handler: EventHandler): void;
emit(event: string, data: any): void;
addAdvice(advice: Advice): void;
getAdvice(id: string): Advice;
setActiveId(id: string): void;
onActiveIdChange(handler: EventHandler): void;
updateAdvice(id: string, data: Advice): void;
updateAdvices(data: Advice[]): void;
getAdvices(): Advice[];
removeAdvice(id: string): void;
}
export declare const AdviceView: ({ editor }: AdviceViewProps) => JSX_2.Element;
declare interface AdviceViewProps {
editor: Editor;
}
export declare class AiActionExecutor {
editor: Editor;
endpointUrl: string;
markdownParser: MarkdownParser;
constructor();
setEditor(editor: Editor): void;
setEndpointUrl(url: string): void;
/**
* TODO: will according the {@link PromptAction.useModel} to return the endpoint in future
* @param action
*/
endpoint(action: PromptAction): string;
handleStreaming(action: PromptAction, prompt: string): Promise;
handleTextOrDiff(action: PromptAction, prompt: string): Promise;
handleDefault(action: PromptAction, prompt: string): Promise;
execute(action: PromptAction): Promise;
}
export declare const ArticlePrompts: PromptAction[];
export declare const BubbleMenuPrompts: PromptAction[];
export declare enum BuiltInFunc {
SIMILAR_CHUNKS = "SIMILAR_CHUNKS",
RELATED_CHUNKS = "RELATED_CHUNKS",
GRAMMAR_CHECK = "GRAMMAR_CHECK",
SPELLING_CHECK = "SPELLING_CHECK",
WIKI_SUMMARY = "WIKI_SUMMARY"
}
export declare class BuiltinFunctionExecutor {
private editor;
constructor(editor: Editor);
execute(action: PromptAction): Promise;
private searchSimilarChunks;
}
export declare enum ChangeForm {
/**
* Insert the output to the document
*/
INSERT = 0,
/**
* Replace the selected text with the output
*/
REPLACE = 1,
/**
* Show the difference between the selected text and the output
*/
DIFF = 2
}
declare interface CommentOptions {
setAdviceCommand: (comment: Advice) => void;
HTMLAttributes: Record;
onAdviceActivated: (commentId: string | null) => void;
}
declare interface CommentStorage {
activeAdviceId: string | null;
}
export declare const createQuickBox: () => Node_3;
export declare const createSlashExtension: (promptsManager?: PromptsManager) => Node_3;
export declare const CustomEditorCommands: (actionHandler: AiActionExecutor, promptsManager?: PromptsManager) => Extension;
export declare enum DefinedVariable {
/**
* The base context, i.e. the document
* 基础上下文,即文档的富余背景
*/
BASE_CONTEXT = "base_context",
/**
* Temporary context, i.e. the background in sidebar
* 临时上下文,即 sidebar 中的背景
*/
TEMP_CONTEXT = "temp_context",
/**
* All the text content before the cursor
* 光标前的所有文本内容
*/
BEFORE_CURSOR = "before_cursor",
/**
* All the text content after the cursor
* 光标后的所有文本内容
*/
AFTER_CURSOR = "after_cursor",
/**
* The selected text
* 选中的文本
*/
SELECTION = "selection",
/**
* All text in the document
* 文档中的所有文本
*/
ALL = "all",
/**
* Similar chunks of the selected text
* 选中文本的相似块
*/
SIMILAR_CHUNKS = "similar_chunks",
/**
* Related chunks of the selected text
* 选中文本的相关块
*/
RELATED_CHUNKS = "related_chunks",
/**
* Title of the document
*/
TITLE = "title"
}
declare type EventHandler = (data: any) => void;
export declare enum FacetType {
TOOLBAR_MENU = 0,
BUBBLE_MENU = 1,
SLASH_COMMAND = 2,
/**
* the
*/
QUICK_INSERT = 3
}
export declare const InlineCompletion: Node_3;
export declare const LiveEditor: () => JSX_2.Element;
export declare const MenuBubble: ({ editor, customActions }: {
editor: Editor;
customActions?: PromptAction[];
}) => JSX_2.Element;
export declare const newAdvice: (content: string) => Advice;
export declare enum OutputForm {
/**
* Append the output to the document, not streaming
*/
NORMAL = 0,
/**
* Streaming the output to the document
*/
STREAMING = 1,
/**
* Show the difference between the selected text and the output
*/
DIFF = 2,
/**
* Show the output in which is a popup
*/
NOTIFICATION = 3,
/**
* Side suggestion box
*/
SIDE_BOX = 4,
/**
* Await all
*/
TEXT = 5
}
export declare interface PromptAction {
/**
* Name of the action, will be displayed in the menu.
* If i18Name is true, then it will be translated by i18n, so we suggest use `{{` and `}}` inside the name.
* For example:
* ```ts
* name: '{{Continue writing}}'
* i18Name: true
* ```
*/
name: string;
/**
* Use i18n to translate the prompt name
*/
i18Name?: boolean;
/**
* Template is a handlebars template, for example:
*
* ```handlebars
* You are in {{TEMP_CONTEXT}} and your selection is {{SELECTION}}
* ```
*/
template: string;
/**
* Final result that compiled using handlebars engine from [template]
*/
compiledTemplate?: string;
/**
* Use builtin function to execute the prompt
*/
builtinFunction?: BuiltInFunc;
/**
* The type of the facet, like toolbar menu, bubble menu, context menu, slash command, quick insert
*/
facetType: FacetType;
/**
* the output form of the prompt, like streaming, normal, chat, inside box, notification
*/
outputForm: OutputForm;
/**
* The change form of the prompt, like insert, replace, diff
*/
changeForm?: ChangeForm;
/**
* The higher the number, the higher the priority, will be placed higher in the menu
*/
priority?: number;
/**
* The icon of the prompt, will be displayed in the menu
*/
icon?: never;
/**
* The description of the prompt, will be displayed in the menu
*/
description?: string;
/**
* Used LLM model, like openai, gpt3, gpt2, etc.
*/
useModel?: string;
/**
* Condition to show the prompt
*/
condition?: string;
/**
* Menu Action
*/
action?: (editor: Editor) => Promise;
}
export declare class PromptCompiler {
private action;
private editor;
constructor(action: PromptAction, editor: Editor);
compile(): void;
}
export declare class PromptsManager {
private constructor();
private static instance;
static getInstance(): PromptsManager;
actionsMap: {
article: PromptAction[];
requirements: PromptAction[];
};
getActions(type: FacetType, articleType: TypeOptions): PromptAction[];
variableList(): string[];
updateActionsMap(articleType: string, prompts: PromptAction[]): void;
compile(string: string, data: object): string;
saveBackgroundContext(context: string): void;
}
export declare const Settings: ({ editor }: {
editor: Editor;
}) => JSX_2.Element;
export declare const setupExtensions: (promptsManager: PromptsManager, actionExecutor: AiActionExecutor) => (Node_2 | Extension | Mark)[];
export declare const Sidebar: React_2.FC;
export declare const SlashCommandsPrompts: PromptAction[];
export declare enum SourceType {
BEFORE_CURSOR = "BEFORE_CURSOR",
SELECTION = "SELECTION"
}
export declare const ToolbarMenu: ({ editor, isBubbleMenu, className }: ToolbarProps) => JSX_2.Element;
export declare const ToolbarMenuPrompts: PromptAction[];
declare interface ToolbarProps {
editor: Editor;
isBubbleMenu?: boolean;
className?: string;
}
declare interface TypeOptions {
value: string;
label: string;
}
export { }