overtype 2.0.5 → 2.0.6

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. ~92KB minified with all features.
3
+ A lightweight markdown editor library with perfect WYSIWYG alignment using an invisible textarea overlay technique. Includes optional toolbar. ~93KB 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** - ~92KB minified
22
+ - 🚀 **Lightweight** - ~93KB 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** | ~92KB | 364.02 KB | 344.51 KB | 560.99 KB | 323.69 KB |
38
+ | **Size** | ~93KB | 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.0.5
2
+ * OverType v2.0.6
3
3
  * A lightweight markdown editor library with perfect WYSIWYG alignment
4
4
  * @license MIT
5
5
  * @author David Miranda
@@ -91,7 +91,7 @@ var MarkdownParser = class {
91
91
  * @returns {string} Parsed bullet list item
92
92
  */
93
93
  static parseBulletList(html) {
94
- return html.replace(/^((?: )*)([-*])\s(.+)$/, (match, indent, marker, content) => {
94
+ return html.replace(/^((?: )*)([-*+])\s(.+)$/, (match, indent, marker, content) => {
95
95
  return `${indent}<li class="bullet-list"><span class="syntax-marker">${marker} </span>${content}</li>`;
96
96
  });
97
97
  }
@@ -150,7 +150,7 @@ var MarkdownParser = class {
150
150
  * @returns {string} HTML with italic styling
151
151
  */
152
152
  static parseItalic(html) {
153
- html = html.replace(new RegExp("(?<!\\*)\\*(?!\\*)(.+?)(?<!\\*)\\*(?!\\*)", "g"), '<em><span class="syntax-marker">*</span>$1<span class="syntax-marker">*</span></em>');
153
+ html = html.replace(new RegExp("(?<![\\*>])\\*(?!\\*)(.+?)(?<!\\*)\\*(?!\\*)", "g"), '<em><span class="syntax-marker">*</span>$1<span class="syntax-marker">*</span></em>');
154
154
  html = html.replace(new RegExp("(?<=^|\\s)_(?!_)(.+?)(?<!_)_(?!_)(?=\\s|$)", "g"), '<em><span class="syntax-marker">_</span>$1<span class="syntax-marker">_</span></em>');
155
155
  return html;
156
156
  }
@@ -2762,6 +2762,28 @@ var Toolbar = class {
2762
2762
  button.addEventListener("click", button._clickHandler);
2763
2763
  return button;
2764
2764
  }
2765
+ /**
2766
+ * Handle button action programmatically (used by keyboard shortcuts)
2767
+ * @param {Object} buttonConfig - Button configuration object with action function
2768
+ */
2769
+ async handleAction(buttonConfig) {
2770
+ this.editor.textarea.focus();
2771
+ try {
2772
+ if (buttonConfig.action) {
2773
+ await buttonConfig.action({
2774
+ editor: this.editor,
2775
+ getValue: () => this.editor.getValue(),
2776
+ setValue: (value) => this.editor.setValue(value),
2777
+ event: null
2778
+ });
2779
+ }
2780
+ } catch (error) {
2781
+ console.error(`Action "${buttonConfig.name}" error:`, error);
2782
+ this.editor.wrapper.dispatchEvent(new CustomEvent("button-error", {
2783
+ detail: { buttonName: buttonConfig.name, error }
2784
+ }));
2785
+ }
2786
+ }
2765
2787
  /**
2766
2788
  * Sanitize SVG to prevent XSS
2767
2789
  */
@@ -3700,10 +3722,13 @@ var _OverType = class _OverType {
3700
3722
  */
3701
3723
  handleKeydown(event) {
3702
3724
  if (event.key === "Tab") {
3703
- event.preventDefault();
3704
3725
  const start = this.textarea.selectionStart;
3705
3726
  const end = this.textarea.selectionEnd;
3706
3727
  const value = this.textarea.value;
3728
+ if (event.shiftKey && start === end) {
3729
+ return;
3730
+ }
3731
+ event.preventDefault();
3707
3732
  if (start !== end && event.shiftKey) {
3708
3733
  const before = value.substring(0, start);
3709
3734
  const selection = value.substring(start, end);