OneNote.Page class

OneNote のページを表します。

Extends

注釈

[ API セット: OneNoteApi 1.1 ]

プロパティ

classNotebookPageSource

ClassNotebookPageSource をページに取得します。

clientUrl

ページのクライアント URL。 読み取りのみ

contents

ページの PageContent オブジェクトのコレクション。 読み取りのみ

context

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

id

ページの ID を取得します。 読み取り専用です。

inkAnalysisOrNull

ページ上のインクのテキスト解釈。 インクの解析情報がない場合は null を返します。

pageLevel

ページのインデント レベルを取得するか設定します。

parentSection

ページを含むセクションを取得します。 読み取り専用です。

title

ページのタイトルを取得するか設定します。

webUrl

ページの Web URL。 読み取りのみ

メソッド

addOutline(left, top, html)

Outline をページの指定した位置に追加します。

analyzePage()

ノード ID とコンテンツを html 形式で含む json 文字列を返します。

applyTranslation(translatedContent)

翻訳されたコンテンツを含む新しいページを挿入します。

copyToSection(destinationSection)

このページを指定したセクションにコピーします。

copyToSectionAndSetClassNotebookPageSource(destinationSection)

このページを指定したセクションにコピーし、ClassNotebookPageSource を設定します。

getRestApiId()

REST API ID を取得します。

hasTitleContent()

ページにコンテンツ タイトルが含まれますか。

insertPageAsSibling(location, title)

現在のページの前か後に、新しいページを挿入します。

insertPageAsSibling(locationString, title)

現在のページの前か後に、新しいページを挿入します。

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.Page オブジェクトは API オブジェクトですが、メソッドは、元の toJSON オブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト (として OneNote.Interfaces.PageData型指定) を返します。

track()

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

untrack()

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

プロパティの詳細

classNotebookPageSource

ClassNotebookPageSource をページに取得します。

readonly classNotebookPageSource: string;

プロパティ値

string

注釈

[ API セット: OneNoteApi 1.1 ]

clientUrl

ページのクライアント URL。 読み取りのみ

readonly clientUrl: string;

プロパティ値

string

注釈

[ API セット: OneNoteApi 1.1 ]

contents

ページの PageContent オブジェクトのコレクション。 読み取りのみ

readonly contents: OneNote.PageContentCollection;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

context

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

context: RequestContext;

プロパティ値

id

ページの ID を取得します。 読み取り専用です。

readonly id: string;

プロパティ値

string

注釈

[ API セット: OneNoteApi 1.1 ]

inkAnalysisOrNull

ページ上のインクのテキスト解釈。 インクの解析情報がない場合は null を返します。

readonly inkAnalysisOrNull: OneNote.InkAnalysis;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

pageLevel

ページのインデント レベルを取得するか設定します。

pageLevel: number;

プロパティ値

number

注釈

[ API セット: OneNoteApi 1.1 ]

parentSection

ページを含むセクションを取得します。 読み取り専用です。

readonly parentSection: OneNote.Section;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

title

ページのタイトルを取得するか設定します。

title: string;

プロパティ値

string

注釈

[ API セット: OneNoteApi 1.1 ]

webUrl

ページの Web URL。 読み取りのみ

readonly webUrl: string;

プロパティ値

string

注釈

[ API セット: OneNoteApi 1.1 ]

メソッドの詳細

addOutline(left, top, html)

Outline をページの指定した位置に追加します。

addOutline(left: number, top: number, html: string): OneNote.Outline;

パラメーター

left

number

Outline の左上隅の左の位置です。

top

number

Outline の左上隅の上の位置です。

html

string

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

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

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

    // Gets the active page.
    const page = context.application.getActivePage();

    // Queue a command to add an outline with given html.
    const outline = page.addOutline(200, 200,
"<p>Images and a table below:</p> \
 <img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==\"> \
 <img src=\"http://imagenes.es.sftcdn.net/es/scrn/6653000/6653659/microsoft-onenote-2013-01-535x535.png\"> \
 <table> \
   <tr> \
     <td>Jill</td> \
     <td>Smith</td> \
     <td>50</td> \
   </tr> \
   <tr> \
     <td>Eve</td> \
     <td>Jackson</td> \
     <td>94</td> \
   </tr> \
 </table>"     
        );

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

analyzePage()

ノード ID とコンテンツを html 形式で含む json 文字列を返します。

analyzePage(): OfficeExtension.ClientResult<string>;

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

applyTranslation(translatedContent)

翻訳されたコンテンツを含む新しいページを挿入します。

applyTranslation(translatedContent: string): void;

パラメーター

translatedContent

string

ページの翻訳されたコンテンツ

戻り値

void

注釈

[ API セット: OneNoteApi 1.1 ]

copyToSection(destinationSection)

このページを指定したセクションにコピーします。

copyToSection(destinationSection: OneNote.Section): OneNote.Page;

パラメーター

destinationSection
OneNote.Section

このページのコピー先のセクション。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

await OneNote.run(async (context) => {
    const app = context.application;
    
    // Gets the active notebook.
    const notebook = app.getActiveNotebook();
    
    // Gets the active page.
    const page = app.getActivePage();
    
    // Queue a command to load sections under the notebook.
    notebook.load('sections');
    
    let newPage;
    
    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();

    const section = notebook.sections.items[0];
    
    // Copy page to the section.
    newPage = page.copyToSection(section);
    newPage.load('id');
    await context.sync();
    
    console.log(newPage.id);
});

copyToSectionAndSetClassNotebookPageSource(destinationSection)

このページを指定したセクションにコピーし、ClassNotebookPageSource を設定します。

copyToSectionAndSetClassNotebookPageSource(destinationSection: OneNote.Section): OneNote.Page;

パラメーター

destinationSection
OneNote.Section

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

getRestApiId()

REST API ID を取得します。

getRestApiId(): OfficeExtension.ClientResult<string>;

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

await OneNote.run(async (context) => {
    // Get the current page.
    const page = context.application.getActivePage();
    const restApiId = page.getRestApiId();

    await context.sync();
    console.log("The REST API ID is " + restApiId.value);
    // Note that the REST API ID isn't all you need to interact with the OneNote REST API.
    // This is only required for SharePoint notebooks. baseUrl will be null for OneDrive notebooks.
    // For SharePoint notebooks, the notebook baseUrl should be used to talk to the OneNote REST API
    // according to the OneNote Development Blog.
    // https://learn.microsoft.com/archive/blogs/onenotedev/and-sharepoint-makes-three
});

hasTitleContent()

ページにコンテンツ タイトルが含まれますか。

hasTitleContent(): OfficeExtension.ClientResult<boolean>;

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

insertPageAsSibling(location, title)

現在のページの前か後に、新しいページを挿入します。

insertPageAsSibling(location: OneNote.InsertLocation, title: string): OneNote.Page;

パラメーター

location
OneNote.InsertLocation

現在のページを基準とした新しいページの場所。

title

string

新しいページのタイトルです。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

insertPageAsSibling(locationString, title)

現在のページの前か後に、新しいページを挿入します。

insertPageAsSibling(locationString: "Before" | "After", title: string): OneNote.Page;

パラメーター

locationString

"Before" | "After"

現在のページを基準とした新しいページの場所。

title

string

新しいページのタイトルです。

戻り値

注釈

[ API セット: OneNoteApi 1.1 ]

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

    // Gets the active page.
    const activePage = context.application.getActivePage();

    // Queue a command to add a new page after the active page.
    const newPage = activePage.insertPageAsSibling("After", "Next Page");

    // Queue a command to load the newPage to access its data.
    context.load(newPage);

    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync();
    console.log("page is created with title: " + newPage.title);
});

load(options)

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

load(options?: OneNote.Interfaces.PageLoadOptions): OneNote.Page;

パラメーター

options
OneNote.Interfaces.PageLoadOptions

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

戻り値

load(propertyNames)

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

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

パラメーター

propertyNames

string | string[]

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

戻り値

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

    // Gets the active page.
    const activePage = context.application.getActivePage();

    // Queue a command to add a new page after the active page.
    const pageContents = activePage.contents;

    // Queue a command to load the pageContents to access its data.
    context.load(pageContents);

    // Run the queued commands, and return a promise to indicate task completion.
    await context.sync()
    for(let i=0; i < pageContents.items.length; i++) {
        const pageContent = pageContents.items[i];
        if (pageContent.type == "Outline") {
            console.log("Found an outline");
        } else if (pageContent.type == "Image") {
            console.log("Found an image");
        } else if (pageContent.type == "Other") {
            console.log("Found a type not supported yet.");
        }
    }
});

load(propertyNamesAndPaths)

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

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

パラメーター

propertyNamesAndPaths

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

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

戻り値

set(properties, options)

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

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

パラメーター

properties
OneNote.Interfaces.PageUpdateData

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

options
OfficeExtension.UpdateOptions

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

戻り値

void

set(properties)

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

set(properties: OneNote.Page): void;

パラメーター

properties
OneNote.Page

戻り値

void

toJSON()

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

toJSON(): OneNote.Interfaces.PageData;

戻り値

track()

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

track(): OneNote.Page;

戻り値

untrack()

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

untrack(): OneNote.Page;

戻り値