neo-md 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -22
- package/dist/index.d.ts +9 -1
- package/dist/index.js +28247 -5627
- package/dist/index.umd.cjs +111 -60
- package/dist/neo-md.css +1 -1
- package/package.json +28 -3
package/README.md
CHANGED
|
@@ -7,7 +7,11 @@ A modern, highly-configurable, and highly-secure React markdown editor component
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
9
|
- **Markdown Toolbar** - Built-in formatting toolbar with buttons for bold, italic, strikethrough, headings (H1-H3), lists, blockquote, code blocks, links, images, tables, and horizontal rules. Wraps selected text or inserts templates with smart cursor repositioning.
|
|
10
|
+
- **Reading Time Estimate** - Displays estimated reading time based on word count with configurable words-per-minute rate. Helps users gauge content length at a glance.
|
|
11
|
+
- **Selection Word Count** - Real-time statistics for selected text showing character, word, and line counts in a floating tooltip. Perfect for tracking specific sections.
|
|
12
|
+
- **Multi-Format Export** - Export markdown to Markdown (.md) and Plain Text (.txt) formats. Fully customizable format selection per implementation.
|
|
10
13
|
- **Bidirectional Scroll Sync** - Proportional scroll synchronization between editor and preview panes. Scrolling either pane keeps the other in lockstep.
|
|
14
|
+
- **ASCII & Diagram Support** - Precise whitespace preservation in plain text code blocks (` ``` `), ensuring text-based diagrams and ASCII art render exactly as typed without space collapsing.
|
|
11
15
|
- **XSS Prevention** - Raw HTML rendering in the editor pane is secured via `isomorphic-dompurify`.
|
|
12
16
|
- **Syntax Highlighting** - Fully customizable color themes for the editor pane with support for headings, bold, italic, links, code blocks, lists, tables, and more.
|
|
13
17
|
- **Controlled & Uncontrolled Support** - Plug it into external state naturally like a standard input element, or let it manage its own.
|
|
@@ -103,28 +107,31 @@ function App() {
|
|
|
103
107
|
|
|
104
108
|
The `MarkdownEditor` component accepts the following props:
|
|
105
109
|
|
|
106
|
-
| Prop | Type | Default | Description
|
|
107
|
-
| --------------------- | -------------------------------- | -------------------- |
|
|
108
|
-
| `value` | `string` | `undefined` | The controlled markdown text.
|
|
109
|
-
| `defaultValue` | `string` | `(default template)` | Initial text for uncontrolled mode.
|
|
110
|
-
| `onChange` | `(value: string) => void` | `undefined` | Callback fired when text changes.
|
|
111
|
-
| `viewMode` | `"edit" \| "preview" \| "split"` | `undefined` | The controlled view mode.
|
|
112
|
-
| `defaultViewMode` | `"edit" \| "preview" \| "split"` | `"split"` | Initial view mode for uncontrolled mode.
|
|
113
|
-
| `onViewModeChange` | `(mode) => void` | `undefined` | Callback fired when a toolbar tab is clicked.
|
|
114
|
-
| `className` | `string` | `""` | Classes applied to the root container.
|
|
115
|
-
| `editorClassName` | `string` | `""` | Classes applied to the editor pane wrapper.
|
|
116
|
-
| `previewClassName` | `string` | `""` | Classes applied to the preview pane wrapper.
|
|
117
|
-
| `showToolbar` | `boolean` | `true` | Shows the top toolbar block.
|
|
118
|
-
| `showWordCount` | `boolean` | `true` | Shows the character counter badge.
|
|
119
|
-
| `
|
|
120
|
-
| `
|
|
121
|
-
| `
|
|
122
|
-
| `
|
|
123
|
-
| `
|
|
124
|
-
| `
|
|
125
|
-
| `
|
|
126
|
-
| `
|
|
127
|
-
| `
|
|
110
|
+
| Prop | Type | Default | Description |
|
|
111
|
+
| --------------------- | -------------------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
112
|
+
| `value` | `string` | `undefined` | The controlled markdown text. |
|
|
113
|
+
| `defaultValue` | `string` | `(default template)` | Initial text for uncontrolled mode. |
|
|
114
|
+
| `onChange` | `(value: string) => void` | `undefined` | Callback fired when text changes. |
|
|
115
|
+
| `viewMode` | `"edit" \| "preview" \| "split"` | `undefined` | The controlled view mode. |
|
|
116
|
+
| `defaultViewMode` | `"edit" \| "preview" \| "split"` | `"split"` | Initial view mode for uncontrolled mode. |
|
|
117
|
+
| `onViewModeChange` | `(mode) => void` | `undefined` | Callback fired when a toolbar tab is clicked. |
|
|
118
|
+
| `className` | `string` | `""` | Classes applied to the root container. |
|
|
119
|
+
| `editorClassName` | `string` | `""` | Classes applied to the editor pane wrapper. |
|
|
120
|
+
| `previewClassName` | `string` | `""` | Classes applied to the preview pane wrapper. |
|
|
121
|
+
| `showToolbar` | `boolean` | `true` | Shows the top toolbar block. |
|
|
122
|
+
| `showWordCount` | `boolean` | `true` | Shows the character counter badge. |
|
|
123
|
+
| `showReadingTime` | `boolean` | `true` | Shows the estimated reading time badge. |
|
|
124
|
+
| `wordsPerMinute` | `number` | `200` | Words per minute for reading time calculation. |
|
|
125
|
+
| `showSelectionCount` | `boolean` | `true` | Shows floating tooltip with stats for selected text. |
|
|
126
|
+
| `showMarkdownToolbar` | `boolean` | `true` | Shows the markdown formatting toolbar. |
|
|
127
|
+
| `enableDownload` | `boolean \| ExportFormat[]` | `true` | Export button with format options. `true` = all formats (md, txt), `false` = disabled, or array like `['markdown', 'text']` for specific formats. |
|
|
128
|
+
| `enableCopy` | `boolean` | `true` | Toggles the "Copy" button. |
|
|
129
|
+
| `enableScrollSync` | `boolean` | `true` | Toggles bidirectional scroll sync between panes. |
|
|
130
|
+
| `placeholder` | `string` | `"Start typing..."` | Textbox placeholder text. |
|
|
131
|
+
| `readOnly` | `boolean` | `false` | Disables text input and hides the formatting toolbar. |
|
|
132
|
+
| `maxLength` | `number` | `undefined` | Hard cap on textarea character length. |
|
|
133
|
+
| `components` | `Components` | `{}` | Complete `react-markdown` DOM rendering overrides. |
|
|
134
|
+
| `syntaxColors` | `SyntaxHighlightColors` | `defaultColors` | Custom color theme for syntax highlighting. |
|
|
128
135
|
|
|
129
136
|
## Exposed Methods (`MarkdownEditorRef`)
|
|
130
137
|
|
|
@@ -133,6 +140,37 @@ Via `forwardRef`, parents can trigger the following imperatives on the editor:
|
|
|
133
140
|
- `focus()`: Forces browser focus onto the underlying `<textarea>`.
|
|
134
141
|
- `getValue()`: Retrieves the current internal markdown string, particularly useful if you run uncontrolled mode and just want the value on submit.
|
|
135
142
|
|
|
143
|
+
## Roadmap
|
|
144
|
+
|
|
145
|
+
- **Table of Contents Sidebar**
|
|
146
|
+
- Auto-generated from headings
|
|
147
|
+
- Clickable navigation
|
|
148
|
+
- Collapsible sections
|
|
149
|
+
- Sticky/floating mode
|
|
150
|
+
- ✅ **Reading Time Estimate** - _Completed_
|
|
151
|
+
- Based on word count
|
|
152
|
+
- Configurable WPM
|
|
153
|
+
- ✅ **Selection Word Count** - _Completed_
|
|
154
|
+
- Character/word/line count
|
|
155
|
+
- **Minimap (like VS Code)**
|
|
156
|
+
- Document overview
|
|
157
|
+
- Quick scroll navigation
|
|
158
|
+
- ✅ **Export to Multiple Formats** - _Completed_
|
|
159
|
+
- PDF with styling (via browser print)
|
|
160
|
+
- Styled HTML
|
|
161
|
+
- Plain text
|
|
162
|
+
- Markdown
|
|
163
|
+
- **Multiple Themes**
|
|
164
|
+
- Predefined color schemes (Monokai, Solarized, etc.)
|
|
165
|
+
- **Find & Replace**
|
|
166
|
+
- Search with regex support
|
|
167
|
+
- Replace all/one at a time
|
|
168
|
+
- Case sensitivity toggle
|
|
169
|
+
- Highlight matches in editor
|
|
170
|
+
- **Link Preview Cards**
|
|
171
|
+
- Hover over links for preview
|
|
172
|
+
- Unfurl metadata (title, description, image)
|
|
173
|
+
|
|
136
174
|
## Contributing
|
|
137
175
|
|
|
138
176
|
Contributions are welcome! Please see our [Contributing Guide](CONTRIBUTING.md) for detailed information on how to get started, development workflow, and coding guidelines.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Components } from 'react-markdown';
|
|
2
2
|
import { default as default_2 } from 'react';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Export utilities for markdown editor
|
|
6
|
+
*/
|
|
7
|
+
declare type ExportFormat = "markdown" | "text";
|
|
8
|
+
|
|
4
9
|
export declare const MarkdownEditor: default_2.ForwardRefExoticComponent<MarkdownEditorProps & default_2.RefAttributes<MarkdownEditorRef>>;
|
|
5
10
|
|
|
6
11
|
export declare interface MarkdownEditorProps {
|
|
@@ -15,8 +20,11 @@ export declare interface MarkdownEditorProps {
|
|
|
15
20
|
previewClassName?: string;
|
|
16
21
|
showToolbar?: boolean;
|
|
17
22
|
showWordCount?: boolean;
|
|
23
|
+
showReadingTime?: boolean;
|
|
24
|
+
wordsPerMinute?: number;
|
|
25
|
+
showSelectionCount?: boolean;
|
|
18
26
|
showMarkdownToolbar?: boolean;
|
|
19
|
-
enableDownload?: boolean;
|
|
27
|
+
enableDownload?: boolean | ExportFormat[];
|
|
20
28
|
enableCopy?: boolean;
|
|
21
29
|
enableScrollSync?: boolean;
|
|
22
30
|
placeholder?: string;
|