@escalated-dev/escalated 0.7.0 → 0.7.1
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/LICENSE +21 -21
- package/README.md +31 -0
- package/package.json +12 -6
- package/src/components/ActiveChatsPanel.vue +246 -0
- package/src/components/ActivityTimeline.stories.js +55 -55
- package/src/components/ActivityTimeline.vue +83 -83
- package/src/components/AdminDashboard.stories.js +1423 -1095
- package/src/components/AgentLoadIndicator.stories.js +37 -37
- package/src/components/AgentLoadIndicator.vue +49 -49
- package/src/components/AgentPerformanceCard.vue +44 -44
- package/src/components/ArticleEditor.vue +82 -82
- package/src/components/AssigneeSelect.vue +37 -37
- package/src/components/AttachmentList.vue +13 -1
- package/src/components/AuditLogEntry.vue +95 -95
- package/src/components/BulkActionBar.vue +166 -166
- package/src/components/CategoryTree.vue +89 -89
- package/src/components/ChartWidget.vue +46 -46
- package/src/components/ChatActionBar.vue +226 -0
- package/src/components/ChatBubble.vue +162 -0
- package/src/components/ChatComposer.vue +308 -0
- package/src/components/ChatQueue.vue +222 -0
- package/src/components/ChatThread.vue +197 -0
- package/src/components/CollisionWarning.stories.js +30 -30
- package/src/components/CollisionWarning.vue +68 -68
- package/src/components/ConditionalFieldRules.vue +135 -135
- package/src/components/ContextPanel.vue +66 -66
- package/src/components/ContextPanelSection.vue +65 -65
- package/src/components/CustomFieldRenderer.vue +159 -159
- package/src/components/EscalatedLayout.vue +29 -6
- package/src/components/FileDropzone.vue +57 -57
- package/src/components/FollowButton.stories.js +30 -30
- package/src/components/FollowButton.vue +88 -88
- package/src/components/KeyboardShortcutHelp.vue +213 -213
- package/src/components/KnowledgePanel.vue +122 -122
- package/src/components/KpiCard.stories.js +32 -32
- package/src/components/KpiCard.vue +88 -88
- package/src/components/MacroDropdown.vue +150 -150
- package/src/components/MentionDropdown.vue +154 -0
- package/src/components/MetricComparison.vue +89 -0
- package/src/components/PercentileChart.vue +67 -0
- package/src/components/PeriodSelector.vue +98 -0
- package/src/components/PermissionMatrix.vue +107 -107
- package/src/components/PinnedNotes.vue +129 -129
- package/src/components/PluginSlot.vue +68 -62
- package/src/components/PresenceIndicator.vue +46 -2
- package/src/components/PriorityBadge.stories.js +33 -33
- package/src/components/PriorityBadge.vue +46 -46
- package/src/components/ReplyComposer.vue +81 -18
- package/src/components/ReplyThread.vue +40 -2
- package/src/components/ReportChart.vue +395 -0
- package/src/components/ReportExportButton.vue +108 -0
- package/src/components/SatisfactionRating.vue +180 -180
- package/src/components/SaveViewDialog.vue +172 -0
- package/src/components/SavedViewSidebar.vue +208 -0
- package/src/components/ScheduleEditor.vue +104 -104
- package/src/components/SideConversation.vue +165 -165
- package/src/components/SideConversationList.vue +147 -147
- package/src/components/SkillTagManager.vue +79 -79
- package/src/components/SlaComplianceChart.vue +46 -53
- package/src/components/SlaTimer.stories.js +35 -35
- package/src/components/SlaTimer.vue +62 -62
- package/src/components/SnoozeButton.vue +247 -0
- package/src/components/StatsCard.stories.js +24 -24
- package/src/components/StatsCard.vue +58 -58
- package/src/components/StatusBadge.stories.js +53 -53
- package/src/components/StatusBadge.vue +78 -78
- package/src/components/TagSelect.vue +84 -84
- package/src/components/TicketFilters.vue +270 -225
- package/src/components/TicketLinkPanel.vue +193 -193
- package/src/components/TicketList.vue +655 -594
- package/src/components/TicketMergeDialog.vue +157 -157
- package/src/components/TicketSplitDialog.vue +98 -0
- package/src/components/TotpInput.stories.js +9 -9
- package/src/components/TotpInput.vue +81 -81
- package/src/components/TwoFactorSetup.vue +113 -113
- package/src/components/VariableTokenInput.vue +111 -0
- package/src/components/WorkflowActionConfig.vue +287 -0
- package/src/components/WorkflowActionList.vue +350 -0
- package/src/components/WorkflowConditionBuilder.vue +265 -0
- package/src/components/WorkflowTriggerSelector.vue +125 -0
- package/src/composables/useChat.js +187 -0
- package/src/composables/useI18n.js +80 -80
- package/src/composables/useKeyboardShortcuts.js +46 -46
- package/src/composables/useMentions.js +134 -0
- package/src/composables/usePluginExtensions.js +159 -159
- package/src/composables/usePluginHooks.js +65 -65
- package/src/composables/useRealtime.js +182 -0
- package/src/defineEscalatedPlugin.js +76 -76
- package/src/index.js +84 -72
- package/src/locales/ar.json +727 -0
- package/src/locales/de.json +678 -430
- package/src/locales/en.json +717 -455
- package/src/locales/es.json +679 -430
- package/src/locales/fr.json +680 -431
- package/src/locales/index.js +12 -2
- package/src/locales/it.json +727 -0
- package/src/locales/ja.json +727 -0
- package/src/locales/ko.json +727 -0
- package/src/locales/nl.json +727 -0
- package/src/locales/pl.json +727 -0
- package/src/locales/pt-BR.json +727 -0
- package/src/locales/ru.json +727 -0
- package/src/locales/tr.json +727 -0
- package/src/locales/zh-CN.json +727 -0
- package/src/pages/Admin/ApiTokens/Index.vue +381 -381
- package/src/pages/Admin/AuditLog/Index.vue +154 -154
- package/src/pages/Admin/BusinessHours/Form.vue +172 -172
- package/src/pages/Admin/BusinessHours/Index.vue +113 -113
- package/src/pages/Admin/CannedResponses/Index.vue +127 -127
- package/src/pages/Admin/Capacity/Index.vue +134 -134
- package/src/pages/Admin/CustomFields/Form.vue +195 -195
- package/src/pages/Admin/CustomFields/Index.vue +134 -134
- package/src/pages/Admin/CustomObjects/Form.vue +202 -202
- package/src/pages/Admin/CustomObjects/Index.vue +127 -127
- package/src/pages/Admin/CustomObjects/Records.vue +228 -228
- package/src/pages/Admin/Departments/Form.vue +75 -75
- package/src/pages/Admin/Departments/Index.vue +110 -109
- package/src/pages/Admin/EscalationRules/Form.vue +157 -157
- package/src/pages/Admin/EscalationRules/Index.vue +178 -178
- package/src/pages/Admin/Import/Connect.vue +0 -1
- package/src/pages/Admin/Import/Index.vue +1 -1
- package/src/pages/Admin/Import/Progress.vue +1 -1
- package/src/pages/Admin/KnowledgeBase/Articles/Form.vue +142 -142
- package/src/pages/Admin/KnowledgeBase/Articles/Index.vue +195 -195
- package/src/pages/Admin/KnowledgeBase/Categories/Index.vue +193 -193
- package/src/pages/Admin/Macros/Index.vue +448 -448
- package/src/pages/Admin/Plugins/Index.vue +327 -327
- package/src/pages/Admin/Reports/AgentDetail.vue +132 -0
- package/src/pages/Admin/Reports/AgentMetrics.vue +115 -115
- package/src/pages/Admin/Reports/AgentRanking.vue +246 -0
- package/src/pages/Admin/Reports/Cohorts.vue +180 -0
- package/src/pages/Admin/Reports/Comparison.vue +141 -0
- package/src/pages/Admin/Reports/CsatReport.vue +127 -127
- package/src/pages/Admin/Reports/Dashboard.vue +36 -21
- package/src/pages/Admin/Reports/ResolutionTimes.vue +164 -0
- package/src/pages/Admin/Reports/ResponseTimes.vue +164 -0
- package/src/pages/Admin/Reports/SlaReport.vue +162 -166
- package/src/pages/Admin/Reports/SlaTrends.vue +183 -0
- package/src/pages/Admin/Reports.vue +206 -206
- package/src/pages/Admin/Roles/Form.vue +71 -71
- package/src/pages/Admin/Roles/Index.vue +122 -122
- package/src/pages/Admin/Settings/CsatSettings.vue +165 -165
- package/src/pages/Admin/Settings/DataRetention.vue +182 -182
- package/src/pages/Admin/Settings/EmailSettings.vue +243 -243
- package/src/pages/Admin/Settings/Sandbox.vue +135 -135
- package/src/pages/Admin/Settings/SsoSettings.vue +218 -218
- package/src/pages/Admin/Settings/TwoFactor.vue +110 -110
- package/src/pages/Admin/Settings.vue +1008 -468
- package/src/pages/Admin/Skills/Form.vue +53 -53
- package/src/pages/Admin/Skills/Index.vue +94 -94
- package/src/pages/Admin/SlaPolicies/Form.vue +118 -118
- package/src/pages/Admin/SlaPolicies/Index.vue +121 -120
- package/src/pages/Admin/Statuses/Form.vue +114 -114
- package/src/pages/Admin/Statuses/Index.vue +153 -153
- package/src/pages/Admin/Tags/Index.vue +191 -191
- package/src/pages/Admin/Tickets/Index.vue +126 -91
- package/src/pages/Admin/Tickets/Show.vue +29 -0
- package/src/pages/Admin/Webhooks/DeliveryLog.vue +120 -120
- package/src/pages/Admin/Webhooks/Form.vue +110 -110
- package/src/pages/Admin/Webhooks/Index.vue +136 -136
- package/src/pages/Admin/Workflows/Builder.vue +207 -0
- package/src/pages/Admin/Workflows/Index.vue +235 -0
- package/src/pages/Admin/Workflows/Logs.vue +286 -0
- package/src/pages/Agent/TicketIndex.vue +112 -88
- package/src/pages/Agent/TicketShow.vue +192 -60
- package/src/pages/Customer/Create.vue +1 -1
- package/src/pages/Customer/Index.vue +31 -31
- package/src/pages/Customer/KnowledgeBase/Article.vue +4 -2
- package/src/pages/Customer/KnowledgeBase/Index.vue +151 -151
- package/src/pages/Customer/Show.vue +69 -63
- package/src/pages/Guest/Create.vue +40 -15
- package/src/pages/Guest/Show.vue +124 -93
- package/src/plugin.js +25 -0
- package/src/utils/mentionHighlight.js +24 -0
- package/src/utils/sanitizeHtml.js +78 -64
- package/src/widget/EscalatedWidget.vue +804 -0
- package/src/widget/index.js +254 -0
- package/src/pages/Admin/Automations/Form.vue +0 -184
- package/src/pages/Admin/Automations/Index.vue +0 -129
package/src/pages/Guest/Show.vue
CHANGED
|
@@ -1,93 +1,124 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import EscalatedLayout from '../../components/EscalatedLayout.vue';
|
|
3
|
-
import StatusBadge from '../../components/StatusBadge.vue';
|
|
4
|
-
import PriorityBadge from '../../components/PriorityBadge.vue';
|
|
5
|
-
import ReplyThread from '../../components/ReplyThread.vue';
|
|
6
|
-
import AttachmentList from '../../components/AttachmentList.vue';
|
|
7
|
-
import SatisfactionRating from '../../components/SatisfactionRating.vue';
|
|
8
|
-
import { useForm } from '@inertiajs/vue3';
|
|
9
|
-
import { ref } from 'vue';
|
|
10
|
-
|
|
11
|
-
const props = defineProps({ ticket: Object, token: String });
|
|
12
|
-
|
|
13
|
-
const isResolved = ['resolved', 'closed'].includes(props.ticket.status);
|
|
14
|
-
|
|
15
|
-
const replyForm = useForm({ body: '', attachments: [] });
|
|
16
|
-
const showCopied = ref(false);
|
|
17
|
-
|
|
18
|
-
function submitReply() {
|
|
19
|
-
replyForm.post(route('escalated.guest.tickets.reply', props.token), {
|
|
20
|
-
onSuccess: () => replyForm.reset(),
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function copyLink() {
|
|
25
|
-
navigator.clipboard.writeText(window.location.href);
|
|
26
|
-
showCopied.value = true;
|
|
27
|
-
setTimeout(() => showCopied.value = false, 2000);
|
|
28
|
-
}
|
|
29
|
-
</script>
|
|
30
|
-
|
|
31
|
-
<template>
|
|
32
|
-
<EscalatedLayout :title="ticket.subject">
|
|
33
|
-
<div class="mx-auto max-w-3xl">
|
|
34
|
-
<!-- Bookmark notice -->
|
|
35
|
-
<div class="mb-4 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3">
|
|
36
|
-
<div class="flex items-start gap-3">
|
|
37
|
-
<svg
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
<
|
|
70
|
-
<
|
|
71
|
-
</div>
|
|
72
|
-
|
|
73
|
-
<!--
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
</
|
|
1
|
+
<script setup>
|
|
2
|
+
import EscalatedLayout from '../../components/EscalatedLayout.vue';
|
|
3
|
+
import StatusBadge from '../../components/StatusBadge.vue';
|
|
4
|
+
import PriorityBadge from '../../components/PriorityBadge.vue';
|
|
5
|
+
import ReplyThread from '../../components/ReplyThread.vue';
|
|
6
|
+
import AttachmentList from '../../components/AttachmentList.vue';
|
|
7
|
+
import SatisfactionRating from '../../components/SatisfactionRating.vue';
|
|
8
|
+
import { useForm } from '@inertiajs/vue3';
|
|
9
|
+
import { ref } from 'vue';
|
|
10
|
+
|
|
11
|
+
const props = defineProps({ ticket: Object, token: String });
|
|
12
|
+
|
|
13
|
+
const isResolved = ['resolved', 'closed'].includes(props.ticket.status);
|
|
14
|
+
|
|
15
|
+
const replyForm = useForm({ body: '', attachments: [] });
|
|
16
|
+
const showCopied = ref(false);
|
|
17
|
+
|
|
18
|
+
function submitReply() {
|
|
19
|
+
replyForm.post(route('escalated.guest.tickets.reply', props.token), {
|
|
20
|
+
onSuccess: () => replyForm.reset(),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function copyLink() {
|
|
25
|
+
navigator.clipboard.writeText(window.location.href);
|
|
26
|
+
showCopied.value = true;
|
|
27
|
+
setTimeout(() => (showCopied.value = false), 2000);
|
|
28
|
+
}
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<template>
|
|
32
|
+
<EscalatedLayout :title="ticket.subject">
|
|
33
|
+
<div class="mx-auto max-w-3xl">
|
|
34
|
+
<!-- Bookmark notice -->
|
|
35
|
+
<div class="mb-4 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3">
|
|
36
|
+
<div class="flex items-start gap-3">
|
|
37
|
+
<svg
|
|
38
|
+
class="mt-0.5 h-5 w-5 shrink-0 text-amber-500"
|
|
39
|
+
fill="none"
|
|
40
|
+
stroke="currentColor"
|
|
41
|
+
stroke-width="1.5"
|
|
42
|
+
viewBox="0 0 24 24"
|
|
43
|
+
>
|
|
44
|
+
<path
|
|
45
|
+
stroke-linecap="round"
|
|
46
|
+
stroke-linejoin="round"
|
|
47
|
+
d="M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"
|
|
48
|
+
/>
|
|
49
|
+
</svg>
|
|
50
|
+
<div>
|
|
51
|
+
<p class="text-sm font-medium text-amber-800">Bookmark this page</p>
|
|
52
|
+
<p class="mt-0.5 text-xs text-amber-600">
|
|
53
|
+
This is your private link to view and reply to this ticket.
|
|
54
|
+
</p>
|
|
55
|
+
</div>
|
|
56
|
+
<button
|
|
57
|
+
class="ml-auto shrink-0 rounded-md border border-amber-300 bg-white px-2.5 py-1 text-xs font-medium text-amber-700 hover:bg-amber-50"
|
|
58
|
+
@click="copyLink"
|
|
59
|
+
>
|
|
60
|
+
{{ showCopied ? 'Copied!' : 'Copy Link' }}
|
|
61
|
+
</button>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
<!-- Ticket header -->
|
|
66
|
+
<div class="mb-4 flex flex-wrap items-center gap-3">
|
|
67
|
+
<span class="font-mono text-sm text-gray-500">{{ ticket.reference }}</span>
|
|
68
|
+
<StatusBadge :status="ticket.status" />
|
|
69
|
+
<PriorityBadge :priority="ticket.priority" />
|
|
70
|
+
<span v-if="ticket.department" class="text-sm text-gray-500">{{ ticket.department.name }}</span>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<!-- CSAT Rating -->
|
|
74
|
+
<SatisfactionRating
|
|
75
|
+
v-if="isResolved && !ticket.satisfaction_rating"
|
|
76
|
+
:action="route('escalated.guest.tickets.rate', token)"
|
|
77
|
+
/>
|
|
78
|
+
|
|
79
|
+
<!-- Description -->
|
|
80
|
+
<div class="mb-6 rounded-lg border border-gray-200 bg-white p-4">
|
|
81
|
+
<p class="whitespace-pre-wrap text-sm text-gray-700">{{ ticket.description }}</p>
|
|
82
|
+
<AttachmentList v-if="ticket.attachments?.length" :attachments="ticket.attachments" class="mt-3" />
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<!-- Replies -->
|
|
86
|
+
<div class="mb-6">
|
|
87
|
+
<h2 class="mb-4 text-lg font-semibold text-gray-900">Replies</h2>
|
|
88
|
+
<ReplyThread :replies="ticket.replies || []" />
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
<!-- Reply form -->
|
|
92
|
+
<div v-if="ticket.status !== 'closed'" class="rounded-lg border border-gray-200 bg-white p-4">
|
|
93
|
+
<h2 class="mb-4 text-lg font-semibold text-gray-900">Reply</h2>
|
|
94
|
+
<form @submit.prevent="submitReply">
|
|
95
|
+
<textarea
|
|
96
|
+
v-model="replyForm.body"
|
|
97
|
+
rows="4"
|
|
98
|
+
required
|
|
99
|
+
placeholder="Write your reply..."
|
|
100
|
+
class="w-full rounded-lg border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500"
|
|
101
|
+
></textarea>
|
|
102
|
+
<div v-if="replyForm.errors.body" class="mt-1 text-sm text-red-600">
|
|
103
|
+
{{ replyForm.errors.body }}
|
|
104
|
+
</div>
|
|
105
|
+
<div class="mt-3 flex justify-end">
|
|
106
|
+
<button
|
|
107
|
+
type="submit"
|
|
108
|
+
:disabled="replyForm.processing"
|
|
109
|
+
class="rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700 disabled:opacity-50"
|
|
110
|
+
>
|
|
111
|
+
{{ replyForm.processing ? 'Sending...' : 'Send Reply' }}
|
|
112
|
+
</button>
|
|
113
|
+
</div>
|
|
114
|
+
</form>
|
|
115
|
+
</div>
|
|
116
|
+
<div
|
|
117
|
+
v-else
|
|
118
|
+
class="rounded-lg border border-gray-200 bg-gray-50 px-4 py-6 text-center text-sm text-gray-500"
|
|
119
|
+
>
|
|
120
|
+
This ticket is closed. No further replies can be added.
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
</EscalatedLayout>
|
|
124
|
+
</template>
|
package/src/plugin.js
CHANGED
|
@@ -17,6 +17,8 @@ import { markRaw } from 'vue';
|
|
|
17
17
|
*/
|
|
18
18
|
export const EscalatedPlugin = {
|
|
19
19
|
install(app, options = {}) {
|
|
20
|
+
installRouteShim();
|
|
21
|
+
|
|
20
22
|
if (options.layout) {
|
|
21
23
|
app.provide('escalated-layout', markRaw(options.layout));
|
|
22
24
|
}
|
|
@@ -38,6 +40,29 @@ export const EscalatedPlugin = {
|
|
|
38
40
|
},
|
|
39
41
|
};
|
|
40
42
|
|
|
43
|
+
// 77 components in this package call the Ziggy `route()` helper (Laravel's
|
|
44
|
+
// named-route URL generator). Laravel hosts ship Ziggy and get `window.route`
|
|
45
|
+
// for free; other host frameworks (Rails, Django, NestJS, Phoenix, Symfony,
|
|
46
|
+
// Adonis, Go, .NET, Spring, WordPress) don't, and the call sites would
|
|
47
|
+
// otherwise throw a bare ReferenceError deep inside a component render with
|
|
48
|
+
// no hint at the cause.
|
|
49
|
+
//
|
|
50
|
+
// Install a stub that throws an informative error instead, so the host app's
|
|
51
|
+
// first failing request points at the actual missing dependency. Laravel hosts
|
|
52
|
+
// that already have Ziggy loaded are left alone.
|
|
53
|
+
function installRouteShim() {
|
|
54
|
+
if (typeof window === 'undefined') return;
|
|
55
|
+
if (typeof window.route === 'function') return;
|
|
56
|
+
|
|
57
|
+
window.route = function escalatedRouteShimMissing(name) {
|
|
58
|
+
throw new Error(
|
|
59
|
+
`[escalated] window.route('${name}') called, but no \`route()\` helper is installed on this host. ` +
|
|
60
|
+
`The escalated agent/admin UI depends on Laravel's Ziggy-style \`route(name, params)\` helper. ` +
|
|
61
|
+
`Install Ziggy (on Laravel hosts) or register a compatible shim on window.route before mounting the app.`,
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
41
66
|
const themeDefaults = {
|
|
42
67
|
primary: '#4f46e5',
|
|
43
68
|
primaryHover: null,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML-encode a string to prevent injection via mention names.
|
|
3
|
+
*/
|
|
4
|
+
function escapeHtml(str) {
|
|
5
|
+
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Replace @{Name} patterns in text with styled mention badges.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} html - The HTML or text content
|
|
12
|
+
* @param {boolean} dark - Whether dark mode is active
|
|
13
|
+
* @returns {string} HTML with mentions wrapped in styled spans
|
|
14
|
+
*/
|
|
15
|
+
export function highlightMentions(html, dark = false) {
|
|
16
|
+
if (!html) return '';
|
|
17
|
+
|
|
18
|
+
const pillClass = dark
|
|
19
|
+
? 'inline-flex items-center rounded-full bg-cyan-500/15 px-1.5 py-0.5 text-xs font-medium text-cyan-400 ring-1 ring-cyan-500/20'
|
|
20
|
+
: 'inline-flex items-center rounded-full bg-blue-100 px-1.5 py-0.5 text-xs font-medium text-blue-700 ring-1 ring-blue-200';
|
|
21
|
+
|
|
22
|
+
// Replace @{Name} with styled pill, encoding the name to prevent injection
|
|
23
|
+
return html.replace(/@\{([^}]+)\}/g, (match, name) => `<span class="${pillClass}">@${escapeHtml(name)}</span>`);
|
|
24
|
+
}
|
|
@@ -1,64 +1,78 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sanitize HTML to prevent stored XSS.
|
|
3
|
-
*
|
|
4
|
-
* Uses the DOM parser to walk the tree and strip dangerous elements and
|
|
5
|
-
* attributes rather than regex, which avoids incomplete-sanitization pitfalls.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const DANGEROUS_TAGS = new Set([
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Sanitize HTML to prevent stored XSS.
|
|
3
|
+
*
|
|
4
|
+
* Uses the DOM parser to walk the tree and strip dangerous elements and
|
|
5
|
+
* attributes rather than regex, which avoids incomplete-sanitization pitfalls.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const DANGEROUS_TAGS = new Set([
|
|
9
|
+
'script',
|
|
10
|
+
'style',
|
|
11
|
+
'iframe',
|
|
12
|
+
'object',
|
|
13
|
+
'embed',
|
|
14
|
+
'form',
|
|
15
|
+
'input',
|
|
16
|
+
'textarea',
|
|
17
|
+
'button',
|
|
18
|
+
'select',
|
|
19
|
+
'option',
|
|
20
|
+
'link',
|
|
21
|
+
'meta',
|
|
22
|
+
'base',
|
|
23
|
+
'applet',
|
|
24
|
+
'noscript',
|
|
25
|
+
'noframes',
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
const URI_ATTRS = new Set(['href', 'src', 'action', 'formaction', 'xlink:href']);
|
|
29
|
+
|
|
30
|
+
export function sanitizeHtml(html) {
|
|
31
|
+
if (!html) return '';
|
|
32
|
+
|
|
33
|
+
const doc = new DOMParser().parseFromString(html, 'text/html');
|
|
34
|
+
|
|
35
|
+
// Remove dangerous elements
|
|
36
|
+
for (const tag of DANGEROUS_TAGS) {
|
|
37
|
+
const els = doc.body.getElementsByTagName(tag);
|
|
38
|
+
while (els.length) els[0].remove();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Walk all remaining elements and strip dangerous attributes
|
|
42
|
+
const all = doc.body.querySelectorAll('*');
|
|
43
|
+
for (let i = 0; i < all.length; i++) {
|
|
44
|
+
const el = all[i];
|
|
45
|
+
const attrs = [...el.attributes];
|
|
46
|
+
for (let j = 0; j < attrs.length; j++) {
|
|
47
|
+
const name = attrs[j].name.toLowerCase();
|
|
48
|
+
|
|
49
|
+
// Remove event handlers (onclick, onerror, etc.)
|
|
50
|
+
if (name.startsWith('on')) {
|
|
51
|
+
el.removeAttribute(attrs[j].name);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Remove javascript: / vbscript: / dangerous data: URIs
|
|
56
|
+
if (URI_ATTRS.has(name)) {
|
|
57
|
+
const val = (attrs[j].value || '').replace(/[\s\u0000-\u001F]+/g, '').toLowerCase();
|
|
58
|
+
if (
|
|
59
|
+
val.startsWith('javascript:') ||
|
|
60
|
+
val.startsWith('vbscript:') ||
|
|
61
|
+
(val.startsWith('data:') && !val.startsWith('data:image/'))
|
|
62
|
+
) {
|
|
63
|
+
el.removeAttribute(attrs[j].name);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Remove style attributes containing expressions or javascript
|
|
68
|
+
if (name === 'style') {
|
|
69
|
+
const val = (attrs[j].value || '').toLowerCase();
|
|
70
|
+
if (val.includes('expression(') || val.includes('javascript:') || val.includes('url(')) {
|
|
71
|
+
el.removeAttribute(attrs[j].name);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return doc.body.innerHTML;
|
|
78
|
+
}
|