New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ink-mde

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ink-mde

The flexible TypeScript Markdown editor that powers https://octo.app.

  • 0.10.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

latest tag license open issues

ink-mde

The flexible TypeScript Markdown editor that powers https://octo.app.

Features

  • Automatic, dark, or light themes (automatic by default)
  • Hybrid plain-text Markdown rendering
  • Supports GitHub Flavored Markdown (an extension of CommonMark)
  • Syntax highlighting for many common languages (in code blocks)
  • Drag-and-drop or paste to upload files
  • Inline Markdown image previews
  • Configurable and stylable
  • An optional formatting toolbar (great for mobile)
  • Vim Mode
  • Plugin API

Getting Started

With your preferred package manager, add ink-mde to your project.

# npm
npm i ink-mde

# pnpm
pnpm i ink-mde

# yarn
yarn add ink-mde

Next, import ink-mde and customize it to fit your needs.

Minimal setup

Mount the component and start writing.

// ./examples/minimal.ts
import ink from 'ink-mde'

// The only requirement is an HTML element.
ink(document.getElementById('editor')!)

Track state changes with hooks

To sync the editor with your app's state, you can use the afterUpdate hook.

// ./examples/hooks.ts
import { defineOptions, ink } from 'ink-mde'

// With hooks, you can keep your state in sync with the editor.
const state = { doc: '# Start with some text' }

// Use defineOptions for automatic type hinting.
const options = defineOptions({
  doc: state.doc,
  hooks: {
    afterUpdate: (doc: string) => {
      state.doc = doc
    },
  },
})

const editor = ink(document.getElementById('editor')!, options)

// You can also update the editor directly.
editor.update(state.doc)

Further customization

Other features of the editor can be customized through the following options.

OptionDescriptionTypeDefault
options.docInitialize the editor with an existing docstring''
options.files.clipboardEnable file uploads on pastebooleanfalse
options.files.dragAndDropEnable drag-and-drop file uploadsbooleanfalse
options.files.handlerHandle file uploads (not handled by ink-mde)(files: FileList) => Promise<any> | void() => {}
options.hooks.afterUpdateRun some code after the doc is updated(doc: string) => void() => {}
options.hooks.beforeUpdateRun some code before the doc is updated(doc: string) => void() => {}
options.interface.appearanceChange the editor theme'auto' | 'dark' | 'light''auto'
options.interface.attributionShow the "powered by ink-mde" attributionbooleantrue
options.interface.imagesRender images in the editorbooleanfalse
options.interface.spellcheckEnable spellcheckbooleantrue
options.interface.toolbarEnable the formatting toolbarbooleanfalse
options.pluginsExtend the editor with custom featuresInk.Editor.Plugin[][]
options.selectionsInitialize the editor with selectionsInk.Editor.Selection[][]
options.toolbar.boldInclude this button in the toolbarbooleantrue
options.toolbar.codeInclude this button in the toolbarbooleantrue
options.toolbar.codeBlockInclude this button in the toolbarbooleantrue
options.toolbar.headingInclude this button in the toolbarbooleantrue
options.toolbar.imageInclude this button in the toolbarbooleantrue
options.toolbar.italicInclude this button in the toolbarbooleantrue
options.toolbar.linkInclude this button in the toolbarbooleantrue
options.toolbar.listInclude this button in the toolbarbooleantrue
options.toolbar.orderedListInclude this button in the toolbarbooleantrue
options.toolbar.quoteInclude this button in the toolbarbooleantrue
options.toolbar.taskListInclude this button in the toolbarbooleantrue
options.toolbar.uploadInclude this button in the toolbarbooleanfalse
options.vimUse Vim keybindings to edit the docbooleanfalse

Plugins

The editor can be extended with custom grammars, completions, and more through the Plugin API. Examples coming soon.

Appearance

Many aspects of the editor's appearance can be customized with CSS custom properties (aka CSS variables).

General-purpose styles
CSS Custom PropertyCSS PropertyDefault (Dark)Override (Light)
--ink-border-radiusborder-radius0.25rem
--ink-colorcolor#fafafa#171717
--ink-font-familyfont-familysans-serif
--ink-flex-directionflex-directioncolumn
Block styles

Blocks are used to provide a dynamic user experience. Examples of blocks are images, multiline code blocks, and the toolbar.

CSS Custom PropertyCSS PropertyDefault (Dark)Override (Light)
--ink-block-background-colorbackground-color#121212#f5f5f5
--ink-block-background-color-on-hoverbackground-color#0f0f0f#e0e0e0
--ink-block-max-heightmax-height20rem
--ink-block-paddingpadding0.5rem
Code styles

These styles are for code blocks and inline code.

CSS Custom PropertyCSS PropertyDefault (Dark)Override (Light)
--ink-code-background-colorbackground-colorvar(--ink-block-background-color)
--ink-code-colorcolorinherit
--ink-code-font-familyfont-family'Monaco', Courier, monospace
Syntax highlighting

You can customize the entire syntax theme too.

CSS Custom PropertyCSS PropertyDefault (Dark)Override (Light)
--ink-syntax-atom-colorcolor#d19a66
--ink-syntax-comment-colorcolor#abb2bf
--ink-syntax-emphasis-colorcolorinherit
--ink-syntax-emphasis-font-stylefont-styleitalic
--ink-syntax-heading-colorcolor#e06c75
--ink-syntax-heading-font-sizefont-size1em
--ink-syntax-heading-font-weightfont-weight600
--ink-syntax-heading1-colorcolor#e06c75
--ink-syntax-heading1-font-sizefont-size1.6em
--ink-syntax-heading1-font-weightfont-weight600
--ink-syntax-heading2-colorcolor#e06c75
--ink-syntax-heading2-font-sizefont-size1.5em
--ink-syntax-heading2-font-weightfont-weight600
--ink-syntax-heading3-colorcolor#e06c75
--ink-syntax-heading3-font-sizefont-size1.4em
--ink-syntax-heading3-font-weightfont-weight600
--ink-syntax-heading4-colorcolor#e06c75
--ink-syntax-heading4-font-sizefont-size1.3em
--ink-syntax-heading4-font-weightfont-weight600
--ink-syntax-heading5-colorcolor#e06c75
--ink-syntax-heading5-font-sizefont-size1.2em
--ink-syntax-heading5-font-weightfont-weight600
--ink-syntax-heading6-colorcolor#e06c75
--ink-syntax-heading6-font-sizefont-size1.1em
--ink-syntax-heading6-font-weightfont-weight600
--ink-syntax-keyword-colorcolor#c678dd
--ink-syntax-link-colorcolor#96c0d8
--ink-syntax-meta-colorcolor#abb2bf
--ink-syntax-name-colorcolor#d19a66
--ink-syntax-name-label-colorcolor#abb2bf
--ink-syntax-name-property-colorcolor#96c0d8
--ink-syntax-name-property-definition-colorcolor#e06c75
--ink-syntax-name-variable-colorcolor#e06c75
--ink-syntax-name-variable-definition-colorcolor#e5c07b
--ink-syntax-name-variable-local-colorcolor#d19a66
--ink-syntax-name-variable-special-colorcolorinherit
--ink-syntax-number-colorcolor#d19a66
--ink-syntax-operator-colorcolor#96c0d8
--ink-syntax-processing-instruction-colorcolor#444444#bbbbbb
--ink-syntax-punctuation-colorcolor#abb2bf
--ink-syntax-strikethrough-colorcolorinherit
--ink-syntax-strikethrough-text-decorationtext-decorationline-through
--ink-syntax-string-colorcolor#98c379
--ink-syntax-string-special-colorcolorinherit
--ink-syntax-strong-colorcolorinherit
--ink-syntax-strong-font-weightfont-weight600
--ink-syntax-url-colorcolor#aaaaaa#666666

Support

Your support is appreciated. Here are some ways you can help. ♥️

Leave the Attribution enabled

There is a small powered by ink-mde attribution in the bottom-right corner of all editor instances by default. Being a free, MIT-licensed library under independent development, that attribution helps to increase awareness of this project and my work in general.

Tell us what you think

Your feedback is immensely important for building ink-mde into a library that we all love. Consider starting a discussion under Octo if you have a question or just want to chat about ideas!

Open a Pull Request

If you feel comfortable with an existing issue, please consider opening a Pull Request. I would love to work with you to get it merged!

Become a financial backer

Keywords

FAQs

Package last updated on 26 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc