Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions modules/ROOT/examples/live-demos/custom-view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ tinymce.init({
],
onShow: (api) => {
const editorContent = ed.getContent();
api.getContainer().innerHTML = `
const container = api.getContainer();
container.innerHTML = `
<div style="height: 100%">
<textarea class="tox-view__pane_panel" style="width: 100%; height: 100%; resize: none; padding: 0.5em">
${editorContent}
</textarea>
</div>`.replace(/\s+/g, '');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
</div>`.replace(/\s+/g, '');
<textarea class="my-textarea" style="width: 100%; height: 100%; resize: none; padding: 0.5em"></textarea>
</div>`;
container.querySelector('.my-textarea').value = editorContent;

<textarea class="tox-view__pane_panel" style="width: 100%; height: 100%; resize: none; padding: 0.5em"></textarea>
</div>`;
container.querySelector('.tox-view__pane_panel').value = editorContent;
},
onHide: (api) => {
console.log('Deactivate code', api.getContainer());
Expand Down
7 changes: 7 additions & 0 deletions modules/ROOT/pages/8.4.0-release-notes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Since this is a new feature, we don't need to describe the previous behaviour.


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
Expand Down
2 changes: 2 additions & 0 deletions modules/ROOT/pages/advcode.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down
4 changes: 4 additions & 0 deletions modules/ROOT/pages/custom-view.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions modules/ROOT/pages/revisionhistory.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down
2 changes: 2 additions & 0 deletions modules/ROOT/pages/suggestededits.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
61 changes: 61 additions & 0 deletions modules/ROOT/partials/configuration/view_show.adoc
Original file line number Diff line number Diff line change
@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
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.


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 = '<p>You opened the view!</p>';
},
onHide: (api) => {
api.getContainer().innerHTML = '';
},
buttons: [{
type: 'button',
text: 'Close',
onAction: toggleView
}]
});
editor.ui.registry.addButton('view', {
text: 'Open view',
onAction: toggleView
});
}
});
----
14 changes: 14 additions & 0 deletions modules/ROOT/partials/plugins/advcode-open-view.adoc
Original file line number Diff line number Diff line change
@@ -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',
});
----
15 changes: 15 additions & 0 deletions modules/ROOT/partials/plugins/revisionhistory-open-view.adoc
Original file line number Diff line number Diff line change
@@ -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
});
----
15 changes: 15 additions & 0 deletions modules/ROOT/partials/plugins/suggestededits-open-view.adoc
Original file line number Diff line number Diff line change
@@ -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)
});
----
Loading