@milkdown/crepe 7.4.0 → 7.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/clsx-dASsG01A.js +6 -0
- package/lib/cjs/clsx-dASsG01A.js.map +1 -0
- package/lib/cjs/{index-5PcT4iSf.js → index--2zEz40J.js} +8 -22
- package/lib/cjs/{index-5PcT4iSf.js.map → index--2zEz40J.js.map} +1 -1
- package/lib/cjs/{index-lrFGGa_l.js → index-5n9R-QCl.js} +5 -19
- package/lib/cjs/{index-lrFGGa_l.js.map → index-5n9R-QCl.js.map} +1 -1
- package/lib/cjs/{index-SxWWV8XD.js → index-HEdBw63r.js} +8 -22
- package/lib/cjs/{index-SxWWV8XD.js.map → index-HEdBw63r.js.map} +1 -1
- package/lib/cjs/{index-vlxA_KJ8.js → index-Hlt9dRH5.js} +5 -19
- package/lib/cjs/{index-vlxA_KJ8.js.map → index-Hlt9dRH5.js.map} +1 -1
- package/lib/cjs/{index-TEjdwq--.js → index-KCW2CzRk.js} +8 -22
- package/lib/{esm/index-DoEghZHy.js.map → cjs/index-KCW2CzRk.js.map} +1 -1
- package/lib/cjs/{index-qRg5-QJH.js → index-KSZhahYb.js} +6 -20
- package/lib/cjs/{index-qRg5-QJH.js.map → index-KSZhahYb.js.map} +1 -1
- package/lib/cjs/index-N1cRxqdw.js +39 -0
- package/lib/cjs/index-N1cRxqdw.js.map +1 -0
- package/lib/cjs/{index-fkT0ywfA.js → index-NNo_VSEA.js} +5 -19
- package/lib/cjs/{index-fkT0ywfA.js.map → index-NNo_VSEA.js.map} +1 -1
- package/lib/cjs/{index-OtaMLv5l.js → index-O1bDbloo.js} +5 -19
- package/lib/cjs/{index-OtaMLv5l.js.map → index-O1bDbloo.js.map} +1 -1
- package/lib/cjs/{index-mJ47ZWO2.js → index-OPh9naof.js} +8 -22
- package/lib/cjs/{index-mJ47ZWO2.js.map → index-OPh9naof.js.map} +1 -1
- package/lib/cjs/{index-OA_u95ey.js → index-PAhfZtcH.js} +5 -19
- package/lib/cjs/{index-OA_u95ey.js.map → index-PAhfZtcH.js.map} +1 -1
- package/lib/cjs/{index-zBr61zy6.js → index-PeRHVz4A.js} +5 -19
- package/lib/{esm/index-6P9Xk934.js.map → cjs/index-PeRHVz4A.js.map} +1 -1
- package/lib/cjs/{index-llNS_EuP.js → index-U7GWrg-w.js} +26 -470
- package/lib/cjs/index-U7GWrg-w.js.map +1 -0
- package/lib/cjs/{index-wXLifZgm.js → index-UTb0Az5e.js} +2 -2
- package/lib/cjs/{index-wXLifZgm.js.map → index-UTb0Az5e.js.map} +1 -1
- package/lib/cjs/{index-t_GA5F26.js → index-UnEAyH8X.js} +5 -19
- package/lib/cjs/{index-t_GA5F26.js.map → index-UnEAyH8X.js.map} +1 -1
- package/lib/cjs/{index-i0_v2uVp.js → index-VCkq0ru1.js} +5 -19
- package/lib/{esm/index-4QzlLVWs.js.map → cjs/index-VCkq0ru1.js.map} +1 -1
- package/lib/cjs/{index-OIQn1x0L.js → index-WQl7Du53.js} +4 -18
- package/lib/cjs/index-WQl7Du53.js.map +1 -0
- package/lib/cjs/{index-GEIgbcVc.js → index-ahL5MvrQ.js} +28 -42
- package/lib/cjs/{index-GEIgbcVc.js.map → index-ahL5MvrQ.js.map} +1 -1
- package/lib/cjs/{index-tbEq3xma.js → index-bpgWLeRY.js} +5 -19
- package/lib/cjs/{index-tbEq3xma.js.map → index-bpgWLeRY.js.map} +1 -1
- package/lib/cjs/index-dEVmN_aj.js +26 -0
- package/lib/cjs/index-dEVmN_aj.js.map +1 -0
- package/lib/cjs/{index-w9buMrFW.js → index-fZupvR_f.js} +8 -22
- package/lib/{esm/index-hQaRWeq1.js.map → cjs/index-fZupvR_f.js.map} +1 -1
- package/lib/cjs/{index-ortUqbAp.js → index-gSM-jgti.js} +5 -19
- package/lib/{esm/index-oMy83ynO.js.map → cjs/index-gSM-jgti.js.map} +1 -1
- package/lib/cjs/{index-LdEYPSZc.js → index-jlPr_A_N.js} +5 -19
- package/lib/cjs/{index-LdEYPSZc.js.map → index-jlPr_A_N.js.map} +1 -1
- package/lib/cjs/index-ocxd4A-M.js +675 -0
- package/lib/cjs/index-ocxd4A-M.js.map +1 -0
- package/lib/cjs/{index-xqKfEyRA.js → index-rFFAL9YA.js} +14 -17
- package/lib/cjs/index-rFFAL9YA.js.map +1 -0
- package/lib/cjs/index-tlx25I_m.js +36 -0
- package/lib/cjs/index-tlx25I_m.js.map +1 -0
- package/lib/cjs/index-tqAbVyds.js +28 -0
- package/lib/cjs/index-tqAbVyds.js.map +1 -0
- package/lib/cjs/index-udZSknd8.js +167 -0
- package/lib/cjs/index-udZSknd8.js.map +1 -0
- package/lib/cjs/index-uleaJDBC.js +19 -0
- package/lib/cjs/index-uleaJDBC.js.map +1 -0
- package/lib/cjs/{index-de3dfsQr.js → index-urB-WDqA.js} +7 -21
- package/lib/cjs/{index-de3dfsQr.js.map → index-urB-WDqA.js.map} +1 -1
- package/lib/cjs/{index-78P4PeZ9.js → index-xWgWtxUR.js} +6 -20
- package/lib/cjs/{index-78P4PeZ9.js.map → index-xWgWtxUR.js.map} +1 -1
- package/lib/cjs/index-z6pe2alg.js.map +1 -1
- package/lib/cjs/index.js +150 -13
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/todoList-YYRQo7wG.js +404 -0
- package/lib/cjs/todoList-YYRQo7wG.js.map +1 -0
- package/lib/esm/clsx-RxCLxYpD.js +4 -0
- package/lib/esm/clsx-RxCLxYpD.js.map +1 -0
- package/lib/esm/{index-a-SAfeeT.js → index-1NetiFdJ.js} +8 -22
- package/lib/esm/{index-a-SAfeeT.js.map → index-1NetiFdJ.js.map} +1 -1
- package/lib/esm/{index-NmjiRA0M.js → index-2I_xbjAZ.js} +28 -42
- package/lib/esm/{index-NmjiRA0M.js.map → index-2I_xbjAZ.js.map} +1 -1
- package/lib/esm/{index-Grquo08f.js → index-2huXYfuJ.js} +8 -22
- package/lib/esm/{index-Grquo08f.js.map → index-2huXYfuJ.js.map} +1 -1
- package/lib/esm/{index-U8q-F7hU.js → index-4x6_TVZv.js} +5 -19
- package/lib/esm/{index-U8q-F7hU.js.map → index-4x6_TVZv.js.map} +1 -1
- package/lib/esm/index-6JoGWH2I.js +17 -0
- package/lib/esm/index-6JoGWH2I.js.map +1 -0
- package/lib/esm/{index-x-zW6gKj.js → index-A-dNwMMf.js} +2 -2
- package/lib/esm/{index-x-zW6gKj.js.map → index-A-dNwMMf.js.map} +1 -1
- package/lib/esm/{index-oMy83ynO.js → index-AV99ipmP.js} +5 -19
- package/lib/{cjs/index-ortUqbAp.js.map → esm/index-AV99ipmP.js.map} +1 -1
- package/lib/esm/{index-VyZguCIt.js → index-CMGDOz11.js} +10 -13
- package/lib/esm/index-CMGDOz11.js.map +1 -0
- package/lib/esm/index-HlPKwzLC.js +34 -0
- package/lib/esm/index-HlPKwzLC.js.map +1 -0
- package/lib/esm/index-Jvxff1vU.js.map +1 -1
- package/lib/esm/{index-vwrMVELn.js → index-PC2bahtq.js} +5 -19
- package/lib/esm/{index-vwrMVELn.js.map → index-PC2bahtq.js.map} +1 -1
- package/lib/esm/{index-UBeneu17.js → index-QBYz82jZ.js} +5 -19
- package/lib/esm/{index-UBeneu17.js.map → index-QBYz82jZ.js.map} +1 -1
- package/lib/esm/{index-bsED907r.js → index-W1pAMr_8.js} +6 -20
- package/lib/esm/{index-bsED907r.js.map → index-W1pAMr_8.js.map} +1 -1
- package/lib/esm/{index-q-qE7-96.js → index-Xzdc2jbA.js} +25 -469
- package/lib/esm/index-Xzdc2jbA.js.map +1 -0
- package/lib/esm/{index-A9zdyi2L.js → index-ZAtZWqJQ.js} +5 -19
- package/lib/esm/{index-A9zdyi2L.js.map → index-ZAtZWqJQ.js.map} +1 -1
- package/lib/esm/index-_A9vu1ED.js +673 -0
- package/lib/esm/index-_A9vu1ED.js.map +1 -0
- package/lib/esm/{index-U71v7KdA.js → index-bnSKBrbD.js} +5 -19
- package/lib/esm/{index-U71v7KdA.js.map → index-bnSKBrbD.js.map} +1 -1
- package/lib/esm/index-fVrfHXda.js +24 -0
- package/lib/esm/index-fVrfHXda.js.map +1 -0
- package/lib/esm/{index-PkBZpDL4.js → index-ftnOhuRS.js} +4 -18
- package/lib/esm/index-ftnOhuRS.js.map +1 -0
- package/lib/esm/{index-4oMdufW4.js → index-iQPB0Rdl.js} +6 -20
- package/lib/esm/{index-4oMdufW4.js.map → index-iQPB0Rdl.js.map} +1 -1
- package/lib/esm/{index-0khVa44f.js → index-kPj3-TKp.js} +5 -19
- package/lib/esm/{index-0khVa44f.js.map → index-kPj3-TKp.js.map} +1 -1
- package/lib/esm/{index-hQaRWeq1.js → index-kgOR7SZ6.js} +8 -22
- package/lib/{cjs/index-w9buMrFW.js.map → esm/index-kgOR7SZ6.js.map} +1 -1
- package/lib/esm/index-lm00PM0y.js +165 -0
- package/lib/esm/index-lm00PM0y.js.map +1 -0
- package/lib/esm/{index-4QzlLVWs.js → index-m49Bj3q7.js} +5 -19
- package/lib/{cjs/index-i0_v2uVp.js.map → esm/index-m49Bj3q7.js.map} +1 -1
- package/lib/esm/index-ohmbt6Ys.js +37 -0
- package/lib/esm/index-ohmbt6Ys.js.map +1 -0
- package/lib/esm/{index-DoEghZHy.js → index-sWVjGw-3.js} +8 -22
- package/lib/esm/index-sWVjGw-3.js.map +1 -0
- package/lib/esm/{index-L7VXk-jT.js → index-twh8lL5o.js} +5 -19
- package/lib/esm/{index-L7VXk-jT.js.map → index-twh8lL5o.js.map} +1 -1
- package/lib/esm/{index-6P9Xk934.js → index-v02MCz4_.js} +5 -19
- package/lib/{cjs/index-zBr61zy6.js.map → esm/index-v02MCz4_.js.map} +1 -1
- package/lib/esm/index-v3rvbocl.js +26 -0
- package/lib/esm/index-v3rvbocl.js.map +1 -0
- package/lib/esm/{index-7BVeXLQZ.js → index-wEXT8mbN.js} +5 -19
- package/lib/esm/{index-7BVeXLQZ.js.map → index-wEXT8mbN.js.map} +1 -1
- package/lib/esm/{index-rwcSpYkt.js → index-wFIac5Kw.js} +7 -21
- package/lib/esm/{index-rwcSpYkt.js.map → index-wFIac5Kw.js.map} +1 -1
- package/lib/esm/{index-bVubJ6Rv.js → index-wg94ewRo.js} +8 -22
- package/lib/esm/{index-bVubJ6Rv.js.map → index-wg94ewRo.js.map} +1 -1
- package/lib/esm/index.js +152 -11
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/todoList-9QsDDcmB.js +368 -0
- package/lib/esm/todoList-9QsDDcmB.js.map +1 -0
- package/lib/theme/_internal/classic-common.css +3 -2
- package/lib/theme/common/block-edit.css +3 -1
- package/lib/theme/common/code-mirror.css +15 -0
- package/lib/theme/common/cursor.css +1 -1
- package/lib/theme/common/image-block.css +2 -0
- package/lib/theme/common/link-tooltip.css +10 -13
- package/lib/theme/common/list-item.css +16 -1
- package/lib/theme/common/prosemirror.css +1 -1
- package/lib/theme/common/style.css +1 -0
- package/lib/theme/common/table.css +217 -0
- package/lib/theme/common/toolbar.css +11 -4
- package/lib/theme/{classic-dark → crepe-dark}/style.css +2 -2
- package/lib/theme/frame/style.css +28 -0
- package/lib/theme/frame-dark/style.css +28 -0
- package/lib/theme/nord/style.css +28 -0
- package/lib/theme/nord-dark/style.css +28 -0
- package/lib/types/core/crepe.d.ts +5 -3
- package/lib/types/core/crepe.d.ts.map +1 -1
- package/lib/types/core/slice.d.ts +2 -2
- package/lib/types/core/slice.d.ts.map +1 -1
- package/lib/types/feature/block-edit/handle/component.d.ts +3 -0
- package/lib/types/feature/block-edit/handle/component.d.ts.map +1 -1
- package/lib/types/feature/block-edit/handle/index.d.ts +5 -4
- package/lib/types/feature/block-edit/handle/index.d.ts.map +1 -1
- package/lib/types/feature/block-edit/index.d.ts +43 -2
- package/lib/types/feature/block-edit/index.d.ts.map +1 -1
- package/lib/types/feature/block-edit/menu/component.d.ts +3 -1
- package/lib/types/feature/block-edit/menu/component.d.ts.map +1 -1
- package/lib/types/feature/block-edit/menu/config.d.ts +3 -12
- package/lib/types/feature/block-edit/menu/config.d.ts.map +1 -1
- package/lib/types/feature/block-edit/menu/group-builder.d.ts +29 -0
- package/lib/types/feature/block-edit/menu/group-builder.d.ts.map +1 -0
- package/lib/types/feature/block-edit/menu/index.d.ts +5 -4
- package/lib/types/feature/block-edit/menu/index.d.ts.map +1 -1
- package/lib/types/feature/block-edit/menu/utils.d.ts +28 -0
- package/lib/types/feature/block-edit/menu/utils.d.ts.map +1 -0
- package/lib/types/feature/code-mirror/index.d.ts +9 -1
- package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
- package/lib/types/feature/cursor/index.d.ts +1 -1
- package/lib/types/feature/cursor/index.d.ts.map +1 -1
- package/lib/types/feature/image-block/index.d.ts +19 -2
- package/lib/types/feature/image-block/index.d.ts.map +1 -1
- package/lib/types/feature/index.d.ts +17 -2
- package/lib/types/feature/index.d.ts.map +1 -1
- package/lib/types/feature/link-tooltip/index.d.ts +12 -2
- package/lib/types/feature/link-tooltip/index.d.ts.map +1 -1
- package/lib/types/feature/list-item/index.d.ts +8 -2
- package/lib/types/feature/list-item/index.d.ts.map +1 -1
- package/lib/types/feature/placeholder/index.d.ts +2 -2
- package/lib/types/feature/placeholder/index.d.ts.map +1 -1
- package/lib/types/feature/shared.d.ts +3 -1
- package/lib/types/feature/shared.d.ts.map +1 -1
- package/lib/types/feature/table/index.d.ts +16 -0
- package/lib/types/feature/table/index.d.ts.map +1 -0
- package/lib/types/feature/toolbar/component.d.ts +3 -1
- package/lib/types/feature/toolbar/component.d.ts.map +1 -1
- package/lib/types/feature/toolbar/index.d.ts +11 -2
- package/lib/types/feature/toolbar/index.d.ts.map +1 -1
- package/lib/types/icons/alignCenter.d.ts +2 -0
- package/lib/types/icons/alignCenter.d.ts.map +1 -0
- package/lib/types/icons/alignLeft.d.ts +2 -0
- package/lib/types/icons/alignLeft.d.ts.map +1 -0
- package/lib/types/icons/alignRight.d.ts +2 -0
- package/lib/types/icons/alignRight.d.ts.map +1 -0
- package/lib/types/icons/bold.d.ts +2 -0
- package/lib/types/icons/bold.d.ts.map +1 -0
- package/lib/types/{feature/list-item/consts.d.ts → icons/bullet.d.ts} +1 -1
- package/lib/types/icons/bullet.d.ts.map +1 -0
- package/lib/types/icons/bulletList.d.ts +2 -0
- package/lib/types/icons/bulletList.d.ts.map +1 -0
- package/lib/types/icons/caption.d.ts +2 -0
- package/lib/types/icons/caption.d.ts.map +1 -0
- package/lib/types/icons/checkBoxChecked.d.ts +2 -0
- package/lib/types/icons/checkBoxChecked.d.ts.map +1 -0
- package/lib/types/icons/checkBoxUnchecked.d.ts +2 -0
- package/lib/types/icons/checkBoxUnchecked.d.ts.map +1 -0
- package/lib/types/icons/chevronDown.d.ts +2 -0
- package/lib/types/icons/chevronDown.d.ts.map +1 -0
- package/lib/types/icons/clear.d.ts +2 -0
- package/lib/types/icons/clear.d.ts.map +1 -0
- package/lib/types/icons/code.d.ts +2 -0
- package/lib/types/icons/code.d.ts.map +1 -0
- package/lib/types/icons/confirm.d.ts +2 -0
- package/lib/types/icons/confirm.d.ts.map +1 -0
- package/lib/types/icons/divider.d.ts +2 -0
- package/lib/types/icons/divider.d.ts.map +1 -0
- package/lib/types/icons/dragHandle.d.ts +2 -0
- package/lib/types/icons/dragHandle.d.ts.map +1 -0
- package/lib/types/icons/edit.d.ts +2 -0
- package/lib/types/icons/edit.d.ts.map +1 -0
- package/lib/types/icons/h1.d.ts +2 -0
- package/lib/types/icons/h1.d.ts.map +1 -0
- package/lib/types/icons/h2.d.ts +2 -0
- package/lib/types/icons/h2.d.ts.map +1 -0
- package/lib/types/icons/h3.d.ts +2 -0
- package/lib/types/icons/h3.d.ts.map +1 -0
- package/lib/types/icons/h4.d.ts +2 -0
- package/lib/types/icons/h4.d.ts.map +1 -0
- package/lib/types/icons/h5.d.ts +2 -0
- package/lib/types/icons/h5.d.ts.map +1 -0
- package/lib/types/icons/h6.d.ts +2 -0
- package/lib/types/icons/h6.d.ts.map +1 -0
- package/lib/types/icons/image.d.ts +2 -0
- package/lib/types/icons/image.d.ts.map +1 -0
- package/lib/types/icons/index.d.ts +36 -0
- package/lib/types/icons/index.d.ts.map +1 -0
- package/lib/types/icons/italic.d.ts +2 -0
- package/lib/types/icons/italic.d.ts.map +1 -0
- package/lib/types/icons/link.d.ts +2 -0
- package/lib/types/icons/link.d.ts.map +1 -0
- package/lib/types/icons/menu.d.ts +2 -0
- package/lib/types/icons/menu.d.ts.map +1 -0
- package/lib/types/icons/orderedList.d.ts +2 -0
- package/lib/types/icons/orderedList.d.ts.map +1 -0
- package/lib/types/icons/plus.d.ts +2 -0
- package/lib/types/icons/plus.d.ts.map +1 -0
- package/lib/types/icons/quote.d.ts +2 -0
- package/lib/types/icons/quote.d.ts.map +1 -0
- package/lib/types/icons/remove.d.ts +2 -0
- package/lib/types/icons/remove.d.ts.map +1 -0
- package/lib/types/icons/search.d.ts +2 -0
- package/lib/types/icons/search.d.ts.map +1 -0
- package/lib/types/icons/strikethrough.d.ts +2 -0
- package/lib/types/icons/strikethrough.d.ts.map +1 -0
- package/lib/types/icons/table.d.ts +2 -0
- package/lib/types/icons/table.d.ts.map +1 -0
- package/lib/types/icons/text.d.ts +2 -0
- package/lib/types/icons/text.d.ts.map +1 -0
- package/lib/types/icons/todoList.d.ts +2 -0
- package/lib/types/icons/todoList.d.ts.map +1 -0
- package/lib/types/utils/index.d.ts +1 -1
- package/lib/types/utils/index.d.ts.map +1 -1
- package/package.json +9 -23
- package/src/core/crepe.ts +15 -9
- package/src/core/slice.ts +2 -2
- package/src/feature/block-edit/handle/component.ts +13 -29
- package/src/feature/block-edit/handle/index.ts +16 -17
- package/src/feature/block-edit/index.ts +50 -5
- package/src/feature/block-edit/menu/component.ts +6 -7
- package/src/feature/block-edit/menu/config.ts +203 -274
- package/src/feature/block-edit/menu/group-builder.ts +50 -0
- package/src/feature/block-edit/menu/index.ts +11 -8
- package/src/feature/block-edit/menu/utils.ts +89 -0
- package/src/feature/code-mirror/index.ts +27 -19
- package/src/feature/cursor/index.ts +3 -4
- package/src/feature/image-block/index.ts +34 -41
- package/src/feature/index.ts +23 -3
- package/src/feature/link-tooltip/index.ts +23 -10
- package/src/feature/list-item/index.ts +21 -9
- package/src/feature/placeholder/index.ts +11 -6
- package/src/feature/shared.ts +4 -1
- package/src/feature/table/index.ts +54 -0
- package/src/feature/toolbar/component.ts +29 -11
- package/src/feature/toolbar/index.ts +21 -9
- package/src/icons/alignCenter.ts +7 -0
- package/src/icons/alignLeft.ts +7 -0
- package/src/icons/alignRight.ts +7 -0
- package/src/icons/bold.ts +7 -0
- package/src/{feature/list-item/consts.ts → icons/bullet.ts} +3 -3
- package/src/icons/bulletList.ts +14 -0
- package/src/icons/caption.ts +7 -0
- package/src/icons/checkBoxChecked.ts +14 -0
- package/src/icons/checkBoxUnchecked.ts +14 -0
- package/src/icons/chevronDown.ts +7 -0
- package/src/icons/clear.ts +14 -0
- package/src/icons/code.ts +14 -0
- package/src/icons/confirm.ts +14 -0
- package/src/icons/divider.ts +14 -0
- package/src/icons/dragHandle.ts +7 -0
- package/src/icons/edit.ts +14 -0
- package/src/icons/h1.ts +14 -0
- package/src/icons/h2.ts +14 -0
- package/src/icons/h3.ts +14 -0
- package/src/icons/h4.ts +14 -0
- package/src/icons/h5.ts +14 -0
- package/src/icons/h6.ts +14 -0
- package/src/icons/image.ts +14 -0
- package/src/icons/index.ts +35 -0
- package/src/icons/italic.ts +7 -0
- package/src/icons/link.ts +7 -0
- package/src/icons/menu.ts +14 -0
- package/src/icons/orderedList.ts +14 -0
- package/src/icons/plus.ts +14 -0
- package/src/icons/quote.ts +14 -0
- package/src/icons/remove.ts +7 -0
- package/src/icons/search.ts +7 -0
- package/src/icons/strikethrough.ts +7 -0
- package/src/icons/table.ts +14 -0
- package/src/icons/text.ts +14 -0
- package/src/icons/todoList.ts +7 -0
- package/src/theme/_internal/classic-common.css +3 -2
- package/src/theme/common/block-edit.css +3 -1
- package/src/theme/common/code-mirror.css +13 -0
- package/src/theme/common/cursor.css +1 -1
- package/src/theme/common/image-block.css +2 -0
- package/src/theme/common/link-tooltip.css +11 -14
- package/src/theme/common/list-item.css +9 -0
- package/src/theme/common/prosemirror.css +1 -1
- package/src/theme/common/style.css +1 -0
- package/src/theme/common/table.css +204 -0
- package/src/theme/common/toolbar.css +14 -4
- package/src/theme/{classic-dark → crepe-dark}/style.css +2 -2
- package/src/theme/frame/style.css +28 -0
- package/src/theme/frame-dark/style.css +28 -0
- package/src/theme/nord/style.css +28 -0
- package/src/theme/nord-dark/style.css +28 -0
- package/src/utils/index.ts +1 -1
- package/lib/cjs/_view-TbSIR42F.js +0 -27
- package/lib/cjs/_view-TbSIR42F.js.map +0 -1
- package/lib/cjs/clsx-7JLENl8W.js +0 -62
- package/lib/cjs/clsx-7JLENl8W.js.map +0 -1
- package/lib/cjs/composed-offset-position.browser.min-FwypoGc1.js +0 -1138
- package/lib/cjs/composed-offset-position.browser.min-FwypoGc1.js.map +0 -1
- package/lib/cjs/helper-OEW-2Vxr.js +0 -9
- package/lib/cjs/helper-OEW-2Vxr.js.map +0 -1
- package/lib/cjs/index-2oxl5Zo4.js +0 -551
- package/lib/cjs/index-2oxl5Zo4.js.map +0 -1
- package/lib/cjs/index-GKolgvC5.js +0 -505
- package/lib/cjs/index-GKolgvC5.js.map +0 -1
- package/lib/cjs/index-JAqL0ybh.js +0 -55
- package/lib/cjs/index-JAqL0ybh.js.map +0 -1
- package/lib/cjs/index-Ne_pk53w.js +0 -178
- package/lib/cjs/index-Ne_pk53w.js.map +0 -1
- package/lib/cjs/index-O3vRXWIP.js +0 -199
- package/lib/cjs/index-O3vRXWIP.js.map +0 -1
- package/lib/cjs/index-OIQn1x0L.js.map +0 -1
- package/lib/cjs/index-PF7s7DOo.js +0 -386
- package/lib/cjs/index-PF7s7DOo.js.map +0 -1
- package/lib/cjs/index-TEjdwq--.js.map +0 -1
- package/lib/cjs/index-kNI3S3lF.js +0 -22477
- package/lib/cjs/index-kNI3S3lF.js.map +0 -1
- package/lib/cjs/index-kvO8ReCY.js +0 -1960
- package/lib/cjs/index-kvO8ReCY.js.map +0 -1
- package/lib/cjs/index-llNS_EuP.js.map +0 -1
- package/lib/cjs/index-xqKfEyRA.js.map +0 -1
- package/lib/cjs/meta-q8q9fHyr.js +0 -14
- package/lib/cjs/meta-q8q9fHyr.js.map +0 -1
- package/lib/cjs/schema-7d3meDfB.js +0 -74
- package/lib/cjs/schema-7d3meDfB.js.map +0 -1
- package/lib/cjs/tooltip-plugin-Mk9fRTxI.js +0 -200
- package/lib/cjs/tooltip-plugin-Mk9fRTxI.js.map +0 -1
- package/lib/esm/_view-JjtfhQ8k.js +0 -25
- package/lib/esm/_view-JjtfhQ8k.js.map +0 -1
- package/lib/esm/clsx-R7WFaNKL.js +0 -52
- package/lib/esm/clsx-R7WFaNKL.js.map +0 -1
- package/lib/esm/composed-offset-position.browser.min-Tnm31e-m.js +0 -1132
- package/lib/esm/composed-offset-position.browser.min-Tnm31e-m.js.map +0 -1
- package/lib/esm/helper-iYEjPbOY.js +0 -7
- package/lib/esm/helper-iYEjPbOY.js.map +0 -1
- package/lib/esm/index-218OjRxG.js +0 -549
- package/lib/esm/index-218OjRxG.js.map +0 -1
- package/lib/esm/index-AHPvVH4H.js +0 -197
- package/lib/esm/index-AHPvVH4H.js.map +0 -1
- package/lib/esm/index-Bg5GFp0g.js +0 -384
- package/lib/esm/index-Bg5GFp0g.js.map +0 -1
- package/lib/esm/index-JkHHp3K-.js +0 -22445
- package/lib/esm/index-JkHHp3K-.js.map +0 -1
- package/lib/esm/index-PkBZpDL4.js.map +0 -1
- package/lib/esm/index-TNMG6UrN.js +0 -53
- package/lib/esm/index-TNMG6UrN.js.map +0 -1
- package/lib/esm/index-VyZguCIt.js.map +0 -1
- package/lib/esm/index-h1arGiXv.js +0 -1958
- package/lib/esm/index-h1arGiXv.js.map +0 -1
- package/lib/esm/index-pHsvfB_I.js +0 -503
- package/lib/esm/index-pHsvfB_I.js.map +0 -1
- package/lib/esm/index-q-qE7-96.js.map +0 -1
- package/lib/esm/index-u8tWJbca.js +0 -176
- package/lib/esm/index-u8tWJbca.js.map +0 -1
- package/lib/esm/meta-3ZYGAGrY.js +0 -12
- package/lib/esm/meta-3ZYGAGrY.js.map +0 -1
- package/lib/esm/schema-hVsy-vme.js +0 -71
- package/lib/esm/schema-hVsy-vme.js.map +0 -1
- package/lib/esm/tooltip-plugin-vZefVSGL.js +0 -194
- package/lib/esm/tooltip-plugin-vZefVSGL.js.map +0 -1
- package/lib/types/feature/block-edit/menu/icons.d.ts +0 -14
- package/lib/types/feature/block-edit/menu/icons.d.ts.map +0 -1
- package/lib/types/feature/link-tooltip/consts.d.ts +0 -5
- package/lib/types/feature/link-tooltip/consts.d.ts.map +0 -1
- package/lib/types/feature/list-item/consts.d.ts.map +0 -1
- package/lib/types/feature/toolbar/consts.d.ts +0 -5
- package/lib/types/feature/toolbar/consts.d.ts.map +0 -1
- package/src/feature/block-edit/menu/icons.ts +0 -170
- package/src/feature/link-tooltip/consts.ts +0 -46
- package/src/feature/toolbar/consts.ts +0 -25
- /package/lib/theme/{classic → crepe}/style.css +0 -0
- /package/src/theme/{classic → crepe}/style.css +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Component } from 'atomico'
|
|
2
2
|
import { c, html, useCallback, useEffect, useHost, useMemo, useRef, useState } from 'atomico'
|
|
3
|
-
import type { Ctx } from '@milkdown/ctx'
|
|
3
|
+
import type { Ctx } from '@milkdown/kit/ctx'
|
|
4
|
+
import type { BlockEditFeatureConfig } from '../index'
|
|
4
5
|
import { getGroups } from './config'
|
|
5
6
|
|
|
6
7
|
export interface MenuProps {
|
|
@@ -8,6 +9,7 @@ export interface MenuProps {
|
|
|
8
9
|
show: boolean
|
|
9
10
|
filter: string
|
|
10
11
|
hide: () => void
|
|
12
|
+
config?: BlockEditFeatureConfig
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
export const menuComponent: Component<MenuProps> = ({
|
|
@@ -15,8 +17,9 @@ export const menuComponent: Component<MenuProps> = ({
|
|
|
15
17
|
hide,
|
|
16
18
|
ctx,
|
|
17
19
|
filter,
|
|
20
|
+
config,
|
|
18
21
|
}) => {
|
|
19
|
-
const { groups, size } = useMemo(() => getGroups(filter), [filter])
|
|
22
|
+
const { groups, size } = useMemo(() => getGroups(filter, config), [filter])
|
|
20
23
|
|
|
21
24
|
const host = useHost()
|
|
22
25
|
const [hoverIndex, setHoverIndex] = useState(0)
|
|
@@ -62,11 +65,6 @@ export const menuComponent: Component<MenuProps> = ({
|
|
|
62
65
|
return
|
|
63
66
|
|
|
64
67
|
scrollRoot.scrollTop = target.offsetTop - scrollRoot.offsetTop
|
|
65
|
-
|
|
66
|
-
// target?.scrollIntoView({
|
|
67
|
-
// behavior: 'smooth',
|
|
68
|
-
// block: 'end',
|
|
69
|
-
// })
|
|
70
68
|
}, [])
|
|
71
69
|
|
|
72
70
|
const runByIndex = useCallback((index: number) => {
|
|
@@ -210,6 +208,7 @@ export const menuComponent: Component<MenuProps> = ({
|
|
|
210
208
|
|
|
211
209
|
menuComponent.props = {
|
|
212
210
|
ctx: Object,
|
|
211
|
+
config: Object,
|
|
213
212
|
show: Boolean,
|
|
214
213
|
filter: String,
|
|
215
214
|
hide: Function,
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { Ctx } from '@milkdown/ctx'
|
|
3
|
-
import { editorViewCtx } from '@milkdown/core'
|
|
1
|
+
import { editorViewCtx } from '@milkdown/kit/core'
|
|
4
2
|
import {
|
|
5
3
|
blockquoteSchema,
|
|
6
4
|
bulletListSchema,
|
|
7
5
|
codeBlockSchema,
|
|
8
6
|
headingSchema,
|
|
9
7
|
hrSchema,
|
|
8
|
+
listItemSchema,
|
|
10
9
|
orderedListSchema,
|
|
11
10
|
paragraphSchema,
|
|
12
|
-
} from '@milkdown/preset
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import { imageBlockSchema } from '@milkdown/components'
|
|
11
|
+
} from '@milkdown/kit/preset/commonmark'
|
|
12
|
+
import { NodeSelection } from '@milkdown/kit/prose/state'
|
|
13
|
+
import { imageBlockSchema } from '@milkdown/kit/component/image-block'
|
|
14
|
+
import { createTable } from '@milkdown/kit/preset/gfm'
|
|
17
15
|
import {
|
|
18
16
|
bulletListIcon,
|
|
19
17
|
codeIcon,
|
|
@@ -27,270 +25,204 @@ import {
|
|
|
27
25
|
imageIcon,
|
|
28
26
|
orderedListIcon,
|
|
29
27
|
quoteIcon,
|
|
28
|
+
tableIcon,
|
|
30
29
|
textIcon,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
key: 'h2',
|
|
149
|
-
label: 'Heading 2',
|
|
150
|
-
icon: h2Icon,
|
|
151
|
-
onRun: (ctx) => {
|
|
152
|
-
const view = ctx.get(editorViewCtx)
|
|
153
|
-
const { dispatch, state } = view
|
|
154
|
-
|
|
155
|
-
const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 2 })
|
|
156
|
-
command(state, dispatch)
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
key: 'h3',
|
|
161
|
-
label: 'Heading 3',
|
|
162
|
-
icon: h3Icon,
|
|
163
|
-
onRun: (ctx) => {
|
|
164
|
-
const view = ctx.get(editorViewCtx)
|
|
165
|
-
const { dispatch, state } = view
|
|
166
|
-
|
|
167
|
-
const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 3 })
|
|
168
|
-
command(state, dispatch)
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
key: 'h4',
|
|
173
|
-
label: 'Heading 4',
|
|
174
|
-
icon: h4Icon,
|
|
175
|
-
onRun: (ctx) => {
|
|
176
|
-
const view = ctx.get(editorViewCtx)
|
|
177
|
-
const { dispatch, state } = view
|
|
178
|
-
|
|
179
|
-
const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 4 })
|
|
180
|
-
command(state, dispatch)
|
|
181
|
-
},
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
key: 'h5',
|
|
185
|
-
label: 'Heading 5',
|
|
186
|
-
icon: h5Icon,
|
|
187
|
-
onRun: (ctx) => {
|
|
188
|
-
const view = ctx.get(editorViewCtx)
|
|
189
|
-
const { dispatch, state } = view
|
|
190
|
-
|
|
191
|
-
const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 5 })
|
|
192
|
-
command(state, dispatch)
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
key: 'h6',
|
|
197
|
-
label: 'Heading 6',
|
|
198
|
-
icon: h6Icon,
|
|
199
|
-
onRun: (ctx) => {
|
|
200
|
-
const view = ctx.get(editorViewCtx)
|
|
201
|
-
const { dispatch, state } = view
|
|
202
|
-
|
|
203
|
-
const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 6 })
|
|
204
|
-
command(state, dispatch)
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
key: 'quote',
|
|
209
|
-
label: 'Quote',
|
|
210
|
-
icon: quoteIcon,
|
|
211
|
-
onRun: (ctx) => {
|
|
212
|
-
const view = ctx.get(editorViewCtx)
|
|
213
|
-
const { dispatch, state } = view
|
|
214
|
-
|
|
215
|
-
const command = clearContentAndWrapInBlockType(blockquoteSchema.type(ctx))
|
|
216
|
-
command(state, dispatch)
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
key: 'divider',
|
|
221
|
-
label: 'Divider',
|
|
222
|
-
icon: dividerIcon,
|
|
223
|
-
onRun: (ctx) => {
|
|
224
|
-
const view = ctx.get(editorViewCtx)
|
|
225
|
-
const { dispatch, state } = view
|
|
226
|
-
|
|
227
|
-
const command = clearContentAndAddBlockType(hrSchema.type(ctx))
|
|
228
|
-
command(state, dispatch)
|
|
229
|
-
},
|
|
230
|
-
},
|
|
231
|
-
],
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
key: 'list',
|
|
235
|
-
label: 'List',
|
|
236
|
-
items: [
|
|
237
|
-
{
|
|
238
|
-
key: 'bullet-list',
|
|
239
|
-
label: 'Bullet List',
|
|
240
|
-
icon: bulletListIcon,
|
|
241
|
-
onRun: (ctx) => {
|
|
242
|
-
const view = ctx.get(editorViewCtx)
|
|
243
|
-
const { dispatch, state } = view
|
|
30
|
+
todoListIcon,
|
|
31
|
+
} from '../../../icons'
|
|
32
|
+
import type { BlockEditFeatureConfig } from '../index'
|
|
33
|
+
import type { MenuItemGroup } from './utils'
|
|
34
|
+
import {
|
|
35
|
+
clearContentAndAddBlockType,
|
|
36
|
+
clearContentAndSetBlockType,
|
|
37
|
+
clearContentAndWrapInBlockType,
|
|
38
|
+
clearRange,
|
|
39
|
+
} from './utils'
|
|
40
|
+
import { GroupBuilder } from './group-builder'
|
|
41
|
+
|
|
42
|
+
export function getGroups(filter?: string, config?: BlockEditFeatureConfig) {
|
|
43
|
+
const groupBuilder = new GroupBuilder()
|
|
44
|
+
groupBuilder
|
|
45
|
+
.addGroup('text', config?.slashMenuTextGroupLabel ?? 'Text')
|
|
46
|
+
.addItem('text', {
|
|
47
|
+
label: config?.slashMenuTextGroupLabel ?? 'Text',
|
|
48
|
+
icon: config?.slashMenuTextIcon?.() ?? textIcon,
|
|
49
|
+
onRun: (ctx) => {
|
|
50
|
+
const view = ctx.get(editorViewCtx)
|
|
51
|
+
const { dispatch, state } = view
|
|
52
|
+
|
|
53
|
+
const command = clearContentAndSetBlockType(paragraphSchema.type(ctx))
|
|
54
|
+
command(state, dispatch)
|
|
55
|
+
},
|
|
56
|
+
})
|
|
57
|
+
.addItem('h1', {
|
|
58
|
+
label: config?.slashMenuH1Label ?? 'Heading 1',
|
|
59
|
+
icon: config?.slashMenuH1Icon?.() ?? h1Icon,
|
|
60
|
+
onRun: (ctx) => {
|
|
61
|
+
const view = ctx.get(editorViewCtx)
|
|
62
|
+
const { dispatch, state } = view
|
|
63
|
+
|
|
64
|
+
const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 1 })
|
|
65
|
+
command(state, dispatch)
|
|
66
|
+
},
|
|
67
|
+
})
|
|
68
|
+
.addItem('h2', {
|
|
69
|
+
label: config?.slashMenuH2Label ?? 'Heading 2',
|
|
70
|
+
icon: config?.slashMenuH2Icon?.() ?? h2Icon,
|
|
71
|
+
onRun: (ctx) => {
|
|
72
|
+
const view = ctx.get(editorViewCtx)
|
|
73
|
+
const { dispatch, state } = view
|
|
74
|
+
|
|
75
|
+
const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 2 })
|
|
76
|
+
command(state, dispatch)
|
|
77
|
+
},
|
|
78
|
+
})
|
|
79
|
+
.addItem('h3', {
|
|
80
|
+
label: config?.slashMenuH3Label ?? 'Heading 3',
|
|
81
|
+
icon: config?.slashMenuH3Icon?.() ?? h3Icon,
|
|
82
|
+
onRun: (ctx) => {
|
|
83
|
+
const view = ctx.get(editorViewCtx)
|
|
84
|
+
const { dispatch, state } = view
|
|
85
|
+
|
|
86
|
+
const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 3 })
|
|
87
|
+
command(state, dispatch)
|
|
88
|
+
},
|
|
89
|
+
})
|
|
90
|
+
.addItem('h4', {
|
|
91
|
+
label: config?.slashMenuH4Label ?? 'Heading 4',
|
|
92
|
+
icon: config?.slashMenuH4Icon?.() ?? h4Icon,
|
|
93
|
+
onRun: (ctx) => {
|
|
94
|
+
const view = ctx.get(editorViewCtx)
|
|
95
|
+
const { dispatch, state } = view
|
|
96
|
+
|
|
97
|
+
const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 4 })
|
|
98
|
+
command(state, dispatch)
|
|
99
|
+
},
|
|
100
|
+
})
|
|
101
|
+
.addItem('h5', {
|
|
102
|
+
label: config?.slashMenuH5Label ?? 'Heading 5',
|
|
103
|
+
icon: config?.slashMenuH5Icon?.() ?? h5Icon,
|
|
104
|
+
onRun: (ctx) => {
|
|
105
|
+
const view = ctx.get(editorViewCtx)
|
|
106
|
+
const { dispatch, state } = view
|
|
107
|
+
|
|
108
|
+
const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 5 })
|
|
109
|
+
command(state, dispatch)
|
|
110
|
+
},
|
|
111
|
+
})
|
|
112
|
+
.addItem('h6', {
|
|
113
|
+
label: config?.slashMenuH6Label ?? 'Heading 6',
|
|
114
|
+
icon: config?.slashMenuH6Icon?.() ?? h6Icon,
|
|
115
|
+
onRun: (ctx) => {
|
|
116
|
+
const view = ctx.get(editorViewCtx)
|
|
117
|
+
const { dispatch, state } = view
|
|
118
|
+
|
|
119
|
+
const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 6 })
|
|
120
|
+
command(state, dispatch)
|
|
121
|
+
},
|
|
122
|
+
})
|
|
123
|
+
.addItem('quote', {
|
|
124
|
+
label: config?.slashMenuQuoteLabel ?? 'Quote',
|
|
125
|
+
icon: config?.slashMenuQuoteIcon?.() ?? quoteIcon,
|
|
126
|
+
onRun: (ctx) => {
|
|
127
|
+
const view = ctx.get(editorViewCtx)
|
|
128
|
+
const { dispatch, state } = view
|
|
129
|
+
|
|
130
|
+
const command = clearContentAndWrapInBlockType(blockquoteSchema.type(ctx))
|
|
131
|
+
command(state, dispatch)
|
|
132
|
+
},
|
|
133
|
+
})
|
|
134
|
+
.addItem('divider', {
|
|
135
|
+
label: config?.slashMenuDividerLabel ?? 'Divider',
|
|
136
|
+
icon: config?.slashMenuDividerIcon?.() ?? dividerIcon,
|
|
137
|
+
onRun: (ctx) => {
|
|
138
|
+
const view = ctx.get(editorViewCtx)
|
|
139
|
+
const { dispatch, state } = view
|
|
140
|
+
|
|
141
|
+
const command = clearContentAndAddBlockType(hrSchema.type(ctx))
|
|
142
|
+
command(state, dispatch)
|
|
143
|
+
},
|
|
144
|
+
})
|
|
244
145
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
146
|
+
groupBuilder.addGroup('list', config?.slashMenuListGroupLabel ?? 'List')
|
|
147
|
+
.addItem('bullet-list', {
|
|
148
|
+
label: config?.slashMenuBulletListLabel ?? 'Bullet List',
|
|
149
|
+
icon: config?.slashMenuBulletListIcon?.() ?? bulletListIcon,
|
|
150
|
+
onRun: (ctx) => {
|
|
151
|
+
const view = ctx.get(editorViewCtx)
|
|
152
|
+
const { dispatch, state } = view
|
|
153
|
+
|
|
154
|
+
const command = clearContentAndWrapInBlockType(bulletListSchema.type(ctx))
|
|
155
|
+
command(state, dispatch)
|
|
156
|
+
},
|
|
157
|
+
})
|
|
158
|
+
.addItem('ordered-list', {
|
|
159
|
+
label: config?.slashMenuOrderedListLabel ?? 'Ordered List',
|
|
160
|
+
icon: config?.slashMenuOrderedListIcon?.() ?? orderedListIcon,
|
|
161
|
+
onRun: (ctx) => {
|
|
162
|
+
const view = ctx.get(editorViewCtx)
|
|
163
|
+
const { dispatch, state } = view
|
|
164
|
+
|
|
165
|
+
const command = clearContentAndWrapInBlockType(orderedListSchema.type(ctx))
|
|
166
|
+
command(state, dispatch)
|
|
167
|
+
},
|
|
168
|
+
})
|
|
169
|
+
.addItem('todo-list', {
|
|
170
|
+
label: config?.slashMenuTaskListLabel ?? 'Todo List',
|
|
171
|
+
icon: config?.slashMenuTaskListIcon?.() ?? todoListIcon,
|
|
172
|
+
onRun: (ctx) => {
|
|
173
|
+
const view = ctx.get(editorViewCtx)
|
|
174
|
+
const { dispatch, state } = view
|
|
175
|
+
|
|
176
|
+
const command = clearContentAndWrapInBlockType(listItemSchema.type(ctx), { checked: false })
|
|
177
|
+
command(state, dispatch)
|
|
178
|
+
},
|
|
179
|
+
})
|
|
256
180
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
181
|
+
groupBuilder.addGroup('advanced', config?.slashMenuAdvancedGroupLabel ?? 'Advanced')
|
|
182
|
+
.addItem('image', {
|
|
183
|
+
label: config?.slashMenuImageLabel ?? 'Image',
|
|
184
|
+
icon: config?.slashMenuImageIcon?.() ?? imageIcon,
|
|
185
|
+
onRun: (ctx) => {
|
|
186
|
+
const view = ctx.get(editorViewCtx)
|
|
187
|
+
const { dispatch, state } = view
|
|
188
|
+
|
|
189
|
+
const command = clearContentAndAddBlockType(imageBlockSchema.type(ctx))
|
|
190
|
+
command(state, dispatch)
|
|
191
|
+
},
|
|
192
|
+
})
|
|
193
|
+
.addItem('code', {
|
|
194
|
+
label: config?.slashMenuCodeBlockLabel ?? 'Code',
|
|
195
|
+
icon: config?.slashMenuCodeBlockIcon?.() ?? codeIcon,
|
|
196
|
+
onRun: (ctx) => {
|
|
197
|
+
const view = ctx.get(editorViewCtx)
|
|
198
|
+
const { dispatch, state } = view
|
|
199
|
+
|
|
200
|
+
const command = clearContentAndAddBlockType(codeBlockSchema.type(ctx))
|
|
201
|
+
command(state, dispatch)
|
|
202
|
+
},
|
|
203
|
+
})
|
|
204
|
+
.addItem('table', {
|
|
205
|
+
label: config?.slashMenuTableLabel ?? 'Table',
|
|
206
|
+
icon: config?.slashMenuTableIcon?.() ?? tableIcon,
|
|
207
|
+
onRun: (ctx) => {
|
|
208
|
+
const view = ctx.get(editorViewCtx)
|
|
209
|
+
const { dispatch, state } = view
|
|
210
|
+
const tr = clearRange(state.tr)
|
|
211
|
+
const table = createTable(ctx, 3, 3)
|
|
212
|
+
tr.replaceSelectionWith(table)
|
|
213
|
+
const { from } = tr.selection
|
|
214
|
+
const pos = from - table.nodeSize + 2
|
|
215
|
+
dispatch(tr)
|
|
216
|
+
requestAnimationFrame(() => {
|
|
217
|
+
const selection = NodeSelection.create(view.state.tr.doc, pos)
|
|
218
|
+
dispatch(view.state.tr.setSelection(selection).scrollIntoView())
|
|
219
|
+
})
|
|
220
|
+
},
|
|
221
|
+
})
|
|
274
222
|
|
|
275
|
-
|
|
276
|
-
command(state, dispatch)
|
|
277
|
-
},
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
key: 'code',
|
|
281
|
-
label: 'Code',
|
|
282
|
-
icon: codeIcon,
|
|
283
|
-
onRun: (ctx) => {
|
|
284
|
-
const view = ctx.get(editorViewCtx)
|
|
285
|
-
const { dispatch, state } = view
|
|
223
|
+
config?.buildMenu?.(groupBuilder)
|
|
286
224
|
|
|
287
|
-
|
|
288
|
-
command(state, dispatch)
|
|
289
|
-
},
|
|
290
|
-
},
|
|
291
|
-
],
|
|
292
|
-
},
|
|
293
|
-
]
|
|
225
|
+
let groups = groupBuilder.build()
|
|
294
226
|
|
|
295
227
|
if (filter) {
|
|
296
228
|
groups = groups
|
|
@@ -312,12 +244,9 @@ export function getGroups(filter?: string) {
|
|
|
312
244
|
}
|
|
313
245
|
|
|
314
246
|
const items = groups.flatMap(groups => groups.items)
|
|
315
|
-
items
|
|
316
|
-
.
|
|
317
|
-
|
|
318
|
-
index,
|
|
319
|
-
})
|
|
320
|
-
}))
|
|
247
|
+
items.forEach(((item, index) => {
|
|
248
|
+
Object.assign(item, { index })
|
|
249
|
+
}))
|
|
321
250
|
|
|
322
251
|
groups.reduce((acc, group) => {
|
|
323
252
|
const end = acc + group.items.length
|
|
@@ -328,7 +257,7 @@ export function getGroups(filter?: string) {
|
|
|
328
257
|
}, 0)
|
|
329
258
|
|
|
330
259
|
return {
|
|
331
|
-
groups: groups as
|
|
260
|
+
groups: groups as MenuItemGroup[],
|
|
332
261
|
size: items.length,
|
|
333
262
|
}
|
|
334
263
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { MenuItem, MenuItemGroup } from './utils'
|
|
2
|
+
|
|
3
|
+
export class GroupBuilder {
|
|
4
|
+
#groups: MenuItemGroup<false>[] = []
|
|
5
|
+
|
|
6
|
+
clear = () => {
|
|
7
|
+
this.#groups = []
|
|
8
|
+
return this
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
#getGroupInstance = (group: MenuItemGroup<false>) => {
|
|
12
|
+
const groupInstance = {
|
|
13
|
+
group,
|
|
14
|
+
addItem: (key: string, item: Omit<MenuItem, 'key' | 'index'>) => {
|
|
15
|
+
const data = { key, ...item }
|
|
16
|
+
group.items.push(data)
|
|
17
|
+
return groupInstance
|
|
18
|
+
},
|
|
19
|
+
clear: () => {
|
|
20
|
+
group.items = []
|
|
21
|
+
return groupInstance
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
return groupInstance
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
addGroup = (key: string, label: string) => {
|
|
28
|
+
const items: Omit<MenuItem, 'index'>[] = []
|
|
29
|
+
const group: MenuItemGroup<false> = {
|
|
30
|
+
key,
|
|
31
|
+
label,
|
|
32
|
+
items,
|
|
33
|
+
}
|
|
34
|
+
this.#groups.push(group)
|
|
35
|
+
|
|
36
|
+
return this.#getGroupInstance(group)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getGroup = (key: string) => {
|
|
40
|
+
const group = this.#groups.find(group => group.key === key)
|
|
41
|
+
if (!group)
|
|
42
|
+
throw new Error(`Group with key ${key} not found`)
|
|
43
|
+
|
|
44
|
+
return this.#getGroupInstance(group)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
build = () => {
|
|
48
|
+
return this.#groups
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { PluginView } from '@milkdown/prose/state'
|
|
2
|
-
import type { EditorView } from '@milkdown/prose/view'
|
|
3
|
-
import { SlashProvider, slashFactory } from '@milkdown/plugin
|
|
4
|
-
import type { Ctx } from '@milkdown/ctx'
|
|
1
|
+
import type { PluginView } from '@milkdown/kit/prose/state'
|
|
2
|
+
import type { EditorView } from '@milkdown/kit/prose/view'
|
|
3
|
+
import { SlashProvider, slashFactory } from '@milkdown/kit/plugin/slash'
|
|
4
|
+
import type { Ctx } from '@milkdown/kit/ctx'
|
|
5
5
|
import type { AtomicoThis } from 'atomico/types/dom'
|
|
6
|
-
import { $ctx } from '@milkdown/utils'
|
|
6
|
+
import { $ctx } from '@milkdown/kit/utils'
|
|
7
7
|
import { defIfNotExists, isInCodeBlock, isInList } from '../../../utils'
|
|
8
|
+
import type { BlockEditFeatureConfig } from '../index'
|
|
8
9
|
import type { MenuProps } from './component'
|
|
9
10
|
import { MenuElement } from './component'
|
|
10
11
|
|
|
@@ -21,9 +22,9 @@ export const menuAPI = $ctx({
|
|
|
21
22
|
} as MenuAPI, 'menuAPICtx')
|
|
22
23
|
|
|
23
24
|
defIfNotExists('milkdown-slash-menu', MenuElement)
|
|
24
|
-
export function configureMenu(ctx: Ctx) {
|
|
25
|
+
export function configureMenu(ctx: Ctx, config?: BlockEditFeatureConfig) {
|
|
25
26
|
ctx.set(menu.key, {
|
|
26
|
-
view: view => new MenuView(ctx, view),
|
|
27
|
+
view: view => new MenuView(ctx, view, config),
|
|
27
28
|
})
|
|
28
29
|
}
|
|
29
30
|
|
|
@@ -32,10 +33,11 @@ class MenuView implements PluginView {
|
|
|
32
33
|
readonly #slashProvider: SlashProvider
|
|
33
34
|
#programmaticallyPos: number | null = null
|
|
34
35
|
|
|
35
|
-
constructor(ctx: Ctx, view: EditorView) {
|
|
36
|
+
constructor(ctx: Ctx, view: EditorView, config?: BlockEditFeatureConfig) {
|
|
36
37
|
this.#content = new MenuElement()
|
|
37
38
|
this.#content.hide = this.hide
|
|
38
39
|
this.#content.ctx = ctx
|
|
40
|
+
this.#content.config = config
|
|
39
41
|
// eslint-disable-next-line ts/no-this-alias
|
|
40
42
|
const self = this
|
|
41
43
|
this.#slashProvider = new SlashProvider({
|
|
@@ -70,6 +72,7 @@ class MenuView implements PluginView {
|
|
|
70
72
|
|
|
71
73
|
return true
|
|
72
74
|
},
|
|
75
|
+
offset: 10,
|
|
73
76
|
})
|
|
74
77
|
|
|
75
78
|
this.#slashProvider.onShow = () => {
|