markupeditor 0.9.36 → 0.9.37

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.
@@ -35623,6 +35623,19 @@ function insertLinkCommand(url) {
35623
35623
  return commandAdapter;
35624
35624
  }
35625
35625
 
35626
+ /**
35627
+ * Insert a link to the header identified by hTag ('H1'-'H6') and index (its position among
35628
+ * headers with that tag), assigning the header a unique id if it doesn't already have one.
35629
+ *
35630
+ * @param {string} hTag One of the strings `H1`-`H6`
35631
+ * @param {number} index Within existing elements with tag `hTag`, this is the index into them that is identified
35632
+ */
35633
+ function insertInternalLink(hTag, index) {
35634
+ const view = activeView();
35635
+ let command = insertInternalLinkCommand(hTag, index);
35636
+ let result = command(view.state, view.dispatch, view);
35637
+ return result
35638
+ }
35626
35639
  function insertInternalLinkCommand(hTag, index) {
35627
35640
  const commandAdapter = (state, dispatch, view) => {
35628
35641
  // Find the node matching hTag that is index into the nodes matching hTag
@@ -35737,12 +35750,34 @@ function headerMatching(hTag, index, state) {
35737
35750
  }
35738
35751
  }
35739
35752
 
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.
35757
+ *
35758
+ * @returns {string} JSON-stringified array of `{hTag, index, text}`
35759
+ */
35760
+ function getHeaders() {
35761
+ const view = activeView();
35762
+ const headersByLevel = headers(view.state);
35763
+ let result = [];
35764
+ for (let level = 1; level < 7; level++) {
35765
+ let hNodes = headersByLevel[level];
35766
+ if (hNodes) {
35767
+ hNodes.forEach((h, index) => {
35768
+ result.push({hTag: 'H' + level.toString(), index: index, text: h.node.textContent});
35769
+ });
35770
+ }
35771
+ }
35772
+ return JSON.stringify(result)
35773
+ }
35774
+
35740
35775
  /**
35741
35776
  * Return all the headers that exist in `state.doc` as arrays keyed by level.
35742
- *
35777
+ *
35743
35778
  * @ignore
35744
35779
  * @param {EditorState} state The state of the ProseMirror editor
35745
- */
35780
+ */
35746
35781
  function headers(state) {
35747
35782
  let headers = {};
35748
35783
  let hType = state.schema.nodes.heading;
@@ -42749,6 +42784,7 @@ const MU = {
42749
42784
  getDataImages,
42750
42785
  getLocalImages,
42751
42786
  getHTML,
42787
+ getHeaders,
42752
42788
  getHeight,
42753
42789
  getImageAttributes,
42754
42790
  getLinkAttributes,
@@ -42756,6 +42792,7 @@ const MU = {
42756
42792
  getTestHTML,
42757
42793
  indent: indent$1,
42758
42794
  insertImage: insertImage$1,
42795
+ insertInternalLink,
42759
42796
  insertLink: insertLink$1,
42760
42797
  insertTable,
42761
42798
  insertHRule,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markupeditor",
3
- "version": "0.9.36",
3
+ "version": "0.9.37",
4
4
  "description": "A web component and API for WYSIWYG HTML editing.",
5
5
  "keywords": [
6
6
  "wysiwyg",