editor: canvas links fix
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 7 May 2014 07:25:02 +0000 (09:25 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 7 May 2014 07:41:42 +0000 (09:41 +0200)
src/editor/plugins/core/core.js
src/editor/plugins/core/links/linkElement.js

index 150464e..ade5d93 100644 (file)
@@ -274,13 +274,12 @@ var createLinkFromSelection = function(callback, params) {
     dialog.on('execute', function(event) {
         doc.transaction(function() {
             var span =  action.params.fragment.startNode.parent().wrapText({
-                _with: {tagName: 'span', attrs: {'class': 'link'}},
+                _with: {tagName: 'span', attrs: {'class': 'link', href: event.formData.href }},
                 offsetStart: params.fragment.startOffset,
                 offsetEnd: params.fragment.endOffset,
                 textNodeIdx: [params.fragment.startNode.getIndex(), params.fragment.endNode.getIndex()]
             }),
                 doc = params.fragment.document;
-            span.setAttr('href', event.formData.href);
             event.success();
             return doc.createFragment(doc.CaretFragment, {node: span.contents()[0], offset:0});
         }, {
index fdb60e1..8a9edd7 100644 (file)
@@ -17,7 +17,7 @@ _.extend(linkElement, {
         genericElement.init.call(this);
         _.bindAll(this, 'changeLink', 'deleteLink');
 
-        var linkText = this.wlxmlNode.getAttr('href'),
+        var linkText = this.wlxmlNode.getAttr('href') || '',
             linkUrl = this.getUrl(linkText);
 
         this.box = $(_.template(boxTemplate)({text: linkText, url: linkUrl}));