TinyMCE directionality for RTL support. Props skeltoac. fixes #1967
git-svn-id: http://svn.automattic.com/wordpress/trunk@3244 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7b9f47b54b
commit
8f6c123fa7
|
@ -79,15 +79,20 @@ addLoadEvent(blurry);
|
||||||
<script type="text/javascript" src="../wp-includes/js/tw-sack.js"></script>
|
<script type="text/javascript" src="../wp-includes/js/tw-sack.js"></script>
|
||||||
<script type="text/javascript" src="list-manipulation.js"></script>
|
<script type="text/javascript" src="list-manipulation.js"></script>
|
||||||
<?php if ( isset( $editing ) ) : ?>
|
<?php if ( isset( $editing ) ) : ?>
|
||||||
<?php if ( 'true' == get_user_option('rich_editing') ) :?>
|
<?php if ( $editing && 'true' == get_user_option('rich_editing') ) :
|
||||||
<script language="javascript" type="text/javascript" src="../wp-includes/js/tinymce/tiny_mce_gzip.php?index=0&theme=advanced&plugins=wordpress,autosave,wphelp"></script>
|
$mce_plugins = apply_filters('mce_plugins', array('wordpress', 'autosave', 'wphelp'));
|
||||||
|
$mce_plugins = implode($mce_plugins, ',');
|
||||||
|
$mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'separator', 'bullist', 'numlist', 'outdent', 'indent', 'separator', 'justifyleft', 'justifycenter', 'justifyright' ,'separator', 'link', 'unlink', 'image', 'emotions', 'wordpress', 'separator', 'undo', 'redo', 'code', 'wphelp'));
|
||||||
|
$mce_buttons = implode($mce_buttons, ',');
|
||||||
|
?>
|
||||||
|
<script language="javascript" type="text/javascript" src="../wp-includes/js/tinymce/tiny_mce_gzip.php?index=0&theme=advanced&plugins=<?php echo $mce_plugins; ?>"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
tinyMCE.init({
|
tinyMCE.init({
|
||||||
mode : "specific_textareas",
|
mode : "specific_textareas",
|
||||||
textarea_trigger : "title",
|
textarea_trigger : "title",
|
||||||
width : "100%",
|
width : "100%",
|
||||||
theme : "advanced",
|
theme : "advanced",
|
||||||
theme_advanced_buttons1 : "bold,italic,strikethrough,separator,bullist,numlist,outdent,indent,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,image,emotions,wordpress,separator,undo,redo,code,wphelp",
|
theme_advanced_buttons1 : "<?php echo $mce_buttons; ?>",
|
||||||
theme_advanced_buttons2 : "",
|
theme_advanced_buttons2 : "",
|
||||||
theme_advanced_buttons3 : "",
|
theme_advanced_buttons3 : "",
|
||||||
theme_advanced_toolbar_location : "top",
|
theme_advanced_toolbar_location : "top",
|
||||||
|
@ -105,8 +110,8 @@ tinyMCE.init({
|
||||||
convert_newlines_to_brs : false,
|
convert_newlines_to_brs : false,
|
||||||
remove_linebreaks : true,
|
remove_linebreaks : true,
|
||||||
save_callback : "wp_save_callback",
|
save_callback : "wp_save_callback",
|
||||||
valid_elements : "-a[id|href|title|rel],-strong/b,-em/i,-strike,-del,-u,p[class|align],-ol,-ul,-li,br,img[class|src|alt|title|width|height|align],-sub,-sup,-blockquote,-table[border=0|cellspacing|cellpadding|width|height|class|align],tr[class|rowspan|width|height|align|valign],td[dir|class|colspan|rowspan|width|height|align|valign],-div[dir|class|align],-span[class|align],-pre[class],-code[class],-address,-h1[class|align],-h2[class|align],-h3[class|align],-h4[class|align],-h5[class|align],-h6[class|align],hr",
|
valid_elements : "-a[id|href|title|rel],-strong/b,-em/i,-strike,-del,-u,p[class|align|dir],-ol,-ul,-li,br,img[class|src|alt|title|width|height|align],-sub,-sup,-blockquote[dir],-table[border=0|cellspacing|cellpadding|width|height|class|align|dir],tr[class|rowspan|width|height|align|valign|dir],td[dir|class|colspan|rowspan|width|height|align|valign],-div[dir|class|align],-span[class|align],-pre[class],-code[class],-address,-h1[class|align|dir],-h2[class|align|dir],-h3[class|align|dir],-h4[class|align|dir],-h5[class|align|dir],-h6[class|align|dir],hr",
|
||||||
plugins : "wordpress,autosave,wphelp"
|
plugins : "<?php echo $mce_plugins; ?>"
|
||||||
<?php do_action('mce_options'); ?>
|
<?php do_action('mce_options'); ?>
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -150,7 +150,7 @@ endforeach;
|
||||||
?>
|
?>
|
||||||
<?php if ( !$richedit ) the_quicktags(); ?>
|
<?php if ( !$richedit ) the_quicktags(); ?>
|
||||||
|
|
||||||
<div><textarea <?php if ( $richedit ) echo 'title="true"'; ?> rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="2" id="content"><?php echo $richedit ? wp_richedit_pre($post->post_content) : $post->post_content; ?></textarea></div>
|
<div><textarea dir="rtl" <?php if ( $richedit ) echo 'title="true"'; ?> rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="2" id="content"><?php echo $richedit ? wp_richedit_pre($post->post_content) : $post->post_content; ?></textarea></div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<?php if ( !$richedit ) : ?>
|
<?php if ( !$richedit ) : ?>
|
||||||
|
|
|
@ -994,7 +994,7 @@ function ent2ncr($text) {
|
||||||
|
|
||||||
function wp_richedit_pre($text) {
|
function wp_richedit_pre($text) {
|
||||||
// Filtering a blank results in an annoying <br />\n
|
// Filtering a blank results in an annoying <br />\n
|
||||||
if ( empty($text) ) return '';
|
if ( empty($text) ) return '<p> </p>';
|
||||||
|
|
||||||
$output = $text;
|
$output = $text;
|
||||||
$output = html_entity_decode($output); // undoes format_to_edit()
|
$output = html_entity_decode($output); // undoes format_to_edit()
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
/* Import plugin specific language pack */
|
||||||
|
tinyMCE.importPluginLanguagePack('directionality', 'en,sv,fr_ca,zh_cn,cs,da,he,no,de,hu,ru,ru_KOI8-R,ru_UTF-8,es,cy,is,pl');
|
||||||
|
|
||||||
|
function TinyMCE_directionality_getInfo() {
|
||||||
|
return {
|
||||||
|
longname : 'Directionality',
|
||||||
|
author : 'Moxiecode Systems',
|
||||||
|
authorurl : 'http://tinymce.moxiecode.com',
|
||||||
|
infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_directionality.html',
|
||||||
|
version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
function TinyMCE_directionality_getControlHTML(control_name) {
|
||||||
|
switch (control_name) {
|
||||||
|
case "ltr":
|
||||||
|
var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceDirectionLTR\');return false;';
|
||||||
|
return '<a href="javascript:' + cmd + '" onclick="' + cmd + '" target="_self" onmousedown="return false;"><img id="{$editor_id}_ltr" src="{$pluginurl}/images/ltr.gif" title="{$lang_directionality_ltr_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>'
|
||||||
|
+ '<div class="zerosize"><input type="button" accesskey="." onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceDirectionLTR\',false);" /></div>';
|
||||||
|
|
||||||
|
case "rtl":
|
||||||
|
var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceDirectionRTL\');return false;';
|
||||||
|
return '<a href="javascript:' + cmd + '" onclick="' + cmd + '" target="_self" onmousedown="return false;"><img id="{$editor_id}_rtl" src="{$pluginurl}/images/rtl.gif" title="{$lang_directionality_rtl_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>'
|
||||||
|
+ '<div class="zerosize"><input type="button" accesskey="," onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceDirectionRTL\',false);" /></div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function TinyMCE_directionality_execCommand(editor_id, element, command, user_interface, value) {
|
||||||
|
// Handle commands
|
||||||
|
switch (command) {
|
||||||
|
case "mceDirectionLTR":
|
||||||
|
var inst = tinyMCE.getInstanceById(editor_id);
|
||||||
|
var elm = tinyMCE.getParentElement(inst.getFocusElement(), "p,div,td,h1,h2,h3,h4,h5,h6,pre,address");
|
||||||
|
|
||||||
|
if (elm)
|
||||||
|
elm.setAttribute("dir", "ltr");
|
||||||
|
|
||||||
|
tinyMCE.triggerNodeChange(false);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case "mceDirectionRTL":
|
||||||
|
var inst = tinyMCE.getInstanceById(editor_id);
|
||||||
|
var elm = tinyMCE.getParentElement(inst.getFocusElement(), "p,div,td,h1,h2,h3,h4,h5,h6,pre,address");
|
||||||
|
|
||||||
|
if (elm)
|
||||||
|
elm.setAttribute("dir", "rtl");
|
||||||
|
|
||||||
|
tinyMCE.triggerNodeChange(false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pass to next handler in chain
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function TinyMCE_directionality_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
|
||||||
|
function getAttrib(elm, name) {
|
||||||
|
return elm.getAttribute(name) ? elm.getAttribute(name) : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
tinyMCE.switchClassSticky(editor_id + '_ltr', 'mceButtonNormal', false);
|
||||||
|
tinyMCE.switchClassSticky(editor_id + '_rtl', 'mceButtonNormal', false);
|
||||||
|
|
||||||
|
if (node == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var elm = tinyMCE.getParentElement(node, "p,div,td,h1,h2,h3,h4,h5,h6,pre,address");
|
||||||
|
if (!elm) {
|
||||||
|
tinyMCE.switchClassSticky(editor_id + '_ltr', 'mceButtonDisabled', true);
|
||||||
|
tinyMCE.switchClassSticky(editor_id + '_rtl', 'mceButtonDisabled', true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var dir = getAttrib(elm, "dir");
|
||||||
|
if (dir == "ltr" || dir == "")
|
||||||
|
tinyMCE.switchClassSticky(editor_id + '_ltr', 'mceButtonSelected', false);
|
||||||
|
else
|
||||||
|
tinyMCE.switchClassSticky(editor_id + '_rtl', 'mceButtonSelected', false);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 155 B |
Binary file not shown.
After Width: | Height: | Size: 153 B |
|
@ -0,0 +1,6 @@
|
||||||
|
// UK lang variables
|
||||||
|
|
||||||
|
tinyMCE.addToLang('',{
|
||||||
|
directionality_ltr_desc : 'Direction left to right (Alt-.)',
|
||||||
|
directionality_rtl_desc : 'Direction right to left (Alt-,)'
|
||||||
|
});
|
Loading…
Reference in New Issue