mirador_rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +13 -0
- data/README.md +97 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/mirador_rails.rb +16 -0
- data/lib/mirador_rails/version.rb +3 -0
- data/lib/mirador_rails/view_helpers.rb +30 -0
- data/mirador_rails.gemspec +30 -0
- data/vendor/assets/images/border_type_1.png +0 -0
- data/vendor/assets/images/border_type_2.png +0 -0
- data/vendor/assets/images/border_type_3.png +0 -0
- data/vendor/assets/images/debut_dark.png +0 -0
- data/vendor/assets/javascripts/mirador.js +1 -0
- data/vendor/assets/javascripts/mirador.min.js +88 -0
- data/vendor/assets/javascripts/mirador.min.js.map +1 -0
- data/vendor/assets/locales/ar/translation.json +42 -0
- data/vendor/assets/locales/de/translation.json +77 -0
- data/vendor/assets/locales/en/translation.json +82 -0
- data/vendor/assets/locales/es/translation.json +35 -0
- data/vendor/assets/locales/fr/translation.json +77 -0
- data/vendor/assets/locales/ga/translation.json +39 -0
- data/vendor/assets/locales/ja/translation.json +82 -0
- data/vendor/assets/locales/ko/translation.json +74 -0
- data/vendor/assets/locales/nl/translation.json +39 -0
- data/vendor/assets/locales/zh-CN/translation.json +74 -0
- data/vendor/assets/locales/zh-TW/translation.json +74 -0
- data/vendor/assets/locales/zh/translation.json +74 -0
- data/vendor/assets/plugins/plugins/advlist/plugin.js +97 -0
- data/vendor/assets/plugins/plugins/advlist/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/anchor/plugin.js +45 -0
- data/vendor/assets/plugins/plugins/anchor/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/autolink/plugin.js +194 -0
- data/vendor/assets/plugins/plugins/autolink/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/autoresize/plugin.js +152 -0
- data/vendor/assets/plugins/plugins/autoresize/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/autosave/plugin.js +165 -0
- data/vendor/assets/plugins/plugins/autosave/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/bbcode/plugin.js +123 -0
- data/vendor/assets/plugins/plugins/bbcode/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/charmap/plugin.js +370 -0
- data/vendor/assets/plugins/plugins/charmap/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/code/plugin.js +60 -0
- data/vendor/assets/plugins/plugins/code/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/colorpicker/plugin.js +112 -0
- data/vendor/assets/plugins/plugins/colorpicker/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/compat3x/css/dialog.css +118 -0
- data/vendor/assets/plugins/plugins/compat3x/img/buttons.png +0 -0
- data/vendor/assets/plugins/plugins/compat3x/img/icons.gif +0 -0
- data/vendor/assets/plugins/plugins/compat3x/img/items.gif +0 -0
- data/vendor/assets/plugins/plugins/compat3x/img/menu_arrow.gif +0 -0
- data/vendor/assets/plugins/plugins/compat3x/img/menu_check.gif +0 -0
- data/vendor/assets/plugins/plugins/compat3x/img/progress.gif +0 -0
- data/vendor/assets/plugins/plugins/compat3x/img/tabs.gif +0 -0
- data/vendor/assets/plugins/plugins/compat3x/plugin.js +297 -0
- data/vendor/assets/plugins/plugins/compat3x/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/compat3x/tiny_mce_popup.js +542 -0
- data/vendor/assets/plugins/plugins/compat3x/utils/editable_selects.js +70 -0
- data/vendor/assets/plugins/plugins/compat3x/utils/form_utils.js +210 -0
- data/vendor/assets/plugins/plugins/compat3x/utils/mctabs.js +164 -0
- data/vendor/assets/plugins/plugins/compat3x/utils/validate.js +252 -0
- data/vendor/assets/plugins/plugins/contextmenu/plugin.js +87 -0
- data/vendor/assets/plugins/plugins/contextmenu/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/directionality/plugin.js +64 -0
- data/vendor/assets/plugins/plugins/directionality/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-cool.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-cry.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-embarassed.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-foot-in-mouth.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-frown.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-innocent.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-kiss.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-laughing.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-money-mouth.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-sealed.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-smile.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-surprised.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-tongue-out.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-undecided.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-wink.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-yell.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/plugin.js +65 -0
- data/vendor/assets/plugins/plugins/emoticons/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/example/dialog.html +8 -0
- data/vendor/assets/plugins/plugins/example/plugin.js +68 -0
- data/vendor/assets/plugins/plugins/example/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/example_dependency/plugin.js +22 -0
- data/vendor/assets/plugins/plugins/example_dependency/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/fullpage/plugin.js +490 -0
- data/vendor/assets/plugins/plugins/fullpage/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/fullscreen/plugin.js +136 -0
- data/vendor/assets/plugins/plugins/fullscreen/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/hr/plugin.js +30 -0
- data/vendor/assets/plugins/plugins/hr/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/image/plugin.js +439 -0
- data/vendor/assets/plugins/plugins/image/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/importcss/plugin.js +195 -0
- data/vendor/assets/plugins/plugins/importcss/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/insertdatetime/plugin.js +121 -0
- data/vendor/assets/plugins/plugins/insertdatetime/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/layer/plugin.js +225 -0
- data/vendor/assets/plugins/plugins/layer/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/legacyoutput/plugin.js +211 -0
- data/vendor/assets/plugins/plugins/legacyoutput/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/link/plugin.js +400 -0
- data/vendor/assets/plugins/plugins/link/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/lists/plugin.js +791 -0
- data/vendor/assets/plugins/plugins/lists/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/media/moxieplayer.swf +0 -0
- data/vendor/assets/plugins/plugins/media/plugin.js +774 -0
- data/vendor/assets/plugins/plugins/media/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/nonbreaking/plugin.js +53 -0
- data/vendor/assets/plugins/plugins/nonbreaking/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/noneditable/plugin.js +540 -0
- data/vendor/assets/plugins/plugins/noneditable/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/pagebreak/plugin.js +88 -0
- data/vendor/assets/plugins/plugins/pagebreak/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/paste/classes/Clipboard.js +634 -0
- data/vendor/assets/plugins/plugins/paste/classes/Plugin.js +110 -0
- data/vendor/assets/plugins/plugins/paste/classes/Quirks.js +159 -0
- data/vendor/assets/plugins/plugins/paste/classes/Utils.js +130 -0
- data/vendor/assets/plugins/plugins/paste/classes/WordFilter.js +493 -0
- data/vendor/assets/plugins/plugins/paste/plugin.dev.js +120 -0
- data/vendor/assets/plugins/plugins/paste/plugin.js +1625 -0
- data/vendor/assets/plugins/plugins/paste/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/preview/plugin.js +88 -0
- data/vendor/assets/plugins/plugins/preview/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/print/plugin.js +32 -0
- data/vendor/assets/plugins/plugins/print/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/save/plugin.js +94 -0
- data/vendor/assets/plugins/plugins/save/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/searchreplace/plugin.js +594 -0
- data/vendor/assets/plugins/plugins/searchreplace/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/spellchecker/classes/DomTextMatcher.js +470 -0
- data/vendor/assets/plugins/plugins/spellchecker/classes/Plugin.js +436 -0
- data/vendor/assets/plugins/plugins/spellchecker/plugin.dev.js +117 -0
- data/vendor/assets/plugins/plugins/spellchecker/plugin.js +996 -0
- data/vendor/assets/plugins/plugins/spellchecker/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/tabfocus/plugin.js +120 -0
- data/vendor/assets/plugins/plugins/tabfocus/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/table/classes/CellSelection.js +176 -0
- data/vendor/assets/plugins/plugins/table/classes/Dialogs.js +749 -0
- data/vendor/assets/plugins/plugins/table/classes/Plugin.js +422 -0
- data/vendor/assets/plugins/plugins/table/classes/Quirks.js +372 -0
- data/vendor/assets/plugins/plugins/table/classes/TableGrid.js +864 -0
- data/vendor/assets/plugins/plugins/table/plugin.dev.js +118 -0
- data/vendor/assets/plugins/plugins/table/plugin.js +2680 -0
- data/vendor/assets/plugins/plugins/table/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/template/plugin.js +262 -0
- data/vendor/assets/plugins/plugins/template/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/textcolor/plugin.js +272 -0
- data/vendor/assets/plugins/plugins/textcolor/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/textpattern/plugin.js +268 -0
- data/vendor/assets/plugins/plugins/textpattern/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/visualblocks/css/visualblocks.css +135 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/address.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/article.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/aside.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/blockquote.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/div.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/dl.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/figure.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/h1.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/h2.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/h3.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/h4.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/h5.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/h6.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/hgroup.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/ol.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/p.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/pre.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/section.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/ul.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/plugin.js +86 -0
- data/vendor/assets/plugins/plugins/visualblocks/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/visualchars/plugin.js +88 -0
- data/vendor/assets/plugins/plugins/visualchars/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/wordcount/plugin.js +69 -0
- data/vendor/assets/plugins/plugins/wordcount/plugin.min.js +1 -0
- data/vendor/assets/skins/skins/lightgray/content.inline.min.css +1 -0
- data/vendor/assets/skins/skins/lightgray/content.min.css +1 -0
- data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.eot +0 -0
- data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.svg +62 -0
- data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.ttf +0 -0
- data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.woff +0 -0
- data/vendor/assets/skins/skins/lightgray/fonts/tinymce.eot +0 -0
- data/vendor/assets/skins/skins/lightgray/fonts/tinymce.svg +63 -0
- data/vendor/assets/skins/skins/lightgray/fonts/tinymce.ttf +0 -0
- data/vendor/assets/skins/skins/lightgray/fonts/tinymce.woff +0 -0
- data/vendor/assets/skins/skins/lightgray/img/anchor.gif +0 -0
- data/vendor/assets/skins/skins/lightgray/img/loader.gif +0 -0
- data/vendor/assets/skins/skins/lightgray/img/object.gif +0 -0
- data/vendor/assets/skins/skins/lightgray/img/trans.gif +0 -0
- data/vendor/assets/skins/skins/lightgray/skin.ie7.min.css +1 -0
- data/vendor/assets/skins/skins/lightgray/skin.min.css +1 -0
- data/vendor/assets/stylesheets/mirador-combined.css +3969 -0
- data/vendor/assets/stylesheets/mirador.css +11 -0
- data/vendor/assets/themes/themes/modern/theme.js +617 -0
- data/vendor/assets/themes/themes/modern/theme.min.js +1 -0
- metadata +318 -0
@@ -0,0 +1 @@
|
|
1
|
+
tinymce.PluginManager.add("media",function(a,b){function c(a){return-1!=a.indexOf(".mp3")?"audio/mpeg":-1!=a.indexOf(".wav")?"audio/wav":-1!=a.indexOf(".mp4")?"video/mp4":-1!=a.indexOf(".webm")?"video/webm":-1!=a.indexOf(".ogg")?"video/ogg":-1!=a.indexOf(".swf")?"application/x-shockwave-flash":""}function d(b){var c=a.settings.media_scripts;if(c)for(var d=0;d<c.length;d++)if(-1!==b.indexOf(c[d].filter))return c[d]}function e(){function b(a){var b,c,f,g;b=d.find("#width")[0],c=d.find("#height")[0],f=b.value(),g=c.value(),d.find("#constrain")[0].checked()&&e&&j&&f&&g&&(a.control==b?(g=Math.round(f/e*g),c.value(g)):(f=Math.round(g/j*f),b.value(f))),e=f,j=g}function c(){k=h(this.value()),this.parent().parent().fromJSON(k)}var d,e,j,k,l=[{name:"source1",type:"filepicker",filetype:"media",size:40,autofocus:!0,label:"Source",onchange:function(a){tinymce.each(a.meta,function(a,b){d.find("#"+b).value(a)})}}];a.settings.media_alt_source!==!1&&l.push({name:"source2",type:"filepicker",filetype:"media",size:40,label:"Alternative source"}),a.settings.media_poster!==!1&&l.push({name:"poster",type:"filepicker",filetype:"image",size:40,label:"Poster"}),a.settings.media_dimensions!==!1&&l.push({type:"container",label:"Dimensions",layout:"flex",align:"center",spacing:5,items:[{name:"width",type:"textbox",maxLength:3,size:3,onchange:b},{type:"label",text:"x"},{name:"height",type:"textbox",maxLength:3,size:3,onchange:b},{name:"constrain",type:"checkbox",checked:!0,text:"Constrain proportions"}]}),k=i(a.selection.getNode()),e=k.width,j=k.height;var n={id:"mcemediasource",type:"textbox",flex:1,name:"embed",value:f(),multiline:!0,label:"Source"};n[m]=c,d=a.windowManager.open({title:"Insert/edit video",data:k,bodyType:"tabpanel",body:[{title:"General",type:"form",onShowTab:function(){k=h(this.next().find("#embed").value()),this.fromJSON(k)},items:l},{title:"Embed",type:"panel",layout:"flex",direction:"column",align:"stretch",padding:10,spacing:10,onShowTab:function(){this.find("#embed").value(g(this.parent().toJSON()))},items:[{type:"label",text:"Paste your embed code below:",forId:"mcemediasource"},n]}],onSubmit:function(){var b,c,d,e;for(b=a.dom.select("img[data-mce-object]"),a.insertContent(g(this.toJSON())),c=a.dom.select("img[data-mce-object]"),d=0;d<b.length;d++)for(e=c.length-1;e>=0;e--)b[d]==c[e]&&c.splice(e,1);a.selection.select(c[0]),a.nodeChanged()}})}function f(){var b=a.selection.getNode();return b.getAttribute("data-mce-object")?a.selection.getContent():void 0}function g(e){var f="";if(!e.source1&&(tinymce.extend(e,h(e.embed)),!e.source1))return"";if(e.source2||(e.source2=""),e.poster||(e.poster=""),e.source1=a.convertURL(e.source1,"source"),e.source2=a.convertURL(e.source2,"source"),e.source1mime=c(e.source1),e.source2mime=c(e.source2),e.poster=a.convertURL(e.poster,"poster"),e.flashPlayerUrl=a.convertURL(b+"/moxieplayer.swf","movie"),tinymce.each(l,function(a){var b,c,d;if(b=a.regex.exec(e.source1)){for(d=a.url,c=0;b[c];c++)d=d.replace("$"+c,function(){return b[c]});e.source1=d,e.type=a.type,e.width=e.width||a.w,e.height=e.height||a.h}}),e.embed)f=k(e.embed,e,!0);else{var g=d(e.source1);g&&(e.type="script",e.width=g.width,e.height=g.height),e.width=e.width||300,e.height=e.height||150,tinymce.each(e,function(b,c){e[c]=a.dom.encode(b)}),"iframe"==e.type?f+='<iframe src="'+e.source1+'" width="'+e.width+'" height="'+e.height+'"></iframe>':"application/x-shockwave-flash"==e.source1mime?(f+='<object data="'+e.source1+'" width="'+e.width+'" height="'+e.height+'" type="application/x-shockwave-flash">',e.poster&&(f+='<img src="'+e.poster+'" width="'+e.width+'" height="'+e.height+'" />'),f+="</object>"):-1!=e.source1mime.indexOf("audio")?a.settings.audio_template_callback?f=a.settings.audio_template_callback(e):f+='<audio controls="controls" src="'+e.source1+'">'+(e.source2?'\n<source src="'+e.source2+'"'+(e.source2mime?' type="'+e.source2mime+'"':"")+" />\n":"")+"</audio>":"script"==e.type?f+='<script src="'+e.source1+'"></script>':f=a.settings.video_template_callback?a.settings.video_template_callback(e):'<video width="'+e.width+'" height="'+e.height+'"'+(e.poster?' poster="'+e.poster+'"':"")+' controls="controls">\n<source src="'+e.source1+'"'+(e.source1mime?' type="'+e.source1mime+'"':"")+" />\n"+(e.source2?'<source src="'+e.source2+'"'+(e.source2mime?' type="'+e.source2mime+'"':"")+" />\n":"")+"</video>"}return f}function h(a){var b={};return new tinymce.html.SaxParser({validate:!1,allow_conditional_comments:!0,special:"script,noscript",start:function(a,c){if(b.source1||"param"!=a||(b.source1=c.map.movie),("iframe"==a||"object"==a||"embed"==a||"video"==a||"audio"==a)&&(b.type||(b.type=a),b=tinymce.extend(c.map,b)),"script"==a){var e=d(c.map.src);if(!e)return;b={type:"script",source1:c.map.src,width:e.width,height:e.height}}"source"==a&&(b.source1?b.source2||(b.source2=c.map.src):b.source1=c.map.src),"img"!=a||b.poster||(b.poster=c.map.src)}}).parse(a),b.source1=b.source1||b.src||b.data,b.source2=b.source2||"",b.poster=b.poster||"",b}function i(b){return b.getAttribute("data-mce-object")?h(a.serializer.serialize(b,{selection:!0})):{}}function j(b){if(a.settings.media_filter_html===!1)return b;var c=new tinymce.html.Writer;return new tinymce.html.SaxParser({validate:!1,allow_conditional_comments:!1,special:"script,noscript",comment:function(a){c.comment(a)},cdata:function(a){c.cdata(a)},text:function(a,b){c.text(a,b)},start:function(a,b,d){if("script"!=a&&"noscript"!=a){for(var e=0;e<b.length;e++)if(0===b[e].name.indexOf("on"))return;c.start(a,b,d)}},end:function(a){"script"!=a&&"noscript"!=a&&c.end(a)}},new tinymce.html.Schema({})).parse(b),c.getContent()}function k(a,b,c){function d(a,b){var c,d,e,f;for(c in b)if(e=""+b[c],a.map[c])for(d=a.length;d--;)f=a[d],f.name==c&&(e?(a.map[c]=e,f.value=e):(delete a.map[c],a.splice(d,1)));else e&&(a.push({name:c,value:e}),a.map[c]=e)}var e,f=new tinymce.html.Writer,g=0;return new tinymce.html.SaxParser({validate:!1,allow_conditional_comments:!0,special:"script,noscript",comment:function(a){f.comment(a)},cdata:function(a){f.cdata(a)},text:function(a,b){f.text(a,b)},start:function(a,h,i){switch(a){case"video":case"object":case"embed":case"img":case"iframe":d(h,{width:b.width,height:b.height})}if(c)switch(a){case"video":d(h,{poster:b.poster,src:""}),b.source2&&d(h,{src:""});break;case"iframe":d(h,{src:b.source1});break;case"source":if(g++,2>=g&&(d(h,{src:b["source"+g],type:b["source"+g+"mime"]}),!b["source"+g]))return;break;case"img":if(!b.poster)return;e=!0}f.start(a,h,i)},end:function(a){if("video"==a&&c)for(var h=1;2>=h;h++)if(b["source"+h]){var i=[];i.map={},h>g&&(d(i,{src:b["source"+h],type:b["source"+h+"mime"]}),f.start("source",i,!0))}if(b.poster&&"object"==a&&c&&!e){var j=[];j.map={},d(j,{src:b.poster,width:b.width,height:b.height}),f.start("img",j,!0)}f.end(a)}},new tinymce.html.Schema({})).parse(a),f.getContent()}var l=[{regex:/youtu\.be\/([\w\-.]+)/,type:"iframe",w:425,h:350,url:"//www.youtube.com/embed/$1"},{regex:/youtube\.com(.+)v=([^&]+)/,type:"iframe",w:425,h:350,url:"//www.youtube.com/embed/$2"},{regex:/vimeo\.com\/([0-9]+)/,type:"iframe",w:425,h:350,url:"//player.vimeo.com/video/$1?title=0&byline=0&portrait=0&color=8dc7dc"},{regex:/vimeo\.com\/(.*)\/([0-9]+)/,type:"iframe",w:425,h:350,url:"//player.vimeo.com/video/$2?title=0&byline=0"},{regex:/maps\.google\.([a-z]{2,3})\/maps\/(.+)msid=(.+)/,type:"iframe",w:425,h:350,url:'//maps.google.com/maps/ms?msid=$2&output=embed"'}],m=tinymce.Env.ie&&tinymce.Env.ie<=8?"onChange":"onInput";a.on("ResolveName",function(a){var b;1==a.target.nodeType&&(b=a.target.getAttribute("data-mce-object"))&&(a.name=b)}),a.on("preInit",function(){var b=a.schema.getSpecialElements();tinymce.each("video audio iframe object".split(" "),function(a){b[a]=new RegExp("</"+a+"[^>]*>","gi")});var c=a.schema.getBoolAttrs();tinymce.each("webkitallowfullscreen mozallowfullscreen allowfullscreen".split(" "),function(a){c[a]={}}),a.parser.addNodeFilter("iframe,video,audio,object,embed,script",function(b,c){for(var e,f,g,h,i,j,k,l,m=b.length;m--;)if(f=b[m],f.parent&&("script"!=f.name||(l=d(f.attr("src"))))){for(g=new tinymce.html.Node("img",1),g.shortEnded=!0,l&&(l.width&&f.attr("width",l.width.toString()),l.height&&f.attr("height",l.height.toString())),j=f.attributes,e=j.length;e--;)h=j[e].name,i=j[e].value,"width"!==h&&"height"!==h&&"style"!==h&&(("data"==h||"src"==h)&&(i=a.convertURL(i,h)),g.attr("data-mce-p-"+h,i));k=f.firstChild&&f.firstChild.value,k&&(g.attr("data-mce-html",escape(k)),g.firstChild=null),g.attr({width:f.attr("width")||"300",height:f.attr("height")||("audio"==c?"30":"150"),style:f.attr("style"),src:tinymce.Env.transparentSrc,"data-mce-object":c,"class":"mce-object mce-object-"+c}),f.replace(g)}}),a.serializer.addAttributeFilter("data-mce-object",function(a,b){for(var c,d,e,f,g,h,i,k=a.length;k--;)if(c=a[k],c.parent){for(i=c.attr(b),d=new tinymce.html.Node(i,1),"audio"!=i&&"script"!=i&&d.attr({width:c.attr("width"),height:c.attr("height")}),d.attr({style:c.attr("style")}),f=c.attributes,e=f.length;e--;){var l=f[e].name;0===l.indexOf("data-mce-p-")&&d.attr(l.substr(11),f[e].value)}"script"==i&&d.attr("type","text/javascript"),g=c.attr("data-mce-html"),g&&(h=new tinymce.html.Node("#text",3),h.raw=!0,h.value=j(unescape(g)),d.append(h)),c.replace(d)}})}),a.on("ObjectSelected",function(a){var b=a.target.getAttribute("data-mce-object");("audio"==b||"script"==b)&&a.preventDefault()}),a.on("objectResized",function(a){var b,c=a.target;c.getAttribute("data-mce-object")&&(b=c.getAttribute("data-mce-html"),b&&(b=unescape(b),c.setAttribute("data-mce-html",escape(k(b,{width:a.width,height:a.height})))))}),a.addButton("media",{tooltip:"Insert/edit video",onclick:e,stateSelector:["img[data-mce-object=video]","img[data-mce-object=iframe]"]}),a.addMenuItem("media",{icon:"media",text:"Insert video",onclick:e,context:"insert",prependToContext:!0})});
|
@@ -0,0 +1,53 @@
|
|
1
|
+
/**
|
2
|
+
* plugin.js
|
3
|
+
*
|
4
|
+
* Copyright, Moxiecode Systems AB
|
5
|
+
* Released under LGPL License.
|
6
|
+
*
|
7
|
+
* License: http://www.tinymce.com/license
|
8
|
+
* Contributing: http://www.tinymce.com/contributing
|
9
|
+
*/
|
10
|
+
|
11
|
+
/*global tinymce:true */
|
12
|
+
|
13
|
+
tinymce.PluginManager.add('nonbreaking', function(editor) {
|
14
|
+
var setting = editor.getParam('nonbreaking_force_tab');
|
15
|
+
|
16
|
+
editor.addCommand('mceNonBreaking', function() {
|
17
|
+
editor.insertContent(
|
18
|
+
(editor.plugins.visualchars && editor.plugins.visualchars.state) ?
|
19
|
+
'<span class="mce-nbsp"> </span>' : ' '
|
20
|
+
);
|
21
|
+
|
22
|
+
editor.dom.setAttrib(editor.dom.select('span.mce-nbsp'), 'data-mce-bogus', '1');
|
23
|
+
});
|
24
|
+
|
25
|
+
editor.addButton('nonbreaking', {
|
26
|
+
title: 'Nonbreaking space',
|
27
|
+
cmd: 'mceNonBreaking'
|
28
|
+
});
|
29
|
+
|
30
|
+
editor.addMenuItem('nonbreaking', {
|
31
|
+
text: 'Nonbreaking space',
|
32
|
+
cmd: 'mceNonBreaking',
|
33
|
+
context: 'insert'
|
34
|
+
});
|
35
|
+
|
36
|
+
if (setting) {
|
37
|
+
var spaces = +setting > 1 ? +setting : 3; // defaults to 3 spaces if setting is true (or 1)
|
38
|
+
|
39
|
+
editor.on('keydown', function(e) {
|
40
|
+
if (e.keyCode == 9) {
|
41
|
+
|
42
|
+
if (e.shiftKey) {
|
43
|
+
return;
|
44
|
+
}
|
45
|
+
|
46
|
+
e.preventDefault();
|
47
|
+
for (var i = 0; i < spaces; i++) {
|
48
|
+
editor.execCommand('mceNonBreaking');
|
49
|
+
}
|
50
|
+
}
|
51
|
+
});
|
52
|
+
}
|
53
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
tinymce.PluginManager.add("nonbreaking",function(a){var b=a.getParam("nonbreaking_force_tab");if(a.addCommand("mceNonBreaking",function(){a.insertContent(a.plugins.visualchars&&a.plugins.visualchars.state?'<span class="mce-nbsp"> </span>':" "),a.dom.setAttrib(a.dom.select("span.mce-nbsp"),"data-mce-bogus","1")}),a.addButton("nonbreaking",{title:"Nonbreaking space",cmd:"mceNonBreaking"}),a.addMenuItem("nonbreaking",{text:"Nonbreaking space",cmd:"mceNonBreaking",context:"insert"}),b){var c=+b>1?+b:3;a.on("keydown",function(b){if(9==b.keyCode){if(b.shiftKey)return;b.preventDefault();for(var d=0;c>d;d++)a.execCommand("mceNonBreaking")}})}});
|
@@ -0,0 +1,540 @@
|
|
1
|
+
/**
|
2
|
+
* plugin.js
|
3
|
+
*
|
4
|
+
* Copyright, Moxiecode Systems AB
|
5
|
+
* Released under LGPL License.
|
6
|
+
*
|
7
|
+
* License: http://www.tinymce.com/license
|
8
|
+
* Contributing: http://www.tinymce.com/contributing
|
9
|
+
*/
|
10
|
+
|
11
|
+
/*jshint loopfunc:true */
|
12
|
+
/*eslint no-loop-func:0 */
|
13
|
+
/*global tinymce:true */
|
14
|
+
|
15
|
+
tinymce.PluginManager.add('noneditable', function(editor) {
|
16
|
+
var TreeWalker = tinymce.dom.TreeWalker;
|
17
|
+
var externalName = 'contenteditable', internalName = 'data-mce-' + externalName;
|
18
|
+
var VK = tinymce.util.VK;
|
19
|
+
|
20
|
+
// Returns the content editable state of a node "true/false" or null
|
21
|
+
function getContentEditable(node) {
|
22
|
+
var contentEditable;
|
23
|
+
|
24
|
+
// Ignore non elements
|
25
|
+
if (node.nodeType === 1) {
|
26
|
+
// Check for fake content editable
|
27
|
+
contentEditable = node.getAttribute(internalName);
|
28
|
+
if (contentEditable && contentEditable !== "inherit") {
|
29
|
+
return contentEditable;
|
30
|
+
}
|
31
|
+
|
32
|
+
// Check for real content editable
|
33
|
+
contentEditable = node.contentEditable;
|
34
|
+
if (contentEditable !== "inherit") {
|
35
|
+
return contentEditable;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
return null;
|
40
|
+
}
|
41
|
+
|
42
|
+
// Returns the noneditable parent or null if there is a editable before it or if it wasn't found
|
43
|
+
function getNonEditableParent(node) {
|
44
|
+
var state;
|
45
|
+
|
46
|
+
while (node) {
|
47
|
+
state = getContentEditable(node);
|
48
|
+
if (state) {
|
49
|
+
return state === "false" ? node : null;
|
50
|
+
}
|
51
|
+
|
52
|
+
node = node.parentNode;
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
function handleContentEditableSelection() {
|
57
|
+
var dom = editor.dom, selection = editor.selection, caretContainerId = 'mce_noneditablecaret', invisibleChar = '\uFEFF';
|
58
|
+
|
59
|
+
// Get caret container parent for the specified node
|
60
|
+
function getParentCaretContainer(node) {
|
61
|
+
while (node) {
|
62
|
+
if (node.id === caretContainerId) {
|
63
|
+
return node;
|
64
|
+
}
|
65
|
+
|
66
|
+
node = node.parentNode;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
// Finds the first text node in the specified node
|
71
|
+
function findFirstTextNode(node) {
|
72
|
+
var walker;
|
73
|
+
|
74
|
+
if (node) {
|
75
|
+
walker = new TreeWalker(node, node);
|
76
|
+
|
77
|
+
for (node = walker.current(); node; node = walker.next()) {
|
78
|
+
if (node.nodeType === 3) {
|
79
|
+
return node;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
// Insert caret container before/after target or expand selection to include block
|
86
|
+
function insertCaretContainerOrExpandToBlock(target, before) {
|
87
|
+
var caretContainer, rng;
|
88
|
+
|
89
|
+
// Select block
|
90
|
+
if (getContentEditable(target) === "false") {
|
91
|
+
if (dom.isBlock(target)) {
|
92
|
+
selection.select(target);
|
93
|
+
return;
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
rng = dom.createRng();
|
98
|
+
|
99
|
+
if (getContentEditable(target) === "true") {
|
100
|
+
if (!target.firstChild) {
|
101
|
+
target.appendChild(editor.getDoc().createTextNode('\u00a0'));
|
102
|
+
}
|
103
|
+
|
104
|
+
target = target.firstChild;
|
105
|
+
before = true;
|
106
|
+
}
|
107
|
+
|
108
|
+
/*
|
109
|
+
caretContainer = dom.create('span', {
|
110
|
+
id: caretContainerId,
|
111
|
+
'data-mce-bogus': true,
|
112
|
+
style:'border: 1px solid red'
|
113
|
+
}, invisibleChar);
|
114
|
+
*/
|
115
|
+
|
116
|
+
caretContainer = dom.create('span', {id: caretContainerId, 'data-mce-bogus': true}, invisibleChar);
|
117
|
+
|
118
|
+
if (before) {
|
119
|
+
target.parentNode.insertBefore(caretContainer, target);
|
120
|
+
} else {
|
121
|
+
dom.insertAfter(caretContainer, target);
|
122
|
+
}
|
123
|
+
|
124
|
+
rng.setStart(caretContainer.firstChild, 1);
|
125
|
+
rng.collapse(true);
|
126
|
+
selection.setRng(rng);
|
127
|
+
|
128
|
+
return caretContainer;
|
129
|
+
}
|
130
|
+
|
131
|
+
// Removes any caret container except the one we might be in
|
132
|
+
function removeCaretContainer(caretContainer) {
|
133
|
+
var rng, child, currentCaretContainer, lastContainer;
|
134
|
+
|
135
|
+
if (caretContainer) {
|
136
|
+
rng = selection.getRng(true);
|
137
|
+
rng.setStartBefore(caretContainer);
|
138
|
+
rng.setEndBefore(caretContainer);
|
139
|
+
|
140
|
+
child = findFirstTextNode(caretContainer);
|
141
|
+
if (child && child.nodeValue.charAt(0) == invisibleChar) {
|
142
|
+
child = child.deleteData(0, 1);
|
143
|
+
}
|
144
|
+
|
145
|
+
dom.remove(caretContainer, true);
|
146
|
+
|
147
|
+
selection.setRng(rng);
|
148
|
+
} else {
|
149
|
+
currentCaretContainer = getParentCaretContainer(selection.getStart());
|
150
|
+
while ((caretContainer = dom.get(caretContainerId)) && caretContainer !== lastContainer) {
|
151
|
+
if (currentCaretContainer !== caretContainer) {
|
152
|
+
child = findFirstTextNode(caretContainer);
|
153
|
+
if (child && child.nodeValue.charAt(0) == invisibleChar) {
|
154
|
+
child = child.deleteData(0, 1);
|
155
|
+
}
|
156
|
+
|
157
|
+
dom.remove(caretContainer, true);
|
158
|
+
}
|
159
|
+
|
160
|
+
lastContainer = caretContainer;
|
161
|
+
}
|
162
|
+
}
|
163
|
+
}
|
164
|
+
|
165
|
+
// Modifies the selection to include contentEditable false elements or insert caret containers
|
166
|
+
function moveSelection() {
|
167
|
+
var nonEditableStart, nonEditableEnd, isCollapsed, rng, element;
|
168
|
+
|
169
|
+
// Checks if there is any contents to the left/right side of caret returns the noneditable element or
|
170
|
+
// any editable element if it finds one inside
|
171
|
+
function hasSideContent(element, left) {
|
172
|
+
var container, offset, walker, node, len;
|
173
|
+
|
174
|
+
container = rng.startContainer;
|
175
|
+
offset = rng.startOffset;
|
176
|
+
|
177
|
+
// If endpoint is in middle of text node then expand to beginning/end of element
|
178
|
+
if (container.nodeType == 3) {
|
179
|
+
len = container.nodeValue.length;
|
180
|
+
if ((offset > 0 && offset < len) || (left ? offset == len : offset === 0)) {
|
181
|
+
return;
|
182
|
+
}
|
183
|
+
} else {
|
184
|
+
// Can we resolve the node by index
|
185
|
+
if (offset < container.childNodes.length) {
|
186
|
+
// Browser represents caret position as the offset at the start of an element. When moving right
|
187
|
+
// this is the element we are moving into so we consider our container to be child node at offset-1
|
188
|
+
var pos = !left && offset > 0 ? offset - 1 : offset;
|
189
|
+
container = container.childNodes[pos];
|
190
|
+
if (container.hasChildNodes()) {
|
191
|
+
container = container.firstChild;
|
192
|
+
}
|
193
|
+
} else {
|
194
|
+
// If not then the caret is at the last position in it's container and the caret container
|
195
|
+
// should be inserted after the noneditable element
|
196
|
+
return !left ? element : null;
|
197
|
+
}
|
198
|
+
}
|
199
|
+
|
200
|
+
// Walk left/right to look for contents
|
201
|
+
walker = new TreeWalker(container, element);
|
202
|
+
while ((node = walker[left ? 'prev' : 'next']())) {
|
203
|
+
if (node.nodeType === 3 && node.nodeValue.length > 0) {
|
204
|
+
return;
|
205
|
+
} else if (getContentEditable(node) === "true") {
|
206
|
+
// Found contentEditable=true element return this one to we can move the caret inside it
|
207
|
+
return node;
|
208
|
+
}
|
209
|
+
}
|
210
|
+
|
211
|
+
return element;
|
212
|
+
}
|
213
|
+
|
214
|
+
// Remove any existing caret containers
|
215
|
+
removeCaretContainer();
|
216
|
+
|
217
|
+
// Get noneditable start/end elements
|
218
|
+
isCollapsed = selection.isCollapsed();
|
219
|
+
nonEditableStart = getNonEditableParent(selection.getStart());
|
220
|
+
nonEditableEnd = getNonEditableParent(selection.getEnd());
|
221
|
+
|
222
|
+
// Is any fo the range endpoints noneditable
|
223
|
+
if (nonEditableStart || nonEditableEnd) {
|
224
|
+
rng = selection.getRng(true);
|
225
|
+
|
226
|
+
// If it's a caret selection then look left/right to see if we need to move the caret out side or expand
|
227
|
+
if (isCollapsed) {
|
228
|
+
nonEditableStart = nonEditableStart || nonEditableEnd;
|
229
|
+
|
230
|
+
if ((element = hasSideContent(nonEditableStart, true))) {
|
231
|
+
// We have no contents to the left of the caret then insert a caret container before the noneditable element
|
232
|
+
insertCaretContainerOrExpandToBlock(element, true);
|
233
|
+
} else if ((element = hasSideContent(nonEditableStart, false))) {
|
234
|
+
// We have no contents to the right of the caret then insert a caret container after the noneditable element
|
235
|
+
insertCaretContainerOrExpandToBlock(element, false);
|
236
|
+
} else {
|
237
|
+
// We are in the middle of a noneditable so expand to select it
|
238
|
+
selection.select(nonEditableStart);
|
239
|
+
}
|
240
|
+
} else {
|
241
|
+
rng = selection.getRng(true);
|
242
|
+
|
243
|
+
// Expand selection to include start non editable element
|
244
|
+
if (nonEditableStart) {
|
245
|
+
rng.setStartBefore(nonEditableStart);
|
246
|
+
}
|
247
|
+
|
248
|
+
// Expand selection to include end non editable element
|
249
|
+
if (nonEditableEnd) {
|
250
|
+
rng.setEndAfter(nonEditableEnd);
|
251
|
+
}
|
252
|
+
|
253
|
+
selection.setRng(rng);
|
254
|
+
}
|
255
|
+
}
|
256
|
+
}
|
257
|
+
|
258
|
+
function handleKey(e) {
|
259
|
+
var keyCode = e.keyCode, nonEditableParent, caretContainer, startElement, endElement;
|
260
|
+
|
261
|
+
function getNonEmptyTextNodeSibling(node, prev) {
|
262
|
+
while ((node = node[prev ? 'previousSibling' : 'nextSibling'])) {
|
263
|
+
if (node.nodeType !== 3 || node.nodeValue.length > 0) {
|
264
|
+
return node;
|
265
|
+
}
|
266
|
+
}
|
267
|
+
}
|
268
|
+
|
269
|
+
function positionCaretOnElement(element, start) {
|
270
|
+
selection.select(element);
|
271
|
+
selection.collapse(start);
|
272
|
+
}
|
273
|
+
|
274
|
+
function canDelete(backspace) {
|
275
|
+
var rng, container, offset, nonEditableParent;
|
276
|
+
|
277
|
+
function removeNodeIfNotParent(node) {
|
278
|
+
var parent = container;
|
279
|
+
|
280
|
+
while (parent) {
|
281
|
+
if (parent === node) {
|
282
|
+
return;
|
283
|
+
}
|
284
|
+
|
285
|
+
parent = parent.parentNode;
|
286
|
+
}
|
287
|
+
|
288
|
+
dom.remove(node);
|
289
|
+
moveSelection();
|
290
|
+
}
|
291
|
+
|
292
|
+
function isNextPrevTreeNodeNonEditable() {
|
293
|
+
var node, walker, nonEmptyElements = editor.schema.getNonEmptyElements();
|
294
|
+
|
295
|
+
walker = new tinymce.dom.TreeWalker(container, editor.getBody());
|
296
|
+
while ((node = (backspace ? walker.prev() : walker.next()))) {
|
297
|
+
// Found IMG/INPUT etc
|
298
|
+
if (nonEmptyElements[node.nodeName.toLowerCase()]) {
|
299
|
+
break;
|
300
|
+
}
|
301
|
+
|
302
|
+
// Found text node with contents
|
303
|
+
if (node.nodeType === 3 && tinymce.trim(node.nodeValue).length > 0) {
|
304
|
+
break;
|
305
|
+
}
|
306
|
+
|
307
|
+
// Found non editable node
|
308
|
+
if (getContentEditable(node) === "false") {
|
309
|
+
removeNodeIfNotParent(node);
|
310
|
+
return true;
|
311
|
+
}
|
312
|
+
}
|
313
|
+
|
314
|
+
// Check if the content node is within a non editable parent
|
315
|
+
if (getNonEditableParent(node)) {
|
316
|
+
return true;
|
317
|
+
}
|
318
|
+
|
319
|
+
return false;
|
320
|
+
}
|
321
|
+
|
322
|
+
if (selection.isCollapsed()) {
|
323
|
+
rng = selection.getRng(true);
|
324
|
+
container = rng.startContainer;
|
325
|
+
offset = rng.startOffset;
|
326
|
+
container = getParentCaretContainer(container) || container;
|
327
|
+
|
328
|
+
// Is in noneditable parent
|
329
|
+
if ((nonEditableParent = getNonEditableParent(container))) {
|
330
|
+
removeNodeIfNotParent(nonEditableParent);
|
331
|
+
return false;
|
332
|
+
}
|
333
|
+
|
334
|
+
// Check if the caret is in the middle of a text node
|
335
|
+
if (container.nodeType == 3 && (backspace ? offset > 0 : offset < container.nodeValue.length)) {
|
336
|
+
return true;
|
337
|
+
}
|
338
|
+
|
339
|
+
// Resolve container index
|
340
|
+
if (container.nodeType == 1) {
|
341
|
+
container = container.childNodes[offset] || container;
|
342
|
+
}
|
343
|
+
|
344
|
+
// Check if previous or next tree node is non editable then block the event
|
345
|
+
if (isNextPrevTreeNodeNonEditable()) {
|
346
|
+
return false;
|
347
|
+
}
|
348
|
+
}
|
349
|
+
|
350
|
+
return true;
|
351
|
+
}
|
352
|
+
|
353
|
+
startElement = selection.getStart();
|
354
|
+
endElement = selection.getEnd();
|
355
|
+
|
356
|
+
// Disable all key presses in contentEditable=false except delete or backspace
|
357
|
+
nonEditableParent = getNonEditableParent(startElement) || getNonEditableParent(endElement);
|
358
|
+
if (nonEditableParent && (keyCode < 112 || keyCode > 124) && keyCode != VK.DELETE && keyCode != VK.BACKSPACE) {
|
359
|
+
// Is Ctrl+c, Ctrl+v or Ctrl+x then use default browser behavior
|
360
|
+
if ((tinymce.isMac ? e.metaKey : e.ctrlKey) && (keyCode == 67 || keyCode == 88 || keyCode == 86)) {
|
361
|
+
return;
|
362
|
+
}
|
363
|
+
|
364
|
+
e.preventDefault();
|
365
|
+
|
366
|
+
// Arrow left/right select the element and collapse left/right
|
367
|
+
if (keyCode == VK.LEFT || keyCode == VK.RIGHT) {
|
368
|
+
var left = keyCode == VK.LEFT;
|
369
|
+
// If a block element find previous or next element to position the caret
|
370
|
+
if (editor.dom.isBlock(nonEditableParent)) {
|
371
|
+
var targetElement = left ? nonEditableParent.previousSibling : nonEditableParent.nextSibling;
|
372
|
+
var walker = new TreeWalker(targetElement, targetElement);
|
373
|
+
var caretElement = left ? walker.prev() : walker.next();
|
374
|
+
positionCaretOnElement(caretElement, !left);
|
375
|
+
} else {
|
376
|
+
positionCaretOnElement(nonEditableParent, left);
|
377
|
+
}
|
378
|
+
}
|
379
|
+
} else {
|
380
|
+
// Is arrow left/right, backspace or delete
|
381
|
+
if (keyCode == VK.LEFT || keyCode == VK.RIGHT || keyCode == VK.BACKSPACE || keyCode == VK.DELETE) {
|
382
|
+
caretContainer = getParentCaretContainer(startElement);
|
383
|
+
if (caretContainer) {
|
384
|
+
// Arrow left or backspace
|
385
|
+
if (keyCode == VK.LEFT || keyCode == VK.BACKSPACE) {
|
386
|
+
nonEditableParent = getNonEmptyTextNodeSibling(caretContainer, true);
|
387
|
+
|
388
|
+
if (nonEditableParent && getContentEditable(nonEditableParent) === "false") {
|
389
|
+
e.preventDefault();
|
390
|
+
|
391
|
+
if (keyCode == VK.LEFT) {
|
392
|
+
positionCaretOnElement(nonEditableParent, true);
|
393
|
+
} else {
|
394
|
+
dom.remove(nonEditableParent);
|
395
|
+
return;
|
396
|
+
}
|
397
|
+
} else {
|
398
|
+
removeCaretContainer(caretContainer);
|
399
|
+
}
|
400
|
+
}
|
401
|
+
|
402
|
+
// Arrow right or delete
|
403
|
+
if (keyCode == VK.RIGHT || keyCode == VK.DELETE) {
|
404
|
+
nonEditableParent = getNonEmptyTextNodeSibling(caretContainer);
|
405
|
+
|
406
|
+
if (nonEditableParent && getContentEditable(nonEditableParent) === "false") {
|
407
|
+
e.preventDefault();
|
408
|
+
|
409
|
+
if (keyCode == VK.RIGHT) {
|
410
|
+
positionCaretOnElement(nonEditableParent, false);
|
411
|
+
} else {
|
412
|
+
dom.remove(nonEditableParent);
|
413
|
+
return;
|
414
|
+
}
|
415
|
+
} else {
|
416
|
+
removeCaretContainer(caretContainer);
|
417
|
+
}
|
418
|
+
}
|
419
|
+
}
|
420
|
+
|
421
|
+
if ((keyCode == VK.BACKSPACE || keyCode == VK.DELETE) && !canDelete(keyCode == VK.BACKSPACE)) {
|
422
|
+
e.preventDefault();
|
423
|
+
return false;
|
424
|
+
}
|
425
|
+
}
|
426
|
+
}
|
427
|
+
}
|
428
|
+
|
429
|
+
editor.on('mousedown', function(e) {
|
430
|
+
var node = editor.selection.getNode();
|
431
|
+
|
432
|
+
if (getContentEditable(node) === "false" && node == e.target) {
|
433
|
+
// Expand selection on mouse down we can't block the default event since it's used for drag/drop
|
434
|
+
moveSelection();
|
435
|
+
}
|
436
|
+
});
|
437
|
+
|
438
|
+
editor.on('mouseup keyup', moveSelection);
|
439
|
+
editor.on('keydown', handleKey);
|
440
|
+
}
|
441
|
+
|
442
|
+
var editClass, nonEditClass, nonEditableRegExps;
|
443
|
+
|
444
|
+
// Converts configured regexps to noneditable span items
|
445
|
+
function convertRegExpsToNonEditable(e) {
|
446
|
+
var i = nonEditableRegExps.length, content = e.content, cls = tinymce.trim(nonEditClass);
|
447
|
+
|
448
|
+
// Don't replace the variables when raw is used for example on undo/redo
|
449
|
+
if (e.format == "raw") {
|
450
|
+
return;
|
451
|
+
}
|
452
|
+
|
453
|
+
while (i--) {
|
454
|
+
content = content.replace(nonEditableRegExps[i], function(match) {
|
455
|
+
var args = arguments, index = args[args.length - 2];
|
456
|
+
|
457
|
+
// Is value inside an attribute then don't replace
|
458
|
+
if (index > 0 && content.charAt(index - 1) == '"') {
|
459
|
+
return match;
|
460
|
+
}
|
461
|
+
|
462
|
+
return (
|
463
|
+
'<span class="' + cls + '" data-mce-content="' + editor.dom.encode(args[0]) + '">' +
|
464
|
+
editor.dom.encode(typeof(args[1]) === "string" ? args[1] : args[0]) + '</span>'
|
465
|
+
);
|
466
|
+
});
|
467
|
+
}
|
468
|
+
|
469
|
+
e.content = content;
|
470
|
+
}
|
471
|
+
|
472
|
+
editClass = " " + tinymce.trim(editor.getParam("noneditable_editable_class", "mceEditable")) + " ";
|
473
|
+
nonEditClass = " " + tinymce.trim(editor.getParam("noneditable_noneditable_class", "mceNonEditable")) + " ";
|
474
|
+
|
475
|
+
// Setup noneditable regexps array
|
476
|
+
nonEditableRegExps = editor.getParam("noneditable_regexp");
|
477
|
+
if (nonEditableRegExps && !nonEditableRegExps.length) {
|
478
|
+
nonEditableRegExps = [nonEditableRegExps];
|
479
|
+
}
|
480
|
+
|
481
|
+
editor.on('PreInit', function() {
|
482
|
+
handleContentEditableSelection();
|
483
|
+
|
484
|
+
if (nonEditableRegExps) {
|
485
|
+
editor.on('BeforeSetContent', convertRegExpsToNonEditable);
|
486
|
+
}
|
487
|
+
|
488
|
+
// Apply contentEditable true/false on elements with the noneditable/editable classes
|
489
|
+
editor.parser.addAttributeFilter('class', function(nodes) {
|
490
|
+
var i = nodes.length, className, node;
|
491
|
+
|
492
|
+
while (i--) {
|
493
|
+
node = nodes[i];
|
494
|
+
className = " " + node.attr("class") + " ";
|
495
|
+
|
496
|
+
if (className.indexOf(editClass) !== -1) {
|
497
|
+
node.attr(internalName, "true");
|
498
|
+
} else if (className.indexOf(nonEditClass) !== -1) {
|
499
|
+
node.attr(internalName, "false");
|
500
|
+
}
|
501
|
+
}
|
502
|
+
});
|
503
|
+
|
504
|
+
// Remove internal name
|
505
|
+
editor.serializer.addAttributeFilter(internalName, function(nodes) {
|
506
|
+
var i = nodes.length, node;
|
507
|
+
|
508
|
+
while (i--) {
|
509
|
+
node = nodes[i];
|
510
|
+
|
511
|
+
if (nonEditableRegExps && node.attr('data-mce-content')) {
|
512
|
+
node.name = "#text";
|
513
|
+
node.type = 3;
|
514
|
+
node.raw = true;
|
515
|
+
node.value = node.attr('data-mce-content');
|
516
|
+
} else {
|
517
|
+
node.attr(externalName, null);
|
518
|
+
node.attr(internalName, null);
|
519
|
+
}
|
520
|
+
}
|
521
|
+
});
|
522
|
+
|
523
|
+
// Convert external name into internal name
|
524
|
+
editor.parser.addAttributeFilter(externalName, function(nodes) {
|
525
|
+
var i = nodes.length, node;
|
526
|
+
|
527
|
+
while (i--) {
|
528
|
+
node = nodes[i];
|
529
|
+
node.attr(internalName, node.attr(externalName));
|
530
|
+
node.attr(externalName, null);
|
531
|
+
}
|
532
|
+
});
|
533
|
+
});
|
534
|
+
|
535
|
+
editor.on('drop', function(e) {
|
536
|
+
if (getNonEditableParent(e.target)) {
|
537
|
+
e.preventDefault();
|
538
|
+
}
|
539
|
+
});
|
540
|
+
});
|