@underverse-ui/underverse 1.0.144 → 1.0.145
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/api-reference.json +1 -1
- package/dist/index.cjs +93 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +95 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/api-reference.json
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -25927,12 +25927,66 @@ function getClipboardTableHtml(dataTransfer) {
|
|
|
25927
25927
|
function escapeHtml(value) {
|
|
25928
25928
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
25929
25929
|
}
|
|
25930
|
+
function renderCellHtml(value) {
|
|
25931
|
+
const lines = value.split("\n");
|
|
25932
|
+
return lines.map((line) => `<p>${escapeHtml(line)}</p>`).join("");
|
|
25933
|
+
}
|
|
25934
|
+
function parseTsvRows(text) {
|
|
25935
|
+
const rows = [];
|
|
25936
|
+
let row = [];
|
|
25937
|
+
let field = "";
|
|
25938
|
+
let inQuotes = false;
|
|
25939
|
+
const pushField = () => {
|
|
25940
|
+
row.push(field);
|
|
25941
|
+
field = "";
|
|
25942
|
+
};
|
|
25943
|
+
const pushRow = () => {
|
|
25944
|
+
pushField();
|
|
25945
|
+
rows.push(row);
|
|
25946
|
+
row = [];
|
|
25947
|
+
};
|
|
25948
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
25949
|
+
const char = text[index];
|
|
25950
|
+
const next = text[index + 1];
|
|
25951
|
+
if (inQuotes) {
|
|
25952
|
+
if (char === '"' && next === '"') {
|
|
25953
|
+
field += '"';
|
|
25954
|
+
index += 1;
|
|
25955
|
+
continue;
|
|
25956
|
+
}
|
|
25957
|
+
if (char === '"') {
|
|
25958
|
+
inQuotes = false;
|
|
25959
|
+
continue;
|
|
25960
|
+
}
|
|
25961
|
+
field += char;
|
|
25962
|
+
continue;
|
|
25963
|
+
}
|
|
25964
|
+
if (char === '"' && field.length === 0) {
|
|
25965
|
+
inQuotes = true;
|
|
25966
|
+
continue;
|
|
25967
|
+
}
|
|
25968
|
+
if (char === " ") {
|
|
25969
|
+
pushField();
|
|
25970
|
+
continue;
|
|
25971
|
+
}
|
|
25972
|
+
if (char === "\n") {
|
|
25973
|
+
pushRow();
|
|
25974
|
+
continue;
|
|
25975
|
+
}
|
|
25976
|
+
field += char;
|
|
25977
|
+
}
|
|
25978
|
+
pushRow();
|
|
25979
|
+
while (rows.length > 0 && rows[rows.length - 1].every((cell) => cell === "")) {
|
|
25980
|
+
rows.pop();
|
|
25981
|
+
}
|
|
25982
|
+
return rows;
|
|
25983
|
+
}
|
|
25930
25984
|
function getClipboardTsvTableHtml(dataTransfer) {
|
|
25931
25985
|
const text = getClipboardData(dataTransfer, "text/plain").replace(/\r\n/g, "\n").replace(/\r/g, "\n").replace(/\n+$/, "");
|
|
25932
25986
|
if (!text.includes(" ")) return "";
|
|
25933
|
-
const rows = text
|
|
25987
|
+
const rows = parseTsvRows(text);
|
|
25934
25988
|
if (rows.length === 0 || rows.every((row) => row.length < 2)) return "";
|
|
25935
|
-
const body = rows.map((row) => `<tr>${row.map((cell) => `<td>${
|
|
25989
|
+
const body = rows.map((row) => `<tr>${row.map((cell) => `<td>${renderCellHtml(cell)}</td>`).join("")}</tr>`).join("");
|
|
25936
25990
|
return `<table><tbody>${body}</tbody></table>`;
|
|
25937
25991
|
}
|
|
25938
25992
|
function fileToDataUrl(file) {
|
|
@@ -36721,6 +36775,14 @@ var MenuBar = ({
|
|
|
36721
36775
|
}
|
|
36722
36776
|
openPreviewDialog();
|
|
36723
36777
|
};
|
|
36778
|
+
import_react67.default.useEffect(() => {
|
|
36779
|
+
if (!showPreviewDialog) return void 0;
|
|
36780
|
+
const previousOverflow = document.body.style.overflow;
|
|
36781
|
+
document.body.style.overflow = "hidden";
|
|
36782
|
+
return () => {
|
|
36783
|
+
document.body.style.overflow = previousOverflow;
|
|
36784
|
+
};
|
|
36785
|
+
}, [showPreviewDialog]);
|
|
36724
36786
|
const applySourceHtml = () => {
|
|
36725
36787
|
editor.chain().focus().setContent(sourceHtml).run();
|
|
36726
36788
|
setShowSourceDialog(false);
|
|
@@ -36938,29 +37000,38 @@ var MenuBar = ({
|
|
|
36938
37000
|
] })
|
|
36939
37001
|
}
|
|
36940
37002
|
),
|
|
36941
|
-
/* @__PURE__ */ (0, import_jsx_runtime93.
|
|
36942
|
-
|
|
36943
|
-
|
|
36944
|
-
|
|
36945
|
-
|
|
36946
|
-
title: t("menubar.preview"),
|
|
36947
|
-
size: "lg",
|
|
36948
|
-
children: editor.isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("p", { className: "text-muted-foreground text-sm", children: t("menubar.previewEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
|
|
36949
|
-
"div",
|
|
37003
|
+
showPreviewDialog && /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: "fixed inset-0 z-9999 flex flex-col bg-background text-foreground", children: [
|
|
37004
|
+
/* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: "flex shrink-0 items-center justify-between border-b border-border bg-card px-4 py-3", children: [
|
|
37005
|
+
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)("h2", { className: "text-base font-semibold", children: t("menubar.preview") }),
|
|
37006
|
+
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
|
|
37007
|
+
"button",
|
|
36950
37008
|
{
|
|
36951
|
-
|
|
36952
|
-
|
|
36953
|
-
|
|
36954
|
-
|
|
36955
|
-
|
|
36956
|
-
|
|
36957
|
-
|
|
36958
|
-
|
|
36959
|
-
)
|
|
37009
|
+
type: "button",
|
|
37010
|
+
onClick: () => setShowPreviewDialog(false),
|
|
37011
|
+
"aria-label": t("menubar.closeDialog"),
|
|
37012
|
+
className: cn(
|
|
37013
|
+
"inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors",
|
|
37014
|
+
"hover:bg-accent hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1"
|
|
37015
|
+
),
|
|
37016
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_lucide_react53.X, { className: "h-4 w-4", "aria-hidden": "true" })
|
|
36960
37017
|
}
|
|
36961
37018
|
)
|
|
36962
|
-
}
|
|
36963
|
-
|
|
37019
|
+
] }),
|
|
37020
|
+
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
|
|
37021
|
+
"div",
|
|
37022
|
+
{
|
|
37023
|
+
"data-testid": "preview-content",
|
|
37024
|
+
className: "min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 py-4 md:px-8",
|
|
37025
|
+
children: editor.isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("p", { className: "text-muted-foreground text-sm", children: t("menubar.previewEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
|
|
37026
|
+
"div",
|
|
37027
|
+
{
|
|
37028
|
+
className: UEDITOR_PROSEMIRROR_CLASS_NAME,
|
|
37029
|
+
dangerouslySetInnerHTML: { __html: editor.getHTML() }
|
|
37030
|
+
}
|
|
37031
|
+
)
|
|
37032
|
+
}
|
|
37033
|
+
)
|
|
37034
|
+
] })
|
|
36964
37035
|
] });
|
|
36965
37036
|
};
|
|
36966
37037
|
|