diff --git a/core-js/src/main/javascript/Utils.js b/core-js/src/main/javascript/Utils.js index a4b03f2f..49e53258 100644 --- a/core-js/src/main/javascript/Utils.js +++ b/core-js/src/main/javascript/Utils.js @@ -16,12 +16,8 @@ * limitations under the License. */ -core.Utils = -{ - escapeInvalidTags: function (text) { - //todo:Pablo. scape invalid tags in a text - return text; - } +core.Utils = { + }; /** diff --git a/mindplot/src/main/javascript/DesignerKeyboard.js b/mindplot/src/main/javascript/DesignerKeyboard.js index 0f474a93..7999eb61 100644 --- a/mindplot/src/main/javascript/DesignerKeyboard.js +++ b/mindplot/src/main/javascript/DesignerKeyboard.js @@ -27,7 +27,6 @@ mindplot.DesignerKeyboard = new Class({ _registerEvents : function(designer) { - // Try with the keyboard .. var model = designer.getModel(); var keyboardEvents = { @@ -220,10 +219,17 @@ mindplot.DesignerKeyboard = new Class({ } // If it's not registered, let's - if (!isRegistered && !excludes.contains(key) && !modifiers.contains(key) && !key.contains('meta') && !key.contains('ctrl') && !key.contains('control')) { + if (!isRegistered && !excludes.contains(key) && 'meta+[' != key) { var nodes = designer.getModel().filterSelectedTopics(); if (nodes.length > 0) { - nodes[0].showTextEditor(event.key); + + // If a modifier is press, the key selected must be ignored. + var pressKey = event.key; + if (modifiers.contains(key)) { + pressKey = ""; + } + + nodes[0].showTextEditor(pressKey); event.stopPropagation(); } } @@ -322,6 +328,7 @@ mindplot.DesignerKeyboard = new Class({ // Give focus to the selected node.... node.setOnFocus(true); } + }); mindplot.DesignerKeyboard.register = function(designer) { diff --git a/mindplot/src/main/javascript/MainTopic.js b/mindplot/src/main/javascript/MainTopic.js index d5ef792d..2dfce8e1 100644 --- a/mindplot/src/main/javascript/MainTopic.js +++ b/mindplot/src/main/javascript/MainTopic.js @@ -139,7 +139,7 @@ mindplot.MainTopic = new Class({ _updatePositionOnChangeSize : function(oldSize, newSize, updatePosition) { - if (updatePosition == false && this.getModel().getFinalPosition()) { + if (!updatePosition && this.getModel().getFinalPosition()) { this.setPosition(this.getModel().getFinalPosition(), false); } else { diff --git a/mindplot/src/main/javascript/MultilineTextEditor.js b/mindplot/src/main/javascript/MultilineTextEditor.js index fe4031d8..055a32db 100644 --- a/mindplot/src/main/javascript/MultilineTextEditor.js +++ b/mindplot/src/main/javascript/MultilineTextEditor.js @@ -17,6 +17,7 @@ */ mindplot.MultilineTextEditor = new Class({ + Extends: Events, initialize:function(topic) { this._topic = topic; }, @@ -41,7 +42,7 @@ mindplot.MultilineTextEditor = new Class({ ); textareaElem.setStyles({ - border: "0 none", + border: "1px gray dashed", background:"transparent", outline: '0 none', resize: 'none', @@ -70,13 +71,22 @@ mindplot.MultilineTextEditor = new Class({ } break; } - this._adjustEditorSize(); event.stopPropagation(); }.bind(this)); + textareaElem.addEvent('keypress', function(event) { + event.stopPropagation(); + }); + + textareaElem.addEvent('keyup', function(event) { + var text = this._getTextareaElem().value; + this.fireEvent('input', [event, text]); + this._adjustEditorSize(); + }.bind(this)); textareaElem.addEvent('blur', function() { - this.close(true); + // @Todo: Issues if this is enables and esc is pressed. +// this.close.bind(this).attempt(true); }.bind(this)); // If the user clicks on the input, all event must be ignored ... @@ -93,21 +103,24 @@ mindplot.MultilineTextEditor = new Class({ _adjustEditorSize : function() { - var textElem = this._getTextareaElem(); - var lines = textElem.value.split('\n'); - var maxLineLength = 5; - lines.forEach(function(line) { - if (maxLineLength < line.length) - maxLineLength = line.length; - }); + if (this.isVisible()) { + var textElem = this._getTextareaElem(); - textElem.setAttribute('cols', maxLineLength + 3); - textElem.setAttribute('rows', lines.length); + var lines = textElem.value.split('\n'); + var maxLineLength = 1; + lines.forEach(function(line) { + if (maxLineLength < line.length) + maxLineLength = line.length; + }); - this._containerElem.setStyles({ - width: maxLineLength + 'em', - height: textElem.getSize().height - }); + textElem.setAttribute('cols', maxLineLength); + textElem.setAttribute('rows', lines.length); + + this._containerElem.setStyles({ + width: (maxLineLength + 3) + 'em', + height: textElem.getSize().height + }); + } }, isVisible : function () { @@ -152,10 +165,6 @@ mindplot.MultilineTextEditor = new Class({ font.color = nodeText.getColor(); this._setStyle(font); - // Set editor's initial text - var text = $defined(defaultText) ? defaultText : topic.getText(); - this._setText(text); - // Set editor's initial size var displayFunc = function() { // Position the editor and set the size... @@ -166,6 +175,11 @@ mindplot.MultilineTextEditor = new Class({ }); this._containerElem.setStyle('display', 'block'); + // Set editor's initial text ... + var text = $defined(defaultText) ? defaultText : topic.getText(); + this._setText(text); + + // Set the element focus and select the current text ... var inputElem = this._getTextareaElem(); inputElem.focus(); this._changeCursor(inputElem, $defined(defaultText)); @@ -214,12 +228,12 @@ mindplot.MultilineTextEditor = new Class({ return this._containerElem.getElement('textarea'); }, - _changeCursor : function(inputElem, selectText) { + _changeCursor : function(textareaElem, selectText) { // Select text if it's required ... - if (inputElem.createTextRange) //ie + if (textareaElem.createTextRange) //ie { - var range = inputElem.createTextRange(); - var pos = inputElem.value.length; + var range = textareaElem.createTextRange(); + var pos = textareaElem.value.length; if (!selectText) { range.select(); range.move("character", pos); @@ -230,7 +244,7 @@ mindplot.MultilineTextEditor = new Class({ } } else if (!selectText) { - inputElem.setSelectionRange(0, inputElem.value.length); + textareaElem.setSelectionRange(0, textareaElem.value.length); } }, diff --git a/mindplot/src/main/javascript/Note.js b/mindplot/src/main/javascript/Note.js index 43b0a017..cbe17f48 100644 --- a/mindplot/src/main/javascript/Note.js +++ b/mindplot/src/main/javascript/Note.js @@ -39,7 +39,7 @@ mindplot.Note = new Class({ }, getText: function() { - return this._text; + return this._textShape; }, getModel : function() { diff --git a/mindplot/src/main/javascript/RichTextEditor.js b/mindplot/src/main/javascript/RichTextEditor.js index 9b177dda..e8543aec 100644 --- a/mindplot/src/main/javascript/RichTextEditor.js +++ b/mindplot/src/main/javascript/RichTextEditor.js @@ -101,9 +101,9 @@ mindplot.RichTextEditor = mindplot.TextEditor.extend({ //becarefull this._editor is not mootools!! this._editor.addEvent('blur',function(event){ this._myOverlay.setStyle('display','none'); - var text = this._text; - this._text = this._editor.instanceById("inputText2").getContent(); - if(text!=this._text){ + var text = this._textShape; + this._textShape = this._editor.instanceById("inputText2").getContent(); + if(text!=this._textShape){ this._applyChanges = true; } console.log('bye'); @@ -118,7 +118,7 @@ mindplot.RichTextEditor = mindplot.TextEditor.extend({ $(this.inputText).focus(); }, getText:function(){ - return this._text; + return this._textShape; }, lostFocusListener:function(){ this._hideNode(); diff --git a/mindplot/src/main/javascript/Topic.js b/mindplot/src/main/javascript/Topic.js index b153f5fd..cf21e489 100644 --- a/mindplot/src/main/javascript/Topic.js +++ b/mindplot/src/main/javascript/Topic.js @@ -53,6 +53,16 @@ mindplot.Topic = new Class({ this._textEditor.show(); event.stopPropagation(true); }.bind(this)); + + this._textEditor.addEvent('input', function(event, text) { + var textShape = this.getTextShape(); +// var oldText = textShape.getText(); + +// this._setText(text, false); + // @Todo: I must resize, no change the position ... +// textShape.setText(oldText); + }.bind(this)); + }, setShapeType : function(type) { @@ -78,8 +88,6 @@ mindplot.Topic = new Class({ // Create a new one ... var innerShape = this.getInnerShape(); - // @Todo: Fix... - //innerShape.cloneEvents(oldInnerShape); // Update figure size ... var size = model.getSize(); @@ -228,14 +236,14 @@ mindplot.Topic = new Class({ }, getTextShape : function() { - if (!$defined(this._text)) { - this._text = this._buildTextShape(false); + if (!$defined(this._textShape)) { + this._textShape = this._buildTextShape(false); // Set Text ... var text = this.getText(); this._setText(text, false); } - return this._text; + return this._textShape; }, getOrBuildIconGroup : function() { @@ -518,12 +526,12 @@ mindplot.Topic = new Class({ _setText : function(text, updateModel) { var textShape = this.getTextShape(); textShape.setText(text); - this._adjustShapes(updateModel); if ($defined(updateModel) && updateModel) { var model = this.getModel(); model.setText(text); } + this._adjustShapes(updateModel); }, setText : function(text) { @@ -1152,7 +1160,6 @@ mindplot.Topic = new Class({ iconGroup.setPosition(topicPadding, topicPadding); iconGroup.seIconSize(fontHeight, fontHeight); - // Add a extra padding between the text and the icons var iconsWidth = iconGroup.getSize().width; if (iconsWidth != 0) { @@ -1169,6 +1176,7 @@ mindplot.Topic = new Class({ // Position node ... textShape.setPosition(topicPadding + iconsWidth, topicPadding); + console.log(textShape.getText() + ":works ?"); }).delay(0, this); }, diff --git a/mindplot/src/main/javascript/collaboration/frameworks/brix/model/NodeModel.js b/mindplot/src/main/javascript/collaboration/frameworks/brix/model/NodeModel.js index 18d04d4c..1870ca6b 100644 --- a/mindplot/src/main/javascript/collaboration/frameworks/brix/model/NodeModel.js +++ b/mindplot/src/main/javascript/collaboration/frameworks/brix/model/NodeModel.js @@ -98,7 +98,7 @@ mindplot.collaboration.frameworks.brix.model.NodeModel = new Class({ result._position = this._position; result._id = this._id; result._mindmap = this._mindmap; - result._text = this._text; + result._textShape = this._textShape; result._shapeType = this._shapeType; result._fontFamily = this._fontFamily; result._fontSize = this._fontSize; @@ -143,7 +143,7 @@ mindplot.collaboration.frameworks.brix.model.NodeModel = new Class({ }, getText : function() { - return this._text; + return this._textShape; }, isNodeModel : function() { diff --git a/mindplot/src/main/javascript/commands/AddNoteToTopicCommand.js b/mindplot/src/main/javascript/commands/AddNoteToTopicCommand.js index 87f1ca32..04cf4b06 100644 --- a/mindplot/src/main/javascript/commands/AddNoteToTopicCommand.js +++ b/mindplot/src/main/javascript/commands/AddNoteToTopicCommand.js @@ -21,13 +21,13 @@ mindplot.commands.AddNoteToTopicCommand = new Class({ initialize: function(topicId, text) { $assert(topicId, 'topicId can not be null'); this._topicsIds = topicId; - this._text = text; + this._textShape = text; this._id = mindplot.Command._nextUUID(); }, execute: function(commandContext) { var topic = commandContext.findTopics(this._topicsIds)[0]; var updated = function() { - topic.addNote(this._text); + topic.addNote(this._textShape); topic._adjustShapes(); }.bind(this); updated.delay(0); diff --git a/mindplot/src/main/javascript/commands/RemoveNoteFromTopicCommand.js b/mindplot/src/main/javascript/commands/RemoveNoteFromTopicCommand.js index ea023576..57201f2e 100644 --- a/mindplot/src/main/javascript/commands/RemoveNoteFromTopicCommand.js +++ b/mindplot/src/main/javascript/commands/RemoveNoteFromTopicCommand.js @@ -26,7 +26,7 @@ mindplot.commands.RemoveNoteFromTopicCommand = new Class({ execute: function(commandContext) { var topic = commandContext.findTopics(this._topicsIds)[0]; - this._text = topic._note.getText(); + this._textShape = topic._note.getText(); var updated = function() { topic.removeNote(); }.bind(this); @@ -36,7 +36,7 @@ mindplot.commands.RemoveNoteFromTopicCommand = new Class({ { var topic = commandContext.findTopics(this._topicsIds)[0]; var updated = function() { - topic.addNote(this._text,commandContext._designer); + topic.addNote(this._textShape,commandContext._designer); topic._adjustShapes(); }.bind(this); updated.delay(0); diff --git a/mindplot/src/main/javascript/model/NodeModel.js b/mindplot/src/main/javascript/model/NodeModel.js index db7ae549..7180c427 100644 --- a/mindplot/src/main/javascript/model/NodeModel.js +++ b/mindplot/src/main/javascript/model/NodeModel.js @@ -38,7 +38,7 @@ mindplot.model.NodeModel = new Class({ this._id = mindplot.model.NodeModel._nextUUID(); } this._mindmap = mindmap; - this._text = null; + this._textShape = null; this._shapeType = null; this._fontFamily = null; this._fontSize = null; @@ -68,7 +68,7 @@ mindplot.model.NodeModel = new Class({ result._position = this._position; result._id = this._id; result._mindmap = this._mindmap; - result._text = this._text; + result._textShape = this._textShape; result._shapeType = this._shapeType; result._fontFamily = this._fontFamily; result._fontSize = this._fontSize; @@ -106,11 +106,11 @@ mindplot.model.NodeModel = new Class({ }, setText : function(text) { - this._text = text; + this._textShape = text; }, getText : function() { - return this._text; + return this._textShape; }, isNodeModel : function() { diff --git a/mindplot/src/main/javascript/model/NoteModel.js b/mindplot/src/main/javascript/model/NoteModel.js index 5a417c7e..87bbaeb1 100644 --- a/mindplot/src/main/javascript/model/NoteModel.js +++ b/mindplot/src/main/javascript/model/NoteModel.js @@ -20,16 +20,16 @@ mindplot.model.NoteModel = new Class({ initialize : function(text, topic) { $assert(text != null, 'note text can not be null'); $assert(topic, 'mindmap can not be null'); - this._text = text; + this._textShape = text; this._topic = topic; }, getText:function() { - return this._text; + return this._textShape; }, setText : function(text) { - this._text = text; + this._textShape = text; }, getTopic : function() { diff --git a/web2d/src/main/javascript/peer/svg/TextPeer.js b/web2d/src/main/javascript/peer/svg/TextPeer.js index c1c88290..c67e2d1b 100644 --- a/web2d/src/main/javascript/peer/svg/TextPeer.js +++ b/web2d/src/main/javascript/peer/svg/TextPeer.js @@ -39,14 +39,12 @@ web2d.peer.svg.TextPeer = new Class({ }, setText : function(text) { - text = core.Utils.escapeInvalidTags(text); var childs = this._native.getChildren(); childs.forEach(function(child) { child.dispose(); }); this._text = text; - this.setVisibility(false); var lines = text.split('\n'); var tspans = []; @@ -61,9 +59,6 @@ web2d.peer.svg.TextPeer = new Class({ this._native.appendChild(tspan); }.bind(this)); - - this.setVisibility(true); - }, getText : function() {