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
|
@@ -63,7 +63,12 @@ export class BlockMenuController {
|
|
|
63
63
|
* after). Delete and Turn into act on their `members`, its items too.
|
|
64
64
|
*/
|
|
65
65
|
blocks = $state([]);
|
|
66
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Where the menu stands: the handle that opened it (a `ChromeAnchor`:
|
|
68
|
+
* your `menu` places itself beside it, its flyout beside the menu);
|
|
69
|
+
* `null` while closed.
|
|
70
|
+
*/
|
|
71
|
+
anchor = $state.raw(null);
|
|
67
72
|
query = $state('');
|
|
68
73
|
/** The keyboard's row. */
|
|
69
74
|
index = $state(0);
|
|
@@ -473,7 +478,7 @@ export class BlockMenuController {
|
|
|
473
478
|
caret(block) {
|
|
474
479
|
const text = block && shownText(block, 'first');
|
|
475
480
|
if (text || !block?.isInTree)
|
|
476
|
-
this.edytor.dispatcher.
|
|
481
|
+
this.edytor.dispatcher.caretIn(text, 0);
|
|
477
482
|
else
|
|
478
483
|
this.edytor.selection.select(blockSelection([block.id]));
|
|
479
484
|
this.focus();
|
|
@@ -11,14 +11,9 @@ import { BlockMenuController, colorCommands } from './BlockMenuController.svelte
|
|
|
11
11
|
export const createBlockMenuPlugin = (options = {}) => (edytor) => {
|
|
12
12
|
const controller = new BlockMenuController(edytor, options);
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* no room, top-aligned with it, moved up as far as the viewport needs
|
|
18
|
-
* (never above its top edge), and scrolls inside when taller (Notion):
|
|
19
|
-
* every row is in the viewport, reachable by the mouse. It follows
|
|
20
|
-
* scrolls and resizes, and closes when the handle leaves the view.
|
|
21
|
-
* Measured in the overlay's frame; the placement (or the close) is written after.
|
|
14
|
+
* The menu places itself by `controller.anchor` (the handle), its
|
|
15
|
+
* flyout by the menu; measured in the overlay's frame, the menu closes
|
|
16
|
+
* when the handle leaves the page or the view.
|
|
22
17
|
*/
|
|
23
18
|
const close = () => controller.close(false);
|
|
24
19
|
const place = (host) => {
|
|
@@ -27,50 +22,10 @@ export const createBlockMenuPlugin = (options = {}) => (edytor) => {
|
|
|
27
22
|
return;
|
|
28
23
|
if (!anchor?.isConnected)
|
|
29
24
|
return close;
|
|
30
|
-
const view = host.ownerDocument.defaultView;
|
|
31
|
-
const menu = host.querySelector('[data-edytor-block-menu]') ??
|
|
32
|
-
host.firstElementChild;
|
|
33
|
-
if (!view || !menu)
|
|
34
|
-
return;
|
|
35
|
-
const [gap, edge, between] = [8, 8, 4];
|
|
36
25
|
const rect = anchor.getBoundingClientRect();
|
|
37
|
-
|
|
26
|
+
const height = host.ownerDocument.defaultView?.innerHeight ?? Infinity;
|
|
27
|
+
if (rect.bottom < 0 || rect.top > height)
|
|
38
28
|
return close;
|
|
39
|
-
// Layout sizes, not the box: the menus open with a scale (0.98 → 1), and a
|
|
40
|
-
// box read mid-animation would place them up to 2% short of their size.
|
|
41
|
-
const [width, height] = [menu.offsetWidth, menu.offsetHeight];
|
|
42
|
-
const right = rect.right + gap;
|
|
43
|
-
const left = rect.left - gap - width;
|
|
44
|
-
let x = right + width <= view.innerWidth - edge
|
|
45
|
-
? right
|
|
46
|
-
: left >= edge
|
|
47
|
-
? left
|
|
48
|
-
: Math.max(edge, Math.min(right, view.innerWidth - edge - width));
|
|
49
|
-
const y = rect.top + height <= view.innerHeight - edge
|
|
50
|
-
? rect.top
|
|
51
|
-
: Math.max(edge, Math.min(rect.bottom, view.innerHeight - edge) - height);
|
|
52
|
-
const flyout = host.querySelector('[data-edytor-block-menu-flyout]');
|
|
53
|
-
const frame = flyout?.parentElement;
|
|
54
|
-
let side = '';
|
|
55
|
-
let shift = '';
|
|
56
|
-
if (flyout && frame) {
|
|
57
|
-
const box = { width: flyout.offsetWidth, height: flyout.offsetHeight };
|
|
58
|
-
// Left of the menu when its right has no room (the menu stays where it is).
|
|
59
|
-
if (x + width + between + box.width > view.innerWidth - edge &&
|
|
60
|
-
x - between - box.width >= edge) {
|
|
61
|
-
side = 'row-reverse';
|
|
62
|
-
x -= between + box.width;
|
|
63
|
-
}
|
|
64
|
-
const top = Math.max(edge, Math.min(y, view.innerHeight - edge - box.height));
|
|
65
|
-
shift = `${top - y}px`;
|
|
66
|
-
}
|
|
67
|
-
return () => {
|
|
68
|
-
Object.assign(host.style, { left: `${x}px`, top: `${y}px` });
|
|
69
|
-
if (frame)
|
|
70
|
-
frame.style.flexDirection = side;
|
|
71
|
-
if (flyout)
|
|
72
|
-
flyout.style.marginTop = shift;
|
|
73
|
-
};
|
|
74
29
|
};
|
|
75
30
|
return {
|
|
76
31
|
// Colours by name in the slash menu (`/red`), as in Notion.
|
package/dist/plugins/chrome.d.ts
CHANGED
|
@@ -9,17 +9,33 @@ import type { Snippet } from 'svelte';
|
|
|
9
9
|
import type { Attachment } from 'svelte/attachments';
|
|
10
10
|
import type { Edytor } from '../edytor.svelte.js';
|
|
11
11
|
import { type BlockActivation, type BlockAddition } from './blockHandles/BlockHandleController.svelte.js';
|
|
12
|
+
/**
|
|
13
|
+
* Where a chrome surface stands, for the app's markup to place itself
|
|
14
|
+
* (Floating UI's virtual element: `computePosition(anchor, floating, …)`,
|
|
15
|
+
* or bits-ui's `customAnchor`): its box read now, in client pixels, on
|
|
16
|
+
* every call (the caret, the selection, a block, a grip, a button), and
|
|
17
|
+
* the element whose scrolling ancestors move it. The package places no
|
|
18
|
+
* popup.
|
|
19
|
+
*/
|
|
20
|
+
export type ChromeAnchor = {
|
|
21
|
+
getBoundingClientRect: () => DOMRect;
|
|
22
|
+
readonly contextElement?: Element;
|
|
23
|
+
};
|
|
24
|
+
/** A {@link ChromeAnchor} reading `rect` (an empty box while there is none) inside `context`. */
|
|
25
|
+
export declare const virtualAnchor: (rect: () => DOMRect | null | undefined, context: () => Element | null | undefined) => ChromeAnchor;
|
|
12
26
|
/**
|
|
13
27
|
* Mount the app's `snippet` for a chrome surface in a fixed host of the
|
|
14
|
-
* overlay (`data-<name
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
28
|
+
* overlay (`data-<name>`), rendered with `payload` while `shown` holds and
|
|
29
|
+
* closed (`close`) when the view turns readonly; the markup places itself
|
|
30
|
+
* by its controller's `anchor`. `measure` runs on the overlay's frames (a
|
|
31
|
+
* surface whose anchor left the page closes there). Without a snippet the
|
|
32
|
+
* surface renders nothing (its controller still works): nothing is
|
|
33
|
+
* mounted. Answers the teardown.
|
|
18
34
|
*/
|
|
19
35
|
export declare const mountChrome: <T>(edytor: Edytor, snippet: Snippet<[T]> | undefined, payload: T, shown: () => unknown, place: {
|
|
20
36
|
name: string;
|
|
21
37
|
zIndex: number;
|
|
22
|
-
measure
|
|
38
|
+
measure?: (host: HTMLElement, origin: DOMRect) => (() => void) | void;
|
|
23
39
|
}, close?: () => void) => () => void;
|
|
24
40
|
/**
|
|
25
41
|
* One row of a chrome list a controller builds for the app's markup: the
|
|
@@ -68,6 +84,12 @@ export declare const identify: (node: HTMLElement, id: string, role?: string) =>
|
|
|
68
84
|
export declare const attribute: (node: HTMLElement, name: string, value: string | undefined) => void;
|
|
69
85
|
/** Whether `node` may name a highlighted row (`aria-activedescendant`): a field, or an element with a role. */
|
|
70
86
|
export declare const namesRows: (node: HTMLElement) => boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Every press in `document` (capture; WebKit's lone `mousedown` after a
|
|
89
|
+
* drag too, `onPress`) outside the elements `inside` matches: `outside`
|
|
90
|
+
* hears it. Answers the teardown.
|
|
91
|
+
*/
|
|
92
|
+
export declare const onPressOutside: (edytor: Edytor, document: Document, inside: string, outside: (event: MouseEvent) => void) => () => void;
|
|
71
93
|
/**
|
|
72
94
|
* A handle menu's events on the editor `node` (the block menu, the `+`'s
|
|
73
95
|
* menu): a grip's activation (`BLOCK_ACTIVATE_EVENT`), a `+`'s offer
|
package/dist/plugins/chrome.js
CHANGED
|
@@ -2,15 +2,24 @@ import Chrome from './Chrome.svelte';
|
|
|
2
2
|
import { onPress } from '../events/onFocus.js';
|
|
3
3
|
import { all, listen } from '../utils/listen.js';
|
|
4
4
|
import { BLOCK_ACTIVATE_EVENT, BLOCK_ADD_EVENT } from './blockHandles/BlockHandleController.svelte.js';
|
|
5
|
+
/** A {@link ChromeAnchor} reading `rect` (an empty box while there is none) inside `context`. */
|
|
6
|
+
export const virtualAnchor = (rect, context) => ({
|
|
7
|
+
getBoundingClientRect: () => rect() ?? new DOMRect(),
|
|
8
|
+
get contextElement() {
|
|
9
|
+
return context() ?? undefined;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
5
12
|
/**
|
|
6
13
|
* Mount the app's `snippet` for a chrome surface in a fixed host of the
|
|
7
|
-
* overlay (`data-<name
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
14
|
+
* overlay (`data-<name>`), rendered with `payload` while `shown` holds and
|
|
15
|
+
* closed (`close`) when the view turns readonly; the markup places itself
|
|
16
|
+
* by its controller's `anchor`. `measure` runs on the overlay's frames (a
|
|
17
|
+
* surface whose anchor left the page closes there). Without a snippet the
|
|
18
|
+
* surface renders nothing (its controller still works): nothing is
|
|
19
|
+
* mounted. Answers the teardown.
|
|
11
20
|
*/
|
|
12
21
|
export const mountChrome = (edytor, snippet, payload, shown, place, close) => snippet
|
|
13
|
-
? edytor.overlay.mount((Chrome), { edytor, snippet, payload, shown, close }, place.name, place.zIndex, place.measure)
|
|
22
|
+
? edytor.overlay.mount((Chrome), { edytor, snippet, payload, shown, close }, place.name, place.zIndex, place.measure ?? (() => { }))
|
|
14
23
|
: () => { };
|
|
15
24
|
/**
|
|
16
25
|
* Write `value` as `node`'s attribute `name`, only when it changes:
|
|
@@ -74,6 +83,15 @@ export const attribute = (node, name, value) => {
|
|
|
74
83
|
};
|
|
75
84
|
/** Whether `node` may name a highlighted row (`aria-activedescendant`): a field, or an element with a role. */
|
|
76
85
|
export const namesRows = (node) => isField(node) || node.hasAttribute('role');
|
|
86
|
+
/**
|
|
87
|
+
* Every press in `document` (capture; WebKit's lone `mousedown` after a
|
|
88
|
+
* drag too, `onPress`) outside the elements `inside` matches: `outside`
|
|
89
|
+
* hears it. Answers the teardown.
|
|
90
|
+
*/
|
|
91
|
+
export const onPressOutside = (edytor, document, inside, outside) => onPress(edytor, document, (event) => {
|
|
92
|
+
if (!event.target?.closest?.(inside))
|
|
93
|
+
outside(event);
|
|
94
|
+
}, true);
|
|
77
95
|
/**
|
|
78
96
|
* A handle menu's events on the editor `node` (the block menu, the `+`'s
|
|
79
97
|
* menu): a grip's activation (`BLOCK_ACTIVATE_EVENT`), a `+`'s offer
|
|
@@ -81,7 +99,4 @@ export const namesRows = (node) => isField(node) || node.hasAttribute('role');
|
|
|
81
99
|
* matches (WebKit's lone `mousedown` after a drag too, `onPress`). Answers
|
|
82
100
|
* the teardown.
|
|
83
101
|
*/
|
|
84
|
-
export const handleMenuEvents = (edytor, node, activate, add, inside, outside) => all(listen(node, BLOCK_ACTIVATE_EVENT, activate), listen(node, BLOCK_ADD_EVENT, add),
|
|
85
|
-
if (!event.target?.closest?.(inside))
|
|
86
|
-
outside();
|
|
87
|
-
}, true));
|
|
102
|
+
export const handleMenuEvents = (edytor, node, activate, add, inside, outside) => all(listen(node, BLOCK_ACTIVATE_EVENT, activate), listen(node, BLOCK_ADD_EVENT, add), onPressOutside(edytor, node.ownerDocument, inside, outside));
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
+
import { codeForms } from '../../export/forms.js';
|
|
2
3
|
import './code.css';
|
|
3
4
|
import type { Plugin, MarkSnippetPayload, BlockSnippetPayload } from '../../plugins.js';
|
|
4
5
|
import { Text } from '../../text/text.svelte.js';
|
|
5
6
|
import { runIntent } from '../../events/beforeInputCommands.js';
|
|
6
|
-
|
|
7
|
+
|
|
7
8
|
import { shown } from '../../selection/visibility.js';
|
|
8
9
|
import { caretBeside } from '../../selection/replaceSelection.js';
|
|
9
10
|
import { siblingSlot } from '../../session/handles.js';
|
|
10
11
|
import CodeHeader from './CodeHeader.svelte';
|
|
11
|
-
import LanguageMenuPanel from './LanguageMenu.svelte';
|
|
12
12
|
import { LanguageMenu, languageMenus } from './languageMenu.svelte.js';
|
|
13
13
|
import { codeEnglish, keywordsOf, labelsOf } from '../../labels.js';
|
|
14
14
|
import {
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
onEdytorAttached: ({ node }) => {
|
|
116
116
|
const menu = ownMenu();
|
|
117
117
|
const snippet = menu?.settings.menu;
|
|
118
|
-
return snippet && menu.panel.mount(node,
|
|
118
|
+
return snippet && menu.panel.mount(node, snippet, menu, () => menu.open !== null);
|
|
119
119
|
},
|
|
120
120
|
hotkeys: {
|
|
121
121
|
// Alt+F10 at a caret in a code line: the keys go to its language button
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
edytor.idToBlock.get(
|
|
175
175
|
edytor.insertBlocks(siblingSlot(line), [{ type: 'codeLine' }]).ids[0] ?? ''
|
|
176
176
|
);
|
|
177
|
-
return prevent(() => edytor.dispatcher.
|
|
177
|
+
return prevent(() => edytor.dispatcher.caretIn(next()?.firstText, 0));
|
|
178
178
|
}
|
|
179
179
|
prevent(() => runIntent(edytor, 'insertParagraph'));
|
|
180
180
|
}
|
|
@@ -189,7 +189,10 @@
|
|
|
189
189
|
prevent(() => {
|
|
190
190
|
const before = caretBeside(block, 'blockBefore', new Set([block]));
|
|
191
191
|
edytor.deleteBlock(block.id);
|
|
192
|
-
edytor.dispatcher.
|
|
192
|
+
edytor.dispatcher.caretIn(
|
|
193
|
+
before?.text ?? code.firstEditableText,
|
|
194
|
+
before?.offset ?? 0
|
|
195
|
+
);
|
|
193
196
|
});
|
|
194
197
|
}
|
|
195
198
|
// Backspace in an empty block right after a code block removes it; the
|
|
@@ -202,7 +205,7 @@
|
|
|
202
205
|
prevent(() => {
|
|
203
206
|
edytor.deleteBlock(block.id);
|
|
204
207
|
const text = previous.lastText;
|
|
205
|
-
edytor.dispatcher.
|
|
208
|
+
edytor.dispatcher.caretIn(text, text?.length ?? 0);
|
|
206
209
|
});
|
|
207
210
|
}
|
|
208
211
|
if (block.type !== 'codeLine') return;
|
|
@@ -213,7 +216,7 @@
|
|
|
213
216
|
const [at, line] = [offset - startText.segStart, startText.stringContent];
|
|
214
217
|
// A closer typed before the same character steps over it.
|
|
215
218
|
if (CLOSERS.has(value) && line[at] === value) {
|
|
216
|
-
prevent(() => edytor.dispatcher.
|
|
219
|
+
prevent(() => edytor.dispatcher.caretIn(startText, at + 1));
|
|
217
220
|
}
|
|
218
221
|
// Quotes pair only at a word boundary: the apostrophe in `don't` stays single.
|
|
219
222
|
const inWord = QUOTES.has(value) && /\w/.test((line[at - 1] ?? '') + (line[at] ?? ''));
|
|
@@ -230,7 +233,7 @@
|
|
|
230
233
|
|
|
231
234
|
blocks: {
|
|
232
235
|
code: {
|
|
233
|
-
...
|
|
236
|
+
...codeForms().code,
|
|
234
237
|
snippet: code,
|
|
235
238
|
presets: [
|
|
236
239
|
{
|
|
@@ -244,8 +247,8 @@
|
|
|
244
247
|
empty: { content: [], children: [{ type: 'codeLine', content: [{ text: '' }] }] }
|
|
245
248
|
},
|
|
246
249
|
codeLine: {
|
|
250
|
+
...codeForms().codeLine,
|
|
247
251
|
snippet: codeLine,
|
|
248
|
-
html: (_, content) => `<pre><code>${content}</code></pre>`,
|
|
249
252
|
transformText: ({ text, block }) =>
|
|
250
253
|
tokenizeCode(text.stringContent, lineLanguage(block.id)),
|
|
251
254
|
// A line holding newlines keeps its first line; each other becomes a code line after it.
|
|
@@ -9,6 +9,7 @@ import { Text } from '../../text/text.svelte.js';
|
|
|
9
9
|
import { attribute } from '../chrome.js';
|
|
10
10
|
import { languageOf } from './languages.js';
|
|
11
11
|
import { all, listen } from '../../utils/listen.js';
|
|
12
|
+
import { keysOf } from '../list.svelte.js';
|
|
12
13
|
/** How long Copy reads Copied after a copy, in milliseconds. */
|
|
13
14
|
const COPIED_FOR = 1200;
|
|
14
15
|
/** A code block's text: its lines, joined by newlines. */
|
|
@@ -112,17 +113,12 @@ export class CodeHeader {
|
|
|
112
113
|
const mousedown = (event) => event.preventDefault();
|
|
113
114
|
// A click from Enter or Space has no pointer (`detail` 0): the keys opened it.
|
|
114
115
|
const click = (event) => this.toggle(event.detail === 0);
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
this.menu?.release();
|
|
122
|
-
else
|
|
123
|
-
return;
|
|
124
|
-
event.preventDefault();
|
|
125
|
-
};
|
|
116
|
+
const open = () => this.expanded || this.toggle(true);
|
|
117
|
+
const keydown = keysOf({
|
|
118
|
+
ArrowDown: open,
|
|
119
|
+
ArrowUp: open,
|
|
120
|
+
Escape: () => this.menu?.release()
|
|
121
|
+
});
|
|
126
122
|
const off = listen(node, 'mousedown', mousedown);
|
|
127
123
|
const off2 = listen(node, 'click', click);
|
|
128
124
|
const off3 = listen(node, 'keydown', keydown);
|
|
@@ -41,8 +41,11 @@ export declare class LanguageMenu extends ChromeList {
|
|
|
41
41
|
} | null;
|
|
42
42
|
/** The search field's text. */
|
|
43
43
|
query: string;
|
|
44
|
-
/**
|
|
45
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Where the list stands: the open block's language button
|
|
46
|
+
* (`ChromeAnchor`), which your `menu` places itself under.
|
|
47
|
+
*/
|
|
48
|
+
get anchor(): import("../chrome.js").ChromeAnchor;
|
|
46
49
|
/** The open block's language id. */
|
|
47
50
|
get current(): string | null;
|
|
48
51
|
/** The rows the query keeps: a language the plugin does not list first (the block's own), then the list. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { untrack } from 'svelte';
|
|
2
2
|
import { takeKeys } from '../../events/onFocus.js';
|
|
3
3
|
import { attribute } from '../chrome.js';
|
|
4
|
-
import { ChromeList, holdKeys } from '../list.svelte.js';
|
|
4
|
+
import { ChromeList, holdKeys, keysOf } from '../list.svelte.js';
|
|
5
5
|
import { Anchored } from '../anchored.svelte.js';
|
|
6
6
|
import { languageOf } from './languages.js';
|
|
7
7
|
import { all, listen } from '../../utils/listen.js';
|
|
@@ -40,9 +40,12 @@ export class LanguageMenu extends ChromeList {
|
|
|
40
40
|
this.settings = settings;
|
|
41
41
|
this.panel = new Anchored(edytor, 'edytor-code-language-host', () => (this.open ? this.#button(this.open.block) : undefined), () => this.close());
|
|
42
42
|
}
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Where the list stands: the open block's language button
|
|
45
|
+
* (`ChromeAnchor`), which your `menu` places itself under.
|
|
46
|
+
*/
|
|
47
|
+
get anchor() {
|
|
48
|
+
return this.panel.anchor;
|
|
46
49
|
}
|
|
47
50
|
/** The open block's language id. */
|
|
48
51
|
get current() {
|
|
@@ -121,7 +124,6 @@ export class LanguageMenu extends ChromeList {
|
|
|
121
124
|
if (!open)
|
|
122
125
|
return;
|
|
123
126
|
this.open = null;
|
|
124
|
-
this.panel.box = null;
|
|
125
127
|
this.query = '';
|
|
126
128
|
this.edytor.overlay.invalidate();
|
|
127
129
|
if (keys === 'button')
|
|
@@ -152,21 +154,12 @@ export class LanguageMenu extends ChromeList {
|
|
|
152
154
|
return all(off, off2);
|
|
153
155
|
});
|
|
154
156
|
/** The search field's keys (`keys`). */
|
|
155
|
-
#keydown = (
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
else if (event.key === 'Enter')
|
|
162
|
-
this.pick();
|
|
163
|
-
else if (event.key === 'Escape')
|
|
164
|
-
this.close(this.open?.keys ? 'button' : 'editor');
|
|
165
|
-
else
|
|
166
|
-
return;
|
|
167
|
-
event.preventDefault();
|
|
168
|
-
event.stopPropagation();
|
|
169
|
-
};
|
|
157
|
+
#keydown = keysOf({
|
|
158
|
+
ArrowDown: () => this.move(1),
|
|
159
|
+
ArrowUp: () => this.move(-1),
|
|
160
|
+
Enter: () => this.pick(),
|
|
161
|
+
Escape: () => this.close(this.open?.keys ? 'button' : 'editor')
|
|
162
|
+
}, true);
|
|
170
163
|
/**
|
|
171
164
|
* The keys back to the editor from a language button (its Escape): the
|
|
172
165
|
* host takes the focus, the caret shown where the selection is.
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
+
import { columnsForms } from '../../export/forms.js';
|
|
2
3
|
import './columns.css';
|
|
3
4
|
import type { BlockSnippetPayload, BlockView, EditorCommand, Plugin } from '../../plugins.js';
|
|
4
5
|
import type { Edytor } from '../../edytor.svelte.js';
|
|
5
6
|
import type { Block } from '../../block/block.svelte.js';
|
|
6
|
-
|
|
7
|
+
|
|
7
8
|
import { convertToKind, wrapBlocks, wrappable, type KindRow } from '../../kinds.js';
|
|
8
9
|
import {
|
|
9
10
|
getSelectedBlocksInDocumentOrder,
|
|
10
11
|
liftLayouts
|
|
11
12
|
} from '../../selection/replaceSelection.js';
|
|
12
13
|
import ColumnResizeStrips from './ColumnResize.svelte';
|
|
13
|
-
import { ColumnResize
|
|
14
|
+
import { ColumnResize } from './resize.svelte.js';
|
|
14
15
|
import { hoverChrome } from '../bands.svelte.js';
|
|
15
16
|
import { all, listen } from '../../utils/listen.js';
|
|
16
17
|
import { columnsEnglish, keywordsOf, labelsOf } from '../../labels.js';
|
|
@@ -23,12 +24,6 @@
|
|
|
23
24
|
minWidth?: number;
|
|
24
25
|
};
|
|
25
26
|
|
|
26
|
-
/** A weight read back from HTML (`data-width`), when it is one. */
|
|
27
|
-
const parsedWidth = (element: HTMLElement): Record<string, number> => {
|
|
28
|
-
const width = Number(element.getAttribute('data-width'));
|
|
29
|
-
return Number.isFinite(width) && width > 0 ? { width } : {};
|
|
30
|
-
};
|
|
31
|
-
|
|
32
27
|
/**
|
|
33
28
|
* Whether `block` sits in a layout's column, at any depth: no layout goes
|
|
34
29
|
* there (`layout.nest`). A `+` menu's stand-in (no id yet) answers by
|
|
@@ -174,15 +169,12 @@
|
|
|
174
169
|
},
|
|
175
170
|
blocks: {
|
|
176
171
|
columns: {
|
|
177
|
-
...
|
|
172
|
+
...columnsForms().columns,
|
|
178
173
|
snippet: columns,
|
|
179
|
-
element: { tag: 'div', attributes: { 'data-edytor-columns': '' } }
|
|
180
|
-
html: (_, __, children) => `<div data-edytor-columns>${children}</div>`,
|
|
181
|
-
plain: (_, __, children) => children,
|
|
182
|
-
parse: (element) => (element.hasAttribute('data-edytor-columns') ? {} : undefined)
|
|
174
|
+
element: { tag: 'div', attributes: { 'data-edytor-columns': '' } }
|
|
183
175
|
},
|
|
184
176
|
column: {
|
|
185
|
-
...
|
|
177
|
+
...columnsForms().column,
|
|
186
178
|
snippet: column,
|
|
187
179
|
// Its weight as shown: a resize drag's preview (this view only), else `data.width`.
|
|
188
180
|
element: (data, id) => ({
|
|
@@ -191,12 +183,7 @@
|
|
|
191
183
|
'data-edytor-column': '',
|
|
192
184
|
style: `flex: ${resize.weight(id, data)} 1 0px`
|
|
193
185
|
}
|
|
194
|
-
})
|
|
195
|
-
html: (block, _, children) =>
|
|
196
|
-
`<div data-edytor-column data-width="${weightOf(block.data)}">${children}</div>`,
|
|
197
|
-
plain: (_, __, children) => children,
|
|
198
|
-
parse: (element) =>
|
|
199
|
-
element.hasAttribute('data-edytor-column') ? parsedWidth(element) : undefined
|
|
186
|
+
})
|
|
200
187
|
}
|
|
201
188
|
}
|
|
202
189
|
};
|
|
@@ -3,8 +3,8 @@ import type { Edytor } from '../../edytor.svelte.js';
|
|
|
3
3
|
import { BandDrag } from '../bands.svelte.js';
|
|
4
4
|
/** The guide line's width (the hover guide's and the drag's). */
|
|
5
5
|
export declare const GUIDE = 2;
|
|
6
|
-
|
|
7
|
-
export
|
|
6
|
+
import { weightOf } from '../../export/forms.js';
|
|
7
|
+
export { weightOf };
|
|
8
8
|
/** The resize band in the gap between the columns `left` and `right` (`bandOf`), layer-relative. */
|
|
9
9
|
export type Strip = {
|
|
10
10
|
/** The layout, and the columns on each side. */
|
|
@@ -119,4 +119,3 @@ export declare class ColumnResize {
|
|
|
119
119
|
/** A band took (`true`) or lost the focus: its layout's bands stay while it holds it. */
|
|
120
120
|
focus: (strip: Strip, focused: boolean) => void;
|
|
121
121
|
}
|
|
122
|
-
export {};
|
|
@@ -5,11 +5,8 @@ import { stacks } from '../../dnd/stacking.js';
|
|
|
5
5
|
import { columnsEnglish, labelsOf } from '../../labels.js';
|
|
6
6
|
/** The guide line's width (the hover guide's and the drag's). */
|
|
7
7
|
export const GUIDE = 2;
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
const width = data?.width;
|
|
11
|
-
return typeof width === 'number' && Number.isFinite(width) && width > 0 ? width : 1;
|
|
12
|
-
};
|
|
8
|
+
import { weightOf } from '../../export/forms.js';
|
|
9
|
+
export { weightOf };
|
|
13
10
|
/** The band's middle in a gap `width` px wide, from the gap's left. */
|
|
14
11
|
const middleOf = (width) => {
|
|
15
12
|
const band = bandOf({ left: 0, right: width });
|
|
@@ -74,6 +74,12 @@ export declare class CommentsController {
|
|
|
74
74
|
readonly resolved: PlacedThread[];
|
|
75
75
|
/** The threads the sidebar shows: the open ones, the resolved ones on demand, the active one. */
|
|
76
76
|
readonly shown: PlacedThread[];
|
|
77
|
+
/**
|
|
78
|
+
* Where the thread being written, else the active one, stands
|
|
79
|
+
* (`ChromeAnchor`): the first line of its text, by which a card may
|
|
80
|
+
* place itself (the sidebar places its cards in the margin).
|
|
81
|
+
*/
|
|
82
|
+
readonly anchor: import("../chrome.js").ChromeAnchor;
|
|
77
83
|
/** The view may write: it may start, answer, resolve and delete comments. */
|
|
78
84
|
get canComment(): boolean;
|
|
79
85
|
/** One thread, by id. */
|
|
@@ -4,6 +4,9 @@ import { showText } from '../planned.js';
|
|
|
4
4
|
import { COMMENT_MARK, blockCommentRuns, commentId, joinAnchors } from '../../crdt/protocols/comments.js';
|
|
5
5
|
import { CommentThreads } from '../../collaboration/comments/threads.js';
|
|
6
6
|
import { takeKeys } from '../../events/onFocus.js';
|
|
7
|
+
import { rangeRects } from '../../collaboration/remoteSelection.js';
|
|
8
|
+
import { runOf } from '../../components/Ranges.svelte';
|
|
9
|
+
import { virtualAnchor } from '../chrome.js';
|
|
7
10
|
const avatarColors = ['#e16259', '#d9730d', '#cb912f', '#448361', '#337ea9', '#9065b0', '#c14c8a'];
|
|
8
11
|
/**
|
|
9
12
|
* The comments plugin's state and actions (`plugins/comments`): the
|
|
@@ -92,6 +95,23 @@ export class CommentsController {
|
|
|
92
95
|
/** The threads the sidebar shows: the open ones, the resolved ones on demand, the active one. */
|
|
93
96
|
shown = $derived(this.threads.filter((thread) => thread.runs.length > 0 &&
|
|
94
97
|
(!thread.resolved || this.showResolved || thread.id === this.active)));
|
|
98
|
+
/**
|
|
99
|
+
* Where the thread being written, else the active one, stands
|
|
100
|
+
* (`ChromeAnchor`): the first line of its text, by which a card may
|
|
101
|
+
* place itself (the sidebar places its cards in the margin).
|
|
102
|
+
*/
|
|
103
|
+
anchor = virtualAnchor(() => {
|
|
104
|
+
const { edytor } = this;
|
|
105
|
+
const run = this.draft
|
|
106
|
+
? this.draftRuns()[0]
|
|
107
|
+
: this.active
|
|
108
|
+
? this.anchors.get(this.active)?.[0]
|
|
109
|
+
: undefined;
|
|
110
|
+
const [rect] = run
|
|
111
|
+
? runOf(edytor, run.block, run.offset, run.length).flatMap(({ start, end }) => rangeRects(edytor, start, end, new DOMRect()))
|
|
112
|
+
: [];
|
|
113
|
+
return rect && new DOMRect(rect.left, rect.top, rect.width, rect.height);
|
|
114
|
+
}, () => this.edytor.node);
|
|
95
115
|
/** The view may write: it may start, answer, resolve and delete comments. */
|
|
96
116
|
get canComment() {
|
|
97
117
|
return this.edytor.dispatcher.permits();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
+
import { equationForms } from '../../export/forms.js';
|
|
2
3
|
import './equation.css';
|
|
3
4
|
import type {
|
|
4
5
|
BlockSnippetPayload,
|
|
@@ -8,17 +9,15 @@
|
|
|
8
9
|
} from '../../plugins.js';
|
|
9
10
|
import type { Edytor } from '../../edytor.svelte.js';
|
|
10
11
|
import { InlineBlock } from '../../block/inlineBlock.svelte.js';
|
|
11
|
-
|
|
12
|
+
|
|
12
13
|
import { equationEnglish, keywordsOf, labelsOf } from '../../labels.js';
|
|
13
14
|
import { id } from '../../utils.js';
|
|
14
15
|
import EquationView from './EquationView.svelte';
|
|
15
|
-
import EquationEditorPanel from './EquationEditor.svelte';
|
|
16
16
|
import {
|
|
17
17
|
EquationEditor,
|
|
18
18
|
EquationRenderer,
|
|
19
19
|
equationViews,
|
|
20
20
|
expressionOf,
|
|
21
|
-
parseEquation,
|
|
22
21
|
type EquationData,
|
|
23
22
|
type EquationErrorPayload,
|
|
24
23
|
type EquationPlaceholderPayload,
|
|
@@ -28,7 +27,7 @@
|
|
|
28
27
|
type KatexLoader
|
|
29
28
|
} from './equation.svelte.js';
|
|
30
29
|
import { katexLoaderOf } from './katex.js';
|
|
31
|
-
import { withRulesAndTriggers } from '../triggers/triggers.js';
|
|
30
|
+
import { placeAtom, withRulesAndTriggers } from '../triggers/triggers.js';
|
|
32
31
|
|
|
33
32
|
export type {
|
|
34
33
|
EquationData,
|
|
@@ -101,13 +100,8 @@
|
|
|
101
100
|
/** `$$E=mc^2$$` typed in text: an inline equation (Notion). */
|
|
102
101
|
const dollars: InputRule = {
|
|
103
102
|
find: /\$\$([^$\n]*[^$\s][^$\n]*)\$\$$/,
|
|
104
|
-
replace: ([, tex],
|
|
105
|
-
remove(() => {
|
|
106
|
-
const atom = { type: INLINE, data: { expression: tex!.trim() } };
|
|
107
|
-
const written = edytor.insertInline(block.id, from, atom).status === 'applied';
|
|
108
|
-
if (written) caret(from + 1);
|
|
109
|
-
return written;
|
|
110
|
-
})
|
|
103
|
+
replace: ([, tex], ctx) =>
|
|
104
|
+
ctx.remove(() => placeAtom(ctx, { type: INLINE, data: { expression: tex!.trim() } }))
|
|
111
105
|
};
|
|
112
106
|
|
|
113
107
|
/** The equation a block selection or an atom selection stands for, if any. */
|
|
@@ -143,6 +137,8 @@
|
|
|
143
137
|
(edytor) => {
|
|
144
138
|
const labels = labelsOf(edytor, 'equation', equationEnglish);
|
|
145
139
|
const renderer = new EquationRenderer(katexLoaderOf(options.katex), options.macros);
|
|
140
|
+
/** The kinds' forms: MathML by KaTeX once it is loaded. */
|
|
141
|
+
const forms = equationForms(renderer.mathml);
|
|
146
142
|
// The records read with no view (`plugin(undefined)`) keep no state.
|
|
147
143
|
if (edytor && !equationViews.has(edytor))
|
|
148
144
|
equationViews.set(edytor, {
|
|
@@ -160,7 +156,7 @@
|
|
|
160
156
|
if (!view || !owns()) return;
|
|
161
157
|
const { editor } = view;
|
|
162
158
|
const { panel } = options;
|
|
163
|
-
return panel && editor.panel.mount(node,
|
|
159
|
+
return panel && editor.panel.mount(node, panel, editor, () => editor.target !== null);
|
|
164
160
|
},
|
|
165
161
|
// A block equation this view just created empty (a slash pick, Turn into) opens its editor.
|
|
166
162
|
onAfterOperation: (change) => {
|
|
@@ -207,7 +203,7 @@
|
|
|
207
203
|
],
|
|
208
204
|
blocks: {
|
|
209
205
|
equation: {
|
|
210
|
-
...
|
|
206
|
+
...forms.blocks.equation,
|
|
211
207
|
snippet: equation,
|
|
212
208
|
empty: { content: [], children: [] },
|
|
213
209
|
presets: [
|
|
@@ -224,19 +220,13 @@
|
|
|
224
220
|
]),
|
|
225
221
|
group: 'Advanced blocks'
|
|
226
222
|
}
|
|
227
|
-
]
|
|
228
|
-
html: (block) =>
|
|
229
|
-
`<div data-edytor-equation>${renderer.mathml(expressionOf(block.data), true)}</div>`,
|
|
230
|
-
plain: (block) => expressionOf(block.data),
|
|
231
|
-
parse: (element) => parseEquation(element, true)
|
|
223
|
+
]
|
|
232
224
|
}
|
|
233
225
|
},
|
|
234
226
|
inlineBlocks: {
|
|
235
227
|
[INLINE]: {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
html: (data) => renderer.mathml(expressionOf(data), false),
|
|
239
|
-
parse: (element) => parseEquation(element, false)
|
|
228
|
+
...forms.inlineBlocks.inlineEquation,
|
|
229
|
+
snippet: inlineEquation
|
|
240
230
|
}
|
|
241
231
|
}
|
|
242
232
|
},
|