---
title: "Vue 3 Editor Source Code and Preview"
description: "Use the Vue 3 editor code, preview and fullscreen plugins, keep the source dialog read-only, and open dialogs from a template ref with openSourceCode()."
head:
- - meta
- name: robots
content: 'index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1'
- - meta
- name: googlebot
content: 'index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1'
- - meta
- name: bingbot
content: 'index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1'
---
Are you an LLM? You can read better optimized documentation at https://raw.githubusercontent.com/eramitgupta/erag/main/text-editor-vue/docs/code-and-preview.md
# Source code, preview, and fullscreen for Vue 3
Three plugins in the Vue 3 editor help users check what they wrote: `code` for the raw HTML, `preview` for a sanitized read-only view, and `fullscreen` for distraction-free editing. Besides the toolbar and menus, a template ref lets your component open the dialogs itself:
```vue
```
The full list of exposed methods is in the [API reference](./api.html).
---
## Configuration
Enable `code`, `preview`, and `fullscreen` plugins:
```ts
const editorConfig: EditorInit = {
plugins: ['code', 'preview', 'fullscreen'],
toolbar: 'undo redo | blocks | bold italic | code preview fullscreen',
sourceCodeEditable: true,
};
```
---
## 1. Source Code View (`code`)
Clicking the **Source Code** (`code`) button or opening **Tools → Source code** launches an interactive HTML code modal.
- Displays raw sanitized HTML structure.
- Allows developers or power users to inspect and directly edit HTML tags.
- Applying changes re-sanitizes and updates the active editor canvas.
Source editing is enabled by default. To keep the dialog available for HTML inspection while preventing changes, set:
```ts
const editorConfig: EditorInit = {
sourceCodeEditable: false,
};
```
When disabled, the source textarea is read-only and the **Apply** button is hidden. The editor's `readonly` or `disabled` state also keeps this dialog read-only.
Programmatic invocation:
```ts
editor.value?.openSourceCode();
```
---
## 2. Live Preview (`preview`)
Clicking **Preview** (`preview`) or opening **File → Preview** launches a modal dialog rendering the sanitized document inside a clean view-only frame.
- Prevents accidental edits while reviewing.
- Shows exact layout rendering without editor toolbars or chrome.
- Includes a **Print** button that prints only the preview content.
Programmatic invocation:
```ts
editor.value?.openPreview();
```
You can also choose **File → Print** without opening Preview. The editor creates a temporary print-only portal, calls the browser print dialog, and cleans the portal afterward so the surrounding application page is not part of the printed document. The [editor workflow page](./editing-experience.html) describes printing alongside undo, paste, and resizing.
---
## 3. Fullscreen Editing Mode (`fullscreen`)
Clicking **Fullscreen** (`fullscreen`) expands the editor canvas across the full browser viewport.
- Hides surrounding page elements and navigation sidebars.
- Uses native browser Fullscreen API with automatic fallback for restricted environments.
- The browser's Escape behavior or clicking the Fullscreen button again exits native fullscreen. The CSS fallback can be toggled with the same editor button.