API to point to next and previous paragraph from the current paragraph
It would be very useful for processing large document to have the ability to access previous and next paragraph from any paragraph object.
Thanks

Thank you for the feedback! We’re happy to let you know that we’ve started work on this.
As always, we present the design for review under the open-spec branches of this repository: https://github.com/officedev/office-js-docs. Please review it and let us know what you think.
Thanks!
Office Extensibility Team
2 comments
-
Petr Simon commented
Finally had a chance to test it. Thank you again. Just in case someone runs into this thread, this is how I do it.
Word.run(function (context) {
var range = context.document.getSelection();
context.load(range.paragraphs);
return context.sync()
.then(function () {
var para = range.paragraphs.items[0];
for (var i = 0; i < totalBefore; i++) {
para = para.getPrevious();
loadedParagraphs.splice(0, 0, para);
}para = range.paragraphs.items[0];
for (var i = 0; i < totalAfter; i++) {
para = para.getNext();
loadedParagraphs.push(para);
}loadedParagraphs.forEach(function (p) {
context.load(p);
});loadedParagraphs.splice(totalBefore, 0, range.paragraphs.items[0]);
})
.then(context.sync)
.then(processParagraphs)
.then(context.sync)
}) -
Petr Simon commented
That's great! Thank you.