Skip to content

Commit

Permalink
Add markup logic for clickable links etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
annemerete committed Aug 29, 2023
1 parent e156f46 commit add3c21
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/components/HTMLOutput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export default {
deep: true,
immediate: true,
async handler(html) {
dompurify.addHook('afterSanitizeAttributes', function (node) {
// set all elements owning target to target=_blank
if ('target' in node) {
node.setAttribute('target', '_blank');
}
});
this.sanitizedHtml = await dompurify.sanitize(marked(html));
},
},
Expand Down
3 changes: 2 additions & 1 deletion src/components/KpiDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{{ $t('kpi.newValue') }}
</pkt-button>
</div>
<p v-if="kpi.description" class="pkt-txt-14-light">{{ kpi.description }}</p>
<HTML-output v-if="kpi.description" class="pkt-txt-14-light" :html="kpi.description" />
</header>

<widget-kpi-progress-graph :kpi="kpi" :progress="progress" :goals="goals" />
Expand Down Expand Up @@ -55,6 +55,7 @@ export default {
components: {
PktButton,
ProgressModal: () => import('@/components/modals/KPIProgressModal.vue'),
HTMLOutput: () => import('@/components/HTMLOutput.vue'),
WidgetKpiProgressGraph,
WidgetKpiProgressHistory,
WidgetKpiProgressStats,
Expand Down
5 changes: 2 additions & 3 deletions src/views/KeyResultHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
/>
</div>
</div>
<p v-if="activeKeyResult.description" class="description">
{{ activeKeyResult.description }}
</p>
<HTML-output v-if="activeKeyResult.description" :html="activeKeyResult.description" />
</header>

<archived-restore
Expand Down Expand Up @@ -144,6 +142,7 @@ export default {
PktButton,
KeyResultDrawer: () => import('@/components/drawers/EditKeyResult.vue'),
ArchivedRestore: () => import('@/components/ArchivedRestore.vue'),
HTMLOutput: () => import('@/components/HTMLOutput.vue'),
},
beforeRouteUpdate: routerGuard,
Expand Down
6 changes: 3 additions & 3 deletions src/views/ObjectiveHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
</div>
</div>
<div class="objective__description">
<p v-if="activeObjective.description" class="description">
{{ activeObjective.description }}
</p>
<HTML-output v-if="activeObjective.description" :html="activeObjective.description" />
<div
v-if="hasEditRights && !activeObjective.archived"
data-mode="dark"
Expand Down Expand Up @@ -93,6 +91,7 @@ import WidgetObjectiveDetails from '@/components/widgets/WidgetObjectiveDetails.
import WidgetWeights from '@/components/widgets/WidgetWeights.vue';
import ProgressionChart from '@/components/ProgressionChart.vue';
import { PktButton } from '@oslokommune/punkt-vue2';
import HTMLOutput from '@/components/HTMLOutput.vue';
export default {
name: 'ObjectiveHome',
Expand All @@ -105,6 +104,7 @@ export default {
WidgetObjectiveDetails,
ProgressionChart,
PktButton,
HTMLOutput,
ObjectiveDrawer: () => import('@/components/drawers/EditObjective.vue'),
KeyResultDrawer: () => import('@/components/drawers/EditKeyResult.vue'),
ArchivedRestore: () => import('@/components/ArchivedRestore.vue'),
Expand Down

0 comments on commit add3c21

Please sign in to comment.