-
Notifications
You must be signed in to change notification settings - Fork 221
DOC-3367: Add new bundling guide overview page. #3983
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
base: tinymce/8
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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] | ||||||||||
| * 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: | ||||||||||
|
Contributor
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.
Suggested change
? |
||||||||||
|
|
||||||||||
| [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 | ||||||||||
|
Contributor
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. I can't see this noted in Sorita's notes and wasn't aware it was a thing - sanity checking where this comes from?
Contributor
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. Oh, was this from her examples for the lang files? 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. 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 | ||||||||||
|
Contributor
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. "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+`) | ||||||||||
|
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.
Suggested change
|
||||||||||
| * **Help**: Requires a keyboard navigation language file (`+js/i18n/keynav/<lang>+`) | ||||||||||
|
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.
Suggested change
|
||||||||||
| * **Page Embed**: Requires a CSS file (`+css/empa30.css+`) | ||||||||||
|
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. 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. | ||||||||||
|
Contributor
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.
Suggested change
or something? from what Sorita said, should never need to pull in a CSS file manually 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. 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 | ||||||||||
|
|
||||||||||
|
Contributor
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.
Suggested change
|
||||||||||
| [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: | ||||||||||
|
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. I think we should also note that the editor's |
||||||||||
|
|
||||||||||
| [source,js] | ||||||||||
| ---- | ||||||||||
| // Community plugin language file | ||||||||||
| import 'tinymce/plugins/<plugincode>/langs/<language>.js'; | ||||||||||
|
|
||||||||||
| // Premium plugin language file (note: .js extension required) | ||||||||||
|
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.
Suggested change
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 | ||||||||||
|
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. 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
Suggested change
|
||||||||||
| * For premium plugins, the language file path must include the `.js` extension | ||||||||||
|
Contributor
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. From the examples here, it looks like the .js is always required, whether premium or community? @soritaheng any thoughts? 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. 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 | ||||||||||
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.
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
jsfile is another way to get the CSS, but it seems safest not to remove those CSS examples when we start tackling those specific pages.