edytor 1.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 (287) hide show
  1. package/README.md +26 -69
  2. package/dist/block/block.svelte.d.ts +6 -4
  3. package/dist/block/block.svelte.js +12 -8
  4. package/dist/block/inlineBlock.svelte.d.ts +6 -2
  5. package/dist/block/inlineBlock.svelte.js +7 -2
  6. package/dist/clipboard/htmlFlow.d.ts +20 -7
  7. package/dist/clipboard/htmlFlow.js +23 -15
  8. package/dist/clipboard/serializeClipboardFragment.d.ts +37 -4
  9. package/dist/clipboard/serializeClipboardFragment.js +6 -4
  10. package/dist/clipboard/textBlocks.d.ts +8 -0
  11. package/dist/clipboard/textBlocks.js +6 -2
  12. package/dist/cloudflare/room/admission.js +3 -3
  13. package/dist/cloudflare/room/context.d.ts +7 -1
  14. package/dist/cloudflare/routeDocumentSocket.d.ts +17 -0
  15. package/dist/cloudflare/routeDocumentSocket.js +53 -0
  16. package/dist/collaboration/awarenessSelection.d.ts +22 -1
  17. package/dist/collaboration/awarenessSelection.js +42 -0
  18. package/dist/collaboration/comments/client.d.ts +1 -1
  19. package/dist/collaboration/comments/client.js +1 -1
  20. package/dist/collaboration/remoteSelection.js +3 -3
  21. package/dist/components/Block.svelte +3 -1
  22. package/dist/components/Edytor.svelte +38 -20
  23. package/dist/components/Edytor.svelte.d.ts +9 -4
  24. package/dist/components/InlineBlock.svelte +1 -1
  25. package/dist/crdt/admission.d.ts +5 -10
  26. package/dist/crdt/admission.js +5 -11
  27. package/dist/crdt/data.d.ts +10 -0
  28. package/dist/crdt/data.js +20 -2
  29. package/dist/crdt/doc/funnel.d.ts +7 -6
  30. package/dist/crdt/doc/funnel.js +10 -9
  31. package/dist/crdt/doc/gate.d.ts +0 -17
  32. package/dist/crdt/doc/gate.js +2 -41
  33. package/dist/crdt/doc/history.js +2 -2
  34. package/dist/crdt/doc/reads.d.ts +7 -0
  35. package/dist/crdt/doc/reads.js +11 -1
  36. package/dist/crdt/document.d.ts +13 -14
  37. package/dist/crdt/document.js +17 -19
  38. package/dist/crdt/edytor-doc.d.ts +22 -4
  39. package/dist/crdt/edytor-doc.js +5 -8
  40. package/dist/crdt/index.d.ts +9 -3
  41. package/dist/crdt/index.js +2 -2
  42. package/dist/crdt/operations.d.ts +1 -1
  43. package/dist/crdt/operations.js +1 -0
  44. package/dist/crdt/props.d.ts +32 -0
  45. package/dist/crdt/props.js +172 -0
  46. package/dist/crdt/protocol.d.ts +2 -2
  47. package/dist/crdt/protocol.js +2 -2
  48. package/dist/crdt/providers/index.d.ts +1 -1
  49. package/dist/crdt/providers/room.d.ts +10 -9
  50. package/dist/crdt/providers/room.js +13 -10
  51. package/dist/crdt/providers/websocket.d.ts +1 -1
  52. package/dist/crdt/providers/websocket.js +28 -29
  53. package/dist/crdt/semantics.js +3 -1
  54. package/dist/dnd/autoScroll.d.ts +15 -7
  55. package/dist/dnd/autoScroll.js +10 -15
  56. package/dist/{plugins/blockHandles → dnd}/dropIndicator.d.ts +2 -2
  57. package/dist/{plugins/blockHandles → dnd}/dropIndicator.js +2 -5
  58. package/dist/dnd/external.d.ts +6 -0
  59. package/dist/dnd/external.js +17 -0
  60. package/dist/{plugins/blockHandles → dnd}/geometry.d.ts +4 -2
  61. package/dist/{plugins/blockHandles → dnd}/geometry.js +3 -4
  62. package/dist/dnd/placement.d.ts +200 -0
  63. package/dist/dnd/placement.js +426 -0
  64. package/dist/dnd/pragmatic.d.ts +3 -1
  65. package/dist/dnd/pragmatic.js +12 -2
  66. package/dist/dnd/vendor/pragmatic/UPSTREAM.md +51 -18
  67. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/drop-target-for-external.d.ts +4 -0
  68. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/drop-target-for-external.js +6 -0
  69. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/element-adapter.d.ts +0 -2
  70. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/element-adapter.js +4 -22
  71. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter-types.d.ts +26 -0
  72. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter.d.ts +30 -0
  73. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/external-adapter.js +203 -0
  74. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/get-available-items.js +13 -0
  75. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/get-available-types.js +9 -0
  76. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/is-an-available-type.js +19 -0
  77. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/monitor-for-external.d.ts +4 -0
  78. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/adapter/monitor-for-external.js +6 -0
  79. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/honey-pot-fix/make-honey-pot-fix.js +4 -16
  80. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/internal-types.d.ts +1 -8
  81. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/make-adapter/make-drop-target.js +5 -6
  82. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/make-adapter/make-monitor.js +2 -3
  83. 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
  84. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/element/custom-native-drag-preview/set-custom-native-drag-preview.js +6 -24
  85. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/contains-files.d.ts +2 -0
  86. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/contains-files.js +5 -0
  87. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/get-files.d.ts +3 -0
  88. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/get-files.js +12 -0
  89. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/public-utils/external/native-types.d.ts +12 -0
  90. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/is-entering-window-in-safari.js +10 -0
  91. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/changing-window/is-entering-window.js +55 -0
  92. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/external.d.ts +4 -0
  93. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/entry-point/external.js +8 -0
  94. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/internal-types.d.ts +0 -4
  95. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/get-scroll-by.js +16 -72
  96. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/over-element/try-scroll.js +1 -9
  97. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/configuration.js +4 -29
  98. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/get-scroll-change.js +2 -3
  99. package/dist/edytor.svelte.d.ts +19 -9
  100. package/dist/edytor.svelte.js +28 -33
  101. package/dist/events/beforeInputCommands.d.ts +2 -2
  102. package/dist/events/beforeInputCommands.js +8 -4
  103. package/dist/events/onBeforeInput.js +1 -1
  104. package/dist/events/onDrop.js +25 -10
  105. package/dist/events/onInput.d.ts +0 -12
  106. package/dist/events/onInput.js +1 -67
  107. package/dist/events/onPaste.d.ts +2 -1
  108. package/dist/events/onPaste.js +8 -3
  109. package/dist/export/forms.d.ts +627 -0
  110. package/dist/export/forms.js +749 -0
  111. package/dist/export/index.d.ts +170 -0
  112. package/dist/export/index.js +161 -0
  113. package/dist/export/markdown.d.ts +41 -0
  114. package/dist/export/markdown.js +585 -0
  115. package/dist/export/markdownWriter.d.ts +9 -0
  116. package/dist/export/markdownWriter.js +133 -0
  117. package/dist/export/mdx.d.ts +15 -0
  118. package/dist/export/mdx.js +33 -0
  119. package/dist/index.d.ts +4 -4
  120. package/dist/index.js +2 -2
  121. package/dist/kinds.js +1 -1
  122. package/dist/labels.d.ts +2 -0
  123. package/dist/labels.js +2 -1
  124. package/dist/plugins/anchored.svelte.d.ts +21 -25
  125. package/dist/plugins/anchored.svelte.js +23 -39
  126. package/dist/plugins/arrowMove/arrowMove.d.ts +1 -1
  127. package/dist/plugins/arrowMove/arrowMove.js +1 -1
  128. package/dist/plugins/blockHandles/BlockHandleController.svelte.d.ts +2 -122
  129. package/dist/plugins/blockHandles/BlockHandleController.svelte.js +48 -414
  130. package/dist/plugins/blockHandles/BlockHandles.svelte +14 -32
  131. package/dist/plugins/blockHandles/blockHandlesPlugin.js +2 -1
  132. package/dist/plugins/blockHandles/dragPreview.d.ts +26 -7
  133. package/dist/plugins/blockHandles/dragPreview.js +33 -0
  134. package/dist/plugins/blockMenu/BlockMenuController.svelte.d.ts +5 -0
  135. package/dist/plugins/blockMenu/BlockMenuController.svelte.js +7 -2
  136. package/dist/plugins/blockMenu/blockMenuPlugin.js +5 -50
  137. package/dist/plugins/chrome.d.ts +27 -5
  138. package/dist/plugins/chrome.js +24 -9
  139. package/dist/plugins/code/CodeHeader.svelte +5 -3
  140. package/dist/plugins/code/CodePlugin.svelte +15 -12
  141. package/dist/plugins/code/header.svelte.js +7 -11
  142. package/dist/plugins/code/languageMenu.svelte.d.ts +5 -2
  143. package/dist/plugins/code/languageMenu.svelte.js +13 -20
  144. package/dist/plugins/code/languages.d.ts +0 -3
  145. package/dist/plugins/code/languages.js +0 -2
  146. package/dist/plugins/columns/ColumnResize.svelte +3 -2
  147. package/dist/plugins/columns/ColumnsPlugin.svelte +8 -21
  148. package/dist/plugins/columns/gaps.d.ts +7 -5
  149. package/dist/plugins/columns/gaps.js +11 -6
  150. package/dist/plugins/columns/resize.svelte.d.ts +5 -6
  151. package/dist/plugins/columns/resize.svelte.js +12 -14
  152. package/dist/plugins/comments/CommentsController.svelte.d.ts +6 -0
  153. package/dist/plugins/comments/CommentsController.svelte.js +20 -0
  154. package/dist/plugins/equation/EquationPlugin.svelte +13 -30
  155. package/dist/plugins/equation/EquationPlugin.svelte.d.ts +1 -0
  156. package/dist/plugins/equation/equation.css +7 -0
  157. package/dist/plugins/equation/equation.svelte.d.ts +7 -15
  158. package/dist/plugins/equation/equation.svelte.js +13 -50
  159. package/dist/plugins/equation/tex.d.ts +17 -0
  160. package/dist/plugins/equation/tex.js +42 -0
  161. package/dist/plugins/fileDrop.d.ts +43 -0
  162. package/dist/plugins/fileDrop.js +122 -0
  163. package/dist/plugins/find/FindController.svelte.d.ts +5 -0
  164. package/dist/plugins/find/FindController.svelte.js +14 -14
  165. package/dist/plugins/find/findPlugin.js +1 -15
  166. package/dist/plugins/image/ImageChrome.svelte +8 -2
  167. package/dist/plugins/image/ImagePlugin.svelte +56 -84
  168. package/dist/plugins/image/ImagePlugin.svelte.d.ts +13 -1
  169. package/dist/plugins/image/controls.svelte.js +16 -2
  170. package/dist/plugins/image/image.css +17 -0
  171. package/dist/plugins/image/toolbar.svelte.d.ts +5 -4
  172. package/dist/plugins/image/toolbar.svelte.js +21 -31
  173. package/dist/plugins/index.d.ts +4 -5
  174. package/dist/plugins/index.js +0 -1
  175. package/dist/plugins/list.svelte.d.ts +9 -0
  176. package/dist/plugins/list.svelte.js +18 -0
  177. package/dist/plugins/markdownShortcuts.js +5 -5
  178. package/dist/plugins/marquee/marqueePlugin.js +0 -4
  179. package/dist/plugins/media/AudioPlugin.svelte +13 -1
  180. package/dist/plugins/media/AudioPlugin.svelte.d.ts +11 -1
  181. package/dist/plugins/media/BookmarkPlugin.svelte +6 -97
  182. package/dist/plugins/media/EmbedPlugin.svelte +5 -90
  183. package/dist/plugins/media/EmptySlot.svelte +36 -20
  184. package/dist/plugins/media/EmptySlot.svelte.d.ts +6 -15
  185. package/dist/plugins/media/FilePlugin.svelte +12 -20
  186. package/dist/plugins/media/FilePlugin.svelte.d.ts +9 -0
  187. package/dist/plugins/media/MediaEmpty.svelte +2 -55
  188. package/dist/plugins/media/MediaEmpty.svelte.d.ts +18 -14
  189. package/dist/plugins/media/SourceBlock.svelte +178 -52
  190. package/dist/plugins/media/SourceBlock.svelte.d.ts +13 -6
  191. package/dist/plugins/media/UploadPreview.svelte +32 -0
  192. package/dist/plugins/media/UploadPreview.svelte.d.ts +11 -0
  193. package/dist/plugins/media/VideoPlugin.svelte +13 -1
  194. package/dist/plugins/media/VideoPlugin.svelte.d.ts +11 -1
  195. package/dist/plugins/media/empty.svelte.d.ts +13 -4
  196. package/dist/plugins/media/empty.svelte.js +32 -26
  197. package/dist/plugins/media/media.d.ts +9 -63
  198. package/dist/plugins/media/media.js +1 -194
  199. package/dist/plugins/media/sources.d.ts +60 -0
  200. package/dist/plugins/media/sources.js +165 -0
  201. package/dist/plugins/media/upload.css +23 -0
  202. package/dist/plugins/media/urlPaste.svelte.d.ts +2 -1
  203. package/dist/plugins/media/urlPaste.svelte.js +12 -21
  204. package/dist/plugins/mention/MentionPlugin.svelte +50 -38
  205. package/dist/plugins/mention/MentionPlugin.svelte.d.ts +11 -2
  206. package/dist/plugins/mention/mention.css +6 -0
  207. package/dist/plugins/page/PagePlugin.svelte +2 -9
  208. package/dist/plugins/page/page.js +1 -1
  209. package/dist/plugins/pageLink/PageLinkPlugin.svelte +126 -28
  210. package/dist/plugins/pageLink/PageLinkPlugin.svelte.d.ts +13 -1
  211. package/dist/plugins/pageLink/pageLink.css +6 -0
  212. package/dist/plugins/richtext/RichTextPlugin.svelte +99 -204
  213. package/dist/plugins/richtext/RichTextPlugin.svelte.d.ts +1 -0
  214. package/dist/plugins/richtext/body.js +1 -1
  215. package/dist/plugins/richtext/calloutIcons.svelte.d.ts +2 -2
  216. package/dist/plugins/richtext/calloutIcons.svelte.js +5 -7
  217. package/dist/plugins/richtext/richTextOperations.d.ts +1 -19
  218. package/dist/plugins/richtext/richTextOperations.js +3 -49
  219. package/dist/plugins/richtext/richtext.css +6 -0
  220. package/dist/plugins/slashMenu/SlashMenuController.svelte.d.ts +2 -0
  221. package/dist/plugins/slashMenu/SlashMenuController.svelte.js +7 -0
  222. package/dist/plugins/slashMenu/slashMenuPlugin.js +5 -14
  223. package/dist/plugins/table/TableChrome.svelte +2 -3
  224. package/dist/plugins/table/TablePlugin.svelte +20 -54
  225. package/dist/plugins/table/chrome.svelte.d.ts +5 -2
  226. package/dist/plugins/table/chrome.svelte.js +33 -56
  227. package/dist/plugins/table/table.js +3 -3
  228. package/dist/plugins/toc/TocPlugin.svelte +2 -4
  229. package/dist/plugins/toolbar/ToolbarController.svelte.d.ts +7 -0
  230. package/dist/plugins/toolbar/ToolbarController.svelte.js +20 -13
  231. package/dist/plugins/toolbar/toolbarPlugin.js +19 -53
  232. package/dist/plugins/triggers/TriggerController.svelte.d.ts +7 -2
  233. package/dist/plugins/triggers/TriggerController.svelte.js +11 -4
  234. package/dist/plugins/triggers/place.js +1 -2
  235. package/dist/plugins/triggers/triggers.d.ts +6 -1
  236. package/dist/plugins/triggers/triggers.js +12 -13
  237. package/dist/plugins/uploads.svelte.d.ts +48 -32
  238. package/dist/plugins/uploads.svelte.js +119 -43
  239. package/dist/plugins.d.ts +66 -14
  240. package/dist/plugins.js +0 -24
  241. package/dist/selection/replaceSelection.js +2 -2
  242. package/dist/selection/selection.svelte.d.ts +4 -10
  243. package/dist/selection/selection.svelte.js +7 -11
  244. package/dist/session/attempt.d.ts +16 -6
  245. package/dist/session/attempt.js +1 -0
  246. package/dist/session/bindings.js +35 -32
  247. package/dist/session/commands.d.ts +7 -11
  248. package/dist/session/commands.js +15 -19
  249. package/dist/session/history.js +1 -0
  250. package/dist/session/inputRules.d.ts +6 -3
  251. package/dist/session/inputRules.js +10 -6
  252. package/dist/session/moves.d.ts +33 -0
  253. package/dist/session/moves.js +71 -1
  254. package/dist/session/navigation.d.ts +7 -0
  255. package/dist/session/navigation.js +20 -11
  256. package/dist/session/props.d.ts +28 -0
  257. package/dist/session/props.js +65 -0
  258. package/dist/session/suggestions.svelte.d.ts +0 -11
  259. package/dist/session/suggestions.svelte.js +15 -3
  260. package/dist/session/uploads.d.ts +29 -0
  261. package/dist/session/uploads.js +10 -0
  262. package/dist/surface/lines.js +1 -3
  263. package/dist/surface/observer.svelte.d.ts +17 -1
  264. package/dist/surface/observer.svelte.js +72 -17
  265. package/dist/surface/overlay.d.ts +0 -14
  266. package/dist/surface/overlay.js +0 -25
  267. package/dist/surface/projector.svelte.js +1 -1
  268. package/dist/text/text.svelte.js +3 -13
  269. package/dist/themes/notion.css +9 -0
  270. package/dist/utils/sanitize.d.ts +38 -0
  271. package/dist/utils/sanitize.js +82 -0
  272. package/dist/utils.d.ts +2 -0
  273. package/dist/utils.js +5 -0
  274. package/package.json +18 -1
  275. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/max-z-index.js +0 -3
  276. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop/util/supports-popover.js +0 -16
  277. package/dist/dnd/vendor/pragmatic/pragmatic-drag-and-drop-auto-scroll/shared/is-axis-allowed.js +0 -3
  278. package/dist/plugins/code/LanguageMenu.svelte +0 -25
  279. package/dist/plugins/code/LanguageMenu.svelte.d.ts +0 -9
  280. package/dist/plugins/equation/EquationEditor.svelte +0 -27
  281. package/dist/plugins/equation/EquationEditor.svelte.d.ts +0 -9
  282. package/dist/plugins/image/ImageToolbarHost.svelte +0 -37
  283. package/dist/plugins/image/ImageToolbarHost.svelte.d.ts +0 -9
  284. package/dist/plugins/richtext/CalloutIconPicker.svelte +0 -26
  285. package/dist/plugins/richtext/CalloutIconPicker.svelte.d.ts +0 -9
  286. /package/dist/{plugins/columns → dnd}/stacking.d.ts +0 -0
  287. /package/dist/{plugins/columns → dnd}/stacking.js +0 -0
@@ -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';
@@ -1,8 +1,7 @@
1
1
  import { canScrollOnEdge } from '../shared/can-scroll-on-edge.js';
2
- import { edgeAxisLookup, edges } from '../shared/edges.js';
2
+ import { edges } from '../shared/edges.js';
3
3
  import { getOverElementHitbox } from '../shared/get-over-element-hitbox.js';
4
4
  import { getScrollChange } from '../shared/get-scroll-change.js';
5
- import { isAxisAllowed } from '../shared/is-axis-allowed.js';
6
5
  import { isWithin } from '../shared/is-within.js';
7
6
  function getRectDefault(element) {
8
7
  return element.getBoundingClientRect();
@@ -13,7 +12,6 @@ export function getScrollBy({
13
12
  timeSinceLastFrame,
14
13
  engagement,
15
14
  config,
16
- allowedAxis,
17
15
  getRect = getRectDefault
18
16
  }) {
19
17
  const client = {
@@ -26,15 +24,6 @@ export function getScrollBy({
26
24
  clientRect,
27
25
  config
28
26
  });
29
- const axis = edgeAxisLookup[edge];
30
-
31
- // Note: changing the allowed axis during a drag will not
32
- // reset time dampening. It was decided it would be too
33
- // complex to implement initially, and we can add it
34
- // later if needed.
35
- if (!isAxisAllowed(axis, allowedAxis)) {
36
- return map;
37
- }
38
27
  if (!isWithin({
39
28
  client,
40
29
  clientRect: hitbox
@@ -50,66 +39,21 @@ export function getScrollBy({
50
39
  });
51
40
  return map;
52
41
  }, new Map());
53
- const left = (() => {
54
- const axis = 'horizontal';
55
- const leftEdge = scrollableEdges.get('left');
56
- if (leftEdge) {
57
- return getScrollChange({
58
- client,
59
- edge: leftEdge.edge,
60
- hitbox: leftEdge.hitbox,
61
- axis,
62
- timeSinceLastFrame,
63
- engagement,
64
- isDistanceDampeningEnabled: true,
65
- config
66
- });
67
- }
68
- const rightEdge = scrollableEdges.get('right');
69
- if (rightEdge) {
70
- return getScrollChange({
71
- client,
72
- edge: rightEdge.edge,
73
- hitbox: rightEdge.hitbox,
74
- axis,
75
- timeSinceLastFrame,
76
- engagement,
77
- isDistanceDampeningEnabled: true,
78
- config
79
- });
80
- }
81
- return 0;
82
- })();
83
- const top = (() => {
84
- const axis = 'vertical';
85
- const bottomEdge = scrollableEdges.get('bottom');
86
- if (bottomEdge) {
87
- return getScrollChange({
88
- client,
89
- edge: bottomEdge.edge,
90
- hitbox: bottomEdge.hitbox,
91
- axis,
92
- timeSinceLastFrame,
93
- engagement,
94
- isDistanceDampeningEnabled: true,
95
- config
96
- });
97
- }
98
- const topEdge = scrollableEdges.get('top');
99
- if (topEdge) {
100
- return getScrollChange({
101
- client,
102
- edge: topEdge.edge,
103
- hitbox: topEdge.hitbox,
104
- axis,
105
- timeSinceLastFrame,
106
- engagement,
107
- isDistanceDampeningEnabled: true,
108
- config
109
- });
110
- }
111
- return 0;
112
- })();
42
+ // edytor: one change per axis, the first of its edges the pointer is over.
43
+ const change = (axis, first, second) => {
44
+ const entry = scrollableEdges.get(first) ?? scrollableEdges.get(second);
45
+ return entry ? getScrollChange({
46
+ client,
47
+ edge: entry.edge,
48
+ hitbox: entry.hitbox,
49
+ axis,
50
+ timeSinceLastFrame,
51
+ engagement,
52
+ config
53
+ }) : 0;
54
+ };
55
+ const left = change('horizontal', 'left', 'right');
56
+ const top = change('vertical', 'bottom', 'top');
113
57
  return {
114
58
  left,
115
59
  top
@@ -1,4 +1,4 @@
1
- import { getInternalConfig } from '../shared/configuration.js';
1
+ import { internalConfig as config } from '../shared/configuration.js';
2
2
  import { markAndGetEngagement } from '../shared/engagement-history.js';
3
3
  import { selector } from './data-attributes.js';
4
4
  import { getScrollBy } from './get-scroll-by.js';
@@ -16,7 +16,6 @@ function tryScrollElements({
16
16
  left: true
17
17
  }
18
18
  }) {
19
- var _container$getConfigu, _container$getAllowed, _container$getAllowed2;
20
19
  // we cannot do any more scrolling
21
20
  if (!isScrollingAvailable(available)) {
22
21
  return available;
@@ -64,14 +63,11 @@ function tryScrollElements({
64
63
  // Marking engagement even if no edges are scrollable.
65
64
  // We are marking engagement as soon as the element is scrolled over
66
65
  const engagement = markAndGetEngagement(element);
67
- const config = getInternalConfig((_container$getConfigu = container.getConfiguration) === null || _container$getConfigu === void 0 ? void 0 : _container$getConfigu.call(container, feedback));
68
- const allowedAxis = (_container$getAllowed = (_container$getAllowed2 = container.getAllowedAxis) === null || _container$getAllowed2 === void 0 ? void 0 : _container$getAllowed2.call(container, feedback)) !== null && _container$getAllowed !== void 0 ? _container$getAllowed : 'all';
69
66
  const scrollBy = getScrollBy({
70
67
  element,
71
68
  engagement,
72
69
  input,
73
70
  timeSinceLastFrame,
74
- allowedAxis,
75
71
  config
76
72
  });
77
73
 
@@ -111,7 +107,6 @@ function tryScrollWindow({
111
107
  element
112
108
  };
113
109
  for (const entry of entries) {
114
- var _entry$getConfigurati, _entry$getAllowedAxis, _entry$getAllowedAxis2;
115
110
  // this entry is not allowing scrolling, we need to look for another
116
111
  if (entry.canScroll && !entry.canScroll(feedback)) {
117
112
  continue;
@@ -120,14 +115,11 @@ function tryScrollWindow({
120
115
  // Note: if we had an event for when the user is leaving a tab
121
116
  // we _could_ conceptually reset the engagement
122
117
  const engagement = markAndGetEngagement(element);
123
- const config = getInternalConfig((_entry$getConfigurati = entry.getConfiguration) === null || _entry$getConfigurati === void 0 ? void 0 : _entry$getConfigurati.call(entry, feedback));
124
- const allowedAxis = (_entry$getAllowedAxis = (_entry$getAllowedAxis2 = entry.getAllowedAxis) === null || _entry$getAllowedAxis2 === void 0 ? void 0 : _entry$getAllowedAxis2.call(entry, feedback)) !== null && _entry$getAllowedAxis !== void 0 ? _entry$getAllowedAxis : 'all';
125
118
  const scrollBy = getScrollBy({
126
119
  element,
127
120
  engagement,
128
121
  input,
129
122
  config,
130
- allowedAxis,
131
123
  getRect: element => DOMRect.fromRect({
132
124
  y: 0,
133
125
  x: 0,
@@ -17,33 +17,8 @@ const baseConfig = {
17
17
  maxMainAxisHitboxSize: 180
18
18
  };
19
19
 
20
- /** What the max scroll should be per second. Using "per second" rather than "per frame"
21
- * as we want a consistent scroll speed regardless of frame rate.
22
- *
23
- *
24
- * I explored trying to make the max scroll speed dynamic based on particular factors.
25
- * However, it ended up being difficult to find a _perfect_ formula.
26
- *
27
- * Likely the perfect answer would involve:
28
- * - the size of the scrollable element
29
- * - the size of the scrollable element relative to the screen size
30
- * - the size of the drag preview
31
- * - the size of elements being scrolled in scrollable elements (expensive and difficult to compute)
32
- */
33
- const maxPixelScrollPerSecond = {
34
- // What the value would be if we were scrolling at 15px per frame at 60fps.
35
- // This is the default as it works well for most experiences.
36
- // In certain scenarios though it can feel a bit slow.
37
- standard: 15 * 60,
38
- // What the value would be if we were scrolling at 25px per frame at 60fps.
39
- // This is not the default as it feels too fast for a lot of experiences.
40
- fast: 25 * 60
20
+ // edytor: no element sets `getConfiguration`: the standard speed only.
21
+ export const internalConfig = {
22
+ ...baseConfig,
23
+ maxPixelScrollPerSecond: 15 * 60
41
24
  };
42
- export function getInternalConfig(provided) {
43
- var _provided$maxScrollSp;
44
- return {
45
- ...baseConfig,
46
- // only allowing limited control over the config at this stage
47
- maxPixelScrollPerSecond: maxPixelScrollPerSecond[(_provided$maxScrollSp = provided === null || provided === void 0 ? void 0 : provided.maxScrollSpeed) !== null && _provided$maxScrollSp !== void 0 ? _provided$maxScrollSp : 'standard']
48
- };
49
- }
@@ -62,7 +62,6 @@ export function getScrollChange({
62
62
  axis,
63
63
  hitbox,
64
64
  edge,
65
- isDistanceDampeningEnabled,
66
65
  config
67
66
  }) {
68
67
  // We have two forms of speed dampening:
@@ -77,13 +76,13 @@ export function getScrollChange({
77
76
  timeSinceLastFrame,
78
77
  config
79
78
  });
80
- const percentageDistanceDampening = isDistanceDampeningEnabled ? getDistanceDampening({
79
+ const percentageDistanceDampening = getDistanceDampening({
81
80
  client,
82
81
  edge,
83
82
  hitbox,
84
83
  axis,
85
84
  config
86
- }) : 1;
85
+ });
87
86
 
88
87
  // Dampen speed by time
89
88
  const percentageThroughTimeDampening = getPercentageInRange({
@@ -18,6 +18,15 @@ import { Dispatcher } from './session/commands.js';
18
18
  import { type KindRow } from './kinds.js';
19
19
  export type EdytorOptions = {
20
20
  readonly?: boolean;
21
+ /**
22
+ * Let users nest blocks under other blocks (default `false`): Tab and
23
+ * Shift+Tab nest and unnest, a drop or a handle's Alt+→ may place a block
24
+ * inside another. Off, those gestures nest nothing and Tab is left to the
25
+ * browser (the focus moves on); containers (lists, toggles, callouts,
26
+ * columns) keep their bodies, and nested blocks already in the document
27
+ * still render and edit.
28
+ */
29
+ allowNesting?: boolean;
21
30
  /** Chords (`mod+s`, `shift+alt+enter`) the view binds before plugins and built-ins. */
22
31
  hotkeys?: Partial<Record<HotKeyCombination, HotKey>>;
23
32
  plugins?: Plugin[];
@@ -25,12 +34,9 @@ export type EdytorOptions = {
25
34
  * The assembled document this view renders — shared facade, history,
26
35
  * awareness and semantics live on it (see `crdt/document.ts`). When
27
36
  * injected the view borrows it: `destroy()` releases only view-owned
28
- * resources. When absent the view internally owns a document built
29
- * around `doc`/`awareness` (the legacy path — same behavior as before).
37
+ * resources. When absent the view owns a fresh one.
30
38
  */
31
39
  document?: EdytorDocument;
32
- doc?: YDoc;
33
- awareness?: Awareness;
34
40
  /** The local author of a view-owned document (with `document`, set it there). */
35
41
  actor?: DocumentActor;
36
42
  /** A view-owned document's `requireHydration` (with `document`, set it there). */
@@ -100,11 +106,13 @@ export declare class Edytor {
100
106
  /** What the components render: one cell per visible block, patched from change reports. */
101
107
  cells: Cells | undefined;
102
108
  /**
103
- * The document's properties, read-your-writes and reactive. Write them
104
- * with `edytor.patchData(null, patches)`. Type them by augmenting
105
- * {@link EdytorDocData}.
109
+ * The document's properties, as plain state: reactive at any depth, and
110
+ * writable (`edytor.data.title = 'Notes'`, `edytor.data.tags.push('x')`,
111
+ * `delete edytor.data.draft`). Each write is the `patchData` operation,
112
+ * dispatched; the writes of one task are one undo step. Type them by
113
+ * augmenting {@link EdytorDocData}.
106
114
  */
107
- get data(): Readonly<EdytorDocData>;
115
+ get data(): EdytorDocData;
108
116
  /** The chrome layer outside the host: handles, menus, remote carets. */
109
117
  readonly overlay: Overlay;
110
118
  /** The chrome popups open on this view (`surface/popups`): what the root's ARIA names. */
@@ -113,6 +121,8 @@ export declare class Edytor {
113
121
  readonly announcer: AnnouncerState;
114
122
  /** The words the view was given (`<Edytor labels>`); its plugins read their section through `labelsOf`. */
115
123
  readonly labels: PartialLabels;
124
+ /** Whether users may nest blocks (`allowNesting`, read once; the rule is `session/moves.ts` `nestsInto`). */
125
+ readonly allowNesting: boolean;
116
126
  private off;
117
127
  private onChange?;
118
128
  private onDocChange?;
@@ -208,7 +218,7 @@ export declare class Edytor {
208
218
  * discarded.
209
219
  *
210
220
  * Releases every listener the editor holds on potentially-SHARED objects
211
- * — an injected doc/awareness outlives a single editor, so an
221
+ * — an injected document outlives a single editor, so an
212
222
  * undestroyed mount leaks a facade `update` listener and the undo
213
223
  * manager's doc observers forever.
214
224
  *