From 42049e8bb4437add8ea828195993a839998bca05 Mon Sep 17 00:00:00 2001 From: Ticruz Date: Fri, 15 Nov 2024 17:03:21 +0100 Subject: [PATCH 1/2] fix #472 #473 --- src/app/editor/LinkExtension.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) 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 } From 5e0d2e7fe16f7f95a2732c793ccc1d3f4a8f57a1 Mon Sep 17 00:00:00 2001 From: Ticruz Date: Fri, 15 Nov 2024 17:23:04 +0100 Subject: [PATCH 2/2] fix Code fencing doesn't allow line breaks #469 --- src/app.css | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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; } -