@harbour-enterprises/superdoc 1.0.0-beta.61 → 1.0.0-beta.62
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-CuTlpPQO.cjs → PdfViewer-Dm3bZ_1B.cjs} +1 -1
- package/dist/chunks/{PdfViewer-BHLsVrSe.es.js → PdfViewer-rmkhzY1H.es.js} +1 -1
- package/dist/chunks/{index-DeFp1DEO.es.js → index-5vPj3xiM.es.js} +3 -3
- package/dist/chunks/{index-E5x6cBKw.cjs → index-VQNmJYMh.cjs} +3 -3
- package/dist/chunks/{index-u8dj63PM-VgHx1nNP.cjs → index-XOsGE2PW-BL-ekicF.cjs} +1 -1
- package/dist/chunks/{index-u8dj63PM-Bfomc8Z6.es.js → index-XOsGE2PW-hNAnvmsK.es.js} +1 -1
- package/dist/chunks/{super-editor.es-CI3WoKIG.es.js → super-editor.es-BIEE4joF.es.js} +190 -62
- package/dist/chunks/{super-editor.es-nY9_xN6Z.cjs → super-editor.es-CxtR72x8.cjs} +190 -62
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-DaSkPzA9.js → converter-Bo9KIIo_.js} +164 -46
- package/dist/super-editor/chunks/{docx-zipper-Cx1zgQ8B.js → docx-zipper-Cw0Rbwvk.js} +1 -1
- package/dist/super-editor/chunks/{editor-45pxcsTR.js → editor-v-i8Oo_X.js} +28 -18
- package/dist/super-editor/chunks/{index-u8dj63PM.js → index-XOsGE2PW.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-C4OC-AnI.js → toolbar-CiKH0Ttu.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.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 +192 -64
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -42131,11 +42131,71 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
42131
42131
|
return JSON.parse(xmljs.xml2json(newXml, null, 2));
|
|
42132
42132
|
}
|
|
42133
42133
|
/**
|
|
42134
|
-
*
|
|
42134
|
+
* Checks if an element name matches the expected local name, with or without namespace prefix.
|
|
42135
|
+
* This helper supports custom namespace prefixes in DOCX files (e.g., 'op:Properties', 'custom:property').
|
|
42136
|
+
*
|
|
42137
|
+
* @private
|
|
42138
|
+
* @static
|
|
42139
|
+
* @param {string|undefined|null} elementName - The element name to check (may include namespace prefix)
|
|
42140
|
+
* @param {string} expectedLocalName - The expected local name without prefix
|
|
42141
|
+
* @returns {boolean} True if the element name matches (with or without prefix)
|
|
42142
|
+
*
|
|
42143
|
+
* @example
|
|
42144
|
+
* // Exact match without prefix
|
|
42145
|
+
* _matchesElementName('Properties', 'Properties') // => true
|
|
42146
|
+
*
|
|
42147
|
+
* @example
|
|
42148
|
+
* // Match with namespace prefix
|
|
42149
|
+
* _matchesElementName('op:Properties', 'Properties') // => true
|
|
42150
|
+
* _matchesElementName('custom:property', 'property') // => true
|
|
42151
|
+
*
|
|
42152
|
+
* @example
|
|
42153
|
+
* // No match
|
|
42154
|
+
* _matchesElementName('SomeOtherElement', 'Properties') // => false
|
|
42155
|
+
* _matchesElementName(':Properties', 'Properties') // => false (empty prefix)
|
|
42156
|
+
*/
|
|
42157
|
+
static _matchesElementName(elementName, expectedLocalName) {
|
|
42158
|
+
if (!elementName || typeof elementName !== "string") return false;
|
|
42159
|
+
if (!expectedLocalName) return false;
|
|
42160
|
+
if (elementName === expectedLocalName) return true;
|
|
42161
|
+
if (elementName.endsWith(`:${expectedLocalName}`)) {
|
|
42162
|
+
const prefix2 = elementName.slice(0, -(expectedLocalName.length + 1));
|
|
42163
|
+
return prefix2.length > 0;
|
|
42164
|
+
}
|
|
42165
|
+
return false;
|
|
42166
|
+
}
|
|
42167
|
+
/**
|
|
42168
|
+
* Generic method to get a stored custom property from docx.
|
|
42169
|
+
* Supports both standard and custom namespace prefixes (e.g., 'op:Properties', 'custom:property').
|
|
42170
|
+
*
|
|
42135
42171
|
* @static
|
|
42136
42172
|
* @param {Array} docx - Array of docx file objects
|
|
42137
42173
|
* @param {string} propertyName - Name of the property to retrieve
|
|
42138
42174
|
* @returns {string|null} The property value or null if not found
|
|
42175
|
+
*
|
|
42176
|
+
* Returns null in the following cases:
|
|
42177
|
+
* - docx array is empty or doesn't contain 'docProps/custom.xml'
|
|
42178
|
+
* - custom.xml cannot be parsed
|
|
42179
|
+
* - Properties element is not found (with or without namespace prefix)
|
|
42180
|
+
* - Property with the specified name is not found
|
|
42181
|
+
* - Property has malformed structure (missing nested elements or text)
|
|
42182
|
+
* - Any error occurs during parsing or retrieval
|
|
42183
|
+
*
|
|
42184
|
+
* @example
|
|
42185
|
+
* // Standard property without namespace prefix
|
|
42186
|
+
* const version = SuperConverter.getStoredCustomProperty(docx, 'SuperdocVersion');
|
|
42187
|
+
* // => '1.2.3'
|
|
42188
|
+
*
|
|
42189
|
+
* @example
|
|
42190
|
+
* // Property with namespace prefix (e.g., from Office 365)
|
|
42191
|
+
* const guid = SuperConverter.getStoredCustomProperty(docx, 'DocumentGuid');
|
|
42192
|
+
* // Works with both 'Properties' and 'op:Properties' elements
|
|
42193
|
+
* // => 'abc-123-def-456'
|
|
42194
|
+
*
|
|
42195
|
+
* @example
|
|
42196
|
+
* // Non-existent property
|
|
42197
|
+
* const missing = SuperConverter.getStoredCustomProperty(docx, 'NonExistent');
|
|
42198
|
+
* // => null
|
|
42139
42199
|
*/
|
|
42140
42200
|
static getStoredCustomProperty(docx, propertyName) {
|
|
42141
42201
|
try {
|
|
@@ -42144,10 +42204,16 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
42144
42204
|
const converter = new _SuperConverter2();
|
|
42145
42205
|
const content = customXml.content;
|
|
42146
42206
|
const contentJson = converter.parseXmlToJson(content);
|
|
42147
|
-
const properties = contentJson
|
|
42207
|
+
const properties = contentJson?.elements?.find((el) => _SuperConverter2._matchesElementName(el.name, "Properties"));
|
|
42148
42208
|
if (!properties?.elements) return null;
|
|
42149
|
-
const property2 = properties.elements.find(
|
|
42209
|
+
const property2 = properties.elements.find(
|
|
42210
|
+
(el) => _SuperConverter2._matchesElementName(el.name, "property") && el.attributes?.name === propertyName
|
|
42211
|
+
);
|
|
42150
42212
|
if (!property2) return null;
|
|
42213
|
+
if (!property2.elements?.[0]?.elements?.[0]?.text) {
|
|
42214
|
+
console.warn(`Malformed property structure for "${propertyName}"`);
|
|
42215
|
+
return null;
|
|
42216
|
+
}
|
|
42151
42217
|
return property2.elements[0].elements[0].text;
|
|
42152
42218
|
} catch (e) {
|
|
42153
42219
|
console.warn(`Error getting custom property ${propertyName}:`, e);
|
|
@@ -42155,60 +42221,112 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
42155
42221
|
}
|
|
42156
42222
|
}
|
|
42157
42223
|
/**
|
|
42158
|
-
* Generic method to set a stored custom property in docx
|
|
42224
|
+
* Generic method to set a stored custom property in docx.
|
|
42225
|
+
* Supports both standard and custom namespace prefixes (e.g., 'op:Properties', 'custom:property').
|
|
42226
|
+
*
|
|
42159
42227
|
* @static
|
|
42160
|
-
* @param {Object} docx - The docx object to store the property in
|
|
42228
|
+
* @param {Object} docx - The docx object to store the property in (converted XML structure)
|
|
42161
42229
|
* @param {string} propertyName - Name of the property
|
|
42162
42230
|
* @param {string|Function} value - Value or function that returns the value
|
|
42163
42231
|
* @param {boolean} preserveExisting - If true, won't overwrite existing values
|
|
42164
|
-
* @returns {string} The stored value
|
|
42232
|
+
* @returns {string|null} The stored value, or null if Properties element is not found
|
|
42233
|
+
*
|
|
42234
|
+
* @throws {Error} If an error occurs during property setting (logged as warning)
|
|
42235
|
+
*
|
|
42236
|
+
* @example
|
|
42237
|
+
* // Set a new property
|
|
42238
|
+
* const value = SuperConverter.setStoredCustomProperty(docx, 'MyProperty', 'MyValue');
|
|
42239
|
+
* // => 'MyValue'
|
|
42240
|
+
*
|
|
42241
|
+
* @example
|
|
42242
|
+
* // Set a property with a function
|
|
42243
|
+
* const guid = SuperConverter.setStoredCustomProperty(docx, 'DocumentGuid', () => uuidv4());
|
|
42244
|
+
* // => 'abc-123-def-456'
|
|
42245
|
+
*
|
|
42246
|
+
* @example
|
|
42247
|
+
* // Preserve existing value
|
|
42248
|
+
* SuperConverter.setStoredCustomProperty(docx, 'MyProperty', 'NewValue', true);
|
|
42249
|
+
* // => 'MyValue' (original value preserved)
|
|
42250
|
+
*
|
|
42251
|
+
* @example
|
|
42252
|
+
* // Works with namespace prefixes
|
|
42253
|
+
* // If docx has 'op:Properties' and 'op:property' elements, this will handle them correctly
|
|
42254
|
+
* const version = SuperConverter.setStoredCustomProperty(docx, 'Version', '2.0.0');
|
|
42255
|
+
* // => '2.0.0'
|
|
42165
42256
|
*/
|
|
42166
42257
|
static setStoredCustomProperty(docx, propertyName, value, preserveExisting = false) {
|
|
42167
|
-
|
|
42168
|
-
|
|
42169
|
-
|
|
42170
|
-
|
|
42171
|
-
|
|
42172
|
-
|
|
42173
|
-
|
|
42174
|
-
|
|
42175
|
-
|
|
42176
|
-
|
|
42177
|
-
|
|
42178
|
-
|
|
42179
|
-
|
|
42180
|
-
|
|
42181
|
-
|
|
42182
|
-
|
|
42183
|
-
|
|
42184
|
-
|
|
42185
|
-
|
|
42186
|
-
|
|
42187
|
-
|
|
42188
|
-
|
|
42189
|
-
|
|
42190
|
-
|
|
42191
|
-
|
|
42192
|
-
name:
|
|
42193
|
-
|
|
42194
|
-
|
|
42195
|
-
|
|
42196
|
-
|
|
42197
|
-
|
|
42198
|
-
|
|
42199
|
-
|
|
42200
|
-
|
|
42201
|
-
|
|
42202
|
-
|
|
42203
|
-
|
|
42204
|
-
|
|
42258
|
+
try {
|
|
42259
|
+
const customLocation = "docProps/custom.xml";
|
|
42260
|
+
if (!docx[customLocation]) docx[customLocation] = generateCustomXml();
|
|
42261
|
+
const customXml = docx[customLocation];
|
|
42262
|
+
const properties = customXml.elements?.find((el) => _SuperConverter2._matchesElementName(el.name, "Properties"));
|
|
42263
|
+
if (!properties) return null;
|
|
42264
|
+
if (!properties.elements) properties.elements = [];
|
|
42265
|
+
let property2 = properties.elements.find(
|
|
42266
|
+
(el) => _SuperConverter2._matchesElementName(el.name, "property") && el.attributes?.name === propertyName
|
|
42267
|
+
);
|
|
42268
|
+
if (property2 && preserveExisting) {
|
|
42269
|
+
if (!property2.elements?.[0]?.elements?.[0]?.text) {
|
|
42270
|
+
console.warn(`Malformed existing property structure for "${propertyName}"`);
|
|
42271
|
+
return null;
|
|
42272
|
+
}
|
|
42273
|
+
return property2.elements[0].elements[0].text;
|
|
42274
|
+
}
|
|
42275
|
+
const finalValue = typeof value === "function" ? value() : value;
|
|
42276
|
+
if (!property2) {
|
|
42277
|
+
const existingPids = properties.elements.filter((el) => el.attributes?.pid).map((el) => parseInt(el.attributes.pid, 10)).filter(Number.isInteger);
|
|
42278
|
+
const pid = existingPids.length > 0 ? Math.max(...existingPids) + 1 : 2;
|
|
42279
|
+
property2 = {
|
|
42280
|
+
type: "element",
|
|
42281
|
+
name: "property",
|
|
42282
|
+
attributes: {
|
|
42283
|
+
name: propertyName,
|
|
42284
|
+
fmtid: "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
|
|
42285
|
+
pid
|
|
42286
|
+
},
|
|
42287
|
+
elements: [
|
|
42288
|
+
{
|
|
42289
|
+
type: "element",
|
|
42290
|
+
name: "vt:lpwstr",
|
|
42291
|
+
elements: [
|
|
42292
|
+
{
|
|
42293
|
+
type: "text",
|
|
42294
|
+
text: finalValue
|
|
42295
|
+
}
|
|
42296
|
+
]
|
|
42297
|
+
}
|
|
42298
|
+
]
|
|
42299
|
+
};
|
|
42300
|
+
properties.elements.push(property2);
|
|
42301
|
+
} else {
|
|
42302
|
+
if (!property2.elements?.[0]?.elements?.[0]) {
|
|
42303
|
+
console.warn(`Malformed property structure for "${propertyName}", recreating structure`);
|
|
42304
|
+
property2.elements = [
|
|
42305
|
+
{
|
|
42306
|
+
type: "element",
|
|
42307
|
+
name: "vt:lpwstr",
|
|
42308
|
+
elements: [
|
|
42309
|
+
{
|
|
42310
|
+
type: "text",
|
|
42311
|
+
text: finalValue
|
|
42312
|
+
}
|
|
42313
|
+
]
|
|
42314
|
+
}
|
|
42315
|
+
];
|
|
42316
|
+
} else {
|
|
42317
|
+
property2.elements[0].elements[0].text = finalValue;
|
|
42318
|
+
}
|
|
42319
|
+
}
|
|
42320
|
+
return finalValue;
|
|
42321
|
+
} catch (e) {
|
|
42322
|
+
console.warn(`Error setting custom property ${propertyName}:`, e);
|
|
42323
|
+
return null;
|
|
42205
42324
|
}
|
|
42206
|
-
return finalValue;
|
|
42207
42325
|
}
|
|
42208
42326
|
static getStoredSuperdocVersion(docx) {
|
|
42209
42327
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
42210
42328
|
}
|
|
42211
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.
|
|
42329
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.62") {
|
|
42212
42330
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
42213
42331
|
}
|
|
42214
42332
|
/**
|
|
@@ -59397,7 +59515,7 @@ const isHeadless = (editor) => {
|
|
|
59397
59515
|
const shouldSkipNodeView = (editor) => {
|
|
59398
59516
|
return isHeadless(editor);
|
|
59399
59517
|
};
|
|
59400
|
-
const summaryVersion = "1.0.0-beta.
|
|
59518
|
+
const summaryVersion = "1.0.0-beta.62";
|
|
59401
59519
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
59402
59520
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
59403
59521
|
function mapAttributes(attrs) {
|
|
@@ -60186,7 +60304,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
60186
60304
|
{ default: remarkStringify },
|
|
60187
60305
|
{ default: remarkGfm }
|
|
60188
60306
|
] = await Promise.all([
|
|
60189
|
-
Promise.resolve().then(() => require("./index-
|
|
60307
|
+
Promise.resolve().then(() => require("./index-XOsGE2PW-BL-ekicF.cjs")),
|
|
60190
60308
|
Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
|
|
60191
60309
|
Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
|
|
60192
60310
|
Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
|
|
@@ -60391,7 +60509,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
60391
60509
|
* Process collaboration migrations
|
|
60392
60510
|
*/
|
|
60393
60511
|
processCollaborationMigrations() {
|
|
60394
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.
|
|
60512
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.62");
|
|
60395
60513
|
if (!this.options.ydoc) return;
|
|
60396
60514
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
60397
60515
|
let docVersion = metaMap.get("version");
|
|
@@ -64364,12 +64482,6 @@ const Engines = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
64364
64482
|
resolveSpacingIndent: resolveSpacingIndent$1,
|
|
64365
64483
|
scaleWrapPolygon
|
|
64366
64484
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
64367
|
-
const extractHeaderFooterSpace = (margins) => {
|
|
64368
|
-
return {
|
|
64369
|
-
headerSpace: margins?.header ?? 0,
|
|
64370
|
-
footerSpace: margins?.footer ?? 0
|
|
64371
|
-
};
|
|
64372
|
-
};
|
|
64373
64485
|
const hasParagraphStyleContext = (context) => {
|
|
64374
64486
|
return Boolean(context?.docx);
|
|
64375
64487
|
};
|
|
@@ -72621,6 +72733,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
72621
72733
|
container.style.height = `${data.height}px`;
|
|
72622
72734
|
container.style.top = `${Math.max(0, offset2)}px`;
|
|
72623
72735
|
container.style.zIndex = "1";
|
|
72736
|
+
container.style.overflow = "visible";
|
|
72624
72737
|
let footerYOffset = 0;
|
|
72625
72738
|
if (kind === "footer" && data.fragments.length > 0) {
|
|
72626
72739
|
const contentHeight = typeof data.contentHeight === "number" ? data.contentHeight : data.fragments.reduce((max2, f2) => {
|
|
@@ -81633,7 +81746,14 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
81633
81746
|
leftJustifiedMarkerSpace = markerBoxWidth + gutterWidth;
|
|
81634
81747
|
}
|
|
81635
81748
|
}
|
|
81636
|
-
|
|
81749
|
+
let initialAvailableWidth;
|
|
81750
|
+
const isFirstLineIndentMode = wordLayout?.firstLineIndentMode === true;
|
|
81751
|
+
const textStartPx = wordLayout?.textStartPx;
|
|
81752
|
+
if (isFirstLineIndentMode && typeof textStartPx === "number" && textStartPx > 0) {
|
|
81753
|
+
initialAvailableWidth = Math.max(1, maxWidth - textStartPx - indentRight);
|
|
81754
|
+
} else {
|
|
81755
|
+
initialAvailableWidth = Math.max(1, contentWidth - firstLineOffset - leftJustifiedMarkerSpace);
|
|
81756
|
+
}
|
|
81637
81757
|
const tabStops = buildTabStopsPx(
|
|
81638
81758
|
indent,
|
|
81639
81759
|
block.attrs?.tabs,
|
|
@@ -83609,7 +83729,9 @@ class HeaderFooterLayoutAdapter {
|
|
|
83609
83729
|
const batch = {};
|
|
83610
83730
|
let hasBlocks = false;
|
|
83611
83731
|
descriptors.forEach((descriptor) => {
|
|
83612
|
-
if (!descriptor.variant)
|
|
83732
|
+
if (!descriptor.variant) {
|
|
83733
|
+
return;
|
|
83734
|
+
}
|
|
83613
83735
|
const blocks = __privateMethod$1(this, _HeaderFooterLayoutAdapter_instances, getBlocks_fn).call(this, descriptor);
|
|
83614
83736
|
if (blocks && blocks.length > 0) {
|
|
83615
83737
|
batch[descriptor.variant] = blocks;
|
|
@@ -86876,14 +86998,20 @@ computeHeaderFooterConstraints_fn = function() {
|
|
|
86876
86998
|
const margins = __privateGet$1(this, _layoutOptions).margins ?? DEFAULT_MARGINS;
|
|
86877
86999
|
const marginLeft = margins.left ?? DEFAULT_MARGINS.left;
|
|
86878
87000
|
const marginRight = margins.right ?? DEFAULT_MARGINS.right;
|
|
86879
|
-
const
|
|
86880
|
-
if (!Number.isFinite(
|
|
87001
|
+
const bodyContentWidth = pageSize.w - (marginLeft + marginRight);
|
|
87002
|
+
if (!Number.isFinite(bodyContentWidth) || bodyContentWidth <= 0) {
|
|
86881
87003
|
return null;
|
|
86882
87004
|
}
|
|
86883
|
-
const
|
|
86884
|
-
const
|
|
87005
|
+
const measurementWidth = bodyContentWidth;
|
|
87006
|
+
const marginTop = margins.top ?? DEFAULT_MARGINS.top;
|
|
87007
|
+
const marginBottom = margins.bottom ?? DEFAULT_MARGINS.bottom;
|
|
87008
|
+
const headerMargin = margins.header ?? 0;
|
|
87009
|
+
const footerMargin = margins.footer ?? 0;
|
|
87010
|
+
const headerContentSpace = Math.max(marginTop - headerMargin, 0);
|
|
87011
|
+
const footerContentSpace = Math.max(marginBottom - footerMargin, 0);
|
|
87012
|
+
const height = Math.max(headerContentSpace, footerContentSpace, 1);
|
|
86885
87013
|
return {
|
|
86886
|
-
width,
|
|
87014
|
+
width: measurementWidth,
|
|
86887
87015
|
height,
|
|
86888
87016
|
// Pass actual page dimensions for page-relative anchor positioning in headers/footers
|
|
86889
87017
|
pageWidth: pageSize.w,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ref, onMounted, onUnmounted, computed, createElementBlock, openBlock, withModifiers, createElementVNode, withDirectives, unref, vModelText, createCommentVNode, nextTick } from "vue";
|
|
2
|
-
import { T as TextSelection } from "./chunks/converter-
|
|
3
|
-
import { _ as _export_sfc } from "./chunks/editor-
|
|
2
|
+
import { T as TextSelection } from "./chunks/converter-Bo9KIIo_.js";
|
|
3
|
+
import { _ as _export_sfc } from "./chunks/editor-v-i8Oo_X.js";
|
|
4
4
|
const DEFAULT_API_ENDPOINT = "https://sd-dev-express-gateway-i6xtm.ondigitalocean.app/insights";
|
|
5
5
|
const SYSTEM_PROMPT = "You are an expert copywriter and you are immersed in a document editor. You are to provide document related text responses based on the user prompts. Only write what is asked for. Do not provide explanations. Try to keep placeholders as short as possible. Do not output your prompt. Your instructions are: ";
|
|
6
6
|
async function baseInsightsFetch(payload, options = {}) {
|
|
@@ -42431,11 +42431,71 @@ const _SuperConverter = class _SuperConverter {
|
|
|
42431
42431
|
return JSON.parse(xmljs.xml2json(newXml, null, 2));
|
|
42432
42432
|
}
|
|
42433
42433
|
/**
|
|
42434
|
-
*
|
|
42434
|
+
* Checks if an element name matches the expected local name, with or without namespace prefix.
|
|
42435
|
+
* This helper supports custom namespace prefixes in DOCX files (e.g., 'op:Properties', 'custom:property').
|
|
42436
|
+
*
|
|
42437
|
+
* @private
|
|
42438
|
+
* @static
|
|
42439
|
+
* @param {string|undefined|null} elementName - The element name to check (may include namespace prefix)
|
|
42440
|
+
* @param {string} expectedLocalName - The expected local name without prefix
|
|
42441
|
+
* @returns {boolean} True if the element name matches (with or without prefix)
|
|
42442
|
+
*
|
|
42443
|
+
* @example
|
|
42444
|
+
* // Exact match without prefix
|
|
42445
|
+
* _matchesElementName('Properties', 'Properties') // => true
|
|
42446
|
+
*
|
|
42447
|
+
* @example
|
|
42448
|
+
* // Match with namespace prefix
|
|
42449
|
+
* _matchesElementName('op:Properties', 'Properties') // => true
|
|
42450
|
+
* _matchesElementName('custom:property', 'property') // => true
|
|
42451
|
+
*
|
|
42452
|
+
* @example
|
|
42453
|
+
* // No match
|
|
42454
|
+
* _matchesElementName('SomeOtherElement', 'Properties') // => false
|
|
42455
|
+
* _matchesElementName(':Properties', 'Properties') // => false (empty prefix)
|
|
42456
|
+
*/
|
|
42457
|
+
static _matchesElementName(elementName, expectedLocalName) {
|
|
42458
|
+
if (!elementName || typeof elementName !== "string") return false;
|
|
42459
|
+
if (!expectedLocalName) return false;
|
|
42460
|
+
if (elementName === expectedLocalName) return true;
|
|
42461
|
+
if (elementName.endsWith(`:${expectedLocalName}`)) {
|
|
42462
|
+
const prefix = elementName.slice(0, -(expectedLocalName.length + 1));
|
|
42463
|
+
return prefix.length > 0;
|
|
42464
|
+
}
|
|
42465
|
+
return false;
|
|
42466
|
+
}
|
|
42467
|
+
/**
|
|
42468
|
+
* Generic method to get a stored custom property from docx.
|
|
42469
|
+
* Supports both standard and custom namespace prefixes (e.g., 'op:Properties', 'custom:property').
|
|
42470
|
+
*
|
|
42435
42471
|
* @static
|
|
42436
42472
|
* @param {Array} docx - Array of docx file objects
|
|
42437
42473
|
* @param {string} propertyName - Name of the property to retrieve
|
|
42438
42474
|
* @returns {string|null} The property value or null if not found
|
|
42475
|
+
*
|
|
42476
|
+
* Returns null in the following cases:
|
|
42477
|
+
* - docx array is empty or doesn't contain 'docProps/custom.xml'
|
|
42478
|
+
* - custom.xml cannot be parsed
|
|
42479
|
+
* - Properties element is not found (with or without namespace prefix)
|
|
42480
|
+
* - Property with the specified name is not found
|
|
42481
|
+
* - Property has malformed structure (missing nested elements or text)
|
|
42482
|
+
* - Any error occurs during parsing or retrieval
|
|
42483
|
+
*
|
|
42484
|
+
* @example
|
|
42485
|
+
* // Standard property without namespace prefix
|
|
42486
|
+
* const version = SuperConverter.getStoredCustomProperty(docx, 'SuperdocVersion');
|
|
42487
|
+
* // => '1.2.3'
|
|
42488
|
+
*
|
|
42489
|
+
* @example
|
|
42490
|
+
* // Property with namespace prefix (e.g., from Office 365)
|
|
42491
|
+
* const guid = SuperConverter.getStoredCustomProperty(docx, 'DocumentGuid');
|
|
42492
|
+
* // Works with both 'Properties' and 'op:Properties' elements
|
|
42493
|
+
* // => 'abc-123-def-456'
|
|
42494
|
+
*
|
|
42495
|
+
* @example
|
|
42496
|
+
* // Non-existent property
|
|
42497
|
+
* const missing = SuperConverter.getStoredCustomProperty(docx, 'NonExistent');
|
|
42498
|
+
* // => null
|
|
42439
42499
|
*/
|
|
42440
42500
|
static getStoredCustomProperty(docx, propertyName) {
|
|
42441
42501
|
try {
|
|
@@ -42444,10 +42504,16 @@ const _SuperConverter = class _SuperConverter {
|
|
|
42444
42504
|
const converter = new _SuperConverter();
|
|
42445
42505
|
const content = customXml.content;
|
|
42446
42506
|
const contentJson = converter.parseXmlToJson(content);
|
|
42447
|
-
const properties = contentJson
|
|
42507
|
+
const properties = contentJson?.elements?.find((el) => _SuperConverter._matchesElementName(el.name, "Properties"));
|
|
42448
42508
|
if (!properties?.elements) return null;
|
|
42449
|
-
const property = properties.elements.find(
|
|
42509
|
+
const property = properties.elements.find(
|
|
42510
|
+
(el) => _SuperConverter._matchesElementName(el.name, "property") && el.attributes?.name === propertyName
|
|
42511
|
+
);
|
|
42450
42512
|
if (!property) return null;
|
|
42513
|
+
if (!property.elements?.[0]?.elements?.[0]?.text) {
|
|
42514
|
+
console.warn(`Malformed property structure for "${propertyName}"`);
|
|
42515
|
+
return null;
|
|
42516
|
+
}
|
|
42451
42517
|
return property.elements[0].elements[0].text;
|
|
42452
42518
|
} catch (e) {
|
|
42453
42519
|
console.warn(`Error getting custom property ${propertyName}:`, e);
|
|
@@ -42455,60 +42521,112 @@ const _SuperConverter = class _SuperConverter {
|
|
|
42455
42521
|
}
|
|
42456
42522
|
}
|
|
42457
42523
|
/**
|
|
42458
|
-
* Generic method to set a stored custom property in docx
|
|
42524
|
+
* Generic method to set a stored custom property in docx.
|
|
42525
|
+
* Supports both standard and custom namespace prefixes (e.g., 'op:Properties', 'custom:property').
|
|
42526
|
+
*
|
|
42459
42527
|
* @static
|
|
42460
|
-
* @param {Object} docx - The docx object to store the property in
|
|
42528
|
+
* @param {Object} docx - The docx object to store the property in (converted XML structure)
|
|
42461
42529
|
* @param {string} propertyName - Name of the property
|
|
42462
42530
|
* @param {string|Function} value - Value or function that returns the value
|
|
42463
42531
|
* @param {boolean} preserveExisting - If true, won't overwrite existing values
|
|
42464
|
-
* @returns {string} The stored value
|
|
42532
|
+
* @returns {string|null} The stored value, or null if Properties element is not found
|
|
42533
|
+
*
|
|
42534
|
+
* @throws {Error} If an error occurs during property setting (logged as warning)
|
|
42535
|
+
*
|
|
42536
|
+
* @example
|
|
42537
|
+
* // Set a new property
|
|
42538
|
+
* const value = SuperConverter.setStoredCustomProperty(docx, 'MyProperty', 'MyValue');
|
|
42539
|
+
* // => 'MyValue'
|
|
42540
|
+
*
|
|
42541
|
+
* @example
|
|
42542
|
+
* // Set a property with a function
|
|
42543
|
+
* const guid = SuperConverter.setStoredCustomProperty(docx, 'DocumentGuid', () => uuidv4());
|
|
42544
|
+
* // => 'abc-123-def-456'
|
|
42545
|
+
*
|
|
42546
|
+
* @example
|
|
42547
|
+
* // Preserve existing value
|
|
42548
|
+
* SuperConverter.setStoredCustomProperty(docx, 'MyProperty', 'NewValue', true);
|
|
42549
|
+
* // => 'MyValue' (original value preserved)
|
|
42550
|
+
*
|
|
42551
|
+
* @example
|
|
42552
|
+
* // Works with namespace prefixes
|
|
42553
|
+
* // If docx has 'op:Properties' and 'op:property' elements, this will handle them correctly
|
|
42554
|
+
* const version = SuperConverter.setStoredCustomProperty(docx, 'Version', '2.0.0');
|
|
42555
|
+
* // => '2.0.0'
|
|
42465
42556
|
*/
|
|
42466
42557
|
static setStoredCustomProperty(docx, propertyName, value, preserveExisting = false) {
|
|
42467
|
-
|
|
42468
|
-
|
|
42469
|
-
|
|
42470
|
-
|
|
42471
|
-
|
|
42472
|
-
|
|
42473
|
-
|
|
42474
|
-
|
|
42475
|
-
|
|
42476
|
-
|
|
42477
|
-
|
|
42478
|
-
|
|
42479
|
-
|
|
42480
|
-
|
|
42481
|
-
|
|
42482
|
-
|
|
42483
|
-
|
|
42484
|
-
|
|
42485
|
-
|
|
42486
|
-
|
|
42487
|
-
|
|
42488
|
-
|
|
42489
|
-
|
|
42490
|
-
|
|
42491
|
-
|
|
42492
|
-
name:
|
|
42493
|
-
|
|
42494
|
-
|
|
42495
|
-
|
|
42496
|
-
|
|
42497
|
-
|
|
42498
|
-
|
|
42499
|
-
|
|
42500
|
-
|
|
42501
|
-
|
|
42502
|
-
|
|
42503
|
-
|
|
42504
|
-
|
|
42558
|
+
try {
|
|
42559
|
+
const customLocation = "docProps/custom.xml";
|
|
42560
|
+
if (!docx[customLocation]) docx[customLocation] = generateCustomXml();
|
|
42561
|
+
const customXml = docx[customLocation];
|
|
42562
|
+
const properties = customXml.elements?.find((el) => _SuperConverter._matchesElementName(el.name, "Properties"));
|
|
42563
|
+
if (!properties) return null;
|
|
42564
|
+
if (!properties.elements) properties.elements = [];
|
|
42565
|
+
let property = properties.elements.find(
|
|
42566
|
+
(el) => _SuperConverter._matchesElementName(el.name, "property") && el.attributes?.name === propertyName
|
|
42567
|
+
);
|
|
42568
|
+
if (property && preserveExisting) {
|
|
42569
|
+
if (!property.elements?.[0]?.elements?.[0]?.text) {
|
|
42570
|
+
console.warn(`Malformed existing property structure for "${propertyName}"`);
|
|
42571
|
+
return null;
|
|
42572
|
+
}
|
|
42573
|
+
return property.elements[0].elements[0].text;
|
|
42574
|
+
}
|
|
42575
|
+
const finalValue = typeof value === "function" ? value() : value;
|
|
42576
|
+
if (!property) {
|
|
42577
|
+
const existingPids = properties.elements.filter((el) => el.attributes?.pid).map((el) => parseInt(el.attributes.pid, 10)).filter(Number.isInteger);
|
|
42578
|
+
const pid = existingPids.length > 0 ? Math.max(...existingPids) + 1 : 2;
|
|
42579
|
+
property = {
|
|
42580
|
+
type: "element",
|
|
42581
|
+
name: "property",
|
|
42582
|
+
attributes: {
|
|
42583
|
+
name: propertyName,
|
|
42584
|
+
fmtid: "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
|
|
42585
|
+
pid
|
|
42586
|
+
},
|
|
42587
|
+
elements: [
|
|
42588
|
+
{
|
|
42589
|
+
type: "element",
|
|
42590
|
+
name: "vt:lpwstr",
|
|
42591
|
+
elements: [
|
|
42592
|
+
{
|
|
42593
|
+
type: "text",
|
|
42594
|
+
text: finalValue
|
|
42595
|
+
}
|
|
42596
|
+
]
|
|
42597
|
+
}
|
|
42598
|
+
]
|
|
42599
|
+
};
|
|
42600
|
+
properties.elements.push(property);
|
|
42601
|
+
} else {
|
|
42602
|
+
if (!property.elements?.[0]?.elements?.[0]) {
|
|
42603
|
+
console.warn(`Malformed property structure for "${propertyName}", recreating structure`);
|
|
42604
|
+
property.elements = [
|
|
42605
|
+
{
|
|
42606
|
+
type: "element",
|
|
42607
|
+
name: "vt:lpwstr",
|
|
42608
|
+
elements: [
|
|
42609
|
+
{
|
|
42610
|
+
type: "text",
|
|
42611
|
+
text: finalValue
|
|
42612
|
+
}
|
|
42613
|
+
]
|
|
42614
|
+
}
|
|
42615
|
+
];
|
|
42616
|
+
} else {
|
|
42617
|
+
property.elements[0].elements[0].text = finalValue;
|
|
42618
|
+
}
|
|
42619
|
+
}
|
|
42620
|
+
return finalValue;
|
|
42621
|
+
} catch (e) {
|
|
42622
|
+
console.warn(`Error setting custom property ${propertyName}:`, e);
|
|
42623
|
+
return null;
|
|
42505
42624
|
}
|
|
42506
|
-
return finalValue;
|
|
42507
42625
|
}
|
|
42508
42626
|
static getStoredSuperdocVersion(docx) {
|
|
42509
42627
|
return _SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
42510
42628
|
}
|
|
42511
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.0.0-beta.
|
|
42629
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.0.0-beta.62") {
|
|
42512
42630
|
return _SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
|
|
42513
42631
|
}
|
|
42514
42632
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as process$1, aJ as commonjsGlobal, B as Buffer, aK as getDefaultExportFromCjs, aL as getContentTypesFromXml, aM as xmljs } from "./converter-
|
|
1
|
+
import { p as process$1, aJ as commonjsGlobal, B as Buffer, aK as getDefaultExportFromCjs, aL as getContentTypesFromXml, aM as xmljs } from "./converter-Bo9KIIo_.js";
|
|
2
2
|
function commonjsRequire(path) {
|
|
3
3
|
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
4
4
|
}
|