Skip to content

Commit b2492b0

Browse files
[Word] Additional Range mappings
1 parent 60a376c commit b2492b0

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
55 Bytes
Binary file not shown.

snippet-extractor-output/snippets.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22393,6 +22393,37 @@
2239322393
const locationValue: Word.LocationRelation = comparedLocation.value;
2239422394
console.log(`Location of the first paragraph in relation to the second paragraph: ${locationValue}`);
2239522395
});
22396+
'Word.Range#expandTo:member(1)':
22397+
- >-
22398+
// Link to full sample:
22399+
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml
22400+
22401+
22402+
await Word.run(async (context) => {
22403+
// Get the complete sentence (as range) associated with the insertion point.
22404+
const sentences: Word.RangeCollection = context.document
22405+
.getSelection()
22406+
.getTextRanges(["."] /* Using the "." as delimiter */, false /*means without trimming spaces*/);
22407+
sentences.load("$none");
22408+
await context.sync();
22409+
22410+
// Expand the range to the end of the paragraph to get all the complete sentences.
22411+
const sentencesToTheEndOfParagraph: Word.RangeCollection = sentences.items[0]
22412+
.getRange()
22413+
.expandTo(
22414+
context.document
22415+
.getSelection()
22416+
.paragraphs.getFirst()
22417+
.getRange(Word.RangeLocation.end)
22418+
)
22419+
.getTextRanges(["."], false /* Don't trim spaces*/);
22420+
sentencesToTheEndOfParagraph.load("text");
22421+
await context.sync();
22422+
22423+
for (let i = 0; i < sentencesToTheEndOfParagraph.items.length; i++) {
22424+
console.log(sentencesToTheEndOfParagraph.items[i].text);
22425+
}
22426+
});
2239622427
'Word.Range#getComments:member(1)':
2239722428
- >-
2239822429
// Link to full sample:
@@ -22448,6 +22479,21 @@
2244822479

2244922480
console.log("Deleted checkbox content control.");
2245022481
});
22482+
'Word.Range#getRange:member(1)':
22483+
- >-
22484+
// Link to full sample:
22485+
https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/99-preview-apis/insert-and-change-dropdown-list-content-control.yaml
22486+
22487+
22488+
// Places a dropdown list content control at the end of the selection.
22489+
22490+
await Word.run(async (context) => {
22491+
let selection = context.document.getSelection();
22492+
selection.getRange(Word.RangeLocation.end).insertContentControl(Word.ContentControlType.dropDownList);
22493+
await context.sync();
22494+
22495+
console.log("Dropdown list content control inserted at the end of the selection.");
22496+
});
2245122497
'Word.Range#getReviewedText:member(1)':
2245222498
- >-
2245322499
// Link to full sample:

0 commit comments

Comments
 (0)