@@ -107,18 +107,18 @@ func enumerateDocsSuggestions(doc *docs.Document) []docsSuggestionListItem {
107107 }
108108
109109 items := make ([]docsSuggestionListItem , 0 )
110- collectDocsSuggestionSegment (& items , "body" , bodyContent (doc .Body ))
110+ collectDocsSuggestionSegment (& items , doc , "body" , bodyContent (doc .Body ))
111111 for _ , id := range sortedDocsMapKeys (doc .Headers ) {
112112 header := doc .Headers [id ]
113- collectDocsSuggestionSegment (& items , "header:" + id , header .Content )
113+ collectDocsSuggestionSegment (& items , doc , "header:" + id , header .Content )
114114 }
115115 for _ , id := range sortedDocsMapKeys (doc .Footers ) {
116116 footer := doc .Footers [id ]
117- collectDocsSuggestionSegment (& items , "footer:" + id , footer .Content )
117+ collectDocsSuggestionSegment (& items , doc , "footer:" + id , footer .Content )
118118 }
119119 for _ , id := range sortedDocsMapKeys (doc .Footnotes ) {
120120 footnote := doc .Footnotes [id ]
121- collectDocsSuggestionSegment (& items , "footnote:" + id , footnote .Content )
121+ collectDocsSuggestionSegment (& items , doc , "footnote:" + id , footnote .Content )
122122 }
123123 return items
124124}
@@ -141,6 +141,7 @@ func sortedDocsMapKeys[T any](values map[string]T) []string {
141141
142142func collectDocsSuggestionSegment (
143143 items * []docsSuggestionListItem ,
144+ doc * docs.Document ,
144145 segment string ,
145146 content []* docs.StructuralElement ,
146147) {
@@ -164,6 +165,14 @@ func collectDocsSuggestionSegment(
164165 )
165166 }
166167 if element .Paragraph != nil {
168+ appendDocsParagraphMapSuggestions (
169+ items ,
170+ lastByKey ,
171+ doc ,
172+ segment ,
173+ element .StartIndex ,
174+ element .Paragraph ,
175+ )
167176 for _ , paragraphElement := range element .Paragraph .Elements {
168177 if paragraphElement == nil {
169178 continue
@@ -173,6 +182,7 @@ func collectDocsSuggestionSegment(
173182 lastByKey ,
174183 segment ,
175184 paragraphElement ,
185+ doc .InlineObjects ,
176186 insertionIDs ,
177187 deletionIDs ,
178188 )
@@ -211,15 +221,61 @@ func collectDocsSuggestionSegment(
211221 walk (content , nil , nil )
212222}
213223
224+ func appendDocsParagraphMapSuggestions (
225+ items * []docsSuggestionListItem ,
226+ lastByKey map [string ]int ,
227+ doc * docs.Document ,
228+ segment string ,
229+ anchorIndex int64 ,
230+ paragraph * docs.Paragraph ,
231+ ) {
232+ if paragraph .Bullet != nil {
233+ if list , ok := doc .Lists [paragraph .Bullet .ListId ]; ok {
234+ appendDocsSuggestionRange (
235+ items ,
236+ lastByKey ,
237+ segment ,
238+ anchorIndex ,
239+ anchorIndex ,
240+ "" ,
241+ []string {list .SuggestedInsertionId },
242+ list .SuggestedDeletionIds ,
243+ )
244+ }
245+ }
246+
247+ objectIDs := append ([]string (nil ), paragraph .PositionedObjectIds ... )
248+ for _ , suggestionID := range sortedDocsMapKeys (paragraph .SuggestedPositionedObjectIds ) {
249+ objectIDs = append (objectIDs , paragraph .SuggestedPositionedObjectIds [suggestionID ].ObjectIds ... )
250+ }
251+ for _ , objectID := range sortedUniqueStrings (objectIDs ) {
252+ object , ok := doc .PositionedObjects [objectID ]
253+ if ! ok {
254+ continue
255+ }
256+ appendDocsSuggestionRange (
257+ items ,
258+ lastByKey ,
259+ segment ,
260+ anchorIndex ,
261+ anchorIndex ,
262+ "" ,
263+ []string {object .SuggestedInsertionId },
264+ object .SuggestedDeletionIds ,
265+ )
266+ }
267+ }
268+
214269func appendDocsSuggestionElement (
215270 items * []docsSuggestionListItem ,
216271 lastByKey map [string ]int ,
217272 segment string ,
218273 element * docs.ParagraphElement ,
274+ inlineObjects map [string ]docs.InlineObject ,
219275 inheritedInsertionIDs []string ,
220276 inheritedDeletionIDs []string ,
221277) {
222- text , insertionIDs , deletionIDs , ok := docsParagraphElementSuggestions (element )
278+ text , insertionIDs , deletionIDs , ok := docsParagraphElementSuggestions (element , inlineObjects )
223279 if ! ok {
224280 return
225281 }
@@ -269,7 +325,10 @@ func appendDocsSuggestionRange(
269325 appendIDs ("deletion" , deletionIDs )
270326}
271327
272- func docsParagraphElementSuggestions (element * docs.ParagraphElement ) (
328+ func docsParagraphElementSuggestions (
329+ element * docs.ParagraphElement ,
330+ inlineObjects map [string ]docs.InlineObject ,
331+ ) (
273332 text string ,
274333 insertionIDs []string ,
275334 deletionIDs []string ,
@@ -294,7 +353,13 @@ func docsParagraphElementSuggestions(element *docs.ParagraphElement) (
294353 case element .HorizontalRule != nil :
295354 return "" , element .HorizontalRule .SuggestedInsertionIds , element .HorizontalRule .SuggestedDeletionIds , true
296355 case element .InlineObjectElement != nil :
297- return "" , element .InlineObjectElement .SuggestedInsertionIds , element .InlineObjectElement .SuggestedDeletionIds , true
356+ insertionIDs := element .InlineObjectElement .SuggestedInsertionIds
357+ deletionIDs := element .InlineObjectElement .SuggestedDeletionIds
358+ if object , ok := inlineObjects [element .InlineObjectElement .InlineObjectId ]; ok {
359+ insertionIDs = mergeDocsSuggestionIDs (insertionIDs , []string {object .SuggestedInsertionId })
360+ deletionIDs = mergeDocsSuggestionIDs (deletionIDs , object .SuggestedDeletionIds )
361+ }
362+ return "" , insertionIDs , deletionIDs , true
298363 case element .PageBreak != nil :
299364 return "" , element .PageBreak .SuggestedInsertionIds , element .PageBreak .SuggestedDeletionIds , true
300365 case element .Person != nil :
0 commit comments