markupeditor 0.9.38 → 0.9.40

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.
@@ -32817,6 +32817,12 @@ function isRecognizedLanguage(name) {
32817
32817
  * the same language for display/matching purposes, matching isRecognizedLanguage's
32818
32818
  * own case-insensitivity.
32819
32819
  *
32820
+ * Filtered through isRecognizedLanguage, so a genuinely custom/unrecognized
32821
+ * language name typed into one block is no longer suggested for reuse in
32822
+ * another. Trade-off accepted for a positive, Markdown-agnostic rule ("only
32823
+ * present languages this app actually supports") rather than a per-language
32824
+ * exclusion list.
32825
+ *
32820
32826
  * @param {Node} doc A ProseMirror document node.
32821
32827
  * @returns {string[]}
32822
32828
  */
@@ -32827,7 +32833,7 @@ function presentCodeLanguages(doc) {
32827
32833
  languages.add(node.attrs.language.toLowerCase());
32828
32834
  }
32829
32835
  });
32830
- return Array.from(languages).sort()
32836
+ return Array.from(languages).filter(isRecognizedLanguage).sort()
32831
32837
  }
32832
32838
 
32833
32839
  // hljs never has classPrefix reconfigured elsewhere in this codebase, so this
@@ -35639,34 +35645,32 @@ function insertInternalLink(hTag, index) {
35639
35645
  function insertInternalLinkCommand(hTag, index) {
35640
35646
  const commandAdapter = (state, dispatch, view) => {
35641
35647
  // Find the node matching hTag that is index into the nodes matching hTag
35642
- let {node} = headerMatching(hTag, index, state);
35648
+ let {node, pos} = headerMatching(hTag, index, state);
35643
35649
  if (!node) return false
35644
- // Get the unique id for this header, which is may or may not already have.
35650
+ // Get the unique id for this header, which it may or may not already have.
35645
35651
  let id = idForHeader(node, state);
35646
- let attrs = node.attrs;
35647
- attrs.id = id;
35648
- // Insert the mark (id is always referenced with # at front) and set (or reset) the
35649
- // id in the header itself. We don't care if it's the same, but we want these changes
35650
- // to be made in a single transaction so we can undo them if needed.
35652
+ // Same transaction as the mark insertion below, so both land as one undo step.
35653
+ let tr = state.tr.setNodeMarkup(pos, undefined, { ...node.attrs, id });
35651
35654
  const selection = state.selection;
35652
35655
  const linkMark = state.schema.marks.link.create({ href: '#' + id });
35653
35656
  if (selection.empty) {
35654
- // In case of an empty selection, insert the textContent of the header and then use
35657
+ // In case of an empty selection, insert the textContent of the header and then use
35655
35658
  // that to link-to the header
35656
35659
  const textNode = state.schema.text(node.textContent, [linkMark]);
35657
- let transaction = state.tr.replaceSelectionWith(textNode, false);
35658
- dispatch(transaction);
35660
+ tr.replaceSelectionWith(textNode, false);
35661
+ dispatch(tr);
35659
35662
  stateChanged(view);
35660
35663
  return true;
35661
35664
  } else {
35662
- const toggle = toggleMark(linkMark.type, linkMark.attrs);
35663
- if (toggle) {
35664
- toggle(state, dispatch);
35665
- stateChanged(view);
35666
- return true;
35667
- } else {
35668
- return false;
35669
- }
35665
+ // Capture toggleMark's steps rather than let it dispatch, then replay them onto
35666
+ // `tr` (setNodeMarkup doesn't shift positions, so they apply cleanly).
35667
+ let captured = null;
35668
+ toggleMark(linkMark.type, linkMark.attrs)(state, t => { captured = t; });
35669
+ if (!captured) return false;
35670
+ for (const step of captured.steps) tr.step(step);
35671
+ dispatch(tr);
35672
+ stateChanged(view);
35673
+ return true;
35670
35674
  }
35671
35675
  };
35672
35676
  return commandAdapter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markupeditor",
3
- "version": "0.9.38",
3
+ "version": "0.9.40",
4
4
  "description": "A web component and API for WYSIWYG HTML editing.",
5
5
  "keywords": [
6
6
  "wysiwyg",