@yudaocode/univer-docs 1.6.214 → 1.6.216
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/WORD_TEMPLATE_PROTOCOL.md +25 -8
- package/fixtures/word-template-protocol-v1.json +27287 -0
- package/lib/cjs/facade/index.js +29 -8
- package/lib/cjs/facade/index.js.map +1 -1
- package/lib/cjs/index.js +935 -90
- package/lib/cjs/index.js.map +1 -1
- package/lib/es/facade/index.js +31 -8
- package/lib/es/facade/index.js.map +1 -1
- package/lib/es/index.js +1344 -504
- package/lib/es/index.js.map +1 -1
- package/lib/types/facade/index.d.ts +8 -1
- package/lib/types/index.d.ts +108 -33
- package/package.json +1 -1
package/lib/es/facade/index.js
CHANGED
|
@@ -205,6 +205,7 @@ import {
|
|
|
205
205
|
ReplyDocCommentCommand,
|
|
206
206
|
ResolveDocCommentCommand,
|
|
207
207
|
SetDocTitlePropertiesCommand,
|
|
208
|
+
summarizeDocTemplate,
|
|
208
209
|
ToggleDocSubscriptCommand,
|
|
209
210
|
ToggleDocSuperscriptCommand,
|
|
210
211
|
UpdateDocHyperlinkCommand
|
|
@@ -239,6 +240,9 @@ var FEnterpriseDoc = class {
|
|
|
239
240
|
getTemplateMetadata() {
|
|
240
241
|
return this._injector.get(IDocSdtService).getTemplateMetadata(this.getId());
|
|
241
242
|
}
|
|
243
|
+
summarizeTemplate() {
|
|
244
|
+
return summarizeDocTemplate(this.save());
|
|
245
|
+
}
|
|
242
246
|
getTables() {
|
|
243
247
|
return listDocTables(this.save());
|
|
244
248
|
}
|
|
@@ -374,8 +378,13 @@ var FEnterpriseDoc = class {
|
|
|
374
378
|
async importDocFileWithReport(file, options) {
|
|
375
379
|
const outcome = await this._injector.get(IDocIoService).importDocWithReport(file, {
|
|
376
380
|
unitId: this.getId(),
|
|
377
|
-
target: options?.target
|
|
381
|
+
target: options?.target,
|
|
382
|
+
signal: options?.signal
|
|
378
383
|
});
|
|
384
|
+
if (options?.signal?.aborted) {
|
|
385
|
+
const err = typeof DOMException !== "undefined" ? new DOMException("The operation was aborted.", "AbortError") : Object.assign(new Error("The operation was aborted."), { name: "AbortError" });
|
|
386
|
+
throw err;
|
|
387
|
+
}
|
|
379
388
|
if (outcome.documentData.body) {
|
|
380
389
|
this._commandService.syncExecuteCommand(ReplaceDocUnitSnapshotCommand.id, {
|
|
381
390
|
unitId: this.getId(),
|
|
@@ -395,7 +404,8 @@ var FEnterpriseDoc = class {
|
|
|
395
404
|
format: "docx",
|
|
396
405
|
data,
|
|
397
406
|
pdfOptions: options?.signatureImageDataUrl ? { signatureImageDataUrl: options.signatureImageDataUrl } : void 0,
|
|
398
|
-
target: options?.target
|
|
407
|
+
target: options?.target,
|
|
408
|
+
signal: options?.signal
|
|
399
409
|
});
|
|
400
410
|
}
|
|
401
411
|
async exportPdf(pdfOptions, options) {
|
|
@@ -405,7 +415,8 @@ var FEnterpriseDoc = class {
|
|
|
405
415
|
format: "pdf",
|
|
406
416
|
data: options?.data ?? pdfOptions?.data,
|
|
407
417
|
pdfOptions,
|
|
408
|
-
target: options?.target
|
|
418
|
+
target: options?.target,
|
|
419
|
+
signal: options?.signal
|
|
409
420
|
});
|
|
410
421
|
}
|
|
411
422
|
getCatalog() {
|
|
@@ -1812,6 +1823,7 @@ import {
|
|
|
1812
1823
|
import { FUniver } from "@univerjs/core/facade";
|
|
1813
1824
|
import {
|
|
1814
1825
|
buildStructuredDocData,
|
|
1826
|
+
createDocAbortError,
|
|
1815
1827
|
IDocAiCopilotService as IDocAiCopilotService2,
|
|
1816
1828
|
IDocIoService as IDocIoService2,
|
|
1817
1829
|
IDocSdtService as IDocSdtService2,
|
|
@@ -1943,7 +1955,8 @@ var FUniverDocsExtMixin = class extends FUniver {
|
|
|
1943
1955
|
async importDocToSnapshotAsync(fileOrInput, options) {
|
|
1944
1956
|
const file = coerceInputToFile(fileOrInput, options);
|
|
1945
1957
|
const partial = await this._injector.get(IDocIoService2).importDoc(file, void 0, {
|
|
1946
|
-
target: options?.target
|
|
1958
|
+
target: options?.target,
|
|
1959
|
+
signal: options?.signal
|
|
1947
1960
|
});
|
|
1948
1961
|
if (partial.body) {
|
|
1949
1962
|
return {
|
|
@@ -1967,7 +1980,13 @@ var FUniverDocsExtMixin = class extends FUniver {
|
|
|
1967
1980
|
}
|
|
1968
1981
|
async importDocToUnitIdAsync(unitId, fileOrInput, options) {
|
|
1969
1982
|
if (!unitId) return false;
|
|
1983
|
+
if (options?.signal?.aborted) {
|
|
1984
|
+
throw createDocAbortError(options.signal);
|
|
1985
|
+
}
|
|
1970
1986
|
const snapshot = await this.importDocToSnapshotAsync(fileOrInput, options);
|
|
1987
|
+
if (options?.signal?.aborted) {
|
|
1988
|
+
throw createDocAbortError(options.signal);
|
|
1989
|
+
}
|
|
1971
1990
|
snapshot.id = unitId;
|
|
1972
1991
|
const existing = this._univerInstanceService.getUnit(
|
|
1973
1992
|
unitId,
|
|
@@ -1995,19 +2014,23 @@ var FUniverDocsExtMixin = class extends FUniver {
|
|
|
1995
2014
|
format,
|
|
1996
2015
|
data: options?.data,
|
|
1997
2016
|
pdfOptions: options?.pdfOptions,
|
|
1998
|
-
target: options?.target
|
|
2017
|
+
target: options?.target,
|
|
2018
|
+
signal: options?.signal
|
|
1999
2019
|
});
|
|
2000
2020
|
}
|
|
2001
2021
|
async exportDocByUnitIdAsync(unitId, format = "docx", options) {
|
|
2022
|
+
if (options?.signal?.aborted) {
|
|
2023
|
+
throw createDocAbortError(options.signal);
|
|
2024
|
+
}
|
|
2002
2025
|
const doc = this.getEnterpriseDoc(unitId);
|
|
2003
2026
|
if (!doc) return null;
|
|
2004
|
-
return this._injector.get(IDocIoService2).
|
|
2005
|
-
unitId,
|
|
2027
|
+
return this._injector.get(IDocIoService2).exportDocFromUnit(unitId, {
|
|
2006
2028
|
snapshot: doc.save(),
|
|
2007
2029
|
format,
|
|
2008
2030
|
data: options?.data,
|
|
2009
2031
|
pdfOptions: options?.pdfOptions,
|
|
2010
|
-
target: options?.target
|
|
2032
|
+
target: options?.target,
|
|
2033
|
+
signal: options?.signal
|
|
2011
2034
|
});
|
|
2012
2035
|
}
|
|
2013
2036
|
};
|