Skip to content

Commit caa1c06

Browse files
chore(deps): bump @tiptap/react from 2.27.2 to 3.23.6 in /sites/partners (#6322)
1 parent ffd6c53 commit caa1c06

5 files changed

Lines changed: 288 additions & 371 deletions

File tree

sites/partners/package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,10 @@
3434
"@bloom-housing/ui-seeds": "3.4.1",
3535
"@heroicons/react": "^2.2.0",
3636
"@mapbox/mapbox-sdk": "^0.13.0",
37-
"@tiptap/core": "^2.24.0",
38-
"@tiptap/extension-character-count": "^2.24.0",
39-
"@tiptap/extension-link": "^2.24.0",
40-
"@tiptap/pm": "^2.24.0",
41-
"@tiptap/react": "^2.24.0",
42-
"@tiptap/starter-kit": "^2.24.0",
37+
"@tiptap/core": "^3.23.6",
38+
"@tiptap/extension-character-count": "^3.23.6",
39+
"@tiptap/react": "^3.23.6",
40+
"@tiptap/starter-kit": "^3.23.6",
4341
"ag-grid-community": "^26.0.0",
4442
"autoprefixer": "^10.3.4",
4543
"axios": "^1.15.0",

sites/partners/src/components/listings/PaperListingForm/index.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,14 @@ const ListingForm = ({
200200
const whatToExpectEditor = useEditor({
201201
extensions: [...EditorExtensions, CharacterCountExtension.configure()],
202202
content: listing?.whatToExpect || selectedJurisdictionData?.whatToExpect,
203-
immediatelyRender: true,
203+
immediatelyRender: false,
204204
})
205205

206206
const whatToExpectAdditionalDetailsEditor = useEditor({
207207
extensions: [...EditorExtensions, CharacterCountExtension.configure()],
208208
content:
209209
listing?.whatToExpectAdditionalText || selectedJurisdictionData?.whatToExpectAdditionalText,
210-
immediatelyRender: true,
210+
immediatelyRender: false,
211211
})
212212

213213
const { data: properties, loading: propertiesLoading } = usePropertiesList({
@@ -230,26 +230,31 @@ const ListingForm = ({
230230
marketingTypeChoice === MarketingTypeEnum.comingSoon &&
231231
!!selectedJurisdictionData.whatToExpectUnderConstruction
232232
) {
233-
whatToExpectEditor.commands.setContent(
233+
whatToExpectEditor?.commands.setContent(
234234
selectedJurisdictionData.whatToExpectUnderConstruction
235235
)
236-
whatToExpectAdditionalDetailsEditor.commands.clearContent()
236+
whatToExpectAdditionalDetailsEditor?.commands.clearContent()
237237
return
238238
}
239239

240240
if (!editMode) {
241241
if (!whatToExpectEditor?.storage.characterCount.characters()) {
242-
whatToExpectEditor.commands.setContent(selectedJurisdictionData.whatToExpect)
242+
whatToExpectEditor?.commands.setContent(selectedJurisdictionData.whatToExpect)
243243
}
244244
if (!whatToExpectAdditionalDetailsEditor?.storage.characterCount.characters()) {
245-
whatToExpectAdditionalDetailsEditor.commands.setContent(
245+
whatToExpectAdditionalDetailsEditor?.commands.setContent(
246246
selectedJurisdictionData.whatToExpectAdditionalText
247247
)
248248
}
249249
}
250250
}
251251
//eslint-disable-next-line
252-
}, [selectedJurisdictionData, marketingTypeChoice])
252+
}, [
253+
selectedJurisdictionData,
254+
marketingTypeChoice,
255+
whatToExpectEditor,
256+
whatToExpectAdditionalDetailsEditor,
257+
])
253258

254259
const enableUnitGroups = doJurisdictionsHaveFeatureFlagOn(
255260
FeatureFlagEnum.enableUnitGroups,
@@ -369,12 +374,10 @@ const ListingForm = ({
369374
async (formData: FormListing, continueEditing: boolean) => {
370375
if (!loading) {
371376
try {
372-
setLoading(true)
373377
clearErrors()
374378
const successful = await formMethods.trigger()
375379

376380
if (whatToExpectEditor?.storage.characterCount.characters() > CHARACTER_LIMIT) {
377-
setLoading(false)
378381
setAlert("form")
379382
return
380383
}
@@ -385,7 +388,6 @@ const ListingForm = ({
385388
whatToExpectAdditionalDetailsEditor?.storage.characterCount.characters() >
386389
CHARACTER_LIMIT
387390
) {
388-
setLoading(false)
389391
setAlert("form")
390392
return
391393
}
@@ -431,6 +433,8 @@ const ListingForm = ({
431433
formData.scheduledPublishAt = null
432434
}
433435

436+
setLoading(true)
437+
434438
if (successful) {
435439
const dataPipeline = new ListingDataPipeline(formData, {
436440
preferences: disableListingPreferences ? [] : preferences,
@@ -547,6 +551,8 @@ const ListingForm = ({
547551
addToast,
548552
enableUnitGroups,
549553
enableAutopublish,
554+
whatToExpectEditor,
555+
whatToExpectAdditionalDetailsEditor,
550556
]
551557
)
552558
return (

sites/partners/src/components/listings/PaperListingForm/sections/ApplicationTypes.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -574,11 +574,6 @@ const ApplicationTypes = ({
574574
name="referralSummary"
575575
id="referralSummary"
576576
maxLength={500}
577-
defaultValue={
578-
methods?.referral?.externalReference
579-
? methods.referral.externalReference
580-
: defaultReferralText
581-
}
582577
inputProps={{
583578
value: methods?.referral
584579
? methods?.referral?.externalReference

sites/partners/src/components/shared/TextEditor.tsx

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useCallback, useState } from "react"
22
import Markdown from "markdown-to-jsx"
33
import { EditorContent, Editor } from "@tiptap/react"
44
import { StarterKit } from "@tiptap/starter-kit"
5-
import { Link as LinkExtension } from "@tiptap/extension-link"
5+
import { CharacterCount } from "@tiptap/extension-character-count"
66
import BoldIcon from "@heroicons/react/16/solid/BoldIcon"
77
import BulletListIcon from "@heroicons/react/16/solid/ListBulletIcon"
88
import OrderedListIcon from "@heroicons/react/16/solid/NumberedListIcon"
@@ -14,48 +14,49 @@ import { t } from "@bloom-housing/ui-components"
1414
import styles from "./TextEditor.module.scss"
1515

1616
export const EditorExtensions = [
17+
CharacterCount,
1718
StarterKit.configure({
1819
heading: false,
1920
code: false,
2021
blockquote: false,
2122
codeBlock: false,
2223
italic: false,
23-
}),
24-
LinkExtension.configure({
25-
openOnClick: true,
26-
autolink: true,
27-
defaultProtocol: "https",
28-
protocols: [
29-
"http",
30-
"https",
31-
{ scheme: "mailto", optionalSlashes: true },
32-
{ scheme: "tel", optionalSlashes: true },
33-
],
34-
isAllowedUri: (url, ctx) => {
35-
try {
36-
// construct URL
37-
const parsedUrl = url.includes(":")
38-
? new URL(url)
39-
: new URL(`${ctx.defaultProtocol}://${url}`)
24+
link: {
25+
openOnClick: true,
26+
autolink: true,
27+
defaultProtocol: "https",
28+
protocols: [
29+
"http",
30+
"https",
31+
{ scheme: "mailto", optionalSlashes: true },
32+
{ scheme: "tel", optionalSlashes: true },
33+
],
34+
isAllowedUri: (url, ctx) => {
35+
try {
36+
// construct URL
37+
const parsedUrl = url.includes(":")
38+
? new URL(url)
39+
: new URL(`${ctx.defaultProtocol}://${url}`)
4040

41-
// use default validation
42-
if (!ctx.defaultValidate(parsedUrl.href)) {
43-
return false
44-
}
41+
// use default validation
42+
if (!ctx.defaultValidate(parsedUrl.href)) {
43+
return false
44+
}
45+
46+
const protocol = parsedUrl.protocol.replace(":", "")
4547

46-
const protocol = parsedUrl.protocol.replace(":", "")
48+
// only allow protocols specified in ctx.protocols
49+
const allowedProtocols = ctx.protocols.map((p) => (typeof p === "string" ? p : p.scheme))
4750

48-
// only allow protocols specified in ctx.protocols
49-
const allowedProtocols = ctx.protocols.map((p) => (typeof p === "string" ? p : p.scheme))
51+
if (!allowedProtocols.includes(protocol)) {
52+
return false
53+
}
5054

51-
if (!allowedProtocols.includes(protocol)) {
55+
return true
56+
} catch {
5257
return false
5358
}
54-
55-
return true
56-
} catch {
57-
return false
58-
}
59+
},
5960
},
6061
}),
6162
]
@@ -77,15 +78,18 @@ const MenuBar = ({ editor }) => {
7778
return
7879
}
7980

81+
// Prepend https:// if the user typed a bare URL with no protocol.
82+
const href = /^[a-z][a-z0-9+.-]*:/i.test(url) ? url : `https://${url}`
83+
8084
// update link
8185
try {
82-
editor?.chain().focus().extendMarkRange("link").setLink({ href: url }).run()
86+
editor?.chain().focus().extendMarkRange("link").setLink({ href }).run()
8387
} catch (e) {
8488
alert(e.message)
8589
}
8690
}, [editor])
8791

88-
if (!editor) {
92+
if (!editor || editor.isDestroyed) {
8993
return null
9094
}
9195

@@ -245,24 +249,26 @@ export const TextEditor = ({
245249
label,
246250
}: TextEditorProps) => {
247251
const [errorState, setErrorState] = useState(error)
252+
const [characterCount, setCharacterCount] = useState(
253+
() => editor?.storage?.characterCount?.characters() ?? 0
254+
)
248255

249256
const labelId = `${editorId}Label`
250257

251-
if (!editor) {
258+
if (!editor || editor.isDestroyed) {
252259
return null
253260
}
254261

255262
editor.on("update", () => {
256263
if (errorState) setErrorState(false)
264+
setCharacterCount(editor?.storage?.characterCount?.characters() ?? 0)
257265
})
258266

259267
editor.on("create", () => {
260268
editor?.view.setProps({
261269
attributes: { "aria-labelledby": labelId, role: "textbox" },
262270
})
263271
})
264-
265-
const characterCount = editor?.storage?.characterCount?.characters()
266272
const overLimit = characterCount > characterLimit
267273

268274
return (

0 commit comments

Comments
 (0)