bedrock_sass 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/assets/_vendor/tinymce/plugins/advlist/index.js +7 -0
  4. data/assets/_vendor/tinymce/plugins/advlist/plugin.js +428 -0
  5. data/assets/_vendor/tinymce/plugins/advlist/plugin.min.js +1 -0
  6. data/assets/_vendor/tinymce/plugins/anchor/index.js +7 -0
  7. data/assets/_vendor/tinymce/plugins/anchor/plugin.js +338 -0
  8. data/assets/_vendor/tinymce/plugins/anchor/plugin.min.js +1 -0
  9. data/assets/_vendor/tinymce/plugins/autolink/index.js +7 -0
  10. data/assets/_vendor/tinymce/plugins/autolink/plugin.js +404 -0
  11. data/assets/_vendor/tinymce/plugins/autolink/plugin.min.js +1 -0
  12. data/assets/_vendor/tinymce/plugins/autoresize/index.js +7 -0
  13. data/assets/_vendor/tinymce/plugins/autoresize/plugin.js +451 -0
  14. data/assets/_vendor/tinymce/plugins/autoresize/plugin.min.js +1 -0
  15. data/assets/_vendor/tinymce/plugins/autosave/index.js +7 -0
  16. data/assets/_vendor/tinymce/plugins/autosave/plugin.js +608 -0
  17. data/assets/_vendor/tinymce/plugins/autosave/plugin.min.js +1 -0
  18. data/assets/_vendor/tinymce/plugins/bbcode/index.js +7 -0
  19. data/assets/_vendor/tinymce/plugins/bbcode/plugin.js +264 -0
  20. data/assets/_vendor/tinymce/plugins/bbcode/plugin.min.js +1 -0
  21. data/assets/_vendor/tinymce/plugins/charmap/index.js +7 -0
  22. data/assets/_vendor/tinymce/plugins/charmap/plugin.js +850 -0
  23. data/assets/_vendor/tinymce/plugins/charmap/plugin.min.js +1 -0
  24. data/assets/_vendor/tinymce/plugins/code/index.js +7 -0
  25. data/assets/_vendor/tinymce/plugins/code/plugin.js +338 -0
  26. data/assets/_vendor/tinymce/plugins/code/plugin.min.js +1 -0
  27. data/assets/_vendor/tinymce/plugins/codesample/css/prism.css +138 -0
  28. data/assets/_vendor/tinymce/plugins/codesample/index.js +7 -0
  29. data/assets/_vendor/tinymce/plugins/codesample/plugin.js +1582 -0
  30. data/assets/_vendor/tinymce/plugins/codesample/plugin.min.js +1 -0
  31. data/assets/_vendor/tinymce/plugins/colorpicker/index.js +7 -0
  32. data/assets/_vendor/tinymce/plugins/colorpicker/plugin.js +272 -0
  33. data/assets/_vendor/tinymce/plugins/colorpicker/plugin.min.js +1 -0
  34. data/assets/_vendor/tinymce/plugins/contextmenu/index.js +7 -0
  35. data/assets/_vendor/tinymce/plugins/contextmenu/plugin.js +496 -0
  36. data/assets/_vendor/tinymce/plugins/contextmenu/plugin.min.js +1 -0
  37. data/assets/_vendor/tinymce/plugins/directionality/index.js +7 -0
  38. data/assets/_vendor/tinymce/plugins/directionality/plugin.js +270 -0
  39. data/assets/_vendor/tinymce/plugins/directionality/plugin.min.js +1 -0
  40. data/assets/_vendor/tinymce/plugins/emoticons/img/smiley-cool.gif +0 -0
  41. data/assets/_vendor/tinymce/plugins/emoticons/img/smiley-cry.gif +0 -0
  42. data/assets/_vendor/tinymce/plugins/emoticons/img/smiley-embarassed.gif +0 -0
  43. data/assets/_vendor/tinymce/plugins/emoticons/img/smiley-foot-in-mouth.gif +0 -0
  44. data/assets/_vendor/tinymce/plugins/emoticons/img/smiley-frown.gif +0 -0
  45. data/assets/_vendor/tinymce/plugins/emoticons/img/smiley-innocent.gif +0 -0
  46. data/assets/_vendor/tinymce/plugins/emoticons/img/smiley-kiss.gif +0 -0
  47. data/assets/_vendor/tinymce/plugins/emoticons/img/smiley-laughing.gif +0 -0
  48. data/assets/_vendor/tinymce/plugins/emoticons/img/smiley-money-mouth.gif +0 -0
  49. data/assets/_vendor/tinymce/plugins/emoticons/img/smiley-sealed.gif +0 -0
  50. data/assets/_vendor/tinymce/plugins/emoticons/img/smiley-smile.gif +0 -0
  51. data/assets/_vendor/tinymce/plugins/emoticons/img/smiley-surprised.gif +0 -0
  52. data/assets/_vendor/tinymce/plugins/emoticons/img/smiley-tongue-out.gif +0 -0
  53. data/assets/_vendor/tinymce/plugins/emoticons/img/smiley-undecided.gif +0 -0
  54. data/assets/_vendor/tinymce/plugins/emoticons/img/smiley-wink.gif +0 -0
  55. data/assets/_vendor/tinymce/plugins/emoticons/img/smiley-yell.gif +0 -0
  56. data/assets/_vendor/tinymce/plugins/emoticons/index.js +7 -0
  57. data/assets/_vendor/tinymce/plugins/emoticons/plugin.js +256 -0
  58. data/assets/_vendor/tinymce/plugins/emoticons/plugin.min.js +1 -0
  59. data/assets/_vendor/tinymce/plugins/fullpage/index.js +7 -0
  60. data/assets/_vendor/tinymce/plugins/fullpage/plugin.js +962 -0
  61. data/assets/_vendor/tinymce/plugins/fullpage/plugin.min.js +1 -0
  62. data/assets/_vendor/tinymce/plugins/fullscreen/index.js +7 -0
  63. data/assets/_vendor/tinymce/plugins/fullscreen/plugin.js +455 -0
  64. data/assets/_vendor/tinymce/plugins/fullscreen/plugin.min.js +1 -0
  65. data/assets/_vendor/tinymce/plugins/help/img/logo.png +0 -0
  66. data/assets/_vendor/tinymce/plugins/help/index.js +7 -0
  67. data/assets/_vendor/tinymce/plugins/help/plugin.js +1527 -0
  68. data/assets/_vendor/tinymce/plugins/help/plugin.min.js +1 -0
  69. data/assets/_vendor/tinymce/plugins/hr/index.js +7 -0
  70. data/assets/_vendor/tinymce/plugins/hr/plugin.js +195 -0
  71. data/assets/_vendor/tinymce/plugins/hr/plugin.min.js +1 -0
  72. data/assets/_vendor/tinymce/plugins/image/index.js +7 -0
  73. data/assets/_vendor/tinymce/plugins/image/plugin.js +1572 -0
  74. data/assets/_vendor/tinymce/plugins/image/plugin.min.js +1 -0
  75. data/assets/_vendor/tinymce/plugins/imagetools/index.js +7 -0
  76. data/assets/_vendor/tinymce/plugins/imagetools/plugin.js +4444 -0
  77. data/assets/_vendor/tinymce/plugins/imagetools/plugin.min.js +2 -0
  78. data/assets/_vendor/tinymce/plugins/importcss/index.js +7 -0
  79. data/assets/_vendor/tinymce/plugins/importcss/plugin.js +577 -0
  80. data/assets/_vendor/tinymce/plugins/importcss/plugin.min.js +1 -0
  81. data/assets/_vendor/tinymce/plugins/insertdatetime/index.js +7 -0
  82. data/assets/_vendor/tinymce/plugins/insertdatetime/plugin.js +482 -0
  83. data/assets/_vendor/tinymce/plugins/insertdatetime/plugin.min.js +1 -0
  84. data/assets/_vendor/tinymce/plugins/legacyoutput/index.js +7 -0
  85. data/assets/_vendor/tinymce/plugins/legacyoutput/plugin.js +395 -0
  86. data/assets/_vendor/tinymce/plugins/legacyoutput/plugin.min.js +1 -0
  87. data/assets/_vendor/tinymce/plugins/link/index.js +7 -0
  88. data/assets/_vendor/tinymce/plugins/link/plugin.js +1231 -0
  89. data/assets/_vendor/tinymce/plugins/link/plugin.min.js +1 -0
  90. data/assets/_vendor/tinymce/plugins/lists/index.js +7 -0
  91. data/assets/_vendor/tinymce/plugins/lists/plugin.js +1985 -0
  92. data/assets/_vendor/tinymce/plugins/lists/plugin.min.js +1 -0
  93. data/assets/_vendor/tinymce/plugins/media/index.js +7 -0
  94. data/assets/_vendor/tinymce/plugins/media/plugin.js +2026 -0
  95. data/assets/_vendor/tinymce/plugins/media/plugin.min.js +1 -0
  96. data/assets/_vendor/tinymce/plugins/nonbreaking/index.js +7 -0
  97. data/assets/_vendor/tinymce/plugins/nonbreaking/plugin.js +313 -0
  98. data/assets/_vendor/tinymce/plugins/nonbreaking/plugin.min.js +1 -0
  99. data/assets/_vendor/tinymce/plugins/noneditable/index.js +7 -0
  100. data/assets/_vendor/tinymce/plugins/noneditable/plugin.js +316 -0
  101. data/assets/_vendor/tinymce/plugins/noneditable/plugin.min.js +1 -0
  102. data/assets/_vendor/tinymce/plugins/pagebreak/index.js +7 -0
  103. data/assets/_vendor/tinymce/plugins/pagebreak/plugin.js +354 -0
  104. data/assets/_vendor/tinymce/plugins/pagebreak/plugin.min.js +1 -0
  105. data/assets/_vendor/tinymce/plugins/paste/index.js +7 -0
  106. data/assets/_vendor/tinymce/plugins/paste/plugin.js +2935 -0
  107. data/assets/_vendor/tinymce/plugins/paste/plugin.min.js +1 -0
  108. data/assets/_vendor/tinymce/plugins/preview/index.js +7 -0
  109. data/assets/_vendor/tinymce/plugins/preview/plugin.js +410 -0
  110. data/assets/_vendor/tinymce/plugins/preview/plugin.min.js +1 -0
  111. data/assets/_vendor/tinymce/plugins/print/index.js +7 -0
  112. data/assets/_vendor/tinymce/plugins/print/plugin.js +194 -0
  113. data/assets/_vendor/tinymce/plugins/print/plugin.min.js +1 -0
  114. data/assets/_vendor/tinymce/plugins/save/index.js +7 -0
  115. data/assets/_vendor/tinymce/plugins/save/plugin.js +370 -0
  116. data/assets/_vendor/tinymce/plugins/save/plugin.min.js +1 -0
  117. data/assets/_vendor/tinymce/plugins/searchreplace/index.js +7 -0
  118. data/assets/_vendor/tinymce/plugins/searchreplace/plugin.js +977 -0
  119. data/assets/_vendor/tinymce/plugins/searchreplace/plugin.min.js +1 -0
  120. data/assets/_vendor/tinymce/plugins/spellchecker/index.js +7 -0
  121. data/assets/_vendor/tinymce/plugins/spellchecker/plugin.js +1419 -0
  122. data/assets/_vendor/tinymce/plugins/spellchecker/plugin.min.js +1 -0
  123. data/assets/_vendor/tinymce/plugins/tabfocus/index.js +7 -0
  124. data/assets/_vendor/tinymce/plugins/tabfocus/plugin.js +419 -0
  125. data/assets/_vendor/tinymce/plugins/tabfocus/plugin.min.js +1 -0
  126. data/assets/_vendor/tinymce/plugins/table/index.js +7 -0
  127. data/assets/_vendor/tinymce/plugins/table/plugin.js +15527 -0
  128. data/assets/_vendor/tinymce/plugins/table/plugin.min.js +5 -0
  129. data/assets/_vendor/tinymce/plugins/template/index.js +7 -0
  130. data/assets/_vendor/tinymce/plugins/template/plugin.js +807 -0
  131. data/assets/_vendor/tinymce/plugins/template/plugin.min.js +1 -0
  132. data/assets/_vendor/tinymce/plugins/textcolor/index.js +7 -0
  133. data/assets/_vendor/tinymce/plugins/textcolor/plugin.js +619 -0
  134. data/assets/_vendor/tinymce/plugins/textcolor/plugin.min.js +1 -0
  135. data/assets/_vendor/tinymce/plugins/textpattern/index.js +7 -0
  136. data/assets/_vendor/tinymce/plugins/textpattern/plugin.js +718 -0
  137. data/assets/_vendor/tinymce/plugins/textpattern/plugin.min.js +1 -0
  138. data/assets/_vendor/tinymce/plugins/toc/index.js +7 -0
  139. data/assets/_vendor/tinymce/plugins/toc/plugin.js +559 -0
  140. data/assets/_vendor/tinymce/plugins/toc/plugin.min.js +1 -0
  141. data/assets/_vendor/tinymce/plugins/visualblocks/css/visualblocks.css +154 -0
  142. data/assets/_vendor/tinymce/plugins/visualblocks/index.js +7 -0
  143. data/assets/_vendor/tinymce/plugins/visualblocks/plugin.js +459 -0
  144. data/assets/_vendor/tinymce/plugins/visualblocks/plugin.min.js +1 -0
  145. data/assets/_vendor/tinymce/plugins/visualchars/index.js +7 -0
  146. data/assets/_vendor/tinymce/plugins/visualchars/plugin.js +1325 -0
  147. data/assets/_vendor/tinymce/plugins/visualchars/plugin.min.js +1 -0
  148. data/assets/_vendor/tinymce/plugins/wordcount/index.js +7 -0
  149. data/assets/_vendor/tinymce/plugins/wordcount/plugin.js +735 -0
  150. data/assets/_vendor/tinymce/plugins/wordcount/plugin.min.js +1 -0
  151. data/assets/_vendor/tinymce/skins/lightgray/content.inline.min.css +1 -0
  152. data/assets/_vendor/tinymce/skins/lightgray/content.min.css +1 -0
  153. data/assets/_vendor/tinymce/skins/lightgray/content.mobile.min.css +1 -0
  154. data/assets/_vendor/tinymce/skins/lightgray/fonts/tinymce-mobile.woff +0 -0
  155. data/assets/_vendor/tinymce/skins/lightgray/fonts/tinymce-small.eot +0 -0
  156. data/assets/_vendor/tinymce/skins/lightgray/fonts/tinymce-small.svg +63 -0
  157. data/assets/_vendor/tinymce/skins/lightgray/fonts/tinymce-small.ttf +0 -0
  158. data/assets/_vendor/tinymce/skins/lightgray/fonts/tinymce-small.woff +0 -0
  159. data/assets/_vendor/tinymce/skins/lightgray/fonts/tinymce.eot +0 -0
  160. data/assets/_vendor/tinymce/skins/lightgray/fonts/tinymce.svg +131 -0
  161. data/assets/_vendor/tinymce/skins/lightgray/fonts/tinymce.ttf +0 -0
  162. data/assets/_vendor/tinymce/skins/lightgray/fonts/tinymce.woff +0 -0
  163. data/assets/_vendor/tinymce/skins/lightgray/img/anchor.gif +0 -0
  164. data/assets/_vendor/tinymce/skins/lightgray/img/loader.gif +0 -0
  165. data/assets/_vendor/tinymce/skins/lightgray/img/object.gif +0 -0
  166. data/assets/_vendor/tinymce/skins/lightgray/img/trans.gif +0 -0
  167. data/assets/_vendor/tinymce/skins/lightgray/skin.min.css +1 -0
  168. data/assets/_vendor/tinymce/skins/lightgray/skin.mobile.min.css +2 -0
  169. data/assets/_vendor/tinymce/themes/inlite/index.js +7 -0
  170. data/assets/_vendor/tinymce/themes/inlite/theme.js +18787 -0
  171. data/assets/_vendor/tinymce/themes/inlite/theme.min.js +5 -0
  172. data/assets/_vendor/tinymce/themes/mobile/index.js +7 -0
  173. data/assets/_vendor/tinymce/themes/mobile/theme.js +23384 -0
  174. data/assets/_vendor/tinymce/themes/mobile/theme.min.js +8 -0
  175. data/assets/_vendor/tinymce/themes/modern/index.js +7 -0
  176. data/assets/_vendor/tinymce/themes/modern/theme.js +18311 -0
  177. data/assets/_vendor/tinymce/themes/modern/theme.min.js +5 -0
  178. data/assets/_vendor/tinymce/tinymce.js +44399 -0
  179. data/assets/bedrock/js/bedrock.js +16587 -6193
  180. data/assets/bedrock/scss/_bedrock-components.scss +16 -0
  181. data/assets/bedrock/scss/_bedrock-settings.scss +15 -0
  182. data/assets/bedrock/scss/components/attachments-grid.scss +138 -0
  183. data/assets/bedrock/scss/components/dropzone-upload.scss +158 -0
  184. data/assets/bedrock/scss/components/global.scss +16 -8
  185. data/assets/bedrock/scss/components/helper-classes.scss +59 -0
  186. data/assets/bedrock/scss/components/inline-edit-box.scss +80 -0
  187. data/assets/bedrock/scss/components/login-box.scss +48 -0
  188. data/assets/bedrock/scss/components/no-content.scss +31 -0
  189. data/assets/bedrock/scss/components/off-canvas-menu.scss +1 -1
  190. data/assets/bedrock/scss/components/page-content.scss +51 -0
  191. data/assets/bedrock/scss/components/reveal-panel.scss +89 -0
  192. data/assets/bedrock/scss/components/select-box.scss +332 -0
  193. data/assets/bedrock/scss/components/tiny-mce-editor.scss +14 -7
  194. data/lib/bedrock_sass.rb +6 -0
  195. data/lib/bedrock_sass/engine.rb +8 -0
  196. data/lib/bedrock_sass/version.rb +1 -1
  197. data/lib/tasks/before_assets_precompile.rake +11 -0
  198. metadata +188 -2
@@ -0,0 +1 @@
1
+ !function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i<g;++i)h[i]=d(e[i]);var j=f.apply(null,h);if(void 0===j)throw"module ["+b+"] returned undefined";c.instance=j},c=function(b,c,d){if("string"!=typeof b)throw"module id must be a string";if(void 0===c)throw"no dependencies for "+b;if(void 0===d)throw"no definition function for "+b;a[b]={deps:c,defn:d,instance:void 0}},d=function(c){var d=a[c];if(void 0===d)throw"module ["+c+"] was undefined";return void 0===d.instance&&b(c),d.instance},e=function(a,b){for(var c=a.length,e=new Array(c),f=0;f<c;++f)e[f]=d(a[f]);b.apply(null,e)},f={};f.bolt={module:{api:{define:c,require:e,demand:d}}};var g=c,h=function(a,b){g(a,[],function(){return b})};h("6",tinymce.util.Tools.resolve),g("1",["6"],function(a){return a("tinymce.PluginManager")}),g("7",["6"],function(a){return a("tinymce.util.VK")}),g("8",[],function(){var a=function(a){return"boolean"==typeof a.link_assume_external_targets&&a.link_assume_external_targets},b=function(a){return"boolean"==typeof a.link_context_toolbar&&a.link_context_toolbar},c=function(a){return a.link_list},d=function(a){return"string"==typeof a.default_link_target},e=function(a){return a.default_link_target},f=function(a){return a.target_list},g=function(a,b){a.settings.target_list=b},h=function(a){return f(a)!==!1},i=function(a){return a.rel_list},j=function(a){return void 0!==i(a)},k=function(a){return a.link_class_list},l=function(a){return void 0!==k(a)},m=function(a){return a.link_title!==!1},n=function(a){return"boolean"==typeof a.allow_unsafe_link_target&&a.allow_unsafe_link_target};return{assumeExternalTargets:a,hasContextToolbar:b,getLinkList:c,hasDefaultLinkTarget:d,getDefaultLinkTarget:e,getTargetList:f,setTargetList:g,shouldShowTargetList:h,getRelList:i,hasRelList:j,getLinkClassList:k,hasLinkClassList:l,shouldShowLinkTitle:m,allowUnsafeLinkTarget:n}}),h("c",document),h("d",window),g("e",["6"],function(a){return a("tinymce.dom.DOMUtils")}),g("f",["6"],function(a){return a("tinymce.Env")}),g("9",["c","d","e","f"],function(a,b,c,d){var e=function(b,c){a.body.appendChild(b),b.dispatchEvent(c),a.body.removeChild(b)},f=function(f){if(!d.ie||d.ie>10){var g=a.createElement("a");g.target="_blank",g.href=f,g.rel="noreferrer noopener";var h=a.createEvent("MouseEvents");h.initMouseEvent("click",!0,!0,b,0,0,0,0,0,!1,!1,!1,!1,0,null),e(g,h)}else{var i=b.open("","_blank");if(i){i.opener=null;var j=i.document;j.open(),j.write('<meta http-equiv="refresh" content="0; url='+c.DOM.encode(f)+'">'),j.close()}}};return{open:f}}),h("g",RegExp),g("h",["6"],function(a){return a("tinymce.util.Tools")}),g("a",["g","h","8"],function(a,b,c){var d=function(a,c){var d=["noopener"],e=a?a.split(/\s+/):[],f=function(a){return b.trim(a.sort().join(" "))},g=function(a){return a=h(a),a.length?a.concat(d):d},h=function(a){return a.filter(function(a){return b.inArray(d,a)===-1})};return e=c?g(e):h(e),e.length?f(e):null},e=function(a){return a.replace(/\uFEFF/g,"")},f=function(a,b){return b=b||a.selection.getNode(),k(b)?a.dom.select("a[href]",b)[0]:a.dom.getParent(b,"a[href]")},g=function(a,b){var c=b?b.innerText||b.textContent:a.getContent({format:"text"});return e(c)},h=function(a){return a&&"A"===a.nodeName&&a.href},i=function(a){return b.grep(a,h).length>0},j=function(a){return!(/</.test(a)&&(!/^<a [^>]+>[^<]+<\/a>$/.test(a)||a.indexOf("href=")===-1))},k=function(a){return a&&"FIGURE"===a.nodeName&&/\bimage\b/i.test(a.className)},l=function(a,b){return function(e){a.undoManager.transact(function(){var g=a.selection.getNode(),h=f(a,g),i={href:e.href,target:e.target?e.target:null,rel:e.rel?e.rel:null,"class":e["class"]?e["class"]:null,title:e.title?e.title:null};c.hasRelList(a.settings)||c.allowUnsafeLinkTarget(a.settings)!==!1||(i.rel=d(i.rel,"_blank"===i.target)),e.href===b.href&&(b.attach(),b={}),h?(a.focus(),e.hasOwnProperty("text")&&("innerText"in h?h.innerText=e.text:h.textContent=e.text),a.dom.setAttribs(h,i),a.selection.select(h),a.undoManager.add()):k(g)?o(a,g,i):e.hasOwnProperty("text")?a.insertContent(a.dom.createHTML("a",i,a.dom.encode(e.text))):a.execCommand("mceInsertLink",!1,i)})}},m=function(a){return function(){a.undoManager.transact(function(){var b=a.selection.getNode();k(b)?n(a,b):a.execCommand("unlink")})}},n=function(a,b){var c,d;d=a.dom.select("img",b)[0],d&&(c=a.dom.getParents(d,"a[href]",b)[0],c&&(c.parentNode.insertBefore(d,c),a.dom.remove(c)))},o=function(a,b,c){var d,e;e=a.dom.select("img",b)[0],e&&(d=a.dom.create("a",c),e.parentNode.insertBefore(d,e),d.appendChild(e))};return{link:l,unlink:m,isLink:h,hasLinks:i,isOnlyTextSelected:j,getAnchorElement:f,getAnchorText:g,toggleTargetRules:d}}),g("i",["6"],function(a){return a("tinymce.util.Delay")}),g("j",["6"],function(a){return a("tinymce.util.XHR")}),g("b",["i","h","j","8","a"],function(a,b,c,d,e){var f={},g=function(a,b){var e=d.getLinkList(a.settings);"string"==typeof e?c.send({url:e,success:function(c){b(a,JSON.parse(c))}}):"function"==typeof e?e(function(c){b(a,c)}):b(a,e)},h=function(a,c,d){var e=function(a,d){return d=d||[],b.each(a,function(a){var b={text:a.text||a.title};a.menu?b.menu=e(a.menu):(b.value=a.value,c&&c(b)),d.push(b)}),d};return e(a,d||[])},i=function(b,c,d){var e=b.selection.getRng();a.setEditorTimeout(b,function(){b.windowManager.confirm(c,function(a){b.selection.setRng(e),d(a)})})},j=function(a,c){var g,j,k,l,m,n,o,p,q,r,s,t={},u=a.selection,v=a.dom,w=function(a){var b=k.find("#text");(!b.value()||a.lastControl&&b.value()===a.lastControl.text())&&b.value(a.control.text()),k.find("#href").value(a.control.value())},x=function(c){var d=[];if(b.each(a.dom.select("a:not([href])"),function(a){var b=a.name||a.id;b&&d.push({text:b,value:"#"+b,selected:c.indexOf("#"+b)!==-1})}),d.length)return d.unshift({text:"None",value:""}),{name:"anchor",type:"listbox",label:"Anchors",values:d,onselect:w}},y=function(){j||!l||t.text||this.parent().parent().find("#text")[0].value(this.value())},z=function(c){var d=c.meta||{};n&&n.value(a.convertURL(this.value(),"href")),b.each(c.meta,function(a,b){var c=k.find("#"+b);"text"===b?0===j.length&&(c.value(a),t.text=a):c.value(a)}),d.attach&&(f={href:this.value(),attach:d.attach}),d.text||y.call(this)},A=function(a){a.meta=k.toJSON()};l=e.isOnlyTextSelected(u.getContent()),g=e.getAnchorElement(a),t.text=j=e.getAnchorText(a.selection,g),t.href=g?v.getAttrib(g,"href"):"",g?t.target=v.getAttrib(g,"target"):d.hasDefaultLinkTarget(a.settings)&&(t.target=d.getDefaultLinkTarget(a.settings)),(s=v.getAttrib(g,"rel"))&&(t.rel=s),(s=v.getAttrib(g,"class"))&&(t["class"]=s),(s=v.getAttrib(g,"title"))&&(t.title=s),l&&(m={name:"text",type:"textbox",size:40,label:"Text to display",onchange:function(){t.text=this.value()}}),c&&(n={type:"listbox",label:"Link list",values:h(c,function(b){b.value=a.convertURL(b.value||b.url,"href")},[{text:"None",value:""}]),onselect:w,value:a.convertURL(t.href,"href"),onPostRender:function(){n=this}}),d.shouldShowTargetList(a.settings)&&(void 0===d.getTargetList(a.settings)&&d.setTargetList(a,[{text:"None",value:""},{text:"New window",value:"_blank"}]),p={name:"target",type:"listbox",label:"Target",values:h(d.getTargetList(a.settings))}),d.hasRelList(a.settings)&&(o={name:"rel",type:"listbox",label:"Rel",values:h(d.getRelList(a.settings),function(b){d.allowUnsafeLinkTarget(a.settings)===!1&&(b.value=e.toggleTargetRules(b.value,"_blank"===t.target))})}),d.hasLinkClassList(a.settings)&&(q={name:"class",type:"listbox",label:"Class",values:h(d.getLinkClassList(a.settings),function(b){b.value&&(b.textStyle=function(){return a.formatter.getCssText({inline:"a",classes:[b.value]})})})}),d.shouldShowLinkTitle(a.settings)&&(r={name:"title",type:"textbox",label:"Title",value:t.title}),k=a.windowManager.open({title:"Insert link",data:t,body:[{name:"href",type:"filepicker",filetype:"file",size:40,autofocus:!0,label:"Url",onchange:z,onkeyup:y,onbeforecall:A},m,r,x(t.href),n,o,p,q],onSubmit:function(c){var g=d.assumeExternalTargets(a.settings),h=e.link(a,f),k=e.unlink(a),m=b.extend({},t,c.data),n=m.href;return n?(l&&m.text!==j||delete m.text,n.indexOf("@")>0&&n.indexOf("//")===-1&&n.indexOf("mailto:")===-1?void i(a,"The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?",function(a){a&&(m.href="mailto:"+n),h(m)}):g===!0&&!/^\w+:/i.test(n)||g===!1&&/^\s*www[\.|\d\.]/i.test(n)?void i(a,"The URL you entered seems to be an external link. Do you want to add the required http:// prefix?",function(a){a&&(m.href="http://"+n),h(m)}):void h(m)):void k()}})},k=function(a){g(a,j)};return{open:k}}),g("3",["7","8","9","a","b"],function(a,b,c,d,e){var f=function(a,b){return a.dom.getParent(b,"a[href]")},g=function(a){return f(a,a.selection.getStart())},h=function(a){var b=a.getAttribute("data-mce-href");return b?b:a.getAttribute("href")},i=function(a){var b=a.plugins.contextmenu;return!!b&&b.isContextMenuVisible()},j=function(a){return a.altKey===!0&&a.shiftKey===!1&&a.ctrlKey===!1&&a.metaKey===!1},k=function(a,b){if(b){var d=h(b);if(/^#/.test(d)){var e=a.$(d);e.length&&a.selection.scrollIntoView(e[0],!0)}else c.open(b.href)}},l=function(a){return function(){e.open(a)}},m=function(a){return function(){k(a,g(a))}},n=function(a){return function(c){var e,f,g;return!!(b.hasContextToolbar(a.settings)&&!i(a)&&d.isLink(c)&&(e=a.selection,f=e.getRng(),g=f.startContainer,3===g.nodeType&&e.isCollapsed()&&f.startOffset>0&&f.startOffset<g.data.length))}},o=function(b){b.on("click",function(c){var d=f(b,c.target);d&&a.metaKeyPressed(c)&&(c.preventDefault(),k(b,d))}),b.on("keydown",function(a){var c=g(b);c&&13===a.keyCode&&j(a)&&(a.preventDefault(),k(b,c))})},p=function(a){return function(){var b=this;a.on("nodechange",function(c){b.active(!a.readonly&&!!d.getAnchorElement(a,c.element))})}},q=function(a){return function(){var b=this,c=function(a){d.hasLinks(a.parents)?b.show():b.hide()};d.hasLinks(a.dom.getParents(a.selection.getStart()))||b.hide(),a.on("nodechange",c),b.on("remove",function(){a.off("nodechange",c)})}};return{openDialog:l,gotoSelectedLink:m,leftClickedOnAHref:n,setupGotoLinks:o,toggleActiveState:p,toggleViewLinkState:q}}),g("2",["3"],function(a){var b=function(b){b.addCommand("mceLink",a.openDialog(b))};return{register:b}}),g("4",["3"],function(a){var b=function(b){b.addShortcut("Meta+K","",a.openDialog(b))};return{setup:b}}),g("5",["3","a"],function(a,b){var c=function(c){c.addButton("link",{active:!1,icon:"link",tooltip:"Insert/edit link",onclick:a.openDialog(c),onpostrender:a.toggleActiveState(c)}),c.addButton("unlink",{active:!1,icon:"unlink",tooltip:"Remove link",onclick:b.unlink(c),onpostrender:a.toggleActiveState(c)}),c.addContextToolbar&&c.addButton("openlink",{icon:"newtab",tooltip:"Open link",onclick:a.gotoSelectedLink(c)})},d=function(b){b.addMenuItem("openlink",{text:"Open link",icon:"newtab",onclick:a.gotoSelectedLink(b),onPostRender:a.toggleViewLinkState(b),prependToContext:!0}),b.addMenuItem("link",{icon:"link",text:"Link",shortcut:"Meta+K",onclick:a.openDialog(b),stateSelector:"a[href]",context:"insert",prependToContext:!0})},e=function(b){b.addContextToolbar&&b.addContextToolbar(a.leftClickedOnAHref(b),"openlink | link unlink")};return{setupButtons:c,setupMenuItems:d,setupContextToolbars:e}}),g("0",["1","2","3","4","5"],function(a,b,c,d,e){return a.add("link",function(a){e.setupButtons(a),e.setupMenuItems(a),e.setupContextToolbars(a),c.setupGotoLinks(a),b.register(a),d.setup(a)}),function(){}}),d("0")()}();
@@ -0,0 +1,7 @@
1
+ // Exports the "lists" plugin for usage with module loaders
2
+ // Usage:
3
+ // CommonJS:
4
+ // require('tinymce/plugins/lists')
5
+ // ES2015:
6
+ // import 'tinymce/plugins/lists'
7
+ require('./plugin.js');
@@ -0,0 +1,1985 @@
1
+ (function () {
2
+
3
+ var defs = {}; // id -> {dependencies, definition, instance (possibly undefined)}
4
+
5
+ // Used when there is no 'main' module.
6
+ // The name is probably (hopefully) unique so minification removes for releases.
7
+ var register_3795 = function (id) {
8
+ var module = dem(id);
9
+ var fragments = id.split('.');
10
+ var target = Function('return this;')();
11
+ for (var i = 0; i < fragments.length - 1; ++i) {
12
+ if (target[fragments[i]] === undefined)
13
+ target[fragments[i]] = {};
14
+ target = target[fragments[i]];
15
+ }
16
+ target[fragments[fragments.length - 1]] = module;
17
+ };
18
+
19
+ var instantiate = function (id) {
20
+ var actual = defs[id];
21
+ var dependencies = actual.deps;
22
+ var definition = actual.defn;
23
+ var len = dependencies.length;
24
+ var instances = new Array(len);
25
+ for (var i = 0; i < len; ++i)
26
+ instances[i] = dem(dependencies[i]);
27
+ var defResult = definition.apply(null, instances);
28
+ if (defResult === undefined)
29
+ throw 'module [' + id + '] returned undefined';
30
+ actual.instance = defResult;
31
+ };
32
+
33
+ var def = function (id, dependencies, definition) {
34
+ if (typeof id !== 'string')
35
+ throw 'module id must be a string';
36
+ else if (dependencies === undefined)
37
+ throw 'no dependencies for ' + id;
38
+ else if (definition === undefined)
39
+ throw 'no definition function for ' + id;
40
+ defs[id] = {
41
+ deps: dependencies,
42
+ defn: definition,
43
+ instance: undefined
44
+ };
45
+ };
46
+
47
+ var dem = function (id) {
48
+ var actual = defs[id];
49
+ if (actual === undefined)
50
+ throw 'module [' + id + '] was undefined';
51
+ else if (actual.instance === undefined)
52
+ instantiate(id);
53
+ return actual.instance;
54
+ };
55
+
56
+ var req = function (ids, callback) {
57
+ var len = ids.length;
58
+ var instances = new Array(len);
59
+ for (var i = 0; i < len; ++i)
60
+ instances[i] = dem(ids[i]);
61
+ callback.apply(null, instances);
62
+ };
63
+
64
+ var ephox = {};
65
+
66
+ ephox.bolt = {
67
+ module: {
68
+ api: {
69
+ define: def,
70
+ require: req,
71
+ demand: dem
72
+ }
73
+ }
74
+ };
75
+
76
+ var define = def;
77
+ var require = req;
78
+ var demand = dem;
79
+ // this helps with minification when using a lot of global references
80
+ var defineGlobal = function (id, ref) {
81
+ define(id, [], function () { return ref; });
82
+ };
83
+ /*jsc
84
+ ["tinymce.plugins.lists.Plugin","tinymce.core.PluginManager","tinymce.plugins.lists.api.Api","tinymce.plugins.lists.api.Commands","tinymce.plugins.lists.core.Keyboard","tinymce.plugins.lists.ui.Buttons","global!tinymce.util.Tools.resolve","tinymce.plugins.lists.core.Delete","tinymce.plugins.lists.actions.Indent","tinymce.plugins.lists.actions.Outdent","tinymce.plugins.lists.actions.ToggleList","tinymce.core.util.VK","tinymce.plugins.lists.api.Settings","tinymce.core.util.Tools","tinymce.plugins.lists.core.NodeType","tinymce.plugins.lists.core.Selection","tinymce.core.api.dom.RangeUtils","tinymce.core.dom.TreeWalker","tinymce.core.api.dom.BookmarkManager","tinymce.core.dom.DOMUtils","tinymce.plugins.lists.core.Bookmark","tinymce.plugins.lists.core.NormalizeLists","tinymce.core.dom.DomQuery","tinymce.plugins.lists.core.SplitList","tinymce.plugins.lists.core.TextBlock","tinymce.plugins.lists.core.Range","tinymce.core.Env"]
85
+ jsc*/
86
+ defineGlobal("global!tinymce.util.Tools.resolve", tinymce.util.Tools.resolve);
87
+ /**
88
+ * ResolveGlobal.js
89
+ *
90
+ * Released under LGPL License.
91
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
92
+ *
93
+ * License: http://www.tinymce.com/license
94
+ * Contributing: http://www.tinymce.com/contributing
95
+ */
96
+
97
+ define(
98
+ 'tinymce.core.PluginManager',
99
+ [
100
+ 'global!tinymce.util.Tools.resolve'
101
+ ],
102
+ function (resolve) {
103
+ return resolve('tinymce.PluginManager');
104
+ }
105
+ );
106
+
107
+ /**
108
+ * ResolveGlobal.js
109
+ *
110
+ * Released under LGPL License.
111
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
112
+ *
113
+ * License: http://www.tinymce.com/license
114
+ * Contributing: http://www.tinymce.com/contributing
115
+ */
116
+
117
+ define(
118
+ 'tinymce.core.api.dom.RangeUtils',
119
+ [
120
+ 'global!tinymce.util.Tools.resolve'
121
+ ],
122
+ function (resolve) {
123
+ return resolve('tinymce.dom.RangeUtils');
124
+ }
125
+ );
126
+
127
+ /**
128
+ * ResolveGlobal.js
129
+ *
130
+ * Released under LGPL License.
131
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
132
+ *
133
+ * License: http://www.tinymce.com/license
134
+ * Contributing: http://www.tinymce.com/contributing
135
+ */
136
+
137
+ define(
138
+ 'tinymce.core.dom.TreeWalker',
139
+ [
140
+ 'global!tinymce.util.Tools.resolve'
141
+ ],
142
+ function (resolve) {
143
+ return resolve('tinymce.dom.TreeWalker');
144
+ }
145
+ );
146
+
147
+ /**
148
+ * ResolveGlobal.js
149
+ *
150
+ * Released under LGPL License.
151
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
152
+ *
153
+ * License: http://www.tinymce.com/license
154
+ * Contributing: http://www.tinymce.com/contributing
155
+ */
156
+
157
+ define(
158
+ 'tinymce.core.util.VK',
159
+ [
160
+ 'global!tinymce.util.Tools.resolve'
161
+ ],
162
+ function (resolve) {
163
+ return resolve('tinymce.util.VK');
164
+ }
165
+ );
166
+
167
+ /**
168
+ * ResolveGlobal.js
169
+ *
170
+ * Released under LGPL License.
171
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
172
+ *
173
+ * License: http://www.tinymce.com/license
174
+ * Contributing: http://www.tinymce.com/contributing
175
+ */
176
+
177
+ define(
178
+ 'tinymce.core.api.dom.BookmarkManager',
179
+ [
180
+ 'global!tinymce.util.Tools.resolve'
181
+ ],
182
+ function (resolve) {
183
+ return resolve('tinymce.dom.BookmarkManager');
184
+ }
185
+ );
186
+
187
+ /**
188
+ * ResolveGlobal.js
189
+ *
190
+ * Released under LGPL License.
191
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
192
+ *
193
+ * License: http://www.tinymce.com/license
194
+ * Contributing: http://www.tinymce.com/contributing
195
+ */
196
+
197
+ define(
198
+ 'tinymce.core.util.Tools',
199
+ [
200
+ 'global!tinymce.util.Tools.resolve'
201
+ ],
202
+ function (resolve) {
203
+ return resolve('tinymce.util.Tools');
204
+ }
205
+ );
206
+
207
+ /**
208
+ * ResolveGlobal.js
209
+ *
210
+ * Released under LGPL License.
211
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
212
+ *
213
+ * License: http://www.tinymce.com/license
214
+ * Contributing: http://www.tinymce.com/contributing
215
+ */
216
+
217
+ define(
218
+ 'tinymce.core.dom.DOMUtils',
219
+ [
220
+ 'global!tinymce.util.Tools.resolve'
221
+ ],
222
+ function (resolve) {
223
+ return resolve('tinymce.dom.DOMUtils');
224
+ }
225
+ );
226
+
227
+ /**
228
+ * NodeType.js
229
+ *
230
+ * Released under LGPL License.
231
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
232
+ *
233
+ * License: http://www.tinymce.com/license
234
+ * Contributing: http://www.tinymce.com/contributing
235
+ */
236
+
237
+ define(
238
+ 'tinymce.plugins.lists.core.NodeType',
239
+ [
240
+ ],
241
+ function () {
242
+ var isTextNode = function (node) {
243
+ return node && node.nodeType === 3;
244
+ };
245
+
246
+ var isListNode = function (node) {
247
+ return node && (/^(OL|UL|DL)$/).test(node.nodeName);
248
+ };
249
+
250
+ var isListItemNode = function (node) {
251
+ return node && /^(LI|DT|DD)$/.test(node.nodeName);
252
+ };
253
+
254
+ var isTableCellNode = function (node) {
255
+ return node && /^(TH|TD)$/.test(node.nodeName);
256
+ };
257
+
258
+ var isBr = function (node) {
259
+ return node && node.nodeName === 'BR';
260
+ };
261
+
262
+ var isFirstChild = function (node) {
263
+ return node.parentNode.firstChild === node;
264
+ };
265
+
266
+ var isLastChild = function (node) {
267
+ return node.parentNode.lastChild === node;
268
+ };
269
+
270
+ var isTextBlock = function (editor, node) {
271
+ return node && !!editor.schema.getTextBlockElements()[node.nodeName];
272
+ };
273
+
274
+ var isBlock = function (node, blockElements) {
275
+ return node && node.nodeName in blockElements;
276
+ };
277
+
278
+ var isBogusBr = function (dom, node) {
279
+ if (!isBr(node)) {
280
+ return false;
281
+ }
282
+
283
+ if (dom.isBlock(node.nextSibling) && !isBr(node.previousSibling)) {
284
+ return true;
285
+ }
286
+
287
+ return false;
288
+ };
289
+
290
+ var isEmpty = function (dom, elm, keepBookmarks) {
291
+ var empty = dom.isEmpty(elm);
292
+
293
+ if (keepBookmarks && dom.select('span[data-mce-type=bookmark]', elm).length > 0) {
294
+ return false;
295
+ }
296
+
297
+ return empty;
298
+ };
299
+
300
+ var isChildOfBody = function (dom, elm) {
301
+ return dom.isChildOf(elm, dom.getRoot());
302
+ };
303
+
304
+ return {
305
+ isTextNode: isTextNode,
306
+ isListNode: isListNode,
307
+ isListItemNode: isListItemNode,
308
+ isTableCellNode: isTableCellNode,
309
+ isBr: isBr,
310
+ isFirstChild: isFirstChild,
311
+ isLastChild: isLastChild,
312
+ isTextBlock: isTextBlock,
313
+ isBlock: isBlock,
314
+ isBogusBr: isBogusBr,
315
+ isEmpty: isEmpty,
316
+ isChildOfBody: isChildOfBody
317
+ };
318
+ }
319
+ );
320
+
321
+
322
+ /**
323
+ * Range.js
324
+ *
325
+ * Released under LGPL License.
326
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
327
+ *
328
+ * License: http://www.tinymce.com/license
329
+ * Contributing: http://www.tinymce.com/contributing
330
+ */
331
+
332
+ define(
333
+ 'tinymce.plugins.lists.core.Range',
334
+ [
335
+ 'tinymce.core.api.dom.RangeUtils',
336
+ 'tinymce.plugins.lists.core.NodeType'
337
+ ],
338
+ function (RangeUtils, NodeType) {
339
+ var getNormalizedEndPoint = function (container, offset) {
340
+ var node = RangeUtils.getNode(container, offset);
341
+
342
+ if (NodeType.isListItemNode(container) && NodeType.isTextNode(node)) {
343
+ var textNodeOffset = offset >= container.childNodes.length ? node.data.length : 0;
344
+ return { container: node, offset: textNodeOffset };
345
+ }
346
+
347
+ return { container: container, offset: offset };
348
+ };
349
+
350
+ var normalizeRange = function (rng) {
351
+ var outRng = rng.cloneRange();
352
+
353
+ var rangeStart = getNormalizedEndPoint(rng.startContainer, rng.startOffset);
354
+ outRng.setStart(rangeStart.container, rangeStart.offset);
355
+
356
+ var rangeEnd = getNormalizedEndPoint(rng.endContainer, rng.endOffset);
357
+ outRng.setEnd(rangeEnd.container, rangeEnd.offset);
358
+
359
+ return outRng;
360
+ };
361
+
362
+ return {
363
+ getNormalizedEndPoint: getNormalizedEndPoint,
364
+ normalizeRange: normalizeRange
365
+ };
366
+ }
367
+ );
368
+
369
+
370
+ /**
371
+ * Bookmark.js
372
+ *
373
+ * Released under LGPL License.
374
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
375
+ *
376
+ * License: http://www.tinymce.com/license
377
+ * Contributing: http://www.tinymce.com/contributing
378
+ */
379
+
380
+ define(
381
+ 'tinymce.plugins.lists.core.Bookmark',
382
+ [
383
+ 'tinymce.core.dom.DOMUtils',
384
+ 'tinymce.plugins.lists.core.NodeType',
385
+ 'tinymce.plugins.lists.core.Range'
386
+ ],
387
+ function (DOMUtils, NodeType, Range) {
388
+ var DOM = DOMUtils.DOM;
389
+
390
+ /**
391
+ * Returns a range bookmark. This will convert indexed bookmarks into temporary span elements with
392
+ * index 0 so that they can be restored properly after the DOM has been modified. Text bookmarks will not have spans
393
+ * added to them since they can be restored after a dom operation.
394
+ *
395
+ * So this: <p><b>|</b><b>|</b></p>
396
+ * becomes: <p><b><span data-mce-type="bookmark">|</span></b><b data-mce-type="bookmark">|</span></b></p>
397
+ *
398
+ * @param {DOMRange} rng DOM Range to get bookmark on.
399
+ * @return {Object} Bookmark object.
400
+ */
401
+ var createBookmark = function (rng) {
402
+ var bookmark = {};
403
+
404
+ var setupEndPoint = function (start) {
405
+ var offsetNode, container, offset;
406
+
407
+ container = rng[start ? 'startContainer' : 'endContainer'];
408
+ offset = rng[start ? 'startOffset' : 'endOffset'];
409
+
410
+ if (container.nodeType === 1) {
411
+ offsetNode = DOM.create('span', { 'data-mce-type': 'bookmark' });
412
+
413
+ if (container.hasChildNodes()) {
414
+ offset = Math.min(offset, container.childNodes.length - 1);
415
+
416
+ if (start) {
417
+ container.insertBefore(offsetNode, container.childNodes[offset]);
418
+ } else {
419
+ DOM.insertAfter(offsetNode, container.childNodes[offset]);
420
+ }
421
+ } else {
422
+ container.appendChild(offsetNode);
423
+ }
424
+
425
+ container = offsetNode;
426
+ offset = 0;
427
+ }
428
+
429
+ bookmark[start ? 'startContainer' : 'endContainer'] = container;
430
+ bookmark[start ? 'startOffset' : 'endOffset'] = offset;
431
+ };
432
+
433
+ setupEndPoint(true);
434
+
435
+ if (!rng.collapsed) {
436
+ setupEndPoint();
437
+ }
438
+
439
+ return bookmark;
440
+ };
441
+
442
+ var resolveBookmark = function (bookmark) {
443
+ function restoreEndPoint(start) {
444
+ var container, offset, node;
445
+
446
+ var nodeIndex = function (container) {
447
+ var node = container.parentNode.firstChild, idx = 0;
448
+
449
+ while (node) {
450
+ if (node === container) {
451
+ return idx;
452
+ }
453
+
454
+ // Skip data-mce-type=bookmark nodes
455
+ if (node.nodeType !== 1 || node.getAttribute('data-mce-type') !== 'bookmark') {
456
+ idx++;
457
+ }
458
+
459
+ node = node.nextSibling;
460
+ }
461
+
462
+ return -1;
463
+ };
464
+
465
+ container = node = bookmark[start ? 'startContainer' : 'endContainer'];
466
+ offset = bookmark[start ? 'startOffset' : 'endOffset'];
467
+
468
+ if (!container) {
469
+ return;
470
+ }
471
+
472
+ if (container.nodeType === 1) {
473
+ offset = nodeIndex(container);
474
+ container = container.parentNode;
475
+ DOM.remove(node);
476
+
477
+ if (!container.hasChildNodes() && DOM.isBlock(container)) {
478
+ container.appendChild(DOM.create('br'));
479
+ }
480
+ }
481
+
482
+ bookmark[start ? 'startContainer' : 'endContainer'] = container;
483
+ bookmark[start ? 'startOffset' : 'endOffset'] = offset;
484
+ }
485
+
486
+ restoreEndPoint(true);
487
+ restoreEndPoint();
488
+
489
+ var rng = DOM.createRng();
490
+
491
+ rng.setStart(bookmark.startContainer, bookmark.startOffset);
492
+
493
+ if (bookmark.endContainer) {
494
+ rng.setEnd(bookmark.endContainer, bookmark.endOffset);
495
+ }
496
+
497
+ return Range.normalizeRange(rng);
498
+ };
499
+
500
+ return {
501
+ createBookmark: createBookmark,
502
+ resolveBookmark: resolveBookmark
503
+ };
504
+ }
505
+ );
506
+
507
+
508
+ /**
509
+ * NormalizeLists.js
510
+ *
511
+ * Released under LGPL License.
512
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
513
+ *
514
+ * License: http://www.tinymce.com/license
515
+ * Contributing: http://www.tinymce.com/contributing
516
+ */
517
+
518
+ define(
519
+ 'tinymce.plugins.lists.core.NormalizeLists',
520
+ [
521
+ 'tinymce.core.dom.DOMUtils',
522
+ 'tinymce.core.util.Tools',
523
+ 'tinymce.plugins.lists.core.NodeType'
524
+ ],
525
+ function (DOMUtils, Tools, NodeType) {
526
+ var DOM = DOMUtils.DOM;
527
+
528
+ var normalizeList = function (dom, ul) {
529
+ var sibling, parentNode = ul.parentNode;
530
+
531
+ // Move UL/OL to previous LI if it's the only child of a LI
532
+ if (parentNode.nodeName === 'LI' && parentNode.firstChild === ul) {
533
+ sibling = parentNode.previousSibling;
534
+ if (sibling && sibling.nodeName === 'LI') {
535
+ sibling.appendChild(ul);
536
+
537
+ if (NodeType.isEmpty(dom, parentNode)) {
538
+ DOM.remove(parentNode);
539
+ }
540
+ } else {
541
+ DOM.setStyle(parentNode, 'listStyleType', 'none');
542
+ }
543
+ }
544
+
545
+ // Append OL/UL to previous LI if it's in a parent OL/UL i.e. old HTML4
546
+ if (NodeType.isListNode(parentNode)) {
547
+ sibling = parentNode.previousSibling;
548
+ if (sibling && sibling.nodeName === 'LI') {
549
+ sibling.appendChild(ul);
550
+ }
551
+ }
552
+ };
553
+
554
+ var normalizeLists = function (dom, element) {
555
+ Tools.each(Tools.grep(dom.select('ol,ul', element)), function (ul) {
556
+ normalizeList(dom, ul);
557
+ });
558
+ };
559
+
560
+ return {
561
+ normalizeList: normalizeList,
562
+ normalizeLists: normalizeLists
563
+ };
564
+ }
565
+ );
566
+
567
+
568
+ /**
569
+ * ResolveGlobal.js
570
+ *
571
+ * Released under LGPL License.
572
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
573
+ *
574
+ * License: http://www.tinymce.com/license
575
+ * Contributing: http://www.tinymce.com/contributing
576
+ */
577
+
578
+ define(
579
+ 'tinymce.core.dom.DomQuery',
580
+ [
581
+ 'global!tinymce.util.Tools.resolve'
582
+ ],
583
+ function (resolve) {
584
+ return resolve('tinymce.dom.DomQuery');
585
+ }
586
+ );
587
+
588
+ /**
589
+ * Selection.js
590
+ *
591
+ * Released under LGPL License.
592
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
593
+ *
594
+ * License: http://www.tinymce.com/license
595
+ * Contributing: http://www.tinymce.com/contributing
596
+ */
597
+
598
+ define(
599
+ 'tinymce.plugins.lists.core.Selection',
600
+ [
601
+ 'tinymce.core.dom.DomQuery',
602
+ 'tinymce.core.util.Tools',
603
+ 'tinymce.plugins.lists.core.NodeType'
604
+ ],
605
+ function (DomQuery, Tools, NodeType) {
606
+ var getParentList = function (editor) {
607
+ var selectionStart = editor.selection.getStart(true);
608
+
609
+ return editor.dom.getParent(selectionStart, 'OL,UL,DL', getClosestListRootElm(editor, selectionStart));
610
+ };
611
+
612
+ var isParentListSelected = function (parentList, selectedBlocks) {
613
+ return parentList && selectedBlocks.length === 1 && selectedBlocks[0] === parentList;
614
+ };
615
+
616
+ var findSubLists = function (parentList) {
617
+ return Tools.grep(parentList.querySelectorAll('ol,ul,dl'), function (elm) {
618
+ return NodeType.isListNode(elm);
619
+ });
620
+ };
621
+
622
+ var getSelectedSubLists = function (editor) {
623
+ var parentList = getParentList(editor);
624
+ var selectedBlocks = editor.selection.getSelectedBlocks();
625
+
626
+ if (isParentListSelected(parentList, selectedBlocks)) {
627
+ return findSubLists(parentList);
628
+ } else {
629
+ return Tools.grep(selectedBlocks, function (elm) {
630
+ return NodeType.isListNode(elm) && parentList !== elm;
631
+ });
632
+ }
633
+ };
634
+
635
+ var findParentListItemsNodes = function (editor, elms) {
636
+ var listItemsElms = Tools.map(elms, function (elm) {
637
+ var parentLi = editor.dom.getParent(elm, 'li,dd,dt', getClosestListRootElm(editor, elm));
638
+
639
+ return parentLi ? parentLi : elm;
640
+ });
641
+
642
+ return DomQuery.unique(listItemsElms);
643
+ };
644
+
645
+ var getSelectedListItems = function (editor) {
646
+ var selectedBlocks = editor.selection.getSelectedBlocks();
647
+ return Tools.grep(findParentListItemsNodes(editor, selectedBlocks), function (block) {
648
+ return NodeType.isListItemNode(block);
649
+ });
650
+ };
651
+
652
+ var getClosestListRootElm = function (editor, elm) {
653
+ var parentTableCell = editor.dom.getParents(elm, 'TD,TH');
654
+ var root = parentTableCell.length > 0 ? parentTableCell[0] : editor.getBody();
655
+
656
+ return root;
657
+ };
658
+
659
+ return {
660
+ getParentList: getParentList,
661
+ getSelectedSubLists: getSelectedSubLists,
662
+ getSelectedListItems: getSelectedListItems,
663
+ getClosestListRootElm: getClosestListRootElm
664
+ };
665
+ }
666
+ );
667
+
668
+
669
+ /**
670
+ * ResolveGlobal.js
671
+ *
672
+ * Released under LGPL License.
673
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
674
+ *
675
+ * License: http://www.tinymce.com/license
676
+ * Contributing: http://www.tinymce.com/contributing
677
+ */
678
+
679
+ define(
680
+ 'tinymce.core.Env',
681
+ [
682
+ 'global!tinymce.util.Tools.resolve'
683
+ ],
684
+ function (resolve) {
685
+ return resolve('tinymce.Env');
686
+ }
687
+ );
688
+
689
+ /**
690
+ * TextBlock.js
691
+ *
692
+ * Released under LGPL License.
693
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
694
+ *
695
+ * License: http://www.tinymce.com/license
696
+ * Contributing: http://www.tinymce.com/contributing
697
+ */
698
+
699
+ define(
700
+ 'tinymce.plugins.lists.core.TextBlock',
701
+ [
702
+ 'tinymce.core.dom.DOMUtils',
703
+ 'tinymce.core.Env',
704
+ 'tinymce.plugins.lists.core.NodeType'
705
+ ],
706
+ function (DOMUtils, Env, NodeType) {
707
+ var DOM = DOMUtils.DOM;
708
+
709
+ var createNewTextBlock = function (editor, contentNode, blockName) {
710
+ var node, textBlock, fragment = DOM.createFragment(), hasContentNode;
711
+ var blockElements = editor.schema.getBlockElements();
712
+
713
+ if (editor.settings.forced_root_block) {
714
+ blockName = blockName || editor.settings.forced_root_block;
715
+ }
716
+
717
+ if (blockName) {
718
+ textBlock = DOM.create(blockName);
719
+
720
+ if (textBlock.tagName === editor.settings.forced_root_block) {
721
+ DOM.setAttribs(textBlock, editor.settings.forced_root_block_attrs);
722
+ }
723
+
724
+ if (!NodeType.isBlock(contentNode.firstChild, blockElements)) {
725
+ fragment.appendChild(textBlock);
726
+ }
727
+ }
728
+
729
+ if (contentNode) {
730
+ while ((node = contentNode.firstChild)) {
731
+ var nodeName = node.nodeName;
732
+
733
+ if (!hasContentNode && (nodeName !== 'SPAN' || node.getAttribute('data-mce-type') !== 'bookmark')) {
734
+ hasContentNode = true;
735
+ }
736
+
737
+ if (NodeType.isBlock(node, blockElements)) {
738
+ fragment.appendChild(node);
739
+ textBlock = null;
740
+ } else {
741
+ if (blockName) {
742
+ if (!textBlock) {
743
+ textBlock = DOM.create(blockName);
744
+ fragment.appendChild(textBlock);
745
+ }
746
+
747
+ textBlock.appendChild(node);
748
+ } else {
749
+ fragment.appendChild(node);
750
+ }
751
+ }
752
+ }
753
+ }
754
+
755
+ if (!editor.settings.forced_root_block) {
756
+ fragment.appendChild(DOM.create('br'));
757
+ } else {
758
+ // BR is needed in empty blocks on non IE browsers
759
+ if (!hasContentNode && (!Env.ie || Env.ie > 10)) {
760
+ textBlock.appendChild(DOM.create('br', { 'data-mce-bogus': '1' }));
761
+ }
762
+ }
763
+
764
+ return fragment;
765
+ };
766
+
767
+ return {
768
+ createNewTextBlock: createNewTextBlock
769
+ };
770
+ }
771
+ );
772
+
773
+ /**
774
+ * SplitList.js
775
+ *
776
+ * Released under LGPL License.
777
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
778
+ *
779
+ * License: http://www.tinymce.com/license
780
+ * Contributing: http://www.tinymce.com/contributing
781
+ */
782
+
783
+ define(
784
+ 'tinymce.plugins.lists.core.SplitList',
785
+ [
786
+ 'tinymce.core.dom.DOMUtils',
787
+ 'tinymce.plugins.lists.core.NodeType',
788
+ 'tinymce.plugins.lists.core.TextBlock',
789
+ 'tinymce.core.util.Tools'
790
+ ],
791
+ function (DOMUtils, NodeType, TextBlock, Tools) {
792
+ var DOM = DOMUtils.DOM;
793
+
794
+ var splitList = function (editor, ul, li, newBlock) {
795
+ var tmpRng, fragment, bookmarks, node;
796
+
797
+ var removeAndKeepBookmarks = function (targetNode) {
798
+ Tools.each(bookmarks, function (node) {
799
+ targetNode.parentNode.insertBefore(node, li.parentNode);
800
+ });
801
+
802
+ DOM.remove(targetNode);
803
+ };
804
+
805
+ bookmarks = DOM.select('span[data-mce-type="bookmark"]', ul);
806
+ newBlock = newBlock || TextBlock.createNewTextBlock(editor, li);
807
+ tmpRng = DOM.createRng();
808
+ tmpRng.setStartAfter(li);
809
+ tmpRng.setEndAfter(ul);
810
+ fragment = tmpRng.extractContents();
811
+
812
+ for (node = fragment.firstChild; node; node = node.firstChild) {
813
+ if (node.nodeName === 'LI' && editor.dom.isEmpty(node)) {
814
+ DOM.remove(node);
815
+ break;
816
+ }
817
+ }
818
+
819
+ if (!editor.dom.isEmpty(fragment)) {
820
+ DOM.insertAfter(fragment, ul);
821
+ }
822
+
823
+ DOM.insertAfter(newBlock, ul);
824
+
825
+ if (NodeType.isEmpty(editor.dom, li.parentNode)) {
826
+ removeAndKeepBookmarks(li.parentNode);
827
+ }
828
+
829
+ DOM.remove(li);
830
+
831
+ if (NodeType.isEmpty(editor.dom, ul)) {
832
+ DOM.remove(ul);
833
+ }
834
+ };
835
+
836
+ return {
837
+ splitList: splitList
838
+ };
839
+ }
840
+ );
841
+
842
+
843
+ /**
844
+ * Outdent.js
845
+ *
846
+ * Released under LGPL License.
847
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
848
+ *
849
+ * License: http://www.tinymce.com/license
850
+ * Contributing: http://www.tinymce.com/contributing
851
+ */
852
+
853
+ define(
854
+ 'tinymce.plugins.lists.actions.Outdent',
855
+ [
856
+ 'tinymce.core.dom.DOMUtils',
857
+ 'tinymce.plugins.lists.core.Bookmark',
858
+ 'tinymce.plugins.lists.core.NodeType',
859
+ 'tinymce.plugins.lists.core.NormalizeLists',
860
+ 'tinymce.plugins.lists.core.Selection',
861
+ 'tinymce.plugins.lists.core.SplitList',
862
+ 'tinymce.plugins.lists.core.TextBlock'
863
+ ],
864
+ function (DOMUtils, Bookmark, NodeType, NormalizeLists, Selection, SplitList, TextBlock) {
865
+ var DOM = DOMUtils.DOM;
866
+
867
+ var removeEmptyLi = function (dom, li) {
868
+ if (NodeType.isEmpty(dom, li)) {
869
+ DOM.remove(li);
870
+ }
871
+ };
872
+
873
+ var outdent = function (editor, li) {
874
+ var ul = li.parentNode, ulParent = ul.parentNode, newBlock;
875
+
876
+ if (ul === editor.getBody()) {
877
+ return true;
878
+ }
879
+
880
+ if (li.nodeName === 'DD') {
881
+ DOM.rename(li, 'DT');
882
+ return true;
883
+ }
884
+
885
+ if (NodeType.isFirstChild(li) && NodeType.isLastChild(li)) {
886
+ if (ulParent.nodeName === "LI") {
887
+ DOM.insertAfter(li, ulParent);
888
+ removeEmptyLi(editor.dom, ulParent);
889
+ DOM.remove(ul);
890
+ } else if (NodeType.isListNode(ulParent)) {
891
+ DOM.remove(ul, true);
892
+ } else {
893
+ ulParent.insertBefore(TextBlock.createNewTextBlock(editor, li), ul);
894
+ DOM.remove(ul);
895
+ }
896
+
897
+ return true;
898
+ } else if (NodeType.isFirstChild(li)) {
899
+ if (ulParent.nodeName === "LI") {
900
+ DOM.insertAfter(li, ulParent);
901
+ li.appendChild(ul);
902
+ removeEmptyLi(editor.dom, ulParent);
903
+ } else if (NodeType.isListNode(ulParent)) {
904
+ ulParent.insertBefore(li, ul);
905
+ } else {
906
+ ulParent.insertBefore(TextBlock.createNewTextBlock(editor, li), ul);
907
+ DOM.remove(li);
908
+ }
909
+
910
+ return true;
911
+ } else if (NodeType.isLastChild(li)) {
912
+ if (ulParent.nodeName === "LI") {
913
+ DOM.insertAfter(li, ulParent);
914
+ } else if (NodeType.isListNode(ulParent)) {
915
+ DOM.insertAfter(li, ul);
916
+ } else {
917
+ DOM.insertAfter(TextBlock.createNewTextBlock(editor, li), ul);
918
+ DOM.remove(li);
919
+ }
920
+
921
+ return true;
922
+ }
923
+
924
+ if (ulParent.nodeName === 'LI') {
925
+ ul = ulParent;
926
+ newBlock = TextBlock.createNewTextBlock(editor, li, 'LI');
927
+ } else if (NodeType.isListNode(ulParent)) {
928
+ newBlock = TextBlock.createNewTextBlock(editor, li, 'LI');
929
+ } else {
930
+ newBlock = TextBlock.createNewTextBlock(editor, li);
931
+ }
932
+
933
+ SplitList.splitList(editor, ul, li, newBlock);
934
+ NormalizeLists.normalizeLists(editor.dom, ul.parentNode);
935
+
936
+ return true;
937
+ };
938
+
939
+ var outdentSelection = function (editor) {
940
+ var listElements = Selection.getSelectedListItems(editor);
941
+
942
+ if (listElements.length) {
943
+ var bookmark = Bookmark.createBookmark(editor.selection.getRng(true));
944
+ var i, y;
945
+ var root = Selection.getClosestListRootElm(editor, editor.selection.getStart(true));
946
+
947
+ i = listElements.length;
948
+ while (i--) {
949
+ var node = listElements[i].parentNode;
950
+
951
+ while (node && node !== root) {
952
+ y = listElements.length;
953
+ while (y--) {
954
+ if (listElements[y] === node) {
955
+ listElements.splice(i, 1);
956
+ break;
957
+ }
958
+ }
959
+
960
+ node = node.parentNode;
961
+ }
962
+ }
963
+
964
+ for (i = 0; i < listElements.length; i++) {
965
+ if (!outdent(editor, listElements[i]) && i === 0) {
966
+ break;
967
+ }
968
+ }
969
+
970
+ editor.selection.setRng(Bookmark.resolveBookmark(bookmark));
971
+ editor.nodeChanged();
972
+
973
+ return true;
974
+ }
975
+ };
976
+
977
+ return {
978
+ outdent: outdent,
979
+ outdentSelection: outdentSelection
980
+ };
981
+ }
982
+ );
983
+
984
+
985
+ /**
986
+ * ToggleList.js
987
+ *
988
+ * Released under LGPL License.
989
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
990
+ *
991
+ * License: http://www.tinymce.com/license
992
+ * Contributing: http://www.tinymce.com/contributing
993
+ */
994
+
995
+ define(
996
+ 'tinymce.plugins.lists.actions.ToggleList',
997
+ [
998
+ 'tinymce.core.api.dom.BookmarkManager',
999
+ 'tinymce.core.util.Tools',
1000
+ 'tinymce.plugins.lists.actions.Outdent',
1001
+ 'tinymce.plugins.lists.core.Bookmark',
1002
+ 'tinymce.plugins.lists.core.NodeType',
1003
+ 'tinymce.plugins.lists.core.NormalizeLists',
1004
+ 'tinymce.plugins.lists.core.Selection',
1005
+ 'tinymce.plugins.lists.core.SplitList'
1006
+ ],
1007
+ function (BookmarkManager, Tools, Outdent, Bookmark, NodeType, NormalizeLists, Selection, SplitList) {
1008
+ var updateListStyle = function (dom, el, detail) {
1009
+ var type = detail['list-style-type'] ? detail['list-style-type'] : null;
1010
+ dom.setStyle(el, 'list-style-type', type);
1011
+ };
1012
+
1013
+ var setAttribs = function (elm, attrs) {
1014
+ Tools.each(attrs, function (value, key) {
1015
+ elm.setAttribute(key, value);
1016
+ });
1017
+ };
1018
+
1019
+ var updateListAttrs = function (dom, el, detail) {
1020
+ setAttribs(el, detail['list-attributes']);
1021
+ Tools.each(dom.select('li', el), function (li) {
1022
+ setAttribs(li, detail['list-item-attributes']);
1023
+ });
1024
+ };
1025
+
1026
+ var updateListWithDetails = function (dom, el, detail) {
1027
+ updateListStyle(dom, el, detail);
1028
+ updateListAttrs(dom, el, detail);
1029
+ };
1030
+
1031
+ var getEndPointNode = function (editor, rng, start, root) {
1032
+ var container, offset;
1033
+
1034
+ container = rng[start ? 'startContainer' : 'endContainer'];
1035
+ offset = rng[start ? 'startOffset' : 'endOffset'];
1036
+
1037
+ // Resolve node index
1038
+ if (container.nodeType === 1) {
1039
+ container = container.childNodes[Math.min(offset, container.childNodes.length - 1)] || container;
1040
+ }
1041
+
1042
+ if (!start && NodeType.isBr(container.nextSibling)) {
1043
+ container = container.nextSibling;
1044
+ }
1045
+
1046
+ while (container.parentNode !== root) {
1047
+ if (NodeType.isTextBlock(editor, container)) {
1048
+ return container;
1049
+ }
1050
+
1051
+ if (/^(TD|TH)$/.test(container.parentNode.nodeName)) {
1052
+ return container;
1053
+ }
1054
+
1055
+ container = container.parentNode;
1056
+ }
1057
+
1058
+ return container;
1059
+ };
1060
+
1061
+ var getSelectedTextBlocks = function (editor, rng, root) {
1062
+ var textBlocks = [], dom = editor.dom;
1063
+
1064
+ var startNode = getEndPointNode(editor, rng, true, root);
1065
+ var endNode = getEndPointNode(editor, rng, false, root);
1066
+ var block, siblings = [];
1067
+
1068
+ for (var node = startNode; node; node = node.nextSibling) {
1069
+ siblings.push(node);
1070
+
1071
+ if (node === endNode) {
1072
+ break;
1073
+ }
1074
+ }
1075
+
1076
+ Tools.each(siblings, function (node) {
1077
+ if (NodeType.isTextBlock(editor, node)) {
1078
+ textBlocks.push(node);
1079
+ block = null;
1080
+ return;
1081
+ }
1082
+
1083
+ if (dom.isBlock(node) || NodeType.isBr(node)) {
1084
+ if (NodeType.isBr(node)) {
1085
+ dom.remove(node);
1086
+ }
1087
+
1088
+ block = null;
1089
+ return;
1090
+ }
1091
+
1092
+ var nextSibling = node.nextSibling;
1093
+ if (BookmarkManager.isBookmarkNode(node)) {
1094
+ if (NodeType.isTextBlock(editor, nextSibling) || (!nextSibling && node.parentNode === root)) {
1095
+ block = null;
1096
+ return;
1097
+ }
1098
+ }
1099
+
1100
+ if (!block) {
1101
+ block = dom.create('p');
1102
+ node.parentNode.insertBefore(block, node);
1103
+ textBlocks.push(block);
1104
+ }
1105
+
1106
+ block.appendChild(node);
1107
+ });
1108
+
1109
+ return textBlocks;
1110
+ };
1111
+
1112
+ var hasCompatibleStyle = function (dom, sib, detail) {
1113
+ var sibStyle = dom.getStyle(sib, 'list-style-type');
1114
+ var detailStyle = detail ? detail['list-style-type'] : '';
1115
+
1116
+ detailStyle = detailStyle === null ? '' : detailStyle;
1117
+
1118
+ return sibStyle === detailStyle;
1119
+ };
1120
+
1121
+ var applyList = function (editor, listName, detail) {
1122
+ var rng = editor.selection.getRng(true), bookmark, listItemName = 'LI';
1123
+ var root = Selection.getClosestListRootElm(editor, editor.selection.getStart(true));
1124
+ var dom = editor.dom;
1125
+
1126
+ detail = detail ? detail : {};
1127
+
1128
+ if (dom.getContentEditable(editor.selection.getNode()) === "false") {
1129
+ return;
1130
+ }
1131
+
1132
+ listName = listName.toUpperCase();
1133
+
1134
+ if (listName === 'DL') {
1135
+ listItemName = 'DT';
1136
+ }
1137
+
1138
+ bookmark = Bookmark.createBookmark(rng);
1139
+
1140
+ Tools.each(getSelectedTextBlocks(editor, rng, root), function (block) {
1141
+ var listBlock, sibling;
1142
+
1143
+ sibling = block.previousSibling;
1144
+ if (sibling && NodeType.isListNode(sibling) && sibling.nodeName === listName && hasCompatibleStyle(dom, sibling, detail)) {
1145
+ listBlock = sibling;
1146
+ block = dom.rename(block, listItemName);
1147
+ sibling.appendChild(block);
1148
+ } else {
1149
+ listBlock = dom.create(listName);
1150
+ block.parentNode.insertBefore(listBlock, block);
1151
+ listBlock.appendChild(block);
1152
+ block = dom.rename(block, listItemName);
1153
+ }
1154
+
1155
+ updateListWithDetails(dom, listBlock, detail);
1156
+ mergeWithAdjacentLists(editor.dom, listBlock);
1157
+ });
1158
+
1159
+ editor.selection.setRng(Bookmark.resolveBookmark(bookmark));
1160
+ };
1161
+
1162
+ var removeList = function (editor) {
1163
+ var bookmark = Bookmark.createBookmark(editor.selection.getRng(true));
1164
+ var root = Selection.getClosestListRootElm(editor, editor.selection.getStart(true));
1165
+ var listItems = Selection.getSelectedListItems(editor);
1166
+ var emptyListItems = Tools.grep(listItems, function (li) {
1167
+ return editor.dom.isEmpty(li);
1168
+ });
1169
+
1170
+ listItems = Tools.grep(listItems, function (li) {
1171
+ return !editor.dom.isEmpty(li);
1172
+ });
1173
+
1174
+ Tools.each(emptyListItems, function (li) {
1175
+ if (NodeType.isEmpty(editor.dom, li)) {
1176
+ Outdent.outdent(editor, li);
1177
+ return;
1178
+ }
1179
+ });
1180
+
1181
+ Tools.each(listItems, function (li) {
1182
+ var node, rootList;
1183
+
1184
+ if (li.parentNode === editor.getBody()) {
1185
+ return;
1186
+ }
1187
+
1188
+ for (node = li; node && node !== root; node = node.parentNode) {
1189
+ if (NodeType.isListNode(node)) {
1190
+ rootList = node;
1191
+ }
1192
+ }
1193
+
1194
+ SplitList.splitList(editor, rootList, li);
1195
+ NormalizeLists.normalizeLists(editor.dom, rootList.parentNode);
1196
+ });
1197
+
1198
+ editor.selection.setRng(Bookmark.resolveBookmark(bookmark));
1199
+ };
1200
+
1201
+ var isValidLists = function (list1, list2) {
1202
+ return list1 && list2 && NodeType.isListNode(list1) && list1.nodeName === list2.nodeName;
1203
+ };
1204
+
1205
+ var hasSameListStyle = function (dom, list1, list2) {
1206
+ var targetStyle = dom.getStyle(list1, 'list-style-type', true);
1207
+ var style = dom.getStyle(list2, 'list-style-type', true);
1208
+ return targetStyle === style;
1209
+ };
1210
+
1211
+ var hasSameClasses = function (elm1, elm2) {
1212
+ return elm1.className === elm2.className;
1213
+ };
1214
+
1215
+ var shouldMerge = function (dom, list1, list2) {
1216
+ return isValidLists(list1, list2) && hasSameListStyle(dom, list1, list2) && hasSameClasses(list1, list2);
1217
+ };
1218
+
1219
+ var mergeWithAdjacentLists = function (dom, listBlock) {
1220
+ var sibling, node;
1221
+
1222
+ sibling = listBlock.nextSibling;
1223
+ if (shouldMerge(dom, listBlock, sibling)) {
1224
+ while ((node = sibling.firstChild)) {
1225
+ listBlock.appendChild(node);
1226
+ }
1227
+
1228
+ dom.remove(sibling);
1229
+ }
1230
+
1231
+ sibling = listBlock.previousSibling;
1232
+ if (shouldMerge(dom, listBlock, sibling)) {
1233
+ while ((node = sibling.lastChild)) {
1234
+ listBlock.insertBefore(node, listBlock.firstChild);
1235
+ }
1236
+
1237
+ dom.remove(sibling);
1238
+ }
1239
+ };
1240
+
1241
+ var updateList = function (dom, list, listName, detail) {
1242
+ if (list.nodeName !== listName) {
1243
+ var newList = dom.rename(list, listName);
1244
+ updateListWithDetails(dom, newList, detail);
1245
+ } else {
1246
+ updateListWithDetails(dom, list, detail);
1247
+ }
1248
+ };
1249
+
1250
+ var toggleMultipleLists = function (editor, parentList, lists, listName, detail) {
1251
+ if (parentList.nodeName === listName && !hasListStyleDetail(detail)) {
1252
+ removeList(editor, listName);
1253
+ } else {
1254
+ var bookmark = Bookmark.createBookmark(editor.selection.getRng(true));
1255
+
1256
+ Tools.each([parentList].concat(lists), function (elm) {
1257
+ updateList(editor.dom, elm, listName, detail);
1258
+ });
1259
+
1260
+ editor.selection.setRng(Bookmark.resolveBookmark(bookmark));
1261
+ }
1262
+ };
1263
+
1264
+ var hasListStyleDetail = function (detail) {
1265
+ return 'list-style-type' in detail;
1266
+ };
1267
+
1268
+ var toggleSingleList = function (editor, parentList, listName, detail) {
1269
+ if (parentList === editor.getBody()) {
1270
+ return;
1271
+ }
1272
+
1273
+ if (parentList) {
1274
+ if (parentList.nodeName === listName && !hasListStyleDetail(detail)) {
1275
+ removeList(editor, listName);
1276
+ } else {
1277
+ var bookmark = Bookmark.createBookmark(editor.selection.getRng(true));
1278
+ updateListWithDetails(editor.dom, parentList, detail);
1279
+ mergeWithAdjacentLists(editor.dom, editor.dom.rename(parentList, listName));
1280
+ editor.selection.setRng(Bookmark.resolveBookmark(bookmark));
1281
+ }
1282
+ } else {
1283
+ applyList(editor, listName, detail);
1284
+ }
1285
+ };
1286
+
1287
+ var toggleList = function (editor, listName, detail) {
1288
+ var parentList = Selection.getParentList(editor);
1289
+ var selectedSubLists = Selection.getSelectedSubLists(editor);
1290
+
1291
+ detail = detail ? detail : {};
1292
+
1293
+ if (parentList && selectedSubLists.length > 0) {
1294
+ toggleMultipleLists(editor, parentList, selectedSubLists, listName, detail);
1295
+ } else {
1296
+ toggleSingleList(editor, parentList, listName, detail);
1297
+ }
1298
+ };
1299
+
1300
+ return {
1301
+ toggleList: toggleList,
1302
+ removeList: removeList,
1303
+ mergeWithAdjacentLists: mergeWithAdjacentLists
1304
+ };
1305
+ }
1306
+ );
1307
+
1308
+
1309
+ /**
1310
+ * Delete.js
1311
+ *
1312
+ * Released under LGPL License.
1313
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
1314
+ *
1315
+ * License: http://www.tinymce.com/license
1316
+ * Contributing: http://www.tinymce.com/contributing
1317
+ */
1318
+
1319
+ define(
1320
+ 'tinymce.plugins.lists.core.Delete',
1321
+ [
1322
+ 'tinymce.core.api.dom.RangeUtils',
1323
+ 'tinymce.core.dom.TreeWalker',
1324
+ 'tinymce.core.util.VK',
1325
+ 'tinymce.plugins.lists.actions.ToggleList',
1326
+ 'tinymce.plugins.lists.core.Bookmark',
1327
+ 'tinymce.plugins.lists.core.NodeType',
1328
+ 'tinymce.plugins.lists.core.NormalizeLists',
1329
+ 'tinymce.plugins.lists.core.Range',
1330
+ 'tinymce.plugins.lists.core.Selection'
1331
+ ],
1332
+ function (RangeUtils, TreeWalker, VK, ToggleList, Bookmark, NodeType, NormalizeLists, Range, Selection) {
1333
+ var findNextCaretContainer = function (editor, rng, isForward, root) {
1334
+ var node = rng.startContainer, offset = rng.startOffset;
1335
+ var nonEmptyBlocks, walker;
1336
+
1337
+ if (node.nodeType === 3 && (isForward ? offset < node.data.length : offset > 0)) {
1338
+ return node;
1339
+ }
1340
+
1341
+ nonEmptyBlocks = editor.schema.getNonEmptyElements();
1342
+ if (node.nodeType === 1) {
1343
+ node = RangeUtils.getNode(node, offset);
1344
+ }
1345
+
1346
+ walker = new TreeWalker(node, root);
1347
+
1348
+ // Delete at <li>|<br></li> then jump over the bogus br
1349
+ if (isForward) {
1350
+ if (NodeType.isBogusBr(editor.dom, node)) {
1351
+ walker.next();
1352
+ }
1353
+ }
1354
+
1355
+ while ((node = walker[isForward ? 'next' : 'prev2']())) {
1356
+ if (node.nodeName === 'LI' && !node.hasChildNodes()) {
1357
+ return node;
1358
+ }
1359
+
1360
+ if (nonEmptyBlocks[node.nodeName]) {
1361
+ return node;
1362
+ }
1363
+
1364
+ if (node.nodeType === 3 && node.data.length > 0) {
1365
+ return node;
1366
+ }
1367
+ }
1368
+ };
1369
+
1370
+ var hasOnlyOneBlockChild = function (dom, elm) {
1371
+ var childNodes = elm.childNodes;
1372
+ return childNodes.length === 1 && !NodeType.isListNode(childNodes[0]) && dom.isBlock(childNodes[0]);
1373
+ };
1374
+
1375
+ var unwrapSingleBlockChild = function (dom, elm) {
1376
+ if (hasOnlyOneBlockChild(dom, elm)) {
1377
+ dom.remove(elm.firstChild, true);
1378
+ }
1379
+ };
1380
+
1381
+ var moveChildren = function (dom, fromElm, toElm) {
1382
+ var node, targetElm;
1383
+
1384
+ targetElm = hasOnlyOneBlockChild(dom, toElm) ? toElm.firstChild : toElm;
1385
+ unwrapSingleBlockChild(dom, fromElm);
1386
+
1387
+ if (!NodeType.isEmpty(dom, fromElm, true)) {
1388
+ while ((node = fromElm.firstChild)) {
1389
+ targetElm.appendChild(node);
1390
+ }
1391
+ }
1392
+ };
1393
+
1394
+ var mergeLiElements = function (dom, fromElm, toElm) {
1395
+ var node, listNode, ul = fromElm.parentNode;
1396
+
1397
+ if (!NodeType.isChildOfBody(dom, fromElm) || !NodeType.isChildOfBody(dom, toElm)) {
1398
+ return;
1399
+ }
1400
+
1401
+ if (NodeType.isListNode(toElm.lastChild)) {
1402
+ listNode = toElm.lastChild;
1403
+ }
1404
+
1405
+ if (ul === toElm.lastChild) {
1406
+ if (NodeType.isBr(ul.previousSibling)) {
1407
+ dom.remove(ul.previousSibling);
1408
+ }
1409
+ }
1410
+
1411
+ node = toElm.lastChild;
1412
+ if (node && NodeType.isBr(node) && fromElm.hasChildNodes()) {
1413
+ dom.remove(node);
1414
+ }
1415
+
1416
+ if (NodeType.isEmpty(dom, toElm, true)) {
1417
+ dom.$(toElm).empty();
1418
+ }
1419
+
1420
+ moveChildren(dom, fromElm, toElm);
1421
+
1422
+ if (listNode) {
1423
+ toElm.appendChild(listNode);
1424
+ }
1425
+
1426
+ dom.remove(fromElm);
1427
+
1428
+ if (NodeType.isEmpty(dom, ul) && ul !== dom.getRoot()) {
1429
+ dom.remove(ul);
1430
+ }
1431
+ };
1432
+
1433
+ var mergeIntoEmptyLi = function (editor, fromLi, toLi) {
1434
+ editor.dom.$(toLi).empty();
1435
+ mergeLiElements(editor.dom, fromLi, toLi);
1436
+ editor.selection.setCursorLocation(toLi);
1437
+ };
1438
+
1439
+ var mergeForward = function (editor, rng, fromLi, toLi) {
1440
+ var dom = editor.dom;
1441
+
1442
+ if (dom.isEmpty(toLi)) {
1443
+ mergeIntoEmptyLi(editor, fromLi, toLi);
1444
+ } else {
1445
+ var bookmark = Bookmark.createBookmark(rng);
1446
+ mergeLiElements(dom, fromLi, toLi);
1447
+ editor.selection.setRng(Bookmark.resolveBookmark(bookmark));
1448
+ }
1449
+ };
1450
+
1451
+ var mergeBackward = function (editor, rng, fromLi, toLi) {
1452
+ var bookmark = Bookmark.createBookmark(rng);
1453
+ mergeLiElements(editor.dom, fromLi, toLi);
1454
+ var resolvedBookmark = Bookmark.resolveBookmark(bookmark);
1455
+ editor.selection.setRng(resolvedBookmark);
1456
+ };
1457
+
1458
+ var backspaceDeleteFromListToListCaret = function (editor, isForward) {
1459
+ var dom = editor.dom, selection = editor.selection;
1460
+ var selectionStartElm = selection.getStart();
1461
+ var root = Selection.getClosestListRootElm(editor, selectionStartElm);
1462
+ var li = dom.getParent(selection.getStart(), 'LI', root);
1463
+ var ul, rng, otherLi;
1464
+
1465
+ if (li) {
1466
+ ul = li.parentNode;
1467
+ if (ul === editor.getBody() && NodeType.isEmpty(dom, ul)) {
1468
+ return true;
1469
+ }
1470
+
1471
+ rng = Range.normalizeRange(selection.getRng(true));
1472
+ otherLi = dom.getParent(findNextCaretContainer(editor, rng, isForward, root), 'LI', root);
1473
+
1474
+ if (otherLi && otherLi !== li) {
1475
+ if (isForward) {
1476
+ mergeForward(editor, rng, otherLi, li);
1477
+ } else {
1478
+ mergeBackward(editor, rng, li, otherLi);
1479
+ }
1480
+
1481
+ return true;
1482
+ } else if (!otherLi) {
1483
+ if (!isForward && ToggleList.removeList(editor, ul.nodeName)) {
1484
+ return true;
1485
+ }
1486
+ }
1487
+ }
1488
+
1489
+ return false;
1490
+ };
1491
+
1492
+ var removeBlock = function (dom, block, root) {
1493
+ var parentBlock = dom.getParent(block.parentNode, dom.isBlock, root);
1494
+
1495
+ dom.remove(block);
1496
+ if (parentBlock && dom.isEmpty(parentBlock)) {
1497
+ dom.remove(parentBlock);
1498
+ }
1499
+ };
1500
+
1501
+ var backspaceDeleteIntoListCaret = function (editor, isForward) {
1502
+ var dom = editor.dom;
1503
+ var selectionStartElm = editor.selection.getStart();
1504
+ var root = Selection.getClosestListRootElm(editor, selectionStartElm);
1505
+ var block = dom.getParent(selectionStartElm, dom.isBlock, root);
1506
+
1507
+ if (block && dom.isEmpty(block)) {
1508
+ var rng = Range.normalizeRange(editor.selection.getRng(true));
1509
+ var otherLi = dom.getParent(findNextCaretContainer(editor, rng, isForward, root), 'LI', root);
1510
+
1511
+ if (otherLi) {
1512
+ editor.undoManager.transact(function () {
1513
+ removeBlock(dom, block, root);
1514
+ ToggleList.mergeWithAdjacentLists(dom, otherLi.parentNode);
1515
+ editor.selection.select(otherLi, true);
1516
+ editor.selection.collapse(isForward);
1517
+ });
1518
+
1519
+ return true;
1520
+ }
1521
+ }
1522
+
1523
+ return false;
1524
+ };
1525
+
1526
+ var backspaceDeleteCaret = function (editor, isForward) {
1527
+ return backspaceDeleteFromListToListCaret(editor, isForward) || backspaceDeleteIntoListCaret(editor, isForward);
1528
+ };
1529
+
1530
+ var backspaceDeleteRange = function (editor) {
1531
+ var selectionStartElm = editor.selection.getStart();
1532
+ var root = Selection.getClosestListRootElm(editor, selectionStartElm);
1533
+ var startListParent = editor.dom.getParent(selectionStartElm, 'LI,DT,DD', root);
1534
+
1535
+ if (startListParent || Selection.getSelectedListItems(editor).length > 0) {
1536
+ editor.undoManager.transact(function () {
1537
+ editor.execCommand('Delete');
1538
+ NormalizeLists.normalizeLists(editor.dom, editor.getBody());
1539
+ });
1540
+
1541
+ return true;
1542
+ }
1543
+
1544
+ return false;
1545
+ };
1546
+
1547
+ var backspaceDelete = function (editor, isForward) {
1548
+ return editor.selection.isCollapsed() ? backspaceDeleteCaret(editor, isForward) : backspaceDeleteRange(editor);
1549
+ };
1550
+
1551
+ var setup = function (editor) {
1552
+ editor.on('keydown', function (e) {
1553
+ if (e.keyCode === VK.BACKSPACE) {
1554
+ if (backspaceDelete(editor, false)) {
1555
+ e.preventDefault();
1556
+ }
1557
+ } else if (e.keyCode === VK.DELETE) {
1558
+ if (backspaceDelete(editor, true)) {
1559
+ e.preventDefault();
1560
+ }
1561
+ }
1562
+ });
1563
+ };
1564
+
1565
+ return {
1566
+ setup: setup,
1567
+ backspaceDelete: backspaceDelete
1568
+ };
1569
+ }
1570
+ );
1571
+
1572
+
1573
+ /**
1574
+ * Api.js
1575
+ *
1576
+ * Released under LGPL License.
1577
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
1578
+ *
1579
+ * License: http://www.tinymce.com/license
1580
+ * Contributing: http://www.tinymce.com/contributing
1581
+ */
1582
+
1583
+ define(
1584
+ 'tinymce.plugins.lists.api.Api',
1585
+ [
1586
+ 'tinymce.plugins.lists.core.Delete'
1587
+ ],
1588
+ function (Delete) {
1589
+ var get = function (editor) {
1590
+ return {
1591
+ backspaceDelete: function (isForward) {
1592
+ Delete.backspaceDelete(editor, isForward);
1593
+ }
1594
+ };
1595
+ };
1596
+
1597
+ return {
1598
+ get: get
1599
+ };
1600
+ }
1601
+ );
1602
+
1603
+
1604
+ /**
1605
+ * Indent.js
1606
+ *
1607
+ * Released under LGPL License.
1608
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
1609
+ *
1610
+ * License: http://www.tinymce.com/license
1611
+ * Contributing: http://www.tinymce.com/contributing
1612
+ */
1613
+
1614
+ define(
1615
+ 'tinymce.plugins.lists.actions.Indent',
1616
+ [
1617
+ 'tinymce.core.dom.DOMUtils',
1618
+ 'tinymce.plugins.lists.core.Bookmark',
1619
+ 'tinymce.plugins.lists.core.NodeType',
1620
+ 'tinymce.plugins.lists.core.Selection'
1621
+ ],
1622
+ function (DOMUtils, Bookmark, NodeType, Selection) {
1623
+ var DOM = DOMUtils.DOM;
1624
+
1625
+ var mergeLists = function (from, to) {
1626
+ var node;
1627
+
1628
+ if (NodeType.isListNode(from)) {
1629
+ while ((node = from.firstChild)) {
1630
+ to.appendChild(node);
1631
+ }
1632
+
1633
+ DOM.remove(from);
1634
+ }
1635
+ };
1636
+
1637
+ var indent = function (li) {
1638
+ var sibling, newList, listStyle;
1639
+
1640
+ if (li.nodeName === 'DT') {
1641
+ DOM.rename(li, 'DD');
1642
+ return true;
1643
+ }
1644
+
1645
+ sibling = li.previousSibling;
1646
+
1647
+ if (sibling && NodeType.isListNode(sibling)) {
1648
+ sibling.appendChild(li);
1649
+ return true;
1650
+ }
1651
+
1652
+ if (sibling && sibling.nodeName === 'LI' && NodeType.isListNode(sibling.lastChild)) {
1653
+ sibling.lastChild.appendChild(li);
1654
+ mergeLists(li.lastChild, sibling.lastChild);
1655
+ return true;
1656
+ }
1657
+
1658
+ sibling = li.nextSibling;
1659
+
1660
+ if (sibling && NodeType.isListNode(sibling)) {
1661
+ sibling.insertBefore(li, sibling.firstChild);
1662
+ return true;
1663
+ }
1664
+
1665
+ /*if (sibling && sibling.nodeName === 'LI' && isListNode(li.lastChild)) {
1666
+ return false;
1667
+ }*/
1668
+
1669
+ sibling = li.previousSibling;
1670
+ if (sibling && sibling.nodeName === 'LI') {
1671
+ newList = DOM.create(li.parentNode.nodeName);
1672
+ listStyle = DOM.getStyle(li.parentNode, 'listStyleType');
1673
+ if (listStyle) {
1674
+ DOM.setStyle(newList, 'listStyleType', listStyle);
1675
+ }
1676
+ sibling.appendChild(newList);
1677
+ newList.appendChild(li);
1678
+ mergeLists(li.lastChild, newList);
1679
+ return true;
1680
+ }
1681
+
1682
+ return false;
1683
+ };
1684
+
1685
+ var indentSelection = function (editor) {
1686
+ var listElements = Selection.getSelectedListItems(editor);
1687
+
1688
+ if (listElements.length) {
1689
+ var bookmark = Bookmark.createBookmark(editor.selection.getRng(true));
1690
+
1691
+ for (var i = 0; i < listElements.length; i++) {
1692
+ if (!indent(listElements[i]) && i === 0) {
1693
+ break;
1694
+ }
1695
+ }
1696
+
1697
+ editor.selection.setRng(Bookmark.resolveBookmark(bookmark));
1698
+ editor.nodeChanged();
1699
+
1700
+ return true;
1701
+ }
1702
+ };
1703
+
1704
+ return {
1705
+ indentSelection: indentSelection
1706
+ };
1707
+ }
1708
+ );
1709
+
1710
+
1711
+ /**
1712
+ * Commands.js
1713
+ *
1714
+ * Released under LGPL License.
1715
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
1716
+ *
1717
+ * License: http://www.tinymce.com/license
1718
+ * Contributing: http://www.tinymce.com/contributing
1719
+ */
1720
+
1721
+ define(
1722
+ 'tinymce.plugins.lists.api.Commands',
1723
+ [
1724
+ 'tinymce.plugins.lists.actions.Indent',
1725
+ 'tinymce.plugins.lists.actions.Outdent',
1726
+ 'tinymce.plugins.lists.actions.ToggleList'
1727
+ ],
1728
+ function (Indent, Outdent, ToggleList) {
1729
+ var queryListCommandState = function (editor, listName) {
1730
+ return function () {
1731
+ var parentList = editor.dom.getParent(editor.selection.getStart(), 'UL,OL,DL');
1732
+ return parentList && parentList.nodeName === listName;
1733
+ };
1734
+ };
1735
+
1736
+ var register = function (editor) {
1737
+ editor.on('BeforeExecCommand', function (e) {
1738
+ var cmd = e.command.toLowerCase(), isHandled;
1739
+
1740
+ if (cmd === "indent") {
1741
+ if (Indent.indentSelection(editor)) {
1742
+ isHandled = true;
1743
+ }
1744
+ } else if (cmd === "outdent") {
1745
+ if (Outdent.outdentSelection(editor)) {
1746
+ isHandled = true;
1747
+ }
1748
+ }
1749
+
1750
+ if (isHandled) {
1751
+ editor.fire('ExecCommand', { command: e.command });
1752
+ e.preventDefault();
1753
+ return true;
1754
+ }
1755
+ });
1756
+
1757
+ editor.addCommand('InsertUnorderedList', function (ui, detail) {
1758
+ ToggleList.toggleList(editor, 'UL', detail);
1759
+ });
1760
+
1761
+ editor.addCommand('InsertOrderedList', function (ui, detail) {
1762
+ ToggleList.toggleList(editor, 'OL', detail);
1763
+ });
1764
+
1765
+ editor.addCommand('InsertDefinitionList', function (ui, detail) {
1766
+ ToggleList.toggleList(editor, 'DL', detail);
1767
+ });
1768
+
1769
+ editor.addQueryStateHandler('InsertUnorderedList', queryListCommandState(editor, 'UL'));
1770
+ editor.addQueryStateHandler('InsertOrderedList', queryListCommandState(editor, 'OL'));
1771
+ editor.addQueryStateHandler('InsertDefinitionList', queryListCommandState(editor, 'DL'));
1772
+ };
1773
+
1774
+ return {
1775
+ register: register
1776
+ };
1777
+ }
1778
+ );
1779
+
1780
+
1781
+ /**
1782
+ * Settings.js
1783
+ *
1784
+ * Released under LGPL License.
1785
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
1786
+ *
1787
+ * License: http://www.tinymce.com/license
1788
+ * Contributing: http://www.tinymce.com/contributing
1789
+ */
1790
+
1791
+ define(
1792
+ 'tinymce.plugins.lists.api.Settings',
1793
+ [
1794
+ ],
1795
+ function () {
1796
+ var shouldIndentOnTab = function (editor) {
1797
+ return editor.getParam('lists_indent_on_tab', true);
1798
+ };
1799
+
1800
+ return {
1801
+ shouldIndentOnTab: shouldIndentOnTab
1802
+ };
1803
+ }
1804
+ );
1805
+
1806
+
1807
+ /**
1808
+ * Keyboard.js
1809
+ *
1810
+ * Released under LGPL License.
1811
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
1812
+ *
1813
+ * License: http://www.tinymce.com/license
1814
+ * Contributing: http://www.tinymce.com/contributing
1815
+ */
1816
+
1817
+ define(
1818
+ 'tinymce.plugins.lists.core.Keyboard',
1819
+ [
1820
+ 'tinymce.core.util.VK',
1821
+ 'tinymce.plugins.lists.actions.Indent',
1822
+ 'tinymce.plugins.lists.actions.Outdent',
1823
+ 'tinymce.plugins.lists.api.Settings',
1824
+ 'tinymce.plugins.lists.core.Delete'
1825
+ ],
1826
+ function (VK, Indent, Outdent, Settings, Delete) {
1827
+ var setupTabKey = function (editor) {
1828
+ editor.on('keydown', function (e) {
1829
+ // Check for tab but not ctrl/cmd+tab since it switches browser tabs
1830
+ if (e.keyCode !== VK.TAB || VK.metaKeyPressed(e)) {
1831
+ return;
1832
+ }
1833
+
1834
+ if (editor.dom.getParent(editor.selection.getStart(), 'LI,DT,DD')) {
1835
+ e.preventDefault();
1836
+
1837
+ if (e.shiftKey) {
1838
+ Outdent.outdentSelection(editor);
1839
+ } else {
1840
+ Indent.indentSelection(editor);
1841
+ }
1842
+ }
1843
+ });
1844
+ };
1845
+
1846
+ var setup = function (editor) {
1847
+ if (Settings.shouldIndentOnTab(editor)) {
1848
+ setupTabKey(editor);
1849
+ }
1850
+
1851
+ Delete.setup(editor);
1852
+ };
1853
+
1854
+ return {
1855
+ setup: setup
1856
+ };
1857
+ }
1858
+ );
1859
+
1860
+
1861
+ /**
1862
+ * Buttons.js
1863
+ *
1864
+ * Released under LGPL License.
1865
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
1866
+ *
1867
+ * License: http://www.tinymce.com/license
1868
+ * Contributing: http://www.tinymce.com/contributing
1869
+ */
1870
+
1871
+ define(
1872
+ 'tinymce.plugins.lists.ui.Buttons',
1873
+ [
1874
+ 'tinymce.core.util.Tools',
1875
+ 'tinymce.plugins.lists.core.NodeType',
1876
+ 'tinymce.plugins.lists.core.Selection'
1877
+ ],
1878
+ function (Tools, NodeType, Selection) {
1879
+ var findIndex = function (list, predicate) {
1880
+ for (var index = 0; index < list.length; index++) {
1881
+ var element = list[index];
1882
+
1883
+ if (predicate(element)) {
1884
+ return index;
1885
+ }
1886
+ }
1887
+ return -1;
1888
+ };
1889
+ var listState = function (editor, listName) {
1890
+ return function (e) {
1891
+ var ctrl = e.control;
1892
+
1893
+ editor.on('NodeChange', function (e) {
1894
+ var tableCellIndex = findIndex(e.parents, NodeType.isTableCellNode);
1895
+ var parents = tableCellIndex !== -1 ? e.parents.slice(0, tableCellIndex) : e.parents;
1896
+ var lists = Tools.grep(parents, NodeType.isListNode);
1897
+ ctrl.active(lists.length > 0 && lists[0].nodeName === listName);
1898
+ });
1899
+ };
1900
+ };
1901
+
1902
+ var indentPostRender = function (editor) {
1903
+ return function (e) {
1904
+ var ctrl = e.control;
1905
+
1906
+ editor.on('nodechange', function () {
1907
+ var listItemBlocks = Selection.getSelectedListItems(editor);
1908
+ var disable = listItemBlocks.length > 0 && NodeType.isFirstChild(listItemBlocks[0]);
1909
+ ctrl.disabled(disable);
1910
+ });
1911
+ };
1912
+ };
1913
+
1914
+ var register = function (editor) {
1915
+ var hasPlugin = function (editor, plugin) {
1916
+ var plugins = editor.settings.plugins ? editor.settings.plugins : '';
1917
+ return Tools.inArray(plugins.split(/[ ,]/), plugin) !== -1;
1918
+ };
1919
+
1920
+ if (!hasPlugin(editor, 'advlist')) {
1921
+ editor.addButton('numlist', {
1922
+ active: false,
1923
+ title: 'Numbered list',
1924
+ cmd: 'InsertOrderedList',
1925
+ onPostRender: listState(editor, 'OL')
1926
+ });
1927
+
1928
+ editor.addButton('bullist', {
1929
+ active: false,
1930
+ title: 'Bullet list',
1931
+ cmd: 'InsertUnorderedList',
1932
+ onPostRender: listState(editor, 'UL')
1933
+ });
1934
+ }
1935
+
1936
+ editor.addButton('indent', {
1937
+ icon: 'indent',
1938
+ title: 'Increase indent',
1939
+ cmd: 'Indent',
1940
+ onPostRender: indentPostRender(editor)
1941
+ });
1942
+ };
1943
+
1944
+ return {
1945
+ register: register
1946
+ };
1947
+ }
1948
+ );
1949
+
1950
+
1951
+ /**
1952
+ * Plugin.js
1953
+ *
1954
+ * Released under LGPL License.
1955
+ * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
1956
+ *
1957
+ * License: http://www.tinymce.com/license
1958
+ * Contributing: http://www.tinymce.com/contributing
1959
+ */
1960
+
1961
+ define(
1962
+ 'tinymce.plugins.lists.Plugin',
1963
+ [
1964
+ 'tinymce.core.PluginManager',
1965
+ 'tinymce.plugins.lists.api.Api',
1966
+ 'tinymce.plugins.lists.api.Commands',
1967
+ 'tinymce.plugins.lists.core.Keyboard',
1968
+ 'tinymce.plugins.lists.ui.Buttons'
1969
+ ],
1970
+ function (PluginManager, Api, Commands, Keyboard, Buttons) {
1971
+ PluginManager.add('lists', function (editor) {
1972
+ Keyboard.setup(editor);
1973
+ Buttons.register(editor);
1974
+ Commands.register(editor);
1975
+
1976
+ return Api.get(editor);
1977
+ });
1978
+
1979
+ return function () { };
1980
+ }
1981
+ );
1982
+
1983
+
1984
+ dem('tinymce.plugins.lists.Plugin')();
1985
+ })();