Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript TinyMCE 4-纯文本/条形HTML标记按钮_Javascript_Html_Tinymce_Tinymce 4 - Fatal编程技术网

Javascript TinyMCE 4-纯文本/条形HTML标记按钮

Javascript TinyMCE 4-纯文本/条形HTML标记按钮,javascript,html,tinymce,tinymce-4,Javascript,Html,Tinymce,Tinymce 4,有没有一种方法可以完全去除所选元素的样式和HTML标记 所以文本将变成文本 使用自定义按钮(功能)或“格式”下拉列表中的“纯文本”样式?试试看 getContent({format:'text'}) 或 getContent({format:'html'}) 试试看 getContent({format:'text'}) 或 getContent({format:'html'}) 多亏了Anub的指导,我自己也做到了 // Store the current selections string/

有没有一种方法可以完全去除所选元素的样式和HTML标记

所以
文本

将变成
文本

使用自定义按钮(功能)或“格式”下拉列表中的“纯文本”样式?

试试看

getContent({format:'text'})

getContent({format:'html'})

试试看

getContent({format:'text'})


getContent({format:'html'})

多亏了Anub的指导,我自己也做到了

// Store the current selections string/value in a variable and strip it's tags
var node = tinymce.activeEditor.selection.getContent({ format : 'text' });

// Replace the selected content with the stripped out content
tinymce.activeEditor.selection.setContent(node);

多亏了Anub的指导,我自己做到了这一点

// Store the current selections string/value in a variable and strip it's tags
var node = tinymce.activeEditor.selection.getContent({ format : 'text' });

// Replace the selected content with the stripped out content
tinymce.activeEditor.selection.setContent(node);

如果你喜欢的话,这里有一个PHP函数,它是如何工作的?我当然更喜欢纯JavaScript解决方案,但这可能是一个选项。如果您感兴趣,有一个PHP函数用于此。这是如何工作的?我当然更喜欢纯JavaScript解决方案,但这可能是一个选项。这只是获取所选内容,但我需要将其设置为能够删除tagsvar node=tinyMCE.activeEditor.selection.getContent();tinyMCE.execCommand('mceReplaceContent',false,%your value,can use node%');现在,我的h2和h3标记被合并成一个h2标记(其中的文本被合并)。是否还要删除h2标记?谢谢这是所选的内容,但我需要将其设置为能够删除标记var node=tinyMCE.activeEditor.selection.getContent();tinyMCE.execCommand('mceReplaceContent',false,%your value,can use node%);现在,我的h2和h3标签被合并成一个h2标签(里面的文本被合并)。是否还要删除h2标记?谢谢