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
1 change: 1 addition & 0 deletions modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
*** xref:annotations.adoc[Using the Annotations API]
** Bundling {productname}
*** xref:introduction-to-bundling-tinymce.adoc[Introduction]
*** xref:bundling-guide.adoc[Bundling overview]
*** Webpack
**** xref:webpack-es6-npm.adoc[ES6 and npm]
**** xref:webpack-cjs-npm.adoc[CommonJS and npm]
Expand Down
3 changes: 3 additions & 0 deletions modules/ROOT/pages/a11ychecker.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ tinymce.init({
});
----

include::partial$misc/bundling-guide-link.adoc[]


[[accessibility-rules]]
== Accessibility Rules

Expand Down
2 changes: 2 additions & 0 deletions modules/ROOT/pages/accordion.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ tinymce.init({
});
----

include::partial$misc/bundling-guide-link.adoc[]

== Options

The following configuration options affect the behavior of the {pluginname} plugin.
Expand Down
3 changes: 3 additions & 0 deletions modules/ROOT/pages/advanced-templates.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ tinymce.init({
});
----

include::partial$misc/bundling-guide-link.adoc[]


NOTE: The undefined options in the above example must be defined. See the xref:options[Options] below for specific details on each function.


Expand Down
3 changes: 3 additions & 0 deletions modules/ROOT/pages/advanced-typography.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ tinymce.init({
});
----

include::partial$misc/bundling-guide-link.adoc[]


== Options

The following configuration options affect the behavior of the {pluginname} plugin.
Expand Down
3 changes: 3 additions & 0 deletions modules/ROOT/pages/advcode.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ tinymce.init({
});
----

include::partial$misc/bundling-guide-link.adoc[]


== Enable full-screen mode

To enable the full-screen mode button in the {pluginname}, configure the plugin to run in inline mode and include the fullscreen plugin:
Expand Down
3 changes: 3 additions & 0 deletions modules/ROOT/pages/advlist.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ tinymce.init({
});
----

include::partial$misc/bundling-guide-link.adoc[]


== Interactive demo

liveDemo::advlist[]
Expand Down
1 change: 1 addition & 0 deletions modules/ROOT/pages/advtable.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ tinymce.init({
});
----

include::partial$misc/bundling-guide-link.adoc[]

== Sorting table rows and columns

Expand Down
3 changes: 3 additions & 0 deletions modules/ROOT/pages/ai.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ tinymce.init({
});
----

include::partial$misc/bundling-guide-link.adoc[]


== Using a proxy server with {pluginname}

NOTE: As per OpenAI’s https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety[best practices for API key safety], deployment of an API key in a client-side environment is specifically not recommended.
Expand Down
2 changes: 2 additions & 0 deletions modules/ROOT/pages/anchor.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ tinymce.init({
});
----

include::partial$misc/bundling-guide-link.adoc[]

== Options

include::partial$configuration/allow_html_in_named_anchor.adoc[leveloffset=+1]
Expand Down
2 changes: 2 additions & 0 deletions modules/ROOT/pages/autocorrect.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ tinymce.init({
});
----

include::partial$misc/bundling-guide-link.adoc[]

[[usage-notes]]
== Usage notes

Expand Down
3 changes: 3 additions & 0 deletions modules/ROOT/pages/autolink.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ tinymce.init({
});
----

include::partial$misc/bundling-guide-link.adoc[]


== Options

include::partial$configuration/link_default_target.adoc[leveloffset=+1]
Expand Down
3 changes: 3 additions & 0 deletions modules/ROOT/pages/autoresize.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ tinymce.init({
});
----

include::partial$misc/bundling-guide-link.adoc[]


== How it works

The Autoresize plugin monitors content changes and automatically adjusts the editor height to accommodate the content. When enabled:
Expand Down
3 changes: 3 additions & 0 deletions modules/ROOT/pages/autosave.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ tinymce.init({
});
----

include::partial$misc/bundling-guide-link.adoc[]


== Options

These settings affect the execution of the `+autosave+` plugin. The settings described here will affect the interval, duration and behavior of locally stored drafts of the current editor instance.
Expand Down
179 changes: 179 additions & 0 deletions modules/ROOT/pages/bundling-guide.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
= Bundling {productname} - Overview
:navtitle: Bundling overview
:description_short: Overview of bundling TinyMCE with module bundlers
:description: Overview of bundling TinyMCE with module bundlers including required imports, plugins, and resources
:keywords: bundling, webpack, vite, rollup, modules, imports, es6, commonjs

This guide provides an overview of bundling {productname} with module bundlers such as Webpack, Vite, Rollup, or Browserify. For bundler-specific setup instructions, see xref:introduction-to-bundling-tinymce.adoc[Introduction to bundling {productname}].

[NOTE]
====
When using TinyMCE Cloud, dependencies and additional resources are automatically loaded. The information below applies to self-hosted installations using NPM or ZIP packages.
====

== Module syntax support

{productname} supports both ES6 modules and CommonJS modules:

* **ES6 modules**: Use `+import+` statements (shown in all documentation examples)
* **CommonJS modules**: Use `+require()+` statements

Both syntaxes are supported, but this documentation uses ES6 module syntax in all examples.

== Required imports

include::partial$module-loading/bundling-required-components.adoc[]

=== Example: Basic required imports

[source,js]
----
/* Import TinyMCE */
import tinymce from 'tinymce';

/* Default icons are required */
import 'tinymce/icons/default';

/* Required TinyMCE components */
import 'tinymce/themes/silver';
import 'tinymce/models/dom';

/* Import a skin (oxide is the default) */
import 'tinymce/skins/ui/oxide/skin.js';
import 'tinymce/skins/ui/oxide/content.js';

/* Content CSS for editor content styling */
import 'tinymce/skins/content/default/content.js';
----

For more information on:

* Icons, see xref:bundling-icons.adoc[Bundling icons]
* Themes, see xref:bundling-themes.adoc[Bundling themes]
* Models, see xref:bundling-models.adoc[Bundling models]
* Skins, see xref:bundling-skins.adoc[Bundling skins]

Choose a reason for hiding this comment

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

The page for Bundling skin mainly references CSS files. @metricjs I think for guides like Webpack and Browserify that already have ways to import CSS files, it may be worth keeping those examples around. We could consider adding a note that importing the js file is another way to get the CSS, but it seems safest not to remove those CSS examples when we start tackling those specific pages.

* Content CSS, see xref:bundling-content-css.adoc[Bundling content CSS]

== Importing plugins

Most plugins can be imported directly using their plugin code. The import path depends on whether the plugin is a community or premium plugin:

=== Community plugins

[source,js]
----
import 'tinymce/plugins/<plugincode>';
----

=== Premium plugins

[source,js]
----
import 'tinymce-premium/plugins/<plugincode>';
----

[IMPORTANT]
====
When using premium plugins with a commercial license, you must include the `+licensekeymanager+` plugin:

[source,js]
----
import 'tinymce-premium/plugins/licensekeymanager';
----

For more information, see xref:bundling-plugins.adoc#using-premium-plugins[Using premium plugins].
====

For detailed information on bundling plugins, see xref:bundling-plugins.adoc[Bundling plugins].

== Plugin gotchas

Some plugins require additional resource files (JS, CSS, or language files) to function properly. These must be explicitly imported when bundling:
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
Some plugins require additional resource files (JS, CSS, or language files) to function properly. These must be explicitly imported when bundling:
Some plugins require additional resource files (JS, CSS, or language files) to function properly. These must be explicitly imported when bundling.

?


[IMPORTANT]
====
Key points about plugin resources:

* Core plugin resources typically use relative paths without file extensions
* Premium plugin resources (from `+tinymce-premium+`) MUST include the `.js` or `.css` file extension in the import path
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't see this noted in Sorita's notes and wasn't aware it was a thing - sanity checking where this comes from?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, was this from her examples for the lang files?

Choose a reason for hiding this comment

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

I think we may not need to include this. An integrator could follow their own import styles, so long as their bundler is configured properly to resolve the file extensions. The choices in the example code were mainly to ensure it would work for the majority out of the box.

* Plugins lazy-load additional resources at runtime, so these files must be included in the bundle or accessible as static assets
Copy link
Contributor

Choose a reason for hiding this comment

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

"Some plugins" or "plugins may" - to not cause panic that every plugin pulls in more resources?

====

=== Plugins requiring additional resources

* **Emoticons**: Requires an emoji database file (`+js/emojis+`)

Choose a reason for hiding this comment

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

Suggested change
* **Emoticons**: Requires an emoji database file (`+js/emojis+`)
* **Emoticons**: Requires an emoji database file (`+js/emojis.js+`)

* **Help**: Requires a keyboard navigation language file (`+js/i18n/keynav/<lang>+`)

Choose a reason for hiding this comment

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

Suggested change
* **Help**: Requires a keyboard navigation language file (`+js/i18n/keynav/<lang>+`)
* **Help**: Requires a keyboard navigation language file (`+js/i18n/keynav/<lang>.js+`)

* **Page Embed**: Requires a CSS file (`+css/empa30.css+`)

Choose a reason for hiding this comment

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

From my testing, this import is not necessary. Was there an issue reported on page embed that required this import?

* **Autocorrect**: Requires a word list file (`+js/en.js+`)
* **Uploadcare**: Requires a webcomponent file (`+js/uc-video.js+`)

For specific import examples, see xref:bundling-plugins.adoc#plugin-resources[Additional plugin resources].

=== Plugin dependencies

Some plugins depend on other plugins. For example:

* The `+advtable+` plugin requires the `+table+` plugin

Always import dependent plugins before the plugin that requires them.

== CSS files

Plugin CSS files are typically included automatically when importing plugins. However, some plugins may require explicit CSS imports for proper styling.
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
Plugin CSS files are typically included automatically when importing plugins. However, some plugins may require explicit CSS imports for proper styling.
Some plugins require additional CSS files. Plugin CSS files are included automatically when importing plugins via their JS file.

or something? from what Sorita said, should never need to pull in a CSS file manually

Choose a reason for hiding this comment

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

Currently, there aren't any plugins that require a CSS import, and if it does, then it would likely require a fix - as in the case for Uploadcare.


When using skins, you must import both:

* The skin CSS file (`+skin.css+` or `+skin.js+`)
* The content UI CSS file (`+content.css+` or `+content.js+`)

For more information, see xref:bundling-skins.adoc[Bundling skins].

== Language files

Language files are optional and used for localizing the {productname} UI and plugin interfaces.

=== Core UI language files

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
For community packages:

[source,js]
----
import 'tinymce/langs/<language>.js';
----

For premium packages:

[source,js]
----
import 'tinymce-premium/langs/<language>.js';
----

=== Plugin language files

Plugin language files are separate from the main UI language files:

Choose a reason for hiding this comment

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

I think we should also note that the editor's language option must first be set to the desired language for the plugin's language file to take effect.


[source,js]
----
// Community plugin language file
import 'tinymce/plugins/<plugincode>/langs/<language>.js';

// Premium plugin language file (note: .js extension required)

Choose a reason for hiding this comment

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

Suggested change
// Premium plugin language file (note: .js extension required)
// Premium plugin language file

We can remove this

import 'tinymce-premium/plugins/<plugincode>/langs/<language>.js';
----

[NOTE]
====
* English is the default language, so `+en.js+` language files don't exist

Choose a reason for hiding this comment

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

Maybe worth specifying it's US English? https://www.tiny.cloud/docs/tinymce/latest/ui-localization/#language. Perhaps also mentioning language packs for extra clarity, as help and autocorrect plugins have an en.js file.

Suggested change
* English is the default language, so `+en.js+` language files don't exist
* US English is the default language, so the language packs do not include `+en.js+` language files

* For premium plugins, the language file path must include the `.js` extension
Copy link
Contributor

Choose a reason for hiding this comment

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

From the examples here, it looks like the .js is always required, whether premium or community? @soritaheng any thoughts?

Choose a reason for hiding this comment

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

Most bundlers support resolving file extensions, so they are not necessarily required. For example, in Vite. Since the order of the resolution could be configured, I went with the extensions in the examples for clarity's sake. But let me know if that should be reconsidered.

====

For more information, see xref:bundling-localization.adoc[UI localizations].

== Next steps

* xref:introduction-to-bundling-tinymce.adoc[Introduction to bundling {productname}] - Bundler-specific guides
* xref:bundling-themes.adoc[Bundling themes] - Theme configuration and customization
* xref:bundling-models.adoc[Bundling models] - Model configuration
* xref:bundling-plugins.adoc[Bundling plugins] - Detailed plugin bundling information
* xref:bundling-skins.adoc[Bundling skins] - Skin configuration and customization
* xref:bundling-icons.adoc[Bundling icons] - Icon pack configuration
* xref:bundling-content-css.adoc[Content CSS] - Content styling configuration
* xref:bundling-localization.adoc[UI localizations] - Language file configuration
2 changes: 2 additions & 0 deletions modules/ROOT/pages/casechange.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ liveDemo::casechange[]

// include::partial$misc/purchase-premium-plugins.adoc[]

include::partial$misc/bundling-guide-link.adoc[]

== Changing the case of selected text

Perform the following steps to change the case of selected text in a document to lowercase, UPPERCASE, or Title Case:
Expand Down
3 changes: 3 additions & 0 deletions modules/ROOT/pages/charmap.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ tinymce.init({
});
----

include::partial$misc/bundling-guide-link.adoc[]


== Options

The default map of unicode characters can be overridden or extended through the options below.
Expand Down
3 changes: 3 additions & 0 deletions modules/ROOT/pages/checklist.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ tinymce.init({
});
----

include::partial$misc/bundling-guide-link.adoc[]


NOTE: The *Checklist* plugin has to be used together with the xref:lists.adoc[Lists] plugin to work.

== CSS
Expand Down
2 changes: 2 additions & 0 deletions modules/ROOT/pages/code.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ tinymce.init({
});
----

include::partial$misc/bundling-guide-link.adoc[]

include::partial$misc/code-dialog-and-selection-state.adoc[]

include::partial$misc/plugin-toolbar-button-id-boilerplate.adoc[]
Expand Down
3 changes: 3 additions & 0 deletions modules/ROOT/pages/codesample.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ tinymce.init({
});
----

include::partial$misc/bundling-guide-link.adoc[]


By default, `+codesample+` uses `+http://prismjs.com/+` to embed the code samples within the editor and works out of the box. That is, when a user copies valid code syntax into the editable area the code will be automatically formatted according to Prism default CSS rules.

NOTE: Prism.js and prism.css need to be added to a page for syntax highlighting to work. See the instructions below to learn how to do this.
Expand Down
3 changes: 3 additions & 0 deletions modules/ROOT/pages/directionality.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ tinymce.init({
});
----

include::partial$misc/bundling-guide-link.adoc[]


include::partial$misc/plugin-toolbar-button-id-boilerplate.adoc[]

== Commands
Expand Down
3 changes: 3 additions & 0 deletions modules/ROOT/pages/editimage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ tinymce.init({
});
----

include::partial$misc/bundling-guide-link.adoc[]


== Self-hosted Installation

To enable the {productname} Image Editing plugin:
Expand Down
2 changes: 2 additions & 0 deletions modules/ROOT/pages/emoticons.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ tinymce.init({
});
----

include::partial$misc/bundling-guide-link.adoc[]

== Browser emoji support

By default, the emoticon plugin inserts Unicode character codes, such as `+\ud83d\ude03+` for the smiley emoji. How emoji are rendered is dependent on the web browser and operating system of the user. As a result of this, some emoji may be rendered in black and white, or may not render. To ensure emoji render consistently across browsers and operating systems, {companyname} recommends adding an emoji-compatible web font to the default font-family using xref:add-css-options.adoc#content_css[`+content_css+`].
Expand Down
3 changes: 3 additions & 0 deletions modules/ROOT/pages/exportpdf.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ tinymce.init({
});
----

include::partial$misc/bundling-guide-link.adoc[]


For more infomation on the exportpdf_token_provider option, see xref:exportpdf.adoc#exportpdf-token-provider[exportpdf_token_provider].

include::partial$misc/admon-jwt-authentication-requirements.adoc[]
Expand Down
Loading
Loading