markloom 0.5.0 → 0.6.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.
Files changed (67) hide show
  1. package/PACKAGES.md +26 -0
  2. package/README.md +20 -2
  3. package/collab.md +44 -7
  4. package/dist/ai/index.cjs +4 -4
  5. package/dist/ai/index.d.cts +5 -4
  6. package/dist/ai/index.d.ts +5 -4
  7. package/dist/ai/index.js +3 -3
  8. package/dist/ai/theme.css +66 -102
  9. package/dist/{chunk-YJAWPRJW.cjs → chunk-ACFYBYZJ.cjs} +2817 -903
  10. package/dist/chunk-CGYCJORO.js +759 -0
  11. package/dist/chunk-EADZKEU4.cjs +498 -0
  12. package/dist/chunk-EJSFZHGT.js +24 -0
  13. package/dist/{chunk-SLRD6FMP.cjs → chunk-I5VK4U7J.cjs} +122 -73
  14. package/dist/{chunk-WUHTCCAE.js → chunk-KYZJIOOL.js} +2403 -489
  15. package/dist/chunk-QEVME6ZU.cjs +759 -0
  16. package/dist/{chunk-MFYF2A6U.js → chunk-SNFF6X45.js} +51 -1
  17. package/dist/{chunk-JMOJU5EU.js → chunk-TB2OY3D4.js} +69 -20
  18. package/dist/{chunk-4TMHVNL6.cjs → chunk-TWD5T4YC.cjs} +155 -105
  19. package/dist/{chunk-JS527FDV.cjs → chunk-U3JZDFL4.cjs} +49 -9
  20. package/dist/{chunk-RLTHVQNQ.js → chunk-VSBIMMI7.js} +45 -5
  21. package/dist/chunk-YBAT343I.js +498 -0
  22. package/dist/chunk-ZKQSQSSM.cjs +24 -0
  23. package/dist/{client-BNams4wv.d.cts → client-CLYq17SW.d.ts} +70 -7
  24. package/dist/{client-A0ZQJnyR.d.ts → client-DAth8pPq.d.cts} +70 -7
  25. package/dist/collab/index.cjs +22 -4
  26. package/dist/collab/index.d.cts +24 -3
  27. package/dist/collab/index.d.ts +24 -3
  28. package/dist/collab/index.js +24 -6
  29. package/dist/{controller-BkY1VPzc.d.ts → controller-6AJ36G52.d.ts} +108 -8
  30. package/dist/{controller-CVIZI--A.d.cts → controller-BIOO_XKJ.d.cts} +108 -8
  31. package/dist/index.cjs +57 -7
  32. package/dist/index.d.cts +18 -5
  33. package/dist/index.d.ts +18 -5
  34. package/dist/index.js +54 -4
  35. package/dist/io/index.cjs +1413 -0
  36. package/dist/io/index.d.cts +33 -0
  37. package/dist/io/index.d.ts +33 -0
  38. package/dist/io/index.js +1413 -0
  39. package/dist/react/index.cjs +8 -8
  40. package/dist/react/index.d.cts +5 -4
  41. package/dist/react/index.d.ts +5 -4
  42. package/dist/react/index.js +7 -7
  43. package/dist/{rebase-batch-8rL_aXEE.d.ts → rebase-batch-DlerAcFN.d.ts} +11 -9
  44. package/dist/{rebase-batch-bYnBJpRO.d.cts → rebase-batch-PjENQ742.d.cts} +11 -9
  45. package/dist/suggest-Bk4zLzuv.d.ts +120 -0
  46. package/dist/suggest-BkGGiPKA.d.cts +120 -0
  47. package/dist/types-COUweEav.d.cts +30 -0
  48. package/dist/types-COUweEav.d.ts +30 -0
  49. package/dist/versions-9mG1epfB.d.cts +51 -0
  50. package/dist/versions-Bubyo4pt.d.ts +51 -0
  51. package/dist/view/index.cjs +56 -12
  52. package/dist/view/index.d.cts +203 -11
  53. package/dist/view/index.d.ts +203 -11
  54. package/dist/view/index.js +52 -8
  55. package/dist/view/theme.css +1840 -1526
  56. package/io.md +38 -0
  57. package/package.json +21 -5
  58. package/dist/chunk-6DCI7AL3.js +0 -208
  59. package/dist/chunk-AC5E42NH.cjs +0 -208
  60. package/dist/chunk-GQ2HHRGI.cjs +0 -16
  61. package/dist/chunk-LA5SBCGQ.js +0 -16
  62. package/dist/chunk-LEYAQNJA.js +0 -220
  63. package/dist/chunk-YXQDCW4Y.cjs +0 -220
  64. package/dist/comments-DlExS6f-.d.cts +0 -43
  65. package/dist/comments-PhnR7Gkn.d.ts +0 -43
  66. package/dist/step-BrvHIK7O.d.cts +0 -65
  67. package/dist/step-BrvHIK7O.d.ts +0 -65
@@ -1,8 +1,9 @@
1
- import { E as ElementNode, S as Step, c as Selection, M as Mark, P as Path, N as Node } from './step-BrvHIK7O.js';
1
+ import { S as Step, a as DocVersion } from './versions-Bubyo4pt.js';
2
+ import { E as ElementNode, S as Selection, M as Mark, P as Path, N as Node } from './types-COUweEav.js';
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 './comments-PhnR7Gkn.js';
5
- import { d as CollabConfig, c as CollabClient } from './client-A0ZQJnyR.js';
5
+ import { H as History, c as CommentThread, C as CommentAuthor, e as SuggestAuthor, T as TextMatch } from './suggest-Bk4zLzuv.js';
6
+ import { d as CollabConfig, c as CollabClient } from './client-CLYq17SW.js';
6
7
 
7
8
  interface MentionCandidate {
8
9
  id: string;
@@ -39,6 +40,8 @@ interface NodeViewCtx {
39
40
  node: ElementNode;
40
41
  text: string;
41
42
  key: number | string;
43
+ /** false = 只读/SSG:不投语言切换等编辑 affordance */
44
+ editable?: boolean;
42
45
  }
43
46
  interface NodeView {
44
47
  render: (ctx: NodeViewCtx) => ComponentChild;
@@ -65,6 +68,7 @@ interface RenderOpts {
65
68
  activeId: string | null;
66
69
  };
67
70
  atomSelect?: AtomSelectCtx | null;
71
+ editable?: boolean;
68
72
  }
69
73
  declare const defaultBlockTag: Record<string, string>;
70
74
  declare const defaultMarkTag: Record<string, string>;
@@ -78,6 +82,11 @@ declare function renderCode(spec: ElementNode, key: number | string, ctx: BlockR
78
82
  declare function renderTable(spec: ElementNode, key: number | string, ctx: BlockRenderCtx): ComponentChild;
79
83
  declare function renderHr(spec: ElementNode, key: number | string, ctx: BlockRenderCtx): ComponentChild;
80
84
  declare const defaultBlockRenderers: Record<string, BlockRenderer>;
85
+ /** Doc → 投影壳 class + 块 vnode。Editor 的 surface ≡ .markloom-doc 只吃 children;SSG 再包一层 div。 */
86
+ declare function projectDoc(doc: ElementNode, opts?: RenderOpts): {
87
+ className: string;
88
+ children: ComponentChild[];
89
+ };
81
90
  declare function renderDoc(doc: ElementNode, opts?: RenderOpts): preact.VNode<preact.ClassAttributes<HTMLElement> & {
82
91
  class: string;
83
92
  'data-markloom': boolean;
@@ -121,6 +130,8 @@ type TextStylePatch = {
121
130
  declare function mergeTextStyleAttrs(attrs: Record<string, unknown> | undefined, patch: TextStylePatch): Record<string, unknown> | null;
122
131
  declare function setTextStyle(doc: ElementNode, sel: Selection, patch: TextStylePatch): InputResult | null;
123
132
  declare function serializeSelection(doc: ElementNode, sel: Selection): string;
133
+ /** 块级 atom 选中态(图/embed/表 exclusive)→ md。path 须为顶层 [idx]。 */
134
+ declare function serializeBlock(doc: ElementNode, path: Path): string | null;
124
135
  declare function mapPaste(doc: ElementNode, sel: Selection, md: string, newId: () => string): InputResult | null;
125
136
  declare function mapPasteBlocks(doc: ElementNode, sel: Selection, frag: ElementNode[], newId: () => string): InputResult | null;
126
137
  declare function indentItem(doc: ElementNode, sel: Selection, newId: () => string): InputResult | null;
@@ -131,6 +142,7 @@ interface BlockRenderCtx {
131
142
  slug?: (text: string) => string;
132
143
  codeView?: NodeView;
133
144
  atomSelect?: AtomSelectCtx | null;
145
+ editable?: boolean;
134
146
  }
135
147
  type BlockRenderer = (spec: ElementNode, key: number | string, ctx: BlockRenderCtx) => ComponentChild;
136
148
  interface InputRuleCtx {
@@ -302,6 +314,7 @@ declare class MentionPopovers {
302
314
  openDate(iso: string, path: number[], anchor: DOMRect): void;
303
315
  private onDocDown;
304
316
  private onKey;
317
+ private applyDate;
305
318
  private paint;
306
319
  private placePop;
307
320
  private paintPerson;
@@ -330,6 +343,17 @@ interface EditorOptions {
330
343
  toc?: boolean | {
331
344
  open?: boolean;
332
345
  };
346
+ search?: boolean;
347
+ versions?: boolean | {
348
+ seed?: DocVersion[];
349
+ max?: number;
350
+ onChange?: (versions: DocVersion[]) => void;
351
+ };
352
+ suggest?: boolean | {
353
+ author?: () => SuggestAuthor;
354
+ tracking?: boolean;
355
+ onChange?: (tracking: boolean) => void;
356
+ };
333
357
  extensions?: Extension[];
334
358
  slashCommands?: SlashCommand[] | (() => SlashCommand[] | undefined);
335
359
  /**
@@ -346,6 +370,8 @@ interface EditorOptions {
346
370
  }
347
371
  declare class Editor {
348
372
  root: HTMLElement;
373
+ /** Preact 独占且 ≡ .markloom-doc;chrome 只挂 root,与投影不交 */
374
+ private surface;
349
375
  history: History;
350
376
  private composing;
351
377
  private composeBase;
@@ -357,12 +383,22 @@ declare class Editor {
357
383
  private imageControls;
358
384
  private commentPanel;
359
385
  private tocPanel;
386
+ private searchBar;
387
+ private versionsPanel;
388
+ private versionList;
389
+ private versionMax;
390
+ private suggestBar;
391
+ private suggestTracking;
392
+ /** 连续 insert / delete 各自 stream id,避免每键一条且插删串 id */
393
+ private suggestInsertId;
394
+ private suggestDeleteId;
360
395
  private mentionPops;
361
396
  private decorations;
362
397
  /** AI 一等公民(opts.ai):斜杠 / 格式栏 / 卡片全内置 */
363
398
  private aiCtl;
364
399
  /** 协作会话;applyingRemote 期间本地 steps 不上行 */
365
400
  private collabCtl;
401
+ private collabUi;
366
402
  private applyingRemote;
367
403
  constructor(root: HTMLElement, doc: ElementNode, opts?: EditorOptions);
368
404
  destroy(): void;
@@ -370,6 +406,41 @@ declare class Editor {
370
406
  get ai(): MarkloomAi | null;
371
407
  /** 协作客户端(opts.collab 启用时) */
372
408
  get collab(): CollabClient | null;
409
+ /** 查找替换栏(opts.search 时) */
410
+ openSearch(): void;
411
+ closeSearch(): void;
412
+ /** 纯读:当前文档内命中(不依赖 UI) */
413
+ find(query: string, opts?: {
414
+ caseSensitive?: boolean;
415
+ }): TextMatch[];
416
+ /** 全部替换并 commit;返回命中数 */
417
+ replaceAllText(query: string, replacement: string, opts?: {
418
+ caseSensitive?: boolean;
419
+ }): number;
420
+ /** 命名版本 API(opts.versions) */
421
+ get versions(): {
422
+ list: () => DocVersion[];
423
+ save: (name?: string) => DocVersion;
424
+ restore: (id: string) => boolean;
425
+ remove: (id: string) => boolean;
426
+ open: () => void | undefined;
427
+ close: () => void | undefined;
428
+ } | null;
429
+ /** 修订/建议 API(opts.suggest) */
430
+ get suggest(): {
431
+ tracking: () => boolean;
432
+ setTracking: (on: boolean) => void;
433
+ open: () => void | undefined;
434
+ close: () => void | undefined;
435
+ markInsert: () => boolean;
436
+ markDelete: () => boolean;
437
+ accept: (id: string) => void | undefined;
438
+ reject: (id: string) => void | undefined;
439
+ } | null;
440
+ private saveVersion;
441
+ private restoreVersion;
442
+ private removeVersion;
443
+ private focusSearchMatch;
373
444
  openAi(mode: 'continue' | 'rewrite'): void;
374
445
  stopAi(): void;
375
446
  get doc(): ElementNode;
@@ -383,11 +454,23 @@ declare class Editor {
383
454
  private syncPlaceholder;
384
455
  dispatch(steps: Step[], selectionAfter?: Selection): void;
385
456
  dispatchStream(steps: Step[], selectionAfter?: Selection): void;
386
- /** 远端协作 op:写入 model 但不上行 */
387
- applyRemote(steps: Step[], selectionAfter?: Selection): void;
457
+ /**
458
+ * 远端协作 op — 写路径唯一 foreign 入口:
459
+ * · 改 doc,不入 past/future(人员粒度)
460
+ * · OT 搬本端 undo/redo 栈
461
+ * · 不再 gapSteps(发送方 batch 已含 gap;本地再补会分叉)
462
+ * · 本端选区随 steps map(光标不被远端编辑挤飞)
463
+ */
464
+ applyRemote(steps: Step[], foreignSite?: number, selectionAfter?: Selection): void;
388
465
  /** 权威快照替换(welcome/resync);清空本地 undo 栈 */
389
466
  replaceDoc(doc: ElementNode): void;
390
- /** 回退一笔 history(AI 事务 discard = undo 整笔) */
467
+ /** 协作快照是否实质为空(仅空段) */
468
+ private isSparseCollabDoc;
469
+ /**
470
+ * 回退一笔**本端** history(AI discard / 协作人员粒度 undo)。
471
+ * 协作时 past 仅含本地提交;inverse 经 applyForeign 保持与远端交错后的坐标,再上行。
472
+ * restore before + scroll(与 redo 对称,无旁路选区通道)。
473
+ */
391
474
  undo(): boolean;
392
475
  redo(): boolean;
393
476
  /** 续写:当前块后插空段并流式灌入 */
@@ -395,6 +478,7 @@ declare class Editor {
395
478
  /** 改写:清空当前块再流式回填 */
396
479
  aiRewrite(blockId?: string): AiWriteSession;
397
480
  private onCompositionStart;
481
+ private onRootMouseDown;
398
482
  private onClick;
399
483
  private onTaskCheck;
400
484
  private openMentionPop;
@@ -403,6 +487,8 @@ declare class Editor {
403
487
  /** caret 是否在 type=ai 块内;是则返该块,否则 null */
404
488
  private aiBlockAt;
405
489
  private aiBlockGuard;
490
+ /** 壳已不在的 aiDraft 顶层块 → 剥事务标记,恢复可编辑 */
491
+ private promoteOrphanAiDrafts;
406
492
  private codeEdge;
407
493
  private codeBlockGuard;
408
494
  private atomControls;
@@ -420,13 +506,22 @@ declare class Editor {
420
506
  private onCompositionEnd;
421
507
  private onKeyDown;
422
508
  private markSel;
509
+ private exclusiveAtomMd;
510
+ /**
511
+ * exclusive 图复制到系统剪贴板:text/plain=md(本编辑器粘贴)、text/html=<img>(富文本应用)、
512
+ * image/png=像素(预览/Finder/微信等)。表只写 md。
513
+ */
514
+ private writeExclusiveClipboard;
423
515
  private onCopy;
424
516
  private onCut;
425
517
  private onPaste;
426
518
  private insertImageFile;
427
519
  private insertImageUrl;
520
+ private selectInsertedImage;
428
521
  private slashInsertImage;
429
522
  private slashInsertMath;
523
+ /** 顶层块在视口中的 rect;找不到则回退视口中上 */
524
+ private blockRect;
430
525
  private slashInsertEmbed;
431
526
  private editMathAtom;
432
527
  private isEmptyTopPara;
@@ -506,8 +601,13 @@ declare class MarkloomAi {
506
601
  * 走 amend,与 begin/stream 同一笔 undo。
507
602
  */
508
603
  accept(blockId: string): void;
509
- /** 整笔撤回事务(= undo) */
604
+ /** 整笔撤回事务(= undo);务必不留 aiDraft 孤儿段 */
510
605
  discard(blockId: string): void;
606
+ /**
607
+ * 清掉 aiFrom=blockId 的顶层 draft;shell=true 时把 ai 壳也换成空段。
608
+ * discard / 异常恢复共用。
609
+ */
610
+ private purgeDrafts;
511
611
  act(blockId: string, action: string): void;
512
612
  private rollback;
513
613
  private findAi;
@@ -520,4 +620,4 @@ declare class MarkloomAi {
520
620
  private paintMd;
521
621
  }
522
622
 
523
- export { diffSpan as $, type AiConfig as A, type BlockInputRule as B, CALLOUT_VARIANTS as C, type DecorationFactory as D, type EditorOptions as E, MentionPopovers as F, type MentionPopoversHost as G, type MentionProfile as H, type InputResult as I, type NodeViewCtx as J, type KeymapCommand as K, type Resolved as L, MarkloomAi as M, type NodeView as N, atomIsSelected as O, type PasteRule as P, blockTransform as Q, type RenderOpts as R, type SlashCommand as S, type TextStylePatch as T, calloutVariantFromQuery as U, caret as V, chord as W, cycleCalloutVariant as X, defaultBlockRenderers as Y, defaultBlockTag as Z, defaultMarkTag as _, type AiPromptMode as a, indentItem as a0, isAtom as a1, isOpaque as a2, leafText as a3, lineBoundaryBack as a4, lineBoundaryFwd as a5, mapInput as a6, mapPaste as a7, mapPasteBlocks as a8, marksAtCaret as a9, mergeTextStyleAttrs as aa, outdentItem as ab, renderCode as ac, renderDoc as ad, renderEmbed as ae, renderHr as af, renderImage as ag, renderTable as ah, renderToHtml as ai, resolve as aj, safeCssValue as ak, serializeSelection as al, setAlign as am, setCalloutVariant as an, setTextStyle as ao, textStyleCss as ap, toggleMark as aq, toggleMarkList as ar, twitchChannel as as, wordBoundaryBack as at, wordBoundaryFwd as au, wrapList as av, youtubeId as aw, 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 BlockKind as n, type BlockRenderCtx as o, type BlockRenderer as p, type CalloutVariant as q, type DecorationHost as r, startAiWrite as s, type InputRuleCtx as t, type Intent as u, type KeymapCtx as v, type KeymapResult as w, type MentionCandidate as x, type MentionHost as y, MentionMenu as z };
623
+ export { diffSpan as $, type AiConfig as A, type BlockInputRule as B, CALLOUT_VARIANTS as C, type DecorationFactory as D, type EditorOptions as E, MentionPopovers as F, type MentionPopoversHost as G, type MentionProfile as H, type InputResult as I, type NodeViewCtx as J, type KeymapCommand as K, type Resolved as L, MarkloomAi as M, type NodeView as N, atomIsSelected as O, type PasteRule as P, blockTransform as Q, type RenderOpts as R, type SlashCommand as S, type TextStylePatch as T, calloutVariantFromQuery as U, caret as V, chord as W, cycleCalloutVariant as X, defaultBlockRenderers as Y, defaultBlockTag as Z, defaultMarkTag as _, type AiPromptMode as a, indentItem as a0, isAtom as a1, isOpaque as a2, leafText as a3, lineBoundaryBack as a4, lineBoundaryFwd as a5, mapInput as a6, mapPaste as a7, mapPasteBlocks as a8, marksAtCaret as a9, mergeTextStyleAttrs as aa, outdentItem as ab, projectDoc as ac, renderCode as ad, renderDoc as ae, renderEmbed as af, renderHr as ag, renderImage as ah, renderTable as ai, renderToHtml as aj, resolve as ak, safeCssValue as al, serializeBlock as am, serializeSelection as an, setAlign as ao, setCalloutVariant as ap, setTextStyle as aq, textStyleCss as ar, toggleMark as as, toggleMarkList as at, twitchChannel as au, wordBoundaryBack as av, wordBoundaryFwd as aw, wrapList as ax, youtubeId as ay, 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 BlockKind as n, type BlockRenderCtx as o, type BlockRenderer as p, type CalloutVariant as q, type DecorationHost as r, startAiWrite as s, type InputRuleCtx as t, type Intent as u, type KeymapCtx as v, type KeymapResult as w, type MentionCandidate as x, type MentionHost as y, MentionMenu as z };
@@ -1,8 +1,9 @@
1
- import { E as ElementNode, S as Step, c as Selection, M as Mark, P as Path, N as Node } from './step-BrvHIK7O.cjs';
1
+ import { S as Step, a as DocVersion } from './versions-9mG1epfB.cjs';
2
+ import { E as ElementNode, S as Selection, M as Mark, P as Path, N as Node } from './types-COUweEav.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 './comments-DlExS6f-.cjs';
5
- import { d as CollabConfig, c as CollabClient } from './client-BNams4wv.cjs';
5
+ import { H as History, c as CommentThread, C as CommentAuthor, e as SuggestAuthor, T as TextMatch } from './suggest-BkGGiPKA.cjs';
6
+ import { d as CollabConfig, c as CollabClient } from './client-DAth8pPq.cjs';
6
7
 
7
8
  interface MentionCandidate {
8
9
  id: string;
@@ -39,6 +40,8 @@ interface NodeViewCtx {
39
40
  node: ElementNode;
40
41
  text: string;
41
42
  key: number | string;
43
+ /** false = 只读/SSG:不投语言切换等编辑 affordance */
44
+ editable?: boolean;
42
45
  }
43
46
  interface NodeView {
44
47
  render: (ctx: NodeViewCtx) => ComponentChild;
@@ -65,6 +68,7 @@ interface RenderOpts {
65
68
  activeId: string | null;
66
69
  };
67
70
  atomSelect?: AtomSelectCtx | null;
71
+ editable?: boolean;
68
72
  }
69
73
  declare const defaultBlockTag: Record<string, string>;
70
74
  declare const defaultMarkTag: Record<string, string>;
@@ -78,6 +82,11 @@ declare function renderCode(spec: ElementNode, key: number | string, ctx: BlockR
78
82
  declare function renderTable(spec: ElementNode, key: number | string, ctx: BlockRenderCtx): ComponentChild;
79
83
  declare function renderHr(spec: ElementNode, key: number | string, ctx: BlockRenderCtx): ComponentChild;
80
84
  declare const defaultBlockRenderers: Record<string, BlockRenderer>;
85
+ /** Doc → 投影壳 class + 块 vnode。Editor 的 surface ≡ .markloom-doc 只吃 children;SSG 再包一层 div。 */
86
+ declare function projectDoc(doc: ElementNode, opts?: RenderOpts): {
87
+ className: string;
88
+ children: ComponentChild[];
89
+ };
81
90
  declare function renderDoc(doc: ElementNode, opts?: RenderOpts): preact.VNode<preact.ClassAttributes<HTMLElement> & {
82
91
  class: string;
83
92
  'data-markloom': boolean;
@@ -121,6 +130,8 @@ type TextStylePatch = {
121
130
  declare function mergeTextStyleAttrs(attrs: Record<string, unknown> | undefined, patch: TextStylePatch): Record<string, unknown> | null;
122
131
  declare function setTextStyle(doc: ElementNode, sel: Selection, patch: TextStylePatch): InputResult | null;
123
132
  declare function serializeSelection(doc: ElementNode, sel: Selection): string;
133
+ /** 块级 atom 选中态(图/embed/表 exclusive)→ md。path 须为顶层 [idx]。 */
134
+ declare function serializeBlock(doc: ElementNode, path: Path): string | null;
124
135
  declare function mapPaste(doc: ElementNode, sel: Selection, md: string, newId: () => string): InputResult | null;
125
136
  declare function mapPasteBlocks(doc: ElementNode, sel: Selection, frag: ElementNode[], newId: () => string): InputResult | null;
126
137
  declare function indentItem(doc: ElementNode, sel: Selection, newId: () => string): InputResult | null;
@@ -131,6 +142,7 @@ interface BlockRenderCtx {
131
142
  slug?: (text: string) => string;
132
143
  codeView?: NodeView;
133
144
  atomSelect?: AtomSelectCtx | null;
145
+ editable?: boolean;
134
146
  }
135
147
  type BlockRenderer = (spec: ElementNode, key: number | string, ctx: BlockRenderCtx) => ComponentChild;
136
148
  interface InputRuleCtx {
@@ -302,6 +314,7 @@ declare class MentionPopovers {
302
314
  openDate(iso: string, path: number[], anchor: DOMRect): void;
303
315
  private onDocDown;
304
316
  private onKey;
317
+ private applyDate;
305
318
  private paint;
306
319
  private placePop;
307
320
  private paintPerson;
@@ -330,6 +343,17 @@ interface EditorOptions {
330
343
  toc?: boolean | {
331
344
  open?: boolean;
332
345
  };
346
+ search?: boolean;
347
+ versions?: boolean | {
348
+ seed?: DocVersion[];
349
+ max?: number;
350
+ onChange?: (versions: DocVersion[]) => void;
351
+ };
352
+ suggest?: boolean | {
353
+ author?: () => SuggestAuthor;
354
+ tracking?: boolean;
355
+ onChange?: (tracking: boolean) => void;
356
+ };
333
357
  extensions?: Extension[];
334
358
  slashCommands?: SlashCommand[] | (() => SlashCommand[] | undefined);
335
359
  /**
@@ -346,6 +370,8 @@ interface EditorOptions {
346
370
  }
347
371
  declare class Editor {
348
372
  root: HTMLElement;
373
+ /** Preact 独占且 ≡ .markloom-doc;chrome 只挂 root,与投影不交 */
374
+ private surface;
349
375
  history: History;
350
376
  private composing;
351
377
  private composeBase;
@@ -357,12 +383,22 @@ declare class Editor {
357
383
  private imageControls;
358
384
  private commentPanel;
359
385
  private tocPanel;
386
+ private searchBar;
387
+ private versionsPanel;
388
+ private versionList;
389
+ private versionMax;
390
+ private suggestBar;
391
+ private suggestTracking;
392
+ /** 连续 insert / delete 各自 stream id,避免每键一条且插删串 id */
393
+ private suggestInsertId;
394
+ private suggestDeleteId;
360
395
  private mentionPops;
361
396
  private decorations;
362
397
  /** AI 一等公民(opts.ai):斜杠 / 格式栏 / 卡片全内置 */
363
398
  private aiCtl;
364
399
  /** 协作会话;applyingRemote 期间本地 steps 不上行 */
365
400
  private collabCtl;
401
+ private collabUi;
366
402
  private applyingRemote;
367
403
  constructor(root: HTMLElement, doc: ElementNode, opts?: EditorOptions);
368
404
  destroy(): void;
@@ -370,6 +406,41 @@ declare class Editor {
370
406
  get ai(): MarkloomAi | null;
371
407
  /** 协作客户端(opts.collab 启用时) */
372
408
  get collab(): CollabClient | null;
409
+ /** 查找替换栏(opts.search 时) */
410
+ openSearch(): void;
411
+ closeSearch(): void;
412
+ /** 纯读:当前文档内命中(不依赖 UI) */
413
+ find(query: string, opts?: {
414
+ caseSensitive?: boolean;
415
+ }): TextMatch[];
416
+ /** 全部替换并 commit;返回命中数 */
417
+ replaceAllText(query: string, replacement: string, opts?: {
418
+ caseSensitive?: boolean;
419
+ }): number;
420
+ /** 命名版本 API(opts.versions) */
421
+ get versions(): {
422
+ list: () => DocVersion[];
423
+ save: (name?: string) => DocVersion;
424
+ restore: (id: string) => boolean;
425
+ remove: (id: string) => boolean;
426
+ open: () => void | undefined;
427
+ close: () => void | undefined;
428
+ } | null;
429
+ /** 修订/建议 API(opts.suggest) */
430
+ get suggest(): {
431
+ tracking: () => boolean;
432
+ setTracking: (on: boolean) => void;
433
+ open: () => void | undefined;
434
+ close: () => void | undefined;
435
+ markInsert: () => boolean;
436
+ markDelete: () => boolean;
437
+ accept: (id: string) => void | undefined;
438
+ reject: (id: string) => void | undefined;
439
+ } | null;
440
+ private saveVersion;
441
+ private restoreVersion;
442
+ private removeVersion;
443
+ private focusSearchMatch;
373
444
  openAi(mode: 'continue' | 'rewrite'): void;
374
445
  stopAi(): void;
375
446
  get doc(): ElementNode;
@@ -383,11 +454,23 @@ declare class Editor {
383
454
  private syncPlaceholder;
384
455
  dispatch(steps: Step[], selectionAfter?: Selection): void;
385
456
  dispatchStream(steps: Step[], selectionAfter?: Selection): void;
386
- /** 远端协作 op:写入 model 但不上行 */
387
- applyRemote(steps: Step[], selectionAfter?: Selection): void;
457
+ /**
458
+ * 远端协作 op — 写路径唯一 foreign 入口:
459
+ * · 改 doc,不入 past/future(人员粒度)
460
+ * · OT 搬本端 undo/redo 栈
461
+ * · 不再 gapSteps(发送方 batch 已含 gap;本地再补会分叉)
462
+ * · 本端选区随 steps map(光标不被远端编辑挤飞)
463
+ */
464
+ applyRemote(steps: Step[], foreignSite?: number, selectionAfter?: Selection): void;
388
465
  /** 权威快照替换(welcome/resync);清空本地 undo 栈 */
389
466
  replaceDoc(doc: ElementNode): void;
390
- /** 回退一笔 history(AI 事务 discard = undo 整笔) */
467
+ /** 协作快照是否实质为空(仅空段) */
468
+ private isSparseCollabDoc;
469
+ /**
470
+ * 回退一笔**本端** history(AI discard / 协作人员粒度 undo)。
471
+ * 协作时 past 仅含本地提交;inverse 经 applyForeign 保持与远端交错后的坐标,再上行。
472
+ * restore before + scroll(与 redo 对称,无旁路选区通道)。
473
+ */
391
474
  undo(): boolean;
392
475
  redo(): boolean;
393
476
  /** 续写:当前块后插空段并流式灌入 */
@@ -395,6 +478,7 @@ declare class Editor {
395
478
  /** 改写:清空当前块再流式回填 */
396
479
  aiRewrite(blockId?: string): AiWriteSession;
397
480
  private onCompositionStart;
481
+ private onRootMouseDown;
398
482
  private onClick;
399
483
  private onTaskCheck;
400
484
  private openMentionPop;
@@ -403,6 +487,8 @@ declare class Editor {
403
487
  /** caret 是否在 type=ai 块内;是则返该块,否则 null */
404
488
  private aiBlockAt;
405
489
  private aiBlockGuard;
490
+ /** 壳已不在的 aiDraft 顶层块 → 剥事务标记,恢复可编辑 */
491
+ private promoteOrphanAiDrafts;
406
492
  private codeEdge;
407
493
  private codeBlockGuard;
408
494
  private atomControls;
@@ -420,13 +506,22 @@ declare class Editor {
420
506
  private onCompositionEnd;
421
507
  private onKeyDown;
422
508
  private markSel;
509
+ private exclusiveAtomMd;
510
+ /**
511
+ * exclusive 图复制到系统剪贴板:text/plain=md(本编辑器粘贴)、text/html=<img>(富文本应用)、
512
+ * image/png=像素(预览/Finder/微信等)。表只写 md。
513
+ */
514
+ private writeExclusiveClipboard;
423
515
  private onCopy;
424
516
  private onCut;
425
517
  private onPaste;
426
518
  private insertImageFile;
427
519
  private insertImageUrl;
520
+ private selectInsertedImage;
428
521
  private slashInsertImage;
429
522
  private slashInsertMath;
523
+ /** 顶层块在视口中的 rect;找不到则回退视口中上 */
524
+ private blockRect;
430
525
  private slashInsertEmbed;
431
526
  private editMathAtom;
432
527
  private isEmptyTopPara;
@@ -506,8 +601,13 @@ declare class MarkloomAi {
506
601
  * 走 amend,与 begin/stream 同一笔 undo。
507
602
  */
508
603
  accept(blockId: string): void;
509
- /** 整笔撤回事务(= undo) */
604
+ /** 整笔撤回事务(= undo);务必不留 aiDraft 孤儿段 */
510
605
  discard(blockId: string): void;
606
+ /**
607
+ * 清掉 aiFrom=blockId 的顶层 draft;shell=true 时把 ai 壳也换成空段。
608
+ * discard / 异常恢复共用。
609
+ */
610
+ private purgeDrafts;
511
611
  act(blockId: string, action: string): void;
512
612
  private rollback;
513
613
  private findAi;
@@ -520,4 +620,4 @@ declare class MarkloomAi {
520
620
  private paintMd;
521
621
  }
522
622
 
523
- export { diffSpan as $, type AiConfig as A, type BlockInputRule as B, CALLOUT_VARIANTS as C, type DecorationFactory as D, type EditorOptions as E, MentionPopovers as F, type MentionPopoversHost as G, type MentionProfile as H, type InputResult as I, type NodeViewCtx as J, type KeymapCommand as K, type Resolved as L, MarkloomAi as M, type NodeView as N, atomIsSelected as O, type PasteRule as P, blockTransform as Q, type RenderOpts as R, type SlashCommand as S, type TextStylePatch as T, calloutVariantFromQuery as U, caret as V, chord as W, cycleCalloutVariant as X, defaultBlockRenderers as Y, defaultBlockTag as Z, defaultMarkTag as _, type AiPromptMode as a, indentItem as a0, isAtom as a1, isOpaque as a2, leafText as a3, lineBoundaryBack as a4, lineBoundaryFwd as a5, mapInput as a6, mapPaste as a7, mapPasteBlocks as a8, marksAtCaret as a9, mergeTextStyleAttrs as aa, outdentItem as ab, renderCode as ac, renderDoc as ad, renderEmbed as ae, renderHr as af, renderImage as ag, renderTable as ah, renderToHtml as ai, resolve as aj, safeCssValue as ak, serializeSelection as al, setAlign as am, setCalloutVariant as an, setTextStyle as ao, textStyleCss as ap, toggleMark as aq, toggleMarkList as ar, twitchChannel as as, wordBoundaryBack as at, wordBoundaryFwd as au, wrapList as av, youtubeId as aw, 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 BlockKind as n, type BlockRenderCtx as o, type BlockRenderer as p, type CalloutVariant as q, type DecorationHost as r, startAiWrite as s, type InputRuleCtx as t, type Intent as u, type KeymapCtx as v, type KeymapResult as w, type MentionCandidate as x, type MentionHost as y, MentionMenu as z };
623
+ export { diffSpan as $, type AiConfig as A, type BlockInputRule as B, CALLOUT_VARIANTS as C, type DecorationFactory as D, type EditorOptions as E, MentionPopovers as F, type MentionPopoversHost as G, type MentionProfile as H, type InputResult as I, type NodeViewCtx as J, type KeymapCommand as K, type Resolved as L, MarkloomAi as M, type NodeView as N, atomIsSelected as O, type PasteRule as P, blockTransform as Q, type RenderOpts as R, type SlashCommand as S, type TextStylePatch as T, calloutVariantFromQuery as U, caret as V, chord as W, cycleCalloutVariant as X, defaultBlockRenderers as Y, defaultBlockTag as Z, defaultMarkTag as _, type AiPromptMode as a, indentItem as a0, isAtom as a1, isOpaque as a2, leafText as a3, lineBoundaryBack as a4, lineBoundaryFwd as a5, mapInput as a6, mapPaste as a7, mapPasteBlocks as a8, marksAtCaret as a9, mergeTextStyleAttrs as aa, outdentItem as ab, projectDoc as ac, renderCode as ad, renderDoc as ae, renderEmbed as af, renderHr as ag, renderImage as ah, renderTable as ai, renderToHtml as aj, resolve as ak, safeCssValue as al, serializeBlock as am, serializeSelection as an, setAlign as ao, setCalloutVariant as ap, setTextStyle as aq, textStyleCss as ar, toggleMark as as, toggleMarkList as at, twitchChannel as au, wordBoundaryBack as av, wordBoundaryFwd as aw, wrapList as ax, youtubeId as ay, 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 BlockKind as n, type BlockRenderCtx as o, type BlockRenderer as p, type CalloutVariant as q, type DecorationHost as r, startAiWrite as s, type InputRuleCtx as t, type Intent as u, type KeymapCtx as v, type KeymapResult as w, type MentionCandidate as x, type MentionHost as y, MentionMenu as z };
package/dist/index.cjs CHANGED
@@ -9,7 +9,6 @@
9
9
 
10
10
 
11
11
 
12
- var _chunkYXQDCW4Ycjs = require('./chunk-YXQDCW4Y.cjs');
13
12
 
14
13
 
15
14
 
@@ -30,6 +29,7 @@ var _chunkYXQDCW4Ycjs = require('./chunk-YXQDCW4Y.cjs');
30
29
 
31
30
 
32
31
 
32
+ var _chunkQEVME6ZUcjs = require('./chunk-QEVME6ZU.cjs');
33
33
 
34
34
 
35
35
 
@@ -70,7 +70,6 @@ var _chunkYXQDCW4Ycjs = require('./chunk-YXQDCW4Y.cjs');
70
70
 
71
71
 
72
72
 
73
- var _chunk4TMHVNL6cjs = require('./chunk-4TMHVNL6.cjs');
74
73
 
75
74
 
76
75
 
@@ -81,21 +80,47 @@ var _chunk4TMHVNL6cjs = require('./chunk-4TMHVNL6.cjs');
81
80
 
82
81
 
83
82
 
84
- var _chunkJS527FDVcjs = require('./chunk-JS527FDV.cjs');
85
83
 
86
84
 
87
85
 
88
86
 
89
- var _chunkGQ2HHRGIcjs = require('./chunk-GQ2HHRGI.cjs');
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+ var _chunkTWD5T4YCcjs = require('./chunk-TWD5T4YC.cjs');
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+ var _chunkU3JZDFL4cjs = require('./chunk-U3JZDFL4.cjs');
110
+
111
+
112
+
113
+
114
+ var _chunkZKQSQSSMcjs = require('./chunk-ZKQSQSSM.cjs');
90
115
 
91
116
  // src/tree/stats.ts
92
117
  function rawText(node) {
93
- if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
118
+ if (_chunkZKQSQSSMcjs.isText.call(void 0, node))
94
119
  return node.text;
95
120
  return node.children.map(rawText).join("");
96
121
  }
97
122
  function spacedText(node) {
98
- if (_chunkGQ2HHRGIcjs.isText.call(void 0, node))
123
+ if (_chunkZKQSQSSMcjs.isText.call(void 0, node))
99
124
  return node.text;
100
125
  return node.children.map(spacedText).join("\n");
101
126
  }
@@ -199,4 +224,29 @@ function docStats(doc) {
199
224
 
200
225
 
201
226
 
202
- exports.amend = _chunkYXQDCW4Ycjs.amend; exports.appendText = _chunk4TMHVNL6cjs.appendText; exports.apply = _chunk4TMHVNL6cjs.apply; exports.applyAll = _chunk4TMHVNL6cjs.applyAll; exports.arrowCell = _chunk4TMHVNL6cjs.arrowCell; exports.basicSchema = _chunk4TMHVNL6cjs.basicSchema; exports.buildGrid = _chunk4TMHVNL6cjs.buildGrid; exports.buildIdIndex = _chunk4TMHVNL6cjs.buildIdIndex; exports.calloutToHtml = _chunk4TMHVNL6cjs.calloutToHtml; exports.caretCell = _chunk4TMHVNL6cjs.caretCell; exports.cellCaret = _chunk4TMHVNL6cjs.cellCaret; exports.cellText = _chunk4TMHVNL6cjs.cellText; exports.checkSchema = _chunk4TMHVNL6cjs.checkSchema; exports.checkTable = _chunk4TMHVNL6cjs.checkTable; exports.clearCells = _chunk4TMHVNL6cjs.clearCells; exports.colspanOf = _chunk4TMHVNL6cjs.colspanOf; exports.commentIdsInDoc = _chunkYXQDCW4Ycjs.commentIdsInDoc; exports.commit = _chunkYXQDCW4Ycjs.commit; exports.deleteCol = _chunk4TMHVNL6cjs.deleteCol; exports.deleteRow = _chunk4TMHVNL6cjs.deleteRow; exports.deleteTableBlock = _chunk4TMHVNL6cjs.deleteTableBlock; exports.diffById = _chunk4TMHVNL6cjs.diffById; exports.docStats = docStats; exports.docToMd = _chunk4TMHVNL6cjs.docToMd; exports.embedHtml = _chunk4TMHVNL6cjs.embedHtml; exports.firstLeafPath = _chunk4TMHVNL6cjs.firstLeafPath; exports.firstViolation = _chunkYXQDCW4Ycjs.firstViolation; exports.hasSpan = _chunk4TMHVNL6cjs.hasSpan; exports.htmlToBlocks = _chunk4TMHVNL6cjs.htmlToBlocks; exports.init = _chunkYXQDCW4Ycjs.init; exports.insertAfter = _chunk4TMHVNL6cjs.insertAfter; exports.insertCol = _chunk4TMHVNL6cjs.insertCol; exports.insertRow = _chunk4TMHVNL6cjs.insertRow; exports.invariants = _chunkYXQDCW4Ycjs.invariants; exports.invert = _chunk4TMHVNL6cjs.invert; exports.invertAll = _chunk4TMHVNL6cjs.invertAll; exports.isElement = _chunkGQ2HHRGIcjs.isElement; exports.isInlineAtom = _chunkGQ2HHRGIcjs.isInlineAtom; exports.isRichHtmlBlocks = _chunk4TMHVNL6cjs.isRichHtmlBlocks; exports.isText = _chunkGQ2HHRGIcjs.isText; exports.lastLeafEnd = _chunk4TMHVNL6cjs.lastLeafEnd; exports.makeBias = _chunkJS527FDVcjs.makeBias; exports.makeTable = _chunk4TMHVNL6cjs.makeTable; exports.mapPosition = _chunkJS527FDVcjs.mapPosition; exports.mapSelection = _chunkJS527FDVcjs.mapSelection; exports.mdToDoc = _chunk4TMHVNL6cjs.mdToDoc; exports.mergeCells = _chunk4TMHVNL6cjs.mergeCells; exports.moveBlock = _chunk4TMHVNL6cjs.moveBlock; exports.moveCol = _chunk4TMHVNL6cjs.moveCol; exports.moveRow = _chunk4TMHVNL6cjs.moveRow; exports.nextCell = _chunk4TMHVNL6cjs.nextCell; exports.nodeAt = _chunk4TMHVNL6cjs.nodeAt; exports.normalizePosition = _chunkJS527FDVcjs.normalizePosition; exports.normalizeToLeaf = _chunk4TMHVNL6cjs.normalizeToLeaf; exports.outline = _chunkYXQDCW4Ycjs.outline; exports.pathOfId = _chunk4TMHVNL6cjs.pathOfId; exports.rebase = _chunkJS527FDVcjs.rebase; exports.rebaseBatchOver = _chunkJS527FDVcjs.rebaseBatchOver; exports.rebaseOne = _chunkJS527FDVcjs.rebaseOne; exports.rebaseStepsThrough = _chunkJS527FDVcjs.rebaseStepsThrough; exports.redo = _chunkYXQDCW4Ycjs.redo; exports.replaceAt = _chunk4TMHVNL6cjs.replaceAt; exports.resolve = _chunk4TMHVNL6cjs.resolve; exports.rewriteNode = _chunk4TMHVNL6cjs.rewriteNode; exports.rowspanOf = _chunk4TMHVNL6cjs.rowspanOf; exports.setAlign = _chunk4TMHVNL6cjs.setAlign; exports.setCellStyle = _chunk4TMHVNL6cjs.setCellStyle; exports.setColWidths = _chunk4TMHVNL6cjs.setColWidths; exports.setFreeze = _chunk4TMHVNL6cjs.setFreeze; exports.spliceAt = _chunk4TMHVNL6cjs.spliceAt; exports.splitCell = _chunk4TMHVNL6cjs.splitCell; exports.stripCommentMarks = _chunkYXQDCW4Ycjs.stripCommentMarks; exports.tableAt = _chunk4TMHVNL6cjs.tableAt; exports.tableColWidths = _chunk4TMHVNL6cjs.tableColWidths; exports.tableHasExtras = _chunk4TMHVNL6cjs.tableHasExtras; exports.tableSchema = _chunk4TMHVNL6cjs.tableSchema; exports.tableShape = _chunk4TMHVNL6cjs.tableShape; exports.tableToHtml = _chunk4TMHVNL6cjs.tableToHtml; exports.transformRemoteAgainstPending = _chunkJS527FDVcjs.transformRemoteAgainstPending; exports.undo = _chunkYXQDCW4Ycjs.undo; exports.validate = _chunk4TMHVNL6cjs.validate; exports.validateAll = _chunk4TMHVNL6cjs.validateAll;
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+ exports.acceptSuggestion = _chunkQEVME6ZUcjs.acceptSuggestion; exports.amend = _chunkQEVME6ZUcjs.amend; exports.appendText = _chunkTWD5T4YCcjs.appendText; exports.apply = _chunkTWD5T4YCcjs.apply; exports.applyAll = _chunkTWD5T4YCcjs.applyAll; exports.applyForeign = _chunkQEVME6ZUcjs.applyForeign; exports.applyReplaceAll = _chunkQEVME6ZUcjs.applyReplaceAll; exports.arrowCell = _chunkTWD5T4YCcjs.arrowCell; exports.basicSchema = _chunkTWD5T4YCcjs.basicSchema; exports.buildGrid = _chunkTWD5T4YCcjs.buildGrid; exports.buildIdIndex = _chunkTWD5T4YCcjs.buildIdIndex; exports.calloutToHtml = _chunkTWD5T4YCcjs.calloutToHtml; exports.caretCell = _chunkTWD5T4YCcjs.caretCell; exports.cellCaret = _chunkTWD5T4YCcjs.cellCaret; exports.cellText = _chunkTWD5T4YCcjs.cellText; exports.checkSchema = _chunkTWD5T4YCcjs.checkSchema; exports.checkTable = _chunkTWD5T4YCcjs.checkTable; exports.clearCells = _chunkTWD5T4YCcjs.clearCells; exports.colspanOf = _chunkTWD5T4YCcjs.colspanOf; exports.commentIdsInDoc = _chunkQEVME6ZUcjs.commentIdsInDoc; exports.commit = _chunkQEVME6ZUcjs.commit; exports.deleteCol = _chunkTWD5T4YCcjs.deleteCol; exports.deleteRow = _chunkTWD5T4YCcjs.deleteRow; exports.deleteTableBlock = _chunkTWD5T4YCcjs.deleteTableBlock; exports.diffById = _chunkTWD5T4YCcjs.diffById; exports.docStats = docStats; exports.docToMd = _chunkTWD5T4YCcjs.docToMd; exports.dropSuggestText = _chunkQEVME6ZUcjs.dropSuggestText; exports.embedHtml = _chunkTWD5T4YCcjs.embedHtml; exports.findText = _chunkQEVME6ZUcjs.findText; exports.firstLeafPath = _chunkTWD5T4YCcjs.firstLeafPath; exports.firstViolation = _chunkQEVME6ZUcjs.firstViolation; exports.getVersion = _chunkQEVME6ZUcjs.getVersion; exports.hasSpan = _chunkTWD5T4YCcjs.hasSpan; exports.htmlToBlocks = _chunkTWD5T4YCcjs.htmlToBlocks; exports.init = _chunkQEVME6ZUcjs.init; exports.insertAfter = _chunkTWD5T4YCcjs.insertAfter; exports.insertCol = _chunkTWD5T4YCcjs.insertCol; exports.insertRow = _chunkTWD5T4YCcjs.insertRow; exports.invariants = _chunkQEVME6ZUcjs.invariants; exports.invert = _chunkTWD5T4YCcjs.invert; exports.invertAll = _chunkTWD5T4YCcjs.invertAll; exports.isElement = _chunkZKQSQSSMcjs.isElement; exports.isInlineAtom = _chunkZKQSQSSMcjs.isInlineAtom; exports.isPlainTransportHtml = _chunkTWD5T4YCcjs.isPlainTransportHtml; exports.isRichHtmlBlocks = _chunkTWD5T4YCcjs.isRichHtmlBlocks; exports.isSuggestMark = _chunkQEVME6ZUcjs.isSuggestMark; exports.isText = _chunkZKQSQSSMcjs.isText; exports.lastLeafEnd = _chunkTWD5T4YCcjs.lastLeafEnd; exports.listSuggestions = _chunkQEVME6ZUcjs.listSuggestions; exports.makeBias = _chunkU3JZDFL4cjs.makeBias; exports.makeTable = _chunkTWD5T4YCcjs.makeTable; exports.mapPosition = _chunkU3JZDFL4cjs.mapPosition; exports.mapSelection = _chunkU3JZDFL4cjs.mapSelection; exports.mapSelectionThrough = _chunkU3JZDFL4cjs.mapSelectionThrough; exports.markSuggestRange = _chunkQEVME6ZUcjs.markSuggestRange; exports.mdStructureBeatsTransport = _chunkTWD5T4YCcjs.mdStructureBeatsTransport; exports.mdToDoc = _chunkTWD5T4YCcjs.mdToDoc; exports.mergeCells = _chunkTWD5T4YCcjs.mergeCells; exports.moveBlock = _chunkTWD5T4YCcjs.moveBlock; exports.moveCol = _chunkTWD5T4YCcjs.moveCol; exports.moveRow = _chunkTWD5T4YCcjs.moveRow; exports.nextCell = _chunkTWD5T4YCcjs.nextCell; exports.nodeAt = _chunkTWD5T4YCcjs.nodeAt; exports.normalizePosition = _chunkU3JZDFL4cjs.normalizePosition; exports.normalizeToLeaf = _chunkTWD5T4YCcjs.normalizeToLeaf; exports.outline = _chunkQEVME6ZUcjs.outline; exports.pathOfId = _chunkTWD5T4YCcjs.pathOfId; exports.preferMarkdownPaste = _chunkTWD5T4YCcjs.preferMarkdownPaste; exports.pushVersion = _chunkQEVME6ZUcjs.pushVersion; exports.rangeForDelete = _chunkQEVME6ZUcjs.rangeForDelete; exports.rangeIsSuggestInsert = _chunkQEVME6ZUcjs.rangeIsSuggestInsert; exports.rebase = _chunkU3JZDFL4cjs.rebase; exports.rebaseBatchOver = _chunkU3JZDFL4cjs.rebaseBatchOver; exports.rebaseOne = _chunkU3JZDFL4cjs.rebaseOne; exports.rebaseStepsThrough = _chunkU3JZDFL4cjs.rebaseStepsThrough; exports.redo = _chunkQEVME6ZUcjs.redo; exports.rejectSuggestion = _chunkQEVME6ZUcjs.rejectSuggestion; exports.removeVersion = _chunkQEVME6ZUcjs.removeVersion; exports.replaceAll = _chunkQEVME6ZUcjs.replaceAll; exports.replaceAt = _chunkTWD5T4YCcjs.replaceAt; exports.replaceMatch = _chunkQEVME6ZUcjs.replaceMatch; exports.resolve = _chunkTWD5T4YCcjs.resolve; exports.resolveTxAfter = _chunkU3JZDFL4cjs.resolveTxAfter; exports.rewriteNode = _chunkTWD5T4YCcjs.rewriteNode; exports.rowspanOf = _chunkTWD5T4YCcjs.rowspanOf; exports.setAlign = _chunkTWD5T4YCcjs.setAlign; exports.setCellStyle = _chunkTWD5T4YCcjs.setCellStyle; exports.setColWidths = _chunkTWD5T4YCcjs.setColWidths; exports.setFreeze = _chunkTWD5T4YCcjs.setFreeze; exports.snapshotDoc = _chunkQEVME6ZUcjs.snapshotDoc; exports.spliceAt = _chunkTWD5T4YCcjs.spliceAt; exports.splitCell = _chunkTWD5T4YCcjs.splitCell; exports.stripCommentMarks = _chunkQEVME6ZUcjs.stripCommentMarks; exports.stripSuggestMarks = _chunkQEVME6ZUcjs.stripSuggestMarks; exports.suggestIdsInDoc = _chunkQEVME6ZUcjs.suggestIdsInDoc; exports.suggestMark = _chunkQEVME6ZUcjs.suggestMark; exports.tableAt = _chunkTWD5T4YCcjs.tableAt; exports.tableColWidths = _chunkTWD5T4YCcjs.tableColWidths; exports.tableHasExtras = _chunkTWD5T4YCcjs.tableHasExtras; exports.tableSchema = _chunkTWD5T4YCcjs.tableSchema; exports.tableShape = _chunkTWD5T4YCcjs.tableShape; exports.tableToHtml = _chunkTWD5T4YCcjs.tableToHtml; exports.transformRemoteAgainstPending = _chunkU3JZDFL4cjs.transformRemoteAgainstPending; exports.undo = _chunkQEVME6ZUcjs.undo; exports.validate = _chunkTWD5T4YCcjs.validate; exports.validateAll = _chunkTWD5T4YCcjs.validateAll;
package/dist/index.d.cts CHANGED
@@ -1,7 +1,9 @@
1
- import { E as ElementNode, P as Path, S as Step, N as Node, a as Position } from './step-BrvHIK7O.cjs';
2
- export { D as DeleteText, b as Doc, I as InsertText, M as Mark, R as ReplaceNode, c as Selection, d as SpliceChildren, T as TextNode, e as apply, f as applyAll, i as invert, g as invertAll, h as isElement, j as isInlineAtom, k as isText, m as moveBlock } from './step-BrvHIK7O.cjs';
3
- export { C as CommentAuthor, a as CommentMessage, b as CommentRenderState, c as CommentThread, d as Commit, H as History, e as amend, f as commentIdsInDoc, g as commit, i as init, r as redo, s as stripCommentMarks, u as undo } from './comments-DlExS6f-.cjs';
4
- export { B as Bias, m as makeBias, c as rebase, r as rebaseBatchOver, a as rebaseOne, b as rebaseStepsThrough, t as transformRemoteAgainstPending } from './rebase-batch-bYnBJpRO.cjs';
1
+ import { S as Step } from './versions-9mG1epfB.cjs';
2
+ export { D as DeleteText, a as DocVersion, I as InsertText, R as ReplaceNode, b as SpliceChildren, c as apply, d as applyAll, g as getVersion, i as invert, e as invertAll, m as moveBlock, p as pushVersion, r as removeVersion, s as snapshotDoc } from './versions-9mG1epfB.cjs';
3
+ import { E as ElementNode, P as Path, N as Node, a as Position } from './types-COUweEav.cjs';
4
+ export { D as Doc, M as Mark, S as Selection, T as TextNode, i as isElement, b as isInlineAtom, c as isText } from './types-COUweEav.cjs';
5
+ export { C as CommentAuthor, a as CommentMessage, b as CommentRenderState, c as CommentThread, d as Commit, H as History, S as SearchOpts, e as SuggestAuthor, f as SuggestHit, g as SuggestKind, T as TextMatch, h as acceptSuggestion, i as amend, j as applyForeign, k as applyReplaceAll, l as commentIdsInDoc, m as commit, n as dropSuggestText, o as findText, p as init, q as isSuggestMark, r as listSuggestions, s as markSuggestRange, t as rangeForDelete, u as rangeIsSuggestInsert, v as redo, w as rejectSuggestion, x as replaceAll, y as replaceMatch, z as stripCommentMarks, A as stripSuggestMarks, B as suggestIdsInDoc, D as suggestMark, E as undo } from './suggest-BkGGiPKA.cjs';
6
+ export { B as Bias, m as makeBias, d as rebase, r as rebaseBatchOver, a as rebaseOne, b as rebaseStepsThrough, t as transformRemoteAgainstPending } from './rebase-batch-PjENQ742.cjs';
5
7
 
6
8
  interface TableShape {
7
9
  rows: number;
@@ -87,6 +89,9 @@ declare const tableSchema: {
87
89
  declare function mdToDoc(md: string): ElementNode;
88
90
  declare function htmlToBlocks(html: string): ElementNode[] | null;
89
91
  declare function isRichHtmlBlocks(blocks: ElementNode[]): boolean;
92
+ declare function isPlainTransportHtml(blocks: ElementNode[]): boolean;
93
+ declare function mdStructureBeatsTransport(plain: string): boolean;
94
+ declare function preferMarkdownPaste(plain: string, htmlBlocks: ElementNode[]): boolean;
90
95
  declare function embedHtml(n: ElementNode): string;
91
96
  declare function tableHasExtras(n: ElementNode): boolean;
92
97
  declare function tableToHtml(n: ElementNode): string;
@@ -162,6 +167,14 @@ declare function mapSelection(step: Step, sel: {
162
167
  anchor: Position;
163
168
  head: Position;
164
169
  };
170
+ declare function mapSelectionThrough<S extends {
171
+ anchor: Position;
172
+ head: Position;
173
+ }>(sel: S | null | undefined, steps: readonly Step[]): S | undefined;
174
+ declare function resolveTxAfter<S extends {
175
+ anchor: Position;
176
+ head: Position;
177
+ }>(before: S | null | undefined, after: S | null | undefined, steps: readonly Step[], gaps?: readonly Step[]): S | undefined;
165
178
  declare function normalizePosition(doc: ElementNode, pos: Position): Position;
166
179
 
167
180
  interface DocStats {
@@ -179,4 +192,4 @@ interface TocEntry {
179
192
  }
180
193
  declare function outline(doc: ElementNode): TocEntry[];
181
194
 
182
- export { type DocStats, ElementNode, type Grid, type IdIndex, Node, type NodeChange, type NodeSpec, Path, Position, type Resolved, type Schema, Step, type TableShape, type TocEntry, type Violation, appendText, arrowCell, basicSchema, buildGrid, buildIdIndex, calloutToHtml, caretCell, cellCaret, cellText, checkSchema, checkTable, clearCells, colspanOf, deleteCol, deleteRow, deleteTableBlock, diffById, docStats, docToMd, embedHtml, firstLeafPath, firstViolation, hasSpan, htmlToBlocks, insertAfter, insertCol, insertRow, invariants, isRichHtmlBlocks, lastLeafEnd, makeTable, mapPosition, mapSelection, mdToDoc, mergeCells, moveCol, moveRow, nextCell, nodeAt, normalizePosition, normalizeToLeaf, outline, pathOfId, replaceAt, resolve, rewriteNode, rowspanOf, setAlign, setCellStyle, setColWidths, setFreeze, spliceAt, splitCell, tableAt, tableColWidths, tableHasExtras, tableSchema, tableShape, tableToHtml, validate, validateAll };
195
+ export { type DocStats, ElementNode, type Grid, type IdIndex, Node, type NodeChange, type NodeSpec, Path, Position, type Resolved, type Schema, Step, type TableShape, type TocEntry, type Violation, appendText, arrowCell, basicSchema, buildGrid, buildIdIndex, calloutToHtml, caretCell, cellCaret, cellText, checkSchema, checkTable, clearCells, colspanOf, deleteCol, deleteRow, deleteTableBlock, diffById, docStats, docToMd, embedHtml, firstLeafPath, firstViolation, hasSpan, htmlToBlocks, insertAfter, insertCol, insertRow, invariants, isPlainTransportHtml, isRichHtmlBlocks, lastLeafEnd, makeTable, mapPosition, mapSelection, mapSelectionThrough, mdStructureBeatsTransport, mdToDoc, mergeCells, moveCol, moveRow, nextCell, nodeAt, normalizePosition, normalizeToLeaf, outline, pathOfId, preferMarkdownPaste, replaceAt, resolve, resolveTxAfter, rewriteNode, rowspanOf, setAlign, setCellStyle, setColWidths, setFreeze, spliceAt, splitCell, tableAt, tableColWidths, tableHasExtras, tableSchema, tableShape, tableToHtml, validate, validateAll };