platejs 54.0.0-beta.11 → 54.0.0-beta.12
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/{EditorStatic-DHtnTXA7.d.ts → EditorStatic-DLn-Y0NA.d.ts} +27 -6
- package/dist/ai/index.d.ts +2 -2
- package/dist/ai/index.js +2 -3
- package/dist/ai/lib/aiDraftSession.js +227 -132
- package/dist/ai/lib/aiPolicy.internal.js +1 -2
- package/dist/ai/lib/editorAgent.js +831 -275
- package/dist/ai/lib/editorAgentPresence.internal.js +113 -0
- package/dist/ai/lib/lockedContext.js +1 -1
- package/dist/ai/lib/registerEditorTools.js +59 -4
- package/dist/ai/lib/webmcpConfinement.internal.js +8 -0
- package/dist/ai/react/AIPlugin.js +2 -2
- package/dist/ai/react/CopilotPlugin.js +25 -11
- package/dist/ai/react/index.d.ts +170 -809
- package/dist/ai/react/index.js +2 -2
- package/dist/ai/react/useEditorAgent.js +230 -42
- package/dist/authored/AuthoredPlugin.js +2 -2
- package/dist/authored/index.d.ts +5 -5
- package/dist/authored/suggestionColorOf.js +10 -5
- package/dist/{authored-C-fSCvgm-CYzDIRS3.d.ts → authored-D-sIdWDF-BO8GVDW5.d.ts} +51 -13
- package/dist/clipboard-format-key-C8pLG2_c-D8fWV8GB.d.ts +1 -0
- package/dist/code-block/codemirror/index.d.ts +2 -2
- package/dist/{comment-anchor.internal-XxZyEyAa.d.ts → comment-anchor.internal-Qv9thB9E.d.ts} +2 -2
- package/dist/compiler/index.d.ts +3 -3
- package/dist/{core-Dt0c81fL.d.ts → core-BWS1N1EV.d.ts} +4147 -6642
- package/dist/core.js +1 -4
- package/dist/diff/index.d.ts +3 -3
- package/dist/docs/agents/skills.md +1 -1
- package/dist/docs/agents.md +15 -25
- package/dist/docs/ai-agents.md +76 -0
- package/dist/docs/ai.md +87 -73
- package/dist/docs/api/anchor.md +2 -2
- package/dist/docs/api/core/plate-components.md +53 -174
- package/dist/docs/api/core/plate-controller.md +1 -1
- package/dist/docs/api/core/plate-editor.md +34 -131
- package/dist/docs/api/core/plate-plugin.md +401 -550
- package/dist/docs/api/core/plate-store.md +1 -1
- package/dist/docs/api/core.md +167 -335
- package/dist/docs/api/dom.md +1 -1
- package/dist/docs/api/editor-api.md +2 -2
- package/dist/docs/api/editor-transforms.md +2 -2
- package/dist/docs/api/element.md +3 -3
- package/dist/docs/api/location.md +2 -2
- package/dist/docs/api/node.md +6 -7
- package/dist/docs/api/path.md +3 -3
- package/dist/docs/api/plate.md +6 -6
- package/dist/docs/api/point.md +4 -3
- package/dist/docs/api/range.md +4 -2
- package/dist/docs/api/react-hooks.md +2 -2
- package/dist/docs/api/resizable.md +20 -42
- package/dist/docs/api/selection.md +2 -2
- package/dist/docs/api/text.md +3 -3
- package/dist/docs/api/utils.md +1 -2
- package/dist/docs/authored-changes.md +5 -3
- package/dist/docs/autoformat.md +0 -12
- package/dist/docs/basic-blocks.md +6 -24
- package/dist/docs/basic-marks.md +11 -47
- package/dist/docs/block-menu.md +22 -16
- package/dist/docs/block-placeholder.md +3 -13
- package/dist/docs/blockquote.md +1 -11
- package/dist/docs/board.md +4 -16
- package/dist/docs/bold.md +1 -7
- package/dist/docs/browser.md +6 -17
- package/dist/docs/callout.md +22 -46
- package/dist/docs/clear-formatting.md +1 -11
- package/dist/docs/clipboard.md +15 -6
- package/dist/docs/code-block.md +33 -33
- package/dist/docs/code.md +1 -7
- package/dist/docs/collaboration.md +122 -0
- package/dist/docs/column.md +8 -18
- package/dist/docs/combobox.md +45 -72
- package/dist/docs/comment.md +52 -28
- package/dist/docs/components/toolbar-buttons.md +38 -0
- package/dist/docs/controlled.md +11 -15
- package/dist/docs/copilot.md +36 -60
- package/dist/docs/date.md +3 -13
- package/dist/docs/details.md +16 -16
- package/dist/docs/diff.md +106 -0
- package/dist/docs/discussion.md +8 -4
- package/dist/docs/dnd.md +54 -61
- package/dist/docs/document-model.md +3 -3
- package/dist/docs/docx.md +40 -21
- package/dist/docs/dom-coverage.md +1 -1
- package/dist/docs/editing-behavior.md +5 -8
- package/dist/docs/editor.md +9 -11
- package/dist/docs/emoji.md +3 -13
- package/dist/docs/equation.md +4 -14
- package/dist/docs/examples/collaboration-example.md +5 -3
- package/dist/docs/examples/editable-voids.md +2 -0
- package/dist/docs/examples/export.md +4 -2
- package/dist/docs/examples/huge-document.md +8 -0
- package/dist/docs/examples/hundreds-editors.md +2 -0
- package/dist/docs/examples/merge.md +46 -0
- package/dist/docs/examples/preview-markdown.md +2 -0
- package/dist/docs/examples/version-history.md +27 -9
- package/dist/docs/exit-break.md +7 -15
- package/dist/docs/field.md +8 -12
- package/dist/docs/find.md +7 -7
- package/dist/docs/font.md +22 -40
- package/dist/docs/footnote.md +154 -200
- package/dist/docs/form.md +2 -2
- package/dist/docs/format-painter.md +1 -11
- package/dist/docs/heading.md +1 -3
- package/dist/docs/highlight.md +2 -8
- package/dist/docs/horizontal-rule.md +3 -13
- package/dist/docs/indent.md +26 -77
- package/dist/docs/index.md +40 -92
- package/dist/docs/ink.md +41 -42
- package/dist/docs/installation/manual.md +24 -28
- package/dist/docs/installation/next.md +21 -21
- package/dist/docs/installation/node.md +6 -10
- package/dist/docs/installation/plate-ui.md +9 -25
- package/dist/docs/installation/react.md +21 -21
- package/dist/docs/installation/rsc.md +7 -13
- package/dist/docs/installation.md +6 -32
- package/dist/docs/italic.md +1 -7
- package/dist/docs/kbd.md +1 -7
- package/dist/docs/line-height.md +1 -11
- package/dist/docs/link.md +47 -73
- package/dist/docs/lint.md +93 -136
- package/dist/docs/list.md +0 -8
- package/dist/docs/llms.txt +64 -60
- package/dist/docs/lock.md +17 -27
- package/dist/docs/markdown.md +25 -24
- package/dist/docs/media.md +59 -122
- package/dist/docs/mention.md +3 -13
- package/dist/docs/multi-select.md +20 -32
- package/dist/docs/navigation-feedback.md +23 -40
- package/dist/docs/pagination.md +2 -0
- package/dist/docs/performance.md +8 -14
- package/dist/docs/plugin-components.md +22 -22
- package/dist/docs/plugin-input-rules.md +16 -26
- package/dist/docs/plugin-methods.md +4 -6
- package/dist/docs/plugin-rules.md +4 -4
- package/dist/docs/plugin-shortcuts.md +5 -5
- package/dist/docs/plugin.md +6 -6
- package/dist/docs/prompt-editor.md +30 -67
- package/dist/docs/releases.md +3 -1
- package/dist/docs/rtl.md +2 -0
- package/dist/docs/selection.md +2 -0
- package/dist/docs/serializing.md +1 -1
- package/dist/docs/single-block.md +1 -3
- package/dist/docs/slash-command.md +8 -16
- package/dist/docs/static.md +70 -31
- package/dist/docs/strikethrough.md +1 -7
- package/dist/docs/subscript.md +1 -7
- package/dist/docs/suggestion.md +14 -12
- package/dist/docs/superscript.md +1 -7
- package/dist/docs/sync.md +41 -52
- package/dist/docs/tabbable.md +34 -54
- package/dist/docs/table.md +14 -30
- package/dist/docs/text-align.md +1 -11
- package/dist/docs/toc.md +33 -67
- package/dist/docs/toolbar.md +40 -56
- package/dist/docs/trailing-block.md +1 -5
- package/dist/docs/transactions.md +2 -2
- package/dist/docs/troubleshooting.md +5 -5
- package/dist/docs/underline.md +1 -7
- package/dist/docs/unit-testing.md +3 -5
- package/dist/docs/upload.md +7 -14
- package/dist/docx/export/index.d.ts +45 -8
- package/dist/docx/export/index.js +2 -1
- package/dist/docx/export/lib/compileAst.js +2 -0
- package/dist/docx/export/lib/docxComments.js +91 -0
- package/dist/docx/export/lib/exportDocx.js +14 -10
- package/dist/docx/export/lib/ooxmlBuilder.js +13 -3
- package/dist/docx/html/cleanWordHtml.internal.js +4 -4
- package/dist/docx/import/index.d.ts +30 -5
- package/dist/docx/import/index.js +2 -1
- package/dist/docx/import/lib/docxComments.js +130 -0
- package/dist/docx/import/lib/importDocx.js +31 -29
- package/dist/docx/import/lib/opcRelationships.js +0 -1
- package/dist/docx/internal/docxComments.js +34 -0
- package/dist/docx/internal/docxPackage.js +7 -17
- package/dist/docx/paste/index.d.ts +4 -4
- package/dist/dom/index.d.ts +1 -1
- package/dist/facade.js +2 -2
- package/dist/features/board/index.d.ts +1 -1
- package/dist/features/callout/index.d.ts +3 -3
- package/dist/features/callout/lib/BaseCalloutPlugin.js +28 -8
- package/dist/features/column/index.d.ts +1 -1
- package/dist/features/comments/BaseCommentsPlugin.js +912 -597
- package/dist/features/comments/comment-active-presentations.internal.js +86 -0
- package/dist/features/comments/comment-range-reader.internal.js +12 -0
- package/dist/features/comments/comment-thread-index.internal.js +49 -3
- package/dist/features/comments/comment-unresolved-index.internal.js +92 -0
- package/dist/features/comments/comment-validation.internal.js +129 -0
- package/dist/features/comments/index.d.ts +3 -3
- package/dist/features/comments/index.js +2 -2
- package/dist/features/date/index.d.ts +3 -3
- package/dist/features/details/index.d.ts +8 -5
- package/dist/features/details/lib/BaseDetailsPlugin.js +359 -151
- package/dist/features/field/index.d.ts +1 -1
- package/dist/features/find/index.d.ts +3 -3
- package/dist/features/footnote/index.d.ts +3 -3
- package/dist/features/ink/index.d.ts +2 -2
- package/dist/features/ink/index.js +2 -2
- package/dist/features/ink/lib/BaseInkPlugin.js +352 -24
- package/dist/features/ink/lib/inkPlaces.internal.js +2 -1
- package/dist/features/ink/lib/inkSvg.internal.js +419 -0
- package/dist/features/lint/index.d.ts +3 -3
- package/dist/features/lock/index.d.ts +1 -1
- package/dist/features/media/index.d.ts +1 -1
- package/dist/features/mention/index.d.ts +1 -1
- package/dist/features/table/index.d.ts +2 -2
- package/dist/features/table/lib/BaseTablePlugin.js +204 -44
- package/dist/features/table/lib/internal/paste.js +65 -3
- package/dist/features/table/lib/internal/selection.js +2 -15
- 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 +8 -6
- package/dist/features/upload/lib/uploadRules.internal.js +1 -1
- package/dist/history/index.d.ts +1 -1
- package/dist/html/index.d.ts +4 -4
- package/dist/html/server/index.d.ts +2 -2
- package/dist/{htmlConversion-BjWKSL9U.d.ts → htmlConversion-CSKHZpPj.d.ts} +2 -2
- package/dist/{htmlTypes-DhhCZ5de.d.ts → htmlTypes-BWVmZblT.d.ts} +3 -3
- package/dist/hyperscript/index.d.ts +1 -1
- package/dist/index-B3oYKAuz.d.ts +1 -0
- package/dist/{index-Hhh7UWtu.d.ts → index-BC79Ewsl.d.ts} +23 -126
- package/dist/index-BTjtVYbH.d.ts +1 -0
- package/dist/{index-NQXqGOd_.d.ts → index-BXvEAvgI.d.ts} +3 -5
- package/dist/{index-B9MSpRO4.d.ts → index-BYUrsInt.d.ts} +3 -3
- package/dist/{index-XBddGrs0.d.ts → index-BcyYN0cZ.d.ts} +61 -30
- package/dist/{index-CL1HDdJA.d.ts → index-BnxfTW_D.d.ts} +1 -1
- package/dist/{index-DxMNc53b-Bdy03WjR.d.ts → index-BufRKKbx-D3xRkmBz.d.ts} +1 -1
- package/dist/{index-DqZkcYSn.d.ts → index-Bwli-ZAF.d.ts} +169 -16
- package/dist/index-BwvwktHw-CcWHZqCi.d.ts +254 -0
- package/dist/{index-Cdd0v2xd.d.ts → index-C_c8FQDA.d.ts} +36 -18
- package/dist/{index-BT95dgbV.d.ts → index-Cnj81Ocd.d.ts} +7 -308
- package/dist/{index-xOaKk1Z-.d.ts → index-Cov2Zhgo.d.ts} +3 -3
- package/dist/{index-C-n83a4v.d.ts → index-CsmfJqlG.d.ts} +3 -3
- package/dist/{index-S9UTBCu_-CGKumalB.d.ts → index-D0hlRs2L-CIw3VG6r.d.ts} +76 -10
- package/dist/{index-CVn-5iB8.d.ts → index-DOdoRr4z.d.ts} +203 -2733
- package/dist/{index-BvShRH4t.d.ts → index-DgPZlAbx.d.ts} +3 -3
- package/dist/{index-CoqXuw4e.d.ts → index-Dsj3VBEr.d.ts} +1 -1
- package/dist/{index-CEJVYDwV.d.ts → index-QhGbk8ma.d.ts} +2 -2
- package/dist/{index-Bc7mANJA.d.ts → index-SOntT3DN.d.ts} +3 -3
- package/dist/{index-SXWqKqcr.d.ts → index-YycKj5Rf.d.ts} +17 -14
- package/dist/{index-CNVnEmz_.d.ts → index-hWp8X22M.d.ts} +3 -3
- package/dist/{index-Bm17RPgG.d.ts → index-nO2mlsRF.d.ts} +2 -2
- package/dist/index-z7QR7V33.d.ts +3 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -4
- package/dist/internal/comments/comment-anchor.internal.js +77 -21
- package/dist/internal/plugin/OverridePlugin.js +9 -37
- package/dist/internal/plugin/conversionLaws.js +45 -0
- package/dist/internal/plugin/markdownPreservedProperties.js +25 -0
- package/dist/lib/plugins/affinity/AffinityPlugin.js +17 -6
- package/dist/lib/plugins/html/HtmlPlugin.js +15 -8
- package/dist/lib/plugins/html/htmlAst.js +35 -24
- package/dist/lib/plugins/html/htmlConversion.js +16 -8
- package/dist/lib/plugins/html/htmlRules.internal.js +5 -9
- package/dist/markdown/index.d.ts +2 -2
- package/dist/markdown/lib/MarkdownPlugin.js +74 -10
- package/dist/markdown/lib/internal/markdownBareLinks.js +9 -4
- package/dist/markdown/lib/internal/markdownDiagnostics.js +4 -25
- package/dist/markdown/lib/internal/markdownMappings.js +8 -4
- package/dist/markdown/lib/internal/markdownParse.js +62 -28
- package/dist/markdown/lib/internal/markdownRuntime.js +142 -41
- package/dist/markdown/lib/internal/markdownSafety.js +7 -73
- package/dist/markdown/lib/internal/markdownSerialize.js +2 -2
- package/dist/markdown/lib/internal/markdownStream.js +160 -385
- package/dist/markdown/lib/internal/markdownTags.js +127 -6
- package/dist/markdown/lib/internal/markdownTailHeal.js +50 -21
- package/dist/markdown/lib/serializer/reportOmittedProperties.js +4 -2
- package/dist/markdown/lib/utils/remarkPlugins.js +13 -9
- package/dist/math/index.d.ts +10 -378
- package/dist/math/react/index.d.ts +4 -4
- package/dist/migrations/documentMigrationAuthored.internal.js +1 -1
- package/dist/migrations/documentMigrations.js +7 -7
- package/dist/migrations/index.d.ts +4 -4
- package/dist/migrations/migratePlateV54.js +7 -1
- package/dist/migrations/migratePlateV54Ast.internal.js +18 -58
- package/dist/migrations/migratePlateV54BuiltIns.internal.js +17 -2
- package/dist/migrations/migratePlateV54Callout.internal.js +61 -0
- package/dist/migrations/migratePlateV54Excalidraw.internal.js +534 -0
- package/dist/migrations/migratePlateV54ExcalidrawHelpers.internal.js +82 -0
- package/dist/migrations/migratePlateV54Profile.internal.js +3 -2
- package/dist/migrations/migratePlateV54Suggestions.internal.js +8 -1
- package/dist/pagination/index.d.ts +1 -1
- package/dist/pagination/react/index.d.ts +21 -34
- package/dist/plain-text.js +2 -1
- package/dist/{protocol-pJoaS7Lo-TtlxZ56u.d.ts → protocol-CikFZBQT-CkSt_wOg.d.ts} +18 -3
- package/dist/react/authored/index.d.ts +4 -4
- package/dist/react/components/EditorContentView.internal.js +2 -3
- package/dist/react/components/NodeSelection.js +21 -13
- package/dist/react/components/PlateView.js +25 -17
- package/dist/react/core.js +1 -4
- package/dist/react/features/board/index.d.ts +5 -5
- package/dist/react/features/callout/index.d.ts +4 -4
- package/dist/react/features/column/index.d.ts +92 -7
- package/dist/react/features/combobox/index.d.ts +4 -4
- package/dist/react/features/comments/index.d.ts +11 -346
- package/dist/react/features/comments/index.js +2 -2
- package/dist/react/features/comments/useCommentThreadIndex.js +22 -81
- package/dist/react/features/date/index.d.ts +4 -4
- package/dist/react/features/details/index.d.ts +123 -9
- package/dist/react/features/field/index.d.ts +5 -5
- package/dist/react/features/footnote/index.d.ts +48 -656
- package/dist/react/features/format-painter/index.d.ts +8 -116
- package/dist/react/features/ink/InkContent.js +53 -16
- package/dist/react/features/ink/InkPlugin.js +19 -8
- package/dist/react/features/ink/index.d.ts +79 -239
- package/dist/react/features/ink/inkCapture.internal.js +69 -3
- package/dist/react/features/ink/inkImages.internal.js +49 -8
- package/dist/react/features/ink/inkInput.internal.js +41 -3
- package/dist/react/features/ink/inkPaint.internal.js +26 -7
- package/dist/react/features/ink/inkPick.internal.js +108 -38
- package/dist/react/features/ink/inkPlacement.internal.js +1 -1
- package/dist/react/features/lock/index.d.ts +5 -5
- package/dist/react/features/media/index.d.ts +5 -5
- package/dist/react/features/mention/index.d.ts +4 -4
- package/dist/react/features/table/index.d.ts +868 -2674
- package/dist/react/features/toc/index.d.ts +2 -2
- package/dist/react/features/upload/index.d.ts +7 -127
- package/dist/react/index.d.ts +7 -7
- package/dist/react/index.js +1 -4
- package/dist/react/plugin/toReactPlugin.js +25 -4
- package/dist/react/utils/BlockPlaceholderPlugin.js +6 -4
- package/dist/react/utils/dispatchPlateShortcut.internal.js +2 -1
- package/dist/react/utils/pipeHandler.internal.js +3 -1
- package/dist/react/virtualized.d.ts +3 -3
- package/dist/refusal-C6nSOIMX-D8fWV8GB.d.ts +1 -0
- package/dist/{registerEditorTools-Bm3Hb9ia.d.ts → registerEditorTools-CyPL0VPh.d.ts} +77 -76
- package/dist/root.js +1 -4
- package/dist/shared-room-BxXvrWve-D8fWV8GB.d.ts +1 -0
- package/dist/skills/plate/SKILL.md +1 -1
- package/dist/skills/plate/references/ai-and-agents.md +1 -1
- package/dist/skills/plate/references/pricing.md +14 -0
- package/dist/{source-DXZpdayy.d.ts → source-pnhMdrj3.d.ts} +3 -3
- package/dist/static/components/EditorStatic.js +41 -18
- package/dist/static/index.d.ts +11 -7
- package/dist/static/internal/staticDocumentView.js +110 -29
- package/dist/static/internal/staticPendingMedia.internal.js +30 -3
- package/dist/static/internal/staticPresentation.js +9 -3
- package/dist/static/renderStaticHtml.js +7 -1
- package/dist/{storage-CtuDpaxQ-BUPEA63U.d.ts → storage-Be0SAaPi-CAmIGvmd.d.ts} +2 -2
- package/dist/sync/cloudflare/index.d.ts +5 -5
- package/dist/sync/index.d.ts +5 -5
- package/dist/sync/index.js +2 -2
- package/dist/sync/postgres/index.d.ts +1 -1
- package/dist/sync/react/hooks.js +9 -2
- package/dist/sync/react/index.d.ts +18 -31
- package/dist/sync/react/index.js +2 -3
- package/dist/sync/server/index.d.ts +6 -5
- package/dist/sync/server/index.js +2 -2
- package/dist/tabbable/react/index.d.ts +4 -4
- package/dist/testing/index.d.ts +17 -8
- package/dist/{transport-BW8_dCgM-CF4HYBwr.d.ts → transport-DhoWUkMZ-Dg4M_Ihs.d.ts} +20 -2
- package/dist/{tx-only-CJBYIp_b-DMnAZyix.d.ts → tx-only-mEsamESa-Bzy5hDat.d.ts} +36 -17
- package/dist/utils/plate-keys.js +1 -1
- package/dist/{widths-BjHOVqQM.d.ts → widths-Dlj60VjK.d.ts} +5 -5
- package/package.json +3 -21
- package/dist/clipboard-format-key-DvfmQCuJ-HYdLkAbO.d.ts +0 -1
- package/dist/docs/excalidraw.md +0 -203
- package/dist/excalidraw/index.d.ts +0 -60
- package/dist/excalidraw/index.js +0 -2
- package/dist/excalidraw/lib/BaseExcalidrawPlugin.js +0 -27
- package/dist/excalidraw/react/ExcalidrawPlugin.js +0 -6
- package/dist/excalidraw/react/index.d.ts +0 -107
- package/dist/excalidraw/react/index.js +0 -3
- package/dist/excalidraw/react/useExcalidrawSync.js +0 -227
- package/dist/index-B49W4Rdt-POMRw5lI.d.ts +0 -118
- package/dist/index-B7I8LIvp.d.ts +0 -3
- package/dist/index-Bmh2YAsK.d.ts +0 -1
- package/dist/index-ivTjNzIe.d.ts +0 -1
- package/dist/lib/utils/applyDeepToNodes.js +0 -17
- package/dist/lib/utils/defaultsDeepToNodes.js +0 -12
- package/dist/lib/utils/mergeDeepToNodes.js +0 -12
- package/dist/refusal-BSa4ShXv-HYdLkAbO.d.ts +0 -1
- package/dist/skills/plate/references/plus-and-pro.md +0 -12
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { $
|
|
2
|
-
import "./htmlTypes-
|
|
3
|
-
import { N as DataTransferDiagnostic, S as DOMEditor, V as ViewportRect, c as DOMApi, d as DOMCoverageCopyPolicy, f as DOMCoverageMaterializeRangeRole, h as DOMCoverageSelectionPolicy, l as DOMClipboardApi, m as DOMCoverageReason, n as DOMPluginTypes, p as DOMCoverageMaterializeReason, r as DropIndicator, t as DOMPlugin, u as DOMCoverageBoundary } from "./index-
|
|
4
|
-
import {
|
|
1
|
+
import { $o as Range, Hc as StateFieldValueInput, Hl as Value, Jc as Text, O as DecorationAttributes, Oi as HistoryOutcome, Ol as TransferPlugin, Qa as Plugin, Wa as Path, Yi as NamedRootKey, _l as TransferCheck, _t as EditorDocumentValue, bl as TransferInput, d as AnyEditor, fo as PluginDependencyContractReference, fs as RootKey, gi as Element$1, gl as TransferApi, ja as NodeTarget, ma as NodeKey, mo as PluginDependencyReferenceFor, ti as EditorUpdatePolicy, tr as EditorSelectorDependencies, wl as TransferOutcome, xl as TransferIntent } from "./tx-only-mEsamESa-Bzy5hDat.js";
|
|
2
|
+
import "./htmlTypes-BWVmZblT.js";
|
|
3
|
+
import { N as DataTransferDiagnostic, S as DOMEditor, V as ViewportRect, c as DOMApi, d as DOMCoverageCopyPolicy, f as DOMCoverageMaterializeRangeRole, h as DOMCoverageSelectionPolicy, l as DOMClipboardApi, m as DOMCoverageReason, n as DOMPluginTypes, p as DOMCoverageMaterializeReason, r as DropIndicator, t as DOMPlugin, u as DOMCoverageBoundary } from "./index-DgPZlAbx.js";
|
|
4
|
+
import { o as Editor$2, st as BasePluginInput } from "./core-BWS1N1EV.js";
|
|
5
5
|
import React$1, { CSSProperties, KeyboardEvent as KeyboardEvent$1, MouseEventHandler, ReactNode, Ref, RefObject, TextareaHTMLAttributes } from "react";
|
|
6
6
|
type DecorationSlice = Readonly<{
|
|
7
7
|
attributes: DecorationAttributes;
|
|
@@ -641,7 +641,7 @@ declare function useEditorRootAreas<TEditor extends AnyEditor = AnyEditor>(edito
|
|
|
641
641
|
* Selection match mode for `useElementSelected`:
|
|
642
642
|
*
|
|
643
643
|
* - `intersects`: any selection reaches the element.
|
|
644
|
-
* - `collapsed`: a collapsed selection reaches the element.
|
|
644
|
+
* - `collapsed`: a collapsed text selection reaches the element; any node selection is false.
|
|
645
645
|
* - `text`: a text selection reaches the element; any node selection is false.
|
|
646
646
|
* - `node`: a node selection holds the element.
|
|
647
647
|
* - `object`: an object node selection holds the element itself.
|
|
@@ -759,11 +759,32 @@ type EditorStaticProps<E = Editor$2> = {
|
|
|
759
759
|
* preview. The editor supplies the plugins and is not edited. Pass the same
|
|
760
760
|
* object again to reuse its validated view. Reads, plugin reads and plugin
|
|
761
761
|
* APIs on the rendered editor see the document; an editor captured when a
|
|
762
|
-
* plugin was created still holds its own value.
|
|
762
|
+
* plugin was created still holds its own value. Mutually exclusive with
|
|
763
|
+
* `fragment`.
|
|
763
764
|
*/
|
|
764
765
|
document?: EditorDocumentValue;
|
|
765
766
|
/** Editor instance. */
|
|
766
767
|
editor: E;
|
|
768
|
+
/**
|
|
769
|
+
* Block fragment to render instead of the editor's document (for example a
|
|
770
|
+
* streamed AI draft). Validated against the editor's element, property, and
|
|
771
|
+
* mark schema via `assertFragment` without enforcing root-prefix rules.
|
|
772
|
+
* Mutually exclusive with `document`.
|
|
773
|
+
*/
|
|
774
|
+
fragment?: Value;
|
|
775
|
+
/**
|
|
776
|
+
* Marks rendered element attributes with `data-editor-inert-media` so static
|
|
777
|
+
* media renderers keep remote URLs inert during untrusted draft previews.
|
|
778
|
+
*/
|
|
779
|
+
inertRemoteMedia?: boolean;
|
|
780
|
+
/**
|
|
781
|
+
* Static plugins that draw the render when `editor` is a live editor, such as
|
|
782
|
+
* the app's static kit. The editor keeps the document, schema, and plugin
|
|
783
|
+
* settings; matched plugin names supply element components, mark components,
|
|
784
|
+
* function wrapper slots, `render.readsDocument`, and static decoration peer
|
|
785
|
+
* filtering. Unmatched editing components render plainly. Pass a stable array.
|
|
786
|
+
*/
|
|
787
|
+
presentation?: readonly BasePluginInput[];
|
|
767
788
|
style?: React$1.CSSProperties;
|
|
768
789
|
} & React$1.HTMLAttributes<HTMLDivElement>;
|
|
769
790
|
declare function EditorStatic<E = Editor$2>(props: EditorStaticProps<E>): React$1.JSX.Element;
|
package/dist/ai/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { A as EditorReadSelection, B as GetEditorToolsOptions, C as EditorIdempotencyEntry, D as EditorReadBlock, E as EditorInkPassageImage, F as EditorToolErrorCode, G as SyncServerAgentPresenceOptions, H as SyncServerAgentHost, I as EditorToolErrorResult, J as SyncServerAgentReceipt, K as SyncServerAgentPresencePoint, L as EditorToolResult, M as EditorToolAnnotation, N as EditorToolCall, O as EditorReadInkResult, P as EditorToolDefinition, Q as getEditorTools, R as EditorVisibilityFilter, S as EditorFindResult, T as EditorInkPassage, U as SyncServerAgentOptions, V as SyncServerAgentGrant, W as SyncServerAgentPresenceInput, X as createEditorAgent, Y as SyncServerAgentRunResult, Z as createSyncServerAgent, _ as EditorAgentPresence, a as HasEditableAISelectionRefs, b as EditorCommentsListResult, c as SerializeAISelectionMarkdownOptions, d as serializeAIEditContext, f as serializeAISelectionMarkdown, g as EditorAgentOptions, h as EditorAgentExecuteOptions, i as AILockedBlockRef, j as EditorSuggestionsListResult, k as EditorReadResult, l as SerializedAIEditContext, m as EditorAgentAccess, n as WebMCPProducerContext, o as LOCKED_BLOCK_PLACEHOLDER_TAG, p as EditorAgent, q as SyncServerAgentPresenceSelection, r as registerEditorTools, s as SerializeAIEditContextOptions, t as RegisterEditorToolsOptions, u as hasEditableAISelection, v as EditorAgentPresenceState, w as EditorIdempotencyStore, x as EditorDebugResult, y as EditorCommentEntry, z as EditorWriteReceipt } from "../registerEditorTools-CyPL0VPh.js";
|
|
2
|
+
export { AILockedBlockRef, EditorAgent, EditorAgentAccess, EditorAgentExecuteOptions, EditorAgentOptions, EditorAgentPresence, EditorAgentPresenceState, EditorCommentEntry, EditorCommentsListResult, EditorDebugResult, EditorFindResult, EditorIdempotencyEntry, EditorIdempotencyStore, EditorInkPassage, EditorInkPassageImage, EditorReadBlock, EditorReadInkResult, EditorReadResult, EditorReadSelection, EditorSuggestionsListResult, EditorToolAnnotation, EditorToolCall, EditorToolDefinition, EditorToolErrorCode, EditorToolErrorResult, EditorToolResult, EditorVisibilityFilter, EditorWriteReceipt, GetEditorToolsOptions, HasEditableAISelectionRefs, LOCKED_BLOCK_PLACEHOLDER_TAG, RegisterEditorToolsOptions, SerializeAIEditContextOptions, SerializeAISelectionMarkdownOptions, SerializedAIEditContext, SyncServerAgentGrant, SyncServerAgentHost, SyncServerAgentOptions, SyncServerAgentPresenceInput, SyncServerAgentPresenceOptions, SyncServerAgentPresencePoint, SyncServerAgentPresenceSelection, SyncServerAgentReceipt, SyncServerAgentRunResult, WebMCPProducerContext, createEditorAgent, createSyncServerAgent, getEditorTools, hasEditableAISelection, registerEditorTools, serializeAIEditContext, serializeAISelectionMarkdown };
|
package/dist/ai/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { LOCKED_BLOCK_PLACEHOLDER_TAG, hasEditableAISelection, serializeAIEditContext, serializeAISelectionMarkdown } from "./lib/lockedContext.js";
|
|
2
|
-
import { createAIDraftSession } from "./lib/aiDraftSession.js";
|
|
3
1
|
import { createEditorAgent, createSyncServerAgent, getEditorTools } from "./lib/editorAgent.js";
|
|
2
|
+
import { LOCKED_BLOCK_PLACEHOLDER_TAG, hasEditableAISelection, serializeAIEditContext, serializeAISelectionMarkdown } from "./lib/lockedContext.js";
|
|
4
3
|
import { registerEditorTools } from "./lib/registerEditorTools.js";
|
|
5
|
-
export { LOCKED_BLOCK_PLACEHOLDER_TAG,
|
|
4
|
+
export { LOCKED_BLOCK_PLACEHOLDER_TAG, createEditorAgent, createSyncServerAgent, getEditorTools, hasEditableAISelection, registerEditorTools, serializeAIEditContext, serializeAISelectionMarkdown };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createAuthoredEditorView, getCompiledEditorSchema, getEditorAuthoredDocumentCapability, hasNonWritableAt
|
|
1
|
+
import { EditorRefusalError, createAuthoredEditorView, getCompiledEditorSchema, getEditorAuthoredDocumentCapability, hasNonWritableAt } from "../../facade.js";
|
|
2
2
|
import { BaseParagraphPlugin } from "../../lib/plugins/paragraph/BaseParagraphPlugin.js";
|
|
3
3
|
import { ContentSlice, ElementApi, NodeApi, PathApi, RangeApi, createEditorView } from "../../core.js";
|
|
4
4
|
import { isListItem } from "../../features/list/lib/listIndex.internal.js";
|
|
@@ -12,11 +12,40 @@ import isEqual from "lodash/isEqual.js";
|
|
|
12
12
|
import cloneDeep from "lodash/cloneDeep.js";
|
|
13
13
|
//#region src/ai/lib/aiDraftSession.ts
|
|
14
14
|
const EMPTY_DRAFT_NODES = Object.freeze([]);
|
|
15
|
+
const AI_INTERNAL_REFUSAL_STALE = "ai-session-internal-stale";
|
|
16
|
+
const AI_INTERNAL_REFUSAL_HIDDEN = "ai-session-internal-hidden";
|
|
17
|
+
const AI_INTERNAL_REFUSAL_LOCKED = "ai-session-internal-locked";
|
|
18
|
+
const AI_INTERNAL_REFUSAL_WITHDRAW = "ai-session-internal-withdraw";
|
|
15
19
|
const isLockRefusalRecord = (record) => {
|
|
16
20
|
if (!record || typeof record !== "object") return false;
|
|
17
21
|
const { reason } = record;
|
|
18
22
|
return reason === "block-locked" || reason === "node-write-veto";
|
|
19
23
|
};
|
|
24
|
+
const readRefusalReason = (record) => record && typeof record === "object" && typeof record.reason === "string" ? record.reason : null;
|
|
25
|
+
const mapUpdateRefusal = (refusal, cellRef) => {
|
|
26
|
+
const reason = readRefusalReason(refusal);
|
|
27
|
+
if (reason === AI_INTERNAL_REFUSAL_STALE) return Object.freeze({ status: "stale" });
|
|
28
|
+
if (reason === AI_INTERNAL_REFUSAL_HIDDEN) return Object.freeze({
|
|
29
|
+
refusal: { reason: "hidden-content" },
|
|
30
|
+
status: "refused"
|
|
31
|
+
});
|
|
32
|
+
if (reason === AI_INTERNAL_REFUSAL_LOCKED) return Object.freeze({
|
|
33
|
+
refusal: { reason: "block-locked" },
|
|
34
|
+
status: "refused"
|
|
35
|
+
});
|
|
36
|
+
if (reason === AI_INTERNAL_REFUSAL_WITHDRAW) return Object.freeze({ status: "refused" });
|
|
37
|
+
if (isLockRefusalRecord(refusal) || refusal === void 0) return Object.freeze({
|
|
38
|
+
refusal: cellRef === void 0 ? { reason: "block-locked" } : {
|
|
39
|
+
reason: "block-locked",
|
|
40
|
+
ref: cellRef
|
|
41
|
+
},
|
|
42
|
+
status: "refused"
|
|
43
|
+
});
|
|
44
|
+
return Object.freeze({
|
|
45
|
+
refusal,
|
|
46
|
+
status: "refused"
|
|
47
|
+
});
|
|
48
|
+
};
|
|
20
49
|
const stripMarkdownSyntax = (input) => input.replaceAll(/<\/?[a-zA-Z][\w-]*(?:\s+[^>]*)?\/?>/g, "").replaceAll(/!\[([^\]]*)\]\([^)]*\)/g, "$1").replaceAll(/\[([^\]]+)\]\([^)]*\)/g, "$1").replaceAll(/^\s{0,3}(?:---+|\*\*\*+|___+)\s*$/gm, "").replaceAll(/^\s{0,3}(?:#{1,6}\s+|>\s+|[-*+]\s+|\d+\.\s+)/gm, "").replaceAll(/(\*\*|__|~~|`)/g, "").replaceAll(/(^|[^\w])\*([^*]+)\*(?=[^\w]|$)/g, "$1$2").replaceAll(/(^|[^\w])_([^_]+)_(?=[^\w]|$)/g, "$1$2");
|
|
21
50
|
const normalizeWithIndexMap = (text) => {
|
|
22
51
|
const chars = [];
|
|
@@ -110,6 +139,55 @@ const createAIDraftSession = (editor, options) => {
|
|
|
110
139
|
let cachedRootView = null;
|
|
111
140
|
let lastCommittedRevision = null;
|
|
112
141
|
let baselineSourceNodes = null;
|
|
142
|
+
let baselineLockedSourceRuns = null;
|
|
143
|
+
const readNodeAnchor = (view, key) => {
|
|
144
|
+
const entry = view.read.nodes.get(key, { match: ElementApi.isElement });
|
|
145
|
+
if (!entry) return null;
|
|
146
|
+
const [node, path] = entry;
|
|
147
|
+
const nodeId = typeof node.id === "string" && node.id.length > 0 ? node.id : null;
|
|
148
|
+
const revision = (nodeId !== null ? view.read.nodes.revision(nodeId) : null) ?? JSON.stringify(node);
|
|
149
|
+
const parentEntry = path.length > 1 ? view.read.nodes.get(PathApi.parent(path), { match: ElementApi.isElement }) : void 0;
|
|
150
|
+
return {
|
|
151
|
+
key,
|
|
152
|
+
parentKey: parentEntry ? view.key(parentEntry[0]) ?? null : null,
|
|
153
|
+
revision
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
const captureTargetAnchor = (view) => {
|
|
157
|
+
if (targetNodeKeys.length === 0) return null;
|
|
158
|
+
const entries = [];
|
|
159
|
+
for (const key of targetNodeKeys) {
|
|
160
|
+
const entry = view.read.nodes.get(key, { match: ElementApi.isElement });
|
|
161
|
+
if (!entry) return null;
|
|
162
|
+
entries.push([
|
|
163
|
+
entry[0],
|
|
164
|
+
entry[1],
|
|
165
|
+
key
|
|
166
|
+
]);
|
|
167
|
+
}
|
|
168
|
+
entries.sort(([, left], [, right]) => PathApi.compare(left, right));
|
|
169
|
+
const anchors = [];
|
|
170
|
+
for (const entry of entries) {
|
|
171
|
+
const anchor = readNodeAnchor(view, entry[2]);
|
|
172
|
+
if (!anchor) return null;
|
|
173
|
+
anchors.push(anchor);
|
|
174
|
+
}
|
|
175
|
+
return anchors;
|
|
176
|
+
};
|
|
177
|
+
let targetAnchor = captureTargetAnchor(editor);
|
|
178
|
+
const cellAnchorRevisions = /* @__PURE__ */ new Map();
|
|
179
|
+
for (const key of tableCellAllowlist.values()) cellAnchorRevisions.set(key, readNodeAnchor(editor, key)?.revision ?? null);
|
|
180
|
+
const refreshAnchors = (refreshOptions) => {
|
|
181
|
+
lastCommittedRevision = editor.read.revision();
|
|
182
|
+
if (refreshOptions?.onlyCellKey !== void 0) {
|
|
183
|
+
const { onlyCellKey, refreshTargetAnchor } = refreshOptions;
|
|
184
|
+
cellAnchorRevisions.set(onlyCellKey, readNodeAnchor(getRootView(), onlyCellKey)?.revision ?? null);
|
|
185
|
+
if (refreshTargetAnchor) targetAnchor = captureTargetAnchor(getRootView());
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
targetAnchor = captureTargetAnchor(getRootView());
|
|
189
|
+
for (const key of tableCellAllowlist.values()) cellAnchorRevisions.set(key, readNodeAnchor(getRootView(), key)?.revision ?? null);
|
|
190
|
+
};
|
|
113
191
|
let snapshot = Object.freeze({
|
|
114
192
|
anchorKey,
|
|
115
193
|
changeId: null,
|
|
@@ -166,11 +244,11 @@ const createAIDraftSession = (editor, options) => {
|
|
|
166
244
|
status: "streaming"
|
|
167
245
|
});
|
|
168
246
|
};
|
|
169
|
-
const
|
|
247
|
+
const resolveOrderedTargetsFromNodes = (nodesApi, view) => {
|
|
170
248
|
if (targetNodeKeys.length === 0) return null;
|
|
171
249
|
const entries = [];
|
|
172
250
|
for (const key of targetNodeKeys) {
|
|
173
|
-
const entry =
|
|
251
|
+
const entry = nodesApi.get(key, { match: ElementApi.isElement });
|
|
174
252
|
if (!entry) return null;
|
|
175
253
|
if (!isPathVisible(view, filter, entry[1], pinnedRoot)) return null;
|
|
176
254
|
entries.push([entry[0], entry[1]]);
|
|
@@ -178,13 +256,41 @@ const createAIDraftSession = (editor, options) => {
|
|
|
178
256
|
entries.sort(([, left], [, right]) => PathApi.compare(left, right));
|
|
179
257
|
return entries;
|
|
180
258
|
};
|
|
259
|
+
const resolveOrderedTargets = (view) => resolveOrderedTargetsFromNodes(view.read.nodes, view);
|
|
260
|
+
const isTargetAnchorCurrent = (view = getRootView()) => {
|
|
261
|
+
if (targetAnchor === null) return editor.read.revision() === (lastCommittedRevision ?? baselineRevision);
|
|
262
|
+
const entries = [];
|
|
263
|
+
for (const expected of targetAnchor) {
|
|
264
|
+
const current = readNodeAnchor(view, expected.key);
|
|
265
|
+
if (!current || current.revision !== expected.revision || current.parentKey !== expected.parentKey) return false;
|
|
266
|
+
const entry = view.read.nodes.get(expected.key, { match: ElementApi.isElement });
|
|
267
|
+
if (!entry) return false;
|
|
268
|
+
entries.push([entry[0], entry[1]]);
|
|
269
|
+
}
|
|
270
|
+
if (entries.length > 1 && !selectionContainsHiddenBlocks) {
|
|
271
|
+
for (let i = 1; i < entries.length; i += 1) {
|
|
272
|
+
const prev = entries[i - 1];
|
|
273
|
+
const curr = entries[i];
|
|
274
|
+
if (!prev || !curr) return false;
|
|
275
|
+
if (PathApi.compare(prev[1], curr[1]) >= 0) return false;
|
|
276
|
+
}
|
|
277
|
+
if (!areAIBlockTargetsContiguous(view, entries)) return false;
|
|
278
|
+
}
|
|
279
|
+
return true;
|
|
280
|
+
};
|
|
281
|
+
const isCellAnchorCurrent = (cellKey) => {
|
|
282
|
+
const expected = cellAnchorRevisions.get(cellKey);
|
|
283
|
+
if (expected === void 0 || expected === null) return false;
|
|
284
|
+
const current = readNodeAnchor(getRootView(), cellKey);
|
|
285
|
+
return current !== null && current.revision === expected;
|
|
286
|
+
};
|
|
181
287
|
const withdrawOwnedChangeGuarded = (proposeView, currentChangeId) => {
|
|
182
|
-
if (
|
|
288
|
+
if (!isTargetAnchorCurrent(getRootView())) return "stale";
|
|
183
289
|
const previous = editor.plugin(AuthoredPlugin).read.change(currentChangeId);
|
|
184
290
|
if (!previous) return "stale";
|
|
185
291
|
const result = proposeView.update.result((tx) => tx.plugin(AuthoredPlugin).withdraw([previous]));
|
|
186
292
|
if (result.status !== "committed" || result.value.status !== "applied") return result.status === "committed" && result.value.status === "stale" ? "stale" : "refused";
|
|
187
|
-
|
|
293
|
+
refreshAnchors();
|
|
188
294
|
return "applied";
|
|
189
295
|
};
|
|
190
296
|
const push = (markdownDelta) => {
|
|
@@ -200,6 +306,10 @@ const createAIDraftSession = (editor, options) => {
|
|
|
200
306
|
}]);
|
|
201
307
|
}
|
|
202
308
|
const streamSnapshot = activeStream.append(markdownDelta);
|
|
309
|
+
if (!streamSnapshot.ok) return emit({
|
|
310
|
+
error: streamSnapshot.diagnostics[0].message,
|
|
311
|
+
status: "streaming"
|
|
312
|
+
});
|
|
203
313
|
return updateStreamPreview(streamSnapshot.nodes);
|
|
204
314
|
};
|
|
205
315
|
const set = (accumulatedMarkdown) => {
|
|
@@ -215,13 +325,17 @@ const createAIDraftSession = (editor, options) => {
|
|
|
215
325
|
}]);
|
|
216
326
|
}
|
|
217
327
|
const streamSnapshot = activeStream.set(accumulatedMarkdown);
|
|
328
|
+
if (!streamSnapshot.ok) return emit({
|
|
329
|
+
error: streamSnapshot.diagnostics[0].message,
|
|
330
|
+
status: "streaming"
|
|
331
|
+
});
|
|
218
332
|
return updateStreamPreview(streamSnapshot.nodes);
|
|
219
333
|
};
|
|
220
334
|
const hasHiddenEditableTarget = (entries) => {
|
|
221
335
|
const { roots } = editor.read.value();
|
|
222
336
|
return selectionContainsHiddenBlocks || entries.some(([node, path]) => hasHiddenDescendant(filter, node, path, pinnedRoot, roots));
|
|
223
337
|
};
|
|
224
|
-
const isRevisionCurrent = () =>
|
|
338
|
+
const isRevisionCurrent = () => isTargetAnchorCurrent(getRootView());
|
|
225
339
|
const landLockedSuggestion = (proposeView, rawDisallowedUrls) => {
|
|
226
340
|
const markdownPlugin = editor.plugin(MarkdownPlugin);
|
|
227
341
|
if (!markdownPlugin.installed) return Object.freeze({
|
|
@@ -261,8 +375,8 @@ const createAIDraftSession = (editor, options) => {
|
|
|
261
375
|
},
|
|
262
376
|
status: "refused"
|
|
263
377
|
});
|
|
264
|
-
const resolveLockedLayout = () => {
|
|
265
|
-
const ordered =
|
|
378
|
+
const resolveLockedLayout = (nodesApi = proposeView.read.nodes) => {
|
|
379
|
+
const ordered = resolveOrderedTargetsFromNodes(nodesApi, proposeView);
|
|
266
380
|
if (!ordered) return { kind: "stale" };
|
|
267
381
|
if (hasHiddenEditableTarget(ordered)) return { kind: "hidden" };
|
|
268
382
|
if (!areAIBlockTargetsContiguous(proposeView, ordered)) return { kind: "stale" };
|
|
@@ -309,25 +423,12 @@ const createAIDraftSession = (editor, options) => {
|
|
|
309
423
|
status: "refused"
|
|
310
424
|
});
|
|
311
425
|
const currentChangeId = snapshot.changeId;
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
const postLayout = currentChangeId ? resolveLockedLayout() : preLayout;
|
|
317
|
-
if (postLayout.kind === "stale") return Object.freeze({ status: "stale" });
|
|
318
|
-
if (postLayout.kind === "hidden") return Object.freeze({
|
|
319
|
-
refusal: { reason: "hidden-content" },
|
|
320
|
-
status: "refused"
|
|
321
|
-
});
|
|
322
|
-
if (postLayout.kind === "locked") return Object.freeze({
|
|
323
|
-
refusal: { reason: "block-locked" },
|
|
324
|
-
status: "refused"
|
|
325
|
-
});
|
|
326
|
-
const { lockedEntries, sourceRuns } = postLayout;
|
|
327
|
-
const preparedRuns = sourceRuns.map((sourceRun, index) => {
|
|
426
|
+
const previousChange = currentChangeId ? editor.plugin(AuthoredPlugin).read.change(currentChangeId) : null;
|
|
427
|
+
if (currentChangeId && !previousChange) return Object.freeze({ status: "stale" });
|
|
428
|
+
const prepareLockedRuns = (sourceRuns) => sourceRuns.map((sourceRun, index) => {
|
|
328
429
|
const answerRun = answerRuns[index] ?? [];
|
|
329
430
|
if (sourceRun.length === 0 || answerRun.length === 0) return answerRun;
|
|
330
|
-
const sourceNodes =
|
|
431
|
+
const sourceNodes = sourceRun.map(([node]) => node);
|
|
331
432
|
const serialized = markdownPlugin.api.serialize({
|
|
332
433
|
document: { children: sourceNodes },
|
|
333
434
|
lossPolicy: "allow"
|
|
@@ -340,53 +441,60 @@ const createAIDraftSession = (editor, options) => {
|
|
|
340
441
|
source: sourceNodes
|
|
341
442
|
}));
|
|
342
443
|
});
|
|
343
|
-
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
const
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
content: cloneDeep(nextRun),
|
|
373
|
-
openEnd: 0,
|
|
374
|
-
openStart: 0
|
|
375
|
-
}), { at: {
|
|
376
|
-
anchor,
|
|
377
|
-
focus
|
|
378
|
-
} });
|
|
444
|
+
const firstProjectedLockedRuns = !currentChangeId ? preLayout.sourceRuns.map((run) => projectBlocksForRoot(editor, pinnedRoot, run)) : null;
|
|
445
|
+
const prePreparedRuns = firstProjectedLockedRuns ? prepareLockedRuns(firstProjectedLockedRuns.map((nodes, runIndex) => {
|
|
446
|
+
const sourceRun = preLayout.sourceRuns[runIndex] ?? [];
|
|
447
|
+
return nodes.map((node, i) => [node, sourceRun[i]?.[1] ?? []]);
|
|
448
|
+
})) : null;
|
|
449
|
+
const updateResult = proposeView.update.result((tx) => {
|
|
450
|
+
if (previousChange) {
|
|
451
|
+
const withdrawOutcome = tx.plugin(AuthoredPlugin).withdraw([previousChange]);
|
|
452
|
+
if (withdrawOutcome.status !== "applied") throw new EditorRefusalError({ reason: withdrawOutcome.status === "stale" ? AI_INTERNAL_REFUSAL_STALE : AI_INTERNAL_REFUSAL_WITHDRAW }, "AI draft withdraw failed.");
|
|
453
|
+
}
|
|
454
|
+
const postLayout = currentChangeId ? resolveLockedLayout(tx.nodes) : preLayout;
|
|
455
|
+
if (postLayout.kind !== "ok") throw new EditorRefusalError({ reason: postLayout.kind === "stale" ? AI_INTERNAL_REFUSAL_STALE : postLayout.kind === "hidden" ? AI_INTERNAL_REFUSAL_HIDDEN : AI_INTERNAL_REFUSAL_LOCKED }, "AI locked layout invalid after withdraw.");
|
|
456
|
+
const { lockedEntries, sourceRuns } = postLayout;
|
|
457
|
+
const savedLockedBaseline = baselineLockedSourceRuns;
|
|
458
|
+
const canReuseProjectedBaseline = savedLockedBaseline !== null && savedLockedBaseline.length === sourceRuns.length;
|
|
459
|
+
const preparedRuns = prePreparedRuns ?? prepareLockedRuns(canReuseProjectedBaseline ? savedLockedBaseline.map((nodes, runIndex) => {
|
|
460
|
+
const sourceRun = sourceRuns[runIndex] ?? [];
|
|
461
|
+
return nodes.map((node, i) => [node, sourceRun[i]?.[1] ?? sourceRun.at(-1)?.[1] ?? []]);
|
|
462
|
+
}) : sourceRuns);
|
|
463
|
+
const changeId = tx.plugin(AuthoredPlugin).propose(currentChangeId ? { changeId: currentChangeId } : void 0);
|
|
464
|
+
for (let index = sourceRuns.length - 1; index >= 0; index -= 1) {
|
|
465
|
+
const sourceRun = sourceRuns[index] ?? [];
|
|
466
|
+
const nextRun = preparedRuns[index] ?? [];
|
|
467
|
+
const lockedAfter = lockedEntries[index];
|
|
468
|
+
const lastLocked = lockedEntries.at(-1);
|
|
469
|
+
if (sourceRun.length === 0) {
|
|
470
|
+
const insertAt = lockedAfter ? lockedAfter[1] : lastLocked ? PathApi.next(lastLocked[1]) : null;
|
|
471
|
+
if (nextRun.length > 0 && insertAt) tx.nodes.insert(cloneDeep(nextRun), { at: insertAt });
|
|
472
|
+
continue;
|
|
379
473
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
474
|
+
if (nextRun.length === 0) {
|
|
475
|
+
for (const [, path] of sourceRun.toReversed()) tx.nodes.remove({ at: path });
|
|
476
|
+
continue;
|
|
477
|
+
}
|
|
478
|
+
if (applyMinimalTextBlockEdits(tx, sourceRun.map(([node]) => node), sourceRun.map(([, path]) => path), nextRun) !== null) continue;
|
|
479
|
+
const first = sourceRun[0];
|
|
480
|
+
const last = sourceRun.at(-1);
|
|
481
|
+
if (!first || !last) continue;
|
|
482
|
+
const anchor = tx.points.start(first[1]);
|
|
483
|
+
const focus = tx.points.end(last[1]);
|
|
484
|
+
if (anchor && focus) tx.slice.replace(ContentSlice.fromJSON({
|
|
485
|
+
content: cloneDeep(nextRun),
|
|
486
|
+
openEnd: 0,
|
|
487
|
+
openStart: 0
|
|
488
|
+
}), { at: {
|
|
489
|
+
anchor,
|
|
490
|
+
focus
|
|
491
|
+
} });
|
|
492
|
+
}
|
|
493
|
+
return changeId;
|
|
388
494
|
});
|
|
495
|
+
if (updateResult.status === "refused") return mapUpdateRefusal(updateResult.refusal);
|
|
389
496
|
if (updateResult.status === "unchanged") {
|
|
497
|
+
baselineLockedSourceRuns = null;
|
|
390
498
|
emit({
|
|
391
499
|
changeId: null,
|
|
392
500
|
draftNodes: EMPTY_DRAFT_NODES,
|
|
@@ -394,7 +502,8 @@ const createAIDraftSession = (editor, options) => {
|
|
|
394
502
|
});
|
|
395
503
|
return Object.freeze({ status: "empty" });
|
|
396
504
|
}
|
|
397
|
-
|
|
505
|
+
if (firstProjectedLockedRuns) baselineLockedSourceRuns = cloneDeep(firstProjectedLockedRuns);
|
|
506
|
+
refreshAnchors();
|
|
398
507
|
emit({
|
|
399
508
|
changeId: updateResult.value,
|
|
400
509
|
draftNodes: EMPTY_DRAFT_NODES,
|
|
@@ -409,12 +518,14 @@ const createAIDraftSession = (editor, options) => {
|
|
|
409
518
|
if (disposed) return Object.freeze({ status: "aborted" });
|
|
410
519
|
const rawDisallowedUrls = findDisallowedRemoteMediaUrlsInMarkdown(rawMarkdown, options.allowRemoteMediaUrl);
|
|
411
520
|
if (mode === "detached") {
|
|
412
|
-
const
|
|
521
|
+
const finalResult = stream ? stream.finish() : null;
|
|
522
|
+
const finalNodes = finalResult ? finalResult.ok ? finalResult.slice.content : [] : snapshot.draftNodes;
|
|
413
523
|
const sanitized = sanitizeDraftOutput(finalNodes);
|
|
414
524
|
const removedUrls = [.../* @__PURE__ */ new Set([...rawDisallowedUrls, ...sanitized.removedUrls])];
|
|
415
525
|
if (sanitized.nodes.length === 0) {
|
|
416
526
|
emit({
|
|
417
527
|
draftNodes: EMPTY_DRAFT_NODES,
|
|
528
|
+
...finalResult && !finalResult.ok ? { error: finalResult.diagnostics[0].message } : {},
|
|
418
529
|
status: "idle"
|
|
419
530
|
});
|
|
420
531
|
if (removedUrls.length > 0) return Object.freeze({
|
|
@@ -450,7 +561,8 @@ const createAIDraftSession = (editor, options) => {
|
|
|
450
561
|
});
|
|
451
562
|
}
|
|
452
563
|
if (!isRevisionCurrent()) return Object.freeze({ status: "stale" });
|
|
453
|
-
const
|
|
564
|
+
const finalResult = stream ? stream.finish() : null;
|
|
565
|
+
const finalStreamNodes = finalResult ? finalResult.ok ? finalResult.slice.content : [] : snapshot.draftNodes;
|
|
454
566
|
const sanitized = sanitizeDraftOutput(finalStreamNodes);
|
|
455
567
|
const removedUrls = [.../* @__PURE__ */ new Set([...rawDisallowedUrls, ...sanitized.removedUrls])];
|
|
456
568
|
if (sanitized.nodes.length === 0) {
|
|
@@ -461,6 +573,7 @@ const createAIDraftSession = (editor, options) => {
|
|
|
461
573
|
emit({
|
|
462
574
|
changeId: null,
|
|
463
575
|
draftNodes: EMPTY_DRAFT_NODES,
|
|
576
|
+
...finalResult && !finalResult.ok ? { error: finalResult.diagnostics[0].message } : {},
|
|
464
577
|
status: "idle"
|
|
465
578
|
});
|
|
466
579
|
if (removedUrls.length > 0) return Object.freeze({
|
|
@@ -511,44 +624,35 @@ const createAIDraftSession = (editor, options) => {
|
|
|
511
624
|
return Object.freeze({ status: "empty" });
|
|
512
625
|
}
|
|
513
626
|
if (!currentChangeId) baselineSourceNodes = cloneDeep(sourceNodes);
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
anchor: startPoint,
|
|
540
|
-
focus: endPoint
|
|
541
|
-
} });
|
|
542
|
-
return changeId;
|
|
543
|
-
});
|
|
544
|
-
} finally {
|
|
545
|
-
unsubscribe();
|
|
546
|
-
}
|
|
547
|
-
if (lockedRefusal || updateResult.status === "refused") return Object.freeze({
|
|
548
|
-
refusal: { reason: "block-locked" },
|
|
549
|
-
status: "refused"
|
|
627
|
+
const previousChange = currentChangeId ? editor.plugin(AuthoredPlugin).read.change(currentChangeId) : null;
|
|
628
|
+
if (currentChangeId && !previousChange) return Object.freeze({ status: "stale" });
|
|
629
|
+
const updateResult = proposeView.update.result((tx) => {
|
|
630
|
+
if (previousChange) {
|
|
631
|
+
const withdrawOutcome = tx.plugin(AuthoredPlugin).withdraw([previousChange]);
|
|
632
|
+
if (withdrawOutcome.status !== "applied") throw new EditorRefusalError({ reason: withdrawOutcome.status === "stale" ? AI_INTERNAL_REFUSAL_STALE : AI_INTERNAL_REFUSAL_WITHDRAW }, "AI draft withdraw failed.");
|
|
633
|
+
}
|
|
634
|
+
const targetEntries = resolveOrderedTargetsFromNodes(tx.nodes, proposeView);
|
|
635
|
+
if (!targetEntries || targetEntries.length === 0) throw new EditorRefusalError({ reason: AI_INTERNAL_REFUSAL_STALE }, "AI target blocks missing after withdraw.");
|
|
636
|
+
const first = targetEntries[0];
|
|
637
|
+
const last = targetEntries.at(-1);
|
|
638
|
+
if (!first || !last) throw new EditorRefusalError({ reason: AI_INTERNAL_REFUSAL_STALE }, "AI target range missing after withdraw.");
|
|
639
|
+
const startPoint = tx.points.start(first[1]);
|
|
640
|
+
const endPoint = tx.points.end(last[1]);
|
|
641
|
+
const changeId = tx.plugin(AuthoredPlugin).propose(currentChangeId ? { changeId: currentChangeId } : void 0);
|
|
642
|
+
if (applyMinimalTextBlockEdits(tx, targetEntries.map(([node]) => node), targetEntries.map(([, path]) => path), fitted) !== null) return changeId;
|
|
643
|
+
if (startPoint && endPoint) tx.slice.replace(ContentSlice.fromJSON({
|
|
644
|
+
content: cloneDeep(fitted),
|
|
645
|
+
openEnd: 0,
|
|
646
|
+
openStart: 0
|
|
647
|
+
}), { at: {
|
|
648
|
+
anchor: startPoint,
|
|
649
|
+
focus: endPoint
|
|
650
|
+
} });
|
|
651
|
+
return changeId;
|
|
550
652
|
});
|
|
653
|
+
if (updateResult.status === "refused") return mapUpdateRefusal(updateResult.refusal);
|
|
551
654
|
if (updateResult.status === "unchanged") {
|
|
655
|
+
baselineSourceNodes = null;
|
|
552
656
|
emit({
|
|
553
657
|
changeId: null,
|
|
554
658
|
draftNodes: EMPTY_DRAFT_NODES,
|
|
@@ -556,7 +660,7 @@ const createAIDraftSession = (editor, options) => {
|
|
|
556
660
|
});
|
|
557
661
|
return Object.freeze({ status: "empty" });
|
|
558
662
|
}
|
|
559
|
-
|
|
663
|
+
refreshAnchors();
|
|
560
664
|
emit({
|
|
561
665
|
changeId: updateResult.value,
|
|
562
666
|
draftNodes: EMPTY_DRAFT_NODES,
|
|
@@ -691,7 +795,8 @@ const createAIDraftSession = (editor, options) => {
|
|
|
691
795
|
refusal: { reason: "read-only" },
|
|
692
796
|
status: "refused"
|
|
693
797
|
});
|
|
694
|
-
if (!
|
|
798
|
+
if (!isCellAnchorCurrent(cellKey)) return Object.freeze({ status: "stale" });
|
|
799
|
+
const wasTargetAnchorCurrent = isTargetAnchorCurrent();
|
|
695
800
|
const cellEntry = proposeView.read.nodes.get(cellKey, { match: ElementApi.isElement });
|
|
696
801
|
if (!cellEntry || !isPathVisible(proposeView, filter, cellEntry[1], pinnedRoot)) return Object.freeze({ status: "stale" });
|
|
697
802
|
if (hasHiddenDescendant(filter, cellEntry[0], cellEntry[1], pinnedRoot, editor.read.value().roots)) return Object.freeze({
|
|
@@ -736,31 +841,19 @@ const createAIDraftSession = (editor, options) => {
|
|
|
736
841
|
block: firstExisting,
|
|
737
842
|
kind: "replaced"
|
|
738
843
|
});
|
|
739
|
-
let lockedRefusal = false;
|
|
740
|
-
const unsubscribe = subscribeEditorRefusals(proposeView, (refusalRecord) => {
|
|
741
|
-
if (isLockRefusalRecord(refusalRecord)) lockedRefusal = true;
|
|
742
|
-
});
|
|
743
844
|
const currentChangeId = snapshot.changeId;
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
tx.nodes.replaceChildren(cloneDeep(landed), { at: cellKey });
|
|
749
|
-
return changeId;
|
|
750
|
-
});
|
|
751
|
-
} finally {
|
|
752
|
-
unsubscribe();
|
|
753
|
-
}
|
|
754
|
-
if (lockedRefusal || updateResult.status === "refused") return Object.freeze({
|
|
755
|
-
refusal: {
|
|
756
|
-
reason: "block-locked",
|
|
757
|
-
ref: record.ref
|
|
758
|
-
},
|
|
759
|
-
status: "refused"
|
|
845
|
+
const updateResult = proposeView.update.result((tx) => {
|
|
846
|
+
const changeId = tx.plugin(AuthoredPlugin).propose(currentChangeId ? { changeId: currentChangeId } : void 0);
|
|
847
|
+
tx.nodes.replaceChildren(cloneDeep(landed), { at: cellKey });
|
|
848
|
+
return changeId;
|
|
760
849
|
});
|
|
850
|
+
if (updateResult.status === "refused") return mapUpdateRefusal(updateResult.refusal, record.ref);
|
|
761
851
|
if (updateResult.status === "unchanged") return Object.freeze({ status: "empty" });
|
|
762
852
|
hasTableCellEdits = true;
|
|
763
|
-
|
|
853
|
+
refreshAnchors({
|
|
854
|
+
onlyCellKey: cellKey,
|
|
855
|
+
refreshTargetAnchor: wasTargetAnchorCurrent
|
|
856
|
+
});
|
|
764
857
|
emit({
|
|
765
858
|
changeId: updateResult.value,
|
|
766
859
|
status: "reviewing"
|
|
@@ -791,7 +884,9 @@ const createAIDraftSession = (editor, options) => {
|
|
|
791
884
|
refusal: result,
|
|
792
885
|
status: result?.status === "stale" ? "stale" : "refused"
|
|
793
886
|
});
|
|
794
|
-
|
|
887
|
+
baselineSourceNodes = null;
|
|
888
|
+
baselineLockedSourceRuns = null;
|
|
889
|
+
refreshAnchors();
|
|
795
890
|
emit({
|
|
796
891
|
changeId: null,
|
|
797
892
|
draftNodes: EMPTY_DRAFT_NODES,
|
|
@@ -20,12 +20,11 @@ const HTML_MEDIA_TAG_URL_RE = /<(?:audio|embed|iframe|img|source|video)\b[^>]*?\
|
|
|
20
20
|
const LINK_ELEMENT_TYPES = /* @__PURE__ */ new Set([PLUGINS.link, "a"]);
|
|
21
21
|
const MEDIA_ELEMENT_TYPES = /* @__PURE__ */ new Set([
|
|
22
22
|
PLUGINS.audio,
|
|
23
|
-
PLUGINS.
|
|
23
|
+
PLUGINS.board,
|
|
24
24
|
PLUGINS.file,
|
|
25
25
|
PLUGINS.image,
|
|
26
26
|
PLUGINS.mediaEmbed,
|
|
27
27
|
PLUGINS.video,
|
|
28
|
-
"board",
|
|
29
28
|
"img",
|
|
30
29
|
"media_embed"
|
|
31
30
|
]);
|