ProjectDocument builds a stable traversal view from legacy and tab-aware Docs fields.
(document *docs.Document)
| 102 | |
| 103 | // ProjectDocument builds a stable traversal view from legacy and tab-aware Docs fields. |
| 104 | func ProjectDocument(document *docs.Document) DocumentProjection { |
| 105 | if document == nil { |
| 106 | return DocumentProjection{} |
| 107 | } |
| 108 | |
| 109 | projection := DocumentProjection{RevisionID: document.RevisionId} |
| 110 | if document.Body != nil || len(document.InlineObjects) > 0 || len(document.PositionedObjects) > 0 { |
| 111 | legacy := projectDocumentSegment( |
| 112 | "", |
| 113 | "", |
| 114 | document.Body, |
| 115 | document.InlineObjects, |
| 116 | document.PositionedObjects, |
| 117 | ) |
| 118 | projection.Legacy = &legacy |
| 119 | } |
| 120 | projectTabs(document.Tabs, &projection.Tabs) |
| 121 | return projection |
| 122 | } |
| 123 | |
| 124 | func projectTabs(tabs []*docs.Tab, projected *[]DocumentSegment) { |
| 125 | for _, tab := range tabs { |