This topic describes the API operations that are related to the Sub object of text documents.
Sub.ClipboardCopy
Listens to clipboard copy operations.
Only JavaScript SDK V1.1.12 and later support this feature.
Syntax
expression.Sub.ClipboardCopy = Function
expression: the application object of the document type.
Return values
Property
Data type
Description
copyId
String
The ID of the clipboard.
isRestoreFocus
Boolean
Indicates whether the focus is restored.
text
String
The copied content.
Example
async function example() { await instance.ready(); const app = instance.Application; // Listen to clipboard copy operations. app.Sub.ClipboardCopy = (e) => { console.log(e); } }
Sub.CurrentPageChange
Listens to changes in the current page number.
Only JavaScript SDK V1.1.12 and later support this feature.
Only PCs support this feature.
Syntax
expression.Sub.CurrentPageChange = Function
expression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Listen to changes in the current page number. app.Sub.CurrentPageChange = (e) => { console.log('Changes in the current page:', e); }; }
Sub.DocMapPanelChange
Listens to the display or hiding operations on the document map panel.
Only JavaScript SDK V1.1.12 and later support this feature.
Only PCs support this feature.
Syntax
expression.Sub.DocMapPanelChange = Function
expression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Listen to the display or hiding operations on the document map panel. app.Sub.DocMapPanelChange = (e) => { console.log('Display of document map panel:', e); }; }
Sub.DropdownListControlItemChange
Listens to changes in the options of a drop-down list.
Only JavaScript SDK V1.1.15 and later support this feature.
Only PCs support this feature.
Syntax
expression.Sub.DocMapPanelChange = Function
expression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Listen to changes in the options of a drop-down list. app.Sub.DropdownListControlItemChange = (e) => { console.log('Changes in options of the drop-down list', e); /* The structure of the response parameters: { Pos: Number, // The location information. Type: String, // Valid values: Select and UnSelect. Info: { Text: String, // The displayed text. Value: String, // The programmed value. }, } */ }; }
Sub.ViewModeChange
Listens to changes in the view mode of pages.
Only JavaScript SDK V1.1.14 and later support this feature.
Syntax
expression.Sub.ViewModeChange = Function
expression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Listen to changes in the view mode of pages. app.Sub.ViewModeChange = (d) => { console.log(d); // A value of web indicates the web layout view mode. A value of pages indicates the page layout view mode. } }
Sub.WindowScrollChange
Listens to the document window scrolls.
Only JavaScript SDK V1.1.12 and later support this feature.
Syntax
expression.Sub.WindowScrollChange = Function
expression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Listen to the document window scrolls. app.Sub.WindowScrollChange = ({ Data }) => { console.log(Data.scrollLeft, Data.scrollTop); } }
Sub.WindowSelectionChange
Listens to changes in a selection.
Only JavaScript SDK V1.1.12 and later support this feature.
Syntax
expression.Sub.WindowSelectionChange = Function
expression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Listen to changes in a selection. app.Sub.WindowSelectionChange = (e) => { const { begin, end } = e; console.log('Start position of the selection:${begin}, End position of the selection:${end}'); }
Sub.AddComment
Listens to new comments.
Only JavaScript SDK V1.1.15 and later support this feature.
Syntax
expression.Sub.AddComment = Function
expression: the application object of the document type.
Return values
Property
Data type
Description
author
String
The name of the user who makes the comment.
pos
Number
The starting position of the body text that corresponds to the comment.
len
Number
The length of the body text that corresponds to the comment.
commentId
String
The ID of the comment.
NoteA comment does not require a value for the commentId parameter, but it does require a value for the rcId parameter. If no value is returned for the commentId parameter, check the value of the rcId parameter.
rcId
String
The ID of the comment.
replyCommentId
String
The ID of the reply to the comment.
type
String
The type of the comment.
content
String
The content of the comment.
date
String
The time when the comment is made.
Example
async function example() { await instance.ready(); const app = instance.Application; // Listen to new comments. app.Sub.AddComment = (e) => { console.log(e); } }
Sub.RemoveComment
Listens to the deletion of comments.
Only JavaScript SDK V1.1.15 and later support this feature.
Syntax
expression.Sub.RemoveComment = Function
expression: the application object of the document type.
Return values
Property
Data type
Description
author
String
The name of the user who makes the comment.
pos
Number
The starting position of the body text that corresponds to the comment.
len
Number
The length of the body text that corresponds to the comment.
commentId
String
The ID of the comment.
NoteA comment does not require a value for the commentId parameter, but it does require a value for the rcId parameter. If no value is returned for the commentId parameter, check the value of the rcId parameter.
rcId
String
The ID of the comment.
replyCommentId
String
The ID of the reply to the comment.
type
String
The type of the comment.
content
String
The content of the comment.
date
String
The time when the comment is made.
Example
async function example() { await instance.ready(); const app = instance.Application; // Listen to the deletion of comments. app.Sub.RemoveComment = (e) => { console.log(e); } }
Sub.EditComment
Listens to the modifications of comments.
Only JavaScript SDK V1.1.15 and later support this feature.
Syntax
expression.Sub.EditComment = Function
expression: the application object of the document type.
Return values
Property
Data type
Description
author
String
The name of the user who makes the comment.
pos
Number
The starting position of the body text that corresponds to the comment.
len
Number
The length of the body text that corresponds to the comment.
commentId
String
The ID of the comment.
NoteA comment does not require a value for the commentId parameter, but it does require a value for the rcId parameter. If no value is returned for the commentId parameter, check the value of the rcId parameter.
rcId
String
The ID of the comment.
replyCommentId
String
The ID of the reply to the comment.
type
String
The type of the comment.
content
String
The content of the comment.
date
String
The time when the comment is made.
Example
async function example() { await instance.ready(); const app = instance.Application; // Listen to the modifications of comments. app.Sub.EditComment = (e) => { console.log(e); } }
Sub.FontMissing
Listens to the font missing events.
Only JavaScript SDK V1.1.15 and later support this feature.
Syntax
expression.Sub.FontMissing = Function
expression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Listen to the font missing events. app.Sub.FontMissing = (e) => { console.log(e); } }
Sub.DocMapItemClick
Listens to clicks on the document map.
Only PCs support this feature.
Syntax
expression.Sub.DocMapItemClick = Function
expression: the application object of the document type.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; app.Sub.DocMapItemClick = (e) => { console.log(e); } }
Sub.ControlItemClick
Listens to clicks on the content controls.
Only JavaScript SDK V1.1.19 and later support this feature. Only PCs support this feature.
Syntax
expression.Sub.ControlItemClick = Function
expression: the application object of the document type.
Example
async function example() { await instance.ready(); const app = instance.Application; app.Sub.ControlItemClick = (e) => { console.log(e); } }
Sub.ContentChange
Listens to changes in the document content.
Only JavaScript SDK V1.1.19 and later support this feature.
Syntax
expression.Sub.ContentChange = Function
expression: the application object of the document type.
async function example() { await instance.ready(); const app = instance.Application; app.Sub.ContentChange = (e) => { console.log(e); } }