Skip to content
Open
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
1 change: 1 addition & 0 deletions sites/partners/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ module.exports = withBundleAnalyzer(
},
]

config.resolve.alias["prosemirror-model"] = require.resolve("prosemirror-model")
return config
},
eslint: {
Expand Down
12 changes: 6 additions & 6 deletions sites/partners/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
"@bloom-housing/ui-seeds": "3.4.1",
"@heroicons/react": "^2.2.0",
"@mapbox/mapbox-sdk": "^0.13.0",
"@tiptap/core": "^2.24.0",
"@tiptap/extension-character-count": "^2.24.0",
"@tiptap/extension-link": "^2.24.0",
"@tiptap/pm": "^2.24.0",
"@tiptap/react": "^2.24.0",
"@tiptap/starter-kit": "^2.24.0",
"@tiptap/core": "^3.23.6",
"@tiptap/extension-character-count": "^3.23.6",
"@tiptap/extension-link": "^3.23.6",
"@tiptap/pm": "^3.23.6",
"@tiptap/react": "^3.23.6",
"@tiptap/starter-kit": "^3.23.6",
"ag-grid-community": "^26.0.0",
"autoprefixer": "^10.3.4",
"axios": "^1.15.0",
Expand Down
66 changes: 34 additions & 32 deletions sites/partners/src/components/shared/TextEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { useCallback, useState } from "react"
import Markdown from "markdown-to-jsx"
import { EditorContent, Editor } from "@tiptap/react"
import { StarterKit } from "@tiptap/starter-kit"
import { Link as LinkExtension } from "@tiptap/extension-link"
import BoldIcon from "@heroicons/react/16/solid/BoldIcon"
import BulletListIcon from "@heroicons/react/16/solid/ListBulletIcon"
import OrderedListIcon from "@heroicons/react/16/solid/NumberedListIcon"
Expand All @@ -20,42 +19,42 @@ export const EditorExtensions = [
blockquote: false,
codeBlock: false,
italic: false,
}),
LinkExtension.configure({
openOnClick: true,
autolink: true,
defaultProtocol: "https",
protocols: [
"http",
"https",
{ scheme: "mailto", optionalSlashes: true },
{ scheme: "tel", optionalSlashes: true },
],
isAllowedUri: (url, ctx) => {
try {
// construct URL
const parsedUrl = url.includes(":")
? new URL(url)
: new URL(`${ctx.defaultProtocol}://${url}`)
link: {
openOnClick: true,
autolink: true,
defaultProtocol: "https",
protocols: [
"http",
"https",
{ scheme: "mailto", optionalSlashes: true },
{ scheme: "tel", optionalSlashes: true },
],
isAllowedUri: (url, ctx) => {
try {
// construct URL
const parsedUrl = url.includes(":")
? new URL(url)
: new URL(`${ctx.defaultProtocol}://${url}`)

// use default validation
if (!ctx.defaultValidate(parsedUrl.href)) {
return false
}
// use default validation
if (!ctx.defaultValidate(parsedUrl.href)) {
return false
}

const protocol = parsedUrl.protocol.replace(":", "")
const protocol = parsedUrl.protocol.replace(":", "")

// only allow protocols specified in ctx.protocols
const allowedProtocols = ctx.protocols.map((p) => (typeof p === "string" ? p : p.scheme))
// only allow protocols specified in ctx.protocols
const allowedProtocols = ctx.protocols.map((p) => (typeof p === "string" ? p : p.scheme))

if (!allowedProtocols.includes(protocol)) {
if (!allowedProtocols.includes(protocol)) {
return false
}

return true
} catch {
return false
}

return true
} catch {
return false
}
},
},
}),
]
Expand All @@ -77,9 +76,12 @@ const MenuBar = ({ editor }) => {
return
}

// Prepend https:// if the user typed a bare URL with no protocol.
const href = /^[a-z][a-z0-9+.-]*:/i.test(url) ? url : `https://${url}`

// update link
try {
editor?.chain().focus().extendMarkRange("link").setLink({ href: url }).run()
editor?.chain().focus().extendMarkRange("link").setLink({ href }).run()
} catch (e) {
alert(e.message)
}
Expand Down
Loading
Loading