@milkdown/crepe 7.8.0 → 7.9.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/confirm-CNveM9QH.js +26 -0
- package/lib/cjs/confirm-CNveM9QH.js.map +1 -0
- package/lib/cjs/edit-BUtBJHpV.js +24 -0
- package/lib/cjs/edit-BUtBJHpV.js.map +1 -0
- package/lib/cjs/functions-BAY51plB.js +39 -0
- package/lib/cjs/functions-BAY51plB.js.map +1 -0
- package/lib/cjs/image-BXLkOVnO.js +24 -0
- package/lib/cjs/image-BXLkOVnO.js.map +1 -0
- package/lib/cjs/{index-DAiGM2G1.js → index-B7gqgc1H.js} +484 -204
- package/lib/cjs/index-B7gqgc1H.js.map +1 -0
- package/lib/cjs/{index-Dub20F3z.js → index-B91KhPew.js} +4 -4
- package/lib/cjs/index-B91KhPew.js.map +1 -0
- package/lib/cjs/{index-nrFkJeLW.js → index-BsrJn8Jp.js} +22 -7
- package/lib/cjs/index-BsrJn8Jp.js.map +1 -0
- package/lib/cjs/{index-BReSN-JQ.js → index-C2CAbC2F.js} +2 -2
- package/lib/cjs/{index-BReSN-JQ.js.map → index-C2CAbC2F.js.map} +1 -1
- package/lib/cjs/{index-CGies6Iv.js → index-CnyNb_OH.js} +45 -45
- package/lib/cjs/index-CnyNb_OH.js.map +1 -0
- package/lib/cjs/{index-CJdEvN3_.js → index-CoTb-QdE.js} +123 -105
- package/lib/cjs/index-CoTb-QdE.js.map +1 -0
- package/lib/cjs/index-DEs_IHHy.js +91 -0
- package/lib/cjs/index-DEs_IHHy.js.map +1 -0
- package/lib/cjs/index-DGAwtnNK.js +349 -0
- package/lib/cjs/index-DGAwtnNK.js.map +1 -0
- package/lib/cjs/index-DLIudQKW.js +126 -0
- package/lib/cjs/index-DLIudQKW.js.map +1 -0
- package/lib/cjs/index-Dw6lXgs6.js +81 -0
- package/lib/cjs/index-Dw6lXgs6.js.map +1 -0
- package/lib/cjs/{index-AlHHvSR_.js → index-xbwf60wt.js} +1 -6
- package/lib/cjs/{index-AlHHvSR_.js.map → index-xbwf60wt.js.map} +1 -1
- package/lib/cjs/{index-CvmlYYXX.js → index-xbxqAqH2.js} +21 -7
- package/lib/cjs/index-xbxqAqH2.js.map +1 -0
- package/lib/cjs/index.js +6 -6
- package/lib/cjs/plus-XLomtlXf.js +24 -0
- package/lib/cjs/plus-XLomtlXf.js.map +1 -0
- package/lib/cjs/remove-Ba-ypwBf.js +17 -0
- package/lib/cjs/remove-Ba-ypwBf.js.map +1 -0
- package/lib/esm/confirm-DtE-HkVd.js +24 -0
- package/lib/esm/confirm-DtE-HkVd.js.map +1 -0
- package/lib/esm/edit-D--t_JAb.js +22 -0
- package/lib/esm/edit-D--t_JAb.js.map +1 -0
- package/lib/esm/functions-DlJPkGmE.js +36 -0
- package/lib/esm/functions-DlJPkGmE.js.map +1 -0
- package/lib/esm/image-DoB1o1sl.js +22 -0
- package/lib/esm/image-DoB1o1sl.js.map +1 -0
- package/lib/esm/index-BAQT-9au.js +347 -0
- package/lib/esm/index-BAQT-9au.js.map +1 -0
- package/lib/esm/{index-DOrkOhki.js → index-BCvtgOeI.js} +4 -4
- package/lib/esm/index-BCvtgOeI.js.map +1 -0
- package/lib/esm/{index-x2oo_GmY.js → index-BDZ_pnSv.js} +122 -104
- package/lib/esm/index-BDZ_pnSv.js.map +1 -0
- package/lib/esm/{index-D6fLMv29.js → index-BPG8iO8t.js} +2 -6
- package/lib/esm/{index-D6fLMv29.js.map → index-BPG8iO8t.js.map} +1 -1
- package/lib/esm/{index-DcRgwPLd.js → index-BUBXHhHG.js} +18 -3
- package/lib/esm/index-BUBXHhHG.js.map +1 -0
- package/lib/esm/{index-CsYl2WR5.js → index-Bvz1Yyiz.js} +2 -2
- package/lib/esm/{index-CsYl2WR5.js.map → index-Bvz1Yyiz.js.map} +1 -1
- package/lib/esm/index-C1aVAv1l.js +124 -0
- package/lib/esm/index-C1aVAv1l.js.map +1 -0
- package/lib/esm/{index-CEOsxgzJ.js → index-CM4urRY9.js} +470 -190
- package/lib/esm/index-CM4urRY9.js.map +1 -0
- package/lib/esm/{index-BFsG6770.js → index-ChR5Qhyf.js} +17 -3
- package/lib/esm/index-ChR5Qhyf.js.map +1 -0
- package/lib/esm/index-CwMVnVeI.js +89 -0
- package/lib/esm/index-CwMVnVeI.js.map +1 -0
- package/lib/esm/{index-BwTxn2hs.js → index-Dc_wWopW.js} +46 -46
- package/lib/esm/index-Dc_wWopW.js.map +1 -0
- package/lib/esm/index-E8UgFLeN.js +79 -0
- package/lib/esm/index-E8UgFLeN.js.map +1 -0
- package/lib/esm/index.js +6 -6
- package/lib/esm/plus-lrX0Q75O.js +22 -0
- package/lib/esm/plus-lrX0Q75O.js.map +1 -0
- package/lib/esm/remove-D3g0Cd6_.js +15 -0
- package/lib/esm/remove-D3g0Cd6_.js.map +1 -0
- package/lib/theme/_internal/classic-common.css +6 -0
- package/lib/theme/common/block-edit.css +23 -23
- package/lib/theme/common/code-mirror.css +43 -44
- package/lib/theme/common/image-block.css +79 -81
- package/lib/theme/common/latex.css +6 -6
- package/lib/theme/common/link-tooltip.css +21 -21
- package/lib/theme/common/list-item.css +11 -10
- package/lib/theme/common/table.css +39 -39
- package/lib/theme/common/toolbar.css +8 -8
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/core/crepe.d.ts +6 -6
- package/lib/types/core/crepe.d.ts.map +1 -1
- package/lib/types/core/slice.d.ts.map +1 -1
- package/lib/types/feature/block-edit/handle/component.d.ts +4 -8
- package/lib/types/feature/block-edit/handle/component.d.ts.map +1 -1
- package/lib/types/feature/block-edit/handle/index.d.ts +1 -1
- package/lib/types/feature/block-edit/handle/index.d.ts.map +1 -1
- package/lib/types/feature/block-edit/index.d.ts.map +1 -1
- package/lib/types/feature/block-edit/menu/component.d.ts +8 -11
- package/lib/types/feature/block-edit/menu/component.d.ts.map +1 -1
- package/lib/types/feature/block-edit/menu/config.d.ts.map +1 -1
- package/lib/types/feature/block-edit/menu/index.d.ts.map +1 -1
- package/lib/types/feature/block-edit/menu/utils.d.ts +2 -3
- package/lib/types/feature/block-edit/menu/utils.d.ts.map +1 -1
- package/lib/types/feature/code-mirror/index.d.ts +3 -4
- package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
- package/lib/types/feature/cursor/index.d.ts.map +1 -1
- package/lib/types/feature/image-block/index.d.ts.map +1 -1
- package/lib/types/feature/index.d.ts +4 -4
- package/lib/types/feature/index.d.ts.map +1 -1
- package/lib/types/feature/latex/index.d.ts.map +1 -1
- package/lib/types/feature/latex/inline-tooltip/component.d.ts +6 -10
- package/lib/types/feature/latex/inline-tooltip/component.d.ts.map +1 -1
- package/lib/types/feature/latex/inline-tooltip/view.d.ts.map +1 -1
- package/lib/types/feature/latex/input-rule.d.ts.map +1 -1
- package/lib/types/feature/latex/remark.d.ts.map +1 -1
- package/lib/types/feature/link-tooltip/index.d.ts.map +1 -1
- package/lib/types/feature/list-item/index.d.ts.map +1 -1
- package/lib/types/feature/placeholder/index.d.ts.map +1 -1
- package/lib/types/feature/shared.d.ts +1 -2
- package/lib/types/feature/shared.d.ts.map +1 -1
- package/lib/types/feature/table/index.d.ts.map +1 -1
- package/lib/types/feature/toolbar/component.d.ts +9 -12
- package/lib/types/feature/toolbar/component.d.ts.map +1 -1
- package/lib/types/feature/toolbar/index.d.ts.map +1 -1
- package/lib/types/icons/align-center.d.ts +1 -1
- package/lib/types/icons/align-center.d.ts.map +1 -1
- package/lib/types/icons/align-left.d.ts +1 -1
- package/lib/types/icons/align-left.d.ts.map +1 -1
- package/lib/types/icons/align-right.d.ts +1 -1
- package/lib/types/icons/align-right.d.ts.map +1 -1
- package/lib/types/icons/bold.d.ts +1 -1
- package/lib/types/icons/bold.d.ts.map +1 -1
- package/lib/types/icons/bullet-list.d.ts +1 -1
- package/lib/types/icons/bullet-list.d.ts.map +1 -1
- package/lib/types/icons/bullet.d.ts +1 -1
- package/lib/types/icons/bullet.d.ts.map +1 -1
- package/lib/types/icons/caption.d.ts +1 -1
- package/lib/types/icons/caption.d.ts.map +1 -1
- package/lib/types/icons/check-box-checked.d.ts +1 -1
- package/lib/types/icons/check-box-checked.d.ts.map +1 -1
- package/lib/types/icons/check-box-unchecked.d.ts +1 -1
- package/lib/types/icons/check-box-unchecked.d.ts.map +1 -1
- package/lib/types/icons/chevron-down.d.ts +1 -1
- package/lib/types/icons/chevron-down.d.ts.map +1 -1
- package/lib/types/icons/clear.d.ts +1 -1
- package/lib/types/icons/clear.d.ts.map +1 -1
- package/lib/types/icons/code.d.ts +1 -1
- package/lib/types/icons/code.d.ts.map +1 -1
- package/lib/types/icons/confirm.d.ts +1 -1
- package/lib/types/icons/confirm.d.ts.map +1 -1
- package/lib/types/icons/copy.d.ts +1 -1
- package/lib/types/icons/copy.d.ts.map +1 -1
- package/lib/types/icons/divider.d.ts +1 -1
- package/lib/types/icons/divider.d.ts.map +1 -1
- package/lib/types/icons/drag-handle.d.ts +1 -1
- package/lib/types/icons/drag-handle.d.ts.map +1 -1
- package/lib/types/icons/edit.d.ts +1 -1
- package/lib/types/icons/edit.d.ts.map +1 -1
- package/lib/types/icons/functions.d.ts +1 -1
- package/lib/types/icons/functions.d.ts.map +1 -1
- package/lib/types/icons/h1.d.ts +1 -1
- package/lib/types/icons/h1.d.ts.map +1 -1
- package/lib/types/icons/h2.d.ts +1 -1
- package/lib/types/icons/h2.d.ts.map +1 -1
- package/lib/types/icons/h3.d.ts +1 -1
- package/lib/types/icons/h3.d.ts.map +1 -1
- package/lib/types/icons/h4.d.ts +1 -1
- package/lib/types/icons/h4.d.ts.map +1 -1
- package/lib/types/icons/h5.d.ts +1 -1
- package/lib/types/icons/h5.d.ts.map +1 -1
- package/lib/types/icons/h6.d.ts +1 -1
- package/lib/types/icons/h6.d.ts.map +1 -1
- package/lib/types/icons/image.d.ts +1 -1
- package/lib/types/icons/image.d.ts.map +1 -1
- package/lib/types/icons/italic.d.ts +1 -1
- package/lib/types/icons/italic.d.ts.map +1 -1
- package/lib/types/icons/link.d.ts +1 -1
- package/lib/types/icons/link.d.ts.map +1 -1
- package/lib/types/icons/menu.d.ts +1 -1
- package/lib/types/icons/menu.d.ts.map +1 -1
- package/lib/types/icons/ordered-list.d.ts +1 -1
- package/lib/types/icons/ordered-list.d.ts.map +1 -1
- package/lib/types/icons/plus.d.ts +1 -1
- package/lib/types/icons/plus.d.ts.map +1 -1
- package/lib/types/icons/quote.d.ts +1 -1
- package/lib/types/icons/quote.d.ts.map +1 -1
- package/lib/types/icons/remove.d.ts +1 -1
- package/lib/types/icons/remove.d.ts.map +1 -1
- package/lib/types/icons/search.d.ts +1 -1
- package/lib/types/icons/search.d.ts.map +1 -1
- package/lib/types/icons/strikethrough.d.ts +1 -1
- package/lib/types/icons/strikethrough.d.ts.map +1 -1
- package/lib/types/icons/table.d.ts +1 -1
- package/lib/types/icons/table.d.ts.map +1 -1
- package/lib/types/icons/text.d.ts +1 -1
- package/lib/types/icons/text.d.ts.map +1 -1
- package/lib/types/icons/todo-list.d.ts +1 -1
- package/lib/types/icons/todo-list.d.ts.map +1 -1
- package/lib/types/icons/visibility-off.d.ts +1 -1
- package/lib/types/icons/visibility-off.d.ts.map +1 -1
- package/package.json +4 -26
- package/src/core/crepe.ts +13 -12
- package/src/core/slice.ts +2 -0
- package/src/feature/block-edit/handle/component.tsx +60 -0
- package/src/feature/block-edit/handle/index.ts +22 -14
- package/src/feature/block-edit/index.ts +3 -1
- package/src/feature/block-edit/menu/component.tsx +237 -0
- package/src/feature/block-edit/menu/config.ts +6 -3
- package/src/feature/block-edit/menu/index.ts +38 -18
- package/src/feature/block-edit/menu/utils.ts +3 -3
- package/src/feature/code-mirror/index.ts +20 -20
- package/src/feature/cursor/index.ts +1 -1
- package/src/feature/image-block/index.ts +3 -1
- package/src/feature/index.ts +5 -4
- package/src/feature/latex/index.ts +8 -8
- package/src/feature/latex/inline-tooltip/component.tsx +57 -0
- package/src/feature/latex/inline-tooltip/view.ts +30 -17
- package/src/feature/latex/input-rule.ts +4 -3
- package/src/feature/latex/remark.ts +3 -2
- package/src/feature/link-tooltip/index.ts +3 -1
- package/src/feature/list-item/index.ts +8 -16
- package/src/feature/placeholder/index.ts +6 -3
- package/src/feature/shared.ts +1 -2
- package/src/feature/table/index.ts +2 -0
- package/src/feature/toolbar/component.tsx +256 -0
- package/src/feature/toolbar/index.ts +34 -17
- package/src/icons/align-center.ts +1 -3
- package/src/icons/align-left.ts +1 -3
- package/src/icons/align-right.ts +1 -3
- package/src/icons/bold.ts +1 -3
- package/src/icons/bullet-list.ts +1 -3
- package/src/icons/bullet.ts +1 -3
- package/src/icons/caption.ts +1 -3
- package/src/icons/check-box-checked.ts +1 -3
- package/src/icons/check-box-unchecked.ts +1 -3
- package/src/icons/chevron-down.ts +1 -3
- package/src/icons/clear.ts +1 -3
- package/src/icons/code.ts +1 -3
- package/src/icons/confirm.ts +1 -3
- package/src/icons/copy.ts +1 -3
- package/src/icons/divider.ts +1 -3
- package/src/icons/drag-handle.ts +1 -3
- package/src/icons/edit.ts +1 -3
- package/src/icons/functions.ts +1 -3
- package/src/icons/h1.ts +1 -3
- package/src/icons/h2.ts +1 -3
- package/src/icons/h3.ts +1 -3
- package/src/icons/h4.ts +1 -3
- package/src/icons/h5.ts +1 -3
- package/src/icons/h6.ts +1 -3
- package/src/icons/image.ts +1 -3
- package/src/icons/italic.ts +1 -3
- package/src/icons/link.ts +1 -3
- package/src/icons/menu.ts +1 -3
- package/src/icons/ordered-list.ts +1 -3
- package/src/icons/plus.ts +1 -3
- package/src/icons/quote.ts +1 -3
- package/src/icons/remove.ts +1 -3
- package/src/icons/search.ts +1 -3
- package/src/icons/strikethrough.ts +1 -3
- package/src/icons/table.ts +1 -3
- package/src/icons/text.ts +1 -3
- package/src/icons/todo-list.ts +1 -3
- package/src/icons/visibility-off.ts +1 -3
- package/src/theme/_internal/classic-common.css +6 -0
- package/src/theme/common/block-edit.css +2 -2
- package/src/theme/common/code-mirror.css +5 -6
- package/src/theme/common/image-block.css +9 -11
- package/src/theme/common/latex.css +1 -1
- package/src/theme/common/link-tooltip.css +2 -2
- package/src/theme/common/list-item.css +3 -2
- package/src/theme/common/table.css +2 -2
- package/src/theme/common/toolbar.css +1 -1
- package/lib/cjs/functions-Dk90yOUc.js +0 -690
- package/lib/cjs/functions-Dk90yOUc.js.map +0 -1
- package/lib/cjs/index-CGies6Iv.js.map +0 -1
- package/lib/cjs/index-CJdEvN3_.js.map +0 -1
- package/lib/cjs/index-CvmlYYXX.js.map +0 -1
- package/lib/cjs/index-D3lu92SA.js +0 -39
- package/lib/cjs/index-D3lu92SA.js.map +0 -1
- package/lib/cjs/index-DAiGM2G1.js.map +0 -1
- package/lib/cjs/index-DKY_Kri2.js +0 -272
- package/lib/cjs/index-DKY_Kri2.js.map +0 -1
- package/lib/cjs/index-DQll67YS.js +0 -65
- package/lib/cjs/index-DQll67YS.js.map +0 -1
- package/lib/cjs/index-Dub20F3z.js.map +0 -1
- package/lib/cjs/index-hPk2gbSt.js +0 -35
- package/lib/cjs/index-hPk2gbSt.js.map +0 -1
- package/lib/cjs/index-nrFkJeLW.js.map +0 -1
- package/lib/esm/functions-Bsik6ikd.js +0 -652
- package/lib/esm/functions-Bsik6ikd.js.map +0 -1
- package/lib/esm/index-B3KiKTSt.js +0 -63
- package/lib/esm/index-B3KiKTSt.js.map +0 -1
- package/lib/esm/index-BFsG6770.js.map +0 -1
- package/lib/esm/index-BwTxn2hs.js.map +0 -1
- package/lib/esm/index-CBrOT1fW.js +0 -37
- package/lib/esm/index-CBrOT1fW.js.map +0 -1
- package/lib/esm/index-CEOsxgzJ.js.map +0 -1
- package/lib/esm/index-Cuk7cL-r.js +0 -33
- package/lib/esm/index-Cuk7cL-r.js.map +0 -1
- package/lib/esm/index-DOrkOhki.js.map +0 -1
- package/lib/esm/index-DcRgwPLd.js.map +0 -1
- package/lib/esm/index-H9uklzH0.js +0 -270
- package/lib/esm/index-H9uklzH0.js.map +0 -1
- package/lib/esm/index-x2oo_GmY.js.map +0 -1
- package/src/feature/block-edit/handle/component.ts +0 -54
- package/src/feature/block-edit/menu/component.ts +0 -241
- package/src/feature/latex/inline-tooltip/component.ts +0 -38
- package/src/feature/toolbar/component.ts +0 -236
|
@@ -9,12 +9,7 @@ function isInList(selection) {
|
|
|
9
9
|
const type = (_a = selection.$from.node(selection.$from.depth - 1)) == null ? void 0 : _a.type;
|
|
10
10
|
return (type == null ? void 0 : type.name) === "list_item";
|
|
11
11
|
}
|
|
12
|
-
function defIfNotExists(tagName, element) {
|
|
13
|
-
if (customElements.get(tagName) == null)
|
|
14
|
-
customElements.define(tagName, element);
|
|
15
|
-
}
|
|
16
12
|
|
|
17
|
-
exports.defIfNotExists = defIfNotExists;
|
|
18
13
|
exports.isInCodeBlock = isInCodeBlock;
|
|
19
14
|
exports.isInList = isInList;
|
|
20
|
-
//# sourceMappingURL=index-
|
|
15
|
+
//# sourceMappingURL=index-xbwf60wt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-xbwf60wt.js","sources":["../../src/utils/index.ts"],"sourcesContent":["import type { Selection } from '@milkdown/kit/prose/state'\n\nexport function isInCodeBlock(selection: Selection) {\n const type = selection.$from.parent.type\n return type.name === 'code_block'\n}\n\nexport function isInList(selection: Selection) {\n const type = selection.$from.node(selection.$from.depth - 1)?.type\n return type?.name === 'list_item'\n}\n\nexport function defIfNotExists(\n tagName: string,\n element: CustomElementConstructor\n) {\n if (customElements.get(tagName) == null)\n customElements.define(tagName, element)\n}\n"],"names":[],"mappings":";;AAEO,SAAS,cAAc,SAAsB,EAAA;AAClD,EAAM,MAAA,IAAA,GAAO,SAAU,CAAA,KAAA,CAAM,MAAO,CAAA,IAAA;AACpC,EAAA,OAAO,KAAK,IAAS,KAAA,YAAA;AACvB;AAEO,SAAS,SAAS,SAAsB,EAAA;AAP/C,EAAA,IAAA,EAAA;AAQE,EAAM,MAAA,IAAA,GAAA,CAAO,eAAU,KAAM,CAAA,IAAA,CAAK,UAAU,KAAM,CAAA,KAAA,GAAQ,CAAC,CAAA,KAA9C,IAAiD,GAAA,MAAA,GAAA,EAAA,CAAA,IAAA;AAC9D,EAAA,OAAA,CAAO,6BAAM,IAAS,MAAA,WAAA;AACxB;;;;;"}
|
|
@@ -2,8 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
var imageBlock = require('@milkdown/kit/component/image-block');
|
|
4
4
|
var imageInline = require('@milkdown/kit/component/image-inline');
|
|
5
|
-
var
|
|
6
|
-
require('
|
|
5
|
+
var confirm = require('./confirm-CNveM9QH.js');
|
|
6
|
+
var image = require('./image-BXLkOVnO.js');
|
|
7
|
+
|
|
8
|
+
const captionIcon = `
|
|
9
|
+
<svg
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
width="32"
|
|
12
|
+
height="32"
|
|
13
|
+
viewBox="0 0 24 24"
|
|
14
|
+
>
|
|
15
|
+
<path
|
|
16
|
+
fill="currentColor"
|
|
17
|
+
d="M9 22a1 1 0 0 1-1-1v-3H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6.1l-3.7 3.71c-.2.19-.45.29-.7.29zm1-6v3.08L13.08 16H20V4H4v12z"
|
|
18
|
+
/>
|
|
19
|
+
</svg>
|
|
20
|
+
`;
|
|
7
21
|
|
|
8
22
|
const defineFeature = (editor, config) => {
|
|
9
23
|
editor.config((ctx) => {
|
|
@@ -11,8 +25,8 @@ const defineFeature = (editor, config) => {
|
|
|
11
25
|
var _a, _b, _c, _d, _e, _f;
|
|
12
26
|
return {
|
|
13
27
|
uploadButton: (_a = config == null ? void 0 : config.inlineUploadButton) != null ? _a : () => "Upload",
|
|
14
|
-
imageIcon: (_b = config == null ? void 0 : config.inlineImageIcon) != null ? _b : () =>
|
|
15
|
-
confirmButton: (_c = config == null ? void 0 : config.inlineConfirmButton) != null ? _c : () =>
|
|
28
|
+
imageIcon: (_b = config == null ? void 0 : config.inlineImageIcon) != null ? _b : () => image.imageIcon,
|
|
29
|
+
confirmButton: (_c = config == null ? void 0 : config.inlineConfirmButton) != null ? _c : () => confirm.confirmIcon,
|
|
16
30
|
uploadPlaceholderText: (_d = config == null ? void 0 : config.inlineUploadPlaceholderText) != null ? _d : "or paste link",
|
|
17
31
|
onUpload: (_f = (_e = config == null ? void 0 : config.inlineOnUpload) != null ? _e : config == null ? void 0 : config.onUpload) != null ? _f : value.onUpload,
|
|
18
32
|
proxyDomURL: config == null ? void 0 : config.proxyDomURL
|
|
@@ -22,8 +36,8 @@ const defineFeature = (editor, config) => {
|
|
|
22
36
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
23
37
|
return {
|
|
24
38
|
uploadButton: (_a = config == null ? void 0 : config.blockUploadButton) != null ? _a : () => "Upload file",
|
|
25
|
-
imageIcon: (_b = config == null ? void 0 : config.blockImageIcon) != null ? _b : () =>
|
|
26
|
-
captionIcon: (_c = config == null ? void 0 : config.blockCaptionIcon) != null ? _c : () =>
|
|
39
|
+
imageIcon: (_b = config == null ? void 0 : config.blockImageIcon) != null ? _b : () => image.imageIcon,
|
|
40
|
+
captionIcon: (_c = config == null ? void 0 : config.blockCaptionIcon) != null ? _c : () => captionIcon,
|
|
27
41
|
confirmButton: (_d = config == null ? void 0 : config.blockConfirmButton) != null ? _d : () => "Confirm",
|
|
28
42
|
captionPlaceholderText: (_e = config == null ? void 0 : config.blockCaptionPlaceholderText) != null ? _e : "Write Image Caption",
|
|
29
43
|
uploadPlaceholderText: (_f = config == null ? void 0 : config.blockUploadPlaceholderText) != null ? _f : "or paste link",
|
|
@@ -35,4 +49,4 @@ const defineFeature = (editor, config) => {
|
|
|
35
49
|
};
|
|
36
50
|
|
|
37
51
|
exports.defineFeature = defineFeature;
|
|
38
|
-
//# sourceMappingURL=index-
|
|
52
|
+
//# sourceMappingURL=index-xbxqAqH2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-xbxqAqH2.js","sources":["../../src/icons/caption.ts","../../src/feature/image-block/index.ts"],"sourcesContent":["export const captionIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"32\"\n height=\"32\"\n viewBox=\"0 0 24 24\"\n >\n <path\n fill=\"currentColor\"\n d=\"M9 22a1 1 0 0 1-1-1v-3H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6.1l-3.7 3.71c-.2.19-.45.29-.7.29zm1-6v3.08L13.08 16H20V4H4v12z\"\n />\n </svg>\n`\n","import {\n imageBlockComponent,\n imageBlockConfig,\n} from '@milkdown/kit/component/image-block'\nimport {\n imageInlineComponent,\n inlineImageConfig,\n} from '@milkdown/kit/component/image-inline'\n\nimport type { DefineFeature, Icon } from '../shared'\n\nimport { captionIcon, imageIcon, confirmIcon } from '../../icons'\n\ninterface ImageBlockConfig {\n onUpload: (file: File) => Promise<string>\n proxyDomURL: (url: string) => Promise<string> | string\n\n inlineImageIcon: Icon\n inlineConfirmButton: Icon\n inlineUploadButton: Icon\n inlineUploadPlaceholderText: string\n inlineOnUpload: (file: File) => Promise<string>\n\n blockImageIcon: Icon\n blockConfirmButton: Icon\n blockCaptionIcon: Icon\n blockUploadButton: Icon\n blockCaptionPlaceholderText: string\n blockUploadPlaceholderText: string\n blockOnUpload: (file: File) => Promise<string>\n}\n\nexport type ImageBlockFeatureConfig = Partial<ImageBlockConfig>\n\nexport const defineFeature: DefineFeature<ImageBlockFeatureConfig> = (\n editor,\n config\n) => {\n editor\n .config((ctx) => {\n ctx.update(inlineImageConfig.key, (value) => ({\n uploadButton: config?.inlineUploadButton ?? (() => 'Upload'),\n imageIcon: config?.inlineImageIcon ?? (() => imageIcon),\n confirmButton: config?.inlineConfirmButton ?? (() => confirmIcon),\n uploadPlaceholderText:\n config?.inlineUploadPlaceholderText ?? 'or paste link',\n onUpload: config?.inlineOnUpload ?? config?.onUpload ?? value.onUpload,\n proxyDomURL: config?.proxyDomURL,\n }))\n ctx.update(imageBlockConfig.key, (value) => ({\n uploadButton: config?.blockUploadButton ?? (() => 'Upload file'),\n imageIcon: config?.blockImageIcon ?? (() => imageIcon),\n captionIcon: config?.blockCaptionIcon ?? (() => captionIcon),\n confirmButton: config?.blockConfirmButton ?? (() => 'Confirm'),\n captionPlaceholderText:\n config?.blockCaptionPlaceholderText ?? 'Write Image Caption',\n uploadPlaceholderText:\n config?.blockUploadPlaceholderText ?? 'or paste link',\n onUpload: config?.blockOnUpload ?? config?.onUpload ?? value.onUpload,\n proxyDomURL: config?.proxyDomURL,\n }))\n })\n .use(imageBlockComponent)\n .use(imageInlineComponent)\n}\n"],"names":["inlineImageConfig","imageIcon","confirmIcon","imageBlockConfig","imageBlockComponent","imageInlineComponent"],"mappings":";;;;;;;AAAO,MAAM,WAAc,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;ACkCd,MAAA,aAAA,GAAwD,CACnE,MAAA,EACA,MACG,KAAA;AACH,EACG,MAAA,CAAA,MAAA,CAAO,CAAC,GAAQ,KAAA;AACf,IAAA,GAAA,CAAI,MAAO,CAAAA,6BAAA,CAAkB,GAAK,EAAA,CAAC,KAAO,KAAA;AAxChD,MAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA;AAwCoD,MAAA,OAAA;AAAA,QAC5C,YAAc,EAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,kBAAR,KAAA,IAAA,GAAA,EAAA,GAA+B,MAAM,QAAA;AAAA,QACnD,SAAW,EAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,eAAR,KAAA,IAAA,GAAA,EAAA,GAA4B,MAAMC,eAAA;AAAA,QAC7C,aAAe,EAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,mBAAR,KAAA,IAAA,GAAA,EAAA,GAAgC,MAAMC,mBAAA;AAAA,QACrD,qBAAA,EAAA,CACE,EAAQ,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA,2BAAA,KAAR,IAAuC,GAAA,EAAA,GAAA,eAAA;AAAA,QACzC,WAAU,EAAQ,GAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA,cAAA,KAAR,YAA0B,MAAQ,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA,QAAA,KAAlC,YAA8C,KAAM,CAAA,QAAA;AAAA,QAC9D,aAAa,MAAQ,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA;AAAA,OACvB;AAAA,KAAE,CAAA;AACF,IAAA,GAAA,CAAI,MAAO,CAAAC,2BAAA,CAAiB,GAAK,EAAA,CAAC,KAAO,KAAA;AAjD/C,MAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA;AAiDmD,MAAA,OAAA;AAAA,QAC3C,YAAc,EAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,iBAAR,KAAA,IAAA,GAAA,EAAA,GAA8B,MAAM,aAAA;AAAA,QAClD,SAAW,EAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,cAAR,KAAA,IAAA,GAAA,EAAA,GAA2B,MAAMF,eAAA;AAAA,QAC5C,WAAa,EAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,gBAAR,KAAA,IAAA,GAAA,EAAA,GAA6B,MAAM,WAAA;AAAA,QAChD,aAAe,EAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAQ,kBAAR,KAAA,IAAA,GAAA,EAAA,GAA+B,MAAM,SAAA;AAAA,QACpD,sBAAA,EAAA,CACE,EAAQ,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA,2BAAA,KAAR,IAAuC,GAAA,EAAA,GAAA,qBAAA;AAAA,QACzC,qBAAA,EAAA,CACE,EAAQ,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA,0BAAA,KAAR,IAAsC,GAAA,EAAA,GAAA,eAAA;AAAA,QACxC,WAAU,EAAQ,GAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA,aAAA,KAAR,YAAyB,MAAQ,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA,QAAA,KAAjC,YAA6C,KAAM,CAAA,QAAA;AAAA,QAC7D,aAAa,MAAQ,IAAA,IAAA,GAAA,MAAA,GAAA,MAAA,CAAA;AAAA,OACvB;AAAA,KAAE,CAAA;AAAA,GACH,CACA,CAAA,GAAA,CAAIG,8BAAmB,CAAA,CACvB,IAAIC,gCAAoB,CAAA;AAC7B;;;;"}
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-CnyNb_OH.js');
|
|
4
4
|
require('@milkdown/kit/core');
|
|
5
|
-
require('@milkdown/kit/
|
|
6
|
-
require('@milkdown/kit/preset/gfm');
|
|
5
|
+
require('@milkdown/kit/plugin/clipboard');
|
|
7
6
|
require('@milkdown/kit/plugin/history');
|
|
8
7
|
require('@milkdown/kit/plugin/indent');
|
|
9
|
-
require('@milkdown/kit/
|
|
10
|
-
require('@milkdown/kit/plugin/clipboard');
|
|
8
|
+
require('@milkdown/kit/plugin/listener');
|
|
11
9
|
require('@milkdown/kit/plugin/trailing');
|
|
10
|
+
require('@milkdown/kit/preset/commonmark');
|
|
11
|
+
require('@milkdown/kit/preset/gfm');
|
|
12
|
+
require('@milkdown/kit/utils');
|
|
12
13
|
require('@milkdown/kit/ctx');
|
|
13
|
-
require('@milkdown/kit/plugin/listener');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const plusIcon = `
|
|
4
|
+
<svg
|
|
5
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
6
|
+
width="24"
|
|
7
|
+
height="24"
|
|
8
|
+
viewBox="0 0 24 24"
|
|
9
|
+
>
|
|
10
|
+
<g clip-path="url(#clip0_971_7676)">
|
|
11
|
+
<path
|
|
12
|
+
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"
|
|
13
|
+
/>
|
|
14
|
+
</g>
|
|
15
|
+
<defs>
|
|
16
|
+
<clipPath id="clip0_971_7676">
|
|
17
|
+
<rect width="24" height="24" />
|
|
18
|
+
</clipPath>
|
|
19
|
+
</defs>
|
|
20
|
+
</svg>
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
exports.plusIcon = plusIcon;
|
|
24
|
+
//# sourceMappingURL=plus-XLomtlXf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plus-XLomtlXf.js","sources":["../../src/icons/plus.ts"],"sourcesContent":["export const plusIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <g clip-path=\"url(#clip0_971_7676)\">\n <path\n 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\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_971_7676\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n"],"names":[],"mappings":";;AAAO,MAAM,QAAW,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const removeIcon = `
|
|
4
|
+
<svg
|
|
5
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
6
|
+
width="24"
|
|
7
|
+
height="24"
|
|
8
|
+
viewBox="0 0 24 24"
|
|
9
|
+
>
|
|
10
|
+
<path
|
|
11
|
+
d="M7.30775 20.4997C6.81058 20.4997 6.385 20.3227 6.031 19.9687C5.677 19.6147 5.5 19.1892 5.5 18.692V5.99973H5.25C5.0375 5.99973 4.85942 5.92782 4.71575 5.78398C4.57192 5.64015 4.5 5.46198 4.5 5.24948C4.5 5.03682 4.57192 4.85873 4.71575 4.71523C4.85942 4.57157 5.0375 4.49973 5.25 4.49973H9C9 4.2549 9.08625 4.04624 9.25875 3.87374C9.43108 3.7014 9.63967 3.61523 9.8845 3.61523H14.1155C14.3603 3.61523 14.5689 3.7014 14.7413 3.87374C14.9138 4.04624 15 4.2549 15 4.49973H18.75C18.9625 4.49973 19.1406 4.57165 19.2843 4.71548C19.4281 4.85932 19.5 5.03748 19.5 5.24998C19.5 5.46265 19.4281 5.64073 19.2843 5.78423C19.1406 5.9279 18.9625 5.99973 18.75 5.99973H18.5V18.692C18.5 19.1892 18.323 19.6147 17.969 19.9687C17.615 20.3227 17.1894 20.4997 16.6923 20.4997H7.30775ZM17 5.99973H7V18.692C7 18.7818 7.02883 18.8556 7.0865 18.9132C7.14417 18.9709 7.21792 18.9997 7.30775 18.9997H16.6923C16.7821 18.9997 16.8558 18.9709 16.9135 18.9132C16.9712 18.8556 17 18.7818 17 18.692V5.99973ZM10.1543 16.9997C10.3668 16.9997 10.5448 16.9279 10.6885 16.7842C10.832 16.6404 10.9037 16.4622 10.9037 16.2497V8.74973C10.9037 8.53723 10.8318 8.35907 10.688 8.21523C10.5443 8.07157 10.3662 7.99973 10.1535 7.99973C9.941 7.99973 9.76292 8.07157 9.61925 8.21523C9.47575 8.35907 9.404 8.53723 9.404 8.74973V16.2497C9.404 16.4622 9.47583 16.6404 9.6195 16.7842C9.76333 16.9279 9.94158 16.9997 10.1543 16.9997ZM13.8465 16.9997C14.059 16.9997 14.2371 16.9279 14.3807 16.7842C14.5243 16.6404 14.596 16.4622 14.596 16.2497V8.74973C14.596 8.53723 14.5242 8.35907 14.3805 8.21523C14.2367 8.07157 14.0584 7.99973 13.8458 7.99973C13.6333 7.99973 13.4552 8.07157 13.3115 8.21523C13.168 8.35907 13.0962 8.53723 13.0962 8.74973V16.2497C13.0962 16.4622 13.1682 16.6404 13.312 16.7842C13.4557 16.9279 13.6338 16.9997 13.8465 16.9997Z"
|
|
12
|
+
/>
|
|
13
|
+
</svg>
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
exports.removeIcon = removeIcon;
|
|
17
|
+
//# sourceMappingURL=remove-Ba-ypwBf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-Ba-ypwBf.js","sources":["../../src/icons/remove.ts"],"sourcesContent":["export const removeIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <path\n d=\"M7.30775 20.4997C6.81058 20.4997 6.385 20.3227 6.031 19.9687C5.677 19.6147 5.5 19.1892 5.5 18.692V5.99973H5.25C5.0375 5.99973 4.85942 5.92782 4.71575 5.78398C4.57192 5.64015 4.5 5.46198 4.5 5.24948C4.5 5.03682 4.57192 4.85873 4.71575 4.71523C4.85942 4.57157 5.0375 4.49973 5.25 4.49973H9C9 4.2549 9.08625 4.04624 9.25875 3.87374C9.43108 3.7014 9.63967 3.61523 9.8845 3.61523H14.1155C14.3603 3.61523 14.5689 3.7014 14.7413 3.87374C14.9138 4.04624 15 4.2549 15 4.49973H18.75C18.9625 4.49973 19.1406 4.57165 19.2843 4.71548C19.4281 4.85932 19.5 5.03748 19.5 5.24998C19.5 5.46265 19.4281 5.64073 19.2843 5.78423C19.1406 5.9279 18.9625 5.99973 18.75 5.99973H18.5V18.692C18.5 19.1892 18.323 19.6147 17.969 19.9687C17.615 20.3227 17.1894 20.4997 16.6923 20.4997H7.30775ZM17 5.99973H7V18.692C7 18.7818 7.02883 18.8556 7.0865 18.9132C7.14417 18.9709 7.21792 18.9997 7.30775 18.9997H16.6923C16.7821 18.9997 16.8558 18.9709 16.9135 18.9132C16.9712 18.8556 17 18.7818 17 18.692V5.99973ZM10.1543 16.9997C10.3668 16.9997 10.5448 16.9279 10.6885 16.7842C10.832 16.6404 10.9037 16.4622 10.9037 16.2497V8.74973C10.9037 8.53723 10.8318 8.35907 10.688 8.21523C10.5443 8.07157 10.3662 7.99973 10.1535 7.99973C9.941 7.99973 9.76292 8.07157 9.61925 8.21523C9.47575 8.35907 9.404 8.53723 9.404 8.74973V16.2497C9.404 16.4622 9.47583 16.6404 9.6195 16.7842C9.76333 16.9279 9.94158 16.9997 10.1543 16.9997ZM13.8465 16.9997C14.059 16.9997 14.2371 16.9279 14.3807 16.7842C14.5243 16.6404 14.596 16.4622 14.596 16.2497V8.74973C14.596 8.53723 14.5242 8.35907 14.3805 8.21523C14.2367 8.07157 14.0584 7.99973 13.8458 7.99973C13.6333 7.99973 13.4552 8.07157 13.3115 8.21523C13.168 8.35907 13.0962 8.53723 13.0962 8.74973V16.2497C13.0962 16.4622 13.1682 16.6404 13.312 16.7842C13.4557 16.9279 13.6338 16.9997 13.8465 16.9997Z\"\n />\n </svg>\n`\n"],"names":[],"mappings":";;AAAO,MAAM,UAAa,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const confirmIcon = `
|
|
2
|
+
<svg
|
|
3
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
4
|
+
width="24"
|
|
5
|
+
height="24"
|
|
6
|
+
viewBox="0 0 24 24"
|
|
7
|
+
fill="none"
|
|
8
|
+
>
|
|
9
|
+
<g clip-path="url(#clip0_1013_1606)">
|
|
10
|
+
<path
|
|
11
|
+
d="M9.00012 16.1998L5.50012 12.6998C5.11012 12.3098 4.49012 12.3098 4.10012 12.6998C3.71012 13.0898 3.71012 13.7098 4.10012 14.0998L8.29012 18.2898C8.68012 18.6798 9.31012 18.6798 9.70012 18.2898L20.3001 7.69982C20.6901 7.30982 20.6901 6.68982 20.3001 6.29982C19.9101 5.90982 19.2901 5.90982 18.9001 6.29982L9.00012 16.1998Z"
|
|
12
|
+
fill="#817567"
|
|
13
|
+
/>
|
|
14
|
+
</g>
|
|
15
|
+
<defs>
|
|
16
|
+
<clipPath id="clip0_1013_1606">
|
|
17
|
+
<rect width="24" height="24" />
|
|
18
|
+
</clipPath>
|
|
19
|
+
</defs>
|
|
20
|
+
</svg>
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
export { confirmIcon as c };
|
|
24
|
+
//# sourceMappingURL=confirm-DtE-HkVd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirm-DtE-HkVd.js","sources":["../../src/icons/confirm.ts"],"sourcesContent":["export const confirmIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n >\n <g clip-path=\"url(#clip0_1013_1606)\">\n <path\n d=\"M9.00012 16.1998L5.50012 12.6998C5.11012 12.3098 4.49012 12.3098 4.10012 12.6998C3.71012 13.0898 3.71012 13.7098 4.10012 14.0998L8.29012 18.2898C8.68012 18.6798 9.31012 18.6798 9.70012 18.2898L20.3001 7.69982C20.6901 7.30982 20.6901 6.68982 20.3001 6.29982C19.9101 5.90982 19.2901 5.90982 18.9001 6.29982L9.00012 16.1998Z\"\n fill=\"#817567\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_1013_1606\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n"],"names":[],"mappings":"AAAO,MAAM,WAAc,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const editIcon = `
|
|
2
|
+
<svg
|
|
3
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
4
|
+
width="24"
|
|
5
|
+
height="24"
|
|
6
|
+
viewBox="0 0 24 24"
|
|
7
|
+
>
|
|
8
|
+
<g clip-path="url(#clip0_1013_1585)">
|
|
9
|
+
<path
|
|
10
|
+
d="M14.06 9.02L14.98 9.94L5.92 19H5V18.08L14.06 9.02ZM17.66 3C17.41 3 17.15 3.1 16.96 3.29L15.13 5.12L18.88 8.87L20.71 7.04C21.1 6.65 21.1 6.02 20.71 5.63L18.37 3.29C18.17 3.09 17.92 3 17.66 3ZM14.06 6.19L3 17.25V21H6.75L17.81 9.94L14.06 6.19Z"
|
|
11
|
+
/>
|
|
12
|
+
</g>
|
|
13
|
+
<defs>
|
|
14
|
+
<clipPath id="clip0_1013_1585">
|
|
15
|
+
<rect width="24" height="24" />
|
|
16
|
+
</clipPath>
|
|
17
|
+
</defs>
|
|
18
|
+
</svg>
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
export { editIcon as e };
|
|
22
|
+
//# sourceMappingURL=edit-D--t_JAb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-D--t_JAb.js","sources":["../../src/icons/edit.ts"],"sourcesContent":["export const editIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <g clip-path=\"url(#clip0_1013_1585)\">\n <path\n d=\"M14.06 9.02L14.98 9.94L5.92 19H5V18.08L14.06 9.02ZM17.66 3C17.41 3 17.15 3.1 16.96 3.29L15.13 5.12L18.88 8.87L20.71 7.04C21.1 6.65 21.1 6.02 20.71 5.63L18.37 3.29C18.17 3.09 17.92 3 17.66 3ZM14.06 6.19L3 17.25V21H6.75L17.81 9.94L14.06 6.19Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_1013_1585\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n"],"names":[],"mappings":"AAAO,MAAM,QAAW,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const codeIcon = `
|
|
2
|
+
<svg
|
|
3
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
4
|
+
width="24"
|
|
5
|
+
height="24"
|
|
6
|
+
viewBox="0 0 24 24"
|
|
7
|
+
>
|
|
8
|
+
<g clip-path="url(#clip0_977_8081)">
|
|
9
|
+
<path
|
|
10
|
+
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"
|
|
11
|
+
/>
|
|
12
|
+
</g>
|
|
13
|
+
<defs>
|
|
14
|
+
<clipPath id="clip0_977_8081">
|
|
15
|
+
<rect width="24" height="24" />
|
|
16
|
+
</clipPath>
|
|
17
|
+
</defs>
|
|
18
|
+
</svg>
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
const functionsIcon = `
|
|
22
|
+
<svg
|
|
23
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
24
|
+
width="32"
|
|
25
|
+
height="32"
|
|
26
|
+
viewBox="0 0 24 24"
|
|
27
|
+
>
|
|
28
|
+
<path
|
|
29
|
+
fill="currentColor"
|
|
30
|
+
d="M7 19v-.808L13.096 12L7 5.808V5h10v1.25H9.102L14.727 12l-5.625 5.77H17V19z"
|
|
31
|
+
/>
|
|
32
|
+
</svg>
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
export { codeIcon as c, functionsIcon as f };
|
|
36
|
+
//# sourceMappingURL=functions-DlJPkGmE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions-DlJPkGmE.js","sources":["../../src/icons/code.ts","../../src/icons/functions.ts"],"sourcesContent":["export const codeIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <g clip-path=\"url(#clip0_977_8081)\">\n <path\n 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\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_977_8081\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n","export const functionsIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"32\"\n height=\"32\"\n viewBox=\"0 0 24 24\"\n >\n <path\n fill=\"currentColor\"\n d=\"M7 19v-.808L13.096 12L7 5.808V5h10v1.25H9.102L14.727 12l-5.625 5.77H17V19z\"\n />\n </svg>\n`\n"],"names":[],"mappings":"AAAO,MAAM,QAAW,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;ACAjB,MAAM,aAAgB,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const imageIcon = `
|
|
2
|
+
<svg
|
|
3
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
4
|
+
width="24"
|
|
5
|
+
height="24"
|
|
6
|
+
viewBox="0 0 24 24"
|
|
7
|
+
>
|
|
8
|
+
<g clip-path="url(#clip0_977_8075)">
|
|
9
|
+
<path
|
|
10
|
+
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"
|
|
11
|
+
/>
|
|
12
|
+
</g>
|
|
13
|
+
<defs>
|
|
14
|
+
<clipPath id="clip0_977_8075">
|
|
15
|
+
<rect width="24" height="24" />
|
|
16
|
+
</clipPath>
|
|
17
|
+
</defs>
|
|
18
|
+
</svg>
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
export { imageIcon as i };
|
|
22
|
+
//# sourceMappingURL=image-DoB1o1sl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-DoB1o1sl.js","sources":["../../src/icons/image.ts"],"sourcesContent":["export const imageIcon = `\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n >\n <g clip-path=\"url(#clip0_977_8075)\">\n <path\n 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\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_977_8075\">\n <rect width=\"24\" height=\"24\" />\n </clipPath>\n </defs>\n </svg>\n`\n"],"names":[],"mappings":"AAAO,MAAM,SAAY,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;"}
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { tooltipFactory, TooltipProvider } from '@milkdown/kit/plugin/tooltip';
|
|
2
|
+
import { NodeSelection, TextSelection } from '@milkdown/kit/prose/state';
|
|
3
|
+
import { defineComponent, h, Fragment, ref, shallowRef, createApp } from 'vue';
|
|
4
|
+
import { Icon } from '@milkdown/kit/component';
|
|
5
|
+
import { linkTooltipAPI } from '@milkdown/kit/component/link-tooltip';
|
|
6
|
+
import { editorViewCtx, commandsCtx } from '@milkdown/kit/core';
|
|
7
|
+
import { strongSchema, emphasisSchema, inlineCodeSchema, linkSchema, toggleStrongCommand, toggleEmphasisCommand, toggleInlineCodeCommand } from '@milkdown/kit/preset/commonmark';
|
|
8
|
+
import { strikethroughSchema, toggleStrikethroughCommand } from '@milkdown/kit/preset/gfm';
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
import { F as FeaturesCtx, C as CrepeFeature } from './index-Dc_wWopW.js';
|
|
11
|
+
import { c as codeIcon, f as functionsIcon } from './functions-DlJPkGmE.js';
|
|
12
|
+
import { m as mathInlineSchema } from './inline-latex-C9IGAXXQ.js';
|
|
13
|
+
import '@milkdown/kit/plugin/clipboard';
|
|
14
|
+
import '@milkdown/kit/plugin/history';
|
|
15
|
+
import '@milkdown/kit/plugin/indent';
|
|
16
|
+
import '@milkdown/kit/plugin/listener';
|
|
17
|
+
import '@milkdown/kit/plugin/trailing';
|
|
18
|
+
import '@milkdown/kit/utils';
|
|
19
|
+
import '@milkdown/kit/ctx';
|
|
20
|
+
import 'katex';
|
|
21
|
+
|
|
22
|
+
const boldIcon = `
|
|
23
|
+
<svg
|
|
24
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
25
|
+
width="24"
|
|
26
|
+
height="24"
|
|
27
|
+
viewBox="0 0 24 24"
|
|
28
|
+
>
|
|
29
|
+
<path
|
|
30
|
+
d="M8.85758 18.625C8.4358 18.625 8.07715 18.4772 7.78163 18.1817C7.48613 17.8862 7.33838 17.5275 7.33838 17.1058V6.8942C7.33838 6.47242 7.48613 6.11377 7.78163 5.81825C8.07715 5.52275 8.4358 5.375 8.85758 5.375H12.1999C13.2191 5.375 14.1406 5.69231 14.9643 6.32693C15.788 6.96154 16.1999 7.81603 16.1999 8.89038C16.1999 9.63779 16.0194 10.2471 15.6585 10.7183C15.2976 11.1894 14.9088 11.5314 14.4922 11.7442C15.005 11.9211 15.4947 12.2708 15.9614 12.7933C16.428 13.3157 16.6614 14.0192 16.6614 14.9038C16.6614 16.182 16.1902 17.1217 15.2479 17.723C14.3056 18.3243 13.3563 18.625 12.3999 18.625H8.85758ZM9.4883 16.6327H12.3191C13.1063 16.6327 13.6627 16.4141 13.9884 15.9769C14.314 15.5397 14.4768 15.1205 14.4768 14.7192C14.4768 14.3179 14.314 13.8987 13.9884 13.4615C13.6627 13.0243 13.0909 12.8057 12.273 12.8057H9.4883V16.6327ZM9.4883 10.875H12.0826C12.6903 10.875 13.172 10.7013 13.5278 10.3539C13.8836 10.0064 14.0615 9.59037 14.0615 9.10575C14.0615 8.59035 13.8733 8.16918 13.497 7.84225C13.1207 7.51533 12.6595 7.35188 12.1133 7.35188H9.4883V10.875Z"
|
|
31
|
+
/>
|
|
32
|
+
</svg>
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
const italicIcon = `
|
|
36
|
+
<svg
|
|
37
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
38
|
+
width="24"
|
|
39
|
+
height="24"
|
|
40
|
+
viewBox="0 0 24 24"
|
|
41
|
+
>
|
|
42
|
+
<path
|
|
43
|
+
d="M6.29811 18.625C6.04505 18.625 5.83115 18.5375 5.65641 18.3626C5.48166 18.1877 5.39429 17.9736 5.39429 17.7203C5.39429 17.467 5.48166 17.2532 5.65641 17.0788C5.83115 16.9045 6.04505 16.8173 6.29811 16.8173H9.21159L12.452 7.18265H9.53851C9.28545 7.18265 9.07155 7.0952 8.89681 6.9203C8.72206 6.7454 8.63469 6.5313 8.63469 6.278C8.63469 6.02472 8.72206 5.81089 8.89681 5.63652C9.07155 5.46217 9.28545 5.375 9.53851 5.375H16.8847C17.1377 5.375 17.3516 5.46245 17.5264 5.63735C17.7011 5.81225 17.7885 6.02634 17.7885 6.27962C17.7885 6.53293 17.7011 6.74676 17.5264 6.92113C17.3516 7.09548 17.1377 7.18265 16.8847 7.18265H14.2789L11.0385 16.8173H13.6443C13.8973 16.8173 14.1112 16.9048 14.286 17.0797C14.4607 17.2546 14.5481 17.4687 14.5481 17.722C14.5481 17.9752 14.4607 18.1891 14.286 18.3634C14.1112 18.5378 13.8973 18.625 13.6443 18.625H6.29811Z"
|
|
44
|
+
/>
|
|
45
|
+
</svg>
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
const linkIcon = `
|
|
49
|
+
<svg
|
|
50
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
51
|
+
width="24"
|
|
52
|
+
height="24"
|
|
53
|
+
viewBox="0 0 24 24"
|
|
54
|
+
>
|
|
55
|
+
<path
|
|
56
|
+
d="M17.0385 19.5003V16.5388H14.0769V15.0388H17.0385V12.0773H18.5384V15.0388H21.5V16.5388H18.5384V19.5003H17.0385ZM10.8077 16.5388H7.03845C5.78282 16.5388 4.7125 16.0963 3.8275 15.2114C2.9425 14.3266 2.5 13.2564 2.5 12.0009C2.5 10.7454 2.9425 9.67504 3.8275 8.78979C4.7125 7.90454 5.78282 7.46191 7.03845 7.46191H10.8077V8.96186H7.03845C6.1987 8.96186 5.48235 9.25834 4.8894 9.85129C4.29645 10.4442 3.99998 11.1606 3.99998 12.0003C3.99998 12.8401 4.29645 13.5564 4.8894 14.1494C5.48235 14.7423 6.1987 15.0388 7.03845 15.0388H10.8077V16.5388ZM8.25 12.7503V11.2504H15.75V12.7503H8.25ZM21.5 12.0003H20C20 11.1606 19.7035 10.4442 19.1106 9.85129C18.5176 9.25834 17.8013 8.96186 16.9615 8.96186H13.1923V7.46191H16.9615C18.2171 7.46191 19.2875 7.90441 20.1725 8.78939C21.0575 9.67439 21.5 10.7447 21.5 12.0003Z"
|
|
57
|
+
/>
|
|
58
|
+
</svg>
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
const strikethroughIcon = `
|
|
62
|
+
<svg
|
|
63
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
64
|
+
width="24"
|
|
65
|
+
height="24"
|
|
66
|
+
viewBox="0 0 24 24"
|
|
67
|
+
>
|
|
68
|
+
<path
|
|
69
|
+
d="M3.25 13.7404C3.0375 13.7404 2.85938 13.6684 2.71563 13.5246C2.57188 13.3808 2.5 13.2026 2.5 12.99C2.5 12.7774 2.57188 12.5993 2.71563 12.4558C2.85938 12.3122 3.0375 12.2404 3.25 12.2404H20.75C20.9625 12.2404 21.1406 12.3123 21.2843 12.4561C21.4281 12.5999 21.5 12.7781 21.5 12.9907C21.5 13.2033 21.4281 13.3814 21.2843 13.525C21.1406 13.6686 20.9625 13.7404 20.75 13.7404H3.25ZM10.9423 10.2596V6.62495H6.5673C6.2735 6.62495 6.02377 6.52201 5.8181 6.31613C5.61245 6.11026 5.50963 5.86027 5.50963 5.56615C5.50963 5.27205 5.61245 5.02083 5.8181 4.8125C6.02377 4.60417 6.2735 4.5 6.5673 4.5H17.4423C17.7361 4.5 17.9858 4.60294 18.1915 4.80883C18.3971 5.01471 18.5 5.2647 18.5 5.5588C18.5 5.85292 18.3971 6.10413 18.1915 6.31245C17.9858 6.52078 17.7361 6.62495 17.4423 6.62495H13.0673V10.2596H10.9423ZM10.9423 15.7211H13.0673V18.4423C13.0673 18.7361 12.9643 18.9858 12.7584 19.1915C12.5526 19.3971 12.3026 19.5 12.0085 19.5C11.7144 19.5 11.4631 19.3962 11.2548 19.1887C11.0465 18.9811 10.9423 18.7291 10.9423 18.4327V15.7211Z"
|
|
70
|
+
/>
|
|
71
|
+
</svg>
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
const Toolbar = defineComponent({
|
|
75
|
+
props: {
|
|
76
|
+
ctx: {
|
|
77
|
+
type: Object,
|
|
78
|
+
required: true
|
|
79
|
+
},
|
|
80
|
+
hide: {
|
|
81
|
+
type: Function,
|
|
82
|
+
required: true
|
|
83
|
+
},
|
|
84
|
+
show: {
|
|
85
|
+
type: Object,
|
|
86
|
+
required: true
|
|
87
|
+
},
|
|
88
|
+
selection: {
|
|
89
|
+
type: Object,
|
|
90
|
+
required: true
|
|
91
|
+
},
|
|
92
|
+
config: {
|
|
93
|
+
type: Object,
|
|
94
|
+
required: false
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
setup(props) {
|
|
98
|
+
const { ctx, hide, config } = props;
|
|
99
|
+
const onClick = (fn) => (e) => {
|
|
100
|
+
e.preventDefault();
|
|
101
|
+
ctx && fn(ctx);
|
|
102
|
+
};
|
|
103
|
+
const isActive = (mark) => {
|
|
104
|
+
const selection = props.selection.value;
|
|
105
|
+
if (!ctx || !selection) return false;
|
|
106
|
+
const { state } = ctx.get(editorViewCtx);
|
|
107
|
+
if (!state) return false;
|
|
108
|
+
const { doc } = state;
|
|
109
|
+
return doc.rangeHasMark(selection.from, selection.to, mark);
|
|
110
|
+
};
|
|
111
|
+
const containsNode = (node) => {
|
|
112
|
+
const selection = props.selection.value;
|
|
113
|
+
if (!ctx || !selection) return false;
|
|
114
|
+
const { state } = ctx.get(editorViewCtx);
|
|
115
|
+
if (!state) return false;
|
|
116
|
+
const { doc } = state;
|
|
117
|
+
if (selection instanceof NodeSelection) {
|
|
118
|
+
return selection.node.type === node;
|
|
119
|
+
}
|
|
120
|
+
const { from, to } = selection;
|
|
121
|
+
let hasNode = false;
|
|
122
|
+
doc.nodesBetween(from, to, (n) => {
|
|
123
|
+
if (n.type === node) {
|
|
124
|
+
hasNode = true;
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
return true;
|
|
128
|
+
});
|
|
129
|
+
return hasNode;
|
|
130
|
+
};
|
|
131
|
+
const flags = ctx == null ? void 0 : ctx.get(FeaturesCtx);
|
|
132
|
+
const isLatexEnabled = flags == null ? void 0 : flags.includes(CrepeFeature.Latex);
|
|
133
|
+
const toggleLatex = (ctx2) => {
|
|
134
|
+
const hasLatex = containsNode(mathInlineSchema.type(ctx2));
|
|
135
|
+
const view = ctx2.get(editorViewCtx);
|
|
136
|
+
const { selection, doc, tr } = view.state;
|
|
137
|
+
if (!hasLatex) {
|
|
138
|
+
const text = doc.textBetween(selection.from, selection.to);
|
|
139
|
+
let _tr2 = tr.replaceSelectionWith(
|
|
140
|
+
mathInlineSchema.type(ctx2).create({
|
|
141
|
+
value: text
|
|
142
|
+
})
|
|
143
|
+
);
|
|
144
|
+
view.dispatch(
|
|
145
|
+
_tr2.setSelection(NodeSelection.create(_tr2.doc, selection.from))
|
|
146
|
+
);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const { from, to } = selection;
|
|
150
|
+
let pos = -1;
|
|
151
|
+
let node = null;
|
|
152
|
+
doc.nodesBetween(from, to, (n, p) => {
|
|
153
|
+
if (node) return false;
|
|
154
|
+
if (n.type === mathInlineSchema.type(ctx2)) {
|
|
155
|
+
pos = p;
|
|
156
|
+
node = n;
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
return true;
|
|
160
|
+
});
|
|
161
|
+
if (!node || pos < 0) return;
|
|
162
|
+
let _tr = tr.delete(pos, pos + 1);
|
|
163
|
+
const content = node.attrs.value;
|
|
164
|
+
_tr = _tr.insertText(content, pos);
|
|
165
|
+
view.dispatch(
|
|
166
|
+
_tr.setSelection(
|
|
167
|
+
TextSelection.create(_tr.doc, from, to + content.length - 1)
|
|
168
|
+
)
|
|
169
|
+
);
|
|
170
|
+
};
|
|
171
|
+
return () => {
|
|
172
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
173
|
+
return /* @__PURE__ */ h(Fragment, null, /* @__PURE__ */ h(
|
|
174
|
+
"button",
|
|
175
|
+
{
|
|
176
|
+
type: "button",
|
|
177
|
+
class: clsx(
|
|
178
|
+
"toolbar-item",
|
|
179
|
+
ctx && isActive(strongSchema.type(ctx)) && "active"
|
|
180
|
+
),
|
|
181
|
+
onPointerdown: onClick((ctx2) => {
|
|
182
|
+
const commands = ctx2.get(commandsCtx);
|
|
183
|
+
commands.call(toggleStrongCommand.key);
|
|
184
|
+
})
|
|
185
|
+
},
|
|
186
|
+
/* @__PURE__ */ h(Icon, { icon: (_b = (_a = config == null ? void 0 : config.boldIcon) == null ? void 0 : _a.call(config)) != null ? _b : boldIcon })
|
|
187
|
+
), /* @__PURE__ */ h(
|
|
188
|
+
"button",
|
|
189
|
+
{
|
|
190
|
+
type: "button",
|
|
191
|
+
class: clsx(
|
|
192
|
+
"toolbar-item",
|
|
193
|
+
ctx && isActive(emphasisSchema.type(ctx)) && "active"
|
|
194
|
+
),
|
|
195
|
+
onPointerdown: onClick((ctx2) => {
|
|
196
|
+
const commands = ctx2.get(commandsCtx);
|
|
197
|
+
commands.call(toggleEmphasisCommand.key);
|
|
198
|
+
})
|
|
199
|
+
},
|
|
200
|
+
/* @__PURE__ */ h(Icon, { icon: (_d = (_c = config == null ? void 0 : config.italicIcon) == null ? void 0 : _c.call(config)) != null ? _d : italicIcon })
|
|
201
|
+
), /* @__PURE__ */ h(
|
|
202
|
+
"button",
|
|
203
|
+
{
|
|
204
|
+
type: "button",
|
|
205
|
+
class: clsx(
|
|
206
|
+
"toolbar-item",
|
|
207
|
+
ctx && isActive(strikethroughSchema.type(ctx)) && "active"
|
|
208
|
+
),
|
|
209
|
+
onPointerdown: onClick((ctx2) => {
|
|
210
|
+
const commands = ctx2.get(commandsCtx);
|
|
211
|
+
commands.call(toggleStrikethroughCommand.key);
|
|
212
|
+
})
|
|
213
|
+
},
|
|
214
|
+
/* @__PURE__ */ h(Icon, { icon: (_f = (_e = config == null ? void 0 : config.strikethroughIcon) == null ? void 0 : _e.call(config)) != null ? _f : strikethroughIcon })
|
|
215
|
+
), /* @__PURE__ */ h("div", { class: "divider" }), /* @__PURE__ */ h(
|
|
216
|
+
"button",
|
|
217
|
+
{
|
|
218
|
+
type: "button",
|
|
219
|
+
class: clsx(
|
|
220
|
+
"toolbar-item",
|
|
221
|
+
ctx && isActive(inlineCodeSchema.type(ctx)) && "active"
|
|
222
|
+
),
|
|
223
|
+
onPointerdown: onClick((ctx2) => {
|
|
224
|
+
const commands = ctx2.get(commandsCtx);
|
|
225
|
+
commands.call(toggleInlineCodeCommand.key);
|
|
226
|
+
})
|
|
227
|
+
},
|
|
228
|
+
/* @__PURE__ */ h(Icon, { icon: (_h = (_g = config == null ? void 0 : config.codeIcon) == null ? void 0 : _g.call(config)) != null ? _h : codeIcon })
|
|
229
|
+
), isLatexEnabled && /* @__PURE__ */ h(
|
|
230
|
+
"button",
|
|
231
|
+
{
|
|
232
|
+
type: "button",
|
|
233
|
+
class: clsx(
|
|
234
|
+
"toolbar-item",
|
|
235
|
+
ctx && containsNode(mathInlineSchema.type(ctx)) && "active"
|
|
236
|
+
),
|
|
237
|
+
onPointerdown: onClick(toggleLatex)
|
|
238
|
+
},
|
|
239
|
+
/* @__PURE__ */ h(Icon, { icon: (_j = (_i = config == null ? void 0 : config.latexIcon) == null ? void 0 : _i.call(config)) != null ? _j : functionsIcon })
|
|
240
|
+
), /* @__PURE__ */ h(
|
|
241
|
+
"button",
|
|
242
|
+
{
|
|
243
|
+
type: "button",
|
|
244
|
+
class: clsx(
|
|
245
|
+
"toolbar-item",
|
|
246
|
+
ctx && isActive(linkSchema.type(ctx)) && "active"
|
|
247
|
+
),
|
|
248
|
+
onPointerdown: onClick((ctx2) => {
|
|
249
|
+
const view = ctx2.get(editorViewCtx);
|
|
250
|
+
const { selection } = view.state;
|
|
251
|
+
if (isActive(linkSchema.type(ctx2))) {
|
|
252
|
+
ctx2.get(linkTooltipAPI.key).removeLink(selection.from, selection.to);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
ctx2.get(linkTooltipAPI.key).addLink(selection.from, selection.to);
|
|
256
|
+
hide == null ? void 0 : hide();
|
|
257
|
+
})
|
|
258
|
+
},
|
|
259
|
+
/* @__PURE__ */ h(Icon, { icon: (_l = (_k = config == null ? void 0 : config.linkIcon) == null ? void 0 : _k.call(config)) != null ? _l : linkIcon })
|
|
260
|
+
));
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
var __typeError = (msg) => {
|
|
266
|
+
throw TypeError(msg);
|
|
267
|
+
};
|
|
268
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
269
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
270
|
+
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);
|
|
271
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
|
|
272
|
+
var _tooltipProvider, _content, _app, _selection, _show;
|
|
273
|
+
const toolbar = tooltipFactory("CREPE_TOOLBAR");
|
|
274
|
+
class ToolbarView {
|
|
275
|
+
constructor(ctx, view, config) {
|
|
276
|
+
__privateAdd(this, _tooltipProvider);
|
|
277
|
+
__privateAdd(this, _content);
|
|
278
|
+
__privateAdd(this, _app);
|
|
279
|
+
__privateAdd(this, _selection);
|
|
280
|
+
__privateAdd(this, _show, ref(false));
|
|
281
|
+
this.update = (view, prevState) => {
|
|
282
|
+
__privateGet(this, _tooltipProvider).update(view, prevState);
|
|
283
|
+
__privateGet(this, _selection).value = view.state.selection;
|
|
284
|
+
};
|
|
285
|
+
this.destroy = () => {
|
|
286
|
+
__privateGet(this, _tooltipProvider).destroy();
|
|
287
|
+
__privateGet(this, _app).unmount();
|
|
288
|
+
__privateGet(this, _content).remove();
|
|
289
|
+
};
|
|
290
|
+
this.hide = () => {
|
|
291
|
+
__privateGet(this, _tooltipProvider).hide();
|
|
292
|
+
};
|
|
293
|
+
const content = document.createElement("div");
|
|
294
|
+
content.className = "milkdown-toolbar";
|
|
295
|
+
__privateSet(this, _selection, shallowRef(view.state.selection));
|
|
296
|
+
const app = createApp(Toolbar, {
|
|
297
|
+
ctx,
|
|
298
|
+
hide: this.hide,
|
|
299
|
+
config,
|
|
300
|
+
selection: __privateGet(this, _selection),
|
|
301
|
+
show: __privateGet(this, _show)
|
|
302
|
+
});
|
|
303
|
+
app.mount(content);
|
|
304
|
+
__privateSet(this, _content, content);
|
|
305
|
+
__privateSet(this, _app, app);
|
|
306
|
+
__privateSet(this, _tooltipProvider, new TooltipProvider({
|
|
307
|
+
content: __privateGet(this, _content),
|
|
308
|
+
debounce: 20,
|
|
309
|
+
offset: 10,
|
|
310
|
+
shouldShow(view2) {
|
|
311
|
+
const { doc, selection } = view2.state;
|
|
312
|
+
const { empty, from, to } = selection;
|
|
313
|
+
const isEmptyTextBlock = !doc.textBetween(from, to).length && selection instanceof TextSelection;
|
|
314
|
+
const isNotTextBlock = !(selection instanceof TextSelection);
|
|
315
|
+
const activeElement = view2.dom.getRootNode().activeElement;
|
|
316
|
+
const isTooltipChildren = content.contains(activeElement);
|
|
317
|
+
const notHasFocus = !view2.hasFocus() && !isTooltipChildren;
|
|
318
|
+
const isReadonly = !view2.editable;
|
|
319
|
+
if (notHasFocus || isNotTextBlock || empty || isEmptyTextBlock || isReadonly)
|
|
320
|
+
return false;
|
|
321
|
+
return true;
|
|
322
|
+
}
|
|
323
|
+
}));
|
|
324
|
+
__privateGet(this, _tooltipProvider).onShow = () => {
|
|
325
|
+
__privateGet(this, _show).value = true;
|
|
326
|
+
};
|
|
327
|
+
__privateGet(this, _tooltipProvider).onHide = () => {
|
|
328
|
+
__privateGet(this, _show).value = false;
|
|
329
|
+
};
|
|
330
|
+
this.update(view);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
_tooltipProvider = new WeakMap();
|
|
334
|
+
_content = new WeakMap();
|
|
335
|
+
_app = new WeakMap();
|
|
336
|
+
_selection = new WeakMap();
|
|
337
|
+
_show = new WeakMap();
|
|
338
|
+
const defineFeature = (editor, config) => {
|
|
339
|
+
editor.config((ctx) => {
|
|
340
|
+
ctx.set(toolbar.key, {
|
|
341
|
+
view: (view) => new ToolbarView(ctx, view, config)
|
|
342
|
+
});
|
|
343
|
+
}).use(toolbar);
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
export { defineFeature };
|
|
347
|
+
//# sourceMappingURL=index-BAQT-9au.js.map
|