@owomark/core 0.1.5 → 0.1.7
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 +30 -10
- package/dist/.build-manifest.json +130 -0
- package/dist/browser.d.ts +66 -0
- package/dist/browser.js +396 -0
- package/dist/chunk-3KTK7CSS.js +82 -0
- package/dist/chunk-5JNL3LHV.js +215 -0
- package/dist/chunk-ASRCHEFF.js +0 -0
- package/dist/chunk-BKJCBEI7.js +397 -0
- package/dist/chunk-CJSBFWKS.js +549 -0
- package/dist/chunk-GA5EFGSZ.js +5820 -0
- package/dist/chunk-OOH46GIF.js +95 -0
- package/dist/chunk-ROJILHRQ.js +192 -0
- package/dist/chunk-WFPUIPWU.js +34 -0
- package/dist/chunk-WXVKSKP3.js +191 -0
- package/dist/chunk-YZYJIXGO.js +0 -0
- package/dist/editor-core-DbPhn6aI.d.ts +249 -0
- package/dist/index.d.ts +77 -86
- package/dist/index.js +161 -245
- package/dist/internal/dom-adapter.d.ts +37 -1
- package/dist/internal/dom-adapter.js +9 -2
- package/dist/public-zMo7BR9l.d.ts +469 -0
- package/dist/registry-C849sxCo.d.ts +74 -0
- package/dist/semantic/components/index.d.ts +9 -0
- package/dist/semantic/components/index.js +11 -0
- package/dist/semantic/editor/index.d.ts +9 -0
- package/dist/semantic/editor/index.js +13 -0
- package/dist/semantic/index.d.ts +7 -0
- package/dist/semantic/index.js +106 -0
- package/dist/semantic/runtime/index.d.ts +9 -0
- package/dist/semantic/runtime/index.js +13 -0
- package/dist/semantic/shared/index.d.ts +10 -0
- package/dist/semantic/shared/index.js +17 -0
- package/dist/semantic/syntax/index.d.ts +151 -0
- package/dist/semantic/syntax/index.js +63 -0
- package/dist/types-DMqYF6Zn.d.ts +83 -0
- package/package.json +29 -1
- package/dist/chunk-TRLKIMRD.js +0 -3227
- package/dist/dom-adapter-CTSJe5Uo.d.ts +0 -469
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { a as OwoMarkDocument, O as OwoMarkSelection, V as VirtualSelection, C as CompositionState, B as BlockType, b as BlockContext, c as BlockInsertType, d as BlockContextListener } from './public-zMo7BR9l.js';
|
|
2
|
+
|
|
3
|
+
type CoreSelectionSnapshot = {
|
|
4
|
+
linear: OwoMarkSelection | null;
|
|
5
|
+
virtual: VirtualSelection | null;
|
|
6
|
+
};
|
|
7
|
+
type CoreStateSnapshot = {
|
|
8
|
+
markdown: string;
|
|
9
|
+
document: OwoMarkDocument;
|
|
10
|
+
selection: CoreSelectionSnapshot;
|
|
11
|
+
composition: CompositionState;
|
|
12
|
+
};
|
|
13
|
+
type BeforeInputIntent = {
|
|
14
|
+
inputType: string;
|
|
15
|
+
data: string | null;
|
|
16
|
+
};
|
|
17
|
+
type KeyDownIntent = {
|
|
18
|
+
key: string;
|
|
19
|
+
ctrlKey: boolean;
|
|
20
|
+
metaKey: boolean;
|
|
21
|
+
altKey: boolean;
|
|
22
|
+
shiftKey: boolean;
|
|
23
|
+
};
|
|
24
|
+
type PasteIntent = {
|
|
25
|
+
text: string;
|
|
26
|
+
};
|
|
27
|
+
type CoreApplyAction = 'handled' | 'allow-native' | 'composition-sync';
|
|
28
|
+
type CoreApplyResult = {
|
|
29
|
+
action: CoreApplyAction;
|
|
30
|
+
snapshot: CoreStateSnapshot;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Structural Tab / Shift+Tab handling for Markdown containers.
|
|
35
|
+
* Code fences, blockquotes, and list items are resolved here so EditorCore
|
|
36
|
+
* only dispatches the intent and keeps its plain-text fallback for
|
|
37
|
+
* out-of-scope paragraphs.
|
|
38
|
+
*/
|
|
39
|
+
type IndentMode = 'auto' | '2' | '4';
|
|
40
|
+
type IndentOperation = 'code-indent' | 'code-outdent' | 'list-indent' | 'list-outdent' | 'blockquote-indent' | 'blockquote-outdent' | 'noop-illegal-mixed-selection' | 'noop-unsupported-structure';
|
|
41
|
+
type IndentResult = {
|
|
42
|
+
handled: boolean;
|
|
43
|
+
value: string;
|
|
44
|
+
selectionStart: number;
|
|
45
|
+
selectionEnd: number;
|
|
46
|
+
indentSize: number;
|
|
47
|
+
language: string;
|
|
48
|
+
operation?: IndentOperation;
|
|
49
|
+
};
|
|
50
|
+
declare function resolveIndentSize(language: string, mode: IndentMode): number;
|
|
51
|
+
declare function applyMarkdownIndent(params: {
|
|
52
|
+
text: string;
|
|
53
|
+
selectionStart: number;
|
|
54
|
+
selectionEnd: number;
|
|
55
|
+
shiftKey: boolean;
|
|
56
|
+
mode: IndentMode;
|
|
57
|
+
}): IndentResult;
|
|
58
|
+
|
|
59
|
+
type CommandDefinition = {
|
|
60
|
+
/** Unique identifier, e.g. 'side-annotation', 'code-fence' */
|
|
61
|
+
id: string;
|
|
62
|
+
/** Display label for menu, injected from editor descriptors for built-ins. */
|
|
63
|
+
label: string;
|
|
64
|
+
/** Descriptor-backed label key for i18n-capable consumers. */
|
|
65
|
+
labelKey?: string;
|
|
66
|
+
/** Optional description shown in menu subtitle */
|
|
67
|
+
description?: string;
|
|
68
|
+
/** Keywords for substring matching (e.g. ['brace', 'margin', 'note']) */
|
|
69
|
+
keywords?: string[];
|
|
70
|
+
/** Icon identifier or inline SVG string */
|
|
71
|
+
icon?: string;
|
|
72
|
+
/** Keyboard shortcut (informational, binding is separate) */
|
|
73
|
+
shortcut?: string;
|
|
74
|
+
/** Menu category for grouping, injected from editor descriptors for built-ins. */
|
|
75
|
+
category?: string;
|
|
76
|
+
/** Descriptor-backed category key for i18n-capable consumers. */
|
|
77
|
+
categoryKey?: string;
|
|
78
|
+
/** Sort priority within category (lower = higher in list, default 100) */
|
|
79
|
+
priority?: number;
|
|
80
|
+
/** Whether this command appears in the slash menu (default: true) */
|
|
81
|
+
slashMenu?: boolean;
|
|
82
|
+
/** Whether this command is eligible for toolbar display */
|
|
83
|
+
toolbarEligible?: boolean;
|
|
84
|
+
/** Predicate: can this command execute given current editor state? */
|
|
85
|
+
canExecute?: (ctx: CommandContext) => boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Execute the command. Supports sync and async.
|
|
88
|
+
* Core awaits the Promise if returned; adapter may show loading indicator.
|
|
89
|
+
*/
|
|
90
|
+
execute: (ctx: CommandContext, payload?: unknown) => void | Promise<void>;
|
|
91
|
+
};
|
|
92
|
+
type CommandContext = {
|
|
93
|
+
/** Current full markdown text (/query already removed when invoked from slash menu) */
|
|
94
|
+
text: string;
|
|
95
|
+
/** Linear selection start offset */
|
|
96
|
+
selectionStart: number;
|
|
97
|
+
/** Linear selection end offset */
|
|
98
|
+
selectionEnd: number;
|
|
99
|
+
/** Low-level: apply a text + selection update to the document (atomic — single undo entry) */
|
|
100
|
+
applyUpdate: (newText: string, selection: {
|
|
101
|
+
anchor: number;
|
|
102
|
+
focus: number;
|
|
103
|
+
}) => void;
|
|
104
|
+
/** Access to current document model (read-only) */
|
|
105
|
+
document: OwoMarkDocument;
|
|
106
|
+
/** Current block type at cursor */
|
|
107
|
+
blockType: BlockType;
|
|
108
|
+
/** Structural depth info for context-aware commands */
|
|
109
|
+
blockDepth: number;
|
|
110
|
+
/**
|
|
111
|
+
* Slash trigger info (only present when invoked from slash menu).
|
|
112
|
+
* Null when invoked via dispatch() or keyboard shortcut.
|
|
113
|
+
*/
|
|
114
|
+
triggerInfo: SlashTriggerInfo | null;
|
|
115
|
+
/** Feature flags from editor config */
|
|
116
|
+
enableSideAnnotation: boolean;
|
|
117
|
+
enableMath: boolean;
|
|
118
|
+
enableComponents: boolean;
|
|
119
|
+
/** Replace the /query trigger text with new content (cursor placed at end) */
|
|
120
|
+
replaceTriggerText: (text: string) => void;
|
|
121
|
+
/** Convert the current block to a different type by replacing its structural prefix */
|
|
122
|
+
turnIntoBlock: (prefix: string) => void;
|
|
123
|
+
/** Insert a new block below the current one */
|
|
124
|
+
insertBlockBelow: (markdown: string) => void;
|
|
125
|
+
/** Replace the current block with a temporary placeholder block and return its stable block ID. */
|
|
126
|
+
insertPlaceholderBlock: (markdown: string) => string | null;
|
|
127
|
+
/** Replace a block by its stable block ID. Returns false if the block no longer exists. */
|
|
128
|
+
replaceBlockById: (blockId: string, markdown: string) => boolean;
|
|
129
|
+
/** Remove a block by its stable block ID. Returns false if the block no longer exists. */
|
|
130
|
+
removeBlockById: (blockId: string) => boolean;
|
|
131
|
+
/** Insert a template with cursor placed at the specified offset within the template */
|
|
132
|
+
insertTemplate: (template: string, cursorOffset: number) => void;
|
|
133
|
+
};
|
|
134
|
+
type SlashTriggerInfo = {
|
|
135
|
+
/** Position of '/' in the document */
|
|
136
|
+
startOffset: number;
|
|
137
|
+
/** Cursor position when command was selected */
|
|
138
|
+
endOffset: number;
|
|
139
|
+
/** Text typed after '/' (e.g. 'side' for '/side') */
|
|
140
|
+
query: string;
|
|
141
|
+
};
|
|
142
|
+
type SlashState = {
|
|
143
|
+
/** Whether the slash menu is currently open */
|
|
144
|
+
active: boolean;
|
|
145
|
+
/** Position of '/' in the document */
|
|
146
|
+
triggerOffset: number;
|
|
147
|
+
/** Characters typed after '/' */
|
|
148
|
+
query: string;
|
|
149
|
+
/** Keyboard-navigated highlight index */
|
|
150
|
+
selectedIndex: number;
|
|
151
|
+
/** registry.search(query) result (readonly — consumers must not mutate) */
|
|
152
|
+
filteredCommands: readonly CommandDefinition[];
|
|
153
|
+
/** True while async command is executing */
|
|
154
|
+
pending: boolean;
|
|
155
|
+
};
|
|
156
|
+
type CommandRegistry = {
|
|
157
|
+
register(def: CommandDefinition): () => void;
|
|
158
|
+
unregister(id: string): void;
|
|
159
|
+
get(id: string): CommandDefinition | undefined;
|
|
160
|
+
getAll(): CommandDefinition[];
|
|
161
|
+
/** Filter commands matching a query string (for slash menu) */
|
|
162
|
+
search(query: string): CommandDefinition[];
|
|
163
|
+
};
|
|
164
|
+
type SlashStateListener = (state: SlashState) => void;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Pure logic editor core. Owns document, history, selection, composition,
|
|
168
|
+
* and input interpretation. No DOM dependency.
|
|
169
|
+
*
|
|
170
|
+
* Adapters (React / Vanilla) call Core input methods and subscribe to
|
|
171
|
+
* state changes. Core never reads or writes DOM.
|
|
172
|
+
*/
|
|
173
|
+
|
|
174
|
+
/** Callback for sovereign mode: View layer subscribes to Model changes. */
|
|
175
|
+
type DocumentChangeCallback = (doc: OwoMarkDocument, selection: VirtualSelection) => void;
|
|
176
|
+
type OwoMarkCore = {
|
|
177
|
+
getSnapshot(): CoreStateSnapshot;
|
|
178
|
+
getMarkdown(): string;
|
|
179
|
+
getSelection(): OwoMarkSelection | null;
|
|
180
|
+
getDocument(): OwoMarkDocument;
|
|
181
|
+
getVirtualSelection(): VirtualSelection | null;
|
|
182
|
+
getComposition(): CompositionState;
|
|
183
|
+
setMarkdown(markdown: string): void;
|
|
184
|
+
replaceMarkdown(markdown: string, selection: OwoMarkSelection): void;
|
|
185
|
+
dispatch(command: string, payload?: unknown): void;
|
|
186
|
+
setIndentMode(mode: IndentMode): void;
|
|
187
|
+
setEnableSideAnnotation(enabled: boolean): void;
|
|
188
|
+
setEnableMath(enabled: boolean): void;
|
|
189
|
+
setEnableComponents(enabled: boolean): void;
|
|
190
|
+
/** Execute a command by its id (for toolbar / external callers). */
|
|
191
|
+
executeCommandById(id: string, payload?: unknown): void;
|
|
192
|
+
/**
|
|
193
|
+
* Apply a document update from an external source (e.g. DOM sync after
|
|
194
|
+
* unknown inputType or composition end). Core reconciles, updates state,
|
|
195
|
+
* and emits changes.
|
|
196
|
+
*/
|
|
197
|
+
syncText(text: string, selection: OwoMarkSelection | null): void;
|
|
198
|
+
applyBeforeInput(intent: BeforeInputIntent, selection: OwoMarkSelection | null): CoreApplyResult;
|
|
199
|
+
applyKeyDown(intent: KeyDownIntent, selection: OwoMarkSelection | null): CoreApplyResult;
|
|
200
|
+
applyPaste(intent: PasteIntent, selection: OwoMarkSelection | null): CoreApplyResult;
|
|
201
|
+
handleCompositionStart(selection: OwoMarkSelection | null): void;
|
|
202
|
+
handleCompositionUpdate(): void;
|
|
203
|
+
handleCompositionEnd(selection: OwoMarkSelection | null, fallbackText?: string | null): CoreApplyResult;
|
|
204
|
+
updateSelection(selection: OwoMarkSelection): void;
|
|
205
|
+
/** Get the block context at the current cursor position. */
|
|
206
|
+
getBlockContext(): BlockContext;
|
|
207
|
+
/**
|
|
208
|
+
* Insert a block template at the current cursor position.
|
|
209
|
+
* Unified entry point for toolbar / command palette.
|
|
210
|
+
*/
|
|
211
|
+
insertBlock(type: BlockInsertType, options?: {
|
|
212
|
+
language?: string;
|
|
213
|
+
}): void;
|
|
214
|
+
getCommandRegistry(): CommandRegistry;
|
|
215
|
+
getSlashState(): SlashState;
|
|
216
|
+
/** Register a custom command. Returns unregister function. */
|
|
217
|
+
registerCommand(def: CommandDefinition): () => void;
|
|
218
|
+
/** Execute a slash command by index in filtered list (for menu click/enter). */
|
|
219
|
+
executeSlashCommand(index: number): void;
|
|
220
|
+
/** Dismiss the slash menu without executing. */
|
|
221
|
+
dismissSlashMenu(): void;
|
|
222
|
+
onChange(callback: (markdown: string) => void): () => void;
|
|
223
|
+
onSelectionChange(callback: (selection: OwoMarkSelection) => void): () => void;
|
|
224
|
+
onCompositionStateChange(callback: (active: boolean) => void): () => void;
|
|
225
|
+
onStateChange(callback: (snapshot: CoreStateSnapshot) => void): () => void;
|
|
226
|
+
onSlashStateChange(callback: SlashStateListener): () => void;
|
|
227
|
+
/** Subscribe to block context changes (fires on selection or document change). */
|
|
228
|
+
onBlockContextChange(callback: BlockContextListener): () => void;
|
|
229
|
+
/**
|
|
230
|
+
* Register a document change callback (sovereign mode).
|
|
231
|
+
* When registered, adapters should render declaratively from the document.
|
|
232
|
+
*/
|
|
233
|
+
onDocumentChange(callback: DocumentChangeCallback): () => void;
|
|
234
|
+
/** Dispose timers and internal state. */
|
|
235
|
+
destroy(): void;
|
|
236
|
+
};
|
|
237
|
+
type CreateOwoMarkCoreOptions = {
|
|
238
|
+
initialMarkdown?: string;
|
|
239
|
+
indentMode?: IndentMode;
|
|
240
|
+
/** Enable side annotation Enter-continuation. Defaults to true. */
|
|
241
|
+
enableSideAnnotation?: boolean;
|
|
242
|
+
/** Enable math slash command visibility. Defaults to true. */
|
|
243
|
+
enableMath?: boolean;
|
|
244
|
+
/** Enable built-in component commands. Defaults to true. */
|
|
245
|
+
enableComponents?: boolean;
|
|
246
|
+
};
|
|
247
|
+
declare function createOwoMarkCore(options?: CreateOwoMarkCoreOptions): OwoMarkCore;
|
|
248
|
+
|
|
249
|
+
export { type BeforeInputIntent as B, type CoreStateSnapshot as C, type DocumentChangeCallback as D, type IndentMode as I, type KeyDownIntent as K, type OwoMarkCore as O, type PasteIntent as P, type SlashState as S, type CommandRegistry as a, type CommandContext as b, type CommandDefinition as c, type CoreApplyAction as d, type CoreApplyResult as e, type CoreSelectionSnapshot as f, type CreateOwoMarkCoreOptions as g, type IndentResult as h, type SlashStateListener as i, type SlashTriggerInfo as j, applyMarkdownIndent as k, createOwoMarkCore as l, resolveIndentSize as r };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { C as CoreStateSnapshot, S as SlashState, a as CommandRegistry } from './editor-core-DbPhn6aI.js';
|
|
2
|
+
export { B as BeforeInputIntent, b as CommandContext, c as CommandDefinition, d as CoreApplyAction, e as CoreApplyResult, f as CoreSelectionSnapshot, g as CreateOwoMarkCoreOptions, D as DocumentChangeCallback, I as IndentMode, h as IndentResult, K as KeyDownIntent, O as OwoMarkCore, P as PasteIntent, i as SlashStateListener, j as SlashTriggerInfo, k as applyMarkdownIndent, l as createOwoMarkCore, r as resolveIndentSize } from './editor-core-DbPhn6aI.js';
|
|
3
|
+
import { g as BlockNode, h as BlockContextType, O as OwoMarkSelection, i as ContainerBlockSyntaxExtension, J as JsonValue, j as ParseMarkdownOptions, a as OwoMarkDocument, k as ConformanceDocument, D as DirtyRange, P as PreviewBlockKind, f as PreviewBlock, l as BlockTransform, m as OwoMarkSharedStateController, n as InlineExtensionPriority, o as InlineSyntaxExtension, T as TokenizeInlineOptions, e as InlineToken, p as TokenizeBlockOptions } from './public-zMo7BR9l.js';
|
|
4
|
+
export { b as BlockContext, d as BlockContextListener, q as BlockExtensionPriority, c as BlockInsertType, r as BlockSyntaxExtension, B as BlockType, s as CLASSLESS_INLINE_TOKEN_TYPES, C as CompositionState, t as ConformanceBlockNode, u as ConformanceContainerNode, v as ConformanceInlineNode, w as ConformanceTableCell, x as ConformanceTableRow, y as ContainerBlockExtensionPriority, z as ContainerFrame, A as ContainerKind, E as CustomBlockRuntimeBinding, F as Decorator, G as DecoratorType, H as HeadingLevel, K as HistoryEntry, L as INLINE_TOKEN_TYPES, M as InlineExtensionHostBlockType, N as InlineScannerMatch, I as InlineTokenType, Q as JsonPrimitive, R as Leaf, S as OwoMarkCommands, U as OwoMarkDocumentTrace, W as OwoMarkEditorLike, X as OwoMarkSharedState, Y as OwoMarkSharedStateStore, Z as ParserDiffScope, _ as ParserExtensionConsumer, $ as ParserExtensionParent, a0 as ParserExtensionScope, a1 as PreviewDirtyReason, a2 as SideAnnotationMemberBlock, a3 as SideAnnotationMemberBlockType, a4 as SideAnnotationSourceKind, a5 as TokenizeBlockExtensionOptions, a6 as VirtualPosition, V as VirtualSelection, a7 as getBlockIndexForPosition, a8 as isVirtualSelectionCollapsed, a9 as linearToVirtual, aa as linearToVirtualPosition, ab as virtualPositionToLinear, ac as virtualPositionsEqual, ad as virtualToLinear } from './public-zMo7BR9l.js';
|
|
5
|
+
export { O as OwoComponentDescriptor, d as OwoEditorEntryDescriptor, f as OwoFeatureFlagKey, g as OwoRuntimeBlockDescriptor, h as OwoSyntaxDescriptor } from './registry-C849sxCo.js';
|
|
6
|
+
export { getSyntaxDescriptor, parseInlineSideAnnotationFromText, stripInlineSideAnnotationTail, stripSideContinuationTail, syntaxRegistry } from './semantic/syntax/index.js';
|
|
7
|
+
export { componentRegistry, getComponentDescriptor, getComponentDescriptorByDirective } from './semantic/components/index.js';
|
|
8
|
+
export { getRuntimeBlockDescriptor, getRuntimeBlockDescriptorByBlockType, getRuntimeBlockDescriptorByPreviewKind, runtimeBlockRegistry } from './semantic/runtime/index.js';
|
|
9
|
+
export { editorEntryRegistry, getEditorEntryDescriptor, getEditorEntryDescriptorByCommandId, resolveEditorEntryPresentation } from './semantic/editor/index.js';
|
|
3
10
|
export { WordBoundaryResult, deleteToLineEnd, deleteToLineStart, deleteWordBackward, deleteWordForward } from './internal/commands/word-boundary.js';
|
|
4
11
|
export { normalizeMarkdownPaste } from './internal/clipboard/paste.js';
|
|
5
12
|
export { enableMapSet, produce } from 'immer';
|
|
13
|
+
import { O as OwoMarkScrollProjectionSnapshot, c as OwoMarkScrollProjectionSegment, S as SourceKey, a as OwoMarkSurfaceGeometrySnapshot, V as ViewportMetrics, G as GlobalScrollPosition } from './types-DMqYF6Zn.js';
|
|
14
|
+
export { C as ContentId, d as Geometry, b as OwoMarkScrollController, e as OwoMarkScrollDegradedReason, f as OwoMarkSurfaceGeometrySegment, g as OwoMarkSurfaceGeometrySnapshotStatus, h as ScrollProjectionSegmentKind, i as ScrollResolutionResult, j as ScrollSurface, k as ScrollToScrollPositionOptions, l as ScrollToScrollPositionResult } from './types-DMqYF6Zn.js';
|
|
6
15
|
|
|
7
16
|
/**
|
|
8
17
|
* Resolve the extended BlockContextType from a BlockNode.
|
|
@@ -39,19 +48,34 @@ type CoreEventHub = {
|
|
|
39
48
|
|
|
40
49
|
declare function createCommandRegistry(): CommandRegistry;
|
|
41
50
|
|
|
51
|
+
declare const CARDS_FAMILY_CUSTOM_BLOCK_KEY = "cards-family";
|
|
52
|
+
type CardsFamilyTone = 'neutral' | 'info' | 'warning';
|
|
53
|
+
type CardsFamilyCard = {
|
|
54
|
+
title: string | null;
|
|
55
|
+
tone: CardsFamilyTone | null;
|
|
56
|
+
bodyMarkdown: string;
|
|
57
|
+
};
|
|
58
|
+
type CardsFamilyAttributes = {
|
|
59
|
+
layout: {
|
|
60
|
+
cols: 2;
|
|
61
|
+
};
|
|
62
|
+
cards: CardsFamilyCard[];
|
|
63
|
+
};
|
|
64
|
+
declare function isCardsFamilyAttributes(value: JsonValue | undefined): value is CardsFamilyAttributes;
|
|
65
|
+
declare const cardsFamilyContainerExtension: ContainerBlockSyntaxExtension;
|
|
66
|
+
|
|
42
67
|
type BlockIdGenerator = () => string;
|
|
43
68
|
/** Create a per-instance block ID generator. */
|
|
44
69
|
declare function createBlockIdGenerator(): BlockIdGenerator;
|
|
45
70
|
/** Reset the default block ID counter (for testing). */
|
|
46
71
|
declare function resetBlockIdCounter(): void;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
* Unchanged blocks at the head and tail preserve old identity (including ID).
|
|
51
|
-
* Middle blocks (inserted, deleted, or modified) use new identity.
|
|
52
|
-
*/
|
|
72
|
+
|
|
73
|
+
declare function parseMarkdownToDocument(markdown: string, genIdOrOptions?: BlockIdGenerator | ParseMarkdownOptions, parseOptions?: ParseMarkdownOptions): OwoMarkDocument;
|
|
74
|
+
|
|
53
75
|
declare function reconcileBlocks(oldBlocks: readonly BlockNode[], newBlocks: readonly BlockNode[]): BlockNode[];
|
|
76
|
+
|
|
54
77
|
declare function serializeDocument(doc: OwoMarkDocument): string;
|
|
78
|
+
|
|
55
79
|
declare function getBlockById(doc: OwoMarkDocument, blockId: string): BlockNode | undefined;
|
|
56
80
|
declare function getBlockIndexById(doc: OwoMarkDocument, blockId: string): number;
|
|
57
81
|
declare function getBlockAtOffset(doc: OwoMarkDocument, offset: number): {
|
|
@@ -60,30 +84,21 @@ declare function getBlockAtOffset(doc: OwoMarkDocument, offset: number): {
|
|
|
60
84
|
};
|
|
61
85
|
declare function getBlockStartOffset(doc: OwoMarkDocument, blockIndex: number): number;
|
|
62
86
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
declare function
|
|
77
|
-
|
|
78
|
-
* Restore a selection on the editor root from linear offsets.
|
|
79
|
-
*/
|
|
80
|
-
declare function restoreSelection(root: HTMLElement, selection: OwoMarkSelection): void;
|
|
81
|
-
/**
|
|
82
|
-
* Read current DOM selection as linear offsets.
|
|
83
|
-
*/
|
|
84
|
-
declare function readSelection(root: HTMLElement): OwoMarkSelection | null;
|
|
85
|
-
/** Invalidate the cached block element list. Call after every DOM render. */
|
|
86
|
-
declare function invalidateBlockCache(root: HTMLElement): void;
|
|
87
|
+
type MdastNode = {
|
|
88
|
+
type: string;
|
|
89
|
+
value?: string;
|
|
90
|
+
depth?: number;
|
|
91
|
+
ordered?: boolean;
|
|
92
|
+
checked?: boolean | null;
|
|
93
|
+
lang?: string | null;
|
|
94
|
+
align?: (string | null)[];
|
|
95
|
+
children?: MdastNode[];
|
|
96
|
+
url?: string;
|
|
97
|
+
alt?: string;
|
|
98
|
+
};
|
|
99
|
+
declare function buildConformanceDocument(blocks: readonly BlockNode[]): ConformanceDocument;
|
|
100
|
+
declare function hydrateOwoMarkDocument(blocks: readonly BlockNode[]): OwoMarkDocument;
|
|
101
|
+
declare function buildConformanceMdastRoot(document: Pick<OwoMarkDocument, 'conformance'>): MdastNode;
|
|
87
102
|
|
|
88
103
|
/**
|
|
89
104
|
* Merge a new dirty block index into an existing dirty range.
|
|
@@ -130,12 +145,6 @@ declare function deriveRenderKey(raw: string, kind: PreviewBlockKind, themeKey?:
|
|
|
130
145
|
*/
|
|
131
146
|
|
|
132
147
|
declare function projectToPreviewBlocks(doc: OwoMarkDocument, themeKey?: string, transforms?: BlockTransform[]): PreviewBlock[];
|
|
133
|
-
/**
|
|
134
|
-
* Compare two preview block arrays and return the dirty range.
|
|
135
|
-
* Uses two-pointer scan to find the tightest changed range (EV3).
|
|
136
|
-
* Returns null if no blocks changed.
|
|
137
|
-
* endBlock is always clamped to valid newBlocks range (RISK-3).
|
|
138
|
-
*/
|
|
139
148
|
declare function computePreviewDirtyRange(oldBlocks: PreviewBlock[], newBlocks: PreviewBlock[]): {
|
|
140
149
|
startBlock: number;
|
|
141
150
|
endBlock: number;
|
|
@@ -156,17 +165,21 @@ type CreateSharedStateOptions = {
|
|
|
156
165
|
};
|
|
157
166
|
declare function createSharedStateStore(options?: CreateSharedStateOptions): OwoMarkSharedStateController;
|
|
158
167
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
168
|
+
declare function createDelimitedInlineExtension(config: {
|
|
169
|
+
key: string;
|
|
170
|
+
opener: string;
|
|
171
|
+
closer?: string;
|
|
172
|
+
priority?: InlineExtensionPriority;
|
|
173
|
+
canNestIn?: InlineSyntaxExtension['canNestIn'];
|
|
174
|
+
diffScope?: InlineSyntaxExtension['diffScope'];
|
|
175
|
+
}): InlineSyntaxExtension;
|
|
176
|
+
declare function tokenizeInline(raw: string, baseOffset?: number, options?: TokenizeInlineOptions): InlineToken[];
|
|
164
177
|
|
|
165
178
|
/**
|
|
166
179
|
* Tokenize a single block's raw text into InlineToken[].
|
|
167
180
|
* Block-level markers (heading #, list bullet, etc.) get their own token types.
|
|
168
181
|
*/
|
|
169
|
-
declare function tokenizeBlock(raw: string, blockType: string, baseOffset?: number): InlineToken[];
|
|
182
|
+
declare function tokenizeBlock(raw: string, blockType: string, baseOffset?: number, options?: TokenizeBlockOptions): InlineToken[];
|
|
170
183
|
|
|
171
184
|
/**
|
|
172
185
|
* Enter key handling: list continuation, blockquote continuation,
|
|
@@ -300,47 +313,6 @@ type ImageSizeSyntax = 'obsidian' | 'pandoc' | 'mou' | 'none';
|
|
|
300
313
|
*/
|
|
301
314
|
declare function createImageSizeTransform(syntax?: ImageSizeSyntax): BlockTransform;
|
|
302
315
|
|
|
303
|
-
/**
|
|
304
|
-
* Incremental DOM patch: only re-render dirty blocks.
|
|
305
|
-
*/
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* Full render: build entire editor DOM from document model.
|
|
309
|
-
*/
|
|
310
|
-
declare function fullRender(root: HTMLElement, doc: OwoMarkDocument): void;
|
|
311
|
-
/**
|
|
312
|
-
* Incremental patch: only re-render blocks in dirty range.
|
|
313
|
-
*/
|
|
314
|
-
declare function patchDirtyBlocks(root: HTMLElement, doc: OwoMarkDocument, dirty: DirtyRange): void;
|
|
315
|
-
/**
|
|
316
|
-
* Detect changed blocks between old and new document, then render minimally.
|
|
317
|
-
* Falls back to full render when block count changes or no dirty blocks found
|
|
318
|
-
* despite text difference (structural shift).
|
|
319
|
-
*/
|
|
320
|
-
declare function detectAndRenderDirty(root: HTMLElement, oldDoc: OwoMarkDocument, newDoc: OwoMarkDocument, fullFallback?: boolean): void;
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Render a block's inline tokens into DOM nodes within a block container.
|
|
324
|
-
* Each block is a <div data-owo-block="index"> containing text/span nodes.
|
|
325
|
-
*/
|
|
326
|
-
|
|
327
|
-
declare const TOKEN_TO_CLASS: Record<InlineTokenType, string>;
|
|
328
|
-
declare const BLOCK_TYPE_TO_CLASS: Record<string, string>;
|
|
329
|
-
declare function createBlockElement(doc: Document, tokens: InlineToken[], blockIndex: number, blockType: string, headingLevel?: number, depth?: number): HTMLDivElement;
|
|
330
|
-
/**
|
|
331
|
-
* Update an existing block element's content with new tokens.
|
|
332
|
-
* Returns true if the block was modified.
|
|
333
|
-
*/
|
|
334
|
-
declare function updateBlockElement(doc: Document, existing: HTMLDivElement, tokens: InlineToken[], blockType: string, headingLevel?: number, depth?: number): boolean;
|
|
335
|
-
|
|
336
|
-
declare const BQ_STEP: number;
|
|
337
|
-
/**
|
|
338
|
-
* Build the CSS box-shadow value for nested blockquote bars.
|
|
339
|
-
* Returns null when depth <= 1 (no extra bars needed — the first bar is
|
|
340
|
-
* rendered by the block's own border/class styling).
|
|
341
|
-
*/
|
|
342
|
-
declare function buildBlockquoteBarsBoxShadow(depth: number): string | null;
|
|
343
|
-
|
|
344
316
|
/** A flattened row for virtual list computation. */
|
|
345
317
|
type VirtualRow = {
|
|
346
318
|
blockIndex: number;
|
|
@@ -362,4 +334,23 @@ declare function buildVirtualRows(blocks: readonly BlockNode[], heightCache: Map
|
|
|
362
334
|
/** Compute the visible range given scroll state. */
|
|
363
335
|
declare function computeVisibleRange(rows: VirtualRow[], scrollTop: number, viewportHeight: number, overscan?: number): VisibleRange;
|
|
364
336
|
|
|
365
|
-
|
|
337
|
+
declare function projectToScrollSegments(previewBlocks: readonly PreviewBlock[]): OwoMarkScrollProjectionSegment[];
|
|
338
|
+
declare function buildScrollProjectionSnapshot(previewBlocks: readonly PreviewBlock[], documentRevision: number): OwoMarkScrollProjectionSnapshot;
|
|
339
|
+
|
|
340
|
+
type ProgressSegment = {
|
|
341
|
+
sourceKey: SourceKey;
|
|
342
|
+
startLine: number;
|
|
343
|
+
endLine: number;
|
|
344
|
+
progressStart: number;
|
|
345
|
+
progressEnd: number;
|
|
346
|
+
top: number;
|
|
347
|
+
bottom: number;
|
|
348
|
+
height: number;
|
|
349
|
+
measured: boolean;
|
|
350
|
+
};
|
|
351
|
+
declare const DEFAULT_VIEWPORT_ANCHOR_RATIO = 0.35;
|
|
352
|
+
declare function buildProgressSegments(projection: OwoMarkScrollProjectionSnapshot, geometry: OwoMarkSurfaceGeometrySnapshot): ProgressSegment[];
|
|
353
|
+
declare function resolveScrollPosition(projection: OwoMarkScrollProjectionSnapshot, geometry: OwoMarkSurfaceGeometrySnapshot, viewport: ViewportMetrics, viewportAnchorRatio?: number): GlobalScrollPosition | null;
|
|
354
|
+
declare function resolveScrollTopFromPosition(position: GlobalScrollPosition, projection: OwoMarkScrollProjectionSnapshot, geometry: OwoMarkSurfaceGeometrySnapshot, viewportHeight: number, scrollHeight: number, viewportAnchorRatio?: number): number | null;
|
|
355
|
+
|
|
356
|
+
export { BlockContextType, type BlockIdGenerator, BlockNode, BlockTransform, CARDS_FAMILY_CUSTOM_BLOCK_KEY, type CardsFamilyAttributes, type CardsFamilyCard, type CardsFamilyTone, CommandRegistry, type CommandResult, ConformanceDocument, ContainerBlockSyntaxExtension, type CoreEventHub, type CoreSlashStateListener, CoreStateSnapshot, type CreateSharedStateOptions, DEFAULT_VIEWPORT_ANCHOR_RATIO, DirtyRange, GlobalScrollPosition, type ImageSizeSyntax, InlineExtensionPriority, InlineSyntaxExtension, InlineToken, JsonValue, NOT_HANDLED, OwoMarkDocument, OwoMarkScrollProjectionSegment, OwoMarkScrollProjectionSnapshot, OwoMarkSelection, OwoMarkSharedStateController, OwoMarkSurfaceGeometrySnapshot, ParseMarkdownOptions, PreviewBlock, PreviewBlockKind, type ProgressSegment, SlashState, SourceKey, TokenizeBlockOptions, TokenizeInlineOptions, ViewportMetrics, type VirtualRow, type VisibleRange, buildConformanceDocument, buildConformanceMdastRoot, buildProgressSegments, buildScrollProjectionSnapshot, buildVirtualRows, cardsFamilyContainerExtension, computePreviewDirtyRange, computeVisibleRange, createBlockIdGenerator, createCommandRegistry, createDelimitedInlineExtension, createImageSizeTransform, createSharedStateStore, deriveBlockId, deriveRenderKey, deriveSourceKey, estimateEditorBlockHeight, expandDirtyRange, expandWithContext, getBlockAtOffset, getBlockById, getBlockIndexById, getBlockStartOffset, handleCharInput, handleMarkdownEnter, handleSmartBackspace, handleSmartDelete, hydrateOwoMarkDocument, insertCodeFence, insertImage, insertLink, insertMathBlock, insertSideAnnotation, insertTable, isCardsFamilyAttributes, parseMarkdownToDocument, projectToPreviewBlocks, projectToScrollSegments, reconcileBlocks, resetBlockIdCounter, resolveBlockContextType, resolveScrollPosition, resolveScrollTopFromPosition, serializeDocument, toggleBold, toggleItalic, tokenizeBlock, tokenizeInline };
|