markupeditor 0.9.37 → 0.9.38

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.
@@ -35751,11 +35751,17 @@ function headerMatching(hTag, index, state) {
35751
35751
  }
35752
35752
 
35753
35753
  /**
35754
- * Return a JSON-stringified array describing every header in the document, in document order
35755
- * within each level. Each entry is `{hTag, index, text}`, where `hTag` and `index` identify the
35756
- * header the same way `insertInternalLink(hTag, index)` and `idForInternalLinkCommand(hTag, index)` do.
35754
+ * Return a JSON-stringified array describing every non-empty header in the document, in document
35755
+ * order within each level. Each entry is `{hTag, index, text, id}`, where `hTag` and `index` identify
35756
+ * the header the same way `insertInternalLink(hTag, index)` and `idForInternalLinkCommand(hTag, index)`
35757
+ * do, and `id` is the header's current id attribute (null if it hasn't been assigned one yet).
35757
35758
  *
35758
- * @returns {string} JSON-stringified array of `{hTag, index, text}`
35759
+ * An empty header is omitted -- it can't form a usable id, so there's nothing to link to -- but
35760
+ * `index` still reflects its true position among ALL headers at that level (empty ones included),
35761
+ * matching what `headerMatching` expects; it's only the reported entries that skip empty headers,
35762
+ * not the numbering.
35763
+ *
35764
+ * @returns {string} JSON-stringified array of `{hTag, index, text, id}`
35759
35765
  */
35760
35766
  function getHeaders() {
35761
35767
  const view = activeView();
@@ -35765,7 +35771,9 @@ function getHeaders() {
35765
35771
  let hNodes = headersByLevel[level];
35766
35772
  if (hNodes) {
35767
35773
  hNodes.forEach((h, index) => {
35768
- result.push({hTag: 'H' + level.toString(), index: index, text: h.node.textContent});
35774
+ const text = h.node.textContent;
35775
+ if (text.trim().length === 0) return
35776
+ result.push({hTag: 'H' + level.toString(), index: index, text: text, id: h.node.attrs.id ?? null});
35769
35777
  });
35770
35778
  }
35771
35779
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markupeditor",
3
- "version": "0.9.37",
3
+ "version": "0.9.38",
4
4
  "description": "A web component and API for WYSIWYG HTML editing.",
5
5
  "keywords": [
6
6
  "wysiwyg",