@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,6 +1,7 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
+ var chunkJPWPR6QU_cjs = require('./chunk-JPWPR6QU.cjs');
4
5
  var chunk5FYU7ZIU_cjs = require('./chunk-5FYU7ZIU.cjs');
5
6
  var chunkQT3A4PFC_cjs = require('./chunk-QT3A4PFC.cjs');
6
7
  var chunk7UTB4PHM_cjs = require('./chunk-7UTB4PHM.cjs');
@@ -19,6 +20,7 @@ var hocuspocus = require('@arbidocs/coedit/hocuspocus');
19
20
  var commands = require('@arbidocs/coedit/commands');
20
21
  var template = require('@arbidocs/coedit/template');
21
22
  var editor = require('@docx-editor.dev/core/editor');
23
+ var documentTools = require('@arbidocs/react/document-tools');
22
24
 
23
25
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
24
26
 
@@ -4287,6 +4289,310 @@ function QuickParts() {
4287
4289
  ] })
4288
4290
  ] }) });
4289
4291
  }
4292
+ var SignatureFieldsContext = React4.createContext(null);
4293
+ function SignatureFieldsProvider({
4294
+ signers,
4295
+ editable,
4296
+ notify,
4297
+ mySignature,
4298
+ children
4299
+ }) {
4300
+ return /* @__PURE__ */ jsxRuntime.jsxs(
4301
+ SignatureFieldsContext.Provider,
4302
+ {
4303
+ value: signers || mySignature ? { fields: !!signers, signers: signers ?? [], editable, notify, mySignature } : null,
4304
+ children: [
4305
+ children,
4306
+ mySignature && /* @__PURE__ */ jsxRuntime.jsx(MySignatureDialog, {})
4307
+ ]
4308
+ }
4309
+ );
4310
+ }
4311
+ async function insertSavedMark(editor$1, saved, mark) {
4312
+ const png = mark === "signature" ? saved.signature_png : saved.initials_png;
4313
+ const { width, height } = documentTools.pngSize(png);
4314
+ const heightPoints = mark === "signature" ? 36 : 24;
4315
+ let widthPoints = width / Math.max(1, height) * heightPoints;
4316
+ let h = heightPoints;
4317
+ if (widthPoints > 200) {
4318
+ h = heightPoints * 200 / widthPoints;
4319
+ widthPoints = 200;
4320
+ }
4321
+ editor$1.focus();
4322
+ const result = await editor.executeImageCommand(editor$1, {
4323
+ type: "insertImage",
4324
+ data: documentTools.pngBytes(png),
4325
+ mime: "image/png",
4326
+ widthPoints,
4327
+ heightPoints: h,
4328
+ description: mark === "signature" ? `Signature of ${saved.name}` : `Initials of ${saved.name}`,
4329
+ title: mark === "signature" ? "Signature" : "Initials"
4330
+ });
4331
+ if (!result.ok) throw new Error(result.reason || "The picture could not be inserted here.");
4332
+ }
4333
+ var openAdopt = null;
4334
+ function MySignatureDialog() {
4335
+ const context = React4.useContext(SignatureFieldsContext);
4336
+ const editor = react.useDocxEditor();
4337
+ const [pending, setPending] = React4.useState(null);
4338
+ openAdopt = setPending;
4339
+ const mine = context?.mySignature;
4340
+ if (!mine) return null;
4341
+ return /* @__PURE__ */ jsxRuntime.jsx(
4342
+ chunkJPWPR6QU_cjs.AdoptSignatureDialog,
4343
+ {
4344
+ open: !!pending,
4345
+ onOpenChange: (open) => !open && setPending(null),
4346
+ mode: "save",
4347
+ defaultName: mine.defaultName,
4348
+ onSave: mine.save,
4349
+ onAdopt: async () => {
4350
+ const mark = pending;
4351
+ setPending(null);
4352
+ const saved = await mine.load();
4353
+ if (editor && saved && mark) {
4354
+ try {
4355
+ await insertSavedMark(editor, saved, mark);
4356
+ } catch (failure) {
4357
+ context?.notify?.(failure instanceof Error ? failure.message : String(failure), "error");
4358
+ }
4359
+ }
4360
+ }
4361
+ }
4362
+ );
4363
+ }
4364
+ function useInsertMySignature() {
4365
+ const context = React4.useContext(SignatureFieldsContext);
4366
+ const editor = react.useDocxEditor();
4367
+ const mine = context?.mySignature;
4368
+ if (!mine || !editor) return null;
4369
+ return async (mark) => {
4370
+ try {
4371
+ const saved = await mine.load();
4372
+ if (!saved) return openAdopt?.(mark);
4373
+ await insertSavedMark(editor, saved, mark);
4374
+ } catch (failure) {
4375
+ context?.notify?.(
4376
+ failure instanceof Error ? failure.message : "The signature could not be inserted.",
4377
+ "error"
4378
+ );
4379
+ }
4380
+ };
4381
+ }
4382
+ function MySignatureMenu() {
4383
+ const insert = useInsertMySignature();
4384
+ const context = React4.useContext(SignatureFieldsContext);
4385
+ if (!insert) return null;
4386
+ return /* @__PURE__ */ jsxRuntime.jsx(RibbonMenu, { label: "My signature", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Signature, { size: 16 }), testId: "docx-my-signature", children: (close) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "native-docx-signature-field", "data-testid": "docx-my-signature-panel", children: [
4387
+ /* @__PURE__ */ jsxRuntime.jsx(
4388
+ "button",
4389
+ {
4390
+ type: "button",
4391
+ disabled: !context?.editable,
4392
+ onClick: () => {
4393
+ close();
4394
+ void insert("signature");
4395
+ },
4396
+ "data-testid": "docx-insert-my-signature",
4397
+ children: "Insert my signature"
4398
+ }
4399
+ ),
4400
+ /* @__PURE__ */ jsxRuntime.jsx(
4401
+ "button",
4402
+ {
4403
+ type: "button",
4404
+ disabled: !context?.editable,
4405
+ onClick: () => {
4406
+ close();
4407
+ void insert("initials");
4408
+ },
4409
+ "data-testid": "docx-insert-my-initials",
4410
+ children: "Insert my initials"
4411
+ }
4412
+ ),
4413
+ /* @__PURE__ */ jsxRuntime.jsx("p", { children: documentTools.INFORMAL_SIGNATURE_NOTE })
4414
+ ] }) });
4415
+ }
4416
+ function MySignatureContextItems() {
4417
+ const insert = useInsertMySignature();
4418
+ if (!insert) return null;
4419
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4420
+ /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.ContextMenu.Separator, {}),
4421
+ /* @__PURE__ */ jsxRuntime.jsx(
4422
+ react.DocxEditor.ContextMenu.Item,
4423
+ {
4424
+ label: "Insert my signature",
4425
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Signature, { size: 14 }),
4426
+ onSelect: () => void insert("signature")
4427
+ }
4428
+ ),
4429
+ /* @__PURE__ */ jsxRuntime.jsx(
4430
+ react.DocxEditor.ContextMenu.Item,
4431
+ {
4432
+ label: "Insert my initials",
4433
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Signature, { size: 14 }),
4434
+ onSelect: () => void insert("initials")
4435
+ }
4436
+ )
4437
+ ] });
4438
+ }
4439
+ var OTHER = "__other__";
4440
+ var NONE2 = "";
4441
+ function insertSignatureField(editor, spec) {
4442
+ const surface = editor.surface;
4443
+ const selection = surface?.state().selection;
4444
+ if (!surface || !selection) throw new Error("Place the cursor where the field goes.");
4445
+ const { head } = selection;
4446
+ const { tag, write } = commands.signatureFieldWrite(spec, head);
4447
+ const result = withDirectEditing(editor, () => surface.session.insertCustomNode(write));
4448
+ if (!result.ok) {
4449
+ throw new Error(
4450
+ result.reason === "locked" ? "A field cannot go inside a locked part of the document." : "The field could not be inserted here."
4451
+ );
4452
+ }
4453
+ const after = { paragraphId: head.paragraphId, offset: head.offset + write.text.length };
4454
+ try {
4455
+ surface.setSelection({ anchor: after, head: after });
4456
+ } catch {
4457
+ }
4458
+ return tag;
4459
+ }
4460
+ function SignatureFieldMenu() {
4461
+ const context = React4.useContext(SignatureFieldsContext);
4462
+ const editor = react.useDocxEditor();
4463
+ const [kind, setKind] = React4.useState("signature");
4464
+ const [who, setWho] = React4.useState(NONE2);
4465
+ const [email, setEmail] = React4.useState("");
4466
+ const [name, setName] = React4.useState("");
4467
+ const [required, setRequired] = React4.useState(true);
4468
+ const [error, setError] = React4.useState("");
4469
+ if (!context?.fields) return null;
4470
+ const other = who === OTHER;
4471
+ const chosen = context.signers.find((s) => s.email === who);
4472
+ const ready = !other || commands.isSignerEmail(email);
4473
+ const insert = (close) => {
4474
+ if (!editor || !ready) return;
4475
+ setError("");
4476
+ try {
4477
+ insertSignatureField(editor, {
4478
+ kind,
4479
+ email: other ? email : chosen?.email ?? null,
4480
+ name: other ? name : chosen?.name ?? null,
4481
+ required
4482
+ });
4483
+ close();
4484
+ setEmail("");
4485
+ setName("");
4486
+ } catch (failure) {
4487
+ setError(failure instanceof Error ? failure.message : "The field could not be inserted.");
4488
+ }
4489
+ };
4490
+ return /* @__PURE__ */ jsxRuntime.jsx(
4491
+ RibbonMenu,
4492
+ {
4493
+ label: "Signature field",
4494
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PenLine, { size: 16 }),
4495
+ testId: "docx-signature-field",
4496
+ keepMounted: true,
4497
+ children: (close) => /* @__PURE__ */ jsxRuntime.jsxs(
4498
+ "form",
4499
+ {
4500
+ className: "native-docx-signature-field",
4501
+ "data-testid": "docx-signature-field-panel",
4502
+ onSubmit: (event) => {
4503
+ event.preventDefault();
4504
+ insert(close);
4505
+ },
4506
+ children: [
4507
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
4508
+ "Field",
4509
+ /* @__PURE__ */ jsxRuntime.jsx(
4510
+ "select",
4511
+ {
4512
+ value: kind,
4513
+ onChange: (event) => setKind(event.target.value),
4514
+ "data-testid": "docx-signature-field-kind",
4515
+ children: commands.SIGNATURE_FIELD_KINDS.map((k) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: k, children: commands.SIGNATURE_FIELD_LABELS[k] }, k))
4516
+ }
4517
+ )
4518
+ ] }),
4519
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
4520
+ "Signer",
4521
+ /* @__PURE__ */ jsxRuntime.jsxs(
4522
+ "select",
4523
+ {
4524
+ value: who,
4525
+ onChange: (event) => setWho(event.target.value),
4526
+ "data-testid": "docx-signature-field-signer",
4527
+ children: [
4528
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: NONE2, children: "Choose when sending" }),
4529
+ context.signers.map((s) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: s.email, children: [
4530
+ s.name || s.email,
4531
+ " (",
4532
+ s.email,
4533
+ ")"
4534
+ ] }, s.email)),
4535
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: OTHER, children: "Someone else, by email\u2026" })
4536
+ ]
4537
+ }
4538
+ )
4539
+ ] }),
4540
+ other && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4541
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
4542
+ "Email",
4543
+ /* @__PURE__ */ jsxRuntime.jsx(
4544
+ "input",
4545
+ {
4546
+ type: "email",
4547
+ value: email,
4548
+ required: true,
4549
+ autoComplete: "off",
4550
+ onChange: (event) => setEmail(event.target.value),
4551
+ "data-testid": "docx-signature-field-email"
4552
+ }
4553
+ )
4554
+ ] }),
4555
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
4556
+ "Name",
4557
+ /* @__PURE__ */ jsxRuntime.jsx(
4558
+ "input",
4559
+ {
4560
+ value: name,
4561
+ maxLength: 200,
4562
+ autoComplete: "off",
4563
+ onChange: (event) => setName(event.target.value),
4564
+ "data-testid": "docx-signature-field-name"
4565
+ }
4566
+ )
4567
+ ] })
4568
+ ] }),
4569
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "native-docx-signature-field-check", children: [
4570
+ /* @__PURE__ */ jsxRuntime.jsx(
4571
+ "input",
4572
+ {
4573
+ type: "checkbox",
4574
+ checked: required,
4575
+ onChange: (event) => setRequired(event.target.checked)
4576
+ }
4577
+ ),
4578
+ "Required"
4579
+ ] }),
4580
+ error && /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", children: error }),
4581
+ /* @__PURE__ */ jsxRuntime.jsx(
4582
+ "button",
4583
+ {
4584
+ type: "submit",
4585
+ disabled: !context.editable || !ready,
4586
+ "data-testid": "docx-signature-field-insert",
4587
+ children: "Insert field"
4588
+ }
4589
+ )
4590
+ ]
4591
+ }
4592
+ )
4593
+ }
4594
+ );
4595
+ }
4290
4596
  var SOURCE = {
4291
4597
  workspace: "This workspace's house template",
4292
4598
  deployment: "The house template for all workspaces",
@@ -4489,6 +4795,8 @@ function DocxRibbon({
4489
4795
  /* @__PURE__ */ jsxRuntime.jsx(RibbonItem, { id: "insert-link", label: "Link", children: /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Link, {}) }),
4490
4796
  /* @__PURE__ */ jsxRuntime.jsx(RibbonItem, { id: "insert-defined-term", label: "Defined term", children: /* @__PURE__ */ jsxRuntime.jsx(DefinedTermButtons, {}) }),
4491
4797
  /* @__PURE__ */ jsxRuntime.jsx(RibbonItem, { id: "insert-quick-parts", label: "Quick Parts", children: /* @__PURE__ */ jsxRuntime.jsx(QuickParts, {}) }),
4798
+ /* @__PURE__ */ jsxRuntime.jsx(RibbonItem, { id: "insert-signature-field", label: "Signature field", children: /* @__PURE__ */ jsxRuntime.jsx(SignatureFieldMenu, {}) }),
4799
+ /* @__PURE__ */ jsxRuntime.jsx(RibbonItem, { id: "insert-my-signature", label: "My signature", children: /* @__PURE__ */ jsxRuntime.jsx(MySignatureMenu, {}) }),
4492
4800
  /* @__PURE__ */ jsxRuntime.jsx(RibbonItem, { id: "insert-cross-reference", label: "Cross-reference", children: /* @__PURE__ */ jsxRuntime.jsx(CrossReferenceButton, {}) })
4493
4801
  ] }),
4494
4802
  /* @__PURE__ */ jsxRuntime.jsx(LayoutTabContent, { tab }),
@@ -4917,86 +5225,98 @@ function NativeDocxEditor({
4917
5225
  documentId: isDraft || snapshot ? void 0 : documentId,
4918
5226
  editable: !stream && !snapshot && ready.canEdit,
4919
5227
  notify: adapter.notify,
4920
- children: /* @__PURE__ */ jsxRuntime.jsxs(
5228
+ children: /* @__PURE__ */ jsxRuntime.jsx(
4921
5229
  CrossReferencesProvider,
4922
5230
  {
4923
5231
  editable: !stream && !snapshot && ready.canEdit,
4924
5232
  references: adapter.references,
4925
5233
  documentId,
4926
5234
  notify: adapter.notify,
4927
- children: [
4928
- /* @__PURE__ */ jsxRuntime.jsx(
4929
- react.DocxEditor.RevisionMarkup,
4930
- {
4931
- insertions: { mark: "underline", color: "blue" },
4932
- deletions: { mark: "strikethrough", color: "red" },
4933
- movedFrom: { mark: "doubleStrikethrough", color: "green" },
4934
- movedTo: { mark: "doubleUnderline", color: "green" },
4935
- trackMoves: true
4936
- }
4937
- ),
4938
- compact && !stream && /* @__PURE__ */ jsxRuntime.jsx(CompactToolbar, {}),
4939
- !compact && !stream && /* @__PURE__ */ jsxRuntime.jsx(
4940
- DocxRibbon,
4941
- {
4942
- onSave: () => void saveVersion(),
4943
- imageGeneration: adapter.imageGeneration && {
4944
- notify: adapter.notify,
4945
- ...adapter.imageGeneration
4946
- },
4947
- badge: (
4948
- // The document's state, in place of a title row above the ribbon.
4949
- /* @__PURE__ */ jsxRuntime.jsx(
4950
- DocumentStateBadge,
4951
- {
4952
- state: snapshot || !ready.canEdit ? "read-only" : ready.room ? "co-editing" : isDraft ? "draft" : void 0
4953
- }
4954
- )
5235
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
5236
+ SignatureFieldsProvider,
5237
+ {
5238
+ signers: adapter.signatureSigners,
5239
+ mySignature: adapter.savedSignature,
5240
+ editable: !stream && !snapshot && ready.canEdit,
5241
+ notify: adapter.notify,
5242
+ children: [
5243
+ /* @__PURE__ */ jsxRuntime.jsx(
5244
+ react.DocxEditor.RevisionMarkup,
5245
+ {
5246
+ insertions: { mark: "underline", color: "blue" },
5247
+ deletions: { mark: "strikethrough", color: "red" },
5248
+ movedFrom: { mark: "doubleStrikethrough", color: "green" },
5249
+ movedTo: { mark: "doubleUnderline", color: "green" },
5250
+ trackMoves: true
5251
+ }
5252
+ ),
5253
+ compact && !stream && /* @__PURE__ */ jsxRuntime.jsx(CompactToolbar, {}),
5254
+ !compact && !stream && /* @__PURE__ */ jsxRuntime.jsx(
5255
+ DocxRibbon,
5256
+ {
5257
+ onSave: () => void saveVersion(),
5258
+ imageGeneration: adapter.imageGeneration && {
5259
+ notify: adapter.notify,
5260
+ ...adapter.imageGeneration
5261
+ },
5262
+ badge: (
5263
+ // The document's state, in place of a title row above the ribbon.
5264
+ /* @__PURE__ */ jsxRuntime.jsx(
5265
+ DocumentStateBadge,
5266
+ {
5267
+ state: snapshot || !ready.canEdit ? "read-only" : ready.room ? "co-editing" : isDraft ? "draft" : void 0
5268
+ }
5269
+ )
5270
+ )
5271
+ }
5272
+ ),
5273
+ !stream && /* @__PURE__ */ jsxRuntime.jsx(WordShortcuts, { scope: stageRef }),
5274
+ !stream && /* @__PURE__ */ jsxRuntime.jsx(TableTabKeys, { scope: stageRef }),
5275
+ /* @__PURE__ */ jsxRuntime.jsxs(
5276
+ "div",
5277
+ {
5278
+ className: "native-docx-stage",
5279
+ ref: stageRef,
5280
+ onMouseDownCapture: (event) => {
5281
+ if (event.button === 2 && ref.current?.getSelectionPlacement())
5282
+ event.preventDefault();
5283
+ },
5284
+ children: [
5285
+ /* @__PURE__ */ jsxRuntime.jsxs(react.DocxEditor.Viewport, { className: "native-docx-viewport", children: [
5286
+ /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Content, {}),
5287
+ /* @__PURE__ */ jsxRuntime.jsxs(
5288
+ DocxMentions,
5289
+ {
5290
+ initialCommentId,
5291
+ mentions: adapter.mentions,
5292
+ notify: adapter.notify,
5293
+ getAgentStatus: adapter.getAgentStatus,
5294
+ requestAgent: adapter.requestAgent ? (request) => adapter.requestAgent(documentId, request) : void 0,
5295
+ children: [
5296
+ /* @__PURE__ */ jsxRuntime.jsx(RoomInputBinding, { session: ready.room?.session }),
5297
+ /* @__PURE__ */ jsxRuntime.jsx(AgentUndoRoom.Provider, { value: ready.room?.ydoc ?? null, children: /* @__PURE__ */ jsxRuntime.jsx(DocxEditorReview, { children: () => /* @__PURE__ */ jsxRuntime.jsxs(DocxEditorReview.Card, { children: [
5298
+ /* @__PURE__ */ jsxRuntime.jsx(DocxCommentActivity, {}),
5299
+ /* @__PURE__ */ jsxRuntime.jsx(AgentUndo, {})
5300
+ ] }) }) })
5301
+ ]
5302
+ }
5303
+ ),
5304
+ !compact && /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.HeaderFooterChrome, {}),
5305
+ !compact && /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.NotesChrome, {}),
5306
+ /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Equation, {}),
5307
+ /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.HyperLink, {}),
5308
+ /* @__PURE__ */ jsxRuntime.jsxs(react.DocxEditor.ContextMenu, { children: [
5309
+ /* @__PURE__ */ jsxRuntime.jsx(DocxContextMenuExtras, {}),
5310
+ /* @__PURE__ */ jsxRuntime.jsx(MySignatureContextItems, {})
5311
+ ] })
5312
+ ] }),
5313
+ !compact && /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.PageNumber, {})
5314
+ ]
5315
+ }
4955
5316
  )
4956
- }
4957
- ),
4958
- !stream && /* @__PURE__ */ jsxRuntime.jsx(WordShortcuts, { scope: stageRef }),
4959
- !stream && /* @__PURE__ */ jsxRuntime.jsx(TableTabKeys, { scope: stageRef }),
4960
- /* @__PURE__ */ jsxRuntime.jsxs(
4961
- "div",
4962
- {
4963
- className: "native-docx-stage",
4964
- ref: stageRef,
4965
- onMouseDownCapture: (event) => {
4966
- if (event.button === 2 && ref.current?.getSelectionPlacement())
4967
- event.preventDefault();
4968
- },
4969
- children: [
4970
- /* @__PURE__ */ jsxRuntime.jsxs(react.DocxEditor.Viewport, { className: "native-docx-viewport", children: [
4971
- /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Content, {}),
4972
- /* @__PURE__ */ jsxRuntime.jsxs(
4973
- DocxMentions,
4974
- {
4975
- initialCommentId,
4976
- mentions: adapter.mentions,
4977
- notify: adapter.notify,
4978
- getAgentStatus: adapter.getAgentStatus,
4979
- requestAgent: adapter.requestAgent ? (request) => adapter.requestAgent(documentId, request) : void 0,
4980
- children: [
4981
- /* @__PURE__ */ jsxRuntime.jsx(RoomInputBinding, { session: ready.room?.session }),
4982
- /* @__PURE__ */ jsxRuntime.jsx(AgentUndoRoom.Provider, { value: ready.room?.ydoc ?? null, children: /* @__PURE__ */ jsxRuntime.jsx(DocxEditorReview, { children: () => /* @__PURE__ */ jsxRuntime.jsxs(DocxEditorReview.Card, { children: [
4983
- /* @__PURE__ */ jsxRuntime.jsx(DocxCommentActivity, {}),
4984
- /* @__PURE__ */ jsxRuntime.jsx(AgentUndo, {})
4985
- ] }) }) })
4986
- ]
4987
- }
4988
- ),
4989
- !compact && /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.HeaderFooterChrome, {}),
4990
- !compact && /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.NotesChrome, {}),
4991
- /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Equation, {}),
4992
- /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.HyperLink, {}),
4993
- /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.ContextMenu, { children: /* @__PURE__ */ jsxRuntime.jsx(DocxContextMenuExtras, {}) })
4994
- ] }),
4995
- !compact && /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.PageNumber, {})
4996
- ]
4997
- }
4998
- )
4999
- ]
5317
+ ]
5318
+ }
5319
+ )
5000
5320
  }
5001
5321
  )
5002
5322
  }
@@ -5101,9 +5421,12 @@ exports.GenerateImageButton = GenerateImageButton;
5101
5421
  exports.HouseTemplateProvider = HouseTemplateProvider;
5102
5422
  exports.LinkHoverCard = LinkHoverCard;
5103
5423
  exports.NativeDocxEditor = NativeDocxEditor;
5424
+ exports.SignatureFieldMenu = SignatureFieldMenu;
5425
+ exports.SignatureFieldsProvider = SignatureFieldsProvider;
5104
5426
  exports.builtinHouseTemplate = builtinHouseTemplate;
5105
5427
  exports.contentPath = contentPath;
5106
5428
  exports.editorPort = editorPort;
5429
+ exports.insertSignatureField = insertSignatureField;
5107
5430
  exports.normalizeDocxExport = normalizeDocxExport;
5108
5431
  exports.referenceText = referenceText;
5109
5432
  exports.referencesPort = referencesPort;
@@ -5120,5 +5443,5 @@ exports.useReview = useReview;
5120
5443
  exports.useReviewItem = useReviewItem;
5121
5444
  exports.useTrackedOrNoted = useTrackedOrNoted;
5122
5445
  exports.withDirectEditing = withDirectEditing;
5123
- //# sourceMappingURL=chunk-JSQEAPTC.cjs.map
5124
- //# sourceMappingURL=chunk-JSQEAPTC.cjs.map
5446
+ //# sourceMappingURL=chunk-4GITK3Q5.cjs.map
5447
+ //# sourceMappingURL=chunk-4GITK3Q5.cjs.map