@jvs-milkdown/crepe 1.2.0 → 1.2.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/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 +451 -30
- 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 +452 -31
- package/lib/esm/index.js.map +1 -1
- package/lib/theme/common/code-mirror.css +13 -0
- package/lib/theme/common/image-block.css +321 -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 +83 -2
- 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 +364 -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
|
|
|
@@ -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
|
},
|
|
@@ -7314,6 +7418,82 @@ const MenuBar = defineComponent({
|
|
|
7314
7418
|
)
|
|
7315
7419
|
) : null
|
|
7316
7420
|
))
|
|
7421
|
+
),
|
|
7422
|
+
/* @__PURE__ */ h(
|
|
7423
|
+
"div",
|
|
7424
|
+
{
|
|
7425
|
+
style: {
|
|
7426
|
+
height: "1px",
|
|
7427
|
+
background: "var(--crepe-color-outline-variant, #eee)",
|
|
7428
|
+
margin: "4px 0"
|
|
7429
|
+
}
|
|
7430
|
+
}
|
|
7431
|
+
),
|
|
7432
|
+
/* @__PURE__ */ h(
|
|
7433
|
+
"div",
|
|
7434
|
+
{
|
|
7435
|
+
style: {
|
|
7436
|
+
padding: "8px 16px",
|
|
7437
|
+
display: "flex",
|
|
7438
|
+
justifyContent: "space-between",
|
|
7439
|
+
alignItems: "center"
|
|
7440
|
+
}
|
|
7441
|
+
},
|
|
7442
|
+
/* @__PURE__ */ h(
|
|
7443
|
+
"span",
|
|
7444
|
+
{
|
|
7445
|
+
style: {
|
|
7446
|
+
fontSize: "14px",
|
|
7447
|
+
color: "var(--crepe-color-on-surface, #333)"
|
|
7448
|
+
}
|
|
7449
|
+
},
|
|
7450
|
+
i18n(props.ctx, "view.editorWidth") || "\u5185\u5BB9\u5BBD\u5EA6"
|
|
7451
|
+
)
|
|
7452
|
+
),
|
|
7453
|
+
/* @__PURE__ */ h(
|
|
7454
|
+
"div",
|
|
7455
|
+
{
|
|
7456
|
+
style: {
|
|
7457
|
+
padding: "4px 16px 8px",
|
|
7458
|
+
display: "flex",
|
|
7459
|
+
gap: "6px"
|
|
7460
|
+
}
|
|
7461
|
+
},
|
|
7462
|
+
[
|
|
7463
|
+
{
|
|
7464
|
+
key: "default",
|
|
7465
|
+
labelKey: "view.widthDefault"
|
|
7466
|
+
},
|
|
7467
|
+
{
|
|
7468
|
+
key: "wide",
|
|
7469
|
+
labelKey: "view.widthWide"
|
|
7470
|
+
},
|
|
7471
|
+
{
|
|
7472
|
+
key: "full",
|
|
7473
|
+
labelKey: "view.widthFull"
|
|
7474
|
+
}
|
|
7475
|
+
].map(({ key, labelKey }) => /* @__PURE__ */ h(
|
|
7476
|
+
"button",
|
|
7477
|
+
{
|
|
7478
|
+
key,
|
|
7479
|
+
type: "button",
|
|
7480
|
+
onClick: (e) => {
|
|
7481
|
+
e.stopPropagation();
|
|
7482
|
+
state.editorWidth = key;
|
|
7483
|
+
},
|
|
7484
|
+
style: {
|
|
7485
|
+
flex: 1,
|
|
7486
|
+
padding: "4px 0",
|
|
7487
|
+
fontSize: "12px",
|
|
7488
|
+
cursor: "pointer",
|
|
7489
|
+
borderRadius: "4px",
|
|
7490
|
+
border: state.editorWidth === key ? "1px solid var(--crepe-color-primary, #1890ff)" : "1px solid var(--crepe-color-outline-variant, #e8e8e8)",
|
|
7491
|
+
background: state.editorWidth === key ? "var(--crepe-color-primary, #1890ff)" : "transparent",
|
|
7492
|
+
color: state.editorWidth === key ? "#fff" : "var(--crepe-color-on-surface, #333)"
|
|
7493
|
+
}
|
|
7494
|
+
},
|
|
7495
|
+
i18n(props.ctx, labelKey) || key
|
|
7496
|
+
))
|
|
7317
7497
|
)
|
|
7318
7498
|
) : null
|
|
7319
7499
|
);
|
|
@@ -7324,6 +7504,191 @@ const MenuBar = defineComponent({
|
|
|
7324
7504
|
}
|
|
7325
7505
|
});
|
|
7326
7506
|
|
|
7507
|
+
const isMac = typeof navigator !== "undefined" && /Mac|iPod|iPhone|iPad/.test(navigator.platform || navigator.userAgent);
|
|
7508
|
+
function fmt(shortcut) {
|
|
7509
|
+
return shortcut.replace(/Mod/g, isMac ? "\u2318" : "Ctrl").replace(/\+/g, isMac ? "" : "+").replace(/Shift/g, isMac ? "\u21E7" : "Shift").replace(/Alt/g, isMac ? "\u2325" : "Alt");
|
|
7510
|
+
}
|
|
7511
|
+
const leftGroups = [
|
|
7512
|
+
{
|
|
7513
|
+
titleKey: "shortcuts.formatting",
|
|
7514
|
+
items: [
|
|
7515
|
+
{ labelKey: "shortcuts.bold", keys: ["Mod+b"] },
|
|
7516
|
+
{ labelKey: "shortcuts.italic", keys: ["Mod+i"] },
|
|
7517
|
+
{ labelKey: "shortcuts.underline", keys: ["Mod+u"] },
|
|
7518
|
+
{ labelKey: "shortcuts.strikethrough", keys: ["Mod+Alt+x"] },
|
|
7519
|
+
{ labelKey: "shortcuts.inlineCode", keys: ["Mod+e"] },
|
|
7520
|
+
{ labelKey: "shortcuts.highlight", keys: ["Mod+Shift+h"] }
|
|
7521
|
+
]
|
|
7522
|
+
},
|
|
7523
|
+
{
|
|
7524
|
+
titleKey: "shortcuts.paragraph",
|
|
7525
|
+
items: [
|
|
7526
|
+
{ labelKey: "shortcuts.paragraph", keys: ["Mod+Alt+0"] },
|
|
7527
|
+
{ labelKey: "shortcuts.heading", keys: ["Mod+Alt+1~6"] }
|
|
7528
|
+
]
|
|
7529
|
+
}
|
|
7530
|
+
];
|
|
7531
|
+
const rightGroups = [
|
|
7532
|
+
{
|
|
7533
|
+
titleKey: "shortcuts.block",
|
|
7534
|
+
items: [
|
|
7535
|
+
{ labelKey: "shortcuts.codeBlock", keys: ["Mod+Alt+c"] },
|
|
7536
|
+
{ labelKey: "shortcuts.blockquote", keys: ["Mod+Shift+b"] },
|
|
7537
|
+
{ labelKey: "shortcuts.orderedList", keys: ["Mod+Alt+7"] },
|
|
7538
|
+
{ labelKey: "shortcuts.bulletList", keys: ["Mod+Alt+8"] },
|
|
7539
|
+
{ labelKey: "shortcuts.indent", keys: ["Tab", "Mod+]"] },
|
|
7540
|
+
{ labelKey: "shortcuts.outdent", keys: ["Shift+Tab", "Mod+["] },
|
|
7541
|
+
{ labelKey: "shortcuts.hardBreak", keys: ["Shift+Enter"] }
|
|
7542
|
+
]
|
|
7543
|
+
},
|
|
7544
|
+
{
|
|
7545
|
+
titleKey: "shortcuts.history",
|
|
7546
|
+
items: [
|
|
7547
|
+
{ labelKey: "shortcuts.undo", keys: ["Mod+z"] },
|
|
7548
|
+
{ labelKey: "shortcuts.redo", keys: ["Mod+y", "Shift+Mod+z"] }
|
|
7549
|
+
]
|
|
7550
|
+
}
|
|
7551
|
+
];
|
|
7552
|
+
const badgeStyle = {
|
|
7553
|
+
display: "inline-flex",
|
|
7554
|
+
alignItems: "center",
|
|
7555
|
+
justifyContent: "center",
|
|
7556
|
+
minWidth: "22px",
|
|
7557
|
+
height: "22px",
|
|
7558
|
+
padding: "0 6px",
|
|
7559
|
+
borderRadius: "4px",
|
|
7560
|
+
fontSize: "11px",
|
|
7561
|
+
fontFamily: "var(--crepe-font-code, monospace)",
|
|
7562
|
+
backgroundColor: "var(--crepe-color-surface-low, color-mix(in srgb, var(--crepe-color-surface), transparent 60%))",
|
|
7563
|
+
border: "1px solid var(--crepe-color-outline-variant, color-mix(in srgb, var(--crepe-color-outline), transparent 80%))",
|
|
7564
|
+
whiteSpace: "nowrap"
|
|
7565
|
+
};
|
|
7566
|
+
const columnStyle = {
|
|
7567
|
+
flex: 1,
|
|
7568
|
+
minWidth: 0
|
|
7569
|
+
};
|
|
7570
|
+
const groupTitleStyle = {
|
|
7571
|
+
fontSize: "11px",
|
|
7572
|
+
fontWeight: 600,
|
|
7573
|
+
color: "var(--crepe-color-on-surface-variant, #888)",
|
|
7574
|
+
marginBottom: "8px",
|
|
7575
|
+
textTransform: "uppercase",
|
|
7576
|
+
letterSpacing: "0.5px"
|
|
7577
|
+
};
|
|
7578
|
+
const rowStyle = {
|
|
7579
|
+
display: "flex",
|
|
7580
|
+
alignItems: "center",
|
|
7581
|
+
justifyContent: "space-between",
|
|
7582
|
+
padding: "5px 0"
|
|
7583
|
+
};
|
|
7584
|
+
const labelStyle = {
|
|
7585
|
+
fontSize: "13px",
|
|
7586
|
+
color: "var(--crepe-color-on-surface, #333)"
|
|
7587
|
+
};
|
|
7588
|
+
function renderGroup(ctx, group) {
|
|
7589
|
+
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))))))));
|
|
7590
|
+
}
|
|
7591
|
+
const ShortcutHelpModal = defineComponent({
|
|
7592
|
+
props: {
|
|
7593
|
+
ctx: { type: Object, required: true },
|
|
7594
|
+
visible: { type: Object, required: true }
|
|
7595
|
+
},
|
|
7596
|
+
setup(props) {
|
|
7597
|
+
const close = () => {
|
|
7598
|
+
props.visible.value = false;
|
|
7599
|
+
};
|
|
7600
|
+
const onKeydown = (e) => {
|
|
7601
|
+
if (e.key === "Escape") close();
|
|
7602
|
+
};
|
|
7603
|
+
onMounted(() => document.addEventListener("keydown", onKeydown));
|
|
7604
|
+
onBeforeUnmount(() => document.removeEventListener("keydown", onKeydown));
|
|
7605
|
+
return () => /* @__PURE__ */ h(
|
|
7606
|
+
"div",
|
|
7607
|
+
{
|
|
7608
|
+
style: {
|
|
7609
|
+
position: "fixed",
|
|
7610
|
+
inset: 0,
|
|
7611
|
+
zIndex: 1e4,
|
|
7612
|
+
background: "rgba(0, 0, 0, 0.4)",
|
|
7613
|
+
display: "flex",
|
|
7614
|
+
alignItems: "center",
|
|
7615
|
+
justifyContent: "center"
|
|
7616
|
+
},
|
|
7617
|
+
onClick: close
|
|
7618
|
+
},
|
|
7619
|
+
/* @__PURE__ */ h(
|
|
7620
|
+
"div",
|
|
7621
|
+
{
|
|
7622
|
+
style: {
|
|
7623
|
+
position: "relative",
|
|
7624
|
+
width: "560px",
|
|
7625
|
+
maxWidth: "calc(100vw - 32px)",
|
|
7626
|
+
background: "var(--crepe-color-surface, #fff)",
|
|
7627
|
+
borderRadius: "12px",
|
|
7628
|
+
boxShadow: "0 8px 32px rgba(0, 0, 0, 0.15)",
|
|
7629
|
+
padding: "20px 24px"
|
|
7630
|
+
},
|
|
7631
|
+
onClick: (e) => e.stopPropagation()
|
|
7632
|
+
},
|
|
7633
|
+
/* @__PURE__ */ h(
|
|
7634
|
+
"div",
|
|
7635
|
+
{
|
|
7636
|
+
style: {
|
|
7637
|
+
display: "flex",
|
|
7638
|
+
alignItems: "center",
|
|
7639
|
+
justifyContent: "space-between",
|
|
7640
|
+
marginBottom: "16px",
|
|
7641
|
+
paddingBottom: "12px",
|
|
7642
|
+
borderBottom: "1px solid var(--crepe-color-outline-variant, color-mix(in srgb, var(--crepe-color-outline), transparent 80%))"
|
|
7643
|
+
}
|
|
7644
|
+
},
|
|
7645
|
+
/* @__PURE__ */ h(
|
|
7646
|
+
"span",
|
|
7647
|
+
{
|
|
7648
|
+
style: {
|
|
7649
|
+
fontSize: "15px",
|
|
7650
|
+
fontWeight: 600,
|
|
7651
|
+
color: "var(--crepe-color-on-surface, #1a1a1a)"
|
|
7652
|
+
}
|
|
7653
|
+
},
|
|
7654
|
+
i18n(props.ctx, "shortcuts.title")
|
|
7655
|
+
),
|
|
7656
|
+
/* @__PURE__ */ h(
|
|
7657
|
+
"button",
|
|
7658
|
+
{
|
|
7659
|
+
type: "button",
|
|
7660
|
+
onClick: close,
|
|
7661
|
+
style: {
|
|
7662
|
+
display: "inline-flex",
|
|
7663
|
+
alignItems: "center",
|
|
7664
|
+
justifyContent: "center",
|
|
7665
|
+
width: "28px",
|
|
7666
|
+
height: "28px",
|
|
7667
|
+
border: "none",
|
|
7668
|
+
background: "transparent",
|
|
7669
|
+
cursor: "pointer",
|
|
7670
|
+
borderRadius: "4px",
|
|
7671
|
+
color: "var(--crepe-color-on-surface-variant, #666)"
|
|
7672
|
+
}
|
|
7673
|
+
},
|
|
7674
|
+
/* @__PURE__ */ h(Icon, { icon: closeIcon })
|
|
7675
|
+
)
|
|
7676
|
+
),
|
|
7677
|
+
/* @__PURE__ */ h("div", { style: { display: "flex", gap: "24px" } }, /* @__PURE__ */ h("div", { style: columnStyle }, leftGroups.map((g) => renderGroup(props.ctx, g))), /* @__PURE__ */ h(
|
|
7678
|
+
"div",
|
|
7679
|
+
{
|
|
7680
|
+
style: {
|
|
7681
|
+
width: "1px",
|
|
7682
|
+
flexShrink: 0,
|
|
7683
|
+
backgroundColor: "var(--crepe-color-outline-variant, color-mix(in srgb, var(--crepe-color-outline), transparent 80%))"
|
|
7684
|
+
}
|
|
7685
|
+
}
|
|
7686
|
+
), /* @__PURE__ */ h("div", { style: columnStyle }, rightGroups.map((g) => renderGroup(props.ctx, g))))
|
|
7687
|
+
)
|
|
7688
|
+
);
|
|
7689
|
+
}
|
|
7690
|
+
});
|
|
7691
|
+
|
|
7327
7692
|
const FixedToolbarComponent = defineComponent({
|
|
7328
7693
|
props: {
|
|
7329
7694
|
ctx: { type: Object, required: true },
|
|
@@ -7333,6 +7698,7 @@ const FixedToolbarComponent = defineComponent({
|
|
|
7333
7698
|
config: { type: Object, required: false }
|
|
7334
7699
|
},
|
|
7335
7700
|
setup(props) {
|
|
7701
|
+
const showShortcuts = ref(false);
|
|
7336
7702
|
return () => /* @__PURE__ */ h(
|
|
7337
7703
|
"div",
|
|
7338
7704
|
{
|
|
@@ -7341,7 +7707,7 @@ const FixedToolbarComponent = defineComponent({
|
|
|
7341
7707
|
alignItems: "center",
|
|
7342
7708
|
justifyContent: "center",
|
|
7343
7709
|
width: "100%",
|
|
7344
|
-
gap: "
|
|
7710
|
+
gap: "0px"
|
|
7345
7711
|
}
|
|
7346
7712
|
},
|
|
7347
7713
|
/* @__PURE__ */ h(MenuBar, { ctx: props.ctx, config: props.config }),
|
|
@@ -7366,7 +7732,32 @@ const FixedToolbarComponent = defineComponent({
|
|
|
7366
7732
|
config: props.config,
|
|
7367
7733
|
isFixed: true
|
|
7368
7734
|
}
|
|
7369
|
-
)
|
|
7735
|
+
),
|
|
7736
|
+
/* @__PURE__ */ h(
|
|
7737
|
+
"div",
|
|
7738
|
+
{
|
|
7739
|
+
style: {
|
|
7740
|
+
width: "1px",
|
|
7741
|
+
minWidth: "1px",
|
|
7742
|
+
height: "20px",
|
|
7743
|
+
flexShrink: 0,
|
|
7744
|
+
backgroundColor: "var(--crepe-color-outline-variant, color-mix(in srgb, var(--crepe-color-outline), transparent 80%))"
|
|
7745
|
+
}
|
|
7746
|
+
}
|
|
7747
|
+
),
|
|
7748
|
+
/* @__PURE__ */ h(
|
|
7749
|
+
"button",
|
|
7750
|
+
{
|
|
7751
|
+
type: "button",
|
|
7752
|
+
class: "toolbar-shortcut-btn",
|
|
7753
|
+
title: i18n(props.ctx, "shortcuts.title"),
|
|
7754
|
+
onClick: () => {
|
|
7755
|
+
showShortcuts.value = true;
|
|
7756
|
+
}
|
|
7757
|
+
},
|
|
7758
|
+
/* @__PURE__ */ h(Icon, { icon: keyboardIcon })
|
|
7759
|
+
),
|
|
7760
|
+
showShortcuts.value && /* @__PURE__ */ h(ShortcutHelpModal, { ctx: props.ctx, visible: showShortcuts })
|
|
7370
7761
|
);
|
|
7371
7762
|
}
|
|
7372
7763
|
});
|
|
@@ -7736,10 +8127,24 @@ function buildDefaultFixedToolbar(builder, _config, ctx) {
|
|
|
7736
8127
|
return;
|
|
7737
8128
|
}
|
|
7738
8129
|
convertHeadingToParagraphIfNeeded(ctx2);
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
8130
|
+
const result = wrapInList(bulletList)(view.state, (tr) => {
|
|
8131
|
+
tr.doc.nodesBetween(
|
|
8132
|
+
tr.mapping.map(from),
|
|
8133
|
+
tr.mapping.map(to),
|
|
8134
|
+
(node, pos) => {
|
|
8135
|
+
if (node.type === listItem) {
|
|
8136
|
+
tr.setNodeMarkup(pos, void 0, {
|
|
8137
|
+
...node.attrs,
|
|
8138
|
+
checked: false,
|
|
8139
|
+
listType: "bullet",
|
|
8140
|
+
label: "\u2022"
|
|
8141
|
+
});
|
|
8142
|
+
}
|
|
8143
|
+
}
|
|
8144
|
+
);
|
|
8145
|
+
view.dispatch(tr);
|
|
7742
8146
|
});
|
|
8147
|
+
if (result) return;
|
|
7743
8148
|
}
|
|
7744
8149
|
});
|
|
7745
8150
|
}
|
|
@@ -7966,10 +8371,9 @@ const DocumentHeader = defineComponent({
|
|
|
7966
8371
|
class: "milkdown-document-title-wrapper",
|
|
7967
8372
|
style: {
|
|
7968
8373
|
width: "100%",
|
|
7969
|
-
|
|
7970
|
-
|
|
7971
|
-
padding:
|
|
7972
|
-
// Match ProseMirror padding
|
|
8374
|
+
maxWidth: editorWidthMap[state.editorWidth] === "none" ? void 0 : editorWidthMap[state.editorWidth],
|
|
8375
|
+
margin: editorWidthMap[state.editorWidth] === "none" ? "0" : "0 auto",
|
|
8376
|
+
padding: `40px ${editorWidthMap[state.editorWidth] === "none" ? "80px" : "0"} 0`
|
|
7973
8377
|
}
|
|
7974
8378
|
},
|
|
7975
8379
|
/* @__PURE__ */ h("style", null, `.milkdown-document-title::placeholder { color: #BFBFBF; }`),
|
|
@@ -8394,7 +8798,7 @@ var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Ca
|
|
|
8394
8798
|
var __privateGet$3 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
8395
8799
|
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
8800
|
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;
|
|
8801
|
+
var _content$2, _app$2, _headerContent, _headerApp, _outlineContent, _outlineApp, _watcher, _selection$1, _show$1, _resizeObserver, _updateOutlineGeometry, _scrollContainers, _view;
|
|
8398
8802
|
const fixedToolbarConfig = $ctx(
|
|
8399
8803
|
{},
|
|
8400
8804
|
"fixedToolbarConfigCtx"
|
|
@@ -8414,6 +8818,7 @@ class FixedToolbarView {
|
|
|
8414
8818
|
__privateAdd$3(this, _resizeObserver);
|
|
8415
8819
|
__privateAdd$3(this, _updateOutlineGeometry);
|
|
8416
8820
|
__privateAdd$3(this, _scrollContainers, []);
|
|
8821
|
+
__privateAdd$3(this, _view);
|
|
8417
8822
|
this.update = (view) => {
|
|
8418
8823
|
__privateGet$3(this, _selection$1).value = view.state.selection;
|
|
8419
8824
|
};
|
|
@@ -8435,6 +8840,7 @@ class FixedToolbarView {
|
|
|
8435
8840
|
if (__privateGet$3(this, _outlineApp)) __privateGet$3(this, _outlineApp).unmount();
|
|
8436
8841
|
if (__privateGet$3(this, _outlineContent)) __privateGet$3(this, _outlineContent).remove();
|
|
8437
8842
|
};
|
|
8843
|
+
__privateSet$3(this, _view, view);
|
|
8438
8844
|
const config = ctx.get(fixedToolbarConfig.key);
|
|
8439
8845
|
const content = document.createElement("div");
|
|
8440
8846
|
content.className = "milkdown-fixed-toolbar";
|
|
@@ -8530,7 +8936,8 @@ class FixedToolbarView {
|
|
|
8530
8936
|
viewState.outlinePosition,
|
|
8531
8937
|
viewState.outlineWidth,
|
|
8532
8938
|
viewState.documentBackground,
|
|
8533
|
-
viewState.showCover
|
|
8939
|
+
viewState.showCover,
|
|
8940
|
+
viewState.editorWidth
|
|
8534
8941
|
],
|
|
8535
8942
|
() => {
|
|
8536
8943
|
if (viewState.documentBackground) {
|
|
@@ -8559,6 +8966,17 @@ class FixedToolbarView {
|
|
|
8559
8966
|
__privateGet$3(this, _content$2).style.marginLeft = "0";
|
|
8560
8967
|
__privateGet$3(this, _content$2).style.marginRight = "0";
|
|
8561
8968
|
}
|
|
8969
|
+
const maxWidth = editorWidthMap[viewState.editorWidth];
|
|
8970
|
+
const isFull = maxWidth === "none";
|
|
8971
|
+
const px = isFull ? "80px" : "0";
|
|
8972
|
+
__privateGet$3(this, _view).dom.style.maxWidth = maxWidth;
|
|
8973
|
+
__privateGet$3(this, _view).dom.style.width = isFull ? "100%" : maxWidth;
|
|
8974
|
+
__privateGet$3(this, _view).dom.style.margin = isFull ? "0" : "0 auto";
|
|
8975
|
+
__privateGet$3(this, _view).dom.style.padding = `20px ${px} 0`;
|
|
8976
|
+
if (__privateGet$3(this, _headerContent)) {
|
|
8977
|
+
__privateGet$3(this, _headerContent).style.margin = isFull ? "0" : "0 auto";
|
|
8978
|
+
__privateGet$3(this, _headerContent).style.padding = `0px`;
|
|
8979
|
+
}
|
|
8562
8980
|
nextTick(() => {
|
|
8563
8981
|
var _a;
|
|
8564
8982
|
(_a = __privateGet$3(this, _updateOutlineGeometry)) == null ? void 0 : _a.call(this);
|
|
@@ -8581,6 +8999,7 @@ _show$1 = new WeakMap();
|
|
|
8581
8999
|
_resizeObserver = new WeakMap();
|
|
8582
9000
|
_updateOutlineGeometry = new WeakMap();
|
|
8583
9001
|
_scrollContainers = new WeakMap();
|
|
9002
|
+
_view = new WeakMap();
|
|
8584
9003
|
const fixedToolbarPlugin = $prose((ctx) => {
|
|
8585
9004
|
return new Plugin({
|
|
8586
9005
|
key: fixedToolbarKey,
|
|
@@ -8620,17 +9039,19 @@ const imageBlock = (editor, config) => {
|
|
|
8620
9039
|
};
|
|
8621
9040
|
});
|
|
8622
9041
|
ctx.update(imageBlockConfig.key, (value) => {
|
|
8623
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
9042
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
8624
9043
|
return {
|
|
8625
9044
|
uploadButton: (_a = config == null ? void 0 : config.blockUploadButton) != null ? _a : i18n(ctx, "imageBlock.blockUploadButton"),
|
|
8626
9045
|
imageIcon: (_b = config == null ? void 0 : config.blockImageIcon) != null ? _b : imageIcon,
|
|
8627
9046
|
captionIcon: (_c = config == null ? void 0 : config.blockCaptionIcon) != null ? _c : captionIcon,
|
|
8628
|
-
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
|
|
9047
|
+
cropIcon: (_d = config == null ? void 0 : config.blockCropIcon) != null ? _d : cropIcon,
|
|
9048
|
+
borderIcon: (_e = config == null ? void 0 : config.blockBorderIcon) != null ? _e : borderIcon,
|
|
9049
|
+
confirmButton: (_f = config == null ? void 0 : config.blockConfirmButton) != null ? _f : i18n(ctx, "imageBlock.blockConfirmButton"),
|
|
9050
|
+
captionPlaceholderText: (_g = config == null ? void 0 : config.blockCaptionPlaceholderText) != null ? _g : i18n(ctx, "imageBlock.blockCaptionPlaceholder"),
|
|
9051
|
+
uploadPlaceholderText: (_h = config == null ? void 0 : config.blockUploadPlaceholderText) != null ? _h : i18n(ctx, "imageBlock.blockUploadPlaceholder"),
|
|
9052
|
+
onUpload: (_j = (_i = config == null ? void 0 : config.blockOnUpload) != null ? _i : config == null ? void 0 : config.onUpload) != null ? _j : value.onUpload,
|
|
8632
9053
|
proxyDomURL: config == null ? void 0 : config.proxyDomURL,
|
|
8633
|
-
onImageLoadError: (
|
|
9054
|
+
onImageLoadError: (_k = config == null ? void 0 : config.onImageLoadError) != null ? _k : value.onImageLoadError,
|
|
8634
9055
|
maxWidth: config == null ? void 0 : config.maxWidth,
|
|
8635
9056
|
maxHeight: config == null ? void 0 : config.maxHeight
|
|
8636
9057
|
};
|