@nextcloud/vue
Version:
Nextcloud vue components
47 lines (46 loc) • 3.2 kB
JavaScript
import { generateUrl as u } from "@nextcloud/router";
/* empty css */import { n as c } from "./_plugin-vue2_normalizer-5b4c43a4.mjs";
import { L as m } from "./Linkify-a0faf443.mjs";
import d from "escape-html";
import s from "striptags";
import b from "vue";
const g = { name: "NcMentionBubble", props: { id: { type: String, required: !0 }, title: { type: String, required: !0 }, icon: { type: String, required: !0 }, iconUrl: { type: [String, null], default: null }, source: { type: String, required: !0 }, primary: { type: Boolean, default: !1 } }, computed: { avatarUrl() {
return this.iconUrl ? this.iconUrl : this.id && this.source === "users" ? this.getAvatarUrl(this.id, 44) : null;
}, mentionText() {
return !this.id.includes(" ") && !this.id.includes("/") ? `@${this.id}` : `@"${this.id}"`;
} }, methods: { getAvatarUrl(t, e) {
return u("/avatar/{user}/{size}", { user: t, size: e });
} } };
var h = function() {
var t = this, e = t._self._c;
return e("span", { staticClass: "mention-bubble", class: { "mention-bubble--primary": t.primary }, attrs: { contenteditable: "false" } }, [e("span", { staticClass: "mention-bubble__wrapper" }, [e("span", { staticClass: "mention-bubble__content" }, [e("span", { staticClass: "mention-bubble__icon", class: [t.icon, `mention-bubble__icon--${t.avatarUrl ? "with-avatar" : ""}`], style: t.avatarUrl ? { backgroundImage: `url(${t.avatarUrl})` } : null }), e("span", { staticClass: "mention-bubble__title", attrs: { role: "heading", title: t.title } })]), e("span", { staticClass: "mention-bubble__select", attrs: { role: "none" } }, [t._v(t._s(t.mentionText))])])]);
}, _ = [], f = c(g, h, _, !1, null, "357e6d0e", null, null);
const v = f.exports, l = "(?:^|\\s)", o = "(?:[^a-z]|$)", y = new RegExp(`${l}(@[a-zA-Z0-9_.@\\-']+)(${o})`, "gi"), $ = new RegExp(`${l}(@"[a-zA-Z0-9 _.@\\-']+")(${o})`, "gi"), z = { props: { userData: { type: Object, default: () => ({}) } }, methods: { renderContent(t) {
return d(t).split(y).map((e) => e.split($)).flat().map((e) => {
if (!e.startsWith("@"))
return m(e);
const n = e.slice(1).replace(/"/gi, "");
return " " + this.genSelectTemplate(n);
}).join("").replace(/\n/gmi, "<br>").replace(/&/gmi, "&");
}, parseContent(t) {
let e = t.replace(/<br>/gmi, `
`);
return e = e.replace(/ /gmi, " "), e = e.replace(/&/gmi, "&"), e = e.replace(/<\/div>/gmi, `
`), e = s(e, "<div>"), e = s(e), e;
}, genSelectTemplate(t) {
if (typeof t > "u")
return `${this.autocompleteTribute.current.collection.trigger}${this.autocompleteTribute.current.mentionText}`;
const e = this.userData[t];
return e ? this.renderComponentHtml(e, v).replace(/[\n\t]/gmi, "") : !t.includes(" ") && !t.includes("/") ? `@${t}` : `@"${t}"`;
}, renderComponentHtml(t, e) {
const n = b.extend(e), i = new n({ propsData: t }), r = document.createElement("div"), a = document.createElement("div");
r.style.display = "none", r.appendChild(a), document.body.appendChild(r), i.$mount(a);
const p = r.innerHTML;
return i.$destroy(), r.remove(), p;
} } };
export {
v as N,
y as U,
$ as a,
z as r
};