|
22393 | 22393 | const locationValue: Word.LocationRelation = comparedLocation.value; |
22394 | 22394 | console.log(`Location of the first paragraph in relation to the second paragraph: ${locationValue}`); |
22395 | 22395 | }); |
| 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 | + }); |
22396 | 22427 | 'Word.Range#getComments:member(1)': |
22397 | 22428 | - >- |
22398 | 22429 | // Link to full sample: |
|
22448 | 22479 |
|
22449 | 22480 | console.log("Deleted checkbox content control."); |
22450 | 22481 | }); |
| 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 | + }); |
22451 | 22497 | 'Word.Range#getReviewedText:member(1)': |
22452 | 22498 | - >- |
22453 | 22499 | // Link to full sample: |
|
0 commit comments