OneNote.RichText class

Paragraph 内の RichText オブジェクトを表します。

Extends

注釈

[ API セット: OneNoteApi 1.1 ]

プロパティ

context

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

id

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

languageId

テキストの言語 ID です。 読み取り専用です。

paragraph

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

style

RichText オブジェクトのテキスト スタイルを取得します。 読み取り専用です。

text

RichText オブジェクトのテキスト コンテンツを取得します。 読み取り専用です。

メソッド

getHtml()

リッチ テキストの HTML を取得します

load(options)

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

load(propertyNames)

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

load(propertyNamesAndPaths)

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

toJSON()

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

track()

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

untrack()

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

プロパティの詳細

context

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

context: RequestContext;

プロパティ値

id

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

readonly id: string;

プロパティ値

string

注釈

[ API セット: OneNoteApi 1.1 ]

languageId

テキストの言語 ID です。 読み取り専用です。

readonly languageId: string;

プロパティ値

string

注釈

[ API セット: OneNoteApi 1.1 ]

paragraph

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

readonly paragraph: OneNote.Paragraph;

プロパティ値

注釈

[ API セット: OneNoteApi 1.1 ]

style

RichText オブジェクトのテキスト スタイルを取得します。 読み取り専用です。

readonly style: OneNote.ParagraphStyle;

プロパティ値

注釈

[ API セット: OneNoteApi 1.8 ]

text

RichText オブジェクトのテキスト コンテンツを取得します。 読み取り専用です。

readonly text: string;

プロパティ値

string

注釈

[ API セット: OneNoteApi 1.1 ]

メソッドの詳細

getHtml()

リッチ テキストの HTML を取得します

getHtml(): OfficeExtension.ClientResult<string>;

戻り値

リッチ テキストの html

注釈

[ API セット: OneNoteApi 1.1 ]

load(options)

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

load(options?: OneNote.Interfaces.RichTextLoadOptions): OneNote.RichText;

パラメーター

options
OneNote.Interfaces.RichTextLoadOptions

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

戻り値

load(propertyNames)

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

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

パラメーター

propertyNames

string | string[]

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

戻り値

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, and then get its outline's paragraphs.
    const outlinePageContents = pageContents.getItem(0);
    let paragraphs = outlinePageContents.outline.paragraphs;
    const richTextParagraphs = paragraphs.items;
    // Queue a command to load the id and type of each page content in the outline.
    pageContents.load("id,type");

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

    // Load all page contents of type Outline.
    $.each(pageContents.items, function(index, pageContent) {
        if(pageContent.type == 'Outline')
        {
            pageContent.load('outline,outline/paragraphs,outline/paragraphs/type');
            outlinePageContents.push(pageContent);
        }
    });
    await context.sync();

    // Load all rich text paragraphs across outlines.
    $.each(outlinePageContents, function(index, outlinePageContent) {
        const outline = outlinePageContent.outline;
        paragraphs = paragraphs.concat(outline.paragraphs.items);
    });
    $.each(paragraphs, function(index, paragraph) {
        if(paragraph.type == 'RichText')
        {
            richTextParagraphs.push(paragraph);
            paragraph.load("id,richText/text");
        }
    });
    await context.sync();

    // Display all rich text paragraphs to the console.
    $.each(richTextParagraphs, function(index, richTextParagraph) {
        const richText = richTextParagraph.richText;
        console.log(
            "Paragraph found with richtext content : " + 
            richText.text + " and richtext id : " + richText.id);
    });
    await context.sync();
});

load(propertyNamesAndPaths)

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

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

パラメーター

propertyNamesAndPaths

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

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

戻り値

toJSON()

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

toJSON(): OneNote.Interfaces.RichTextData;

戻り値

track()

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

track(): OneNote.RichText;

戻り値

untrack()

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

untrack(): OneNote.RichText;

戻り値