7 var breakContentTransformation = {
9 var node = this.context,
10 newNodes, emptyNode, emptyText;
11 newNodes = node.transform('smartxml.split', {offset: args.offset});
12 [newNodes.first, newNodes.second].some(function(newNode) {
13 if(!(newNode.contents().length)) {
14 newNode.transform('smartxml.append', {text: ''});
18 return _.extend(newNodes, {emptyText: emptyText});
20 isAllowed: function() {
26 var breakContentAction = function(document, context) { //@ editor.getDocument(); editor.getContext('...')
27 var textNode = context.cursor.currentNode;
31 result = textNode.transform('core.break-content', {offset: context.cursor.offset});
33 if(result.emptyText) {
34 goto = result.createdEmpty;
38 gotoOptions = {caretTo: 'start'};
41 context.setCurrentElement(goto, gotoOptions);
44 breakContentAction.isAllowed = function(document, context) {
46 var node = context.cursor.currentNode;
47 return node.nodeType === Node.TEXT_NODE;
52 {key: 'ENTER', target: 'main-document-area', handler: function(editor) {
53 var action = editor.getAction('core.break-document-content');
54 if(action.isAllowed()) {
58 {key: 'ENTER', target: 'main-document-area', actionHandler: 'core.break-document-content'}
63 name: 'core.break-document-content',
64 context: 'main-document-area',
66 icon: 'core:some-name',
67 action: breakContentAction
71 // zapisywanie dokumentu:
73 documentTransformations: [
74 {name: 'core.break-content', textNode: true, t: breakContentTransformation},
76 // transformacja z poziomu smartxml
77 {name: 'core.wrap-with', textNode: true, t: wrapWith}
80 {name: 'list.remove-list', elementNode: 'list', t: null}
81 // hipotetyczna akcja na itemie listy
82 {name: 'list.extract', elementNode: 'item', requiresParent: 'list', requiresInParents: '?'}