我构建了一个元框,单击按钮可以显示启用了富文本编辑的文本区域。创建textarea并将其附加到DOM后,我运行以下命令来初始化编辑器:
console.log(wp.editor.getDefaultSettings());
var settings = {
tinymce: {toolbar1:"bold,italic,bullist,link"}
};
wp.editor.initialize( contentID, settings);
结果,文本区域出现,tinymce在其上初始化。问题是我的自定义设置无效。在上面的示例中,我仍然得到numlist按钮,而设置中没有指定它:
根据
the documentation 我自己的设置应该与默认设置合并,默认设置似乎不会像
wp.editor.getDefaultSettings()
返回值:
{
"tinymce":{
"theme":"modern",
"skin":"lightgray",
"language":"fr",
"formats":{
"alignleft":[
{
"selector":"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",
"styles":{
"textAlign":"left"
}
},
{
"selector":"img,table,dl.wp-caption",
"classes":"alignleft"
}
],
"aligncenter":[
{
"selector":"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",
"styles":{
"textAlign":"center"
}
},
{
"selector":"img,table,dl.wp-caption",
"classes":"aligncenter"
}
],
"alignright":[
{
"selector":"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",
"styles":{
"textAlign":"right"
}
},
{
"selector":"img,table,dl.wp-caption",
"classes":"alignright"
}
],
"strikethrough":{
"inline":"del"
}
},
"relative_urls":false,
"remove_script_host":false,
"convert_urls":false,
"browser_spellcheck":true,
"fix_list_elements":true,
"entities":"38,amp,60,lt,62,gt",
"entity_encoding":"raw",
"keep_styles":false,
"cache_suffix":"wp-mce-4800-20180716-tadv-4.7.13",
"resize":"vertical",
"menubar":false,
"branding":false,
"preview_styles":"font-family font-size font-weight font-style text-decoration text-transform",
"end_container_on_empty_block":true,
"wpeditimage_html5_captions":true,
"wp_lang_attr":"fr-FR",
"wp_keep_scroll_position":false,
"wp_shortcut_labels":{
"Heading 1":"access1",
"Heading 2":"access2",
"Heading 3":"access3",
"Heading 4":"access4",
"Heading 5":"access5",
"Heading 6":"access6",
"Paragraph":"access7",
"Blockquote":"accessQ",
"Underline":"metaU",
"Strikethrough":"accessD",
"Bold":"metaB",
"Italic":"metaI",
"Code":"accessX",
"Align center":"accessC",
"Align right":"accessR",
"Align left":"accessL",
"Justify":"accessJ",
"Cut":"metaX",
"Copy":"metaC",
"Paste":"metaV",
"Select all":"metaA",
"Undo":"metaZ",
"Redo":"metaY",
"Bullet list":"accessU",
"Numbered list":"accessO",
"Insert/edit image":"accessM",
"Remove link":"accessS",
"Toolbar Toggle":"accessZ",
"Insert Read More tag":"accessT",
"Insert Page Break tag":"accessP",
"Distraction-free writing mode":"accessW",
"Keyboard Shortcuts":"accessH"
},
"content_css":"https://[redacted]/dev/www/core/wp-includes/css/dashicons.css?ver=4.9.8,https://[redacted]/dev/www/core/wp-includes/js/tinymce/skins/wordpress/wp-content.css?ver=4.9.8",
"toolbar1":"bold,italic,bullist,numlist,link",
"wpautop":false,
"indent":true,
"elementpath":false,
"plugins":"charmap,colorpicker,hr,lists,paste,tabfocus,textcolor,fullscreen,wordpress,wpautoresize,wpeditimage,wpemoji,wpgallery,wplink,wptextpattern"
},
"quicktags":{
"buttons":"strong,em,link,ul,ol,li,code"
}
}
知道我做错了什么吗?