@blocknote/xl-ai 0.47.3 → 0.48.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.
- package/dist/blocknote-xl-ai.cjs +2 -2
- package/dist/blocknote-xl-ai.cjs.map +1 -1
- package/dist/blocknote-xl-ai.js +573 -925
- package/dist/blocknote-xl-ai.js.map +1 -1
- package/dist/locales.cjs +2 -2
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +1593 -1486
- package/dist/locales.js.map +1 -1
- package/dist/server-Ct45EOTu.cjs +36 -0
- package/dist/server-Ct45EOTu.cjs.map +1 -0
- package/dist/server-JIYg7ELG.js +1630 -0
- package/dist/server-JIYg7ELG.js.map +1 -0
- package/dist/server.cjs +1 -2
- package/dist/server.js +3 -23
- package/dist/style.css +2 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +13 -13
- package/src/api/formats/tests/sharedTestCases.ts +3 -3
- package/src/prosemirror/changeset.ts +8 -2
- package/src/prosemirror/rebaseTool.ts +1 -1
- package/dist/client-BPNTLm1-.cjs +0 -36
- package/dist/client-BPNTLm1-.cjs.map +0 -1
- package/dist/client-DHVeP6Er.js +0 -2149
- package/dist/client-DHVeP6Er.js.map +0 -1
- package/dist/server.cjs.map +0 -1
- package/dist/server.js.map +0 -1
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{Add heading (h1) and code block_1_21c6ffe4ff4bd18e2a782b926b61618c.json → Add heading (h1) and code block_1_144961d511efe7e04c44ff79ecabf43e.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{add a list (end)_1_d0219ee443d8f6d3563dcffcba160730.json → add a list (end)_1_ca20c0b56ff3bdfe67f76b3e1b3c82bc.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{add a new paragraph (empty doc)_1_0737d0ae03c2d0adf101da14bdef2414.json → add a new paragraph (empty doc)_1_509f796014e0dae8a4a50e1aaab8a378.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{add a new paragraph (end)_1_25717cdb5e0dabfd9e85a28126fc6b5b.json → add a new paragraph (end)_1_f4419c510915474907ca2fb35f92d2b8.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{add a new paragraph (start)_1_8fc8e14082d21bf98623cd9ef57bafff.json → add a new paragraph (start)_1_3426f436a5b272f3b8e26edcec43fdae.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{Add heading (h1) and code block_1_72b3fb10d4b64ad2c57b7e759fb45ea2.json → Add heading (h1) and code block_1_3f0b847de3745c61a82e3a9728770d4d.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{add a list (end)_1_6330fcc2bc48733981e5337c6f38fe08.json → add a list (end)_1_680d0a41316e174365d11814e9df7fda.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{add a new paragraph (empty doc)_1_1df3fb78a5790897b37bfba0ae96be1e.json → add a new paragraph (empty doc)_1_3f2fffcfa733575ca2a6c4f9d1a8f615.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{add a new paragraph (end)_1_13ac6e523b724ec3d4e4113c1f973f7d.json → add a new paragraph (end)_1_04b2bff7b39bfda09c5d3f116cbb53b9.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{add a new paragraph (start)_1_c7a2f3226a4ee862c75a049c92cea98f.json → add a new paragraph (start)_1_45ec5a1e5fa6757f02843c8803e7a334.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{Add heading (h1) and code block_1_a10f3f8e8e6d938c54950352eae2f50f.json → Add heading (h1) and code block_1_ece60088a9ecb6767d83b6584bbec6d9.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{add a list (end)_1_b0a300b9716085d9bfa169d8085d10b7.json → add a list (end)_1_64e60c0c2add32fbfe1da823b8c7990a.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{add a new paragraph (empty doc)_1_9d4f54665e392006af18af614d32e632.json → add a new paragraph (empty doc)_1_100f09592ece8a32c33dff2dc612c649.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{add a new paragraph (end)_1_d862f2761b7f6594f4b571c7f8291820.json → add a new paragraph (end)_1_a2a9884926fbc5218a3f00c9952cefd5.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{add a new paragraph (start)_1_94759353bbdb9e30152eb0164488ba89.json → add a new paragraph (start)_1_c85bbb5cec5410289d652e15b2df6fa3.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{add and update paragraph_1_2dbe9e9945d6cabc0b02e812a6ba1b93.json → add and update paragraph_1_380a0c02b5089b38247457135c044cf7.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{add paragraph and update selection_1_ed2eea810db5ab73a8478e981735f2a6.json → add paragraph and update selection_1_298b51bb28c5f95ab9a00205d4e38460.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{add and update paragraph_1_7a6f24c686aeb896da8088bd8ea14089.json → add and update paragraph_1_f6253c11196abdbeae0f898cc9df85eb.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{add paragraph and update selection_1_9d907341d7a5b18529ccaf20cacbbe6f.json → add paragraph and update selection_1_dc29d735348684d1ec3e290ad8c03a71.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{add and update paragraph_1_a562a7fd96440f9bfac43e04c1bf144a.json → add and update paragraph_1_a27ae10badcc3913a00eb86f77ac64db.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{add paragraph and update selection_1_6bb242aace6ad9ae71bcb369ce8208d4.json → add paragraph and update selection_1_86f10ca461ee44e74ae571fb9f214338.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Delete/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{delete first block_1_71dfbd70fa9bcd8c2378c0b255360279.json → delete first block_1_91346200727a71ab9ad8c5d014835688.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Delete/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{delete first block_1_72e05e8a661b9149b89f8ca9a80a2129.json → delete first block_1_150a539024aa981c9f6bcb068875a6c9.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Delete/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{delete first block_1_f51e5c59768fde7bccc5635d90890452.json → delete first block_1_1b3c4ac85d448677697457098332ceba.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{clear block formatting_1_f3ecead131eac14f117b601ad92bae90.json → clear block formatting_1_fc858b37cc10ed7b65802375977eaf7a.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{drop mark and link and change text within mark_1_6b686110fa540e40d81fd68ee23cde86.json → drop mark and link and change text within mark_1_fe3cac9da9d1e17a20ee8c0c4380d925.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{drop mark and link_1_fee0a33a7c0951dacc8fd9ba02adef0a.json → drop mark and link_1_f6ee881e6d3b4cd9553256523e67683a.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{fix spelling mid-word selection_1_ce6692c22eda2a757e123681118a333d.json → fix spelling mid-word selection_1_360f2cf4db48ef5b92c8e24ed0998167.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{modify nested content_1_1d18b29fde3a6494f2d1df98d0689bcf.json → modify nested content_1_a57d7364de9ba3d72686aca4f3c424e4.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{modify parent content_1_7d96675c4edc13f69084f42983de6d73.json → modify parent content_1_5f7043c9275e742ea47f92b66e65a845.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{plain source block, add mention_1_785d7f53424b53e8b64f4732aa578c61.json → plain source block, add mention_1_ccd752aefdbc2252a5a09bebac393afb.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{standard update_1_c01c22b2bf79f30908ce9ffb0798a79f.json → standard update_1_c44a31a1631a3a10efcd5e17645998f1.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{styles + ic in source block, remove mark_1_66f540dda8b5f8e8713b9c6f0bdd4d3f.json → styles + ic in source block, remove mark_1_df177a6a4f26b0fbcba307c6d21cab76.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{styles + ic in source block, remove mention_1_9111f9b26383721d9186c99d035f44e8.json → styles + ic in source block, remove mention_1_4ba9f3411694f807e85e8e33f4b3c8cd.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{styles + ic in source block, replace content_1_6a2c68962725ab2dc43dc12b5e9e5d8f.json → styles + ic in source block, replace content_1_f5b001d0f8415a00e8b043f3e3e33535.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{styles + ic in source block, update mention prop_1_60f48a7bd81fb6a72b96b284d61c6e53.json → styles + ic in source block, update mention prop_1_c197e3f5ce1dbc1a68765acbd198881a.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{styles + ic in source block, update text_1_284f982ebe3b60bc15c674d63795a879.json → styles + ic in source block, update text_1_a0b93418bb2a5c0049e0a5c896f72191.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{styles + ic in target block, add mark (paragraph)_1_6c8e4ac91518d57e4827481f00ddc38e.json → styles + ic in target block, add mark (paragraph)_1_fb2285b8d362cb8adcf78f6039ad3058.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{styles + ic in target block, add mark (word)_1_06f3ae0ab5b505f03cf8e0c6bd654b1e.json → styles + ic in target block, add mark (word)_1_e0087b91327576eaff9f8d4d368e0a03.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{translate selection_1_1ad7d1a857e525e2d0f5a8c85b645a0e.json → translate selection_1_4706b49daa5ad7afe9dfadded2e335c5.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{turn paragraphs into list_1_0e8f14f06679e951d88ec74919c24b90.json → turn paragraphs into list_1_a3ce79b4f32d1dd6ac04dbe6b69e187b.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{update block prop and content_1_f6c1cfee51cd75204495d3db1d80350e.json → update block prop and content_1_5bb684c9ae46815b5367a39bd42d5257.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{update block prop_1_759983067f25f0daafb42bc9fefcdb64.json → update block prop_1_8469a78802d46f3d9ec74dd1fbf49fd8.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{update block type and content_1_e9d9d699bbe4a3b6e754c530ffe56e2c.json → update block type and content_1_226cc5d7352c8c7e58a15d064543518c.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{update block type_1_ac405ec31a0cb874515b0c5b6aa2eb2d.json → update block type_1_c4cc00889532e0baa73998da5e79c303.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{clear block formatting_1_1b60a2dae45a21cc2916e15e97bfd289.json → clear block formatting_1_6c08229db90214b8a20b0d7dfefb2824.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{drop mark and link and change text within mark_1_a7e99401a3cc86c79b30fdf47b0dc28e.json → drop mark and link and change text within mark_1_e5c77f0f881e77f6ee27a25f203ffdcb.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{drop mark and link_1_75e458d048de9ef0fb1eef34109ec81b.json → drop mark and link_1_b93576392cb38dc57acd85f7fc55c6cd.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{fix spelling mid-word selection_1_8c47595610a6a2d15e1c5c751528e97a.json → fix spelling mid-word selection_1_9c19d479f2d356a48480d5ec5e384229.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{modify nested content_1_f81acd3a9fb46c387163c91724ec4c55.json → modify nested content_1_f42fc26924afc557d18ef6696f36a8fa.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{modify parent content_1_49c9371e221a7966cac554b99ba56b02.json → modify parent content_1_e8424752b43fa146d8575a475924de52.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{plain source block, add mention_1_b2be33e4a07122a85e49b521c20f26db.json → plain source block, add mention_1_b18afae076d7f7f423477f1e1bc5813a.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{standard update_1_08d79a078de070c800627c412f9a0d9f.json → standard update_1_529e09ae665507a31316cb632f5cabcd.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{styles + ic in source block, remove mark_1_0d87ce48c7e9e690bde7fc3668fe735b.json → styles + ic in source block, remove mark_1_20036398e12cf4a20b50024ad5f30018.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{styles + ic in source block, remove mention_1_a96e84a734674ca195c2b40bab34c2fa.json → styles + ic in source block, remove mention_1_ed131f0383e7709a4e5fae2df28af29a.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{styles + ic in source block, replace content_1_f5be35337d2ac3c65ec6363d4f347364.json → styles + ic in source block, replace content_1_51bfdc443e43bbf18599fcc3a16c5683.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{styles + ic in source block, update mention prop_1_a09c043f6d105b1496a7c79ce34e28d3.json → styles + ic in source block, update mention prop_1_7641f5691799d2666855c113b6659b71.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{styles + ic in source block, update text_1_dfc536ede5303a75993dea08764b318e.json → styles + ic in source block, update text_1_8fcb24a91437026c480205de77507871.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{styles + ic in target block, add mark (paragraph)_1_ebbeca51137a25dc54cdb7bafab53bed.json → styles + ic in target block, add mark (paragraph)_1_be126322b804c53145dbd35a6aa1131f.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{styles + ic in target block, add mark (word)_1_d6f14d8cecee690c72107e57eee0efbf.json → styles + ic in target block, add mark (word)_1_ec13a3b1d4f97b79148833b507295ffa.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{translate selection_1_59b3c2f2328276dc62dad98af951d63c.json → translate selection_1_f1a2ffb178b441d40625b8f110e3290f.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{turn paragraphs into list_1_50b1aa228a2b2557dea5026daaef2fad.json → turn paragraphs into list_1_8367ba81813ffe9d2d17f2de266f3039.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{update block prop and content_1_4a65e945b3b6fac5d4a0cf8d623486d3.json → update block prop and content_1_8557c5a4249c324adfff5d243645e3de.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{update block prop_1_83a73dcfd05a6cf6754e1eb24114c1f1.json → update block prop_1_16dda1caa1f43ab624eb28a605179dd3.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{update block type and content_1_7500fd44498888e45aedc9dfa669737c.json → update block type and content_1_8b167672c96bf3c69b9b146eb4f26451.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{update block type_1_92eb84e55a7b9efe5daf52bef299b4a6.json → update block type_1_7326b3d0db43c8f399aba2bc44c80194.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{clear block formatting_1_21bbf793e092bd207656f933b2274b21.json → clear block formatting_1_651c2e0b4f940c6cece61513462d2ddd.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{drop mark and link and change text within mark_1_70261ec295eec99f6b835af3371749ef.json → drop mark and link and change text within mark_1_94f36faff958747b5d66a185e268bba7.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{drop mark and link_1_45e52fc97822fb0e7573a6603137ab4e.json → drop mark and link_1_60bf97139612cd25b1f99502383df8aa.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{fix spelling mid-word selection_1_74934d888aa5deba8c74b66c12d81443.json → fix spelling mid-word selection_1_db44da41b500c6883e215f2b6d013f58.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{modify nested content_1_bfd4f73138b34375f33d28b5ee48d971.json → modify nested content_1_f3a35d9120c6ff0e02a89548d8349363.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{modify parent content_1_df8380600ae416c0eb70034e41b59701.json → modify parent content_1_7205cf7ec3d86e8ebd9c555028c5db74.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{plain source block, add mention_1_4579057dabcbe2f9f73c9a329a99393d.json → plain source block, add mention_1_d5759fe9868f60a47538d31361c68b3c.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{standard update_1_ede2a6f5b9da689056b55d71d91434fe.json → standard update_1_f6a167a6ea376d70d84dd9aac6ac7bb3.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{styles + ic in source block, remove mark_1_a6d8c670d163bd0cf79a424c6a6054a0.json → styles + ic in source block, remove mark_1_990c696cfe9af87de056328060fd1f93.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{styles + ic in source block, remove mention_1_ea57e8c6df3c134fa91348e7b71e7a57.json → styles + ic in source block, remove mention_1_fd4deb4dce4d79ae14939fda71c510fd.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{styles + ic in source block, replace content_1_24429e5416bc371492edd73611cf3946.json → styles + ic in source block, replace content_1_6cd810cd03bff509578637fe27d13a92.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{styles + ic in source block, update mention prop_1_079714c774da28b17075269c1cdd1696.json → styles + ic in source block, update mention prop_1_f0e30d1d6cbc94e6b7dcb8abb7e0221f.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{styles + ic in source block, update text_1_e0d8184c9829e07f8df2860248818bc8.json → styles + ic in source block, update text_1_1104dff815f18f8f786fb7d4e4522d47.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{styles + ic in target block, add mark (paragraph)_1_6b7d5cf6029aa5db5a9aaad9264795f8.json → styles + ic in target block, add mark (paragraph)_1_e2f4cdb3df42b17c74cd1d2d00d2f8d5.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{styles + ic in target block, add mark (word)_1_ffc7b82f1fb9de2ffacf16dda33c09eb.json → styles + ic in target block, add mark (word)_1_6b5073ce92485be7974a344d50247b4a.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{translate selection_1_b8200b55589e761efded3c08e8709a53.json → translate selection_1_d343e10867cc7b3d9850847c99826b61.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{turn paragraphs into list_1_30410f1a45a0de453f68c27fa57dded9.json → turn paragraphs into list_1_3373025fd96315ed15342f3a3a727771.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{update block prop and content_1_2184f0d7adf54cebd8f2068b93783d8b.json → update block prop and content_1_780bfe04d42dd48e9115cba7c4582c01.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{update block prop_1_56a595216306ecbe9557436eabd778b1.json → update block prop_1_667c03220ba6e678d0c91b9de092484b.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{update block type and content_1_894e0e3aa3fe005922264627bab288ea.json → update block type and content_1_f3c6521f6f12dc50dc16d0bbc277a858.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{update block type_1_0bf2510ac3023bb1a62d991c85655cba.json → update block type_1_7c4fbdcabcec0568ade27d2b47afbaab.json} +0 -0
package/dist/blocknote-xl-ai.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=require("@ai-sdk/react"),_=require("@blocknote/core"),I=require("@blocknote/core/extensions"),P=require("@handlewithcare/prosemirror-suggest-changes"),L=require("prosemirror-model"),B=require("prosemirror-state"),Y=require("prosemirror-tables"),A=require("prosemirror-view"),J=require("y-prosemirror"),a=require("./client-BPNTLm1-.cjs"),u=require("react/jsx-runtime"),b=require("@blocknote/react"),C=require("react"),j=require("@floating-ui/react"),Q=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},w=Q(C),V=new B.PluginKey("blocknote-agent-cursor");function X(e){return new B.Plugin({key:V,view:t=>({}),state:{init:()=>({selection:void 0}),apply:(t,o)=>{const n=t.getMeta("aiAgent");return n?{selection:n.selection}:{selection:void 0}}},props:{decorations:t=>{const{doc:o}=t,{selection:n}=V.getState(t),i=[];if(!n)return A.DecorationSet.create(o,[]);i.push(A.Decoration.widget(n.head,()=>ee(e),{key:"agent-cursor",side:10}));const m=Math.min(n.anchor,n.head),h=Math.max(n.anchor,n.head);return i.push(A.Decoration.inline(m,h,J.defaultSelectionBuilder(e),{inclusiveEnd:!0,inclusiveStart:!1})),A.DecorationSet.create(o,i)}}})}const ee=e=>{const t=document.createElement("span");t.classList.add("bn-collaboration-cursor__base"),t.setAttribute("data-active","true");const o=document.createElement("span");o.setAttribute("contentedEditable","false"),o.classList.add("bn-collaboration-cursor__caret"),o.setAttribute("style",`background-color: ${e.color}`);const n=document.createElement("span");return n.classList.add("bn-collaboration-cursor__label"),n.setAttribute("style",`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null),o.insertBefore(n,null),t.insertBefore(document.createTextNode(""),null),t.insertBefore(o,null),t.insertBefore(document.createTextNode(""),null),t},te=new B.PluginKey("blocknote-ai-plugin"),S=_.createExtension(({editor:e,options:t})=>{const o=_.createStore(t??{}),n=_.createStore({aiMenuState:"closed"});let i,m=!1;const h=P.suggestChanges();return h.props.decorations=void 0,{key:"ai",options:o,store:n,mount({signal:r}){let s=!1;document.addEventListener("scroll",()=>{s&&(m=!1),s=!0},{capture:!0,signal:r}),document.addEventListener("scrollend",()=>{s=!1},{capture:!0,signal:r})},prosemirrorPlugins:[new B.Plugin({key:te,filterTransaction:r=>{var l;const s=n.state.aiMenuState;return!(s!=="closed"&&s.status==="ai-writing"&&(l=r.getMeta(Y.fixTablesKey))!=null&&l.fixTables)}}),h,X((t==null?void 0:t.agentCursor)||{name:"AI",color:"#8bc6ff"})],openAIMenuAtBlock(r){var l,d;(l=e.getExtension(I.ShowSelectionExtension))==null||l.showSelection(!0,"aiMenu"),e.isEditable=!1,n.setState({aiMenuState:{blockId:r,status:"user-input"}});const s=(d=e.domElement)==null?void 0:d.querySelector(`[data-node-type="blockContainer"][data-id="${r}"]`);s==null||s.scrollIntoView({block:"center"})},closeAIMenu(){var r;n.setState({aiMenuState:"closed"}),i=void 0,(r=e.getExtension(I.ShowSelectionExtension))==null||r.showSelection(!1,"aiMenu"),e.isEditable=!0,e.focus()},acceptChanges(){var s;const r=e.prosemirrorState.doc;e.exec((l,d)=>P.revertSuggestions(l,c=>{d==null||d(c.setMeta("addToHistory",!1))})),e.exec((l,d)=>{const c=l.tr;c.replace(0,c.doc.content.size,new L.Slice(L.Fragment.from(r),0,0));const f=l.apply(c);return P.applySuggestions(f,g=>{d==null||d(c.replace(0,c.doc.content.size,new L.Slice(L.Fragment.from(g.doc),0,0)))})}),(s=e.getExtension(I.ForkYDocExtension))==null||s.merge({keepChanges:!0}),this.closeAIMenu()},rejectChanges(){var r;e.exec((s,l)=>P.revertSuggestions(s,d=>{l==null||l(d.setMeta("addToHistory",!1))})),(r=e.getExtension(I.ForkYDocExtension))==null||r.merge({keepChanges:!1}),this.closeAIMenu()},async abort(r){const{aiMenuState:s}=n.state;if(s==="closed"||!i||s.status!=="thinking"&&s.status!=="ai-writing")return;const l=i.chat;i.abortController.abort(r),await l.stop()},async retry(){const{aiMenuState:r}=n.state;if(r==="closed"||r.status!=="error"||!i)throw new Error("retry() is only valid when a previous response failed");return(i==null?void 0:i.chat.status)==="error"?this.invokeAI({...i.previousRequestOptions,userPrompt:"An error occured in the previous request. Please retry to accomplish the last user prompt."}):this.invokeAI({...i.previousRequestOptions,userPrompt:"An error occured while executing the previous tool call. Please retry to accomplish the last user prompt."})},setAIResponseStatus(r){var l;const s=n.state.aiMenuState;if(s!=="closed")if(r==="ai-writing"&&((l=e.getExtension(I.ShowSelectionExtension))==null||l.showSelection(!1,"aiMenu")),typeof r=="object"){if(r.status!=="error")throw new _.UnreachableCaseError(r.status);this.store.setState({aiMenuState:{status:r.status,error:r.error,blockId:s.blockId}})}else this.store.setState({aiMenuState:{status:r,blockId:s.blockId}})},async callLLM(r){return this.invokeAI(r)},async invokeAI(r){var s,l,d,c;this.setAIResponseStatus("thinking"),(s=e.getExtension(I.ForkYDocExtension))==null||s.fork();try{const f=new AbortController;i?(i.previousRequestOptions=r,i.abortController=f):i={previousRequestOptions:r,chat:((l=r.chatProvider)==null?void 0:l.call(r))||((c=(d=this.options.state).chatProvider)==null?void 0:c.call(d))||new G.Chat({sendAutomaticallyWhen:()=>!1,transport:r.transport||this.options.state.transport}),abortController:f};const g=i.chat;r={...o.state,...r};const x=await a.buildAIRequest({editor:e,useSelection:r.useSelection,deleteEmptyCursorBlock:r.deleteEmptyCursorBlock,streamToolsProvider:r.streamToolsProvider??this.options.state.streamToolsProvider,documentStateBuilder:r.documentStateBuilder??this.options.state.documentStateBuilder,onBlockUpdated:T=>{const E=n.state.aiMenuState,p=E==="closed"?void 0:E;if(!p||p.status!=="ai-writing")return;const y=_.getNodeById(T,e.prosemirrorState.doc);y&&(n.setState({aiMenuState:{blockId:T,status:"ai-writing"}}),m&&e.prosemirrorView.domAtPos(y.posBeforeNode+1).node.scrollIntoView({block:"center"}))},onStart:()=>{m=!0,this.setAIResponseStatus("ai-writing"),x.emptyCursorBlockToDelete&&x.editor.getBlock(x.emptyCursorBlockToDelete)&&x.editor.removeBlocks([x.emptyCursorBlockToDelete])}}),M=await a.sendMessageWithAIRequest(g,x,{role:"user",parts:[{type:"text",text:r.userPrompt}]},r.chatRequestOptions||this.options.state.chatRequestOptions,i.abortController.signal);M.ok&&g.status!=="error"||f.signal.aborted?this.setAIResponseStatus("user-reviewing"):(console.warn("Error calling LLM",{result:M,chatStatus:g.status,chatError:g.error}),this.setAIResponseStatus({status:"error",error:M.ok?g.error:M.error}))}catch(f){this.setAIResponseStatus({status:"error",error:f}),console.error("Unexpected error calling LLM",f,i==null?void 0:i.chat.messages)}}}});var N={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},z=w.default.createContext&&w.default.createContext(N),ne=["attr","size","title"];function oe(e,t){if(e==null)return{};var o=re(e,t),n,i;if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(e);for(i=0;i<m.length;i++)n=m[i],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function re(e,t){if(e==null)return{};var o={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;o[n]=e[n]}return o}function D(){return D=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},D.apply(this,arguments)}function H(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),o.push.apply(o,n)}return o}function O(e){for(var t=1;t<arguments.length;t++){var o=arguments[t]!=null?arguments[t]:{};t%2?H(Object(o),!0).forEach(function(n){ie(e,n,o[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):H(Object(o)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))})}return e}function ie(e,t,o){return t=se(t),t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function se(e){var t=ae(e,"string");return typeof t=="symbol"?t:t+""}function ae(e,t){if(typeof e!="object"||!e)return e;var o=e[Symbol.toPrimitive];if(o!==void 0){var n=o.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function F(e){return e&&e.map((t,o)=>w.default.createElement(t.tag,O({key:o},t.attr),F(t.child)))}function v(e){return t=>w.default.createElement(le,D({attr:O({},e.attr)},t),F(e.child))}function le(e){var t=o=>{var{attr:n,size:i,title:m}=e,h=oe(e,ne),r=i||o.size||"1em",s;return o.className&&(s=o.className),e.className&&(s=(s?s+" ":"")+e.className),w.default.createElement("svg",D({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},o.attr,n,h,{className:s,style:O(O({color:e.color||o.color},o.style),e.style),height:r,width:r,xmlns:"http://www.w3.org/2000/svg"}),m&&w.default.createElement("title",null,m),e.children)};return z!==void 0?w.default.createElement(z.Consumer,null,o=>t(o)):t(N)}function U(e){return v({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M8 7V11L2 6L8 1V5H13C17.4183 5 21 8.58172 21 13C21 17.4183 17.4183 21 13 21H4V19H13C16.3137 19 19 16.3137 19 13C19 9.68629 16.3137 7 13 7H8Z"},child:[]}]})(e)}function Z(e){return v({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M17.8492 11.6983L17.1421 10.9912L7.24264 20.8907H3V16.648L14.3137 5.33432L19.9706 10.9912C20.3611 11.3817 20.3611 12.0149 19.9706 12.4054L12.8995 19.4765L11.4853 18.0622L17.8492 11.6983ZM15.7279 9.57696L14.3137 8.16274L5 17.4765V18.8907H6.41421L15.7279 9.57696ZM18.5563 2.50589L21.3848 5.33432C21.7753 5.72484 21.7753 6.35801 21.3848 6.74853L19.9706 8.16274L15.7279 3.9201L17.1421 2.50589C17.5327 2.11537 18.1658 2.11537 18.5563 2.50589Z"},child:[]}]})(e)}function ce(e){return v({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M15.1986 9.94447C14.7649 9.5337 14.4859 8.98613 14.4085 8.39384L14.0056 5.31138L11.275 6.79724C10.7503 7.08274 10.1433 7.17888 9.55608 7.06948L6.49998 6.50015L7.06931 9.55625C7.17871 10.1435 7.08257 10.7505 6.79707 11.2751L5.31121 14.0057L8.39367 14.4086C8.98596 14.4861 9.53353 14.7651 9.94431 15.1987L12.0821 17.4557L13.4178 14.6486C13.6745 14.1092 14.109 13.6747 14.6484 13.418L17.4555 12.0823L15.1986 9.94447ZM15.2238 15.5079L13.0111 20.1581C12.8687 20.4573 12.5107 20.5844 12.2115 20.442C12.1448 20.4103 12.0845 20.3665 12.0337 20.3129L8.49229 16.5741C8.39749 16.474 8.27113 16.4096 8.13445 16.3918L3.02816 15.7243C2.69958 15.6814 2.46804 15.3802 2.51099 15.0516C2.52056 14.9784 2.54359 14.9075 2.5789 14.8426L5.04031 10.3192C5.1062 10.1981 5.12839 10.058 5.10314 9.92253L4.16 4.85991C4.09931 4.53414 4.3142 4.22086 4.63997 4.16017C4.7126 4.14664 4.78711 4.14664 4.85974 4.16017L9.92237 5.10331C10.0579 5.12855 10.198 5.10637 10.319 5.04048L14.8424 2.57907C15.1335 2.42068 15.4979 2.52825 15.6562 2.81931C15.6916 2.88421 15.7146 2.95507 15.7241 3.02833L16.3916 8.13462C16.4095 8.2713 16.4739 8.39766 16.5739 8.49245L20.3127 12.0338C20.5533 12.2617 20.5636 12.6415 20.3357 12.8821C20.2849 12.9357 20.2246 12.9795 20.1579 13.0112L15.5078 15.224C15.3833 15.2832 15.283 15.3835 15.2238 15.5079ZM16.0206 17.435L17.4348 16.0208L21.6775 20.2634L20.2633 21.6776L16.0206 17.435Z"},child:[]}]})(e)}function ue(e){return v({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M8.00008 6V9H5.00008V6H8.00008ZM3.00008 4V11H10.0001V4H3.00008ZM13.0001 4H21.0001V6H13.0001V4ZM13.0001 11H21.0001V13H13.0001V11ZM13.0001 18H21.0001V20H13.0001V18ZM10.7072 16.2071L9.29297 14.7929L6.00008 18.0858L4.20718 16.2929L2.79297 17.7071L6.00008 20.9142L10.7072 16.2071Z"},child:[]}]})(e)}function me(e){return v({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M15 18H16.5C17.8807 18 19 16.8807 19 15.5C19 14.1193 17.8807 13 16.5 13H3V11H16.5C18.9853 11 21 13.0147 21 15.5C21 17.9853 18.9853 20 16.5 20H15V22L11 19L15 16V18ZM3 4H21V6H3V4ZM9 18V20H3V18H9Z"},child:[]}]})(e)}function de(e){return v({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M13 6V21H11V6H5V4H19V6H13Z"},child:[]}]})(e)}function fe(e){return v({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M6.23509 6.45329C4.85101 7.89148 4 9.84636 4 12C4 16.4183 7.58172 20 12 20C13.0808 20 14.1116 19.7857 15.0521 19.3972C15.1671 18.6467 14.9148 17.9266 14.8116 17.6746C14.582 17.115 13.8241 16.1582 12.5589 14.8308C12.2212 14.4758 12.2429 14.2035 12.3636 13.3943L12.3775 13.3029C12.4595 12.7486 12.5971 12.4209 14.4622 12.1248C15.4097 11.9746 15.6589 12.3533 16.0043 12.8777C16.0425 12.9358 16.0807 12.9928 16.1198 13.0499C16.4479 13.5297 16.691 13.6394 17.0582 13.8064C17.2227 13.881 17.428 13.9751 17.7031 14.1314C18.3551 14.504 18.3551 14.9247 18.3551 15.8472V15.9518C18.3551 16.3434 18.3168 16.6872 18.2566 16.9859C19.3478 15.6185 20 13.8854 20 12C20 8.70089 18.003 5.8682 15.1519 4.64482C14.5987 5.01813 13.8398 5.54726 13.575 5.91C13.4396 6.09538 13.2482 7.04166 12.6257 7.11976C12.4626 7.14023 12.2438 7.12589 12.012 7.11097C11.3905 7.07058 10.5402 7.01606 10.268 7.75495C10.0952 8.2232 10.0648 9.49445 10.6239 10.1543C10.7134 10.2597 10.7307 10.4547 10.6699 10.6735C10.59 10.9608 10.4286 11.1356 10.3783 11.1717C10.2819 11.1163 10.0896 10.8931 9.95938 10.7412C9.64554 10.3765 9.25405 9.92233 8.74797 9.78176C8.56395 9.73083 8.36166 9.68867 8.16548 9.64736C7.6164 9.53227 6.99443 9.40134 6.84992 9.09302C6.74442 8.8672 6.74488 8.55621 6.74529 8.22764C6.74529 7.8112 6.74529 7.34029 6.54129 6.88256C6.46246 6.70541 6.35689 6.56446 6.23509 6.45329ZM12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22Z"},child:[]}]})(e)}function ge(e){return v({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z"},child:[]}]})(e)}function pe(e){return v({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z"},child:[]}]})(e)}function he(e){return v({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M12 4C9.4095 4 7.10606 5.23053 5.64274 7.14274L8 9.5H2V3.5L4.21863 5.71863C6.05061 3.452 8.85558 2 12 2 17.5228 2 22 6.47715 22 12H20C20 7.58172 16.4183 4 12 4ZM4 12C4 16.4183 7.58172 20 12 20 14.5905 20 16.894 18.7695 18.3573 16.8573L16 14.5 22 14.5V20.5L19.7814 18.2814C17.9494 20.548 15.1444 22 12 22 6.47715 22 2 17.5228 2 12H4Z"},child:[]}]})(e)}function q(e){return v({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M17.0007 1.20825 18.3195 3.68108 20.7923 4.99992 18.3195 6.31876 17.0007 8.79159 15.6818 6.31876 13.209 4.99992 15.6818 3.68108 17.0007 1.20825ZM8.00065 4.33325 10.6673 9.33325 15.6673 11.9999 10.6673 14.6666 8.00065 19.6666 5.33398 14.6666.333984 11.9999 5.33398 9.33325 8.00065 4.33325ZM19.6673 16.3333 18.0007 13.2083 16.334 16.3333 13.209 17.9999 16.334 19.6666 18.0007 22.7916 19.6673 19.6666 22.7923 17.9999 19.6673 16.3333Z"},child:[]}]})(e)}function R(){const e=b.useBlockNoteContext();return a.getAIDictionary(e.editor)}const W=e=>{const t=b.useComponentsContext(),{onManualPromptSubmit:o,promptText:n,onPromptTextChange:i,disabled:m}=e,[h,r]=C.useState(""),s=n||h,l=C.useCallback(async p=>{p.key==="Enter"&&!p.nativeEvent.isComposing&&o(s)},[s,o]),d=C.useCallback(p=>{const y=p.currentTarget.value;i&&i(y),n===void 0&&r(y)},[i,r,n]),c=C.useMemo(()=>I.filterSuggestionItems(e.items,s),[s,e.items]),{selectedIndex:f,setSelectedIndex:g,handler:k}=b.useSuggestionMenuKeyboardHandler(c,p=>p.onItemClick()),x=c.length>0&&f>=0&&f<c.length?`bn-suggestion-menu-item-${f}`:void 0,M=C.useCallback(p=>{p.key==="Enter"&&!p.nativeEvent.isComposing?c.length>0?k(p):l(p):k(p)},[l,k,c.length]);C.useEffect(()=>{g(0)},[s,g]);const T=C.useRef(null),E=C.useRef(m);return C.useEffect(()=>{T.current&&E.current&&!m&&T.current.focus(),m&&(E.current=!0)},[m]),u.jsxs("div",{className:"bn-combobox",children:[u.jsx(t.Generic.Form.Root,{children:u.jsx(t.Generic.Form.TextInput,{ref:T,className:"bn-combobox-input",name:"ai-prompt",variant:"large",icon:e.icon,value:s||"",placeholder:e.placeholder,disabled:e.disabled,onKeyDown:M,onChange:d,autoComplete:"off",rightSection:e.rightSection,"aria-activedescendant":x})}),c.length>0&&u.jsx(t.SuggestionMenu.Root,{className:"bn-combobox-items",id:"ai-suggestion-menu",children:c.map((p,y)=>u.jsx(t.SuggestionMenu.Item,{className:_.mergeCSSClasses("bn-suggestion-menu-item",p.size==="small"?"bn-suggestion-menu-item-small":""),id:`bn-suggestion-menu-item-${y}`,isSelected:y===f,onClick:p.onItemClick,item:p},p.title))})]})};function Ce(e){const t=a.getAIDictionary(e),o=e.getExtension(S);return o?[{key:"continue_writing",title:t.ai_default_commands.continue_writing.title,aliases:t.ai_default_commands.continue_writing.aliases,icon:u.jsx(Z,{size:18}),onItemClick:async()=>{await o.invokeAI({userPrompt:"Continue writing at the current cursor position related to the previous text. Add multiple blocks if needed. If the document looks like a template / draft, follow the template. Be extensive if needed.",streamToolsProvider:a.aiDocumentFormats.html.getStreamToolsProvider({defaultStreamTools:{add:!0,delete:!1,update:!1}})})},size:"small"},{key:"summarize",title:t.ai_default_commands.summarize.title,aliases:t.ai_default_commands.summarize.aliases,icon:u.jsx(me,{size:18}),onItemClick:async()=>{await o.invokeAI({userPrompt:"Summarize",streamToolsProvider:a.aiDocumentFormats.html.getStreamToolsProvider({defaultStreamTools:{add:!0,delete:!1,update:!1}})})},size:"small"},{key:"action_items",title:t.ai_default_commands.add_action_items.title,aliases:t.ai_default_commands.add_action_items.aliases,icon:u.jsx(ue,{size:18}),onItemClick:async()=>{await o.invokeAI({userPrompt:"Add action items",streamToolsProvider:a.aiDocumentFormats.html.getStreamToolsProvider({defaultStreamTools:{add:!0,delete:!1,update:!1}})})},size:"small"},{key:"write_anything",title:t.ai_default_commands.write_anything.title,aliases:t.ai_default_commands.write_anything.aliases,icon:u.jsx(Z,{size:18}),onItemClick:n=>{n(t.ai_default_commands.write_anything.prompt_placeholder)},size:"small"}]:[]}function be(e){const t=a.getAIDictionary(e),o=e.getExtension(S);return o?[{key:"improve_writing",title:t.ai_default_commands.improve_writing.title,aliases:t.ai_default_commands.improve_writing.aliases,icon:u.jsx(de,{size:18}),onItemClick:async()=>{await o.invokeAI({useSelection:!0,userPrompt:"Improve writing",streamToolsProvider:a.aiDocumentFormats.html.getStreamToolsProvider({defaultStreamTools:{add:!1,delete:!1,update:!0}})})},size:"small"},{key:"fix_spelling",title:t.ai_default_commands.fix_spelling.title,aliases:t.ai_default_commands.fix_spelling.aliases,icon:u.jsx(pe,{size:18}),onItemClick:async()=>{await o.invokeAI({useSelection:!0,userPrompt:"Fix spelling",streamToolsProvider:a.aiDocumentFormats.html.getStreamToolsProvider({defaultStreamTools:{add:!1,delete:!1,update:!0}})})},size:"small"},{key:"translate",title:t.ai_default_commands.translate.title,aliases:t.ai_default_commands.translate.aliases,icon:u.jsx(fe,{size:18}),onItemClick:n=>{n(t.ai_default_commands.translate.prompt_placeholder)},size:"small"},{key:"simplify",title:t.ai_default_commands.simplify.title,aliases:t.ai_default_commands.simplify.aliases,icon:u.jsx(ce,{size:18}),onItemClick:async()=>{await o.invokeAI({useSelection:!0,userPrompt:"Simplify",streamToolsProvider:a.aiDocumentFormats.html.getStreamToolsProvider({defaultStreamTools:{add:!1,delete:!1,update:!0}})})},size:"small"}]:[]}function Se(e){const t=a.getAIDictionary(e),o=e.getExtension(S);return o?[{key:"accept",title:t.ai_menu.actions.accept.title,aliases:t.ai_menu.actions.accept.aliases,icon:u.jsx(ge,{size:18}),onItemClick:()=>{o.acceptChanges()},size:"small"},{key:"revert",title:t.ai_menu.actions.revert.title,aliases:t.ai_menu.actions.revert.aliases,icon:u.jsx(U,{size:18}),onItemClick:()=>{o.rejectChanges()},size:"small"}]:[]}function ve(e){const t=a.getAIDictionary(e),o=e.getExtension(S);return o?[{key:"retry",title:t.ai_menu.actions.retry.title,aliases:t.ai_menu.actions.retry.aliases,icon:u.jsx(he,{size:18}),onItemClick:async()=>{await o.retry()},size:"small"},{key:"cancel",title:t.ai_menu.actions.cancel.title,aliases:t.ai_menu.actions.cancel.aliases,icon:u.jsx(U,{size:18}),onItemClick:()=>{o.rejectChanges()},size:"small"}]:[]}function K(e,t){return t==="user-input"?e.getSelection()?be(e):Ce(e):t==="user-reviewing"?Se(e):t==="error"?ve(e):[]}const $=e=>{const t=b.useBlockNoteEditor(),[o,n]=C.useState(""),i=R(),m=b.useComponentsContext(),h=b.useExtension(S),r=b.useExtensionState(S,{selector:g=>g.aiMenuState!=="closed"?g.aiMenuState.status:"closed"}),{items:s}=e,l=C.useMemo(()=>{let g=[];return s?g=s(t,r):g=K(t,r),g.map(k=>({...k,onItemClick:()=>{k.onItemClick(n)}}))},[s,r,t]),d=C.useCallback(async g=>{await h.invokeAI({userPrompt:g,useSelection:t.getSelection()!==void 0})},[h,t]);C.useEffect(()=>{(r==="ai-writing"||r==="user-reviewing"||r==="error")&&n("")},[r]);const c=C.useMemo(()=>r==="thinking"?i.ai_menu.status.thinking:r==="ai-writing"?i.ai_menu.status.editing:r==="error"?i.ai_menu.status.error:i.ai_menu.input_placeholder,[r,i]),f=C.useMemo(()=>{if(r==="thinking"||r==="ai-writing")return u.jsx(m.SuggestionMenu.Loader,{className:"bn-suggestion-menu-loader bn-combobox-right-section"});if(r==="error")return u.jsx("div",{className:"bn-combobox-right-section bn-combobox-error",children:u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",fill:"currentColor",children:u.jsx("path",{d:"M480-280q17 0 28.5-11.5T520-320q0-17-11.5-28.5T480-360q-17 0-28.5 11.5T440-320q0 17 11.5 28.5T480-280Zm0-160q17 0 28.5-11.5T520-480v-160q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640v160q0 17 11.5 28.5T480-440Zm0 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"})})})},[m,r]);return u.jsx(W,{onManualPromptSubmit:e.onManualPromptSubmit||d,items:l,promptText:o,onPromptTextChange:n,placeholder:c,disabled:r==="thinking"||r==="ai-writing",icon:u.jsx("div",{className:"bn-combobox-icon",children:u.jsx(q,{})}),rightSection:f})},xe=e=>{const t=b.useBlockNoteEditor(),o=b.useExtension(S),n=b.useExtensionState(S,{editor:t,selector:r=>r.aiMenuState}),i=n==="closed"?void 0:n.blockId,m=C.useMemo(()=>{var r,s,l,d;return{...e.floatingUIOptions,useFloatingOptions:{open:n!=="closed",placement:"bottom",middleware:[j.offset(10),j.flip(),j.size({apply({rects:c,elements:f}){Object.assign(f.floating.style,{width:`${c.reference.width}px`})}})],onOpenChange:c=>{c||n==="closed"||(n.status==="user-input"?o.closeAIMenu():(n.status==="user-reviewing"||n.status==="error")&&o.rejectChanges())},whileElementsMounted(c,f,g){return j.autoUpdate(c,f,g,{animationFrame:!0})},...(r=e.floatingUIOptions)==null?void 0:r.useFloatingOptions},useDismissProps:{enabled:n==="closed"||n.status==="user-input",outsidePress:c=>{if(c.target instanceof Element){const f=c.target.closest(".bn-block");f&&f.getAttribute("data-id")===i&&o.closeAIMenu()}return!0},...(s=e.floatingUIOptions)==null?void 0:s.useDismissProps},elementProps:{style:{zIndex:100},...(l=e.floatingUIOptions)==null?void 0:l.elementProps},focusManagerProps:{disabled:!1,getInsideElements:()=>t.domElement?[t.domElement]:[],...(d=e.floatingUIOptions)==null?void 0:d.focusManagerProps}}},[o,n,i,e.floatingUIOptions,t.domElement]),h=e.aiMenu||$;return u.jsx(b.BlockPopover,{blockId:i,...m,children:n!=="closed"&&u.jsx(h,{})})},ye=()=>{const e=R(),t=b.useComponentsContext(),o=b.useBlockNoteEditor(),n=b.useExtension(S),i=b.useExtension(I.FormattingToolbarExtension),m=()=>{const h=o.getSelection();if(!h)throw new Error("No selection");const r=h.blocks[h.blocks.length-1].id;n.openAIMenuAtBlock(r),i.store.setState(!1)};return o.isEditable?u.jsx(t.Generic.Toolbar.Button,{className:"bn-button",label:e.formatting_toolbar.ai.tooltip,mainTooltip:e.formatting_toolbar.ai.tooltip,icon:u.jsx(q,{}),onClick:m}):null},Ie={AI:q};function ke(e){const t=e.getExtension(S);return t?[{key:"ai",onItemClick:()=>{const n=e.getTextCursorPosition();n.block.content&&Array.isArray(n.block.content)&&n.block.content.length===0&&n.prevBlock?t.openAIMenuAtBlock(n.prevBlock.id):t.openAIMenuAtBlock(n.block.id)},...a.getAIDictionary(e).slash_menu.ai,icon:u.jsx(Ie.AI,{})}]:[]}exports.ClientSideTransport=a.ClientSideTransport;exports.PROVIDER_OVERRIDES=a.PROVIDER_OVERRIDES;exports.StreamToolExecutor=a.StreamToolExecutor;exports._getApplySuggestionsTr=a.getApplySuggestionsTr;exports.aiDocumentFormats=a.aiDocumentFormats;exports.buildAIRequest=a.buildAIRequest;exports.createStreamToolsArraySchema=a.createStreamToolsArraySchema;exports.fetchViaProxy=a.fetchViaProxy;exports.getAIDictionary=a.getAIDictionary;exports.getProviderOverrides=a.getProviderOverrides;exports.injectDocumentStateMessages=a.injectDocumentStateMessages;exports.makeDocumentStateBuilder=a.makeDocumentStateBuilder;exports.objectStreamToOperationsResult=a.objectStreamToOperationsResult;exports.promptHelpers=a.promptHelpers;exports.sendMessageWithAIRequest=a.sendMessageWithAIRequest;exports.setupToolCallStreaming=a.setupToolCallStreaming;exports.streamToolsToToolSet=a.streamToolsToToolSet;exports.toolDefinitionsToToolSet=a.toolDefinitionsToToolSet;exports.toolSetToToolDefinitions=a.toolSetToToolDefinitions;exports.AIExtension=S;exports.AIMenu=$;exports.AIMenuController=xe;exports.AIToolbarButton=ye;exports.PromptSuggestionMenu=W;exports.getAISlashMenuItems=ke;exports.getDefaultAIMenuItems=K;exports.useAIDictionary=R;
|
|
2
|
-
//# sourceMappingURL=blocknote-xl-ai.cjs.map
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./server-Ct45EOTu.cjs`);let t=require(`@ai-sdk/react`),n=require(`@blocknote/core`),r=require(`@blocknote/core/extensions`),i=require(`@handlewithcare/prosemirror-suggest-changes`),a=require(`prosemirror-model`),o=require(`prosemirror-state`),s=require(`prosemirror-tables`),c=require(`prosemirror-view`),l=require(`y-prosemirror`),u=require(`@blocknote/react`),d=require(`react`),f=require(`react-icons/ri`),p=require(`react/jsx-runtime`),m=require(`@floating-ui/react`);var h=new o.PluginKey(`blocknote-agent-cursor`);function g(e){return new o.Plugin({key:h,view:e=>({}),state:{init:()=>({selection:void 0}),apply:(e,t)=>{let n=e.getMeta(`aiAgent`);return n?{selection:n.selection}:{selection:void 0}}},props:{decorations:t=>{let{doc:n}=t,{selection:r}=h.getState(t),i=[];if(!r)return c.DecorationSet.create(n,[]);i.push(c.Decoration.widget(r.head,()=>_(e),{key:`agent-cursor`,side:10}));let a=Math.min(r.anchor,r.head),o=Math.max(r.anchor,r.head);return i.push(c.Decoration.inline(a,o,(0,l.defaultSelectionBuilder)(e),{inclusiveEnd:!0,inclusiveStart:!1})),c.DecorationSet.create(n,i)}}})}var _=e=>{let t=document.createElement(`span`);t.classList.add(`bn-collaboration-cursor__base`),t.setAttribute(`data-active`,`true`);let n=document.createElement(`span`);n.setAttribute(`contentedEditable`,`false`),n.classList.add(`bn-collaboration-cursor__caret`),n.setAttribute(`style`,`background-color: ${e.color}`);let r=document.createElement(`span`);return r.classList.add(`bn-collaboration-cursor__label`),r.setAttribute(`style`,`background-color: ${e.color}`),r.insertBefore(document.createTextNode(e.name),null),n.insertBefore(r,null),t.insertBefore(document.createTextNode(``),null),t.insertBefore(n,null),t.insertBefore(document.createTextNode(``),null),t},v=new o.PluginKey(`blocknote-ai-plugin`),y=(0,n.createExtension)(({editor:c,options:l})=>{let u=(0,n.createStore)(l??{}),d=(0,n.createStore)({aiMenuState:`closed`}),f,p=!1,m=(0,i.suggestChanges)();return m.props.decorations=void 0,{key:`ai`,options:u,store:d,mount({signal:e}){let t=!1;document.addEventListener(`scroll`,()=>{t&&(p=!1),t=!0},{capture:!0,signal:e}),document.addEventListener(`scrollend`,()=>{t=!1},{capture:!0,signal:e})},prosemirrorPlugins:[new o.Plugin({key:v,filterTransaction:e=>{let t=d.state.aiMenuState;return!(t!==`closed`&&t.status===`ai-writing`&&e.getMeta(s.fixTablesKey)?.fixTables)}}),m,g(l?.agentCursor||{name:`AI`,color:`#8bc6ff`})],openAIMenuAtBlock(e){c.getExtension(r.ShowSelectionExtension)?.showSelection(!0,`aiMenu`),c.isEditable=!1,d.setState({aiMenuState:{blockId:e,status:`user-input`}}),(c.domElement?.querySelector(`[data-node-type="blockContainer"][data-id="${e}"]`))?.scrollIntoView({block:`center`})},closeAIMenu(){d.setState({aiMenuState:`closed`}),f=void 0,c.getExtension(r.ShowSelectionExtension)?.showSelection(!1,`aiMenu`),c.isEditable=!0,c.focus()},acceptChanges(){let e=c.prosemirrorState.doc;c.exec((e,t)=>(0,i.revertSuggestions)(e,e=>{t?.(e.setMeta(`addToHistory`,!1))})),c.exec((t,n)=>{let r=t.tr;return r.replace(0,r.doc.content.size,new a.Slice(a.Fragment.from(e),0,0)),(0,i.applySuggestions)(t.apply(r),e=>{n?.(r.replace(0,r.doc.content.size,new a.Slice(a.Fragment.from(e.doc),0,0)))})}),c.getExtension(r.ForkYDocExtension)?.merge({keepChanges:!0}),this.closeAIMenu()},rejectChanges(){c.exec((e,t)=>(0,i.revertSuggestions)(e,e=>{t?.(e.setMeta(`addToHistory`,!1))})),c.getExtension(r.ForkYDocExtension)?.merge({keepChanges:!1}),this.closeAIMenu()},async abort(e){let{aiMenuState:t}=d.state;if(t===`closed`||!f||t.status!==`thinking`&&t.status!==`ai-writing`)return;let n=f.chat;f.abortController.abort(e),await n.stop()},async retry(){let{aiMenuState:e}=d.state;if(e===`closed`||e.status!==`error`||!f)throw Error(`retry() is only valid when a previous response failed`);return f?.chat.status===`error`?this.invokeAI({...f.previousRequestOptions,userPrompt:`An error occured in the previous request. Please retry to accomplish the last user prompt.`}):this.invokeAI({...f.previousRequestOptions,userPrompt:`An error occured while executing the previous tool call. Please retry to accomplish the last user prompt.`})},setAIResponseStatus(e){let t=d.state.aiMenuState;if(t!==`closed`)if(e===`ai-writing`&&c.getExtension(r.ShowSelectionExtension)?.showSelection(!1,`aiMenu`),typeof e==`object`){if(e.status!==`error`)throw new n.UnreachableCaseError(e.status);this.store.setState({aiMenuState:{status:e.status,error:e.error,blockId:t.blockId}})}else this.store.setState({aiMenuState:{status:e,blockId:t.blockId}})},async callLLM(e){return this.invokeAI(e)},async invokeAI(i){this.setAIResponseStatus(`thinking`),c.getExtension(r.ForkYDocExtension)?.fork();try{let r=new AbortController;f?(f.previousRequestOptions=i,f.abortController=r):f={previousRequestOptions:i,chat:i.chatProvider?.()||this.options.state.chatProvider?.()||new t.Chat({sendAutomaticallyWhen:()=>!1,transport:i.transport||this.options.state.transport}),abortController:r};let a=f.chat;i={...u.state,...i};let o=await e.y({editor:c,useSelection:i.useSelection,deleteEmptyCursorBlock:i.deleteEmptyCursorBlock,streamToolsProvider:i.streamToolsProvider??this.options.state.streamToolsProvider,documentStateBuilder:i.documentStateBuilder??this.options.state.documentStateBuilder,onBlockUpdated:e=>{let t=d.state.aiMenuState,r=t===`closed`?void 0:t;if(!r||r.status!==`ai-writing`)return;let i=(0,n.getNodeById)(e,c.prosemirrorState.doc);i&&(d.setState({aiMenuState:{blockId:e,status:`ai-writing`}}),p&&c.prosemirrorView.domAtPos(i.posBeforeNode+1).node.scrollIntoView({block:`center`}))},onStart:()=>{p=!0,this.setAIResponseStatus(`ai-writing`),o.emptyCursorBlockToDelete&&o.editor.getBlock(o.emptyCursorBlockToDelete)&&o.editor.removeBlocks([o.emptyCursorBlockToDelete])}}),s=await e.s(a,o,{role:`user`,parts:[{type:`text`,text:i.userPrompt}]},i.chatRequestOptions||this.options.state.chatRequestOptions,f.abortController.signal);s.ok&&a.status!==`error`||r.signal.aborted?this.setAIResponseStatus(`user-reviewing`):(console.warn(`Error calling LLM`,{result:s,chatStatus:a.status,chatError:a.error}),this.setAIResponseStatus({status:`error`,error:s.ok?a.error:s.error}))}catch(e){this.setAIResponseStatus({status:`error`,error:e}),console.error(`Unexpected error calling LLM`,e,f?.chat.messages)}}}});function b(){return e.n((0,u.useBlockNoteContext)().editor)}var x=e=>{let t=(0,u.useComponentsContext)(),{onManualPromptSubmit:i,promptText:a,onPromptTextChange:o,disabled:s}=e,[c,l]=(0,d.useState)(``),f=a||c,m=(0,d.useCallback)(async e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&i(f)},[f,i]),h=(0,d.useCallback)(e=>{let t=e.currentTarget.value;o&&o(t),a===void 0&&l(t)},[o,l,a]),g=(0,d.useMemo)(()=>(0,r.filterSuggestionItems)(e.items,f),[f,e.items]),{selectedIndex:_,setSelectedIndex:v,handler:y}=(0,u.useSuggestionMenuKeyboardHandler)(g,e=>e.onItemClick()),b=g.length>0&&_>=0&&_<g.length?`bn-suggestion-menu-item-${_}`:void 0,x=(0,d.useCallback)(e=>{e.key===`Enter`&&!e.nativeEvent.isComposing?g.length>0?y(e):m(e):y(e)},[m,y,g.length]);(0,d.useEffect)(()=>{v(0)},[f,v]);let S=(0,d.useRef)(null),C=(0,d.useRef)(s);return(0,d.useEffect)(()=>{S.current&&C.current&&!s&&S.current.focus(),s&&(C.current=!0)},[s]),(0,p.jsxs)(`div`,{className:`bn-combobox`,children:[(0,p.jsx)(t.Generic.Form.Root,{children:(0,p.jsx)(t.Generic.Form.TextInput,{ref:S,className:`bn-combobox-input`,name:`ai-prompt`,variant:`large`,icon:e.icon,value:f||``,placeholder:e.placeholder,disabled:e.disabled,onKeyDown:x,onChange:h,autoComplete:`off`,rightSection:e.rightSection,"aria-activedescendant":b})}),g.length>0&&(0,p.jsx)(t.SuggestionMenu.Root,{className:`bn-combobox-items`,id:`ai-suggestion-menu`,children:g.map((e,r)=>(0,p.jsx)(t.SuggestionMenu.Item,{className:(0,n.mergeCSSClasses)(`bn-suggestion-menu-item`,e.size===`small`?`bn-suggestion-menu-item-small`:``),id:`bn-suggestion-menu-item-${r}`,isSelected:r===_,onClick:e.onItemClick,item:e},e.title))})]})};function S(t){let n=e.n(t),r=t.getExtension(y);return r?[{key:`continue_writing`,title:n.ai_default_commands.continue_writing.title,aliases:n.ai_default_commands.continue_writing.aliases,icon:(0,p.jsx)(f.RiBallPenLine,{size:18}),onItemClick:async()=>{await r.invokeAI({userPrompt:`Continue writing at the current cursor position related to the previous text. Add multiple blocks if needed. If the document looks like a template / draft, follow the template. Be extensive if needed.`,streamToolsProvider:e.i.html.getStreamToolsProvider({defaultStreamTools:{add:!0,delete:!1,update:!1}})})},size:`small`},{key:`summarize`,title:n.ai_default_commands.summarize.title,aliases:n.ai_default_commands.summarize.aliases,icon:(0,p.jsx)(f.RiTextWrap,{size:18}),onItemClick:async()=>{await r.invokeAI({userPrompt:`Summarize`,streamToolsProvider:e.i.html.getStreamToolsProvider({defaultStreamTools:{add:!0,delete:!1,update:!1}})})},size:`small`},{key:`action_items`,title:n.ai_default_commands.add_action_items.title,aliases:n.ai_default_commands.add_action_items.aliases,icon:(0,p.jsx)(f.RiListCheck3,{size:18}),onItemClick:async()=>{await r.invokeAI({userPrompt:`Add action items`,streamToolsProvider:e.i.html.getStreamToolsProvider({defaultStreamTools:{add:!0,delete:!1,update:!1}})})},size:`small`},{key:`write_anything`,title:n.ai_default_commands.write_anything.title,aliases:n.ai_default_commands.write_anything.aliases,icon:(0,p.jsx)(f.RiBallPenLine,{size:18}),onItemClick:e=>{e(n.ai_default_commands.write_anything.prompt_placeholder)},size:`small`}]:[]}function C(t){let n=e.n(t),r=t.getExtension(y);return r?[{key:`improve_writing`,title:n.ai_default_commands.improve_writing.title,aliases:n.ai_default_commands.improve_writing.aliases,icon:(0,p.jsx)(f.RiText,{size:18}),onItemClick:async()=>{await r.invokeAI({useSelection:!0,userPrompt:`Improve writing`,streamToolsProvider:e.i.html.getStreamToolsProvider({defaultStreamTools:{add:!1,delete:!1,update:!0}})})},size:`small`},{key:`fix_spelling`,title:n.ai_default_commands.fix_spelling.title,aliases:n.ai_default_commands.fix_spelling.aliases,icon:(0,p.jsx)(f.RiCheckLine,{size:18}),onItemClick:async()=>{await r.invokeAI({useSelection:!0,userPrompt:`Fix spelling`,streamToolsProvider:e.i.html.getStreamToolsProvider({defaultStreamTools:{add:!1,delete:!1,update:!0}})})},size:`small`},{key:`translate`,title:n.ai_default_commands.translate.title,aliases:n.ai_default_commands.translate.aliases,icon:(0,p.jsx)(f.RiEarthLine,{size:18}),onItemClick:e=>{e(n.ai_default_commands.translate.prompt_placeholder)},size:`small`},{key:`simplify`,title:n.ai_default_commands.simplify.title,aliases:n.ai_default_commands.simplify.aliases,icon:(0,p.jsx)(f.RiMagicLine,{size:18}),onItemClick:async()=>{await r.invokeAI({useSelection:!0,userPrompt:`Simplify`,streamToolsProvider:e.i.html.getStreamToolsProvider({defaultStreamTools:{add:!1,delete:!1,update:!0}})})},size:`small`}]:[]}function w(t){let n=e.n(t),r=t.getExtension(y);return r?[{key:`accept`,title:n.ai_menu.actions.accept.title,aliases:n.ai_menu.actions.accept.aliases,icon:(0,p.jsx)(f.RiCheckFill,{size:18}),onItemClick:()=>{r.acceptChanges()},size:`small`},{key:`revert`,title:n.ai_menu.actions.revert.title,aliases:n.ai_menu.actions.revert.aliases,icon:(0,p.jsx)(f.RiArrowGoBackFill,{size:18}),onItemClick:()=>{r.rejectChanges()},size:`small`}]:[]}function T(t){let n=e.n(t),r=t.getExtension(y);return r?[{key:`retry`,title:n.ai_menu.actions.retry.title,aliases:n.ai_menu.actions.retry.aliases,icon:(0,p.jsx)(f.RiLoopLeftFill,{size:18}),onItemClick:async()=>{await r.retry()},size:`small`},{key:`cancel`,title:n.ai_menu.actions.cancel.title,aliases:n.ai_menu.actions.cancel.aliases,icon:(0,p.jsx)(f.RiArrowGoBackFill,{size:18}),onItemClick:()=>{r.rejectChanges()},size:`small`}]:[]}function E(e,t){return t===`user-input`?e.getSelection()?C(e):S(e):t===`user-reviewing`?w(e):t===`error`?T(e):[]}var D=e=>{let t=(0,u.useBlockNoteEditor)(),[n,r]=(0,d.useState)(``),i=b(),a=(0,u.useComponentsContext)(),o=(0,u.useExtension)(y),s=(0,u.useExtensionState)(y,{selector:e=>e.aiMenuState===`closed`?`closed`:e.aiMenuState.status}),{items:c}=e,l=(0,d.useMemo)(()=>{let e=[];return e=c?c(t,s):E(t,s),e.map(e=>({...e,onItemClick:()=>{e.onItemClick(r)}}))},[c,s,t]),m=(0,d.useCallback)(async e=>{await o.invokeAI({userPrompt:e,useSelection:t.getSelection()!==void 0})},[o,t]);(0,d.useEffect)(()=>{(s===`ai-writing`||s===`user-reviewing`||s===`error`)&&r(``)},[s]);let h=(0,d.useMemo)(()=>s===`thinking`?i.ai_menu.status.thinking:s===`ai-writing`?i.ai_menu.status.editing:s===`error`?i.ai_menu.status.error:i.ai_menu.input_placeholder,[s,i]),g=(0,d.useMemo)(()=>{if(s===`thinking`||s===`ai-writing`)return(0,p.jsx)(a.SuggestionMenu.Loader,{className:`bn-suggestion-menu-loader bn-combobox-right-section`});if(s===`error`)return(0,p.jsx)(`div`,{className:`bn-combobox-right-section bn-combobox-error`,children:(0,p.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,height:`1em`,viewBox:`0 -960 960 960`,width:`1em`,fill:`currentColor`,children:(0,p.jsx)(`path`,{d:`M480-280q17 0 28.5-11.5T520-320q0-17-11.5-28.5T480-360q-17 0-28.5 11.5T440-320q0 17 11.5 28.5T480-280Zm0-160q17 0 28.5-11.5T520-480v-160q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640v160q0 17 11.5 28.5T480-440Zm0 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z`})})})},[a,s]);return(0,p.jsx)(x,{onManualPromptSubmit:e.onManualPromptSubmit||m,items:l,promptText:n,onPromptTextChange:r,placeholder:h,disabled:s===`thinking`||s===`ai-writing`,icon:(0,p.jsx)(`div`,{className:`bn-combobox-icon`,children:(0,p.jsx)(f.RiSparkling2Fill,{})}),rightSection:g})},O=e=>{let t=(0,u.useBlockNoteEditor)(),n=(0,u.useExtension)(y),r=(0,u.useExtensionState)(y,{editor:t,selector:e=>e.aiMenuState}),i=r===`closed`?void 0:r.blockId,a=(0,d.useMemo)(()=>({...e.floatingUIOptions,useFloatingOptions:{open:r!==`closed`,placement:`bottom`,middleware:[(0,m.offset)(10),(0,m.flip)(),(0,m.size)({apply({rects:e,elements:t}){Object.assign(t.floating.style,{width:`${e.reference.width}px`})}})],onOpenChange:e=>{e||r===`closed`||(r.status===`user-input`?n.closeAIMenu():(r.status===`user-reviewing`||r.status===`error`)&&n.rejectChanges())},whileElementsMounted(e,t,n){return(0,m.autoUpdate)(e,t,n,{animationFrame:!0})},...e.floatingUIOptions?.useFloatingOptions},useDismissProps:{enabled:r===`closed`||r.status===`user-input`,outsidePress:e=>{if(e.target instanceof Element){let t=e.target.closest(`.bn-block`);t&&t.getAttribute(`data-id`)===i&&n.closeAIMenu()}return!0},...e.floatingUIOptions?.useDismissProps},elementProps:{style:{zIndex:100},...e.floatingUIOptions?.elementProps},focusManagerProps:{disabled:!1,getInsideElements:()=>t.domElement?[t.domElement]:[],...e.floatingUIOptions?.focusManagerProps}}),[n,r,i,e.floatingUIOptions,t.domElement]),o=e.aiMenu||D;return(0,p.jsx)(u.BlockPopover,{blockId:i,...a,children:r!==`closed`&&(0,p.jsx)(o,{})})},k=()=>{let e=b(),t=(0,u.useComponentsContext)(),n=(0,u.useBlockNoteEditor)(),i=(0,u.useExtension)(y),a=(0,u.useExtension)(r.FormattingToolbarExtension);return n.isEditable?(0,p.jsx)(t.Generic.Toolbar.Button,{className:`bn-button`,label:e.formatting_toolbar.ai.tooltip,mainTooltip:e.formatting_toolbar.ai.tooltip,icon:(0,p.jsx)(f.RiSparkling2Fill,{}),onClick:()=>{let e=n.getSelection();if(!e)throw Error(`No selection`);let t=e.blocks[e.blocks.length-1].id;i.openAIMenuAtBlock(t),a.store.setState(!1)}}):null},A={AI:f.RiSparkling2Fill};function j(t){let n=t.getExtension(y);return n?[{key:`ai`,onItemClick:()=>{let e=t.getTextCursorPosition();e.block.content&&Array.isArray(e.block.content)&&e.block.content.length===0&&e.prevBlock?n.openAIMenuAtBlock(e.prevBlock.id):n.openAIMenuAtBlock(e.block.id)},...e.n(t).slash_menu.ai,icon:(0,p.jsx)(A.AI,{})}]:[]}exports.AIExtension=y,exports.AIMenu=D,exports.AIMenuController=O,exports.AIToolbarButton=k,exports.ClientSideTransport=e.u,exports.PROVIDER_OVERRIDES=e.d,exports.PromptSuggestionMenu=x,exports.StreamToolExecutor=e.g,exports._getApplySuggestionsTr=e.a,exports.aiDocumentFormats=e.i,exports.buildAIRequest=e.y,exports.createStreamToolsArraySchema=e._,exports.fetchViaProxy=e.t,exports.getAIDictionary=e.n,exports.getAISlashMenuItems=j,exports.getDefaultAIMenuItems=E,exports.getProviderOverrides=e.f,exports.injectDocumentStateMessages=e.h,exports.makeDocumentStateBuilder=e.o,exports.objectStreamToOperationsResult=e.l,exports.promptHelpers=e.r,exports.sendMessageWithAIRequest=e.s,exports.setupToolCallStreaming=e.c,exports.streamToolsToToolSet=e.v,exports.toolDefinitionsToToolSet=e.p,exports.toolSetToToolDefinitions=e.m,exports.useAIDictionary=b;
|
|
2
|
+
//# sourceMappingURL=blocknote-xl-ai.cjs.map
|