Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
}

10 changes: 2 additions & 8 deletions src/app/editor/LinkExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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!,
Expand All @@ -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
}
Expand Down