mirror of
https://github.com/heyman/heynote.git
synced 2025-06-20 01:27:44 +02:00
Fix so that links are clickable in Markdown mode.
Do not include closing parentheses in link regex.
This commit is contained in:
parent
f4a5806f0c
commit
4a042ca5da
@ -6,7 +6,7 @@ const modChar = window.heynote.platform.isMac ? "⌘" : "Ctrl"
|
|||||||
const eventKeyModAttribute = window.heynote.platform.isMac ? "metaKey" : "ctrlKey"
|
const eventKeyModAttribute = window.heynote.platform.isMac ? "metaKey" : "ctrlKey"
|
||||||
|
|
||||||
const linkMatcher = new MatchDecorator({
|
const linkMatcher = new MatchDecorator({
|
||||||
regexp: /https?:\/\/[^\s]+/gi,
|
regexp: /https?:\/\/[^\s\)]+/gi,
|
||||||
decoration: match => {
|
decoration: match => {
|
||||||
return Decoration.mark({
|
return Decoration.mark({
|
||||||
class: "heynote-link",
|
class: "heynote-link",
|
||||||
@ -29,7 +29,7 @@ export const links = ViewPlugin.fromClass(class {
|
|||||||
eventHandlers: {
|
eventHandlers: {
|
||||||
click: (e, view) => {
|
click: (e, view) => {
|
||||||
let target = e.target
|
let target = e.target
|
||||||
if (target.classList.contains("heynote-link") && e[eventKeyModAttribute]) {
|
if (target.closest(".heynote-link")?.classList.contains("heynote-link") && e[eventKeyModAttribute]) {
|
||||||
let linkEl = document.createElement("a")
|
let linkEl = document.createElement("a")
|
||||||
linkEl.href = target.textContent
|
linkEl.href = target.textContent
|
||||||
linkEl.target = "_blank"
|
linkEl.target = "_blank"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user