markloom 0.5.1 → 0.7.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/PACKAGES.md +26 -0
- package/README.md +20 -2
- package/collab.md +60 -13
- package/dist/ai/index.cjs +5 -4
- package/dist/ai/index.d.cts +5 -4
- package/dist/ai/index.d.ts +5 -4
- package/dist/ai/index.js +4 -3
- package/dist/ai/theme.css +66 -102
- package/dist/{chunk-ZMTLSFLO.js → chunk-4Q7PAR2T.js} +5746 -1341
- package/dist/chunk-75EJ4ARB.cjs +642 -0
- package/dist/{chunk-JS527FDV.cjs → chunk-BMPCVT3B.cjs} +47 -39
- package/dist/{chunk-RLTHVQNQ.js → chunk-EFYT2223.js} +47 -39
- package/dist/chunk-HXABDVLZ.cjs +297 -0
- package/dist/{chunk-YIFOGP2D.cjs → chunk-I2LDEVLA.cjs} +499 -102
- package/dist/chunk-MQLRZQZL.js +642 -0
- package/dist/chunk-OVHASRID.cjs +4279 -0
- package/dist/chunk-PCSVBPOR.cjs +40 -0
- package/dist/{chunk-FCH7LZFI.js → chunk-PSAXWBNM.js} +450 -53
- package/dist/chunk-PZRWTLLB.cjs +858 -0
- package/dist/chunk-QO7JEZDB.js +4279 -0
- package/dist/chunk-WSJUXPAG.js +40 -0
- package/dist/{chunk-VXM7Q6P5.cjs → chunk-Y4IXQFWL.cjs} +6026 -1621
- package/dist/chunk-YLVSMDIO.js +858 -0
- package/dist/chunk-ZL6WT6OY.js +297 -0
- package/dist/client-BvvyHjhh.d.ts +250 -0
- package/dist/client-Ciy7Fa_k.d.cts +250 -0
- package/dist/collab/index.cjs +17 -4
- package/dist/collab/index.d.cts +18 -7
- package/dist/collab/index.d.ts +18 -7
- package/dist/collab/index.js +19 -6
- package/dist/{controller-DQITsFhy.d.cts → controller-CHznEhAR.d.cts} +277 -26
- package/dist/{controller-BNuuUM3E.d.ts → controller-DLqI8_jm.d.ts} +277 -26
- package/dist/index.cjs +119 -7
- package/dist/index.d.cts +138 -6
- package/dist/index.d.ts +138 -6
- package/dist/index.js +130 -18
- package/dist/io/index.cjs +1412 -0
- package/dist/io/index.d.cts +33 -0
- package/dist/io/index.d.ts +33 -0
- package/dist/io/index.js +1412 -0
- package/dist/react/index.cjs +9 -8
- package/dist/react/index.d.cts +5 -4
- package/dist/react/index.d.ts +5 -4
- package/dist/react/index.js +8 -7
- package/dist/{rebase-batch-8rL_aXEE.d.ts → rebase-batch-CSnv8FKp.d.ts} +11 -9
- package/dist/{rebase-batch-bYnBJpRO.d.cts → rebase-batch-DO1ygkx9.d.cts} +11 -9
- package/dist/types-BkHlmUFL.d.cts +34 -0
- package/dist/types-BkHlmUFL.d.ts +34 -0
- package/dist/versions-DNFf8zVz.d.cts +51 -0
- package/dist/versions-DOkOyh2J.d.ts +51 -0
- package/dist/view/index.cjs +259 -17
- package/dist/view/index.d.cts +277 -12
- package/dist/view/index.d.ts +277 -12
- package/dist/view/index.js +256 -14
- package/dist/view/theme.css +2093 -1577
- package/dist/word-count-BPw9G2Bg.d.ts +130 -0
- package/dist/word-count-DNLn1h_t.d.cts +130 -0
- package/io.md +38 -0
- package/package.json +25 -4
- package/dist/chunk-4JSJAHTB.js +0 -255
- package/dist/chunk-4TMHVNL6.cjs +0 -2297
- package/dist/chunk-ALZ3A5CS.cjs +0 -255
- package/dist/chunk-GQ2HHRGI.cjs +0 -16
- package/dist/chunk-LA5SBCGQ.js +0 -16
- package/dist/chunk-LEYAQNJA.js +0 -220
- package/dist/chunk-MFYF2A6U.js +0 -2297
- package/dist/chunk-YXQDCW4Y.cjs +0 -220
- package/dist/client-6KiH4kGK.d.ts +0 -144
- package/dist/client-ZRZj2nkq.d.cts +0 -144
- package/dist/comments-DlExS6f-.d.cts +0 -43
- package/dist/comments-PhnR7Gkn.d.ts +0 -43
- package/dist/step-BrvHIK7O.d.cts +0 -65
- package/dist/step-BrvHIK7O.d.ts +0 -65
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as Step, a as DocVersion } from './versions-DNFf8zVz.cjs';
|
|
2
|
+
import { E as ElementNode, S as Selection, M as Mark, P as Path, N as Node } from './types-BkHlmUFL.cjs';
|
|
2
3
|
import * as preact from 'preact';
|
|
3
4
|
import { ComponentChild } from 'preact';
|
|
4
|
-
import { H as History, c as CommentThread, C as CommentAuthor } from './
|
|
5
|
-
import { d as CollabConfig, c as CollabClient } from './client-
|
|
5
|
+
import { H as History, c as CommentThread, C as CommentAuthor, e as SuggestAuthor, T as TextMatch, W as WordCount } from './word-count-DNLn1h_t.cjs';
|
|
6
|
+
import { d as CollabConfig, g as CollabReplica, c as CollabClient } from './client-Ciy7Fa_k.cjs';
|
|
6
7
|
|
|
7
8
|
interface MentionCandidate {
|
|
8
9
|
id: string;
|
|
@@ -35,10 +36,16 @@ declare class MentionMenu {
|
|
|
35
36
|
private paint;
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
declare function safeCssValue(v: string): string;
|
|
40
|
+
type TextStyleAttr = 'color' | 'backgroundColor' | 'fontFamily' | 'fontSize' | 'lineHeight';
|
|
41
|
+
declare function attrsToStyle(attrs: Record<string, unknown> | undefined): string;
|
|
42
|
+
|
|
38
43
|
interface NodeViewCtx {
|
|
39
44
|
node: ElementNode;
|
|
40
45
|
text: string;
|
|
41
46
|
key: number | string;
|
|
47
|
+
/** false = 只读/SSG:不投语言切换等编辑 affordance */
|
|
48
|
+
editable?: boolean;
|
|
42
49
|
}
|
|
43
50
|
interface NodeView {
|
|
44
51
|
render: (ctx: NodeViewCtx) => ComponentChild;
|
|
@@ -65,12 +72,44 @@ interface RenderOpts {
|
|
|
65
72
|
activeId: string | null;
|
|
66
73
|
};
|
|
67
74
|
atomSelect?: AtomSelectCtx | null;
|
|
75
|
+
editable?: boolean;
|
|
76
|
+
leafDecos?: WeakMap<object, InlineDeco[]>;
|
|
77
|
+
diagram?: DiagramResolver;
|
|
78
|
+
blockCache?: BlockVnodeCache;
|
|
79
|
+
checkboxLabel?: (checked: boolean) => string;
|
|
80
|
+
}
|
|
81
|
+
/** 图表(```mermaid 一类围栏)的当前态:html = 画好的 SVG/HTML;error = 画不出来的原因;都没有 = 还在画。 */
|
|
82
|
+
interface DiagramState {
|
|
83
|
+
html?: string;
|
|
84
|
+
error?: string;
|
|
85
|
+
}
|
|
86
|
+
/** 取一个代码块的图表态。null = 这个块不是图表,照常画成代码。(lang, 源码, 块 id);同一源码的结果由调用方缓存。 */
|
|
87
|
+
type DiagramResolver = (lang: string, source: string, id: string) => DiagramState | null;
|
|
88
|
+
/**
|
|
89
|
+
* 顶层块的 vnode 缓存(Editor 持有,长文档的逐字输入靠它只重画被改的那一块)。
|
|
90
|
+
* 文档是不可变树、没碰的块保持同一个对象,所以「同一个块对象 + 同样的渲染上下文」得到的 vnode 必然相同;
|
|
91
|
+
* 把上一轮的 vnode 原样交给 Preact,它认出是同一个 vnode 就整棵跳过 diff(不再对账上万块)。
|
|
92
|
+
* 上下文(`key`)变了——显隐符、可编辑态、评论态、图选中态——调用方整个换一个新缓存。
|
|
93
|
+
* 依赖「渲染时才定下来的、会随别处变」的东西不能缓存:slug 工厂(重名标题的后缀按先后累加)、行内装饰(按路径落到叶上)、图表围栏(异步出图)。
|
|
94
|
+
*/
|
|
95
|
+
interface BlockVnodeCache {
|
|
96
|
+
key: string;
|
|
97
|
+
map: WeakMap<object, {
|
|
98
|
+
vnode: ComponentChild;
|
|
99
|
+
id: string | number;
|
|
100
|
+
}>;
|
|
101
|
+
}
|
|
102
|
+
/** 文本叶内 [from,to) 套 class 的装饰。 */
|
|
103
|
+
interface InlineDeco {
|
|
104
|
+
from: number;
|
|
105
|
+
to: number;
|
|
106
|
+
class: string;
|
|
68
107
|
}
|
|
69
108
|
declare const defaultBlockTag: Record<string, string>;
|
|
70
109
|
declare const defaultMarkTag: Record<string, string>;
|
|
71
110
|
declare function renderImage(spec: ElementNode, key: number | string, atomSelect?: AtomSelectCtx | null): ComponentChild;
|
|
72
|
-
|
|
73
|
-
declare
|
|
111
|
+
|
|
112
|
+
declare const textStyleCss: typeof attrsToStyle;
|
|
74
113
|
declare function renderEmbed(spec: ElementNode, key: number | string, atomSelect?: AtomSelectCtx | null): ComponentChild;
|
|
75
114
|
declare function youtubeId(url: string): string | null;
|
|
76
115
|
declare function twitchChannel(url: string): string | null;
|
|
@@ -78,12 +117,19 @@ declare function renderCode(spec: ElementNode, key: number | string, ctx: BlockR
|
|
|
78
117
|
declare function renderTable(spec: ElementNode, key: number | string, ctx: BlockRenderCtx): ComponentChild;
|
|
79
118
|
declare function renderHr(spec: ElementNode, key: number | string, ctx: BlockRenderCtx): ComponentChild;
|
|
80
119
|
declare const defaultBlockRenderers: Record<string, BlockRenderer>;
|
|
120
|
+
/** Doc → 投影壳 class + 块 vnode。Editor 的 surface ≡ .markloom-doc 只吃 children;SSG 再包一层 div。 */
|
|
121
|
+
declare function projectDoc(doc: ElementNode, opts?: RenderOpts): {
|
|
122
|
+
className: string;
|
|
123
|
+
children: ComponentChild[];
|
|
124
|
+
};
|
|
81
125
|
declare function renderDoc(doc: ElementNode, opts?: RenderOpts): preact.VNode<preact.ClassAttributes<HTMLElement> & {
|
|
82
126
|
class: string;
|
|
83
127
|
'data-markloom': boolean;
|
|
84
128
|
}>;
|
|
85
129
|
declare function renderToHtml(doc: ElementNode, opts?: RenderOpts): string;
|
|
86
130
|
|
|
131
|
+
type ListType = 'a' | 'A' | 'i' | 'I';
|
|
132
|
+
|
|
87
133
|
interface InputResult {
|
|
88
134
|
steps: Step[];
|
|
89
135
|
selection: Selection;
|
|
@@ -95,42 +141,89 @@ declare function wordBoundaryBack(text: string, offset: number): number | null;
|
|
|
95
141
|
declare function wordBoundaryFwd(text: string, offset: number): number | null;
|
|
96
142
|
declare function lineBoundaryBack(text: string, offset: number): number | null;
|
|
97
143
|
declare function lineBoundaryFwd(text: string, offset: number): number | null;
|
|
144
|
+
declare function leafBlockPath(sel: Selection): Path;
|
|
145
|
+
declare function nearestListPath(doc: ElementNode, fromPath: Path): Path | null;
|
|
98
146
|
declare function isAtom(block: Node): boolean;
|
|
147
|
+
declare function keepsApart(block: Node): boolean;
|
|
99
148
|
declare function isOpaque(block: Node): boolean;
|
|
100
149
|
declare function mapInput(doc: ElementNode, intent: Intent, data: string, sel: Selection, newId: () => string, rules?: BlockInputRule[], pendingMarks?: Mark[] | null): InputResult | null;
|
|
101
|
-
declare function wrapList(block: ElementNode,
|
|
150
|
+
declare function wrapList(block: ElementNode, blockPath: number | Path, newId: () => string, rest: string, tail: Node[], ordered: boolean, start?: number): InputResult;
|
|
102
151
|
type BlockKind = 'paragraph' | 'heading1' | 'heading2' | 'heading3' | 'quote' | 'callout' | 'bullet' | 'ordered' | 'task' | 'code';
|
|
152
|
+
declare function isCellBlockKind(kind: BlockKind): boolean;
|
|
103
153
|
declare const CALLOUT_VARIANTS: readonly ["info", "warn", "success", "danger"];
|
|
104
154
|
type CalloutVariant = typeof CALLOUT_VARIANTS[number];
|
|
105
155
|
declare function calloutVariantFromQuery(q: string): CalloutVariant;
|
|
106
|
-
declare function blockTransform(block: ElementNode,
|
|
156
|
+
declare function blockTransform(block: ElementNode, blockPath: number | Path, kind: BlockKind, newId: () => string, extra?: {
|
|
107
157
|
variant?: CalloutVariant;
|
|
108
158
|
}): InputResult;
|
|
159
|
+
declare function joinPrevList(doc: ElementNode, path: Path, kind: BlockKind, made: ElementNode, count?: number): InputResult | null;
|
|
160
|
+
declare function blockTransformRange(doc: ElementNode, sel: Selection, kind: BlockKind, newId: () => string, extra?: {
|
|
161
|
+
variant?: CalloutVariant;
|
|
162
|
+
}): InputResult | null;
|
|
109
163
|
declare function setCalloutVariant(doc: ElementNode, path: Path, variant: CalloutVariant): InputResult | null;
|
|
110
164
|
declare function cycleCalloutVariant(doc: ElementNode, path: Path): InputResult | null;
|
|
111
165
|
declare function setAlign(doc: ElementNode, sel: Selection, align: 'left' | 'center' | 'right' | 'justify'): InputResult | null;
|
|
166
|
+
declare function setHeadingDepth(doc: ElementNode, sel: Selection, depth: number): InputResult | null;
|
|
167
|
+
declare function setListType(doc: ElementNode, sel: Selection, type: ListType | null): InputResult | null;
|
|
112
168
|
declare function marksAtCaret(doc: ElementNode, path: Path): Mark[];
|
|
169
|
+
declare function expandToLink(doc: ElementNode, sel: Selection): Selection;
|
|
113
170
|
declare function toggleMarkList(marks: Mark[], name: string, attrs?: Record<string, unknown>): Mark[];
|
|
171
|
+
/** 清除格式:选区里的文字去掉全部 mark,但批注锚点(comment)不是格式,留着。塌缩选区、没有可清的 mark 返回 null。 */
|
|
172
|
+
declare function clearMarks(doc: ElementNode, sel: Selection): InputResult | null;
|
|
114
173
|
declare function toggleMark(doc: ElementNode, sel: Selection, markName: string, attrs?: Record<string, unknown>): InputResult | null;
|
|
115
174
|
type TextStylePatch = {
|
|
116
|
-
|
|
117
|
-
backgroundColor?: string | null;
|
|
118
|
-
fontFamily?: string | null;
|
|
119
|
-
fontSize?: string | null;
|
|
175
|
+
[K in TextStyleAttr]?: string | null;
|
|
120
176
|
};
|
|
121
177
|
declare function mergeTextStyleAttrs(attrs: Record<string, unknown> | undefined, patch: TextStylePatch): Record<string, unknown> | null;
|
|
122
178
|
declare function setTextStyle(doc: ElementNode, sel: Selection, patch: TextStylePatch): InputResult | null;
|
|
123
179
|
declare function serializeSelection(doc: ElementNode, sel: Selection): string;
|
|
180
|
+
/** 块级 atom 选中态(图/embed/表 exclusive)→ md。path 须为顶层 [idx]。 */
|
|
181
|
+
declare function serializeBlock(doc: ElementNode, path: Path): string | null;
|
|
124
182
|
declare function mapPaste(doc: ElementNode, sel: Selection, md: string, newId: () => string): InputResult | null;
|
|
125
183
|
declare function mapPasteBlocks(doc: ElementNode, sel: Selection, frag: ElementNode[], newId: () => string): InputResult | null;
|
|
126
184
|
declare function indentItem(doc: ElementNode, sel: Selection, newId: () => string): InputResult | null;
|
|
127
185
|
declare function outdentItem(doc: ElementNode, sel: Selection, newId: () => string): InputResult | null;
|
|
186
|
+
declare function tableAbove(doc: ElementNode, p: Path): Path | null;
|
|
187
|
+
interface TypedLink {
|
|
188
|
+
start: number;
|
|
189
|
+
text: string;
|
|
190
|
+
url: string;
|
|
191
|
+
title?: string;
|
|
192
|
+
}
|
|
193
|
+
/** marker = caret 前文本(还没含刚打的 `)`)。认得出就返回要换成链接的区间与内容。 */
|
|
194
|
+
declare function parseTypedLink(marker: string): TypedLink | null;
|
|
195
|
+
declare const markdownLinkRule: BlockInputRule;
|
|
196
|
+
interface InlinePair {
|
|
197
|
+
delim: string;
|
|
198
|
+
mark: string;
|
|
199
|
+
}
|
|
200
|
+
declare const INLINE_PAIRS: readonly InlinePair[];
|
|
201
|
+
interface InlinePairHit {
|
|
202
|
+
start: number;
|
|
203
|
+
content: string;
|
|
204
|
+
mark: string;
|
|
205
|
+
}
|
|
206
|
+
/** marker = caret 前的叶内文本;trigger = 刚打的字符;startOk = 叶首算不算词边界(前一叶的末字符是空白/标点/没有)。 */
|
|
207
|
+
declare function matchInlinePair(marker: string, trigger: string, startOk: boolean, table?: readonly InlinePair[]): InlinePairHit | null;
|
|
208
|
+
declare const inlinePairRule: BlockInputRule;
|
|
209
|
+
interface TypedUrl {
|
|
210
|
+
start: number;
|
|
211
|
+
url: string;
|
|
212
|
+
trail: string;
|
|
213
|
+
}
|
|
214
|
+
/** marker = caret 前叶内文本。认得出一个刚打完的网址就返回它在叶内的起点、网址本身、网址后被排除的标点。 */
|
|
215
|
+
declare function parseTypedUrl(marker: string): TypedUrl | null;
|
|
216
|
+
declare function urlAutolink(should?: (url: string) => boolean): BlockInputRule;
|
|
217
|
+
/** 默认规则:任何通过 isSafeLinkUrl 的网址都成链接。 */
|
|
218
|
+
declare const urlAutolinkRule: BlockInputRule;
|
|
128
219
|
|
|
129
220
|
interface BlockRenderCtx {
|
|
130
221
|
renderChild: (node: ElementNode['children'][number], key: number) => ComponentChild;
|
|
131
222
|
slug?: (text: string) => string;
|
|
132
223
|
codeView?: NodeView;
|
|
133
224
|
atomSelect?: AtomSelectCtx | null;
|
|
225
|
+
editable?: boolean;
|
|
226
|
+
diagram?: DiagramResolver;
|
|
134
227
|
}
|
|
135
228
|
type BlockRenderer = (spec: ElementNode, key: number | string, ctx: BlockRenderCtx) => ComponentChild;
|
|
136
229
|
interface InputRuleCtx {
|
|
@@ -183,9 +276,13 @@ interface DecorationHost {
|
|
|
183
276
|
dispatch: (steps: Step[], selectionAfter?: Selection) => void;
|
|
184
277
|
sel: () => Selection | null;
|
|
185
278
|
markSel: () => Selection | null;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
279
|
+
/** 给文本叶 path 里的 [from,to) 套 class(只是显示,不进文档;位置不随编辑映射,文档一变要自己重给)。返回撤销函数 */
|
|
280
|
+
decorateInline: (path: Path, from: number, to: number, attrs: {
|
|
281
|
+
class: string;
|
|
282
|
+
}) => () => void;
|
|
283
|
+
insertImage: (blockPath: number | number[]) => void;
|
|
284
|
+
insertMath?: (blockPath: number | Path) => void;
|
|
285
|
+
insertEmbed?: (blockPath: number | Path, kind: 'youtube' | 'twitch' | 'audio' | 'file') => void;
|
|
189
286
|
insertBelow: (blockIdx: number) => void;
|
|
190
287
|
langs: () => string[];
|
|
191
288
|
mentionSource: () => ((query: string) => MentionCandidate[]) | undefined;
|
|
@@ -231,6 +328,8 @@ interface Resolved {
|
|
|
231
328
|
}
|
|
232
329
|
declare function resolve(extensions: Extension[]): Resolved;
|
|
233
330
|
|
|
331
|
+
type TypingKind = 'insert' | 'delete';
|
|
332
|
+
|
|
234
333
|
/** OpenAI-compatible 供应商配置(xAI / OpenAI / 智谱 …) */
|
|
235
334
|
type AiProvider = {
|
|
236
335
|
host: string;
|
|
@@ -302,12 +401,16 @@ declare class MentionPopovers {
|
|
|
302
401
|
openDate(iso: string, path: number[], anchor: DOMRect): void;
|
|
303
402
|
private onDocDown;
|
|
304
403
|
private onKey;
|
|
404
|
+
private applyDate;
|
|
305
405
|
private paint;
|
|
306
406
|
private placePop;
|
|
307
407
|
private paintPerson;
|
|
308
408
|
private paintDateTime;
|
|
309
409
|
}
|
|
310
410
|
|
|
411
|
+
type Autofocus = boolean | 'start' | 'end' | 'all' | number;
|
|
412
|
+
declare function autofocusSelection(doc: ElementNode, mode: Autofocus): Selection | null;
|
|
413
|
+
|
|
311
414
|
interface EditorOptions {
|
|
312
415
|
onChange?: (doc: ElementNode) => void;
|
|
313
416
|
slug?: () => (text: string) => string;
|
|
@@ -321,6 +424,7 @@ interface EditorOptions {
|
|
|
321
424
|
mentionSource?: (query: string) => MentionCandidate[];
|
|
322
425
|
mentionProfile?: (id: string) => MentionProfile | null | undefined;
|
|
323
426
|
renderMath?: (latex: string, display: boolean) => string | null;
|
|
427
|
+
renderDiagram?: (lang: string, source: string) => string | Promise<string> | null;
|
|
324
428
|
invisibleCharacters?: boolean;
|
|
325
429
|
comments?: {
|
|
326
430
|
threads?: CommentThread[];
|
|
@@ -330,6 +434,27 @@ interface EditorOptions {
|
|
|
330
434
|
toc?: boolean | {
|
|
331
435
|
open?: boolean;
|
|
332
436
|
};
|
|
437
|
+
autofocus?: Autofocus;
|
|
438
|
+
search?: boolean;
|
|
439
|
+
sourceMode?: boolean;
|
|
440
|
+
source?: string;
|
|
441
|
+
focusMode?: boolean;
|
|
442
|
+
typewriterMode?: boolean;
|
|
443
|
+
spellcheck?: boolean;
|
|
444
|
+
checkboxLabel?: (checked: boolean) => string;
|
|
445
|
+
exitOnArrowUp?: boolean;
|
|
446
|
+
exitOnArrowDown?: boolean;
|
|
447
|
+
shouldAutoLink?: (url: string) => boolean;
|
|
448
|
+
versions?: boolean | {
|
|
449
|
+
seed?: DocVersion[];
|
|
450
|
+
max?: number;
|
|
451
|
+
onChange?: (versions: DocVersion[]) => void;
|
|
452
|
+
};
|
|
453
|
+
suggest?: boolean | {
|
|
454
|
+
author?: () => SuggestAuthor;
|
|
455
|
+
tracking?: boolean;
|
|
456
|
+
onChange?: (tracking: boolean) => void;
|
|
457
|
+
};
|
|
333
458
|
extensions?: Extension[];
|
|
334
459
|
slashCommands?: SlashCommand[] | (() => SlashCommand[] | undefined);
|
|
335
460
|
/**
|
|
@@ -342,14 +467,20 @@ interface EditorOptions {
|
|
|
342
467
|
* 实时协作(中心化 OT + WebSocket)。传 { url, room } 即连 Cloudflare worker 房间。
|
|
343
468
|
* 本地 dispatch 自动上行;远端 applyRemote。见 collab.md。
|
|
344
469
|
*/
|
|
345
|
-
collab?: CollabConfig
|
|
470
|
+
collab?: Omit<CollabConfig, 'onReplica'> & {
|
|
471
|
+
onState?: (state: {
|
|
472
|
+
doc: ElementNode;
|
|
473
|
+
replica: CollabReplica;
|
|
474
|
+
}) => void;
|
|
475
|
+
};
|
|
346
476
|
}
|
|
347
477
|
declare class Editor {
|
|
348
478
|
root: HTMLElement;
|
|
479
|
+
/** Preact 独占且 ≡ .markloom-doc;chrome 只挂 root,与投影不交 */
|
|
480
|
+
private surface;
|
|
349
481
|
history: History;
|
|
350
|
-
private
|
|
351
|
-
private
|
|
352
|
-
private pendingMarks;
|
|
482
|
+
private tx;
|
|
483
|
+
private afterCommit;
|
|
353
484
|
private opts;
|
|
354
485
|
private resolved;
|
|
355
486
|
private invisible;
|
|
@@ -357,7 +488,20 @@ declare class Editor {
|
|
|
357
488
|
private imageControls;
|
|
358
489
|
private commentPanel;
|
|
359
490
|
private tocPanel;
|
|
491
|
+
private searchBar;
|
|
492
|
+
private modes;
|
|
493
|
+
private sourceCtl;
|
|
494
|
+
private srcMd;
|
|
495
|
+
private versionsPanel;
|
|
496
|
+
private versionList;
|
|
497
|
+
private versionMax;
|
|
498
|
+
private suggestBar;
|
|
499
|
+
private suggestTracking;
|
|
500
|
+
/** 连续 insert / delete 各自 stream id,避免每键一条且插删串 id */
|
|
501
|
+
private suggestInsertId;
|
|
502
|
+
private suggestDeleteId;
|
|
360
503
|
private mentionPops;
|
|
504
|
+
private footnoteUi;
|
|
361
505
|
private decorations;
|
|
362
506
|
/** AI 一等公民(opts.ai):斜杠 / 格式栏 / 卡片全内置 */
|
|
363
507
|
private aiCtl;
|
|
@@ -365,30 +509,110 @@ declare class Editor {
|
|
|
365
509
|
private collabCtl;
|
|
366
510
|
private collabUi;
|
|
367
511
|
private applyingRemote;
|
|
512
|
+
private typing;
|
|
368
513
|
constructor(root: HTMLElement, doc: ElementNode, opts?: EditorOptions);
|
|
369
514
|
destroy(): void;
|
|
370
515
|
/** AI 控制器(opts.ai 启用时);应用工具栏可 ed.ai?.openAtFocus / stop */
|
|
371
516
|
get ai(): MarkloomAi | null;
|
|
372
517
|
/** 协作客户端(opts.collab 启用时) */
|
|
373
518
|
get collab(): CollabClient | null;
|
|
519
|
+
/** 源码模式(opts.sourceMode 时):切换 / 设定 / 当前是否在源码里 */
|
|
520
|
+
toggleSource(): void;
|
|
521
|
+
setSourceMode(on: boolean): void;
|
|
522
|
+
get inSourceMode(): boolean;
|
|
523
|
+
/** 现在文档的块 span 指向的那份原文:宿主 docToMd(doc, editor.source)。在源码里还没同步的字也算(同步在停手 300ms 后,或切回时)。 */
|
|
524
|
+
get source(): string;
|
|
525
|
+
/** 查找替换栏(opts.search 时) */
|
|
526
|
+
openSearch(): void;
|
|
527
|
+
closeSearch(): void;
|
|
528
|
+
/** 纯读:当前文档内命中(不依赖 UI) */
|
|
529
|
+
find(query: string, opts?: {
|
|
530
|
+
caseSensitive?: boolean;
|
|
531
|
+
}): TextMatch[];
|
|
532
|
+
/** 全部替换并 commit;返回命中数 */
|
|
533
|
+
replaceAllText(query: string, replacement: string, opts?: {
|
|
534
|
+
caseSensitive?: boolean;
|
|
535
|
+
}): number;
|
|
536
|
+
/** 命名版本 API(opts.versions) */
|
|
537
|
+
get versions(): {
|
|
538
|
+
list: () => DocVersion[];
|
|
539
|
+
save: (name?: string) => DocVersion;
|
|
540
|
+
restore: (id: string) => boolean;
|
|
541
|
+
remove: (id: string) => boolean;
|
|
542
|
+
open: () => void | undefined;
|
|
543
|
+
close: () => void | undefined;
|
|
544
|
+
} | null;
|
|
545
|
+
/** 修订/建议 API(opts.suggest) */
|
|
546
|
+
get suggest(): {
|
|
547
|
+
tracking: () => boolean;
|
|
548
|
+
setTracking: (on: boolean) => void;
|
|
549
|
+
open: () => void | undefined;
|
|
550
|
+
close: () => void | undefined;
|
|
551
|
+
markInsert: () => boolean;
|
|
552
|
+
markDelete: () => boolean;
|
|
553
|
+
accept: (id: string) => void | undefined;
|
|
554
|
+
reject: (id: string) => void | undefined;
|
|
555
|
+
} | null;
|
|
556
|
+
private saveVersion;
|
|
557
|
+
private restoreVersion;
|
|
558
|
+
private removeVersion;
|
|
559
|
+
private focusSearchMatch;
|
|
374
560
|
openAi(mode: 'continue' | 'rewrite'): void;
|
|
375
561
|
stopAi(): void;
|
|
376
562
|
get doc(): ElementNode;
|
|
563
|
+
/** 字数统计(Typora 口径:中日韩一字一词,英文按词;不含 front matter 和 HTML 原样块)。读一次遍历一遍,不缓存。 */
|
|
564
|
+
stats(): WordCount;
|
|
565
|
+
setFocusMode(on: boolean): void;
|
|
566
|
+
setTypewriterMode(on: boolean): void;
|
|
567
|
+
get focusMode(): boolean;
|
|
568
|
+
get typewriterMode(): boolean;
|
|
569
|
+
/** 运行时切拼写检查。undefined = 去掉属性,跟浏览器。 */
|
|
570
|
+
setSpellcheck(on: boolean | undefined): void;
|
|
377
571
|
setEditable(editable: boolean): void;
|
|
378
572
|
setInvisibleCharacters(visible: boolean): void;
|
|
379
573
|
get invisibleCharacters(): boolean;
|
|
380
574
|
get comments(): CommentThread[];
|
|
381
575
|
setComments(threads: CommentThread[]): void;
|
|
382
576
|
private get readonly();
|
|
577
|
+
private inlineDecos;
|
|
578
|
+
private setInlineDecos;
|
|
579
|
+
private leafDecos;
|
|
580
|
+
private topIds;
|
|
581
|
+
private blockCache;
|
|
383
582
|
private draw;
|
|
583
|
+
private onModesSelection;
|
|
584
|
+
private diagramCache;
|
|
585
|
+
private diagramPending;
|
|
586
|
+
private diagramLast;
|
|
587
|
+
private diagramTimers;
|
|
588
|
+
private destroyed;
|
|
589
|
+
private diagramState;
|
|
590
|
+
private syncDiagram;
|
|
384
591
|
private syncPlaceholder;
|
|
385
|
-
dispatch(steps: Step[], selectionAfter?: Selection
|
|
592
|
+
dispatch(steps: Step[], selectionAfter?: Selection, opts?: {
|
|
593
|
+
scroll?: boolean;
|
|
594
|
+
coalesce?: TypingKind;
|
|
595
|
+
}): void;
|
|
596
|
+
private plainCode;
|
|
386
597
|
dispatchStream(steps: Step[], selectionAfter?: Selection): void;
|
|
387
|
-
/**
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
598
|
+
/**
|
|
599
|
+
* 远端协作 op — 写路径唯一 foreign 入口:
|
|
600
|
+
* · 改 doc,不入 past/future(人员粒度)
|
|
601
|
+
* · OT 搬本端 undo/redo 栈
|
|
602
|
+
* · 不再 gapSteps(发送方 batch 已含 gap;本地再补会分叉)
|
|
603
|
+
* · 本端选区随 steps map(光标不被远端编辑挤飞)
|
|
604
|
+
*/
|
|
605
|
+
applyRemote(steps: Step[], foreignSite?: number, selectionAfter?: Selection): void;
|
|
606
|
+
/** 新副本或无 pending 的安全快照替换;清空本地 undo 栈。 */
|
|
607
|
+
replaceDoc(doc: ElementNode, opts?: {
|
|
608
|
+
notify?: boolean;
|
|
609
|
+
quiet?: boolean;
|
|
610
|
+
}): void;
|
|
611
|
+
/**
|
|
612
|
+
* 回退一笔**本端** history(AI discard / 协作人员粒度 undo)。
|
|
613
|
+
* 协作时 past 仅含本地提交;inverse 经 applyForeign 保持与远端交错后的坐标,再上行。
|
|
614
|
+
* restore before + scroll(与 redo 对称,无旁路选区通道)。
|
|
615
|
+
*/
|
|
392
616
|
undo(): boolean;
|
|
393
617
|
redo(): boolean;
|
|
394
618
|
/** 续写:当前块后插空段并流式灌入 */
|
|
@@ -396,12 +620,22 @@ declare class Editor {
|
|
|
396
620
|
/** 改写:清空当前块再流式回填 */
|
|
397
621
|
aiRewrite(blockId?: string): AiWriteSession;
|
|
398
622
|
private onCompositionStart;
|
|
623
|
+
private onRootMouseDown;
|
|
399
624
|
private onClick;
|
|
400
625
|
private onTaskCheck;
|
|
401
626
|
private openMentionPop;
|
|
402
627
|
private setMentionDate;
|
|
628
|
+
/**
|
|
629
|
+
* 仅清**格内**原生 ol/ul(CE 自动列表漏网)。
|
|
630
|
+
* 禁止碰顶层 list——那是 model 合法投影,误删 = 列表刚建就被扒掉、看起来「空格没反应」。
|
|
631
|
+
*/
|
|
632
|
+
private healCellNativeLists;
|
|
633
|
+
/** 事件来自根里、文档面之外的表单控件(查找栏、版本栏的输入框):它们自己处理输入,编辑器的管线不碰。 */
|
|
634
|
+
private fromControl;
|
|
635
|
+
private onDomInput;
|
|
636
|
+
/** 插空格并跑 inputRules:`1. `/`- ` → list;否则字面空格。CE 自动列表接管后走此路径。 */
|
|
637
|
+
private applySpaceWithRules;
|
|
403
638
|
private onBeforeInput;
|
|
404
|
-
/** caret 是否在 type=ai 块内;是则返该块,否则 null */
|
|
405
639
|
private aiBlockAt;
|
|
406
640
|
private aiBlockGuard;
|
|
407
641
|
/** 壳已不在的 aiDraft 顶层块 → 剥事务标记,恢复可编辑 */
|
|
@@ -414,6 +648,7 @@ declare class Editor {
|
|
|
414
648
|
private onEdgeVisualLine;
|
|
415
649
|
private atomAtEdgeVertical;
|
|
416
650
|
private atomSelectGuard;
|
|
651
|
+
private nestedAtomBefore;
|
|
417
652
|
private atomBlockGuard;
|
|
418
653
|
private neighborCaret;
|
|
419
654
|
private isCodeBlock;
|
|
@@ -423,13 +658,29 @@ declare class Editor {
|
|
|
423
658
|
private onCompositionEnd;
|
|
424
659
|
private onKeyDown;
|
|
425
660
|
private markSel;
|
|
661
|
+
private exclusiveAtomMd;
|
|
662
|
+
/**
|
|
663
|
+
* exclusive 图复制到系统剪贴板:text/plain=md(本编辑器粘贴)、text/html=<img>(富文本应用)、
|
|
664
|
+
* image/png=像素(预览/Finder/微信等)。表只写 md。
|
|
665
|
+
*/
|
|
666
|
+
private writeExclusiveClipboard;
|
|
426
667
|
private onCopy;
|
|
427
668
|
private onCut;
|
|
669
|
+
private static dragging;
|
|
670
|
+
private onDragStart;
|
|
671
|
+
private onDragEnd;
|
|
672
|
+
private onDrop;
|
|
673
|
+
private dropPoint;
|
|
674
|
+
private insertionAt;
|
|
428
675
|
private onPaste;
|
|
429
676
|
private insertImageFile;
|
|
430
677
|
private insertImageUrl;
|
|
678
|
+
private selectInsertedImage;
|
|
679
|
+
private asBlockPath;
|
|
431
680
|
private slashInsertImage;
|
|
432
681
|
private slashInsertMath;
|
|
682
|
+
/** 块在视口中的 rect;Path 顶层或格内均可;找不到则回退视口中上 */
|
|
683
|
+
private blockRect;
|
|
433
684
|
private slashInsertEmbed;
|
|
434
685
|
private editMathAtom;
|
|
435
686
|
private isEmptyTopPara;
|
|
@@ -528,4 +779,4 @@ declare class MarkloomAi {
|
|
|
528
779
|
private paintMd;
|
|
529
780
|
}
|
|
530
781
|
|
|
531
|
-
export {
|
|
782
|
+
export { atomIsSelected as $, type AiConfig as A, type BlockInputRule as B, CALLOUT_VARIANTS as C, type DecorationFactory as D, type EditorOptions as E, type InputRuleCtx as F, type Intent as G, type KeymapCtx as H, INLINE_PAIRS as I, type KeymapResult as J, type KeymapCommand as K, type MentionCandidate as L, MarkloomAi as M, type NodeView as N, type MentionHost as O, MentionMenu as P, MentionPopovers as Q, type MentionPopoversHost as R, type MentionProfile as S, type NodeViewCtx as T, type PasteRule as U, type RenderOpts as V, type Resolved as W, type SlashCommand as X, type TextStylePatch as Y, type TypedLink as Z, type TypedUrl as _, type AiPromptMode as a, autofocusSelection as a0, blockTransform as a1, blockTransformRange as a2, calloutVariantFromQuery as a3, caret as a4, chord as a5, clearMarks as a6, cycleCalloutVariant as a7, defaultBlockRenderers as a8, defaultBlockTag as a9, renderCode as aA, renderDoc as aB, renderEmbed as aC, renderHr as aD, renderImage as aE, renderTable as aF, renderToHtml as aG, resolve as aH, safeCssValue as aI, serializeBlock as aJ, serializeSelection as aK, setAlign as aL, setCalloutVariant as aM, setHeadingDepth as aN, setListType as aO, setTextStyle as aP, tableAbove as aQ, textStyleCss as aR, toggleMark as aS, toggleMarkList as aT, twitchChannel as aU, urlAutolink as aV, urlAutolinkRule as aW, wordBoundaryBack as aX, wordBoundaryFwd as aY, wrapList as aZ, youtubeId as a_, defaultMarkTag as aa, diffSpan as ab, expandToLink as ac, indentItem as ad, inlinePairRule as ae, isAtom as af, isCellBlockKind as ag, isOpaque as ah, joinPrevList as ai, keepsApart as aj, leafBlockPath as ak, leafText as al, lineBoundaryBack as am, lineBoundaryFwd as an, mapInput as ao, mapPaste as ap, mapPasteBlocks as aq, markdownLinkRule as ar, marksAtCaret as as, matchInlinePair as at, mergeTextStyleAttrs as au, nearestListPath as av, outdentItem as aw, parseTypedLink as ax, parseTypedUrl as ay, projectDoc as az, type AiProvider as b, type AiStreamFn as c, type AiStreamInput as d, type AiWriteMode as e, type AiWriteSession as f, type MarkloomAiOpts as g, blockPlainText as h, createAiStream as i, focusBlockId as j, Editor as k, type Extension as l, type AtomSelectCtx as m, type Autofocus as n, type BlockKind as o, type BlockRenderCtx as p, type BlockRenderer as q, type BlockVnodeCache as r, startAiWrite as s, type CalloutVariant as t, type DecorationHost as u, type DiagramResolver as v, type DiagramState as w, type InlineDeco as x, type InlinePairHit as y, type InputResult as z };
|