@yudaocode/univer-docs-ui 1.6.210 → 1.6.211

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/lib/cjs/index.js CHANGED
@@ -39,6 +39,7 @@ var __decorateParam = (index, decorator) => (target, key) => decorator(target, k
39
39
  // src/index.ts
40
40
  var src_exports = {};
41
41
  __export(src_exports, {
42
+ DOC_IMPORT_ACCEPT_EXTENSIONS: () => DOC_IMPORT_ACCEPT_EXTENSIONS,
42
43
  DOC_INSPECTOR_COMPONENT_KEY: () => DOC_INSPECTOR_COMPONENT_KEY,
43
44
  DOC_INSPECTOR_SIDEBAR_ID: () => DOC_INSPECTOR_SIDEBAR_ID,
44
45
  DocInspectorPanel: () => DocInspectorPanel,
@@ -490,34 +491,43 @@ var PrintDocOperation = {
490
491
  return triggerIframePrint(pdfBytes);
491
492
  }
492
493
  };
494
+ var DOC_IMPORT_ACCEPT_EXTENSIONS = ".docx,.doc,.rtf,.odt,.xml,.md,.html,.txt,.json";
493
495
  var ImportDocFileOperation = {
494
496
  id: "yudao-docs-ui.operation.import-file",
495
497
  type: import_core2.CommandType.OPERATION,
496
498
  handler: (accessor, params) => {
497
- if (typeof document === "undefined") return false;
498
499
  const commandService = accessor.get(import_core2.ICommandService);
499
- const instanceService = accessor.get(import_core2.IUniverInstanceService);
500
- const ioService = accessor.get(import_univer_docs.IDocIoService);
501
- const input = document.createElement("input");
502
- input.type = "file";
503
- input.accept = ".docx,.doc,.rtf,.odt,.xml,.md,.html,.txt,.json";
504
- input.onchange = async () => {
505
- const file = input.files?.[0];
506
- if (!file) return;
507
- const docModel = instanceService.getCurrentUnitOfType(import_core2.UniverInstanceType.UNIVER_DOC);
508
- if (!docModel) return;
509
- const parsed = await ioService.importDoc(file, docModel.getUnitId(), {
510
- target: params?.target
500
+ if (params?.file) {
501
+ const instanceService = accessor.get(import_core2.IUniverInstanceService);
502
+ const ioService = accessor.get(import_univer_docs.IDocIoService);
503
+ const docModel = instanceService.getCurrentUnitOfType(
504
+ import_core2.UniverInstanceType.UNIVER_DOC
505
+ );
506
+ if (!docModel) return false;
507
+ void ioService.importDoc(params.file, docModel.getUnitId(), {
508
+ target: params.target
509
+ }).then((parsed) => {
510
+ if (parsed.body) {
511
+ commandService.syncExecuteCommand(import_univer_docs.ReplaceDocUnitSnapshotCommand.id, {
512
+ unitId: docModel.getUnitId(),
513
+ snapshot: parsed
514
+ });
515
+ }
511
516
  });
512
- if (parsed.body) {
513
- commandService.syncExecuteCommand(import_univer_docs.ReplaceDocUnitSnapshotCommand.id, {
514
- unitId: docModel.getUnitId(),
515
- snapshot: parsed
516
- });
517
+ return true;
518
+ }
519
+ try {
520
+ if (accessor.has(IDocsUIFeatureService)) {
521
+ const featureService = accessor.get(IDocsUIFeatureService);
522
+ if (featureService.getFeatures().builtinPreviewModal !== false) {
523
+ featureService.openModal("import");
524
+ return true;
525
+ }
526
+ return false;
517
527
  }
518
- };
519
- input.click();
520
- return true;
528
+ } catch {
529
+ }
530
+ return commandService.syncExecuteCommand(OpenDocModalOperation.id, { tab: "import" });
521
531
  }
522
532
  };
523
533
  var QuickInsertDocSdtOperation = {
@@ -836,6 +846,12 @@ var DocInspectorPanel = () => {
836
846
  const [newCascadeCond, setNewCascadeCond] = (0, import_react.useState)('contractType == "\u8DE8\u5883\u91C7\u8D2D" && amount > 500000');
837
847
  const [newCascadeConcept, setNewCascadeConcept] = (0, import_react.useState)("taxClause");
838
848
  const [newNoteText, setNewNoteText] = (0, import_react.useState)("");
849
+ const [loopTableId, setLoopTableId] = (0, import_react.useState)("");
850
+ const [loopRowIndex, setLoopRowIndex] = (0, import_react.useState)(1);
851
+ const [loopListKey, setLoopListKey] = (0, import_react.useState)("");
852
+ const [loopRepeatHeader, setLoopRepeatHeader] = (0, import_react.useState)(true);
853
+ const [loopEmptyStrategy, setLoopEmptyStrategy] = (0, import_react.useState)("keep-blank");
854
+ const [loopEmptyPlaceholder, setLoopEmptyPlaceholder] = (0, import_react.useState)("\u6682\u65E0\u660E\u7EC6\u6570\u636E");
839
855
  const versionsTick = (0, import_ui2.useObservable)(sdtService.versionsChange$, "");
840
856
  (0, import_react.useEffect)(() => {
841
857
  const disp = commandService.onCommandExecuted((info) => {
@@ -845,6 +861,34 @@ var DocInspectorPanel = () => {
845
861
  });
846
862
  return () => disp.dispose();
847
863
  }, [commandService]);
864
+ (0, import_react.useEffect)(() => {
865
+ if (!unit) return;
866
+ const tbls = (0, import_univer_docs2.listDocTables)(unit.getSnapshot());
867
+ if (tbls.length === 0) return;
868
+ const selTbl = tbls.find((t) => t.tableId === loopTableId) ?? tbls[0];
869
+ const defaultRow = selTbl.rowCount > 1 ? 1 : 0;
870
+ const clampedRow = Math.min(Math.max(0, loopRowIndex), Math.max(0, selTbl.rowCount - 1));
871
+ const targetRow = loopTableId === selTbl.tableId ? clampedRow : defaultRow;
872
+ if (loopTableId !== selTbl.tableId) {
873
+ setLoopTableId(selTbl.tableId);
874
+ setLoopRowIndex(targetRow);
875
+ } else if (loopRowIndex !== targetRow) {
876
+ setLoopRowIndex(targetRow);
877
+ }
878
+ const meta = sdtService.getTemplateMetadata(unit.getUnitId());
879
+ const cfg = meta.tableRowLoops?.[`${selTbl.tableId}:${targetRow}`];
880
+ if (cfg) {
881
+ setLoopListKey(cfg.listKey || "");
882
+ setLoopRepeatHeader(cfg.repeatHeaderRow ?? true);
883
+ setLoopEmptyStrategy(cfg.emptyStrategy ?? "keep-blank");
884
+ setLoopEmptyPlaceholder(cfg.emptyPlaceholderText ?? "\u6682\u65E0\u660E\u7EC6\u6570\u636E");
885
+ } else {
886
+ setLoopListKey("");
887
+ setLoopRepeatHeader(true);
888
+ setLoopEmptyStrategy("keep-blank");
889
+ setLoopEmptyPlaceholder("\u6682\u65E0\u660E\u7EC6\u6570\u636E");
890
+ }
891
+ }, [unit, loopTableId, loopRowIndex, metaVersion, rev, sdtService]);
848
892
  if (!unit) return null;
849
893
  void rev;
850
894
  void metaVersion;
@@ -1914,6 +1958,267 @@ var DocInspectorPanel = () => {
1914
1958
  ] })
1915
1959
  ] })
1916
1960
  ] }),
1961
+ tables.length > 0 && (() => {
1962
+ const activeLoopTable = tables.find((t) => t.tableId === loopTableId) ?? tables[0];
1963
+ const activeLoopRowIdx = Math.min(
1964
+ Math.max(0, loopRowIndex),
1965
+ Math.max(0, activeLoopTable.rowCount - 1)
1966
+ );
1967
+ const existingLoop = metadata.tableRowLoops?.[`${activeLoopTable.tableId}:${activeLoopRowIdx}`];
1968
+ const suggestedListKeys = Array.from(
1969
+ /* @__PURE__ */ new Set([
1970
+ ...(metadata.datasets ?? []).map((ds) => ds.id).filter(Boolean),
1971
+ ...Object.entries(metadata.sampleData ?? {}).filter(([, val]) => Array.isArray(val)).map(([key]) => key)
1972
+ ])
1973
+ );
1974
+ const allBoundLoops = Object.values(metadata.tableRowLoops ?? {});
1975
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "yudao-doc-section", "data-testid": "yudao-table-row-loops-card", children: [
1976
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "yudao-doc-section-title", children: [
1977
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u8868\u683C\u660E\u7EC6\u884C\u5FAA\u73AF (tableRowLoops)" }),
1978
+ allBoundLoops.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1979
+ "span",
1980
+ {
1981
+ style: {
1982
+ fontSize: 10.5,
1983
+ padding: "1px 6px",
1984
+ borderRadius: 999,
1985
+ background: "#f3f5ff",
1986
+ color: "#2c53f1",
1987
+ fontWeight: 500
1988
+ },
1989
+ children: [
1990
+ "\u5DF2\u7ED1 ",
1991
+ allBoundLoops.length,
1992
+ " \u884C"
1993
+ ]
1994
+ }
1995
+ )
1996
+ ] }),
1997
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", gap: 6 }, children: [
1998
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1999
+ "select",
2000
+ {
2001
+ "data-testid": "yudao-loop-table-select",
2002
+ value: activeLoopTable.tableId,
2003
+ onChange: (e) => {
2004
+ const nextTbl = tables.find((t) => t.tableId === e.target.value) ?? tables[0];
2005
+ setLoopTableId(nextTbl.tableId);
2006
+ setLoopRowIndex(nextTbl.rowCount > 1 ? 1 : 0);
2007
+ },
2008
+ style: {
2009
+ flex: 1,
2010
+ fontSize: 11.5,
2011
+ padding: "4px 6px",
2012
+ border: "1px solid #e3e5ea",
2013
+ borderRadius: 6,
2014
+ color: "#1b1c1f",
2015
+ background: "#ffffff"
2016
+ },
2017
+ children: tables.map((t, idx) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("option", { value: t.tableId, children: [
2018
+ "\u8868\u683C #",
2019
+ idx + 1,
2020
+ " (",
2021
+ t.tableId,
2022
+ ", ",
2023
+ t.rowCount,
2024
+ "\u884C)"
2025
+ ] }, t.tableId))
2026
+ }
2027
+ ),
2028
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2029
+ "select",
2030
+ {
2031
+ "data-testid": "yudao-loop-row-select",
2032
+ value: activeLoopRowIdx,
2033
+ onChange: (e) => setLoopRowIndex(Number(e.target.value)),
2034
+ style: {
2035
+ width: 120,
2036
+ fontSize: 11.5,
2037
+ padding: "4px 6px",
2038
+ border: "1px solid #e3e5ea",
2039
+ borderRadius: 6,
2040
+ color: "#1b1c1f",
2041
+ background: "#ffffff"
2042
+ },
2043
+ children: activeLoopTable.rows.map((r) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("option", { value: r.rowIndex, children: [
2044
+ "\u7B2C ",
2045
+ r.rowIndex + 1,
2046
+ " \u884C (row ",
2047
+ r.rowIndex,
2048
+ ")",
2049
+ r.loopConfig ? ` [${r.loopConfig.listKey}]` : ""
2050
+ ] }, r.rowIndex))
2051
+ }
2052
+ )
2053
+ ] }),
2054
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-doc-field-row", children: [
2055
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u7ED1\u5B9A\u5217\u8868\u6570\u636E\u96C6\u952E (listKey)" }),
2056
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2057
+ "input",
2058
+ {
2059
+ type: "text",
2060
+ "data-testid": "yudao-loop-listkey-input",
2061
+ placeholder: "\u5982 items \u6216 order.items",
2062
+ value: loopListKey,
2063
+ onChange: (e) => setLoopListKey(e.target.value)
2064
+ }
2065
+ )
2066
+ ] }),
2067
+ suggestedListKeys.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", gap: 4, flexWrap: "wrap", alignItems: "center" }, children: [
2068
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { fontSize: 10.5, color: "#7d8698" }, children: "\u5FEB\u6377\u63A8\u8350\uFF1A" }),
2069
+ suggestedListKeys.map((candKey) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2070
+ "button",
2071
+ {
2072
+ type: "button",
2073
+ className: `yudao-doc-mini-btn ${loopListKey === candKey ? "is-soft-primary" : ""}`,
2074
+ style: { padding: "1px 6px", fontSize: 10.5 },
2075
+ onClick: () => setLoopListKey(candKey),
2076
+ children: candKey
2077
+ },
2078
+ candKey
2079
+ ))
2080
+ ] }),
2081
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2082
+ "label",
2083
+ {
2084
+ style: {
2085
+ display: "flex",
2086
+ alignItems: "center",
2087
+ gap: 6,
2088
+ fontSize: 11.5,
2089
+ color: "#31363f",
2090
+ cursor: "pointer"
2091
+ },
2092
+ children: [
2093
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2094
+ "input",
2095
+ {
2096
+ type: "checkbox",
2097
+ "data-testid": "yudao-loop-repeat-header",
2098
+ checked: loopRepeatHeader,
2099
+ onChange: (e) => setLoopRepeatHeader(e.target.checked)
2100
+ }
2101
+ ),
2102
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u91CD\u590D\u8868\u5934 (repeatHeaderRow)" })
2103
+ ]
2104
+ }
2105
+ ),
2106
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-doc-field-row", children: [
2107
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u7A7A\u6570\u636E\u7B56\u7565 (emptyStrategy)" }),
2108
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2109
+ "select",
2110
+ {
2111
+ "data-testid": "yudao-loop-empty-strategy",
2112
+ value: loopEmptyStrategy,
2113
+ onChange: (e) => setLoopEmptyStrategy(e.target.value),
2114
+ children: [
2115
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "keep-blank", children: "\u4FDD\u7559\u7A7A\u884C (keep-blank)" }),
2116
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "placeholder", children: "\u7A7A\u6570\u636E\u5360\u4F4D\u6587\u672C (placeholder)" }),
2117
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "remove", children: "\u79FB\u9664\u660E\u7EC6\u884C (remove)" })
2118
+ ]
2119
+ }
2120
+ )
2121
+ ] }),
2122
+ loopEmptyStrategy === "placeholder" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "yudao-doc-field-row", children: [
2123
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u7A7A\u6570\u636E\u5360\u4F4D\u6587\u672C (emptyPlaceholderText)" }),
2124
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2125
+ "input",
2126
+ {
2127
+ type: "text",
2128
+ "data-testid": "yudao-loop-empty-placeholder",
2129
+ placeholder: "\u5982 \u6682\u65E0\u660E\u7EC6\u6570\u636E",
2130
+ value: loopEmptyPlaceholder,
2131
+ onChange: (e) => setLoopEmptyPlaceholder(e.target.value)
2132
+ }
2133
+ )
2134
+ ] }),
2135
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", gap: 6 }, children: [
2136
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2137
+ "button",
2138
+ {
2139
+ type: "button",
2140
+ "data-testid": "yudao-loop-save-btn",
2141
+ className: "yudao-doc-mini-btn is-primary",
2142
+ style: { flex: 1 },
2143
+ disabled: !loopListKey.trim(),
2144
+ onClick: () => commandService.syncExecuteCommand(import_univer_docs2.SetDocTableRowLoopCommand.id, {
2145
+ unitId: unit.getUnitId(),
2146
+ tableId: activeLoopTable.tableId,
2147
+ rowIndex: activeLoopRowIdx,
2148
+ config: {
2149
+ listKey: loopListKey.trim(),
2150
+ repeatHeaderRow: loopRepeatHeader,
2151
+ emptyStrategy: loopEmptyStrategy,
2152
+ ...loopEmptyStrategy === "placeholder" ? { emptyPlaceholderText: loopEmptyPlaceholder || "\u6682\u65E0\u660E\u7EC6\u6570\u636E" } : {}
2153
+ }
2154
+ }),
2155
+ children: existingLoop ? "\u66F4\u65B0\u660E\u7EC6\u5FAA\u73AF\u7ED1\u5B9A" : "\u4FDD\u5B58\u660E\u7EC6\u5FAA\u73AF\u7ED1\u5B9A"
2156
+ }
2157
+ ),
2158
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2159
+ "button",
2160
+ {
2161
+ type: "button",
2162
+ "data-testid": "yudao-loop-clear-btn",
2163
+ className: "yudao-doc-mini-btn",
2164
+ disabled: !existingLoop,
2165
+ onClick: () => commandService.syncExecuteCommand(import_univer_docs2.SetDocTableRowLoopCommand.id, {
2166
+ unitId: unit.getUnitId(),
2167
+ tableId: activeLoopTable.tableId,
2168
+ rowIndex: activeLoopRowIdx,
2169
+ config: null
2170
+ }),
2171
+ children: "\u6E05\u9664\u7ED1\u5B9A"
2172
+ }
2173
+ )
2174
+ ] }),
2175
+ allBoundLoops.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: allBoundLoops.map((item) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2176
+ "div",
2177
+ {
2178
+ style: {
2179
+ display: "flex",
2180
+ justifyContent: "space-between",
2181
+ alignItems: "center",
2182
+ fontSize: 10.5,
2183
+ padding: "3px 6px",
2184
+ borderRadius: 5,
2185
+ background: "#f9fafb",
2186
+ border: "1px solid #e3e5ea",
2187
+ color: "#4e5565"
2188
+ },
2189
+ children: [
2190
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
2191
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("code", { children: item.tableId }),
2192
+ " \u7B2C ",
2193
+ item.rowIndex + 1,
2194
+ " \u884C ->",
2195
+ " ",
2196
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("code", { children: item.listKey }),
2197
+ " (",
2198
+ item.emptyStrategy || "keep-blank",
2199
+ ")"
2200
+ ] }),
2201
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2202
+ "button",
2203
+ {
2204
+ type: "button",
2205
+ className: "yudao-doc-mini-btn is-danger",
2206
+ style: { padding: "1px 5px", fontSize: 10 },
2207
+ onClick: () => commandService.syncExecuteCommand(import_univer_docs2.SetDocTableRowLoopCommand.id, {
2208
+ unitId: unit.getUnitId(),
2209
+ tableId: item.tableId,
2210
+ rowIndex: item.rowIndex,
2211
+ config: null
2212
+ }),
2213
+ children: "\u79FB\u9664"
2214
+ }
2215
+ )
2216
+ ]
2217
+ },
2218
+ `${item.tableId}:${item.rowIndex}`
2219
+ )) })
2220
+ ] });
2221
+ })(),
1917
2222
  features.paragraphAdvancedLayout && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "yudao-doc-section", children: [
1918
2223
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "yudao-doc-section-title", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u6BB5\u843D\u5206\u9875\u63A7\u5236\u4E0E\u5236\u8868\u4F4D\u524D\u5BFC\u7B26" }) }),
1919
2224
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", gap: 6, alignItems: "center" }, children: [
@@ -4697,6 +5002,13 @@ var MODAL_PEN_COLORS = [
4697
5002
  { hex: "#2C53F1", label: "\u7B7E\u5B57\u84DD" },
4698
5003
  { hex: "#DC2626", label: "\u6731\u7802\u7EA2" }
4699
5004
  ];
5005
+ function inferExtFromFileName(fileName) {
5006
+ const m = fileName.trim().toLowerCase().match(/\.([^.]+)$/);
5007
+ if (!m) return "docx";
5008
+ if (m[1] === "markdown") return "md";
5009
+ if (m[1] === "htm") return "html";
5010
+ return m[1];
5011
+ }
4700
5012
  function repaintModalSignatureCanvas(canvas, strokes) {
4701
5013
  const ctx = canvas?.getContext("2d");
4702
5014
  if (!canvas || !ctx) return;
@@ -4748,8 +5060,12 @@ var DocPreviewAndIoModal = () => {
4748
5060
  const [sigPenColor, setSigPenColor] = (0, import_react3.useState)("#1B1C1F");
4749
5061
  const [isDrawingSig, setIsDrawingSig] = (0, import_react3.useState)(false);
4750
5062
  const [ioTarget, setIoTarget] = (0, import_react3.useState)("browser");
5063
+ const [exportFormat, setExportFormat] = (0, import_react3.useState)("docx");
4751
5064
  const [skipDatasetOnExport, setSkipDatasetOnExport] = (0, import_react3.useState)(false);
4752
- const [importWarnings, setImportWarnings] = (0, import_react3.useState)([]);
5065
+ const [selectedImportFile, setSelectedImportFile] = (0, import_react3.useState)(null);
5066
+ const [pendingImport, setPendingImport] = (0, import_react3.useState)(null);
5067
+ const [ioError, setIoError] = (0, import_react3.useState)(null);
5068
+ const fileInputRef = (0, import_react3.useRef)(null);
4753
5069
  const sigCanvasRef = (0, import_react3.useRef)(null);
4754
5070
  const iframeRef = (0, import_react3.useRef)(null);
4755
5071
  (0, import_react3.useEffect)(() => {
@@ -4765,8 +5081,13 @@ var DocPreviewAndIoModal = () => {
4765
5081
  })
4766
5082
  );
4767
5083
  setJsonEditorText(JSON.stringify(snap, null, 2));
4768
- setIoTarget(ioService.getIoCapabilities().recommendedDefaultTarget);
4769
- setImportWarnings([]);
5084
+ const caps = ioService.getIoCapabilities();
5085
+ const activeOp = tab === "import" ? "import" : "export";
5086
+ const activeFmt = tab === "import" ? "docx" : exportFormat;
5087
+ const resolvedDefault = caps.defaultIoTarget === "browser" ? "browser" : caps.defaultIoTarget === "server" ? "server" : caps.formats[activeOp]?.[activeFmt]?.defaultTarget ?? caps.recommendedDefaultTarget;
5088
+ setIoTarget(resolvedDefault);
5089
+ setPendingImport(null);
5090
+ setIoError(null);
4770
5091
  setStatusTip("");
4771
5092
  }, [open, unit, features.datasetBinding, sdtService, ioService, ioAdapter]);
4772
5093
  if (!open || !unit || !features.builtinPreviewModal) return null;
@@ -4778,6 +5099,14 @@ var DocPreviewAndIoModal = () => {
4778
5099
  const isCustomBackendAdapter = Boolean(
4779
5100
  ioAdapter.exportDoc || ioAdapter.importDoc || ioAdapter.onSave
4780
5101
  );
5102
+ const activeCapabilityOp = tab === "import" ? "import" : "export";
5103
+ const activeFormatMatrix = ioCaps.formats[activeCapabilityOp];
5104
+ const browserSupportedFormats = import_univer_docs4.DOC_IO_CAPABILITY_FORMATS.filter(
5105
+ (fmt) => activeFormatMatrix[fmt]?.browser
5106
+ );
5107
+ const serverSupportedFormats = import_univer_docs4.DOC_IO_CAPABILITY_FORMATS.filter(
5108
+ (fmt) => activeFormatMatrix[fmt]?.server
5109
+ );
4781
5110
  const refreshHtmlPreview = (overrides) => {
4782
5111
  try {
4783
5112
  const parsedRaw = features.datasetBinding ? JSON.parse(datasetText) : void 0;
@@ -4811,7 +5140,29 @@ var DocPreviewAndIoModal = () => {
4811
5140
  setStatusTip(`\u586B\u5145\u5931\u8D25: ${err?.message || String(err)}`);
4812
5141
  }
4813
5142
  };
4814
- const handleDownload = async (format) => {
5143
+ const triggerBlobDownload = (bytes, mime, downloadName) => {
5144
+ if (typeof document !== "undefined" && typeof URL !== "undefined" && typeof URL.createObjectURL === "function") {
5145
+ const ab = bytes.buffer.slice(
5146
+ bytes.byteOffset,
5147
+ bytes.byteOffset + bytes.byteLength
5148
+ );
5149
+ const blob = new Blob([ab], { type: mime });
5150
+ const url = URL.createObjectURL(blob);
5151
+ const a = document.createElement("a");
5152
+ a.href = url;
5153
+ a.download = downloadName;
5154
+ a.click();
5155
+ setTimeout(() => {
5156
+ try {
5157
+ URL.revokeObjectURL(url);
5158
+ } catch {
5159
+ }
5160
+ }, 1e3);
5161
+ }
5162
+ };
5163
+ const runExport = async (format, targetOverride) => {
5164
+ const activeTarget = targetOverride ?? ioTarget;
5165
+ setIoError(null);
4815
5166
  try {
4816
5167
  const parsedRaw = features.datasetBinding && !skipDatasetOnExport ? JSON.parse(datasetText) : void 0;
4817
5168
  const parsedData = Array.isArray(parsedRaw) ? parsedRaw[0] : parsedRaw;
@@ -4828,21 +5179,21 @@ var DocPreviewAndIoModal = () => {
4828
5179
  showLineNumbers,
4829
5180
  printFieldsOnly
4830
5181
  } : void 0,
4831
- target: ioTarget
5182
+ target: activeTarget
4832
5183
  });
4833
- const mime = format === "docx" ? "application/vnd.openxmlformats-officedocument.wordprocessingml.document" : format === "pdf" ? "application/pdf" : format === "rtf" ? "application/rtf" : format === "odt" ? "application/vnd.oasis.opendocument.text" : format === "md" ? "text/markdown;charset=utf-8" : "text/html;charset=utf-8";
4834
- const blob = new Blob([bytes.buffer], { type: mime });
4835
- const url = URL.createObjectURL(blob);
4836
- const a = document.createElement("a");
4837
- a.href = url;
4838
- a.download = `${snapshot.title || "document"}.${format}`;
4839
- a.click();
4840
- setTimeout(() => URL.revokeObjectURL(url), 1e3);
4841
- const channelLabel = ioTarget === "server" ? `\u670D\u52A1\u7AEF (${ioAdapter.name})` : "\u6D4F\u89C8\u5668\u672C\u5730\u5F15\u64CE";
5184
+ const mime = format === "docx" ? "application/vnd.openxmlformats-officedocument.wordprocessingml.document" : format === "pdf" ? "application/pdf" : format === "rtf" || format === "doc" ? "application/rtf" : format === "odt" ? "application/vnd.oasis.opendocument.text" : format === "md" ? "text/markdown;charset=utf-8" : format === "txt" ? "text/plain;charset=utf-8" : format === "json" ? "application/json;charset=utf-8" : "text/html;charset=utf-8";
5185
+ triggerBlobDownload(bytes, mime, `${snapshot.title || "document"}.${format}`);
5186
+ const channelLabel = activeTarget === "server" ? `\u670D\u52A1\u7AEF\u5904\u7406 (${ioAdapter.name})` : "\u6D4F\u89C8\u5668\u5904\u7406";
4842
5187
  setStatusTip(`\u5DF2\u901A\u8FC7 ${channelLabel} \u5BFC\u51FA .${format} \u6587\u4EF6`);
4843
5188
  } catch (err) {
4844
- const hint = err?.suggestedFallback === "server" ? "\uFF08\u672A\u81EA\u52A8\u9759\u9ED8\u964D\u7EA7\uFF0C\u53EF\u5207\u6362\u4E3A\u300C\u670D\u52A1\u7AEF\u5904\u7406\u300D\u91CD\u8BD5\uFF09" : "";
4845
- setStatusTip(`\u5BFC\u51FA\u5931\u8D25: ${err?.message || String(err)}${hint}`);
5189
+ const message = err?.message || String(err);
5190
+ setIoError({
5191
+ operation: "export",
5192
+ failedTarget: activeTarget,
5193
+ message,
5194
+ exportFormat: format
5195
+ });
5196
+ setStatusTip(`\u5BFC\u51FA\u5931\u8D25: ${message}`);
4846
5197
  }
4847
5198
  };
4848
5199
  const handleBatchExportPdf = () => {
@@ -4866,49 +5217,93 @@ var DocPreviewAndIoModal = () => {
4866
5217
  showLineNumbers,
4867
5218
  printFieldsOnly
4868
5219
  });
4869
- const blob = new Blob([pdfBytes.buffer], { type: "application/pdf" });
4870
- const url = URL.createObjectURL(blob);
4871
- const a = document.createElement("a");
4872
- a.href = url;
4873
- a.download = `${snapshot.title || "document"}_batch_${records.length}.pdf`;
4874
- a.click();
4875
- setTimeout(() => URL.revokeObjectURL(url), 1e3);
5220
+ triggerBlobDownload(
5221
+ pdfBytes,
5222
+ "application/pdf",
5223
+ `${snapshot.title || "document"}_batch_${records.length}.pdf`
5224
+ );
4876
5225
  setStatusTip(`\u5DF2\u6279\u91CF\u5957\u6253\u5408\u5E76\u5BFC\u51FA ${records.length} \u4EFD\u8BB0\u5F55\u4E3A\u5355\u4EFD\u8FDE\u7EED PDF`);
4877
5226
  } catch (err) {
4878
5227
  setStatusTip(`\u6279\u91CF\u5408\u5E76\u5BFC\u51FA PDF \u5931\u8D25: ${err?.message || String(err)}`);
4879
5228
  }
4880
5229
  };
4881
- const handleImportBySelectedTarget = () => {
4882
- const input = document.createElement("input");
4883
- input.type = "file";
4884
- input.accept = ".docx,.doc,.rtf,.odt,.xml,.md,.html,.txt,.json";
4885
- input.onchange = async () => {
4886
- const file = input.files?.[0];
4887
- if (!file) return;
4888
- setImportWarnings([]);
4889
- try {
4890
- const outcome = await ioService.importDocWithReport(file, {
4891
- unitId: unit.getUnitId(),
4892
- target: ioTarget
4893
- });
4894
- if (outcome.documentData.body) {
4895
- commandService.syncExecuteCommand(import_univer_docs4.ReplaceDocUnitSnapshotCommand.id, {
4896
- unitId: unit.getUnitId(),
4897
- snapshot: outcome.documentData
4898
- });
4899
- }
4900
- setImportWarnings(outcome.warnings.map((w) => w.message));
4901
- setJsonEditorText(JSON.stringify(unit.getSnapshot(), null, 2));
4902
- setPreviewHtml((0, import_univer_docs4.exportDocHtmlString)(unit.getSnapshot(), void 0, { printFieldsOnly }));
4903
- setStatusTip(
4904
- `\u5DF2\u901A\u8FC7 ${outcome.executedBy === "server" ? "\u670D\u52A1\u7AEF\u5904\u7406" : "\u6D4F\u89C8\u5668\u5904\u7406"} \u5BFC\u5165\u300C${file.name}\u300D\uFF08\u672A\u843D\u5E93\uFF0C\u70B9\u4FDD\u5B58\u751F\u6548\uFF09`
5230
+ const runImportFile = async (file, targetOverride) => {
5231
+ const activeTarget = targetOverride ?? ioTarget;
5232
+ setSelectedImportFile(file);
5233
+ setIoError(null);
5234
+ setPendingImport(null);
5235
+ try {
5236
+ const outcome = await ioService.importDocWithReport(file, {
5237
+ unitId: unit.getUnitId(),
5238
+ target: activeTarget
5239
+ });
5240
+ const stagedSnap = outcome.snapshot ?? outcome.documentData;
5241
+ setPendingImport({
5242
+ snapshot: stagedSnap,
5243
+ warnings: outcome.warnings,
5244
+ executedBy: outcome.executedBy,
5245
+ fileName: outcome.fileName || file.name
5246
+ });
5247
+ if (stagedSnap.body) {
5248
+ setPreviewHtml(
5249
+ (0, import_univer_docs4.exportDocHtmlString)(stagedSnap, void 0, { printFieldsOnly })
4905
5250
  );
4906
- } catch (err) {
4907
- const hint = err?.suggestedFallback === "server" ? "\uFF08\u672A\u9759\u9ED8\u964D\u7EA7\uFF0C\u5EFA\u8BAE\u6539\u9009\u300C\u670D\u52A1\u7AEF\u5904\u7406\u300D\u91CD\u8BD5\uFF09" : "";
4908
- setStatusTip(`\u5BFC\u5165\u5931\u8D25: ${err?.message || String(err)}${hint}`);
4909
5251
  }
4910
- };
4911
- input.click();
5252
+ setStatusTip(
5253
+ `\u5DF2\u5B8C\u6210\u300C${outcome.fileName || file.name}\u300D\u9884\u89E3\u6790\uFF08\u5C1A\u672A\u8986\u76D6\u5F53\u524D\u8BBE\u8BA1\u5668\u6587\u6863\uFF0C\u8BF7\u786E\u8BA4\u540E\u5E94\u7528\uFF09`
5254
+ );
5255
+ } catch (err) {
5256
+ const message = err?.message || String(err);
5257
+ setIoError({
5258
+ operation: "import",
5259
+ failedTarget: activeTarget,
5260
+ message
5261
+ });
5262
+ setStatusTip(`\u5BFC\u5165\u5931\u8D25: ${message}`);
5263
+ }
5264
+ };
5265
+ const handleFileInputChange = (e) => {
5266
+ const file = e.target.files?.[0];
5267
+ if (!file) return;
5268
+ if (ioCaps.defaultIoTarget === "auto") {
5269
+ const ext = inferExtFromFileName(file.name);
5270
+ const fmtDef = ioCaps.formats.import[ext]?.defaultTarget;
5271
+ if (fmtDef && fmtDef !== ioTarget) {
5272
+ setIoTarget(fmtDef);
5273
+ void runImportFile(file, fmtDef);
5274
+ return;
5275
+ }
5276
+ }
5277
+ void runImportFile(file, ioTarget);
5278
+ };
5279
+ const handleConfirmStagedImport = () => {
5280
+ if (!pendingImport) return;
5281
+ if (pendingImport.snapshot.body) {
5282
+ commandService.syncExecuteCommand(import_univer_docs4.ReplaceDocUnitSnapshotCommand.id, {
5283
+ unitId: unit.getUnitId(),
5284
+ snapshot: pendingImport.snapshot
5285
+ });
5286
+ }
5287
+ setPendingImport(null);
5288
+ setJsonEditorText(JSON.stringify(unit.getSnapshot(), null, 2));
5289
+ setPreviewHtml((0, import_univer_docs4.exportDocHtmlString)(unit.getSnapshot(), void 0, { printFieldsOnly }));
5290
+ setStatusTip("\u5DF2\u5E94\u7528\u5230\u5F53\u524D\u8BBE\u8BA1\u5668\uFF0C\u8BF7\u7531\u5BBF\u4E3B\u4FDD\u5B58");
5291
+ };
5292
+ const handleCancelStagedImport = () => {
5293
+ setPendingImport(null);
5294
+ setPreviewHtml((0, import_univer_docs4.exportDocHtmlString)(unit.getSnapshot(), void 0, { printFieldsOnly }));
5295
+ setStatusTip("\u5DF2\u53D6\u6D88\u672C\u6B21\u5BFC\u5165\uFF0C\u5F53\u524D\u8BBE\u8BA1\u5668\u6587\u6863\u672A\u505A\u4FEE\u6539");
5296
+ };
5297
+ const handleSwitchTargetAndRetry = () => {
5298
+ if (!ioError) return;
5299
+ const nextTarget = ioError.failedTarget === "browser" ? "server" : "browser";
5300
+ setIoTarget(nextTarget);
5301
+ setIoError(null);
5302
+ if (ioError.operation === "import" && selectedImportFile) {
5303
+ void runImportFile(selectedImportFile, nextTarget);
5304
+ } else if (ioError.operation === "export") {
5305
+ void runExport(ioError.exportFormat ?? exportFormat, nextTarget);
5306
+ }
4912
5307
  };
4913
5308
  const handleSaveToHost = async () => {
4914
5309
  try {
@@ -4923,643 +5318,844 @@ var DocPreviewAndIoModal = () => {
4923
5318
  setStatusTip(`\u4FDD\u5B58\u5931\u8D25: ${err?.message || String(err)}`);
4924
5319
  }
4925
5320
  };
4926
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "yudao-doc-modal-backdrop", onClick: () => featureService.closeModal(), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "yudao-doc-modal-card", onClick: (e) => e.stopPropagation(), children: [
4927
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "yudao-doc-modal-header", children: [
4928
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "yudao-doc-modal-tabs", children: [
5321
+ const stagedStats = pendingImport?.snapshot?.body ? (0, import_univer_docs4.getDocumentStats)(pendingImport.snapshot) : null;
5322
+ const renderIoControlCard = () => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
5323
+ "div",
5324
+ {
5325
+ style: {
5326
+ padding: "8px 10px",
5327
+ background: "#ffffff",
5328
+ border: "1px solid #e3e5ea",
5329
+ borderRadius: 8,
5330
+ display: "flex",
5331
+ flexDirection: "column",
5332
+ gap: 6
5333
+ },
5334
+ children: [
5335
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", fontSize: 11.5 }, children: [
5336
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { fontWeight: 600, color: "#1b1c1f" }, children: [
5337
+ "\u5BFC\u5165/\u5BFC\u51FA\u5904\u7406\u901A\u9053\uFF08\u9ED8\u8BA4: ",
5338
+ ioCaps.defaultIoTarget,
5339
+ "\uFF09"
5340
+ ] }),
5341
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { fontSize: 10.5, color: "#7d8698" }, children: [
5342
+ "\u5FEB\u7167 ",
5343
+ snapSizeKb,
5344
+ " KB"
5345
+ ] })
5346
+ ] }),
5347
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 6 }, children: [
5348
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
5349
+ "button",
5350
+ {
5351
+ type: "button",
5352
+ "data-testid": "yudao-io-target-browser",
5353
+ className: `yudao-doc-segmented-btn ${ioTarget === "browser" ? "is-active" : ""}`,
5354
+ style: {
5355
+ display: "flex",
5356
+ flexDirection: "column",
5357
+ alignItems: "flex-start",
5358
+ gap: 3,
5359
+ padding: "6px 8px",
5360
+ border: `1px solid ${ioTarget === "browser" ? "#2c53f1" : "#e3e5ea"}`,
5361
+ borderRadius: 6,
5362
+ background: ioTarget === "browser" ? "#f3f5ff" : "#f9fafb",
5363
+ textAlign: "left"
5364
+ },
5365
+ onClick: () => setIoTarget("browser"),
5366
+ children: [
5367
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontWeight: 600, fontSize: 11.5, color: "#1b1c1f" }, children: "\u6D4F\u89C8\u5668\u5904\u7406" }),
5368
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontSize: 9.5, color: "#4e5565", lineHeight: 1.3 }, children: browserSupportedFormats.length > 0 ? browserSupportedFormats.join(" / ") : "\u672A\u542F\u7528\u672C\u5730\u683C\u5F0F" })
5369
+ ]
5370
+ }
5371
+ ),
5372
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
5373
+ "button",
5374
+ {
5375
+ type: "button",
5376
+ "data-testid": "yudao-io-target-server",
5377
+ className: `yudao-doc-segmented-btn ${ioTarget === "server" ? "is-active" : ""}`,
5378
+ style: {
5379
+ display: "flex",
5380
+ flexDirection: "column",
5381
+ alignItems: "flex-start",
5382
+ gap: 3,
5383
+ padding: "6px 8px",
5384
+ border: `1px solid ${ioTarget === "server" ? "#2c53f1" : "#e3e5ea"}`,
5385
+ borderRadius: 6,
5386
+ background: ioTarget === "server" ? "#f3f5ff" : "#f9fafb",
5387
+ textAlign: "left"
5388
+ },
5389
+ onClick: () => setIoTarget("server"),
5390
+ children: [
5391
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontWeight: 600, fontSize: 11.5, color: "#1b1c1f" }, children: "\u670D\u52A1\u7AEF\u5904\u7406" }),
5392
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontSize: 9.5, color: "#4e5565", lineHeight: 1.3 }, children: serverSupportedFormats.length > 0 ? serverSupportedFormats.join(" / ") : "\u672A\u63A5\u5165" })
5393
+ ]
5394
+ }
5395
+ )
5396
+ ] }),
4929
5397
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
4930
- "button",
4931
- {
4932
- type: "button",
4933
- className: `yudao-doc-modal-tab ${tab === "preview" ? "is-active" : ""}`,
4934
- onClick: () => featureService.setModalTab("preview"),
4935
- children: "\u5957\u6253\u9884\u89C8\u4E0E\u5BFC\u51FA"
4936
- }
4937
- ),
4938
- features.sdtControls && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
4939
- "button",
5398
+ "input",
4940
5399
  {
4941
- type: "button",
4942
- className: `yudao-doc-modal-tab ${tab === "form" ? "is-active" : ""}`,
4943
- onClick: () => featureService.setModalTab("form"),
4944
- children: "\u7ED3\u6784\u5316\u8868\u5355\u6821\u9A8C\u4E0E\u53D6\u503C"
5400
+ ref: fileInputRef,
5401
+ type: "file",
5402
+ "data-testid": "yudao-io-file-input",
5403
+ accept: DOC_IMPORT_ACCEPT_EXTENSIONS,
5404
+ style: { display: "none" },
5405
+ onChange: handleFileInputChange
4945
5406
  }
4946
5407
  ),
4947
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
4948
- "button",
4949
- {
4950
- type: "button",
4951
- className: `yudao-doc-modal-tab ${tab === "json" ? "is-active" : ""}`,
4952
- onClick: () => featureService.setModalTab("json"),
4953
- children: `{ } Univer IDocumentData \u5951\u7EA6`
4954
- }
4955
- )
4956
- ] }),
4957
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: 10 }, children: [
4958
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
4959
- "span",
4960
- {
4961
- style: {
5408
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", gap: 6, alignItems: "center" }, children: [
5409
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5410
+ "button",
5411
+ {
5412
+ type: "button",
5413
+ "data-testid": "yudao-io-pick-file",
5414
+ className: "yudao-doc-mini-btn",
5415
+ style: { flex: 1 },
5416
+ onClick: () => {
5417
+ if (fileInputRef.current) {
5418
+ fileInputRef.current.value = "";
5419
+ fileInputRef.current.click();
5420
+ }
5421
+ },
5422
+ children: "\u9009\u62E9\u6587\u4EF6\u9884\u5BFC\u5165"
5423
+ }
5424
+ ),
5425
+ selectedImportFile && !pendingImport && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5426
+ "span",
5427
+ {
5428
+ style: {
5429
+ fontSize: 10.5,
5430
+ color: "#4e5565",
5431
+ maxWidth: 130,
5432
+ overflow: "hidden",
5433
+ textOverflow: "ellipsis",
5434
+ whiteSpace: "nowrap"
5435
+ },
5436
+ title: selectedImportFile.name,
5437
+ children: selectedImportFile.name
5438
+ }
5439
+ )
5440
+ ] }),
5441
+ pendingImport && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
5442
+ "div",
5443
+ {
5444
+ "data-testid": "yudao-io-staged-result",
5445
+ style: {
5446
+ padding: "8px",
5447
+ borderRadius: 6,
5448
+ background: "#f3f5ff",
5449
+ border: "1px solid #d2dafa",
5450
+ display: "flex",
5451
+ flexDirection: "column",
5452
+ gap: 6,
4962
5453
  fontSize: 11,
4963
- padding: "3px 8px",
4964
- borderRadius: 999,
4965
- background: isCustomBackendAdapter ? "#f3f5ff" : "#eeeff1",
4966
- color: isCustomBackendAdapter ? "#2c53f1" : "#4e5565",
4967
- border: `1px solid ${isCustomBackendAdapter ? "#d2dafa" : "#e3e5ea"}`,
4968
- fontWeight: 500
5454
+ color: "#1b1c1f"
4969
5455
  },
4970
5456
  children: [
4971
- "IO \u7BA1\u9053: ",
4972
- ioAdapter.name || "frontend-default"
4973
- ]
4974
- }
4975
- ),
4976
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
4977
- "button",
4978
- {
4979
- type: "button",
4980
- className: "yudao-doc-mini-btn",
4981
- onClick: () => featureService.closeModal(),
4982
- children: "\u5173\u95ED"
4983
- }
4984
- )
4985
- ] })
4986
- ] }),
4987
- tab === "preview" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { flex: 1, minHeight: 0, display: "flex" }, children: [
4988
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
4989
- "div",
4990
- {
4991
- style: {
4992
- width: features.datasetBinding ? 340 : 230,
4993
- borderRight: "1px solid #e3e5ea",
4994
- padding: 14,
4995
- display: "flex",
4996
- flexDirection: "column",
4997
- gap: 8,
4998
- background: "#f9fafb"
4999
- },
5000
- children: [
5001
- features.datasetBinding ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
5002
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { fontSize: 12, fontWeight: 600, color: "#1b1c1f" }, children: "\u4E1A\u52A1\u6570\u636E\u96C6 JSON\uFF08\u652F\u6301\u5355\u6761\u5BF9\u8C61\u6216\u6279\u91CF\u6570\u7EC4 [...]\uFF09" }),
5457
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", gap: 6 }, children: [
5458
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { style: { wordBreak: "break-all" }, children: pendingImport.fileName }),
5459
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5460
+ "span",
5461
+ {
5462
+ style: {
5463
+ fontSize: 10,
5464
+ padding: "1px 6px",
5465
+ borderRadius: 999,
5466
+ background: "#ffffff",
5467
+ border: "1px solid #d2dafa",
5468
+ color: "#2c53f1",
5469
+ flexShrink: 0
5470
+ },
5471
+ children: pendingImport.executedBy === "server" ? "\u670D\u52A1\u7AEF\u5904\u7406" : "\u6D4F\u89C8\u5668\u5904\u7406"
5472
+ }
5473
+ )
5474
+ ] }),
5475
+ stagedStats && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { fontSize: 10.5, color: "#4e5565" }, children: [
5476
+ "\u6BB5\u843D ",
5477
+ stagedStats.paragraphCount,
5478
+ " \xB7 \u8868\u683C ",
5479
+ stagedStats.tableCount,
5480
+ " \xB7 \u63A7\u4EF6",
5481
+ " ",
5482
+ stagedStats.sdtTotalCount
5483
+ ] }),
5003
5484
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5004
- "textarea",
5485
+ "ul",
5005
5486
  {
5006
- className: "yudao-doc-code-area",
5007
- value: datasetText,
5008
- onChange: (e) => setDatasetText(e.target.value)
5487
+ "data-testid": "yudao-io-warnings",
5488
+ style: {
5489
+ margin: 0,
5490
+ paddingLeft: pendingImport.warnings.length > 0 ? 16 : 0,
5491
+ listStyle: pendingImport.warnings.length > 0 ? "disc" : "none",
5492
+ fontSize: 10.5,
5493
+ color: "#4e5565"
5494
+ },
5495
+ children: pendingImport.warnings.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("li", { children: "\u65E0\u683C\u5F0F\u964D\u7EA7\u544A\u8B66" }) : pendingImport.warnings.map((w, idx) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("li", { children: w.message }, `${w.code}-${idx}`))
5009
5496
  }
5010
5497
  ),
5011
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", gap: 6, flexWrap: "wrap" }, children: [
5012
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "yudao-doc-mini-btn", onClick: () => refreshHtmlPreview(), children: "\u5237\u65B0\u53F3\u4FA7\u9884\u89C8" }),
5498
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", gap: 6 }, children: [
5013
5499
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5014
5500
  "button",
5015
5501
  {
5016
5502
  type: "button",
5503
+ "data-testid": "yudao-io-confirm-import",
5504
+ className: "yudao-doc-mini-btn is-primary",
5505
+ style: { flex: 1 },
5506
+ onClick: handleConfirmStagedImport,
5507
+ children: "\u786E\u8BA4\u5E94\u7528\u5230\u8BBE\u8BA1\u5668"
5508
+ }
5509
+ ),
5510
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5511
+ "button",
5512
+ {
5513
+ type: "button",
5514
+ "data-testid": "yudao-io-cancel-import",
5017
5515
  className: "yudao-doc-mini-btn",
5018
- onClick: handleApplyDatasetToEditor,
5019
- children: "\u586B\u5145\u81F3\u4E3B\u6587\u6863"
5516
+ onClick: handleCancelStagedImport,
5517
+ children: "\u53D6\u6D88\u672C\u6B21\u5BFC\u5165"
5020
5518
  }
5021
5519
  )
5022
5520
  ] })
5023
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { fontSize: 12, color: "#4e5565", lineHeight: 1.6 }, children: [
5024
- "\u5F53\u524D\u5904\u4E8E\u7EAF\u51C0 Word \u7F16\u8F91\u6A21\u5F0F\u3002\u53EF\u4E00\u952E\u5BFC\u51FA\u517C\u5BB9 Microsoft Word / WPS \u7684\u6807\u51C6 ",
5025
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: ".docx" }),
5026
- " ",
5027
- "\u6216\u72EC\u7ACB ",
5028
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: ".html" }),
5029
- " \u6587\u4EF6\u3002"
5030
- ] }),
5031
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 6, paddingTop: 4, borderTop: "1px solid #e3e5ea" }, children: [
5032
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5033
- "input",
5034
- {
5035
- type: "text",
5036
- placeholder: "\u516C\u6587\u7EA2\u5934\u7248\u5934\uFF08\u5982\uFF1A\u828B\u9053\u96C6\u56E2\u6587\u4EF6\uFF09",
5037
- value: redHeaderTitle,
5038
- onChange: (e) => {
5039
- setRedHeaderTitle(e.target.value);
5040
- refreshHtmlPreview({ red: e.target.value });
5041
- },
5042
- style: {
5043
- border: "1px solid #e3e5ea",
5044
- borderRadius: 6,
5045
- padding: "5px 8px",
5046
- fontSize: 11.5,
5047
- color: "#1b1c1f",
5048
- background: "#ffffff"
5049
- }
5050
- }
5051
- ),
5052
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5053
- "input",
5054
- {
5055
- type: "text",
5056
- placeholder: "\u9632\u4F2A\u659C\u5411\u5E73\u94FA\u6C34\u5370\uFF08\u5982\uFF1A\u5185\u90E8\u673A\u5BC6\uFF09",
5057
- value: watermarkText,
5058
- onChange: (e) => {
5059
- setWatermarkText(e.target.value);
5060
- refreshHtmlPreview({ wm: e.target.value });
5061
- },
5062
- style: {
5063
- border: "1px solid #e3e5ea",
5064
- borderRadius: 6,
5065
- padding: "5px 8px",
5066
- fontSize: 11.5,
5067
- color: "#1b1c1f",
5068
- background: "#ffffff"
5069
- }
5070
- }
5071
- ),
5521
+ ]
5522
+ }
5523
+ ),
5524
+ ioError && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
5525
+ "div",
5526
+ {
5527
+ "data-testid": "yudao-io-error-banner",
5528
+ style: {
5529
+ padding: "7px 8px",
5530
+ borderRadius: 6,
5531
+ background: "#fef2f2",
5532
+ border: "1px solid #fecaca",
5533
+ color: "#b91c1c",
5534
+ fontSize: 11,
5535
+ display: "flex",
5536
+ flexDirection: "column",
5537
+ gap: 6
5538
+ },
5539
+ children: [
5540
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { lineHeight: 1.4 }, children: ioError.message }),
5072
5541
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5073
- "input",
5542
+ "button",
5074
5543
  {
5075
- type: "text",
5076
- placeholder: "\u8DE8\u9875\u9A91\u7F1D\u7AE0\u4E3B\u4F53\uFF08\u5982\uFF1A\u828B\u9053\u79D1\u6280\u5408\u540C\u7AE0\uFF09",
5077
- value: straddleSealText,
5078
- onChange: (e) => {
5079
- setStraddleSealText(e.target.value);
5080
- refreshHtmlPreview({ seal: e.target.value });
5081
- },
5082
- style: {
5083
- border: "1px solid #e3e5ea",
5084
- borderRadius: 6,
5085
- padding: "5px 8px",
5086
- fontSize: 11.5,
5087
- color: "#1b1c1f",
5088
- background: "#ffffff"
5089
- }
5544
+ type: "button",
5545
+ "data-testid": "yudao-io-switch-retry",
5546
+ className: "yudao-doc-mini-btn",
5547
+ onClick: handleSwitchTargetAndRetry,
5548
+ children: `\u5207\u6362\u4E3A\u300C${ioError.failedTarget === "browser" ? "\u670D\u52A1\u7AEF\u5904\u7406" : "\u6D4F\u89C8\u5668\u5904\u7406"}\u300D\u91CD\u8BD5`
5090
5549
  }
5091
- ),
5092
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 6, fontSize: 11.5, color: "#31363f", cursor: "pointer" }, children: [
5093
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5094
- "input",
5095
- {
5096
- type: "checkbox",
5097
- checked: showLineNumbers,
5098
- onChange: (e) => {
5099
- setShowLineNumbers(e.target.checked);
5100
- refreshHtmlPreview({ lineNo: e.target.checked });
5550
+ )
5551
+ ]
5552
+ }
5553
+ ),
5554
+ features.datasetBinding && ioTarget === "browser" && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 5, fontSize: 11, color: "#31363f", cursor: "pointer" }, children: [
5555
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5556
+ "input",
5557
+ {
5558
+ type: "checkbox",
5559
+ checked: skipDatasetOnExport,
5560
+ onChange: (e) => setSkipDatasetOnExport(e.target.checked)
5561
+ }
5562
+ ),
5563
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "\u4EC5\u7F16\u7801\u5F53\u524D\u5FEB\u7167\uFF08\u4E0D\u91CD\u590D\u6267\u884C\u6570\u636E\u96C6\u586B\u6570\uFF09" })
5564
+ ] })
5565
+ ]
5566
+ }
5567
+ );
5568
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "yudao-doc-modal-backdrop", onClick: () => featureService.closeModal(), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
5569
+ "div",
5570
+ {
5571
+ className: "yudao-doc-modal-card",
5572
+ "data-testid": "yudao-io-modal",
5573
+ onClick: (e) => e.stopPropagation(),
5574
+ children: [
5575
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "yudao-doc-modal-header", children: [
5576
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "yudao-doc-modal-tabs", children: [
5577
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5578
+ "button",
5579
+ {
5580
+ type: "button",
5581
+ className: `yudao-doc-modal-tab ${tab === "import" ? "is-active" : ""}`,
5582
+ onClick: () => featureService.setModalTab("import"),
5583
+ children: "\u6587\u6863\u5BFC\u5165"
5584
+ }
5585
+ ),
5586
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5587
+ "button",
5588
+ {
5589
+ type: "button",
5590
+ className: `yudao-doc-modal-tab ${tab === "preview" ? "is-active" : ""}`,
5591
+ onClick: () => featureService.setModalTab("preview"),
5592
+ children: "\u5957\u6253\u9884\u89C8\u4E0E\u5BFC\u51FA"
5593
+ }
5594
+ ),
5595
+ features.sdtControls && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5596
+ "button",
5597
+ {
5598
+ type: "button",
5599
+ className: `yudao-doc-modal-tab ${tab === "form" ? "is-active" : ""}`,
5600
+ onClick: () => featureService.setModalTab("form"),
5601
+ children: "\u7ED3\u6784\u5316\u8868\u5355\u6821\u9A8C\u4E0E\u53D6\u503C"
5602
+ }
5603
+ ),
5604
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5605
+ "button",
5606
+ {
5607
+ type: "button",
5608
+ className: `yudao-doc-modal-tab ${tab === "json" ? "is-active" : ""}`,
5609
+ onClick: () => featureService.setModalTab("json"),
5610
+ children: `{ } Univer IDocumentData \u5951\u7EA6`
5611
+ }
5612
+ )
5613
+ ] }),
5614
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: 10 }, children: [
5615
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
5616
+ "span",
5617
+ {
5618
+ style: {
5619
+ fontSize: 11,
5620
+ padding: "3px 8px",
5621
+ borderRadius: 999,
5622
+ background: isCustomBackendAdapter ? "#f3f5ff" : "#eeeff1",
5623
+ color: isCustomBackendAdapter ? "#2c53f1" : "#4e5565",
5624
+ border: `1px solid ${isCustomBackendAdapter ? "#d2dafa" : "#e3e5ea"}`,
5625
+ fontWeight: 500
5626
+ },
5627
+ children: [
5628
+ "IO \u7BA1\u9053: ",
5629
+ ioAdapter.name || "frontend-default"
5630
+ ]
5631
+ }
5632
+ ),
5633
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5634
+ "button",
5635
+ {
5636
+ type: "button",
5637
+ className: "yudao-doc-mini-btn",
5638
+ onClick: () => featureService.closeModal(),
5639
+ children: "\u5173\u95ED"
5640
+ }
5641
+ )
5642
+ ] })
5643
+ ] }),
5644
+ tab === "import" || tab === "preview" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { flex: 1, minHeight: 0, display: "flex" }, children: [
5645
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
5646
+ "div",
5647
+ {
5648
+ style: {
5649
+ width: features.datasetBinding ? 356 : 290,
5650
+ borderRight: "1px solid #e3e5ea",
5651
+ padding: 14,
5652
+ display: "flex",
5653
+ flexDirection: "column",
5654
+ gap: 8,
5655
+ background: "#f9fafb",
5656
+ overflowY: "auto"
5657
+ },
5658
+ children: [
5659
+ tab === "import" && renderIoControlCard(),
5660
+ features.datasetBinding ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
5661
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { fontSize: 12, fontWeight: 600, color: "#1b1c1f" }, children: "\u4E1A\u52A1\u6570\u636E\u96C6 JSON\uFF08\u652F\u6301\u5355\u6761\u5BF9\u8C61\u6216\u6279\u91CF\u6570\u7EC4 [...]\uFF09" }),
5662
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5663
+ "textarea",
5664
+ {
5665
+ className: "yudao-doc-code-area",
5666
+ value: datasetText,
5667
+ onChange: (e) => setDatasetText(e.target.value)
5668
+ }
5669
+ ),
5670
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", gap: 6, flexWrap: "wrap" }, children: [
5671
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "yudao-doc-mini-btn", onClick: () => refreshHtmlPreview(), children: "\u5237\u65B0\u53F3\u4FA7\u9884\u89C8" }),
5672
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5673
+ "button",
5674
+ {
5675
+ type: "button",
5676
+ className: "yudao-doc-mini-btn",
5677
+ onClick: handleApplyDatasetToEditor,
5678
+ children: "\u586B\u5145\u81F3\u4E3B\u6587\u6863"
5679
+ }
5680
+ )
5681
+ ] })
5682
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { fontSize: 12, color: "#4e5565", lineHeight: 1.6 }, children: [
5683
+ "\u652F\u6301\u6309\u6B21\u9009\u62E9\u6D4F\u89C8\u5668\u672C\u5730\u5F15\u64CE\u6216\u670D\u52A1\u7AEF\u63A5\u53E3\u5BFC\u5165/\u5BFC\u51FA\u6807\u51C6 ",
5684
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: ".docx" }),
5685
+ "\u3001",
5686
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: ".pdf" }),
5687
+ "\u3001",
5688
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: ".html" }),
5689
+ "\u3001",
5690
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: ".md" }),
5691
+ " \u7B49\u6587\u6863\u683C\u5F0F\u3002"
5692
+ ] }),
5693
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 6, paddingTop: 4, borderTop: "1px solid #e3e5ea" }, children: [
5694
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5695
+ "input",
5696
+ {
5697
+ type: "text",
5698
+ placeholder: "\u516C\u6587\u7EA2\u5934\u7248\u5934\uFF08\u5982\uFF1A\u96C6\u56E2\u7EA2\u5934\u6587\u4EF6\uFF09",
5699
+ value: redHeaderTitle,
5700
+ onChange: (e) => {
5701
+ setRedHeaderTitle(e.target.value);
5702
+ refreshHtmlPreview({ red: e.target.value });
5703
+ },
5704
+ style: {
5705
+ border: "1px solid #e3e5ea",
5706
+ borderRadius: 6,
5707
+ padding: "5px 8px",
5708
+ fontSize: 11.5,
5709
+ color: "#1b1c1f",
5710
+ background: "#ffffff"
5711
+ }
5712
+ }
5713
+ ),
5714
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5715
+ "input",
5716
+ {
5717
+ type: "text",
5718
+ placeholder: "\u9632\u4F2A\u659C\u5411\u5E73\u94FA\u6C34\u5370\uFF08\u5982\uFF1A\u5185\u90E8\u673A\u5BC6\uFF09",
5719
+ value: watermarkText,
5720
+ onChange: (e) => {
5721
+ setWatermarkText(e.target.value);
5722
+ refreshHtmlPreview({ wm: e.target.value });
5723
+ },
5724
+ style: {
5725
+ border: "1px solid #e3e5ea",
5726
+ borderRadius: 6,
5727
+ padding: "5px 8px",
5728
+ fontSize: 11.5,
5729
+ color: "#1b1c1f",
5730
+ background: "#ffffff"
5731
+ }
5732
+ }
5733
+ ),
5734
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5735
+ "input",
5736
+ {
5737
+ type: "text",
5738
+ placeholder: "\u8DE8\u9875\u9A91\u7F1D\u7AE0\u4E3B\u4F53\uFF08\u5982\uFF1A\u516C\u53F8\u5408\u540C\u4E13\u7528\u7AE0\uFF09",
5739
+ value: straddleSealText,
5740
+ onChange: (e) => {
5741
+ setStraddleSealText(e.target.value);
5742
+ refreshHtmlPreview({ seal: e.target.value });
5743
+ },
5744
+ style: {
5745
+ border: "1px solid #e3e5ea",
5746
+ borderRadius: 6,
5747
+ padding: "5px 8px",
5748
+ fontSize: 11.5,
5749
+ color: "#1b1c1f",
5750
+ background: "#ffffff"
5751
+ }
5752
+ }
5753
+ ),
5754
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 6, fontSize: 11.5, color: "#31363f", cursor: "pointer" }, children: [
5755
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5756
+ "input",
5757
+ {
5758
+ type: "checkbox",
5759
+ checked: showLineNumbers,
5760
+ onChange: (e) => {
5761
+ setShowLineNumbers(e.target.checked);
5762
+ refreshHtmlPreview({ lineNo: e.target.checked });
5763
+ }
5764
+ }
5765
+ ),
5766
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "\u663E\u793A\u6CD5\u52A1\u5DE6\u4FA7\u884C\u53F7 (Line Numbers)" })
5767
+ ] }),
5768
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 6, fontSize: 11.5, color: "#31363f", cursor: "pointer" }, children: [
5769
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5770
+ "input",
5771
+ {
5772
+ type: "checkbox",
5773
+ checked: printFieldsOnly,
5774
+ onChange: (e) => {
5775
+ setPrintFieldsOnly(e.target.checked);
5776
+ refreshHtmlPreview({ fieldsOnly: e.target.checked });
5777
+ }
5778
+ }
5779
+ ),
5780
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "\u4EC5\u5957\u6253\u586B\u7A7A\u503C (\u9690\u85CF\u56FA\u5B9A\u6B63\u6587)" })
5781
+ ] }),
5782
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
5783
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", fontSize: 11 }, children: [
5784
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontWeight: 600, color: "#31363f" }, children: "\u843D\u6B3E\u624B\u5199\u7B7E\u540D\u677F" }),
5785
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", gap: 4 }, children: [
5786
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5787
+ "button",
5788
+ {
5789
+ type: "button",
5790
+ className: "yudao-doc-mini-btn",
5791
+ style: { padding: "1px 6px", fontSize: 10.5 },
5792
+ disabled: sigStrokes.length === 0,
5793
+ onClick: () => {
5794
+ const next = sigStrokes.slice(0, -1);
5795
+ setSigStrokes(next);
5796
+ repaintModalSignatureCanvas(sigCanvasRef.current, next);
5797
+ const nextUrl = next.length === 0 ? "" : (sigCanvasRef.current ? (0, import_univer_docs4.autoCropCanvasToPngDataUrl)(sigCanvasRef.current) : "") || (0, import_univer_docs4.renderSignatureStrokesToSvgDataUri)(next)?.dataUri || "";
5798
+ setSignatureDataUrl(nextUrl);
5799
+ refreshHtmlPreview({ sig: nextUrl });
5800
+ },
5801
+ children: "\u64A4\u9500"
5802
+ }
5803
+ ),
5804
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5805
+ "button",
5806
+ {
5807
+ type: "button",
5808
+ className: "yudao-doc-mini-btn",
5809
+ style: { padding: "1px 6px", fontSize: 10.5 },
5810
+ onClick: () => {
5811
+ setSigStrokes([]);
5812
+ repaintModalSignatureCanvas(sigCanvasRef.current, []);
5813
+ setSignatureDataUrl("");
5814
+ refreshHtmlPreview({ sig: "" });
5815
+ },
5816
+ children: "\u6E05\u7A7A\u7B7E\u540D"
5817
+ }
5818
+ )
5819
+ ] })
5820
+ ] }),
5821
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { display: "flex", gap: 4 }, children: MODAL_PEN_COLORS.map((pen) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
5822
+ "button",
5823
+ {
5824
+ type: "button",
5825
+ className: `yudao-doc-mini-btn ${sigPenColor === pen.hex ? "is-soft-primary" : ""}`,
5826
+ style: { padding: "1px 6px", fontSize: 10.5 },
5827
+ onClick: () => setSigPenColor(pen.hex),
5828
+ children: [
5829
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5830
+ "span",
5831
+ {
5832
+ style: {
5833
+ display: "inline-block",
5834
+ width: 7,
5835
+ height: 7,
5836
+ borderRadius: 999,
5837
+ background: pen.hex,
5838
+ marginRight: 4
5839
+ }
5840
+ }
5841
+ ),
5842
+ pen.label
5843
+ ]
5844
+ },
5845
+ pen.hex
5846
+ )) }),
5847
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5848
+ "canvas",
5849
+ {
5850
+ ref: sigCanvasRef,
5851
+ width: 260,
5852
+ height: 64,
5853
+ style: {
5854
+ border: "1px dashed #e3e5ea",
5855
+ borderRadius: 6,
5856
+ background: "#ffffff",
5857
+ cursor: "crosshair",
5858
+ touchAction: "none"
5859
+ },
5860
+ onPointerDown: (e) => {
5861
+ const cvs = sigCanvasRef.current;
5862
+ if (!cvs) return;
5863
+ const rect = cvs.getBoundingClientRect();
5864
+ const pt = { x: e.clientX - rect.left, y: e.clientY - rect.top };
5865
+ const next = [
5866
+ ...sigStrokes,
5867
+ { points: [pt], color: sigPenColor, lineWidth: 2.2 }
5868
+ ];
5869
+ setSigStrokes(next);
5870
+ setIsDrawingSig(true);
5871
+ repaintModalSignatureCanvas(cvs, next);
5872
+ },
5873
+ onPointerMove: (e) => {
5874
+ if (!isDrawingSig) return;
5875
+ const cvs = sigCanvasRef.current;
5876
+ if (!cvs || sigStrokes.length === 0) return;
5877
+ const rect = cvs.getBoundingClientRect();
5878
+ const pt = { x: e.clientX - rect.left, y: e.clientY - rect.top };
5879
+ const next = [...sigStrokes];
5880
+ const last = next[next.length - 1];
5881
+ next[next.length - 1] = { ...last, points: [...last.points, pt] };
5882
+ setSigStrokes(next);
5883
+ repaintModalSignatureCanvas(cvs, next);
5884
+ },
5885
+ onPointerUp: () => {
5886
+ if (!isDrawingSig) return;
5887
+ setIsDrawingSig(false);
5888
+ const cropped = (sigCanvasRef.current ? (0, import_univer_docs4.autoCropCanvasToPngDataUrl)(sigCanvasRef.current) : "") || (0, import_univer_docs4.renderSignatureStrokesToSvgDataUri)(sigStrokes)?.dataUri || "";
5889
+ setSignatureDataUrl(cropped);
5890
+ refreshHtmlPreview({ sig: cropped });
5891
+ },
5892
+ onPointerLeave: () => {
5893
+ if (!isDrawingSig) return;
5894
+ setIsDrawingSig(false);
5895
+ const cropped = (sigCanvasRef.current ? (0, import_univer_docs4.autoCropCanvasToPngDataUrl)(sigCanvasRef.current) : "") || (0, import_univer_docs4.renderSignatureStrokesToSvgDataUri)(sigStrokes)?.dataUri || "";
5896
+ setSignatureDataUrl(cropped);
5897
+ refreshHtmlPreview({ sig: cropped });
5898
+ }
5899
+ }
5900
+ )
5901
+ ] })
5902
+ ] }),
5903
+ tab !== "import" && renderIoControlCard(),
5904
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 6, marginTop: 2 }, children: [
5905
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", gap: 6 }, children: [
5906
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
5907
+ "select",
5908
+ {
5909
+ "data-testid": "yudao-io-export-format",
5910
+ value: exportFormat,
5911
+ onChange: (e) => setExportFormat(e.target.value),
5912
+ style: {
5913
+ width: 110,
5914
+ fontSize: 11.5,
5915
+ padding: "4px 6px",
5916
+ border: "1px solid #e3e5ea",
5917
+ borderRadius: 6,
5918
+ color: "#1b1c1f",
5919
+ background: "#ffffff"
5920
+ },
5921
+ children: [
5922
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "docx", children: ".docx (Word)" }),
5923
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "pdf", children: ".pdf (PDF)" }),
5924
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "html", children: ".html (HTML)" }),
5925
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "md", children: ".md (Markdown)" }),
5926
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "rtf", children: ".rtf (RTF)" }),
5927
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "odt", children: ".odt (ODT)" }),
5928
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "doc", children: ".doc (\u517C\u5BB9)" }),
5929
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "txt", children: ".txt (\u7EAF\u6587\u672C)" }),
5930
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "json", children: ".json (\u5FEB\u7167)" })
5931
+ ]
5932
+ }
5933
+ ),
5934
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5935
+ "button",
5936
+ {
5937
+ type: "button",
5938
+ "data-testid": "yudao-io-export-download",
5939
+ className: "yudao-doc-mini-btn is-primary yudao-doc-export-btn",
5940
+ style: { flex: 1 },
5941
+ onClick: () => void runExport(exportFormat),
5942
+ children: `\u5BFC\u51FA\u4E0B\u8F7D (.${exportFormat})`
5943
+ }
5944
+ )
5945
+ ] }),
5946
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5947
+ "button",
5948
+ {
5949
+ type: "button",
5950
+ className: "yudao-doc-mini-btn yudao-doc-export-btn",
5951
+ onClick: () => void runExport("pdf"),
5952
+ children: "\u5BFC\u51FA\u6B63\u5F0F\u9A91\u7F1D\u7AE0 PDF"
5101
5953
  }
5102
- }
5103
- ),
5104
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "\u663E\u793A\u6CD5\u52A1\u5DE6\u4FA7\u884C\u53F7 (Line Numbers)" })
5105
- ] }),
5106
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 6, fontSize: 11.5, color: "#31363f", cursor: "pointer" }, children: [
5107
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5108
- "input",
5109
- {
5110
- type: "checkbox",
5111
- checked: printFieldsOnly,
5112
- onChange: (e) => {
5113
- setPrintFieldsOnly(e.target.checked);
5114
- refreshHtmlPreview({ fieldsOnly: e.target.checked });
5954
+ ),
5955
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5956
+ "button",
5957
+ {
5958
+ type: "button",
5959
+ className: "yudao-doc-mini-btn yudao-doc-export-btn",
5960
+ onClick: handleBatchExportPdf,
5961
+ children: "\u6279\u91CF\u5957\u6253\u5408\u5E76\u5BFC\u51FA PDF"
5115
5962
  }
5116
- }
5117
- ),
5118
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "\u4EC5\u5957\u6253\u586B\u7A7A\u503C (\u9690\u85CF\u56FA\u5B9A\u6B63\u6587)" })
5119
- ] }),
5120
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 4 }, children: [
5121
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", fontSize: 11 }, children: [
5122
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontWeight: 600, color: "#31363f" }, children: "\u843D\u6B3E\u624B\u5199\u7B7E\u540D\u677F" }),
5123
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", gap: 4 }, children: [
5963
+ ),
5964
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 6 }, children: [
5124
5965
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5125
5966
  "button",
5126
5967
  {
5127
5968
  type: "button",
5128
- className: "yudao-doc-mini-btn",
5129
- style: { padding: "1px 6px", fontSize: 10.5 },
5130
- disabled: sigStrokes.length === 0,
5131
- onClick: () => {
5132
- const next = sigStrokes.slice(0, -1);
5133
- setSigStrokes(next);
5134
- repaintModalSignatureCanvas(sigCanvasRef.current, next);
5135
- const nextUrl = next.length === 0 ? "" : (sigCanvasRef.current ? (0, import_univer_docs4.autoCropCanvasToPngDataUrl)(sigCanvasRef.current) : "") || (0, import_univer_docs4.renderSignatureStrokesToSvgDataUri)(next)?.dataUri || "";
5136
- setSignatureDataUrl(nextUrl);
5137
- refreshHtmlPreview({ sig: nextUrl });
5138
- },
5139
- children: "\u64A4\u9500"
5969
+ className: "yudao-doc-mini-btn yudao-doc-export-btn",
5970
+ onClick: () => void runExport("html"),
5971
+ children: "\u5BFC\u51FA (.html)"
5140
5972
  }
5141
5973
  ),
5142
5974
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5143
5975
  "button",
5144
5976
  {
5145
5977
  type: "button",
5146
- className: "yudao-doc-mini-btn",
5147
- style: { padding: "1px 6px", fontSize: 10.5 },
5978
+ className: "yudao-doc-mini-btn yudao-doc-export-btn",
5979
+ onClick: () => void runExport("md"),
5980
+ children: "\u5BFC\u51FA Markdown (.md)"
5981
+ }
5982
+ ),
5983
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5984
+ "button",
5985
+ {
5986
+ type: "button",
5987
+ className: "yudao-doc-mini-btn yudao-doc-export-btn",
5988
+ style: { gridColumn: "1 / -1" },
5148
5989
  onClick: () => {
5149
- setSigStrokes([]);
5150
- repaintModalSignatureCanvas(sigCanvasRef.current, []);
5151
- setSignatureDataUrl("");
5152
- refreshHtmlPreview({ sig: "" });
5990
+ iframeRef.current?.contentWindow?.focus();
5991
+ iframeRef.current?.contentWindow?.print();
5153
5992
  },
5154
- children: "\u6E05\u7A7A\u7B7E\u540D"
5993
+ children: "A4 \u77E2\u91CF\u6253\u5370"
5155
5994
  }
5156
5995
  )
5157
- ] })
5996
+ ] }),
5997
+ ioAdapter.onSave && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5998
+ "button",
5999
+ {
6000
+ type: "button",
6001
+ className: "yudao-doc-mini-btn yudao-doc-export-btn",
6002
+ onClick: handleSaveToHost,
6003
+ children: "\u4FDD\u5B58\u6A21\u677F\u81F3\u5BBF\u4E3B\u540E\u7AEF"
6004
+ }
6005
+ )
5158
6006
  ] }),
5159
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { display: "flex", gap: 4 }, children: MODAL_PEN_COLORS.map((pen) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
5160
- "button",
5161
- {
5162
- type: "button",
5163
- className: `yudao-doc-mini-btn ${sigPenColor === pen.hex ? "is-soft-primary" : ""}`,
5164
- style: { padding: "1px 6px", fontSize: 10.5 },
5165
- onClick: () => setSigPenColor(pen.hex),
5166
- children: [
5167
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5168
- "span",
5169
- {
5170
- style: {
5171
- display: "inline-block",
5172
- width: 7,
5173
- height: 7,
5174
- borderRadius: 999,
5175
- background: pen.hex,
5176
- marginRight: 4
5177
- }
5178
- }
5179
- ),
5180
- pen.label
5181
- ]
5182
- },
5183
- pen.hex
5184
- )) }),
5185
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5186
- "canvas",
6007
+ statusTip && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
6008
+ "div",
5187
6009
  {
5188
- ref: sigCanvasRef,
5189
- width: 260,
5190
- height: 64,
6010
+ "data-testid": "yudao-io-status-tip",
5191
6011
  style: {
5192
- border: "1px dashed #e3e5ea",
5193
- borderRadius: 6,
5194
- background: "#ffffff",
5195
- cursor: "crosshair",
5196
- touchAction: "none"
5197
- },
5198
- onPointerDown: (e) => {
5199
- const cvs = sigCanvasRef.current;
5200
- if (!cvs) return;
5201
- const rect = cvs.getBoundingClientRect();
5202
- const pt = { x: e.clientX - rect.left, y: e.clientY - rect.top };
5203
- const next = [
5204
- ...sigStrokes,
5205
- { points: [pt], color: sigPenColor, lineWidth: 2.2 }
5206
- ];
5207
- setSigStrokes(next);
5208
- setIsDrawingSig(true);
5209
- repaintModalSignatureCanvas(cvs, next);
5210
- },
5211
- onPointerMove: (e) => {
5212
- if (!isDrawingSig) return;
5213
- const cvs = sigCanvasRef.current;
5214
- if (!cvs || sigStrokes.length === 0) return;
5215
- const rect = cvs.getBoundingClientRect();
5216
- const pt = { x: e.clientX - rect.left, y: e.clientY - rect.top };
5217
- const next = [...sigStrokes];
5218
- const last = next[next.length - 1];
5219
- next[next.length - 1] = { ...last, points: [...last.points, pt] };
5220
- setSigStrokes(next);
5221
- repaintModalSignatureCanvas(cvs, next);
5222
- },
5223
- onPointerUp: () => {
5224
- if (!isDrawingSig) return;
5225
- setIsDrawingSig(false);
5226
- const cropped = (sigCanvasRef.current ? (0, import_univer_docs4.autoCropCanvasToPngDataUrl)(sigCanvasRef.current) : "") || (0, import_univer_docs4.renderSignatureStrokesToSvgDataUri)(sigStrokes)?.dataUri || "";
5227
- setSignatureDataUrl(cropped);
5228
- refreshHtmlPreview({ sig: cropped });
6012
+ fontSize: 11.5,
6013
+ color: "#2c53f1",
6014
+ background: "#f3f5ff",
6015
+ border: "1px solid #d2dafa",
6016
+ padding: "6px 8px",
6017
+ borderRadius: 6
5229
6018
  },
5230
- onPointerLeave: () => {
5231
- if (!isDrawingSig) return;
5232
- setIsDrawingSig(false);
5233
- const cropped = (sigCanvasRef.current ? (0, import_univer_docs4.autoCropCanvasToPngDataUrl)(sigCanvasRef.current) : "") || (0, import_univer_docs4.renderSignatureStrokesToSvgDataUri)(sigStrokes)?.dataUri || "";
5234
- setSignatureDataUrl(cropped);
5235
- refreshHtmlPreview({ sig: cropped });
5236
- }
6019
+ children: statusTip
5237
6020
  }
5238
6021
  )
5239
- ] })
5240
- ] }),
5241
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
6022
+ ]
6023
+ }
6024
+ ),
6025
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { flex: 1, background: "#eeeff1", padding: 20, overflow: "auto" }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
6026
+ "iframe",
6027
+ {
6028
+ ref: iframeRef,
6029
+ title: "Word Document Preview",
6030
+ srcDoc: previewHtml,
6031
+ style: {
6032
+ width: "100%",
6033
+ height: "100%",
6034
+ border: "1px solid #e3e5ea",
6035
+ background: "#ffffff",
6036
+ borderRadius: 4,
6037
+ boxShadow: "0 4px 16px rgba(27, 28, 31, 0.08)"
6038
+ }
6039
+ }
6040
+ ) })
6041
+ ] }) : tab === "form" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { flex: 1, minHeight: 0, padding: 18, display: "flex", gap: 16 }, children: [
6042
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { width: 320, display: "flex", flexDirection: "column", gap: 10 }, children: [
6043
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5242
6044
  "div",
5243
6045
  {
5244
6046
  style: {
5245
- padding: "8px 10px",
5246
- background: "#ffffff",
5247
- border: "1px solid #e3e5ea",
6047
+ padding: "12px 14px",
5248
6048
  borderRadius: 8,
5249
- display: "flex",
5250
- flexDirection: "column",
5251
- gap: 6
6049
+ background: validation.valid ? "#f3f5ff" : "#f9fafb",
6050
+ border: `1px solid ${validation.valid ? "#d2dafa" : "#e3e5ea"}`,
6051
+ color: validation.valid ? "#2c53f1" : "#1b1c1f",
6052
+ fontWeight: 600,
6053
+ fontSize: 12.5
5252
6054
  },
5253
- children: [
5254
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", fontSize: 11.5 }, children: [
5255
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontWeight: 600, color: "#1b1c1f" }, children: "\u5BFC\u5165/\u5BFC\u51FA\u5904\u7406\u65B9\u5F0F\uFF08\u6309\u6B21\u9009\u62E9\uFF09" }),
5256
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { fontSize: 10.5, color: "#7d8698" }, children: [
5257
- "\u5FEB\u7167 ",
5258
- snapSizeKb,
5259
- " KB"
5260
- ] })
5261
- ] }),
5262
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "yudao-doc-segmented", children: [
5263
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5264
- "button",
5265
- {
5266
- type: "button",
5267
- className: `yudao-doc-segmented-btn ${ioTarget === "browser" ? "is-active" : ""}`,
5268
- onClick: () => setIoTarget("browser"),
5269
- children: "\u6D4F\u89C8\u5668\u5904\u7406"
5270
- }
5271
- ),
5272
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
5273
- "button",
5274
- {
5275
- type: "button",
5276
- className: `yudao-doc-segmented-btn ${ioTarget === "server" ? "is-active" : ""}`,
5277
- onClick: () => setIoTarget("server"),
5278
- children: [
5279
- "\u670D\u52A1\u7AEF",
5280
- ioCaps.server.exportDoc || ioCaps.server.importDoc ? "" : " (\u672A\u63A5\u5165)"
5281
- ]
5282
- }
5283
- )
5284
- ] }),
5285
- ioTarget === "browser" ? exportCapReport.warnings.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
5286
- "div",
5287
- {
5288
- style: {
5289
- fontSize: 10.5,
5290
- color: "#4e5565",
5291
- background: "#f9fafb",
5292
- border: "1px solid #e3e5ea",
5293
- padding: "4px 6px",
5294
- borderRadius: 5,
5295
- lineHeight: 1.4
5296
- },
5297
- children: [
5298
- "\u6D4F\u89C8\u5668\u7AEF\u63D0\u793A\uFF1A",
5299
- exportCapReport.warnings.join("\uFF1B")
5300
- ]
5301
- }
5302
- ) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { fontSize: 10.5, color: "#4e5565", lineHeight: 1.4 }, children: "\u6D4F\u89C8\u5668\u672C\u5730\u5904\u7406\uFF1A\u96F6\u4E0A\u4F20\uFF0C\u5B8C\u6574\u4FDD\u7559\u8868\u683C/SDT/\u811A\u6CE8\u5C3E\u6CE8/\u591A\u680F/\u591A\u9875\u7709\u9875\u811A/\u4FEE\u8BA2\u7559\u75D5\u4E0E\u77E2\u91CF\u9A91\u7F1D\u7AE0 PDF\u3002" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { fontSize: 10.5, color: "#4e5565", lineHeight: 1.4 }, children: "\u670D\u52A1\u7AEF\u5904\u7406\uFF1A\u8D70\u540E\u7AEF Apache POI / poi-tl \u9AD8\u4FDD\u771F\u8BFB\u5199\uFF08\u5931\u8D25\u4E0D\u9759\u9ED8\u8F6C\u524D\u7AEF\uFF09\u3002" }),
5303
- features.datasetBinding && ioTarget === "browser" && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { style: { display: "flex", alignItems: "center", gap: 5, fontSize: 11, color: "#31363f", cursor: "pointer" }, children: [
5304
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5305
- "input",
5306
- {
5307
- type: "checkbox",
5308
- checked: skipDatasetOnExport,
5309
- onChange: (e) => setSkipDatasetOnExport(e.target.checked)
5310
- }
5311
- ),
5312
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "\u4EC5\u7F16\u7801\u5F53\u524D\u5FEB\u7167\uFF08\u4E0D\u91CD\u590D\u6267\u884C\u6570\u636E\u96C6\u586B\u6570\uFF09" })
5313
- ] })
5314
- ]
6055
+ children: validation.valid ? "\u6240\u6709\u5FC5\u586B\u7ED3\u6784\u5316\u63A7\u4EF6\u5747\u5DF2\u5408\u89C4\u586B\u5199\u5B8C\u6BD5" : `\u5B58\u5728 ${validation.issues.length} \u4E2A\u7ED3\u6784\u5316\u63A7\u4EF6\u5F85\u586B\u5199\u6216\u683C\u5F0F\u672A\u901A\u8FC7`
5315
6056
  }
5316
6057
  ),
5317
- importWarnings.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
6058
+ validation.issues.map((it) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
5318
6059
  "div",
5319
6060
  {
5320
6061
  style: {
5321
- fontSize: 10.5,
5322
- color: "#4e5565",
6062
+ padding: "8px 10px",
6063
+ borderRadius: 6,
5323
6064
  background: "#f9fafb",
5324
6065
  border: "1px solid #e3e5ea",
5325
- padding: "5px 7px",
5326
- borderRadius: 6,
5327
- lineHeight: 1.4
6066
+ borderLeft: "2px solid #d93025",
6067
+ color: "#31363f",
6068
+ fontSize: 12
5328
6069
  },
5329
6070
  children: [
5330
- "\u5BFC\u5165\u964D\u7EA7\u6E05\u5355\uFF1A",
5331
- importWarnings.join("\uFF1B")
6071
+ "\u2022 ",
6072
+ it.message,
6073
+ " (",
6074
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: it.tag }),
6075
+ ")"
5332
6076
  ]
6077
+ },
6078
+ it.controlId
6079
+ ))
6080
+ ] }),
6081
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { flex: 1, display: "flex", flexDirection: "column", gap: 8 }, children: [
6082
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { fontSize: 12.5, fontWeight: 600, color: "#1b1c1f" }, children: [
6083
+ "\u63D0\u53D6\u7684\u7ED3\u6784\u5316\u8868\u5355\u952E\u503C JSON (",
6084
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: "getFormValues()" }),
6085
+ ")\uFF1A"
6086
+ ] }),
6087
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
6088
+ "textarea",
6089
+ {
6090
+ readOnly: true,
6091
+ className: "yudao-doc-code-area",
6092
+ value: JSON.stringify(validation.values, null, 2)
5333
6093
  }
5334
- ),
5335
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 6, marginTop: 2 }, children: [
5336
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5337
- "button",
5338
- {
5339
- type: "button",
5340
- className: "yudao-doc-mini-btn is-primary yudao-doc-export-btn",
5341
- onClick: () => handleDownload("docx"),
5342
- children: "\u5BFC\u51FA Word (.docx)"
5343
- }
5344
- ),
6094
+ )
6095
+ ] })
6096
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { flex: 1, minHeight: 0, padding: 16, display: "flex", flexDirection: "column", gap: 10 }, children: [
6097
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
6098
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { fontSize: 12.5, fontWeight: 600, color: "#1b1c1f" }, children: [
6099
+ "Univer \u6807\u51C6 ",
6100
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: "IDocumentData" }),
6101
+ " JSON\uFF08\u542B\u539F\u751F ",
6102
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: "CustomRangeType.SDT" }),
6103
+ "\uFF09"
6104
+ ] }),
6105
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", gap: 8 }, children: [
5345
6106
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5346
6107
  "button",
5347
6108
  {
5348
6109
  type: "button",
5349
- className: "yudao-doc-mini-btn yudao-doc-export-btn",
5350
- onClick: () => handleDownload("pdf"),
5351
- children: "\u5BFC\u51FA\u6B63\u5F0F\u9A91\u7F1D\u7AE0 PDF"
6110
+ className: "yudao-doc-mini-btn",
6111
+ onClick: () => {
6112
+ navigator.clipboard?.writeText(jsonEditorText);
6113
+ setStatusTip("\u5DF2\u590D\u5236 JSON \u5230\u526A\u8D34\u677F\uFF01");
6114
+ },
6115
+ children: "\u590D\u5236 JSON"
5352
6116
  }
5353
6117
  ),
5354
6118
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5355
6119
  "button",
5356
6120
  {
5357
6121
  type: "button",
5358
- className: "yudao-doc-mini-btn yudao-doc-export-btn",
5359
- onClick: handleBatchExportPdf,
5360
- children: "\u6279\u91CF\u5957\u6253\u5408\u5E76\u5BFC\u51FA PDF"
5361
- }
5362
- ),
5363
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 6 }, children: [
5364
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5365
- "button",
5366
- {
5367
- type: "button",
5368
- className: "yudao-doc-mini-btn yudao-doc-export-btn",
5369
- onClick: handleImportBySelectedTarget,
5370
- children: "\u6309\u6240\u9009\u65B9\u5F0F\u5BFC\u5165"
5371
- }
5372
- ),
5373
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5374
- "button",
5375
- {
5376
- type: "button",
5377
- className: "yudao-doc-mini-btn yudao-doc-export-btn",
5378
- onClick: () => handleDownload("html"),
5379
- children: "\u5BFC\u51FA (.html)"
5380
- }
5381
- ),
5382
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5383
- "button",
5384
- {
5385
- type: "button",
5386
- className: "yudao-doc-mini-btn yudao-doc-export-btn",
5387
- onClick: () => handleDownload("md"),
5388
- children: "\u5BFC\u51FA Markdown (.md)"
5389
- }
5390
- ),
5391
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5392
- "button",
5393
- {
5394
- type: "button",
5395
- className: "yudao-doc-mini-btn yudao-doc-export-btn",
5396
- onClick: () => {
5397
- iframeRef.current?.contentWindow?.focus();
5398
- iframeRef.current?.contentWindow?.print();
5399
- },
5400
- children: "A4 \u77E2\u91CF\u6253\u5370"
5401
- }
5402
- )
5403
- ] }),
5404
- ioAdapter.onSave && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5405
- "button",
5406
- {
5407
- type: "button",
5408
- className: "yudao-doc-mini-btn yudao-doc-export-btn",
5409
- onClick: handleSaveToHost,
5410
- children: "\u4FDD\u5B58\u6A21\u677F\u81F3\u5BBF\u4E3B\u540E\u7AEF"
6122
+ className: "yudao-doc-mini-btn is-primary",
6123
+ onClick: () => {
6124
+ try {
6125
+ const parsed = JSON.parse(jsonEditorText);
6126
+ commandService.syncExecuteCommand(import_univer_docs4.ReplaceDocUnitSnapshotCommand.id, {
6127
+ unitId: unit.getUnitId(),
6128
+ snapshot: parsed
6129
+ });
6130
+ setStatusTip("\u5DF2\u5E94\u7528 JSON \u5FEB\u7167\uFF08\u652F\u6301 Ctrl+Z \u64A4\u9500\uFF09\uFF01");
6131
+ } catch (err) {
6132
+ setStatusTip(`JSON \u683C\u5F0F\u6709\u8BEF: ${err?.message || String(err)}`);
6133
+ }
6134
+ },
6135
+ children: "\u5E94\u7528\u7F16\u8F91\u5668\u4E2D\u7684 JSON"
5411
6136
  }
5412
6137
  )
5413
- ] }),
5414
- statusTip && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5415
- "div",
5416
- {
5417
- style: {
5418
- fontSize: 11.5,
5419
- color: "#2c53f1",
5420
- background: "#f3f5ff",
5421
- border: "1px solid #d2dafa",
5422
- padding: "6px 8px",
5423
- borderRadius: 6
5424
- },
5425
- children: statusTip
5426
- }
5427
- )
5428
- ]
5429
- }
5430
- ),
5431
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { flex: 1, background: "#eeeff1", padding: 20, overflow: "auto" }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5432
- "iframe",
5433
- {
5434
- ref: iframeRef,
5435
- title: "Word Document Preview",
5436
- srcDoc: previewHtml,
5437
- style: {
5438
- width: "100%",
5439
- height: "100%",
5440
- border: "1px solid #e3e5ea",
5441
- background: "#ffffff",
5442
- borderRadius: 4,
5443
- boxShadow: "0 4px 16px rgba(27, 28, 31, 0.08)"
5444
- }
5445
- }
5446
- ) })
5447
- ] }) : tab === "form" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { flex: 1, minHeight: 0, padding: 18, display: "flex", gap: 16 }, children: [
5448
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { width: 320, display: "flex", flexDirection: "column", gap: 10 }, children: [
5449
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5450
- "div",
5451
- {
5452
- style: {
5453
- padding: "12px 14px",
5454
- borderRadius: 8,
5455
- background: validation.valid ? "#f3f5ff" : "#f9fafb",
5456
- border: `1px solid ${validation.valid ? "#d2dafa" : "#e3e5ea"}`,
5457
- color: validation.valid ? "#2c53f1" : "#1b1c1f",
5458
- fontWeight: 600,
5459
- fontSize: 12.5
5460
- },
5461
- children: validation.valid ? "\u6240\u6709\u5FC5\u586B\u7ED3\u6784\u5316\u63A7\u4EF6\u5747\u5DF2\u5408\u89C4\u586B\u5199\u5B8C\u6BD5" : `\u5B58\u5728 ${validation.issues.length} \u4E2A\u7ED3\u6784\u5316\u63A7\u4EF6\u5F85\u586B\u5199\u6216\u683C\u5F0F\u672A\u901A\u8FC7`
5462
- }
5463
- ),
5464
- validation.issues.map((it) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
5465
- "div",
5466
- {
5467
- style: {
5468
- padding: "8px 10px",
5469
- borderRadius: 6,
5470
- background: "#f9fafb",
5471
- border: "1px solid #e3e5ea",
5472
- borderLeft: "2px solid #d93025",
5473
- color: "#31363f",
5474
- fontSize: 12
5475
- },
5476
- children: [
5477
- "\u2022 ",
5478
- it.message,
5479
- " (",
5480
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: it.tag }),
5481
- ")"
5482
- ]
5483
- },
5484
- it.controlId
5485
- ))
5486
- ] }),
5487
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { flex: 1, display: "flex", flexDirection: "column", gap: 8 }, children: [
5488
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { fontSize: 12.5, fontWeight: 600, color: "#1b1c1f" }, children: [
5489
- "\u63D0\u53D6\u7684\u7ED3\u6784\u5316\u8868\u5355\u952E\u503C JSON (",
5490
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: "getFormValues()" }),
5491
- ")\uFF1A"
5492
- ] }),
5493
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5494
- "textarea",
5495
- {
5496
- readOnly: true,
5497
- className: "yudao-doc-code-area",
5498
- value: JSON.stringify(validation.values, null, 2)
5499
- }
5500
- )
5501
- ] })
5502
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { flex: 1, minHeight: 0, padding: 16, display: "flex", flexDirection: "column", gap: 10 }, children: [
5503
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
5504
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { fontSize: 12.5, fontWeight: 600, color: "#1b1c1f" }, children: [
5505
- "Univer \u6807\u51C6 ",
5506
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: "IDocumentData" }),
5507
- " JSON\uFF08\u542B\u539F\u751F ",
5508
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", { children: "CustomRangeType.SDT" }),
5509
- "\uFF09"
5510
- ] }),
5511
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", gap: 8 }, children: [
5512
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5513
- "button",
5514
- {
5515
- type: "button",
5516
- className: "yudao-doc-mini-btn",
5517
- onClick: () => {
5518
- navigator.clipboard?.writeText(jsonEditorText);
5519
- setStatusTip("\u5DF2\u590D\u5236 JSON \u5230\u526A\u8D34\u677F\uFF01");
5520
- },
5521
- children: "\u590D\u5236 JSON"
5522
- }
5523
- ),
6138
+ ] })
6139
+ ] }),
6140
+ statusTip && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { fontSize: 12, color: "#2c53f1" }, children: statusTip }),
5524
6141
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5525
- "button",
6142
+ "textarea",
5526
6143
  {
5527
- type: "button",
5528
- className: "yudao-doc-mini-btn is-primary",
5529
- onClick: () => {
5530
- try {
5531
- const parsed = JSON.parse(jsonEditorText);
5532
- commandService.syncExecuteCommand(import_univer_docs4.ReplaceDocUnitSnapshotCommand.id, {
5533
- unitId: unit.getUnitId(),
5534
- snapshot: parsed
5535
- });
5536
- setStatusTip("\u5DF2\u5E94\u7528 JSON \u5FEB\u7167\uFF08\u652F\u6301 Ctrl+Z \u64A4\u9500\uFF09\uFF01");
5537
- } catch (err) {
5538
- setStatusTip(`JSON \u683C\u5F0F\u6709\u8BEF: ${err?.message || String(err)}`);
5539
- }
5540
- },
5541
- children: "\u5E94\u7528\u7F16\u8F91\u5668\u4E2D\u7684 JSON"
6144
+ className: "yudao-doc-code-area",
6145
+ value: jsonEditorText,
6146
+ onChange: (e) => setJsonEditorText(e.target.value)
5542
6147
  }
5543
6148
  )
5544
6149
  ] })
5545
- ] }),
5546
- statusTip && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { fontSize: 12, color: "#2c53f1" }, children: statusTip }),
5547
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
5548
- "textarea",
5549
- {
5550
- className: "yudao-doc-code-area",
5551
- value: jsonEditorText,
5552
- onChange: (e) => setJsonEditorText(e.target.value)
5553
- }
5554
- )
5555
- ] })
5556
- ] }) });
6150
+ ]
6151
+ }
6152
+ ) });
5557
6153
  };
5558
6154
 
5559
6155
  // src/views/popup/DocSdtCanvasPopupHost.tsx
5560
6156
  var import_core6 = require("@univerjs/core");
5561
6157
  var import_docs3 = require("@univerjs/docs");
5562
- var import_docs_ui3 = require("@univerjs/docs-ui");
6158
+ var import_docs_ui4 = require("@univerjs/docs-ui");
5563
6159
  var import_engine_render = require("@univerjs/engine-render");
5564
6160
  var import_ui5 = require("@univerjs/ui");
5565
6161
  var import_univer_docs5 = require("@yudaocode/univer-docs");
@@ -5923,7 +6519,7 @@ var DocSdtCanvasPopupHost = () => {
5923
6519
  const renderUnit = renderManagerService.getRenderUnitById(unitId2);
5924
6520
  if (!renderUnit) return false;
5925
6521
  try {
5926
- const docEventService = renderUnit.with(import_docs_ui3.DocEventManagerService);
6522
+ const docEventService = renderUnit.with(import_docs_ui4.DocEventManagerService);
5927
6523
  clickSub = docEventService.clickCustomRanges$.subscribe((payload) => {
5928
6524
  const range = payload?.range;
5929
6525
  if (!range) return;
@@ -7639,7 +8235,7 @@ DocsExtUIController = __decorateClass([
7639
8235
  // src/plugin.ts
7640
8236
  var import_core8 = require("@univerjs/core");
7641
8237
  var import_docs4 = require("@univerjs/docs");
7642
- var import_docs_ui7 = require("@univerjs/docs-ui");
8238
+ var import_docs_ui8 = require("@univerjs/docs-ui");
7643
8239
  var import_univer_docs6 = require("@yudaocode/univer-docs");
7644
8240
  var UNIVER_DOCS_EXT_UI_PLUGIN_NAME = "YUDAO_UNIVER_DOCS_EXT_UI_PLUGIN";
7645
8241
  var UniverDocsExtUIPlugin = class extends import_core8.Plugin {
@@ -7671,11 +8267,12 @@ UniverDocsExtUIPlugin.pluginName = UNIVER_DOCS_EXT_UI_PLUGIN_NAME;
7671
8267
  UniverDocsExtUIPlugin.packageName = "@yudaocode/univer-docs-ui";
7672
8268
  UniverDocsExtUIPlugin.type = import_core8.UniverInstanceType.UNIVER_DOC;
7673
8269
  UniverDocsExtUIPlugin = __decorateClass([
7674
- (0, import_core8.DependentOn)(import_docs4.UniverDocsPlugin, import_docs_ui7.UniverDocsUIPlugin, import_univer_docs6.UniverDocsExtPlugin),
8270
+ (0, import_core8.DependentOn)(import_docs4.UniverDocsPlugin, import_docs_ui8.UniverDocsUIPlugin, import_univer_docs6.UniverDocsExtPlugin),
7675
8271
  __decorateParam(1, (0, import_core8.Inject)(import_core8.Injector))
7676
8272
  ], UniverDocsExtUIPlugin);
7677
8273
  // Annotate the CommonJS export names for ESM import in node:
7678
8274
  0 && (module.exports = {
8275
+ DOC_IMPORT_ACCEPT_EXTENSIONS,
7679
8276
  DOC_INSPECTOR_COMPONENT_KEY,
7680
8277
  DOC_INSPECTOR_SIDEBAR_ID,
7681
8278
  DocInspectorPanel,