@zero-library/common 3.2.0 → 3.2.2

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.cjs.js CHANGED
@@ -1378,6 +1378,7 @@ var commonZhCN = {
1378
1378
  filePreview: {
1379
1379
  title: "\u6587\u4EF6\u9884\u89C8",
1380
1380
  closePreview: "\u5173\u95ED\u9884\u89C8",
1381
+ htmlPreviewTitle: "HTML \u9884\u89C8",
1381
1382
  previewImageAlt: "\u9884\u89C8\u56FE\u7247",
1382
1383
  previewNotSupported: "\u6682\u4E0D\u652F\u6301 {{suffix}} \u6587\u4EF6\u7684\u9884\u89C8",
1383
1384
  previewNotSupportedDownload: "{{suffix}} \u6587\u4EF6\u6682\u4E0D\u652F\u6301\u5728\u7EBF\u9884\u89C8\uFF0C\u8BF7\u4E0B\u8F7D\u6253\u5F00",
@@ -1412,6 +1413,7 @@ var commonZhCN = {
1412
1413
  unknown: "\u672A\u77E5",
1413
1414
  // 工具栏
1414
1415
  toolbar: {
1416
+ toolbarAria: "\u7F16\u8F91\u5668\u5DE5\u5177\u680F",
1415
1417
  quote: "\u5F15\u7528\u9009\u4E2D\u6587\u672C",
1416
1418
  annotation: "\u6279\u6CE8",
1417
1419
  excerpt: "\u6458\u5F55\u7B14\u8BB0",
@@ -1449,6 +1451,7 @@ var commonZhCN = {
1449
1451
  toggle: "\u5207\u6362\u9AD8\u4EAE\u663E\u793A ({{color}})",
1450
1452
  label: "\u80CC\u666F\u8272",
1451
1453
  textLabel: "\u6587\u672C\u80CC\u666F\u8272",
1454
+ colorOptionAria: "{{label}} \u9AD8\u4EAE\u989C\u8272",
1452
1455
  removeBackground: "\u79FB\u9664\u80CC\u666F",
1453
1456
  removeHighlight: "\u79FB\u9664\u9AD8\u4EAE",
1454
1457
  default: "\u9ED8\u8BA4\u80CC\u666F",
@@ -1485,7 +1488,14 @@ var commonZhCN = {
1485
1488
  empty: "\u6682\u65E0\u6458\u5F55"
1486
1489
  },
1487
1490
  // 文件 / 图片上传
1491
+ themeToggle: {
1492
+ switchToLight: "\u5207\u6362\u5230\u6D45\u8272\u6A21\u5F0F",
1493
+ switchToDark: "\u5207\u6362\u5230\u6DF1\u8272\u6A21\u5F0F"
1494
+ },
1488
1495
  upload: {
1496
+ clickToUpload: "\u70B9\u51FB\u4E0A\u4F20",
1497
+ dragAndDrop: "\u6216\u62D6\u62FD\u5230\u6B64\u5904",
1498
+ maxFileHint: "\u6700\u591A {{limit}} \u4E2A\u6587\u4EF6\uFF0C\u6BCF\u4E2A {{size}}MB",
1489
1499
  noFile: "\u672A\u63D0\u4F9B\u6587\u4EF6",
1490
1500
  canceled: "\u4E0A\u4F20\u5DF2\u53D6\u6D88",
1491
1501
  fileSizeExceeded: "\u6587\u4EF6\u5927\u5C0F\u8D85\u8FC7\u6700\u5927\u9650\u5236 ({{max}}MB)",
@@ -1567,6 +1577,7 @@ var commonEnUS = {
1567
1577
  filePreview: {
1568
1578
  title: "File Preview",
1569
1579
  closePreview: "Close preview",
1580
+ htmlPreviewTitle: "HTML Preview",
1570
1581
  previewImageAlt: "Preview image",
1571
1582
  previewNotSupported: "Preview of {{suffix}} files is not supported",
1572
1583
  previewNotSupportedDownload: "{{suffix}} files cannot be previewed online, please download and open",
@@ -1599,6 +1610,7 @@ var commonEnUS = {
1599
1610
  mainArea: "Main content area, start typing...",
1600
1611
  unknown: "Unknown",
1601
1612
  toolbar: {
1613
+ toolbarAria: "Editor toolbar",
1602
1614
  quote: "Quote Selected Text",
1603
1615
  annotation: "Annotate",
1604
1616
  excerpt: "Excerpt Note",
@@ -1635,6 +1647,7 @@ var commonEnUS = {
1635
1647
  toggle: "Toggle highlight ({{color}})",
1636
1648
  label: "Background color",
1637
1649
  textLabel: "Text background color",
1650
+ colorOptionAria: "{{label}} highlight color",
1638
1651
  removeBackground: "Remove background",
1639
1652
  removeHighlight: "Remove highlight",
1640
1653
  default: "Default background",
@@ -1668,7 +1681,14 @@ var commonEnUS = {
1668
1681
  confirmDelete: "Delete this excerpt?",
1669
1682
  empty: "No excerpts"
1670
1683
  },
1684
+ themeToggle: {
1685
+ switchToLight: "Switch to light mode",
1686
+ switchToDark: "Switch to dark mode"
1687
+ },
1671
1688
  upload: {
1689
+ clickToUpload: "Click to upload",
1690
+ dragAndDrop: "or drag and drop",
1691
+ maxFileHint: "Maximum {{limit}} files, {{size}}MB each",
1672
1692
  noFile: "No file provided",
1673
1693
  canceled: "Upload canceled",
1674
1694
  fileSizeExceeded: "File size exceeds the maximum limit ({{max}}MB)",
@@ -1759,6 +1779,7 @@ var commonJaJP = {
1759
1779
  filePreview: {
1760
1780
  title: "\u30D5\u30A1\u30A4\u30EB\u30D7\u30EC\u30D3\u30E5\u30FC",
1761
1781
  closePreview: "\u30D7\u30EC\u30D3\u30E5\u30FC\u3092\u9589\u3058\u308B",
1782
+ htmlPreviewTitle: "HTML \u30D7\u30EC\u30D3\u30E5\u30FC",
1762
1783
  previewImageAlt: "\u30D7\u30EC\u30D3\u30E5\u30FC\u753B\u50CF",
1763
1784
  previewNotSupported: "{{suffix}}\u30D5\u30A1\u30A4\u30EB\u306E\u30D7\u30EC\u30D3\u30E5\u30FC\u306B\u306F\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u305B\u3093",
1764
1785
  previewNotSupportedDownload: "{{suffix}}\u30D5\u30A1\u30A4\u30EB\u306F\u30AA\u30F3\u30E9\u30A4\u30F3\u30D7\u30EC\u30D3\u30E5\u30FC\u306B\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u305B\u3093\u3002\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u3057\u3066\u958B\u3044\u3066\u304F\u3060\u3055\u3044",
@@ -1793,6 +1814,7 @@ var commonJaJP = {
1793
1814
  unknown: "\u4E0D\u660E",
1794
1815
  // ツールバー
1795
1816
  toolbar: {
1817
+ toolbarAria: "\u30A8\u30C7\u30A3\u30BF\u30FC\u30C4\u30FC\u30EB\u30D0\u30FC",
1796
1818
  quote: "\u9078\u629E\u30C6\u30AD\u30B9\u30C8\u3092\u5F15\u7528",
1797
1819
  annotation: "\u6CE8\u91C8",
1798
1820
  excerpt: "\u629C\u7C8B\u30E1\u30E2",
@@ -1830,6 +1852,7 @@ var commonJaJP = {
1830
1852
  toggle: "\u30CF\u30A4\u30E9\u30A4\u30C8\u8868\u793A\u3092\u5207\u308A\u66FF\u3048 ({{color}})",
1831
1853
  label: "\u80CC\u666F\u8272",
1832
1854
  textLabel: "\u30C6\u30AD\u30B9\u30C8\u80CC\u666F\u8272",
1855
+ colorOptionAria: "{{label}} \u306E\u30CF\u30A4\u30E9\u30A4\u30C8\u8272",
1833
1856
  removeBackground: "\u80CC\u666F\u3092\u524A\u9664",
1834
1857
  removeHighlight: "\u30CF\u30A4\u30E9\u30A4\u30C8\u3092\u524A\u9664",
1835
1858
  default: "\u30C7\u30D5\u30A9\u30EB\u30C8\u80CC\u666F",
@@ -1866,7 +1889,14 @@ var commonJaJP = {
1866
1889
  empty: "\u629C\u7C8B\u306F\u3042\u308A\u307E\u305B\u3093"
1867
1890
  },
1868
1891
  // ファイル / 画像アップロード
1892
+ themeToggle: {
1893
+ switchToLight: "\u30E9\u30A4\u30C8\u30E2\u30FC\u30C9\u306B\u5207\u308A\u66FF\u3048",
1894
+ switchToDark: "\u30C0\u30FC\u30AF\u30E2\u30FC\u30C9\u306B\u5207\u308A\u66FF\u3048"
1895
+ },
1869
1896
  upload: {
1897
+ clickToUpload: "\u30AF\u30EA\u30C3\u30AF\u3057\u3066\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9",
1898
+ dragAndDrop: "\u307E\u305F\u306F\u30C9\u30E9\u30C3\u30B0\uFF06\u30C9\u30ED\u30C3\u30D7",
1899
+ maxFileHint: "\u6700\u5927 {{limit}} \u4EF6\u3001\u5404 {{size}}MB \u307E\u3067",
1870
1900
  noFile: "\u30D5\u30A1\u30A4\u30EB\u304C\u63D0\u4F9B\u3055\u308C\u3066\u3044\u307E\u305B\u3093",
1871
1901
  canceled: "\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306F\u30AD\u30E3\u30F3\u30BB\u30EB\u3055\u308C\u307E\u3057\u305F",
1872
1902
  fileSizeExceeded: "\u30D5\u30A1\u30A4\u30EB\u30B5\u30A4\u30BA\u304C\u6700\u5927\u5236\u9650\u3092\u8D85\u3048\u3066\u3044\u307E\u3059 ({{max}}MB)",
@@ -1896,10 +1926,21 @@ var LocaleProvider = ({ children, ...rest }) => {
1896
1926
 
1897
1927
  // src/i18n/index.ts
1898
1928
  var DEFAULT_LNG = "zh-CN";
1929
+ function normalizeLang(lng) {
1930
+ const normalized = String(lng || "").trim().toLowerCase();
1931
+ if (!normalized) return DEFAULT_LNG;
1932
+ if (normalized.startsWith("zh")) return "zh-CN";
1933
+ if (normalized.startsWith("en")) return "en-US";
1934
+ if (normalized.startsWith("ja")) return "ja-JP";
1935
+ }
1936
+ function getNavigatorLang() {
1937
+ if (typeof navigator === "undefined") return DEFAULT_LNG;
1938
+ return normalizeLang(navigator.language);
1939
+ }
1899
1940
  var LANG_KEY = "ns-lang";
1900
1941
  var langManager = createTokenManager({ key: LANG_KEY });
1901
1942
  function getLang() {
1902
- return langManager.get() || DEFAULT_LNG;
1943
+ return langManager.get() || getNavigatorLang();
1903
1944
  }
1904
1945
  var i18n = i18next.createInstance({
1905
1946
  lng: DEFAULT_LNG,
@@ -1924,11 +1965,12 @@ function initI18n(options = {}) {
1924
1965
  return i18n;
1925
1966
  }
1926
1967
  function switchLang(lng, reload = false) {
1927
- langManager.set(lng);
1968
+ const nextLang = normalizeLang(lng);
1969
+ langManager.set(nextLang);
1928
1970
  if (reload) {
1929
1971
  window?.top?.location.reload();
1930
1972
  } else {
1931
- i18n.changeLanguage(lng);
1973
+ i18n.changeLanguage(nextLang);
1932
1974
  }
1933
1975
  }
1934
1976
  function useTranslation(namespace) {
@@ -3507,7 +3549,7 @@ var CodePreview = ({ fileUrl, suffix }) => {
3507
3549
  var CodePreview_default = CodePreview;
3508
3550
  var { Text } = antd.Typography;
3509
3551
  pdfjsLib__namespace.GlobalWorkerOptions.workerSrc = "https://unpkg.com/pdfjs-dist@5.4.296/legacy/build/pdf.worker.min.mjs";
3510
- var MIN_SCALE = 0.6;
3552
+ var MIN_SCALE = 0.1;
3511
3553
  var MAX_SCALE = 1.5;
3512
3554
  var SCALE_STEP = 0.1;
3513
3555
  var PdfPage = React3__namespace.default.memo(({ pdf, pageNumber, scale, scrollContainerRef, defaultSize }) => {
@@ -3853,7 +3895,7 @@ var HtmlPreview = ({ fileUrl }) => {
3853
3895
  srcDoc: content,
3854
3896
  style: { width: "100%", height: "100%", border: "none" },
3855
3897
  sandbox: "allow-scripts allow-same-origin allow-popups allow-forms",
3856
- title: "HTML Preview"
3898
+ title: t2("filePreview.htmlPreviewTitle")
3857
3899
  }
3858
3900
  ) : null });
3859
3901
  };
@@ -6047,13 +6089,14 @@ var Toolbar = React3.forwardRef(
6047
6089
  ({ children, className, variant = "fixed", ...props }, ref) => {
6048
6090
  const toolbarRef = React3.useRef(null);
6049
6091
  const composedRef = useComposedRef(toolbarRef, ref);
6092
+ const { t: t2 } = useTranslation(NS_COMMON);
6050
6093
  useToolbarNavigation(toolbarRef);
6051
6094
  return /* @__PURE__ */ jsxRuntime.jsx(
6052
6095
  "div",
6053
6096
  {
6054
6097
  ref: composedRef,
6055
6098
  role: "toolbar",
6056
- "aria-label": "toolbar",
6099
+ "aria-label": t2("markdownEditor.toolbar.toolbarAria"),
6057
6100
  "data-variant": variant,
6058
6101
  className: cn("tiptap-toolbar", className),
6059
6102
  ...props,
@@ -7043,7 +7086,7 @@ function ColorHighlightPopoverContent({
7043
7086
  editor,
7044
7087
  highlightColor: color.value,
7045
7088
  tooltip: t2(color.labelKey),
7046
- "aria-label": `${t2(color.labelKey)} highlight color`,
7089
+ "aria-label": t2("markdownEditor.highlight.colorOptionAria", { label: t2(color.labelKey) }),
7047
7090
  tabIndex: index === selectedIndex ? 0 : -1,
7048
7091
  "data-highlighted": selectedIndex === index
7049
7092
  },
@@ -7615,7 +7658,7 @@ var HeadingDropdownMenu = React3.forwardRef(
7615
7658
  tabIndex: -1,
7616
7659
  disabled: !canToggle3,
7617
7660
  "data-disabled": !canToggle3,
7618
- "aria-label": "Format text as heading",
7661
+ "aria-label": t2("markdownEditor.toolbar.heading"),
7619
7662
  "aria-pressed": isActive,
7620
7663
  tooltip: t2("markdownEditor.toolbar.heading"),
7621
7664
  ...buttonProps,