@blocknote/xl-ai 0.33.0 → 0.34.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.
- package/dist/blocknote-xl-ai.cjs +4 -4
- package/dist/blocknote-xl-ai.cjs.map +1 -1
- package/dist/blocknote-xl-ai.js +110 -120
- package/dist/blocknote-xl-ai.js.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +8 -8
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{Add heading (h1) and code block_1_4ed20a68d545bbcac0a6974406d9b1b1.json → Add heading (h1) and code block_1_2f82a8f66db1e848b6fcf11cf3b40597.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{add a list (end)_1_a8c0f5688c447808ea40e16816bc9d88.json → add a list (end)_1_c2d9df5eea16a2823b16315808698634.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{add a new paragraph (empty doc)_1_4200cbf42b5dd56e2fb7c1dc4c0e5c95.json → add a new paragraph (empty doc)_1_4a415aef98742a73f1d8e76b31b48fd9.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{add a new paragraph (end)_1_3cecc2859589d59d7b2a73b271a02ebb.json → add a new paragraph (end)_1_c3ac403267365e72e1acdeaf703272ac.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{add a new paragraph (start)_1_0b6e5ba7c365aa004ab09915db4747d2.json → add a new paragraph (start)_1_a7deaebd8a05b0eacd438ef4772a84b0.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{Add heading (h1) and code block_1_f09fb671c15594eba4367376e1de7404.json → Add heading (h1) and code block_1_c9d02980acbb81e12922c758580ae086.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{add a list (end)_1_9ca128e303da5f76048c82f2c1928b5f.json → add a list (end)_1_898ab571e824bb2cf7bfd3a4ec769cc4.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{add a new paragraph (empty doc)_1_fedaaecc10d6ddf733d85168d2167795.json → add a new paragraph (empty doc)_1_13f4377aac43e7a42d2e0fbe377b093f.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{add a new paragraph (end)_1_fe965ef7a99beb3acc090a9f597b4279.json → add a new paragraph (end)_1_41b6ad49c80f708e02a289f0a978d10f.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{add a new paragraph (start)_1_232100784a2397a470c08d82001cb7fb.json → add a new paragraph (start)_1_ba9d1b82c2e1653cbfad19e72d157d19.json } +2 -2
- 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_da4995473884c05440ca118c6ae41453.json → Add heading (h1) and code block_1_d7a1ca07ded19de08a51f21236c2d68e.json } +2 -2
- 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_bcc7319416c9b14368ea5ad861f9b722.json → add a list (end)_1_ea8fe6c45678a567e7bfc9a4f9ff9d7e.json } +2 -2
- 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_8fd66df698028c81b94d9c3da3f48565.json → add a new paragraph (empty doc)_1_be406ee8435789d49b4de3a2952366bc.json } +2 -2
- 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_1df9f2bee04498ef092f332ebce02289.json → add a new paragraph (end)_1_0f618344844192bfd9fca2e00cb8ef3a.json } +2 -2
- 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_ddea32bf65559924075cf5a378ff52a9.json → add a new paragraph (start)_1_a171c162d38c9ae40b2a22be3ef913b9.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{Add heading (h1) and code block_1_411b9303baf0445a2b3d22af986dcbd7.json → Add heading (h1) and code block_1_4490bc6c485a737b4584207976c00303.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{add a list (end)_1_b62f9dcc3af6272c847eb867f28464e4.json → add a list (end)_1_7a96610c4bbc6c8f141e4addbc2106bf.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{add a new paragraph (empty doc)_1_e3538aed67ed181c709f2c76ebd3b88c.json → add a new paragraph (empty doc)_1_44de7bf7410dad3111bbadfa384b3806.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{add a new paragraph (end)_1_4da2dc377fad46f51e531f5cb2594b48.json → add a new paragraph (end)_1_b6706fca4145b801d7884d53dd16458f.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{add a new paragraph (start)_1_9a1739085965869c82a4ab025a9b426c.json → add a new paragraph (start)_1_f2e4502c4c5fb89e3ab56801c4e2ebb1.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/Add heading (h1) and code block_1_bde67ab7834e0e85453474bfec5d6899.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/add a list (end)_1_87f55153eeb60ab71bfc14cc2fd2f957.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/add a new paragraph (empty doc)_1_51ba760ef2fb18f3445641c82a09fabc.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/add a new paragraph (end)_1_8e7994f92b21645243d6012cbefb10aa.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/add a new paragraph (start)_1_13e966493243f338888f862532e11055.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{add and update paragraph_1_a16755b57abd9123bc8d138ece2fc206.json → add and update paragraph_1_a6c32f94ed9ef180b605d3e529b66f0a.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{add paragraph and update selection_1_9d3466520f605a356f2c31458954e816.json → add paragraph and update selection_1_da1b9a436aabf66b488fd5f147c006d6.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{add and update paragraph_1_051b564433dad882d26853a2d2e41841.json → add and update paragraph_1_b747e1a9db81d87169dbb057c80a400e.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{add paragraph and update selection_1_0ca431ee9c56812e10198e60552a536f.json → add paragraph and update selection_1_1441637b8dce16dc9c48df2cf6507d9b.json } +2 -2
- 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_8ef78aa1880fd8536fa49acb127f51c0.json → add and update paragraph_1_7252c232ad6e528961ee8cb6825e1ced.json } +2 -2
- 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_04f9e76ff73eff953288564e5385dbd4.json → add paragraph and update selection_1_ce0574730306ae367b09cefba52e1ee5.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{add and update paragraph_1_e9e8ca04b228ebbec6f48d24c147fbcf.json → add and update paragraph_1_304d3249edb4213cd5b98862492557f2.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{add paragraph and update selection_1_f5cd402d603bead3d759ebb5485f39c3.json → add paragraph and update selection_1_58bb195c54dff663752ffdd8e6b50bf0.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/add and update paragraph_1_f7403010a908af399a5228468b304f47.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/add paragraph and update selection_1_495ea67d9ad44b58172da3db145b3a10.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Delete/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{delete first block_1_a4ec61146ba0a517742770cb5843201f.json → delete first block_1_278e7fb63bd96fb65d7e2b2a6c215e24.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Delete/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{delete first block_1_ee24300ba2c8986f54c02b0d2aec9691.json → delete first block_1_b8070bd231a475d9df5bbb9da081cf01.json } +2 -2
- 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_21ad45e4791e6ce60e52c20228c507ff.json → delete first block_1_5190aca5ac8dc8a51ad5b5ab8277fc21.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Delete/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{delete first block_1_002ed2fb069e97008c626fe8c2d43637.json → delete first block_1_9b505e5406bea6b6aa0194536538eed7.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Delete/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/delete first block_1_4fd26859e74455f20838c0acf2b72429.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{drop mark and link and change text within mark_1_a97a8a61e45a5cfa1f37771aefbf06ba.json → drop mark and link and change text within mark_1_8978afc5c34284715a8914c2fd570f93.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{drop mark and link_1_80d39d8c2f69d28a6aec0dee64eb7b4f.json → drop mark and link_1_938010771c761a751ffbec3118e90f37.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{modify nested content_1_64d59c27de629179d00d268836aebcba.json → modify nested content_1_671661bffc93e10ce475a7a35f15d754.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{modify parent content_1_7cb863416d6d953446640251160e084e.json → modify parent content_1_3be350bb2a881627e6d2c9bf1c977133.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{plain source block, add mention_1_c6025cf7f6efc3b57f721752b1f49801.json → plain source block, add mention_1_fbbe189dec37c71e5cfc78fa72504cd6.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{standard update_1_b3b73d97f68d26aba18541b8c809ec4d.json → standard update_1_fa30387ecfa9d5ca59f612c7ab97f4bd.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{styles + ic in source block, remove mark_1_f6a509381d62c4242864af576bb7ba61.json → styles + ic in source block, remove mark_1_db38bde293870f2bef2303384e4e0a55.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{styles + ic in source block, remove mention_1_61539d923364c797cda8519b7d6dbb77.json → styles + ic in source block, remove mention_1_2b37d06351765e430fa35e5ca5c63dec.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{styles + ic in source block, replace content_1_a73907775c98b6c395eac24591e7f1d4.json → styles + ic in source block, replace content_1_7a40338400651cdf9b96bdf8da120da9.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{styles + ic in source block, update mention prop_1_1821b0f5da6b0bdb28f9444c6eaca222.json → styles + ic in source block, update mention prop_1_2d883e86ea71cfb987a22379a3edfa77.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{styles + ic in source block, update text_1_82f2d8a07824544fad31d34c8a554af1.json → styles + ic in source block, update text_1_3ccdc93a62d16ec0bcf50be253c1dc56.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{styles + ic in target block, add mark (paragraph)_1_c8bc122a4cb48783ca677fc4aa6cd947.json → styles + ic in target block, add mark (paragraph)_1_809e0216515551c13573267a351ba535.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{styles + ic in target block, add mark (word)_1_686bfcd92e4eb65462c1811ad4a3976d.json → styles + ic in target block, add mark (word)_1_12dba322e1c862453710164ab8dacd01.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{translate selection_1_2968b738a7996331d8faf2692d652c3c.json → translate selection_1_e8c60e9f841b4ab0a3e3542f57873ecf.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{turn paragraphs into list_1_dd8e963f842a261deec745e8d4608bfd.json → turn paragraphs into list_1_0301237447d5b4413e7dadcad3480eb7.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{update block type and content_1_06943ba0bda62a61f058ba07379ab4b7.json → update block type and content_1_9206839a16fcfab9cdcdd9e45f09f1da.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/{update block type_1_9e53c774c99f178f06b3c7b3608d1605.json → update block type_1_16071edfe34f45ccfeb3bb4b023da531.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{drop mark and link and change text within mark_1_2b911dce06e556a512fa22d1a0042b5a.json → drop mark and link and change text within mark_1_fe18c50fd2feadd6457384d8fb8944ec.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{drop mark and link_1_f7d042c6ddd42b02098b813fe6e2da2b.json → drop mark and link_1_221aeca7fef5f125b53481e1b86ef472.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{modify nested content_1_0cbaaf87b0c6b588f7d7e21f72ed7a7c.json → modify nested content_1_556624e3ee02680707ba62c186d62e84.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{modify parent content_1_d190a41cfce34eb5362468031cb608fe.json → modify parent content_1_c0bdc581c11c643bf23b9b9db2d63c81.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{plain source block, add mention_1_963338caea5317fbaa588fed459f0895.json → plain source block, add mention_1_0864d889b31cae8e316f6a78ef61df7d.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{standard update_1_da09ee8bda5dc347edc748b59bc3bb16.json → standard update_1_f80b18afddb894d5ef20c2e5b40d1735.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{styles + ic in source block, remove mark_1_90482aba878618976330fda1af8f6766.json → styles + ic in source block, remove mark_1_de6fb747b4d41b8d888fabe55320091c.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{styles + ic in source block, remove mention_1_5c149679babf73b41810f291fcb4d558.json → styles + ic in source block, remove mention_1_c0ff836d1dce7a2f6e6f86f220640315.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{styles + ic in source block, replace content_1_0c9d3ace7da95353a998edbaff79177d.json → styles + ic in source block, replace content_1_da5f1ab6fa91c869e64322937264846f.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{styles + ic in source block, update mention prop_1_57893638a0ceb0edac342346fa706076.json → styles + ic in source block, update mention prop_1_38b3b843f1c225ba4b5fae0ea9fe7d69.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{styles + ic in source block, update text_1_ef01870ca5f4083b4ea345e00d3c52ff.json → styles + ic in source block, update text_1_b5b0d849bf7cfd45920a42b802840eb0.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{styles + ic in target block, add mark (paragraph)_1_ee8107efdf5fd19552a7fff0b08f6657.json → styles + ic in target block, add mark (paragraph)_1_15b8c82decbf30a714f2df977d22c034.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{styles + ic in target block, add mark (word)_1_ca95d8d83853d5deb4765c6768a2563f.json → styles + ic in target block, add mark (word)_1_7b3ed3b4d44c3e948694f0ea709b6a18.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{translate selection_1_674d4ec4b8af2ac528ec90892731f67a.json → translate selection_1_b44a83174a714b0c75c0ae03566175c0.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{turn paragraphs into list_1_1ec910c96203d1d86b7dcce97e352e91.json → turn paragraphs into list_1_0d58195328e2194c6d2466a4ff9f8bc5.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{update block type and content_1_e09825f3b2477a73e86972716897a19e.json → update block type and content_1_25e6f872caa48f5825f7ceb4b0f78655.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/{update block type_1_cf54cfb6c7dfc32b6429ca1a2302a2b6.json → update block type_1_1199a83747eb0f064e1c6badaa3e788d.json } +2 -2
- 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_efeeda50dc4be1869d555c44cc00a5f5.json → drop mark and link and change text within mark_1_5936286917db7874ab151e025d44f0ec.json } +2 -2
- 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_e3ff518cb46e814abe773f4184678323.json → drop mark and link_1_4aa07cf0823d35359854ab671dd8403a.json } +2 -2
- 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_c335661f5c1022666f7905497d4a3189.json → modify nested content_1_f2b4ede7c5fa7fe6f53f0224d9c843e6.json } +2 -2
- 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_73db91187a949699f0fd921ebe60d841.json → modify parent content_1_37be7ebe33cd5e612c15b138aa8e868a.json } +2 -2
- 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_57f7d170977b8d3400a3a1d7182790b0.json → plain source block, add mention_1_3ab6cac43fb1418a242820f5fb741a80.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{standard update_1_67b27460b36b3013a36967448a8522c4.json → standard update_1_45a526f03ac0adef7c3c45cb4cda6d5a.json } +2 -2
- 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_abd6ba31606c51fb682ca64b85af7008.json → styles + ic in source block, remove mark_1_466a1bc182d81c967fcd9dc2d0161046.json } +2 -2
- 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_bcb2fc9b7ec7eb1ae370d9387dc7e505.json → styles + ic in source block, remove mention_1_2b98509c91ffaa3f4b775afdebef2dd1.json } +2 -2
- 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_9e6d5cd399d444173556b9dc0afc3334.json → styles + ic in source block, replace content_1_24ba9ad6b82850e51f9aeb27631974c1.json } +2 -2
- 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_e1d72f9616d34022fba9ea219eb13748.json → styles + ic in source block, update mention prop_1_64f592e51960d717cdbd7aa155ae6196.json } +2 -2
- 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_bd11c0a3efe0e2b04a0133c6ca73a5cd.json → styles + ic in source block, update text_1_9ae98cae168d1714dcdd12abbf4ab7dc.json } +2 -2
- 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_c865fea79947e8f5885f8c7ebc7dd91a.json → styles + ic in target block, add mark (paragraph)_1_42509ec379b9798b007c4481b1b65118.json } +2 -2
- 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_e155e7bf26070976e31928b82bb13fbc.json → styles + ic in target block, add mark (word)_1_4054e8af99647ab39ef82cbd2fa546c9.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{translate selection_1_54ec8515dd6ab214d8b92c5cf4f09529.json → translate selection_1_e16698998bf1a04cb9538d79a1ceff2c.json } +2 -2
- 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_ec7bd4074c354be223256a9d0ab17e64.json → turn paragraphs into list_1_12667c1a7b080c02776120c0a85b9cd9.json } +2 -2
- 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_a935b00dc3276d6713bffbfb1fdf211e.json → update block type and content_1_4f67ef168fbf2021f1b78fb11b22f568.json } +2 -2
- 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_21d1130a166f73bca224130b84ed37c4.json → update block type_1_f14e429b4f85b7586942a94000a44f21.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{drop mark and link and change text within mark_1_8798a9655a7eb7a651bb81f5f811fc60.json → drop mark and link and change text within mark_1_c9e281ea445a93fbc84005fa8a92d07e.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{drop mark and link_1_001ea299cc5ab0754d17884094fa9d86.json → drop mark and link_1_6f06b0c532060f9a0c1c0b2f64f2b6ab.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{modify nested content_1_3b7f9df9f7701d51e2ccf274e5280a7d.json → modify nested content_1_f87724ae16fe199bd8fb1ac207a3ab99.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{modify parent content_1_3b9c9ee90eacd058e510ca1c82cbd554.json → modify parent content_1_85ee68d4daa7ddab518c19afcd02cb44.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{plain source block, add mention_1_2e588074658964fdee8f372a25645e39.json → plain source block, add mention_1_babb54324affa4adb9249cdae14cf222.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{standard update_1_8aa8c7ee6f4c17a92493df542b131069.json → standard update_1_8c6a9aa2df797ab1a789805eb44c20c6.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{styles + ic in source block, remove mark_1_7c37aad8ce27e926dc486960a90f35eb.json → styles + ic in source block, remove mark_1_3308e5066e651a6abeb10e26cd62b8c2.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{styles + ic in source block, remove mention_1_a9fa6b0be7fae1d70499aa6ecfea6704.json → styles + ic in source block, remove mention_1_5b43e33507a6bc64943c2383991ad7d4.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{styles + ic in source block, replace content_1_4d4299b8044479fe9e15a4a168707806.json → styles + ic in source block, replace content_1_b9c728e7fe649e31114138d69a0b69c7.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{styles + ic in source block, update mention prop_1_c6fa894a14f6be81fb568283e4724af9.json → styles + ic in source block, update mention prop_1_6fb8402fb1c0ef42821646b7ae01a6f8.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{styles + ic in source block, update text_1_aa627d12493a30d6fa1bbf6d282b6ecd.json → styles + ic in source block, update text_1_39a7f24d933099914037252cc9e02645.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{styles + ic in target block, add mark (paragraph)_1_711e7638278935cce832085d8cce0abc.json → styles + ic in target block, add mark (paragraph)_1_cecd6722d457eb6bb4b1231e28c61b64.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{styles + ic in target block, add mark (word)_1_739768c550cdc9eb5af10dbacc7c6d22.json → styles + ic in target block, add mark (word)_1_ca614a9ed0162e6f24732e67e6076cb1.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{translate selection_1_83bf8aa261516bf197d1391294bbcb06.json → translate selection_1_1d9ae8d2cabb0ab2d3425b42da65f9aa.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{turn paragraphs into list_1_5aa207db4b8600962363d2352bf0b1c4.json → turn paragraphs into list_1_c329ee96e44a6acec8c490bfe9036c3c.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{update block type and content_1_12e64702225f7eb521a176feffbdde9a.json → update block type and content_1_99c94387729dc443ea9a142027ae75a1.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/{update block type_1_b81e29ddb0de05a668236685bd2df42c.json → update block type_1_9d69f7aa4a1a514ddb293bfae46db69d.json } +2 -2
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/drop mark and link and change text within mark_1_99fc53184b728115e2c9bf977d44addb.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/drop mark and link_1_ec6e45525b18ba57e7669697631ed856.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/modify nested content_1_69e8bfa87ec2c7377f0f3e5bec154a35.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/modify parent content_1_4fa129b1c39dce035ef12c29e733d88f.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/plain source block, add mention_1_110023b0bf33e516b42bee6f23b6a840.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/standard update_1_3ea83b592a9e001f52872db06794772f.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/styles + ic in source block, remove mark_1_6cf3d04771c2ac3bb39f84bda06a167a.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/styles + ic in source block, remove mention_1_b5e611d650819fc89af1f9ccfb59f24e.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/styles + ic in source block, replace content_1_016a76a8b508815af96b7185d6137346.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/styles + ic in source block, update mention prop_1_a6321b1baeca3f0e777cc6f735d39599.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/styles + ic in source block, update text_1_cd61b04f5a5a80de556e7524ab8efa7e.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/styles + ic in target block, add mark (paragraph)_1_dca280088154bf070ef536e89a0570c3.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/styles + ic in target block, add mark (word)_1_2419100d41a8a73ec4a564889d7a57e9.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/translate selection_1_290252f83e798ac47770abfbb9bf6d73.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/turn paragraphs into list_1_8103f7c569fd8326b0ae947eefd7d92d.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/update block type and content_1_282445e6005328e75fc2768da3503c3b.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/update block type_1_f1fcbe3b4b5404a79557569199effbf2.json +15 -0
- package/src/api/formats/html-blocks/tools/index.ts +4 -14
- package/src/testUtil/cases/updateOperationTestCases.ts +1 -1
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/Add heading (h1) and code block_1_91d754a12d792f37fe1483d19a7b4e64.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/add a list (end)_1_1b9c5367195624176c28a1ca3684ebac.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/add a new paragraph (empty doc)_1_bda56d4903fe73aa33304a959057957d.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/add a new paragraph (end)_1_731edbb5fc3b6e4a927978b9e203f336.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/add a new paragraph (start)_1_56f9b395b16c8dc222ce13deb68cd412.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/add and update paragraph_1_2551adfcc4ecd63e37094152b44c1144.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/add paragraph and update selection_1_fc5837fa3ab53d1a511a8092a926d87d.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Delete/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/delete first block_1_af53bf5e53a86669deaae43b9ab27c67.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/drop mark and link and change text within mark_1_f48c2d1d72f4c3514c346629fb7f4d0d.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/drop mark and link_1_c357b571feb374378ba1b288c39b6c31.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/modify nested content_1_782caee9bbb515bfdae481d31ea48e48.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/modify parent content_1_92e8df7af02866607d407a52926d4f52.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/plain source block, add mention_1_69dfced69472e5cf7789a98b3ccbbdd8.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/standard update_1_f5d03fb0433b5e5b912f40dbffd9f462.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/styles + ic in source block, remove mark_1_d0386ebc8dc8350f33c44c2251cd1d3c.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/styles + ic in source block, remove mention_1_83b1ed76da3ba0a764fdc6fb4d25e47a.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/styles + ic in source block, replace content_1_dd48a67d4d41880db75515d0a95a53dc.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/styles + ic in source block, update mention prop_1_e21784bb9948aac3dd70492535dff192.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/styles + ic in source block, update text_1_72b362e3a2e48e9e1d5dad68fc3da63c.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/styles + ic in target block, add mark (paragraph)_1_968bf60fd7c9520b848955d47ea8a568.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/styles + ic in target block, add mark (word)_1_45c3fcc7757ac314a77786102326e125.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/translate selection_1_8cfca4c1847085a8a31be1818346738e.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/turn paragraphs into list_1_2f31610c836b996af773c3856634d5c3.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/update block type and content_1_94cf62e3727b3443984720bc54218659.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/update block type_1_19432d3e11d58717813be52d54eb6edd.json +0 -15
package/dist/blocknote-xl-ai.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Ye=Object.defineProperty;var Ge=(e,t,o)=>t in e?Ye(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var U=(e,t,o)=>Ge(e,typeof t!="symbol"?t+"":t,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("@blocknote/core"),D=require("@blocknote/prosemirror-suggest-changes"),j=require("ai"),q=require("prosemirror-state"),Ke=require("prosemirror-tables"),Xe=require("lodash.isequal"),$=require("prosemirror-model"),C=require("prosemirror-transform"),K=require("prosemirror-changeset"),z=require("prosemirror-view"),Qe=require("y-prosemirror"),y=require("react/jsx-runtime"),B=require("@blocknote/react"),v=require("react"),Ce=require("zustand"),X=require("@floating-ui/react"),Pe=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},et=Pe(Xe),L=Pe(v),ue=e=>{let t;const o=new Set,r=(u,f)=>{const l=typeof u=="function"?u(t):u;if(!Object.is(l,t)){const m=t;t=f??(typeof l!="object"||l===null)?l:Object.assign({},t,l),o.forEach(p=>p(t,m))}},n=()=>t,i={setState:r,getState:n,getInitialState:()=>c,subscribe:u=>(o.add(u),()=>o.delete(u))},c=t=e(r,n,i);return i},de=e=>e?ue(e):ue;function tt(e){const{properties:t,required:o,$defs:r,...n}=e.parameters;return{schema:{type:"object",description:e.description,properties:{type:{type:"string",enum:[e.name]},...t},required:["type",...o??[]],additionalProperties:!1,...n},$defs:r}}function Oe(e){const t=e.map(r=>tt(r)),o={};for(const r of t)for(const n in r.$defs){if(o[n]&&!et.default(o[n],r.$defs[n]))throw new Error(`Duplicate, but different definition for ${n}`);o[n]=r.$defs[n]}return{type:"object",properties:{operations:{type:"array",items:{anyOf:t.map(r=>r.schema)}}},additionalProperties:!1,required:["operations"],$defs:Object.keys(o).length>0?o:void 0}}function ot(e){return new ReadableStream({async start(t){try{for await(const o of e)t.enqueue(o);t.close()}catch(o){t.error(o)}}})}function R(e){if(e.locked)throw new Error("Stream (source) is already locked and cannot be iterated.");const t=e.pipeThrough(new TransformStream);return t[Symbol.asyncIterator]=()=>{if(t.locked)throw new Error("Stream is already locked and cannot be iterated again.");const o=t.getReader();return{async next(){const{done:r,value:n}=await o.read();return r?{done:!0,value:void 0}:{done:!1,value:n}}}},t}function xe(e){return R(ot(e))}async function*rt(e){var n;let t=0,o=!0,r;for await(const s of e)if((n=s.operations)!=null&&n.length){for(let a=t;a<s.operations.length;a++){const i=s.operations[a];r=i,yield{partialOperation:i,isUpdateToPreviousOperation:a===t&&!o,isPossiblyPartial:a===s.operations.length-1},o=!1}t=s.operations.length-1}if(!r)throw new Error("No operations seen");yield{partialOperation:r,isUpdateToPreviousOperation:!0,isPossiblyPartial:!1}}async function*Me(e,t){let o=!1;for await(const r of e){const n=r.operation;n.ok?(yield{operation:n.value,isUpdateToPreviousOperation:o?!1:r.isUpdateToPreviousOperation,isPossiblyPartial:r.isPossiblyPartial},o=!1):(o=o||!r.isUpdateToPreviousOperation,t==null||t({...r,operation:n}))}}async function*Be(e,t){for await(const o of e){const r=t.find(s=>s.name===o.partialOperation.type);if(!r){yield{operation:{ok:!1,error:`No matching function for ${o.partialOperation.type}`},isUpdateToPreviousOperation:o.isUpdateToPreviousOperation,isPossiblyPartial:o.isPossiblyPartial};continue}yield{operation:r.validate(o.partialOperation),isUpdateToPreviousOperation:o.isUpdateToPreviousOperation,isPossiblyPartial:o.isPossiblyPartial}}}async function*nt(e,t){const o=Be(e,t);yield*Me(o,n=>{if(!n.isPossiblyPartial)throw new Error("invalid operation: "+n.operation.error)})}async function*st(e,t){const o=Be(e,t);yield*Me(o,n=>{throw new Error("invalid operation: "+n.operation.error)})}async function it(e,t){const{_generateObjectOptions:o,...r}=t;if(o&&("output"in o||"schema"in o))throw new Error("Cannot provide output or schema in _generateObjectOptions");const s={output:"object",schema:j.jsonSchema(Oe(e)),mode:r.model.provider==="mistral.chat"||r.model.provider==="google.generative-ai"?"auto":"tool",...r,...o??{}},a=await j.generateObject(s),i=at(a.object);if(!i.ok)throw new Error(i.error);let c;return{streamObjectResult:void 0,generateObjectResult:a,get operationsSource(){return c||(c=xe(st(i.value,e))),c},async getGeneratedOperations(){return a.object}}}function at(e){if(!e||typeof e!="object"||!("operations"in e)||!Array.isArray(e.operations))return{ok:!1,error:"No operations returned"};const t=e.operations;async function*o(){for(const r of t)yield{partialOperation:r,isUpdateToPreviousOperation:!1,isPossiblyPartial:!1}}return{ok:!0,value:o()}}async function ct(e,t,o=()=>{}){const{_streamObjectOptions:r,...n}=t;if(r&&("output"in r||"schema"in r))throw new Error("Cannot provide output or schema in _streamObjectOptions");const a={output:"object",schema:j.jsonSchema(Oe(e)),mode:n.model.provider==="mistral.chat"||n.model.provider==="google.generative-ai"?"auto":"tool",...n,...t._streamObjectOptions??{}},i=j.streamObject(a);let c;const[u,f]=i.fullStream.tee(),l=(async()=>{let m={operations:[]};const p=R(dt(f));for await(const h of p)h&&typeof h=="object"&&"operations"in h&&(m=h);return m})();return{streamObjectResult:i,generateObjectResult:void 0,get operationsSource(){return c||(c=xe(nt(rt(lt(ut(R(u)),o)),e))),c},async getGeneratedOperations(){return l}}}async function*lt(e,t){let o=!0;for await(const r of e)o&&(t(),o=!1),yield r}function ut(e){return R(e.pipeThrough(new TransformStream({transform(t,o){switch(t.type){case"object":o.enqueue(t.object);break;case"text-delta":case"finish":break;case"error":o.error(t.error);break;default:{const r=t;throw new Error(`Unsupported chunk type: ${r}`)}}}})))}function dt(e){return R(e.pipeThrough(new TransformStream({transform(t,o){switch(t.type){case"object":o.enqueue(t.object);break;case"text-delta":case"finish":break;case"error":break;default:{const r=t;throw new Error(`Unsupported chunk type: ${r}`)}}}})))}function oe(e){return(e.type==="paragraph"||!e.type)&&!e.content||Array.isArray(e.content)&&e.content.length===0}class pt{constructor(t,o,r){this.messages=t,this.llmResult=o,this.streamTools=r}async*applyToolCalls(){let t=this.llmResult.operationsSource;for(const o of this.streamTools)t=o.execute(t);yield*t}async execute(){for await(const t of this.applyToolCalls());}async _logToolCalls(){for await(const t of this.llmResult.operationsSource)console.log(JSON.stringify(t,null,2))}}function ft(e,t,o=!0,r=!0){let n=0,s=e.length;if(o)for(;n<s&&t(e[n]);)n++;if(r)for(;s>n&&t(e[s-1]);)s--;return e.slice(n,s)}function E(e,t){return ft(e,r=>oe(r)&&(t==null?void 0:t.cursorBlockId)!==r.id,(t==null?void 0:t.trimStart)??!1,(t==null?void 0:t.trimEnd)??!0)}function Y(e,t){const o=e.getTextCursorPosition(),r=[];for(const n of t){const s=n.id===o.block.id;r.push({id:n.id,block:n.block}),s&&r.push({cursor:!0})}return r}async function x(e,t){return await Promise.all(e.map(async o=>({id:o.id,block:await t(o)})))}function P(e){return e.flatMap(t=>[{...t,children:[]},...P(t.children)])}function N(e){return e.map(t=>typeof t=="object"&&t&&"id"in t?{...t,id:`${t.id}$`}:t)}async function Ie(e,t){const o=e.getTextCursorPosition().block.id,r=E(e.document,{cursorBlockId:o}),n=await x(P(r),async c=>e.blocksToHTMLLossy([c])),a=Y(e,n).filter(c=>"cursor"in c||!(t.excludeBlockIds||[]).includes(c.id));return{htmlBlocks:N(a)}}async function _e(e,t){const o=await x(P(t.selectedBlocks),async n=>e.blocksToHTMLLossy([n]));return{htmlSelectedBlocks:N(o),htmlDocument:(await x(P(e.document),async n=>e.blocksToHTMLLossy([n]))).map(({block:n})=>({block:n}))}}function mt(e){return[{role:"system",content:"You're manipulating a selected part of a text document using HTML blocks. \n Make sure to follow the json schema provided and always include the trailing $ in ids. \n List items are 1 block with 1 list item each, so block content `<ul><li>item1</li></ul>` is valid, but `<ul><li>item1</li><li>item2</li></ul>` is invalid. We'll merge them automatically.\n This is the selection as an array of html blocks:"},{role:"system",content:JSON.stringify(e.htmlSelectedBlocks)},{role:"system",content:"This is the entire document (INCLUDING the selected text), find the selected text in there to understand the context:"},{role:"system",content:JSON.stringify(e.htmlDocument)},{role:"system",content:"The user asks you to do the following:"},{role:"user",content:e.userPrompt}]}function ht(e){return[{role:"system",content:"You're manipulating a text document using HTML blocks. \n Make sure to follow the json schema provided. When referencing ids they MUST be EXACTLY the same (including the trailing $). \n List items are 1 block with 1 list item each, so block content `<ul><li>item1</li></ul>` is valid, but `<ul><li>item1</li><li>item2</li></ul>` is invalid. We'll merge them automatically.\n For code blocks, you can use the `data-language` attribute on a code block to specify the language.\n This is the document as an array of html blocks (the cursor is BETWEEN two blocks as indicated by cursor: true):"},{role:"system",content:JSON.stringify(e.htmlBlocks)},{role:"system",content:'First, determine what part of the document the user is talking about. You SHOULD probably take cursor info into account if needed.\n EXAMPLE: if user says "below" (without pointing to a specific part of the document) he / she probably indicates the block(s) after the cursor. \n EXAMPLE: If you want to insert content AT the cursor position (UNLESS indicated otherwise by the user), \n then you need `referenceId` to point to the block before the cursor with position `after` (or block below and `before`).\n \n '+(e.isEmptyDocument?"Because the document is empty, first update the empty block before adding new blocks.":"Prefer updating existing blocks over removing and adding (but this also depends on the user's question).")},{role:"system",content:"The user asks you to do the following:"},{role:"user",content:e.userPrompt}]}const yt=async(e,t)=>{const o=E(e.document).length===0;if(t.selectedBlocks){const r=await _e(e,{selectedBlocks:t.selectedBlocks});return t.previousMessages?[...t.previousMessages,{role:"system",content:`After processing the previous response, this is the updated selection.
|
|
1
|
+
"use strict";var Ye=Object.defineProperty;var Ge=(e,t,o)=>t in e?Ye(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var U=(e,t,o)=>Ge(e,typeof t!="symbol"?t+"":t,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("@blocknote/core"),D=require("@blocknote/prosemirror-suggest-changes"),j=require("ai"),q=require("prosemirror-state"),Ke=require("prosemirror-tables"),Xe=require("lodash.isequal"),R=require("prosemirror-model"),C=require("prosemirror-transform"),K=require("prosemirror-changeset"),z=require("prosemirror-view"),Qe=require("y-prosemirror"),y=require("react/jsx-runtime"),B=require("@blocknote/react"),v=require("react"),Ce=require("zustand"),X=require("@floating-ui/react"),Pe=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},et=Pe(Xe),L=Pe(v),ue=e=>{let t;const o=new Set,r=(u,f)=>{const l=typeof u=="function"?u(t):u;if(!Object.is(l,t)){const m=t;t=f??(typeof l!="object"||l===null)?l:Object.assign({},t,l),o.forEach(p=>p(t,m))}},n=()=>t,i={setState:r,getState:n,getInitialState:()=>c,subscribe:u=>(o.add(u),()=>o.delete(u))},c=t=e(r,n,i);return i},de=e=>e?ue(e):ue;function tt(e){const{properties:t,required:o,$defs:r,...n}=e.parameters;return{schema:{type:"object",description:e.description,properties:{type:{type:"string",enum:[e.name]},...t},required:["type",...o??[]],additionalProperties:!1,...n},$defs:r}}function Oe(e){const t=e.map(r=>tt(r)),o={};for(const r of t)for(const n in r.$defs){if(o[n]&&!et.default(o[n],r.$defs[n]))throw new Error(`Duplicate, but different definition for ${n}`);o[n]=r.$defs[n]}return{type:"object",properties:{operations:{type:"array",items:{anyOf:t.map(r=>r.schema)}}},additionalProperties:!1,required:["operations"],$defs:Object.keys(o).length>0?o:void 0}}function ot(e){return new ReadableStream({async start(t){try{for await(const o of e)t.enqueue(o);t.close()}catch(o){t.error(o)}}})}function $(e){if(e.locked)throw new Error("Stream (source) is already locked and cannot be iterated.");const t=e.pipeThrough(new TransformStream);return t[Symbol.asyncIterator]=()=>{if(t.locked)throw new Error("Stream is already locked and cannot be iterated again.");const o=t.getReader();return{async next(){const{done:r,value:n}=await o.read();return r?{done:!0,value:void 0}:{done:!1,value:n}}}},t}function xe(e){return $(ot(e))}async function*rt(e){var n;let t=0,o=!0,r;for await(const s of e)if((n=s.operations)!=null&&n.length){for(let a=t;a<s.operations.length;a++){const i=s.operations[a];r=i,yield{partialOperation:i,isUpdateToPreviousOperation:a===t&&!o,isPossiblyPartial:a===s.operations.length-1},o=!1}t=s.operations.length-1}if(!r)throw new Error("No operations seen");yield{partialOperation:r,isUpdateToPreviousOperation:!0,isPossiblyPartial:!1}}async function*Me(e,t){let o=!1;for await(const r of e){const n=r.operation;n.ok?(yield{operation:n.value,isUpdateToPreviousOperation:o?!1:r.isUpdateToPreviousOperation,isPossiblyPartial:r.isPossiblyPartial},o=!1):(o=o||!r.isUpdateToPreviousOperation,t==null||t({...r,operation:n}))}}async function*Be(e,t){for await(const o of e){const r=t.find(s=>s.name===o.partialOperation.type);if(!r){yield{operation:{ok:!1,error:`No matching function for ${o.partialOperation.type}`},isUpdateToPreviousOperation:o.isUpdateToPreviousOperation,isPossiblyPartial:o.isPossiblyPartial};continue}yield{operation:r.validate(o.partialOperation),isUpdateToPreviousOperation:o.isUpdateToPreviousOperation,isPossiblyPartial:o.isPossiblyPartial}}}async function*nt(e,t){const o=Be(e,t);yield*Me(o,n=>{if(!n.isPossiblyPartial)throw new Error("invalid operation: "+n.operation.error)})}async function*st(e,t){const o=Be(e,t);yield*Me(o,n=>{throw new Error("invalid operation: "+n.operation.error)})}async function it(e,t){const{_generateObjectOptions:o,...r}=t;if(o&&("output"in o||"schema"in o))throw new Error("Cannot provide output or schema in _generateObjectOptions");const s={output:"object",schema:j.jsonSchema(Oe(e)),mode:r.model.provider==="mistral.chat"||r.model.provider==="google.generative-ai"?"auto":"tool",...r,...o??{}},a=await j.generateObject(s),i=at(a.object);if(!i.ok)throw new Error(i.error);let c;return{streamObjectResult:void 0,generateObjectResult:a,get operationsSource(){return c||(c=xe(st(i.value,e))),c},async getGeneratedOperations(){return a.object}}}function at(e){if(!e||typeof e!="object"||!("operations"in e)||!Array.isArray(e.operations))return{ok:!1,error:"No operations returned"};const t=e.operations;async function*o(){for(const r of t)yield{partialOperation:r,isUpdateToPreviousOperation:!1,isPossiblyPartial:!1}}return{ok:!0,value:o()}}async function ct(e,t,o=()=>{}){const{_streamObjectOptions:r,...n}=t;if(r&&("output"in r||"schema"in r))throw new Error("Cannot provide output or schema in _streamObjectOptions");const a={output:"object",schema:j.jsonSchema(Oe(e)),mode:n.model.provider==="mistral.chat"||n.model.provider==="google.generative-ai"?"auto":"tool",...n,...t._streamObjectOptions??{}},i=j.streamObject(a);let c;const[u,f]=i.fullStream.tee(),l=(async()=>{let m={operations:[]};const p=$(dt(f));for await(const h of p)h&&typeof h=="object"&&"operations"in h&&(m=h);return m})();return{streamObjectResult:i,generateObjectResult:void 0,get operationsSource(){return c||(c=xe(nt(rt(lt(ut($(u)),o)),e))),c},async getGeneratedOperations(){return l}}}async function*lt(e,t){let o=!0;for await(const r of e)o&&(t(),o=!1),yield r}function ut(e){return $(e.pipeThrough(new TransformStream({transform(t,o){switch(t.type){case"object":o.enqueue(t.object);break;case"text-delta":case"finish":break;case"error":o.error(t.error);break;default:{const r=t;throw new Error(`Unsupported chunk type: ${r}`)}}}})))}function dt(e){return $(e.pipeThrough(new TransformStream({transform(t,o){switch(t.type){case"object":o.enqueue(t.object);break;case"text-delta":case"finish":break;case"error":break;default:{const r=t;throw new Error(`Unsupported chunk type: ${r}`)}}}})))}function oe(e){return(e.type==="paragraph"||!e.type)&&!e.content||Array.isArray(e.content)&&e.content.length===0}class pt{constructor(t,o,r){this.messages=t,this.llmResult=o,this.streamTools=r}async*applyToolCalls(){let t=this.llmResult.operationsSource;for(const o of this.streamTools)t=o.execute(t);yield*t}async execute(){for await(const t of this.applyToolCalls());}async _logToolCalls(){for await(const t of this.llmResult.operationsSource)console.log(JSON.stringify(t,null,2))}}function ft(e,t,o=!0,r=!0){let n=0,s=e.length;if(o)for(;n<s&&t(e[n]);)n++;if(r)for(;s>n&&t(e[s-1]);)s--;return e.slice(n,s)}function E(e,t){return ft(e,r=>oe(r)&&(t==null?void 0:t.cursorBlockId)!==r.id,(t==null?void 0:t.trimStart)??!1,(t==null?void 0:t.trimEnd)??!0)}function Y(e,t){const o=e.getTextCursorPosition(),r=[];for(const n of t){const s=n.id===o.block.id;r.push({id:n.id,block:n.block}),s&&r.push({cursor:!0})}return r}async function x(e,t){return await Promise.all(e.map(async o=>({id:o.id,block:await t(o)})))}function P(e){return e.flatMap(t=>[{...t,children:[]},...P(t.children)])}function N(e){return e.map(t=>typeof t=="object"&&t&&"id"in t?{...t,id:`${t.id}$`}:t)}async function Ie(e,t){const o=e.getTextCursorPosition().block.id,r=E(e.document,{cursorBlockId:o}),n=await x(P(r),async c=>e.blocksToHTMLLossy([c])),a=Y(e,n).filter(c=>"cursor"in c||!(t.excludeBlockIds||[]).includes(c.id));return{htmlBlocks:N(a)}}async function _e(e,t){const o=await x(P(t.selectedBlocks),async n=>e.blocksToHTMLLossy([n]));return{htmlSelectedBlocks:N(o),htmlDocument:(await x(P(e.document),async n=>e.blocksToHTMLLossy([n]))).map(({block:n})=>({block:n}))}}function mt(e){return[{role:"system",content:"You're manipulating a selected part of a text document using HTML blocks. \n Make sure to follow the json schema provided and always include the trailing $ in ids. \n List items are 1 block with 1 list item each, so block content `<ul><li>item1</li></ul>` is valid, but `<ul><li>item1</li><li>item2</li></ul>` is invalid. We'll merge them automatically.\n This is the selection as an array of html blocks:"},{role:"system",content:JSON.stringify(e.htmlSelectedBlocks)},{role:"system",content:"This is the entire document (INCLUDING the selected text), find the selected text in there to understand the context:"},{role:"system",content:JSON.stringify(e.htmlDocument)},{role:"system",content:"The user asks you to do the following:"},{role:"user",content:e.userPrompt}]}function ht(e){return[{role:"system",content:"You're manipulating a text document using HTML blocks. \n Make sure to follow the json schema provided. When referencing ids they MUST be EXACTLY the same (including the trailing $). \n List items are 1 block with 1 list item each, so block content `<ul><li>item1</li></ul>` is valid, but `<ul><li>item1</li><li>item2</li></ul>` is invalid. We'll merge them automatically.\n For code blocks, you can use the `data-language` attribute on a code block to specify the language.\n This is the document as an array of html blocks (the cursor is BETWEEN two blocks as indicated by cursor: true):"},{role:"system",content:JSON.stringify(e.htmlBlocks)},{role:"system",content:'First, determine what part of the document the user is talking about. You SHOULD probably take cursor info into account if needed.\n EXAMPLE: if user says "below" (without pointing to a specific part of the document) he / she probably indicates the block(s) after the cursor. \n EXAMPLE: If you want to insert content AT the cursor position (UNLESS indicated otherwise by the user), \n then you need `referenceId` to point to the block before the cursor with position `after` (or block below and `before`).\n \n '+(e.isEmptyDocument?"Because the document is empty, first update the empty block before adding new blocks.":"Prefer updating existing blocks over removing and adding (but this also depends on the user's question).")},{role:"system",content:"The user asks you to do the following:"},{role:"user",content:e.userPrompt}]}const yt=async(e,t)=>{const o=E(e.document).length===0;if(t.selectedBlocks){const r=await _e(e,{selectedBlocks:t.selectedBlocks});return t.previousMessages?[...t.previousMessages,{role:"system",content:`After processing the previous response, this is the updated selection.
|
|
2
2
|
Ignore previous documents, you MUST issue operations against this latest version of the document:`},{role:"system",content:JSON.stringify(r.htmlSelectedBlocks)},{role:"system",content:"This is the updated entire document:"},{role:"system",content:JSON.stringify(r.htmlDocument)},{role:"system",content:`You SHOULD use "update" operations to update blocks you added / edited previously
|
|
3
3
|
(unless the user explicitly asks you otherwise to add or delete other blocks).
|
|
4
4
|
|
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
Ignore previous documents, you MUST issue operations against this latest version of the document:`},{role:"system",content:JSON.stringify(r.htmlBlocks)},{role:"system",content:`You SHOULD use "update" operations to update blocks you added / edited previously
|
|
7
7
|
(unless the user explicitly asks you otherwise to add or delete other blocks).
|
|
8
8
|
|
|
9
|
-
The user now asks you to do the following:`},{role:"user",content:t.userPrompt}]:ht({...r,userPrompt:t.userPrompt,isEmptyDocument:o})}};function gt(e){let t,o=!1;return e.descendants((r,n)=>o?!1:(r.isText&&(o=!0,t=n),!0)),t}function F(e){var s;const t=T.getPmSchema(e),{modification:o}=t.marks,r=[],n=new C.Transform(e.before);for(let a=0;a<e.steps.length;a++){const i=e.steps[a],c=new C.Mapping(e.mapping.maps.slice(0,a)).invert();if(i.structure){if(i instanceof C.ReplaceStep){if(i.to!==i.from+1||i.slice.openStart!==0||i.slice.openEnd!==1||i.slice.content.size!==2)throw new Error("Structure change is not in expected format (ReplaceStep)")}else if(i instanceof C.ReplaceAroundStep){if(i.insert!==1||i.slice.size!==2||i.gapTo!==i.to-1||i.gapFrom!==i.from+1)throw new Error("Structure change is not in expected format (ReplaceAroundStep)")}else throw new Error("Step is not a ReplaceStep or ReplaceAroundStep");const b=c.map(i.from),g=i.slice.content.firstChild,k=n.doc.resolve(n.mapping.map(b)).nodeAfter;let w=g.marks||[];g.type!==k.type&&(w=o.create({type:"nodeType",previousValue:k.type.name,newValue:g.type.name}).addToSet(w));const H=new Set([...Object.keys(g.attrs),...Object.keys(k.attrs)]);for(const M of H)g.attrs[M]!==k.attrs[M]&&(w=o.create({type:"attr",attrName:M,previousValue:k.attrs[M],newValue:g.attrs[M]}).addToSet(w));const _=n.steps.length;n.setNodeMarkup(n.mapping.map(b),g.type,g.attrs,w),r.push({prosemirrorSteps:n.steps.slice(_),selection:void 0,type:"replace"});continue}if(!(i instanceof C.ReplaceStep))throw new Error("Step is not a ReplaceStep");const u=c.map(i.from),f=c.map(i.to);if(i.slice.openStart>0||i.slice.openEnd>0)throw new Error("Slice has openStart or openEnd > 0, but structure=false");r.push({prosemirrorSteps:[],selection:{anchor:n.mapping.map(u),head:n.mapping.map(f)},type:"select"});const l=i.slice.content.textBetween(0,i.slice.size),m=l===n.doc.textBetween(n.mapping.map(u),n.mapping.map(f));let p;if(m)p=i.slice.content.size;else if(l.length===0)p=i.slice.content.size;else{const b=gt(i.slice.content);if(b===void 0)throw new Error("unexpected: no first character found");p=b+1}let h=n.mapping.map(f);const d=n.mapping.map(f);let S=!0;for(let b=p;b<=i.slice.content.size;b++){const g=S&&u!==f,k=n.steps.length;if(g){const _=n.doc.resolve(n.mapping.map(u));(s=_.nodeAfter)!=null&&s.isBlock&&n.addNodeMark(_.pos,t.mark("deletion",{})),n.addMark(_.pos,h,t.mark("deletion",{})),h=n.mapping.map(f)}const w=new $.Slice(i.slice.content.cut(0,b),0,0);n.replace(d,h,w).addMark(d,d+w.content.size,t.mark("insertion",{})),n.doc.nodesBetween(d,d+w.content.size,(_,M)=>M<d||M>d+w.content.size?!0:(_.isBlock&&n.addNodeMark(M,t.mark("insertion",{})),!1)),h=n.mapping.slice(k).map(h);const H=q.TextSelection.near(n.doc.resolve(d+w.content.size),-1);r.push({prosemirrorSteps:n.steps.slice(k),selection:{anchor:H.from,head:H.from},type:g?"replace":"insert"}),S=!1}}return r}async function re(e){const t=Math.random()*.3+.85;if(e.type==="select")await new Promise(o=>setTimeout(o,100*t));else if(e.type==="insert")await new Promise(o=>setTimeout(o,10*t));else if(e.type==="replace")await new Promise(o=>setTimeout(o,200*t));else throw new T.UnreachableCaseError(e.type)}function ne(e,t){e.setMeta("addToHistory",!1),t.selection&&e.setMeta("aiAgent",{selection:{anchor:t.selection.anchor,head:t.selection.head}});for(const o of t.prosemirrorSteps)if(e.maybeStep(o).failed)throw new Error("failed to apply step");return e}function kt(e,t,o){const r=new C.Transform(t);for(const a of e){const i=new C.ReplaceStep(r.mapping.map(a.fromA),r.mapping.map(a.toA),o.slice(a.fromB,a.toB));r.step(i)}const n=r.mapping.invert();let s=r.doc.content.findDiffStart(o.content);for(;s!==null;){const a=o.resolve(s).nodeAfter,i=r.doc.resolve(s).nodeAfter;if(!a||!i)throw new Error("diffNode not found");const c=!a.isLeaf&&a.content.eq(i.content),u=c?1:Math.min(a.nodeSize,i.nodeSize),f=s+u,l=n.map(s),m=n.map(f);let p=e.length;for(let d=0;d<e.length;d++)if(e[d].fromA>=m){p=d;break}e.splice(p,0,{fromA:l,toA:m,fromB:s,toB:f,deleted:[],inserted:[],type:c?"node-type-or-attr-update":"mark-update"}),r.step(new C.ReplaceStep(s,f,o.slice(s,f),c));const h=r.doc.content.findDiffStart(o.content);if(h===s)throw new Error("diffStart not moving");s=h}return e}const pe=(e,t)=>{const o=new Set,r=new Set;e.descendants(a=>{a.type.name==="tableCell"&&o.add(JSON.stringify(a.toJSON()))}),t.descendants(a=>{a.type.name==="tableCell"&&r.add(JSON.stringify(a.toJSON()))});const n=new Set([...o].filter(a=>r.has(a)));return{encodeCharacter:a=>a,encodeNodeStart:a=>{if(a.type.name==="tableCell"){const i=JSON.stringify(a.toJSON());return n.has(i)?i:a.type.name}return a.type.name},encodeNodeEnd:a=>{if(a.type.name==="tableCell"){const i=JSON.stringify(a.toJSON());return n.has(i)?i:-1}return-1},compareTokens:(a,i)=>a===i}};function G(e,t,o=!1,r,n){const s=T.getNodeById(e.id,t),a=new C.Transform(t);T.updateBlockTr(a,s.posBeforeNode,e.block,r,n);let i=a.doc,c=K.ChangeSet.create(t,void 0,pe(t,i));if(c=c.addSteps(i,a.mapping.maps,0),o&&c.changes.length>0){const l=c.changes[c.changes.length-1],m=l.toA-l.fromA,p=l.toB-l.fromB;if(m>p){const h=t.slice(l.fromA+p,l.toA);a.step(new C.ReplaceStep(l.toB,l.toB,h)),i=a.doc,c=K.ChangeSet.create(c.startDoc,void 0,pe(c.startDoc,i)),c=c.addSteps(i,a.mapping.maps,0)}}const u=[],f=K.simplifyChanges(c.changes,i);for(let l=0;l<f.length;l++){const m=f[l],p=i.slice(m.fromB,m.toB);if(p.openEnd===1&&p.openStart===0&&(m.type="node-type-or-attr-update",p.size>2)){const h={fromA:m.fromA,toA:m.fromA+1,fromB:m.fromB,toB:m.fromB+1,deleted:[],inserted:[],type:"node-type-or-attr-update"},d={fromA:m.fromA+1,toA:m.toA,fromB:m.fromB+1,toB:m.toB,deleted:[],inserted:[]};f.splice(l,1,h,d),l++}}kt(f,t,i);for(let l=0;l<f.length;l++){const m=f[l],p=i.slice(m.fromB,m.toB);if(p.openEnd>0&&p.size>1)throw new Error("unexpected, openEnd > 0 and size > 1, this should have been split into two steps");l===f.length-1&&o&&m.type==="mark-update"||u.push(new C.ReplaceStep(m.fromA,m.toA,p,m.type==="node-type-or-attr-update"))}return u}function bt(e,t){if(!e||!Array.isArray(e)||e.length===0)return{ok:!1,error:"blocks is required"};const o=[];for(const r of e){const n=t(r);if(!n.ok)return{ok:!1,error:`Invalid block: ${n.error}`};o.push(n.value)}return{ok:!0,value:o}}function se(e){return(t,o)=>{const r=typeof e.schema=="function"?e.schema(t):e.schema;return{name:"add",description:e.description,parameters:{type:"object",properties:{referenceId:{type:"string",description:"MUST be an id of a block in the document"},position:{type:"string",enum:["before","after"],description:"`after` to add blocks AFTER (below) the block with `referenceId`, `before` to add the block BEFORE (above)"},blocks:{items:r.block,type:"array"}},required:["referenceId","position","blocks"],$defs:r.$defs},validate:n=>{if(n.type!=="add")return{ok:!1,error:"invalid operation type"};if(n.position!=="before"&&n.position!=="after")return{ok:!1,error:"invalid position"};if(!n.referenceId||!n.blocks)return{ok:!1,error:"referenceId and blocks are required"};let s=n.referenceId;if(o.idsSuffixed){if(!(s!=null&&s.endsWith("$")))return{ok:!1,error:"referenceId must end with $"};s=s.slice(0,-1)}if(!t.getBlock(s))return{ok:!1,error:"referenceId not found"};const i=bt(n.blocks,c=>e.validateBlock(c,t));return i.ok?{ok:!0,value:{type:n.type,referenceId:s,position:n.position,blocks:i.value}}:i},execute:async function*(n){var i;let s=[];const a={};for await(const c of n){if(c.isUpdateToPreviousOperation||(s=[]),c.operation.type!=="add"){yield c;continue}const u=c.operation,f=await e.toJSONToolCall(t,{...c,operation:u});if(f&&!(c.isPossiblyPartial&&oe(f.blocks[f.blocks.length-1]))){for(let l=0;l<f.blocks.length;l++){const m=f.blocks[l],p=t.prosemirrorState.tr;let h=[];if(l<s.length){const d=await e.rebaseTool(s[l],t),b=G({id:s[l],block:m},d.doc,!1).map(g=>g.map(d.invertMap));for(const g of b)p.step(g.map(p.mapping));h=F(p),h=h.filter(g=>g.type!=="select")}else{const d=u.position==="after"?a[u.referenceId]:void 0,S=T.insertBlocks(p,[m],l>0?s[l-1]:d||u.referenceId,l>0?"after":u.position);s.push(...S.map(b=>b.id)),h=F(p)}h.find(d=>d.type==="replace");for(const d of h)o.withDelays&&await re(d),t.transact(S=>{ne(S,d)}),(i=o.onBlockUpdate)==null||i.call(o,s[l])}c.isPossiblyPartial||u.position==="after"&&(a[u.referenceId]=s[s.length-1])}}}}}}function ie(e){return(t,o)=>{const r=typeof e.schema=="function"?e.schema(t):e.schema;return{name:"update",description:e.description,parameters:{type:"object",properties:{id:{type:"string",description:"id of block to update"},block:r.block},required:["id","block"],$defs:r.$defs},validate:n=>{if(n.type!=="update")return{ok:!1,error:"invalid operation type"};if(!n.id)return{ok:!1,error:"id is required"};let s=n.id;if(o.idsSuffixed){if(!(s!=null&&s.endsWith("$")))return{ok:!1,error:"id must end with $"};s=s.slice(0,-1)}if(!n.block)return{ok:!1,error:"block is required"};const a=t.getBlock(s);if(!a)return console.error("BLOCK NOT FOUND",s),{ok:!1,error:"block not found"};const i=e.validateBlock(n.block,t,a.type);return i.ok?{ok:!0,value:{type:n.type,id:s,block:i.value}}:i},execute:async function*(n){var c;let a=50;const i=o.updateSelection?{from:T.trackPosition(t,o.updateSelection.from),to:T.trackPosition(t,o.updateSelection.to)}:void 0;for await(const u of n){if(u.operation.type!=="update"){yield u;continue}const f=u.operation;if(u.isPossiblyPartial){const k=JSON.stringify(f.block).length;if(k<a)continue;a=k+50}else a=50;const l=await e.rebaseTool(f.id,t),m=i?l.invertMap.invert().map(i.from()):void 0,p=i?l.invertMap.invert().map(i.to()):void 0,h=await e.toJSONToolCall(t,u);if(!h)continue;const d=G(h,l.doc,u.isPossiblyPartial,m,p);if(d.length===1&&u.isPossiblyPartial)continue;const S=d.map(k=>k.map(l.invertMap)),b=new C.Transform(t.prosemirrorState.doc);for(const k of S)b.step(k.map(b.mapping));const g=F(b);for(const k of g)o.withDelays&&await re(k),t.transact(w=>{ne(w,k)}),(c=o.onBlockUpdate)==null||c.call(o,f.id)}}}}}const ae=(e,t)=>({name:"delete",description:"Delete a block",parameters:{type:"object",properties:{id:{type:"string",description:"id of block to delete"}},required:["id"]},validate:o=>{if(o.type!=="delete")return{ok:!1,error:"invalid operation type"};if(!o.id)return{ok:!1,error:"id is required"};let r=o.id;if(t.idsSuffixed){if(!(r!=null&&r.endsWith("$")))return{ok:!1,error:"id must end with $"};r=r.slice(0,-1)}return e.getBlock(r)?{ok:!0,value:{type:"delete",id:r}}:{ok:!1,error:"block not found"}},execute:async function*(o){var r;for await(const n of o){if(n.operation.type!=="delete"){yield n;continue}const s=n.operation,a=e.prosemirrorState.tr;T.removeAndInsertBlocks(a,[s.id],[]);const i=F(a);for(const c of i)t.withDelays&&await re(c),e.transact(u=>{ne(u,c)}),(r=t.onBlockUpdate)==null||r.call(t,s.id)}}});function fe(e){const t=e.lastIndexOf("<"),o=e.lastIndexOf(">");let r=e;if(t>o&&(r=e.substring(0,t),!r.trim()))return;const n=r.match(/&[a-zA-Z0-9]*$/);n&&(r=r.substring(0,r.length-n[0].length));const i=new DOMParser().parseFromString(`<div>${r}</div>`,"text/html").body.firstChild;return i?i.innerHTML:""}function J(e){let t;if(D.applySuggestions(e.prosemirrorState,o=>{t=o}),!t)throw new Error("applySuggestionsTr is not set");return t}function V(e,t){const o=t.mapping.invert();return{doc:t.doc,tr:()=>new C.Transform(t.doc),invertMap:o,rebaseTr:r=>{if(r.steps.length===0)throw new Error("No steps to apply");let n=e.prosemirrorState.tr;for(const s of r.steps){const a=s.map(o);if(!a)throw new Error("Step is not mapped");n=n.step(a)}return n}}}async function me(e,t){var u;const o=J(t),r=T.getBlock(o.doc,e);if(!r)throw new Error("block not found");const n=await t.blocksToHTMLLossy([{...r,children:[]}]),s=(u=window.__TEST_OPTIONS)==null?void 0:u.mockID,a=await t.tryParseHTMLToBlocks(n);if(window.__TEST_OPTIONS&&(window.__TEST_OPTIONS.mockID=s),a.length!==1)throw new Error("html diff invalid block count");const i=a[0];if(i.id=e,G({id:e,block:i},o.doc).length)throw new Error("html diff");return V(t,o)}function he(e){return typeof e!="string"?{ok:!1,error:"block must be a string"}:{ok:!0,value:e}}const Q={add:se({description:"Insert new blocks",schema:{block:{$ref:"#/$defs/block"},$defs:{block:{type:"string",description:"html of block (MUST be a single HTML element)"}}},validateBlock:he,rebaseTool:me,toJSONToolCall:async(e,t)=>{var n;const o=(n=window.__TEST_OPTIONS)==null?void 0:n.mockID,r=(await Promise.all(t.operation.blocks.map(async s=>{const a=t.isPossiblyPartial?fe(s):s;return a?(await e.tryParseHTMLToBlocks(a)).map(i=>(delete i.id,i)):[]}))).flat();if(window.__TEST_OPTIONS&&(window.__TEST_OPTIONS.mockID=o),r.length!==0)return{...t.operation,blocks:r}}}),update:ie({description:"Update a block",schema:{block:{$ref:"#/$defs/block"},$defs:{block:{type:"string",description:"html of block (MUST be a single HTML element)"}}},validateBlock:he,rebaseTool:me,toJSONToolCall:async(e,t)=>{const o=t.isPossiblyPartial?fe(t.operation.block):t.operation.block;if(!o)return;const r=(await e.tryParseHTMLToBlocks(o))[0];return window.__TEST_OPTIONS&&(window.__TEST_OPTIONS.mockID=void 0),delete r.id,{...t.operation,block:r}}}),delete:ae};function St(e,t,o,r,n){const s={add:!0,update:!0,delete:!0,...o};return[...s.update?[Q.update(e,{idsSuffixed:!0,withDelays:t,updateSelection:r,onBlockUpdate:n})]:[],...s.add?[Q.add(e,{idsSuffixed:!0,withDelays:t,onBlockUpdate:n})]:[],...s.delete?[Q.delete(e,{idsSuffixed:!0,withDelays:t,onBlockUpdate:n})]:[]]}const Le={getStreamTools:St,defaultPromptBuilder:yt,promptHelpers:{getDataForPromptNoSelection:Ie,getDataForPromptWithSelection:_e}};async function Ee(e,t){const{userPrompt:o,useSelection:r,deleteEmptyCursorBlock:n,stream:s,onStart:a,withDelays:i,dataFormat:c,previousResponse:u,...f}={maxRetries:2,deleteEmptyCursorBlock:!0,stream:!0,withDelays:!0,dataFormat:Le,...t},l=t.promptBuilder??c.defaultPromptBuilder,m=c.getStreamTools,p=r?void 0:e.getTextCursorPosition().block,h=p&&n&&oe(p)&&E(e.document).length>0?p.id:void 0,d=r?e.getSelectionCutBlocks():void 0;let S;u&&(S=u.messages.map(w=>w.role==="user"&&typeof w.content=="string"?{role:"system",content:`USER_MESSAGE: ${w.content}`}:w),S.push({role:"system",content:`ASSISTANT_MESSAGE: These are the operations returned by a previous LLM call:
|
|
9
|
+
The user now asks you to do the following:`},{role:"user",content:t.userPrompt}]:ht({...r,userPrompt:t.userPrompt,isEmptyDocument:o})}};function gt(e){let t,o=!1;return e.descendants((r,n)=>o?!1:(r.isText&&(o=!0,t=n),!0)),t}function F(e){var s;const t=T.getPmSchema(e),{modification:o}=t.marks,r=[],n=new C.Transform(e.before);for(let a=0;a<e.steps.length;a++){const i=e.steps[a],c=new C.Mapping(e.mapping.maps.slice(0,a)).invert();if(i.structure){if(i instanceof C.ReplaceStep){if(i.to!==i.from+1||i.slice.openStart!==0||i.slice.openEnd!==1||i.slice.content.size!==2)throw new Error("Structure change is not in expected format (ReplaceStep)")}else if(i instanceof C.ReplaceAroundStep){if(i.insert!==1||i.slice.size!==2||i.gapTo!==i.to-1||i.gapFrom!==i.from+1)throw new Error("Structure change is not in expected format (ReplaceAroundStep)")}else throw new Error("Step is not a ReplaceStep or ReplaceAroundStep");const b=c.map(i.from),g=i.slice.content.firstChild,k=n.doc.resolve(n.mapping.map(b)).nodeAfter;let w=g.marks||[];g.type!==k.type&&(w=o.create({type:"nodeType",previousValue:k.type.name,newValue:g.type.name}).addToSet(w));const H=new Set([...Object.keys(g.attrs),...Object.keys(k.attrs)]);for(const M of H)g.attrs[M]!==k.attrs[M]&&(w=o.create({type:"attr",attrName:M,previousValue:k.attrs[M],newValue:g.attrs[M]}).addToSet(w));const _=n.steps.length;n.setNodeMarkup(n.mapping.map(b),g.type,g.attrs,w),r.push({prosemirrorSteps:n.steps.slice(_),selection:void 0,type:"replace"});continue}if(!(i instanceof C.ReplaceStep))throw new Error("Step is not a ReplaceStep");const u=c.map(i.from),f=c.map(i.to);if(i.slice.openStart>0||i.slice.openEnd>0)throw new Error("Slice has openStart or openEnd > 0, but structure=false");r.push({prosemirrorSteps:[],selection:{anchor:n.mapping.map(u),head:n.mapping.map(f)},type:"select"});const l=i.slice.content.textBetween(0,i.slice.size),m=l===n.doc.textBetween(n.mapping.map(u),n.mapping.map(f));let p;if(m)p=i.slice.content.size;else if(l.length===0)p=i.slice.content.size;else{const b=gt(i.slice.content);if(b===void 0)throw new Error("unexpected: no first character found");p=b+1}let h=n.mapping.map(f);const d=n.mapping.map(f);let S=!0;for(let b=p;b<=i.slice.content.size;b++){const g=S&&u!==f,k=n.steps.length;if(g){const _=n.doc.resolve(n.mapping.map(u));(s=_.nodeAfter)!=null&&s.isBlock&&n.addNodeMark(_.pos,t.mark("deletion",{})),n.addMark(_.pos,h,t.mark("deletion",{})),h=n.mapping.map(f)}const w=new R.Slice(i.slice.content.cut(0,b),0,0);n.replace(d,h,w).addMark(d,d+w.content.size,t.mark("insertion",{})),n.doc.nodesBetween(d,d+w.content.size,(_,M)=>M<d||M>d+w.content.size?!0:(_.isBlock&&n.addNodeMark(M,t.mark("insertion",{})),!1)),h=n.mapping.slice(k).map(h);const H=q.TextSelection.near(n.doc.resolve(d+w.content.size),-1);r.push({prosemirrorSteps:n.steps.slice(k),selection:{anchor:H.from,head:H.from},type:g?"replace":"insert"}),S=!1}}return r}async function re(e){const t=Math.random()*.3+.85;if(e.type==="select")await new Promise(o=>setTimeout(o,100*t));else if(e.type==="insert")await new Promise(o=>setTimeout(o,10*t));else if(e.type==="replace")await new Promise(o=>setTimeout(o,200*t));else throw new T.UnreachableCaseError(e.type)}function ne(e,t){e.setMeta("addToHistory",!1),t.selection&&e.setMeta("aiAgent",{selection:{anchor:t.selection.anchor,head:t.selection.head}});for(const o of t.prosemirrorSteps)if(e.maybeStep(o).failed)throw new Error("failed to apply step");return e}function kt(e,t,o){const r=new C.Transform(t);for(const a of e){const i=new C.ReplaceStep(r.mapping.map(a.fromA),r.mapping.map(a.toA),o.slice(a.fromB,a.toB));r.step(i)}const n=r.mapping.invert();let s=r.doc.content.findDiffStart(o.content);for(;s!==null;){const a=o.resolve(s).nodeAfter,i=r.doc.resolve(s).nodeAfter;if(!a||!i)throw new Error("diffNode not found");const c=!a.isLeaf&&a.content.eq(i.content),u=c?1:Math.min(a.nodeSize,i.nodeSize),f=s+u,l=n.map(s),m=n.map(f);let p=e.length;for(let d=0;d<e.length;d++)if(e[d].fromA>=m){p=d;break}e.splice(p,0,{fromA:l,toA:m,fromB:s,toB:f,deleted:[],inserted:[],type:c?"node-type-or-attr-update":"mark-update"}),r.step(new C.ReplaceStep(s,f,o.slice(s,f),c));const h=r.doc.content.findDiffStart(o.content);if(h===s)throw new Error("diffStart not moving");s=h}return e}const pe=(e,t)=>{const o=new Set,r=new Set;e.descendants(a=>{a.type.name==="tableCell"&&o.add(JSON.stringify(a.toJSON()))}),t.descendants(a=>{a.type.name==="tableCell"&&r.add(JSON.stringify(a.toJSON()))});const n=new Set([...o].filter(a=>r.has(a)));return{encodeCharacter:a=>a,encodeNodeStart:a=>{if(a.type.name==="tableCell"){const i=JSON.stringify(a.toJSON());return n.has(i)?i:a.type.name}return a.type.name},encodeNodeEnd:a=>{if(a.type.name==="tableCell"){const i=JSON.stringify(a.toJSON());return n.has(i)?i:-1}return-1},compareTokens:(a,i)=>a===i}};function G(e,t,o=!1,r,n){const s=T.getNodeById(e.id,t),a=new C.Transform(t);T.updateBlockTr(a,s.posBeforeNode,e.block,r,n);let i=a.doc,c=K.ChangeSet.create(t,void 0,pe(t,i));if(c=c.addSteps(i,a.mapping.maps,0),o&&c.changes.length>0){const l=c.changes[c.changes.length-1],m=l.toA-l.fromA,p=l.toB-l.fromB;if(m>p){const h=t.slice(l.fromA+p,l.toA);a.step(new C.ReplaceStep(l.toB,l.toB,h)),i=a.doc,c=K.ChangeSet.create(c.startDoc,void 0,pe(c.startDoc,i)),c=c.addSteps(i,a.mapping.maps,0)}}const u=[],f=K.simplifyChanges(c.changes,i);for(let l=0;l<f.length;l++){const m=f[l],p=i.slice(m.fromB,m.toB);if(p.openEnd===1&&p.openStart===0&&(m.type="node-type-or-attr-update",p.size>2)){const h={fromA:m.fromA,toA:m.fromA+1,fromB:m.fromB,toB:m.fromB+1,deleted:[],inserted:[],type:"node-type-or-attr-update"},d={fromA:m.fromA+1,toA:m.toA,fromB:m.fromB+1,toB:m.toB,deleted:[],inserted:[]};f.splice(l,1,h,d),l++}}kt(f,t,i);for(let l=0;l<f.length;l++){const m=f[l],p=i.slice(m.fromB,m.toB);if(p.openEnd>0&&p.size>1)throw new Error("unexpected, openEnd > 0 and size > 1, this should have been split into two steps");l===f.length-1&&o&&m.type==="mark-update"||u.push(new C.ReplaceStep(m.fromA,m.toA,p,m.type==="node-type-or-attr-update"))}return u}function bt(e,t){if(!e||!Array.isArray(e)||e.length===0)return{ok:!1,error:"blocks is required"};const o=[];for(const r of e){const n=t(r);if(!n.ok)return{ok:!1,error:`Invalid block: ${n.error}`};o.push(n.value)}return{ok:!0,value:o}}function se(e){return(t,o)=>{const r=typeof e.schema=="function"?e.schema(t):e.schema;return{name:"add",description:e.description,parameters:{type:"object",properties:{referenceId:{type:"string",description:"MUST be an id of a block in the document"},position:{type:"string",enum:["before","after"],description:"`after` to add blocks AFTER (below) the block with `referenceId`, `before` to add the block BEFORE (above)"},blocks:{items:r.block,type:"array"}},required:["referenceId","position","blocks"],$defs:r.$defs},validate:n=>{if(n.type!=="add")return{ok:!1,error:"invalid operation type"};if(n.position!=="before"&&n.position!=="after")return{ok:!1,error:"invalid position"};if(!n.referenceId||!n.blocks)return{ok:!1,error:"referenceId and blocks are required"};let s=n.referenceId;if(o.idsSuffixed){if(!(s!=null&&s.endsWith("$")))return{ok:!1,error:"referenceId must end with $"};s=s.slice(0,-1)}if(!t.getBlock(s))return{ok:!1,error:"referenceId not found"};const i=bt(n.blocks,c=>e.validateBlock(c,t));return i.ok?{ok:!0,value:{type:n.type,referenceId:s,position:n.position,blocks:i.value}}:i},execute:async function*(n){var i;let s=[];const a={};for await(const c of n){if(c.isUpdateToPreviousOperation||(s=[]),c.operation.type!=="add"){yield c;continue}const u=c.operation,f=await e.toJSONToolCall(t,{...c,operation:u});if(f&&!(c.isPossiblyPartial&&oe(f.blocks[f.blocks.length-1]))){for(let l=0;l<f.blocks.length;l++){const m=f.blocks[l],p=t.prosemirrorState.tr;let h=[];if(l<s.length){const d=await e.rebaseTool(s[l],t),b=G({id:s[l],block:m},d.doc,!1).map(g=>g.map(d.invertMap));for(const g of b)p.step(g.map(p.mapping));h=F(p),h=h.filter(g=>g.type!=="select")}else{const d=u.position==="after"?a[u.referenceId]:void 0,S=T.insertBlocks(p,[m],l>0?s[l-1]:d||u.referenceId,l>0?"after":u.position);s.push(...S.map(b=>b.id)),h=F(p)}h.find(d=>d.type==="replace");for(const d of h)o.withDelays&&await re(d),t.transact(S=>{ne(S,d)}),(i=o.onBlockUpdate)==null||i.call(o,s[l])}c.isPossiblyPartial||u.position==="after"&&(a[u.referenceId]=s[s.length-1])}}}}}}function ie(e){return(t,o)=>{const r=typeof e.schema=="function"?e.schema(t):e.schema;return{name:"update",description:e.description,parameters:{type:"object",properties:{id:{type:"string",description:"id of block to update"},block:r.block},required:["id","block"],$defs:r.$defs},validate:n=>{if(n.type!=="update")return{ok:!1,error:"invalid operation type"};if(!n.id)return{ok:!1,error:"id is required"};let s=n.id;if(o.idsSuffixed){if(!(s!=null&&s.endsWith("$")))return{ok:!1,error:"id must end with $"};s=s.slice(0,-1)}if(!n.block)return{ok:!1,error:"block is required"};const a=t.getBlock(s);if(!a)return console.error("BLOCK NOT FOUND",s),{ok:!1,error:"block not found"};const i=e.validateBlock(n.block,t,a.type);return i.ok?{ok:!0,value:{type:n.type,id:s,block:i.value}}:i},execute:async function*(n){var c;let a=50;const i=o.updateSelection?{from:T.trackPosition(t,o.updateSelection.from),to:T.trackPosition(t,o.updateSelection.to)}:void 0;for await(const u of n){if(u.operation.type!=="update"){yield u;continue}const f=u.operation;if(u.isPossiblyPartial){const k=JSON.stringify(f.block).length;if(k<a)continue;a=k+50}else a=50;const l=await e.rebaseTool(f.id,t),m=i?l.invertMap.invert().map(i.from()):void 0,p=i?l.invertMap.invert().map(i.to()):void 0,h=await e.toJSONToolCall(t,u);if(!h)continue;const d=G(h,l.doc,u.isPossiblyPartial,m,p);if(d.length===1&&u.isPossiblyPartial)continue;const S=d.map(k=>k.map(l.invertMap)),b=new C.Transform(t.prosemirrorState.doc);for(const k of S)b.step(k.map(b.mapping));const g=F(b);for(const k of g)o.withDelays&&await re(k),t.transact(w=>{ne(w,k)}),(c=o.onBlockUpdate)==null||c.call(o,f.id)}}}}}const ae=(e,t)=>({name:"delete",description:"Delete a block",parameters:{type:"object",properties:{id:{type:"string",description:"id of block to delete"}},required:["id"]},validate:o=>{if(o.type!=="delete")return{ok:!1,error:"invalid operation type"};if(!o.id)return{ok:!1,error:"id is required"};let r=o.id;if(t.idsSuffixed){if(!(r!=null&&r.endsWith("$")))return{ok:!1,error:"id must end with $"};r=r.slice(0,-1)}return e.getBlock(r)?{ok:!0,value:{type:"delete",id:r}}:{ok:!1,error:"block not found"}},execute:async function*(o){var r;for await(const n of o){if(n.operation.type!=="delete"){yield n;continue}const s=n.operation,a=e.prosemirrorState.tr;T.removeAndInsertBlocks(a,[s.id],[]);const i=F(a);for(const c of i)t.withDelays&&await re(c),e.transact(u=>{ne(u,c)}),(r=t.onBlockUpdate)==null||r.call(t,s.id)}}});function fe(e){const t=e.lastIndexOf("<"),o=e.lastIndexOf(">");let r=e;if(t>o&&(r=e.substring(0,t),!r.trim()))return;const n=r.match(/&[a-zA-Z0-9]*$/);n&&(r=r.substring(0,r.length-n[0].length));const i=new DOMParser().parseFromString(`<div>${r}</div>`,"text/html").body.firstChild;return i?i.innerHTML:""}function J(e){let t;if(D.applySuggestions(e.prosemirrorState,o=>{t=o}),!t)throw new Error("applySuggestionsTr is not set");return t}function V(e,t){const o=t.mapping.invert();return{doc:t.doc,tr:()=>new C.Transform(t.doc),invertMap:o,rebaseTr:r=>{if(r.steps.length===0)throw new Error("No steps to apply");let n=e.prosemirrorState.tr;for(const s of r.steps){const a=s.map(o);if(!a)throw new Error("Step is not mapped");n=n.step(a)}return n}}}async function me(e,t){var u;const o=J(t),r=T.getBlock(o.doc,e);if(!r)throw new Error("block not found");const n=await t.blocksToHTMLLossy([{...r,children:[]}]),s=(u=window.__TEST_OPTIONS)==null?void 0:u.mockID,a=await t.tryParseHTMLToBlocks(n);if(window.__TEST_OPTIONS&&(window.__TEST_OPTIONS.mockID=s),a.length!==1)throw new Error("html diff invalid block count");const i=a[0];if(i.id=e,G({id:e,block:i},o.doc).length)throw new Error("html diff");return V(t,o)}function he(e){return typeof e!="string"?{ok:!1,error:"block must be a string"}:{ok:!0,value:e}}const Q={add:se({description:"Insert new blocks",schema:{block:{type:"string",description:"html of block (MUST be a single HTML element)"}},validateBlock:he,rebaseTool:me,toJSONToolCall:async(e,t)=>{var n;const o=(n=window.__TEST_OPTIONS)==null?void 0:n.mockID,r=(await Promise.all(t.operation.blocks.map(async s=>{const a=t.isPossiblyPartial?fe(s):s;return a?(await e.tryParseHTMLToBlocks(a)).map(i=>(delete i.id,i)):[]}))).flat();if(window.__TEST_OPTIONS&&(window.__TEST_OPTIONS.mockID=o),r.length!==0)return{...t.operation,blocks:r}}}),update:ie({description:"Update a block",schema:{block:{type:"string",description:"html of block (MUST be a single HTML element)"}},validateBlock:he,rebaseTool:me,toJSONToolCall:async(e,t)=>{const o=t.isPossiblyPartial?fe(t.operation.block):t.operation.block;if(!o)return;const r=(await e.tryParseHTMLToBlocks(o))[0];return window.__TEST_OPTIONS&&(window.__TEST_OPTIONS.mockID=void 0),delete r.id,{...t.operation,block:r}}}),delete:ae};function St(e,t,o,r,n){const s={add:!0,update:!0,delete:!0,...o};return[...s.update?[Q.update(e,{idsSuffixed:!0,withDelays:t,updateSelection:r,onBlockUpdate:n})]:[],...s.add?[Q.add(e,{idsSuffixed:!0,withDelays:t,onBlockUpdate:n})]:[],...s.delete?[Q.delete(e,{idsSuffixed:!0,withDelays:t,onBlockUpdate:n})]:[]]}const Le={getStreamTools:St,defaultPromptBuilder:yt,promptHelpers:{getDataForPromptNoSelection:Ie,getDataForPromptWithSelection:_e}};async function Ee(e,t){const{userPrompt:o,useSelection:r,deleteEmptyCursorBlock:n,stream:s,onStart:a,withDelays:i,dataFormat:c,previousResponse:u,...f}={maxRetries:2,deleteEmptyCursorBlock:!0,stream:!0,withDelays:!0,dataFormat:Le,...t},l=t.promptBuilder??c.defaultPromptBuilder,m=c.getStreamTools,p=r?void 0:e.getTextCursorPosition().block,h=p&&n&&oe(p)&&E(e.document).length>0?p.id:void 0,d=r?e.getSelectionCutBlocks():void 0;let S;u&&(S=u.messages.map(w=>w.role==="user"&&typeof w.content=="string"?{role:"system",content:`USER_MESSAGE: ${w.content}`}:w),S.push({role:"system",content:`ASSISTANT_MESSAGE: These are the operations returned by a previous LLM call:
|
|
10
10
|
`+JSON.stringify(await u.llmResult.getGeneratedOperations())}));const b=await l(e,{selectedBlocks:d==null?void 0:d.blocks,userPrompt:o,excludeBlockIds:h?[h]:void 0,previousMessages:S}),g=m(e,i,t.defaultStreamTools,d?{from:d._meta.startPos,to:d._meta.endPos}:void 0,t.onBlockUpdate);let k;return s?k=await ct(g,{messages:b,...f},()=>{h&&e.removeBlocks([h]),a==null||a()}):(k=await it(g,{messages:b,...f}),h&&e.removeBlocks([h]),a==null||a()),new pt(b,k,g)}async function Ne(e,t){const o=e.getTextCursorPosition().block.id,r=E(e.document,{cursorBlockId:o}),n=await x(P(r),async c=>({...c,children:void 0})),a=Y(e,n).filter(c=>"cursor"in c||!(t.excludeBlockIds||[]).includes(c.id));return{jsonBlocks:N(a)}}async function Ae(e,t){const o=await x(P(t.selectedBlocks),async n=>n);return{jsonSelectedBlocks:N(o),jsonDocument:(await x(P(e.document),async n=>({...n,id:void 0,children:void 0}))).map(({block:n})=>({block:n}))}}function wt(e){return[{role:"system",content:`You're manipulating a selected part of a text document using JSON blocks.
|
|
11
11
|
Make sure to follow the json schema provided and always include the trailing $ in ids.
|
|
12
12
|
This is the selection as an array of JSON blocks:`},{role:"system",content:JSON.stringify(e.jsonSelectedBlocks)},{role:"system",content:"This is the entire document (INCLUDING the selected text), find the selected text in there to understand the context:"},{role:"system",content:JSON.stringify(e.jsonDocument)},{role:"system",content:"The user asks you to do the following:"},{role:"user",content:e.userPrompt}]}function Tt(e){return[{role:"system",content:`You're manipulating a text document using JSON blocks.
|
|
13
13
|
Make sure to follow the json schema provided. When referencing ids they MUST be EXACTLY the same (including the trailing $).
|
|
14
|
-
This is the document as an array of JSON blocks (the cursor is BETWEEN two blocks as indicated by cursor: true):`},{role:"system",content:JSON.stringify(e.jsonBlocks)},...e.isEmptyDocument?[{role:"system",content:"Because the actual document is empty, this is an example document to understand the schema:"},{role:"system",content:JSON.stringify({id:"ref3",type:"paragraph",content:[{type:"text",text:"Hello, world! ",styles:{}},{type:"text",text:"Bold text. ",styles:{bold:!0}},{type:"link",href:"https://www.w3.org",content:"Link."}]})}]:[],{role:"system",content:"The user asks you to do the following:"},{role:"system",content:'First, determine what part of the document the user is talking about. You SHOULD probably take cursor info into account if needed.\n EXAMPLE: if user says "below" (without pointing to a specific part of the document) he / she probably indicates the block(s) after the cursor. \n EXAMPLE: If you want to insert content AT the cursor position (UNLESS indicated otherwise by the user), then you need `referenceId` to point to the block before the cursor with position `after` (or block below and `before`).\n \n '+(e.isEmptyDocument?"Because the document is empty, first update the empty block before adding new blocks.":"Prefer updating existing blocks over removing and adding (but this also depends on the user's question).")},{role:"user",content:e.userPrompt}]}const vt=async(e,t)=>{const o=E(e.document).length===0;if(t.selectedBlocks){const r=await Ae(e,{selectedBlocks:t.selectedBlocks});return wt({...r,userPrompt:t.userPrompt})}else{const r=await Ne(e,t);return Tt({...r,userPrompt:t.userPrompt,isEmptyDocument:o})}};function Ct(e){const t={},o={};return e.forEach(n=>{const{type:s,...a}=n.properties,i=JSON.stringify(a);t[i]?t[i].push(s.enum[0]):(t[i]=[s.enum[0]],o[i]=n)}),Object.keys(t).map(n=>{const s=o[n];return{...s,properties:{...s.properties,type:{type:"string",enum:t[n]}}}})}function Pt(e){return{type:"object",properties:Object.fromEntries(Object.entries(e).map(([t,o])=>[t,{type:o.propSchema}])),additionalProperties:!1}}function Ot(){return{type:"object",properties:{type:{type:"string",enum:["text"]},text:{type:"string"},styles:{$ref:"#/$defs/styles"}},additionalProperties:!1,required:["type","text"]}}function je(e){return{type:"object",properties:Object.fromEntries(Object.entries(e).filter(([t,o])=>o.default!==void 0).map(([t,o])=>[t,{type:typeof o.default,enum:o.values}])),additionalProperties:!1}}function xt(e){return{type:"array",items:{anyOf:Object.entries(e).map(([t,o])=>o==="text"?{$ref:"#/$defs/styledtext"}:o==="link"?{type:"object",properties:{type:{type:"string",enum:["link"]},content:{type:"array",items:{$ref:"#/$defs/styledtext"}},href:{type:"string"}},additionalProperties:!1,required:["type","href","content"]}:{type:"object",properties:{type:{type:"string",enum:[o.type]},content:o.content==="styled"?{type:"array",items:{$ref:"#/$defs/styledtext"}}:void 0,props:je(o.propSchema)},additionalProperties:!1,required:["type",...o.content==="styled"?["content"]:[]]})}}}function Mt(e){return{anyOf:Ct(Object.entries(e).map(([t,o])=>({type:"object",properties:{type:{type:"string",enum:[o.type]},content:o.content==="inline"?{$ref:"#/$defs/inlinecontent"}:o.content==="table"?{type:"object",properties:{}}:void 0,props:je(o.propSchema)},additionalProperties:!1,required:["type"]})))}}function Bt(e){const t=JSON.parse(JSON.stringify({blockSchema:e.blockSchema,inlineContentSchema:e.inlineContentSchema,styleSchema:e.styleSchema}));return{removeFileBlocks(){return t.blockSchema=Object.fromEntries(Object.entries(t.blockSchema).filter(([o,r])=>!r.isFileBlock)),this},removeDefaultProps(){return t.blockSchema=Object.fromEntries(Object.entries(t.blockSchema).map(([o,r])=>[o,{...r,propSchema:Object.fromEntries(Object.entries(r.propSchema).filter(n=>typeof T.defaultProps[n[0]]>"u"))}])),this},get(){return t}}}function ye(e){return e=Bt(e).removeFileBlocks().removeDefaultProps().get(),{$defs:{styles:Pt(e.styleSchema),styledtext:Ot(),inlinecontent:xt(e.inlineContentSchema),block:Mt(e.blockSchema)}}}function De(e,t){return!t.schema.inlineContentSchema[e.type]||T.isStyledTextInlineContent(e)&&!("text"in e)?!1:T.isLinkInlineContent(e)?!("content"in e)||!("href"in e)?!1:De(e.content,t):!0}function ge(e,t,o){const r=e.type||o,n=t.schema.blockSchema[r];if(!n)return{ok:!1,error:"block type not found in editor"};if(e.children,n.content==="none"){if(e.content)return{ok:!1,error:"block content not expected for this block type"}}else{if(!e.content)return{ok:!0,value:e};if(!Array.isArray(e.content))return{ok:!1,error:"block content must be an array"};if(n.content==="table")return{ok:!0,value:e};if(!e.content.every(s=>De(s,t)))return{ok:!1,error:"block content must be an array of inline content"}}return{ok:!0,value:e}}const ee={add:se({description:"Insert new blocks",schema:e=>({block:{$ref:"#/$defs/block"},...ye(e.schema)}),validateBlock:ge,rebaseTool:async(e,t)=>V(t,J(t)),toJSONToolCall:async(e,t)=>t.operation}),update:ie({description:"Update a block, the new block will replace the existing block.",schema:e=>({block:{$ref:"#/$defs/block"},...ye(e.schema)}),validateBlock:ge,rebaseTool:async(e,t)=>V(t,J(t)),toJSONToolCall:async(e,t)=>{const o=Object.fromEntries(Object.entries(T.defaultProps).map(([r,n])=>[r,n.default]));return{...t.operation,block:{...t.operation.block,props:{...o,...t.operation.block.props}}}}}),delete:ae};function It(e,t,o,r){const n={add:!0,update:!0,delete:!0,...o};return[...n.update?[ee.update(e,{idsSuffixed:!0,withDelays:t,updateSelection:r})]:[],...n.add?[ee.add(e,{idsSuffixed:!0,withDelays:t})]:[],...n.delete?[ee.delete(e,{idsSuffixed:!0,withDelays:t})]:[]]}const _t={getStreamTools:It,defaultPromptBuilder:vt,promptHelpers:{getDataForPromptNoSelection:Ne,getDataForPromptWithSelection:Ae}};async function
|
|
14
|
+
This is the document as an array of JSON blocks (the cursor is BETWEEN two blocks as indicated by cursor: true):`},{role:"system",content:JSON.stringify(e.jsonBlocks)},...e.isEmptyDocument?[{role:"system",content:"Because the actual document is empty, this is an example document to understand the schema:"},{role:"system",content:JSON.stringify({id:"ref3",type:"paragraph",content:[{type:"text",text:"Hello, world! ",styles:{}},{type:"text",text:"Bold text. ",styles:{bold:!0}},{type:"link",href:"https://www.w3.org",content:"Link."}]})}]:[],{role:"system",content:"The user asks you to do the following:"},{role:"system",content:'First, determine what part of the document the user is talking about. You SHOULD probably take cursor info into account if needed.\n EXAMPLE: if user says "below" (without pointing to a specific part of the document) he / she probably indicates the block(s) after the cursor. \n EXAMPLE: If you want to insert content AT the cursor position (UNLESS indicated otherwise by the user), then you need `referenceId` to point to the block before the cursor with position `after` (or block below and `before`).\n \n '+(e.isEmptyDocument?"Because the document is empty, first update the empty block before adding new blocks.":"Prefer updating existing blocks over removing and adding (but this also depends on the user's question).")},{role:"user",content:e.userPrompt}]}const vt=async(e,t)=>{const o=E(e.document).length===0;if(t.selectedBlocks){const r=await Ae(e,{selectedBlocks:t.selectedBlocks});return wt({...r,userPrompt:t.userPrompt})}else{const r=await Ne(e,t);return Tt({...r,userPrompt:t.userPrompt,isEmptyDocument:o})}};function Ct(e){const t={},o={};return e.forEach(n=>{const{type:s,...a}=n.properties,i=JSON.stringify(a);t[i]?t[i].push(s.enum[0]):(t[i]=[s.enum[0]],o[i]=n)}),Object.keys(t).map(n=>{const s=o[n];return{...s,properties:{...s.properties,type:{type:"string",enum:t[n]}}}})}function Pt(e){return{type:"object",properties:Object.fromEntries(Object.entries(e).map(([t,o])=>[t,{type:o.propSchema}])),additionalProperties:!1}}function Ot(){return{type:"object",properties:{type:{type:"string",enum:["text"]},text:{type:"string"},styles:{$ref:"#/$defs/styles"}},additionalProperties:!1,required:["type","text"]}}function je(e){return{type:"object",properties:Object.fromEntries(Object.entries(e).filter(([t,o])=>o.default!==void 0).map(([t,o])=>[t,{type:typeof o.default,enum:o.values}])),additionalProperties:!1}}function xt(e){return{type:"array",items:{anyOf:Object.entries(e).map(([t,o])=>o==="text"?{$ref:"#/$defs/styledtext"}:o==="link"?{type:"object",properties:{type:{type:"string",enum:["link"]},content:{type:"array",items:{$ref:"#/$defs/styledtext"}},href:{type:"string"}},additionalProperties:!1,required:["type","href","content"]}:{type:"object",properties:{type:{type:"string",enum:[o.type]},content:o.content==="styled"?{type:"array",items:{$ref:"#/$defs/styledtext"}}:void 0,props:je(o.propSchema)},additionalProperties:!1,required:["type",...o.content==="styled"?["content"]:[]]})}}}function Mt(e){return{anyOf:Ct(Object.entries(e).map(([t,o])=>({type:"object",properties:{type:{type:"string",enum:[o.type]},content:o.content==="inline"?{$ref:"#/$defs/inlinecontent"}:o.content==="table"?{type:"object",properties:{}}:void 0,props:je(o.propSchema)},additionalProperties:!1,required:["type"]})))}}function Bt(e){const t=JSON.parse(JSON.stringify({blockSchema:e.blockSchema,inlineContentSchema:e.inlineContentSchema,styleSchema:e.styleSchema}));return{removeFileBlocks(){return t.blockSchema=Object.fromEntries(Object.entries(t.blockSchema).filter(([o,r])=>!r.isFileBlock)),this},removeDefaultProps(){return t.blockSchema=Object.fromEntries(Object.entries(t.blockSchema).map(([o,r])=>[o,{...r,propSchema:Object.fromEntries(Object.entries(r.propSchema).filter(n=>typeof T.defaultProps[n[0]]>"u"))}])),this},get(){return t}}}function ye(e){return e=Bt(e).removeFileBlocks().removeDefaultProps().get(),{$defs:{styles:Pt(e.styleSchema),styledtext:Ot(),inlinecontent:xt(e.inlineContentSchema),block:Mt(e.blockSchema)}}}function De(e,t){return!t.schema.inlineContentSchema[e.type]||T.isStyledTextInlineContent(e)&&!("text"in e)?!1:T.isLinkInlineContent(e)?!("content"in e)||!("href"in e)?!1:De(e.content,t):!0}function ge(e,t,o){const r=e.type||o,n=t.schema.blockSchema[r];if(!n)return{ok:!1,error:"block type not found in editor"};if(e.children,n.content==="none"){if(e.content)return{ok:!1,error:"block content not expected for this block type"}}else{if(!e.content)return{ok:!0,value:e};if(!Array.isArray(e.content))return{ok:!1,error:"block content must be an array"};if(n.content==="table")return{ok:!0,value:e};if(!e.content.every(s=>De(s,t)))return{ok:!1,error:"block content must be an array of inline content"}}return{ok:!0,value:e}}const ee={add:se({description:"Insert new blocks",schema:e=>({block:{$ref:"#/$defs/block"},...ye(e.schema)}),validateBlock:ge,rebaseTool:async(e,t)=>V(t,J(t)),toJSONToolCall:async(e,t)=>t.operation}),update:ie({description:"Update a block, the new block will replace the existing block.",schema:e=>({block:{$ref:"#/$defs/block"},...ye(e.schema)}),validateBlock:ge,rebaseTool:async(e,t)=>V(t,J(t)),toJSONToolCall:async(e,t)=>{const o=Object.fromEntries(Object.entries(T.defaultProps).map(([r,n])=>[r,n.default]));return{...t.operation,block:{...t.operation.block,props:{...o,...t.operation.block.props}}}}}),delete:ae};function It(e,t,o,r){const n={add:!0,update:!0,delete:!0,...o};return[...n.update?[ee.update(e,{idsSuffixed:!0,withDelays:t,updateSelection:r})]:[],...n.add?[ee.add(e,{idsSuffixed:!0,withDelays:t})]:[],...n.delete?[ee.delete(e,{idsSuffixed:!0,withDelays:t})]:[]]}const _t={getStreamTools:It,defaultPromptBuilder:vt,promptHelpers:{getDataForPromptNoSelection:Ne,getDataForPromptWithSelection:Ae}};async function Re(e,t){const o=e.getTextCursorPosition().block.id,r=E(e.document,{cursorBlockId:o}),n=await x(P(r),async c=>e.blocksToMarkdownLossy([c])),a=Y(e,n).filter(c=>"cursor"in c||!(t.excludeBlockIds||[]).includes(c.id));return{markdownBlocks:N(a)}}async function $e(e,t){const o=await x(P(t.selectedBlocks),async n=>e.blocksToMarkdownLossy([n]));return{markdownSelectedBlocks:N(o),markdownDocument:(await x(P(e.document),async n=>e.blocksToMarkdownLossy([n]))).map(({block:n})=>({block:n}))}}function Lt(e){return[{role:"system",content:`You're manipulating a selected part of a text document using markdown blocks.
|
|
15
15
|
Make sure to follow the json schema provided and always include the trailing $ in ids.
|
|
16
16
|
This is the selection as an array of markdown blocks:`},{role:"system",content:JSON.stringify(e.markdownSelectedBlocks)},{role:"system",content:"This is the entire document (INCLUDING the selected text), find the selected text in there to understand the context:"},{role:"system",content:JSON.stringify(e.markdownDocument)},{role:"system",content:"The user asks you to do the following:"},{role:"user",content:e.userPrompt}]}function Et(e){return[{role:"system",content:`You're manipulating a text document using markdown blocks.
|
|
17
17
|
Make sure to follow the json schema provided. When referencing ids they MUST be EXACTLY the same (including the trailing $).
|
|
18
|
-
This is the document as an array of markdown blocks (the cursor is BETWEEN two blocks as indicated by cursor: true):`},{role:"system",content:JSON.stringify(e.markdownBlocks)},{role:"system",content:"The user asks you to do the following:"},{role:"user",content:e.userPrompt},{role:"system",content:'First, determine what part of the document the user is talking about. You SHOULD probably take cursor info into account if needed.\n EXAMPLE: if user says "below" (without pointing to a specific part of the document) he / she probably indicates the block(s) after the cursor. \n EXAMPLE: If you want to insert content AT the cursor position (UNLESS indicated otherwise by the user), then you need `referenceId` to point to the block before the cursor with position `after` (or block below and `before`).\n \n Prefer updating blocks over adding or removing (but this also depends on the user\'s question).'}]}const Nt=async(e,t)=>{if(t.selectedBlocks){const o=await
|
|
18
|
+
This is the document as an array of markdown blocks (the cursor is BETWEEN two blocks as indicated by cursor: true):`},{role:"system",content:JSON.stringify(e.markdownBlocks)},{role:"system",content:"The user asks you to do the following:"},{role:"user",content:e.userPrompt},{role:"system",content:'First, determine what part of the document the user is talking about. You SHOULD probably take cursor info into account if needed.\n EXAMPLE: if user says "below" (without pointing to a specific part of the document) he / she probably indicates the block(s) after the cursor. \n EXAMPLE: If you want to insert content AT the cursor position (UNLESS indicated otherwise by the user), then you need `referenceId` to point to the block before the cursor with position `after` (or block below and `before`).\n \n Prefer updating blocks over adding or removing (but this also depends on the user\'s question).'}]}const Nt=async(e,t)=>{if(t.selectedBlocks){const o=await $e(e,{selectedBlocks:t.selectedBlocks});return Lt({...o,userPrompt:t.userPrompt})}else{const o=await Re(e,t);return Et({...o,userPrompt:t.userPrompt})}};async function ke(e,t){const o=J(t),r=await t.blocksToMarkdownLossy([T.getBlock(o.doc,e)]),n=await t.tryParseMarkdownToBlocks(r),s=G({id:e,block:n[0]},o.doc),a=new C.Mapping;for(const i of s){const c=i.map(a);if(!c)throw new Error("Failed to map step");o.step(c),a.appendMap(c.getMap())}return V(t,o)}function be(e){return typeof e!="string"?{ok:!1,error:"block must be a string"}:{ok:!0,value:e}}const te={add:se({description:"Insert new blocks",schema:{block:{$ref:"#/$defs/block"},$defs:{block:{type:"string",description:"markdown of block"}}},validateBlock:be,rebaseTool:ke,toJSONToolCall:async(e,t)=>{const o=await Promise.all(t.operation.blocks.map(async r=>{const n=(await e.tryParseMarkdownToBlocks(r.trim()))[0];return delete n.id,n}));return window.__TEST_OPTIONS&&(window.__TEST_OPTIONS.mockID=void 0),{...t.operation,blocks:o}}}),update:ie({description:"Update a block, the new block will replace the existing block.",schema:{block:{$ref:"#/$defs/block"},$defs:{block:{type:"string",description:"markdown of block"}}},validateBlock:be,rebaseTool:ke,toJSONToolCall:async(e,t)=>{const o=(await e.tryParseMarkdownToBlocks(t.operation.block.trim()))[0];return delete o.id,window.__TEST_OPTIONS&&(window.__TEST_OPTIONS.mockID=void 0),{...t.operation,block:o}}}),delete:ae};function At(e,t,o,r){const n={add:!0,update:!0,delete:!0,...o};return[...n.update?[te.update(e,{idsSuffixed:!0,withDelays:t,updateSelection:r})]:[],...n.add?[te.add(e,{idsSuffixed:!0,withDelays:t})]:[],...n.delete?[te.delete(e,{idsSuffixed:!0,withDelays:t})]:[]]}const jt={getStreamTools:At,defaultPromptBuilder:Nt,promptHelpers:{getDataForPromptNoSelection:Re,getDataForPromptWithSelection:$e}},Dt={addCursorPosition:Y,flattenBlocks:P,suffixIDs:N,trimEmptyBlocks:E,convertBlocks:x},qe={_experimental_json:_t,_experimental_markdown:jt,html:Le},Se=new q.PluginKey("blocknote-agent-cursor");function Rt(e){return new q.Plugin({key:Se,view:t=>({}),state:{init:()=>({selection:void 0}),apply:(t,o)=>{const r=t.getMeta("aiAgent");return r?{selection:r.selection}:{selection:void 0}}},props:{decorations:t=>{const{doc:o}=t,{selection:r}=Se.getState(t),n=[];if(!r)return z.DecorationSet.create(o,[]);n.push(z.Decoration.widget(r.head,()=>$t(e),{key:"agent-cursor",side:10}));const s=Math.min(r.anchor,r.head),a=Math.max(r.anchor,r.head);return n.push(z.Decoration.inline(s,a,Qe.defaultSelectionBuilder(e),{inclusiveEnd:!0,inclusiveStart:!1})),z.DecorationSet.create(o,n)}}})}const $t=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 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),o.insertBefore(r,null),t.insertBefore(document.createTextNode(""),null),t.insertBefore(o,null),t.insertBefore(document.createTextNode(""),null),t},qt=new q.PluginKey("blocknote-ai-plugin");class ce extends T.BlockNoteExtension{constructor(o,r){super();U(this,"previousRequestOptions");U(this,"_store",de()(o=>({aiMenuState:"closed"})));U(this,"options");this.editor=o,this.options=de()(n=>({dataFormat:qe.html,stream:!0,...r})),this.addProsemirrorPlugin(new q.Plugin({key:qt,filterTransaction:n=>{var a;const s=this.store.getState().aiMenuState;return!(s!=="closed"&&s.status==="ai-writing"&&(a=n.getMeta(Ke.fixTablesKey))!=null&&a.fixTables)}})),this.addProsemirrorPlugin(D.suggestChanges()),this.addProsemirrorPlugin(Rt(r.agentCursor||{name:"AI",color:"#8bc6ff"}))}static key(){return"ai"}get store(){return this._store}openAIMenuAtBlock(o){this.editor.setForceSelectionVisible(!0),this.editor.isEditable=!1,this._store.setState({aiMenuState:{blockId:o,status:"user-input"}})}closeAIMenu(){this.previousRequestOptions=void 0,this._store.setState({aiMenuState:"closed",llmResponse:void 0}),this.editor.setForceSelectionVisible(!1),this.editor.isEditable=!0,this.editor.focus()}acceptChanges(){var r;const o=this.editor.prosemirrorState.doc;this.editor.exec((n,s)=>D.revertSuggestions(n,a=>{s==null||s(a.setMeta("addToHistory",!1))})),this.editor.exec((n,s)=>{const a=n.tr;a.replace(0,a.doc.content.size,new R.Slice(R.Fragment.from(o),0,0));const i=n.apply(a);return D.applySuggestions(i,c=>{s==null||s(a.replace(0,a.doc.content.size,new R.Slice(R.Fragment.from(c.doc),0,0)))})}),(r=this.editor.forkYDocPlugin)==null||r.merge({keepChanges:!0}),this.closeAIMenu()}rejectChanges(){var o;this.editor.exec((r,n)=>D.revertSuggestions(r,s=>{n==null||n(s.setMeta("addToHistory",!1))})),(o=this.editor.forkYDocPlugin)==null||o.merge({keepChanges:!1}),this.closeAIMenu()}async retry(){const o=this.store.getState().aiMenuState;if(o==="closed"||o.status!=="error"||!this.previousRequestOptions)throw new Error("retry() is only valid when a previous response failed");if(o.error instanceof j.APICallError||o.error instanceof j.RetryError)return this.callLLM(this.previousRequestOptions);{const r=o.error instanceof Error?o.error.message:String(o.error);return this.callLLM({userPrompt:`An error occured: ${r}
|
|
19
19
|
Please retry the previous user request.`})}}setAIResponseStatus(o){const r=this.store.getState().aiMenuState;if(r!=="closed")if(o==="ai-writing"&&this.editor.setForceSelectionVisible(!1),typeof o=="object"){if(o.status!=="error")throw new T.UnreachableCaseError(o.status);this._store.setState({aiMenuState:{status:o.status,error:o.error,blockId:r.blockId}})}else this._store.setState({aiMenuState:{status:o,blockId:r.blockId}})}async callLLM(o){var n;this.setAIResponseStatus("thinking"),(n=this.editor.forkYDocPlugin)==null||n.fork();let r;try{const s={...this.options.getState(),...o,previousResponse:this.store.getState().llmResponse};this.previousRequestOptions=s,r=await Ee(this.editor,{...s,onStart:()=>{var a;this.setAIResponseStatus("ai-writing"),(a=o.onStart)==null||a.call(o)},onBlockUpdate:a=>{var i;this._store.setState({aiMenuState:{blockId:a,status:"ai-writing"}}),(i=o.onBlockUpdate)==null||i.call(o,a)}}),this._store.setState({llmResponse:r}),await r.execute(),this.setAIResponseStatus("user-reviewing")}catch(s){this.setAIResponseStatus({status:"error",error:s}),console.warn("Error calling LLM",s)}return r}}function Ht(e){return t=>new ce(t,e)}function I(e){return e.extension(ce)}const Ut=(e,t)=>async(o,r)=>{const n=new Request(o,r),s=new Request(`${e}?provider=${encodeURIComponent(t)}&url=${encodeURIComponent(n.url)}`,{headers:n.headers,body:(r==null?void 0:r.body)||n.body,method:n.method,duplex:"half"});try{return await fetch(s)}catch(a){throw new TypeError("fetch failed",{cause:a})}};function zt(e){return{getProviderSettings:t=>({apiKey:e.apiKey,fetch:Ut(e.baseURL,t)})}}var He={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},we=L.default.createContext&&L.default.createContext(He),Ft=["attr","size","title"];function Jt(e,t){if(e==null)return{};var o=Vt(e,t),r,n;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n<s.length;n++)r=s[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function Vt(e,t){if(e==null)return{};var o={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;o[r]=e[r]}return o}function Z(){return Z=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},Z.apply(this,arguments)}function Te(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),o.push.apply(o,r)}return o}function W(e){for(var t=1;t<arguments.length;t++){var o=arguments[t]!=null?arguments[t]:{};t%2?Te(Object(o),!0).forEach(function(r){Zt(e,r,o[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):Te(Object(o)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(o,r))})}return e}function Zt(e,t,o){return t=Wt(t),t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function Wt(e){var t=Yt(e,"string");return typeof t=="symbol"?t:t+""}function Yt(e,t){if(typeof e!="object"||!e)return e;var o=e[Symbol.toPrimitive];if(o!==void 0){var r=o.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ue(e){return e&&e.map((t,o)=>L.default.createElement(t.tag,W({key:o},t.attr),Ue(t.child)))}function O(e){return t=>L.default.createElement(Gt,Z({attr:W({},e.attr)},t),Ue(e.child))}function Gt(e){var t=o=>{var{attr:r,size:n,title:s}=e,a=Jt(e,Ft),i=n||o.size||"1em",c;return o.className&&(c=o.className),e.className&&(c=(c?c+" ":"")+e.className),L.default.createElement("svg",Z({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},o.attr,r,a,{className:c,style:W(W({color:e.color||o.color},o.style),e.style),height:i,width:i,xmlns:"http://www.w3.org/2000/svg"}),s&&L.default.createElement("title",null,s),e.children)};return we!==void 0?L.default.createElement(we.Consumer,null,o=>t(o)):t(He)}function ze(e){return O({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 ve(e){return O({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 Kt(e){return O({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 Xt(e){return O({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 Qt(e){return O({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 eo(e){return O({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M13 6V21H11V6H5V4H19V6H13Z"},child:[]}]})(e)}function to(e){return O({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 oo(e){return O({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 ro(e){return O({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 no(e){return O({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 le(e){return O({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 A(e){if(!e.dictionary.ai)throw new Error("AI dictionary not found");return e.dictionary.ai}function Fe(){const e=B.useBlockNoteContext();return A(e.editor)}const Je=e=>{const t=B.useComponentsContext(),{onManualPromptSubmit:o,promptText:r,onPromptTextChange:n}=e,[s,a]=v.useState(""),i=r||s,c=v.useCallback(async d=>{d.key==="Enter"&&o(i)},[i,o]),u=v.useCallback(d=>{const S=d.currentTarget.value;n&&n(S),r===void 0&&a(S)},[n,a,r]),f=v.useMemo(()=>T.filterSuggestionItems(e.items,i),[i,e.items]),{selectedIndex:l,setSelectedIndex:m,handler:p}=B.useSuggestionMenuKeyboardHandler(f,d=>d.onItemClick()),h=v.useCallback(d=>{d.key==="Enter"?f.length>0?p(d):c(d):p(d)},[c,p,f.length]);return v.useEffect(()=>{m(0)},[i,m]),y.jsxs("div",{className:"bn-combobox",children:[y.jsx(t.Generic.Form.Root,{children:y.jsx(t.Generic.Form.TextInput,{className:"bn-combobox-input",name:"ai-prompt",variant:"large",icon:e.icon,value:i||"",autoFocus:!0,placeholder:e.placeholder,disabled:e.disabled,onKeyDown:h,onChange:u,autoComplete:"off",rightSection:e.rightSection},"input-"+e.disabled)}),y.jsx(t.SuggestionMenu.Root,{className:"bn-combobox-items",id:"ai-suggestion-menu",children:f.map((d,S)=>y.jsx(t.SuggestionMenu.Item,{className:T.mergeCSSClasses("bn-suggestion-menu-item",d.size==="small"?"bn-suggestion-menu-item-small":""),id:`bn-suggestion-menu-item-${S}`,isSelected:S===l,onClick:d.onItemClick,item:d},d.title))})]})};function so(e){const t=A(e),o=I(e);return[{key:"continue_writing",title:t.ai_default_commands.continue_writing.title,aliases:t.ai_default_commands.continue_writing.aliases,icon:y.jsx(ve,{size:18}),onItemClick:async()=>{await o.callLLM({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.",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:y.jsx(Qt,{size:18}),onItemClick:async()=>{await o.callLLM({userPrompt:"Summarize",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:y.jsx(Xt,{size:18}),onItemClick:async()=>{await o.callLLM({userPrompt:"Add action items",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:y.jsx(ve,{size:18}),onItemClick:r=>{r(t.ai_default_commands.write_anything.prompt_placeholder)},size:"small"}]}function io(e){const t=A(e),o=I(e);return[{key:"improve_writing",title:t.ai_default_commands.improve_writing.title,aliases:t.ai_default_commands.improve_writing.aliases,icon:y.jsx(eo,{size:18}),onItemClick:async()=>{await o.callLLM({useSelection:!0,userPrompt:"Improve writing",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:y.jsx(ro,{size:18}),onItemClick:async()=>{await o.callLLM({useSelection:!0,userPrompt:"Fix spelling",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:y.jsx(to,{size:18}),onItemClick:r=>{r(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:y.jsx(Kt,{size:18}),onItemClick:async()=>{await o.callLLM({useSelection:!0,userPrompt:"Simplify",defaultStreamTools:{add:!1,delete:!1,update:!0}})},size:"small"}]}function ao(e){const t=A(e),o=I(e);return[{key:"accept",title:t.ai_menu.actions.accept.title,aliases:t.ai_menu.actions.accept.aliases,icon:y.jsx(oo,{size:18}),onItemClick:()=>{o.acceptChanges()},size:"small"},{key:"revert",title:t.ai_menu.actions.revert.title,aliases:t.ai_menu.actions.revert.aliases,icon:y.jsx(ze,{size:18}),onItemClick:()=>{o.rejectChanges()},size:"small"}]}function co(e){const t=A(e),o=I(e);return[{key:"retry",title:t.ai_menu.actions.retry.title,aliases:t.ai_menu.actions.retry.aliases,icon:y.jsx(no,{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:y.jsx(ze,{size:18}),onItemClick:()=>{o.rejectChanges()},size:"small"}]}function Ve(e,t){return t==="user-input"?e.getSelection()?io(e):so(e):t==="user-reviewing"?ao(e):t==="error"?co(e):[]}const Ze=e=>{const t=B.useBlockNoteEditor(),[o,r]=v.useState(""),n=Fe(),s=B.useComponentsContext(),a=I(t),i=Ce.useStore(a.store,p=>p.aiMenuState!=="closed"?p.aiMenuState.status:"closed"),{items:c}=e,u=v.useMemo(()=>{let p=[];return c?p=c(t,i):p=Ve(t,i),p.map(h=>({...h,onItemClick:()=>{h.onItemClick(r)}}))},[c,i,t]),f=v.useCallback(async p=>{await a.callLLM({userPrompt:p,useSelection:t.getSelection()!==void 0})},[a,t]);v.useEffect(()=>{(i==="user-reviewing"||i==="error")&&r("")},[i]);const l=v.useMemo(()=>i==="thinking"?n.ai_menu.status.thinking:i==="ai-writing"?n.ai_menu.status.editing:i==="error"?n.ai_menu.status.error:n.ai_menu.input_placeholder,[i,n]),m=v.useMemo(()=>{if(i==="thinking"||i==="ai-writing")return y.jsx(s.SuggestionMenu.Loader,{className:"bn-suggestion-menu-loader bn-combobox-right-section"});if(i==="error")return y.jsx("div",{className:"bn-combobox-right-section bn-combobox-error",children:y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",fill:"currentColor",children:y.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"})})})},[s,i]);return y.jsx(Je,{onManualPromptSubmit:e.onManualPromptSubmit||f,items:u,promptText:o,onPromptTextChange:r,placeholder:l,disabled:i==="thinking"||i==="ai-writing",icon:y.jsx("div",{className:"bn-combobox-icon",children:y.jsx(le,{})}),rightSection:m})},We=e=>{const t=e.blockID?document.querySelector(`[data-id="${e.blockID}"]`):void 0,o=v.useMemo(()=>t?{getBoundingClientRect:()=>t.getBoundingClientRect(),contextElement:t}:null,[t]),{isMounted:r,ref:n,style:s,getFloatingProps:a,isPositioned:i}=B.useUIElementPositioning(!!t,o,3e3,{canDismiss:{enabled:!0,escapeKey:!0,outsidePress:e.canDismissViaOutsidePress},placement:"bottom",middleware:[X.offset(10),X.size({apply({rects:c,elements:u}){Object.assign(u.floating.style,{width:`${c.reference.width}px`})}})],onOpenChange:e.onOpenChange,whileElementsMounted:(c,u,f)=>X.autoUpdate(c,u,f,{animationFrame:!0}),...e.floatingOptions});return r?y.jsx("div",{ref:n,style:{...s},...a(),children:i&&e.children}):null},lo=e=>{const t=B.useBlockNoteEditor(),o=I(t),r=Ce.useStore(o.store,a=>a.aiMenuState),n=r==="closed"?void 0:r.blockId,s=e.aiMenu||Ze;return y.jsx(We,{canDismissViaOutsidePress:r==="closed"||r.status==="user-input",blockID:n,onOpenChange:a=>{a||r==="closed"||(r.status==="user-input"?o.closeAIMenu():(r.status==="user-reviewing"||r.status==="error")&&o.rejectChanges())},children:y.jsx(s,{})})},uo=()=>{const e=Fe(),t=B.useComponentsContext(),o=B.useBlockNoteEditor(),r=I(o),n=()=>{o.formattingToolbar.closeMenu();const s=o.getSelection();if(!s)throw new Error("No selection");const a=s.blocks[s.blocks.length-1].id;r.openAIMenuAtBlock(a)};return o.isEditable?y.jsx(t.Generic.Toolbar.Button,{className:"bn-button",label:e.formatting_toolbar.ai.tooltip,mainTooltip:e.formatting_toolbar.ai.tooltip,icon:y.jsx(le,{}),onClick:n}):null},po={AI:le};function fo(e){const t=I(e);return[{key:"ai",onItemClick:()=>{const r=e.getTextCursorPosition();r.block.content&&Array.isArray(r.block.content)&&r.block.content.length===0&&r.prevBlock?t.openAIMenuAtBlock(r.prevBlock.id):t.openAIMenuAtBlock(r.block.id)},...A(e).slash_menu.ai,icon:y.jsx(po.AI,{})}]}exports.AIExtension=ce;exports.AIMenu=Ze;exports.AIMenuController=lo;exports.AIToolbarButton=uo;exports.BlockPositioner=We;exports.PromptSuggestionMenu=Je;exports.callLLM=Ee;exports.createAIExtension=Ht;exports.createBlockNoteAIClient=zt;exports.getAIDictionary=A;exports.getAIExtension=I;exports.getAISlashMenuItems=fo;exports.getDefaultAIMenuItems=Ve;exports.llmFormats=qe;exports.promptHelpers=Dt;
|
|
20
20
|
//# sourceMappingURL=blocknote-xl-ai.cjs.map
|