@jvs-milkdown/crepe 1.2.0 → 1.2.2
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/builder.js +55 -2
- package/lib/cjs/builder.js.map +1 -1
- package/lib/cjs/feature/block-edit/index.js +73 -5
- package/lib/cjs/feature/block-edit/index.js.map +1 -1
- package/lib/cjs/feature/code-mirror/index.js +65 -3
- package/lib/cjs/feature/code-mirror/index.js.map +1 -1
- package/lib/cjs/feature/cursor/index.js +55 -2
- package/lib/cjs/feature/cursor/index.js.map +1 -1
- package/lib/cjs/feature/image-block/index.js +76 -8
- package/lib/cjs/feature/image-block/index.js.map +1 -1
- package/lib/cjs/feature/latex/index.js +55 -2
- package/lib/cjs/feature/latex/index.js.map +1 -1
- package/lib/cjs/feature/link-tooltip/index.js +55 -2
- package/lib/cjs/feature/link-tooltip/index.js.map +1 -1
- package/lib/cjs/feature/list-item/index.js +55 -2
- package/lib/cjs/feature/list-item/index.js.map +1 -1
- package/lib/cjs/feature/placeholder/index.js +55 -2
- package/lib/cjs/feature/placeholder/index.js.map +1 -1
- package/lib/cjs/feature/table/index.js +55 -2
- package/lib/cjs/feature/table/index.js.map +1 -1
- package/lib/cjs/feature/toolbar/index.js +73 -5
- package/lib/cjs/feature/toolbar/index.js.map +1 -1
- package/lib/cjs/index.js +457 -31
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/builder.js +55 -2
- package/lib/esm/builder.js.map +1 -1
- package/lib/esm/feature/block-edit/index.js +73 -5
- package/lib/esm/feature/block-edit/index.js.map +1 -1
- package/lib/esm/feature/code-mirror/index.js +65 -3
- package/lib/esm/feature/code-mirror/index.js.map +1 -1
- package/lib/esm/feature/cursor/index.js +55 -2
- package/lib/esm/feature/cursor/index.js.map +1 -1
- package/lib/esm/feature/image-block/index.js +76 -8
- package/lib/esm/feature/image-block/index.js.map +1 -1
- package/lib/esm/feature/latex/index.js +55 -2
- package/lib/esm/feature/latex/index.js.map +1 -1
- package/lib/esm/feature/link-tooltip/index.js +55 -2
- package/lib/esm/feature/link-tooltip/index.js.map +1 -1
- package/lib/esm/feature/list-item/index.js +55 -2
- package/lib/esm/feature/list-item/index.js.map +1 -1
- package/lib/esm/feature/placeholder/index.js +55 -2
- package/lib/esm/feature/placeholder/index.js.map +1 -1
- package/lib/esm/feature/table/index.js +55 -2
- package/lib/esm/feature/table/index.js.map +1 -1
- package/lib/esm/feature/toolbar/index.js +73 -5
- package/lib/esm/feature/toolbar/index.js.map +1 -1
- package/lib/esm/index.js +458 -32
- package/lib/esm/index.js.map +1 -1
- package/lib/theme/common/code-mirror.css +13 -0
- package/lib/theme/common/image-block.css +324 -22
- package/lib/theme/common/reset.css +3 -0
- package/lib/theme/common/toolbar.css +27 -2
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/core/locale.ts +55 -0
- package/src/feature/block-edit/menu/config.ts +19 -3
- package/src/feature/code-mirror/index.ts +3 -0
- package/src/feature/fixed-toolbar/component.tsx +31 -2
- package/src/feature/fixed-toolbar/config.ts +18 -3
- package/src/feature/fixed-toolbar/document-header.tsx +8 -4
- package/src/feature/fixed-toolbar/index.ts +18 -1
- package/src/feature/fixed-toolbar/menu-bar.tsx +91 -3
- package/src/feature/fixed-toolbar/shortcut-help-modal.tsx +244 -0
- package/src/feature/fixed-toolbar/view-menu-state.ts +9 -0
- package/src/feature/image-block/index.ts +11 -1
- package/src/icons/border.ts +5 -0
- package/src/icons/close.ts +3 -0
- package/src/icons/crop.ts +6 -0
- package/src/icons/index.ts +5 -0
- package/src/icons/keyboard.ts +3 -0
- package/src/icons/word-wrap.ts +6 -0
- package/src/theme/common/code-mirror.css +13 -0
- package/src/theme/common/image-block.css +368 -23
- package/src/theme/common/reset.css +3 -0
- package/src/theme/common/toolbar.css +30 -2
package/lib/esm/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { createSlice } from '@jvs-milkdown/kit/ctx';
|
|
|
6
6
|
import { commandsCtx, editorViewCtx, editorCtx, EditorStatus, schemaCtx, editorViewOptionsCtx, Editor, rootCtx, defaultValueCtx } from '@jvs-milkdown/kit/core';
|
|
7
7
|
import { findNodeInSelection, findParent, nodeRule } from '@jvs-milkdown/kit/prose';
|
|
8
8
|
import { NodeSelection, TextSelection, Plugin, PluginKey, EditorState, AllSelection } from '@jvs-milkdown/kit/prose/state';
|
|
9
|
-
import { defineComponent, ref, computed, watch, watchEffect, onUnmounted, h, createApp, Fragment, reactive, onMounted, shallowRef, nextTick } from 'vue';
|
|
9
|
+
import { defineComponent, ref, computed, watch, watchEffect, onUnmounted, h, createApp, Fragment, reactive, onMounted, onBeforeUnmount, shallowRef, nextTick } from 'vue';
|
|
10
10
|
import { computePosition, flip, shift, offset } from '@floating-ui/dom';
|
|
11
11
|
import { slashFactory, SlashProvider } from '@jvs-milkdown/kit/plugin/slash';
|
|
12
12
|
import { Icon } from '@jvs-milkdown/kit/component';
|
|
@@ -16,6 +16,7 @@ import { $remark, $markAttr, $markSchema, $command, $ctx, $nodeSchema, $prose, $
|
|
|
16
16
|
import { visit } from 'unist-util-visit';
|
|
17
17
|
import { imageBlockSchema, imageBlockConfig, imageBlockComponent } from '@jvs-milkdown/kit/component/image-block';
|
|
18
18
|
import { lift, toggleMark } from '@jvs-milkdown/kit/prose/commands';
|
|
19
|
+
import { wrapInList } from '@jvs-milkdown/kit/prose/schema-list';
|
|
19
20
|
import katex from 'katex';
|
|
20
21
|
import { defaultKeymap, indentWithTab } from '@codemirror/commands';
|
|
21
22
|
import { keymap } from '@codemirror/view';
|
|
@@ -214,6 +215,10 @@ const clearIcon = `
|
|
|
214
215
|
</svg>
|
|
215
216
|
`;
|
|
216
217
|
|
|
218
|
+
const closeIcon = `
|
|
219
|
+
<svg viewBox="0 0 1024 1024" width="20" height="20"><path d="M619.52 544.448l324.672-324.928a53.632 53.632 0 0 0 0-75.776 53.376 53.376 0 0 0-75.712 0L543.872 468.672l-324.48-324.928a53.376 53.376 0 0 0-75.712 0 53.632 53.632 0 0 0 0 75.776l324.48 324.8-324.48 324.928a53.632 53.632 0 0 0 75.776 75.776l324.416-324.8 324.48 324.8a53.184 53.184 0 0 0 37.952 15.744 53.696 53.696 0 0 0 37.76-91.52l-324.48-324.8z" fill="#6F7588"></path></svg>
|
|
220
|
+
`;
|
|
221
|
+
|
|
217
222
|
const codeIcon = `
|
|
218
223
|
<svg viewBox="0 0 1024 1024" width="24" height="24">
|
|
219
224
|
<path d="M64 830.848V193.152q0-53.504 37.76-91.328Q139.712 64 193.216 64h637.696q53.504 0 91.328 37.76 37.824 37.888 37.824 91.392v637.696q0 53.504-37.76 91.328-37.888 37.824-91.392 37.824H193.152q-53.504 0-91.328-37.76Q64 884.288 64 830.784z m94.72 0q0 34.432 34.432 34.432h637.696q34.432 0 34.432-34.432V193.152q0-34.432-34.432-34.432H193.152q-34.432 0-34.432 34.432v637.696zM278.144 432q-6.592-6.592-10.24-15.296-3.584-8.704-3.584-18.176 0-4.608 0.896-9.216t2.688-8.832q1.792-4.288 4.416-8.192 2.56-3.904 5.824-7.232 3.392-3.2 7.232-5.888 3.84-2.56 8.192-4.352 4.224-1.792 8.896-2.688 4.544-0.96 9.216-0.96 9.408 0 18.112 3.584 8.704 3.648 15.36 10.304L491.968 512q6.72 6.656 10.24 15.36 3.648 8.64 3.648 18.112 0 9.408-3.584 18.112-3.584 8.704-10.24 15.36L345.216 725.76q-6.72 6.72-15.36 10.304-8.768 3.584-18.24 3.584-4.608 0-9.216-0.896-4.48-0.896-8.832-2.688-4.288-1.728-8.192-4.416-3.84-2.56-7.168-5.888-3.328-3.264-5.888-7.104-2.624-3.904-4.416-8.192-1.792-4.288-2.688-8.96-0.96-4.48-0.96-9.216 0-9.408 3.648-18.112 3.584-8.64 10.24-15.36L391.68 545.408 278.144 432z m440.832 299.2H585.472q-4.672 0-9.28-0.896-4.544-0.832-8.832-2.688-4.352-1.792-8.256-4.352-3.84-2.56-7.104-5.952-3.264-3.2-5.952-7.04-2.56-3.968-4.352-8.256-1.728-4.352-2.688-8.896-0.896-4.544-0.896-9.28 0-4.608 0.896-9.216 0.96-4.544 2.688-8.832 1.792-4.352 4.352-8.32 2.688-3.84 5.952-7.04 3.2-3.328 7.168-5.952 3.904-2.56 8.192-4.352 4.288-1.792 8.832-2.688 4.608-0.96 9.28-0.96h133.504q4.736 0 9.28 0.96 4.608 0.896 8.96 2.688 4.224 1.792 8.128 4.352 3.84 2.624 7.104 5.888 3.392 3.328 5.952 7.232 2.624 3.904 4.416 8.192 1.792 4.288 2.624 8.832 0.896 4.608 0.896 9.216 0 4.736-0.896 9.28-0.832 4.608-2.624 8.96-1.792 4.224-4.48 8.128-2.56 3.84-5.888 7.104-3.2 3.392-7.04 5.952-3.968 2.56-8.256 4.352-4.352 1.856-8.896 2.688-4.544 0.896-9.28 0.896z" fill="#363B4C" p-id="16577"></path></svg>
|
|
@@ -610,6 +615,30 @@ const splitCellIcon = `
|
|
|
610
615
|
</svg>
|
|
611
616
|
`;
|
|
612
617
|
|
|
618
|
+
const keyboardIcon = `
|
|
619
|
+
<svg t="1778036070440" class="icon" viewBox="0 0 1024 1024" width="20" height="20"><path d="M934.4 190.08c0-23.68-18.048-42.88-40.192-42.88H129.856c-22.208 0-40.256 19.2-40.256 42.88v643.84c0 23.68 17.984 42.88 40.32 42.88h764.288c22.144 0 40.128-19.2 40.192-42.88V190.08z m-764.352 43.008h683.968v558.016H170.048V233.088z m603.456 343.296c11.072 0 20.16 9.728 20.16 21.44v42.944c0 11.84-9.088 21.44-20.16 21.44H250.56a20.8 20.8 0 0 1-20.16-21.44v-42.88c0-11.904 9.088-21.504 20.16-21.504h522.88z m-422.4-193.088a20.8 20.8 0 0 0-20.096-21.44H250.56a20.8 20.8 0 0 0-20.16 21.44v42.88c0 11.904 9.088 21.504 20.16 21.504h80.448c11.072 0 20.096-9.728 20.096-21.44v-42.944zM512 361.856c11.136 0 20.096 9.6 20.096 21.44v42.88c0 11.84-8.96 21.504-20.096 21.504H431.616a20.8 20.8 0 0 1-20.16-21.44v-42.944c0-11.84 9.024-21.44 20.16-21.44H512z m281.6 21.44a20.8 20.8 0 0 0-20.096-21.44H612.608a20.8 20.8 0 0 0-20.16 21.44v42.88c0 11.904 9.088 21.504 20.16 21.504h160.896a20.928 20.928 0 0 0 20.16-21.44v-42.944z" fill="#363B4C" p-id="13200"></path></svg>
|
|
620
|
+
`;
|
|
621
|
+
|
|
622
|
+
const wordWrapIcon = `
|
|
623
|
+
<svg viewBox="0 0 1024 1024" height="24px"
|
|
624
|
+
width="24px">
|
|
625
|
+
<path d="M128 850.88V173.12q0-4.48 0.896-8.832 0.832-4.352 2.56-8.448 1.664-4.096 4.16-7.808 2.432-3.648 5.568-6.848 3.2-3.136 6.848-5.568 3.712-2.496 7.808-4.16 4.096-1.728 8.448-2.56Q168.704 128 173.12 128q4.48 0 8.832 0.896 4.352 0.832 8.448 2.56 4.096 1.664 7.808 4.16 3.648 2.432 6.848 5.568 3.136 3.2 5.568 6.848 2.496 3.712 4.16 7.808 1.728 4.096 2.56 8.448 0.896 4.416 0.896 8.832v677.76q0 4.48-0.896 8.768-0.832 4.416-2.56 8.512-1.664 4.096-4.16 7.808-2.432 3.648-5.568 6.848-3.2 3.136-6.848 5.568-3.712 2.496-7.808 4.16-4.096 1.728-8.448 2.56-4.416 0.896-8.832 0.896-4.48 0-8.832-0.896-4.352-0.832-8.448-2.56-4.096-1.664-7.808-4.16-3.648-2.432-6.848-5.632-3.136-3.136-5.568-6.784-2.496-3.712-4.16-7.808-1.728-4.096-2.56-8.512Q128 855.296 128 850.88z m677.76 0a45.12 45.12 0 0 0 90.24 0V173.12a45.12 45.12 0 0 0-90.24 0v677.76zM471.232 684.8a46.208 46.208 0 0 1-4.288 0.192h-48l48 48.448c8.832 8.896 13.056 20.288 13.056 32a44.8 44.8 0 0 1-12.992 32 45.184 45.184 0 0 1-64 0L282.24 676.224A44.992 44.992 0 0 1 269.184 640a44.992 44.992 0 0 1 13.056-36.288l120.704-120.704a45.184 45.184 0 1 1 64 64l-47.744 47.744h47.744c2.176 0 4.352 0.128 6.464 0.448h70.656q47.68 0 81.472-33.728 33.728-33.792 33.728-81.472 0-47.744-33.728-81.472Q591.744 364.8 544 364.8H384a44.8 44.8 0 1 1 0-89.6h160q84.8 0 144.832 59.968 59.968 59.968 59.968 144.832 0 84.8-59.968 144.832-60.032 59.968-144.832 59.968H471.232z" fill="#363B4C"></path>
|
|
626
|
+
</svg>
|
|
627
|
+
`;
|
|
628
|
+
|
|
629
|
+
const cropIcon = `
|
|
630
|
+
<svg viewBox="0 0 1024 1024" height="24px" width="24px">
|
|
631
|
+
<path d="M192 128v128H128v64h192V128h-128z m0 0h64v128h-64V128z m512 0v128h192v64H640V128h64z m-512 640H128v-64h192v192h-128v-128z m0 128h64v-128h-64v128z m512 0v-128h192v64h-128v128h-64z m0 0h64v-128h-64v128z" fill="currentColor"/>
|
|
632
|
+
<path d="M256 256h512v512H256z" fill="none" stroke="currentColor" stroke-width="64"/>
|
|
633
|
+
</svg>
|
|
634
|
+
`;
|
|
635
|
+
|
|
636
|
+
const borderIcon = `
|
|
637
|
+
<svg viewBox="0 0 1024 1024" height="24px" width="24px">
|
|
638
|
+
<path d="M160 160h704v704H160z" fill="none" stroke="currentColor" stroke-width="64" stroke-dasharray="64 32"/>
|
|
639
|
+
</svg>
|
|
640
|
+
`;
|
|
641
|
+
|
|
613
642
|
const defaultConfig = {
|
|
614
643
|
[CrepeFeature.CodeMirror]: {
|
|
615
644
|
theme: oneDark,
|
|
@@ -645,12 +674,17 @@ const zhCN = {
|
|
|
645
674
|
"view.docBackground": "\u6587\u6863\u80CC\u666F\u8272",
|
|
646
675
|
"view.title": "\u663E\u793A\u6807\u9898",
|
|
647
676
|
"view.cover": "\u663E\u793A\u5C01\u9762",
|
|
677
|
+
"view.editorWidth": "\u5185\u5BB9\u5BBD\u5EA6",
|
|
678
|
+
"view.widthDefault": "\u9ED8\u8BA4",
|
|
679
|
+
"view.widthWide": "\u8F83\u5BBD",
|
|
680
|
+
"view.widthFull": "\u5168\u5BBD",
|
|
648
681
|
// code-mirror
|
|
649
682
|
"codeMirror.searchPlaceholder": "\u641C\u7D22\u8BED\u8A00",
|
|
650
683
|
"codeMirror.noResultText": "\u65E0\u7ED3\u679C",
|
|
651
684
|
"codeMirror.previewToggleOptionEdit": "\u7F16\u8F91",
|
|
652
685
|
"codeMirror.previewToggleOptionHide": "\u9690\u85CF",
|
|
653
686
|
"codeMirror.previewLabel": "\u9884\u89C8",
|
|
687
|
+
"codeMirror.wrapText": "\u81EA\u52A8\u6362\u884C",
|
|
654
688
|
// link-tooltip
|
|
655
689
|
"linkTooltip.pasteLink": "\u7C98\u8D34\u94FE\u63A5...",
|
|
656
690
|
// image-block
|
|
@@ -748,7 +782,29 @@ const zhCN = {
|
|
|
748
782
|
"latex.escToExit": "\u6309 ESC \u5B8C\u6210\u8F93\u5165",
|
|
749
783
|
"latex.helpDoc": "\u67E5\u770B\u5E2E\u52A9\u6587\u6863",
|
|
750
784
|
"latex.emptyPlaceholder": "\u6DFB\u52A0 LaTeX \u516C\u5F0F",
|
|
751
|
-
"latex.inputPlaceholder": "\u8BF7\u8F93\u5165\u516C\u5F0F"
|
|
785
|
+
"latex.inputPlaceholder": "\u8BF7\u8F93\u5165\u516C\u5F0F",
|
|
786
|
+
// shortcuts
|
|
787
|
+
"shortcuts.title": "\u952E\u76D8\u5FEB\u6377\u952E",
|
|
788
|
+
"shortcuts.formatting": "\u6587\u672C\u683C\u5F0F",
|
|
789
|
+
"shortcuts.bold": "\u52A0\u7C97",
|
|
790
|
+
"shortcuts.italic": "\u659C\u4F53",
|
|
791
|
+
"shortcuts.underline": "\u4E0B\u5212\u7EBF",
|
|
792
|
+
"shortcuts.strikethrough": "\u5220\u9664\u7EBF",
|
|
793
|
+
"shortcuts.inlineCode": "\u884C\u5185\u4EE3\u7801",
|
|
794
|
+
"shortcuts.highlight": "\u9AD8\u4EAE",
|
|
795
|
+
"shortcuts.paragraph": "\u6BB5\u843D",
|
|
796
|
+
"shortcuts.heading": "\u6807\u9898",
|
|
797
|
+
"shortcuts.block": "\u5757\u7EA7\u5143\u7D20",
|
|
798
|
+
"shortcuts.codeBlock": "\u4EE3\u7801\u5757",
|
|
799
|
+
"shortcuts.blockquote": "\u5F15\u7528",
|
|
800
|
+
"shortcuts.orderedList": "\u6709\u5E8F\u5217\u8868",
|
|
801
|
+
"shortcuts.bulletList": "\u65E0\u5E8F\u5217\u8868",
|
|
802
|
+
"shortcuts.indent": "\u589E\u52A0\u7F29\u8FDB",
|
|
803
|
+
"shortcuts.outdent": "\u51CF\u5C11\u7F29\u8FDB",
|
|
804
|
+
"shortcuts.hardBreak": "\u6362\u884C",
|
|
805
|
+
"shortcuts.history": "\u5386\u53F2\u8BB0\u5F55",
|
|
806
|
+
"shortcuts.undo": "\u64A4\u9500",
|
|
807
|
+
"shortcuts.redo": "\u91CD\u505A"
|
|
752
808
|
};
|
|
753
809
|
const enUS = {
|
|
754
810
|
"handle.add": "Add content",
|
|
@@ -769,11 +825,16 @@ const enUS = {
|
|
|
769
825
|
"view.docBackground": "Document Background",
|
|
770
826
|
"view.title": "Show Title",
|
|
771
827
|
"view.cover": "Show Cover",
|
|
828
|
+
"view.editorWidth": "Content Width",
|
|
829
|
+
"view.widthDefault": "Default",
|
|
830
|
+
"view.widthWide": "Wide",
|
|
831
|
+
"view.widthFull": "Full Width",
|
|
772
832
|
"codeMirror.searchPlaceholder": "Search language",
|
|
773
833
|
"codeMirror.noResultText": "No result",
|
|
774
834
|
"codeMirror.previewToggleOptionEdit": "Edit",
|
|
775
835
|
"codeMirror.previewToggleOptionHide": "Hide",
|
|
776
836
|
"codeMirror.previewLabel": "Preview",
|
|
837
|
+
"codeMirror.wrapText": "Wrap",
|
|
777
838
|
"linkTooltip.pasteLink": "Paste link...",
|
|
778
839
|
"imageBlock.inlineUploadButton": "Upload",
|
|
779
840
|
"imageBlock.inlineUploadPlaceholder": "or paste link",
|
|
@@ -863,7 +924,28 @@ const enUS = {
|
|
|
863
924
|
"latex.escToExit": "Press ESC to finish",
|
|
864
925
|
"latex.helpDoc": "Help Doc",
|
|
865
926
|
"latex.emptyPlaceholder": "Add LaTeX",
|
|
866
|
-
"latex.inputPlaceholder": "Please enter formula"
|
|
927
|
+
"latex.inputPlaceholder": "Please enter formula",
|
|
928
|
+
"shortcuts.title": "Keyboard Shortcuts",
|
|
929
|
+
"shortcuts.formatting": "Text Formatting",
|
|
930
|
+
"shortcuts.bold": "Bold",
|
|
931
|
+
"shortcuts.italic": "Italic",
|
|
932
|
+
"shortcuts.underline": "Underline",
|
|
933
|
+
"shortcuts.strikethrough": "Strikethrough",
|
|
934
|
+
"shortcuts.inlineCode": "Inline Code",
|
|
935
|
+
"shortcuts.highlight": "Highlight",
|
|
936
|
+
"shortcuts.paragraph": "Paragraph",
|
|
937
|
+
"shortcuts.heading": "Heading",
|
|
938
|
+
"shortcuts.block": "Block Elements",
|
|
939
|
+
"shortcuts.codeBlock": "Code Block",
|
|
940
|
+
"shortcuts.blockquote": "Blockquote",
|
|
941
|
+
"shortcuts.orderedList": "Ordered List",
|
|
942
|
+
"shortcuts.bulletList": "Bullet List",
|
|
943
|
+
"shortcuts.indent": "Indent",
|
|
944
|
+
"shortcuts.outdent": "Outdent",
|
|
945
|
+
"shortcuts.hardBreak": "Hard Break",
|
|
946
|
+
"shortcuts.history": "History",
|
|
947
|
+
"shortcuts.undo": "Undo",
|
|
948
|
+
"shortcuts.redo": "Redo"
|
|
867
949
|
};
|
|
868
950
|
const translationsCtx = createSlice(
|
|
869
951
|
{
|
|
@@ -1910,10 +1992,24 @@ function getGroups$1(filter, config, ctx) {
|
|
|
1910
1992
|
return;
|
|
1911
1993
|
}
|
|
1912
1994
|
convertHeadingToParagraphIfNeeded$1(ctx2);
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1995
|
+
const result = wrapInList(bulletList)(view.state, (tr) => {
|
|
1996
|
+
tr.doc.nodesBetween(
|
|
1997
|
+
tr.mapping.map(from),
|
|
1998
|
+
tr.mapping.map(to),
|
|
1999
|
+
(node, pos) => {
|
|
2000
|
+
if (node.type === listItem) {
|
|
2001
|
+
tr.setNodeMarkup(pos, void 0, {
|
|
2002
|
+
...node.attrs,
|
|
2003
|
+
checked: false,
|
|
2004
|
+
listType: "bullet",
|
|
2005
|
+
label: "\u2022"
|
|
2006
|
+
});
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
);
|
|
2010
|
+
view.dispatch(tr);
|
|
1916
2011
|
});
|
|
2012
|
+
if (result) return;
|
|
1917
2013
|
}
|
|
1918
2014
|
});
|
|
1919
2015
|
}
|
|
@@ -3169,7 +3265,7 @@ var __accessCheck$5 = (obj, member, msg) => member.has(obj) || __typeError$5("Ca
|
|
|
3169
3265
|
var __privateGet$5 = (obj, member, getter) => (__accessCheck$5(obj, member, "read from private field"), member.get(obj));
|
|
3170
3266
|
var __privateAdd$5 = (obj, member, value) => member.has(obj) ? __typeError$5("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
3171
3267
|
var __privateSet$5 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value);
|
|
3172
|
-
var _content$4, _app$4, _filter, _slashProvider, _activeKey, _view, _programmaticallyPos, _mode, _hideTimeout, _isMenuHovered, _keepOpenUntilClickOutside;
|
|
3268
|
+
var _content$4, _app$4, _filter, _slashProvider, _activeKey, _view$1, _programmaticallyPos, _mode, _hideTimeout, _isMenuHovered, _keepOpenUntilClickOutside;
|
|
3173
3269
|
const menu = slashFactory("CREPE_MENU");
|
|
3174
3270
|
function configureMenu(ctx, config) {
|
|
3175
3271
|
ctx.set(menu.key, {
|
|
@@ -3183,7 +3279,7 @@ class MenuView {
|
|
|
3183
3279
|
__privateAdd$5(this, _filter);
|
|
3184
3280
|
__privateAdd$5(this, _slashProvider);
|
|
3185
3281
|
__privateAdd$5(this, _activeKey);
|
|
3186
|
-
__privateAdd$5(this, _view);
|
|
3282
|
+
__privateAdd$5(this, _view$1);
|
|
3187
3283
|
__privateAdd$5(this, _programmaticallyPos, null);
|
|
3188
3284
|
__privateAdd$5(this, _mode, null);
|
|
3189
3285
|
__privateAdd$5(this, _hideTimeout);
|
|
@@ -3212,7 +3308,7 @@ class MenuView {
|
|
|
3212
3308
|
__privateSet$5(this, _programmaticallyPos, pos);
|
|
3213
3309
|
__privateSet$5(this, _mode, mode);
|
|
3214
3310
|
__privateGet$5(this, _filter).value = "";
|
|
3215
|
-
const node = __privateGet$5(this, _view).state.doc.nodeAt(pos);
|
|
3311
|
+
const node = __privateGet$5(this, _view$1).state.doc.nodeAt(pos);
|
|
3216
3312
|
if (node) {
|
|
3217
3313
|
__privateGet$5(this, _activeKey).value = getBlockKey(node);
|
|
3218
3314
|
} else {
|
|
@@ -3260,7 +3356,7 @@ class MenuView {
|
|
|
3260
3356
|
__privateGet$5(this, _app$4).unmount();
|
|
3261
3357
|
__privateGet$5(this, _content$4).remove();
|
|
3262
3358
|
};
|
|
3263
|
-
__privateSet$5(this, _view, view);
|
|
3359
|
+
__privateSet$5(this, _view$1, view);
|
|
3264
3360
|
const content = document.createElement("div");
|
|
3265
3361
|
content.classList.add("milkdown-slash-menu");
|
|
3266
3362
|
const show = ref(false);
|
|
@@ -3347,7 +3443,7 @@ _app$4 = new WeakMap();
|
|
|
3347
3443
|
_filter = new WeakMap();
|
|
3348
3444
|
_slashProvider = new WeakMap();
|
|
3349
3445
|
_activeKey = new WeakMap();
|
|
3350
|
-
_view = new WeakMap();
|
|
3446
|
+
_view$1 = new WeakMap();
|
|
3351
3447
|
_programmaticallyPos = new WeakMap();
|
|
3352
3448
|
_mode = new WeakMap();
|
|
3353
3449
|
_hideTimeout = new WeakMap();
|
|
@@ -3799,7 +3895,9 @@ const codeMirror = (editor, config = {}) => {
|
|
|
3799
3895
|
},
|
|
3800
3896
|
previewLabel: config.previewLabel || i18n(ctx, "codeMirror.previewLabel"),
|
|
3801
3897
|
previewLoading: config.previewLoading || defaultConfig.previewLoading,
|
|
3802
|
-
previewOnlyByDefault: (_a = config.previewOnlyByDefault) != null ? _a : defaultConfig.previewOnlyByDefault
|
|
3898
|
+
previewOnlyByDefault: (_a = config.previewOnlyByDefault) != null ? _a : defaultConfig.previewOnlyByDefault,
|
|
3899
|
+
wrapText: config.wrapText || i18n(ctx, "codeMirror.wrapText"),
|
|
3900
|
+
wrapIcon: config.wrapIcon || wordWrapIcon
|
|
3803
3901
|
};
|
|
3804
3902
|
});
|
|
3805
3903
|
}).use(codeBlockComponent);
|
|
@@ -6856,6 +6954,11 @@ function randomCover(custom) {
|
|
|
6856
6954
|
return (_a = images[Math.floor(Math.random() * images.length)]) != null ? _a : "";
|
|
6857
6955
|
}
|
|
6858
6956
|
|
|
6957
|
+
const editorWidthMap = {
|
|
6958
|
+
default: "820px",
|
|
6959
|
+
wide: "1020px",
|
|
6960
|
+
full: "none"
|
|
6961
|
+
};
|
|
6859
6962
|
const createViewMenuState = () => reactive({
|
|
6860
6963
|
outlineVisible: false,
|
|
6861
6964
|
outlinePosition: "left",
|
|
@@ -6863,7 +6966,8 @@ const createViewMenuState = () => reactive({
|
|
|
6863
6966
|
documentBackground: null,
|
|
6864
6967
|
showTitle: false,
|
|
6865
6968
|
showCover: false,
|
|
6866
|
-
coverUrl: ""
|
|
6969
|
+
coverUrl: "",
|
|
6970
|
+
editorWidth: "default"
|
|
6867
6971
|
});
|
|
6868
6972
|
const viewMenuStateCtx = $ctx(createViewMenuState(), "viewMenuStateCtx");
|
|
6869
6973
|
|
|
@@ -6947,7 +7051,7 @@ const MenuBar = defineComponent({
|
|
|
6947
7051
|
activeSubmenu.value = menuKey;
|
|
6948
7052
|
};
|
|
6949
7053
|
const closeMenu = (e) => {
|
|
6950
|
-
if (showMenu.value && containerRef.value && !containerRef.value.contains(e.target)) {
|
|
7054
|
+
if (showMenu.value && containerRef.value && !containerRef.value.contains(e.target) && mainRef.value && !mainRef.value.contains(e.target)) {
|
|
6951
7055
|
showMenu.value = false;
|
|
6952
7056
|
activeSubmenu.value = null;
|
|
6953
7057
|
if (rafId) cancelAnimationFrame(rafId);
|
|
@@ -6984,7 +7088,7 @@ const MenuBar = defineComponent({
|
|
|
6984
7088
|
style: {
|
|
6985
7089
|
display: "flex",
|
|
6986
7090
|
alignItems: "center",
|
|
6987
|
-
padding: "0
|
|
7091
|
+
padding: "0 6px 0 0",
|
|
6988
7092
|
position: "relative"
|
|
6989
7093
|
}
|
|
6990
7094
|
},
|
|
@@ -7067,6 +7171,11 @@ const MenuBar = defineComponent({
|
|
|
7067
7171
|
{
|
|
7068
7172
|
key: menuKey,
|
|
7069
7173
|
onMouseenter: () => onMouseEnterItem(menuKey),
|
|
7174
|
+
onMouseleave: () => {
|
|
7175
|
+
if (hasSubmenu(menuKey)) {
|
|
7176
|
+
activeSubmenu.value = null;
|
|
7177
|
+
}
|
|
7178
|
+
},
|
|
7070
7179
|
style: {
|
|
7071
7180
|
position: "relative",
|
|
7072
7181
|
padding: "8px 16px",
|
|
@@ -7314,6 +7423,82 @@ const MenuBar = defineComponent({
|
|
|
7314
7423
|
)
|
|
7315
7424
|
) : null
|
|
7316
7425
|
))
|
|
7426
|
+
),
|
|
7427
|
+
/* @__PURE__ */ h(
|
|
7428
|
+
"div",
|
|
7429
|
+
{
|
|
7430
|
+
style: {
|
|
7431
|
+
height: "1px",
|
|
7432
|
+
background: "var(--crepe-color-outline-variant, #eee)",
|
|
7433
|
+
margin: "4px 0"
|
|
7434
|
+
}
|
|
7435
|
+
}
|
|
7436
|
+
),
|
|
7437
|
+
/* @__PURE__ */ h(
|
|
7438
|
+
"div",
|
|
7439
|
+
{
|
|
7440
|
+
style: {
|
|
7441
|
+
padding: "8px 16px",
|
|
7442
|
+
display: "flex",
|
|
7443
|
+
justifyContent: "space-between",
|
|
7444
|
+
alignItems: "center"
|
|
7445
|
+
}
|
|
7446
|
+
},
|
|
7447
|
+
/* @__PURE__ */ h(
|
|
7448
|
+
"span",
|
|
7449
|
+
{
|
|
7450
|
+
style: {
|
|
7451
|
+
fontSize: "14px",
|
|
7452
|
+
color: "var(--crepe-color-on-surface, #333)"
|
|
7453
|
+
}
|
|
7454
|
+
},
|
|
7455
|
+
i18n(props.ctx, "view.editorWidth") || "\u5185\u5BB9\u5BBD\u5EA6"
|
|
7456
|
+
)
|
|
7457
|
+
),
|
|
7458
|
+
/* @__PURE__ */ h(
|
|
7459
|
+
"div",
|
|
7460
|
+
{
|
|
7461
|
+
style: {
|
|
7462
|
+
padding: "4px 16px 8px",
|
|
7463
|
+
display: "flex",
|
|
7464
|
+
gap: "6px"
|
|
7465
|
+
}
|
|
7466
|
+
},
|
|
7467
|
+
[
|
|
7468
|
+
{
|
|
7469
|
+
key: "default",
|
|
7470
|
+
labelKey: "view.widthDefault"
|
|
7471
|
+
},
|
|
7472
|
+
{
|
|
7473
|
+
key: "wide",
|
|
7474
|
+
labelKey: "view.widthWide"
|
|
7475
|
+
},
|
|
7476
|
+
{
|
|
7477
|
+
key: "full",
|
|
7478
|
+
labelKey: "view.widthFull"
|
|
7479
|
+
}
|
|
7480
|
+
].map(({ key, labelKey }) => /* @__PURE__ */ h(
|
|
7481
|
+
"button",
|
|
7482
|
+
{
|
|
7483
|
+
key,
|
|
7484
|
+
type: "button",
|
|
7485
|
+
onClick: (e) => {
|
|
7486
|
+
e.stopPropagation();
|
|
7487
|
+
state.editorWidth = key;
|
|
7488
|
+
},
|
|
7489
|
+
style: {
|
|
7490
|
+
flex: 1,
|
|
7491
|
+
padding: "4px 0",
|
|
7492
|
+
fontSize: "12px",
|
|
7493
|
+
cursor: "pointer",
|
|
7494
|
+
borderRadius: "4px",
|
|
7495
|
+
border: state.editorWidth === key ? "1px solid var(--crepe-color-primary, #1890ff)" : "1px solid var(--crepe-color-outline-variant, #e8e8e8)",
|
|
7496
|
+
background: state.editorWidth === key ? "var(--crepe-color-primary, #1890ff)" : "transparent",
|
|
7497
|
+
color: state.editorWidth === key ? "#fff" : "var(--crepe-color-on-surface, #333)"
|
|
7498
|
+
}
|
|
7499
|
+
},
|
|
7500
|
+
i18n(props.ctx, labelKey) || key
|
|
7501
|
+
))
|
|
7317
7502
|
)
|
|
7318
7503
|
) : null
|
|
7319
7504
|
);
|
|
@@ -7324,6 +7509,191 @@ const MenuBar = defineComponent({
|
|
|
7324
7509
|
}
|
|
7325
7510
|
});
|
|
7326
7511
|
|
|
7512
|
+
const isMac = typeof navigator !== "undefined" && /Mac|iPod|iPhone|iPad/.test(navigator.platform || navigator.userAgent);
|
|
7513
|
+
function fmt(shortcut) {
|
|
7514
|
+
return shortcut.replace(/Mod/g, isMac ? "\u2318" : "Ctrl").replace(/\+/g, isMac ? "" : "+").replace(/Shift/g, isMac ? "\u21E7" : "Shift").replace(/Alt/g, isMac ? "\u2325" : "Alt");
|
|
7515
|
+
}
|
|
7516
|
+
const leftGroups = [
|
|
7517
|
+
{
|
|
7518
|
+
titleKey: "shortcuts.formatting",
|
|
7519
|
+
items: [
|
|
7520
|
+
{ labelKey: "shortcuts.bold", keys: ["Mod+b"] },
|
|
7521
|
+
{ labelKey: "shortcuts.italic", keys: ["Mod+i"] },
|
|
7522
|
+
{ labelKey: "shortcuts.underline", keys: ["Mod+u"] },
|
|
7523
|
+
{ labelKey: "shortcuts.strikethrough", keys: ["Mod+Alt+x"] },
|
|
7524
|
+
{ labelKey: "shortcuts.inlineCode", keys: ["Mod+e"] },
|
|
7525
|
+
{ labelKey: "shortcuts.highlight", keys: ["Mod+Shift+h"] }
|
|
7526
|
+
]
|
|
7527
|
+
},
|
|
7528
|
+
{
|
|
7529
|
+
titleKey: "shortcuts.paragraph",
|
|
7530
|
+
items: [
|
|
7531
|
+
{ labelKey: "shortcuts.paragraph", keys: ["Mod+Alt+0"] },
|
|
7532
|
+
{ labelKey: "shortcuts.heading", keys: ["Mod+Alt+1~6"] }
|
|
7533
|
+
]
|
|
7534
|
+
}
|
|
7535
|
+
];
|
|
7536
|
+
const rightGroups = [
|
|
7537
|
+
{
|
|
7538
|
+
titleKey: "shortcuts.block",
|
|
7539
|
+
items: [
|
|
7540
|
+
{ labelKey: "shortcuts.codeBlock", keys: ["Mod+Alt+c"] },
|
|
7541
|
+
{ labelKey: "shortcuts.blockquote", keys: ["Mod+Shift+b"] },
|
|
7542
|
+
{ labelKey: "shortcuts.orderedList", keys: ["Mod+Alt+7"] },
|
|
7543
|
+
{ labelKey: "shortcuts.bulletList", keys: ["Mod+Alt+8"] },
|
|
7544
|
+
{ labelKey: "shortcuts.indent", keys: ["Tab", "Mod+]"] },
|
|
7545
|
+
{ labelKey: "shortcuts.outdent", keys: ["Shift+Tab", "Mod+["] },
|
|
7546
|
+
{ labelKey: "shortcuts.hardBreak", keys: ["Shift+Enter"] }
|
|
7547
|
+
]
|
|
7548
|
+
},
|
|
7549
|
+
{
|
|
7550
|
+
titleKey: "shortcuts.history",
|
|
7551
|
+
items: [
|
|
7552
|
+
{ labelKey: "shortcuts.undo", keys: ["Mod+z"] },
|
|
7553
|
+
{ labelKey: "shortcuts.redo", keys: ["Mod+y", "Shift+Mod+z"] }
|
|
7554
|
+
]
|
|
7555
|
+
}
|
|
7556
|
+
];
|
|
7557
|
+
const badgeStyle = {
|
|
7558
|
+
display: "inline-flex",
|
|
7559
|
+
alignItems: "center",
|
|
7560
|
+
justifyContent: "center",
|
|
7561
|
+
minWidth: "22px",
|
|
7562
|
+
height: "22px",
|
|
7563
|
+
padding: "0 6px",
|
|
7564
|
+
borderRadius: "4px",
|
|
7565
|
+
fontSize: "11px",
|
|
7566
|
+
fontFamily: "var(--crepe-font-code, monospace)",
|
|
7567
|
+
backgroundColor: "var(--crepe-color-surface-low, color-mix(in srgb, var(--crepe-color-surface), transparent 60%))",
|
|
7568
|
+
border: "1px solid var(--crepe-color-outline-variant, color-mix(in srgb, var(--crepe-color-outline), transparent 80%))",
|
|
7569
|
+
whiteSpace: "nowrap"
|
|
7570
|
+
};
|
|
7571
|
+
const columnStyle = {
|
|
7572
|
+
flex: 1,
|
|
7573
|
+
minWidth: 0
|
|
7574
|
+
};
|
|
7575
|
+
const groupTitleStyle = {
|
|
7576
|
+
fontSize: "11px",
|
|
7577
|
+
fontWeight: 600,
|
|
7578
|
+
color: "var(--crepe-color-on-surface-variant, #888)",
|
|
7579
|
+
marginBottom: "8px",
|
|
7580
|
+
textTransform: "uppercase",
|
|
7581
|
+
letterSpacing: "0.5px"
|
|
7582
|
+
};
|
|
7583
|
+
const rowStyle = {
|
|
7584
|
+
display: "flex",
|
|
7585
|
+
alignItems: "center",
|
|
7586
|
+
justifyContent: "space-between",
|
|
7587
|
+
padding: "5px 0"
|
|
7588
|
+
};
|
|
7589
|
+
const labelStyle = {
|
|
7590
|
+
fontSize: "13px",
|
|
7591
|
+
color: "var(--crepe-color-on-surface, #333)"
|
|
7592
|
+
};
|
|
7593
|
+
function renderGroup(ctx, group) {
|
|
7594
|
+
return /* @__PURE__ */ h("div", { style: { marginBottom: "16px" }, key: group.titleKey }, /* @__PURE__ */ h("div", { style: groupTitleStyle }, i18n(ctx, group.titleKey)), /* @__PURE__ */ h("div", { style: { display: "flex", flexDirection: "column" } }, group.items.map((item) => /* @__PURE__ */ h("div", { key: item.labelKey, style: rowStyle }, /* @__PURE__ */ h("span", { style: labelStyle }, i18n(ctx, item.labelKey)), /* @__PURE__ */ h("div", { style: { display: "flex", gap: "4px", alignItems: "center" } }, item.keys.map((key, i) => /* @__PURE__ */ h("span", { key: i, style: badgeStyle }, fmt(key))))))));
|
|
7595
|
+
}
|
|
7596
|
+
const ShortcutHelpModal = defineComponent({
|
|
7597
|
+
props: {
|
|
7598
|
+
ctx: { type: Object, required: true },
|
|
7599
|
+
visible: { type: Object, required: true }
|
|
7600
|
+
},
|
|
7601
|
+
setup(props) {
|
|
7602
|
+
const close = () => {
|
|
7603
|
+
props.visible.value = false;
|
|
7604
|
+
};
|
|
7605
|
+
const onKeydown = (e) => {
|
|
7606
|
+
if (e.key === "Escape") close();
|
|
7607
|
+
};
|
|
7608
|
+
onMounted(() => document.addEventListener("keydown", onKeydown));
|
|
7609
|
+
onBeforeUnmount(() => document.removeEventListener("keydown", onKeydown));
|
|
7610
|
+
return () => /* @__PURE__ */ h(
|
|
7611
|
+
"div",
|
|
7612
|
+
{
|
|
7613
|
+
style: {
|
|
7614
|
+
position: "fixed",
|
|
7615
|
+
inset: 0,
|
|
7616
|
+
zIndex: 1e4,
|
|
7617
|
+
background: "rgba(0, 0, 0, 0.4)",
|
|
7618
|
+
display: "flex",
|
|
7619
|
+
alignItems: "center",
|
|
7620
|
+
justifyContent: "center"
|
|
7621
|
+
},
|
|
7622
|
+
onClick: close
|
|
7623
|
+
},
|
|
7624
|
+
/* @__PURE__ */ h(
|
|
7625
|
+
"div",
|
|
7626
|
+
{
|
|
7627
|
+
style: {
|
|
7628
|
+
position: "relative",
|
|
7629
|
+
width: "560px",
|
|
7630
|
+
maxWidth: "calc(100vw - 32px)",
|
|
7631
|
+
background: "var(--crepe-color-surface, #fff)",
|
|
7632
|
+
borderRadius: "12px",
|
|
7633
|
+
boxShadow: "0 8px 32px rgba(0, 0, 0, 0.15)",
|
|
7634
|
+
padding: "20px 24px"
|
|
7635
|
+
},
|
|
7636
|
+
onClick: (e) => e.stopPropagation()
|
|
7637
|
+
},
|
|
7638
|
+
/* @__PURE__ */ h(
|
|
7639
|
+
"div",
|
|
7640
|
+
{
|
|
7641
|
+
style: {
|
|
7642
|
+
display: "flex",
|
|
7643
|
+
alignItems: "center",
|
|
7644
|
+
justifyContent: "space-between",
|
|
7645
|
+
marginBottom: "16px",
|
|
7646
|
+
paddingBottom: "12px",
|
|
7647
|
+
borderBottom: "1px solid var(--crepe-color-outline-variant, color-mix(in srgb, var(--crepe-color-outline), transparent 80%))"
|
|
7648
|
+
}
|
|
7649
|
+
},
|
|
7650
|
+
/* @__PURE__ */ h(
|
|
7651
|
+
"span",
|
|
7652
|
+
{
|
|
7653
|
+
style: {
|
|
7654
|
+
fontSize: "15px",
|
|
7655
|
+
fontWeight: 600,
|
|
7656
|
+
color: "var(--crepe-color-on-surface, #1a1a1a)"
|
|
7657
|
+
}
|
|
7658
|
+
},
|
|
7659
|
+
i18n(props.ctx, "shortcuts.title")
|
|
7660
|
+
),
|
|
7661
|
+
/* @__PURE__ */ h(
|
|
7662
|
+
"button",
|
|
7663
|
+
{
|
|
7664
|
+
type: "button",
|
|
7665
|
+
onClick: close,
|
|
7666
|
+
style: {
|
|
7667
|
+
display: "inline-flex",
|
|
7668
|
+
alignItems: "center",
|
|
7669
|
+
justifyContent: "center",
|
|
7670
|
+
width: "28px",
|
|
7671
|
+
height: "28px",
|
|
7672
|
+
border: "none",
|
|
7673
|
+
background: "transparent",
|
|
7674
|
+
cursor: "pointer",
|
|
7675
|
+
borderRadius: "4px",
|
|
7676
|
+
color: "var(--crepe-color-on-surface-variant, #666)"
|
|
7677
|
+
}
|
|
7678
|
+
},
|
|
7679
|
+
/* @__PURE__ */ h(Icon, { icon: closeIcon })
|
|
7680
|
+
)
|
|
7681
|
+
),
|
|
7682
|
+
/* @__PURE__ */ h("div", { style: { display: "flex", gap: "24px" } }, /* @__PURE__ */ h("div", { style: columnStyle }, leftGroups.map((g) => renderGroup(props.ctx, g))), /* @__PURE__ */ h(
|
|
7683
|
+
"div",
|
|
7684
|
+
{
|
|
7685
|
+
style: {
|
|
7686
|
+
width: "1px",
|
|
7687
|
+
flexShrink: 0,
|
|
7688
|
+
backgroundColor: "var(--crepe-color-outline-variant, color-mix(in srgb, var(--crepe-color-outline), transparent 80%))"
|
|
7689
|
+
}
|
|
7690
|
+
}
|
|
7691
|
+
), /* @__PURE__ */ h("div", { style: columnStyle }, rightGroups.map((g) => renderGroup(props.ctx, g))))
|
|
7692
|
+
)
|
|
7693
|
+
);
|
|
7694
|
+
}
|
|
7695
|
+
});
|
|
7696
|
+
|
|
7327
7697
|
const FixedToolbarComponent = defineComponent({
|
|
7328
7698
|
props: {
|
|
7329
7699
|
ctx: { type: Object, required: true },
|
|
@@ -7333,6 +7703,7 @@ const FixedToolbarComponent = defineComponent({
|
|
|
7333
7703
|
config: { type: Object, required: false }
|
|
7334
7704
|
},
|
|
7335
7705
|
setup(props) {
|
|
7706
|
+
const showShortcuts = ref(false);
|
|
7336
7707
|
return () => /* @__PURE__ */ h(
|
|
7337
7708
|
"div",
|
|
7338
7709
|
{
|
|
@@ -7341,7 +7712,7 @@ const FixedToolbarComponent = defineComponent({
|
|
|
7341
7712
|
alignItems: "center",
|
|
7342
7713
|
justifyContent: "center",
|
|
7343
7714
|
width: "100%",
|
|
7344
|
-
gap: "
|
|
7715
|
+
gap: "0px"
|
|
7345
7716
|
}
|
|
7346
7717
|
},
|
|
7347
7718
|
/* @__PURE__ */ h(MenuBar, { ctx: props.ctx, config: props.config }),
|
|
@@ -7366,7 +7737,32 @@ const FixedToolbarComponent = defineComponent({
|
|
|
7366
7737
|
config: props.config,
|
|
7367
7738
|
isFixed: true
|
|
7368
7739
|
}
|
|
7369
|
-
)
|
|
7740
|
+
),
|
|
7741
|
+
/* @__PURE__ */ h(
|
|
7742
|
+
"div",
|
|
7743
|
+
{
|
|
7744
|
+
style: {
|
|
7745
|
+
width: "1px",
|
|
7746
|
+
minWidth: "1px",
|
|
7747
|
+
height: "20px",
|
|
7748
|
+
flexShrink: 0,
|
|
7749
|
+
backgroundColor: "var(--crepe-color-outline-variant, color-mix(in srgb, var(--crepe-color-outline), transparent 80%))"
|
|
7750
|
+
}
|
|
7751
|
+
}
|
|
7752
|
+
),
|
|
7753
|
+
/* @__PURE__ */ h(
|
|
7754
|
+
"button",
|
|
7755
|
+
{
|
|
7756
|
+
type: "button",
|
|
7757
|
+
class: "toolbar-shortcut-btn",
|
|
7758
|
+
title: i18n(props.ctx, "shortcuts.title"),
|
|
7759
|
+
onClick: () => {
|
|
7760
|
+
showShortcuts.value = true;
|
|
7761
|
+
}
|
|
7762
|
+
},
|
|
7763
|
+
/* @__PURE__ */ h(Icon, { icon: keyboardIcon })
|
|
7764
|
+
),
|
|
7765
|
+
showShortcuts.value && /* @__PURE__ */ h(ShortcutHelpModal, { ctx: props.ctx, visible: showShortcuts })
|
|
7370
7766
|
);
|
|
7371
7767
|
}
|
|
7372
7768
|
});
|
|
@@ -7736,10 +8132,24 @@ function buildDefaultFixedToolbar(builder, _config, ctx) {
|
|
|
7736
8132
|
return;
|
|
7737
8133
|
}
|
|
7738
8134
|
convertHeadingToParagraphIfNeeded(ctx2);
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
8135
|
+
const result = wrapInList(bulletList)(view.state, (tr) => {
|
|
8136
|
+
tr.doc.nodesBetween(
|
|
8137
|
+
tr.mapping.map(from),
|
|
8138
|
+
tr.mapping.map(to),
|
|
8139
|
+
(node, pos) => {
|
|
8140
|
+
if (node.type === listItem) {
|
|
8141
|
+
tr.setNodeMarkup(pos, void 0, {
|
|
8142
|
+
...node.attrs,
|
|
8143
|
+
checked: false,
|
|
8144
|
+
listType: "bullet",
|
|
8145
|
+
label: "\u2022"
|
|
8146
|
+
});
|
|
8147
|
+
}
|
|
8148
|
+
}
|
|
8149
|
+
);
|
|
8150
|
+
view.dispatch(tr);
|
|
7742
8151
|
});
|
|
8152
|
+
if (result) return;
|
|
7743
8153
|
}
|
|
7744
8154
|
});
|
|
7745
8155
|
}
|
|
@@ -7966,10 +8376,9 @@ const DocumentHeader = defineComponent({
|
|
|
7966
8376
|
class: "milkdown-document-title-wrapper",
|
|
7967
8377
|
style: {
|
|
7968
8378
|
width: "100%",
|
|
7969
|
-
|
|
7970
|
-
|
|
7971
|
-
padding:
|
|
7972
|
-
// Match ProseMirror padding
|
|
8379
|
+
maxWidth: editorWidthMap[state.editorWidth] === "none" ? void 0 : editorWidthMap[state.editorWidth],
|
|
8380
|
+
margin: editorWidthMap[state.editorWidth] === "none" ? "0" : "0 auto",
|
|
8381
|
+
padding: `40px ${editorWidthMap[state.editorWidth] === "none" ? "80px" : "0"} 0`
|
|
7973
8382
|
}
|
|
7974
8383
|
},
|
|
7975
8384
|
/* @__PURE__ */ h("style", null, `.milkdown-document-title::placeholder { color: #BFBFBF; }`),
|
|
@@ -8394,7 +8803,7 @@ var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Ca
|
|
|
8394
8803
|
var __privateGet$3 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
8395
8804
|
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);
|
|
8396
8805
|
var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
|
|
8397
|
-
var _content$2, _app$2, _headerContent, _headerApp, _outlineContent, _outlineApp, _watcher, _selection$1, _show$1, _resizeObserver, _updateOutlineGeometry, _scrollContainers;
|
|
8806
|
+
var _content$2, _app$2, _headerContent, _headerApp, _outlineContent, _outlineApp, _watcher, _selection$1, _show$1, _resizeObserver, _updateOutlineGeometry, _scrollContainers, _view;
|
|
8398
8807
|
const fixedToolbarConfig = $ctx(
|
|
8399
8808
|
{},
|
|
8400
8809
|
"fixedToolbarConfigCtx"
|
|
@@ -8414,6 +8823,7 @@ class FixedToolbarView {
|
|
|
8414
8823
|
__privateAdd$3(this, _resizeObserver);
|
|
8415
8824
|
__privateAdd$3(this, _updateOutlineGeometry);
|
|
8416
8825
|
__privateAdd$3(this, _scrollContainers, []);
|
|
8826
|
+
__privateAdd$3(this, _view);
|
|
8417
8827
|
this.update = (view) => {
|
|
8418
8828
|
__privateGet$3(this, _selection$1).value = view.state.selection;
|
|
8419
8829
|
};
|
|
@@ -8435,6 +8845,7 @@ class FixedToolbarView {
|
|
|
8435
8845
|
if (__privateGet$3(this, _outlineApp)) __privateGet$3(this, _outlineApp).unmount();
|
|
8436
8846
|
if (__privateGet$3(this, _outlineContent)) __privateGet$3(this, _outlineContent).remove();
|
|
8437
8847
|
};
|
|
8848
|
+
__privateSet$3(this, _view, view);
|
|
8438
8849
|
const config = ctx.get(fixedToolbarConfig.key);
|
|
8439
8850
|
const content = document.createElement("div");
|
|
8440
8851
|
content.className = "milkdown-fixed-toolbar";
|
|
@@ -8530,7 +8941,8 @@ class FixedToolbarView {
|
|
|
8530
8941
|
viewState.outlinePosition,
|
|
8531
8942
|
viewState.outlineWidth,
|
|
8532
8943
|
viewState.documentBackground,
|
|
8533
|
-
viewState.showCover
|
|
8944
|
+
viewState.showCover,
|
|
8945
|
+
viewState.editorWidth
|
|
8534
8946
|
],
|
|
8535
8947
|
() => {
|
|
8536
8948
|
if (viewState.documentBackground) {
|
|
@@ -8559,6 +8971,17 @@ class FixedToolbarView {
|
|
|
8559
8971
|
__privateGet$3(this, _content$2).style.marginLeft = "0";
|
|
8560
8972
|
__privateGet$3(this, _content$2).style.marginRight = "0";
|
|
8561
8973
|
}
|
|
8974
|
+
const maxWidth = editorWidthMap[viewState.editorWidth];
|
|
8975
|
+
const isFull = maxWidth === "none";
|
|
8976
|
+
const px = isFull ? "80px" : "0";
|
|
8977
|
+
__privateGet$3(this, _view).dom.style.maxWidth = maxWidth;
|
|
8978
|
+
__privateGet$3(this, _view).dom.style.width = isFull ? "100%" : maxWidth;
|
|
8979
|
+
__privateGet$3(this, _view).dom.style.margin = isFull ? "0" : "0 auto";
|
|
8980
|
+
__privateGet$3(this, _view).dom.style.padding = `20px ${px} 0`;
|
|
8981
|
+
if (__privateGet$3(this, _headerContent)) {
|
|
8982
|
+
__privateGet$3(this, _headerContent).style.margin = isFull ? "0" : "0 auto";
|
|
8983
|
+
__privateGet$3(this, _headerContent).style.padding = `0px`;
|
|
8984
|
+
}
|
|
8562
8985
|
nextTick(() => {
|
|
8563
8986
|
var _a;
|
|
8564
8987
|
(_a = __privateGet$3(this, _updateOutlineGeometry)) == null ? void 0 : _a.call(this);
|
|
@@ -8581,6 +9004,7 @@ _show$1 = new WeakMap();
|
|
|
8581
9004
|
_resizeObserver = new WeakMap();
|
|
8582
9005
|
_updateOutlineGeometry = new WeakMap();
|
|
8583
9006
|
_scrollContainers = new WeakMap();
|
|
9007
|
+
_view = new WeakMap();
|
|
8584
9008
|
const fixedToolbarPlugin = $prose((ctx) => {
|
|
8585
9009
|
return new Plugin({
|
|
8586
9010
|
key: fixedToolbarKey,
|
|
@@ -8620,17 +9044,19 @@ const imageBlock = (editor, config) => {
|
|
|
8620
9044
|
};
|
|
8621
9045
|
});
|
|
8622
9046
|
ctx.update(imageBlockConfig.key, (value) => {
|
|
8623
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
9047
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
8624
9048
|
return {
|
|
8625
9049
|
uploadButton: (_a = config == null ? void 0 : config.blockUploadButton) != null ? _a : i18n(ctx, "imageBlock.blockUploadButton"),
|
|
8626
9050
|
imageIcon: (_b = config == null ? void 0 : config.blockImageIcon) != null ? _b : imageIcon,
|
|
8627
9051
|
captionIcon: (_c = config == null ? void 0 : config.blockCaptionIcon) != null ? _c : captionIcon,
|
|
8628
|
-
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
|
|
9052
|
+
cropIcon: (_d = config == null ? void 0 : config.blockCropIcon) != null ? _d : cropIcon,
|
|
9053
|
+
borderIcon: (_e = config == null ? void 0 : config.blockBorderIcon) != null ? _e : borderIcon,
|
|
9054
|
+
confirmButton: (_f = config == null ? void 0 : config.blockConfirmButton) != null ? _f : i18n(ctx, "imageBlock.blockConfirmButton"),
|
|
9055
|
+
captionPlaceholderText: (_g = config == null ? void 0 : config.blockCaptionPlaceholderText) != null ? _g : i18n(ctx, "imageBlock.blockCaptionPlaceholder"),
|
|
9056
|
+
uploadPlaceholderText: (_h = config == null ? void 0 : config.blockUploadPlaceholderText) != null ? _h : i18n(ctx, "imageBlock.blockUploadPlaceholder"),
|
|
9057
|
+
onUpload: (_j = (_i = config == null ? void 0 : config.blockOnUpload) != null ? _i : config == null ? void 0 : config.onUpload) != null ? _j : value.onUpload,
|
|
8632
9058
|
proxyDomURL: config == null ? void 0 : config.proxyDomURL,
|
|
8633
|
-
onImageLoadError: (
|
|
9059
|
+
onImageLoadError: (_k = config == null ? void 0 : config.onImageLoadError) != null ? _k : value.onImageLoadError,
|
|
8634
9060
|
maxWidth: config == null ? void 0 : config.maxWidth,
|
|
8635
9061
|
maxHeight: config == null ? void 0 : config.maxHeight
|
|
8636
9062
|
};
|