You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// whitespace and some characters; for example, `👨👦` becomes `👨‍👦` after processing by TinyMCE. Therefore, HTML processed by TinyMCE needs to be normalized before it can be compared.
1074
+
//
1075
+
// 1. Document-only: HTML is stored in `.doc`;
1076
+
// ignore `.doc_blocks`.
1077
+
// 2. Normal mode: HTML is stored in
1078
+
// `.doc_blocks`; perform a binary compare of
1079
+
// `.doc`, then an HTML comparison of `.doc_blocks`.
1079
1080
//
1080
-
// 1. Compare the `doc` values. If they differ,
1081
-
// then the the Client needs an update.
1082
-
// 2. Compare each code block using simple
1083
-
// equality. If this fails, compare the doc
1084
-
// block text excluding newlines. If still
1085
-
// different, then the Client needs an
1086
-
// update.
1087
-
if code_mirror_translated.doc != self.code_mirror_doc
1088
-
|| !doc_block_compare(
1089
-
&code_mirror_translated.doc_blocks,
1090
-
self.code_mirror_doc_blocks.as_ref().unwrap(),
1091
-
)
1081
+
// It looks like comparing HTML is risky, since TinyMCE (or something) store emojis differently. Perhaps we need to compare Markdown instead of HTML? Or HTML after processing? The second seems easier.
1082
+
let is_markdown_mode = cfw.metadata.mode == MARKDOWN_MODE;
// TinyMCE replaces newlines inside paragraphs with a space and (I think) avoids surrogate pairs by breaking them into a series of UTF-16 characters. Therefore, to compare HTML, normalize HTML touched by TinyMCE first.
1198
+
fncompare_html(
1199
+
// A string containing HTML that's been normalized by html5ever.
1200
+
normalized_html:&str,
1201
+
// A string containing HTML that's not normalized; for example, data after processing by TinyMCE.
1202
+
raw_html:&str,
1203
+
) -> bool{
1204
+
// The normalized HTML is word-wrapped, while the raw HTML is not. Use this to ignore the differences between newlines and spaces, in order to ignore these differences.
0 commit comments