@vite-hub/ui 0.6.1 → 0.8.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/README.md +106 -46
- package/dist/AttachmentTitle-BWw0ck0T.js +110 -0
- package/dist/BubbleContent-B1a4e3vE.js +45 -0
- package/dist/Chat-CuSthJVg.js +112 -0
- package/dist/ChatMessage-CFQs0v4N.js +94 -0
- package/dist/CodeBlockContent-BjXJm8lO.js +92 -0
- package/dist/CodeBlockTitle-DIu8Ef3V.js +99 -0
- package/dist/CommentRow-XY3FNp30.js +86 -0
- package/dist/CopyButton-Bs6DT-Z8.js +188 -0
- package/dist/Markdown-Da5t-931.js +70 -0
- package/dist/MarkdownCodeBlock-BWDLOWPO.js +127 -0
- package/dist/MarkdownImage-CJN3myt4.js +111 -0
- package/dist/MessageHeader-CJ9eBHSS.js +61 -0
- package/dist/MessageParts-CyJLG34y.js +57 -0
- package/dist/MessageScrollerViewport-BaTlWLki.js +142 -0
- package/dist/MorphText-B6MWdeIv.js +36 -0
- package/dist/RollNumber-CnF52zJM.js +49 -0
- package/dist/SwapIcon-CUIq1TU5.js +67 -0
- package/dist/TraceTitle-Cp0y7RRD.js +133 -0
- package/dist/agent-session-2j2gbGpp.js +875 -0
- package/dist/agent-session-BwZSMi4S.d.ts +312 -0
- package/dist/appendItems-hQ4aBd9Q.js +4047 -0
- package/dist/attachment-BllgHx9Q.d.ts +124 -0
- package/dist/attachment-DQMJNfj0.js +35 -0
- package/dist/avatar-stack-Bj1xUkzY.d.ts +4 -0
- package/dist/avatar-stack-CoLlsmwJ.js +72 -0
- package/dist/bubble-D3M2_InY.js +32 -0
- package/dist/bubble-DmplVxLr.d.ts +64 -0
- package/dist/chat-DWdyMSuj.d.ts +13 -0
- package/dist/chat-message-QLHnX_ED.d.ts +11 -0
- package/dist/chat-session-BOj5L3Ey.d.ts +29 -0
- package/dist/chat-session-cxUzvwdj.js +43 -0
- package/dist/choices-input-DqgXl5a-.d.ts +97 -0
- package/dist/{vue-d2Td6uu2.js → client-BG-oCUtv-5i4sRwXP.js} +4156 -4156
- package/dist/code-block-BqOEVWPh.d.ts +182 -0
- package/dist/code-block-CMERLfew.js +14 -0
- package/dist/code-view-26RY6dX8.js +137 -0
- package/dist/code-view-D8yYdFUc.d.ts +184 -0
- package/dist/{comment-composer-DmDM3XYP.d.ts → comment-composer-CsVOvG9j.d.ts} +6 -6
- package/dist/{comment-composer-X7vJKh5b.js → comment-composer-D_mcH3Ts.js} +175 -37
- package/dist/{comment-layer-KnnVfdRV.d.ts → comment-layer-C3xmg-0_.d.ts} +14 -5
- package/dist/comment-layer-Ci6ipGi2.js +1206 -0
- package/dist/{comment-panel-DoLDOw3E.d.ts → comment-panel-DxN21VoY.d.ts} +24 -17
- package/dist/comment-selection-bar-B_bchB2O.d.ts +33 -0
- package/dist/comment-selection-bar-DZAtiRZ9.js +144 -0
- package/dist/{comment-thread-DPV2kqA4.d.ts → comment-thread-BmsqcjVQ.d.ts} +9 -8
- package/dist/{comment-thread-jqPx6aJ8.js → comment-thread-BzOZVqF2.js} +74 -49
- package/dist/comments-BU8cTt5o.d.ts +50 -0
- package/dist/{comments-9MDSNm-9.js → comments-BaSrroRV.js} +32 -4
- package/dist/{comments-OWjNidkP.d.ts → comments-ZfV6IZs8.d.ts} +9 -2
- package/dist/components-B_2Q0dJ3.js +269 -0
- package/dist/{config-LRonN53j.js → config-BDQYUjjp.js} +10 -29
- package/dist/{config-COSdO-ay.d.ts → config-JmsTI7gs.d.ts} +20 -33
- package/dist/connection-status-BVSH2ZVo.js +72 -0
- package/dist/connection-status-g62BTn44.d.ts +37 -0
- package/dist/copy-button-CRiXUFsl.d.ts +17 -0
- package/dist/device-frame-BW6IjB6P.d.ts +78 -0
- package/dist/device-frame-DDWoyB-G.js +515 -0
- package/dist/diffs-BTKaVnsb.d.ts +272 -0
- package/dist/diffs.d.ts +3 -0
- package/dist/{pierre-code-view-C49BVDrc.js → diffs.js} +147 -4223
- package/dist/drop-field-C0bXv1J-.d.ts +35 -0
- package/dist/drop-field-DeIvKoJs.js +77 -0
- package/dist/editor-BsOTjnnN.d.ts +540 -0
- package/dist/{markdown-editor-D1irG9Xl.js → editor-hXea1i46.js} +833 -106
- package/dist/editor.d.ts +2 -0
- package/dist/editor.js +3 -0
- package/dist/element-BpjNQvZ0.js +6 -0
- package/dist/{file-tree-CRFIdtzw.js → file-tree-B4JKbp4r.js} +19 -18
- package/dist/{file-tree-DOtkeBaq.d.ts → file-tree-BdnKA6UA.d.ts} +33 -8
- package/dist/file-tree-DDSIafDn.d.ts +22 -0
- package/dist/file-tree-DS5shGSL.js +46 -0
- package/dist/file-tree.d.ts +2 -0
- package/dist/file-tree.js +1 -0
- package/dist/files-cuVXzWlx.js +30 -0
- package/dist/filter-search-C9e6sGij.d.ts +28 -0
- package/dist/filter-search-COZsoRiR.js +73 -0
- package/dist/formatCSSVariablePrefix-DLS1Ed1_.js +5 -0
- package/dist/headless-2IcUWHMq.d.ts +51 -0
- package/dist/headless.d.ts +7 -4
- package/dist/headless.js +5 -3
- package/dist/highlight.d.ts +2 -0
- package/dist/highlight.js +1 -0
- package/dist/{highlights-C2AbEdDI.js → highlights-8Al0-h-v.js} +3 -2
- package/dist/{hold-to-delete-BSMrpE-i.d.ts → hold-to-delete-CQc1JaG_.d.ts} +7 -0
- package/dist/{hold-to-delete-Cludb56v.js → hold-to-delete-D1Vy40w5.js} +138 -20
- package/dist/hold-to-delete-DazElJT2.js +85 -0
- package/dist/hold-to-delete-ksBE7wxc.d.ts +58 -0
- package/dist/index-CffOzibW.d.ts +77 -0
- package/dist/{index-B2cbt3py.d.ts → index-D3-uYBqH.d.ts} +1 -1
- package/dist/index.d.ts +165 -52
- package/dist/index.js +126 -670
- package/dist/markdown-BLALLOc0.d.ts +45 -0
- package/dist/{parts/components/markdown-renderer.d.ts → markdown-DkDxdpMU.d.ts} +10 -7
- package/dist/{markdown-renderer-DMyYKeil.js → markdown-_0HhbsOo.js} +125 -127
- package/dist/markdown-editor.d.ts +51 -98
- package/dist/markdown-editor.js +70 -3
- package/dist/markdown.d.ts +2 -0
- package/dist/markdown.js +1 -0
- package/dist/marker-CvcWZ3Zp.d.ts +59 -0
- package/dist/marker-DNL6QR3L.js +63 -0
- package/dist/message-BwivYIEl.js +13 -0
- package/dist/message-DEq4K5cQ.d.ts +72 -0
- package/dist/message-parts-B1BZFVKe.d.ts +3 -0
- package/dist/message-parts-CG3gNWn8.d.ts +11 -0
- package/dist/message-parts.d.ts +2 -0
- package/dist/message-parts.js +1 -0
- package/dist/message-scroller-D7AvM31v.d.ts +41 -0
- package/dist/motion/core.d.ts +4 -4
- package/dist/motion/core.js +5 -11
- package/dist/motion-BH6ShUam.d.ts +12 -0
- package/dist/{install-C4LwcJda.js → motion-BhARaNBB.js} +1 -1
- package/dist/{effects-C1zYpSpg.js → motion-core-JZZiPKEk.js} +1829 -120
- package/dist/{motion-core-Dh20n5Se.d.ts → motion-core-gfsTPLbh.d.ts} +35 -74
- package/dist/motion-list-9vD1hSS0.js +49 -0
- package/dist/motion.d.ts +5 -14
- package/dist/motion.js +6 -13
- package/dist/nuxt-ui-D3Qda35W.js +22 -0
- package/dist/nuxt.d.ts +9 -5
- package/dist/nuxt.js +28 -33
- package/dist/parts/components/agent-session.d.ts +2 -295
- package/dist/parts/components/agent-session.js +1 -659
- package/dist/parts/components/attachment.d.ts +2 -85
- package/dist/parts/components/attachment.js +3 -72
- package/dist/parts/components/avatar-stack.d.ts +3 -2
- package/dist/parts/components/avatar-stack.js +1 -60
- package/dist/parts/components/bubble.d.ts +2 -69
- package/dist/parts/components/bubble.js +3 -52
- package/dist/parts/components/chat-message.d.ts +3 -25
- package/dist/parts/components/chat-message.js +1 -50
- package/dist/parts/components/chat-session.d.ts +2 -26
- package/dist/parts/components/chat-session.js +1 -37
- package/dist/parts/components/chat.d.ts +3 -52
- package/dist/parts/components/chat.js +1 -105
- package/dist/parts/components/code-block.d.ts +2 -102
- package/dist/parts/components/code-block.js +4 -109
- package/dist/parts/components/code-view.d.ts +3 -268
- package/dist/parts/components/code-view.js +1 -1
- package/dist/parts/components/comment-composer.d.ts +1 -1
- package/dist/parts/components/comment-composer.js +1 -1
- package/dist/parts/components/comment-layer.d.ts +1 -1
- package/dist/parts/components/comment-layer.js +1 -634
- package/dist/parts/components/comment-panel.d.ts +2 -2
- package/dist/parts/components/comment-panel.js +22 -16
- package/dist/parts/components/comment-selection-bar.d.ts +2 -2
- package/dist/parts/components/comment-selection-bar.js +1 -116
- package/dist/parts/components/comment-thread.d.ts +1 -1
- package/dist/parts/components/comment-thread.js +1 -3
- package/dist/parts/components/comments.d.ts +8 -9
- package/dist/parts/components/comments.js +5 -9
- package/dist/parts/components/connection-status.d.ts +2 -36
- package/dist/parts/components/connection-status.js +1 -64
- package/dist/parts/components/copy-button.d.ts +3 -126
- package/dist/parts/components/copy-button.js +1 -226
- package/dist/parts/components/device-frame.d.ts +2 -128
- package/dist/parts/components/device-frame.js +1 -470
- package/dist/parts/components/drop-field.d.ts +2 -67
- package/dist/parts/components/drop-field.js +1 -76
- package/dist/parts/components/file-tree.d.ts +3 -2
- package/dist/parts/components/file-tree.js +3 -1
- package/dist/parts/components/filter-search.d.ts +2 -45
- package/dist/parts/components/filter-search.js +1 -57
- package/dist/parts/components/hold-to-delete.d.ts +2 -80
- package/dist/parts/components/hold-to-delete.js +1 -75
- package/dist/parts/components/markdown.d.ts +3 -45
- package/dist/parts/components/markdown.js +1 -46
- package/dist/parts/components/marker.d.ts +2 -32
- package/dist/parts/components/marker.js +1 -22
- package/dist/parts/components/message-parts.d.ts +3 -25
- package/dist/parts/components/message-parts.js +1 -45
- package/dist/parts/components/message.d.ts +2 -32
- package/dist/parts/components/message.js +3 -22
- package/dist/parts/components/motion-list.d.ts +2 -40
- package/dist/parts/components/motion-list.js +1 -41
- package/dist/parts/components/motion.d.ts +5 -118
- package/dist/parts/components/motion.js +5 -163
- package/dist/parts/components/patch-parsers.d.ts +1 -1
- package/dist/parts/components/progress.d.ts +2 -39
- package/dist/parts/components/progress.js +1 -53
- package/dist/parts/components/prompt-input.d.ts +2 -134
- package/dist/parts/components/prompt-input.js +1 -253
- package/dist/parts/components/relative-time.d.ts +2 -71
- package/dist/parts/components/relative-time.js +1 -1
- package/dist/parts/components/status.d.ts +2 -58
- package/dist/parts/components/status.js +1 -47
- package/dist/parts/components/sync-status.d.ts +2 -22
- package/dist/parts/components/sync-status.js +1 -48
- package/dist/parts/components/tool-list.d.ts +2 -28
- package/dist/parts/components/tool-list.js +1 -118
- package/dist/parts/components/trace-run.d.ts +2 -25
- package/dist/parts/components/trace-run.js +1 -89
- package/dist/parts/components/trace.d.ts +2 -59
- package/dist/parts/components/trace.js +1 -76
- package/dist/parts/composables/attachments.js +75 -1
- package/dist/parts/headless/choices-input.d.ts +2 -2
- package/dist/parts/headless/choices-input.js +49 -37
- package/dist/parts/headless/comments.d.ts +1 -1
- package/dist/parts/headless/comments.js +1 -1
- package/dist/parts/headless/message-scroller.d.ts +2 -2
- package/dist/parts/headless/message-scroller.js +211 -309
- package/dist/parts/headless/relative-time.d.ts +2 -0
- package/dist/parts/headless/relative-time.js +1 -0
- package/dist/parts/workspace/browser-support-notice.d.ts +1 -1
- package/dist/parts/workspace/browser-support-notice.js +6 -5
- package/dist/parts/workspace/connect-panel.js +1 -1
- package/dist/parts/workspace/runners/web-container.js +2 -2
- package/dist/parts/workspace/workspace-bar.d.ts +1 -1
- package/dist/parts/workspace/workspace-bar.js +1 -1
- package/dist/parts/workspace/workspace-boot-status.d.ts +1 -1
- package/dist/parts/workspace/workspace-boot-status.js +1 -206
- package/dist/parts/workspace/workspace-editor-head.d.ts +1 -1
- package/dist/parts/workspace/workspace-editor-head.js +1 -1
- package/dist/parts/workspace/workspace-editor.d.ts +2 -2
- package/dist/parts/workspace/workspace-examples.js +1 -1
- package/dist/parts/workspace/workspace-file-tree.d.ts +1 -1
- package/dist/parts/workspace/workspace-file-tree.js +3 -2
- package/dist/parts/workspace/workspace-guide.d.ts +1 -1
- package/dist/parts/workspace/workspace-guide.js +1 -1
- package/dist/parts/workspace/workspace-preview.d.ts +1 -1
- package/dist/parts/workspace/workspace-preview.js +14 -12
- package/dist/parts/workspace/workspace-shell.d.ts +1 -1
- package/dist/parts/workspace/workspace-shell.js +11 -11
- package/dist/parts/workspace/workspace-sidebar.d.ts +2 -2
- package/dist/parts/workspace/workspace-sidebar.js +2 -2
- package/dist/parts/workspace/workspace-start.d.ts +1 -1
- package/dist/parts/workspace/workspace-start.js +1 -1
- package/dist/parts/workspace/workspace-steps.js +1 -1
- package/dist/parts/workspace/workspace.d.ts +3 -3
- package/dist/parts/workspace/workspace.js +5 -5
- package/dist/press-BuEC-XvZ.d.ts +83 -0
- package/dist/progress-8P8RLYMy.js +47 -0
- package/dist/progress-Ch0fA-bf.d.ts +8 -0
- package/dist/prompt-input-CRXEJBAK.js +412 -0
- package/dist/prompt-input-j4OFTF5p.d.ts +116 -0
- package/dist/relative-time-BnJfjeEm.js +131 -0
- package/dist/relative-time-BuP-Gvzn.d.ts +43 -0
- package/dist/{relative-time-DJnw45tr.js → relative-time-Dz2DR4eb.js} +64 -114
- package/dist/relative-time-grHFu1kY.d.ts +11 -0
- package/dist/{ring-GaJsg32c.js → ring-B0nZBnU0.js} +1 -2
- package/dist/runtime/nuxt-plugin.js +2 -5
- package/dist/{shiki-CbfEu_Az.js → shiki-CxzM_xNo.js} +3 -2
- package/dist/stand-ins-CuKM1UH1.js +339 -0
- package/dist/status-B2Yhrwv8.js +67 -0
- package/dist/status-ySiRa-8O.d.ts +38 -0
- package/dist/{stream-tokenizer-ByC3l0HQ.js → stream-tokenizer-BsjV6wxW.js} +1 -1
- package/dist/styles.css +4348 -3410
- package/dist/sync-status-B29eG_n-.js +59 -0
- package/dist/sync-status-D4KdGO6y.d.ts +35 -0
- package/dist/theme.css +3 -0
- package/dist/theme.d.ts +14 -0
- package/dist/theme.js +19 -8
- package/dist/{themes-DKugPHlg.js → themes-B0_ioVT0.js} +1 -1
- package/dist/tool-list-DDaCqpR6.js +209 -0
- package/dist/tool-list-DMRPM0Yi.d.ts +50 -0
- package/dist/trace-KCBvOsw_.d.ts +113 -0
- package/dist/trace-run-Dk962P5a.d.ts +49 -0
- package/dist/trace-run-nh6FIsl6.js +202 -0
- package/dist/{opt-out-D66l60sg.js → tween-1W-LlKk9.js} +65 -2
- package/dist/types-CMU8Vmew.d.ts +71 -0
- package/dist/types-CTk3aNb5.d.ts +15 -0
- package/dist/types-D0a3i4Fw.d.ts +21 -0
- package/dist/types-DTecvcsZ.d.ts +35 -0
- package/dist/types-D_BWab7g.d.ts +75 -0
- package/dist/types-RHaQ4gj1.d.ts +27 -0
- package/dist/ui-components-CKQAPI-W.js +7 -0
- package/dist/unwrapDefault-CExq-4rm.js +5 -0
- package/dist/utils-hi9-xROt.js +37 -0
- package/dist/vite.d.ts +0 -1
- package/dist/vite.js +8 -14
- package/dist/{vue-vUGpdMct.js → vue-BdA18K5-.js} +1 -1
- package/dist/workspace-boot-status-CyGlJS06.js +216 -0
- package/dist/{workspace-shell-ChCwWPyv.d.ts → workspace-shell-B4A7CINd.d.ts} +1 -1
- package/dist/workspace.d.ts +1 -1
- package/dist/workspace.js +1 -2
- package/package.json +46 -15
- package/dist/announce-B0DLwflT.js +0 -31
- package/dist/attachments-DgwoQZKY.js +0 -88
- package/dist/avatar-stack-C0IKwj6g.d.ts +0 -57
- package/dist/choices-input-BUf-QqGj.d.ts +0 -92
- package/dist/code-view-Cg4nyTNA.js +0 -172
- package/dist/comment-attachments-DAzUbRmJ.js +0 -23
- package/dist/comment-list-ncwaCSVX.d.ts +0 -60
- package/dist/comment-person-D_IyIjXo.js +0 -39
- package/dist/comment-pin-hBJFiSYW.d.ts +0 -66
- package/dist/comment-row-DPMWI5Z0.js +0 -38
- package/dist/comment-selection-bar-CVuS-FNL.d.ts +0 -40
- package/dist/comment-send-CUkL3TbZ.js +0 -275
- package/dist/comment-send-MmxFsOQf.d.ts +0 -23
- package/dist/comment-send.css +0 -267
- package/dist/comment-status-nsCdrRk_.js +0 -20
- package/dist/drop-field-CNZgwFVO.js +0 -162
- package/dist/editor-Dmk3k6f6.js +0 -620
- package/dist/format-CPipR1FP.js +0 -19
- package/dist/handlers-CnbkvXjX.js +0 -181
- package/dist/icon-XZaCUZTG.d.ts +0 -29
- package/dist/image-preview-BKVUtfwQ.js +0 -104
- package/dist/index-B_PSX-5h.d.ts +0 -69
- package/dist/list-DUTAo0uC.js +0 -270
- package/dist/markdown-editor-B7gD60tp.d.ts +0 -189
- package/dist/message-scroller-BZqS63IX.d.ts +0 -173
- package/dist/nuxt-ui-7ByUrymx.js +0 -43
- package/dist/parts/components/comment-list.d.ts +0 -2
- package/dist/parts/components/comment-list.js +0 -173
- package/dist/parts/components/comment-pin.d.ts +0 -2
- package/dist/parts/components/comment-pin.js +0 -74
- package/dist/parts/components/comment-send.d.ts +0 -2
- package/dist/parts/components/comment-send.js +0 -1
- package/dist/parts/components/markdown-editor.d.ts +0 -2
- package/dist/parts/components/markdown-editor.js +0 -1
- package/dist/parts/components/markdown-renderer.js +0 -1
- package/dist/payload-text-DQNRbJY5.js +0 -31
- package/dist/progress-DL9k-ERG.js +0 -265
- package/dist/registry-DAIjCjWd.js +0 -77
- package/dist/slot-part-BWHvQ3mK.js +0 -25
- package/dist/text-gacox6bp.js +0 -822
- package/dist/travel-BliEidau.js +0 -180
- package/dist/tween-Dv3IIIQG.js +0 -61
- package/dist/types-Ceh7h7NT.d.ts +0 -31
- package/dist/visual-copy-CHHBfJ6O.js +0 -14
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { C as shikiDark, S as theme, T as isElement$2, c as
|
|
1
|
+
import { C as shikiDark, S as theme, T as isElement$2, c as rowsOf, d as src_default, f as src_default$2, g as hash, h as src_default$3, m as src_default$1, r as Properties, t as createProgress, u as addStyles, v as scalar, w as childrenOf$1 } from "./client-BG-oCUtv-5i4sRwXP.js";
|
|
2
2
|
import { t as uiErrorDiagnostics } from "./error-diagnostics-BlgA9rI2.js";
|
|
3
|
-
import { n as
|
|
4
|
-
import { r as
|
|
5
|
-
import {
|
|
3
|
+
import { n as useViteHubUIIcons } from "./config-BDQYUjjp.js";
|
|
4
|
+
import { r as createMotionList } from "./motion-core-JZZiPKEk.js";
|
|
5
|
+
import { i as useStandIn } from "./stand-ins-CuKM1UH1.js";
|
|
6
|
+
import { Comment, Fragment, computed, defineComponent, h, inject, isVNode, onBeforeUnmount, onMounted, onScopeDispose, provide, ref, shallowRef, unref, watch, watchEffect } from "vue";
|
|
6
7
|
import { defineDiagnostics } from "nostics";
|
|
7
|
-
import {
|
|
8
|
+
import { Tooltip, TooltipContent, TooltipShortcut, TooltipTrigger } from "@ui-sdk/vue/tooltip";
|
|
9
|
+
import { Menu, MenuContent, MenuGroup, MenuGroupLabel, MenuItem, MenuItemIcon, MenuSeparator, MenuTrigger } from "@ui-sdk/vue/menu";
|
|
8
10
|
import { defineComarkPlugin, parseMarkdown } from "comark";
|
|
9
11
|
import { indent } from "comark/utils";
|
|
10
12
|
import { renderFrontmatter, renderMarkdown } from "comark/render";
|
|
@@ -18,8 +20,16 @@ import components from "comark/plugins/components";
|
|
|
18
20
|
import frontmatterPlugin from "comark/plugins/frontmatter";
|
|
19
21
|
import taskList from "comark/plugins/task-list";
|
|
20
22
|
import { parseFrontmatter } from "comark/parse";
|
|
21
|
-
import { Plugin as Plugin$1, PluginKey } from "@tiptap/pm/state";
|
|
23
|
+
import { NodeSelection, Plugin as Plugin$1, PluginKey } from "@tiptap/pm/state";
|
|
22
24
|
import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
|
25
|
+
import { Editor as Editor$1, EditorContent, NodeViewContent, NodeViewWrapper, VueNodeViewRenderer, nodeViewProps } from "@tiptap/vue-3";
|
|
26
|
+
import { flip, offset, shift } from "@floating-ui/dom";
|
|
27
|
+
import DragHandle from "@tiptap/extension-drag-handle-vue-3";
|
|
28
|
+
import { ReplaceStep } from "@tiptap/pm/transform";
|
|
29
|
+
import { BubbleMenu } from "@tiptap/vue-3/menus";
|
|
30
|
+
import { Toggle, ToggleIcon } from "@ui-sdk/vue/toggle";
|
|
31
|
+
import { Toolbar, ToolbarButton, ToolbarGroup, ToolbarSeparator } from "@ui-sdk/vue/toolbar";
|
|
32
|
+
import { TriggerMenu, TriggerMenuContent, TriggerMenuGroup, TriggerMenuGroupLabel, TriggerMenuItem, TriggerMenuItemIcon, TriggerMenuList, TriggerMenuSeparator, TriggerMenuStatus } from "@ui-sdk/vue/trigger-menu";
|
|
23
33
|
// ../blob/dist/object-DRSmpe04.js
|
|
24
34
|
/** A non-null object that is not an array. Functions do not pass. */
|
|
25
35
|
function isRecord(value) {
|
|
@@ -2283,7 +2293,7 @@ function useComarkEditor(markdown, options = {}) {
|
|
|
2283
2293
|
components,
|
|
2284
2294
|
field
|
|
2285
2295
|
});
|
|
2286
|
-
editor.value = new Editor({
|
|
2296
|
+
editor.value = new Editor$1({
|
|
2287
2297
|
extensions: [ComarkKit.configure({
|
|
2288
2298
|
componentView: view,
|
|
2289
2299
|
...options.kit
|
|
@@ -2369,7 +2379,186 @@ defineComponent({
|
|
|
2369
2379
|
};
|
|
2370
2380
|
}
|
|
2371
2381
|
});
|
|
2372
|
-
// src/
|
|
2382
|
+
// src/editor/handlers.ts
|
|
2383
|
+
/**
|
|
2384
|
+
* The key that the editor parts read their handlers from, as a `Ref<EditorHandlers>`. It is the string that Nuxt UI's
|
|
2385
|
+
* editor components inject, so one `provide()` serves both sets.
|
|
2386
|
+
*/
|
|
2387
|
+
const editorHandlersKey = "editorHandlers";
|
|
2388
|
+
function isNodeTypeSelected(editor, types) {
|
|
2389
|
+
const { $from, to } = editor.state.selection;
|
|
2390
|
+
let found = false;
|
|
2391
|
+
editor.state.doc.nodesBetween($from.pos, to, (node) => {
|
|
2392
|
+
if (types.includes(node.type.name)) found = true;
|
|
2393
|
+
});
|
|
2394
|
+
return found;
|
|
2395
|
+
}
|
|
2396
|
+
const hasExtension = (editor, name) => editor.extensionManager.extensions.some((extension) => extension.name === name);
|
|
2397
|
+
const blocked = (editor) => isNodeTypeSelected(editor, ["image"]) || editor.isActive("code");
|
|
2398
|
+
function blockHandler(name, toggle, can) {
|
|
2399
|
+
return {
|
|
2400
|
+
canExecute: can,
|
|
2401
|
+
execute: (editor) => toggle(editor.chain().focus()),
|
|
2402
|
+
isActive: (editor) => editor.isActive(name),
|
|
2403
|
+
isDisabled: blocked
|
|
2404
|
+
};
|
|
2405
|
+
}
|
|
2406
|
+
const listItemTypes = ["bulletList", "orderedList"];
|
|
2407
|
+
function listHandler(type) {
|
|
2408
|
+
const toggle = (chain) => type === "bulletList" ? chain.toggleBulletList() : chain.toggleOrderedList();
|
|
2409
|
+
const inAnyList = (editor) => listItemTypes.some((name) => hasExtension(editor, name) && editor.isActive(name));
|
|
2410
|
+
return {
|
|
2411
|
+
canExecute: (editor) => (type === "bulletList" ? editor.can().toggleBulletList() : editor.can().toggleOrderedList()) || editor.isActive("listItem") || inAnyList(editor),
|
|
2412
|
+
execute: (editor) => {
|
|
2413
|
+
const { selection } = editor.state;
|
|
2414
|
+
let chain = editor.chain().focus();
|
|
2415
|
+
if (selection instanceof NodeSelection) {
|
|
2416
|
+
const first = selection.node.firstChild?.firstChild;
|
|
2417
|
+
const last = selection.node.lastChild?.lastChild;
|
|
2418
|
+
const from = first ? selection.from + first.nodeSize : selection.from + 1;
|
|
2419
|
+
const to = last ? selection.to - last.nodeSize : selection.to - 1;
|
|
2420
|
+
chain = chain.setTextSelection({
|
|
2421
|
+
from,
|
|
2422
|
+
to
|
|
2423
|
+
}).clearNodes();
|
|
2424
|
+
}
|
|
2425
|
+
const lift = (current) => {
|
|
2426
|
+
let result = current.liftListItem("listItem");
|
|
2427
|
+
for (const name of listItemTypes) if (hasExtension(editor, name)) result = result.lift(name);
|
|
2428
|
+
return result;
|
|
2429
|
+
};
|
|
2430
|
+
if (editor.isActive(type)) return lift(chain).selectTextblockEnd();
|
|
2431
|
+
if (inAnyList(editor)) return toggle(lift(chain)).selectTextblockEnd();
|
|
2432
|
+
return toggle(chain).selectTextblockEnd();
|
|
2433
|
+
},
|
|
2434
|
+
isActive: (editor) => editor.isActive(type),
|
|
2435
|
+
isDisabled: (editor) => !hasExtension(editor, type) || blocked(editor)
|
|
2436
|
+
};
|
|
2437
|
+
}
|
|
2438
|
+
function blockAt(editor, item) {
|
|
2439
|
+
const node = item.pos == null ? null : editor.state.doc.nodeAt(item.pos);
|
|
2440
|
+
return node && item.pos != null ? {
|
|
2441
|
+
node,
|
|
2442
|
+
pos: item.pos
|
|
2443
|
+
} : void 0;
|
|
2444
|
+
}
|
|
2445
|
+
function moveHandler(direction) {
|
|
2446
|
+
const target = (editor, item) => {
|
|
2447
|
+
const block = blockAt(editor, item);
|
|
2448
|
+
if (!block) return void 0;
|
|
2449
|
+
const $pos = editor.state.doc.resolve(block.pos);
|
|
2450
|
+
const index = $pos.index();
|
|
2451
|
+
if (direction === "up" ? index <= 0 : index >= $pos.parent.childCount - 1) return void 0;
|
|
2452
|
+
const neighbor = $pos.parent.child(direction === "up" ? index - 1 : index + 1);
|
|
2453
|
+
return {
|
|
2454
|
+
...block,
|
|
2455
|
+
to: direction === "up" ? block.pos - neighbor.nodeSize : block.pos + neighbor.nodeSize
|
|
2456
|
+
};
|
|
2457
|
+
};
|
|
2458
|
+
return {
|
|
2459
|
+
canExecute: (editor, item) => Boolean(target(editor, item)),
|
|
2460
|
+
execute: (editor, item) => {
|
|
2461
|
+
const move = target(editor, item);
|
|
2462
|
+
if (!move) return editor.chain();
|
|
2463
|
+
return editor.chain().focus().deleteRange({
|
|
2464
|
+
from: move.pos,
|
|
2465
|
+
to: move.pos + move.node.nodeSize
|
|
2466
|
+
}).insertContentAt(move.to, move.node.toJSON());
|
|
2467
|
+
},
|
|
2468
|
+
isActive: () => false
|
|
2469
|
+
};
|
|
2470
|
+
}
|
|
2471
|
+
/**
|
|
2472
|
+
* The handlers of the item kinds that ViteHub's editors use: `mark` (with `mark`), `heading` (with `level`),
|
|
2473
|
+
* `paragraph`, `blockquote`, `codeBlock`, `horizontalRule`, `bulletList`, `orderedList`, and, for the block at `pos`,
|
|
2474
|
+
* `duplicate`, `delete`, `moveUp`, `moveDown`, and `suggestion` (opens the "/" menu below it). They match Nuxt UI's
|
|
2475
|
+
* `createHandlers()` for these kinds. Spread your own over them for other kinds.
|
|
2476
|
+
*/
|
|
2477
|
+
function createEditorHandlers() {
|
|
2478
|
+
return {
|
|
2479
|
+
mark: {
|
|
2480
|
+
canExecute: (editor, { mark = "" }) => editor.can().toggleMark(mark),
|
|
2481
|
+
execute: (editor, { mark = "" }) => editor.chain().focus().toggleMark(mark),
|
|
2482
|
+
isActive: (editor, { mark = "" }) => editor.isActive(mark),
|
|
2483
|
+
isDisabled: (editor, { mark = "" }) => !editor.schema.marks[mark] || isNodeTypeSelected(editor, ["image"])
|
|
2484
|
+
},
|
|
2485
|
+
heading: {
|
|
2486
|
+
canExecute: (editor, { level = 1 }) => editor.can().toggleHeading({ level }),
|
|
2487
|
+
execute: (editor, { level = 1 }) => editor.chain().focus().toggleHeading({ level }),
|
|
2488
|
+
isActive: (editor, item) => editor.isActive("heading", { level: item.level }),
|
|
2489
|
+
isDisabled: blocked
|
|
2490
|
+
},
|
|
2491
|
+
paragraph: blockHandler("paragraph", (chain) => chain.setParagraph(), (editor) => editor.can().setParagraph()),
|
|
2492
|
+
blockquote: blockHandler("blockquote", (chain) => chain.toggleBlockquote(), (editor) => editor.can().toggleBlockquote()),
|
|
2493
|
+
codeBlock: blockHandler("codeBlock", (chain) => chain.toggleCodeBlock(), (editor) => editor.can().toggleCodeBlock()),
|
|
2494
|
+
horizontalRule: blockHandler("horizontalRule", (chain) => chain.setHorizontalRule(), (editor) => editor.can().setHorizontalRule()),
|
|
2495
|
+
bulletList: listHandler("bulletList"),
|
|
2496
|
+
orderedList: listHandler("orderedList"),
|
|
2497
|
+
duplicate: {
|
|
2498
|
+
canExecute: (editor, item) => Boolean(blockAt(editor, item)),
|
|
2499
|
+
execute: (editor, item) => {
|
|
2500
|
+
const block = blockAt(editor, item);
|
|
2501
|
+
return block ? editor.chain().focus().insertContentAt(block.pos + block.node.nodeSize, block.node.toJSON()) : editor.chain();
|
|
2502
|
+
},
|
|
2503
|
+
isActive: () => false
|
|
2504
|
+
},
|
|
2505
|
+
delete: {
|
|
2506
|
+
canExecute: (editor, item) => Boolean(blockAt(editor, item)),
|
|
2507
|
+
execute: (editor, item) => {
|
|
2508
|
+
const block = blockAt(editor, item);
|
|
2509
|
+
return block ? editor.chain().focus().deleteRange({
|
|
2510
|
+
from: block.pos,
|
|
2511
|
+
to: block.pos + block.node.nodeSize
|
|
2512
|
+
}) : editor.chain();
|
|
2513
|
+
},
|
|
2514
|
+
isActive: () => false
|
|
2515
|
+
},
|
|
2516
|
+
moveUp: moveHandler("up"),
|
|
2517
|
+
moveDown: moveHandler("down"),
|
|
2518
|
+
suggestion: {
|
|
2519
|
+
canExecute: () => true,
|
|
2520
|
+
execute: (editor, item) => {
|
|
2521
|
+
const slash = {
|
|
2522
|
+
content: [{
|
|
2523
|
+
text: "/",
|
|
2524
|
+
type: "text"
|
|
2525
|
+
}],
|
|
2526
|
+
type: "paragraph"
|
|
2527
|
+
};
|
|
2528
|
+
const block = blockAt(editor, item);
|
|
2529
|
+
if (block) return editor.chain().focus().insertContentAt(block.pos + block.node.nodeSize, slash);
|
|
2530
|
+
const { $from } = editor.state.selection;
|
|
2531
|
+
return editor.chain().focus().insertContentAt($from.before($from.depth) + $from.node($from.depth).nodeSize, slash);
|
|
2532
|
+
},
|
|
2533
|
+
isActive: () => false
|
|
2534
|
+
}
|
|
2535
|
+
};
|
|
2536
|
+
}
|
|
2537
|
+
function mapEditorItems(editor, items, handlers) {
|
|
2538
|
+
const all = {
|
|
2539
|
+
...createEditorHandlers(),
|
|
2540
|
+
...handlers
|
|
2541
|
+
};
|
|
2542
|
+
const map = (group) => group.filter(Boolean).map((entry) => {
|
|
2543
|
+
if (entry.type) return entry;
|
|
2544
|
+
const { children, ...rest } = entry;
|
|
2545
|
+
const mappedChildren = children?.length ? Array.isArray(children[0]) ? children.map(map) : map(children) : void 0;
|
|
2546
|
+
const handler = entry.kind ? all[entry.kind] : void 0;
|
|
2547
|
+
if (!handler) return {
|
|
2548
|
+
...rest,
|
|
2549
|
+
children: mappedChildren
|
|
2550
|
+
};
|
|
2551
|
+
return {
|
|
2552
|
+
...rest,
|
|
2553
|
+
active: handler.isActive(editor, entry),
|
|
2554
|
+
children: mappedChildren,
|
|
2555
|
+
disabled: Boolean(handler.isDisabled?.(editor, entry)) || !handler.canExecute(editor, entry),
|
|
2556
|
+
onSelect: () => void handler.execute(editor, entry).run()
|
|
2557
|
+
};
|
|
2558
|
+
});
|
|
2559
|
+
return items.length && Array.isArray(items[0]) ? items.map(map) : map(items);
|
|
2560
|
+
}
|
|
2561
|
+
// src/internal/markdown-editor.ts
|
|
2373
2562
|
/**
|
|
2374
2563
|
* Uploads to a route that returns the result of `blob.handleUpload()`, with progress, and resolves with the stored
|
|
2375
2564
|
* object's URL. The Blob store has to be served (`blob.serve`), so the object has a URL to link.
|
|
@@ -2384,7 +2573,7 @@ function blobUpload(route) {
|
|
|
2384
2573
|
return object.url;
|
|
2385
2574
|
};
|
|
2386
2575
|
}
|
|
2387
|
-
const
|
|
2576
|
+
const toolbarItems = [
|
|
2388
2577
|
[
|
|
2389
2578
|
{
|
|
2390
2579
|
kind: "mark",
|
|
@@ -2510,118 +2699,656 @@ const image = {
|
|
|
2510
2699
|
icon: "i-lucide-image"
|
|
2511
2700
|
};
|
|
2512
2701
|
/**
|
|
2513
|
-
*
|
|
2514
|
-
*
|
|
2515
|
-
*
|
|
2516
|
-
|
|
2702
|
+
* The state of a Markdown editor on comark-ui's editor: the editor bound to `markdown`, or the one given, with the upload
|
|
2703
|
+
* plugin on it when there is an `upload`, and the items of its bubble toolbar and "/" menu. It provides the handlers that
|
|
2704
|
+
* the menus run. Call it in `setup()`.
|
|
2705
|
+
*/
|
|
2706
|
+
function useMarkdownEditor(markdown, options = {}) {
|
|
2707
|
+
const initialEditor = options.editor;
|
|
2708
|
+
const own = initialEditor ? void 0 : useComarkEditor(markdown, {
|
|
2709
|
+
extensions: options.extensions,
|
|
2710
|
+
plugins: options.plugins
|
|
2711
|
+
});
|
|
2712
|
+
const editor = computed(() => initialEditor ?? own?.editor.value);
|
|
2713
|
+
const upload = shallowRef();
|
|
2714
|
+
watchEffect(() => {
|
|
2715
|
+
const route = unref(options.upload);
|
|
2716
|
+
const send = typeof route === "string" ? blobUpload(route) : route;
|
|
2717
|
+
upload.value = send && {
|
|
2718
|
+
upload: send,
|
|
2719
|
+
accept: unref(options.accept) ?? ((file) => /^(?:image|video|audio)\//.test(file.type)),
|
|
2720
|
+
onError: (error, file) => options.onError?.({
|
|
2721
|
+
error,
|
|
2722
|
+
file
|
|
2723
|
+
})
|
|
2724
|
+
};
|
|
2725
|
+
});
|
|
2726
|
+
watch([editor, upload], ([current, uploads], _, onCleanup) => {
|
|
2727
|
+
if (!current || !uploads || uploadKey.getState(current.state)) return;
|
|
2728
|
+
current.registerPlugin(uploadPlugin(uploads));
|
|
2729
|
+
onCleanup(() => {
|
|
2730
|
+
if (!current.isDestroyed) current.unregisterPlugin(uploadKey);
|
|
2731
|
+
});
|
|
2732
|
+
}, { immediate: true });
|
|
2733
|
+
const handlers = computed(() => ({
|
|
2734
|
+
...createEditorHandlers(),
|
|
2735
|
+
image: {
|
|
2736
|
+
canExecute: () => Boolean(upload.value),
|
|
2737
|
+
execute: (current) => ({ run: () => upload.value ? chooseFiles(current.view, upload.value) : false }),
|
|
2738
|
+
isActive: () => false,
|
|
2739
|
+
isDisabled: () => !upload.value
|
|
2740
|
+
}
|
|
2741
|
+
}));
|
|
2742
|
+
provide(editorHandlersKey, handlers);
|
|
2743
|
+
return {
|
|
2744
|
+
editor,
|
|
2745
|
+
toolbarItems,
|
|
2746
|
+
menuItems: computed(() => upload.value ? [...blocks, image] : blocks)
|
|
2747
|
+
};
|
|
2748
|
+
}
|
|
2749
|
+
// src/ui-sdk/editor.ts
|
|
2750
|
+
/**
|
|
2751
|
+
* The editor parts on ui-sdk: Nuxt UI's `UEditorToolbar`, `UEditorSuggestionMenu`, and `UEditorDragHandle`, with the
|
|
2752
|
+
* props, slots, and events that ViteHub's editors use. Positioning at the selection and the block, and dragging blocks,
|
|
2753
|
+
* stay with Tiptap's own menu plugins. They run items through the handlers that the editor provides under
|
|
2754
|
+
* `editorHandlersKey`, as Nuxt UI's do.
|
|
2517
2755
|
*/
|
|
2518
|
-
const
|
|
2519
|
-
|
|
2756
|
+
const ToggleButton = Toggle;
|
|
2757
|
+
const ToggleButtonIcon = ToggleIcon;
|
|
2758
|
+
const Bar = Toolbar;
|
|
2759
|
+
const BarButton = ToolbarButton;
|
|
2760
|
+
const BarGroup = ToolbarGroup;
|
|
2761
|
+
const BarSeparator = ToolbarSeparator;
|
|
2762
|
+
const Tip = Tooltip;
|
|
2763
|
+
const TipTrigger = TooltipTrigger;
|
|
2764
|
+
const TipContent = TooltipContent;
|
|
2765
|
+
const TipShortcut = TooltipShortcut;
|
|
2766
|
+
const DropdownMenu = Menu;
|
|
2767
|
+
const DropdownTrigger = MenuTrigger;
|
|
2768
|
+
const DropdownContent = MenuContent;
|
|
2769
|
+
const DropdownItem = MenuItem;
|
|
2770
|
+
const SlashMenu = TriggerMenu;
|
|
2771
|
+
const SlashContent = TriggerMenuContent;
|
|
2772
|
+
const SlashList = TriggerMenuList;
|
|
2773
|
+
const SlashItem = TriggerMenuItem;
|
|
2774
|
+
const SlashStatus = TriggerMenuStatus;
|
|
2775
|
+
const BlockHandle = DragHandle;
|
|
2776
|
+
const BubbleMenu$1 = BubbleMenu;
|
|
2777
|
+
function useHandlers() {
|
|
2778
|
+
return inject(editorHandlersKey, computed(createEditorHandlers), true);
|
|
2779
|
+
}
|
|
2780
|
+
const isGroups = (items) => items.length > 0 && Array.isArray(items[0]);
|
|
2781
|
+
const groupsOf = (items) => !items?.length ? [] : isGroups(items) ? items : [items];
|
|
2782
|
+
const shortcutOf = (kbds) => kbds?.length ? kbds.map((key) => key === "meta" ? "mod" : key).join("+") : void 0;
|
|
2783
|
+
/** Nuxt UI's `UEditorToolbar`, in its `fixed` and `bubble` layouts, on ui-sdk's `Toolbar`, `Toggle`, and `Menu`. */
|
|
2784
|
+
const UEditorToolbar = defineComponent({
|
|
2785
|
+
name: "UEditorToolbar",
|
|
2520
2786
|
inheritAttrs: false,
|
|
2521
2787
|
props: {
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2788
|
+
editor: {
|
|
2789
|
+
required: true,
|
|
2790
|
+
type: Object
|
|
2791
|
+
},
|
|
2792
|
+
items: {
|
|
2793
|
+
default: () => [],
|
|
2794
|
+
type: Array
|
|
2795
|
+
},
|
|
2796
|
+
layout: {
|
|
2797
|
+
default: "fixed",
|
|
2798
|
+
type: String
|
|
2799
|
+
},
|
|
2800
|
+
size: {
|
|
2801
|
+
default: "sm",
|
|
2802
|
+
type: String
|
|
2803
|
+
},
|
|
2804
|
+
/** For the `bubble` layout, as Tiptap's `BubbleMenu` takes them. */
|
|
2805
|
+
appendTo: {
|
|
2806
|
+
default: void 0,
|
|
2807
|
+
type: [Object, Function]
|
|
2808
|
+
},
|
|
2809
|
+
getReferencedVirtualElement: {
|
|
2810
|
+
default: void 0,
|
|
2811
|
+
type: Function
|
|
2812
|
+
},
|
|
2813
|
+
options: {
|
|
2814
|
+
default: void 0,
|
|
2815
|
+
type: Object
|
|
2816
|
+
},
|
|
2817
|
+
pluginKey: {
|
|
2818
|
+
default: void 0,
|
|
2819
|
+
type: [String, Object]
|
|
2820
|
+
},
|
|
2821
|
+
resizeDelay: {
|
|
2822
|
+
default: void 0,
|
|
2823
|
+
type: Number
|
|
2824
|
+
},
|
|
2825
|
+
shouldShow: {
|
|
2826
|
+
default: void 0,
|
|
2827
|
+
type: Function
|
|
2828
|
+
},
|
|
2829
|
+
updateDelay: {
|
|
2830
|
+
default: void 0,
|
|
2831
|
+
type: Number
|
|
2525
2832
|
},
|
|
2526
|
-
|
|
2833
|
+
ui: {
|
|
2834
|
+
default: () => ({}),
|
|
2835
|
+
type: Object
|
|
2836
|
+
}
|
|
2837
|
+
},
|
|
2838
|
+
setup(props, { attrs, slots }) {
|
|
2839
|
+
const UIcon = useStandIn("UIcon");
|
|
2840
|
+
const handlers = useHandlers();
|
|
2841
|
+
const icons = useViteHubUIIcons();
|
|
2842
|
+
const isActive = (item) => {
|
|
2843
|
+
if (!props.editor.isEditable) return false;
|
|
2844
|
+
if ("items" in item && item.items?.length) return groupsOf(item.items).flat().some(isActive);
|
|
2845
|
+
if (!item.kind) return "active" in item && item.active || false;
|
|
2846
|
+
return handlers.value[item.kind]?.isActive(props.editor, item) ?? false;
|
|
2847
|
+
};
|
|
2848
|
+
const isDisabled = (item) => {
|
|
2849
|
+
if (!props.editor.isEditable) return true;
|
|
2850
|
+
if ("items" in item && item.items?.length) {
|
|
2851
|
+
const actionable = groupsOf(item.items).flat().filter((entry) => entry.type !== "separator" && entry.type !== "label");
|
|
2852
|
+
return !actionable.length || actionable.every(isDisabled);
|
|
2853
|
+
}
|
|
2854
|
+
if (!item.kind) return item.disabled ?? false;
|
|
2855
|
+
const handler = handlers.value[item.kind];
|
|
2856
|
+
if (!handler) return false;
|
|
2857
|
+
return Boolean(handler.isDisabled?.(props.editor, item)) || !handler.canExecute(props.editor, item);
|
|
2858
|
+
};
|
|
2859
|
+
const onClick = (event, item) => {
|
|
2860
|
+
if (!props.editor.isEditable || isDisabled(item)) return;
|
|
2861
|
+
if (!item.kind || "items" in item && item.items) {
|
|
2862
|
+
if ("onClick" in item && item.onClick) for (const run of [item.onClick].flat()) run(event);
|
|
2863
|
+
return;
|
|
2864
|
+
}
|
|
2865
|
+
handlers.value[item.kind]?.execute(props.editor, item).run();
|
|
2866
|
+
};
|
|
2867
|
+
const content = (item) => {
|
|
2868
|
+
const child = item.items ? groupsOf(item.items).flat().find((entry) => entry.kind && isActive(entry)) : void 0;
|
|
2869
|
+
const icon = child?.icon ?? item.icon;
|
|
2870
|
+
const label = item.label !== void 0 && child?.label ? child.label : item.label;
|
|
2871
|
+
return [
|
|
2872
|
+
icon ? h(ToggleButtonIcon, () => h(UIcon, { name: icon })) : null,
|
|
2873
|
+
label ? h("span", { "data-slot": "editor-toolbar-label" }, label) : null,
|
|
2874
|
+
item.trailingIcon ? h(UIcon, {
|
|
2875
|
+
"data-slot": "editor-toolbar-trailing-icon",
|
|
2876
|
+
name: item.trailingIcon
|
|
2877
|
+
}) : null
|
|
2878
|
+
];
|
|
2879
|
+
};
|
|
2880
|
+
const named = (item) => ({ "aria-label": item["aria-label"] ?? (item.label ? void 0 : item.tooltip?.text) });
|
|
2881
|
+
const withTooltip = (item, control) => {
|
|
2882
|
+
if (!item.tooltip?.text) return control({});
|
|
2883
|
+
const shortcut = shortcutOf(item.tooltip.kbds);
|
|
2884
|
+
return h(Tip, {
|
|
2885
|
+
disabled: isDisabled(item),
|
|
2886
|
+
shortcut,
|
|
2887
|
+
type: "description"
|
|
2888
|
+
}, () => [h(TipTrigger, null, { render: ({ props: trigger }) => control(trigger) }), h(TipContent, { sideOffset: 6 }, () => [item.tooltip?.text, shortcut ? h(TipShortcut) : null])]);
|
|
2889
|
+
};
|
|
2890
|
+
const menuEntry = (entry, index) => {
|
|
2891
|
+
if (entry.type === "label") return h(MenuGroupLabel, { key: index }, () => entry.label);
|
|
2892
|
+
if (entry.type === "separator") return h(MenuSeparator, { key: index });
|
|
2893
|
+
const active = Boolean(entry.kind) && isActive(entry);
|
|
2894
|
+
return h(DropdownItem, {
|
|
2895
|
+
"data-active": active ? "" : void 0,
|
|
2896
|
+
disabled: isDisabled(entry),
|
|
2897
|
+
key: index,
|
|
2898
|
+
label: entry.label,
|
|
2899
|
+
onSelect: (event) => entry.kind ? onClick(event, entry) : entry.onSelect?.(event)
|
|
2900
|
+
}, () => [
|
|
2901
|
+
entry.icon ? h(MenuItemIcon, () => h(UIcon, { name: entry.icon })) : null,
|
|
2902
|
+
h("span", entry.label),
|
|
2903
|
+
active ? h(UIcon, {
|
|
2904
|
+
"data-slot": "editor-toolbar-check",
|
|
2905
|
+
name: icons.value.check
|
|
2906
|
+
}) : null
|
|
2907
|
+
]);
|
|
2908
|
+
};
|
|
2909
|
+
const control = (item, index) => {
|
|
2910
|
+
const slot = slots[item.slot ?? "item"];
|
|
2911
|
+
if (slot) return slot({
|
|
2912
|
+
index,
|
|
2913
|
+
isActive,
|
|
2914
|
+
isDisabled,
|
|
2915
|
+
item,
|
|
2916
|
+
onClick
|
|
2917
|
+
});
|
|
2918
|
+
const data = {
|
|
2919
|
+
"data-size": props.size,
|
|
2920
|
+
key: index
|
|
2921
|
+
};
|
|
2922
|
+
if (item.items?.length) {
|
|
2923
|
+
const groups = groupsOf(item.items);
|
|
2924
|
+
return h(DropdownMenu, { key: index }, () => [withTooltip(item, (trigger) => h(BarButton, {
|
|
2925
|
+
...data,
|
|
2926
|
+
disabled: isDisabled(item)
|
|
2927
|
+
}, { render: ({ props: button }) => h(DropdownTrigger, {
|
|
2928
|
+
...trigger,
|
|
2929
|
+
...button,
|
|
2930
|
+
...named(item),
|
|
2931
|
+
"data-active": isActive(item) ? "" : void 0,
|
|
2932
|
+
"data-slot": "toggle"
|
|
2933
|
+
}, () => content(item)) })), h(DropdownContent, {
|
|
2934
|
+
align: item.content?.align ?? "start",
|
|
2935
|
+
class: item.ui?.content,
|
|
2936
|
+
side: item.content?.side,
|
|
2937
|
+
sideOffset: item.content?.sideOffset ?? 8
|
|
2938
|
+
}, () => groups.flatMap((group, groupIndex) => [groupIndex ? h(MenuSeparator, { key: `separator-${groupIndex}` }) : null, h(MenuGroup, { key: `group-${groupIndex}` }, () => group.map(menuEntry))]))]);
|
|
2939
|
+
}
|
|
2940
|
+
if (item.kind) return withTooltip(item, (trigger) => h(ToggleButton, {
|
|
2941
|
+
...trigger,
|
|
2942
|
+
...data,
|
|
2943
|
+
...named(item),
|
|
2944
|
+
disabled: isDisabled(item),
|
|
2945
|
+
pressed: isActive(item),
|
|
2946
|
+
onPressedChange: (_pressed, details) => onClick(details.event ?? new Event("click"), item)
|
|
2947
|
+
}, () => content(item)));
|
|
2948
|
+
return withTooltip(item, (trigger) => h(BarButton, {
|
|
2949
|
+
...trigger,
|
|
2950
|
+
...data,
|
|
2951
|
+
...named(item),
|
|
2952
|
+
"data-active": isActive(item) ? "" : void 0,
|
|
2953
|
+
"data-slot": "toggle",
|
|
2954
|
+
disabled: isDisabled(item),
|
|
2955
|
+
onClick: (event) => onClick(event, item)
|
|
2956
|
+
}, () => content(item)));
|
|
2957
|
+
};
|
|
2958
|
+
return () => {
|
|
2959
|
+
props.editor.state;
|
|
2960
|
+
const groups = groupsOf(props.items);
|
|
2961
|
+
const { class: baseClass, ...rootAttrs } = attrs;
|
|
2962
|
+
const bar = h(Bar, {
|
|
2963
|
+
"aria-label": "Formatting",
|
|
2964
|
+
...props.layout === "fixed" ? rootAttrs : {},
|
|
2965
|
+
class: [
|
|
2966
|
+
"vh-editor-toolbar",
|
|
2967
|
+
props.ui.base,
|
|
2968
|
+
baseClass
|
|
2969
|
+
],
|
|
2970
|
+
"data-layout": props.layout
|
|
2971
|
+
}, () => groups.flatMap((group, groupIndex) => [h(BarGroup, {
|
|
2972
|
+
class: props.ui.group,
|
|
2973
|
+
key: `group-${groupIndex}`
|
|
2974
|
+
}, () => group.map(control)), groupIndex < groups.length - 1 ? h(BarSeparator, {
|
|
2975
|
+
class: props.ui.separator,
|
|
2976
|
+
key: `separator-${groupIndex}`
|
|
2977
|
+
}) : null]));
|
|
2978
|
+
if (props.layout !== "bubble") return bar;
|
|
2979
|
+
return h(BubbleMenu$1, {
|
|
2980
|
+
...rootAttrs,
|
|
2981
|
+
appendTo: props.appendTo,
|
|
2982
|
+
class: ["vh-editor-toolbar-root", props.ui.root],
|
|
2983
|
+
editor: props.editor,
|
|
2984
|
+
getReferencedVirtualElement: props.getReferencedVirtualElement,
|
|
2985
|
+
options: {
|
|
2986
|
+
offset: 8,
|
|
2987
|
+
shift: { padding: 8 },
|
|
2988
|
+
...props.options
|
|
2989
|
+
},
|
|
2990
|
+
pluginKey: props.pluginKey,
|
|
2991
|
+
resizeDelay: props.resizeDelay,
|
|
2992
|
+
shouldShow: props.shouldShow ?? null,
|
|
2993
|
+
tabindex: -1,
|
|
2994
|
+
updateDelay: props.updateDelay
|
|
2995
|
+
}, () => bar);
|
|
2996
|
+
};
|
|
2997
|
+
}
|
|
2998
|
+
});
|
|
2999
|
+
const collator = new Intl.Collator(void 0, {
|
|
3000
|
+
sensitivity: "base",
|
|
3001
|
+
usage: "search"
|
|
3002
|
+
});
|
|
3003
|
+
function contains(value, part) {
|
|
3004
|
+
if (!part) return true;
|
|
3005
|
+
const text = value.normalize("NFC");
|
|
3006
|
+
const search = part.normalize("NFC");
|
|
3007
|
+
for (let index = 0; index + search.length <= text.length; index++) if (collator.compare(text.slice(index, index + search.length), search) === 0) return true;
|
|
3008
|
+
return false;
|
|
3009
|
+
}
|
|
3010
|
+
function score(value, query) {
|
|
3011
|
+
if (!contains(value, query)) return void 0;
|
|
3012
|
+
if (contains(query, value)) return 0;
|
|
3013
|
+
if (collator.compare(value.slice(0, query.length), query) === 0) return 1;
|
|
3014
|
+
return 2;
|
|
3015
|
+
}
|
|
3016
|
+
function rank(items, query, fields) {
|
|
3017
|
+
if (!query) return items;
|
|
3018
|
+
const scored = [];
|
|
3019
|
+
for (const item of items) {
|
|
3020
|
+
let best;
|
|
3021
|
+
for (const field of fields) {
|
|
3022
|
+
const value = item[field];
|
|
3023
|
+
if (value == null) continue;
|
|
3024
|
+
for (const text of [value].flat().map(String)) {
|
|
3025
|
+
const found = Math.min(score(text, query) ?? 3, score(text.replace(/[\s_-]/g, ""), query) ?? 3);
|
|
3026
|
+
if (best === void 0 || found < best) best = found;
|
|
3027
|
+
}
|
|
3028
|
+
}
|
|
3029
|
+
if (best !== void 0 && best < 3) scored.push({
|
|
3030
|
+
item,
|
|
3031
|
+
score: best
|
|
3032
|
+
});
|
|
3033
|
+
}
|
|
3034
|
+
return scored.sort((a, b) => a.score - b.score).map(({ item }) => item);
|
|
3035
|
+
}
|
|
3036
|
+
const OBJECT = "";
|
|
3037
|
+
const choosable = (item) => item.type !== "label" && item.type !== "separator";
|
|
3038
|
+
/**
|
|
3039
|
+
* The editor as ui-sdk's `TriggerMenu` reads it. Offsets are document positions. The text before the caret is the text
|
|
3040
|
+
* of its block, after a line break that stands for the block's start, so a trigger at the start of a block matches as
|
|
3041
|
+
* one after a space does.
|
|
3042
|
+
*/
|
|
3043
|
+
function tiptapAdapter(editor) {
|
|
3044
|
+
return {
|
|
3045
|
+
get element() {
|
|
3046
|
+
return editor.isDestroyed ? void 0 : editor.view.dom;
|
|
3047
|
+
},
|
|
3048
|
+
textBefore(length) {
|
|
3049
|
+
const { $head } = editor.state.selection;
|
|
3050
|
+
if (!$head.parent.isTextblock) return null;
|
|
3051
|
+
const from = Math.max(0, $head.parentOffset - length);
|
|
3052
|
+
const text = $head.parent.textBetween(from, $head.parentOffset, void 0, OBJECT);
|
|
3053
|
+
return from === 0 && text.length < length ? {
|
|
3054
|
+
offset: $head.start() - 1,
|
|
3055
|
+
text: `\n${text}`
|
|
3056
|
+
} : {
|
|
3057
|
+
offset: $head.start() + from,
|
|
3058
|
+
text
|
|
3059
|
+
};
|
|
3060
|
+
},
|
|
3061
|
+
selection() {
|
|
3062
|
+
if (editor.isDestroyed || !editor.view.hasFocus()) return null;
|
|
3063
|
+
const { from, to } = editor.state.selection;
|
|
3064
|
+
return {
|
|
3065
|
+
end: to,
|
|
3066
|
+
start: from
|
|
3067
|
+
};
|
|
3068
|
+
},
|
|
3069
|
+
rectAt(offset) {
|
|
3070
|
+
try {
|
|
3071
|
+
const rect = editor.view.coordsAtPos(offset);
|
|
3072
|
+
return {
|
|
3073
|
+
height: rect.bottom - rect.top,
|
|
3074
|
+
width: Math.max(0, rect.right - rect.left),
|
|
3075
|
+
x: rect.left,
|
|
3076
|
+
y: rect.top
|
|
3077
|
+
};
|
|
3078
|
+
} catch {
|
|
3079
|
+
return null;
|
|
3080
|
+
}
|
|
3081
|
+
},
|
|
3082
|
+
replace(range, content) {
|
|
3083
|
+
editor.chain().focus().insertContentAt({
|
|
3084
|
+
from: range.start,
|
|
3085
|
+
to: range.end
|
|
3086
|
+
}, typeof content === "string" ? content : content.label ?? "").run();
|
|
3087
|
+
},
|
|
3088
|
+
subscribe(listener) {
|
|
3089
|
+
const onTransaction = ({ transaction }) => {
|
|
3090
|
+
if (!transaction.docChanged) {
|
|
3091
|
+
if (transaction.selectionSet) listener({ type: "selection" });
|
|
3092
|
+
return;
|
|
3093
|
+
}
|
|
3094
|
+
const user = !transaction.getMeta("y-sync$");
|
|
3095
|
+
for (const step of transaction.steps) {
|
|
3096
|
+
if (!(step instanceof ReplaceStep)) continue;
|
|
3097
|
+
listener({
|
|
3098
|
+
inserted: step.slice.content.textBetween(0, step.slice.content.size, "\n", OBJECT),
|
|
3099
|
+
range: {
|
|
3100
|
+
end: step.to,
|
|
3101
|
+
start: step.from
|
|
3102
|
+
},
|
|
3103
|
+
type: "input",
|
|
3104
|
+
user
|
|
3105
|
+
});
|
|
3106
|
+
}
|
|
3107
|
+
};
|
|
3108
|
+
const onComposition = (event) => listener({ type: event.type === "compositionstart" ? "compositionstart" : "compositionend" });
|
|
3109
|
+
editor.on("transaction", onTransaction);
|
|
3110
|
+
editor.view.dom.addEventListener("compositionstart", onComposition);
|
|
3111
|
+
editor.view.dom.addEventListener("compositionend", onComposition);
|
|
3112
|
+
return () => {
|
|
3113
|
+
editor.off("transaction", onTransaction);
|
|
3114
|
+
if (!editor.isDestroyed) {
|
|
3115
|
+
editor.view.dom.removeEventListener("compositionstart", onComposition);
|
|
3116
|
+
editor.view.dom.removeEventListener("compositionend", onComposition);
|
|
3117
|
+
}
|
|
3118
|
+
};
|
|
3119
|
+
},
|
|
3120
|
+
composing: () => editor.view.composing
|
|
3121
|
+
};
|
|
3122
|
+
}
|
|
3123
|
+
/**
|
|
3124
|
+
* Nuxt UI's `UEditorSuggestionMenu` on ui-sdk's `TriggerMenu`. Typing `char` opens a list at the caret, the text after
|
|
3125
|
+
* it filters `items` with Nuxt UI's ranking, the arrow keys move the highlight and wrap, Enter or Tab runs it, and
|
|
3126
|
+
* Escape closes the list until the trigger is typed again. The caret stays in the editor, which points at the list
|
|
3127
|
+
* with `aria-controls` and `aria-activedescendant`.
|
|
3128
|
+
*/
|
|
3129
|
+
const UEditorSuggestionMenu = defineComponent({
|
|
3130
|
+
name: "UEditorSuggestionMenu",
|
|
3131
|
+
inheritAttrs: false,
|
|
3132
|
+
props: {
|
|
2527
3133
|
editor: {
|
|
2528
|
-
|
|
2529
|
-
|
|
3134
|
+
required: true,
|
|
3135
|
+
type: Object
|
|
2530
3136
|
},
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
type:
|
|
2534
|
-
default: void 0
|
|
3137
|
+
items: {
|
|
3138
|
+
default: () => [],
|
|
3139
|
+
type: Array
|
|
2535
3140
|
},
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
type:
|
|
2539
|
-
default: void 0
|
|
3141
|
+
char: {
|
|
3142
|
+
default: "/",
|
|
3143
|
+
type: String
|
|
2540
3144
|
},
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
type: Array
|
|
2544
|
-
default: void 0
|
|
3145
|
+
filterFields: {
|
|
3146
|
+
default: () => ["label"],
|
|
3147
|
+
type: Array
|
|
2545
3148
|
},
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
type:
|
|
2549
|
-
|
|
3149
|
+
limit: {
|
|
3150
|
+
default: 42,
|
|
3151
|
+
type: Number
|
|
3152
|
+
},
|
|
3153
|
+
ui: {
|
|
3154
|
+
default: () => ({}),
|
|
3155
|
+
type: Object
|
|
3156
|
+
}
|
|
3157
|
+
},
|
|
3158
|
+
setup(props, { attrs }) {
|
|
3159
|
+
const UIcon = useStandIn("UIcon");
|
|
3160
|
+
const handlers = useHandlers();
|
|
3161
|
+
const query = ref("");
|
|
3162
|
+
const adapter = shallowRef();
|
|
3163
|
+
onMounted(() => {
|
|
3164
|
+
if (!props.editor.isDestroyed) adapter.value = tiptapAdapter(props.editor);
|
|
3165
|
+
});
|
|
3166
|
+
const flat = computed(() => groupsOf(props.items).flat());
|
|
3167
|
+
const matches = computed(() => rank(flat.value, query.value, props.filterFields).slice(0, props.limit));
|
|
3168
|
+
const groups = computed(() => groupsOf(props.items).map((group) => group.filter((item) => matches.value.includes(item)).sort((a, b) => matches.value.indexOf(a) - matches.value.indexOf(b))).filter((group) => group.some(choosable)));
|
|
3169
|
+
const triggers = computed(() => [{
|
|
3170
|
+
char: props.char,
|
|
3171
|
+
filter: false
|
|
3172
|
+
}]);
|
|
3173
|
+
const onSelect = (value, details) => {
|
|
3174
|
+
details.preventDefault();
|
|
3175
|
+
const item = flat.value[Number(value)];
|
|
3176
|
+
if (!item?.kind) return;
|
|
3177
|
+
props.editor.chain().focus().deleteRange({
|
|
3178
|
+
from: details.match.start,
|
|
3179
|
+
to: details.match.end
|
|
3180
|
+
}).run();
|
|
3181
|
+
handlers.value[item.kind]?.execute(props.editor, item).run();
|
|
3182
|
+
};
|
|
3183
|
+
return () => h(SlashMenu, {
|
|
3184
|
+
editor: adapter.value,
|
|
3185
|
+
loop: true,
|
|
3186
|
+
triggers: triggers.value,
|
|
3187
|
+
onQueryChange: (next) => query.value = next,
|
|
3188
|
+
onSelect
|
|
3189
|
+
}, () => [h(SlashStatus, { class: "vh-editor-suggestion-menu__status" }), h(SlashContent, {
|
|
3190
|
+
...attrs,
|
|
3191
|
+
align: "start",
|
|
3192
|
+
class: [
|
|
3193
|
+
"vh-editor-suggestion-menu",
|
|
3194
|
+
props.ui.content,
|
|
3195
|
+
attrs.class
|
|
3196
|
+
],
|
|
3197
|
+
collisionPadding: 8,
|
|
3198
|
+
side: "bottom",
|
|
3199
|
+
sideOffset: 8
|
|
3200
|
+
}, () => h(SlashList, { "aria-label": "Insert block" }, () => groups.value.flatMap((group, groupIndex) => [groupIndex ? h(TriggerMenuSeparator, { key: `separator-${groupIndex}` }) : null, h(TriggerMenuGroup, { key: `group-${groupIndex}` }, () => group.map((item, index) => {
|
|
3201
|
+
if (item.type === "label") return h(TriggerMenuGroupLabel, {
|
|
3202
|
+
class: item.class,
|
|
3203
|
+
key: `label-${index}`
|
|
3204
|
+
}, () => item.label);
|
|
3205
|
+
if (item.type === "separator") return h(TriggerMenuSeparator, { key: `separator-${index}` });
|
|
3206
|
+
const value = String(flat.value.indexOf(item));
|
|
3207
|
+
return h(SlashItem, {
|
|
3208
|
+
class: item.class,
|
|
3209
|
+
disabled: item.disabled,
|
|
3210
|
+
key: value,
|
|
3211
|
+
keywords: item.keywords,
|
|
3212
|
+
label: item.label,
|
|
3213
|
+
value
|
|
3214
|
+
}, () => [item.icon ? h(TriggerMenuItemIcon, () => h(UIcon, { name: item.icon })) : null, h("span", { "data-slot": "editor-suggestion-text" }, [h("span", { "data-slot": "editor-suggestion-label" }, item.label), item.description ? h("span", { "data-slot": "editor-suggestion-description" }, item.description) : null])]);
|
|
3215
|
+
}))])))]);
|
|
3216
|
+
}
|
|
3217
|
+
});
|
|
3218
|
+
/**
|
|
3219
|
+
* Moves the drag handle to each new place with the list mover of the motion layer, as a neighbor of a list moves. The
|
|
3220
|
+
* drag handle extension places it with `left` and `top`. A handle that was hidden shows at its new place at once.
|
|
3221
|
+
*/
|
|
3222
|
+
function followPlace(element) {
|
|
3223
|
+
const parent = element.parentElement;
|
|
3224
|
+
if (!parent) return () => {};
|
|
3225
|
+
const list = createMotionList(parent, { items: () => [element] });
|
|
3226
|
+
const read = () => ({
|
|
3227
|
+
place: `${element.style.left} ${element.style.top}`,
|
|
3228
|
+
shown: element.style.visibility !== "hidden"
|
|
3229
|
+
});
|
|
3230
|
+
let last = read();
|
|
3231
|
+
list.measure();
|
|
3232
|
+
const observer = new MutationObserver(() => {
|
|
3233
|
+
const next = read();
|
|
3234
|
+
if (next.place === last.place && next.shown === last.shown) return;
|
|
3235
|
+
if (next.shown && last.shown) list.play();
|
|
3236
|
+
last = next;
|
|
3237
|
+
list.measure();
|
|
3238
|
+
});
|
|
3239
|
+
observer.observe(element, {
|
|
3240
|
+
attributes: true,
|
|
3241
|
+
attributeFilter: ["style"]
|
|
3242
|
+
});
|
|
3243
|
+
return () => {
|
|
3244
|
+
observer.disconnect();
|
|
3245
|
+
list.destroy();
|
|
3246
|
+
};
|
|
3247
|
+
}
|
|
3248
|
+
/**
|
|
3249
|
+
* Nuxt UI's `UEditorDragHandle`: a handle beside the block under the pointer, which drags the block to move it. A press
|
|
3250
|
+
* selects the block and emits `nodeChange`. The default slot replaces the button and gets `onClick`, which selects the
|
|
3251
|
+
* block and returns it, and `ui.handle()`, the class of a handle button.
|
|
3252
|
+
*/
|
|
3253
|
+
const UEditorDragHandle = defineComponent({
|
|
3254
|
+
name: "UEditorDragHandle",
|
|
3255
|
+
inheritAttrs: false,
|
|
3256
|
+
props: {
|
|
3257
|
+
editor: {
|
|
3258
|
+
required: true,
|
|
3259
|
+
type: Object
|
|
3260
|
+
},
|
|
3261
|
+
icon: {
|
|
3262
|
+
default: void 0,
|
|
3263
|
+
type: String
|
|
3264
|
+
},
|
|
3265
|
+
nested: {
|
|
3266
|
+
default: false,
|
|
3267
|
+
type: [Boolean, Object]
|
|
3268
|
+
},
|
|
3269
|
+
pluginKey: {
|
|
3270
|
+
default: void 0,
|
|
3271
|
+
type: [String, Object]
|
|
3272
|
+
},
|
|
3273
|
+
ui: {
|
|
3274
|
+
default: () => ({}),
|
|
3275
|
+
type: Object
|
|
2550
3276
|
}
|
|
2551
3277
|
},
|
|
2552
3278
|
emits: {
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
uploadError: (_error, _file) => true
|
|
3279
|
+
hover: (_node) => true,
|
|
3280
|
+
nodeChange: (_node) => true
|
|
2556
3281
|
},
|
|
2557
3282
|
setup(props, { attrs, emit, slots }) {
|
|
2558
|
-
const
|
|
2559
|
-
const
|
|
2560
|
-
const
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
}
|
|
2568
|
-
const
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
}
|
|
2573
|
-
const
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
3283
|
+
const UButton = useStandIn("UButton");
|
|
3284
|
+
const current = ref();
|
|
3285
|
+
const nodeAt = (pos) => {
|
|
3286
|
+
if (pos == null || pos < 0) return void 0;
|
|
3287
|
+
const node = props.editor.state.doc.nodeAt(pos);
|
|
3288
|
+
return node ? {
|
|
3289
|
+
node: node.toJSON(),
|
|
3290
|
+
pos
|
|
3291
|
+
} : void 0;
|
|
3292
|
+
};
|
|
3293
|
+
const onNodeChange = ({ pos }) => {
|
|
3294
|
+
current.value = pos;
|
|
3295
|
+
const found = nodeAt(pos);
|
|
3296
|
+
if (found) emit("hover", found);
|
|
3297
|
+
};
|
|
3298
|
+
const onClick = () => {
|
|
3299
|
+
const found = nodeAt(current.value);
|
|
3300
|
+
if (!found) return void 0;
|
|
3301
|
+
emit("nodeChange", found);
|
|
3302
|
+
props.editor.chain().setNodeSelection(found.pos).run();
|
|
3303
|
+
return found;
|
|
3304
|
+
};
|
|
3305
|
+
const ui = { handle: (options) => [
|
|
3306
|
+
"vh-editor-drag-handle__handle",
|
|
3307
|
+
props.ui.handle,
|
|
3308
|
+
options?.class
|
|
3309
|
+
].filter(Boolean).join(" ") };
|
|
3310
|
+
const handle = ref();
|
|
3311
|
+
let stopFollowing;
|
|
3312
|
+
onMounted(() => {
|
|
3313
|
+
const element = handle.value?.$el;
|
|
3314
|
+
if (element instanceof HTMLElement) stopFollowing = followPlace(element);
|
|
2582
3315
|
});
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
isActive: () => false,
|
|
2596
|
-
isDisabled: () => !options.value
|
|
2597
|
-
}
|
|
2598
|
-
}));
|
|
2599
|
-
provide(editorHandlersKey, handlers);
|
|
2600
|
-
const menu = computed(() => options.value ? [...blocks, image] : blocks);
|
|
2601
|
-
return () => {
|
|
2602
|
-
const current = editor.value;
|
|
2603
|
-
if (!current) return null;
|
|
2604
|
-
return h("div", {
|
|
2605
|
-
...attrs,
|
|
2606
|
-
class: ["vh-markdown-editor", attrs.class]
|
|
2607
|
-
}, [
|
|
2608
|
-
h("div", { class: "vh-markdown-editor-content vh-typeset" }, [h("style", {
|
|
2609
|
-
"data-comark-typeset": "",
|
|
2610
|
-
innerHTML: typesetCss
|
|
2611
|
-
}), h(EditorContent, { editor: current })]),
|
|
2612
|
-
h(UEditorToolbar, {
|
|
2613
|
-
editor: current,
|
|
2614
|
-
items: toolbar,
|
|
2615
|
-
layout: "bubble"
|
|
2616
|
-
}),
|
|
2617
|
-
h(UEditorSuggestionMenu, {
|
|
2618
|
-
editor: current,
|
|
2619
|
-
items: menu.value
|
|
2620
|
-
}),
|
|
2621
|
-
h(UEditorDragHandle, { editor: current }),
|
|
2622
|
-
slots.default?.({ editor: current })
|
|
2623
|
-
]);
|
|
3316
|
+
onBeforeUnmount(() => stopFollowing?.());
|
|
3317
|
+
const computePositionConfig = {
|
|
3318
|
+
middleware: [
|
|
3319
|
+
offset(({ rects }) => ({
|
|
3320
|
+
alignmentAxis: rects.reference.height > 40 ? 0 : (rects.reference.height - rects.floating.height) / 2,
|
|
3321
|
+
mainAxis: 8
|
|
3322
|
+
})),
|
|
3323
|
+
flip(),
|
|
3324
|
+
shift()
|
|
3325
|
+
],
|
|
3326
|
+
placement: "left-start",
|
|
3327
|
+
strategy: "absolute"
|
|
2624
3328
|
};
|
|
3329
|
+
return () => h(BlockHandle, {
|
|
3330
|
+
class: ["vh-editor-drag-handle", props.ui.root].filter(Boolean).join(" "),
|
|
3331
|
+
computePositionConfig,
|
|
3332
|
+
ref: handle,
|
|
3333
|
+
"data-slot": "editor-drag-handle",
|
|
3334
|
+
editor: props.editor,
|
|
3335
|
+
nested: props.nested,
|
|
3336
|
+
onClick,
|
|
3337
|
+
onNodeChange,
|
|
3338
|
+
...props.pluginKey ? { pluginKey: props.pluginKey } : {}
|
|
3339
|
+
}, () => slots.default ? slots.default({
|
|
3340
|
+
onClick,
|
|
3341
|
+
ui
|
|
3342
|
+
}) : h(UButton, {
|
|
3343
|
+
"aria-label": "Drag to move, or press to select the block",
|
|
3344
|
+
color: "neutral",
|
|
3345
|
+
icon: props.icon ?? "i-lucide-grip-vertical",
|
|
3346
|
+
size: "sm",
|
|
3347
|
+
variant: "ghost",
|
|
3348
|
+
...attrs,
|
|
3349
|
+
class: ui.handle({ class: attrs.class }),
|
|
3350
|
+
"data-slot": "editor-drag-handle-button"
|
|
3351
|
+
}));
|
|
2625
3352
|
}
|
|
2626
3353
|
});
|
|
2627
|
-
export { blobUpload as n,
|
|
3354
|
+
export { useMarkdownEditor as a, mapEditorItems as c, blobUpload as i, UEditorSuggestionMenu as n, createEditorHandlers as o, UEditorToolbar as r, editorHandlersKey as s, UEditorDragHandle as t };
|