src_js/iconolab-bundle/src/components/editor/Comment.vue
author duong tam kien <tk@deveha.com>
Fri, 24 Feb 2017 17:47:45 +0100
changeset 391 7ab1cc12827e
parent 323 55c024fc7c60
child 396 0a4743126d74
permissions -rw-r--r--
adds handling of rich text (markdown)

<template>
    <div class="comment">
        <div class="comment-body" v-html="commentFormatted"></div>
        <div class="comment-footer">
            <span class="comment-author">{{ username }}</span>
            <span class="comment-date">{{ dateFormatted }}</span>
        </div>
    </div>
</template>

<script>

    import showdown from 'showdown'

    const converter = new showdown.Converter()

    export default {
        props: [
            'comment',
            'username',
            'email',
            'date'
        ],
        computed: {
            dateFormatted: function () {

                var date = new Date(this.date);

                var day = date.getDate();
                var month = date.getMonth() + 1;
                var year = date.getFullYear();

                return day + '/' + month + '/' + year;
            },
            commentFormatted: function(){
              return converter.makeHtml(this.comment);
            }
        }
    }

</script>

<style scoped>
.comment {
    font-size: 12px;
    padding: 5px 0;
    border-bottom: 1px solid #ccc;
}
.comment-footer {
    margin-top: 5px;
    color: #ccc;
}
.comment-date {
    float: right;
}
</style>