@bhsd/codemirror-mediawiki 3.6.7 → 3.7.0

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/openLinks.js CHANGED
@@ -2,8 +2,7 @@ import { EditorView } from '@codemirror/view';
2
2
  import { ensureSyntaxTree } from '@codemirror/language';
3
3
  import { tokens } from './config';
4
4
  import { isMac } from './constants';
5
- import { hasTag } from './util';
6
- const modKey = isMac ? 'metaKey' : 'ctrlKey', key = isMac ? 'Meta' : 'Control', tags = ['extLinkProtocol', 'extLink', 'freeExtLinkProtocol', 'freeExtLink', 'magicLink', 'pageName'], links = ['extlink-protocol', 'extlink', 'free-extlink-protocol', 'free-extlink', 'magic-link'], pagename = '.cm-mw-pagename', wikiLinks = [
5
+ const modKey = isMac ? 'metaKey' : 'ctrlKey', key = isMac ? 'Meta' : 'Control', links = ['extlink-protocol', 'extlink', 'free-extlink-protocol', 'free-extlink', 'magic-link'], pagename = '.cm-mw-pagename', wikiLinks = [
7
6
  'template-name',
8
7
  'link-pagename',
9
8
  `parserfunction${pagename}`,
@@ -43,21 +42,18 @@ export const mouseEventListener = (e, view, langConfig) => {
43
42
  || !(e.target instanceof Element && getComputedStyle(e.target).textDecorationLine === 'underline')) {
44
43
  return undefined;
45
44
  }
46
- const position = view.posAtCoords(e);
47
- if (!position) {
45
+ const posAndSide = view.posAndSideAtCoords(e);
46
+ if (!posAndSide) {
48
47
  return undefined;
49
48
  }
50
- const { state } = view, tree = ensureSyntaxTree(state, position);
49
+ const { state } = view, tree = ensureSyntaxTree(state, posAndSide.pos);
51
50
  if (!tree) {
52
51
  return undefined;
53
52
  }
54
- let node = tree.resolve(position, -1);
53
+ let node = tree.resolve(posAndSide.pos, posAndSide.assoc);
55
54
  if (node.name.includes(tokens.linkToSection)) {
56
55
  node = node.prevSibling;
57
56
  }
58
- else if (!hasTag(new Set(node.name.split('_')), tags)) {
59
- node = tree.resolve(position, 1);
60
- }
61
57
  const { name, from, to } = node;
62
58
  if (name.includes(tokens.pageName) && typeof langConfig?.titleParser === 'function') {
63
59
  return langConfig.titleParser(state, node);
package/dist/statusBar.js CHANGED
@@ -51,8 +51,11 @@ const updateDiagnosticMessage = (cm, allDiagnostics, main, msg) => {
51
51
  const diagnostic = diagnostics.find(({ from, to }) => from <= main.head && to >= main.head) ?? diagnostics[0], view = cm.view;
52
52
  msg.textContent = diagnostic.message;
53
53
  if (diagnostic.actions) {
54
- msg.append(...diagnostic.actions.map(({ name, apply }) => {
54
+ msg.append(...diagnostic.actions.map(({ name, tooltip, apply }) => {
55
55
  const button = elt('button', { type: 'button', class: actionSelector.slice(1) }, name);
56
+ if (tooltip) {
57
+ button.title = tooltip;
58
+ }
56
59
  button.addEventListener('click', e => {
57
60
  e.preventDefault();
58
61
  apply(view, diagnostic.from, diagnostic.to);