platejs 54.0.0-beta.6 → 54.0.0-beta.7
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/{AIChatRequestContext-BYpGufVe.d.ts → AIChatRequestContext-DVGOeWhQ.d.ts} +2 -2
- package/dist/{BaseSuggestionPlugin-C52LR8RN.d.ts → BaseSuggestionPlugin-BRFMMyEo.d.ts} +8 -7
- package/dist/{PlateStatic-DMClx-tH.d.ts → PlateStatic-DIwBAVqF.d.ts} +3 -3
- package/dist/ai/index.d.ts +1 -1
- package/dist/ai/react/AIChatPlugin.js +12 -6
- package/dist/ai/react/CopilotPlugin.js +10 -5
- package/dist/ai/react/index.d.ts +94 -82
- package/dist/ai/react/useAIChat.js +41 -36
- package/dist/authored/index.d.ts +4 -4
- package/dist/code-block/codemirror/index.d.ts +1 -1
- package/dist/{combobox-DgYdu5mZ.d.ts → combobox-CfCJYKT0.d.ts} +2 -2
- package/dist/{comparison-types-DBQFu7Rt-DYc2TC2H.d.ts → comparison-types-CsmDG5r2-z1s4gX06.d.ts} +1 -1
- package/dist/compiler/index.d.ts +2 -2
- package/dist/{core-CQKT9eNc.d.ts → core-Cqc_KzpG.d.ts} +409 -472
- package/dist/core.js +1 -2
- package/dist/diff/index.d.ts +2 -2
- package/dist/docs/annotations.md +37 -120
- package/dist/docs/api/core/plate-components.md +5 -4
- package/dist/docs/api/core/plate-plugin.md +1 -1
- package/dist/docs/api/core/plate-store.md +5 -5
- package/dist/docs/api/core.md +31 -64
- package/dist/docs/api/document-change.md +21 -0
- package/dist/docs/api/editor-api.md +19 -16
- package/dist/docs/api/editor-transforms.md +27 -8
- package/dist/docs/api/react-hooks.md +103 -130
- package/dist/docs/authored-changes.md +12 -13
- package/dist/docs/board.md +45 -35
- package/dist/docs/clipboard.md +11 -7
- package/dist/docs/decorations.md +3 -4
- package/dist/docs/dnd.md +1 -1
- package/dist/docs/docx.md +6 -4
- package/dist/docs/editor-methods.md +7 -16
- package/dist/docs/editor.md +22 -66
- package/dist/docs/field.md +120 -54
- package/dist/docs/find.md +36 -28
- package/dist/docs/footnote.md +14 -8
- package/dist/docs/history.md +166 -12
- package/dist/docs/ink.md +231 -0
- package/dist/docs/installation/plate-ui.md +16 -0
- package/dist/docs/llms.txt +5 -5
- package/dist/docs/markdown.md +4 -3
- package/dist/docs/roots.md +92 -28
- package/dist/docs/schema.md +5 -3
- package/dist/docs/suggestion.md +27 -14
- package/dist/docs/table.md +2 -2
- package/dist/docs/toc.md +2 -2
- package/dist/docx/export/index.d.ts +3 -3
- package/dist/docx/export/lib/comments.js +124 -44
- package/dist/docx/export/lib/exportDocx.js +31 -22
- package/dist/docx/export/lib/hostIndex.js +92 -0
- package/dist/docx/export/lib/reviewProjection.js +154 -55
- package/dist/docx/import/index.d.ts +4 -4
- package/dist/docx/paste/index.d.ts +4 -4
- package/dist/dom/index.d.ts +2 -2
- package/dist/dom/plite-dom.internal.js +2 -2
- package/dist/excalidraw/index.d.ts +3 -3
- package/dist/excalidraw/react/index.d.ts +3 -3
- package/dist/facade.js +3 -3
- package/dist/features/basic-nodes/lib/BaseHeadingPlugins.js +4 -2
- package/dist/features/basic-styles/lib/BaseFormattingPlugin.js +5 -2
- package/dist/features/board/index.d.ts +2 -2
- package/dist/features/board/index.js +2 -1
- package/dist/features/board/lib/BaseBoardPlugin.js +80 -22
- package/dist/features/board/lib/BaseBoardTextPlugin.js +12 -0
- package/dist/features/board/lib/boardArrow.internal.js +2 -2
- package/dist/features/board/lib/boardHeights.internal.js +57 -0
- package/dist/features/board/lib/boardHtml.internal.js +18 -1
- package/dist/features/board/lib/boardMember.internal.js +2 -2
- package/dist/features/board/lib/boardShape.internal.js +6 -1
- package/dist/features/board/lib/boardStyle.internal.js +5 -1
- package/dist/features/board/lib/boardTypes.internal.js +4 -1
- package/dist/features/callout/index.d.ts +3 -3
- package/dist/features/combobox/index.d.ts +2 -2
- package/dist/features/comments/BaseCommentsPlugin.js +47 -227
- package/dist/features/comments/comment-thread-index.internal.js +822 -0
- package/dist/features/comments/index.d.ts +2 -2
- package/dist/features/date/index.d.ts +3 -3
- package/dist/features/details/index.d.ts +3 -3
- package/dist/features/field/index.d.ts +2 -2
- package/dist/features/field/lib/BaseFieldPlugin.js +148 -51
- package/dist/features/field/lib/applyFieldValues.js +45 -26
- package/dist/features/field/lib/fieldRules.internal.js +518 -100
- package/dist/features/find/index.d.ts +15 -16
- package/dist/features/find/lib/BaseFindPlugin.js +871 -123
- package/dist/features/footnote/index.d.ts +1 -1
- package/dist/features/footnote/lib/BaseFootnotePlugin.js +35 -15
- package/dist/features/ink/index.d.ts +2 -2
- package/dist/features/ink/lib/BaseInkPlugin.js +411 -50
- package/dist/features/ink/lib/inkAnchor.internal.js +436 -0
- package/dist/features/ink/lib/inkGone.internal.js +8 -6
- package/dist/features/ink/lib/inkMatch.internal.js +262 -51
- package/dist/features/ink/lib/inkPlaces.internal.js +67 -26
- package/dist/features/ink/lib/inkReflow.internal.js +406 -0
- package/dist/features/layout/index.d.ts +1 -1
- package/dist/features/lint/index.d.ts +16 -16
- package/dist/features/list/lib/BaseListPlugin.js +2 -1
- package/dist/features/media/index.d.ts +1 -1
- package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +2 -1
- package/dist/features/mention/index.d.ts +5 -5
- package/dist/features/suggestion/index.d.ts +1 -1
- package/dist/features/table/index.d.ts +1 -1
- package/dist/features/table/lib/BaseTablePlugin.js +284 -142
- package/dist/features/toc/index.d.ts +1 -1
- package/dist/features/upload/index.d.ts +1 -1
- package/dist/features/upload/lib/BaseUploadPlugin.js +5 -4
- package/dist/history/index.d.ts +3 -3
- package/dist/history/index.js +2 -1
- package/dist/html/index.d.ts +3 -3
- package/dist/html/server/index.d.ts +1 -1
- package/dist/{htmlTypes-8IFX0ezP.d.ts → htmlTypes-i_FBCMf2.d.ts} +2 -2
- package/dist/hyperscript/index.d.ts +1 -1
- package/dist/{index-Cp0QfjUV.d.ts → index-1PlYsibA.d.ts} +11 -12
- package/dist/{index-DbPoiwq_.d.ts → index-1rcWTB-o.d.ts} +3 -3
- package/dist/{index-C-5w6252.d.ts → index-B4ZhSQdk.d.ts} +41 -41
- package/dist/{index-DE1Mcccg.d.ts → index-BI0NS7kx.d.ts} +3 -3
- package/dist/{index-BIP1GoWI.d.ts → index-BWCC4DCP.d.ts} +2 -12
- package/dist/{index-D2w_9_tb.d.ts → index-Bv13FX9o.d.ts} +32 -32
- package/dist/{index-BTFrh2Cz.d.ts → index-By7BkzIN.d.ts} +2 -2
- package/dist/{index-B4oeyc99.d.ts → index-CJGkjkH6.d.ts} +1 -1
- package/dist/{index-BBsiQIzw.d.ts → index-CLNem74G.d.ts} +25 -8
- package/dist/{index-CrUMAwqm.d.ts → index-CS4G_W_R.d.ts} +1 -5
- package/dist/{index-PDROnF1G-Ds_dbJsr.d.ts → index-CTTjpWgb-Fdrn8NP4.d.ts} +1 -1
- package/dist/{index-BapA_uvI.d.ts → index-CVAHIQ3p.d.ts} +5 -5
- package/dist/{index-DUk2VZ_1.d.ts → index-Cc2ajXAd.d.ts} +7 -7
- package/dist/{index-BfHCmKG3.d.ts → index-CmISVYmz.d.ts} +127 -79
- package/dist/{index-BAz_KJSV.d.ts → index-CrJ9Km8W.d.ts} +2 -2
- package/dist/{index-Dh7pWHZo.d.ts → index-CxG1Atvg.d.ts} +298 -38
- package/dist/{index-BcuSI8EM.d.ts → index-DNXr_SN-.d.ts} +9 -7
- package/dist/{index-BbsVGwn8.d.ts → index-DfkFmApH.d.ts} +303 -387
- package/dist/{index-AOVPovEr.d.ts → index-KteL56rA.d.ts} +211 -224
- package/dist/{index-DM6z4D7q.d.ts → index-OMa7dlcS.d.ts} +35 -33
- package/dist/{index-DFMkcY5V.d.ts → index-uVbqCpDa.d.ts} +149 -130
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -2
- package/dist/internal/plugin/compilePlateModel.js +15 -1
- package/dist/internal/plugin/plateChangeHandlers.js +1 -1
- package/dist/internal/plugin/resolvePlugin.js +10 -1
- package/dist/lib/editor/withPlite.js +33 -3
- package/dist/lib/plugins/dom/DOMPlugin.js +6 -2
- package/dist/lib/plugins/html/HtmlPlugin.js +5 -3
- package/dist/lib/plugins/input-rules/createInputRules.js +3 -3
- package/dist/lib/utils/getInjectMatch.js +1 -1
- package/dist/markdown/index.d.ts +1 -1
- package/dist/markdown/lib/deserializer/convertNodesDeserialize.js +2 -2
- package/dist/markdown/lib/internal/markdownConversion.js +7 -17
- package/dist/math/index.d.ts +3 -3
- package/dist/math/react/index.d.ts +4 -4
- package/dist/migrations/documentMigrations.js +23 -5
- package/dist/migrations/index.d.ts +3 -3
- package/dist/migrations/migratePlateV54Ast.internal.js +4 -1
- package/dist/migrations/migratePlateV54Profile.internal.js +0 -4
- package/dist/pagination/index.d.ts +1 -1
- package/dist/pagination/react/PagedEditorContent.js +6 -6
- package/dist/pagination/react/index.d.ts +16 -13
- package/dist/react/components/NodeSelection.js +129 -50
- package/dist/react/components/Plate.js +142 -119
- package/dist/react/components/PlateContainer.js +51 -47
- package/dist/react/components/PlateContent.js +3 -3
- package/dist/react/core.js +3 -4
- package/dist/react/editor/getPlateCorePlugins.internal.js +1 -1
- package/dist/react/editor/withPlate.js +10 -4
- package/dist/react/features/board/BoardPlugin.js +7 -1
- package/dist/react/features/board/BoardShape.js +214 -159
- package/dist/react/features/board/BoardSurface.js +2 -2
- package/dist/react/features/board/boardExport.internal.js +225 -80
- package/dist/react/features/board/boardGesture.internal.js +193 -33
- package/dist/react/features/board/boardIndex.internal.js +271 -26
- package/dist/react/features/board/boardKeys.internal.js +7 -3
- package/dist/react/features/board/boardPick.internal.js +3 -2
- package/dist/react/features/board/boardPreview.internal.js +56 -8
- package/dist/react/features/board/boardResize.internal.js +110 -28
- package/dist/react/features/board/boardSnap.internal.js +14 -9
- package/dist/react/features/board/boardView.internal.js +440 -24
- package/dist/react/features/board/boardVoice.internal.js +1 -0
- package/dist/react/features/board/index.d.ts +322 -42
- package/dist/react/features/board/index.js +2 -2
- package/dist/react/features/callout/index.d.ts +3 -3
- package/dist/react/features/combobox/index.d.ts +5 -5
- package/dist/react/features/comments/index.d.ts +66 -65
- package/dist/react/features/date/index.d.ts +4 -4
- package/dist/react/features/details/index.d.ts +5 -5
- package/dist/react/features/field/FieldPlugin.js +3 -3
- package/dist/react/features/field/index.d.ts +72 -92
- package/dist/react/features/footnote/index.d.ts +63 -60
- package/dist/react/features/format-painter/index.d.ts +4 -4
- package/dist/react/features/ink/InkContent.js +79 -51
- package/dist/react/features/ink/InkCopyView.js +13 -2
- package/dist/react/features/ink/InkPlugin.js +44 -10
- package/dist/react/features/ink/index.d.ts +217 -307
- package/dist/react/features/ink/inkCapture.internal.js +3 -1
- package/dist/react/features/ink/inkImages.internal.js +263 -0
- package/dist/react/features/ink/inkMeasure.internal.js +24 -11
- package/dist/react/features/ink/inkPaint.internal.js +31 -23
- package/dist/react/features/ink/inkPick.internal.js +45 -20
- package/dist/react/features/ink/inkPlacement.internal.js +182 -37
- package/dist/react/features/layout/index.d.ts +6 -6
- package/dist/react/features/list/ListPlugin.js +10 -6
- package/dist/react/features/media/index.d.ts +26 -26
- package/dist/react/features/mention/index.d.ts +6 -6
- package/dist/react/features/suggestion/index.d.ts +6 -6
- package/dist/react/features/suggestion/suggestion-view.internal.js +38 -36
- package/dist/react/features/suggestion/useSuggestion.js +17 -14
- package/dist/react/features/table/TablePlugin.js +12 -5
- package/dist/react/features/table/index.d.ts +20 -22
- package/dist/react/features/table/useTableResize.js +4 -4
- package/dist/react/features/toc/index.d.ts +2 -2
- package/dist/react/features/upload/index.d.ts +44 -44
- package/dist/react/index.d.ts +5 -6
- package/dist/react/index.js +3 -4
- package/dist/react/internal/plate-context.js +13 -42
- package/dist/react/internal/plite-components.js +2 -2
- package/dist/react/internal/usePlateModelRevision.js +2 -3
- package/dist/react/plite-react.js +2 -2
- package/dist/react/stores/element/useElementStore.js +78 -52
- package/dist/react/stores/plate/useEditor.js +70 -32
- package/dist/react/stores/plate/useEditorSelector.js +193 -53
- package/dist/react/utils/BlockPlaceholderPlugin.js +10 -4
- package/dist/react/virtualized.d.ts +4 -4
- package/dist/react/virtualized.js +2 -2
- package/dist/root.js +1 -2
- package/dist/{source-D5CyclpX.d.ts → source-Dcgqj5Mf.d.ts} +3 -3
- package/dist/static/components/PlateStatic.js +13 -2
- package/dist/static/index.d.ts +6 -6
- package/dist/static/internal/staticDocumentView.js +67 -1
- package/dist/static/pluginRenderTextStatic.internal.js +2 -1
- package/dist/tabbable/index.d.ts +1 -1
- package/dist/tabbable/react/index.d.ts +3 -3
- package/dist/testing/index.d.ts +2 -2
- package/dist/{index-DHt8nZQ6-NUTahb8N.d.ts → tx-only-1FM45FSj-D40jacZv.d.ts} +6913 -6640
- package/dist/yjs/index.d.ts +1 -1
- package/dist/yjs/react/index.d.ts +5 -5
- package/package.json +2 -6
- package/dist/docs/migration/plite-to-plate.md +0 -352
- package/dist/features/comments/plite-comments.internal.js +0 -2
- package/dist/index-BvQzYVAW-Jvz2iG8B.d.ts +0 -65
- package/dist/lib/plugins/element-id/ElementIdPlugin.js +0 -43
- package/dist/lib/plugins/element-id/elementIdAdmission.internal.js +0 -34
- package/dist/react/libs/jotai.js +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./core-
|
|
1
|
+
import { Wa as NodeSelectionMode, Yc as Selection, bs as Range, oo as Path, xu as Value } from "./tx-only-1FM45FSj-D40jacZv.js";
|
|
2
|
+
import "./core-Cqc_KzpG.js";
|
|
3
3
|
type AIToolName = 'comment' | 'edit' | 'generate' | null;
|
|
4
4
|
/** Request-local reference into `AIChatRequestContext.children`. */
|
|
5
5
|
type AIChatRequestNodeRef = Readonly<{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./htmlTypes-
|
|
3
|
-
import {
|
|
4
|
-
import { S as AuthoredView, _ as AuthoredPlugin, b as AuthoredResult, c as AuthoredDecision, h as AuthoredPage, m as AuthoredOutcome, n as AuthoredChangeDetails, o as AuthoredChangesDelta, r as AuthoredChangeGroup, t as AuthoredChange, u as AuthoredGroupDetails, v as AuthoredQuery, x as AuthoredReview, y as AuthoredRefusal } from "./index-
|
|
1
|
+
import { Aa as NodeKey, bu as TxOnlyMethod, po as Plugin, ta as Location, vu as TxDeclaredMethod } from "./tx-only-1FM45FSj-D40jacZv.js";
|
|
2
|
+
import "./htmlTypes-i_FBCMf2.js";
|
|
3
|
+
import { $i as BasePluginDependencyReferenceFor, H as InternalBasePluginRuntimeExtension, go as PluginReference, mo as PluginDependency, v as BasePlugin } from "./core-Cqc_KzpG.js";
|
|
4
|
+
import { S as AuthoredView, _ as AuthoredPlugin, b as AuthoredResult, c as AuthoredDecision, h as AuthoredPage, m as AuthoredOutcome, n as AuthoredChangeDetails, o as AuthoredChangesDelta, r as AuthoredChangeGroup, t as AuthoredChange, u as AuthoredGroupDetails, v as AuthoredQuery, x as AuthoredReview, y as AuthoredRefusal } from "./index-CLNem74G.js";
|
|
5
5
|
/** Paints each node's pending authored changes as `data-editor-authored-*` attributes. */
|
|
6
6
|
declare const BaseSuggestionPlugin: BasePlugin<Readonly<{
|
|
7
7
|
inject: true;
|
|
@@ -29,6 +29,7 @@ declare const BaseSuggestionPlugin: BasePlugin<Readonly<{
|
|
|
29
29
|
}>) => readonly AuthoredChangeGroup[];
|
|
30
30
|
groupOf: (changeId: string) => AuthoredChangeGroup | null;
|
|
31
31
|
outcome: (id: string) => AuthoredOutcome | null;
|
|
32
|
+
gridLocked: (node: unknown) => boolean;
|
|
32
33
|
reviewOf: (node: unknown) => AuthoredReview;
|
|
33
34
|
}>> & Readonly<Record<"update", {
|
|
34
35
|
decide: TxDeclaredMethod<(decisions: AuthoredDecision | readonly AuthoredDecision[]) => AuthoredResult>;
|
|
@@ -49,7 +50,7 @@ declare const BaseSuggestionPlugin: BasePlugin<Readonly<{
|
|
|
49
50
|
};
|
|
50
51
|
};
|
|
51
52
|
}> & Readonly<{
|
|
52
|
-
name: "
|
|
53
|
+
name: "authoredRecords";
|
|
53
54
|
}>>>, "enabled" | "name">> & PluginDependency<never>];
|
|
54
55
|
}>> & Pick<InternalBasePluginRuntimeExtension<BasePlugin<Readonly<{}> & Readonly<{
|
|
55
56
|
name: "authored";
|
|
@@ -66,7 +67,7 @@ declare const BaseSuggestionPlugin: BasePlugin<Readonly<{
|
|
|
66
67
|
};
|
|
67
68
|
};
|
|
68
69
|
}> & Readonly<{
|
|
69
|
-
name: "
|
|
70
|
+
name: "authoredRecords";
|
|
70
71
|
}>>>];
|
|
71
72
|
}> & Readonly<Record<never, never>>>, Readonly<{}> & Readonly<{
|
|
72
73
|
name: "authored";
|
|
@@ -83,7 +84,7 @@ declare const BaseSuggestionPlugin: BasePlugin<Readonly<{
|
|
|
83
84
|
};
|
|
84
85
|
};
|
|
85
86
|
}> & Readonly<{
|
|
86
|
-
name: "
|
|
87
|
+
name: "authoredRecords";
|
|
87
88
|
}>>>];
|
|
88
89
|
}> & Readonly<Record<never, never>>, AuthoredPlugin>, "~schema.plugins">];
|
|
89
90
|
}> & Readonly<Record<never, never>>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Tt as EditorDocumentValue } from "./
|
|
2
|
-
import "./htmlTypes-
|
|
3
|
-
import { u as Editor } from "./core-
|
|
1
|
+
import { Tt as EditorDocumentValue } from "./tx-only-1FM45FSj-D40jacZv.js";
|
|
2
|
+
import "./htmlTypes-i_FBCMf2.js";
|
|
3
|
+
import { u as Editor } from "./core-Cqc_KzpG.js";
|
|
4
4
|
import React$1 from "react";
|
|
5
5
|
type EditorStaticProps<E = Editor> = {
|
|
6
6
|
/**
|
package/dist/ai/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as AIToolName, i as AIChatRequestRefs, n as AIChatRequestNodeRef, o as resolveAIChatRequestContext, r as AIChatRequestNodeSelection, t as AIChatRequestContext } from "../AIChatRequestContext-
|
|
1
|
+
import { a as AIToolName, i as AIChatRequestRefs, n as AIChatRequestNodeRef, o as resolveAIChatRequestContext, r as AIChatRequestNodeSelection, t as AIChatRequestContext } from "../AIChatRequestContext-DVGOeWhQ.js";
|
|
2
2
|
export { AIChatRequestContext, AIChatRequestNodeRef, AIChatRequestNodeSelection, AIChatRequestRefs, AIToolName, resolveAIChatRequestContext };
|
|
@@ -161,7 +161,8 @@ const AIChatPlugin = definePlugin(PLUGINS.aiChat, {
|
|
|
161
161
|
const selectionPath = state.selection.nodes().at(-1)?.[1] ?? selection?.focus.path;
|
|
162
162
|
const path = generated?.[1] ?? selectionPath?.slice(0, 1) ?? [0];
|
|
163
163
|
const entry = state.nodes.get(path, { match: ElementApi.isElement });
|
|
164
|
-
const
|
|
164
|
+
const columnGroupSchema = columnGroup?.schema;
|
|
165
|
+
const containerTypes = /* @__PURE__ */ new Set([...columnGroupSchema && "type" in columnGroupSchema ? [columnGroupSchema.type] : [], ...tablePlugin.installed ? [tablePlugin.schema.type] : []]);
|
|
165
166
|
return entry && containerTypes.has(entry[0].type) ? state.nodes.above()?.[1] ?? path : path;
|
|
166
167
|
};
|
|
167
168
|
const getInsertStart = (state) => {
|
|
@@ -212,11 +213,16 @@ const AIChatPlugin = definePlugin(PLUGINS.aiChat, {
|
|
|
212
213
|
const view = projectEditorView(editor, root ? { root } : {});
|
|
213
214
|
const { chatNodes } = context.store.get();
|
|
214
215
|
const restored = suggestionTarget.paths.map((path) => view.read.nodes.get(path, { match: ElementApi.isElement })?.[0]);
|
|
215
|
-
if (restored.length !== chatNodes.length
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
216
|
+
if (restored.length !== chatNodes.length) return;
|
|
217
|
+
const nextChatNodes = chatNodes.flatMap((chatNode, index) => {
|
|
218
|
+
const node = restored[index];
|
|
219
|
+
return node && node.type === chatNode.node.type && NodeApi.string(node) === NodeApi.string(chatNode.node) ? [{
|
|
220
|
+
...chatNode,
|
|
221
|
+
nodeKey: view.key(node)
|
|
222
|
+
}] : [];
|
|
223
|
+
});
|
|
224
|
+
if (nextChatNodes.length !== chatNodes.length) return;
|
|
225
|
+
context.store.set({ chatNodes: nextChatNodes });
|
|
220
226
|
};
|
|
221
227
|
const withReviewRecords = (blocks) => {
|
|
222
228
|
const { records } = editor.read.value();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { subscribeSharedEditorViewState } from "../../facade.js";
|
|
2
3
|
import { PLUGINS } from "../../utils/plate-keys.js";
|
|
3
4
|
import { NodeApi, RangeApi, defineEffect, defineStateField, editorCommands, locateAt, txLocate } from "../../core.js";
|
|
4
|
-
import { useEditorViewState } from "../../react/plite-react.js";
|
|
5
5
|
import { definePlugin } from "../../react/plugin/definePlugin.js";
|
|
6
6
|
import { MarkdownPlugin } from "../../markdown/lib/MarkdownPlugin.js";
|
|
7
7
|
import { AIChatPlugin } from "./AIChatPlugin.js";
|
|
@@ -304,7 +304,6 @@ const CopilotPlugin = definePlugin(PLUGINS.copilot, {
|
|
|
304
304
|
debouncedTrigger = context.store.get().debounceDelay ? debounce(triggerImmediately, context.store.get().debounceDelay) : null;
|
|
305
305
|
return {
|
|
306
306
|
slots: { wrapRoot: function CopilotIntegration({ children, editableRef }) {
|
|
307
|
-
useEditorViewState(context.editor, (view) => view.isReadOnly());
|
|
308
307
|
const attachment = React.useRef(null);
|
|
309
308
|
React.useLayoutEffect(() => {
|
|
310
309
|
const element = editableRef.current;
|
|
@@ -317,9 +316,15 @@ const CopilotPlugin = definePlugin(PLUGINS.copilot, {
|
|
|
317
316
|
}
|
|
318
317
|
if (!isWritable()) stop();
|
|
319
318
|
});
|
|
320
|
-
React.useLayoutEffect(() =>
|
|
321
|
-
|
|
322
|
-
|
|
319
|
+
React.useLayoutEffect(() => {
|
|
320
|
+
const unsubscribeReadOnly = subscribeSharedEditorViewState(context.editor, "readOnly", () => {
|
|
321
|
+
if (!isWritable()) stop();
|
|
322
|
+
});
|
|
323
|
+
return () => {
|
|
324
|
+
unsubscribeReadOnly();
|
|
325
|
+
attachment.current?.detach();
|
|
326
|
+
attachment.current = null;
|
|
327
|
+
};
|
|
323
328
|
}, []);
|
|
324
329
|
return children;
|
|
325
330
|
} },
|
package/dist/ai/react/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../../htmlTypes-
|
|
3
|
-
import {
|
|
4
|
-
import { c as
|
|
5
|
-
import { a as AIToolName } from "../../AIChatRequestContext-
|
|
6
|
-
import {
|
|
7
|
-
import { O as MarkdownSyncPlugin, d as Unsafe, i as MarkdownEditor, l as Handle, n as MarkdownApi, u as Join } from "../../index-
|
|
8
|
-
import { S as AuthoredView, _ as AuthoredPlugin, b as AuthoredResult, c as AuthoredDecision, h as AuthoredPage, m as AuthoredOutcome, n as AuthoredChangeDetails, o as AuthoredChangesDelta, r as AuthoredChangeGroup, t as AuthoredChange, u as AuthoredGroupDetails, v as AuthoredQuery, x as AuthoredReview, y as AuthoredRefusal } from "../../index-
|
|
9
|
-
import "../../index-
|
|
1
|
+
import { Aa as NodeKey, Ho as PluginReference, Ko as PluginTypeProvider, Oi as Element, Wa as NodeSelectionMode, b as BasePoint, ba as NodeEntry, bs as Range, bu as TxOnlyMethod, fa as Node, oo as Path, pn as EditorReadMethodTree, po as Plugin, rn as EditorNodesOptions, ta as Location, v as BaseElement, vu as TxDeclaredMethod, xu as Value, zi as HistoryApi } from "../../tx-only-1FM45FSj-D40jacZv.js";
|
|
2
|
+
import "../../htmlTypes-i_FBCMf2.js";
|
|
3
|
+
import { $i as BasePluginDependencyReferenceFor, Ba as DefinitionOf, H as InternalBasePluginRuntimeExtension, Ji as HistoryPluginState, go as PluginReference$1, mo as PluginDependency, v as BasePlugin, yo as PluginSchemaDeclaration } from "../../core-Cqc_KzpG.js";
|
|
4
|
+
import { c as HistoryStateApi, l as HistoryTxApi, n as History, s as HistoryPluginTypeProvider } from "../../index-BWCC4DCP.js";
|
|
5
|
+
import { a as AIToolName } from "../../AIChatRequestContext-DVGOeWhQ.js";
|
|
6
|
+
import { kt as Plugin$1, n as InternalReactEditorWithInstalledPlugins, t as Editor, xt as InternalPluginAuthorExtension } from "../../index-DfkFmApH.js";
|
|
7
|
+
import { O as MarkdownSyncPlugin, d as Unsafe, i as MarkdownEditor, l as Handle, n as MarkdownApi, u as Join } from "../../index-Cc2ajXAd.js";
|
|
8
|
+
import { S as AuthoredView, _ as AuthoredPlugin, b as AuthoredResult, c as AuthoredDecision, h as AuthoredPage, m as AuthoredOutcome, n as AuthoredChangeDetails, o as AuthoredChangesDelta, r as AuthoredChangeGroup, t as AuthoredChange, u as AuthoredGroupDetails, v as AuthoredQuery, x as AuthoredReview, y as AuthoredRefusal } from "../../index-CLNem74G.js";
|
|
9
|
+
import "../../index-CVAHIQ3p.js";
|
|
10
10
|
import * as React from "react";
|
|
11
11
|
import React$1 from "react";
|
|
12
12
|
import { ChatRequestOptions, ChatStatus, ChatTransport, DataUIPart, UIMessage } from "ai";
|
|
@@ -193,6 +193,7 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
193
193
|
readonly [x: string]: unknown;
|
|
194
194
|
readonly text: string;
|
|
195
195
|
})[];
|
|
196
|
+
readonly id?: string;
|
|
196
197
|
readonly type: string;
|
|
197
198
|
};
|
|
198
199
|
readonly nodeKey: NodeKey;
|
|
@@ -206,6 +207,7 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
206
207
|
readonly [x: string]: unknown;
|
|
207
208
|
readonly text: string;
|
|
208
209
|
})[];
|
|
210
|
+
readonly id?: string;
|
|
209
211
|
readonly type: string;
|
|
210
212
|
}[];
|
|
211
213
|
readonly streaming: boolean;
|
|
@@ -219,9 +221,6 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
219
221
|
}> & Readonly<{
|
|
220
222
|
__pluginWritableProperties: never;
|
|
221
223
|
}> & Readonly<Record<"api", MarkdownApi<Value>>> & Readonly<Record<never, never>>> & Pick<BasePlugin<Readonly<{
|
|
222
|
-
readonly name: "markdown";
|
|
223
|
-
readonly api: MarkdownApi<Value>;
|
|
224
|
-
readonly dataTransferFormats: true;
|
|
225
224
|
readonly initialState: {
|
|
226
225
|
readonly plainMarks: readonly string[] | null;
|
|
227
226
|
readonly remarkPlugins: readonly (MarkdownSyncPlugin<readonly never[]> | readonly [MarkdownSyncPlugin<readonly never[]>, ...unknown[]])[];
|
|
@@ -282,6 +281,9 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
282
281
|
readonly unsafe?: readonly Unsafe[] | null | undefined;
|
|
283
282
|
} | null;
|
|
284
283
|
};
|
|
284
|
+
readonly name: "markdown";
|
|
285
|
+
readonly api: MarkdownApi<Value>;
|
|
286
|
+
readonly dataTransferFormats: true;
|
|
285
287
|
readonly validate: true;
|
|
286
288
|
}>> & Readonly<Record<never, never>>, "~schema.plugins">, PluginReference$1<"authored"> & PluginDependency<Readonly<{
|
|
287
289
|
name: "authored";
|
|
@@ -304,6 +306,7 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
304
306
|
}>) => readonly AuthoredChangeGroup[];
|
|
305
307
|
groupOf: (changeId: string) => AuthoredChangeGroup | null;
|
|
306
308
|
outcome: (id: string) => AuthoredOutcome | null;
|
|
309
|
+
gridLocked: (node: unknown) => boolean;
|
|
307
310
|
reviewOf: (node: unknown) => AuthoredReview;
|
|
308
311
|
}>> & Readonly<Record<"update", {
|
|
309
312
|
decide: TxDeclaredMethod<(decisions: AuthoredDecision | readonly AuthoredDecision[]) => AuthoredResult>;
|
|
@@ -324,7 +327,7 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
324
327
|
};
|
|
325
328
|
};
|
|
326
329
|
}> & Readonly<{
|
|
327
|
-
name: "
|
|
330
|
+
name: "authoredRecords";
|
|
328
331
|
}>>>, "enabled" | "name">> & PluginDependency<never>];
|
|
329
332
|
}>> & Pick<InternalBasePluginRuntimeExtension<BasePlugin<Readonly<{}> & Readonly<{
|
|
330
333
|
name: "authored";
|
|
@@ -341,7 +344,7 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
341
344
|
};
|
|
342
345
|
};
|
|
343
346
|
}> & Readonly<{
|
|
344
|
-
name: "
|
|
347
|
+
name: "authoredRecords";
|
|
345
348
|
}>>>];
|
|
346
349
|
}> & Readonly<Record<never, never>>>, Readonly<{}> & Readonly<{
|
|
347
350
|
name: "authored";
|
|
@@ -358,7 +361,7 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
358
361
|
};
|
|
359
362
|
};
|
|
360
363
|
}> & Readonly<{
|
|
361
|
-
name: "
|
|
364
|
+
name: "authoredRecords";
|
|
362
365
|
}>>>];
|
|
363
366
|
}> & Readonly<Record<never, never>>, AuthoredPlugin>, "~schema.plugins">, PluginReference$1<"history"> & PluginDependency<Readonly<{
|
|
364
367
|
name: "history";
|
|
@@ -419,6 +422,7 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
419
422
|
readonly [x: string]: unknown;
|
|
420
423
|
readonly text: string;
|
|
421
424
|
})[];
|
|
425
|
+
readonly id?: string;
|
|
422
426
|
readonly type: string;
|
|
423
427
|
};
|
|
424
428
|
readonly nodeKey: NodeKey;
|
|
@@ -432,6 +436,7 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
432
436
|
readonly [x: string]: unknown;
|
|
433
437
|
readonly text: string;
|
|
434
438
|
})[];
|
|
439
|
+
readonly id?: string;
|
|
435
440
|
readonly type: string;
|
|
436
441
|
}[];
|
|
437
442
|
readonly streaming: boolean;
|
|
@@ -445,9 +450,6 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
445
450
|
}> & Readonly<{
|
|
446
451
|
__pluginWritableProperties: never;
|
|
447
452
|
}> & Readonly<Record<"api", MarkdownApi<Value>>> & Readonly<Record<never, never>>> & Pick<BasePlugin<Readonly<{
|
|
448
|
-
readonly name: "markdown";
|
|
449
|
-
readonly api: MarkdownApi<Value>;
|
|
450
|
-
readonly dataTransferFormats: true;
|
|
451
453
|
readonly initialState: {
|
|
452
454
|
readonly plainMarks: readonly string[] | null;
|
|
453
455
|
readonly remarkPlugins: readonly (MarkdownSyncPlugin<readonly never[]> | readonly [MarkdownSyncPlugin<readonly never[]>, ...unknown[]])[];
|
|
@@ -508,6 +510,9 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
508
510
|
readonly unsafe?: readonly Unsafe[] | null | undefined;
|
|
509
511
|
} | null;
|
|
510
512
|
};
|
|
513
|
+
readonly name: "markdown";
|
|
514
|
+
readonly api: MarkdownApi<Value>;
|
|
515
|
+
readonly dataTransferFormats: true;
|
|
511
516
|
readonly validate: true;
|
|
512
517
|
}>> & Readonly<Record<never, never>>, "~schema.plugins">, PluginReference$1<"authored"> & PluginDependency<Readonly<{
|
|
513
518
|
name: "authored";
|
|
@@ -530,6 +535,7 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
530
535
|
}>) => readonly AuthoredChangeGroup[];
|
|
531
536
|
groupOf: (changeId: string) => AuthoredChangeGroup | null;
|
|
532
537
|
outcome: (id: string) => AuthoredOutcome | null;
|
|
538
|
+
gridLocked: (node: unknown) => boolean;
|
|
533
539
|
reviewOf: (node: unknown) => AuthoredReview;
|
|
534
540
|
}>> & Readonly<Record<"update", {
|
|
535
541
|
decide: TxDeclaredMethod<(decisions: AuthoredDecision | readonly AuthoredDecision[]) => AuthoredResult>;
|
|
@@ -550,7 +556,7 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
550
556
|
};
|
|
551
557
|
};
|
|
552
558
|
}> & Readonly<{
|
|
553
|
-
name: "
|
|
559
|
+
name: "authoredRecords";
|
|
554
560
|
}>>>, "enabled" | "name">> & PluginDependency<never>];
|
|
555
561
|
}>> & Pick<InternalBasePluginRuntimeExtension<BasePlugin<Readonly<{}> & Readonly<{
|
|
556
562
|
name: "authored";
|
|
@@ -567,7 +573,7 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
567
573
|
};
|
|
568
574
|
};
|
|
569
575
|
}> & Readonly<{
|
|
570
|
-
name: "
|
|
576
|
+
name: "authoredRecords";
|
|
571
577
|
}>>>];
|
|
572
578
|
}> & Readonly<Record<never, never>>>, Readonly<{}> & Readonly<{
|
|
573
579
|
name: "authored";
|
|
@@ -584,7 +590,7 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
584
590
|
};
|
|
585
591
|
};
|
|
586
592
|
}> & Readonly<{
|
|
587
|
-
name: "
|
|
593
|
+
name: "authoredRecords";
|
|
588
594
|
}>>>];
|
|
589
595
|
}> & Readonly<Record<never, never>>, AuthoredPlugin>, "~schema.plugins">, PluginReference$1<"history"> & PluginDependency<Readonly<{
|
|
590
596
|
name: "history";
|
|
@@ -658,7 +664,9 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
658
664
|
} | undefined;
|
|
659
665
|
readonly insertStart: () => {
|
|
660
666
|
path: Path;
|
|
661
|
-
startBlock: BaseElement
|
|
667
|
+
startBlock: (BaseElement & Readonly<{
|
|
668
|
+
id: string;
|
|
669
|
+
}>) | undefined;
|
|
662
670
|
startInEmptyParagraph: boolean;
|
|
663
671
|
};
|
|
664
672
|
readonly markdown: (args_0: {
|
|
@@ -666,7 +674,9 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
666
674
|
}) => string;
|
|
667
675
|
readonly node: (options?: Omit<EditorNodesOptions<Node>, 'type'> & {
|
|
668
676
|
streaming?: boolean;
|
|
669
|
-
}) => NodeEntry<BaseElement
|
|
677
|
+
}) => NodeEntry<BaseElement & Readonly<{
|
|
678
|
+
id: string;
|
|
679
|
+
}>> | undefined;
|
|
670
680
|
readonly prompt: (args_0: {
|
|
671
681
|
prompt?: EditorPrompt;
|
|
672
682
|
}) => string;
|
|
@@ -708,6 +718,7 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
708
718
|
readonly [x: string]: unknown;
|
|
709
719
|
readonly text: string;
|
|
710
720
|
})[];
|
|
721
|
+
readonly id?: string;
|
|
711
722
|
readonly type: string;
|
|
712
723
|
};
|
|
713
724
|
readonly nodeKey: NodeKey;
|
|
@@ -721,6 +732,7 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
721
732
|
readonly [x: string]: unknown;
|
|
722
733
|
readonly text: string;
|
|
723
734
|
})[];
|
|
735
|
+
readonly id?: string;
|
|
724
736
|
readonly type: string;
|
|
725
737
|
}[];
|
|
726
738
|
readonly streaming: boolean;
|
|
@@ -831,9 +843,6 @@ declare const CopilotPlugin: InternalPluginAuthorExtension<InternalPluginAuthorE
|
|
|
831
843
|
}> & Readonly<{
|
|
832
844
|
__pluginWritableProperties: never;
|
|
833
845
|
}> & Readonly<Record<"api", MarkdownApi<Value>>> & Readonly<Record<never, never>>> & Pick<BasePlugin<Readonly<{
|
|
834
|
-
readonly name: "markdown";
|
|
835
|
-
readonly api: MarkdownApi<Value>;
|
|
836
|
-
readonly dataTransferFormats: true;
|
|
837
846
|
readonly initialState: {
|
|
838
847
|
readonly plainMarks: readonly string[] | null;
|
|
839
848
|
readonly remarkPlugins: readonly (MarkdownSyncPlugin<readonly never[]> | readonly [MarkdownSyncPlugin<readonly never[]>, ...unknown[]])[];
|
|
@@ -894,6 +903,9 @@ declare const CopilotPlugin: InternalPluginAuthorExtension<InternalPluginAuthorE
|
|
|
894
903
|
readonly unsafe?: readonly Unsafe[] | null | undefined;
|
|
895
904
|
} | null;
|
|
896
905
|
};
|
|
906
|
+
readonly name: "markdown";
|
|
907
|
+
readonly api: MarkdownApi<Value>;
|
|
908
|
+
readonly dataTransferFormats: true;
|
|
897
909
|
readonly validate: true;
|
|
898
910
|
}>> & Readonly<Record<never, never>>, "~schema.plugins">];
|
|
899
911
|
readonly editOnly: true;
|
|
@@ -956,9 +968,6 @@ declare const CopilotPlugin: InternalPluginAuthorExtension<InternalPluginAuthorE
|
|
|
956
968
|
}> & Readonly<{
|
|
957
969
|
__pluginWritableProperties: never;
|
|
958
970
|
}> & Readonly<Record<"api", MarkdownApi<Value>>> & Readonly<Record<never, never>>> & Pick<BasePlugin<Readonly<{
|
|
959
|
-
readonly name: "markdown";
|
|
960
|
-
readonly api: MarkdownApi<Value>;
|
|
961
|
-
readonly dataTransferFormats: true;
|
|
962
971
|
readonly initialState: {
|
|
963
972
|
readonly plainMarks: readonly string[] | null;
|
|
964
973
|
readonly remarkPlugins: readonly (MarkdownSyncPlugin<readonly never[]> | readonly [MarkdownSyncPlugin<readonly never[]>, ...unknown[]])[];
|
|
@@ -1019,6 +1028,9 @@ declare const CopilotPlugin: InternalPluginAuthorExtension<InternalPluginAuthorE
|
|
|
1019
1028
|
readonly unsafe?: readonly Unsafe[] | null | undefined;
|
|
1020
1029
|
} | null;
|
|
1021
1030
|
};
|
|
1031
|
+
readonly name: "markdown";
|
|
1032
|
+
readonly api: MarkdownApi<Value>;
|
|
1033
|
+
readonly dataTransferFormats: true;
|
|
1022
1034
|
readonly validate: true;
|
|
1023
1035
|
}>> & Readonly<Record<never, never>>, "~schema.plugins">];
|
|
1024
1036
|
readonly editOnly: true;
|
|
@@ -1029,14 +1041,61 @@ declare const CopilotPlugin: InternalPluginAuthorExtension<InternalPluginAuthorE
|
|
|
1029
1041
|
readonly triggerSuggestion: () => Promise<false | undefined> | undefined;
|
|
1030
1042
|
}, {}, {}, {}, readonly [], boolean, readonly []>, Readonly<{
|
|
1031
1043
|
readonly name: "copilot";
|
|
1044
|
+
readonly initialState: {
|
|
1045
|
+
readonly abortController: AbortController | null;
|
|
1046
|
+
readonly autoTriggerQuery: (options: {
|
|
1047
|
+
editor: MarkdownEditor<Editor>;
|
|
1048
|
+
}) => boolean;
|
|
1049
|
+
readonly completeOptions: {
|
|
1050
|
+
readonly api: string;
|
|
1051
|
+
readonly body?: {
|
|
1052
|
+
readonly [x: string]: unknown;
|
|
1053
|
+
} | undefined;
|
|
1054
|
+
readonly credentials?: RequestCredentials;
|
|
1055
|
+
readonly fetch?: typeof fetch;
|
|
1056
|
+
readonly headers?: Headers | readonly (readonly [string, string])[] | {
|
|
1057
|
+
readonly [x: string]: string;
|
|
1058
|
+
} | undefined;
|
|
1059
|
+
readonly onError?: (error: Error) => void;
|
|
1060
|
+
readonly onFinish?: (prompt: string, completion: string) => void;
|
|
1061
|
+
readonly onResponse?: (response: Response) => Promise<void> | void;
|
|
1062
|
+
} | null;
|
|
1063
|
+
readonly completion: string | null;
|
|
1064
|
+
readonly debounceDelay: number;
|
|
1065
|
+
readonly error: Error | null;
|
|
1066
|
+
readonly getNextWord: (options: {
|
|
1067
|
+
text: string;
|
|
1068
|
+
}) => {
|
|
1069
|
+
firstWord: string;
|
|
1070
|
+
remainingText: string;
|
|
1071
|
+
};
|
|
1072
|
+
readonly getPrompt: (options: {
|
|
1073
|
+
editor: MarkdownEditor<Editor>;
|
|
1074
|
+
}) => string;
|
|
1075
|
+
readonly isLoading: boolean;
|
|
1076
|
+
readonly renderGhostText: (() => React$1.ReactNode) | null;
|
|
1077
|
+
readonly shouldAbort: boolean;
|
|
1078
|
+
readonly suggestionNodeKey: NodeKey | null;
|
|
1079
|
+
readonly suggestionText: string | null;
|
|
1080
|
+
readonly triggerQuery: (options: {
|
|
1081
|
+
editor: MarkdownEditor<Editor>;
|
|
1082
|
+
}) => boolean;
|
|
1083
|
+
};
|
|
1084
|
+
readonly update: {
|
|
1085
|
+
accept: () => false | undefined;
|
|
1086
|
+
acceptNextWord: () => false | undefined;
|
|
1087
|
+
reject: () => false | undefined;
|
|
1088
|
+
setBlockSuggestion: TxDeclaredMethod<({ key, text }: {
|
|
1089
|
+
text: string;
|
|
1090
|
+
key?: NodeKey | null;
|
|
1091
|
+
}) => void>;
|
|
1092
|
+
setSuggestion: TxDeclaredMethod<(next: CopilotSuggestionState) => void>;
|
|
1093
|
+
};
|
|
1032
1094
|
readonly dependencies: readonly [PluginReference$1<"markdown"> & PluginDependency<Readonly<{
|
|
1033
1095
|
name: "markdown";
|
|
1034
1096
|
}> & Readonly<{
|
|
1035
1097
|
__pluginWritableProperties: never;
|
|
1036
1098
|
}> & Readonly<Record<"api", MarkdownApi<Value>>> & Readonly<Record<never, never>>> & Pick<BasePlugin<Readonly<{
|
|
1037
|
-
readonly name: "markdown";
|
|
1038
|
-
readonly api: MarkdownApi<Value>;
|
|
1039
|
-
readonly dataTransferFormats: true;
|
|
1040
1099
|
readonly initialState: {
|
|
1041
1100
|
readonly plainMarks: readonly string[] | null;
|
|
1042
1101
|
readonly remarkPlugins: readonly (MarkdownSyncPlugin<readonly never[]> | readonly [MarkdownSyncPlugin<readonly never[]>, ...unknown[]])[];
|
|
@@ -1097,6 +1156,9 @@ declare const CopilotPlugin: InternalPluginAuthorExtension<InternalPluginAuthorE
|
|
|
1097
1156
|
readonly unsafe?: readonly Unsafe[] | null | undefined;
|
|
1098
1157
|
} | null;
|
|
1099
1158
|
};
|
|
1159
|
+
readonly name: "markdown";
|
|
1160
|
+
readonly api: MarkdownApi<Value>;
|
|
1161
|
+
readonly dataTransferFormats: true;
|
|
1100
1162
|
readonly validate: true;
|
|
1101
1163
|
}>> & Readonly<Record<never, never>>, "~schema.plugins">];
|
|
1102
1164
|
readonly api: {
|
|
@@ -1105,58 +1167,8 @@ declare const CopilotPlugin: InternalPluginAuthorExtension<InternalPluginAuthorE
|
|
|
1105
1167
|
};
|
|
1106
1168
|
readonly editOnly: true;
|
|
1107
1169
|
readonly effectTypes: true;
|
|
1108
|
-
readonly initialState: {
|
|
1109
|
-
readonly abortController: AbortController | null;
|
|
1110
|
-
readonly autoTriggerQuery: (options: {
|
|
1111
|
-
editor: MarkdownEditor<Editor>;
|
|
1112
|
-
}) => boolean;
|
|
1113
|
-
readonly completeOptions: {
|
|
1114
|
-
readonly api: string;
|
|
1115
|
-
readonly body?: {
|
|
1116
|
-
readonly [x: string]: unknown;
|
|
1117
|
-
} | undefined;
|
|
1118
|
-
readonly credentials?: RequestCredentials;
|
|
1119
|
-
readonly fetch?: typeof fetch;
|
|
1120
|
-
readonly headers?: Headers | readonly (readonly [string, string])[] | {
|
|
1121
|
-
readonly [x: string]: string;
|
|
1122
|
-
} | undefined;
|
|
1123
|
-
readonly onError?: (error: Error) => void;
|
|
1124
|
-
readonly onFinish?: (prompt: string, completion: string) => void;
|
|
1125
|
-
readonly onResponse?: (response: Response) => Promise<void> | void;
|
|
1126
|
-
} | null;
|
|
1127
|
-
readonly completion: string | null;
|
|
1128
|
-
readonly debounceDelay: number;
|
|
1129
|
-
readonly error: Error | null;
|
|
1130
|
-
readonly getNextWord: (options: {
|
|
1131
|
-
text: string;
|
|
1132
|
-
}) => {
|
|
1133
|
-
firstWord: string;
|
|
1134
|
-
remainingText: string;
|
|
1135
|
-
};
|
|
1136
|
-
readonly getPrompt: (options: {
|
|
1137
|
-
editor: MarkdownEditor<Editor>;
|
|
1138
|
-
}) => string;
|
|
1139
|
-
readonly isLoading: boolean;
|
|
1140
|
-
readonly renderGhostText: (() => React$1.ReactNode) | null;
|
|
1141
|
-
readonly shouldAbort: boolean;
|
|
1142
|
-
readonly suggestionNodeKey: NodeKey | null;
|
|
1143
|
-
readonly suggestionText: string | null;
|
|
1144
|
-
readonly triggerQuery: (options: {
|
|
1145
|
-
editor: MarkdownEditor<Editor>;
|
|
1146
|
-
}) => boolean;
|
|
1147
|
-
};
|
|
1148
1170
|
readonly slots: true;
|
|
1149
1171
|
readonly stateFields: true;
|
|
1150
|
-
readonly update: {
|
|
1151
|
-
accept: () => false | undefined;
|
|
1152
|
-
acceptNextWord: () => false | undefined;
|
|
1153
|
-
reject: () => false | undefined;
|
|
1154
|
-
setBlockSuggestion: TxDeclaredMethod<({ key, text }: {
|
|
1155
|
-
text: string;
|
|
1156
|
-
key?: NodeKey | null;
|
|
1157
|
-
}) => void>;
|
|
1158
|
-
setSuggestion: TxDeclaredMethod<(next: CopilotSuggestionState) => void>;
|
|
1159
|
-
};
|
|
1160
1172
|
}>, "commands" | "on" | "selectors" | "shortcuts" | "slots", {}, {}, {}, {
|
|
1161
1173
|
readonly isSuggested: (state: Readonly<{
|
|
1162
1174
|
readonly abortController: AbortController | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { getEditorRuntimeOwner } from "../../core.js";
|
|
3
|
-
import {
|
|
3
|
+
import { useEditorSelector } from "../../react/stores/plate/useEditorSelector.js";
|
|
4
4
|
import { useEditor } from "../../react/stores/plate/useEditor.js";
|
|
5
5
|
import { AIChatPlugin, getAIChatCommandEditor } from "./AIChatPlugin.js";
|
|
6
6
|
import * as React$1 from "react";
|
|
@@ -237,7 +237,7 @@ function createEditorChat(editor, transport) {
|
|
|
237
237
|
* the last view cancels the request. Check the data callback's signal after await.
|
|
238
238
|
*/
|
|
239
239
|
function useAIChat(t0) {
|
|
240
|
-
const $ = c(
|
|
240
|
+
const $ = c(15);
|
|
241
241
|
const { editableRef, transport, onData } = t0;
|
|
242
242
|
const mountedEditor = useEditor();
|
|
243
243
|
let t1;
|
|
@@ -247,11 +247,16 @@ function useAIChat(t0) {
|
|
|
247
247
|
$[1] = t1;
|
|
248
248
|
} else t1 = $[1];
|
|
249
249
|
const editor = t1;
|
|
250
|
-
const readOnly = useEditorViewState(mountedEditor, _temp);
|
|
251
|
-
const attachment = React$1.useRef(null);
|
|
252
250
|
let t2;
|
|
253
|
-
if ($[2]
|
|
254
|
-
t2 =
|
|
251
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
252
|
+
t2 = { dependsOn: "readOnly" };
|
|
253
|
+
$[2] = t2;
|
|
254
|
+
} else t2 = $[2];
|
|
255
|
+
const readOnly = useEditorSelector(mountedEditor, _temp, t2);
|
|
256
|
+
const attachment = React$1.useRef(null);
|
|
257
|
+
let t3;
|
|
258
|
+
if ($[3] !== editableRef || $[4] !== editor || $[5] !== onData || $[6] !== transport) {
|
|
259
|
+
t3 = () => {
|
|
255
260
|
const element = editableRef.current;
|
|
256
261
|
const previous = attachment.current;
|
|
257
262
|
if (previous?.element === element && previous.session === sessions.get(editor) && previous.session.transport === transport) {
|
|
@@ -281,47 +286,47 @@ function useAIChat(t0) {
|
|
|
281
286
|
detach: session.attach(view)
|
|
282
287
|
};
|
|
283
288
|
};
|
|
284
|
-
$[
|
|
285
|
-
$[
|
|
286
|
-
$[
|
|
287
|
-
$[
|
|
288
|
-
$[
|
|
289
|
-
} else
|
|
290
|
-
React$1.useLayoutEffect(
|
|
291
|
-
let t3;
|
|
289
|
+
$[3] = editableRef;
|
|
290
|
+
$[4] = editor;
|
|
291
|
+
$[5] = onData;
|
|
292
|
+
$[6] = transport;
|
|
293
|
+
$[7] = t3;
|
|
294
|
+
} else t3 = $[7];
|
|
295
|
+
React$1.useLayoutEffect(t3);
|
|
292
296
|
let t4;
|
|
293
|
-
|
|
294
|
-
|
|
297
|
+
let t5;
|
|
298
|
+
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
299
|
+
t4 = () => () => {
|
|
295
300
|
attachment.current?.detach();
|
|
296
301
|
attachment.current = null;
|
|
297
302
|
};
|
|
298
|
-
|
|
299
|
-
$[7] = t3;
|
|
303
|
+
t5 = [];
|
|
300
304
|
$[8] = t4;
|
|
305
|
+
$[9] = t5;
|
|
301
306
|
} else {
|
|
302
|
-
t3 = $[7];
|
|
303
307
|
t4 = $[8];
|
|
308
|
+
t5 = $[9];
|
|
304
309
|
}
|
|
305
|
-
React$1.useLayoutEffect(
|
|
306
|
-
let
|
|
307
|
-
if ($[
|
|
308
|
-
|
|
310
|
+
React$1.useLayoutEffect(t4, t5);
|
|
311
|
+
let t6;
|
|
312
|
+
if ($[10] !== editor) {
|
|
313
|
+
t6 = () => {
|
|
309
314
|
sessions.get(editor)?.refresh();
|
|
310
315
|
};
|
|
311
|
-
$[
|
|
312
|
-
$[
|
|
313
|
-
} else
|
|
314
|
-
let
|
|
315
|
-
if ($[
|
|
316
|
-
|
|
317
|
-
$[
|
|
318
|
-
$[
|
|
319
|
-
$[
|
|
320
|
-
} else
|
|
321
|
-
React$1.useEffect(
|
|
316
|
+
$[10] = editor;
|
|
317
|
+
$[11] = t6;
|
|
318
|
+
} else t6 = $[11];
|
|
319
|
+
let t7;
|
|
320
|
+
if ($[12] !== editor || $[13] !== readOnly) {
|
|
321
|
+
t7 = [editor, readOnly];
|
|
322
|
+
$[12] = editor;
|
|
323
|
+
$[13] = readOnly;
|
|
324
|
+
$[14] = t7;
|
|
325
|
+
} else t7 = $[14];
|
|
326
|
+
React$1.useEffect(t6, t7);
|
|
322
327
|
}
|
|
323
|
-
function _temp(
|
|
324
|
-
return
|
|
328
|
+
function _temp(current) {
|
|
329
|
+
return current.read.view.isReadOnly();
|
|
325
330
|
}
|
|
326
331
|
//#endregion
|
|
327
332
|
export { useAIChat };
|
package/dist/authored/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as AuthoredProjectionRefusal, m as AuthoredProjectionDiagnostic, p as AuthoredDocumentProjection } from "../
|
|
2
|
-
import { C as
|
|
3
|
-
import { t as AuthoredPlugin } from "../index-
|
|
4
|
-
export { type AuthoredChange, type AuthoredChangeDetails, type AuthoredChangeGroup, type AuthoredChangeKind, type AuthoredChangePart, type AuthoredChangesDelta, type AuthoredComparisonImportResult, type AuthoredDecision, type AuthoredDocumentProjection, type AuthoredFormatProjection, type AuthoredGroupDetails, type AuthoredGroupPart, type AuthoredMark, type AuthoredOptions, type AuthoredOutcome, type AuthoredPage, AuthoredPlaceError, AuthoredPlugin, type AuthoredProjectionDiagnostic, type AuthoredProjectionRefusal, type AuthoredQuery, type AuthoredRefusal, type AuthoredResult, type AuthoredReview, type AuthoredView, projectAuthoredDocument, projectAuthoredRange, proposeAuthoredComparison };
|
|
1
|
+
import { h as AuthoredProjectionRefusal, m as AuthoredProjectionDiagnostic, p as AuthoredDocumentProjection } from "../tx-only-1FM45FSj-D40jacZv.js";
|
|
2
|
+
import { C as GaveWrite, D as proposeAuthoredComparison, E as projectAuthoredRange, S as AuthoredView, T as projectAuthoredDocument, a as AuthoredChangePart, b as AuthoredResult, c as AuthoredDecision, d as AuthoredGroupPart, f as AuthoredMark, g as AuthoredPlaceError, h as AuthoredPage, i as AuthoredChangeKind, l as AuthoredFormatProjection, m as AuthoredOutcome, n as AuthoredChangeDetails, o as AuthoredChangesDelta, p as AuthoredOptions, r as AuthoredChangeGroup, s as AuthoredComparisonImportResult, t as AuthoredChange, u as AuthoredGroupDetails, v as AuthoredQuery, w as SplitGave, x as AuthoredReview, y as AuthoredRefusal } from "../index-CLNem74G.js";
|
|
3
|
+
import { t as AuthoredPlugin } from "../index-CVAHIQ3p.js";
|
|
4
|
+
export { type AuthoredChange, type AuthoredChangeDetails, type AuthoredChangeGroup, type AuthoredChangeKind, type AuthoredChangePart, type AuthoredChangesDelta, type AuthoredComparisonImportResult, type AuthoredDecision, type AuthoredDocumentProjection, type AuthoredFormatProjection, type AuthoredGroupDetails, type AuthoredGroupPart, type AuthoredMark, type AuthoredOptions, type AuthoredOutcome, type AuthoredPage, AuthoredPlaceError, AuthoredPlugin, type AuthoredProjectionDiagnostic, type AuthoredProjectionRefusal, type AuthoredQuery, type AuthoredRefusal, type AuthoredResult, type AuthoredReview, type AuthoredView, type GaveWrite, type SplitGave, projectAuthoredDocument, projectAuthoredRange, proposeAuthoredComparison };
|