gpt4 book ai didi

jquery - 使用jquery将内容与tinymce中的rtl对齐

转载 作者:行者123 更新时间:2023-12-03 22:50:53 26 4
gpt4 key购买 nike

我正在开发一个Wordpress插件,我在tinymce界面添加了一个按钮,当用户按下它时,文本的方向从右向左转换。我尝试执行以下操作,但没有成功

        tinymce.get('#tinymce').getBody().dir ="rtl";

enter image description here

最佳答案

法典关于 Writing a Post in RTL Language 的文章推荐使用插件WP-RTL ,其中

[...] enables the text directions functionality that exist already in the original TinyMCE editor which allow writing texts in Left-to-Right and Right-to-Left directions in the same post (or page) for languages like Arabic, Persian and Hebrew.

它的代码非常简单:

<?php
/*
Plugin Name: WP-RTL
Plugin URI: http://www.fadvisor.net/blog/2008/10/wp-rtl/
Description: Adds two buttons to the TinyMCE editor to enable writing text in Left to Right (LTR) and Right to Left (RTL) directions.
Version: 0.3
Author: Fahad Alduraibi
Author URI: http://www.fadvisor.net/blog/
*/

add_action( "init", "tinymce_bidi_addbuttons" );

function tinymce_bidi_addbuttons() {
if( !current_user_can ( 'edit_posts' ) && !current_user_can ( 'edit_pages' ) ) {
return;
}
if( get_user_option ( 'rich_editing' ) == 'true' ) {
add_filter( "mce_external_plugins", "tinymce_bidi_plugin" );
add_filter( "mce_buttons", "tinymce_bidi_buttons" );
}
}
function tinymce_bidi_buttons($buttons) {
array_push($buttons, "separator", "ltr", "rtl");
return $buttons;
}

function tinymce_bidi_plugin($plugin_array) {
if (get_bloginfo('version') < 3.9) {
$plugin_array['directionality'] = includes_url('js/tinymce/plugins/directionality/editor_plugin.js');
} else {
$plugin_array['directionality'] = includes_url('js/tinymce/plugins/directionality/plugin.min.js');
}
return $plugin_array;
}

这就是它的作用:


关于jquery - 使用jquery将内容与tinymce中的rtl对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26130144/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com