Skip to content

Commit 227357b

Browse files
kemister85metricjs
andauthored
DOC-3387: Context7 benchmark improvements bucket (#4066)
* DOC-3388: Add getContent and setContent examples to save-content partial (#4052) Add programmatic get/set content section with runnable examples using editor.getContent(), getContent({ format: 'text' }), and editor.setContent() to address Context7 benchmark Q3 (12/100). * DOC-3389: Strengthen add-css-options page for custom content CSS (#4053) Update description and add keywords for content_css and content_style. Add intro paragraph explaining the two options to address Context7 benchmark Q8 (0/100). * DOC-3390: Add editor.on('change') example to events page (#4054) Add content change callback example using setup option and editor.on('change') to address Context7 benchmark Q4 (30/100). * DOC-3391: Add addButton and addCommand example to creating-a-plugin (#4055) * DOC-3391: Add addButton and addCommand example to creating-a-plugin Add toolbar button section showing PluginManager.add with editor.ui.registry.addButton and editor.addCommand to address Context7 benchmark Q9 (15/100). * Update modules/ROOT/pages/creating-a-plugin.adoc Co-authored-by: Millie <millie.macdonald@tiny.cloud> --------- Co-authored-by: Millie <millie.macdonald@tiny.cloud> * DOC-3392: Add programmatic mode.set example to readonly docs (#4056) Add example showing editor.mode.set('readonly') and editor.mode.set('design') for runtime mode switching to address Context7 benchmark Q7 (25/100). * DOC-3393: Add plugins and toolbar multi-plugin example to quickstart (#4057) Add "Configure plugins and toolbar" section with plugins: 'image code' and toolbar example to the quickstart partial to address Context7 benchmark Q2 (56/100). * DOC-3394: Add content filtering intro to content-filtering page (#4058) Update description and keywords to mention valid_elements, invalid_elements, extended_valid_elements. Add intro paragraph summarizing key filtering options to address Context7 benchmark Q10 (22/100). * DOC-3395: Improve quickstart keywords for selector/ID discoverability (#4059) Add selector, textarea, id, tinymce.init keywords to all quickstart pages (cloud, npm, php, .net, zip) to address Context7 benchmark Q1 (62/100). * DOC-3396: Improve custom-toolbarbuttons and file-image-upload metadata (#4060) Update description and keywords for custom-toolbarbuttons (addButton, custom button), file-image-upload (images_upload_handler), and upload-images pages to address Context7 benchmark Q5/Q6 (25/100 each). --------- Co-authored-by: Millie <millie.macdonald@tiny.cloud>
1 parent 93fa9b1 commit 227357b

15 files changed

Lines changed: 142 additions & 16 deletions

modules/ROOT/pages/add-css-options.adoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
= Adding or changing the editor content CSS
22
:navtitle: Add CSS
3-
:description: Options for changing the editor content CSS.
3+
:description: Apply custom CSS to the editor content area using content_css and content_style. Control typography, colors, margins, and layout in the editable region.
4+
:keywords: content_css, content_style, custom CSS, content area, stylesheet, editor styling
5+
6+
Use `+content_css+` to load external stylesheets into the editable area, or `+content_style+` to inject inline CSS. Both options apply only to the editor content (the iframe body in classic mode), not the surrounding UI.
47

58
== Add CSS and styles to the editor
69

modules/ROOT/pages/cloud-quick-start.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
= Quick start: {productname} from {cloudname}
22
:navtitle: Quick start: Cloud
33
:description_short: Setup a basic {productname} {productmajorversion} editor using the {cloudname}.
4-
:description: Get an instance of {productname} {productmajorversion} up and running using the {cloudname}.
5-
:keywords: tinymce, script, textarea
4+
:description: Get an instance of {productname} {productmajorversion} up and running using the {cloudname}. Initialize the editor on a textarea element using its ID with tinymce.init and the selector option.
5+
:keywords: tinymce, script, textarea, selector, id, #mytextarea, tinymce.init, initialize, quick start
66
:productSource: cloud
77

88

modules/ROOT/pages/content-filtering.adoc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
= Content filtering options
22
:navtitle: Content filtering
3-
:description_short: Learn how to create clean, maintainable and readable content.
4-
:description: These settings change the way the editor handles the input and output of content. This will help you to create clean, maintainable and readable content.
3+
:description_short: Control which HTML elements and attributes are allowed or removed using valid_elements, invalid_elements, and extended_valid_elements.
4+
:description: Configure content filtering and sanitization using valid_elements, invalid_elements, extended_valid_elements, and paste hooks. Control which HTML elements and attributes {productname} allows or removes when content is inserted or pasted.
5+
:keywords: valid_elements, invalid_elements, extended_valid_elements, allow_html_in_named_anchor, content filtering, sanitization, HTML elements, paste_preprocess, paste_postprocess
6+
7+
Use `+valid_elements+` to define which elements and attributes are allowed, `+invalid_elements+` to block specific elements, and `+extended_valid_elements+` to add or modify rules. For paste-time filtering, use the `+PastePreProcess+` and `+PastePostProcess+` events or the xref:introduction-to-powerpaste.adoc[PowerPaste] plugin options.
58

69
include::partial$configuration/allow_conditional_comments.adoc[]
710

modules/ROOT/pages/creating-a-plugin.adoc

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
= Create a plugin for {productname}
22
:navtitle: Create a plugin
33
:description_short: Introducing plugin creation, with an example.
4-
:description: A short introduction to creating plugins for TinyMCE along with an example plugin.
5-
:keywords: plugin, plugin.js, plugin.min.js, tinymce.js
4+
:description: Create custom TinyMCE plugins using PluginManager.add, and expand their functionality with custom toolbar buttons using editor.ui.registry.addButton, custom commands using editor.addCommand, and more.
5+
:keywords: plugin, plugin.js, plugin.min.js, tinymce.js, PluginManager, addButton, addCommand, custom plugin, toolbar button
66

77
{productname} is designed to be easily extended by custom plugins; with APIs for registering custom plugins, and creating and localizing custom UI.
88

@@ -45,6 +45,47 @@ tinymce.PluginManager.add('pluginId', (editor, url) => {
4545
});
4646
----
4747

48+
== Adding a toolbar button to a custom plugin
49+
50+
Use `+editor.ui.registry.addButton+` to add a toolbar button and `+editor.addCommand+` to define the action. Register both inside the plugin callback passed to `+PluginManager.add()+`:
51+
52+
[source,js]
53+
----
54+
tinymce.PluginManager.add('myplugin', (editor, url) => {
55+
editor.addCommand('myCommand', () => {
56+
editor.insertContent('&nbsp;<strong>Inserted content</strong>&nbsp;');
57+
});
58+
59+
editor.ui.registry.addButton('mybutton', {
60+
text: 'My Button',
61+
onAction: () => editor.execCommand('myCommand')
62+
});
63+
64+
return {
65+
getMetadata: () => ({
66+
name: 'My plugin',
67+
url: 'https://example.com/docs'
68+
})
69+
};
70+
});
71+
----
72+
73+
Then include the plugin and button in the editor configuration:
74+
75+
[source,js]
76+
----
77+
tinymce.init({
78+
selector: 'textarea',
79+
plugins: 'myplugin',
80+
toolbar: 'mybutton',
81+
external_plugins: {
82+
myplugin: '/path/to/myplugin.js'
83+
}
84+
});
85+
----
86+
87+
For more toolbar button types, see xref:custom-toolbarbuttons.adoc[Toolbar buttons].
88+
4889
== Using custom plugins with {productname}
4990

5091
Custom plugins can be added to a {productname} instance by either:

modules/ROOT/pages/custom-toolbarbuttons.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
= Toolbar buttons
22
:navtitle: Toolbar buttons
3-
:description: Add a custom buttons to the {productname} {productmajorversion} toolbar.
4-
:keywords: toolbar, toolbarbuttons, buttons, toolbarbuttonsapi
3+
:description: Add custom toolbar buttons using editor.ui.registry.addButton and the setup callback. Create buttons that trigger commands or custom actions.
4+
:keywords: toolbar, toolbarbuttons, buttons, toolbarbuttonsapi, custom button, addButton, editor.ui.registry, setup callback, onAction
55

66
== Use cases
77

modules/ROOT/pages/dotnet-projects.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
= Installing {productname} for .NET
22
:navtitle: .NET projects
33
:description: Learn how to install {productname} from NuGet.
4-
:keywords: nuget .net install
4+
:keywords: nuget, .net, install, selector, textarea, id, tinymce.init
55

66
== Install {productname} using NuGet
77

modules/ROOT/pages/events.adoc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,24 @@ tinymce.init({
9797
});
9898
----
9999

100+
=== Example: content change callback
101+
102+
To run a callback when the editor content changes, use the `+Change+` event with `+editor.on()+` inside the `+setup+` option:
103+
104+
[source,js]
105+
----
106+
tinymce.init({
107+
selector: 'textarea',
108+
setup: (editor) => {
109+
editor.on('change', () => {
110+
console.log('Content was modified.');
111+
});
112+
}
113+
});
114+
----
115+
116+
The `+Change+` event fires when content changes are committed, such as when moving focus away from the editor. For real-time updates as the user types, use the `+input+` event instead.
117+
100118
[[browser-native-events]]
101119
== Supported browser-native events
102120

modules/ROOT/pages/file-image-upload.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
= Image and file options
22
:navtitle: Images and files
3-
:description: These settings affect TinyMCE's image and file handling capabilities.
3+
:description: Configure image uploads to a server using images_upload_handler or images_upload_url. Handle file uploads with custom logic or a server endpoint.
4+
:keywords: images_upload_handler, images_upload_url, image upload, server, upload handler, file picker, images_file_types
45

56
== Controlling or adjusting allowed image and file formats
67

modules/ROOT/pages/npm-projects.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
= Quick start: {productname} from NPM or Yarn
22
:navtitle: Quick start: NPM/Yarn
33
:description: Learn how to install {productname} from NPM using NPM and Yarn, including premium plugins for commercial customers.
4-
:keywords: yarn, npm, javascript, install, premium plugins, tinymce-premium
4+
:keywords: yarn, npm, javascript, install, premium plugins, tinymce-premium, selector, textarea, id, tinymce.init
55

66
== Install {productname} using NPM or Yarn
77

modules/ROOT/pages/php-projects.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
= Installing {productname} with Composer
22
:navtitle: PHP projects
33
:description: Learn how to install {productname} from Packagist using Composer.
4-
:keywords: php, composer, packagist, install
4+
:keywords: php, composer, packagist, install, selector, textarea, id, tinymce.init
55

66
== Install {productname} using the Composer package manager
77

0 commit comments

Comments
 (0)