edytor 2.0.0 → 4.0.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 (346) hide show
  1. package/README.md +19 -4
  2. package/dist/block/block.svelte.js +2 -4
  3. package/dist/clipboard/htmlFlow.d.ts +20 -7
  4. package/dist/clipboard/htmlFlow.js +23 -15
  5. package/dist/clipboard/serializeClipboardFragment.d.ts +37 -4
  6. package/dist/clipboard/serializeClipboardFragment.js +6 -4
  7. package/dist/clipboard/textBlocks.d.ts +8 -0
  8. package/dist/clipboard/textBlocks.js +6 -2
  9. package/dist/cloudflare/DocumentRoom.d.ts +13 -9
  10. package/dist/cloudflare/DocumentRoom.js +10 -6
  11. package/dist/cloudflare/room/admission.js +3 -3
  12. package/dist/cloudflare/room/context.d.ts +28 -27
  13. package/dist/cloudflare/room/context.js +2 -2
  14. package/dist/cloudflare/room/purge.d.ts +6 -3
  15. package/dist/cloudflare/room/purge.js +44 -19
  16. package/dist/cloudflare/room/updates.d.ts +3 -4
  17. package/dist/cloudflare/room/updates.js +6 -8
  18. package/dist/cloudflare/routeDocumentSocket.d.ts +17 -0
  19. package/dist/cloudflare/routeDocumentSocket.js +53 -0
  20. package/dist/collaboration/comments/client.d.ts +1 -1
  21. package/dist/collaboration/comments/client.js +1 -1
  22. package/dist/collaboration/remoteSelection.js +3 -3
  23. package/dist/components/Edytor.svelte +2 -10
  24. package/dist/components/Edytor.svelte.d.ts +1 -3
  25. package/dist/crdt/admission.d.ts +5 -10
  26. package/dist/crdt/admission.js +5 -11
  27. package/dist/crdt/attribution/attribution.d.ts +31 -12
  28. package/dist/crdt/attribution/attribution.js +56 -18
  29. package/dist/crdt/attribution/block.d.ts +3 -3
  30. package/dist/crdt/attribution/block.js +7 -8
  31. package/dist/crdt/attribution/index.d.ts +1 -1
  32. package/dist/crdt/attribution/index.js +1 -1
  33. package/dist/crdt/data.d.ts +62 -31
  34. package/dist/crdt/data.js +211 -103
  35. package/dist/crdt/doc/delete.d.ts +1 -1
  36. package/dist/crdt/doc/delete.js +13 -30
  37. package/dist/crdt/doc/funnel.d.ts +7 -6
  38. package/dist/crdt/doc/funnel.js +39 -33
  39. package/dist/crdt/doc/gate.d.ts +3 -20
  40. package/dist/crdt/doc/gate.js +2 -41
  41. package/dist/crdt/doc/history.d.ts +25 -9
  42. package/dist/crdt/doc/history.js +152 -42
  43. package/dist/crdt/doc/layout.js +11 -22
  44. package/dist/crdt/doc/meta.js +12 -17
  45. package/dist/crdt/doc/moves.d.ts +1 -1
  46. package/dist/crdt/doc/moves.js +52 -32
  47. package/dist/crdt/doc/reads.js +2 -2
  48. package/dist/crdt/doc/seed.js +2 -2
  49. package/dist/crdt/doc/split-merge.js +12 -15
  50. package/dist/crdt/doc/steps.d.ts +25 -13
  51. package/dist/crdt/doc/steps.js +52 -122
  52. package/dist/crdt/doc/types.d.ts +21 -9
  53. package/dist/crdt/document.d.ts +21 -19
  54. package/dist/crdt/document.js +26 -23
  55. package/dist/crdt/edytor-doc.d.ts +66 -68
  56. package/dist/crdt/edytor-doc.js +21 -20
  57. package/dist/crdt/engine-api.d.ts +33 -1
  58. package/dist/crdt/engine.d.ts +0 -1
  59. package/dist/crdt/engine.js +1 -4
  60. package/dist/crdt/flow.d.ts +1 -1
  61. package/dist/crdt/flow.js +25 -27
  62. package/dist/crdt/index.d.ts +29 -28
  63. package/dist/crdt/index.js +3 -3
  64. package/dist/crdt/placement/display.d.ts +5 -30
  65. package/dist/crdt/placement/display.js +39 -144
  66. package/dist/crdt/placement/keys.d.ts +58 -0
  67. package/dist/crdt/placement/keys.js +90 -0
  68. package/dist/crdt/placement/model.d.ts +119 -118
  69. package/dist/crdt/placement/model.js +242 -142
  70. package/dist/crdt/placement/resolve.d.ts +123 -35
  71. package/dist/crdt/placement/resolve.js +187 -153
  72. package/dist/crdt/placement/slots.d.ts +134 -0
  73. package/dist/crdt/placement/slots.js +152 -0
  74. package/dist/crdt/protocol.d.ts +2 -2
  75. package/dist/crdt/protocol.js +2 -2
  76. package/dist/crdt/providers/index.d.ts +1 -1
  77. package/dist/crdt/providers/room.d.ts +26 -11
  78. package/dist/crdt/providers/room.js +77 -27
  79. package/dist/crdt/providers/websocket.d.ts +1 -1
  80. package/dist/crdt/providers/websocket.js +33 -32
  81. package/dist/crdt/purge.d.ts +17 -8
  82. package/dist/crdt/purge.js +236 -126
  83. package/dist/crdt/restore.d.ts +2 -2
  84. package/dist/crdt/restore.js +18 -34
  85. package/dist/crdt/schema.d.ts +22 -21
  86. package/dist/crdt/schema.js +29 -23
  87. package/dist/crdt/semantics.js +3 -1
  88. package/dist/crdt/storage.d.ts +1 -1
  89. package/dist/crdt/storage.js +1 -1
  90. package/dist/crdt/structs.d.ts +15 -15
  91. package/dist/crdt/structs.js +8 -22
  92. package/dist/crdt/text/index/cache.js +4 -0
  93. package/dist/crdt/text/index/claims.js +12 -0
  94. package/dist/crdt/text/index/fold.d.ts +2 -3
  95. package/dist/crdt/text/index/fold.js +194 -44
  96. package/dist/crdt/text/index/layout.js +5 -8
  97. package/dist/crdt/text/index/placement.d.ts +26 -18
  98. package/dist/crdt/text/index/placement.js +404 -138
  99. package/dist/crdt/text/index/records.d.ts +3 -3
  100. package/dist/crdt/text/index/records.js +24 -31
  101. package/dist/crdt/text/index/shared.d.ts +11 -3
  102. package/dist/crdt/text/index/shared.js +12 -3
  103. package/dist/crdt/text/index/state.d.ts +21 -17
  104. package/dist/crdt/text/index/state.js +15 -17
  105. package/dist/crdt/text/index/streams.d.ts +10 -5
  106. package/dist/crdt/text/index/streams.js +78 -27
  107. package/dist/crdt/text/items.d.ts +10 -3
  108. package/dist/crdt/text/items.js +7 -0
  109. package/dist/crdt/text/model.d.ts +77 -62
  110. package/dist/crdt/text/model.js +84 -169
  111. package/dist/crdt/text/ranges.d.ts +1 -1
  112. package/dist/crdt/text/ranges.js +3 -3
  113. package/dist/crdt/text/rows.d.ts +13 -7
  114. package/dist/crdt/text/rows.js +24 -7
  115. package/dist/crdt/text/runs.d.ts +17 -12
  116. package/dist/crdt/text/runs.js +24 -7
  117. package/dist/crdt/text/streams.d.ts +26 -13
  118. package/dist/crdt/text/streams.js +41 -14
  119. package/dist/crdt/vendor/yjs/UPSTREAM.md +568 -21
  120. package/dist/crdt/vendor/yjs/dts/global.d.ts +2 -0
  121. package/dist/crdt/vendor/yjs/dts/index.d.ts +1 -1
  122. package/dist/crdt/vendor/yjs/dts/structs/AbstractStruct.d.ts +7 -0
  123. package/dist/crdt/vendor/yjs/dts/structs/Item.d.ts +194 -10
  124. package/dist/crdt/vendor/yjs/dts/utils/Doc.d.ts +6 -3
  125. package/dist/crdt/vendor/yjs/dts/utils/StructStore.d.ts +5 -18
  126. package/dist/crdt/vendor/yjs/dts/utils/Transaction.d.ts +15 -1
  127. package/dist/crdt/vendor/yjs/dts/utils/UpdateDecoder.d.ts +14 -6
  128. package/dist/crdt/vendor/yjs/dts/utils/UpdateEncoder.d.ts +33 -6
  129. package/dist/crdt/vendor/yjs/dts/utils/ids.d.ts +1 -65
  130. package/dist/crdt/vendor/yjs/dts/utils/marks.d.ts +6 -1
  131. package/dist/crdt/vendor/yjs/dts/ynode.d.ts +43 -7
  132. package/dist/crdt/vendor/yjs/global.d.ts +2 -0
  133. package/dist/crdt/vendor/yjs/src/index.js +1 -1
  134. package/dist/crdt/vendor/yjs/src/structs/AbstractStruct.js +10 -0
  135. package/dist/crdt/vendor/yjs/src/structs/Item.js +610 -51
  136. package/dist/crdt/vendor/yjs/src/utils/BlockSet.js +18 -9
  137. package/dist/crdt/vendor/yjs/src/utils/Doc.js +5 -3
  138. package/dist/crdt/vendor/yjs/src/utils/StructStore.js +5 -0
  139. package/dist/crdt/vendor/yjs/src/utils/Transaction.js +36 -13
  140. package/dist/crdt/vendor/yjs/src/utils/UpdateDecoder.js +88 -18
  141. package/dist/crdt/vendor/yjs/src/utils/UpdateEncoder.js +119 -32
  142. package/dist/crdt/vendor/yjs/src/utils/encoding.js +13 -1
  143. package/dist/crdt/vendor/yjs/src/utils/ids.js +7 -7
  144. package/dist/crdt/vendor/yjs/src/utils/marks.js +193 -8
  145. package/dist/crdt/vendor/yjs/src/utils/redo.js +1 -1
  146. package/dist/crdt/vendor/yjs/src/utils/transaction-helpers.js +1 -1
  147. package/dist/crdt/vendor/yjs/src/utils/updates.js +3 -3
  148. package/dist/crdt/vendor/yjs/src/ynode.js +177 -12
  149. package/dist/dnd/autoScroll.d.ts +15 -7
  150. package/dist/dnd/autoScroll.js +10 -15
  151. package/dist/dnd/dropIndicator.js +2 -5
  152. package/dist/dnd/external.d.ts +6 -0
  153. package/dist/dnd/external.js +17 -0
  154. package/dist/dnd/geometry.d.ts +2 -0
  155. package/dist/dnd/geometry.js +3 -4
  156. package/dist/dnd/placement.d.ts +1 -1
  157. package/dist/dnd/pragmatic.d.ts +3 -1
  158. package/dist/dnd/pragmatic.js +12 -2
  159. package/dist/dnd/vendor/pragmatic/UPSTREAM.md +51 -18
  160. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/drop-target-for-external.d.ts +4 -0
  161. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/drop-target-for-external.js +6 -0
  162. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/element-adapter.d.ts +0 -2
  163. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/element-adapter.js +4 -22
  164. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter-types.d.ts +26 -0
  165. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter.d.ts +30 -0
  166. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter.js +203 -0
  167. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/get-available-items.js +13 -0
  168. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/get-available-types.js +9 -0
  169. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/is-an-available-type.js +19 -0
  170. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/monitor-for-external.d.ts +4 -0
  171. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/monitor-for-external.js +6 -0
  172. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/honey-pot-fix/make-honey-pot-fix.js +4 -16
  173. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/internal-types.d.ts +1 -8
  174. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/make-adapter/make-drop-target.js +5 -6
  175. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/make-adapter/make-monitor.js +2 -3
  176. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/element/custom-native-drag-preview/set-custom-native-drag-preview.d.ts +1 -1
  177. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/element/custom-native-drag-preview/set-custom-native-drag-preview.js +6 -24
  178. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/contains-files.d.ts +2 -0
  179. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/contains-files.js +5 -0
  180. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/get-files.d.ts +3 -0
  181. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/get-files.js +12 -0
  182. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/native-types.d.ts +12 -0
  183. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/is-entering-window-in-safari.js +10 -0
  184. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/is-entering-window.js +55 -0
  185. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/external.d.ts +4 -0
  186. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/external.js +8 -0
  187. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/internal-types.d.ts +0 -4
  188. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/get-scroll-by.js +16 -72
  189. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/try-scroll.js +1 -9
  190. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/configuration.js +4 -29
  191. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/get-scroll-change.js +2 -3
  192. package/dist/edytor.svelte.d.ts +2 -5
  193. package/dist/edytor.svelte.js +21 -32
  194. package/dist/events/beforeInputCommands.js +2 -2
  195. package/dist/events/onBeforeInput.js +1 -1
  196. package/dist/events/onDrop.d.ts +0 -6
  197. package/dist/events/onDrop.js +10 -23
  198. package/dist/events/onInput.d.ts +0 -12
  199. package/dist/events/onInput.js +1 -67
  200. package/dist/events/onPageHide.d.ts +3 -0
  201. package/dist/events/onPageHide.js +16 -0
  202. package/dist/export/forms.d.ts +627 -0
  203. package/dist/export/forms.js +749 -0
  204. package/dist/export/index.d.ts +170 -0
  205. package/dist/export/index.js +161 -0
  206. package/dist/export/markdown.d.ts +41 -0
  207. package/dist/export/markdown.js +585 -0
  208. package/dist/export/markdownWriter.d.ts +9 -0
  209. package/dist/export/markdownWriter.js +133 -0
  210. package/dist/export/mdx.d.ts +15 -0
  211. package/dist/export/mdx.js +33 -0
  212. package/dist/index.d.ts +3 -3
  213. package/dist/index.js +1 -1
  214. package/dist/kinds.js +1 -1
  215. package/dist/plugins/anchored.svelte.d.ts +21 -25
  216. package/dist/plugins/anchored.svelte.js +23 -39
  217. package/dist/plugins/blockHandles/BlockHandleController.svelte.js +24 -32
  218. package/dist/plugins/blockHandles/dragPreview.d.ts +26 -7
  219. package/dist/plugins/blockHandles/dragPreview.js +33 -0
  220. package/dist/plugins/blockMenu/BlockMenuController.svelte.d.ts +5 -0
  221. package/dist/plugins/blockMenu/BlockMenuController.svelte.js +7 -2
  222. package/dist/plugins/blockMenu/blockMenuPlugin.js +5 -50
  223. package/dist/plugins/chrome.d.ts +27 -5
  224. package/dist/plugins/chrome.js +24 -9
  225. package/dist/plugins/code/CodePlugin.svelte +12 -9
  226. package/dist/plugins/code/header.svelte.js +7 -11
  227. package/dist/plugins/code/languageMenu.svelte.d.ts +5 -2
  228. package/dist/plugins/code/languageMenu.svelte.js +13 -20
  229. package/dist/plugins/columns/ColumnsPlugin.svelte +7 -20
  230. package/dist/plugins/columns/resize.svelte.d.ts +2 -3
  231. package/dist/plugins/columns/resize.svelte.js +2 -5
  232. package/dist/plugins/comments/CommentsController.svelte.d.ts +6 -0
  233. package/dist/plugins/comments/CommentsController.svelte.js +20 -0
  234. package/dist/plugins/equation/EquationPlugin.svelte +12 -22
  235. package/dist/plugins/equation/equation.svelte.d.ts +7 -15
  236. package/dist/plugins/equation/equation.svelte.js +13 -50
  237. package/dist/plugins/equation/tex.d.ts +17 -0
  238. package/dist/plugins/equation/tex.js +42 -0
  239. package/dist/plugins/fileDrop.d.ts +38 -23
  240. package/dist/plugins/fileDrop.js +82 -76
  241. package/dist/plugins/find/FindController.svelte.d.ts +5 -0
  242. package/dist/plugins/find/FindController.svelte.js +14 -14
  243. package/dist/plugins/find/findPlugin.js +1 -15
  244. package/dist/plugins/image/ImageChrome.svelte +8 -2
  245. package/dist/plugins/image/ImagePlugin.svelte +15 -52
  246. package/dist/plugins/image/controls.svelte.js +16 -2
  247. package/dist/plugins/image/toolbar.svelte.d.ts +5 -4
  248. package/dist/plugins/image/toolbar.svelte.js +21 -31
  249. package/dist/plugins/index.d.ts +1 -1
  250. package/dist/plugins/list.svelte.d.ts +9 -0
  251. package/dist/plugins/list.svelte.js +18 -0
  252. package/dist/plugins/marquee/marqueePlugin.js +0 -4
  253. package/dist/plugins/media/AudioPlugin.svelte +1 -1
  254. package/dist/plugins/media/BookmarkPlugin.svelte +6 -97
  255. package/dist/plugins/media/EmbedPlugin.svelte +5 -90
  256. package/dist/plugins/media/EmptySlot.svelte +36 -20
  257. package/dist/plugins/media/EmptySlot.svelte.d.ts +6 -15
  258. package/dist/plugins/media/FilePlugin.svelte +1 -19
  259. package/dist/plugins/media/MediaEmpty.svelte +2 -55
  260. package/dist/plugins/media/MediaEmpty.svelte.d.ts +18 -14
  261. package/dist/plugins/media/SourceBlock.svelte +142 -52
  262. package/dist/plugins/media/SourceBlock.svelte.d.ts +10 -4
  263. package/dist/plugins/media/VideoPlugin.svelte +1 -1
  264. package/dist/plugins/media/empty.svelte.js +2 -7
  265. package/dist/plugins/media/media.d.ts +2 -63
  266. package/dist/plugins/media/media.js +1 -194
  267. package/dist/plugins/media/sources.d.ts +60 -0
  268. package/dist/plugins/media/sources.js +165 -0
  269. package/dist/plugins/media/urlPaste.svelte.d.ts +2 -1
  270. package/dist/plugins/media/urlPaste.svelte.js +12 -21
  271. package/dist/plugins/mention/MentionPlugin.svelte +8 -35
  272. package/dist/plugins/page/PagePlugin.svelte +2 -9
  273. package/dist/plugins/page/page.js +1 -1
  274. package/dist/plugins/pageLink/PageLinkPlugin.svelte +6 -13
  275. package/dist/plugins/richtext/RichTextPlugin.svelte +85 -197
  276. package/dist/plugins/richtext/body.js +1 -1
  277. package/dist/plugins/richtext/calloutIcons.svelte.d.ts +2 -2
  278. package/dist/plugins/richtext/calloutIcons.svelte.js +5 -7
  279. package/dist/plugins/richtext/richTextOperations.d.ts +1 -19
  280. package/dist/plugins/richtext/richTextOperations.js +3 -49
  281. package/dist/plugins/slashMenu/SlashMenuController.svelte.d.ts +2 -0
  282. package/dist/plugins/slashMenu/SlashMenuController.svelte.js +7 -0
  283. package/dist/plugins/slashMenu/slashMenuPlugin.js +5 -14
  284. package/dist/plugins/table/TableChrome.svelte +2 -3
  285. package/dist/plugins/table/TablePlugin.svelte +20 -54
  286. package/dist/plugins/table/chrome.svelte.d.ts +5 -2
  287. package/dist/plugins/table/chrome.svelte.js +30 -54
  288. package/dist/plugins/table/table.js +3 -3
  289. package/dist/plugins/toc/TocPlugin.svelte +2 -4
  290. package/dist/plugins/toolbar/ToolbarController.svelte.d.ts +7 -0
  291. package/dist/plugins/toolbar/ToolbarController.svelte.js +20 -13
  292. package/dist/plugins/toolbar/toolbarPlugin.js +19 -53
  293. package/dist/plugins/triggers/TriggerController.svelte.d.ts +7 -2
  294. package/dist/plugins/triggers/TriggerController.svelte.js +11 -4
  295. package/dist/plugins/triggers/place.js +1 -2
  296. package/dist/plugins/triggers/triggers.d.ts +6 -1
  297. package/dist/plugins/triggers/triggers.js +12 -13
  298. package/dist/plugins/uploads.svelte.d.ts +5 -2
  299. package/dist/plugins/uploads.svelte.js +25 -15
  300. package/dist/plugins.d.ts +26 -0
  301. package/dist/plugins.js +0 -24
  302. package/dist/selection/replaceSelection.js +2 -2
  303. package/dist/selection/selection.svelte.d.ts +4 -10
  304. package/dist/selection/selection.svelte.js +7 -11
  305. package/dist/session/bindings.js +1 -1
  306. package/dist/session/commands.d.ts +7 -11
  307. package/dist/session/commands.js +13 -19
  308. package/dist/session/inputRules.js +1 -1
  309. package/dist/session/navigation.js +1 -1
  310. package/dist/session/suggestions.svelte.d.ts +0 -11
  311. package/dist/session/suggestions.svelte.js +15 -3
  312. package/dist/session/uploads.d.ts +8 -8
  313. package/dist/surface/lines.js +1 -3
  314. package/dist/surface/observer.svelte.d.ts +17 -1
  315. package/dist/surface/observer.svelte.js +74 -19
  316. package/dist/surface/overlay.d.ts +0 -14
  317. package/dist/surface/overlay.js +0 -25
  318. package/dist/surface/projector.svelte.d.ts +15 -3
  319. package/dist/surface/projector.svelte.js +60 -9
  320. package/dist/text/text.svelte.js +3 -13
  321. package/dist/utils/sanitize.d.ts +38 -0
  322. package/dist/utils/sanitize.js +82 -0
  323. package/dist/utils.d.ts +2 -0
  324. package/dist/utils.js +5 -0
  325. package/package.json +19 -2
  326. package/dist/crdt/placement/rank.d.ts +0 -87
  327. package/dist/crdt/placement/rank.js +0 -332
  328. package/dist/crdt/placement/source.d.ts +0 -43
  329. package/dist/crdt/placement/source.js +0 -66
  330. package/dist/crdt/text/delete-index.d.ts +0 -129
  331. package/dist/crdt/text/delete-index.js +0 -365
  332. package/dist/crdt/text/deletes.d.ts +0 -76
  333. package/dist/crdt/text/deletes.js +0 -362
  334. package/dist/crdt/text/index/anchored.d.ts +0 -17
  335. package/dist/crdt/text/index/anchored.js +0 -197
  336. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/max-z-index.js +0 -3
  337. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/supports-popover.js +0 -16
  338. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/is-axis-allowed.js +0 -3
  339. package/dist/plugins/code/LanguageMenu.svelte +0 -25
  340. package/dist/plugins/code/LanguageMenu.svelte.d.ts +0 -9
  341. package/dist/plugins/equation/EquationEditor.svelte +0 -27
  342. package/dist/plugins/equation/EquationEditor.svelte.d.ts +0 -9
  343. package/dist/plugins/image/ImageToolbarHost.svelte +0 -37
  344. package/dist/plugins/image/ImageToolbarHost.svelte.d.ts +0 -9
  345. package/dist/plugins/richtext/CalloutIconPicker.svelte +0 -26
  346. package/dist/plugins/richtext/CalloutIconPicker.svelte.d.ts +0 -9
@@ -1,4 +1,4 @@
1
- import { getOwnRowBottom, isBeside, nestIndent, ownRow, ownTextRow } from './geometry.js';
1
+ import { cssVar, getOwnRowBottom, isBeside, nestIndent, ownRow, ownTextRow } from './geometry.js';
2
2
  /** Notion's drop bar: 4px (its height in `BlockHandles.svelte`, its look the app's). */
3
3
  const BAR = 4;
4
4
  /** Place `element` at `box`, relative to the layer (`origin`). */
@@ -14,10 +14,7 @@ const place = (element, box, origin) => Object.assign(element.style, {
14
14
  * unset there without one.
15
15
  */
16
16
  const themed = (from, name) => {
17
- const value = from.ownerDocument.defaultView
18
- ?.getComputedStyle(from)
19
- .getPropertyValue(name)
20
- .trim();
17
+ const value = cssVar(from, name);
21
18
  return (element) => value ? element.style.setProperty(name, value) : element.style.removeProperty(name);
22
19
  };
23
20
  /**
@@ -0,0 +1,6 @@
1
+ import type { Scrollers } from './autoScroll.js';
2
+ export { dropTargetForExternal } from './vendor/pragmatic/pragmatic-drag-and-drop/adapter/drop-target-for-external.js';
3
+ export { containsFiles } from './vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/contains-files.js';
4
+ export { getFiles } from './vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/get-files.js';
5
+ /** The external adapter's auto-scroll, while `ours()` (the drag is over this editor). */
6
+ export declare const externalScrollers: (ours: () => boolean) => Scrollers;
@@ -0,0 +1,17 @@
1
+ // Pragmatic drag and drop's external adapter (vendored with the element
2
+ // adapter, on its core, `vendor/pragmatic/UPSTREAM.md`): drags that start
3
+ // outside the window (files from the desktop). Only the media plugins that
4
+ // take an upload import it (`plugins/fileDrop.ts`), so a view without them
5
+ // ships none of it.
6
+ import { autoScrollForExternal, autoScrollWindowForExternal } from './vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/external.js';
7
+ export { dropTargetForExternal } from './vendor/pragmatic/pragmatic-drag-and-drop/adapter/drop-target-for-external.js';
8
+ export { containsFiles } from './vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/contains-files.js';
9
+ export { getFiles } from './vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/get-files.js';
10
+ /** The external adapter's auto-scroll, while `ours()` (the drag is over this editor). */
11
+ export const externalScrollers = (ours) => {
12
+ const canScroll = () => ours();
13
+ return {
14
+ window: () => autoScrollWindowForExternal({ canScroll }),
15
+ element: (element) => autoScrollForExternal({ element, canScroll })
16
+ };
17
+ };
@@ -27,6 +27,8 @@ export declare const ownTextRow: (node: HTMLElement) => DOMRect;
27
27
  */
28
28
  export declare const NEST_INDENT = 24;
29
29
  export declare const nestIndent: (node: HTMLElement) => number;
30
+ /** The theme variable `name` as `node` inherits it, read now (none outside a window). */
31
+ export declare const cssVar: (node: HTMLElement, name: string) => string | undefined;
30
32
  /**
31
33
  * Whether `y` is over the hint of `node`'s empty body (`body.hint`, a kind's
32
34
  * `data-edytor-empty-body` element: an open toggle's, a callout's): a drop
@@ -31,12 +31,11 @@ export const ownTextRow = (node) => {
31
31
  */
32
32
  export const NEST_INDENT = 24;
33
33
  export const nestIndent = (node) => {
34
- const value = node.ownerDocument.defaultView
35
- ?.getComputedStyle(node)
36
- .getPropertyValue('--edytor-nest-indent')
37
- .trim();
34
+ const value = cssVar(node, '--edytor-nest-indent');
38
35
  return value?.endsWith('px') ? parseFloat(value) : NEST_INDENT;
39
36
  };
37
+ /** The theme variable `name` as `node` inherits it, read now (none outside a window). */
38
+ export const cssVar = (node, name) => node.ownerDocument.defaultView?.getComputedStyle(node).getPropertyValue(name).trim();
40
39
  /**
41
40
  * Whether `y` is over the hint of `node`'s empty body (`body.hint`, a kind's
42
41
  * `data-edytor-empty-body` element: an open toggle's, a callout's): a drop
@@ -5,7 +5,7 @@
5
5
  * (`Drag`: the blocks it moves, none for files) and the placements the
6
6
  * document takes for it (`fits`); the rows are the view's drop targets
7
7
  * (`targetOf`). The block handles wire it to the drag library; a file drag
8
- * reads it from the host's own `dragover` (the media plugins' `plugins/fileDrop.ts`).
8
+ * reads it from Pragmatic's external adapter (the media plugins' `plugins/fileDrop.ts`).
9
9
  */
10
10
  import type { Block } from '../block/block.svelte.js';
11
11
  import type { Edytor } from '../edytor.svelte.js';
@@ -1,4 +1,6 @@
1
+ import type { Scrollers } from './autoScroll.js';
1
2
  export { draggable, dropTargetForElements } from './vendor/pragmatic/pragmatic-drag-and-drop/entry-point/element/adapter.js';
2
3
  export type { ElementDropTargetEventPayloadMap } from './vendor/pragmatic/pragmatic-drag-and-drop/entry-point/element/adapter.js';
3
4
  export { setCustomNativeDragPreview } from './vendor/pragmatic/pragmatic-drag-and-drop/entry-point/element/set-custom-native-drag-preview.js';
4
- export { autoScrollForElements as autoScroll, autoScrollWindowForElements as autoScrollWindow } from './vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/element.js';
5
+ /** The element adapter's auto-scroll, for the drags whose data `ours` says are this editor's. */
6
+ export declare const elementScrollers: (ours: (data: Record<string | symbol, unknown>) => boolean) => Scrollers;
@@ -1,7 +1,17 @@
1
1
  // Atlassian's Pragmatic drag and drop, forked in `vendor/pragmatic` (its own
2
2
  // ES2019 build, `UPSTREAM.md`): the element adapter, the custom native drag
3
3
  // preview and the element auto-scroll, all on one core,
4
- // so the auto-scroll's monitor sees the drags this adapter starts.
4
+ // so the auto-scroll's monitor sees the drags this adapter starts. The
5
+ // external adapter (files dragged from outside) is `external.ts`'s, loaded
6
+ // only by the media plugins that take an upload.
7
+ import { autoScrollForElements, autoScrollWindowForElements } from './vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/element.js';
5
8
  export { draggable, dropTargetForElements } from './vendor/pragmatic/pragmatic-drag-and-drop/entry-point/element/adapter.js';
6
9
  export { setCustomNativeDragPreview } from './vendor/pragmatic/pragmatic-drag-and-drop/entry-point/element/set-custom-native-drag-preview.js';
7
- export { autoScrollForElements as autoScroll, autoScrollWindowForElements as autoScrollWindow } from './vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/element.js';
10
+ /** The element adapter's auto-scroll, for the drags whose data `ours` says are this editor's. */
11
+ export const elementScrollers = (ours) => {
12
+ const canScroll = ({ source }) => ours(source.data);
13
+ return {
14
+ window: () => autoScrollWindowForElements({ canScroll }),
15
+ element: (element) => autoScrollForElements({ element, canScroll })
16
+ };
17
+ };
@@ -2,9 +2,10 @@
2
2
 
3
3
  Atlassian's Pragmatic drag and drop, forked inside edytor: only the modules
4
4
  edytor reaches, as the packages publish them, so the block handles' and the
5
- table grips' drags run the library's own logic without depending on its
6
- packages. `src/lib/dnd/pragmatic.ts` is the one importer; nothing else in
7
- edytor imports from this directory. Do not edit these files by hand: re-sync
5
+ table grips' drags, and files dragged from outside, run the library's own logic without depending on its
6
+ packages. `src/lib/dnd/pragmatic.ts` (the element adapter) and `src/lib/dnd/external.ts`
7
+ (the external adapter, imported only by the media plugins that take an
8
+ upload) are the importers; nothing else in edytor imports from this directory. Do not edit these files by hand: re-sync
8
9
  (below) and record every change here.
9
10
 
10
11
  ## Pinned source
@@ -34,8 +35,8 @@ against `dist/es2019/<same path>` (or `dist/types/<same path>` for a `.d.ts`).
34
35
 
35
36
  ## What was kept
36
37
 
37
- The module closure of the three entry points `pragmatic.ts` imports, nothing
38
- else:
38
+ The module closure of the entry points `pragmatic.ts` and `external.ts`
39
+ import, nothing else:
39
40
 
40
41
  - core `entry-point/element/adapter` (`draggable`, `dropTargetForElements`,
41
42
  `monitorForElements`): the element adapter, the drag lifecycle, drop targets
@@ -43,12 +44,20 @@ else:
43
44
  detection;
44
45
  - core `entry-point/element/set-custom-native-drag-preview`;
45
46
  - auto-scroll `entry-point/element` (`autoScrollForElements`,
46
- `autoScrollWindowForElements`, the over-element API and its scheduler).
47
+ `autoScrollWindowForElements`, the over-element API and its scheduler);
48
+ - core `adapter/drop-target-for-external` (`dropTargetForExternal`: the
49
+ external adapter, its drag of what enters the window, the window-entering
50
+ detection, the available types and items) and `adapter/monitor-for-external`
51
+ (the auto-scroll's monitor), `public-utils/external/contains-files` and
52
+ `get-files` (`containsFiles`, `getFiles`): files dragged from outside;
53
+ - auto-scroll `entry-point/external` (`autoScrollForExternal`,
54
+ `autoScrollWindowForExternal`), on the same over-element API.
47
55
 
48
56
  The `.d.ts` files are the declarations those entry points' types reach (9
49
- files); a `.js` without one is reached only from other vendored `.js`.
50
- Everything else the packages publish (the external and text-selection
51
- adapters, the other utilities, the hitbox package (the block handles split a
57
+ files for the element entries, 8 for the external ones); a `.js` without one is reached only from other vendored `.js`.
58
+ Everything else the packages publish (the text-selection adapter, the
59
+ external adapter's text, HTML and URL getters (edytor reads only files from
60
+ an external drag; text and HTML drops stay the core's `events/onDrop.ts`), the other utilities, the hitbox package (the block handles split a
52
61
  row into its halves themselves), the unsafe-overflow auto-scroll, CommonJS and `dist/esm` builds) is left out.
53
62
 
54
63
  ## Local changes (the only ones)
@@ -57,7 +66,7 @@ row into its halves themselves), the unsafe-overflow auto-scroll, CommonJS and `
57
66
  (`'./once'` → `'./once.js'`, a directory import its `/index.js`), so the
58
67
  packaged `dist/` loads in Node as ES modules too. Every bare specifier
59
68
  between the packages (`@atlaskit/pragmatic-drag-and-drop/adapter/element-adapter`,
60
- `…/utils/combine`, `…/utils/once`, `…/get-element-from-point-without-honey-pot`,
69
+ `…/adapter/monitor-for-external`, `…/utils/combine`, `…/utils/once`, `…/get-element-from-point-without-honey-pot`,
61
70
  `…/types` in the declarations) and to the two dependencies
62
71
  (`bind-event-listener`, `raf-schd`) becomes the relative path of the
63
72
  vendored file. This binds the auto-scroll package to the same core as the
@@ -71,9 +80,31 @@ row into its halves themselves), the unsafe-overflow auto-scroll, CommonJS and `
71
80
  type annotations removed (the code, comments and names unchanged). Its
72
81
  types are not needed: no vendored declaration names them.
73
82
 
74
- No statement of the libraries' own code is changed. A check that a re-sync
75
- reproduces this: strip every import specifier from each vendored file and from
76
- its upstream file, and compare: they are equal.
83
+ 3. **Options edytor never passes, removed** (each site marked `// edytor:`):
84
+ the auto-scroll's `getConfiguration` (its speed is the standard one, a
85
+ constant `internalConfig`) and `getAllowedAxis` (both axes always:
86
+ `shared/is-axis-allowed.js` is gone), and its distance dampening always on
87
+ (`get-scroll-by.js` reads its two axes through one `change`); a
88
+ `draggable`'s `dragHandle`, a drop target's `getDropEffect` and
89
+ `onDropTargetChange`, a monitor's `canMonitor`, and the native drag
90
+ preview's default `getOffset` (both callers give theirs). Their
91
+ declarations go too, so a caller passing one does not compile. And no
92
+ fallback for an engine without the Popover API (every supported engine
93
+ has it: `util/supports-popover.js` and `util/max-z-index.js` are gone);
94
+ the jsdom lanes stub `showPopover`.
95
+
96
+ 4. **An external drag's items show their `kind` and `type` while dragging**
97
+ (`adapter/external-adapter.js`, marked `// edytor:`): upstream locks
98
+ `items: []` until the drop; edytor snapshots each `DataTransferItem`'s
99
+ `kind` and `type` at the `dragenter` (what browsers expose then; the
100
+ live list empties after the event), with `getAsFile()` answering `null`.
101
+ The drop's payload is upstream's (the real items). The file drop reads it
102
+ to show the line only where the dragged files would land.
103
+
104
+ No other statement of the libraries' own code is changed. A check that a
105
+ re-sync reproduces this: strip every import specifier from each vendored file
106
+ and from its upstream file, and compare: they are equal but for the sites of
107
+ changes 3 and 4.
77
108
 
78
109
  ## How edytor builds around it
79
110
 
@@ -83,7 +114,8 @@ its upstream file, and compare: they are equal.
83
114
  (`scripts/xloc.mjs`, `scripts/bundle-size.mjs`) skip it as vendored code.
84
115
  - `package.json#sideEffects` lists the core's directory: upstream declares the
85
116
  core with side effects (`count-events-for-safari.js` binds its WebKit
86
- listeners at import), the auto-scroll without.
117
+ listeners at import, `adapter/external-adapter.js` its window `dragenter`
118
+ and `dragstart` listeners), the auto-scroll without.
87
119
  - Nothing runs against the DOM at import (the core guards `typeof window`):
88
120
  server rendering imports it as before.
89
121
 
@@ -92,12 +124,13 @@ its upstream file, and compare: they are equal.
92
124
  1. Install the new versions of the two packages (and of `bind-event-listener`,
93
125
  `raf-schd`) somewhere outside the package's dependencies.
94
126
  2. From each package's `module:es2019` entry (`element/adapter`,
95
- `element/set-custom-native-drag-preview`, auto-scroll
96
- `element`), follow every import; copy each reached `dist/es2019` file and,
127
+ `element/set-custom-native-drag-preview`, `adapter/drop-target-for-external`,
128
+ `adapter/monitor-for-external`, `utils/contains-files`, `utils/get-files`,
129
+ auto-scroll `element` and `external`), follow every import; copy each reached `dist/es2019` file and,
97
130
  from each entry's `types` field, each reached `dist/types` declaration to
98
131
  the same path here, rewriting specifiers as in change 1.
99
- 3. Redo change 2 from `bind-event-listener`'s `src/`; copy
132
+ 3. Redo change 2 from `bind-event-listener`'s `src/`, and changes 3 and 4; copy
100
133
  `raf-schd/dist/raf-schd.esm.js`; copy the license files.
101
134
  4. Update the table above, run the drag lanes (the block handle, table, columns,
102
- drop reach, auto-scroll, drag preview and press-after-drag specs in
135
+ drop reach, auto-scroll, drag preview, press-after-drag and file drop specs in
103
136
  Chromium, Firefox and WebKit, the jsdom drag rows) and the packed consumer.
@@ -0,0 +1,4 @@
1
+ import { type CleanupFn } from '../internal-types.js';
2
+ import { adapter } from './external-adapter.js';
3
+ import type { StripEventsForDropTargets } from './external-adapter-types.js';
4
+ export declare function dropTargetForExternal(args: StripEventsForDropTargets<Parameters<typeof adapter.dropTarget>[0]>): CleanupFn;
@@ -0,0 +1,6 @@
1
+ import { adapter } from './external-adapter.js';
2
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
3
+ export function dropTargetForExternal(args) {
4
+ // not removing unused events, just leaning on the type system
5
+ return adapter.dropTarget(args);
6
+ }
@@ -21,8 +21,6 @@ type DraggableArgs = {
21
21
  * can have a "draggable" attribute
22
22
  */
23
23
  element: HTMLElement;
24
- /** The part of a draggable `element` that you want to use to control the dragging of the whole `element` */
25
- dragHandle?: Element;
26
24
  /** Conditionally allow a drag to occur */
27
25
  canDrag?: (args: DraggableGetFeedbackArgs) => boolean;
28
26
  /** Used to attach data to a drag operation. Called once just before the drag starts */
@@ -1,5 +1,4 @@
1
1
  import { bind } from '../../bind-event-listener/index.js';
2
- import { getElementFromPointWithoutHoneypot } from '../honey-pot-fix/get-element-from-point-without-honey-pot.js';
3
2
  import { makeHoneyPotFix } from '../honey-pot-fix/make-honey-pot-fix.js';
4
3
  import { makeAdapter } from '../make-adapter/make-adapter.js';
5
4
  import { combine } from '../public-utils/combine.js';
@@ -34,7 +33,7 @@ const adapter = makeAdapter({
34
33
  return combine(honeyPotFix.bindEvents(), bind(document, {
35
34
  type: 'dragstart',
36
35
  listener(event) {
37
- var _entry$dragHandle, _entry$getInitialData, _entry$getInitialData2, _entry$dragHandle2, _entry$getInitialData3, _entry$getInitialData4;
36
+ var _entry$getInitialData, _entry$getInitialData2, _entry$getInitialData3, _entry$getInitialData4;
38
37
  if (!api.canStart(event)) {
39
38
  return;
40
39
  }
@@ -123,7 +122,8 @@ const adapter = makeAdapter({
123
122
  const input = getInput(event);
124
123
  const feedback = {
125
124
  element: entry.element,
126
- dragHandle: (_entry$dragHandle = entry.dragHandle) !== null && _entry$dragHandle !== void 0 ? _entry$dragHandle : null,
125
+ // edytor: no draggable sets `dragHandle`.
126
+ dragHandle: null,
127
127
  input
128
128
  };
129
129
 
@@ -134,24 +134,6 @@ const adapter = makeAdapter({
134
134
  return;
135
135
  }
136
136
 
137
- // Check: is there a drag handle and is the user using it?
138
- if (entry.dragHandle) {
139
- // technically don't need this util, but just being
140
- // consistent with how we look up what is under the users
141
- // cursor.
142
- const over = getElementFromPointWithoutHoneypot({
143
- x: input.clientX,
144
- y: input.clientY
145
- });
146
-
147
- // if we are not dragging from the drag handle (or something inside the drag handle)
148
- // then we will cancel the active drag
149
- if (!entry.dragHandle.contains(over)) {
150
- event.preventDefault();
151
- return;
152
- }
153
- }
154
-
155
137
  /**
156
138
  * **Goal**
157
139
  * Pass information to other applications
@@ -215,7 +197,7 @@ const adapter = makeAdapter({
215
197
  event.dataTransfer.setData(elementAdapterNativeDataKey, '');
216
198
  const payload = {
217
199
  element: entry.element,
218
- dragHandle: (_entry$dragHandle2 = entry.dragHandle) !== null && _entry$dragHandle2 !== void 0 ? _entry$dragHandle2 : null,
200
+ dragHandle: null,
219
201
  data: (_entry$getInitialData3 = (_entry$getInitialData4 = entry.getInitialData) === null || _entry$getInitialData4 === void 0 ? void 0 : _entry$getInitialData4.call(entry, feedback)) !== null && _entry$getInitialData3 !== void 0 ? _entry$getInitialData3 : {}
220
202
  };
221
203
  const dragType = {
@@ -0,0 +1,26 @@
1
+ import { type BaseEventPayload, type DropTargetEventBasePayload, type DropTargetEventPayloadMap, type DropTargetGetFeedbackArgs, type EventPayloadMap, type ExternalDragType, type MonitorGetFeedbackArgs } from '../internal-types.js';
2
+ export type { NativeMediaType, ExternalDragPayload } from '../internal-types.js';
3
+ export /**
4
+ * Some events don't make sense for the external adapter
5
+ *
6
+ * `onGenerateDragPreview`
7
+ * The browser creates the drag preview for external drags, so we don't
8
+ * need an event to generate the preview for _monitors_ or the _dropTarget_
9
+ *
10
+ * `onDragStart`
11
+ * An external drag can never start from in the `window`, so _dropTarget_'s
12
+ * don't need `onDragStart`
13
+ */ type StripEventsForDropTargets<T> = Omit<T, 'onGenerateDragPreview' | 'onDragStart'>;
14
+ export type StripEventsForMonitors<T> = Omit<T, 'onGenerateDragPreview'>;
15
+ /** Common event payload for all events */
16
+ export type ExternalEventBasePayload = BaseEventPayload<ExternalDragType>;
17
+ /** A map containing payloads for all events */
18
+ export type ExternalEventPayloadMap = StripEventsForMonitors<EventPayloadMap<ExternalDragType>>;
19
+ /** Common event payload for all drop target events */
20
+ export type ExternalDropTargetEventBasePayload = DropTargetEventBasePayload<ExternalDragType>;
21
+ /** A map containing payloads for all events on drop targets */
22
+ export type ExternalDropTargetEventPayloadMap = StripEventsForDropTargets<DropTargetEventPayloadMap<ExternalDragType>>;
23
+ /** Arguments given to all feedback functions (eg `canDrop()`) on a `dropTargetForExternal` */
24
+ export type ExternalDropTargetGetFeedbackArgs = DropTargetGetFeedbackArgs<ExternalDragType>;
25
+ /** Arguments given to all monitor feedback functions (eg `canMonitor()`) for a `monitorForExternal` */
26
+ export type ExternalMonitorGetFeedbackArgs = MonitorGetFeedbackArgs<ExternalDragType>;
@@ -0,0 +1,30 @@
1
+ import { type BaseEventPayload, type CleanupFn, type DropTargetArgs, type DropTargetEventBasePayload, type DropTargetEventPayloadMap, type DropTargetGetFeedbackArgs, type EventPayloadMap, type ExternalDragType, type MonitorArgs, type MonitorGetFeedbackArgs } from '../internal-types.js';
2
+ export declare const adapter: {
3
+ registerUsage: () => CleanupFn;
4
+ dropTarget: (args: DropTargetArgs<ExternalDragType>) => CleanupFn;
5
+ monitor: (args: MonitorArgs<ExternalDragType>) => CleanupFn;
6
+ };
7
+ export /**
8
+ * Some events don't make sense for the external adapter
9
+ *
10
+ * `onGenerateDragPreview`
11
+ * The browser creates the drag preview for external drags, so we don't
12
+ * need an event to generate the preview for _monitors_ or the _dropTarget_
13
+ *
14
+ * `onDragStart`
15
+ * An external drag can never start from in the `window`, so _dropTarget_'s
16
+ * don't need `onDragStart`
17
+ */ type StripEventsForDropTargets<T> = Omit<T, 'onGenerateDragPreview' | 'onDragStart'>;
18
+ export type StripEventsForMonitors<T> = Omit<T, 'onGenerateDragPreview'>;
19
+ /** Common event payload for all events */
20
+ export type ExternalEventBasePayload = BaseEventPayload<ExternalDragType>;
21
+ /** A map containing payloads for all events */
22
+ export type ExternalEventPayloadMap = StripEventsForMonitors<EventPayloadMap<ExternalDragType>>;
23
+ /** Common event payload for all drop target events */
24
+ export type ExternalDropTargetEventBasePayload = DropTargetEventBasePayload<ExternalDragType>;
25
+ /** A map containing payloads for all events on drop targets */
26
+ export type ExternalDropTargetEventPayloadMap = StripEventsForDropTargets<DropTargetEventPayloadMap<ExternalDragType>>;
27
+ /** Arguments given to all feedback functions (eg `canDrop()`) on a `dropTargetForExternal` */
28
+ export type ExternalDropTargetGetFeedbackArgs = DropTargetGetFeedbackArgs<ExternalDragType>;
29
+ /** Arguments given to all monitor feedback functions (eg `canMonitor()`) for a `monitorForExternal` */
30
+ export type ExternalMonitorGetFeedbackArgs = MonitorGetFeedbackArgs<ExternalDragType>;
@@ -0,0 +1,203 @@
1
+ import { bind, bindAll } from '../../bind-event-listener/index.js';
2
+ import { makeAdapter } from '../make-adapter/make-adapter.js';
3
+ import { isEnteringWindow } from '../util/changing-window/is-entering-window.js';
4
+ import { getBindingsForBrokenDrags } from '../util/detect-broken-drag.js';
5
+ import { getAvailableItems } from './get-available-items.js';
6
+ import { getAvailableTypes } from './get-available-types.js';
7
+ import { isAnAvailableType } from './is-an-available-type.js';
8
+ let didDragStartLocally = false;
9
+ export const adapter = makeAdapter({
10
+ typeKey: 'external',
11
+ // for external drags, we are generally making a copy of something that is being dragged
12
+ defaultDropEffect: 'copy',
13
+ mount(api) {
14
+ // Binding to the `window` so that the element adapter
15
+ // has a chance to get in first on the`document`.
16
+ // We are giving preference to the element adapter.
17
+ return bind(window, {
18
+ type: 'dragenter',
19
+ listener(event) {
20
+ // drag operation was started within the document, it won't be an "external" drag
21
+ if (didDragStartLocally) {
22
+ return;
23
+ }
24
+
25
+ // Note: not checking if event was cancelled (`event.defaultPrevented`) as
26
+ // cancelling a "dragenter" accepts the drag operation (not prevent it)
27
+
28
+ // Something has gone wrong with our drag event
29
+ if (!event.dataTransfer) {
30
+ // Including this code on "test" and "development" environments:
31
+ // - Browser tests commonly run against "development" builds
32
+ // - Unit tests commonly run in "test"
33
+ if (process.env.NODE_ENV !== 'production') {
34
+ // eslint-disable-next-line no-console
35
+ console.warn(`
36
+ It appears as though you have are not testing DragEvents correctly.
37
+
38
+ - If you are unit testing, ensure you have polyfilled DragEvent.
39
+ - If you are browser testing, ensure you are dispatching drag events correctly.
40
+
41
+ Please see our testing guides for more information:
42
+ https://atlassian.design/components/pragmatic-drag-and-drop/core-package/testing
43
+ `.replace(/ {2}/g, ''));
44
+ }
45
+ return;
46
+ }
47
+ if (!api.canStart(event)) {
48
+ return;
49
+ }
50
+ if (!isEnteringWindow({
51
+ dragEnter: event
52
+ })) {
53
+ return;
54
+ }
55
+
56
+ // Note: not checking types for `elementAdapterNativeDataKey` as we expect to see that
57
+ // key when pdnd started the drag in another document
58
+ const types = getAvailableTypes(event.dataTransfer);
59
+ if (!types.length) {
60
+ return;
61
+ }
62
+ const locked = {
63
+ types,
64
+ // edytor: the items' `kind` and `type` as the browser shows them while
65
+ // dragging (no data: `getAsFile()` is `null` until the drop), snapshotted
66
+ // since the live list empties once the event is dispatched.
67
+ items: Array.from(event.dataTransfer.items ?? [], ({
68
+ kind,
69
+ type
70
+ }) => ({
71
+ kind,
72
+ type,
73
+ getAsFile: () => null,
74
+ getAsString: () => {}
75
+ })),
76
+ getStringData: () => null
77
+ };
78
+ api.start({
79
+ event,
80
+ dragType: {
81
+ type: 'external',
82
+ startedFrom: 'external',
83
+ payload: locked,
84
+ getDropPayload(event) {
85
+ // this would be a platform error
86
+ // trying to handle it gracefully rather than throwing (for now)
87
+ if (!event.dataTransfer) {
88
+ return locked;
89
+ }
90
+ const items = getAvailableItems(event.dataTransfer);
91
+ // need to use `.bind` as `getData` is required
92
+ // to be run with `event.dataTransfer` as the "this" context
93
+ const nativeGetData = event.dataTransfer.getData.bind(event.dataTransfer);
94
+ return {
95
+ types,
96
+ items,
97
+ // return `null` if there is no result, otherwise string
98
+ getStringData(mediaType) {
99
+ // not dragging the requested type
100
+ // return `null` (no result)
101
+ if (!types.includes(mediaType)) {
102
+ return null;
103
+ }
104
+
105
+ // nativeGetData will return `""` when there is no value,
106
+ // but at this point we know we will only get explicitly set
107
+ // values back as we have checked the `types`.
108
+ // `""` can be an explicitly set value.
109
+ const value = nativeGetData(mediaType);
110
+
111
+ // not exposing data for unavailable types
112
+ if (!isAnAvailableType({
113
+ type: mediaType,
114
+ value
115
+ })) {
116
+ return null;
117
+ }
118
+ return value;
119
+ }
120
+ };
121
+ }
122
+ }
123
+ });
124
+ }
125
+ });
126
+ }
127
+ });
128
+
129
+ /** Common event payload for all events */
130
+
131
+ /** A map containing payloads for all events */
132
+
133
+ /** Common event payload for all drop target events */
134
+
135
+ /** A map containing payloads for all events on drop targets */
136
+
137
+ /** Arguments given to all feedback functions (eg `canDrop()`) on a `dropTargetForExternal` */
138
+
139
+ /** Arguments given to all monitor feedback functions (eg `canMonitor()`) for a `monitorForExternal` */
140
+
141
+ (function startup() {
142
+ // server side rendering check
143
+ if (typeof window === 'undefined') {
144
+ return;
145
+ }
146
+
147
+ // A shared single usage registration as we want to capture
148
+ // all external drag operations, even if there are no drop targets
149
+ // on the page yet
150
+ adapter.registerUsage();
151
+ // independent of pdnd, we need to keep track of
152
+ // all drag operations so that we can know if a drag operation
153
+ // has started locally
154
+
155
+ const idle = {
156
+ type: 'idle'
157
+ };
158
+ let state = idle;
159
+ function clear() {
160
+ if (state.type !== 'dragging') {
161
+ return;
162
+ }
163
+ didDragStartLocally = false;
164
+ state.cleanup();
165
+ state = idle;
166
+ }
167
+ function bindEndEvents() {
168
+ return bindAll(window, [{
169
+ type: 'dragend',
170
+ listener: clear
171
+ }, ...getBindingsForBrokenDrags({
172
+ onDragEnd: clear
173
+ })],
174
+ // we want to make sure we get all the events,
175
+ // and this helps avoid not seeing events when folks stop
176
+ // them later on the event path
177
+ {
178
+ capture: true
179
+ });
180
+ }
181
+
182
+ // we always keep this event listener active
183
+ bind(window, {
184
+ type: 'dragstart',
185
+ listener() {
186
+ // something bad has happened if this is true!
187
+ if (state.type !== 'idle') {
188
+ return;
189
+ }
190
+ // set our global flag
191
+ didDragStartLocally = true;
192
+ state = {
193
+ type: 'dragging',
194
+ cleanup: bindEndEvents()
195
+ };
196
+ },
197
+ // binding in the capture phase so these listeners are called
198
+ // before our listeners in the adapters `mount` function
199
+ options: {
200
+ capture: true
201
+ }
202
+ });
203
+ })();
@@ -0,0 +1,13 @@
1
+ import { isAnAvailableType } from './is-an-available-type.js';
2
+
3
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
4
+ export function getAvailableItems(dataTransfer) {
5
+ // item.kind is 'string' | 'file'
6
+ // For 'string' item.type is the mimeType (eg 'text/plain')
7
+ // For 'file' item.type is the file type (eg 'image/jpg')
8
+
9
+ return Array.from(dataTransfer.items).filter(item => item.kind === 'file' || isAnAvailableType({
10
+ type: item.type,
11
+ value: dataTransfer.getData(item.type)
12
+ }));
13
+ }
@@ -0,0 +1,9 @@
1
+ import { isAnAvailableType } from './is-an-available-type.js';
2
+
3
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
4
+ export function getAvailableTypes(transfer) {
5
+ return Array.from(transfer.types).filter(type => isAnAvailableType({
6
+ type,
7
+ value: transfer.getData(type)
8
+ }));
9
+ }
@@ -0,0 +1,19 @@
1
+ import { androidFallbackText } from '../util/android.js';
2
+ import { textMediaType } from '../util/media-types/text-media-type.js';
3
+ import { elementAdapterNativeDataKey } from './element-adapter-native-data-key.js';
4
+ export function isAnAvailableType({
5
+ type,
6
+ value
7
+ }) {
8
+ // We don't want to expose our private elementAdapter key / value
9
+ if (type === elementAdapterNativeDataKey) {
10
+ return false;
11
+ }
12
+ // Not exposing "text/plain" if it contains the android fallback text
13
+ // We _could_ add an `isAndroid()` check, but it's probably safest
14
+ // to trim this data out, regardless of what OS we see it on.
15
+ if (type === textMediaType && value === androidFallbackText) {
16
+ return false;
17
+ }
18
+ return true;
19
+ }
@@ -0,0 +1,4 @@
1
+ import { type CleanupFn } from '../internal-types.js';
2
+ import { adapter } from './external-adapter.js';
3
+ import type { StripEventsForMonitors } from './external-adapter-types.js';
4
+ export declare function monitorForExternal(args: StripEventsForMonitors<Parameters<typeof adapter.monitor>[0]>): CleanupFn;
@@ -0,0 +1,6 @@
1
+ import { adapter } from './external-adapter.js';
2
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
3
+ export function monitorForExternal(args) {
4
+ // not removing unused events, just leaning on the type system
5
+ return adapter.monitor(args);
6
+ }