Word.RangeLocation enum

Comentarios

[ Conjunto de API: WordApi 1.3 ]

Ejemplos

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml

await Word.run(async (context) => {
  // Get the complete sentence (as range) associated with the insertion point.
  const sentences = context.document
    .getSelection()
    .getTextRanges(["."] /* Using the "." as delimiter */, false /*means without trimming spaces*/);
  sentences.load("$none");
  await context.sync();

  // Expand the range to the end of the paragraph to get all the complete sentences.
  const sentencesToTheEndOfParagraph = sentences.items[0]
    .getRange()
    .expandTo(
      context.document
        .getSelection()
        .paragraphs.getFirst()
        .getRange(Word.RangeLocation.end)
    )
    .getTextRanges(["."], false /* Don't trim spaces*/);
  sentencesToTheEndOfParagraph.load("text");
  await context.sync();

  for (let i = 0; i < sentencesToTheEndOfParagraph.items.length; i++) {
    console.log(sentencesToTheEndOfParagraph.items[i].text);
  }
});

Campos

after = "After"

Punto después del objeto . Si el objeto es un control de contenido de párrafo o un control de contenido de tabla, es el punto después de los caracteres EOP o Table.

before = "Before"

Solo para el control de contenido. Es el punto antes de la etiqueta de apertura.

content = "Content"

Intervalo entre "Start" y "End".

end = "End"

Punto final del objeto. Para el párrafo, es el punto anterior al EOP. Para el control de contenido, es el punto antes de la etiqueta de cierre.

start = "Start"

Punto inicial del objeto. Para el control de contenido, es el punto después de la etiqueta de apertura.

whole = "Whole"

Intervalo completo del objeto. Si el objeto es un control de contenido de párrafo o un control de contenido de tabla, también se incluyen los caracteres EOP o Table después del control de contenido.