{"id":49940999,"url":"https://github.com/neuronexul/draftly","last_synced_at":"2026-05-17T11:07:00.040Z","repository":{"id":336627314,"uuid":"1143519281","full_name":"NeuroNexul/draftly","owner":"NeuroNexul","description":"A modern, intuitive Markdown editor built on the powerful CodeMirror 6 framework, designed to bring a truly What You See Is What You Get experience ","archived":false,"fork":false,"pushed_at":"2026-03-17T11:33:33.000Z","size":992,"stargazers_count":18,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-26T17:57:32.703Z","etag":null,"topics":["codemirror6","cross-framework","customizable","extensible","lezer-parser","markdown","wysiwyg"],"latest_commit_sha":null,"homepage":"https://draftly.nexul.in","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NeuroNexul.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-27T17:19:55.000Z","updated_at":"2026-03-25T13:34:55.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/NeuroNexul/draftly","commit_stats":null,"previous_names":["neuronexul/draftly"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/NeuroNexul/draftly","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeuroNexul%2Fdraftly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeuroNexul%2Fdraftly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeuroNexul%2Fdraftly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeuroNexul%2Fdraftly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NeuroNexul","download_url":"https://codeload.github.com/NeuroNexul/draftly/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NeuroNexul%2Fdraftly/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33136091,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T09:28:26.183Z","status":"ssl_error","status_checked_at":"2026-05-17T09:27:52.702Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codemirror6","cross-framework","customizable","extensible","lezer-parser","markdown","wysiwyg"],"created_at":"2026-05-17T11:06:55.702Z","updated_at":"2026-05-17T11:07:00.034Z","avatar_url":"https://github.com/NeuroNexul.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eDraftly\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cstrong\u003eA modern, extensible markdown editor and previewer for the web.\u003c/strong\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/draftly\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/draftly?style=flat-square\u0026color=blue\" alt=\"npm version\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/draftly\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/draftly?style=flat-square\" alt=\"npm downloads\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/NeuroNexul/draftly/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/draftly?style=flat-square\" alt=\"license\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/NeuroNexul/draftly\"\u003e\u003cimg src=\"https://img.shields.io/github/stars/NeuroNexul/draftly?style=flat-square\" alt=\"GitHub stars\" /\u003e\u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/badge/TypeScript-Ready-blue?style=flat-square\u0026logo=typescript\u0026logoColor=white\" alt=\"TypeScript\" /\u003e\n  \u003cimg src=\"https://img.shields.io/badge/CodeMirror-6-orange?style=flat-square\" alt=\"CodeMirror 6\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e •\n  \u003ca href=\"#quick-start\"\u003eQuick Start\u003c/a\u003e •\n  \u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e •\n  \u003ca href=\"#features\"\u003eFeatures\u003c/a\u003e •\n  \u003ca href=\"#api-reference\"\u003eAPI\u003c/a\u003e •\n  \u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n## Overview\n\n**Draftly** is a powerful, pluggable markdown editor and preview toolkit built on top of **CodeMirror 6**. It provides a seamless \"rich text\" editing experience while preserving standard markdown syntax. Draftly also includes a static HTML renderer that produces output visually identical to the editor, making it perfect for blogs, documentation sites, and content management systems.\n\n### Why Draftly?\n\n- 🚀 **Modern Architecture**: Built on CodeMirror 6 with incremental Lezer parsing.\n- 🎨 **Rich Editing**: WYSIWYG-like experience with full markdown control.\n- 🔌 **Extensible Plugin System**: Add custom rendering, keymaps, and syntax.\n- 🖼️ **Static Preview**: Render markdown to semantic HTML with visual parity.\n- 🌗 **Theming**: First-class support for light and dark modes.\n- 📦 **Modular Exports**: Import only what you need (`draftly/editor`, `draftly/preview`, `draftly/plugins`).\n\n---\n\n## Installation\n\nInstall the package via your preferred package manager:\n\n```bash\n# npm\nnpm install draftly\n\n# yarn\nyarn add draftly\n\n# pnpm\npnpm add draftly\n\n# bun\nbun add draftly\n```\n\n### Peer Dependencies\n\nDraftly requires the following CodeMirror packages as peer dependencies. Make sure they are installed in your project:\n\n```bash\nnpm install @codemirror/commands @codemirror/lang-markdown @codemirror/language @codemirror/language-data @codemirror/state @codemirror/view\n```\n\n---\n\n## Quick Start\n\nGet up and running in seconds.\n\n```tsx\nimport { EditorView } from \"@codemirror/view\";\nimport { EditorState } from \"@codemirror/state\";\nimport { draftly } from \"draftly\";\n\nconst view = new EditorView({\n  state: EditorState.create({\n    doc: \"# Hello, Draftly!\",\n    extensions: [draftly()],\n  }),\n  parent: document.getElementById(\"editor\")!,\n});\n```\n\n---\n\n## Usage\n\nDraftly is designed for flexibility. Use it as a CodeMirror extension for interactive editing or as a standalone renderer for static previews.\n\n### Editor Integration\n\nHere's a complete example using `@uiw/react-codemirror`:\n\n```tsx\nimport CodeMirror from \"@uiw/react-codemirror\";\nimport { draftly, allPlugins, ThemeEnum } from \"draftly\";\nimport { githubDark } from \"@uiw/codemirror-theme-github\";\n\nfunction MarkdownEditor() {\n  return (\n    \u003cCodeMirror\n      value=\"# Welcome to Draftly\\n\\nStart writing...\"\n      height=\"500px\"\n      extensions={[\n        draftly({\n          theme: ThemeEnum.DARK,\n          themeStyle: githubDark,\n          plugins: allPlugins,\n          lineWrapping: true,\n          history: true,\n          indentWithTab: true,\n          onNodesChange: (nodes) =\u003e console.log(\"AST:\", nodes),\n        }),\n      ]}\n    /\u003e\n  );\n}\n```\n\n#### Editor Configuration (`DraftlyConfig`)\n\n| Option                | Type                             | Default          | Description                                              |\n| --------------------- | -------------------------------- | ---------------- | -------------------------------------------------------- |\n| `theme`               | `ThemeEnum`                      | `ThemeEnum.AUTO` | Theme mode: `LIGHT`, `DARK`, or `AUTO`.                  |\n| `themeStyle`          | `Extension`                      | `undefined`      | CodeMirror theme extension (e.g., `githubDark`).         |\n| `plugins`             | `DraftlyPlugin[]`                | `[]`             | Plugins to enable for rendering and parsing.             |\n| `baseStyles`          | `boolean`                        | `true`           | Load default base styles.                                |\n| `disableViewPlugin`   | `boolean`                        | `false`          | Disable rich rendering (raw markdown mode).              |\n| `defaultKeybindings`  | `boolean`                        | `true`           | Enable default CodeMirror keybindings.                   |\n| `history`             | `boolean`                        | `true`           | Enable undo/redo history.                                |\n| `indentWithTab`       | `boolean`                        | `true`           | Use Tab for indentation.                                 |\n| `highlightActiveLine` | `boolean`                        | `true`           | Highlight the current line (in raw mode).                |\n| `lineWrapping`        | `boolean`                        | `true`           | Enable line wrapping.                                    |\n| `onNodesChange`       | `(nodes: DraftlyNode[]) =\u003e void` | `undefined`      | Callback fired on every document update with parsed AST. |\n| `markdown`            | `MarkdownConfig[]`               | `[]`             | Additional Lezer markdown parser extensions.             |\n| `extensions`          | `Extension[]`                    | `[]`             | Additional CodeMirror extensions.                        |\n| `keymap`              | `KeyBinding[]`                   | `[]`             | Additional keybindings.                                  |\n\n---\n\n### Static Preview\n\nRender markdown to semantic HTML for server-side rendering, static site generation, or read-only views.\n\n```tsx\nimport { preview, generateCSS, allPlugins, ThemeEnum } from \"draftly\";\n\nconst markdown = `\n# Hello World\n\nThis is a **bold** statement with some \\`inline code\\`.\n\n- Item 1\n- Item 2\n- Item 3\n`;\n\n// Generate HTML\nconst html = preview(markdown, {\n  theme: ThemeEnum.LIGHT,\n  plugins: allPlugins,\n  sanitize: true,\n  wrapperClass: \"prose\",\n});\n\n// Generate matching CSS\nconst css = generateCSS({\n  theme: ThemeEnum.LIGHT,\n  plugins: allPlugins,\n  wrapperClass: \"prose\",\n  includeBase: true,\n});\n\n// Use in your app\nfunction ArticlePreview() {\n  return (\n    \u003c\u003e\n      \u003cstyle\u003e{css}\u003c/style\u003e\n      \u003carticle dangerouslySetInnerHTML={{ __html: html }} /\u003e\n    \u003c/\u003e\n  );\n}\n```\n\n#### Preview Configuration (`PreviewConfig`)\n\n| Option         | Type               | Default             | Description                           |\n| -------------- | ------------------ | ------------------- | ------------------------------------- |\n| `plugins`      | `DraftlyPlugin[]`  | `[]`                | Plugins for rendering.                |\n| `theme`        | `ThemeEnum`        | `ThemeEnum.AUTO`    | Theme mode.                           |\n| `sanitize`     | `boolean`          | `true`              | Sanitize HTML output (via DOMPurify). |\n| `wrapperClass` | `string`           | `\"draftly-preview\"` | CSS class for the wrapper element.    |\n| `wrapperTag`   | `string`           | `\"article\"`         | HTML tag for the wrapper element.     |\n| `markdown`     | `MarkdownConfig[]` | `[]`                | Additional parser extensions.         |\n\n---\n\n## Features\n\n### 🎯 Rich Text Editing\n\nDraftly's `ViewPlugin` decorates the editor to hide markdown syntax and render styled content inline. This provides a WYSIWYG-like experience while keeping the source as plain markdown.\n\n- **Inline Formatting**: Bold, italic, strikethrough, and code are styled in-place.\n- **Headings**: Rendered with proper sizes and weights.\n- **Lists**: Ordered and unordered lists with custom bullets.\n- **Images**: Displayed inline with alt text and captions.\n- **Links**: Clickable with visual distinction.\n- **Code Blocks**: Syntax highlighted with language detection.\n\n### 🔌 Plugin Architecture\n\nEvery feature in Draftly is a plugin. Plugins can provide:\n\n- **CodeMirror Extensions**: Custom decorations, widgets, and behaviors.\n- **Markdown Parser Extensions**: Extend the Lezer parser for custom syntax.\n- **Keymaps**: Add keyboard shortcuts.\n- **Themes**: Inject custom styles based on the current theme.\n- **Preview Renderers**: Define how elements are rendered to static HTML.\n\n```typescript\nimport { DraftlyPlugin } from \"draftly/editor\";\n\nclass MyCustomPlugin extends DraftlyPlugin {\n  name = \"my-custom-plugin\";\n\n  onRegister(context) {\n    console.log(\"Plugin registered!\", context.config);\n  }\n\n  getExtensions() {\n    return [\n      /* CodeMirror extensions */\n    ];\n  }\n\n  getKeymap() {\n    return [\n      /* KeyBinding[] */\n    ];\n  }\n\n  getMarkdownConfig() {\n    return {\n      /* MarkdownConfig */\n    };\n  }\n\n  theme(mode) {\n    return {\n      /* Theme spec */\n    };\n  }\n}\n```\n\n### 🌲 AST Access\n\nAccess the parsed document structure via the `onNodesChange` callback. Perfect for building:\n\n- **Table of Contents**\n- **Document Outlines**\n- **Navigation Breadcrumbs**\n- **Word/Line Counters**\n\n```typescript\ntype DraftlyNode = {\n  from: number; // Start position\n  to: number; // End position\n  name: string; // Node type (e.g., \"Heading\", \"Paragraph\")\n  children: DraftlyNode[];\n  isSelected: boolean; // True if cursor is within this node\n};\n```\n\n### 🌗 Theming\n\nDraftly provides seamless theming with automatic light/dark mode support:\n\n- **Auto Detection**: Follows system preference with `ThemeEnum.AUTO`.\n- **Manual Control**: Force `ThemeEnum.LIGHT` or `ThemeEnum.DARK`.\n- **Custom Themes**: Pass any CodeMirror theme via `themeStyle`.\n- **Preview Parity**: CSS generation ensures preview matches editor styling.\n\n### 📦 Modular Imports\n\nImport only what you need to minimize bundle size:\n\n```typescript\n// Full package\nimport { draftly, preview, allPlugins } from \"draftly\";\n\n// Editor only\nimport { draftly, DraftlyPlugin } from \"draftly/editor\";\n\n// Preview only\nimport { preview, generateCSS } from \"draftly/preview\";\n\n// Individual plugins\nimport { HeadingPlugin, ListPlugin } from \"draftly/plugins\";\n```\n\n---\n\n## API Reference\n\n### Exports\n\n| Export          | Path              | Description                                     |\n| --------------- | ----------------- | ----------------------------------------------- |\n| `draftly`       | `draftly/editor`  | Main editor extension factory.                  |\n| `DraftlyPlugin` | `draftly/editor`  | Base class for creating plugins.                |\n| `ThemeEnum`     | `draftly/editor`  | Enum for theme modes (`AUTO`, `LIGHT`, `DARK`). |\n| `DraftlyNode`   | `draftly/editor`  | Type for AST nodes.                             |\n| `preview`       | `draftly/preview` | Function to render markdown to HTML.            |\n| `generateCSS`   | `draftly/preview` | Function to generate CSS for preview styling.   |\n| `allPlugins`    | `draftly/plugins` | Array of all built-in plugins.                  |\n\n---\n\n## Browser Support\n\nDraftly supports all modern browsers:\n\n| Browser | Version |\n| ------- | ------- |\n| Chrome  | 88+     |\n| Firefox | 78+     |\n| Safari  | 14+     |\n| Edge    | 88+     |\n\n---\n\n## Contributing\n\nContributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) before submitting a pull request.\n\n---\n\n## License\n\n[MIT](LICENSE) © [NeuroNexul](https://github.com/NeuroNexul)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneuronexul%2Fdraftly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneuronexul%2Fdraftly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneuronexul%2Fdraftly/lists"}