@arbidocs/blocks 0.4.114 → 0.4.115

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.
Files changed (29) hide show
  1. package/dist/{NativeDocxEditor-MBCBXYDZ.js → NativeDocxEditor-6SCZDPKK.js} +3 -3
  2. package/dist/{NativeDocxEditor-MBCBXYDZ.js.map → NativeDocxEditor-6SCZDPKK.js.map} +1 -1
  3. package/dist/{NativeDocxEditor-AQZSUGET.cjs → NativeDocxEditor-BBTLE23K.cjs} +7 -7
  4. package/dist/{NativeDocxEditor-AQZSUGET.cjs.map → NativeDocxEditor-BBTLE23K.cjs.map} +1 -1
  5. package/dist/{chunk-RUFNJRLW.cjs → chunk-ES4H653I.cjs} +4 -4
  6. package/dist/{chunk-RUFNJRLW.cjs.map → chunk-ES4H653I.cjs.map} +1 -1
  7. package/dist/{chunk-GIBRZ54P.js → chunk-FEODWQLH.js} +3 -3
  8. package/dist/{chunk-GIBRZ54P.js.map → chunk-FEODWQLH.js.map} +1 -1
  9. package/dist/{chunk-3OT37I24.js → chunk-GMDAQIRC.js} +49 -17
  10. package/dist/chunk-GMDAQIRC.js.map +1 -0
  11. package/dist/{chunk-ETBB5KMN.cjs → chunk-NL7M7VQ2.cjs} +48 -16
  12. package/dist/chunk-NL7M7VQ2.cjs.map +1 -0
  13. package/dist/{chunk-HF4PAYBM.cjs → chunk-QZLK3F2E.cjs} +5 -5
  14. package/dist/{chunk-HF4PAYBM.cjs.map → chunk-QZLK3F2E.cjs.map} +1 -1
  15. package/dist/{chunk-TKJSCHSX.js → chunk-TKI34NP5.js} +3 -3
  16. package/dist/{chunk-TKJSCHSX.js.map → chunk-TKI34NP5.js.map} +1 -1
  17. package/dist/connect/docx.cjs +6 -6
  18. package/dist/connect/docx.js +4 -4
  19. package/dist/connect/index.cjs +4 -4
  20. package/dist/connect/index.js +3 -3
  21. package/dist/docx/NativeDocxEditor.d.ts +1 -1
  22. package/dist/docx/index.cjs +46 -46
  23. package/dist/docx/index.js +3 -3
  24. package/dist/docx/review/author.d.ts +4 -0
  25. package/node_modules/@arbidocs/coedit/package.json +1 -1
  26. package/package.json +4 -4
  27. package/src/docx/styles.css +13 -1
  28. package/dist/chunk-3OT37I24.js.map +0 -1
  29. package/dist/chunk-ETBB5KMN.cjs.map +0 -1
@@ -218,6 +218,15 @@ function reviewModule() {
218
218
  };
219
219
  }
220
220
 
221
+ // src/docx/review/author.ts
222
+ var ARBI_AUTHORS = /* @__PURE__ */ new Set(["ARBI", "Assistant"]);
223
+ function isArbiAuthor(entry) {
224
+ return ARBI_AUTHORS.has((entry.author ?? "").trim());
225
+ }
226
+ function authorName(entry) {
227
+ return isArbiAuthor(entry) ? "ARBI" : entry.author || "Reviewer";
228
+ }
229
+
221
230
  // src/docx/review/commentText.ts
222
231
  var SKIP = /* @__PURE__ */ new Set(["delText", "instrText", "delInstrText", "pPr", "rPr"]);
223
232
  function inline(node) {
@@ -270,6 +279,7 @@ function useReviewItem() {
270
279
  }
271
280
  var CARD_GAP = 8;
272
281
  var CLUSTER_GAP = 24;
282
+ var BUBBLE_DROP = 32;
273
283
  var REVIEW_MARGIN_MIN_WIDTH = 900;
274
284
  var REVISION_LABELS = {
275
285
  insert: "Inserted",
@@ -315,6 +325,8 @@ function authorHue(author) {
315
325
  return Math.abs(hash) % 360;
316
326
  }
317
327
  function Avatar({ entry }) {
328
+ if (isArbiAuthor(entry))
329
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "native-docx-review-avatar", "data-arbi": "", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(ui.ArbiIcon, { size: 16, "aria-hidden": true }) });
318
330
  return /* @__PURE__ */ jsxRuntime.jsx(
319
331
  "span",
320
332
  {
@@ -330,7 +342,7 @@ function Byline({ entry, children }) {
330
342
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "native-docx-review-byline", children: [
331
343
  /* @__PURE__ */ jsxRuntime.jsx(Avatar, { entry }),
332
344
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "native-docx-review-who", children: [
333
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "native-docx-review-author", children: entry.author || "Reviewer" }),
345
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "native-docx-review-author", children: authorName(entry) }),
334
346
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "native-docx-review-meta", children: [
335
347
  kindLabel(entry),
336
348
  date && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -448,7 +460,7 @@ function Card({
448
460
  ref: cardRef,
449
461
  className: "native-docx-review-card",
450
462
  tabIndex: 0,
451
- "aria-label": `${entry.kind === "revision" ? "Change" : "Comment"} by ${entry.author || "reviewer"}`,
463
+ "aria-label": `${entry.kind === "revision" ? "Change" : "Comment"} by ${authorName(entry)}`,
452
464
  onKeyDown: (event) => {
453
465
  if (event.target !== event.currentTarget) return;
454
466
  if ((event.key === "Enter" || event.key === " ") && entry.activatable) {
@@ -817,7 +829,7 @@ function DocxEditorReviewRail({
817
829
  "data-testid": "review-marker",
818
830
  "data-kind": comment ? "comment" : first.kind,
819
831
  "data-active": cluster === shown || void 0,
820
- "aria-label": cluster.entries.length === 1 ? `${first.author}: ${first.text.slice(0, 60)}` : `${cluster.entries.length} comments and changes`,
832
+ "aria-label": cluster.entries.length === 1 ? `${authorName(first)}: ${first.text.slice(0, 60)}` : `${cluster.entries.length} comments and changes`,
821
833
  "aria-expanded": layout === "compact" ? cluster === shown : void 0,
822
834
  style: { top: cluster.y },
823
835
  onClick: () => {
@@ -843,7 +855,7 @@ function DocxEditorReviewRail({
843
855
  "data-state": "open",
844
856
  "aria-label": "Review",
845
857
  style: {
846
- top: draft ? draft.anchorY * scale : shown?.y ?? 0,
858
+ top: (draft ? draft.anchorY * scale : shown?.y ?? 0) + BUBBLE_DROP,
847
859
  width: Math.max(220, Math.min(340, area.width - 56))
848
860
  },
849
861
  onKeyDown: (event) => {
@@ -1058,7 +1070,7 @@ function DocxCommentActivity() {
1058
1070
  children: [
1059
1071
  /* @__PURE__ */ jsxRuntime.jsx(ui.DialogHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.DialogTitle, { children: "Document comment" }) }),
1060
1072
  thread.map((entry) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1 border-b pb-4 last:border-0", children: [
1061
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium", children: entry.author || "Reviewer" }),
1073
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium", children: authorName(entry) }),
1062
1074
  /* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": "docx-full-comment-text", children: /* @__PURE__ */ jsxRuntime.jsx(ui.AiMarkdown, { allowHtml: false, children: commentText(entry) }) })
1063
1075
  ] }, entry.key)),
1064
1076
  statuses.map(([id, run]) => /* @__PURE__ */ jsxRuntime.jsxs("p", { role: "status", className: "text-sm", children: [
@@ -1251,13 +1263,12 @@ function DocxMentions({
1251
1263
  const replies = review.items.filter(
1252
1264
  (entry) => entry.kind === "comment" && entry.parentId === commentId
1253
1265
  );
1254
- const author = replies.at(-1)?.author || target.author;
1255
- const agent = mentions.find((person) => person.kind === "agent" && person.name === author);
1256
- if (agent || author === "ARBI" || author === "Assistant")
1257
- prefixMention(
1258
- field,
1259
- author === "ARBI" || author === "Assistant" ? "ARBI" : agent?.name || "ARBI"
1260
- );
1266
+ const last = replies.at(-1) ?? target;
1267
+ const agent = mentions.find(
1268
+ (person) => person.kind === "agent" && person.name === last.author
1269
+ );
1270
+ if (agent || isArbiAuthor(last))
1271
+ prefixMention(field, isArbiAuthor(last) ? "ARBI" : agent?.name || "ARBI");
1261
1272
  },
1262
1273
  onInputCapture: (event) => {
1263
1274
  const field = event.target;
@@ -4398,6 +4409,22 @@ function DefinedTermButtons() {
4398
4409
  }
4399
4410
  );
4400
4411
  }
4412
+ var DOCUMENT_STATES = {
4413
+ "co-editing": {
4414
+ label: "Co-editing",
4415
+ title: "Edits sync live with everyone who has this document open"
4416
+ },
4417
+ "read-only": {
4418
+ label: "Read-only",
4419
+ title: "This copy cannot be edited: an earlier version, or the last saved copy"
4420
+ },
4421
+ draft: { label: "Private draft", title: "Only you can see this until you save it" }
4422
+ };
4423
+ function DocumentStateBadge({ state }) {
4424
+ if (!state) return null;
4425
+ const { label, title } = DOCUMENT_STATES[state];
4426
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { "data-state": state, title, children: label });
4427
+ }
4401
4428
  function DocxRibbon({
4402
4429
  onSave,
4403
4430
  badge,
@@ -4875,8 +4902,13 @@ function NativeDocxEditor({
4875
4902
  ...adapter.imageGeneration
4876
4903
  },
4877
4904
  badge: (
4878
- // Says the document is shared live, in place of a title row above the ribbon.
4879
- ready.room && ready.canEdit && !snapshot ? /* @__PURE__ */ jsxRuntime.jsx("span", { title: "Edits sync live with everyone who has this document open", children: "Co-edit mode" }) : void 0
4905
+ // The document's state, in place of a title row above the ribbon.
4906
+ /* @__PURE__ */ jsxRuntime.jsx(
4907
+ DocumentStateBadge,
4908
+ {
4909
+ state: snapshot || !ready.canEdit ? "read-only" : ready.room ? "co-editing" : isDraft ? "draft" : void 0
4910
+ }
4911
+ )
4880
4912
  )
4881
4913
  }
4882
4914
  ),
@@ -5024,5 +5056,5 @@ exports.useReview = useReview;
5024
5056
  exports.useReviewItem = useReviewItem;
5025
5057
  exports.useTrackedOrNoted = useTrackedOrNoted;
5026
5058
  exports.withDirectEditing = withDirectEditing;
5027
- //# sourceMappingURL=chunk-ETBB5KMN.cjs.map
5028
- //# sourceMappingURL=chunk-ETBB5KMN.cjs.map
5059
+ //# sourceMappingURL=chunk-NL7M7VQ2.cjs.map
5060
+ //# sourceMappingURL=chunk-NL7M7VQ2.cjs.map