我需要选择刚刚插入Froala textarea的一大块文本。以下是我尝试过的内容:
// wrapper is used to get the outerHTML
var wrapper = $('<span/>');
var content = $('<p/>', { 'class': 'schedule' });
content.html(value);
wrapper.append(content);
editor.froalaEditor('html.insert', wrapper.html());
editor.froalaEditor('selection.setAtEnd', $('.schedule')[0]);
还尝试添加selection.setAtStart
电话;使用markers
模块;添加selection.restore
;关注textarea,以及其他一些尝试,但没有任何效果。
如何实现这一目标?
感谢。
答案 0 :(得分:1)
所以在搜索了Froala的GitHub问题后,我发现了这个:
$('#editor').html('<p></p>');
$('#editor').froalaEditor();
var $p = $('#editor').data('froala.editor').$el.find('p:first');
$p.html('foo' + $.FroalaEditor.START_MARKER + 'bar' + $.FroalaEditor.END_MARKER);
$('#editor').froalaEditor('selection.restore');
(来源:https://github.com/froala/wysiwyg-editor/issues/803)
看起来有一种特殊的方式来选择插入的内容,文档没有提到它。