edytor 1.0.0 → 2.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 (116) hide show
  1. package/README.md +14 -72
  2. package/dist/block/block.svelte.d.ts +6 -4
  3. package/dist/block/block.svelte.js +10 -4
  4. package/dist/block/inlineBlock.svelte.d.ts +6 -2
  5. package/dist/block/inlineBlock.svelte.js +7 -2
  6. package/dist/cloudflare/room/context.d.ts +6 -0
  7. package/dist/collaboration/awarenessSelection.d.ts +22 -1
  8. package/dist/collaboration/awarenessSelection.js +42 -0
  9. package/dist/components/Block.svelte +3 -1
  10. package/dist/components/Edytor.svelte +36 -10
  11. package/dist/components/Edytor.svelte.d.ts +8 -1
  12. package/dist/components/InlineBlock.svelte +1 -1
  13. package/dist/crdt/data.d.ts +10 -0
  14. package/dist/crdt/data.js +20 -2
  15. package/dist/crdt/doc/reads.d.ts +7 -0
  16. package/dist/crdt/doc/reads.js +11 -1
  17. package/dist/crdt/document.d.ts +8 -0
  18. package/dist/crdt/document.js +12 -0
  19. package/dist/crdt/edytor-doc.d.ts +18 -0
  20. package/dist/crdt/edytor-doc.js +2 -1
  21. package/dist/crdt/index.d.ts +6 -0
  22. package/dist/crdt/operations.d.ts +1 -1
  23. package/dist/crdt/operations.js +1 -0
  24. package/dist/crdt/props.d.ts +32 -0
  25. package/dist/crdt/props.js +172 -0
  26. package/dist/{plugins/blockHandles → dnd}/dropIndicator.d.ts +2 -2
  27. package/dist/{plugins/blockHandles → dnd}/geometry.d.ts +2 -2
  28. package/dist/dnd/placement.d.ts +200 -0
  29. package/dist/dnd/placement.js +426 -0
  30. package/dist/edytor.svelte.d.ts +17 -4
  31. package/dist/edytor.svelte.js +16 -7
  32. package/dist/events/beforeInputCommands.d.ts +2 -2
  33. package/dist/events/beforeInputCommands.js +8 -4
  34. package/dist/events/onDrop.d.ts +6 -0
  35. package/dist/events/onDrop.js +38 -10
  36. package/dist/events/onPaste.d.ts +2 -1
  37. package/dist/events/onPaste.js +8 -3
  38. package/dist/index.d.ts +2 -2
  39. package/dist/index.js +1 -1
  40. package/dist/labels.d.ts +2 -0
  41. package/dist/labels.js +2 -1
  42. package/dist/plugins/arrowMove/arrowMove.d.ts +1 -1
  43. package/dist/plugins/arrowMove/arrowMove.js +1 -1
  44. package/dist/plugins/blockHandles/BlockHandleController.svelte.d.ts +2 -122
  45. package/dist/plugins/blockHandles/BlockHandleController.svelte.js +29 -387
  46. package/dist/plugins/blockHandles/BlockHandles.svelte +14 -32
  47. package/dist/plugins/blockHandles/blockHandlesPlugin.js +2 -1
  48. package/dist/plugins/code/CodeHeader.svelte +5 -3
  49. package/dist/plugins/code/CodePlugin.svelte +3 -3
  50. package/dist/plugins/code/languages.d.ts +0 -3
  51. package/dist/plugins/code/languages.js +0 -2
  52. package/dist/plugins/columns/ColumnResize.svelte +3 -2
  53. package/dist/plugins/columns/ColumnsPlugin.svelte +1 -1
  54. package/dist/plugins/columns/gaps.d.ts +7 -5
  55. package/dist/plugins/columns/gaps.js +11 -6
  56. package/dist/plugins/columns/resize.svelte.d.ts +3 -3
  57. package/dist/plugins/columns/resize.svelte.js +11 -10
  58. package/dist/plugins/equation/EquationPlugin.svelte +1 -8
  59. package/dist/plugins/equation/EquationPlugin.svelte.d.ts +1 -0
  60. package/dist/plugins/equation/equation.css +7 -0
  61. package/dist/plugins/fileDrop.d.ts +28 -0
  62. package/dist/plugins/fileDrop.js +116 -0
  63. package/dist/plugins/image/ImagePlugin.svelte +42 -33
  64. package/dist/plugins/image/ImagePlugin.svelte.d.ts +13 -1
  65. package/dist/plugins/image/image.css +17 -0
  66. package/dist/plugins/index.d.ts +3 -4
  67. package/dist/plugins/index.js +0 -1
  68. package/dist/plugins/markdownShortcuts.js +5 -5
  69. package/dist/plugins/media/AudioPlugin.svelte +13 -1
  70. package/dist/plugins/media/AudioPlugin.svelte.d.ts +11 -1
  71. package/dist/plugins/media/FilePlugin.svelte +11 -1
  72. package/dist/plugins/media/FilePlugin.svelte.d.ts +9 -0
  73. package/dist/plugins/media/SourceBlock.svelte +48 -12
  74. package/dist/plugins/media/SourceBlock.svelte.d.ts +4 -3
  75. package/dist/plugins/media/UploadPreview.svelte +32 -0
  76. package/dist/plugins/media/UploadPreview.svelte.d.ts +11 -0
  77. package/dist/plugins/media/VideoPlugin.svelte +13 -1
  78. package/dist/plugins/media/VideoPlugin.svelte.d.ts +11 -1
  79. package/dist/plugins/media/empty.svelte.d.ts +13 -4
  80. package/dist/plugins/media/empty.svelte.js +30 -19
  81. package/dist/plugins/media/media.d.ts +7 -0
  82. package/dist/plugins/media/upload.css +23 -0
  83. package/dist/plugins/mention/MentionPlugin.svelte +72 -33
  84. package/dist/plugins/mention/MentionPlugin.svelte.d.ts +11 -2
  85. package/dist/plugins/mention/mention.css +6 -0
  86. package/dist/plugins/pageLink/PageLinkPlugin.svelte +122 -17
  87. package/dist/plugins/pageLink/PageLinkPlugin.svelte.d.ts +13 -1
  88. package/dist/plugins/pageLink/pageLink.css +6 -0
  89. package/dist/plugins/richtext/RichTextPlugin.svelte +14 -7
  90. package/dist/plugins/richtext/RichTextPlugin.svelte.d.ts +1 -0
  91. package/dist/plugins/richtext/richtext.css +6 -0
  92. package/dist/plugins/table/chrome.svelte.js +4 -3
  93. package/dist/plugins/uploads.svelte.d.ts +45 -32
  94. package/dist/plugins/uploads.svelte.js +105 -39
  95. package/dist/plugins.d.ts +40 -14
  96. package/dist/session/attempt.d.ts +16 -6
  97. package/dist/session/attempt.js +1 -0
  98. package/dist/session/bindings.js +34 -31
  99. package/dist/session/commands.js +2 -0
  100. package/dist/session/history.js +1 -0
  101. package/dist/session/inputRules.d.ts +6 -3
  102. package/dist/session/inputRules.js +9 -5
  103. package/dist/session/moves.d.ts +33 -0
  104. package/dist/session/moves.js +71 -1
  105. package/dist/session/navigation.d.ts +7 -0
  106. package/dist/session/navigation.js +19 -10
  107. package/dist/session/props.d.ts +28 -0
  108. package/dist/session/props.js +65 -0
  109. package/dist/session/uploads.d.ts +29 -0
  110. package/dist/session/uploads.js +10 -0
  111. package/dist/themes/notion.css +9 -0
  112. package/package.json +1 -1
  113. /package/dist/{plugins/blockHandles → dnd}/dropIndicator.js +0 -0
  114. /package/dist/{plugins/blockHandles → dnd}/geometry.js +0 -0
  115. /package/dist/{plugins/columns → dnd}/stacking.d.ts +0 -0
  116. /package/dist/{plugins/columns → dnd}/stacking.js +0 -0
@@ -3,15 +3,19 @@ import { runOccurrence } from './onBeforeInput.js';
3
3
  import { createEdytorClipboardFragment, writeEdytorClipboardData } from '../clipboard/clipboard.js';
4
4
  import { endTextDrag, startTextDrag, textDragOf } from '../clipboard/moveText.js';
5
5
  import { caretAtPoint, getDomSelection } from '../selection/domSelection.js';
6
+ import { viewUploads } from '../session/uploads.js';
6
7
  /**
7
8
  * Payloads the editor can consume on drop. Preventing `dragover` is what
8
9
  * enables a drop, so it is prevented only for these types — internal and
9
10
  * unsupported drags keep the browser's not-allowed affordance and can never
10
11
  * produce a native DOM mutation.
11
12
  *
12
- * `Files` is intentionally accepted: file drops route through the plugin
13
- * `onPaste` hook (the Files → image seam: the image plugin with `upload`
14
- * claims image files; unclaimed files insert nothing).
13
+ * `Files` is intentionally accepted (so the browser never opens a dropped
14
+ * file in place of the page): with the view's uploads (a media plugin given
15
+ * an `upload`), file drops route through the plugin `onPaste` hook with the
16
+ * drop indicator's placement (`ViewUploads.drop`: a block per file the kinds
17
+ * take there; unclaimed files insert nothing); without them a drop carrying
18
+ * files is ignored, its effect `none`.
15
19
  */
16
20
  const ACCEPTED_FOREIGN_DROP_TYPES = ['Files', 'text/html', 'text/plain', 'text/uri-list'];
17
21
  /**
@@ -121,8 +125,8 @@ const isAcceptedForeignDrop = (root, dataTransfer) => {
121
125
  // Preventing the drop suppresses the browser's own `insertFromDrop`
122
126
  // beforeinput, so the accepted payload is the occurrence itself — the same
123
127
  // routing as `insertFromPaste`, with the drop point as its declared target
124
- // range (`caretAtPoint`).
125
- const insertFromDrop = (edytor, root, event) => {
128
+ // range (`caretAtPoint`); files carry the indicator's placement (`at`).
129
+ const insertFromDrop = (edytor, root, event, placement = null) => {
126
130
  const at = caretAtPoint(root.ownerDocument, event.clientX, event.clientY);
127
131
  const point = at &&
128
132
  new StaticRange({
@@ -135,6 +139,7 @@ const insertFromDrop = (edytor, root, event) => {
135
139
  inputType: 'insertFromDrop',
136
140
  dataTransfer: event.dataTransfer,
137
141
  declared: point && root.contains(point.startContainer) ? point : null,
142
+ placement,
138
143
  cancelable: true
139
144
  });
140
145
  };
@@ -176,22 +181,33 @@ export const preventUnsupportedDrop = (event, edytor) => {
176
181
  drag.dropping = true;
177
182
  return insertFromDrop(edytor, root, event);
178
183
  }
184
+ const files = typesOf(event.dataTransfer).includes('Files');
185
+ // The view's uploads take dropped files (a media plugin given an `upload`); none: ignored.
186
+ const drop = files ? viewUploads(edytor)?.drop : undefined;
179
187
  if (event.type === 'dragover') {
180
188
  if (isAcceptedForeignDrop(root, event.dataTransfer)) {
181
189
  event.preventDefault();
182
190
  event.stopPropagation();
183
- if (event.dataTransfer) {
184
- event.dataTransfer.dropEffect = 'copy';
185
- }
191
+ // Files show where they land (the block drag's indicator); none in a
192
+ // read-only view or one without uploads, which takes no file drop (the
193
+ // browser must not open the file).
194
+ const shown = drop && !ownsEvent(root, event) && drop.over(event);
195
+ if (event.dataTransfer)
196
+ event.dataTransfer.dropEffect = files && (edytor.readonly || !drop) ? 'none' : 'copy';
197
+ if (drop && !shown)
198
+ drop.end();
186
199
  }
187
200
  return;
188
201
  }
189
202
  const accepted = isAcceptedForeignDrop(root, event.dataTransfer);
203
+ // Where the files land: the indicator's placement, re-resolved at the drop point.
204
+ const at = drop && accepted && !ownsEvent(root, event) ? drop.at(event) : null;
205
+ drop?.end();
190
206
  if (accepted && isControlDrop(root, event))
191
207
  return;
192
208
  event.preventDefault();
193
209
  event.stopPropagation();
194
- if (!accepted) {
210
+ if (!accepted || (files && (edytor.readonly || !drop))) {
195
211
  return;
196
212
  }
197
213
  if (ownsEvent(root, event) || isNativeInteractiveControl(event.target)) {
@@ -201,5 +217,17 @@ export const preventUnsupportedDrop = (event, edytor) => {
201
217
  }
202
218
  // Mid-composition drops are swallowed: the preview owns the write path.
203
219
  if (!edytor.isComposing)
204
- return insertFromDrop(edytor, root, event);
220
+ return insertFromDrop(edytor, root, event, at);
221
+ };
222
+ /**
223
+ * A drag leaving the host (to the page around it, or out of the window):
224
+ * a file drag's indicator goes. Moving between the host's own elements is
225
+ * no leave.
226
+ */
227
+ export const onDragLeave = (edytor, event) => {
228
+ const root = event.currentTarget;
229
+ const to = event.relatedTarget;
230
+ if (to instanceof Node && root.contains(to))
231
+ return;
232
+ viewUploads(edytor)?.drop.end();
205
233
  };
@@ -6,7 +6,8 @@ import type { Edytor } from '../edytor.svelte.js';
6
6
  * the document AND cancel its paste) or under a live composition (its
7
7
  * preview owns the write path: the browser pastes, the observer reconciles
8
8
  * it after the end, as PM input.ts:656-660). Else, unless Shift asks for
9
- * plain text: an Edytor fragment; what an extension's `onPaste` claims; a
9
+ * plain text: an Edytor fragment; what an extension's `onPaste` claims (the
10
+ * `pasteFirst` ones first, then list order); a
10
11
  * file nothing claimed inserts nothing (the Files → image seam), never its
11
12
  * name; external HTML (HTML that carries nothing falls through); markdown
12
13
  * text as its blocks (`paste.markdown`), except in a code block's lines.
@@ -54,7 +54,8 @@ const syncCollapsedDomCaretForPaste = (edytor) => {
54
54
  * the document AND cancel its paste) or under a live composition (its
55
55
  * preview owns the write path: the browser pastes, the observer reconciles
56
56
  * it after the end, as PM input.ts:656-660). Else, unless Shift asks for
57
- * plain text: an Edytor fragment; what an extension's `onPaste` claims; a
57
+ * plain text: an Edytor fragment; what an extension's `onPaste` claims (the
58
+ * `pasteFirst` ones first, then list order); a
58
59
  * file nothing claimed inserts nothing (the Files → image seam), never its
59
60
  * name; external HTML (HTML that carries nothing falls through); markdown
60
61
  * text as its blocks (`paste.markdown`), except in a code block's lines.
@@ -70,8 +71,12 @@ export async function onPaste(e) {
70
71
  if (!(shiftPasteModifierHeld && plain)) {
71
72
  const fragment = readEdytorClipboardFragment(data);
72
73
  if (!fragment) {
73
- const claimed = (plugin) => vetoable((prevent) => plugin.onPaste?.({ prevent, e }));
74
- if (this.dispatcher.intercept(claimed, () => e.preventDefault()))
74
+ // The `pasteFirst` hooks (a pasted reference: page link's `fromPaste`), then the
75
+ // others in list order; the first that prevents claims the paste.
76
+ const claimed = (first) => (plugin) => !!plugin.pasteFirst === first && vetoable((prevent) => plugin.onPaste?.({ prevent, e }));
77
+ const stop = () => e.preventDefault();
78
+ if (this.dispatcher.intercept(claimed(true), stop) ||
79
+ this.dispatcher.intercept(claimed(false), stop))
75
80
  return;
76
81
  if (data?.files?.length)
77
82
  return e.preventDefault();
package/dist/index.d.ts CHANGED
@@ -42,7 +42,7 @@ export type { CommandResult } from './session/commands.js';
42
42
  export { convertToKind, turnCommands, wrapBlocks, wrappable, type KindRow } from './kinds.js';
43
43
  export { textToBlocks, type TextToBlocksOptions } from './clipboard/textBlocks.js';
44
44
  export type { Suggestion, Suggestions, SuggestionAt, SuggestionContent, SuggestionOptions, SuggestionRange, SuggestionStatus, SuggestionsAt, ResolvedAt } from './session/suggestions.svelte.js';
45
- export { createRichTextPlugin, richTextOperations, richTextPlaceholder, CALLOUT_ICONS, createCalloutIconsPlugin, createUploadsPlugin, type UploadsOptions, type CalloutIconPicker, type CalloutIconsOptions, type RichTextPluginOptions, type TodoCheckboxPayload, type CalloutIconPayload, type EmptyBodyPayload, createArrowMovePlugin, createCodePlugin, CODE_LANGUAGES, loadCodeLanguage, type CodeLanguage, type CodePluginOptions, type CodeHeader, type LanguageMenu, type LanguageMenuItem, type LanguageRow, createMarkdownShortcutsPlugin, createMentionPlugin, type MentionItem, type MentionData, type MentionPluginOptions, createPageLinkPlugin, type PageLinkItem, type PageLinkData, type PageLinkPluginOptions, type TriggerMenuController, withRulesAndTriggers, BLOCK_ACTIVATE_EVENT, BLOCK_ADD_EVENT, type BlockActivation, type BlockAddition, createBlockHandlesPlugin, type BlockHandlesOptions, type BlockHandleSnippetPayload, type BlockHandleController, createSlashMenuPlugin, type SlashMenuOptions, type SlashMenuController, createToolbarPlugin, type ToolbarOptions, type ToolbarController, createBlockMenuPlugin, type BlockMenuOptions, type BlockMenuController, type BlockMenuAction, type BlockMenuColor, createSuggestionsPlugin, createSuggestionBarPlugin, type SuggestionBarOptions, type SuggestionBarPayload, createImagePlugin, safeImageSrc, storableImageSrc, MAX_INLINE_IMAGE_BYTES, createColumnsPlugin, type ColumnsPluginOptions, createEmbedPlugin, EMBED_PROVIDERS, EMBED_SANDBOX, EMBED_ALLOW, embedSourceOf, type EmbedProvider, type EmbedPluginOptions, type EmbedFallbackPayload, createBookmarkPlugin, type BookmarkPluginOptions, type BookmarkPreview, type BookmarkCardPayload, createFilePlugin, type FilePluginOptions, type FileRowPayload, createVideoPlugin, createAudioPlugin, safeWebUrl, safeMediaSrc, type MediaKind, createMediaEmptyPlugin, type MediaEmptyOptions, createImageToolbarPlugin, type ImageToolbar, type ImageToolbarOptions, type MediaEmptyController, type MediaEmptyFailure, type UrlPasteController, type UrlPasteOffer, type UrlPasteOption, type ImageControls, type ImageBox, type MenuItemPayload, createFindPlugin, findController, findMatches, type FindPluginOptions, type FindController, type ReplaceMatches, type FindMatch, type FindOptions, createMarqueePlugin, type MarqueePluginOptions, type MarqueeBoxPayload, createCommentsPlugin, commentsController, type CommentsPluginOptions, type CommentCardPayload, type CommentsController, type CommentDraft, type CommentNotice, type CommentUser, type PlacedThread, createPagePlugin, type PagePluginOptions, type PageBlockLinkPayload, createTocPlugin, type TocPluginOptions, type TocHeadingLevel, type TocEntryPayload, type TocEmptyPayload, createTablePlugin, type TablePluginOptions, insertTableRow, deleteTableRows, insertTableColumn, deleteTableColumn, moveTableColumn, moveTableRows, fillTableCell, type TableChrome, type TableMenu, type TableMenuRow, type TableMenuItem, type TableGripPayload, type TableAddPayload, tableBlock, type TableBlockOptions, createEquationPlugin, KATEX_CDN, KATEX_VERSION, type EquationPluginOptions, type EquationData, type EquationEditor, type EquationErrorPayload, type EquationPlaceholderPayload, type EquationTarget, type KatexLike, type KatexLoader } from './plugins/index.js';
45
+ export { createRichTextPlugin, richTextOperations, richTextPlaceholder, CALLOUT_ICONS, createCalloutIconsPlugin, type CalloutIconPicker, type CalloutIconsOptions, type RichTextPluginOptions, type TodoCheckboxPayload, type CalloutIconPayload, type EmptyBodyPayload, createArrowMovePlugin, createCodePlugin, CODE_LANGUAGES, loadCodeLanguage, type CodeLanguage, type CodePluginOptions, type CodeHeader, type LanguageMenu, type LanguageMenuItem, type LanguageRow, createMarkdownShortcutsPlugin, createMentionPlugin, type MentionItem, type MentionData, type MentionPluginOptions, createPageLinkPlugin, type PageLinkItem, type PageLinkData, type PageLinkPluginOptions, type TriggerMenuController, withRulesAndTriggers, BLOCK_ACTIVATE_EVENT, BLOCK_ADD_EVENT, type BlockActivation, type BlockAddition, createBlockHandlesPlugin, type BlockHandlesOptions, type BlockHandleSnippetPayload, type BlockHandleController, createSlashMenuPlugin, type SlashMenuOptions, type SlashMenuController, createToolbarPlugin, type ToolbarOptions, type ToolbarController, createBlockMenuPlugin, type BlockMenuOptions, type BlockMenuController, type BlockMenuAction, type BlockMenuColor, createSuggestionsPlugin, createSuggestionBarPlugin, type SuggestionBarOptions, type SuggestionBarPayload, createImagePlugin, type ImagePluginOptions, safeImageSrc, storableImageSrc, MAX_INLINE_IMAGE_BYTES, createColumnsPlugin, type ColumnsPluginOptions, createEmbedPlugin, EMBED_PROVIDERS, EMBED_SANDBOX, EMBED_ALLOW, embedSourceOf, type EmbedProvider, type EmbedPluginOptions, type EmbedFallbackPayload, createBookmarkPlugin, type BookmarkPluginOptions, type BookmarkPreview, type BookmarkCardPayload, createFilePlugin, type FilePluginOptions, type FileRowPayload, createVideoPlugin, type VideoPluginOptions, createAudioPlugin, type AudioPluginOptions, safeWebUrl, safeMediaSrc, type MediaKind, createMediaEmptyPlugin, type MediaEmptyOptions, createImageToolbarPlugin, type ImageToolbar, type ImageToolbarOptions, type MediaEmptyController, type MediaEmptyFailure, type UrlPasteController, type UrlPasteOffer, type UrlPasteOption, type ImageControls, type ImageBox, type MenuItemPayload, createFindPlugin, findController, findMatches, type FindPluginOptions, type FindController, type ReplaceMatches, type FindMatch, type FindOptions, createMarqueePlugin, type MarqueePluginOptions, type MarqueeBoxPayload, createCommentsPlugin, commentsController, type CommentsPluginOptions, type CommentCardPayload, type CommentsController, type CommentDraft, type CommentNotice, type CommentUser, type PlacedThread, createPagePlugin, type PagePluginOptions, type PageBlockLinkPayload, createTocPlugin, type TocPluginOptions, type TocHeadingLevel, type TocEntryPayload, type TocEmptyPayload, createTablePlugin, type TablePluginOptions, insertTableRow, deleteTableRows, insertTableColumn, deleteTableColumn, moveTableColumn, moveTableRows, fillTableCell, type TableChrome, type TableMenu, type TableMenuRow, type TableMenuItem, type TableGripPayload, type TableAddPayload, tableBlock, type TableBlockOptions, createEquationPlugin, KATEX_CDN, KATEX_VERSION, type EquationPluginOptions, type EquationData, type EquationEditor, type EquationErrorPayload, type EquationPlaceholderPayload, type EquationTarget, type KatexLike, type KatexLoader } from './plugins/index.js';
46
46
  export { BLOCK_COLORS, setBlockColor, type BlockColorField } from './block/colors.js';
47
47
  export { englishLabels, type Labels, type PartialLabels } from './labels.js';
48
48
  export { EdytorDocument, createDocument, loadDocument, attachDocument, defaultSemantics, semanticsOf, mergeSemantics, SemanticConflictError, DocumentNotReadyError, DocumentDestroyedError, SchemaMismatchError, UndecodableUpdateError, UnsupportedDocError, SyncRefusedError, type CreateDocumentOptions, type LoadDocumentOptions, type DocumentActor, type DocumentReadiness, type KindSemantics, type JSONDoc, type JSONBlock, type JSONText, type JSONInlineBlock, type OpResult, type Plan, type Prepared, type DocChange } from './crdt/index.js';
@@ -60,7 +60,7 @@ export type { Key, Modifier, Modifiers } from './session/keymap.js';
60
60
  export type { TriggerRange } from './plugins/triggers/TriggerController.svelte.js';
61
61
  export type { RichTextLink, RichTextMark } from './plugins/richtext/richTextOperations.js';
62
62
  export type { KindUpload, UploadReport, Uploader } from './plugins/uploads.svelte.js';
63
- export type { AwarenessLike, PresenceWriter } from './collaboration/awarenessSelection.js';
63
+ export type { AwarenessLike, PresencePeer, PresenceSource, PresenceWriter } from './collaboration/awarenessSelection.js';
64
64
  export type { DataPatch } from './crdt/data.js';
65
65
  export type { AnchorAffinity, BlockRole, DocAnchor, TextRange } from './crdt/doc/types.js';
66
66
  export type { Flow, FlowLine, FlowTarget } from './crdt/flow.js';
package/dist/index.js CHANGED
@@ -35,7 +35,7 @@ export { PreventionError, isPrevention } from './utils.js';
35
35
  export { convertToKind, turnCommands, wrapBlocks, wrappable } from './kinds.js';
36
36
  export { textToBlocks } from './clipboard/textBlocks.js';
37
37
  // ── The bundled plugins ────────────────────────────────────────────────
38
- export { createRichTextPlugin, richTextOperations, richTextPlaceholder, CALLOUT_ICONS, createCalloutIconsPlugin, createUploadsPlugin, createArrowMovePlugin, createCodePlugin, CODE_LANGUAGES, loadCodeLanguage, createMarkdownShortcutsPlugin, createMentionPlugin, createPageLinkPlugin, withRulesAndTriggers, BLOCK_ACTIVATE_EVENT, BLOCK_ADD_EVENT, createBlockHandlesPlugin, createSlashMenuPlugin, createToolbarPlugin, createBlockMenuPlugin, createSuggestionsPlugin, createSuggestionBarPlugin, createImagePlugin, safeImageSrc, storableImageSrc, MAX_INLINE_IMAGE_BYTES, createColumnsPlugin, createEmbedPlugin, EMBED_PROVIDERS, EMBED_SANDBOX, EMBED_ALLOW, embedSourceOf, createBookmarkPlugin, createFilePlugin, createVideoPlugin, createAudioPlugin, safeWebUrl, safeMediaSrc, createMediaEmptyPlugin, createImageToolbarPlugin, createFindPlugin, findController, findMatches, createMarqueePlugin, createCommentsPlugin, commentsController, createPagePlugin, createTocPlugin, createTablePlugin, insertTableRow, deleteTableRows, insertTableColumn, deleteTableColumn, moveTableColumn, moveTableRows, fillTableCell, tableBlock, createEquationPlugin, KATEX_CDN, KATEX_VERSION } from './plugins/index.js';
38
+ export { createRichTextPlugin, richTextOperations, richTextPlaceholder, CALLOUT_ICONS, createCalloutIconsPlugin, createArrowMovePlugin, createCodePlugin, CODE_LANGUAGES, loadCodeLanguage, createMarkdownShortcutsPlugin, createMentionPlugin, createPageLinkPlugin, withRulesAndTriggers, BLOCK_ACTIVATE_EVENT, BLOCK_ADD_EVENT, createBlockHandlesPlugin, createSlashMenuPlugin, createToolbarPlugin, createBlockMenuPlugin, createSuggestionsPlugin, createSuggestionBarPlugin, createImagePlugin, safeImageSrc, storableImageSrc, MAX_INLINE_IMAGE_BYTES, createColumnsPlugin, createEmbedPlugin, EMBED_PROVIDERS, EMBED_SANDBOX, EMBED_ALLOW, embedSourceOf, createBookmarkPlugin, createFilePlugin, createVideoPlugin, createAudioPlugin, safeWebUrl, safeMediaSrc, createMediaEmptyPlugin, createImageToolbarPlugin, createFindPlugin, findController, findMatches, createMarqueePlugin, createCommentsPlugin, commentsController, createPagePlugin, createTocPlugin, createTablePlugin, insertTableRow, deleteTableRows, insertTableColumn, deleteTableColumn, moveTableColumn, moveTableRows, fillTableCell, tableBlock, createEquationPlugin, KATEX_CDN, KATEX_VERSION } from './plugins/index.js';
39
39
  export { BLOCK_COLORS, setBlockColor } from './block/colors.js';
40
40
  // ── Localization ───────────────────────────────────────────────────────
41
41
  export { englishLabels } from './labels.js';
package/dist/labels.d.ts CHANGED
@@ -116,6 +116,8 @@ export type MediaLabels = {
116
116
  audio: string;
117
117
  /** A file's size, in bytes. */
118
118
  fileSize: (bytes: number) => string;
119
+ /** A file that is uploading (its block's status, beside the progress). */
120
+ uploading: string;
119
121
  };
120
122
  export type CodeLabels = {
121
123
  /** The preset (a language's name is its `CodePluginOptions.languages` row's). */
package/dist/labels.js CHANGED
@@ -118,7 +118,8 @@ export const mediaEnglish = /* @__PURE__ */ frozen({
118
118
  file: 'File',
119
119
  video: 'Video',
120
120
  audio: 'Audio',
121
- fileSize: bytes
121
+ fileSize: bytes,
122
+ uploading: 'Uploading…'
122
123
  });
123
124
  /** The `code` section in English. */
124
125
  export const codeEnglish = /* @__PURE__ */ frozen({ code: 'Code' });
@@ -1,3 +1,3 @@
1
1
  import type { Plugin } from '../../plugins.js';
2
- /** Block moves from the keyboard (Mod+Up/Down, Mod+Shift+Up/Down): a default plugin. */
2
+ /** Block moves from the keyboard (Mod+Up/Down, Mod+Shift+Up/Down): apps list it (`createArrowMovePlugin()`), it is not a default. */
3
3
  export declare const createArrowMovePlugin: () => Plugin;
@@ -24,7 +24,7 @@ const move = (direction, caret = false) => ({ edytor, prevent }) => {
24
24
  selectMoved(edytor, moved, selected);
25
25
  });
26
26
  };
27
- /** Block moves from the keyboard (Mod+Up/Down, Mod+Shift+Up/Down): a default plugin. */
27
+ /** Block moves from the keyboard (Mod+Up/Down, Mod+Shift+Up/Down): apps list it (`createArrowMovePlugin()`), it is not a default. */
28
28
  export const createArrowMovePlugin = () => branded('arrowMove', () => ({
29
29
  hotkeys: {
30
30
  'mod+arrowdown': move('down'),
@@ -53,6 +53,8 @@ export declare class BlockHandleController {
53
53
  private group;
54
54
  /** The drop bar and the nest backdrop in the overlay, while our drag runs. */
55
55
  private readonly indicator;
56
+ /** Where a drop lands (the one resolution a file drag reads too). */
57
+ private readonly drop;
56
58
  /** The selection the drag in progress replaced when it started: its undo step restores it. */
57
59
  private held;
58
60
  /** The handle the drag in progress started from: its width is the handle column's. */
@@ -100,57 +102,6 @@ export declare class BlockHandleController {
100
102
  registerHandle(element: HTMLElement, block: Block): () => void;
101
103
  /** A candidate drop target; registered at once when our drag is in progress. */
102
104
  addDropTarget(node: HTMLElement, target: Block): () => void;
103
- /**
104
- * The editor's content column (`start`…`end`, the root's content box:
105
- * where its blocks' boxes start and end), the width of the handle column
106
- * left of it (the drag's handle, measured: `+`, grip and the gap to the
107
- * block) and how far the drag reaches past them (`dropReach`, the
108
- * `--edytor-drop-reach` the root inherits).
109
- */
110
- private gutter;
111
- /**
112
- * A placement in the editor's margins at the pointer (`dnd.reach`), within
113
- * the editor's height, for the row the content's near edge shows at the
114
- * pointer's height (`rowAt`: a nested block's own row; over a layout, the
115
- * row of its first column on the left, of its last on the right, never
116
- * another), by the zone the pointer is in (`marginAt`):
117
- * - the handle column left of the blocks (`gutter`): that row's reorder
118
- * (`reorder`): a drag straight down the handles reorders, row after
119
- * row, gaps included (never a beside band);
120
- * - the first `BESIDE_MARGIN` px past it on the left, and past the
121
- * content's right edge: the beside band of that side (`beside`, as if
122
- * the pointer were at that edge) when the document has a layout kind
123
- * and the row offers one (a refused band shows nothing);
124
- * - elsewhere within the reach (and there without a band): the reorder,
125
- * on the left the handle column's, on the right the one the row's
126
- * right edge offers (its halves as just inside the content, so nothing
127
- * jumps as the pointer leaves it).
128
- * `undefined` past the reach, above or below the editor, and inside the
129
- * content (the blocks' own targets answer there).
130
- */
131
- private margin;
132
- /**
133
- * The halves of `row` (`zones`) at the pointer, the one it is in first:
134
- * the top half of `rect` (its own row by default) before, the bottom one
135
- * after; with `plain`, only before or after a block — never inside one.
136
- */
137
- private halves;
138
- /**
139
- * The first placement of `halves` the document takes (a refused one gives
140
- * way to the next, then to the other half's), `blocked` when the first
141
- * half took none; `null` when none fits.
142
- */
143
- private pick;
144
- /**
145
- * The handle column's reorder over `row` at the pointer: its plain halves
146
- * (`halves`, the pointer's x picking the level); `null` when neither half
147
- * fits. Over an item of a container the dragged blocks do not fit in (a
148
- * paragraph over a list's item: the document refuses every placement at
149
- * the item's level), the container is the row: its whole box, the upper
150
- * half before it, the lower half after it (round 4), so a drag down the
151
- * handles meets the list as one row it can pass.
152
- */
153
- private reorder;
154
105
  /** The blocks a drop of `source` moves: the drag's own group, fixed when it started. */
155
106
  private moving;
156
107
  /** The blocks the selection covers when `source` is one of them, else `source` alone. */
@@ -168,75 +119,6 @@ export declare class BlockHandleController {
168
119
  * else `source`.
169
120
  */
170
121
  private select;
171
- /** Whether the drag of `source` may land at a placement. */
172
- private fits;
173
- /**
174
- * The block whose row the pointer is on over `node`: the last shown drop
175
- * target in it whose row starts at or above the pointer (beside a nested
176
- * block, over its ancestors' indent, the pointer is on that block's
177
- * row), else `target`, over its own row (`emptied`). A layout's columns
178
- * sit side by side: only the one under the pointer is measured (between
179
- * two of them, the layout is the row: its gap).
180
- */
181
- private rowAt;
182
- /** Whether the document has a layout kind: only then are there beside placements. */
183
- private get layouts();
184
- /**
185
- * The block a beside placement over `block` stands beside: the document's
186
- * own resolution (`facade.besideAt`, `placeBeside`'s): a list item's list,
187
- * a code line's code block, a toggle's child itself, an item itself.
188
- */
189
- private besideOf;
190
- /** The item (and its layout) a beside placement at `outer` (`besideOf`) adds a column beside. */
191
- private layoutOf;
192
- /**
193
- * Notion's beside bands over `row` (`docs/columns-plan.md`, "View layer"), only while the
194
- * pointer is within its own row's height, the document has a layout kind
195
- * and the layout the drop makes or grows does not stack (`stacks`):
196
- * - right: the row's last 15% (at least 32px), and the slop past it;
197
- * - left: the slop left of the row (its sticky margin, left of its text
198
- * column), only for a row whose parent is the root or a column (a
199
- * list's item: its list's) — a nested row keeps the pointer's x for its
200
- * levels (`zones`) — and only
201
- * inside the editor (a column's gap): left of the editor's blocks is the
202
- * handle column, which reorders (`margin`);
203
- * - over a layout's gap (the row is the layout): right of the column
204
- * before it, a new column between.
205
- * `undefined` outside the bands (the hitbox's halves stand), else the
206
- * placement, or `null` when the document refuses it: a refused band shows
207
- * nothing.
208
- */
209
- private beside;
210
- /** Where the editor's blocks start (`gutter`), or `fallback` without a host. */
211
- private inside;
212
- /** The children a block shows: none for a closed toggle's, or a container's items. */
213
- private shown;
214
- /**
215
- * Over a dragged block, the parent it leaves when that parent shows no
216
- * other child: the gap under the parent's own row, which reparents as
217
- * the parent's lower half does (`zones`). Else `row`.
218
- */
219
- private emptied;
220
- /**
221
- * The placements over `row`, each half's in preference order (a refused
222
- * one gives way to the next, then to the other half's):
223
- * - the top half: before it;
224
- * - the bottom half of a block whose children show (not a closed toggle):
225
- * its first child's slot. Pragmatic drag and drop's tree rule: an
226
- * expanded item offers no "after" on its own row;
227
- * - else, after it at the level whose text column is nearest the pointer:
228
- * the last block of a nested group reparents to any ancestor it ends,
229
- * down to the root. Past one nesting step right of its text start,
230
- * inside it (its last child) first. A block every shown child of which
231
- * is dragged is not expanded: its levels, never inside it when the drag
232
- * moves only its children (they would stay where they are).
233
- * None over a dragged block's own row or its subtree: released there, the
234
- * drag changes nothing (its levels would outdent it) — unless it empties
235
- * its parent's shown children (`emptied`): that parent's row. Over the
236
- * hint of the row's empty body (`body.hint`: an open toggle's, a
237
- * callout's), inside it first, either half.
238
- */
239
- private zones;
240
122
  /**
241
123
  * The placement a drop target record offers: the page's margins
242
124
  * (`margin`), else a beside band of the row first (`beside`; `false` when
@@ -245,7 +127,5 @@ export declare class BlockHandleController {
245
127
  * live.
246
128
  */
247
129
  private placement;
248
- /** The dragged block that is `row` or holds it: its row offers nothing (it moves with the drag). */
249
- private carrier;
250
130
  }
251
131
  export {};