fix: don't leak HTML comment content into pasted paragraph text

_parseDeltaElement's fallback branch called child.text on any
non-Element DOM node, including dom.Comment (whose .text getter
aliases its raw data). This let real HTML comments -- e.g. the
internal tracking marker Google's AI Overview panel injects when
you copy its answer text -- surface as visible garbage in the
editor. Skip non-Text nodes here, matching the dom.Text check
_parseElement already does one level up.
This commit is contained in:
Nathan 2026-07-07 13:30:19 +08:00
commit bb995825dd

View file

@ -470,9 +470,11 @@ class DocumentHTMLDecoder extends Converter<String, Document> {
);
}
}
} else {
delta.insert(child.text?.replaceAll(RegExp(r'\n+$'), '') ?? '');
} else if (child is dom.Text) {
delta.insert(child.text.replaceAll(RegExp(r'\n+$'), ''));
}
// other node types (e.g. dom.Comment) carry no visible content and
// are intentionally skipped, mirroring _parseElement's handling.
}
return (delta, nodes);