@aionbuilders/nabu 0.1.0-beta.0 → 0.1.1
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/CHANGELOG.md +531 -0
- package/LICENSE +21 -0
- package/README.md +72 -341
- package/dist/behaviors/text/RichText.svelte +24 -4
- package/dist/behaviors/text/markdown-shortcuts.extension.d.ts +3 -0
- package/dist/behaviors/text/markdown-shortcuts.extension.js +35 -10
- package/dist/behaviors/text/markdown-syntax.d.ts +42 -0
- package/dist/behaviors/text/markdown-syntax.js +81 -0
- package/dist/behaviors/text/rich-text.extension.d.ts +3 -0
- package/dist/behaviors/text/rich-text.extension.js +95 -38
- package/dist/behaviors/text/text.behavior.svelte.d.ts +195 -55
- package/dist/behaviors/text/text.behavior.svelte.js +531 -103
- package/dist/behaviors/text/typography.extension.d.ts +2 -1
- package/dist/behaviors/text/typography.extension.js +3 -2
- package/dist/blocks/BlockList.svelte +48 -0
- package/dist/blocks/BlockList.svelte.d.ts +17 -0
- package/dist/blocks/Nabu.svelte +169 -25
- package/dist/blocks/Nabu.svelte.d.ts +13 -0
- package/dist/blocks/block.extension.d.ts +3 -0
- package/dist/blocks/block.extension.js +4 -7
- package/dist/blocks/block.svelte.d.ts +350 -86
- package/dist/blocks/block.svelte.js +370 -59
- package/dist/blocks/blockquote/Blockquote.svelte +1 -2
- package/dist/blocks/blockquote/blockquote.extension.d.ts +4 -1
- package/dist/blocks/blockquote/blockquote.extension.js +14 -5
- package/dist/blocks/blockquote/blockquote.svelte.d.ts +19 -11
- package/dist/blocks/blockquote/blockquote.svelte.js +58 -13
- package/dist/blocks/callout/Callout.svelte +6 -8
- package/dist/blocks/callout/callout.extension.d.ts +4 -1
- package/dist/blocks/callout/callout.extension.js +19 -3
- package/dist/blocks/callout/callout.svelte.d.ts +5 -3
- package/dist/blocks/callout/callout.svelte.js +11 -6
- package/dist/blocks/chunks.d.ts +49 -0
- package/dist/blocks/chunks.js +90 -0
- package/dist/blocks/code/Code.svelte +7 -8
- package/dist/blocks/code/code.extension.d.ts +4 -1
- package/dist/blocks/code/code.extension.js +22 -2
- package/dist/blocks/code/code.svelte.d.ts +9 -2
- package/dist/blocks/code/code.svelte.js +49 -25
- package/dist/blocks/container.utils.d.ts +85 -13
- package/dist/blocks/container.utils.js +338 -178
- package/dist/blocks/dialogue/Dialogue.svelte +8 -4
- package/dist/blocks/dialogue/dialogue.svelte.d.ts +33 -2
- package/dist/blocks/dialogue/dialogue.svelte.js +58 -4
- package/dist/blocks/dialogue/hooks/onBeforeInput.hook.d.ts +2 -2
- package/dist/blocks/dialogue/hooks/onBeforeInput.hook.js +6 -4
- package/dist/blocks/dialogue/index.d.ts +12 -1
- package/dist/blocks/dialogue/index.js +51 -35
- package/dist/blocks/divider/divider.extension.d.ts +23 -1
- package/dist/blocks/divider/divider.extension.js +85 -19
- package/dist/blocks/divider/divider.svelte.d.ts +7 -2
- package/dist/blocks/divider/divider.svelte.js +9 -4
- package/dist/blocks/file/File.svelte +13 -6
- package/dist/blocks/file/file.extension.d.ts +4 -1
- package/dist/blocks/file/file.extension.js +9 -1
- package/dist/blocks/file/file.svelte.d.ts +3 -3
- package/dist/blocks/file/file.svelte.js +20 -14
- package/dist/blocks/heading/Heading.svelte +1 -2
- package/dist/blocks/heading/heading.svelte.d.ts +23 -11
- package/dist/blocks/heading/heading.svelte.js +68 -13
- package/dist/blocks/heading/hooks/onBeforeInput.hook.js +7 -5
- package/dist/blocks/heading/index.d.ts +2 -2
- package/dist/blocks/heading/index.js +33 -8
- package/dist/blocks/image/Image.svelte +5 -2
- package/dist/blocks/image/image.extension.d.ts +4 -1
- package/dist/blocks/image/image.extension.js +9 -1
- package/dist/blocks/image/image.svelte.d.ts +17 -6
- package/dist/blocks/image/image.svelte.js +33 -11
- package/dist/blocks/index.d.ts +1 -1
- package/dist/blocks/index.js +1 -1
- package/dist/blocks/list/List.svelte +1 -0
- package/dist/blocks/list/ListItem.svelte +1 -0
- package/dist/blocks/list/convert.d.ts +20 -0
- package/dist/blocks/list/convert.js +92 -0
- package/dist/blocks/list/hooks/onBeforeInput.hook.js +49 -28
- package/dist/blocks/list/html-flat.d.ts +78 -0
- package/dist/blocks/list/html-flat.js +244 -0
- package/dist/blocks/list/indent.d.ts +86 -0
- package/dist/blocks/list/indent.js +205 -0
- package/dist/blocks/list/index.d.ts +6 -3
- package/dist/blocks/list/index.js +42 -31
- package/dist/blocks/list/list-item.svelte.d.ts +32 -18
- package/dist/blocks/list/list-item.svelte.js +99 -100
- package/dist/blocks/list/list.behavior.svelte.d.ts +4 -1
- package/dist/blocks/list/list.behavior.svelte.js +6 -1
- package/dist/blocks/list/list.svelte.d.ts +89 -18
- package/dist/blocks/list/list.svelte.js +129 -125
- package/dist/blocks/list/markdown.d.ts +149 -0
- package/dist/blocks/list/markdown.js +442 -0
- package/dist/blocks/list/normalize.d.ts +11 -0
- package/dist/blocks/list/normalize.js +396 -0
- package/dist/blocks/list/paste.d.ts +45 -0
- package/dist/blocks/list/paste.js +242 -0
- package/dist/blocks/list/step-back.d.ts +24 -0
- package/dist/blocks/list/step-back.js +87 -0
- package/dist/blocks/list/to-list.d.ts +7 -0
- package/dist/blocks/list/to-list.js +44 -0
- package/dist/blocks/list/todos-toggle.d.ts +20 -0
- package/dist/blocks/list/todos-toggle.js +48 -0
- package/dist/blocks/media/markdown.d.ts +12 -0
- package/dist/blocks/media/markdown.js +26 -0
- package/dist/blocks/media/media-block.svelte.d.ts +77 -2
- package/dist/blocks/media/media-block.svelte.js +124 -12
- package/dist/blocks/media/media.helpers.d.ts +6 -1
- package/dist/blocks/media/media.helpers.js +43 -6
- package/dist/blocks/megablock.svelte.d.ts +50 -19
- package/dist/blocks/megablock.svelte.js +114 -74
- package/dist/blocks/move.d.ts +23 -0
- package/dist/blocks/move.js +92 -0
- package/dist/blocks/nabu.svelte.d.ts +764 -71
- package/dist/blocks/nabu.svelte.js +1753 -189
- package/dist/blocks/paragraph/Paragraph.svelte +1 -2
- package/dist/blocks/paragraph/index.d.ts +2 -2
- package/dist/blocks/paragraph/index.js +35 -13
- package/dist/blocks/paragraph/paragraph.svelte.d.ts +46 -14
- package/dist/blocks/paragraph/paragraph.svelte.js +77 -16
- package/dist/blocks/paragraph/table.html.d.ts +9 -0
- package/dist/blocks/paragraph/table.html.js +111 -0
- package/dist/blocks/paragraph/table.markdown.d.ts +32 -0
- package/dist/blocks/paragraph/table.markdown.js +90 -0
- package/dist/blocks/region/Region.svelte +264 -0
- package/dist/blocks/region/Region.svelte.d.ts +11 -0
- package/dist/blocks/region/actions.d.ts +135 -0
- package/dist/blocks/region/actions.js +402 -0
- package/dist/blocks/region/close.d.ts +35 -0
- package/dist/blocks/region/close.js +130 -0
- package/dist/blocks/region/commands.d.ts +6 -0
- package/dist/blocks/region/commands.js +277 -0
- package/dist/blocks/region/create.d.ts +72 -0
- package/dist/blocks/region/create.js +208 -0
- package/dist/blocks/region/end-marker.d.ts +35 -0
- package/dist/blocks/region/end-marker.js +51 -0
- package/dist/blocks/region/facts.d.ts +69 -0
- package/dist/blocks/region/facts.js +152 -0
- package/dist/blocks/region/format.d.ts +91 -0
- package/dist/blocks/region/format.js +260 -0
- package/dist/blocks/region/index.d.ts +14 -0
- package/dist/blocks/region/index.js +14 -0
- package/dist/blocks/region/insert.d.ts +59 -0
- package/dist/blocks/region/insert.js +102 -0
- package/dist/blocks/region/messages.d.ts +254 -0
- package/dist/blocks/region/messages.js +131 -0
- package/dist/blocks/region/normalize.d.ts +7 -0
- package/dist/blocks/region/normalize.js +170 -0
- package/dist/blocks/region/region.extension.d.ts +58 -0
- package/dist/blocks/region/region.extension.js +119 -0
- package/dist/blocks/region/region.svelte.d.ts +221 -0
- package/dist/blocks/region/region.svelte.js +582 -0
- package/dist/blocks/region/regions.svelte.d.ts +141 -0
- package/dist/blocks/region/regions.svelte.js +276 -0
- package/dist/blocks/region/serialize.d.ts +57 -0
- package/dist/blocks/region/serialize.js +112 -0
- package/dist/blocks/region/types.d.ts +255 -0
- package/dist/blocks/region/types.js +204 -0
- package/dist/blocks/selection.svelte.d.ts +106 -8
- package/dist/blocks/selection.svelte.js +622 -74
- package/dist/blocks/subthread.d.ts +80 -0
- package/dist/blocks/subthread.js +167 -0
- package/dist/blocks/text-block.svelte.d.ts +35 -14
- package/dist/blocks/text-block.svelte.js +42 -8
- package/dist/blocks/toggle/Toggle.svelte +4 -15
- package/dist/blocks/toggle/markdown.d.ts +20 -0
- package/dist/blocks/toggle/markdown.js +112 -0
- package/dist/blocks/toggle/toggle.extension.d.ts +4 -1
- package/dist/blocks/toggle/toggle.extension.js +6 -0
- package/dist/blocks/toggle/toggle.svelte.d.ts +55 -8
- package/dist/blocks/toggle/toggle.svelte.js +134 -34
- package/dist/blocks/undo-selection.d.ts +175 -0
- package/dist/blocks/undo-selection.js +360 -0
- package/dist/blocks/video/Video.svelte +5 -2
- package/dist/blocks/video/video.extension.d.ts +4 -1
- package/dist/blocks/video/video.extension.js +9 -1
- package/dist/blocks/video/video.svelte.d.ts +6 -5
- package/dist/blocks/video/video.svelte.js +18 -9
- package/dist/extend.d.ts +55 -0
- package/dist/extend.js +88 -0
- package/dist/files/assets.clipboard.d.ts +77 -0
- package/dist/files/assets.clipboard.js +152 -0
- package/dist/files/files.svelte.d.ts +321 -19
- package/dist/files/files.svelte.js +847 -43
- package/dist/files/index.d.ts +3 -1
- package/dist/files/index.js +3 -1
- package/dist/files/outbox.d.ts +69 -0
- package/dist/files/outbox.js +48 -0
- package/dist/files/status.d.ts +65 -0
- package/dist/files/status.js +87 -0
- package/dist/files/store.d.ts +97 -0
- package/dist/files/store.js +65 -0
- package/dist/files/uploads.svelte.d.ts +174 -0
- package/dist/files/uploads.svelte.js +504 -0
- package/dist/index.d.ts +68 -9
- package/dist/index.js +117 -10
- package/dist/nabu-theme.css +21 -1
- package/dist/paste/html.paste.d.ts +74 -3
- package/dist/paste/html.paste.js +550 -86
- package/dist/paste/markdown-inline.d.ts +86 -0
- package/dist/paste/markdown-inline.js +528 -0
- package/dist/paste/markdown.paste.d.ts +2 -8
- package/dist/paste/markdown.paste.js +78 -94
- package/dist/paste/nabu.paste.d.ts +3 -0
- package/dist/paste/nabu.paste.js +29 -3
- package/dist/paste/plain-text.paste.d.ts +2 -2
- package/dist/paste/plain-text.paste.js +3 -3
- package/dist/persistence/asset-store.d.ts +51 -0
- package/dist/persistence/asset-store.js +103 -0
- package/dist/persistence/autosave.d.ts +53 -0
- package/dist/persistence/autosave.js +62 -0
- package/dist/persistence/compact.d.ts +162 -0
- package/dist/persistence/compact.js +141 -0
- package/dist/persistence/history.d.ts +77 -0
- package/dist/persistence/history.js +176 -0
- package/dist/persistence/indexeddb.d.ts +190 -4
- package/dist/persistence/indexeddb.js +333 -29
- package/dist/persistence/merge.d.ts +38 -0
- package/dist/persistence/merge.js +36 -0
- package/dist/persistence/outbox.d.ts +25 -0
- package/dist/persistence/outbox.js +40 -0
- package/dist/persistence/persistence.d.ts +70 -9
- package/dist/persistence/persistence.js +507 -35
- package/dist/persistence/recovery.d.ts +79 -0
- package/dist/persistence/recovery.js +79 -0
- package/dist/persistence/release.d.ts +34 -0
- package/dist/persistence/release.js +64 -0
- package/dist/persistence/state.svelte.d.ts +53 -0
- package/dist/persistence/state.svelte.js +48 -0
- package/dist/persistence/sync.d.ts +39 -0
- package/dist/persistence/sync.js +138 -0
- package/dist/persistence/tail.d.ts +42 -0
- package/dist/persistence/tail.js +103 -0
- package/dist/presets.d.ts +29 -26
- package/dist/presets.js +35 -13
- package/dist/themes/atelier.css +318 -0
- package/dist/ui/CommandChooser.svelte +153 -0
- package/dist/ui/CommandChooser.svelte.d.ts +13 -0
- package/dist/ui/CommandInvite.svelte +99 -0
- package/dist/ui/CommandInvite.svelte.d.ts +12 -0
- package/dist/ui/DragHandle.svelte +97 -21
- package/dist/ui/FloatingToolbar.svelte +75 -27
- package/dist/ui/FloatingToolbar.svelte.d.ts +10 -0
- package/dist/ui/SlashMenu.svelte +147 -15
- package/dist/ui/SlashMenu.svelte.d.ts +20 -0
- package/dist/ui/anchor.d.ts +112 -0
- package/dist/ui/anchor.js +136 -0
- package/dist/ui/index.d.ts +7 -1
- package/dist/ui/index.js +12 -1
- package/dist/ui/slash-menu.svelte.d.ts +79 -7
- package/dist/ui/slash-menu.svelte.js +85 -51
- package/dist/utils/command-confirm.svelte.d.ts +349 -0
- package/dist/utils/command-confirm.svelte.js +673 -0
- package/dist/utils/commands.d.ts +328 -0
- package/dist/utils/commands.js +416 -0
- package/dist/utils/composition.d.ts +28 -0
- package/dist/utils/composition.js +51 -0
- package/dist/utils/dom-scope.d.ts +14 -0
- package/dist/utils/dom-scope.js +20 -0
- package/dist/utils/drop.d.ts +160 -0
- package/dist/utils/drop.js +305 -0
- package/dist/utils/extensions.d.ts +439 -45
- package/dist/utils/extensions.js +271 -29
- package/dist/utils/html.d.ts +44 -0
- package/dist/utils/html.js +183 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/keys.d.ts +120 -0
- package/dist/utils/keys.js +248 -0
- package/dist/utils/links.d.ts +22 -0
- package/dist/utils/links.js +34 -0
- package/dist/utils/placeholders.d.ts +81 -3
- package/dist/utils/placeholders.js +73 -3
- package/dist/utils/selection.svelte.d.ts +48 -20
- package/dist/utils/selection.svelte.js +60 -10
- package/dist/utils/spellcheck.d.ts +9 -0
- package/dist/utils/spellcheck.js +17 -0
- package/dist/utils/tab.d.ts +31 -0
- package/dist/utils/tab.js +117 -0
- package/dist/utils/words.d.ts +42 -0
- package/dist/utils/words.js +147 -0
- package/dist/vite.d.ts +9 -3
- package/dist/vite.js +19 -8
- package/package.json +56 -20
- package/dist/blocks/variable.svelte.d.ts +0 -47
- package/dist/blocks/variable.svelte.js +0 -51
- package/dist/blocks/zone/TemplateEditor.svelte +0 -308
- package/dist/blocks/zone/TemplateEditor.svelte.d.ts +0 -11
- package/dist/blocks/zone/Zone.svelte +0 -272
- package/dist/blocks/zone/Zone.svelte.d.ts +0 -11
- package/dist/blocks/zone/ZoneEditor.svelte +0 -289
- package/dist/blocks/zone/ZoneEditor.svelte.d.ts +0 -11
- package/dist/blocks/zone/ZoneTemplatesList.svelte +0 -188
- package/dist/blocks/zone/ZoneTemplatesList.svelte.d.ts +0 -11
- package/dist/blocks/zone/hooks/onBeforeInput.hook.d.ts +0 -3
- package/dist/blocks/zone/hooks/onBeforeInput.hook.js +0 -30
- package/dist/blocks/zone/index.d.ts +0 -2
- package/dist/blocks/zone/index.js +0 -2
- package/dist/blocks/zone/zone.extension.d.ts +0 -2
- package/dist/blocks/zone/zone.extension.js +0 -237
- package/dist/blocks/zone/zone.svelte.d.ts +0 -221
- package/dist/blocks/zone/zone.svelte.js +0 -608
- package/dist/overlays/context/Context.svelte +0 -182
- package/dist/overlays/context/Context.svelte.d.ts +0 -17
- package/dist/overlays/context/collect.d.ts +0 -17
- package/dist/overlays/context/collect.js +0 -33
- package/dist/overlays/context/context.extension.d.ts +0 -2
- package/dist/overlays/context/context.extension.js +0 -8
- package/dist/overlays/context/context.svelte.d.ts +0 -82
- package/dist/overlays/context/context.svelte.js +0 -159
- package/dist/overlays/context/index.d.ts +0 -3
- package/dist/overlays/context/index.js +0 -3
|
@@ -1,79 +1,48 @@
|
|
|
1
1
|
import { MegaBlock } from "../megablock.svelte.js";
|
|
2
2
|
import ListItemComponent from "./ListItem.svelte";
|
|
3
|
+
import { List, listStart } from "./list.svelte.js";
|
|
4
|
+
import { moveItems, handleTab } from "./indent.js";
|
|
5
|
+
import { retypeItem } from "./convert.js";
|
|
6
|
+
import { pasteIntoItem } from "./paste.js";
|
|
3
7
|
import { LoroText } from "loro-crdt";
|
|
4
8
|
import { TextBehavior, deltaToHtml, deltaToMarkdown } from "../../behaviors/text";
|
|
9
|
+
import { renderItem, adjacentRun, markerWidth } from "./markdown.js";
|
|
5
10
|
|
|
6
11
|
/**
|
|
7
12
|
* @import { Nabu, NabuNode, Block } from "..";
|
|
8
13
|
*/
|
|
9
14
|
|
|
10
15
|
/**
|
|
11
|
-
* @typedef {NabuNode<{type: "list-item", text: LoroText}>} ListItemNode
|
|
16
|
+
* @typedef {NabuNode<{type: "list-item", text: LoroText, checked?: boolean}>} ListItemNode
|
|
12
17
|
*/
|
|
13
18
|
|
|
19
|
+
/** What the list renderers (markdown.js) need from outside: the inline serializer and the `start` normalizer. */
|
|
20
|
+
const markdownEnv = { toMarkdown: (/** @type {any[]} */ delta) => deltaToMarkdown(delta), listStart };
|
|
21
|
+
|
|
14
22
|
/**
|
|
15
|
-
* Indent a list item (Tab behavior): move
|
|
23
|
+
* Indent a list item (Tab behavior): move under the previous sibling (into its last sublist when of the same type, else a new one).
|
|
24
|
+
* The selection (collapsed caret or range) is restored afterwards. See indent.js.
|
|
16
25
|
* @param {ListItem} item
|
|
17
26
|
* @returns {boolean}
|
|
18
27
|
*/
|
|
19
28
|
export function indentListItem(item) {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (!parentList) return false;
|
|
25
|
-
|
|
26
|
-
const previousNode = parentList.children()?.[currentIndex - 1];
|
|
27
|
-
if (!previousNode) return false;
|
|
28
|
-
const previousItem = item.nabu.blocks.get(previousNode.id.toString());
|
|
29
|
-
if (!previousItem || previousItem.type !== 'list-item') return false;
|
|
30
|
-
|
|
31
|
-
// @ts-ignore
|
|
32
|
-
const targetSublist = previousItem.getOrCreateSublist();
|
|
33
|
-
const targetSublistId = targetSublist.node.id.toString();
|
|
34
|
-
|
|
35
|
-
item.nabu.tree.move(item.node.id.toString(), targetSublistId);
|
|
36
|
-
|
|
37
|
-
if (item.sublist) {
|
|
38
|
-
for (const childNode of item.sublist.node.children()) {
|
|
39
|
-
item.nabu.tree.move(childNode.id.toString(), targetSublistId);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
item.commit().then(() => item.behavior.block.focus());
|
|
44
|
-
return true;
|
|
29
|
+
const node = /** @type {import("../nabu.svelte.js").NabuNode} */ (item.node);
|
|
30
|
+
const movable = !!node.index() && node.parent()?.children()?.[/** @type {number} */ (node.index()) - 1]?.data.get('type') === 'list-item';
|
|
31
|
+
if (movable) moveItems(item.nabu, [node], false);
|
|
32
|
+
return movable;
|
|
45
33
|
}
|
|
46
34
|
|
|
47
35
|
/**
|
|
48
36
|
* Unindent a list item (Shift+Tab behavior): move out of parent sublist, carry followers.
|
|
37
|
+
* The selection (collapsed caret or range) is restored afterwards. See indent.js.
|
|
49
38
|
* @param {ListItem} item
|
|
50
39
|
* @returns {boolean}
|
|
51
40
|
*/
|
|
52
41
|
export function unindentListItem(item) {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (!grandParentItemNode || grandParentItemNode.data.get('type') !== 'list-item') return false;
|
|
58
|
-
|
|
59
|
-
const myIndex = item.node.index();
|
|
60
|
-
const followers = parentListNode.children().slice(myIndex + 1);
|
|
61
|
-
|
|
62
|
-
if (followers.length > 0) {
|
|
63
|
-
const mySublist = item.getOrCreateSublist();
|
|
64
|
-
for (const follower of followers) {
|
|
65
|
-
item.nabu.tree.move(follower.id.toString(), mySublist.node.id.toString());
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const targetParentListNode = grandParentItemNode.parent();
|
|
70
|
-
if (!targetParentListNode) return false;
|
|
71
|
-
|
|
72
|
-
const targetIndex = grandParentItemNode.index() + 1;
|
|
73
|
-
item.nabu.tree.move(item.node.id.toString(), targetParentListNode.id.toString(), targetIndex);
|
|
74
|
-
|
|
75
|
-
item.commit().then(() => item.behavior.block.focus());
|
|
76
|
-
return true;
|
|
42
|
+
const node = /** @type {import("../nabu.svelte.js").NabuNode} */ (item.node);
|
|
43
|
+
const movable = node.parent()?.parent()?.data.get('type') === 'list-item';
|
|
44
|
+
if (movable) moveItems(item.nabu, [node], true);
|
|
45
|
+
return movable;
|
|
77
46
|
}
|
|
78
47
|
|
|
79
48
|
export class ListItem extends MegaBlock {
|
|
@@ -95,22 +64,21 @@ export class ListItem extends MegaBlock {
|
|
|
95
64
|
this.checked = !!this.node.data.get('checked');
|
|
96
65
|
});
|
|
97
66
|
|
|
67
|
+
// One item (and its sublists), indented under the items that hold it. A whole list is rendered by the List.
|
|
98
68
|
this.serializers.set('markdown', () => {
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
prefix = `- [${this.checked ? 'x' : ' '}]`;
|
|
105
|
-
} else {
|
|
106
|
-
prefix = listType === 'ordered' ? `${this.index + 1}.` : '-';
|
|
69
|
+
const list = /** @type {any} */ (this.parent);
|
|
70
|
+
let indent = '';
|
|
71
|
+
for (let item = /** @type {any} */ (this); item.parent?.parent?.type === 'list-item'; item = item.parent.parent) {
|
|
72
|
+
const outer = item.parent.parent;
|
|
73
|
+
indent = ' '.repeat(markerWidth(outer.parent?.listType, (outer.parent?.start ?? 1) + outer.index)) + indent;
|
|
107
74
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
75
|
+
return renderItem(this.toPasteBlock(), markdownEnv, {
|
|
76
|
+
listType: list?.listType ?? 'bullet',
|
|
77
|
+
index: this.index,
|
|
78
|
+
start: list?.start ?? 1,
|
|
79
|
+
run: list ? adjacentRun(list.listType, list.siblingsBefore()) : 0,
|
|
80
|
+
indent,
|
|
81
|
+
});
|
|
114
82
|
});
|
|
115
83
|
this.serializers.set('json', () => {
|
|
116
84
|
/** @type {Record<string, any>} */
|
|
@@ -118,7 +86,7 @@ export class ListItem extends MegaBlock {
|
|
|
118
86
|
id: this.id,
|
|
119
87
|
type: 'list-item',
|
|
120
88
|
content: this.behavior.toJSON(),
|
|
121
|
-
...(this.isTodo ? { checked: this.checked } : {})
|
|
89
|
+
...(this.isTodo ? { props: { checked: this.checked } } : {})
|
|
122
90
|
};
|
|
123
91
|
const childrenJson = this.children.map(c => c.serialize('json')).filter(Boolean);
|
|
124
92
|
if (childrenJson.length) result.children = childrenJson;
|
|
@@ -134,6 +102,21 @@ export class ListItem extends MegaBlock {
|
|
|
134
102
|
|
|
135
103
|
isTodo = $derived(/** @type {any} */ (this.parent)?.listType === 'todo');
|
|
136
104
|
|
|
105
|
+
/**
|
|
106
|
+
* This item and its sublists as PasteBlocks (the shape the static serializers read).
|
|
107
|
+
* @returns {import('../../utils/extensions.js').PasteBlock}
|
|
108
|
+
*/
|
|
109
|
+
toPasteBlock() {
|
|
110
|
+
const pb = this.behavior.toClipboardBlock({ props: this.clipboardProps });
|
|
111
|
+
const sublists = this.sublists;
|
|
112
|
+
return sublists.length ? { ...pb, children: sublists.map(sub => /** @type {any} */ (sub).toPasteBlock()) } : pb;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** A to-do item carries its `checked` state onto the clipboard. */
|
|
116
|
+
get clipboardProps() {
|
|
117
|
+
return this.isTodo ? { checked: this.checked } : {};
|
|
118
|
+
}
|
|
119
|
+
|
|
137
120
|
/**
|
|
138
121
|
* Set the checked state and persist to Loro.
|
|
139
122
|
* @param {boolean} v
|
|
@@ -145,9 +128,10 @@ export class ListItem extends MegaBlock {
|
|
|
145
128
|
}
|
|
146
129
|
|
|
147
130
|
/**
|
|
148
|
-
* Toggle the checked state.
|
|
131
|
+
* Toggle the checked state (the user's gesture: a click on the box, the key). Does nothing in a read-only editor.
|
|
149
132
|
*/
|
|
150
133
|
toggleChecked() {
|
|
134
|
+
if (this.nabu.readonly) return;
|
|
151
135
|
this.setChecked(!this.checked);
|
|
152
136
|
}
|
|
153
137
|
|
|
@@ -161,6 +145,7 @@ export class ListItem extends MegaBlock {
|
|
|
161
145
|
|
|
162
146
|
selection = $derived(this.behavior.selection);
|
|
163
147
|
|
|
148
|
+
// @ts-ignore — `super.positions`: Svelte compiles the parent's `$derived` field to a prototype accessor, which TS sees as a field
|
|
164
149
|
positions = $derived(this.behavior.positions + super.positions);
|
|
165
150
|
|
|
166
151
|
wordCount = $derived((this.behavior?.wordCount ?? 0) + this.children.reduce((sum, c) => sum + (c.wordCount ?? 0), 0));
|
|
@@ -184,7 +169,11 @@ export class ListItem extends MegaBlock {
|
|
|
184
169
|
return { block: this, offset: this.behavior.text.length };
|
|
185
170
|
}
|
|
186
171
|
|
|
187
|
-
sublist
|
|
172
|
+
/** Every sublist, in order: an item may hold several, of different types (`a > [ul[…], ol[…], ul[…]]`). */
|
|
173
|
+
sublists = $derived(this.children.filter(child => child.node.data.get("type") === "list"));
|
|
174
|
+
|
|
175
|
+
/** The first sublist (see `sublists`). */
|
|
176
|
+
sublist = $derived(this.sublists[0]);
|
|
188
177
|
|
|
189
178
|
/**
|
|
190
179
|
* A ListItem must always live inside a List.
|
|
@@ -204,29 +193,46 @@ export class ListItem extends MegaBlock {
|
|
|
204
193
|
}
|
|
205
194
|
|
|
206
195
|
/**
|
|
207
|
-
*
|
|
196
|
+
* The sublist that receives a child of type `listType`: the LAST sublist when it has that type, otherwise
|
|
197
|
+
* a new one appended after the existing sublists (an item may hold several sublists of different types).
|
|
208
198
|
* @param {"bullet" | "ordered" | "todo"} [listType]
|
|
209
199
|
*/
|
|
210
200
|
getOrCreateSublist(listType = /** @type {any} */ (this.parent)?.listType || "bullet") {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
201
|
+
const last = this.sublists.at(-1);
|
|
202
|
+
if (last && /** @type {any} */ (last).listType === listType) return last;
|
|
203
|
+
|
|
204
|
+
// No nabu.insert() here: it commits, and the list schema normalizer would delete this still-empty
|
|
205
|
+
// list before the caller had the chance to fill it.
|
|
206
|
+
return List.create(this.nabu, "list", { listType }, this.node.id.toString());
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* A list item cannot simply change type where it stands (a list only holds items): it leaves its list,
|
|
211
|
+
* which is split around it, and keeps its text, marks and caret. See convert.js.
|
|
212
|
+
* @param {string} newType
|
|
213
|
+
* @param {Record<string, any>} [props={}]
|
|
214
|
+
*/
|
|
215
|
+
retype(newType, props = {}) {
|
|
216
|
+
retypeItem(this.nabu, /** @type {NabuNode} */ (this.node), newType, props);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* A paste landing in a list item: paragraphs and lists are absorbed as items of this list, any block an
|
|
221
|
+
* item cannot hold splits the list. See paste.js.
|
|
222
|
+
* @param {import('../../utils/extensions.js').PasteBlock[]} blocks
|
|
223
|
+
* @param {{ offset: number }} ctx
|
|
224
|
+
*/
|
|
225
|
+
acceptPaste(blocks, ctx) {
|
|
226
|
+
return pasteIntoItem(/** @type {any} */ (this), ctx.offset, blocks);
|
|
216
227
|
}
|
|
217
228
|
|
|
218
229
|
/** @param {KeyboardEvent} event */
|
|
219
230
|
keydown(event) {
|
|
220
|
-
if (event.key
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
indentListItem(this);
|
|
226
|
-
}
|
|
227
|
-
return true;
|
|
228
|
-
}
|
|
229
|
-
return false;
|
|
231
|
+
if (event.key !== 'Tab') return false;
|
|
232
|
+
// Single item, or a selection spanning several items that landed here (see ListExtension's onKeyDown).
|
|
233
|
+
if (handleTab(this.nabu, event)) return true;
|
|
234
|
+
// Plain Tab inside the item (modifier combos aside): never let the focus leave the editor.
|
|
235
|
+
return !(event.ctrlKey || event.altKey || event.metaKey);
|
|
230
236
|
}
|
|
231
237
|
|
|
232
238
|
/** @param {InputEvent} event */
|
|
@@ -258,25 +264,16 @@ export class ListItem extends MegaBlock {
|
|
|
258
264
|
split(options) {
|
|
259
265
|
return this.ascend("onSplit", null, {
|
|
260
266
|
offset: options?.offset || 0,
|
|
261
|
-
delta: this.behavior.container.sliceDelta(options?.offset || 0, this.
|
|
267
|
+
delta: this.behavior.container.sliceDelta(options?.offset || 0, this.behavior.container.length)
|
|
262
268
|
});
|
|
263
269
|
}
|
|
264
270
|
|
|
265
271
|
/**
|
|
266
272
|
* @param {import('../../utils/extensions.js').PasteBlock} pb
|
|
267
|
-
* @param {
|
|
273
|
+
* @param {Partial<import('../../utils/extensions.js').SerializeContext> & { listType?: string, index?: number, start?: number, run?: number, indent?: string }} helpers `run`: position of the list among adjacent lists (marker alternation), `indent`: what the item is nested under
|
|
268
274
|
*/
|
|
269
|
-
static toMarkdown(pb, {
|
|
270
|
-
|
|
271
|
-
let prefix;
|
|
272
|
-
if (listType === 'todo') {
|
|
273
|
-
prefix = `- [${pb.props?.checked ? 'x' : ' '}]`;
|
|
274
|
-
} else {
|
|
275
|
-
prefix = listType === 'ordered' ? `${index + 1}.` : '-';
|
|
276
|
-
}
|
|
277
|
-
const text = deltaToMarkdown(pb.delta || []);
|
|
278
|
-
const sublists = (pb.children || []).map(sub => recurse(sub, { depth: depth + 1 })).join('\n');
|
|
279
|
-
return `${indent}${prefix} ${text}${sublists ? '\n' + sublists : ''}`;
|
|
275
|
+
static toMarkdown(pb, { listType = 'bullet', index = 0, start = 1, run = 0, indent = '' }) {
|
|
276
|
+
return renderItem(pb, markdownEnv, { listType, index, start, run, indent });
|
|
280
277
|
}
|
|
281
278
|
|
|
282
279
|
/**
|
|
@@ -314,19 +311,21 @@ export class ListItem extends MegaBlock {
|
|
|
314
311
|
/** @type {import('../../utils/extensions.js').PasteBlock} */
|
|
315
312
|
const result = { type: 'list-item', delta, partial: false };
|
|
316
313
|
if (cb) result.props = { checked: cb.hasAttribute('checked') };
|
|
314
|
+
// Google Docs checklist: `<li role="checkbox" aria-checked="true">`
|
|
315
|
+
else if (el.getAttribute('aria-checked') === 'true' || el.getAttribute('aria-checked') === 'false') result.props = { checked: el.getAttribute('aria-checked') === 'true' };
|
|
317
316
|
if (childLists.length) result.children = childLists;
|
|
318
317
|
return result;
|
|
319
318
|
}
|
|
320
319
|
|
|
321
|
-
/** @param {Nabu} nabu @param {string} type @param {
|
|
320
|
+
/** @param {Nabu} nabu @param {string} type @param {Record<string, any>} [props={}] @param {string|null} [parentId=null] @param {number|null} [index=null] */
|
|
322
321
|
static create(nabu, type, props = {}, parentId = null, index = null) {
|
|
323
|
-
const node = nabu.tree.createNode(parentId || undefined, index
|
|
322
|
+
const node = nabu.tree.createNode(/** @type {import('loro-crdt').TreeID | undefined} */ (parentId || undefined), index ?? undefined);
|
|
324
323
|
node.data.set("type", "list-item");
|
|
325
324
|
const container = node.data.setContainer("text", new LoroText());
|
|
326
325
|
if (props.text) container.insert(0, props.text);
|
|
327
326
|
if (props.delta) container.applyDelta([...props.delta]);
|
|
328
327
|
if (props.checked !== undefined) /** @type {any} */ (node.data).set('checked', !!props.checked);
|
|
329
|
-
const block = new ListItem(nabu, node);
|
|
328
|
+
const block = new ListItem(nabu, /** @type {ListItemNode} */ (node));
|
|
330
329
|
return block;
|
|
331
330
|
}
|
|
332
331
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @import {LoroText} from "loro-crdt";
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* @typedef {NabuNode<{type: "list", listType: "bullet" | "ordered" | "todo"}>} ListNode
|
|
6
|
+
* @typedef {NabuNode<{type: "list", listType: "bullet" | "ordered" | "todo", start?: number}>} ListNode
|
|
7
7
|
*/
|
|
8
8
|
export class ListBehavior {
|
|
9
9
|
/** @param {Block} block */
|
|
@@ -13,12 +13,15 @@ export class ListBehavior {
|
|
|
13
13
|
node: ListNode;
|
|
14
14
|
/** @type {"bullet" | "ordered" | "todo"} */
|
|
15
15
|
listType: "bullet" | "ordered" | "todo";
|
|
16
|
+
/** Raw `start` number from the node (null = unset); List.start normalizes it. @type {number | null} */
|
|
17
|
+
start: number | null;
|
|
16
18
|
/** @param {Block} block */
|
|
17
19
|
absorbs(block: Block): true | undefined;
|
|
18
20
|
}
|
|
19
21
|
export type ListNode = NabuNode<{
|
|
20
22
|
type: "list";
|
|
21
23
|
listType: "bullet" | "ordered" | "todo";
|
|
24
|
+
start?: number;
|
|
22
25
|
}>;
|
|
23
26
|
import type { Block } from "..";
|
|
24
27
|
import type { NabuNode } from "..";
|
|
@@ -6,7 +6,7 @@ import { MegaBlock } from "../megablock.svelte.js";
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @typedef {NabuNode<{type: "list", listType: "bullet" | "ordered" | "todo"}>} ListNode
|
|
9
|
+
* @typedef {NabuNode<{type: "list", listType: "bullet" | "ordered" | "todo", start?: number}>} ListNode
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
export class ListBehavior {
|
|
@@ -16,11 +16,16 @@ export class ListBehavior {
|
|
|
16
16
|
this.nabu = block.nabu;
|
|
17
17
|
this.node = /** @type {ListNode} */ (block.node);
|
|
18
18
|
this.listType = /** @type {"bullet" | "ordered" | "todo"} */ (this.node.data.get("listType") || "bullet");
|
|
19
|
+
this.start = /** @type {any} */ (this.node.data.get("start")) ?? null;
|
|
19
20
|
this.node.data.subscribe(() => {
|
|
20
21
|
this.listType = /** @type {"bullet" | "ordered" | "todo"} */ (this.node.data.get("listType") || "bullet");
|
|
22
|
+
this.start = /** @type {any} */ (this.node.data.get("start")) ?? null;
|
|
21
23
|
});
|
|
22
24
|
}
|
|
23
25
|
|
|
26
|
+
/** Raw `start` number from the node (null = unset); List.start normalizes it. @type {number | null} */
|
|
27
|
+
start = $state(null);
|
|
28
|
+
|
|
24
29
|
/** @type {"bullet" | "ordered" | "todo"} */
|
|
25
30
|
listType = $state("bullet");
|
|
26
31
|
|
|
@@ -2,16 +2,24 @@
|
|
|
2
2
|
* @import { Nabu, NabuNode } from "../nabu.svelte.js";
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
* @typedef {NabuNode<{type: "list", listType: "bullet" | "ordered" | "todo"}>} ListNode
|
|
5
|
+
* @typedef {NabuNode<{type: "list", listType: "bullet" | "ordered" | "todo", start?: number}>} ListNode
|
|
6
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* Normalize a list's `start` number: only meaningful for ORDERED lists, and `1` is the default.
|
|
9
|
+
* @param {string | undefined} listType
|
|
10
|
+
* @param {any} start a number, a numeric string (markdown / `<ol start>`), or nothing
|
|
11
|
+
* @returns {number | null} the number to store / emit, or null = default (omit it)
|
|
12
|
+
*/
|
|
13
|
+
export function listStart(listType: string | undefined, start: any): number | null;
|
|
7
14
|
export class List extends MegaBlock {
|
|
8
15
|
/**
|
|
16
|
+
* Markdown of a list and its sublists. Adjacent lists alternate their marker (`-` / `*`, `.` / `)`), see `adjacentRun`.
|
|
9
17
|
* @param {import('../../utils/extensions.js').PasteBlock} pb
|
|
10
|
-
* @param {{
|
|
18
|
+
* @param {{ indent?: string, before?: import('../../utils/extensions.js').PasteBlock[] }} helpers `before`: the siblings before the list
|
|
11
19
|
*/
|
|
12
|
-
static toMarkdown(pb: import("../../utils/extensions.js").PasteBlock, {
|
|
13
|
-
|
|
14
|
-
|
|
20
|
+
static toMarkdown(pb: import("../../utils/extensions.js").PasteBlock, { indent, before }: {
|
|
21
|
+
indent?: string;
|
|
22
|
+
before?: import("../../utils/extensions.js").PasteBlock[];
|
|
15
23
|
}): string;
|
|
16
24
|
/**
|
|
17
25
|
* @param {import('../../utils/extensions.js').PasteBlock} pb
|
|
@@ -20,56 +28,116 @@ export class List extends MegaBlock {
|
|
|
20
28
|
static toHtml(pb: import("../../utils/extensions.js").PasteBlock, { recurse }: {
|
|
21
29
|
recurse: (child: import("../../utils/extensions.js").PasteBlock) => string;
|
|
22
30
|
}): string;
|
|
31
|
+
/**
|
|
32
|
+
* Markdown lists, see markdown.js: markers `-` `*` `+` `1.` `1)`, nesting by indentation (2 / 4 spaces, TAB), tasks,
|
|
33
|
+
* loose lists, continuation paragraphs of an item.
|
|
34
|
+
*/
|
|
23
35
|
static markdownRules: {
|
|
24
36
|
priority: number;
|
|
25
|
-
|
|
26
|
-
|
|
37
|
+
interruptsParagraph: (line: string) => boolean;
|
|
38
|
+
detect: (line: string) => boolean;
|
|
39
|
+
consume: (lines: string[], i: number, helpers: any) => number;
|
|
27
40
|
}[];
|
|
28
41
|
/**
|
|
29
|
-
* Parse markdown list lines into a nested List/ListItem PasteBlock tree
|
|
30
|
-
*
|
|
42
|
+
* Parse markdown list lines into a nested List/ListItem PasteBlock tree (an array when the marker type changes at
|
|
43
|
+
* the root: several lists).
|
|
31
44
|
*
|
|
32
45
|
* @param {string[]} lines
|
|
33
|
-
* @param {{ parseInline: (text: string) => import('loro-crdt').Delta<string>[] }} helpers
|
|
34
|
-
* @returns {import('../../utils/extensions.js').PasteBlock | null}
|
|
46
|
+
* @param {{ parseInline: (text: string) => import('loro-crdt').Delta<string>[], joinLines?: boolean, softBreak?: string }} helpers
|
|
47
|
+
* @returns {import('../../utils/extensions.js').PasteBlock | import('../../utils/extensions.js').PasteBlock[] | null}
|
|
35
48
|
*/
|
|
36
|
-
static fromMarkdown(lines: string[],
|
|
49
|
+
static fromMarkdown(lines: string[], helpers: {
|
|
37
50
|
parseInline: (text: string) => import("loro-crdt").Delta<string>[];
|
|
38
|
-
|
|
51
|
+
joinLines?: boolean;
|
|
52
|
+
softBreak?: string;
|
|
53
|
+
}): import("../../utils/extensions.js").PasteBlock | import("../../utils/extensions.js").PasteBlock[] | null;
|
|
39
54
|
static htmlRules: ({
|
|
40
55
|
selector: string;
|
|
41
56
|
props: {
|
|
42
57
|
listType: string;
|
|
43
58
|
};
|
|
44
59
|
priority: number;
|
|
60
|
+
filter?: undefined;
|
|
61
|
+
} | {
|
|
62
|
+
selector: string;
|
|
63
|
+
filter: (el: Element) => boolean;
|
|
64
|
+
props: {
|
|
65
|
+
listType: string;
|
|
66
|
+
};
|
|
67
|
+
priority: number;
|
|
45
68
|
} | {
|
|
46
69
|
selector: string;
|
|
47
70
|
props: {
|
|
48
71
|
listType: string;
|
|
49
72
|
};
|
|
50
73
|
priority?: undefined;
|
|
74
|
+
filter?: undefined;
|
|
51
75
|
})[];
|
|
52
76
|
/**
|
|
77
|
+
* The elements after `el` that continue its list (the `html` interpreter reads them as part of this list): the `<ul>`
|
|
78
|
+
* per nesting level of Google Docs, the following list paragraphs of Word.
|
|
53
79
|
* @param {Element} el
|
|
54
|
-
* @
|
|
80
|
+
* @returns {Element[]}
|
|
81
|
+
*/
|
|
82
|
+
static htmlSiblings(el: Element): Element[];
|
|
83
|
+
/**
|
|
84
|
+
* @param {Element} el
|
|
85
|
+
* @param {{ parseChildren: (el: Element) => import('../../utils/extensions.js').PasteBlock[], parseBlock: (el: Element) => import('../../utils/extensions.js').PasteBlock | null, parseInline: (el: Element) => import('loro-crdt').Delta<string>[] }} helpers
|
|
55
86
|
* @param {{ props?: { listType?: string } }} [rule]
|
|
87
|
+
* @param {Element[]} [siblings] what `htmlSiblings` absorbed
|
|
56
88
|
* @returns {import('../../utils/extensions.js').PasteBlock | null}
|
|
57
89
|
*/
|
|
58
|
-
static fromHTML(el: Element,
|
|
90
|
+
static fromHTML(el: Element, helpers: {
|
|
59
91
|
parseChildren: (el: Element) => import("../../utils/extensions.js").PasteBlock[];
|
|
92
|
+
parseBlock: (el: Element) => import("../../utils/extensions.js").PasteBlock | null;
|
|
93
|
+
parseInline: (el: Element) => import("loro-crdt").Delta<string>[];
|
|
60
94
|
}, rule?: {
|
|
61
95
|
props?: {
|
|
62
96
|
listType?: string;
|
|
63
97
|
};
|
|
64
|
-
}): import("../../utils/extensions.js").PasteBlock | null;
|
|
65
|
-
/** @param {Nabu} nabu @param {string} type @param {
|
|
66
|
-
static create(nabu: Nabu, type: string, props?:
|
|
98
|
+
}, siblings?: Element[]): import("../../utils/extensions.js").PasteBlock | null;
|
|
99
|
+
/** @param {Nabu} nabu @param {string} type @param {Record<string, any>} [props={}] @param {string|null} [parentId=null] @param {number|null} [index=null] */
|
|
100
|
+
static create(nabu: Nabu, type: string, props?: Record<string, any>, parentId?: string | null, index?: number | null): List;
|
|
67
101
|
/** @param {Nabu} nabu @param {ListNode} node */
|
|
68
102
|
constructor(nabu: Nabu, node: ListNode);
|
|
69
103
|
behavior: ListBehavior;
|
|
104
|
+
/**
|
|
105
|
+
* This list, its items and their sublists as PasteBlocks (the shape the static serializers read).
|
|
106
|
+
* @returns {import('../../utils/extensions.js').PasteBlock}
|
|
107
|
+
*/
|
|
108
|
+
toPasteBlock(): import("../../utils/extensions.js").PasteBlock;
|
|
109
|
+
/**
|
|
110
|
+
* The siblings before this list (the lists right before it decide its marker, see `adjacentRun`).
|
|
111
|
+
* @returns {Array<{ type: string, props: { listType?: string } }>}
|
|
112
|
+
*/
|
|
113
|
+
siblingsBefore(): Array<{
|
|
114
|
+
type: string;
|
|
115
|
+
props: {
|
|
116
|
+
listType?: string;
|
|
117
|
+
};
|
|
118
|
+
}>;
|
|
70
119
|
listType: "bullet" | "ordered" | "todo";
|
|
120
|
+
/** First number of an ORDERED list (`<ol start>`); null = 1, the default. @type {number | null} */
|
|
121
|
+
start: number | null;
|
|
122
|
+
/** `start` is only emitted when it is not the default. */
|
|
71
123
|
get clipboardProps(): {
|
|
72
124
|
listType: "bullet" | "ordered" | "todo";
|
|
125
|
+
start?: undefined;
|
|
126
|
+
} | {
|
|
127
|
+
listType: "bullet" | "ordered" | "todo";
|
|
128
|
+
start: number;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Copying a slice that starts at item `firstChildIndex` of an ORDERED list: the copy is numbered from that item's
|
|
132
|
+
* visual number (`start + index`), not from the original list start.
|
|
133
|
+
* @param {number} firstChildIndex
|
|
134
|
+
*/
|
|
135
|
+
clipboardPropsFrom(firstChildIndex: number): {
|
|
136
|
+
listType: "bullet" | "ordered" | "todo";
|
|
137
|
+
start?: undefined;
|
|
138
|
+
} | {
|
|
139
|
+
listType: "bullet" | "ordered" | "todo";
|
|
140
|
+
start: number;
|
|
73
141
|
};
|
|
74
142
|
component: import("svelte").Component<any, any, string> | import("svelte").Component<{
|
|
75
143
|
block: import("./list.svelte.js").List;
|
|
@@ -86,12 +154,15 @@ export class List extends MegaBlock {
|
|
|
86
154
|
offset: number;
|
|
87
155
|
delta: import("loro-crdt").Delta<string>;
|
|
88
156
|
}): {
|
|
157
|
+
block: import("./list-item.svelte.js").ListItem;
|
|
158
|
+
} | {
|
|
89
159
|
block: import("../block.svelte.js").Block;
|
|
90
160
|
};
|
|
91
161
|
}
|
|
92
162
|
export type ListNode = NabuNode<{
|
|
93
163
|
type: "list";
|
|
94
164
|
listType: "bullet" | "ordered" | "todo";
|
|
165
|
+
start?: number;
|
|
95
166
|
}>;
|
|
96
167
|
import { MegaBlock } from "../megablock.svelte.js";
|
|
97
168
|
import { ListBehavior } from "./list.behavior.svelte.js";
|