overtype 2.3.4 → 2.3.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 +1 -1
- package/dist/overtype-webcomponent.esm.js +65 -38
- package/dist/overtype-webcomponent.esm.js.map +2 -2
- package/dist/overtype-webcomponent.js +65 -38
- package/dist/overtype-webcomponent.js.map +2 -2
- package/dist/overtype-webcomponent.min.js +31 -30
- package/dist/overtype.cjs +49 -37
- package/dist/overtype.cjs.map +2 -2
- package/dist/overtype.esm.js +49 -37
- package/dist/overtype.esm.js.map +2 -2
- package/dist/overtype.js +49 -37
- package/dist/overtype.js.map +2 -2
- package/dist/overtype.min.js +25 -24
- package/package.json +3 -2
- package/src/overtype-webcomponent.js +17 -1
- package/src/overtype.js +34 -21
- package/src/styles.js +19 -18
package/README.md
CHANGED
|
@@ -780,7 +780,7 @@ Special thanks to:
|
|
|
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
786
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OverType v2.3.
|
|
2
|
+
* OverType v2.3.6
|
|
3
3
|
* A lightweight markdown editor library with perfect WYSIWYG alignment
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @author David Miranda
|
|
@@ -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 */
|
|
@@ -1241,6 +1238,16 @@ function generateStyles(options = {}) {
|
|
|
1241
1238
|
-ms-user-select: none !important;
|
|
1242
1239
|
}
|
|
1243
1240
|
|
|
1241
|
+
/* Prevent external resets (Tailwind, Bootstrap, etc.) from breaking alignment.
|
|
1242
|
+
Any element whose font metrics differ from the textarea causes the CSS "strut"
|
|
1243
|
+
to inflate line boxes, drifting the overlay. Force inheritance so every element
|
|
1244
|
+
inside the preview matches the textarea exactly. */
|
|
1245
|
+
.overtype-wrapper .overtype-preview * {
|
|
1246
|
+
font-family: inherit !important;
|
|
1247
|
+
font-size: inherit !important;
|
|
1248
|
+
line-height: inherit !important;
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1244
1251
|
/* Defensive styles for preview child divs */
|
|
1245
1252
|
.overtype-wrapper .overtype-preview div {
|
|
1246
1253
|
/* Reset any inherited styles */
|
|
@@ -1366,7 +1373,7 @@ function generateStyles(options = {}) {
|
|
|
1366
1373
|
.overtype-wrapper .overtype-preview pre code {
|
|
1367
1374
|
background: transparent !important;
|
|
1368
1375
|
color: var(--code, #0d3b66) !important;
|
|
1369
|
-
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 */
|
|
1370
1377
|
}
|
|
1371
1378
|
|
|
1372
1379
|
/* Blockquotes */
|
|
@@ -1451,26 +1458,20 @@ function generateStyles(options = {}) {
|
|
|
1451
1458
|
.overtype-stats {
|
|
1452
1459
|
height: 40px !important;
|
|
1453
1460
|
padding: 0 20px !important;
|
|
1454
|
-
background: #f8f9fa !important;
|
|
1455
|
-
border-top: 1px solid #e0e0e0 !important;
|
|
1461
|
+
background: var(--bg-secondary, #f8f9fa) !important;
|
|
1462
|
+
border-top: 1px solid var(--border, #e0e0e0) !important;
|
|
1456
1463
|
display: flex !important;
|
|
1457
1464
|
justify-content: space-between !important;
|
|
1458
1465
|
align-items: center !important;
|
|
1459
1466
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
|
|
1460
1467
|
font-size: 0.85rem !important;
|
|
1461
|
-
color: #666 !important;
|
|
1468
|
+
color: var(--text-secondary, #666) !important;
|
|
1462
1469
|
flex-shrink: 0 !important; /* Don't shrink */
|
|
1463
1470
|
z-index: 10001 !important; /* Above link tooltip */
|
|
1464
1471
|
position: relative !important; /* Enable z-index */
|
|
1465
1472
|
}
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
.overtype-container[data-theme="cave"] .overtype-stats {
|
|
1469
|
-
background: var(--bg-secondary, #1D2D3E) !important;
|
|
1470
|
-
border-top: 1px solid rgba(197, 221, 232, 0.1) !important;
|
|
1471
|
-
color: var(--text, #c5dde8) !important;
|
|
1472
|
-
}
|
|
1473
|
-
|
|
1473
|
+
|
|
1474
|
+
|
|
1474
1475
|
.overtype-stats .overtype-stat {
|
|
1475
1476
|
display: flex !important;
|
|
1476
1477
|
align-items: center !important;
|
|
@@ -4751,6 +4752,7 @@ var _OverType = class _OverType {
|
|
|
4751
4752
|
// Callbacks
|
|
4752
4753
|
onChange: null,
|
|
4753
4754
|
onKeydown: null,
|
|
4755
|
+
onRender: null,
|
|
4754
4756
|
// Features
|
|
4755
4757
|
showActiveLineRaw: false,
|
|
4756
4758
|
showStats: false,
|
|
@@ -4814,15 +4816,7 @@ var _OverType = class _OverType {
|
|
|
4814
4816
|
return;
|
|
4815
4817
|
}
|
|
4816
4818
|
this.wrapper._instance = this;
|
|
4817
|
-
|
|
4818
|
-
this.wrapper.style.setProperty("--instance-font-size", this.options.fontSize);
|
|
4819
|
-
}
|
|
4820
|
-
if (this.options.lineHeight) {
|
|
4821
|
-
this.wrapper.style.setProperty("--instance-line-height", String(this.options.lineHeight));
|
|
4822
|
-
}
|
|
4823
|
-
if (this.options.padding) {
|
|
4824
|
-
this.wrapper.style.setProperty("--instance-padding", this.options.padding);
|
|
4825
|
-
}
|
|
4819
|
+
this._applyInstanceCSSVars();
|
|
4826
4820
|
this._configureTextarea();
|
|
4827
4821
|
this._applyOptions();
|
|
4828
4822
|
}
|
|
@@ -4870,15 +4864,7 @@ var _OverType = class _OverType {
|
|
|
4870
4864
|
}
|
|
4871
4865
|
this.wrapper = document.createElement("div");
|
|
4872
4866
|
this.wrapper.className = "overtype-wrapper";
|
|
4873
|
-
|
|
4874
|
-
this.wrapper.style.setProperty("--instance-font-size", this.options.fontSize);
|
|
4875
|
-
}
|
|
4876
|
-
if (this.options.lineHeight) {
|
|
4877
|
-
this.wrapper.style.setProperty("--instance-line-height", String(this.options.lineHeight));
|
|
4878
|
-
}
|
|
4879
|
-
if (this.options.padding) {
|
|
4880
|
-
this.wrapper.style.setProperty("--instance-padding", this.options.padding);
|
|
4881
|
-
}
|
|
4867
|
+
this._applyInstanceCSSVars();
|
|
4882
4868
|
this.wrapper._instance = this;
|
|
4883
4869
|
this.textarea = document.createElement("textarea");
|
|
4884
4870
|
this.textarea.className = "overtype-input";
|
|
@@ -4992,11 +4978,34 @@ var _OverType = class _OverType {
|
|
|
4992
4978
|
Object.assign(this.actionsById, buildActionsMap([toolbarButtons.upload]));
|
|
4993
4979
|
}
|
|
4994
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
|
+
}
|
|
4995
5003
|
/**
|
|
4996
5004
|
* Apply options to the editor
|
|
4997
5005
|
* @private
|
|
4998
5006
|
*/
|
|
4999
5007
|
_applyOptions() {
|
|
5008
|
+
this._applyInstanceCSSVars();
|
|
5000
5009
|
if (this.options.autofocus) {
|
|
5001
5010
|
this.textarea.focus();
|
|
5002
5011
|
}
|
|
@@ -5149,6 +5158,9 @@ var _OverType = class _OverType {
|
|
|
5149
5158
|
if (this.options.onChange && this.initialized) {
|
|
5150
5159
|
this.options.onChange(text, this);
|
|
5151
5160
|
}
|
|
5161
|
+
if (this.options.onRender) {
|
|
5162
|
+
this.options.onRender(this.preview, isPreviewMode ? "preview" : "normal", this);
|
|
5163
|
+
}
|
|
5152
5164
|
}
|
|
5153
5165
|
/**
|
|
5154
5166
|
* Apply background styling to code blocks
|
|
@@ -6015,6 +6027,7 @@ var OverTypeEditor = class extends HTMLElement {
|
|
|
6015
6027
|
this._isConnected = false;
|
|
6016
6028
|
this._handleChange = this._handleChange.bind(this);
|
|
6017
6029
|
this._handleKeydown = this._handleKeydown.bind(this);
|
|
6030
|
+
this._handleRender = this._handleRender.bind(this);
|
|
6018
6031
|
}
|
|
6019
6032
|
/**
|
|
6020
6033
|
* Decode common escape sequences from attribute string values
|
|
@@ -6185,7 +6198,8 @@ var OverTypeEditor = class extends HTMLElement {
|
|
|
6185
6198
|
smartLists: !this.hasAttribute("smart-lists") || this.getAttribute("smart-lists") !== "false",
|
|
6186
6199
|
spellcheck: this.hasAttribute("spellcheck") && this.getAttribute("spellcheck") !== "false",
|
|
6187
6200
|
onChange: this._handleChange,
|
|
6188
|
-
onKeydown: this._handleKeydown
|
|
6201
|
+
onKeydown: this._handleKeydown,
|
|
6202
|
+
onRender: this._handleRender
|
|
6189
6203
|
};
|
|
6190
6204
|
const fontSize = this.getAttribute("font-size");
|
|
6191
6205
|
if (fontSize)
|
|
@@ -6404,6 +6418,19 @@ var OverTypeEditor = class extends HTMLElement {
|
|
|
6404
6418
|
editor: this._editor
|
|
6405
6419
|
});
|
|
6406
6420
|
}
|
|
6421
|
+
/**
|
|
6422
|
+
* Handle render events from OverType
|
|
6423
|
+
* @private
|
|
6424
|
+
* @param {HTMLElement} preview - The preview DOM element
|
|
6425
|
+
* @param {string} mode - Current mode ('normal' or 'preview')
|
|
6426
|
+
*/
|
|
6427
|
+
_handleRender(preview, mode) {
|
|
6428
|
+
this._dispatchEvent("render", {
|
|
6429
|
+
preview,
|
|
6430
|
+
mode,
|
|
6431
|
+
editor: this._editor
|
|
6432
|
+
});
|
|
6433
|
+
}
|
|
6407
6434
|
/**
|
|
6408
6435
|
* Update value attribute without triggering observer
|
|
6409
6436
|
* @private
|