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.
@@ -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
@@ -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
  }
@@ -4738,7 +4738,7 @@ ${blockSuffix}` : suffix;
4738
4738
  });
4739
4739
  this.initialized = true;
4740
4740
  if (this.options.onChange) {
4741
- this.options.onChange(this.getValue(), this);
4741
+ this._notifyChange();
4742
4742
  }
4743
4743
  }
4744
4744
  /**
@@ -5178,13 +5178,19 @@ ${blockSuffix}` : suffix;
5178
5178
  if (this.options.showStats && this.statsBar) {
5179
5179
  this._updateStats();
5180
5180
  }
5181
- if (this.options.onChange && this.initialized) {
5182
- this.options.onChange(text, this);
5183
- }
5184
5181
  if (this.options.onRender) {
5185
5182
  this.options.onRender(this.preview, isPreviewMode ? "preview" : "normal", this);
5186
5183
  }
5187
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
+ }
5188
5194
  /**
5189
5195
  * Apply background styling to code blocks
5190
5196
  * @private
@@ -5218,6 +5224,7 @@ ${blockSuffix}` : suffix;
5218
5224
  */
5219
5225
  handleInput(event) {
5220
5226
  this.updatePreview();
5227
+ this._notifyChange();
5221
5228
  }
5222
5229
  /**
5223
5230
  * Handle keydown events
@@ -5398,11 +5405,15 @@ ${blockSuffix}` : suffix;
5398
5405
  * @param {string} value - Markdown content to set
5399
5406
  */
5400
5407
  setValue(value) {
5408
+ const didChange = this.textarea.value !== value;
5401
5409
  this.textarea.value = value;
5402
5410
  this.updatePreview();
5403
5411
  if (this.options.autoResize) {
5404
5412
  this._updateAutoHeight();
5405
5413
  }
5414
+ if (didChange) {
5415
+ this._notifyChange();
5416
+ }
5406
5417
  }
5407
5418
  /**
5408
5419
  * Execute an action by ID