@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
@@ -12,9 +12,10 @@ import starter_kit from "@tiptap/starter-kit";
12
12
  import { Bold, Code2, Columns2, Image, Italic, Link2, List, ListChecks, ListOrdered, Minus, PencilLine, Quote, Redo2, Strikethrough, Table2, Undo2, Unlink } from "lucide-react";
13
13
  import { mergeOfficeTiptapExtensions, documentPlainTextAsHtml, customSelectionMenuItems } from "./0~5050.js";
14
14
  import { OfficeSelect, isWorkspaceContextMenuKeyboardEvent, WorkOfficeZoomControls, WorkOfficeStatusBar, Dialog, WorkOfficeRibbon, workspaceContextMenuPosition, WorkspaceContextMenu, WorkOfficeRibbonGroup, WorkOfficeRibbonButton, WorkOfficePreviewBar } from "./0~4595.js";
15
- import { button_Button, stepOfficeZoom, useOfficeEditorWheelZoom, office_text_field_OfficeTextField } from "./0~9512.js";
15
+ import { button_Button, OfficeTiptapPresenceLayer, useOfficePublishPresenceLocation, stepOfficeZoom, office_text_field_OfficeTextField, useOfficeEditorWheelZoom, MarkdownSourcePresenceLayer } from "./0~6090.js";
16
16
  import { normalizeDocumentHref, DOCUMENT_LINK_VALIDATION_MESSAGE } from "./0~work-document-links.js";
17
- import { WorkEditorLoadingState } from "./432.js";
17
+ import { readOfficeMarkdownCollaboration as readWorkOfficeMarkdownCollaboration, createOfficeMarkdownCollaborationBinding as createWorkOfficeMarkdownCollaborationBinding } from "./2591.js";
18
+ import { useOfficeEditorInitialFocus, useOfficeCollaborationLocationNavigator, WorkEditorLoadingState } from "./432.js";
18
19
  var markdown_editor_namespaceObject = {};
19
20
  __webpack_require__.r(markdown_editor_namespaceObject);
20
21
  __webpack_require__.d(markdown_editor_namespaceObject, {
@@ -112,7 +113,7 @@ const WorkMarkdown = Extension.create({
112
113
  };
113
114
  }
114
115
  });
115
- function createWorkMarkdownExtensions() {
116
+ function createWorkMarkdownExtensions(options = {}) {
116
117
  return [
117
118
  starter_kit.configure({
118
119
  link: {
@@ -120,7 +121,10 @@ function createWorkMarkdownExtensions() {
120
121
  defaultProtocol: 'https',
121
122
  openOnClick: false
122
123
  },
123
- underline: false
124
+ underline: false,
125
+ ...options.collaborative ? {
126
+ undoRedo: false
127
+ } : {}
124
128
  }),
125
129
  TaskList,
126
130
  TaskItem.configure({
@@ -723,8 +727,8 @@ async function copyMarkdownSelection(text) {
723
727
  }
724
728
  }
725
729
  const MARKDOWN_SURFACE_FOCUS_RETRY_FRAMES = 4;
726
- function restoreMarkdownEditingSurfaceFocus(getTarget) {
727
- const commandTrigger = document.activeElement;
730
+ function restoreMarkdownEditingSurfaceFocus(getTarget, focusOrigin = document.activeElement) {
731
+ const commandTrigger = focusOrigin;
728
732
  let remainingFrames = MARKDOWN_SURFACE_FOCUS_RETRY_FRAMES;
729
733
  const restore = ()=>{
730
734
  if (remainingFrames <= 0) return;
@@ -951,7 +955,7 @@ const markdownToolbarShortcuts = {
951
955
  label: 'Cmd/Ctrl+Z'
952
956
  }
953
957
  };
954
- function MarkdownToolbar({ editor, fileActions, sourceEditing, canSourceRedo, canSourceUndo, viewMode, getSourceFocusTarget, getSourceSelection, onSourceCommand, onSourceRedo, onSourceReplace, onSourceUndo, onViewModeChange }) {
958
+ function MarkdownToolbar({ editor, fileActions, collaborative, sourceEditing, canSourceRedo, canSourceUndo, viewMode, getSourceFocusTarget, getSourceSelection, onSourceCommand, onSourceRedo, onSourceReplace, onSourceUndo, onViewModeChange }) {
955
959
  const [activeTab, setActiveTab] = useState('home');
956
960
  const [insertDialog, setInsertDialog] = useState(null);
957
961
  const sourceSelection = sourceEditing ? getSourceSelection() : null;
@@ -965,8 +969,9 @@ function MarkdownToolbar({ editor, fileActions, sourceEditing, canSourceRedo, ca
965
969
  level: 3
966
970
  }) ? 'h3' : 'paragraph';
967
971
  const linkActive = sourceEditing ? Boolean(sourceLink) : editor.isActive('link');
968
- const canUndo = sourceEditing ? canSourceUndo : canRunVisualEditorCommand(editor, ()=>editor.can().chain().focus().undo().run());
969
- const canRedo = sourceEditing ? canSourceRedo : canRunVisualEditorCommand(editor, ()=>editor.can().chain().focus().redo().run());
972
+ const usesSharedHistory = sourceEditing || collaborative;
973
+ const canUndo = usesSharedHistory ? canSourceUndo : canRunVisualEditorCommand(editor, ()=>editor.can().chain().focus().undo().run());
974
+ const canRedo = usesSharedHistory ? canSourceRedo : canRunVisualEditorCommand(editor, ()=>editor.can().chain().focus().redo().run());
970
975
  const runCommand = (sourceCommand, visualCommand)=>{
971
976
  if (sourceEditing) return void onSourceCommand(sourceCommand);
972
977
  visualCommand();
@@ -1132,7 +1137,7 @@ function MarkdownToolbar({ editor, fileActions, sourceEditing, canSourceRedo, ca
1132
1137
  shortcut: markdownToolbarShortcuts.undo,
1133
1138
  disabled: !canUndo,
1134
1139
  onClick: ()=>{
1135
- if (sourceEditing) onSourceUndo();
1140
+ if (usesSharedHistory) onSourceUndo();
1136
1141
  else editor.chain().focus().undo().run();
1137
1142
  },
1138
1143
  children: /*#__PURE__*/ jsx(Undo2, {
@@ -1144,7 +1149,7 @@ function MarkdownToolbar({ editor, fileActions, sourceEditing, canSourceRedo, ca
1144
1149
  shortcut: markdownToolbarShortcuts.redo,
1145
1150
  disabled: !canRedo,
1146
1151
  onClick: ()=>{
1147
- if (sourceEditing) onSourceRedo();
1152
+ if (usesSharedHistory) onSourceRedo();
1148
1153
  else editor.chain().focus().redo().run();
1149
1154
  },
1150
1155
  children: /*#__PURE__*/ jsx(Redo2, {
@@ -1436,6 +1441,7 @@ function proportionalMarkdownScrollTop(sourceScrollTop, sourceScrollHeight, sour
1436
1441
  function MarkdownWorkspace({ editor, markdown, mode, readOnly = false, visualReadOnly = readOnly, sourceRef, sourceSelectionRequest, onSourceChange, onSourceCommand, onSourceContextMenu, onSourceIntent, onSourceRedo, onSourceSelectionChange, onSourceUndo, onVisualContextMenu, onVisualIntent }) {
1437
1442
  const workspaceRef = useRef(null);
1438
1443
  const visualRef = useRef(null);
1444
+ const visualCanvasRef = useRef(null);
1439
1445
  const synchronizedTargetRef = useRef(null);
1440
1446
  const releaseFrameRef = useRef(null);
1441
1447
  const sourceInputTypeRef = useRef(void 0);
@@ -1633,6 +1639,10 @@ function MarkdownWorkspace({ editor, markdown, mode, readOnly = false, visualRea
1633
1639
  onSourceSelectionChange?.(markdown_workspace_sourceSelection(event.currentTarget));
1634
1640
  },
1635
1641
  onScroll: handleSourceScroll
1642
+ }),
1643
+ /*#__PURE__*/ jsx(MarkdownSourcePresenceLayer, {
1644
+ markdown: markdown,
1645
+ sourceRef: sourceRef
1636
1646
  })
1637
1647
  ]
1638
1648
  }),
@@ -1671,11 +1681,20 @@ function MarkdownWorkspace({ editor, markdown, mode, readOnly = false, visualRea
1671
1681
  className: "work-markdown-pane-label",
1672
1682
  children: "预览"
1673
1683
  }),
1674
- /*#__PURE__*/ jsx("div", {
1684
+ /*#__PURE__*/ jsxs("div", {
1685
+ ref: visualCanvasRef,
1675
1686
  className: "work-markdown-canvas",
1676
- children: /*#__PURE__*/ jsx(EditorContent, {
1677
- editor: editor
1678
- })
1687
+ children: [
1688
+ /*#__PURE__*/ jsx(EditorContent, {
1689
+ editor: editor
1690
+ }),
1691
+ /*#__PURE__*/ jsx(OfficeTiptapPresenceLayer, {
1692
+ containerRef: visualCanvasRef,
1693
+ editor: editor,
1694
+ kind: "markdown",
1695
+ markdownSurface: "visual"
1696
+ })
1697
+ ]
1679
1698
  })
1680
1699
  ]
1681
1700
  })
@@ -1838,33 +1857,51 @@ function sameSelection(left, right) {
1838
1857
  }
1839
1858
  const MARKDOWN_PREVIEW_SYNC_DELAY = 160;
1840
1859
  const EMPTY_MARKDOWN_EXTENSIONS = [];
1841
- function MarkdownEditor({ content, extensions: additionalExtensions = EMPTY_MARKDOWN_EXTENSIONS, preview, saveStatus, fileActions, getSelectionMenuItems, onChange }) {
1842
- const contentRef = useRef(content);
1860
+ function MarkdownEditor({ autoFocus = true, collaboration, content, extensions: additionalExtensions = EMPTY_MARKDOWN_EXTENSIONS, preview, saveStatus, fileActions, getSelectionMenuItems, onChange }) {
1861
+ const collaborationRef = useRef(collaboration);
1862
+ if (collaborationRef.current !== collaboration) throw new Error('MarkdownEditor collaboration sessions cannot be replaced while mounted. Remount the editor for another shared document.');
1863
+ const collaborationBindingRef = useRef(void 0);
1864
+ const collaborative = void 0 !== collaboration;
1865
+ const collaborationEditable = !collaboration || 'edit' === collaboration.mode;
1866
+ const readOnly = preview || !collaborationEditable;
1867
+ const initialContent = collaboration ? readWorkOfficeMarkdownCollaboration(collaboration) : content;
1868
+ const contentRef = useRef(initialContent);
1843
1869
  const onChangeRef = useRef(onChange);
1844
1870
  const receivedContentRef = useRef(content);
1845
- const appliedMarkdownRef = useRef(content.markdown);
1871
+ const appliedMarkdownRef = useRef(initialContent.markdown);
1846
1872
  const emittedMarkdownRef = useRef(null);
1847
- const sourceMarkdownRef = useRef(content.markdown);
1848
- const initialMarkdownRef = useRef(content.markdown);
1873
+ const sourceMarkdownRef = useRef(initialContent.markdown);
1874
+ const initialMarkdownRef = useRef(initialContent.markdown);
1849
1875
  const previewTimerRef = useRef(null);
1850
1876
  const sourceTextareaRef = useRef(null);
1851
1877
  const markdownRootRef = useRef(null);
1852
- const [sourceMarkdown, setSourceMarkdown] = useState(content.markdown);
1878
+ const [sourceMarkdown, setSourceMarkdown] = useState(initialContent.markdown);
1853
1879
  const [selectionMenu, setSelectionMenu] = useState(null);
1854
1880
  const [sourceSelectionRequest, setSourceSelectionRequest] = useState();
1855
1881
  const [viewMode, setViewMode] = useState('split');
1856
1882
  const [zoom, setZoom] = useState(100);
1857
- const [, setSelectionVersion] = useState(0);
1858
- const { canRedo: canRedoSource, canUndo: canUndoSource, record: recordSourceHistory, redo: redoSourceHistory, reset: resetSourceHistory, undo: undoSourceHistory, updateSelection: updateSourceHistorySelection } = useMarkdownSourceHistory(content.markdown);
1859
- contentRef.current = content;
1883
+ const [selectionVersion, setSelectionVersion] = useState(0);
1884
+ const [presenceSurface, setPresenceSurface] = useState(preview ? 'visual' : 'source');
1885
+ const [sourcePresenceSelection, setSourcePresenceSelection] = useState({
1886
+ start: 0,
1887
+ end: 0,
1888
+ direction: 'none'
1889
+ });
1890
+ const { canRedo: canRedoSource, canUndo: canUndoSource, record: recordSourceHistory, redo: redoSourceHistory, reset: resetSourceHistory, undo: undoSourceHistory, updateSelection: updateSourceHistorySelection } = useMarkdownSourceHistory(initialContent.markdown);
1891
+ if (!collaborative) contentRef.current = content;
1860
1892
  onChangeRef.current = onChange;
1893
+ const [, refreshCollaborationHistory] = useState(0);
1894
+ const [collaborationReady, setCollaborationReady] = useState(!collaborative);
1861
1895
  const cancelPreviewSync = useCallback(()=>{
1862
1896
  if (null === previewTimerRef.current) return;
1863
1897
  clearTimeout(previewTimerRef.current);
1864
1898
  previewTimerRef.current = null;
1865
1899
  }, []);
1866
- const extensions = useMemo(()=>mergeOfficeTiptapExtensions('MarkdownEditor', createWorkMarkdownExtensions(), additionalExtensions), [
1867
- additionalExtensions
1900
+ const extensions = useMemo(()=>mergeOfficeTiptapExtensions('MarkdownEditor', createWorkMarkdownExtensions({
1901
+ collaborative
1902
+ }), additionalExtensions), [
1903
+ additionalExtensions,
1904
+ collaborative
1868
1905
  ]);
1869
1906
  const editorProps = useMemo(()=>({
1870
1907
  attributes: {
@@ -1872,18 +1909,40 @@ function MarkdownEditor({ content, extensions: additionalExtensions = EMPTY_MARK
1872
1909
  'aria-multiline': 'true',
1873
1910
  role: 'textbox',
1874
1911
  spellcheck: 'true'
1912
+ },
1913
+ handleKeyDown: (_view, event)=>{
1914
+ if (!collaborative || readOnly || event.altKey || !(event.metaKey || event.ctrlKey)) return false;
1915
+ const key = event.key.toLocaleLowerCase();
1916
+ if ('z' === key) {
1917
+ if (event.shiftKey) collaborationBindingRef.current?.redo();
1918
+ else collaborationBindingRef.current?.undo();
1919
+ return true;
1920
+ }
1921
+ if ('y' === key && !event.shiftKey) {
1922
+ collaborationBindingRef.current?.redo();
1923
+ return true;
1924
+ }
1925
+ return false;
1875
1926
  }
1876
- }), []);
1927
+ }), [
1928
+ collaborative,
1929
+ readOnly
1930
+ ]);
1877
1931
  const editor = useEditor({
1878
1932
  extensions,
1879
1933
  content: initialMarkdownRef.current,
1880
1934
  contentType: 'markdown',
1881
- editable: !preview && 'visual' === viewMode,
1935
+ editable: !readOnly && 'visual' === viewMode,
1882
1936
  editorProps,
1883
1937
  onUpdate: ({ editor: current })=>{
1884
1938
  const markdown = current.getMarkdown();
1885
1939
  if (markdown === appliedMarkdownRef.current) return;
1886
1940
  cancelPreviewSync();
1941
+ if (collaborative) {
1942
+ appliedMarkdownRef.current = markdown;
1943
+ collaborationBindingRef.current?.replace(markdown);
1944
+ return;
1945
+ }
1887
1946
  const next = {
1888
1947
  ...contentRef.current,
1889
1948
  markdown
@@ -1924,12 +1983,54 @@ function MarkdownEditor({ content, extensions: additionalExtensions = EMPTY_MARK
1924
1983
  cancelPreviewSync,
1925
1984
  editor
1926
1985
  ]);
1986
+ useEffect(()=>{
1987
+ if (!collaboration) return;
1988
+ const binding = createWorkOfficeMarkdownCollaborationBinding(collaboration);
1989
+ collaborationBindingRef.current = binding;
1990
+ setCollaborationReady(true);
1991
+ return ()=>{
1992
+ if (collaborationBindingRef.current === binding) collaborationBindingRef.current = void 0;
1993
+ binding.destroy();
1994
+ };
1995
+ }, [
1996
+ collaboration
1997
+ ]);
1998
+ useEffect(()=>{
1999
+ if (!collaboration) return;
2000
+ const binding = collaborationBindingRef.current;
2001
+ if (!binding) return;
2002
+ const unsubscribeContent = binding.subscribe(({ content: next })=>{
2003
+ contentRef.current = next;
2004
+ sourceMarkdownRef.current = next.markdown;
2005
+ setSourceMarkdown(next.markdown);
2006
+ if (preview || 'source' !== viewMode) queueMarkdownPreview(next.markdown, 'visual' === viewMode);
2007
+ onChangeRef.current(next);
2008
+ });
2009
+ const unsubscribeHistory = binding.subscribeHistory(()=>refreshCollaborationHistory((value)=>value + 1));
2010
+ const current = binding.content();
2011
+ if (current.markdown !== sourceMarkdownRef.current) {
2012
+ contentRef.current = current;
2013
+ sourceMarkdownRef.current = current.markdown;
2014
+ setSourceMarkdown(current.markdown);
2015
+ if (preview || 'source' !== viewMode) queueMarkdownPreview(current.markdown, 'visual' === viewMode);
2016
+ onChangeRef.current(current);
2017
+ }
2018
+ return ()=>{
2019
+ unsubscribeContent();
2020
+ unsubscribeHistory();
2021
+ };
2022
+ }, [
2023
+ collaboration,
2024
+ preview,
2025
+ queueMarkdownPreview,
2026
+ viewMode
2027
+ ]);
1927
2028
  useEffect(()=>cancelPreviewSync, [
1928
2029
  cancelPreviewSync
1929
2030
  ]);
1930
2031
  useEffect(()=>{
1931
2032
  if (!editor) return;
1932
- const visualEditorReadOnly = preview || 'visual' !== viewMode;
2033
+ const visualEditorReadOnly = readOnly || 'visual' !== viewMode;
1933
2034
  let checkboxFrame = null;
1934
2035
  const applyTaskCheckboxState = ()=>{
1935
2036
  for (const checkbox of editor.view.dom.querySelectorAll('li[data-type="taskItem"] > label input[type="checkbox"]')){
@@ -1978,10 +2079,11 @@ function MarkdownEditor({ content, extensions: additionalExtensions = EMPTY_MARK
1978
2079
  };
1979
2080
  }, [
1980
2081
  editor,
1981
- preview,
2082
+ readOnly,
1982
2083
  viewMode
1983
2084
  ]);
1984
2085
  useEffect(()=>{
2086
+ if (collaborative) return;
1985
2087
  if (!editor || receivedContentRef.current === content) return;
1986
2088
  receivedContentRef.current = content;
1987
2089
  const markdown = content.markdown;
@@ -1995,17 +2097,19 @@ function MarkdownEditor({ content, extensions: additionalExtensions = EMPTY_MARK
1995
2097
  }
1996
2098
  emittedMarkdownRef.current = null;
1997
2099
  resetSourceHistory(markdown, textareaSelection(sourceTextareaRef.current, markdown.length));
1998
- if (preview || 'source' !== viewMode) queueMarkdownPreview(markdown, true);
2100
+ if (readOnly || 'source' !== viewMode) queueMarkdownPreview(markdown, true);
1999
2101
  }, [
2000
2102
  content,
2103
+ collaborative,
2001
2104
  editor,
2002
- preview,
2105
+ readOnly,
2003
2106
  queueMarkdownPreview,
2004
2107
  resetSourceHistory,
2005
2108
  viewMode
2006
2109
  ]);
2007
2110
  const updateSource = useCallback((markdown)=>{
2008
2111
  if (markdown === sourceMarkdownRef.current) return;
2112
+ if (collaborative) return void collaborationBindingRef.current?.replace(markdown);
2009
2113
  sourceMarkdownRef.current = markdown;
2010
2114
  setSourceMarkdown(markdown);
2011
2115
  const next = {
@@ -2017,6 +2121,7 @@ function MarkdownEditor({ content, extensions: additionalExtensions = EMPTY_MARK
2017
2121
  onChangeRef.current(next);
2018
2122
  if ('source' !== viewMode) queueMarkdownPreview(markdown);
2019
2123
  }, [
2124
+ collaborative,
2020
2125
  queueMarkdownPreview,
2021
2126
  viewMode
2022
2127
  ]);
@@ -2037,11 +2142,12 @@ function MarkdownEditor({ content, extensions: additionalExtensions = EMPTY_MARK
2037
2142
  }));
2038
2143
  }, []);
2039
2144
  const applySourceEdit = useCallback((edit)=>{
2040
- recordSourceHistory(edit);
2145
+ if (!collaborative) recordSourceHistory(edit);
2041
2146
  updateSource(edit.markdown);
2042
2147
  requestSourceSelection(edit.selection);
2043
2148
  return true;
2044
2149
  }, [
2150
+ collaborative,
2045
2151
  recordSourceHistory,
2046
2152
  requestSourceSelection,
2047
2153
  updateSource
@@ -2051,12 +2157,15 @@ function MarkdownEditor({ content, extensions: additionalExtensions = EMPTY_MARK
2051
2157
  markdown,
2052
2158
  selection
2053
2159
  };
2054
- if (!recordSourceHistory(edit, {
2055
- typing: true,
2056
- inputType
2057
- })) return;
2160
+ if (!collaborative) {
2161
+ if (!recordSourceHistory(edit, {
2162
+ typing: true,
2163
+ inputType
2164
+ })) return;
2165
+ }
2058
2166
  updateSource(markdown);
2059
2167
  }, [
2168
+ collaborative,
2060
2169
  recordSourceHistory,
2061
2170
  updateSource
2062
2171
  ]);
@@ -2069,12 +2178,20 @@ function MarkdownEditor({ content, extensions: additionalExtensions = EMPTY_MARK
2069
2178
  requestSourceSelection,
2070
2179
  updateSource
2071
2180
  ]);
2072
- const undoSource = useCallback(()=>applySourceHistory(undoSourceHistory()), [
2181
+ const undoSource = useCallback(()=>{
2182
+ if (collaborative) return collaborationBindingRef.current?.undo() ?? false;
2183
+ return applySourceHistory(undoSourceHistory());
2184
+ }, [
2073
2185
  applySourceHistory,
2186
+ collaborative,
2074
2187
  undoSourceHistory
2075
2188
  ]);
2076
- const redoSource = useCallback(()=>applySourceHistory(redoSourceHistory()), [
2189
+ const redoSource = useCallback(()=>{
2190
+ if (collaborative) return collaborationBindingRef.current?.redo() ?? false;
2191
+ return applySourceHistory(redoSourceHistory());
2192
+ }, [
2077
2193
  applySourceHistory,
2194
+ collaborative,
2078
2195
  redoSourceHistory
2079
2196
  ]);
2080
2197
  const runSourceCommand = useCallback((command)=>{
@@ -2095,16 +2212,22 @@ function MarkdownEditor({ content, extensions: additionalExtensions = EMPTY_MARK
2095
2212
  getSourceSelection
2096
2213
  ]);
2097
2214
  const handleSourceSelectionChange = useCallback((selection)=>{
2098
- updateSourceHistorySelection(selection);
2215
+ if (!collaborative) updateSourceHistorySelection(selection);
2216
+ setSourcePresenceSelection(selection);
2099
2217
  setSelectionVersion((value)=>value + 1);
2100
2218
  }, [
2219
+ collaborative,
2101
2220
  updateSourceHistorySelection
2102
2221
  ]);
2103
2222
  const handleVisualIntent = useCallback(()=>{
2223
+ setPresenceSurface('visual');
2104
2224
  applyMarkdownToEditor(sourceMarkdownRef.current);
2105
2225
  }, [
2106
2226
  applyMarkdownToEditor
2107
2227
  ]);
2228
+ const handleSourceIntent = useCallback(()=>{
2229
+ setPresenceSurface('source');
2230
+ }, []);
2108
2231
  const openSourceSelectionMenu = useCallback((event)=>{
2109
2232
  if (!getSelectionMenuItems) return false;
2110
2233
  const current = getSourceSelection();
@@ -2150,6 +2273,7 @@ function MarkdownEditor({ content, extensions: additionalExtensions = EMPTY_MARK
2150
2273
  ]);
2151
2274
  const changeViewMode = useCallback((mode)=>{
2152
2275
  const focusSurface = 'visual' === mode ? 'visual' : 'source';
2276
+ setPresenceSurface(focusSurface);
2153
2277
  if ('source' !== mode) applyMarkdownToEditor(sourceMarkdownRef.current);
2154
2278
  setViewMode(mode);
2155
2279
  restoreMarkdownEditingSurfaceFocus(()=>{
@@ -2160,7 +2284,79 @@ function MarkdownEditor({ content, extensions: additionalExtensions = EMPTY_MARK
2160
2284
  applyMarkdownToEditor,
2161
2285
  editor
2162
2286
  ]);
2287
+ const markdownPresenceLocation = useMemo(()=>{
2288
+ const surface = readOnly ? 'visual' : presenceSurface;
2289
+ if ('source' === surface) {
2290
+ const maximum = sourceMarkdownRef.current.length;
2291
+ const start = Math.max(0, Math.min(maximum, sourcePresenceSelection.start));
2292
+ const end = Math.max(0, Math.min(maximum, sourcePresenceSelection.end));
2293
+ const backward = 'backward' === sourcePresenceSelection.direction;
2294
+ return {
2295
+ kind: 'markdown',
2296
+ surface,
2297
+ anchor: backward ? end : start,
2298
+ head: backward ? start : end
2299
+ };
2300
+ }
2301
+ if (!editor || editor.isDestroyed) return null;
2302
+ const { anchor, head } = editor.state.selection;
2303
+ return {
2304
+ kind: 'markdown',
2305
+ surface,
2306
+ anchor,
2307
+ head
2308
+ };
2309
+ }, [
2310
+ editor,
2311
+ presenceSurface,
2312
+ readOnly,
2313
+ selectionVersion,
2314
+ sourcePresenceSelection
2315
+ ]);
2316
+ useOfficePublishPresenceLocation(markdownPresenceLocation);
2317
+ const navigateToMarkdownParticipant = useCallback((participant)=>{
2318
+ const location = participant.location;
2319
+ if (!editor || editor.isDestroyed || location?.kind !== 'markdown') return false;
2320
+ const surface = location.surface ?? 'source';
2321
+ if ('source' === surface) {
2322
+ if (readOnly || location.anchor > sourceMarkdownRef.current.length || location.head > sourceMarkdownRef.current.length) return false;
2323
+ setPresenceSurface('source');
2324
+ if ('visual' === viewMode) setViewMode('source');
2325
+ requestSourceSelection({
2326
+ start: Math.min(location.anchor, location.head),
2327
+ end: Math.max(location.anchor, location.head),
2328
+ direction: location.anchor > location.head ? 'backward' : 'forward'
2329
+ });
2330
+ return true;
2331
+ }
2332
+ const maximum = editor.state.doc.content.size;
2333
+ if (location.anchor > maximum || location.head > maximum) return false;
2334
+ setPresenceSurface('visual');
2335
+ if ('visual' !== viewMode) {
2336
+ applyMarkdownToEditor(sourceMarkdownRef.current);
2337
+ setViewMode('visual');
2338
+ }
2339
+ const from = Math.min(location.anchor, location.head);
2340
+ const to = Math.max(location.anchor, location.head);
2341
+ requestAnimationFrame(()=>{
2342
+ if (editor.isDestroyed) return;
2343
+ editor.chain().focus().setTextSelection({
2344
+ from,
2345
+ to
2346
+ }).scrollIntoView().run();
2347
+ });
2348
+ return true;
2349
+ }, [
2350
+ applyMarkdownToEditor,
2351
+ editor,
2352
+ readOnly,
2353
+ requestSourceSelection,
2354
+ viewMode
2355
+ ]);
2356
+ useOfficeCollaborationLocationNavigator(navigateToMarkdownParticipant);
2163
2357
  const deferredMarkdown = useDeferredValue(sourceMarkdown);
2358
+ const canUndoMarkdown = collaborative ? collaborationBindingRef.current?.canUndo() ?? false : canUndoSource;
2359
+ const canRedoMarkdown = collaborative ? collaborationBindingRef.current?.canRedo() ?? false : canRedoSource;
2164
2360
  const metrics = useMemo(()=>markdownMetrics(deferredMarkdown), [
2165
2361
  deferredMarkdown
2166
2362
  ]);
@@ -2179,10 +2375,18 @@ function MarkdownEditor({ content, extensions: additionalExtensions = EMPTY_MARK
2179
2375
  maximum: 180
2180
2376
  }))
2181
2377
  });
2182
- if (!editor) return /*#__PURE__*/ jsx(WorkEditorLoadingState, {
2378
+ useOfficeEditorInitialFocus({
2379
+ enabled: autoFocus && !readOnly && collaborationReady && Boolean(editor && !editor.isDestroyed),
2380
+ getTarget: ()=>{
2381
+ if ('visual' !== viewMode) return sourceTextareaRef.current;
2382
+ return !editor || editor.isDestroyed ? null : editor.view.dom;
2383
+ },
2384
+ isTargetReady: (target)=>target instanceof HTMLTextAreaElement ? !target.disabled && !target.readOnly : 'true' === target.getAttribute('contenteditable')
2385
+ });
2386
+ if (!editor || !collaborationReady) return /*#__PURE__*/ jsx(WorkEditorLoadingState, {
2183
2387
  title: "正在准备 Markdown 编辑器"
2184
2388
  });
2185
- if (preview) return /*#__PURE__*/ jsxs("section", {
2389
+ if (readOnly) return /*#__PURE__*/ jsxs("section", {
2186
2390
  ref: markdownRootRef,
2187
2391
  className: "work-markdown-editor preview",
2188
2392
  style: editorStyle,
@@ -2220,9 +2424,10 @@ function MarkdownEditor({ content, extensions: additionalExtensions = EMPTY_MARK
2220
2424
  /*#__PURE__*/ jsx(MarkdownToolbar, {
2221
2425
  editor: editor,
2222
2426
  fileActions: fileActions,
2427
+ collaborative: collaborative,
2223
2428
  sourceEditing: 'visual' !== viewMode,
2224
- canSourceRedo: canRedoSource,
2225
- canSourceUndo: canUndoSource,
2429
+ canSourceRedo: canRedoMarkdown,
2430
+ canSourceUndo: canUndoMarkdown,
2226
2431
  viewMode: viewMode,
2227
2432
  getSourceFocusTarget: ()=>sourceTextareaRef.current,
2228
2433
  getSourceSelection: getSourceSelection,
@@ -2243,6 +2448,7 @@ function MarkdownEditor({ content, extensions: additionalExtensions = EMPTY_MARK
2243
2448
  onSourceCommand: runSourceCommand,
2244
2449
  onSourceContextMenu: getSelectionMenuItems ? openSourceSelectionMenu : void 0,
2245
2450
  onSourceRedo: redoSource,
2451
+ onSourceIntent: handleSourceIntent,
2246
2452
  onSourceSelectionChange: handleSourceSelectionChange,
2247
2453
  onSourceUndo: undoSource,
2248
2454
  onVisualContextMenu: getSelectionMenuItems ? openVisualSelectionMenu : void 0,