platejs 54.0.0-beta.2 → 54.0.0-beta.4
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/README.md +1 -1
- package/THIRD_PARTY_NOTICES.md +56 -0
- package/dist/{AIChatRequestContext-BMVWhfPV.d.ts → AIChatRequestContext-DrUahdTc.d.ts} +2 -2
- package/dist/{BaseSuggestionPlugin-DBl3fqnm.d.ts → BaseSuggestionPlugin-_7Ka6nY3.d.ts} +7 -3
- package/dist/{PlateStatic-DhNv2ejp.d.ts → PlateStatic-D3Cb-QwH.d.ts} +7 -7
- package/dist/ai/index.d.ts +1 -1
- package/dist/ai/react/AIChatPlugin.js +113 -78
- package/dist/ai/react/CopilotPlugin.js +1 -1
- package/dist/ai/react/index.d.ts +23 -16
- package/dist/authored/index.d.ts +4 -4
- package/dist/code-block/codemirror/createCodeMirrorAdapter.js +12 -9
- package/dist/code-block/codemirror/index.d.ts +1 -1
- package/dist/{combobox-DkBGgyd3.d.ts → combobox-Dr0OYZIE.d.ts} +2 -2
- package/dist/{comparison-types-CYnJ35qU.d.ts → comparison-types-DdwE6mYq-BogsHoUO.d.ts} +10 -2
- package/dist/compiler/index.d.ts +2 -2
- package/dist/{core-BJG8l_mk.d.ts → core-BqR-fEDp.d.ts} +493 -116
- package/dist/diff/index.d.ts +2 -2
- package/dist/docs/ai.md +4 -3
- package/dist/docs/api/core/plate-components.md +0 -19
- package/dist/docs/api/core/plate-controller.md +5 -3
- package/dist/docs/api/core/plate-plugin.md +3 -0
- package/dist/docs/api/core/plate-store.md +3 -3
- package/dist/docs/api/core.md +45 -5
- package/dist/docs/api/dom.md +11 -4
- package/dist/docs/api/editor-transforms.md +2 -1
- package/dist/docs/api/react-hooks.md +45 -13
- package/dist/docs/authored-changes.md +9 -4
- package/dist/docs/basic-blocks.md +42 -29
- package/dist/docs/block-placeholder.md +4 -2
- package/dist/docs/blockquote.md +5 -3
- package/dist/docs/board.md +118 -10
- package/dist/docs/code-block.md +47 -0
- package/dist/docs/comment.md +2 -2
- package/dist/docs/discussion.md +1 -1
- package/dist/docs/document-model.md +15 -3
- package/dist/docs/docx.md +1 -1
- package/dist/docs/dom-coverage.md +5 -0
- package/dist/docs/editor.md +50 -4
- package/dist/docs/examples/editable-voids.md +2 -3
- package/dist/docs/external-text.md +2 -0
- package/dist/docs/field.md +370 -0
- package/dist/docs/find.md +9 -6
- package/dist/docs/form.md +2 -0
- package/dist/docs/heading.md +6 -0
- package/dist/docs/installation/manual.md +0 -4
- package/dist/docs/link.md +3 -3
- package/dist/docs/llms.txt +4 -2
- package/dist/docs/markdown.md +270 -14
- package/dist/docs/plugin-components.md +13 -10
- package/dist/docs/plugin-input-rules.md +66 -15
- package/dist/docs/prompt-editor.md +205 -0
- package/dist/docs/roots.md +8 -6
- package/dist/docs/rtl.md +6 -4
- package/dist/docs/selection.md +7 -4
- package/dist/docs/suggestion.md +1 -1
- package/dist/docs/toolbar.md +26 -30
- package/dist/docs/upload.md +106 -17
- package/dist/docx/export/index.d.ts +3 -3
- package/dist/docx/export/lib/docxStaticComponents.js +12 -2
- package/dist/docx/export/lib/exportDocx.js +46 -17
- package/dist/docx/export/lib/internal/xml-builder.js +11 -16
- package/dist/docx/export/lib/reviewPart.js +1 -1
- package/dist/docx/export/lib/reviewProjection.js +52 -10
- package/dist/docx/import/index.d.ts +4 -4
- package/dist/docx/paste/index.d.ts +4 -4
- package/dist/dom/index.d.ts +1 -6
- package/dist/dom/plite-dom.internal.js +2 -2
- package/dist/excalidraw/index.d.ts +3 -2
- package/dist/excalidraw/react/index.d.ts +3 -2
- package/dist/facade.js +2 -2
- package/dist/features/basic-nodes/lib/BaseBlockPlugins.js +13 -5
- package/dist/features/basic-nodes/lib/BaseHeadingPlugins.js +32 -10
- package/dist/features/board/index.d.ts +2 -2
- package/dist/features/board/lib/BaseBoardPlugin.js +14 -1
- package/dist/features/board/lib/boardStroke.internal.js +13 -1
- package/dist/features/board/lib/boardTypes.internal.js +16 -0
- package/dist/features/callout/index.d.ts +3 -2
- package/dist/features/code-block/lib/BaseCodeBlockPlugin.js +14 -5
- package/dist/features/combobox/index.d.ts +2 -2
- package/dist/features/comments/BaseCommentsPlugin.js +33 -17
- package/dist/features/comments/index.d.ts +1 -1
- package/dist/features/date/index.d.ts +3 -2
- package/dist/features/details/index.d.ts +3 -2
- package/dist/features/details/lib/BaseDetailsPlugin.js +25 -12
- package/dist/features/field/index.d.ts +2 -0
- package/dist/features/field/index.js +4 -0
- package/dist/features/field/lib/BaseFieldPlugin.js +360 -0
- package/dist/features/field/lib/applyFieldValues.js +188 -0
- package/dist/features/field/lib/fieldRules.internal.js +204 -0
- package/dist/features/find/index.d.ts +3 -2
- package/dist/features/footnote/index.d.ts +1 -1
- package/dist/features/ink/index.d.ts +1 -1
- package/dist/features/ink/lib/BaseInkPlugin.js +126 -103
- package/dist/features/ink/lib/inkCodec.internal.js +130 -0
- package/dist/features/ink/lib/inkGone.internal.js +229 -48
- package/dist/features/ink/lib/inkPlaces.internal.js +534 -64
- package/dist/features/layout/index.d.ts +1 -1
- package/dist/features/link/lib/BaseLinkPlugin.js +6 -4
- package/dist/features/lint/index.d.ts +3 -2
- package/dist/features/media/index.d.ts +2 -2
- package/dist/features/media/index.js +2 -2
- package/dist/features/media/lib/media/parseMediaUrl.js +11 -1
- package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +206 -4
- package/dist/features/mention/index.d.ts +5 -4
- 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 +64 -15
- package/dist/features/table/lib/internal/selection.js +4 -2
- package/dist/features/toc/index.d.ts +1 -1
- package/dist/features/upload/index.d.ts +2 -2
- package/dist/features/upload/lib/BaseUploadPlugin.js +464 -250
- package/dist/history/index.d.ts +2 -2
- package/dist/html/index.d.ts +3 -3
- package/dist/html/server/index.d.ts +1 -1
- package/dist/{htmlTypes-DjeFG3P8.d.ts → htmlTypes-eT2ZGDAj.d.ts} +2 -31
- package/dist/hyperscript/index.d.ts +1 -1
- package/dist/{index-DzD6BIFJ.d.ts → index-B33E1CRJ.d.ts} +295 -6
- package/dist/{index-Cl77E9yr.d.ts → index-B7moSod7.d.ts} +2 -2
- package/dist/{index-hsC_sOn2.d.ts → index-B8-5Sr7I.d.ts} +35 -5
- package/dist/{index-BiQerPJS.d.ts → index-B8QJDAmG.d.ts} +2 -2
- package/dist/{index-BBKGrsG3.d.ts → index-BTx5oK7k.d.ts} +1 -1
- package/dist/{index-iaZOhA76.d.ts → index-BWPcE4ac-Cto_IsNs.d.ts} +7 -1
- package/dist/{index-BU6k1Aev.d.ts → index-BXjLmx1n-CXk17buG.d.ts} +4781 -4584
- package/dist/{index-kLKMc-pI.d.ts → index-BXwU9QH6.d.ts} +2 -2
- package/dist/{index-DTgaSxKr.d.ts → index-BkwR-5hH.d.ts} +40 -4
- package/dist/{index-Bq3sdm3S.d.ts → index-BsV2McRr.d.ts} +5 -4
- package/dist/index-C9Fu-P4E.d.ts +773 -0
- package/dist/{index-D5W-p9bS.d.ts → index-Ca48r1ng.d.ts} +49 -4
- package/dist/{index-CcZbqPqk.d.ts → index-Cob_iBdu.d.ts} +116 -41
- package/dist/{index-Bxfvicyy.d.ts → index-CpY7Xnxw.d.ts} +4 -3
- package/dist/{index-BkR7-GLI.d.ts → index-DNQXzU-X.d.ts} +2 -2
- package/dist/{index-D1CFXA-i.d.ts → index-DPowErHa.d.ts} +471 -141
- package/dist/{index-DaM37gF6.d.ts → index-DShbzec2.d.ts} +38 -23
- package/dist/{index-DC_MNGyu.d.ts → index-DYdObeFQ.d.ts} +3 -3
- package/dist/{index-Bc2Yg_2j.d.ts → index-Dq3Jlj8O-BJ6NxZm0.d.ts} +2 -2
- package/dist/{index-CT7miqQN.d.ts → index-DwWQVwQt.d.ts} +29 -11
- package/dist/{index-xdmCBvlT.d.ts → index-JWgwL5l3.d.ts} +5 -2
- package/dist/{index-DLA2DUR2.d.ts → index-M781pyx9.d.ts} +4 -3
- package/dist/{index-DdIRduDG.d.ts → index-d7io3MzC.d.ts} +3 -2
- package/dist/index.d.ts +4 -4
- package/dist/{react/internal → internal}/penStroke.internal.js +1 -1
- package/dist/internal/plugin/OverridePlugin.js +101 -119
- package/dist/internal/plugin/collectPlateNodeMappings.js +5 -1
- package/dist/internal/plugin/pastedUploadFiles.js +4 -0
- package/dist/internal/plugin/resolvePlugin.js +1 -1
- package/dist/internal/plugin/resolvePlugins.js +3 -0
- package/dist/internal/plugin/uploadDrafts.js +6 -0
- package/dist/internal/utils/mergePlugins.js +1 -0
- package/dist/lib/plugins/element-id/ElementIdPlugin.js +14 -18
- package/dist/lib/plugins/html/HtmlPlugin.js +9 -0
- package/dist/lib/plugins/html/htmlSafety.js +1 -1
- package/dist/lib/plugins/input-rules/InputRulesPlugin.js +77 -28
- package/dist/lib/plugins/input-rules/inputRuleVeto.internal.js +16 -0
- package/dist/markdown/index.d.ts +2 -2
- package/dist/markdown/index.js +3 -1
- package/dist/markdown/lib/MarkdownPlugin.js +14 -11
- package/dist/markdown/lib/RawHtmlPlugin.js +26 -0
- package/dist/markdown/lib/deserializer/mdastToSlate.js +12 -2
- package/dist/markdown/lib/internal/markdownConversion.js +776 -74
- package/dist/markdown/lib/internal/markdownDiagnostics.js +18 -7
- package/dist/markdown/lib/internal/markdownFootnoteWriter.js +35 -0
- package/dist/markdown/lib/internal/markdownFrontmatter.js +102 -0
- package/dist/markdown/lib/internal/markdownIntrinsics.js +125 -43
- package/dist/markdown/lib/internal/markdownLine.js +5 -3
- package/dist/markdown/lib/internal/markdownMappings.js +19 -7
- package/dist/markdown/lib/internal/markdownOpenTail.js +381 -0
- package/dist/markdown/lib/internal/markdownRawHtml.js +353 -0
- package/dist/markdown/lib/internal/markdownSegments.js +57 -48
- package/dist/markdown/lib/internal/markdownTags.js +29 -9
- package/dist/markdown/lib/serializer/convertNodesSerialize.js +10 -8
- package/dist/markdown/lib/serializer/convertPhrasingSerialize.js +226 -0
- package/dist/markdown/lib/serializer/listToMdastTree.js +2 -0
- package/dist/math/index.d.ts +3 -2
- package/dist/math/react/index.d.ts +4 -3
- package/dist/migrations/index.d.ts +3 -3
- package/dist/migrations/migratePlateV54.js +4 -6
- package/dist/migrations/migratePlateV54RetiredMarks.internal.js +23 -8
- package/dist/migrations/migratePlateV54Suggestions.internal.js +2 -2
- package/dist/migrations/v53-manifest.internal.js +4 -0
- package/dist/pagination/index.d.ts +1 -1
- package/dist/pagination/react/index.d.ts +4 -4
- package/dist/react/components/EditorContentView.internal.js +42 -23
- package/dist/react/components/EditorProvider.js +5 -5
- package/dist/react/components/Plate.js +102 -128
- package/dist/react/components/PlateContainer.js +40 -32
- package/dist/react/components/PlateController.js +28 -16
- package/dist/react/components/PlateRoot.internal.js +3 -2
- package/dist/react/core.js +4 -4
- package/dist/react/features/board/BoardSurface.js +116 -87
- package/dist/react/features/board/boardClipboard.internal.js +15 -5
- package/dist/react/features/board/boardExport.internal.js +470 -0
- package/dist/react/features/board/boardGesture.internal.js +6 -3
- package/dist/react/features/board/boardIndex.internal.js +7 -18
- package/dist/react/features/board/boardPictureStyles.internal.js +415 -0
- package/dist/react/features/board/boardPictures.internal.js +19 -13
- package/dist/react/features/board/boardView.internal.js +190 -50
- package/dist/react/features/board/boardVoice.internal.js +10 -11
- package/dist/react/features/board/index.d.ts +108 -18
- package/dist/react/features/callout/index.d.ts +3 -2
- package/dist/react/features/combobox/index.d.ts +8 -8
- package/dist/react/features/comments/index.d.ts +6 -5
- package/dist/react/features/date/index.d.ts +4 -3
- package/dist/react/features/details/index.d.ts +4 -3
- package/dist/react/features/field/FieldPlugin.js +35 -0
- package/dist/react/features/field/index.d.ts +315 -0
- package/dist/react/features/field/index.js +2 -0
- package/dist/react/features/footnote/index.d.ts +7 -6
- package/dist/react/features/format-painter/index.d.ts +4 -3
- package/dist/react/features/ink/InkContent.js +313 -0
- package/dist/react/features/ink/index.d.ts +57 -33
- package/dist/react/features/ink/index.js +2 -2
- package/dist/react/features/ink/inkCapture.internal.js +39 -17
- package/dist/react/features/ink/inkInput.internal.js +1 -1
- package/dist/react/features/ink/inkLayout.internal.js +6 -3
- package/dist/react/features/ink/inkPaint.internal.js +78 -2
- package/dist/react/features/ink/inkPlacement.internal.js +332 -104
- package/dist/react/features/ink/inkWatch.internal.js +7 -5
- package/dist/react/features/layout/index.d.ts +5 -4
- package/dist/react/features/media/index.d.ts +5 -4
- package/dist/react/features/mention/index.d.ts +6 -5
- package/dist/react/features/resizable/Resizable.js +4 -6
- package/dist/react/features/resizable/index.d.ts +5 -5
- package/dist/react/features/suggestion/index.d.ts +6 -5
- package/dist/react/features/table/TablePlugin.js +4 -11
- package/dist/react/features/table/index.d.ts +10 -8
- package/dist/react/features/table/useTableResize.js +10 -1
- package/dist/react/features/toc/index.d.ts +2 -2
- package/dist/react/features/upload/index.d.ts +11 -6
- package/dist/react/index.d.ts +6 -6
- package/dist/react/index.js +4 -4
- package/dist/react/internal/plate-context.js +434 -188
- package/dist/react/plite-react.js +2 -2
- package/dist/react/plugins/navigation-feedback/NavigationFeedbackPlugin.js +12 -10
- package/dist/react/stores/plate/useEditor.js +32 -14
- package/dist/react/stores/plate/useEditorHistory.js +55 -0
- package/dist/react/stores/plate/useEditorSelector.js +79 -21
- package/dist/react/utils/BlockPlaceholderPlugin.js +5 -2
- package/dist/react/utils/pipeRenderElement.internal.js +1 -1
- package/dist/react/utils/pluginRenderElement.internal.js +1 -1
- package/dist/react/virtualized.d.ts +4 -4
- package/dist/{source-CNKy99Th.d.ts → source-BGohy8vH.d.ts} +4 -4
- package/dist/static/index.d.ts +18 -18
- package/dist/static/internal/renderStaticHtmlWithOverrides.js +2 -2
- package/dist/static/internal/staticPresentation.js +4 -4
- package/dist/static/internal/writeStaticSelectionClipboardData.js +7 -2
- package/dist/tabbable/index.d.ts +1 -1
- package/dist/tabbable/react/index.d.ts +3 -3
- package/dist/testing/index.d.ts +3 -3
- package/dist/yjs/index.d.ts +1 -1
- package/dist/yjs/react/index.d.ts +6 -6
- package/package.json +20 -2
- package/dist/markdown/lib/serializer/convertTextsSerialize.js +0 -163
- package/dist/react/components/EditorSelectionView.js +0 -40
- package/dist/react/features/ink/InkLayer.js +0 -218
- package/dist/react/internal/createPlateTargetScope.js +0 -62
package/README.md
CHANGED
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -55,3 +55,59 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
55
55
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
56
56
|
SOFTWARE.
|
|
57
57
|
```
|
|
58
|
+
|
|
59
|
+
## Excalidraw
|
|
60
|
+
|
|
61
|
+
`platejs` includes the segment and ellipse intersection tests in `src/features/board/lib/boardArrow.internal.ts`, adapted from [Excalidraw](https://github.com/excalidraw/excalidraw)'s `@excalidraw/math`. Excalidraw is distributed under the MIT License:
|
|
62
|
+
|
|
63
|
+
```text
|
|
64
|
+
MIT License
|
|
65
|
+
|
|
66
|
+
Copyright (c) 2020 Excalidraw
|
|
67
|
+
|
|
68
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
69
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
70
|
+
in the Software without restriction, including without limitation the rights
|
|
71
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
72
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
73
|
+
furnished to do so, subject to the following conditions:
|
|
74
|
+
|
|
75
|
+
The above copyright notice and this permission notice shall be included in all
|
|
76
|
+
copies or substantial portions of the Software.
|
|
77
|
+
|
|
78
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
79
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
80
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
81
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
82
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
83
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
84
|
+
SOFTWARE.
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## perfect-freehand
|
|
88
|
+
|
|
89
|
+
`platejs` includes the pen stroke path and simulated pressure in `src/internal/penStroke.internal.ts`, adapted from [perfect-freehand](https://github.com/steveruizok/perfect-freehand). The board and ink input draw their pen strokes with it. perfect-freehand is distributed under the MIT License:
|
|
90
|
+
|
|
91
|
+
```text
|
|
92
|
+
MIT License
|
|
93
|
+
|
|
94
|
+
Copyright (c) 2021 Stephen Ruiz Ltd
|
|
95
|
+
|
|
96
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
97
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
98
|
+
in the Software without restriction, including without limitation the rights
|
|
99
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
100
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
101
|
+
furnished to do so, subject to the following conditions:
|
|
102
|
+
|
|
103
|
+
The above copyright notice and this permission notice shall be included in all
|
|
104
|
+
copies or substantial portions of the Software.
|
|
105
|
+
|
|
106
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
107
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
108
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
109
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
110
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
111
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
112
|
+
SOFTWARE.
|
|
113
|
+
```
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./core-
|
|
1
|
+
import { $a as Path, Fc as Selection, La as NodeSelectionMode, ps as Range, su as Value } from "./index-BXjLmx1n-CXk17buG.js";
|
|
2
|
+
import "./core-BqR-fEDp.js";
|
|
3
3
|
type AIToolName = 'comment' | 'edit' | 'generate' | null;
|
|
4
4
|
/** Request-local reference into `AIChatRequestContext.children`. */
|
|
5
5
|
type AIChatRequestNodeRef = Readonly<{
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { Ca as NodeKey, Ji as Location, iu as TxDeclaredMethod, oo as Plugin, ou as TxOnlyMethod } from "./index-BXjLmx1n-CXk17buG.js";
|
|
2
|
+
import "./htmlTypes-eT2ZGDAj.js";
|
|
3
|
+
import { Co as PluginReference, V as InternalBasePluginRuntimeExtension, _ as BasePlugin, aa as BasePluginDependencyReferenceFor, xo as PluginDependency } from "./core-BqR-fEDp.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-B8-5Sr7I.js";
|
|
4
5
|
/** Paints each node's pending authored changes as `data-editor-authored-*` attributes. */
|
|
5
6
|
declare const BaseSuggestionPlugin: BasePlugin<Readonly<{
|
|
6
7
|
inject: true;
|
|
@@ -20,6 +21,9 @@ declare const BaseSuggestionPlugin: BasePlugin<Readonly<{
|
|
|
20
21
|
change: (id: string) => AuthoredChange | null;
|
|
21
22
|
changes: (query?: AuthoredQuery) => AuthoredPage;
|
|
22
23
|
details: (id: string) => AuthoredChangeDetails | null;
|
|
24
|
+
groupDetails: (changeId: string, options?: Readonly<{
|
|
25
|
+
limit?: number;
|
|
26
|
+
}>) => AuthoredGroupDetails | null;
|
|
23
27
|
groups: (query: Readonly<{
|
|
24
28
|
at: Location | NodeKey;
|
|
25
29
|
}>) => readonly AuthoredChangeGroup[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./htmlTypes-
|
|
3
|
-
import { u as Editor } from "./core-
|
|
4
|
-
import React from "react";
|
|
1
|
+
import { Tt as EditorDocumentValue } from "./index-BXjLmx1n-CXk17buG.js";
|
|
2
|
+
import "./htmlTypes-eT2ZGDAj.js";
|
|
3
|
+
import { u as Editor } from "./core-BqR-fEDp.js";
|
|
4
|
+
import React$1 from "react";
|
|
5
5
|
type EditorStaticProps<E = Editor> = {
|
|
6
6
|
/**
|
|
7
7
|
* A document to render instead of the editor's own, such as a streamed
|
|
@@ -13,7 +13,7 @@ type EditorStaticProps<E = Editor> = {
|
|
|
13
13
|
document?: EditorDocumentValue;
|
|
14
14
|
/** Editor instance. */
|
|
15
15
|
editor: E;
|
|
16
|
-
style?: React.CSSProperties;
|
|
17
|
-
} & React.HTMLAttributes<HTMLDivElement>;
|
|
18
|
-
declare function EditorStatic<E = Editor>(props: EditorStaticProps<E>): React.JSX.Element;
|
|
16
|
+
style?: React$1.CSSProperties;
|
|
17
|
+
} & React$1.HTMLAttributes<HTMLDivElement>;
|
|
18
|
+
declare function EditorStatic<E = Editor>(props: EditorStaticProps<E>): React$1.JSX.Element;
|
|
19
19
|
export { EditorStaticProps as n, EditorStatic as t };
|
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-DrUahdTc.js";
|
|
2
2
|
export { AIChatRequestContext, AIChatRequestNodeRef, AIChatRequestNodeSelection, AIChatRequestRefs, AIToolName, resolveAIChatRequestContext };
|
|
@@ -2,6 +2,7 @@ import { canPlaceBlocksAtPath, getCompiledEditorSchema, getEditorAuthoredDocumen
|
|
|
2
2
|
import { getCompiledPlatePlugin } from "../../internal/plugin/compilePlateModel.js";
|
|
3
3
|
import { resolveInsertionAnchor } from "../../internal/plugin/insertionAnchor.js";
|
|
4
4
|
import { HistoryPlugin } from "../../lib/plugins/HistoryPlugin.js";
|
|
5
|
+
import { isInputRuleVetoed } from "../../lib/plugins/input-rules/inputRuleVeto.internal.js";
|
|
5
6
|
import { BaseParagraphPlugin } from "../../lib/plugins/paragraph/BaseParagraphPlugin.js";
|
|
6
7
|
import { PLUGINS } from "../../utils/plate-keys.js";
|
|
7
8
|
import { ContentSlice, ElementApi, NodeApi, PathApi, PointApi, RangeApi, SelectionApi, TextApi, defineEffect, editorCommands } from "../../core.js";
|
|
@@ -15,7 +16,10 @@ import { captureTextRange, fillEmptyListItem, formatAIOutput, landAIOutput, sugg
|
|
|
15
16
|
import isEqual from "lodash/isEqual.js";
|
|
16
17
|
import cloneDeep from "lodash/cloneDeep.js";
|
|
17
18
|
//#region src/ai/react/AIChatPlugin.ts
|
|
18
|
-
const aiChatShowEffect = defineEffect({
|
|
19
|
+
const aiChatShowEffect = defineEffect({
|
|
20
|
+
history: "skip",
|
|
21
|
+
key: "ai.chat.show"
|
|
22
|
+
});
|
|
19
23
|
const aiChatCommandEditors = /* @__PURE__ */ new WeakMap();
|
|
20
24
|
const getAIChatCommandEditor = (editor) => aiChatCommandEditors.get(editor) ?? editor;
|
|
21
25
|
const withoutReviewMarks = (node) => {
|
|
@@ -116,6 +120,10 @@ const AIChatPlugin = definePlugin(PLUGINS.aiChat, {
|
|
|
116
120
|
if (!selection) return null;
|
|
117
121
|
return () => actionEditor.update.selection.set(selection);
|
|
118
122
|
};
|
|
123
|
+
const resolveChatSelection = () => {
|
|
124
|
+
const stored = context.store.get("chatSelection");
|
|
125
|
+
return stored && previewAnchor ? previewAnchor.resolve() : stored;
|
|
126
|
+
};
|
|
119
127
|
const restoreTarget = (commandEditor) => {
|
|
120
128
|
const restore = prepareTargetRestore(commandEditor);
|
|
121
129
|
restore?.();
|
|
@@ -182,12 +190,15 @@ const AIChatPlugin = definePlugin(PLUGINS.aiChat, {
|
|
|
182
190
|
if (!changeId) return null;
|
|
183
191
|
const change = pendingChange();
|
|
184
192
|
const authored = projectEditorView(editor, { authorId: change?.authorId }).plugin(AuthoredPlugin);
|
|
185
|
-
const result = change ? action === "reject" ? authored.update.withdraw([change]) : authored.update.decide({
|
|
193
|
+
const result = (change ? action === "reject" ? authored.update.withdraw([change]) : authored.update.decide({
|
|
186
194
|
action,
|
|
187
195
|
changes: [change]
|
|
188
196
|
}) : {
|
|
189
197
|
ids: [changeId],
|
|
190
198
|
status: "unchanged"
|
|
199
|
+
}) ?? {
|
|
200
|
+
ids: [changeId],
|
|
201
|
+
status: "invalid"
|
|
191
202
|
};
|
|
192
203
|
if (reviewSucceeded(result)) {
|
|
193
204
|
context.store.set({ _changeId: null });
|
|
@@ -219,7 +230,7 @@ const AIChatPlugin = definePlugin(PLUGINS.aiChat, {
|
|
|
219
230
|
return (projected?.ok ? projected.blocks : entries.map(([node]) => node)).filter((node) => ElementApi.isElement(node));
|
|
220
231
|
};
|
|
221
232
|
const resetOptions = () => {
|
|
222
|
-
|
|
233
|
+
const { chat } = context.store.get();
|
|
223
234
|
previewAnchor?.release();
|
|
224
235
|
previewAnchor = null;
|
|
225
236
|
previewOwner = null;
|
|
@@ -228,8 +239,6 @@ const AIChatPlugin = definePlugin(PLUGINS.aiChat, {
|
|
|
228
239
|
suggestionTarget = null;
|
|
229
240
|
tableDraft.clear();
|
|
230
241
|
aiChatCommandEditors.delete(editor);
|
|
231
|
-
const { chat } = context.store.get();
|
|
232
|
-
if (chat?.messages.length) chat.clear();
|
|
233
242
|
responseAuthor = null;
|
|
234
243
|
context.store.set({
|
|
235
244
|
_blockKey: null,
|
|
@@ -244,6 +253,11 @@ const AIChatPlugin = definePlugin(PLUGINS.aiChat, {
|
|
|
244
253
|
previewValue: [],
|
|
245
254
|
toolName: null
|
|
246
255
|
});
|
|
256
|
+
try {
|
|
257
|
+
cancel();
|
|
258
|
+
} finally {
|
|
259
|
+
if (chat?.messages.length) chat.clear();
|
|
260
|
+
}
|
|
247
261
|
};
|
|
248
262
|
const resetEditor = (commandEditor, { restoreSelection = true } = {}) => {
|
|
249
263
|
const result = decideCurrentChange("reject");
|
|
@@ -499,8 +513,22 @@ const AIChatPlugin = definePlugin(PLUGINS.aiChat, {
|
|
|
499
513
|
});
|
|
500
514
|
};
|
|
501
515
|
const finishCompleteAction = () => {
|
|
502
|
-
|
|
503
|
-
|
|
516
|
+
try {
|
|
517
|
+
resetOptions();
|
|
518
|
+
} finally {
|
|
519
|
+
hideOptions();
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
const landAndClose = (actionEditor, land) => {
|
|
523
|
+
let closed = false;
|
|
524
|
+
if (actionEditor?.update((tx, { afterCommit }) => {
|
|
525
|
+
if (!land(tx)) return false;
|
|
526
|
+
afterCommit(() => {
|
|
527
|
+
closed = true;
|
|
528
|
+
finishCompleteAction();
|
|
529
|
+
});
|
|
530
|
+
return true;
|
|
531
|
+
}) && !closed) finishCompleteAction();
|
|
504
532
|
};
|
|
505
533
|
const getActionChatBlocks = (tx) => {
|
|
506
534
|
const chatNodes = context.store.get("chatNodes");
|
|
@@ -632,13 +660,16 @@ const AIChatPlugin = definePlugin(PLUGINS.aiChat, {
|
|
|
632
660
|
const sourceRoots = new Set(state.chatNodes.map(({ nodeKey }) => resolveTargetRoot(commandEditor, nodeKey)?.root));
|
|
633
661
|
const root = actionEditor.read.view.root();
|
|
634
662
|
if (!suggestionTarget && (sourceRoots.size !== 1 || !sourceRoots.has(root))) return false;
|
|
635
|
-
|
|
663
|
+
const capturedSelection = resolveChatSelection();
|
|
664
|
+
if (state.chatSelection && !capturedSelection) return false;
|
|
636
665
|
const currentChangeId = state._changeId;
|
|
637
|
-
const capturedSelection = state.chatSelection;
|
|
638
666
|
const parsed = editor.api.markdown.parseSlice(content);
|
|
639
667
|
if (!parsed.ok) {
|
|
640
668
|
const result = decideCurrentChange("reject");
|
|
641
|
-
if (!result || reviewSucceeded(result))
|
|
669
|
+
if (!result || reviewSucceeded(result)) {
|
|
670
|
+
suggestion = null;
|
|
671
|
+
suggestionTarget = null;
|
|
672
|
+
}
|
|
642
673
|
return false;
|
|
643
674
|
}
|
|
644
675
|
const targetKeys = state.chatNodes.map(({ nodeKey }) => nodeKey);
|
|
@@ -678,35 +709,51 @@ const AIChatPlugin = definePlugin(PLUGINS.aiChat, {
|
|
|
678
709
|
kind: "text",
|
|
679
710
|
range
|
|
680
711
|
};
|
|
681
|
-
suggestionTarget = target;
|
|
682
712
|
}
|
|
683
713
|
const nextNodes = parseSuggestion(parsed.slice.content, target);
|
|
684
714
|
if (suggestion && actionEditor.read.children() !== suggestion.children) return false;
|
|
685
715
|
const previous = currentChangeId ? editor.plugin(AuthoredPlugin).read.change(currentChangeId) : null;
|
|
686
|
-
if (previous)
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
716
|
+
if (previous) {
|
|
717
|
+
let withdrawn = false;
|
|
718
|
+
actionEditor.update((tx, { afterCommit }) => {
|
|
719
|
+
tx.history.merge();
|
|
720
|
+
tx.plugin(AuthoredPlugin).withdraw([previous]);
|
|
721
|
+
afterCommit(({ snapshot }) => {
|
|
722
|
+
withdrawn = true;
|
|
723
|
+
suggestion &&= {
|
|
724
|
+
...suggestion,
|
|
725
|
+
children: snapshot.children
|
|
726
|
+
};
|
|
727
|
+
});
|
|
728
|
+
});
|
|
729
|
+
if (!withdrawn || suggestion && actionEditor.read.children() !== suggestion.children) return false;
|
|
730
|
+
}
|
|
731
|
+
const response = parsed.slice.content.filter((node) => ElementApi.isElement(node));
|
|
690
732
|
let publishedChangeId = null;
|
|
691
|
-
actionEditor.
|
|
733
|
+
const publish = (changeId, children = actionEditor.read.children()) => {
|
|
734
|
+
publishedChangeId = changeId;
|
|
735
|
+
suggestion = {
|
|
736
|
+
children,
|
|
737
|
+
response
|
|
738
|
+
};
|
|
739
|
+
suggestionTarget = target;
|
|
740
|
+
context.store.set({
|
|
741
|
+
_changeId: changeId,
|
|
742
|
+
previewValue: []
|
|
743
|
+
});
|
|
744
|
+
const published = pendingChange();
|
|
745
|
+
if (published) responseAuthor = {
|
|
746
|
+
authorId: published.authorId,
|
|
747
|
+
requestId: context.store.get("_requestId")
|
|
748
|
+
};
|
|
749
|
+
};
|
|
750
|
+
if (actionEditor.update((tx, { afterCommit }) => {
|
|
692
751
|
const changeId = tx.plugin(AuthoredPlugin).propose(currentChangeId ? { changeId: currentChangeId } : void 0);
|
|
693
752
|
if (currentChangeId) tx.history.merge();
|
|
694
753
|
else tx.history.newBatch();
|
|
695
|
-
if (writeSuggestion(tx, target, nextNodes))
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
children: actionEditor.read.children(),
|
|
699
|
-
response: parsed.slice.content.filter((node) => ElementApi.isElement(node))
|
|
700
|
-
};
|
|
701
|
-
context.store.set({
|
|
702
|
-
_changeId: publishedChangeId,
|
|
703
|
-
previewValue: []
|
|
704
|
-
});
|
|
705
|
-
const published = pendingChange();
|
|
706
|
-
if (published) responseAuthor = {
|
|
707
|
-
authorId: published.authorId,
|
|
708
|
-
requestId: context.store.get("_requestId")
|
|
709
|
-
};
|
|
754
|
+
if (writeSuggestion(tx, target, nextNodes)) afterCommit(({ snapshot }) => publish(changeId, snapshot.children));
|
|
755
|
+
return true;
|
|
756
|
+
}) && publishedChangeId === null) publish(null);
|
|
710
757
|
return publishedChangeId !== null;
|
|
711
758
|
};
|
|
712
759
|
const acceptAIResponse = (commandEditor) => {
|
|
@@ -717,37 +764,34 @@ const AIChatPlugin = definePlugin(PLUGINS.aiChat, {
|
|
|
717
764
|
}
|
|
718
765
|
responseAuthor = null;
|
|
719
766
|
if (tableDraft.size > 0) {
|
|
720
|
-
|
|
721
|
-
getActionEditor(commandEditor)?.update((tx) => {
|
|
767
|
+
landAndClose(getActionEditor(commandEditor), (tx) => {
|
|
722
768
|
const targets = [...tableDraft].map(([key, draft]) => ({
|
|
723
769
|
draft,
|
|
724
770
|
entry: resolveTargetRoot(commandEditor, key)?.root === tx.view.root() ? tx.nodes.get(key, { match: ElementApi.isElement }) : void 0
|
|
725
771
|
}));
|
|
726
|
-
if (targets.some(({ entry }) => !entry)) return;
|
|
772
|
+
if (targets.some(({ entry }) => !entry)) return false;
|
|
727
773
|
tx.history.newBatch();
|
|
728
774
|
for (const { draft, entry } of targets) if (entry) tx.nodes.replaceChildren(cloneDeep(draft.children), { at: tx.key(entry[0]) });
|
|
729
|
-
|
|
775
|
+
return true;
|
|
730
776
|
});
|
|
731
|
-
if (applied) finishCompleteAction();
|
|
732
777
|
return;
|
|
733
778
|
}
|
|
734
779
|
if (context.store.get("mode") === "chat") {
|
|
735
780
|
completeDetachedOutput(commandEditor, "replaceSelection", "single");
|
|
736
781
|
return;
|
|
737
782
|
}
|
|
738
|
-
|
|
739
|
-
getActionEditor(commandEditor)?.update((tx) => {
|
|
783
|
+
landAndClose(getActionEditor(commandEditor), (tx) => {
|
|
740
784
|
const output = getActionPreviewSource();
|
|
741
785
|
const blockKey = context.store.get("_blockKey");
|
|
742
786
|
const target = blockKey ? tx.nodes.get(blockKey, { match: ElementApi.isElement }) : void 0;
|
|
743
|
-
if (!target || !output) return;
|
|
787
|
+
if (!target || !output) return false;
|
|
744
788
|
tx.history.newBatch();
|
|
745
789
|
const [node, path] = target;
|
|
746
790
|
const replace = node.type === paragraph.schema.type && tx.nodes.isEmpty(node);
|
|
747
791
|
const [anchor, anchorPath] = replace ? target : resolveInsertionAnchor(editor, tx, target);
|
|
748
792
|
const firstPath = replace ? path : PathApi.next(anchorPath);
|
|
749
793
|
const firstIndex = firstPath.at(-1);
|
|
750
|
-
if (firstIndex === void 0) return;
|
|
794
|
+
if (firstIndex === void 0) return false;
|
|
751
795
|
const blocks = cloneDeep(replace ? isListItem(node) ? landAIOutput(editor, tx, fillEmptyListItem(output, node), {
|
|
752
796
|
block: node,
|
|
753
797
|
kind: "replaced"
|
|
@@ -759,52 +803,43 @@ const AIChatPlugin = definePlugin(PLUGINS.aiChat, {
|
|
|
759
803
|
kind: "kept"
|
|
760
804
|
}));
|
|
761
805
|
const placed = placeActionBlocks(tx, blocks, firstPath, replace ? [firstIndex] : void 0);
|
|
762
|
-
if (!placed) return;
|
|
806
|
+
if (!placed) return false;
|
|
763
807
|
let last;
|
|
764
808
|
if (replace) {
|
|
765
|
-
if (!tx.nodes.replace(placed, { at: path })) return;
|
|
809
|
+
if (!tx.nodes.replace(placed, { at: path })) return false;
|
|
766
810
|
last = [...firstPath.slice(0, -1), firstIndex + placed.length - 1];
|
|
767
811
|
} else {
|
|
768
812
|
last = tx.blocks.insert(placed, { after: anchorPath })?.at(-1);
|
|
769
|
-
if (!last) return;
|
|
813
|
+
if (!last) return false;
|
|
770
814
|
}
|
|
771
815
|
const end = tx.points.end(last);
|
|
772
816
|
if (end) tx.selection.set(end);
|
|
773
|
-
|
|
817
|
+
return true;
|
|
774
818
|
});
|
|
775
|
-
if (applied) finishCompleteAction();
|
|
776
819
|
};
|
|
777
820
|
const completeDetachedOutput = (commandEditor, action, format, response) => {
|
|
778
|
-
|
|
779
|
-
getActionEditor(commandEditor)?.update((tx) => {
|
|
821
|
+
const land = (tx) => {
|
|
780
822
|
const source = response ?? getActionPreviewSource();
|
|
781
|
-
if (!source) return;
|
|
782
|
-
const
|
|
783
|
-
|
|
784
|
-
if (capturedSelection && previewAnchor && !chatSelection) return;
|
|
823
|
+
if (!source) return false;
|
|
824
|
+
const chatSelection = resolveChatSelection();
|
|
825
|
+
if (context.store.get("chatSelection") && !chatSelection) return false;
|
|
785
826
|
if (chatSelection) {
|
|
786
827
|
const [start, end] = RangeApi.edges(chatSelection);
|
|
787
828
|
const block = tx.nodes.block({ at: action === "insertBelow" ? end : start });
|
|
788
|
-
if (!block) return;
|
|
789
|
-
if (action === "insertBelow")
|
|
790
|
-
applied = insertActionBlocks(tx, cloneDeep(source), format, block);
|
|
791
|
-
return;
|
|
792
|
-
}
|
|
829
|
+
if (!block) return false;
|
|
830
|
+
if (action === "insertBelow") return insertActionBlocks(tx, cloneDeep(source), format, block);
|
|
793
831
|
const blocks = formatAIOutput({
|
|
794
832
|
blocks: cloneDeep(source),
|
|
795
833
|
format,
|
|
796
834
|
sourceBlock: block[0]
|
|
797
835
|
});
|
|
798
|
-
if (!blocks) return;
|
|
836
|
+
if (!blocks) return false;
|
|
799
837
|
tx.history.newBatch();
|
|
800
838
|
const whole = wholeTextBlocks(tx, chatSelection, (first) => landAIOutput(editor, tx, blocks, {
|
|
801
839
|
block: first,
|
|
802
840
|
kind: "replaced"
|
|
803
841
|
}));
|
|
804
|
-
if (whole)
|
|
805
|
-
applied = replaceActionBlocks(tx, whole.nodes, whole.blocks);
|
|
806
|
-
return;
|
|
807
|
-
}
|
|
842
|
+
if (whole) return replaceActionBlocks(tx, whole.nodes, whole.blocks);
|
|
808
843
|
const landed = landAIOutput(editor, tx, blocks, {
|
|
809
844
|
block: block[0],
|
|
810
845
|
kind: "kept"
|
|
@@ -812,36 +847,32 @@ const AIChatPlugin = definePlugin(PLUGINS.aiChat, {
|
|
|
812
847
|
const openTextBlock = (node) => node && !tx.schema.isVoid(node) && node.children.every((child) => TextApi.isText(child) || tx.schema.isInline(child)) ? 1 : 0;
|
|
813
848
|
const [head, ...rest] = landed;
|
|
814
849
|
const tail = head && openTextBlock(head) ? placeActionBlocks(tx, rest, PathApi.next(block[1])) : rest;
|
|
815
|
-
if (!tail) return;
|
|
850
|
+
if (!tail) return false;
|
|
816
851
|
const content = head ? [head, ...tail] : landed;
|
|
817
|
-
|
|
852
|
+
return tx.slice.replace(ContentSlice.fromJSON({
|
|
818
853
|
content,
|
|
819
854
|
openStart: openTextBlock(content[0]),
|
|
820
855
|
openEnd: openTextBlock(content.at(-1))
|
|
821
856
|
}), { at: chatSelection });
|
|
822
|
-
return;
|
|
823
857
|
}
|
|
824
858
|
const selected = getActionChatBlocks(tx);
|
|
825
|
-
if (selected.length === 0) return;
|
|
859
|
+
if (selected.length === 0) return false;
|
|
826
860
|
const sourceBlock = action === "insertBelow" ? selected.at(-1) : selected[0];
|
|
827
|
-
if (!sourceBlock) return;
|
|
828
|
-
if (action === "insertBelow")
|
|
829
|
-
applied = insertActionBlocks(tx, cloneDeep(source), format, sourceBlock);
|
|
830
|
-
return;
|
|
831
|
-
}
|
|
861
|
+
if (!sourceBlock) return false;
|
|
862
|
+
if (action === "insertBelow") return insertActionBlocks(tx, cloneDeep(source), format, sourceBlock);
|
|
832
863
|
const blocks = formatAIOutput({
|
|
833
864
|
blocks: cloneDeep(source),
|
|
834
865
|
format: format === "single" && selected.length > 1 ? "none" : format,
|
|
835
866
|
sourceBlock: sourceBlock[0]
|
|
836
867
|
});
|
|
837
|
-
if (!blocks) return;
|
|
868
|
+
if (!blocks) return false;
|
|
838
869
|
tx.history.newBatch();
|
|
839
|
-
|
|
870
|
+
return replaceActionBlocks(tx, landAIOutput(editor, tx, blocks, {
|
|
840
871
|
block: sourceBlock[0],
|
|
841
872
|
kind: "replaced"
|
|
842
873
|
}), selected);
|
|
843
|
-
}
|
|
844
|
-
|
|
874
|
+
};
|
|
875
|
+
landAndClose(getActionEditor(commandEditor), land);
|
|
845
876
|
};
|
|
846
877
|
const show = (commandEditor, target) => {
|
|
847
878
|
const result = resetEditor(commandEditor);
|
|
@@ -862,7 +893,7 @@ const AIChatPlugin = definePlugin(PLUGINS.aiChat, {
|
|
|
862
893
|
const { trigger, triggerPreviousCharPattern, triggerQuery } = context.store.get();
|
|
863
894
|
const selection = state.selection();
|
|
864
895
|
const matches = trigger instanceof RegExp ? trigger.test(input.text) : Array.isArray(trigger) ? trigger.includes(input.text) : input.text === trigger;
|
|
865
|
-
if (!selection || !matches || triggerQuery && !triggerQuery(context.editor)) return false;
|
|
896
|
+
if (!selection || !matches || triggerQuery && !triggerQuery(context.editor) || isInputRuleVetoed(context.editor, state)) return false;
|
|
866
897
|
const before = state.points.before(selection);
|
|
867
898
|
const previous = before ? state.text.string({
|
|
868
899
|
anchor: before,
|
|
@@ -895,9 +926,13 @@ const AIChatPlugin = definePlugin(PLUGINS.aiChat, {
|
|
|
895
926
|
accept: () => acceptAIResponse(commandEditor),
|
|
896
927
|
/** Close the session, cancel its request, and discard any unapplied draft. */
|
|
897
928
|
hide: ({ focus = true } = {}) => {
|
|
898
|
-
|
|
929
|
+
let result;
|
|
930
|
+
try {
|
|
931
|
+
result = resetEditor(commandEditor, { restoreSelection: focus });
|
|
932
|
+
} finally {
|
|
933
|
+
if (!result || reviewSucceeded(result)) hideOptions();
|
|
934
|
+
}
|
|
899
935
|
if (result && !reviewSucceeded(result)) return result;
|
|
900
|
-
hideOptions();
|
|
901
936
|
if (focus) commandEditor.api.dom.focus();
|
|
902
937
|
return result;
|
|
903
938
|
},
|
|
@@ -909,9 +944,9 @@ const AIChatPlugin = definePlugin(PLUGINS.aiChat, {
|
|
|
909
944
|
/** Cancel the request, discard its draft, and request a new response. */
|
|
910
945
|
reload: () => {
|
|
911
946
|
const { chat, toolName } = context.store.get();
|
|
912
|
-
cancel();
|
|
913
947
|
const result = decideCurrentChange("reject");
|
|
914
948
|
if (result && !reviewSucceeded(result)) return result;
|
|
949
|
+
cancel();
|
|
915
950
|
suggestion = null;
|
|
916
951
|
suggestionTarget = null;
|
|
917
952
|
previewOwner = null;
|
|
@@ -370,7 +370,7 @@ const CopilotPlugin = definePlugin(PLUGINS.copilot, {
|
|
|
370
370
|
});
|
|
371
371
|
if (!commit.selectionChanged) return;
|
|
372
372
|
const selection = context.editor.read.selection();
|
|
373
|
-
if (selection && (!previousSelection || !RangeApi.equals(previousSelection, selection)) && context.store.get().autoTriggerQuery?.({ editor: context.editor }) && context.editor.
|
|
373
|
+
if (selection && (!previousSelection || !RangeApi.equals(previousSelection, selection)) && context.store.get().autoTriggerQuery?.({ editor: context.editor }) && context.editor.api.dom.isFocused()) context.api.triggerSuggestion();
|
|
374
374
|
previousSelection = selection;
|
|
375
375
|
},
|
|
376
376
|
mouseDown: () => {
|
package/dist/ai/react/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { $
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import "../../index-
|
|
9
|
-
import
|
|
10
|
-
import React from "react";
|
|
1
|
+
import { $a as Path, Ca as NodeKey, Ci as Element, Fo as PluginReference, Ji as Location, La as NodeSelectionMode, Pi as HistoryApi, aa as Node, b as BasePoint, dn as EditorReadMethodTree, iu as TxDeclaredMethod, oo as Plugin, ou as TxOnlyMethod, pa as NodeEntry, ps as Range, su as Value, tn as EditorNodesOptions, v as BaseElement, zo as PluginTypeProvider } from "../../index-BXjLmx1n-CXk17buG.js";
|
|
2
|
+
import "../../htmlTypes-eT2ZGDAj.js";
|
|
3
|
+
import { Co as PluginReference$1, Eo as PluginSchemaDeclaration, V as InternalBasePluginRuntimeExtension, _ as BasePlugin, aa as BasePluginDependencyReferenceFor, ea as HistoryPluginState, qa as DefinitionOf, xo as PluginDependency } from "../../core-BqR-fEDp.js";
|
|
4
|
+
import { c as HistoryPluginTypeProvider, d as HistoryTxApi, n as History, u as HistoryStateApi } from "../../index-DNQXzU-X.js";
|
|
5
|
+
import { a as AIToolName } from "../../AIChatRequestContext-DrUahdTc.js";
|
|
6
|
+
import { At as Plugin$1, n as InternalReactEditorWithInstalledPlugins, t as Editor, xt as InternalPluginAuthorExtension } from "../../index-DPowErHa.js";
|
|
7
|
+
import { O as MarkdownSyncPlugin, d as Unsafe, i as MarkdownEditor, l as Handle, n as MarkdownApi, u as Join } from "../../index-Cob_iBdu.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-B8-5Sr7I.js";
|
|
9
|
+
import "../../index-M781pyx9.js";
|
|
10
|
+
import * as React from "react";
|
|
11
|
+
import React$1 from "react";
|
|
11
12
|
import { ChatRequestOptions, ChatStatus, ChatTransport, DataUIPart, UIMessage } from "ai";
|
|
12
13
|
type AIMode = 'chat' | 'insert';
|
|
13
14
|
type TComment = {
|
|
@@ -295,6 +296,9 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
295
296
|
change: (id: string) => AuthoredChange | null;
|
|
296
297
|
changes: (query?: AuthoredQuery) => AuthoredPage;
|
|
297
298
|
details: (id: string) => AuthoredChangeDetails | null;
|
|
299
|
+
groupDetails: (changeId: string, options?: Readonly<{
|
|
300
|
+
limit?: number;
|
|
301
|
+
}>) => AuthoredGroupDetails | null;
|
|
298
302
|
groups: (query: Readonly<{
|
|
299
303
|
at: Location | NodeKey;
|
|
300
304
|
}>) => readonly AuthoredChangeGroup[];
|
|
@@ -518,6 +522,9 @@ declare const AIChatPlugin: InternalPluginAuthorExtension<Plugin$1<Readonly<{
|
|
|
518
522
|
change: (id: string) => AuthoredChange | null;
|
|
519
523
|
changes: (query?: AuthoredQuery) => AuthoredPage;
|
|
520
524
|
details: (id: string) => AuthoredChangeDetails | null;
|
|
525
|
+
groupDetails: (changeId: string, options?: Readonly<{
|
|
526
|
+
limit?: number;
|
|
527
|
+
}>) => AuthoredGroupDetails | null;
|
|
521
528
|
groups: (query: Readonly<{
|
|
522
529
|
at: Location | NodeKey;
|
|
523
530
|
}>) => readonly AuthoredChangeGroup[];
|
|
@@ -755,7 +762,7 @@ type CopilotPluginState = {
|
|
|
755
762
|
editor: MarkdownEditor<Editor>;
|
|
756
763
|
}) => string;
|
|
757
764
|
isLoading: boolean;
|
|
758
|
-
renderGhostText: (() => React.ReactNode) | null;
|
|
765
|
+
renderGhostText: (() => React$1.ReactNode) | null;
|
|
759
766
|
shouldAbort: boolean;
|
|
760
767
|
suggestionNodeKey: NodeKey | null;
|
|
761
768
|
suggestionText: string | null;
|
|
@@ -801,7 +808,7 @@ declare const CopilotPlugin: InternalPluginAuthorExtension<InternalPluginAuthorE
|
|
|
801
808
|
editor: MarkdownEditor<Editor>;
|
|
802
809
|
}) => string;
|
|
803
810
|
readonly isLoading: boolean;
|
|
804
|
-
readonly renderGhostText: (() => React.ReactNode) | null;
|
|
811
|
+
readonly renderGhostText: (() => React$1.ReactNode) | null;
|
|
805
812
|
readonly shouldAbort: boolean;
|
|
806
813
|
readonly suggestionNodeKey: NodeKey | null;
|
|
807
814
|
readonly suggestionText: string | null;
|
|
@@ -926,7 +933,7 @@ declare const CopilotPlugin: InternalPluginAuthorExtension<InternalPluginAuthorE
|
|
|
926
933
|
editor: MarkdownEditor<Editor>;
|
|
927
934
|
}) => string;
|
|
928
935
|
readonly isLoading: boolean;
|
|
929
|
-
readonly renderGhostText: (() => React.ReactNode) | null;
|
|
936
|
+
readonly renderGhostText: (() => React$1.ReactNode) | null;
|
|
930
937
|
readonly shouldAbort: boolean;
|
|
931
938
|
readonly suggestionNodeKey: NodeKey | null;
|
|
932
939
|
readonly suggestionText: string | null;
|
|
@@ -1130,7 +1137,7 @@ declare const CopilotPlugin: InternalPluginAuthorExtension<InternalPluginAuthorE
|
|
|
1130
1137
|
editor: MarkdownEditor<Editor>;
|
|
1131
1138
|
}) => string;
|
|
1132
1139
|
readonly isLoading: boolean;
|
|
1133
|
-
readonly renderGhostText: (() => React.ReactNode) | null;
|
|
1140
|
+
readonly renderGhostText: (() => React$1.ReactNode) | null;
|
|
1134
1141
|
readonly shouldAbort: boolean;
|
|
1135
1142
|
readonly suggestionNodeKey: NodeKey | null;
|
|
1136
1143
|
readonly suggestionText: string | null;
|
|
@@ -1183,7 +1190,7 @@ declare const CopilotPlugin: InternalPluginAuthorExtension<InternalPluginAuthorE
|
|
|
1183
1190
|
editor: MarkdownEditor<Editor>;
|
|
1184
1191
|
}) => string;
|
|
1185
1192
|
readonly isLoading: boolean;
|
|
1186
|
-
readonly renderGhostText: (() => React.ReactNode) | null;
|
|
1193
|
+
readonly renderGhostText: (() => React$1.ReactNode) | null;
|
|
1187
1194
|
readonly shouldAbort: boolean;
|
|
1188
1195
|
readonly suggestionNodeKey: NodeKey | null;
|
|
1189
1196
|
readonly suggestionText: string | null;
|
|
@@ -1199,7 +1206,7 @@ type CopilotDefinition = DefinitionOf<typeof CopilotPlugin>;
|
|
|
1199
1206
|
* the last view cancels the request. Check the data callback's signal after await.
|
|
1200
1207
|
*/
|
|
1201
1208
|
declare function useAIChat({ editableRef, transport, onData }: {
|
|
1202
|
-
editableRef: React
|
|
1209
|
+
editableRef: React.RefObject<HTMLElement | null>;
|
|
1203
1210
|
transport: ChatTransport<UIMessage>;
|
|
1204
1211
|
onData?: (part: DataUIPart<Record<string, unknown>>, signal: AbortSignal) => void;
|
|
1205
1212
|
}): void;
|
package/dist/authored/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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 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 "../index-BXjLmx1n-CXk17buG.js";
|
|
2
|
+
import { C as projectAuthoredDocument, S as AuthoredView, T as proposeAuthoredComparison, 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 projectAuthoredRange, x as AuthoredReview, y as AuthoredRefusal } from "../index-B8-5Sr7I.js";
|
|
3
|
+
import { t as AuthoredPlugin } from "../index-M781pyx9.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, projectAuthoredDocument, projectAuthoredRange, proposeAuthoredComparison };
|