@harbour-enterprises/superdoc 0.14.6-next.3 → 0.14.6-next.5
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/{index-BMwK7kM5.es.js → index-BvK-G6B1.es.js} +2 -2
- package/dist/chunks/{index-CZuIe8A3.cjs → index-CCRVYhTn.cjs} +1 -1
- package/dist/chunks/{index-Oz4X1zyg.cjs → index-CgJ5KVh6.cjs} +2 -2
- package/dist/chunks/{index-MJ-5Yknb.es.js → index-oHslWah4.es.js} +1 -1
- package/dist/chunks/{super-editor.es-Doj47_Uk.es.js → super-editor.es-BYiQ5Sba.es.js} +145 -41
- package/dist/chunks/{super-editor.es-Do3auYDx.cjs → super-editor.es-MF7rUP6m.cjs} +145 -41
- package/dist/chunks/{url-CRVat8D5.cjs → url-BG1Z_Z2_.cjs} +1 -1
- package/dist/chunks/{url-Cqg2Hljl.es.js → url-Dvx6wrNT.es.js} +1 -1
- package/dist/chunks/{xml-js-t28wMlyv.cjs → xml-js-BHJlXtfU.cjs} +11 -4
- package/dist/chunks/{xml-js-D78KIQHL.es.js → xml-js-DNISVjNF.es.js} +11 -4
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-Ro5dTlZK.js → converter-CBjKXKtl.js} +2 -2
- package/dist/super-editor/chunks/{docx-zipper-Bw5bp8Iy.js → docx-zipper-CW7ZrG_n.js} +1 -1
- package/dist/super-editor/chunks/{editor-CxB6pOHC.js → editor-CUhB7mWQ.js} +145 -41
- package/dist/super-editor/chunks/{toolbar-BAcW5u42.js → toolbar-CGArQvBn.js} +2 -2
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor/core/Editor.d.ts +7 -0
- package/dist/super-editor/core/Editor.d.ts.map +1 -1
- package/dist/super-editor/core/helpers/annotator.d.ts.map +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/extensions/pagination/pagination-helpers.d.ts.map +1 -1
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/super-editor.es.js +6 -6
- 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 +5 -5
- package/dist/superdoc.es.js +6 -6
- package/dist/superdoc.umd.js +146 -42
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as commonjsGlobal, B as Buffer, a as getAugmentedNamespace, g as getDefaultExportFromCjs } from "./jszip-CYDYUNnI.es.js";
|
|
2
2
|
import { p as process$1 } from "./vue-lU0o_RlU.es.js";
|
|
3
|
-
import { e as eventsExports, r as require$$2, u as util, i as inherits_browserExports, b as browser$1, a as requireString_decoder } from "./xml-js-
|
|
4
|
-
import { u as url } from "./url-
|
|
3
|
+
import { e as eventsExports, r as require$$2, u as util, i as inherits_browserExports, b as browser$1, a as requireString_decoder } from "./xml-js-DNISVjNF.es.js";
|
|
4
|
+
import { u as url } from "./url-Dvx6wrNT.es.js";
|
|
5
5
|
function _mergeNamespaces(n, m) {
|
|
6
6
|
for (var i = 0; i < m.length; i++) {
|
|
7
7
|
const e = m[i];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const jszip = require("./jszip-D5XoMX4C.cjs");
|
|
3
3
|
const vue = require("./vue-tQYF719J.cjs");
|
|
4
|
-
const xmlJs = require("./xml-js-
|
|
5
|
-
const url = require("./url-
|
|
4
|
+
const xmlJs = require("./xml-js-BHJlXtfU.cjs");
|
|
5
|
+
const url = require("./url-BG1Z_Z2_.cjs");
|
|
6
6
|
function _mergeNamespaces(n, m) {
|
|
7
7
|
for (var i = 0; i < m.length; i++) {
|
|
8
8
|
const e = m[i];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { g as getDefaultExportFromCjs } from "./jszip-CYDYUNnI.es.js";
|
|
2
|
-
import { s as streamHttp, r as require$$1 } from "./index-
|
|
2
|
+
import { s as streamHttp, r as require$$1 } from "./index-BvK-G6B1.es.js";
|
|
3
3
|
function _mergeNamespaces(n, m) {
|
|
4
4
|
for (var i = 0; i < m.length; i++) {
|
|
5
5
|
const e = m[i];
|
|
@@ -24305,7 +24305,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
24305
24305
|
return;
|
|
24306
24306
|
}
|
|
24307
24307
|
}
|
|
24308
|
-
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.14.6-next.
|
|
24308
|
+
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.14.6-next.5") {
|
|
24309
24309
|
const customLocation = "docProps/custom.xml";
|
|
24310
24310
|
if (!docx[customLocation]) {
|
|
24311
24311
|
docx[customLocation] = generateCustomXml();
|
|
@@ -24781,7 +24781,7 @@ function storeSuperdocVersion(docx) {
|
|
|
24781
24781
|
function generateCustomXml() {
|
|
24782
24782
|
return DEFAULT_CUSTOM_XML;
|
|
24783
24783
|
}
|
|
24784
|
-
function generateSuperdocVersion(pid = 2, version2 = "0.14.6-next.
|
|
24784
|
+
function generateSuperdocVersion(pid = 2, version2 = "0.14.6-next.5") {
|
|
24785
24785
|
return {
|
|
24786
24786
|
type: "element",
|
|
24787
24787
|
name: "property",
|
|
@@ -40168,6 +40168,7 @@ const onHeaderFooterDataUpdate = async ({ editor, transaction }, mainEditor, sec
|
|
|
40168
40168
|
});
|
|
40169
40169
|
});
|
|
40170
40170
|
mainEditor.converter[`${type2}s`][sectionId] = updatedData;
|
|
40171
|
+
mainEditor.setOptions({ isHeaderFooterChanged: editor.docChanged });
|
|
40171
40172
|
await updateYdocDocxData(mainEditor);
|
|
40172
40173
|
};
|
|
40173
40174
|
const setEditorToolbar = ({ editor }, mainEditor) => {
|
|
@@ -40996,33 +40997,46 @@ const processTables = ({ state: state2, tr, annotationValues }) => {
|
|
|
40996
40997
|
tables.reverse().forEach(({ pos }) => {
|
|
40997
40998
|
const currentTableNode = tr.doc.nodeAt(pos);
|
|
40998
40999
|
if (!currentTableNode || currentTableNode.type.name !== "table") return;
|
|
40999
|
-
|
|
41000
|
+
try {
|
|
41001
|
+
generateTableIfNecessary({ tableNode: { node: currentTableNode, pos }, annotationValues, tr, state: state2 });
|
|
41002
|
+
} catch (error) {
|
|
41003
|
+
console.error("Error generating table at pos", pos, ":", error);
|
|
41004
|
+
}
|
|
41000
41005
|
});
|
|
41001
41006
|
return tr;
|
|
41002
41007
|
};
|
|
41003
41008
|
const generateTableIfNecessary = ({ tableNode, annotationValues, tr, state: state2 }) => {
|
|
41004
|
-
let rowNodeToGenerate = null;
|
|
41005
|
-
let currentRow = null;
|
|
41006
41009
|
const {
|
|
41007
41010
|
tableRow: RowType,
|
|
41008
41011
|
tableCell: CellType,
|
|
41009
41012
|
fieldAnnotation: FieldType,
|
|
41010
41013
|
paragraph: ParaType
|
|
41011
41014
|
} = state2.schema.nodes;
|
|
41015
|
+
const rows = [];
|
|
41012
41016
|
tableNode.node.descendants((node2, pos) => {
|
|
41013
|
-
if (
|
|
41014
|
-
|
|
41015
|
-
if (node2.type === FieldType) {
|
|
41016
|
-
const annotationValue = getAnnotationValue(node2.attrs.fieldId, annotationValues);
|
|
41017
|
-
if (Array.isArray(annotationValue) && node2.attrs.generatorIndex === null) {
|
|
41018
|
-
rowNodeToGenerate = currentRow;
|
|
41019
|
-
}
|
|
41017
|
+
if (node2.type === RowType) {
|
|
41018
|
+
rows.push({ node: node2, pos });
|
|
41020
41019
|
}
|
|
41021
41020
|
});
|
|
41021
|
+
let rowNodeToGenerate = null;
|
|
41022
|
+
for (const row of rows) {
|
|
41023
|
+
let hasArrayAnnotation = false;
|
|
41024
|
+
row.node.descendants((node2, pos) => {
|
|
41025
|
+
if (node2.type === FieldType) {
|
|
41026
|
+
const annotationValue = getAnnotationValue(node2.attrs.fieldId, annotationValues);
|
|
41027
|
+
if (Array.isArray(annotationValue) && node2.attrs.generatorIndex === null) {
|
|
41028
|
+
hasArrayAnnotation = true;
|
|
41029
|
+
}
|
|
41030
|
+
}
|
|
41031
|
+
});
|
|
41032
|
+
if (hasArrayAnnotation) {
|
|
41033
|
+
rowNodeToGenerate = row;
|
|
41034
|
+
break;
|
|
41035
|
+
}
|
|
41036
|
+
}
|
|
41022
41037
|
if (!rowNodeToGenerate) return;
|
|
41023
41038
|
const { node: rowNode, pos: rowStartPos } = rowNodeToGenerate;
|
|
41024
|
-
const absoluteRowStart =
|
|
41025
|
-
const absoluteRowEnd = absoluteRowStart + rowNode.nodeSize;
|
|
41039
|
+
const absoluteRowStart = tableNode.pos + 1 + rowStartPos;
|
|
41026
41040
|
let rowsToGenerate = 0;
|
|
41027
41041
|
rowNode.descendants((childNode, childPos) => {
|
|
41028
41042
|
if (childNode.type === FieldType) {
|
|
@@ -41033,34 +41047,112 @@ const generateTableIfNecessary = ({ tableNode, annotationValues, tr, state: stat
|
|
|
41033
41047
|
}
|
|
41034
41048
|
});
|
|
41035
41049
|
if (rowsToGenerate <= 1) return;
|
|
41050
|
+
const validateAttributes = (attrs) => {
|
|
41051
|
+
const cleaned = {};
|
|
41052
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
41053
|
+
if (value !== void 0 && value !== null) {
|
|
41054
|
+
if (key === "displayLabel") {
|
|
41055
|
+
cleaned[key] = String(value);
|
|
41056
|
+
} else if (key === "rawHtml" || key === "linkUrl" || key === "imageSrc") {
|
|
41057
|
+
cleaned[key] = String(value);
|
|
41058
|
+
} else if (typeof value === "string" && value.length > 0) {
|
|
41059
|
+
cleaned[key] = value;
|
|
41060
|
+
} else if (typeof value !== "string") {
|
|
41061
|
+
cleaned[key] = value;
|
|
41062
|
+
}
|
|
41063
|
+
}
|
|
41064
|
+
}
|
|
41065
|
+
return cleaned;
|
|
41066
|
+
};
|
|
41036
41067
|
const rebuildCell = (cellNode, rowIndex) => {
|
|
41037
|
-
|
|
41038
|
-
|
|
41039
|
-
|
|
41040
|
-
|
|
41041
|
-
|
|
41042
|
-
|
|
41043
|
-
|
|
41044
|
-
|
|
41045
|
-
|
|
41046
|
-
|
|
41047
|
-
|
|
41048
|
-
|
|
41049
|
-
|
|
41068
|
+
try {
|
|
41069
|
+
const updatedBlocks = cellNode.content.content.map((blockNode) => {
|
|
41070
|
+
if (blockNode.type !== ParaType) return blockNode;
|
|
41071
|
+
const updatedInlines = blockNode.content.content.map((inlineNode) => {
|
|
41072
|
+
if (inlineNode.type !== FieldType) return inlineNode;
|
|
41073
|
+
let matchedAnnotationValues = getAnnotationValue(inlineNode.attrs.fieldId, annotationValues);
|
|
41074
|
+
if (!Array.isArray(matchedAnnotationValues)) {
|
|
41075
|
+
matchedAnnotationValues = [matchedAnnotationValues];
|
|
41076
|
+
}
|
|
41077
|
+
const value = matchedAnnotationValues[rowIndex];
|
|
41078
|
+
let extraAttrs = {};
|
|
41079
|
+
try {
|
|
41080
|
+
const rawExtraAttrs = getFieldAttrs(inlineNode, value, null);
|
|
41081
|
+
extraAttrs = validateAttributes(rawExtraAttrs || {});
|
|
41082
|
+
} catch (error) {
|
|
41083
|
+
console.error("Error getting field attrs:", error);
|
|
41084
|
+
extraAttrs = {};
|
|
41085
|
+
}
|
|
41086
|
+
const baseAttrs = validateAttributes(inlineNode.attrs || {});
|
|
41087
|
+
const newAttrs = {
|
|
41088
|
+
...baseAttrs,
|
|
41089
|
+
...extraAttrs,
|
|
41090
|
+
generatorIndex: rowIndex
|
|
41091
|
+
};
|
|
41092
|
+
try {
|
|
41093
|
+
return FieldType.create(
|
|
41094
|
+
newAttrs,
|
|
41095
|
+
inlineNode.content || Fragment.empty,
|
|
41096
|
+
inlineNode.marks || []
|
|
41097
|
+
);
|
|
41098
|
+
} catch (error) {
|
|
41099
|
+
console.error("Error creating field node:", error);
|
|
41100
|
+
try {
|
|
41101
|
+
const fallbackAttrs = {
|
|
41102
|
+
...baseAttrs,
|
|
41103
|
+
generatorIndex: rowIndex,
|
|
41104
|
+
displayLabel: String(value || "")
|
|
41105
|
+
};
|
|
41106
|
+
return FieldType.create(
|
|
41107
|
+
validateAttributes(fallbackAttrs),
|
|
41108
|
+
inlineNode.content || Fragment.empty,
|
|
41109
|
+
inlineNode.marks || []
|
|
41110
|
+
);
|
|
41111
|
+
} catch (fallbackError) {
|
|
41112
|
+
console.error("Fallback also failed:", fallbackError);
|
|
41113
|
+
return inlineNode;
|
|
41114
|
+
}
|
|
41115
|
+
}
|
|
41116
|
+
});
|
|
41117
|
+
try {
|
|
41118
|
+
return ParaType.create(
|
|
41119
|
+
validateAttributes(blockNode.attrs || {}),
|
|
41120
|
+
Fragment.from(updatedInlines),
|
|
41121
|
+
blockNode.marks || []
|
|
41122
|
+
);
|
|
41123
|
+
} catch (error) {
|
|
41124
|
+
console.error("Error creating paragraph node:", error);
|
|
41125
|
+
return blockNode;
|
|
41126
|
+
}
|
|
41050
41127
|
});
|
|
41051
|
-
return
|
|
41052
|
-
|
|
41053
|
-
|
|
41128
|
+
return CellType.create(
|
|
41129
|
+
validateAttributes(cellNode.attrs || {}),
|
|
41130
|
+
Fragment.from(updatedBlocks),
|
|
41131
|
+
cellNode.marks || []
|
|
41132
|
+
);
|
|
41133
|
+
} catch (error) {
|
|
41134
|
+
console.error(`Failed to rebuild cell for row ${rowIndex}:`, error);
|
|
41135
|
+
throw error;
|
|
41136
|
+
}
|
|
41054
41137
|
};
|
|
41055
|
-
|
|
41056
|
-
const
|
|
41057
|
-
|
|
41058
|
-
|
|
41059
|
-
|
|
41138
|
+
try {
|
|
41139
|
+
const newRows = [];
|
|
41140
|
+
for (let rowIndex = 0; rowIndex < rowsToGenerate; rowIndex++) {
|
|
41141
|
+
const newCells = rowNode.content.content.map((cellNode) => rebuildCell(cellNode, rowIndex));
|
|
41142
|
+
const newRow = RowType.create(
|
|
41143
|
+
validateAttributes(rowNode.attrs || {}),
|
|
41144
|
+
Fragment.from(newCells),
|
|
41145
|
+
rowNode.marks || []
|
|
41146
|
+
);
|
|
41147
|
+
newRows.push(newRow);
|
|
41148
|
+
}
|
|
41149
|
+
const mappedRowStart = tr.mapping.map(absoluteRowStart);
|
|
41150
|
+
const rowEnd = mappedRowStart + rowNode.nodeSize;
|
|
41151
|
+
tr.replaceWith(mappedRowStart, rowEnd, Fragment.from(newRows));
|
|
41152
|
+
} catch (error) {
|
|
41153
|
+
console.error("Error during row generation:", error);
|
|
41154
|
+
throw error;
|
|
41060
41155
|
}
|
|
41061
|
-
const mappedDeleteStart = tr.mapping.map(absoluteRowStart);
|
|
41062
|
-
const mappedDeleteEnd = mappedDeleteStart + rowNode.nodeSize;
|
|
41063
|
-
tr.delete(mappedDeleteStart - 1, mappedDeleteEnd + 1);
|
|
41064
41156
|
};
|
|
41065
41157
|
const getAnnotationValue = (id, annotationValues) => {
|
|
41066
41158
|
return annotationValues.find((value) => value.input_id === id)?.input_value || null;
|
|
@@ -41719,7 +41811,9 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
41719
41811
|
// telemetry
|
|
41720
41812
|
telemetry: null,
|
|
41721
41813
|
// Docx xml updated by User
|
|
41722
|
-
customUpdatedFiles: {}
|
|
41814
|
+
customUpdatedFiles: {},
|
|
41815
|
+
isHeaderFooterChanged: false,
|
|
41816
|
+
isCustomXmlChanged: false
|
|
41723
41817
|
});
|
|
41724
41818
|
__privateMethod$1(this, _Editor_instances, initContainerElement_fn).call(this, options2);
|
|
41725
41819
|
__privateMethod$1(this, _Editor_instances, checkHeadless_fn).call(this, options2);
|
|
@@ -41737,6 +41831,13 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
41737
41831
|
this.setHighContrastMode = setHighContrastMode;
|
|
41738
41832
|
initMode();
|
|
41739
41833
|
}
|
|
41834
|
+
/**
|
|
41835
|
+
* Getter which indicates if any changes happen in Editor
|
|
41836
|
+
* @returns {boolean}
|
|
41837
|
+
*/
|
|
41838
|
+
get docChanged() {
|
|
41839
|
+
return this.options.isHeaderFooterChanged || this.options.isCustomXmlChanged || !this.options.initialState.doc.eq(this.state.doc);
|
|
41840
|
+
}
|
|
41740
41841
|
mount(el) {
|
|
41741
41842
|
__privateMethod$1(this, _Editor_instances, createView_fn).call(this, el);
|
|
41742
41843
|
window.setTimeout(() => {
|
|
@@ -42375,7 +42476,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
42375
42476
|
* @returns {Object | void} Migration results
|
|
42376
42477
|
*/
|
|
42377
42478
|
processCollaborationMigrations() {
|
|
42378
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.14.6-next.
|
|
42479
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.14.6-next.5");
|
|
42379
42480
|
if (!this.options.ydoc) return;
|
|
42380
42481
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
42381
42482
|
let docVersion = metaMap.get("version");
|
|
@@ -42457,6 +42558,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
42457
42558
|
const internalFileXml = this.converter.schemaToXml(updatedContent);
|
|
42458
42559
|
this.options.customUpdatedFiles[name] = String(internalFileXml);
|
|
42459
42560
|
}
|
|
42561
|
+
this.options.isCustomXmlChanged = true;
|
|
42460
42562
|
}
|
|
42461
42563
|
/**
|
|
42462
42564
|
* Get all nodes of a specific type
|
|
@@ -42743,10 +42845,11 @@ createView_fn = function(element) {
|
|
|
42743
42845
|
let doc2 = __privateMethod$1(this, _Editor_instances, generatePmData_fn).call(this);
|
|
42744
42846
|
const state2 = { schema: this.schema };
|
|
42745
42847
|
if (!this.options.ydoc) state2.doc = doc2;
|
|
42848
|
+
this.options.initialState = EditorState.create(state2);
|
|
42746
42849
|
this.view = new EditorView(element, {
|
|
42747
42850
|
...this.options.editorProps,
|
|
42748
42851
|
dispatchTransaction: __privateMethod$1(this, _Editor_instances, dispatchTransaction_fn).bind(this),
|
|
42749
|
-
state:
|
|
42852
|
+
state: this.options.initialState,
|
|
42750
42853
|
handleClick: __privateMethod$1(this, _Editor_instances, handleNodeSelection_fn).bind(this),
|
|
42751
42854
|
handleDoubleClick: async (view, pos, event) => {
|
|
42752
42855
|
if (this.options.documentMode !== "editing") return;
|
|
@@ -42786,6 +42889,7 @@ onCollaborationReady_fn = function({ editor, ydoc }) {
|
|
|
42786
42889
|
console.debug("🔗 [super-editor] Collaboration ready");
|
|
42787
42890
|
this.options.onCollaborationReady({ editor, ydoc });
|
|
42788
42891
|
this.options.collaborationIsReady = true;
|
|
42892
|
+
this.options.initialState = this.state;
|
|
42789
42893
|
const { tr } = this.state;
|
|
42790
42894
|
tr.setMeta("collaborationReady", true);
|
|
42791
42895
|
this.view.dispatch(tr);
|
|
@@ -24322,7 +24322,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
24322
24322
|
return;
|
|
24323
24323
|
}
|
|
24324
24324
|
}
|
|
24325
|
-
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.14.6-next.
|
|
24325
|
+
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.14.6-next.5") {
|
|
24326
24326
|
const customLocation = "docProps/custom.xml";
|
|
24327
24327
|
if (!docx[customLocation]) {
|
|
24328
24328
|
docx[customLocation] = generateCustomXml();
|
|
@@ -24798,7 +24798,7 @@ function storeSuperdocVersion(docx) {
|
|
|
24798
24798
|
function generateCustomXml() {
|
|
24799
24799
|
return DEFAULT_CUSTOM_XML;
|
|
24800
24800
|
}
|
|
24801
|
-
function generateSuperdocVersion(pid = 2, version2 = "0.14.6-next.
|
|
24801
|
+
function generateSuperdocVersion(pid = 2, version2 = "0.14.6-next.5") {
|
|
24802
24802
|
return {
|
|
24803
24803
|
type: "element",
|
|
24804
24804
|
name: "property",
|
|
@@ -40185,6 +40185,7 @@ const onHeaderFooterDataUpdate = async ({ editor, transaction }, mainEditor, sec
|
|
|
40185
40185
|
});
|
|
40186
40186
|
});
|
|
40187
40187
|
mainEditor.converter[`${type2}s`][sectionId] = updatedData;
|
|
40188
|
+
mainEditor.setOptions({ isHeaderFooterChanged: editor.docChanged });
|
|
40188
40189
|
await updateYdocDocxData(mainEditor);
|
|
40189
40190
|
};
|
|
40190
40191
|
const setEditorToolbar = ({ editor }, mainEditor) => {
|
|
@@ -41013,33 +41014,46 @@ const processTables = ({ state: state2, tr, annotationValues }) => {
|
|
|
41013
41014
|
tables.reverse().forEach(({ pos }) => {
|
|
41014
41015
|
const currentTableNode = tr.doc.nodeAt(pos);
|
|
41015
41016
|
if (!currentTableNode || currentTableNode.type.name !== "table") return;
|
|
41016
|
-
|
|
41017
|
+
try {
|
|
41018
|
+
generateTableIfNecessary({ tableNode: { node: currentTableNode, pos }, annotationValues, tr, state: state2 });
|
|
41019
|
+
} catch (error) {
|
|
41020
|
+
console.error("Error generating table at pos", pos, ":", error);
|
|
41021
|
+
}
|
|
41017
41022
|
});
|
|
41018
41023
|
return tr;
|
|
41019
41024
|
};
|
|
41020
41025
|
const generateTableIfNecessary = ({ tableNode, annotationValues, tr, state: state2 }) => {
|
|
41021
|
-
let rowNodeToGenerate = null;
|
|
41022
|
-
let currentRow = null;
|
|
41023
41026
|
const {
|
|
41024
41027
|
tableRow: RowType,
|
|
41025
41028
|
tableCell: CellType,
|
|
41026
41029
|
fieldAnnotation: FieldType,
|
|
41027
41030
|
paragraph: ParaType
|
|
41028
41031
|
} = state2.schema.nodes;
|
|
41032
|
+
const rows = [];
|
|
41029
41033
|
tableNode.node.descendants((node2, pos) => {
|
|
41030
|
-
if (
|
|
41031
|
-
|
|
41032
|
-
if (node2.type === FieldType) {
|
|
41033
|
-
const annotationValue = getAnnotationValue(node2.attrs.fieldId, annotationValues);
|
|
41034
|
-
if (Array.isArray(annotationValue) && node2.attrs.generatorIndex === null) {
|
|
41035
|
-
rowNodeToGenerate = currentRow;
|
|
41036
|
-
}
|
|
41034
|
+
if (node2.type === RowType) {
|
|
41035
|
+
rows.push({ node: node2, pos });
|
|
41037
41036
|
}
|
|
41038
41037
|
});
|
|
41038
|
+
let rowNodeToGenerate = null;
|
|
41039
|
+
for (const row of rows) {
|
|
41040
|
+
let hasArrayAnnotation = false;
|
|
41041
|
+
row.node.descendants((node2, pos) => {
|
|
41042
|
+
if (node2.type === FieldType) {
|
|
41043
|
+
const annotationValue = getAnnotationValue(node2.attrs.fieldId, annotationValues);
|
|
41044
|
+
if (Array.isArray(annotationValue) && node2.attrs.generatorIndex === null) {
|
|
41045
|
+
hasArrayAnnotation = true;
|
|
41046
|
+
}
|
|
41047
|
+
}
|
|
41048
|
+
});
|
|
41049
|
+
if (hasArrayAnnotation) {
|
|
41050
|
+
rowNodeToGenerate = row;
|
|
41051
|
+
break;
|
|
41052
|
+
}
|
|
41053
|
+
}
|
|
41039
41054
|
if (!rowNodeToGenerate) return;
|
|
41040
41055
|
const { node: rowNode, pos: rowStartPos } = rowNodeToGenerate;
|
|
41041
|
-
const absoluteRowStart =
|
|
41042
|
-
const absoluteRowEnd = absoluteRowStart + rowNode.nodeSize;
|
|
41056
|
+
const absoluteRowStart = tableNode.pos + 1 + rowStartPos;
|
|
41043
41057
|
let rowsToGenerate = 0;
|
|
41044
41058
|
rowNode.descendants((childNode, childPos) => {
|
|
41045
41059
|
if (childNode.type === FieldType) {
|
|
@@ -41050,34 +41064,112 @@ const generateTableIfNecessary = ({ tableNode, annotationValues, tr, state: stat
|
|
|
41050
41064
|
}
|
|
41051
41065
|
});
|
|
41052
41066
|
if (rowsToGenerate <= 1) return;
|
|
41067
|
+
const validateAttributes = (attrs) => {
|
|
41068
|
+
const cleaned = {};
|
|
41069
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
41070
|
+
if (value !== void 0 && value !== null) {
|
|
41071
|
+
if (key === "displayLabel") {
|
|
41072
|
+
cleaned[key] = String(value);
|
|
41073
|
+
} else if (key === "rawHtml" || key === "linkUrl" || key === "imageSrc") {
|
|
41074
|
+
cleaned[key] = String(value);
|
|
41075
|
+
} else if (typeof value === "string" && value.length > 0) {
|
|
41076
|
+
cleaned[key] = value;
|
|
41077
|
+
} else if (typeof value !== "string") {
|
|
41078
|
+
cleaned[key] = value;
|
|
41079
|
+
}
|
|
41080
|
+
}
|
|
41081
|
+
}
|
|
41082
|
+
return cleaned;
|
|
41083
|
+
};
|
|
41053
41084
|
const rebuildCell = (cellNode, rowIndex) => {
|
|
41054
|
-
|
|
41055
|
-
|
|
41056
|
-
|
|
41057
|
-
|
|
41058
|
-
|
|
41059
|
-
|
|
41060
|
-
|
|
41061
|
-
|
|
41062
|
-
|
|
41063
|
-
|
|
41064
|
-
|
|
41065
|
-
|
|
41066
|
-
|
|
41085
|
+
try {
|
|
41086
|
+
const updatedBlocks = cellNode.content.content.map((blockNode) => {
|
|
41087
|
+
if (blockNode.type !== ParaType) return blockNode;
|
|
41088
|
+
const updatedInlines = blockNode.content.content.map((inlineNode) => {
|
|
41089
|
+
if (inlineNode.type !== FieldType) return inlineNode;
|
|
41090
|
+
let matchedAnnotationValues = getAnnotationValue(inlineNode.attrs.fieldId, annotationValues);
|
|
41091
|
+
if (!Array.isArray(matchedAnnotationValues)) {
|
|
41092
|
+
matchedAnnotationValues = [matchedAnnotationValues];
|
|
41093
|
+
}
|
|
41094
|
+
const value = matchedAnnotationValues[rowIndex];
|
|
41095
|
+
let extraAttrs = {};
|
|
41096
|
+
try {
|
|
41097
|
+
const rawExtraAttrs = getFieldAttrs(inlineNode, value, null);
|
|
41098
|
+
extraAttrs = validateAttributes(rawExtraAttrs || {});
|
|
41099
|
+
} catch (error) {
|
|
41100
|
+
console.error("Error getting field attrs:", error);
|
|
41101
|
+
extraAttrs = {};
|
|
41102
|
+
}
|
|
41103
|
+
const baseAttrs = validateAttributes(inlineNode.attrs || {});
|
|
41104
|
+
const newAttrs = {
|
|
41105
|
+
...baseAttrs,
|
|
41106
|
+
...extraAttrs,
|
|
41107
|
+
generatorIndex: rowIndex
|
|
41108
|
+
};
|
|
41109
|
+
try {
|
|
41110
|
+
return FieldType.create(
|
|
41111
|
+
newAttrs,
|
|
41112
|
+
inlineNode.content || Fragment.empty,
|
|
41113
|
+
inlineNode.marks || []
|
|
41114
|
+
);
|
|
41115
|
+
} catch (error) {
|
|
41116
|
+
console.error("Error creating field node:", error);
|
|
41117
|
+
try {
|
|
41118
|
+
const fallbackAttrs = {
|
|
41119
|
+
...baseAttrs,
|
|
41120
|
+
generatorIndex: rowIndex,
|
|
41121
|
+
displayLabel: String(value || "")
|
|
41122
|
+
};
|
|
41123
|
+
return FieldType.create(
|
|
41124
|
+
validateAttributes(fallbackAttrs),
|
|
41125
|
+
inlineNode.content || Fragment.empty,
|
|
41126
|
+
inlineNode.marks || []
|
|
41127
|
+
);
|
|
41128
|
+
} catch (fallbackError) {
|
|
41129
|
+
console.error("Fallback also failed:", fallbackError);
|
|
41130
|
+
return inlineNode;
|
|
41131
|
+
}
|
|
41132
|
+
}
|
|
41133
|
+
});
|
|
41134
|
+
try {
|
|
41135
|
+
return ParaType.create(
|
|
41136
|
+
validateAttributes(blockNode.attrs || {}),
|
|
41137
|
+
Fragment.from(updatedInlines),
|
|
41138
|
+
blockNode.marks || []
|
|
41139
|
+
);
|
|
41140
|
+
} catch (error) {
|
|
41141
|
+
console.error("Error creating paragraph node:", error);
|
|
41142
|
+
return blockNode;
|
|
41143
|
+
}
|
|
41067
41144
|
});
|
|
41068
|
-
return
|
|
41069
|
-
|
|
41070
|
-
|
|
41145
|
+
return CellType.create(
|
|
41146
|
+
validateAttributes(cellNode.attrs || {}),
|
|
41147
|
+
Fragment.from(updatedBlocks),
|
|
41148
|
+
cellNode.marks || []
|
|
41149
|
+
);
|
|
41150
|
+
} catch (error) {
|
|
41151
|
+
console.error(`Failed to rebuild cell for row ${rowIndex}:`, error);
|
|
41152
|
+
throw error;
|
|
41153
|
+
}
|
|
41071
41154
|
};
|
|
41072
|
-
|
|
41073
|
-
const
|
|
41074
|
-
|
|
41075
|
-
|
|
41076
|
-
|
|
41155
|
+
try {
|
|
41156
|
+
const newRows = [];
|
|
41157
|
+
for (let rowIndex = 0; rowIndex < rowsToGenerate; rowIndex++) {
|
|
41158
|
+
const newCells = rowNode.content.content.map((cellNode) => rebuildCell(cellNode, rowIndex));
|
|
41159
|
+
const newRow = RowType.create(
|
|
41160
|
+
validateAttributes(rowNode.attrs || {}),
|
|
41161
|
+
Fragment.from(newCells),
|
|
41162
|
+
rowNode.marks || []
|
|
41163
|
+
);
|
|
41164
|
+
newRows.push(newRow);
|
|
41165
|
+
}
|
|
41166
|
+
const mappedRowStart = tr.mapping.map(absoluteRowStart);
|
|
41167
|
+
const rowEnd = mappedRowStart + rowNode.nodeSize;
|
|
41168
|
+
tr.replaceWith(mappedRowStart, rowEnd, Fragment.from(newRows));
|
|
41169
|
+
} catch (error) {
|
|
41170
|
+
console.error("Error during row generation:", error);
|
|
41171
|
+
throw error;
|
|
41077
41172
|
}
|
|
41078
|
-
const mappedDeleteStart = tr.mapping.map(absoluteRowStart);
|
|
41079
|
-
const mappedDeleteEnd = mappedDeleteStart + rowNode.nodeSize;
|
|
41080
|
-
tr.delete(mappedDeleteStart - 1, mappedDeleteEnd + 1);
|
|
41081
41173
|
};
|
|
41082
41174
|
const getAnnotationValue = (id, annotationValues) => {
|
|
41083
41175
|
return annotationValues.find((value) => value.input_id === id)?.input_value || null;
|
|
@@ -41736,7 +41828,9 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
41736
41828
|
// telemetry
|
|
41737
41829
|
telemetry: null,
|
|
41738
41830
|
// Docx xml updated by User
|
|
41739
|
-
customUpdatedFiles: {}
|
|
41831
|
+
customUpdatedFiles: {},
|
|
41832
|
+
isHeaderFooterChanged: false,
|
|
41833
|
+
isCustomXmlChanged: false
|
|
41740
41834
|
});
|
|
41741
41835
|
__privateMethod$1(this, _Editor_instances, initContainerElement_fn).call(this, options2);
|
|
41742
41836
|
__privateMethod$1(this, _Editor_instances, checkHeadless_fn).call(this, options2);
|
|
@@ -41754,6 +41848,13 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
41754
41848
|
this.setHighContrastMode = setHighContrastMode;
|
|
41755
41849
|
initMode();
|
|
41756
41850
|
}
|
|
41851
|
+
/**
|
|
41852
|
+
* Getter which indicates if any changes happen in Editor
|
|
41853
|
+
* @returns {boolean}
|
|
41854
|
+
*/
|
|
41855
|
+
get docChanged() {
|
|
41856
|
+
return this.options.isHeaderFooterChanged || this.options.isCustomXmlChanged || !this.options.initialState.doc.eq(this.state.doc);
|
|
41857
|
+
}
|
|
41757
41858
|
mount(el) {
|
|
41758
41859
|
__privateMethod$1(this, _Editor_instances, createView_fn).call(this, el);
|
|
41759
41860
|
window.setTimeout(() => {
|
|
@@ -42392,7 +42493,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
42392
42493
|
* @returns {Object | void} Migration results
|
|
42393
42494
|
*/
|
|
42394
42495
|
processCollaborationMigrations() {
|
|
42395
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.14.6-next.
|
|
42496
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.14.6-next.5");
|
|
42396
42497
|
if (!this.options.ydoc) return;
|
|
42397
42498
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
42398
42499
|
let docVersion = metaMap.get("version");
|
|
@@ -42474,6 +42575,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
42474
42575
|
const internalFileXml = this.converter.schemaToXml(updatedContent);
|
|
42475
42576
|
this.options.customUpdatedFiles[name] = String(internalFileXml);
|
|
42476
42577
|
}
|
|
42578
|
+
this.options.isCustomXmlChanged = true;
|
|
42477
42579
|
}
|
|
42478
42580
|
/**
|
|
42479
42581
|
* Get all nodes of a specific type
|
|
@@ -42760,10 +42862,11 @@ createView_fn = function(element) {
|
|
|
42760
42862
|
let doc2 = __privateMethod$1(this, _Editor_instances, generatePmData_fn).call(this);
|
|
42761
42863
|
const state2 = { schema: this.schema };
|
|
42762
42864
|
if (!this.options.ydoc) state2.doc = doc2;
|
|
42865
|
+
this.options.initialState = EditorState.create(state2);
|
|
42763
42866
|
this.view = new EditorView(element, {
|
|
42764
42867
|
...this.options.editorProps,
|
|
42765
42868
|
dispatchTransaction: __privateMethod$1(this, _Editor_instances, dispatchTransaction_fn).bind(this),
|
|
42766
|
-
state:
|
|
42869
|
+
state: this.options.initialState,
|
|
42767
42870
|
handleClick: __privateMethod$1(this, _Editor_instances, handleNodeSelection_fn).bind(this),
|
|
42768
42871
|
handleDoubleClick: async (view, pos, event) => {
|
|
42769
42872
|
if (this.options.documentMode !== "editing") return;
|
|
@@ -42803,6 +42906,7 @@ onCollaborationReady_fn = function({ editor, ydoc }) {
|
|
|
42803
42906
|
console.debug("🔗 [super-editor] Collaboration ready");
|
|
42804
42907
|
this.options.onCollaborationReady({ editor, ydoc });
|
|
42805
42908
|
this.options.collaborationIsReady = true;
|
|
42909
|
+
this.options.initialState = this.state;
|
|
42806
42910
|
const { tr } = this.state;
|
|
42807
42911
|
tr.setMeta("collaborationReady", true);
|
|
42808
42912
|
this.view.dispatch(tr);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const jszip = require("./jszip-D5XoMX4C.cjs");
|
|
3
|
-
const xmlJs = require("./xml-js-
|
|
3
|
+
const xmlJs = require("./xml-js-BHJlXtfU.cjs");
|
|
4
4
|
const __viteBrowserExternal = require("./__vite-browser-external-DWbQq7bv.cjs");
|
|
5
5
|
var punycode$1 = { exports: {} };
|
|
6
6
|
/*! https://mths.be/punycode v1.4.1 by @mathias */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as commonjsGlobal, g as getDefaultExportFromCjs, a as getAugmentedNamespace } from "./jszip-CYDYUNnI.es.js";
|
|
2
|
-
import { t as type, g as getIntrinsic, c as callBound$2 } from "./xml-js-
|
|
2
|
+
import { t as type, g as getIntrinsic, c as callBound$2 } from "./xml-js-DNISVjNF.es.js";
|
|
3
3
|
import { _ as __viteBrowserExternal } from "./__vite-browser-external-CURh0WXD.es.js";
|
|
4
4
|
var punycode$1 = { exports: {} };
|
|
5
5
|
/*! https://mths.be/punycode v1.4.1 by @mathias */
|
|
@@ -515,8 +515,15 @@ function requireHasSymbols() {
|
|
|
515
515
|
return hasSymbols$1;
|
|
516
516
|
}
|
|
517
517
|
var Reflect_getPrototypeOf = typeof Reflect !== "undefined" && Reflect.getPrototypeOf || null;
|
|
518
|
-
var
|
|
519
|
-
var
|
|
518
|
+
var Object_getPrototypeOf;
|
|
519
|
+
var hasRequiredObject_getPrototypeOf;
|
|
520
|
+
function requireObject_getPrototypeOf() {
|
|
521
|
+
if (hasRequiredObject_getPrototypeOf) return Object_getPrototypeOf;
|
|
522
|
+
hasRequiredObject_getPrototypeOf = 1;
|
|
523
|
+
var $Object2 = esObjectAtoms;
|
|
524
|
+
Object_getPrototypeOf = $Object2.getPrototypeOf || null;
|
|
525
|
+
return Object_getPrototypeOf;
|
|
526
|
+
}
|
|
520
527
|
var implementation;
|
|
521
528
|
var hasRequiredImplementation;
|
|
522
529
|
function requireImplementation() {
|
|
@@ -659,7 +666,7 @@ var get = desc && typeof desc.get === "function" ? callBind$2([desc.get]) : type
|
|
|
659
666
|
}
|
|
660
667
|
) : false;
|
|
661
668
|
var reflectGetProto = Reflect_getPrototypeOf;
|
|
662
|
-
var originalGetProto =
|
|
669
|
+
var originalGetProto = requireObject_getPrototypeOf();
|
|
663
670
|
var getDunderProto = get;
|
|
664
671
|
var getProto$3 = reflectGetProto ? function getProto(O) {
|
|
665
672
|
return reflectGetProto(O);
|
|
@@ -724,7 +731,7 @@ var ThrowTypeError = $gOPD ? function() {
|
|
|
724
731
|
}() : throwTypeError;
|
|
725
732
|
var hasSymbols2 = requireHasSymbols()();
|
|
726
733
|
var getProto$2 = getProto$3;
|
|
727
|
-
var $ObjectGPO =
|
|
734
|
+
var $ObjectGPO = requireObject_getPrototypeOf();
|
|
728
735
|
var $ReflectGPO = Reflect_getPrototypeOf;
|
|
729
736
|
var $apply$1 = requireFunctionApply();
|
|
730
737
|
var $call = requireFunctionCall();
|