diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/MenuItem.mjs | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/MenuItem.mjs b/src/MenuItem.mjs index cffd4a7..2fcb144 100644 --- a/src/MenuItem.mjs +++ b/src/MenuItem.mjs | |||
| @@ -399,16 +399,22 @@ export const restoreCamera = map => | |||
| 399 | export const addRefLink = (cm, refLinks) => | 399 | export const addRefLink = (cm, refLinks) => |
| 400 | new Folder({ | 400 | new Folder({ |
| 401 | text: 'Add Link', | 401 | text: 'Add Link', |
| 402 | items: refLinks.map(refLink => new Item({ | 402 | items: refLinks.map(refLink => { |
| 403 | text: refLink.link.startsWith('geo:') ? `@ ${refLink.ref}` : refLink.ref, | 403 | let text = refLink.ref |
| 404 | title: refLink.link, | 404 | if (refLink.link.startsWith('geo:')) text = `@ ${text}` |
| 405 | onclick: () => { | 405 | if (refLink.title?.match(/^=>/)) text = `=> ${text}` |
| 406 | const selection = cm.getSelection() | 406 | |
| 407 | if (selection === refLink.ref) { | 407 | return new Item({ |
| 408 | cm.replaceSelection(`[${selection}]`) | 408 | text, |
| 409 | } else { | 409 | title: refLink.link, |
| 410 | cm.replaceSelection(`[${selection}][${refLink.ref}]`) | 410 | onclick: () => { |
| 411 | } | 411 | const selection = cm.getSelection() |
| 412 | }, | 412 | if (selection === refLink.ref) { |
| 413 | })), | 413 | cm.replaceSelection(`[${selection}]`) |
| 414 | } else { | ||
| 415 | cm.replaceSelection(`[${selection}][${refLink.ref}]`) | ||
| 416 | } | ||
| 417 | }, | ||
| 418 | }) | ||
| 419 | }), | ||
| 414 | }) | 420 | }) |