You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/includes/office-js-api-models.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ The Office JavaScript API includes two distinct models:
10
10
This API model uses [promises](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise) and allows you to specify multiple operations in each request you send to the Office application. Batching operations in this manner can significantly improve add-in performance in Office applications on the web. Application-specific APIs were introduced with Office 2016.
11
11
12
12
> [!NOTE]
13
-
> There's also an application-specific API for [Visio](../reference/overview/visio-javascript-reference-overview.md), but you can use it only in SharePoint Online pages to interact with Visio diagrams that have been embedded in the page. Office Web Add-ins are not supported in Visio.
13
+
> There's also an application-specific API for [Visio](../visio/visio-overview.md), but you can use it only in SharePoint Online pages to interact with Visio diagrams that have been embedded in the page. Office Web Add-ins are not supported in Visio.
14
14
15
15
See [Using the application-specific API model](../develop/application-specific-api-model.md) to learn more about this API model.
Copy file name to clipboardExpand all lines: docs/visio/visio-overview.md
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,18 @@
1
1
---
2
2
title: Visio JavaScript API overview
3
3
description: Overview of the Visio JavaScript API.
4
-
ms.date: 07/18/2022
4
+
ms.date: 07/15/2025
5
5
ms.service: visio
6
6
ms.topic: overview
7
7
ms.custom: scenarios:getting-started
8
-
ms.localizationpriority: high
8
+
ms.localizationpriority: medium
9
9
---
10
10
11
11
# Visio JavaScript API overview
12
12
13
-
You can use the Visio JavaScript APIs to embed Visio diagrams in *classic* SharePoint pages in SharePoint Online. (This extensibility feature is not supported in on-premise SharePoint or on SharePoint Framework pages.)
13
+
You can use the Visio JavaScript APIs to embed Visio diagrams in *classic* SharePoint pages in SharePoint Online. (This extensibility feature isn't supported in on-premises SharePoint or SharePoint Framework pages.)
14
14
15
-
An embedded Visio diagram is a diagram that is stored in a SharePoint document library and displayed on a SharePoint page. To embed a Visio diagram, display it in an HTML `<iframe>` element. Then you can use Visio JavaScript APIs to programmatically work with the embedded diagram.
15
+
An embedded Visio diagram is stored in a SharePoint document library and displayed on a SharePoint page. To embed a Visio diagram, display it in an HTML `<iframe>` element. Then use Visio JavaScript APIs to programmatically work with the embedded diagram.
16
16
17
17

18
18
@@ -23,7 +23,7 @@ You can use the Visio JavaScript APIs to:
23
23
- Write custom handlers for mouse events within the drawing.
24
24
- Expose diagram data, such as shape text, shape data, and hyperlinks, to your solution.
25
25
26
-
This article describes how to use the Visio JavaScript APIs with Visio on the web to build your solutions for SharePoint Online. It introduces key concepts that are fundamental to using the APIs, such as `EmbeddedSession`, `RequestContext`, and JavaScript proxy objects, and the `sync()`, `Visio.run()`, and `load()` methods. The code examples show you how to apply these concepts.
26
+
This article describes how to use the Visio JavaScript APIs with Visio on the web to build solutions for SharePoint Online. It introduces key concepts that are fundamental to using the APIs, such as `EmbeddedSession`, `RequestContext`, and JavaScript proxy objects, and the `sync()`, `Visio.run()`, and `load()` methods. The code examples show you how to apply these concepts.
`Visio.run()` executes a batch script that performs actions on the Visio object model. The batch commands include definitions of local JavaScript proxy objects and `sync()` methods that synchronize the state between local and Visio objects and promise resolution. The advantage of batching requests in `Visio.run()` is that when the promise is resolved, any tracked page objects that were allocated during the execution will be automatically released.
41
+
`Visio.run()` executes a batch script that performs actions on the Visio object model. The batch commands include definitions of local JavaScript proxy objects and `sync()` methods that synchronize the state between local and Visio objects and promise resolution. The advantage of batching requests in `Visio.run()` is that when the promise is resolved, any tracked page objects that were allocated during execution are automatically released.
42
42
43
-
The `run` function takes in session and RequestContext object and returns a promise (typically, just the result of `context.sync()`). It is possible to run the batch operation outside of the `Visio.run()`. However, in such a scenario, any page object references needs to be manually tracked and managed.
43
+
The `run` function takes in session and RequestContext object and returns a promise (typically, just the result of `context.sync()`). You can run the batch operation outside of `Visio.run()`. However, in such a scenario, any page object references need to be manually tracked and managed.
44
44
45
45
## RequestContext
46
46
47
-
The RequestContext object facilitates requests to the Visio application. Because the developer frame and the Visio web client run in two different iframes, the RequestContext object (context in next example) is required to get access to Visio and related objects such as pages and shapes, from the developer frame.
47
+
The RequestContext object facilitates requests to the Visio application. Because the developer frame and the Visio web client run in two different iframes, the RequestContext object (context in the next example) is required to get access to Visio and related objects such as pages and shapes from the developer frame.
48
48
49
49
```js
50
50
functionhideToolbars() {
@@ -63,9 +63,9 @@ function hideToolbars() {
63
63
64
64
## Proxy objects
65
65
66
-
The Visio JavaScript objects declared and used in an embedded session are proxy objects for the real objects in a Visio document. All actions taken on proxy objects are not realized in Visio, and the state of the Visio document is not realized in the proxy objects until the document state has been synchronized. The document state is synchronized when `context.sync()` is run.
66
+
The Visio JavaScript objects declared and used in an embedded session are proxy objects for the real objects in a Visio document. All actions taken on proxy objects aren't realized in Visio, and the state of the Visio document isn't realized in the proxy objects until the document state has been synchronized. The document state is synchronized when `context.sync()` is run.
67
67
68
-
For example, the local JavaScript object getActivePage is declared to reference the selected page. This can be used to queue the setting of its properties and invoking methods. The actions on such objects are not realized until the `sync()` method is run.
68
+
For example, the local JavaScript object getActivePage is declared to reference the selected page. You can use this to queue the setting of its properties and invoke methods. The actions on such objects aren't realized until the `sync()` method is run.
69
69
70
70
```js
71
71
constactivePage=context.document.getActivePage();
@@ -77,7 +77,7 @@ The `sync()` method synchronizes the state between JavaScript proxy objects and
77
77
78
78
## load()
79
79
80
-
The `load()` method is used to fill in the proxy objects created in the JavaScript layer. When trying to retrieve an object such as a document, a local proxy object is created first in the JavaScript layer. Such an object can be used to queue the setting of its properties and invoking methods. However, for reading object properties or relations, the `load()` and `sync()` methods need to be invoked first. The load() method takes in the properties and relations that need to be loaded when the `sync()` method is called.
80
+
The `load()` method is used to fill in the proxy objects created in the JavaScript layer. When trying to retrieve an object such as a document, a local proxy object is created first in the JavaScript layer. You can use such an object to queue the setting of its properties and invoke methods. However, for reading object properties or relations, the `load()` and `sync()` methods need to be invoked first. The load() method takes in the properties and relations that need to be loaded when the `sync()` method is called.
81
81
82
82
The following shows the syntax for the `load()` method.
83
83
@@ -117,7 +117,7 @@ Visio.run(session, function (context) {
117
117
118
118
## Error messages
119
119
120
-
Errors are returned using an error object that consists of a code and a message. The following table provides a list of possible error conditions that can occur.
120
+
Errors are returned using an error object that consists of a code and a message. The following table provides a list of possible error conditions.
@@ -130,7 +130,7 @@ Errors are returned using an error object that consists of a code and a message.
130
130
131
131
## Get started
132
132
133
-
You can use the example in this section to get started. This example shows you how to programmatically display the shape text of the selected shape in a Visio diagram. To begin, create a classic page in SharePoint Online or edit an existing page. Add a script editor webpart on the page and copy-paste the following code.
133
+
You can use the example in this section to get started. This example shows you how to programmatically display the shape text of the selected shape in a Visio diagram. To begin, create a classic page in SharePoint Online or edit an existing page. Add a script editor web part on the page and copy-paste the following code.
@@ -192,12 +192,12 @@ function getSelectedShapeText() {
192
192
</script>
193
193
```
194
194
195
-
After that, all you need is the URL of a Visio diagram that you want to work with. Just upload the Visio diagram to SharePoint Online and open it in Visio on the web. From there, open the Embed dialog and use the Embed URL in the above example.
195
+
After that, all you need is the URL of a Visio diagram that you want to work with. Upload the Visio diagram to SharePoint Online and open it in Visio on the web. From there, open the Embed dialog and use the Embed URL in the above example.
196
196
197
197

198
198
199
-
If you are using Visio on the web in Edit mode, open the Embed dialog by choosing **File** > **Share** > **Embed**. If you are using Visio on the web in View mode, open the Embed dialog by choosing '...' and then **Embed**.
199
+
If you're using Visio on the web in Edit mode, open the Embed dialog by choosing **File** > **Share** > **Embed**. If you're using Visio on the web in View mode, open the Embed dialog by choosing '...' and then **Embed**.
200
200
201
201
## Visio JavaScript API reference
202
202
203
-
For detailed information about Visio JavaScript API, see the [Visio JavaScript API reference documentation](/javascript/api/visio).
203
+
For detailed information about the Visio JavaScript API, see the [Visio JavaScript API reference documentation](/javascript/api/visio).
0 commit comments