jazz-tools 0.13.10 → 0.13.11
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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +10 -0
- package/dist/{chunk-NFVKGXSH.js → chunk-I7NYAGLP.js} +23 -398
- package/dist/{chunk-NFVKGXSH.js.map → chunk-I7NYAGLP.js.map} +1 -1
- package/dist/coValues/coPlainText.d.ts +7 -0
- package/dist/coValues/coPlainText.d.ts.map +1 -1
- package/dist/coValues/coRichText.d.ts +2 -257
- package/dist/coValues/coRichText.d.ts.map +1 -1
- package/dist/exports.d.ts +1 -1
- package/dist/exports.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/testing.js +1 -1
- package/package.json +2 -2
- package/src/coValues/coPlainText.ts +23 -1
- package/src/coValues/coRichText.ts +2 -660
- package/src/exports.ts +1 -7
- package/src/tests/coPlainText.test.ts +21 -3
- package/dist/tests/coRichText.test.d.ts +0 -2
- package/dist/tests/coRichText.test.d.ts.map +0 -1
- package/src/tests/coRichText.test.ts +0 -937
@@ -24,6 +24,7 @@ export declare class CoPlainText extends String implements CoValue {
|
|
24
24
|
valueOf(): string;
|
25
25
|
toJSON(): string;
|
26
26
|
[inspect](): string;
|
27
|
+
insertBefore(idx: number, text: string): void;
|
27
28
|
insertAfter(idx: number, text: string): void;
|
28
29
|
deleteRange(range: {
|
29
30
|
from: number;
|
@@ -34,6 +35,12 @@ export declare class CoPlainText extends String implements CoValue {
|
|
34
35
|
idxBefore(pos: TextPos): number | undefined;
|
35
36
|
idxAfter(pos: TextPos): number | undefined;
|
36
37
|
static fromRaw<V extends CoPlainText>(this: CoValueClass<V> & typeof CoPlainText, raw: RawCoPlainText): V & CoPlainText;
|
38
|
+
/**
|
39
|
+
* Apply text, modifying the text in place. Calculates the diff and applies it to the CoValue.
|
40
|
+
*
|
41
|
+
* @category Mutation
|
42
|
+
*/
|
43
|
+
applyDiff(other: string): void;
|
37
44
|
/**
|
38
45
|
* Load a `CoPlainText` with a given ID, as a given account.
|
39
46
|
*
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"coPlainText.d.ts","sourceRoot":"","sources":["../../src/coValues/coPlainText.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EAET,KAAK,cAAc,EAEpB,MAAM,QAAQ,CAAC;
|
1
|
+
{"version":3,"file":"coPlainText.d.ts","sourceRoot":"","sources":["../../src/coValues/coPlainText.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EAET,KAAK,cAAc,EAEpB,MAAM,QAAQ,CAAC;AAEhB,OAAO,KAAK,EACV,kBAAkB,EAClB,OAAO,EACP,YAAY,EACZ,EAAE,EACF,QAAQ,EACR,wBAAwB,EAEzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,OAAO,EAKR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC;AAE3B,qBAAa,WAAY,SAAQ,MAAO,YAAW,OAAO;IAChD,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IACb,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,cAAc,CAAC;IAE7B,IAAI,MAAM,IAAI,OAAO,GAAG,KAAK,CAI5B;IAED,IAAI,SAAS,YAEZ;gBAGC,OAAO,EACH;QAAE,OAAO,EAAE,cAAc,CAAA;KAAE,GAC3B;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAAA;KAAE;IAmB9C,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,WAAW,EACjC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,EACrB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;QAA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Q,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW,EAAE,MAAM,IAAI,KAAK,IAAI,GACpE,MAAM,IAAI;IACb,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,WAAW,EACpC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,EACrB,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EACT,OAAO,EAAE,IAAI,CAAC,wBAAwB,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,SAAS,CAAC,EAC3D,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW,EAAE,MAAM,IAAI,KAAK,IAAI,GACpE,MAAM,IAAI;IAUb;;;;;;;;QAQI;IACJ,SAAS,CAAC,CAAC,SAAS,WAAW,EAC7B,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW,EAAE,MAAM,IAAI,KAAK,IAAI,GACpE,MAAM,IAAI;CAGd"}
|
@@ -1,259 +1,4 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
import { CoList } from "./coList.js";
|
4
|
-
import { CoMap, type CoMapInit } from "./coMap.js";
|
5
|
-
import { CoPlainText, type TextPos } from "./coPlainText.js";
|
6
|
-
import type { Group } from "./group.js";
|
7
|
-
/**
|
8
|
-
* Base class for text annotations and formatting marks.
|
9
|
-
* Represents a mark with start and end positions in text.
|
10
|
-
*
|
11
|
-
* Example text: "Hello world! How are you?"
|
12
|
-
* If we want to mark "world" with bold:
|
13
|
-
*
|
14
|
-
* ```
|
15
|
-
* uncertainty region
|
16
|
-
* ↓
|
17
|
-
* Hello [····]world[····]! How are you?
|
18
|
-
* ↑ ↑ ↑ ↑
|
19
|
-
* | | | |
|
20
|
-
* startAfter | | endBefore
|
21
|
-
* startBefore endAfter
|
22
|
-
* ```
|
23
|
-
*
|
24
|
-
* - startAfter: Position after "Hello " (exclusive boundary)
|
25
|
-
* - startBefore: Position before "world" (inclusive boundary)
|
26
|
-
* - endAfter: Position after "world" (inclusive boundary)
|
27
|
-
* - endBefore: Position before "!" (exclusive boundary)
|
28
|
-
*
|
29
|
-
* The regions marked with [····] are "uncertainty regions" where:
|
30
|
-
* - Text inserted in the left uncertainty region may or may not be part of the mark
|
31
|
-
* - Text inserted in the right uncertainty region may or may not be part of the mark
|
32
|
-
* - Text inserted between startBefore and endAfter is definitely part of the mark
|
33
|
-
*
|
34
|
-
* Positions must satisfy:
|
35
|
-
* 0 ≤ startAfter ≤ startBefore < endAfter ≤ endBefore ≤ textLength
|
36
|
-
* A mark cannot be zero-length, so endAfter must be greater than startBefore.
|
37
|
-
*/
|
38
|
-
export declare class Mark extends CoMap {
|
39
|
-
startAfter: co<import("cojson").OpID | null>;
|
40
|
-
startBefore: co<import("cojson").OpID>;
|
41
|
-
endAfter: co<import("cojson").OpID>;
|
42
|
-
endBefore: co<import("cojson").OpID | null>;
|
43
|
-
tag: co<string>;
|
44
|
-
/**
|
45
|
-
* Validates and clamps mark positions to ensure they are in the correct order
|
46
|
-
* @returns Normalized positions or null if invalid
|
47
|
-
*/
|
48
|
-
validatePositions(textLength: number, idxAfter: (pos: TextPos) => number | undefined, idxBefore: (pos: TextPos) => number | undefined): {
|
49
|
-
startAfter: number;
|
50
|
-
startBefore: number;
|
51
|
-
endAfter: number;
|
52
|
-
endBefore: number;
|
53
|
-
} | null;
|
1
|
+
import { CoPlainText } from "./coPlainText.js";
|
2
|
+
export declare class CoRichText extends CoPlainText {
|
54
3
|
}
|
55
|
-
/**
|
56
|
-
* A mark with resolved numeric positions in text.
|
57
|
-
* Contains both position information and reference to the source mark.
|
58
|
-
* @template R Type extending Mark, defaults to Mark
|
59
|
-
*/
|
60
|
-
export type ResolvedMark<R extends Mark = Mark> = {
|
61
|
-
startAfter: number;
|
62
|
-
startBefore: number;
|
63
|
-
endAfter: number;
|
64
|
-
endBefore: number;
|
65
|
-
sourceMark: R;
|
66
|
-
};
|
67
|
-
/**
|
68
|
-
* A mark that has been resolved and diffused with certainty information.
|
69
|
-
* Includes start/end positions and indication of boundary certainty.
|
70
|
-
* @template R Type extending Mark, defaults to Mark
|
71
|
-
*/
|
72
|
-
export type ResolvedAndDiffusedMark<R extends Mark = Mark> = {
|
73
|
-
start: number;
|
74
|
-
end: number;
|
75
|
-
side: "uncertainStart" | "certainMiddle" | "uncertainEnd";
|
76
|
-
sourceMark: R;
|
77
|
-
};
|
78
|
-
/**
|
79
|
-
* Defines how marks should be focused when resolving positions.
|
80
|
-
* - 'far': Positions marks at furthest valid positions
|
81
|
-
* - 'close': Positions marks at nearest valid positions
|
82
|
-
* - 'closestWhitespace': Positions marks at nearest whitespace
|
83
|
-
*/
|
84
|
-
export type FocusBias = "far" | "close" | "closestWhitespace";
|
85
|
-
/**
|
86
|
-
* A mark that has been resolved and focused to specific positions.
|
87
|
-
* Contains simplified position information and reference to source mark.
|
88
|
-
* @template R Type extending Mark, defaults to Mark
|
89
|
-
*/
|
90
|
-
export type ResolvedAndFocusedMark<R extends Mark = Mark> = {
|
91
|
-
start: number;
|
92
|
-
end: number;
|
93
|
-
sourceMark: R;
|
94
|
-
};
|
95
|
-
/**
|
96
|
-
* Main class for handling rich text content with marks.
|
97
|
-
* Combines plain text with a list of marks for formatting and annotations.
|
98
|
-
* Provides methods for text manipulation, mark insertion, and tree conversion.
|
99
|
-
*/
|
100
|
-
export declare class CoRichText extends CoMap {
|
101
|
-
text: co<CoPlainText | null>;
|
102
|
-
marks: co<CoList<co<Mark | null>> | null>;
|
103
|
-
/**
|
104
|
-
* Create a CoRichText from plain text.
|
105
|
-
*/
|
106
|
-
static createFromPlainText(text: string, options: {
|
107
|
-
owner: Account | Group;
|
108
|
-
}): CoRichText;
|
109
|
-
/**
|
110
|
-
* Create a CoRichText from plain text and a mark.
|
111
|
-
*/
|
112
|
-
static createFromPlainTextAndMark<MarkClass extends {
|
113
|
-
new (...args: any[]): Mark;
|
114
|
-
create(init: any, options: {
|
115
|
-
owner: Account | Group;
|
116
|
-
}): Mark;
|
117
|
-
}>(text: string, WrapIn: MarkClass, extraArgs: Omit<CoMapInit<InstanceType<MarkClass>>, "startAfter" | "startBefore" | "endAfter" | "endBefore">, options: {
|
118
|
-
owner: Account | Group;
|
119
|
-
}): CoRichText;
|
120
|
-
/**
|
121
|
-
* Insert text at a specific index.
|
122
|
-
*/
|
123
|
-
insertAfter(idx: number, text: string): void;
|
124
|
-
/**
|
125
|
-
* Delete a range of text.
|
126
|
-
*/
|
127
|
-
deleteRange(range: {
|
128
|
-
from: number;
|
129
|
-
to: number;
|
130
|
-
}): void;
|
131
|
-
/**
|
132
|
-
* Get the position of a specific index.
|
133
|
-
*/
|
134
|
-
posBefore(idx: number): TextPos | undefined;
|
135
|
-
/**
|
136
|
-
* Get the position of a specific index.
|
137
|
-
*/
|
138
|
-
posAfter(idx: number): TextPos | undefined;
|
139
|
-
/**
|
140
|
-
* Get the index of a specific position.
|
141
|
-
*/
|
142
|
-
idxBefore(pos: TextPos): number | undefined;
|
143
|
-
/**
|
144
|
-
* Get the index of a specific position.
|
145
|
-
*/
|
146
|
-
idxAfter(pos: TextPos): number | undefined;
|
147
|
-
/**
|
148
|
-
* Insert a mark at a specific range.
|
149
|
-
*/
|
150
|
-
insertMark<MarkClass extends {
|
151
|
-
new (...args: any[]): Mark;
|
152
|
-
create(init: any, options: {
|
153
|
-
owner: Account | Group;
|
154
|
-
}): Mark;
|
155
|
-
}>(start: number, end: number, RangeClass: MarkClass, extraArgs: Omit<CoMapInit<InstanceType<MarkClass>>, "startAfter" | "startBefore" | "endAfter" | "endBefore">, options?: {
|
156
|
-
markOwner?: Account | Group;
|
157
|
-
}): void;
|
158
|
-
/**
|
159
|
-
* Remove a mark at a specific range.
|
160
|
-
*/
|
161
|
-
removeMark<MarkClass extends {
|
162
|
-
new (...args: any[]): Mark;
|
163
|
-
create(init: any, options: {
|
164
|
-
owner: Account | Group;
|
165
|
-
}): Mark;
|
166
|
-
}>(start: number, end: number, RangeClass: MarkClass, options: {
|
167
|
-
tag: string;
|
168
|
-
}): void;
|
169
|
-
/**
|
170
|
-
* Resolve the positions of all marks.
|
171
|
-
*/
|
172
|
-
resolveMarks(): ResolvedMark[];
|
173
|
-
/**
|
174
|
-
* Resolve and diffuse the positions of all marks.
|
175
|
-
*/
|
176
|
-
resolveAndDiffuseMarks(): ResolvedAndDiffusedMark[];
|
177
|
-
/**
|
178
|
-
* Resolve, diffuse, and focus the positions of all marks.
|
179
|
-
*/
|
180
|
-
resolveAndDiffuseAndFocusMarks(): ResolvedAndFocusedMark[];
|
181
|
-
/**
|
182
|
-
* Convert a CoRichText to a tree structure useful for client libraries.
|
183
|
-
*/
|
184
|
-
toTree(tagPrecedence: string[]): TreeNode;
|
185
|
-
get length(): number;
|
186
|
-
/**
|
187
|
-
* Convert a CoRichText to plain text.
|
188
|
-
*/
|
189
|
-
toString(): string;
|
190
|
-
}
|
191
|
-
/**
|
192
|
-
* Represents a leaf node in the rich text tree structure.
|
193
|
-
* Contains plain text without any marks.
|
194
|
-
*/
|
195
|
-
export type TreeLeaf = {
|
196
|
-
type: "leaf";
|
197
|
-
start: number;
|
198
|
-
end: number;
|
199
|
-
};
|
200
|
-
/**
|
201
|
-
* Represents a node in the rich text tree structure.
|
202
|
-
* Can contain other nodes or leaves, and includes formatting information.
|
203
|
-
*/
|
204
|
-
export type TreeNode = {
|
205
|
-
type: "node";
|
206
|
-
tag: string;
|
207
|
-
start: number;
|
208
|
-
end: number;
|
209
|
-
range?: ResolvedAndFocusedMark;
|
210
|
-
children: (TreeNode | TreeLeaf)[];
|
211
|
-
};
|
212
|
-
/**
|
213
|
-
* Split a node at a specific index. So that the node is split into two parts, one before the index, and one after the index.
|
214
|
-
*/
|
215
|
-
export declare function splitNode(node: TreeNode | TreeLeaf, at: number): [TreeNode | TreeLeaf | undefined, TreeNode | TreeLeaf | undefined];
|
216
|
-
/**
|
217
|
-
* Heading mark for rich text formatting.
|
218
|
-
*/
|
219
|
-
export declare class Heading extends Mark {
|
220
|
-
tag: co<"heading">;
|
221
|
-
level: co<number>;
|
222
|
-
}
|
223
|
-
/**
|
224
|
-
* Paragraph mark for rich text formatting.
|
225
|
-
*/
|
226
|
-
export declare class Paragraph extends Mark {
|
227
|
-
tag: co<"paragraph">;
|
228
|
-
}
|
229
|
-
/**
|
230
|
-
* Link mark for rich text formatting.
|
231
|
-
*/
|
232
|
-
export declare class Link extends Mark {
|
233
|
-
tag: co<"link">;
|
234
|
-
url: co<string>;
|
235
|
-
}
|
236
|
-
/**
|
237
|
-
* Strong (bold) mark for rich text formatting.
|
238
|
-
*/
|
239
|
-
export declare class Strong extends Mark {
|
240
|
-
tag: co<"strong">;
|
241
|
-
}
|
242
|
-
/**
|
243
|
-
* Emphasis (italic) mark for rich text formatting.
|
244
|
-
*/
|
245
|
-
export declare class Em extends Mark {
|
246
|
-
tag: co<"em">;
|
247
|
-
}
|
248
|
-
/**
|
249
|
-
* Collection of predefined mark types for common text formatting.
|
250
|
-
* Includes marks for headings, paragraphs, links, and text styling.
|
251
|
-
*/
|
252
|
-
export declare const Marks: {
|
253
|
-
Heading: typeof Heading;
|
254
|
-
Paragraph: typeof Paragraph;
|
255
|
-
Link: typeof Link;
|
256
|
-
Strong: typeof Strong;
|
257
|
-
Em: typeof Em;
|
258
|
-
};
|
259
4
|
//# sourceMappingURL=coRichText.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"coRichText.d.ts","sourceRoot":"","sources":["../../src/coValues/coRichText.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"coRichText.d.ts","sourceRoot":"","sources":["../../src/coValues/coRichText.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,qBAAa,UAAW,SAAQ,WAAW;CAAG"}
|
package/dist/exports.d.ts
CHANGED
@@ -7,7 +7,7 @@ export { BinaryCoStream, CoFeed, CoStream, type CoFeedEntry, FileStream, } from
|
|
7
7
|
export { CoList } from "./coValues/coList.js";
|
8
8
|
export { CoMap, type CoMapInit } from "./coValues/coMap.js";
|
9
9
|
export { CoPlainText, type TextPos } from "./coValues/coPlainText.js";
|
10
|
-
export { CoRichText
|
10
|
+
export { CoRichText } from "./coValues/coRichText.js";
|
11
11
|
export { ImageDefinition } from "./coValues/extensions/imageDef.js";
|
12
12
|
export { Group } from "./coValues/group.js";
|
13
13
|
export { CoValueBase } from "./coValues/interfaces.js";
|
package/dist/exports.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,OAAO,EACP,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,IAAI,EACJ,SAAS,EACT,WAAW,GACZ,MAAM,QAAQ,CAAC;AAEhB,YAAY,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,KAAK,YAAY,EACjB,KAAK,oBAAoB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,cAAc,EACd,MAAM,EACN,QAAQ,EACR,KAAK,WAAW,EAChB,UAAU,GACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,KAAK,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":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AAkB,EAClB,KAAK,2BAA2B,GACjC,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,KAAK,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,wCAAwC,EACxC,8BAA8B,EAC9B,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,sBAAsB,GAC5B,MAAM,eAAe,CAAC;AAEvB,mBAAmB,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
@@ -18,7 +18,6 @@ import {
|
|
18
18
|
InboxSender,
|
19
19
|
JazzContextManager,
|
20
20
|
KvStoreContext,
|
21
|
-
Marks,
|
22
21
|
PassphraseAuth,
|
23
22
|
Profile,
|
24
23
|
SchemaUnion,
|
@@ -35,7 +34,7 @@ import {
|
|
35
34
|
parseInviteLink,
|
36
35
|
randomSessionProvider,
|
37
36
|
subscribeToCoValue
|
38
|
-
} from "./chunk-
|
37
|
+
} from "./chunk-I7NYAGLP.js";
|
39
38
|
|
40
39
|
// src/index.ts
|
41
40
|
import { MAX_RECOMMENDED_TX_SIZE, cojsonInternals } from "cojson";
|
@@ -62,7 +61,6 @@ export {
|
|
62
61
|
JazzContextManager,
|
63
62
|
KvStoreContext,
|
64
63
|
MAX_RECOMMENDED_TX_SIZE,
|
65
|
-
Marks,
|
66
64
|
PassphraseAuth,
|
67
65
|
Profile,
|
68
66
|
SchemaUnion,
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./exports.js\";\n\nexport { MAX_RECOMMENDED_TX_SIZE, cojsonInternals } from \"cojson\";\n"],"mappings":"
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./exports.js\";\n\nexport { MAX_RECOMMENDED_TX_SIZE, cojsonInternals } from \"cojson\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,yBAAyB,uBAAuB;","names":[]}
|
package/dist/testing.js
CHANGED
package/package.json
CHANGED
@@ -17,11 +17,11 @@
|
|
17
17
|
},
|
18
18
|
"type": "module",
|
19
19
|
"license": "MIT",
|
20
|
-
"version": "0.13.
|
20
|
+
"version": "0.13.11",
|
21
21
|
"dependencies": {
|
22
22
|
"@scure/bip39": "^1.3.0",
|
23
23
|
"fast-myers-diff": "^3.2.0",
|
24
|
-
"cojson": "0.13.
|
24
|
+
"cojson": "0.13.11"
|
25
25
|
},
|
26
26
|
"devDependencies": {
|
27
27
|
"tsup": "8.3.5",
|
@@ -4,6 +4,7 @@ import {
|
|
4
4
|
type RawCoPlainText,
|
5
5
|
stringifyOpID,
|
6
6
|
} from "cojson";
|
7
|
+
import { calcPatch } from "fast-myers-diff";
|
7
8
|
import type {
|
8
9
|
AnonymousJazzAgent,
|
9
10
|
CoValue,
|
@@ -45,7 +46,7 @@ export class CoPlainText extends String implements CoValue {
|
|
45
46
|
| { fromRaw: RawCoPlainText }
|
46
47
|
| { text: string; owner: Account | Group },
|
47
48
|
) {
|
48
|
-
super();
|
49
|
+
super("fromRaw" in options ? options.fromRaw.toString() : options.text);
|
49
50
|
|
50
51
|
let raw;
|
51
52
|
|
@@ -90,6 +91,10 @@ export class CoPlainText extends String implements CoValue {
|
|
90
91
|
return this.toJSON();
|
91
92
|
}
|
92
93
|
|
94
|
+
insertBefore(idx: number, text: string) {
|
95
|
+
this._raw.insertBefore(idx, text);
|
96
|
+
}
|
97
|
+
|
93
98
|
insertAfter(idx: number, text: string) {
|
94
99
|
this._raw.insertAfter(idx, text);
|
95
100
|
}
|
@@ -121,6 +126,23 @@ export class CoPlainText extends String implements CoValue {
|
|
121
126
|
return new this({ fromRaw: raw });
|
122
127
|
}
|
123
128
|
|
129
|
+
/**
|
130
|
+
* Apply text, modifying the text in place. Calculates the diff and applies it to the CoValue.
|
131
|
+
*
|
132
|
+
* @category Mutation
|
133
|
+
*/
|
134
|
+
applyDiff(other: string) {
|
135
|
+
const current = this._raw.toString();
|
136
|
+
for (const [from, to, insert] of [...calcPatch(current, other)].reverse()) {
|
137
|
+
if (to > from) {
|
138
|
+
this.deleteRange({ from, to });
|
139
|
+
}
|
140
|
+
if (insert.length > 0) {
|
141
|
+
this.insertBefore(from, insert);
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}
|
145
|
+
|
124
146
|
/**
|
125
147
|
* Load a `CoPlainText` with a given ID, as a given account.
|
126
148
|
*
|