我试图让tinymce编辑iframe与这个美妙的tabifier一起工作:
http://www.barelyfitz.com/projects/tabber
我已经成功安装了它们并且它们工作得很好。
在我的示例中,我测试了以下内容:
Run Code Online (Sandbox Code Playgroud)<p>test</p>
tinymce 工作正常。
我所做的下一个测试是使用 tabber:
Run Code Online (Sandbox Code Playgroud)<div class='tabber' id='tabber1'> <div class='tabbertab' title='FIRSTTAB' > test firsttab </div> <div class='tabbertab' title='SECONDTAB' > test secondtab </div> </div>
代码完美地保存在数据库中,结果完美地加载到输出视图中,显示两个选项卡,每个选项卡都有其内容。
问题是在尝试使用tinymce再次编辑内容时,选项卡未显示。内容完美加载到tinymce iframe 中,没有选项卡。其如下图所示:
测试第一个选项卡
测试第二个选项卡
里面的 HTML 代码很好,它之前保存了正确的 tabbifier html 代码。
问题可能是tinymce的iframe无法加载或解释tabber.js的javascript并且它不显示选项卡。我已经测试过使用此代码在tinymce iframe内加载tabber.js的javascript,并且似乎加载了它,但选项卡仍未显示:
<script type="text/javascript">
tinyMCE.init({
mode: "exact",
elements: "%s",
theme: "%s",
%s
%s
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_statusbar_location: "bottom",
theme_advanced_resizing: true
%s
setup : function(ed)
{
ed.onInit.add(function(ed, evt)
{
alert("entered tiny");
// Load a script from a …Run Code Online (Sandbox Code Playgroud) 我在弹出窗口中使用tinyMCE编辑器,弹出窗口是由ajaxcall构建的。仅当 ajaxcall 调用弹出窗口时,编辑器才第一次正确呈现。关闭弹出窗口后,当我再次打开弹出窗口时,编辑器不会渲染,它只会显示带有 HTML 代码的文本区域?有什么办法解决这个问题吗。
小MCE 4.1.3
没有显示错误!
我正在使用一个简短的 Jquery 脚本来实时预览一些输入字段。现在使用 TinyMCE,我无法获取tinyMCE 的值以将其插入 div 中。我发现了另一个线程Get value of tinymce textarea with jquery selector,但我真的不知道如何在我的代码中使用这个tipps。我是 jQuery 的初学者,非常感谢每一个帮助。
$(document).ready(function() {
updatePreview();
$('#live-preview-form input, #live-preview-form textarea').bind('blur keyup',updatePreview);
});
function updatePreview(){
var tinymce = $('#lp-message');
tinymce.html($('#message').val());
}
Run Code Online (Sandbox Code Playgroud) 我尝试在 WordPress 管理区域中使用 Tinymce 编辑器的 getContent 功能,但无济于事。
这是我想做的工作笔
https://codepen.io/anon/pen/oWxjyM?editors=1111
超文本标记语言
<textarea class="wp-editor-area" rows="20" autocomplete="off" cols="40" name="wprss_ftp_post_prepend" id="wprsspostprepend"><p>To give is good</p></textarea>
Run Code Online (Sandbox Code Playgroud)
JS
jQuery(document).ready(function() {
$("#wprsspostprepend").addClass("prepend_editor");
var name = "wprsspostprepend";
if($("#" + name).length > 0) {
tinyMCE.init({
mode : "specific_textareas",
editor_selector : "prepend_editor"
});
var content = tinyMCE.activeEditor.getContent();
alert(content);
tinyMCE.activeEditor.setContent("<div id='random-wrap'>" + content + "</div>");
}
});
Run Code Online (Sandbox Code Playgroud)
如果它在 codepen 中工作,为什么我会在 WordPress 中收到空引用错误。
我正在尝试在我的项目中使用angular2-tinymce库。我已成功将tinymce集成到我的模块中。但是当tinymce编辑器中发生任何更改时,我无法触发更改事件的任何回调。
// in add-progress-note.module.ts file
@NgModule({
declarations: [
AddProgressNotePage,
],
imports: [
IonicPageModule.forChild(AddProgressNotePage),
TinymceModule.withConfig({
menubar: false,
plugins: ['textcolor'],
toolbar: 'forecolor',
resize: false,
statusbar: false
})
]
})
// in add-progress-note.html file
<ion-row class="note-editor" id="noteArea">
<app-tinymce class="note-input-textarea" [(ngModel)]='noteText' (change)="onChangeNote()"></app-tinymce>
</ion-row>
// in add-progress-note.ts file
onChangeNote(): void {
console.log(this.noteText);
}
Run Code Online (Sandbox Code Playgroud)
我的 onChangeNote 没有触发。
如何为tinymce编辑器中的任何更改事件触发回调事件?
我在 Angular 5 项目中使用 TinyMCE 编辑器,并且想要处理图像上传,但我目前无法做到这一点。这是我当前的代码:
<editor
name="questionStatement"
apiKey="somekey"
[init]='{
plugins : [
"advlist autolink lists link image charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars code fullscreen",
"insertdatetime media nonbreaking save table contextmenu directionality",
"emoticons template paste textcolor colorpicker textpattern"
],
toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
past_date_images: true,
external_plugins: { tiny_mce_wiris: "https://www.wiris.net/demo/plugins/tiny_mce/plugin.js" },
toolbar: "tiny_mce_wiris_formulaEditor, tiny_mce_wiris_formulaEditorChemistry"
}'
</editor>
Run Code Online (Sandbox Code Playgroud)
将tinyMCE 与Angular 结合使用,我需要在光标位置插入文本,最好使用工具栏按钮。
据我了解,我需要onExecCommand通过命令使用该事件mceInsertContent。
我查看了以下内容:
但这些解决方案在这种情况下没有帮助。
<editor [init]="tinyMceConfig"
[formControl]="data.formControl">
</editor>
Run Code Online (Sandbox Code Playgroud)
/* ... */
export class EditorDialogComponent implements OnInit {
tinyMceConfig: any;
constructor(
/* ... */
) { }
ngOnInit() {
this.configureTinyMce();
}
configureTinyMce() {
this.tinyMceConfig = {
theme: 'modern',
menubar: false,
branding: false,
height: 400,
skin_url: 'assets/tinymce/skins/lightgray',
inline: false,
plugins: [
'advlist lists link image directionality',
'searchreplace visualblocks visualchars media table contextmenu paste textcolor colorpicker pagebreak code'
],
// …Run Code Online (Sandbox Code Playgroud) 对于博客文件,由 php foreach 循环创建的所有文章评论都有自己的Reply按钮,用于在 textarea 中打开带有 tinymce 的模式对话框。注意,当有评论时,页面加载需要一些时间。当我查看浏览器检查器时,我看到最后 tiny 正在为每个 textarea 加载一个“sink”元素,就在以下内容的关闭标记之前body:
<div class="tox tox-silver-sink tox-tinymce-aux" style="position: relative;"></div>
<div class="tox tox-silver-sink tox-tinymce-aux" style="position: relative;"></div>
<div class="tox tox-silver-sink tox-tinymce-aux" style="position: relative;"></div>
<div class="tox tox-silver-sink tox-tinymce-aux" style="position: relative;"></div>
<div class="tox tox-silver-sink tox-tinymce-aux" style="position: relative;"></div>
....and so on...
Run Code Online (Sandbox Code Playgroud)
这些 div 的加载需要一些时间,并且会降低页面加载的性能。我可以做些什么来提高页面加载的性能?
我们正在尝试使用 Webpacker(和 Stimulus)将我们的应用程序升级到 Rails 6。除了 TinyMCE 之外,一切都很顺利。我们有两个问题,我会在单独的问题中问他们。
我们安装 TinyMCE 使用
yarn add tinymce
Run Code Online (Sandbox Code Playgroud)
并且有版本5.3.0
在我们的刺激控制器标头中,我们有:
import tinymce from 'tinymce/tinymce';
import 'tinymce/themes/silver';
import 'tinymce/skins/ui/oxide/skin.min';
import 'tinymce/skins/ui/oxide/content.min';
import 'tinymce/plugins/paste';
import 'tinymce/plugins/link';
Run Code Online (Sandbox Code Playgroud)
然后在控制器connect块中我们有:
connect() {
console.log('gonna reload');
require.context(
'!file-loader?name=[path][name].[ext]&context=node_modules/tinymce&outputPath=js!tinymce/skins',
true,
/.*/
);
tinymce.init({
selector: '.tinymce',
plugins: ['paste', 'link'],
skin: false
});
}
Run Code Online (Sandbox Code Playgroud)
这是基本上有效的代码,除了在控制台中我看到:
VM40 application-68201fac0dcbbcb543e0.js:213771 GET https://xxx.ngrok.io/packs/js/icons/default/icons.js net::ERR_ABORTED 404 (Not Found)
VM40 application-68201fac0dcbbcb543e0.js:224775 Failed to load icons: default from url https://xxx.ngrok.io/packs/js/icons/default/icons.js
Run Code Online (Sandbox Code Playgroud)
我们需要另一个require.context来处理这些的加载吗?
将 TinyMCE 编辑器放置在引导模式中时,该编辑器可见且正常运行,但是当单击菜单项时,菜单不会显示。