# ONLYOFFICE Docs API Samples: A Resizable Editor Dialog and Live Watermark Updates

If you build on top of ONLYOFFICE Docs, two new samples from the API changelog 10.3.0 cover common integration requests: opening the editor without leaving the current page, and changing the watermark from your own interface.

- A native `<dialog>` that hosts the editor and can be moved, resized and closed.
- The editor's own cross button wired to your dialog.
- A watermark set in the config and replaced at runtime through the Automation API.

Let's dig in.

## What the Samples Do

**Opening the editor in a dialog** opens the editor over the page. Users move the dialog by the top edge of the frame, resize it by the other edges and corners, and close it with the cross button in the editor.

**Working with watermark** changes the watermark drawn over the pages from an external UI, for example to show the current user's name or the document status. The editor redraws the pages in real time.

## How It Works

### The Dialog and Its Frame

The editor runs in an iframe from Document Server, so pointer events over the editor never reach the host page. The sample therefore puts a thin frame around the editor that belongs to the host page: a `<dialog id="editorDialog">` with `<div id="editorContainer">` and eight handles (the top edge is a `<button>`, the rest are `<div class="handle">` elements with a `data-edge` value).

**Why this matters:** the dialog, not the editor, owns the pointer, so you control the window behavior with plain DOM code.

### Editor Config for a Dialog

`openEditor(config)` creates `new DocsAPI.DocEditor()` with `editorConfig.customization.close` (`visible: true`, `text: "Close"`), `compactHeader: true`, `width` and `height` of `"100%"`, `onAppReady` to mark the editor ready, and `onRequestClose` to call `dialog.close()`. The dialog is sized to at most 1100 × 720, centered and opened with `dialog.showModal()`.

**Why this matters:** the cross button appears only when both `close` and `onRequestClose` are set. Miss one, and users have no way to close the editor from inside it.

### Moving, Resizing and Closing

Handles capture the pointer on `pointerdown`, with a minimum size of 480 × 320. The dialog is moved and resized in place, because moving the iframe to another element makes the browser reload it. While dragging, the iframe gets `pointer-events: none`. Arrow keys move the dialog, and Shift with the arrow keys resizes it.

On Esc, the sample cancels the `cancel` event and calls `requestClose()` once the editor is ready; on `close`, it calls `destroyEditor()`. If the editor fails to load, there is no cross button, so the sample page suggests a custom close button, for example from `onError`.

### Watermark: Config First, Then Runtime Updates

The initial watermark lives in `document.options.watermark_on_draw`, and `%user_name%` is replaced with `editorConfig.user.name`. The sample uses a rectangle rotated by -45 degrees with `transparent: 0.3` and the text "Confidential: %user_name%".

When the user clicks Apply, the sample sends the new watermark as a JSON string:

```javascript
connector.executeMethod("SetProperties", [{ watermark_on_draw: JSON.stringify(buildWatermark()) }])
```

**Why this matters:** per the reference, this watermark is drawn on every page while the document is open, added to PDF and image downloads, and never saved to the document. It is not access control, so restrict `download`, `print` and `copy` in the permissions as well.

*The connector (Automation API) is available only for ONLYOFFICE Docs Developer, as a premium feature at an extra cost.*

## Running the Sample

1. Open the [dialog sample](https://api.onlyoffice.com/docs/docs-api/samples/opening-in-dialog?utm_source=hashnode&utm_medium=referral&utm_campaign=docs-de_dev_en_samples_202611&utm_content=v10-3-0_sample-opening-in-dialog), choose a document type and click **Open in a dialog**.
2. Open the [watermark sample](https://api.onlyoffice.com/docs/docs-api/samples/automation-api/working-with-watermark?utm_source=hashnode&utm_medium=referral&utm_campaign=docs-de_dev_en_samples_202611&utm_content=v10-3-0_sample-working-with-watermark), set color, opacity and angle, and click **Apply**.
3. Move the code into your integration and replace the document config with your own.

## Where to Take It Next

- Add a custom close button that appears from `onError`.
- Fill `%user_name%` from your auth system and escape quotes and backslashes in the name.
- Switch the watermark text when a document changes status (draft, approved).
- Combine both: open the editor in a dialog with a per-user watermark.

To get started, check the [document config reference](https://api.onlyoffice.com/docs/docs-api/usage-api/config/document?utm_source=hashnode&utm_medium=referral&utm_campaign=docs-de_dev_en_samples_202611&utm_content=v10-3-0_docs-config-document).

## Useful Links

- [Sample: Opening the editor in a dialog](https://api.onlyoffice.com/docs/docs-api/samples/opening-in-dialog?utm_source=hashnode&utm_medium=referral&utm_campaign=docs-de_dev_en_samples_202611&utm_content=v10-3-0_sample-opening-in-dialog)
- [Sample: Working with watermark](https://api.onlyoffice.com/docs/docs-api/samples/automation-api/working-with-watermark?utm_source=hashnode&utm_medium=referral&utm_campaign=docs-de_dev_en_samples_202611&utm_content=v10-3-0_sample-working-with-watermark)
- [Customization: close and compactHeader](https://api.onlyoffice.com/docs/docs-api/usage-api/config/editor/customization/customization-standard-branding?utm_source=hashnode&utm_medium=referral&utm_campaign=docs-de_dev_en_samples_202611&utm_content=v10-3-0_docs-customization)
- [Docs API events](https://api.onlyoffice.com/docs/docs-api/usage-api/config/events?utm_source=hashnode&utm_medium=referral&utm_campaign=docs-de_dev_en_samples_202611&utm_content=v10-3-0_docs-events) and [methods](https://api.onlyoffice.com/docs/docs-api/usage-api/methods?utm_source=hashnode&utm_medium=referral&utm_campaign=docs-de_dev_en_samples_202611&utm_content=v10-3-0_docs-methods)
- [SetProperties](https://api.onlyoffice.com/docs/plugins/interacting-with-editors/document-api/Methods/SetProperties?utm_source=hashnode&utm_medium=referral&utm_campaign=docs-de_dev_en_samples_202611&utm_content=v10-3-0_docs-setproperties)
- [ONLYOFFICE Docs Developer pricing](https://www.onlyoffice.com/pricing?utm_source=hashnode&utm_medium=referral&utm_campaign=docs-de_dev_en_samples_202611&utm_content=v10-3-0_pricing-docs-developer)
- [API changelog 10.3.0](https://api.onlyoffice.com/changelog/2026/11/13/version-10-3-0?utm_source=hashnode&utm_medium=referral&utm_campaign=docs-de_dev_en_samples_202611&utm_content=v10-3-0_changelog)
