mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-14 14:24:24 +00:00
Rendre les commentaire markdown
This commit is contained in:
parent
821fce3dd8
commit
d6f5eae0c9
@ -18,8 +18,6 @@
|
|||||||
v-model="content"
|
v-model="content"
|
||||||
tag-name="textarea">
|
tag-name="textarea">
|
||||||
</ckeditor>
|
</ckeditor>
|
||||||
<!-- <textarea v-model="content" class="form-control" id="content" rows="3"
|
|
||||||
:placeholder="$t('comment.label')"></textarea> -->
|
|
||||||
|
|
||||||
<div class="d-flex justify-content-end p-2">
|
<div class="d-flex justify-content-end p-2">
|
||||||
<button class="btn btn-chill-green text-white float-right" type="submit">
|
<button class="btn btn-chill-green text-white float-right" type="submit">
|
||||||
|
@ -2,28 +2,66 @@
|
|||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<i class="fa fa-comment"></i>
|
<i class="fa fa-comment"></i>
|
||||||
<span class="mx-1">
|
<span class="mx-1">
|
||||||
{{ $t('history.comment',{ comment: commentHistory.content}) }}
|
{{ $t("history.comment") }}
|
||||||
</span>
|
</span>
|
||||||
|
<div class="mt-2">
|
||||||
|
<div v-html="convertMarkdownToHtml(commentHistory.content)"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { PropType, defineComponent } from "vue";
|
||||||
import { PropType, defineComponent } from 'vue';
|
import { marked } from "marked";
|
||||||
|
import DOMPurify from "dompurify";
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import { Comment } from '../../../types';
|
import { Comment } from "../../../types";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'TicketHistoryCommentComponent',
|
name: "TicketHistoryCommentComponent",
|
||||||
props: {
|
props: {
|
||||||
commentHistory: {
|
commentHistory: {
|
||||||
type: Object as PropType<Comment>,
|
type: Object as PropType<Comment>,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup() {}
|
setup() {
|
||||||
|
|
||||||
|
const preprocess = (markdown: string): string => {
|
||||||
|
return markdown;
|
||||||
|
};
|
||||||
|
|
||||||
|
const postprocess = (html: string): string => {
|
||||||
|
DOMPurify.addHook("afterSanitizeAttributes", (node: any) => {
|
||||||
|
if ("target" in node) {
|
||||||
|
node.setAttribute("target", "_blank");
|
||||||
|
node.setAttribute("rel", "noopener noreferrer");
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
!node.hasAttribute("target") &&
|
||||||
|
(node.hasAttribute("xlink:href") ||
|
||||||
|
node.hasAttribute("href"))
|
||||||
|
) {
|
||||||
|
node.setAttribute("xlink:show", "new");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return DOMPurify.sanitize(html);
|
||||||
|
};
|
||||||
|
|
||||||
|
const convertMarkdownToHtml = (markdown: string): string => {
|
||||||
|
marked.use({ hooks: { postprocess, preprocess } });
|
||||||
|
const rawHtml = marked(markdown) as string;
|
||||||
|
return rawHtml;
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
convertMarkdownToHtml,
|
||||||
|
};
|
||||||
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
<style lang="scss" scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user