overtype 2.3.6 → 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.6
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
  }
@@ -4741,7 +4741,7 @@ ${blockSuffix}` : suffix;
4741
4741
  });
4742
4742
  this.initialized = true;
4743
4743
  if (this.options.onChange) {
4744
- this.options.onChange(this.getValue(), this);
4744
+ this._notifyChange();
4745
4745
  }
4746
4746
  }
4747
4747
  /**
@@ -5181,13 +5181,19 @@ ${blockSuffix}` : suffix;
5181
5181
  if (this.options.showStats && this.statsBar) {
5182
5182
  this._updateStats();
5183
5183
  }
5184
- if (this.options.onChange && this.initialized) {
5185
- this.options.onChange(text, this);
5186
- }
5187
5184
  if (this.options.onRender) {
5188
5185
  this.options.onRender(this.preview, isPreviewMode ? "preview" : "normal", this);
5189
5186
  }
5190
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
+ }
5191
5197
  /**
5192
5198
  * Apply background styling to code blocks
5193
5199
  * @private
@@ -5221,6 +5227,7 @@ ${blockSuffix}` : suffix;
5221
5227
  */
5222
5228
  handleInput(event) {
5223
5229
  this.updatePreview();
5230
+ this._notifyChange();
5224
5231
  }
5225
5232
  /**
5226
5233
  * Handle keydown events
@@ -5401,11 +5408,15 @@ ${blockSuffix}` : suffix;
5401
5408
  * @param {string} value - Markdown content to set
5402
5409
  */
5403
5410
  setValue(value) {
5411
+ const didChange = this.textarea.value !== value;
5404
5412
  this.textarea.value = value;
5405
5413
  this.updatePreview();
5406
5414
  if (this.options.autoResize) {
5407
5415
  this._updateAutoHeight();
5408
5416
  }
5417
+ if (didChange) {
5418
+ this._notifyChange();
5419
+ }
5409
5420
  }
5410
5421
  /**
5411
5422
  * Execute an action by ID