Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

fix(ui): Link rendering in comment editor Uses new npm dependency @tiptap/extension-link to fix link rendering Previously links would be stripped from the editor in rich text mode This extension allows users to: - Insert links using markdown syntax in markdown mode - Paste links directly in rich text mode - Preserve links when toggling between modes

widal00159beed96d871
diff --git a/package-lock.json b/package-lock.json
index 963f568ab..0c2d7d446 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -12,6 +12,7 @@
"@lingui/react": "^5.1.2",
"@tiptap/extension-hard-break": "^2.11.5",
"@tiptap/extension-image": "^2.22.3",
+ "@tiptap/extension-link": "^2.11.5",
"@tiptap/extension-mention": "^2.11.5",
"@tiptap/extension-placeholder": "^2.11.5",
"@tiptap/pm": "^2.11.5",
@@ -4903,6 +4904,23 @@
"@tiptap/core": "^2.7.0"
}
},
+ "node_modules/@tiptap/extension-link": {
+ "version": "2.26.2",
+ "resolved": "https://registry.npmjs.org/@tiptap/extension-link/-/extension-link-2.26.2.tgz",
+ "integrity": "sha512-rzYxx5wI1551ubPfW2pJ3V957cX/WAmbUI3q8Un+LlOsSmbddl+5BjlF5t/vl/pwaOv7FJAz9e29n877zkGOVQ==",
+ "license": "MIT",
+ "dependencies": {
+ "linkifyjs": "^4.2.0"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/ueberdosis"
+ },
+ "peerDependencies": {
+ "@tiptap/core": "^2.7.0",
+ "@tiptap/pm": "^2.7.0"
+ }
+ },
"node_modules/@tiptap/extension-list-item": {
"version": "2.11.5",
"resolved": "https://registry.npmjs.org/@tiptap/extension-list-item/-/extension-list-item-2.11.5.tgz",
@@ -13643,6 +13661,12 @@
"uc.micro": "^2.0.0"
}
},
+ "node_modules/linkifyjs": {
+ "version": "4.3.2",
+ "resolved": "https://registry.npmjs.org/linkifyjs/-/linkifyjs-4.3.2.tgz",
+ "integrity": "sha512-NT1CJtq3hHIreOianA8aSXn6Cw0JzYOuDQbOrSPe7gqFnCpKP++MQe3ODgO3oh2GJFORkAAdqredOa60z63GbA==",
+ "license": "MIT"
+ },
"node_modules/loader-runner": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz",
diff --git a/package.json b/package.json
index a9d0c7d54..0b1b90b2f 100644
--- a/package.json
+++ b/package.json
@@ -8,6 +8,7 @@
"@lingui/react": "^5.1.2",
"@tiptap/extension-hard-break": "^2.11.5",
"@tiptap/extension-image": "^2.22.3",
+ "@tiptap/extension-link": "^2.11.5",
"@tiptap/extension-mention": "^2.11.5",
"@tiptap/extension-placeholder": "^2.11.5",
"@tiptap/pm": "^2.11.5",
diff --git a/public/components/common/form/CommentEditor.tsx b/public/components/common/form/CommentEditor.tsx
index 3a0baf01f..64c9c0fd8 100644
--- a/public/components/common/form/CommentEditor.tsx
+++ b/public/components/common/form/CommentEditor.tsx
@@ -1,5 +1,6 @@
import { Editor } from "@tiptap/react"
import StarterKit from "@tiptap/starter-kit"
+import Link from "@tiptap/extension-link"
import React, { useState, useRef, useEffect } from "react"
import { EditorContent, useEditor } from "@tiptap/react"
import { Markdown } from "tiptap-markdown"
@@ -426,6 +427,16 @@ const Tiptap: React.FunctionComponent<CommentEditorProps> = (props) => {
]
: [
StarterKit,
+ Link.configure({
+ openOnClick: false,
+ autolink: true,
+ defaultProtocol: "https",
+ HTMLAttributes: {
+ class: "text-link",
+ target: "_blank",
+ rel: "noopener nofollow",
+ },
+ }),
Markdown.configure({
html: true,
breaks: true,