@blocknote/xl-ai 0.40.0 → 0.41.1

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.
@@ -1 +1 @@
1
- {"builtAt":1759218529249,"assets":[{"name":"blocknote-xl-ai.cjs","size":69318},{"name":"locales.cjs","size":23791},{"name":"locales.cjs.map","size":55283},{"name":"blocknote-xl-ai.cjs.map","size":2431678}],"chunks":[{"id":"a1ee98a","entry":true,"initial":true,"files":["blocknote-xl-ai.cjs"],"names":["blocknote-xl-ai"]},{"id":"842df4c","entry":true,"initial":true,"files":["locales.cjs"],"names":["locales"]}],"modules":[{"name":"./src/style.css","size":0,"chunks":["a1ee98a"]},{"name":"../../node_modules/.pnpm/zustand@5.0.3_@types+react@19.1.8_immer@10.1.1_react@19.1.0_use-sync-external-store@1.5.0_react@19.1.0_/node_modules/zustand/esm/vanilla.mjs","size":973,"chunks":["a1ee98a"]},{"name":"./src/streamTool/jsonSchema.ts","size":1399,"chunks":["a1ee98a"]},{"name":"./src/api/aiRequest/defaultAIRequestSender.ts","size":886,"chunks":["a1ee98a"]},{"name":"./src/streamTool/StreamToolExecutor.ts","size":4829,"chunks":["a1ee98a"]},{"name":"./src/util/stream.ts","size":1069,"chunks":["a1ee98a"]},{"name":"./src/streamTool/filterNewOrUpdatedOperations.ts","size":933,"chunks":["a1ee98a"]},{"name":"./src/streamTool/filterValidOperations.ts","size":681,"chunks":["a1ee98a"]},{"name":"./src/streamTool/toValidatedOperations.ts","size":819,"chunks":["a1ee98a"]},{"name":"./src/streamTool/preprocess.ts","size":446,"chunks":["a1ee98a"]},{"name":"./src/streamTool/vercelAiSdk/util/UIMessageStreamToOperationsResult.ts","size":306,"chunks":["a1ee98a"]},{"name":"./src/streamTool/vercelAiSdk/util/chatHandlers.ts","size":5009,"chunks":["a1ee98a"]},{"name":"./src/util/emptyBlock.ts","size":170,"chunks":["a1ee98a"]},{"name":"./src/util/trimArray.ts","size":327,"chunks":["a1ee98a"]},{"name":"./src/api/promptHelpers/trimEmptyBlocks.ts","size":272,"chunks":["a1ee98a"]},{"name":"./src/api/aiRequest/execute.ts","size":1618,"chunks":["a1ee98a"]},{"name":"./src/api/formats/html-blocks/defaultHTMLPromptBuilder.ts","size":5585,"chunks":["a1ee98a"]},{"name":"./src/api/promptHelpers/addCursorPosition.ts","size":390,"chunks":["a1ee98a"]},{"name":"./src/api/promptHelpers/convertBlocks.ts","size":183,"chunks":["a1ee98a"]},{"name":"./src/api/promptHelpers/flattenBlocks.ts","size":162,"chunks":["a1ee98a"]},{"name":"./src/api/promptHelpers/suffixIds.ts","size":204,"chunks":["a1ee98a"]},{"name":"./src/api/formats/html-blocks/htmlPromptData.ts","size":1960,"chunks":["a1ee98a"]},{"name":"./src/prosemirror/fragmentUtil.ts","size":262,"chunks":["a1ee98a"]},{"name":"./src/prosemirror/agent.ts","size":6220,"chunks":["a1ee98a"]},{"name":"./src/prosemirror/changeset.ts","size":6000,"chunks":["a1ee98a"]},{"name":"./src/streamTool/streamTool.ts","size":48,"chunks":["a1ee98a"]},{"name":"./src/api/formats/base-tools/util/validateBlockArray.ts","size":574,"chunks":["a1ee98a"]},{"name":"./src/api/formats/base-tools/createAddBlocksTool.ts","size":5409,"chunks":["a1ee98a"]},{"name":"./src/api/formats/base-tools/createUpdateBlockTool.ts","size":4228,"chunks":["a1ee98a"]},{"name":"./src/api/formats/base-tools/delete.ts","size":1781,"chunks":["a1ee98a"]},{"name":"./src/api/formats/html-blocks/tools/getPartialHTML.ts","size":699,"chunks":["a1ee98a"]},{"name":"./src/prosemirror/rebaseTool.ts","size":1508,"chunks":["a1ee98a"]},{"name":"./src/api/formats/html-blocks/tools/rebaseTool.ts","size":829,"chunks":["a1ee98a"]},{"name":"./src/api/formats/html-blocks/tools/validate.ts","size":204,"chunks":["a1ee98a"]},{"name":"./src/api/formats/html-blocks/tools/index.ts","size":1886,"chunks":["a1ee98a"]},{"name":"./src/api/formats/html-blocks/htmlBlocks.ts","size":2015,"chunks":["a1ee98a"]},{"name":"./src/api/formats/json/jsonPromptData.ts","size":2064,"chunks":["a1ee98a"]},{"name":"./src/api/schema/mergeSchema.ts","size":829,"chunks":["a1ee98a"]},{"name":"./src/api/schema/schemaToJSONSchema.ts","size":4910,"chunks":["a1ee98a"]},{"name":"./src/api/formats/json/tools/validate.ts","size":1603,"chunks":["a1ee98a"]},{"name":"./src/api/formats/json/tools/index.ts","size":1324,"chunks":["a1ee98a"]},{"name":"./src/api/formats/json/defaultJSONPromptBuilder.ts","size":4680,"chunks":["a1ee98a"]},{"name":"./src/api/formats/json/json.ts","size":2010,"chunks":["a1ee98a"]},{"name":"./src/api/formats/markdown-blocks/markdownPromptData.ts","size":1975,"chunks":["a1ee98a"]},{"name":"./src/api/formats/markdown-blocks/tools/rebaseTool.ts","size":633,"chunks":["a1ee98a"]},{"name":"./src/api/formats/markdown-blocks/tools/validate.ts","size":202,"chunks":["a1ee98a"]},{"name":"./src/api/formats/markdown-blocks/tools/index.ts","size":1505,"chunks":["a1ee98a"]},{"name":"./src/api/formats/markdown-blocks/defaultMarkdownPromptBuilder.ts","size":4740,"chunks":["a1ee98a"]},{"name":"./src/api/formats/markdown-blocks/markdownBlocks.ts","size":1943,"chunks":["a1ee98a"]},{"name":"./src/api/formats/index.ts","size":149,"chunks":["a1ee98a"]},{"name":"./src/api/promptHelpers/index.ts","size":112,"chunks":["a1ee98a"]},{"name":"./src/plugins/AgentCursorPlugin.ts","size":2444,"chunks":["a1ee98a"]},{"name":"./src/AIExtension.ts","size":7391,"chunks":["a1ee98a"]},{"name":"./src/blocknoteAIClient/client.ts","size":533,"chunks":["a1ee98a"]},{"name":"../../node_modules/.pnpm/react-icons@5.5.0_react@19.1.0/node_modules/react-icons/lib/iconContext.mjs","size":251,"chunks":["a1ee98a"]},{"name":"../../node_modules/.pnpm/react-icons@5.5.0_react@19.1.0/node_modules/react-icons/lib/iconBase.mjs","size":4003,"chunks":["a1ee98a"]},{"name":"../../node_modules/.pnpm/react-icons@5.5.0_react@19.1.0/node_modules/react-icons/ri/index.mjs","size":6747,"chunks":["a1ee98a"]},{"name":"./src/i18n/dictionary.ts","size":150,"chunks":["a1ee98a"]},{"name":"./src/i18n/useAIDictionary.ts","size":113,"chunks":["a1ee98a"]},{"name":"./src/components/AIMenu/PromptSuggestionMenu.tsx","size":2905,"chunks":["a1ee98a"]},{"name":"./src/components/AIMenu/getDefaultAIMenuItems.tsx","size":7608,"chunks":["a1ee98a"]},{"name":"./src/components/AIMenu/AIMenu.tsx","size":3528,"chunks":["a1ee98a"]},{"name":"./src/components/AIMenu/BlockPositioner.tsx","size":1424,"chunks":["a1ee98a"]},{"name":"./src/components/AIMenu/AIMenuController.tsx","size":918,"chunks":["a1ee98a"]},{"name":"./src/components/FormattingToolbar/AIToolbarButton.tsx","size":857,"chunks":["a1ee98a"]},{"name":"./src/components/SuggestionMenu/getAISlashMenuItems.tsx","size":679,"chunks":["a1ee98a"]},{"name":"./src/streamTool/toolDefinitionsToToolSet.ts","size":342,"chunks":["a1ee98a"]},{"name":"./src/streamTool/vercelAiSdk/util/partialObjectStreamUtil.ts","size":2350,"chunks":["a1ee98a"]},{"name":"./src/streamTool/vercelAiSdk/clientside/ClientSideTransport.ts","size":3090,"chunks":["a1ee98a"]},{"name":"./src/index.ts","size":0,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/ar.ts","size":1531,"chunks":["842df4c"]},{"name":"./src/i18n/locales/de.ts","size":1585,"chunks":["842df4c"]},{"name":"./src/i18n/locales/en.ts","size":1483,"chunks":["842df4c"]},{"name":"./src/i18n/locales/es.ts","size":1553,"chunks":["842df4c"]},{"name":"./src/i18n/locales/fr.ts","size":1569,"chunks":["842df4c"]},{"name":"./src/i18n/locales/he.ts","size":1401,"chunks":["842df4c"]},{"name":"./src/i18n/locales/hr.ts","size":1494,"chunks":["842df4c"]},{"name":"./src/i18n/locales/is.ts","size":1562,"chunks":["842df4c"]},{"name":"./src/i18n/locales/it.ts","size":1555,"chunks":["842df4c"]},{"name":"./src/i18n/locales/ja.ts","size":1372,"chunks":["842df4c"]},{"name":"./src/i18n/locales/ko.ts","size":1394,"chunks":["842df4c"]},{"name":"./src/i18n/locales/nl.ts","size":1536,"chunks":["842df4c"]},{"name":"./src/i18n/locales/no.ts","size":1509,"chunks":["842df4c"]},{"name":"./src/i18n/locales/pl.ts","size":1510,"chunks":["842df4c"]},{"name":"./src/i18n/locales/pt.ts","size":1548,"chunks":["842df4c"]},{"name":"./src/i18n/locales/ru.ts","size":1549,"chunks":["842df4c"]},{"name":"./src/i18n/locales/sk.ts","size":1511,"chunks":["842df4c"]},{"name":"./src/i18n/locales/uk.ts","size":1556,"chunks":["842df4c"]},{"name":"./src/i18n/locales/vi.ts","size":1506,"chunks":["842df4c"]},{"name":"./src/i18n/locales/zh-tw.ts","size":1345,"chunks":["842df4c"]},{"name":"./src/i18n/locales/zh.ts","size":1340,"chunks":["842df4c"]},{"name":"./src/i18n/locales/index.ts","size":0,"chunks":["842df4c"]}]}
1
+ {"builtAt":1760026178074,"assets":[{"name":"blocknote-xl-ai.cjs","size":70050},{"name":"locales.cjs","size":23791},{"name":"locales.cjs.map","size":55283},{"name":"blocknote-xl-ai.cjs.map","size":2434408}],"chunks":[{"id":"a1ee98a","entry":true,"initial":true,"files":["blocknote-xl-ai.cjs"],"names":["blocknote-xl-ai"]},{"id":"842df4c","entry":true,"initial":true,"files":["locales.cjs"],"names":["locales"]}],"modules":[{"name":"./src/style.css","size":0,"chunks":["a1ee98a"]},{"name":"../../node_modules/.pnpm/zustand@5.0.3_@types+react@19.1.8_immer@10.1.1_react@19.1.0_use-sync-external-store@1.6.0_react@19.1.0_/node_modules/zustand/esm/vanilla.mjs","size":973,"chunks":["a1ee98a"]},{"name":"./src/streamTool/jsonSchema.ts","size":1399,"chunks":["a1ee98a"]},{"name":"./src/api/aiRequest/defaultAIRequestSender.ts","size":886,"chunks":["a1ee98a"]},{"name":"./src/streamTool/StreamToolExecutor.ts","size":4829,"chunks":["a1ee98a"]},{"name":"./src/util/stream.ts","size":1069,"chunks":["a1ee98a"]},{"name":"./src/streamTool/filterNewOrUpdatedOperations.ts","size":933,"chunks":["a1ee98a"]},{"name":"./src/streamTool/filterValidOperations.ts","size":681,"chunks":["a1ee98a"]},{"name":"./src/streamTool/toValidatedOperations.ts","size":819,"chunks":["a1ee98a"]},{"name":"./src/streamTool/preprocess.ts","size":446,"chunks":["a1ee98a"]},{"name":"./src/streamTool/vercelAiSdk/util/UIMessageStreamToOperationsResult.ts","size":306,"chunks":["a1ee98a"]},{"name":"./src/streamTool/vercelAiSdk/util/chatHandlers.ts","size":5009,"chunks":["a1ee98a"]},{"name":"./src/util/emptyBlock.ts","size":170,"chunks":["a1ee98a"]},{"name":"./src/util/trimArray.ts","size":327,"chunks":["a1ee98a"]},{"name":"./src/api/promptHelpers/trimEmptyBlocks.ts","size":272,"chunks":["a1ee98a"]},{"name":"./src/api/aiRequest/execute.ts","size":1618,"chunks":["a1ee98a"]},{"name":"./src/api/formats/html-blocks/defaultHTMLPromptBuilder.ts","size":5585,"chunks":["a1ee98a"]},{"name":"./src/api/promptHelpers/addCursorPosition.ts","size":390,"chunks":["a1ee98a"]},{"name":"./src/api/promptHelpers/convertBlocks.ts","size":183,"chunks":["a1ee98a"]},{"name":"./src/api/promptHelpers/flattenBlocks.ts","size":162,"chunks":["a1ee98a"]},{"name":"./src/api/promptHelpers/suffixIds.ts","size":204,"chunks":["a1ee98a"]},{"name":"./src/api/formats/html-blocks/htmlPromptData.ts","size":1960,"chunks":["a1ee98a"]},{"name":"./src/prosemirror/fragmentUtil.ts","size":262,"chunks":["a1ee98a"]},{"name":"./src/prosemirror/agent.ts","size":6220,"chunks":["a1ee98a"]},{"name":"./src/prosemirror/changeset.ts","size":6000,"chunks":["a1ee98a"]},{"name":"./src/streamTool/streamTool.ts","size":48,"chunks":["a1ee98a"]},{"name":"./src/api/formats/base-tools/util/validateBlockArray.ts","size":574,"chunks":["a1ee98a"]},{"name":"./src/api/formats/base-tools/createAddBlocksTool.ts","size":5409,"chunks":["a1ee98a"]},{"name":"./src/api/formats/base-tools/createUpdateBlockTool.ts","size":4228,"chunks":["a1ee98a"]},{"name":"./src/api/formats/base-tools/delete.ts","size":1781,"chunks":["a1ee98a"]},{"name":"./src/api/formats/html-blocks/tools/getPartialHTML.ts","size":699,"chunks":["a1ee98a"]},{"name":"./src/prosemirror/rebaseTool.ts","size":1508,"chunks":["a1ee98a"]},{"name":"./src/api/formats/html-blocks/tools/rebaseTool.ts","size":829,"chunks":["a1ee98a"]},{"name":"./src/api/formats/html-blocks/tools/validate.ts","size":204,"chunks":["a1ee98a"]},{"name":"./src/api/formats/html-blocks/tools/index.ts","size":1886,"chunks":["a1ee98a"]},{"name":"./src/api/formats/html-blocks/htmlBlocks.ts","size":2015,"chunks":["a1ee98a"]},{"name":"./src/api/formats/json/jsonPromptData.ts","size":2064,"chunks":["a1ee98a"]},{"name":"./src/api/schema/mergeSchema.ts","size":829,"chunks":["a1ee98a"]},{"name":"./src/api/schema/schemaToJSONSchema.ts","size":4910,"chunks":["a1ee98a"]},{"name":"./src/api/formats/json/tools/validate.ts","size":1603,"chunks":["a1ee98a"]},{"name":"./src/api/formats/json/tools/index.ts","size":1324,"chunks":["a1ee98a"]},{"name":"./src/api/formats/json/defaultJSONPromptBuilder.ts","size":4680,"chunks":["a1ee98a"]},{"name":"./src/api/formats/json/json.ts","size":2010,"chunks":["a1ee98a"]},{"name":"./src/api/formats/markdown-blocks/markdownPromptData.ts","size":1975,"chunks":["a1ee98a"]},{"name":"./src/api/formats/markdown-blocks/tools/rebaseTool.ts","size":633,"chunks":["a1ee98a"]},{"name":"./src/api/formats/markdown-blocks/tools/validate.ts","size":202,"chunks":["a1ee98a"]},{"name":"./src/api/formats/markdown-blocks/tools/index.ts","size":1505,"chunks":["a1ee98a"]},{"name":"./src/api/formats/markdown-blocks/defaultMarkdownPromptBuilder.ts","size":4740,"chunks":["a1ee98a"]},{"name":"./src/api/formats/markdown-blocks/markdownBlocks.ts","size":1943,"chunks":["a1ee98a"]},{"name":"./src/api/formats/index.ts","size":149,"chunks":["a1ee98a"]},{"name":"./src/api/promptHelpers/index.ts","size":112,"chunks":["a1ee98a"]},{"name":"./src/plugins/AgentCursorPlugin.ts","size":2444,"chunks":["a1ee98a"]},{"name":"./src/AIExtension.ts","size":8734,"chunks":["a1ee98a"]},{"name":"./src/blocknoteAIClient/client.ts","size":533,"chunks":["a1ee98a"]},{"name":"../../node_modules/.pnpm/react-icons@5.5.0_react@19.1.0/node_modules/react-icons/lib/iconContext.mjs","size":251,"chunks":["a1ee98a"]},{"name":"../../node_modules/.pnpm/react-icons@5.5.0_react@19.1.0/node_modules/react-icons/lib/iconBase.mjs","size":4003,"chunks":["a1ee98a"]},{"name":"../../node_modules/.pnpm/react-icons@5.5.0_react@19.1.0/node_modules/react-icons/ri/index.mjs","size":6747,"chunks":["a1ee98a"]},{"name":"./src/i18n/dictionary.ts","size":150,"chunks":["a1ee98a"]},{"name":"./src/i18n/useAIDictionary.ts","size":113,"chunks":["a1ee98a"]},{"name":"./src/components/AIMenu/PromptSuggestionMenu.tsx","size":2905,"chunks":["a1ee98a"]},{"name":"./src/components/AIMenu/getDefaultAIMenuItems.tsx","size":7608,"chunks":["a1ee98a"]},{"name":"./src/components/AIMenu/AIMenu.tsx","size":3528,"chunks":["a1ee98a"]},{"name":"./src/components/AIMenu/BlockPositioner.tsx","size":1424,"chunks":["a1ee98a"]},{"name":"./src/components/AIMenu/AIMenuController.tsx","size":918,"chunks":["a1ee98a"]},{"name":"./src/components/FormattingToolbar/AIToolbarButton.tsx","size":857,"chunks":["a1ee98a"]},{"name":"./src/components/SuggestionMenu/getAISlashMenuItems.tsx","size":679,"chunks":["a1ee98a"]},{"name":"./src/streamTool/toolDefinitionsToToolSet.ts","size":342,"chunks":["a1ee98a"]},{"name":"./src/streamTool/vercelAiSdk/util/partialObjectStreamUtil.ts","size":2350,"chunks":["a1ee98a"]},{"name":"./src/streamTool/vercelAiSdk/clientside/ClientSideTransport.ts","size":3090,"chunks":["a1ee98a"]},{"name":"./src/index.ts","size":0,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/ar.ts","size":1531,"chunks":["842df4c"]},{"name":"./src/i18n/locales/de.ts","size":1585,"chunks":["842df4c"]},{"name":"./src/i18n/locales/en.ts","size":1483,"chunks":["842df4c"]},{"name":"./src/i18n/locales/es.ts","size":1553,"chunks":["842df4c"]},{"name":"./src/i18n/locales/fr.ts","size":1569,"chunks":["842df4c"]},{"name":"./src/i18n/locales/he.ts","size":1401,"chunks":["842df4c"]},{"name":"./src/i18n/locales/hr.ts","size":1494,"chunks":["842df4c"]},{"name":"./src/i18n/locales/is.ts","size":1562,"chunks":["842df4c"]},{"name":"./src/i18n/locales/it.ts","size":1555,"chunks":["842df4c"]},{"name":"./src/i18n/locales/ja.ts","size":1372,"chunks":["842df4c"]},{"name":"./src/i18n/locales/ko.ts","size":1394,"chunks":["842df4c"]},{"name":"./src/i18n/locales/nl.ts","size":1536,"chunks":["842df4c"]},{"name":"./src/i18n/locales/no.ts","size":1509,"chunks":["842df4c"]},{"name":"./src/i18n/locales/pl.ts","size":1510,"chunks":["842df4c"]},{"name":"./src/i18n/locales/pt.ts","size":1548,"chunks":["842df4c"]},{"name":"./src/i18n/locales/ru.ts","size":1549,"chunks":["842df4c"]},{"name":"./src/i18n/locales/sk.ts","size":1511,"chunks":["842df4c"]},{"name":"./src/i18n/locales/uk.ts","size":1556,"chunks":["842df4c"]},{"name":"./src/i18n/locales/vi.ts","size":1506,"chunks":["842df4c"]},{"name":"./src/i18n/locales/zh-tw.ts","size":1345,"chunks":["842df4c"]},{"name":"./src/i18n/locales/zh.ts","size":1340,"chunks":["842df4c"]},{"name":"./src/i18n/locales/index.ts","size":0,"chunks":["842df4c"]}]}
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "directory": "packages/xl-ai"
12
12
  },
13
13
  "license": "GPL-3.0 OR PROPRIETARY",
14
- "version": "0.40.0",
14
+ "version": "0.41.1",
15
15
  "files": [
16
16
  "dist",
17
17
  "types",
@@ -56,10 +56,10 @@
56
56
  }
57
57
  },
58
58
  "dependencies": {
59
- "@blocknote/core": "0.40.0",
60
- "@blocknote/mantine": "0.40.0",
59
+ "@blocknote/core": "0.41.1",
60
+ "@blocknote/mantine": "0.41.1",
61
61
  "@blocknote/prosemirror-suggest-changes": "^0.1.3",
62
- "@blocknote/react": "0.40.0",
62
+ "@blocknote/react": "0.41.1",
63
63
  "@floating-ui/react": "^0.26.4",
64
64
  "@tiptap/core": "^3.4.3",
65
65
  "ai": "^5.0.45",
@@ -71,7 +71,7 @@
71
71
  "prosemirror-state": "^1.4.3",
72
72
  "prosemirror-tables": "^1.6.4",
73
73
  "prosemirror-transform": "^1.10.4",
74
- "prosemirror-view": "^1.40.1",
74
+ "prosemirror-view": "^1.41.2",
75
75
  "react": "^19.1.0",
76
76
  "react-dom": "^19.1.0",
77
77
  "react-icons": "^5.2.1",
@@ -2,6 +2,7 @@ import { Chat } from "@ai-sdk/react";
2
2
  import {
3
3
  BlockNoteEditor,
4
4
  BlockNoteExtension,
5
+ getNodeById,
5
6
  UnreachableCaseError,
6
7
  } from "@blocknote/core";
7
8
  import {
@@ -65,6 +66,9 @@ export class AIExtension extends BlockNoteExtension {
65
66
  }
66
67
  | undefined;
67
68
 
69
+ private scrollInProgress = false;
70
+ private autoScroll = false;
71
+
68
72
  public static key(): string {
69
73
  return "ai";
70
74
  }
@@ -134,6 +138,31 @@ export class AIExtension extends BlockNoteExtension {
134
138
  options.agentCursor || { name: "AI", color: "#8bc6ff" },
135
139
  ),
136
140
  );
141
+
142
+ // Listens for `scroll` and `scrollend` events to see if a new scroll was
143
+ // started before an existing one ended. This is the most reliable way we
144
+ // have of checking if a scroll event was caused by the user and not by
145
+ // `scrollIntoView`, as the events are otherwise indistinguishable. If a
146
+ // scroll was started before an existing one finished (meaning the user has
147
+ // scrolled), auto scrolling is disabled.
148
+ document.addEventListener(
149
+ "scroll",
150
+ () => {
151
+ if (this.scrollInProgress) {
152
+ this.autoScroll = false;
153
+ }
154
+
155
+ this.scrollInProgress = true;
156
+ },
157
+ true,
158
+ );
159
+ document.addEventListener(
160
+ "scrollend",
161
+ () => {
162
+ this.scrollInProgress = false;
163
+ },
164
+ true,
165
+ );
137
166
  }
138
167
 
139
168
  /**
@@ -148,6 +177,12 @@ export class AIExtension extends BlockNoteExtension {
148
177
  status: "user-input",
149
178
  },
150
179
  });
180
+
181
+ // Scrolls to the block when the menu opens.
182
+ const blockElement = this.editor.domElement?.querySelector(
183
+ `[data-node-type="blockContainer"][data-id="${blockID}"]`,
184
+ );
185
+ blockElement?.scrollIntoView({ block: "center" });
151
186
  }
152
187
 
153
188
  /**
@@ -371,7 +406,7 @@ export class AIExtension extends BlockNoteExtension {
371
406
  useSelection: opts.useSelection,
372
407
  deleteEmptyCursorBlock: opts.deleteEmptyCursorBlock,
373
408
  streamToolsProvider: opts.streamToolsProvider,
374
- onBlockUpdated: (blockId: string) => {
409
+ onBlockUpdated: (blockId) => {
375
410
  // NOTE: does this setState with an anon object trigger unnecessary re-renders?
376
411
  this._store.setState({
377
412
  aiMenuState: {
@@ -379,6 +414,34 @@ export class AIExtension extends BlockNoteExtension {
379
414
  status: "ai-writing",
380
415
  },
381
416
  });
417
+
418
+ // Scrolls to the block being edited by the AI while auto scrolling is
419
+ // enabled.
420
+ if (!this.autoScroll) {
421
+ return;
422
+ }
423
+
424
+ const aiMenuState = this._store.getState().aiMenuState;
425
+ const aiMenuOpenState =
426
+ aiMenuState === "closed" ? undefined : aiMenuState;
427
+ if (!aiMenuOpenState || aiMenuOpenState.status !== "ai-writing") {
428
+ return;
429
+ }
430
+
431
+ const nodeInfo = getNodeById(
432
+ aiMenuOpenState.blockId,
433
+ this.editor.prosemirrorState.doc,
434
+ );
435
+ if (!nodeInfo) {
436
+ return;
437
+ }
438
+
439
+ const blockElement = this.editor.prosemirrorView.domAtPos(
440
+ nodeInfo.posBeforeNode + 1,
441
+ );
442
+ (blockElement.node as HTMLElement).scrollIntoView({
443
+ block: "center",
444
+ });
382
445
  },
383
446
  });
384
447
 
@@ -387,6 +450,7 @@ export class AIExtension extends BlockNoteExtension {
387
450
  sender,
388
451
  chatRequestOptions: opts.chatRequestOptions,
389
452
  onStart: () => {
453
+ this.autoScroll = true;
390
454
  this.setAIResponseStatus("ai-writing");
391
455
  },
392
456
  });
@@ -5,46 +5,6 @@ exports[`creates json schema 1`] = `
5
5
  "$defs": {
6
6
  "block": {
7
7
  "anyOf": [
8
- {
9
- "additionalProperties": false,
10
- "properties": {
11
- "content": undefined,
12
- "props": {
13
- "additionalProperties": false,
14
- "properties": {
15
- "caption": {
16
- "enum": undefined,
17
- "type": "string",
18
- },
19
- "name": {
20
- "enum": undefined,
21
- "type": "string",
22
- },
23
- "showPreview": {
24
- "enum": undefined,
25
- "type": "boolean",
26
- },
27
- "url": {
28
- "enum": undefined,
29
- "type": "string",
30
- },
31
- },
32
- "type": "object",
33
- },
34
- "type": {
35
- "enum": [
36
- "audio",
37
- "image",
38
- "video",
39
- ],
40
- "type": "string",
41
- },
42
- },
43
- "required": [
44
- "type",
45
- ],
46
- "type": "object",
47
- },
48
8
  {
49
9
  "additionalProperties": false,
50
10
  "properties": {
@@ -134,25 +94,12 @@ exports[`creates json schema 1`] = `
134
94
  "content": undefined,
135
95
  "props": {
136
96
  "additionalProperties": false,
137
- "properties": {
138
- "caption": {
139
- "enum": undefined,
140
- "type": "string",
141
- },
142
- "name": {
143
- "enum": undefined,
144
- "type": "string",
145
- },
146
- "url": {
147
- "enum": undefined,
148
- "type": "string",
149
- },
150
- },
97
+ "properties": {},
151
98
  "type": "object",
152
99
  },
153
100
  "type": {
154
101
  "enum": [
155
- "file",
102
+ "divider",
156
103
  ],
157
104
  "type": "string",
158
105
  },
@@ -19,6 +19,8 @@ type AIPluginState = {
19
19
  export declare class AIExtension extends BlockNoteExtension {
20
20
  readonly editor: BlockNoteEditor<any, any, any>;
21
21
  private chatSession;
22
+ private scrollInProgress;
23
+ private autoScroll;
22
24
  static key(): string;
23
25
  private readonly _store;
24
26
  /**
@@ -50,6 +50,7 @@ export declare function getEditorWithBlockFormatting(): BlockNoteEditor<import("
50
50
  readonly default: string;
51
51
  };
52
52
  }, "inline">;
53
+ readonly divider: import("@blocknote/core").BlockSpec<"divider", {}, "none">;
53
54
  readonly file: import("@blocknote/core").BlockSpec<"file", {
54
55
  readonly backgroundColor: {
55
56
  default: "default";
@@ -70,7 +71,7 @@ export declare function getEditorWithBlockFormatting(): BlockNoteEditor<import("
70
71
  readonly optional: true;
71
72
  } | undefined;
72
73
  readonly level: {
73
- readonly default: 1 | 2 | 4 | 3 | 5 | 6;
74
+ readonly default: 1 | 4 | 2 | 3 | 5 | 6;
74
75
  readonly values: readonly number[];
75
76
  };
76
77
  readonly backgroundColor: {
@@ -50,6 +50,7 @@ export declare function getEditorWithFormattingAndMentions(): BlockNoteEditor<im
50
50
  readonly default: string;
51
51
  };
52
52
  }, "inline">;
53
+ readonly divider: import("@blocknote/core").BlockSpec<"divider", {}, "none">;
53
54
  readonly file: import("@blocknote/core").BlockSpec<"file", {
54
55
  readonly backgroundColor: {
55
56
  default: "default";
@@ -70,7 +71,7 @@ export declare function getEditorWithFormattingAndMentions(): BlockNoteEditor<im
70
71
  readonly optional: true;
71
72
  } | undefined;
72
73
  readonly level: {
73
- readonly default: 1 | 2 | 4 | 3 | 5 | 6;
74
+ readonly default: 1 | 4 | 2 | 3 | 5 | 6;
74
75
  readonly values: readonly number[];
75
76
  };
76
77
  readonly backgroundColor: {
@@ -50,6 +50,7 @@ export declare function getSimpleEditor(): BlockNoteEditor<import("@blocknote/co
50
50
  readonly default: string;
51
51
  };
52
52
  }, "inline">;
53
+ readonly divider: import("@blocknote/core").BlockSpec<"divider", {}, "none">;
53
54
  readonly file: import("@blocknote/core").BlockSpec<"file", {
54
55
  readonly backgroundColor: {
55
56
  default: "default";
@@ -70,7 +71,7 @@ export declare function getSimpleEditor(): BlockNoteEditor<import("@blocknote/co
70
71
  readonly optional: true;
71
72
  } | undefined;
72
73
  readonly level: {
73
- readonly default: 1 | 2 | 4 | 3 | 5 | 6;
74
+ readonly default: 1 | 4 | 2 | 3 | 5 | 6;
74
75
  readonly values: readonly number[];
75
76
  };
76
77
  readonly backgroundColor: {
@@ -317,6 +318,7 @@ export declare function getSimpleEditorWithCursorBetweenBlocks(): BlockNoteEdito
317
318
  readonly default: string;
318
319
  };
319
320
  }, "inline">;
321
+ readonly divider: import("@blocknote/core").BlockSpec<"divider", {}, "none">;
320
322
  readonly file: import("@blocknote/core").BlockSpec<"file", {
321
323
  readonly backgroundColor: {
322
324
  default: "default";
@@ -337,7 +339,7 @@ export declare function getSimpleEditorWithCursorBetweenBlocks(): BlockNoteEdito
337
339
  readonly optional: true;
338
340
  } | undefined;
339
341
  readonly level: {
340
- readonly default: 1 | 2 | 4 | 3 | 5 | 6;
342
+ readonly default: 1 | 4 | 2 | 3 | 5 | 6;
341
343
  readonly values: readonly number[];
342
344
  };
343
345
  readonly backgroundColor: {
@@ -50,6 +50,7 @@ export declare function getEditorWithTables(): BlockNoteEditor<import("@blocknot
50
50
  readonly default: string;
51
51
  };
52
52
  }, "inline">;
53
+ readonly divider: import("@blocknote/core").BlockSpec<"divider", {}, "none">;
53
54
  readonly file: import("@blocknote/core").BlockSpec<"file", {
54
55
  readonly backgroundColor: {
55
56
  default: "default";
@@ -70,7 +71,7 @@ export declare function getEditorWithTables(): BlockNoteEditor<import("@blocknot
70
71
  readonly optional: true;
71
72
  } | undefined;
72
73
  readonly level: {
73
- readonly default: 1 | 2 | 4 | 3 | 5 | 6;
74
+ readonly default: 1 | 4 | 2 | 3 | 5 | 6;
74
75
  readonly values: readonly number[];
75
76
  };
76
77
  readonly backgroundColor: {
@@ -58,6 +58,7 @@ export declare const schemaWithMention: import("@blocknote/core").CustomBlockNot
58
58
  readonly default: string;
59
59
  };
60
60
  }, "inline">;
61
+ readonly divider: import("@blocknote/core").BlockSpec<"divider", {}, "none">;
61
62
  readonly file: import("@blocknote/core").BlockSpec<"file", {
62
63
  readonly backgroundColor: {
63
64
  default: "default";
@@ -78,7 +79,7 @@ export declare const schemaWithMention: import("@blocknote/core").CustomBlockNot
78
79
  readonly optional: true;
79
80
  } | undefined;
80
81
  readonly level: {
81
- readonly default: 1 | 2 | 4 | 3 | 5 | 6;
82
+ readonly default: 1 | 4 | 2 | 3 | 5 | 6;
82
83
  readonly values: readonly number[];
83
84
  };
84
85
  readonly backgroundColor: {