Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [2.2.0] - 2025-12-26

### Added
- File upload support with drag-and-drop and paste handling



## [2.1.1] - 2025-12-13

### Added
Expand Down
70 changes: 66 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OverType

A lightweight markdown editor library with perfect WYSIWYG alignment using an invisible textarea overlay technique. Includes optional toolbar. ~95KB minified with all features.
A lightweight markdown editor library with perfect WYSIWYG alignment using an invisible textarea overlay technique. Includes optional toolbar. ~98KB minified with all features.

## Live Examples

Expand All @@ -19,7 +19,7 @@ A lightweight markdown editor library with perfect WYSIWYG alignment using an in
- ⌨️ **Keyboard shortcuts** - Common markdown shortcuts (Cmd/Ctrl+B for bold, etc.)
- 📱 **Mobile optimized** - Responsive design with mobile-specific styles
- 🔄 **DOM persistence aware** - Recovers from existing DOM (perfect for HyperClay and similar platforms)
- 🚀 **Lightweight** - ~95KB minified
- 🚀 **Lightweight** - ~98KB minified
- 🎯 **Optional toolbar** - Clean, minimal toolbar with all essential formatting
- ✨ **Smart shortcuts** - Keyboard shortcuts with selection preservation
- 📝 **Smart list continuation** - GitHub-style automatic list continuation on Enter
Expand All @@ -35,7 +35,7 @@ We overlap an invisible textarea on top of styled output, giving the illusion of

| Feature | OverType | HyperMD | Milkdown | TUI Editor | EasyMDE |
|---------|----------|---------|----------|------------|---------|
| **Size** | ~95KB | 364.02 KB | 344.51 KB | 560.99 KB | 323.69 KB |
| **Size** | ~98KB | 364.02 KB | 344.51 KB | 560.99 KB | 323.69 KB |
| **Dependencies** | Bundled | CodeMirror | ProseMirror + plugins | Multiple libs | CodeMirror |
| **Setup** | Single file | Complex config | Build step required | Complex config | Moderate |
| **Approach** | Invisible textarea | ContentEditable | ContentEditable | ContentEditable | CodeMirror |
Expand Down Expand Up @@ -355,6 +355,52 @@ function MarkdownEditor({ value, onChange }) {
}
```

### File Upload

When enabled, users can paste or drag-and-drop files into the editor. A placeholder is inserted while the file is uploaded asynchronously.

```javascript
const [editor] = new OverType('#editor', {
fileUpload: {
enabled: true,
onInsertFile: async (file) => {
// Upload file to server here
const formData = new FormData();
formData.append('file', file);
const response = await fetch('/api/upload', {
method: 'POST',
body: formData
});
const data = await response.json();
// Return markdown to insert
return `![${file.name}](${data.url})`;
}
}
});
```

Files can also be uploaded in batch mode by setting `fileUpload.batch` to `true`. In this mode, all files dropped or pasted at once are sent together in a single call to `onInsertFile`, which receives an array of files and should return an array of corresponding markdown strings.

```javascript
const [editor] = new OverType('#editor', {
fileUpload: {
enabled: true,
batch: true, // Enable batch upload
onInsertFile: async (files) => {
const formData = new FormData();
files.forEach(file => formData.append('file[]', file));
const response = await fetch('/api/upload', {
method: 'POST',
body: formData
});
const data = await response.json();
// Return array of markdown strings
return data.urls.map((url, index) => `![${files[index].name}](${url})`);
}
}
});
```

### Standalone Parser

Import and use the markdown parser without the full editor for server-side rendering, static site generation, or browser extensions:
Expand Down Expand Up @@ -473,7 +519,22 @@ new OverType(target, options)

// Callbacks
onChange: (value, instance) => {},
onKeydown: (event, instance) => {}
onKeydown: (event, instance) => {},

// File Upload
fileUpload: {
enabled: false, // Enable/disable file upload
maxSize: 10 * 1024 * 1024, // Defaults to 10 MB
mimeTypes: [], // Allowed mime types. Default is all files allowed
onInsertFile: async (file) => {
// Callback when placeholder is inserted into editor
// Upload to server here
// (e.g await fetch('/api/upload'))

// Return the markdown that should replace the placeholder
return `![${file.name}](/uploads/${encodeURIComponent(file.name)})`;
},
}
}
```

Expand Down Expand Up @@ -775,6 +836,7 @@ Special thanks to:
- [1951FDG](https://github.com/1951FDG) - Reported unordered list rendering bug ([#74](https://github.com/panphora/overtype/issues/74)), suggested showStats() API improvement ([#77](https://github.com/panphora/overtype/issues/77))
- [nodesocket](https://github.com/nodesocket) - Reported toolbarButtons export issues ([#73](https://github.com/panphora/overtype/issues/73), [#78](https://github.com/panphora/overtype/issues/78))
- [Travis Bell](https://github.com/travisbell) - Reported keyboard shortcuts bug in ESM build ([#80](https://github.com/panphora/overtype/issues/80))
- [Richard Leek](https://github.com/sorokya) - Added file upload feature ([#27](https://github.com/panphora/overtype/issues/27))

### TypeScript & Framework Support
- [merlinz01](https://github.com/merlinz01) - Contributed TypeScript declaration file ([#20](https://github.com/panphora/overtype/pull/20))
Expand Down
116 changes: 115 additions & 1 deletion dist/overtype-webcomponent.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

116 changes: 115 additions & 1 deletion dist/overtype-webcomponent.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading