When utilizing a WKWebView with a contenteditable div as a textual content editor, I’ve the next CSS utilized to the editor container:
#editor {
font-size: 12pt;
}
At any time when the consumer accepts an autocorrect suggestion or QuickType prediction, WebKit mechanically wraps the affected textual content in a with specific inline kinds, for instance:
corrected phrase
This solely occurs to textual content touched by autocorrect/prediction, not your complete paragraph, so the ensuing innerHTML turns into inconsistent.
What I’ve confirmed up to now:
-
The visible distinction seems to be precipitated particularly by
font-size: 12pt -
-webkit-text-size-adjust: 100%itself doesn’t seem to have an effect on rendering -
This conduct doesn’t reproduce on desktop browsers
-
Seems to be particular to iOS WebKit /
WKWebView
Questions:
-
Is there any strategy to stop WebKit from materializing computed CSS into inline kinds throughout autocorrect, with out disabling autocorrect solely?
-
Is that this conduct formally documented wherever?
-
What precisely triggers this injection — solely autocorrect, or additionally QuickType, paste, spellcheck, and different enhancing operations?
-
Is post-processing/sanitizing the generated HTML to strip these injected inline kinds thought of the usual workaround?
