@a3s-lab/office 0.2.2 → 0.4.0

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 (277) hide show
  1. package/COLLABORATION_ROADMAP.md +426 -0
  2. package/README.md +649 -10
  3. package/dist/0~1403.js +1 -1
  4. package/dist/0~2805.js +1279 -0
  5. package/dist/{0~use-office-draft.js → 0~345.js} +30 -1
  6. package/dist/0~3539.js +1 -1
  7. package/dist/0~3557.js +1 -1
  8. package/dist/0~3635.js +1 -1
  9. package/dist/0~4595.js +123 -12
  10. package/dist/0~4980.js +154 -0
  11. package/dist/0~5050.js +124 -113
  12. package/dist/{0~9512.js → 0~6090.js} +540 -3
  13. package/dist/0~7048.js +92 -66
  14. package/dist/0~7614.js +2 -1
  15. package/dist/0~7754.js +5653 -0
  16. package/dist/0~9445.js +1 -1
  17. package/dist/0~document-editor.js +4992 -3323
  18. package/dist/0~markdown-editor.js +250 -44
  19. package/dist/0~pdf-viewer.js +1016 -24
  20. package/dist/0~presentation-editor.js +179 -8
  21. package/dist/0~spreadsheet-editor.js +3371 -578
  22. package/dist/0~work-docx-export.js +6801 -658
  23. package/dist/0~work-docx-import.js +1388 -795
  24. package/dist/0~work-office-diagnostics.js +524 -30
  25. package/dist/0~work-pptx-export.js +2 -1
  26. package/dist/0~work-pptx-import.js +1 -2
  27. package/dist/0~work-presentation-charts.js +1 -1
  28. package/dist/2591.js +197 -0
  29. package/dist/3818.js +1090 -0
  30. package/dist/4104.js +970 -60
  31. package/dist/432.js +171 -14
  32. package/dist/4476.js +2008 -0
  33. package/dist/4560.js +674 -0
  34. package/dist/4650.js +70 -0
  35. package/dist/{1134.js → 5184.js} +183 -1
  36. package/dist/6489.js +18 -18
  37. package/dist/7060.js +132 -0
  38. package/dist/8715.js +2 -136
  39. package/dist/8928.js +16778 -0
  40. package/dist/9787.js +209 -0
  41. package/dist/core.d.ts +29 -9
  42. package/dist/core.js +10 -2
  43. package/dist/index.js +13 -3
  44. package/dist/internal/collaboration/office-collaboration-flat-json.d.ts +13 -0
  45. package/dist/internal/collaboration/office-collaboration-json.d.ts +4 -0
  46. package/dist/internal/collaboration/office-collaboration-presence.d.ts +86 -0
  47. package/dist/internal/collaboration/office-collaboration-transport.d.ts +42 -0
  48. package/dist/internal/collaboration/office-collaboration.d.ts +85 -0
  49. package/dist/internal/collaboration/office-document-collaboration-bibliography.d.ts +7 -0
  50. package/dist/internal/collaboration/office-document-collaboration-claims.d.ts +9 -0
  51. package/dist/internal/collaboration/office-document-collaboration-comments.d.ts +7 -0
  52. package/dist/internal/collaboration/office-document-collaboration-sidecar-utils.d.ts +27 -0
  53. package/dist/internal/collaboration/office-document-collaboration-sidecars.d.ts +16 -0
  54. package/dist/internal/collaboration/office-document-collaboration.d.ts +45 -0
  55. package/dist/internal/collaboration/office-markdown-collaboration.d.ts +31 -0
  56. package/dist/internal/collaboration/office-pdf-collaboration-claims.d.ts +4 -0
  57. package/dist/internal/collaboration/office-pdf-collaboration-conflicts.d.ts +2 -0
  58. package/dist/internal/collaboration/office-pdf-collaboration-model.d.ts +26 -0
  59. package/dist/internal/collaboration/office-pdf-collaboration-records.d.ts +21 -0
  60. package/dist/internal/collaboration/office-pdf-collaboration-types.d.ts +91 -0
  61. package/dist/internal/collaboration/office-pdf-collaboration-validation.d.ts +4 -0
  62. package/dist/internal/collaboration/office-pdf-collaboration.d.ts +35 -0
  63. package/dist/internal/collaboration/office-presentation-collaboration-model.d.ts +25 -0
  64. package/dist/internal/collaboration/office-presentation-collaboration-records.d.ts +22 -0
  65. package/dist/internal/collaboration/office-presentation-collaboration-validation.d.ts +4 -0
  66. package/dist/internal/collaboration/office-presentation-collaboration.d.ts +32 -0
  67. package/dist/internal/collaboration/office-spreadsheet-collaboration-cells.d.ts +13 -0
  68. package/dist/internal/collaboration/office-spreadsheet-collaboration-claims.d.ts +4 -0
  69. package/dist/internal/collaboration/office-spreadsheet-collaboration-conflicts.d.ts +2 -0
  70. package/dist/internal/collaboration/office-spreadsheet-collaboration-flat-json.d.ts +10 -0
  71. package/dist/internal/collaboration/office-spreadsheet-collaboration-model.d.ts +31 -0
  72. package/dist/internal/collaboration/office-spreadsheet-collaboration-records.d.ts +17 -0
  73. package/dist/internal/collaboration/office-spreadsheet-collaboration-validation.d.ts +4 -0
  74. package/dist/internal/collaboration/office-spreadsheet-collaboration.d.ts +32 -0
  75. package/dist/internal/design-system/primitives/navigation/tabs.d.ts +3 -1
  76. package/dist/internal/features/work/components/work-document-page-border.d.ts +6 -0
  77. package/dist/internal/features/work/editors/document-command-catalog.d.ts +536 -0
  78. package/dist/internal/features/work/editors/document-editor-focus.d.ts +1 -1
  79. package/dist/internal/features/work/editors/document-editor-support.d.ts +7 -3
  80. package/dist/internal/features/work/editors/document-editor.d.ts +8 -2
  81. package/dist/internal/features/work/editors/document-external-content.d.ts +14 -0
  82. package/dist/internal/features/work/editors/document-format-clipboard.d.ts +6 -0
  83. package/dist/internal/features/work/editors/document-format-tools.d.ts +4 -0
  84. package/dist/internal/features/work/editors/document-layout-panel.d.ts +4 -1
  85. package/dist/internal/features/work/editors/document-page-chrome-wps-shortcuts.d.ts +2 -0
  86. package/dist/internal/features/work/editors/document-page-layout-ribbon.d.ts +14 -0
  87. package/dist/internal/features/work/editors/document-page-stack.d.ts +10 -1
  88. package/dist/internal/features/work/editors/document-page-thumbnail.d.ts +2 -0
  89. package/dist/internal/features/work/editors/document-pagination-run-coordinator.d.ts +26 -0
  90. package/dist/internal/features/work/editors/document-picture-properties-dialog-model.d.ts +20 -1
  91. package/dist/internal/features/work/editors/document-review-navigation.d.ts +9 -0
  92. package/dist/internal/features/work/editors/document-statistics-dialog.d.ts +7 -0
  93. package/dist/internal/features/work/editors/document-status-bar.d.ts +2 -1
  94. package/dist/internal/features/work/editors/document-table-properties-dialog-model.d.ts +4 -1
  95. package/dist/internal/features/work/editors/document-toolbar.d.ts +19 -42
  96. package/dist/internal/features/work/editors/document-wps-shortcuts.d.ts +12 -0
  97. package/dist/internal/features/work/editors/document-zoom.d.ts +17 -0
  98. package/dist/internal/features/work/editors/markdown-editor-focus.d.ts +1 -1
  99. package/dist/internal/features/work/editors/markdown-editor.d.ts +5 -1
  100. package/dist/internal/features/work/editors/markdown-toolbar.d.ts +2 -1
  101. package/dist/internal/features/work/editors/office-collaboration-participants.d.ts +3 -0
  102. package/dist/internal/features/work/editors/office-collaboration-presence-context.d.ts +17 -0
  103. package/dist/internal/features/work/editors/office-collaboration-presence-ui.d.ts +25 -0
  104. package/dist/internal/features/work/editors/office-editor-focus-handoff.d.ts +27 -0
  105. package/dist/internal/features/work/editors/pdf-annotation-controller.d.ts +5 -0
  106. package/dist/internal/features/work/editors/pdf-collaboration-presence.d.ts +3 -0
  107. package/dist/internal/features/work/editors/pdf-collaboration-projection.d.ts +10 -0
  108. package/dist/internal/features/work/editors/pdf-evidence-contract.d.ts +36 -0
  109. package/dist/internal/features/work/editors/pdf-evidence-overlay.d.ts +37 -0
  110. package/dist/internal/features/work/editors/pdf-toolbar.d.ts +2 -1
  111. package/dist/internal/features/work/editors/pdf-viewer-controller.d.ts +7 -1
  112. package/dist/internal/features/work/editors/pdf-viewer.d.ts +11 -1
  113. package/dist/internal/features/work/editors/presentation-collaboration-presence.d.ts +5 -0
  114. package/dist/internal/features/work/editors/presentation-editor-focus.d.ts +3 -2
  115. package/dist/internal/features/work/editors/presentation-editor-types.d.ts +3 -0
  116. package/dist/internal/features/work/editors/presentation-editor.d.ts +1 -1
  117. package/dist/internal/features/work/editors/spreadsheet-auto-filter.d.ts +9 -0
  118. package/dist/internal/features/work/editors/spreadsheet-cell-clear.d.ts +3 -0
  119. package/dist/internal/features/work/editors/spreadsheet-cell-merge.d.ts +12 -0
  120. package/dist/internal/features/work/editors/spreadsheet-clipboard-shortcuts.d.ts +3 -7
  121. package/dist/internal/features/work/editors/spreadsheet-collaboration-presence.d.ts +9 -0
  122. package/dist/internal/features/work/editors/spreadsheet-command-catalog.d.ts +464 -0
  123. package/dist/internal/features/work/editors/spreadsheet-command-controller.d.ts +45 -9
  124. package/dist/internal/features/work/editors/spreadsheet-context-menu.d.ts +2 -0
  125. package/dist/internal/features/work/editors/spreadsheet-editor-ribbon.d.ts +9 -28
  126. package/dist/internal/features/work/editors/spreadsheet-editor.d.ts +8 -2
  127. package/dist/internal/features/work/editors/spreadsheet-format-painter.d.ts +27 -0
  128. package/dist/internal/features/work/editors/spreadsheet-freeze-panes.d.ts +14 -0
  129. package/dist/internal/features/work/editors/use-document-insert-commands.d.ts +3 -2
  130. package/dist/internal/features/work/editors/use-document-pagination.d.ts +6 -1
  131. package/dist/internal/features/work/editors/use-document-review-conflicts.d.ts +28 -0
  132. package/dist/internal/features/work/editors/use-spreadsheet-auto-filter.d.ts +21 -0
  133. package/dist/internal/features/work/editors/use-spreadsheet-collaboration.d.ts +27 -0
  134. package/dist/internal/features/work/editors/use-spreadsheet-format-painter.d.ts +18 -0
  135. package/dist/internal/features/work/editors/work-office-chrome.d.ts +22 -3
  136. package/dist/internal/features/work/editors/work-office-ribbon-overflow.d.ts +2 -0
  137. package/dist/internal/features/work/work-document-bookmark-references.d.ts +37 -0
  138. package/dist/internal/features/work/work-document-bookmarks.d.ts +29 -0
  139. package/dist/internal/features/work/work-document-caption-nodes.d.ts +4 -1
  140. package/dist/internal/features/work/work-document-comments.d.ts +1 -1
  141. package/dist/internal/features/work/work-document-equations.d.ts +513 -0
  142. package/dist/internal/features/work/work-document-extensions.d.ts +1 -0
  143. package/dist/internal/features/work/work-document-field-identity.d.ts +2 -0
  144. package/dist/internal/features/work/work-document-field-node.d.ts +2 -2
  145. package/dist/internal/features/work/work-document-fields.d.ts +7 -0
  146. package/dist/internal/features/work/work-document-image-identity.d.ts +30 -0
  147. package/dist/internal/features/work/work-document-image-layout.d.ts +46 -1
  148. package/dist/internal/features/work/work-document-image-wrap-contour.d.ts +16 -0
  149. package/dist/internal/features/work/work-document-incremental-layout.d.ts +2 -2
  150. package/dist/internal/features/work/work-document-model-codec.d.ts +4 -1
  151. package/dist/internal/features/work/work-document-note-integrity.d.ts +2 -0
  152. package/dist/internal/features/work/work-document-page-borders.d.ts +25 -0
  153. package/dist/internal/features/work/work-document-page-capture.d.ts +8 -0
  154. package/dist/internal/features/work/work-document-page-frames.d.ts +15 -0
  155. package/dist/internal/features/work/work-document-page-margins.d.ts +56 -0
  156. package/dist/internal/features/work/work-document-page-size.d.ts +47 -0
  157. package/dist/internal/features/work/work-document-pagination-measurement.d.ts +1 -2
  158. package/dist/internal/features/work/work-document-pagination-types.d.ts +7 -2
  159. package/dist/internal/features/work/work-document-pagination.d.ts +2 -2
  160. package/dist/internal/features/work/work-document-paragraph-borders.d.ts +32 -0
  161. package/dist/internal/features/work/work-document-paragraph-identity.d.ts +26 -0
  162. package/dist/internal/features/work/work-document-paragraph-shading.d.ts +18 -0
  163. package/dist/internal/features/work/work-document-review-conflicts.d.ts +35 -0
  164. package/dist/internal/features/work/work-document-section.d.ts +4 -0
  165. package/dist/internal/features/work/work-document-snapshot.d.ts +19 -0
  166. package/dist/internal/features/work/work-document-source.d.ts +23 -0
  167. package/dist/internal/features/work/work-document-table-column-widths.d.ts +7 -0
  168. package/dist/internal/features/work/work-document-table-property-changes.d.ts +3 -0
  169. package/dist/internal/features/work/work-document-table-row-identity.d.ts +15 -0
  170. package/dist/internal/features/work/work-document-table-sizing.d.ts +3 -0
  171. package/dist/internal/features/work/work-document-text-layout.d.ts +3 -1
  172. package/dist/internal/features/work/work-document-word-line-metrics.d.ts +2 -0
  173. package/dist/internal/features/work/work-docx-bookmark-diagnostics.d.ts +3 -0
  174. package/dist/internal/features/work/work-docx-bookmark-import.d.ts +24 -0
  175. package/dist/internal/features/work/work-docx-bookmarks.d.ts +17 -0
  176. package/dist/internal/features/work/work-docx-comment-durable-id-preservation.d.ts +2 -0
  177. package/dist/internal/features/work/work-docx-comment-export.d.ts +3 -0
  178. package/dist/internal/features/work/work-docx-comment-metadata.d.ts +2 -0
  179. package/dist/internal/features/work/work-docx-drawing-extension-preservation.d.ts +4 -0
  180. package/dist/internal/features/work/work-docx-equation-diagnostics.d.ts +3 -0
  181. package/dist/internal/features/work/work-docx-equation-export.d.ts +14 -0
  182. package/dist/internal/features/work/work-docx-equation-import.d.ts +30 -0
  183. package/dist/internal/features/work/work-docx-equation-story.d.ts +9 -0
  184. package/dist/internal/features/work/work-docx-export-formatting.d.ts +3 -1
  185. package/dist/internal/features/work/work-docx-export-image.d.ts +5 -1
  186. package/dist/internal/features/work/work-docx-export.d.ts +1 -1
  187. package/dist/internal/features/work/work-docx-field-instructions.d.ts +8 -0
  188. package/dist/internal/features/work/work-docx-font-table-preservation.d.ts +3 -0
  189. package/dist/internal/features/work/work-docx-ignorable-extension-preservation.d.ts +15 -0
  190. package/dist/internal/features/work/work-docx-image-crop.d.ts +12 -0
  191. package/dist/internal/features/work/work-docx-image-identity.d.ts +17 -0
  192. package/dist/internal/features/work/work-docx-image-layer.d.ts +12 -0
  193. package/dist/internal/features/work/work-docx-image-layout-import.d.ts +14 -2
  194. package/dist/internal/features/work/work-docx-image-wrap.d.ts +15 -0
  195. package/dist/internal/features/work/work-docx-import.d.ts +13 -3
  196. package/dist/internal/features/work/work-docx-list-export.d.ts +18 -0
  197. package/dist/internal/features/work/work-docx-list-import.d.ts +14 -0
  198. package/dist/internal/features/work/work-docx-note-comment-content-control-block-preservation.d.ts +18 -0
  199. package/dist/internal/features/work/work-docx-note-comment-content-control-model.d.ts +47 -0
  200. package/dist/internal/features/work/work-docx-note-comment-content-control-preservation.d.ts +4 -0
  201. package/dist/internal/features/work/work-docx-note-comment-content-control-properties.d.ts +17 -0
  202. package/dist/internal/features/work/work-docx-note-comment-content-control-table-model.d.ts +17 -0
  203. package/dist/internal/features/work/work-docx-note-comment-content-control-xml.d.ts +14 -0
  204. package/dist/internal/features/work/work-docx-note-comment-extension-preservation.d.ts +2 -0
  205. package/dist/internal/features/work/work-docx-note-comment-hyperlink-content.d.ts +40 -0
  206. package/dist/internal/features/work/work-docx-note-comment-hyperlink-preservation.d.ts +5 -0
  207. package/dist/internal/features/work/work-docx-note-comment-hyperlink-relationships.d.ts +35 -0
  208. package/dist/internal/features/work/work-docx-note-comment-identity.d.ts +15 -0
  209. package/dist/internal/features/work/work-docx-note-comment-run-preservation.d.ts +4 -0
  210. package/dist/internal/features/work/work-docx-note-comment-run-properties.d.ts +2 -0
  211. package/dist/internal/features/work/work-docx-note-image-import.d.ts +12 -0
  212. package/dist/internal/features/work/work-docx-note-image-relationships.d.ts +1 -0
  213. package/dist/internal/features/work/work-docx-numbering-extension-preservation.d.ts +6 -0
  214. package/dist/internal/features/work/work-docx-numbering.d.ts +1 -0
  215. package/dist/internal/features/work/work-docx-page-borders-diagnostics.d.ts +3 -0
  216. package/dist/internal/features/work/work-docx-page-borders-import.d.ts +10 -0
  217. package/dist/internal/features/work/work-docx-page-margins-diagnostics.d.ts +3 -0
  218. package/dist/internal/features/work/work-docx-page-margins-import.d.ts +18 -0
  219. package/dist/internal/features/work/work-docx-page-size-diagnostics.d.ts +2 -0
  220. package/dist/internal/features/work/work-docx-page-size-import.d.ts +17 -0
  221. package/dist/internal/features/work/work-docx-paragraph-borders-diagnostics.d.ts +3 -0
  222. package/dist/internal/features/work/work-docx-paragraph-borders-export.d.ts +18 -0
  223. package/dist/internal/features/work/work-docx-paragraph-borders-import.d.ts +24 -0
  224. package/dist/internal/features/work/work-docx-paragraph-default-collapsed.d.ts +19 -0
  225. package/dist/internal/features/work/work-docx-paragraph-extension-preservation.d.ts +2 -0
  226. package/dist/internal/features/work/work-docx-paragraph-identity-import.d.ts +10 -0
  227. package/dist/internal/features/work/work-docx-paragraph-identity.d.ts +18 -0
  228. package/dist/internal/features/work/work-docx-paragraph-pagination-import.d.ts +6 -1
  229. package/dist/internal/features/work/work-docx-paragraph-shading-diagnostics.d.ts +3 -0
  230. package/dist/internal/features/work/work-docx-paragraph-shading-export.d.ts +5 -0
  231. package/dist/internal/features/work/work-docx-paragraph-shading-import.d.ts +18 -0
  232. package/dist/internal/features/work/work-docx-run-formatting-import.d.ts +3 -0
  233. package/dist/internal/features/work/work-docx-settings-preservation.d.ts +10 -0
  234. package/dist/internal/features/work/work-docx-settings-xml.d.ts +16 -0
  235. package/dist/internal/features/work/work-docx-style-extension-preservation.d.ts +2 -0
  236. package/dist/internal/features/work/work-docx-table-cell-export.d.ts +2 -1
  237. package/dist/internal/features/work/work-docx-table-cell-import.d.ts +3 -0
  238. package/dist/internal/features/work/work-docx-table-extension-preservation.d.ts +2 -0
  239. package/dist/internal/features/work/work-docx-table-row-import.d.ts +2 -0
  240. package/dist/internal/features/work/work-docx-table-sizing-import.d.ts +1 -0
  241. package/dist/internal/features/work/work-docx-theme-reference.d.ts +23 -0
  242. package/dist/internal/features/work/work-docx-theme.d.ts +4 -1
  243. package/dist/internal/features/work/work-docx-twips.d.ts +12 -0
  244. package/dist/internal/features/work/work-file-contract.d.ts +1 -0
  245. package/dist/internal/features/work/work-file-io.d.ts +1 -1
  246. package/dist/internal/features/work/work-markdown-extensions.d.ts +4 -1
  247. package/dist/internal/features/work/work-ooxml-package-preservation.d.ts +12 -0
  248. package/dist/internal/features/work/work-ooxml-package-security.d.ts +6 -0
  249. package/dist/internal/features/work/work-ooxml-relationship-preservation.d.ts +10 -0
  250. package/dist/internal/features/work/work-ooxml-xml.d.ts +2 -0
  251. package/dist/internal/features/work/work-pdf-export.d.ts +10 -0
  252. package/dist/internal/features/work/work-repository.d.ts +2 -0
  253. package/dist/internal/features/work/work-types.d.ts +15 -2
  254. package/dist/internal/kernel/office-kernel-client-types.d.ts +1 -0
  255. package/dist/internal/kernel/office-kernel-protocol.d.ts +7 -0
  256. package/dist/internal/kernel/office-kernel-version.d.ts +1 -1
  257. package/dist/office-kernel.wasm +0 -0
  258. package/dist/office-kernel.worker.js +93 -41
  259. package/dist/react.d.ts +18 -12
  260. package/dist/react.js +1 -1
  261. package/dist/styles.css +1367 -16
  262. package/dist/vue.d.ts +48 -5
  263. package/dist/vue.js +42 -3
  264. package/dist/web-component.d.ts +24 -2
  265. package/dist/web-component.js +101 -2
  266. package/docs/latest/en/browser-editor-architecture.md +262 -47
  267. package/package.json +29 -4
  268. package/dist/0~152.js +0 -94
  269. package/dist/0~2582.js +0 -485
  270. package/dist/0~4750.js +0 -939
  271. package/dist/0~5861.js +0 -596
  272. package/dist/0~work-document-extensions.js +0 -3045
  273. package/dist/0~work-document-model-codec.js +0 -42
  274. package/dist/0~work-docx-bibliography.js +0 -347
  275. package/dist/0~work-docx-page-color.js +0 -42
  276. package/dist/2881.js +0 -1455
  277. package/dist/8728.js +0 -723
@@ -1,4 +1,5 @@
1
1
  import { useCallback, useRef, useState } from "react";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
2
3
  function useOfficeDraft(createInitial) {
3
4
  const [initial] = useState(createInitial);
4
5
  const [draft, setDraftState] = useState(initial);
@@ -43,4 +44,32 @@ function useOfficeDraft(createInitial) {
43
44
  syncDraft
44
45
  };
45
46
  }
46
- export { useOfficeDraft };
47
+ function InlineNotice({ title, children, icon, actions, tone = 'info', role, className = '' }) {
48
+ return /*#__PURE__*/ jsxs("div", {
49
+ className: `ds-inline-notice ${tone}${className ? ` ${className}` : ''}`,
50
+ role: role,
51
+ children: [
52
+ icon && /*#__PURE__*/ jsx("span", {
53
+ className: "ds-inline-notice-icon",
54
+ "aria-hidden": "true",
55
+ children: icon
56
+ }),
57
+ /*#__PURE__*/ jsxs("div", {
58
+ className: "ds-inline-notice-copy",
59
+ children: [
60
+ title && /*#__PURE__*/ jsx("strong", {
61
+ children: title
62
+ }),
63
+ /*#__PURE__*/ jsx("div", {
64
+ children: children
65
+ })
66
+ ]
67
+ }),
68
+ actions && /*#__PURE__*/ jsx("div", {
69
+ className: "ds-inline-notice-actions",
70
+ children: actions
71
+ })
72
+ ]
73
+ });
74
+ }
75
+ export { InlineNotice, useOfficeDraft };
package/dist/0~3539.js CHANGED
@@ -7,7 +7,7 @@ import { presentationChartLegendPositionLabel, presentationChartShowsLegend, nor
7
7
  import { OfficeCheckbox, CommittedOfficeNumberField, CollectionState } from "./0~7048.js";
8
8
  import { OfficeColorPicker } from "./0~3635.js";
9
9
  import { OfficeSelect } from "./0~4595.js";
10
- import { office_text_field_OfficeTextField, CommittedOfficeTextField } from "./0~9512.js";
10
+ import { office_text_field_OfficeTextField, CommittedOfficeTextField } from "./0~6090.js";
11
11
  function spreadsheetAgentMenuItems(selection, onAgentRequest, applyProposal) {
12
12
  return [
13
13
  {
package/dist/0~3557.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useLayoutEffect, useMemo, useRef } from "react";
2
- import { matchesOfficeEditorKeyboardShortcut } from "./0~9512.js";
2
+ import { matchesOfficeEditorKeyboardShortcut } from "./0~6090.js";
3
3
  const DEFAULT_EXTENSION_PRIORITY = 100;
4
4
  function createOfficeEditorExtension(config) {
5
5
  const name = config.name.trim();
package/dist/0~3635.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Check, ChevronDown } from "lucide-react";
3
3
  import { useEffect, useRef, useState } from "react";
4
- import { button_Button, Popover } from "./0~9512.js";
4
+ import { button_Button, Popover } from "./0~6090.js";
5
5
  const THEME_COLORS = [
6
6
  '#111827',
7
7
  '#1f2937',
package/dist/0~4595.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Fragment as jsx_runtime_Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Fragment, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
3
3
  import { createPortal } from "react-dom";
4
- import { Check, ChevronDown, ChevronLeft, ChevronRight, Eye, Minus, Plus, X } from "lucide-react";
5
- import { moveOfficeMenuFocus, useDialogFocusScope, icon_button_IconButton, Popover, matchesAriaKeyShortcuts, officeOverlayPortalRoot } from "./0~9512.js";
4
+ import { Check, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, Eye, Minus, Plus, X } from "lucide-react";
5
+ import { WorkOfficeCollaborationParticipants, moveOfficeMenuFocus, useDialogFocusScope, icon_button_IconButton, Popover, matchesAriaKeyShortcuts, officeOverlayPortalRoot } from "./0~6090.js";
6
6
  const CONTEXT_MENU_MARGIN = 8;
7
7
  const CONTEXT_MENU_TAB_STOP_SELECTOR = 'a[href]:not([tabindex="-1"]), button:not(:disabled):not([tabindex="-1"]), input:not(:disabled):not([type="hidden"]):not([tabindex="-1"]), select:not(:disabled):not([tabindex="-1"]), textarea:not(:disabled):not([tabindex="-1"]), [contenteditable="true"]:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])';
8
8
  function isWorkspaceContextMenuKeyboardEvent({ key, shiftKey }) {
@@ -542,7 +542,7 @@ function useTabNavigation({ items, onChange }) {
542
542
  setTabElement
543
543
  };
544
544
  }
545
- function Tabs({ ariaLabel, value, items, onChange, variant = 'segment', size = 'standard', className = '', containerRef }) {
545
+ function Tabs({ ariaLabel, value, items, onChange, onTabDoubleClick, variant = 'segment', size = 'standard', className = '', containerRef }) {
546
546
  const tabNavigation = useTabNavigation({
547
547
  items,
548
548
  onChange
@@ -562,12 +562,14 @@ function Tabs({ ariaLabel, value, items, onChange, variant = 'segment', size = '
562
562
  role: "tab",
563
563
  id: item.tabId,
564
564
  "data-tab-id": item.id,
565
+ "data-contextual": item.contextual ? 'true' : void 0,
565
566
  "aria-label": item.label,
566
567
  "aria-selected": selected,
567
568
  "aria-controls": item.panelId,
568
569
  tabIndex: selected ? 0 : -1,
569
570
  disabled: item.disabled,
570
571
  onClick: ()=>onChange(item.id),
572
+ onDoubleClick: ()=>onTabDoubleClick?.(item.id),
571
573
  onKeyDown: (event)=>tabNavigation.handleTabKeyDown(event, item.id),
572
574
  children: [
573
575
  item.icon && /*#__PURE__*/ jsx("span", {
@@ -663,6 +665,11 @@ function roundSliderValue(value, step) {
663
665
  return Number((Math.round(value / step) * step).toFixed(decimalPlaces));
664
666
  }
665
667
  const WORK_OFFICE_RIBBON_SCROLL_INSET = 34;
668
+ function calculateRibbonDensity(clientWidth) {
669
+ if (clientWidth <= 0 || clientWidth >= 1120) return 'comfortable';
670
+ if (clientWidth >= 760) return 'compact-low';
671
+ return 'compact-normal';
672
+ }
666
673
  function calculateRibbonOverflow({ clientWidth, items, scrollLeft }) {
667
674
  const lastItem = items.at(-1);
668
675
  if (!lastItem || clientWidth <= 0) return {
@@ -689,9 +696,12 @@ function calculateRibbonScrollTarget({ clientWidth, direction, items, scrollLeft
689
696
  if (!target) return scrollLeft;
690
697
  return Math.max(0, target.left - WORK_OFFICE_RIBBON_SCROLL_INSET);
691
698
  }
692
- function WorkOfficeRibbon({ ariaLabel, tabs, defaultTab, activeTab, onTabChange, panels, fileActions, className = '', toolbarClassName = '' }) {
699
+ function WorkOfficeRibbon({ ariaLabel, tabs, defaultTab, activeTab, onTabChange, panels, fileActions, quickAccessActions, adaptive = false, collapsible = false, collapsed: controlledCollapsed, defaultCollapsed = false, onCollapsedChange, className = '', toolbarClassName = '' }) {
693
700
  const reactId = useId().replaceAll(':', '');
694
701
  const [internalTab, setInternalTab] = useState(defaultTab);
702
+ const [internalCollapsed, setInternalCollapsed] = useState(defaultCollapsed);
703
+ const [temporarilyExpanded, setTemporarilyExpanded] = useState(false);
704
+ const [ribbonDensity, setRibbonDensity] = useState('comfortable');
695
705
  const [ribbonOverflow, setRibbonOverflow] = useState({
696
706
  backward: false,
697
707
  forward: false
@@ -702,14 +712,21 @@ function WorkOfficeRibbon({ ariaLabel, tabs, defaultTab, activeTab, onTabChange,
702
712
  });
703
713
  const tabListRef = useRef(null);
704
714
  const toolbarRef = useRef(null);
715
+ const ribbonRef = useRef(null);
705
716
  const selectedTab = activeTab ?? internalTab;
706
717
  const selectedLabel = tabs.find((tab)=>tab.id === selectedTab)?.label ?? tabs[0]?.label ?? '';
718
+ const contextualTabActive = Boolean(tabs.find((tab)=>tab.id === selectedTab)?.contextual);
707
719
  const selectedPanel = panels[selectedTab];
708
720
  const hasSelectedPanel = null != selectedPanel;
721
+ const collapsed = collapsible && (controlledCollapsed ?? internalCollapsed);
722
+ const panelExpanded = hasSelectedPanel && (!collapsed || temporarilyExpanded);
709
723
  const hasRibbonOverflow = ribbonOverflow.backward || ribbonOverflow.forward;
710
724
  const updateRibbonOverflow = useCallback(()=>{
711
725
  const toolbar = toolbarRef.current;
712
726
  if (!toolbar) return;
727
+ const ribbonWidth = ribbonRef.current?.clientWidth || toolbar.clientWidth;
728
+ const nextDensity = adaptive ? calculateRibbonDensity(ribbonWidth) : 'comfortable';
729
+ setRibbonDensity((current)=>current === nextDensity ? current : nextDensity);
713
730
  const { backward, forward } = calculateRibbonOverflow({
714
731
  clientWidth: toolbar.clientWidth,
715
732
  items: ribbonItemGeometry(toolbar),
@@ -720,7 +737,9 @@ function WorkOfficeRibbon({ ariaLabel, tabs, defaultTab, activeTab, onTabChange,
720
737
  backward,
721
738
  forward
722
739
  });
723
- }, []);
740
+ }, [
741
+ adaptive
742
+ ]);
724
743
  const scrollRibbon = (direction)=>{
725
744
  const toolbar = toolbarRef.current;
726
745
  if (!toolbar) return;
@@ -759,8 +778,29 @@ function WorkOfficeRibbon({ ariaLabel, tabs, defaultTab, activeTab, onTabChange,
759
778
  };
760
779
  const selectTab = (tab)=>{
761
780
  if (void 0 === activeTab) setInternalTab(tab);
781
+ if (collapsed) setTemporarilyExpanded(true);
762
782
  onTabChange?.(tab);
763
783
  };
784
+ const changeCollapsed = useCallback((nextCollapsed)=>{
785
+ if (void 0 === controlledCollapsed) setInternalCollapsed(nextCollapsed);
786
+ setTemporarilyExpanded(false);
787
+ onCollapsedChange?.(nextCollapsed);
788
+ }, [
789
+ controlledCollapsed,
790
+ onCollapsedChange
791
+ ]);
792
+ useEffect(()=>{
793
+ if (!collapsed || !temporarilyExpanded) return;
794
+ const closeTemporaryPanel = (event)=>{
795
+ if (event.target instanceof Node && ribbonRef.current?.contains(event.target)) return;
796
+ setTemporarilyExpanded(false);
797
+ };
798
+ document.addEventListener('pointerdown', closeTemporaryPanel, true);
799
+ return ()=>document.removeEventListener('pointerdown', closeTemporaryPanel, true);
800
+ }, [
801
+ collapsed,
802
+ temporarilyExpanded
803
+ ]);
764
804
  useLayoutEffect(()=>{
765
805
  const toolbar = toolbarRef.current;
766
806
  if (!toolbar) return;
@@ -768,12 +808,12 @@ function WorkOfficeRibbon({ ariaLabel, tabs, defaultTab, activeTab, onTabChange,
768
808
  updateRibbonOverflow();
769
809
  }, [
770
810
  selectedTab,
771
- hasSelectedPanel,
811
+ panelExpanded,
772
812
  updateRibbonOverflow
773
813
  ]);
774
814
  useLayoutEffect(()=>{
775
815
  const toolbar = toolbarRef.current;
776
- if (!toolbar) return;
816
+ if (!toolbar || !panelExpanded) return;
777
817
  let frame = requestAnimationFrame(updateRibbonOverflow);
778
818
  const scheduleOverflowUpdate = ()=>{
779
819
  cancelAnimationFrame(frame);
@@ -803,7 +843,7 @@ function WorkOfficeRibbon({ ariaLabel, tabs, defaultTab, activeTab, onTabChange,
803
843
  window.removeEventListener('resize', scheduleOverflowUpdate);
804
844
  };
805
845
  }, [
806
- hasSelectedPanel,
846
+ panelExpanded,
807
847
  updateRibbonOverflow
808
848
  ]);
809
849
  useLayoutEffect(()=>{
@@ -848,8 +888,11 @@ function WorkOfficeRibbon({ ariaLabel, tabs, defaultTab, activeTab, onTabChange,
848
888
  updateTabOverflow
849
889
  ]);
850
890
  return /*#__PURE__*/ jsxs("section", {
891
+ ref: ribbonRef,
851
892
  className: `work-office-ribbon ${className}`.trim(),
852
893
  "aria-label": ariaLabel,
894
+ "data-collapsed": collapsed ? 'true' : void 0,
895
+ "data-contextual-active": contextualTabActive ? 'true' : void 0,
853
896
  children: [
854
897
  /*#__PURE__*/ jsxs("div", {
855
898
  className: "work-office-ribbon-tabs-row",
@@ -857,6 +900,9 @@ function WorkOfficeRibbon({ ariaLabel, tabs, defaultTab, activeTab, onTabChange,
857
900
  fileActions?.length ? /*#__PURE__*/ jsx(WorkOfficeFileMenu, {
858
901
  actions: fileActions
859
902
  }) : null,
903
+ quickAccessActions?.length ? /*#__PURE__*/ jsx(WorkOfficeQuickAccessToolbar, {
904
+ actions: quickAccessActions
905
+ }) : null,
860
906
  /*#__PURE__*/ jsxs("div", {
861
907
  className: "work-office-ribbon-tab-strip",
862
908
  children: [
@@ -872,7 +918,10 @@ function WorkOfficeRibbon({ ariaLabel, tabs, defaultTab, activeTab, onTabChange,
872
918
  tabId: `${reactId}-tab-${tab.id}`,
873
919
  panelId: `${reactId}-panel`
874
920
  })),
875
- onChange: selectTab
921
+ onChange: selectTab,
922
+ onTabDoubleClick: (tab)=>{
923
+ if (collapsible && tab === selectedTab) changeCollapsed(!collapsed);
924
+ }
876
925
  }),
877
926
  (tabOverflow.backward || tabOverflow.forward) && /*#__PURE__*/ jsxs("nav", {
878
927
  className: "work-office-ribbon-tab-navigation",
@@ -899,6 +948,22 @@ function WorkOfficeRibbon({ ariaLabel, tabs, defaultTab, activeTab, onTabChange,
899
948
  ]
900
949
  })
901
950
  ]
951
+ }),
952
+ collapsible && /*#__PURE__*/ jsx("button", {
953
+ type: "button",
954
+ className: "work-office-ribbon-collapse",
955
+ "aria-label": collapsed ? '展开功能区' : '折叠功能区',
956
+ title: collapsed ? '展开功能区' : '折叠功能区',
957
+ "aria-controls": `${reactId}-panel`,
958
+ "aria-expanded": panelExpanded,
959
+ onClick: ()=>changeCollapsed(!collapsed),
960
+ children: collapsed ? /*#__PURE__*/ jsx(ChevronDown, {
961
+ size: 14,
962
+ "aria-hidden": "true"
963
+ }) : /*#__PURE__*/ jsx(ChevronUp, {
964
+ size: 14,
965
+ "aria-hidden": "true"
966
+ })
902
967
  })
903
968
  ]
904
969
  }),
@@ -906,6 +971,7 @@ function WorkOfficeRibbon({ ariaLabel, tabs, defaultTab, activeTab, onTabChange,
906
971
  id: `${reactId}-panel`,
907
972
  className: "work-office-ribbon-panel",
908
973
  "data-empty": hasSelectedPanel ? void 0 : 'true',
974
+ hidden: !panelExpanded,
909
975
  role: "tabpanel",
910
976
  "aria-labelledby": `${reactId}-tab-${selectedTab}`,
911
977
  children: hasSelectedPanel && /*#__PURE__*/ jsxs(jsx_runtime_Fragment, {
@@ -923,6 +989,7 @@ function WorkOfficeRibbon({ ariaLabel, tabs, defaultTab, activeTab, onTabChange,
923
989
  /*#__PURE__*/ jsx("div", {
924
990
  ref: toolbarRef,
925
991
  className: `work-office-toolbar ${toolbarClassName}`.trim(),
992
+ "data-density": ribbonDensity,
926
993
  "data-has-overflow": hasRibbonOverflow ? 'true' : void 0,
927
994
  role: "toolbar",
928
995
  "aria-label": `${selectedLabel}工具栏`,
@@ -945,6 +1012,25 @@ function WorkOfficeRibbon({ ariaLabel, tabs, defaultTab, activeTab, onTabChange,
945
1012
  ]
946
1013
  });
947
1014
  }
1015
+ function WorkOfficeQuickAccessToolbar({ actions }) {
1016
+ return /*#__PURE__*/ jsx("div", {
1017
+ className: "work-office-quick-access",
1018
+ role: "toolbar",
1019
+ "aria-label": "快速访问工具栏",
1020
+ children: actions.map((action)=>/*#__PURE__*/ jsx("button", {
1021
+ type: "button",
1022
+ "aria-label": action.label,
1023
+ "aria-keyshortcuts": action.ariaKeyShortcuts,
1024
+ title: action.shortcut ? `${action.label}(${action.shortcut})` : action.label,
1025
+ disabled: action.disabled,
1026
+ onClick: ()=>void action.onSelect(),
1027
+ children: /*#__PURE__*/ jsx("span", {
1028
+ "aria-hidden": "true",
1029
+ children: action.icon
1030
+ })
1031
+ }, action.id))
1032
+ });
1033
+ }
948
1034
  function ribbonItemGeometry(toolbar) {
949
1035
  return Array.from(toolbar.children).flatMap((element)=>element instanceof HTMLElement ? [
950
1036
  ribbonItemBounds(toolbar, element)
@@ -990,6 +1076,9 @@ function WorkOfficePreviewBar({ ariaLabel, label, detail, fileActions, className
990
1076
  children: detail
991
1077
  })
992
1078
  ]
1079
+ }),
1080
+ /*#__PURE__*/ jsx(WorkOfficeCollaborationParticipants, {
1081
+ variant: "toolbar"
993
1082
  })
994
1083
  ]
995
1084
  });
@@ -1073,10 +1162,11 @@ function WorkOfficeFileMenu({ actions }) {
1073
1162
  })
1074
1163
  });
1075
1164
  }
1076
- function WorkOfficeRibbonGroup({ label, children }) {
1165
+ function WorkOfficeRibbonGroup({ label, priority = 'normal', children }) {
1077
1166
  return /*#__PURE__*/ jsxs("section", {
1078
1167
  className: "work-office-ribbon-group",
1079
1168
  "aria-label": label,
1169
+ "data-priority": priority,
1080
1170
  children: [
1081
1171
  /*#__PURE__*/ jsx("div", {
1082
1172
  children: children
@@ -1108,21 +1198,42 @@ function WorkOfficeRibbonButton({ label, visibleLabel = label, badge, active, di
1108
1198
  ]
1109
1199
  });
1110
1200
  }
1111
- function WorkOfficeStatusBar({ children, controls, className = '' }) {
1112
- return /*#__PURE__*/ jsxs("footer", {
1201
+ function WorkOfficeStatusBar({ ariaLabel = '编辑器状态栏', children, controls, controlsLabel = '视图与缩放', className = '' }) {
1202
+ return /*#__PURE__*/ jsxs("section", {
1113
1203
  className: `work-office-status ${className}`.trim(),
1204
+ "aria-label": ariaLabel,
1114
1205
  children: [
1115
1206
  /*#__PURE__*/ jsx("div", {
1116
1207
  className: "work-office-status-info",
1117
1208
  children: children
1118
1209
  }),
1210
+ /*#__PURE__*/ jsx(WorkOfficeCollaborationParticipants, {}),
1119
1211
  controls && /*#__PURE__*/ jsx("div", {
1120
1212
  className: "work-office-status-view",
1213
+ role: "toolbar",
1214
+ "aria-label": controlsLabel,
1215
+ onKeyDown: moveOfficeToolbarFocus,
1121
1216
  children: controls
1122
1217
  })
1123
1218
  ]
1124
1219
  });
1125
1220
  }
1221
+ function moveOfficeToolbarFocus(event) {
1222
+ if (![
1223
+ 'ArrowLeft',
1224
+ 'ArrowRight',
1225
+ 'Home',
1226
+ 'End'
1227
+ ].includes(event.key) || event.target instanceof HTMLElement && 'slider' === event.target.getAttribute('role')) return;
1228
+ const controls = [
1229
+ ...event.currentTarget.querySelectorAll('button:not(:disabled), [role="slider"]:not([aria-disabled="true"])')
1230
+ ];
1231
+ if (!controls.length) return;
1232
+ const currentIndex = controls.indexOf(document.activeElement);
1233
+ const nextIndex = 'Home' === event.key ? 0 : 'End' === event.key ? controls.length - 1 : 'ArrowRight' === event.key ? (currentIndex + 1 + controls.length) % controls.length : (currentIndex - 1 + controls.length) % controls.length;
1234
+ event.preventDefault();
1235
+ controls[nextIndex]?.focus();
1236
+ }
1126
1237
  function WorkOfficeZoomControls({ zoom, minimum = 50, maximum = 200, step = 10, decreaseLabel, increaseLabel, outputLabel, sliderLabel, onChange }) {
1127
1238
  const clamp = (value)=>Math.min(maximum, Math.max(minimum, Math.round(value)));
1128
1239
  return /*#__PURE__*/ jsxs(jsx_runtime_Fragment, {
package/dist/0~4980.js ADDED
@@ -0,0 +1,154 @@
1
+ import jszip from "jszip";
2
+ import { documentNoteKey } from "./8928.js";
3
+ import { directChild, xmlNamespacePrefix, attribute, parseXml } from "./5184.js";
4
+ import { DEFAULT_DOCUMENT_PAGE_COLOR, normalizeDocumentPageColor } from "./0~work-document-page-color.js";
5
+ const MAX_NATIVE_ID = 2147483647;
6
+ const MIN_NATIVE_COMMENT_ID = -2147483648;
7
+ function importedDocumentNoteId(kind, target) {
8
+ const match = new RegExp(`^${kind}-([1-9][0-9]{0,9})$`).exec(target);
9
+ const nativeId = match ? decimalId(match[1], false) : null;
10
+ return null === nativeId ? null : `docx-${kind}-${nativeId}`;
11
+ }
12
+ function assignDocxNoteIds(notes) {
13
+ const candidates = notes.map((note)=>({
14
+ key: documentNoteKey(note.kind, note.id),
15
+ kind: note.kind,
16
+ nativeId: documentNoteNativeId(note.kind, note.id)
17
+ }));
18
+ const counts = occurrenceCounts(candidates.flatMap(({ kind, nativeId })=>null === nativeId ? [] : [
19
+ `${kind}:${nativeId}`
20
+ ]));
21
+ const used = {
22
+ footnote: new Set(),
23
+ endnote: new Set()
24
+ };
25
+ for (const candidate of candidates)if (null !== candidate.nativeId && 1 === counts.get(`${candidate.kind}:${candidate.nativeId}`)) used[candidate.kind].add(candidate.nativeId);
26
+ const next = {
27
+ footnote: 1,
28
+ endnote: 1
29
+ };
30
+ return new Map(candidates.map((candidate)=>{
31
+ const stable = null !== candidate.nativeId && 1 === counts.get(`${candidate.kind}:${candidate.nativeId}`) ? candidate.nativeId : null;
32
+ const id = stable ?? nextAvailableId(used[candidate.kind], next, candidate.kind);
33
+ used[candidate.kind].add(id);
34
+ return [
35
+ candidate.key,
36
+ id
37
+ ];
38
+ }));
39
+ }
40
+ function assignDocxCommentThreads(comments) {
41
+ const candidates = [];
42
+ for (const comment of comments){
43
+ candidates.push({
44
+ nativeId: documentCommentNativeId(comment.id, false)
45
+ });
46
+ for (const reply of comment.replies ?? [])candidates.push({
47
+ nativeId: documentCommentNativeId(reply.id, true)
48
+ });
49
+ }
50
+ const counts = occurrenceCounts(candidates.flatMap(({ nativeId })=>null === nativeId ? [] : [
51
+ String(nativeId)
52
+ ]));
53
+ const used = new Set();
54
+ for (const candidate of candidates)if (null !== candidate.nativeId && 1 === counts.get(String(candidate.nativeId))) used.add(candidate.nativeId);
55
+ let nextId = 0;
56
+ const assigned = new Map();
57
+ for (const candidate of candidates){
58
+ const stable = null !== candidate.nativeId && 1 === counts.get(String(candidate.nativeId)) ? candidate.nativeId : null;
59
+ if (null !== stable) {
60
+ assigned.set(candidate, stable);
61
+ continue;
62
+ }
63
+ while(used.has(nextId))nextId += 1;
64
+ assigned.set(candidate, nextId);
65
+ used.add(nextId);
66
+ nextId += 1;
67
+ }
68
+ let index = 0;
69
+ return comments.map((comment)=>{
70
+ const root = candidates[index];
71
+ index += 1;
72
+ const replies = (comment.replies ?? []).map((reply)=>{
73
+ const candidate = candidates[index];
74
+ index += 1;
75
+ return {
76
+ id: assigned.get(candidate),
77
+ reply
78
+ };
79
+ });
80
+ return {
81
+ comment,
82
+ id: assigned.get(root),
83
+ replies
84
+ };
85
+ });
86
+ }
87
+ function documentNoteNativeId(kind, id) {
88
+ const match = /^docx-(footnote|endnote)-([1-9][0-9]{0,9})$/.exec(id);
89
+ return match?.[1] === kind ? decimalId(match[2], false) : null;
90
+ }
91
+ function documentCommentNativeId(id, reply) {
92
+ const pattern = reply ? /^docx-comment-reply-(0|-?[1-9][0-9]{0,9})$/ : /^docx-comment-(0|-?[1-9][0-9]{0,9})$/;
93
+ return normalizeDocxCommentId(pattern.exec(id)?.[1]);
94
+ }
95
+ function normalizeDocxCommentId(value) {
96
+ if (!value || !/^(?:0|-?[1-9][0-9]{0,9})$/.test(value)) return null;
97
+ const number = Number(value);
98
+ return Number.isSafeInteger(number) && number >= MIN_NATIVE_COMMENT_ID && number <= MAX_NATIVE_ID ? number : null;
99
+ }
100
+ function decimalId(value, allowZero) {
101
+ if (!value) return null;
102
+ const number = Number(value);
103
+ return Number.isSafeInteger(number) && number <= MAX_NATIVE_ID && (allowZero ? number >= 0 : number > 0) ? number : null;
104
+ }
105
+ function occurrenceCounts(values) {
106
+ const counts = new Map();
107
+ for (const value of values)counts.set(value, (counts.get(value) ?? 0) + 1);
108
+ return counts;
109
+ }
110
+ function nextAvailableId(used, next, kind) {
111
+ while(used.has(next[kind]))next[kind] += 1;
112
+ const id = next[kind];
113
+ next[kind] += 1;
114
+ return id;
115
+ }
116
+ const WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
117
+ function importDocxPageColor(document) {
118
+ const background = directChild(document.documentElement, 'background');
119
+ const color = attribute(background ?? document.documentElement, 'color');
120
+ if (!background || !color || 'auto' === color.toLowerCase()) return;
121
+ return normalizeDocumentPageColor(`#${color}`);
122
+ }
123
+ async function patchDocxPageColor(buffer, value) {
124
+ const pageColor = normalizeDocumentPageColor(value);
125
+ if (!pageColor || pageColor === DEFAULT_DOCUMENT_PAGE_COLOR) return buffer;
126
+ const archive = await jszip.loadAsync(buffer);
127
+ const documentEntry = archive.file('word/document.xml');
128
+ if (!documentEntry) return buffer;
129
+ const document = parseXml(await documentEntry.async('text'), 'word/document.xml');
130
+ upsertDocumentBackground(document, pageColor.slice(1).toUpperCase());
131
+ archive.file('word/document.xml', new XMLSerializer().serializeToString(document));
132
+ const settingsEntry = archive.file('word/settings.xml');
133
+ if (settingsEntry) {
134
+ const settings = parseXml(await settingsEntry.async('text'), 'word/settings.xml');
135
+ if (!directChild(settings.documentElement, 'displayBackgroundShape')) settings.documentElement.append(settings.createElementNS(WORD_NAMESPACE, wordQualifiedName(settings.documentElement, 'displayBackgroundShape')));
136
+ archive.file('word/settings.xml', new XMLSerializer().serializeToString(settings));
137
+ }
138
+ return archive.generateAsync({
139
+ type: 'arraybuffer'
140
+ });
141
+ }
142
+ function upsertDocumentBackground(document, color) {
143
+ const root = document.documentElement;
144
+ let background = directChild(root, 'background');
145
+ if (!background) {
146
+ background = document.createElementNS(WORD_NAMESPACE, wordQualifiedName(root, 'background'));
147
+ root.insertBefore(background, directChild(root, 'body') ?? root.firstChild);
148
+ }
149
+ background.setAttributeNS(WORD_NAMESPACE, wordQualifiedName(root, 'color'), color);
150
+ }
151
+ function wordQualifiedName(root, localName) {
152
+ return `${xmlNamespacePrefix(root, WORD_NAMESPACE) ?? root.prefix ?? 'w'}:${localName}`;
153
+ }
154
+ export { assignDocxCommentThreads, assignDocxNoteIds, importDocxPageColor, importedDocumentNoteId, normalizeDocxCommentId, patchDocxPageColor };