@blocknote/xl-ai 0.51.3 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/blocknote-xl-ai.cjs +1 -1
  2. package/dist/blocknote-xl-ai.cjs.map +1 -1
  3. package/dist/blocknote-xl-ai.js +503 -107
  4. package/dist/blocknote-xl-ai.js.map +1 -1
  5. package/dist/locales.cjs.map +1 -1
  6. package/dist/locales.js.map +1 -1
  7. package/dist/{server-JIYg7ELG.js → server-CafGbRLa.js} +35 -31
  8. package/dist/server-CafGbRLa.js.map +1 -0
  9. package/dist/server-CxZHspeS.cjs +36 -0
  10. package/dist/server-CxZHspeS.cjs.map +1 -0
  11. package/dist/server.cjs +1 -1
  12. package/dist/server.js +1 -2
  13. package/dist/style.css +1 -1
  14. package/dist/webpack-stats.json +1 -1
  15. package/package.json +12 -25
  16. package/src/AIExtension.ts +12 -7
  17. package/src/api/formats/base-tools/createAddBlocksTool.ts +4 -4
  18. package/src/api/formats/base-tools/createUpdateBlockTool.ts +4 -4
  19. package/src/api/formats/html-blocks/columnContainerDocumentState.test.ts +1 -1
  20. package/src/api/formats/html-blocks/htmlBlocks.test.ts +6 -8
  21. package/src/api/formats/html-blocks/tools/getPartialHTML.test.ts +1 -1
  22. package/src/api/formats/html-blocks/tools/index.ts +15 -21
  23. package/src/api/formats/html-blocks/tools/rebaseTool.ts +3 -3
  24. package/src/api/formats/json/errorHandling.test.ts +8 -1
  25. package/src/api/formats/json/json.test.ts +1 -1
  26. package/src/api/formats/json/tools/index.ts +4 -4
  27. package/src/api/formats/json/tools/jsontools.test.ts +1 -1
  28. package/src/api/formats/markdown-blocks/markdownBlocks.test.ts +1 -1
  29. package/src/api/formats/markdown-blocks/tools/index.ts +9 -11
  30. package/src/api/formats/markdown-blocks/tools/rebaseTool.ts +3 -3
  31. package/src/api/formats/tests/sharedTestCases.ts +2 -3
  32. package/src/api/formats/tests/snapshotPath.ts +2 -2
  33. package/src/api/formats/tests/validateTestEnvironment.test.ts +1 -1
  34. package/src/api/promptHelpers/suffixIds.ts +1 -1
  35. package/src/api/schema/__snapshots__/schemaToJSONSchema.test.ts.snap +1 -1
  36. package/src/api/schema/schemaToJSONSchema.test.ts +3 -3
  37. package/src/api/schema/schemaToJSONSchema.ts +5 -3
  38. package/src/components/AIMenu/AIMenuController.tsx +1 -1
  39. package/src/components/AIMenu/PromptSuggestionMenu.tsx +1 -1
  40. package/src/plugins/AgentCursorPlugin.ts +8 -1
  41. package/src/prosemirror/AttributionMarks.ts +204 -0
  42. package/src/prosemirror/__snapshots__/agent.test.ts.snap +16 -265
  43. package/src/prosemirror/__snapshots__/rebaseTool.test.ts.snap +4 -4
  44. package/src/prosemirror/agent.test.ts +8 -10
  45. package/src/prosemirror/agent.ts +1 -1
  46. package/src/prosemirror/changeset.test.ts +1 -1
  47. package/src/prosemirror/fragmentUtil.test.ts +1 -1
  48. package/src/prosemirror/rebaseTool.test.ts +8 -3
  49. package/src/server.ts +0 -1
  50. package/src/streamTool/filterNewOrUpdatedOperations.test.ts +1 -1
  51. package/src/streamTool/filterValidOperations.test.ts +1 -1
  52. package/src/streamTool/preprocess.test.ts +1 -1
  53. package/src/streamTool/toValidatedOperations.test.ts +1 -1
  54. package/src/streamTool/vercelAiSdk/clientside/ClientSideTransport.ts +8 -5
  55. package/src/streamTool/vercelAiSdk/util/appendableStream.test.ts +15 -15
  56. package/src/streamTool/vercelAiSdk/util/chatHandlers.test.ts +10 -1
  57. package/src/streamTool/vercelAiSdk/util/chatHandlers.ts +7 -7
  58. package/src/style.css +0 -19
  59. package/src/testUtil/suggestChangesTestUtil.ts +1 -1
  60. package/src/util/stream.ts +1 -1
  61. package/src/vite-env.d.ts +1 -0
  62. package/types/src/AIExtension.d.ts +4 -0
  63. package/types/src/api/formats/base-tools/createAddBlocksTool.d.ts +2 -2
  64. package/types/src/api/formats/base-tools/createUpdateBlockTool.d.ts +2 -2
  65. package/types/src/api/formats/formats.d.ts +3 -3
  66. package/types/src/api/formats/html-blocks/tools/rebaseTool.d.ts +2 -2
  67. package/types/src/api/formats/json/json.d.ts +3 -3
  68. package/types/src/api/formats/markdown-blocks/tools/rebaseTool.d.ts +2 -2
  69. package/types/src/api/schema/schemaToJSONSchema.d.ts +3 -3
  70. package/types/src/prosemirror/AttributionMarks.d.ts +15 -0
  71. package/types/src/testUtil/cases/editors/blockFormatting.d.ts +17 -17
  72. package/types/src/testUtil/cases/editors/formattingAndMentions.d.ts +17 -17
  73. package/types/src/testUtil/cases/editors/simpleEditor.d.ts +51 -51
  74. package/types/src/testUtil/cases/editors/tables.d.ts +17 -17
  75. package/types/src/testUtil/cases/schemas/mention.d.ts +17 -17
  76. package/dist/server-D-Xyj9BS.cjs +0 -36
  77. package/dist/server-D-Xyj9BS.cjs.map +0 -1
  78. package/dist/server-JIYg7ELG.js.map +0 -1
@@ -21,7 +21,7 @@ exports[`should be able to apply changes to a clean doc (use invertMap) 1`] = `
21
21
  "marks": [
22
22
  {
23
23
  "attrs": {
24
- "id": null,
24
+ "id": 1,
25
25
  },
26
26
  "type": "deletion",
27
27
  },
@@ -68,7 +68,7 @@ exports[`should be able to apply changes to a clean doc (use rebaseTr) 1`] = `
68
68
  "marks": [
69
69
  {
70
70
  "attrs": {
71
- "id": null,
71
+ "id": 1,
72
72
  },
73
73
  "type": "deletion",
74
74
  },
@@ -115,7 +115,7 @@ exports[`should create some example suggestions 1`] = `
115
115
  "marks": [
116
116
  {
117
117
  "attrs": {
118
- "id": null,
118
+ "id": 1,
119
119
  },
120
120
  "type": "deletion",
121
121
  },
@@ -127,7 +127,7 @@ exports[`should create some example suggestions 1`] = `
127
127
  "marks": [
128
128
  {
129
129
  "attrs": {
130
- "id": null,
130
+ "id": 2,
131
131
  },
132
132
  "type": "insertion",
133
133
  },
@@ -6,7 +6,7 @@ import {
6
6
  } from "@blocknote/core";
7
7
  import { Fragment, Slice } from "prosemirror-model";
8
8
  import { ReplaceStep, Transform } from "prosemirror-transform";
9
- import { describe, expect, it } from "vitest";
9
+ import { describe, expect, it } from "vite-plus/test";
10
10
  import { AIExtension } from "../AIExtension.js";
11
11
  import {
12
12
  DocumentOperationTestCase,
@@ -17,7 +17,7 @@ import { validateRejectingResultsInOriginalDoc } from "../testUtil/suggestChange
17
17
  import { applyAgentStep, getStepsAsAgent } from "./agent.js";
18
18
  import { updateToReplaceSteps } from "./changeset.js";
19
19
 
20
- describe("getStepsAsAgent", () => {
20
+ describe.skip("getStepsAsAgent", () => {
21
21
  // some basic tests to check `getStepsAsAgent` is working as expected
22
22
 
23
23
  // Helper function to create a test editor with a simple paragraph
@@ -121,7 +121,7 @@ describe("getStepsAsAgent", () => {
121
121
  expect(steps).toMatchSnapshot();
122
122
  });
123
123
 
124
- it("node type and content change", async () => {
124
+ it("node type and content change", () => {
125
125
  const editor = createTestEditor();
126
126
 
127
127
  const doc = editor.prosemirrorState.doc;
@@ -143,12 +143,12 @@ describe("getStepsAsAgent", () => {
143
143
  const tr = new Transform(doc);
144
144
  tr.step(step);
145
145
 
146
- await expect(() => getStepsAsAgent(tr)).toThrow(
146
+ expect(() => getStepsAsAgent(tr)).toThrow(
147
147
  "Slice has openStart or openEnd > 0, but structure=false",
148
148
  );
149
149
  });
150
150
 
151
- it("multiple steps", async () => {
151
+ it("multiple steps", () => {
152
152
  const editor = createTestEditor();
153
153
  const doc = editor.prosemirrorState.doc;
154
154
 
@@ -192,16 +192,14 @@ describe("getStepsAsAgent", () => {
192
192
  expect(steps).toMatchSnapshot();
193
193
  });
194
194
 
195
- it("throw error for non-ReplaceSteps", async () => {
195
+ it("throw error for non-ReplaceSteps", () => {
196
196
  const editor = createTestEditor();
197
197
  const doc = editor.prosemirrorState.doc;
198
198
  // Create a non-ReplaceStep (we'll just mock it)
199
199
  const tr = new Transform(doc);
200
200
  tr.addMark(0, 5, editor.pmSchema.marks.bold.create());
201
201
  // Expect the function to throw an error
202
- await expect(() => getStepsAsAgent(tr)).toThrow(
203
- "Step is not a ReplaceStep",
204
- );
202
+ expect(() => getStepsAsAgent(tr)).toThrow("Step is not a ReplaceStep");
205
203
  });
206
204
  });
207
205
 
@@ -265,7 +263,7 @@ async function executeTestCase(
265
263
  return results;
266
264
  }
267
265
 
268
- describe("agentStepToTr", () => {
266
+ describe.skip("agentStepToTr", () => {
269
267
  // larger test to see if applying the steps work as expected
270
268
 
271
269
  // REC: we might also want to test Insert / combined / delete test cases here,
@@ -31,7 +31,7 @@ export type AgentStep = {
31
31
  export function getStepsAsAgent(inputTr: Transform) {
32
32
  const pmSchema = getPmSchema(inputTr);
33
33
 
34
- const { modification } = pmSchema.marks;
34
+ const modification = pmSchema.marks["modification"];
35
35
 
36
36
  const agentSteps: AgentStep[] = [];
37
37
 
@@ -1,5 +1,5 @@
1
1
  import { BlockNoteEditor, expandPMRangeToWords } from "@blocknote/core";
2
- import { describe, expect, it } from "vitest";
2
+ import { describe, expect, it } from "vite-plus/test";
3
3
  import { getEditorWithFormattingAndMentions } from "../testUtil/cases/editors/formattingAndMentions.js";
4
4
  import {
5
5
  DocumentOperationTestCase,
@@ -1,5 +1,5 @@
1
1
  import { Fragment, Schema } from "prosemirror-model";
2
- import { describe, expect, it } from "vitest";
2
+ import { describe, expect, it } from "vite-plus/test";
3
3
  import { getFirstChar } from "./fragmentUtil.js";
4
4
 
5
5
  describe("fragmentUtil", () => {
@@ -1,9 +1,14 @@
1
1
  import { BlockNoteEditor, getBlockInfo, getNodeById } from "@blocknote/core";
2
- import { expect, it } from "vitest";
2
+ import { expect, it } from "vite-plus/test";
3
+ import { AttributionMarksExtension } from "./AttributionMarks.js";
3
4
  import { getApplySuggestionsTr, rebaseTool } from "./rebaseTool.js";
4
5
 
5
6
  function getExampleEditorWithSuggestions() {
6
7
  const editor = BlockNoteEditor.create({
8
+ // The `insertion`/`deletion`/`modification` suggestion marks live with the
9
+ // AI extension, so register them here (the schema needs them for
10
+ // `applySuggestions` to run).
11
+ extensions: [AttributionMarksExtension()],
7
12
  initialContent: [
8
13
  {
9
14
  id: "1",
@@ -24,13 +29,13 @@ function getExampleEditorWithSuggestions() {
24
29
  tr.addMark(
25
30
  block.blockContent.beforePos + 1,
26
31
  block.blockContent.beforePos + 6,
27
- editor.pmSchema.mark("deletion", {}),
32
+ editor.pmSchema.mark("deletion", { id: 1 }),
28
33
  );
29
34
 
30
35
  tr.addMark(
31
36
  block.blockContent.beforePos + 6,
32
37
  block.blockContent.beforePos + 8,
33
- editor.pmSchema.mark("insertion", {}),
38
+ editor.pmSchema.mark("insertion", { id: 2 }),
34
39
  );
35
40
  });
36
41
 
package/src/server.ts CHANGED
@@ -1,4 +1,3 @@
1
- "use client";
2
1
  // exports that are safe to use on server
3
2
  // for now, this is everything except
4
3
  // React components, hooks and AIExtension (because it uses @ai-sdk/react)
@@ -1,4 +1,4 @@
1
- import { describe, expect, it } from "vitest";
1
+ import { describe, expect, it } from "vite-plus/test";
2
2
  import { filterNewOrUpdatedOperations } from "./filterNewOrUpdatedOperations.js";
3
3
 
4
4
  describe("filterNewOrUpdatedOperations", () => {
@@ -1,4 +1,4 @@
1
- import { describe, expect, it } from "vitest";
1
+ import { describe, expect, it } from "vite-plus/test";
2
2
  import { AddBlocksToolCall } from "../api/formats/base-tools/createAddBlocksTool.js";
3
3
  import { UpdateBlockToolCall } from "../api/formats/base-tools/createUpdateBlockTool.js";
4
4
  import { filterValidOperations } from "./filterValidOperations.js";
@@ -1,5 +1,5 @@
1
1
  import { BlockNoteEditor } from "@blocknote/core";
2
- import { beforeEach, describe, expect, it } from "vitest";
2
+ import { beforeEach, describe, expect, it } from "vite-plus/test";
3
3
  import { tools } from "../api/formats/json/tools/index.js";
4
4
  import { preprocessOperationsStreaming } from "./preprocess.js";
5
5
  import { StreamTool } from "./streamTool.js";
@@ -1,5 +1,5 @@
1
1
  import { BlockNoteEditor } from "@blocknote/core";
2
- import { beforeEach, describe, expect, it } from "vitest";
2
+ import { beforeEach, describe, expect, it } from "vite-plus/test";
3
3
 
4
4
  import { tools } from "../api/formats/json/tools/index.js";
5
5
  import { StreamTool } from "./streamTool.js";
@@ -33,9 +33,9 @@ export function getProviderOverrides(model: Exclude<LanguageModel, string>) {
33
33
  );
34
34
  }
35
35
 
36
- export class ClientSideTransport<UI_MESSAGE extends UIMessage>
37
- implements ChatTransport<UI_MESSAGE>
38
- {
36
+ export class ClientSideTransport<
37
+ UI_MESSAGE extends UIMessage,
38
+ > implements ChatTransport<UI_MESSAGE> {
39
39
  constructor(
40
40
  public readonly opts: {
41
41
  /**
@@ -95,7 +95,10 @@ export class ClientSideTransport<UI_MESSAGE extends UIMessage>
95
95
  // activeTools: ["applyDocumentOperations"],
96
96
  });
97
97
 
98
- return ret.toUIMessageStream();
98
+ return ret.toUIMessageStream({
99
+ onError: (error) =>
100
+ error instanceof Error ? error.message : String(error),
101
+ });
99
102
  }
100
103
 
101
104
  async sendMessages({
@@ -107,7 +110,7 @@ export class ClientSideTransport<UI_MESSAGE extends UIMessage>
107
110
  > {
108
111
  const stream = this.opts.stream ?? true;
109
112
  const toolDefinitions = (body as any).toolDefinitions;
110
- const tools = await toolDefinitionsToToolSet(toolDefinitions);
113
+ const tools = toolDefinitionsToToolSet(toolDefinitions);
111
114
 
112
115
  if (stream) {
113
116
  // this can be used to simulate initial network errors
@@ -1,4 +1,4 @@
1
- import { describe, expect, it } from "vitest";
1
+ import { describe, expect, it } from "vite-plus/test";
2
2
  import { createAppendableStream } from "./appendableStream.js";
3
3
 
4
4
  async function collectStream<T>(stream: ReadableStream<T>): Promise<T[]> {
@@ -30,11 +30,11 @@ describe("createAppendableStream", () => {
30
30
  },
31
31
  });
32
32
 
33
- append(infiniteStream);
33
+ void append(infiniteStream);
34
34
 
35
35
  // Cancel the output stream after a short delay
36
36
  setTimeout(() => {
37
- output.cancel("cancelled");
37
+ void output.cancel("cancelled");
38
38
  }, 100);
39
39
 
40
40
  // finalize should resolve (or reject) eventually, not hang forever
@@ -59,7 +59,7 @@ describe("createAppendableStream", () => {
59
59
  },
60
60
  });
61
61
 
62
- append(stream);
62
+ void append(stream);
63
63
  await finalize();
64
64
 
65
65
  const results = await collectStream(output);
@@ -85,8 +85,8 @@ describe("createAppendableStream", () => {
85
85
  },
86
86
  });
87
87
 
88
- append(stream1);
89
- append(stream2);
88
+ void append(stream1);
89
+ void append(stream2);
90
90
  await finalize();
91
91
 
92
92
  const results = await collectStream(output);
@@ -110,7 +110,7 @@ describe("createAppendableStream", () => {
110
110
  },
111
111
  });
112
112
 
113
- append(stream);
113
+ void append(stream);
114
114
  await finalize();
115
115
 
116
116
  const results = await collectStream(output);
@@ -127,7 +127,7 @@ describe("createAppendableStream", () => {
127
127
  },
128
128
  });
129
129
 
130
- append(stream);
130
+ void append(stream);
131
131
 
132
132
  // finalize resolves even when there's an error
133
133
  await finalize();
@@ -141,7 +141,7 @@ describe("createAppendableStream", () => {
141
141
  it("should throw when appending to a canceled stream", async () => {
142
142
  const { output, append } = createAppendableStream<number>();
143
143
 
144
- output.cancel("cancelled");
144
+ void output.cancel("cancelled");
145
145
 
146
146
  const stream = new ReadableStream<number>({
147
147
  start(controller) {
@@ -170,7 +170,7 @@ describe("createAppendableStream", () => {
170
170
  const appendPromise = append(slowStream);
171
171
 
172
172
  // Cancel before the stream finishes
173
- output.cancel("cancelled");
173
+ void output.cancel("cancelled");
174
174
 
175
175
  // The append promise should resolve (cancellation is handled internally)
176
176
  await appendPromise;
@@ -198,8 +198,8 @@ describe("createAppendableStream", () => {
198
198
  },
199
199
  });
200
200
 
201
- append(slowStream);
202
- append(fastStream);
201
+ void append(slowStream);
202
+ void append(fastStream);
203
203
  await finalize();
204
204
 
205
205
  const results = await collectStream(output);
@@ -215,7 +215,7 @@ describe("createAppendableStream", () => {
215
215
  },
216
216
  });
217
217
 
218
- append(emptyStream);
218
+ void append(emptyStream);
219
219
  await finalize();
220
220
 
221
221
  const results = await collectStream(output);
@@ -237,8 +237,8 @@ describe("createAppendableStream", () => {
237
237
  },
238
238
  });
239
239
 
240
- append(empty1);
241
- append(empty2);
240
+ void append(empty1);
241
+ void append(empty2);
242
242
  await finalize();
243
243
 
244
244
  const results = await collectStream(output);
@@ -6,7 +6,8 @@ import {
6
6
  UIMessage,
7
7
  UIMessageChunk,
8
8
  } from "ai";
9
- import { describe, expect, it } from "vitest";
9
+ import { describe, expect, it } from "vite-plus/test";
10
+ import { AttributionMarksExtension } from "../../../prosemirror/AttributionMarks.js";
10
11
  import { aiDocumentFormats } from "../../../server.js";
11
12
  import { ChunkExecutionError } from "../../ChunkExecutionError.js";
12
13
  import { setupToolCallStreaming } from "./chatHandlers.js";
@@ -81,6 +82,10 @@ describe("setupToolCallStreaming", () => {
81
82
 
82
83
  it("should handle abort signal", async () => {
83
84
  const editor = BlockNoteEditor.create({
85
+ // The stream tools apply changes as suggestions, which need the AI
86
+ // suggestion marks (`insertion` / `deletion` / `modification`) in the
87
+ // schema.
88
+ extensions: [AttributionMarksExtension()],
84
89
  initialContent: [
85
90
  {
86
91
  type: "paragraph",
@@ -154,6 +159,10 @@ describe("setupToolCallStreaming", () => {
154
159
 
155
160
  it("should handle abort signal that is already aborted", async () => {
156
161
  const editor = BlockNoteEditor.create({
162
+ // The stream tools apply changes as suggestions, which need the AI
163
+ // suggestion marks (`insertion` / `deletion` / `modification`) in the
164
+ // schema.
165
+ extensions: [AttributionMarksExtension()],
157
166
  initialContent: [
158
167
  {
159
168
  type: "paragraph",
@@ -61,7 +61,7 @@ export async function setupToolCallStreaming(
61
61
  data.toolName,
62
62
  data.toolCallId,
63
63
  );
64
- appendableStream.append(toolCallStreamData.operationsStream);
64
+ void appendableStream.append(toolCallStreamData.operationsStream);
65
65
  toolCallStreams.set(data.toolCallId, toolCallStreamData);
66
66
  if (first) {
67
67
  first = false;
@@ -93,7 +93,7 @@ export async function setupToolCallStreaming(
93
93
  for (const data of toolCallStreams.values()) {
94
94
  if (!data.complete) {
95
95
  // this can happen in case of a network error for example
96
- data.writer.abort(chat.error);
96
+ void data.writer.abort(chat.error);
97
97
  }
98
98
  }
99
99
  // reject(chat.error);
@@ -157,7 +157,7 @@ export async function setupToolCallStreaming(
157
157
  // TODO: it would be better to add these tool outputs "live" as they occur,
158
158
  // possibly including a callback to create checkpoints after applying a tool
159
159
  if (!errorSeen) {
160
- chat.addToolOutput({
160
+ void chat.addToolOutput({
161
161
  state: "output-available",
162
162
  tool: toolCalls[index].toolName,
163
163
  toolCallId: toolCalls[index].toolCallId,
@@ -165,7 +165,7 @@ export async function setupToolCallStreaming(
165
165
  output: { status: "ok" },
166
166
  });
167
167
  } else {
168
- chat.addToolOutput({
168
+ void chat.addToolOutput({
169
169
  tool: toolCalls[index].toolName,
170
170
  toolCallId: toolCalls[index].toolCallId,
171
171
  state: "output-error",
@@ -271,7 +271,7 @@ function processToolCallPart(part: any, toolCallData: ToolCallStreamData) {
271
271
  if (part.state === "input-streaming") {
272
272
  const input = part.input;
273
273
  if (input !== undefined) {
274
- toolCallData.writer.write(input as any);
274
+ void toolCallData.writer.write(input as any);
275
275
  }
276
276
  } else if (part.state === "input-available") {
277
277
  const input = part.input;
@@ -280,8 +280,8 @@ function processToolCallPart(part: any, toolCallData: ToolCallStreamData) {
280
280
  }
281
281
  if (!toolCallData.complete) {
282
282
  toolCallData.complete = true;
283
- toolCallData.writer.write(input as any);
284
- toolCallData.writer.close();
283
+ void toolCallData.writer.write(input as any);
284
+ void toolCallData.writer.close();
285
285
  }
286
286
  }
287
287
  }
package/src/style.css CHANGED
@@ -12,22 +12,3 @@
12
12
  .bn-combobox-items:empty {
13
13
  display: none;
14
14
  }
15
-
16
- div[data-type="modification"] {
17
- display: inline;
18
- }
19
-
20
- ins,
21
- [data-type="modification"] {
22
- background: rgba(24, 122, 220, 0.1);
23
- border-bottom: 2px solid rgba(24, 122, 220, 0.1);
24
- color: rgb(20, 95, 170);
25
- text-decoration: none;
26
- }
27
-
28
- del,
29
- [DISABLED-data-node-deletion] {
30
- color: rgba(100, 90, 75, 0.3);
31
- text-decoration: line-through;
32
- text-decoration-thickness: 1px;
33
- }
@@ -1,7 +1,7 @@
1
1
  import { BlockNoteEditor } from "@blocknote/core";
2
2
  import { revertSuggestions } from "@handlewithcare/prosemirror-suggest-changes";
3
3
  import { Node } from "prosemirror-model";
4
- import { expect } from "vitest";
4
+ import { expect } from "vite-plus/test";
5
5
 
6
6
  export function validateRejectingResultsInOriginalDoc(
7
7
  editor: BlockNoteEditor<any, any, any>,
@@ -39,7 +39,7 @@ export function createAsyncIterableStream<T>(
39
39
 
40
40
  const stream = source.pipeThrough(new TransformStream<T, T>());
41
41
 
42
- (stream as AsyncIterableStream<T>)[Symbol.asyncIterator] = () => {
42
+ (stream as any)[Symbol.asyncIterator] = () => {
43
43
  if (stream.locked) {
44
44
  throw new Error("Stream is already locked and cannot be iterated again.");
45
45
  }
@@ -0,0 +1 @@
1
+ /// <reference types="vite-plus/client" />
@@ -28,6 +28,10 @@ export declare const AIExtension: (options?: (AIRequestHelpers & {
28
28
  key: string;
29
29
  options: import("@tanstack/store").Store<AIRequestHelpers, (cb: AIRequestHelpers) => AIRequestHelpers>;
30
30
  store: import("@tanstack/store").Store<AIPluginState, (cb: AIPluginState) => AIPluginState>;
31
+ blockNoteExtensions: import("@blocknote/core").ExtensionFactoryInstance<{
32
+ key: string;
33
+ tiptapExtensions: import("@tiptap/core").Mark<any, any>[];
34
+ }>[];
31
35
  mount({ signal }: {
32
36
  signal: AbortSignal;
33
37
  }): void;
@@ -35,7 +35,7 @@ export declare function createAddBlocksTool<T>(config: {
35
35
  * - apply operations from a format that doesn't support all Block features (e.g.: markdown)
36
36
  * (the projection should be the the BlockNote document without the unsupported features)
37
37
  */
38
- rebaseTool: (id: string, editor: BlockNoteEditor<any, any, any>) => Promise<RebaseTool>;
38
+ rebaseTool: (id: string, editor: BlockNoteEditor<any, any, any>) => RebaseTool;
39
39
  /**
40
40
  * Converts the operation from `AddBlocksToolCall<T>` to `AddBlocksToolCall<PartialBlock<any, any, any>>`
41
41
  *
@@ -46,7 +46,7 @@ export declare function createAddBlocksTool<T>(config: {
46
46
  operation: AddBlocksToolCall<T>;
47
47
  isUpdateToPreviousOperation: boolean;
48
48
  isPossiblyPartial: boolean;
49
- }) => Promise<AddBlocksToolCall<PartialBlock<any, any, any>> | undefined>;
49
+ }) => AddBlocksToolCall<PartialBlock<any, any, any>> | undefined;
50
50
  }): (editor: BlockNoteEditor<any, any, any>, options: {
51
51
  idsSuffixed: boolean;
52
52
  withDelays: boolean;
@@ -40,7 +40,7 @@ export declare function createUpdateBlockTool<T>(config: {
40
40
  * - apply operations from a format that doesn't support all Block features (e.g.: markdown)
41
41
  * (the projection should be the the BlockNote document without the unsupported features)
42
42
  */
43
- rebaseTool: (id: string, editor: BlockNoteEditor<any, any, any>) => Promise<RebaseTool>;
43
+ rebaseTool: (id: string, editor: BlockNoteEditor<any, any, any>) => RebaseTool;
44
44
  /**
45
45
  * Converts the operation from `AddBlocksToolCall<T>` to `AddBlocksToolCall<PartialBlock<any, any, any>>`
46
46
  *
@@ -51,7 +51,7 @@ export declare function createUpdateBlockTool<T>(config: {
51
51
  operation: UpdateBlockToolCall<T>;
52
52
  isUpdateToPreviousOperation: boolean;
53
53
  isPossiblyPartial: boolean;
54
- }) => Promise<UpdateBlockToolCall<PartialBlock<any, any, any>> | undefined>;
54
+ }) => UpdateBlockToolCall<PartialBlock<any, any, any>> | undefined;
55
55
  }): (editor: BlockNoteEditor<any, any, any>, options: {
56
56
  idsSuffixed: boolean;
57
57
  withDelays: boolean;
@@ -66,11 +66,11 @@ export declare const aiDocumentFormats: {
66
66
  };
67
67
  systemPrompt: string;
68
68
  defaultDocumentStateBuilder: DocumentStateBuilder<{
69
- id: undefined;
70
- children: undefined;
71
69
  type: any;
72
70
  props: import("@blocknote/core").Props<any>;
73
- content: (import("@blocknote/core").StyledText<any> | import("@blocknote/core").Link<any> | import("@blocknote/core").CustomInlineContentFromConfig<any, any>)[] | import("@blocknote/core").TableContent<any, any> | undefined;
71
+ content: (import("@blocknote/core").CustomInlineContentFromConfig<any, any> | import("@blocknote/core").Link<any> | import("@blocknote/core").StyledText<any>)[] | import("@blocknote/core").PlainContent | import("@blocknote/core").TableContent<any, any> | undefined;
72
+ id: undefined;
73
+ children: undefined;
74
74
  }>;
75
75
  };
76
76
  _experimental_markdown: {
@@ -1,7 +1,7 @@
1
1
  import { BlockNoteEditor } from "@blocknote/core";
2
- export declare function createHTMLRebaseTool(id: string, editor: BlockNoteEditor<any, any, any>): Promise<{
2
+ export declare function createHTMLRebaseTool(id: string, editor: BlockNoteEditor<any, any, any>): {
3
3
  doc: import("prosemirror-model").Node;
4
4
  tr: () => import("prosemirror-transform").Transform;
5
5
  invertMap: import("prosemirror-transform").Mapping;
6
6
  rebaseTr: (tr: import("prosemirror-transform").Transform) => import("prosemirror-state").Transaction;
7
- }>;
7
+ };
@@ -37,10 +37,10 @@ export declare const jsonBlockLLMFormat: {
37
37
  };
38
38
  systemPrompt: string;
39
39
  defaultDocumentStateBuilder: import("../DocumentStateBuilder.js").DocumentStateBuilder<{
40
- id: undefined;
41
- children: undefined;
42
40
  type: any;
43
41
  props: import("@blocknote/core").Props<any>;
44
- content: (import("@blocknote/core").StyledText<any> | import("@blocknote/core").Link<any> | import("@blocknote/core").CustomInlineContentFromConfig<any, any>)[] | import("@blocknote/core").TableContent<any, any> | undefined;
42
+ content: (import("@blocknote/core").CustomInlineContentFromConfig<any, any> | import("@blocknote/core").Link<any> | import("@blocknote/core").StyledText<any>)[] | import("@blocknote/core").PlainContent | import("@blocknote/core").TableContent<any, any> | undefined;
43
+ id: undefined;
44
+ children: undefined;
45
45
  }>;
46
46
  };
@@ -1,8 +1,8 @@
1
1
  import { BlockNoteEditor } from "@blocknote/core";
2
2
  import { Mapping } from "prosemirror-transform";
3
- export declare function createMDRebaseTool(id: string, editor: BlockNoteEditor<any, any, any>): Promise<{
3
+ export declare function createMDRebaseTool(id: string, editor: BlockNoteEditor<any, any, any>): {
4
4
  doc: import("prosemirror-model").Node;
5
5
  tr: () => import("prosemirror-transform").Transform;
6
6
  invertMap: Mapping;
7
7
  rebaseTr: (tr: import("prosemirror-transform").Transform) => import("prosemirror-state").Transaction;
8
- }>;
8
+ };
@@ -31,6 +31,7 @@ export declare function blockNoteSchemaToJSONSchema(schema: BlockNoteSchema<any,
31
31
  additionalProperties?: undefined;
32
32
  required?: undefined;
33
33
  } | {
34
+ $ref?: undefined;
34
35
  type: string;
35
36
  properties: {
36
37
  type: {
@@ -50,10 +51,11 @@ export declare function blockNoteSchemaToJSONSchema(schema: BlockNoteSchema<any,
50
51
  };
51
52
  additionalProperties: boolean;
52
53
  required: string[];
53
- $ref?: undefined;
54
54
  } | {
55
+ $ref?: undefined;
55
56
  type: string;
56
57
  properties: {
58
+ href?: undefined;
57
59
  type: {
58
60
  type: string;
59
61
  enum: string[];
@@ -65,11 +67,9 @@ export declare function blockNoteSchemaToJSONSchema(schema: BlockNoteSchema<any,
65
67
  };
66
68
  } | undefined;
67
69
  props: SimpleJSONObjectSchema;
68
- href?: undefined;
69
70
  };
70
71
  additionalProperties: boolean;
71
72
  required: string[];
72
- $ref?: undefined;
73
73
  })[];
74
74
  };
75
75
  };
@@ -0,0 +1,15 @@
1
+ import { Mark } from "@tiptap/core";
2
+ export declare const SuggestionAddMark: Mark<any, any>;
3
+ export declare const SuggestionDeleteMark: Mark<any, any>;
4
+ export declare const SuggestionModificationMark: Mark<any, any>;
5
+ /**
6
+ * Bundles the three AI suggestion marks (`insertion` / `deletion` /
7
+ * `modification`) into a single BlockNote extension, so they can be registered
8
+ * in one line wherever they're needed (the AI extension, or a test that
9
+ * exercises suggestions). The marks opt into being allowed on block nodes via
10
+ * their `blockLevelSuggestion` option — see core's `suggestionMarks`.
11
+ */
12
+ export declare const AttributionMarksExtension: () => import("@blocknote/core").ExtensionFactoryInstance<{
13
+ key: string;
14
+ tiptapExtensions: Mark<any, any>[];
15
+ }>;