overtype 1.1.8 → 1.2.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # OverType
2
2
 
3
- A lightweight markdown editor library with perfect WYSIWYG alignment using an invisible textarea overlay technique. Includes optional toolbar. ~45KB minified with all features.
3
+ A lightweight markdown editor library with perfect WYSIWYG alignment using an invisible textarea overlay technique. Includes optional toolbar. ~78KB minified with all features.
4
4
 
5
5
  ## Features
6
6
 
@@ -9,7 +9,7 @@ A lightweight markdown editor library with perfect WYSIWYG alignment using an in
9
9
  - ⌨️ **Keyboard shortcuts** - Common markdown shortcuts (Cmd/Ctrl+B for bold, etc.)
10
10
  - 📱 **Mobile optimized** - Responsive design with mobile-specific styles
11
11
  - 🔄 **DOM persistence aware** - Recovers from existing DOM (perfect for HyperClay and similar platforms)
12
- - 🚀 **Lightweight** - ~45KB minified
12
+ - 🚀 **Lightweight** - ~78KB minified
13
13
  - 🎯 **Optional toolbar** - Clean, minimal toolbar with all essential formatting
14
14
  - ✨ **Smart shortcuts** - Keyboard shortcuts with selection preservation
15
15
  - 🔧 **Framework agnostic** - Works with React, Vue, vanilla JS, and more
@@ -24,7 +24,7 @@ We overlap an invisible textarea on top of styled output, giving the illusion of
24
24
 
25
25
  | Feature | OverType | HyperMD | Milkdown | TUI Editor | EasyMDE |
26
26
  |---------|----------|---------|----------|------------|---------|
27
- | **Size** | ~45KB | 364.02 KB | 344.51 KB | 560.99 KB | 323.69 KB |
27
+ | **Size** | ~78KB | 364.02 KB | 344.51 KB | 560.99 KB | 323.69 KB |
28
28
  | **Dependencies** | Bundled | CodeMirror | ProseMirror + plugins | Multiple libs | CodeMirror |
29
29
  | **Setup** | Single file | Complex config | Build step required | Complex config | Moderate |
30
30
  | **Approach** | Invisible textarea | ContentEditable | ContentEditable | ContentEditable | CodeMirror |
@@ -96,10 +96,10 @@ editor.setTheme('cave');
96
96
  </script>
97
97
  ```
98
98
 
99
- ### Toolbar
99
+ ### Toolbar & View Modes
100
100
 
101
101
  ```javascript
102
- // Enable the toolbar
102
+ // Enable the toolbar with view mode switcher
103
103
  const [editor] = new OverType('#editor', {
104
104
  toolbar: true, // Enables the toolbar
105
105
  value: '# Document\n\nSelect text and use the toolbar buttons!'
@@ -110,7 +110,17 @@ const [editor] = new OverType('#editor', {
110
110
  // - Heading levels (H1, H2, H3)
111
111
  // - Links, inline code, code blocks
112
112
  // - Bullet and numbered lists
113
+ // - View mode switcher (eye icon dropdown)
113
114
  // - All with keyboard shortcuts!
115
+
116
+ // Three view modes available via toolbar dropdown:
117
+ // 1. Normal Edit - Default WYSIWYG markdown editing
118
+ // 2. Plain Textarea - Shows raw markdown without preview overlay
119
+ // 3. Preview Mode - Read-only rendered preview with clickable links
120
+
121
+ // Programmatically switch modes:
122
+ editor.showPlainTextarea(true); // Switch to plain textarea mode
123
+ editor.showPreviewMode(true); // Switch to preview mode
114
124
  ```
115
125
 
116
126
  ### Keyboard Shortcuts
@@ -188,6 +198,35 @@ const [editor] = new OverType('#editor', {
188
198
  });
189
199
  ```
190
200
 
201
+ ### Preview & HTML Export
202
+
203
+ Generate HTML previews or export the rendered content:
204
+
205
+ ```javascript
206
+ const [editor] = new OverType('#editor', {
207
+ value: '# Title\n\n**Bold** text with [links](https://example.com)'
208
+ });
209
+
210
+ // Get the raw markdown
211
+ const markdown = editor.getValue();
212
+ // Returns: "# Title\n\n**Bold** text with [links](https://example.com)"
213
+
214
+ // Get rendered HTML for display
215
+ const html = editor.getRenderedHTML();
216
+ // Returns basic HTML with markdown elements
217
+
218
+ // Get HTML with post-processing (consolidated lists/code blocks)
219
+ const processedHTML = editor.getRenderedHTML(true);
220
+ // Returns HTML optimized for preview mode
221
+
222
+ // Get the current preview element's HTML
223
+ const previewHTML = editor.getPreviewHTML();
224
+ // Returns exactly what's shown in the editor's preview layer
225
+
226
+ // Example: Create external preview
227
+ document.getElementById('external-preview').innerHTML = editor.getRenderedHTML(true);
228
+ ```
229
+
191
230
  ### Stats Bar
192
231
 
193
232
  Enable a built-in stats bar that shows character, word, and line counts:
@@ -290,6 +329,11 @@ new OverType(target, options)
290
329
  placeholder: 'Start typing...',
291
330
  value: '',
292
331
 
332
+ // Auto-resize
333
+ autoResize: false, // Auto-expand height with content
334
+ minHeight: '100px', // Minimum height when autoResize is enabled
335
+ maxHeight: null, // Maximum height (null = unlimited)
336
+
293
337
  // Native textarea properties
294
338
  textareaProps: {
295
339
  required: true,
@@ -298,8 +342,11 @@ new OverType(target, options)
298
342
  // Any HTML textarea attribute
299
343
  },
300
344
 
345
+ // Toolbar
346
+ toolbar: false, // Enable/disable toolbar with formatting buttons
347
+
301
348
  // Stats bar
302
- showStats: false, // Enable/disable stats bar
349
+ showStats: false, // Enable/disable stats bar
303
350
  statsFormatter: (stats) => { // Custom stats format
304
351
  return `${stats.chars} chars | ${stats.words} words`;
305
352
  },
@@ -319,10 +366,23 @@ editor.getValue()
319
366
  // Set markdown content
320
367
  editor.setValue(markdown)
321
368
 
369
+ // Get rendered HTML of the current content
370
+ editor.getRenderedHTML() // Basic HTML rendering
371
+ editor.getRenderedHTML(true) // With post-processing (consolidated lists/code blocks)
372
+
373
+ // Get the current preview element's HTML
374
+ editor.getPreviewHTML() // Returns exactly what's displayed in the preview
375
+
322
376
  // Change theme
323
377
  editor.setTheme('cave') // Built-in theme name
324
378
  editor.setTheme(customThemeObject) // Custom theme
325
379
 
380
+ // View modes
381
+ editor.showPlainTextarea(true) // Switch to plain textarea mode
382
+ editor.showPlainTextarea(false) // Switch back to normal mode
383
+ editor.showPreviewMode(true) // Switch to preview mode
384
+ editor.showPreviewMode(false) // Switch back to normal mode
385
+
326
386
  // Focus/blur
327
387
  editor.focus()
328
388
  editor.blur()