overtype 2.3.3 → 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 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. ~117KB minified with all features.
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** - ~117KB minified
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** | ~117KB | 364.02 KB | 344.51 KB | 560.99 KB | 323.69 KB |
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 |
@@ -69,7 +69,7 @@ npm install overtype
69
69
 
70
70
  ### CDN
71
71
  ```html
72
- <script src="https://unpkg.com/overtype/dist/overtype.min.js"></script>
72
+ <script src="https://cdn.jsdelivr.net/npm/overtype@latest/dist/overtype.min.js"></script>
73
73
  ```
74
74
 
75
75
  ## Quick Start
@@ -1,5 +1,5 @@
1
1
  /**
2
- * OverType v2.3.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 */
@@ -1678,6 +1688,11 @@ function generateStyles(options = {}) {
1678
1688
  cursor: text !important;
1679
1689
  }
1680
1690
 
1691
+ .overtype-container.overtype-auto-resize[data-mode="preview"] .overtype-preview {
1692
+ position: static !important;
1693
+ height: auto !important;
1694
+ }
1695
+
1681
1696
  /* Hide syntax markers in preview mode */
1682
1697
  .overtype-container[data-mode="preview"] .syntax-marker {
1683
1698
  display: none !important;
@@ -4746,6 +4761,7 @@ var _OverType = class _OverType {
4746
4761
  // Callbacks
4747
4762
  onChange: null,
4748
4763
  onKeydown: null,
4764
+ onRender: null,
4749
4765
  // Features
4750
4766
  showActiveLineRaw: false,
4751
4767
  showStats: false,
@@ -5144,6 +5160,9 @@ var _OverType = class _OverType {
5144
5160
  if (this.options.onChange && this.initialized) {
5145
5161
  this.options.onChange(text, this);
5146
5162
  }
5163
+ if (this.options.onRender) {
5164
+ this.options.onRender(this.preview, isPreviewMode ? "preview" : "normal", this);
5165
+ }
5147
5166
  }
5148
5167
  /**
5149
5168
  * Apply background styling to code blocks
@@ -5585,11 +5604,18 @@ var _OverType = class _OverType {
5585
5604
  const preview = this.preview;
5586
5605
  const wrapper = this.wrapper;
5587
5606
  const isPreviewMode = this.container.dataset.mode === "preview";
5588
- const scrollTop = isPreviewMode ? preview.scrollTop : textarea.scrollTop;
5607
+ if (isPreviewMode) {
5608
+ wrapper.style.removeProperty("height");
5609
+ preview.style.removeProperty("height");
5610
+ preview.style.removeProperty("overflow-y");
5611
+ textarea.style.removeProperty("height");
5612
+ textarea.style.removeProperty("overflow-y");
5613
+ return;
5614
+ }
5615
+ const scrollTop = textarea.scrollTop;
5589
5616
  wrapper.style.setProperty("height", "auto", "important");
5590
- preview.style.setProperty("height", "auto", "important");
5591
5617
  textarea.style.setProperty("height", "auto", "important");
5592
- let newHeight = isPreviewMode ? preview.scrollHeight : textarea.scrollHeight;
5618
+ let newHeight = textarea.scrollHeight;
5593
5619
  if (this.options.minHeight) {
5594
5620
  const minHeight = parseInt(this.options.minHeight);
5595
5621
  newHeight = Math.max(newHeight, minHeight);
@@ -6003,6 +6029,7 @@ var OverTypeEditor = class extends HTMLElement {
6003
6029
  this._isConnected = false;
6004
6030
  this._handleChange = this._handleChange.bind(this);
6005
6031
  this._handleKeydown = this._handleKeydown.bind(this);
6032
+ this._handleRender = this._handleRender.bind(this);
6006
6033
  }
6007
6034
  /**
6008
6035
  * Decode common escape sequences from attribute string values
@@ -6173,7 +6200,8 @@ var OverTypeEditor = class extends HTMLElement {
6173
6200
  smartLists: !this.hasAttribute("smart-lists") || this.getAttribute("smart-lists") !== "false",
6174
6201
  spellcheck: this.hasAttribute("spellcheck") && this.getAttribute("spellcheck") !== "false",
6175
6202
  onChange: this._handleChange,
6176
- onKeydown: this._handleKeydown
6203
+ onKeydown: this._handleKeydown,
6204
+ onRender: this._handleRender
6177
6205
  };
6178
6206
  const fontSize = this.getAttribute("font-size");
6179
6207
  if (fontSize)
@@ -6392,6 +6420,19 @@ var OverTypeEditor = class extends HTMLElement {
6392
6420
  editor: this._editor
6393
6421
  });
6394
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
+ }
6395
6436
  /**
6396
6437
  * Update value attribute without triggering observer
6397
6438
  * @private