superdoc 0.31.0-next.4 → 0.31.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-CMqo3BcJ.cjs → PdfViewer-BSud7RY4.cjs} +1 -1
- package/dist/chunks/{PdfViewer-mTeXBeGP.es.js → PdfViewer-DK93vPf1.es.js} +1 -1
- package/dist/chunks/{index-INrjzFwK.es.js → index-Bz2Q2Xq2.es.js} +3 -3
- package/dist/chunks/{index-BtYu5_4F.cjs → index-Crequs_q.cjs} +3 -3
- package/dist/chunks/{index-BmNdb0G--hU1qknba.es.js → index-DAES86tg-BDL6WVta.es.js} +1 -1
- package/dist/chunks/{index-BmNdb0G--CqIBE8k-.cjs → index-DAES86tg-Cjexh3WM.cjs} +1 -1
- package/dist/chunks/{super-editor.es-DUqAKtdo.es.js → super-editor.es-BWeMHRHm.es.js} +228 -239
- package/dist/chunks/{super-editor.es-_Mo5sfTs.cjs → super-editor.es-D8NdQdlk.cjs} +228 -239
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-BsxkbtGe.js → converter-DEQxlCAJ.js} +194 -235
- package/dist/super-editor/chunks/{docx-zipper-DzOHQzzj.js → docx-zipper-C6VMEIY_.js} +1 -1
- package/dist/super-editor/chunks/{editor-o3FNUBVU.js → editor-D0zFmUwx.js} +36 -6
- package/dist/super-editor/chunks/{index-BmNdb0G-.js → index-DAES86tg.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-CbCPJP6P.js → toolbar-Cwx5bBDV.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/super-editor/src/core/super-converter/exporter.d.ts +0 -48
- package/dist/super-editor/super-editor/src/core/super-converter/exporter.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/generate-paragraph-properties.d.ts +8 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/generate-paragraph-properties.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/translate-paragraph-node.d.ts +8 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/translate-paragraph-node.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/convert-sdt-content-to-runs.d.ts +7 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/convert-sdt-content-to-runs.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/translate-field-annotation.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/t/helpers/translate-text-node.d.ts +5 -0
- package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/w/t/helpers/translate-text-node.d.ts.map +1 -0
- package/dist/super-editor/super-editor/src/extensions/linked-styles/helpers.d.ts +1 -0
- package/dist/super-editor/super-editor/src/extensions/linked-styles/helpers.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/linked-styles/plugin.d.ts.map +1 -1
- package/dist/super-editor/super-editor/src/extensions/paragraph/paragraph.d.ts.map +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 +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +230 -241
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -15409,19 +15409,6 @@ const hasSomeParentWithClass = (element, classname) => {
|
|
|
15409
15409
|
if (element.className?.split(" ")?.indexOf(classname) >= 0) return true;
|
|
15410
15410
|
return element.parentNode && hasSomeParentWithClass(element.parentNode, classname);
|
|
15411
15411
|
};
|
|
15412
|
-
function generateDocxRandomId(length2 = 8) {
|
|
15413
|
-
const max2 = 2147483647;
|
|
15414
|
-
const value = Math.floor(Math.random() * (max2 + 1));
|
|
15415
|
-
return value.toString(16).padStart(length2, "0").slice(0, length2);
|
|
15416
|
-
}
|
|
15417
|
-
function generateRandomSigned32BitIntStrId() {
|
|
15418
|
-
const val = Math.floor(Math.random() * 2147483647);
|
|
15419
|
-
return val.toString();
|
|
15420
|
-
}
|
|
15421
|
-
function generateRandom32BitHex() {
|
|
15422
|
-
const val = Math.floor(Math.random() * 2147483647);
|
|
15423
|
-
return val.toString(16).toUpperCase().padStart(8, "0");
|
|
15424
|
-
}
|
|
15425
15412
|
const DEFAULT_DOCX_DEFS = {
|
|
15426
15413
|
"xmlns:wpc": "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
|
|
15427
15414
|
"xmlns:cx": "http://schemas.microsoft.com/office/drawing/2014/chartex",
|
|
@@ -16627,15 +16614,6 @@ const COMMENTS_XML_DEFINITIONS = {
|
|
|
16627
16614
|
DOCUMENT_RELS_XML_DEF,
|
|
16628
16615
|
CONTENT_TYPES
|
|
16629
16616
|
};
|
|
16630
|
-
const carbonCopy = (obj) => {
|
|
16631
|
-
if (!obj) return void 0;
|
|
16632
|
-
try {
|
|
16633
|
-
return JSON.parse(JSON.stringify(obj));
|
|
16634
|
-
} catch (e) {
|
|
16635
|
-
console.error("Error in carbonCopy", obj, e);
|
|
16636
|
-
return void 0;
|
|
16637
|
-
}
|
|
16638
|
-
};
|
|
16639
16617
|
function translateChildNodes(params2) {
|
|
16640
16618
|
const { content: nodes } = params2.node;
|
|
16641
16619
|
if (!nodes) return [];
|
|
@@ -18243,6 +18221,15 @@ const config$n = {
|
|
|
18243
18221
|
attributes: validXmlAttributes$h
|
|
18244
18222
|
};
|
|
18245
18223
|
const translator$21 = NodeTranslator.from(config$n);
|
|
18224
|
+
const carbonCopy = (obj) => {
|
|
18225
|
+
if (!obj) return void 0;
|
|
18226
|
+
try {
|
|
18227
|
+
return JSON.parse(JSON.stringify(obj));
|
|
18228
|
+
} catch (e) {
|
|
18229
|
+
console.error("Error in carbonCopy", obj, e);
|
|
18230
|
+
return void 0;
|
|
18231
|
+
}
|
|
18232
|
+
};
|
|
18246
18233
|
const mergeTextNodes = (nodes) => {
|
|
18247
18234
|
if (!nodes || !Array.isArray(nodes)) {
|
|
18248
18235
|
return nodes;
|
|
@@ -20076,6 +20063,56 @@ const handleParagraphNode$1 = (params2) => {
|
|
|
20076
20063
|
}
|
|
20077
20064
|
return schemaNode;
|
|
20078
20065
|
};
|
|
20066
|
+
function generateParagraphProperties(params2) {
|
|
20067
|
+
const { node } = params2;
|
|
20068
|
+
const { attrs = {} } = node;
|
|
20069
|
+
const paragraphProperties = carbonCopy(attrs.paragraphProperties || {});
|
|
20070
|
+
if (attrs.styleId !== paragraphProperties.styleId) {
|
|
20071
|
+
paragraphProperties.styleId = attrs.styleId;
|
|
20072
|
+
}
|
|
20073
|
+
["borders", "styleId", "indent", "textAlign", "keepLines", "keepNext", "spacing", "tabStops"].forEach((key2) => {
|
|
20074
|
+
let propKey = key2 === "textAlign" ? "justification" : key2;
|
|
20075
|
+
if (JSON.stringify(paragraphProperties[propKey]) !== JSON.stringify(attrs[key2])) {
|
|
20076
|
+
paragraphProperties[propKey] = attrs[key2];
|
|
20077
|
+
}
|
|
20078
|
+
});
|
|
20079
|
+
const framePr = attrs.dropcap;
|
|
20080
|
+
if (framePr) {
|
|
20081
|
+
framePr.dropCap = framePr.type;
|
|
20082
|
+
delete framePr.type;
|
|
20083
|
+
}
|
|
20084
|
+
if (JSON.stringify(paragraphProperties.framePr) !== JSON.stringify(framePr)) {
|
|
20085
|
+
paragraphProperties.framePr = framePr;
|
|
20086
|
+
}
|
|
20087
|
+
const marksProps = decodeRPrFromMarks(attrs.marksAttrs || []);
|
|
20088
|
+
const finalRunProps = combineRunProperties([paragraphProperties.runProperties || {}, marksProps]);
|
|
20089
|
+
paragraphProperties.runProperties = finalRunProps;
|
|
20090
|
+
const pPr = translator$12.decode({ node: { ...node, attrs: { paragraphProperties } } });
|
|
20091
|
+
const sectPr = node.attrs?.paragraphProperties?.sectPr;
|
|
20092
|
+
if (sectPr) {
|
|
20093
|
+
pPr.elements.push(sectPr);
|
|
20094
|
+
}
|
|
20095
|
+
return pPr;
|
|
20096
|
+
}
|
|
20097
|
+
function translateParagraphNode(params2) {
|
|
20098
|
+
const elements = translateChildNodes(params2);
|
|
20099
|
+
const htmlAnnotationChild = elements.find((element) => element.name === "htmlAnnotation");
|
|
20100
|
+
if (htmlAnnotationChild) {
|
|
20101
|
+
return htmlAnnotationChild.elements;
|
|
20102
|
+
}
|
|
20103
|
+
const pPr = generateParagraphProperties(params2);
|
|
20104
|
+
if (pPr) elements.unshift(pPr);
|
|
20105
|
+
let attributes = {};
|
|
20106
|
+
if (params2.node.attrs?.rsidRDefault) {
|
|
20107
|
+
attributes["w:rsidRDefault"] = params2.node.attrs.rsidRDefault;
|
|
20108
|
+
}
|
|
20109
|
+
const result = {
|
|
20110
|
+
name: "w:p",
|
|
20111
|
+
elements,
|
|
20112
|
+
attributes
|
|
20113
|
+
};
|
|
20114
|
+
return result;
|
|
20115
|
+
}
|
|
20079
20116
|
const encode$A = (attributes) => {
|
|
20080
20117
|
return attributes["w:rsidDel"];
|
|
20081
20118
|
};
|
|
@@ -20355,6 +20392,19 @@ const ensureTrackedWrapper = (runs, trackingMarksByType = /* @__PURE__ */ new Ma
|
|
|
20355
20392
|
}
|
|
20356
20393
|
return runs;
|
|
20357
20394
|
};
|
|
20395
|
+
function generateDocxRandomId(length2 = 8) {
|
|
20396
|
+
const max2 = 2147483647;
|
|
20397
|
+
const value = Math.floor(Math.random() * (max2 + 1));
|
|
20398
|
+
return value.toString(16).padStart(length2, "0").slice(0, length2);
|
|
20399
|
+
}
|
|
20400
|
+
function generateRandomSigned32BitIntStrId() {
|
|
20401
|
+
const val = Math.floor(Math.random() * 2147483647);
|
|
20402
|
+
return val.toString();
|
|
20403
|
+
}
|
|
20404
|
+
function generateRandom32BitHex() {
|
|
20405
|
+
const val = Math.floor(Math.random() * 2147483647);
|
|
20406
|
+
return val.toString(16).toUpperCase().padStart(8, "0");
|
|
20407
|
+
}
|
|
20358
20408
|
const XML_NODE_NAME$j = "w:hyperlink";
|
|
20359
20409
|
const SD_NODE_NAME$g = "link";
|
|
20360
20410
|
const _createAttributeHandler = (xmlName, sdName) => ({
|
|
@@ -20451,13 +20501,13 @@ function _addNewLinkRelationship(params2, link) {
|
|
|
20451
20501
|
type: "element",
|
|
20452
20502
|
name: "Relationship",
|
|
20453
20503
|
attributes: {
|
|
20454
|
-
Id: id
|
|
20504
|
+
Id: `rId${id}`,
|
|
20455
20505
|
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
|
|
20456
20506
|
Target: link,
|
|
20457
20507
|
TargetMode: "External"
|
|
20458
20508
|
}
|
|
20459
20509
|
});
|
|
20460
|
-
return id
|
|
20510
|
+
return `rId${id}`;
|
|
20461
20511
|
}
|
|
20462
20512
|
const config$i = {
|
|
20463
20513
|
xmlName: XML_NODE_NAME$j,
|
|
@@ -30471,6 +30521,59 @@ const config$c = {
|
|
|
30471
30521
|
attributes: validXmlAttributes$6
|
|
30472
30522
|
};
|
|
30473
30523
|
const translator$s = NodeTranslator.from(config$c);
|
|
30524
|
+
function getTextNodeForExport(text, marks, params2) {
|
|
30525
|
+
const hasLeadingOrTrailingSpace = /^\s|\s$/.test(text);
|
|
30526
|
+
const space = hasLeadingOrTrailingSpace ? "preserve" : null;
|
|
30527
|
+
const nodeAttrs = space ? { "xml:space": space } : null;
|
|
30528
|
+
const textNodes = [];
|
|
30529
|
+
const textRunProperties = decodeRPrFromMarks(marks || []);
|
|
30530
|
+
const parentRunProperties = params2.extraParams?.runProperties || {};
|
|
30531
|
+
const combinedRunProperties = combineRunProperties([parentRunProperties, textRunProperties]);
|
|
30532
|
+
const rPrNode = translator$1N.decode({ node: { attrs: { runProperties: combinedRunProperties } } });
|
|
30533
|
+
textNodes.push({
|
|
30534
|
+
name: "w:t",
|
|
30535
|
+
elements: [{ text, type: "text" }],
|
|
30536
|
+
attributes: nodeAttrs
|
|
30537
|
+
});
|
|
30538
|
+
if (params2) {
|
|
30539
|
+
const { editor } = params2;
|
|
30540
|
+
const customMarks = editor.extensionService.extensions.filter((e) => e.isExternal === true);
|
|
30541
|
+
marks.forEach((mark) => {
|
|
30542
|
+
const isCustomMark = customMarks.some((customMark) => {
|
|
30543
|
+
const customMarkName = customMark.name;
|
|
30544
|
+
return mark.type === customMarkName;
|
|
30545
|
+
});
|
|
30546
|
+
if (!isCustomMark) return;
|
|
30547
|
+
let attrsString = "";
|
|
30548
|
+
Object.entries(mark.attrs).forEach(([key2, value]) => {
|
|
30549
|
+
if (value) {
|
|
30550
|
+
attrsString += `${key2}=${value};`;
|
|
30551
|
+
}
|
|
30552
|
+
});
|
|
30553
|
+
if (isCustomMark) {
|
|
30554
|
+
textNodes.unshift({
|
|
30555
|
+
type: "element",
|
|
30556
|
+
name: "w:bookmarkStart",
|
|
30557
|
+
attributes: {
|
|
30558
|
+
"w:id": "5000",
|
|
30559
|
+
"w:name": mark.type + ";" + attrsString
|
|
30560
|
+
}
|
|
30561
|
+
});
|
|
30562
|
+
textNodes.push({
|
|
30563
|
+
type: "element",
|
|
30564
|
+
name: "w:bookmarkEnd",
|
|
30565
|
+
attributes: {
|
|
30566
|
+
"w:id": "5000"
|
|
30567
|
+
}
|
|
30568
|
+
});
|
|
30569
|
+
}
|
|
30570
|
+
});
|
|
30571
|
+
}
|
|
30572
|
+
return {
|
|
30573
|
+
name: "w:r",
|
|
30574
|
+
elements: rPrNode ? [rPrNode, ...textNodes] : textNodes
|
|
30575
|
+
};
|
|
30576
|
+
}
|
|
30474
30577
|
var he$2 = { exports: {} };
|
|
30475
30578
|
/*! https://mths.be/he v1.2.0 by @mathias | MIT license */
|
|
30476
30579
|
var he$1 = he$2.exports;
|
|
@@ -30877,18 +30980,31 @@ function prepareUrlAnnotation(params2) {
|
|
|
30877
30980
|
node: { attrs = {}, marks = [] }
|
|
30878
30981
|
} = params2;
|
|
30879
30982
|
if (!attrs.linkUrl) return prepareTextAnnotation(params2);
|
|
30880
|
-
const
|
|
30881
|
-
|
|
30882
|
-
|
|
30883
|
-
|
|
30884
|
-
|
|
30885
|
-
|
|
30886
|
-
|
|
30887
|
-
|
|
30888
|
-
|
|
30889
|
-
|
|
30890
|
-
|
|
30983
|
+
const linkTextNode = {
|
|
30984
|
+
type: "text",
|
|
30985
|
+
text: attrs.linkUrl,
|
|
30986
|
+
marks: [
|
|
30987
|
+
...marks,
|
|
30988
|
+
{
|
|
30989
|
+
type: "link",
|
|
30990
|
+
attrs: {
|
|
30991
|
+
href: attrs.linkUrl,
|
|
30992
|
+
history: true,
|
|
30993
|
+
text: attrs.linkUrl
|
|
30994
|
+
}
|
|
30995
|
+
},
|
|
30996
|
+
{
|
|
30997
|
+
type: "textStyle",
|
|
30998
|
+
attrs: {
|
|
30999
|
+
color: "#467886"
|
|
31000
|
+
}
|
|
31001
|
+
}
|
|
31002
|
+
]
|
|
30891
31003
|
};
|
|
31004
|
+
return translator$10.decode({
|
|
31005
|
+
...params2,
|
|
31006
|
+
node: linkTextNode
|
|
31007
|
+
});
|
|
30892
31008
|
}
|
|
30893
31009
|
function translateFieldAttrsToMarks(attrs = {}) {
|
|
30894
31010
|
const { fontFamily: fontFamily2, fontSize: fontSize2, bold, underline, italic, textColor, textHighlight } = attrs;
|
|
@@ -31081,6 +31197,46 @@ function translateDocumentPartObj(params2) {
|
|
|
31081
31197
|
};
|
|
31082
31198
|
return result;
|
|
31083
31199
|
}
|
|
31200
|
+
const RUN_LEVEL_WRAPPERS = /* @__PURE__ */ new Set(["w:hyperlink", "w:ins", "w:del"]);
|
|
31201
|
+
function convertSdtContentToRuns(elements) {
|
|
31202
|
+
const normalized = Array.isArray(elements) ? elements : [elements];
|
|
31203
|
+
const runs = [];
|
|
31204
|
+
normalized.forEach((element) => {
|
|
31205
|
+
if (!element) return;
|
|
31206
|
+
if (element.name === "w:sdtPr") {
|
|
31207
|
+
return;
|
|
31208
|
+
}
|
|
31209
|
+
if (element.name === "w:r") {
|
|
31210
|
+
runs.push(element);
|
|
31211
|
+
return;
|
|
31212
|
+
}
|
|
31213
|
+
if (element.name === "w:sdt") {
|
|
31214
|
+
const sdtContent = (element.elements || []).find((child) => child?.name === "w:sdtContent");
|
|
31215
|
+
if (sdtContent?.elements) {
|
|
31216
|
+
runs.push(...convertSdtContentToRuns(sdtContent.elements));
|
|
31217
|
+
}
|
|
31218
|
+
return;
|
|
31219
|
+
}
|
|
31220
|
+
if (RUN_LEVEL_WRAPPERS.has(element.name)) {
|
|
31221
|
+
const wrapperElements = convertSdtContentToRuns(element.elements || []);
|
|
31222
|
+
if (wrapperElements.length) {
|
|
31223
|
+
runs.push({
|
|
31224
|
+
...element,
|
|
31225
|
+
elements: wrapperElements
|
|
31226
|
+
});
|
|
31227
|
+
}
|
|
31228
|
+
return;
|
|
31229
|
+
}
|
|
31230
|
+
if (element.name) {
|
|
31231
|
+
runs.push({
|
|
31232
|
+
name: "w:r",
|
|
31233
|
+
type: "element",
|
|
31234
|
+
elements: element.elements || [element]
|
|
31235
|
+
});
|
|
31236
|
+
}
|
|
31237
|
+
});
|
|
31238
|
+
return runs.filter((run2) => Array.isArray(run2.elements) && run2.elements.length > 0);
|
|
31239
|
+
}
|
|
31084
31240
|
function translateStructuredContent(params2) {
|
|
31085
31241
|
const { node, isFinalDoc } = params2;
|
|
31086
31242
|
const childContent = translateChildNodes({ ...params2, node });
|
|
@@ -34328,7 +34484,6 @@ const config = {
|
|
|
34328
34484
|
attributes: validXmlAttributes
|
|
34329
34485
|
};
|
|
34330
34486
|
const translator = NodeTranslator.from(config);
|
|
34331
|
-
const RUN_LEVEL_WRAPPERS = /* @__PURE__ */ new Set(["w:hyperlink", "w:ins", "w:del"]);
|
|
34332
34487
|
const DEFAULT_SECTION_PROPS_TWIPS = Object.freeze({
|
|
34333
34488
|
pageSize: Object.freeze({ width: "12240", height: "15840" }),
|
|
34334
34489
|
pageMargins: Object.freeze({
|
|
@@ -34386,45 +34541,6 @@ const ensureSectionLayoutDefaults = (sectPr, converter) => {
|
|
|
34386
34541
|
});
|
|
34387
34542
|
return sectPr;
|
|
34388
34543
|
};
|
|
34389
|
-
function convertSdtContentToRuns(elements) {
|
|
34390
|
-
const normalized = Array.isArray(elements) ? elements : [elements];
|
|
34391
|
-
const runs = [];
|
|
34392
|
-
normalized.forEach((element) => {
|
|
34393
|
-
if (!element) return;
|
|
34394
|
-
if (element.name === "w:sdtPr") {
|
|
34395
|
-
return;
|
|
34396
|
-
}
|
|
34397
|
-
if (element.name === "w:r") {
|
|
34398
|
-
runs.push(element);
|
|
34399
|
-
return;
|
|
34400
|
-
}
|
|
34401
|
-
if (element.name === "w:sdt") {
|
|
34402
|
-
const sdtContent = (element.elements || []).find((child) => child?.name === "w:sdtContent");
|
|
34403
|
-
if (sdtContent?.elements) {
|
|
34404
|
-
runs.push(...convertSdtContentToRuns(sdtContent.elements));
|
|
34405
|
-
}
|
|
34406
|
-
return;
|
|
34407
|
-
}
|
|
34408
|
-
if (RUN_LEVEL_WRAPPERS.has(element.name)) {
|
|
34409
|
-
const wrapperElements = convertSdtContentToRuns(element.elements || []);
|
|
34410
|
-
if (wrapperElements.length) {
|
|
34411
|
-
runs.push({
|
|
34412
|
-
...element,
|
|
34413
|
-
elements: wrapperElements
|
|
34414
|
-
});
|
|
34415
|
-
}
|
|
34416
|
-
return;
|
|
34417
|
-
}
|
|
34418
|
-
if (element.name) {
|
|
34419
|
-
runs.push({
|
|
34420
|
-
name: "w:r",
|
|
34421
|
-
type: "element",
|
|
34422
|
-
elements: element.elements || [element]
|
|
34423
|
-
});
|
|
34424
|
-
}
|
|
34425
|
-
});
|
|
34426
|
-
return runs.filter((run2) => Array.isArray(run2.elements) && run2.elements.length > 0);
|
|
34427
|
-
}
|
|
34428
34544
|
function exportSchemaToJson(params2) {
|
|
34429
34545
|
const { type: type2 } = params2.node || {};
|
|
34430
34546
|
const router = {
|
|
@@ -34531,57 +34647,7 @@ function translateHeadingNode(params2) {
|
|
|
34531
34647
|
// Maps to Heading1, Heading2, etc. in Word
|
|
34532
34648
|
}
|
|
34533
34649
|
};
|
|
34534
|
-
return
|
|
34535
|
-
}
|
|
34536
|
-
function translateParagraphNode(params2) {
|
|
34537
|
-
const elements = translateChildNodes(params2);
|
|
34538
|
-
const htmlAnnotationChild = elements.find((element) => element.name === "htmlAnnotation");
|
|
34539
|
-
if (htmlAnnotationChild) {
|
|
34540
|
-
return htmlAnnotationChild.elements;
|
|
34541
|
-
}
|
|
34542
|
-
const pPr = generateParagraphProperties(params2);
|
|
34543
|
-
if (pPr) elements.unshift(pPr);
|
|
34544
|
-
let attributes = {};
|
|
34545
|
-
if (params2.node.attrs?.rsidRDefault) {
|
|
34546
|
-
attributes["w:rsidRDefault"] = params2.node.attrs.rsidRDefault;
|
|
34547
|
-
}
|
|
34548
|
-
const result = {
|
|
34549
|
-
name: "w:p",
|
|
34550
|
-
elements,
|
|
34551
|
-
attributes
|
|
34552
|
-
};
|
|
34553
|
-
return result;
|
|
34554
|
-
}
|
|
34555
|
-
function generateParagraphProperties(params2) {
|
|
34556
|
-
const { node } = params2;
|
|
34557
|
-
const { attrs = {} } = node;
|
|
34558
|
-
const paragraphProperties = carbonCopy(attrs.paragraphProperties || {});
|
|
34559
|
-
if (attrs.styleId !== paragraphProperties.styleId) {
|
|
34560
|
-
paragraphProperties.styleId = attrs.styleId;
|
|
34561
|
-
}
|
|
34562
|
-
["borders", "styleId", "indent", "textAlign", "keepLines", "keepNext", "spacing", "tabStops"].forEach((key2) => {
|
|
34563
|
-
let propKey = key2 === "textAlign" ? "justification" : key2;
|
|
34564
|
-
if (JSON.stringify(paragraphProperties[propKey]) !== JSON.stringify(attrs[key2])) {
|
|
34565
|
-
paragraphProperties[key2] = attrs[key2];
|
|
34566
|
-
}
|
|
34567
|
-
});
|
|
34568
|
-
const framePr = attrs.dropcap;
|
|
34569
|
-
if (framePr) {
|
|
34570
|
-
framePr.dropCap = framePr.type;
|
|
34571
|
-
delete framePr.type;
|
|
34572
|
-
}
|
|
34573
|
-
if (JSON.stringify(paragraphProperties.framePr) !== JSON.stringify(framePr)) {
|
|
34574
|
-
paragraphProperties.framePr = framePr;
|
|
34575
|
-
}
|
|
34576
|
-
const marksProps = decodeRPrFromMarks(attrs.marksAttrs || []);
|
|
34577
|
-
const finalRunProps = combineRunProperties([paragraphProperties.runProperties || {}, marksProps]);
|
|
34578
|
-
paragraphProperties.runProperties = finalRunProps;
|
|
34579
|
-
const pPr = translator$12.decode({ node: { ...node, attrs: { paragraphProperties } } });
|
|
34580
|
-
const sectPr = node.attrs?.paragraphProperties?.sectPr;
|
|
34581
|
-
if (sectPr) {
|
|
34582
|
-
pPr.elements.push(sectPr);
|
|
34583
|
-
}
|
|
34584
|
-
return pPr;
|
|
34650
|
+
return translator$11.decode({ ...params2, node: paragraphNode });
|
|
34585
34651
|
}
|
|
34586
34652
|
function translateDocumentNode(params2) {
|
|
34587
34653
|
const bodyNode = {
|
|
@@ -34596,59 +34662,6 @@ function translateDocumentNode(params2) {
|
|
|
34596
34662
|
};
|
|
34597
34663
|
return [node, params2];
|
|
34598
34664
|
}
|
|
34599
|
-
function getTextNodeForExport(text, marks, params2) {
|
|
34600
|
-
const hasLeadingOrTrailingSpace = /^\s|\s$/.test(text);
|
|
34601
|
-
const space = hasLeadingOrTrailingSpace ? "preserve" : null;
|
|
34602
|
-
const nodeAttrs = space ? { "xml:space": space } : null;
|
|
34603
|
-
const textNodes = [];
|
|
34604
|
-
const textRunProperties = decodeRPrFromMarks(marks || []);
|
|
34605
|
-
const parentRunProperties = params2.extraParams?.runProperties || {};
|
|
34606
|
-
const combinedRunProperties = combineRunProperties([parentRunProperties, textRunProperties]);
|
|
34607
|
-
const rPrNode = translator$1N.decode({ node: { attrs: { runProperties: combinedRunProperties } } });
|
|
34608
|
-
textNodes.push({
|
|
34609
|
-
name: "w:t",
|
|
34610
|
-
elements: [{ text, type: "text" }],
|
|
34611
|
-
attributes: nodeAttrs
|
|
34612
|
-
});
|
|
34613
|
-
if (params2) {
|
|
34614
|
-
const { editor } = params2;
|
|
34615
|
-
const customMarks = editor.extensionService.extensions.filter((e) => e.isExternal === true);
|
|
34616
|
-
marks.forEach((mark) => {
|
|
34617
|
-
const isCustomMark = customMarks.some((customMark) => {
|
|
34618
|
-
const customMarkName = customMark.name;
|
|
34619
|
-
return mark.type === customMarkName;
|
|
34620
|
-
});
|
|
34621
|
-
if (!isCustomMark) return;
|
|
34622
|
-
let attrsString = "";
|
|
34623
|
-
Object.entries(mark.attrs).forEach(([key2, value]) => {
|
|
34624
|
-
if (value) {
|
|
34625
|
-
attrsString += `${key2}=${value};`;
|
|
34626
|
-
}
|
|
34627
|
-
});
|
|
34628
|
-
if (isCustomMark) {
|
|
34629
|
-
textNodes.unshift({
|
|
34630
|
-
type: "element",
|
|
34631
|
-
name: "w:bookmarkStart",
|
|
34632
|
-
attributes: {
|
|
34633
|
-
"w:id": "5000",
|
|
34634
|
-
"w:name": mark.type + ";" + attrsString
|
|
34635
|
-
}
|
|
34636
|
-
});
|
|
34637
|
-
textNodes.push({
|
|
34638
|
-
type: "element",
|
|
34639
|
-
name: "w:bookmarkEnd",
|
|
34640
|
-
attributes: {
|
|
34641
|
-
"w:id": "5000"
|
|
34642
|
-
}
|
|
34643
|
-
});
|
|
34644
|
-
}
|
|
34645
|
-
});
|
|
34646
|
-
}
|
|
34647
|
-
return {
|
|
34648
|
-
name: "w:r",
|
|
34649
|
-
elements: rPrNode ? [rPrNode, ...textNodes] : textNodes
|
|
34650
|
-
};
|
|
34651
|
-
}
|
|
34652
34665
|
function wrapTextInRun(nodeOrNodes, marks) {
|
|
34653
34666
|
let elements = [];
|
|
34654
34667
|
if (Array.isArray(nodeOrNodes)) elements = nodeOrNodes;
|
|
@@ -34677,60 +34690,6 @@ function processOutputMarks(marks = []) {
|
|
|
34677
34690
|
}
|
|
34678
34691
|
});
|
|
34679
34692
|
}
|
|
34680
|
-
function processLinkContentNode(node) {
|
|
34681
|
-
if (!node) return node;
|
|
34682
|
-
const contentNode = carbonCopy(node);
|
|
34683
|
-
if (!contentNode) return contentNode;
|
|
34684
|
-
const hyperlinkStyle = {
|
|
34685
|
-
name: "w:rStyle",
|
|
34686
|
-
attributes: { "w:val": "Hyperlink" }
|
|
34687
|
-
};
|
|
34688
|
-
const color = {
|
|
34689
|
-
name: "w:color",
|
|
34690
|
-
attributes: { "w:val": "467886" }
|
|
34691
|
-
};
|
|
34692
|
-
const underline = {
|
|
34693
|
-
name: "w:u",
|
|
34694
|
-
attributes: {
|
|
34695
|
-
"w:val": "none"
|
|
34696
|
-
}
|
|
34697
|
-
};
|
|
34698
|
-
if (contentNode.name === "w:r") {
|
|
34699
|
-
const runProps = contentNode.elements.find((el) => el.name === "w:rPr");
|
|
34700
|
-
if (runProps) {
|
|
34701
|
-
const foundColor = runProps.elements.find((el) => el.name === "w:color");
|
|
34702
|
-
const foundHyperlinkStyle = runProps.elements.find((el) => el.name === "w:rStyle");
|
|
34703
|
-
const underlineMark = runProps.elements.find((el) => el.name === "w:u");
|
|
34704
|
-
if (!foundColor) runProps.elements.unshift(color);
|
|
34705
|
-
if (!foundHyperlinkStyle) runProps.elements.unshift(hyperlinkStyle);
|
|
34706
|
-
if (!underlineMark) runProps.elements.unshift(underline);
|
|
34707
|
-
} else {
|
|
34708
|
-
const runProps2 = {
|
|
34709
|
-
name: "w:rPr",
|
|
34710
|
-
elements: [hyperlinkStyle, color]
|
|
34711
|
-
};
|
|
34712
|
-
contentNode.elements.unshift(runProps2);
|
|
34713
|
-
}
|
|
34714
|
-
}
|
|
34715
|
-
return contentNode;
|
|
34716
|
-
}
|
|
34717
|
-
function addNewLinkRelationship(params2, link) {
|
|
34718
|
-
const newId = "rId" + generateDocxRandomId();
|
|
34719
|
-
if (!params2.relationships || !Array.isArray(params2.relationships)) {
|
|
34720
|
-
params2.relationships = [];
|
|
34721
|
-
}
|
|
34722
|
-
params2.relationships.push({
|
|
34723
|
-
type: "element",
|
|
34724
|
-
name: "Relationship",
|
|
34725
|
-
attributes: {
|
|
34726
|
-
Id: newId,
|
|
34727
|
-
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
|
|
34728
|
-
Target: link,
|
|
34729
|
-
TargetMode: "External"
|
|
34730
|
-
}
|
|
34731
|
-
});
|
|
34732
|
-
return newId;
|
|
34733
|
-
}
|
|
34734
34693
|
function translateMark(mark) {
|
|
34735
34694
|
const xmlMark = SuperConverter.markTypes.find((m2) => m2.type === mark.type);
|
|
34736
34695
|
if (!xmlMark) {
|
|
@@ -34911,7 +34870,7 @@ const prepareCommentParaIds = (comment) => {
|
|
|
34911
34870
|
return newComment;
|
|
34912
34871
|
};
|
|
34913
34872
|
const getCommentDefinition = (comment, commentId, allComments, editor) => {
|
|
34914
|
-
const translatedText =
|
|
34873
|
+
const translatedText = translator$11.decode({ editor, node: comment.commentJSON });
|
|
34915
34874
|
const attributes = {
|
|
34916
34875
|
"w:id": String(commentId),
|
|
34917
34876
|
"w:author": comment.creatorName || comment.importedAuthor?.name,
|
|
@@ -35326,7 +35285,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
35326
35285
|
static getStoredSuperdocVersion(docx) {
|
|
35327
35286
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
35328
35287
|
}
|
|
35329
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.31.0-next.
|
|
35288
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "0.31.0-next.6") {
|
|
35330
35289
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
35331
35290
|
}
|
|
35332
35291
|
/**
|
|
@@ -52586,7 +52545,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
52586
52545
|
{ default: remarkStringify },
|
|
52587
52546
|
{ default: remarkGfm }
|
|
52588
52547
|
] = await Promise.all([
|
|
52589
|
-
import("./index-
|
|
52548
|
+
import("./index-DAES86tg-BDL6WVta.es.js"),
|
|
52590
52549
|
import("./index-DRCvimau-Cw339678.es.js"),
|
|
52591
52550
|
import("./index-C_x_N6Uh-DJn8hIEt.es.js"),
|
|
52592
52551
|
import("./index-D_sWOSiG-DE96TaT5.es.js"),
|
|
@@ -52787,7 +52746,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
52787
52746
|
* Process collaboration migrations
|
|
52788
52747
|
*/
|
|
52789
52748
|
processCollaborationMigrations() {
|
|
52790
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.31.0-next.
|
|
52749
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.31.0-next.6");
|
|
52791
52750
|
if (!this.options.ydoc) return;
|
|
52792
52751
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
52793
52752
|
let docVersion = metaMap.get("version");
|
|
@@ -56606,7 +56565,7 @@ const applyLinkedStyleToTransaction = (tr, editor, style2) => {
|
|
|
56606
56565
|
let selection = tr.selection;
|
|
56607
56566
|
const state2 = editor.state;
|
|
56608
56567
|
const focusState = CustomSelectionPluginKey.getState(state2);
|
|
56609
|
-
if (selection.empty && focusState?.preservedSelection) {
|
|
56568
|
+
if (selection.empty && focusState?.preservedSelection && !focusState?.preservedSelection.empty) {
|
|
56610
56569
|
selection = focusState.preservedSelection;
|
|
56611
56570
|
tr.setSelection(selection);
|
|
56612
56571
|
} else if (selection.empty && editor.options.lastSelection) {
|
|
@@ -56673,6 +56632,31 @@ const applyLinkedStyleToTransaction = (tr, editor, style2) => {
|
|
|
56673
56632
|
});
|
|
56674
56633
|
return true;
|
|
56675
56634
|
};
|
|
56635
|
+
const stepInsertsTextIntoStyledParagraph = (tr, oldEditorState, step, stepIndex) => {
|
|
56636
|
+
if (!step.slice || step.slice.size === 0 || typeof step.from !== "number") {
|
|
56637
|
+
return false;
|
|
56638
|
+
}
|
|
56639
|
+
let insertsText = false;
|
|
56640
|
+
step.slice.content.descendants((node) => {
|
|
56641
|
+
if (node.type?.name === "text" && node.text?.length) {
|
|
56642
|
+
insertsText = true;
|
|
56643
|
+
return false;
|
|
56644
|
+
}
|
|
56645
|
+
return true;
|
|
56646
|
+
});
|
|
56647
|
+
if (!insertsText) return false;
|
|
56648
|
+
const docBeforeStep = tr.docs?.[stepIndex] || oldEditorState.doc;
|
|
56649
|
+
if (!docBeforeStep) return false;
|
|
56650
|
+
const resolvedPos = Math.min(step.from, docBeforeStep.content.size);
|
|
56651
|
+
const $pos = docBeforeStep.resolve(resolvedPos);
|
|
56652
|
+
for (let depth = $pos.depth; depth >= 0; depth--) {
|
|
56653
|
+
const node = $pos.node(depth);
|
|
56654
|
+
if (node?.type?.name === "paragraph") {
|
|
56655
|
+
return Boolean(node.attrs?.styleId);
|
|
56656
|
+
}
|
|
56657
|
+
}
|
|
56658
|
+
return false;
|
|
56659
|
+
};
|
|
56676
56660
|
const LinkedStylesPluginKey = new PluginKey("linkedStyles");
|
|
56677
56661
|
const createLinkedStylesPlugin = (editor) => {
|
|
56678
56662
|
return new Plugin({
|
|
@@ -56706,7 +56690,7 @@ const createLinkedStylesPlugin = (editor) => {
|
|
|
56706
56690
|
if (tr.docChanged) {
|
|
56707
56691
|
let mightAffectStyles = false;
|
|
56708
56692
|
const styleRelatedMarks = /* @__PURE__ */ new Set(["textStyle", "bold", "italic", "underline", "strike"]);
|
|
56709
|
-
tr.steps.forEach((step) => {
|
|
56693
|
+
tr.steps.forEach((step, index2) => {
|
|
56710
56694
|
if (step.slice) {
|
|
56711
56695
|
step.slice.content.descendants((node) => {
|
|
56712
56696
|
if (node.attrs?.styleId) {
|
|
@@ -56727,6 +56711,9 @@ const createLinkedStylesPlugin = (editor) => {
|
|
|
56727
56711
|
mightAffectStyles = true;
|
|
56728
56712
|
}
|
|
56729
56713
|
}
|
|
56714
|
+
if (!mightAffectStyles && stepInsertsTextIntoStyledParagraph(tr, oldEditorState, step, index2)) {
|
|
56715
|
+
mightAffectStyles = true;
|
|
56716
|
+
}
|
|
56730
56717
|
});
|
|
56731
56718
|
if (mightAffectStyles) {
|
|
56732
56719
|
const styles = LinkedStylesPluginKey.getState(editor.state).styles;
|
|
@@ -58077,6 +58064,8 @@ const Paragraph = OxmlNode.create({
|
|
|
58077
58064
|
}
|
|
58078
58065
|
},
|
|
58079
58066
|
styleId: {
|
|
58067
|
+
default: null,
|
|
58068
|
+
keepOnSplit: false,
|
|
58080
58069
|
renderDOM: (attrs) => {
|
|
58081
58070
|
if (!attrs.styleId) return {};
|
|
58082
58071
|
return { styleid: attrs.styleId };
|