diff --git a/packages/bytemd/src/editor.svelte b/packages/bytemd/src/editor.svelte index 9326a92..ec41d75 100644 --- a/packages/bytemd/src/editor.svelte +++ b/packages/bytemd/src/editor.svelte @@ -23,6 +23,7 @@ useGfm, useYaml, useYamlFrontmatter, + useContinuelist, createEditorUtils, findStartIndex, getBuiltinActions, @@ -170,6 +171,7 @@ useGfm(codemirror) useYaml(codemirror) useYamlFrontmatter(codemirror) + useContinuelist(codemirror) // @ts-ignore TODO: type editor = codemirror(editorEl, { @@ -178,6 +180,9 @@ lineWrapping: true, tabSize: 8, // keep consistent with preview: https://developer.mozilla.org/en-US/docs/Web/CSS/tab-size#formal_definition indentUnit: 4, // nested ordered list does not work with 2 spaces + extraKeys: { + Enter: 'newlineAndIndentContinueMarkdownList', + }, // https://github.com/codemirror/CodeMirror/blob/c955a0fb02d9a09cf98b775cb94589e4980303c1/mode/markdown/index.html#L359 ...editorConfig, placeholder, }) diff --git a/packages/bytemd/src/helpers.ts b/packages/bytemd/src/helpers.ts index 533263a..118c284 100644 --- a/packages/bytemd/src/helpers.ts +++ b/packages/bytemd/src/helpers.ts @@ -16,6 +16,7 @@ import useMarkdown from 'codemirror-ssr/mode/markdown/markdown' import useGfm from 'codemirror-ssr/mode/gfm/gfm' import useYaml from 'codemirror-ssr/mode/yaml/yaml' import useYamlFrontmatter from 'codemirror-ssr/mode/yaml-frontmatter/yaml-frontmatter' +import useContinuelist from 'codemirror-ssr/addon/edit/continuelist' import { icons } from './icons' export type { DelegateInstance, Root, Element, VFile, Plugin } @@ -35,6 +36,7 @@ export { useGfm, useYaml, useYamlFrontmatter, + useContinuelist, // icons, }