@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,1958 +0,0 @@
|
|
|
1
|
-
import { $ as $ctx, f as commonjsGlobal, g as getDefaultExportFromCjs, e as editorViewCtx, d as $prose, p as paragraphSchema, h as headingSchema, j as blockquoteSchema, k as hrSchema, o as bulletListSchema, q as orderedListSchema, c as codeBlockSchema } from './index-JkHHp3K-.js';
|
|
2
|
-
import { NodeSelection, PluginKey, Plugin, TextSelection } from '@milkdown/prose/state';
|
|
3
|
-
import { browser, findParentNode, posToDOMRect } from '@milkdown/prose';
|
|
4
|
-
import { dropPoint, findWrapping } from '@milkdown/prose/transform';
|
|
5
|
-
import { DOMSerializer } from '@milkdown/prose/model';
|
|
6
|
-
import { o as offset, c as computePosition, p as platform, t, f as flip } from './composed-offset-position.browser.min-Tnm31e-m.js';
|
|
7
|
-
import { d as defIfNotExists, i as isInCodeBlock, a as isInList } from './index-Jvxff1vU.js';
|
|
8
|
-
import { html, c, useMemo, useHost, useState, useRef, useCallback, useEffect } from 'atomico';
|
|
9
|
-
import { i as imageBlockSchema } from './schema-hVsy-vme.js';
|
|
10
|
-
import { d as debounce$1 } from './index-Bg5GFp0g.js';
|
|
11
|
-
import '@milkdown/prose/history';
|
|
12
|
-
import '@milkdown/prose/keymap';
|
|
13
|
-
import '@milkdown/prose/commands';
|
|
14
|
-
import '@milkdown/prose/inputrules';
|
|
15
|
-
import '@milkdown/prose/schema-list';
|
|
16
|
-
import '@milkdown/prose/view';
|
|
17
|
-
import './meta-3ZYGAGrY.js';
|
|
18
|
-
|
|
19
|
-
function withMeta(plugin, meta) {
|
|
20
|
-
Object.assign(plugin, {
|
|
21
|
-
meta: {
|
|
22
|
-
package: "@milkdown/plugin-block",
|
|
23
|
-
...meta
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
return plugin;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const defaultNodeFilter = (_pos, node) => {
|
|
30
|
-
const { name } = node.type;
|
|
31
|
-
if (name.startsWith("table") && name !== "table")
|
|
32
|
-
return false;
|
|
33
|
-
return true;
|
|
34
|
-
};
|
|
35
|
-
const blockConfig = $ctx({ filterNodes: defaultNodeFilter }, "blockConfig");
|
|
36
|
-
withMeta(blockConfig, {
|
|
37
|
-
displayName: "Ctx<blockConfig>"
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* lodash (Custom Build) <https://lodash.com/>
|
|
42
|
-
* Build: `lodash modularize exports="npm" -o ./`
|
|
43
|
-
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
|
44
|
-
* Released under MIT license <https://lodash.com/license>
|
|
45
|
-
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
46
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
/** Used as the `TypeError` message for "Functions" methods. */
|
|
50
|
-
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
51
|
-
|
|
52
|
-
/** Used as references for various `Number` constants. */
|
|
53
|
-
var NAN = 0 / 0;
|
|
54
|
-
|
|
55
|
-
/** `Object#toString` result references. */
|
|
56
|
-
var symbolTag = '[object Symbol]';
|
|
57
|
-
|
|
58
|
-
/** Used to match leading and trailing whitespace. */
|
|
59
|
-
var reTrim = /^\s+|\s+$/g;
|
|
60
|
-
|
|
61
|
-
/** Used to detect bad signed hexadecimal string values. */
|
|
62
|
-
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
63
|
-
|
|
64
|
-
/** Used to detect binary string values. */
|
|
65
|
-
var reIsBinary = /^0b[01]+$/i;
|
|
66
|
-
|
|
67
|
-
/** Used to detect octal string values. */
|
|
68
|
-
var reIsOctal = /^0o[0-7]+$/i;
|
|
69
|
-
|
|
70
|
-
/** Built-in method references without a dependency on `root`. */
|
|
71
|
-
var freeParseInt = parseInt;
|
|
72
|
-
|
|
73
|
-
/** Detect free variable `global` from Node.js. */
|
|
74
|
-
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
75
|
-
|
|
76
|
-
/** Detect free variable `self`. */
|
|
77
|
-
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
78
|
-
|
|
79
|
-
/** Used as a reference to the global object. */
|
|
80
|
-
var root = freeGlobal || freeSelf || Function('return this')();
|
|
81
|
-
|
|
82
|
-
/** Used for built-in method references. */
|
|
83
|
-
var objectProto = Object.prototype;
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Used to resolve the
|
|
87
|
-
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
88
|
-
* of values.
|
|
89
|
-
*/
|
|
90
|
-
var objectToString = objectProto.toString;
|
|
91
|
-
|
|
92
|
-
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
93
|
-
var nativeMax = Math.max,
|
|
94
|
-
nativeMin = Math.min;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Gets the timestamp of the number of milliseconds that have elapsed since
|
|
98
|
-
* the Unix epoch (1 January 1970 00:00:00 UTC).
|
|
99
|
-
*
|
|
100
|
-
* @static
|
|
101
|
-
* @memberOf _
|
|
102
|
-
* @since 2.4.0
|
|
103
|
-
* @category Date
|
|
104
|
-
* @returns {number} Returns the timestamp.
|
|
105
|
-
* @example
|
|
106
|
-
*
|
|
107
|
-
* _.defer(function(stamp) {
|
|
108
|
-
* console.log(_.now() - stamp);
|
|
109
|
-
* }, _.now());
|
|
110
|
-
* // => Logs the number of milliseconds it took for the deferred invocation.
|
|
111
|
-
*/
|
|
112
|
-
var now = function() {
|
|
113
|
-
return root.Date.now();
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Creates a debounced function that delays invoking `func` until after `wait`
|
|
118
|
-
* milliseconds have elapsed since the last time the debounced function was
|
|
119
|
-
* invoked. The debounced function comes with a `cancel` method to cancel
|
|
120
|
-
* delayed `func` invocations and a `flush` method to immediately invoke them.
|
|
121
|
-
* Provide `options` to indicate whether `func` should be invoked on the
|
|
122
|
-
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked
|
|
123
|
-
* with the last arguments provided to the debounced function. Subsequent
|
|
124
|
-
* calls to the debounced function return the result of the last `func`
|
|
125
|
-
* invocation.
|
|
126
|
-
*
|
|
127
|
-
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
128
|
-
* invoked on the trailing edge of the timeout only if the debounced function
|
|
129
|
-
* is invoked more than once during the `wait` timeout.
|
|
130
|
-
*
|
|
131
|
-
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
132
|
-
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
133
|
-
*
|
|
134
|
-
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
135
|
-
* for details over the differences between `_.debounce` and `_.throttle`.
|
|
136
|
-
*
|
|
137
|
-
* @static
|
|
138
|
-
* @memberOf _
|
|
139
|
-
* @since 0.1.0
|
|
140
|
-
* @category Function
|
|
141
|
-
* @param {Function} func The function to debounce.
|
|
142
|
-
* @param {number} [wait=0] The number of milliseconds to delay.
|
|
143
|
-
* @param {Object} [options={}] The options object.
|
|
144
|
-
* @param {boolean} [options.leading=false]
|
|
145
|
-
* Specify invoking on the leading edge of the timeout.
|
|
146
|
-
* @param {number} [options.maxWait]
|
|
147
|
-
* The maximum time `func` is allowed to be delayed before it's invoked.
|
|
148
|
-
* @param {boolean} [options.trailing=true]
|
|
149
|
-
* Specify invoking on the trailing edge of the timeout.
|
|
150
|
-
* @returns {Function} Returns the new debounced function.
|
|
151
|
-
* @example
|
|
152
|
-
*
|
|
153
|
-
* // Avoid costly calculations while the window size is in flux.
|
|
154
|
-
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
|
|
155
|
-
*
|
|
156
|
-
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
|
|
157
|
-
* jQuery(element).on('click', _.debounce(sendMail, 300, {
|
|
158
|
-
* 'leading': true,
|
|
159
|
-
* 'trailing': false
|
|
160
|
-
* }));
|
|
161
|
-
*
|
|
162
|
-
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
|
|
163
|
-
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
|
|
164
|
-
* var source = new EventSource('/stream');
|
|
165
|
-
* jQuery(source).on('message', debounced);
|
|
166
|
-
*
|
|
167
|
-
* // Cancel the trailing debounced invocation.
|
|
168
|
-
* jQuery(window).on('popstate', debounced.cancel);
|
|
169
|
-
*/
|
|
170
|
-
function debounce(func, wait, options) {
|
|
171
|
-
var lastArgs,
|
|
172
|
-
lastThis,
|
|
173
|
-
maxWait,
|
|
174
|
-
result,
|
|
175
|
-
timerId,
|
|
176
|
-
lastCallTime,
|
|
177
|
-
lastInvokeTime = 0,
|
|
178
|
-
leading = false,
|
|
179
|
-
maxing = false,
|
|
180
|
-
trailing = true;
|
|
181
|
-
|
|
182
|
-
if (typeof func != 'function') {
|
|
183
|
-
throw new TypeError(FUNC_ERROR_TEXT);
|
|
184
|
-
}
|
|
185
|
-
wait = toNumber(wait) || 0;
|
|
186
|
-
if (isObject(options)) {
|
|
187
|
-
leading = !!options.leading;
|
|
188
|
-
maxing = 'maxWait' in options;
|
|
189
|
-
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
190
|
-
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function invokeFunc(time) {
|
|
194
|
-
var args = lastArgs,
|
|
195
|
-
thisArg = lastThis;
|
|
196
|
-
|
|
197
|
-
lastArgs = lastThis = undefined;
|
|
198
|
-
lastInvokeTime = time;
|
|
199
|
-
result = func.apply(thisArg, args);
|
|
200
|
-
return result;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
function leadingEdge(time) {
|
|
204
|
-
// Reset any `maxWait` timer.
|
|
205
|
-
lastInvokeTime = time;
|
|
206
|
-
// Start the timer for the trailing edge.
|
|
207
|
-
timerId = setTimeout(timerExpired, wait);
|
|
208
|
-
// Invoke the leading edge.
|
|
209
|
-
return leading ? invokeFunc(time) : result;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function remainingWait(time) {
|
|
213
|
-
var timeSinceLastCall = time - lastCallTime,
|
|
214
|
-
timeSinceLastInvoke = time - lastInvokeTime,
|
|
215
|
-
result = wait - timeSinceLastCall;
|
|
216
|
-
|
|
217
|
-
return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function shouldInvoke(time) {
|
|
221
|
-
var timeSinceLastCall = time - lastCallTime,
|
|
222
|
-
timeSinceLastInvoke = time - lastInvokeTime;
|
|
223
|
-
|
|
224
|
-
// Either this is the first call, activity has stopped and we're at the
|
|
225
|
-
// trailing edge, the system time has gone backwards and we're treating
|
|
226
|
-
// it as the trailing edge, or we've hit the `maxWait` limit.
|
|
227
|
-
return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
|
|
228
|
-
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function timerExpired() {
|
|
232
|
-
var time = now();
|
|
233
|
-
if (shouldInvoke(time)) {
|
|
234
|
-
return trailingEdge(time);
|
|
235
|
-
}
|
|
236
|
-
// Restart the timer.
|
|
237
|
-
timerId = setTimeout(timerExpired, remainingWait(time));
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function trailingEdge(time) {
|
|
241
|
-
timerId = undefined;
|
|
242
|
-
|
|
243
|
-
// Only invoke if we have `lastArgs` which means `func` has been
|
|
244
|
-
// debounced at least once.
|
|
245
|
-
if (trailing && lastArgs) {
|
|
246
|
-
return invokeFunc(time);
|
|
247
|
-
}
|
|
248
|
-
lastArgs = lastThis = undefined;
|
|
249
|
-
return result;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
function cancel() {
|
|
253
|
-
if (timerId !== undefined) {
|
|
254
|
-
clearTimeout(timerId);
|
|
255
|
-
}
|
|
256
|
-
lastInvokeTime = 0;
|
|
257
|
-
lastArgs = lastCallTime = lastThis = timerId = undefined;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
function flush() {
|
|
261
|
-
return timerId === undefined ? result : trailingEdge(now());
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
function debounced() {
|
|
265
|
-
var time = now(),
|
|
266
|
-
isInvoking = shouldInvoke(time);
|
|
267
|
-
|
|
268
|
-
lastArgs = arguments;
|
|
269
|
-
lastThis = this;
|
|
270
|
-
lastCallTime = time;
|
|
271
|
-
|
|
272
|
-
if (isInvoking) {
|
|
273
|
-
if (timerId === undefined) {
|
|
274
|
-
return leadingEdge(lastCallTime);
|
|
275
|
-
}
|
|
276
|
-
if (maxing) {
|
|
277
|
-
// Handle invocations in a tight loop.
|
|
278
|
-
timerId = setTimeout(timerExpired, wait);
|
|
279
|
-
return invokeFunc(lastCallTime);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
if (timerId === undefined) {
|
|
283
|
-
timerId = setTimeout(timerExpired, wait);
|
|
284
|
-
}
|
|
285
|
-
return result;
|
|
286
|
-
}
|
|
287
|
-
debounced.cancel = cancel;
|
|
288
|
-
debounced.flush = flush;
|
|
289
|
-
return debounced;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Creates a throttled function that only invokes `func` at most once per
|
|
294
|
-
* every `wait` milliseconds. The throttled function comes with a `cancel`
|
|
295
|
-
* method to cancel delayed `func` invocations and a `flush` method to
|
|
296
|
-
* immediately invoke them. Provide `options` to indicate whether `func`
|
|
297
|
-
* should be invoked on the leading and/or trailing edge of the `wait`
|
|
298
|
-
* timeout. The `func` is invoked with the last arguments provided to the
|
|
299
|
-
* throttled function. Subsequent calls to the throttled function return the
|
|
300
|
-
* result of the last `func` invocation.
|
|
301
|
-
*
|
|
302
|
-
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
303
|
-
* invoked on the trailing edge of the timeout only if the throttled function
|
|
304
|
-
* is invoked more than once during the `wait` timeout.
|
|
305
|
-
*
|
|
306
|
-
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
307
|
-
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
308
|
-
*
|
|
309
|
-
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
310
|
-
* for details over the differences between `_.throttle` and `_.debounce`.
|
|
311
|
-
*
|
|
312
|
-
* @static
|
|
313
|
-
* @memberOf _
|
|
314
|
-
* @since 0.1.0
|
|
315
|
-
* @category Function
|
|
316
|
-
* @param {Function} func The function to throttle.
|
|
317
|
-
* @param {number} [wait=0] The number of milliseconds to throttle invocations to.
|
|
318
|
-
* @param {Object} [options={}] The options object.
|
|
319
|
-
* @param {boolean} [options.leading=true]
|
|
320
|
-
* Specify invoking on the leading edge of the timeout.
|
|
321
|
-
* @param {boolean} [options.trailing=true]
|
|
322
|
-
* Specify invoking on the trailing edge of the timeout.
|
|
323
|
-
* @returns {Function} Returns the new throttled function.
|
|
324
|
-
* @example
|
|
325
|
-
*
|
|
326
|
-
* // Avoid excessively updating the position while scrolling.
|
|
327
|
-
* jQuery(window).on('scroll', _.throttle(updatePosition, 100));
|
|
328
|
-
*
|
|
329
|
-
* // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
|
|
330
|
-
* var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
|
|
331
|
-
* jQuery(element).on('click', throttled);
|
|
332
|
-
*
|
|
333
|
-
* // Cancel the trailing throttled invocation.
|
|
334
|
-
* jQuery(window).on('popstate', throttled.cancel);
|
|
335
|
-
*/
|
|
336
|
-
function throttle(func, wait, options) {
|
|
337
|
-
var leading = true,
|
|
338
|
-
trailing = true;
|
|
339
|
-
|
|
340
|
-
if (typeof func != 'function') {
|
|
341
|
-
throw new TypeError(FUNC_ERROR_TEXT);
|
|
342
|
-
}
|
|
343
|
-
if (isObject(options)) {
|
|
344
|
-
leading = 'leading' in options ? !!options.leading : leading;
|
|
345
|
-
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
|
346
|
-
}
|
|
347
|
-
return debounce(func, wait, {
|
|
348
|
-
'leading': leading,
|
|
349
|
-
'maxWait': wait,
|
|
350
|
-
'trailing': trailing
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* Checks if `value` is the
|
|
356
|
-
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
357
|
-
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
358
|
-
*
|
|
359
|
-
* @static
|
|
360
|
-
* @memberOf _
|
|
361
|
-
* @since 0.1.0
|
|
362
|
-
* @category Lang
|
|
363
|
-
* @param {*} value The value to check.
|
|
364
|
-
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
365
|
-
* @example
|
|
366
|
-
*
|
|
367
|
-
* _.isObject({});
|
|
368
|
-
* // => true
|
|
369
|
-
*
|
|
370
|
-
* _.isObject([1, 2, 3]);
|
|
371
|
-
* // => true
|
|
372
|
-
*
|
|
373
|
-
* _.isObject(_.noop);
|
|
374
|
-
* // => true
|
|
375
|
-
*
|
|
376
|
-
* _.isObject(null);
|
|
377
|
-
* // => false
|
|
378
|
-
*/
|
|
379
|
-
function isObject(value) {
|
|
380
|
-
var type = typeof value;
|
|
381
|
-
return !!value && (type == 'object' || type == 'function');
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
386
|
-
* and has a `typeof` result of "object".
|
|
387
|
-
*
|
|
388
|
-
* @static
|
|
389
|
-
* @memberOf _
|
|
390
|
-
* @since 4.0.0
|
|
391
|
-
* @category Lang
|
|
392
|
-
* @param {*} value The value to check.
|
|
393
|
-
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
394
|
-
* @example
|
|
395
|
-
*
|
|
396
|
-
* _.isObjectLike({});
|
|
397
|
-
* // => true
|
|
398
|
-
*
|
|
399
|
-
* _.isObjectLike([1, 2, 3]);
|
|
400
|
-
* // => true
|
|
401
|
-
*
|
|
402
|
-
* _.isObjectLike(_.noop);
|
|
403
|
-
* // => false
|
|
404
|
-
*
|
|
405
|
-
* _.isObjectLike(null);
|
|
406
|
-
* // => false
|
|
407
|
-
*/
|
|
408
|
-
function isObjectLike(value) {
|
|
409
|
-
return !!value && typeof value == 'object';
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
/**
|
|
413
|
-
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
414
|
-
*
|
|
415
|
-
* @static
|
|
416
|
-
* @memberOf _
|
|
417
|
-
* @since 4.0.0
|
|
418
|
-
* @category Lang
|
|
419
|
-
* @param {*} value The value to check.
|
|
420
|
-
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
421
|
-
* @example
|
|
422
|
-
*
|
|
423
|
-
* _.isSymbol(Symbol.iterator);
|
|
424
|
-
* // => true
|
|
425
|
-
*
|
|
426
|
-
* _.isSymbol('abc');
|
|
427
|
-
* // => false
|
|
428
|
-
*/
|
|
429
|
-
function isSymbol(value) {
|
|
430
|
-
return typeof value == 'symbol' ||
|
|
431
|
-
(isObjectLike(value) && objectToString.call(value) == symbolTag);
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
/**
|
|
435
|
-
* Converts `value` to a number.
|
|
436
|
-
*
|
|
437
|
-
* @static
|
|
438
|
-
* @memberOf _
|
|
439
|
-
* @since 4.0.0
|
|
440
|
-
* @category Lang
|
|
441
|
-
* @param {*} value The value to process.
|
|
442
|
-
* @returns {number} Returns the number.
|
|
443
|
-
* @example
|
|
444
|
-
*
|
|
445
|
-
* _.toNumber(3.2);
|
|
446
|
-
* // => 3.2
|
|
447
|
-
*
|
|
448
|
-
* _.toNumber(Number.MIN_VALUE);
|
|
449
|
-
* // => 5e-324
|
|
450
|
-
*
|
|
451
|
-
* _.toNumber(Infinity);
|
|
452
|
-
* // => Infinity
|
|
453
|
-
*
|
|
454
|
-
* _.toNumber('3.2');
|
|
455
|
-
* // => 3.2
|
|
456
|
-
*/
|
|
457
|
-
function toNumber(value) {
|
|
458
|
-
if (typeof value == 'number') {
|
|
459
|
-
return value;
|
|
460
|
-
}
|
|
461
|
-
if (isSymbol(value)) {
|
|
462
|
-
return NAN;
|
|
463
|
-
}
|
|
464
|
-
if (isObject(value)) {
|
|
465
|
-
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
|
|
466
|
-
value = isObject(other) ? (other + '') : other;
|
|
467
|
-
}
|
|
468
|
-
if (typeof value != 'string') {
|
|
469
|
-
return value === 0 ? value : +value;
|
|
470
|
-
}
|
|
471
|
-
value = value.replace(reTrim, '');
|
|
472
|
-
var isBinary = reIsBinary.test(value);
|
|
473
|
-
return (isBinary || reIsOctal.test(value))
|
|
474
|
-
? freeParseInt(value.slice(2), isBinary ? 2 : 8)
|
|
475
|
-
: (reIsBadHex.test(value) ? NAN : +value);
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
var lodash_throttle = throttle;
|
|
479
|
-
|
|
480
|
-
var throttle$1 = /*@__PURE__*/getDefaultExportFromCjs(lodash_throttle);
|
|
481
|
-
|
|
482
|
-
function removePossibleTable(view, event) {
|
|
483
|
-
var _a;
|
|
484
|
-
const { state } = view;
|
|
485
|
-
const $pos = state.selection.$anchor;
|
|
486
|
-
for (let d = $pos.depth; d > 0; d--) {
|
|
487
|
-
const node = $pos.node(d);
|
|
488
|
-
if (node.type.spec.tableRole === "table") {
|
|
489
|
-
const eventPos = view.posAtCoords({ left: event.clientX, top: event.clientY });
|
|
490
|
-
if (!eventPos)
|
|
491
|
-
return null;
|
|
492
|
-
const slice = (_a = view.dragging) == null ? void 0 : _a.slice;
|
|
493
|
-
if (!slice)
|
|
494
|
-
return null;
|
|
495
|
-
const $mouse = view.state.doc.resolve(eventPos.pos);
|
|
496
|
-
const insertPos = dropPoint(view.state.doc, $mouse.pos, slice);
|
|
497
|
-
if (insertPos == null || insertPos < 0)
|
|
498
|
-
return null;
|
|
499
|
-
let tr = state.tr;
|
|
500
|
-
tr = tr.delete($pos.before(d), $pos.after(d));
|
|
501
|
-
const pos = tr.mapping.map(insertPos);
|
|
502
|
-
tr = tr.replaceRange(pos, pos, slice);
|
|
503
|
-
return tr;
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
return null;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
function selectRootNodeByDom(view, coords, filterNodes) {
|
|
510
|
-
var _a;
|
|
511
|
-
const root = view.dom.parentElement;
|
|
512
|
-
if (!root)
|
|
513
|
-
return null;
|
|
514
|
-
const pos = (_a = view.posAtCoords({
|
|
515
|
-
left: coords.x,
|
|
516
|
-
top: coords.y
|
|
517
|
-
})) == null ? void 0 : _a.inside;
|
|
518
|
-
if (pos == null || pos < 0)
|
|
519
|
-
return null;
|
|
520
|
-
let $pos = view.state.doc.resolve(pos);
|
|
521
|
-
let node = view.state.doc.nodeAt(pos);
|
|
522
|
-
let element = view.nodeDOM(pos);
|
|
523
|
-
const filter = () => {
|
|
524
|
-
if ($pos.depth >= 1 && $pos.index($pos.depth) === 0) {
|
|
525
|
-
const ancestorPos = $pos.before($pos.depth);
|
|
526
|
-
node = view.state.doc.nodeAt(ancestorPos);
|
|
527
|
-
element = view.nodeDOM(ancestorPos);
|
|
528
|
-
$pos = view.state.doc.resolve(ancestorPos);
|
|
529
|
-
if (!filterNodes($pos, node))
|
|
530
|
-
filter();
|
|
531
|
-
}
|
|
532
|
-
};
|
|
533
|
-
filter();
|
|
534
|
-
if (!element || !node)
|
|
535
|
-
return null;
|
|
536
|
-
return { node, $pos, el: element };
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
let _detachedDoc = null;
|
|
540
|
-
function detachedDoc() {
|
|
541
|
-
return _detachedDoc || (_detachedDoc = document.implementation.createHTMLDocument("title"));
|
|
542
|
-
}
|
|
543
|
-
const wrapMap = {
|
|
544
|
-
thead: ["table"],
|
|
545
|
-
tbody: ["table"],
|
|
546
|
-
tfoot: ["table"],
|
|
547
|
-
caption: ["table"],
|
|
548
|
-
colgroup: ["table"],
|
|
549
|
-
col: ["table", "colgroup"],
|
|
550
|
-
tr: ["table", "tbody"],
|
|
551
|
-
td: ["table", "tbody", "tr"],
|
|
552
|
-
th: ["table", "tbody", "tr"]
|
|
553
|
-
};
|
|
554
|
-
function serializeForClipboard(view, slice) {
|
|
555
|
-
const context = [];
|
|
556
|
-
let { openStart, openEnd, content } = slice;
|
|
557
|
-
while (openStart > 1 && openEnd > 1 && content.childCount === 1 && content.firstChild.childCount === 1) {
|
|
558
|
-
openStart -= 1;
|
|
559
|
-
openEnd -= 1;
|
|
560
|
-
const node = content.firstChild;
|
|
561
|
-
context.push(
|
|
562
|
-
node.type.name,
|
|
563
|
-
node.attrs !== node.type.defaultAttrs ? node.attrs : null
|
|
564
|
-
);
|
|
565
|
-
content = node.content;
|
|
566
|
-
}
|
|
567
|
-
const serializer = view.someProp("clipboardSerializer") || DOMSerializer.fromSchema(view.state.schema);
|
|
568
|
-
const doc = detachedDoc();
|
|
569
|
-
const wrap = doc.createElement("div");
|
|
570
|
-
wrap.appendChild(serializer.serializeFragment(content, { document: doc }));
|
|
571
|
-
let firstChild = wrap.firstChild;
|
|
572
|
-
let needsWrap;
|
|
573
|
-
let wrappers = 0;
|
|
574
|
-
while (firstChild && firstChild.nodeType === 1 && (needsWrap = wrapMap[firstChild.nodeName.toLowerCase()])) {
|
|
575
|
-
for (let i = needsWrap.length - 1; i >= 0; i--) {
|
|
576
|
-
const wrapper = doc.createElement(needsWrap[i]);
|
|
577
|
-
while (wrap.firstChild) wrapper.appendChild(wrap.firstChild);
|
|
578
|
-
wrap.appendChild(wrapper);
|
|
579
|
-
wrappers++;
|
|
580
|
-
}
|
|
581
|
-
firstChild = wrap.firstChild;
|
|
582
|
-
}
|
|
583
|
-
if (firstChild && firstChild.nodeType === 1) {
|
|
584
|
-
firstChild.setAttribute(
|
|
585
|
-
"data-pm-slice",
|
|
586
|
-
`${openStart} ${openEnd}${wrappers ? ` -${wrappers}` : ""} ${JSON.stringify(context)}`
|
|
587
|
-
);
|
|
588
|
-
}
|
|
589
|
-
const text = view.someProp("clipboardTextSerializer", (f) => f(slice, view)) || slice.content.textBetween(0, slice.content.size, "\n\n");
|
|
590
|
-
return { dom: wrap, text };
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
var __typeError$4 = (msg) => {
|
|
594
|
-
throw TypeError(msg);
|
|
595
|
-
};
|
|
596
|
-
var __accessCheck$4 = (obj, member, msg) => member.has(obj) || __typeError$4("Cannot " + msg);
|
|
597
|
-
var __privateGet$4 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
598
|
-
var __privateAdd$4 = (obj, member, value) => member.has(obj) ? __typeError$4("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
599
|
-
var __privateSet$4 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
600
|
-
var _ctx$2, _createSelection, _activeSelection, _active, _activeDOMRect, _dragging, _BlockService_instances, filterNodes_get, view_get, _notify, _hide, _show, _handleMouseDown, _handleMouseUp, _handleDragStart, _mousemoveCallback, _dragEnd;
|
|
601
|
-
const brokenClipboardAPI = browser.ie && browser.ie_version < 15 || browser.ios && browser.webkit_version < 604;
|
|
602
|
-
const buffer = 20;
|
|
603
|
-
class BlockService {
|
|
604
|
-
constructor() {
|
|
605
|
-
__privateAdd$4(this, _BlockService_instances);
|
|
606
|
-
/// @internal
|
|
607
|
-
__privateAdd$4(this, _ctx$2);
|
|
608
|
-
/// @internal
|
|
609
|
-
__privateAdd$4(this, _createSelection, () => {
|
|
610
|
-
if (!__privateGet$4(this, _active))
|
|
611
|
-
return null;
|
|
612
|
-
const result = __privateGet$4(this, _active);
|
|
613
|
-
const view = __privateGet$4(this, _BlockService_instances, view_get);
|
|
614
|
-
if (view && NodeSelection.isSelectable(result.node)) {
|
|
615
|
-
const nodeSelection = NodeSelection.create(view.state.doc, result.$pos.pos);
|
|
616
|
-
view.dispatch(view.state.tr.setSelection(nodeSelection));
|
|
617
|
-
view.focus();
|
|
618
|
-
__privateSet$4(this, _activeSelection, nodeSelection);
|
|
619
|
-
return nodeSelection;
|
|
620
|
-
}
|
|
621
|
-
return null;
|
|
622
|
-
});
|
|
623
|
-
/// @internal
|
|
624
|
-
__privateAdd$4(this, _activeSelection, null);
|
|
625
|
-
/// @internal
|
|
626
|
-
__privateAdd$4(this, _active, null);
|
|
627
|
-
/// @internal
|
|
628
|
-
__privateAdd$4(this, _activeDOMRect);
|
|
629
|
-
/// @internal
|
|
630
|
-
__privateAdd$4(this, _dragging, false);
|
|
631
|
-
/// @internal
|
|
632
|
-
__privateAdd$4(this, _notify);
|
|
633
|
-
/// @internal
|
|
634
|
-
__privateAdd$4(this, _hide, () => {
|
|
635
|
-
var _a;
|
|
636
|
-
(_a = __privateGet$4(this, _notify)) == null ? void 0 : _a.call(this, { type: "hide" });
|
|
637
|
-
__privateSet$4(this, _active, null);
|
|
638
|
-
});
|
|
639
|
-
/// @internal
|
|
640
|
-
__privateAdd$4(this, _show, (active) => {
|
|
641
|
-
var _a;
|
|
642
|
-
__privateSet$4(this, _active, active);
|
|
643
|
-
(_a = __privateGet$4(this, _notify)) == null ? void 0 : _a.call(this, { type: "show", active });
|
|
644
|
-
});
|
|
645
|
-
/// Bind editor context and notify function to the service.
|
|
646
|
-
this.bind = (ctx, notify) => {
|
|
647
|
-
__privateSet$4(this, _ctx$2, ctx);
|
|
648
|
-
__privateSet$4(this, _notify, notify);
|
|
649
|
-
};
|
|
650
|
-
/// Add mouse event to the dom.
|
|
651
|
-
this.addEvent = (dom) => {
|
|
652
|
-
dom.addEventListener("mousedown", __privateGet$4(this, _handleMouseDown));
|
|
653
|
-
dom.addEventListener("mouseup", __privateGet$4(this, _handleMouseUp));
|
|
654
|
-
dom.addEventListener("dragstart", __privateGet$4(this, _handleDragStart));
|
|
655
|
-
};
|
|
656
|
-
/// Remove mouse event to the dom.
|
|
657
|
-
this.removeEvent = (dom) => {
|
|
658
|
-
dom.removeEventListener("mousedown", __privateGet$4(this, _handleMouseDown));
|
|
659
|
-
dom.removeEventListener("mouseup", __privateGet$4(this, _handleMouseUp));
|
|
660
|
-
dom.removeEventListener("dragstart", __privateGet$4(this, _handleDragStart));
|
|
661
|
-
};
|
|
662
|
-
/// Unbind the notify function.
|
|
663
|
-
this.unBind = () => {
|
|
664
|
-
__privateSet$4(this, _notify, void 0);
|
|
665
|
-
};
|
|
666
|
-
/// @internal
|
|
667
|
-
__privateAdd$4(this, _handleMouseDown, () => {
|
|
668
|
-
var _a;
|
|
669
|
-
__privateSet$4(this, _activeDOMRect, (_a = __privateGet$4(this, _active)) == null ? void 0 : _a.el.getBoundingClientRect());
|
|
670
|
-
__privateGet$4(this, _createSelection).call(this);
|
|
671
|
-
});
|
|
672
|
-
/// @internal
|
|
673
|
-
__privateAdd$4(this, _handleMouseUp, () => {
|
|
674
|
-
if (!__privateGet$4(this, _dragging)) {
|
|
675
|
-
requestAnimationFrame(() => {
|
|
676
|
-
var _a;
|
|
677
|
-
if (!__privateGet$4(this, _activeDOMRect))
|
|
678
|
-
return;
|
|
679
|
-
(_a = __privateGet$4(this, _BlockService_instances, view_get)) == null ? void 0 : _a.focus();
|
|
680
|
-
});
|
|
681
|
-
return;
|
|
682
|
-
}
|
|
683
|
-
__privateSet$4(this, _dragging, false);
|
|
684
|
-
__privateSet$4(this, _activeSelection, null);
|
|
685
|
-
});
|
|
686
|
-
/// @internal
|
|
687
|
-
__privateAdd$4(this, _handleDragStart, (event) => {
|
|
688
|
-
var _a;
|
|
689
|
-
__privateSet$4(this, _dragging, true);
|
|
690
|
-
const view = __privateGet$4(this, _BlockService_instances, view_get);
|
|
691
|
-
if (!view)
|
|
692
|
-
return;
|
|
693
|
-
view.dom.dataset.dragging = "true";
|
|
694
|
-
const selection = __privateGet$4(this, _activeSelection);
|
|
695
|
-
if (event.dataTransfer && selection) {
|
|
696
|
-
const slice = selection.content();
|
|
697
|
-
event.dataTransfer.effectAllowed = "copyMove";
|
|
698
|
-
const { dom, text } = serializeForClipboard(view, slice);
|
|
699
|
-
event.dataTransfer.clearData();
|
|
700
|
-
event.dataTransfer.setData(brokenClipboardAPI ? "Text" : "text/html", dom.innerHTML);
|
|
701
|
-
if (!brokenClipboardAPI)
|
|
702
|
-
event.dataTransfer.setData("text/plain", text);
|
|
703
|
-
const activeEl = (_a = __privateGet$4(this, _active)) == null ? void 0 : _a.el;
|
|
704
|
-
if (activeEl)
|
|
705
|
-
event.dataTransfer.setDragImage(activeEl, 0, 0);
|
|
706
|
-
view.dragging = {
|
|
707
|
-
slice,
|
|
708
|
-
move: true
|
|
709
|
-
};
|
|
710
|
-
__privateGet$4(this, _hide).call(this);
|
|
711
|
-
}
|
|
712
|
-
});
|
|
713
|
-
/// @internal
|
|
714
|
-
this.keydownCallback = (view) => {
|
|
715
|
-
__privateGet$4(this, _hide).call(this);
|
|
716
|
-
__privateSet$4(this, _dragging, false);
|
|
717
|
-
view.dom.dataset.dragging = "false";
|
|
718
|
-
return false;
|
|
719
|
-
};
|
|
720
|
-
/// @internal
|
|
721
|
-
__privateAdd$4(this, _mousemoveCallback, throttle$1((view, event) => {
|
|
722
|
-
if (!view.editable)
|
|
723
|
-
return;
|
|
724
|
-
const rect = view.dom.getBoundingClientRect();
|
|
725
|
-
const x = rect.left + rect.width / 2;
|
|
726
|
-
const dom = view.root.elementFromPoint(x, event.clientY);
|
|
727
|
-
if (!(dom instanceof Element)) {
|
|
728
|
-
__privateGet$4(this, _hide).call(this);
|
|
729
|
-
return;
|
|
730
|
-
}
|
|
731
|
-
const filterNodes = __privateGet$4(this, _BlockService_instances, filterNodes_get);
|
|
732
|
-
if (!filterNodes)
|
|
733
|
-
return;
|
|
734
|
-
const result = selectRootNodeByDom(view, { x, y: event.clientY }, filterNodes);
|
|
735
|
-
if (!result) {
|
|
736
|
-
__privateGet$4(this, _hide).call(this);
|
|
737
|
-
return;
|
|
738
|
-
}
|
|
739
|
-
__privateGet$4(this, _show).call(this, result);
|
|
740
|
-
}, 200));
|
|
741
|
-
/// @internal
|
|
742
|
-
this.mousemoveCallback = (view, event) => {
|
|
743
|
-
if (view.composing || !view.editable)
|
|
744
|
-
return false;
|
|
745
|
-
__privateGet$4(this, _mousemoveCallback).call(this, view, event);
|
|
746
|
-
return false;
|
|
747
|
-
};
|
|
748
|
-
/// @internal
|
|
749
|
-
this.dragoverCallback = (view, event) => {
|
|
750
|
-
var _a;
|
|
751
|
-
if (__privateGet$4(this, _dragging)) {
|
|
752
|
-
const root = (_a = __privateGet$4(this, _BlockService_instances, view_get)) == null ? void 0 : _a.dom.parentElement;
|
|
753
|
-
if (!root)
|
|
754
|
-
return false;
|
|
755
|
-
const hasHorizontalScrollbar = root.scrollHeight > root.clientHeight;
|
|
756
|
-
const rootRect = root.getBoundingClientRect();
|
|
757
|
-
if (hasHorizontalScrollbar) {
|
|
758
|
-
if (root.scrollTop > 0 && Math.abs(event.y - rootRect.y) < buffer) {
|
|
759
|
-
const top = root.scrollTop > 10 ? root.scrollTop - 10 : 0;
|
|
760
|
-
root.scrollTop = top;
|
|
761
|
-
return false;
|
|
762
|
-
}
|
|
763
|
-
const totalHeight = Math.round(view.dom.getBoundingClientRect().height);
|
|
764
|
-
const scrollBottom = Math.round(root.scrollTop + rootRect.height);
|
|
765
|
-
if (scrollBottom < totalHeight && Math.abs(event.y - (rootRect.height + rootRect.y)) < buffer) {
|
|
766
|
-
const top = root.scrollTop + 10;
|
|
767
|
-
root.scrollTop = top;
|
|
768
|
-
return false;
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
return false;
|
|
773
|
-
};
|
|
774
|
-
/// @internal
|
|
775
|
-
this.dragenterCallback = (view) => {
|
|
776
|
-
__privateSet$4(this, _dragging, true);
|
|
777
|
-
view.dom.dataset.dragging = "true";
|
|
778
|
-
};
|
|
779
|
-
/// @internal
|
|
780
|
-
this.dragleaveCallback = (view, event) => {
|
|
781
|
-
const x = event.clientX;
|
|
782
|
-
const y = event.clientY;
|
|
783
|
-
if (x < 0 || y < 0 || x > window.innerWidth || y > window.innerHeight) {
|
|
784
|
-
__privateSet$4(this, _active, null);
|
|
785
|
-
__privateGet$4(this, _dragEnd).call(this, view);
|
|
786
|
-
}
|
|
787
|
-
};
|
|
788
|
-
/// @internal
|
|
789
|
-
this.dropCallback = (view, event) => {
|
|
790
|
-
const tr = removePossibleTable(view, event);
|
|
791
|
-
__privateGet$4(this, _dragEnd).call(this, view);
|
|
792
|
-
if (tr) {
|
|
793
|
-
view.dispatch(tr);
|
|
794
|
-
event.preventDefault();
|
|
795
|
-
return true;
|
|
796
|
-
}
|
|
797
|
-
return false;
|
|
798
|
-
};
|
|
799
|
-
/// @internal
|
|
800
|
-
this.dragendCallback = (view) => {
|
|
801
|
-
__privateGet$4(this, _dragEnd).call(this, view);
|
|
802
|
-
};
|
|
803
|
-
/// @internal
|
|
804
|
-
__privateAdd$4(this, _dragEnd, (view) => {
|
|
805
|
-
__privateSet$4(this, _dragging, false);
|
|
806
|
-
view.dom.dataset.dragging = "false";
|
|
807
|
-
});
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
_ctx$2 = new WeakMap();
|
|
811
|
-
_createSelection = new WeakMap();
|
|
812
|
-
_activeSelection = new WeakMap();
|
|
813
|
-
_active = new WeakMap();
|
|
814
|
-
_activeDOMRect = new WeakMap();
|
|
815
|
-
_dragging = new WeakMap();
|
|
816
|
-
_BlockService_instances = new WeakSet();
|
|
817
|
-
filterNodes_get = function() {
|
|
818
|
-
var _a;
|
|
819
|
-
return (_a = __privateGet$4(this, _ctx$2)) == null ? void 0 : _a.get(blockConfig.key).filterNodes;
|
|
820
|
-
};
|
|
821
|
-
view_get = function() {
|
|
822
|
-
var _a;
|
|
823
|
-
return (_a = __privateGet$4(this, _ctx$2)) == null ? void 0 : _a.get(editorViewCtx);
|
|
824
|
-
};
|
|
825
|
-
_notify = new WeakMap();
|
|
826
|
-
_hide = new WeakMap();
|
|
827
|
-
_show = new WeakMap();
|
|
828
|
-
_handleMouseDown = new WeakMap();
|
|
829
|
-
_handleMouseUp = new WeakMap();
|
|
830
|
-
_handleDragStart = new WeakMap();
|
|
831
|
-
_mousemoveCallback = new WeakMap();
|
|
832
|
-
_dragEnd = new WeakMap();
|
|
833
|
-
|
|
834
|
-
const blockService = $ctx(new BlockService(), "blockService");
|
|
835
|
-
withMeta(blockConfig, {
|
|
836
|
-
displayName: "Ctx<blockService>"
|
|
837
|
-
});
|
|
838
|
-
const blockSpec = $ctx({}, "blockSpec");
|
|
839
|
-
withMeta(blockConfig, {
|
|
840
|
-
displayName: "Ctx<blockSpec>"
|
|
841
|
-
});
|
|
842
|
-
const blockPlugin = $prose((ctx) => {
|
|
843
|
-
const milkdownPluginBlockKey = new PluginKey("MILKDOWN_BLOCK");
|
|
844
|
-
const service = ctx.get(blockService.key);
|
|
845
|
-
const spec = ctx.get(blockSpec.key);
|
|
846
|
-
return new Plugin({
|
|
847
|
-
key: milkdownPluginBlockKey,
|
|
848
|
-
...spec,
|
|
849
|
-
props: {
|
|
850
|
-
...spec.props,
|
|
851
|
-
handleDOMEvents: {
|
|
852
|
-
drop: (view, event) => {
|
|
853
|
-
return service.dropCallback(view, event);
|
|
854
|
-
},
|
|
855
|
-
pointermove: (view, event) => {
|
|
856
|
-
return service.mousemoveCallback(view, event);
|
|
857
|
-
},
|
|
858
|
-
keydown: (view) => {
|
|
859
|
-
return service.keydownCallback(view);
|
|
860
|
-
},
|
|
861
|
-
dragover: (view, event) => {
|
|
862
|
-
return service.dragoverCallback(view, event);
|
|
863
|
-
},
|
|
864
|
-
dragleave: (view, event) => {
|
|
865
|
-
return service.dragleaveCallback(view, event);
|
|
866
|
-
},
|
|
867
|
-
dragenter: (view) => {
|
|
868
|
-
return service.dragenterCallback(view);
|
|
869
|
-
},
|
|
870
|
-
dragend: (view) => {
|
|
871
|
-
return service.dragendCallback(view);
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
});
|
|
876
|
-
});
|
|
877
|
-
withMeta(blockPlugin, {
|
|
878
|
-
displayName: "Prose<block>"
|
|
879
|
-
});
|
|
880
|
-
|
|
881
|
-
var __typeError$3 = (msg) => {
|
|
882
|
-
throw TypeError(msg);
|
|
883
|
-
};
|
|
884
|
-
var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Cannot " + msg);
|
|
885
|
-
var __privateGet$3 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
886
|
-
var __privateAdd$3 = (obj, member, value) => member.has(obj) ? __typeError$3("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
887
|
-
var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
888
|
-
var __privateMethod$1 = (obj, member, method) => (__accessCheck$3(obj, member, "access private method"), method);
|
|
889
|
-
var _element, _ctx$1, _service, _activeNode, _initialized$1, _getOffset, _getPosition, _getPlacement, _BlockProvider_instances, init_fn;
|
|
890
|
-
class BlockProvider {
|
|
891
|
-
constructor(options) {
|
|
892
|
-
__privateAdd$3(this, _BlockProvider_instances);
|
|
893
|
-
/// @internal
|
|
894
|
-
__privateAdd$3(this, _element);
|
|
895
|
-
/// @internal
|
|
896
|
-
__privateAdd$3(this, _ctx$1);
|
|
897
|
-
/// @internal
|
|
898
|
-
__privateAdd$3(this, _service);
|
|
899
|
-
/// @internal
|
|
900
|
-
__privateAdd$3(this, _activeNode, null);
|
|
901
|
-
/// @internal
|
|
902
|
-
__privateAdd$3(this, _initialized$1, false);
|
|
903
|
-
/// @internal
|
|
904
|
-
__privateAdd$3(this, _getOffset);
|
|
905
|
-
/// @internal
|
|
906
|
-
__privateAdd$3(this, _getPosition);
|
|
907
|
-
/// @internal
|
|
908
|
-
__privateAdd$3(this, _getPlacement);
|
|
909
|
-
/// Update provider state by editor view.
|
|
910
|
-
this.update = () => {
|
|
911
|
-
requestAnimationFrame(() => {
|
|
912
|
-
if (!__privateGet$3(this, _initialized$1)) {
|
|
913
|
-
try {
|
|
914
|
-
__privateMethod$1(this, _BlockProvider_instances, init_fn).call(this);
|
|
915
|
-
__privateSet$3(this, _initialized$1, true);
|
|
916
|
-
} catch (e) {
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
});
|
|
920
|
-
};
|
|
921
|
-
/// Destroy the block.
|
|
922
|
-
this.destroy = () => {
|
|
923
|
-
var _a, _b;
|
|
924
|
-
(_a = __privateGet$3(this, _service)) == null ? void 0 : _a.unBind();
|
|
925
|
-
(_b = __privateGet$3(this, _service)) == null ? void 0 : _b.removeEvent(__privateGet$3(this, _element));
|
|
926
|
-
__privateGet$3(this, _element).remove();
|
|
927
|
-
};
|
|
928
|
-
/// Show the block.
|
|
929
|
-
this.show = (active) => {
|
|
930
|
-
const dom = active.el;
|
|
931
|
-
const editorDom = __privateGet$3(this, _ctx$1).get(editorViewCtx).dom;
|
|
932
|
-
const deriveContext = {
|
|
933
|
-
ctx: __privateGet$3(this, _ctx$1),
|
|
934
|
-
active,
|
|
935
|
-
editorDom,
|
|
936
|
-
blockDom: __privateGet$3(this, _element)
|
|
937
|
-
};
|
|
938
|
-
const virtualEl = {
|
|
939
|
-
contextElement: dom,
|
|
940
|
-
getBoundingClientRect: () => {
|
|
941
|
-
if (__privateGet$3(this, _getPosition))
|
|
942
|
-
return __privateGet$3(this, _getPosition).call(this, deriveContext);
|
|
943
|
-
return dom.getBoundingClientRect();
|
|
944
|
-
}
|
|
945
|
-
};
|
|
946
|
-
const middleware = [flip()];
|
|
947
|
-
if (__privateGet$3(this, _getOffset)) {
|
|
948
|
-
const offsetOption = __privateGet$3(this, _getOffset).call(this, deriveContext);
|
|
949
|
-
const offsetExt = offset(offsetOption);
|
|
950
|
-
middleware.push(offsetExt);
|
|
951
|
-
}
|
|
952
|
-
computePosition(virtualEl, __privateGet$3(this, _element), {
|
|
953
|
-
placement: __privateGet$3(this, _getPlacement) ? __privateGet$3(this, _getPlacement).call(this, deriveContext) : "left",
|
|
954
|
-
middleware,
|
|
955
|
-
platform: {
|
|
956
|
-
...platform,
|
|
957
|
-
getOffsetParent: (element) => platform.getOffsetParent(element, t)
|
|
958
|
-
}
|
|
959
|
-
}).then(({ x, y }) => {
|
|
960
|
-
Object.assign(__privateGet$3(this, _element).style, {
|
|
961
|
-
left: `${x}px`,
|
|
962
|
-
top: `${y}px`
|
|
963
|
-
});
|
|
964
|
-
__privateGet$3(this, _element).dataset.show = "true";
|
|
965
|
-
});
|
|
966
|
-
};
|
|
967
|
-
/// Hide the block.
|
|
968
|
-
this.hide = () => {
|
|
969
|
-
__privateGet$3(this, _element).dataset.show = "false";
|
|
970
|
-
Object.assign(__privateGet$3(this, _element).style, {
|
|
971
|
-
left: `-999px`,
|
|
972
|
-
top: `-999px`
|
|
973
|
-
});
|
|
974
|
-
};
|
|
975
|
-
__privateSet$3(this, _ctx$1, options.ctx);
|
|
976
|
-
__privateSet$3(this, _element, options.content);
|
|
977
|
-
__privateSet$3(this, _getOffset, options.getOffset);
|
|
978
|
-
__privateSet$3(this, _getPosition, options.getPosition);
|
|
979
|
-
__privateSet$3(this, _getPlacement, options.getPlacement);
|
|
980
|
-
this.hide();
|
|
981
|
-
}
|
|
982
|
-
/// The context of current active node.
|
|
983
|
-
get active() {
|
|
984
|
-
return __privateGet$3(this, _activeNode);
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
_element = new WeakMap();
|
|
988
|
-
_ctx$1 = new WeakMap();
|
|
989
|
-
_service = new WeakMap();
|
|
990
|
-
_activeNode = new WeakMap();
|
|
991
|
-
_initialized$1 = new WeakMap();
|
|
992
|
-
_getOffset = new WeakMap();
|
|
993
|
-
_getPosition = new WeakMap();
|
|
994
|
-
_getPlacement = new WeakMap();
|
|
995
|
-
_BlockProvider_instances = new WeakSet();
|
|
996
|
-
/// @internal
|
|
997
|
-
init_fn = function() {
|
|
998
|
-
var _a;
|
|
999
|
-
const view = __privateGet$3(this, _ctx$1).get(editorViewCtx);
|
|
1000
|
-
(_a = view.dom.parentElement) == null ? void 0 : _a.appendChild(__privateGet$3(this, _element));
|
|
1001
|
-
const service = __privateGet$3(this, _ctx$1).get(blockService.key);
|
|
1002
|
-
service.bind(__privateGet$3(this, _ctx$1), (message) => {
|
|
1003
|
-
if (message.type === "hide") {
|
|
1004
|
-
this.hide();
|
|
1005
|
-
__privateSet$3(this, _activeNode, null);
|
|
1006
|
-
} else if (message.type === "show") {
|
|
1007
|
-
this.show(message.active);
|
|
1008
|
-
__privateSet$3(this, _activeNode, message.active);
|
|
1009
|
-
}
|
|
1010
|
-
});
|
|
1011
|
-
__privateSet$3(this, _service, service);
|
|
1012
|
-
__privateGet$3(this, _service).addEvent(__privateGet$3(this, _element));
|
|
1013
|
-
__privateGet$3(this, _element).draggable = true;
|
|
1014
|
-
};
|
|
1015
|
-
|
|
1016
|
-
const block = [blockSpec, blockConfig, blockService, blockPlugin];
|
|
1017
|
-
block.key = blockSpec.key;
|
|
1018
|
-
block.pluginKey = blockPlugin.key;
|
|
1019
|
-
|
|
1020
|
-
function slashFactory(id) {
|
|
1021
|
-
const slashSpec = $ctx({}, `${id}_SLASH_SPEC`);
|
|
1022
|
-
const slashPlugin = $prose((ctx) => {
|
|
1023
|
-
const spec = ctx.get(slashSpec.key);
|
|
1024
|
-
return new Plugin({
|
|
1025
|
-
key: new PluginKey(`${id}_SLASH`),
|
|
1026
|
-
...spec
|
|
1027
|
-
});
|
|
1028
|
-
});
|
|
1029
|
-
const result = [slashSpec, slashPlugin];
|
|
1030
|
-
result.key = slashSpec.key;
|
|
1031
|
-
result.pluginKey = slashPlugin.key;
|
|
1032
|
-
slashSpec.meta = {
|
|
1033
|
-
package: "@milkdown/plugin-slash",
|
|
1034
|
-
displayName: `Ctx<slashSpec>|${id}`
|
|
1035
|
-
};
|
|
1036
|
-
slashPlugin.meta = {
|
|
1037
|
-
package: "@milkdown/plugin-slash",
|
|
1038
|
-
displayName: `Prose<slash>|${id}`
|
|
1039
|
-
};
|
|
1040
|
-
return result;
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
var __typeError$2 = (msg) => {
|
|
1044
|
-
throw TypeError(msg);
|
|
1045
|
-
};
|
|
1046
|
-
var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
|
|
1047
|
-
var __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
1048
|
-
var __privateAdd$2 = (obj, member, value) => member.has(obj) ? __typeError$2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1049
|
-
var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
1050
|
-
var __privateMethod = (obj, member, method) => (__accessCheck$2(obj, member, "access private method"), method);
|
|
1051
|
-
var _initialized, _debounce, _trigger, _shouldShow, _offset, _onUpdate, _SlashProvider_instances, _shouldShow_fn;
|
|
1052
|
-
class SlashProvider {
|
|
1053
|
-
constructor(options) {
|
|
1054
|
-
__privateAdd$2(this, _SlashProvider_instances);
|
|
1055
|
-
/// @internal
|
|
1056
|
-
__privateAdd$2(this, _initialized, false);
|
|
1057
|
-
/// @internal
|
|
1058
|
-
__privateAdd$2(this, _debounce);
|
|
1059
|
-
/// @internal
|
|
1060
|
-
__privateAdd$2(this, _trigger);
|
|
1061
|
-
/// @internal
|
|
1062
|
-
__privateAdd$2(this, _shouldShow);
|
|
1063
|
-
/// The offset to get the block. Default is 0.
|
|
1064
|
-
__privateAdd$2(this, _offset);
|
|
1065
|
-
/// On show callback.
|
|
1066
|
-
this.onShow = () => {
|
|
1067
|
-
};
|
|
1068
|
-
/// On hide callback.
|
|
1069
|
-
this.onHide = () => {
|
|
1070
|
-
};
|
|
1071
|
-
/// @internal
|
|
1072
|
-
__privateAdd$2(this, _onUpdate, (view, prevState) => {
|
|
1073
|
-
var _a;
|
|
1074
|
-
const { state, composing } = view;
|
|
1075
|
-
const { selection, doc } = state;
|
|
1076
|
-
const { ranges } = selection;
|
|
1077
|
-
const from = Math.min(...ranges.map((range) => range.$from.pos));
|
|
1078
|
-
const to = Math.max(...ranges.map((range) => range.$to.pos));
|
|
1079
|
-
const isSame = prevState && prevState.doc.eq(doc) && prevState.selection.eq(selection);
|
|
1080
|
-
if (!__privateGet$2(this, _initialized)) {
|
|
1081
|
-
(_a = view.dom.parentElement) == null ? void 0 : _a.appendChild(this.element);
|
|
1082
|
-
__privateSet$2(this, _initialized, true);
|
|
1083
|
-
}
|
|
1084
|
-
if (composing || isSame)
|
|
1085
|
-
return;
|
|
1086
|
-
if (!__privateGet$2(this, _shouldShow).call(this, view, prevState)) {
|
|
1087
|
-
this.hide();
|
|
1088
|
-
return;
|
|
1089
|
-
}
|
|
1090
|
-
const virtualEl = {
|
|
1091
|
-
getBoundingClientRect: () => posToDOMRect(view, from, to)
|
|
1092
|
-
};
|
|
1093
|
-
computePosition(virtualEl, this.element, {
|
|
1094
|
-
placement: "bottom-start",
|
|
1095
|
-
middleware: [flip(), offset(__privateGet$2(this, _offset))],
|
|
1096
|
-
platform: {
|
|
1097
|
-
...platform,
|
|
1098
|
-
getOffsetParent: (element) => platform.getOffsetParent(element, t)
|
|
1099
|
-
}
|
|
1100
|
-
}).then(({ x, y }) => {
|
|
1101
|
-
Object.assign(this.element.style, {
|
|
1102
|
-
left: `${x}px`,
|
|
1103
|
-
top: `${y}px`
|
|
1104
|
-
});
|
|
1105
|
-
});
|
|
1106
|
-
this.show();
|
|
1107
|
-
});
|
|
1108
|
-
/// Update provider state by editor view.
|
|
1109
|
-
this.update = (view, prevState) => {
|
|
1110
|
-
const updater = debounce$1(__privateGet$2(this, _onUpdate), __privateGet$2(this, _debounce));
|
|
1111
|
-
updater(view, prevState);
|
|
1112
|
-
};
|
|
1113
|
-
/// Get the content of the current text block.
|
|
1114
|
-
/// Pass the `matchNode` function to determine whether the current node should be matched, by default, it will match the paragraph node.
|
|
1115
|
-
this.getContent = (view, matchNode = (node) => node.type.name === "paragraph") => {
|
|
1116
|
-
const { selection } = view.state;
|
|
1117
|
-
const { empty, $from } = selection;
|
|
1118
|
-
const isTextBlock = view.state.selection instanceof TextSelection;
|
|
1119
|
-
const isSlashChildren = this.element.contains(document.activeElement);
|
|
1120
|
-
const notHasFocus = !view.hasFocus() && !isSlashChildren;
|
|
1121
|
-
const isReadonly = !view.editable;
|
|
1122
|
-
const paragraph = findParentNode(matchNode)(view.state.selection);
|
|
1123
|
-
const isNotInParagraph = !paragraph;
|
|
1124
|
-
if (notHasFocus || isReadonly || !empty || !isTextBlock || isNotInParagraph)
|
|
1125
|
-
return;
|
|
1126
|
-
return $from.parent.textBetween(Math.max(0, $from.parentOffset - 500), $from.parentOffset, void 0, "\uFFFC");
|
|
1127
|
-
};
|
|
1128
|
-
/// Destroy the slash.
|
|
1129
|
-
this.destroy = () => {
|
|
1130
|
-
};
|
|
1131
|
-
/// Show the slash.
|
|
1132
|
-
this.show = () => {
|
|
1133
|
-
this.element.dataset.show = "true";
|
|
1134
|
-
this.onShow();
|
|
1135
|
-
};
|
|
1136
|
-
/// Hide the slash.
|
|
1137
|
-
this.hide = () => {
|
|
1138
|
-
this.element.dataset.show = "false";
|
|
1139
|
-
this.onHide();
|
|
1140
|
-
};
|
|
1141
|
-
var _a, _b, _c;
|
|
1142
|
-
this.element = options.content;
|
|
1143
|
-
__privateSet$2(this, _debounce, (_a = options.debounce) != null ? _a : 200);
|
|
1144
|
-
__privateSet$2(this, _shouldShow, (_b = options.shouldShow) != null ? _b : __privateMethod(this, _SlashProvider_instances, _shouldShow_fn));
|
|
1145
|
-
__privateSet$2(this, _trigger, (_c = options.trigger) != null ? _c : "/");
|
|
1146
|
-
__privateSet$2(this, _offset, options.offset);
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
_initialized = new WeakMap();
|
|
1150
|
-
_debounce = new WeakMap();
|
|
1151
|
-
_trigger = new WeakMap();
|
|
1152
|
-
_shouldShow = new WeakMap();
|
|
1153
|
-
_offset = new WeakMap();
|
|
1154
|
-
_onUpdate = new WeakMap();
|
|
1155
|
-
_SlashProvider_instances = new WeakSet();
|
|
1156
|
-
/// @internal
|
|
1157
|
-
_shouldShow_fn = function(view) {
|
|
1158
|
-
const currentTextBlockContent = this.getContent(view);
|
|
1159
|
-
if (!currentTextBlockContent)
|
|
1160
|
-
return false;
|
|
1161
|
-
const target = currentTextBlockContent.at(-1);
|
|
1162
|
-
if (!target)
|
|
1163
|
-
return false;
|
|
1164
|
-
return Array.isArray(__privateGet$2(this, _trigger)) ? __privateGet$2(this, _trigger).includes(target) : __privateGet$2(this, _trigger) === target;
|
|
1165
|
-
};
|
|
1166
|
-
|
|
1167
|
-
const textIcon = html`
|
|
1168
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
1169
|
-
<g clip-path="url(#clip0_992_5547)">
|
|
1170
|
-
<path d="M5 5.5C5 6.33 5.67 7 6.5 7H10.5V17.5C10.5 18.33 11.17 19 12 19C12.83 19 13.5 18.33 13.5 17.5V7H17.5C18.33 7 19 6.33 19 5.5C19 4.67 18.33 4 17.5 4H6.5C5.67 4 5 4.67 5 5.5Z" fill="#817567"/>
|
|
1171
|
-
</g>
|
|
1172
|
-
<defs>
|
|
1173
|
-
<clipPath id="clip0_992_5547">
|
|
1174
|
-
<rect width="24" height="24" fill="white"/>
|
|
1175
|
-
</clipPath>
|
|
1176
|
-
</defs>
|
|
1177
|
-
</svg>
|
|
1178
|
-
`;
|
|
1179
|
-
const h1Icon = html`
|
|
1180
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
1181
|
-
<g clip-path="url(#clip0_992_5553)">
|
|
1182
|
-
<path d="M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM19 19H5V5H19V19ZM12 17H14V7H10V9H12V17Z" fill="#817567"/>
|
|
1183
|
-
</g>
|
|
1184
|
-
<defs>
|
|
1185
|
-
<clipPath id="clip0_992_5553">
|
|
1186
|
-
<rect width="24" height="24" fill="white"/>
|
|
1187
|
-
</clipPath>
|
|
1188
|
-
</defs>
|
|
1189
|
-
</svg>
|
|
1190
|
-
`;
|
|
1191
|
-
const h2Icon = html`
|
|
1192
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
1193
|
-
<g clip-path="url(#clip0_992_5559)">
|
|
1194
|
-
<path d="M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM19 19H5V5H19V19ZM15 15H11V13H13C14.1 13 15 12.11 15 11V9C15 7.89 14.1 7 13 7H9V9H13V11H11C9.9 11 9 11.89 9 13V17H15V15Z" fill="#817567"/>
|
|
1195
|
-
</g>
|
|
1196
|
-
<defs>
|
|
1197
|
-
<clipPath id="clip0_992_5559">
|
|
1198
|
-
<rect width="24" height="24" fill="white"/>
|
|
1199
|
-
</clipPath>
|
|
1200
|
-
</defs>
|
|
1201
|
-
</svg>
|
|
1202
|
-
`;
|
|
1203
|
-
const h3Icon = html`
|
|
1204
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
1205
|
-
<g clip-path="url(#clip0_992_5565)">
|
|
1206
|
-
<path d="M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM19 19H5V5H19V19ZM15 15V13.5C15 12.67 14.33 12 13.5 12C14.33 12 15 11.33 15 10.5V9C15 7.89 14.1 7 13 7H9V9H13V11H11V13H13V15H9V17H13C14.1 17 15 16.11 15 15Z" fill="#817567"/>
|
|
1207
|
-
</g>
|
|
1208
|
-
<defs>
|
|
1209
|
-
<clipPath id="clip0_992_5565">
|
|
1210
|
-
<rect width="24" height="24" fill="white"/>
|
|
1211
|
-
</clipPath>
|
|
1212
|
-
</defs>
|
|
1213
|
-
</svg>
|
|
1214
|
-
`;
|
|
1215
|
-
const h4Icon = html`
|
|
1216
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
1217
|
-
<g clip-path="url(#clip0_977_7757)">
|
|
1218
|
-
<path d="M19.04 3H5.04004C3.94004 3 3.04004 3.9 3.04004 5V19C3.04004 20.1 3.94004 21 5.04004 21H19.04C20.14 21 21.04 20.1 21.04 19V5C21.04 3.9 20.14 3 19.04 3ZM19.04 19H5.04004V5H19.04V19ZM13.04 17H15.04V7H13.04V11H11.04V7H9.04004V13H13.04V17Z" fill="#817567"/>
|
|
1219
|
-
</g>
|
|
1220
|
-
<defs>
|
|
1221
|
-
<clipPath id="clip0_977_7757">
|
|
1222
|
-
<rect width="24" height="24" fill="white"/>
|
|
1223
|
-
</clipPath>
|
|
1224
|
-
</defs>
|
|
1225
|
-
</svg>
|
|
1226
|
-
`;
|
|
1227
|
-
const h5Icon = html`
|
|
1228
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
1229
|
-
<g clip-path="url(#clip0_977_7760)">
|
|
1230
|
-
<path d="M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM19 19H5V5H19V19ZM15 15V13C15 11.89 14.1 11 13 11H11V9H15V7H9V13H13V15H9V17H13C14.1 17 15 16.11 15 15Z" fill="#817567"/>
|
|
1231
|
-
</g>
|
|
1232
|
-
<defs>
|
|
1233
|
-
<clipPath id="clip0_977_7760">
|
|
1234
|
-
<rect width="24" height="24" fill="white"/>
|
|
1235
|
-
</clipPath>
|
|
1236
|
-
</defs>
|
|
1237
|
-
</svg>
|
|
1238
|
-
`;
|
|
1239
|
-
const h6Icon = html`
|
|
1240
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
1241
|
-
<g clip-path="url(#clip0_977_7763)">
|
|
1242
|
-
<path d="M11 17H13C14.1 17 15 16.11 15 15V13C15 11.89 14.1 11 13 11H11V9H15V7H11C9.9 7 9 7.89 9 9V15C9 16.11 9.9 17 11 17ZM11 13H13V15H11V13ZM19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM19 19H5V5H19V19Z" fill="#817567"/>
|
|
1243
|
-
</g>
|
|
1244
|
-
<defs>
|
|
1245
|
-
<clipPath id="clip0_977_7763">
|
|
1246
|
-
<rect width="24" height="24" fill="white"/>
|
|
1247
|
-
</clipPath>
|
|
1248
|
-
</defs>
|
|
1249
|
-
</svg>
|
|
1250
|
-
`;
|
|
1251
|
-
const bulletListIcon = html`
|
|
1252
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
1253
|
-
<g clip-path="url(#clip0_977_8070)">
|
|
1254
|
-
<path d="M4 10.5C3.17 10.5 2.5 11.17 2.5 12C2.5 12.83 3.17 13.5 4 13.5C4.83 13.5 5.5 12.83 5.5 12C5.5 11.17 4.83 10.5 4 10.5ZM4 4.5C3.17 4.5 2.5 5.17 2.5 6C2.5 6.83 3.17 7.5 4 7.5C4.83 7.5 5.5 6.83 5.5 6C5.5 5.17 4.83 4.5 4 4.5ZM4 16.5C3.17 16.5 2.5 17.18 2.5 18C2.5 18.82 3.18 19.5 4 19.5C4.82 19.5 5.5 18.82 5.5 18C5.5 17.18 4.83 16.5 4 16.5ZM8 19H20C20.55 19 21 18.55 21 18C21 17.45 20.55 17 20 17H8C7.45 17 7 17.45 7 18C7 18.55 7.45 19 8 19ZM8 13H20C20.55 13 21 12.55 21 12C21 11.45 20.55 11 20 11H8C7.45 11 7 11.45 7 12C7 12.55 7.45 13 8 13ZM7 6C7 6.55 7.45 7 8 7H20C20.55 7 21 6.55 21 6C21 5.45 20.55 5 20 5H8C7.45 5 7 5.45 7 6Z" fill="#817567"/>
|
|
1255
|
-
</g>
|
|
1256
|
-
<defs>
|
|
1257
|
-
<clipPath id="clip0_977_8070">
|
|
1258
|
-
<rect width="24" height="24" fill="white"/>
|
|
1259
|
-
</clipPath>
|
|
1260
|
-
</defs>
|
|
1261
|
-
</svg>
|
|
1262
|
-
`;
|
|
1263
|
-
const orderedListIcon = html`
|
|
1264
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
1265
|
-
<g clip-path="url(#clip0_977_8067)">
|
|
1266
|
-
<path d="M8 7H20C20.55 7 21 6.55 21 6C21 5.45 20.55 5 20 5H8C7.45 5 7 5.45 7 6C7 6.55 7.45 7 8 7ZM20 17H8C7.45 17 7 17.45 7 18C7 18.55 7.45 19 8 19H20C20.55 19 21 18.55 21 18C21 17.45 20.55 17 20 17ZM20 11H8C7.45 11 7 11.45 7 12C7 12.55 7.45 13 8 13H20C20.55 13 21 12.55 21 12C21 11.45 20.55 11 20 11ZM4.5 16H2.5C2.22 16 2 16.22 2 16.5C2 16.78 2.22 17 2.5 17H4V17.5H3.5C3.22 17.5 3 17.72 3 18C3 18.28 3.22 18.5 3.5 18.5H4V19H2.5C2.22 19 2 19.22 2 19.5C2 19.78 2.22 20 2.5 20H4.5C4.78 20 5 19.78 5 19.5V16.5C5 16.22 4.78 16 4.5 16ZM2.5 5H3V7.5C3 7.78 3.22 8 3.5 8C3.78 8 4 7.78 4 7.5V4.5C4 4.22 3.78 4 3.5 4H2.5C2.22 4 2 4.22 2 4.5C2 4.78 2.22 5 2.5 5ZM4.5 10H2.5C2.22 10 2 10.22 2 10.5C2 10.78 2.22 11 2.5 11H3.8L2.12 12.96C2.04 13.05 2 13.17 2 13.28V13.5C2 13.78 2.22 14 2.5 14H4.5C4.78 14 5 13.78 5 13.5C5 13.22 4.78 13 4.5 13H3.2L4.88 11.04C4.96 10.95 5 10.83 5 10.72V10.5C5 10.22 4.78 10 4.5 10Z" fill="#817567"/>
|
|
1267
|
-
</g>
|
|
1268
|
-
<defs>
|
|
1269
|
-
<clipPath id="clip0_977_8067">
|
|
1270
|
-
<rect width="24" height="24" fill="white"/>
|
|
1271
|
-
</clipPath>
|
|
1272
|
-
</defs>
|
|
1273
|
-
</svg>
|
|
1274
|
-
`;
|
|
1275
|
-
const quoteIcon = html`
|
|
1276
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
1277
|
-
<g clip-path="url(#clip0_977_7897)">
|
|
1278
|
-
<path d="M7.17 17C7.68 17 8.15 16.71 8.37 16.26L9.79 13.42C9.93 13.14 10 12.84 10 12.53V8C10 7.45 9.55 7 9 7H5C4.45 7 4 7.45 4 8V12C4 12.55 4.45 13 5 13H7L5.97 15.06C5.52 15.95 6.17 17 7.17 17ZM17.17 17C17.68 17 18.15 16.71 18.37 16.26L19.79 13.42C19.93 13.14 20 12.84 20 12.53V8C20 7.45 19.55 7 19 7H15C14.45 7 14 7.45 14 8V12C14 12.55 14.45 13 15 13H17L15.97 15.06C15.52 15.95 16.17 17 17.17 17Z" fill="#817567"/>
|
|
1279
|
-
</g>
|
|
1280
|
-
<defs>
|
|
1281
|
-
<clipPath id="clip0_977_7897">
|
|
1282
|
-
<rect width="24" height="24" fill="white"/>
|
|
1283
|
-
</clipPath>
|
|
1284
|
-
</defs>
|
|
1285
|
-
</svg>
|
|
1286
|
-
`;
|
|
1287
|
-
const dividerIcon = html`
|
|
1288
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
1289
|
-
<g clip-path="url(#clip0_977_7900)">
|
|
1290
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M19 13H5C4.45 13 4 12.55 4 12C4 11.45 4.45 11 5 11H19C19.55 11 20 11.45 20 12C20 12.55 19.55 13 19 13Z" fill="#817567"/>
|
|
1291
|
-
</g>
|
|
1292
|
-
<defs>
|
|
1293
|
-
<clipPath id="clip0_977_7900">
|
|
1294
|
-
<rect width="24" height="24" fill="white"/>
|
|
1295
|
-
</clipPath>
|
|
1296
|
-
</defs>
|
|
1297
|
-
</svg>
|
|
1298
|
-
`;
|
|
1299
|
-
const imageIcon = html`
|
|
1300
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
1301
|
-
<g clip-path="url(#clip0_977_8075)">
|
|
1302
|
-
<path d="M19 5V19H5V5H19ZM19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM14.14 11.86L11.14 15.73L9 13.14L6 17H18L14.14 11.86Z" fill="#817567"/>
|
|
1303
|
-
</g>
|
|
1304
|
-
<defs>
|
|
1305
|
-
<clipPath id="clip0_977_8075">
|
|
1306
|
-
<rect width="24" height="24" fill="white"/>
|
|
1307
|
-
</clipPath>
|
|
1308
|
-
</defs>
|
|
1309
|
-
</svg>
|
|
1310
|
-
`;
|
|
1311
|
-
const codeIcon = html`
|
|
1312
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
1313
|
-
<g clip-path="url(#clip0_977_8081)">
|
|
1314
|
-
<path d="M9.4 16.6L4.8 12L9.4 7.4L8 6L2 12L8 18L9.4 16.6ZM14.6 16.6L19.2 12L14.6 7.4L16 6L22 12L16 18L14.6 16.6Z" fill="#817567"/>
|
|
1315
|
-
</g>
|
|
1316
|
-
<defs>
|
|
1317
|
-
<clipPath id="clip0_977_8081">
|
|
1318
|
-
<rect width="24" height="24" fill="white"/>
|
|
1319
|
-
</clipPath>
|
|
1320
|
-
</defs>
|
|
1321
|
-
</svg>
|
|
1322
|
-
`;
|
|
1323
|
-
|
|
1324
|
-
function clearRange(tr) {
|
|
1325
|
-
const { $from, $to } = tr.selection;
|
|
1326
|
-
const { pos: from } = $from;
|
|
1327
|
-
const { pos: to } = $to;
|
|
1328
|
-
tr = tr.deleteRange(from - $from.node().content.size, to);
|
|
1329
|
-
return tr;
|
|
1330
|
-
}
|
|
1331
|
-
function setBlockType(tr, nodeType, attrs = null) {
|
|
1332
|
-
const { from, to } = tr.selection;
|
|
1333
|
-
return tr.setBlockType(from, to, nodeType, attrs);
|
|
1334
|
-
}
|
|
1335
|
-
function wrapInBlockType(tr, nodeType, attrs = null) {
|
|
1336
|
-
const { $from, $to } = tr.selection;
|
|
1337
|
-
const range = $from.blockRange($to);
|
|
1338
|
-
const wrapping = range && findWrapping(range, nodeType, attrs);
|
|
1339
|
-
if (!wrapping)
|
|
1340
|
-
return null;
|
|
1341
|
-
return tr.wrap(range, wrapping);
|
|
1342
|
-
}
|
|
1343
|
-
function addBlockType(tr, nodeType, attrs = null) {
|
|
1344
|
-
const node = nodeType.createAndFill(attrs);
|
|
1345
|
-
if (!node)
|
|
1346
|
-
return null;
|
|
1347
|
-
return tr.replaceSelectionWith(node);
|
|
1348
|
-
}
|
|
1349
|
-
function clearContentAndSetBlockType(nodeType, attrs = null) {
|
|
1350
|
-
return (state, dispatch) => {
|
|
1351
|
-
if (dispatch) {
|
|
1352
|
-
const tr = setBlockType(clearRange(state.tr), nodeType, attrs);
|
|
1353
|
-
dispatch(tr.scrollIntoView());
|
|
1354
|
-
}
|
|
1355
|
-
return true;
|
|
1356
|
-
};
|
|
1357
|
-
}
|
|
1358
|
-
function clearContentAndWrapInBlockType(nodeType, attrs = null) {
|
|
1359
|
-
return (state, dispatch) => {
|
|
1360
|
-
const tr = wrapInBlockType(clearRange(state.tr), nodeType, attrs);
|
|
1361
|
-
if (!tr)
|
|
1362
|
-
return false;
|
|
1363
|
-
if (dispatch)
|
|
1364
|
-
dispatch(tr.scrollIntoView());
|
|
1365
|
-
return true;
|
|
1366
|
-
};
|
|
1367
|
-
}
|
|
1368
|
-
function clearContentAndAddBlockType(nodeType, attrs = null) {
|
|
1369
|
-
return (state, dispatch) => {
|
|
1370
|
-
const tr = addBlockType(clearRange(state.tr), nodeType, attrs);
|
|
1371
|
-
if (!tr)
|
|
1372
|
-
return false;
|
|
1373
|
-
if (dispatch)
|
|
1374
|
-
dispatch(tr.scrollIntoView());
|
|
1375
|
-
return true;
|
|
1376
|
-
};
|
|
1377
|
-
}
|
|
1378
|
-
function getGroups(filter) {
|
|
1379
|
-
let groups = [
|
|
1380
|
-
{
|
|
1381
|
-
key: "text",
|
|
1382
|
-
label: "Text",
|
|
1383
|
-
items: [
|
|
1384
|
-
{
|
|
1385
|
-
key: "text",
|
|
1386
|
-
label: "Text",
|
|
1387
|
-
icon: textIcon,
|
|
1388
|
-
onRun: (ctx) => {
|
|
1389
|
-
const view = ctx.get(editorViewCtx);
|
|
1390
|
-
const { dispatch, state } = view;
|
|
1391
|
-
const command = clearContentAndSetBlockType(paragraphSchema.type(ctx));
|
|
1392
|
-
command(state, dispatch);
|
|
1393
|
-
}
|
|
1394
|
-
},
|
|
1395
|
-
{
|
|
1396
|
-
key: "h1",
|
|
1397
|
-
label: "Heading 1",
|
|
1398
|
-
icon: h1Icon,
|
|
1399
|
-
onRun: (ctx) => {
|
|
1400
|
-
const view = ctx.get(editorViewCtx);
|
|
1401
|
-
const { dispatch, state } = view;
|
|
1402
|
-
const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 1 });
|
|
1403
|
-
command(state, dispatch);
|
|
1404
|
-
}
|
|
1405
|
-
},
|
|
1406
|
-
{
|
|
1407
|
-
key: "h2",
|
|
1408
|
-
label: "Heading 2",
|
|
1409
|
-
icon: h2Icon,
|
|
1410
|
-
onRun: (ctx) => {
|
|
1411
|
-
const view = ctx.get(editorViewCtx);
|
|
1412
|
-
const { dispatch, state } = view;
|
|
1413
|
-
const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 2 });
|
|
1414
|
-
command(state, dispatch);
|
|
1415
|
-
}
|
|
1416
|
-
},
|
|
1417
|
-
{
|
|
1418
|
-
key: "h3",
|
|
1419
|
-
label: "Heading 3",
|
|
1420
|
-
icon: h3Icon,
|
|
1421
|
-
onRun: (ctx) => {
|
|
1422
|
-
const view = ctx.get(editorViewCtx);
|
|
1423
|
-
const { dispatch, state } = view;
|
|
1424
|
-
const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 3 });
|
|
1425
|
-
command(state, dispatch);
|
|
1426
|
-
}
|
|
1427
|
-
},
|
|
1428
|
-
{
|
|
1429
|
-
key: "h4",
|
|
1430
|
-
label: "Heading 4",
|
|
1431
|
-
icon: h4Icon,
|
|
1432
|
-
onRun: (ctx) => {
|
|
1433
|
-
const view = ctx.get(editorViewCtx);
|
|
1434
|
-
const { dispatch, state } = view;
|
|
1435
|
-
const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 4 });
|
|
1436
|
-
command(state, dispatch);
|
|
1437
|
-
}
|
|
1438
|
-
},
|
|
1439
|
-
{
|
|
1440
|
-
key: "h5",
|
|
1441
|
-
label: "Heading 5",
|
|
1442
|
-
icon: h5Icon,
|
|
1443
|
-
onRun: (ctx) => {
|
|
1444
|
-
const view = ctx.get(editorViewCtx);
|
|
1445
|
-
const { dispatch, state } = view;
|
|
1446
|
-
const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 5 });
|
|
1447
|
-
command(state, dispatch);
|
|
1448
|
-
}
|
|
1449
|
-
},
|
|
1450
|
-
{
|
|
1451
|
-
key: "h6",
|
|
1452
|
-
label: "Heading 6",
|
|
1453
|
-
icon: h6Icon,
|
|
1454
|
-
onRun: (ctx) => {
|
|
1455
|
-
const view = ctx.get(editorViewCtx);
|
|
1456
|
-
const { dispatch, state } = view;
|
|
1457
|
-
const command = clearContentAndSetBlockType(headingSchema.type(ctx), { level: 6 });
|
|
1458
|
-
command(state, dispatch);
|
|
1459
|
-
}
|
|
1460
|
-
},
|
|
1461
|
-
{
|
|
1462
|
-
key: "quote",
|
|
1463
|
-
label: "Quote",
|
|
1464
|
-
icon: quoteIcon,
|
|
1465
|
-
onRun: (ctx) => {
|
|
1466
|
-
const view = ctx.get(editorViewCtx);
|
|
1467
|
-
const { dispatch, state } = view;
|
|
1468
|
-
const command = clearContentAndWrapInBlockType(blockquoteSchema.type(ctx));
|
|
1469
|
-
command(state, dispatch);
|
|
1470
|
-
}
|
|
1471
|
-
},
|
|
1472
|
-
{
|
|
1473
|
-
key: "divider",
|
|
1474
|
-
label: "Divider",
|
|
1475
|
-
icon: dividerIcon,
|
|
1476
|
-
onRun: (ctx) => {
|
|
1477
|
-
const view = ctx.get(editorViewCtx);
|
|
1478
|
-
const { dispatch, state } = view;
|
|
1479
|
-
const command = clearContentAndAddBlockType(hrSchema.type(ctx));
|
|
1480
|
-
command(state, dispatch);
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
]
|
|
1484
|
-
},
|
|
1485
|
-
{
|
|
1486
|
-
key: "list",
|
|
1487
|
-
label: "List",
|
|
1488
|
-
items: [
|
|
1489
|
-
{
|
|
1490
|
-
key: "bullet-list",
|
|
1491
|
-
label: "Bullet List",
|
|
1492
|
-
icon: bulletListIcon,
|
|
1493
|
-
onRun: (ctx) => {
|
|
1494
|
-
const view = ctx.get(editorViewCtx);
|
|
1495
|
-
const { dispatch, state } = view;
|
|
1496
|
-
const command = clearContentAndWrapInBlockType(bulletListSchema.type(ctx));
|
|
1497
|
-
command(state, dispatch);
|
|
1498
|
-
}
|
|
1499
|
-
},
|
|
1500
|
-
{
|
|
1501
|
-
key: "ordered-list",
|
|
1502
|
-
label: "Ordered List",
|
|
1503
|
-
icon: orderedListIcon,
|
|
1504
|
-
onRun: (ctx) => {
|
|
1505
|
-
const view = ctx.get(editorViewCtx);
|
|
1506
|
-
const { dispatch, state } = view;
|
|
1507
|
-
const command = clearContentAndWrapInBlockType(orderedListSchema.type(ctx));
|
|
1508
|
-
command(state, dispatch);
|
|
1509
|
-
}
|
|
1510
|
-
}
|
|
1511
|
-
]
|
|
1512
|
-
},
|
|
1513
|
-
{
|
|
1514
|
-
key: "advanced",
|
|
1515
|
-
label: "Advanced",
|
|
1516
|
-
items: [
|
|
1517
|
-
{
|
|
1518
|
-
key: "image",
|
|
1519
|
-
label: "Image",
|
|
1520
|
-
icon: imageIcon,
|
|
1521
|
-
onRun: (ctx) => {
|
|
1522
|
-
const view = ctx.get(editorViewCtx);
|
|
1523
|
-
const { dispatch, state } = view;
|
|
1524
|
-
const command = clearContentAndAddBlockType(imageBlockSchema.type(ctx));
|
|
1525
|
-
command(state, dispatch);
|
|
1526
|
-
}
|
|
1527
|
-
},
|
|
1528
|
-
{
|
|
1529
|
-
key: "code",
|
|
1530
|
-
label: "Code",
|
|
1531
|
-
icon: codeIcon,
|
|
1532
|
-
onRun: (ctx) => {
|
|
1533
|
-
const view = ctx.get(editorViewCtx);
|
|
1534
|
-
const { dispatch, state } = view;
|
|
1535
|
-
const command = clearContentAndAddBlockType(codeBlockSchema.type(ctx));
|
|
1536
|
-
command(state, dispatch);
|
|
1537
|
-
}
|
|
1538
|
-
}
|
|
1539
|
-
]
|
|
1540
|
-
}
|
|
1541
|
-
];
|
|
1542
|
-
if (filter) {
|
|
1543
|
-
groups = groups.map((group) => {
|
|
1544
|
-
const items2 = group.items.filter((item) => item.label.toLowerCase().includes(filter.toLowerCase()));
|
|
1545
|
-
return {
|
|
1546
|
-
...group,
|
|
1547
|
-
items: items2
|
|
1548
|
-
};
|
|
1549
|
-
}).filter((group) => group.items.length > 0);
|
|
1550
|
-
}
|
|
1551
|
-
const items = groups.flatMap((groups2) => groups2.items);
|
|
1552
|
-
items.forEach((item, index) => {
|
|
1553
|
-
Object.assign(item, {
|
|
1554
|
-
index
|
|
1555
|
-
});
|
|
1556
|
-
});
|
|
1557
|
-
groups.reduce((acc, group) => {
|
|
1558
|
-
const end = acc + group.items.length;
|
|
1559
|
-
Object.assign(group, {
|
|
1560
|
-
range: [acc, end]
|
|
1561
|
-
});
|
|
1562
|
-
return end;
|
|
1563
|
-
}, 0);
|
|
1564
|
-
return {
|
|
1565
|
-
groups,
|
|
1566
|
-
size: items.length
|
|
1567
|
-
};
|
|
1568
|
-
}
|
|
1569
|
-
|
|
1570
|
-
const menuComponent = ({
|
|
1571
|
-
show,
|
|
1572
|
-
hide,
|
|
1573
|
-
ctx,
|
|
1574
|
-
filter
|
|
1575
|
-
}) => {
|
|
1576
|
-
const { groups, size } = useMemo(() => getGroups(filter), [filter]);
|
|
1577
|
-
const host = useHost();
|
|
1578
|
-
const [hoverIndex, setHoverIndex] = useState(0);
|
|
1579
|
-
const root = useMemo(() => host.current.getRootNode(), [host]);
|
|
1580
|
-
const prevMousePosition = useRef({ x: -999, y: -999 });
|
|
1581
|
-
const onMouseMove = useCallback((e) => {
|
|
1582
|
-
const prevPos = prevMousePosition.current;
|
|
1583
|
-
if (!prevPos)
|
|
1584
|
-
return;
|
|
1585
|
-
const { x, y } = e;
|
|
1586
|
-
prevPos.x = x;
|
|
1587
|
-
prevPos.y = y;
|
|
1588
|
-
}, []);
|
|
1589
|
-
useEffect(() => {
|
|
1590
|
-
if (size === 0 && show)
|
|
1591
|
-
hide == null ? void 0 : hide();
|
|
1592
|
-
}, [size, show]);
|
|
1593
|
-
const onHover = useCallback((index, after) => {
|
|
1594
|
-
setHoverIndex((prev) => {
|
|
1595
|
-
const next = typeof index === "function" ? index(prev) : index;
|
|
1596
|
-
after == null ? void 0 : after(next);
|
|
1597
|
-
return next;
|
|
1598
|
-
});
|
|
1599
|
-
}, []);
|
|
1600
|
-
const scrollToIndex = useCallback((index) => {
|
|
1601
|
-
const target = host.current.querySelector(`[data-index="${index}"]`);
|
|
1602
|
-
const scrollRoot = host.current.querySelector(".menu-groups");
|
|
1603
|
-
if (!target || !scrollRoot)
|
|
1604
|
-
return;
|
|
1605
|
-
scrollRoot.scrollTop = target.offsetTop - scrollRoot.offsetTop;
|
|
1606
|
-
}, []);
|
|
1607
|
-
const runByIndex = useCallback((index) => {
|
|
1608
|
-
const item = groups.flatMap((group) => group.items).at(index);
|
|
1609
|
-
if (item && ctx)
|
|
1610
|
-
item.onRun(ctx);
|
|
1611
|
-
hide == null ? void 0 : hide();
|
|
1612
|
-
}, [groups]);
|
|
1613
|
-
const onKeydown = useCallback((e) => {
|
|
1614
|
-
if (e.key === "Escape") {
|
|
1615
|
-
e.preventDefault();
|
|
1616
|
-
hide == null ? void 0 : hide();
|
|
1617
|
-
return;
|
|
1618
|
-
}
|
|
1619
|
-
if (e.key === "ArrowDown") {
|
|
1620
|
-
e.preventDefault();
|
|
1621
|
-
return onHover((index) => index < size - 1 ? index + 1 : index, scrollToIndex);
|
|
1622
|
-
}
|
|
1623
|
-
if (e.key === "ArrowUp") {
|
|
1624
|
-
e.preventDefault();
|
|
1625
|
-
return onHover((index) => index <= 0 ? index : index - 1, scrollToIndex);
|
|
1626
|
-
}
|
|
1627
|
-
if (e.key === "ArrowLeft") {
|
|
1628
|
-
e.preventDefault();
|
|
1629
|
-
return onHover((index) => {
|
|
1630
|
-
const group = groups.find((group2) => group2.range[0] <= index && group2.range[1] > index);
|
|
1631
|
-
if (!group)
|
|
1632
|
-
return index;
|
|
1633
|
-
const prevGroup = groups[groups.indexOf(group) - 1];
|
|
1634
|
-
if (!prevGroup)
|
|
1635
|
-
return index;
|
|
1636
|
-
return prevGroup.range[1] - 1;
|
|
1637
|
-
}, scrollToIndex);
|
|
1638
|
-
}
|
|
1639
|
-
if (e.key === "ArrowRight") {
|
|
1640
|
-
e.preventDefault();
|
|
1641
|
-
return onHover((index) => {
|
|
1642
|
-
const group = groups.find((group2) => group2.range[0] <= index && group2.range[1] > index);
|
|
1643
|
-
if (!group)
|
|
1644
|
-
return index;
|
|
1645
|
-
const nextGroup = groups[groups.indexOf(group) + 1];
|
|
1646
|
-
if (!nextGroup)
|
|
1647
|
-
return index;
|
|
1648
|
-
return nextGroup.range[0];
|
|
1649
|
-
}, scrollToIndex);
|
|
1650
|
-
}
|
|
1651
|
-
if (e.key === "Enter") {
|
|
1652
|
-
e.preventDefault();
|
|
1653
|
-
runByIndex(hoverIndex);
|
|
1654
|
-
}
|
|
1655
|
-
}, [hide, groups, hoverIndex]);
|
|
1656
|
-
const onMouseEnter = useCallback((index) => {
|
|
1657
|
-
return (e) => {
|
|
1658
|
-
const prevPos = prevMousePosition.current;
|
|
1659
|
-
if (!prevPos)
|
|
1660
|
-
return;
|
|
1661
|
-
const { x, y } = e;
|
|
1662
|
-
if (x === prevPos.x && y === prevPos.y)
|
|
1663
|
-
return;
|
|
1664
|
-
onHover(index);
|
|
1665
|
-
};
|
|
1666
|
-
}, []);
|
|
1667
|
-
useEffect(() => {
|
|
1668
|
-
if (show)
|
|
1669
|
-
root.addEventListener("keydown", onKeydown, { capture: true });
|
|
1670
|
-
else root.removeEventListener("keydown", onKeydown, { capture: true });
|
|
1671
|
-
return () => {
|
|
1672
|
-
root.removeEventListener("keydown", onKeydown, { capture: true });
|
|
1673
|
-
};
|
|
1674
|
-
}, [show, onKeydown]);
|
|
1675
|
-
return html`
|
|
1676
|
-
<host onmousedown=${(e) => e.preventDefault()}>
|
|
1677
|
-
<nav class="tab-group">
|
|
1678
|
-
<ul>
|
|
1679
|
-
${groups.map((group) => html`<li
|
|
1680
|
-
key=${group.key}
|
|
1681
|
-
onmousedown=${() => onHover(group.range[0], scrollToIndex)}
|
|
1682
|
-
class=${hoverIndex >= group.range[0] && hoverIndex < group.range[1] ? "selected" : ""}
|
|
1683
|
-
>
|
|
1684
|
-
${group.label}
|
|
1685
|
-
</li>`)}
|
|
1686
|
-
</ul>
|
|
1687
|
-
</nav>
|
|
1688
|
-
<div class="menu-groups" onmousemove=${onMouseMove}>
|
|
1689
|
-
${groups.map((group) => {
|
|
1690
|
-
return html`
|
|
1691
|
-
<div key=${group.key} class="menu-group">
|
|
1692
|
-
<h6>${group.label}</h6>
|
|
1693
|
-
<ul>
|
|
1694
|
-
${group.items.map(
|
|
1695
|
-
(item) => html`<li
|
|
1696
|
-
key=${item.key}
|
|
1697
|
-
data-index=${item.index}
|
|
1698
|
-
class=${hoverIndex === item.index ? "hover" : ""}
|
|
1699
|
-
onmouseenter=${onMouseEnter(item.index)}
|
|
1700
|
-
onmousedown=${() => {
|
|
1701
|
-
var _a;
|
|
1702
|
-
(_a = host.current.querySelector(`[data-index="${item.index}"]`)) == null ? void 0 : _a.classList.add("active");
|
|
1703
|
-
}}
|
|
1704
|
-
onmouseup=${() => {
|
|
1705
|
-
var _a;
|
|
1706
|
-
(_a = host.current.querySelector(`[data-index="${item.index}"]`)) == null ? void 0 : _a.classList.remove("active");
|
|
1707
|
-
runByIndex(item.index);
|
|
1708
|
-
}}
|
|
1709
|
-
>
|
|
1710
|
-
${item.icon}
|
|
1711
|
-
<span>${item.label}</span>
|
|
1712
|
-
</li>`
|
|
1713
|
-
)}
|
|
1714
|
-
</ul>
|
|
1715
|
-
</div>
|
|
1716
|
-
`;
|
|
1717
|
-
})}
|
|
1718
|
-
</div>
|
|
1719
|
-
</host>
|
|
1720
|
-
`;
|
|
1721
|
-
};
|
|
1722
|
-
menuComponent.props = {
|
|
1723
|
-
ctx: Object,
|
|
1724
|
-
show: Boolean,
|
|
1725
|
-
filter: String,
|
|
1726
|
-
hide: Function
|
|
1727
|
-
};
|
|
1728
|
-
const MenuElement = c(menuComponent);
|
|
1729
|
-
|
|
1730
|
-
var __typeError$1 = (msg) => {
|
|
1731
|
-
throw TypeError(msg);
|
|
1732
|
-
};
|
|
1733
|
-
var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
|
|
1734
|
-
var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
1735
|
-
var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1736
|
-
var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
1737
|
-
var _content$1, _slashProvider, _programmaticallyPos;
|
|
1738
|
-
const menu = slashFactory("CREPE_MENU");
|
|
1739
|
-
const menuAPI = $ctx({
|
|
1740
|
-
show: () => {
|
|
1741
|
-
},
|
|
1742
|
-
hide: () => {
|
|
1743
|
-
}
|
|
1744
|
-
}, "menuAPICtx");
|
|
1745
|
-
defIfNotExists("milkdown-slash-menu", MenuElement);
|
|
1746
|
-
function configureMenu(ctx) {
|
|
1747
|
-
ctx.set(menu.key, {
|
|
1748
|
-
view: (view) => new MenuView(ctx, view)
|
|
1749
|
-
});
|
|
1750
|
-
}
|
|
1751
|
-
class MenuView {
|
|
1752
|
-
constructor(ctx, view) {
|
|
1753
|
-
__privateAdd$1(this, _content$1);
|
|
1754
|
-
__privateAdd$1(this, _slashProvider);
|
|
1755
|
-
__privateAdd$1(this, _programmaticallyPos, null);
|
|
1756
|
-
this.update = (view) => {
|
|
1757
|
-
__privateGet$1(this, _slashProvider).update(view);
|
|
1758
|
-
};
|
|
1759
|
-
this.show = (pos) => {
|
|
1760
|
-
__privateSet$1(this, _programmaticallyPos, pos);
|
|
1761
|
-
__privateGet$1(this, _content$1).filter = "";
|
|
1762
|
-
__privateGet$1(this, _slashProvider).show();
|
|
1763
|
-
};
|
|
1764
|
-
this.hide = () => {
|
|
1765
|
-
__privateSet$1(this, _programmaticallyPos, null);
|
|
1766
|
-
__privateGet$1(this, _slashProvider).hide();
|
|
1767
|
-
};
|
|
1768
|
-
this.destroy = () => {
|
|
1769
|
-
__privateGet$1(this, _slashProvider).destroy();
|
|
1770
|
-
__privateGet$1(this, _content$1).remove();
|
|
1771
|
-
};
|
|
1772
|
-
__privateSet$1(this, _content$1, new MenuElement());
|
|
1773
|
-
__privateGet$1(this, _content$1).hide = this.hide;
|
|
1774
|
-
__privateGet$1(this, _content$1).ctx = ctx;
|
|
1775
|
-
const self = this;
|
|
1776
|
-
__privateSet$1(this, _slashProvider, new SlashProvider({
|
|
1777
|
-
content: __privateGet$1(this, _content$1),
|
|
1778
|
-
debounce: 20,
|
|
1779
|
-
shouldShow(view2) {
|
|
1780
|
-
if (isInCodeBlock(view2.state.selection) || isInList(view2.state.selection))
|
|
1781
|
-
return false;
|
|
1782
|
-
const currentText = this.getContent(view2, (node) => ["paragraph", "heading"].includes(node.type.name));
|
|
1783
|
-
if (currentText == null)
|
|
1784
|
-
return false;
|
|
1785
|
-
const pos = __privateGet$1(self, _programmaticallyPos);
|
|
1786
|
-
__privateGet$1(self, _content$1).filter = currentText.startsWith("/") ? currentText.slice(1) : currentText;
|
|
1787
|
-
if (typeof pos === "number") {
|
|
1788
|
-
if (view2.state.doc.resolve(pos).node() !== view2.state.doc.resolve(view2.state.selection.from).node()) {
|
|
1789
|
-
__privateSet$1(self, _programmaticallyPos, null);
|
|
1790
|
-
return false;
|
|
1791
|
-
}
|
|
1792
|
-
return true;
|
|
1793
|
-
}
|
|
1794
|
-
if (!currentText.startsWith("/"))
|
|
1795
|
-
return false;
|
|
1796
|
-
return true;
|
|
1797
|
-
}
|
|
1798
|
-
}));
|
|
1799
|
-
__privateGet$1(this, _slashProvider).onShow = () => {
|
|
1800
|
-
__privateGet$1(this, _content$1).show = true;
|
|
1801
|
-
};
|
|
1802
|
-
__privateGet$1(this, _slashProvider).onHide = () => {
|
|
1803
|
-
__privateGet$1(this, _content$1).show = false;
|
|
1804
|
-
};
|
|
1805
|
-
this.update(view);
|
|
1806
|
-
ctx.set(menuAPI.key, {
|
|
1807
|
-
show: (pos) => this.show(pos),
|
|
1808
|
-
hide: () => this.hide()
|
|
1809
|
-
});
|
|
1810
|
-
}
|
|
1811
|
-
}
|
|
1812
|
-
_content$1 = new WeakMap();
|
|
1813
|
-
_slashProvider = new WeakMap();
|
|
1814
|
-
_programmaticallyPos = new WeakMap();
|
|
1815
|
-
|
|
1816
|
-
const menuIcon = html`
|
|
1817
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
1818
|
-
<g clip-path="url(#clip0_971_7680)">
|
|
1819
|
-
<path d="M11 18C11 19.1 10.1 20 9 20C7.9 20 7 19.1 7 18C7 16.9 7.9 16 9 16C10.1 16 11 16.9 11 18ZM9 10C7.9 10 7 10.9 7 12C7 13.1 7.9 14 9 14C10.1 14 11 13.1 11 12C11 10.9 10.1 10 9 10ZM9 4C7.9 4 7 4.9 7 6C7 7.1 7.9 8 9 8C10.1 8 11 7.1 11 6C11 4.9 10.1 4 9 4ZM15 8C16.1 8 17 7.1 17 6C17 4.9 16.1 4 15 4C13.9 4 13 4.9 13 6C13 7.1 13.9 8 15 8ZM15 10C13.9 10 13 10.9 13 12C13 13.1 13.9 14 15 14C16.1 14 17 13.1 17 12C17 10.9 16.1 10 15 10ZM15 16C13.9 16 13 16.9 13 18C13 19.1 13.9 20 15 20C16.1 20 17 19.1 17 18C17 16.9 16.1 16 15 16Z" fill="#817567"/>
|
|
1820
|
-
</g>
|
|
1821
|
-
<defs>
|
|
1822
|
-
<clipPath id="clip0_971_7680">
|
|
1823
|
-
<rect width="24" height="24" fill="white"/>
|
|
1824
|
-
</clipPath>
|
|
1825
|
-
</defs>
|
|
1826
|
-
</svg>
|
|
1827
|
-
`;
|
|
1828
|
-
const plusIcon = html`
|
|
1829
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
1830
|
-
<g clip-path="url(#clip0_971_7676)">
|
|
1831
|
-
<path d="M18 13H13V18C13 18.55 12.55 19 12 19C11.45 19 11 18.55 11 18V13H6C5.45 13 5 12.55 5 12C5 11.45 5.45 11 6 11H11V6C11 5.45 11.45 5 12 5C12.55 5 13 5.45 13 6V11H18C18.55 11 19 11.45 19 12C19 12.55 18.55 13 18 13Z" fill="#817567"/>
|
|
1832
|
-
</g>
|
|
1833
|
-
<defs>
|
|
1834
|
-
<clipPath id="clip0_971_7676">
|
|
1835
|
-
<rect width="24" height="24" fill="white"/>
|
|
1836
|
-
</clipPath>
|
|
1837
|
-
</defs>
|
|
1838
|
-
</svg>
|
|
1839
|
-
`;
|
|
1840
|
-
const blockHandleComponent = ({ onAdd }) => {
|
|
1841
|
-
const ref = useRef();
|
|
1842
|
-
useEffect(() => {
|
|
1843
|
-
var _a;
|
|
1844
|
-
(_a = ref.current) == null ? void 0 : _a.classList.remove("active");
|
|
1845
|
-
});
|
|
1846
|
-
const onMouseDown = (e) => {
|
|
1847
|
-
var _a;
|
|
1848
|
-
e.preventDefault();
|
|
1849
|
-
e.stopPropagation();
|
|
1850
|
-
(_a = ref.current) == null ? void 0 : _a.classList.add("active");
|
|
1851
|
-
};
|
|
1852
|
-
const onMouseUp = (e) => {
|
|
1853
|
-
var _a;
|
|
1854
|
-
e.preventDefault();
|
|
1855
|
-
e.stopPropagation();
|
|
1856
|
-
onAdd == null ? void 0 : onAdd();
|
|
1857
|
-
(_a = ref.current) == null ? void 0 : _a.classList.remove("active");
|
|
1858
|
-
};
|
|
1859
|
-
return html`
|
|
1860
|
-
<host>
|
|
1861
|
-
<div ref=${ref} onmousedown=${onMouseDown} onmouseup=${onMouseUp} class="operation-item">
|
|
1862
|
-
${plusIcon}
|
|
1863
|
-
</div>
|
|
1864
|
-
<div class="operation-item">
|
|
1865
|
-
${menuIcon}
|
|
1866
|
-
</div>
|
|
1867
|
-
</host>
|
|
1868
|
-
`;
|
|
1869
|
-
};
|
|
1870
|
-
blockHandleComponent.props = {
|
|
1871
|
-
show: Boolean,
|
|
1872
|
-
onAdd: Function
|
|
1873
|
-
};
|
|
1874
|
-
const BlockHandleElement = c(blockHandleComponent);
|
|
1875
|
-
|
|
1876
|
-
var __typeError = (msg) => {
|
|
1877
|
-
throw TypeError(msg);
|
|
1878
|
-
};
|
|
1879
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
1880
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
1881
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1882
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
1883
|
-
var _content, _provider, _ctx;
|
|
1884
|
-
class BlockHandleView {
|
|
1885
|
-
constructor(ctx) {
|
|
1886
|
-
__privateAdd(this, _content);
|
|
1887
|
-
__privateAdd(this, _provider);
|
|
1888
|
-
__privateAdd(this, _ctx);
|
|
1889
|
-
this.update = () => {
|
|
1890
|
-
__privateGet(this, _provider).update();
|
|
1891
|
-
};
|
|
1892
|
-
this.destroy = () => {
|
|
1893
|
-
__privateGet(this, _provider).destroy();
|
|
1894
|
-
__privateGet(this, _content).remove();
|
|
1895
|
-
};
|
|
1896
|
-
this.onAdd = () => {
|
|
1897
|
-
const ctx = __privateGet(this, _ctx);
|
|
1898
|
-
const view = ctx.get(editorViewCtx);
|
|
1899
|
-
if (!view.hasFocus())
|
|
1900
|
-
view.focus();
|
|
1901
|
-
const { state, dispatch } = view;
|
|
1902
|
-
const active = __privateGet(this, _provider).active;
|
|
1903
|
-
if (!active)
|
|
1904
|
-
return;
|
|
1905
|
-
const pos = active.$pos;
|
|
1906
|
-
const isNoneTextBlock = ["hr", "image-block"].includes(active.node.type.name);
|
|
1907
|
-
const nodeSize = isNoneTextBlock ? active.node.nodeSize : active.node.content.size;
|
|
1908
|
-
const side = pos.pos + nodeSize + (["blockquote"].includes(pos.parent.type.name) ? 1 : 0);
|
|
1909
|
-
const offset = ["blockquote"].includes(pos.parent.type.name) ? 1 : isNoneTextBlock ? 1 : 2;
|
|
1910
|
-
let tr = state.tr.insert(side, paragraphSchema.type(ctx).create());
|
|
1911
|
-
tr = tr.setSelection(TextSelection.create(tr.doc, side + offset));
|
|
1912
|
-
dispatch(tr.scrollIntoView());
|
|
1913
|
-
__privateGet(this, _provider).hide();
|
|
1914
|
-
ctx.get(menuAPI.key).show(tr.selection.from);
|
|
1915
|
-
};
|
|
1916
|
-
__privateSet(this, _ctx, ctx);
|
|
1917
|
-
const content = new BlockHandleElement();
|
|
1918
|
-
__privateSet(this, _content, content);
|
|
1919
|
-
__privateGet(this, _content).onAdd = this.onAdd;
|
|
1920
|
-
__privateSet(this, _provider, new BlockProvider({
|
|
1921
|
-
ctx,
|
|
1922
|
-
content,
|
|
1923
|
-
getOffset: () => 16,
|
|
1924
|
-
getPlacement: ({ active, blockDom }) => {
|
|
1925
|
-
let totalDescendant = 0;
|
|
1926
|
-
active.node.descendants((node) => {
|
|
1927
|
-
totalDescendant += node.childCount;
|
|
1928
|
-
});
|
|
1929
|
-
const dom = active.el;
|
|
1930
|
-
const domRect = dom.getBoundingClientRect();
|
|
1931
|
-
const handleRect = blockDom.getBoundingClientRect();
|
|
1932
|
-
const style = window.getComputedStyle(dom);
|
|
1933
|
-
const paddingTop = Number.parseInt(style.paddingTop, 10) || 0;
|
|
1934
|
-
const paddingBottom = Number.parseInt(style.paddingBottom, 10) || 0;
|
|
1935
|
-
const height = domRect.height - paddingTop - paddingBottom;
|
|
1936
|
-
const handleHeight = handleRect.height;
|
|
1937
|
-
return totalDescendant > 2 || handleHeight * 2 < height ? "left-start" : "left";
|
|
1938
|
-
}
|
|
1939
|
-
}));
|
|
1940
|
-
this.update();
|
|
1941
|
-
}
|
|
1942
|
-
}
|
|
1943
|
-
_content = new WeakMap();
|
|
1944
|
-
_provider = new WeakMap();
|
|
1945
|
-
_ctx = new WeakMap();
|
|
1946
|
-
defIfNotExists("milkdown-block-handle", BlockHandleElement);
|
|
1947
|
-
function configureBlockHandle(ctx) {
|
|
1948
|
-
ctx.set(block.key, {
|
|
1949
|
-
view: () => new BlockHandleView(ctx)
|
|
1950
|
-
});
|
|
1951
|
-
}
|
|
1952
|
-
|
|
1953
|
-
const defineFeature = (editor) => {
|
|
1954
|
-
editor.config(configureBlockHandle).config(configureMenu).use(menuAPI).use(block).use(menu);
|
|
1955
|
-
};
|
|
1956
|
-
|
|
1957
|
-
export { defineFeature };
|
|
1958
|
-
//# sourceMappingURL=index-h1arGiXv.js.map
|