synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
116 lines (115 loc) • 3.67 kB
JavaScript
import { jsxs as s, jsx as o } from "react/jsx-runtime";
import { useState as d } from "react";
import { Markdown as g } from "./MarkdownSynapse.js";
import { displayToast as k } from "../ToastMessage/ToastMessage.js";
import { Typography as p, Box as c, Collapse as b } from "@mui/material";
import { KeyboardArrowUpTwoTone as v, KeyboardArrowDownTwoTone as M, ContentCopyTwoTone as S } from "@mui/icons-material";
import { copyStringToClipboard as P } from "../../utils/functions/StringUtils.js";
import { stripHTML as j } from "./MarkdownUtils.js";
const N = (t) => {
const [r, w] = d(!1), [e, f] = d(), [l, h] = d(), y = (i) => {
if (i) {
const n = j(i);
n.trim() !== l && (h(n.trim()), f(n.trim().split(/\s+/).length), t.setPlainTextResult && t.setPlainTextResult(n.trim()));
}
}, {
textDescription: x = "full text",
showCopyPlainText: u,
markdown: C,
ownerId: T,
title: m
} = t;
if (C == null && T == null)
return;
const a = {
color: "grey.700",
marginBottom: "-5px !important",
height: "18px"
};
return /* @__PURE__ */ s(
"div",
{
className: "MarkdownCollapse",
style: {
display: e != null && e > 0 ? "block" : "none"
},
children: [
m && /* @__PURE__ */ o(p, { variant: "subtitle1", sx: { margin: "20px 0px 10px 0px" }, children: m }),
/* @__PURE__ */ s(
c,
{
sx: {
display: "flex",
justifyContent: "space-between",
backgroundColor: "grey.200",
padding: "15px"
},
children: [
/* @__PURE__ */ s(
p,
{
variant: "smallLink",
onClick: () => w(!r),
"aria-controls": "collapse-text",
"aria-expanded": r,
sx: {
"&:hover": {
cursor: "pointer"
}
},
children: [
r ? "Hide" : "View",
" ",
x,
" ",
e ? `(${e} words)` : "",
r ? /* @__PURE__ */ o(v, { sx: a }) : /* @__PURE__ */ o(M, { sx: a })
]
}
),
u && /* @__PURE__ */ o(c, { children: /* @__PURE__ */ s(
p,
{
variant: "smallLink",
onClick: () => {
l && P(l).then(
() => {
k("Successfully copied to the clipboard");
},
(i) => {
console.error(i);
}
);
},
sx: {
"&:hover": {
cursor: "pointer"
}
},
children: [
/* @__PURE__ */ o(S, { sx: a }),
"Copy ",
x,
" to clipboard"
]
}
) })
]
}
),
/* @__PURE__ */ o(b, { in: r, children: /* @__PURE__ */ o(c, { sx: { backgroundColor: "grey.100", padding: "25px" }, children: /* @__PURE__ */ o("div", { id: "collapse-text", children: /* @__PURE__ */ o(
g,
{
...t,
onMarkdownProcessingDone: y
}
) }) }) })
]
}
);
};
export {
N as MarkdownCollapse,
N as default
};
//# sourceMappingURL=MarkdownCollapse.js.map