Angular 将所选内容复制到对话框TinyMCE plugin中的输入文本框
我想将所选内容从编辑器复制到自定义插件对话框中的文本框中Angular 将所选内容复制到对话框TinyMCE plugin中的输入文本框,angular,tinymce,tinymce-plugins,Angular,Tinymce,Tinymce Plugins,我想将所选内容从编辑器复制到自定义插件对话框中的文本框中 return editor.windowManager.open({ title: 'Example plugin', body: { type: 'panel', items: [ { type: 'input', name: 'title', label: 'Title' } ] }, buttons: [ {
return editor.windowManager.open({
title: 'Example plugin',
body: {
type: 'panel',
items: [
{
type: 'input',
name: 'title',
label: 'Title'
}
]
},
buttons: [
{
type: 'cancel',
text: 'Close'
},
{
type: 'submit',
text: 'Save',
primary: true
}
],
onSubmit: function (api) {
var data = api.getData();
// Insert content when the window form is submitted
editor.insertContent('Title: ' + data.title);
api.close();
}
});
})
现在,我想获取所选内容(editor.selection.getContent())的名称,并将其加载到输入字段名“title”中。我该怎么做?编辑器.windowManager.open()的返回值是一个对话框实例API,它有一个
setData
方法
tinymce.init({
selector: '#textarea',
setup: function(editor) {
editor.ui.registry.addButton('example_button', {
icon: 'embed-page',
onAction: function() {
var api=editor.windowManager.open(dialogConfig);
var data=api.getData();
var selectedNode = tinymce.activeEditor.selection.getNode();
// do it here
data.title=selectedNode.innerHTML();
api.setData(data);
}
}
}
})
代码通过单击工具栏按钮获取打开的对话框的API,并使用
setData
在对话框实例中保存数据结构(请参见对话框UI文档中的initialData
,getData()
,setData()
)。这是窗体和所选对象之间的连接。编辑器.windowManager.open()的返回值是一个对话框实例API,它有一个setData
方法
tinymce.init({
selector: '#textarea',
setup: function(editor) {
editor.ui.registry.addButton('example_button', {
icon: 'embed-page',
onAction: function() {
var api=editor.windowManager.open(dialogConfig);
var data=api.getData();
var selectedNode = tinymce.activeEditor.selection.getNode();
// do it here
data.title=selectedNode.innerHTML();
api.setData(data);
}
}
}
})
代码通过单击工具栏按钮获取打开的对话框的API,并使用setData
在对话框实例中保存数据结构(请参见对话框UI文档中的initialData
,getData()
,setData()
)。这是窗体和选定对象之间的连接