@conduction/nextcloud-vue 2.186.0 → 2.187.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components/CnChartWidget/CnChartWidget.vue.js +1 -1
- package/dist/esm/components/CnChartWidget/CnChartWidget2.vue.js +58 -0
- package/dist/esm/components/CnChartWidget/CnChartWidget2.vue.js.map +1 -1
- package/dist/esm/components/CnChartWidget/CnChartWidget3.vue.js +2 -2
- package/dist/esm/components/CnChartWidget/CnChartWidget3.vue.js.map +1 -1
- package/dist/esm/components/CnPeopleWidget/CnPeopleWidget.vue.js +1 -1
- package/dist/esm/components/CnPeopleWidget/CnPeopleWidget2.vue.js +281 -27
- package/dist/esm/components/CnPeopleWidget/CnPeopleWidget2.vue.js.map +1 -1
- package/dist/esm/components/CnPeopleWidget/CnPeopleWidget3.vue.js +86 -33
- package/dist/esm/components/CnPeopleWidget/CnPeopleWidget3.vue.js.map +1 -1
- package/dist/esm/components/CnPeopleWidget/peopleCache.js +76 -0
- package/dist/esm/components/CnPeopleWidget/peopleCache.js.map +1 -0
- package/dist/esm/components/CnPeopleWidgetForm/CnPeopleWidgetForm.vue.js +1 -1
- package/dist/esm/components/CnPeopleWidgetForm/CnPeopleWidgetForm2.vue.js +40 -9
- package/dist/esm/components/CnPeopleWidgetForm/CnPeopleWidgetForm2.vue.js.map +1 -1
- package/dist/esm/components/CnPeopleWidgetForm/CnPeopleWidgetForm3.vue.js +35 -26
- package/dist/esm/components/CnPeopleWidgetForm/CnPeopleWidgetForm3.vue.js.map +1 -1
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue.js +1 -1
- package/dist/esm/components/CnTextWidget/CnTextWidget2.vue.js +32 -12
- package/dist/esm/components/CnTextWidget/CnTextWidget2.vue.js.map +1 -1
- package/dist/esm/components/CnTextWidget/CnTextWidget3.vue.js.map +1 -1
- package/dist/esm/l10n/nl.json.js +4 -0
- package/dist/esm/l10n/nl.json.js.map +1 -1
- package/dist/esm/library-style.js +1 -1
- package/dist/esm/nextcloud-vue.css +206 -150
- package/dist/nextcloud-vue.cjs.js +1366 -864
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/dist/nextcloud-vue.css +206 -150
- package/l10n/nl.json +4 -0
- package/package.json +1 -1
- package/src/components/CnChartWidget/CnChartWidget.vue +60 -2
- package/src/components/CnPeopleWidget/CnPeopleWidget.vue +402 -56
- package/src/components/CnPeopleWidget/peopleCache.js +73 -0
- package/src/components/CnPeopleWidgetForm/CnPeopleWidgetForm.vue +45 -11
- package/src/components/CnTextWidget/CnTextWidget.vue +32 -12
|
@@ -1,26 +1,32 @@
|
|
|
1
|
-
import { resolveComponent, openBlock, createElementBlock, createVNode,
|
|
1
|
+
import { resolveComponent, openBlock, createElementBlock, createVNode, toDisplayString, createCommentVNode, createElementVNode, createTextVNode } from 'vue';
|
|
2
2
|
|
|
3
3
|
const _hoisted_1 = { class: "cn-people-widget-form" };
|
|
4
|
-
const _hoisted_2 = {
|
|
5
|
-
const _hoisted_3 = ["value", "placeholder"];
|
|
6
|
-
const _hoisted_4 = { class: "cn-people-widget-form__field cn-people-widget-form__field--inline" };
|
|
7
|
-
const _hoisted_5 = ["checked"];
|
|
8
|
-
const _hoisted_6 = { class: "cn-people-widget-form__field cn-people-widget-form__field--inline" };
|
|
9
|
-
const _hoisted_7 = ["checked"];
|
|
10
|
-
const _hoisted_8 = {
|
|
4
|
+
const _hoisted_2 = {
|
|
11
5
|
key: 0,
|
|
6
|
+
class: "cn-people-widget-form__error",
|
|
7
|
+
role: "alert"
|
|
8
|
+
};
|
|
9
|
+
const _hoisted_3 = { class: "cn-people-widget-form__field" };
|
|
10
|
+
const _hoisted_4 = ["value", "placeholder"];
|
|
11
|
+
const _hoisted_5 = { class: "cn-people-widget-form__field cn-people-widget-form__field--inline" };
|
|
12
|
+
const _hoisted_6 = ["checked"];
|
|
13
|
+
const _hoisted_7 = { class: "cn-people-widget-form__field cn-people-widget-form__field--inline" };
|
|
14
|
+
const _hoisted_8 = ["checked"];
|
|
15
|
+
const _hoisted_9 = {
|
|
16
|
+
key: 1,
|
|
12
17
|
class: "cn-people-widget-form__field"
|
|
13
18
|
};
|
|
14
|
-
const
|
|
15
|
-
const
|
|
19
|
+
const _hoisted_10 = ["value"];
|
|
20
|
+
const _hoisted_11 = {
|
|
16
21
|
key: 0,
|
|
17
|
-
class: "cn-people-widget-form__error"
|
|
22
|
+
class: "cn-people-widget-form__error",
|
|
23
|
+
role: "alert"
|
|
18
24
|
};
|
|
19
|
-
const
|
|
20
|
-
key:
|
|
25
|
+
const _hoisted_12 = {
|
|
26
|
+
key: 2,
|
|
21
27
|
class: "cn-people-widget-form__field"
|
|
22
28
|
};
|
|
23
|
-
const
|
|
29
|
+
const _hoisted_13 = ["value"];
|
|
24
30
|
|
|
25
31
|
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
26
32
|
const _component_NcSelect = resolveComponent("NcSelect");
|
|
@@ -42,9 +48,12 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
42
48
|
reduce: (option) => option.value,
|
|
43
49
|
label: "label",
|
|
44
50
|
clearable: false,
|
|
45
|
-
"onUpdate:modelValue": _cache[1] || (_cache[1] = $event => ($options.
|
|
51
|
+
"onUpdate:modelValue": _cache[1] || (_cache[1] = $event => ($options.updateSortBy($event)))
|
|
46
52
|
}, null, 8 /* PROPS */, ["modelValue", "options", "inputLabel", "reduce"]),
|
|
47
|
-
|
|
53
|
+
($data.sortByError)
|
|
54
|
+
? (openBlock(), createElementBlock("p", _hoisted_2, toDisplayString($data.sortByError), 1 /* TEXT */))
|
|
55
|
+
: createCommentVNode("v-if", true),
|
|
56
|
+
createElementVNode("label", _hoisted_3, [
|
|
48
57
|
createTextVNode(toDisplayString($options.t('nextcloud-vue', 'Group filter (comma-separated, blank for all)')) + " ", 1 /* TEXT */),
|
|
49
58
|
createElementVNode("input", {
|
|
50
59
|
type: "text",
|
|
@@ -52,26 +61,26 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
52
61
|
value: $options.groupFilterText,
|
|
53
62
|
placeholder: $options.t('nextcloud-vue', 'e.g. management, product'),
|
|
54
63
|
onInput: _cache[2] || (_cache[2] = $event => ($options.updateGroupFilter($event.target.value)))
|
|
55
|
-
}, null, 40 /* PROPS, NEED_HYDRATION */,
|
|
64
|
+
}, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_4)
|
|
56
65
|
]),
|
|
57
|
-
createElementVNode("label",
|
|
66
|
+
createElementVNode("label", _hoisted_5, [
|
|
58
67
|
createElementVNode("input", {
|
|
59
68
|
type: "checkbox",
|
|
60
69
|
checked: $data.excludeDisabled,
|
|
61
70
|
onChange: _cache[3] || (_cache[3] = $event => ($options.updateField('excludeDisabled', $event.target.checked)))
|
|
62
|
-
}, null, 40 /* PROPS, NEED_HYDRATION */,
|
|
71
|
+
}, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_6),
|
|
63
72
|
createTextVNode(" " + toDisplayString($options.t('nextcloud-vue', 'Exclude disabled users')), 1 /* TEXT */)
|
|
64
73
|
]),
|
|
65
|
-
createElementVNode("label",
|
|
74
|
+
createElementVNode("label", _hoisted_7, [
|
|
66
75
|
createElementVNode("input", {
|
|
67
76
|
type: "checkbox",
|
|
68
77
|
checked: $data.showBirthdays,
|
|
69
78
|
onChange: _cache[4] || (_cache[4] = $event => ($options.updateField('showBirthdays', $event.target.checked)))
|
|
70
|
-
}, null, 40 /* PROPS, NEED_HYDRATION */,
|
|
79
|
+
}, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_8),
|
|
71
80
|
createTextVNode(" " + toDisplayString($options.t('nextcloud-vue', 'Show birthdays')), 1 /* TEXT */)
|
|
72
81
|
]),
|
|
73
82
|
($data.showBirthdays)
|
|
74
|
-
? (openBlock(), createElementBlock("label",
|
|
83
|
+
? (openBlock(), createElementBlock("label", _hoisted_9, [
|
|
75
84
|
createTextVNode(toDisplayString($options.t('nextcloud-vue', 'Birthday window (days, 0–30)')) + " ", 1 /* TEXT */),
|
|
76
85
|
createElementVNode("input", {
|
|
77
86
|
type: "number",
|
|
@@ -80,14 +89,14 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
80
89
|
max: "30",
|
|
81
90
|
value: $data.birthdayWindowDays,
|
|
82
91
|
onInput: _cache[5] || (_cache[5] = $event => ($options.updateBirthdayWindow($event.target.value)))
|
|
83
|
-
}, null, 40 /* PROPS, NEED_HYDRATION */,
|
|
92
|
+
}, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_10),
|
|
84
93
|
($data.birthdayWindowError)
|
|
85
|
-
? (openBlock(), createElementBlock("span",
|
|
94
|
+
? (openBlock(), createElementBlock("span", _hoisted_11, toDisplayString($data.birthdayWindowError), 1 /* TEXT */))
|
|
86
95
|
: createCommentVNode("v-if", true)
|
|
87
96
|
]))
|
|
88
97
|
: createCommentVNode("v-if", true),
|
|
89
98
|
($data.layout !== 'list')
|
|
90
|
-
? (openBlock(), createElementBlock("label",
|
|
99
|
+
? (openBlock(), createElementBlock("label", _hoisted_12, [
|
|
91
100
|
createTextVNode(toDisplayString($options.t('nextcloud-vue', 'Columns')) + " ", 1 /* TEXT */),
|
|
92
101
|
createElementVNode("select", {
|
|
93
102
|
value: $data.columns,
|
|
@@ -97,7 +106,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
97
106
|
createElementVNode("option", { value: 2 }, " 2 ", -1 /* CACHED */),
|
|
98
107
|
createElementVNode("option", { value: 3 }, " 3 ", -1 /* CACHED */),
|
|
99
108
|
createElementVNode("option", { value: 4 }, " 4 ", -1 /* CACHED */)
|
|
100
|
-
]))], 40 /* PROPS, NEED_HYDRATION */,
|
|
109
|
+
]))], 40 /* PROPS, NEED_HYDRATION */, _hoisted_13)
|
|
101
110
|
]))
|
|
102
111
|
: createCommentVNode("v-if", true)
|
|
103
112
|
]))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CnPeopleWidgetForm3.vue.js","sources":["../../../../src/components/CnPeopleWidgetForm/CnPeopleWidgetForm.vue?vue&type=template&id=53a2b86c&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div class=\"cn-people-widget-form\">\n\t\t<NcSelect\n\t\t\t:modelValue=\"layout\"\n\t\t\t:options=\"layoutOptions\"\n\t\t\t:inputLabel=\"t('nextcloud-vue', 'Layout')\"\n\t\t\t:reduce=\"(option) => option.value\"\n\t\t\tlabel=\"label\"\n\t\t\t:clearable=\"false\"\n\t\t\t@update:modelValue=\"updateField('layout', $event)\" />\n\n\t\t<NcSelect\n\t\t\t:modelValue=\"sortBy\"\n\t\t\t:options=\"sortByOptions\"\n\t\t\t:inputLabel=\"t('nextcloud-vue', 'Sort by')\"\n\t\t\t:reduce=\"(option) => option.value\"\n\t\t\tlabel=\"label\"\n\t\t\t:clearable=\"false\"\n\t\t\t@update:modelValue=\"updateField('sortBy', $event)\" />\n\n\t\t<label class=\"cn-people-widget-form__field\">\n\t\t\t{{ t('nextcloud-vue', 'Group filter (comma-separated, blank for all)') }}\n\t\t\t<input\n\t\t\t\ttype=\"text\"\n\t\t\t\tclass=\"cn-people-widget-form__input\"\n\t\t\t\t:value=\"groupFilterText\"\n\t\t\t\t:placeholder=\"t('nextcloud-vue', 'e.g. management, product')\"\n\t\t\t\t@input=\"updateGroupFilter($event.target.value)\">\n\t\t</label>\n\n\t\t<label class=\"cn-people-widget-form__field cn-people-widget-form__field--inline\">\n\t\t\t<input\n\t\t\t\ttype=\"checkbox\"\n\t\t\t\t:checked=\"excludeDisabled\"\n\t\t\t\t@change=\"updateField('excludeDisabled', $event.target.checked)\">\n\t\t\t{{ t('nextcloud-vue', 'Exclude disabled users') }}\n\t\t</label>\n\n\t\t<label class=\"cn-people-widget-form__field cn-people-widget-form__field--inline\">\n\t\t\t<input\n\t\t\t\ttype=\"checkbox\"\n\t\t\t\t:checked=\"showBirthdays\"\n\t\t\t\t@change=\"updateField('showBirthdays', $event.target.checked)\">\n\t\t\t{{ t('nextcloud-vue', 'Show birthdays') }}\n\t\t</label>\n\n\t\t<label v-if=\"showBirthdays\" class=\"cn-people-widget-form__field\">\n\t\t\t{{ t('nextcloud-vue', 'Birthday window (days, 0–30)') }}\n\t\t\t<input\n\t\t\t\ttype=\"number\"\n\t\t\t\tclass=\"cn-people-widget-form__input\"\n\t\t\t\tmin=\"0\"\n\t\t\t\tmax=\"30\"\n\t\t\t\t:value=\"birthdayWindowDays\"\n\t\t\t\t@input=\"updateBirthdayWindow($event.target.value)\">\n\t\t\t<span v-if=\"birthdayWindowError\" class=\"cn-people-widget-form__error\">\n\t\t\t\t{{ birthdayWindowError }}\n\t\t\t</span>\n\t\t</label>\n\n\t\t<label v-if=\"layout !== 'list'\" class=\"cn-people-widget-form__field\">\n\t\t\t{{ t('nextcloud-vue', 'Columns') }}\n\t\t\t<select\n\t\t\t\t:value=\"columns\"\n\t\t\t\tclass=\"cn-people-widget-form__input\"\n\t\t\t\t@change=\"updateField('columns', Number($event.target.value))\">\n\t\t\t\t<option :value=\"2\">\n\t\t\t\t\t2\n\t\t\t\t</option>\n\t\t\t\t<option :value=\"3\">\n\t\t\t\t\t3\n\t\t\t\t</option>\n\t\t\t\t<option :value=\"4\">\n\t\t\t\t\t4\n\t\t\t\t</option>\n\t\t\t</select>\n\t\t</label>\n\t</div>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcSelect } from '@nextcloud/vue'\n\nconst DEFAULT_CONTENT = Object.freeze({\n\tlayout: 'grid',\n\tselectionMode: 'filter',\n\tselectedUsers: [],\n\tfilters: [],\n\tfilterOperator: 'AND',\n\texcludeDisabled: true,\n\tshowBirthdays: true,\n\tbirthdayWindowDays: 7,\n\tsortBy: 'displayName',\n\tcolumns: 3,\n\tshowFields: {\n\t\tdisplayName: true,\n\t\trole: true,\n\t\torganisation: true,\n\t\temail: true,\n\t\tphone: true,\n\t\tavatar: true,\n\t\tbirthdate: true,\n\t},\n})\n\n/**\n * CnPeopleWidgetForm — the `CnAddWidgetModal` sub-form for creating or editing\n * a `people` widget placement. Exposes layout, sort, group filter, exclude\n * disabled, show birthdays + window, and columns; less common keys\n * (selectionMode, selectedUsers, filterOperator, showFields) travel through\n * untouched from their defaults. Group filter persists as the canonical\n * `[{fieldName:'group', operator:'in', values:[...]}]` shape. Emits\n * `update:content` on change and exposes `validate()` (birthday window 0..30).\n */\nexport default {\n\tname: 'CnPeopleWidgetForm',\n\n\tcomponents: {\n\t\tNcSelect,\n\t},\n\n\tprops: {\n\t\t/** The placement being edited, or `null` in create mode. */\n\t\teditingWidget: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** Initial content values when not editing (registry defaults). */\n\t\tvalue: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({ ...DEFAULT_CONTENT }),\n\t\t},\n\t},\n\n\temits: [\n\t\t/**\n\t\t * Emitted with the assembled content blob on every change.\n\t\t *\n\t\t * @event update:content\n\t\t * @type {object}\n\t\t */\n\t\t'update:content',\n\t],\n\n\tdata() {\n\t\tconst initial = this.editingWidget?.content || this.value || {}\n\t\tconst groupFilter = (initial.filters || [])\n\t\t\t.find((f) => f && f.fieldName === 'group')\n\t\treturn {\n\t\t\tlayout: initial.layout ?? DEFAULT_CONTENT.layout,\n\t\t\tselectionMode: initial.selectionMode ?? DEFAULT_CONTENT.selectionMode,\n\t\t\tselectedUsers: Array.isArray(initial.selectedUsers)\n\t\t\t\t? [...initial.selectedUsers]\n\t\t\t\t: [...DEFAULT_CONTENT.selectedUsers],\n\n\t\t\tfilterOperator: initial.filterOperator ?? DEFAULT_CONTENT.filterOperator,\n\t\t\texcludeDisabled: typeof initial.excludeDisabled === 'boolean'\n\t\t\t\t? initial.excludeDisabled\n\t\t\t\t: DEFAULT_CONTENT.excludeDisabled,\n\n\t\t\tshowBirthdays: typeof initial.showBirthdays === 'boolean'\n\t\t\t\t? initial.showBirthdays\n\t\t\t\t: DEFAULT_CONTENT.showBirthdays,\n\n\t\t\tbirthdayWindowDays: typeof initial.birthdayWindowDays === 'number'\n\t\t\t\t? initial.birthdayWindowDays\n\t\t\t\t: DEFAULT_CONTENT.birthdayWindowDays,\n\n\t\t\tsortBy: initial.sortBy ?? DEFAULT_CONTENT.sortBy,\n\t\t\tcolumns: typeof initial.columns === 'number'\n\t\t\t\t? initial.columns\n\t\t\t\t: DEFAULT_CONTENT.columns,\n\n\t\t\tshowFields: { ...DEFAULT_CONTENT.showFields, ...(initial.showFields || {}) },\n\t\t\tgroupFilterValues: groupFilter && Array.isArray(groupFilter.values)\n\t\t\t\t? [...groupFilter.values]\n\t\t\t\t: [],\n\n\t\t\tbirthdayWindowError: '',\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/** Layout select options. */\n\t\tlayoutOptions() {\n\t\t\treturn [\n\t\t\t\t{ value: 'card', label: t('nextcloud-vue', 'Card') },\n\t\t\t\t{ value: 'grid', label: t('nextcloud-vue', 'Grid') },\n\t\t\t\t{ value: 'list', label: t('nextcloud-vue', 'List') },\n\t\t\t]\n\t\t},\n\n\t\t/** Sort select options. */\n\t\tsortByOptions() {\n\t\t\treturn [\n\t\t\t\t{ value: 'displayName', label: t('nextcloud-vue', 'Display name') },\n\t\t\t\t{ value: 'group', label: t('nextcloud-vue', 'Group') },\n\t\t\t]\n\t\t},\n\n\t\t/** Comma-joined group filter values for the text input. */\n\t\tgroupFilterText() {\n\t\t\treturn this.groupFilterValues.join(', ')\n\t\t},\n\n\t\t/** The canonical filters array assembled from the group input. */\n\t\tassembledFilters() {\n\t\t\tif (this.groupFilterValues.length === 0) {\n\t\t\t\treturn []\n\t\t\t}\n\t\t\treturn [{\n\t\t\t\tfieldName: 'group',\n\t\t\t\toperator: 'in',\n\t\t\t\tvalues: this.groupFilterValues,\n\t\t\t}]\n\t\t},\n\n\t\t/** The full content blob assembled from the current field values. */\n\t\tassembledContent() {\n\t\t\treturn {\n\t\t\t\tlayout: this.layout,\n\t\t\t\tselectionMode: this.selectionMode,\n\t\t\t\tselectedUsers: this.selectedUsers,\n\t\t\t\tfilters: this.assembledFilters,\n\t\t\t\tfilterOperator: this.filterOperator,\n\t\t\t\texcludeDisabled: this.excludeDisabled,\n\t\t\t\tshowBirthdays: this.showBirthdays,\n\t\t\t\tbirthdayWindowDays: this.birthdayWindowDays,\n\t\t\t\tsortBy: this.sortBy,\n\t\t\t\tcolumns: this.columns,\n\t\t\t\tshowFields: this.showFields,\n\t\t\t}\n\t\t},\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * Set a field and notify the parent.\n\t\t *\n\t\t * @param {string} field one of the form's reactive keys.\n\t\t * @param {unknown} value the new value.\n\t\t * @return {void}\n\t\t */\n\t\tupdateField(field, value) {\n\t\t\tthis[field] = value\n\t\t\tthis.$emit('update:content', this.assembledContent)\n\t\t},\n\n\t\t/**\n\t\t * Parse the comma-separated group input into the canonical filters\n\t\t * shape and re-emit the assembled content.\n\t\t *\n\t\t * @param {string} raw the textbox value.\n\t\t * @return {void}\n\t\t */\n\t\tupdateGroupFilter(raw) {\n\t\t\tthis.groupFilterValues = (raw || '')\n\t\t\t\t.split(',')\n\t\t\t\t.map((part) => part.trim())\n\t\t\t\t.filter((part) => part.length > 0)\n\t\t\tthis.$emit('update:content', this.assembledContent)\n\t\t},\n\n\t\t/**\n\t\t * Validate + clamp the birthday window to the 0..30 range, recording a\n\t\t * localised inline error when out of range.\n\t\t *\n\t\t * @param {string|number} raw the input value.\n\t\t * @return {void}\n\t\t */\n\t\tupdateBirthdayWindow(raw) {\n\t\t\tconst numeric = Number(raw)\n\t\t\tif (!Number.isFinite(numeric) || numeric < 0 || numeric > 30) {\n\t\t\t\tthis.birthdayWindowError = t('nextcloud-vue', 'Must be between 0 and 30')\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.birthdayWindowError = ''\n\t\t\tthis.birthdayWindowDays = Math.floor(numeric)\n\t\t\tthis.$emit('update:content', this.assembledContent)\n\t\t},\n\n\t\t/**\n\t\t * Validate the form; an empty array means valid.\n\t\t *\n\t\t * @return {string[]} the validation errors.\n\t\t */\n\t\tvalidate() {\n\t\t\tconst errors = []\n\t\t\tif (typeof this.birthdayWindowDays !== 'number'\n\t\t\t\t|| this.birthdayWindowDays < 0\n\t\t\t\t|| this.birthdayWindowDays > 30) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Birthday window must be between 0 and 30'))\n\t\t\t}\n\t\t\tif (!['card', 'grid', 'list'].includes(this.layout)) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Invalid layout'))\n\t\t\t}\n\t\t\tif (!['displayName', 'group'].includes(this.sortBy)) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Invalid sort key'))\n\t\t\t}\n\t\t\treturn errors\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-people-widget-form {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n}\n\n.cn-people-widget-form__field {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 4px;\n\tfont-size: 14px;\n}\n\n.cn-people-widget-form__field--inline {\n\tflex-direction: row;\n\talign-items: center;\n\tgap: 8px;\n}\n\n.cn-people-widget-form__input {\n\tpadding: 6px 10px;\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius);\n\tbackground: var(--color-main-background);\n\tcolor: var(--color-main-text);\n\tfont: inherit;\n}\n\n.cn-people-widget-form__error {\n\tcolor: var(--color-error, #c00);\n\tfont-size: 12px;\n}\n</style>\n"],"names":["_openBlock","_createElementBlock","_createTextVNode","_toDisplayString","_createElementVNode"],"mappings":";;AAWM,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,uBAAuB;AAmB1B,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,8BAAY;;AAUlB,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC,mEAAqC;;AAQ3C,MAAA,UAAA,GAAA,EAAA,KAAK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AAC,gCAAe,GACjB,EAAA,CAAA,YAAA;UAAAC,kBAAA;AACA,YAAA,KAAK,EAAE,KAAA,CAAA,OAAA;AACR,YAAA,KAAK,EAAC,8BAAY;YACjB,QAAA,EAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,MAAA,KAAA,oBAAA,CAAA,SAAA,EAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,KAAA,CAAA,CAAA,CAAA;;AACD,YAAAA,kBAAA,CAEC,QAAA,EAAA,EAFO,KAAA,EAAA,CAAA,IAAA,KAEP,EAAA,EAAA,cAAA;AACD,YAAAA,kBAAA,CAEK,QAAA,EAAA,EAFG,KAAA,EAAA,CAAA,IAAA,KAER,EAAA,EAAA,cAAA;AACA,YAAAA,kBAAA,aAAE,KAAA,EAAA,CAAA,IAAA;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"CnPeopleWidgetForm3.vue.js","sources":["../../../../src/components/CnPeopleWidgetForm/CnPeopleWidgetForm.vue?vue&type=template&id=085c8426&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div class=\"cn-people-widget-form\">\n\t\t<NcSelect\n\t\t\t:modelValue=\"layout\"\n\t\t\t:options=\"layoutOptions\"\n\t\t\t:inputLabel=\"t('nextcloud-vue', 'Layout')\"\n\t\t\t:reduce=\"(option) => option.value\"\n\t\t\tlabel=\"label\"\n\t\t\t:clearable=\"false\"\n\t\t\t@update:modelValue=\"updateField('layout', $event)\" />\n\n\t\t<NcSelect\n\t\t\t:modelValue=\"sortBy\"\n\t\t\t:options=\"sortByOptions\"\n\t\t\t:inputLabel=\"t('nextcloud-vue', 'Sort by')\"\n\t\t\t:reduce=\"(option) => option.value\"\n\t\t\tlabel=\"label\"\n\t\t\t:clearable=\"false\"\n\t\t\t@update:modelValue=\"updateSortBy($event)\" />\n\t\t<p v-if=\"sortByError\" class=\"cn-people-widget-form__error\" role=\"alert\">\n\t\t\t{{ sortByError }}\n\t\t</p>\n\n\t\t<label class=\"cn-people-widget-form__field\">\n\t\t\t{{ t('nextcloud-vue', 'Group filter (comma-separated, blank for all)') }}\n\t\t\t<input\n\t\t\t\ttype=\"text\"\n\t\t\t\tclass=\"cn-people-widget-form__input\"\n\t\t\t\t:value=\"groupFilterText\"\n\t\t\t\t:placeholder=\"t('nextcloud-vue', 'e.g. management, product')\"\n\t\t\t\t@input=\"updateGroupFilter($event.target.value)\">\n\t\t</label>\n\n\t\t<label class=\"cn-people-widget-form__field cn-people-widget-form__field--inline\">\n\t\t\t<input\n\t\t\t\ttype=\"checkbox\"\n\t\t\t\t:checked=\"excludeDisabled\"\n\t\t\t\t@change=\"updateField('excludeDisabled', $event.target.checked)\">\n\t\t\t{{ t('nextcloud-vue', 'Exclude disabled users') }}\n\t\t</label>\n\n\t\t<label class=\"cn-people-widget-form__field cn-people-widget-form__field--inline\">\n\t\t\t<input\n\t\t\t\ttype=\"checkbox\"\n\t\t\t\t:checked=\"showBirthdays\"\n\t\t\t\t@change=\"updateField('showBirthdays', $event.target.checked)\">\n\t\t\t{{ t('nextcloud-vue', 'Show birthdays') }}\n\t\t</label>\n\n\t\t<label v-if=\"showBirthdays\" class=\"cn-people-widget-form__field\">\n\t\t\t{{ t('nextcloud-vue', 'Birthday window (days, 0–30)') }}\n\t\t\t<input\n\t\t\t\ttype=\"number\"\n\t\t\t\tclass=\"cn-people-widget-form__input\"\n\t\t\t\tmin=\"0\"\n\t\t\t\tmax=\"30\"\n\t\t\t\t:value=\"birthdayWindowDays\"\n\t\t\t\t@input=\"updateBirthdayWindow($event.target.value)\">\n\t\t\t<span v-if=\"birthdayWindowError\" class=\"cn-people-widget-form__error\" role=\"alert\">\n\t\t\t\t{{ birthdayWindowError }}\n\t\t\t</span>\n\t\t</label>\n\n\t\t<label v-if=\"layout !== 'list'\" class=\"cn-people-widget-form__field\">\n\t\t\t{{ t('nextcloud-vue', 'Columns') }}\n\t\t\t<select\n\t\t\t\t:value=\"columns\"\n\t\t\t\tclass=\"cn-people-widget-form__input\"\n\t\t\t\t@change=\"updateField('columns', Number($event.target.value))\">\n\t\t\t\t<option :value=\"2\">\n\t\t\t\t\t2\n\t\t\t\t</option>\n\t\t\t\t<option :value=\"3\">\n\t\t\t\t\t3\n\t\t\t\t</option>\n\t\t\t\t<option :value=\"4\">\n\t\t\t\t\t4\n\t\t\t\t</option>\n\t\t\t</select>\n\t\t</label>\n\t</div>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport { NcSelect } from '@nextcloud/vue'\n\nconst SORT_KEYS = ['displayName', 'group']\n\nconst DEFAULT_CONTENT = Object.freeze({\n\tlayout: 'grid',\n\tselectionMode: 'filter',\n\tselectedUsers: [],\n\tfilters: [],\n\tfilterOperator: 'AND',\n\texcludeDisabled: true,\n\tshowBirthdays: true,\n\tbirthdayWindowDays: 7,\n\tsortBy: 'displayName',\n\tcolumns: 3,\n\tshowFields: {\n\t\tdisplayName: true,\n\t\trole: true,\n\t\torganisation: true,\n\t\temail: true,\n\t\tphone: true,\n\t\tavatar: true,\n\t\tbirthdate: true,\n\t},\n})\n\n/**\n * CnPeopleWidgetForm — the `CnAddWidgetModal` sub-form for creating or editing\n * a `people` widget placement. Exposes layout, sort, group filter, exclude\n * disabled, show birthdays + window, and columns; less common keys\n * (selectionMode, selectedUsers, filterOperator, showFields) travel through\n * untouched from their defaults. Group filter persists as the canonical\n * `[{fieldName:'group', operator:'in', values:[...]}]` shape. Emits\n * `update:content` on change and exposes `validate()`: a birthday window\n * typed outside 0..30 keeps the form invalid until it is corrected, and a\n * stored unknown `sortBy` is shown as Display name with a message, keeping\n * the form invalid until a sort key is picked.\n */\nexport default {\n\tname: 'CnPeopleWidgetForm',\n\n\tcomponents: {\n\t\tNcSelect,\n\t},\n\n\tprops: {\n\t\t/** The placement being edited, or `null` in create mode. */\n\t\teditingWidget: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\n\t\t/** Initial content values when not editing (registry defaults). */\n\t\tvalue: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({ ...DEFAULT_CONTENT }),\n\t\t},\n\t},\n\n\temits: [\n\t\t/**\n\t\t * Emitted with the assembled content blob on every change.\n\t\t *\n\t\t * @event update:content\n\t\t * @type {object}\n\t\t */\n\t\t'update:content',\n\t],\n\n\tdata() {\n\t\tconst initial = this.editingWidget?.content || this.value || {}\n\t\tconst storedSortBy = initial.sortBy ?? DEFAULT_CONTENT.sortBy\n\t\tconst sortByKnown = SORT_KEYS.includes(storedSortBy)\n\t\tconst groupFilter = (initial.filters || [])\n\t\t\t.find((f) => f && f.fieldName === 'group')\n\t\treturn {\n\t\t\tlayout: initial.layout ?? DEFAULT_CONTENT.layout,\n\t\t\tselectionMode: initial.selectionMode ?? DEFAULT_CONTENT.selectionMode,\n\t\t\tselectedUsers: Array.isArray(initial.selectedUsers)\n\t\t\t\t? [...initial.selectedUsers]\n\t\t\t\t: [...DEFAULT_CONTENT.selectedUsers],\n\n\t\t\tfilterOperator: initial.filterOperator ?? DEFAULT_CONTENT.filterOperator,\n\t\t\texcludeDisabled: typeof initial.excludeDisabled === 'boolean'\n\t\t\t\t? initial.excludeDisabled\n\t\t\t\t: DEFAULT_CONTENT.excludeDisabled,\n\n\t\t\tshowBirthdays: typeof initial.showBirthdays === 'boolean'\n\t\t\t\t? initial.showBirthdays\n\t\t\t\t: DEFAULT_CONTENT.showBirthdays,\n\n\t\t\tbirthdayWindowDays: typeof initial.birthdayWindowDays === 'number'\n\t\t\t\t? initial.birthdayWindowDays\n\t\t\t\t: DEFAULT_CONTENT.birthdayWindowDays,\n\n\t\t\tsortBy: sortByKnown ? storedSortBy : DEFAULT_CONTENT.sortBy,\n\t\t\tsortByError: sortByKnown\n\t\t\t\t? ''\n\t\t\t\t: t('nextcloud-vue', 'Unknown sort key \"{key}\". Display name is used instead.', { key: String(storedSortBy) }),\n\n\t\t\tcolumns: typeof initial.columns === 'number'\n\t\t\t\t? initial.columns\n\t\t\t\t: DEFAULT_CONTENT.columns,\n\n\t\t\tshowFields: { ...DEFAULT_CONTENT.showFields, ...(initial.showFields || {}) },\n\t\t\tgroupFilterValues: groupFilter && Array.isArray(groupFilter.values)\n\t\t\t\t? [...groupFilter.values]\n\t\t\t\t: [],\n\n\t\t\tbirthdayWindowError: '',\n\t\t}\n\t},\n\n\tcomputed: {\n\t\t/** Layout select options. */\n\t\tlayoutOptions() {\n\t\t\treturn [\n\t\t\t\t{ value: 'card', label: t('nextcloud-vue', 'Card') },\n\t\t\t\t{ value: 'grid', label: t('nextcloud-vue', 'Grid') },\n\t\t\t\t{ value: 'list', label: t('nextcloud-vue', 'List') },\n\t\t\t]\n\t\t},\n\n\t\t/** Sort select options. */\n\t\tsortByOptions() {\n\t\t\treturn [\n\t\t\t\t{ value: 'displayName', label: t('nextcloud-vue', 'Display name') },\n\t\t\t\t{ value: 'group', label: t('nextcloud-vue', 'Group') },\n\t\t\t]\n\t\t},\n\n\t\t/** Comma-joined group filter values for the text input. */\n\t\tgroupFilterText() {\n\t\t\treturn this.groupFilterValues.join(', ')\n\t\t},\n\n\t\t/** The canonical filters array assembled from the group input. */\n\t\tassembledFilters() {\n\t\t\tif (this.groupFilterValues.length === 0) {\n\t\t\t\treturn []\n\t\t\t}\n\t\t\treturn [{\n\t\t\t\tfieldName: 'group',\n\t\t\t\toperator: 'in',\n\t\t\t\tvalues: this.groupFilterValues,\n\t\t\t}]\n\t\t},\n\n\t\t/** The full content blob assembled from the current field values. */\n\t\tassembledContent() {\n\t\t\treturn {\n\t\t\t\tlayout: this.layout,\n\t\t\t\tselectionMode: this.selectionMode,\n\t\t\t\tselectedUsers: this.selectedUsers,\n\t\t\t\tfilters: this.assembledFilters,\n\t\t\t\tfilterOperator: this.filterOperator,\n\t\t\t\texcludeDisabled: this.excludeDisabled,\n\t\t\t\tshowBirthdays: this.showBirthdays,\n\t\t\t\tbirthdayWindowDays: this.birthdayWindowDays,\n\t\t\t\tsortBy: this.sortBy,\n\t\t\t\tcolumns: this.columns,\n\t\t\t\tshowFields: this.showFields,\n\t\t\t}\n\t\t},\n\t},\n\n\tmethods: {\n\t\tt,\n\n\t\t/**\n\t\t * Set a field and notify the parent.\n\t\t *\n\t\t * @param {string} field one of the form's reactive keys.\n\t\t * @param {unknown} value the new value.\n\t\t * @return {void}\n\t\t */\n\t\tupdateField(field, value) {\n\t\t\tthis[field] = value\n\t\t\tthis.$emit('update:content', this.assembledContent)\n\t\t},\n\n\t\t/**\n\t\t * Set the sort key; picking one confirms it and clears the\n\t\t * unknown-key message.\n\t\t *\n\t\t * @param {string} value the chosen sort key.\n\t\t * @return {void}\n\t\t */\n\t\tupdateSortBy(value) {\n\t\t\tthis.sortByError = ''\n\t\t\tthis.updateField('sortBy', value)\n\t\t},\n\n\t\t/**\n\t\t * Parse the comma-separated group input into the canonical filters\n\t\t * shape and re-emit the assembled content.\n\t\t *\n\t\t * @param {string} raw the textbox value.\n\t\t * @return {void}\n\t\t */\n\t\tupdateGroupFilter(raw) {\n\t\t\tthis.groupFilterValues = (raw || '')\n\t\t\t\t.split(',')\n\t\t\t\t.map((part) => part.trim())\n\t\t\t\t.filter((part) => part.length > 0)\n\t\t\tthis.$emit('update:content', this.assembledContent)\n\t\t},\n\n\t\t/**\n\t\t * Validate the birthday window against the 0..30 range. An out-of-range\n\t\t * value records a localised inline error, which keeps `validate()`\n\t\t * failing until a valid value is typed; the last valid value stays in\n\t\t * the content.\n\t\t *\n\t\t * @param {string|number} raw the input value.\n\t\t * @return {void}\n\t\t */\n\t\tupdateBirthdayWindow(raw) {\n\t\t\tconst numeric = Number(raw)\n\t\t\tif (raw === '' || !Number.isFinite(numeric) || numeric < 0 || numeric > 30) {\n\t\t\t\tthis.birthdayWindowError = t('nextcloud-vue', 'Must be between 0 and 30')\n\t\t\t} else {\n\t\t\t\tthis.birthdayWindowError = ''\n\t\t\t\tthis.birthdayWindowDays = Math.floor(numeric)\n\t\t\t}\n\t\t\tthis.$emit('update:content', this.assembledContent)\n\t\t},\n\n\t\t/**\n\t\t * Validate the form; an empty array means valid.\n\t\t *\n\t\t * @return {string[]} the validation errors.\n\t\t */\n\t\tvalidate() {\n\t\t\tconst errors = []\n\t\t\tif (this.sortByError) {\n\t\t\t\terrors.push(this.sortByError)\n\t\t\t}\n\t\t\tif (this.showBirthdays && this.birthdayWindowError) {\n\t\t\t\terrors.push(this.birthdayWindowError)\n\t\t\t}\n\t\t\tif (typeof this.birthdayWindowDays !== 'number'\n\t\t\t\t|| this.birthdayWindowDays < 0\n\t\t\t\t|| this.birthdayWindowDays > 30) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Birthday window must be between 0 and 30'))\n\t\t\t}\n\t\t\tif (!['card', 'grid', 'list'].includes(this.layout)) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Invalid layout'))\n\t\t\t}\n\t\t\tif (!SORT_KEYS.includes(this.sortBy)) {\n\t\t\t\terrors.push(t('nextcloud-vue', 'Invalid sort key'))\n\t\t\t}\n\t\t\treturn errors\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-people-widget-form {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 12px;\n}\n\n.cn-people-widget-form__field {\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: 4px;\n\tfont-size: 14px;\n}\n\n.cn-people-widget-form__field--inline {\n\tflex-direction: row;\n\talign-items: center;\n\tgap: 8px;\n}\n\n.cn-people-widget-form__input {\n\tpadding: 6px 10px;\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius);\n\tbackground: var(--color-main-background);\n\tcolor: var(--color-main-text);\n\tfont: inherit;\n}\n\n.cn-people-widget-form__error {\n\tcolor: var(--color-error, #c00);\n\tfont-size: 12px;\n}\n</style>\n"],"names":["_openBlock","_createElementBlock","_toDisplayString","_createTextVNode","_createElementVNode"],"mappings":";;AAWM,MAAA,UAAA,GAAA,EAAA,KAAK,EAAC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AC,qDAAI;;AAEP,YAAA,IAAI,EAAC,QAAQ;AACb,YAAA,KAAK,EAAC,8BAA8B;AACpC,YAAA,GAAG,EAAC,GAAG;AACP,YAAA,GAAG,EAAC,IAAC;AACJ,YAAA,KAAI,EAAA,KAAA,CAAA,kBAAA;;;WAEM,KAAA,CAAA,mBAAmB;4BAA/BD,kBAAA,CAEM,MAAA,EAFN,WAEM,EAAAC,eAAA,CADF,KAAA,CAAA,mBAAmB,CAAA,EAAA,CAAA,YAAA;;;;KAIX,KAAA,CAAA,MAAM,KAAA,MAAA;;AACf,UAAAC,eAAA,CAAAD,eAAA,CAAA,QAAA,CAAA,CAAC,gCAAe,GACjB,EAAA,CAAA,YAAA;UAAAE,kBAAA;AACA,YAAA,KAAK,EAAE,KAAA,CAAA,OAAA;AACR,YAAA,KAAK,EAAC,8BAAY;YACjB,QAAA,EAAA,MAAA,CAAA,CAAA,CAAA,KAAA,MAAA,CAAA,CAAA,CAAA,GAAA,MAAA,KAAA,oBAAA,CAAA,SAAA,EAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,KAAA,CAAA,CAAA,CAAA;;AACD,YAAAA,kBAAA,CAEC,QAAA,EAAA,EAFO,KAAA,EAAA,CAAA,IAAA,KAEP,EAAA,EAAA,cAAA;AACD,YAAAA,kBAAA,CAEK,QAAA,EAAA,EAFG,KAAA,EAAA,CAAA,IAAA,KAER,EAAA,EAAA,cAAA;AACA,YAAAA,kBAAA,aAAE,KAAA,EAAA,CAAA,IAAA;;;;;;;"}
|
|
@@ -2,7 +2,7 @@ import script from './CnTextWidget2.vue.js';
|
|
|
2
2
|
import { render } from './CnTextWidget3.vue.js';
|
|
3
3
|
|
|
4
4
|
script.render = render;
|
|
5
|
-
script.__scopeId = "data-v-
|
|
5
|
+
script.__scopeId = "data-v-ebdce82c";
|
|
6
6
|
const __sfc_main = script;
|
|
7
7
|
|
|
8
8
|
export { __sfc_main as default };
|
|
@@ -31,6 +31,24 @@ function ensureDomPurifyHook() {
|
|
|
31
31
|
hookRegistered = true;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
// The widget's own sanitiser config: `target` survives (the hook above adds
|
|
35
|
+
// `rel`), `data-*` attributes do not.
|
|
36
|
+
const SANITIZE_CONFIG = {
|
|
37
|
+
ADD_ATTR: ['target'],
|
|
38
|
+
ALLOW_DATA_ATTR: false,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Sanitise author HTML with the widget's own config.
|
|
43
|
+
*
|
|
44
|
+
* @param {string} html The HTML.
|
|
45
|
+
* @return {string} HTML safe for `v-html`.
|
|
46
|
+
*/
|
|
47
|
+
function sanitize(html) {
|
|
48
|
+
ensureDomPurifyHook();
|
|
49
|
+
return DOMPurify.sanitize(html, SANITIZE_CONFIG)
|
|
50
|
+
}
|
|
51
|
+
|
|
34
52
|
/**
|
|
35
53
|
* CnTextWidget — renders user-authored multi-line text (or a small table)
|
|
36
54
|
* inside a dashboard cell. Text content is passed through DOMPurify before
|
|
@@ -96,7 +114,11 @@ var script = {
|
|
|
96
114
|
|
|
97
115
|
computed: {
|
|
98
116
|
/**
|
|
99
|
-
* The text: `content.textField` of the object as it is, else
|
|
117
|
+
* The text: `content.textField` of the object as it is, else
|
|
118
|
+
* `content.text`; '' when absent. Plain text goes through the app's
|
|
119
|
+
* translate function; text holding markup (`<`, `>`, `&`) is author
|
|
120
|
+
* content and is shown as written, because the translate function
|
|
121
|
+
* sanitises with its own allow-list (which drops `target`).
|
|
100
122
|
*
|
|
101
123
|
* @spec openspec/changes/text-widget-monospace/tasks.md#task-2
|
|
102
124
|
*/
|
|
@@ -106,7 +128,11 @@ var script = {
|
|
|
106
128
|
const value = this.objectData?.[field];
|
|
107
129
|
return value === undefined || value === null ? '' : String(value)
|
|
108
130
|
}
|
|
109
|
-
|
|
131
|
+
const text = this.content?.text;
|
|
132
|
+
if (typeof text !== 'string') {
|
|
133
|
+
return ''
|
|
134
|
+
}
|
|
135
|
+
return /[<>&]/.test(text) ? text : this.tr(text)
|
|
110
136
|
},
|
|
111
137
|
|
|
112
138
|
/**
|
|
@@ -192,9 +218,7 @@ var script = {
|
|
|
192
218
|
} else {
|
|
193
219
|
html = this.text;
|
|
194
220
|
}
|
|
195
|
-
return
|
|
196
|
-
ADD_ATTR: ['target'],
|
|
197
|
-
})
|
|
221
|
+
return sanitize(html)
|
|
198
222
|
},
|
|
199
223
|
|
|
200
224
|
/** Localised placeholder shown when there is no text content. */
|
|
@@ -260,8 +284,8 @@ var script = {
|
|
|
260
284
|
height: '100%',
|
|
261
285
|
padding: '16px',
|
|
262
286
|
display: 'flex',
|
|
263
|
-
'align-items': 'center',
|
|
264
|
-
'justify-content': 'center',
|
|
287
|
+
'align-items': 'safe center',
|
|
288
|
+
'justify-content': 'safe center',
|
|
265
289
|
overflow: 'auto',
|
|
266
290
|
'background-color': this.backgroundColor,
|
|
267
291
|
...(this.link ? { 'flex-direction': 'column', gap: '8px', 'align-items': 'flex-start' } : {}),
|
|
@@ -294,10 +318,6 @@ var script = {
|
|
|
294
318
|
},
|
|
295
319
|
},
|
|
296
320
|
|
|
297
|
-
created() {
|
|
298
|
-
ensureDomPurifyHook();
|
|
299
|
-
},
|
|
300
|
-
|
|
301
321
|
methods: {
|
|
302
322
|
/**
|
|
303
323
|
* A manifest string through the app's translate function.
|
|
@@ -328,7 +348,7 @@ var script = {
|
|
|
328
348
|
* @return {string} sanitised HTML safe to render via `v-html`.
|
|
329
349
|
*/
|
|
330
350
|
sanitizeCell(text) {
|
|
331
|
-
return
|
|
351
|
+
return sanitize(typeof text === 'string' ? text : '')
|
|
332
352
|
},
|
|
333
353
|
|
|
334
354
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CnTextWidget2.vue.js","sources":["../../../../src/components/CnTextWidget/CnTextWidget.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div class=\"cn-text-widget\" :style=\"wrapperStyle\">\n\t\t<table\n\t\t\tv-if=\"tableMode\"\n\t\t\tclass=\"cn-text-widget__table\"\n\t\t\t:style=\"tableContainerStyle\">\n\t\t\t<tbody>\n\t\t\t\t<tr v-for=\"(row, rIdx) in tableRows\" :key=\"`r-${rIdx}`\">\n\t\t\t\t\t<template v-for=\"(cell, cIdx) in row\">\n\t\t\t\t\t\t<th\n\t\t\t\t\t\t\tv-if=\"isHeaderCell(rIdx)\"\n\t\t\t\t\t\t\tv-show=\"!isPlaceholderCellAt(rIdx, cIdx)\"\n\t\t\t\t\t\t\t:key=\"`c-${rIdx}-${cIdx}`\"\n\t\t\t\t\t\t\t:rowspan=\"cell.rowSpan || 1\"\n\t\t\t\t\t\t\t:colspan=\"cell.colSpan || 1\"\n\t\t\t\t\t\t\t:style=\"headerCellStyle(cIdx)\">\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-if=\"cellHasText(cell)\"\n\t\t\t\t\t\t\t\tv-html=\"sanitizeCell(cell.text)\" /><!-- eslint-disable-line vue/no-v-html -->\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\t\tclass=\"cn-text-widget__cell-placeholder\">\n\t\t\t\t\t\t\t\t{{ emptyCellPlaceholder }}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</th>\n\t\t\t\t\t\t<td\n\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\tv-show=\"!isPlaceholderCellAt(rIdx, cIdx)\"\n\t\t\t\t\t\t\t:key=\"`c-${rIdx}-${cIdx}`\"\n\t\t\t\t\t\t\t:rowspan=\"cell.rowSpan || 1\"\n\t\t\t\t\t\t\t:colspan=\"cell.colSpan || 1\"\n\t\t\t\t\t\t\t:style=\"dataCellStyle(cIdx)\">\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-if=\"cellHasText(cell)\"\n\t\t\t\t\t\t\t\tv-html=\"sanitizeCell(cell.text)\" /><!-- eslint-disable-line vue/no-v-html -->\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\t\tclass=\"cn-text-widget__cell-placeholder\">\n\t\t\t\t\t\t\t\t{{ emptyCellPlaceholder }}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</template>\n\t\t\t\t</tr>\n\t\t\t</tbody>\n\t\t</table>\n\t\t<pre\n\t\t\tv-else-if=\"monospace && hasText\"\n\t\t\tclass=\"cn-text-widget__mono\"\n\t\t\tdata-testid=\"cn-text-widget-mono\"\n\t\t\t:style=\"monoStyle\">{{ text }}</pre>\n\t\t<div\n\t\t\tv-else-if=\"hasText\"\n\t\t\tclass=\"cn-text-widget__content\"\n\t\t\t:class=\"contentClass\"\n\t\t\t:style=\"contentStyle\"\n\t\t\tv-html=\"sanitizedHtml\" /><!-- eslint-disable-line vue/no-v-html -->\n\t\t<span\n\t\t\tv-else\n\t\t\tclass=\"cn-text-widget__placeholder\"\n\t\t\t:style=\"contentStyle\">\n\t\t\t{{ placeholderText }}\n\t\t</span>\n\t\t<a\n\t\t\tv-if=\"link\"\n\t\t\tclass=\"cn-text-widget__link\"\n\t\t\tdata-testid=\"cn-text-widget-link\"\n\t\t\t:href=\"link.url\"\n\t\t\t:target=\"link.external ? '_blank' : null\"\n\t\t\t:rel=\"link.external ? 'noopener noreferrer' : null\"\n\t\t\t@click=\"openLink\">\n\t\t\t{{ link.label }}\n\t\t\t<ChevronRight :size=\"16\" />\n\t\t</a>\n\t</div>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport DOMPurify from 'dompurify'\nimport { Marked } from 'marked'\nimport ChevronRight from 'vue-material-design-icons/ChevronRight.vue'\nimport { followLinkClick, resolveHref } from '../../utils/linkNavigation.js'\nimport { isPlaceholderCell } from '../../utils/textTable.js'\n\n// Per-module `Marked` instance so configuration is scoped here and does NOT\n// mutate the global `marked` singleton (which would affect any other code in\n// the same app that imports `marked`). `gfm: true` enables tables; `breaks:\n// false` keeps CommonMark-strict newline behaviour.\nconst markedInstance = new Marked({\n\tgfm: true,\n\tbreaks: false,\n})\n\n// DOMPurify allow-list hook: author-supplied `target=_blank` links survive\n// sanitisation (we add `target` to ADD_ATTR below); the hook then appends\n// `rel=\"noopener noreferrer\"` to mitigate reverse-tabnabbing. The hook is\n// idempotent and registered once.\nlet hookRegistered = false\nfunction ensureDomPurifyHook() {\n\tif (hookRegistered) {\n\t\treturn\n\t}\n\tDOMPurify.addHook('afterSanitizeAttributes', (node) => {\n\t\tif (node.tagName === 'A' && node.getAttribute('target') === '_blank') {\n\t\t\tnode.setAttribute('rel', 'noopener noreferrer')\n\t\t}\n\t})\n\thookRegistered = true\n}\n\n/**\n * CnTextWidget — renders user-authored multi-line text (or a small table)\n * inside a dashboard cell. Text content is passed through DOMPurify before\n * injection via `v-html` so common formatting tags survive while XSS vectors\n * (`<script>`, `on*` attributes, `javascript:` URLs) are stripped.\n *\n * Persisted shape: `{text, fontSize, color, backgroundColor, textAlign,\n * contentMode, tableMode, tableData}`. Defaults: `fontSize='14px'`,\n * `color='var(--color-main-text)'`, `backgroundColor='transparent'`,\n * `textAlign='left'`. `contentMode` absent means the legacy `'html'` branch;\n * the literal `'markdown'` parses via marked (GFM tables) then sanitises\n * through the same allow-list — a single trust boundary protects both modes.\n *\n * When `tableMode === true`, the renderer draws an HTML `<table>` from\n * `tableData` instead: header rows promote row 0 to `<th>`, per-column\n * alignment is applied inline, and `colSpan` / `rowSpan` become native HTML\n * attributes. Merge-swallowed cells are hidden via `v-show` so the visual\n * grid stays rectangular.\n *\n * With `monospace: true` the text is shown as typed, in a fixed-width font\n * with its spaces and line breaks kept, and is never parsed as HTML or\n * markdown: a receipt or a log line. `textField` reads the text from that\n * field of the detail page's object instead of `text`.\n *\n * Registered as the `text` dashboard widget type via the renderer's\n * `index.js`.\n */\nexport default {\n\tname: 'CnTextWidget',\n\n\tcomponents: { ChevronRight },\n\n\tinject: {\n\t\t/** The app's translate function, provided by CnAppRoot. Identity outside one. */\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * Persisted widget content blob: `{text, fontSize, color,\n\t\t * backgroundColor, textAlign, contentMode, tableMode, tableData, link,\n\t\t * monospace, textField}`.\n\t\t * All keys are optional; missing keys collapse to documented defaults.\n\t\t * `text` and `link.label` go through the app's translate function.\n\t\t * `link` is `{label, route}` (a page id, or a path starting with `/`) or\n\t\t * `{label, href}` (an external URL), drawn under the text.\n\t\t * `monospace` shows the text as typed in a fixed-width font;\n\t\t * `textField` reads the text from that field of `objectData`.\n\t\t *\n\t\t * @type {{text: string, fontSize: string, color: string, backgroundColor: string, textAlign: string, contentMode: string, tableMode: boolean, tableData: object, link: {label: string, route: string, href: string}, monospace: boolean, textField: string}}\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/** The detail page's object, which `content.textField` reads from. */\n\t\tobjectData: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * The text: `content.textField` of the object as it is, else `content.text` translated; '' when absent.\n\t\t *\n\t\t * @spec openspec/changes/text-widget-monospace/tasks.md#task-2\n\t\t */\n\t\ttext() {\n\t\t\tconst field = this.content?.textField\n\t\t\tif (typeof field === 'string' && field !== '') {\n\t\t\t\tconst value = this.objectData?.[field]\n\t\t\t\treturn value === undefined || value === null ? '' : String(value)\n\t\t\t}\n\t\t\treturn typeof this.content?.text === 'string' ? this.tr(this.content.text) : ''\n\t\t},\n\n\t\t/**\n\t\t * Whether the text shows as typed, in a fixed-width font.\n\t\t *\n\t\t * @spec openspec/changes/text-widget-monospace/tasks.md#task-1\n\t\t */\n\t\tmonospace() {\n\t\t\treturn this.content?.monospace === true\n\t\t},\n\n\t\t/** Inline style for the fixed-width text. */\n\t\tmonoStyle() {\n\t\t\treturn {\n\t\t\t\t'font-size': this.fontSize,\n\t\t\t\tcolor: this.color,\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The link under the text, from `content.link`: `{ label, route }`\n\t\t * (a page id, or a router path when it starts with `/`) or\n\t\t * `{ label, href }` (an external URL, opened in a new tab). The label\n\t\t * goes through the app's translate function. Null without a label or\n\t\t * a target.\n\t\t *\n\t\t * @return {{label: string, url: string, location: (object|null), external: boolean}|null} The link.\n\t\t */\n\t\tlink() {\n\t\t\tconst link = this.content?.link\n\t\t\tif (!link || typeof link !== 'object' || typeof link.label !== 'string' || link.label === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tif (typeof link.route === 'string' && link.route !== '') {\n\t\t\t\tconst location = link.route.startsWith('/') ? { path: link.route } : { name: link.route }\n\t\t\t\tconst url = resolveHref(location, this.$router)\n\t\t\t\treturn url ? { label: this.tr(link.label), url, location, external: false } : null\n\t\t\t}\n\t\t\tif (typeof link.href === 'string' && link.href !== '') {\n\t\t\t\treturn { label: this.tr(link.label), url: link.href, location: null, external: true }\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\n\t\t/** Whether the text has any non-whitespace content. */\n\t\thasText() {\n\t\t\treturn this.text.trim() !== ''\n\t\t},\n\n\t\t/** Resolved content mode — only `'markdown'` switches the branch. */\n\t\tcontentMode() {\n\t\t\treturn this.content?.contentMode === 'markdown' ? 'markdown' : 'html'\n\t\t},\n\n\t\t/** CSS class selecting the markdown vs html content-spacing rules. */\n\t\tcontentClass() {\n\t\t\treturn this.contentMode === 'markdown'\n\t\t\t\t? 'cn-text-widget__content--markdown'\n\t\t\t\t: 'cn-text-widget__content--html'\n\t\t},\n\n\t\t/**\n\t\t * The HTML to render: either the raw author HTML (sanitised) or the\n\t\t * markdown rendering of the author text (sanitised). Both branches go\n\t\t * through DOMPurify, which strips `<script>`, `<style>`, `<link>`,\n\t\t * `on*` attributes, and `javascript:` URLs.\n\t\t *\n\t\t * @return {string} sanitised HTML safe for `v-html` injection.\n\t\t */\n\t\tsanitizedHtml() {\n\t\t\tlet html\n\t\t\tif (this.contentMode === 'markdown') {\n\t\t\t\ttry {\n\t\t\t\t\thtml = markedInstance.parse(this.text)\n\t\t\t\t\tif (typeof html !== 'string') {\n\t\t\t\t\t\thtml = String(html)\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Defensive: fall back to the raw text rather than crash\n\t\t\t\t\t// the dashboard if the parser throws.\n\t\t\t\t\thtml = this.text\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\thtml = this.text\n\t\t\t}\n\t\t\treturn DOMPurify.sanitize(html, {\n\t\t\t\tADD_ATTR: ['target'],\n\t\t\t})\n\t\t},\n\n\t\t/** Localised placeholder shown when there is no text content. */\n\t\tplaceholderText() {\n\t\t\treturn t('nextcloud-vue', 'No text content')\n\t\t},\n\n\t\t/** Localised placeholder shown inside an empty table cell. */\n\t\temptyCellPlaceholder() {\n\t\t\treturn t('nextcloud-vue', 'Empty cell')\n\t\t},\n\n\t\t/** Resolved font size (default `14px`). */\n\t\tfontSize() {\n\t\t\treturn this.content?.fontSize || '14px'\n\t\t},\n\n\t\t/** Resolved text colour (default theme main text). */\n\t\tcolor() {\n\t\t\treturn this.content?.color || 'var(--color-main-text)'\n\t\t},\n\n\t\t/** Resolved background colour (default transparent). */\n\t\tbackgroundColor() {\n\t\t\treturn this.content?.backgroundColor || 'transparent'\n\t\t},\n\n\t\t/** Resolved text alignment (default `left`). */\n\t\ttextAlign() {\n\t\t\treturn this.content?.textAlign || 'left'\n\t\t},\n\n\t\t/** Whether the renderer is in table mode. */\n\t\ttableMode() {\n\t\t\treturn this.content?.tableMode === true\n\t\t},\n\n\t\t/** The persisted tableData object, or null. */\n\t\ttableData() {\n\t\t\treturn this.content?.tableData || null\n\t\t},\n\n\t\t/** The table rows array (empty when no table data). */\n\t\ttableRows() {\n\t\t\treturn Array.isArray(this.tableData?.rows) ? this.tableData.rows : []\n\t\t},\n\n\t\t/** Whether row 0 should render as a header row. */\n\t\theaderRow() {\n\t\t\treturn this.tableData?.headerRow === true\n\t\t},\n\n\t\t/** Per-column text-alignment array. */\n\t\tcolumnAlignments() {\n\t\t\tconst aligns = this.tableData?.columnAlignments\n\t\t\treturn Array.isArray(aligns) ? aligns : []\n\t\t},\n\n\t\t/** Inline style for the flex wrapper. */\n\t\twrapperStyle() {\n\t\t\treturn {\n\t\t\t\twidth: '100%',\n\t\t\t\theight: '100%',\n\t\t\t\tpadding: '16px',\n\t\t\t\tdisplay: 'flex',\n\t\t\t\t'align-items': 'center',\n\t\t\t\t'justify-content': 'center',\n\t\t\t\toverflow: 'auto',\n\t\t\t\t'background-color': this.backgroundColor,\n\t\t\t\t...(this.link ? { 'flex-direction': 'column', gap: '8px', 'align-items': 'flex-start' } : {}),\n\t\t\t}\n\t\t},\n\n\t\t/** Inline style for the text / placeholder content. */\n\t\tcontentStyle() {\n\t\t\tconst base = {\n\t\t\t\t'font-size': this.fontSize,\n\t\t\t\t'text-align': this.textAlign,\n\t\t\t\tcolor: this.color,\n\t\t\t\twidth: '100%',\n\t\t\t\t'overflow-wrap': 'break-word',\n\t\t\t}\n\t\t\tif (!this.hasText) {\n\t\t\t\tbase['font-style'] = 'italic'\n\t\t\t\tbase.color = 'var(--color-text-maxcontrast)'\n\t\t\t}\n\t\t\treturn base\n\t\t},\n\n\t\t/** Inline style for the table container. */\n\t\ttableContainerStyle() {\n\t\t\treturn {\n\t\t\t\t'font-size': this.fontSize,\n\t\t\t\tcolor: this.color,\n\t\t\t\twidth: '100%',\n\t\t\t}\n\t\t},\n\t},\n\n\tcreated() {\n\t\tensureDomPurifyHook()\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * A manifest string through the app's translate function.\n\t\t *\n\t\t * @param {string} text The string.\n\t\t * @return {string} The translated string.\n\t\t */\n\t\ttr(text) {\n\t\t\treturn typeof this.cnTranslate === 'function' ? this.cnTranslate(text) : text\n\t\t},\n\n\t\t/**\n\t\t * Route a plain click on an in-app link, so the page does not reload.\n\t\t *\n\t\t * @param {MouseEvent} event The click.\n\t\t */\n\t\topenLink(event) {\n\t\t\tif (this.link && !this.link.external) {\n\t\t\t\tfollowLinkClick(event, this.link.location, this.$router)\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Run cell text through DOMPurify so the table-mode render path has\n\t\t * the same XSS-stripping guarantees as the text-mode path.\n\t\t *\n\t\t * @param {string} text raw cell text (may contain HTML).\n\t\t * @return {string} sanitised HTML safe to render via `v-html`.\n\t\t */\n\t\tsanitizeCell(text) {\n\t\t\treturn DOMPurify.sanitize(typeof text === 'string' ? text : '')\n\t\t},\n\n\t\t/**\n\t\t * Whether the given row index renders as `<th>` (header row).\n\t\t *\n\t\t * @param {number} rIdx the 0-based row index.\n\t\t * @return {boolean} true when row 0 and the header flag is set.\n\t\t */\n\t\tisHeaderCell(rIdx) {\n\t\t\treturn this.headerRow && rIdx === 0\n\t\t},\n\n\t\t/**\n\t\t * Whether a cell is covered by another cell's `rowSpan` / `colSpan`\n\t\t * and so must be hidden to keep the grid rectangular.\n\t\t *\n\t\t * @param {number} rIdx the row index.\n\t\t * @param {number} cIdx the column index.\n\t\t * @return {boolean} true when the cell is a covered placeholder.\n\t\t */\n\t\tisPlaceholderCellAt(rIdx, cIdx) {\n\t\t\treturn isPlaceholderCell(this.tableRows, rIdx, cIdx)\n\t\t},\n\n\t\t/**\n\t\t * Whether a cell has any non-whitespace text.\n\t\t *\n\t\t * @param {object} cell the cell object.\n\t\t * @return {boolean} true when the cell has text.\n\t\t */\n\t\tcellHasText(cell) {\n\t\t\treturn typeof cell?.text === 'string' && cell.text.trim() !== ''\n\t\t},\n\n\t\t/**\n\t\t * Inline style for a data cell at a given column.\n\t\t *\n\t\t * @param {number} cIdx the column index.\n\t\t * @return {object} the cell style object.\n\t\t */\n\t\tdataCellStyle(cIdx) {\n\t\t\treturn {\n\t\t\t\t'text-align': this.columnAlignments[cIdx] || 'left',\n\t\t\t\tborder: '1px solid var(--color-border)',\n\t\t\t\tpadding: '8px',\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Inline style for a header cell at a given column.\n\t\t *\n\t\t * @param {number} cIdx the column index.\n\t\t * @return {object} the header cell style object.\n\t\t */\n\t\theaderCellStyle(cIdx) {\n\t\t\treturn {\n\t\t\t\t...this.dataCellStyle(cIdx),\n\t\t\t\t'background-color': 'var(--color-background-hover)',\n\t\t\t\t'font-weight': 'bold',\n\t\t\t}\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-text-widget {\n\twidth: 100%;\n\theight: 100%;\n}\n\n.cn-text-widget__mono {\n\twidth: 100%;\n\tmargin: 0;\n\tpadding: 12px;\n\tfont-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;\n\tline-height: 1.4;\n\twhite-space: pre-wrap;\n\toverflow-wrap: anywhere;\n\ttext-align: start;\n\tbackground: var(--color-background-dark);\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius);\n}\n\n.cn-text-widget__content,\n.cn-text-widget__placeholder {\n\t/* Safety net — ensures long URLs / words inside the sanitised HTML wrap\n\t rather than overflowing horizontally. */\n\toverflow-wrap: break-word;\n\tmax-width: 100%;\n}\n\n/* Restore inline-emphasis semantics inside rendered content. Nextcloud's\n server CSS styles bare <em> as muted (var(--color-text-maxcontrast)) and can\n drop the italic, so `_x_` / `**_x_**` looked greyed-out and non-italic. Force\n italic <em> / bold <strong> that inherit the widget's own text colour. */\n.cn-text-widget :deep(em),\n.cn-text-widget :deep(i) {\n\tfont-style: italic;\n\tcolor: inherit;\n}\n\n.cn-text-widget :deep(strong),\n.cn-text-widget :deep(b) {\n\tfont-weight: bold;\n\tcolor: inherit;\n}\n\n/* Nextcloud's server CSS strips list markers/indent (`list-style: none`,\n no padding), so rendered `<ul>`/`<ol>` looked like plain text. Restore\n bullets/numbers and indentation, including nested levels. */\n.cn-text-widget :deep(ul),\n.cn-text-widget :deep(ol) {\n\tmargin: 4px 0;\n\tpadding-left: 1.5em;\n}\n\n.cn-text-widget :deep(ul) {\n\tlist-style: disc outside;\n}\n\n.cn-text-widget :deep(ol) {\n\tlist-style: decimal outside;\n}\n\n.cn-text-widget :deep(ul ul) {\n\tlist-style-type: circle;\n}\n\n.cn-text-widget :deep(ul ul ul) {\n\tlist-style-type: square;\n}\n\n.cn-text-widget :deep(li) {\n\tdisplay: list-item;\n}\n\n/* Nextcloud's server CSS flattens heading sizes (e.g. h1 → 100%, so it fell\n back to the ~14px body size while h2 stayed 1.8em), leaving them oddly\n scaled. Apply a consistent em-based scale that grows with the widget's own\n font size. */\n.cn-text-widget :deep(h1) {\n\tfont-size: 2em;\n}\n\n.cn-text-widget :deep(h2) {\n\tfont-size: 1.5em;\n}\n\n.cn-text-widget :deep(h3) {\n\tfont-size: 1.25em;\n}\n\n.cn-text-widget :deep(h4) {\n\tfont-size: 1.1em;\n}\n\n.cn-text-widget :deep(h5) {\n\tfont-size: 1em;\n}\n\n.cn-text-widget :deep(h6) {\n\tfont-size: 0.85em;\n}\n\n.cn-text-widget__content--markdown :deep(h1),\n.cn-text-widget__content--markdown :deep(h2),\n.cn-text-widget__content--markdown :deep(h3),\n.cn-text-widget__content--markdown :deep(h4),\n.cn-text-widget__content--markdown :deep(h5),\n.cn-text-widget__content--markdown :deep(h6) {\n\tmargin: 8px 0 4px;\n\tfont-weight: 600;\n\tline-height: 1.3;\n}\n\n.cn-text-widget__content--markdown :deep(p),\n.cn-text-widget__content--markdown :deep(ul),\n.cn-text-widget__content--markdown :deep(ol),\n.cn-text-widget__content--markdown :deep(blockquote) {\n\tmargin: 4px 0;\n}\n\n.cn-text-widget__content--markdown :deep(code) {\n\tpadding: 1px 4px;\n\tborder-radius: 3px;\n\tbackground: var(--color-background-hover);\n\tfont-family: var(--font-monospace, monospace);\n\tfont-size: 0.95em;\n}\n\n.cn-text-widget__content--markdown :deep(pre) {\n\tpadding: 8px;\n\tborder-radius: var(--border-radius);\n\tbackground: var(--color-background-hover);\n\toverflow: auto;\n}\n\n.cn-text-widget__content--markdown :deep(pre) :deep(code) {\n\tpadding: 0;\n\tbackground: transparent;\n}\n\n.cn-text-widget__content--markdown :deep(blockquote) {\n\tpadding-left: 8px;\n\tborder-left: 3px solid var(--color-border);\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-text-widget__content--markdown :deep(table) {\n\tborder-collapse: collapse;\n\tmargin: 4px 0;\n}\n\n.cn-text-widget__content--markdown :deep(th),\n.cn-text-widget__content--markdown :deep(td) {\n\tpadding: 4px 8px;\n\tborder: 1px solid var(--color-border);\n}\n\n.cn-text-widget__table {\n\tborder-collapse: collapse;\n\twidth: 100%;\n}\n\n.cn-text-widget__table th,\n.cn-text-widget__table td {\n\toverflow-wrap: break-word;\n\tvertical-align: top;\n}\n\n.cn-text-widget__cell-placeholder {\n\tcolor: var(--color-text-maxcontrast);\n\tfont-style: italic;\n}\n\n.cn-text-widget__link {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tgap: 2px;\n\tfont-size: 14px;\n\tfont-weight: 600;\n\tcolor: var(--color-primary-element);\n\ttext-decoration: none;\n}\n\n.cn-text-widget__link:hover,\n.cn-text-widget__link:focus-visible {\n\ttext-decoration: underline;\n}\n</style>\n"],"names":["t"],"mappings":";;;;;;;AAyFA;AACA;AACA;AACA;AACA,MAAM,cAAa,GAAI,IAAI,MAAM,CAAC;AACjC,CAAA,GAAG,EAAE,IAAI;CACT,MAAM,EAAE,KAAK;AACd,CAAC;;AAED;AACA;AACA;AACA;AACA,IAAI,cAAa,GAAI;AACrB,SAAS,mBAAmB,GAAG;AAC9B,CAAA,IAAI,cAAc,EAAE;EACnB;AACD,CAAA;CACA,SAAS,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC,IAAI,KAAK;AACtD,EAAA,IAAI,IAAI,CAAC,OAAM,KAAM,GAAE,IAAK,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAA,KAAM,QAAQ,EAAE;AACrE,GAAA,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,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AAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI;EACpD,CAAC;;AAED;AACC;AACA;AACA;AACA;;AAED,EAAA,WAAW,CAAC,IAAI,EAAE;GACjB,OAAO,OAAO,IAAI,EAAE,IAAG,KAAM,QAAO,IAAK,IAAI,CAAC,IAAI,CAAC,IAAI,EAAC,KAAM;EAC/D,CAAC;;AAED;AACC;AACA;AACA;AACA;;AAED,EAAA,aAAa,CAAC,IAAI,EAAE;AACnB,GAAA,OAAO;IACN,YAAY,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,KAAK,MAAM;AACnD,IAAA,MAAM,EAAE,+BAA+B;IACvC,OAAO,EAAE,KAAK;AACf;EACD,CAAC;;AAED;AACC;AACA;AACA;AACA;;AAED,EAAA,eAAe,CAAC,IAAI,EAAE;AACrB,GAAA,OAAO;IACN,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;IAC3B,kBAAkB,EAAE,+BAA+B;AACnD,IAAA,aAAa,EAAE,MAAM;AACtB;EACD,CAAC;EACD;AACF;;"}
|
|
1
|
+
{"version":3,"file":"CnTextWidget2.vue.js","sources":["../../../../src/components/CnTextWidget/CnTextWidget.vue"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div class=\"cn-text-widget\" :style=\"wrapperStyle\">\n\t\t<table\n\t\t\tv-if=\"tableMode\"\n\t\t\tclass=\"cn-text-widget__table\"\n\t\t\t:style=\"tableContainerStyle\">\n\t\t\t<tbody>\n\t\t\t\t<tr v-for=\"(row, rIdx) in tableRows\" :key=\"`r-${rIdx}`\">\n\t\t\t\t\t<template v-for=\"(cell, cIdx) in row\">\n\t\t\t\t\t\t<th\n\t\t\t\t\t\t\tv-if=\"isHeaderCell(rIdx)\"\n\t\t\t\t\t\t\tv-show=\"!isPlaceholderCellAt(rIdx, cIdx)\"\n\t\t\t\t\t\t\t:key=\"`c-${rIdx}-${cIdx}`\"\n\t\t\t\t\t\t\t:rowspan=\"cell.rowSpan || 1\"\n\t\t\t\t\t\t\t:colspan=\"cell.colSpan || 1\"\n\t\t\t\t\t\t\t:style=\"headerCellStyle(cIdx)\">\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-if=\"cellHasText(cell)\"\n\t\t\t\t\t\t\t\tv-html=\"sanitizeCell(cell.text)\" /><!-- eslint-disable-line vue/no-v-html -->\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\t\tclass=\"cn-text-widget__cell-placeholder\">\n\t\t\t\t\t\t\t\t{{ emptyCellPlaceholder }}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</th>\n\t\t\t\t\t\t<td\n\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\tv-show=\"!isPlaceholderCellAt(rIdx, cIdx)\"\n\t\t\t\t\t\t\t:key=\"`c-${rIdx}-${cIdx}`\"\n\t\t\t\t\t\t\t:rowspan=\"cell.rowSpan || 1\"\n\t\t\t\t\t\t\t:colspan=\"cell.colSpan || 1\"\n\t\t\t\t\t\t\t:style=\"dataCellStyle(cIdx)\">\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-if=\"cellHasText(cell)\"\n\t\t\t\t\t\t\t\tv-html=\"sanitizeCell(cell.text)\" /><!-- eslint-disable-line vue/no-v-html -->\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\t\tclass=\"cn-text-widget__cell-placeholder\">\n\t\t\t\t\t\t\t\t{{ emptyCellPlaceholder }}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</template>\n\t\t\t\t</tr>\n\t\t\t</tbody>\n\t\t</table>\n\t\t<pre\n\t\t\tv-else-if=\"monospace && hasText\"\n\t\t\tclass=\"cn-text-widget__mono\"\n\t\t\tdata-testid=\"cn-text-widget-mono\"\n\t\t\t:style=\"monoStyle\">{{ text }}</pre>\n\t\t<div\n\t\t\tv-else-if=\"hasText\"\n\t\t\tclass=\"cn-text-widget__content\"\n\t\t\t:class=\"contentClass\"\n\t\t\t:style=\"contentStyle\"\n\t\t\tv-html=\"sanitizedHtml\" /><!-- eslint-disable-line vue/no-v-html -->\n\t\t<span\n\t\t\tv-else\n\t\t\tclass=\"cn-text-widget__placeholder\"\n\t\t\t:style=\"contentStyle\">\n\t\t\t{{ placeholderText }}\n\t\t</span>\n\t\t<a\n\t\t\tv-if=\"link\"\n\t\t\tclass=\"cn-text-widget__link\"\n\t\t\tdata-testid=\"cn-text-widget-link\"\n\t\t\t:href=\"link.url\"\n\t\t\t:target=\"link.external ? '_blank' : null\"\n\t\t\t:rel=\"link.external ? 'noopener noreferrer' : null\"\n\t\t\t@click=\"openLink\">\n\t\t\t{{ link.label }}\n\t\t\t<ChevronRight :size=\"16\" />\n\t\t</a>\n\t</div>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport DOMPurify from 'dompurify'\nimport { Marked } from 'marked'\nimport ChevronRight from 'vue-material-design-icons/ChevronRight.vue'\nimport { followLinkClick, resolveHref } from '../../utils/linkNavigation.js'\nimport { isPlaceholderCell } from '../../utils/textTable.js'\n\n// Per-module `Marked` instance so configuration is scoped here and does NOT\n// mutate the global `marked` singleton (which would affect any other code in\n// the same app that imports `marked`). `gfm: true` enables tables; `breaks:\n// false` keeps CommonMark-strict newline behaviour.\nconst markedInstance = new Marked({\n\tgfm: true,\n\tbreaks: false,\n})\n\n// DOMPurify allow-list hook: author-supplied `target=_blank` links survive\n// sanitisation (we add `target` to ADD_ATTR below); the hook then appends\n// `rel=\"noopener noreferrer\"` to mitigate reverse-tabnabbing. The hook is\n// idempotent and registered once.\nlet hookRegistered = false\nfunction ensureDomPurifyHook() {\n\tif (hookRegistered) {\n\t\treturn\n\t}\n\tDOMPurify.addHook('afterSanitizeAttributes', (node) => {\n\t\tif (node.tagName === 'A' && node.getAttribute('target') === '_blank') {\n\t\t\tnode.setAttribute('rel', 'noopener noreferrer')\n\t\t}\n\t})\n\thookRegistered = true\n}\n\n// The widget's own sanitiser config: `target` survives (the hook above adds\n// `rel`), `data-*` attributes do not.\nconst SANITIZE_CONFIG = {\n\tADD_ATTR: ['target'],\n\tALLOW_DATA_ATTR: false,\n}\n\n/**\n * Sanitise author HTML with the widget's own config.\n *\n * @param {string} html The HTML.\n * @return {string} HTML safe for `v-html`.\n */\nfunction sanitize(html) {\n\tensureDomPurifyHook()\n\treturn DOMPurify.sanitize(html, SANITIZE_CONFIG)\n}\n\n/**\n * CnTextWidget — renders user-authored multi-line text (or a small table)\n * inside a dashboard cell. Text content is passed through DOMPurify before\n * injection via `v-html` so common formatting tags survive while XSS vectors\n * (`<script>`, `on*` attributes, `javascript:` URLs) are stripped.\n *\n * Persisted shape: `{text, fontSize, color, backgroundColor, textAlign,\n * contentMode, tableMode, tableData}`. Defaults: `fontSize='14px'`,\n * `color='var(--color-main-text)'`, `backgroundColor='transparent'`,\n * `textAlign='left'`. `contentMode` absent means the legacy `'html'` branch;\n * the literal `'markdown'` parses via marked (GFM tables) then sanitises\n * through the same allow-list — a single trust boundary protects both modes.\n *\n * When `tableMode === true`, the renderer draws an HTML `<table>` from\n * `tableData` instead: header rows promote row 0 to `<th>`, per-column\n * alignment is applied inline, and `colSpan` / `rowSpan` become native HTML\n * attributes. Merge-swallowed cells are hidden via `v-show` so the visual\n * grid stays rectangular.\n *\n * With `monospace: true` the text is shown as typed, in a fixed-width font\n * with its spaces and line breaks kept, and is never parsed as HTML or\n * markdown: a receipt or a log line. `textField` reads the text from that\n * field of the detail page's object instead of `text`.\n *\n * Registered as the `text` dashboard widget type via the renderer's\n * `index.js`.\n */\nexport default {\n\tname: 'CnTextWidget',\n\n\tcomponents: { ChevronRight },\n\n\tinject: {\n\t\t/** The app's translate function, provided by CnAppRoot. Identity outside one. */\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * Persisted widget content blob: `{text, fontSize, color,\n\t\t * backgroundColor, textAlign, contentMode, tableMode, tableData, link,\n\t\t * monospace, textField}`.\n\t\t * All keys are optional; missing keys collapse to documented defaults.\n\t\t * `text` and `link.label` go through the app's translate function.\n\t\t * `link` is `{label, route}` (a page id, or a path starting with `/`) or\n\t\t * `{label, href}` (an external URL), drawn under the text.\n\t\t * `monospace` shows the text as typed in a fixed-width font;\n\t\t * `textField` reads the text from that field of `objectData`.\n\t\t *\n\t\t * @type {{text: string, fontSize: string, color: string, backgroundColor: string, textAlign: string, contentMode: string, tableMode: boolean, tableData: object, link: {label: string, route: string, href: string}, monospace: boolean, textField: string}}\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/** The detail page's object, which `content.textField` reads from. */\n\t\tobjectData: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * The text: `content.textField` of the object as it is, else\n\t\t * `content.text`; '' when absent. Plain text goes through the app's\n\t\t * translate function; text holding markup (`<`, `>`, `&`) is author\n\t\t * content and is shown as written, because the translate function\n\t\t * sanitises with its own allow-list (which drops `target`).\n\t\t *\n\t\t * @spec openspec/changes/text-widget-monospace/tasks.md#task-2\n\t\t */\n\t\ttext() {\n\t\t\tconst field = this.content?.textField\n\t\t\tif (typeof field === 'string' && field !== '') {\n\t\t\t\tconst value = this.objectData?.[field]\n\t\t\t\treturn value === undefined || value === null ? '' : String(value)\n\t\t\t}\n\t\t\tconst text = this.content?.text\n\t\t\tif (typeof text !== 'string') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\treturn /[<>&]/.test(text) ? text : this.tr(text)\n\t\t},\n\n\t\t/**\n\t\t * Whether the text shows as typed, in a fixed-width font.\n\t\t *\n\t\t * @spec openspec/changes/text-widget-monospace/tasks.md#task-1\n\t\t */\n\t\tmonospace() {\n\t\t\treturn this.content?.monospace === true\n\t\t},\n\n\t\t/** Inline style for the fixed-width text. */\n\t\tmonoStyle() {\n\t\t\treturn {\n\t\t\t\t'font-size': this.fontSize,\n\t\t\t\tcolor: this.color,\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The link under the text, from `content.link`: `{ label, route }`\n\t\t * (a page id, or a router path when it starts with `/`) or\n\t\t * `{ label, href }` (an external URL, opened in a new tab). The label\n\t\t * goes through the app's translate function. Null without a label or\n\t\t * a target.\n\t\t *\n\t\t * @return {{label: string, url: string, location: (object|null), external: boolean}|null} The link.\n\t\t */\n\t\tlink() {\n\t\t\tconst link = this.content?.link\n\t\t\tif (!link || typeof link !== 'object' || typeof link.label !== 'string' || link.label === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tif (typeof link.route === 'string' && link.route !== '') {\n\t\t\t\tconst location = link.route.startsWith('/') ? { path: link.route } : { name: link.route }\n\t\t\t\tconst url = resolveHref(location, this.$router)\n\t\t\t\treturn url ? { label: this.tr(link.label), url, location, external: false } : null\n\t\t\t}\n\t\t\tif (typeof link.href === 'string' && link.href !== '') {\n\t\t\t\treturn { label: this.tr(link.label), url: link.href, location: null, external: true }\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\n\t\t/** Whether the text has any non-whitespace content. */\n\t\thasText() {\n\t\t\treturn this.text.trim() !== ''\n\t\t},\n\n\t\t/** Resolved content mode — only `'markdown'` switches the branch. */\n\t\tcontentMode() {\n\t\t\treturn this.content?.contentMode === 'markdown' ? 'markdown' : 'html'\n\t\t},\n\n\t\t/** CSS class selecting the markdown vs html content-spacing rules. */\n\t\tcontentClass() {\n\t\t\treturn this.contentMode === 'markdown'\n\t\t\t\t? 'cn-text-widget__content--markdown'\n\t\t\t\t: 'cn-text-widget__content--html'\n\t\t},\n\n\t\t/**\n\t\t * The HTML to render: either the raw author HTML (sanitised) or the\n\t\t * markdown rendering of the author text (sanitised). Both branches go\n\t\t * through DOMPurify, which strips `<script>`, `<style>`, `<link>`,\n\t\t * `on*` attributes, and `javascript:` URLs.\n\t\t *\n\t\t * @return {string} sanitised HTML safe for `v-html` injection.\n\t\t */\n\t\tsanitizedHtml() {\n\t\t\tlet html\n\t\t\tif (this.contentMode === 'markdown') {\n\t\t\t\ttry {\n\t\t\t\t\thtml = markedInstance.parse(this.text)\n\t\t\t\t\tif (typeof html !== 'string') {\n\t\t\t\t\t\thtml = String(html)\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Defensive: fall back to the raw text rather than crash\n\t\t\t\t\t// the dashboard if the parser throws.\n\t\t\t\t\thtml = this.text\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\thtml = this.text\n\t\t\t}\n\t\t\treturn sanitize(html)\n\t\t},\n\n\t\t/** Localised placeholder shown when there is no text content. */\n\t\tplaceholderText() {\n\t\t\treturn t('nextcloud-vue', 'No text content')\n\t\t},\n\n\t\t/** Localised placeholder shown inside an empty table cell. */\n\t\temptyCellPlaceholder() {\n\t\t\treturn t('nextcloud-vue', 'Empty cell')\n\t\t},\n\n\t\t/** Resolved font size (default `14px`). */\n\t\tfontSize() {\n\t\t\treturn this.content?.fontSize || '14px'\n\t\t},\n\n\t\t/** Resolved text colour (default theme main text). */\n\t\tcolor() {\n\t\t\treturn this.content?.color || 'var(--color-main-text)'\n\t\t},\n\n\t\t/** Resolved background colour (default transparent). */\n\t\tbackgroundColor() {\n\t\t\treturn this.content?.backgroundColor || 'transparent'\n\t\t},\n\n\t\t/** Resolved text alignment (default `left`). */\n\t\ttextAlign() {\n\t\t\treturn this.content?.textAlign || 'left'\n\t\t},\n\n\t\t/** Whether the renderer is in table mode. */\n\t\ttableMode() {\n\t\t\treturn this.content?.tableMode === true\n\t\t},\n\n\t\t/** The persisted tableData object, or null. */\n\t\ttableData() {\n\t\t\treturn this.content?.tableData || null\n\t\t},\n\n\t\t/** The table rows array (empty when no table data). */\n\t\ttableRows() {\n\t\t\treturn Array.isArray(this.tableData?.rows) ? this.tableData.rows : []\n\t\t},\n\n\t\t/** Whether row 0 should render as a header row. */\n\t\theaderRow() {\n\t\t\treturn this.tableData?.headerRow === true\n\t\t},\n\n\t\t/** Per-column text-alignment array. */\n\t\tcolumnAlignments() {\n\t\t\tconst aligns = this.tableData?.columnAlignments\n\t\t\treturn Array.isArray(aligns) ? aligns : []\n\t\t},\n\n\t\t/** Inline style for the flex wrapper. */\n\t\twrapperStyle() {\n\t\t\treturn {\n\t\t\t\twidth: '100%',\n\t\t\t\theight: '100%',\n\t\t\t\tpadding: '16px',\n\t\t\t\tdisplay: 'flex',\n\t\t\t\t'align-items': 'safe center',\n\t\t\t\t'justify-content': 'safe center',\n\t\t\t\toverflow: 'auto',\n\t\t\t\t'background-color': this.backgroundColor,\n\t\t\t\t...(this.link ? { 'flex-direction': 'column', gap: '8px', 'align-items': 'flex-start' } : {}),\n\t\t\t}\n\t\t},\n\n\t\t/** Inline style for the text / placeholder content. */\n\t\tcontentStyle() {\n\t\t\tconst base = {\n\t\t\t\t'font-size': this.fontSize,\n\t\t\t\t'text-align': this.textAlign,\n\t\t\t\tcolor: this.color,\n\t\t\t\twidth: '100%',\n\t\t\t\t'overflow-wrap': 'break-word',\n\t\t\t}\n\t\t\tif (!this.hasText) {\n\t\t\t\tbase['font-style'] = 'italic'\n\t\t\t\tbase.color = 'var(--color-text-maxcontrast)'\n\t\t\t}\n\t\t\treturn base\n\t\t},\n\n\t\t/** Inline style for the table container. */\n\t\ttableContainerStyle() {\n\t\t\treturn {\n\t\t\t\t'font-size': this.fontSize,\n\t\t\t\tcolor: this.color,\n\t\t\t\twidth: '100%',\n\t\t\t}\n\t\t},\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * A manifest string through the app's translate function.\n\t\t *\n\t\t * @param {string} text The string.\n\t\t * @return {string} The translated string.\n\t\t */\n\t\ttr(text) {\n\t\t\treturn typeof this.cnTranslate === 'function' ? this.cnTranslate(text) : text\n\t\t},\n\n\t\t/**\n\t\t * Route a plain click on an in-app link, so the page does not reload.\n\t\t *\n\t\t * @param {MouseEvent} event The click.\n\t\t */\n\t\topenLink(event) {\n\t\t\tif (this.link && !this.link.external) {\n\t\t\t\tfollowLinkClick(event, this.link.location, this.$router)\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Run cell text through DOMPurify so the table-mode render path has\n\t\t * the same XSS-stripping guarantees as the text-mode path.\n\t\t *\n\t\t * @param {string} text raw cell text (may contain HTML).\n\t\t * @return {string} sanitised HTML safe to render via `v-html`.\n\t\t */\n\t\tsanitizeCell(text) {\n\t\t\treturn sanitize(typeof text === 'string' ? text : '')\n\t\t},\n\n\t\t/**\n\t\t * Whether the given row index renders as `<th>` (header row).\n\t\t *\n\t\t * @param {number} rIdx the 0-based row index.\n\t\t * @return {boolean} true when row 0 and the header flag is set.\n\t\t */\n\t\tisHeaderCell(rIdx) {\n\t\t\treturn this.headerRow && rIdx === 0\n\t\t},\n\n\t\t/**\n\t\t * Whether a cell is covered by another cell's `rowSpan` / `colSpan`\n\t\t * and so must be hidden to keep the grid rectangular.\n\t\t *\n\t\t * @param {number} rIdx the row index.\n\t\t * @param {number} cIdx the column index.\n\t\t * @return {boolean} true when the cell is a covered placeholder.\n\t\t */\n\t\tisPlaceholderCellAt(rIdx, cIdx) {\n\t\t\treturn isPlaceholderCell(this.tableRows, rIdx, cIdx)\n\t\t},\n\n\t\t/**\n\t\t * Whether a cell has any non-whitespace text.\n\t\t *\n\t\t * @param {object} cell the cell object.\n\t\t * @return {boolean} true when the cell has text.\n\t\t */\n\t\tcellHasText(cell) {\n\t\t\treturn typeof cell?.text === 'string' && cell.text.trim() !== ''\n\t\t},\n\n\t\t/**\n\t\t * Inline style for a data cell at a given column.\n\t\t *\n\t\t * @param {number} cIdx the column index.\n\t\t * @return {object} the cell style object.\n\t\t */\n\t\tdataCellStyle(cIdx) {\n\t\t\treturn {\n\t\t\t\t'text-align': this.columnAlignments[cIdx] || 'left',\n\t\t\t\tborder: '1px solid var(--color-border)',\n\t\t\t\tpadding: '8px',\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Inline style for a header cell at a given column.\n\t\t *\n\t\t * @param {number} cIdx the column index.\n\t\t * @return {object} the header cell style object.\n\t\t */\n\t\theaderCellStyle(cIdx) {\n\t\t\treturn {\n\t\t\t\t...this.dataCellStyle(cIdx),\n\t\t\t\t'background-color': 'var(--color-background-hover)',\n\t\t\t\t'font-weight': 'bold',\n\t\t\t}\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-text-widget {\n\twidth: 100%;\n\theight: 100%;\n}\n\n.cn-text-widget__mono {\n\twidth: 100%;\n\tmargin: 0;\n\tpadding: 12px;\n\tfont-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;\n\tline-height: 1.4;\n\twhite-space: pre-wrap;\n\toverflow-wrap: anywhere;\n\ttext-align: start;\n\tbackground: var(--color-background-dark);\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius);\n}\n\n.cn-text-widget__content,\n.cn-text-widget__placeholder {\n\t/* Safety net — ensures long URLs / words inside the sanitised HTML wrap\n\t rather than overflowing horizontally. */\n\toverflow-wrap: break-word;\n\tmax-width: 100%;\n}\n\n/* Restore inline-emphasis semantics inside rendered content. Nextcloud's\n server CSS styles bare <em> as muted (var(--color-text-maxcontrast)) and can\n drop the italic, so `_x_` / `**_x_**` looked greyed-out and non-italic. Force\n italic <em> / bold <strong> that inherit the widget's own text colour. */\n.cn-text-widget :deep(em),\n.cn-text-widget :deep(i) {\n\tfont-style: italic;\n\tcolor: inherit;\n}\n\n.cn-text-widget :deep(strong),\n.cn-text-widget :deep(b) {\n\tfont-weight: bold;\n\tcolor: inherit;\n}\n\n/* Nextcloud's server CSS strips list markers/indent (`list-style: none`,\n no padding), so rendered `<ul>`/`<ol>` looked like plain text. Restore\n bullets/numbers and indentation, including nested levels. */\n.cn-text-widget :deep(ul),\n.cn-text-widget :deep(ol) {\n\tmargin: 4px 0;\n\tpadding-left: 1.5em;\n}\n\n.cn-text-widget :deep(ul) {\n\tlist-style: disc outside;\n}\n\n.cn-text-widget :deep(ol) {\n\tlist-style: decimal outside;\n}\n\n.cn-text-widget :deep(ul ul) {\n\tlist-style-type: circle;\n}\n\n.cn-text-widget :deep(ul ul ul) {\n\tlist-style-type: square;\n}\n\n.cn-text-widget :deep(li) {\n\tdisplay: list-item;\n}\n\n/* Nextcloud's server CSS flattens heading sizes (e.g. h1 → 100%, so it fell\n back to the ~14px body size while h2 stayed 1.8em), leaving them oddly\n scaled. Apply a consistent em-based scale that grows with the widget's own\n font size. */\n.cn-text-widget :deep(h1) {\n\tfont-size: 2em;\n}\n\n.cn-text-widget :deep(h2) {\n\tfont-size: 1.5em;\n}\n\n.cn-text-widget :deep(h3) {\n\tfont-size: 1.25em;\n}\n\n.cn-text-widget :deep(h4) {\n\tfont-size: 1.1em;\n}\n\n.cn-text-widget :deep(h5) {\n\tfont-size: 1em;\n}\n\n.cn-text-widget :deep(h6) {\n\tfont-size: 0.85em;\n}\n\n.cn-text-widget__content--markdown :deep(h1),\n.cn-text-widget__content--markdown :deep(h2),\n.cn-text-widget__content--markdown :deep(h3),\n.cn-text-widget__content--markdown :deep(h4),\n.cn-text-widget__content--markdown :deep(h5),\n.cn-text-widget__content--markdown :deep(h6) {\n\tmargin: 8px 0 4px;\n\tfont-weight: 600;\n\tline-height: 1.3;\n}\n\n.cn-text-widget__content--markdown :deep(p),\n.cn-text-widget__content--markdown :deep(ul),\n.cn-text-widget__content--markdown :deep(ol),\n.cn-text-widget__content--markdown :deep(blockquote) {\n\tmargin: 4px 0;\n}\n\n.cn-text-widget__content--markdown :deep(code) {\n\tpadding: 1px 4px;\n\tborder-radius: 3px;\n\tbackground: var(--color-background-hover);\n\tfont-family: var(--font-monospace, monospace);\n\tfont-size: 0.95em;\n}\n\n.cn-text-widget__content--markdown :deep(pre) {\n\tpadding: 8px;\n\tborder-radius: var(--border-radius);\n\tbackground: var(--color-background-hover);\n\toverflow: auto;\n}\n\n.cn-text-widget__content--markdown :deep(pre) :deep(code) {\n\tpadding: 0;\n\tbackground: transparent;\n}\n\n.cn-text-widget__content--markdown :deep(blockquote) {\n\tpadding-left: 8px;\n\tborder-left: 3px solid var(--color-border);\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-text-widget__content--markdown :deep(table) {\n\tborder-collapse: collapse;\n\tmargin: 4px 0;\n}\n\n.cn-text-widget__content--markdown :deep(th),\n.cn-text-widget__content--markdown :deep(td) {\n\tpadding: 4px 8px;\n\tborder: 1px solid var(--color-border);\n}\n\n.cn-text-widget__table {\n\tborder-collapse: collapse;\n\twidth: 100%;\n}\n\n.cn-text-widget__table th,\n.cn-text-widget__table td {\n\toverflow-wrap: break-word;\n\tvertical-align: top;\n}\n\n.cn-text-widget__cell-placeholder {\n\tcolor: var(--color-text-maxcontrast);\n\tfont-style: italic;\n}\n\n.cn-text-widget__link {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tgap: 2px;\n\tfont-size: 14px;\n\tfont-weight: 600;\n\tcolor: var(--color-primary-element);\n\ttext-decoration: none;\n}\n\n.cn-text-widget__link:hover,\n.cn-text-widget__link:focus-visible {\n\ttext-decoration: underline;\n}\n</style>\n"],"names":["t"],"mappings":";;;;;;;AAyFA;AACA;AACA;AACA;AACA,MAAM,cAAa,GAAI,IAAI,MAAM,CAAC;AACjC,CAAA,GAAG,EAAE,IAAI;CACT,MAAM,EAAE,KAAK;AACd,CAAC;;AAED;AACA;AACA;AACA;AACA,IAAI,cAAa,GAAI;AACrB,SAAS,mBAAmB,GAAG;AAC9B,CAAA,IAAI,cAAc,EAAE;EACnB;AACD,CAAA;CACA,SAAS,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC,IAAI,KAAK;AACtD,EAAA,IAAI,IAAI,CAAC,OAAM,KAAM,GAAE,IAAK,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAA,KAAM,QAAQ,EAAE;AACrE,GAAA,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,qBAAqB;AAC/C,EAAA;CAC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,CAAC,IAAI,EAAE;GAClB,OAAO,IAAI,CAAC,SAAQ,IAAK,IAAG,KAAM;EACnC,CAAC;;AAED;;AAEC;AACA;AACA;AACA;;;AAGD,EAAA,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE;GAC/B,OAAO,iBAAiB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI;EACpD,CAAC;;AAED;AACC;AACA;AACA;AACA;;AAED,EAAA,WAAW,CAAC,IAAI,EAAE;GACjB,OAAO,OAAO,IAAI,EAAE,IAAG,KAAM,QAAO,IAAK,IAAI,CAAC,IAAI,CAAC,IAAI,EAAC,KAAM;EAC/D,CAAC;;AAED;AACC;AACA;AACA;AACA;;AAED,EAAA,aAAa,CAAC,IAAI,EAAE;AACnB,GAAA,OAAO;IACN,YAAY,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,KAAK,MAAM;AACnD,IAAA,MAAM,EAAE,+BAA+B;IACvC,OAAO,EAAE,KAAK;AACf;EACD,CAAC;;AAED;AACC;AACA;AACA;AACA;;AAED,EAAA,eAAe,CAAC,IAAI,EAAE;AACrB,GAAA,OAAO;IACN,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;IAC3B,kBAAkB,EAAE,+BAA+B;AACnD,IAAA,aAAa,EAAE,MAAM;AACtB;EACD,CAAC;EACD;AACF;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CnTextWidget3.vue.js","sources":["../../../../src/components/CnTextWidget/CnTextWidget.vue?vue&type=template&id=750bab5a&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div class=\"cn-text-widget\" :style=\"wrapperStyle\">\n\t\t<table\n\t\t\tv-if=\"tableMode\"\n\t\t\tclass=\"cn-text-widget__table\"\n\t\t\t:style=\"tableContainerStyle\">\n\t\t\t<tbody>\n\t\t\t\t<tr v-for=\"(row, rIdx) in tableRows\" :key=\"`r-${rIdx}`\">\n\t\t\t\t\t<template v-for=\"(cell, cIdx) in row\">\n\t\t\t\t\t\t<th\n\t\t\t\t\t\t\tv-if=\"isHeaderCell(rIdx)\"\n\t\t\t\t\t\t\tv-show=\"!isPlaceholderCellAt(rIdx, cIdx)\"\n\t\t\t\t\t\t\t:key=\"`c-${rIdx}-${cIdx}`\"\n\t\t\t\t\t\t\t:rowspan=\"cell.rowSpan || 1\"\n\t\t\t\t\t\t\t:colspan=\"cell.colSpan || 1\"\n\t\t\t\t\t\t\t:style=\"headerCellStyle(cIdx)\">\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-if=\"cellHasText(cell)\"\n\t\t\t\t\t\t\t\tv-html=\"sanitizeCell(cell.text)\" /><!-- eslint-disable-line vue/no-v-html -->\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\t\tclass=\"cn-text-widget__cell-placeholder\">\n\t\t\t\t\t\t\t\t{{ emptyCellPlaceholder }}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</th>\n\t\t\t\t\t\t<td\n\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\tv-show=\"!isPlaceholderCellAt(rIdx, cIdx)\"\n\t\t\t\t\t\t\t:key=\"`c-${rIdx}-${cIdx}`\"\n\t\t\t\t\t\t\t:rowspan=\"cell.rowSpan || 1\"\n\t\t\t\t\t\t\t:colspan=\"cell.colSpan || 1\"\n\t\t\t\t\t\t\t:style=\"dataCellStyle(cIdx)\">\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-if=\"cellHasText(cell)\"\n\t\t\t\t\t\t\t\tv-html=\"sanitizeCell(cell.text)\" /><!-- eslint-disable-line vue/no-v-html -->\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\t\tclass=\"cn-text-widget__cell-placeholder\">\n\t\t\t\t\t\t\t\t{{ emptyCellPlaceholder }}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</template>\n\t\t\t\t</tr>\n\t\t\t</tbody>\n\t\t</table>\n\t\t<pre\n\t\t\tv-else-if=\"monospace && hasText\"\n\t\t\tclass=\"cn-text-widget__mono\"\n\t\t\tdata-testid=\"cn-text-widget-mono\"\n\t\t\t:style=\"monoStyle\">{{ text }}</pre>\n\t\t<div\n\t\t\tv-else-if=\"hasText\"\n\t\t\tclass=\"cn-text-widget__content\"\n\t\t\t:class=\"contentClass\"\n\t\t\t:style=\"contentStyle\"\n\t\t\tv-html=\"sanitizedHtml\" /><!-- eslint-disable-line vue/no-v-html -->\n\t\t<span\n\t\t\tv-else\n\t\t\tclass=\"cn-text-widget__placeholder\"\n\t\t\t:style=\"contentStyle\">\n\t\t\t{{ placeholderText }}\n\t\t</span>\n\t\t<a\n\t\t\tv-if=\"link\"\n\t\t\tclass=\"cn-text-widget__link\"\n\t\t\tdata-testid=\"cn-text-widget-link\"\n\t\t\t:href=\"link.url\"\n\t\t\t:target=\"link.external ? '_blank' : null\"\n\t\t\t:rel=\"link.external ? 'noopener noreferrer' : null\"\n\t\t\t@click=\"openLink\">\n\t\t\t{{ link.label }}\n\t\t\t<ChevronRight :size=\"16\" />\n\t\t</a>\n\t</div>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport DOMPurify from 'dompurify'\nimport { Marked } from 'marked'\nimport ChevronRight from 'vue-material-design-icons/ChevronRight.vue'\nimport { followLinkClick, resolveHref } from '../../utils/linkNavigation.js'\nimport { isPlaceholderCell } from '../../utils/textTable.js'\n\n// Per-module `Marked` instance so configuration is scoped here and does NOT\n// mutate the global `marked` singleton (which would affect any other code in\n// the same app that imports `marked`). `gfm: true` enables tables; `breaks:\n// false` keeps CommonMark-strict newline behaviour.\nconst markedInstance = new Marked({\n\tgfm: true,\n\tbreaks: false,\n})\n\n// DOMPurify allow-list hook: author-supplied `target=_blank` links survive\n// sanitisation (we add `target` to ADD_ATTR below); the hook then appends\n// `rel=\"noopener noreferrer\"` to mitigate reverse-tabnabbing. The hook is\n// idempotent and registered once.\nlet hookRegistered = false\nfunction ensureDomPurifyHook() {\n\tif (hookRegistered) {\n\t\treturn\n\t}\n\tDOMPurify.addHook('afterSanitizeAttributes', (node) => {\n\t\tif (node.tagName === 'A' && node.getAttribute('target') === '_blank') {\n\t\t\tnode.setAttribute('rel', 'noopener noreferrer')\n\t\t}\n\t})\n\thookRegistered = true\n}\n\n/**\n * CnTextWidget — renders user-authored multi-line text (or a small table)\n * inside a dashboard cell. Text content is passed through DOMPurify before\n * injection via `v-html` so common formatting tags survive while XSS vectors\n * (`<script>`, `on*` attributes, `javascript:` URLs) are stripped.\n *\n * Persisted shape: `{text, fontSize, color, backgroundColor, textAlign,\n * contentMode, tableMode, tableData}`. Defaults: `fontSize='14px'`,\n * `color='var(--color-main-text)'`, `backgroundColor='transparent'`,\n * `textAlign='left'`. `contentMode` absent means the legacy `'html'` branch;\n * the literal `'markdown'` parses via marked (GFM tables) then sanitises\n * through the same allow-list — a single trust boundary protects both modes.\n *\n * When `tableMode === true`, the renderer draws an HTML `<table>` from\n * `tableData` instead: header rows promote row 0 to `<th>`, per-column\n * alignment is applied inline, and `colSpan` / `rowSpan` become native HTML\n * attributes. Merge-swallowed cells are hidden via `v-show` so the visual\n * grid stays rectangular.\n *\n * With `monospace: true` the text is shown as typed, in a fixed-width font\n * with its spaces and line breaks kept, and is never parsed as HTML or\n * markdown: a receipt or a log line. `textField` reads the text from that\n * field of the detail page's object instead of `text`.\n *\n * Registered as the `text` dashboard widget type via the renderer's\n * `index.js`.\n */\nexport default {\n\tname: 'CnTextWidget',\n\n\tcomponents: { ChevronRight },\n\n\tinject: {\n\t\t/** The app's translate function, provided by CnAppRoot. Identity outside one. */\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * Persisted widget content blob: `{text, fontSize, color,\n\t\t * backgroundColor, textAlign, contentMode, tableMode, tableData, link,\n\t\t * monospace, textField}`.\n\t\t * All keys are optional; missing keys collapse to documented defaults.\n\t\t * `text` and `link.label` go through the app's translate function.\n\t\t * `link` is `{label, route}` (a page id, or a path starting with `/`) or\n\t\t * `{label, href}` (an external URL), drawn under the text.\n\t\t * `monospace` shows the text as typed in a fixed-width font;\n\t\t * `textField` reads the text from that field of `objectData`.\n\t\t *\n\t\t * @type {{text: string, fontSize: string, color: string, backgroundColor: string, textAlign: string, contentMode: string, tableMode: boolean, tableData: object, link: {label: string, route: string, href: string}, monospace: boolean, textField: string}}\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/** The detail page's object, which `content.textField` reads from. */\n\t\tobjectData: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * The text: `content.textField` of the object as it is, else `content.text` translated; '' when absent.\n\t\t *\n\t\t * @spec openspec/changes/text-widget-monospace/tasks.md#task-2\n\t\t */\n\t\ttext() {\n\t\t\tconst field = this.content?.textField\n\t\t\tif (typeof field === 'string' && field !== '') {\n\t\t\t\tconst value = this.objectData?.[field]\n\t\t\t\treturn value === undefined || value === null ? '' : String(value)\n\t\t\t}\n\t\t\treturn typeof this.content?.text === 'string' ? this.tr(this.content.text) : ''\n\t\t},\n\n\t\t/**\n\t\t * Whether the text shows as typed, in a fixed-width font.\n\t\t *\n\t\t * @spec openspec/changes/text-widget-monospace/tasks.md#task-1\n\t\t */\n\t\tmonospace() {\n\t\t\treturn this.content?.monospace === true\n\t\t},\n\n\t\t/** Inline style for the fixed-width text. */\n\t\tmonoStyle() {\n\t\t\treturn {\n\t\t\t\t'font-size': this.fontSize,\n\t\t\t\tcolor: this.color,\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The link under the text, from `content.link`: `{ label, route }`\n\t\t * (a page id, or a router path when it starts with `/`) or\n\t\t * `{ label, href }` (an external URL, opened in a new tab). The label\n\t\t * goes through the app's translate function. Null without a label or\n\t\t * a target.\n\t\t *\n\t\t * @return {{label: string, url: string, location: (object|null), external: boolean}|null} The link.\n\t\t */\n\t\tlink() {\n\t\t\tconst link = this.content?.link\n\t\t\tif (!link || typeof link !== 'object' || typeof link.label !== 'string' || link.label === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tif (typeof link.route === 'string' && link.route !== '') {\n\t\t\t\tconst location = link.route.startsWith('/') ? { path: link.route } : { name: link.route }\n\t\t\t\tconst url = resolveHref(location, this.$router)\n\t\t\t\treturn url ? { label: this.tr(link.label), url, location, external: false } : null\n\t\t\t}\n\t\t\tif (typeof link.href === 'string' && link.href !== '') {\n\t\t\t\treturn { label: this.tr(link.label), url: link.href, location: null, external: true }\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\n\t\t/** Whether the text has any non-whitespace content. */\n\t\thasText() {\n\t\t\treturn this.text.trim() !== ''\n\t\t},\n\n\t\t/** Resolved content mode — only `'markdown'` switches the branch. */\n\t\tcontentMode() {\n\t\t\treturn this.content?.contentMode === 'markdown' ? 'markdown' : 'html'\n\t\t},\n\n\t\t/** CSS class selecting the markdown vs html content-spacing rules. */\n\t\tcontentClass() {\n\t\t\treturn this.contentMode === 'markdown'\n\t\t\t\t? 'cn-text-widget__content--markdown'\n\t\t\t\t: 'cn-text-widget__content--html'\n\t\t},\n\n\t\t/**\n\t\t * The HTML to render: either the raw author HTML (sanitised) or the\n\t\t * markdown rendering of the author text (sanitised). Both branches go\n\t\t * through DOMPurify, which strips `<script>`, `<style>`, `<link>`,\n\t\t * `on*` attributes, and `javascript:` URLs.\n\t\t *\n\t\t * @return {string} sanitised HTML safe for `v-html` injection.\n\t\t */\n\t\tsanitizedHtml() {\n\t\t\tlet html\n\t\t\tif (this.contentMode === 'markdown') {\n\t\t\t\ttry {\n\t\t\t\t\thtml = markedInstance.parse(this.text)\n\t\t\t\t\tif (typeof html !== 'string') {\n\t\t\t\t\t\thtml = String(html)\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Defensive: fall back to the raw text rather than crash\n\t\t\t\t\t// the dashboard if the parser throws.\n\t\t\t\t\thtml = this.text\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\thtml = this.text\n\t\t\t}\n\t\t\treturn DOMPurify.sanitize(html, {\n\t\t\t\tADD_ATTR: ['target'],\n\t\t\t})\n\t\t},\n\n\t\t/** Localised placeholder shown when there is no text content. */\n\t\tplaceholderText() {\n\t\t\treturn t('nextcloud-vue', 'No text content')\n\t\t},\n\n\t\t/** Localised placeholder shown inside an empty table cell. */\n\t\temptyCellPlaceholder() {\n\t\t\treturn t('nextcloud-vue', 'Empty cell')\n\t\t},\n\n\t\t/** Resolved font size (default `14px`). */\n\t\tfontSize() {\n\t\t\treturn this.content?.fontSize || '14px'\n\t\t},\n\n\t\t/** Resolved text colour (default theme main text). */\n\t\tcolor() {\n\t\t\treturn this.content?.color || 'var(--color-main-text)'\n\t\t},\n\n\t\t/** Resolved background colour (default transparent). */\n\t\tbackgroundColor() {\n\t\t\treturn this.content?.backgroundColor || 'transparent'\n\t\t},\n\n\t\t/** Resolved text alignment (default `left`). */\n\t\ttextAlign() {\n\t\t\treturn this.content?.textAlign || 'left'\n\t\t},\n\n\t\t/** Whether the renderer is in table mode. */\n\t\ttableMode() {\n\t\t\treturn this.content?.tableMode === true\n\t\t},\n\n\t\t/** The persisted tableData object, or null. */\n\t\ttableData() {\n\t\t\treturn this.content?.tableData || null\n\t\t},\n\n\t\t/** The table rows array (empty when no table data). */\n\t\ttableRows() {\n\t\t\treturn Array.isArray(this.tableData?.rows) ? this.tableData.rows : []\n\t\t},\n\n\t\t/** Whether row 0 should render as a header row. */\n\t\theaderRow() {\n\t\t\treturn this.tableData?.headerRow === true\n\t\t},\n\n\t\t/** Per-column text-alignment array. */\n\t\tcolumnAlignments() {\n\t\t\tconst aligns = this.tableData?.columnAlignments\n\t\t\treturn Array.isArray(aligns) ? aligns : []\n\t\t},\n\n\t\t/** Inline style for the flex wrapper. */\n\t\twrapperStyle() {\n\t\t\treturn {\n\t\t\t\twidth: '100%',\n\t\t\t\theight: '100%',\n\t\t\t\tpadding: '16px',\n\t\t\t\tdisplay: 'flex',\n\t\t\t\t'align-items': 'center',\n\t\t\t\t'justify-content': 'center',\n\t\t\t\toverflow: 'auto',\n\t\t\t\t'background-color': this.backgroundColor,\n\t\t\t\t...(this.link ? { 'flex-direction': 'column', gap: '8px', 'align-items': 'flex-start' } : {}),\n\t\t\t}\n\t\t},\n\n\t\t/** Inline style for the text / placeholder content. */\n\t\tcontentStyle() {\n\t\t\tconst base = {\n\t\t\t\t'font-size': this.fontSize,\n\t\t\t\t'text-align': this.textAlign,\n\t\t\t\tcolor: this.color,\n\t\t\t\twidth: '100%',\n\t\t\t\t'overflow-wrap': 'break-word',\n\t\t\t}\n\t\t\tif (!this.hasText) {\n\t\t\t\tbase['font-style'] = 'italic'\n\t\t\t\tbase.color = 'var(--color-text-maxcontrast)'\n\t\t\t}\n\t\t\treturn base\n\t\t},\n\n\t\t/** Inline style for the table container. */\n\t\ttableContainerStyle() {\n\t\t\treturn {\n\t\t\t\t'font-size': this.fontSize,\n\t\t\t\tcolor: this.color,\n\t\t\t\twidth: '100%',\n\t\t\t}\n\t\t},\n\t},\n\n\tcreated() {\n\t\tensureDomPurifyHook()\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * A manifest string through the app's translate function.\n\t\t *\n\t\t * @param {string} text The string.\n\t\t * @return {string} The translated string.\n\t\t */\n\t\ttr(text) {\n\t\t\treturn typeof this.cnTranslate === 'function' ? this.cnTranslate(text) : text\n\t\t},\n\n\t\t/**\n\t\t * Route a plain click on an in-app link, so the page does not reload.\n\t\t *\n\t\t * @param {MouseEvent} event The click.\n\t\t */\n\t\topenLink(event) {\n\t\t\tif (this.link && !this.link.external) {\n\t\t\t\tfollowLinkClick(event, this.link.location, this.$router)\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Run cell text through DOMPurify so the table-mode render path has\n\t\t * the same XSS-stripping guarantees as the text-mode path.\n\t\t *\n\t\t * @param {string} text raw cell text (may contain HTML).\n\t\t * @return {string} sanitised HTML safe to render via `v-html`.\n\t\t */\n\t\tsanitizeCell(text) {\n\t\t\treturn DOMPurify.sanitize(typeof text === 'string' ? text : '')\n\t\t},\n\n\t\t/**\n\t\t * Whether the given row index renders as `<th>` (header row).\n\t\t *\n\t\t * @param {number} rIdx the 0-based row index.\n\t\t * @return {boolean} true when row 0 and the header flag is set.\n\t\t */\n\t\tisHeaderCell(rIdx) {\n\t\t\treturn this.headerRow && rIdx === 0\n\t\t},\n\n\t\t/**\n\t\t * Whether a cell is covered by another cell's `rowSpan` / `colSpan`\n\t\t * and so must be hidden to keep the grid rectangular.\n\t\t *\n\t\t * @param {number} rIdx the row index.\n\t\t * @param {number} cIdx the column index.\n\t\t * @return {boolean} true when the cell is a covered placeholder.\n\t\t */\n\t\tisPlaceholderCellAt(rIdx, cIdx) {\n\t\t\treturn isPlaceholderCell(this.tableRows, rIdx, cIdx)\n\t\t},\n\n\t\t/**\n\t\t * Whether a cell has any non-whitespace text.\n\t\t *\n\t\t * @param {object} cell the cell object.\n\t\t * @return {boolean} true when the cell has text.\n\t\t */\n\t\tcellHasText(cell) {\n\t\t\treturn typeof cell?.text === 'string' && cell.text.trim() !== ''\n\t\t},\n\n\t\t/**\n\t\t * Inline style for a data cell at a given column.\n\t\t *\n\t\t * @param {number} cIdx the column index.\n\t\t * @return {object} the cell style object.\n\t\t */\n\t\tdataCellStyle(cIdx) {\n\t\t\treturn {\n\t\t\t\t'text-align': this.columnAlignments[cIdx] || 'left',\n\t\t\t\tborder: '1px solid var(--color-border)',\n\t\t\t\tpadding: '8px',\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Inline style for a header cell at a given column.\n\t\t *\n\t\t * @param {number} cIdx the column index.\n\t\t * @return {object} the header cell style object.\n\t\t */\n\t\theaderCellStyle(cIdx) {\n\t\t\treturn {\n\t\t\t\t...this.dataCellStyle(cIdx),\n\t\t\t\t'background-color': 'var(--color-background-hover)',\n\t\t\t\t'font-weight': 'bold',\n\t\t\t}\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-text-widget {\n\twidth: 100%;\n\theight: 100%;\n}\n\n.cn-text-widget__mono {\n\twidth: 100%;\n\tmargin: 0;\n\tpadding: 12px;\n\tfont-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;\n\tline-height: 1.4;\n\twhite-space: pre-wrap;\n\toverflow-wrap: anywhere;\n\ttext-align: start;\n\tbackground: var(--color-background-dark);\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius);\n}\n\n.cn-text-widget__content,\n.cn-text-widget__placeholder {\n\t/* Safety net — ensures long URLs / words inside the sanitised HTML wrap\n\t rather than overflowing horizontally. */\n\toverflow-wrap: break-word;\n\tmax-width: 100%;\n}\n\n/* Restore inline-emphasis semantics inside rendered content. Nextcloud's\n server CSS styles bare <em> as muted (var(--color-text-maxcontrast)) and can\n drop the italic, so `_x_` / `**_x_**` looked greyed-out and non-italic. Force\n italic <em> / bold <strong> that inherit the widget's own text colour. */\n.cn-text-widget :deep(em),\n.cn-text-widget :deep(i) {\n\tfont-style: italic;\n\tcolor: inherit;\n}\n\n.cn-text-widget :deep(strong),\n.cn-text-widget :deep(b) {\n\tfont-weight: bold;\n\tcolor: inherit;\n}\n\n/* Nextcloud's server CSS strips list markers/indent (`list-style: none`,\n no padding), so rendered `<ul>`/`<ol>` looked like plain text. Restore\n bullets/numbers and indentation, including nested levels. */\n.cn-text-widget :deep(ul),\n.cn-text-widget :deep(ol) {\n\tmargin: 4px 0;\n\tpadding-left: 1.5em;\n}\n\n.cn-text-widget :deep(ul) {\n\tlist-style: disc outside;\n}\n\n.cn-text-widget :deep(ol) {\n\tlist-style: decimal outside;\n}\n\n.cn-text-widget :deep(ul ul) {\n\tlist-style-type: circle;\n}\n\n.cn-text-widget :deep(ul ul ul) {\n\tlist-style-type: square;\n}\n\n.cn-text-widget :deep(li) {\n\tdisplay: list-item;\n}\n\n/* Nextcloud's server CSS flattens heading sizes (e.g. h1 → 100%, so it fell\n back to the ~14px body size while h2 stayed 1.8em), leaving them oddly\n scaled. Apply a consistent em-based scale that grows with the widget's own\n font size. */\n.cn-text-widget :deep(h1) {\n\tfont-size: 2em;\n}\n\n.cn-text-widget :deep(h2) {\n\tfont-size: 1.5em;\n}\n\n.cn-text-widget :deep(h3) {\n\tfont-size: 1.25em;\n}\n\n.cn-text-widget :deep(h4) {\n\tfont-size: 1.1em;\n}\n\n.cn-text-widget :deep(h5) {\n\tfont-size: 1em;\n}\n\n.cn-text-widget :deep(h6) {\n\tfont-size: 0.85em;\n}\n\n.cn-text-widget__content--markdown :deep(h1),\n.cn-text-widget__content--markdown :deep(h2),\n.cn-text-widget__content--markdown :deep(h3),\n.cn-text-widget__content--markdown :deep(h4),\n.cn-text-widget__content--markdown :deep(h5),\n.cn-text-widget__content--markdown :deep(h6) {\n\tmargin: 8px 0 4px;\n\tfont-weight: 600;\n\tline-height: 1.3;\n}\n\n.cn-text-widget__content--markdown :deep(p),\n.cn-text-widget__content--markdown :deep(ul),\n.cn-text-widget__content--markdown :deep(ol),\n.cn-text-widget__content--markdown :deep(blockquote) {\n\tmargin: 4px 0;\n}\n\n.cn-text-widget__content--markdown :deep(code) {\n\tpadding: 1px 4px;\n\tborder-radius: 3px;\n\tbackground: var(--color-background-hover);\n\tfont-family: var(--font-monospace, monospace);\n\tfont-size: 0.95em;\n}\n\n.cn-text-widget__content--markdown :deep(pre) {\n\tpadding: 8px;\n\tborder-radius: var(--border-radius);\n\tbackground: var(--color-background-hover);\n\toverflow: auto;\n}\n\n.cn-text-widget__content--markdown :deep(pre) :deep(code) {\n\tpadding: 0;\n\tbackground: transparent;\n}\n\n.cn-text-widget__content--markdown :deep(blockquote) {\n\tpadding-left: 8px;\n\tborder-left: 3px solid var(--color-border);\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-text-widget__content--markdown :deep(table) {\n\tborder-collapse: collapse;\n\tmargin: 4px 0;\n}\n\n.cn-text-widget__content--markdown :deep(th),\n.cn-text-widget__content--markdown :deep(td) {\n\tpadding: 4px 8px;\n\tborder: 1px solid var(--color-border);\n}\n\n.cn-text-widget__table {\n\tborder-collapse: collapse;\n\twidth: 100%;\n}\n\n.cn-text-widget__table th,\n.cn-text-widget__table td {\n\toverflow-wrap: break-word;\n\tvertical-align: top;\n}\n\n.cn-text-widget__cell-placeholder {\n\tcolor: var(--color-text-maxcontrast);\n\tfont-style: italic;\n}\n\n.cn-text-widget__link {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tgap: 2px;\n\tfont-size: 14px;\n\tfont-weight: 600;\n\tcolor: var(--color-primary-element);\n\ttext-decoration: none;\n}\n\n.cn-text-widget__link:hover,\n.cn-text-widget__link:focus-visible {\n\ttext-decoration: underline;\n}\n</style>\n"],"names":["_createElementBlock","_createElementVNode","_Fragment","_renderList","_normalizeStyle","_toDisplayString","_normalizeClass"],"mappings":";;;;;;AA+BQ,EAAA,KAAI,EAAA;;;;;;AAgBJ,EAAA,KAAA,EAAA;;;;;;;;uBApCLA,kBAAA;AAAG,IAAA,KAAG,EAAA,gBAAA;AAAA,IAAA,KAAA,iBAAA,QAAA,CAAA,YAAA;;KAEA,QAAA,CAAA,SAAS;yCAyCR,OAAA,EAAA;;AAxCJ,UAAA,KAAE,EAAA,uBAAA;eACC,iBAAE,QAAA,CAAA,mBAAmB;;UACvBC,kBAAA,CAqCI,OAAA,EAAA,IAAA,EAAA;iDADFC,QAAA,EAAA,IAAA,EAAAC,UAAA,CAnCqB,QAAA,CAAA,SAAE,EAAA,CAAhB,GAAG,EAAE,IAAI,KAAA;sDAmChB,IAAA,EAAA;AAnCuB,gBAAA,GAAA,OAAA,IAAA,CAAA;;qDAkChBD,QAAA,EAAA,IAAA,EAAAC,UAAA,CAjCkB,GAAA,EAAA,CAAX,IAAI,EAAC,IAAK,KA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A;;;;;;;;AAmBG,QAAA,CAAA,QAAA,CAAA,SAAO,IAAA,QAAA,CAAA,OAAA;wBADnBL,kBAAA,CAIqB,KAAA,EAAA;;AAFpB,YAAA,KAAK,EAAC,sBAAsB;AAC5B,YAAA,aAAW,EAAC,qBAAQ;AACnB,YAAA,KAAK,iBAAE,QAAA,CAAA,SAAS;6BAAG,QAAA,CAAA,IAAA,CAAA,EAAA,CAAA,mBAAA;WAEjB,QAAA,CAAA,OAAA;0BADHA,kBAAA,CAKoB,KAAA,EAAA;;cAHpB,KAAK,EAAAM,cAAA,CAAA,CAAA,yBAAA,EACG,QAAA,CAAA,YAAY,CAAA,CAAA;AACnB,cAAA,KAAK,iBAAE,QAAA,CAAA,YAAY,CAAA;AACpB,cAAA,SAAoB,EAAZ,QAAA,CAAA;;0BACTN,kBAAA,CAKO,MAAA,EAAA;;AAHN,cAAA,KAAK,EAAC,6BAAI;AACT,cAAA,KAAK,iBAAE,QAAA,CAAA,YAAY;+BACjB,QAAA,CAAA,eAAe,CAAA,EAAA,CAAA,mBAAA,CAAA;KAGZ,QAAA,CAAA,IAAI;sBADVA,kBAAA;;AAEA,UAAA,KAAK,EAAC,sBAAW;AACjB,UAAA,aAAW,EAAC,qBAAG;UACd,IAAI,EAAE,QAAA,CAAA,IAAI,CAAC,GAAG;UACd,MAAC,EAAA,QAAA,CAAA,IAAA,CAAA,QAAA,GAAA,QAAA,GAAA,IAAA;UACD,GAAE,EAAA,QAAA,CAAA,IAAA,CAAA,QAAA,GAAA,qBAAA,GAAA,IAAA;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"CnTextWidget3.vue.js","sources":["../../../../src/components/CnTextWidget/CnTextWidget.vue?vue&type=template&id=ebdce82c&lang.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2026 Conduction B.V.\n - SPDX-License-Identifier: EUPL-1.2\n-->\n\n<template>\n\t<div class=\"cn-text-widget\" :style=\"wrapperStyle\">\n\t\t<table\n\t\t\tv-if=\"tableMode\"\n\t\t\tclass=\"cn-text-widget__table\"\n\t\t\t:style=\"tableContainerStyle\">\n\t\t\t<tbody>\n\t\t\t\t<tr v-for=\"(row, rIdx) in tableRows\" :key=\"`r-${rIdx}`\">\n\t\t\t\t\t<template v-for=\"(cell, cIdx) in row\">\n\t\t\t\t\t\t<th\n\t\t\t\t\t\t\tv-if=\"isHeaderCell(rIdx)\"\n\t\t\t\t\t\t\tv-show=\"!isPlaceholderCellAt(rIdx, cIdx)\"\n\t\t\t\t\t\t\t:key=\"`c-${rIdx}-${cIdx}`\"\n\t\t\t\t\t\t\t:rowspan=\"cell.rowSpan || 1\"\n\t\t\t\t\t\t\t:colspan=\"cell.colSpan || 1\"\n\t\t\t\t\t\t\t:style=\"headerCellStyle(cIdx)\">\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-if=\"cellHasText(cell)\"\n\t\t\t\t\t\t\t\tv-html=\"sanitizeCell(cell.text)\" /><!-- eslint-disable-line vue/no-v-html -->\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\t\tclass=\"cn-text-widget__cell-placeholder\">\n\t\t\t\t\t\t\t\t{{ emptyCellPlaceholder }}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</th>\n\t\t\t\t\t\t<td\n\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\tv-show=\"!isPlaceholderCellAt(rIdx, cIdx)\"\n\t\t\t\t\t\t\t:key=\"`c-${rIdx}-${cIdx}`\"\n\t\t\t\t\t\t\t:rowspan=\"cell.rowSpan || 1\"\n\t\t\t\t\t\t\t:colspan=\"cell.colSpan || 1\"\n\t\t\t\t\t\t\t:style=\"dataCellStyle(cIdx)\">\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-if=\"cellHasText(cell)\"\n\t\t\t\t\t\t\t\tv-html=\"sanitizeCell(cell.text)\" /><!-- eslint-disable-line vue/no-v-html -->\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tv-else\n\t\t\t\t\t\t\t\tclass=\"cn-text-widget__cell-placeholder\">\n\t\t\t\t\t\t\t\t{{ emptyCellPlaceholder }}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</template>\n\t\t\t\t</tr>\n\t\t\t</tbody>\n\t\t</table>\n\t\t<pre\n\t\t\tv-else-if=\"monospace && hasText\"\n\t\t\tclass=\"cn-text-widget__mono\"\n\t\t\tdata-testid=\"cn-text-widget-mono\"\n\t\t\t:style=\"monoStyle\">{{ text }}</pre>\n\t\t<div\n\t\t\tv-else-if=\"hasText\"\n\t\t\tclass=\"cn-text-widget__content\"\n\t\t\t:class=\"contentClass\"\n\t\t\t:style=\"contentStyle\"\n\t\t\tv-html=\"sanitizedHtml\" /><!-- eslint-disable-line vue/no-v-html -->\n\t\t<span\n\t\t\tv-else\n\t\t\tclass=\"cn-text-widget__placeholder\"\n\t\t\t:style=\"contentStyle\">\n\t\t\t{{ placeholderText }}\n\t\t</span>\n\t\t<a\n\t\t\tv-if=\"link\"\n\t\t\tclass=\"cn-text-widget__link\"\n\t\t\tdata-testid=\"cn-text-widget-link\"\n\t\t\t:href=\"link.url\"\n\t\t\t:target=\"link.external ? '_blank' : null\"\n\t\t\t:rel=\"link.external ? 'noopener noreferrer' : null\"\n\t\t\t@click=\"openLink\">\n\t\t\t{{ link.label }}\n\t\t\t<ChevronRight :size=\"16\" />\n\t\t</a>\n\t</div>\n</template>\n\n<script>\nimport { translate as t } from '@nextcloud/l10n'\nimport DOMPurify from 'dompurify'\nimport { Marked } from 'marked'\nimport ChevronRight from 'vue-material-design-icons/ChevronRight.vue'\nimport { followLinkClick, resolveHref } from '../../utils/linkNavigation.js'\nimport { isPlaceholderCell } from '../../utils/textTable.js'\n\n// Per-module `Marked` instance so configuration is scoped here and does NOT\n// mutate the global `marked` singleton (which would affect any other code in\n// the same app that imports `marked`). `gfm: true` enables tables; `breaks:\n// false` keeps CommonMark-strict newline behaviour.\nconst markedInstance = new Marked({\n\tgfm: true,\n\tbreaks: false,\n})\n\n// DOMPurify allow-list hook: author-supplied `target=_blank` links survive\n// sanitisation (we add `target` to ADD_ATTR below); the hook then appends\n// `rel=\"noopener noreferrer\"` to mitigate reverse-tabnabbing. The hook is\n// idempotent and registered once.\nlet hookRegistered = false\nfunction ensureDomPurifyHook() {\n\tif (hookRegistered) {\n\t\treturn\n\t}\n\tDOMPurify.addHook('afterSanitizeAttributes', (node) => {\n\t\tif (node.tagName === 'A' && node.getAttribute('target') === '_blank') {\n\t\t\tnode.setAttribute('rel', 'noopener noreferrer')\n\t\t}\n\t})\n\thookRegistered = true\n}\n\n// The widget's own sanitiser config: `target` survives (the hook above adds\n// `rel`), `data-*` attributes do not.\nconst SANITIZE_CONFIG = {\n\tADD_ATTR: ['target'],\n\tALLOW_DATA_ATTR: false,\n}\n\n/**\n * Sanitise author HTML with the widget's own config.\n *\n * @param {string} html The HTML.\n * @return {string} HTML safe for `v-html`.\n */\nfunction sanitize(html) {\n\tensureDomPurifyHook()\n\treturn DOMPurify.sanitize(html, SANITIZE_CONFIG)\n}\n\n/**\n * CnTextWidget — renders user-authored multi-line text (or a small table)\n * inside a dashboard cell. Text content is passed through DOMPurify before\n * injection via `v-html` so common formatting tags survive while XSS vectors\n * (`<script>`, `on*` attributes, `javascript:` URLs) are stripped.\n *\n * Persisted shape: `{text, fontSize, color, backgroundColor, textAlign,\n * contentMode, tableMode, tableData}`. Defaults: `fontSize='14px'`,\n * `color='var(--color-main-text)'`, `backgroundColor='transparent'`,\n * `textAlign='left'`. `contentMode` absent means the legacy `'html'` branch;\n * the literal `'markdown'` parses via marked (GFM tables) then sanitises\n * through the same allow-list — a single trust boundary protects both modes.\n *\n * When `tableMode === true`, the renderer draws an HTML `<table>` from\n * `tableData` instead: header rows promote row 0 to `<th>`, per-column\n * alignment is applied inline, and `colSpan` / `rowSpan` become native HTML\n * attributes. Merge-swallowed cells are hidden via `v-show` so the visual\n * grid stays rectangular.\n *\n * With `monospace: true` the text is shown as typed, in a fixed-width font\n * with its spaces and line breaks kept, and is never parsed as HTML or\n * markdown: a receipt or a log line. `textField` reads the text from that\n * field of the detail page's object instead of `text`.\n *\n * Registered as the `text` dashboard widget type via the renderer's\n * `index.js`.\n */\nexport default {\n\tname: 'CnTextWidget',\n\n\tcomponents: { ChevronRight },\n\n\tinject: {\n\t\t/** The app's translate function, provided by CnAppRoot. Identity outside one. */\n\t\tcnTranslate: { default: () => (key) => key },\n\t},\n\n\tprops: {\n\t\t/**\n\t\t * Persisted widget content blob: `{text, fontSize, color,\n\t\t * backgroundColor, textAlign, contentMode, tableMode, tableData, link,\n\t\t * monospace, textField}`.\n\t\t * All keys are optional; missing keys collapse to documented defaults.\n\t\t * `text` and `link.label` go through the app's translate function.\n\t\t * `link` is `{label, route}` (a page id, or a path starting with `/`) or\n\t\t * `{label, href}` (an external URL), drawn under the text.\n\t\t * `monospace` shows the text as typed in a fixed-width font;\n\t\t * `textField` reads the text from that field of `objectData`.\n\t\t *\n\t\t * @type {{text: string, fontSize: string, color: string, backgroundColor: string, textAlign: string, contentMode: string, tableMode: boolean, tableData: object, link: {label: string, route: string, href: string}, monospace: boolean, textField: string}}\n\t\t */\n\t\tcontent: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => ({}),\n\t\t},\n\n\t\t/** The detail page's object, which `content.textField` reads from. */\n\t\tobjectData: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\n\tcomputed: {\n\t\t/**\n\t\t * The text: `content.textField` of the object as it is, else\n\t\t * `content.text`; '' when absent. Plain text goes through the app's\n\t\t * translate function; text holding markup (`<`, `>`, `&`) is author\n\t\t * content and is shown as written, because the translate function\n\t\t * sanitises with its own allow-list (which drops `target`).\n\t\t *\n\t\t * @spec openspec/changes/text-widget-monospace/tasks.md#task-2\n\t\t */\n\t\ttext() {\n\t\t\tconst field = this.content?.textField\n\t\t\tif (typeof field === 'string' && field !== '') {\n\t\t\t\tconst value = this.objectData?.[field]\n\t\t\t\treturn value === undefined || value === null ? '' : String(value)\n\t\t\t}\n\t\t\tconst text = this.content?.text\n\t\t\tif (typeof text !== 'string') {\n\t\t\t\treturn ''\n\t\t\t}\n\t\t\treturn /[<>&]/.test(text) ? text : this.tr(text)\n\t\t},\n\n\t\t/**\n\t\t * Whether the text shows as typed, in a fixed-width font.\n\t\t *\n\t\t * @spec openspec/changes/text-widget-monospace/tasks.md#task-1\n\t\t */\n\t\tmonospace() {\n\t\t\treturn this.content?.monospace === true\n\t\t},\n\n\t\t/** Inline style for the fixed-width text. */\n\t\tmonoStyle() {\n\t\t\treturn {\n\t\t\t\t'font-size': this.fontSize,\n\t\t\t\tcolor: this.color,\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * The link under the text, from `content.link`: `{ label, route }`\n\t\t * (a page id, or a router path when it starts with `/`) or\n\t\t * `{ label, href }` (an external URL, opened in a new tab). The label\n\t\t * goes through the app's translate function. Null without a label or\n\t\t * a target.\n\t\t *\n\t\t * @return {{label: string, url: string, location: (object|null), external: boolean}|null} The link.\n\t\t */\n\t\tlink() {\n\t\t\tconst link = this.content?.link\n\t\t\tif (!link || typeof link !== 'object' || typeof link.label !== 'string' || link.label === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tif (typeof link.route === 'string' && link.route !== '') {\n\t\t\t\tconst location = link.route.startsWith('/') ? { path: link.route } : { name: link.route }\n\t\t\t\tconst url = resolveHref(location, this.$router)\n\t\t\t\treturn url ? { label: this.tr(link.label), url, location, external: false } : null\n\t\t\t}\n\t\t\tif (typeof link.href === 'string' && link.href !== '') {\n\t\t\t\treturn { label: this.tr(link.label), url: link.href, location: null, external: true }\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\n\t\t/** Whether the text has any non-whitespace content. */\n\t\thasText() {\n\t\t\treturn this.text.trim() !== ''\n\t\t},\n\n\t\t/** Resolved content mode — only `'markdown'` switches the branch. */\n\t\tcontentMode() {\n\t\t\treturn this.content?.contentMode === 'markdown' ? 'markdown' : 'html'\n\t\t},\n\n\t\t/** CSS class selecting the markdown vs html content-spacing rules. */\n\t\tcontentClass() {\n\t\t\treturn this.contentMode === 'markdown'\n\t\t\t\t? 'cn-text-widget__content--markdown'\n\t\t\t\t: 'cn-text-widget__content--html'\n\t\t},\n\n\t\t/**\n\t\t * The HTML to render: either the raw author HTML (sanitised) or the\n\t\t * markdown rendering of the author text (sanitised). Both branches go\n\t\t * through DOMPurify, which strips `<script>`, `<style>`, `<link>`,\n\t\t * `on*` attributes, and `javascript:` URLs.\n\t\t *\n\t\t * @return {string} sanitised HTML safe for `v-html` injection.\n\t\t */\n\t\tsanitizedHtml() {\n\t\t\tlet html\n\t\t\tif (this.contentMode === 'markdown') {\n\t\t\t\ttry {\n\t\t\t\t\thtml = markedInstance.parse(this.text)\n\t\t\t\t\tif (typeof html !== 'string') {\n\t\t\t\t\t\thtml = String(html)\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Defensive: fall back to the raw text rather than crash\n\t\t\t\t\t// the dashboard if the parser throws.\n\t\t\t\t\thtml = this.text\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\thtml = this.text\n\t\t\t}\n\t\t\treturn sanitize(html)\n\t\t},\n\n\t\t/** Localised placeholder shown when there is no text content. */\n\t\tplaceholderText() {\n\t\t\treturn t('nextcloud-vue', 'No text content')\n\t\t},\n\n\t\t/** Localised placeholder shown inside an empty table cell. */\n\t\temptyCellPlaceholder() {\n\t\t\treturn t('nextcloud-vue', 'Empty cell')\n\t\t},\n\n\t\t/** Resolved font size (default `14px`). */\n\t\tfontSize() {\n\t\t\treturn this.content?.fontSize || '14px'\n\t\t},\n\n\t\t/** Resolved text colour (default theme main text). */\n\t\tcolor() {\n\t\t\treturn this.content?.color || 'var(--color-main-text)'\n\t\t},\n\n\t\t/** Resolved background colour (default transparent). */\n\t\tbackgroundColor() {\n\t\t\treturn this.content?.backgroundColor || 'transparent'\n\t\t},\n\n\t\t/** Resolved text alignment (default `left`). */\n\t\ttextAlign() {\n\t\t\treturn this.content?.textAlign || 'left'\n\t\t},\n\n\t\t/** Whether the renderer is in table mode. */\n\t\ttableMode() {\n\t\t\treturn this.content?.tableMode === true\n\t\t},\n\n\t\t/** The persisted tableData object, or null. */\n\t\ttableData() {\n\t\t\treturn this.content?.tableData || null\n\t\t},\n\n\t\t/** The table rows array (empty when no table data). */\n\t\ttableRows() {\n\t\t\treturn Array.isArray(this.tableData?.rows) ? this.tableData.rows : []\n\t\t},\n\n\t\t/** Whether row 0 should render as a header row. */\n\t\theaderRow() {\n\t\t\treturn this.tableData?.headerRow === true\n\t\t},\n\n\t\t/** Per-column text-alignment array. */\n\t\tcolumnAlignments() {\n\t\t\tconst aligns = this.tableData?.columnAlignments\n\t\t\treturn Array.isArray(aligns) ? aligns : []\n\t\t},\n\n\t\t/** Inline style for the flex wrapper. */\n\t\twrapperStyle() {\n\t\t\treturn {\n\t\t\t\twidth: '100%',\n\t\t\t\theight: '100%',\n\t\t\t\tpadding: '16px',\n\t\t\t\tdisplay: 'flex',\n\t\t\t\t'align-items': 'safe center',\n\t\t\t\t'justify-content': 'safe center',\n\t\t\t\toverflow: 'auto',\n\t\t\t\t'background-color': this.backgroundColor,\n\t\t\t\t...(this.link ? { 'flex-direction': 'column', gap: '8px', 'align-items': 'flex-start' } : {}),\n\t\t\t}\n\t\t},\n\n\t\t/** Inline style for the text / placeholder content. */\n\t\tcontentStyle() {\n\t\t\tconst base = {\n\t\t\t\t'font-size': this.fontSize,\n\t\t\t\t'text-align': this.textAlign,\n\t\t\t\tcolor: this.color,\n\t\t\t\twidth: '100%',\n\t\t\t\t'overflow-wrap': 'break-word',\n\t\t\t}\n\t\t\tif (!this.hasText) {\n\t\t\t\tbase['font-style'] = 'italic'\n\t\t\t\tbase.color = 'var(--color-text-maxcontrast)'\n\t\t\t}\n\t\t\treturn base\n\t\t},\n\n\t\t/** Inline style for the table container. */\n\t\ttableContainerStyle() {\n\t\t\treturn {\n\t\t\t\t'font-size': this.fontSize,\n\t\t\t\tcolor: this.color,\n\t\t\t\twidth: '100%',\n\t\t\t}\n\t\t},\n\t},\n\n\tmethods: {\n\t\t/**\n\t\t * A manifest string through the app's translate function.\n\t\t *\n\t\t * @param {string} text The string.\n\t\t * @return {string} The translated string.\n\t\t */\n\t\ttr(text) {\n\t\t\treturn typeof this.cnTranslate === 'function' ? this.cnTranslate(text) : text\n\t\t},\n\n\t\t/**\n\t\t * Route a plain click on an in-app link, so the page does not reload.\n\t\t *\n\t\t * @param {MouseEvent} event The click.\n\t\t */\n\t\topenLink(event) {\n\t\t\tif (this.link && !this.link.external) {\n\t\t\t\tfollowLinkClick(event, this.link.location, this.$router)\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Run cell text through DOMPurify so the table-mode render path has\n\t\t * the same XSS-stripping guarantees as the text-mode path.\n\t\t *\n\t\t * @param {string} text raw cell text (may contain HTML).\n\t\t * @return {string} sanitised HTML safe to render via `v-html`.\n\t\t */\n\t\tsanitizeCell(text) {\n\t\t\treturn sanitize(typeof text === 'string' ? text : '')\n\t\t},\n\n\t\t/**\n\t\t * Whether the given row index renders as `<th>` (header row).\n\t\t *\n\t\t * @param {number} rIdx the 0-based row index.\n\t\t * @return {boolean} true when row 0 and the header flag is set.\n\t\t */\n\t\tisHeaderCell(rIdx) {\n\t\t\treturn this.headerRow && rIdx === 0\n\t\t},\n\n\t\t/**\n\t\t * Whether a cell is covered by another cell's `rowSpan` / `colSpan`\n\t\t * and so must be hidden to keep the grid rectangular.\n\t\t *\n\t\t * @param {number} rIdx the row index.\n\t\t * @param {number} cIdx the column index.\n\t\t * @return {boolean} true when the cell is a covered placeholder.\n\t\t */\n\t\tisPlaceholderCellAt(rIdx, cIdx) {\n\t\t\treturn isPlaceholderCell(this.tableRows, rIdx, cIdx)\n\t\t},\n\n\t\t/**\n\t\t * Whether a cell has any non-whitespace text.\n\t\t *\n\t\t * @param {object} cell the cell object.\n\t\t * @return {boolean} true when the cell has text.\n\t\t */\n\t\tcellHasText(cell) {\n\t\t\treturn typeof cell?.text === 'string' && cell.text.trim() !== ''\n\t\t},\n\n\t\t/**\n\t\t * Inline style for a data cell at a given column.\n\t\t *\n\t\t * @param {number} cIdx the column index.\n\t\t * @return {object} the cell style object.\n\t\t */\n\t\tdataCellStyle(cIdx) {\n\t\t\treturn {\n\t\t\t\t'text-align': this.columnAlignments[cIdx] || 'left',\n\t\t\t\tborder: '1px solid var(--color-border)',\n\t\t\t\tpadding: '8px',\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Inline style for a header cell at a given column.\n\t\t *\n\t\t * @param {number} cIdx the column index.\n\t\t * @return {object} the header cell style object.\n\t\t */\n\t\theaderCellStyle(cIdx) {\n\t\t\treturn {\n\t\t\t\t...this.dataCellStyle(cIdx),\n\t\t\t\t'background-color': 'var(--color-background-hover)',\n\t\t\t\t'font-weight': 'bold',\n\t\t\t}\n\t\t},\n\t},\n}\n</script>\n\n<style scoped>\n.cn-text-widget {\n\twidth: 100%;\n\theight: 100%;\n}\n\n.cn-text-widget__mono {\n\twidth: 100%;\n\tmargin: 0;\n\tpadding: 12px;\n\tfont-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;\n\tline-height: 1.4;\n\twhite-space: pre-wrap;\n\toverflow-wrap: anywhere;\n\ttext-align: start;\n\tbackground: var(--color-background-dark);\n\tborder: 1px solid var(--color-border);\n\tborder-radius: var(--border-radius);\n}\n\n.cn-text-widget__content,\n.cn-text-widget__placeholder {\n\t/* Safety net — ensures long URLs / words inside the sanitised HTML wrap\n\t rather than overflowing horizontally. */\n\toverflow-wrap: break-word;\n\tmax-width: 100%;\n}\n\n/* Restore inline-emphasis semantics inside rendered content. Nextcloud's\n server CSS styles bare <em> as muted (var(--color-text-maxcontrast)) and can\n drop the italic, so `_x_` / `**_x_**` looked greyed-out and non-italic. Force\n italic <em> / bold <strong> that inherit the widget's own text colour. */\n.cn-text-widget :deep(em),\n.cn-text-widget :deep(i) {\n\tfont-style: italic;\n\tcolor: inherit;\n}\n\n.cn-text-widget :deep(strong),\n.cn-text-widget :deep(b) {\n\tfont-weight: bold;\n\tcolor: inherit;\n}\n\n/* Nextcloud's server CSS strips list markers/indent (`list-style: none`,\n no padding), so rendered `<ul>`/`<ol>` looked like plain text. Restore\n bullets/numbers and indentation, including nested levels. */\n.cn-text-widget :deep(ul),\n.cn-text-widget :deep(ol) {\n\tmargin: 4px 0;\n\tpadding-left: 1.5em;\n}\n\n.cn-text-widget :deep(ul) {\n\tlist-style: disc outside;\n}\n\n.cn-text-widget :deep(ol) {\n\tlist-style: decimal outside;\n}\n\n.cn-text-widget :deep(ul ul) {\n\tlist-style-type: circle;\n}\n\n.cn-text-widget :deep(ul ul ul) {\n\tlist-style-type: square;\n}\n\n.cn-text-widget :deep(li) {\n\tdisplay: list-item;\n}\n\n/* Nextcloud's server CSS flattens heading sizes (e.g. h1 → 100%, so it fell\n back to the ~14px body size while h2 stayed 1.8em), leaving them oddly\n scaled. Apply a consistent em-based scale that grows with the widget's own\n font size. */\n.cn-text-widget :deep(h1) {\n\tfont-size: 2em;\n}\n\n.cn-text-widget :deep(h2) {\n\tfont-size: 1.5em;\n}\n\n.cn-text-widget :deep(h3) {\n\tfont-size: 1.25em;\n}\n\n.cn-text-widget :deep(h4) {\n\tfont-size: 1.1em;\n}\n\n.cn-text-widget :deep(h5) {\n\tfont-size: 1em;\n}\n\n.cn-text-widget :deep(h6) {\n\tfont-size: 0.85em;\n}\n\n.cn-text-widget__content--markdown :deep(h1),\n.cn-text-widget__content--markdown :deep(h2),\n.cn-text-widget__content--markdown :deep(h3),\n.cn-text-widget__content--markdown :deep(h4),\n.cn-text-widget__content--markdown :deep(h5),\n.cn-text-widget__content--markdown :deep(h6) {\n\tmargin: 8px 0 4px;\n\tfont-weight: 600;\n\tline-height: 1.3;\n}\n\n.cn-text-widget__content--markdown :deep(p),\n.cn-text-widget__content--markdown :deep(ul),\n.cn-text-widget__content--markdown :deep(ol),\n.cn-text-widget__content--markdown :deep(blockquote) {\n\tmargin: 4px 0;\n}\n\n.cn-text-widget__content--markdown :deep(code) {\n\tpadding: 1px 4px;\n\tborder-radius: 3px;\n\tbackground: var(--color-background-hover);\n\tfont-family: var(--font-monospace, monospace);\n\tfont-size: 0.95em;\n}\n\n.cn-text-widget__content--markdown :deep(pre) {\n\tpadding: 8px;\n\tborder-radius: var(--border-radius);\n\tbackground: var(--color-background-hover);\n\toverflow: auto;\n}\n\n.cn-text-widget__content--markdown :deep(pre) :deep(code) {\n\tpadding: 0;\n\tbackground: transparent;\n}\n\n.cn-text-widget__content--markdown :deep(blockquote) {\n\tpadding-left: 8px;\n\tborder-left: 3px solid var(--color-border);\n\tcolor: var(--color-text-maxcontrast);\n}\n\n.cn-text-widget__content--markdown :deep(table) {\n\tborder-collapse: collapse;\n\tmargin: 4px 0;\n}\n\n.cn-text-widget__content--markdown :deep(th),\n.cn-text-widget__content--markdown :deep(td) {\n\tpadding: 4px 8px;\n\tborder: 1px solid var(--color-border);\n}\n\n.cn-text-widget__table {\n\tborder-collapse: collapse;\n\twidth: 100%;\n}\n\n.cn-text-widget__table th,\n.cn-text-widget__table td {\n\toverflow-wrap: break-word;\n\tvertical-align: top;\n}\n\n.cn-text-widget__cell-placeholder {\n\tcolor: var(--color-text-maxcontrast);\n\tfont-style: italic;\n}\n\n.cn-text-widget__link {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tgap: 2px;\n\tfont-size: 14px;\n\tfont-weight: 600;\n\tcolor: var(--color-primary-element);\n\ttext-decoration: none;\n}\n\n.cn-text-widget__link:hover,\n.cn-text-widget__link:focus-visible {\n\ttext-decoration: underline;\n}\n</style>\n"],"names":["_createElementBlock","_createElementVNode","_Fragment","_renderList","_normalizeStyle","_toDisplayString","_normalizeClass"],"mappings":";;;;;;AA+BQ,EAAA,KAAI,EAAA;;;;;;AAgBJ,EAAA,KAAA,EAAA;;;;;;;;uBApCLA,kBAAA;AAAG,IAAA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C,qBAAG;UACd,IAAI,EAAE,QAAA,CAAA,IAAI,CAAC,GAAG;UACd,MAAC,EAAA,QAAA,CAAA,IAAA,CAAA,QAAA,GAAA,QAAA,GAAA,IAAA;UACD,GAAE,EAAA,QAAA,CAAA,IAAA,CAAA,QAAA,GAAA,qBAAA,GAAA,IAAA;;;;;;;;;;"}
|
package/dist/esm/l10n/nl.json.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
var translations = {
|
|
2
|
+
"Find everyone tagged {tag}": "Vind iedereen met de tag {tag}",
|
|
3
|
+
"No matching users.": "Geen passende gebruikers.",
|
|
4
|
+
"Search by name, email or expertise…": "Zoek op naam, e-mail of expertise…",
|
|
5
|
+
"Unknown sort key \"{key}\". Display name is used instead.": "Onbekende sorteersleutel \"{key}\". Er wordt op weergavenaam gesorteerd.",
|
|
2
6
|
"Search the knowledge base": "Zoek in de kennisbank",
|
|
3
7
|
"Searching…": "Zoeken…",
|
|
4
8
|
"Knowledge base unavailable": "Kennisbank niet beschikbaar",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nl.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nl.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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