overtype 2.3.2 → 2.3.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "overtype",
3
- "version": "2.3.2",
3
+ "version": "2.3.3",
4
4
  "description": "A lightweight markdown editor library with perfect WYSIWYG alignment using an invisible textarea overlay",
5
5
  "main": "dist/overtype.cjs",
6
6
  "module": "dist/overtype.esm.js",
package/src/overtype.js CHANGED
@@ -1321,26 +1321,23 @@ class OverType {
1321
1321
  */
1322
1322
  _updateAutoHeight() {
1323
1323
  if (!this.options.autoResize) return;
1324
-
1324
+
1325
1325
  const textarea = this.textarea;
1326
1326
  const preview = this.preview;
1327
1327
  const wrapper = this.wrapper;
1328
-
1329
- // Get computed styles
1330
- const computed = window.getComputedStyle(textarea);
1331
- const paddingTop = parseFloat(computed.paddingTop);
1332
- const paddingBottom = parseFloat(computed.paddingBottom);
1333
-
1328
+ const isPreviewMode = this.container.dataset.mode === 'preview';
1329
+
1334
1330
  // Store scroll positions
1335
- const scrollTop = textarea.scrollTop;
1336
-
1331
+ const scrollTop = isPreviewMode ? preview.scrollTop : textarea.scrollTop;
1332
+
1337
1333
  // Reset heights to get accurate scrollHeight
1338
1334
  // Wrapper must also reset so the absolute-positioned textarea isn't constrained
1339
1335
  wrapper.style.setProperty('height', 'auto', 'important');
1336
+ preview.style.setProperty('height', 'auto', 'important');
1340
1337
  textarea.style.setProperty('height', 'auto', 'important');
1341
1338
 
1342
- // Calculate new height based on scrollHeight
1343
- let newHeight = textarea.scrollHeight;
1339
+ // In preview mode, textarea is display:none so measure preview instead
1340
+ let newHeight = isPreviewMode ? preview.scrollHeight : textarea.scrollHeight;
1344
1341
 
1345
1342
  // Apply min height constraint
1346
1343
  if (this.options.minHeight) {
@@ -1409,6 +1406,7 @@ class OverType {
1409
1406
  showNormalEditMode() {
1410
1407
  this.container.dataset.mode = 'normal';
1411
1408
  this.updatePreview(); // Re-render with normal mode (e.g., show syntax markers)
1409
+ this._updateAutoHeight();
1412
1410
 
1413
1411
  // Always sync scroll from preview to textarea
1414
1412
  requestAnimationFrame(() => {
@@ -1425,6 +1423,7 @@ class OverType {
1425
1423
  */
1426
1424
  showPlainTextarea() {
1427
1425
  this.container.dataset.mode = 'plain';
1426
+ this._updateAutoHeight();
1428
1427
 
1429
1428
  // Update toolbar button if exists
1430
1429
  if (this.toolbar) {
@@ -1445,6 +1444,7 @@ class OverType {
1445
1444
  showPreviewMode() {
1446
1445
  this.container.dataset.mode = 'preview';
1447
1446
  this.updatePreview(); // Re-render with preview mode (e.g., checkboxes)
1447
+ this._updateAutoHeight();
1448
1448
  return this;
1449
1449
  }
1450
1450