Word.LocationRelation enum

注解

[ API 集:WordApi 1.3 ]

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/compare-location.yaml

// Compares the location of one paragraph in relation to another paragraph.
await Word.run(async (context) => {
  const paragraphs = context.document.body.paragraphs;
  paragraphs.load("items");

  await context.sync();

  const firstParagraphAsRange = paragraphs.items[0].getRange();
  const secondParagraphAsRange = paragraphs.items[1].getRange();

  const comparedLocation = firstParagraphAsRange.compareLocationWith(secondParagraphAsRange);

  await context.sync();

  console.log(`Location of the first paragraph in relation to the second paragraph: ${comparedLocation.value}`);
});

字段

adjacentAfter = "AdjacentAfter"

指示此实例发生在区域之后,并且与 该区域相邻。

adjacentBefore = "AdjacentBefore"

指示此实例发生在区域之前且与该区域相邻。

after = "After"

指示此实例发生在 范围之后。

before = "Before"

指示此实例在范围之前发生。

contains = "Contains"

指示此实例包含范围,但此实例的开始和结束字符除外。

containsEnd = "ContainsEnd"

指示此实例包含区域,并且它共享相同的结束字符。 区域不在此实例中共享相同的起始字符。

containsStart = "ContainsStart"

指示此实例包含区域,并且它共享相同的起始字符。 区域不与此实例共享相同的结束字符。

equal = "Equal"

指示此实例和区域表示相同的范围。

inside = "Inside"

指示此实例在 范围内。 范围不在此实例中共享相同的起始字符和结束字符。

insideEnd = "InsideEnd"

指示此实例在 范围内,并且它共享相同的结束字符。 区域不在此实例中共享相同的起始字符。

insideStart = "InsideStart"

指示此实例在范围内,并且它共享相同的起始字符。 区域不与此实例共享相同的结束字符。

overlapsAfter = "OverlapsAfter"

指示此实例从该区域内开始,并重叠该区域的最后一个字符。

overlapsBefore = "OverlapsBefore"

指示此实例在区域之前开始,并且与范围的第一个字符重叠。

unrelated = "Unrelated"

指示此实例和区域位于不同的子文档中。