overtype 2.3.5 → 2.3.7
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 +11 -6
- package/dist/overtype-webcomponent.esm.js +52 -43
- package/dist/overtype-webcomponent.esm.js.map +2 -2
- package/dist/overtype-webcomponent.js +52 -43
- package/dist/overtype-webcomponent.js.map +2 -2
- package/dist/overtype-webcomponent.min.js +49 -58
- package/dist/overtype.cjs +52 -43
- package/dist/overtype.cjs.map +2 -2
- package/dist/overtype.esm.js +52 -43
- package/dist/overtype.esm.js.map +2 -2
- package/dist/overtype.js +52 -43
- package/dist/overtype.js.map +2 -2
- package/dist/overtype.min.js +50 -59
- package/package.json +1 -1
- package/src/overtype.js +44 -27
- package/src/parser.js +3 -3
- package/src/styles.js +9 -18
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. ~117KB 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** - ~117KB 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** | ~117KB | 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 |
|
|
@@ -775,14 +775,19 @@ Special thanks to:
|
|
|
775
775
|
- [Kristián Kostecký](https://github.com/kristiankostecky) - Fixed toolbar option being ignored in reinit() ([#62](https://github.com/panphora/overtype/pull/62))
|
|
776
776
|
- [Lyric Wai](https://github.com/lyricat) - Fixed double-escaping of links ([#64](https://github.com/panphora/overtype/pull/64)), shared code block alignment fix ([#65](https://github.com/panphora/overtype/issues/65))
|
|
777
777
|
- [kozi](https://github.com/kozi) - Reported Firefox link tooltip bug ([#68](https://github.com/panphora/overtype/issues/68)), toolbar positioning ([#69](https://github.com/panphora/overtype/issues/69)), theme CSS variable issues ([#70](https://github.com/panphora/overtype/issues/70), [#71](https://github.com/panphora/overtype/issues/71))
|
|
778
|
-
- [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))
|
|
779
|
-
- [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)), suggested image toolbar button ([#89](https://github.com/panphora/overtype/issues/89))
|
|
778
|
+
- [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)), reported placeholder CSS regression ([#102](https://github.com/panphora/overtype/issues/102))
|
|
779
|
+
- [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)), suggested image toolbar button ([#89](https://github.com/panphora/overtype/issues/89)), reported custom theme stats bar styling ([#101](https://github.com/panphora/overtype/issues/101))
|
|
780
780
|
- [Travis Bell](https://github.com/travisbell) - Reported keyboard shortcuts bug in ESM build ([#80](https://github.com/panphora/overtype/issues/80))
|
|
781
781
|
- [fab2713](https://github.com/fab2713) - Reported italic rendering in lists ([#81](https://github.com/panphora/overtype/issues/81)), reinit maxHeight ([#82](https://github.com/panphora/overtype/issues/82)), placeholder visibility ([#83](https://github.com/panphora/overtype/issues/83)), suggested auto theme ([#84](https://github.com/panphora/overtype/issues/84)), relative URL prefix ([#85](https://github.com/panphora/overtype/issues/85)), minification improvements ([#94](https://github.com/panphora/overtype/issues/94))
|
|
782
782
|
- [oooo-ps](https://github.com/oooo-ps) - Reported remote script loading issue ([#86](https://github.com/panphora/overtype/issues/86))
|
|
783
|
-
- [ddarfantasy](https://github.com/ddarfantasy) - Reported text misalignment
|
|
783
|
+
- [ddarfantasy](https://github.com/ddarfantasy), [ThaUnknown](https://github.com/ThaUnknown) - Reported and debugged text misalignment caused by CSS framework font resets ([#91](https://github.com/panphora/overtype/issues/91))
|
|
784
784
|
- [milen-yordanov](https://github.com/milen-yordanov) - Reported code block colors ignoring theme in preview mode ([#97](https://github.com/panphora/overtype/issues/97))
|
|
785
785
|
- [asalimian](https://github.com/asalimian) - Reported spellcheck being disabled ([#98](https://github.com/panphora/overtype/issues/98))
|
|
786
|
+
- [be5invis](https://github.com/be5invis) - Reported reinit() not propagating fontSize changes ([#108](https://github.com/panphora/overtype/issues/108))
|
|
787
|
+
- [Danny Vink](https://github.com/dannyvink) - Fixed task list overlay alignment with spaced checkbox markers ([#109](https://github.com/panphora/overtype/pull/109))
|
|
788
|
+
- [yurivish](https://github.com/yurivish) - Reported fontFamily option not being applied ([#110](https://github.com/panphora/overtype/issues/110))
|
|
789
|
+
- [phinnaeus](https://github.com/phinnaeus) - Diagnosed missing fontFamily wiring ([#110](https://github.com/panphora/overtype/issues/110))
|
|
790
|
+
- [Tan Nhu](https://github.com/tnhu) - Fixed onChange feedback loop with async syntax highlighters ([#111](https://github.com/panphora/overtype/pull/111))
|
|
786
791
|
|
|
787
792
|
### TypeScript & Framework Support
|
|
788
793
|
- [merlinz01](https://github.com/merlinz01) - Contributed TypeScript declaration file ([#20](https://github.com/panphora/overtype/pull/20))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OverType v2.3.
|
|
2
|
+
* OverType v2.3.7
|
|
3
3
|
* A lightweight markdown editor library with perfect WYSIWYG alignment
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @author David Miranda
|
|
@@ -122,13 +122,13 @@ var MarkdownParser = class {
|
|
|
122
122
|
* @returns {string} Parsed task list item
|
|
123
123
|
*/
|
|
124
124
|
static parseTaskList(html, isPreviewMode = false) {
|
|
125
|
-
return html.replace(/^((?: )*)
|
|
125
|
+
return html.replace(/^((?: )*)-(\s+)\[([ xX])\](\s*)(.*)$/, (match, indent, spacingBeforeBox, checked, spacingAfterBox, content) => {
|
|
126
126
|
content = this.parseInlineElements(content);
|
|
127
127
|
if (isPreviewMode) {
|
|
128
128
|
const isChecked = checked.toLowerCase() === "x";
|
|
129
129
|
return `${indent}<li class="task-list"><input type="checkbox" ${isChecked ? "checked" : ""}> ${content}</li>`;
|
|
130
130
|
} else {
|
|
131
|
-
return `${indent}<li class="task-list"><span class="syntax-marker"
|
|
131
|
+
return `${indent}<li class="task-list"><span class="syntax-marker">-${spacingBeforeBox}[${checked}]${spacingAfterBox}</span>${content}</li>`;
|
|
132
132
|
}
|
|
133
133
|
});
|
|
134
134
|
}
|
|
@@ -1106,9 +1106,9 @@ function generateStyles(options = {}) {
|
|
|
1106
1106
|
left: 0 !important;
|
|
1107
1107
|
width: 100% !important;
|
|
1108
1108
|
height: 100% !important;
|
|
1109
|
-
|
|
1109
|
+
|
|
1110
1110
|
/* Font properties - any difference breaks alignment */
|
|
1111
|
-
font-family: ${fontFamily} !important;
|
|
1111
|
+
font-family: var(--instance-font-family, ${fontFamily}) !important;
|
|
1112
1112
|
font-variant-ligatures: none !important; /* keep metrics stable for code */
|
|
1113
1113
|
font-size: var(--instance-font-size, ${fontSize}) !important;
|
|
1114
1114
|
line-height: var(--instance-line-height, ${lineHeight}) !important;
|
|
@@ -1215,15 +1215,12 @@ function generateStyles(options = {}) {
|
|
|
1215
1215
|
z-index: 0 !important;
|
|
1216
1216
|
pointer-events: none !important;
|
|
1217
1217
|
user-select: none !important;
|
|
1218
|
-
font-family: ${fontFamily} !important;
|
|
1218
|
+
font-family: var(--instance-font-family, ${fontFamily}) !important;
|
|
1219
1219
|
font-size: var(--instance-font-size, ${fontSize}) !important;
|
|
1220
1220
|
line-height: var(--instance-line-height, ${lineHeight}) !important;
|
|
1221
1221
|
padding: var(--instance-padding, ${padding}) !important;
|
|
1222
1222
|
box-sizing: border-box !important;
|
|
1223
1223
|
color: var(--placeholder, #999) !important;
|
|
1224
|
-
overflow: hidden !important;
|
|
1225
|
-
white-space: nowrap !important;
|
|
1226
|
-
text-overflow: ellipsis !important;
|
|
1227
1224
|
}
|
|
1228
1225
|
|
|
1229
1226
|
/* Preview layer styles */
|
|
@@ -1376,7 +1373,7 @@ function generateStyles(options = {}) {
|
|
|
1376
1373
|
.overtype-wrapper .overtype-preview pre code {
|
|
1377
1374
|
background: transparent !important;
|
|
1378
1375
|
color: var(--code, #0d3b66) !important;
|
|
1379
|
-
font-family: ${fontFamily} !important; /* Match textarea font exactly for alignment */
|
|
1376
|
+
font-family: var(--instance-font-family, ${fontFamily}) !important; /* Match textarea font exactly for alignment */
|
|
1380
1377
|
}
|
|
1381
1378
|
|
|
1382
1379
|
/* Blockquotes */
|
|
@@ -1461,26 +1458,20 @@ function generateStyles(options = {}) {
|
|
|
1461
1458
|
.overtype-stats {
|
|
1462
1459
|
height: 40px !important;
|
|
1463
1460
|
padding: 0 20px !important;
|
|
1464
|
-
background: #f8f9fa !important;
|
|
1465
|
-
border-top: 1px solid #e0e0e0 !important;
|
|
1461
|
+
background: var(--bg-secondary, #f8f9fa) !important;
|
|
1462
|
+
border-top: 1px solid var(--border, #e0e0e0) !important;
|
|
1466
1463
|
display: flex !important;
|
|
1467
1464
|
justify-content: space-between !important;
|
|
1468
1465
|
align-items: center !important;
|
|
1469
1466
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
|
|
1470
1467
|
font-size: 0.85rem !important;
|
|
1471
|
-
color: #666 !important;
|
|
1468
|
+
color: var(--text-secondary, #666) !important;
|
|
1472
1469
|
flex-shrink: 0 !important; /* Don't shrink */
|
|
1473
1470
|
z-index: 10001 !important; /* Above link tooltip */
|
|
1474
1471
|
position: relative !important; /* Enable z-index */
|
|
1475
1472
|
}
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
.overtype-container[data-theme="cave"] .overtype-stats {
|
|
1479
|
-
background: var(--bg-secondary, #1D2D3E) !important;
|
|
1480
|
-
border-top: 1px solid rgba(197, 221, 232, 0.1) !important;
|
|
1481
|
-
color: var(--text, #c5dde8) !important;
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1473
|
+
|
|
1474
|
+
|
|
1484
1475
|
.overtype-stats .overtype-stat {
|
|
1485
1476
|
display: flex !important;
|
|
1486
1477
|
align-items: center !important;
|
|
@@ -4724,7 +4715,7 @@ var _OverType = class _OverType {
|
|
|
4724
4715
|
});
|
|
4725
4716
|
this.initialized = true;
|
|
4726
4717
|
if (this.options.onChange) {
|
|
4727
|
-
this.
|
|
4718
|
+
this._notifyChange();
|
|
4728
4719
|
}
|
|
4729
4720
|
}
|
|
4730
4721
|
/**
|
|
@@ -4825,15 +4816,7 @@ var _OverType = class _OverType {
|
|
|
4825
4816
|
return;
|
|
4826
4817
|
}
|
|
4827
4818
|
this.wrapper._instance = this;
|
|
4828
|
-
|
|
4829
|
-
this.wrapper.style.setProperty("--instance-font-size", this.options.fontSize);
|
|
4830
|
-
}
|
|
4831
|
-
if (this.options.lineHeight) {
|
|
4832
|
-
this.wrapper.style.setProperty("--instance-line-height", String(this.options.lineHeight));
|
|
4833
|
-
}
|
|
4834
|
-
if (this.options.padding) {
|
|
4835
|
-
this.wrapper.style.setProperty("--instance-padding", this.options.padding);
|
|
4836
|
-
}
|
|
4819
|
+
this._applyInstanceCSSVars();
|
|
4837
4820
|
this._configureTextarea();
|
|
4838
4821
|
this._applyOptions();
|
|
4839
4822
|
}
|
|
@@ -4881,15 +4864,7 @@ var _OverType = class _OverType {
|
|
|
4881
4864
|
}
|
|
4882
4865
|
this.wrapper = document.createElement("div");
|
|
4883
4866
|
this.wrapper.className = "overtype-wrapper";
|
|
4884
|
-
|
|
4885
|
-
this.wrapper.style.setProperty("--instance-font-size", this.options.fontSize);
|
|
4886
|
-
}
|
|
4887
|
-
if (this.options.lineHeight) {
|
|
4888
|
-
this.wrapper.style.setProperty("--instance-line-height", String(this.options.lineHeight));
|
|
4889
|
-
}
|
|
4890
|
-
if (this.options.padding) {
|
|
4891
|
-
this.wrapper.style.setProperty("--instance-padding", this.options.padding);
|
|
4892
|
-
}
|
|
4867
|
+
this._applyInstanceCSSVars();
|
|
4893
4868
|
this.wrapper._instance = this;
|
|
4894
4869
|
this.textarea = document.createElement("textarea");
|
|
4895
4870
|
this.textarea.className = "overtype-input";
|
|
@@ -5003,11 +4978,34 @@ var _OverType = class _OverType {
|
|
|
5003
4978
|
Object.assign(this.actionsById, buildActionsMap([toolbarButtons.upload]));
|
|
5004
4979
|
}
|
|
5005
4980
|
}
|
|
4981
|
+
/**
|
|
4982
|
+
* Apply instance-specific styles via CSS custom properties on the wrapper.
|
|
4983
|
+
* Called from init paths and from _applyOptions so reinit() propagates
|
|
4984
|
+
* font/padding changes.
|
|
4985
|
+
* @private
|
|
4986
|
+
*/
|
|
4987
|
+
_applyInstanceCSSVars() {
|
|
4988
|
+
if (!this.wrapper)
|
|
4989
|
+
return;
|
|
4990
|
+
if (this.options.fontSize) {
|
|
4991
|
+
this.wrapper.style.setProperty("--instance-font-size", this.options.fontSize);
|
|
4992
|
+
}
|
|
4993
|
+
if (this.options.lineHeight) {
|
|
4994
|
+
this.wrapper.style.setProperty("--instance-line-height", String(this.options.lineHeight));
|
|
4995
|
+
}
|
|
4996
|
+
if (this.options.padding) {
|
|
4997
|
+
this.wrapper.style.setProperty("--instance-padding", this.options.padding);
|
|
4998
|
+
}
|
|
4999
|
+
if (this.options.fontFamily) {
|
|
5000
|
+
this.wrapper.style.setProperty("--instance-font-family", this.options.fontFamily);
|
|
5001
|
+
}
|
|
5002
|
+
}
|
|
5006
5003
|
/**
|
|
5007
5004
|
* Apply options to the editor
|
|
5008
5005
|
* @private
|
|
5009
5006
|
*/
|
|
5010
5007
|
_applyOptions() {
|
|
5008
|
+
this._applyInstanceCSSVars();
|
|
5011
5009
|
if (this.options.autofocus) {
|
|
5012
5010
|
this.textarea.focus();
|
|
5013
5011
|
}
|
|
@@ -5157,13 +5155,19 @@ var _OverType = class _OverType {
|
|
|
5157
5155
|
if (this.options.showStats && this.statsBar) {
|
|
5158
5156
|
this._updateStats();
|
|
5159
5157
|
}
|
|
5160
|
-
if (this.options.onChange && this.initialized) {
|
|
5161
|
-
this.options.onChange(text, this);
|
|
5162
|
-
}
|
|
5163
5158
|
if (this.options.onRender) {
|
|
5164
5159
|
this.options.onRender(this.preview, isPreviewMode ? "preview" : "normal", this);
|
|
5165
5160
|
}
|
|
5166
5161
|
}
|
|
5162
|
+
/**
|
|
5163
|
+
* Notify listeners that the editor value changed
|
|
5164
|
+
* @private
|
|
5165
|
+
*/
|
|
5166
|
+
_notifyChange() {
|
|
5167
|
+
if (!this.options.onChange || !this.initialized)
|
|
5168
|
+
return;
|
|
5169
|
+
this.options.onChange(this.textarea.value, this);
|
|
5170
|
+
}
|
|
5167
5171
|
/**
|
|
5168
5172
|
* Apply background styling to code blocks
|
|
5169
5173
|
* @private
|
|
@@ -5197,6 +5201,7 @@ var _OverType = class _OverType {
|
|
|
5197
5201
|
*/
|
|
5198
5202
|
handleInput(event) {
|
|
5199
5203
|
this.updatePreview();
|
|
5204
|
+
this._notifyChange();
|
|
5200
5205
|
}
|
|
5201
5206
|
/**
|
|
5202
5207
|
* Handle keydown events
|
|
@@ -5377,11 +5382,15 @@ var _OverType = class _OverType {
|
|
|
5377
5382
|
* @param {string} value - Markdown content to set
|
|
5378
5383
|
*/
|
|
5379
5384
|
setValue(value) {
|
|
5385
|
+
const didChange = this.textarea.value !== value;
|
|
5380
5386
|
this.textarea.value = value;
|
|
5381
5387
|
this.updatePreview();
|
|
5382
5388
|
if (this.options.autoResize) {
|
|
5383
5389
|
this._updateAutoHeight();
|
|
5384
5390
|
}
|
|
5391
|
+
if (didChange) {
|
|
5392
|
+
this._notifyChange();
|
|
5393
|
+
}
|
|
5385
5394
|
}
|
|
5386
5395
|
/**
|
|
5387
5396
|
* Execute an action by ID
|