diff --git a/src/app.css b/src/app.css index d08b0e76c..887ee491c 100644 --- a/src/app.css +++ b/src/app.css @@ -244,7 +244,7 @@ body, } .tiptap pre code { - @apply block max-w-full overflow-auto whitespace-nowrap rounded bg-neutral-200 px-1 no-underline text-neutral-800; + @apply block max-w-full overflow-auto rounded bg-neutral-200 px-1 text-neutral-800 no-underline; } .tiptap p code { @@ -266,10 +266,9 @@ body, .link-content, .tiptap [tag] { - @apply max-w-full overflow-hidden text-ellipsis whitespace-nowrap rounded bg-neutral-200 px-1 no-underline text-neutral-800; + @apply max-w-full overflow-hidden text-ellipsis whitespace-nowrap rounded bg-neutral-200 px-1 text-neutral-800 no-underline; } .link-content.link-content-selected { @apply bg-neutral-300; } - diff --git a/src/app/editor/LinkExtension.ts b/src/app/editor/LinkExtension.ts index bbc399f31..5616e097a 100644 --- a/src/app/editor/LinkExtension.ts +++ b/src/app/editor/LinkExtension.ts @@ -4,8 +4,7 @@ import type {Node as ProsemirrorNode} from "@tiptap/pm/model" import type {MarkdownSerializerState} from "prosemirror-markdown" import {createPasteRuleMatch} from "./util" -export const LINK_REGEX = - /([a-z\+:]{2,30}:\/\/)?[^<>\(\)\s]+\.[a-z]{2,6}[^\s]*[^<>"'\.!?,:\s\)\(]*/gi +export const LINK_REGEX = /([a-z\+:]{2,30}:\/\/)?[^<>\(\)\s]+\.[a-z]{2,6}[^\s<>"'\.!?,:\)\(]*/gi export interface LinkAttributes { url: string @@ -67,7 +66,6 @@ export const LinkExtension = Node.create({ new InputRule({ find: text => { const match = last(Array.from(text.matchAll(LINK_REGEX))) - if (match && text.length === match.index + match[0].length + 1) { return { index: match.index!, @@ -82,15 +80,11 @@ export const LinkExtension = Node.create({ }, handler: ({state, range, match}) => { const {tr} = state - if (match[0]) { try { tr.insert(range.from - 1, this.type.create(match.data)) .delete(tr.mapping.map(range.from - 1), tr.mapping.map(range.to)) - .insert( - tr.mapping.map(range.to), - this.editor.schema.text(last(Array.from(match.input!))), - ) + .insertText(last(Array.from(match.input!))) } catch (e) { // If the node was already linkified, the above code breaks for whatever reason }