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
@@ -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
+ }
@@ -1,7 +1,5 @@
1
1
  import { bind, bindAll } from '../../bind-event-listener/index.js';
2
- import { maxZIndex } from '../util/max-z-index.js';
3
2
  import { popoverResetUserAgentStyles } from '../util/popover-reset-styles.js';
4
- import { supportsPopover } from '../util/supports-popover.js';
5
3
  import { honeyPotDataAttribute } from './honey-pot-data-attribute.js';
6
4
  const honeyPotSize = 2;
7
5
  const halfHoneyPotSize = honeyPotSize / 2;
@@ -137,9 +135,8 @@ function mountHoneyPot({
137
135
  // including elements using z-index and other stacking contexts.
138
136
  // "manual" means no light dismiss — we manage the lifecycle ourselves.
139
137
  // Falls back to position:fixed + maxZIndex when the popover API is not available.
140
- if (supportsPopover()) {
141
- element.setAttribute('popover', 'manual');
142
- }
138
+ // edytor: every supported engine has the Popover API (no fallback).
139
+ element.setAttribute('popover', 'manual');
143
140
 
144
141
  // can shift during the drag thanks to Firefox
145
142
  let clientRect = getHoneyPotRectFor({
@@ -147,14 +144,7 @@ function mountHoneyPot({
147
144
  });
148
145
  Object.assign(element.style, {
149
146
  position: 'fixed',
150
- ...(supportsPopover() ?
151
- // needs to come first as it has 'inset: unset' which
152
- // needs to be overridden by our top / left values
153
- popoverResetUserAgentStyles : {
154
- // Fallback: using maximum possible z-index so that this element
155
- // will always be on top of other positioned content.
156
- zIndex: maxZIndex
157
- }),
147
+ ...popoverResetUserAgentStyles,
158
148
  // Setting a background color explicitly to avoid any inherited styles.
159
149
  // Looks like this could be `opacity: 0`, but worried that _might_
160
150
  // cause the element to be ignored on some platforms.
@@ -172,9 +162,7 @@ function mountHoneyPot({
172
162
  })
173
163
  });
174
164
  document.body.appendChild(element);
175
- if (supportsPopover()) {
176
- element.showPopover();
177
- }
165
+ element.showPopover();
178
166
 
179
167
  /**
180
168
  * 🦊 In firefox we can get `"pointermove"` events after the drag
@@ -243,9 +243,7 @@ export type MonitorGetFeedbackArgs<DragType extends AllDragTypes> = {
243
243
  */
244
244
  source: DragType['payload'];
245
245
  };
246
- export type MonitorArgs<DragType extends AllDragTypes> = Partial<AllEvents<DragType>> & {
247
- canMonitor?: (args: MonitorGetFeedbackArgs<DragType>) => boolean;
248
- };
246
+ export type MonitorArgs<DragType extends AllDragTypes> = Partial<AllEvents<DragType>>;
249
247
  export type DropTargetGetFeedbackArgs<DragType extends AllDragTypes> = {
250
248
  /**
251
249
  * The users _current_ input
@@ -318,11 +316,6 @@ export type DropTargetArgs<DragType extends AllDragTypes> = {
318
316
  * dropped on.
319
317
  */
320
318
  canDrop?: (args: DropTargetGetFeedbackArgs<DragType>) => boolean;
321
- /**
322
- * Optionally provide a _drop effect_ to be applied when
323
- * this drop target is the innermost drop target being dragged over.
324
- */
325
- getDropEffect?: (args: DropTargetGetFeedbackArgs<DragType>) => DropTargetAllowedDropEffect;
326
319
  /**
327
320
  * Return `true` if you want your drop target to hold onto
328
321
  * selection after the user is no longer dragging over this drop target.
@@ -51,7 +51,7 @@ export function makeDropTarget({
51
51
  input,
52
52
  result = []
53
53
  }) {
54
- var _args$getData, _args$getData2, _args$getDropEffect, _args$getDropEffect2;
54
+ var _args$getData, _args$getData2;
55
55
  if (target == null) {
56
56
  return result;
57
57
  }
@@ -104,7 +104,8 @@ export function makeDropTarget({
104
104
 
105
105
  // calculate our new record
106
106
  const data = (_args$getData = (_args$getData2 = args.getData) === null || _args$getData2 === void 0 ? void 0 : _args$getData2.call(args, feedback)) !== null && _args$getData !== void 0 ? _args$getData : {};
107
- const dropEffect = (_args$getDropEffect = (_args$getDropEffect2 = args.getDropEffect) === null || _args$getDropEffect2 === void 0 ? void 0 : _args$getDropEffect2.call(args, feedback)) !== null && _args$getDropEffect !== void 0 ? _args$getDropEffect : defaultDropEffect;
107
+ // edytor: no drop target sets `getDropEffect`.
108
+ const dropEffect = defaultDropEffect;
108
109
  const record = {
109
110
  data,
110
111
  element: args.element,
@@ -150,7 +151,6 @@ export function makeDropTarget({
150
151
  const isCurrent = new Set(payload.location.current.dropTargets.map(record => record.element));
151
152
  const visited = new Set();
152
153
  for (const record of payload.location.previous.dropTargets) {
153
- var _entry$onDropTargetCh;
154
154
  visited.add(record.element);
155
155
  const entry = registry.get(record.element);
156
156
  const isOver = isCurrent.has(record.element);
@@ -158,7 +158,7 @@ export function makeDropTarget({
158
158
  ...payload,
159
159
  self: record
160
160
  };
161
- entry === null || entry === void 0 ? void 0 : (_entry$onDropTargetCh = entry.onDropTargetChange) === null || _entry$onDropTargetCh === void 0 ? void 0 : _entry$onDropTargetCh.call(entry, args);
161
+ // edytor: no drop target sets `onDropTargetChange`.
162
162
 
163
163
  // if we cannot find the drop target in the current array, then it has been left
164
164
  if (!isOver) {
@@ -167,7 +167,7 @@ export function makeDropTarget({
167
167
  }
168
168
  }
169
169
  for (const record of payload.location.current.dropTargets) {
170
- var _entry$onDropTargetCh2, _entry$onDragEnter;
170
+ var _entry$onDragEnter;
171
171
  // already published an update to this drop target
172
172
  if (visited.has(record.element)) {
173
173
  continue;
@@ -178,7 +178,6 @@ export function makeDropTarget({
178
178
  self: record
179
179
  };
180
180
  const entry = registry.get(record.element);
181
- entry === null || entry === void 0 ? void 0 : (_entry$onDropTargetCh2 = entry.onDropTargetChange) === null || _entry$onDropTargetCh2 === void 0 ? void 0 : _entry$onDropTargetCh2.call(entry, args);
182
181
  entry === null || entry === void 0 ? void 0 : (_entry$onDragEnter = entry.onDragEnter) === null || _entry$onDragEnter === void 0 ? void 0 : _entry$onDragEnter.call(entry, args);
183
182
  }
184
183
  }
@@ -9,9 +9,8 @@ export function makeMonitor() {
9
9
  // Monitor is allowed to monitor events if:
10
10
  // 1. It has no `canMonitor` function (default is that a monitor can listen to everything)
11
11
  // 2. `canMonitor` returns true
12
- if (!monitor.canMonitor || monitor.canMonitor(dragging.canMonitorArgs)) {
13
- dragging.active.add(monitor);
14
- }
12
+ // edytor: no monitor sets `canMonitor`.
13
+ dragging.active.add(monitor);
15
14
  }
16
15
  function monitorForConsumers(args) {
17
16
  // We are giving each `args` a new reference so that you
@@ -29,7 +29,7 @@ type RenderFn = ({ container, }: {
29
29
  * });
30
30
  */
31
31
  export declare function setCustomNativeDragPreview({ render, nativeSetDragImage, getOffset, }: {
32
- getOffset?: GetOffsetFn;
32
+ getOffset: GetOffsetFn;
33
33
  render: RenderFn;
34
34
  nativeSetDragImage: ElementEventPayloadMap['onGenerateDragPreview']['nativeSetDragImage'];
35
35
  }): void;
@@ -1,8 +1,6 @@
1
1
  import { monitorForElements } from '../../../adapter/element-adapter.js';
2
2
  import { isSafari } from '../../../util/is-safari.js';
3
- import { maxZIndex } from '../../../util/max-z-index.js';
4
3
  import { popoverResetUserAgentStyles } from '../../../util/popover-reset-styles.js';
5
- import { supportsPopover } from '../../../util/supports-popover.js';
6
4
 
7
5
  /** A function to remove the element that has been added to the `container`.
8
6
  * @example () => root.unmount()
@@ -10,13 +8,6 @@ import { supportsPopover } from '../../../util/supports-popover.js';
10
8
 
11
9
  /** A function that will render a preview element into a `container` `HTMLElement` */
12
10
 
13
- /** By default we use the build in values for the native drag preview: {x: 0, y: 0} */
14
- function defaultOffset() {
15
- return {
16
- x: 0,
17
- y: 0
18
- };
19
- }
20
11
 
21
12
  /** This function provides the ability to mount an element for it to be used as the native drag preview
22
13
  *
@@ -37,7 +28,8 @@ function defaultOffset() {
37
28
  export function setCustomNativeDragPreview({
38
29
  render,
39
30
  nativeSetDragImage,
40
- getOffset = defaultOffset
31
+ // edytor: every caller gives its `getOffset`.
32
+ getOffset
41
33
  }) {
42
34
  const container = document.createElement('div');
43
35
 
@@ -50,23 +42,15 @@ export function setCustomNativeDragPreview({
50
42
  // Falls back to position:fixed + maxZIndex when the popover API is not available.
51
43
  // Note: the popover attribute must be set before the element is in the DOM.
52
44
  // `.showPopover()` is called further below after the element is appended to the body.
53
- if (supportsPopover()) {
54
- container.setAttribute('popover', 'manual');
55
- }
45
+ // edytor: every supported engine has the Popover API (no fallback).
46
+ container.setAttribute('popover', 'manual');
56
47
  Object.assign(container.style, {
57
48
  // Ensuring we don't cause reflow when adding the element to the page
58
49
  // Using `position:fixed` rather than `position:absolute` so we are
59
50
  // positioned on the current viewport.
60
51
  // `position:fixed` also creates a new stacking context, so we don't need to do that here
61
52
  position: 'fixed',
62
- ...(supportsPopover() ?
63
- // needs to come first as it has 'inset: unset' which
64
- // needs to be overridden by our top / left values
65
- popoverResetUserAgentStyles : {
66
- // Fallback: using maximum possible z-index so that this element
67
- // will always be on top of other positioned content.
68
- zIndex: maxZIndex
69
- }),
53
+ ...popoverResetUserAgentStyles,
70
54
  // According to `mdn`, the element can be offscreen:
71
55
  // https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/setDragImage#imgelement
72
56
  //
@@ -82,9 +66,7 @@ export function setCustomNativeDragPreview({
82
66
  document.body.append(container);
83
67
 
84
68
  // `.showPopover()` must be called after the element is in the DOM.
85
- if (supportsPopover()) {
86
- container.showPopover();
87
- }
69
+ container.showPopover();
88
70
  const unmount = render({
89
71
  container
90
72
  });
@@ -0,0 +1,2 @@
1
+ import { type ContainsSource } from './native-types.js';
2
+ export declare function containsFiles({ source }: ContainsSource): boolean;
@@ -0,0 +1,5 @@
1
+ export function containsFiles({
2
+ source
3
+ }) {
4
+ return source.types.includes('Files');
5
+ }
@@ -0,0 +1,3 @@
1
+ import { type ContainsSource } from './native-types.js';
2
+ /** Obtain an array of the dragged `File`s */
3
+ export declare function getFiles({ source }: ContainsSource): File[];
@@ -0,0 +1,12 @@
1
+ /** Obtain an array of the dragged `File`s */
2
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
3
+ export function getFiles({
4
+ source
5
+ }) {
6
+ return source.items
7
+ // unlike other media types, for files:
8
+ // item.kind is 'file'
9
+ // item.type is the type of file eg 'image/jpg'
10
+ // for other media types, item.type is the mime format
11
+ .filter(item => item.kind === 'file').map(item => item.getAsFile()).filter(file => file != null);
12
+ }
@@ -0,0 +1,12 @@
1
+ import type { ExternalDragPayload } from '../../internal-types.js';
2
+ /** `ContainsSource` works for
3
+ * 1. `monitorForNative` > `canMonitor()`
4
+ * 2. `dropTargetForNative` > `canDrop()`
5
+ *
6
+ * We are also using `SourcePayload` as the parameter type for all native getters.
7
+ * For example, `getFiles({source}: SourcePayload)`
8
+ */
9
+ export type ContainsSource = {
10
+ source: ExternalDragPayload;
11
+ };
12
+ export type PredicateFn = (args: ContainsSource) => boolean;
@@ -0,0 +1,10 @@
1
+ import { isSafari } from '../is-safari.js';
2
+ import { symbols } from './count-events-for-safari.js';
3
+ export function isEnteringWindowInSafari({
4
+ dragEnter
5
+ }) {
6
+ if (!isSafari()) {
7
+ return false;
8
+ }
9
+ return dragEnter.hasOwnProperty(symbols.isEnteringWindow);
10
+ }
@@ -0,0 +1,55 @@
1
+ import { isFirefox } from '../is-firefox.js';
2
+ import { isSafari } from '../is-safari.js';
3
+ import { isEnteringWindowInSafari } from './is-entering-window-in-safari.js';
4
+ import { isFromAnotherWindow } from './is-from-another-window.js';
5
+ export function isEnteringWindow({
6
+ dragEnter
7
+ }) {
8
+ const {
9
+ type,
10
+ relatedTarget
11
+ } = dragEnter;
12
+ if (type !== 'dragenter') {
13
+ return false;
14
+ }
15
+ if (isSafari()) {
16
+ return isEnteringWindowInSafari({
17
+ dragEnter
18
+ });
19
+ }
20
+
21
+ // standard check
22
+ if (relatedTarget == null) {
23
+ return true;
24
+ }
25
+
26
+ /**
27
+ * 🦊 Exception: `iframe` in Firefox (`125.0`)
28
+ *
29
+ * Case 1: parent `window` → child `iframe`
30
+ * `relatedTarget` is the `iframe` element in the parent `window`
31
+ * (foreign element)
32
+ *
33
+ * Case 2: child `iframe` → parent `window`
34
+ * `relatedTarget` is an element inside the child `iframe`
35
+ * (foreign element)
36
+ */
37
+
38
+ if (isFirefox()) {
39
+ return isFromAnotherWindow(relatedTarget);
40
+ }
41
+
42
+ /**
43
+ * 🌏 Exception: `iframe` in Chrome (`124.0`)
44
+ *
45
+ * Case 1: parent `window` → child `iframe`
46
+ * `relatedTarget` is `null` *(standard check)*
47
+ *
48
+ * Case 2: child `iframe` → parent `window`
49
+ * `relatedTarget` is the `iframe` element in the parent `window`
50
+ */
51
+
52
+ // Case 2
53
+ // Using `instanceof` check as the element will be in the same `window`
54
+ return relatedTarget instanceof HTMLIFrameElement;
55
+ }
@@ -0,0 +1,4 @@
1
+ import type { ExternalDragType, CleanupFn } from '../../pragmatic-drag-and-drop/entry-point/types.js';
2
+ import type { ElementAutoScrollArgs, WindowAutoScrollArgs } from '../internal-types.js';
3
+ export declare const autoScrollForExternal: (args: ElementAutoScrollArgs<ExternalDragType>) => CleanupFn;
4
+ export declare const autoScrollWindowForExternal: (args?: WindowAutoScrollArgs<ExternalDragType>) => CleanupFn;
@@ -0,0 +1,8 @@
1
+ import { monitorForExternal } from '../../pragmatic-drag-and-drop/adapter/monitor-for-external.js';
2
+ import { makeApi } from '../over-element/make-api.js';
3
+ const api = makeApi({
4
+ monitor: monitorForExternal
5
+ });
6
+ export const autoScrollForExternal = api.autoScroll;
7
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
8
+ export const autoScrollWindowForExternal = api.autoScrollWindow;
@@ -37,13 +37,9 @@ export type PublicConfig = Partial<{
37
37
  export type ElementAutoScrollArgs<DragType extends AllDragTypes> = {
38
38
  element: Element;
39
39
  canScroll?: (args: ElementGetFeedbackArgs<DragType>) => boolean;
40
- getAllowedAxis?: (args: ElementGetFeedbackArgs<DragType>) => AllowedAxis;
41
- getConfiguration?: (args: ElementGetFeedbackArgs<DragType>) => PublicConfig;
42
40
  };
43
41
  export type WindowAutoScrollArgs<DragType extends AllDragTypes> = {
44
42
  canScroll?: (args: WindowGetFeedbackArgs<DragType>) => boolean;
45
- getAllowedAxis?: (args: WindowGetFeedbackArgs<DragType>) => AllowedAxis;
46
- getConfiguration?: (args: WindowGetFeedbackArgs<DragType>) => PublicConfig;
47
43
  };
48
44
  export type Side = 'start' | 'end';
49
45
  export type Axis = 'vertical' | 'horizontal';