toggle writing mode bookmark
This commit is contained in:
File diff suppressed because one or more lines are too long
2
public/js/app/page-min.js
vendored
2
public/js/app/page-min.js
vendored
File diff suppressed because one or more lines are too long
2
public/js/common-min.js
vendored
2
public/js/common-min.js
vendored
File diff suppressed because one or more lines are too long
@ -810,18 +810,54 @@ function reIsOk(re) {
|
||||
// marker
|
||||
// 下拉扩展工具栏用, 点击文档导航用
|
||||
LEA.bookmark = null;
|
||||
LEA.hasBookmark = false;
|
||||
function saveBookmark() {
|
||||
try {
|
||||
bookmark = tinymce.activeEditor.selection.getBookmark(); // 光标, 为了处理后重新定位到那个位置
|
||||
LEA.bookmark = tinymce.activeEditor.selection.getBookmark(); // 光标, 为了处理后重新定位到那个位置
|
||||
// 如果之前没有focus, 则会在文档开头设置bookmark, 添加一行, 不行.
|
||||
// $p不是<p>, 很诡异
|
||||
// 6-5
|
||||
if(LEA.bookmark && LEA.bookmark.id) {
|
||||
var $ic = $($("#editorContent_ifr").contents());
|
||||
var $body = $ic.find("body");
|
||||
var $p = $body.children().eq(0);
|
||||
// 找到
|
||||
if($p.is("span")) {
|
||||
var $children = $p;
|
||||
var $c = $children.eq(0);
|
||||
if($c.attr("id") == LEA.bookmark.id + "_start") {
|
||||
LEA.hasBookmark = false;
|
||||
$c.remove();
|
||||
} else {
|
||||
LEA.hasBookmark = true;
|
||||
}
|
||||
} else if($p.is("p")) {
|
||||
var $children = $p.children();
|
||||
if($children.length == 1 && $.trim($p.text()) == "") {
|
||||
var $c = $children.eq(0);
|
||||
if($c.attr("id") == LEA.bookmark.id + "_start") {
|
||||
LEA.hasBookmark = false;
|
||||
$p.remove();
|
||||
} else {
|
||||
LEA.hasBookmark = true;
|
||||
}
|
||||
} else {
|
||||
LEA.hasBookmark = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch(e) {
|
||||
}
|
||||
}
|
||||
function restoreBookmark() {
|
||||
try {
|
||||
if(LEA.hasBookmark) {
|
||||
// 必须要focus()!!!
|
||||
var editor = tinymce.activeEditor;
|
||||
editor.focus();
|
||||
editor.selection.moveToBookmark(LEA.bookmark);
|
||||
}
|
||||
} catch(e) {
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user