Files
homebox/frontend/components/global/Markdown.vue
Tonya f16ad427eb Fix small bugs in UI (#786)
* chore: added `rel="noopener noreferrer"` to external links for improved security on homepage

* fix: reused variable name

* feat: make the item table use a link instead of a click event

* fix: pagination now shows correct page if loading page that isnt 1

* fix: make save button sticky again on item edit page

* fix: adjust sticky header positioning based on whether legacy header is enabled

* fix: navigate to homepage on unauthorized request in useUserApi function

* fix: enhance link handling in DetailsSection

* fix: improve markdown rendering, don't add big breaks between lines, make the gap smaller and dont have a trailing newline

* fix: use secondary colour as switch secondary colour so its more visible against bg

* fix: call refresh methods on location and label stores during component mount for better data consistency

* fix: loading indicators

* fix: convert detail.text to string for correct URL handling in DetailsSection component

* fix: use replace instead of splice to remove newline at end of markdown

* fix: use css vars for header height
2025-06-13 09:29:33 +01:00

41 lines
1.1 KiB
Vue

<script setup lang="ts">
import MarkdownIt from "markdown-it";
import DOMPurify from "dompurify";
type Props = {
source: string | null | undefined;
};
const props = withDefaults(defineProps<Props>(), {
source: null,
});
const md = new MarkdownIt({
html: true,
linkify: true,
typographer: true,
});
const raw = computed(() => {
const html = md.render(props.source || "").replace(/\n$/, ""); // remove trailing newline
return DOMPurify.sanitize(html);
});
</script>
<template>
<!-- eslint-disable-next-line vue/no-v-html -->
<div class="markdown text-wrap break-words" v-html="raw"></div>
</template>
<style scoped>
* {
word-wrap: break-word; /*Fix for long words going out of emelent bounds and issue #407 */
overflow-wrap: break-word; /*Fix for long words going out of emelent bounds and issue #407 */
white-space: pre-wrap; /*Fix for long words going out of emelent bounds and issue #407 */
}
.markdown {
max-width: 100%;
overflow: hidden; /*Fix for long words going out of emelent bounds and issue #407 */
}
</style>