X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/66aae866400efc99684f51486f8ce1ebb7f59404..87cdc842b0f5f80d78ecb3cbbc3ce5c6ed6a7e62:/modules/visualEditor.js diff --git a/modules/visualEditor.js b/modules/visualEditor.js index 1c61ef0..d5ff4b5 100644 --- a/modules/visualEditor.js +++ b/modules/visualEditor.js @@ -315,16 +315,18 @@ rng.modules.visualEditor = function(sandbox) { }, updateEditPane: function(node) { var pane = this.node.find('#rng-visualEditor-edit'); + var parentClass = node.parent().attr('wlxml-class'); pane.html( $(sandbox.getTemplate('editPane')({tag: node.attr('wlxml-tag'), klass: node.attr('wlxml-class')}))); var parent = node.parent('[wlxml-tag]').length ? { - repr: node.parent().attr('wlxml-tag') + ' / ' + (node.parent().attr('wlxml-class') || '[[no class]]'), + repr: node.parent().attr('wlxml-tag') + (parentClass ? ' / ' + parentClass : ''), id: node.parent().attr('id') } : undefined; var children = []; node.children('[wlxml-tag]').each(function() { var child = $(this); - children.push({repr: child.attr('wlxml-tag') + ' / ' + (child.attr('wlxml-class') || '[[no class]]'), id: child.attr('id')}); + var childClass = child.attr('wlxml-class'); + children.push({repr: child.attr('wlxml-tag') + (childClass ? ' / ' + childClass : ''), id: child.attr('id')}); }); var naviTemplate = sandbox.getTemplate('editPaneNavigation')({parent: parent, children: children}); pane.find('.rng-visualEditor-editPaneSurrouding > div').html($(naviTemplate)); @@ -351,7 +353,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')); } }); }, @@ -423,12 +425,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); }