From 30fc88d9e8f2ba5db27eb1829a7cd1f553279622 Mon Sep 17 00:00:00 2001 From: Karl Kemister-Sheppard Date: Mon, 16 Mar 2026 13:33:36 +1000 Subject: [PATCH] Docs: DOC-3243 - New view_show option to display a specified view on initialization --- .../examples/live-demos/custom-view/index.js | 10 +-- modules/ROOT/pages/8.4.0-release-notes.adoc | 7 +++ modules/ROOT/pages/advcode.adoc | 2 + modules/ROOT/pages/custom-view.adoc | 4 ++ modules/ROOT/pages/revisionhistory.adoc | 2 + modules/ROOT/pages/suggestededits.adoc | 2 + .../partials/configuration/view_show.adoc | 61 +++++++++++++++++++ .../partials/plugins/advcode-open-view.adoc | 14 +++++ .../plugins/revisionhistory-open-view.adoc | 15 +++++ .../plugins/suggestededits-open-view.adoc | 15 +++++ 10 files changed, 127 insertions(+), 5 deletions(-) create mode 100644 modules/ROOT/partials/configuration/view_show.adoc create mode 100644 modules/ROOT/partials/plugins/advcode-open-view.adoc create mode 100644 modules/ROOT/partials/plugins/revisionhistory-open-view.adoc create mode 100644 modules/ROOT/partials/plugins/suggestededits-open-view.adoc diff --git a/modules/ROOT/examples/live-demos/custom-view/index.js b/modules/ROOT/examples/live-demos/custom-view/index.js index 98e3a4e322..7e98a7b061 100644 --- a/modules/ROOT/examples/live-demos/custom-view/index.js +++ b/modules/ROOT/examples/live-demos/custom-view/index.js @@ -28,12 +28,12 @@ tinymce.init({ ], onShow: (api) => { const editorContent = ed.getContent(); - api.getContainer().innerHTML = ` + const container = api.getContainer(); + container.innerHTML = `
- -
`.replace(/\s+/g, ''); + + `; + container.querySelector('.tox-view__pane_panel').value = editorContent; }, onHide: (api) => { console.log('Deactivate code', api.getContainer()); diff --git a/modules/ROOT/pages/8.4.0-release-notes.adoc b/modules/ROOT/pages/8.4.0-release-notes.adoc index 9d8d4ba772..1c488d6607 100644 --- a/modules/ROOT/pages/8.4.0-release-notes.adoc +++ b/modules/ROOT/pages/8.4.0-release-notes.adoc @@ -125,6 +125,13 @@ For information on using Enhanced Skins & Icon Packs, see: xref:enhanced-skins-a // CCFR here. +=== New `view_show` option to display a specified view on initialization. +// #TINY-11967 + +Previously, integrators could not configure the editor to open with a specific view (such as Suggested Edits or Revision History) displayed on initialization. This was needed when users would only need to resolve suggested changes or review content, or when the current user had permission only to review changes. + +In {productname} {release-version}, the new xref:custom-view.adoc#view_show[`+view_show+`] option allows specifying which view to display when the editor is initialized. The option behaves similarly to `+sidebar_show+` but takes precedence for views; both sidebars and views can be configured to show on init. + [[changes]] == Changes diff --git a/modules/ROOT/pages/advcode.adoc b/modules/ROOT/pages/advcode.adoc index 504b7bba41..fcab998756 100644 --- a/modules/ROOT/pages/advcode.adoc +++ b/modules/ROOT/pages/advcode.adoc @@ -66,6 +66,8 @@ include::partial$configuration/advcode_prettify_getcontent.adoc[leveloffset=+1] include::partial$configuration/advcode_prettify_editor.adoc[leveloffset=+1] +include::partial$plugins/advcode-open-view.adoc[] + include::partial$misc/advcode-shortcuts.adoc[] include::partial$misc/plugin-toolbar-button-id-boilerplate.adoc[] diff --git a/modules/ROOT/pages/custom-view.adoc b/modules/ROOT/pages/custom-view.adoc index 2cb4d7555b..7df476776f 100644 --- a/modules/ROOT/pages/custom-view.adoc +++ b/modules/ROOT/pages/custom-view.adoc @@ -57,6 +57,10 @@ To query the state of the custom view (whether it is currently visible or hidden editor.queryCommandValue('ToggleView') == 'myCustomView'; ---- +== Options + +include::partial$configuration/view_show.adoc[leveloffset=+1] + == Interactive example This example shows how to integrate a custom view using the `addView` API. diff --git a/modules/ROOT/pages/revisionhistory.adoc b/modules/ROOT/pages/revisionhistory.adoc index 0df0343897..0832b8b085 100644 --- a/modules/ROOT/pages/revisionhistory.adoc +++ b/modules/ROOT/pages/revisionhistory.adoc @@ -121,6 +121,8 @@ include::partial$configuration/revisionhistory_css_url.adoc[leveloffset=+1] include::partial$configuration/revisionhistory_diff_classes.adoc[leveloffset=+1] +include::partial$plugins/revisionhistory-open-view.adoc[] + include::partial$misc/plugin-toolbar-button-id-boilerplate.adoc[] include::partial$misc/plugin-menu-item-id-boilerplate.adoc[] diff --git a/modules/ROOT/pages/suggestededits.adoc b/modules/ROOT/pages/suggestededits.adoc index 9d983e4a26..662df2c641 100644 --- a/modules/ROOT/pages/suggestededits.adoc +++ b/modules/ROOT/pages/suggestededits.adoc @@ -127,6 +127,8 @@ include::partial$configuration/suggestededits_access.adoc[leveloffset=+1] include::partial$configuration/suggestededits_auto_approve.adoc[leveloffset=+1] +include::partial$plugins/suggestededits-open-view.adoc[] + include::partial$configuration/user_id.adoc[leveloffset=+1] include::partial$configuration/fetch_users.adoc[leveloffset=+1] diff --git a/modules/ROOT/partials/configuration/view_show.adoc b/modules/ROOT/partials/configuration/view_show.adoc new file mode 100644 index 0000000000..614b685aeb --- /dev/null +++ b/modules/ROOT/partials/configuration/view_show.adoc @@ -0,0 +1,61 @@ +[[view_show]] +== `+view_show+` + +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. + +The value must match the name of a registered view. Premium plugins that register views include: + +* xref:suggestededits.adoc[Suggested Edits] (`+suggestededits+`) +* xref:revisionhistory.adoc[Revision History] (`+revision+`) +* xref:advcode.adoc[Enhanced Code Editor] (`+code+`) + +Custom views registered via xref:custom-view.adoc[`+addView+`] can also be specified. + +include::partial$misc/admon-iframe-only.adoc[] + +*Type:* `+String+` + +=== Example: using `+view_show+` with a premium plugin + +[source,js] +---- +tinymce.init({ + selector: 'textarea', // change this value according to your HTML + plugins: 'suggestededits', + toolbar: 'suggestededits', + view_show: 'suggestededits', + // ... other Suggested Edits options (suggestededits_model, user_id, fetch_users) +}); +---- + +=== Example: using `+view_show+` with a custom view + +[source,js] +---- +tinymce.init({ + selector: 'textarea', // change this value according to your HTML + menubar: false, + toolbar: 'view', + view_show: 'view', + setup: (editor) => { + const toggleView = () => editor.execCommand('ToggleView', false, 'view'); + editor.ui.registry.addView('view', { + onShow: (api) => { + api.getContainer().innerHTML = '

You opened the view!

'; + }, + onHide: (api) => { + api.getContainer().innerHTML = ''; + }, + buttons: [{ + type: 'button', + text: 'Close', + onAction: toggleView + }] + }); + editor.ui.registry.addButton('view', { + text: 'Open view', + onAction: toggleView + }); + } +}); +---- diff --git a/modules/ROOT/partials/plugins/advcode-open-view.adoc b/modules/ROOT/partials/plugins/advcode-open-view.adoc new file mode 100644 index 0000000000..d4e899a68f --- /dev/null +++ b/modules/ROOT/partials/plugins/advcode-open-view.adoc @@ -0,0 +1,14 @@ +== Show view on editor load + +The xref:custom-view.adoc#view_show[`+view_show+`] option can be used to show the {pluginname} view when the editor is loaded. + +.For example: +[source,js] +---- +tinymce.init({ + selector: 'textarea', // change this value according to your HTML + plugins: 'advcode', + toolbar: 'code', + view_show: 'code', +}); +---- diff --git a/modules/ROOT/partials/plugins/revisionhistory-open-view.adoc b/modules/ROOT/partials/plugins/revisionhistory-open-view.adoc new file mode 100644 index 0000000000..98a16364e9 --- /dev/null +++ b/modules/ROOT/partials/plugins/revisionhistory-open-view.adoc @@ -0,0 +1,15 @@ +== Show view on editor load + +The xref:custom-view.adoc#view_show[`+view_show+`] option can be used to show the {pluginname} view when the editor is loaded. + +.For example: +[source,js] +---- +tinymce.init({ + selector: 'textarea', // change this value according to your HTML + plugins: 'revisionhistory', + toolbar: 'revisionhistory', + view_show: 'revision', + revisionhistory_fetch: () => Promise.resolve([]), // Replace with API request to get saved revisions +}); +---- diff --git a/modules/ROOT/partials/plugins/suggestededits-open-view.adoc b/modules/ROOT/partials/plugins/suggestededits-open-view.adoc new file mode 100644 index 0000000000..1885c66f11 --- /dev/null +++ b/modules/ROOT/partials/plugins/suggestededits-open-view.adoc @@ -0,0 +1,15 @@ +== Show view on editor load + +The xref:custom-view.adoc#view_show[`+view_show+`] option can be used to show the {pluginname} view when the editor is loaded. + +.For example: +[source,js] +---- +tinymce.init({ + selector: 'textarea', // change this value according to your HTML + plugins: 'suggestededits', + toolbar: 'suggestededits', + view_show: 'suggestededits', + // ... other Suggested Edits options (e.g. suggestededits_model, user_id, fetch_users) +}); +----