Public

Updated at:

The Public object exposes shared utilities across the Web Office SDK, including broadcast messaging, document version restoration, third-party pop-up dispatching, and secure link opening.

Public

A public processing function.

  • Syntax

    expression.Public

    expression: the document type application object.

  • Example

    //@file=base.docx
    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Get the Public processing object.
      const panes = await app.Public;
    }

Methods

Public.SendBroadcast()

Sends a global broadcast.

  • Syntax

    expression.SendBroadcast({ Data, Id })

    expression: the instantiated Public object

  • Parameters

    Property

    Type

    Required

    Description

    Data

    Object

    Yes

    The broadcast message payload.

    Id

    Boolean

    No

    The ID of the user who receives the message.

  • Return values

    Returns the corresponding Public object.

  • Example

    //@file=base.docx
    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Get the Public processing object.
      const Public = await app.Public;
    
      // Send a global broadcast.
      const result = await Public.SendBroadcast({
        Data: {message: 'Test'}
      });
    }

Public.PreviewRestore()

Restores a document to a previous version.

  • Syntax

    expression.PreviewRestore({ Version, Reversion, })

    expression: the instantiated Public object

  • Parameters

    Property

    Type

    Required

    Description

    Version

    number

    Yes

    The version number to restore to.

    Revision

    number

    No

    The revision record to restore from.

    HistoryId

    string

    No

    The ID of the target version in the version history.

  • Return values

    Returns the corresponding Public object.

  • Example

    //@file=base.docx
    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Get the Public processing object.
      const Public = await app.Public;
    
      // Restore to a specific version of the document.
      const pane = await Public.PreviewRestore({
            Version:535,
            HistoryId:'test'});
    }

Public.DispatchModelVisible()

Dispatches an operation event of a third-party pop-up.

  • Syntax

    expression.DispatchModelVisible({ Visible })

    expression: the instantiated Public object

  • Parameters

    Property

    Type

    Required

    Description

    Visible

    boolean

    No

    Whether the pop-up is visible. Default value: false.

  • Return values

    Returns the corresponding Public object.

  • Example

    //@file=base.docx
    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Get the Public processing object.
      const Public = await app.Public;
    
      // Dispatch a visibility event for a third-party pop-up.
      const pane = await Public.DispatchModelVisible(true);
    }

Public.OpenLink()

Wraps window.open with link security validation. This method accepts the same parameters as window.open().

  • Syntax

    expression.OpenLink()

    expression: the instantiated Public object

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      await app.Public.OpenLink('https://www.aliyun.com')
    }

Property

Public.KeyBoardHeight

Gets or sets the keyboard height on mobile devices.

Important

The height value is in logical pixels. Convert physical pixels to logical pixels before setting this property.

  • Syntax

    expression.KeyBoardHeight

    expression: the instantiated Public object

  • Example

    //@file=base.docx
    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Get the Public processing object.
      const Public = await app.Public;
    
      // Get the current keyboard height on mobile devices.
      const height = await Public.KeyBoardHeight;
    
      // Set the keyboard height (in logical pixels).
      Public.KeyBoardHeight = 48;
    }