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/dist/overtype.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * OverType v2.3.5
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
@@ -148,13 +148,13 @@ var OverType = (() => {
148
148
  * @returns {string} Parsed task list item
149
149
  */
150
150
  static parseTaskList(html, isPreviewMode = false) {
151
- return html.replace(/^((?: )*)-\s+\[([ xX])\]\s+(.+)$/, (match, indent, checked, content) => {
151
+ return html.replace(/^((?: )*)-(\s+)\[([ xX])\](\s*)(.*)$/, (match, indent, spacingBeforeBox, checked, spacingAfterBox, content) => {
152
152
  content = this.parseInlineElements(content);
153
153
  if (isPreviewMode) {
154
154
  const isChecked = checked.toLowerCase() === "x";
155
155
  return `${indent}<li class="task-list"><input type="checkbox" ${isChecked ? "checked" : ""}> ${content}</li>`;
156
156
  } else {
157
- return `${indent}<li class="task-list"><span class="syntax-marker">- [${checked}] </span>${content}</li>`;
157
+ return `${indent}<li class="task-list"><span class="syntax-marker">-${spacingBeforeBox}[${checked}]${spacingAfterBox}</span>${content}</li>`;
158
158
  }
159
159
  });
160
160
  }
@@ -1132,9 +1132,9 @@ var OverType = (() => {
1132
1132
  left: 0 !important;
1133
1133
  width: 100% !important;
1134
1134
  height: 100% !important;
1135
-
1135
+
1136
1136
  /* Font properties - any difference breaks alignment */
1137
- font-family: ${fontFamily} !important;
1137
+ font-family: var(--instance-font-family, ${fontFamily}) !important;
1138
1138
  font-variant-ligatures: none !important; /* keep metrics stable for code */
1139
1139
  font-size: var(--instance-font-size, ${fontSize}) !important;
1140
1140
  line-height: var(--instance-line-height, ${lineHeight}) !important;
@@ -1241,15 +1241,12 @@ var OverType = (() => {
1241
1241
  z-index: 0 !important;
1242
1242
  pointer-events: none !important;
1243
1243
  user-select: none !important;
1244
- font-family: ${fontFamily} !important;
1244
+ font-family: var(--instance-font-family, ${fontFamily}) !important;
1245
1245
  font-size: var(--instance-font-size, ${fontSize}) !important;
1246
1246
  line-height: var(--instance-line-height, ${lineHeight}) !important;
1247
1247
  padding: var(--instance-padding, ${padding}) !important;
1248
1248
  box-sizing: border-box !important;
1249
1249
  color: var(--placeholder, #999) !important;
1250
- overflow: hidden !important;
1251
- white-space: nowrap !important;
1252
- text-overflow: ellipsis !important;
1253
1250
  }
1254
1251
 
1255
1252
  /* Preview layer styles */
@@ -1402,7 +1399,7 @@ var OverType = (() => {
1402
1399
  .overtype-wrapper .overtype-preview pre code {
1403
1400
  background: transparent !important;
1404
1401
  color: var(--code, #0d3b66) !important;
1405
- font-family: ${fontFamily} !important; /* Match textarea font exactly for alignment */
1402
+ font-family: var(--instance-font-family, ${fontFamily}) !important; /* Match textarea font exactly for alignment */
1406
1403
  }
1407
1404
 
1408
1405
  /* Blockquotes */
@@ -1487,26 +1484,20 @@ var OverType = (() => {
1487
1484
  .overtype-stats {
1488
1485
  height: 40px !important;
1489
1486
  padding: 0 20px !important;
1490
- background: #f8f9fa !important;
1491
- border-top: 1px solid #e0e0e0 !important;
1487
+ background: var(--bg-secondary, #f8f9fa) !important;
1488
+ border-top: 1px solid var(--border, #e0e0e0) !important;
1492
1489
  display: flex !important;
1493
1490
  justify-content: space-between !important;
1494
1491
  align-items: center !important;
1495
1492
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
1496
1493
  font-size: 0.85rem !important;
1497
- color: #666 !important;
1494
+ color: var(--text-secondary, #666) !important;
1498
1495
  flex-shrink: 0 !important; /* Don't shrink */
1499
1496
  z-index: 10001 !important; /* Above link tooltip */
1500
1497
  position: relative !important; /* Enable z-index */
1501
1498
  }
1502
-
1503
- /* Dark theme stats bar */
1504
- .overtype-container[data-theme="cave"] .overtype-stats {
1505
- background: var(--bg-secondary, #1D2D3E) !important;
1506
- border-top: 1px solid rgba(197, 221, 232, 0.1) !important;
1507
- color: var(--text, #c5dde8) !important;
1508
- }
1509
-
1499
+
1500
+
1510
1501
  .overtype-stats .overtype-stat {
1511
1502
  display: flex !important;
1512
1503
  align-items: center !important;
@@ -4750,7 +4741,7 @@ ${blockSuffix}` : suffix;
4750
4741
  });
4751
4742
  this.initialized = true;
4752
4743
  if (this.options.onChange) {
4753
- this.options.onChange(this.getValue(), this);
4744
+ this._notifyChange();
4754
4745
  }
4755
4746
  }
4756
4747
  /**
@@ -4851,15 +4842,7 @@ ${blockSuffix}` : suffix;
4851
4842
  return;
4852
4843
  }
4853
4844
  this.wrapper._instance = this;
4854
- if (this.options.fontSize) {
4855
- this.wrapper.style.setProperty("--instance-font-size", this.options.fontSize);
4856
- }
4857
- if (this.options.lineHeight) {
4858
- this.wrapper.style.setProperty("--instance-line-height", String(this.options.lineHeight));
4859
- }
4860
- if (this.options.padding) {
4861
- this.wrapper.style.setProperty("--instance-padding", this.options.padding);
4862
- }
4845
+ this._applyInstanceCSSVars();
4863
4846
  this._configureTextarea();
4864
4847
  this._applyOptions();
4865
4848
  }
@@ -4907,15 +4890,7 @@ ${blockSuffix}` : suffix;
4907
4890
  }
4908
4891
  this.wrapper = document.createElement("div");
4909
4892
  this.wrapper.className = "overtype-wrapper";
4910
- if (this.options.fontSize) {
4911
- this.wrapper.style.setProperty("--instance-font-size", this.options.fontSize);
4912
- }
4913
- if (this.options.lineHeight) {
4914
- this.wrapper.style.setProperty("--instance-line-height", String(this.options.lineHeight));
4915
- }
4916
- if (this.options.padding) {
4917
- this.wrapper.style.setProperty("--instance-padding", this.options.padding);
4918
- }
4893
+ this._applyInstanceCSSVars();
4919
4894
  this.wrapper._instance = this;
4920
4895
  this.textarea = document.createElement("textarea");
4921
4896
  this.textarea.className = "overtype-input";
@@ -5029,11 +5004,34 @@ ${blockSuffix}` : suffix;
5029
5004
  Object.assign(this.actionsById, buildActionsMap([toolbarButtons.upload]));
5030
5005
  }
5031
5006
  }
5007
+ /**
5008
+ * Apply instance-specific styles via CSS custom properties on the wrapper.
5009
+ * Called from init paths and from _applyOptions so reinit() propagates
5010
+ * font/padding changes.
5011
+ * @private
5012
+ */
5013
+ _applyInstanceCSSVars() {
5014
+ if (!this.wrapper)
5015
+ return;
5016
+ if (this.options.fontSize) {
5017
+ this.wrapper.style.setProperty("--instance-font-size", this.options.fontSize);
5018
+ }
5019
+ if (this.options.lineHeight) {
5020
+ this.wrapper.style.setProperty("--instance-line-height", String(this.options.lineHeight));
5021
+ }
5022
+ if (this.options.padding) {
5023
+ this.wrapper.style.setProperty("--instance-padding", this.options.padding);
5024
+ }
5025
+ if (this.options.fontFamily) {
5026
+ this.wrapper.style.setProperty("--instance-font-family", this.options.fontFamily);
5027
+ }
5028
+ }
5032
5029
  /**
5033
5030
  * Apply options to the editor
5034
5031
  * @private
5035
5032
  */
5036
5033
  _applyOptions() {
5034
+ this._applyInstanceCSSVars();
5037
5035
  if (this.options.autofocus) {
5038
5036
  this.textarea.focus();
5039
5037
  }
@@ -5183,13 +5181,19 @@ ${blockSuffix}` : suffix;
5183
5181
  if (this.options.showStats && this.statsBar) {
5184
5182
  this._updateStats();
5185
5183
  }
5186
- if (this.options.onChange && this.initialized) {
5187
- this.options.onChange(text, this);
5188
- }
5189
5184
  if (this.options.onRender) {
5190
5185
  this.options.onRender(this.preview, isPreviewMode ? "preview" : "normal", this);
5191
5186
  }
5192
5187
  }
5188
+ /**
5189
+ * Notify listeners that the editor value changed
5190
+ * @private
5191
+ */
5192
+ _notifyChange() {
5193
+ if (!this.options.onChange || !this.initialized)
5194
+ return;
5195
+ this.options.onChange(this.textarea.value, this);
5196
+ }
5193
5197
  /**
5194
5198
  * Apply background styling to code blocks
5195
5199
  * @private
@@ -5223,6 +5227,7 @@ ${blockSuffix}` : suffix;
5223
5227
  */
5224
5228
  handleInput(event) {
5225
5229
  this.updatePreview();
5230
+ this._notifyChange();
5226
5231
  }
5227
5232
  /**
5228
5233
  * Handle keydown events
@@ -5403,11 +5408,15 @@ ${blockSuffix}` : suffix;
5403
5408
  * @param {string} value - Markdown content to set
5404
5409
  */
5405
5410
  setValue(value) {
5411
+ const didChange = this.textarea.value !== value;
5406
5412
  this.textarea.value = value;
5407
5413
  this.updatePreview();
5408
5414
  if (this.options.autoResize) {
5409
5415
  this._updateAutoHeight();
5410
5416
  }
5417
+ if (didChange) {
5418
+ this._notifyChange();
5419
+ }
5411
5420
  }
5412
5421
  /**
5413
5422
  * Execute an action by ID