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.
@@ -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
@@ -145,13 +145,13 @@ var OverTypeEditor = (() => {
145
145
  * @returns {string} Parsed task list item
146
146
  */
147
147
  static parseTaskList(html, isPreviewMode = false) {
148
- return html.replace(/^((?: )*)-\s+\[([ xX])\]\s+(.+)$/, (match, indent, checked, content) => {
148
+ return html.replace(/^((?: )*)-(\s+)\[([ xX])\](\s*)(.*)$/, (match, indent, spacingBeforeBox, checked, spacingAfterBox, content) => {
149
149
  content = this.parseInlineElements(content);
150
150
  if (isPreviewMode) {
151
151
  const isChecked = checked.toLowerCase() === "x";
152
152
  return `${indent}<li class="task-list"><input type="checkbox" ${isChecked ? "checked" : ""}> ${content}</li>`;
153
153
  } else {
154
- return `${indent}<li class="task-list"><span class="syntax-marker">- [${checked}] </span>${content}</li>`;
154
+ return `${indent}<li class="task-list"><span class="syntax-marker">-${spacingBeforeBox}[${checked}]${spacingAfterBox}</span>${content}</li>`;
155
155
  }
156
156
  });
157
157
  }
@@ -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 */
@@ -1399,7 +1396,7 @@ var OverTypeEditor = (() => {
1399
1396
  .overtype-wrapper .overtype-preview pre code {
1400
1397
  background: transparent !important;
1401
1398
  color: var(--code, #0d3b66) !important;
1402
- 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 */
1403
1400
  }
1404
1401
 
1405
1402
  /* Blockquotes */
@@ -1484,26 +1481,20 @@ var OverTypeEditor = (() => {
1484
1481
  .overtype-stats {
1485
1482
  height: 40px !important;
1486
1483
  padding: 0 20px !important;
1487
- background: #f8f9fa !important;
1488
- border-top: 1px solid #e0e0e0 !important;
1484
+ background: var(--bg-secondary, #f8f9fa) !important;
1485
+ border-top: 1px solid var(--border, #e0e0e0) !important;
1489
1486
  display: flex !important;
1490
1487
  justify-content: space-between !important;
1491
1488
  align-items: center !important;
1492
1489
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
1493
1490
  font-size: 0.85rem !important;
1494
- color: #666 !important;
1491
+ color: var(--text-secondary, #666) !important;
1495
1492
  flex-shrink: 0 !important; /* Don't shrink */
1496
1493
  z-index: 10001 !important; /* Above link tooltip */
1497
1494
  position: relative !important; /* Enable z-index */
1498
1495
  }
1499
-
1500
- /* Dark theme stats bar */
1501
- .overtype-container[data-theme="cave"] .overtype-stats {
1502
- background: var(--bg-secondary, #1D2D3E) !important;
1503
- border-top: 1px solid rgba(197, 221, 232, 0.1) !important;
1504
- color: var(--text, #c5dde8) !important;
1505
- }
1506
-
1496
+
1497
+
1507
1498
  .overtype-stats .overtype-stat {
1508
1499
  display: flex !important;
1509
1500
  align-items: center !important;
@@ -4747,7 +4738,7 @@ ${blockSuffix}` : suffix;
4747
4738
  });
4748
4739
  this.initialized = true;
4749
4740
  if (this.options.onChange) {
4750
- this.options.onChange(this.getValue(), this);
4741
+ this._notifyChange();
4751
4742
  }
4752
4743
  }
4753
4744
  /**
@@ -4848,15 +4839,7 @@ ${blockSuffix}` : suffix;
4848
4839
  return;
4849
4840
  }
4850
4841
  this.wrapper._instance = this;
4851
- if (this.options.fontSize) {
4852
- this.wrapper.style.setProperty("--instance-font-size", this.options.fontSize);
4853
- }
4854
- if (this.options.lineHeight) {
4855
- this.wrapper.style.setProperty("--instance-line-height", String(this.options.lineHeight));
4856
- }
4857
- if (this.options.padding) {
4858
- this.wrapper.style.setProperty("--instance-padding", this.options.padding);
4859
- }
4842
+ this._applyInstanceCSSVars();
4860
4843
  this._configureTextarea();
4861
4844
  this._applyOptions();
4862
4845
  }
@@ -4904,15 +4887,7 @@ ${blockSuffix}` : suffix;
4904
4887
  }
4905
4888
  this.wrapper = document.createElement("div");
4906
4889
  this.wrapper.className = "overtype-wrapper";
4907
- if (this.options.fontSize) {
4908
- this.wrapper.style.setProperty("--instance-font-size", this.options.fontSize);
4909
- }
4910
- if (this.options.lineHeight) {
4911
- this.wrapper.style.setProperty("--instance-line-height", String(this.options.lineHeight));
4912
- }
4913
- if (this.options.padding) {
4914
- this.wrapper.style.setProperty("--instance-padding", this.options.padding);
4915
- }
4890
+ this._applyInstanceCSSVars();
4916
4891
  this.wrapper._instance = this;
4917
4892
  this.textarea = document.createElement("textarea");
4918
4893
  this.textarea.className = "overtype-input";
@@ -5026,11 +5001,34 @@ ${blockSuffix}` : suffix;
5026
5001
  Object.assign(this.actionsById, buildActionsMap([toolbarButtons.upload]));
5027
5002
  }
5028
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
+ }
5029
5026
  /**
5030
5027
  * Apply options to the editor
5031
5028
  * @private
5032
5029
  */
5033
5030
  _applyOptions() {
5031
+ this._applyInstanceCSSVars();
5034
5032
  if (this.options.autofocus) {
5035
5033
  this.textarea.focus();
5036
5034
  }
@@ -5180,13 +5178,19 @@ ${blockSuffix}` : suffix;
5180
5178
  if (this.options.showStats && this.statsBar) {
5181
5179
  this._updateStats();
5182
5180
  }
5183
- if (this.options.onChange && this.initialized) {
5184
- this.options.onChange(text, this);
5185
- }
5186
5181
  if (this.options.onRender) {
5187
5182
  this.options.onRender(this.preview, isPreviewMode ? "preview" : "normal", this);
5188
5183
  }
5189
5184
  }
5185
+ /**
5186
+ * Notify listeners that the editor value changed
5187
+ * @private
5188
+ */
5189
+ _notifyChange() {
5190
+ if (!this.options.onChange || !this.initialized)
5191
+ return;
5192
+ this.options.onChange(this.textarea.value, this);
5193
+ }
5190
5194
  /**
5191
5195
  * Apply background styling to code blocks
5192
5196
  * @private
@@ -5220,6 +5224,7 @@ ${blockSuffix}` : suffix;
5220
5224
  */
5221
5225
  handleInput(event) {
5222
5226
  this.updatePreview();
5227
+ this._notifyChange();
5223
5228
  }
5224
5229
  /**
5225
5230
  * Handle keydown events
@@ -5400,11 +5405,15 @@ ${blockSuffix}` : suffix;
5400
5405
  * @param {string} value - Markdown content to set
5401
5406
  */
5402
5407
  setValue(value) {
5408
+ const didChange = this.textarea.value !== value;
5403
5409
  this.textarea.value = value;
5404
5410
  this.updatePreview();
5405
5411
  if (this.options.autoResize) {
5406
5412
  this._updateAutoHeight();
5407
5413
  }
5414
+ if (didChange) {
5415
+ this._notifyChange();
5416
+ }
5408
5417
  }
5409
5418
  /**
5410
5419
  * Execute an action by ID