overtype 2.0.4 → 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 |
@@ -740,7 +740,7 @@ Special thanks to:
740
740
  - [kbhomes](https://github.com/kbhomes) - Fixed text selection desynchronization during overscroll ([#17](https://github.com/panphora/overtype/pull/17))
741
741
  - [Kristián Kostecký](https://github.com/kristiankostecky) - Fixed toolbar option being ignored in reinit() ([#62](https://github.com/panphora/overtype/pull/62))
742
742
  - [Lyric Wai](https://github.com/lyricat) - Fixed double-escaping of links ([#64](https://github.com/panphora/overtype/pull/64)), reported code block alignment issues ([#65](https://github.com/panphora/overtype/issues/65))
743
- - [kozi](https://github.com/kozi) - Reported link tooltip issues in Firefox ([#68](https://github.com/panphora/overtype/issues/68)) and toolbar positioning ([#69](https://github.com/panphora/overtype/issues/69))
743
+ - [kozi](https://github.com/kozi) - Reported link tooltip issues in Firefox ([#68](https://github.com/panphora/overtype/issues/68)), toolbar positioning ([#69](https://github.com/panphora/overtype/issues/69)), theme synchronization issues ([#70](https://github.com/panphora/overtype/issues/70), [#71](https://github.com/panphora/overtype/issues/71))
744
744
 
745
745
  ### TypeScript & Framework Support
746
746
  - [merlinz01](https://github.com/merlinz01) - Initial TypeScript definitions implementation ([#20](https://github.com/panphora/overtype/pull/20))
@@ -1,5 +1,5 @@
1
1
  /**
2
- * OverType v2.0.4
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
  }
@@ -1660,16 +1660,22 @@ var solar = {
1660
1660
  // White - editor background
1661
1661
  text: "#0d3b66",
1662
1662
  // Yale Blue - main text
1663
+ textPrimary: "#0d3b66",
1664
+ // Yale Blue - primary text (same as text)
1665
+ textSecondary: "#5a7a9b",
1666
+ // Muted blue - secondary text
1663
1667
  h1: "#f95738",
1664
1668
  // Tomato - h1 headers
1665
1669
  h2: "#ee964b",
1666
- // Sandy Brown - h2 headers
1670
+ // Sandy Brown - h2 headers
1667
1671
  h3: "#3d8a51",
1668
1672
  // Forest green - h3 headers
1669
1673
  strong: "#ee964b",
1670
1674
  // Sandy Brown - bold text
1671
1675
  em: "#f95738",
1672
1676
  // Tomato - italic text
1677
+ del: "#ee964b",
1678
+ // Sandy Brown - deleted text (same as strong)
1673
1679
  link: "#0d3b66",
1674
1680
  // Yale Blue - links
1675
1681
  code: "#0d3b66",
@@ -1682,17 +1688,25 @@ var solar = {
1682
1688
  // Muted blue - horizontal rules
1683
1689
  syntaxMarker: "rgba(13, 59, 102, 0.52)",
1684
1690
  // Yale Blue with transparency
1691
+ syntax: "#999999",
1692
+ // Gray - syntax highlighting fallback
1685
1693
  cursor: "#f95738",
1686
1694
  // Tomato - cursor
1687
1695
  selection: "rgba(244, 211, 94, 0.4)",
1688
1696
  // Naples Yellow with transparency
1689
1697
  listMarker: "#ee964b",
1690
1698
  // Sandy Brown - list markers
1699
+ rawLine: "#5a7a9b",
1700
+ // Muted blue - raw line indicators
1701
+ border: "#e0e0e0",
1702
+ // Light gray - borders
1703
+ hoverBg: "#f0f0f0",
1704
+ // Very light gray - hover backgrounds
1705
+ primary: "#0d3b66",
1706
+ // Yale Blue - primary accent
1691
1707
  // Toolbar colors
1692
1708
  toolbarBg: "#ffffff",
1693
1709
  // White - toolbar background
1694
- toolbarBorder: "rgba(13, 59, 102, 0.15)",
1695
- // Yale Blue border
1696
1710
  toolbarIcon: "#0d3b66",
1697
1711
  // Yale Blue - icon color
1698
1712
  toolbarHover: "#f5f5f5",
@@ -1710,6 +1724,10 @@ var cave = {
1710
1724
  // Darker charcoal - editor background
1711
1725
  text: "#c5dde8",
1712
1726
  // Light blue-gray - main text
1727
+ textPrimary: "#c5dde8",
1728
+ // Light blue-gray - primary text (same as text)
1729
+ textSecondary: "#9fcfec",
1730
+ // Brighter blue - secondary text
1713
1731
  h1: "#d4a5ff",
1714
1732
  // Rich lavender - h1 headers
1715
1733
  h2: "#f6ae2d",
@@ -1720,6 +1738,8 @@ var cave = {
1720
1738
  // Hunyadi Yellow - bold text
1721
1739
  em: "#9fcfec",
1722
1740
  // Brighter blue - italic text
1741
+ del: "#f6ae2d",
1742
+ // Hunyadi Yellow - deleted text (same as strong)
1723
1743
  link: "#9fcfec",
1724
1744
  // Brighter blue - links
1725
1745
  code: "#c5dde8",
@@ -1732,17 +1752,25 @@ var cave = {
1732
1752
  // Light blue-gray - horizontal rules
1733
1753
  syntaxMarker: "rgba(159, 207, 236, 0.73)",
1734
1754
  // Brighter blue semi-transparent
1755
+ syntax: "#7a8c98",
1756
+ // Muted gray-blue - syntax highlighting fallback
1735
1757
  cursor: "#f26419",
1736
1758
  // Orange Pantone - cursor
1737
1759
  selection: "rgba(51, 101, 138, 0.4)",
1738
1760
  // Lapis Lazuli with transparency
1739
1761
  listMarker: "#f6ae2d",
1740
1762
  // Hunyadi Yellow - list markers
1763
+ rawLine: "#9fcfec",
1764
+ // Brighter blue - raw line indicators
1765
+ border: "#2a3f52",
1766
+ // Dark blue-gray - borders
1767
+ hoverBg: "#243546",
1768
+ // Slightly lighter charcoal - hover backgrounds
1769
+ primary: "#9fcfec",
1770
+ // Brighter blue - primary accent
1741
1771
  // Toolbar colors for dark theme
1742
1772
  toolbarBg: "#1D2D3E",
1743
1773
  // Darker charcoal - toolbar background
1744
- toolbarBorder: "rgba(197, 221, 232, 0.1)",
1745
- // Light blue-gray border
1746
1774
  toolbarIcon: "#c5dde8",
1747
1775
  // Light blue-gray - icon color
1748
1776
  toolbarHover: "#243546",
@@ -2262,6 +2290,7 @@ function generateStyles(options = {}) {
2262
2290
  gap: 4px !important;
2263
2291
  padding: 8px !important; /* Override reset */
2264
2292
  background: var(--toolbar-bg, var(--bg-primary, #f8f9fa)) !important; /* Override reset */
2293
+ border-bottom: 1px solid var(--toolbar-border, transparent) !important; /* Override reset */
2265
2294
  overflow-x: auto !important; /* Allow horizontal scrolling */
2266
2295
  overflow-y: hidden !important; /* Hide vertical overflow */
2267
2296
  -webkit-overflow-scrolling: touch !important;
@@ -2733,6 +2762,28 @@ var Toolbar = class {
2733
2762
  button.addEventListener("click", button._clickHandler);
2734
2763
  return button;
2735
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
+ }
2736
2787
  /**
2737
2788
  * Sanitize SVG to prevent XSS
2738
2789
  */
@@ -3671,10 +3722,13 @@ var _OverType = class _OverType {
3671
3722
  */
3672
3723
  handleKeydown(event) {
3673
3724
  if (event.key === "Tab") {
3674
- event.preventDefault();
3675
3725
  const start = this.textarea.selectionStart;
3676
3726
  const end = this.textarea.selectionEnd;
3677
3727
  const value = this.textarea.value;
3728
+ if (event.shiftKey && start === end) {
3729
+ return;
3730
+ }
3731
+ event.preventDefault();
3678
3732
  if (start !== end && event.shiftKey) {
3679
3733
  const before = value.substring(0, start);
3680
3734
  const selection = value.substring(start, end);
@@ -4511,6 +4565,9 @@ var OverTypeEditor = class extends HTMLElement {
4511
4565
  break;
4512
4566
  case "theme":
4513
4567
  this._reinjectStyles();
4568
+ if (this._editor && this._editor.setTheme) {
4569
+ this._editor.setTheme(value || "solar");
4570
+ }
4514
4571
  break;
4515
4572
  case "placeholder":
4516
4573
  if (this._editor.textarea) {