Skip to content

Commit

Permalink
Making __ids readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
Ebad Salehi committed Nov 8, 2024
1 parent 0048517 commit bad6b07
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/lexical-mark/src/MarkNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type SerializedMarkNode = Spread<
/** @noInheritDoc */
export class MarkNode extends ElementNode {
/** @internal */
__ids: Array<string>;
__ids: readonly string[];

static getType(): string {
return 'mark';
Expand All @@ -57,13 +57,13 @@ export class MarkNode extends ElementNode {
exportJSON(): SerializedMarkNode {
return {
...super.exportJSON(),
ids: this.getIDs(),
ids: Array.from(this.getIDs()),
type: 'mark',
version: 1,
};
}

constructor(ids: Array<string>, key?: NodeKey) {
constructor(ids: readonly string[], key?: NodeKey) {
super(key);
this.__ids = ids || [];
}
Expand Down Expand Up @@ -112,7 +112,7 @@ export class MarkNode extends ElementNode {

getIDs(): Array<string> {
const self = this.getLatest();
return $isMarkNode(self) ? self.__ids : [];
return $isMarkNode(self) ? Array.from(self.__ids) : [];
}

addID(id: string): void {
Expand Down Expand Up @@ -197,7 +197,7 @@ export class MarkNode extends ElementNode {
}
}

export function $createMarkNode(ids: Array<string>): MarkNode {
export function $createMarkNode(ids: readonly string[]): MarkNode {
return $applyNodeReplacement(new MarkNode(ids));
}

Expand Down

0 comments on commit bad6b07

Please sign in to comment.