Skip to content

Commit

Permalink
Rendre clickable les liens dans les demandes et ses réponses (#809)
Browse files Browse the repository at this point in the history
Co-authored-by: niladic <git@nil.choron.cc>
  • Loading branch information
mdulac and niladic authored Oct 28, 2020
1 parent 8c3525d commit 3a7d3ef
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"clean": "rimraf public/generated-js"
},
"dependencies": {
"anchorme": "2.1.2",
"ts-polyfill": "3.8.2"
},
"devDependencies": {
Expand Down
18 changes: 18 additions & 0 deletions typescript/src/anchorme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import anchorme from "anchorme"
import {Options} from "anchorme/dist/node/types";

const options: Partial<Options> = {
attributes: {
target: "_blank",
rel: "nofollow noreferrer noopener"
},
}

const descriptions: HTMLCollectionOf<HTMLElement> = document.getElementsByClassName("application__message") as HTMLCollectionOf<HTMLElement>

Array.from(descriptions).forEach((description) => {
const content: string | null = description.innerText ? anchorme({input: description.innerText, options}) : null
if (content) {
description.innerHTML = content
}
});
3 changes: 2 additions & 1 deletion typescript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ import 'core-js/web/dom-collections';
// Our scripts
import "./admin.ts"
import "./mdl-extensions.ts"
import "./application-attachment"
import "./validateAccount"
import "./application-attachment"
import "./anchorme"

0 comments on commit 3a7d3ef

Please sign in to comment.