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.
- package/dist/markup-editor.js +13 -5
- package/package.json +1 -1
package/dist/markup-editor.js
CHANGED
|
@@ -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
|
|
35755
|
-
* within each level. Each entry is `{hTag, index, text}`, where `hTag` and `index` identify
|
|
35756
|
-
* header the same way `insertInternalLink(hTag, index)` and `idForInternalLinkCommand(hTag, index)`
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
}
|