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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * OverType v2.3.4
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
@@ -1129,9 +1129,9 @@ var OverTypeEditor = (() => {
1129
1129
  left: 0 !important;
1130
1130
  width: 100% !important;
1131
1131
  height: 100% !important;
1132
-
1132
+
1133
1133
  /* Font properties - any difference breaks alignment */
1134
- font-family: ${fontFamily} !important;
1134
+ font-family: var(--instance-font-family, ${fontFamily}) !important;
1135
1135
  font-variant-ligatures: none !important; /* keep metrics stable for code */
1136
1136
  font-size: var(--instance-font-size, ${fontSize}) !important;
1137
1137
  line-height: var(--instance-line-height, ${lineHeight}) !important;
@@ -1238,15 +1238,12 @@ var OverTypeEditor = (() => {
1238
1238
  z-index: 0 !important;
1239
1239
  pointer-events: none !important;
1240
1240
  user-select: none !important;
1241
- font-family: ${fontFamily} !important;
1241
+ font-family: var(--instance-font-family, ${fontFamily}) !important;
1242
1242
  font-size: var(--instance-font-size, ${fontSize}) !important;
1243
1243
  line-height: var(--instance-line-height, ${lineHeight}) !important;
1244
1244
  padding: var(--instance-padding, ${padding}) !important;
1245
1245
  box-sizing: border-box !important;
1246
1246
  color: var(--placeholder, #999) !important;
1247
- overflow: hidden !important;
1248
- white-space: nowrap !important;
1249
- text-overflow: ellipsis !important;
1250
1247
  }
1251
1248
 
1252
1249
  /* Preview layer styles */
@@ -1264,6 +1261,16 @@ var OverTypeEditor = (() => {
1264
1261
  -ms-user-select: none !important;
1265
1262
  }
1266
1263
 
1264
+ /* Prevent external resets (Tailwind, Bootstrap, etc.) from breaking alignment.
1265
+ Any element whose font metrics differ from the textarea causes the CSS "strut"
1266
+ to inflate line boxes, drifting the overlay. Force inheritance so every element
1267
+ inside the preview matches the textarea exactly. */
1268
+ .overtype-wrapper .overtype-preview * {
1269
+ font-family: inherit !important;
1270
+ font-size: inherit !important;
1271
+ line-height: inherit !important;
1272
+ }
1273
+
1267
1274
  /* Defensive styles for preview child divs */
1268
1275
  .overtype-wrapper .overtype-preview div {
1269
1276
  /* Reset any inherited styles */
@@ -1389,7 +1396,7 @@ var OverTypeEditor = (() => {
1389
1396
  .overtype-wrapper .overtype-preview pre code {
1390
1397
  background: transparent !important;
1391
1398
  color: var(--code, #0d3b66) !important;
1392
- font-family: ${fontFamily} !important; /* Match textarea font exactly for alignment */
1399
+ font-family: var(--instance-font-family, ${fontFamily}) !important; /* Match textarea font exactly for alignment */
1393
1400
  }
1394
1401
 
1395
1402
  /* Blockquotes */
@@ -1474,26 +1481,20 @@ var OverTypeEditor = (() => {
1474
1481
  .overtype-stats {
1475
1482
  height: 40px !important;
1476
1483
  padding: 0 20px !important;
1477
- background: #f8f9fa !important;
1478
- border-top: 1px solid #e0e0e0 !important;
1484
+ background: var(--bg-secondary, #f8f9fa) !important;
1485
+ border-top: 1px solid var(--border, #e0e0e0) !important;
1479
1486
  display: flex !important;
1480
1487
  justify-content: space-between !important;
1481
1488
  align-items: center !important;
1482
1489
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
1483
1490
  font-size: 0.85rem !important;
1484
- color: #666 !important;
1491
+ color: var(--text-secondary, #666) !important;
1485
1492
  flex-shrink: 0 !important; /* Don't shrink */
1486
1493
  z-index: 10001 !important; /* Above link tooltip */
1487
1494
  position: relative !important; /* Enable z-index */
1488
1495
  }
1489
-
1490
- /* Dark theme stats bar */
1491
- .overtype-container[data-theme="cave"] .overtype-stats {
1492
- background: var(--bg-secondary, #1D2D3E) !important;
1493
- border-top: 1px solid rgba(197, 221, 232, 0.1) !important;
1494
- color: var(--text, #c5dde8) !important;
1495
- }
1496
-
1496
+
1497
+
1497
1498
  .overtype-stats .overtype-stat {
1498
1499
  display: flex !important;
1499
1500
  align-items: center !important;
@@ -4774,6 +4775,7 @@ ${blockSuffix}` : suffix;
4774
4775
  // Callbacks
4775
4776
  onChange: null,
4776
4777
  onKeydown: null,
4778
+ onRender: null,
4777
4779
  // Features
4778
4780
  showActiveLineRaw: false,
4779
4781
  showStats: false,
@@ -4837,15 +4839,7 @@ ${blockSuffix}` : suffix;
4837
4839
  return;
4838
4840
  }
4839
4841
  this.wrapper._instance = this;
4840
- if (this.options.fontSize) {
4841
- this.wrapper.style.setProperty("--instance-font-size", this.options.fontSize);
4842
- }
4843
- if (this.options.lineHeight) {
4844
- this.wrapper.style.setProperty("--instance-line-height", String(this.options.lineHeight));
4845
- }
4846
- if (this.options.padding) {
4847
- this.wrapper.style.setProperty("--instance-padding", this.options.padding);
4848
- }
4842
+ this._applyInstanceCSSVars();
4849
4843
  this._configureTextarea();
4850
4844
  this._applyOptions();
4851
4845
  }
@@ -4893,15 +4887,7 @@ ${blockSuffix}` : suffix;
4893
4887
  }
4894
4888
  this.wrapper = document.createElement("div");
4895
4889
  this.wrapper.className = "overtype-wrapper";
4896
- if (this.options.fontSize) {
4897
- this.wrapper.style.setProperty("--instance-font-size", this.options.fontSize);
4898
- }
4899
- if (this.options.lineHeight) {
4900
- this.wrapper.style.setProperty("--instance-line-height", String(this.options.lineHeight));
4901
- }
4902
- if (this.options.padding) {
4903
- this.wrapper.style.setProperty("--instance-padding", this.options.padding);
4904
- }
4890
+ this._applyInstanceCSSVars();
4905
4891
  this.wrapper._instance = this;
4906
4892
  this.textarea = document.createElement("textarea");
4907
4893
  this.textarea.className = "overtype-input";
@@ -5015,11 +5001,34 @@ ${blockSuffix}` : suffix;
5015
5001
  Object.assign(this.actionsById, buildActionsMap([toolbarButtons.upload]));
5016
5002
  }
5017
5003
  }
5004
+ /**
5005
+ * Apply instance-specific styles via CSS custom properties on the wrapper.
5006
+ * Called from init paths and from _applyOptions so reinit() propagates
5007
+ * font/padding changes.
5008
+ * @private
5009
+ */
5010
+ _applyInstanceCSSVars() {
5011
+ if (!this.wrapper)
5012
+ return;
5013
+ if (this.options.fontSize) {
5014
+ this.wrapper.style.setProperty("--instance-font-size", this.options.fontSize);
5015
+ }
5016
+ if (this.options.lineHeight) {
5017
+ this.wrapper.style.setProperty("--instance-line-height", String(this.options.lineHeight));
5018
+ }
5019
+ if (this.options.padding) {
5020
+ this.wrapper.style.setProperty("--instance-padding", this.options.padding);
5021
+ }
5022
+ if (this.options.fontFamily) {
5023
+ this.wrapper.style.setProperty("--instance-font-family", this.options.fontFamily);
5024
+ }
5025
+ }
5018
5026
  /**
5019
5027
  * Apply options to the editor
5020
5028
  * @private
5021
5029
  */
5022
5030
  _applyOptions() {
5031
+ this._applyInstanceCSSVars();
5023
5032
  if (this.options.autofocus) {
5024
5033
  this.textarea.focus();
5025
5034
  }
@@ -5172,6 +5181,9 @@ ${blockSuffix}` : suffix;
5172
5181
  if (this.options.onChange && this.initialized) {
5173
5182
  this.options.onChange(text, this);
5174
5183
  }
5184
+ if (this.options.onRender) {
5185
+ this.options.onRender(this.preview, isPreviewMode ? "preview" : "normal", this);
5186
+ }
5175
5187
  }
5176
5188
  /**
5177
5189
  * Apply background styling to code blocks
@@ -6038,6 +6050,7 @@ ${blockSuffix}` : suffix;
6038
6050
  this._isConnected = false;
6039
6051
  this._handleChange = this._handleChange.bind(this);
6040
6052
  this._handleKeydown = this._handleKeydown.bind(this);
6053
+ this._handleRender = this._handleRender.bind(this);
6041
6054
  }
6042
6055
  /**
6043
6056
  * Decode common escape sequences from attribute string values
@@ -6208,7 +6221,8 @@ ${blockSuffix}` : suffix;
6208
6221
  smartLists: !this.hasAttribute("smart-lists") || this.getAttribute("smart-lists") !== "false",
6209
6222
  spellcheck: this.hasAttribute("spellcheck") && this.getAttribute("spellcheck") !== "false",
6210
6223
  onChange: this._handleChange,
6211
- onKeydown: this._handleKeydown
6224
+ onKeydown: this._handleKeydown,
6225
+ onRender: this._handleRender
6212
6226
  };
6213
6227
  const fontSize = this.getAttribute("font-size");
6214
6228
  if (fontSize)
@@ -6427,6 +6441,19 @@ ${blockSuffix}` : suffix;
6427
6441
  editor: this._editor
6428
6442
  });
6429
6443
  }
6444
+ /**
6445
+ * Handle render events from OverType
6446
+ * @private
6447
+ * @param {HTMLElement} preview - The preview DOM element
6448
+ * @param {string} mode - Current mode ('normal' or 'preview')
6449
+ */
6450
+ _handleRender(preview, mode) {
6451
+ this._dispatchEvent("render", {
6452
+ preview,
6453
+ mode,
6454
+ editor: this._editor
6455
+ });
6456
+ }
6430
6457
  /**
6431
6458
  * Update value attribute without triggering observer
6432
6459
  * @private