aboutsummaryrefslogtreecommitdiffstats
path: root/apps/comments/src/components/Comment.vue
diff options
context:
space:
mode:
authorMaksim Sukharev <antreesy.web@gmail.com>2025-03-04 19:09:46 +0100
committerMaksim Sukharev <antreesy.web@gmail.com>2025-03-05 09:11:58 +0100
commit1cc7a462427c769ceba07dd6ceac630fe0452d0a (patch)
tree92ad10e385fddaa448cc565e0a3661f92717fde5 /apps/comments/src/components/Comment.vue
parenta4760ef906ba897f19669898466bdb5c48703ec0 (diff)
downloadnextcloud-server-1cc7a462427c769ceba07dd6ceac630fe0452d0a.tar.gz
nextcloud-server-1cc7a462427c769ceba07dd6ceac630fe0452d0a.zip
fix(Comment): replace richEditor mixin with NcRichText
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
Diffstat (limited to 'apps/comments/src/components/Comment.vue')
-rw-r--r--apps/comments/src/components/Comment.vue51
1 files changed, 32 insertions, 19 deletions
diff --git a/apps/comments/src/components/Comment.vue b/apps/comments/src/components/Comment.vue
index 42ef3d3e499..fb08778b9d2 100644
--- a/apps/comments/src/components/Comment.vue
+++ b/apps/comments/src/components/Comment.vue
@@ -90,14 +90,12 @@
</form>
<!-- Message content -->
- <!-- The html is escaped and sanitized before rendering -->
- <!-- eslint-disable vue/no-v-html-->
- <div v-else
- :class="{'comment__message--expanded': expanded}"
+ <NcRichText v-else
class="comment__message"
- @click="onExpand"
- v-html="renderedContent" />
- <!-- eslint-enable vue/no-v-html-->
+ :class="{'comment__message--expanded': expanded}"
+ :text="richContent.message"
+ :arguments="richContent.mentions"
+ @click="onExpand" />
</div>
</component>
</template>
@@ -113,7 +111,7 @@ import NcAvatar from '@nextcloud/vue/components/NcAvatar'
import NcButton from '@nextcloud/vue/components/NcButton'
import NcDateTime from '@nextcloud/vue/components/NcDateTime'
import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon'
-import RichEditorMixin from '@nextcloud/vue/dist/Mixins/richEditor.js'
+import NcUserBubble from '@nextcloud/vue/components/NcUserBubble'
import IconArrowRight from 'vue-material-design-icons/ArrowRight.vue'
import IconClose from 'vue-material-design-icons/Close.vue'
@@ -126,6 +124,7 @@ import { useDeletedCommentLimbo } from '../store/deletedCommentLimbo.js'
// Dynamic loading
const NcRichContenteditable = () => import('@nextcloud/vue/components/NcRichContenteditable')
+const NcRichText = () => import('@nextcloud/vue/components/NcRichText')
export default {
name: 'Comment',
@@ -143,8 +142,9 @@ export default {
NcDateTime,
NcLoadingIcon,
NcRichContenteditable,
+ NcRichText,
},
- mixins: [RichEditorMixin, CommentMixin],
+ mixins: [CommentMixin],
inheritAttrs: false,
@@ -177,6 +177,10 @@ export default {
type: Function,
required: true,
},
+ userData: {
+ type: Object,
+ default: () => ({}),
+ },
tag: {
type: String,
@@ -206,16 +210,25 @@ export default {
return getCurrentUser().uid === this.actorId
},
- /**
- * Rendered content as html string
- *
- * @return {string}
- */
- renderedContent() {
- if (this.isEmptyMessage) {
- return ''
- }
- return this.renderContent(this.localMessage)
+ richContent() {
+ const mentions = {}
+ let message = this.localMessage
+
+ Object.keys(this.userData).forEach((user, index) => {
+ const key = `mention-${index}`
+ const regex = new RegExp(`@${user}|@"${user}"`, 'g')
+ message = message.replace(regex, `{${key}}`)
+ mentions[key] = {
+ component: NcUserBubble,
+ props: {
+ user,
+ displayName: this.userData[user].label,
+ primary: this.userData[user].primary,
+ },
+ }
+ })
+
+ return { mentions, message }
},
isEmptyMessage() {