fnp
/
fnpeditor.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
31f486a
)
save caret position when ending a list
author
Jan Szejko
<janek37@gmail.com>
Thu, 23 Feb 2017 12:50:17 +0000
(13:50 +0100)
committer
Jan Szejko
<janek37@gmail.com>
Thu, 23 Feb 2017 12:50:17 +0000
(13:50 +0100)
src/editor/plugins/core/lists.js
patch
|
blob
|
history
diff --git
a/src/editor/plugins/core/lists.js
b/src/editor/plugins/core/lists.js
index
1ff6ccd
..
750fb7e
100644
(file)
--- a/
src/editor/plugins/core/lists.js
+++ b/
src/editor/plugins/core/lists.js
@@
-92,14
+92,16
@@
var toggleListAction = function(type) {
if(current.parent().is('item') && current.parent().parent().is('list') && current.parent().next() === null) {
var item = current.parent();
var list = item.parent();
if(current.parent().is('item') && current.parent().parent().is('list') && current.parent().next() === null) {
var item = current.parent();
var list = item.parent();
- current.document.transaction(function() {
+ var doc = current.document;
+ doc.transaction(function() {
var p = list.after({tagName: 'div', attrs: {'class': 'p'}});
p.append({text: current.getText()});
item.detach();
if(list.contents().length === 0) {
list.detach();
}
var p = list.after({tagName: 'div', attrs: {'class': 'p'}});
p.append({text: current.getText()});
item.detach();
if(list.contents().length === 0) {
list.detach();
}
- return current.document.createFragment(current.document.NodeFragment, {node: p});
+ return doc.createFragment(
+ doc.CaretFragment, {node: p.contents()[0], offset: params.fragment.offset});
}, {
metadata: {
description: action.getState().description,
}, {
metadata: {
description: action.getState().description,
@@
-113,14
+115,15
@@
var toggleListAction = function(type) {
var toSearch = current.nodeType === Node.ELEMENT_NODE ? [current] : [];
toSearch = toSearch.concat(current.parents());
toSearch.some(function(node) {
var toSearch = current.nodeType === Node.ELEMENT_NODE ? [current] : [];
toSearch = toSearch.concat(current.parents());
toSearch.some(function(node) {
+ var doc = node.document;
if(node.is('list')) {
if(node.is('list')) {
-
node.document
.transaction(function() {
+
doc
.transaction(function() {
var firstItem = node.object.extractListItems(),
toret;
if(params.fragment.isValid()) {
toret = params.fragment;
} else {
var firstItem = node.object.extractListItems(),
toret;
if(params.fragment.isValid()) {
toret = params.fragment;
} else {
- toret =
node.document.createFragment(node.document
.NodeFragment, {node: firstItem});
+ toret =
doc.createFragment(doc
.NodeFragment, {node: firstItem});
}
return toret;
}, {
}
return toret;
}, {