+ \r
+ view.node.on('change', '.rng-visualEditor-editPaneSelectionForm select', function(e) {\r
+ var target = $(e.target);\r
+ var selection = window.getSelection();\r
+ if(selection.anchorNode.isSameNode(selection.focusNode) && selection.anchorNode.nodeType === Node.TEXT_NODE) { \r
+ var startOffset = selection.anchorOffset;\r
+ var endOffset = selection.focusOffset;\r
+ if(startOffset > endOffset) {\r
+ var tmp = startOffset;\r
+ startOffset = endOffset;\r
+ endOffset = tmp;\r
+ }\r
+ var node = selection.anchorNode;\r
+ var prefix = node.data.substr(0, startOffset);\r
+ var suffix = node.data.substr(endOffset);\r
+ var core = node.data.substr(startOffset, endOffset - startOffset);\r
+ $(node).replaceWith(prefix + '<span wlxml-tag="' + target.val() + '">' + core + '</span>' + suffix); \r
+ isDirty = true;\r
+ }\r
+ });\r