@aionbuilders/nabu 0.1.0-alpha.0 → 0.1.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -1
- package/dist/behaviors/text/index.d.ts +1 -1
- package/dist/behaviors/text/index.js +1 -1
- package/dist/behaviors/text/rich-text.extension.js +96 -30
- package/dist/behaviors/text/text.behavior.svelte.d.ts +19 -0
- package/dist/behaviors/text/text.behavior.svelte.js +64 -2
- package/dist/blocks/Block.svelte +3 -3
- package/dist/blocks/BlockGap.svelte +55 -0
- package/dist/blocks/BlockGap.svelte.d.ts +11 -0
- package/dist/blocks/Nabu.svelte +8 -0
- package/dist/blocks/block.extension.d.ts +2 -0
- package/dist/blocks/block.extension.js +32 -0
- package/dist/blocks/block.svelte.d.ts +41 -9
- package/dist/blocks/block.svelte.js +55 -18
- package/dist/blocks/container.utils.d.ts +54 -4
- package/dist/blocks/container.utils.js +211 -8
- package/dist/blocks/dialogue/Dialogue.svelte +46 -0
- package/dist/blocks/dialogue/Dialogue.svelte.d.ts +11 -0
- package/dist/blocks/dialogue/dialogue.svelte.d.ts +41 -0
- package/dist/blocks/dialogue/dialogue.svelte.js +87 -0
- package/dist/blocks/dialogue/hooks/onBeforeInput.hook.d.ts +3 -0
- package/dist/blocks/dialogue/hooks/onBeforeInput.hook.js +52 -0
- package/dist/blocks/dialogue/index.d.ts +7 -0
- package/dist/blocks/dialogue/index.js +47 -0
- package/dist/blocks/heading/Heading.svelte +13 -9
- package/dist/blocks/heading/heading.svelte.d.ts +40 -4
- package/dist/blocks/heading/heading.svelte.js +60 -4
- package/dist/blocks/heading/hooks/onBeforeInput.hook.js +1 -1
- package/dist/blocks/heading/index.d.ts +2 -2
- package/dist/blocks/heading/index.js +11 -7
- package/dist/blocks/index.d.ts +7 -4
- package/dist/blocks/index.js +7 -4
- package/dist/blocks/list/ListItem.svelte +6 -2
- package/dist/blocks/list/hooks/onBeforeInput.hook.d.ts +3 -0
- package/dist/blocks/list/hooks/onBeforeInput.hook.js +77 -0
- package/dist/blocks/list/index.d.ts +2 -2
- package/dist/blocks/list/index.js +17 -3
- package/dist/blocks/list/list-item.svelte.d.ts +59 -6
- package/dist/blocks/list/list-item.svelte.js +157 -89
- package/dist/blocks/list/list.behavior.svelte.d.ts +1 -0
- package/dist/blocks/list/list.behavior.svelte.js +5 -4
- package/dist/blocks/list/list.svelte.d.ts +60 -7
- package/dist/blocks/list/list.svelte.js +116 -15
- package/dist/blocks/megablock.svelte.d.ts +30 -5
- package/dist/blocks/megablock.svelte.js +113 -17
- package/dist/blocks/nabu.svelte.d.ts +44 -6
- package/dist/blocks/nabu.svelte.js +397 -15
- package/dist/blocks/paragraph/Paragraph.svelte +12 -16
- package/dist/blocks/paragraph/Paragraph.svelte.d.ts +2 -2
- package/dist/blocks/paragraph/index.d.ts +2 -2
- package/dist/blocks/paragraph/index.js +29 -8
- package/dist/blocks/paragraph/paragraph.svelte.d.ts +33 -5
- package/dist/blocks/paragraph/paragraph.svelte.js +55 -3
- package/dist/blocks/selection.svelte.d.ts +6 -5
- package/dist/blocks/selection.svelte.js +209 -18
- package/dist/blocks/variable.svelte.d.ts +47 -0
- package/dist/blocks/variable.svelte.js +51 -0
- package/dist/blocks/zone/TemplateEditor.svelte +308 -0
- package/dist/blocks/zone/TemplateEditor.svelte.d.ts +11 -0
- package/dist/blocks/zone/Zone.svelte +272 -0
- package/dist/blocks/zone/Zone.svelte.d.ts +11 -0
- package/dist/blocks/zone/ZoneEditor copy.svelte +118 -0
- package/dist/blocks/zone/ZoneEditor copy.svelte.d.ts +11 -0
- package/dist/blocks/zone/ZoneEditor.svelte +289 -0
- package/dist/blocks/zone/ZoneEditor.svelte.d.ts +11 -0
- package/dist/blocks/zone/ZoneTemplatesList.svelte +188 -0
- package/dist/blocks/zone/ZoneTemplatesList.svelte.d.ts +11 -0
- package/dist/blocks/zone/hooks/onBeforeInput.hook.d.ts +3 -0
- package/dist/blocks/zone/hooks/onBeforeInput.hook.js +30 -0
- package/dist/blocks/zone/index.d.ts +2 -0
- package/dist/blocks/zone/index.js +2 -0
- package/dist/blocks/zone/zone.extension.d.ts +2 -0
- package/dist/blocks/zone/zone.extension.js +227 -0
- package/dist/blocks/zone/zone.svelte.d.ts +222 -0
- package/dist/blocks/zone/zone.svelte.js +620 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -1
- package/dist/nabu-theme.css +92 -0
- package/dist/overlays/context/Context.svelte +179 -0
- package/dist/overlays/context/Context.svelte.d.ts +16 -0
- package/dist/overlays/context/collect.d.ts +17 -0
- package/dist/overlays/context/collect.js +33 -0
- package/dist/overlays/context/context.extension.d.ts +2 -0
- package/dist/overlays/context/context.extension.js +8 -0
- package/dist/overlays/context/context.svelte.d.ts +81 -0
- package/dist/overlays/context/context.svelte.js +159 -0
- package/dist/overlays/context/index.d.ts +3 -0
- package/dist/overlays/context/index.js +3 -0
- package/dist/paste/html.paste.d.ts +12 -0
- package/dist/paste/html.paste.js +192 -0
- package/dist/paste/index.d.ts +4 -0
- package/dist/paste/index.js +4 -0
- package/dist/paste/markdown.paste.d.ts +12 -0
- package/dist/paste/markdown.paste.js +140 -0
- package/dist/paste/nabu.paste.d.ts +2 -0
- package/dist/paste/nabu.paste.js +20 -0
- package/dist/paste/plain-text.paste.d.ts +8 -0
- package/dist/paste/plain-text.paste.js +42 -0
- package/dist/persistence/indexeddb.d.ts +19 -0
- package/dist/persistence/indexeddb.js +71 -0
- package/dist/persistence/persistence.d.ts +48 -0
- package/dist/persistence/persistence.js +80 -0
- package/dist/presets.d.ts +38 -0
- package/dist/presets.js +86 -0
- package/dist/utils/extensions.d.ts +63 -0
- package/dist/utils/extensions.js +33 -0
- package/dist/utils/selection.svelte.js +0 -5
- package/package.json +14 -3
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { Extension } from '../../utils/extensions.js';
|
|
2
|
+
import { ZoneBlock } from './zone.svelte.js';
|
|
3
|
+
import ZoneComponent from './Zone.svelte';
|
|
4
|
+
import { findLCA, findDirectChildOf } from '../container.utils.js';
|
|
5
|
+
import { onBeforeInput as zoneInsertTrigger } from './hooks/onBeforeInput.hook.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @import { Nabu } from '../nabu.svelte.js';
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* onBeforeInput hook — intercepts deleteContentBackward at the start of the
|
|
13
|
+
* first content block inside a Zone, before TextBehavior's findBackward() can
|
|
14
|
+
* traverse up and out of the Zone boundary.
|
|
15
|
+
*
|
|
16
|
+
* Fires BEFORE block routing in Nabu.dispatchEventToSelection.
|
|
17
|
+
*
|
|
18
|
+
* @param {Nabu} nabu
|
|
19
|
+
* @param {InputEvent} event
|
|
20
|
+
* @param {import('../block.svelte.js').Block} block
|
|
21
|
+
*/
|
|
22
|
+
function zoneBackspaceGuard(nabu, event, block) {
|
|
23
|
+
if (event.inputType !== 'deleteContentBackward') return;
|
|
24
|
+
|
|
25
|
+
// Use the block's model selection (TextBehavior.selection) rather than the raw
|
|
26
|
+
// DOM startOffset, which varies by text node structure and is unreliable here.
|
|
27
|
+
const blockSel = block.selection;
|
|
28
|
+
if (!blockSel || !blockSel.isCollapsed || blockSel.from !== 0) return;
|
|
29
|
+
|
|
30
|
+
// Walk up from block. If every ancestor up to a Zone is the first child (index 0),
|
|
31
|
+
// the cursor is at the very start of the Zone — block the event.
|
|
32
|
+
// Stop early if a non-first-child is found (there's something to merge with inside).
|
|
33
|
+
let current = block;
|
|
34
|
+
while (current && current.parent) {
|
|
35
|
+
if (current.parent.type === 'zone') {
|
|
36
|
+
if (current.index === 0) return nabu.BREAK;
|
|
37
|
+
break; // Has a previous sibling inside the zone — allow normal merge
|
|
38
|
+
}
|
|
39
|
+
if (current.index !== 0) break; // Has a previous sibling in a sub-container
|
|
40
|
+
current = current.parent;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const ZoneExtension = new Extension('zone', {
|
|
45
|
+
block: ZoneBlock,
|
|
46
|
+
component: ZoneComponent,
|
|
47
|
+
|
|
48
|
+
hooks: {
|
|
49
|
+
onBeforeInput: (nabu, event, block) => {
|
|
50
|
+
return zoneBackspaceGuard(nabu, event, block) ?? zoneInsertTrigger(nabu, event, block);
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
actions: {
|
|
55
|
+
/**
|
|
56
|
+
* Move all children of the Zone to its parent position, then delete the Zone.
|
|
57
|
+
* @param {Nabu} nabu
|
|
58
|
+
* @param {{ zoneId: string }} data
|
|
59
|
+
*/
|
|
60
|
+
'zone:unwrap': (nabu, { zoneId }) => {
|
|
61
|
+
const zone = nabu.blocks.get(zoneId);
|
|
62
|
+
if (!zone || zone.type !== 'zone') return;
|
|
63
|
+
|
|
64
|
+
const parentNode = zone.node.parent();
|
|
65
|
+
const parentId = parentNode ? parentNode.id : undefined;
|
|
66
|
+
const zoneIndex = zone.node.index();
|
|
67
|
+
|
|
68
|
+
// Reverse so that when each child is inserted at zoneIndex, the original
|
|
69
|
+
// order is preserved (each insert pushes the previous one down).
|
|
70
|
+
// @ts-ignore — zone.children comes from MegaBlock
|
|
71
|
+
const children = /** @type {import('../block.svelte.js').Block[]} */ ([...zone.children]);
|
|
72
|
+
children.reverse().forEach(child => {
|
|
73
|
+
nabu.tree.move(child.node.id, parentId, zoneIndex);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
nabu.tree.delete(zone.node.id);
|
|
77
|
+
nabu.commit();
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @param {Nabu} nabu
|
|
82
|
+
* @param {{ zoneId: string, status: string }} data
|
|
83
|
+
*/
|
|
84
|
+
'zone:setStatus': (nabu, { zoneId, status }) => {
|
|
85
|
+
const zone = /** @type {import('./zone.svelte.js').ZoneBlock | undefined} */ (nabu.blocks.get(zoneId));
|
|
86
|
+
if (!zone || zone.type !== 'zone') return;
|
|
87
|
+
zone.status = status;
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @param {Nabu} nabu
|
|
92
|
+
* @param {{ zoneId: string, text: string }} data
|
|
93
|
+
*/
|
|
94
|
+
'zone:setSynopsis': (nabu, { zoneId, text }) => {
|
|
95
|
+
const zone = /** @type {import('./zone.svelte.js').ZoneBlock | undefined} */ (nabu.blocks.get(zoneId));
|
|
96
|
+
if (!zone || zone.type !== 'zone') return;
|
|
97
|
+
zone.setSynopsis(text);
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @param {Nabu} nabu
|
|
102
|
+
* @param {{ zoneId: string, target: number | null }} data
|
|
103
|
+
*/
|
|
104
|
+
'zone:setWordCountTarget': (nabu, { zoneId, target }) => {
|
|
105
|
+
const zone = /** @type {import('./zone.svelte.js').ZoneBlock | undefined} */ (nabu.blocks.get(zoneId));
|
|
106
|
+
if (!zone || zone.type !== 'zone') return;
|
|
107
|
+
zone.wordCountTarget = target;
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Insert a new empty zone (with one paragraph) after the anchor block's
|
|
112
|
+
* root-level ancestor. Moves the cursor into the new paragraph.
|
|
113
|
+
* @param {Nabu} nabu
|
|
114
|
+
* @param {{ props?: Object }} [data]
|
|
115
|
+
*/
|
|
116
|
+
'zone:insert': (nabu, data) => {
|
|
117
|
+
const anchor = nabu.selection.anchorBlock;
|
|
118
|
+
if (!anchor) return;
|
|
119
|
+
|
|
120
|
+
// If the cursor is inside a zone, insert there; otherwise insert at root level.
|
|
121
|
+
let nearestZone = anchor.parent;
|
|
122
|
+
while (nearestZone && nearestZone.type !== 'zone') nearestZone = nearestZone.parent;
|
|
123
|
+
|
|
124
|
+
let insertIndex, parentId;
|
|
125
|
+
if (nearestZone) {
|
|
126
|
+
const directChild = findDirectChildOf(anchor, nearestZone);
|
|
127
|
+
insertIndex = (directChild?.index ?? 0) + 1;
|
|
128
|
+
parentId = nearestZone.node.id.toString();
|
|
129
|
+
} else {
|
|
130
|
+
let rootBlock = anchor;
|
|
131
|
+
while (rootBlock.parent) rootBlock = rootBlock.parent;
|
|
132
|
+
insertIndex = (nabu.children.indexOf(rootBlock)) + 1;
|
|
133
|
+
parentId = null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Create zone + paragraph in one transaction
|
|
137
|
+
const zone = ZoneBlock.create(nabu, 'zone', data?.props ?? {}, parentId, insertIndex);
|
|
138
|
+
|
|
139
|
+
const ParagraphClass = nabu.registry.get('paragraph');
|
|
140
|
+
let newParagraph = null;
|
|
141
|
+
if (ParagraphClass) {
|
|
142
|
+
newParagraph = ParagraphClass.create(nabu, 'paragraph', {}, zone.node.id.toString(), 0);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
nabu.commit().then(() => {
|
|
146
|
+
const target = newParagraph ? nabu.blocks.get(newParagraph.id) ?? newParagraph : null;
|
|
147
|
+
if (target) nabu.selection.setCursor(target, 0);
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Wrap the selected blocks in a new zone.
|
|
153
|
+
*
|
|
154
|
+
* - Collapsed / single block: wraps the block's direct child of its
|
|
155
|
+
* nearest non-zone ancestor (or the root-level block).
|
|
156
|
+
* - Multi-block selection: finds the LCA of startBlock/endBlock, resolves
|
|
157
|
+
* their direct children inside that container, and wraps the whole range.
|
|
158
|
+
* - No-op if every candidate is already a zone.
|
|
159
|
+
*
|
|
160
|
+
* @param {Nabu} nabu
|
|
161
|
+
* @param {{ props?: Object }} [data]
|
|
162
|
+
*/
|
|
163
|
+
'zone:wrap': (nabu, data) => {
|
|
164
|
+
const sel = nabu.selection;
|
|
165
|
+
const startBlock = sel.startBlock ?? sel.anchorBlock;
|
|
166
|
+
const endBlock = sel.endBlock ?? sel.focusBlock;
|
|
167
|
+
if (!startBlock) return;
|
|
168
|
+
|
|
169
|
+
const savedOffset = startBlock.behaviors?.get('text')?.selection?.from ?? 0;
|
|
170
|
+
|
|
171
|
+
/** @type {import('../block.svelte.js').Block[]} */
|
|
172
|
+
let toWrap;
|
|
173
|
+
/** @type {string | null} */
|
|
174
|
+
let parentId;
|
|
175
|
+
/** @type {number} */
|
|
176
|
+
let insertIndex;
|
|
177
|
+
|
|
178
|
+
if (!endBlock || startBlock === endBlock || sel.isCollapsed) {
|
|
179
|
+
// ── Single-block path ──────────────────────────────────────────
|
|
180
|
+
// Find direct child of the nearest container (zone or root level).
|
|
181
|
+
// The while loop stops at zone boundaries, so wrapping inside a zone
|
|
182
|
+
// creates a nested zone — which is now intentionally supported.
|
|
183
|
+
let target = startBlock;
|
|
184
|
+
while (target.parent && target.parent.type !== 'zone') {
|
|
185
|
+
target = target.parent;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
toWrap = [target];
|
|
189
|
+
parentId = target.parent ? target.parent.node.id.toString() : null;
|
|
190
|
+
insertIndex = target.index ?? 0;
|
|
191
|
+
} else {
|
|
192
|
+
// ── Multi-block path ───────────────────────────────────────────
|
|
193
|
+
const lca = findLCA(startBlock, endBlock);
|
|
194
|
+
// Container is the LCA block, or nabu itself if blocks are root-level
|
|
195
|
+
const container = lca ?? nabu;
|
|
196
|
+
|
|
197
|
+
const sc = findDirectChildOf(startBlock, container);
|
|
198
|
+
const ec = findDirectChildOf(endBlock, container);
|
|
199
|
+
if (!sc || !ec) return;
|
|
200
|
+
|
|
201
|
+
const containerChildren = /** @type {import('../block.svelte.js').Block[]} */ (
|
|
202
|
+
lca ? /** @type {any} */ (lca).children : nabu.children
|
|
203
|
+
);
|
|
204
|
+
const si = containerChildren.indexOf(sc);
|
|
205
|
+
const ei = containerChildren.indexOf(ec);
|
|
206
|
+
if (si === -1 || ei === -1 || si > ei) return;
|
|
207
|
+
|
|
208
|
+
toWrap = containerChildren.slice(si, ei + 1);
|
|
209
|
+
parentId = lca ? lca.node.id.toString() : null;
|
|
210
|
+
insertIndex = si;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const zone = ZoneBlock.create(nabu, 'zone', data?.props ?? {}, parentId, insertIndex);
|
|
214
|
+
toWrap.forEach((block, i) => nabu.tree.move(block.node.id, zone.node.id, i));
|
|
215
|
+
|
|
216
|
+
const zoneId = zone.id;
|
|
217
|
+
nabu.commit().then(() => {
|
|
218
|
+
const fresh = nabu.blocks.get(startBlock.id);
|
|
219
|
+
if (fresh) nabu.selection.setCursor(fresh, savedOffset);
|
|
220
|
+
if (/** @type {any} */ (data)?.focusTitle) {
|
|
221
|
+
const freshZone = /** @type {import('./zone.svelte.js').ZoneBlock | undefined} */ (nabu.blocks.get(zoneId));
|
|
222
|
+
freshZone?.focusTitle();
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
});
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
export function formatTemplateLabel(formatString: any, index: any, title?: string): any;
|
|
2
|
+
/**
|
|
3
|
+
* @import { Nabu, NabuNode } from '../nabu.svelte.js';
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {NabuNode<{type: "zone", synopsis: LoroText, status: string, wordCountTarget: number | null, title: string, template: string | null}>} ZoneNode
|
|
7
|
+
*/
|
|
8
|
+
export class ZoneBlock extends MegaBlock {
|
|
9
|
+
/**
|
|
10
|
+
* @param {Nabu} nabu
|
|
11
|
+
* @param {string} type
|
|
12
|
+
* @param {Object} [props]
|
|
13
|
+
* @param {string | null} [parentId]
|
|
14
|
+
* @param {number | null} [index]
|
|
15
|
+
*/
|
|
16
|
+
static create(nabu: Nabu, type: string, props?: Object, parentId?: string | null, index?: number | null): ZoneBlock;
|
|
17
|
+
/** @param {Nabu} nabu @param {ZoneNode} node */
|
|
18
|
+
constructor(nabu: Nabu, node: ZoneNode);
|
|
19
|
+
synopsisContainer: LoroText;
|
|
20
|
+
/** @type {string} */
|
|
21
|
+
_status: string;
|
|
22
|
+
/** @type {number | null} */
|
|
23
|
+
_wordCountTarget: number | null;
|
|
24
|
+
/** @type {string} */
|
|
25
|
+
_title: string;
|
|
26
|
+
/** @type {string | null} */
|
|
27
|
+
_template: string | null;
|
|
28
|
+
/** @type {string} */
|
|
29
|
+
synopsisText: string;
|
|
30
|
+
zones: Zones;
|
|
31
|
+
/** @type {Counter?} */
|
|
32
|
+
counter: Counter | null;
|
|
33
|
+
/** Incremented each time the title input should be focused. */
|
|
34
|
+
_focusTitleTick: number;
|
|
35
|
+
wordCount: number;
|
|
36
|
+
set status(value: string);
|
|
37
|
+
get status(): string;
|
|
38
|
+
set wordCountTarget(value: number | null);
|
|
39
|
+
get wordCountTarget(): number | null;
|
|
40
|
+
set title(value: string);
|
|
41
|
+
get title(): string;
|
|
42
|
+
set template(value: string | null);
|
|
43
|
+
get template(): string | null;
|
|
44
|
+
focusTitle(): void;
|
|
45
|
+
/** Returns the LoroText container for direct CRDT mutation. */
|
|
46
|
+
get synopsis(): LoroText;
|
|
47
|
+
parentZones: ZoneBlock[];
|
|
48
|
+
parentZone: ZoneBlock;
|
|
49
|
+
count: number;
|
|
50
|
+
/**
|
|
51
|
+
* Replace the synopsis text entirely.
|
|
52
|
+
* @param {string} text
|
|
53
|
+
*/
|
|
54
|
+
setSynopsis(text: string): void;
|
|
55
|
+
get clipboardProps(): {
|
|
56
|
+
status: string;
|
|
57
|
+
wordCountTarget: number | null;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Called via ascend("onSplit") when a child block's Enter key fires.
|
|
61
|
+
* Creates a new paragraph inside this Zone, never outside it.
|
|
62
|
+
*
|
|
63
|
+
* @param {Event | null} event
|
|
64
|
+
* @param {{ from: import('../block.svelte.js').Block, offset: number, delta: import('loro-crdt').Delta<string>[] }} data
|
|
65
|
+
*/
|
|
66
|
+
onSplit(event: Event | null, data: {
|
|
67
|
+
from: import("../block.svelte.js").Block;
|
|
68
|
+
offset: number;
|
|
69
|
+
delta: import("loro-crdt").Delta<string>[];
|
|
70
|
+
}): {
|
|
71
|
+
block: import("../block.svelte.js").Block;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export class Zones {
|
|
75
|
+
/** @param {Nabu} nabu */
|
|
76
|
+
static get(nabu: Nabu): Zones;
|
|
77
|
+
/** @param {Nabu} nabu */
|
|
78
|
+
constructor(nabu: Nabu);
|
|
79
|
+
templates: Templates;
|
|
80
|
+
/**
|
|
81
|
+
* Flat list of all ZoneBlocks in document order (DFS traversal).
|
|
82
|
+
* @type {ZoneBlock[]}
|
|
83
|
+
*/
|
|
84
|
+
all: ZoneBlock[];
|
|
85
|
+
/**
|
|
86
|
+
* Total number of zones.
|
|
87
|
+
*/
|
|
88
|
+
count: number;
|
|
89
|
+
/**
|
|
90
|
+
* Hierarchical zone tree — zones nested inside other zones.
|
|
91
|
+
* @type {Array<{zone: ZoneBlock, children: any[]}>}
|
|
92
|
+
*/
|
|
93
|
+
tree: Array<{
|
|
94
|
+
zone: ZoneBlock;
|
|
95
|
+
children: any[];
|
|
96
|
+
}>;
|
|
97
|
+
/**
|
|
98
|
+
* The innermost zone containing the current cursor, or null if outside any zone.
|
|
99
|
+
* @type {ZoneBlock | null}
|
|
100
|
+
*/
|
|
101
|
+
current: ZoneBlock | null;
|
|
102
|
+
/**
|
|
103
|
+
* Index of the current zone in `all` (-1 if cursor is outside any zone).
|
|
104
|
+
*/
|
|
105
|
+
currentIndex: number;
|
|
106
|
+
/**
|
|
107
|
+
* Navigate to the next zone (moves cursor to its first text position).
|
|
108
|
+
*/
|
|
109
|
+
goToNext(): void;
|
|
110
|
+
/**
|
|
111
|
+
* Navigate to the previous zone.
|
|
112
|
+
*/
|
|
113
|
+
goToPrevious(): void;
|
|
114
|
+
counters: Counters;
|
|
115
|
+
#private;
|
|
116
|
+
}
|
|
117
|
+
/** @extends SvelteMap<string, Template> */
|
|
118
|
+
export class Templates extends SvelteMap<string, Template> {
|
|
119
|
+
/** @param {Nabu} nabu @param {Zones} zones */
|
|
120
|
+
constructor(nabu: Nabu, zones: Zones);
|
|
121
|
+
nabu: Nabu;
|
|
122
|
+
zones: Zones;
|
|
123
|
+
map: import("loro-crdt").LoroMap<Record<string, unknown>>;
|
|
124
|
+
/** @param {string} id @param {TemplateData} [data] */
|
|
125
|
+
"new"(id: string, data?: TemplateData): Template;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* @typedef {Object} TemplateData
|
|
129
|
+
* @property {string} id - Unique identifier for the template.
|
|
130
|
+
* @property {string} label - The template's display name.
|
|
131
|
+
* @property {{
|
|
132
|
+
* scope: "root" | "parent",
|
|
133
|
+
* } | boolean | null | undefined} [counter]
|
|
134
|
+
*/
|
|
135
|
+
export class Template {
|
|
136
|
+
/** @param {TemplateData} init @param {Templates} templates */
|
|
137
|
+
constructor(init: TemplateData, templates: Templates);
|
|
138
|
+
templates: Templates;
|
|
139
|
+
id: string;
|
|
140
|
+
_label: string;
|
|
141
|
+
/** @type {TemplateData['counter']} */
|
|
142
|
+
_counter: TemplateData["counter"];
|
|
143
|
+
set label(value: string);
|
|
144
|
+
get label(): string;
|
|
145
|
+
renderLabel(index: any, title?: string): any;
|
|
146
|
+
/** @param {TemplateData['counter']} value */
|
|
147
|
+
set counter(value: TemplateData["counter"]);
|
|
148
|
+
/**
|
|
149
|
+
* @returns {{scope: "root" | "parent"} | null | undefined}
|
|
150
|
+
*/
|
|
151
|
+
get counter(): {
|
|
152
|
+
scope: "root" | "parent";
|
|
153
|
+
} | null | undefined;
|
|
154
|
+
/** @param {ZoneBlock} zone */
|
|
155
|
+
getCounter(zone: ZoneBlock): Counter | null | undefined;
|
|
156
|
+
/** @param {function(TemplateData): TemplateData} callback */
|
|
157
|
+
update(callback: (arg0: TemplateData) => TemplateData): void;
|
|
158
|
+
}
|
|
159
|
+
export class Counters {
|
|
160
|
+
/** @type {SvelteMap<string, Counter>} */
|
|
161
|
+
counters: SvelteMap<string, Counter>;
|
|
162
|
+
/** @type {SvelteMap<ZoneBlock, string>} */
|
|
163
|
+
index: SvelteMap<ZoneBlock, string>;
|
|
164
|
+
/**
|
|
165
|
+
* @param {ZoneBlock} zone
|
|
166
|
+
*/
|
|
167
|
+
unsubscribe(zone: ZoneBlock): void;
|
|
168
|
+
/**
|
|
169
|
+
* @param {ZoneBlock} zone
|
|
170
|
+
* @param {"root"|string} scope
|
|
171
|
+
* @param {string} name
|
|
172
|
+
*/
|
|
173
|
+
subscribe(zone: ZoneBlock, scope: "root" | string, name: string): Counter | undefined;
|
|
174
|
+
}
|
|
175
|
+
export type ZoneNode = NabuNode<{
|
|
176
|
+
type: "zone";
|
|
177
|
+
synopsis: LoroText;
|
|
178
|
+
status: string;
|
|
179
|
+
wordCountTarget: number | null;
|
|
180
|
+
title: string;
|
|
181
|
+
template: string | null;
|
|
182
|
+
}>;
|
|
183
|
+
export type TemplateData = {
|
|
184
|
+
/**
|
|
185
|
+
* - Unique identifier for the template.
|
|
186
|
+
*/
|
|
187
|
+
id: string;
|
|
188
|
+
/**
|
|
189
|
+
* - The template's display name.
|
|
190
|
+
*/
|
|
191
|
+
label: string;
|
|
192
|
+
counter?: {
|
|
193
|
+
scope: "root" | "parent";
|
|
194
|
+
} | boolean | null | undefined;
|
|
195
|
+
};
|
|
196
|
+
import { MegaBlock } from '../megablock.svelte.js';
|
|
197
|
+
import { LoroText } from 'loro-crdt';
|
|
198
|
+
/**
|
|
199
|
+
* @extends SvelteSet<ZoneBlock>
|
|
200
|
+
*/
|
|
201
|
+
declare class Counter extends SvelteSet<ZoneBlock> {
|
|
202
|
+
/**
|
|
203
|
+
* @param {"root"|string} scope
|
|
204
|
+
* @param {string} name
|
|
205
|
+
*/
|
|
206
|
+
constructor(scope: "root" | string, name: string);
|
|
207
|
+
scope: string;
|
|
208
|
+
name: string;
|
|
209
|
+
watcher: () => void;
|
|
210
|
+
unwatch: () => void;
|
|
211
|
+
zones: ZoneBlock[];
|
|
212
|
+
/**
|
|
213
|
+
* @param {ZoneBlock} targetZone
|
|
214
|
+
* @returns {number}
|
|
215
|
+
*/
|
|
216
|
+
getIndex(targetZone: ZoneBlock): number;
|
|
217
|
+
}
|
|
218
|
+
import type { Nabu } from '../nabu.svelte.js';
|
|
219
|
+
import { SvelteMap } from 'svelte/reactivity';
|
|
220
|
+
import type { NabuNode } from '../nabu.svelte.js';
|
|
221
|
+
import { SvelteSet } from 'svelte/reactivity';
|
|
222
|
+
export {};
|