问题描述
我正在使用 Joomla 1.7 并且我制作了一个自定义按钮(editor-xtd 插件)我想在当前编辑器内容中插入一些字符串.
I am using Joomla 1.7 and I am made a custom button (editor-xtd plugin)that I want to insert some string into the current editor content.
喜欢阅读更多按钮.我搜索了 Readmore 代码,发现:
Like in the Readmore button. I have searched through the Readmore code and found :
$js = "
function insertReadmore(editor) {
var content = $getContent
if (content.match(/<hrs+id=("|')system-readmore("|')s*/*>/i)) {
alert('$present');
return false;
} else {
jInsertEditorText('<hr id="system-readmore" />', editor);
}
}
";
现在当我尝试调用 jInsertEditorText
时,我似乎收到一个错误,提示它丢失了.
Now when I try to call jInsertEditorText
, I seem to get an error that it's missing.
某些论坛建议我导入 mootools.js,但这似乎并没有奏效.
Some forum suggested I import mootools.js, but that didn't seem to do the trick.
我在哪里可以找到它或者有其他方法吗?
Where can I find it or is there some other approach?
推荐答案
我知道这个问题的答案来得很晚,但是它出现在 Google 的第一页上并且仍然没有答案,所以这里是:
I know that this answer comes in very very late for this question, but it appears on the first page of Google and remains unanswered, so here it is:
自 2012 年以来情况发生了变化,编辑现在必须实现以下两个功能:
Things have changed since 2012 and editors now must implement the following two functions:
// Set value
if (typeof Joomla.editors.instances["jform_editor_name"] !== "undefined") {
Joomla.editors.instances["jform_editor_name"].setValue(ourHTML);
}
// Get value
var text = Joomla.editors.instances["jform_editor_name"].getValue();
这篇关于如何在 Joomla 中以编程方式将文本插入编辑器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!