edytor 2.0.0 → 3.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 (222) 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/room/admission.js +3 -3
  10. package/dist/cloudflare/room/context.d.ts +1 -1
  11. package/dist/cloudflare/routeDocumentSocket.d.ts +17 -0
  12. package/dist/cloudflare/routeDocumentSocket.js +53 -0
  13. package/dist/collaboration/comments/client.d.ts +1 -1
  14. package/dist/collaboration/comments/client.js +1 -1
  15. package/dist/collaboration/remoteSelection.js +3 -3
  16. package/dist/components/Edytor.svelte +2 -10
  17. package/dist/components/Edytor.svelte.d.ts +1 -3
  18. package/dist/crdt/admission.d.ts +5 -10
  19. package/dist/crdt/admission.js +5 -11
  20. package/dist/crdt/doc/funnel.d.ts +7 -6
  21. package/dist/crdt/doc/funnel.js +10 -9
  22. package/dist/crdt/doc/gate.d.ts +0 -17
  23. package/dist/crdt/doc/gate.js +2 -41
  24. package/dist/crdt/doc/history.js +2 -2
  25. package/dist/crdt/document.d.ts +5 -14
  26. package/dist/crdt/document.js +5 -19
  27. package/dist/crdt/edytor-doc.d.ts +4 -4
  28. package/dist/crdt/edytor-doc.js +3 -7
  29. package/dist/crdt/index.d.ts +3 -3
  30. package/dist/crdt/index.js +2 -2
  31. package/dist/crdt/protocol.d.ts +2 -2
  32. package/dist/crdt/protocol.js +2 -2
  33. package/dist/crdt/providers/index.d.ts +1 -1
  34. package/dist/crdt/providers/room.d.ts +10 -9
  35. package/dist/crdt/providers/room.js +13 -10
  36. package/dist/crdt/providers/websocket.d.ts +1 -1
  37. package/dist/crdt/providers/websocket.js +28 -29
  38. package/dist/crdt/semantics.js +3 -1
  39. package/dist/dnd/autoScroll.d.ts +15 -7
  40. package/dist/dnd/autoScroll.js +10 -15
  41. package/dist/dnd/dropIndicator.js +2 -5
  42. package/dist/dnd/external.d.ts +6 -0
  43. package/dist/dnd/external.js +17 -0
  44. package/dist/dnd/geometry.d.ts +2 -0
  45. package/dist/dnd/geometry.js +3 -4
  46. package/dist/dnd/placement.d.ts +1 -1
  47. package/dist/dnd/pragmatic.d.ts +3 -1
  48. package/dist/dnd/pragmatic.js +12 -2
  49. package/dist/dnd/vendor/pragmatic/UPSTREAM.md +51 -18
  50. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/drop-target-for-external.d.ts +4 -0
  51. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/drop-target-for-external.js +6 -0
  52. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/element-adapter.d.ts +0 -2
  53. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/element-adapter.js +4 -22
  54. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter-types.d.ts +26 -0
  55. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter.d.ts +30 -0
  56. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter.js +203 -0
  57. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/get-available-items.js +13 -0
  58. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/get-available-types.js +9 -0
  59. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/is-an-available-type.js +19 -0
  60. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/monitor-for-external.d.ts +4 -0
  61. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/monitor-for-external.js +6 -0
  62. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/honey-pot-fix/make-honey-pot-fix.js +4 -16
  63. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/internal-types.d.ts +1 -8
  64. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/make-adapter/make-drop-target.js +5 -6
  65. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/make-adapter/make-monitor.js +2 -3
  66. 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
  67. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/element/custom-native-drag-preview/set-custom-native-drag-preview.js +6 -24
  68. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/contains-files.d.ts +2 -0
  69. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/contains-files.js +5 -0
  70. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/get-files.d.ts +3 -0
  71. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/get-files.js +12 -0
  72. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/native-types.d.ts +12 -0
  73. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/is-entering-window-in-safari.js +10 -0
  74. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/is-entering-window.js +55 -0
  75. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/external.d.ts +4 -0
  76. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/external.js +8 -0
  77. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/internal-types.d.ts +0 -4
  78. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/get-scroll-by.js +16 -72
  79. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/try-scroll.js +1 -9
  80. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/configuration.js +4 -29
  81. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/get-scroll-change.js +2 -3
  82. package/dist/edytor.svelte.d.ts +2 -5
  83. package/dist/edytor.svelte.js +17 -31
  84. package/dist/events/onBeforeInput.js +1 -1
  85. package/dist/events/onDrop.d.ts +0 -6
  86. package/dist/events/onDrop.js +10 -23
  87. package/dist/events/onInput.d.ts +0 -12
  88. package/dist/events/onInput.js +1 -67
  89. package/dist/export/forms.d.ts +627 -0
  90. package/dist/export/forms.js +749 -0
  91. package/dist/export/index.d.ts +170 -0
  92. package/dist/export/index.js +161 -0
  93. package/dist/export/markdown.d.ts +41 -0
  94. package/dist/export/markdown.js +585 -0
  95. package/dist/export/markdownWriter.d.ts +9 -0
  96. package/dist/export/markdownWriter.js +133 -0
  97. package/dist/export/mdx.d.ts +15 -0
  98. package/dist/export/mdx.js +33 -0
  99. package/dist/index.d.ts +3 -3
  100. package/dist/index.js +1 -1
  101. package/dist/kinds.js +1 -1
  102. package/dist/plugins/anchored.svelte.d.ts +21 -25
  103. package/dist/plugins/anchored.svelte.js +23 -39
  104. package/dist/plugins/blockHandles/BlockHandleController.svelte.js +24 -32
  105. package/dist/plugins/blockHandles/dragPreview.d.ts +26 -7
  106. package/dist/plugins/blockHandles/dragPreview.js +33 -0
  107. package/dist/plugins/blockMenu/BlockMenuController.svelte.d.ts +5 -0
  108. package/dist/plugins/blockMenu/BlockMenuController.svelte.js +7 -2
  109. package/dist/plugins/blockMenu/blockMenuPlugin.js +5 -50
  110. package/dist/plugins/chrome.d.ts +27 -5
  111. package/dist/plugins/chrome.js +24 -9
  112. package/dist/plugins/code/CodePlugin.svelte +12 -9
  113. package/dist/plugins/code/header.svelte.js +7 -11
  114. package/dist/plugins/code/languageMenu.svelte.d.ts +5 -2
  115. package/dist/plugins/code/languageMenu.svelte.js +13 -20
  116. package/dist/plugins/columns/ColumnsPlugin.svelte +7 -20
  117. package/dist/plugins/columns/resize.svelte.d.ts +2 -3
  118. package/dist/plugins/columns/resize.svelte.js +2 -5
  119. package/dist/plugins/comments/CommentsController.svelte.d.ts +6 -0
  120. package/dist/plugins/comments/CommentsController.svelte.js +20 -0
  121. package/dist/plugins/equation/EquationPlugin.svelte +12 -22
  122. package/dist/plugins/equation/equation.svelte.d.ts +7 -15
  123. package/dist/plugins/equation/equation.svelte.js +13 -50
  124. package/dist/plugins/equation/tex.d.ts +17 -0
  125. package/dist/plugins/equation/tex.js +42 -0
  126. package/dist/plugins/fileDrop.d.ts +38 -23
  127. package/dist/plugins/fileDrop.js +82 -76
  128. package/dist/plugins/find/FindController.svelte.d.ts +5 -0
  129. package/dist/plugins/find/FindController.svelte.js +14 -14
  130. package/dist/plugins/find/findPlugin.js +1 -15
  131. package/dist/plugins/image/ImageChrome.svelte +8 -2
  132. package/dist/plugins/image/ImagePlugin.svelte +15 -52
  133. package/dist/plugins/image/controls.svelte.js +16 -2
  134. package/dist/plugins/image/toolbar.svelte.d.ts +5 -4
  135. package/dist/plugins/image/toolbar.svelte.js +21 -31
  136. package/dist/plugins/index.d.ts +1 -1
  137. package/dist/plugins/list.svelte.d.ts +9 -0
  138. package/dist/plugins/list.svelte.js +18 -0
  139. package/dist/plugins/marquee/marqueePlugin.js +0 -4
  140. package/dist/plugins/media/AudioPlugin.svelte +1 -1
  141. package/dist/plugins/media/BookmarkPlugin.svelte +6 -97
  142. package/dist/plugins/media/EmbedPlugin.svelte +5 -90
  143. package/dist/plugins/media/EmptySlot.svelte +36 -20
  144. package/dist/plugins/media/EmptySlot.svelte.d.ts +6 -15
  145. package/dist/plugins/media/FilePlugin.svelte +1 -19
  146. package/dist/plugins/media/MediaEmpty.svelte +2 -55
  147. package/dist/plugins/media/MediaEmpty.svelte.d.ts +18 -14
  148. package/dist/plugins/media/SourceBlock.svelte +142 -52
  149. package/dist/plugins/media/SourceBlock.svelte.d.ts +10 -4
  150. package/dist/plugins/media/VideoPlugin.svelte +1 -1
  151. package/dist/plugins/media/empty.svelte.js +2 -7
  152. package/dist/plugins/media/media.d.ts +2 -63
  153. package/dist/plugins/media/media.js +1 -194
  154. package/dist/plugins/media/sources.d.ts +60 -0
  155. package/dist/plugins/media/sources.js +165 -0
  156. package/dist/plugins/media/urlPaste.svelte.d.ts +2 -1
  157. package/dist/plugins/media/urlPaste.svelte.js +12 -21
  158. package/dist/plugins/mention/MentionPlugin.svelte +8 -35
  159. package/dist/plugins/page/PagePlugin.svelte +2 -9
  160. package/dist/plugins/page/page.js +1 -1
  161. package/dist/plugins/pageLink/PageLinkPlugin.svelte +6 -13
  162. package/dist/plugins/richtext/RichTextPlugin.svelte +85 -197
  163. package/dist/plugins/richtext/body.js +1 -1
  164. package/dist/plugins/richtext/calloutIcons.svelte.d.ts +2 -2
  165. package/dist/plugins/richtext/calloutIcons.svelte.js +5 -7
  166. package/dist/plugins/richtext/richTextOperations.d.ts +1 -19
  167. package/dist/plugins/richtext/richTextOperations.js +3 -49
  168. package/dist/plugins/slashMenu/SlashMenuController.svelte.d.ts +2 -0
  169. package/dist/plugins/slashMenu/SlashMenuController.svelte.js +7 -0
  170. package/dist/plugins/slashMenu/slashMenuPlugin.js +5 -14
  171. package/dist/plugins/table/TableChrome.svelte +2 -3
  172. package/dist/plugins/table/TablePlugin.svelte +20 -54
  173. package/dist/plugins/table/chrome.svelte.d.ts +5 -2
  174. package/dist/plugins/table/chrome.svelte.js +30 -54
  175. package/dist/plugins/table/table.js +3 -3
  176. package/dist/plugins/toc/TocPlugin.svelte +2 -4
  177. package/dist/plugins/toolbar/ToolbarController.svelte.d.ts +7 -0
  178. package/dist/plugins/toolbar/ToolbarController.svelte.js +20 -13
  179. package/dist/plugins/toolbar/toolbarPlugin.js +19 -53
  180. package/dist/plugins/triggers/TriggerController.svelte.d.ts +7 -2
  181. package/dist/plugins/triggers/TriggerController.svelte.js +11 -4
  182. package/dist/plugins/triggers/place.js +1 -2
  183. package/dist/plugins/triggers/triggers.d.ts +6 -1
  184. package/dist/plugins/triggers/triggers.js +12 -13
  185. package/dist/plugins/uploads.svelte.d.ts +5 -2
  186. package/dist/plugins/uploads.svelte.js +25 -15
  187. package/dist/plugins.d.ts +26 -0
  188. package/dist/plugins.js +0 -24
  189. package/dist/selection/replaceSelection.js +2 -2
  190. package/dist/selection/selection.svelte.d.ts +4 -10
  191. package/dist/selection/selection.svelte.js +7 -11
  192. package/dist/session/bindings.js +1 -1
  193. package/dist/session/commands.d.ts +7 -11
  194. package/dist/session/commands.js +13 -19
  195. package/dist/session/inputRules.js +1 -1
  196. package/dist/session/navigation.js +1 -1
  197. package/dist/session/suggestions.svelte.d.ts +0 -11
  198. package/dist/session/suggestions.svelte.js +15 -3
  199. package/dist/session/uploads.d.ts +8 -8
  200. package/dist/surface/lines.js +1 -3
  201. package/dist/surface/observer.svelte.d.ts +17 -1
  202. package/dist/surface/observer.svelte.js +72 -17
  203. package/dist/surface/overlay.d.ts +0 -14
  204. package/dist/surface/overlay.js +0 -25
  205. package/dist/surface/projector.svelte.js +1 -1
  206. package/dist/text/text.svelte.js +3 -13
  207. package/dist/utils/sanitize.d.ts +38 -0
  208. package/dist/utils/sanitize.js +82 -0
  209. package/dist/utils.d.ts +2 -0
  210. package/dist/utils.js +5 -0
  211. package/package.json +18 -1
  212. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/max-z-index.js +0 -3
  213. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/supports-popover.js +0 -16
  214. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/is-axis-allowed.js +0 -3
  215. package/dist/plugins/code/LanguageMenu.svelte +0 -25
  216. package/dist/plugins/code/LanguageMenu.svelte.d.ts +0 -9
  217. package/dist/plugins/equation/EquationEditor.svelte +0 -27
  218. package/dist/plugins/equation/EquationEditor.svelte.d.ts +0 -9
  219. package/dist/plugins/image/ImageToolbarHost.svelte +0 -37
  220. package/dist/plugins/image/ImageToolbarHost.svelte.d.ts +0 -9
  221. package/dist/plugins/richtext/CalloutIconPicker.svelte +0 -26
  222. package/dist/plugins/richtext/CalloutIconPicker.svelte.d.ts +0 -9
@@ -142,16 +142,16 @@ export const bindWebsocketProvider = (Y) => {
142
142
  provider.synced = true;
143
143
  }
144
144
  });
145
- // A room's comment threads (`watchComments`): the listeners of each room,
146
- // by `<serverUrl>/<room>`, and the providers dialing it. A provider asks
147
- // the room for them (a subscribe) at every open while a room has a
148
- // listener, and hands each message the room sends to every listener.
149
- const commentListeners = new Map();
150
- const providersOf = new Map();
145
+ const watchers = new Set();
146
+ const providers = new Set();
151
147
  const subscribeFrame = (on) => frame(messageComments, (e) => writeCommentsSubscribe(e, on));
148
+ const hears = (watcher, provider) => watcher.room === provider.roomname &&
149
+ (watcher.channel === null || watcher.channel === provider.bcChannel);
150
+ const listenersOf = (provider) => [...watchers].filter((watcher) => hears(watcher, provider)).map((watcher) => watcher.listener);
151
+ const providersFor = (watcher) => [...providers].filter((p) => hears(watcher, p));
152
152
  room.messageHandlers[messageComments] = (_encoder, decoder, provider) => {
153
153
  const message = readCommentsMessage(decoder);
154
- for (const listener of [...(commentListeners.get(provider.bcChannel) ?? [])]) {
154
+ for (const listener of listenersOf(provider)) {
155
155
  try {
156
156
  listener(message);
157
157
  }
@@ -162,26 +162,28 @@ export const bindWebsocketProvider = (Y) => {
162
162
  };
163
163
  /**
164
164
  * Hear the comment threads of `room` on `server` (the URL a provider
165
- * dials, `ws:`/`wss:`): every provider of that room subscribes now and
166
- * at each (re)connect, which the room answers with every thread (a
167
- * `snapshot`), then sends each `change`. Answers the unsubscribe; the
168
- * last one leaving tells the room to stop.
165
+ * dials, `ws:`/`wss:`; `null`: every provider of that room on the page,
166
+ * whatever its server): every such provider subscribes now and at each
167
+ * (re)connect, which the room answers with every thread (a `snapshot`),
168
+ * then sends each `change`. Answers the unsubscribe; the last listener
169
+ * of a provider leaving tells its room to stop.
169
170
  */
170
171
  const watchComments = (server, roomName, listener) => {
171
- const key = `${server.replace(/\/+$/, '')}/${roomName}`;
172
- const listeners = commentListeners.get(key) ?? new Set();
173
- commentListeners.set(key, listeners);
174
- const first = listeners.size === 0;
175
- listeners.add(listener);
176
- if (first)
177
- for (const provider of providersOf.get(key) ?? [])
178
- send(provider, subscribeFrame(true));
172
+ const watcher = {
173
+ room: roomName,
174
+ channel: server === null ? null : `${server.replace(/\/+$/, '')}/${roomName}`,
175
+ listener
176
+ };
177
+ const fresh = providersFor(watcher).filter((p) => listenersOf(p).length === 0);
178
+ watchers.add(watcher);
179
+ for (const provider of fresh)
180
+ send(provider, subscribeFrame(true));
179
181
  return () => {
180
- if (!listeners.delete(listener) || listeners.size > 0)
182
+ if (!watchers.delete(watcher))
181
183
  return;
182
- commentListeners.delete(key);
183
- for (const provider of providersOf.get(key) ?? [])
184
- send(provider, subscribeFrame(false));
184
+ for (const provider of providersFor(watcher))
185
+ if (listenersOf(provider).length === 0)
186
+ send(provider, subscribeFrame(false));
185
187
  };
186
188
  };
187
189
  // The room's acknowledgement and its bounded catch-up (a frame too large
@@ -468,7 +470,7 @@ export const bindWebsocketProvider = (Y) => {
468
470
  for (const buf of room.hello(provider))
469
471
  sendOn(provider, websocket, buf);
470
472
  // The room's comment threads, while someone listens (`watchComments`).
471
- if (commentListeners.get(provider.bcChannel)?.size)
473
+ if (listenersOf(provider).length > 0)
472
474
  sendOn(provider, websocket, subscribeFrame(true));
473
475
  };
474
476
  provider.emit('status', [{ status: 'connecting' }]);
@@ -540,8 +542,7 @@ export const bindWebsocketProvider = (Y) => {
540
542
  this._resync = setInterval(() => send(this, room.step1(this)), resyncInterval);
541
543
  }
542
544
  this._bcSubscriber = room.bcSubscriber(this);
543
- const peers = providersOf.get(this.bcChannel) ?? new Set();
544
- providersOf.set(this.bcChannel, peers.add(this));
545
+ providers.add(this);
545
546
  // Local doc updates go to the room; another tab's go to the server
546
547
  // only (`broadcastUpdate` quarantines a read-only document). A
547
548
  // socket the room made read-only gets this document's own edits
@@ -641,9 +642,7 @@ export const bindWebsocketProvider = (Y) => {
641
642
  return;
642
643
  clearInterval(this._resync);
643
644
  clearInterval(this._checkInterval);
644
- const peers = providersOf.get(this.bcChannel);
645
- if (peers?.delete(this) && peers.size === 0)
646
- providersOf.delete(this.bcChannel);
645
+ providers.delete(this);
647
646
  this.disconnect();
648
647
  this.awareness.off('update', this._awarenessUpdateHandler);
649
648
  this.doc.off('update', this._updateHandler);
@@ -40,6 +40,7 @@ export const normalizeRole = (role) => {
40
40
  };
41
41
  };
42
42
  /** Freeze `value` and everything in it: the tables are shared by every document. */
43
+ /* @__NO_SIDE_EFFECTS__ */
43
44
  const frozen = (value) => {
44
45
  if (value && typeof value === 'object' && !Object.isFrozen(value)) {
45
46
  Object.freeze(value);
@@ -294,7 +295,8 @@ export const equationSemantics = /* @__PURE__ */ semanticsOf(equationKinds);
294
295
  * plugins are not default plugins of `<Edytor>`, but their roles are here so their
295
296
  * blocks read the same on every replica.
296
297
  */
297
- export const defaultSemantics = withMarks(semanticsOf(richTextKinds, codeKinds, imageKinds, mediaKinds, layoutKinds, pageKinds, tocKinds, tableKinds, equationKinds), { ...richTextMarks, ...commentMarks });
298
+ export const defaultSemantics = /* @__PURE__ */ withMarks(semanticsOf(richTextKinds, codeKinds, imageKinds, mediaKinds, layoutKinds, pageKinds, tocKinds, tableKinds, equationKinds),
299
+ /* @__PURE__ */ Object.assign({}, richTextMarks, commentMarks));
298
300
  /**
299
301
  * The facade configuration (`EdytorDocConfig`) a document with no view
300
302
  * reads `semantics` with — the room's: roles, default children, content-less kinds
@@ -1,9 +1,17 @@
1
+ /** One adapter's auto-scroll (Atlassian's auto-scroll package), its drags already chosen. */
2
+ export type Scrollers = {
3
+ /** The window scrolls as the pointer nears its edges. */
4
+ window(): () => void;
5
+ /** `element` scrolls as the pointer nears its edges. */
6
+ element(element: Element): () => void;
7
+ };
1
8
  /**
2
- * Auto-scroll for one drag (a block's, a table row's or column's; Atlassian's
3
- * auto-scroll package): the window
4
- * and every scrolling element from the editor up (the editor included) scroll
5
- * as the pointer nears their edges, faster the closer and the longer it stays,
6
- * innermost first. `ours` keeps it to this editor's drags. Registered at the
7
- * drag's start (the package allows it mid-drag); the answer releases it.
9
+ * Auto-scroll for one drag (a block's, a table row's or column's, files
10
+ * dragged from outside): the window and every scrolling element from the
11
+ * editor up (the editor included) scroll as the pointer nears their edges,
12
+ * faster the closer and the longer it stays, innermost first. `scrollers`
13
+ * is the drag's adapter's (`elementScrollers`, `externalScrollers`), kept to
14
+ * this editor's drags. Registered at the drag's start (the package allows it
15
+ * mid-drag); the answer releases it.
8
16
  */
9
- export declare const autoScrollFor: (root: HTMLElement, ours: (data: Record<string | symbol, unknown>) => boolean) => (() => void);
17
+ export declare const autoScrollFor: (root: HTMLElement, scrollers: Scrollers) => (() => void);
@@ -1,25 +1,20 @@
1
- import { autoScroll, autoScrollWindow } from './pragmatic.js';
2
1
  /**
3
- * Auto-scroll for one drag (a block's, a table row's or column's; Atlassian's
4
- * auto-scroll package): the window
5
- * and every scrolling element from the editor up (the editor included) scroll
6
- * as the pointer nears their edges, faster the closer and the longer it stays,
7
- * innermost first. `ours` keeps it to this editor's drags. Registered at the
8
- * drag's start (the package allows it mid-drag); the answer releases it.
2
+ * Auto-scroll for one drag (a block's, a table row's or column's, files
3
+ * dragged from outside): the window and every scrolling element from the
4
+ * editor up (the editor included) scroll as the pointer nears their edges,
5
+ * faster the closer and the longer it stays, innermost first. `scrollers`
6
+ * is the drag's adapter's (`elementScrollers`, `externalScrollers`), kept to
7
+ * this editor's drags. Registered at the drag's start (the package allows it
8
+ * mid-drag); the answer releases it.
9
9
  */
10
- export const autoScrollFor = (root, ours) => {
11
- // The scroller hit-tests with `elementsFromPoint` every frame (jsdom has none),
12
- // so it is created only where that exists.
13
- if (typeof root.ownerDocument.elementsFromPoint !== 'function')
14
- return () => { };
15
- const canScroll = ({ source }) => ours(source.data);
16
- const releases = [autoScrollWindow({ canScroll })];
10
+ export const autoScrollFor = (root, scrollers) => {
11
+ const releases = [scrollers.window()];
17
12
  const { body, documentElement, defaultView } = root.ownerDocument;
18
13
  // The window is the document's scroller: stop below it.
19
14
  for (let element = root; element && element !== body && element !== documentElement; element = element.parentElement) {
20
15
  const { overflowX, overflowY } = defaultView.getComputedStyle(element);
21
16
  if (/auto|scroll|overlay/.test(`${overflowX} ${overflowY}`))
22
- releases.push(autoScroll({ element, canScroll }));
17
+ releases.push(scrollers.element(element));
23
18
  }
24
19
  return () => releases.forEach((release) => release());
25
20
  };
@@ -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>;