@seafile/sdoc-editor 0.3.6 → 0.3.7

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 (339) hide show
  1. package/dist/api/sdoc-server-api.js +165 -170
  2. package/dist/api/seafile-api.js +180 -246
  3. package/dist/basic-sdk/comment/comment-decorate.js +23 -30
  4. package/dist/basic-sdk/comment/components/comment-all-participants/index.js +18 -18
  5. package/dist/basic-sdk/comment/components/comment-all-participants/participant-avatar.js +13 -13
  6. package/dist/basic-sdk/comment/components/comment-delete-shadow.js +11 -9
  7. package/dist/basic-sdk/comment/components/comment-editor.js +37 -34
  8. package/dist/basic-sdk/comment/components/comment-input/comment-participant-item.js +16 -14
  9. package/dist/basic-sdk/comment/components/comment-input/index.js +110 -106
  10. package/dist/basic-sdk/comment/components/comment-item-content.js +29 -37
  11. package/dist/basic-sdk/comment/components/comment-item-reply.js +24 -33
  12. package/dist/basic-sdk/comment/components/comment-item-resolved-reply.js +5 -3
  13. package/dist/basic-sdk/comment/components/comment-item-wrapper.js +190 -285
  14. package/dist/basic-sdk/comment/components/comment-list.js +52 -72
  15. package/dist/basic-sdk/comment/components/comment-participants-editor/index.js +23 -30
  16. package/dist/basic-sdk/comment/components/comment-participants-editor/searched-collaborators.js +21 -19
  17. package/dist/basic-sdk/comment/components/comment-participants-editor/selected-participants.js +16 -14
  18. package/dist/basic-sdk/comment/components/editor-comment.js +23 -32
  19. package/dist/basic-sdk/comment/components/elements-comment-count/element-comment-count.js +18 -20
  20. package/dist/basic-sdk/comment/components/elements-comment-count/index.js +8 -8
  21. package/dist/basic-sdk/comment/components/global-comment/global-comment-body-header.js +23 -25
  22. package/dist/basic-sdk/comment/components/global-comment/global-comment-editor.js +9 -7
  23. package/dist/basic-sdk/comment/components/global-comment/global-comment-header.js +9 -6
  24. package/dist/basic-sdk/comment/components/global-comment/index.js +63 -86
  25. package/dist/basic-sdk/comment/constants/index.js +9 -9
  26. package/dist/basic-sdk/comment/helper.js +27 -26
  27. package/dist/basic-sdk/comment/hooks/comment-hooks/use-comment-context.js +8 -7
  28. package/dist/basic-sdk/comment/hooks/comment-hooks/use-comment-list.js +19 -30
  29. package/dist/basic-sdk/comment/hooks/comment-hooks/use-comment-mount.js +41 -71
  30. package/dist/basic-sdk/comment/hooks/notification-hooks/use-notification-context.js +8 -7
  31. package/dist/basic-sdk/comment/hooks/notification-hooks/use-notification-mount.js +45 -64
  32. package/dist/basic-sdk/comment/hooks/use-participants.js +46 -53
  33. package/dist/basic-sdk/comment/index.js +22 -19
  34. package/dist/basic-sdk/comment/provider/comment-context-provider.js +9 -11
  35. package/dist/basic-sdk/comment/provider/index.js +4 -2
  36. package/dist/basic-sdk/comment/provider/notification-context-provider.js +9 -11
  37. package/dist/basic-sdk/comment/reducer/comment-reducer.js +151 -137
  38. package/dist/basic-sdk/comment/reducer/notification-reducer.js +20 -15
  39. package/dist/basic-sdk/comment/utils/index.js +180 -173
  40. package/dist/basic-sdk/comment/utils/notification-utils.js +15 -14
  41. package/dist/basic-sdk/constants/index.js +9 -9
  42. package/dist/basic-sdk/cursor/helper.js +13 -9
  43. package/dist/basic-sdk/cursor/use-cursors.js +9 -13
  44. package/dist/basic-sdk/decorates/index.js +8 -9
  45. package/dist/basic-sdk/editor/editable-article.js +63 -57
  46. package/dist/basic-sdk/editor/sdoc-editor.js +42 -47
  47. package/dist/basic-sdk/extension/commons/color-menu/color-item.js +6 -4
  48. package/dist/basic-sdk/extension/commons/color-menu/index.js +40 -50
  49. package/dist/basic-sdk/extension/commons/dropdown-menu-item/index.js +17 -16
  50. package/dist/basic-sdk/extension/commons/element-popover/index.js +27 -45
  51. package/dist/basic-sdk/extension/commons/insert-element-dialog/index.js +46 -59
  52. package/dist/basic-sdk/extension/commons/menu/menu-group.js +7 -21
  53. package/dist/basic-sdk/extension/commons/menu/menu-item.js +17 -14
  54. package/dist/basic-sdk/extension/commons/more-dropdown/index.js +9 -7
  55. package/dist/basic-sdk/extension/commons/select-file-dialog/helpers.js +3 -3
  56. package/dist/basic-sdk/extension/commons/select-file-dialog/index.js +26 -23
  57. package/dist/basic-sdk/extension/commons/select-file-dialog/local-files/index.js +49 -80
  58. package/dist/basic-sdk/extension/constants/color.js +10 -10
  59. package/dist/basic-sdk/extension/constants/diff-view.js +3 -3
  60. package/dist/basic-sdk/extension/constants/element-type.js +29 -29
  61. package/dist/basic-sdk/extension/constants/font.js +44 -37
  62. package/dist/basic-sdk/extension/constants/index.js +27 -16
  63. package/dist/basic-sdk/extension/constants/keyboard.js +4 -4
  64. package/dist/basic-sdk/extension/constants/menus-config.js +234 -203
  65. package/dist/basic-sdk/extension/core/queries/index.js +185 -285
  66. package/dist/basic-sdk/extension/core/transforms/focus-editor.js +2 -2
  67. package/dist/basic-sdk/extension/core/transforms/move-children.js +14 -14
  68. package/dist/basic-sdk/extension/core/transforms/remove-node-children.js +6 -18
  69. package/dist/basic-sdk/extension/core/transforms/replace-node.js +22 -19
  70. package/dist/basic-sdk/extension/core/transforms/update-parent-node.js +6 -8
  71. package/dist/basic-sdk/extension/core/utils/index.js +12 -12
  72. package/dist/basic-sdk/extension/index.js +6 -6
  73. package/dist/basic-sdk/extension/plugins/blockquote/helpers.js +39 -54
  74. package/dist/basic-sdk/extension/plugins/blockquote/index.js +1 -1
  75. package/dist/basic-sdk/extension/plugins/blockquote/menu/index.js +34 -44
  76. package/dist/basic-sdk/extension/plugins/blockquote/model.js +8 -9
  77. package/dist/basic-sdk/extension/plugins/blockquote/plugin.js +36 -37
  78. package/dist/basic-sdk/extension/plugins/blockquote/render-elem.js +7 -5
  79. package/dist/basic-sdk/extension/plugins/check-list/helpers.js +15 -25
  80. package/dist/basic-sdk/extension/plugins/check-list/index.js +1 -1
  81. package/dist/basic-sdk/extension/plugins/check-list/menu/index.js +35 -45
  82. package/dist/basic-sdk/extension/plugins/check-list/model.js +9 -10
  83. package/dist/basic-sdk/extension/plugins/check-list/plugin.js +16 -10
  84. package/dist/basic-sdk/extension/plugins/check-list/render-elem.js +42 -56
  85. package/dist/basic-sdk/extension/plugins/clear-format/helpers.js +21 -36
  86. package/dist/basic-sdk/extension/plugins/clear-format/menu/index.js +12 -10
  87. package/dist/basic-sdk/extension/plugins/code-block/helpers.js +40 -58
  88. package/dist/basic-sdk/extension/plugins/code-block/hover-menu/index.js +38 -46
  89. package/dist/basic-sdk/extension/plugins/code-block/index.js +1 -1
  90. package/dist/basic-sdk/extension/plugins/code-block/menu/index.js +9 -7
  91. package/dist/basic-sdk/extension/plugins/code-block/model.js +8 -9
  92. package/dist/basic-sdk/extension/plugins/code-block/plugin.js +44 -51
  93. package/dist/basic-sdk/extension/plugins/code-block/prismjs.js +27 -27
  94. package/dist/basic-sdk/extension/plugins/code-block/render-elem.js +62 -58
  95. package/dist/basic-sdk/extension/plugins/file-link/constants/index.js +16 -14
  96. package/dist/basic-sdk/extension/plugins/file-link/helpers.js +34 -36
  97. package/dist/basic-sdk/extension/plugins/file-link/hover-menu/index.js +19 -23
  98. package/dist/basic-sdk/extension/plugins/file-link/index.js +1 -1
  99. package/dist/basic-sdk/extension/plugins/file-link/menu/index.js +10 -8
  100. package/dist/basic-sdk/extension/plugins/file-link/plugin.js +17 -11
  101. package/dist/basic-sdk/extension/plugins/file-link/render-elem.js +34 -38
  102. package/dist/basic-sdk/extension/plugins/font/helpers.js +75 -78
  103. package/dist/basic-sdk/extension/plugins/font/index.js +1 -1
  104. package/dist/basic-sdk/extension/plugins/font/menu/font-family/font-item.js +14 -13
  105. package/dist/basic-sdk/extension/plugins/font/menu/font-family/index.js +38 -55
  106. package/dist/basic-sdk/extension/plugins/font/menu/font-size/font-size-scale.js +12 -10
  107. package/dist/basic-sdk/extension/plugins/font/menu/font-size/index.js +29 -31
  108. package/dist/basic-sdk/extension/plugins/font/menu/index.js +5 -3
  109. package/dist/basic-sdk/extension/plugins/font/plugin.js +4 -4
  110. package/dist/basic-sdk/extension/plugins/header/helpers.js +32 -38
  111. package/dist/basic-sdk/extension/plugins/header/index.js +1 -1
  112. package/dist/basic-sdk/extension/plugins/header/menu/index.js +101 -107
  113. package/dist/basic-sdk/extension/plugins/header/plugin.js +41 -44
  114. package/dist/basic-sdk/extension/plugins/header/render-elem.js +28 -20
  115. package/dist/basic-sdk/extension/plugins/html/helper.js +30 -28
  116. package/dist/basic-sdk/extension/plugins/html/index.js +1 -1
  117. package/dist/basic-sdk/extension/plugins/html/plugin.js +12 -10
  118. package/dist/basic-sdk/extension/plugins/html/rules/blockquote.js +5 -3
  119. package/dist/basic-sdk/extension/plugins/html/rules/check-list.js +4 -2
  120. package/dist/basic-sdk/extension/plugins/html/rules/code-block.js +20 -24
  121. package/dist/basic-sdk/extension/plugins/html/rules/header.js +7 -5
  122. package/dist/basic-sdk/extension/plugins/html/rules/image.js +4 -2
  123. package/dist/basic-sdk/extension/plugins/html/rules/index.js +1 -1
  124. package/dist/basic-sdk/extension/plugins/html/rules/link.js +5 -3
  125. package/dist/basic-sdk/extension/plugins/html/rules/list.js +6 -4
  126. package/dist/basic-sdk/extension/plugins/html/rules/paragraph.js +5 -3
  127. package/dist/basic-sdk/extension/plugins/html/rules/table.js +5 -3
  128. package/dist/basic-sdk/extension/plugins/html/rules/text.js +5 -3
  129. package/dist/basic-sdk/extension/plugins/image/constants/index.js +2 -2
  130. package/dist/basic-sdk/extension/plugins/image/dialogs/image-previewer.js +59 -75
  131. package/dist/basic-sdk/extension/plugins/image/helpers.js +74 -98
  132. package/dist/basic-sdk/extension/plugins/image/hover-menu/index.js +49 -62
  133. package/dist/basic-sdk/extension/plugins/image/index.js +1 -1
  134. package/dist/basic-sdk/extension/plugins/image/menu/index.js +12 -9
  135. package/dist/basic-sdk/extension/plugins/image/model.js +11 -12
  136. package/dist/basic-sdk/extension/plugins/image/plugin.js +43 -35
  137. package/dist/basic-sdk/extension/plugins/image/render-elem.js +73 -91
  138. package/dist/basic-sdk/extension/plugins/index.js +1 -1
  139. package/dist/basic-sdk/extension/plugins/link/dialog/add-link-dialog/index.js +30 -39
  140. package/dist/basic-sdk/extension/plugins/link/helpers.js +76 -100
  141. package/dist/basic-sdk/extension/plugins/link/hover/index.js +12 -9
  142. package/dist/basic-sdk/extension/plugins/link/index.js +1 -1
  143. package/dist/basic-sdk/extension/plugins/link/menu/index.js +10 -8
  144. package/dist/basic-sdk/extension/plugins/link/model.js +10 -11
  145. package/dist/basic-sdk/extension/plugins/link/plugin.js +28 -31
  146. package/dist/basic-sdk/extension/plugins/link/render-elem.js +66 -74
  147. package/dist/basic-sdk/extension/plugins/list/helpers.js +45 -57
  148. package/dist/basic-sdk/extension/plugins/list/index.js +1 -1
  149. package/dist/basic-sdk/extension/plugins/list/menu/index.js +37 -49
  150. package/dist/basic-sdk/extension/plugins/list/model.js +11 -12
  151. package/dist/basic-sdk/extension/plugins/list/plugin/index.js +16 -12
  152. package/dist/basic-sdk/extension/plugins/list/plugin/insert-break-list.js +4 -4
  153. package/dist/basic-sdk/extension/plugins/list/plugin/insert-fragment-list.js +54 -70
  154. package/dist/basic-sdk/extension/plugins/list/plugin/normalize-list.js +16 -20
  155. package/dist/basic-sdk/extension/plugins/list/plugin/on-tab-handle.js +19 -14
  156. package/dist/basic-sdk/extension/plugins/list/plugin/shortcut.js +20 -28
  157. package/dist/basic-sdk/extension/plugins/list/queries/index.js +16 -18
  158. package/dist/basic-sdk/extension/plugins/list/render-elem.js +23 -15
  159. package/dist/basic-sdk/extension/plugins/list/transforms/insert-list-item.js +20 -24
  160. package/dist/basic-sdk/extension/plugins/list/transforms/move-list-item-down.js +16 -19
  161. package/dist/basic-sdk/extension/plugins/list/transforms/move-list-item-up.js +31 -35
  162. package/dist/basic-sdk/extension/plugins/list/transforms/move-list-items-to-list.js +18 -18
  163. package/dist/basic-sdk/extension/plugins/list/transforms/move-list-items.js +23 -24
  164. package/dist/basic-sdk/extension/plugins/list/transforms/normalize-list-item.js +38 -55
  165. package/dist/basic-sdk/extension/plugins/list/transforms/normalize-nested-list.js +11 -13
  166. package/dist/basic-sdk/extension/plugins/list/transforms/remove-first-list-item.js +8 -8
  167. package/dist/basic-sdk/extension/plugins/list/transforms/toggle-list.js +42 -50
  168. package/dist/basic-sdk/extension/plugins/list/transforms/unwrap-list.js +11 -14
  169. package/dist/basic-sdk/extension/plugins/markdown/index.js +1 -1
  170. package/dist/basic-sdk/extension/plugins/markdown/plugin.js +59 -52
  171. package/dist/basic-sdk/extension/plugins/paragraph/index.js +1 -1
  172. package/dist/basic-sdk/extension/plugins/paragraph/render-elem.js +12 -10
  173. package/dist/basic-sdk/extension/plugins/sdoc-link/constants/index.js +16 -14
  174. package/dist/basic-sdk/extension/plugins/sdoc-link/helpers.js +66 -65
  175. package/dist/basic-sdk/extension/plugins/sdoc-link/hover-menu/index.js +19 -23
  176. package/dist/basic-sdk/extension/plugins/sdoc-link/index.js +1 -1
  177. package/dist/basic-sdk/extension/plugins/sdoc-link/menu/index.js +10 -8
  178. package/dist/basic-sdk/extension/plugins/sdoc-link/plugin.js +23 -15
  179. package/dist/basic-sdk/extension/plugins/sdoc-link/render-elem.js +35 -39
  180. package/dist/basic-sdk/extension/plugins/table/constants/index.js +16 -14
  181. package/dist/basic-sdk/extension/plugins/table/dialog/custom-table-size-dialog/index.js +17 -24
  182. package/dist/basic-sdk/extension/plugins/table/dialog/custom-table-size-dialog/number-input.js +9 -7
  183. package/dist/basic-sdk/extension/plugins/table/helpers.js +466 -440
  184. package/dist/basic-sdk/extension/plugins/table/index.js +1 -1
  185. package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/cell-bg-color-menu.js +16 -13
  186. package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/cell-text-align-menu.js +16 -18
  187. package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/common-menu.js +58 -65
  188. package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.js +7 -5
  189. package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/remove-table-menu.js +11 -9
  190. package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/table-column-menu.js +13 -14
  191. package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/table-row-menu.js +13 -14
  192. package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/index.js +92 -105
  193. package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/insert-table-element.js +62 -66
  194. package/dist/basic-sdk/extension/plugins/table/menu/table-menu/index.js +9 -7
  195. package/dist/basic-sdk/extension/plugins/table/model.js +14 -15
  196. package/dist/basic-sdk/extension/plugins/table/plugin.js +130 -112
  197. package/dist/basic-sdk/extension/plugins/table/popover/table-size-popover/index.js +31 -45
  198. package/dist/basic-sdk/extension/plugins/table/popover/table-template/index.js +12 -14
  199. package/dist/basic-sdk/extension/plugins/table/popover/table-template/sample-table.js +15 -19
  200. package/dist/basic-sdk/extension/plugins/table/render/hooks.js +25 -32
  201. package/dist/basic-sdk/extension/plugins/table/render/index.js +57 -67
  202. package/dist/basic-sdk/extension/plugins/table/render/render-cell.js +42 -36
  203. package/dist/basic-sdk/extension/plugins/table/render/render-row.js +44 -49
  204. package/dist/basic-sdk/extension/plugins/table/render/resize-handlers/first-column-left-resize-handler.js +36 -45
  205. package/dist/basic-sdk/extension/plugins/table/render/resize-handlers/index.js +10 -8
  206. package/dist/basic-sdk/extension/plugins/table/render/resize-handlers/resize-handler.js +41 -50
  207. package/dist/basic-sdk/extension/plugins/table/render/table-header/columns-header/column-header.js +30 -29
  208. package/dist/basic-sdk/extension/plugins/table/render/table-header/columns-header/index.js +21 -33
  209. package/dist/basic-sdk/extension/plugins/table/render/table-header/index.js +17 -15
  210. package/dist/basic-sdk/extension/plugins/table/render/table-header/rows-columns-header.js +7 -5
  211. package/dist/basic-sdk/extension/plugins/table/render/table-header/rows-header/index.js +22 -32
  212. package/dist/basic-sdk/extension/plugins/table/render/table-header/rows-header/row-header.js +41 -43
  213. package/dist/basic-sdk/extension/plugins/table/render/table-root.js +16 -20
  214. package/dist/basic-sdk/extension/plugins/text-align/helpers.js +19 -24
  215. package/dist/basic-sdk/extension/plugins/text-align/index.js +1 -1
  216. package/dist/basic-sdk/extension/plugins/text-align/menu/index.js +20 -26
  217. package/dist/basic-sdk/extension/plugins/text-style/caret.js +9 -7
  218. package/dist/basic-sdk/extension/plugins/text-style/helpers.js +17 -24
  219. package/dist/basic-sdk/extension/plugins/text-style/index.js +1 -1
  220. package/dist/basic-sdk/extension/plugins/text-style/menu/index.js +38 -37
  221. package/dist/basic-sdk/extension/plugins/text-style/plugin.js +6 -6
  222. package/dist/basic-sdk/extension/plugins/text-style/render-elem.js +14 -10
  223. package/dist/basic-sdk/extension/render/custom-element.js +30 -49
  224. package/dist/basic-sdk/extension/render/element-decorate/rebase-decorate/index.js +6 -4
  225. package/dist/basic-sdk/extension/render/element-decorate/rebase-decorate/rebase-delete-modify-decorate.js +13 -10
  226. package/dist/basic-sdk/extension/render/element-decorate/rebase-decorate/rebase-modify-delete-decorate.js +13 -10
  227. package/dist/basic-sdk/extension/render/element-decorate/rebase-decorate/rebase-modify-modify-decorate.js +21 -19
  228. package/dist/basic-sdk/extension/render/render-element.js +5 -3
  229. package/dist/basic-sdk/extension/render/render-leaf.js +4 -6
  230. package/dist/basic-sdk/extension/toolbar/context-toolbar/index.js +18 -16
  231. package/dist/basic-sdk/extension/toolbar/header-toolbar/index.js +5 -3
  232. package/dist/basic-sdk/extension/toolbar/header-toolbar/insert-toolbar/index.js +29 -29
  233. package/dist/basic-sdk/extension/toolbar/header-toolbar/redo-undo.js +45 -53
  234. package/dist/basic-sdk/extension/toolbar/side-toolbar/event.js +8 -8
  235. package/dist/basic-sdk/extension/toolbar/side-toolbar/helpers.js +45 -49
  236. package/dist/basic-sdk/extension/toolbar/side-toolbar/index.js +50 -72
  237. package/dist/basic-sdk/extension/toolbar/side-toolbar/insert-below-menu.js +5 -3
  238. package/dist/basic-sdk/extension/toolbar/side-toolbar/insert-block-menu.js +25 -26
  239. package/dist/basic-sdk/extension/toolbar/side-toolbar/side-menu.js +24 -26
  240. package/dist/basic-sdk/extension/toolbar/side-toolbar/transform-menus.js +14 -16
  241. package/dist/basic-sdk/extension/utils/index.js +4 -4
  242. package/dist/basic-sdk/highlight/index.js +8 -13
  243. package/dist/basic-sdk/highlight/setNodeToDecorations.js +43 -73
  244. package/dist/basic-sdk/hooks/use-color-context.js +27 -35
  245. package/dist/basic-sdk/hooks/use-scroll-context.js +6 -4
  246. package/dist/basic-sdk/hooks/use-selection-element.js +5 -7
  247. package/dist/basic-sdk/hooks/use-selection-position.js +13 -15
  248. package/dist/basic-sdk/hooks/use-selection-update.js +6 -11
  249. package/dist/basic-sdk/layout/article-container.js +20 -23
  250. package/dist/basic-sdk/layout/editor-container.js +6 -4
  251. package/dist/basic-sdk/layout/editor-content.js +15 -15
  252. package/dist/basic-sdk/node-id/constants.js +9 -9
  253. package/dist/basic-sdk/node-id/helpers.js +44 -29
  254. package/dist/basic-sdk/node-id/index.js +13 -11
  255. package/dist/basic-sdk/outline/index.js +24 -27
  256. package/dist/basic-sdk/outline/outline-item.js +39 -44
  257. package/dist/basic-sdk/socket/helpers.js +99 -90
  258. package/dist/basic-sdk/socket/socket-client.js +175 -171
  259. package/dist/basic-sdk/socket/socket-manager.js +316 -297
  260. package/dist/basic-sdk/socket/with-socket-io.js +38 -30
  261. package/dist/basic-sdk/utils/debug.js +4 -4
  262. package/dist/basic-sdk/utils/diff-text.js +191 -193
  263. package/dist/basic-sdk/utils/diff.js +115 -106
  264. package/dist/basic-sdk/utils/document-utils.js +10 -13
  265. package/dist/basic-sdk/utils/dom-utils.js +18 -16
  266. package/dist/basic-sdk/utils/event-bus.js +26 -39
  267. package/dist/basic-sdk/utils/event-handler.js +81 -79
  268. package/dist/basic-sdk/utils/mouse-event.js +29 -27
  269. package/dist/basic-sdk/utils/object-utils.js +35 -53
  270. package/dist/basic-sdk/utils/rebase.js +101 -76
  271. package/dist/basic-sdk/views/published-revision-diff-viewer.js +19 -22
  272. package/dist/basic-sdk/views/readonly-article.js +7 -5
  273. package/dist/basic-sdk/views/revision-diff-viewer.js +15 -18
  274. package/dist/basic-sdk/views/sdoc-diff-viewer.js +8 -6
  275. package/dist/basic-sdk/views/sdoc-viewer.js +9 -7
  276. package/dist/components/common-loading/index.js +1 -1
  277. package/dist/components/doc-info/index.js +25 -23
  278. package/dist/components/doc-operations/collaborators-operation/collaborators-popover.js +36 -49
  279. package/dist/components/doc-operations/collaborators-operation/index.js +58 -76
  280. package/dist/components/doc-operations/comments-operation/index.js +7 -13
  281. package/dist/components/doc-operations/history-operation.js +5 -5
  282. package/dist/components/doc-operations/index.js +10 -9
  283. package/dist/components/doc-operations/more-operations.js +15 -21
  284. package/dist/components/doc-operations/revision-operations/changes-count/index.js +15 -16
  285. package/dist/components/doc-operations/revision-operations/index.js +65 -71
  286. package/dist/components/doc-operations/revision-operations/more-revision-operations/index.js +13 -17
  287. package/dist/components/doc-operations/revision-operations/publish-revision/index.js +8 -5
  288. package/dist/components/doc-operations/revision-operations/revisions/index.js +13 -19
  289. package/dist/components/doc-operations/revision-operations/revisions/revisions-dialog/index.js +56 -87
  290. package/dist/components/doc-operations/revision-operations/revisions/revisions-dialog/revision-operation/index.js +14 -16
  291. package/dist/components/doc-operations/revision-operations/view-changes/index.js +25 -32
  292. package/dist/components/doc-operations/share-operation/index.js +2 -2
  293. package/dist/components/doc-operations/tag-operation/constans.js +1 -1
  294. package/dist/components/doc-operations/tag-operation/file-tag-quick-view/index.js +26 -42
  295. package/dist/components/doc-operations/tag-operation/index.js +1 -1
  296. package/dist/components/doc-operations/tag-operation/tag-popover/index.js +95 -175
  297. package/dist/components/doc-operations/tag-operation/utils.js +2 -6
  298. package/dist/components/draft-dropdown/index.js +44 -53
  299. package/dist/components/loading/index.js +8 -22
  300. package/dist/components/modal-portal/index.js +15 -32
  301. package/dist/components/switch/index.js +8 -6
  302. package/dist/components/tip-dialog/index.js +21 -23
  303. package/dist/components/tip-message/index.js +93 -92
  304. package/dist/components/toast/alert.js +73 -88
  305. package/dist/components/toast/index.js +1 -1
  306. package/dist/components/toast/toast.js +76 -103
  307. package/dist/components/toast/toastManager.js +55 -89
  308. package/dist/components/toast/toaster.js +54 -56
  309. package/dist/components/tooltip/index.js +15 -16
  310. package/dist/constants/index.js +26 -6
  311. package/dist/constants/transfer-types.js +3 -3
  312. package/dist/context.js +242 -339
  313. package/dist/hooks/use-collaborators.js +18 -20
  314. package/dist/hooks/use-document.js +33 -45
  315. package/dist/layout/content.js +13 -26
  316. package/dist/layout/header.js +13 -26
  317. package/dist/layout/layout.js +11 -9
  318. package/dist/model/notification.js +10 -11
  319. package/dist/model/revision.js +27 -28
  320. package/dist/model/user.js +10 -11
  321. package/dist/pages/error-boundary.js +18 -36
  322. package/dist/pages/error-page.js +14 -26
  323. package/dist/pages/published-revision-viewer.js +23 -35
  324. package/dist/pages/simple-editor.js +39 -46
  325. package/dist/pages/simple-viewer.js +70 -104
  326. package/dist/utils/date-utils.js +67 -81
  327. package/dist/utils/get-event-transfer.js +13 -15
  328. package/dist/utils/hotkey.js +24 -24
  329. package/dist/utils/index.js +20 -20
  330. package/dist/utils/local-storage-utils.js +41 -58
  331. package/package.json +10 -10
  332. package/public/locales/cs/sdoc-editor.json +3 -1
  333. package/public/locales/de/sdoc-editor.json +3 -1
  334. package/public/locales/en/sdoc-editor.json +1 -0
  335. package/public/locales/es/sdoc-editor.json +3 -1
  336. package/public/locales/fr/sdoc-editor.json +3 -1
  337. package/public/locales/it/sdoc-editor.json +3 -1
  338. package/public/locales/ru/sdoc-editor.json +3 -1
  339. package/public/locales/zh_CN/sdoc-editor.json +1 -0
@@ -1,6 +1,3 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
1
  var _class;
5
2
  import EventBus from '../utils/event-bus';
6
3
  import { syncRemoteOperations, reExecRevertOperationList, revertOperationList, syncRemoteCursorLocation } from './helpers';
@@ -13,326 +10,348 @@ import { EXTERNAL_EVENT } from '../../constants';
13
10
  // --> conflict --> idle
14
11
  // --> disconnect --> conflict --> idle
15
12
  // --> idle
16
- var STATE = {
13
+ const STATE = {
17
14
  IDLE: 'idle',
18
15
  SENDING: 'sending',
19
16
  CONFLICT: 'conflict',
20
17
  DISCONNECT: 'disconnect',
21
18
  NEED_RELOAD: 'need_reload'
22
19
  };
23
- var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, _document, config) {
24
- var _this = this;
25
- _classCallCheck(this, SocketManager);
26
- this.getDocumentVersion = function () {
27
- var version = _this.document.version;
28
- return version;
29
- };
30
- this.updateDocumentVersion = function (document) {
31
- _this.document['version'] = document.version;
32
- };
33
- this.receivePublishDocument = function () {
34
- _this.eventBus.dispatch(EXTERNAL_EVENT.PUBLISH_DOCUMENT);
35
- };
36
- this.receivePublishDocumentError = function () {
37
- _this.eventBus.dispatch(EXTERNAL_EVENT.PUBLISH_DOCUMENT_ERROR);
38
- };
39
- this.receiveRemoveDocument = function () {
40
- _this.eventBus.dispatch(EXTERNAL_EVENT.REMOVE_DOCUMENT);
41
- };
42
- this.receiveRemoveDocumentError = function () {
43
- _this.eventBus.dispatch(EXTERNAL_EVENT.REMOVE_DOCUMENT_ERROR);
44
- };
45
- this.receiveDocumentReplaced = function () {
46
- _this.eventBus.dispatch(EXTERNAL_EVENT.DOCUMENT_REPLACED);
47
- };
48
- this.receiveDocumentReplacedError = function () {
49
- _this.eventBus.dispatch(EXTERNAL_EVENT.DOCUMENT_REPLACED_ERROR);
50
- };
51
- this.receiveNewNotification = function (notification) {
52
- _this.eventBus.dispatch(EXTERNAL_EVENT.NEW_NOTIFICATION, notification);
53
- };
54
- this.onReceiveLocalOperations = function (operations) {
55
- _this.pendingOperationList.push(operations);
56
- var lastOpBeginTime = new Date().getTime();
57
- _this.pendingOperationBeginTimeList.push(lastOpBeginTime);
58
- var firstOpBeginTime = _this.pendingOperationBeginTimeList[0];
59
- var isExceedExecuteTime = (lastOpBeginTime - firstOpBeginTime) / 1000 > 30 ? true : false;
60
- if (isExceedExecuteTime || _this.pendingOperationList.length > 50) {
61
- _this.dispatchConnectState('pending_operations_exceed_limit');
62
- }
63
- _this.sendOperations();
64
- };
65
- this.sendOperations = function () {
66
- if (_this.state !== STATE.IDLE) return;
67
- stateDebug("State changed: ".concat(_this.state, " -> ").concat(STATE.SENDING));
68
- _this.state = STATE.SENDING;
69
- _this.sendNextOperations();
70
- };
71
- this.sendNextOperations = function () {
72
- if (_this.state !== STATE.SENDING) return;
73
- if (_this.pendingOperationList.length === 0) {
74
- stateDebug("State Changed: ".concat(_this.state, " -> ").concat(STATE.IDLE));
75
- _this.state = STATE.IDLE;
76
- return;
77
- }
78
- _this.dispatchConnectState('is-saving');
79
- var version = _this.document.version;
80
- var operations = _this.pendingOperationList.shift();
81
- var selection = _this.editor.selection;
82
- _this._sendingOperations = operations;
83
- _this.socketClient.sendOperations(operations, version, selection, _this.sendOperationsCallback);
84
- };
85
- this.sendOperationsCallback = function (result) {
86
- if (result && result.success) {
87
- var serverVersion = result.version;
88
- _this.document['version'] = serverVersion;
89
- var lastSavedAt = new Date().getTime();
90
- _this.dispatchConnectState('saved', lastSavedAt);
20
+ class SocketManager {
21
+ constructor(editor, _document, config) {
22
+ this.getDocumentVersion = () => {
23
+ const {
24
+ version
25
+ } = this.document;
26
+ return version;
27
+ };
28
+ this.updateDocumentVersion = document => {
29
+ this.document['version'] = document.version;
30
+ };
31
+ this.receivePublishDocument = () => {
32
+ this.eventBus.dispatch(EXTERNAL_EVENT.PUBLISH_DOCUMENT);
33
+ };
34
+ this.receivePublishDocumentError = () => {
35
+ this.eventBus.dispatch(EXTERNAL_EVENT.PUBLISH_DOCUMENT_ERROR);
36
+ };
37
+ this.receiveRemoveDocument = () => {
38
+ this.eventBus.dispatch(EXTERNAL_EVENT.REMOVE_DOCUMENT);
39
+ };
40
+ this.receiveRemoveDocumentError = () => {
41
+ this.eventBus.dispatch(EXTERNAL_EVENT.REMOVE_DOCUMENT_ERROR);
42
+ };
43
+ this.receiveDocumentReplaced = () => {
44
+ this.eventBus.dispatch(EXTERNAL_EVENT.DOCUMENT_REPLACED);
45
+ };
46
+ this.receiveDocumentReplacedError = () => {
47
+ this.eventBus.dispatch(EXTERNAL_EVENT.DOCUMENT_REPLACED_ERROR);
48
+ };
49
+ this.receiveNewNotification = notification => {
50
+ this.eventBus.dispatch(EXTERNAL_EVENT.NEW_NOTIFICATION, notification);
51
+ };
52
+ this.onReceiveLocalOperations = operations => {
53
+ this.pendingOperationList.push(operations);
54
+ const lastOpBeginTime = new Date().getTime();
55
+ this.pendingOperationBeginTimeList.push(lastOpBeginTime);
56
+ const firstOpBeginTime = this.pendingOperationBeginTimeList[0];
57
+ const isExceedExecuteTime = (lastOpBeginTime - firstOpBeginTime) / 1000 > 30 ? true : false;
58
+ if (isExceedExecuteTime || this.pendingOperationList.length > 50) {
59
+ this.dispatchConnectState('pending_operations_exceed_limit');
60
+ }
61
+ this.sendOperations();
62
+ };
63
+ this.sendOperations = () => {
64
+ if (this.state !== STATE.IDLE) return;
65
+ stateDebug("State changed: ".concat(this.state, " -> ").concat(STATE.SENDING));
66
+ this.state = STATE.SENDING;
67
+ this.sendNextOperations();
68
+ };
69
+ this.sendNextOperations = () => {
70
+ if (this.state !== STATE.SENDING) return;
71
+ if (this.pendingOperationList.length === 0) {
72
+ stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.IDLE));
73
+ this.state = STATE.IDLE;
74
+ return;
75
+ }
76
+ this.dispatchConnectState('is-saving');
77
+ const version = this.document.version;
78
+ const operations = this.pendingOperationList.shift();
79
+ const selection = this.editor.selection;
80
+ this._sendingOperations = operations;
81
+ this.socketClient.sendOperations(operations, version, selection, this.sendOperationsCallback);
82
+ };
83
+ this.sendOperationsCallback = result => {
84
+ if (result && result.success) {
85
+ const {
86
+ version: serverVersion
87
+ } = result;
88
+ this.document['version'] = serverVersion;
89
+ const lastSavedAt = new Date().getTime();
90
+ this.dispatchConnectState('saved', lastSavedAt);
91
91
 
92
- // send next operations
93
- _this.pendingOperationBeginTimeList.shift(); // remove current operation's begin time
94
- _this._sendingOperations = null;
95
- _this.sendNextOperations();
96
- return;
97
- }
92
+ // send next operations
93
+ this.pendingOperationBeginTimeList.shift(); // remove current operation's begin time
94
+ this._sendingOperations = null;
95
+ this.sendNextOperations();
96
+ return;
97
+ }
98
98
 
99
- // Operations are execute failure
100
- var error_type = result.error_type;
101
- if (error_type === 'load_document_content_error' || error_type === 'save_operations_to_database_error') {
102
- // load_document_content_error: After a short-term reconnection, the content of the document fails to load
103
- // save_operation_to_database_error: Save operation to database error
104
- _this.dispatchConnectState(error_type);
99
+ // Operations are execute failure
100
+ const {
101
+ error_type
102
+ } = result;
103
+ if (error_type === 'load_document_content_error' || error_type === 'save_operations_to_database_error') {
104
+ // load_document_content_error: After a short-term reconnection, the content of the document fails to load
105
+ // save_operation_to_database_error: Save operation to database error
106
+ this.dispatchConnectState(error_type);
105
107
 
106
- // reset sending control
107
- stateDebug("State Changed: ".concat(_this.state, " -> ").concat(STATE.NEED_RELOAD));
108
- _this.state = STATE.NEED_RELOAD;
109
- _this._sendingOperations = null;
110
- } else if (error_type === 'version_behind_server') {
111
- // Put the failed operation into the pending list and re-execute it
112
- _this.pendingOperationList.unshift(_toConsumableArray(_this._sendingOperations));
113
- stateDebug("State Changed: ".concat(_this.state, " -> ").concat(STATE.CONFLICT));
114
- _this.state = STATE.CONFLICT;
115
- var lose_operations = result.lose_operations;
116
- _this.resolveConflicting(lose_operations);
117
- } else if (error_type === 'execute_client_operations_error') {
118
- _this.editor.isRemote = true;
119
- var dupSendingOperations = _toConsumableArray(_this._sendingOperations);
120
- revertOperationList(_this.editor, [dupSendingOperations]);
108
+ // reset sending control
109
+ stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.NEED_RELOAD));
110
+ this.state = STATE.NEED_RELOAD;
111
+ this._sendingOperations = null;
112
+ } else if (error_type === 'version_behind_server') {
113
+ // Put the failed operation into the pending list and re-execute it
114
+ this.pendingOperationList.unshift([...this._sendingOperations]);
115
+ stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.CONFLICT));
116
+ this.state = STATE.CONFLICT;
117
+ const {
118
+ lose_operations
119
+ } = result;
120
+ this.resolveConflicting(lose_operations);
121
+ } else if (error_type === 'execute_client_operations_error') {
122
+ this.editor.isRemote = true;
123
+ const dupSendingOperations = [...this._sendingOperations];
124
+ revertOperationList(this.editor, [dupSendingOperations]);
121
125
 
122
- // Update the save time after revert
123
- var _lastSavedAt = new Date().getTime();
124
- _this.dispatchConnectState('saved', _lastSavedAt);
126
+ // Update the save time after revert
127
+ const lastSavedAt = new Date().getTime();
128
+ this.dispatchConnectState('saved', lastSavedAt);
125
129
 
126
- // Set isRemote to false must be in Promise.resolve function, make sure the modification of isRemote is later than the onChange event
127
- Promise.resolve().then(function (_) {
128
- _this.editor.isRemote = false;
129
- _this.dispatchConnectState(error_type);
130
+ // Set isRemote to false must be in Promise.resolve function, make sure the modification of isRemote is later than the onChange event
131
+ Promise.resolve().then(_ => {
132
+ this.editor.isRemote = false;
133
+ this.dispatchConnectState(error_type);
130
134
 
131
- // send next operations
132
- _this._sendingOperations = null;
133
- _this.sendNextOperations();
134
- });
135
- }
136
- };
137
- this.onReceiveRemoteOperations = function (params) {
138
- // if this.disconnect is true, Then the message sent by the remote end cannot be received
139
- if (_this.state !== STATE.IDLE) return;
140
- var serverVersion = params.version;
141
- var clientVersion = _this.document.version;
142
- if (serverVersion === clientVersion + 1) {
143
- // update execute remote operations flag
144
- _this.editor.isRemote = true;
145
- var operations = params.operations;
146
- // Update content & version
147
- serverDebug('execute remote operations: %O', operations);
148
- try {
149
- syncRemoteOperations(_this.editor, operations);
150
- } catch (error) {
151
- stateDebug("State Changed: ".concat(_this.state, " -> ").concat(STATE.CONFLICT));
152
- _this.state = STATE.CONFLICT;
153
- _this.dispatchConnectState('sync_server_operations_error');
135
+ // send next operations
136
+ this._sendingOperations = null;
137
+ this.sendNextOperations();
138
+ });
139
+ }
140
+ };
141
+ this.onReceiveRemoteOperations = params => {
142
+ // if this.disconnect is true, Then the message sent by the remote end cannot be received
143
+ if (this.state !== STATE.IDLE) return;
144
+ const {
145
+ version: serverVersion
146
+ } = params;
147
+ const {
148
+ version: clientVersion
149
+ } = this.document;
150
+ if (serverVersion === clientVersion + 1) {
151
+ // update execute remote operations flag
152
+ this.editor.isRemote = true;
153
+ const {
154
+ operations
155
+ } = params;
156
+ // Update content & version
157
+ serverDebug('execute remote operations: %O', operations);
158
+ try {
159
+ syncRemoteOperations(this.editor, operations);
160
+ } catch (error) {
161
+ stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.CONFLICT));
162
+ this.state = STATE.CONFLICT;
163
+ this.dispatchConnectState('sync_server_operations_error');
164
+ return;
165
+ }
166
+
167
+ // Update document
168
+ this.document.version = serverVersion;
169
+ this.document.children = this.editor.children;
170
+ Promise.resolve().then(() => {
171
+ this.editor.isRemote = false;
172
+ this.revertOperationList = [];
173
+ });
174
+ } else {
175
+ // isConflict
176
+ this.onConflictHappen();
177
+ }
178
+ };
179
+ this.onReconnect = result => {
180
+ const {
181
+ version: serverVersion
182
+ } = result;
183
+ const clientVersion = this.getDocumentVersion();
184
+ // The client version is inconsistent with the server version, and the latest operations performed by the server need to be loaded
185
+ if (serverVersion !== clientVersion) {
186
+ this.onConflictHappen();
154
187
  return;
155
188
  }
156
189
 
157
- // Update document
158
- _this.document.version = serverVersion;
159
- _this.document.children = _this.editor.children;
160
- Promise.resolve().then(function () {
161
- _this.editor.isRemote = false;
162
- _this.revertOperationList = [];
163
- });
164
- } else {
165
- // isConflict
166
- _this.onConflictHappen();
167
- }
168
- };
169
- this.onReconnect = function (result) {
170
- var serverVersion = result.version;
171
- var clientVersion = _this.getDocumentVersion();
172
- // The client version is inconsistent with the server version, and the latest operations performed by the server need to be loaded
173
- if (serverVersion !== clientVersion) {
174
- _this.onConflictHappen();
175
- return;
176
- }
190
+ // The version consistency indicates that there is no conflict and no processing is required
191
+ stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.IDLE));
192
+ this.state = STATE.IDLE;
193
+ if (this.pendingOperationList.length > 0) {
194
+ clientDebug('After reconnection, manually trigger the execution of ops.');
195
+ stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.SENDING));
196
+ this.state = STATE.SENDING;
197
+ this.sendNextOperations();
198
+ }
199
+ };
200
+ this.onConflictHappen = () => {
201
+ stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.CONFLICT));
202
+ this.state = STATE.CONFLICT;
203
+ this.socketClient.getRecentOperations();
204
+ };
205
+ this.onGetRecentOperations = result => {
206
+ const {
207
+ mode,
208
+ content
209
+ } = result;
210
+ conflictDebug('Start conflict resolution');
211
+ // sync document
212
+ if (mode === 'document') {
213
+ const {
214
+ version,
215
+ children
216
+ } = content;
217
+ // 1. update document
218
+ conflictDebug('Update local document to remote document');
219
+ this.document.children = children;
220
+ this.document.version = version;
221
+ this.editor.children = children;
222
+ this.editor.isRemote = true;
223
+ this.editor.onChange();
224
+ stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.IDLE));
225
+ this.editor.isRemote = false;
226
+ this.state = STATE.IDLE;
227
+ this._sendingOperations = null;
177
228
 
178
- // The version consistency indicates that there is no conflict and no processing is required
179
- stateDebug("State Changed: ".concat(_this.state, " -> ").concat(STATE.IDLE));
180
- _this.state = STATE.IDLE;
181
- if (_this.pendingOperationList.length > 0) {
182
- clientDebug('After reconnection, manually trigger the execution of ops.');
183
- stateDebug("State Changed: ".concat(_this.state, " -> ").concat(STATE.SENDING));
184
- _this.state = STATE.SENDING;
185
- _this.sendNextOperations();
186
- }
187
- };
188
- this.onConflictHappen = function () {
189
- stateDebug("State Changed: ".concat(_this.state, " -> ").concat(STATE.CONFLICT));
190
- _this.state = STATE.CONFLICT;
191
- _this.socketClient.getRecentOperations();
192
- };
193
- this.onGetRecentOperations = function (result) {
194
- var mode = result.mode,
195
- content = result.content;
196
- conflictDebug('Start conflict resolution');
197
- // sync document
198
- if (mode === 'document') {
199
- var version = content.version,
200
- children = content.children;
201
- // 1. update document
202
- conflictDebug('Update local document to remote document');
203
- _this.document.children = children;
204
- _this.document.version = version;
205
- _this.editor.children = children;
206
- _this.editor.isRemote = true;
207
- _this.editor.onChange();
208
- stateDebug("State Changed: ".concat(_this.state, " -> ").concat(STATE.IDLE));
209
- _this.editor.isRemote = false;
210
- _this.state = STATE.IDLE;
211
- _this._sendingOperations = null;
229
+ // 2. exec client operationList
230
+ const pendingOperationList = this.pendingOperationList.slice();
231
+ this.pendingOperationList = [];
212
232
 
213
- // 2. exec client operationList
214
- var pendingOperationList = _this.pendingOperationList.slice();
215
- _this.pendingOperationList = [];
233
+ // need resend this operations to server
234
+ conflictDebug('Re-execute local unsynchronized operations: %o', pendingOperationList);
235
+ reExecRevertOperationList(this.editor, pendingOperationList);
236
+ return;
237
+ }
216
238
 
217
- // need resend this operations to server
218
- conflictDebug('Re-execute local unsynchronized operations: %o', pendingOperationList);
219
- reExecRevertOperationList(_this.editor, pendingOperationList);
220
- return;
221
- }
239
+ // mode os operations: sync operations
240
+ // content is [{version, operations}, {version, operations}, ...]
241
+ const loseOperations = content;
242
+ this.resolveConflicting(loseOperations);
243
+ };
244
+ this.resolveConflicting = loseOperations => {
245
+ conflictDebug('resolve conflicts');
246
+ this.editor.isRemote = true;
247
+ if (this.pendingOperationList.length !== 0) {
248
+ // 1. Revert operations
249
+ // 1.1 record reverted operationList & clear pendingOperationList
250
+ this.revertOperationList = this.pendingOperationList.slice();
251
+ this.pendingOperationList = [];
222
252
 
223
- // mode os operations: sync operations
224
- // content is [{version, operations}, {version, operations}, ...]
225
- var loseOperations = content;
226
- _this.resolveConflicting(loseOperations);
227
- };
228
- this.resolveConflicting = function (loseOperations) {
229
- conflictDebug('resolve conflicts');
230
- _this.editor.isRemote = true;
231
- if (_this.pendingOperationList.length !== 0) {
232
- // 1. Revert operations
233
- // 1.1 record reverted operationList & clear pendingOperationList
234
- _this.revertOperationList = _this.pendingOperationList.slice();
235
- _this.pendingOperationList = [];
253
+ // 1.2 Revert operationList
254
+ conflictDebug('revert locale operations: %O', this.revertOperationList);
255
+ revertOperationList(this.editor, this.revertOperationList);
256
+ }
257
+ loseOperations = loseOperations.sort((prev, next) => prev.version - next.version);
258
+ conflictDebug('lose operations length: %s', loseOperations.length);
259
+ while (loseOperations.length > 0) {
260
+ const operationParams = loseOperations.shift();
261
+ // 2. execute operations
262
+ const {
263
+ operations,
264
+ version: serverVersion
265
+ } = operationParams;
266
+ // 2.1 Update content & version
267
+ conflictDebug('execute lose operations: %O', operations);
268
+ try {
269
+ syncRemoteOperations(this.editor, operations);
270
+ } catch (error) {
271
+ stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.CONFLICT));
272
+ this.state = STATE.CONFLICT;
273
+ this.dispatchConnectState('sync_server_operations_error');
274
+ return;
275
+ }
236
276
 
237
- // 1.2 Revert operationList
238
- conflictDebug('revert locale operations: %O', _this.revertOperationList);
239
- revertOperationList(_this.editor, _this.revertOperationList);
240
- }
241
- loseOperations = loseOperations.sort(function (prev, next) {
242
- return prev.version - next.version;
243
- });
244
- conflictDebug('lose operations length: %s', loseOperations.length);
245
- while (loseOperations.length > 0) {
246
- var operationParams = loseOperations.shift();
247
- // 2. execute operations
248
- var operations = operationParams.operations,
249
- serverVersion = operationParams.version;
250
- // 2.1 Update content & version
251
- conflictDebug('execute lose operations: %O', operations);
252
- try {
253
- syncRemoteOperations(_this.editor, operations);
254
- } catch (error) {
255
- stateDebug("State Changed: ".concat(_this.state, " -> ").concat(STATE.CONFLICT));
256
- _this.state = STATE.CONFLICT;
257
- _this.dispatchConnectState('sync_server_operations_error');
277
+ // 2.2 Update document
278
+ this.document.version = serverVersion;
279
+ this.document.children = this.editor.children;
280
+ }
281
+ if (this.revertOperationList.length === 0) {
282
+ Promise.resolve().then(() => {
283
+ this.editor.isRemote = false;
284
+ stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.IDLE));
285
+ this.state = STATE.IDLE;
286
+ this._sendingOperations = null;
287
+ this.revertOperationList = [];
288
+ });
258
289
  return;
259
290
  }
260
291
 
261
- // 2.2 Update document
262
- _this.document.version = serverVersion;
263
- _this.document.children = _this.editor.children;
264
- }
265
- if (_this.revertOperationList.length === 0) {
266
- Promise.resolve().then(function () {
267
- _this.editor.isRemote = false;
268
- stateDebug("State Changed: ".concat(_this.state, " -> ").concat(STATE.IDLE));
269
- _this.state = STATE.IDLE;
270
- _this._sendingOperations = null;
271
- _this.revertOperationList = [];
272
- });
273
- return;
274
- }
275
-
276
- // Set isRemote to false must be in Promise.resolve function, make sure the modification of isRemote is later than the onChange event
277
- Promise.resolve().then(function () {
278
- // reset execute remote operations flag
279
- _this.editor.isRemote = false;
280
- stateDebug("State Changed: ".concat(_this.state, " -> ").concat(STATE.IDLE));
281
- _this.state = STATE.IDLE;
282
- _this._sendingOperations = null;
292
+ // Set isRemote to false must be in Promise.resolve function, make sure the modification of isRemote is later than the onChange event
293
+ Promise.resolve().then(() => {
294
+ // reset execute remote operations flag
295
+ this.editor.isRemote = false;
296
+ stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.IDLE));
297
+ this.state = STATE.IDLE;
298
+ this._sendingOperations = null;
283
299
 
284
- // 3. Execute pending operations
285
- // 3.1 Re-execute operations
286
- conflictDebug('Editor isRemote is false: %s', _this.editor.isRemote);
287
- conflictDebug('Re-execute pending operations, %O', _this.revertOperationList);
288
- reExecRevertOperationList(_this.editor, _this.revertOperationList);
300
+ // 3. Execute pending operations
301
+ // 3.1 Re-execute operations
302
+ conflictDebug('Editor isRemote is false: %s', this.editor.isRemote);
303
+ conflictDebug('Re-execute pending operations, %O', this.revertOperationList);
304
+ reExecRevertOperationList(this.editor, this.revertOperationList);
289
305
 
290
- // 3.2 Clear revert operationList
291
- _this.revertOperationList = [];
292
- conflictDebug('Complete conflict resolution');
293
- });
294
- };
295
- this.sendCursorLocation = function (location) {
296
- _this.socketClient.sendCursorLocation(location);
297
- };
298
- this.receiveCursorLocation = function (params) {
299
- var user = params.user,
300
- location = params.location,
301
- cursorData = params.cursor_data;
302
- syncRemoteCursorLocation(_this.editor, user, location, cursorData);
303
- return;
304
- };
305
- this.dispatchConnectState = function (type, message) {
306
- if (type === 'leave-room') {
307
- deleteCursor(_this.editor, message);
308
- _this.editor.onCursor && _this.editor.onCursor(_this.editor.cursors);
309
- }
310
- if (type === 'disconnect') {
311
- // current state is sending
312
- if (_this._sendingOperations) {
313
- _this.pendingOperationList.unshift(_this._sendingOperations.slice());
314
- _this._sendingOperations = null;
306
+ // 3.2 Clear revert operationList
307
+ this.revertOperationList = [];
308
+ conflictDebug('Complete conflict resolution');
309
+ });
310
+ };
311
+ this.sendCursorLocation = location => {
312
+ this.socketClient.sendCursorLocation(location);
313
+ };
314
+ this.receiveCursorLocation = params => {
315
+ const {
316
+ user,
317
+ location,
318
+ cursor_data: cursorData
319
+ } = params;
320
+ syncRemoteCursorLocation(this.editor, user, location, cursorData);
321
+ return;
322
+ };
323
+ this.dispatchConnectState = (type, message) => {
324
+ if (type === 'leave-room') {
325
+ deleteCursor(this.editor, message);
326
+ this.editor.onCursor && this.editor.onCursor(this.editor.cursors);
327
+ }
328
+ if (type === 'disconnect') {
329
+ // current state is sending
330
+ if (this._sendingOperations) {
331
+ this.pendingOperationList.unshift(this._sendingOperations.slice());
332
+ this._sendingOperations = null;
333
+ }
334
+ stateDebug("State Changed: ".concat(this.state, " -> ").concat(STATE.DISCONNECT));
335
+ this.state = STATE.DISCONNECT;
315
336
  }
316
- stateDebug("State Changed: ".concat(_this.state, " -> ").concat(STATE.DISCONNECT));
317
- _this.state = STATE.DISCONNECT;
318
- }
319
- _this.eventBus.dispatch(type, message);
320
- };
321
- this.closeSocketConnect = function () {
322
- _this.socketClient.disconnectWithServer();
323
- };
324
- this.editor = editor;
325
- this.document = _document;
326
- this.socketClient = new SocketClient(config);
327
- this.pendingOperationList = []; // Two-dimensional arrays: [operations, operations, ...]
328
- this.pendingOperationBeginTimeList = [];
329
- this.remoteOperationsList = []; // Same with pending operations
330
- this.revertOperationList = [];
331
- this.eventBus = EventBus.getInstance();
332
- this.state = STATE.IDLE;
333
- });
337
+ this.eventBus.dispatch(type, message);
338
+ };
339
+ this.closeSocketConnect = () => {
340
+ this.socketClient.disconnectWithServer();
341
+ };
342
+ this.editor = editor;
343
+ this.document = _document;
344
+ this.socketClient = new SocketClient(config);
345
+ this.pendingOperationList = []; // Two-dimensional arrays: [operations, operations, ...]
346
+ this.pendingOperationBeginTimeList = [];
347
+ this.remoteOperationsList = []; // Same with pending operations
348
+ this.revertOperationList = [];
349
+ this.eventBus = EventBus.getInstance();
350
+ this.state = STATE.IDLE;
351
+ }
352
+ }
334
353
  _class = SocketManager;
335
- SocketManager.getInstance = function (editor, document, socketConfig) {
354
+ SocketManager.getInstance = (editor, document, socketConfig) => {
336
355
  if (_class.instance) {
337
356
  return _class.instance;
338
357
  }
@@ -342,7 +361,7 @@ SocketManager.getInstance = function (editor, document, socketConfig) {
342
361
  _class.instance = new _class(editor, document, socketConfig);
343
362
  return _class.instance;
344
363
  };
345
- SocketManager.destroy = function () {
364
+ SocketManager.destroy = () => {
346
365
  _class.instance = null;
347
366
  };
348
367
  export default SocketManager;