@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
|
@@ -7,34 +7,66 @@
|
|
|
7
7
|
export function deltaToHtml(delta: import("loro-crdt").Delta<string>[]): string;
|
|
8
8
|
/**
|
|
9
9
|
* Converts a Loro text delta to inline Markdown.
|
|
10
|
+
* A line break (`\n` in the text) is exported as a markdown hard break (backslash + newline), unless `rawBreaks`
|
|
11
|
+
* (a block that re-reads its own lines, like a callout body, keeps the plain newline).
|
|
10
12
|
* @param {import('loro-crdt').Delta<string>[]} delta
|
|
13
|
+
* @param {{ rawBreaks?: boolean }} [options]
|
|
11
14
|
* @returns {string}
|
|
12
15
|
*/
|
|
13
|
-
export function deltaToMarkdown(delta: import("loro-crdt").Delta<string>[]
|
|
16
|
+
export function deltaToMarkdown(delta: import("loro-crdt").Delta<string>[], { rawBreaks }?: {
|
|
17
|
+
rawBreaks?: boolean;
|
|
18
|
+
}): string;
|
|
19
|
+
/** A link destination: raw when plain, `<…>` when it holds whitespace, angle brackets or unbalanced parentheses. */
|
|
20
|
+
export function markdownDestination(href: string): string;
|
|
14
21
|
/**
|
|
15
|
-
*
|
|
16
|
-
|
|
22
|
+
* Length (UTF-16 units) of the user-perceived character starting at `index` — the unit one Delete press removes.
|
|
23
|
+
* `Intl.Segmenter` handles ZWJ sequences, flags and combining marks; without it a surrogate pair is kept whole.
|
|
24
|
+
* A caret inside a cluster deletes up to the end of that cluster. 0 at the end of the text.
|
|
25
|
+
* @param {string} text @param {number} index
|
|
26
|
+
*/
|
|
27
|
+
export function nextGraphemeLength(text: string, index: number): number;
|
|
28
|
+
/**
|
|
29
|
+
* Length (UTF-16 units) of the user-perceived character ENDING at `index` — the unit one Backspace press removes.
|
|
30
|
+
* Mirror of {@link nextGraphemeLength}: `Intl.Segmenter` handles ZWJ sequences, flags and combining marks; without it a
|
|
31
|
+
* surrogate pair is kept whole. A caret inside a cluster deletes back to the start of that cluster. 0 at the start.
|
|
32
|
+
* @param {string} text @param {number} index
|
|
33
|
+
*/
|
|
34
|
+
export function prevGraphemeLength(text: string, index: number): number;
|
|
35
|
+
/**
|
|
36
|
+
* The editing of a block's rich text: wraps a Loro text and offers the reactive `text` and `delta`, the selection in that text, and insertion, deletion, splitting, marks and links. Text blocks use it through `TextBlock`; a container with a header (list item, toggle) owns one.
|
|
37
|
+
*/
|
|
17
38
|
export class TextBehavior {
|
|
18
39
|
/** @param {Block} block @param {LoroText} [container] */
|
|
19
40
|
constructor(block: Block, container?: LoroText);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
41
|
+
/** @public */
|
|
42
|
+
public block: Block;
|
|
43
|
+
nabu: import("../../blocks").Nabu;
|
|
44
|
+
/**
|
|
45
|
+
* @type {LoroText}
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
public container: LoroText;
|
|
49
|
+
/** @public */
|
|
50
|
+
public text: string;
|
|
51
|
+
/** @public */
|
|
52
|
+
public delta: import("loro-crdt").Delta<string>[];
|
|
53
|
+
/** @public */
|
|
54
|
+
public selection: {
|
|
27
55
|
from: number;
|
|
28
56
|
to: number;
|
|
29
57
|
isCollapsed: boolean;
|
|
30
|
-
direction: "
|
|
58
|
+
direction: "backward" | "forward" | "none";
|
|
31
59
|
} | null;
|
|
32
|
-
|
|
60
|
+
/** @public */
|
|
61
|
+
public positions: number;
|
|
33
62
|
/**
|
|
34
|
-
* Number of
|
|
63
|
+
* Number of words in this text: segmented with `Intl.Segmenter` in the language of the editor (`nabu.lang`) when the platform
|
|
64
|
+
* has it, so Chinese or Japanese text counts its words rather than one per sentence; whitespace-separated otherwise. See
|
|
65
|
+
* `utils/words.js`. Reactive in the text and in `nabu.lang`.
|
|
35
66
|
* @returns {number}
|
|
67
|
+
* @public
|
|
36
68
|
*/
|
|
37
|
-
get wordCount(): number;
|
|
69
|
+
public get wordCount(): number;
|
|
38
70
|
/**
|
|
39
71
|
* @param {HTMLElement} element
|
|
40
72
|
* @param {NabuSelection} globalSelection
|
|
@@ -43,7 +75,7 @@ export class TextBehavior {
|
|
|
43
75
|
from: number;
|
|
44
76
|
to: number;
|
|
45
77
|
isCollapsed: boolean;
|
|
46
|
-
direction: "
|
|
78
|
+
direction: "backward" | "forward" | "none";
|
|
47
79
|
} | null;
|
|
48
80
|
/**
|
|
49
81
|
* Calcule l'offset textuel d'un point DOM par rapport au début de ce bloc
|
|
@@ -52,89 +84,197 @@ export class TextBehavior {
|
|
|
52
84
|
* @param {HTMLElement?} [element]
|
|
53
85
|
*/
|
|
54
86
|
calculateOffset(node: Node, offset: number, element?: HTMLElement | null): number;
|
|
55
|
-
/**
|
|
56
|
-
|
|
87
|
+
/**
|
|
88
|
+
* {@link TextBehavior#calculateOffset} bounded by the MODEL text: an empty text renders a lone "\n" placeholder, and a caret
|
|
89
|
+
* after it is still offset 0, not 1 (P-108). (Not during an IME composition: the browser's text is ahead of the model then.)
|
|
90
|
+
* @param {Node} node @param {number} offset @param {HTMLElement?} [element]
|
|
91
|
+
*/
|
|
92
|
+
modelOffset(node: Node, offset: number, element?: HTMLElement | null): number;
|
|
93
|
+
/**
|
|
94
|
+
* IME composition starts. With a trailing render filler (`<br data-nabu-filler>`, the empty last line after a "\n")
|
|
95
|
+
* the browser puts the composed text in a NEW text node before the filler (and may swap the filler for a `<br>` of
|
|
96
|
+
* its own) — nodes Svelte does not know, which would stay next to the ones it updates once the model catches up
|
|
97
|
+
* (text shown twice). Remember Svelte's nodes so {@link TextBehavior#restoreAfterComposition} can undo the browser's
|
|
98
|
+
* additions at the end. No filler: nothing to do.
|
|
99
|
+
*/
|
|
100
|
+
snapshotForComposition(): void;
|
|
101
|
+
/**
|
|
102
|
+
* End of a composition begun next to a filler, BEFORE the composed text reaches the model: remove the text nodes and
|
|
103
|
+
* `<br>` the browser created meanwhile (the composed text is committed to the model, which the next render shows
|
|
104
|
+
* through Svelte's own nodes); a canceled composition (`composedText` empty) gets its filler back.
|
|
105
|
+
* @param {string} composedText
|
|
106
|
+
*/
|
|
107
|
+
restoreAfterComposition(composedText: string): void;
|
|
108
|
+
/**
|
|
109
|
+
* @param {InputEvent} event
|
|
110
|
+
* @param {ReturnType<TextBehavior["getSelection"]>} [selection]
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
113
|
+
public handleBeforeInput(event: InputEvent, selection?: ReturnType<TextBehavior["getSelection"]>): any;
|
|
57
114
|
/** @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [selection] */
|
|
58
115
|
handleInsertText(event: InputEvent, selection?: ReturnType<TextBehavior["getSelection"]>): true | undefined;
|
|
59
116
|
/** @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel] */
|
|
60
117
|
handleInsertLineBreak(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): void;
|
|
61
118
|
/** @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel] */
|
|
62
|
-
handleDeleteContentBackward(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>):
|
|
119
|
+
handleDeleteContentBackward(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): true | undefined;
|
|
63
120
|
/** @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel] */
|
|
64
|
-
handleDeleteContentForward(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>):
|
|
121
|
+
handleDeleteContentForward(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): true | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* Deletes the word before the cursor (Ctrl+Backspace on Win/Linux, Option+Backspace on Mac): the whitespace between the
|
|
124
|
+
* caret and the word goes with it, and the caret lands where the word started ("one two |" -> "one |", issue #4).
|
|
125
|
+
*
|
|
126
|
+
* For a collapsed selection the range is computed from the model text, never from `event.getTargetRanges()`: browsers
|
|
127
|
+
* disagree on it (Chromium stops right after the previous space, leaving "one two " from "one two three"), so the
|
|
128
|
+
* behavior would differ per engine. The rules (words by `Intl.Segmenter`, punctuation, line breaks) are in
|
|
129
|
+
* {@link wordDeleteRange}. A selection is deleted whole.
|
|
130
|
+
* @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel]
|
|
131
|
+
*/
|
|
132
|
+
handleDeleteWordBackward(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): boolean | undefined;
|
|
133
|
+
/**
|
|
134
|
+
* Deletes the word after the cursor (Ctrl+Delete on Win/Linux, Option+Fn+Delete on Mac). Like the backward deletion it is
|
|
135
|
+
* resolved from the model text only (`getTargetRanges()` is engine-dependent). macOS deletes up to the end of the next
|
|
136
|
+
* word ("one |two three" -> "one | three"), Windows up to the start of the one after ("one |two three" -> "one |three");
|
|
137
|
+
* see {@link wordDeleteRange}. A selection is deleted whole.
|
|
138
|
+
* @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel]
|
|
139
|
+
*/
|
|
140
|
+
handleDeleteWordForward(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): boolean | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* Deletes from the start of the current line to the cursor (Cmd+Backspace on Mac; `deleteHardLineBackward`).
|
|
143
|
+
* A selection inside the block is deleted whole.
|
|
144
|
+
* @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel]
|
|
145
|
+
*/
|
|
146
|
+
handleDeleteSoftLineBackward(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): boolean | undefined;
|
|
65
147
|
/**
|
|
66
|
-
* Deletes the
|
|
67
|
-
*
|
|
68
|
-
* so no orphan space is left behind (issue #4).
|
|
148
|
+
* Deletes from the cursor to the end of the current line (Cmd+Fn+Delete, Ctrl+K style; `deleteHardLineForward`).
|
|
149
|
+
* At the end of a line (before a "\n") or of the block nothing is deleted. A selection is deleted whole.
|
|
69
150
|
* @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel]
|
|
70
151
|
*/
|
|
71
|
-
|
|
152
|
+
handleDeleteSoftLineForward(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): boolean | undefined;
|
|
72
153
|
/**
|
|
73
|
-
* Deletes the
|
|
74
|
-
*
|
|
154
|
+
* Deletes the whole line(s) touched by the selection (`deleteEntireSoftLine`): the text between the surrounding "\n"
|
|
155
|
+
* (or block edges), the line breaks themselves are kept. Caret at the start of the emptied line.
|
|
75
156
|
* @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel]
|
|
76
157
|
*/
|
|
77
|
-
|
|
158
|
+
handleDeleteEntireLine(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): boolean | undefined;
|
|
78
159
|
/**
|
|
79
|
-
*
|
|
80
|
-
* (Cmd+Backspace on Mac).
|
|
160
|
+
* `deleteContent`: delete the selection (no direction). A collapsed caret deletes nothing.
|
|
81
161
|
* @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel]
|
|
82
162
|
*/
|
|
83
|
-
|
|
163
|
+
handleDeleteContent(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): boolean | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* `insertReplacementText`: a spellcheck / autocorrect replacement. The replacement text comes in
|
|
166
|
+
* `dataTransfer` (`text/plain`) or `data`; the range to replace in `getTargetRanges()` (mapped to model offsets), else
|
|
167
|
+
* the selection. The replaced run's marks are kept on the new text. One edit (one undo step), caret after it.
|
|
168
|
+
* @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel]
|
|
169
|
+
*/
|
|
170
|
+
handleInsertReplacementText(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): boolean;
|
|
171
|
+
/**
|
|
172
|
+
* `insertFromYank` (Emacs-style yank on macOS): the text is inserted as plain text at the caret, replacing the selection.
|
|
173
|
+
* No input rule runs (it is a paste, not typing).
|
|
174
|
+
* @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel]
|
|
175
|
+
*/
|
|
176
|
+
handleInsertFromYank(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): true | undefined;
|
|
177
|
+
/**
|
|
178
|
+
* `insertTranspose` (macOS Ctrl+T): swaps the two graphemes around the caret; at the end of the text, the last two.
|
|
179
|
+
* Marks travel with their character. No-op with a selection, at the start, with a single character or across a line break.
|
|
180
|
+
* @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel]
|
|
181
|
+
*/
|
|
182
|
+
handleInsertTranspose(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): boolean;
|
|
84
183
|
/** @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [sel] */
|
|
85
184
|
handleInsertParagraph(event: InputEvent, sel?: ReturnType<TextBehavior["getSelection"]>): any;
|
|
86
185
|
/**
|
|
87
186
|
* Retrouve le nœud texte et l'offset DOM pour un offset Modèle donné
|
|
88
187
|
* @param {number} targetOffset
|
|
89
188
|
* @param {HTMLElement?} [element]
|
|
189
|
+
* @public
|
|
90
190
|
*/
|
|
91
|
-
getDOMPoint(targetOffset: number, element?: HTMLElement | null): {
|
|
191
|
+
public getDOMPoint(targetOffset: number, element?: HTMLElement | null): {
|
|
92
192
|
node: Node;
|
|
93
193
|
offset: number;
|
|
94
194
|
} | null;
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
195
|
+
/**
|
|
196
|
+
* @param {number} index
|
|
197
|
+
* @param {string} text
|
|
198
|
+
* @public
|
|
199
|
+
*/
|
|
200
|
+
public insert(index: number, text: string): void;
|
|
201
|
+
/**
|
|
202
|
+
* @param {Parameters<Block["delete"]>[0]} [deletion]
|
|
203
|
+
* @param {ReturnType<TextBehavior["getSelection"]>} [selection]
|
|
204
|
+
* @public
|
|
205
|
+
*/
|
|
206
|
+
public delete(deletion?: Parameters<Block["delete"]>[0], selection?: ReturnType<TextBehavior["getSelection"]>): void;
|
|
207
|
+
/**
|
|
208
|
+
* @param {import('loro-crdt').Delta<string>[]} data
|
|
209
|
+
* @public
|
|
210
|
+
*/
|
|
211
|
+
public applyDelta(data?: import("loro-crdt").Delta<string>[]): void;
|
|
101
212
|
/**
|
|
102
213
|
* @param {Parameters<Block["split"]>[0]} [options]
|
|
103
214
|
* @param {ReturnType<TextBehavior["getSelection"]>} [selection]
|
|
104
215
|
* @returns {ReturnType<Block["split"]>}
|
|
216
|
+
* @public
|
|
105
217
|
*/
|
|
106
|
-
split(options?: Parameters<Block["split"]>[0], selection?: ReturnType<TextBehavior["getSelection"]>): ReturnType<Block["split"]>;
|
|
107
|
-
/**
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
218
|
+
public split(options?: Parameters<Block["split"]>[0], selection?: ReturnType<TextBehavior["getSelection"]>): ReturnType<Block["split"]>;
|
|
219
|
+
/**
|
|
220
|
+
* @param {string} markName
|
|
221
|
+
* @param {any} value
|
|
222
|
+
* @param {Pick<NonNullable<ReturnType<TextBehavior["getSelection"]>>, 'from' | 'to' | 'isCollapsed'> | null} sel
|
|
223
|
+
* @public
|
|
224
|
+
*/
|
|
225
|
+
public applyMark(markName: string, value: any, sel: Pick<NonNullable<ReturnType<TextBehavior["getSelection"]>>, "from" | "to" | "isCollapsed"> | null): void;
|
|
226
|
+
/**
|
|
227
|
+
* @param {string} markName
|
|
228
|
+
* @param {Pick<NonNullable<ReturnType<TextBehavior["getSelection"]>>, 'from' | 'to' | 'isCollapsed'> | null} sel
|
|
229
|
+
* @public
|
|
230
|
+
*/
|
|
231
|
+
public removeMark(markName: string, sel: Pick<NonNullable<ReturnType<TextBehavior["getSelection"]>>, "from" | "to" | "isCollapsed"> | null): void;
|
|
232
|
+
/**
|
|
233
|
+
* @param {string} markName
|
|
234
|
+
* @param {Pick<NonNullable<ReturnType<TextBehavior["getSelection"]>>, 'from' | 'to' | 'isCollapsed'> | null} sel
|
|
235
|
+
* @public
|
|
236
|
+
*/
|
|
237
|
+
public isMarkActive(markName: string, sel: Pick<NonNullable<ReturnType<TextBehavior["getSelection"]>>, "from" | "to" | "isCollapsed"> | null): boolean;
|
|
238
|
+
/**
|
|
239
|
+
* @param {string} markName
|
|
240
|
+
* @param {any} value
|
|
241
|
+
* @param {Pick<NonNullable<ReturnType<TextBehavior["getSelection"]>>, 'from' | 'to' | 'isCollapsed'> | null} sel
|
|
242
|
+
* @public
|
|
243
|
+
*/
|
|
244
|
+
public toggleMark(markName: string, value: any, sel: Pick<NonNullable<ReturnType<TextBehavior["getSelection"]>>, "from" | "to" | "isCollapsed"> | null): void;
|
|
245
|
+
/** @param {{ rawBreaks?: boolean }} [options] see {@link deltaToMarkdown}
|
|
246
|
+
* @public
|
|
247
|
+
* @returns {string} */
|
|
248
|
+
public toMarkdown(options?: {
|
|
249
|
+
rawBreaks?: boolean;
|
|
250
|
+
}): string;
|
|
117
251
|
/**
|
|
118
252
|
* Converts the text delta to a Slate-like JSON format.
|
|
119
253
|
* @returns {{text: string, [mark: string]: any}[]}
|
|
254
|
+
* @public
|
|
120
255
|
*/
|
|
121
|
-
toJSON(): {
|
|
256
|
+
public toJSON(): {
|
|
122
257
|
text: string;
|
|
123
258
|
[mark: string]: any;
|
|
124
259
|
}[];
|
|
125
260
|
/**
|
|
126
261
|
* Serializes a (partial) range of this block's text as a PasteBlock.
|
|
127
|
-
* @param {{ from?: number, to?: number, partial?: 'start'|'end'|'both'|false, props?: Record<string,any> }} [context]
|
|
128
|
-
* @returns {import('
|
|
262
|
+
* @param {{ from?: number, to?: number | null, partial?: 'start'|'end'|'both'|false, props?: Record<string,any> }} [context]
|
|
263
|
+
* @returns {import('../../utils/extensions.js').PasteBlock}
|
|
264
|
+
* @public
|
|
129
265
|
*/
|
|
130
|
-
toClipboardBlock({ from, to, partial, props }?: {
|
|
266
|
+
public toClipboardBlock({ from, to, partial, props }?: {
|
|
131
267
|
from?: number;
|
|
132
|
-
to?: number;
|
|
268
|
+
to?: number | null;
|
|
133
269
|
partial?: "start" | "end" | "both" | false;
|
|
134
270
|
props?: Record<string, any>;
|
|
135
|
-
}):
|
|
136
|
-
/**
|
|
137
|
-
|
|
271
|
+
}): import("../../utils/extensions.js").PasteBlock;
|
|
272
|
+
/**
|
|
273
|
+
* @param {Block} other
|
|
274
|
+
* @public
|
|
275
|
+
*/
|
|
276
|
+
public absorbs(other: Block): boolean;
|
|
277
|
+
#private;
|
|
138
278
|
}
|
|
139
279
|
export type TextNode = NabuNode<{
|
|
140
280
|
type: "paragraph";
|