From: Aleksander Ɓukasz Date: Fri, 19 Apr 2013 09:14:18 +0000 (+0200) Subject: Visual editor: simple tagging capability X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/9201c5810622e27a19de7e331046108d7110c46b?ds=sidebyside;hp=1ffafa96f9858a9eb43d3a66d7593ae0cbf090d1 Visual editor: simple tagging capability --- diff --git a/editor.css b/editor.css index 916239e..aa920c8 100644 --- a/editor.css +++ b/editor.css @@ -68,6 +68,7 @@ body { } +#rng-visualEditor-sidebar, #rng-visualEditor-sidebar p, #rng-visualEditor-sidebar td, #rng-visualEditor-sidebar label, @@ -109,15 +110,30 @@ body { margin-bottom: 0px; } -.rng-visualEditor-editPaneNodeForm label { +.rng-visualEditor-editPaneNodeForm label , +.rng-visualEditor-editPaneSelectionForm label +{ width: 50px; display: inline-block; } -.rng-visualEditor-editPaneNodeForm select { +.rng-visualEditor-editPaneNodeForm select, +.rng-visualEditor-editPaneSelectionForm select + { width: 100px; } + + +.rng-visualEditor-sidebarContentItem fieldset { + margin-bottom: 10px; +} + +.rng-visualEditor-sidebarContentItem legend { + font-size:11px; + height:30px; +} + #rng-visualEditor-meta table { margin-bottom:10px; } diff --git a/modules/visualEditor.js b/modules/visualEditor.js index 8a96cb9..70fc435 100644 --- a/modules/visualEditor.js +++ b/modules/visualEditor.js @@ -127,6 +127,26 @@ rng.modules.visualEditor = function(sandbox) { mediator.getCurrentNode().attr('wlxml-'+attr, target.val()); isDirty = true; }); + + view.node.on('change', '.rng-visualEditor-editPaneSelectionForm select', function(e) { + var target = $(e.target); + var selection = window.getSelection(); + if(selection.anchorNode.isSameNode(selection.focusNode) && selection.anchorNode.nodeType === Node.TEXT_NODE) { + var startOffset = selection.anchorOffset; + var endOffset = selection.focusOffset; + if(startOffset > endOffset) { + var tmp = startOffset; + startOffset = endOffset; + endOffset = tmp; + } + var node = selection.anchorNode; + var prefix = node.data.substr(0, startOffset); + var suffix = node.data.substr(endOffset); + var core = node.data.substr(startOffset, endOffset - startOffset); + $(node).replaceWith(prefix + '' + core + '' + suffix); + isDirty = true; + } + }); }, selectTab: function(id) { this.node.find('.rng-visualEditor-sidebarContentItem').hide();