overtype 2.3.4 → 2.3.5
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 +3 -3
- package/dist/overtype-webcomponent.esm.js +31 -2
- package/dist/overtype-webcomponent.esm.js.map +2 -2
- package/dist/overtype-webcomponent.js +31 -2
- package/dist/overtype-webcomponent.js.map +2 -2
- package/dist/overtype-webcomponent.min.js +20 -10
- package/dist/overtype.cjs +15 -1
- package/dist/overtype.cjs.map +2 -2
- package/dist/overtype.esm.js +15 -1
- package/dist/overtype.esm.js.map +2 -2
- package/dist/overtype.js +15 -1
- package/dist/overtype.js.map +2 -2
- package/dist/overtype.min.js +16 -6
- package/package.json +3 -2
- package/src/overtype-webcomponent.js +17 -1
- package/src/overtype.js +6 -0
- package/src/styles.js +10 -0
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. ~
|
|
3
|
+
A lightweight markdown editor library with perfect WYSIWYG alignment using an invisible textarea overlay technique. Includes optional toolbar. ~118KB minified with all features.
|
|
4
4
|
|
|
5
5
|
## Live Examples
|
|
6
6
|
|
|
@@ -19,7 +19,7 @@ A lightweight markdown editor library with perfect WYSIWYG alignment using an in
|
|
|
19
19
|
- ⌨️ **Keyboard shortcuts** - Common markdown shortcuts (Cmd/Ctrl+B for bold, etc.)
|
|
20
20
|
- 📱 **Mobile optimized** - Responsive design with mobile-specific styles
|
|
21
21
|
- 🔄 **DOM persistence aware** - Recovers from existing DOM (perfect for HyperClay and similar platforms)
|
|
22
|
-
- 🚀 **Lightweight** - ~
|
|
22
|
+
- 🚀 **Lightweight** - ~118KB minified
|
|
23
23
|
- 🎯 **Optional toolbar** - Clean, minimal toolbar with all essential formatting
|
|
24
24
|
- ✨ **Smart shortcuts** - Keyboard shortcuts with selection preservation
|
|
25
25
|
- 📝 **Smart list continuation** - GitHub-style automatic list continuation on Enter
|
|
@@ -35,7 +35,7 @@ We overlap an invisible textarea on top of styled output, giving the illusion of
|
|
|
35
35
|
|
|
36
36
|
| Feature | OverType | HyperMD | Milkdown | TUI Editor | EasyMDE |
|
|
37
37
|
|---------|----------|---------|----------|------------|---------|
|
|
38
|
-
| **Size** | ~
|
|
38
|
+
| **Size** | ~118KB | 364.02 KB | 344.51 KB | 560.99 KB | 323.69 KB |
|
|
39
39
|
| **Dependencies** | Bundled | CodeMirror | ProseMirror + plugins | Multiple libs | CodeMirror |
|
|
40
40
|
| **Setup** | Single file | Complex config | Build step required | Complex config | Moderate |
|
|
41
41
|
| **Approach** | Invisible textarea | ContentEditable | ContentEditable | ContentEditable | CodeMirror |
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OverType v2.3.
|
|
2
|
+
* OverType v2.3.5
|
|
3
3
|
* A lightweight markdown editor library with perfect WYSIWYG alignment
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @author David Miranda
|
|
@@ -1241,6 +1241,16 @@ function generateStyles(options = {}) {
|
|
|
1241
1241
|
-ms-user-select: none !important;
|
|
1242
1242
|
}
|
|
1243
1243
|
|
|
1244
|
+
/* Prevent external resets (Tailwind, Bootstrap, etc.) from breaking alignment.
|
|
1245
|
+
Any element whose font metrics differ from the textarea causes the CSS "strut"
|
|
1246
|
+
to inflate line boxes, drifting the overlay. Force inheritance so every element
|
|
1247
|
+
inside the preview matches the textarea exactly. */
|
|
1248
|
+
.overtype-wrapper .overtype-preview * {
|
|
1249
|
+
font-family: inherit !important;
|
|
1250
|
+
font-size: inherit !important;
|
|
1251
|
+
line-height: inherit !important;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1244
1254
|
/* Defensive styles for preview child divs */
|
|
1245
1255
|
.overtype-wrapper .overtype-preview div {
|
|
1246
1256
|
/* Reset any inherited styles */
|
|
@@ -4751,6 +4761,7 @@ var _OverType = class _OverType {
|
|
|
4751
4761
|
// Callbacks
|
|
4752
4762
|
onChange: null,
|
|
4753
4763
|
onKeydown: null,
|
|
4764
|
+
onRender: null,
|
|
4754
4765
|
// Features
|
|
4755
4766
|
showActiveLineRaw: false,
|
|
4756
4767
|
showStats: false,
|
|
@@ -5149,6 +5160,9 @@ var _OverType = class _OverType {
|
|
|
5149
5160
|
if (this.options.onChange && this.initialized) {
|
|
5150
5161
|
this.options.onChange(text, this);
|
|
5151
5162
|
}
|
|
5163
|
+
if (this.options.onRender) {
|
|
5164
|
+
this.options.onRender(this.preview, isPreviewMode ? "preview" : "normal", this);
|
|
5165
|
+
}
|
|
5152
5166
|
}
|
|
5153
5167
|
/**
|
|
5154
5168
|
* Apply background styling to code blocks
|
|
@@ -6015,6 +6029,7 @@ var OverTypeEditor = class extends HTMLElement {
|
|
|
6015
6029
|
this._isConnected = false;
|
|
6016
6030
|
this._handleChange = this._handleChange.bind(this);
|
|
6017
6031
|
this._handleKeydown = this._handleKeydown.bind(this);
|
|
6032
|
+
this._handleRender = this._handleRender.bind(this);
|
|
6018
6033
|
}
|
|
6019
6034
|
/**
|
|
6020
6035
|
* Decode common escape sequences from attribute string values
|
|
@@ -6185,7 +6200,8 @@ var OverTypeEditor = class extends HTMLElement {
|
|
|
6185
6200
|
smartLists: !this.hasAttribute("smart-lists") || this.getAttribute("smart-lists") !== "false",
|
|
6186
6201
|
spellcheck: this.hasAttribute("spellcheck") && this.getAttribute("spellcheck") !== "false",
|
|
6187
6202
|
onChange: this._handleChange,
|
|
6188
|
-
onKeydown: this._handleKeydown
|
|
6203
|
+
onKeydown: this._handleKeydown,
|
|
6204
|
+
onRender: this._handleRender
|
|
6189
6205
|
};
|
|
6190
6206
|
const fontSize = this.getAttribute("font-size");
|
|
6191
6207
|
if (fontSize)
|
|
@@ -6404,6 +6420,19 @@ var OverTypeEditor = class extends HTMLElement {
|
|
|
6404
6420
|
editor: this._editor
|
|
6405
6421
|
});
|
|
6406
6422
|
}
|
|
6423
|
+
/**
|
|
6424
|
+
* Handle render events from OverType
|
|
6425
|
+
* @private
|
|
6426
|
+
* @param {HTMLElement} preview - The preview DOM element
|
|
6427
|
+
* @param {string} mode - Current mode ('normal' or 'preview')
|
|
6428
|
+
*/
|
|
6429
|
+
_handleRender(preview, mode) {
|
|
6430
|
+
this._dispatchEvent("render", {
|
|
6431
|
+
preview,
|
|
6432
|
+
mode,
|
|
6433
|
+
editor: this._editor
|
|
6434
|
+
});
|
|
6435
|
+
}
|
|
6407
6436
|
/**
|
|
6408
6437
|
* Update value attribute without triggering observer
|
|
6409
6438
|
* @private
|