Skip to content

Commit 2f87b8a

Browse files
committed
fix(json-crdt-extensions): 🐛 allow setting non-constant slice data
1 parent c529aaf commit 2f87b8a

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/json-crdt-extensions/peritext/Peritext.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ export class Peritext implements Printable {
111111
}
112112

113113
/**
114-
* Creates a point at a view position in the text. The `pos` argument specifies
115-
* the position of the character, not the gap between characters.
114+
* Creates a point at a view position in the text. The `pos` argument
115+
* specifies the position of the character, not the gap between characters.
116116
*
117117
* @param pos Position of the character in the text.
118118
* @param anchor Whether the point should attach before or after a character.
@@ -162,7 +162,8 @@ export class Peritext implements Printable {
162162
}
163163

164164
/**
165-
* Creates a range from two points, the points have to be in the correct order.
165+
* Creates a range from two points, the points have to be in the correct
166+
* order.
166167
*
167168
* @param start Start point of the range, must be before or equal to end.
168169
* @param end End point of the range, must be after or equal to start.
@@ -173,8 +174,8 @@ export class Peritext implements Printable {
173174
}
174175

175176
/**
176-
* A convenience method for creating a range from a view position and a length.
177-
* See {@link Range.at} for more information.
177+
* A convenience method for creating a range from a view position and a
178+
* length. See {@link Range.at} for more information.
178179
*
179180
* @param start Position in the text.
180181
* @param length Length of the range.

src/json-crdt-extensions/peritext/editor/Editor.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import type {SliceType} from '../slice/types';
1212
import type {MarkerSlice} from '../slice/MarkerSlice';
1313
import type {Slices} from '../slice/Slices';
1414

15+
/**
16+
* Rename to `PeritextApi`.
17+
*/
1518
export class Editor implements Printable {
1619
/**
1720
* Cursor is the the current user selection. It can be a caret or a
@@ -25,6 +28,7 @@ export class Editor implements Printable {
2528
) {
2629
const point = txt.pointAbsStart();
2730
const range = txt.range(point, point.clone());
31+
// TODO: Add ability to remove cursor.
2832
this.cursor = slices.ins<Cursor, typeof Cursor>(range, SliceBehavior.Cursor, CursorAnchor.Start, undefined, Cursor);
2933
}
3034

src/json-crdt-extensions/peritext/slice/PersistedSlice.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class PersistedSlice<T = string> extends Range<T> implements MutableSlice
112112
this.type = params.type;
113113
changes.push([SliceTupleIndex.Type, s.con(this.type)]);
114114
}
115-
if (hasOwnProperty(params, 'data')) changes.push([SliceTupleIndex.Data, s.con(params.data)]);
115+
if (hasOwnProperty(params, 'data')) changes.push([SliceTupleIndex.Data, params.data]);
116116
if (updateHeader) {
117117
const header =
118118
(this.behavior << SliceHeaderShift.Behavior) +

0 commit comments

Comments
 (0)