Ways to focus on TinyMCE editor for customization

Would it be possible to target the entire TinyMCE editor in order to apply some styling, such as adding 10px of padding around it? I'm using TinyMCE 4 and starting with the HTML code shown below results in TinyMCE generating additional HTML.

I would like to style the complete TinyMCE editor, specifically #mce_9. However, #mce_9 is an automatically assigned ID by TinyMCE, and I prefer not to hardcode it into my CSS. The body_id and body_class properties provided by TinyMCE only allow me to target the internal iframe, not the entire editor.

tinyMCE.init({
    selector: "#frontContent",
    //body_id:"frontContentWindow"
});

Original HTML content before applying TinyMCE:

<div id="content">
    <div id="frontContent">BLA BLA BLA</div>
</div>

Updated HTML after implementing TinyMCE:

<div id="content">
    <div tabindex="-1" hidefocus="1" class="mce-tinymce mce-container mce-panel" id="mce_9" style="visibility: hidden; border-width: 1px; width: 600px;">
        <div class="mce-container-body mce-stack-layout" id="mce_9-body">
            ....
        </div>
    </div>
    <div id="frontContent" style="display: none;" aria-hidden="true">BLA BLA BLA</div>
</div>

Answer №1

It is assumed that multiple individuals can utilize two TinyMCE editors, with the id being generated dynamically and not specific. It is recommended to use the class mce-tinymce instead of a unique id.

<div id="content">
    <div tabindex="-1" hidefocus="1" class="mce-tinymce mce-container mce-panel" id="mce_9" style="visibility: hidden; border-width: 1px; width: 600px;">
        <div class="mce-container-body mce-stack-layout" id="mce_9-body">
            ....
        </div>
    </div>
    <div id="frontContent" style="display: none;" aria-hidden="true">BLA BLA BLA</div>
</div>

<div id="content2">
    <div tabindex="-1" hidefocus="1" class="mce-tinymce mce-container mce-panel" id="mce_10" style="visibility: hidden; border-width: 1px; width: 600px;">
        <div class="mce-container-body mce-stack-layout" id="mce_10-body">
            ....
        </div>
    </div>
    <div id="frontContent2" style="display: none;" aria-hidden="true">BLA BLA BLA</div>
</div>

<style>
#content2 .mce-tinymce{
   padding:10px;
}
</style>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can I restrict the number of characters per line in a textarea using javascript or jQuery?

Is there a method to control the number of characters per line in a textarea? For example, on lines 1-3 of the textarea, only 20 characters can be entered, while on subsequent lines, up to 50 characters are allowed. The current structure of the textarea l ...

How to Retrieve a Specific Line with jQuery

Could jQuery be used to retrieve the offset of the first letter in the 5th visual line of a block's content? I am referring to the visual line determined by the browser, not the line seen in the source code. ...

Handling image errors in jQuery for responsive design queries

Images on my website change based on the screen size using media queries. I am looking for a way to handle errors that may occur using jQuery. I want to display a text message if the image fails to load. Here is the code I have so far: <div class="con ...

Incorporate a new element into your webpage using an AJAX call in Symfony 3, all without

I am currently working on implementing Symfony forms within a modal using AJAX to prevent page reloading every time an add/remove or update action is submitted. However, I am not very familiar with AJAX and unsure how to proceed. Can anyone provide guidanc ...

Sorting JSON data in EJS based on categories

Hello, I am facing a dilemma. I need to apply category filtering to a JSON file but I am unsure of how to proceed with it. For instance, I wish to filter the 'vida' category along with its description and price. I seem to be stuck at this junctu ...

Pandas now supports exporting data frames to HTML with the added feature of conditional

Is there a way to format a table in pandas where data in each column are styled based on their values, similar to conditional formatting in spreadsheet programs? An example scenario is highlighting significant values in a table: correlation p-value ...

Leveraging AJAX to dynamically load an MVC user control within a jQuery tab housed within a jQuery dialog (C# included)

I am working on an index page that lists products and I want to include a dialog with tabs for Edit/Create Product, Product Images, and Brands. The Brands tab is not specific to the product being edited/created and does not need an ID to be passed. I have ...

Tips for sending a parameter to an onClick handler function in a component generated using array.map()

I've been developing a web application that allows users to store collections. There is a dashboard page where all the user's collections are displayed in a table format, with each row representing a collection and columns showing the collection ...

Event Triggered Upon Element Addition to DOM: JQuery Livequery Equivalent in Version 1.7

Is it possible to trigger an event when a certain element is added to a page, especially when I am using a Chrome extension and do not control the source page? I have explored the capabilities of JQuery 1.7's on() method, but it seems to focus on spe ...

Is the memory usage of node.js proportional to the number of concurrent requests, or is there a potential memory leak?

Running the following node.js code: var http = require('http'); http.createServer(function(req,res){ res.writeHead(200,{'Content-Type': 'text/plain'}); res.write("Hello"); res.end(); }).listen(8888); Upon starting the server ...

What is the best way to make a gradient fill and rounded border with CSS?

I am interested in creating a gradient and rounded border similar to the top bar on Instagram. Although I know how to create a rounded and solid border, this one utilizes a gradient. It appears that Instagram uses a canvas, but I am wondering if it can b ...

Is this code in line with commonly accepted norms and standards in Javascript and HTML?

Check out this Javascript Quiz script I created: /* Jane Doe. 2022. */ var Questions = [ { Question: "What is 5+2?", Values: ["7", "9", "10", "6"], Answer: 1 }, { Question: "What is the square root of 16?", Values: ["7", "5", "4", "1"], Answer: ...

Change the opacity of a DIV or any other element when hovering over it

I have successfully applied opacity: 1; to a paragraph when hovering over itself. However, I want the opacity to also change when hovering over the header above it. Here is my CSS code: .testH { font-family: impact; text-align: center; font-s ...

Created a custom JQuery Slider from scratch - Disappointed with the results

Despite having experience in J2ee/C/C++, I am new to Javascript and JQuery. I managed to create my own JQuery slider, complete with source code: <!DOCTYPE html> <html> <head> <title>Experimentation</title> <style ...

Is it possible to customize the color of the placeholder and clear-icon in the ion-search bar without affecting

I am working with two ion-search bars and I need to customize the placeholder and clear icon color for just one of them. <ion-searchbar class="search-bar" placeholder="search"></ion-searchbar> My goal is to target a specific i ...

I'm having trouble asynchronously adding a row to a table using the @angular/material:table schematic

Having trouble asynchronously adding rows using the @angular/material:table schematic. Despite calling this.table.renderRows(), the new rows are not displayed correctly. The "works" part is added to the table, reflecting in the paginator, but the asynchron ...

Using Mongoose to insert a JavaScript object directly into the database

Recently, I've been working on POSTing a JS object through AJAX to the nodejs backend. My goal is to seamlessly insert this js object into my mongoose db without having to manually map each key to the schema. This is what I have currently (a bit clun ...

Encountering a 500 error within a Passport JS and React application

I'm currently developing a chat application using React, and I've hit a roadblock while trying to authenticate users. The axios post request is throwing a 500 error that seems to be elusive. Even when the correct credentials are entered for a use ...

transferring a function from a main component to a nested component using swipeout functionality in react-native

I am attempting to transfer a function from a parent container to a child container within react native. The user is presented with a list of items on the screen, where they can swipe the list to reveal additional options. Child import React from &ap ...

JavaScript has received an event on Server XHR

Situation: There is a scenario where the target API is external and cannot be altered. A JS client initiates sending data to the API upon clicking a button. The code snippet resembles something like this: $.ajax({ type: "POST", url: &quo ...