Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8150331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:02:19+00:00 2026-06-06T15:02:19+00:00

Current tinyMCE version (3.5.2). Hi, I am working on a custom plugin which adds

  • 0

Current tinyMCE version (3.5.2).

Hi,

I am working on a custom plugin which adds and removes custom formats.

Adding a format to the current selection is simple however I couldn’t
find a fitting solution for removing multiple formats.

What I did find was the RemoveFormat command:

tinymce.activeEditor.execCommand('RemoveFormat');
// which is the same as 
tinymce.activeEditor.formatter.remove('removeformat');

This function does remove any formats of the current selection
and that is definitely to much as I want to remove only some of the formats.

So I tried to call the remove method for every format

tinymce.activeEditor.formatter.remove('format_1');
tinymce.activeEditor.formatter.remove('format_2');
...

However this wasn’t successful either as it doesn’t remove nested formats.
If you select the following paragraph and call tinymce.activeEditor.formatter.remove('format_2'); it will NOT remove the format as the paragraph doesn’t use this format itself.

<p class="format_1">abcd<span class="format_2>ef</span>g</p>

Is there any way to remove a format of an element and also of all of its children like RemoveFormat?


Update (@Thariama)

All my formats are custom formats with the following structure:

  "demo_format_1" : { 
      "classes" : "demo_format_1",
      "deep" : true,
      "exact" : false,
      "inline" : "span",
      "selector" : "*",
      "title" : "Demo Format"
   }}

Update:

After implementing this again I found further cases.
Here are examples of all special cases which came to my mind:

Text before removing the format:

<p>abc<span class=demo_format_1>def</span></p>

Case 1 (Covered with the so Jeffery To)

Selecting the whole paragraph should give you the following result

 <p>abcdef</p>

Case 2

Selecting only f should give you the following result

<p>abc<span class=demo_format_1>de</span>f</p>

Case 3

Selecting only cd should give you the following result

<p>abcd<span class=demo_format_1>ef</span></p>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T15:02:21+00:00Added an answer on June 6, 2026 at 3:02 pm

    tinymce.Formatter.remove can be called on a specific node, so:

    var selection = ed.selection.getSel(),
        ancestor = ed.selection.getNode(),
        els = ancestor.getElementsByTagName('span'),
        l = els.length,
        i = 0;
    if (selection.containsNode(ancestor, true) && ancestor.nodeName.toLowerCase() === 'span') {
        ed.formatter.remove('demo_format_2', null, ancestor);
    }
    for ( ; i < l; i++) {
        if (selection.containsNode(els[i], true)) {
            ed.formatter.remove('demo_format_2', null, els[i]);
        }
    }
    

    Demo


    Update: Turns out the trouble is caused by including both inline and selector in the format, which marks it as “mixed” (inline + block level). If you define the format with only inline:

    demo_format_1: {
        inline: "span",
        classes: "demo_format_1"
    }
    

    then formatter.remove('demo_format_1') works as you’d expect (demo).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can bind eventsin the current window, but I'm using TinyMCE which creates an
Current situation: I have the current version of my MVC Framework which uses classes
Current project is an Mvc4 application, I had Ioc working and recently it just
Current demo here: http://www.studioimbrue.com/sites/eliotdudik I have the tabs system working wonderfully. I'm trying to
This is driving me nuts!@#!@# I can load the tinyMce plugin for jquery just
Current Situation: Direct Binding I have an NSTableView which displays the data that comes
Current developing an iPhone app using jQuery mobile, everything is looking great however when
This is question about tinymce... Current image editor is slow for because it demands
I am trying to write a plugin for TinyMCE with a feature to add
Current functionality just outlines the matching brace which is hard to see. How would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.