93 lines
2.3 KiB
Vue
93 lines
2.3 KiB
Vue
<script setup>
|
|
import { defineProps, onMounted, ref } from "vue";
|
|
import { decodeEmojis } from "../../utils/string";
|
|
import DOMPurify from 'dompurify';
|
|
|
|
const props = defineProps({ data: Object });
|
|
const date = new Date(props.data.date);
|
|
|
|
const iframe = ref(null);
|
|
|
|
onMounted(() => {
|
|
const doc = iframe.value.contentDocument || iframe.value.contentWindow.document;
|
|
const html = DOMPurify.sanitize(props.data.content);
|
|
doc.open();
|
|
// todo dompurify
|
|
// background vs color
|
|
doc.write(`
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Document</title>
|
|
</head>
|
|
<body style="margin: 0;">
|
|
${html}
|
|
</body>
|
|
</html>
|
|
`);
|
|
doc.close();
|
|
});
|
|
</script>
|
|
<!-- to if to is more than me
|
|
cc -->
|
|
<!-- object (channel only)
|
|
content
|
|
attachments -->
|
|
<template>
|
|
<div class="message">
|
|
<div id="context">
|
|
<div class="left" id="profile">Carrefour@emailing .carrefor.fr "carrefour"</div>
|
|
<div class="middle">{{ decodeEmojis(props.data.subject) }}</div>
|
|
<div class="right" id="date">
|
|
{{
|
|
date.toLocaleString("en-GB", {
|
|
weekday: "short",
|
|
year: "numeric",
|
|
month: "2-digit",
|
|
day: "2-digit",
|
|
hour: "2-digit",
|
|
minute: "2-digit",
|
|
timezone: "UTC+1",
|
|
})
|
|
}}
|
|
</div>
|
|
</div>
|
|
<iframe ref="iframe"></iframe>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.message {
|
|
width: auto;
|
|
border: white 1px solid;
|
|
padding: 10px;
|
|
margin: 5px;
|
|
}
|
|
|
|
#context {
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: space-between;
|
|
}
|
|
|
|
iframe {
|
|
overflow-y: auto;
|
|
max-height: 300px;
|
|
width: 100%;
|
|
max-width: 750px; /* template width being 600px to 640px up to 750px (experiment and test) */
|
|
}
|
|
|
|
.left,
|
|
.right {
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.middle {
|
|
margin: 0 10px;
|
|
text-align: center;
|
|
}
|
|
</style>
|