Skip to content

Commit

Permalink
Add missing comments to exposed interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
hackerwins committed Jul 5, 2023
1 parent 6dc3195 commit 83f6ab7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/document/json/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ export class Tree {
}

/**
* `getInitialRoot` returns the root node of this tree.
* `buildRoot` builds the root of this tree with the given initial root
* which set by the user.
*/
public buildRoot(context: ChangeContext): CRDTTreeNode {
if (!this.initialRoot) {
Expand Down Expand Up @@ -438,7 +439,7 @@ export class Tree {
}

/**
* `createRange` returns pair of CRDTTreePos of the given integer offsets.
* `createRangeByPath` returns pair of CRDTTreePos of the given path.
*/
createRangeByPath(fromPath: Array<number>, toPath: Array<number>): TreeRange {
if (!this.context || !this.tree) {
Expand Down
40 changes: 40 additions & 0 deletions src/document/operation/operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,57 @@ export type CounterOperationInfo = IncreaseOpInfo;
export type ArrayOperationInfo = AddOpInfo | RemoveOpInfo | MoveOpInfo;
export type ObjectOperationInfo = SetOpInfo | RemoveOpInfo;
export type TreeOperationInfo = TreeEditOpInfo | TreeStyleOpInfo;

/**
* `AddOpInfo` represents the information of the add operation.
*/
export type AddOpInfo = {
type: 'add';
path: string;
index: number;
};

/**
* `MoveOpInfo` represents the information of the move operation.
*/
export type MoveOpInfo = {
type: 'move';
path: string;
previousIndex: number;
index: number;
};

/**
* `SetOpInfo` represents the information of the set operation.
*/
export type SetOpInfo = {
type: 'set';
path: string;
key: string;
};

/**
* `RemoveOpInfo` represents the information of the remove operation.
*/
export type RemoveOpInfo = {
type: 'remove';
path: string;
key?: string;
index?: number;
};

/**
* `IncreaseOpInfo` represents the information of the increase operation.
*/
export type IncreaseOpInfo = {
type: 'increase';
path: string;
value: number;
};

/**
* `EditOpInfo` represents the information of the edit operation.
*/
export type EditOpInfo = {
type: 'edit';
from: number;
Expand All @@ -73,6 +97,10 @@ export type EditOpInfo = {
content: string;
};
};

/**
* `StyleOpInfo` represents the information of the style operation.
*/
export type StyleOpInfo = {
type: 'style';
from: number;
Expand All @@ -82,12 +110,20 @@ export type StyleOpInfo = {
attributes: Indexable;
};
};

/**
* `SelectOpInfo` represents the information of the select operation.
*/
export type SelectOpInfo = {
type: 'select';
from: number;
to: number;
path: string;
};

/**
* `TreeEditOpInfo` represents the information of the tree edit operation.
*/
export type TreeEditOpInfo = {
type: 'tree-edit';
from: number;
Expand All @@ -97,6 +133,10 @@ export type TreeEditOpInfo = {
value: TreeNode;
path: string;
};

/**
* `TreeStyleOpInfo` represents the information of the tree style operation.
*/
export type TreeStyleOpInfo = {
type: 'tree-style';
from: number;
Expand Down

0 comments on commit 83f6ab7

Please sign in to comment.