Make WordPress Core

Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#11512 closed feature request (fixed)

Allow themes to provide a stylesheet for use within the rich text editor

Reported by: caesarsgrunt's profile caesarsgrunt Owned by:
Milestone: 3.0 Priority: normal
Severity: normal Version: 2.9
Component: Editor Keywords:
Focuses: Cc:

Description

At the moment, the "WYSIWYG" view is not really representative (at times, not remotely representative) of what the post will actually look like when published.

It would be nice if themes could easily provide a stylesheet for use within the rich editor, which could include many of the same rules as are used on the frontend.

Attachments (4)

add_editor_style.diff (2.3 KB) - added by nacin 15 years ago.
add_editor_style.2.diff (1.6 KB) - added by nacin 15 years ago.
Second pass supports arrays of stylesheets, and multiple calls to add_editor_style()
add_editor_style.3.diff (2.0 KB) - added by nacin 15 years ago.
Some child theme logic
add_editor_style.4.diff (3.1 KB) - added by nacin 15 years ago.
Less work being done

Download all attachments as: .zip

Change History (26)

#1 @scribu
15 years ago

  • Keywords close added

There was a discussion in the past about the possibility of allowing themes to style the login screen. Matt, if I remember well, was strictly opposed to the ideea. So I don't think this is going to happen.

Here's a possible solution: convince the PostHaste plugin author to make it use NicEdit* instead of a plain textarea. That way you get both a rich text editor and the ability to preview the post as you're writing it.

For editing, you can use my Front-end Editor plugin (it already uses NicEdit) :D

  • NicEdit is a WYSIWYG editor that preserves all the styles around it, with no fuss.

#2 @azaozz
15 years ago

  • Resolution set to worksforme
  • Status changed from new to closed

This is actually possible at the moment by using the 'tiny_mce_before_init' filter. Could probably make a short tutorial or a "developer plugin" that can be copied and added to themes.

#3 follow-ups: @Denis-de-Bernardy
15 years ago

I disagree, even though I'm potentially losing lots of business arguments here... how hard would it be make WP auto-detect some kind of mce.css file in the theme's folder?

Answer: not hard at all...

#4 @hakre
15 years ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened

I like the preview button. It does work and I can see the post in the frontends context properly. I'm not shure if this would work within the visual editor that well, but a prototype would be definetly nice to have. Next to javascript, styles can be injected in admin-head for post/page editor.

Closing after 7 hours without letting the reporter to provide feedback is quite rude IMHO.

#5 in reply to: ↑ 3 ; follow-up: @azaozz
15 years ago

Replying to Denis-de-Bernardy:
... how hard would it be make WP auto-detect some kind of mce.css file in the theme's folder?

Answer: not hard at all...

How hard would it be for a theme to include couple lines of code to set that? Same answer :)

Also it would need two args, one to include the extra CSS, another to define which styles should show in the drop-down menus.

Replying to hakre:

Closing after 7 hours without letting the reporter to provide feedback is quite rude IMHO.

Hmm, this is a feature request for a feature that already exists, it has nothing to do with being "rude" or "nice", simply don't see why this ticket has to stay open.

#6 in reply to: ↑ 5 @Denis-de-Bernardy
15 years ago

Replying to azaozz:

Replying to Denis-de-Bernardy:
... how hard would it be make WP auto-detect some kind of mce.css file in the theme's folder?

Answer: not hard at all...

How hard would it be for a theme to include couple lines of code to set that? Same answer :)

no, it isn't, you can't assume that theme devs know much about php,

Replying to hakre:

Closing after 7 hours without letting the reporter to provide feedback is quite rude IMHO.

Hmm, this is a feature request for a feature that already exists, it has nothing to do with being "rude" or "nice", simply don't see why this ticket has to stay open.

I disagree. the got closed only a few hours it got opened. The idea, though, existed already prior to this in a separate ticket, too.

It definitely deserves a few thoughts imo...

#7 follow-up: @azaozz
15 years ago

I'm not sure I follow...

  1. Feature request for an existing feature: ticket is either "invalid" or "worksforme"...
  1. "It definitely deserves a few thoughts...". Agree, it deserves few thoughts by theme authors whether they want to use this (it's quite limited, header, footer, sidebars, etc. cannot be shown in the editor) and whether they are ready to maintain it. Nothing to do with a ticket in trac.

#8 @caesarsgrunt
15 years ago

  • Keywords close removed

Sorry not to have come back into this discussion before; Trac isn't sending email notifications properly.

Whilst it is possible to do this from functions.php in a theme, I do think it would be nice if it could be done automatically in core by recognising a specific filename in the theme, like all other WP theming, so that it became a standard thing to do in themes. This is not an existing feature. Nor can I see why there should be any opposition - scribu, did matt give reasons?

#9 in reply to: ↑ 7 @caesarsgrunt
15 years ago

Replying to azaozz:

  1. "It definitely deserves a few thoughts...". Agree, it deserves few thoughts by theme authors whether they want to use this (it's quite limited, header, footer, sidebars, etc. cannot be shown in the editor) and whether they are ready to maintain it. Nothing to do with a ticket in trac.

I'm not suggesting a full preview of the whole site; just that themes style the content of the rich editor to use eg the same font, same styles for images, headings, etc, so that you can tell approximately how the post will be formatted after publishing.

#10 follow-up: @dd32
15 years ago

I'd agree with Denis here, If its possible for WordPress to "auto detect" a mce.css-style-named file in the themes folder, Why not allow it to happen without the extra PHP on the theme authors side.. Those that have mentioned that many theme developers are not strong coders is true.. just look at some of the themes out there.

Anything to make a Theme developers life easier, and providing benefit to other WordPress users is a plus from me.

#11 @caesarsgrunt
15 years ago

For what it's worth, the code to do this from within functions.php is this :

function ym_mce_css($content) {
	return get_bloginfo('stylesheet_directory').'/admin/mce.css';
}
add_filter('mce_css', 'ym_mce_css');

But it would be nice if WP detected mce.css automatically, to raise awareness of the ability to do this and make it more widespread. The rich editor is an important thing to theme.

#12 in reply to: ↑ 3 @hakre
15 years ago

Replying to Denis-de-Bernardy:

I disagree, even though I'm potentially losing lots of business arguments here... how hard would it be make WP auto-detect some kind of mce.css file in the theme's folder?

only for admin please. we should provide a filter, functions.php of the theme can overwrite (is the frontend theme loaded while the user is in the admin?!) so that it can place that into a folder or name it as wished.

#13 @hakre
15 years ago

  • Keywords needs-patch added

#14 in reply to: ↑ 10 @nacin
15 years ago

Replying to dd32:

I'd agree with Denis here, If its possible for WordPress to "auto detect" a mce.css-style-named file in the themes folder, Why not allow it to happen without the extra PHP on the theme authors side.. Those that have mentioned that many theme developers are not strong coders is true.. just look at some of the themes out there.

Anything to make a Theme developers life easier, and providing benefit to other WordPress users is a plus from me.

We're using editor-style.css in twentyten. I imagine that might raise the profile of this ability a bit.

#15 @nacin
15 years ago

(In [13441]) Introduce add_editor_style() to easily register a stylesheet for the visual editor. see #11512 see #9015

@nacin
15 years ago

Second pass supports arrays of stylesheets, and multiple calls to add_editor_style()

@nacin
15 years ago

Some child theme logic

#16 @nacin
15 years ago

(In [13444]) add_editor_style(), second pass. Accept an array of stylesheets, also allow multiple calls to the function. Support child themes. See #9015 see #11512

#17 @nacin
15 years ago

  • Keywords needs-patch removed
  • Resolution set to fixed
  • Status changed from reopened to closed

Closing out. add_editor_style() looks good.

@nacin
15 years ago

Less work being done

#18 @nacin
15 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Re-opening so we don't forget about patch 4.

#19 @ryan
15 years ago

Looks good.

#20 @ryan
15 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

#21 follow-up: @caesarsgrunt
15 years ago

Just curious, since I've not been involved in dev for a while - what is the advantage of having to register the stylesheet, as in this system, rather than automatically detecting it as is done for other theme files?

#22 in reply to: ↑ 21 @nacin
15 years ago

Replying to caesarsgrunt:

Just curious, since I've not been involved in dev for a while - what is the advantage of having to register the stylesheet, as in this system, rather than automatically detecting it as is done for other theme files?

Performance. Most themes will never use this, so we'd be wasting our time on a file_exists() check over and over.

We do use file_exists() here when a child theme is used, but the stylesheet still needs to be registered first, so we're still avoiding unnecessary file_exists() checks.

Note: See TracTickets for help on using tickets.