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 🙏

© 2026 – Pkg Stats / Ryan Hefner

pict-section-markdowneditor

v1.0.6

Published

Pict segmented markdown editor section built on CodeMirror

Readme

pict-section-markdowneditor

A segmented markdown editor for Pict applications, built on CodeMirror v6. Split your document into independently editable segments, reorder them with drag-and-drop, and get live rich previews with syntax highlighting, mermaid diagrams, and KaTeX math.

Quick Start

npm install pict-section-markdowneditor

1. Define an Editor View

Extend PictSectionMarkdownEditor and register it with a Pict application:

const libPictApplication = require('pict-application');
const libPictSectionMarkdownEditor = require('pict-section-markdowneditor');

class MyEditorView extends libPictSectionMarkdownEditor
{
	constructor(pFable, pOptions, pServiceHash)
	{
		super(pFable, pOptions, pServiceHash);
	}
}

const _EditorConfig = (
{
	"ViewIdentifier": "MyEditor",
	"TargetElementAddress": "#EditorContainer",
	"ContentDataAddress": "AppData.Document.Segments",
	"ReadOnly": false,
	"EnableRichPreview": true
});

class MyApp extends libPictApplication
{
	constructor(pFable, pOptions, pServiceHash)
	{
		super(pFable, pOptions, pServiceHash);
		this.pict.addView('MyEditorView', _EditorConfig, MyEditorView);
	}

	onAfterInitialize()
	{
		super.onAfterInitialize();
		this.pict.views.MyEditorView.render();
	}
}

module.exports = MyApp;

module.exports.default_configuration = (
{
	"Name": "My Editor App",
	"Hash": "MyEditorApp",
	"MainViewportViewIdentifier": "MyEditorView",
	"pict_configuration":
	{
		"Product": "MyEditor-App",
		"DefaultAppData":
		{
			"Document":
			{
				"Segments":
				[
					{ "Content": "# Hello\n\nStart writing here." }
				]
			}
		}
	}
});

2. Create the HTML Page

<!doctype html>
<html>
<head>
	<style id="PICT-CSS"></style>
	<script src="./codemirror-bundle.js"></script>
	<script src="./pict.min.js"></script>
	<script>
		Pict.safeOnDocumentReady(() => { Pict.safeLoadPictApplication(MyApp, 1) });
	</script>
</head>
<body>
	<div id="EditorContainer"></div>
	<script src="./my_app.min.js"></script>
</body>
</html>

3. Build and Run

npx quack build && npx quack copy

Open dist/index.html in your browser.

How It Works

  1. Your Pict application initializes and renders the editor view
  2. The view reads ContentDataAddress from AppData to load an array of segment objects
  3. Each segment gets its own CodeMirror editor instance inside a four-quadrant layout
  4. Formatting buttons (bold, italic, code, heading, link, image) appear in the sidebar
  5. Content changes are debounced and marshaled back to AppData automatically
  6. Rich previews render markdown to HTML via pict-section-content with mermaid and KaTeX post-processing

CodeMirror Integration

The editor does not bundle CodeMirror directly. Your application must provide EditorView, EditorState, and an extensions array in one of two ways:

  1. Window global -- Set window.CodeMirrorModules with the required exports (recommended for browser apps)
  2. Explicit injection -- Call view.connectCodeMirrorModules({ EditorView, EditorState, extensions }) before rendering

Features

  • Segmented Editing -- Break documents into independently editable segments with add, remove, and reorder
  • Drag-and-Drop Reorder -- Drag segments by the handle to reorganize your document
  • Rich Preview -- Live rendered markdown below each segment with syntax highlighting, mermaid diagrams, and KaTeX math
  • Formatting Toolbar -- Bold, italic, code, heading, link, and image buttons that follow your cursor
  • Image Support -- Paste, drag, or file-pick images with base64 inline or server-side upload via the onImageUpload hook
  • Data URI Collapse -- Long base64 image URIs are visually collapsed in the editor without changing the document
  • Read-Only Mode -- Toggle editing on or off at runtime with setReadOnly()
  • Rendered View -- Toggle a full-document read-mode preview that combines all segments
  • Keyboard Shortcuts -- Ctrl/Cmd+B bold, Ctrl/Cmd+I italic, Ctrl/Cmd+E inline code

Examples

Four working example applications are included in the example_applications/ folder:

  • markdown_editor/ -- Full-featured segmented editor with previews, formatting, drag reorder, and rich content
  • embedded_editor/ -- Small bordered widget for notes, comments, or form fields
  • book_viewer/ -- A multi-chapter book rendered with pict-section-content, click any section to edit it inline
  • server_upload/ -- Orator server with image upload endpoint demonstrating the onImageUpload hook

Learn More

Related Packages

License

MIT

Contributing

Pull requests are welcome. For details on our code of conduct, contribution process, and testing requirements, see the Retold Contributing Guide.