npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@markmirror/core

v0.3.0

Published

The fundamentals of the MarkMirror Markdown editor

Downloads

9

Readme

@markmirror/core

The fundamentals of MarkMirror - a Markdown Editor based on CodeMirror 6.

Usage

1. Install the package

Get the source code via npm:

npm install @markmirror/core

The package contains the fundamentals of the editor, and you can create a basic editor with only the core code.

2. Prepare the element

Prepare a HTML element to mount the editor. For instance a <div>:

<div id="editor"></div>

You can also use a <textarea> as the mounting element. In this case, the editor will use the value of the textarea as the editor's content.

<textarea id="editor"></textarea>

3. Insert the style

MarkMirror has a beautiful built-in CSS file. You can include the style.css:

import "@markmirror/core/style.css"

If you don't like it, you can always use your own CSS file.

4. Initialize the editor

When everything is ready, you can create the javascript code:

import { MarkMirror, markdown } from "@markmirror/core"

// initialize the editor
const editor = new MarkMirror([
  markdown(),
])

You can put more extensions when initializing the editor. The extensions are compatible with codemirror. For example:

import { keymap } from "@codemirror/view"
import { history, defaultKeymap, historyKeymap } from "@codemirror/commands"

const editor = new MarkMirror([
  markdown(),
  history(),
  keymap.of([...defaultKeymap, ...historyKeymap]),
])

5. Render the editor

The final step is mounting the editor to the prepared element above.

// mount the editor to #editor element
editor.render(document.getElementById("editor"))

If you are using a <div> element, and you want to add the default content for the editor:

const content = 'Hello **world**'
editor.render(document.getElementById("editor"), content)

All settled, open your browser and play with the editor.