@harbour-enterprises/superdoc 1.4.0-next.1 → 1.4.0-next.2
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-DRTk3dY6.es.js → PdfViewer-Dnv-LGqI.es.js} +2 -2
- package/dist/chunks/{PdfViewer-H9_8IbtN.cjs → PdfViewer-DqN1vOXI.cjs} +2 -2
- package/dist/chunks/{SuperConverter-CFRB4XNw.es.js → SuperConverter-DxlpZQZQ.es.js} +266 -6
- package/dist/chunks/{SuperConverter-CgY28MJz.cjs → SuperConverter-Dy4wkQEB.cjs} +266 -6
- package/dist/chunks/{index-BP9aFfwI.es.js → index-D246eEeJ.es.js} +4 -4
- package/dist/chunks/{index-C3KRKogJ.cjs → index-DJuBZura.cjs} +57 -20
- package/dist/chunks/{index-BdaseaBw.cjs → index-DpgrTjYC.cjs} +4 -4
- package/dist/chunks/{index-CEcYlysg.es.js → index-dnQEKI-e.es.js} +57 -20
- package/dist/super-editor/converter.cjs +1 -1
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor.cjs +2 -2
- package/dist/super-editor.es.js +3 -3
- package/dist/superdoc.cjs +3 -3
- package/dist/superdoc.es.js +3 -3
- package/dist/superdoc.umd.js +323 -26
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +3 -3
package/dist/superdoc.umd.js
CHANGED
|
@@ -24064,7 +24064,7 @@
|
|
|
24064
24064
|
const DRAWING_XML_TAG = "w:drawing";
|
|
24065
24065
|
const SHAPE_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
|
|
24066
24066
|
const GROUP_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup";
|
|
24067
|
-
const normalizeTargetPath = (targetPath = "") => {
|
|
24067
|
+
const normalizeTargetPath$1 = (targetPath = "") => {
|
|
24068
24068
|
if (!targetPath) return targetPath;
|
|
24069
24069
|
const trimmed = targetPath.replace(/^\/+/, "");
|
|
24070
24070
|
if (trimmed.startsWith("word/")) return trimmed;
|
|
@@ -24223,7 +24223,14 @@
|
|
|
24223
24223
|
}
|
|
24224
24224
|
const stretch = blipFill?.elements.find((el) => el.name === "a:stretch");
|
|
24225
24225
|
const fillRect = stretch?.elements.find((el) => el.name === "a:fillRect");
|
|
24226
|
+
const srcRect = blipFill?.elements.find((el) => el.name === "a:srcRect");
|
|
24227
|
+
const srcRectAttrs = srcRect?.attributes || {};
|
|
24228
|
+
const srcRectHasNegativeValues = ["l", "t", "r", "b"].some((attr) => {
|
|
24229
|
+
const val = srcRectAttrs[attr];
|
|
24230
|
+
return val != null && parseFloat(val) < 0;
|
|
24231
|
+
});
|
|
24226
24232
|
const shouldStretch = Boolean(stretch && fillRect);
|
|
24233
|
+
const shouldCover = shouldStretch && !srcRectHasNegativeValues;
|
|
24227
24234
|
const spPr = picture.elements.find((el) => el.name === "pic:spPr");
|
|
24228
24235
|
if (spPr) {
|
|
24229
24236
|
const xfrm = spPr.elements.find((el) => el.name === "a:xfrm");
|
|
@@ -24252,7 +24259,7 @@
|
|
|
24252
24259
|
}
|
|
24253
24260
|
const { attributes: relAttributes } = rel;
|
|
24254
24261
|
const targetPath = relAttributes["Target"];
|
|
24255
|
-
const path2 = normalizeTargetPath(targetPath);
|
|
24262
|
+
const path2 = normalizeTargetPath$1(targetPath);
|
|
24256
24263
|
const extension = path2.substring(path2.lastIndexOf(".") + 1);
|
|
24257
24264
|
let finalSrc = path2;
|
|
24258
24265
|
let finalExtension = extension;
|
|
@@ -24300,7 +24307,7 @@
|
|
|
24300
24307
|
wrapText: wrap2.attrs.wrapText
|
|
24301
24308
|
} : {},
|
|
24302
24309
|
wrapTopAndBottom: wrap2.type === "TopAndBottom",
|
|
24303
|
-
|
|
24310
|
+
shouldCover,
|
|
24304
24311
|
originalPadding: {
|
|
24305
24312
|
distT: attributes["distT"],
|
|
24306
24313
|
distB: attributes["distB"],
|
|
@@ -24493,7 +24500,7 @@
|
|
|
24493
24500
|
const { elements } = relationships || [];
|
|
24494
24501
|
const rel = elements?.find((el) => el.attributes["Id"] === rEmbed);
|
|
24495
24502
|
if (!rel) return null;
|
|
24496
|
-
const targetPath = normalizeTargetPath(rel.attributes?.["Target"]);
|
|
24503
|
+
const targetPath = normalizeTargetPath$1(rel.attributes?.["Target"]);
|
|
24497
24504
|
const path2 = targetPath;
|
|
24498
24505
|
const nvPicPr = pic.elements?.find((el) => el.name === "pic:nvPicPr");
|
|
24499
24506
|
const cNvPr = nvPicPr?.elements?.find((el) => el.name === "pic:cNvPr");
|
|
@@ -34987,6 +34994,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
34987
34994
|
if (!node2 || typeof node2.type !== "string") return;
|
|
34988
34995
|
const type = node2.type;
|
|
34989
34996
|
const preservableNodeName = PRESERVABLE_INLINE_XML_NAMES[type];
|
|
34997
|
+
if (type === "image" && node2.attrs?.isAnchor) {
|
|
34998
|
+
result.push(node2);
|
|
34999
|
+
return;
|
|
35000
|
+
}
|
|
34990
35001
|
if (!INLINE_TYPES.has(type)) {
|
|
34991
35002
|
result.push(node2);
|
|
34992
35003
|
} else if (preservableNodeName) {
|
|
@@ -35180,6 +35191,137 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35180
35191
|
}
|
|
35181
35192
|
return style2;
|
|
35182
35193
|
}
|
|
35194
|
+
function handleShapeImageImport({ params: params2, pict }) {
|
|
35195
|
+
const shape = pict.elements?.find((el) => el.name === "v:shape");
|
|
35196
|
+
if (!shape) return null;
|
|
35197
|
+
const imagedata = shape.elements?.find((el) => el.name === "v:imagedata");
|
|
35198
|
+
if (!imagedata) return null;
|
|
35199
|
+
const { docx, filename } = params2;
|
|
35200
|
+
const shapeAttrs = shape.attributes || {};
|
|
35201
|
+
const imagedataAttrs = imagedata.attributes || {};
|
|
35202
|
+
const rId = imagedataAttrs["r:id"];
|
|
35203
|
+
if (!rId) {
|
|
35204
|
+
console.warn("v:imagedata missing r:id attribute");
|
|
35205
|
+
return null;
|
|
35206
|
+
}
|
|
35207
|
+
const currentFile = filename || "document.xml";
|
|
35208
|
+
let rels = docx[`word/_rels/${currentFile}.rels`];
|
|
35209
|
+
if (!rels) rels = docx[`word/_rels/document.xml.rels`];
|
|
35210
|
+
const relationships = rels?.elements?.find((el) => el.name === "Relationships");
|
|
35211
|
+
const { elements } = relationships || [];
|
|
35212
|
+
const rel = elements?.find((el) => el.attributes["Id"] === rId);
|
|
35213
|
+
if (!rel) {
|
|
35214
|
+
console.warn(`Relationship not found for r:id="${rId}"`);
|
|
35215
|
+
return null;
|
|
35216
|
+
}
|
|
35217
|
+
const targetPath = rel.attributes["Target"];
|
|
35218
|
+
const normalizedPath = normalizeTargetPath(targetPath);
|
|
35219
|
+
const style2 = shapeAttrs.style || "";
|
|
35220
|
+
const styleObj = parseVmlStyle(style2);
|
|
35221
|
+
const width = styleObj.width || "100px";
|
|
35222
|
+
const height = styleObj.height || "100px";
|
|
35223
|
+
const position2 = {
|
|
35224
|
+
type: styleObj.position || "absolute",
|
|
35225
|
+
marginLeft: styleObj["margin-left"] || "0",
|
|
35226
|
+
marginTop: styleObj["margin-top"] || "0"
|
|
35227
|
+
};
|
|
35228
|
+
const zIndex = styleObj["z-index"] ? parseInt(styleObj["z-index"], 10) : void 0;
|
|
35229
|
+
const hPosition = styleObj["mso-position-horizontal"] || "center";
|
|
35230
|
+
const vPosition = styleObj["mso-position-vertical"] || "center";
|
|
35231
|
+
const hRelativeTo = styleObj["mso-position-horizontal-relative"] || "margin";
|
|
35232
|
+
const vRelativeTo = styleObj["mso-position-vertical-relative"] || "margin";
|
|
35233
|
+
const gain = imagedataAttrs["gain"];
|
|
35234
|
+
const blacklevel = imagedataAttrs["blacklevel"];
|
|
35235
|
+
const title = imagedataAttrs["o:title"] || "Watermark";
|
|
35236
|
+
const imageNode = {
|
|
35237
|
+
type: "image",
|
|
35238
|
+
attrs: {
|
|
35239
|
+
src: normalizedPath,
|
|
35240
|
+
alt: title,
|
|
35241
|
+
extension: normalizedPath.substring(normalizedPath.lastIndexOf(".") + 1),
|
|
35242
|
+
title,
|
|
35243
|
+
rId,
|
|
35244
|
+
// Store VML-specific attributes for round-trip
|
|
35245
|
+
vmlWatermark: true,
|
|
35246
|
+
vmlStyle: style2,
|
|
35247
|
+
vmlAttributes: shapeAttrs,
|
|
35248
|
+
vmlImagedata: imagedataAttrs,
|
|
35249
|
+
// Positioning
|
|
35250
|
+
isAnchor: true,
|
|
35251
|
+
inline: false,
|
|
35252
|
+
wrap: {
|
|
35253
|
+
type: "None",
|
|
35254
|
+
attrs: {
|
|
35255
|
+
behindDoc: Number.isFinite(zIndex) ? zIndex < 0 : true
|
|
35256
|
+
}
|
|
35257
|
+
},
|
|
35258
|
+
anchorData: {
|
|
35259
|
+
hRelativeFrom: hRelativeTo,
|
|
35260
|
+
vRelativeFrom: vRelativeTo,
|
|
35261
|
+
alignH: hPosition,
|
|
35262
|
+
alignV: vPosition
|
|
35263
|
+
},
|
|
35264
|
+
// Size
|
|
35265
|
+
size: {
|
|
35266
|
+
width: convertToPixels(width),
|
|
35267
|
+
height: convertToPixels(height)
|
|
35268
|
+
},
|
|
35269
|
+
marginOffset: {
|
|
35270
|
+
horizontal: convertToPixels(position2.marginLeft),
|
|
35271
|
+
top: convertToPixels(position2.marginTop)
|
|
35272
|
+
},
|
|
35273
|
+
// Image adjustments
|
|
35274
|
+
...gain && { gain },
|
|
35275
|
+
...blacklevel && { blacklevel }
|
|
35276
|
+
}
|
|
35277
|
+
};
|
|
35278
|
+
return imageNode;
|
|
35279
|
+
}
|
|
35280
|
+
function normalizeTargetPath(targetPath = "") {
|
|
35281
|
+
if (!targetPath) return targetPath;
|
|
35282
|
+
const trimmed = targetPath.replace(/^\/+/, "");
|
|
35283
|
+
if (trimmed.startsWith("word/")) return trimmed;
|
|
35284
|
+
if (trimmed.startsWith("media/")) return `word/${trimmed}`;
|
|
35285
|
+
return `word/${trimmed}`;
|
|
35286
|
+
}
|
|
35287
|
+
function parseVmlStyle(style2) {
|
|
35288
|
+
const result = {};
|
|
35289
|
+
if (!style2) return result;
|
|
35290
|
+
const declarations = style2.split(";").filter((s2) => s2.trim());
|
|
35291
|
+
for (const decl of declarations) {
|
|
35292
|
+
const [prop, value] = decl.split(":").map((s2) => s2.trim());
|
|
35293
|
+
if (prop && value) {
|
|
35294
|
+
result[prop] = value;
|
|
35295
|
+
}
|
|
35296
|
+
}
|
|
35297
|
+
return result;
|
|
35298
|
+
}
|
|
35299
|
+
function convertToPixels(value) {
|
|
35300
|
+
if (typeof value === "number") return value;
|
|
35301
|
+
if (!value || typeof value !== "string") return 0;
|
|
35302
|
+
const match = value.match(/^([\d.]+)([a-z%]+)?$/i);
|
|
35303
|
+
if (!match) return 0;
|
|
35304
|
+
const num = parseFloat(match[1]);
|
|
35305
|
+
const unit = match[2] || "px";
|
|
35306
|
+
switch (unit.toLowerCase()) {
|
|
35307
|
+
case "px":
|
|
35308
|
+
return num;
|
|
35309
|
+
case "pt":
|
|
35310
|
+
return num * (96 / 72);
|
|
35311
|
+
// 1pt = 1/72 inch, 96 DPI
|
|
35312
|
+
case "in":
|
|
35313
|
+
return num * 96;
|
|
35314
|
+
case "cm":
|
|
35315
|
+
return num * (96 / 2.54);
|
|
35316
|
+
case "mm":
|
|
35317
|
+
return num * (96 / 25.4);
|
|
35318
|
+
case "pc":
|
|
35319
|
+
return num * 16;
|
|
35320
|
+
// 1pc = 12pt
|
|
35321
|
+
default:
|
|
35322
|
+
return num;
|
|
35323
|
+
}
|
|
35324
|
+
}
|
|
35183
35325
|
function pictNodeTypeStrategy(node2) {
|
|
35184
35326
|
const shape = node2.elements?.find((el) => el.name === "v:shape");
|
|
35185
35327
|
const group = node2.elements?.find((el) => el.name === "v:group");
|
|
@@ -35198,6 +35340,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35198
35340
|
if (textbox) {
|
|
35199
35341
|
return { type: "shapeContainer", handler: handleShapeTextboxImport };
|
|
35200
35342
|
}
|
|
35343
|
+
const imagedata = shape.elements?.find((el) => el.name === "v:imagedata");
|
|
35344
|
+
if (imagedata) {
|
|
35345
|
+
return { type: "image", handler: handleShapeImageImport };
|
|
35346
|
+
}
|
|
35201
35347
|
}
|
|
35202
35348
|
return { type: "unknown", handler: null };
|
|
35203
35349
|
}
|
|
@@ -35296,8 +35442,116 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35296
35442
|
};
|
|
35297
35443
|
return wrapTextInRun(pict);
|
|
35298
35444
|
}
|
|
35445
|
+
function translateVmlWatermark(params2) {
|
|
35446
|
+
const { node: node2 } = params2;
|
|
35447
|
+
const { attrs } = node2;
|
|
35448
|
+
if (attrs.vmlAttributes && attrs.vmlImagedata) {
|
|
35449
|
+
const shape2 = {
|
|
35450
|
+
name: "v:shape",
|
|
35451
|
+
attributes: attrs.vmlAttributes,
|
|
35452
|
+
elements: [
|
|
35453
|
+
{
|
|
35454
|
+
name: "v:imagedata",
|
|
35455
|
+
attributes: {
|
|
35456
|
+
...attrs.vmlImagedata,
|
|
35457
|
+
"r:id": attrs.rId
|
|
35458
|
+
}
|
|
35459
|
+
}
|
|
35460
|
+
]
|
|
35461
|
+
};
|
|
35462
|
+
const pict2 = {
|
|
35463
|
+
name: "w:pict",
|
|
35464
|
+
attributes: {
|
|
35465
|
+
"w14:anchorId": generateRandomSigned32BitIntStrId()
|
|
35466
|
+
},
|
|
35467
|
+
elements: [shape2]
|
|
35468
|
+
};
|
|
35469
|
+
const par2 = {
|
|
35470
|
+
name: "w:p",
|
|
35471
|
+
elements: [wrapTextInRun(pict2)]
|
|
35472
|
+
};
|
|
35473
|
+
return par2;
|
|
35474
|
+
}
|
|
35475
|
+
const style2 = buildVmlStyle(attrs);
|
|
35476
|
+
const shape = {
|
|
35477
|
+
name: "v:shape",
|
|
35478
|
+
attributes: {
|
|
35479
|
+
id: `WordPictureWatermark${generateRandomSigned32BitIntStrId().replace("-", "")}`,
|
|
35480
|
+
"o:spid": `_x0000_s${Math.floor(Math.random() * 1e4)}`,
|
|
35481
|
+
type: "#_x0000_t75",
|
|
35482
|
+
style: style2,
|
|
35483
|
+
"o:allowincell": "f"
|
|
35484
|
+
},
|
|
35485
|
+
elements: [
|
|
35486
|
+
{
|
|
35487
|
+
name: "v:imagedata",
|
|
35488
|
+
attributes: {
|
|
35489
|
+
"r:id": attrs.rId,
|
|
35490
|
+
"o:title": attrs.title || attrs.alt || "Watermark",
|
|
35491
|
+
...attrs.gain && { gain: attrs.gain },
|
|
35492
|
+
...attrs.blacklevel && { blacklevel: attrs.blacklevel }
|
|
35493
|
+
}
|
|
35494
|
+
}
|
|
35495
|
+
]
|
|
35496
|
+
};
|
|
35497
|
+
const pict = {
|
|
35498
|
+
name: "w:pict",
|
|
35499
|
+
attributes: {
|
|
35500
|
+
"w14:anchorId": generateRandomSigned32BitIntStrId()
|
|
35501
|
+
},
|
|
35502
|
+
elements: [shape]
|
|
35503
|
+
};
|
|
35504
|
+
const par = {
|
|
35505
|
+
name: "w:p",
|
|
35506
|
+
elements: [wrapTextInRun(pict)]
|
|
35507
|
+
};
|
|
35508
|
+
return par;
|
|
35509
|
+
}
|
|
35510
|
+
function buildVmlStyle(attrs) {
|
|
35511
|
+
const styles = [];
|
|
35512
|
+
styles.push("position:absolute");
|
|
35513
|
+
if (attrs.size) {
|
|
35514
|
+
if (attrs.size.width) {
|
|
35515
|
+
styles.push(`width:${convertToPt(attrs.size.width)}pt`);
|
|
35516
|
+
}
|
|
35517
|
+
if (attrs.size.height) {
|
|
35518
|
+
styles.push(`height:${convertToPt(attrs.size.height)}pt`);
|
|
35519
|
+
}
|
|
35520
|
+
}
|
|
35521
|
+
if (attrs.marginOffset) {
|
|
35522
|
+
if (attrs.marginOffset.horizontal !== void 0) {
|
|
35523
|
+
styles.push(`margin-left:${convertToPt(attrs.marginOffset.horizontal)}pt`);
|
|
35524
|
+
}
|
|
35525
|
+
if (attrs.marginOffset.top !== void 0) {
|
|
35526
|
+
styles.push(`margin-top:${convertToPt(attrs.marginOffset.top)}pt`);
|
|
35527
|
+
}
|
|
35528
|
+
}
|
|
35529
|
+
if (attrs.wrap?.attrs?.behindDoc) {
|
|
35530
|
+
styles.push("z-index:-251653120");
|
|
35531
|
+
}
|
|
35532
|
+
if (attrs.anchorData) {
|
|
35533
|
+
if (attrs.anchorData.alignH) {
|
|
35534
|
+
styles.push(`mso-position-horizontal:${attrs.anchorData.alignH}`);
|
|
35535
|
+
}
|
|
35536
|
+
if (attrs.anchorData.alignV) {
|
|
35537
|
+
styles.push(`mso-position-vertical:${attrs.anchorData.alignV}`);
|
|
35538
|
+
}
|
|
35539
|
+
if (attrs.anchorData.hRelativeFrom) {
|
|
35540
|
+
styles.push(`mso-position-horizontal-relative:${attrs.anchorData.hRelativeFrom}`);
|
|
35541
|
+
}
|
|
35542
|
+
if (attrs.anchorData.vRelativeFrom) {
|
|
35543
|
+
styles.push(`mso-position-vertical-relative:${attrs.anchorData.vRelativeFrom}`);
|
|
35544
|
+
}
|
|
35545
|
+
}
|
|
35546
|
+
styles.push("mso-width-percent:0");
|
|
35547
|
+
styles.push("mso-height-percent:0");
|
|
35548
|
+
return styles.join(";");
|
|
35549
|
+
}
|
|
35550
|
+
function convertToPt(pixels) {
|
|
35551
|
+
return pixels * 72 / 96;
|
|
35552
|
+
}
|
|
35299
35553
|
const XML_NODE_NAME = "w:pict";
|
|
35300
|
-
const SD_NODE_NAME = ["shapeContainer", "contentBlock"];
|
|
35554
|
+
const SD_NODE_NAME = ["shapeContainer", "contentBlock", "image"];
|
|
35301
35555
|
const validXmlAttributes = [];
|
|
35302
35556
|
function encode$1(params2) {
|
|
35303
35557
|
const { node: node2, pNode } = params2.extraParams;
|
|
@@ -35321,6 +35575,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
35321
35575
|
shapeContainer: () => translateShapeContainer(params2),
|
|
35322
35576
|
shapeTextbox: () => translateShapeTextbox(params2),
|
|
35323
35577
|
contentBlock: () => translateContentBlock(params2),
|
|
35578
|
+
image: () => {
|
|
35579
|
+
if (node2.attrs?.vmlWatermark) {
|
|
35580
|
+
return translateVmlWatermark(params2);
|
|
35581
|
+
}
|
|
35582
|
+
return null;
|
|
35583
|
+
},
|
|
35324
35584
|
default: () => null
|
|
35325
35585
|
};
|
|
35326
35586
|
const decoder = types2[node2.type] ?? types2.default;
|
|
@@ -36436,7 +36696,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36436
36696
|
static getStoredSuperdocVersion(docx) {
|
|
36437
36697
|
return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
36438
36698
|
}
|
|
36439
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.4.0-next.
|
|
36699
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.4.0-next.2") {
|
|
36440
36700
|
return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
36441
36701
|
}
|
|
36442
36702
|
/**
|
|
@@ -62252,7 +62512,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
62252
62512
|
return false;
|
|
62253
62513
|
}
|
|
62254
62514
|
};
|
|
62255
|
-
const summaryVersion = "1.4.0-next.
|
|
62515
|
+
const summaryVersion = "1.4.0-next.2";
|
|
62256
62516
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
62257
62517
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
62258
62518
|
function mapAttributes(attrs) {
|
|
@@ -64885,7 +65145,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
64885
65145
|
* Process collaboration migrations
|
|
64886
65146
|
*/
|
|
64887
65147
|
processCollaborationMigrations() {
|
|
64888
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.4.0-next.
|
|
65148
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.4.0-next.2");
|
|
64889
65149
|
if (!this.options.ydoc) return;
|
|
64890
65150
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
64891
65151
|
let docVersion = metaMap.get("version");
|
|
@@ -70619,6 +70879,9 @@ ${l}
|
|
|
70619
70879
|
imgEl.style.width = "100%";
|
|
70620
70880
|
imgEl.style.height = "100%";
|
|
70621
70881
|
imgEl.style.objectFit = block.objectFit ?? "contain";
|
|
70882
|
+
if (block.objectFit === "cover") {
|
|
70883
|
+
imgEl.style.objectPosition = "left top";
|
|
70884
|
+
}
|
|
70622
70885
|
imgEl.style.display = "block";
|
|
70623
70886
|
imageWrapper.appendChild(imgEl);
|
|
70624
70887
|
content2.appendChild(imageWrapper);
|
|
@@ -70648,6 +70911,9 @@ ${l}
|
|
|
70648
70911
|
img2.style.width = "100%";
|
|
70649
70912
|
img2.style.height = "100%";
|
|
70650
70913
|
img2.style.objectFit = block.objectFit ?? "contain";
|
|
70914
|
+
if (block.objectFit === "cover") {
|
|
70915
|
+
img2.style.objectPosition = "left top";
|
|
70916
|
+
}
|
|
70651
70917
|
drawingInner.appendChild(img2);
|
|
70652
70918
|
} else if (renderDrawingContent) {
|
|
70653
70919
|
const drawingContent = renderDrawingContent(block);
|
|
@@ -73220,7 +73486,7 @@ ${l}
|
|
|
73220
73486
|
if (fragment.pmEnd != null) {
|
|
73221
73487
|
fragmentEl.dataset.pmEnd = String(fragment.pmEnd);
|
|
73222
73488
|
}
|
|
73223
|
-
if (fragment.metadata) {
|
|
73489
|
+
if (fragment.metadata && !block.attrs?.vmlWatermark) {
|
|
73224
73490
|
fragmentEl.setAttribute("data-image-metadata", JSON.stringify(fragment.metadata));
|
|
73225
73491
|
}
|
|
73226
73492
|
const img2 = this.doc.createElement("img");
|
|
@@ -73231,7 +73497,28 @@ ${l}
|
|
|
73231
73497
|
img2.style.width = "100%";
|
|
73232
73498
|
img2.style.height = "100%";
|
|
73233
73499
|
img2.style.objectFit = block.objectFit ?? "contain";
|
|
73500
|
+
if (block.objectFit === "cover") {
|
|
73501
|
+
img2.style.objectPosition = "left top";
|
|
73502
|
+
}
|
|
73234
73503
|
img2.style.display = block.display === "inline" ? "inline-block" : "block";
|
|
73504
|
+
const filters = [];
|
|
73505
|
+
if (block.gain != null || block.blacklevel != null) {
|
|
73506
|
+
if (block.gain && typeof block.gain === "string" && block.gain.endsWith("f")) {
|
|
73507
|
+
const contrast = Math.max(0, parseInt(block.gain) / 65536);
|
|
73508
|
+
if (contrast > 0) {
|
|
73509
|
+
filters.push(`contrast(${contrast})`);
|
|
73510
|
+
}
|
|
73511
|
+
}
|
|
73512
|
+
if (block.blacklevel && typeof block.blacklevel === "string" && block.blacklevel.endsWith("f")) {
|
|
73513
|
+
const brightness = Math.max(0, 1 + parseInt(block.blacklevel) / 327 / 100) + 0.5;
|
|
73514
|
+
if (brightness > 0) {
|
|
73515
|
+
filters.push(`brightness(${brightness})`);
|
|
73516
|
+
}
|
|
73517
|
+
}
|
|
73518
|
+
if (filters.length > 0) {
|
|
73519
|
+
img2.style.filter = filters.join(" ");
|
|
73520
|
+
}
|
|
73521
|
+
}
|
|
73235
73522
|
fragmentEl.appendChild(img2);
|
|
73236
73523
|
return fragmentEl;
|
|
73237
73524
|
} catch (error) {
|
|
@@ -73311,6 +73598,9 @@ ${l}
|
|
|
73311
73598
|
img2.style.width = "100%";
|
|
73312
73599
|
img2.style.height = "100%";
|
|
73313
73600
|
img2.style.objectFit = drawing.objectFit ?? "contain";
|
|
73601
|
+
if (drawing.objectFit === "cover") {
|
|
73602
|
+
img2.style.objectPosition = "left top";
|
|
73603
|
+
}
|
|
73314
73604
|
img2.style.display = "block";
|
|
73315
73605
|
return img2;
|
|
73316
73606
|
}
|
|
@@ -78059,13 +78349,8 @@ ${l}
|
|
|
78059
78349
|
let baseX;
|
|
78060
78350
|
let availableWidth;
|
|
78061
78351
|
if (relativeFrom === "page") {
|
|
78062
|
-
|
|
78063
|
-
|
|
78064
|
-
availableWidth = contentWidth;
|
|
78065
|
-
} else {
|
|
78066
|
-
baseX = 0;
|
|
78067
|
-
availableWidth = pageWidth != null ? pageWidth : contentWidth;
|
|
78068
|
-
}
|
|
78352
|
+
baseX = 0;
|
|
78353
|
+
availableWidth = pageWidth != null ? pageWidth : contentWidth + marginLeft + marginRight;
|
|
78069
78354
|
} else if (relativeFrom === "margin") {
|
|
78070
78355
|
baseX = contentLeft;
|
|
78071
78356
|
availableWidth = contentWidth;
|
|
@@ -79554,7 +79839,9 @@ ${l}
|
|
|
79554
79839
|
if (!isImage && !isDrawing) continue;
|
|
79555
79840
|
const drawingBlock = block;
|
|
79556
79841
|
const drawingMeasure = measure;
|
|
79557
|
-
if (!drawingBlock.anchor?.isAnchored)
|
|
79842
|
+
if (!drawingBlock.anchor?.isAnchored) {
|
|
79843
|
+
continue;
|
|
79844
|
+
}
|
|
79558
79845
|
if (isPageRelativeAnchor(drawingBlock)) {
|
|
79559
79846
|
result.push({ block: drawingBlock, measure: drawingMeasure });
|
|
79560
79847
|
}
|
|
@@ -92650,8 +92937,9 @@ ${l}
|
|
|
92650
92937
|
const isInline2 = normalizedWrap?.type === "Inline" || typeof attrs.inline === "boolean" && attrs.inline;
|
|
92651
92938
|
const display = explicitDisplay === "inline" || explicitDisplay === "block" ? explicitDisplay : isInline2 ? "inline" : "block";
|
|
92652
92939
|
const explicitObjectFit = typeof attrs.objectFit === "string" ? attrs.objectFit : void 0;
|
|
92940
|
+
const shouldCover = attrs.shouldCover === true;
|
|
92653
92941
|
const isAnchor = anchor?.isAnchored ?? (typeof attrs.isAnchor === "boolean" ? attrs.isAnchor : false);
|
|
92654
|
-
const objectFit = isAllowedObjectFit(explicitObjectFit) ? explicitObjectFit : display === "inline" ? "scale-down" : isAnchor ? "contain" : "contain";
|
|
92942
|
+
const objectFit = isAllowedObjectFit(explicitObjectFit) ? explicitObjectFit : shouldCover ? "cover" : display === "inline" ? "scale-down" : isAnchor ? "contain" : "contain";
|
|
92655
92943
|
return {
|
|
92656
92944
|
kind: "image",
|
|
92657
92945
|
id: nextBlockId("image"),
|
|
@@ -92666,7 +92954,10 @@ ${l}
|
|
|
92666
92954
|
margin: toBoxSpacing(attrs.marginOffset),
|
|
92667
92955
|
anchor,
|
|
92668
92956
|
wrap: normalizedWrap,
|
|
92669
|
-
attrs: attrsWithPm
|
|
92957
|
+
attrs: attrsWithPm,
|
|
92958
|
+
// VML image adjustments for watermark effects
|
|
92959
|
+
gain: typeof attrs.gain === "string" || typeof attrs.gain === "number" ? attrs.gain : void 0,
|
|
92960
|
+
blacklevel: typeof attrs.blacklevel === "string" || typeof attrs.blacklevel === "number" ? attrs.blacklevel : void 0
|
|
92670
92961
|
};
|
|
92671
92962
|
}
|
|
92672
92963
|
function handleImageNode(node2, context) {
|
|
@@ -96616,11 +96907,13 @@ ${l}
|
|
|
96616
96907
|
const intrinsic = getIntrinsicImageSize(block, constraints.maxWidth);
|
|
96617
96908
|
const isBlockBehindDoc = block.anchor?.behindDoc;
|
|
96618
96909
|
const isBlockWrapBehindDoc = block.wrap?.type === "None" && block.wrap?.behindDoc;
|
|
96619
|
-
const
|
|
96910
|
+
const isPageRelativeAnchor2 = block.anchor?.isAnchored && (block.anchor?.hRelativeFrom === "page" || block.anchor?.hRelativeFrom === "margin");
|
|
96911
|
+
const bypassWidthConstraint = isBlockBehindDoc || isBlockWrapBehindDoc || isPageRelativeAnchor2;
|
|
96620
96912
|
const isWidthConstraintBypassed = bypassWidthConstraint || constraints.maxWidth <= 0;
|
|
96621
96913
|
const maxWidth = isWidthConstraintBypassed ? intrinsic.width : constraints.maxWidth;
|
|
96622
96914
|
const hasNegativeVerticalPosition = block.anchor?.isAnchored && (typeof block.anchor?.offsetV === "number" && block.anchor.offsetV < 0 || typeof block.margin?.top === "number" && block.margin.top < 0);
|
|
96623
|
-
const
|
|
96915
|
+
const shouldBypassHeightConstraint = hasNegativeVerticalPosition || block.objectFit === "cover";
|
|
96916
|
+
const maxHeight = shouldBypassHeightConstraint || !constraints.maxHeight || constraints.maxHeight <= 0 ? Infinity : constraints.maxHeight;
|
|
96624
96917
|
const widthScale = maxWidth / intrinsic.width;
|
|
96625
96918
|
const heightScale = maxHeight / intrinsic.height;
|
|
96626
96919
|
const scale = Math.min(1, widthScale, heightScale);
|
|
@@ -111235,18 +111528,18 @@ ${l}
|
|
|
111235
111528
|
// Used during DOCX export to restore the original metafile format.
|
|
111236
111529
|
originalExtension: { rendered: false },
|
|
111237
111530
|
originalSrc: { rendered: false },
|
|
111238
|
-
|
|
111531
|
+
shouldCover: {
|
|
111239
111532
|
default: false,
|
|
111240
111533
|
rendered: false
|
|
111241
111534
|
},
|
|
111242
111535
|
size: {
|
|
111243
111536
|
default: {},
|
|
111244
|
-
renderDOM: ({ size: size2,
|
|
111537
|
+
renderDOM: ({ size: size2, shouldCover }) => {
|
|
111245
111538
|
let style2 = "";
|
|
111246
111539
|
let { width, height } = size2 ?? {};
|
|
111247
111540
|
if (width) style2 += `width: ${width}px;`;
|
|
111248
|
-
if (height &&
|
|
111249
|
-
style2 += `height: ${height}px; object-fit:
|
|
111541
|
+
if (height && shouldCover) {
|
|
111542
|
+
style2 += `height: ${height}px; object-fit: cover; object-position: left top;`;
|
|
111250
111543
|
} else if (height) style2 += "height: auto;";
|
|
111251
111544
|
return { style: style2 };
|
|
111252
111545
|
}
|
|
@@ -119405,6 +119698,9 @@ ${l}
|
|
|
119405
119698
|
if (!node2 || !nodeNames.includes(node2.type.name)) {
|
|
119406
119699
|
return DecorationSet.empty;
|
|
119407
119700
|
}
|
|
119701
|
+
if (node2.attrs?.vmlWatermark === true) {
|
|
119702
|
+
return DecorationSet.empty;
|
|
119703
|
+
}
|
|
119408
119704
|
const decorations = [];
|
|
119409
119705
|
if (nodeNames.includes(selection.node?.type.name)) {
|
|
119410
119706
|
decorations.push(
|
|
@@ -119487,6 +119783,7 @@ ${l}
|
|
|
119487
119783
|
const pos = Number.parseInt(wrapper.getAttribute("data-pos"), 10);
|
|
119488
119784
|
const node2 = view.state.doc.nodeAt(pos);
|
|
119489
119785
|
if (!nodeNames.includes(node2?.type.name)) return;
|
|
119786
|
+
if (node2?.attrs?.vmlWatermark === true) return;
|
|
119490
119787
|
currentWrapper = wrapper;
|
|
119491
119788
|
resizeContainer = document.createElement("div");
|
|
119492
119789
|
resizeContainer.className = "sd-editor-resize-container";
|
|
@@ -144773,7 +145070,7 @@ ${reason}`);
|
|
|
144773
145070
|
this.config.colors = shuffleArray(this.config.colors);
|
|
144774
145071
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
144775
145072
|
this.colorIndex = 0;
|
|
144776
|
-
this.version = "1.4.0-next.
|
|
145073
|
+
this.version = "1.4.0-next.2";
|
|
144777
145074
|
this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
|
|
144778
145075
|
this.superdocId = config2.superdocId || v4();
|
|
144779
145076
|
this.colors = this.config.colors;
|