4.11.2-alpha.4 • Published 3 years ago

@sosuisen/milkdown-preset-gfm v4.11.2-alpha.4

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

@milkdown/preset-commonmark

Common mark preset for milkdown. Add support for commonmark.

Example Usage

import { Editor } from '@milkdown/core';
import { nord } from '@milkdown/theme-nord';

import { commonmark } from '@milkdown/preset-commonmark';
import '@milkdown/preset-commonmark/lib/style.css';

Editor.make().use(nord).use(commonmark).create();

Custom Keymap

import { commonmark, blockquote, SupportedKeys } from '@milkdown/preset-commonmark';

const nodes = commonmark.configure(blockquote, {
    keymap: {
        [SupportedKeys.Blockquote]: 'Mod-Shift-b',
    },
});

Editor.make().use(nodes);

Keymap supported:

  • HardBreak
  • Blockquote
  • TaskList
  • BulletList
  • OrderedList
  • CodeFence
  • H1
  • H2
  • H3
  • H4
  • H5
  • H6
  • Text
  • CodeInline
  • Em
  • Bold
  • StrikeThrough
  • NextListItem
  • SinkListItem
  • LiftListItem

Custom Style

import { commonmark, paragraph, heading } from '@milkdown/commonmark';

const nodes = commonmark
    .configure(paragraph, {
        className: () => 'my-custom-paragraph',
    })
    .configure(heading, {
        className: (attrs) => `my-custom-heading my-h${attrs.level}`,
    });

Editor.make().use(nodes);