<template>
    <view class="tx c-inline">
        <text
            v-for="(text, i) in list"
            :key="i"
            :class="list.length > 1 ? 'c-block' : 'c-inline'"
            selectable
        >
            {{ text }}
        </text>
    </view>
</template>

<script>
/**
 * @file components/im/im-text
 * @author haoyan
 */
export default {
    config: {
        component: true
    },
    props: {
        item: {
            'type': Object,
            'default': {}
        }
    },
    data() {
        return {
            list: []
        };
    },
    lifetimes: {
        attached() {
            // 兼容换行
            const content = this.item.text;
            this.list = content.split(/\n/);
        }
    }
};
</script>

<style lang="less">
.c-block {
    display: block;
    min-height: 21px;
}

.tx {
    word-break: break-all;
}
</style>
