Use synonyms in Tooltip
This commit is contained in:
parent
e4b00117c3
commit
bbc292561f
1 changed files with 10 additions and 4 deletions
|
|
@ -31,6 +31,9 @@ window.addEventListener(
|
||||||
export const strudelTooltip = hoverTooltip(
|
export const strudelTooltip = hoverTooltip(
|
||||||
(view, pos, side) => {
|
(view, pos, side) => {
|
||||||
// Word selection from CodeMirror Hover Tooltip example https://codemirror.net/examples/tooltip/#hover-tooltips
|
// Word selection from CodeMirror Hover Tooltip example https://codemirror.net/examples/tooltip/#hover-tooltips
|
||||||
|
if (!ctrlDown) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
let { from, to, text } = view.state.doc.lineAt(pos);
|
let { from, to, text } = view.state.doc.lineAt(pos);
|
||||||
let start = pos,
|
let start = pos,
|
||||||
end = pos;
|
end = pos;
|
||||||
|
|
@ -47,11 +50,14 @@ export const strudelTooltip = hoverTooltip(
|
||||||
// Get entry from Strudel documentation
|
// Get entry from Strudel documentation
|
||||||
let entry = jsdoc.docs.filter((doc) => getDocLabel(doc) === word)[0];
|
let entry = jsdoc.docs.filter((doc) => getDocLabel(doc) === word)[0];
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
return null;
|
// Try for synonyms
|
||||||
}
|
entry = jsdoc.docs.filter((doc) => doc.synonyms && doc.synonyms.includes(word))[0];
|
||||||
if (!ctrlDown) {
|
if (!entry) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
entry.name = word;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pos: start,
|
pos: start,
|
||||||
end,
|
end,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue