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
@@ -122,13 +122,13 @@ var MarkdownParser = class {
122
122
  * @returns {string} Parsed task list item
123
123
  */
124
124
  static parseTaskList(html, isPreviewMode = false) {
125
- return html.replace(/^((?: )*)-\s+\[([ xX])\]\s+(.+)$/, (match, indent, checked, content) => {
125
+ return html.replace(/^((?: )*)-(\s+)\[([ xX])\](\s*)(.*)$/, (match, indent, spacingBeforeBox, checked, spacingAfterBox, content) => {
126
126
  content = this.parseInlineElements(content);
127
127
  if (isPreviewMode) {
128
128
  const isChecked = checked.toLowerCase() === "x";
129
129
  return `${indent}<li class="task-list"><input type="checkbox" ${isChecked ? "checked" : ""}> ${content}</li>`;
130
130
  } else {
131
- return `${indent}<li class="task-list"><span class="syntax-marker">- [${checked}] </span>${content}</li>`;
131
+ return `${indent}<li class="task-list"><span class="syntax-marker">-${spacingBeforeBox}[${checked}]${spacingAfterBox}</span>${content}</li>`;
132
132
  }
133
133
  });
134
134
  }
@@ -4715,7 +4715,7 @@ var _OverType = class _OverType {
4715
4715
  });
4716
4716
  this.initialized = true;
4717
4717
  if (this.options.onChange) {
4718
- this.options.onChange(this.getValue(), this);
4718
+ this._notifyChange();
4719
4719
  }
4720
4720
  }
4721
4721
  /**
@@ -5155,13 +5155,19 @@ var _OverType = class _OverType {
5155
5155
  if (this.options.showStats && this.statsBar) {
5156
5156
  this._updateStats();
5157
5157
  }
5158
- if (this.options.onChange && this.initialized) {
5159
- this.options.onChange(text, this);
5160
- }
5161
5158
  if (this.options.onRender) {
5162
5159
  this.options.onRender(this.preview, isPreviewMode ? "preview" : "normal", this);
5163
5160
  }
5164
5161
  }
5162
+ /**
5163
+ * Notify listeners that the editor value changed
5164
+ * @private
5165
+ */
5166
+ _notifyChange() {
5167
+ if (!this.options.onChange || !this.initialized)
5168
+ return;
5169
+ this.options.onChange(this.textarea.value, this);
5170
+ }
5165
5171
  /**
5166
5172
  * Apply background styling to code blocks
5167
5173
  * @private
@@ -5195,6 +5201,7 @@ var _OverType = class _OverType {
5195
5201
  */
5196
5202
  handleInput(event) {
5197
5203
  this.updatePreview();
5204
+ this._notifyChange();
5198
5205
  }
5199
5206
  /**
5200
5207
  * Handle keydown events
@@ -5375,11 +5382,15 @@ var _OverType = class _OverType {
5375
5382
  * @param {string} value - Markdown content to set
5376
5383
  */
5377
5384
  setValue(value) {
5385
+ const didChange = this.textarea.value !== value;
5378
5386
  this.textarea.value = value;
5379
5387
  this.updatePreview();
5380
5388
  if (this.options.autoResize) {
5381
5389
  this._updateAutoHeight();
5382
5390
  }
5391
+ if (didChange) {
5392
+ this._notifyChange();
5393
+ }
5383
5394
  }
5384
5395
  /**
5385
5396
  * Execute an action by ID