@kinetis/vector-ui 0.12.4 → 0.13.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/CHANGELOG.md +97 -3
- package/README.md +13 -5
- package/app/components/Vx/Cell/Markdown.vue +1 -1
- package/app/components/Vx/Cell/RichText.vue +1 -1
- package/app/components/Vx/CommandPalette.vue +16 -2
- package/app/components/Vx/FieldsForm.vue +10 -2
- package/app/components/Vx/Input/KeyValue.vue +2 -2
- package/app/components/Vx/Input/Markdown.vue +5 -0
- package/app/components/Vx/Input/Money.vue +1 -1
- package/app/components/Vx/Input/RichText.vue +6 -1
- package/app/components/Vx/Input/Text.vue +18 -2
- package/app/components/Vx/Input/Textarea.vue +19 -2
- package/app/components/Vx/InputAddons.vue +45 -0
- package/app/components/Vx/Layout.vue +1 -1
- package/app/components/Vx/List/Pager.vue +1 -1
- package/app/components/Vx/List/ViewMenu.vue +1 -1
- package/app/components/Vx/Queues/Failed.vue +2 -2
- package/app/components/Vx/Queues/FailedDetail.vue +2 -2
- package/app/components/Vx/Queues/Metrics.vue +1 -1
- package/app/components/Vx/Queues/Overview.vue +2 -2
- package/app/components/Vx/Resource/Audit.vue +4 -0
- package/app/components/Vx/Resource/Form.vue +9 -1
- package/app/components/Vx/Resource/RelationPanel.vue +1 -1
- package/app/components/Vx/Resource/Table.vue +25 -2
- package/app/components/Vx/Widget/Card.vue +2 -2
- package/app/components/VxAi/ApprovalCard.vue +115 -0
- package/app/components/VxAi/Assistant.vue +190 -0
- package/app/components/VxAi/Credentials.vue +111 -0
- package/app/components/VxAi/FilterAsk.vue +176 -0
- package/app/components/VxAi/WritingAddon.vue +127 -0
- package/app/components/VxAi/WritingMenu.vue +91 -0
- package/app/components/VxAi/WritingResult.vue +48 -0
- package/app/components/VxAi/WritingToolbarItem.vue +189 -0
- package/app/composables/useConfirm.ts +1 -1
- package/app/composables/useVectorApi.ts +4 -4
- package/app/composables/useVectorAssistant.ts +318 -0
- package/app/composables/useVectorAuthStore.ts +1 -1
- package/app/composables/useVectorExtend.ts +157 -0
- package/app/composables/useVectorExtensions.ts +64 -6
- package/app/composables/useVectorFields.ts +1 -1
- package/app/composables/useVectorIdle.ts +1 -1
- package/app/composables/useVectorLocale.ts +2 -2
- package/app/composables/useVectorSchema.ts +1 -1
- package/app/composables/useVectorVersion.ts +2 -2
- package/app/composables/useVectorWriting.ts +72 -0
- package/app/i18n/ar/ai.ts +93 -0
- package/app/i18n/ar/index.ts +2 -1
- package/app/i18n/ar/record.ts +4 -0
- package/app/i18n/ar/shell.ts +1 -0
- package/app/i18n/de/ai.ts +93 -0
- package/app/i18n/de/index.ts +2 -1
- package/app/i18n/de/record.ts +4 -0
- package/app/i18n/de/shell.ts +1 -0
- package/app/i18n/en/ai.ts +93 -0
- package/app/i18n/en/index.ts +2 -1
- package/app/i18n/en/record.ts +4 -0
- package/app/i18n/en/shell.ts +1 -0
- package/app/i18n/es/ai.ts +93 -0
- package/app/i18n/es/index.ts +2 -1
- package/app/i18n/es/record.ts +4 -0
- package/app/i18n/es/shell.ts +1 -0
- package/app/i18n/fr/ai.ts +93 -0
- package/app/i18n/fr/index.ts +2 -1
- package/app/i18n/fr/record.ts +4 -0
- package/app/i18n/fr/shell.ts +1 -0
- package/app/i18n/he/ai.ts +93 -0
- package/app/i18n/he/index.ts +2 -1
- package/app/i18n/he/record.ts +4 -0
- package/app/i18n/he/shell.ts +1 -0
- package/app/i18n/index.ts +1 -1
- package/app/i18n/it/ai.ts +93 -0
- package/app/i18n/it/index.ts +2 -1
- package/app/i18n/it/record.ts +4 -0
- package/app/i18n/it/shell.ts +1 -0
- package/app/i18n/ja/ai.ts +93 -0
- package/app/i18n/ja/index.ts +2 -1
- package/app/i18n/ja/record.ts +4 -0
- package/app/i18n/ja/shell.ts +1 -0
- package/app/i18n/ko/ai.ts +93 -0
- package/app/i18n/ko/index.ts +2 -1
- package/app/i18n/ko/record.ts +4 -0
- package/app/i18n/ko/shell.ts +1 -0
- package/app/i18n/nl/ai.ts +93 -0
- package/app/i18n/nl/index.ts +2 -1
- package/app/i18n/nl/record.ts +4 -0
- package/app/i18n/nl/shell.ts +1 -0
- package/app/i18n/pl/ai.ts +93 -0
- package/app/i18n/pl/index.ts +2 -1
- package/app/i18n/pl/record.ts +4 -0
- package/app/i18n/pl/shell.ts +1 -0
- package/app/i18n/pt/ai.ts +93 -0
- package/app/i18n/pt/index.ts +2 -1
- package/app/i18n/pt/record.ts +4 -0
- package/app/i18n/pt/shell.ts +1 -0
- package/app/i18n/pt-BR/ai.ts +93 -0
- package/app/i18n/pt-BR/index.ts +2 -1
- package/app/i18n/pt-BR/record.ts +4 -0
- package/app/i18n/pt-BR/shell.ts +1 -0
- package/app/i18n/ru/ai.ts +93 -0
- package/app/i18n/ru/index.ts +2 -1
- package/app/i18n/ru/record.ts +4 -0
- package/app/i18n/ru/shell.ts +1 -0
- package/app/i18n/tr/ai.ts +93 -0
- package/app/i18n/tr/index.ts +2 -1
- package/app/i18n/tr/record.ts +4 -0
- package/app/i18n/tr/shell.ts +1 -0
- package/app/i18n/uk/ai.ts +93 -0
- package/app/i18n/uk/index.ts +2 -1
- package/app/i18n/uk/record.ts +4 -0
- package/app/i18n/uk/shell.ts +1 -0
- package/app/i18n/zh-Hans/ai.ts +93 -0
- package/app/i18n/zh-Hans/index.ts +2 -1
- package/app/i18n/zh-Hans/record.ts +4 -0
- package/app/i18n/zh-Hans/shell.ts +1 -0
- package/app/layouts/vector.vue +4 -1
- package/app/pages/settings.vue +7 -1
- package/app/plugins/vector-ai.client.ts +54 -0
- package/app/plugins/vector-extensions.client.ts +28 -37
- package/app/types/vector.ts +40 -3
- package/app/utils/aiAvailability.ts +55 -0
- package/app/utils/assistantBody.ts +69 -0
- package/app/utils/assistantStream.ts +133 -0
- package/app/utils/assistantTools.ts +45 -0
- package/app/utils/followScroll.ts +110 -0
- package/app/utils/format.ts +3 -3
- package/app/utils/internal/paths.ts +1 -1
- package/app/utils/queues.ts +1 -1
- package/app/utils/recordLinks.ts +45 -0
- package/app/utils/richtext.ts +3 -3
- package/app/utils/translate.ts +2 -2
- package/dist/static/200.html +1 -1
- package/dist/static/404.html +1 -1
- package/dist/static/_nuxt/-ksGenLl.js +1 -0
- package/dist/static/_nuxt/{DDJY3JL5.js → 0Q9tQaGZ.js} +1 -1
- package/dist/static/_nuxt/2mrvZCJz.js +3 -0
- package/dist/static/_nuxt/{C2PH7r9_.js → 2u7wMpR1.js} +1 -1
- package/dist/static/_nuxt/72BATg3-.js +1 -0
- package/dist/static/_nuxt/{BKtgreqG.js → 7hLwEPpo.js} +1 -1
- package/dist/static/_nuxt/{D5vg-NJ4.js → 7rwxDW6j.js} +1 -1
- package/dist/static/_nuxt/{Pj99sh0X.js → AbcTnLPe.js} +1 -1
- package/dist/static/_nuxt/B-b861aP.js +1 -0
- package/dist/static/_nuxt/{Cuw0JSbz.js → B2rZ5lwu.js} +1 -1
- package/dist/static/_nuxt/B4hfz7cN.js +1 -0
- package/dist/static/_nuxt/B65UlNtP.js +1 -0
- package/dist/static/_nuxt/{oThorgNS.js → B8JL5gwX.js} +1 -1
- package/dist/static/_nuxt/{D5Woe3YR.js → B8wNbnS0.js} +1 -1
- package/dist/static/_nuxt/{BDM1yKDf.js → B9FqenNL.js} +1 -1
- package/dist/static/_nuxt/{wLSd0d84.js → B9s6vEby.js} +1 -1
- package/dist/static/_nuxt/BE6e_jlD.js +1 -0
- package/dist/static/_nuxt/{Dx8sj9kP.js → BFZfZyte.js} +1 -1
- package/dist/static/_nuxt/{Dnl_Q9LX.js → BJSRjsBt.js} +1 -1
- package/dist/static/_nuxt/{lRmDd_Kx.js → BJh6qVAK.js} +1 -1
- package/dist/static/_nuxt/{DBmDhhWl.js → BJxaGigr.js} +1 -1
- package/dist/static/_nuxt/{CmoDOC5e.js → BL2SeM_r.js} +1 -1
- package/dist/static/_nuxt/BPT7yI6j.js +1 -0
- package/dist/static/_nuxt/BQ47h6Wh.js +1 -0
- package/dist/static/_nuxt/{CalcRVj7.js → BQitPbA5.js} +1 -1
- package/dist/static/_nuxt/{D9unnd4n.js → BSj4WTjT.js} +1 -1
- package/dist/static/_nuxt/{D3cKZbMy.js → BVrihF-G.js} +1 -1
- package/dist/static/_nuxt/BW9qBvMR.js +1 -0
- package/dist/static/_nuxt/{DU1KpHiJ.js → BWscDCZb.js} +1 -1
- package/dist/static/_nuxt/{JGAhx20W.js → BXnWvqRw.js} +1 -1
- package/dist/static/_nuxt/BcSEGymu.js +2 -0
- package/dist/static/_nuxt/Bj-QksVr.js +2 -0
- package/dist/static/_nuxt/{CvMhFq5K.js → Bl4F_9Di.js} +1 -1
- package/dist/static/_nuxt/{BRbbmSpl.js → BowgCQje.js} +1 -1
- package/dist/static/_nuxt/{DgVB5umK.js → BuTE4a2w.js} +1 -1
- package/dist/static/_nuxt/Bw6FrC2B.js +1 -0
- package/dist/static/_nuxt/{Cv0_BbF0.js → Byf6uyFv.js} +1 -1
- package/dist/static/_nuxt/Bzvft7RG.js +1 -0
- package/dist/static/_nuxt/C1y0neXX.js +1 -0
- package/dist/static/_nuxt/{BUF7Jq4U.js → C48zuAYh.js} +1 -1
- package/dist/static/_nuxt/{DJFQLDk5.js → C52FYB-5.js} +1 -1
- package/dist/static/_nuxt/CAXk9Oc1.js +1 -0
- package/dist/static/_nuxt/{C7fSyjDf.js → CD5zJmlk.js} +1 -1
- package/dist/static/_nuxt/CDnV5Q2S.js +2 -0
- package/dist/static/_nuxt/{CzTUD5Qk.js → CE5HzlKJ.js} +1 -1
- package/dist/static/_nuxt/{7K6MnLUx.js → CF_C4t63.js} +1 -1
- package/dist/static/_nuxt/CFuvN8kq.js +1 -0
- package/dist/static/_nuxt/{CqMf6Lsu.js → CHIGMs2v.js} +1 -1
- package/dist/static/_nuxt/CIcNJyjb.js +1 -0
- package/dist/static/_nuxt/{Dyz4VrUP.js → CLJSzUt5.js} +1 -1
- package/dist/static/_nuxt/CQvUQgZO.js +2 -0
- package/dist/static/_nuxt/{N6Uxr2YO.js → CRAHgjs4.js} +1 -1
- package/dist/static/_nuxt/{B6NDob-m.js → CSezMYzn.js} +1 -1
- package/dist/static/_nuxt/{B7CwuqHQ.js → CSgLLbCN.js} +1 -1
- package/dist/static/_nuxt/{1EmobxKy.js → CTHBH7-N.js} +1 -1
- package/dist/static/_nuxt/CVGEoUmj.js +1 -0
- package/dist/static/_nuxt/{bm6plv74.js → CVePRzEp.js} +1 -1
- package/dist/static/_nuxt/{R3rw3hPp.js → CWfptrnU.js} +1 -1
- package/dist/static/_nuxt/{C1djf5sc.js → CXSf4TOH.js} +1 -1
- package/dist/static/_nuxt/CbOoWXps.js +1 -0
- package/dist/static/_nuxt/Cf2NM87n.js +1 -0
- package/dist/static/_nuxt/{ycmL3bWs.js → CjYmnU-l.js} +1 -1
- package/dist/static/_nuxt/Ckm05LT2.js +1 -0
- package/dist/static/_nuxt/{DHtEcXUO.js → Cl2jXKkl.js} +1 -1
- package/dist/static/_nuxt/{CF1K6UXb.js → Clx69IQe.js} +1 -1
- package/dist/static/_nuxt/{BZDOVMsw.js → CmJ0ekjX.js} +1 -1
- package/dist/static/_nuxt/{Cjyh4OAN.js → Cpel4vlt.js} +1 -1
- package/dist/static/_nuxt/{CUAnR2FD.js → CrYfHi9E.js} +1 -1
- package/dist/static/_nuxt/CvTgOEOS.js +1 -0
- package/dist/static/_nuxt/CvVbTdaI.js +1 -0
- package/dist/static/_nuxt/{DoNlTJTo.js → D2ovGjnz.js} +1 -1
- package/dist/static/_nuxt/{BOHl_j0c.js → D3cIKCPa.js} +1 -1
- package/dist/static/_nuxt/{CvtjhXJ1.js → D3jC5ZAK.js} +1 -1
- package/dist/static/_nuxt/{FzhpMR1D.js → D3xofh1k.js} +1 -1
- package/dist/static/_nuxt/{BfuFZvSA.js → D7dC5VYH.js} +1 -1
- package/dist/static/_nuxt/{DfVLYfcR.js → D7eR_J9I.js} +1 -1
- package/dist/static/_nuxt/DAXm0JlI.js +1 -0
- package/dist/static/_nuxt/DDsQjoa8.js +1 -0
- package/dist/static/_nuxt/DFIqxsd4.js +1 -0
- package/dist/static/_nuxt/DGQrzV9s.js +1 -0
- package/dist/static/_nuxt/{1_Uuyt8D.js → DHNZ4ANp.js} +1 -1
- package/dist/static/_nuxt/{AXpHq_M6.js → DKOyYUi8.js} +1 -1
- package/dist/static/_nuxt/DOEj9Txc.js +1 -0
- package/dist/static/_nuxt/{CJepLjEa.js → DOq2YmIE.js} +1 -1
- package/dist/static/_nuxt/DOxWca9k.js +1 -0
- package/dist/static/_nuxt/{D7JW3pi_.js → DVyeIIya.js} +1 -1
- package/dist/static/_nuxt/{DT1zmKvw.js → DW3p59oX.js} +1 -1
- package/dist/static/_nuxt/{ERkvasWH.js → DXZAXwNd.js} +1 -1
- package/dist/static/_nuxt/{D11OKveI.js → DYPYEI74.js} +1 -1
- package/dist/static/_nuxt/D_hQWjK3.js +1 -0
- package/dist/static/_nuxt/{ZNfE-M4g.js → Dao3p0cp.js} +1 -1
- package/dist/static/_nuxt/{D3xqGGYp.js → DcC5rHQt.js} +1 -1
- package/dist/static/_nuxt/DdYMnBKs.js +1 -0
- package/dist/static/_nuxt/{DOOLWZFN.js → DeZyAt_3.js} +1 -1
- package/dist/static/_nuxt/DfApYreK.js +10 -0
- package/dist/static/_nuxt/{BEcvuouq.js → DjRWYJ_r.js} +1 -1
- package/dist/static/_nuxt/{DqVTouT1.js → DllQuWrz.js} +1 -1
- package/dist/static/_nuxt/DpWwaWd-.js +185 -0
- package/dist/static/_nuxt/DryMzf1V.js +1 -0
- package/dist/static/_nuxt/{BEu939QZ.js → DsLys5JK.js} +1 -1
- package/dist/static/_nuxt/DvEvjhbF.js +1 -0
- package/dist/static/_nuxt/{B1lIMV_o.js → Dw7WalTb.js} +1 -1
- package/dist/static/_nuxt/{Dqv1iAUt.js → DwpSsR4l.js} +1 -1
- package/dist/static/_nuxt/FfebEZGy.js +1 -0
- package/dist/static/_nuxt/{DPDZkh6Z.js → GdAHGVsW.js} +1 -1
- package/dist/static/_nuxt/{qFGHTGtX.js → HdAGfEVj.js} +1 -1
- package/dist/static/_nuxt/{CsakM5cG.js → IxgCkjBe.js} +1 -1
- package/dist/static/_nuxt/{BJiySRJW.js → Jl8QPdwt.js} +1 -1
- package/dist/static/_nuxt/{4_OCizmC.js → KWfizXHd.js} +1 -1
- package/dist/static/_nuxt/KeyValue.CWzmqYlQ.css +1 -0
- package/dist/static/_nuxt/Notifications.CAlaWnJg.css +1 -0
- package/dist/static/_nuxt/PqTF-5Vs.js +1 -0
- package/dist/static/_nuxt/SacKuioS.js +65 -0
- package/dist/static/_nuxt/TlyrWgih.js +1 -0
- package/dist/static/_nuxt/{oj_DzV60.js → WAarVmAq.js} +1 -1
- package/dist/static/_nuxt/{DcWEOxVe.js → XnbMqODk.js} +1 -1
- package/dist/static/_nuxt/{R_5D07UV.js → Y2iAEIYr.js} +1 -1
- package/dist/static/_nuxt/_resource_.Q2lVCG-n.css +1 -0
- package/dist/static/_nuxt/{BSj7_50x.js → b2bdl3qT.js} +1 -1
- package/dist/static/_nuxt/bNqxxQg2.js +1 -0
- package/dist/static/_nuxt/builds/latest.json +1 -1
- package/dist/static/_nuxt/builds/meta/f78103ad-2489-4aee-b300-160bb1a81e35.json +1 -0
- package/dist/static/_nuxt/{yO0LqdZ2.js → e2dpeiRT.js} +1 -1
- package/dist/static/_nuxt/{entry.DmwuXgFN.css → entry.CANiyyNa.css} +1 -1
- package/dist/static/_nuxt/error-404.D5YWHu6f.css +1 -0
- package/dist/static/_nuxt/error-500.BP1eYUQR.css +1 -0
- package/dist/static/_nuxt/{CB-gmtNU.js → fLsGnP3B.js} +1 -1
- package/dist/static/_nuxt/gYmJEXHP.js +1 -0
- package/dist/static/_nuxt/{B-nBg1Xv.js → jI4JB4sB.js} +1 -1
- package/dist/static/_nuxt/{DebXB2Xn.js → qoAbHCOq.js} +1 -1
- package/dist/static/_nuxt/rYfJ_RlJ.js +1 -0
- package/dist/static/_nuxt/{CrGsoVt3.js → tGXqY3hN.js} +1 -1
- package/dist/static/_nuxt/{Bk4XXIda.js → tv5vSe5Y.js} +1 -1
- package/dist/static/_nuxt/vector.NgmG3ZDn.css +1 -0
- package/dist/static/_nuxt/{BEX0oVSL.js → wSbLQ3i5.js} +2 -2
- package/dist/static/_nuxt/{0Vkqk5K3.js → y5gvPoD3.js} +1 -1
- package/dist/static/_nuxt/{DyweGZi4.js → yIw8BzU6.js} +1 -1
- package/dist/static/_nuxt/{NTQyXsYJ.js → zA0zNamO.js} +1 -1
- package/dist/static/index.html +1 -1
- package/dist/static/jobs/index.html +1 -1
- package/dist/static/login/index.html +1 -1
- package/dist/static/queues/index.html +1 -1
- package/dist/static/settings/index.html +1 -1
- package/dist/static/vector-bundle.json +148 -152
- package/package.json +19 -18
- package/dist/static/_nuxt/7dnGTtf6.js +0 -2
- package/dist/static/_nuxt/AfaX5CNR.js +0 -105
- package/dist/static/_nuxt/B-KA4dLI.js +0 -65
- package/dist/static/_nuxt/B6S9Z6WQ.js +0 -1
- package/dist/static/_nuxt/BDNMzG2s.js +0 -1
- package/dist/static/_nuxt/BJhRZpbP.js +0 -1
- package/dist/static/_nuxt/BPzr_ZFH.js +0 -1
- package/dist/static/_nuxt/BZXFBS4d.js +0 -1
- package/dist/static/_nuxt/Bp1wYuAu.js +0 -2
- package/dist/static/_nuxt/BpF7UbSy.js +0 -1
- package/dist/static/_nuxt/BqIYBnn1.js +0 -1
- package/dist/static/_nuxt/Brpk64DL.js +0 -1
- package/dist/static/_nuxt/BtZEn8rG.js +0 -1
- package/dist/static/_nuxt/BzcHWzF1.js +0 -1
- package/dist/static/_nuxt/C-dF6TjJ.js +0 -1
- package/dist/static/_nuxt/C0BqlrB-.js +0 -1
- package/dist/static/_nuxt/C6kvBrux.js +0 -1
- package/dist/static/_nuxt/C9pCrKWL.js +0 -1
- package/dist/static/_nuxt/CBIdPVBN.js +0 -1
- package/dist/static/_nuxt/CE4w7ySf.js +0 -1
- package/dist/static/_nuxt/CEq7Sdek.js +0 -1
- package/dist/static/_nuxt/CIIjiec-.js +0 -1
- package/dist/static/_nuxt/CL8kR7Jl.js +0 -1
- package/dist/static/_nuxt/CTqdSnzX.js +0 -1
- package/dist/static/_nuxt/CcarPq9D.js +0 -1
- package/dist/static/_nuxt/Cet_varq.js +0 -1
- package/dist/static/_nuxt/ChHwRItD.js +0 -1
- package/dist/static/_nuxt/ClGaGEq-.js +0 -1
- package/dist/static/_nuxt/CojXjKit.js +0 -1
- package/dist/static/_nuxt/CpCuvz_Q.js +0 -1
- package/dist/static/_nuxt/D-sMWl8f.js +0 -1
- package/dist/static/_nuxt/D1s1ZPEA.js +0 -2
- package/dist/static/_nuxt/D7UGFkhh.js +0 -1
- package/dist/static/_nuxt/D8p7N22I.js +0 -1
- package/dist/static/_nuxt/DBXnb1tR.js +0 -1
- package/dist/static/_nuxt/DL237dS3.js +0 -1
- package/dist/static/_nuxt/DRB_eN3w.js +0 -67
- package/dist/static/_nuxt/Djb5b_0H.js +0 -1
- package/dist/static/_nuxt/DlpIJgqB.js +0 -1
- package/dist/static/_nuxt/DrEHkKjX.js +0 -10
- package/dist/static/_nuxt/Dt7NqY56.js +0 -1
- package/dist/static/_nuxt/DuYZsH0p.js +0 -1
- package/dist/static/_nuxt/Dx-cZwBu.js +0 -2
- package/dist/static/_nuxt/IhWbQWqt.js +0 -1
- package/dist/static/_nuxt/JkGLG92w.js +0 -1
- package/dist/static/_nuxt/KeyValue.CczYMB-Q.css +0 -1
- package/dist/static/_nuxt/Notifications.AEytcgEO.css +0 -1
- package/dist/static/_nuxt/QTRQ5bvA.js +0 -1
- package/dist/static/_nuxt/UoJt16Vw.js +0 -1
- package/dist/static/_nuxt/VSpacer.DfbUir7X.css +0 -1
- package/dist/static/_nuxt/_resource_.CZ-hvn3L.css +0 -1
- package/dist/static/_nuxt/builds/meta/5f231028-949f-4f49-8f8d-307070c40687.json +0 -1
- package/dist/static/_nuxt/error-404.DIb-VIQ0.css +0 -1
- package/dist/static/_nuxt/error-500.BvRwBykK.css +0 -1
- package/dist/static/_nuxt/vector.ClRRJOjR.css +0 -1
- package/dist/static/_nuxt/wlpNGAAZ.js +0 -3
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { VectorFilterGroup, VectorFilterQuery, VectorFilters, VectorOperator, VectorResource } from '#vector/app/types/vector'
|
|
3
|
+
|
|
4
|
+
// Plain-language filters: a list-toolbar item beside the search. The
|
|
5
|
+
// sentence goes to POST /vector/ai/filters/{resource}; the answer (the
|
|
6
|
+
// list's own grammar, validated by the server) reaches the list at once,
|
|
7
|
+
// through its update:filters, update:groups and update:search, and a note
|
|
8
|
+
// below says what it understood and offers Undo, which puts back the
|
|
9
|
+
// list's filter and search as they were before. A relation the sentence
|
|
10
|
+
// named ambiguously shows its candidates in the note; the one picked joins
|
|
11
|
+
// the list's filter. Shown only when capabilities.ai.filters is on, the
|
|
12
|
+
// resource is not kept from AI, and it has a field to filter by.
|
|
13
|
+
|
|
14
|
+
interface Candidate { id: number | string, label: string }
|
|
15
|
+
interface Unresolved { field: string, op: VectorOperator, text: string, candidates: Candidate[] }
|
|
16
|
+
interface Translation {
|
|
17
|
+
filter: VectorFilters
|
|
18
|
+
groups: VectorFilterGroup[]
|
|
19
|
+
q: string | null
|
|
20
|
+
explanation: string
|
|
21
|
+
unresolved: Unresolved[]
|
|
22
|
+
}
|
|
23
|
+
interface Before { filters: VectorFilters, groups: VectorFilterGroup[], search: string | null, searched: boolean }
|
|
24
|
+
|
|
25
|
+
const props = defineProps<{
|
|
26
|
+
resource: VectorResource
|
|
27
|
+
filters: VectorFilters
|
|
28
|
+
groups: VectorFilterGroup[]
|
|
29
|
+
advanced?: VectorFilterQuery[]
|
|
30
|
+
search: string | null
|
|
31
|
+
}>()
|
|
32
|
+
|
|
33
|
+
const emit = defineEmits<{
|
|
34
|
+
'update:filters': [VectorFilters]
|
|
35
|
+
'update:groups': [VectorFilterGroup[]]
|
|
36
|
+
'update:search': [string | null]
|
|
37
|
+
}>()
|
|
38
|
+
|
|
39
|
+
const { schema } = useVectorSchema()
|
|
40
|
+
const api = useVectorApi()
|
|
41
|
+
const { t } = useVectorT()
|
|
42
|
+
|
|
43
|
+
const shown = computed(() => aiOffered(aiCapabilities(schema.value), 'filters', props.resource.slug)
|
|
44
|
+
&& props.resource.fields.some(f => f.operators.length > 0))
|
|
45
|
+
|
|
46
|
+
const text = ref('')
|
|
47
|
+
const busy = ref(false)
|
|
48
|
+
const failure = ref<string | null>(null)
|
|
49
|
+
const note = ref<{ explanation: string, unresolved: Unresolved[] } | null>(null)
|
|
50
|
+
const before = ref<Before | null>(null)
|
|
51
|
+
|
|
52
|
+
/** The list's filter as the server reads it: the conditions, and its groups as the list page sends them. */
|
|
53
|
+
function current(): VectorFilterQuery {
|
|
54
|
+
const all: VectorFilterQuery = { ...props.filters }
|
|
55
|
+
const groups = props.groups.filter(g => g.length > 0).map(g => ({ or: g }))
|
|
56
|
+
if (groups.length === 1) all.or = groups[0]!.or
|
|
57
|
+
else if (groups.length > 1) all.and = groups
|
|
58
|
+
return all
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function zone(): string {
|
|
62
|
+
try {
|
|
63
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
64
|
+
} catch {
|
|
65
|
+
return 'UTC'
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function ask() {
|
|
70
|
+
const sentence = text.value.trim()
|
|
71
|
+
if (sentence === '' || busy.value) return
|
|
72
|
+
busy.value = true
|
|
73
|
+
failure.value = null
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
const answer = await api<Translation>(`/vector/ai/filters/${encodeURIComponent(props.resource.slug)}`, {
|
|
77
|
+
method: 'POST',
|
|
78
|
+
body: { text: sentence, timezone: zone(), current: { filter: current() } },
|
|
79
|
+
})
|
|
80
|
+
apply(answer)
|
|
81
|
+
} catch (error) {
|
|
82
|
+
// the sentence stays, to be corrected or sent again
|
|
83
|
+
failure.value = describe(error)
|
|
84
|
+
} finally {
|
|
85
|
+
busy.value = false
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The answer reaches the list at once. The list as it was is kept for
|
|
91
|
+
* Undo, from before the first of several sentences in a row, so Undo
|
|
92
|
+
* goes back to the list the admin started from. The request carries no
|
|
93
|
+
* search, so a null q leaves the list's own search as it is. The sentence
|
|
94
|
+
* stays in the field, to be refined and sent again.
|
|
95
|
+
*/
|
|
96
|
+
function apply(answer: Translation) {
|
|
97
|
+
const searched = answer.q !== null
|
|
98
|
+
before.value ??= { filters: { ...props.filters }, groups: props.groups.map(group => group.map(alternative => ({ ...alternative }))), search: props.search, searched: false }
|
|
99
|
+
if (searched) before.value.searched = true
|
|
100
|
+
emit('update:filters', Array.isArray(answer.filter) ? {} : { ...answer.filter })
|
|
101
|
+
emit('update:groups', answer.groups.map(group => group.map(alternative => ({ ...alternative }))))
|
|
102
|
+
if (searched) emit('update:search', answer.q)
|
|
103
|
+
note.value = { explanation: answer.explanation, unresolved: answer.unresolved }
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The server's reason; for a spent budget, when it renews; when the
|
|
108
|
+
* response lets Retry-After be read. Cross-origin it can only be read when
|
|
109
|
+
* the API's CORS exposes it; without it, the server's own words.
|
|
110
|
+
*/
|
|
111
|
+
function describe(error: unknown): string {
|
|
112
|
+
return aiStatusOf(error) === 429 ? aiFailureMessage(error, t('ai.filters.budgetSpent')) : vectorErrorMessage(error)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** A candidate of an ambiguous relation joins the list's filter as its condition. */
|
|
116
|
+
function pick(entry: Unresolved, candidate: Candidate) {
|
|
117
|
+
emit('update:filters', { ...props.filters, [entry.field]: { ...props.filters[entry.field], [entry.op]: String(candidate.id) } })
|
|
118
|
+
if (note.value) note.value = { ...note.value, unresolved: note.value.unresolved.filter(u => u !== entry) }
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const fieldLabel = (name: string) => props.resource.fields.find(f => f.name === name)?.label ?? name
|
|
122
|
+
|
|
123
|
+
/** Puts the list's filter and search back as they were before the sentence. */
|
|
124
|
+
function undo() {
|
|
125
|
+
if (before.value) {
|
|
126
|
+
emit('update:filters', before.value.filters)
|
|
127
|
+
emit('update:groups', before.value.groups)
|
|
128
|
+
if (before.value.searched) emit('update:search', before.value.search)
|
|
129
|
+
}
|
|
130
|
+
close()
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Keeps the list as it is; the next sentence starts from it. */
|
|
134
|
+
function close() {
|
|
135
|
+
note.value = null
|
|
136
|
+
before.value = null
|
|
137
|
+
}
|
|
138
|
+
</script>
|
|
139
|
+
|
|
140
|
+
<template>
|
|
141
|
+
<div v-if="shown" class="vx-ai-filter d-contents" data-ai-filters>
|
|
142
|
+
<v-text-field
|
|
143
|
+
v-model="text"
|
|
144
|
+
:placeholder="t('ai.filters.placeholder', { label: resource.label })"
|
|
145
|
+
:aria-label="t('ai.filters.label')"
|
|
146
|
+
prepend-inner-icon="mdi-creation-outline"
|
|
147
|
+
:loading="busy"
|
|
148
|
+
:disabled="busy"
|
|
149
|
+
:maxlength="500"
|
|
150
|
+
density="compact"
|
|
151
|
+
hide-details
|
|
152
|
+
style="max-width: 360px; min-width: 240px"
|
|
153
|
+
data-ai-filters-input
|
|
154
|
+
@keydown.enter.prevent="ask"
|
|
155
|
+
/>
|
|
156
|
+
<v-alert v-if="failure" type="warning" variant="tonal" density="compact" class="vx-ai-filter__row" :text="failure" closable data-ai-filters-failure @click:close="failure = null" />
|
|
157
|
+
<v-sheet v-if="note" border rounded class="vx-ai-filter__row px-3 py-2" data-ai-filters-note>
|
|
158
|
+
<div class="d-flex align-center ga-2">
|
|
159
|
+
<v-icon icon="mdi-creation-outline" size="small" />
|
|
160
|
+
<span class="text-body-2 flex-grow-1" data-ai-filters-explanation>{{ note.explanation || t('ai.filters.noExplanation') }}</span>
|
|
161
|
+
<v-btn size="small" variant="text" prepend-icon="mdi-undo" data-ai-filters-undo @click="undo">{{ t('ai.filters.undo') }}</v-btn>
|
|
162
|
+
<v-btn size="small" variant="text" icon="mdi-close" :aria-label="t('ai.filters.close')" data-ai-filters-close @click="close" />
|
|
163
|
+
</div>
|
|
164
|
+
<div v-for="entry in note.unresolved" :key="`${entry.field}.${entry.op}`" class="d-flex align-center flex-wrap ga-1 mt-2" :data-ai-filters-unresolved="entry.field">
|
|
165
|
+
<v-chip size="small" color="warning" variant="tonal" prepend-icon="mdi-help-circle-outline">{{ t('ai.filters.which', { field: fieldLabel(entry.field), text: entry.text }) }}</v-chip>
|
|
166
|
+
<v-chip v-for="candidate in entry.candidates" :key="candidate.id" size="small" variant="outlined" :data-ai-filters-candidate="candidate.id" @click="pick(entry, candidate)">{{ candidate.label }}</v-chip>
|
|
167
|
+
</div>
|
|
168
|
+
</v-sheet>
|
|
169
|
+
</div>
|
|
170
|
+
</template>
|
|
171
|
+
|
|
172
|
+
<style scoped>
|
|
173
|
+
/* the field sits in the toolbar's own row; the note and a failure take a row of their own below it */
|
|
174
|
+
.d-contents { display: contents; }
|
|
175
|
+
.vx-ai-filter__row { flex-basis: 100%; }
|
|
176
|
+
</style>
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { VectorField } from '#vector/app/types/vector'
|
|
3
|
+
import type { WritingAnswer, WritingOperation } from '../../composables/useVectorWriting'
|
|
4
|
+
import WritingMenu from './WritingMenu.vue'
|
|
5
|
+
import WritingResult from './WritingResult.vue'
|
|
6
|
+
|
|
7
|
+
// Writing help inside a text input (defineInputAddon, `string` and
|
|
8
|
+
// `text`, placement `inner`): an icon at the field's inline end opens the
|
|
9
|
+
// menu; the answer opens in a popover anchored to the field, beside the
|
|
10
|
+
// text it was asked about, with Replace (which puts it in the input, for
|
|
11
|
+
// the person to review and save as their own edit) and Discard; Escape
|
|
12
|
+
// or a click outside it discards too. A failure keeps the text as it was
|
|
13
|
+
// and says why, in the same popover. Shown only where writing help is
|
|
14
|
+
// offered for this field (useVectorWriting().offered()), and only on that
|
|
15
|
+
// resource's own create or edit page: the record comes from the page, as
|
|
16
|
+
// it does for the editor toolbar item, so a settings form, a bulk edit and
|
|
17
|
+
// an action's dialog (forms the addon is also mounted in) show nothing.
|
|
18
|
+
const props = defineProps<{
|
|
19
|
+
field: VectorField
|
|
20
|
+
/** The resource's slug; empty in a settings group. */
|
|
21
|
+
resource: string
|
|
22
|
+
record: Record<string, unknown> | null
|
|
23
|
+
modelValue: unknown
|
|
24
|
+
disabled?: boolean
|
|
25
|
+
}>()
|
|
26
|
+
|
|
27
|
+
const emit = defineEmits<{ 'update:modelValue': [value: string] }>()
|
|
28
|
+
|
|
29
|
+
const writing = useVectorWriting()
|
|
30
|
+
const host = useVectorHost()
|
|
31
|
+
const { t } = useVectorT()
|
|
32
|
+
|
|
33
|
+
const context = host.context()
|
|
34
|
+
// This resource's create page (/r/{resource}/create) or one of its records'
|
|
35
|
+
// edit pages (/r/{resource}/{id}/edit), and nothing else: not its list
|
|
36
|
+
// (bulk edit), not a record's page (its actions' dialogs, a related
|
|
37
|
+
// record's create form), not another resource's page.
|
|
38
|
+
const page = context.path.split('/')
|
|
39
|
+
const onForm = props.resource !== '' && context.resource === props.resource && page[1] === 'r' && (
|
|
40
|
+
context.recordId === undefined
|
|
41
|
+
? page.length === 4 && page[3] === 'create'
|
|
42
|
+
: page.length === 5 && page[4] === 'edit'
|
|
43
|
+
)
|
|
44
|
+
const shown = computed(() => onForm && writing.offered(props.resource, props.field.name))
|
|
45
|
+
const text = computed(() => typeof props.modelValue === 'string' ? props.modelValue : '')
|
|
46
|
+
const busy = ref(false)
|
|
47
|
+
const failure = ref<string | null>(null)
|
|
48
|
+
const result = ref<{ before: string, answer: WritingAnswer } | null>(null)
|
|
49
|
+
|
|
50
|
+
async function run(operation: WritingOperation, targetLocale: string | null) {
|
|
51
|
+
const before = text.value
|
|
52
|
+
if (before.trim() === '' || busy.value) return
|
|
53
|
+
busy.value = true
|
|
54
|
+
failure.value = null
|
|
55
|
+
result.value = null
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
const answer = await writing.write(props.resource, props.field.name, { operation, text: before, format: 'plain', targetLocale, recordId: context.recordId ?? null })
|
|
59
|
+
result.value = { before, answer }
|
|
60
|
+
} catch (error) {
|
|
61
|
+
// the input keeps its text: nothing was put in it
|
|
62
|
+
failure.value = writing.describe(error)
|
|
63
|
+
} finally {
|
|
64
|
+
busy.value = false
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function replace() {
|
|
69
|
+
if (result.value === null) return
|
|
70
|
+
emit('update:modelValue', result.value.answer.text)
|
|
71
|
+
result.value = null
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function discard() {
|
|
75
|
+
result.value = null
|
|
76
|
+
failure.value = null
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// the popover hangs from the field the addon sits in (from the addon itself outside one), as wide as
|
|
80
|
+
// the field up to 480px; it is open while there is an answer or a failure to show
|
|
81
|
+
const root = ref<HTMLElement | null>(null)
|
|
82
|
+
const anchor = ref<HTMLElement | null>(null)
|
|
83
|
+
const width = ref(0)
|
|
84
|
+
const popover = computed({
|
|
85
|
+
get: () => result.value !== null || failure.value !== null,
|
|
86
|
+
set: (opened: boolean) => {
|
|
87
|
+
if (!opened) discard()
|
|
88
|
+
},
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
watch(root, (element) => {
|
|
92
|
+
anchor.value = element?.closest<HTMLElement>('.v-input') ?? element
|
|
93
|
+
})
|
|
94
|
+
watch(popover, (opened) => {
|
|
95
|
+
if (opened) width.value = Math.min(anchor.value?.getBoundingClientRect().width ?? 0, 480)
|
|
96
|
+
})
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<template>
|
|
100
|
+
<div v-if="shown" ref="root" class="vx-ai-writing d-inline-flex align-center" data-ai-writing>
|
|
101
|
+
<WritingMenu icon :disabled="props.disabled || text.trim() === ''" :busy="busy" @run="run" />
|
|
102
|
+
<v-menu
|
|
103
|
+
v-if="anchor"
|
|
104
|
+
v-model="popover"
|
|
105
|
+
:activator="anchor"
|
|
106
|
+
:open-on-click="false"
|
|
107
|
+
:close-on-content-click="false"
|
|
108
|
+
location="bottom end"
|
|
109
|
+
:min-width="width || undefined"
|
|
110
|
+
max-width="480"
|
|
111
|
+
>
|
|
112
|
+
<v-card class="pa-2" data-ai-writing-popover>
|
|
113
|
+
<div v-if="failure" class="text-body-2 text-error pa-1" role="alert" data-ai-writing-failure>{{ failure }}</div>
|
|
114
|
+
<WritingResult
|
|
115
|
+
v-if="result"
|
|
116
|
+
:before="result.before"
|
|
117
|
+
:after="result.answer.text"
|
|
118
|
+
format="plain"
|
|
119
|
+
:truncated="result.answer.truncated"
|
|
120
|
+
@replace="replace"
|
|
121
|
+
@discard="discard"
|
|
122
|
+
/>
|
|
123
|
+
</v-card>
|
|
124
|
+
</v-menu>
|
|
125
|
+
<span class="d-sr-only" aria-live="polite">{{ busy ? t('ai.writing.busy') : '' }}</span>
|
|
126
|
+
</div>
|
|
127
|
+
</template>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { WritingOperation } from '../../composables/useVectorWriting'
|
|
3
|
+
|
|
4
|
+
// Writing help's menu, inside a text input and in an editor's toolbar:
|
|
5
|
+
// Rewrite, Shorten, Fix grammar, and Translate to… which lists the
|
|
6
|
+
// languages. Emits the operation chosen, with the language for a
|
|
7
|
+
// translation.
|
|
8
|
+
const props = defineProps<{
|
|
9
|
+
disabled?: boolean
|
|
10
|
+
busy?: boolean
|
|
11
|
+
/** The activator as an icon button, for an editor's toolbar and inside a text input. */
|
|
12
|
+
icon?: boolean
|
|
13
|
+
/** Why the menu cannot be opened now, shown as the activator's title. */
|
|
14
|
+
hint?: string
|
|
15
|
+
}>()
|
|
16
|
+
|
|
17
|
+
const emit = defineEmits<{ run: [operation: WritingOperation, targetLocale: string | null] }>()
|
|
18
|
+
|
|
19
|
+
const { t } = useVectorT()
|
|
20
|
+
const { languageName, languages: languageTags } = useVectorWriting()
|
|
21
|
+
const open = ref(false)
|
|
22
|
+
const languages = ref(false)
|
|
23
|
+
|
|
24
|
+
watch(open, (opened) => {
|
|
25
|
+
if (!opened) languages.value = false
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
function run(operation: WritingOperation, targetLocale: string | null = null) {
|
|
29
|
+
open.value = false
|
|
30
|
+
emit('run', operation, targetLocale)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const operations: { operation: Exclude<WritingOperation, 'translate'>, label: string, icon: string }[] = [
|
|
34
|
+
{ operation: 'rewrite', label: 'ai.writing.rewrite', icon: 'mdi-pencil-outline' },
|
|
35
|
+
{ operation: 'shorten', label: 'ai.writing.shorten', icon: 'mdi-arrow-collapse-horizontal' },
|
|
36
|
+
{ operation: 'grammar', label: 'ai.writing.grammar', icon: 'mdi-spellcheck' },
|
|
37
|
+
]
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<template>
|
|
41
|
+
<v-menu v-model="open" location="bottom start" :disabled="props.disabled || props.busy">
|
|
42
|
+
<template #activator="{ props: activator }">
|
|
43
|
+
<v-btn
|
|
44
|
+
v-if="props.icon"
|
|
45
|
+
v-bind="activator"
|
|
46
|
+
data-ai-writing-menu
|
|
47
|
+
icon="mdi-creation-outline"
|
|
48
|
+
size="small"
|
|
49
|
+
variant="text"
|
|
50
|
+
:loading="props.busy"
|
|
51
|
+
:disabled="props.disabled"
|
|
52
|
+
:title="props.hint ?? t('ai.writing.label')"
|
|
53
|
+
:aria-label="t('ai.writing.label')"
|
|
54
|
+
/>
|
|
55
|
+
<v-btn
|
|
56
|
+
v-else
|
|
57
|
+
v-bind="activator"
|
|
58
|
+
data-ai-writing-menu
|
|
59
|
+
prepend-icon="mdi-creation-outline"
|
|
60
|
+
size="small"
|
|
61
|
+
variant="text"
|
|
62
|
+
:loading="props.busy"
|
|
63
|
+
:disabled="props.disabled"
|
|
64
|
+
:title="props.hint"
|
|
65
|
+
>
|
|
66
|
+
{{ t('ai.writing.label') }}
|
|
67
|
+
</v-btn>
|
|
68
|
+
</template>
|
|
69
|
+
<v-list v-if="!languages" density="compact" data-ai-writing-operations>
|
|
70
|
+
<v-list-item
|
|
71
|
+
v-for="item in operations"
|
|
72
|
+
:key="item.operation"
|
|
73
|
+
:data-ai-writing-operation="item.operation"
|
|
74
|
+
:prepend-icon="item.icon"
|
|
75
|
+
:title="t(item.label)"
|
|
76
|
+
@click="run(item.operation)"
|
|
77
|
+
/>
|
|
78
|
+
<v-list-item data-ai-writing-operation="translate" prepend-icon="mdi-translate" :title="t('ai.writing.translate')" append-icon="mdi-chevron-right" @click.stop="languages = true" />
|
|
79
|
+
</v-list>
|
|
80
|
+
<v-list v-else density="compact" data-ai-writing-languages>
|
|
81
|
+
<v-list-item prepend-icon="mdi-chevron-left" :title="t('ai.writing.back')" @click.stop="languages = false" />
|
|
82
|
+
<v-list-item
|
|
83
|
+
v-for="tag in languageTags"
|
|
84
|
+
:key="tag"
|
|
85
|
+
:data-ai-writing-language="tag"
|
|
86
|
+
:title="languageName(tag)"
|
|
87
|
+
@click="run('translate', tag)"
|
|
88
|
+
/>
|
|
89
|
+
</v-list>
|
|
90
|
+
</v-menu>
|
|
91
|
+
</template>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// Writing help's answer beside the text it was asked about, before it
|
|
3
|
+
// touches the input: Replace puts it there (the person saves it as their
|
|
4
|
+
// own edit), Discard drops it. A Markdown answer renders only through the
|
|
5
|
+
// admin's own Markdown sanitizer; plain text renders as text.
|
|
6
|
+
const props = defineProps<{
|
|
7
|
+
before: string
|
|
8
|
+
after: string
|
|
9
|
+
format: 'plain' | 'markdown'
|
|
10
|
+
truncated: boolean
|
|
11
|
+
}>()
|
|
12
|
+
|
|
13
|
+
defineEmits<{ replace: [], discard: [] }>()
|
|
14
|
+
|
|
15
|
+
const { t } = useVectorT()
|
|
16
|
+
const host = useVectorHost()
|
|
17
|
+
const html = (text: string) => host.markdownHtml(text)
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<v-card variant="outlined" class="vx-ai-writing-result pa-3" data-ai-writing-result>
|
|
22
|
+
<div class="d-flex flex-wrap ga-3">
|
|
23
|
+
<div class="vx-ai-writing-side">
|
|
24
|
+
<div class="text-caption text-medium-emphasis">{{ t('ai.writing.before') }}</div>
|
|
25
|
+
<!-- eslint-disable-next-line vue/no-v-html -- sanitized by the admin's own Markdown renderer -->
|
|
26
|
+
<div v-if="props.format === 'markdown'" class="vx-richtext-view" data-ai-writing-before v-html="html(props.before)" />
|
|
27
|
+
<div v-else class="vx-ai-writing-text" data-ai-writing-before>{{ props.before }}</div>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="vx-ai-writing-side">
|
|
30
|
+
<div class="text-caption text-medium-emphasis">{{ t('ai.writing.after') }}</div>
|
|
31
|
+
<!-- eslint-disable-next-line vue/no-v-html -- sanitized by the admin's own Markdown renderer -->
|
|
32
|
+
<div v-if="props.format === 'markdown'" class="vx-richtext-view" data-ai-writing-after v-html="html(props.after)" />
|
|
33
|
+
<div v-else class="vx-ai-writing-text" data-ai-writing-after>{{ props.after }}</div>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
<div v-if="props.truncated" class="text-caption text-warning mt-2" data-ai-writing-truncated>{{ t('ai.writing.truncated') }}</div>
|
|
37
|
+
<div class="d-flex justify-end ga-2 mt-2">
|
|
38
|
+
<v-btn variant="text" size="small" data-ai-writing-discard @click="$emit('discard')">{{ t('ai.writing.discard') }}</v-btn>
|
|
39
|
+
<v-btn color="primary" variant="flat" size="small" data-ai-writing-replace @click="$emit('replace')">{{ t('ai.writing.replace') }}</v-btn>
|
|
40
|
+
</div>
|
|
41
|
+
</v-card>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<style>
|
|
45
|
+
.vx-ai-writing-result { width: 100%; }
|
|
46
|
+
.vx-ai-writing-side { flex: 1 1 240px; min-width: 0; }
|
|
47
|
+
.vx-ai-writing-text { white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
48
|
+
</style>
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { VectorField } from '#vector/app/types/vector'
|
|
3
|
+
import type { WritingAnswer, WritingOperation } from '../../composables/useVectorWriting'
|
|
4
|
+
import WritingMenu from './WritingMenu.vue'
|
|
5
|
+
import WritingResult from './WritingResult.vue'
|
|
6
|
+
|
|
7
|
+
// Writing help in the toolbar of a rich-text or Markdown editor
|
|
8
|
+
// (defineEditorToolbarItem): the same menu, acting on the editor's
|
|
9
|
+
// selection (its plain text in a rich-text field, its Markdown source in
|
|
10
|
+
// a Markdown field) or, while nothing is selected, on the whole
|
|
11
|
+
// document; disabled only while the editor holds no text. The answer
|
|
12
|
+
// shows beside the text it was asked about; Replace puts it in place of
|
|
13
|
+
// that selection, or of the whole document, as text (paragraphs for its
|
|
14
|
+
// lines), so the document keeps to the field's own schema (a Markdown
|
|
15
|
+
// answer is parsed by the editor's own Markdown reader) and the person
|
|
16
|
+
// saves it as their own edit. The resource and the record come from the page the editor is
|
|
17
|
+
// on, so it is shown only on that resource's own create or edit page, for
|
|
18
|
+
// one of that resource's own fields, as the input addon is: an editor is
|
|
19
|
+
// also mounted in a bulk edit, an action's dialog and a relation's inline
|
|
20
|
+
// create, where the page names no record of this field's resource, and
|
|
21
|
+
// only where writing help is offered for this field.
|
|
22
|
+
|
|
23
|
+
/** The part of a Tiptap editor this item uses. */
|
|
24
|
+
interface Chain {
|
|
25
|
+
focus: () => Chain
|
|
26
|
+
insertContentAt: (range: { from: number, to: number }, content: unknown) => Chain
|
|
27
|
+
run: () => boolean
|
|
28
|
+
}
|
|
29
|
+
interface WritingEditor {
|
|
30
|
+
state: {
|
|
31
|
+
selection: {
|
|
32
|
+
from: number
|
|
33
|
+
to: number
|
|
34
|
+
empty: boolean
|
|
35
|
+
$from: { parent: { isTextblock: boolean } }
|
|
36
|
+
$to: { parent: { isTextblock: boolean } }
|
|
37
|
+
content: () => { content: { toJSON: () => unknown } }
|
|
38
|
+
}
|
|
39
|
+
doc: { content: { size: number }, textBetween: (from: number, to: number, blockSeparator?: string) => string, toJSON: () => unknown }
|
|
40
|
+
}
|
|
41
|
+
schema: { nodes: Record<string, unknown> }
|
|
42
|
+
markdown?: { serialize: (content: unknown) => string, parse: (markdown: string) => { content?: unknown[] } }
|
|
43
|
+
on: (event: 'transaction', handler: () => void) => unknown
|
|
44
|
+
off: (event: 'transaction', handler: () => void) => unknown
|
|
45
|
+
chain: () => Chain
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const props = defineProps<{ editor: WritingEditor, field: VectorField }>()
|
|
49
|
+
|
|
50
|
+
const writing = useVectorWriting()
|
|
51
|
+
const host = useVectorHost()
|
|
52
|
+
const { t } = useVectorT()
|
|
53
|
+
|
|
54
|
+
const markdown = computed(() => props.field.type === 'markdown')
|
|
55
|
+
const context = host.context()
|
|
56
|
+
// This resource's create page (/r/{resource}/create) or one of its records'
|
|
57
|
+
// edit pages (/r/{resource}/{id}/edit), and a field that resource has: not
|
|
58
|
+
// its list (bulk edit), not a record's page (its actions' dialogs, a
|
|
59
|
+
// related record's create form), not another resource's page.
|
|
60
|
+
const page = context.path.split('/')
|
|
61
|
+
const ownField = context.resource !== undefined
|
|
62
|
+
&& host.schema.value?.resources?.[context.resource]?.fields.some(f => f.name === props.field.name) === true
|
|
63
|
+
const onForm = ownField && page[1] === 'r' && (
|
|
64
|
+
context.recordId === undefined
|
|
65
|
+
? page.length === 4 && page[3] === 'create'
|
|
66
|
+
: page.length === 5 && page[4] === 'edit'
|
|
67
|
+
)
|
|
68
|
+
const shown = computed(() => onForm && (props.field.type === 'richtext' || markdown.value) && writing.offered(context.resource, props.field.name))
|
|
69
|
+
|
|
70
|
+
/** The whole document's plain text, a line between blocks. */
|
|
71
|
+
function documentText(): string {
|
|
72
|
+
const { doc } = props.editor.state
|
|
73
|
+
return doc.textBetween(0, doc.content.size, '\n')
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// the editor's state is no Vue state: its transactions say when the selection moved or the text changed
|
|
77
|
+
const empty = ref(props.editor.state.selection.empty)
|
|
78
|
+
const blank = ref(documentText().trim() === '')
|
|
79
|
+
const track = () => {
|
|
80
|
+
empty.value = props.editor.state.selection.empty
|
|
81
|
+
blank.value = documentText().trim() === ''
|
|
82
|
+
}
|
|
83
|
+
onMounted(() => props.editor.on('transaction', track))
|
|
84
|
+
onBeforeUnmount(() => props.editor.off('transaction', track))
|
|
85
|
+
|
|
86
|
+
const busy = ref(false)
|
|
87
|
+
const failure = ref<string | null>(null)
|
|
88
|
+
// whole: asked about the whole document, plain is then its text as it was sent, and its range is read again at Replace
|
|
89
|
+
const result = ref<{ from: number, to: number, whole: boolean, inline: boolean, plain: string, before: string, answer: WritingAnswer } | null>(null)
|
|
90
|
+
|
|
91
|
+
/** The selection, or the whole document, as text to send: its Markdown source in a Markdown field, its plain text otherwise. */
|
|
92
|
+
function selected(whole: boolean, from: number, to: number): string {
|
|
93
|
+
const { state } = props.editor
|
|
94
|
+
if (markdown.value && props.editor.markdown) {
|
|
95
|
+
return props.editor.markdown.serialize(whole ? state.doc.toJSON() : { type: 'doc', content: state.selection.content().content.toJSON() }).trim()
|
|
96
|
+
}
|
|
97
|
+
return state.doc.textBetween(from, to, '\n')
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function run(operation: WritingOperation, targetLocale: string | null) {
|
|
101
|
+
const { selection, doc } = props.editor.state
|
|
102
|
+
const whole = selection.empty
|
|
103
|
+
// nothing selected: the whole document
|
|
104
|
+
const from = whole ? 0 : selection.from
|
|
105
|
+
const to = whole ? doc.content.size : selection.to
|
|
106
|
+
if (busy.value || context.resource === undefined) return
|
|
107
|
+
const before = selected(whole, from, to)
|
|
108
|
+
if (before.trim() === '') return
|
|
109
|
+
// the text as it was asked about, read now, while the range is the document's own: what Replace finds there must still be this
|
|
110
|
+
const plain = whole ? documentText() : doc.textBetween(from, to, '\n')
|
|
111
|
+
busy.value = true
|
|
112
|
+
failure.value = null
|
|
113
|
+
result.value = null
|
|
114
|
+
|
|
115
|
+
try {
|
|
116
|
+
const answer = await writing.write(context.resource, props.field.name, {
|
|
117
|
+
operation,
|
|
118
|
+
text: before,
|
|
119
|
+
format: markdown.value ? 'markdown' : 'plain',
|
|
120
|
+
targetLocale,
|
|
121
|
+
recordId: context.recordId ?? null,
|
|
122
|
+
})
|
|
123
|
+
// within one line of text a single line goes in as text; anything wider as paragraphs
|
|
124
|
+
result.value = { from, to, whole, inline: !whole && selection.$from.parent.isTextblock && selection.$to.parent.isTextblock && !plain.includes('\n'), plain, before, answer }
|
|
125
|
+
} catch (error) {
|
|
126
|
+
// the document keeps its text: nothing was put in it
|
|
127
|
+
failure.value = writing.describe(error)
|
|
128
|
+
} finally {
|
|
129
|
+
busy.value = false
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** The answer as content for this editor: parsed Markdown, or text; a paragraph per line where the schema has paragraphs. */
|
|
134
|
+
function content(text: string, inline: boolean): unknown {
|
|
135
|
+
if (markdown.value && props.editor.markdown) return props.editor.markdown.parse(text).content ?? []
|
|
136
|
+
const lines = text.split('\n')
|
|
137
|
+
if ((inline && lines.length === 1) || props.editor.schema.nodes.paragraph === undefined) return { type: 'text', text: lines.join(' ') }
|
|
138
|
+
return lines.map(line => line === '' ? { type: 'paragraph' } : { type: 'paragraph', content: [{ type: 'text', text: line }] })
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function replace() {
|
|
142
|
+
const current = result.value
|
|
143
|
+
if (current === null) return
|
|
144
|
+
// the text it was asked about must still be there, where it was, for the whole document, all of it, unchanged since it was sent
|
|
145
|
+
const size = props.editor.state.doc.content.size
|
|
146
|
+
const to = current.whole ? size : current.to
|
|
147
|
+
// a document that shrank below the old range no longer holds it: reading there would throw
|
|
148
|
+
if (to > size || (current.whole ? documentText() : props.editor.state.doc.textBetween(current.from, to, '\n')) !== current.plain) {
|
|
149
|
+
failure.value = t(current.whole ? 'ai.writing.changedDocument' : 'ai.writing.changed')
|
|
150
|
+
result.value = null
|
|
151
|
+
return
|
|
152
|
+
}
|
|
153
|
+
props.editor.chain().focus().insertContentAt({ from: current.from, to }, content(current.answer.text, current.inline)).run()
|
|
154
|
+
result.value = null
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function discard() {
|
|
158
|
+
result.value = null
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const dialog = computed({
|
|
162
|
+
get: () => result.value !== null,
|
|
163
|
+
set: (open: boolean) => {
|
|
164
|
+
if (!open) discard()
|
|
165
|
+
},
|
|
166
|
+
})
|
|
167
|
+
</script>
|
|
168
|
+
|
|
169
|
+
<template>
|
|
170
|
+
<span v-if="shown" class="vx-ai-writing-toolbar d-inline-flex align-center" data-ai-writing>
|
|
171
|
+
<WritingMenu icon :disabled="blank" :busy="busy" :hint="blank ? t('ai.writing.emptyEditor') : empty ? t('ai.writing.wholeDocument') : undefined" @run="run" />
|
|
172
|
+
<v-tooltip v-if="failure" :text="failure" location="bottom">
|
|
173
|
+
<template #activator="{ props: activator }">
|
|
174
|
+
<v-icon v-bind="activator" icon="mdi-alert-circle-outline" color="error" size="small" role="alert" :aria-label="failure" data-ai-writing-failure />
|
|
175
|
+
</template>
|
|
176
|
+
</v-tooltip>
|
|
177
|
+
<v-dialog v-model="dialog" max-width="720">
|
|
178
|
+
<WritingResult
|
|
179
|
+
v-if="result"
|
|
180
|
+
:before="result.before"
|
|
181
|
+
:after="result.answer.text"
|
|
182
|
+
:format="markdown ? 'markdown' : 'plain'"
|
|
183
|
+
:truncated="result.answer.truncated"
|
|
184
|
+
@replace="replace"
|
|
185
|
+
@discard="discard"
|
|
186
|
+
/>
|
|
187
|
+
</v-dialog>
|
|
188
|
+
</span>
|
|
189
|
+
</template>
|
|
@@ -43,7 +43,7 @@ export function useConfirm() {
|
|
|
43
43
|
return ask(options).then(answer => answer !== null)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
/** Resolves to the typed text
|
|
46
|
+
/** Resolves to the typed text (equal to `requireText`) on confirm, or null when declined. */
|
|
47
47
|
function confirmTyped(options: ConfirmOptions & { requireText: string, requireLabel: string }): Promise<string | null> {
|
|
48
48
|
return ask(options)
|
|
49
49
|
}
|
|
@@ -8,11 +8,11 @@ let ending: { token: string | null | undefined, done: Promise<void> } | null = n
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* The one HTTP client every Vector request goes through. Bearer mode
|
|
11
|
-
* attaches the in-memory token
|
|
12
|
-
* minutes left
|
|
11
|
+
* attaches the in-memory token (renewed first when it has under two
|
|
12
|
+
* minutes left) and on a 401 renews it once and repeats the request
|
|
13
13
|
* (a 401 for a token another request already renewed only repeats it),
|
|
14
|
-
* sending the user to the login page
|
|
15
|
-
* that renewal failed
|
|
14
|
+
* sending the user to the login page (once, however many requests
|
|
15
|
+
* that renewal failed) only when that fails too (a 401 means the
|
|
16
16
|
* request did nothing, so repeating even a POST is safe); cookie mode
|
|
17
17
|
* (hosted) rides the application's session cookie, sends the CSRF token
|
|
18
18
|
* on every unsafe method, and hands a 401 to the application's own login
|