fnp
/
fnpeditor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
editor: Setting descriptions for transactions performed in actions
[fnpeditor.git]
/
src
/
editor
/
modules
/
documentCanvas
/
canvas
/
keyboard.js
diff --git
a/src/editor/modules/documentCanvas/canvas/keyboard.js
b/src/editor/modules/documentCanvas/canvas/keyboard.js
index
f879851
..
9be3dae
100644
(file)
--- a/
src/editor/modules/documentCanvas/canvas/keyboard.js
+++ b/
src/editor/modules/documentCanvas/canvas/keyboard.js
@@
-4,7
+4,7
@@
define([
], function(documentElement, utils) {
'use strict';
], function(documentElement, utils) {
'use strict';
-
+/* globals gettext */
var KEYS = {
ENTER: 13,
var KEYS = {
ENTER: 13,
@@
-50,7
+50,7
@@
handlers.push({key: KEYS.ENTER,
if(Object.keys(cursor.getPosition()).length === 0) {
var currentElement = canvas.getCurrentNodeElement();
if(currentElement) {
if(Object.keys(cursor.getPosition()).length === 0) {
var currentElement = canvas.getCurrentNodeElement();
if(currentElement) {
- canvas.wlxmlDocument.startTransaction();
+ canvas.wlxmlDocument.startTransaction(
gettext('Splitting text')
);
added = currentElement.wlxmlNode.after({
tagName: currentElement.getWlxmlTag() || 'div',
attrs: {'class': currentElement.getWlxmlClass() || 'p'}
added = currentElement.wlxmlNode.after({
tagName: currentElement.getWlxmlTag() || 'div',
attrs: {'class': currentElement.getWlxmlClass() || 'p'}
@@
-68,7
+68,7
@@
handlers.push({key: KEYS.ENTER,
element = element.parent();
}
element = element.parent();
}
- canvas.wlxmlDocument.startTransaction();
+ canvas.wlxmlDocument.startTransaction(
gettext('Splitting text')
);
added = element.wlxmlNode.after(
{tagName: element.getWlxmlTag() || 'div', attrs: {'class': element.getWlxmlClass() || 'p'}}
);
added = element.wlxmlNode.after(
{tagName: element.getWlxmlTag() || 'div', attrs: {'class': element.getWlxmlClass() || 'p'}}
);
@@
-100,9
+100,13
@@
handlers.push({key: KEYS.ENTER,
// goto = nodes.second;
// gotoOptions = {caretTo: 'start'};
// }
// goto = nodes.second;
// gotoOptions = {caretTo: 'start'};
// }
+ var node = position.element.wlxmlNode,
+ result, goto, gotoOptions;
+
+ node.document.transaction(function() {
+ result = position.element.wlxmlNode.breakContent({offset: position.offset});
+ }, this, gettext('Splitting text'));
- var result = position.element.wlxmlNode.breakContent({offset: position.offset}),
- goto, gotoOptions;
if(result.emptyText) {
goto = result.emptyText;
gotoOptions = {};
if(result.emptyText) {
goto = result.emptyText;
gotoOptions = {};
@@
-183,11
+187,14
@@
handlers.push({keys: [KEYS.BACKSPACE, KEYS.DELETE],
var cursor = canvas.getCursor(),
position = canvas.getCursor().getPosition(),
element = position.element,
var cursor = canvas.getCursor(),
position = canvas.getCursor().getPosition(),
element = position.element,
- node = element
.wlxmlNode
,
+ node = element
? element.wlxmlNode : null
,
direction = 'above',
caretTo = 'end',
goto;
direction = 'above',
caretTo = 'end',
goto;
+ if(!element || !node) {
+ return;
+ }
if(event.which === KEYS.DELETE) {
direction = 'below';
if(event.which === KEYS.DELETE) {
direction = 'below';