Skip to content

Commit af92bf5

Browse files
DOC-2689: Documentation enhancements for autoresize plugin in v8 docs. (#3831)
* DOC-2689: Documentation enhancements for autoresize plugin. * Update modules/ROOT/pages/autoresize.adoc Co-authored-by: Mitchell Crompton <[email protected]> * Update modules/ROOT/pages/autoresize.adoc Co-authored-by: Mitchell Crompton <[email protected]> --------- Co-authored-by: Mitchell Crompton <[email protected]>
1 parent 06e26ff commit af92bf5

File tree

8 files changed

+98
-21
lines changed

8 files changed

+98
-21
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<div id="container">
2+
<textarea id="autoresize">
3+
<h1>Autoresize Plugin Demo</h1>
4+
<p>This demo shows the autoresize plugin in action. The editor automatically adjusts its height based on content. Try adding or removing content to see the dynamic resizing behavior.</p>
5+
<div>
6+
<div><strong>How it works:</strong></div>
7+
<ul>
8+
<li>Type or paste content to see the editor expand</li>
9+
<li>Delete content to see the editor shrink</li>
10+
<li>The editor respects min/max height set limits</li>
11+
</ul>
12+
</div>
13+
</textarea>
14+
</div>
15+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
tinymce.init({
2+
selector: 'textarea#autoresize',
3+
plugins: "autoresize lists code",
4+
toolbar: 'undo redo | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent',
5+
// Autoresize options
6+
min_height: 100,
7+
max_height: 400,
8+
autoresize_bottom_margin: 20,
9+
autoresize_overflow_padding: 10,
10+
});

modules/ROOT/pages/autoresize.adoc

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
:navtitle: Autoresize
33
:description_short:
44
:description: Automatically resize TinyMCE to fit content.
5-
:keywords: height, width, max_height, min_height, autoresize_overflow_padding, autoresize_overflow_padding
5+
:keywords: height, width, max_height, min_height, autoresize_overflow_padding, autoresize_bottom_margin, resize
66
:pluginname: Autoresize
77
:plugincode: autoresize
88

9-
This plugin automatically resizes the editor to the content inside it. It is typically used to prevent the editor from expanding infinitely as a user types into the editable area. For example, by giving the `+max_height+` option a value the editor will stop resizing when the set value is reached.
9+
The {pluginname} plugin automatically adjusts the editor height to match its content. This creates a more intuitive editing experience where the editor grows and shrinks naturally with content. Setting the `+max_height+` option would allow you to still control when the content would become scrollable.
10+
11+
== Interactive demo
12+
13+
liveDemo::autoresize[]
1014

1115
== Basic setup
1216

@@ -18,9 +22,18 @@ tinymce.init({
1822
});
1923
----
2024

25+
== How it works
26+
27+
The Autoresize plugin monitors content changes and automatically adjusts the editor height to accommodate the content. When enabled:
28+
29+
* The editor initializes and renders based on the minimum height specified by `+min_height+` option.
30+
* As content is added, the editor expands vertically
31+
* The editor stops expanding when it reaches the `+max_height+` limit
32+
* The `+resize+` handle is removed from the editor.
33+
2134
== Options
2235

23-
These settings affect the execution of the Autoresize plugin, including changes to the minimum width, height, bottom margin, and default initialization state.
36+
These settings control the autoresize behavior, including height limits, padding, and margins.
2437

2538
include::partial$configuration/autoresize_bottom_margin.adoc[leveloffset=+1]
2639

@@ -34,4 +47,4 @@ include::partial$configuration/min_height.adoc[leveloffset=+1]
3447

3548
The Autoresize plugin provides the following {productname} command.
3649

37-
include::partial$commands/autoresize-cmds.adoc[]
50+
include::partial$commands/autoresize-cmds.adoc[leveloffset=+1]
Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
[cols="1,3",options="header"]
22
|===
33
|Command |Description
4-
|mceAutoResize |Auto resizes the editor to the contents.
4+
|mceAutoResize |Automatically resizes the editor to fit its current content.
55
|===
66

7-
.Example
7+
== Manual autoresize trigger
8+
9+
The `+mceAutoResize+` command can be used to manually trigger the autoresize functionality. This is useful when:
10+
11+
* Content is dynamically added or removed programmatically
12+
* The editor needs to be resized after external changes
13+
* You want to ensure the editor size matches its content at a specific moment
14+
15+
.Example: triggering autoresize manually
816
[source,js]
917
----
18+
// Resize the active editor
1019
tinymce.activeEditor.execCommand('mceAutoResize');
20+
21+
// Resize a specific editor by ID
22+
tinymce.get('my-editor-id').execCommand('mceAutoResize');
1123
----
24+

modules/ROOT/partials/configuration/autoresize_bottom_margin.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ This option allows you to specify the size of the `+padding+` at the bottom of t
55

66
*Type:* `+Number+`
77

8-
=== Example: using `+autoresize_bottom_margin+`
8+
*Default value:* `+50+`
9+
10+
=== Example: adding bottom margin for better content spacing
911

1012
[source,js]
1113
----
1214
tinymce.init({
1315
selector: 'textarea', // change this value according to your HTML
1416
plugins: 'autoresize',
15-
autoresize_bottom_margin: 50
17+
autoresize_bottom_margin: 60 // 50px is the default value
1618
});
1719
----
1820

19-
As of version 6.3, `autoresize_bottom_margin` must be set to a value below the `+margin-bottom+` property of any content CSS, else it will be ignored and set to `+0+`.
20-
21-
=== Example: setting `+autoresize_bottom_margin+` to zero because `+margin-bottom+` is set elsewhere
21+
=== Example: setting bottom margin to zero
2222

2323
[source,js]
2424
----

modules/ROOT/partials/configuration/autoresize_overflow_padding.adoc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ This option allows you to specify the size of the `+padding+` at the sides of th
55

66
*Type:* `+Number+`
77

8-
=== Example: `+autoresize_overflow_padding+`
8+
*Default value:* `+1+`
9+
10+
=== Example: adding horizontal padding for better content spacing
911

1012
[source,js]
1113
----
@@ -15,3 +17,14 @@ tinymce.init({
1517
autoresize_overflow_padding: 50
1618
});
1719
----
20+
21+
=== Example: setting horizontal padding to zero
22+
23+
[source,js]
24+
----
25+
tinymce.init({
26+
selector: 'textarea', // change this value according to your HTML
27+
plugins: 'autoresize',
28+
autoresize_overflow_padding: 0
29+
});
30+
----

modules/ROOT/partials/configuration/max_height.adoc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[[max_height]]
22
== `+max_height+`
33

4-
The `+max_height+` option has two kinds of behaviors depending on the state of the xref:autoresize.adoc[`+autoresize+`] plugin:
4+
The `+max_height+` option has different behaviors depending on whether the xref:autoresize.adoc[`+autoresize+`] plugin is enabled:
55

6-
* `+autoresize+` OFF (Default): Without the `+autoresize+` plugin, this option sets the maximum height that a user can stretch the entire {productname} interface (by grabbing the draggable area in the bottom right of the editor interface).
7-
* `+autoresize+` ON: With the `+autoresize+` plugin, this option sets the maximum height the editor can automatically expand to.
6+
* **Without `+autoresize+` plugin**: Sets the maximum height that users can manually resize the entire {productname} interface by dragging the resize handle in the bottom-right corner.
7+
* **With `+autoresize+` plugin**: Sets the maximum height the editor can automatically expand to when content is added.
88

99
*Type:* `+Number+`
1010

@@ -25,9 +25,15 @@ ifeval::["{plugincode}" == "autoresize"]
2525
tinymce.init({
2626
selector: 'textarea', // change this value according to your HTML
2727
plugins: 'autoresize',
28-
max_height: 500
28+
max_height: 600
2929
});
3030
----
3131
endif::[]
3232

33-
NOTE: If the xref:editor-size-options.adoc#resize[`+resize+`] option is set to `+false+` the resize handle will be disabled and a user will not be able to resize the editor (by manual dragging). Note that `+resize+` defaults to `+false+` when the `+autoresize+` plugin is enabled.
33+
[NOTE]
34+
====
35+
* If the xref:editor-size-options.adoc#resize[`+resize+`] option is set to `+false+`, the resize handle will be disabled and users cannot manually resize the editor.
36+
* The `+resize+` option defaults to `+false+` when the `+autoresize+` plugin is enabled.
37+
* Values are specified in pixels without units.
38+
* If `+max_height+` is not set when using the `+autoresize+` plugin, the editor will default to the standard `+max_height+` behavior (unlimited height expansion).
39+
====

modules/ROOT/partials/configuration/min_height.adoc

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[[min_height]]
22
== `+min_height+`
33

4-
The *min_height* option has two kinds of behaviors depending on the state of the xref:autoresize.adoc[`+autoresize+`] plugin:
4+
The `+min_height+` option has different behaviors depending on whether the xref:autoresize.adoc[`+autoresize+`] plugin is enabled:
55

6-
* `+autoresize+` OFF (Default): Without the `+autoresize+` plugin, this option sets the minimum height that a user can shrink the entire {productname} interface (by grabbing the draggable area in the bottom right of the editor interface).
7-
* `+autoresize+` ON: With the `+autoresize+` plugin, this option sets the minimum height the editor can automatically shrink to.
6+
* **Without `+autoresize+` plugin**: Sets the minimum height that users can manually shrink the entire {productname} interface by dragging the resize handle in the bottom-right corner.
7+
* **With `+autoresize+` plugin**: Sets the minimum height the editor can automatically shrink to when content is removed.
88

99
*Type:* `+Number+`
1010

@@ -32,4 +32,11 @@ tinymce.init({
3232
----
3333
endif::[]
3434

35-
NOTE: If the xref:editor-size-options.adoc#resize[`+resize+`] option is set to `+false+` the resize handle will be disabled and a user will not be able to resize the editor (by manual dragging). Note that `+resize+` defaults to `+false+` when the `+autoresize+` plugin is enabled.
35+
[NOTE]
36+
====
37+
* If the xref:editor-size-options.adoc#resize[`+resize+`] option is set to `+false+`, the resize handle will be disabled and users cannot manually resize the editor.
38+
* The `+resize+` option defaults to `+false+` when the `+autoresize+` plugin is enabled.
39+
* Values are specified in pixels without units.
40+
* Setting `+min_height+` too low may cause usability issues on mobile devices.
41+
* If `+min_height+` is not set when using the `+autoresize+` plugin, the editor will default to the standard `+min_height+` value of `+100+` pixels.
42+
====

0 commit comments

Comments
 (0)