If possible, Suggested changes should omit Deleted text and only include Inserted text
Currently, both are concatenated one after the other, sometimes causing incomprehensible output.
Oh, interesting! I hadn't looked at how edits in suggest changes mode show up at all. I will see what I can do. Alternatively, feel free to file a PR!
Well, the bad news is that I don’t think this is going to be possible in Safari. It should be do-able in most other browsers, but it might be a little complex and take some time.
The basic setup here is that Google Docs doesn’t put anything in the rich text/HTML representation of the document that differentiates between the suggested and normal text. However, there is some info about the suggestions in the "Docs Slice" proprietary format of the data. Safari’s security restrictions prevent us from reading that data from the pasteboard (since it comes from a different domain, we only get the standardized formats and nothing proprietary/custom), but we can check it in most other browsers.
In the docs slice, we have data.resolved.dsl_suggesteddeletions and data.resolved.dsl_suggestedinsertions for deletions and insertions, respectively. Each one contains an stsl_sugg array that has sub-arrays at the indexes where the suggestions start and end in the text. Other indexes are null. The subarray has one value in it if it is the start of a suggestion and no values in it if it is the end of the suggestion.
For example, the text (where ~ marks a deletion and + an insertion):
This is a test of +suggested +changes +to+~in~ documents.
^^ ^^ ^^ ^^^ ^^
| | | | |
18 28 36 | 40
38
Has slice clip data like:
{
"resolved": {
"dsl_spacers": "This is a test of suggested changes toin documents.",
"dsl_suggestedinsertions": {
"sgsl_sugg": [
[],
null, // repeated nulls for indexes 1-17
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
["suggest.36xzw8xfadwd"], // at index 18
null, // repeated nulls for indexes 19-27
null,
null,
null,
null,
null,
null,
null,
null,
[], // at index 28
null, // repeated nulls for indexes 29-35
null,
null,
null,
null,
null,
null,
["suggest.mtgbiqaxvzgz"], // at index 36
null,
[] // at index 38
]
},
"dsl_suggesteddeletions": {
"sgsl_sugg": [
[],
null, // repeated nulls for indexes 1-37
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
["suggest.mtgbiqaxvzgz"], // at index 38
null,
[] // at index 40
]
}
// ...other properties...
}
}
The values are in the form: suggest.<id> where the id is the same for the insertion and deletion entry of something that is a replacement.
@hftf in the mean time (or if you are in Safari), I think the best you can really do is switch the doc to “viewing” mode (instead of “editing” or “suggesting”) and copy from there. Unfortunately that hides the suggestions, rather than taking/using them.
Thank you for investigating! I don't think I have the bandwidth to learn the codebase and make a PR at the moment, so will await progress if there is any!