|
| 1 | +[[view_show]] |
| 2 | +== `+view_show+` |
| 3 | + |
| 4 | +This option allows the specified view to be displayed on editor initialization. It behaves similarly to xref:customsidebar.adoc#sidebar_show[`+sidebar_show+`] but applies to views and takes precedence when both are configured. Views and sidebars can both be set to show on init, with the sidebar shown once the view is closed. |
| 5 | + |
| 6 | +The value must match the name of a registered view. Premium plugins that register views include: |
| 7 | + |
| 8 | +* xref:suggestededits.adoc[Suggested Edits] (`+suggestededits+`) |
| 9 | +* xref:revisionhistory.adoc[Revision History] (`+revision+`) |
| 10 | +* xref:advcode.adoc[Enhanced Code Editor] (`+code+`) |
| 11 | + |
| 12 | +Custom views registered via xref:custom-view.adoc[`+addView+`] can also be specified. |
| 13 | + |
| 14 | +include::partial$misc/admon-iframe-only.adoc[] |
| 15 | + |
| 16 | +*Type:* `+String+` |
| 17 | + |
| 18 | +=== Example: using `+view_show+` with a premium plugin |
| 19 | + |
| 20 | +[source,js] |
| 21 | +---- |
| 22 | +tinymce.init({ |
| 23 | + selector: 'textarea', // change this value according to your HTML |
| 24 | + plugins: 'suggestededits', |
| 25 | + toolbar: 'suggestededits', |
| 26 | + view_show: 'suggestededits', |
| 27 | + // ... other Suggested Edits options (suggestededits_model, user_id, fetch_users) |
| 28 | +}); |
| 29 | +---- |
| 30 | + |
| 31 | +=== Example: using `+view_show+` with a custom view |
| 32 | + |
| 33 | +[source,js] |
| 34 | +---- |
| 35 | +tinymce.init({ |
| 36 | + selector: 'textarea', // change this value according to your HTML |
| 37 | + menubar: false, |
| 38 | + toolbar: 'view', |
| 39 | + view_show: 'view', |
| 40 | + setup: (editor) => { |
| 41 | + const toggleView = () => editor.execCommand('ToggleView', false, 'view'); |
| 42 | + editor.ui.registry.addView('view', { |
| 43 | + onShow: (api) => { |
| 44 | + api.getContainer().innerHTML = '<p>You opened the view!</p>'; |
| 45 | + }, |
| 46 | + onHide: (api) => { |
| 47 | + api.getContainer().innerHTML = ''; |
| 48 | + }, |
| 49 | + buttons: [{ |
| 50 | + type: 'button', |
| 51 | + text: 'Close', |
| 52 | + onAction: toggleView |
| 53 | + }] |
| 54 | + }); |
| 55 | + editor.ui.registry.addButton('view', { |
| 56 | + text: 'Open view', |
| 57 | + onAction: toggleView |
| 58 | + }); |
| 59 | + } |
| 60 | +}); |
| 61 | +---- |
0 commit comments