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
package/dist/react/index.cjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
5
|
-
require('../chunk-
|
|
6
|
-
require('../chunk-
|
|
7
|
-
require('../chunk-
|
|
8
|
-
require('../chunk-
|
|
9
|
-
require('../chunk-
|
|
3
|
+
var _chunkY4IXQFWLcjs = require('../chunk-Y4IXQFWL.cjs');
|
|
4
|
+
require('../chunk-PZRWTLLB.cjs');
|
|
5
|
+
require('../chunk-I2LDEVLA.cjs');
|
|
6
|
+
require('../chunk-OVHASRID.cjs');
|
|
7
|
+
require('../chunk-75EJ4ARB.cjs');
|
|
8
|
+
require('../chunk-BMPCVT3B.cjs');
|
|
9
|
+
require('../chunk-HXABDVLZ.cjs');
|
|
10
|
+
require('../chunk-PCSVBPOR.cjs');
|
|
10
11
|
|
|
11
12
|
// src/react/index.ts
|
|
12
13
|
var _react = require('react');
|
|
@@ -20,7 +21,7 @@ function useMarkloom(initialDoc, opts = {}) {
|
|
|
20
21
|
const host = ref.current;
|
|
21
22
|
if (!host)
|
|
22
23
|
return;
|
|
23
|
-
const ed = new (0,
|
|
24
|
+
const ed = new (0, _chunkY4IXQFWLcjs.Editor)(host, initialDoc, {
|
|
24
25
|
...optsRef.current,
|
|
25
26
|
onChange: (d) => {
|
|
26
27
|
setDoc(d);
|
package/dist/react/index.d.cts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { MutableRefObject } from 'react';
|
|
3
|
-
import { E as ElementNode } from '../
|
|
4
|
-
import { E as EditorOptions, k as Editor } from '../controller-
|
|
3
|
+
import { E as ElementNode } from '../types-BkHlmUFL.cjs';
|
|
4
|
+
import { E as EditorOptions, k as Editor } from '../controller-CHznEhAR.cjs';
|
|
5
|
+
import '../versions-DNFf8zVz.cjs';
|
|
5
6
|
import 'preact';
|
|
6
|
-
import '../
|
|
7
|
-
import '../client-
|
|
7
|
+
import '../word-count-DNLn1h_t.cjs';
|
|
8
|
+
import '../client-Ciy7Fa_k.cjs';
|
|
8
9
|
|
|
9
10
|
declare function useMarkloom(initialDoc: ElementNode, opts?: EditorOptions): {
|
|
10
11
|
ref: react.RefObject<HTMLDivElement | null>;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { MutableRefObject } from 'react';
|
|
3
|
-
import { E as ElementNode } from '../
|
|
4
|
-
import { E as EditorOptions, k as Editor } from '../controller-
|
|
3
|
+
import { E as ElementNode } from '../types-BkHlmUFL.js';
|
|
4
|
+
import { E as EditorOptions, k as Editor } from '../controller-DLqI8_jm.js';
|
|
5
|
+
import '../versions-DOkOyh2J.js';
|
|
5
6
|
import 'preact';
|
|
6
|
-
import '../
|
|
7
|
-
import '../client-
|
|
7
|
+
import '../word-count-BPw9G2Bg.js';
|
|
8
|
+
import '../client-BvvyHjhh.js';
|
|
8
9
|
|
|
9
10
|
declare function useMarkloom(initialDoc: ElementNode, opts?: EditorOptions): {
|
|
10
11
|
ref: react.RefObject<HTMLDivElement | null>;
|
package/dist/react/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Editor
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-4Q7PAR2T.js";
|
|
4
|
+
import "../chunk-YLVSMDIO.js";
|
|
5
|
+
import "../chunk-PSAXWBNM.js";
|
|
6
|
+
import "../chunk-QO7JEZDB.js";
|
|
7
|
+
import "../chunk-MQLRZQZL.js";
|
|
8
|
+
import "../chunk-EFYT2223.js";
|
|
9
|
+
import "../chunk-ZL6WT6OY.js";
|
|
10
|
+
import "../chunk-WSJUXPAG.js";
|
|
10
11
|
|
|
11
12
|
// src/react/index.ts
|
|
12
13
|
import { createElement, useEffect, useRef, useState } from "react";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as Step } from './
|
|
1
|
+
import { S as Step } from './versions-DOkOyh2J.js';
|
|
2
2
|
|
|
3
3
|
type Bias = -1 | 1;
|
|
4
4
|
declare function makeBias(thisSite: number, overSite: number): Bias;
|
|
@@ -6,11 +6,16 @@ declare function rebase(over: Step, step: Step, bias: Bias): Step | Step[] | nul
|
|
|
6
6
|
|
|
7
7
|
/** 把单步 step 穿过 over,产出 0..n 步(裂步)或空(作废) */
|
|
8
8
|
declare function rebaseOne(over: Step, step: Step, bias: Bias): Step[];
|
|
9
|
-
/** 一批 steps
|
|
9
|
+
/** 一批 steps 各自穿过一条 over(无批内顺序依赖) */
|
|
10
10
|
declare function rebaseBatchOver(over: Step, steps: Step[], bias: Bias): Step[];
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* 顺序批 seq 穿过单条已应用的 over。
|
|
13
|
+
* s1' = T(s1, o); o' = T(o, s1); s2' = T(s2, o'); …
|
|
14
|
+
* 多步 commit / inverse 必须走这条,不能对批内每步独立 T(*, o)。
|
|
15
|
+
*/
|
|
16
|
+
declare function transformSeqThroughOne(seq: Step[], over: Step, bias: Bias, biasOpp: Bias): Step[];
|
|
17
|
+
/**
|
|
18
|
+
* 本站顺序 steps 穿过一系列并发 op(每条带 siteId + 顺序 steps)。
|
|
14
19
|
*/
|
|
15
20
|
declare function rebaseStepsThrough(steps: Step[], concurrent: {
|
|
16
21
|
siteId: number;
|
|
@@ -19,10 +24,7 @@ declare function rebaseStepsThrough(steps: Step[], concurrent: {
|
|
|
19
24
|
/**
|
|
20
25
|
* 远端一批 remote 穿过本地 pending 队列 → remote';
|
|
21
26
|
* pending 同步被 remote 搬坐标 → pending'。
|
|
22
|
-
*
|
|
23
|
-
* 对每个 pending 项 p:
|
|
24
|
-
* remote 穿过 p: bias = makeBias(remoteSite, localSite)
|
|
25
|
-
* p 穿过「进入 p 前」的 remote: bias = makeBias(localSite, remoteSite)
|
|
27
|
+
* pending 每项、remote 均为顺序批,用 transformSeqThroughOne。
|
|
26
28
|
*/
|
|
27
29
|
declare function transformRemoteAgainstPending(remote: Step[], remoteSite: number, pending: {
|
|
28
30
|
siteId: number;
|
|
@@ -35,4 +37,4 @@ declare function transformRemoteAgainstPending(remote: Step[], remoteSite: numbe
|
|
|
35
37
|
}[];
|
|
36
38
|
};
|
|
37
39
|
|
|
38
|
-
export { type Bias as B, rebaseOne as a, rebaseStepsThrough as b,
|
|
40
|
+
export { type Bias as B, rebaseOne as a, rebaseStepsThrough as b, transformSeqThroughOne as c, rebase as d, makeBias as m, rebaseBatchOver as r, transformRemoteAgainstPending as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as Step } from './
|
|
1
|
+
import { S as Step } from './versions-DNFf8zVz.cjs';
|
|
2
2
|
|
|
3
3
|
type Bias = -1 | 1;
|
|
4
4
|
declare function makeBias(thisSite: number, overSite: number): Bias;
|
|
@@ -6,11 +6,16 @@ declare function rebase(over: Step, step: Step, bias: Bias): Step | Step[] | nul
|
|
|
6
6
|
|
|
7
7
|
/** 把单步 step 穿过 over,产出 0..n 步(裂步)或空(作废) */
|
|
8
8
|
declare function rebaseOne(over: Step, step: Step, bias: Bias): Step[];
|
|
9
|
-
/** 一批 steps
|
|
9
|
+
/** 一批 steps 各自穿过一条 over(无批内顺序依赖) */
|
|
10
10
|
declare function rebaseBatchOver(over: Step, steps: Step[], bias: Bias): Step[];
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* 顺序批 seq 穿过单条已应用的 over。
|
|
13
|
+
* s1' = T(s1, o); o' = T(o, s1); s2' = T(s2, o'); …
|
|
14
|
+
* 多步 commit / inverse 必须走这条,不能对批内每步独立 T(*, o)。
|
|
15
|
+
*/
|
|
16
|
+
declare function transformSeqThroughOne(seq: Step[], over: Step, bias: Bias, biasOpp: Bias): Step[];
|
|
17
|
+
/**
|
|
18
|
+
* 本站顺序 steps 穿过一系列并发 op(每条带 siteId + 顺序 steps)。
|
|
14
19
|
*/
|
|
15
20
|
declare function rebaseStepsThrough(steps: Step[], concurrent: {
|
|
16
21
|
siteId: number;
|
|
@@ -19,10 +24,7 @@ declare function rebaseStepsThrough(steps: Step[], concurrent: {
|
|
|
19
24
|
/**
|
|
20
25
|
* 远端一批 remote 穿过本地 pending 队列 → remote';
|
|
21
26
|
* pending 同步被 remote 搬坐标 → pending'。
|
|
22
|
-
*
|
|
23
|
-
* 对每个 pending 项 p:
|
|
24
|
-
* remote 穿过 p: bias = makeBias(remoteSite, localSite)
|
|
25
|
-
* p 穿过「进入 p 前」的 remote: bias = makeBias(localSite, remoteSite)
|
|
27
|
+
* pending 每项、remote 均为顺序批,用 transformSeqThroughOne。
|
|
26
28
|
*/
|
|
27
29
|
declare function transformRemoteAgainstPending(remote: Step[], remoteSite: number, pending: {
|
|
28
30
|
siteId: number;
|
|
@@ -35,4 +37,4 @@ declare function transformRemoteAgainstPending(remote: Step[], remoteSite: numbe
|
|
|
35
37
|
}[];
|
|
36
38
|
};
|
|
37
39
|
|
|
38
|
-
export { type Bias as B, rebaseOne as a, rebaseStepsThrough as b,
|
|
40
|
+
export { type Bias as B, rebaseOne as a, rebaseStepsThrough as b, transformSeqThroughOne as c, rebase as d, makeBias as m, rebaseBatchOver as r, transformRemoteAgainstPending as t };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
interface TextNode {
|
|
2
|
+
text: string;
|
|
3
|
+
marks?: Mark[];
|
|
4
|
+
}
|
|
5
|
+
interface ElementNode {
|
|
6
|
+
type: string;
|
|
7
|
+
attrs?: Record<string, unknown>;
|
|
8
|
+
children: Node[];
|
|
9
|
+
id?: string;
|
|
10
|
+
}
|
|
11
|
+
type Node = TextNode | ElementNode;
|
|
12
|
+
interface Mark {
|
|
13
|
+
name: string;
|
|
14
|
+
attrs?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
declare function isText(n: Node | null | undefined): n is TextNode;
|
|
17
|
+
declare function isElement(n: Node | null | undefined): n is ElementNode;
|
|
18
|
+
declare function isInlineAtom(n: Node): boolean;
|
|
19
|
+
declare function isFootnoteDef(n: Node): boolean;
|
|
20
|
+
declare function footnoteKey(label: string): string;
|
|
21
|
+
declare function isCallout(n: Node): boolean;
|
|
22
|
+
declare function isAiCompose(n: Node): boolean;
|
|
23
|
+
type Path = number[];
|
|
24
|
+
interface Position {
|
|
25
|
+
path: Path;
|
|
26
|
+
assoc?: -1 | 1;
|
|
27
|
+
}
|
|
28
|
+
interface Selection {
|
|
29
|
+
anchor: Position;
|
|
30
|
+
head: Position;
|
|
31
|
+
}
|
|
32
|
+
type Doc = ElementNode;
|
|
33
|
+
|
|
34
|
+
export { type Doc as D, type ElementNode as E, type Mark as M, type Node as N, type Path as P, type Selection as S, type TextNode as T, type Position as a, isCallout as b, isElement as c, isFootnoteDef as d, isInlineAtom as e, footnoteKey as f, isText as g, isAiCompose as i };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
interface TextNode {
|
|
2
|
+
text: string;
|
|
3
|
+
marks?: Mark[];
|
|
4
|
+
}
|
|
5
|
+
interface ElementNode {
|
|
6
|
+
type: string;
|
|
7
|
+
attrs?: Record<string, unknown>;
|
|
8
|
+
children: Node[];
|
|
9
|
+
id?: string;
|
|
10
|
+
}
|
|
11
|
+
type Node = TextNode | ElementNode;
|
|
12
|
+
interface Mark {
|
|
13
|
+
name: string;
|
|
14
|
+
attrs?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
declare function isText(n: Node | null | undefined): n is TextNode;
|
|
17
|
+
declare function isElement(n: Node | null | undefined): n is ElementNode;
|
|
18
|
+
declare function isInlineAtom(n: Node): boolean;
|
|
19
|
+
declare function isFootnoteDef(n: Node): boolean;
|
|
20
|
+
declare function footnoteKey(label: string): string;
|
|
21
|
+
declare function isCallout(n: Node): boolean;
|
|
22
|
+
declare function isAiCompose(n: Node): boolean;
|
|
23
|
+
type Path = number[];
|
|
24
|
+
interface Position {
|
|
25
|
+
path: Path;
|
|
26
|
+
assoc?: -1 | 1;
|
|
27
|
+
}
|
|
28
|
+
interface Selection {
|
|
29
|
+
anchor: Position;
|
|
30
|
+
head: Position;
|
|
31
|
+
}
|
|
32
|
+
type Doc = ElementNode;
|
|
33
|
+
|
|
34
|
+
export { type Doc as D, type ElementNode as E, type Mark as M, type Node as N, type Path as P, type Selection as S, type TextNode as T, type Position as a, isCallout as b, isElement as c, isFootnoteDef as d, isInlineAtom as e, footnoteKey as f, isText as g, isAiCompose as i };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { P as Path, N as Node, E as ElementNode } from './types-BkHlmUFL.cjs';
|
|
2
|
+
|
|
3
|
+
interface InsertText {
|
|
4
|
+
kind: 'insertText';
|
|
5
|
+
path: Path;
|
|
6
|
+
offset: number;
|
|
7
|
+
text: string;
|
|
8
|
+
marks?: {
|
|
9
|
+
name: string;
|
|
10
|
+
attrs?: Record<string, unknown>;
|
|
11
|
+
}[];
|
|
12
|
+
}
|
|
13
|
+
interface DeleteText {
|
|
14
|
+
kind: 'deleteText';
|
|
15
|
+
path: Path;
|
|
16
|
+
offset: number;
|
|
17
|
+
length: number;
|
|
18
|
+
}
|
|
19
|
+
interface ReplaceNode {
|
|
20
|
+
kind: 'replaceNode';
|
|
21
|
+
path: Path;
|
|
22
|
+
node: Node;
|
|
23
|
+
}
|
|
24
|
+
interface SpliceChildren {
|
|
25
|
+
kind: 'spliceChildren';
|
|
26
|
+
path: Path;
|
|
27
|
+
at: number;
|
|
28
|
+
remove: number;
|
|
29
|
+
insert: Node[];
|
|
30
|
+
}
|
|
31
|
+
type Step = InsertText | DeleteText | ReplaceNode | SpliceChildren;
|
|
32
|
+
declare function apply(doc: ElementNode, step: Step): ElementNode;
|
|
33
|
+
declare function invert(doc: ElementNode, step: Step): Step;
|
|
34
|
+
declare function applyAll(doc: ElementNode, steps: Step[]): ElementNode;
|
|
35
|
+
declare function moveBlock(doc: ElementNode, fromIdx: number, toGap: number): Step[];
|
|
36
|
+
declare function invertAll(doc: ElementNode, steps: Step[]): Step[];
|
|
37
|
+
|
|
38
|
+
type DocVersion = {
|
|
39
|
+
id: string;
|
|
40
|
+
name: string;
|
|
41
|
+
createdAt: number;
|
|
42
|
+
doc: ElementNode;
|
|
43
|
+
};
|
|
44
|
+
/** 从当前 doc 切一份命名快照(深拷贝)。 */
|
|
45
|
+
declare function snapshotDoc(doc: ElementNode, name: string, id?: string): DocVersion;
|
|
46
|
+
/** 环形上限:超 max 时丢最旧(保留 head 近端)。 */
|
|
47
|
+
declare function pushVersion(list: DocVersion[], v: DocVersion, max?: number): DocVersion[];
|
|
48
|
+
declare function getVersion(list: DocVersion[], id: string): DocVersion | undefined;
|
|
49
|
+
declare function removeVersion(list: DocVersion[], id: string): DocVersion[];
|
|
50
|
+
|
|
51
|
+
export { type DeleteText as D, type InsertText as I, type ReplaceNode as R, type Step as S, type DocVersion as a, type SpliceChildren as b, apply as c, applyAll as d, invertAll as e, getVersion as g, invert as i, moveBlock as m, pushVersion as p, removeVersion as r, snapshotDoc as s };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { P as Path, N as Node, E as ElementNode } from './types-BkHlmUFL.js';
|
|
2
|
+
|
|
3
|
+
interface InsertText {
|
|
4
|
+
kind: 'insertText';
|
|
5
|
+
path: Path;
|
|
6
|
+
offset: number;
|
|
7
|
+
text: string;
|
|
8
|
+
marks?: {
|
|
9
|
+
name: string;
|
|
10
|
+
attrs?: Record<string, unknown>;
|
|
11
|
+
}[];
|
|
12
|
+
}
|
|
13
|
+
interface DeleteText {
|
|
14
|
+
kind: 'deleteText';
|
|
15
|
+
path: Path;
|
|
16
|
+
offset: number;
|
|
17
|
+
length: number;
|
|
18
|
+
}
|
|
19
|
+
interface ReplaceNode {
|
|
20
|
+
kind: 'replaceNode';
|
|
21
|
+
path: Path;
|
|
22
|
+
node: Node;
|
|
23
|
+
}
|
|
24
|
+
interface SpliceChildren {
|
|
25
|
+
kind: 'spliceChildren';
|
|
26
|
+
path: Path;
|
|
27
|
+
at: number;
|
|
28
|
+
remove: number;
|
|
29
|
+
insert: Node[];
|
|
30
|
+
}
|
|
31
|
+
type Step = InsertText | DeleteText | ReplaceNode | SpliceChildren;
|
|
32
|
+
declare function apply(doc: ElementNode, step: Step): ElementNode;
|
|
33
|
+
declare function invert(doc: ElementNode, step: Step): Step;
|
|
34
|
+
declare function applyAll(doc: ElementNode, steps: Step[]): ElementNode;
|
|
35
|
+
declare function moveBlock(doc: ElementNode, fromIdx: number, toGap: number): Step[];
|
|
36
|
+
declare function invertAll(doc: ElementNode, steps: Step[]): Step[];
|
|
37
|
+
|
|
38
|
+
type DocVersion = {
|
|
39
|
+
id: string;
|
|
40
|
+
name: string;
|
|
41
|
+
createdAt: number;
|
|
42
|
+
doc: ElementNode;
|
|
43
|
+
};
|
|
44
|
+
/** 从当前 doc 切一份命名快照(深拷贝)。 */
|
|
45
|
+
declare function snapshotDoc(doc: ElementNode, name: string, id?: string): DocVersion;
|
|
46
|
+
/** 环形上限:超 max 时丢最旧(保留 head 近端)。 */
|
|
47
|
+
declare function pushVersion(list: DocVersion[], v: DocVersion, max?: number): DocVersion[];
|
|
48
|
+
declare function getVersion(list: DocVersion[], id: string): DocVersion | undefined;
|
|
49
|
+
declare function removeVersion(list: DocVersion[], id: string): DocVersion[];
|
|
50
|
+
|
|
51
|
+
export { type DeleteText as D, type InsertText as I, type ReplaceNode as R, type Step as S, type DocVersion as a, type SpliceChildren as b, apply as c, applyAll as d, invertAll as e, getVersion as g, invert as i, moveBlock as m, pushVersion as p, removeVersion as r, snapshotDoc as s };
|