-
Notifications
You must be signed in to change notification settings - Fork 220
TINYDOC-3570: Resizable sidebars documentation (TINYMCE-14486) #4307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kemister85
wants to merge
5
commits into
feature/8.9/TINYDOC-3570
Choose a base branch
from
feature/8.9/TINYDOC-3570_TINYMCE-14528
base: feature/8.9/TINYDOC-3570
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f4f8d44
Docs: TINYDOC-3570 - New options for configuring the width of resizab…
kemister85 3734706
Docs: TINYMCE-14678 - Custom sidebars opt in to resizing with the new…
kemister85 e6e58f0
Docs: TINYMCE-14529 - Add SidebarResizeStart and SidebarResized events
kemister85 ebdd26b
Docs: TINYMCE-14527 - Sidebars can now be resized by dragging their edge
kemister85 70292b7
Docs: TINYMCE-14678 - Use a version admonition for resizable sidebar …
kemister85 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,19 @@ The `+icon+` specifies an icon for the sidebar toggle button. The icon should be | |
|
|
||
| *Type:* `+String+` | ||
|
|
||
| [[resizable]] | ||
| ==== `+resizable+` | ||
|
|
||
| The `+resizable+` specifies whether a user can resize the sidebar by dragging the edge of the sidebar. The default is `+false+`. | ||
|
|
||
| include::partial$misc/admon-requires-8.9v.adoc[] | ||
|
|
||
| When set to `+true+`, {productname} renders a resize handle and controls the width of the sidebar using the xref:customsidebar.adoc#sidebar_width[`+sidebar_width+`], xref:customsidebar.adoc#sidebar_min_width[`+sidebar_min_width+`], and xref:customsidebar.adoc#sidebar_max_width[`+sidebar_max_width+`] options. The content of a sidebar registered with `+resizable+` set to `+true+` needs to follow the width of the parent element. For information, see: xref:customsidebar.adoc#styling-a-resizable-sidebar[Styling a resizable sidebar]. | ||
|
|
||
| When `+resizable+` is omitted or set to `+false+`, {productname} does not render a resize handle, ignores the three sidebar width options, and renders the sidebar at the width defined by the content styles of that sidebar. | ||
|
|
||
| *Type:* `+Boolean+` | ||
|
|
||
| [[onSetup]] | ||
| ==== `+onSetup+` | ||
|
|
||
|
|
@@ -62,10 +75,108 @@ The `+onHide+` specifies a function to be called when the panel is hidden. It pa | |
|
|
||
| The `+element():HTMLElement+` function returns the root element of the sidebar panel. | ||
|
|
||
| [[resizable-sidebars]] | ||
| == Resizable sidebars | ||
|
|
||
| include::partial$misc/admon-requires-8.9v.adoc[] | ||
|
|
||
| A user can resize a sidebar by dragging the edge of the sidebar toward or away from the editable area. {productname} renders a resize handle only for sidebars registered with the xref:customsidebar.adoc#resizable[`+resizable+`] property set to `+true+`. | ||
|
|
||
| The sidebars registered by the xref:introduction-to-tiny-comments.adoc[Comments] and xref:tinymceai.adoc[{productname} AI] plugins are resizable by default. Sidebars registered through `+addSidebar+` are not resizable by default, so a custom sidebar created before {productname} 8.9 renders as it did previously. | ||
|
|
||
| The xref:customsidebar.adoc#sidebar_width[`+sidebar_width+`], xref:customsidebar.adoc#sidebar_min_width[`+sidebar_min_width+`], and xref:customsidebar.adoc#sidebar_max_width[`+sidebar_max_width+`] options apply to every resizable sidebar in an editor. {productname} cannot set a separate width for an individual sidebar. | ||
|
|
||
| [[styling-a-resizable-sidebar]] | ||
| === Styling a resizable sidebar | ||
|
|
||
| The content styles of a sidebar that is not resizable determine how wide the sidebar renders. | ||
|
|
||
| [source,js] | ||
| ---- | ||
| tinymce.init({ | ||
| selector: 'textarea', // change this value according to your HTML | ||
| sidebar_show: 'mysidebar', | ||
| setup: (editor) => { | ||
| editor.ui.registry.addSidebar('mysidebar', { | ||
| tooltip: 'My sidebar', | ||
| icon: 'comment', | ||
| onShow: (api) => { | ||
| const container = document.createElement('div'); | ||
| container.style.width = '600px'; | ||
| api.element().appendChild(container); | ||
| }, | ||
| }); | ||
| } | ||
| }); | ||
| ---- | ||
|
|
||
| {productname} sets the width of a resizable sidebar, so the content styles need to follow the width of the parent element rather than set a width. Set the width of the content to `+100%+` so that the content inherits the width from xref:customsidebar.adoc#element[`+api.element()+`]. | ||
|
|
||
| [source,js] | ||
| ---- | ||
| tinymce.init({ | ||
| selector: 'textarea', // change this value according to your HTML | ||
| sidebar_show: 'mysidebar', | ||
| sidebar_width: 500, | ||
| setup: (editor) => { | ||
| editor.ui.registry.addSidebar('mysidebar', { | ||
| tooltip: 'My sidebar', | ||
| icon: 'comment', | ||
| resizable: true, | ||
| onShow: (api) => { | ||
| const container = document.createElement('div'); | ||
| container.style.width = '100%'; | ||
| api.element().appendChild(container); | ||
| }, | ||
| }); | ||
| } | ||
| }); | ||
| ---- | ||
|
|
||
| IMPORTANT: A sidebar whose content styles set a fixed width does not render correctly when `+resizable+` is set to `+true+`. Update the content styles to `+100%+` before enabling the property. | ||
|
|
||
| [[persisting-the-sidebar-width]] | ||
| === Persisting the sidebar width | ||
|
|
||
| {productname} does not store the width a user drags a sidebar to. To keep a width between editor loads, store the width reported by the xref:events.adoc#editor-core-events[`+SidebarResized+`] event and pass the stored value to xref:customsidebar.adoc#sidebar_width[`+sidebar_width+`] when the editor is next created. | ||
|
|
||
| [source,js] | ||
| ---- | ||
| const storedWidth = window.localStorage.getItem('sidebar-width'); | ||
|
|
||
| tinymce.init({ | ||
| selector: 'textarea', // change this value according to your HTML | ||
| sidebar_show: 'mysidebar', | ||
| sidebar_width: storedWidth ? parseInt(storedWidth, 10) : 440, | ||
| setup: (editor) => { | ||
| editor.ui.registry.addSidebar('mysidebar', { | ||
| tooltip: 'My sidebar', | ||
| icon: 'comment', | ||
| resizable: true, | ||
| onShow: (api) => { | ||
| const container = document.createElement('div'); | ||
| container.style.width = '100%'; | ||
| api.element().appendChild(container); | ||
| }, | ||
| }); | ||
|
|
||
| editor.on('SidebarResized', (e) => { | ||
| window.localStorage.setItem('sidebar-width', e.width); | ||
| }); | ||
| } | ||
| }); | ||
| ---- | ||
|
|
||
| == Options | ||
|
|
||
| include::partial$configuration/sidebar_max_width.adoc[leveloffset=+1] | ||
|
|
||
| include::partial$configuration/sidebar_min_width.adoc[leveloffset=+1] | ||
|
|
||
| include::partial$configuration/sidebar_show.adoc[leveloffset=+1] | ||
|
|
||
| include::partial$configuration/sidebar_width.adoc[leveloffset=+1] | ||
|
|
||
| [[example-inside-the-tinymceinit]] | ||
| == Example inside the tinymce.init | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we update the examples below to include |
||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
modules/ROOT/partials/configuration/sidebar_max_width.adoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| [[sidebar_max_width]] | ||
| == `+sidebar_max_width+` | ||
|
|
||
| This option sets the largest width, in pixels, that a user can drag the sidebar to. | ||
|
|
||
| The option applies only to sidebars registered with the `+resizable+` property set to `+true+`. A user cannot resize a sidebar registered without that property, and {productname} ignores this option. | ||
|
|
||
| This option restricts dragging only. This option does not restrict the width set by xref:customsidebar.adoc#sidebar_width[`+sidebar_width+`], so a sidebar can open wider than the value set here. | ||
|
|
||
| include::partial$misc/admon-iframe-only.adoc[] | ||
|
|
||
| *Type:* `+Number+` | ||
|
|
||
| *Default value:* `+800+` | ||
|
|
||
| === Example: using `+sidebar_max_width+` | ||
|
|
||
| [source,js] | ||
| ---- | ||
| tinymce.init({ | ||
| selector: 'textarea', // change this value according to your HTML | ||
| sidebar_show: 'mysidebar', | ||
| sidebar_max_width: 600, | ||
| setup: (editor) => { | ||
| editor.ui.registry.addSidebar('mysidebar', { | ||
| tooltip: 'My sidebar', | ||
| icon: 'comment', | ||
| resizable: true, | ||
| onShow: (api) => { | ||
| api.element().innerHTML = 'Hello world!'; | ||
| }, | ||
| }); | ||
| } | ||
| }); | ||
| ---- | ||
|
|
||
| === Limitations of the `+sidebar_max_width+` option | ||
|
|
||
| The editable area cannot shrink below 280 pixels, and this limit takes precedence over `+sidebar_max_width+`. For information on this restriction, see: xref:customsidebar.adoc#limitations-of-the-sidebar-width-option[Limitations of the `+sidebar_width+` option]. | ||
|
|
||
| In a narrow editor, the width that remains beside a 280-pixel editable area can be smaller than the value set by `+sidebar_max_width+`. In that case, the remaining width becomes the effective maximum, and a user cannot drag the sidebar beyond that width. |
41 changes: 41 additions & 0 deletions
41
modules/ROOT/partials/configuration/sidebar_min_width.adoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| [[sidebar_min_width]] | ||
| == `+sidebar_min_width+` | ||
|
|
||
| This option sets the smallest width, in pixels, that a user can drag the sidebar to. | ||
|
|
||
| The option applies only to sidebars registered with the `+resizable+` property set to `+true+`. A user cannot resize a sidebar registered without that property, and {productname} ignores this option. | ||
|
|
||
| This option restricts dragging only. This option does not restrict the width set by xref:customsidebar.adoc#sidebar_width[`+sidebar_width+`], so a sidebar can open narrower than the value set here. | ||
|
|
||
| include::partial$misc/admon-iframe-only.adoc[] | ||
|
|
||
| *Type:* `+Number+` | ||
|
|
||
| *Default value:* `+300+` | ||
|
|
||
| === Example: using `+sidebar_min_width+` | ||
|
|
||
| [source,js] | ||
| ---- | ||
| tinymce.init({ | ||
| selector: 'textarea', // change this value according to your HTML | ||
| sidebar_show: 'mysidebar', | ||
| sidebar_min_width: 400, | ||
| setup: (editor) => { | ||
| editor.ui.registry.addSidebar('mysidebar', { | ||
| tooltip: 'My sidebar', | ||
| icon: 'comment', | ||
| resizable: true, | ||
| onShow: (api) => { | ||
| api.element().innerHTML = 'Hello world!'; | ||
| }, | ||
| }); | ||
| } | ||
| }); | ||
| ---- | ||
|
|
||
| === Limitations of the `+sidebar_min_width+` option | ||
|
|
||
| The editable area cannot shrink below 280 pixels, and this limit takes precedence over `+sidebar_min_width+`. For information on this restriction, see: xref:customsidebar.adoc#limitations-of-the-sidebar-width-option[Limitations of the `+sidebar_width+` option]. | ||
|
|
||
| When the editor is too narrow to provide the width set by `+sidebar_min_width+` alongside a 280-pixel editable area, {productname} does not resize the sidebar on drag, and the sidebar keeps the current width. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| [[sidebar_width]] | ||
| == `+sidebar_width+` | ||
|
|
||
| This option sets the width, in pixels, that the sidebar opens at on editor initialization. | ||
|
|
||
| The option applies only to sidebars registered with the `+resizable+` property set to `+true+`. A sidebar registered without that property keeps the width defined by the content styles of that sidebar, and {productname} ignores this option. | ||
|
|
||
| The xref:customsidebar.adoc#sidebar_min_width[`+sidebar_min_width+`] and xref:customsidebar.adoc#sidebar_max_width[`+sidebar_max_width+`] options do not restrict the width set by this option. Those options restrict only the widths a user can drag the sidebar to. The minimum width of the editable area does restrict this width. For information on this restriction, see: xref:customsidebar.adoc#limitations-of-the-sidebar-width-option[Limitations of the `+sidebar_width+` option]. | ||
|
|
||
| include::partial$misc/admon-iframe-only.adoc[] | ||
|
|
||
| *Type:* `+Number+` | ||
|
|
||
| *Default value:* `+440+` | ||
|
|
||
| === Example: using `+sidebar_width+` | ||
|
|
||
| [source,js] | ||
| ---- | ||
| tinymce.init({ | ||
| selector: 'textarea', // change this value according to your HTML | ||
| sidebar_show: 'mysidebar', | ||
| sidebar_width: 500, | ||
| setup: (editor) => { | ||
| editor.ui.registry.addSidebar('mysidebar', { | ||
| tooltip: 'My sidebar', | ||
| icon: 'comment', | ||
| resizable: true, | ||
| onShow: (api) => { | ||
| api.element().innerHTML = 'Hello world!'; | ||
| }, | ||
| }); | ||
| } | ||
| }); | ||
| ---- | ||
|
|
||
| [[limitations-of-the-sidebar-width-option]] | ||
| === Limitations of the `+sidebar_width+` option | ||
|
|
||
| The editable area and the sidebar share the same container. To keep the editable area usable, {productname} does not allow the editable area to shrink below 280 pixels. This limit is fixed and takes precedence over `+sidebar_width+`, xref:customsidebar.adoc#sidebar_min_width[`+sidebar_min_width+`], and xref:customsidebar.adoc#sidebar_max_width[`+sidebar_max_width+`]. | ||
|
|
||
| When the editor is too narrow to provide the requested width alongside a 280-pixel editable area, {productname} reduces the sidebar to the width that remains. For example, in an editor 1000 pixels wide, a `+sidebar_width+` of 2000 results in a sidebar approximately 716 pixels wide, because the editable area reserves 280 pixels and the editor border occupies the remaining pixels. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| NOTE: This feature is only available for {productname} 8.9 and later. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TinyMCEAI plugin had a default sidebar width set to 440px, and after release of resizable sidebars 440px is the new default, so the sidebar is initially the same width.
TinyComments plugin had a default sidebar width set to 300px, and after release of resizable sidebars it's also 440px, so there's a change and TinyComments sidebar is not wider by default.
Should we mention that in the release notes for comments plugin?