@platejs/ai 52.3.1 → 52.3.10
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 +24 -0
- package/dist/{index-BvrXoj5P.d.ts → index-Dyi5V2wm.d.ts} +6 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -1927
- package/dist/react/index.d.ts +15 -13
- package/dist/react/index.js +8 -8
- package/package.json +22 -20
package/dist/react/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { c as AIMode, d as BaseAIPluginConfig, i as EditorPrompt, l as AIToolName } from "../index-
|
|
2
|
-
import * as
|
|
1
|
+
import { c as AIMode, d as BaseAIPluginConfig, i as EditorPrompt, l as AIToolName } from "../index-Dyi5V2wm";
|
|
2
|
+
import * as platejs0 from "platejs";
|
|
3
3
|
import { Descendant, EditorNodesOptions, ExtendConfig, NodeEntry, OmitFirst, Path, PluginConfig, Range, RemoveNodesOptions, SlateEditor, TElement, TIdElement, TRange, TTableElement, TText } from "platejs";
|
|
4
4
|
import { DeserializeMdOptions, SerializeMdOptions } from "@platejs/markdown";
|
|
5
|
-
import * as
|
|
5
|
+
import * as platejs_react0 from "platejs/react";
|
|
6
6
|
import { OverrideEditor, PlateEditor, RenderNodeWrapperProps } from "platejs/react";
|
|
7
7
|
import React from "react";
|
|
8
8
|
import { ChatRequestOptions, UIMessage } from "ai";
|
|
@@ -11,15 +11,15 @@ import { TriggerComboboxPluginOptions } from "@platejs/combobox";
|
|
|
11
11
|
|
|
12
12
|
//#region src/react/ai/AIPlugin.d.ts
|
|
13
13
|
type AIPluginConfig = ExtendConfig<BaseAIPluginConfig>;
|
|
14
|
-
declare const AIPlugin:
|
|
15
|
-
insertNodes: (nodes:
|
|
16
|
-
target?:
|
|
14
|
+
declare const AIPlugin: platejs_react0.PlatePlugin<platejs0.PluginConfig<any, {}, {}, Record<any, {
|
|
15
|
+
insertNodes: (nodes: platejs0.Descendant[], args_1?: {
|
|
16
|
+
target?: platejs0.Path;
|
|
17
17
|
} | undefined) => void;
|
|
18
18
|
removeMarks: (args_0?: {
|
|
19
|
-
at?:
|
|
19
|
+
at?: platejs0.TLocation;
|
|
20
20
|
} | undefined) => void;
|
|
21
21
|
removeNodes: (args_0?: {
|
|
22
|
-
at?:
|
|
22
|
+
at?: platejs0.Path;
|
|
23
23
|
} | undefined) => void;
|
|
24
24
|
undo: () => void;
|
|
25
25
|
}>, {}>>;
|
|
@@ -151,7 +151,7 @@ type AIChatPluginConfig = PluginConfig<'aiChat', {
|
|
|
151
151
|
removeAnchor: (options?: EditorNodesOptions) => void;
|
|
152
152
|
};
|
|
153
153
|
}>;
|
|
154
|
-
declare const AIChatPlugin:
|
|
154
|
+
declare const AIChatPlugin: platejs_react0.PlatePlugin<PluginConfig<"aiChat", {
|
|
155
155
|
_blockChunks: string;
|
|
156
156
|
_blockPath: Path | null;
|
|
157
157
|
/** @private Using For streamInsertChunk */
|
|
@@ -227,7 +227,7 @@ declare const AIChatPlugin: platejs_react1.PlatePlugin<PluginConfig<"aiChat", {
|
|
|
227
227
|
insertBelow: (sourceEditor: SlateEditor, args_1?: {
|
|
228
228
|
format?: "all" | "none" | "single";
|
|
229
229
|
} | undefined) => void;
|
|
230
|
-
removeAnchor: (options?:
|
|
230
|
+
removeAnchor: (options?: platejs0.RemoveNodesOptions | undefined) => void;
|
|
231
231
|
replaceSelection: (sourceEditor: SlateEditor, args_1?: {
|
|
232
232
|
format?: "all" | "none" | "single";
|
|
233
233
|
} | undefined) => void;
|
|
@@ -245,7 +245,7 @@ declare const withAIChat: OverrideEditor<AIChatPluginConfig>;
|
|
|
245
245
|
*/
|
|
246
246
|
declare const useAIChatEditor: (editor: SlateEditor, content: string, {
|
|
247
247
|
parser
|
|
248
|
-
}?: DeserializeMdOptions) =>
|
|
248
|
+
}?: DeserializeMdOptions) => platejs0.Value;
|
|
249
249
|
//#endregion
|
|
250
250
|
//#region src/react/ai-chat/hooks/useChatChunk.d.ts
|
|
251
251
|
declare const useChatChunk: ({
|
|
@@ -281,7 +281,9 @@ declare const useEditorChat: ({
|
|
|
281
281
|
}: UseEditorChatOptions) => void;
|
|
282
282
|
//#endregion
|
|
283
283
|
//#region src/react/ai-chat/streaming/streamDeserializeInlineMd.d.ts
|
|
284
|
-
declare const streamDeserializeInlineMd: (editor: PlateEditor, text: string, options?: DeserializeMdOptions) =>
|
|
284
|
+
declare const streamDeserializeInlineMd: (editor: PlateEditor, text: string, options?: DeserializeMdOptions) => platejs0.Descendant[] | {
|
|
285
|
+
text: string;
|
|
286
|
+
}[];
|
|
285
287
|
//#endregion
|
|
286
288
|
//#region src/react/ai-chat/streaming/streamDeserializeMd.d.ts
|
|
287
289
|
declare const streamDeserializeMd: (editor: PlateEditor, data: string, options?: DeserializeMdOptions) => TElement[] | {
|
|
@@ -486,7 +488,7 @@ type CompletionState = {
|
|
|
486
488
|
error?: Error | null;
|
|
487
489
|
isLoading?: boolean;
|
|
488
490
|
};
|
|
489
|
-
declare const CopilotPlugin:
|
|
491
|
+
declare const CopilotPlugin: platejs_react0.PlatePlugin<PluginConfig<"copilot", CompletionState & {
|
|
490
492
|
/**
|
|
491
493
|
* AI completion options. See:
|
|
492
494
|
* {@link https://sdk.vercel.ai/docs/reference/ai-sdk-ui/use-completion#parameters | AI SDK UI useCompletion Parameters}
|
package/dist/react/index.js
CHANGED
|
@@ -3,11 +3,11 @@ import { ElementApi, KEYS, NodeApi, PathApi, RangeApi, TextApi, bindFirst, getPl
|
|
|
3
3
|
import { SkipSuggestionDeletes, acceptSuggestion, diffToSuggestions, getSuggestionKey, getTransientSuggestionKey, rejectSuggestion } from "@platejs/suggestion";
|
|
4
4
|
import { isSelecting } from "@platejs/selection";
|
|
5
5
|
import { MarkdownPlugin, deserializeInlineMd, deserializeMd, serializeInlineMd, serializeMd } from "@platejs/markdown";
|
|
6
|
-
import
|
|
7
|
-
import { createTPlatePlugin, getEditorPlugin as getEditorPlugin$1, toPlatePlugin, useEditorPlugin, usePluginOption } from "platejs/react";
|
|
6
|
+
import { createTPlatePlugin, getEditorPlugin, toPlatePlugin, useEditorPlugin, usePluginOption } from "platejs/react";
|
|
8
7
|
import { distance } from "fastest-levenshtein";
|
|
9
8
|
import { BlockSelectionPlugin, removeBlockSelectionNodes } from "@platejs/selection/react";
|
|
10
9
|
import { SuggestionPlugin } from "@platejs/suggestion/react";
|
|
10
|
+
import cloneDeep from "lodash/cloneDeep.js";
|
|
11
11
|
import { c } from "react-compiler-runtime";
|
|
12
12
|
import React, { useEffect, useMemo, useRef } from "react";
|
|
13
13
|
import debounce from "lodash/debounce.js";
|
|
@@ -171,7 +171,7 @@ const acceptAISuggestions = (editor) => {
|
|
|
171
171
|
const acceptAIChat = (editor) => {
|
|
172
172
|
const mode = editor.getOption(AIChatPlugin, "mode");
|
|
173
173
|
if (mode === "insert") {
|
|
174
|
-
const { tf } = getEditorPlugin
|
|
174
|
+
const { tf } = getEditorPlugin(editor, AIPlugin);
|
|
175
175
|
const api = editor.getApi({ key: KEYS.ai });
|
|
176
176
|
const lastAINodePath = api.aiChat.node({
|
|
177
177
|
at: [],
|
|
@@ -379,7 +379,7 @@ const rejectAISuggestions = (editor) => {
|
|
|
379
379
|
//#endregion
|
|
380
380
|
//#region src/react/ai-chat/utils/resetAIChat.ts
|
|
381
381
|
const resetAIChat = (editor, { undo = true } = {}) => {
|
|
382
|
-
const { api, getOptions, setOptions } = getEditorPlugin
|
|
382
|
+
const { api, getOptions, setOptions } = getEditorPlugin(editor, { key: KEYS.aiChat });
|
|
383
383
|
api.aiChat.stop();
|
|
384
384
|
const chat = getOptions().chat;
|
|
385
385
|
if (chat.messages && chat.messages.length > 0) chat.setMessages?.([]);
|
|
@@ -395,7 +395,7 @@ const resetAIChat = (editor, { undo = true } = {}) => {
|
|
|
395
395
|
//#endregion
|
|
396
396
|
//#region src/react/ai-chat/utils/submitAIChat.ts
|
|
397
397
|
const submitAIChat = (editor, input, { mode, options, prompt, toolName: toolNameProps } = {}) => {
|
|
398
|
-
const { getOptions, setOption } = getEditorPlugin
|
|
398
|
+
const { getOptions, setOption } = getEditorPlugin(editor, { key: KEYS.aiChat });
|
|
399
399
|
const { chat, toolName: toolNameOption } = getOptions();
|
|
400
400
|
const toolName = toolNameProps ?? toolNameOption ?? null;
|
|
401
401
|
if (!prompt && input?.length === 0) return;
|
|
@@ -1091,7 +1091,7 @@ const getCurrentBlockPath = (editor) => {
|
|
|
1091
1091
|
//#endregion
|
|
1092
1092
|
//#region src/react/copilot/renderCopilotBelowNodes.tsx
|
|
1093
1093
|
const renderCopilotBelowNodes = ({ editor }) => {
|
|
1094
|
-
const { renderGhostText: GhostText } = getEditorPlugin
|
|
1094
|
+
const { renderGhostText: GhostText } = getEditorPlugin(editor, { key: KEYS.copilot }).getOptions();
|
|
1095
1095
|
if (!GhostText) return;
|
|
1096
1096
|
return ({ children }) => /* @__PURE__ */ React.createElement(React.Fragment, null, children, /* @__PURE__ */ React.createElement(GhostText, null));
|
|
1097
1097
|
};
|
|
@@ -1199,7 +1199,7 @@ const getNextWord = ({ text }) => {
|
|
|
1199
1199
|
//#endregion
|
|
1200
1200
|
//#region src/react/copilot/utils/triggerCopilotSuggestion.ts
|
|
1201
1201
|
const triggerCopilotSuggestion = async (editor) => {
|
|
1202
|
-
const { api, getOptions, setOption } = getEditorPlugin
|
|
1202
|
+
const { api, getOptions, setOption } = getEditorPlugin(editor, { key: KEYS.copilot });
|
|
1203
1203
|
const { completeOptions, getPrompt, isLoading, triggerQuery } = getOptions();
|
|
1204
1204
|
if (isLoading || editor.getOptions({ key: KEYS.aiChat }).chat?.isLoading) return false;
|
|
1205
1205
|
if (!triggerQuery({ editor })) return false;
|
|
@@ -1234,7 +1234,7 @@ const withoutAbort = (editor, fn) => {
|
|
|
1234
1234
|
//#endregion
|
|
1235
1235
|
//#region src/react/copilot/transforms/acceptCopilotNextWord.ts
|
|
1236
1236
|
const acceptCopilotNextWord = (editor) => {
|
|
1237
|
-
const { api, getOptions } = getEditorPlugin
|
|
1237
|
+
const { api, getOptions } = getEditorPlugin(editor, { key: KEYS.copilot });
|
|
1238
1238
|
const { getNextWord: getNextWord$1, suggestionText } = getOptions();
|
|
1239
1239
|
if (!suggestionText?.length) return false;
|
|
1240
1240
|
const { firstWord, remainingText } = getNextWord$1({ text: suggestionText });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platejs/ai",
|
|
3
|
-
"version": "52.3.
|
|
3
|
+
"version": "52.3.10",
|
|
4
4
|
"description": "Text AI plugin for Plate",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plate",
|
|
@@ -28,29 +28,20 @@
|
|
|
28
28
|
"files": [
|
|
29
29
|
"dist/**/*"
|
|
30
30
|
],
|
|
31
|
-
"scripts": {
|
|
32
|
-
"brl": "yarn p:brl",
|
|
33
|
-
"build": "yarn p:build",
|
|
34
|
-
"build:watch": "yarn p:build:watch",
|
|
35
|
-
"clean": "yarn p:clean",
|
|
36
|
-
"lint": "yarn p:lint",
|
|
37
|
-
"lint:fix": "yarn p:lint:fix",
|
|
38
|
-
"test": "yarn p:test",
|
|
39
|
-
"test:watch": "yarn p:test:watch",
|
|
40
|
-
"typecheck": "yarn p:typecheck"
|
|
41
|
-
},
|
|
42
31
|
"dependencies": {
|
|
43
|
-
"@platejs/markdown": "52.3.1",
|
|
44
|
-
"@platejs/selection": "52.0.16",
|
|
45
|
-
"@platejs/suggestion": "52.0.11",
|
|
46
32
|
"fastest-levenshtein": "1.0.16",
|
|
47
33
|
"lodash": "^4.17.21",
|
|
48
|
-
"react-compiler-runtime": "^1.0.0"
|
|
34
|
+
"react-compiler-runtime": "^1.0.0",
|
|
35
|
+
"@platejs/markdown": "^52.3.10",
|
|
36
|
+
"@platejs/selection": "^52.3.10",
|
|
37
|
+
"@platejs/suggestion": "^52.3.10",
|
|
38
|
+
"@platejs/table": "^52.3.10"
|
|
49
39
|
},
|
|
50
40
|
"devDependencies": {
|
|
51
41
|
"@ai-sdk/react": "^3.0.0",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
42
|
+
"ai": "^6.0.0",
|
|
43
|
+
"@plate/scripts": "1.0.0",
|
|
44
|
+
"platejs": "^52.3.9"
|
|
54
45
|
},
|
|
55
46
|
"peerDependencies": {
|
|
56
47
|
"platejs": ">=52.0.15",
|
|
@@ -61,5 +52,16 @@
|
|
|
61
52
|
"access": "public"
|
|
62
53
|
},
|
|
63
54
|
"type": "module",
|
|
64
|
-
"module": "./dist/index.js"
|
|
65
|
-
|
|
55
|
+
"module": "./dist/index.js",
|
|
56
|
+
"scripts": {
|
|
57
|
+
"brl": "plate-pkg p:brl",
|
|
58
|
+
"build": "plate-pkg p:build",
|
|
59
|
+
"build:watch": "plate-pkg p:build:watch",
|
|
60
|
+
"clean": "plate-pkg p:clean",
|
|
61
|
+
"lint": "plate-pkg p:lint",
|
|
62
|
+
"lint:fix": "plate-pkg p:lint:fix",
|
|
63
|
+
"test": "plate-pkg p:test",
|
|
64
|
+
"test:watch": "plate-pkg p:test:watch",
|
|
65
|
+
"typecheck": "plate-pkg p:typecheck"
|
|
66
|
+
}
|
|
67
|
+
}
|