@arbidocs/blocks 0.4.158 → 0.4.159

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 (172) hide show
  1. package/dist/{ConnectedNativeDocxComparison-64RDIFEI.cjs → ConnectedNativeDocxComparison-R6RU5TZE.cjs} +12 -11
  2. package/dist/{ConnectedNativeDocxComparison-64RDIFEI.cjs.map → ConnectedNativeDocxComparison-R6RU5TZE.cjs.map} +1 -1
  3. package/dist/{ConnectedStreamedWordArtifact-GYBCBAJZ.js → ConnectedNativeDocxComparison-XMZ5KLD4.js} +11 -10
  4. package/dist/{ConnectedStreamedWordArtifact-GYBCBAJZ.js.map → ConnectedNativeDocxComparison-XMZ5KLD4.js.map} +1 -1
  5. package/dist/{ConnectedNativeDocxEditor-UAAICR4X.cjs → ConnectedNativeDocxEditor-LBATSM3M.cjs} +11 -10
  6. package/dist/{ConnectedNativeDocxEditor-UAAICR4X.cjs.map → ConnectedNativeDocxEditor-LBATSM3M.cjs.map} +1 -1
  7. package/dist/{ConnectedNativeDocxEditor-OT5DLWCM.js → ConnectedNativeDocxEditor-NGUK2AX6.js} +9 -8
  8. package/dist/{ConnectedNativeDocxEditor-OT5DLWCM.js.map → ConnectedNativeDocxEditor-NGUK2AX6.js.map} +1 -1
  9. package/dist/{ConnectedStreamedWordArtifact-AJXPNTT3.cjs → ConnectedStreamedWordArtifact-CWFR6A37.cjs} +12 -11
  10. package/dist/ConnectedStreamedWordArtifact-CWFR6A37.cjs.map +1 -0
  11. package/dist/{ConnectedNativeDocxComparison-JOWYEINS.js → ConnectedStreamedWordArtifact-IXRJ7MUE.js} +11 -10
  12. package/dist/{ConnectedNativeDocxComparison-JOWYEINS.js.map → ConnectedStreamedWordArtifact-IXRJ7MUE.js.map} +1 -1
  13. package/dist/{NativeDocxEditor-M3I776GD.cjs → NativeDocxEditor-T2PJIZMU.cjs} +9 -7
  14. package/dist/{NativeDocxEditor-M3I776GD.cjs.map → NativeDocxEditor-T2PJIZMU.cjs.map} +1 -1
  15. package/dist/{NativeDocxEditor-JBQMH3MP.js → NativeDocxEditor-TBTBD6TC.js} +5 -3
  16. package/dist/{NativeDocxEditor-JBQMH3MP.js.map → NativeDocxEditor-TBTBD6TC.js.map} +1 -1
  17. package/dist/{WorkspaceTableView-FQPJQWUE.js → WorkspaceTableView-DWUE4VQF.js} +7 -6
  18. package/dist/WorkspaceTableView-DWUE4VQF.js.map +1 -0
  19. package/dist/{WorkspaceTableView-CZEFIAVT.cjs → WorkspaceTableView-EYLEUZZT.cjs} +9 -8
  20. package/dist/WorkspaceTableView-EYLEUZZT.cjs.map +1 -0
  21. package/dist/agents/index.cjs +241 -241
  22. package/dist/agents/index.js +7 -7
  23. package/dist/calls/index.cjs +3 -3
  24. package/dist/calls/index.js +2 -2
  25. package/dist/chat/index.cjs +1 -1
  26. package/dist/chat/index.js +1 -1
  27. package/dist/{chunk-RJUXSXBH.cjs → chunk-2BHDRVVL.cjs} +18 -8
  28. package/dist/chunk-2BHDRVVL.cjs.map +1 -0
  29. package/dist/chunk-2R3GGNPA.js +151 -0
  30. package/dist/chunk-2R3GGNPA.js.map +1 -0
  31. package/dist/{chunk-Y7PPQ7UT.js → chunk-3OCNUKGX.js} +4 -4
  32. package/dist/{chunk-Y7PPQ7UT.js.map → chunk-3OCNUKGX.js.map} +1 -1
  33. package/dist/{chunk-D3WFIFRY.cjs → chunk-3VW7ZXQ6.cjs} +211 -5
  34. package/dist/chunk-3VW7ZXQ6.cjs.map +1 -0
  35. package/dist/{chunk-JSQEAPTC.cjs → chunk-4GITK3Q5.cjs} +398 -75
  36. package/dist/chunk-4GITK3Q5.cjs.map +1 -0
  37. package/dist/{chunk-7KWUQQIB.js → chunk-5ZIYPZYE.js} +3 -3
  38. package/dist/{chunk-7KWUQQIB.js.map → chunk-5ZIYPZYE.js.map} +1 -1
  39. package/dist/{chunk-AUDUNQO6.cjs → chunk-6QAAIDQQ.cjs} +50 -50
  40. package/dist/{chunk-AUDUNQO6.cjs.map → chunk-6QAAIDQQ.cjs.map} +1 -1
  41. package/dist/{chunk-V3HG3LK3.js → chunk-7UENVUA6.js} +4 -4
  42. package/dist/{chunk-V3HG3LK3.js.map → chunk-7UENVUA6.js.map} +1 -1
  43. package/dist/{chunk-EWCJXUBP.js → chunk-AVXRXPII.js} +3 -3
  44. package/dist/{chunk-EWCJXUBP.js.map → chunk-AVXRXPII.js.map} +1 -1
  45. package/dist/{chunk-TAWPVD6C.cjs → chunk-B3FMUFAW.cjs} +3 -3
  46. package/dist/{chunk-TAWPVD6C.cjs.map → chunk-B3FMUFAW.cjs.map} +1 -1
  47. package/dist/{chunk-7IRSCMNK.js → chunk-BGXWPVHR.js} +3 -3
  48. package/dist/{chunk-7IRSCMNK.js.map → chunk-BGXWPVHR.js.map} +1 -1
  49. package/dist/chunk-DAN7EJ4O.js +482 -0
  50. package/dist/chunk-DAN7EJ4O.js.map +1 -0
  51. package/dist/{chunk-ZAVEMQ37.cjs → chunk-DWZXSPMB.cjs} +3 -3
  52. package/dist/{chunk-ZAVEMQ37.cjs.map → chunk-DWZXSPMB.cjs.map} +1 -1
  53. package/dist/chunk-E4H5H2C3.cjs +18 -0
  54. package/dist/{chunk-DVIQWBDM.cjs.map → chunk-E4H5H2C3.cjs.map} +1 -1
  55. package/dist/{chunk-VY4UFXTM.cjs → chunk-ETJFC6MO.cjs} +4 -4
  56. package/dist/{chunk-VY4UFXTM.cjs.map → chunk-ETJFC6MO.cjs.map} +1 -1
  57. package/dist/{chunk-FGI3YFQH.js → chunk-FTZ45WHY.js} +4 -4
  58. package/dist/{chunk-FGI3YFQH.js.map → chunk-FTZ45WHY.js.map} +1 -1
  59. package/dist/{chunk-FBSIWJSG.cjs → chunk-GC2FSPSQ.cjs} +6 -6
  60. package/dist/{chunk-FBSIWJSG.cjs.map → chunk-GC2FSPSQ.cjs.map} +1 -1
  61. package/dist/{chunk-TQIY2SVY.cjs → chunk-GFVIFXWT.cjs} +5 -5
  62. package/dist/{chunk-TQIY2SVY.cjs.map → chunk-GFVIFXWT.cjs.map} +1 -1
  63. package/dist/chunk-JPWPR6QU.cjs +485 -0
  64. package/dist/chunk-JPWPR6QU.cjs.map +1 -0
  65. package/dist/{chunk-KQYPP72K.js → chunk-JTJCCL2E.js} +212 -9
  66. package/dist/chunk-JTJCCL2E.js.map +1 -0
  67. package/dist/{chunk-P6FMKXAB.js → chunk-KFMRBZQK.js} +16 -6
  68. package/dist/chunk-KFMRBZQK.js.map +1 -0
  69. package/dist/{chunk-VMFLWFXK.js → chunk-MNG7N6M2.js} +4 -4
  70. package/dist/{chunk-VMFLWFXK.js.map → chunk-MNG7N6M2.js.map} +1 -1
  71. package/dist/chunk-NMZI3K6R.cjs +159 -0
  72. package/dist/chunk-NMZI3K6R.cjs.map +1 -0
  73. package/dist/{chunk-UYC5BJCB.cjs → chunk-NPLGB4LI.cjs} +5 -5
  74. package/dist/{chunk-UYC5BJCB.cjs.map → chunk-NPLGB4LI.cjs.map} +1 -1
  75. package/dist/{chunk-SCK3GAE5.cjs → chunk-P2YM67Y5.cjs} +5 -5
  76. package/dist/{chunk-SCK3GAE5.cjs.map → chunk-P2YM67Y5.cjs.map} +1 -1
  77. package/dist/{chunk-VE6S6NRQ.js → chunk-P6RIBIVN.js} +4 -4
  78. package/dist/{chunk-VE6S6NRQ.js.map → chunk-P6RIBIVN.js.map} +1 -1
  79. package/dist/chunk-Q2XGM372.cjs +18 -0
  80. package/dist/{chunk-GWGUZ5X6.cjs.map → chunk-Q2XGM372.cjs.map} +1 -1
  81. package/dist/{chunk-FWIBFGUQ.cjs → chunk-QJFJ5JBF.cjs} +3 -3
  82. package/dist/{chunk-FWIBFGUQ.cjs.map → chunk-QJFJ5JBF.cjs.map} +1 -1
  83. package/dist/{chunk-2DQHFJNP.js → chunk-QKR5LWDO.js} +7 -7
  84. package/dist/{chunk-2DQHFJNP.js.map → chunk-QKR5LWDO.js.map} +1 -1
  85. package/dist/{chunk-GDRLM2EX.js → chunk-RATEAOKT.js} +3 -3
  86. package/dist/{chunk-GDRLM2EX.js.map → chunk-RATEAOKT.js.map} +1 -1
  87. package/dist/{chunk-NFI46I77.cjs → chunk-TQUYWUEE.cjs} +11 -157
  88. package/dist/chunk-TQUYWUEE.cjs.map +1 -0
  89. package/dist/{chunk-ECERC6TI.js → chunk-VHJHY7TT.js} +3 -3
  90. package/dist/{chunk-ECERC6TI.js.map → chunk-VHJHY7TT.js.map} +1 -1
  91. package/dist/{chunk-ZO7PJMCO.js → chunk-WU34CHU5.js} +3 -3
  92. package/dist/{chunk-ZO7PJMCO.js.map → chunk-WU34CHU5.js.map} +1 -1
  93. package/dist/{chunk-ONTUMV74.js → chunk-XER3JLC7.js} +398 -78
  94. package/dist/chunk-XER3JLC7.js.map +1 -0
  95. package/dist/{chunk-LY37J3AC.cjs → chunk-YF3QUHKN.cjs} +4 -4
  96. package/dist/{chunk-LY37J3AC.cjs.map → chunk-YF3QUHKN.cjs.map} +1 -1
  97. package/dist/{chunk-Y73X65FF.js → chunk-ZDOKJD44.js} +5 -144
  98. package/dist/chunk-ZDOKJD44.js.map +1 -0
  99. package/dist/collaboration/index.cjs +1 -1
  100. package/dist/collaboration/index.js +1 -1
  101. package/dist/connect/docx.cjs +15 -14
  102. package/dist/connect/docx.js +11 -10
  103. package/dist/connect/index.cjs +542 -540
  104. package/dist/connect/index.cjs.map +1 -1
  105. package/dist/connect/index.js +27 -25
  106. package/dist/connect/index.js.map +1 -1
  107. package/dist/connect/viewer.cjs +90 -69
  108. package/dist/connect/viewer.cjs.map +1 -1
  109. package/dist/connect/viewer.js +40 -19
  110. package/dist/connect/viewer.js.map +1 -1
  111. package/dist/connection/viewer/ViewerPdfPane.d.ts +7 -1
  112. package/dist/document-tools/AdoptSignatureDialog.d.ts +39 -4
  113. package/dist/document-tools/PlaceMySignatureButton.d.ts +16 -0
  114. package/dist/document-tools/SavedSignatureSettings.d.ts +10 -0
  115. package/dist/document-tools/index.cjs +38 -23
  116. package/dist/document-tools/index.d.ts +2 -0
  117. package/dist/document-tools/index.js +6 -3
  118. package/dist/document-tools/viewer/AnnotatedPdfViewer.d.ts +10 -1
  119. package/dist/document-tools/viewer/SignatureRequestEditor.d.ts +7 -4
  120. package/dist/document-tools/viewer/index.cjs +184 -18
  121. package/dist/document-tools/viewer/index.cjs.map +1 -1
  122. package/dist/document-tools/viewer/index.js +184 -18
  123. package/dist/document-tools/viewer/index.js.map +1 -1
  124. package/dist/docx/NativeDocxEditor.d.ts +5 -0
  125. package/dist/docx/index.cjs +61 -47
  126. package/dist/docx/index.d.ts +1 -0
  127. package/dist/docx/index.js +5 -3
  128. package/dist/docx/signatures/SignatureFields.d.ts +50 -0
  129. package/dist/facts/index.cjs +56 -56
  130. package/dist/facts/index.js +6 -6
  131. package/dist/files/index.cjs +239 -239
  132. package/dist/files/index.js +6 -6
  133. package/dist/home/index.cjs +2 -2
  134. package/dist/home/index.js +2 -2
  135. package/dist/index.cjs +409 -409
  136. package/dist/index.js +14 -14
  137. package/dist/retrieval/index.cjs +1 -1
  138. package/dist/retrieval/index.js +1 -1
  139. package/dist/settings/index.cjs +187 -186
  140. package/dist/settings/index.js +4 -3
  141. package/dist/shell/index.cjs +3 -3
  142. package/dist/shell/index.js +3 -3
  143. package/dist/studio/index.cjs +3 -3
  144. package/dist/studio/index.js +3 -3
  145. package/dist/workflow-canvas/index.cjs +19 -19
  146. package/dist/workflow-canvas/index.js +7 -7
  147. package/node_modules/@arbidocs/coedit/dist/commands.cjs +109 -16
  148. package/node_modules/@arbidocs/coedit/dist/commands.cjs.map +1 -1
  149. package/node_modules/@arbidocs/coedit/dist/commands.d.cts +84 -1
  150. package/node_modules/@arbidocs/coedit/dist/commands.d.ts +84 -1
  151. package/node_modules/@arbidocs/coedit/dist/commands.js +99 -17
  152. package/node_modules/@arbidocs/coedit/dist/commands.js.map +1 -1
  153. package/node_modules/@arbidocs/coedit/package.json +1 -1
  154. package/package.json +5 -5
  155. package/src/docx/styles.css +50 -0
  156. package/dist/ConnectedStreamedWordArtifact-AJXPNTT3.cjs.map +0 -1
  157. package/dist/WorkspaceTableView-CZEFIAVT.cjs.map +0 -1
  158. package/dist/WorkspaceTableView-FQPJQWUE.js.map +0 -1
  159. package/dist/chunk-6MG62I5B.cjs +0 -272
  160. package/dist/chunk-6MG62I5B.cjs.map +0 -1
  161. package/dist/chunk-D3WFIFRY.cjs.map +0 -1
  162. package/dist/chunk-DVIQWBDM.cjs +0 -18
  163. package/dist/chunk-EQB3WELX.js +0 -269
  164. package/dist/chunk-EQB3WELX.js.map +0 -1
  165. package/dist/chunk-GWGUZ5X6.cjs +0 -18
  166. package/dist/chunk-JSQEAPTC.cjs.map +0 -1
  167. package/dist/chunk-KQYPP72K.js.map +0 -1
  168. package/dist/chunk-NFI46I77.cjs.map +0 -1
  169. package/dist/chunk-ONTUMV74.js.map +0 -1
  170. package/dist/chunk-P6FMKXAB.js.map +0 -1
  171. package/dist/chunk-RJUXSXBH.cjs.map +0 -1
  172. package/dist/chunk-Y73X65FF.js.map +0 -1
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { AdoptSignatureDialog } from './chunk-DAN7EJ4O.js';
2
3
  import { FactPassageItem } from './chunk-HFZ45FD3.js';
3
4
  import { stylesXml, groupDefinitions, definitionLabels, filterTermGroups, docxPackage, documentXml, esc } from './chunk-DIB4JYUY.js';
4
5
  import { filterMentionCandidates, MentionMenu, findMentionQuery, listOptionId, extractMentions, useListKeyNav } from './chunk-AA3PT6KR.js';
@@ -10,14 +11,15 @@ import React4, { createContext, useContext, useState, useRef, useCallback, useEf
10
11
  import { createPortal } from 'react-dom';
11
12
  import { collectReviewItems, revisionItemsOf } from '@docx-editor.dev/core/store';
12
13
  import { useDocxEditor, ReviewRailContext, useEditorSnapshot, useEditorState, useChromeTranslate, DocxEditor, useParagraphStyle, normalizeImageBytes, usePageSetup, useEditorCommand } from '@docx-editor.dev/react';
13
- import { MessageSquarePlus, MessageSquare, PencilLine, ChevronLeft, ChevronRight, X, ChevronUp, ChevronDown, CheckCheck, RotateCcw, CircleCheck, Trash2, Check, SendHorizontal, Loader2, Sparkles, Type, Pilcrow, UsersRound, RefreshCw, WifiOff, Download, Save, Ellipsis, BookA, Blocks, Link2, Superscript, NotebookText, RefreshCcw, Columns2, Settings2, BetweenHorizontalStart, BetweenHorizontalEnd, BetweenVerticalStart, BetweenVerticalEnd, Merge, Split, Heading, AlignVerticalJustifyStart, AlignVerticalJustifyCenter, AlignVerticalJustifyEnd, RotateCw, FlipHorizontal2, FlipVertical2, Scaling, RectangleVertical, RectangleHorizontal, FileText, SeparatorHorizontal, Captions } from 'lucide-react';
14
+ import { MessageSquarePlus, MessageSquare, PencilLine, ChevronLeft, ChevronRight, X, ChevronUp, ChevronDown, CheckCheck, RotateCcw, CircleCheck, Trash2, Check, SendHorizontal, Loader2, Sparkles, PenLine, Type, Pilcrow, UsersRound, RefreshCw, WifiOff, Download, Save, Ellipsis, BookA, Blocks, Signature, Link2, Superscript, NotebookText, RefreshCcw, Columns2, Settings2, BetweenHorizontalStart, BetweenHorizontalEnd, BetweenVerticalStart, BetweenVerticalEnd, Merge, Split, Heading, AlignVerticalJustifyStart, AlignVerticalJustifyCenter, AlignVerticalJustifyEnd, RotateCw, FlipHorizontal2, FlipVertical2, Scaling, RectangleVertical, RectangleHorizontal, FileText, SeparatorHorizontal, Captions } from 'lucide-react';
14
15
  import * as Y from 'yjs';
15
16
  import { DOCUMENT_COLLABORATION_VERSIONS, collaborationModule } from '@arbidocs/coedit';
16
17
  import { createHocuspocusCollaboration } from '@arbidocs/coedit/hocuspocus';
17
- import { documentStyleIds, stylesUsed, readParagraphs, insertDefinedTerm, definitionOfAnchor, documentNumbering, paragraphRunsXml, listTargets, refreshCrossReferences, REF_BOOKMARK_PREFIX, insertDocumentReference, refResult, markCrossReferenceTarget, insertCrossReferenceField, filterTargets, paragraphNumber, fragmentPackage, AGENT_UNDO_MAP, undoOps } from '@arbidocs/coedit/commands';
18
+ import { documentStyleIds, stylesUsed, readParagraphs, insertDefinedTerm, definitionOfAnchor, documentNumbering, paragraphRunsXml, listTargets, refreshCrossReferences, REF_BOOKMARK_PREFIX, insertDocumentReference, refResult, markCrossReferenceTarget, insertCrossReferenceField, filterTargets, signatureFieldWrite, isSignerEmail, SIGNATURE_FIELD_KINDS, SIGNATURE_FIELD_LABELS, paragraphNumber, fragmentPackage, AGENT_UNDO_MAP, undoOps } from '@arbidocs/coedit/commands';
18
19
  export { findDefinitionsSection, insertCrossReference, insertDefinedTerm, insertDocumentReference, listTargets, paragraphNumber } from '@arbidocs/coedit/commands';
19
20
  import { defaultLegalTemplate, listBuildingBlocks, attachedTemplateOf, linkedLevelStyles, styleDivergence, buildingBlockFragment, fragmentClipboardHtml, trackInsertion, newFromTemplate } from '@arbidocs/coedit/template';
20
21
  import { executeImageCommand } from '@docx-editor.dev/core/editor';
22
+ import { pngSize, pngBytes, INFORMAL_SIGNATURE_NOTE } from '@arbidocs/react/document-tools';
21
23
 
22
24
  function normalizeDocxExport(data) {
23
25
  const files = unzipSync(new Uint8Array(data));
@@ -4263,6 +4265,310 @@ function QuickParts() {
4263
4265
  ] })
4264
4266
  ] }) });
4265
4267
  }
4268
+ var SignatureFieldsContext = createContext(null);
4269
+ function SignatureFieldsProvider({
4270
+ signers,
4271
+ editable,
4272
+ notify,
4273
+ mySignature,
4274
+ children
4275
+ }) {
4276
+ return /* @__PURE__ */ jsxs(
4277
+ SignatureFieldsContext.Provider,
4278
+ {
4279
+ value: signers || mySignature ? { fields: !!signers, signers: signers ?? [], editable, notify, mySignature } : null,
4280
+ children: [
4281
+ children,
4282
+ mySignature && /* @__PURE__ */ jsx(MySignatureDialog, {})
4283
+ ]
4284
+ }
4285
+ );
4286
+ }
4287
+ async function insertSavedMark(editor, saved, mark) {
4288
+ const png = mark === "signature" ? saved.signature_png : saved.initials_png;
4289
+ const { width, height } = pngSize(png);
4290
+ const heightPoints = mark === "signature" ? 36 : 24;
4291
+ let widthPoints = width / Math.max(1, height) * heightPoints;
4292
+ let h = heightPoints;
4293
+ if (widthPoints > 200) {
4294
+ h = heightPoints * 200 / widthPoints;
4295
+ widthPoints = 200;
4296
+ }
4297
+ editor.focus();
4298
+ const result = await executeImageCommand(editor, {
4299
+ type: "insertImage",
4300
+ data: pngBytes(png),
4301
+ mime: "image/png",
4302
+ widthPoints,
4303
+ heightPoints: h,
4304
+ description: mark === "signature" ? `Signature of ${saved.name}` : `Initials of ${saved.name}`,
4305
+ title: mark === "signature" ? "Signature" : "Initials"
4306
+ });
4307
+ if (!result.ok) throw new Error(result.reason || "The picture could not be inserted here.");
4308
+ }
4309
+ var openAdopt = null;
4310
+ function MySignatureDialog() {
4311
+ const context = useContext(SignatureFieldsContext);
4312
+ const editor = useDocxEditor();
4313
+ const [pending, setPending] = useState(null);
4314
+ openAdopt = setPending;
4315
+ const mine = context?.mySignature;
4316
+ if (!mine) return null;
4317
+ return /* @__PURE__ */ jsx(
4318
+ AdoptSignatureDialog,
4319
+ {
4320
+ open: !!pending,
4321
+ onOpenChange: (open) => !open && setPending(null),
4322
+ mode: "save",
4323
+ defaultName: mine.defaultName,
4324
+ onSave: mine.save,
4325
+ onAdopt: async () => {
4326
+ const mark = pending;
4327
+ setPending(null);
4328
+ const saved = await mine.load();
4329
+ if (editor && saved && mark) {
4330
+ try {
4331
+ await insertSavedMark(editor, saved, mark);
4332
+ } catch (failure) {
4333
+ context?.notify?.(failure instanceof Error ? failure.message : String(failure), "error");
4334
+ }
4335
+ }
4336
+ }
4337
+ }
4338
+ );
4339
+ }
4340
+ function useInsertMySignature() {
4341
+ const context = useContext(SignatureFieldsContext);
4342
+ const editor = useDocxEditor();
4343
+ const mine = context?.mySignature;
4344
+ if (!mine || !editor) return null;
4345
+ return async (mark) => {
4346
+ try {
4347
+ const saved = await mine.load();
4348
+ if (!saved) return openAdopt?.(mark);
4349
+ await insertSavedMark(editor, saved, mark);
4350
+ } catch (failure) {
4351
+ context?.notify?.(
4352
+ failure instanceof Error ? failure.message : "The signature could not be inserted.",
4353
+ "error"
4354
+ );
4355
+ }
4356
+ };
4357
+ }
4358
+ function MySignatureMenu() {
4359
+ const insert = useInsertMySignature();
4360
+ const context = useContext(SignatureFieldsContext);
4361
+ if (!insert) return null;
4362
+ return /* @__PURE__ */ jsx(RibbonMenu, { label: "My signature", icon: /* @__PURE__ */ jsx(Signature, { size: 16 }), testId: "docx-my-signature", children: (close) => /* @__PURE__ */ jsxs("div", { className: "native-docx-signature-field", "data-testid": "docx-my-signature-panel", children: [
4363
+ /* @__PURE__ */ jsx(
4364
+ "button",
4365
+ {
4366
+ type: "button",
4367
+ disabled: !context?.editable,
4368
+ onClick: () => {
4369
+ close();
4370
+ void insert("signature");
4371
+ },
4372
+ "data-testid": "docx-insert-my-signature",
4373
+ children: "Insert my signature"
4374
+ }
4375
+ ),
4376
+ /* @__PURE__ */ jsx(
4377
+ "button",
4378
+ {
4379
+ type: "button",
4380
+ disabled: !context?.editable,
4381
+ onClick: () => {
4382
+ close();
4383
+ void insert("initials");
4384
+ },
4385
+ "data-testid": "docx-insert-my-initials",
4386
+ children: "Insert my initials"
4387
+ }
4388
+ ),
4389
+ /* @__PURE__ */ jsx("p", { children: INFORMAL_SIGNATURE_NOTE })
4390
+ ] }) });
4391
+ }
4392
+ function MySignatureContextItems() {
4393
+ const insert = useInsertMySignature();
4394
+ if (!insert) return null;
4395
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
4396
+ /* @__PURE__ */ jsx(DocxEditor.ContextMenu.Separator, {}),
4397
+ /* @__PURE__ */ jsx(
4398
+ DocxEditor.ContextMenu.Item,
4399
+ {
4400
+ label: "Insert my signature",
4401
+ icon: /* @__PURE__ */ jsx(Signature, { size: 14 }),
4402
+ onSelect: () => void insert("signature")
4403
+ }
4404
+ ),
4405
+ /* @__PURE__ */ jsx(
4406
+ DocxEditor.ContextMenu.Item,
4407
+ {
4408
+ label: "Insert my initials",
4409
+ icon: /* @__PURE__ */ jsx(Signature, { size: 14 }),
4410
+ onSelect: () => void insert("initials")
4411
+ }
4412
+ )
4413
+ ] });
4414
+ }
4415
+ var OTHER = "__other__";
4416
+ var NONE2 = "";
4417
+ function insertSignatureField(editor, spec) {
4418
+ const surface = editor.surface;
4419
+ const selection = surface?.state().selection;
4420
+ if (!surface || !selection) throw new Error("Place the cursor where the field goes.");
4421
+ const { head } = selection;
4422
+ const { tag, write } = signatureFieldWrite(spec, head);
4423
+ const result = withDirectEditing(editor, () => surface.session.insertCustomNode(write));
4424
+ if (!result.ok) {
4425
+ throw new Error(
4426
+ result.reason === "locked" ? "A field cannot go inside a locked part of the document." : "The field could not be inserted here."
4427
+ );
4428
+ }
4429
+ const after = { paragraphId: head.paragraphId, offset: head.offset + write.text.length };
4430
+ try {
4431
+ surface.setSelection({ anchor: after, head: after });
4432
+ } catch {
4433
+ }
4434
+ return tag;
4435
+ }
4436
+ function SignatureFieldMenu() {
4437
+ const context = useContext(SignatureFieldsContext);
4438
+ const editor = useDocxEditor();
4439
+ const [kind, setKind] = useState("signature");
4440
+ const [who, setWho] = useState(NONE2);
4441
+ const [email, setEmail] = useState("");
4442
+ const [name, setName] = useState("");
4443
+ const [required, setRequired] = useState(true);
4444
+ const [error, setError] = useState("");
4445
+ if (!context?.fields) return null;
4446
+ const other = who === OTHER;
4447
+ const chosen = context.signers.find((s) => s.email === who);
4448
+ const ready = !other || isSignerEmail(email);
4449
+ const insert = (close) => {
4450
+ if (!editor || !ready) return;
4451
+ setError("");
4452
+ try {
4453
+ insertSignatureField(editor, {
4454
+ kind,
4455
+ email: other ? email : chosen?.email ?? null,
4456
+ name: other ? name : chosen?.name ?? null,
4457
+ required
4458
+ });
4459
+ close();
4460
+ setEmail("");
4461
+ setName("");
4462
+ } catch (failure) {
4463
+ setError(failure instanceof Error ? failure.message : "The field could not be inserted.");
4464
+ }
4465
+ };
4466
+ return /* @__PURE__ */ jsx(
4467
+ RibbonMenu,
4468
+ {
4469
+ label: "Signature field",
4470
+ icon: /* @__PURE__ */ jsx(PenLine, { size: 16 }),
4471
+ testId: "docx-signature-field",
4472
+ keepMounted: true,
4473
+ children: (close) => /* @__PURE__ */ jsxs(
4474
+ "form",
4475
+ {
4476
+ className: "native-docx-signature-field",
4477
+ "data-testid": "docx-signature-field-panel",
4478
+ onSubmit: (event) => {
4479
+ event.preventDefault();
4480
+ insert(close);
4481
+ },
4482
+ children: [
4483
+ /* @__PURE__ */ jsxs("label", { children: [
4484
+ "Field",
4485
+ /* @__PURE__ */ jsx(
4486
+ "select",
4487
+ {
4488
+ value: kind,
4489
+ onChange: (event) => setKind(event.target.value),
4490
+ "data-testid": "docx-signature-field-kind",
4491
+ children: SIGNATURE_FIELD_KINDS.map((k) => /* @__PURE__ */ jsx("option", { value: k, children: SIGNATURE_FIELD_LABELS[k] }, k))
4492
+ }
4493
+ )
4494
+ ] }),
4495
+ /* @__PURE__ */ jsxs("label", { children: [
4496
+ "Signer",
4497
+ /* @__PURE__ */ jsxs(
4498
+ "select",
4499
+ {
4500
+ value: who,
4501
+ onChange: (event) => setWho(event.target.value),
4502
+ "data-testid": "docx-signature-field-signer",
4503
+ children: [
4504
+ /* @__PURE__ */ jsx("option", { value: NONE2, children: "Choose when sending" }),
4505
+ context.signers.map((s) => /* @__PURE__ */ jsxs("option", { value: s.email, children: [
4506
+ s.name || s.email,
4507
+ " (",
4508
+ s.email,
4509
+ ")"
4510
+ ] }, s.email)),
4511
+ /* @__PURE__ */ jsx("option", { value: OTHER, children: "Someone else, by email\u2026" })
4512
+ ]
4513
+ }
4514
+ )
4515
+ ] }),
4516
+ other && /* @__PURE__ */ jsxs(Fragment, { children: [
4517
+ /* @__PURE__ */ jsxs("label", { children: [
4518
+ "Email",
4519
+ /* @__PURE__ */ jsx(
4520
+ "input",
4521
+ {
4522
+ type: "email",
4523
+ value: email,
4524
+ required: true,
4525
+ autoComplete: "off",
4526
+ onChange: (event) => setEmail(event.target.value),
4527
+ "data-testid": "docx-signature-field-email"
4528
+ }
4529
+ )
4530
+ ] }),
4531
+ /* @__PURE__ */ jsxs("label", { children: [
4532
+ "Name",
4533
+ /* @__PURE__ */ jsx(
4534
+ "input",
4535
+ {
4536
+ value: name,
4537
+ maxLength: 200,
4538
+ autoComplete: "off",
4539
+ onChange: (event) => setName(event.target.value),
4540
+ "data-testid": "docx-signature-field-name"
4541
+ }
4542
+ )
4543
+ ] })
4544
+ ] }),
4545
+ /* @__PURE__ */ jsxs("label", { className: "native-docx-signature-field-check", children: [
4546
+ /* @__PURE__ */ jsx(
4547
+ "input",
4548
+ {
4549
+ type: "checkbox",
4550
+ checked: required,
4551
+ onChange: (event) => setRequired(event.target.checked)
4552
+ }
4553
+ ),
4554
+ "Required"
4555
+ ] }),
4556
+ error && /* @__PURE__ */ jsx("p", { role: "alert", children: error }),
4557
+ /* @__PURE__ */ jsx(
4558
+ "button",
4559
+ {
4560
+ type: "submit",
4561
+ disabled: !context.editable || !ready,
4562
+ "data-testid": "docx-signature-field-insert",
4563
+ children: "Insert field"
4564
+ }
4565
+ )
4566
+ ]
4567
+ }
4568
+ )
4569
+ }
4570
+ );
4571
+ }
4266
4572
  var SOURCE = {
4267
4573
  workspace: "This workspace's house template",
4268
4574
  deployment: "The house template for all workspaces",
@@ -4465,6 +4771,8 @@ function DocxRibbon({
4465
4771
  /* @__PURE__ */ jsx(RibbonItem, { id: "insert-link", label: "Link", children: /* @__PURE__ */ jsx(DocxEditor.Toolbar.Link, {}) }),
4466
4772
  /* @__PURE__ */ jsx(RibbonItem, { id: "insert-defined-term", label: "Defined term", children: /* @__PURE__ */ jsx(DefinedTermButtons, {}) }),
4467
4773
  /* @__PURE__ */ jsx(RibbonItem, { id: "insert-quick-parts", label: "Quick Parts", children: /* @__PURE__ */ jsx(QuickParts, {}) }),
4774
+ /* @__PURE__ */ jsx(RibbonItem, { id: "insert-signature-field", label: "Signature field", children: /* @__PURE__ */ jsx(SignatureFieldMenu, {}) }),
4775
+ /* @__PURE__ */ jsx(RibbonItem, { id: "insert-my-signature", label: "My signature", children: /* @__PURE__ */ jsx(MySignatureMenu, {}) }),
4468
4776
  /* @__PURE__ */ jsx(RibbonItem, { id: "insert-cross-reference", label: "Cross-reference", children: /* @__PURE__ */ jsx(CrossReferenceButton, {}) })
4469
4777
  ] }),
4470
4778
  /* @__PURE__ */ jsx(LayoutTabContent, { tab }),
@@ -4893,86 +5201,98 @@ function NativeDocxEditor({
4893
5201
  documentId: isDraft || snapshot ? void 0 : documentId,
4894
5202
  editable: !stream && !snapshot && ready.canEdit,
4895
5203
  notify: adapter.notify,
4896
- children: /* @__PURE__ */ jsxs(
5204
+ children: /* @__PURE__ */ jsx(
4897
5205
  CrossReferencesProvider,
4898
5206
  {
4899
5207
  editable: !stream && !snapshot && ready.canEdit,
4900
5208
  references: adapter.references,
4901
5209
  documentId,
4902
5210
  notify: adapter.notify,
4903
- children: [
4904
- /* @__PURE__ */ jsx(
4905
- DocxEditor.RevisionMarkup,
4906
- {
4907
- insertions: { mark: "underline", color: "blue" },
4908
- deletions: { mark: "strikethrough", color: "red" },
4909
- movedFrom: { mark: "doubleStrikethrough", color: "green" },
4910
- movedTo: { mark: "doubleUnderline", color: "green" },
4911
- trackMoves: true
4912
- }
4913
- ),
4914
- compact && !stream && /* @__PURE__ */ jsx(CompactToolbar, {}),
4915
- !compact && !stream && /* @__PURE__ */ jsx(
4916
- DocxRibbon,
4917
- {
4918
- onSave: () => void saveVersion(),
4919
- imageGeneration: adapter.imageGeneration && {
4920
- notify: adapter.notify,
4921
- ...adapter.imageGeneration
4922
- },
4923
- badge: (
4924
- // The document's state, in place of a title row above the ribbon.
4925
- /* @__PURE__ */ jsx(
4926
- DocumentStateBadge,
4927
- {
4928
- state: snapshot || !ready.canEdit ? "read-only" : ready.room ? "co-editing" : isDraft ? "draft" : void 0
4929
- }
4930
- )
5211
+ children: /* @__PURE__ */ jsxs(
5212
+ SignatureFieldsProvider,
5213
+ {
5214
+ signers: adapter.signatureSigners,
5215
+ mySignature: adapter.savedSignature,
5216
+ editable: !stream && !snapshot && ready.canEdit,
5217
+ notify: adapter.notify,
5218
+ children: [
5219
+ /* @__PURE__ */ jsx(
5220
+ DocxEditor.RevisionMarkup,
5221
+ {
5222
+ insertions: { mark: "underline", color: "blue" },
5223
+ deletions: { mark: "strikethrough", color: "red" },
5224
+ movedFrom: { mark: "doubleStrikethrough", color: "green" },
5225
+ movedTo: { mark: "doubleUnderline", color: "green" },
5226
+ trackMoves: true
5227
+ }
5228
+ ),
5229
+ compact && !stream && /* @__PURE__ */ jsx(CompactToolbar, {}),
5230
+ !compact && !stream && /* @__PURE__ */ jsx(
5231
+ DocxRibbon,
5232
+ {
5233
+ onSave: () => void saveVersion(),
5234
+ imageGeneration: adapter.imageGeneration && {
5235
+ notify: adapter.notify,
5236
+ ...adapter.imageGeneration
5237
+ },
5238
+ badge: (
5239
+ // The document's state, in place of a title row above the ribbon.
5240
+ /* @__PURE__ */ jsx(
5241
+ DocumentStateBadge,
5242
+ {
5243
+ state: snapshot || !ready.canEdit ? "read-only" : ready.room ? "co-editing" : isDraft ? "draft" : void 0
5244
+ }
5245
+ )
5246
+ )
5247
+ }
5248
+ ),
5249
+ !stream && /* @__PURE__ */ jsx(WordShortcuts, { scope: stageRef }),
5250
+ !stream && /* @__PURE__ */ jsx(TableTabKeys, { scope: stageRef }),
5251
+ /* @__PURE__ */ jsxs(
5252
+ "div",
5253
+ {
5254
+ className: "native-docx-stage",
5255
+ ref: stageRef,
5256
+ onMouseDownCapture: (event) => {
5257
+ if (event.button === 2 && ref.current?.getSelectionPlacement())
5258
+ event.preventDefault();
5259
+ },
5260
+ children: [
5261
+ /* @__PURE__ */ jsxs(DocxEditor.Viewport, { className: "native-docx-viewport", children: [
5262
+ /* @__PURE__ */ jsx(DocxEditor.Content, {}),
5263
+ /* @__PURE__ */ jsxs(
5264
+ DocxMentions,
5265
+ {
5266
+ initialCommentId,
5267
+ mentions: adapter.mentions,
5268
+ notify: adapter.notify,
5269
+ getAgentStatus: adapter.getAgentStatus,
5270
+ requestAgent: adapter.requestAgent ? (request) => adapter.requestAgent(documentId, request) : void 0,
5271
+ children: [
5272
+ /* @__PURE__ */ jsx(RoomInputBinding, { session: ready.room?.session }),
5273
+ /* @__PURE__ */ jsx(AgentUndoRoom.Provider, { value: ready.room?.ydoc ?? null, children: /* @__PURE__ */ jsx(DocxEditorReview, { children: () => /* @__PURE__ */ jsxs(DocxEditorReview.Card, { children: [
5274
+ /* @__PURE__ */ jsx(DocxCommentActivity, {}),
5275
+ /* @__PURE__ */ jsx(AgentUndo, {})
5276
+ ] }) }) })
5277
+ ]
5278
+ }
5279
+ ),
5280
+ !compact && /* @__PURE__ */ jsx(DocxEditor.HeaderFooterChrome, {}),
5281
+ !compact && /* @__PURE__ */ jsx(DocxEditor.NotesChrome, {}),
5282
+ /* @__PURE__ */ jsx(DocxEditor.Equation, {}),
5283
+ /* @__PURE__ */ jsx(DocxEditor.HyperLink, {}),
5284
+ /* @__PURE__ */ jsxs(DocxEditor.ContextMenu, { children: [
5285
+ /* @__PURE__ */ jsx(DocxContextMenuExtras, {}),
5286
+ /* @__PURE__ */ jsx(MySignatureContextItems, {})
5287
+ ] })
5288
+ ] }),
5289
+ !compact && /* @__PURE__ */ jsx(DocxEditor.PageNumber, {})
5290
+ ]
5291
+ }
4931
5292
  )
4932
- }
4933
- ),
4934
- !stream && /* @__PURE__ */ jsx(WordShortcuts, { scope: stageRef }),
4935
- !stream && /* @__PURE__ */ jsx(TableTabKeys, { scope: stageRef }),
4936
- /* @__PURE__ */ jsxs(
4937
- "div",
4938
- {
4939
- className: "native-docx-stage",
4940
- ref: stageRef,
4941
- onMouseDownCapture: (event) => {
4942
- if (event.button === 2 && ref.current?.getSelectionPlacement())
4943
- event.preventDefault();
4944
- },
4945
- children: [
4946
- /* @__PURE__ */ jsxs(DocxEditor.Viewport, { className: "native-docx-viewport", children: [
4947
- /* @__PURE__ */ jsx(DocxEditor.Content, {}),
4948
- /* @__PURE__ */ jsxs(
4949
- DocxMentions,
4950
- {
4951
- initialCommentId,
4952
- mentions: adapter.mentions,
4953
- notify: adapter.notify,
4954
- getAgentStatus: adapter.getAgentStatus,
4955
- requestAgent: adapter.requestAgent ? (request) => adapter.requestAgent(documentId, request) : void 0,
4956
- children: [
4957
- /* @__PURE__ */ jsx(RoomInputBinding, { session: ready.room?.session }),
4958
- /* @__PURE__ */ jsx(AgentUndoRoom.Provider, { value: ready.room?.ydoc ?? null, children: /* @__PURE__ */ jsx(DocxEditorReview, { children: () => /* @__PURE__ */ jsxs(DocxEditorReview.Card, { children: [
4959
- /* @__PURE__ */ jsx(DocxCommentActivity, {}),
4960
- /* @__PURE__ */ jsx(AgentUndo, {})
4961
- ] }) }) })
4962
- ]
4963
- }
4964
- ),
4965
- !compact && /* @__PURE__ */ jsx(DocxEditor.HeaderFooterChrome, {}),
4966
- !compact && /* @__PURE__ */ jsx(DocxEditor.NotesChrome, {}),
4967
- /* @__PURE__ */ jsx(DocxEditor.Equation, {}),
4968
- /* @__PURE__ */ jsx(DocxEditor.HyperLink, {}),
4969
- /* @__PURE__ */ jsx(DocxEditor.ContextMenu, { children: /* @__PURE__ */ jsx(DocxContextMenuExtras, {}) })
4970
- ] }),
4971
- !compact && /* @__PURE__ */ jsx(DocxEditor.PageNumber, {})
4972
- ]
4973
- }
4974
- )
4975
- ]
5293
+ ]
5294
+ }
5295
+ )
4976
5296
  }
4977
5297
  )
4978
5298
  }
@@ -5036,6 +5356,6 @@ function NativeDocxEditor({
5036
5356
  );
5037
5357
  }
5038
5358
 
5039
- export { BUILTIN_TEMPLATE_NAME, CrossReferenceDialog, CrossReferencesProvider, DEFAULT_CROSS_REFERENCES_LABELS, DEFAULT_DEFINED_TERMS_LABELS, DEFINED_TERM_TRIGGER, DefinedTermsProvider, DocxAuthorContext, DocxCommentActivity, DocxEditorReview, DocxMentions, DocxParticipants, DocxRibbon, GenerateImageButton, HouseTemplateProvider, LinkHoverCard, NativeDocxEditor, builtinHouseTemplate, contentPath, editorPort, normalizeDocxExport, referenceText, referencesPort, resolveHouseTemplate, reviewModule, shortTitle, structuralPort, templateFileName, trackedOrNoted, useCrossReferences, useDefinedTerms, useHouseTemplate, useReview, useReviewItem, useTrackedOrNoted, withDirectEditing };
5040
- //# sourceMappingURL=chunk-ONTUMV74.js.map
5041
- //# sourceMappingURL=chunk-ONTUMV74.js.map
5359
+ export { BUILTIN_TEMPLATE_NAME, CrossReferenceDialog, CrossReferencesProvider, DEFAULT_CROSS_REFERENCES_LABELS, DEFAULT_DEFINED_TERMS_LABELS, DEFINED_TERM_TRIGGER, DefinedTermsProvider, DocxAuthorContext, DocxCommentActivity, DocxEditorReview, DocxMentions, DocxParticipants, DocxRibbon, GenerateImageButton, HouseTemplateProvider, LinkHoverCard, NativeDocxEditor, SignatureFieldMenu, SignatureFieldsProvider, builtinHouseTemplate, contentPath, editorPort, insertSignatureField, normalizeDocxExport, referenceText, referencesPort, resolveHouseTemplate, reviewModule, shortTitle, structuralPort, templateFileName, trackedOrNoted, useCrossReferences, useDefinedTerms, useHouseTemplate, useReview, useReviewItem, useTrackedOrNoted, withDirectEditing };
5360
+ //# sourceMappingURL=chunk-XER3JLC7.js.map
5361
+ //# sourceMappingURL=chunk-XER3JLC7.js.map