editor: canvas keys handling - wrapping document transformations in transactions
[fnpeditor.git] / src / editor / plugins / core / core.js
1 define(function(require) {
2     
3 'use strict';
4
5 var _ = require('libs/underscore'),
6     plugin = {documentExtension: {textNode: {}}};
7
8
9 plugin.documentExtension.textNode.transformations = {
10     breakContent: {
11         impl: function(args) {
12             var node = this,
13                 newNodes, emptyText;
14             newNodes = node.split({offset: args.offset});
15             [newNodes.first, newNodes.second].some(function(newNode) {
16                 if(!(newNode.contents().length)) {
17                     emptyText = newNode.append({text: ''});
18                     return true; // break
19                 }
20             });
21             return _.extend(newNodes, {emptyText: emptyText});
22         },
23         getChangeRoot: function() {
24             return this.context.parent().parent();
25         }
26     }
27 };
28
29 return plugin;
30
31 });