Skip to content

Commit bc21468

Browse files
committed
feat(websocket): Allow to return { text: string; } style lines from update
1 parent 9806ecd commit bc21468

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

websocket/makeChanges.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@ import type { Page } from "@cosense/types/rest";
33
import type { Change } from "./change.ts";
44
import { findMetadata, getHelpfeels } from "./findMetadata.ts";
55
import { isSameArray } from "./isSameArray.ts";
6+
import { isString } from "@core/unknownutil/is/string";
67

78
export function* makeChanges(
89
before: Page,
9-
after: string[],
10+
after: (string | { text: string })[],
1011
userId: string,
1112
): Generator<Change, void, unknown> {
1213
// Prevent newline characters from being included in the text
1314
// This ensures consistent line handling across different platforms
14-
const after_ = after.flatMap((text) => text.split("\n"));
15+
const after_ = after.flatMap((text) =>
16+
(isString(text) ? text : text.text).split("\n")
17+
);
1518

1619
// First, yield changes in the main content
1720
// Content changes must be processed before metadata to maintain consistency

websocket/patch.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ export const patch = (
4848
update: (
4949
lines: BaseLine[],
5050
metadata: PatchMetadata,
51-
) => string[] | undefined | Promise<string[] | undefined>,
51+
) =>
52+
| (string | { text: string })[]
53+
| undefined
54+
| Promise<(string | { text: string })[] | undefined>,
5255
options?: PatchOptions,
5356
): Promise<Result<string, PushError | Socket.DisconnectReason>> =>
5457
push(

0 commit comments

Comments
 (0)