X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/762797788fd3c0256a14b0f343410f40d34d4d8e..b5a1f98a2118706355925314bfe3027ba45464e8:/modules/visualEditor.js diff --git a/modules/visualEditor.js b/modules/visualEditor.js index cef7de7..65de452 100644 --- a/modules/visualEditor.js +++ b/modules/visualEditor.js @@ -1,5 +1,6 @@ -rng.modules.visualEditor = function(sandbox) { - var transformations = rng.modules.visualEditor.transformations; +define(['./visualEditor.transformations'], function(transformations) { + +return function(sandbox) { var view = { node: $(sandbox.getTemplate('main')()), @@ -277,6 +278,7 @@ rng.modules.visualEditor = function(sandbox) { var view = this; this.node.find('#rng-visualEditor-sidebarButtons a').click(function(e) { e.preventDefault(); + e.stopPropagation(); var target = $(e.currentTarget); if(!target.attr('data-content-id')) return; @@ -353,7 +355,7 @@ rng.modules.visualEditor = function(sandbox) { mediator.toolbarButtonToggled(btn.attr('data-btn'), btn.hasClass('active')); } if(btn.attr('data-btn-type') === 'cmd') { - mediator.toolbarButtonCmd(btn.attr('data-btn')); + mediator.toolbarButtonCmd(btn.attr('data-btn'), btn.attr('data-meta')); } }); }, @@ -425,12 +427,19 @@ rng.modules.visualEditor = function(sandbox) { if(btn === 'tags') view.toggleTags(toggle); }, - toolbarButtonCmd: function(btn) { + toolbarButtonCmd: function(btn, meta) { if(btn === 'new-node') { + var wlxmlTag = toolbarView.getOption('newTag-tag'); + var wlxmlClass = toolbarView.getOption('newTag-class'); + if(meta) { + var split = meta.split('/'); + wlxmlTag = split[0]; + wlxmlClass = split[1]; + } if(window.getSelection().isCollapsed) - view.insertNewNode(toolbarView.getOption('newTag-tag'), toolbarView.getOption('newTag-class')); + view.insertNewNode(wlxmlTag, wlxmlClass); else { - this.wrapWithNodeRequest(toolbarView.getOption('newTag-tag'), toolbarView.getOption('newTag-class')); + this.wrapWithNodeRequest(wlxmlTag, wlxmlClass); } @@ -486,4 +495,6 @@ rng.modules.visualEditor = function(sandbox) { } } -}; \ No newline at end of file +}; + +}); \ No newline at end of file