wordinweb 0.3.8 → 0.3.9

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.
@@ -5367,7 +5367,7 @@ function parseParagraph(p, ctx) {
5367
5367
  if (ctx.revisionColor) {
5368
5368
  const author = revisionAuthor(mark);
5369
5369
  para.markRevisionColor = ctx.revisionColor(author);
5370
- para.markChanges = [{ id: `mark-${para.markRevision}:${attr(mark, "id") ?? ""}`, kind: para.markRevision, author, date: attr(mark, "date"), label: deleted ? "Deleted paragraph mark" : "Inserted paragraph mark" }];
5370
+ para.markChanges = [{ id: `mark-${para.markRevision}:${attr(mark, "id") ?? ""}`, kind: para.markRevision, author, date: attr(mark, "date"), dateUtc: attr(mark, "dateUtc"), label: deleted ? "Deleted paragraph mark" : "Inserted paragraph mark" }];
5371
5371
  }
5372
5372
  }
5373
5373
  }
@@ -5381,7 +5381,7 @@ function parseParagraph(p, ctx) {
5381
5381
  }
5382
5382
  var MOVE_COLOR = "#008000";
5383
5383
  function formatChange(el2, what) {
5384
- return { id: `${localName(el2.name)}:${attr(el2, "id") ?? ""}`, kind: "format", author: revisionAuthor(el2), date: attr(el2, "date"), label: `Formatted: ${what}` };
5384
+ return { id: `${localName(el2.name)}:${attr(el2, "id") ?? ""}`, kind: "format", author: revisionAuthor(el2), date: attr(el2, "date"), dateUtc: attr(el2, "dateUtc"), label: `Formatted: ${what}` };
5385
5385
  }
5386
5386
  function revisionAuthor(el2) {
5387
5387
  return attr(el2, "author") ?? "Unknown";
@@ -5677,7 +5677,7 @@ function parseParaChildren(parent, ctx, out, field, bookmarks) {
5677
5677
  const author = revisionAuthor(el2);
5678
5678
  const color = ctx.revisionColor ? move ? MOVE_COLOR : ctx.revisionColor(author) : isInsert ? "#188038" : "#D93025";
5679
5679
  const double = move && !!ctx.revisionColor;
5680
- const change = ctx.revisionColor ? { id: `${ln}:${attr(el2, "id") ?? ""}`, kind: ln, author, date: attr(el2, "date"), label: move ? isInsert ? "Moved to" : "Moved from" : isInsert ? "Inserted" : "Deleted" } : void 0;
5680
+ const change = ctx.revisionColor ? { id: `${ln}:${attr(el2, "id") ?? ""}`, kind: ln, author, date: attr(el2, "date"), dateUtc: attr(el2, "dateUtc"), label: move ? isInsert ? "Moved to" : "Moved from" : isInsert ? "Inserted" : "Deleted" } : void 0;
5681
5681
  const style = (r) => {
5682
5682
  r.props = {
5683
5683
  ...r.props,
@@ -7490,7 +7490,7 @@ function parseTable(tbl, ctx) {
7490
7490
  if (rowChange) {
7491
7491
  const inserted = localName(rowChange.name) === "ins";
7492
7492
  const author = revisionAuthor(rowChange);
7493
- const change = { id: `row-${localName(rowChange.name)}:${attr(rowChange, "id") ?? ""}`, kind: inserted ? "ins" : "del", author, date: attr(rowChange, "date"), label: inserted ? "Inserted row" : "Deleted row" };
7493
+ const change = { id: `row-${localName(rowChange.name)}:${attr(rowChange, "id") ?? ""}`, kind: inserted ? "ins" : "del", author, date: attr(rowChange, "date"), dateUtc: attr(rowChange, "dateUtc"), label: inserted ? "Inserted row" : "Deleted row" };
7494
7494
  const color = ctx.revisionColor(author);
7495
7495
  for (const run of runsOfBlocks(row.cells.flatMap((cell) => cell.blocks))) {
7496
7496
  run.props = { ...run.props, color, ...inserted ? { underline: "single" } : { strike: true } };
@@ -7900,6 +7900,8 @@ var _DocxDocument = class _DocxDocument {
7900
7900
  /** Retained commentsExtended.xml tree (comment threading), when present. */
7901
7901
  this.commentsExtPart = null;
7902
7902
  this.commentsExtRoot = null;
7903
+ /** True UTC comment times from commentsExtensible.xml, by the comment's last w14:paraId. */
7904
+ this.commentDateUtc = /* @__PURE__ */ new Map();
7903
7905
  this.commentsExtDirty = false;
7904
7906
  /** Conditional table formats per table style id, keyed by the Styles object
7905
7907
  * so re-parsing styles.xml (edits) naturally invalidates the cache. */
@@ -8127,6 +8129,17 @@ var _DocxDocument = class _DocxDocument {
8127
8129
  this.commentsPart = docDir + "comments.xml";
8128
8130
  this.commentsRoot = commentsRoot;
8129
8131
  }
8132
+ const durableOf = /* @__PURE__ */ new Map();
8133
+ for (const id of this.readXmlOptional(docDir + "commentsIds.xml")?.children ?? []) {
8134
+ const paraId2 = attr(id, "paraId");
8135
+ const durableId = attr(id, "durableId");
8136
+ if (paraId2 && durableId) durableOf.set(durableId, paraId2);
8137
+ }
8138
+ for (const ex of this.readXmlOptional(docDir + "commentsExtensible.xml")?.children ?? []) {
8139
+ const paraId2 = durableOf.get(attr(ex, "durableId") ?? "");
8140
+ const dateUtc = attr(ex, "dateUtc");
8141
+ if (paraId2 && dateUtc) this.commentDateUtc.set(paraId2, dateUtc);
8142
+ }
8130
8143
  const commentsExtRoot = this.readXmlOptional(docDir + "commentsExtended.xml");
8131
8144
  if (commentsExtRoot) {
8132
8145
  this.commentsExtPart = docDir + "commentsExtended.xml";
@@ -8746,6 +8759,7 @@ var _DocxDocument = class _DocxDocument {
8746
8759
  author: attr(c, "author") ?? "",
8747
8760
  initials: attr(c, "initials"),
8748
8761
  date: attr(c, "date"),
8762
+ dateUtc: paraId2 ? this.commentDateUtc.get(paraId2) : void 0,
8749
8763
  text: paras.join("\n"),
8750
8764
  paraId: paraId2
8751
8765
  });
@@ -22659,6 +22673,22 @@ function paragraphHasContent(p) {
22659
22673
  return false;
22660
22674
  }
22661
22675
 
22676
+ // ../core/src/word-date.ts
22677
+ function wordDate(at = /* @__PURE__ */ new Date()) {
22678
+ const two = (n) => String(n).padStart(2, "0");
22679
+ return `${at.getFullYear()}-${two(at.getMonth() + 1)}-${two(at.getDate())}T${two(at.getHours())}:${two(at.getMinutes())}:${two(at.getSeconds())}Z`;
22680
+ }
22681
+ function readWordDate(date, dateUtc) {
22682
+ if (dateUtc) {
22683
+ const utc = new Date(dateUtc);
22684
+ if (!isNaN(utc.getTime())) return utc;
22685
+ }
22686
+ const m = date?.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?/);
22687
+ if (!m) return null;
22688
+ const local = new Date(+m[1], +m[2] - 1, +m[3], +m[4], +m[5], +(m[6] ?? 0));
22689
+ return isNaN(local.getTime()) ? null : local;
22690
+ }
22691
+
22662
22692
  // ../core/src/checkbox.ts
22663
22693
  function checkboxStateElement(run, t) {
22664
22694
  if (!run?.content) return void 0;
@@ -25006,8 +25036,7 @@ function renderComments(doc, root, bindings, zoom, options) {
25006
25036
  const card = document.createElement("div");
25007
25037
  card.className = "dxw-comment-card";
25008
25038
  card.dataset.dxwCommentId = comment.id;
25009
- const when = comment.date ? new Date(comment.date) : null;
25010
- const dateText = when && !isNaN(when.getTime()) ? when.toLocaleDateString() : "";
25039
+ const dateText = readWordDate(comment.date, comment.dateUtc)?.toLocaleDateString() ?? "";
25011
25040
  const head = document.createElement("div");
25012
25041
  head.className = "dxw-comment-head";
25013
25042
  const avatar = document.createElement("div");
@@ -25057,10 +25086,9 @@ function renderComments(doc, root, bindings, zoom, options) {
25057
25086
  const rAuthor = document.createElement("div");
25058
25087
  rAuthor.className = "dxw-comment-author";
25059
25088
  rAuthor.textContent = reply.author || "Reply";
25060
- const rWhen = reply.date ? new Date(reply.date) : null;
25061
25089
  const rMeta = document.createElement("div");
25062
25090
  rMeta.className = "dxw-comment-date";
25063
- rMeta.textContent = rWhen && !isNaN(rWhen.getTime()) ? rWhen.toLocaleDateString() : "";
25091
+ rMeta.textContent = readWordDate(reply.date, reply.dateUtc)?.toLocaleDateString() ?? "";
25064
25092
  rWho.append(rAuthor, rMeta);
25065
25093
  rHead.append(rAvatar, rWho);
25066
25094
  const rBody = document.createElement("div");
@@ -26240,6 +26268,8 @@ export {
26240
26268
  checkboxStateElement,
26241
26269
  toggleCheckbox,
26242
26270
  isSafeUrl,
26271
+ wordDate,
26272
+ readWordDate,
26243
26273
  renderToDom,
26244
26274
  paintsSettled,
26245
26275
  printStylesheet,
@@ -26252,4 +26282,4 @@ export {
26252
26282
  cfb/cfb.js:
26253
26283
  (*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com *)
26254
26284
  */
26255
- //# sourceMappingURL=chunk-LBXLKYTZ.js.map
26285
+ //# sourceMappingURL=chunk-CXXISL5X.js.map