Class RichLink

리치링크

Drive 파일이나 YouTube 동영상과 같은 Google 리소스에 대한 링크를 나타내는 요소입니다.

메서드

메서드반환 유형간략한 설명
copy()RichLink현재 요소의 분리된 전체 사본을 반환합니다.
getAttributes()Object요소의 속성을 가져옵니다.
getMimeType()String|null항목이 드라이브 파일 링크인 경우 사용할 수 있는 링크의 MIME 유형을 반환하고, 그렇지 않은 경우 null을 반환합니다.
getNextSibling()Element|null요소의 다음 동위 요소를 가져옵니다.
getParent()ContainerElement|null요소의 상위 요소를 가져옵니다.
getPreviousSibling()Element|null요소의 이전 동급 요소를 가져옵니다.
getTitle()String링크의 표시된 제목을 반환합니다.
getType()ElementType요소의 ElementType를 가져옵니다.
getUrl()String리소스의 URL을 반환합니다.
isAtDocumentEnd()Boolean요소가 Document의 끝에 있는지 여부를 확인합니다.
merge()RichLink|null요소를 동일한 유형의 이전 형제와 병합합니다.
removeFromParent()RichLink|null요소를 상위 요소에서 삭제합니다.
setAttributes(attributes)RichLink요소의 속성을 설정합니다.

자세한 문서

copy()

현재 요소의 분리된 전체 사본을 반환합니다.

요소에 있는 하위 요소도 복사됩니다. 새 요소에 상위 요소가 없습니다.

리턴

RichLink - 새로운 문구입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getAttributes()

요소의 속성을 가져옵니다.

결과는 각 속성 이름이 DocumentApp.Attribute 열거형의 항목에 해당하는 유효한 요소 속성의 속성을 포함하는 객체입니다.

const doc = DocumentApp.getActiveDocument();
const documentTab = doc.getActiveTab().asDocumentTab();
const body = documentTab.getBody();

// Append a styled paragraph.
const par = body.appendParagraph('A bold, italicized paragraph.');
par.setBold(true);
par.setItalic(true);

// Retrieve the paragraph's attributes.
const atts = par.getAttributes();

// Log the paragraph attributes.
for (const att in atts) {
  Logger.log(`${att}:${atts[att]}`);
}

리턴

Object - 요소의 속성입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getMimeType()

항목이 드라이브 파일 링크인 경우 사용할 수 있는 링크의 MIME 유형을 반환하고, 그렇지 않은 경우 null을 반환합니다.

예를 들어 링크가 Google Docs 파일을 가리키는 경우 application/vnd.google-apps.document 문자열이 반환됩니다.

리턴

String|null - 링크의 MIME 유형입니다(있는 경우).

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getNextSibling()

요소의 다음 동위 요소를 가져옵니다.

다음 동위 요소는 상위 요소가 동일하며 현재 요소를 따릅니다.

리턴

Element|null - 다음 동급 요소입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getParent()

요소의 상위 요소를 가져옵니다.

상위 요소에 현재 요소가 포함되어 있습니다.

리턴

ContainerElement|null - 상위 요소입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getPreviousSibling()

요소의 이전 동급 요소를 가져옵니다.

이전 동급 요소의 상위 요소가 동일하고 현재 요소보다 앞에 있습니다.

리턴

Element|null - 이전 동급 요소입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getTitle()

링크의 표시된 제목을 반환합니다. 이 제목은 링크가 삽입되거나 마지막으로 업데이트된 시점의 연결된 리소스 제목과 일치합니다. 예를 들어 이 링크가 '분석'이라는 제목의 Google Docs 문서로 연결되는 경우 Analysis이 반환됩니다.

리턴

String: 링크의 표시 제목입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getType()

요소의 ElementType를 가져옵니다.

getType()을 사용하여 지정된 요소의 정확한 유형을 확인합니다.

const doc = DocumentApp.getActiveDocument();
const documentTab = doc.getActiveTab().asDocumentTab();
const body = documentTab.getBody();

// Obtain the first element in the active tab's body.

const firstChild = body.getChild(0);

// Use getType() to determine the element's type.
if (firstChild.getType() === DocumentApp.ElementType.PARAGRAPH) {
  Logger.log('The first element is a paragraph.');
} else {
  Logger.log('The first element is not a paragraph.');
}

리턴

ElementType: 요소 유형입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getUrl()

리소스의 URL을 반환합니다.

리턴

String - 리소스의 URL입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

isAtDocumentEnd()

요소가 Document의 끝에 있는지 여부를 확인합니다.

리턴

Boolean - 요소가 탭 끝에 있는지 여부입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

merge()

요소를 동일한 유형의 이전 형제와 병합합니다.

동일한 ElementType의 요소만 병합할 수 있습니다. 현재 요소에 포함된 하위 요소는 이전 형제 요소로 이동됩니다.

현재 요소가 문서에서 삭제됩니다.

const doc = DocumentApp.getActiveDocument();
const documentTab = doc.getActiveTab().asDocumentTab();
const body = documentTab.getBody();

// Example 1: Merge paragraphs
// Append two paragraphs to the document's active tab.
const par1 = body.appendParagraph('Paragraph 1.');
const par2 = body.appendParagraph('Paragraph 2.');
// Merge the newly added paragraphs into a single paragraph.
par2.merge();

// Example 2: Merge table cells
// Create a two-dimensional array containing the table's cell contents.
const cells = [
  ['Row 1, Cell 1', 'Row 1, Cell 2'],
  ['Row 2, Cell 1', 'Row 2, Cell 2'],
];
// Build a table from the array.
const table = body.appendTable(cells);
// Get the first row in the table.
const row = table.getRow(0);
// Get the two cells in this row.
const cell1 = row.getCell(0);
const cell2 = row.getCell(1);
// Merge the current cell into its preceding sibling element.
const merged = cell2.merge();

리턴

RichLink|null - 병합된 요소입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

removeFromParent()

요소를 상위 요소에서 삭제합니다.

const doc = DocumentApp.getActiveDocument();
const documentTab = doc.getActiveTab().asDocumentTab();
const body = documentTab.getBody();

// Remove all images in the active tab's body.
const imgs = body.getImages();
for (let i = 0; i < imgs.length; i++) {
  imgs[i].removeFromParent();
}

리턴

RichLink|null - 삭제된 요소입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setAttributes(attributes)

요소의 속성을 설정합니다.

지정된 속성 매개변수는 각 속성 이름이 DocumentApp.Attribute 열거형의 항목이고 각 속성 값이 적용할 새 값인 객체여야 합니다.

const doc = DocumentApp.getActiveDocument();
const documentTab = doc.getActiveTab().asDocumentTab();
const body = documentTab.getBody();

// Define a custom paragraph style.
const style = {};
style[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] =
    DocumentApp.HorizontalAlignment.RIGHT;
style[DocumentApp.Attribute.FONT_FAMILY] = 'Calibri';
style[DocumentApp.Attribute.FONT_SIZE] = 18;
style[DocumentApp.Attribute.BOLD] = true;

// Append a plain paragraph.
const par = body.appendParagraph('A paragraph with custom style.');

// Apply the custom style.
par.setAttributes(style);

매개변수

이름유형설명
attributesObject요소의 속성입니다.

리턴

RichLink - 현재 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents