@harbour-enterprises/superdoc 1.8.0-next.1 → 1.8.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.
@@ -1,6 +1,6 @@
1
1
  import { d as defineComponent, h, T as Transition, p as process$1, w as watchEffect, c as computed, r as ref, f as onMounted, X as onUnmounted, E as createElementBlock, G as openBlock, K as createBaseVNode, M as createCommentVNode, I as createVNode, v as unref } from "./vue-BnBKJwCW.es.js";
2
- import { N as NBaseLoading, u as useSuperdocStore, s as storeToRefs, a as useSelection } from "./index-DTus436U.es.js";
3
- import { C as derived, r as c, q as cB, aF as fadeInTransition, y as cM, I as warnOnce, J as useConfig, N as useTheme, aG as pxfy, P as createKey, Q as useThemeClass, aH as useCompitable, ai as _export_sfc } from "./index-BUj9aTuQ.es.js";
2
+ import { N as NBaseLoading, u as useSuperdocStore, s as storeToRefs, a as useSelection } from "./index-CQ5eyZh8.es.js";
3
+ import { C as derived, r as c, q as cB, aF as fadeInTransition, y as cM, I as warnOnce, J as useConfig, N as useTheme, aG as pxfy, P as createKey, Q as useThemeClass, aH as useCompitable, ai as _export_sfc } from "./index-Ck-OA2Y9.es.js";
4
4
  function self(vars) {
5
5
  const {
6
6
  opacityDisabled,
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const vue = require("./vue-De9wkgLl.cjs");
4
- const superdoc = require("./index-CpumvFGI.cjs");
5
- const index = require("./index-BlW_FHkN.cjs");
4
+ const superdoc = require("./index-BTaAZtKc.cjs");
5
+ const index = require("./index-3dXTFEES.cjs");
6
6
  function self(vars) {
7
7
  const {
8
8
  opacityDisabled,
@@ -27534,8 +27534,9 @@ const decode$l = (params) => {
27534
27534
  if (exportedCommentDefs?.length === 0) return;
27535
27535
  if (commentsExportType === "clean") return;
27536
27536
  const commentNodeId = node.attrs["w:id"];
27537
+ const nodeIdStr = String(commentNodeId);
27537
27538
  const originalComment = comments.find((comment) => {
27538
- return comment.commentId == commentNodeId;
27539
+ return String(comment.commentId) === nodeIdStr || String(comment.importedId) === nodeIdStr;
27539
27540
  });
27540
27541
  if (!originalComment) return;
27541
27542
  const parentCommentId = originalComment.parentCommentId;
@@ -29796,284 +29797,6 @@ const DocxHelpers = {
29796
29797
  getNewRelationshipId
29797
29798
  };
29798
29799
  const kebabCase = (str) => str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
29799
- function getCrypto() {
29800
- if (typeof globalThis === "undefined") {
29801
- return void 0;
29802
- }
29803
- const cryptoObj = globalThis.crypto ?? globalThis.msCrypto;
29804
- if (cryptoObj && typeof cryptoObj.getRandomValues === "function") {
29805
- return cryptoObj;
29806
- }
29807
- return void 0;
29808
- }
29809
- function randomBytes(length) {
29810
- const array = new Uint8Array(length);
29811
- const cryptoObj = getCrypto();
29812
- if (cryptoObj) {
29813
- cryptoObj.getRandomValues(array);
29814
- return array;
29815
- }
29816
- for (let i = 0; i < length; i++) {
29817
- array[i] = Math.floor(Math.random() * 256);
29818
- }
29819
- return array;
29820
- }
29821
- class Telemetry {
29822
- /**
29823
- * Initialize telemetry service
29824
- * @param config - Telemetry configuration
29825
- */
29826
- constructor(config2) {
29827
- this.statistics = {
29828
- nodeTypes: {},
29829
- markTypes: {},
29830
- attributes: {},
29831
- errorCount: 0
29832
- };
29833
- this.unknownElements = [];
29834
- this.errors = [];
29835
- this.fileStructure = {
29836
- totalFiles: 0,
29837
- maxDepth: 0,
29838
- totalNodes: 0,
29839
- files: []
29840
- };
29841
- this.documentInfo = null;
29842
- this.enabled = config2.enabled ?? true;
29843
- this.licenseKey = config2.licenseKey ?? Telemetry.COMMUNITY_LICENSE_KEY;
29844
- this.endpoint = config2.endpoint ?? Telemetry.DEFAULT_ENDPOINT;
29845
- this.documentGuid = config2.documentGuid;
29846
- this.documentIdentifier = config2.documentIdentifier;
29847
- this.superdocVersion = config2.superdocVersion;
29848
- this.sessionId = this.generateId();
29849
- }
29850
- static {
29851
- this.COMMUNITY_LICENSE_KEY = "community-and-eval-agplv3";
29852
- }
29853
- static {
29854
- this.DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
29855
- }
29856
- /**
29857
- * Get browser environment information
29858
- * @returns Browser information
29859
- */
29860
- getBrowserInfo() {
29861
- return {
29862
- userAgent: window.navigator.userAgent,
29863
- currentUrl: window.location.href,
29864
- hostname: window.location.hostname,
29865
- referrerUrl: document.referrer,
29866
- screenSize: {
29867
- width: window.screen.width,
29868
- height: window.screen.height
29869
- }
29870
- };
29871
- }
29872
- /**
29873
- * Track document usage event
29874
- * @param name - Event name (use TelemetryEventNames for standard events)
29875
- * @param properties - Additional properties
29876
- */
29877
- async trackUsage(name, properties = {}) {
29878
- if (!this.enabled) return;
29879
- const event = {
29880
- id: this.generateId(),
29881
- type: "usage",
29882
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
29883
- sessionId: this.sessionId,
29884
- documentGuid: this.documentGuid,
29885
- // Updated field name
29886
- documentIdentifier: this.documentIdentifier,
29887
- // Include both
29888
- superdocVersion: this.superdocVersion,
29889
- file: this.documentInfo,
29890
- browser: this.getBrowserInfo(),
29891
- name,
29892
- properties
29893
- };
29894
- await this.sendDataToTelemetry(event);
29895
- }
29896
- trackStatistic(categoryOrData, legacyData) {
29897
- let data;
29898
- if (typeof categoryOrData === "string") {
29899
- data = { ...legacyData, category: categoryOrData };
29900
- } else {
29901
- data = categoryOrData;
29902
- }
29903
- if (data.category === "node") {
29904
- this.statistics.nodeTypes[data.elementName] = (this.statistics.nodeTypes[data.elementName] || 0) + 1;
29905
- this.fileStructure.totalNodes++;
29906
- } else if (data.category === "unknown") {
29907
- const addedElement = this.unknownElements.find((e) => e.elementName === data.elementName);
29908
- if (addedElement) {
29909
- addedElement.count += 1;
29910
- addedElement.attributes = {
29911
- ...addedElement.attributes,
29912
- ...data.attributes
29913
- };
29914
- } else {
29915
- this.unknownElements.push({
29916
- elementName: data.elementName,
29917
- count: 1,
29918
- attributes: data.attributes
29919
- });
29920
- }
29921
- } else if (data.category === "error") {
29922
- this.errors.push(data);
29923
- this.statistics.errorCount++;
29924
- }
29925
- if (data.category === "node" && data.marks?.length) {
29926
- data.marks.forEach((mark) => {
29927
- this.statistics.markTypes[mark.type] = (this.statistics.markTypes[mark.type] || 0) + 1;
29928
- });
29929
- }
29930
- if (data.attributes && Object.keys(data.attributes).length) {
29931
- const styleAttributes = [
29932
- "textIndent",
29933
- "textAlign",
29934
- "spacing",
29935
- "lineHeight",
29936
- "indent",
29937
- "list-style-type",
29938
- "listLevel",
29939
- "textStyle",
29940
- "order",
29941
- "lvlText",
29942
- "lvlJc",
29943
- "listNumberingType",
29944
- "numId"
29945
- ];
29946
- Object.keys(data.attributes).forEach((attribute) => {
29947
- if (!styleAttributes.includes(attribute)) return;
29948
- this.statistics.attributes[attribute] = (this.statistics.attributes[attribute] || 0) + 1;
29949
- });
29950
- }
29951
- }
29952
- /**
29953
- * Track file structure
29954
- * @param structure - File structure information
29955
- * @param fileSource - original file
29956
- * @param documentId - document GUID
29957
- * @param documentIdentifier - document identifier (GUID or hash)
29958
- * @param internalId - document ID from settings.xml
29959
- */
29960
- async trackFileStructure(structure, fileSource, documentId, documentIdentifier, internalId) {
29961
- this.fileStructure = structure;
29962
- this.documentInfo = await this.processDocument(fileSource, {
29963
- guid: documentId,
29964
- // Updated parameter name
29965
- identifier: documentIdentifier,
29966
- // New parameter
29967
- internalId
29968
- });
29969
- }
29970
- /**
29971
- * Process document metadata
29972
- * @param file - Document file
29973
- * @param options - Additional options
29974
- * @returns Document metadata
29975
- */
29976
- async processDocument(file, options = {}) {
29977
- if (!file) {
29978
- console.warn("Telemetry: missing file source");
29979
- return null;
29980
- }
29981
- return {
29982
- guid: options.guid,
29983
- // Updated from 'id'
29984
- identifier: options.identifier,
29985
- // New field
29986
- name: file.name,
29987
- size: file.size,
29988
- lastModified: file.lastModified ? new Date(file.lastModified).toISOString() : null,
29989
- type: file.type || "docx",
29990
- internalId: options.internalId
29991
- // Microsoft's GUID if present
29992
- };
29993
- }
29994
- isTelemetryDataChanged() {
29995
- if (Object.keys(this.statistics.nodeTypes).length <= 1) return false;
29996
- return Object.keys(this.statistics.nodeTypes).length > 0 || Object.keys(this.statistics.markTypes).length > 0 || Object.keys(this.statistics.attributes).length > 0 || this.statistics.errorCount > 0 || this.fileStructure.totalFiles > 0 || this.fileStructure.maxDepth > 0 || this.fileStructure.totalNodes > 0 || this.fileStructure.files.length > 0 || this.errors.length > 0 || this.unknownElements.length > 0;
29997
- }
29998
- /**
29999
- * Sends current report
30000
- * @returns Promise that resolves when report is sent
30001
- */
30002
- async sendReport() {
30003
- if (!this.enabled || !this.isTelemetryDataChanged()) return;
30004
- const report = [
30005
- {
30006
- id: this.generateId(),
30007
- type: "parsing",
30008
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
30009
- sessionId: this.sessionId,
30010
- documentGuid: this.documentGuid,
30011
- documentIdentifier: this.documentIdentifier,
30012
- superdocVersion: this.superdocVersion,
30013
- file: this.documentInfo,
30014
- browser: this.getBrowserInfo(),
30015
- statistics: this.statistics,
30016
- fileStructure: this.fileStructure,
30017
- unknownElements: this.unknownElements,
30018
- errors: this.errors
30019
- }
30020
- ];
30021
- await this.sendDataToTelemetry(report);
30022
- }
30023
- /**
30024
- * Sends data to the service
30025
- * @param data - Payload to send
30026
- * @returns Promise that resolves when data is sent
30027
- */
30028
- async sendDataToTelemetry(data) {
30029
- try {
30030
- const response = await fetch(this.endpoint, {
30031
- method: "POST",
30032
- headers: {
30033
- "Content-Type": "application/json",
30034
- "X-License-Key": this.licenseKey
30035
- },
30036
- body: JSON.stringify(data)
30037
- });
30038
- if (!response.ok) {
30039
- throw new Error(`Upload failed: ${response.statusText}`);
30040
- } else {
30041
- this.resetStatistics();
30042
- }
30043
- } catch (error) {
30044
- console.error("Failed to upload telemetry:", error);
30045
- }
30046
- }
30047
- /**
30048
- * Generate unique identifier
30049
- * @returns Unique ID
30050
- * @private
30051
- */
30052
- generateId() {
30053
- const timestamp = Date.now();
30054
- const random = Array.from(randomBytes(4)).map((b2) => b2.toString(16).padStart(2, "0")).join("");
30055
- return `${timestamp}-${random}`;
30056
- }
30057
- /**
30058
- * Reset statistics
30059
- */
30060
- resetStatistics() {
30061
- this.statistics = {
30062
- nodeTypes: {},
30063
- markTypes: {},
30064
- attributes: {},
30065
- errorCount: 0
30066
- };
30067
- this.fileStructure = {
30068
- totalFiles: 0,
30069
- maxDepth: 0,
30070
- totalNodes: 0,
30071
- files: []
30072
- };
30073
- this.unknownElements = [];
30074
- this.errors = [];
30075
- }
30076
- }
30077
29800
  const getDefaultStyleDefinition = (defaultStyleId, docx) => {
30078
29801
  const result = { lineSpaceBefore: null, lineSpaceAfter: null };
30079
29802
  if (!defaultStyleId) return result;
@@ -30244,38 +29967,6 @@ const createDocumentJson = (docx, converter, editor) => {
30244
29967
  converter.documentOrigin = detectDocumentOrigin(docx);
30245
29968
  converter.commentThreadingProfile = detectCommentThreadingProfile(docx);
30246
29969
  }
30247
- if (converter?.telemetry) {
30248
- const files = Object.keys(docx).map((filePath) => {
30249
- const parts = filePath.split("/");
30250
- return {
30251
- filePath,
30252
- fileDepth: parts.length,
30253
- fileType: filePath.split(".").pop()
30254
- };
30255
- });
30256
- const trackStructure = (documentIdentifier = null) => converter.telemetry.trackFileStructure(
30257
- {
30258
- totalFiles: files.length,
30259
- maxDepth: Math.max(...files.map((f) => f.fileDepth)),
30260
- totalNodes: 0,
30261
- files
30262
- },
30263
- converter.fileSource,
30264
- converter.documentGuid ?? converter.documentId ?? null,
30265
- documentIdentifier ?? converter.documentId ?? null,
30266
- converter.documentInternalId
30267
- );
30268
- try {
30269
- const identifierResult = converter.getDocumentIdentifier?.();
30270
- if (identifierResult && typeof identifierResult.then === "function") {
30271
- identifierResult.then(trackStructure).catch(() => trackStructure());
30272
- } else {
30273
- trackStructure(identifierResult);
30274
- }
30275
- } catch {
30276
- trackStructure();
30277
- }
30278
- }
30279
29970
  const nodeListHandler = defaultNodeListHandler();
30280
29971
  const bodyNode = json.elements[0].elements.find((el) => el.name === "w:body");
30281
29972
  if (bodyNode) {
@@ -30318,12 +30009,6 @@ const createDocumentJson = (docx, converter, editor) => {
30318
30009
  ...bodySectPr ? { bodySectPr } : {}
30319
30010
  }
30320
30011
  };
30321
- if (result.content.length > 1) {
30322
- converter?.telemetry?.trackUsage("document_import", {
30323
- documentType: "docx",
30324
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
30325
- });
30326
- }
30327
30012
  return {
30328
30013
  pmDoc: result,
30329
30014
  savedTagsToRestore: node,
@@ -30446,16 +30131,8 @@ const createNodeListHandler = (nodeHandlers) => {
30446
30131
  );
30447
30132
  if (unhandled) {
30448
30133
  if (!context.elementName) continue;
30449
- converter?.telemetry?.trackStatistic("unknown", context);
30450
30134
  continue;
30451
30135
  } else {
30452
- converter?.telemetry?.trackStatistic("node", context);
30453
- if (context.type === "orderedList" || context.type === "bulletList") {
30454
- context.content.forEach((item) => {
30455
- const innerItemContext = getSafeElementContext([item], 0, item, `/word/${filename || "document.xml"}`);
30456
- converter?.telemetry?.trackStatistic("attributes", innerItemContext);
30457
- });
30458
- }
30459
30136
  const hasHighlightMark = nodes[0]?.marks?.find((mark) => mark.type === "highlight");
30460
30137
  if (hasHighlightMark) {
30461
30138
  converter?.docHiglightColors.add(hasHighlightMark.attrs.color.toUpperCase());
@@ -30477,26 +30154,12 @@ const createNodeListHandler = (nodeHandlers) => {
30477
30154
  } catch (error) {
30478
30155
  console.debug("Import error", error);
30479
30156
  editor?.emit("exception", { error, editor });
30480
- converter?.telemetry?.trackStatistic("error", {
30481
- type: "processing_error",
30482
- message: error.message,
30483
- name: error.name,
30484
- stack: error.stack,
30485
- fileName: `/word/${filename || "document.xml"}`
30486
- });
30487
30157
  }
30488
30158
  }
30489
30159
  return processedElements;
30490
30160
  } catch (error) {
30491
30161
  console.debug("Error during import", error);
30492
30162
  editor?.emit("exception", { error, editor });
30493
- converter?.telemetry?.trackStatistic("error", {
30494
- type: "fatal_error",
30495
- message: error.message,
30496
- name: error.name,
30497
- stack: error.stack,
30498
- fileName: `/word/${filename || "document.xml"}`
30499
- });
30500
30163
  throw error;
30501
30164
  }
30502
30165
  };
@@ -32906,7 +32569,6 @@ class SuperConverter {
32906
32569
  this.json = params?.json;
32907
32570
  this.tagsNotInSchema = ["w:body"];
32908
32571
  this.savedTagsToRestore = [];
32909
- this.telemetry = params?.telemetry || null;
32910
32572
  this.documentInternalId = null;
32911
32573
  this.fileSource = params?.fileSource || null;
32912
32574
  this.documentId = params?.documentId || null;
@@ -33199,7 +32861,7 @@ class SuperConverter {
33199
32861
  static getStoredSuperdocVersion(docx) {
33200
32862
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
33201
32863
  }
33202
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.8.0-next.1") {
32864
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.8.0-next.2") {
33203
32865
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
33204
32866
  }
33205
32867
  /**
@@ -33266,7 +32928,7 @@ class SuperConverter {
33266
32928
  return null;
33267
32929
  }
33268
32930
  /**
33269
- * Generate document hash for telemetry (async, lazy)
32931
+ * Generate document hash (async, lazy)
33270
32932
  */
33271
32933
  async #generateDocumentHash() {
33272
32934
  if (!this.fileSource) return `HASH-${Date.now()}`;