-
Notifications
You must be signed in to change notification settings - Fork 0
fix(sync): content_preview / content_text から HTML タグを除去 #498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -296,7 +296,15 @@ export class CollaborationManager { | |
| const parts: string[] = []; | ||
| const walk = (node: Y.XmlFragment | Y.XmlElement | Y.XmlText) => { | ||
| if (node instanceof Y.XmlText) { | ||
| parts.push(node.toJSON()); | ||
| // toDelta() を使い書式属性なしの純粋なテキストのみを抽出する。 | ||
| // toString() / toJSON() は <bold> 等の HTML タグを返すため使用しない。 | ||
| // Use toDelta() to extract pure text without formatting attributes. | ||
| // toString() / toJSON() return HTML-like tags (<bold>, etc.) so we avoid them. | ||
| for (const op of node.toDelta()) { | ||
| if (typeof op.insert === "string") { | ||
| parts.push(op.insert); | ||
| } | ||
| } | ||
| } else { | ||
| for (const child of node.toArray()) { | ||
| if ( | ||
|
Comment on lines
+303
to
310
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Client-side extractText inserts spurious newlines between formatted text runs The old code pushed one string per This corrupts (Refers to lines 289-307) Prompt for agentsWas this helpful? React with 👍 or 👎 to provide feedback. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node.toDelta()は、テキスト内の書式(太字、斜体など)が切り替わる箇所で複数のopを返します。現在の実装では、各op.insertを個別にparts配列に push していますが、最終的にparts.join("\n")(307行目)で連結されるため、書式の境界ごとに意図しない改行が挿入されてしまいます。XmlTextノード内のテキストは、改行を挟まずに結合してからpartsに追加することで、以前のtoJSON()を使用していた時と同様の構造(1つのXmlTextノードにつき1つのparts要素)を維持しつつ、HTML タグのみを除去できます。