Grid Lines Missing: Customizing Rows and Columns in TinyMCE Editor
TinyMCE is a popular open-source WYSIWYG HTML editor that is used to create and edit content for websites. It offers various plugins to extend its functionality, and one such plugin is the "Table" plugin, which enables users to create and edit tables within the editor. However, when using TinyMCE version 4.8.1 with the Optimizely solution, you might encounter an issue where the grid lines are missing when creating or editing tables.
Understanding the Issue
The issue occurs due to a conflict between the TinyMCE Table plugin and the Optimizely solution. The Optimizely solution modifies the TinyMCE editor's core functionality, which affects the Table plugin's ability to display grid lines. To resolve this issue, we need to customize the Table plugin's settings.
Customizing the Table Plugin
To customize the Table plugin's settings, you need to add some JavaScript code to your website. Here are the steps:
Step 1: Create a Custom Script
Create a new JavaScript file, let's call it "tiny-mce-table.js". This file will contain the custom code to enable grid lines in the Table plugin.
// Replace the existing init function with the following code
tinymce.init = function (editor) {
// Your existing initialization code goes here
// Customize the Table plugin settings
editor.plugins.table.options.showGrid = true;
editor.plugins.table.options.grid_widths = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100];
editor.plugins.table.options.grid_heights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100];
};
Make sure to replace the existing "init" function with the code provided. This code sets the "showGrid" option to true, which enables grid lines, and sets the available grid widths and heights.
Step 2: Include the Custom Script
Include the "tiny-mce-table.js" file in your HTML document, after the TinyMCE initialization code. You can do this by adding the following line to the head or body of your HTML:
<script src="tiny-mce-table.js" type="text/javascript"></script>
Testing the Solution
Now, when you use the TinyMCE editor to create or edit tables, the grid lines should be displayed.
In this article, we discussed how to customize the Table plugin in TinyMCE Editor version 4.8.1 to display grid lines when using the Optimizely solution. We created a custom JavaScript file, "tiny-mce-table.js", which sets the Table plugin's options to enable grid lines. We then included this file in our HTML document, and the grid lines were displayed when creating or editing tables in the TinyMCE editor.