kopia lustrzana https://github.com/nextcloud/social
Uses hashtag-regex to rewrite hashtag's href rather than linkifyjs.
Reason: linkifyjs doesn't support non-latin characters. So "#Framasphère" is identified as "#Framasph" for example. Signed-off-by: Cyrille Bollu <cyrpub@bollu.be>pull/661/head
rodzic
e64c1b5244
commit
18862db660
|
@ -28,6 +28,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"vue-masonry-css": "^1.0.3",
|
||||
"hashtag-regex": "^2.0.0",
|
||||
"linkifyjs": "^2.1.8",
|
||||
"nextcloud-axios": "^0.2.0",
|
||||
"nextcloud-vue": "^0.11.4",
|
||||
|
|
|
@ -52,16 +52,16 @@
|
|||
<script>
|
||||
import Avatar from 'nextcloud-vue/dist/Components/Avatar'
|
||||
import * as linkify from 'linkifyjs'
|
||||
import pluginTag from 'linkifyjs/plugins/hashtag'
|
||||
import pluginMention from 'linkifyjs/plugins/mention'
|
||||
import 'linkifyjs/string'
|
||||
import popoverMenu from './../mixins/popoverMenu'
|
||||
import currentUser from './../mixins/currentUserMixin'
|
||||
import PostAttachment from './PostAttachment'
|
||||
|
||||
pluginTag(linkify)
|
||||
pluginMention(linkify)
|
||||
|
||||
const hashtagRegex = require('hashtag-regex')
|
||||
|
||||
export default {
|
||||
name: 'TimelinePost',
|
||||
components: {
|
||||
|
@ -109,14 +109,17 @@ export default {
|
|||
message = message.replace(/(?:\r\n|\r|\n)/g, '<br />')
|
||||
message = message.linkify({
|
||||
formatHref: {
|
||||
hashtag: function(href) {
|
||||
return OC.generateUrl('/apps/social/timeline/tags/' + href.substring(1))
|
||||
},
|
||||
mention: function(href) {
|
||||
return OC.generateUrl('/apps/social/@' + href.substring(1))
|
||||
}
|
||||
}
|
||||
})
|
||||
// Replace hashtag's href parameter with local ones
|
||||
const regex = hashtagRegex()
|
||||
message = message.replace(regex, function(matched) {
|
||||
var a = '<a href="' + OC.generateUrl('/apps/social/timeline/tags/' + matched.substring(1)) + '">' + matched + '</a>'
|
||||
return a
|
||||
})
|
||||
message = this.$twemoji.parse(message)
|
||||
return message
|
||||
},
|
||||
|
|
Ładowanie…
Reference in New Issue