edytor 0.0.11 → 0.1.0-next.16
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 +77 -197
- package/dist/block/block.svelte.d.ts +156 -69
- package/dist/block/block.svelte.js +324 -355
- package/dist/block/block.utils.d.ts +191 -24
- package/dist/block/block.utils.js +327 -460
- package/dist/block/contentRange.d.ts +4 -0
- package/dist/block/contentRange.js +20 -0
- package/dist/block/inlineBlock.svelte.d.ts +26 -19
- package/dist/block/inlineBlock.svelte.js +91 -39
- package/dist/clipboard/clipboard.d.ts +4 -0
- package/dist/clipboard/clipboard.js +4 -0
- package/dist/clipboard/createClipboardFragment.d.ts +3 -0
- package/dist/clipboard/createClipboardFragment.js +103 -0
- package/dist/clipboard/fragmentData.d.ts +6 -0
- package/dist/clipboard/fragmentData.js +74 -0
- package/dist/clipboard/htmlFlow.d.ts +22 -0
- package/dist/clipboard/htmlFlow.js +167 -0
- package/dist/clipboard/insertClipboardFragment.d.ts +18 -0
- package/dist/clipboard/insertClipboardFragment.js +48 -0
- package/dist/clipboard/serializeClipboardFragment.d.ts +7 -0
- package/dist/clipboard/serializeClipboardFragment.js +53 -0
- package/dist/clipboard/textBlocks.d.ts +23 -0
- package/dist/clipboard/textBlocks.js +103 -0
- package/dist/clipboard/types.d.ts +20 -0
- package/dist/clipboard/types.js +2 -0
- package/dist/cloudflare/DocumentRoom.d.ts +586 -0
- package/dist/cloudflare/DocumentRoom.js +1706 -0
- package/dist/cloudflare/index.d.ts +8 -0
- package/dist/cloudflare/index.js +8 -0
- package/dist/cloudflare/routeDocumentSocket.d.ts +33 -0
- package/dist/cloudflare/routeDocumentSocket.js +51 -0
- package/dist/collaboration/RemoteSelections.svelte +94 -0
- package/dist/collaboration/RemoteSelections.svelte.d.ts +7 -0
- package/dist/collaboration/awarenessSelection.d.ts +127 -0
- package/dist/collaboration/awarenessSelection.js +199 -0
- package/dist/collaboration/documentSync.d.ts +20 -0
- package/dist/collaboration/documentSync.js +13 -0
- package/dist/collaboration/index.d.ts +3 -0
- package/dist/collaboration/index.js +3 -0
- package/dist/collaboration/providers.d.ts +13 -0
- package/dist/collaboration/providers.js +21 -0
- package/dist/collaboration/remoteSelection.d.ts +21 -0
- package/dist/collaboration/remoteSelection.js +159 -0
- package/dist/components/Block.svelte +223 -15
- package/dist/components/Block.svelte.d.ts +4 -2
- package/dist/components/Content.svelte +128 -32
- package/dist/components/Content.svelte.d.ts +6 -2
- package/dist/components/Edytor.svelte +308 -110
- package/dist/components/Edytor.svelte.d.ts +64 -20
- package/dist/components/InlineBlock.svelte +38 -7
- package/dist/components/InlineBlock.svelte.d.ts +5 -2
- package/dist/components/Mark.svelte +29 -13
- package/dist/components/Mark.svelte.d.ts +4 -4
- package/dist/components/Suggestion.svelte +48 -0
- package/dist/components/Suggestion.svelte.d.ts +7 -0
- package/dist/components/SuggestionRanges.svelte +58 -0
- package/dist/components/SuggestionRanges.svelte.d.ts +7 -0
- package/dist/components/Text.svelte +107 -14
- package/dist/components/Text.svelte.d.ts +8 -1
- package/dist/constants.d.ts +0 -2
- package/dist/constants.js +0 -2
- package/dist/crdt/admission.d.ts +141 -0
- package/dist/crdt/admission.js +147 -0
- package/dist/crdt/anchors.d.ts +47 -0
- package/dist/crdt/anchors.js +42 -0
- package/dist/crdt/attribution/attribution.d.ts +169 -0
- package/dist/crdt/attribution/attribution.js +136 -0
- package/dist/crdt/attribution/block.d.ts +200 -0
- package/dist/crdt/attribution/block.js +327 -0
- package/dist/crdt/attribution/index.d.ts +9 -0
- package/dist/crdt/attribution/index.js +9 -0
- package/dist/crdt/data.d.ts +81 -0
- package/dist/crdt/data.js +383 -0
- package/dist/crdt/document.d.ts +590 -0
- package/dist/crdt/document.js +1160 -0
- package/dist/crdt/edytor-doc.d.ts +752 -0
- package/dist/crdt/edytor-doc.js +2382 -0
- package/dist/crdt/engine-api.d.ts +153 -0
- package/dist/crdt/engine.d.ts +37 -0
- package/dist/crdt/engine.js +50 -0
- package/dist/crdt/flow.d.ts +104 -0
- package/dist/crdt/flow.js +229 -0
- package/dist/crdt/index.d.ts +630 -0
- package/dist/crdt/index.js +168 -0
- package/dist/crdt/migration/legacy-schema.d.ts +61 -0
- package/dist/crdt/migration/legacy-schema.js +149 -0
- package/dist/crdt/migration/migrate.d.ts +67 -0
- package/dist/crdt/migration/migrate.js +219 -0
- package/dist/crdt/nodes.d.ts +120 -0
- package/dist/crdt/nodes.js +56 -0
- package/dist/crdt/placement/model.d.ts +383 -0
- package/dist/crdt/placement/model.js +811 -0
- package/dist/crdt/placement/rank.d.ts +57 -0
- package/dist/crdt/placement/rank.js +209 -0
- package/dist/crdt/protocols/auth.d.ts +28 -0
- package/dist/crdt/protocols/auth.js +43 -0
- package/dist/crdt/protocols/awareness.d.ts +87 -0
- package/dist/crdt/protocols/awareness.js +271 -0
- package/dist/crdt/protocols/envelope.d.ts +75 -0
- package/dist/crdt/protocols/envelope.js +89 -0
- package/dist/crdt/protocols/observable.d.ts +19 -0
- package/dist/crdt/protocols/observable.js +26 -0
- package/dist/crdt/protocols/sync.d.ts +82 -0
- package/dist/crdt/protocols/sync.js +288 -0
- package/dist/crdt/providers/container.d.ts +23 -0
- package/dist/crdt/providers/container.js +64 -0
- package/dist/crdt/providers/index.d.ts +282 -0
- package/dist/crdt/providers/index.js +118 -0
- package/dist/crdt/providers/indexeddb.d.ts +196 -0
- package/dist/crdt/providers/indexeddb.js +332 -0
- package/dist/crdt/providers/room.d.ts +193 -0
- package/dist/crdt/providers/room.js +444 -0
- package/dist/crdt/providers/websocket.d.ts +223 -0
- package/dist/crdt/providers/websocket.js +601 -0
- package/dist/crdt/rand.d.ts +22 -0
- package/dist/crdt/rand.js +22 -0
- package/dist/crdt/rangeDelete.d.ts +85 -0
- package/dist/crdt/rangeDelete.js +126 -0
- package/dist/crdt/schema.d.ts +96 -0
- package/dist/crdt/schema.js +79 -0
- package/dist/crdt/semantics.d.ts +81 -0
- package/dist/crdt/semantics.js +57 -0
- package/dist/crdt/structs.d.ts +106 -0
- package/dist/crdt/structs.js +119 -0
- package/dist/crdt/text/deletes.d.ts +23 -0
- package/dist/crdt/text/deletes.js +608 -0
- package/dist/crdt/text/model.d.ts +280 -0
- package/dist/crdt/text/model.js +554 -0
- package/dist/crdt/text/runs.d.ts +212 -0
- package/dist/crdt/text/runs.js +1142 -0
- package/dist/crdt/vendor/yjs/API-NOTES.md +59 -0
- package/dist/crdt/vendor/yjs/LICENSE +23 -0
- package/dist/crdt/vendor/yjs/UPSTREAM.md +653 -0
- package/dist/crdt/vendor/yjs/dts/global.d.ts +52 -0
- package/dist/crdt/vendor/yjs/dts/index.d.ts +25 -0
- package/dist/crdt/vendor/yjs/dts/structs/AbstractStruct.d.ts +38 -0
- package/dist/crdt/vendor/yjs/dts/structs/GC.d.ts +25 -0
- package/dist/crdt/vendor/yjs/dts/structs/Item.d.ts +748 -0
- package/dist/crdt/vendor/yjs/dts/structs/Skip.d.ts +30 -0
- package/dist/crdt/vendor/yjs/dts/utils/BlockSet.d.ts +34 -0
- package/dist/crdt/vendor/yjs/dts/utils/Doc.d.ts +198 -0
- package/dist/crdt/vendor/yjs/dts/utils/EventHandler.d.ts +17 -0
- package/dist/crdt/vendor/yjs/dts/utils/ID.d.ts +20 -0
- package/dist/crdt/vendor/yjs/dts/utils/RangeCursor.d.ts +198 -0
- package/dist/crdt/vendor/yjs/dts/utils/RelativePosition.d.ts +80 -0
- package/dist/crdt/vendor/yjs/dts/utils/StructStore.d.ts +61 -0
- package/dist/crdt/vendor/yjs/dts/utils/Transaction.d.ts +129 -0
- package/dist/crdt/vendor/yjs/dts/utils/UndoManager.d.ts +205 -0
- package/dist/crdt/vendor/yjs/dts/utils/UpdateDecoder.d.ts +170 -0
- package/dist/crdt/vendor/yjs/dts/utils/UpdateEncoder.d.ts +164 -0
- package/dist/crdt/vendor/yjs/dts/utils/YEvent.d.ts +93 -0
- package/dist/crdt/vendor/yjs/dts/utils/content-helper.d.ts +1 -0
- package/dist/crdt/vendor/yjs/dts/utils/encoding-helpers.d.ts +5 -0
- package/dist/crdt/vendor/yjs/dts/utils/encoding.d.ts +26 -0
- package/dist/crdt/vendor/yjs/dts/utils/ids.d.ts +407 -0
- package/dist/crdt/vendor/yjs/dts/utils/isParentOf.d.ts +1 -0
- package/dist/crdt/vendor/yjs/dts/utils/meta.d.ts +25 -0
- package/dist/crdt/vendor/yjs/dts/utils/renderer-helpers.d.ts +98 -0
- package/dist/crdt/vendor/yjs/dts/utils/schemas.d.ts +2 -0
- package/dist/crdt/vendor/yjs/dts/utils/transaction-helpers.d.ts +15 -0
- package/dist/crdt/vendor/yjs/dts/utils/updates.d.ts +70 -0
- package/dist/crdt/vendor/yjs/dts/ynode.d.ts +655 -0
- package/dist/crdt/vendor/yjs/global.d.ts +52 -0
- package/dist/crdt/vendor/yjs/src/index.js +64 -0
- package/dist/crdt/vendor/yjs/src/structs/AbstractStruct.js +64 -0
- package/dist/crdt/vendor/yjs/src/structs/GC.js +75 -0
- package/dist/crdt/vendor/yjs/src/structs/Item.js +1538 -0
- package/dist/crdt/vendor/yjs/src/structs/Skip.js +72 -0
- package/dist/crdt/vendor/yjs/src/utils/BlockSet.js +291 -0
- package/dist/crdt/vendor/yjs/src/utils/Doc.js +255 -0
- package/dist/crdt/vendor/yjs/src/utils/EventHandler.js +75 -0
- package/dist/crdt/vendor/yjs/src/utils/ID.js +59 -0
- package/dist/crdt/vendor/yjs/src/utils/RangeCursor.js +407 -0
- package/dist/crdt/vendor/yjs/src/utils/RelativePosition.js +301 -0
- package/dist/crdt/vendor/yjs/src/utils/StructStore.js +134 -0
- package/dist/crdt/vendor/yjs/src/utils/Transaction.js +458 -0
- package/dist/crdt/vendor/yjs/src/utils/UndoManager.js +554 -0
- package/dist/crdt/vendor/yjs/src/utils/UpdateDecoder.js +284 -0
- package/dist/crdt/vendor/yjs/src/utils/UpdateEncoder.js +323 -0
- package/dist/crdt/vendor/yjs/src/utils/YEvent.js +158 -0
- package/dist/crdt/vendor/yjs/src/utils/content-helper.js +0 -0
- package/dist/crdt/vendor/yjs/src/utils/encoding-helpers.js +110 -0
- package/dist/crdt/vendor/yjs/src/utils/encoding.js +662 -0
- package/dist/crdt/vendor/yjs/src/utils/ids.js +1504 -0
- package/dist/crdt/vendor/yjs/src/utils/isParentOf.js +19 -0
- package/dist/crdt/vendor/yjs/src/utils/meta.js +74 -0
- package/dist/crdt/vendor/yjs/src/utils/renderer-helpers.js +186 -0
- package/dist/crdt/vendor/yjs/src/utils/schemas.js +3 -0
- package/dist/crdt/vendor/yjs/src/utils/transaction-helpers.js +391 -0
- package/dist/crdt/vendor/yjs/src/utils/updates.js +264 -0
- package/dist/crdt/vendor/yjs/src/ynode.js +2897 -0
- package/dist/dnd/pragmatic.d.ts +22 -0
- package/dist/dnd/pragmatic.js +26 -0
- package/dist/edytor.svelte.d.ts +323 -54
- package/dist/edytor.svelte.js +771 -197
- package/dist/edytor.utils.d.ts +49 -2
- package/dist/edytor.utils.js +65 -76
- package/dist/events/beforeInputCommands.d.ts +21 -0
- package/dist/events/beforeInputCommands.js +328 -0
- package/dist/events/beforeInputDeleteCommands.d.ts +3 -0
- package/dist/events/beforeInputDeleteCommands.js +245 -0
- package/dist/events/dataTransferPayload.d.ts +6 -0
- package/dist/events/dataTransferPayload.js +9 -0
- package/dist/events/domTextOffset.d.ts +12 -0
- package/dist/events/domTextOffset.js +52 -0
- package/dist/events/events.utils.d.ts +3 -0
- package/dist/events/events.utils.js +13 -0
- package/dist/events/nativeInteractiveControl.d.ts +31 -0
- package/dist/events/nativeInteractiveControl.js +98 -0
- package/dist/events/onBeforeInput.d.ts +10 -1
- package/dist/events/onBeforeInput.js +449 -330
- package/dist/events/onCopy.d.ts +7 -0
- package/dist/events/onCopy.js +30 -0
- package/dist/events/onCut.d.ts +8 -0
- package/dist/events/onCut.js +13 -0
- package/dist/events/onDrop.d.ts +16 -0
- package/dist/events/onDrop.js +158 -0
- package/dist/events/onFocus.d.ts +4 -0
- package/dist/events/onFocus.js +166 -0
- package/dist/events/onInput.d.ts +20 -0
- package/dist/events/onInput.js +249 -0
- package/dist/events/onKeyDown.js +191 -11
- package/dist/events/onPaste.d.ts +3 -0
- package/dist/events/onPaste.js +108 -0
- package/dist/events/wordBoundary.d.ts +2 -0
- package/dist/events/wordBoundary.js +58 -0
- package/dist/index.d.ts +38 -1
- package/dist/index.js +36 -1
- package/dist/kinds.d.ts +100 -0
- package/dist/kinds.js +198 -0
- package/dist/plugins/arrowMove/arrowMove.d.ts +1 -1
- package/dist/plugins/arrowMove/arrowMove.js +30 -65
- package/dist/plugins/blockHandles/BlockHandle.svelte +152 -0
- package/dist/plugins/blockHandles/BlockHandle.svelte.d.ts +12 -0
- package/dist/plugins/blockHandles/BlockHandleController.svelte.d.ts +208 -0
- package/dist/plugins/blockHandles/BlockHandleController.svelte.js +823 -0
- package/dist/plugins/blockHandles/BlockHandles.svelte +151 -0
- package/dist/plugins/blockHandles/BlockHandles.svelte.d.ts +20 -0
- package/dist/plugins/blockHandles/autoScroll.d.ts +8 -0
- package/dist/plugins/blockHandles/autoScroll.js +25 -0
- package/dist/plugins/blockHandles/blockHandlesPlugin.d.ts +37 -0
- package/dist/plugins/blockHandles/blockHandlesPlugin.js +100 -0
- package/dist/plugins/blockHandles/dragPreview.d.ts +33 -0
- package/dist/plugins/blockHandles/dragPreview.js +228 -0
- package/dist/plugins/blockMenu/BlockMenu.svelte +301 -0
- package/dist/plugins/blockMenu/BlockMenu.svelte.d.ts +9 -0
- package/dist/plugins/blockMenu/BlockMenuController.svelte.d.ts +102 -0
- package/dist/plugins/blockMenu/BlockMenuController.svelte.js +245 -0
- package/dist/plugins/blockMenu/blockMenuPlugin.d.ts +11 -0
- package/dist/plugins/blockMenu/blockMenuPlugin.js +89 -0
- package/dist/plugins/code/CodePlugin.svelte +210 -163
- package/dist/plugins/code/CodePlugin.svelte.d.ts +1 -3
- package/dist/plugins/code/code.css +92 -0
- package/dist/plugins/icons.d.ts +2 -0
- package/dist/plugins/icons.js +31 -0
- package/dist/plugins/image/ImageEmpty.svelte +69 -0
- package/dist/plugins/image/ImageEmpty.svelte.d.ts +8 -0
- package/dist/plugins/image/ImagePlugin.svelte +74 -12
- package/dist/plugins/image/ImagePlugin.svelte.d.ts +15 -0
- package/dist/plugins/image/image.d.ts +2 -0
- package/dist/plugins/image/image.js +7 -0
- package/dist/plugins/index.d.ts +14 -1
- package/dist/plugins/index.js +10 -1
- package/dist/plugins/keepInView.d.ts +4 -0
- package/dist/plugins/keepInView.js +6 -0
- package/dist/plugins/markdownShortcuts.d.ts +3 -0
- package/dist/plugins/markdownShortcuts.js +104 -0
- package/dist/plugins/mention/MentionPlugin.svelte +28 -31
- package/dist/plugins/richtext/RichTextPlugin.svelte +411 -200
- package/dist/plugins/richtext/RichTextPlugin.svelte.d.ts +8 -7
- package/dist/plugins/richtext/richTextOperations.d.ts +53 -0
- package/dist/plugins/richtext/richTextOperations.js +200 -0
- package/dist/plugins/slashMenu/SlashMenu.svelte +297 -0
- package/dist/plugins/slashMenu/SlashMenu.svelte.d.ts +11 -0
- package/dist/plugins/slashMenu/SlashMenuController.svelte.d.ts +56 -0
- package/dist/plugins/slashMenu/SlashMenuController.svelte.js +275 -0
- package/dist/plugins/slashMenu/slashMenuPlugin.d.ts +25 -0
- package/dist/plugins/slashMenu/slashMenuPlugin.js +105 -0
- package/dist/plugins/suggestions/SuggestionBars.svelte +142 -0
- package/dist/plugins/suggestions/SuggestionBars.svelte.d.ts +10 -0
- package/dist/plugins/suggestions/suggestionsPlugin.d.ts +28 -0
- package/dist/plugins/suggestions/suggestionsPlugin.js +53 -0
- package/dist/plugins/toolbar/Toolbar.svelte +341 -0
- package/dist/plugins/toolbar/Toolbar.svelte.d.ts +9 -0
- package/dist/plugins/toolbar/ToolbarController.svelte.d.ts +85 -0
- package/dist/plugins/toolbar/ToolbarController.svelte.js +150 -0
- package/dist/plugins/toolbar/toolbarPlugin.d.ts +16 -0
- package/dist/plugins/toolbar/toolbarPlugin.js +40 -0
- package/dist/plugins.d.ts +249 -40
- package/dist/plugins.js +11 -5
- package/dist/selection/domSelection.d.ts +29 -0
- package/dist/selection/domSelection.js +230 -0
- package/dist/selection/replaceSelection.d.ts +143 -0
- package/dist/selection/replaceSelection.js +316 -0
- package/dist/selection/selection.svelte.d.ts +275 -37
- package/dist/selection/selection.svelte.js +1162 -331
- package/dist/selection/selection.utils.d.ts +35 -4
- package/dist/selection/selection.utils.js +309 -100
- package/dist/selection/visibility.d.ts +88 -0
- package/dist/selection/visibility.js +140 -0
- package/dist/session/attempt.d.ts +190 -0
- package/dist/session/attempt.js +188 -0
- package/dist/session/bindings.d.ts +16 -0
- package/dist/session/bindings.js +262 -0
- package/dist/session/commands.d.ts +158 -0
- package/dist/session/commands.js +601 -0
- package/dist/session/composition.svelte.d.ts +114 -0
- package/dist/session/composition.svelte.js +489 -0
- package/dist/session/editing/text.d.ts +33 -0
- package/dist/session/editing/text.js +36 -0
- package/dist/session/handles.d.ts +63 -0
- package/dist/session/handles.js +123 -0
- package/dist/session/history.d.ts +49 -0
- package/dist/session/history.js +131 -0
- package/dist/session/keymap.d.ts +42 -0
- package/dist/session/keymap.js +144 -0
- package/dist/session/moves.d.ts +32 -0
- package/dist/session/moves.js +116 -0
- package/dist/session/navigation.d.ts +51 -0
- package/dist/session/navigation.js +312 -0
- package/dist/session/props.d.ts +28 -0
- package/dist/session/props.js +162 -0
- package/dist/session/selection.d.ts +126 -0
- package/dist/session/selection.js +227 -0
- package/dist/session/suggestions.svelte.d.ts +125 -0
- package/dist/session/suggestions.svelte.js +329 -0
- package/dist/session/virtual.d.ts +33 -0
- package/dist/session/virtual.js +182 -0
- package/dist/surface/attributes.d.ts +36 -0
- package/dist/surface/attributes.js +143 -0
- package/dist/surface/cells.d.ts +103 -0
- package/dist/surface/cells.js +215 -0
- package/dist/surface/observer.svelte.d.ts +70 -0
- package/dist/surface/observer.svelte.js +969 -0
- package/dist/surface/overlay.d.ts +33 -0
- package/dist/surface/overlay.js +91 -0
- package/dist/surface/pin.svelte.d.ts +56 -0
- package/dist/surface/pin.svelte.js +108 -0
- package/dist/surface/projector.svelte.d.ts +69 -0
- package/dist/surface/projector.svelte.js +486 -0
- package/dist/text/deltas.d.ts +14 -3
- package/dist/text/deltas.js +27 -90
- package/dist/text/text.svelte.d.ts +43 -31
- package/dist/text/text.svelte.js +88 -69
- package/dist/text/text.utils.d.ts +7 -2
- package/dist/text/text.utils.js +121 -97
- package/dist/themes/notion.css +473 -0
- package/dist/utils/diffText.d.ts +15 -0
- package/dist/utils/diffText.js +26 -0
- package/dist/utils/json.d.ts +90 -3
- package/dist/utils/json.js +369 -2
- package/dist/utils.d.ts +3 -1
- package/dist/utils.js +2 -0
- package/package.json +112 -50
- package/dist/block/content.svelte.d.ts +0 -14
- package/dist/block/content.svelte.js +0 -40
- package/dist/components/ReadonlyEditor.svelte +0 -46
- package/dist/components/ReadonlyEditor.svelte.d.ts +0 -4
- package/dist/components/readonlyElements.svelte.d.ts +0 -82
- package/dist/components/readonlyElements.svelte.js +0 -144
- package/dist/dnd.svelte.d.ts +0 -17
- package/dist/dnd.svelte.js +0 -125
- package/dist/hotkeys.d.ts +0 -27
- package/dist/hotkeys.js +0 -282
- package/dist/localProvider.d.ts +0 -82
- package/dist/localProvider.js +0 -267
- package/dist/plugins/code/prism.css +0 -141
- package/dist/utils/jsx.d.ts +0 -25
- package/dist/utils/jsx.js +0 -66
- package/dist/utils/serialize.js +0 -1
- /package/dist/{utils/serialize.d.ts → crdt/engine-api.js} +0 -0
package/README.md
CHANGED
|
@@ -1,231 +1,111 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<img src="cover.jpg" alt="Edytor Logo" width="60%"/>
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
<p>A collaborative block editor for Svelte 5, on a Yjs v14 engine</p>
|
|
5
5
|
|
|
6
|
-
[](https://badge.fury.io/js/edytor)
|
|
7
6
|
[](https://opensource.org/licenses/MIT)
|
|
8
|
-
[](http://makeapullrequest.com)
|
|
9
7
|
[](https://svelte.dev)
|
|
10
|
-
[](https://www.typescriptlang.org/)
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
<a href="
|
|
14
|
-
<a href="#quick-start">Quick
|
|
9
|
+
<p>
|
|
10
|
+
<a href="https://edytor-docs.beynar.workers.dev/docs">Documentation</a> •
|
|
11
|
+
<a href="#quick-start">Quick start</a> •
|
|
12
|
+
<a href="https://edytor-docs.beynar.workers.dev/docs/reference/migration">Migrating from 0.0.11</a>
|
|
15
13
|
</p>
|
|
16
14
|
</div>
|
|
17
15
|
|
|
18
|
-
Edytor aims to be
|
|
19
|
-
|
|
20
|
-
## ⚠️ Work in progress
|
|
21
|
-
|
|
22
|
-
Edytor is currently in the early stages of development. It is not yet ready for production use.
|
|
23
|
-
I welcome early contributors to help us build a better editor for Svelte.
|
|
24
|
-
Just run it, see what you can do with it, and open issues or PRs.
|
|
25
|
-
|
|
26
|
-
If you want to submit an issue please share the json value of the document. It will help understand and fix the issue.
|
|
27
|
-
|
|
28
|
-
## ✨ Features
|
|
29
|
-
|
|
30
|
-
- 📑 **Customizable with snippets**: Use snippets to render your own blocks and marks
|
|
31
|
-
- 🎨 **Rich Text Formatting**: Full support for marks, blocks and inline blocks.
|
|
32
|
-
- 🤝 **Real-time Collaboration**: Uses Y.js as data store, collaborative editing is built-in
|
|
33
|
-
- 🔌 **Plugin System**: Extensible architecture for custom features. I try to make every action performed by the editor hackable and preventable to let you build your own features.
|
|
34
|
-
- ⚡ **High Performance**: Optimized for large documents, fine grained update at the leaf level thanks to Y.js and Svelte's reactivity
|
|
35
|
-
- 🔄 **Undo/Redo**: Built-in history management
|
|
36
|
-
- 📦 **Lightweight**: Relatively small bundle size compared to other rich text editors
|
|
37
|
-
- 📦 **AI copilot ready**: Support inline text suggestions for ai completions.
|
|
38
|
-
|
|
39
|
-
## ✨ Things that are ready
|
|
40
|
-
|
|
41
|
-
- [x] YJS backed editing
|
|
42
|
-
- [x] Basic block operations and text operations.
|
|
43
|
-
- [x] Stable data structure
|
|
44
|
-
- [x] Undo/Redo
|
|
45
|
-
- [x] Rich text formatting
|
|
46
|
-
- [x] Customizable with snippets
|
|
47
|
-
- [x] Plugin system
|
|
48
|
-
- [x] Text suggestions
|
|
49
|
-
- [x] Inline blocks
|
|
50
|
-
- [x] Nesting
|
|
51
|
-
- [x] Selection + movable blocks
|
|
52
|
-
- [x] Content transformation
|
|
53
|
-
- [x] Content normalization
|
|
54
|
-
- [x] Island blocks
|
|
55
|
-
- [x] Customizable hotkeys
|
|
56
|
-
- [x] Void elements and editable void elements
|
|
57
|
-
- [x] Text spanning deletion
|
|
58
|
-
- [x] Block spanning deletion.
|
|
59
|
-
- [x] Readable JSON data structure
|
|
60
|
-
- [x] Readonly edytor to lightweightly render static content without the Y.js extra works.
|
|
61
|
-
|
|
62
|
-
## ✨ Things that are not ready
|
|
63
|
-
|
|
64
|
-
- [ ] DND
|
|
65
|
-
- [ ] Battle tested collaborative editing + awareness + providers
|
|
66
|
-
- [ ] Children normalization
|
|
67
|
-
- [ ] Children transformation
|
|
68
|
-
- [ ] Block suggestions
|
|
69
|
-
- [ ] Reactive data (inline)block properties with syncrostate.
|
|
70
|
-
|
|
71
|
-
## 🧠 Concepts
|
|
72
|
-
|
|
73
|
-
Edytor structure is built around this key concepts:
|
|
74
|
-
|
|
75
|
-
- **Blocks**: Container elements like paragraphs, headings, and lists
|
|
76
|
-
- **Content**: The content of a block is an array of inlines blocks or text and marks.
|
|
77
|
-
- **Children**: Children are the blocks that are directly inside a block. They allow an infinite nesting.
|
|
78
|
-
- **Marks**: Texts are simply text with marks that define the formatting.
|
|
79
|
-
- **Inline blocks**: Inline blocks are inline elements that are no editable and render custom components like footnotes, equations, etc.
|
|
80
|
-
|
|
81
|
-
Schematic example of a document:
|
|
82
|
-
(content and children are not dom element, i put them here to help you understand the structure)
|
|
83
|
-
|
|
84
|
-
```html
|
|
85
|
-
<root>
|
|
86
|
-
<block>
|
|
87
|
-
<content>
|
|
88
|
-
<text mark="bold">Hello</text>
|
|
89
|
-
<text>World</text>
|
|
90
|
-
<inline-block type="footnote">
|
|
91
|
-
<!-- Inline block are rendered by the user code -->
|
|
92
|
-
</inline-block>
|
|
93
|
-
</content>
|
|
94
|
-
<children>
|
|
95
|
-
<nested-block>
|
|
96
|
-
<content>
|
|
97
|
-
<text>World</text>
|
|
98
|
-
</content>
|
|
99
|
-
</nested-block>
|
|
100
|
-
<nested-block>
|
|
101
|
-
<content>
|
|
102
|
-
<text>World</text>
|
|
103
|
-
</content>
|
|
104
|
-
<children>
|
|
105
|
-
<nested-block>
|
|
106
|
-
<content>
|
|
107
|
-
<text>World</text>
|
|
108
|
-
</content>
|
|
109
|
-
</nested-block>
|
|
110
|
-
</children>
|
|
111
|
-
</nested-block>
|
|
112
|
-
</children>
|
|
113
|
-
</block>
|
|
114
|
-
</root>
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### Blocks
|
|
118
|
-
|
|
119
|
-
Blocks are the container elements like paragraphs, headings, and lists.
|
|
120
|
-
They have a content that is an array of inlines blocks or text.
|
|
121
|
-
They may have children that is an array of nested-blocks.
|
|
122
|
-
Blocks can be nested unless they are void or inside an island
|
|
123
|
-
|
|
124
|
-
An island is a block that is editable but is structuraly stable and isolated from the rest of the document.
|
|
125
|
-
It is impossible to merge an island with another block. It is also impossible to move another block inside an island.
|
|
126
|
-
You may think of an island as a block that is editable but is not completely part of the document structure and isolated from the rest of the document.
|
|
16
|
+
Edytor aims to be for Svelte what Slate.js is for React: a heavily customizable editor with an API to build any kind of collaborative rich text editor.
|
|
127
17
|
|
|
128
|
-
|
|
129
|
-
Void blocks can render and edit their content anyway. That is usefull to render caption.
|
|
130
|
-
You may think of a void block as a block that is completely independent from the rest of the document.
|
|
131
|
-
Void blocks acts also like an island but are even less editables.
|
|
18
|
+
> **Work in progress.** Edytor is a pre-release (`0.1.0-next.16`, `edytor@next` on npm) and not ready for production; the API changes between releases without a compatibility layer. The untagged `edytor@0.0.11` on npm predates the current API. Issues and PRs are welcome: when you report a bug, include the document's JSON value.
|
|
132
19
|
|
|
133
|
-
|
|
20
|
+
## Features
|
|
134
21
|
|
|
135
|
-
|
|
22
|
+
- **Notion-style editing out of the box.** `<Edytor />` alone is a rich text editor with images: headings, lists, to-dos, toggles, callouts, quotes, dividers, ten marks, Notion's markdown shortcuts and hotkeys. Add the Notion theme, block handles with a block menu (drag one block, or every block the selection covers), a slash menu, a selection toolbar and code blocks.
|
|
23
|
+
- **Your markup.** Blocks, marks and inline atoms render through your Svelte snippets; the slash menu, toolbar, block menu and handles take a snippet and keep their behavior.
|
|
24
|
+
- **Synced properties.** `block.data`, `atom.data` and `edytor.data` read and write like plain objects (`bind:value={block.data.title}`); each property and each array item syncs on its own, so concurrent edits of different properties, or of different items of one array, merge.
|
|
25
|
+
- **AI suggestions.** `edytor.suggestions.add(position, content)` proposes text, paragraphs, lists, to-dos or images after, before or inside a block, at the end of its text, or in place of the selection; it streams in, shows only on your screen, and becomes one undo step when accepted ([Suggestions](https://edytor-docs.beynar.workers.dev/docs/editor/suggestions)).
|
|
26
|
+
- **Plugins that can veto anything.** Every command is prepared before it writes; plugins see the command and each planned step and can refuse or replace it.
|
|
27
|
+
- **Real-time collaboration.** One `EdytorDocument` shared by any number of views, or none (headless). Presence cursors, identity-preserving moves, splits and merges, and undo that only takes back your own edits.
|
|
28
|
+
- **Offline first.** A local IndexedDB copy and cross-tab sync; offline edits survive reloads and reach the server on reconnect.
|
|
29
|
+
- **A Cloudflare Durable Object room.** `edytor/cloudflare` stores in SQLite, acknowledges after the write, binds identity to the socket and hibernates.
|
|
30
|
+
- **Headless and Worker-safe.** `edytor/crdt/edytor` runs in Node and Workers without Svelte.
|
|
136
31
|
|
|
137
|
-
|
|
32
|
+
## Install
|
|
138
33
|
|
|
139
|
-
|
|
140
|
-
They are rendered by the user code and are not editable nor focusable.
|
|
141
|
-
They have a data property
|
|
142
|
-
|
|
143
|
-
## 🚀 Quick Start
|
|
144
|
-
|
|
145
|
-
### Installation (not published yet)
|
|
34
|
+
The pre-release is on npm under the `next` tag. Name the tag: a bare `edytor` is the old, incompatible `0.0.11`.
|
|
146
35
|
|
|
147
36
|
```bash
|
|
148
|
-
|
|
149
|
-
# or
|
|
150
|
-
yarn add edytor
|
|
151
|
-
# or
|
|
152
|
-
pnpm add edytor
|
|
37
|
+
pnpm add edytor@next
|
|
153
38
|
```
|
|
154
39
|
|
|
155
|
-
|
|
40
|
+
`svelte@^5` is a peer dependency. Do not install `yjs`: the v14 engine is vendored (`edytor/crdt`). See [installation](https://edytor-docs.beynar.workers.dev/docs/getting-started).
|
|
41
|
+
|
|
42
|
+
## Quick start
|
|
156
43
|
|
|
157
44
|
```svelte
|
|
158
|
-
<script>
|
|
159
|
-
import {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
45
|
+
<script lang="ts">
|
|
46
|
+
import {
|
|
47
|
+
Edytor,
|
|
48
|
+
codePlugin,
|
|
49
|
+
markdownShortcutsPlugin,
|
|
50
|
+
slashMenuPlugin,
|
|
51
|
+
toolbarPlugin,
|
|
52
|
+
blockMenuPlugin,
|
|
53
|
+
richTextPlaceholder,
|
|
54
|
+
type JSONDoc
|
|
55
|
+
} from 'edytor';
|
|
56
|
+
import 'edytor/themes/notion.css';
|
|
57
|
+
|
|
58
|
+
const value: JSONDoc = {
|
|
59
|
+
children: [{ type: 'paragraph', content: [{ text: 'Hello, World!' }] }]
|
|
168
60
|
};
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
61
|
+
const plugins = [
|
|
62
|
+
codePlugin,
|
|
63
|
+
markdownShortcutsPlugin,
|
|
64
|
+
slashMenuPlugin,
|
|
65
|
+
toolbarPlugin,
|
|
66
|
+
blockMenuPlugin
|
|
67
|
+
];
|
|
173
68
|
</script>
|
|
174
69
|
|
|
175
|
-
<
|
|
70
|
+
<div class="edytor-notion">
|
|
71
|
+
<Edytor
|
|
72
|
+
{value}
|
|
73
|
+
{plugins}
|
|
74
|
+
placeholder={richTextPlaceholder}
|
|
75
|
+
onChange={(root) => console.log(root)}
|
|
76
|
+
/>
|
|
77
|
+
</div>
|
|
176
78
|
```
|
|
177
79
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
I'm welcome to any contribution to improve the testing.
|
|
181
|
-
In the end, every block operation should be tested.
|
|
182
|
-
I've implemented a custom jsx parser to simplify testing the editor.
|
|
80
|
+
`<Edytor>` adds the rich text, image, arrow-move and suggestions plugins after yours, and block handles. To collaborate, name a room and a server running the [`edytor/cloudflare` room](https://edytor-docs.beynar.workers.dev/docs/server/quick-start):
|
|
183
81
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
82
|
+
```svelte
|
|
83
|
+
<Edytor
|
|
84
|
+
server="wss://example.com/rooms"
|
|
85
|
+
room={documentId}
|
|
86
|
+
params={{ token }}
|
|
87
|
+
actor={{ id: userId }}
|
|
88
|
+
/>
|
|
190
89
|
```
|
|
191
90
|
|
|
192
|
-
|
|
91
|
+
## Documentation
|
|
193
92
|
|
|
194
|
-
|
|
195
|
-
{
|
|
196
|
-
"type": "root",
|
|
197
|
-
"children": [{ "type": "paragraph", "content": [{ "text": "Hello, World!" }] }]
|
|
198
|
-
}
|
|
199
|
-
```
|
|
93
|
+
The [documentation site](https://edytor-docs.beynar.workers.dev/docs) is the single source for the API and behavior; this README only introduces the package.
|
|
200
94
|
|
|
201
|
-
|
|
95
|
+
- [Getting started](https://edytor-docs.beynar.workers.dev/docs/getting-started): installation, quick start, SvelteKit, entry points and bundle size
|
|
96
|
+
- [Concepts](https://edytor-docs.beynar.workers.dev/docs/concepts/document-model): the document model, blocks, void and island roles
|
|
97
|
+
- [Editor](https://edytor-docs.beynar.workers.dev/docs/editor/edytor-component): the component, commands, selection, history, clipboard, readonly
|
|
98
|
+
- [Plugins](https://edytor-docs.beynar.workers.dev/docs/plugins) and [customization](https://edytor-docs.beynar.workers.dev/docs/customization/blocks): bundled plugins, custom blocks and marks, [hotkeys and editing behavior](https://edytor-docs.beynar.workers.dev/docs/customization/hotkeys)
|
|
99
|
+
- [Collaboration](https://edytor-docs.beynar.workers.dev/docs/collaboration) and [server](https://edytor-docs.beynar.workers.dev/docs/server/quick-start): documents, providers, presence, the Durable Object room and its protocol
|
|
100
|
+
- [Reference](https://edytor-docs.beynar.workers.dev/docs/reference/document-api): the document API, [troubleshooting](https://edytor-docs.beynar.workers.dev/docs/reference/troubleshooting), [migration from 0.0.11](https://edytor-docs.beynar.workers.dev/docs/reference/migration), limitations
|
|
202
101
|
|
|
203
|
-
|
|
204
|
-
<root>
|
|
205
|
-
<paragraph>Hello, |World!|</paragraph>
|
|
206
|
-
</root>
|
|
207
|
-
```
|
|
102
|
+
## Contributing
|
|
208
103
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
</root>
|
|
217
|
-
);
|
|
218
|
-
|
|
219
|
-
edytor.selection.state.startBlock?.splitBlock({
|
|
220
|
-
index: edytor.selection.state.yStart,
|
|
221
|
-
text: edytor.selection.state.startText
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
expect(
|
|
225
|
-
<root>
|
|
226
|
-
<paragraph>Hello, </paragraph>
|
|
227
|
-
<paragraph>World!</paragraph>
|
|
228
|
-
</root>
|
|
229
|
-
);
|
|
230
|
-
});
|
|
104
|
+
`AGENTS.md` describes the architecture (one owner per fact), where to fix what, and the test lanes. The docs live in `site/content/docs`; a change to public behavior updates them in the same commit.
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
pnpm install
|
|
108
|
+
pnpm check && pnpm lint
|
|
109
|
+
pnpm exec vitest --run # unit and model fixtures (JSX fixture DSL in src/tests/jsx)
|
|
110
|
+
pnpm test:dom # editors mounted in jsdom
|
|
231
111
|
```
|
|
@@ -1,53 +1,119 @@
|
|
|
1
1
|
import { Text } from '../text/text.svelte.js';
|
|
2
2
|
import { Edytor } from '../edytor.svelte.js';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import type { JSONBlock, JSONText, JSONInlineBlock } from '../utils/json.js';
|
|
4
|
+
import { type BlockOperations } from './block.utils.js';
|
|
5
5
|
import type { BlockDefinition } from '../plugins.js';
|
|
6
6
|
import { InlineBlock } from './inlineBlock.svelte.js';
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import type { DocBlock } from '../crdt/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* An id-only block handle (§2.4 "Handles", R4): every getter reads the
|
|
10
|
+
* document index (transaction-aware), every mutator issues a command. The
|
|
11
|
+
* view keeps one per id (`edytor.idToBlock`); `node` is the element the core
|
|
12
|
+
* renders for it (O45).
|
|
13
|
+
*/
|
|
14
|
+
/** Mark an element inside a block's markup as non-editable chrome (`block.void`, a preview's too). */
|
|
15
|
+
export declare const voidChrome: (node: HTMLElement) => void;
|
|
9
16
|
export declare class Block {
|
|
10
17
|
#private;
|
|
11
18
|
readonly: boolean;
|
|
12
|
-
edytor: Edytor;
|
|
13
|
-
|
|
14
|
-
parent?: Block;
|
|
15
|
-
yChildren: Y.Array<YBlock>;
|
|
16
|
-
yContent: Y.Array<YBlock | Y.Text>;
|
|
17
|
-
children: Block[];
|
|
18
|
-
content: (Text | InlineBlock)[];
|
|
19
|
-
id: string;
|
|
20
|
-
data: Record<string, any>;
|
|
19
|
+
readonly edytor: Edytor;
|
|
20
|
+
readonly id: string;
|
|
21
21
|
node?: HTMLElement;
|
|
22
|
-
|
|
22
|
+
constructor(edytor: Edytor, id: string);
|
|
23
|
+
get isRoot(): boolean;
|
|
24
|
+
/** The typed document node — `null` for the root. */
|
|
25
|
+
get model(): DocBlock | null;
|
|
26
|
+
/** The display parent (the root for a top-level block); none for the root or a dead block. */
|
|
27
|
+
get parent(): Block | undefined;
|
|
28
|
+
get children(): Block[];
|
|
29
|
+
/** Text segments and inline atoms, alternating, starting and ending with a text. */
|
|
30
|
+
get content(): (Text | InlineBlock)[];
|
|
31
|
+
get type(): string;
|
|
32
|
+
/** Retype the block — the `setBlock` command (readonly, hooks, `dispatcher.last`). */
|
|
33
|
+
set type(value: string);
|
|
34
|
+
/**
|
|
35
|
+
* The block's `data` as a live proxy (`session/props.ts`): reads follow the
|
|
36
|
+
* document (reactive through the block's cell), writes are `patchData`
|
|
37
|
+
* commands. The root's is the document's data (`edytor.data`).
|
|
38
|
+
*/
|
|
39
|
+
get data(): Record<string, any>;
|
|
40
|
+
get definition(): BlockDefinition;
|
|
41
|
+
/**
|
|
42
|
+
* Replace the block's `data` — a `patchData` command of its root (readonly,
|
|
43
|
+
* hooks, `dispatcher.last`); `block.model.setData` is the raw document write.
|
|
44
|
+
*/
|
|
45
|
+
setData: (data: Record<string, unknown>) => void;
|
|
23
46
|
get selected(): boolean;
|
|
24
47
|
get focused(): boolean;
|
|
25
|
-
|
|
48
|
+
/** May this block move at all — R5 `canPlace` without a destination (drag handles). */
|
|
49
|
+
get movable(): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* May text-level structural commands (convert, markdown shortcut, slash
|
|
52
|
+
* menu) apply: the block is movable — or the virtual paragraph of an
|
|
53
|
+
* emptied document, which a conversion creates with its kind
|
|
54
|
+
* (SW10-lists-3) — has no role of its own and renders its own content —
|
|
55
|
+
* a container (a list) is never converted, its items are (ZW-02).
|
|
56
|
+
*/
|
|
57
|
+
get convertible(): boolean;
|
|
26
58
|
get firstEditableText(): Text | undefined;
|
|
27
59
|
get lastEditableText(): Text | undefined;
|
|
28
60
|
get index(): number;
|
|
29
|
-
set index(value: number);
|
|
30
|
-
get type(): string;
|
|
31
|
-
set type(value: string);
|
|
32
61
|
get depth(): number;
|
|
33
62
|
get path(): number[];
|
|
34
|
-
|
|
35
|
-
get
|
|
63
|
+
/** The block is visible in the document (a dead handle answers false). */
|
|
64
|
+
get isInTree(): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* @deprecated `edytor.suggestions` with `{ end: block.id }`. The content of
|
|
67
|
+
* this block's latest `end` suggestion, as parts (a text's runs, or an
|
|
68
|
+
* atom); setting it replaces this block's `end` suggestions, `null` drops them.
|
|
69
|
+
*/
|
|
70
|
+
get suggestions(): (JSONText[] | JSONInlineBlock)[] | null;
|
|
36
71
|
set suggestions(value: (JSONText[] | JSONInlineBlock)[] | null);
|
|
37
72
|
get nextBlock(): Block | null;
|
|
38
73
|
get previousBlock(): Block | null;
|
|
39
74
|
get closestPreviousBlock(): Block | null;
|
|
40
75
|
get closestNextBlock(): Block | null;
|
|
41
|
-
get deepestChild(): Block;
|
|
42
76
|
get hasChildren(): boolean;
|
|
77
|
+
/** It shows content: text or an inline atom (a block holding only a mention is not empty). */
|
|
43
78
|
get hasContent(): boolean;
|
|
79
|
+
/** It holds nothing: no content and no children (the emptiness Turn into reads, `holdsNothing`). */
|
|
44
80
|
get isEmpty(): boolean;
|
|
81
|
+
get isNested(): boolean;
|
|
82
|
+
/** This block's JSON — the document's one serializer (`facade.blockJSON`, L14). */
|
|
45
83
|
get value(): JSONBlock;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
84
|
+
isChildOf(block: Block): boolean;
|
|
85
|
+
/** Whether this kind renders its own content slot — the adopted capability (R5, O22). */
|
|
86
|
+
get rendersContent(): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* A container: it shows only its children (a list), neither void nor an
|
|
89
|
+
* island — the document's container rule (YW-02). Its items hold what it
|
|
90
|
+
* shows; it is never converted (`convertible`).
|
|
91
|
+
*/
|
|
92
|
+
get isContainer(): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* An item of a list: its parent is a container whose items are a kind of
|
|
95
|
+
* their own (a `list-item` in an `unordered-list`), not the document's
|
|
96
|
+
* default — a column of paragraphs is no list. Turned into another kind,
|
|
97
|
+
* an item leaves its list; <kbd>Enter</kbd> in an empty one ends it.
|
|
98
|
+
*/
|
|
99
|
+
get isListItem(): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* The list this block shows in: its container when it is an item
|
|
102
|
+
* (`isListItem`), or — an item outdented out of a nested list into the
|
|
103
|
+
* item holding it (SW8-roles-4) — the list of the items of its kind it
|
|
104
|
+
* sits under. <kbd>Enter</kbd> in an empty one outdents it; the menus
|
|
105
|
+
* name it by the list's `itemKind`.
|
|
106
|
+
*/
|
|
107
|
+
get list(): Block | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* The first text of this block's own content — none for a kind that
|
|
110
|
+
* does not render its content (a list container, a divider): its slot
|
|
111
|
+
* is never displayed, so no caret or endpoint may land there. A block
|
|
112
|
+
* without a content slot (the root) answers with its first child's.
|
|
113
|
+
*/
|
|
114
|
+
get firstText(): Text | undefined;
|
|
115
|
+
/** The last text of this block's own content (see {@link firstText}). */
|
|
116
|
+
get lastText(): Text | undefined;
|
|
51
117
|
addChildBlock: (args_0: {
|
|
52
118
|
block: JSONBlock;
|
|
53
119
|
index: number;
|
|
@@ -56,68 +122,89 @@ export declare class Block {
|
|
|
56
122
|
blocks: JSONBlock[];
|
|
57
123
|
index: number;
|
|
58
124
|
}) => Block[];
|
|
59
|
-
insertBlockAfter: (
|
|
125
|
+
insertBlockAfter: (payload: {
|
|
60
126
|
block: JSONBlock;
|
|
61
|
-
}) => Block | null;
|
|
62
|
-
insertBlockBefore: (
|
|
127
|
+
}, plan?: import("../crdt/index.js").Prepared | undefined) => Block | null | undefined;
|
|
128
|
+
insertBlockBefore: (payload: {
|
|
63
129
|
block: JSONBlock;
|
|
64
|
-
}) => Block | null;
|
|
65
|
-
splitBlock: (
|
|
130
|
+
}, plan?: import("../crdt/index.js").Prepared | undefined) => Block | null | undefined;
|
|
131
|
+
splitBlock: (payload: {
|
|
66
132
|
index: number;
|
|
67
133
|
text: Text;
|
|
68
|
-
}) => Block | null;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
134
|
+
}, plan?: import("../crdt/index.js").Prepared | undefined) => Block | null | undefined;
|
|
135
|
+
duplicateBlock: (_?: {} | undefined, plan?: import("../crdt/index.js").Prepared | undefined) => Block | null | undefined;
|
|
136
|
+
removeBlock: (payload?: {
|
|
137
|
+
keepChildren?: boolean;
|
|
138
|
+
} | undefined, plan?: import("../crdt/index.js").Prepared | undefined) => void;
|
|
139
|
+
unNestBlock: (this: Block, _?: {} | undefined, plan?: import("../crdt/index.js").Prepared | undefined) => Block | null;
|
|
140
|
+
mergeBlockBackward: (_?: {} | undefined, plan?: import("../crdt/index.js").Prepared | undefined) => Block | null | undefined;
|
|
141
|
+
mergeBlockForward: (_?: {} | undefined, plan?: import("../crdt/index.js").Prepared | undefined) => Block | null | undefined;
|
|
142
|
+
nestBlock: (this: Block, _?: {} | undefined, plan?: import("../crdt/index.js").Prepared | undefined) => Block | null;
|
|
143
|
+
setBlock: (payload: {
|
|
144
|
+
value: Partial<JSONBlock>;
|
|
145
|
+
}, plan?: import("../crdt/index.js").Prepared | undefined) => void;
|
|
146
|
+
moveBlock: (this: Block, payload: {
|
|
80
147
|
path: number[];
|
|
81
|
-
}) => Block | null;
|
|
148
|
+
}, plan?: import("../crdt/index.js").Prepared | undefined) => Block | null;
|
|
149
|
+
moveBlocks: (this: Block, payload: {
|
|
150
|
+
blocks: Block[];
|
|
151
|
+
path: number[];
|
|
152
|
+
}, plan?: import("../crdt/index.js").Prepared | undefined) => Block[];
|
|
82
153
|
pushContentIntoBlock: (args_0: {
|
|
83
154
|
value: (Text | InlineBlock)[];
|
|
84
155
|
}) => void;
|
|
85
|
-
removeInlineBlock: (
|
|
156
|
+
removeInlineBlock: (payload: {
|
|
86
157
|
index: number;
|
|
87
|
-
}) => void;
|
|
158
|
+
}, plan?: import("../crdt/index.js").Prepared | undefined) => void;
|
|
159
|
+
patchData: (payload: {
|
|
160
|
+
ops: import("../crdt/index.js").DataPatch[];
|
|
161
|
+
atom?: string;
|
|
162
|
+
}, plan?: import("../crdt/index.js").Prepared | undefined) => void;
|
|
88
163
|
addInlineBlock: (args_0: {
|
|
89
164
|
index: number;
|
|
90
165
|
block: JSONInlineBlock;
|
|
91
166
|
text: Text;
|
|
92
|
-
}) => Text;
|
|
167
|
+
}) => Text | null | undefined;
|
|
93
168
|
normalizeContent: () => void;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
169
|
+
normalizeChildren: () => void;
|
|
170
|
+
/** @deprecated `edytor.suggestions.add({ end: block.id }, …)`. */
|
|
171
|
+
suggestText: (payload: BlockOperations["suggestText"]) => void;
|
|
172
|
+
/** @deprecated `suggestion.accept()`. */
|
|
97
173
|
acceptSuggestedText: () => void;
|
|
98
|
-
deleteContentAtRange: (
|
|
174
|
+
deleteContentAtRange: (payload: {
|
|
99
175
|
start: [number, number];
|
|
100
176
|
end: [number, number];
|
|
101
|
-
}) => void;
|
|
177
|
+
}, plan?: import("../crdt/index.js").Prepared | undefined) => void;
|
|
178
|
+
/** Mark an element inside the block's markup as non-editable chrome (a header, a caption bar). */
|
|
102
179
|
void: (node: HTMLElement) => void;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
} |
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
180
|
+
/**
|
|
181
|
+
* The text segment that displays block offset `offset`, and the offset in
|
|
182
|
+
* it — the one offset → segment mapper over the committed parts (a
|
|
183
|
+
* boundary before an atom reads the text before it; past the end, the
|
|
184
|
+
* last text's end).
|
|
185
|
+
*/
|
|
186
|
+
textAtOffset: (offset: number) => {
|
|
187
|
+
text: Text;
|
|
188
|
+
offset: number;
|
|
189
|
+
} | null;
|
|
190
|
+
/**
|
|
191
|
+
* Insert children at `index`: a JSON spec is created (its id kept, minted
|
|
192
|
+
* when missing); a block handle moves there with its identity.
|
|
193
|
+
*/
|
|
194
|
+
insertChildren: (index: number, blocks: (JSONBlock | Block)[]) => void;
|
|
195
|
+
/** Delete `length` visible children from `index`, each with its subtree (a document delete). */
|
|
196
|
+
deleteChildren: (index: number, length?: number) => void;
|
|
197
|
+
/**
|
|
198
|
+
* Insert content before part `index` (a text segment or an inline atom):
|
|
199
|
+
* each entry is a text's runs or an atom, as JSON.
|
|
200
|
+
*/
|
|
201
|
+
insertParts: (index: number, parts: (JSONText[] | JSONInlineBlock)[]) => void;
|
|
202
|
+
/**
|
|
203
|
+
* Register the element the core rendered for this block (O45) and run the
|
|
204
|
+
* attach hooks. A re-rendered block (moved, re-parented) keeps its declared
|
|
205
|
+
* view state (R11): an open toggle stays open.
|
|
206
|
+
*/
|
|
118
207
|
attach: (node: HTMLElement) => {
|
|
119
208
|
destroy: () => void;
|
|
120
209
|
};
|
|
121
210
|
}
|
|
122
|
-
export declare function observeChildren(this: Block, event: Y.YArrayEvent<YBlock>): void;
|
|
123
|
-
export declare function observeContent(this: Block, event: Y.YArrayEvent<YBlock | Y.Text>): void;
|