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.
- package/README.md +19 -4
- package/dist/block/block.svelte.js +2 -4
- package/dist/clipboard/htmlFlow.d.ts +20 -7
- package/dist/clipboard/htmlFlow.js +23 -15
- package/dist/clipboard/serializeClipboardFragment.d.ts +37 -4
- package/dist/clipboard/serializeClipboardFragment.js +6 -4
- package/dist/clipboard/textBlocks.d.ts +8 -0
- package/dist/clipboard/textBlocks.js +6 -2
- package/dist/cloudflare/DocumentRoom.d.ts +13 -9
- package/dist/cloudflare/DocumentRoom.js +10 -6
- package/dist/cloudflare/room/admission.js +3 -3
- package/dist/cloudflare/room/context.d.ts +28 -27
- package/dist/cloudflare/room/context.js +2 -2
- package/dist/cloudflare/room/purge.d.ts +6 -3
- package/dist/cloudflare/room/purge.js +44 -19
- package/dist/cloudflare/room/updates.d.ts +3 -4
- package/dist/cloudflare/room/updates.js +6 -8
- package/dist/cloudflare/routeDocumentSocket.d.ts +17 -0
- package/dist/cloudflare/routeDocumentSocket.js +53 -0
- package/dist/collaboration/comments/client.d.ts +1 -1
- package/dist/collaboration/comments/client.js +1 -1
- package/dist/collaboration/remoteSelection.js +3 -3
- package/dist/components/Edytor.svelte +2 -10
- package/dist/components/Edytor.svelte.d.ts +1 -3
- package/dist/crdt/admission.d.ts +5 -10
- package/dist/crdt/admission.js +5 -11
- package/dist/crdt/attribution/attribution.d.ts +31 -12
- package/dist/crdt/attribution/attribution.js +56 -18
- package/dist/crdt/attribution/block.d.ts +3 -3
- package/dist/crdt/attribution/block.js +7 -8
- package/dist/crdt/attribution/index.d.ts +1 -1
- package/dist/crdt/attribution/index.js +1 -1
- package/dist/crdt/data.d.ts +62 -31
- package/dist/crdt/data.js +211 -103
- package/dist/crdt/doc/delete.d.ts +1 -1
- package/dist/crdt/doc/delete.js +13 -30
- package/dist/crdt/doc/funnel.d.ts +7 -6
- package/dist/crdt/doc/funnel.js +39 -33
- package/dist/crdt/doc/gate.d.ts +3 -20
- package/dist/crdt/doc/gate.js +2 -41
- package/dist/crdt/doc/history.d.ts +25 -9
- package/dist/crdt/doc/history.js +152 -42
- package/dist/crdt/doc/layout.js +11 -22
- package/dist/crdt/doc/meta.js +12 -17
- package/dist/crdt/doc/moves.d.ts +1 -1
- package/dist/crdt/doc/moves.js +52 -32
- package/dist/crdt/doc/reads.js +2 -2
- package/dist/crdt/doc/seed.js +2 -2
- package/dist/crdt/doc/split-merge.js +12 -15
- package/dist/crdt/doc/steps.d.ts +25 -13
- package/dist/crdt/doc/steps.js +52 -122
- package/dist/crdt/doc/types.d.ts +21 -9
- package/dist/crdt/document.d.ts +21 -19
- package/dist/crdt/document.js +26 -23
- package/dist/crdt/edytor-doc.d.ts +66 -68
- package/dist/crdt/edytor-doc.js +21 -20
- package/dist/crdt/engine-api.d.ts +33 -1
- package/dist/crdt/engine.d.ts +0 -1
- package/dist/crdt/engine.js +1 -4
- package/dist/crdt/flow.d.ts +1 -1
- package/dist/crdt/flow.js +25 -27
- package/dist/crdt/index.d.ts +29 -28
- package/dist/crdt/index.js +3 -3
- package/dist/crdt/placement/display.d.ts +5 -30
- package/dist/crdt/placement/display.js +39 -144
- package/dist/crdt/placement/keys.d.ts +58 -0
- package/dist/crdt/placement/keys.js +90 -0
- package/dist/crdt/placement/model.d.ts +119 -118
- package/dist/crdt/placement/model.js +242 -142
- package/dist/crdt/placement/resolve.d.ts +123 -35
- package/dist/crdt/placement/resolve.js +187 -153
- package/dist/crdt/placement/slots.d.ts +134 -0
- package/dist/crdt/placement/slots.js +152 -0
- package/dist/crdt/protocol.d.ts +2 -2
- package/dist/crdt/protocol.js +2 -2
- package/dist/crdt/providers/index.d.ts +1 -1
- package/dist/crdt/providers/room.d.ts +26 -11
- package/dist/crdt/providers/room.js +77 -27
- package/dist/crdt/providers/websocket.d.ts +1 -1
- package/dist/crdt/providers/websocket.js +33 -32
- package/dist/crdt/purge.d.ts +17 -8
- package/dist/crdt/purge.js +236 -126
- package/dist/crdt/restore.d.ts +2 -2
- package/dist/crdt/restore.js +18 -34
- package/dist/crdt/schema.d.ts +22 -21
- package/dist/crdt/schema.js +29 -23
- package/dist/crdt/semantics.js +3 -1
- package/dist/crdt/storage.d.ts +1 -1
- package/dist/crdt/storage.js +1 -1
- package/dist/crdt/structs.d.ts +15 -15
- package/dist/crdt/structs.js +8 -22
- package/dist/crdt/text/index/cache.js +4 -0
- package/dist/crdt/text/index/claims.js +12 -0
- package/dist/crdt/text/index/fold.d.ts +2 -3
- package/dist/crdt/text/index/fold.js +194 -44
- package/dist/crdt/text/index/layout.js +5 -8
- package/dist/crdt/text/index/placement.d.ts +26 -18
- package/dist/crdt/text/index/placement.js +404 -138
- package/dist/crdt/text/index/records.d.ts +3 -3
- package/dist/crdt/text/index/records.js +24 -31
- package/dist/crdt/text/index/shared.d.ts +11 -3
- package/dist/crdt/text/index/shared.js +12 -3
- package/dist/crdt/text/index/state.d.ts +21 -17
- package/dist/crdt/text/index/state.js +15 -17
- package/dist/crdt/text/index/streams.d.ts +10 -5
- package/dist/crdt/text/index/streams.js +78 -27
- package/dist/crdt/text/items.d.ts +10 -3
- package/dist/crdt/text/items.js +7 -0
- package/dist/crdt/text/model.d.ts +77 -62
- package/dist/crdt/text/model.js +84 -169
- package/dist/crdt/text/ranges.d.ts +1 -1
- package/dist/crdt/text/ranges.js +3 -3
- package/dist/crdt/text/rows.d.ts +13 -7
- package/dist/crdt/text/rows.js +24 -7
- package/dist/crdt/text/runs.d.ts +17 -12
- package/dist/crdt/text/runs.js +24 -7
- package/dist/crdt/text/streams.d.ts +26 -13
- package/dist/crdt/text/streams.js +41 -14
- package/dist/crdt/vendor/yjs/UPSTREAM.md +568 -21
- package/dist/crdt/vendor/yjs/dts/global.d.ts +2 -0
- package/dist/crdt/vendor/yjs/dts/index.d.ts +1 -1
- package/dist/crdt/vendor/yjs/dts/structs/AbstractStruct.d.ts +7 -0
- package/dist/crdt/vendor/yjs/dts/structs/Item.d.ts +194 -10
- package/dist/crdt/vendor/yjs/dts/utils/Doc.d.ts +6 -3
- package/dist/crdt/vendor/yjs/dts/utils/StructStore.d.ts +5 -18
- package/dist/crdt/vendor/yjs/dts/utils/Transaction.d.ts +15 -1
- package/dist/crdt/vendor/yjs/dts/utils/UpdateDecoder.d.ts +14 -6
- package/dist/crdt/vendor/yjs/dts/utils/UpdateEncoder.d.ts +33 -6
- package/dist/crdt/vendor/yjs/dts/utils/ids.d.ts +1 -65
- package/dist/crdt/vendor/yjs/dts/utils/marks.d.ts +6 -1
- package/dist/crdt/vendor/yjs/dts/ynode.d.ts +43 -7
- package/dist/crdt/vendor/yjs/global.d.ts +2 -0
- package/dist/crdt/vendor/yjs/src/index.js +1 -1
- package/dist/crdt/vendor/yjs/src/structs/AbstractStruct.js +10 -0
- package/dist/crdt/vendor/yjs/src/structs/Item.js +610 -51
- package/dist/crdt/vendor/yjs/src/utils/BlockSet.js +18 -9
- package/dist/crdt/vendor/yjs/src/utils/Doc.js +5 -3
- package/dist/crdt/vendor/yjs/src/utils/StructStore.js +5 -0
- package/dist/crdt/vendor/yjs/src/utils/Transaction.js +36 -13
- package/dist/crdt/vendor/yjs/src/utils/UpdateDecoder.js +88 -18
- package/dist/crdt/vendor/yjs/src/utils/UpdateEncoder.js +119 -32
- package/dist/crdt/vendor/yjs/src/utils/encoding.js +13 -1
- package/dist/crdt/vendor/yjs/src/utils/ids.js +7 -7
- package/dist/crdt/vendor/yjs/src/utils/marks.js +193 -8
- package/dist/crdt/vendor/yjs/src/utils/redo.js +1 -1
- package/dist/crdt/vendor/yjs/src/utils/transaction-helpers.js +1 -1
- package/dist/crdt/vendor/yjs/src/utils/updates.js +3 -3
- package/dist/crdt/vendor/yjs/src/ynode.js +177 -12
- package/dist/dnd/autoScroll.d.ts +15 -7
- package/dist/dnd/autoScroll.js +10 -15
- package/dist/dnd/dropIndicator.js +2 -5
- package/dist/dnd/external.d.ts +6 -0
- package/dist/dnd/external.js +17 -0
- package/dist/dnd/geometry.d.ts +2 -0
- package/dist/dnd/geometry.js +3 -4
- package/dist/dnd/placement.d.ts +1 -1
- package/dist/dnd/pragmatic.d.ts +3 -1
- package/dist/dnd/pragmatic.js +12 -2
- package/dist/dnd/vendor/pragmatic/UPSTREAM.md +51 -18
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/drop-target-for-external.d.ts +4 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/drop-target-for-external.js +6 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/element-adapter.d.ts +0 -2
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/element-adapter.js +4 -22
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter-types.d.ts +26 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter.d.ts +30 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter.js +203 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/get-available-items.js +13 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/get-available-types.js +9 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/is-an-available-type.js +19 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/monitor-for-external.d.ts +4 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/monitor-for-external.js +6 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/honey-pot-fix/make-honey-pot-fix.js +4 -16
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/internal-types.d.ts +1 -8
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/make-adapter/make-drop-target.js +5 -6
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/make-adapter/make-monitor.js +2 -3
- 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
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/element/custom-native-drag-preview/set-custom-native-drag-preview.js +6 -24
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/contains-files.d.ts +2 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/contains-files.js +5 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/get-files.d.ts +3 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/get-files.js +12 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/native-types.d.ts +12 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/is-entering-window-in-safari.js +10 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/is-entering-window.js +55 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/external.d.ts +4 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/external.js +8 -0
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/internal-types.d.ts +0 -4
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/get-scroll-by.js +16 -72
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/try-scroll.js +1 -9
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/configuration.js +4 -29
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/get-scroll-change.js +2 -3
- package/dist/edytor.svelte.d.ts +2 -5
- package/dist/edytor.svelte.js +21 -32
- package/dist/events/beforeInputCommands.js +2 -2
- package/dist/events/onBeforeInput.js +1 -1
- package/dist/events/onDrop.d.ts +0 -6
- package/dist/events/onDrop.js +10 -23
- package/dist/events/onInput.d.ts +0 -12
- package/dist/events/onInput.js +1 -67
- package/dist/events/onPageHide.d.ts +3 -0
- package/dist/events/onPageHide.js +16 -0
- package/dist/export/forms.d.ts +627 -0
- package/dist/export/forms.js +749 -0
- package/dist/export/index.d.ts +170 -0
- package/dist/export/index.js +161 -0
- package/dist/export/markdown.d.ts +41 -0
- package/dist/export/markdown.js +585 -0
- package/dist/export/markdownWriter.d.ts +9 -0
- package/dist/export/markdownWriter.js +133 -0
- package/dist/export/mdx.d.ts +15 -0
- package/dist/export/mdx.js +33 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/kinds.js +1 -1
- package/dist/plugins/anchored.svelte.d.ts +21 -25
- package/dist/plugins/anchored.svelte.js +23 -39
- package/dist/plugins/blockHandles/BlockHandleController.svelte.js +24 -32
- package/dist/plugins/blockHandles/dragPreview.d.ts +26 -7
- package/dist/plugins/blockHandles/dragPreview.js +33 -0
- package/dist/plugins/blockMenu/BlockMenuController.svelte.d.ts +5 -0
- package/dist/plugins/blockMenu/BlockMenuController.svelte.js +7 -2
- package/dist/plugins/blockMenu/blockMenuPlugin.js +5 -50
- package/dist/plugins/chrome.d.ts +27 -5
- package/dist/plugins/chrome.js +24 -9
- package/dist/plugins/code/CodePlugin.svelte +12 -9
- package/dist/plugins/code/header.svelte.js +7 -11
- package/dist/plugins/code/languageMenu.svelte.d.ts +5 -2
- package/dist/plugins/code/languageMenu.svelte.js +13 -20
- package/dist/plugins/columns/ColumnsPlugin.svelte +7 -20
- package/dist/plugins/columns/resize.svelte.d.ts +2 -3
- package/dist/plugins/columns/resize.svelte.js +2 -5
- package/dist/plugins/comments/CommentsController.svelte.d.ts +6 -0
- package/dist/plugins/comments/CommentsController.svelte.js +20 -0
- package/dist/plugins/equation/EquationPlugin.svelte +12 -22
- package/dist/plugins/equation/equation.svelte.d.ts +7 -15
- package/dist/plugins/equation/equation.svelte.js +13 -50
- package/dist/plugins/equation/tex.d.ts +17 -0
- package/dist/plugins/equation/tex.js +42 -0
- package/dist/plugins/fileDrop.d.ts +38 -23
- package/dist/plugins/fileDrop.js +82 -76
- package/dist/plugins/find/FindController.svelte.d.ts +5 -0
- package/dist/plugins/find/FindController.svelte.js +14 -14
- package/dist/plugins/find/findPlugin.js +1 -15
- package/dist/plugins/image/ImageChrome.svelte +8 -2
- package/dist/plugins/image/ImagePlugin.svelte +15 -52
- package/dist/plugins/image/controls.svelte.js +16 -2
- package/dist/plugins/image/toolbar.svelte.d.ts +5 -4
- package/dist/plugins/image/toolbar.svelte.js +21 -31
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/list.svelte.d.ts +9 -0
- package/dist/plugins/list.svelte.js +18 -0
- package/dist/plugins/marquee/marqueePlugin.js +0 -4
- package/dist/plugins/media/AudioPlugin.svelte +1 -1
- package/dist/plugins/media/BookmarkPlugin.svelte +6 -97
- package/dist/plugins/media/EmbedPlugin.svelte +5 -90
- package/dist/plugins/media/EmptySlot.svelte +36 -20
- package/dist/plugins/media/EmptySlot.svelte.d.ts +6 -15
- package/dist/plugins/media/FilePlugin.svelte +1 -19
- package/dist/plugins/media/MediaEmpty.svelte +2 -55
- package/dist/plugins/media/MediaEmpty.svelte.d.ts +18 -14
- package/dist/plugins/media/SourceBlock.svelte +142 -52
- package/dist/plugins/media/SourceBlock.svelte.d.ts +10 -4
- package/dist/plugins/media/VideoPlugin.svelte +1 -1
- package/dist/plugins/media/empty.svelte.js +2 -7
- package/dist/plugins/media/media.d.ts +2 -63
- package/dist/plugins/media/media.js +1 -194
- package/dist/plugins/media/sources.d.ts +60 -0
- package/dist/plugins/media/sources.js +165 -0
- package/dist/plugins/media/urlPaste.svelte.d.ts +2 -1
- package/dist/plugins/media/urlPaste.svelte.js +12 -21
- package/dist/plugins/mention/MentionPlugin.svelte +8 -35
- package/dist/plugins/page/PagePlugin.svelte +2 -9
- package/dist/plugins/page/page.js +1 -1
- package/dist/plugins/pageLink/PageLinkPlugin.svelte +6 -13
- package/dist/plugins/richtext/RichTextPlugin.svelte +85 -197
- package/dist/plugins/richtext/body.js +1 -1
- package/dist/plugins/richtext/calloutIcons.svelte.d.ts +2 -2
- package/dist/plugins/richtext/calloutIcons.svelte.js +5 -7
- package/dist/plugins/richtext/richTextOperations.d.ts +1 -19
- package/dist/plugins/richtext/richTextOperations.js +3 -49
- package/dist/plugins/slashMenu/SlashMenuController.svelte.d.ts +2 -0
- package/dist/plugins/slashMenu/SlashMenuController.svelte.js +7 -0
- package/dist/plugins/slashMenu/slashMenuPlugin.js +5 -14
- package/dist/plugins/table/TableChrome.svelte +2 -3
- package/dist/plugins/table/TablePlugin.svelte +20 -54
- package/dist/plugins/table/chrome.svelte.d.ts +5 -2
- package/dist/plugins/table/chrome.svelte.js +30 -54
- package/dist/plugins/table/table.js +3 -3
- package/dist/plugins/toc/TocPlugin.svelte +2 -4
- package/dist/plugins/toolbar/ToolbarController.svelte.d.ts +7 -0
- package/dist/plugins/toolbar/ToolbarController.svelte.js +20 -13
- package/dist/plugins/toolbar/toolbarPlugin.js +19 -53
- package/dist/plugins/triggers/TriggerController.svelte.d.ts +7 -2
- package/dist/plugins/triggers/TriggerController.svelte.js +11 -4
- package/dist/plugins/triggers/place.js +1 -2
- package/dist/plugins/triggers/triggers.d.ts +6 -1
- package/dist/plugins/triggers/triggers.js +12 -13
- package/dist/plugins/uploads.svelte.d.ts +5 -2
- package/dist/plugins/uploads.svelte.js +25 -15
- package/dist/plugins.d.ts +26 -0
- package/dist/plugins.js +0 -24
- package/dist/selection/replaceSelection.js +2 -2
- package/dist/selection/selection.svelte.d.ts +4 -10
- package/dist/selection/selection.svelte.js +7 -11
- package/dist/session/bindings.js +1 -1
- package/dist/session/commands.d.ts +7 -11
- package/dist/session/commands.js +13 -19
- package/dist/session/inputRules.js +1 -1
- package/dist/session/navigation.js +1 -1
- package/dist/session/suggestions.svelte.d.ts +0 -11
- package/dist/session/suggestions.svelte.js +15 -3
- package/dist/session/uploads.d.ts +8 -8
- package/dist/surface/lines.js +1 -3
- package/dist/surface/observer.svelte.d.ts +17 -1
- package/dist/surface/observer.svelte.js +74 -19
- package/dist/surface/overlay.d.ts +0 -14
- package/dist/surface/overlay.js +0 -25
- package/dist/surface/projector.svelte.d.ts +15 -3
- package/dist/surface/projector.svelte.js +60 -9
- package/dist/text/text.svelte.js +3 -13
- package/dist/utils/sanitize.d.ts +38 -0
- package/dist/utils/sanitize.js +82 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +5 -0
- package/package.json +19 -2
- package/dist/crdt/placement/rank.d.ts +0 -87
- package/dist/crdt/placement/rank.js +0 -332
- package/dist/crdt/placement/source.d.ts +0 -43
- package/dist/crdt/placement/source.js +0 -66
- package/dist/crdt/text/delete-index.d.ts +0 -129
- package/dist/crdt/text/delete-index.js +0 -365
- package/dist/crdt/text/deletes.d.ts +0 -76
- package/dist/crdt/text/deletes.js +0 -362
- package/dist/crdt/text/index/anchored.d.ts +0 -17
- package/dist/crdt/text/index/anchored.js +0 -197
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/max-z-index.js +0 -3
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/supports-popover.js +0 -16
- package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/is-axis-allowed.js +0 -3
- package/dist/plugins/code/LanguageMenu.svelte +0 -25
- package/dist/plugins/code/LanguageMenu.svelte.d.ts +0 -9
- package/dist/plugins/equation/EquationEditor.svelte +0 -27
- package/dist/plugins/equation/EquationEditor.svelte.d.ts +0 -9
- package/dist/plugins/image/ImageToolbarHost.svelte +0 -37
- package/dist/plugins/image/ImageToolbarHost.svelte.d.ts +0 -9
- package/dist/plugins/richtext/CalloutIconPicker.svelte +0 -26
- 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
|
|
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
|
+
};
|
package/dist/dnd/geometry.d.ts
CHANGED
|
@@ -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
|
package/dist/dnd/geometry.js
CHANGED
|
@@ -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
|
|
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
|
package/dist/dnd/placement.d.ts
CHANGED
|
@@ -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
|
|
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';
|
package/dist/dnd/pragmatic.d.ts
CHANGED
|
@@ -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
|
-
|
|
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;
|
package/dist/dnd/pragmatic.js
CHANGED
|
@@ -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
|
-
|
|
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`
|
|
7
|
-
|
|
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
|
|
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
|
|
51
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
|
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`,
|
|
96
|
-
`
|
|
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
|
|
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
|
|
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.
|
package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/drop-target-for-external.d.ts
ADDED
|
@@ -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$
|
|
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
|
-
|
|
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:
|
|
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
|
+
}
|