@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/dist/index.js CHANGED
@@ -25772,12 +25772,66 @@ function getClipboardTableHtml(dataTransfer) {
25772
25772
  function escapeHtml(value) {
25773
25773
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
25774
25774
  }
25775
+ function renderCellHtml(value) {
25776
+ const lines = value.split("\n");
25777
+ return lines.map((line) => `<p>${escapeHtml(line)}</p>`).join("");
25778
+ }
25779
+ function parseTsvRows(text) {
25780
+ const rows = [];
25781
+ let row = [];
25782
+ let field = "";
25783
+ let inQuotes = false;
25784
+ const pushField = () => {
25785
+ row.push(field);
25786
+ field = "";
25787
+ };
25788
+ const pushRow = () => {
25789
+ pushField();
25790
+ rows.push(row);
25791
+ row = [];
25792
+ };
25793
+ for (let index = 0; index < text.length; index += 1) {
25794
+ const char = text[index];
25795
+ const next = text[index + 1];
25796
+ if (inQuotes) {
25797
+ if (char === '"' && next === '"') {
25798
+ field += '"';
25799
+ index += 1;
25800
+ continue;
25801
+ }
25802
+ if (char === '"') {
25803
+ inQuotes = false;
25804
+ continue;
25805
+ }
25806
+ field += char;
25807
+ continue;
25808
+ }
25809
+ if (char === '"' && field.length === 0) {
25810
+ inQuotes = true;
25811
+ continue;
25812
+ }
25813
+ if (char === " ") {
25814
+ pushField();
25815
+ continue;
25816
+ }
25817
+ if (char === "\n") {
25818
+ pushRow();
25819
+ continue;
25820
+ }
25821
+ field += char;
25822
+ }
25823
+ pushRow();
25824
+ while (rows.length > 0 && rows[rows.length - 1].every((cell) => cell === "")) {
25825
+ rows.pop();
25826
+ }
25827
+ return rows;
25828
+ }
25775
25829
  function getClipboardTsvTableHtml(dataTransfer) {
25776
25830
  const text = getClipboardData(dataTransfer, "text/plain").replace(/\r\n/g, "\n").replace(/\r/g, "\n").replace(/\n+$/, "");
25777
25831
  if (!text.includes(" ")) return "";
25778
- const rows = text.split("\n").map((row) => row.split(" "));
25832
+ const rows = parseTsvRows(text);
25779
25833
  if (rows.length === 0 || rows.every((row) => row.length < 2)) return "";
25780
- const body = rows.map((row) => `<tr>${row.map((cell) => `<td>${escapeHtml(cell)}</td>`).join("")}</tr>`).join("");
25834
+ const body = rows.map((row) => `<tr>${row.map((cell) => `<td>${renderCellHtml(cell)}</td>`).join("")}</tr>`).join("");
25781
25835
  return `<table><tbody>${body}</tbody></table>`;
25782
25836
  }
25783
25837
  function fileToDataUrl(file) {
@@ -36166,7 +36220,8 @@ import {
36166
36220
  Trash2 as Trash25,
36167
36221
  Underline as UnderlineIcon3,
36168
36222
  Undo as UndoIcon2,
36169
- Upload as Upload4
36223
+ Upload as Upload4,
36224
+ X as X19
36170
36225
  } from "lucide-react";
36171
36226
  import { Fragment as Fragment35, jsx as jsx92, jsxs as jsxs77 } from "react/jsx-runtime";
36172
36227
  function MenuTableInsertGrid({
@@ -36664,6 +36719,14 @@ var MenuBar = ({
36664
36719
  }
36665
36720
  openPreviewDialog();
36666
36721
  };
36722
+ React81.useEffect(() => {
36723
+ if (!showPreviewDialog) return void 0;
36724
+ const previousOverflow = document.body.style.overflow;
36725
+ document.body.style.overflow = "hidden";
36726
+ return () => {
36727
+ document.body.style.overflow = previousOverflow;
36728
+ };
36729
+ }, [showPreviewDialog]);
36667
36730
  const applySourceHtml = () => {
36668
36731
  editor.chain().focus().setContent(sourceHtml).run();
36669
36732
  setShowSourceDialog(false);
@@ -36881,29 +36944,38 @@ var MenuBar = ({
36881
36944
  ] })
36882
36945
  }
36883
36946
  ),
36884
- /* @__PURE__ */ jsx92(
36885
- Modal_default,
36886
- {
36887
- isOpen: showPreviewDialog,
36888
- onClose: () => setShowPreviewDialog(false),
36889
- title: t("menubar.preview"),
36890
- size: "lg",
36891
- children: editor.isEmpty ? /* @__PURE__ */ jsx92("p", { className: "text-muted-foreground text-sm", children: t("menubar.previewEmpty") }) : /* @__PURE__ */ jsx92(
36892
- "div",
36947
+ showPreviewDialog && /* @__PURE__ */ jsxs77("div", { className: "fixed inset-0 z-9999 flex flex-col bg-background text-foreground", children: [
36948
+ /* @__PURE__ */ jsxs77("div", { className: "flex shrink-0 items-center justify-between border-b border-border bg-card px-4 py-3", children: [
36949
+ /* @__PURE__ */ jsx92("h2", { className: "text-base font-semibold", children: t("menubar.preview") }),
36950
+ /* @__PURE__ */ jsx92(
36951
+ "button",
36893
36952
  {
36894
- "data-testid": "preview-content",
36895
- className: "max-h-[70vh] overflow-y-auto overscroll-contain pr-2",
36896
- children: /* @__PURE__ */ jsx92(
36897
- "div",
36898
- {
36899
- className: UEDITOR_PROSEMIRROR_CLASS_NAME,
36900
- dangerouslySetInnerHTML: { __html: editor.getHTML() }
36901
- }
36902
- )
36953
+ type: "button",
36954
+ onClick: () => setShowPreviewDialog(false),
36955
+ "aria-label": t("menubar.closeDialog"),
36956
+ className: cn(
36957
+ "inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors",
36958
+ "hover:bg-accent hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1"
36959
+ ),
36960
+ children: /* @__PURE__ */ jsx92(X19, { className: "h-4 w-4", "aria-hidden": "true" })
36903
36961
  }
36904
36962
  )
36905
- }
36906
- )
36963
+ ] }),
36964
+ /* @__PURE__ */ jsx92(
36965
+ "div",
36966
+ {
36967
+ "data-testid": "preview-content",
36968
+ className: "min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 py-4 md:px-8",
36969
+ children: editor.isEmpty ? /* @__PURE__ */ jsx92("p", { className: "text-muted-foreground text-sm", children: t("menubar.previewEmpty") }) : /* @__PURE__ */ jsx92(
36970
+ "div",
36971
+ {
36972
+ className: UEDITOR_PROSEMIRROR_CLASS_NAME,
36973
+ dangerouslySetInnerHTML: { __html: editor.getHTML() }
36974
+ }
36975
+ )
36976
+ }
36977
+ )
36978
+ ] })
36907
36979
  ] });
36908
36980
  };
36909
36981