@harbour-enterprises/superdoc 0.19.0-next.5 → 0.19.0-next.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{PdfViewer-DaZtoNpm.cjs → PdfViewer-BlV8_l4e.cjs} +1 -1
- package/dist/chunks/{PdfViewer-C2898kqZ.es.js → PdfViewer-oqYWe1FJ.es.js} +1 -1
- package/dist/chunks/{index-CkJ5hnvC.es.js → index-CeockUQz.es.js} +35 -3
- package/dist/chunks/{index-Di9R4Aas.cjs → index-DHyh73q4.cjs} +35 -3
- package/dist/chunks/{super-editor.es-kuaVTS8t.es.js → super-editor.es-BRBU19lM.es.js} +115 -91
- package/dist/chunks/{super-editor.es-DG-S6GN9.cjs → super-editor.es-bu-RKSWh.cjs} +115 -91
- package/dist/core/SuperDoc.d.ts.map +1 -1
- package/dist/stores/superdoc-store.d.ts +3 -0
- package/dist/stores/superdoc-store.d.ts.map +1 -1
- package/dist/style.css +6 -6
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-CrJvpQ8J.js → converter-BFq1XXek.js} +18 -7
- package/dist/super-editor/chunks/{docx-zipper-CHHaFCfj.js → docx-zipper-BahUy6FS.js} +1 -1
- package/dist/super-editor/chunks/{editor-DlzGbfD-.js → editor-BdLd21gy.js} +92 -84
- package/dist/super-editor/chunks/{toolbar-DeKOVf4h.js → toolbar-DoJY1zlM.js} +2 -2
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/style.css +6 -6
- package/dist/super-editor/super-editor.es.js +13 -8
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +148 -92
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/superdoc.umd.js
CHANGED
|
@@ -34206,7 +34206,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
34206
34206
|
encode: (_2, encodedAttrs) => {
|
|
34207
34207
|
return encodedAttrs["value"] != null ? encodedAttrs : void 0;
|
|
34208
34208
|
},
|
|
34209
|
-
decode: function({ node: node2 }
|
|
34209
|
+
decode: function({ node: node2 }) {
|
|
34210
34210
|
const decodedAttrs = this.decodeAttributes({ node: { ...node2, attrs: node2.attrs[sdName] || {} } });
|
|
34211
34211
|
return decodedAttrs["w:w"] != null ? decodedAttrs : void 0;
|
|
34212
34212
|
}
|
|
@@ -34224,7 +34224,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
34224
34224
|
};
|
|
34225
34225
|
};
|
|
34226
34226
|
function encodeProperties(node2, translatorsByXmlName, asArray = false) {
|
|
34227
|
-
|
|
34227
|
+
if (!node2?.elements || node2.elements.length === 0) {
|
|
34228
|
+
return asArray ? [] : {};
|
|
34229
|
+
}
|
|
34230
|
+
const attributes = asArray ? [] : {};
|
|
34228
34231
|
node2.elements.forEach((el) => {
|
|
34229
34232
|
const translator2 = translatorsByXmlName[el.name];
|
|
34230
34233
|
if (translator2) {
|
|
@@ -34241,6 +34244,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
34241
34244
|
return attributes;
|
|
34242
34245
|
}
|
|
34243
34246
|
function decodeProperties(translatorsBySdName, properties) {
|
|
34247
|
+
if (!properties || typeof properties !== "object") {
|
|
34248
|
+
return [];
|
|
34249
|
+
}
|
|
34244
34250
|
const elements = [];
|
|
34245
34251
|
Object.keys(properties).forEach((key) => {
|
|
34246
34252
|
const translator2 = translatorsBySdName[key];
|
|
@@ -35045,7 +35051,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35045
35051
|
}
|
|
35046
35052
|
return href;
|
|
35047
35053
|
};
|
|
35048
|
-
function decode(params2
|
|
35054
|
+
function decode(params2) {
|
|
35049
35055
|
const { node: node2 } = params2;
|
|
35050
35056
|
const linkMark = node2.marks.find((m2) => m2.type === "link");
|
|
35051
35057
|
const linkAttrs = this.decodeAttributes({ ...params2, node: linkMark });
|
|
@@ -38406,7 +38412,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
38406
38412
|
}
|
|
38407
38413
|
} catch (error) {
|
|
38408
38414
|
console.debug("Import error", error);
|
|
38409
|
-
editor?.emit("exception", { error });
|
|
38415
|
+
editor?.emit("exception", { error, editor });
|
|
38410
38416
|
converter?.telemetry?.trackStatistic("error", {
|
|
38411
38417
|
type: "processing_error",
|
|
38412
38418
|
message: error.message,
|
|
@@ -38419,7 +38425,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
38419
38425
|
return processedElements;
|
|
38420
38426
|
} catch (error) {
|
|
38421
38427
|
console.debug("Error during import", error);
|
|
38422
|
-
editor?.emit("exception", { error });
|
|
38428
|
+
editor?.emit("exception", { error, editor });
|
|
38423
38429
|
converter?.telemetry?.trackStatistic("error", {
|
|
38424
38430
|
type: "fatal_error",
|
|
38425
38431
|
message: error.message,
|
|
@@ -38885,8 +38891,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
38885
38891
|
return { typeface, panose };
|
|
38886
38892
|
}
|
|
38887
38893
|
getSchema(editor) {
|
|
38888
|
-
|
|
38889
|
-
|
|
38894
|
+
let result;
|
|
38895
|
+
try {
|
|
38896
|
+
this.getDocumentInternalId();
|
|
38897
|
+
result = createDocumentJson({ ...this.convertedXml, media: this.media }, this, editor);
|
|
38898
|
+
} catch (error) {
|
|
38899
|
+
editor?.emit("exception", { error, editor });
|
|
38900
|
+
}
|
|
38890
38901
|
if (result) {
|
|
38891
38902
|
this.savedTagsToRestore.push({ ...result.savedTagsToRestore });
|
|
38892
38903
|
this.pageStyles = result.pageStyles;
|
|
@@ -55277,7 +55288,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
55277
55288
|
}
|
|
55278
55289
|
return { root: root2, wasFixed };
|
|
55279
55290
|
}
|
|
55280
|
-
function cleanupRootChildren(root2
|
|
55291
|
+
function cleanupRootChildren(root2) {
|
|
55281
55292
|
const validChildren = root2.elements?.filter((child) => child?.type === "element" && child.name === "Relationship") || [];
|
|
55282
55293
|
if (root2.elements?.length !== validChildren.length) {
|
|
55283
55294
|
root2.elements = validChildren;
|
|
@@ -56274,85 +56285,89 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
56274
56285
|
getUpdatedDocs = false,
|
|
56275
56286
|
fieldsHighlightColor = null
|
|
56276
56287
|
} = {}) {
|
|
56277
|
-
|
|
56278
|
-
|
|
56279
|
-
|
|
56280
|
-
|
|
56281
|
-
|
|
56282
|
-
|
|
56283
|
-
|
|
56284
|
-
|
|
56285
|
-
|
|
56286
|
-
|
|
56287
|
-
|
|
56288
|
-
|
|
56289
|
-
__privateMethod$1(this, _Editor_instances, validateDocumentExport_fn).call(this);
|
|
56290
|
-
if (exportXmlOnly || exportJsonOnly) return documentXml;
|
|
56291
|
-
const customXml = this.converter.schemaToXml(this.converter.convertedXml["docProps/custom.xml"].elements[0]);
|
|
56292
|
-
const styles = this.converter.schemaToXml(this.converter.convertedXml["word/styles.xml"].elements[0]);
|
|
56293
|
-
const customSettings = this.converter.schemaToXml(this.converter.convertedXml["word/settings.xml"].elements[0]);
|
|
56294
|
-
const rels = this.converter.schemaToXml(this.converter.convertedXml["word/_rels/document.xml.rels"].elements[0]);
|
|
56295
|
-
const media = this.converter.addedMedia;
|
|
56296
|
-
const updatedHeadersFooters = {};
|
|
56297
|
-
Object.entries(this.converter.convertedXml).forEach(([name, json2]) => {
|
|
56298
|
-
if (name.includes("header") || name.includes("footer")) {
|
|
56299
|
-
const resultXml = this.converter.schemaToXml(json2.elements[0]);
|
|
56300
|
-
updatedHeadersFooters[name] = String(resultXml);
|
|
56301
|
-
}
|
|
56302
|
-
});
|
|
56303
|
-
const numberingData = this.converter.convertedXml["word/numbering.xml"];
|
|
56304
|
-
const numbering = this.converter.schemaToXml(numberingData.elements[0]);
|
|
56305
|
-
const updatedDocs = {
|
|
56306
|
-
...this.options.customUpdatedFiles,
|
|
56307
|
-
"word/document.xml": String(documentXml),
|
|
56308
|
-
"docProps/custom.xml": String(customXml),
|
|
56309
|
-
"word/settings.xml": String(customSettings),
|
|
56310
|
-
"word/_rels/document.xml.rels": String(rels),
|
|
56311
|
-
"word/numbering.xml": String(numbering),
|
|
56312
|
-
// Replace & with & in styles.xml as DOCX viewers can't handle it
|
|
56313
|
-
"word/styles.xml": String(styles).replace(/&/gi, "&"),
|
|
56314
|
-
...updatedHeadersFooters
|
|
56315
|
-
};
|
|
56316
|
-
if (comments.length) {
|
|
56317
|
-
const commentsXml = this.converter.schemaToXml(this.converter.convertedXml["word/comments.xml"].elements[0]);
|
|
56318
|
-
const commentsExtendedXml = this.converter.schemaToXml(
|
|
56319
|
-
this.converter.convertedXml["word/commentsExtended.xml"].elements[0]
|
|
56320
|
-
);
|
|
56321
|
-
const commentsExtensibleXml = this.converter.schemaToXml(
|
|
56322
|
-
this.converter.convertedXml["word/commentsExtensible.xml"].elements[0]
|
|
56323
|
-
);
|
|
56324
|
-
const commentsIdsXml = this.converter.schemaToXml(
|
|
56325
|
-
this.converter.convertedXml["word/commentsIds.xml"].elements[0]
|
|
56288
|
+
try {
|
|
56289
|
+
const json = __privateMethod$1(this, _Editor_instances, prepareDocumentForExport_fn).call(this, comments);
|
|
56290
|
+
const documentXml = await this.converter.exportToDocx(
|
|
56291
|
+
json,
|
|
56292
|
+
this.schema,
|
|
56293
|
+
this.storage.image.media,
|
|
56294
|
+
isFinalDoc,
|
|
56295
|
+
commentsType,
|
|
56296
|
+
comments,
|
|
56297
|
+
this,
|
|
56298
|
+
exportJsonOnly,
|
|
56299
|
+
fieldsHighlightColor
|
|
56326
56300
|
);
|
|
56327
|
-
|
|
56328
|
-
|
|
56329
|
-
|
|
56330
|
-
|
|
56331
|
-
|
|
56332
|
-
|
|
56333
|
-
|
|
56334
|
-
|
|
56335
|
-
|
|
56336
|
-
|
|
56337
|
-
|
|
56301
|
+
__privateMethod$1(this, _Editor_instances, validateDocumentExport_fn).call(this);
|
|
56302
|
+
if (exportXmlOnly || exportJsonOnly) return documentXml;
|
|
56303
|
+
const customXml = this.converter.schemaToXml(this.converter.convertedXml["docProps/custom.xml"].elements[0]);
|
|
56304
|
+
const styles = this.converter.schemaToXml(this.converter.convertedXml["word/styles.xml"].elements[0]);
|
|
56305
|
+
const customSettings = this.converter.schemaToXml(this.converter.convertedXml["word/settings.xml"].elements[0]);
|
|
56306
|
+
const rels = this.converter.schemaToXml(this.converter.convertedXml["word/_rels/document.xml.rels"].elements[0]);
|
|
56307
|
+
const media = this.converter.addedMedia;
|
|
56308
|
+
const updatedHeadersFooters = {};
|
|
56309
|
+
Object.entries(this.converter.convertedXml).forEach(([name, json2]) => {
|
|
56310
|
+
if (name.includes("header") || name.includes("footer")) {
|
|
56311
|
+
const resultXml = this.converter.schemaToXml(json2.elements[0]);
|
|
56312
|
+
updatedHeadersFooters[name] = String(resultXml);
|
|
56313
|
+
}
|
|
56314
|
+
});
|
|
56315
|
+
const numberingData = this.converter.convertedXml["word/numbering.xml"];
|
|
56316
|
+
const numbering = this.converter.schemaToXml(numberingData.elements[0]);
|
|
56317
|
+
const updatedDocs = {
|
|
56318
|
+
...this.options.customUpdatedFiles,
|
|
56319
|
+
"word/document.xml": String(documentXml),
|
|
56320
|
+
"docProps/custom.xml": String(customXml),
|
|
56321
|
+
"word/settings.xml": String(customSettings),
|
|
56322
|
+
"word/_rels/document.xml.rels": String(rels),
|
|
56323
|
+
"word/numbering.xml": String(numbering),
|
|
56324
|
+
// Replace & with & in styles.xml as DOCX viewers can't handle it
|
|
56325
|
+
"word/styles.xml": String(styles).replace(/&/gi, "&"),
|
|
56326
|
+
...updatedHeadersFooters
|
|
56327
|
+
};
|
|
56328
|
+
if (comments.length) {
|
|
56329
|
+
const commentsXml = this.converter.schemaToXml(this.converter.convertedXml["word/comments.xml"].elements[0]);
|
|
56330
|
+
const commentsExtendedXml = this.converter.schemaToXml(
|
|
56331
|
+
this.converter.convertedXml["word/commentsExtended.xml"].elements[0]
|
|
56332
|
+
);
|
|
56333
|
+
const commentsExtensibleXml = this.converter.schemaToXml(
|
|
56334
|
+
this.converter.convertedXml["word/commentsExtensible.xml"].elements[0]
|
|
56335
|
+
);
|
|
56336
|
+
const commentsIdsXml = this.converter.schemaToXml(
|
|
56337
|
+
this.converter.convertedXml["word/commentsIds.xml"].elements[0]
|
|
56338
|
+
);
|
|
56339
|
+
updatedDocs["word/comments.xml"] = String(commentsXml);
|
|
56340
|
+
updatedDocs["word/commentsExtended.xml"] = String(commentsExtendedXml);
|
|
56341
|
+
updatedDocs["word/commentsExtensible.xml"] = String(commentsExtensibleXml);
|
|
56342
|
+
updatedDocs["word/commentsIds.xml"] = String(commentsIdsXml);
|
|
56343
|
+
}
|
|
56344
|
+
const zipper = new DocxZipper();
|
|
56345
|
+
if (getUpdatedDocs) {
|
|
56346
|
+
updatedDocs["[Content_Types].xml"] = await zipper.updateContentTypes(
|
|
56347
|
+
{
|
|
56348
|
+
files: this.options.content
|
|
56349
|
+
},
|
|
56350
|
+
media,
|
|
56351
|
+
true
|
|
56352
|
+
);
|
|
56353
|
+
return updatedDocs;
|
|
56354
|
+
}
|
|
56355
|
+
const result = await zipper.updateZip({
|
|
56356
|
+
docx: this.options.content,
|
|
56357
|
+
updatedDocs,
|
|
56358
|
+
originalDocxFile: this.options.fileSource,
|
|
56338
56359
|
media,
|
|
56339
|
-
|
|
56340
|
-
|
|
56341
|
-
|
|
56360
|
+
fonts: this.options.fonts,
|
|
56361
|
+
isHeadless: this.options.isHeadless
|
|
56362
|
+
});
|
|
56363
|
+
this.options.telemetry?.trackUsage("document_export", {
|
|
56364
|
+
documentType: "docx",
|
|
56365
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
56366
|
+
});
|
|
56367
|
+
return result;
|
|
56368
|
+
} catch (error) {
|
|
56369
|
+
this.emit("exception", { error, editor: this });
|
|
56342
56370
|
}
|
|
56343
|
-
const result = await zipper.updateZip({
|
|
56344
|
-
docx: this.options.content,
|
|
56345
|
-
updatedDocs,
|
|
56346
|
-
originalDocxFile: this.options.fileSource,
|
|
56347
|
-
media,
|
|
56348
|
-
fonts: this.options.fonts,
|
|
56349
|
-
isHeadless: this.options.isHeadless
|
|
56350
|
-
});
|
|
56351
|
-
this.options.telemetry?.trackUsage("document_export", {
|
|
56352
|
-
documentType: "docx",
|
|
56353
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
56354
|
-
});
|
|
56355
|
-
return result;
|
|
56356
56371
|
}
|
|
56357
56372
|
/**
|
|
56358
56373
|
* Destroy the editor and clean up resources
|
|
@@ -56373,7 +56388,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
56373
56388
|
}
|
|
56374
56389
|
this.converter.headerEditors.length = 0;
|
|
56375
56390
|
this.converter.footerEditors.length = 0;
|
|
56376
|
-
} catch {
|
|
56391
|
+
} catch (error) {
|
|
56392
|
+
this.emit("exception", { error, editor: this });
|
|
56377
56393
|
}
|
|
56378
56394
|
}
|
|
56379
56395
|
/**
|
|
@@ -56438,7 +56454,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
56438
56454
|
this.initDefaultStyles();
|
|
56439
56455
|
if (this.options.ydoc && this.options.collaborationProvider) {
|
|
56440
56456
|
updateYdocDocxData(this);
|
|
56441
|
-
this.initializeCollaborationData(
|
|
56457
|
+
this.initializeCollaborationData();
|
|
56442
56458
|
} else {
|
|
56443
56459
|
__privateMethod$1(this, _Editor_instances, insertNewFileData_fn).call(this);
|
|
56444
56460
|
}
|
|
@@ -56598,7 +56614,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
56598
56614
|
this.on("beforeCreate", this.options.onBeforeCreate);
|
|
56599
56615
|
this.emit("beforeCreate", { editor: this });
|
|
56600
56616
|
this.on("contentError", this.options.onContentError);
|
|
56601
|
-
this.on("exception", this.options.onException);
|
|
56602
56617
|
this.mount(this.options.element);
|
|
56603
56618
|
this.on("create", this.options.onCreate);
|
|
56604
56619
|
this.on("update", this.options.onUpdate);
|
|
@@ -56616,6 +56631,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
56616
56631
|
this.on("paginationUpdate", this.options.onPaginationUpdate);
|
|
56617
56632
|
this.on("comment-positions", this.options.onCommentLocationsUpdate);
|
|
56618
56633
|
this.on("list-definitions-change", this.options.onListDefinitionsChange);
|
|
56634
|
+
this.on("exception", this.options.onException);
|
|
56619
56635
|
if (!this.options.isHeadless) {
|
|
56620
56636
|
this.initializeCollaborationData();
|
|
56621
56637
|
this.initDefaultStyles();
|
|
@@ -56942,7 +56958,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
56942
56958
|
console.debug("🔗 [super-editor] Ending collaboration");
|
|
56943
56959
|
if (this.options.collaborationProvider) this.options.collaborationProvider.disconnect();
|
|
56944
56960
|
if (this.options.ydoc) this.options.ydoc.destroy();
|
|
56945
|
-
} catch {
|
|
56961
|
+
} catch (error) {
|
|
56962
|
+
this.emit("exception", { error, editor: this });
|
|
56946
56963
|
}
|
|
56947
56964
|
};
|
|
56948
56965
|
validateDocumentInit_fn = function() {
|
|
@@ -66231,6 +66248,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
66231
66248
|
file = processedImageResult.file;
|
|
66232
66249
|
} catch (err) {
|
|
66233
66250
|
console.warn("Error processing image:", err);
|
|
66251
|
+
editor.emit("exception", { error: err, editor });
|
|
66234
66252
|
return;
|
|
66235
66253
|
}
|
|
66236
66254
|
await uploadImage({
|
|
@@ -66285,9 +66303,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
66285
66303
|
view.dispatch(
|
|
66286
66304
|
view.state.tr.replaceWith(placeholderPos, placeholderPos, imageNode).setMeta(ImagePlaceholderPluginKey, removeMeta)
|
|
66287
66305
|
);
|
|
66288
|
-
} catch {
|
|
66306
|
+
} catch (error) {
|
|
66289
66307
|
let removeMeta = { type: "remove", id };
|
|
66290
66308
|
view.dispatch(tr.setMeta(ImagePlaceholderPluginKey, removeMeta));
|
|
66309
|
+
editor.emit("exception", { error, editor });
|
|
66291
66310
|
}
|
|
66292
66311
|
}
|
|
66293
66312
|
function addImageRelationship({ editor, path }) {
|
|
@@ -87826,7 +87845,9 @@ ${style2}
|
|
|
87826
87845
|
} else if (typeof command2 === "function") {
|
|
87827
87846
|
command2({ item, argument, option });
|
|
87828
87847
|
} else {
|
|
87829
|
-
|
|
87848
|
+
const error = new Error(`[super-toolbar 🎨] Command not found: ${command2}`);
|
|
87849
|
+
this.emit("exception", { error, editor: this.activeEditor });
|
|
87850
|
+
throw error;
|
|
87830
87851
|
}
|
|
87831
87852
|
this.updateToolbarState();
|
|
87832
87853
|
}
|
|
@@ -89081,6 +89102,9 @@ ${style2}
|
|
|
89081
89102
|
return { content: docx, media, mediaFiles, fonts };
|
|
89082
89103
|
} catch (err) {
|
|
89083
89104
|
console.debug("Error loading new file data:", err);
|
|
89105
|
+
if (typeof props.options.onException === "function") {
|
|
89106
|
+
props.options.onException({ error: err, editor: null });
|
|
89107
|
+
}
|
|
89084
89108
|
}
|
|
89085
89109
|
};
|
|
89086
89110
|
const initializeData = async () => {
|
|
@@ -89283,7 +89307,7 @@ ${style2}
|
|
|
89283
89307
|
};
|
|
89284
89308
|
}
|
|
89285
89309
|
};
|
|
89286
|
-
const SuperEditor = /* @__PURE__ */ _export_sfc$1(_sfc_main$1$1, [["__scopeId", "data-v-
|
|
89310
|
+
const SuperEditor = /* @__PURE__ */ _export_sfc$1(_sfc_main$1$1, [["__scopeId", "data-v-0c36dd72"]]);
|
|
89287
89311
|
const _hoisted_1$h = ["innerHTML"];
|
|
89288
89312
|
const _sfc_main$i = {
|
|
89289
89313
|
__name: "SuperInput",
|
|
@@ -92435,6 +92459,7 @@ ${reason}`);
|
|
|
92435
92459
|
}
|
|
92436
92460
|
const useSuperdocStore = /* @__PURE__ */ defineStore("superdoc", () => {
|
|
92437
92461
|
const currentConfig = ref$1(null);
|
|
92462
|
+
let exceptionHandler = null;
|
|
92438
92463
|
const commentsStore = useCommentsStore();
|
|
92439
92464
|
const documents = ref$1([]);
|
|
92440
92465
|
const documentBounds = ref$1([]);
|
|
@@ -92469,6 +92494,13 @@ ${reason}`);
|
|
|
92469
92494
|
scrollTop: 0,
|
|
92470
92495
|
scrollLeft: 0
|
|
92471
92496
|
});
|
|
92497
|
+
const setExceptionHandler = (handler2) => {
|
|
92498
|
+
exceptionHandler = typeof handler2 === "function" ? handler2 : null;
|
|
92499
|
+
};
|
|
92500
|
+
const emitException = (payload) => {
|
|
92501
|
+
const handler2 = exceptionHandler || currentConfig.value?.onException;
|
|
92502
|
+
if (typeof handler2 === "function") handler2(payload);
|
|
92503
|
+
};
|
|
92472
92504
|
const init2 = async (config2) => {
|
|
92473
92505
|
reset();
|
|
92474
92506
|
currentConfig.value = config2;
|
|
@@ -92494,11 +92526,30 @@ ${reason}`);
|
|
|
92494
92526
|
const initializeDocuments = async (docsToProcess = []) => {
|
|
92495
92527
|
if (!docsToProcess) return [];
|
|
92496
92528
|
for (let doc2 of docsToProcess) {
|
|
92529
|
+
if (!doc2) {
|
|
92530
|
+
emitException({
|
|
92531
|
+
error: new Error("Received empty document entry during initialization."),
|
|
92532
|
+
stage: "document-init",
|
|
92533
|
+
document: doc2
|
|
92534
|
+
});
|
|
92535
|
+
console.warn("[superdoc] Skipping empty document entry.");
|
|
92536
|
+
continue;
|
|
92537
|
+
}
|
|
92497
92538
|
try {
|
|
92498
92539
|
let docWithData = await _initializeDocumentData(doc2);
|
|
92540
|
+
if (!docWithData) {
|
|
92541
|
+
emitException({
|
|
92542
|
+
error: new Error("Document could not be initialized with the provided configuration."),
|
|
92543
|
+
stage: "document-init",
|
|
92544
|
+
document: doc2
|
|
92545
|
+
});
|
|
92546
|
+
console.warn("[superdoc] Skipping document due to invalid configuration:", doc2);
|
|
92547
|
+
continue;
|
|
92548
|
+
}
|
|
92499
92549
|
const smartDoc = useDocument(docWithData, currentConfig.value);
|
|
92500
92550
|
documents.value.push(smartDoc);
|
|
92501
92551
|
} catch (e) {
|
|
92552
|
+
emitException({ error: e, stage: "document-init", document: doc2 });
|
|
92502
92553
|
console.warn("[superdoc] Error initializing document:", doc2, "with error:", e, "Skipping document.");
|
|
92503
92554
|
}
|
|
92504
92555
|
}
|
|
@@ -92542,7 +92593,7 @@ ${reason}`);
|
|
|
92542
92593
|
const fileObject = await getFileObject(doc2.url, doc2.name || "document", doc2.type);
|
|
92543
92594
|
return { ...doc2, data: fileObject };
|
|
92544
92595
|
}
|
|
92545
|
-
|
|
92596
|
+
return null;
|
|
92546
92597
|
};
|
|
92547
92598
|
const areDocumentsReady = computed(() => {
|
|
92548
92599
|
for (let obj of documents.value.filter((doc2) => doc2.type === "pdf")) {
|
|
@@ -92592,6 +92643,7 @@ ${reason}`);
|
|
|
92592
92643
|
areDocumentsReady,
|
|
92593
92644
|
// Actions
|
|
92594
92645
|
init: init2,
|
|
92646
|
+
setExceptionHandler,
|
|
92595
92647
|
reset,
|
|
92596
92648
|
handlePageReady,
|
|
92597
92649
|
getDocument,
|
|
@@ -106736,6 +106788,9 @@ ${style2}
|
|
|
106736
106788
|
this.superdocStore = superdocStore;
|
|
106737
106789
|
this.commentsStore = commentsStore;
|
|
106738
106790
|
this.highContrastModeStore = highContrastModeStore;
|
|
106791
|
+
if (typeof this.superdocStore.setExceptionHandler === "function") {
|
|
106792
|
+
this.superdocStore.setExceptionHandler((payload) => this.emit("exception", payload));
|
|
106793
|
+
}
|
|
106739
106794
|
this.superdocStore.init(this.config);
|
|
106740
106795
|
this.commentsStore.init(this.config.modules.comments);
|
|
106741
106796
|
}
|
|
@@ -106931,6 +106986,7 @@ ${style2}
|
|
|
106931
106986
|
};
|
|
106932
106987
|
this.toolbar = new SuperToolbar(config2);
|
|
106933
106988
|
this.toolbar.on("superdoc-command", this.onToolbarCommand.bind(this));
|
|
106989
|
+
this.toolbar.on("exception", this.config.onException);
|
|
106934
106990
|
this.once("editorCreate", () => this.toolbar.updateToolbarState());
|
|
106935
106991
|
}
|
|
106936
106992
|
/**
|