@platejs/ai 51.1.1 → 52.0.0
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/dist/getEditorPrompt-BnVrgUl3.js +102 -0
- package/dist/index-CyVv31EV.d.ts +96 -0
- package/dist/index.d.ts +2 -22
- package/dist/index.js +47 -224
- package/dist/react/index.d.ts +469 -377
- package/dist/react/index.js +1252 -1927
- package/package.json +14 -22
- package/dist/getEditorPrompt-C7EEuMw8.d.mts +0 -54
- package/dist/getEditorPrompt-C7EEuMw8.d.ts +0 -54
- package/dist/index.d.mts +0 -22
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -193
- package/dist/index.mjs.map +0 -1
- package/dist/react/index.d.mts +0 -471
- package/dist/react/index.js.map +0 -1
- package/dist/react/index.mjs +0 -1984
- package/dist/react/index.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platejs/ai",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "52.0.0",
|
|
4
4
|
"description": "Text AI plugin for Plate",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plate",
|
|
@@ -19,22 +19,12 @@
|
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"exports": {
|
|
22
|
-
".":
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"module": "./dist/index.mjs",
|
|
26
|
-
"require": "./dist/index.js"
|
|
27
|
-
},
|
|
28
|
-
"./react": {
|
|
29
|
-
"types": "./dist/react/index.d.ts",
|
|
30
|
-
"import": "./dist/react/index.mjs",
|
|
31
|
-
"module": "./dist/react/index.mjs",
|
|
32
|
-
"require": "./dist/react/index.js"
|
|
33
|
-
}
|
|
22
|
+
".": "./dist/index.js",
|
|
23
|
+
"./react": "./dist/react/index.js",
|
|
24
|
+
"./package.json": "./package.json"
|
|
34
25
|
},
|
|
35
|
-
"main": "dist/index.js",
|
|
36
|
-
"
|
|
37
|
-
"types": "dist/index.d.ts",
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
38
28
|
"files": [
|
|
39
29
|
"dist/**/*"
|
|
40
30
|
],
|
|
@@ -50,23 +40,25 @@
|
|
|
50
40
|
"typecheck": "yarn p:typecheck"
|
|
51
41
|
},
|
|
52
42
|
"dependencies": {
|
|
53
|
-
"@platejs/markdown": "
|
|
54
|
-
"@platejs/selection": "
|
|
55
|
-
"@platejs/suggestion": "
|
|
43
|
+
"@platejs/markdown": "52.0.0",
|
|
44
|
+
"@platejs/selection": "52.0.0",
|
|
45
|
+
"@platejs/suggestion": "52.0.0",
|
|
56
46
|
"fastest-levenshtein": "1.0.16",
|
|
57
47
|
"lodash": "^4.17.21"
|
|
58
48
|
},
|
|
59
49
|
"devDependencies": {
|
|
60
50
|
"@ai-sdk/react": "2.0.28",
|
|
61
|
-
"@platejs/combobox": "
|
|
51
|
+
"@platejs/combobox": "52.0.0",
|
|
62
52
|
"ai": "5.0.28"
|
|
63
53
|
},
|
|
64
54
|
"peerDependencies": {
|
|
65
|
-
"platejs": ">=
|
|
55
|
+
"platejs": ">=52.0.0",
|
|
66
56
|
"react": ">=18.0.0",
|
|
67
57
|
"react-dom": ">=18.0.0"
|
|
68
58
|
},
|
|
69
59
|
"publishConfig": {
|
|
70
60
|
"access": "public"
|
|
71
|
-
}
|
|
61
|
+
},
|
|
62
|
+
"type": "module",
|
|
63
|
+
"module": "./dist/index.js"
|
|
72
64
|
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import * as platejs from 'platejs';
|
|
2
|
-
import { SlateEditor, Descendant, Path, TLocation, PluginConfig, OmitFirst } from 'platejs';
|
|
3
|
-
|
|
4
|
-
declare const insertAINodes: (editor: SlateEditor, nodes: Descendant[], { target, }?: {
|
|
5
|
-
target?: Path;
|
|
6
|
-
}) => void;
|
|
7
|
-
|
|
8
|
-
declare const removeAIMarks: (editor: SlateEditor, { at }?: {
|
|
9
|
-
at?: TLocation;
|
|
10
|
-
}) => void;
|
|
11
|
-
|
|
12
|
-
declare const removeAINodes: (editor: SlateEditor, { at }?: {
|
|
13
|
-
at?: Path;
|
|
14
|
-
}) => void;
|
|
15
|
-
|
|
16
|
-
type BaseAIPluginConfig = PluginConfig<'ai', {}, {}, {
|
|
17
|
-
ai: {
|
|
18
|
-
insertNodes: OmitFirst<typeof insertAINodes>;
|
|
19
|
-
removeMarks: OmitFirst<typeof removeAIMarks>;
|
|
20
|
-
removeNodes: OmitFirst<typeof removeAINodes>;
|
|
21
|
-
};
|
|
22
|
-
}>;
|
|
23
|
-
declare const BaseAIPlugin: platejs.SlatePlugin<PluginConfig<any, {}, {}, Record<any, {
|
|
24
|
-
insertNodes: (nodes: platejs.Descendant[], args_1?: {
|
|
25
|
-
target?: platejs.Path;
|
|
26
|
-
} | undefined) => void;
|
|
27
|
-
removeMarks: (args_0?: {
|
|
28
|
-
at?: platejs.TLocation;
|
|
29
|
-
} | undefined) => void;
|
|
30
|
-
removeNodes: (args_0?: {
|
|
31
|
-
at?: platejs.Path;
|
|
32
|
-
} | undefined) => void;
|
|
33
|
-
undo: () => void;
|
|
34
|
-
}>, {}>>;
|
|
35
|
-
|
|
36
|
-
type AIToolName = 'comment' | 'edit' | 'generate' | null;
|
|
37
|
-
type AIMode = 'chat' | 'insert';
|
|
38
|
-
|
|
39
|
-
type EditorPrompt = ((params: EditorPromptParams) => string) | PromptConfig | string;
|
|
40
|
-
interface EditorPromptParams {
|
|
41
|
-
editor: SlateEditor;
|
|
42
|
-
isBlockSelecting: boolean;
|
|
43
|
-
isSelecting: boolean;
|
|
44
|
-
}
|
|
45
|
-
interface PromptConfig {
|
|
46
|
-
default: string;
|
|
47
|
-
blockSelecting?: string;
|
|
48
|
-
selecting?: string;
|
|
49
|
-
}
|
|
50
|
-
declare const getEditorPrompt: (editor: SlateEditor, { prompt, }: {
|
|
51
|
-
prompt?: EditorPrompt;
|
|
52
|
-
}) => string;
|
|
53
|
-
|
|
54
|
-
export { type AIToolName as A, type BaseAIPluginConfig as B, type EditorPrompt as E, type PromptConfig as P, BaseAIPlugin as a, type AIMode as b, removeAINodes as c, type EditorPromptParams as d, getEditorPrompt as g, insertAINodes as i, removeAIMarks as r };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import * as platejs from 'platejs';
|
|
2
|
-
import { SlateEditor, Descendant, Path, TLocation, PluginConfig, OmitFirst } from 'platejs';
|
|
3
|
-
|
|
4
|
-
declare const insertAINodes: (editor: SlateEditor, nodes: Descendant[], { target, }?: {
|
|
5
|
-
target?: Path;
|
|
6
|
-
}) => void;
|
|
7
|
-
|
|
8
|
-
declare const removeAIMarks: (editor: SlateEditor, { at }?: {
|
|
9
|
-
at?: TLocation;
|
|
10
|
-
}) => void;
|
|
11
|
-
|
|
12
|
-
declare const removeAINodes: (editor: SlateEditor, { at }?: {
|
|
13
|
-
at?: Path;
|
|
14
|
-
}) => void;
|
|
15
|
-
|
|
16
|
-
type BaseAIPluginConfig = PluginConfig<'ai', {}, {}, {
|
|
17
|
-
ai: {
|
|
18
|
-
insertNodes: OmitFirst<typeof insertAINodes>;
|
|
19
|
-
removeMarks: OmitFirst<typeof removeAIMarks>;
|
|
20
|
-
removeNodes: OmitFirst<typeof removeAINodes>;
|
|
21
|
-
};
|
|
22
|
-
}>;
|
|
23
|
-
declare const BaseAIPlugin: platejs.SlatePlugin<PluginConfig<any, {}, {}, Record<any, {
|
|
24
|
-
insertNodes: (nodes: platejs.Descendant[], args_1?: {
|
|
25
|
-
target?: platejs.Path;
|
|
26
|
-
} | undefined) => void;
|
|
27
|
-
removeMarks: (args_0?: {
|
|
28
|
-
at?: platejs.TLocation;
|
|
29
|
-
} | undefined) => void;
|
|
30
|
-
removeNodes: (args_0?: {
|
|
31
|
-
at?: platejs.Path;
|
|
32
|
-
} | undefined) => void;
|
|
33
|
-
undo: () => void;
|
|
34
|
-
}>, {}>>;
|
|
35
|
-
|
|
36
|
-
type AIToolName = 'comment' | 'edit' | 'generate' | null;
|
|
37
|
-
type AIMode = 'chat' | 'insert';
|
|
38
|
-
|
|
39
|
-
type EditorPrompt = ((params: EditorPromptParams) => string) | PromptConfig | string;
|
|
40
|
-
interface EditorPromptParams {
|
|
41
|
-
editor: SlateEditor;
|
|
42
|
-
isBlockSelecting: boolean;
|
|
43
|
-
isSelecting: boolean;
|
|
44
|
-
}
|
|
45
|
-
interface PromptConfig {
|
|
46
|
-
default: string;
|
|
47
|
-
blockSelecting?: string;
|
|
48
|
-
selecting?: string;
|
|
49
|
-
}
|
|
50
|
-
declare const getEditorPrompt: (editor: SlateEditor, { prompt, }: {
|
|
51
|
-
prompt?: EditorPrompt;
|
|
52
|
-
}) => string;
|
|
53
|
-
|
|
54
|
-
export { type AIToolName as A, type BaseAIPluginConfig as B, type EditorPrompt as E, type PromptConfig as P, BaseAIPlugin as a, type AIMode as b, removeAINodes as c, type EditorPromptParams as d, getEditorPrompt as g, insertAINodes as i, removeAIMarks as r };
|
package/dist/index.d.mts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export { b as AIMode, A as AIToolName, a as BaseAIPlugin, B as BaseAIPluginConfig, E as EditorPrompt, d as EditorPromptParams, P as PromptConfig, g as getEditorPrompt, i as insertAINodes, r as removeAIMarks, c as removeAINodes } from './getEditorPrompt-C7EEuMw8.mjs';
|
|
2
|
-
import { SlateEditor, History } from 'platejs';
|
|
3
|
-
|
|
4
|
-
declare const undoAI: (editor: SlateEditor) => void;
|
|
5
|
-
|
|
6
|
-
type AIBatch = History['undos'][number] & {
|
|
7
|
-
ai?: boolean;
|
|
8
|
-
};
|
|
9
|
-
declare const withAIBatch: (editor: SlateEditor, fn: () => void, { split, }?: {
|
|
10
|
-
split?: boolean;
|
|
11
|
-
}) => void;
|
|
12
|
-
|
|
13
|
-
type MarkdownType = 'block' | 'blockSelection' | 'blockSelectionWithBlockId' | 'blockWithBlockId' | 'editor' | 'editorWithBlockId';
|
|
14
|
-
declare const replacePlaceholders: (editor: SlateEditor, text: string, { prompt, }?: {
|
|
15
|
-
prompt?: string;
|
|
16
|
-
}) => string;
|
|
17
|
-
|
|
18
|
-
declare const getMarkdown: (editor: SlateEditor, { type, }: {
|
|
19
|
-
type: MarkdownType;
|
|
20
|
-
}) => string;
|
|
21
|
-
|
|
22
|
-
export { type AIBatch, type MarkdownType, getMarkdown, replacePlaceholders, undoAI, withAIBatch };
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/lib/BaseAIPlugin.ts","../src/lib/transforms/insertAINodes.ts","../src/lib/transforms/removeAIMarks.ts","../src/lib/transforms/removeAINodes.ts","../src/lib/transforms/undoAI.ts","../src/lib/transforms/withAIBatch.ts","../src/lib/utils/getEditorPrompt.ts","../src/lib/utils/getMarkdown.ts","../src/lib/utils/replacePlaceholders.ts"],"sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from './lib/index';\n","import {\n type OmitFirst,\n type PluginConfig,\n bindFirst,\n createTSlatePlugin,\n KEYS,\n} from 'platejs';\n\nimport { removeAIMarks, undoAI } from './transforms';\nimport { insertAINodes } from './transforms/insertAINodes';\nimport { removeAINodes } from './transforms/removeAINodes';\n\nexport type BaseAIPluginConfig = PluginConfig<\n 'ai',\n {},\n {},\n {\n ai: {\n insertNodes: OmitFirst<typeof insertAINodes>;\n removeMarks: OmitFirst<typeof removeAIMarks>;\n removeNodes: OmitFirst<typeof removeAINodes>;\n };\n }\n>;\n\nexport const BaseAIPlugin = createTSlatePlugin({\n key: KEYS.ai,\n node: { isDecoration: false, isLeaf: true },\n}).extendTransforms(({ editor }) => ({\n insertNodes: bindFirst(insertAINodes, editor),\n removeMarks: bindFirst(removeAIMarks, editor),\n removeNodes: bindFirst(removeAINodes, editor),\n undo: bindFirst(undoAI, editor),\n}));\n","import type { Descendant, Path, SlateEditor } from 'platejs';\n\nexport const insertAINodes = (\n editor: SlateEditor,\n nodes: Descendant[],\n {\n target,\n }: {\n target?: Path;\n } = {}\n) => {\n if (!target && !editor.selection?.focus.path) return;\n\n const aiNodes = nodes.map((node) => ({\n ...node,\n ai: true,\n }));\n\n editor.tf.withoutNormalizing(() => {\n editor.tf.insertNodes(aiNodes, {\n at: editor.api.end(target || editor.selection!.focus.path),\n select: true,\n });\n editor.tf.collapse({ edge: 'end' });\n });\n};\n","import { type SlateEditor, type TLocation, getPluginType, KEYS } from 'platejs';\n\nexport const removeAIMarks = (\n editor: SlateEditor,\n { at = [] }: { at?: TLocation } = {}\n) => {\n const nodeType = getPluginType(editor, KEYS.ai);\n\n editor.tf.unsetNodes(nodeType, {\n at,\n match: (n) => (n as any)[nodeType],\n });\n};\n","import { type Path, type SlateEditor, TextApi } from 'platejs';\n\nexport const removeAINodes = (\n editor: SlateEditor,\n { at = [] }: { at?: Path } = {}\n) => {\n editor.tf.removeNodes({\n at,\n match: (n) => TextApi.isText(n) && !!(n as any).ai,\n });\n};\n","import type { SlateEditor } from 'platejs';\n\nimport { getTransientSuggestionKey } from '@platejs/suggestion';\n\nexport const undoAI = (editor: SlateEditor) => {\n const hasAINodeOrAISuggestion =\n editor.api.some({\n at: [],\n match: (n) => !!(n as any).ai,\n }) ||\n editor.api.some({\n at: [],\n match: (n) => !!n[getTransientSuggestionKey()],\n });\n\n if ((editor.history.undos.at(-1) as any)?.ai && hasAINodeOrAISuggestion) {\n editor.undo();\n editor.history.redos.pop();\n }\n};\n","import type { History, SlateEditor } from 'platejs';\n\nexport type AIBatch = History['undos'][number] & { ai?: boolean };\n\nexport const withAIBatch = (\n editor: SlateEditor,\n fn: () => void,\n {\n split,\n }: {\n split?: boolean;\n } = {}\n) => {\n if (split) {\n editor.tf.withNewBatch(fn);\n } else {\n editor.tf.withMerging(fn);\n }\n\n const lastBatch = editor.history.undos?.at(-1) as AIBatch | undefined;\n\n if (lastBatch) {\n lastBatch.ai = true;\n }\n};\n","import { isSelecting } from '@platejs/selection';\nimport { type SlateEditor, KEYS } from 'platejs';\n\nexport type EditorPrompt =\n | ((params: EditorPromptParams) => string)\n | PromptConfig\n | string;\n\nexport interface EditorPromptParams {\n editor: SlateEditor;\n isBlockSelecting: boolean;\n isSelecting: boolean;\n}\n\nexport interface PromptConfig {\n default: string;\n blockSelecting?: string;\n selecting?: string;\n}\n\nconst createPromptFromConfig = (\n config: PromptConfig,\n params: EditorPromptParams\n): string => {\n const { isBlockSelecting, isSelecting } = params;\n\n if (isBlockSelecting && config.blockSelecting) {\n return config.blockSelecting ?? config.default;\n } else if (isSelecting && config.selecting) {\n return config.selecting ?? config.default;\n } else {\n return config.default;\n }\n};\n\nexport const getEditorPrompt = (\n editor: SlateEditor,\n {\n prompt = '',\n }: {\n prompt?: EditorPrompt;\n }\n): string => {\n const params: EditorPromptParams = {\n editor,\n isBlockSelecting: editor.getOption(\n { key: KEYS.blockSelection },\n 'isSelectingSome'\n ),\n isSelecting: isSelecting(editor),\n };\n\n let promptText = '';\n\n if (typeof prompt === 'function') {\n promptText = prompt(params);\n } else if (typeof prompt === 'object') {\n promptText = createPromptFromConfig(prompt, params);\n } else {\n promptText = prompt;\n }\n\n return promptText;\n};\n","import { serializeMd } from '@platejs/markdown';\nimport { type SlateEditor, type TElement, KEYS } from 'platejs';\n\nimport type { MarkdownType } from './replacePlaceholders';\n\n// Internal\nexport const getMarkdown = (\n editor: SlateEditor,\n {\n type,\n }: {\n type: MarkdownType;\n }\n) => {\n if (type === 'editor' || type === 'editorWithBlockId') {\n return serializeMd(editor, {\n withBlockId: type === 'editorWithBlockId',\n });\n }\n\n if (type === 'block' || type === 'blockWithBlockId') {\n const blocks = editor.api.blocks({ mode: 'highest' }).map(([node]) => node);\n\n return serializeMd(editor, {\n value: blocks,\n withBlockId: type === 'blockWithBlockId',\n });\n }\n\n if (type === 'blockSelection' || type === 'blockSelectionWithBlockId') {\n const fragment = editor.api.fragment<TElement>();\n\n // Remove any block formatting\n if (fragment.length === 1) {\n const modifiedFragment = [\n {\n children: fragment[0].children,\n type: KEYS.p,\n },\n ];\n\n return serializeMd(editor, {\n value: modifiedFragment,\n withBlockId: type === 'blockSelectionWithBlockId',\n });\n }\n\n return serializeMd(editor, {\n value: fragment,\n withBlockId: type === 'blockSelectionWithBlockId',\n });\n }\n\n return '';\n};\n","import type { SlateEditor } from 'platejs';\n\nimport { getMarkdown } from './getMarkdown';\n\nexport type MarkdownType =\n | 'block'\n | 'blockSelection'\n | 'blockSelectionWithBlockId'\n | 'blockWithBlockId'\n | 'editor'\n | 'editorWithBlockId';\n\nexport const replacePlaceholders = (\n editor: SlateEditor,\n text: string,\n {\n prompt,\n }: {\n prompt?: string;\n } = {}\n): string => {\n let result = text.replace('{prompt}', prompt || '');\n\n const placeholders: Record<string, MarkdownType> = {\n '{blockSelectionWithBlockId}': 'blockSelectionWithBlockId',\n '{blockSelection}': 'blockSelection',\n '{blockWithBlockId}': 'blockWithBlockId',\n '{block}': 'block',\n '{editorWithBlockId}': 'editorWithBlockId',\n '{editor}': 'editor',\n };\n\n Object.entries(placeholders).forEach(([placeholder, type]) => {\n if (result.includes(placeholder)) {\n result = result.replace(placeholder, getMarkdown(editor, { type }));\n }\n });\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,kBAMO;;;ACJA,IAAM,gBAAgB,CAC3B,QACA,OACA;AAAA,EACE;AACF,IAEI,CAAC,MACF;AACH,MAAI,CAAC,UAAU,CAAC,OAAO,WAAW,MAAM,KAAM;AAE9C,QAAM,UAAU,MAAM,IAAI,CAAC,UAAU;AAAA,IACnC,GAAG;AAAA,IACH,IAAI;AAAA,EACN,EAAE;AAEF,SAAO,GAAG,mBAAmB,MAAM;AACjC,WAAO,GAAG,YAAY,SAAS;AAAA,MAC7B,IAAI,OAAO,IAAI,IAAI,UAAU,OAAO,UAAW,MAAM,IAAI;AAAA,MACz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AAA,EACF,CAAC;AAED,SAAO;AACT;","names":["import_platejs","import_platejs","import_platejs","isSelecting","import_platejs"]}
|
package/dist/index.mjs
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
// src/lib/BaseAIPlugin.ts
|
|
2
|
-
import {
|
|
3
|
-
bindFirst,
|
|
4
|
-
createTSlatePlugin,
|
|
5
|
-
KEYS as KEYS2
|
|
6
|
-
} from "platejs";
|
|
7
|
-
|
|
8
|
-
// src/lib/transforms/insertAINodes.ts
|
|
9
|
-
var insertAINodes = (editor, nodes, {
|
|
10
|
-
target
|
|
11
|
-
} = {}) => {
|
|
12
|
-
if (!target && !editor.selection?.focus.path) return;
|
|
13
|
-
const aiNodes = nodes.map((node) => ({
|
|
14
|
-
...node,
|
|
15
|
-
ai: true
|
|
16
|
-
}));
|
|
17
|
-
editor.tf.withoutNormalizing(() => {
|
|
18
|
-
editor.tf.insertNodes(aiNodes, {
|
|
19
|
-
at: editor.api.end(target || editor.selection.focus.path),
|
|
20
|
-
select: true
|
|
21
|
-
});
|
|
22
|
-
editor.tf.collapse({ edge: "end" });
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
// src/lib/transforms/removeAIMarks.ts
|
|
27
|
-
import { getPluginType, KEYS } from "platejs";
|
|
28
|
-
var removeAIMarks = (editor, { at = [] } = {}) => {
|
|
29
|
-
const nodeType = getPluginType(editor, KEYS.ai);
|
|
30
|
-
editor.tf.unsetNodes(nodeType, {
|
|
31
|
-
at,
|
|
32
|
-
match: (n) => n[nodeType]
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// src/lib/transforms/removeAINodes.ts
|
|
37
|
-
import { TextApi } from "platejs";
|
|
38
|
-
var removeAINodes = (editor, { at = [] } = {}) => {
|
|
39
|
-
editor.tf.removeNodes({
|
|
40
|
-
at,
|
|
41
|
-
match: (n) => TextApi.isText(n) && !!n.ai
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// src/lib/transforms/undoAI.ts
|
|
46
|
-
import { getTransientSuggestionKey } from "@platejs/suggestion";
|
|
47
|
-
var undoAI = (editor) => {
|
|
48
|
-
const hasAINodeOrAISuggestion = editor.api.some({
|
|
49
|
-
at: [],
|
|
50
|
-
match: (n) => !!n.ai
|
|
51
|
-
}) || editor.api.some({
|
|
52
|
-
at: [],
|
|
53
|
-
match: (n) => !!n[getTransientSuggestionKey()]
|
|
54
|
-
});
|
|
55
|
-
if (editor.history.undos.at(-1)?.ai && hasAINodeOrAISuggestion) {
|
|
56
|
-
editor.undo();
|
|
57
|
-
editor.history.redos.pop();
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
// src/lib/transforms/withAIBatch.ts
|
|
62
|
-
var withAIBatch = (editor, fn, {
|
|
63
|
-
split
|
|
64
|
-
} = {}) => {
|
|
65
|
-
if (split) {
|
|
66
|
-
editor.tf.withNewBatch(fn);
|
|
67
|
-
} else {
|
|
68
|
-
editor.tf.withMerging(fn);
|
|
69
|
-
}
|
|
70
|
-
const lastBatch = editor.history.undos?.at(-1);
|
|
71
|
-
if (lastBatch) {
|
|
72
|
-
lastBatch.ai = true;
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// src/lib/BaseAIPlugin.ts
|
|
77
|
-
var BaseAIPlugin = createTSlatePlugin({
|
|
78
|
-
key: KEYS2.ai,
|
|
79
|
-
node: { isDecoration: false, isLeaf: true }
|
|
80
|
-
}).extendTransforms(({ editor }) => ({
|
|
81
|
-
insertNodes: bindFirst(insertAINodes, editor),
|
|
82
|
-
removeMarks: bindFirst(removeAIMarks, editor),
|
|
83
|
-
removeNodes: bindFirst(removeAINodes, editor),
|
|
84
|
-
undo: bindFirst(undoAI, editor)
|
|
85
|
-
}));
|
|
86
|
-
|
|
87
|
-
// src/lib/utils/getEditorPrompt.ts
|
|
88
|
-
import { isSelecting } from "@platejs/selection";
|
|
89
|
-
import { KEYS as KEYS3 } from "platejs";
|
|
90
|
-
var createPromptFromConfig = (config, params) => {
|
|
91
|
-
const { isBlockSelecting, isSelecting: isSelecting2 } = params;
|
|
92
|
-
if (isBlockSelecting && config.blockSelecting) {
|
|
93
|
-
return config.blockSelecting ?? config.default;
|
|
94
|
-
} else if (isSelecting2 && config.selecting) {
|
|
95
|
-
return config.selecting ?? config.default;
|
|
96
|
-
} else {
|
|
97
|
-
return config.default;
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
var getEditorPrompt = (editor, {
|
|
101
|
-
prompt = ""
|
|
102
|
-
}) => {
|
|
103
|
-
const params = {
|
|
104
|
-
editor,
|
|
105
|
-
isBlockSelecting: editor.getOption(
|
|
106
|
-
{ key: KEYS3.blockSelection },
|
|
107
|
-
"isSelectingSome"
|
|
108
|
-
),
|
|
109
|
-
isSelecting: isSelecting(editor)
|
|
110
|
-
};
|
|
111
|
-
let promptText = "";
|
|
112
|
-
if (typeof prompt === "function") {
|
|
113
|
-
promptText = prompt(params);
|
|
114
|
-
} else if (typeof prompt === "object") {
|
|
115
|
-
promptText = createPromptFromConfig(prompt, params);
|
|
116
|
-
} else {
|
|
117
|
-
promptText = prompt;
|
|
118
|
-
}
|
|
119
|
-
return promptText;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
// src/lib/utils/getMarkdown.ts
|
|
123
|
-
import { serializeMd } from "@platejs/markdown";
|
|
124
|
-
import { KEYS as KEYS4 } from "platejs";
|
|
125
|
-
var getMarkdown = (editor, {
|
|
126
|
-
type
|
|
127
|
-
}) => {
|
|
128
|
-
if (type === "editor" || type === "editorWithBlockId") {
|
|
129
|
-
return serializeMd(editor, {
|
|
130
|
-
withBlockId: type === "editorWithBlockId"
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
if (type === "block" || type === "blockWithBlockId") {
|
|
134
|
-
const blocks = editor.api.blocks({ mode: "highest" }).map(([node]) => node);
|
|
135
|
-
return serializeMd(editor, {
|
|
136
|
-
value: blocks,
|
|
137
|
-
withBlockId: type === "blockWithBlockId"
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
if (type === "blockSelection" || type === "blockSelectionWithBlockId") {
|
|
141
|
-
const fragment = editor.api.fragment();
|
|
142
|
-
if (fragment.length === 1) {
|
|
143
|
-
const modifiedFragment = [
|
|
144
|
-
{
|
|
145
|
-
children: fragment[0].children,
|
|
146
|
-
type: KEYS4.p
|
|
147
|
-
}
|
|
148
|
-
];
|
|
149
|
-
return serializeMd(editor, {
|
|
150
|
-
value: modifiedFragment,
|
|
151
|
-
withBlockId: type === "blockSelectionWithBlockId"
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
return serializeMd(editor, {
|
|
155
|
-
value: fragment,
|
|
156
|
-
withBlockId: type === "blockSelectionWithBlockId"
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
return "";
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
// src/lib/utils/replacePlaceholders.ts
|
|
163
|
-
var replacePlaceholders = (editor, text, {
|
|
164
|
-
prompt
|
|
165
|
-
} = {}) => {
|
|
166
|
-
let result = text.replace("{prompt}", prompt || "");
|
|
167
|
-
const placeholders = {
|
|
168
|
-
"{blockSelectionWithBlockId}": "blockSelectionWithBlockId",
|
|
169
|
-
"{blockSelection}": "blockSelection",
|
|
170
|
-
"{blockWithBlockId}": "blockWithBlockId",
|
|
171
|
-
"{block}": "block",
|
|
172
|
-
"{editorWithBlockId}": "editorWithBlockId",
|
|
173
|
-
"{editor}": "editor"
|
|
174
|
-
};
|
|
175
|
-
Object.entries(placeholders).forEach(([placeholder, type]) => {
|
|
176
|
-
if (result.includes(placeholder)) {
|
|
177
|
-
result = result.replace(placeholder, getMarkdown(editor, { type }));
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
return result;
|
|
181
|
-
};
|
|
182
|
-
export {
|
|
183
|
-
BaseAIPlugin,
|
|
184
|
-
getEditorPrompt,
|
|
185
|
-
getMarkdown,
|
|
186
|
-
insertAINodes,
|
|
187
|
-
removeAIMarks,
|
|
188
|
-
removeAINodes,
|
|
189
|
-
replacePlaceholders,
|
|
190
|
-
undoAI,
|
|
191
|
-
withAIBatch
|
|
192
|
-
};
|
|
193
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/BaseAIPlugin.ts","../src/lib/transforms/insertAINodes.ts","../src/lib/transforms/removeAIMarks.ts","../src/lib/transforms/removeAINodes.ts","../src/lib/transforms/undoAI.ts","../src/lib/transforms/withAIBatch.ts","../src/lib/utils/getEditorPrompt.ts","../src/lib/utils/getMarkdown.ts","../src/lib/utils/replacePlaceholders.ts"],"sourcesContent":["import {\n type OmitFirst,\n type PluginConfig,\n bindFirst,\n createTSlatePlugin,\n KEYS,\n} from 'platejs';\n\nimport { removeAIMarks, undoAI } from './transforms';\nimport { insertAINodes } from './transforms/insertAINodes';\nimport { removeAINodes } from './transforms/removeAINodes';\n\nexport type BaseAIPluginConfig = PluginConfig<\n 'ai',\n {},\n {},\n {\n ai: {\n insertNodes: OmitFirst<typeof insertAINodes>;\n removeMarks: OmitFirst<typeof removeAIMarks>;\n removeNodes: OmitFirst<typeof removeAINodes>;\n };\n }\n>;\n\nexport const BaseAIPlugin = createTSlatePlugin({\n key: KEYS.ai,\n node: { isDecoration: false, isLeaf: true },\n}).extendTransforms(({ editor }) => ({\n insertNodes: bindFirst(insertAINodes, editor),\n removeMarks: bindFirst(removeAIMarks, editor),\n removeNodes: bindFirst(removeAINodes, editor),\n undo: bindFirst(undoAI, editor),\n}));\n","import type { Descendant, Path, SlateEditor } from 'platejs';\n\nexport const insertAINodes = (\n editor: SlateEditor,\n nodes: Descendant[],\n {\n target,\n }: {\n target?: Path;\n } = {}\n) => {\n if (!target && !editor.selection?.focus.path) return;\n\n const aiNodes = nodes.map((node) => ({\n ...node,\n ai: true,\n }));\n\n editor.tf.withoutNormalizing(() => {\n editor.tf.insertNodes(aiNodes, {\n at: editor.api.end(target || editor.selection!.focus.path),\n select: true,\n });\n editor.tf.collapse({ edge: 'end' });\n });\n};\n","import { type SlateEditor, type TLocation, getPluginType, KEYS } from 'platejs';\n\nexport const removeAIMarks = (\n editor: SlateEditor,\n { at = [] }: { at?: TLocation } = {}\n) => {\n const nodeType = getPluginType(editor, KEYS.ai);\n\n editor.tf.unsetNodes(nodeType, {\n at,\n match: (n) => (n as any)[nodeType],\n });\n};\n","import { type Path, type SlateEditor, TextApi } from 'platejs';\n\nexport const removeAINodes = (\n editor: SlateEditor,\n { at = [] }: { at?: Path } = {}\n) => {\n editor.tf.removeNodes({\n at,\n match: (n) => TextApi.isText(n) && !!(n as any).ai,\n });\n};\n","import type { SlateEditor } from 'platejs';\n\nimport { getTransientSuggestionKey } from '@platejs/suggestion';\n\nexport const undoAI = (editor: SlateEditor) => {\n const hasAINodeOrAISuggestion =\n editor.api.some({\n at: [],\n match: (n) => !!(n as any).ai,\n }) ||\n editor.api.some({\n at: [],\n match: (n) => !!n[getTransientSuggestionKey()],\n });\n\n if ((editor.history.undos.at(-1) as any)?.ai && hasAINodeOrAISuggestion) {\n editor.undo();\n editor.history.redos.pop();\n }\n};\n","import type { History, SlateEditor } from 'platejs';\n\nexport type AIBatch = History['undos'][number] & { ai?: boolean };\n\nexport const withAIBatch = (\n editor: SlateEditor,\n fn: () => void,\n {\n split,\n }: {\n split?: boolean;\n } = {}\n) => {\n if (split) {\n editor.tf.withNewBatch(fn);\n } else {\n editor.tf.withMerging(fn);\n }\n\n const lastBatch = editor.history.undos?.at(-1) as AIBatch | undefined;\n\n if (lastBatch) {\n lastBatch.ai = true;\n }\n};\n","import { isSelecting } from '@platejs/selection';\nimport { type SlateEditor, KEYS } from 'platejs';\n\nexport type EditorPrompt =\n | ((params: EditorPromptParams) => string)\n | PromptConfig\n | string;\n\nexport interface EditorPromptParams {\n editor: SlateEditor;\n isBlockSelecting: boolean;\n isSelecting: boolean;\n}\n\nexport interface PromptConfig {\n default: string;\n blockSelecting?: string;\n selecting?: string;\n}\n\nconst createPromptFromConfig = (\n config: PromptConfig,\n params: EditorPromptParams\n): string => {\n const { isBlockSelecting, isSelecting } = params;\n\n if (isBlockSelecting && config.blockSelecting) {\n return config.blockSelecting ?? config.default;\n } else if (isSelecting && config.selecting) {\n return config.selecting ?? config.default;\n } else {\n return config.default;\n }\n};\n\nexport const getEditorPrompt = (\n editor: SlateEditor,\n {\n prompt = '',\n }: {\n prompt?: EditorPrompt;\n }\n): string => {\n const params: EditorPromptParams = {\n editor,\n isBlockSelecting: editor.getOption(\n { key: KEYS.blockSelection },\n 'isSelectingSome'\n ),\n isSelecting: isSelecting(editor),\n };\n\n let promptText = '';\n\n if (typeof prompt === 'function') {\n promptText = prompt(params);\n } else if (typeof prompt === 'object') {\n promptText = createPromptFromConfig(prompt, params);\n } else {\n promptText = prompt;\n }\n\n return promptText;\n};\n","import { serializeMd } from '@platejs/markdown';\nimport { type SlateEditor, type TElement, KEYS } from 'platejs';\n\nimport type { MarkdownType } from './replacePlaceholders';\n\n// Internal\nexport const getMarkdown = (\n editor: SlateEditor,\n {\n type,\n }: {\n type: MarkdownType;\n }\n) => {\n if (type === 'editor' || type === 'editorWithBlockId') {\n return serializeMd(editor, {\n withBlockId: type === 'editorWithBlockId',\n });\n }\n\n if (type === 'block' || type === 'blockWithBlockId') {\n const blocks = editor.api.blocks({ mode: 'highest' }).map(([node]) => node);\n\n return serializeMd(editor, {\n value: blocks,\n withBlockId: type === 'blockWithBlockId',\n });\n }\n\n if (type === 'blockSelection' || type === 'blockSelectionWithBlockId') {\n const fragment = editor.api.fragment<TElement>();\n\n // Remove any block formatting\n if (fragment.length === 1) {\n const modifiedFragment = [\n {\n children: fragment[0].children,\n type: KEYS.p,\n },\n ];\n\n return serializeMd(editor, {\n value: modifiedFragment,\n withBlockId: type === 'blockSelectionWithBlockId',\n });\n }\n\n return serializeMd(editor, {\n value: fragment,\n withBlockId: type === 'blockSelectionWithBlockId',\n });\n }\n\n return '';\n};\n","import type { SlateEditor } from 'platejs';\n\nimport { getMarkdown } from './getMarkdown';\n\nexport type MarkdownType =\n | 'block'\n | 'blockSelection'\n | 'blockSelectionWithBlockId'\n | 'blockWithBlockId'\n | 'editor'\n | 'editorWithBlockId';\n\nexport const replacePlaceholders = (\n editor: SlateEditor,\n text: string,\n {\n prompt,\n }: {\n prompt?: string;\n } = {}\n): string => {\n let result = text.replace('{prompt}', prompt || '');\n\n const placeholders: Record<string, MarkdownType> = {\n '{blockSelectionWithBlockId}': 'blockSelectionWithBlockId',\n '{blockSelection}': 'blockSelection',\n '{blockWithBlockId}': 'blockWithBlockId',\n '{block}': 'block',\n '{editorWithBlockId}': 'editorWithBlockId',\n '{editor}': 'editor',\n };\n\n Object.entries(placeholders).forEach(([placeholder, type]) => {\n if (result.includes(placeholder)) {\n result = result.replace(placeholder, getMarkdown(editor, { type }));\n }\n });\n\n return result;\n};\n"],"mappings":";AAAA;AAAA,EAGE;AAAA,EACA;AAAA,EACA,QAAAA;AAAA,OACK;;;ACJA,IAAM,gBAAgB,CAC3B,QACA,OACA;AAAA,EACE;AACF,IAEI,CAAC,MACF;AACH,MAAI,CAAC,UAAU,CAAC,OAAO,WAAW,MAAM,KAAM;AAE9C,QAAM,UAAU,MAAM,IAAI,CAAC,UAAU;AAAA,IACnC,GAAG;AAAA,IACH,IAAI;AAAA,EACN,EAAE;AAEF,SAAO,GAAG,mBAAmB,MAAM;AACjC,WAAO,GAAG,YAAY,SAAS;AAAA,MAC7B,IAAI,OAAO,IAAI,IAAI,UAAU,OAAO,UAAW,MAAM,IAAI;AAAA,MACzD,QAAQ;AAAA,IACV,CAAC;AACD,WAAO,GAAG,SAAS,EAAE,MAAM,MAAM,CAAC;AAAA,EACpC,CAAC;AACH;;;ACzBA,SAA2C,eAAe,YAAY;AAE/D,IAAM,gBAAgB,CAC3B,QACA,EAAE,KAAK,CAAC,EAAE,IAAwB,CAAC,MAChC;AACH,QAAM,WAAW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