OneNote.Paragraph class

ページに表示されるコンテンツのコンテナー。 Paragraph に含めることができるのは、コンテンツの ParagraphType の種類のいずれか 1 つです。

Extends

注釈

[ API セット: OneNoteApi 1.1 ]

プロパティ

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

id

Paragraph オブジェクトの ID を取得します。 読み取り専用です。

image

Paragraph 内の Image オブジェクトを取得します。 ParagraphType が Image ではない場合は例外をスローします。 読み取り専用です。

inkWords

Paragraph 内のインク コレクションを取得します。 ParagraphType が Ink ではない場合は例外をスローします。 読み取り専用です。

outline

Paragraph を含む Outline オブジェクトを取得します。 読み取り専用です。

paragraphs

この段落の下にある段落のコレクション。 読み取りのみ

parentParagraph

親の Paragraph オブジェクトを取得します。 親の Paragraph が存在しない場合はスローします。 読み取り専用です。

parentParagraphOrNull

親の Paragraph オブジェクトを取得します。 親の Paragraph が存在しない場合は null を返します。 読み取り専用です。

parentTableCell

Paragraph を含む TableCell オブジェクトを取得します (存在する場合)。 親が TableCell でない場合は ItemNotFound をスローします。 読み取り専用です。

parentTableCellOrNull

Paragraph を含む TableCell オブジェクトを取得します (存在する場合)。 親が TableCell でない場合は null を返します。 読み取り専用です。

richText

Paragraph 内の RichText オブジェクトを取得します。 ParagraphType が RichText ではない場合は例外をスローします。 読み取り専用

table

Paragraph 内の Table オブジェクトを取得します。 ParagraphType が Table ではない場合は例外をスローします。 読み取り専用です。

type

Paragraph オブジェクトの種類を取得します。 読み取り専用です。

メソッド

addNoteTag(type, status)

段落に NoteTag を追加します。

addNoteTag(typeString, statusString)

段落に NoteTag を追加します。

delete()

段落を削除します。

getParagraphInfo()

段落のリスト情報を取得する

insertHtmlAsSibling(insertLocation, html)

指定された HTML コンテンツを挿入します。

insertHtmlAsSibling(insertLocationString, html)

指定された HTML コンテンツを挿入します。

insertImageAsSibling(insertLocation, base64EncodedImage, width, height)

指定された挿入位置にイメージを挿入します。

insertImageAsSibling(insertLocationString, base64EncodedImage, width, height)

指定された挿入位置にイメージを挿入します。

insertRichTextAsSibling(insertLocation, paragraphText)

指定された挿入位置に段落テキストを挿入します。

insertRichTextAsSibling(insertLocationString, paragraphText)

指定された挿入位置に段落テキストを挿入します。

insertTableAsSibling(insertLocation, rowCount, columnCount, values)

指定された数の行と列を含む表を現在の段落の前または後に追加します。

insertTableAsSibling(insertLocationString, rowCount, columnCount, values)

指定された数の行と列を含む表を現在の段落の前または後に追加します。

load(options)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNames)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNamesAndPaths)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

set(properties, options)

オブジェクトの複数のプロパティを同時に設定します。 適切なプロパティを持つプレーン オブジェクトまたは同じ型の別の API オブジェクトを渡すことができます。

set(properties)

既存の読み込まれたオブジェクトに基づいて、オブジェクトに複数のプロパティを同時に設定します。

toJSON()

API オブジェクトが に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドを JSON.stringify()オーバーライドします。 (JSON.stringifyさらに、渡される オブジェクトの メソッドを呼び出 toJSON します)。元の OneNote.Paragraph オブジェクトは API オブジェクトですが、メソッドは、元の toJSON オブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト (として OneNote.Interfaces.ParagraphData型指定) を返します。

track()

ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは の短縮形です context.trackedObjects.add(thisObject)。 このオブジェクトを呼び出しで .sync 使用し、".run" バッチのシーケンシャル実行の外部で使用していて、プロパティを設定するとき、またはオブジェクトのメソッドを呼び出すときに "InvalidObjectPath" エラーが発生する場合は、オブジェクトが最初に作成されたときに、追跡対象のオブジェクト コレクションにオブジェクトを追加する必要があります。

untrack()

前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは の context.trackedObjects.remove(thisObject)短縮形です。 追跡対象オブジェクトが多いとホスト アプリケーションの動作が遅くなります。追加したオブジェクトが不要になったら、必ずそれを解放してください。 メモリ解放が有効になる前に を呼び出す context.sync() 必要があります。

プロパティの詳細

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

context: RequestContext;

プロパティ値

id

Paragraph オブジェクトの ID を取得します。 読み取り専用です。

readonly id: string;

プロパティ値

string

注釈

[ API セット: OneNoteApi 1.1 ]

image

Paragraph 内の Image オブジェクトを取得します。 ParagraphType が Image ではない場合は例外をスローします。 読み取り専用です。

readonly image: OneNote.Image;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

inkWords

Paragraph 内のインク コレクションを取得します。 ParagraphType が Ink ではない場合は例外をスローします。 読み取り専用です。

readonly inkWords: OneNote.InkWordCollection;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

outline

Paragraph を含む Outline オブジェクトを取得します。 読み取り専用です。

readonly outline: OneNote.Outline;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

paragraphs

この段落の下にある段落のコレクション。 読み取りのみ

readonly paragraphs: OneNote.ParagraphCollection;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

parentParagraph

親の Paragraph オブジェクトを取得します。 親の Paragraph が存在しない場合はスローします。 読み取り専用です。

readonly parentParagraph: OneNote.Paragraph;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

parentParagraphOrNull

親の Paragraph オブジェクトを取得します。 親の Paragraph が存在しない場合は null を返します。 読み取り専用です。

readonly parentParagraphOrNull: OneNote.Paragraph;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

parentTableCell

Paragraph を含む TableCell オブジェクトを取得します (存在する場合)。 親が TableCell でない場合は ItemNotFound をスローします。 読み取り専用です。

readonly parentTableCell: OneNote.TableCell;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

parentTableCellOrNull

Paragraph を含む TableCell オブジェクトを取得します (存在する場合)。 親が TableCell でない場合は null を返します。 読み取り専用です。

readonly parentTableCellOrNull: OneNote.TableCell;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

richText

Paragraph 内の RichText オブジェクトを取得します。 ParagraphType が RichText ではない場合は例外をスローします。 読み取り専用

readonly richText: OneNote.RichText;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

table

Paragraph 内の Table オブジェクトを取得します。 ParagraphType が Table ではない場合は例外をスローします。 読み取り専用です。

readonly table: OneNote.Table;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

type

Paragraph オブジェクトの種類を取得します。 読み取り専用です。

readonly type: OneNote.ParagraphType | "RichText" | "Image" | "Table" | "Ink" | "Other";

プロパティ値

OneNote.ParagraphType | "RichText" | "Image" | "Table" | "Ink" | "Other"

注釈

[ API セット: OneNoteApi 1.1 ]

メソッドの詳細

addNoteTag(type, status)

段落に NoteTag を追加します。

addNoteTag(type: OneNote.NoteTagType, status: OneNote.NoteTagStatus): OneNote.NoteTag;

パラメーター

type
OneNote.NoteTagType

NoteTag の型。

status
OneNote.NoteTagStatus

NoteTag の状態。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

addNoteTag(typeString, statusString)

段落に NoteTag を追加します。

addNoteTag(typeString: "Unknown" | "ToDo" | "Important" | "Question" | "Contact" | "Address" | "PhoneNumber" | "Website" | "Idea" | "Critical" | "ToDoPriority1" | "ToDoPriority2", statusString: "Unknown" | "Normal" | "Completed" | "Disabled" | "OutlookTask" | "TaskNotSyncedYet" | "TaskRemoved"): OneNote.NoteTag;

パラメーター

typeString

"Unknown" | "ToDo" | "Important" | "Question" | "Contact" | "Address" | "PhoneNumber" | "Website" | "Idea" | "Critical" | "ToDoPriority1" | "ToDoPriority2"

NoteTag の型。

statusString

"Unknown" | "Normal" | "Completed" | "Disabled" | "OutlookTask" | "TaskNotSyncedYet" | "TaskRemoved"

NoteTag の状態。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

delete()

段落を削除します。

delete(): void;

戻り値

void

注釈

[ API セット: OneNoteApi 1.1 ]

await OneNote.run(async (context) => {

    // Get the collection of pageContent items from the page.
    const pageContents = context.application.getActivePage().contents;

    // Get the first PageContent on the page assuming its an outline, get the outline's paragraphs.
    const pageContent = pageContents.getItemAt(0);
    
    const paragraphs = pageContent.outline.paragraphs;
    
    const firstParagraph = paragraphs.getItemAt(0);
    
    // Queue a command to load the id and type of the first paragraph.
    firstParagraph.load("id,type");

    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();
            
    // Queue a command to delete the first paragraph.
    firstParagraph.delete();
    
    // Run the command to delete it.
    await context.sync();
});

getParagraphInfo()

段落のリスト情報を取得する

getParagraphInfo(): OfficeExtension.ClientResult<OneNote.ParagraphInfo>;

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

insertHtmlAsSibling(insertLocation, html)

指定された HTML コンテンツを挿入します。

insertHtmlAsSibling(insertLocation: OneNote.InsertLocation, html: string): void;

パラメーター

insertLocation
OneNote.InsertLocation

現在の Paragraph を基準にした新しいコンテンツの場所です。

html

string

コンテンツの視覚表示を記述する HTML 文字列です。 OneNote アドイン JavaScript API で サポートされている HTML に関するページを参照してください。

戻り値

void

注釈

[ API セット: OneNoteApi 1.1 ]

await OneNote.run(async (context) => {

    // Get the collection of pageContent items from the page.
    const pageContents = context.application.getActivePage().contents;

    // Get the first PageContent on the page.
    // Assuming its an outline, get the outline's paragraphs.
    const pageContent = pageContents.getItemAt(0);
    const paragraphs = pageContent.outline.paragraphs;
    const firstParagraph = paragraphs.getItemAt(0);

    // Queue a command to load the id and type of the first paragraph.
    firstParagraph.load("id,type");

    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();

    // Queue commands to insert before and after the first paragraph.
    firstParagraph.insertHtmlAsSibling("Before", "<p>ContentBeforeFirstParagraph</p>");
    firstParagraph.insertHtmlAsSibling("After", "<p>ContentAfterFirstParagraph</p>");
    
    // Run the command to run inserts.
    await context.sync();
});

insertHtmlAsSibling(insertLocationString, html)

指定された HTML コンテンツを挿入します。

insertHtmlAsSibling(insertLocationString: "Before" | "After", html: string): void;

パラメーター

insertLocationString

"Before" | "After"

現在の Paragraph を基準にした新しいコンテンツの場所です。

html

string

コンテンツの視覚表示を記述する HTML 文字列です。 OneNote アドイン JavaScript API で サポートされている HTML に関するページを参照してください。

戻り値

void

注釈

[ API セット: OneNoteApi 1.1 ]

insertImageAsSibling(insertLocation, base64EncodedImage, width, height)

指定された挿入位置にイメージを挿入します。

insertImageAsSibling(insertLocation: OneNote.InsertLocation, base64EncodedImage: string, width: number, height: number): OneNote.Image;

パラメーター

insertLocation
OneNote.InsertLocation

現在の Paragraph を基準にした表の位置。

base64EncodedImage

string

追加する HTML 文字列です。

width

number

オプション。 ポイント単位の幅。 既定値は null で、イメージの幅が使用されます。

height

number

オプション。 ポイント単位の高さ。 既定値は null で、イメージの高さが使用されます。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

await OneNote.run(async (context) => {

    // Get the collection of pageContent items from the page.
    const pageContents = context.application.getActivePage().contents;

    // Get the first PageContent on the page.
    // Assuming its an outline, get the outline's paragraphs.
    const pageContent = pageContents.getItemAt(0);
    const paragraphs = pageContent.outline.paragraphs;
    const firstParagraph = paragraphs.getItemAt(0);

    // Queue a command to load the id and type of the first paragraph.
    firstParagraph.load("id,type");

    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();

    // Queue commands to insert before and after the first paragraph.
    firstParagraph.insertImageAsSibling("Before", "R0lGODlhDwAPAKECAAAAzMzM/////wAAACwAAAAADwAPAAACIISPeQHsrZ5ModrLlN48CXF8m2iQ3YmmKqVlRtW4MLwWACH+H09wdGltaXplZCBieSBVbGVhZCBTbWFydFNhdmVyIQAAOw==");
    firstParagraph.insertImageAsSibling("After", "R0lGODlhDwAPAKECAAAAzMzM/////wAAACwAAAAADwAPAAACIISPeQHsrZ5ModrLlN48CXF8m2iQ3YmmKqVlRtW4MLwWACH+H09wdGltaXplZCBieSBVbGVhZCBTbWFydFNhdmVyIQAAOw==");
    
    // Run the command to insert images.
    await context.sync();
});

insertImageAsSibling(insertLocationString, base64EncodedImage, width, height)

指定された挿入位置にイメージを挿入します。

insertImageAsSibling(insertLocationString: "Before" | "After", base64EncodedImage: string, width: number, height: number): OneNote.Image;

パラメーター

insertLocationString

"Before" | "After"

現在の Paragraph を基準にした表の位置。

base64EncodedImage

string

追加する HTML 文字列です。

width

number

オプション。 ポイント単位の幅。 既定値は null で、イメージの幅が使用されます。

height

number

オプション。 ポイント単位の高さ。 既定値は null で、イメージの高さが使用されます。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

insertRichTextAsSibling(insertLocation, paragraphText)

指定された挿入位置に段落テキストを挿入します。

insertRichTextAsSibling(insertLocation: OneNote.InsertLocation, paragraphText: string): OneNote.RichText;

パラメーター

insertLocation
OneNote.InsertLocation

現在の Paragraph を基準にした表の位置。

paragraphText

string

追加する HTML 文字列です。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

await OneNote.run(async (context) => {

    // Get the collection of pageContent items from the page.
    const pageContents = context.application.getActivePage().contents;

    // Get the first PageContent on the page assuming its an outline, get the outline's paragraphs.
    const pageContent = pageContents.getItemAt(0);
    const paragraphs = pageContent.outline.paragraphs;
    const firstParagraph = paragraphs.getItemAt(0);

    // Queue a command to load the id and type of the first paragraph.
    firstParagraph.load("id,type");

    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();

    // Queue commands to insert before and after the first paragraph.
    firstParagraph.insertRichTextAsSibling("Before", "Text Appears Before Paragraph");
    firstParagraph.insertRichTextAsSibling("After", "Text Appears After Paragraph");
    
    // Run the command to insert text contents.
    await context.sync();
});

insertRichTextAsSibling(insertLocationString, paragraphText)

指定された挿入位置に段落テキストを挿入します。

insertRichTextAsSibling(insertLocationString: "Before" | "After", paragraphText: string): OneNote.RichText;

パラメーター

insertLocationString

"Before" | "After"

現在の Paragraph を基準にした表の位置。

paragraphText

string

追加する HTML 文字列です。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

insertTableAsSibling(insertLocation, rowCount, columnCount, values)

指定された数の行と列を含む表を現在の段落の前または後に追加します。

insertTableAsSibling(insertLocation: OneNote.InsertLocation, rowCount: number, columnCount: number, values?: string[][]): OneNote.Table;

パラメーター

insertLocation
OneNote.InsertLocation

現在の Paragraph を基準にした表の位置。

rowCount

number

表の行数を指定します。

columnCount

number

表の列数を指定します。

values

string[][]

省略可能な 2 次元配列。 対応する文字列が配列で指定されている場合、セルに設定されます。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

insertTableAsSibling(insertLocationString, rowCount, columnCount, values)

指定された数の行と列を含む表を現在の段落の前または後に追加します。

insertTableAsSibling(insertLocationString: "Before" | "After", rowCount: number, columnCount: number, values?: string[][]): OneNote.Table;

パラメーター

insertLocationString

"Before" | "After"

現在の Paragraph を基準にした表の位置。

rowCount

number

表の行数を指定します。

columnCount

number

表の列数を指定します。

values

string[][]

省略可能な 2 次元配列。 対応する文字列が配列で指定されている場合、セルに設定されます。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

load(options)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(options?: OneNote.Interfaces.ParagraphLoadOptions): OneNote.Paragraph;

パラメーター

options
OneNote.Interfaces.ParagraphLoadOptions

読み込むオブジェクトのプロパティのオプションを提供します。

戻り値

load(propertyNames)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNames?: string | string[]): OneNote.Paragraph;

パラメーター

propertyNames

string | string[]

読み込むプロパティを指定するコンマ区切り文字列または文字列の配列。

戻り値

await OneNote.run(async (context) => {

    // Get the collection of pageContent items from the page.
    const pageContents = context.application.getActivePage().contents;
    
    // Queue a command to load the outline property of each pageContent.
    pageContents.load("outline");
        
    // Get the first PageContent on the page, and then get its Outline.
    const pageContent = pageContents._GetItem(0);
    const paragraphs = pageContent.outline.paragraphs;
            
    // Queue a command to load the id and type of each paragraph.
    paragraphs.load("id,type");
            
    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();
    // Write the text.
    $.each(paragraphs.items, function(index, paragraph) {
        console.log("Paragraph type: " + paragraph.type);
        console.log("Paragraph ID: " + paragraph.id);
    });
});

load(propertyNamesAndPaths)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): OneNote.Paragraph;

パラメーター

propertyNamesAndPaths

{ select?: string; expand?: string; }

propertyNamesAndPaths.select は、読み込むプロパティを指定するコンマ区切り文字列で propertyNamesAndPaths.expand 、読み込むナビゲーション プロパティを指定するコンマ区切りの文字列です。

戻り値

set(properties, options)

オブジェクトの複数のプロパティを同時に設定します。 適切なプロパティを持つプレーン オブジェクトまたは同じ型の別の API オブジェクトを渡すことができます。

set(properties: Interfaces.ParagraphUpdateData, options?: OfficeExtension.UpdateOptions): void;

パラメーター

properties
OneNote.Interfaces.ParagraphUpdateData

メソッドが呼び出されるオブジェクトのプロパティに等形的に構造化されたプロパティを持つ JavaScript オブジェクト。

options
OfficeExtension.UpdateOptions

properties オブジェクトが読み取り専用プロパティを設定しようとした場合にエラーを抑制するオプションを提供します。

戻り値

void

set(properties)

既存の読み込まれたオブジェクトに基づいて、オブジェクトに複数のプロパティを同時に設定します。

set(properties: OneNote.Paragraph): void;

パラメーター

properties
OneNote.Paragraph

戻り値

void

toJSON()

API オブジェクトが に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドを JSON.stringify()オーバーライドします。 (JSON.stringifyさらに、渡される オブジェクトの メソッドを呼び出 toJSON します)。元の OneNote.Paragraph オブジェクトは API オブジェクトですが、メソッドは、元の toJSON オブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト (として OneNote.Interfaces.ParagraphData型指定) を返します。

toJSON(): OneNote.Interfaces.ParagraphData;

戻り値

track()

ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは の短縮形です context.trackedObjects.add(thisObject)。 このオブジェクトを呼び出しで .sync 使用し、".run" バッチのシーケンシャル実行の外部で使用していて、プロパティを設定するとき、またはオブジェクトのメソッドを呼び出すときに "InvalidObjectPath" エラーが発生する場合は、オブジェクトが最初に作成されたときに、追跡対象のオブジェクト コレクションにオブジェクトを追加する必要があります。

track(): OneNote.Paragraph;

戻り値

untrack()

前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは の context.trackedObjects.remove(thisObject)短縮形です。 追跡対象オブジェクトが多いとホスト アプリケーションの動作が遅くなります。追加したオブジェクトが不要になったら、必ずそれを解放してください。 メモリ解放が有効になる前に を呼び出す context.sync() 必要があります。

untrack(): OneNote.Paragraph;

戻り値