@aionbuilders/nabu 0.1.0-beta.0 → 0.1.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/CHANGELOG.md +523 -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 +199 -48
- package/dist/behaviors/text/text.behavior.svelte.js +549 -83
- 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 +31 -17
- 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 +1746 -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 +34 -13
- 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 +54 -7
- 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/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 +47 -19
- 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 +7 -0
- package/dist/utils/words.js +62 -0
- package/dist/vite.d.ts +9 -3
- package/dist/vite.js +19 -8
- package/package.json +54 -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,81 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The base class of every block. A block wraps a node of the document tree (Loro) and holds the behaviour of one block type: the capability flags, the tree accessors, and the handlers for typing, keys, splitting, merging, pasting and serialization that a subclass overrides.
|
|
3
|
+
*/
|
|
1
4
|
export class Block {
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @param {Nabu} nabu
|
|
7
|
+
* @param {NabuNode} node
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
public static load(nabu: Nabu, node: NabuNode): Block;
|
|
11
|
+
/**
|
|
12
|
+
* @param {Nabu} nabu
|
|
13
|
+
* @param {string} type
|
|
14
|
+
* @param {Record<string, any>} [props={}]
|
|
15
|
+
* @param {string|null} [parentId=null]
|
|
16
|
+
* @param {number|null} [index=null]
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
public static create(nabu: Nabu, type: string, props?: Record<string, any>, parentId?: string | null, index?: number | null): Block;
|
|
20
|
+
/**
|
|
21
|
+
* Which HTML elements this block reads on paste (see {@link HtmlRule}). Declare it together with `fromHTML`.
|
|
22
|
+
* @type {import('../utils/extensions.js').HtmlRule[] | undefined}
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
public static htmlRules: import("../utils/extensions.js").HtmlRule[] | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Make the block(s) of an element matched by one of `htmlRules`; `null` / `[]` declines. `siblings` are the following
|
|
28
|
+
* elements `htmlSiblings` claimed.
|
|
29
|
+
* @type {((el: Element, helpers: import('../utils/extensions.js').HtmlHelpers, rule: import('../utils/extensions.js').HtmlRule, siblings: Element[]) => import('../utils/extensions.js').PasteBlock | import('../utils/extensions.js').PasteBlock[] | null) | undefined}
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
public static fromHTML: ((el: Element, helpers: import("../utils/extensions.js").HtmlHelpers, rule: import("../utils/extensions.js").HtmlRule, siblings: Element[]) => import("../utils/extensions.js").PasteBlock | import("../utils/extensions.js").PasteBlock[] | null) | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Ask to absorb the elements that follow `el` (a structure that spans several elements, a list in Google Docs); returns them in order.
|
|
35
|
+
* @type {((el: Element, rule: import('../utils/extensions.js').HtmlRule, helpers: import('../utils/extensions.js').HtmlHelpers) => Element[]) | undefined}
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
public static htmlSiblings: ((el: Element, rule: import("../utils/extensions.js").HtmlRule, helpers: import("../utils/extensions.js").HtmlHelpers) => Element[]) | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* How this block starts and how many lines it takes in markdown (see {@link MarkdownRule}). Declare it together with `fromMarkdown`.
|
|
41
|
+
* @type {import('../utils/extensions.js').MarkdownRule[] | undefined}
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
public static markdownRules: import("../utils/extensions.js").MarkdownRule[] | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Make the block(s) of the lines a `markdownRules` rule consumed; `null` declines (the next rule is tried).
|
|
47
|
+
* @type {((lines: string[], helpers: import('../utils/extensions.js').MarkdownHelpers, rule: import('../utils/extensions.js').MarkdownRule) => import('../utils/extensions.js').PasteBlock | import('../utils/extensions.js').PasteBlock[] | null) | undefined}
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
public static fromMarkdown: ((lines: string[], helpers: import("../utils/extensions.js").MarkdownHelpers, rule: import("../utils/extensions.js").MarkdownRule) => import("../utils/extensions.js").PasteBlock | import("../utils/extensions.js").PasteBlock[] | null) | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* The markdown of a block of this type, for the clipboard's `text/plain` and for containers that serialize their children.
|
|
53
|
+
* @type {((pb: import('../utils/extensions.js').PasteBlock, ctx: import('../utils/extensions.js').SerializeContext) => string) | undefined}
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
public static toMarkdown: ((pb: import("../utils/extensions.js").PasteBlock, ctx: import("../utils/extensions.js").SerializeContext) => string) | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* The HTML of a block of this type, for the clipboard's `text/html`.
|
|
59
|
+
* @type {((pb: import('../utils/extensions.js').PasteBlock, ctx: import('../utils/extensions.js').SerializeContext) => string) | undefined}
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
public static toHtml: ((pb: import("../utils/extensions.js").PasteBlock, ctx: import("../utils/extensions.js").SerializeContext) => string) | undefined;
|
|
6
63
|
/** @param {Nabu} nabu @param {NabuNode} node */
|
|
7
64
|
constructor(nabu: Nabu, node: NabuNode);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
* @
|
|
23
|
-
* @
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
65
|
+
/**
|
|
66
|
+
* The editor this block belongs to.
|
|
67
|
+
* @type {Nabu}
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
public nabu: Nabu;
|
|
71
|
+
/**
|
|
72
|
+
* The block's node in the document tree (Loro): `node.data` holds its `type` and props, `node.parent()` / `node.children()` the structure.
|
|
73
|
+
* @type {NabuNode}
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
public node: NabuNode;
|
|
77
|
+
/**
|
|
78
|
+
* The Loro tree id of the node (also the key in `nabu.blocks`).
|
|
79
|
+
* @type {import('loro-crdt').TreeID}
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
public id: import("loro-crdt").TreeID;
|
|
83
|
+
/**
|
|
84
|
+
* The block type, as registered by its extension (`'paragraph'`, `'callout'`...). Read from the node when the block is built; `retype()` changes the node, and the engine builds a new block.
|
|
85
|
+
* @type {string}
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
public type: string;
|
|
89
|
+
/**
|
|
90
|
+
* @type {MegaBlock | null}
|
|
91
|
+
* @public
|
|
92
|
+
*/
|
|
93
|
+
public parent: MegaBlock | null;
|
|
94
|
+
/**
|
|
95
|
+
* Serializers of this block by format: `'markdown'`, `'json'`, `'application/x-nabu+json'` (the clipboard) or one of your own.
|
|
96
|
+
* Each receives the context of the call (`{ from, to, partial }` for the clipboard) and returns the serialized block.
|
|
97
|
+
* @type {SvelteMap<string, function(any): any>}
|
|
98
|
+
* @public
|
|
99
|
+
*/
|
|
100
|
+
public serializers: SvelteMap<string, (arg0: any) => any>;
|
|
101
|
+
/**
|
|
102
|
+
* The behaviors of the block by name; a text block has `'text'` (a `TextBehavior`).
|
|
103
|
+
* @type {SvelteMap<string, any>}
|
|
104
|
+
* @public
|
|
105
|
+
*/
|
|
106
|
+
public behaviors: SvelteMap<string, any>;
|
|
107
|
+
/** The selection covers this block (reactive). @public */
|
|
108
|
+
public selected: boolean;
|
|
109
|
+
/** The selection starts in this block (reactive). @public */
|
|
110
|
+
public isSelectionStart: boolean;
|
|
111
|
+
/** The selection ends in this block (reactive). @public */
|
|
112
|
+
public isSelectionEnd: boolean;
|
|
113
|
+
/** The selection covers this block and neither starts nor ends in it (reactive). @public */
|
|
114
|
+
public isIntermediate: boolean;
|
|
115
|
+
/** @public */
|
|
116
|
+
public clearSelection(): void;
|
|
117
|
+
/**
|
|
118
|
+
* @type {{from: number, to: number, direction: "forward" | "backward" | "none"} | null}
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
121
|
+
public selection: {
|
|
33
122
|
from: number;
|
|
34
123
|
to: number;
|
|
35
124
|
direction: "forward" | "backward" | "none";
|
|
36
125
|
} | null;
|
|
37
|
-
|
|
126
|
+
/** @public */
|
|
127
|
+
public positions: number;
|
|
38
128
|
/**
|
|
39
129
|
* Number of words contained in this block. Overridden by text blocks
|
|
40
130
|
* (own text) and containers (sum of children) so that parents can
|
|
41
131
|
* aggregate without re-traversing the whole subtree.
|
|
42
132
|
* @type {number}
|
|
133
|
+
* @public
|
|
134
|
+
*/
|
|
135
|
+
public wordCount: number;
|
|
136
|
+
/**
|
|
137
|
+
* When false, Enter inserts a literal "\n" in place instead of splitting the block.
|
|
138
|
+
* @type {boolean}
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
141
|
+
public splitsOnEnter: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* When false, onBeforeInput markdown-shortcut hooks and inputRules are skipped in this block.
|
|
144
|
+
* @type {boolean}
|
|
145
|
+
* @public
|
|
146
|
+
*/
|
|
147
|
+
public transformsEnabled: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* When false, inline marks (bold/italic/...) are never applied to this block.
|
|
150
|
+
* @type {boolean}
|
|
151
|
+
* @public
|
|
152
|
+
*/
|
|
153
|
+
public marksEnabled: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* True when the block currently hides its children (they are not rendered, e.g. a collapsed
|
|
156
|
+
* foldable block): navigation (`findForward` / `findBackward` / `findLastDescendant`, caret
|
|
157
|
+
* normalisation) never enters them. Override with a getter in a subclass.
|
|
158
|
+
* @type {boolean}
|
|
159
|
+
* @public
|
|
160
|
+
*/
|
|
161
|
+
public get hidesChildren(): boolean;
|
|
162
|
+
/**
|
|
163
|
+
* When true, the text of this block is an ISOLATED FIELD (like a form input embedded in the document): a text selection
|
|
164
|
+
* that does not lie entirely inside this block never touches its text. For such a selection (the engine's rules, see
|
|
165
|
+
* `container.utils.js`, `selection.svelte.js`):
|
|
166
|
+
* - range deletion, typing over it, cut and the marks skip the text of this block, and delete neither this block nor its
|
|
167
|
+
* container; the clipboard gets the TEXT blocks only (the block's own text and its container are not copied);
|
|
168
|
+
* - two text blocks on either side of an isolated block, or in different "isolation owners" (the nearest ancestor that
|
|
169
|
+
* isolates), never merge, so a deletion across them clears both sides without joining them;
|
|
170
|
+
* - the block is not highlighted (`data-nabu-isolated` + the root's `data-nabu-range`), and a selection end that would
|
|
171
|
+
* land in it is moved past it, in the direction of travel; a selection that STARTS in it stays bounded to it;
|
|
172
|
+
* - the caret enters it at its start going down / right, at its end going up / left; Select All inside it selects its text.
|
|
173
|
+
* @type {boolean}
|
|
174
|
+
* @public
|
|
175
|
+
*/
|
|
176
|
+
public isolatesSelection: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* When true, pasting inside this block inserts the clipboard's text/plain verbatim (replacing the selection), skipping every paste interpreter: no blocks created, no markdown/HTML interpretation.
|
|
179
|
+
* @type {boolean}
|
|
180
|
+
* @public
|
|
43
181
|
*/
|
|
44
|
-
|
|
45
|
-
/** When false, Enter inserts a literal "\n" in place instead of splitting the block. @type {boolean} */
|
|
46
|
-
splitsOnEnter: boolean;
|
|
47
|
-
/** When false, onBeforeInput markdown-shortcut hooks and inputRules are skipped in this block. @type {boolean} */
|
|
48
|
-
transformsEnabled: boolean;
|
|
49
|
-
/** When false, inline marks (bold/italic/...) are never applied to this block. @type {boolean} */
|
|
50
|
-
marksEnabled: boolean;
|
|
182
|
+
public pastesAsPlainText: boolean;
|
|
51
183
|
/**
|
|
52
184
|
* Resolve a document-local offset to { block, offset } within this block.
|
|
53
185
|
* Leaf blocks with text return themselves directly.
|
|
54
186
|
* Override in MegaBlock (pure containers) and mixed blocks (e.g. ListItem).
|
|
55
187
|
* @param {number} localOffset
|
|
56
188
|
* @returns {{ block: Block, offset: number } | null}
|
|
189
|
+
* @public
|
|
57
190
|
*/
|
|
58
|
-
resolveOffset(localOffset: number): {
|
|
191
|
+
public resolveOffset(localOffset: number): {
|
|
59
192
|
block: Block;
|
|
60
193
|
offset: number;
|
|
61
194
|
} | null;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
195
|
+
/** @public */
|
|
196
|
+
public index: number;
|
|
197
|
+
/**
|
|
198
|
+
* @type {Block?}
|
|
199
|
+
* @public
|
|
200
|
+
*/
|
|
201
|
+
public previous: Block | null;
|
|
202
|
+
/**
|
|
203
|
+
* @type {Block?}
|
|
204
|
+
* @public
|
|
205
|
+
*/
|
|
206
|
+
public next: Block | null;
|
|
207
|
+
/** @public */
|
|
208
|
+
public parents: MegaBlock[];
|
|
209
|
+
/** @public */
|
|
210
|
+
public component: import("svelte").Component<any, any, string> | null;
|
|
211
|
+
/**
|
|
212
|
+
* Resolved placeholder to render in `data-placeholder` ('' = none). Combines the
|
|
213
|
+
* Nabu `placeholders` option, the block's emptiness and — with `show: 'focus'`
|
|
214
|
+
* (default) — whether it holds the collapsed cursor.
|
|
215
|
+
*
|
|
216
|
+
* The default text is declared by each block class as `static placeholder`
|
|
217
|
+
* (string, `false`, or `(block) => string | false`), overridable per type through
|
|
218
|
+
* the `placeholders.text` option. Blocks without a text behavior never show one.
|
|
219
|
+
* (No `static placeholder` is declared here: Svelte forbids a static and a
|
|
220
|
+
* reactive field with the same name in one class.)
|
|
221
|
+
* @type {string}
|
|
222
|
+
* @public
|
|
223
|
+
*/
|
|
224
|
+
public placeholder: string;
|
|
225
|
+
/**
|
|
226
|
+
* @type {HTMLElement | null}
|
|
227
|
+
* @public
|
|
228
|
+
*/
|
|
229
|
+
public element: HTMLElement | null;
|
|
230
|
+
/**
|
|
231
|
+
* The next block in document order (own descendants first, then the following siblings with their descendants, then
|
|
232
|
+
* those of each ancestor) that satisfies `predicate`, or null. A block that hides its children is not entered.
|
|
233
|
+
* LINEAR: every block is visited at most once (the following siblings are only DESCENDED into, never searched
|
|
234
|
+
* "forward" again, which would revisit everything after them).
|
|
235
|
+
* @param {(block: Block) => boolean} predicate @returns {Block | null}
|
|
236
|
+
* @public
|
|
237
|
+
*/
|
|
238
|
+
public findForward(predicate: (block: Block) => boolean): Block | null;
|
|
239
|
+
/**
|
|
240
|
+
* @param {(block: Block) => boolean} predicate
|
|
241
|
+
* @returns {Block | null}
|
|
242
|
+
* @public
|
|
243
|
+
*/
|
|
244
|
+
public findBackward(predicate: (block: Block) => boolean): Block | null;
|
|
75
245
|
/**
|
|
76
246
|
* Returns real, uncommitted siblings, which is useful for extensions that want to check the document structure before the transaction is committed.
|
|
247
|
+
* @public
|
|
77
248
|
*/
|
|
78
|
-
getAdjacentSiblings(): {
|
|
249
|
+
public getAdjacentSiblings(): {
|
|
79
250
|
previous: null;
|
|
80
251
|
next: null;
|
|
81
252
|
previousNode?: undefined;
|
|
@@ -83,58 +254,130 @@ export class Block {
|
|
|
83
254
|
} | {
|
|
84
255
|
previous: Block | null | undefined;
|
|
85
256
|
next: Block | null | undefined;
|
|
86
|
-
previousNode: import("loro-crdt").LoroTreeNode<
|
|
257
|
+
previousNode: import("loro-crdt").LoroTreeNode<{
|
|
87
258
|
type: string;
|
|
88
|
-
}
|
|
89
|
-
nextNode: import("loro-crdt").LoroTreeNode<
|
|
259
|
+
} & Record<string, any>> | import("loro-crdt").LoroTreeNode<Record<string, unknown>> | null;
|
|
260
|
+
nextNode: import("loro-crdt").LoroTreeNode<{
|
|
90
261
|
type: string;
|
|
91
|
-
}
|
|
262
|
+
} & Record<string, any>> | import("loro-crdt").LoroTreeNode<Record<string, unknown>> | null;
|
|
92
263
|
};
|
|
93
264
|
/**
|
|
94
265
|
* Helper pour trouver le dernier descendant profond qui matche
|
|
95
266
|
* @param {(block: Block) => boolean} predicate
|
|
96
267
|
* @returns {Block | null}
|
|
268
|
+
* @public
|
|
97
269
|
*/
|
|
98
|
-
findLastDescendant(predicate: (block: Block) => boolean): Block | null;
|
|
99
|
-
|
|
270
|
+
public findLastDescendant(predicate: (block: Block) => boolean): Block | null;
|
|
271
|
+
/** @public */
|
|
272
|
+
public destroy(): void;
|
|
100
273
|
/**
|
|
101
274
|
* Transforme ce bloc en un autre type de bloc.
|
|
102
275
|
* @param {string} newType
|
|
103
|
-
* @param {
|
|
276
|
+
* @param {Record<string, any>} [props={}]
|
|
277
|
+
* @public
|
|
278
|
+
*/
|
|
279
|
+
public transformTo(newType: string, props?: Record<string, any>): void;
|
|
280
|
+
/**
|
|
281
|
+
* The mutations of a type change, without the commit: the caller owns the transaction
|
|
282
|
+
* (`transformTo`, the `block:transform` action…). By default the block is retyped IN PLACE (same node:
|
|
283
|
+
* its id, text and position survive). Override it when a block cannot simply change type where it
|
|
284
|
+
* stands (e.g. because its parent only accepts some children): do the same job with Loro mutations only.
|
|
285
|
+
* @param {string} newType
|
|
286
|
+
* @param {Record<string, any>} [props={}]
|
|
287
|
+
* @public
|
|
288
|
+
*/
|
|
289
|
+
public retype(newType: string, props?: Record<string, any>): void;
|
|
290
|
+
/**
|
|
291
|
+
* @param {number} index
|
|
292
|
+
* @param {string} text
|
|
293
|
+
* @public
|
|
294
|
+
*/
|
|
295
|
+
public insert(index: number, text: string): void;
|
|
296
|
+
/**
|
|
297
|
+
* @param {{from?: number, to?: number, index?: number, length?: number}} [deletion]
|
|
298
|
+
* @public
|
|
104
299
|
*/
|
|
105
|
-
|
|
106
|
-
/** @param {number} index @param {string} text */
|
|
107
|
-
insert(index: number, text: string): void;
|
|
108
|
-
/** @param {{from?: number, to?: number, index?: number, length?: number}} [deletion] */
|
|
109
|
-
delete(deletion?: {
|
|
300
|
+
public delete(deletion?: {
|
|
110
301
|
from?: number;
|
|
111
302
|
to?: number;
|
|
112
303
|
index?: number;
|
|
113
304
|
length?: number;
|
|
114
305
|
}): void;
|
|
115
|
-
/**
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
306
|
+
/**
|
|
307
|
+
* @param {Block} block
|
|
308
|
+
* @returns {any}
|
|
309
|
+
* @public
|
|
310
|
+
*/
|
|
311
|
+
public absorbs(block: Block): any;
|
|
312
|
+
/**
|
|
313
|
+
* @param {Block} block
|
|
314
|
+
* @returns {any}
|
|
315
|
+
* @public
|
|
316
|
+
*/
|
|
317
|
+
public mergeWith(block: Block): any;
|
|
119
318
|
/**
|
|
120
319
|
* Consumes another block, handling children relocation intelligently.
|
|
121
320
|
* @param {Block} otherBlock - The block to consume or be consumed by
|
|
122
321
|
* @param {'into' | 'from'} direction - 'into' = this merges into other, 'from' = other merges into this
|
|
123
322
|
* @returns {Block} The surviving block
|
|
323
|
+
* @public
|
|
124
324
|
*/
|
|
125
|
-
consume(otherBlock: Block, direction?: "into" | "from"): Block;
|
|
325
|
+
public consume(otherBlock: Block, direction?: "into" | "from"): Block;
|
|
126
326
|
/**
|
|
127
327
|
* Declares a required parent type for structural integrity.
|
|
128
328
|
* Override in subclasses (e.g. ListItem requires a "list" parent).
|
|
129
329
|
* Used by wrapOrphan() after block relocations.
|
|
130
330
|
* @returns {{ type: string, props: () => Record<string, any> } | null}
|
|
331
|
+
* @public
|
|
131
332
|
*/
|
|
132
|
-
get requiredParent(): {
|
|
333
|
+
public get requiredParent(): {
|
|
133
334
|
type: string;
|
|
134
335
|
props: () => Record<string, any>;
|
|
135
336
|
} | null;
|
|
136
|
-
/**
|
|
137
|
-
|
|
337
|
+
/**
|
|
338
|
+
* Whether an EMPTY child of this block takes the type of a whole block pasted into it (a `# Title` pasted
|
|
339
|
+
* into an empty paragraph makes it a heading). Always true for root blocks; a container with structural
|
|
340
|
+
* rules about its children (a list) keeps it `false`, a container with a free-form body (a toggle) opts in.
|
|
341
|
+
* @returns {boolean}
|
|
342
|
+
* @public
|
|
343
|
+
*/
|
|
344
|
+
public get adoptsPastedTypes(): boolean;
|
|
345
|
+
/**
|
|
346
|
+
* Paste extension point: lets the block that holds the caret decide how a pasted fragment lands, instead
|
|
347
|
+
* of the engine's default (first block merged into the caret block, the rest inserted after it as
|
|
348
|
+
* siblings). A block that lives in a container with its own rules about what it can hold overrides it
|
|
349
|
+
* (e.g. a list item turns pasted paragraphs into siblings items and splits its list around a block it
|
|
350
|
+
* cannot hold). The engine has already removed the selection; it commits the whole paste as ONE
|
|
351
|
+
* transaction (one undo step) and puts the caret at the returned point.
|
|
352
|
+
*
|
|
353
|
+
* Contract: return null to DECLINE, and then touch nothing (the default insertion runs). Otherwise
|
|
354
|
+
* apply the whole paste on the tree (the blocks are created through `nabu.createPasteBlock` /
|
|
355
|
+
* `nabu.insertPasteBlock`), do NOT commit, and return where the caret goes.
|
|
356
|
+
* @param {import('../utils/extensions.js').PasteBlock[]} blocks the sanitized fragment
|
|
357
|
+
* @param {{ offset: number }} ctx the caret offset in this block's text
|
|
358
|
+
* @returns {{ block: Block | null, offset: number } | null} `block: null` leaves the caret to the engine
|
|
359
|
+
* @public
|
|
360
|
+
*/
|
|
361
|
+
public acceptPaste(blocks: import("../utils/extensions.js").PasteBlock[], ctx: {
|
|
362
|
+
offset: number;
|
|
363
|
+
}): {
|
|
364
|
+
block: Block | null;
|
|
365
|
+
offset: number;
|
|
366
|
+
} | null;
|
|
367
|
+
/**
|
|
368
|
+
* The blocks that travel together when THIS block is dragged by its handle (P-81): this block and anything the drag must carry
|
|
369
|
+
* with it, in document order, all in the same parent. The default is the block alone (a container carries its own children:
|
|
370
|
+
* they are its tree children). A block whose "extent" is not its subtree overrides it (an extension may widen the range). The drop rules are the same for any range: it cannot land inside itself.
|
|
371
|
+
* @returns {Block[]}
|
|
372
|
+
* @public
|
|
373
|
+
*/
|
|
374
|
+
public dragRange(): Block[];
|
|
375
|
+
/**
|
|
376
|
+
* @param {{from?: number, to?: number, index?: number, length?: number, offset?: number}} options
|
|
377
|
+
* @returns {{block: Block} | null}
|
|
378
|
+
* @public
|
|
379
|
+
*/
|
|
380
|
+
public split(options: {
|
|
138
381
|
from?: number;
|
|
139
382
|
to?: number;
|
|
140
383
|
index?: number;
|
|
@@ -143,8 +386,12 @@ export class Block {
|
|
|
143
386
|
}): {
|
|
144
387
|
block: Block;
|
|
145
388
|
} | null;
|
|
146
|
-
/**
|
|
147
|
-
|
|
389
|
+
/**
|
|
390
|
+
* @param {{start?: number, end?: number, offset?: number} | null } options
|
|
391
|
+
* @param {boolean} [passive=false]
|
|
392
|
+
* @public
|
|
393
|
+
*/
|
|
394
|
+
public focus(options?: {
|
|
148
395
|
start?: number;
|
|
149
396
|
end?: number;
|
|
150
397
|
offset?: number;
|
|
@@ -165,24 +412,41 @@ export class Block {
|
|
|
165
412
|
/**
|
|
166
413
|
* @param {number} offset
|
|
167
414
|
* @returns {{node: Node, offset: number} | null}
|
|
415
|
+
* @public
|
|
168
416
|
*/
|
|
169
|
-
getDOMPoint(offset: number): {
|
|
417
|
+
public getDOMPoint(offset: number): {
|
|
170
418
|
node: Node;
|
|
171
419
|
offset: number;
|
|
172
420
|
} | null;
|
|
173
|
-
/**
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
|
|
421
|
+
/**
|
|
422
|
+
* @param {string} eventName
|
|
423
|
+
* @param {Event | null} event
|
|
424
|
+
* @param {Object} [data={}]
|
|
425
|
+
* @public
|
|
426
|
+
*/
|
|
427
|
+
public ascend(eventName: string, event: Event | null, data?: Object): any;
|
|
428
|
+
/**
|
|
429
|
+
* @param {InputEvent} event
|
|
430
|
+
* @returns {any}
|
|
431
|
+
* @public
|
|
432
|
+
*/
|
|
433
|
+
public beforeinput(event: InputEvent): any;
|
|
434
|
+
/**
|
|
435
|
+
* @param {KeyboardEvent} event
|
|
436
|
+
* @returns {any}
|
|
437
|
+
* @public
|
|
438
|
+
*/
|
|
439
|
+
public keydown(event: KeyboardEvent): any;
|
|
440
|
+
/** @public */
|
|
441
|
+
public commit(): Promise<void>;
|
|
442
|
+
/**
|
|
443
|
+
* @param {string} format
|
|
444
|
+
* @param {Record<string, any>} [context]
|
|
445
|
+
* @public
|
|
446
|
+
*/
|
|
447
|
+
public serialize(format: string, context?: Record<string, any>): any;
|
|
182
448
|
}
|
|
183
449
|
import type { Nabu } from "./nabu.svelte.js";
|
|
184
450
|
import type { NabuNode } from "./nabu.svelte.js";
|
|
185
451
|
import type { MegaBlock } from "./megablock.svelte.js";
|
|
186
452
|
import { SvelteMap } from "svelte/reactivity";
|
|
187
|
-
import { Variable } from "./variable.svelte.js";
|
|
188
|
-
import type { VariableInit } from "./variable.svelte.js";
|