Skip to content

Commit e9a2ded

Browse files
authored
Merge pull request #38 from tinymce/hotfix/tinymce-8
Update demos to the latest version of TinyMCE
2 parents 75d8ea1 + 608cf6d commit e9a2ded

34 files changed

+528
-1689
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ You can download and run these demos locally. Some demos uses premium plugins so
1717

1818
## License
1919
The files in this repository are licensed under an MIT license.
20-
TinyMCE is licensed under a LGPL or commercial license.
20+
TinyMCE is available under a commercial license and a subset of the features are open source under the GNU General Public License Version 2 or later.

cool-demos/conditional-blocks.html

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,52 +15,61 @@
1515
<meta charset="utf-8">
1616
<title>Conditional blocks</title>
1717
<meta name="viewport" content="width=device-width, initial-scale=1">
18-
<script src="https://cdn.tiny.cloud/1/qagffr3pkuv17a8on1afax661irst1hbr4e6tbv888sz91jc/tinymce/5-dev/tinymce.min.js" referrerpolicy="origin"></script>
18+
<script src="https://cdn.tiny.cloud/1/qagffr3pkuv17a8on1afax661irst1hbr4e6tbv888sz91jc/tinymce/8/tinymce.min.js" referrerpolicy="origin"></script>
1919

2020
<script>
2121
tinymce.init({
2222
selector: '#editor',
2323

2424
// Tip! To make TinyMCE leaner, only include the plugins you actually need.
25-
plugins: 'autoresize advcode link lists noneditable',
25+
plugins: 'autoresize advcode link lists mergetags',
2626

27-
// We have put our custom insert conditional block button last.
28-
toolbar: 'bold italic strikethrough backcolor | bullist numlist link | conditionalblock | code',
27+
// We have put our custom insert conditional block button second to last.
28+
toolbar: 'bold italic strikethrough backcolor | bullist numlist link mergetags | conditionalblock | code',
2929

3030
// "Thin" is a premium icon pack you get wth the cloud essential plan.
3131
// See https://www.tiny.cloud for more details and purchasing options
3232
// You can also create your own icon packs for TinyMCE
33-
// https://www.tiny.cloud/docs/advanced/creating-an-icon-pack/
33+
// https://www.tiny.cloud/docs/tinymce/latest/enhanced-skins-and-icon-packs/
34+
// https://www.tiny.cloud/docs/tinymce/latest/creating-an-icon-pack/
3435
icons: 'thin',
3536

36-
// "Naked" is a premium icon pack you get wth the cloud essential plan
37+
// "Naked" is a premium icon pack you get with the cloud essential plan
3738
// See https://www.tiny.cloud for more details and purchasing options
3839
// You can also create your own skins for TinyMCE
39-
// https://www.tiny.cloud/docs/advanced/creating-a-skin/
40+
// https://www.tiny.cloud/docs/tinymce/latest/creating-a-skin/
4041
skin: 'naked',
4142

4243
// If we don't need the menubar we can hide it
43-
// https://www.tiny.cloud/docs/configure/editor-appearance/#menubar
44+
// https://www.tiny.cloud/docs/tinymce/latest/menus-configuration-options/#menubar
4445
menubar: false,
4546

47+
// Easily configure replacement values using merge tags plugin
48+
// https://www.tiny.cloud/docs/tinymce/latest/mergetags/
49+
mergetags_list: [
50+
{ title: "first_name", value: "first_name" },
51+
{ title: "number_of_people", value: "number_of_people" },
52+
{ title: "agent_first_name", value: "agent_first_name" },
53+
],
54+
4655
// Tell TinyMCE that conditional-block is a valid element.
47-
// https://www.tiny.cloud/docs/configure/content-filtering/#custom_elements
56+
// https://www.tiny.cloud/docs/tinymce/latest/content-filtering/#custom_elements
4857
custom_elements: 'conditional-block',
4958

5059
setup: (editor) => {
5160
// Instead of defining a custom icon pack, we can register individual
5261
// icons using the API.
53-
// https://www.tiny.cloud/docs/api/tinymce.editor.ui/tinymce.editor.ui.registry/#addicon
62+
// https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.editor.ui.registry/#addicon
5463
editor.ui.registry.addIcon('conditional-block', '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path d="M19 4a2 2 0 1 1-1.854 2.751L15 6.75c-1.239 0-1.85.61-2.586 2.31l-.3.724c-.42 1.014-.795 1.738-1.246 2.217.406.43.751 1.06 1.12 1.92l.426 1.018c.704 1.626 1.294 2.256 2.428 2.307l.158.004h2.145a2 2 0 1 1 0 1.501L15 18.75l-.219-.004c-1.863-.072-2.821-1.086-3.742-3.208l-.49-1.17c-.513-1.163-.87-1.57-1.44-1.614L9 12.75l-2.146.001a2 2 0 1 1 0-1.501H9c.636 0 1.004-.383 1.548-1.619l.385-.92c.955-2.291 1.913-3.382 3.848-3.457L15 5.25h2.145A2 2 0 0 1 19 4z" fill-rule="evenodd"/></svg>');
5564

5665
// The preinit event is fired after the editor is loaded but before
5766
// the content is loaded
58-
// https://www.tiny.cloud/docs/advanced/events/#editorcoreevents
67+
// https://www.tiny.cloud/docs/tinymce/latest/events/
5968
editor.on('PreInit', () => {
6069
// Get the iframe window object and the iframes document object
6170
// and call our setup function that creates the web component
62-
// https://www.tiny.cloud/docs/api/tinymce/tinymce.editor/#getwin
63-
// https://www.tiny.cloud/docs/api/tinymce/tinymce.editor/#getdoc
71+
// https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.editor/#getWin
72+
// https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.editor/#getDoc
6473
const win = editor.getWin();
6574
const doc = editor.getDoc();
6675
setupWebComponent(win, doc, editor);
@@ -69,9 +78,9 @@
6978
// on the web component to make it behave like a noneditable but selectable
7079
// element inside TinyMCE. But we don't want the contenteditable attribute
7180
// to be saved with the content. We therefore need to filter out the attribute
72-
// upon serlialization (which happens on "save", view sourcecode and preview
81+
// upon serialization (which happens on "save", view source code and preview
7382
// among others).
74-
// https://www.tiny.cloud/docs/api/tinymce.dom/tinymce.dom.serializer/#addnodefilter
83+
// https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.dom.serializer/#addNodeFilter
7584
editor.serializer.addNodeFilter('conditional-block', (nodes) => {
7685
// Iterate through all filtered nodes and remove the contenteditable attribute
7786
// as well as the wrapper <div> we add when creating the custom element
@@ -81,15 +90,15 @@
8190
node.attr('contenteditable', null);
8291
// Traverse into the first child which would be the <div contenteditable="true">
8392
// and use unwrap to remove the <div> but keep the children.
84-
// https://www.tiny.cloud/docs/api/tinymce.html/tinymce.html.node/#unwrap
93+
// https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.html.node/#unwrap
8594
node.firstChild.unwrap();
8695
}
8796
});
8897
});
8998
});
9099

91100
// Register a custom toolbar menu button to insert the conditional block
92-
// https://www.tiny.cloud/docs/ui-components/typesoftoolbarbuttons/#menubutton
101+
// https://www.tiny.cloud/docs/tinymce/latest/custom-menu-toolbar-button/
93102
editor.ui.registry.addButton('conditionalblock', {
94103
icon: 'conditional-block',
95104
tooltip: 'Insert conditional block',
@@ -104,8 +113,8 @@
104113
// In a real world scenario, with much more custom styles for headings
105114
// links, tables, images etc, it's recommended to use the content_css
106115
// option to load a separate CSS file. Makes editing easier too.
107-
// https://www.tiny.cloud/docs/configure/content-appearance/#content_style
108-
// https://www.tiny.cloud/docs/configure/content-appearance/#content_css
116+
// https://www.tiny.cloud/docs/tinymce/latest/add-css-options/#content_style
117+
// https://www.tiny.cloud/docs/tinymce/latest/add-css-options/#content_css
109118
content_style: `
110119
/* We remove the default selected outline because it doesn't follow the
111120
* border radius and reintroduce it as a box-shadow.
@@ -307,8 +316,7 @@
307316
const dialogManager = (conditionalBlock, editor) => {
308317
// Open a TinyMCE modal where the user can set the badge's
309318
// background and text color.
310-
// https://www.tiny.cloud/docs/ui-components/dialog/
311-
// https://www.tiny.cloud/docs/ui-components/dialogcomponents/
319+
// https://www.tiny.cloud/docs/tinymce/latest/dialog/
312320
editor.windowManager.open({
313321
title: 'Insert/edit Conditional block',
314322
body: {
@@ -368,13 +376,13 @@
368376
// Check if a block is edited or a new block is to be inserted
369377
if (!conditionalBlock) {
370378
// Insert content at the location of the cursor.
371-
// https://www.tiny.cloud/docs/api/tinymce/tinymce.editor/#insertcontent
379+
// https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.editor/#insertContent
372380
editor.insertContent(`<conditional-block data-property="${data.property}" data-operator="${data.operator}" data-value="${data.value}"><p>Write conditional text here</p></conditional-block>`);
373381
}
374382
else {
375383
// Working directly with the DOM often requires manually adding
376384
// the actions to the undo stack.
377-
// https://www.tiny.cloud/docs/api/tinymce/tinymce.undomanager/
385+
// https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.undomanager/
378386
editor.undoManager.transact(() => {
379387
// Update the data-attributes on the conditional-block element
380388
conditionalBlock.dataset.property = data.property;
@@ -383,7 +391,7 @@
383391
});
384392

385393
// Tell TinyMCE that the ui has been updated.
386-
// https://www.tiny.cloud/docs/api/tinymce/tinymce.editor/#nodechanged
394+
// https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.editor/#nodeChanged
387395
editor.nodeChanged();
388396
}
389397

cool-demos/expand-editor-and-show-toolbar.html

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
2-
This demo showcases a minimalist editor that expands on focus
2+
This demo showcases a minimalist editor that expands on focus.
33
It uses the TinyMCE inline mode to allow for greater control
4-
over the toolbar position and behavior.
4+
over the toolbar position and behavior.
55
-->
66

77
<!doctype html>
@@ -10,40 +10,39 @@
1010
<meta charset="utf-8">
1111
<title>Expand and show toolbar demo</title>
1212
<meta name="viewport" content="width=device-width, initial-scale=1">
13-
<script src="https://cdn.tiny.cloud/1/qagffr3pkuv17a8on1afax661irst1hbr4e6tbv888sz91jc/tinymce/5-dev/tinymce.min.js" referrerpolicy="origin"></script>
13+
<script src="https://cdn.tiny.cloud/1/qagffr3pkuv17a8on1afax661irst1hbr4e6tbv888sz91jc/tinymce/8/tinymce.min.js" referrerpolicy="origin"></script>
1414

1515
<script>
1616
tinymce.init({
1717
selector: "#editor-content",
18-
plugins: "emoticons hr image link lists charmap table",
19-
toolbar: "formatgroup paragraphgroup insertgroup",
18+
plugins: "emoticons image link lists charmap table",
2019
placeholder: "Ask a question or post an update...",
2120
menubar: false,
2221
skin: 'naked',
2322
icons: 'thin',
2423

2524
// Enable inline mode
26-
// https://www.tiny.cloud/docs/configure/editor-appearance/#inline
25+
// https://www.tiny.cloud/docs/tinymce/latest/use-tinymce-inline/
2726
inline: true,
2827

2928
// Render the toolbar in this container.
30-
// https://www.tiny.cloud/docs/configure/editor-appearance/#fixed_toolbar_container
29+
// https://www.tiny.cloud/docs/tinymce/latest/menus-configuration-options/#fixed_toolbar_container
3130
fixed_toolbar_container: '#editor-toolbar',
3231

3332
// Makes menus move upwards
34-
// https://www.tiny.cloud/docs/configure/editor-appearance/#toolbar_location
33+
// https://www.tiny.cloud/docs/tinymce/latest/toolbar-configuration-options/#toolbar_location
3534
toolbar_location: 'bottom',
3635

3736
// Remove the manual image resizing as we're using percentage widths
38-
// https://www.tiny.cloud/docs/configure/advanced-editing-behavior/#object_resizing
37+
// https://www.tiny.cloud/docs/tinymce/latest/content-behavior-options/#object_resizing
3938
object_resizing: false,
4039

4140
// Hide the right click context menus
42-
// https://www.tiny.cloud/docs/configure/editor-appearance/#contextmenu
41+
// https://www.tiny.cloud/docs/tinymce/latest/menus-configuration-options/#contextmenu
4342
contextmenu: false,
4443

4544
// Create three custom toolbar groups
46-
// https://www.tiny.cloud/docs/configure/editor-appearance/#toolbar_groups
45+
// https://www.tiny.cloud/docs/tinymce/latest/toolbar-configuration-options/#toolbar_groups
4746
toolbar_groups: {
4847
formatgroup: {
4948
icon: 'format',
@@ -61,31 +60,34 @@
6160
items: 'link image emoticons charmap hr'
6261
}
6362
},
63+
64+
// Show the three toolbar groups
65+
toolbar: "formatgroup paragraphgroup insertgroup",
6466

6567
// On mobile, toolbar_mode is sliding by default which is not compatible
6668
// with toolbar_groups. Therefore we explicitly set toolbar_mode to floating
6769
// on mobile and touch devices.
68-
// https://www.tiny.cloud/docs/configure/editor-appearance/#toolbar_mode
69-
// https://www.tiny.cloud/docs/configure/editor-appearance/#mobile
70+
// https://www.tiny.cloud/docs/tinymce/latest/toolbar-configuration-options/#toolbar_mode
71+
// https://www.tiny.cloud/docs/tinymce/latest/tinymce-for-mobile/
7072
mobile: {
7173
toolbar_mode: 'floating'
7274
},
7375

7476
setup: (editor) => {
7577
// Apply a custom class to the wrapper element when the editor gets focus
76-
// https://www.tiny.cloud/docs/advanced/events/
78+
// https://www.tiny.cloud/docs/tinymce/latest/events/
7779
editor.on('focus', () => {
7880
document.getElementById('editor-wrap').classList.add('focused');
7981
});
8082

8183
// Remove the custom class when the editor loses focus
82-
// https://www.tiny.cloud/docs/advanced/events/
84+
// https://www.tiny.cloud/docs/tinymce/latest/events/
8385
editor.on('blur', () => {
8486
document.getElementById('editor-wrap').classList.remove('focused');
8587
});
8688

8789
// Register a custom context toolbar for images
88-
// https://www.tiny.cloud/docs/ui-components/contexttoolbar/#registeringacontexttoolbar
90+
// https://www.tiny.cloud/docs/tinymce/latest/contexttoolbar/#registeringacontexttoolbar
8991
editor.ui.registry.addContextToolbar('editimage', {
9092
predicate: (node) => {
9193
return node.nodeName.toLowerCase() === 'img'
@@ -96,24 +98,24 @@
9698
});
9799

98100
// Register a custom edit image button
99-
// https://www.tiny.cloud/docs/ui-components/toolbarbuttons/
101+
// https://www.tiny.cloud/docs/tinymce/latest/custom-toolbarbuttons/
100102
editor.ui.registry.addButton('editimage', {
101103
icon: 'edit-block',
102104
onAction: () => {
103105
// Display the image dialog
104-
// https://www.tiny.cloud/docs/plugins/image/#commands
106+
// https://www.tiny.cloud/docs/tinymce/latest/image/#commands
105107
editor.execCommand('mceImage');
106108
}
107109
});
108110

109111
// Register a custom remove image button
110-
// https://www.tiny.cloud/docs/ui-components/toolbarbuttons/
112+
// https://www.tiny.cloud/docs/tinymce/latest/custom-toolbarbuttons/
111113
editor.ui.registry.addButton('removeimage', {
112114
icon: 'remove',
113115
onAction: () => {
114116
// Get the currently selected content (called "node") and delete it.
115-
// https://www.tiny.cloud/docs/api/tinymce.dom/tinymce.dom.selection/
116-
// https://www.tiny.cloud/docs/api/tinymce.html/tinymce.html.node/
117+
// https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.dom.selection/
118+
// https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.html.node/
117119
const node = tinymce.activeEditor.selection.getNode();
118120
node.remove();
119121
}

0 commit comments

Comments
 (0)