gnuside-aloha-rails 0.23.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (826) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +18 -0
  3. data/README.md +48 -0
  4. data/Rakefile +69 -0
  5. data/app/assets/javascripts/aloha.js +3 -0
  6. data/app/assets/javascripts/aloha/preinit.js.erb +1 -0
  7. data/lib/aloha-rails.rb +1 -0
  8. data/lib/aloha/rails.rb +2 -0
  9. data/lib/aloha/rails/engine.rb +9 -0
  10. data/lib/aloha/rails/version.rb +7 -0
  11. data/lib/tasks/aloha-assets.rake +9 -0
  12. data/vendor/assets/javascripts/aloha/css/aloha.scss +31 -0
  13. data/vendor/assets/javascripts/aloha/img/arrow-down.png +0 -0
  14. data/vendor/assets/javascripts/aloha/img/arrow-left.png +0 -0
  15. data/vendor/assets/javascripts/aloha/img/arrow.png +0 -0
  16. data/vendor/assets/javascripts/aloha/img/base-multi.png +0 -0
  17. data/vendor/assets/javascripts/aloha/img/base.png +0 -0
  18. data/vendor/assets/javascripts/aloha/img/bg.png +0 -0
  19. data/vendor/assets/javascripts/aloha/img/breadcrumb-divider.png +0 -0
  20. data/vendor/assets/javascripts/aloha/img/gentics-logo.png +0 -0
  21. data/vendor/assets/javascripts/aloha/img/grabhandle.png +0 -0
  22. data/vendor/assets/javascripts/aloha/img/maximize.png +0 -0
  23. data/vendor/assets/javascripts/aloha/img/multisplit-base.jpg +0 -0
  24. data/vendor/assets/javascripts/aloha/img/multisplit-close.gif +0 -0
  25. data/vendor/assets/javascripts/aloha/img/multisplit-open.gif +0 -0
  26. data/vendor/assets/javascripts/aloha/img/pin.png +0 -0
  27. data/vendor/assets/javascripts/aloha/img/removeformat.png +0 -0
  28. data/vendor/assets/javascripts/aloha/img/text_indent.png +0 -0
  29. data/vendor/assets/javascripts/aloha/img/text_indent_remove.png +0 -0
  30. data/vendor/assets/javascripts/aloha/lib/aloha-jquery-noconflict.js +14 -0
  31. data/vendor/assets/javascripts/aloha/lib/aloha.js +595 -0
  32. data/vendor/assets/javascripts/aloha/lib/aloha/block-jump.js +153 -0
  33. data/vendor/assets/javascripts/aloha/lib/aloha/command.js +287 -0
  34. data/vendor/assets/javascripts/aloha/lib/aloha/console.js +347 -0
  35. data/vendor/assets/javascripts/aloha/lib/aloha/contenthandlermanager.js +104 -0
  36. data/vendor/assets/javascripts/aloha/lib/aloha/copypaste.js +108 -0
  37. data/vendor/assets/javascripts/aloha/lib/aloha/core.js +623 -0
  38. data/vendor/assets/javascripts/aloha/lib/aloha/ecma5shims.js +326 -0
  39. data/vendor/assets/javascripts/aloha/lib/aloha/editable.js +1042 -0
  40. data/vendor/assets/javascripts/aloha/lib/aloha/engine.js +8646 -0
  41. data/vendor/assets/javascripts/aloha/lib/aloha/ephemera.js +492 -0
  42. data/vendor/assets/javascripts/aloha/lib/aloha/ierange-m2.js +29 -0
  43. data/vendor/assets/javascripts/aloha/lib/aloha/jquery.aloha.js +542 -0
  44. data/vendor/assets/javascripts/aloha/lib/aloha/markup.js +1276 -0
  45. data/vendor/assets/javascripts/aloha/lib/aloha/nls/ca/i18n.js +11 -0
  46. data/vendor/assets/javascripts/aloha/lib/aloha/nls/de/i18n.js +11 -0
  47. data/vendor/assets/javascripts/aloha/lib/aloha/nls/i18n.js +20 -0
  48. data/vendor/assets/javascripts/aloha/lib/aloha/nls/mk/i18n.js +11 -0
  49. data/vendor/assets/javascripts/aloha/lib/aloha/nls/pt-br/i18n.js +11 -0
  50. data/vendor/assets/javascripts/aloha/lib/aloha/nls/ru/i18n.js +11 -0
  51. data/vendor/assets/javascripts/aloha/lib/aloha/nls/uk/i18n.js +11 -0
  52. data/vendor/assets/javascripts/aloha/lib/aloha/nls/zh-hans/i18n.js +11 -0
  53. data/vendor/assets/javascripts/aloha/lib/aloha/observable.js +113 -0
  54. data/vendor/assets/javascripts/aloha/lib/aloha/plugin.js +281 -0
  55. data/vendor/assets/javascripts/aloha/lib/aloha/pluginmanager.js +203 -0
  56. data/vendor/assets/javascripts/aloha/lib/aloha/rangy-core.js +30 -0
  57. data/vendor/assets/javascripts/aloha/lib/aloha/registry.js +137 -0
  58. data/vendor/assets/javascripts/aloha/lib/aloha/repository.js +255 -0
  59. data/vendor/assets/javascripts/aloha/lib/aloha/repositorymanager.js +742 -0
  60. data/vendor/assets/javascripts/aloha/lib/aloha/repositoryobjects.js +162 -0
  61. data/vendor/assets/javascripts/aloha/lib/aloha/selection.js +2402 -0
  62. data/vendor/assets/javascripts/aloha/lib/aloha/sidebar.js +1045 -0
  63. data/vendor/assets/javascripts/aloha/lib/aloha/state-override.js +147 -0
  64. data/vendor/assets/javascripts/aloha/lib/css.js +455 -0
  65. data/vendor/assets/javascripts/aloha/lib/i18n.js +192 -0
  66. data/vendor/assets/javascripts/aloha/lib/require.js +2053 -0
  67. data/vendor/assets/javascripts/aloha/lib/text.js +288 -0
  68. data/vendor/assets/javascripts/aloha/lib/util/arrays.js +287 -0
  69. data/vendor/assets/javascripts/aloha/lib/util/boundary-markers.js +86 -0
  70. data/vendor/assets/javascripts/aloha/lib/util/browser.js +32 -0
  71. data/vendor/assets/javascripts/aloha/lib/util/class.js +78 -0
  72. data/vendor/assets/javascripts/aloha/lib/util/dom.js +1888 -0
  73. data/vendor/assets/javascripts/aloha/lib/util/dom2.js +908 -0
  74. data/vendor/assets/javascripts/aloha/lib/util/functions.js +62 -0
  75. data/vendor/assets/javascripts/aloha/lib/util/html.js +311 -0
  76. data/vendor/assets/javascripts/aloha/lib/util/json2.js +464 -0
  77. data/vendor/assets/javascripts/aloha/lib/util/keys.js +65 -0
  78. data/vendor/assets/javascripts/aloha/lib/util/lang.js +89 -0
  79. data/vendor/assets/javascripts/aloha/lib/util/maps.js +130 -0
  80. data/vendor/assets/javascripts/aloha/lib/util/misc.js +51 -0
  81. data/vendor/assets/javascripts/aloha/lib/util/position.js +176 -0
  82. data/vendor/assets/javascripts/aloha/lib/util/range-context.js +776 -0
  83. data/vendor/assets/javascripts/aloha/lib/util/range.js +917 -0
  84. data/vendor/assets/javascripts/aloha/lib/util/strings.js +122 -0
  85. data/vendor/assets/javascripts/aloha/lib/util/trees.js +336 -0
  86. data/vendor/assets/javascripts/aloha/lib/vendor/3rdparty.txt +70 -0
  87. data/vendor/assets/javascripts/aloha/lib/vendor/amplify.store.js +298 -0
  88. data/vendor/assets/javascripts/aloha/lib/vendor/class.js +76 -0
  89. data/vendor/assets/javascripts/aloha/lib/vendor/grid.locale.de.js +138 -0
  90. data/vendor/assets/javascripts/aloha/lib/vendor/grid.locale.en.js +133 -0
  91. data/vendor/assets/javascripts/aloha/lib/vendor/ierange-m2.js +508 -0
  92. data/vendor/assets/javascripts/aloha/lib/vendor/jquery-1.7.2.js +9421 -0
  93. data/vendor/assets/javascripts/aloha/lib/vendor/jquery-ui-1.9.0.custom-aloha.js +14711 -0
  94. data/vendor/assets/javascripts/aloha/lib/vendor/jquery.jqgrid.js +474 -0
  95. data/vendor/assets/javascripts/aloha/lib/vendor/jquery.jstree.js +4549 -0
  96. data/vendor/assets/javascripts/aloha/lib/vendor/jquery.layout-1.3.0-rc30.7.js +5924 -0
  97. data/vendor/assets/javascripts/aloha/lib/vendor/pubsub/js/pubsub-unminified.js +187 -0
  98. data/vendor/assets/javascripts/aloha/lib/vendor/pubsub/js/pubsub.js +2 -0
  99. data/vendor/assets/javascripts/aloha/lib/vendor/rangy-core.js +3295 -0
  100. data/vendor/assets/javascripts/aloha/lib/vendor/repository-browser/css/jstree.css +88 -0
  101. data/vendor/assets/javascripts/aloha/lib/vendor/repository-browser/css/repository-browser.css +744 -0
  102. data/vendor/assets/javascripts/aloha/lib/vendor/repository-browser/img/arrow-000-medium.png +0 -0
  103. data/vendor/assets/javascripts/aloha/lib/vendor/repository-browser/img/arrow-180.png +0 -0
  104. data/vendor/assets/javascripts/aloha/lib/vendor/repository-browser/img/arrow-315-medium.png +0 -0
  105. data/vendor/assets/javascripts/aloha/lib/vendor/repository-browser/img/arrow-stop-180.png +0 -0
  106. data/vendor/assets/javascripts/aloha/lib/vendor/repository-browser/img/arrow-stop.png +0 -0
  107. data/vendor/assets/javascripts/aloha/lib/vendor/repository-browser/img/arrow.png +0 -0
  108. data/vendor/assets/javascripts/aloha/lib/vendor/repository-browser/img/control-stop-square-small.png +0 -0
  109. data/vendor/assets/javascripts/aloha/lib/vendor/repository-browser/img/folder-horizontal-open.png +0 -0
  110. data/vendor/assets/javascripts/aloha/lib/vendor/repository-browser/img/folder-open.png +0 -0
  111. data/vendor/assets/javascripts/aloha/lib/vendor/repository-browser/img/magnifier-left.png +0 -0
  112. data/vendor/assets/javascripts/aloha/lib/vendor/repository-browser/img/page.png +0 -0
  113. data/vendor/assets/javascripts/aloha/lib/vendor/repository-browser/img/picture.png +0 -0
  114. data/vendor/assets/javascripts/aloha/lib/vendor/repository-browser/img/sort-alphabet-descending.png +0 -0
  115. data/vendor/assets/javascripts/aloha/lib/vendor/repository-browser/img/sort-alphabet.png +0 -0
  116. data/vendor/assets/javascripts/aloha/lib/vendor/repository-browser/img/throbber.gif +0 -0
  117. data/vendor/assets/javascripts/aloha/lib/vendor/repository-browser/js/repository-browser-unminified.js +1450 -0
  118. data/vendor/assets/javascripts/aloha/lib/vendor/repository-browser/js/repository-browser.js +32 -0
  119. data/vendor/assets/javascripts/aloha/lib/vendor/sanitize.js +278 -0
  120. data/vendor/assets/javascripts/aloha/plugins/common/abbr/css/abbr.css +1 -0
  121. data/vendor/assets/javascripts/aloha/plugins/common/abbr/img/remabbr.png +0 -0
  122. data/vendor/assets/javascripts/aloha/plugins/common/abbr/lib/abbr-plugin.js +304 -0
  123. data/vendor/assets/javascripts/aloha/plugins/common/abbr/nls/ca/i18n.js +6 -0
  124. data/vendor/assets/javascripts/aloha/plugins/common/abbr/nls/de/i18n.js +6 -0
  125. data/vendor/assets/javascripts/aloha/plugins/common/abbr/nls/i18n.js +15 -0
  126. data/vendor/assets/javascripts/aloha/plugins/common/abbr/nls/mk/i18n.js +6 -0
  127. data/vendor/assets/javascripts/aloha/plugins/common/abbr/nls/pt-br/i18n.js +6 -0
  128. data/vendor/assets/javascripts/aloha/plugins/common/abbr/nls/ru/i18n.js +6 -0
  129. data/vendor/assets/javascripts/aloha/plugins/common/abbr/nls/uk/i18n.js +6 -0
  130. data/vendor/assets/javascripts/aloha/plugins/common/abbr/nls/zh-hans/i18n.js +6 -0
  131. data/vendor/assets/javascripts/aloha/plugins/common/abbr/package.json +1 -0
  132. data/vendor/assets/javascripts/aloha/plugins/common/align/LICENSE +166 -0
  133. data/vendor/assets/javascripts/aloha/plugins/common/align/README +12 -0
  134. data/vendor/assets/javascripts/aloha/plugins/common/align/css/align.css +31 -0
  135. data/vendor/assets/javascripts/aloha/plugins/common/align/img/align.png +0 -0
  136. data/vendor/assets/javascripts/aloha/plugins/common/align/lib/align-plugin.js +465 -0
  137. data/vendor/assets/javascripts/aloha/plugins/common/align/nls/ca/i18n.js +6 -0
  138. data/vendor/assets/javascripts/aloha/plugins/common/align/nls/de/i18n.js +9 -0
  139. data/vendor/assets/javascripts/aloha/plugins/common/align/nls/i18n.js +18 -0
  140. data/vendor/assets/javascripts/aloha/plugins/common/align/nls/mk/i18n.js +6 -0
  141. data/vendor/assets/javascripts/aloha/plugins/common/align/nls/pt-br/i18n.js +6 -0
  142. data/vendor/assets/javascripts/aloha/plugins/common/align/nls/ru/i18n.js +6 -0
  143. data/vendor/assets/javascripts/aloha/plugins/common/align/nls/uk/i18n.js +6 -0
  144. data/vendor/assets/javascripts/aloha/plugins/common/align/nls/zh-hans/i18n.js +6 -0
  145. data/vendor/assets/javascripts/aloha/plugins/common/align/package.json +2 -0
  146. data/vendor/assets/javascripts/aloha/plugins/common/block/README +0 -0
  147. data/vendor/assets/javascripts/aloha/plugins/common/block/css/block.css +110 -0
  148. data/vendor/assets/javascripts/aloha/plugins/common/block/img/toolbar-draghandle.gif +0 -0
  149. data/vendor/assets/javascripts/aloha/plugins/common/block/lib/block-plugin.js +347 -0
  150. data/vendor/assets/javascripts/aloha/plugins/common/block/lib/block.js +1277 -0
  151. data/vendor/assets/javascripts/aloha/plugins/common/block/lib/blockcontenthandler.js +118 -0
  152. data/vendor/assets/javascripts/aloha/plugins/common/block/lib/blockmanager.js +621 -0
  153. data/vendor/assets/javascripts/aloha/plugins/common/block/lib/editor.js +331 -0
  154. data/vendor/assets/javascripts/aloha/plugins/common/block/lib/editormanager.js +55 -0
  155. data/vendor/assets/javascripts/aloha/plugins/common/block/lib/sidebarattributeeditor.js +126 -0
  156. data/vendor/assets/javascripts/aloha/plugins/common/block/nls/ca/i18n.js +3 -0
  157. data/vendor/assets/javascripts/aloha/plugins/common/block/nls/de/i18n.js +3 -0
  158. data/vendor/assets/javascripts/aloha/plugins/common/block/nls/i18n.js +12 -0
  159. data/vendor/assets/javascripts/aloha/plugins/common/block/nls/mk/i18n.js +3 -0
  160. data/vendor/assets/javascripts/aloha/plugins/common/block/nls/pt-br/i18n.js +3 -0
  161. data/vendor/assets/javascripts/aloha/plugins/common/block/nls/ru/i18n.js +3 -0
  162. data/vendor/assets/javascripts/aloha/plugins/common/block/nls/uk/i18n.js +3 -0
  163. data/vendor/assets/javascripts/aloha/plugins/common/block/nls/zh-hans/i18n.js +3 -0
  164. data/vendor/assets/javascripts/aloha/plugins/common/block/package.json +11 -0
  165. data/vendor/assets/javascripts/aloha/plugins/common/characterpicker/css/characterpicker.css +44 -0
  166. data/vendor/assets/javascripts/aloha/plugins/common/characterpicker/img/icon.png +0 -0
  167. data/vendor/assets/javascripts/aloha/plugins/common/characterpicker/lib/characterpicker-plugin.js +466 -0
  168. data/vendor/assets/javascripts/aloha/plugins/common/characterpicker/nls/ca/i18n.js +3 -0
  169. data/vendor/assets/javascripts/aloha/plugins/common/characterpicker/nls/de/i18n.js +3 -0
  170. data/vendor/assets/javascripts/aloha/plugins/common/characterpicker/nls/i18n.js +12 -0
  171. data/vendor/assets/javascripts/aloha/plugins/common/characterpicker/nls/mk/i18n.js +3 -0
  172. data/vendor/assets/javascripts/aloha/plugins/common/characterpicker/nls/pt-br/i18n.js +3 -0
  173. data/vendor/assets/javascripts/aloha/plugins/common/characterpicker/nls/ru/i18n.js +3 -0
  174. data/vendor/assets/javascripts/aloha/plugins/common/characterpicker/nls/uk/i18n.js +3 -0
  175. data/vendor/assets/javascripts/aloha/plugins/common/characterpicker/nls/zh-hans/i18n.js +3 -0
  176. data/vendor/assets/javascripts/aloha/plugins/common/commands/css/abbr.css +0 -0
  177. data/vendor/assets/javascripts/aloha/plugins/common/commands/lib/commands-plugin.js +33 -0
  178. data/vendor/assets/javascripts/aloha/plugins/common/commands/lib/inserthtml.js +126 -0
  179. data/vendor/assets/javascripts/aloha/plugins/common/commands/package.json +1 -0
  180. data/vendor/assets/javascripts/aloha/plugins/common/contenthandler/README.md +0 -0
  181. data/vendor/assets/javascripts/aloha/plugins/common/contenthandler/lib/blockelementcontenthandler.js +144 -0
  182. data/vendor/assets/javascripts/aloha/plugins/common/contenthandler/lib/contenthandler-plugin.js +65 -0
  183. data/vendor/assets/javascripts/aloha/plugins/common/contenthandler/lib/contenthandler-utils.js +58 -0
  184. data/vendor/assets/javascripts/aloha/plugins/common/contenthandler/lib/genericcontenthandler.js +359 -0
  185. data/vendor/assets/javascripts/aloha/plugins/common/contenthandler/lib/oembedcontenthandler.js +461 -0
  186. data/vendor/assets/javascripts/aloha/plugins/common/contenthandler/lib/sanitizecontenthandler.js +186 -0
  187. data/vendor/assets/javascripts/aloha/plugins/common/contenthandler/lib/wordcontenthandler.js +461 -0
  188. data/vendor/assets/javascripts/aloha/plugins/common/contenthandler/package.json +1 -0
  189. data/vendor/assets/javascripts/aloha/plugins/common/dom-to-xhtml/lib/dom-to-xhtml-plugin.js +74 -0
  190. data/vendor/assets/javascripts/aloha/plugins/common/dom-to-xhtml/lib/dom-to-xhtml.js +415 -0
  191. data/vendor/assets/javascripts/aloha/plugins/common/format/img/em.png +0 -0
  192. data/vendor/assets/javascripts/aloha/plugins/common/format/img/strong.png +0 -0
  193. data/vendor/assets/javascripts/aloha/plugins/common/format/lib/format-plugin.js +594 -0
  194. data/vendor/assets/javascripts/aloha/plugins/common/format/nls/ca/i18n.js +52 -0
  195. data/vendor/assets/javascripts/aloha/plugins/common/format/nls/de/i18n.js +52 -0
  196. data/vendor/assets/javascripts/aloha/plugins/common/format/nls/i18n.js +61 -0
  197. data/vendor/assets/javascripts/aloha/plugins/common/format/nls/mk/i18n.js +52 -0
  198. data/vendor/assets/javascripts/aloha/plugins/common/format/nls/pt-br/i18n.js +52 -0
  199. data/vendor/assets/javascripts/aloha/plugins/common/format/nls/ru/i18n.js +52 -0
  200. data/vendor/assets/javascripts/aloha/plugins/common/format/nls/uk/i18n.js +52 -0
  201. data/vendor/assets/javascripts/aloha/plugins/common/format/nls/zh-hans/i18n.js +52 -0
  202. data/vendor/assets/javascripts/aloha/plugins/common/highlighteditables/css/highlighteditables.css +14 -0
  203. data/vendor/assets/javascripts/aloha/plugins/common/highlighteditables/lib/highlighteditables-plugin.js +100 -0
  204. data/vendor/assets/javascripts/aloha/plugins/common/highlighteditables/package.json +1 -0
  205. data/vendor/assets/javascripts/aloha/plugins/common/horizontalruler/css/horizontalruler.css +3 -0
  206. data/vendor/assets/javascripts/aloha/plugins/common/horizontalruler/img/icon.png +0 -0
  207. data/vendor/assets/javascripts/aloha/plugins/common/horizontalruler/lib/horizontalruler-plugin.js +95 -0
  208. data/vendor/assets/javascripts/aloha/plugins/common/horizontalruler/nls/ca/i18n.js +3 -0
  209. data/vendor/assets/javascripts/aloha/plugins/common/horizontalruler/nls/de/i18n.js +3 -0
  210. data/vendor/assets/javascripts/aloha/plugins/common/horizontalruler/nls/i18n.js +12 -0
  211. data/vendor/assets/javascripts/aloha/plugins/common/horizontalruler/nls/mk/i18n.js +3 -0
  212. data/vendor/assets/javascripts/aloha/plugins/common/horizontalruler/nls/pt-br/i18n.js +3 -0
  213. data/vendor/assets/javascripts/aloha/plugins/common/horizontalruler/nls/ru/i18n.js +3 -0
  214. data/vendor/assets/javascripts/aloha/plugins/common/horizontalruler/nls/uk/i18n.js +3 -0
  215. data/vendor/assets/javascripts/aloha/plugins/common/horizontalruler/nls/zh-hans/i18n.js +3 -0
  216. data/vendor/assets/javascripts/aloha/plugins/common/image/README.md +66 -0
  217. data/vendor/assets/javascripts/aloha/plugins/common/image/css/image.css +133 -0
  218. data/vendor/assets/javascripts/aloha/plugins/common/image/img/blank.jpg +0 -0
  219. data/vendor/assets/javascripts/aloha/plugins/common/image/img/crop-buttons.gif +0 -0
  220. data/vendor/assets/javascripts/aloha/plugins/common/image/img/cropnresize.png +0 -0
  221. data/vendor/assets/javascripts/aloha/plugins/common/image/img/handle-sw.png +0 -0
  222. data/vendor/assets/javascripts/aloha/plugins/common/image/img/image-align-left.png +0 -0
  223. data/vendor/assets/javascripts/aloha/plugins/common/image/img/image-align-none.png +0 -0
  224. data/vendor/assets/javascripts/aloha/plugins/common/image/img/image-align-right.png +0 -0
  225. data/vendor/assets/javascripts/aloha/plugins/common/image/img/image-border.png +0 -0
  226. data/vendor/assets/javascripts/aloha/plugins/common/image/img/image-title.png +0 -0
  227. data/vendor/assets/javascripts/aloha/plugins/common/image/img/image.gif +0 -0
  228. data/vendor/assets/javascripts/aloha/plugins/common/image/img/padding-decrease.gif +0 -0
  229. data/vendor/assets/javascripts/aloha/plugins/common/image/img/padding-increase.gif +0 -0
  230. data/vendor/assets/javascripts/aloha/plugins/common/image/img/page.png +0 -0
  231. data/vendor/assets/javascripts/aloha/plugins/common/image/img/size-decrease.gif +0 -0
  232. data/vendor/assets/javascripts/aloha/plugins/common/image/img/size-increase.gif +0 -0
  233. data/vendor/assets/javascripts/aloha/plugins/common/image/lib/image-floatingMenu.js +308 -0
  234. data/vendor/assets/javascripts/aloha/plugins/common/image/lib/image-plugin-actions.js +0 -0
  235. data/vendor/assets/javascripts/aloha/plugins/common/image/lib/image-plugin.js +1341 -0
  236. data/vendor/assets/javascripts/aloha/plugins/common/image/nls/ca/i18n.js +32 -0
  237. data/vendor/assets/javascripts/aloha/plugins/common/image/nls/de/i18n.js +32 -0
  238. data/vendor/assets/javascripts/aloha/plugins/common/image/nls/i18n.js +41 -0
  239. data/vendor/assets/javascripts/aloha/plugins/common/image/nls/mk/i18n.js +32 -0
  240. data/vendor/assets/javascripts/aloha/plugins/common/image/nls/pt-br/i18n.js +32 -0
  241. data/vendor/assets/javascripts/aloha/plugins/common/image/nls/ru/i18n.js +32 -0
  242. data/vendor/assets/javascripts/aloha/plugins/common/image/nls/uk/i18n.js +32 -0
  243. data/vendor/assets/javascripts/aloha/plugins/common/image/nls/zh-hans/i18n.js +32 -0
  244. data/vendor/assets/javascripts/aloha/plugins/common/image/package.json +1 -0
  245. data/vendor/assets/javascripts/aloha/plugins/common/image/vendor/jcrop/jcrop.gif +0 -0
  246. data/vendor/assets/javascripts/aloha/plugins/common/image/vendor/jcrop/jquery.jcrop.css +46 -0
  247. data/vendor/assets/javascripts/aloha/plugins/common/image/vendor/jcrop/jquery.jcrop.min.js +165 -0
  248. data/vendor/assets/javascripts/aloha/plugins/common/image/vendor/mousewheel/mousewheel.js +85 -0
  249. data/vendor/assets/javascripts/aloha/plugins/common/image/vendor/ui/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  250. data/vendor/assets/javascripts/aloha/plugins/common/image/vendor/ui/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  251. data/vendor/assets/javascripts/aloha/plugins/common/image/vendor/ui/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
  252. data/vendor/assets/javascripts/aloha/plugins/common/image/vendor/ui/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  253. data/vendor/assets/javascripts/aloha/plugins/common/image/vendor/ui/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  254. data/vendor/assets/javascripts/aloha/plugins/common/image/vendor/ui/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  255. data/vendor/assets/javascripts/aloha/plugins/common/image/vendor/ui/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  256. data/vendor/assets/javascripts/aloha/plugins/common/image/vendor/ui/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  257. data/vendor/assets/javascripts/aloha/plugins/common/image/vendor/ui/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  258. data/vendor/assets/javascripts/aloha/plugins/common/image/vendor/ui/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
  259. data/vendor/assets/javascripts/aloha/plugins/common/image/vendor/ui/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
  260. data/vendor/assets/javascripts/aloha/plugins/common/image/vendor/ui/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
  261. data/vendor/assets/javascripts/aloha/plugins/common/image/vendor/ui/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
  262. data/vendor/assets/javascripts/aloha/plugins/common/image/vendor/ui/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
  263. data/vendor/assets/javascripts/aloha/plugins/common/link/css/link.css +52 -0
  264. data/vendor/assets/javascripts/aloha/plugins/common/link/extra/delicious.js +264 -0
  265. data/vendor/assets/javascripts/aloha/plugins/common/link/extra/linklist.js +247 -0
  266. data/vendor/assets/javascripts/aloha/plugins/common/link/extra/slowlinklist.js +247 -0
  267. data/vendor/assets/javascripts/aloha/plugins/common/link/lib/link-plugin.js +958 -0
  268. data/vendor/assets/javascripts/aloha/plugins/common/link/nls/ca/i18n.js +14 -0
  269. data/vendor/assets/javascripts/aloha/plugins/common/link/nls/de/i18n.js +14 -0
  270. data/vendor/assets/javascripts/aloha/plugins/common/link/nls/i18n.js +23 -0
  271. data/vendor/assets/javascripts/aloha/plugins/common/link/nls/mk/i18n.js +14 -0
  272. data/vendor/assets/javascripts/aloha/plugins/common/link/nls/pt-br/i18n.js +14 -0
  273. data/vendor/assets/javascripts/aloha/plugins/common/link/nls/ru/i18n.js +14 -0
  274. data/vendor/assets/javascripts/aloha/plugins/common/link/nls/uk/i18n.js +14 -0
  275. data/vendor/assets/javascripts/aloha/plugins/common/link/nls/zh-hans/i18n.js +14 -0
  276. data/vendor/assets/javascripts/aloha/plugins/common/list/lib/list-plugin.js +878 -0
  277. data/vendor/assets/javascripts/aloha/plugins/common/list/nls/ca/i18n.js +7 -0
  278. data/vendor/assets/javascripts/aloha/plugins/common/list/nls/de/i18n.js +7 -0
  279. data/vendor/assets/javascripts/aloha/plugins/common/list/nls/i18n.js +16 -0
  280. data/vendor/assets/javascripts/aloha/plugins/common/list/nls/mk/i18n.js +7 -0
  281. data/vendor/assets/javascripts/aloha/plugins/common/list/nls/pt-br/i18n.js +7 -0
  282. data/vendor/assets/javascripts/aloha/plugins/common/list/nls/ru/i18n.js +7 -0
  283. data/vendor/assets/javascripts/aloha/plugins/common/list/nls/uk/i18n.js +7 -0
  284. data/vendor/assets/javascripts/aloha/plugins/common/list/nls/zh-hans/i18n.js +7 -0
  285. data/vendor/assets/javascripts/aloha/plugins/common/list/package.json +1 -0
  286. data/vendor/assets/javascripts/aloha/plugins/common/paste/lib/paste-plugin.js +457 -0
  287. data/vendor/assets/javascripts/aloha/plugins/common/paste/package.json +8 -0
  288. data/vendor/assets/javascripts/aloha/plugins/common/table/css/table.css +125 -0
  289. data/vendor/assets/javascripts/aloha/plugins/common/table/img/down.cur +0 -0
  290. data/vendor/assets/javascripts/aloha/plugins/common/table/img/left.cur +0 -0
  291. data/vendor/assets/javascripts/aloha/plugins/common/table/img/table_layout.png +0 -0
  292. data/vendor/assets/javascripts/aloha/plugins/common/table/img/wai-green.png +0 -0
  293. data/vendor/assets/javascripts/aloha/plugins/common/table/img/wai-red.png +0 -0
  294. data/vendor/assets/javascripts/aloha/plugins/common/table/lib/table-cell.js +542 -0
  295. data/vendor/assets/javascripts/aloha/plugins/common/table/lib/table-create-layer.js +213 -0
  296. data/vendor/assets/javascripts/aloha/plugins/common/table/lib/table-plugin-utils.js +494 -0
  297. data/vendor/assets/javascripts/aloha/plugins/common/table/lib/table-plugin.js +1596 -0
  298. data/vendor/assets/javascripts/aloha/plugins/common/table/lib/table-selection.js +468 -0
  299. data/vendor/assets/javascripts/aloha/plugins/common/table/lib/table.js +2110 -0
  300. data/vendor/assets/javascripts/aloha/plugins/common/table/nls/ca/i18n.js +28 -0
  301. data/vendor/assets/javascripts/aloha/plugins/common/table/nls/de/i18n.js +29 -0
  302. data/vendor/assets/javascripts/aloha/plugins/common/table/nls/i18n.js +38 -0
  303. data/vendor/assets/javascripts/aloha/plugins/common/table/nls/mk/i18n.js +28 -0
  304. data/vendor/assets/javascripts/aloha/plugins/common/table/nls/pt-br/i18n.js +28 -0
  305. data/vendor/assets/javascripts/aloha/plugins/common/table/nls/ru/i18n.js +28 -0
  306. data/vendor/assets/javascripts/aloha/plugins/common/table/nls/uk/i18n.js +28 -0
  307. data/vendor/assets/javascripts/aloha/plugins/common/table/nls/zh-hans/i18n.js +28 -0
  308. data/vendor/assets/javascripts/aloha/plugins/common/table/package.json +1 -0
  309. data/vendor/assets/javascripts/aloha/plugins/common/ui/css/jquery-ui-1.9m6.css +430 -0
  310. data/vendor/assets/javascripts/aloha/plugins/common/ui/css/ui.css +689 -0
  311. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/blockquote.png +0 -0
  312. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/character-picker.png +0 -0
  313. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/em.png +0 -0
  314. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/format-block.png +0 -0
  315. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/format-inline.png +0 -0
  316. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/indent.png +0 -0
  317. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/jqueryui/ui-icons_222222_256x240.png +0 -0
  318. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/justify.png +0 -0
  319. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/language-annotation.png +0 -0
  320. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/metaview.png +0 -0
  321. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/metaview/anchor.png +0 -0
  322. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/metaview/blockquote.png +0 -0
  323. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/metaview/caption.png +0 -0
  324. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/metaview/cite.png +0 -0
  325. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/metaview/dd.png +0 -0
  326. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/metaview/div.png +0 -0
  327. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/metaview/dl.png +0 -0
  328. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/metaview/dt.png +0 -0
  329. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/metaview/h1.png +0 -0
  330. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/metaview/h2.png +0 -0
  331. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/metaview/h3.png +0 -0
  332. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/metaview/h4.png +0 -0
  333. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/metaview/h5.png +0 -0
  334. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/metaview/h6.png +0 -0
  335. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/metaview/p.png +0 -0
  336. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/metaview/pre.png +0 -0
  337. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/metaview/q.png +0 -0
  338. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/metaview/table.png +0 -0
  339. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/metaview/td.png +0 -0
  340. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/metaview/th.png +0 -0
  341. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/multisplit-close.gif +0 -0
  342. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/multisplit-open.gif +0 -0
  343. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/outdent.png +0 -0
  344. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/quote.png +0 -0
  345. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/removeformat.png +0 -0
  346. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/strong.png +0 -0
  347. data/vendor/assets/javascripts/aloha/plugins/common/ui/img/tree.png +0 -0
  348. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/arena.js +11 -0
  349. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/autocomplete.js +70 -0
  350. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/button.js +114 -0
  351. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/component.js +121 -0
  352. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/container.js +210 -0
  353. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/context.js +53 -0
  354. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/dialog.js +215 -0
  355. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/floating.js +405 -0
  356. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/menuButton.js +169 -0
  357. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/multiSplit.js +237 -0
  358. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/port-helper-attribute-field.js +440 -0
  359. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/port-helper-multi-split.js +71 -0
  360. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/scopes.js +187 -0
  361. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/settings.js +202 -0
  362. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/subguarded.js +183 -0
  363. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/surface.js +106 -0
  364. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/tab.js +316 -0
  365. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/text.js +33 -0
  366. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/toggleButton.js +57 -0
  367. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/toolbar.js +251 -0
  368. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/ui-plugin.js +169 -0
  369. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/ui.js +181 -0
  370. data/vendor/assets/javascripts/aloha/plugins/common/ui/lib/utils.js +104 -0
  371. data/vendor/assets/javascripts/aloha/plugins/common/ui/nls/ca/i18n.js +46 -0
  372. data/vendor/assets/javascripts/aloha/plugins/common/ui/nls/de/i18n.js +48 -0
  373. data/vendor/assets/javascripts/aloha/plugins/common/ui/nls/i18n.js +75 -0
  374. data/vendor/assets/javascripts/aloha/plugins/common/ui/nls/mk/i18n.js +46 -0
  375. data/vendor/assets/javascripts/aloha/plugins/common/ui/nls/pt-br/i18n.js +46 -0
  376. data/vendor/assets/javascripts/aloha/plugins/common/ui/nls/ru/i18n.js +46 -0
  377. data/vendor/assets/javascripts/aloha/plugins/common/ui/nls/uk/i18n.js +46 -0
  378. data/vendor/assets/javascripts/aloha/plugins/common/ui/nls/zh-hans/i18n.js +46 -0
  379. data/vendor/assets/javascripts/aloha/plugins/common/ui/vendor/jquery-ui-autocomplete-html.js +42 -0
  380. data/vendor/assets/javascripts/aloha/plugins/common/undo/lib/undo-plugin.js +165 -0
  381. data/vendor/assets/javascripts/aloha/plugins/common/undo/package.json +7 -0
  382. data/vendor/assets/javascripts/aloha/plugins/common/undo/vendor/diff_match_patch_uncompressed.js +2155 -0
  383. data/vendor/assets/javascripts/aloha/plugins/common/undo/vendor/undo.js +121 -0
  384. data/vendor/assets/javascripts/aloha/plugins/extra/attributes/README +0 -0
  385. data/vendor/assets/javascripts/aloha/plugins/extra/attributes/css/attributes.css +12 -0
  386. data/vendor/assets/javascripts/aloha/plugins/extra/attributes/lib/attributes-plugin.js +237 -0
  387. data/vendor/assets/javascripts/aloha/plugins/extra/attributes/nls/ca/i18n.js +5 -0
  388. data/vendor/assets/javascripts/aloha/plugins/extra/attributes/nls/de/i18n.js +5 -0
  389. data/vendor/assets/javascripts/aloha/plugins/extra/attributes/nls/i18n.js +14 -0
  390. data/vendor/assets/javascripts/aloha/plugins/extra/attributes/nls/mk/i18n.js +5 -0
  391. data/vendor/assets/javascripts/aloha/plugins/extra/attributes/nls/pt-br/i18n.js +5 -0
  392. data/vendor/assets/javascripts/aloha/plugins/extra/attributes/nls/ru/i18n.js +5 -0
  393. data/vendor/assets/javascripts/aloha/plugins/extra/attributes/nls/uk/i18n.js +5 -0
  394. data/vendor/assets/javascripts/aloha/plugins/extra/attributes/nls/zh-hans/i18n.js +5 -0
  395. data/vendor/assets/javascripts/aloha/plugins/extra/captioned-image/css/captioned-image.css +15 -0
  396. data/vendor/assets/javascripts/aloha/plugins/extra/captioned-image/lib/captioned-image-plugin.js +555 -0
  397. data/vendor/assets/javascripts/aloha/plugins/extra/cite/README +0 -0
  398. data/vendor/assets/javascripts/aloha/plugins/extra/cite/css/cite.css +39 -0
  399. data/vendor/assets/javascripts/aloha/plugins/extra/cite/img/blockquote.png +0 -0
  400. data/vendor/assets/javascripts/aloha/plugins/extra/cite/img/icon_cite.png +0 -0
  401. data/vendor/assets/javascripts/aloha/plugins/extra/cite/lib/cite-plugin.js +614 -0
  402. data/vendor/assets/javascripts/aloha/plugins/extra/cite/nls/ca/i18n.js +4 -0
  403. data/vendor/assets/javascripts/aloha/plugins/extra/cite/nls/de/i18n.js +4 -0
  404. data/vendor/assets/javascripts/aloha/plugins/extra/cite/nls/i18n.js +13 -0
  405. data/vendor/assets/javascripts/aloha/plugins/extra/cite/nls/mk/i18n.js +4 -0
  406. data/vendor/assets/javascripts/aloha/plugins/extra/cite/nls/pt-br/i18n.js +4 -0
  407. data/vendor/assets/javascripts/aloha/plugins/extra/cite/nls/ru/i18n.js +4 -0
  408. data/vendor/assets/javascripts/aloha/plugins/extra/cite/nls/uk/i18n.js +4 -0
  409. data/vendor/assets/javascripts/aloha/plugins/extra/cite/nls/zh-hans/i18n.js +4 -0
  410. data/vendor/assets/javascripts/aloha/plugins/extra/cite/package.json +1 -0
  411. data/vendor/assets/javascripts/aloha/plugins/extra/comments/img/add-icon.png +0 -0
  412. data/vendor/assets/javascripts/aloha/plugins/extra/comments/img/add.png +0 -0
  413. data/vendor/assets/javascripts/aloha/plugins/extra/comments/img/comments.png +0 -0
  414. data/vendor/assets/javascripts/aloha/plugins/extra/comments/img/hr.png +0 -0
  415. data/vendor/assets/javascripts/aloha/plugins/extra/comments/img/textbox.png +0 -0
  416. data/vendor/assets/javascripts/aloha/plugins/extra/comments/lib/comments-plugin.js +692 -0
  417. data/vendor/assets/javascripts/aloha/plugins/extra/comments/lib/comments.css +442 -0
  418. data/vendor/assets/javascripts/aloha/plugins/extra/comments/package.json +1 -0
  419. data/vendor/assets/javascripts/aloha/plugins/extra/draganddropfiles/README.md +5 -0
  420. data/vendor/assets/javascripts/aloha/plugins/extra/draganddropfiles/TODO.md +2 -0
  421. data/vendor/assets/javascripts/aloha/plugins/extra/draganddropfiles/img/cross.png +0 -0
  422. data/vendor/assets/javascripts/aloha/plugins/extra/draganddropfiles/img/hourglass.png +0 -0
  423. data/vendor/assets/javascripts/aloha/plugins/extra/draganddropfiles/img/loading.gif +0 -0
  424. data/vendor/assets/javascripts/aloha/plugins/extra/draganddropfiles/img/page.png +0 -0
  425. data/vendor/assets/javascripts/aloha/plugins/extra/draganddropfiles/img/tick.png +0 -0
  426. data/vendor/assets/javascripts/aloha/plugins/extra/draganddropfiles/lib/draganddropfiles-plugin.js +4 -0
  427. data/vendor/assets/javascripts/aloha/plugins/extra/draganddropfiles/lib/dragndropfiles.css +110 -0
  428. data/vendor/assets/javascripts/aloha/plugins/extra/draganddropfiles/lib/dragndropfiles.js +363 -0
  429. data/vendor/assets/javascripts/aloha/plugins/extra/draganddropfiles/lib/dropfilesrepository.js +365 -0
  430. data/vendor/assets/javascripts/aloha/plugins/extra/draganddropfiles/nls/ca/i18n.js +3 -0
  431. data/vendor/assets/javascripts/aloha/plugins/extra/draganddropfiles/nls/de/i18n.js +3 -0
  432. data/vendor/assets/javascripts/aloha/plugins/extra/draganddropfiles/nls/i18n.js +12 -0
  433. data/vendor/assets/javascripts/aloha/plugins/extra/draganddropfiles/nls/mk/i18n.js +3 -0
  434. data/vendor/assets/javascripts/aloha/plugins/extra/draganddropfiles/nls/pt-br/i18n.js +3 -0
  435. data/vendor/assets/javascripts/aloha/plugins/extra/draganddropfiles/nls/ru/i18n.js +3 -0
  436. data/vendor/assets/javascripts/aloha/plugins/extra/draganddropfiles/nls/uk/i18n.js +3 -0
  437. data/vendor/assets/javascripts/aloha/plugins/extra/draganddropfiles/nls/zh-hans/i18n.js +3 -0
  438. data/vendor/assets/javascripts/aloha/plugins/extra/draganddropfiles/package.json +1 -0
  439. data/vendor/assets/javascripts/aloha/plugins/extra/formatlesspaste/README.md +1 -0
  440. data/vendor/assets/javascripts/aloha/plugins/extra/formatlesspaste/css/formatless.css +7 -0
  441. data/vendor/assets/javascripts/aloha/plugins/extra/formatlesspaste/img/button.png +0 -0
  442. data/vendor/assets/javascripts/aloha/plugins/extra/formatlesspaste/lib/formatlesshandler.js +97 -0
  443. data/vendor/assets/javascripts/aloha/plugins/extra/formatlesspaste/lib/formatlesspaste-plugin.js +230 -0
  444. data/vendor/assets/javascripts/aloha/plugins/extra/formatlesspaste/nls/ca/i18n.js +3 -0
  445. data/vendor/assets/javascripts/aloha/plugins/extra/formatlesspaste/nls/de/i18n.js +3 -0
  446. data/vendor/assets/javascripts/aloha/plugins/extra/formatlesspaste/nls/i18n.js +12 -0
  447. data/vendor/assets/javascripts/aloha/plugins/extra/formatlesspaste/nls/mk/i18n.js +3 -0
  448. data/vendor/assets/javascripts/aloha/plugins/extra/formatlesspaste/nls/pt-br/i18n.js +3 -0
  449. data/vendor/assets/javascripts/aloha/plugins/extra/formatlesspaste/nls/ru/i18n.js +3 -0
  450. data/vendor/assets/javascripts/aloha/plugins/extra/formatlesspaste/nls/uk/i18n.js +3 -0
  451. data/vendor/assets/javascripts/aloha/plugins/extra/formatlesspaste/nls/zh-hans/i18n.js +3 -0
  452. data/vendor/assets/javascripts/aloha/plugins/extra/formatlesspaste/package.json +8 -0
  453. data/vendor/assets/javascripts/aloha/plugins/extra/headerids/README +0 -0
  454. data/vendor/assets/javascripts/aloha/plugins/extra/headerids/css/headerids.css +8 -0
  455. data/vendor/assets/javascripts/aloha/plugins/extra/headerids/lib/headerids-plugin.js +254 -0
  456. data/vendor/assets/javascripts/aloha/plugins/extra/headerids/nls/ca/i18n.js +6 -0
  457. data/vendor/assets/javascripts/aloha/plugins/extra/headerids/nls/de/i18n.js +6 -0
  458. data/vendor/assets/javascripts/aloha/plugins/extra/headerids/nls/i18n.js +15 -0
  459. data/vendor/assets/javascripts/aloha/plugins/extra/headerids/nls/mk/i18n.js +6 -0
  460. data/vendor/assets/javascripts/aloha/plugins/extra/headerids/nls/pt-br/i18n.js +6 -0
  461. data/vendor/assets/javascripts/aloha/plugins/extra/headerids/nls/ru/i18n.js +6 -0
  462. data/vendor/assets/javascripts/aloha/plugins/extra/headerids/nls/uk/i18n.js +6 -0
  463. data/vendor/assets/javascripts/aloha/plugins/extra/headerids/nls/zh-hans/i18n.js +6 -0
  464. data/vendor/assets/javascripts/aloha/plugins/extra/hints/README.md +12 -0
  465. data/vendor/assets/javascripts/aloha/plugins/extra/hints/css/hints.css +29 -0
  466. data/vendor/assets/javascripts/aloha/plugins/extra/hints/lib/hints-plugin.js +97 -0
  467. data/vendor/assets/javascripts/aloha/plugins/extra/hints/package.json +9 -0
  468. data/vendor/assets/javascripts/aloha/plugins/extra/hints/vendor/tipsy.js +242 -0
  469. data/vendor/assets/javascripts/aloha/plugins/extra/imagebrowser/README +0 -0
  470. data/vendor/assets/javascripts/aloha/plugins/extra/imagebrowser/lib/imagebrowser-plugin.js +160 -0
  471. data/vendor/assets/javascripts/aloha/plugins/extra/imagebrowser/nls/ca/i18n.js +6 -0
  472. data/vendor/assets/javascripts/aloha/plugins/extra/imagebrowser/nls/de/i18n.js +6 -0
  473. data/vendor/assets/javascripts/aloha/plugins/extra/imagebrowser/nls/i18n.js +15 -0
  474. data/vendor/assets/javascripts/aloha/plugins/extra/imagebrowser/nls/mk/i18n.js +6 -0
  475. data/vendor/assets/javascripts/aloha/plugins/extra/imagebrowser/nls/pt-br/i18n.js +6 -0
  476. data/vendor/assets/javascripts/aloha/plugins/extra/imagebrowser/nls/ru/i18n.js +6 -0
  477. data/vendor/assets/javascripts/aloha/plugins/extra/imagebrowser/nls/uk/i18n.js +6 -0
  478. data/vendor/assets/javascripts/aloha/plugins/extra/imagebrowser/nls/zh-hans/i18n.js +6 -0
  479. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/README +0 -0
  480. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ad.png +0 -0
  481. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ae.png +0 -0
  482. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/af.png +0 -0
  483. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ag.png +0 -0
  484. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ai.png +0 -0
  485. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/al.png +0 -0
  486. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/am.png +0 -0
  487. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/an.png +0 -0
  488. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ao.png +0 -0
  489. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ar.png +0 -0
  490. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/as.png +0 -0
  491. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/at.png +0 -0
  492. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/au.png +0 -0
  493. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/aw.png +0 -0
  494. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ax.png +0 -0
  495. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/az.png +0 -0
  496. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ba.png +0 -0
  497. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/bb.png +0 -0
  498. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/bd.png +0 -0
  499. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/be.png +0 -0
  500. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/bf.png +0 -0
  501. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/bg.png +0 -0
  502. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/bh.png +0 -0
  503. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/bi.png +0 -0
  504. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/bj.png +0 -0
  505. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/bm.png +0 -0
  506. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/bn.png +0 -0
  507. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/bo.png +0 -0
  508. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/br.png +0 -0
  509. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/bs.png +0 -0
  510. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/bt.png +0 -0
  511. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/bv.png +0 -0
  512. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/bw.png +0 -0
  513. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/by.png +0 -0
  514. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/bz.png +0 -0
  515. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ca.png +0 -0
  516. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/catalonia.png +0 -0
  517. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/cc.png +0 -0
  518. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/cd.png +0 -0
  519. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/cf.png +0 -0
  520. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/cg.png +0 -0
  521. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ch.png +0 -0
  522. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ci.png +0 -0
  523. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ck.png +0 -0
  524. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/cl.png +0 -0
  525. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/cm.png +0 -0
  526. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/cn.png +0 -0
  527. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/co.png +0 -0
  528. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/cr.png +0 -0
  529. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/cs.png +0 -0
  530. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/cu.png +0 -0
  531. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/cv.png +0 -0
  532. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/cx.png +0 -0
  533. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/cy.png +0 -0
  534. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/cz.png +0 -0
  535. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/de.png +0 -0
  536. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/dj.png +0 -0
  537. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/dk.png +0 -0
  538. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/dm.png +0 -0
  539. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/do.png +0 -0
  540. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/dz.png +0 -0
  541. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ec.png +0 -0
  542. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ee.png +0 -0
  543. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/eg.png +0 -0
  544. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/eh.png +0 -0
  545. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/en.png +0 -0
  546. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/er.png +0 -0
  547. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/es.png +0 -0
  548. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/et.png +0 -0
  549. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/europeanunion.png +0 -0
  550. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/fam.png +0 -0
  551. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/fi.png +0 -0
  552. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/fj.png +0 -0
  553. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/fk.png +0 -0
  554. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/fm.png +0 -0
  555. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/fo.png +0 -0
  556. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/fr.png +0 -0
  557. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ga.png +0 -0
  558. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/gb.png +0 -0
  559. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/gd.png +0 -0
  560. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ge.png +0 -0
  561. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/gf.png +0 -0
  562. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/gh.png +0 -0
  563. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/gi.png +0 -0
  564. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/gl.png +0 -0
  565. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/gm.png +0 -0
  566. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/gn.png +0 -0
  567. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/gp.png +0 -0
  568. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/gq.png +0 -0
  569. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/gr.png +0 -0
  570. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/gs.png +0 -0
  571. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/gt.png +0 -0
  572. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/gu.png +0 -0
  573. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/gw.png +0 -0
  574. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/gy.png +0 -0
  575. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/hk.png +0 -0
  576. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/hm.png +0 -0
  577. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/hn.png +0 -0
  578. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/hr.png +0 -0
  579. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ht.png +0 -0
  580. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/hu.png +0 -0
  581. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/id.png +0 -0
  582. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ie.png +0 -0
  583. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/il.png +0 -0
  584. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/in.png +0 -0
  585. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/io.png +0 -0
  586. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/iq.png +0 -0
  587. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ir.png +0 -0
  588. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/is.png +0 -0
  589. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/it.png +0 -0
  590. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/jm.png +0 -0
  591. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/jo.png +0 -0
  592. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/jp.png +0 -0
  593. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ke.png +0 -0
  594. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/kg.png +0 -0
  595. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/kh.png +0 -0
  596. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ki.png +0 -0
  597. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/km.png +0 -0
  598. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/kn.png +0 -0
  599. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/kp.png +0 -0
  600. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/kr.png +0 -0
  601. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/kw.png +0 -0
  602. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ky.png +0 -0
  603. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/kz.png +0 -0
  604. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/la.png +0 -0
  605. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/lb.png +0 -0
  606. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/lc.png +0 -0
  607. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/li.png +0 -0
  608. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/lk.png +0 -0
  609. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/lr.png +0 -0
  610. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ls.png +0 -0
  611. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/lt.png +0 -0
  612. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/lu.png +0 -0
  613. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/lv.png +0 -0
  614. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ly.png +0 -0
  615. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ma.png +0 -0
  616. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/mc.png +0 -0
  617. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/md.png +0 -0
  618. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/me.png +0 -0
  619. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/mg.png +0 -0
  620. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/mh.png +0 -0
  621. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/mk.png +0 -0
  622. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ml.png +0 -0
  623. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/mm.png +0 -0
  624. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/mn.png +0 -0
  625. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/mo.png +0 -0
  626. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/mp.png +0 -0
  627. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/mq.png +0 -0
  628. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/mr.png +0 -0
  629. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ms.png +0 -0
  630. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/mt.png +0 -0
  631. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/mu.png +0 -0
  632. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/mv.png +0 -0
  633. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/mw.png +0 -0
  634. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/mx.png +0 -0
  635. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/my.png +0 -0
  636. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/mz.png +0 -0
  637. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/na.png +0 -0
  638. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/nc.png +0 -0
  639. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ne.png +0 -0
  640. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/nf.png +0 -0
  641. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ng.png +0 -0
  642. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ni.png +0 -0
  643. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/nl.png +0 -0
  644. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/no.png +0 -0
  645. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/np.png +0 -0
  646. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/nr.png +0 -0
  647. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/nu.png +0 -0
  648. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/nz.png +0 -0
  649. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/om.png +0 -0
  650. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/pa.png +0 -0
  651. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/pe.png +0 -0
  652. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/pf.png +0 -0
  653. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/pg.png +0 -0
  654. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ph.png +0 -0
  655. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/pk.png +0 -0
  656. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/pl.png +0 -0
  657. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/pm.png +0 -0
  658. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/pn.png +0 -0
  659. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/pr.png +0 -0
  660. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ps.png +0 -0
  661. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/pt.png +0 -0
  662. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/pw.png +0 -0
  663. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/py.png +0 -0
  664. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/qa.png +0 -0
  665. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/re.png +0 -0
  666. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ro.png +0 -0
  667. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/rs.png +0 -0
  668. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ru.png +0 -0
  669. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/rw.png +0 -0
  670. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/sa.png +0 -0
  671. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/sb.png +0 -0
  672. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/sc.png +0 -0
  673. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/scotland.png +0 -0
  674. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/sd.png +0 -0
  675. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/se.png +0 -0
  676. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/sg.png +0 -0
  677. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/sh.png +0 -0
  678. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/si.png +0 -0
  679. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/sj.png +0 -0
  680. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/sk.png +0 -0
  681. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/sl.png +0 -0
  682. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/sm.png +0 -0
  683. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/sn.png +0 -0
  684. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/so.png +0 -0
  685. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/sr.png +0 -0
  686. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/st.png +0 -0
  687. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/sv.png +0 -0
  688. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/sy.png +0 -0
  689. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/sz.png +0 -0
  690. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/tc.png +0 -0
  691. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/td.png +0 -0
  692. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/tf.png +0 -0
  693. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/tg.png +0 -0
  694. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/th.png +0 -0
  695. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/tj.png +0 -0
  696. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/tk.png +0 -0
  697. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/tl.png +0 -0
  698. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/tm.png +0 -0
  699. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/tn.png +0 -0
  700. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/to.png +0 -0
  701. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/tr.png +0 -0
  702. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/tt.png +0 -0
  703. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/tv.png +0 -0
  704. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/tw.png +0 -0
  705. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/tz.png +0 -0
  706. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ua.png +0 -0
  707. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ug.png +0 -0
  708. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/um.png +0 -0
  709. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/us.png +0 -0
  710. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/uy.png +0 -0
  711. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/uz.png +0 -0
  712. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/va.png +0 -0
  713. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/vc.png +0 -0
  714. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ve.png +0 -0
  715. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/vg.png +0 -0
  716. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/vi.png +0 -0
  717. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/vn.png +0 -0
  718. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/vu.png +0 -0
  719. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/wales.png +0 -0
  720. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/wf.png +0 -0
  721. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ws.png +0 -0
  722. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/ye.png +0 -0
  723. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/yt.png +0 -0
  724. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/za.png +0 -0
  725. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/zm.png +0 -0
  726. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/img/flags/zw.png +0 -0
  727. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/lib/linkbrowser-plugin.js +161 -0
  728. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/nls/ca/i18n.js +6 -0
  729. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/nls/de/i18n.js +6 -0
  730. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/nls/i18n.js +15 -0
  731. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/nls/mk/i18n.js +6 -0
  732. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/nls/pt-br/i18n.js +6 -0
  733. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/nls/ru/i18n.js +6 -0
  734. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/nls/uk/i18n.js +6 -0
  735. data/vendor/assets/javascripts/aloha/plugins/extra/linkbrowser/nls/zh-hans/i18n.js +6 -0
  736. data/vendor/assets/javascripts/aloha/plugins/extra/linkchecker/nls/ca/i18n.js +28 -0
  737. data/vendor/assets/javascripts/aloha/plugins/extra/linkchecker/nls/de/i18n.js +28 -0
  738. data/vendor/assets/javascripts/aloha/plugins/extra/linkchecker/nls/i18n.js +37 -0
  739. data/vendor/assets/javascripts/aloha/plugins/extra/linkchecker/nls/mk/i18n.js +28 -0
  740. data/vendor/assets/javascripts/aloha/plugins/extra/linkchecker/nls/pt-br/i18n.js +28 -0
  741. data/vendor/assets/javascripts/aloha/plugins/extra/linkchecker/nls/ru/i18n.js +28 -0
  742. data/vendor/assets/javascripts/aloha/plugins/extra/linkchecker/nls/uk/i18n.js +28 -0
  743. data/vendor/assets/javascripts/aloha/plugins/extra/linkchecker/nls/zh-hans/i18n.js +28 -0
  744. data/vendor/assets/javascripts/aloha/plugins/extra/linkchecker/package.json +1 -0
  745. data/vendor/assets/javascripts/aloha/plugins/extra/linkchecker/proxy.php.example +244 -0
  746. data/vendor/assets/javascripts/aloha/plugins/extra/linkchecker/src/linkchecker.css +14 -0
  747. data/vendor/assets/javascripts/aloha/plugins/extra/linkchecker/src/linkchecker.js +269 -0
  748. data/vendor/assets/javascripts/aloha/plugins/extra/listenforcer/lib/listenforcer-plugin.js +190 -0
  749. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/README +0 -0
  750. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/css/metaview.css +78 -0
  751. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/anchor.png +0 -0
  752. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/blockquote.png +0 -0
  753. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/button.png +0 -0
  754. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/caption.png +0 -0
  755. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/cite.png +0 -0
  756. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/dd.png +0 -0
  757. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/div.png +0 -0
  758. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/dl.png +0 -0
  759. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/dt.png +0 -0
  760. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/h1.png +0 -0
  761. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/h2.png +0 -0
  762. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/h3.png +0 -0
  763. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/h4.png +0 -0
  764. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/h5.png +0 -0
  765. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/h6.png +0 -0
  766. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/hr.png +0 -0
  767. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/icon_cite.png +0 -0
  768. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/p.png +0 -0
  769. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/pre.png +0 -0
  770. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/table.png +0 -0
  771. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/td.png +0 -0
  772. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/img/th.png +0 -0
  773. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/lib/metaview-plugin.js +185 -0
  774. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/nls/ca/i18n.js +3 -0
  775. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/nls/de/i18n.js +3 -0
  776. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/nls/i18n.js +12 -0
  777. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/nls/mk/i18n.js +3 -0
  778. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/nls/pt-br/i18n.js +3 -0
  779. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/nls/ru/i18n.js +3 -0
  780. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/nls/uk/i18n.js +3 -0
  781. data/vendor/assets/javascripts/aloha/plugins/extra/metaview/nls/zh-hans/i18n.js +3 -0
  782. data/vendor/assets/javascripts/aloha/plugins/extra/numerated-headers/README +0 -0
  783. data/vendor/assets/javascripts/aloha/plugins/extra/numerated-headers/css/numerated-headers.css +7 -0
  784. data/vendor/assets/javascripts/aloha/plugins/extra/numerated-headers/img/headers.png +0 -0
  785. data/vendor/assets/javascripts/aloha/plugins/extra/numerated-headers/lib/numerated-headers-plugin.js +421 -0
  786. data/vendor/assets/javascripts/aloha/plugins/extra/numerated-headers/nls/ca/i18n.js +5 -0
  787. data/vendor/assets/javascripts/aloha/plugins/extra/numerated-headers/nls/de/i18n.js +6 -0
  788. data/vendor/assets/javascripts/aloha/plugins/extra/numerated-headers/nls/i18n.js +15 -0
  789. data/vendor/assets/javascripts/aloha/plugins/extra/numerated-headers/nls/mk/i18n.js +5 -0
  790. data/vendor/assets/javascripts/aloha/plugins/extra/numerated-headers/nls/pt-br/i18n.js +5 -0
  791. data/vendor/assets/javascripts/aloha/plugins/extra/numerated-headers/nls/ru/i18n.js +5 -0
  792. data/vendor/assets/javascripts/aloha/plugins/extra/numerated-headers/nls/uk/i18n.js +5 -0
  793. data/vendor/assets/javascripts/aloha/plugins/extra/numerated-headers/nls/zh-hans/i18n.js +5 -0
  794. data/vendor/assets/javascripts/aloha/plugins/extra/profiler/css/profiler.css +34 -0
  795. data/vendor/assets/javascripts/aloha/plugins/extra/profiler/lib/profiler-plugin.js +304 -0
  796. data/vendor/assets/javascripts/aloha/plugins/extra/ribbon/README.md +8 -0
  797. data/vendor/assets/javascripts/aloha/plugins/extra/ribbon/css/ribbon.css +54 -0
  798. data/vendor/assets/javascripts/aloha/plugins/extra/ribbon/img/fade-in.png +0 -0
  799. data/vendor/assets/javascripts/aloha/plugins/extra/ribbon/img/fade-out.png +0 -0
  800. data/vendor/assets/javascripts/aloha/plugins/extra/ribbon/lib/ribbon-plugin.js +144 -0
  801. data/vendor/assets/javascripts/aloha/plugins/extra/ribbon/package.json +1 -0
  802. data/vendor/assets/javascripts/aloha/plugins/extra/sourceview/css/sourceview.css +18 -0
  803. data/vendor/assets/javascripts/aloha/plugins/extra/sourceview/lib/sourceview-plugin.js +252 -0
  804. data/vendor/assets/javascripts/aloha/plugins/extra/sourceview/vendor/htmlbeautifier.js +468 -0
  805. data/vendor/assets/javascripts/aloha/plugins/extra/textcolor/css/textcolor.css +65 -0
  806. data/vendor/assets/javascripts/aloha/plugins/extra/textcolor/img/icon.png +0 -0
  807. data/vendor/assets/javascripts/aloha/plugins/extra/textcolor/lib/textcolor-plugin.js +420 -0
  808. data/vendor/assets/javascripts/aloha/plugins/extra/textcolor/nls/de/i18n.js +3 -0
  809. data/vendor/assets/javascripts/aloha/plugins/extra/textcolor/nls/i18n.js +6 -0
  810. data/vendor/assets/javascripts/aloha/plugins/extra/toc/lib/toc-plugin.js +399 -0
  811. data/vendor/assets/javascripts/aloha/plugins/extra/toc/nls/ca/i18n.js +3 -0
  812. data/vendor/assets/javascripts/aloha/plugins/extra/toc/nls/de/i18n.js +3 -0
  813. data/vendor/assets/javascripts/aloha/plugins/extra/toc/nls/i18n.js +12 -0
  814. data/vendor/assets/javascripts/aloha/plugins/extra/toc/nls/mk/i18n.js +3 -0
  815. data/vendor/assets/javascripts/aloha/plugins/extra/toc/nls/pt-br/i18n.js +3 -0
  816. data/vendor/assets/javascripts/aloha/plugins/extra/toc/nls/ru/i18n.js +3 -0
  817. data/vendor/assets/javascripts/aloha/plugins/extra/toc/nls/uk/i18n.js +3 -0
  818. data/vendor/assets/javascripts/aloha/plugins/extra/toc/nls/zh-hans/i18n.js +3 -0
  819. data/vendor/assets/javascripts/aloha/plugins/extra/toc/package.json +1 -0
  820. data/vendor/assets/javascripts/aloha/plugins/extra/validation/lib/validation-plugin.js +277 -0
  821. data/vendor/assets/stylesheets/aloha-common-extra.css +24 -0
  822. data/vendor/assets/stylesheets/aloha-core.css +19 -0
  823. data/vendor/assets/stylesheets/aloha-reset.css +24 -0
  824. data/vendor/assets/stylesheets/aloha-sidebar.css +296 -0
  825. data/vendor/assets/stylesheets/aloha.css +31 -0
  826. metadata +898 -0
@@ -0,0 +1,2155 @@
1
+ /**
2
+ * Diff Match and Patch
3
+ *
4
+ * Copyright 2006 Google Inc.
5
+ * http://code.google.com/p/google-diff-match-patch/
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+
20
+ /**
21
+ * @fileoverview Computes the difference between two texts to create a patch.
22
+ * Applies the patch onto another text, allowing for errors.
23
+ * @author fraser@google.com (Neil Fraser)
24
+ */
25
+
26
+ /**
27
+ * Class containing the diff, match and patch methods.
28
+ * @constructor
29
+ */
30
+ function diff_match_patch() {
31
+
32
+ // Defaults.
33
+ // Redefine these in your program to override the defaults.
34
+
35
+ // Number of seconds to map a diff before giving up (0 for infinity).
36
+ this.Diff_Timeout = 1.0;
37
+ // Cost of an empty edit operation in terms of edit characters.
38
+ this.Diff_EditCost = 4;
39
+ // At what point is no match declared (0.0 = perfection, 1.0 = very loose).
40
+ this.Match_Threshold = 0.5;
41
+ // How far to search for a match (0 = exact location, 1000+ = broad match).
42
+ // A match this many characters away from the expected location will add
43
+ // 1.0 to the score (0.0 is a perfect match).
44
+ this.Match_Distance = 1000;
45
+ // When deleting a large block of text (over ~64 characters), how close does
46
+ // the contents have to match the expected contents. (0.0 = perfection,
47
+ // 1.0 = very loose). Note that Match_Threshold controls how closely the
48
+ // end points of a delete need to match.
49
+ this.Patch_DeleteThreshold = 0.5;
50
+ // Chunk size for context length.
51
+ this.Patch_Margin = 4;
52
+
53
+ // The number of bits in an int.
54
+ this.Match_MaxBits = 32;
55
+ }
56
+
57
+
58
+ // DIFF FUNCTIONS
59
+
60
+
61
+ /**
62
+ * The data structure representing a diff is an array of tuples:
63
+ * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
64
+ * which means: delete 'Hello', add 'Goodbye' and keep ' world.'
65
+ */
66
+ var DIFF_DELETE = -1;
67
+ var DIFF_INSERT = 1;
68
+ var DIFF_EQUAL = 0;
69
+
70
+ /** @typedef {!Array.<number|string>} */
71
+ diff_match_patch.Diff;
72
+
73
+
74
+ /**
75
+ * Find the differences between two texts. Simplifies the problem by stripping
76
+ * any common prefix or suffix off the texts before diffing.
77
+ * @param {string} text1 Old string to be diffed.
78
+ * @param {string} text2 New string to be diffed.
79
+ * @param {boolean=} opt_checklines Optional speedup flag. If present and false,
80
+ * then don't run a line-level diff first to identify the changed areas.
81
+ * Defaults to true, which does a faster, slightly less optimal diff.
82
+ * @param {number} opt_deadline Optional time when the diff should be complete
83
+ * by. Used internally for recursive calls. Users should set DiffTimeout
84
+ * instead.
85
+ * @return {!Array.<!diff_match_patch.Diff>} Array of diff tuples.
86
+ */
87
+ diff_match_patch.prototype.diff_main = function(text1, text2, opt_checklines,
88
+ opt_deadline) {
89
+ // Set a deadline by which time the diff must be complete.
90
+ if (typeof opt_deadline == 'undefined') {
91
+ if (this.Diff_Timeout <= 0) {
92
+ opt_deadline = Number.MAX_VALUE;
93
+ } else {
94
+ opt_deadline = (new Date).getTime() + this.Diff_Timeout * 1000;
95
+ }
96
+ }
97
+ var deadline = opt_deadline;
98
+
99
+ // Check for null inputs.
100
+ if (text1 == null || text2 == null) {
101
+ throw new Error('Null input. (diff_main)');
102
+ }
103
+
104
+ // Check for equality (speedup).
105
+ if (text1 == text2) {
106
+ if (text1) {
107
+ return [[DIFF_EQUAL, text1]];
108
+ }
109
+ return [];
110
+ }
111
+
112
+ if (typeof opt_checklines == 'undefined') {
113
+ opt_checklines = true;
114
+ }
115
+ var checklines = opt_checklines;
116
+
117
+ // Trim off common prefix (speedup).
118
+ var commonlength = this.diff_commonPrefix(text1, text2);
119
+ var commonprefix = text1.substring(0, commonlength);
120
+ text1 = text1.substring(commonlength);
121
+ text2 = text2.substring(commonlength);
122
+
123
+ // Trim off common suffix (speedup).
124
+ commonlength = this.diff_commonSuffix(text1, text2);
125
+ var commonsuffix = text1.substring(text1.length - commonlength);
126
+ text1 = text1.substring(0, text1.length - commonlength);
127
+ text2 = text2.substring(0, text2.length - commonlength);
128
+
129
+ // Compute the diff on the middle block.
130
+ var diffs = this.diff_compute_(text1, text2, checklines, deadline);
131
+
132
+ // Restore the prefix and suffix.
133
+ if (commonprefix) {
134
+ diffs.unshift([DIFF_EQUAL, commonprefix]);
135
+ }
136
+ if (commonsuffix) {
137
+ diffs.push([DIFF_EQUAL, commonsuffix]);
138
+ }
139
+ this.diff_cleanupMerge(diffs);
140
+ return diffs;
141
+ };
142
+
143
+
144
+ /**
145
+ * Find the differences between two texts. Assumes that the texts do not
146
+ * have any common prefix or suffix.
147
+ * @param {string} text1 Old string to be diffed.
148
+ * @param {string} text2 New string to be diffed.
149
+ * @param {boolean} checklines Speedup flag. If false, then don't run a
150
+ * line-level diff first to identify the changed areas.
151
+ * If true, then run a faster, slightly less optimal diff.
152
+ * @param {number} deadline Time when the diff should be complete by.
153
+ * @return {!Array.<!diff_match_patch.Diff>} Array of diff tuples.
154
+ * @private
155
+ */
156
+ diff_match_patch.prototype.diff_compute_ = function(text1, text2, checklines,
157
+ deadline) {
158
+ var diffs;
159
+
160
+ if (!text1) {
161
+ // Just add some text (speedup).
162
+ return [[DIFF_INSERT, text2]];
163
+ }
164
+
165
+ if (!text2) {
166
+ // Just delete some text (speedup).
167
+ return [[DIFF_DELETE, text1]];
168
+ }
169
+
170
+ var longtext = text1.length > text2.length ? text1 : text2;
171
+ var shorttext = text1.length > text2.length ? text2 : text1;
172
+ var i = longtext.indexOf(shorttext);
173
+ if (i != -1) {
174
+ // Shorter text is inside the longer text (speedup).
175
+ diffs = [[DIFF_INSERT, longtext.substring(0, i)],
176
+ [DIFF_EQUAL, shorttext],
177
+ [DIFF_INSERT, longtext.substring(i + shorttext.length)]];
178
+ // Swap insertions for deletions if diff is reversed.
179
+ if (text1.length > text2.length) {
180
+ diffs[0][0] = diffs[2][0] = DIFF_DELETE;
181
+ }
182
+ return diffs;
183
+ }
184
+
185
+ if (shorttext.length == 1) {
186
+ // Single character string.
187
+ // After the previous speedup, the character can't be an equality.
188
+ return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
189
+ }
190
+ longtext = shorttext = null; // Garbage collect.
191
+
192
+ // Check to see if the problem can be split in two.
193
+ var hm = this.diff_halfMatch_(text1, text2);
194
+ if (hm) {
195
+ // A half-match was found, sort out the return data.
196
+ var text1_a = hm[0];
197
+ var text1_b = hm[1];
198
+ var text2_a = hm[2];
199
+ var text2_b = hm[3];
200
+ var mid_common = hm[4];
201
+ // Send both pairs off for separate processing.
202
+ var diffs_a = this.diff_main(text1_a, text2_a, checklines, deadline);
203
+ var diffs_b = this.diff_main(text1_b, text2_b, checklines, deadline);
204
+ // Merge the results.
205
+ return diffs_a.concat([[DIFF_EQUAL, mid_common]], diffs_b);
206
+ }
207
+
208
+ if (checklines && text1.length > 100 && text2.length > 100) {
209
+ return this.diff_lineMode_(text1, text2, deadline);
210
+ }
211
+
212
+ return this.diff_bisect_(text1, text2, deadline);
213
+ };
214
+
215
+
216
+ /**
217
+ * Do a quick line-level diff on both strings, then rediff the parts for
218
+ * greater accuracy.
219
+ * This speedup can produce non-minimal diffs.
220
+ * @param {string} text1 Old string to be diffed.
221
+ * @param {string} text2 New string to be diffed.
222
+ * @param {number} deadline Time when the diff should be complete by.
223
+ * @return {!Array.<!diff_match_patch.Diff>} Array of diff tuples.
224
+ * @private
225
+ */
226
+ diff_match_patch.prototype.diff_lineMode_ = function(text1, text2, deadline) {
227
+ // Scan the text on a line-by-line basis first.
228
+ var a = this.diff_linesToChars_(text1, text2);
229
+ text1 = /** @type {string} */(a[0]);
230
+ text2 = /** @type {string} */(a[1]);
231
+ var linearray = /** @type {!Array.<string>} */(a[2]);
232
+
233
+ var diffs = this.diff_bisect_(text1, text2, deadline);
234
+
235
+ // Convert the diff back to original text.
236
+ this.diff_charsToLines_(diffs, linearray);
237
+ // Eliminate freak matches (e.g. blank lines)
238
+ this.diff_cleanupSemantic(diffs);
239
+
240
+ // Rediff any replacement blocks, this time character-by-character.
241
+ // Add a dummy entry at the end.
242
+ diffs.push([DIFF_EQUAL, '']);
243
+ var pointer = 0;
244
+ var count_delete = 0;
245
+ var count_insert = 0;
246
+ var text_delete = '';
247
+ var text_insert = '';
248
+ while (pointer < diffs.length) {
249
+ switch (diffs[pointer][0]) {
250
+ case DIFF_INSERT:
251
+ count_insert++;
252
+ text_insert += diffs[pointer][1];
253
+ break;
254
+ case DIFF_DELETE:
255
+ count_delete++;
256
+ text_delete += diffs[pointer][1];
257
+ break;
258
+ case DIFF_EQUAL:
259
+ // Upon reaching an equality, check for prior redundancies.
260
+ if (count_delete >= 1 && count_insert >= 1) {
261
+ // Delete the offending records and add the merged ones.
262
+ var a = this.diff_main(text_delete, text_insert, false, deadline);
263
+ diffs.splice(pointer - count_delete - count_insert,
264
+ count_delete + count_insert);
265
+ pointer = pointer - count_delete - count_insert;
266
+ for (var j = a.length - 1; j >= 0; j--) {
267
+ diffs.splice(pointer, 0, a[j]);
268
+ }
269
+ pointer = pointer + a.length;
270
+ }
271
+ count_insert = 0;
272
+ count_delete = 0;
273
+ text_delete = '';
274
+ text_insert = '';
275
+ break;
276
+ }
277
+ pointer++;
278
+ }
279
+ diffs.pop(); // Remove the dummy entry at the end.
280
+
281
+ return diffs;
282
+ };
283
+
284
+
285
+ /**
286
+ * Find the 'middle snake' of a diff, split the problem in two
287
+ * and return the recursively constructed diff.
288
+ * See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.
289
+ * @param {string} text1 Old string to be diffed.
290
+ * @param {string} text2 New string to be diffed.
291
+ * @param {number} deadline Time at which to bail if not yet complete.
292
+ * @return {!Array.<!diff_match_patch.Diff>} Array of diff tuples.
293
+ * @private
294
+ */
295
+ diff_match_patch.prototype.diff_bisect_ = function(text1, text2, deadline) {
296
+ // Cache the text lengths to prevent multiple calls.
297
+ var text1_length = text1.length;
298
+ var text2_length = text2.length;
299
+ var max_d = Math.ceil((text1_length + text2_length) / 2);
300
+ var v_offset = max_d;
301
+ var v_length = 2 * max_d;
302
+ var v1 = new Array(v_length);
303
+ var v2 = new Array(v_length);
304
+ // Setting all elements to -1 is faster in Chrome & Firefox than mixing
305
+ // integers and undefined.
306
+ for (var x = 0; x < v_length; x++) {
307
+ v1[x] = -1;
308
+ v2[x] = -1;
309
+ }
310
+ v1[v_offset + 1] = 0;
311
+ v2[v_offset + 1] = 0;
312
+ var delta = text1_length - text2_length;
313
+ // If the total number of characters is odd, then the front path will collide
314
+ // with the reverse path.
315
+ var front = (delta % 2 != 0);
316
+ // Offsets for start and end of k loop.
317
+ // Prevents mapping of space beyond the grid.
318
+ var k1start = 0;
319
+ var k1end = 0;
320
+ var k2start = 0;
321
+ var k2end = 0;
322
+ for (var d = 0; d < max_d; d++) {
323
+ // Bail out if deadline is reached.
324
+ if ((new Date()).getTime() > deadline) {
325
+ break;
326
+ }
327
+
328
+ // Walk the front path one step.
329
+ for (var k1 = -d + k1start; k1 <= d - k1end; k1 += 2) {
330
+ var k1_offset = v_offset + k1;
331
+ var x1;
332
+ if (k1 == -d || k1 != d && v1[k1_offset - 1] < v1[k1_offset + 1]) {
333
+ x1 = v1[k1_offset + 1];
334
+ } else {
335
+ x1 = v1[k1_offset - 1] + 1;
336
+ }
337
+ var y1 = x1 - k1;
338
+ while (x1 < text1_length && y1 < text2_length &&
339
+ text1.charAt(x1) == text2.charAt(y1)) {
340
+ x1++;
341
+ y1++;
342
+ }
343
+ v1[k1_offset] = x1;
344
+ if (x1 > text1_length) {
345
+ // Ran off the right of the graph.
346
+ k1end += 2;
347
+ } else if (y1 > text2_length) {
348
+ // Ran off the bottom of the graph.
349
+ k1start += 2;
350
+ } else if (front) {
351
+ var k2_offset = v_offset + delta - k1;
352
+ if (k2_offset >= 0 && k2_offset < v_length && v2[k2_offset] != -1) {
353
+ // Mirror x2 onto top-left coordinate system.
354
+ var x2 = text1_length - v2[k2_offset];
355
+ if (x1 >= x2) {
356
+ // Overlap detected.
357
+ return this.diff_bisectSplit_(text1, text2, x1, y1, deadline);
358
+ }
359
+ }
360
+ }
361
+ }
362
+
363
+ // Walk the reverse path one step.
364
+ for (var k2 = -d + k2start; k2 <= d - k2end; k2 += 2) {
365
+ var k2_offset = v_offset + k2;
366
+ var x2;
367
+ if (k2 == -d || k2 != d && v2[k2_offset - 1] < v2[k2_offset + 1]) {
368
+ x2 = v2[k2_offset + 1];
369
+ } else {
370
+ x2 = v2[k2_offset - 1] + 1;
371
+ }
372
+ var y2 = x2 - k2;
373
+ while (x2 < text1_length && y2 < text2_length &&
374
+ text1.charAt(text1_length - x2 - 1) ==
375
+ text2.charAt(text2_length - y2 - 1)) {
376
+ x2++;
377
+ y2++;
378
+ }
379
+ v2[k2_offset] = x2;
380
+ if (x2 > text1_length) {
381
+ // Ran off the left of the graph.
382
+ k2end += 2;
383
+ } else if (y2 > text2_length) {
384
+ // Ran off the top of the graph.
385
+ k2start += 2;
386
+ } else if (!front) {
387
+ var k1_offset = v_offset + delta - k2;
388
+ if (k1_offset >= 0 && k1_offset < v_length && v1[k1_offset] != -1) {
389
+ var x1 = v1[k1_offset];
390
+ var y1 = v_offset + x1 - k1_offset;
391
+ // Mirror x2 onto top-left coordinate system.
392
+ x2 = text1_length - x2;
393
+ if (x1 >= x2) {
394
+ // Overlap detected.
395
+ return this.diff_bisectSplit_(text1, text2, x1, y1, deadline);
396
+ }
397
+ }
398
+ }
399
+ }
400
+ }
401
+ // Diff took too long and hit the deadline or
402
+ // number of diffs equals number of characters, no commonality at all.
403
+ return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
404
+ };
405
+
406
+
407
+ /**
408
+ * Given the location of the 'middle snake', split the diff in two parts
409
+ * and recurse.
410
+ * @param {string} text1 Old string to be diffed.
411
+ * @param {string} text2 New string to be diffed.
412
+ * @param {number} x Index of split point in text1.
413
+ * @param {number} y Index of split point in text2.
414
+ * @param {number} deadline Time at which to bail if not yet complete.
415
+ * @return {!Array.<!diff_match_patch.Diff>} Array of diff tuples.
416
+ * @private
417
+ */
418
+ diff_match_patch.prototype.diff_bisectSplit_ = function(text1, text2, x, y,
419
+ deadline) {
420
+ var text1a = text1.substring(0, x);
421
+ var text2a = text2.substring(0, y);
422
+ var text1b = text1.substring(x);
423
+ var text2b = text2.substring(y);
424
+
425
+ // Compute both diffs serially.
426
+ var diffs = this.diff_main(text1a, text2a, false, deadline);
427
+ var diffsb = this.diff_main(text1b, text2b, false, deadline);
428
+
429
+ return diffs.concat(diffsb);
430
+ };
431
+
432
+
433
+ /**
434
+ * Split two texts into an array of strings. Reduce the texts to a string of
435
+ * hashes where each Unicode character represents one line.
436
+ * @param {string} text1 First string.
437
+ * @param {string} text2 Second string.
438
+ * @return {!Array.<string|!Array.<string>>} Three element Array, containing the
439
+ * encoded text1, the encoded text2 and the array of unique strings. The
440
+ * zeroth element of the array of unique strings is intentionally blank.
441
+ * @private
442
+ */
443
+ diff_match_patch.prototype.diff_linesToChars_ = function(text1, text2) {
444
+ var lineArray = []; // e.g. lineArray[4] == 'Hello\n'
445
+ var lineHash = {}; // e.g. lineHash['Hello\n'] == 4
446
+
447
+ // '\x00' is a valid character, but various debuggers don't like it.
448
+ // So we'll insert a junk entry to avoid generating a null character.
449
+ lineArray[0] = '';
450
+
451
+ /**
452
+ * Split a text into an array of strings. Reduce the texts to a string of
453
+ * hashes where each Unicode character represents one line.
454
+ * Modifies linearray and linehash through being a closure.
455
+ * @param {string} text String to encode.
456
+ * @return {string} Encoded string.
457
+ * @private
458
+ */
459
+ function diff_linesToCharsMunge_(text) {
460
+ var chars = '';
461
+ // Walk the text, pulling out a substring for each line.
462
+ // text.split('\n') would would temporarily double our memory footprint.
463
+ // Modifying text would create many large strings to garbage collect.
464
+ var lineStart = 0;
465
+ var lineEnd = -1;
466
+ // Keeping our own length variable is faster than looking it up.
467
+ var lineArrayLength = lineArray.length;
468
+ while (lineEnd < text.length - 1) {
469
+ lineEnd = text.indexOf('\n', lineStart);
470
+ if (lineEnd == -1) {
471
+ lineEnd = text.length - 1;
472
+ }
473
+ var line = text.substring(lineStart, lineEnd + 1);
474
+ lineStart = lineEnd + 1;
475
+
476
+ if (lineHash.hasOwnProperty ? lineHash.hasOwnProperty(line) :
477
+ (lineHash[line] !== undefined)) {
478
+ chars += String.fromCharCode(lineHash[line]);
479
+ } else {
480
+ chars += String.fromCharCode(lineArrayLength);
481
+ lineHash[line] = lineArrayLength;
482
+ lineArray[lineArrayLength++] = line;
483
+ }
484
+ }
485
+ return chars;
486
+ }
487
+
488
+ var chars1 = diff_linesToCharsMunge_(text1);
489
+ var chars2 = diff_linesToCharsMunge_(text2);
490
+ return [chars1, chars2, lineArray];
491
+ };
492
+
493
+
494
+ /**
495
+ * Rehydrate the text in a diff from a string of line hashes to real lines of
496
+ * text.
497
+ * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
498
+ * @param {!Array.<string>} lineArray Array of unique strings.
499
+ * @private
500
+ */
501
+ diff_match_patch.prototype.diff_charsToLines_ = function(diffs, lineArray) {
502
+ for (var x = 0; x < diffs.length; x++) {
503
+ var chars = diffs[x][1];
504
+ var text = [];
505
+ for (var y = 0; y < chars.length; y++) {
506
+ text[y] = lineArray[chars.charCodeAt(y)];
507
+ }
508
+ diffs[x][1] = text.join('');
509
+ }
510
+ };
511
+
512
+
513
+ /**
514
+ * Determine the common prefix of two strings.
515
+ * @param {string} text1 First string.
516
+ * @param {string} text2 Second string.
517
+ * @return {number} The number of characters common to the start of each
518
+ * string.
519
+ */
520
+ diff_match_patch.prototype.diff_commonPrefix = function(text1, text2) {
521
+ // Quick check for common null cases.
522
+ if (!text1 || !text2 || text1.charAt(0) != text2.charAt(0)) {
523
+ return 0;
524
+ }
525
+ // Binary search.
526
+ // Performance analysis: http://neil.fraser.name/news/2007/10/09/
527
+ var pointermin = 0;
528
+ var pointermax = Math.min(text1.length, text2.length);
529
+ var pointermid = pointermax;
530
+ var pointerstart = 0;
531
+ while (pointermin < pointermid) {
532
+ if (text1.substring(pointerstart, pointermid) ==
533
+ text2.substring(pointerstart, pointermid)) {
534
+ pointermin = pointermid;
535
+ pointerstart = pointermin;
536
+ } else {
537
+ pointermax = pointermid;
538
+ }
539
+ pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
540
+ }
541
+ return pointermid;
542
+ };
543
+
544
+
545
+ /**
546
+ * Determine the common suffix of two strings.
547
+ * @param {string} text1 First string.
548
+ * @param {string} text2 Second string.
549
+ * @return {number} The number of characters common to the end of each string.
550
+ */
551
+ diff_match_patch.prototype.diff_commonSuffix = function(text1, text2) {
552
+ // Quick check for common null cases.
553
+ if (!text1 || !text2 ||
554
+ text1.charAt(text1.length - 1) != text2.charAt(text2.length - 1)) {
555
+ return 0;
556
+ }
557
+ // Binary search.
558
+ // Performance analysis: http://neil.fraser.name/news/2007/10/09/
559
+ var pointermin = 0;
560
+ var pointermax = Math.min(text1.length, text2.length);
561
+ var pointermid = pointermax;
562
+ var pointerend = 0;
563
+ while (pointermin < pointermid) {
564
+ if (text1.substring(text1.length - pointermid, text1.length - pointerend) ==
565
+ text2.substring(text2.length - pointermid, text2.length - pointerend)) {
566
+ pointermin = pointermid;
567
+ pointerend = pointermin;
568
+ } else {
569
+ pointermax = pointermid;
570
+ }
571
+ pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
572
+ }
573
+ return pointermid;
574
+ };
575
+
576
+
577
+ /**
578
+ * Determine if the suffix of one string is the prefix of another.
579
+ * @param {string} text1 First string.
580
+ * @param {string} text2 Second string.
581
+ * @return {number} The number of characters common to the end of the first
582
+ * string and the start of the second string.
583
+ * @private
584
+ */
585
+ diff_match_patch.prototype.diff_commonOverlap_ = function(text1, text2) {
586
+ // Cache the text lengths to prevent multiple calls.
587
+ var text1_length = text1.length;
588
+ var text2_length = text2.length;
589
+ // Eliminate the null case.
590
+ if (text1_length == 0 || text2_length == 0) {
591
+ return 0;
592
+ }
593
+ // Truncate the longer string.
594
+ if (text1_length > text2_length) {
595
+ text1 = text1.substring(text1_length - text2_length);
596
+ } else if (text1_length < text2_length) {
597
+ text2 = text2.substring(0, text1_length);
598
+ }
599
+ var text_length = Math.min(text1_length, text2_length);
600
+ // Quick check for the worst case.
601
+ if (text1 == text2) {
602
+ return text_length;
603
+ }
604
+
605
+ // Start by looking for a single character match
606
+ // and increase length until no match is found.
607
+ // Performance analysis: http://neil.fraser.name/news/2010/11/04/
608
+ var best = 0;
609
+ var length = 1;
610
+ while (true) {
611
+ var pattern = text1.substring(text_length - length);
612
+ var found = text2.indexOf(pattern);
613
+ if (found == -1) {
614
+ return best;
615
+ }
616
+ length += found;
617
+ if (found == 0 || text1.substring(text_length - length) ==
618
+ text2.substring(0, length)) {
619
+ best = length;
620
+ length++;
621
+ }
622
+ }
623
+ };
624
+
625
+
626
+ /**
627
+ * Do the two texts share a substring which is at least half the length of the
628
+ * longer text?
629
+ * This speedup can produce non-minimal diffs.
630
+ * @param {string} text1 First string.
631
+ * @param {string} text2 Second string.
632
+ * @return {Array.<string>} Five element Array, containing the prefix of
633
+ * text1, the suffix of text1, the prefix of text2, the suffix of
634
+ * text2 and the common middle. Or null if there was no match.
635
+ * @private
636
+ */
637
+ diff_match_patch.prototype.diff_halfMatch_ = function(text1, text2) {
638
+ if (this.Diff_Timeout <= 0) {
639
+ // Don't risk returning a non-optimal diff if we have unlimited time.
640
+ return null;
641
+ }
642
+ var longtext = text1.length > text2.length ? text1 : text2;
643
+ var shorttext = text1.length > text2.length ? text2 : text1;
644
+ if (longtext.length < 4 || shorttext.length * 2 < longtext.length) {
645
+ return null; // Pointless.
646
+ }
647
+ var dmp = this; // 'this' becomes 'window' in a closure.
648
+
649
+ /**
650
+ * Does a substring of shorttext exist within longtext such that the substring
651
+ * is at least half the length of longtext?
652
+ * Closure, but does not reference any external variables.
653
+ * @param {string} longtext Longer string.
654
+ * @param {string} shorttext Shorter string.
655
+ * @param {number} i Start index of quarter length substring within longtext.
656
+ * @return {Array.<string>} Five element Array, containing the prefix of
657
+ * longtext, the suffix of longtext, the prefix of shorttext, the suffix
658
+ * of shorttext and the common middle. Or null if there was no match.
659
+ * @private
660
+ */
661
+ function diff_halfMatchI_(longtext, shorttext, i) {
662
+ // Start with a 1/4 length substring at position i as a seed.
663
+ var seed = longtext.substring(i, i + Math.floor(longtext.length / 4));
664
+ var j = -1;
665
+ var best_common = '';
666
+ var best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b;
667
+ while ((j = shorttext.indexOf(seed, j + 1)) != -1) {
668
+ var prefixLength = dmp.diff_commonPrefix(longtext.substring(i),
669
+ shorttext.substring(j));
670
+ var suffixLength = dmp.diff_commonSuffix(longtext.substring(0, i),
671
+ shorttext.substring(0, j));
672
+ if (best_common.length < suffixLength + prefixLength) {
673
+ best_common = shorttext.substring(j - suffixLength, j) +
674
+ shorttext.substring(j, j + prefixLength);
675
+ best_longtext_a = longtext.substring(0, i - suffixLength);
676
+ best_longtext_b = longtext.substring(i + prefixLength);
677
+ best_shorttext_a = shorttext.substring(0, j - suffixLength);
678
+ best_shorttext_b = shorttext.substring(j + prefixLength);
679
+ }
680
+ }
681
+ if (best_common.length * 2 >= longtext.length) {
682
+ return [best_longtext_a, best_longtext_b,
683
+ best_shorttext_a, best_shorttext_b, best_common];
684
+ } else {
685
+ return null;
686
+ }
687
+ }
688
+
689
+ // First check if the second quarter is the seed for a half-match.
690
+ var hm1 = diff_halfMatchI_(longtext, shorttext,
691
+ Math.ceil(longtext.length / 4));
692
+ // Check again based on the third quarter.
693
+ var hm2 = diff_halfMatchI_(longtext, shorttext,
694
+ Math.ceil(longtext.length / 2));
695
+ var hm;
696
+ if (!hm1 && !hm2) {
697
+ return null;
698
+ } else if (!hm2) {
699
+ hm = hm1;
700
+ } else if (!hm1) {
701
+ hm = hm2;
702
+ } else {
703
+ // Both matched. Select the longest.
704
+ hm = hm1[4].length > hm2[4].length ? hm1 : hm2;
705
+ }
706
+
707
+ // A half-match was found, sort out the return data.
708
+ var text1_a, text1_b, text2_a, text2_b;
709
+ if (text1.length > text2.length) {
710
+ text1_a = hm[0];
711
+ text1_b = hm[1];
712
+ text2_a = hm[2];
713
+ text2_b = hm[3];
714
+ } else {
715
+ text2_a = hm[0];
716
+ text2_b = hm[1];
717
+ text1_a = hm[2];
718
+ text1_b = hm[3];
719
+ }
720
+ var mid_common = hm[4];
721
+ return [text1_a, text1_b, text2_a, text2_b, mid_common];
722
+ };
723
+
724
+
725
+ /**
726
+ * Reduce the number of edits by eliminating semantically trivial equalities.
727
+ * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
728
+ */
729
+ diff_match_patch.prototype.diff_cleanupSemantic = function(diffs) {
730
+ var changes = false;
731
+ var equalities = []; // Stack of indices where equalities are found.
732
+ var equalitiesLength = 0; // Keeping our own length var is faster in JS.
733
+ /** @type {?string} */
734
+ var lastequality = null; // Always equal to equalities[equalitiesLength-1][1]
735
+ var pointer = 0; // Index of current position.
736
+ // Number of characters that changed prior to the equality.
737
+ var length_insertions1 = 0;
738
+ var length_deletions1 = 0;
739
+ // Number of characters that changed after the equality.
740
+ var length_insertions2 = 0;
741
+ var length_deletions2 = 0;
742
+ while (pointer < diffs.length) {
743
+ if (diffs[pointer][0] == DIFF_EQUAL) { // Equality found.
744
+ equalities[equalitiesLength++] = pointer;
745
+ length_insertions1 = length_insertions2;
746
+ length_deletions1 = length_deletions2;
747
+ length_insertions2 = 0;
748
+ length_deletions2 = 0;
749
+ lastequality = /** @type {string} */(diffs[pointer][1]);
750
+ } else { // An insertion or deletion.
751
+ if (diffs[pointer][0] == DIFF_INSERT) {
752
+ length_insertions2 += diffs[pointer][1].length;
753
+ } else {
754
+ length_deletions2 += diffs[pointer][1].length;
755
+ }
756
+ if (lastequality !== null && (lastequality.length <=
757
+ Math.max(length_insertions1, length_deletions1)) &&
758
+ (lastequality.length <= Math.max(length_insertions2,
759
+ length_deletions2))) {
760
+ // Duplicate record.
761
+ diffs.splice(equalities[equalitiesLength - 1], 0,
762
+ [DIFF_DELETE, lastequality]);
763
+ // Change second copy to insert.
764
+ diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT;
765
+ // Throw away the equality we just deleted.
766
+ equalitiesLength--;
767
+ // Throw away the previous equality (it needs to be reevaluated).
768
+ equalitiesLength--;
769
+ pointer = equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1;
770
+ length_insertions1 = 0; // Reset the counters.
771
+ length_deletions1 = 0;
772
+ length_insertions2 = 0;
773
+ length_deletions2 = 0;
774
+ lastequality = null;
775
+ changes = true;
776
+ }
777
+ }
778
+ pointer++;
779
+ }
780
+
781
+ // Normalize the diff.
782
+ if (changes) {
783
+ this.diff_cleanupMerge(diffs);
784
+ }
785
+ this.diff_cleanupSemanticLossless(diffs);
786
+
787
+ // Find any overlaps between deletions and insertions.
788
+ // e.g: <del>abcxx</del><ins>xxdef</ins>
789
+ // -> <del>abc</del>xx<ins>def</ins>
790
+ pointer = 1;
791
+ while (pointer < diffs.length) {
792
+ if (diffs[pointer - 1][0] == DIFF_DELETE &&
793
+ diffs[pointer][0] == DIFF_INSERT) {
794
+ var deletion = /** @type {string} */(diffs[pointer - 1][1]);
795
+ var insertion = /** @type {string} */(diffs[pointer][1]);
796
+ var overlap_length = this.diff_commonOverlap_(deletion, insertion);
797
+ if (overlap_length) {
798
+ // Overlap found. Insert an equality and trim the surrounding edits.
799
+ diffs.splice(pointer, 0,
800
+ [DIFF_EQUAL, insertion.substring(0, overlap_length)]);
801
+ diffs[pointer - 1][1] =
802
+ deletion.substring(0, deletion.length - overlap_length);
803
+ diffs[pointer + 1][1] = insertion.substring(overlap_length);
804
+ pointer++;
805
+ }
806
+ pointer++;
807
+ }
808
+ pointer++;
809
+ }
810
+ };
811
+
812
+
813
+ /**
814
+ * Look for single edits surrounded on both sides by equalities
815
+ * which can be shifted sideways to align the edit to a word boundary.
816
+ * e.g: The c<ins>at c</ins>ame. -> The <ins>cat </ins>came.
817
+ * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
818
+ */
819
+ diff_match_patch.prototype.diff_cleanupSemanticLossless = function(diffs) {
820
+ // Define some regex patterns for matching boundaries.
821
+ var punctuation = /[^a-zA-Z0-9]/;
822
+ var whitespace = /\s/;
823
+ var linebreak = /[\r\n]/;
824
+ var blanklineEnd = /\n\r?\n$/;
825
+ var blanklineStart = /^\r?\n\r?\n/;
826
+
827
+ /**
828
+ * Given two strings, compute a score representing whether the internal
829
+ * boundary falls on logical boundaries.
830
+ * Scores range from 5 (best) to 0 (worst).
831
+ * Closure, makes reference to regex patterns defined above.
832
+ * @param {string} one First string.
833
+ * @param {string} two Second string.
834
+ * @return {number} The score.
835
+ * @private
836
+ */
837
+ function diff_cleanupSemanticScore_(one, two) {
838
+ if (!one || !two) {
839
+ // Edges are the best.
840
+ return 5;
841
+ }
842
+
843
+ // Each port of this function behaves slightly differently due to
844
+ // subtle differences in each language's definition of things like
845
+ // 'whitespace'. Since this function's purpose is largely cosmetic,
846
+ // the choice has been made to use each language's native features
847
+ // rather than force total conformity.
848
+ var score = 0;
849
+ // One point for non-alphanumeric.
850
+ if (one.charAt(one.length - 1).match(punctuation) ||
851
+ two.charAt(0).match(punctuation)) {
852
+ score++;
853
+ // Two points for whitespace.
854
+ if (one.charAt(one.length - 1).match(whitespace) ||
855
+ two.charAt(0).match(whitespace)) {
856
+ score++;
857
+ // Three points for line breaks.
858
+ if (one.charAt(one.length - 1).match(linebreak) ||
859
+ two.charAt(0).match(linebreak)) {
860
+ score++;
861
+ // Four points for blank lines.
862
+ if (one.match(blanklineEnd) || two.match(blanklineStart)) {
863
+ score++;
864
+ }
865
+ }
866
+ }
867
+ }
868
+ return score;
869
+ }
870
+
871
+ var pointer = 1;
872
+ // Intentionally ignore the first and last element (don't need checking).
873
+ while (pointer < diffs.length - 1) {
874
+ if (diffs[pointer - 1][0] == DIFF_EQUAL &&
875
+ diffs[pointer + 1][0] == DIFF_EQUAL) {
876
+ // This is a single edit surrounded by equalities.
877
+ var equality1 = /** @type {string} */(diffs[pointer - 1][1]);
878
+ var edit = /** @type {string} */(diffs[pointer][1]);
879
+ var equality2 = /** @type {string} */(diffs[pointer + 1][1]);
880
+
881
+ // First, shift the edit as far left as possible.
882
+ var commonOffset = this.diff_commonSuffix(equality1, edit);
883
+ if (commonOffset) {
884
+ var commonString = edit.substring(edit.length - commonOffset);
885
+ equality1 = equality1.substring(0, equality1.length - commonOffset);
886
+ edit = commonString + edit.substring(0, edit.length - commonOffset);
887
+ equality2 = commonString + equality2;
888
+ }
889
+
890
+ // Second, step character by character right, looking for the best fit.
891
+ var bestEquality1 = equality1;
892
+ var bestEdit = edit;
893
+ var bestEquality2 = equality2;
894
+ var bestScore = diff_cleanupSemanticScore_(equality1, edit) +
895
+ diff_cleanupSemanticScore_(edit, equality2);
896
+ while (edit.charAt(0) === equality2.charAt(0)) {
897
+ equality1 += edit.charAt(0);
898
+ edit = edit.substring(1) + equality2.charAt(0);
899
+ equality2 = equality2.substring(1);
900
+ var score = diff_cleanupSemanticScore_(equality1, edit) +
901
+ diff_cleanupSemanticScore_(edit, equality2);
902
+ // The >= encourages trailing rather than leading whitespace on edits.
903
+ if (score >= bestScore) {
904
+ bestScore = score;
905
+ bestEquality1 = equality1;
906
+ bestEdit = edit;
907
+ bestEquality2 = equality2;
908
+ }
909
+ }
910
+
911
+ if (diffs[pointer - 1][1] != bestEquality1) {
912
+ // We have an improvement, save it back to the diff.
913
+ if (bestEquality1) {
914
+ diffs[pointer - 1][1] = bestEquality1;
915
+ } else {
916
+ diffs.splice(pointer - 1, 1);
917
+ pointer--;
918
+ }
919
+ diffs[pointer][1] = bestEdit;
920
+ if (bestEquality2) {
921
+ diffs[pointer + 1][1] = bestEquality2;
922
+ } else {
923
+ diffs.splice(pointer + 1, 1);
924
+ pointer--;
925
+ }
926
+ }
927
+ }
928
+ pointer++;
929
+ }
930
+ };
931
+
932
+
933
+ /**
934
+ * Reduce the number of edits by eliminating operationally trivial equalities.
935
+ * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
936
+ */
937
+ diff_match_patch.prototype.diff_cleanupEfficiency = function(diffs) {
938
+ var changes = false;
939
+ var equalities = []; // Stack of indices where equalities are found.
940
+ var equalitiesLength = 0; // Keeping our own length var is faster in JS.
941
+ var lastequality = ''; // Always equal to equalities[equalitiesLength-1][1]
942
+ var pointer = 0; // Index of current position.
943
+ // Is there an insertion operation before the last equality.
944
+ var pre_ins = false;
945
+ // Is there a deletion operation before the last equality.
946
+ var pre_del = false;
947
+ // Is there an insertion operation after the last equality.
948
+ var post_ins = false;
949
+ // Is there a deletion operation after the last equality.
950
+ var post_del = false;
951
+ while (pointer < diffs.length) {
952
+ if (diffs[pointer][0] == DIFF_EQUAL) { // Equality found.
953
+ if (diffs[pointer][1].length < this.Diff_EditCost &&
954
+ (post_ins || post_del)) {
955
+ // Candidate found.
956
+ equalities[equalitiesLength++] = pointer;
957
+ pre_ins = post_ins;
958
+ pre_del = post_del;
959
+ lastequality = diffs[pointer][1];
960
+ } else {
961
+ // Not a candidate, and can never become one.
962
+ equalitiesLength = 0;
963
+ lastequality = '';
964
+ }
965
+ post_ins = post_del = false;
966
+ } else { // An insertion or deletion.
967
+ if (diffs[pointer][0] == DIFF_DELETE) {
968
+ post_del = true;
969
+ } else {
970
+ post_ins = true;
971
+ }
972
+ /*
973
+ * Five types to be split:
974
+ * <ins>A</ins><del>B</del>XY<ins>C</ins><del>D</del>
975
+ * <ins>A</ins>X<ins>C</ins><del>D</del>
976
+ * <ins>A</ins><del>B</del>X<ins>C</ins>
977
+ * <ins>A</del>X<ins>C</ins><del>D</del>
978
+ * <ins>A</ins><del>B</del>X<del>C</del>
979
+ */
980
+ if (lastequality && ((pre_ins && pre_del && post_ins && post_del) ||
981
+ ((lastequality.length < this.Diff_EditCost / 2) &&
982
+ (pre_ins + pre_del + post_ins + post_del) == 3))) {
983
+ // Duplicate record.
984
+ diffs.splice(equalities[equalitiesLength - 1], 0,
985
+ [DIFF_DELETE, lastequality]);
986
+ // Change second copy to insert.
987
+ diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT;
988
+ equalitiesLength--; // Throw away the equality we just deleted;
989
+ lastequality = '';
990
+ if (pre_ins && pre_del) {
991
+ // No changes made which could affect previous entry, keep going.
992
+ post_ins = post_del = true;
993
+ equalitiesLength = 0;
994
+ } else {
995
+ equalitiesLength--; // Throw away the previous equality.
996
+ pointer = equalitiesLength > 0 ?
997
+ equalities[equalitiesLength - 1] : -1;
998
+ post_ins = post_del = false;
999
+ }
1000
+ changes = true;
1001
+ }
1002
+ }
1003
+ pointer++;
1004
+ }
1005
+
1006
+ if (changes) {
1007
+ this.diff_cleanupMerge(diffs);
1008
+ }
1009
+ };
1010
+
1011
+
1012
+ /**
1013
+ * Reorder and merge like edit sections. Merge equalities.
1014
+ * Any edit section can move as long as it doesn't cross an equality.
1015
+ * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
1016
+ */
1017
+ diff_match_patch.prototype.diff_cleanupMerge = function(diffs) {
1018
+ diffs.push([DIFF_EQUAL, '']); // Add a dummy entry at the end.
1019
+ var pointer = 0;
1020
+ var count_delete = 0;
1021
+ var count_insert = 0;
1022
+ var text_delete = '';
1023
+ var text_insert = '';
1024
+ var commonlength;
1025
+ while (pointer < diffs.length) {
1026
+ switch (diffs[pointer][0]) {
1027
+ case DIFF_INSERT:
1028
+ count_insert++;
1029
+ text_insert += diffs[pointer][1];
1030
+ pointer++;
1031
+ break;
1032
+ case DIFF_DELETE:
1033
+ count_delete++;
1034
+ text_delete += diffs[pointer][1];
1035
+ pointer++;
1036
+ break;
1037
+ case DIFF_EQUAL:
1038
+ // Upon reaching an equality, check for prior redundancies.
1039
+ if (count_delete + count_insert > 1) {
1040
+ if (count_delete !== 0 && count_insert !== 0) {
1041
+ // Factor out any common prefixies.
1042
+ commonlength = this.diff_commonPrefix(text_insert, text_delete);
1043
+ if (commonlength !== 0) {
1044
+ if ((pointer - count_delete - count_insert) > 0 &&
1045
+ diffs[pointer - count_delete - count_insert - 1][0] ==
1046
+ DIFF_EQUAL) {
1047
+ diffs[pointer - count_delete - count_insert - 1][1] +=
1048
+ text_insert.substring(0, commonlength);
1049
+ } else {
1050
+ diffs.splice(0, 0, [DIFF_EQUAL,
1051
+ text_insert.substring(0, commonlength)]);
1052
+ pointer++;
1053
+ }
1054
+ text_insert = text_insert.substring(commonlength);
1055
+ text_delete = text_delete.substring(commonlength);
1056
+ }
1057
+ // Factor out any common suffixies.
1058
+ commonlength = this.diff_commonSuffix(text_insert, text_delete);
1059
+ if (commonlength !== 0) {
1060
+ diffs[pointer][1] = text_insert.substring(text_insert.length -
1061
+ commonlength) + diffs[pointer][1];
1062
+ text_insert = text_insert.substring(0, text_insert.length -
1063
+ commonlength);
1064
+ text_delete = text_delete.substring(0, text_delete.length -
1065
+ commonlength);
1066
+ }
1067
+ }
1068
+ // Delete the offending records and add the merged ones.
1069
+ if (count_delete === 0) {
1070
+ diffs.splice(pointer - count_delete - count_insert,
1071
+ count_delete + count_insert, [DIFF_INSERT, text_insert]);
1072
+ } else if (count_insert === 0) {
1073
+ diffs.splice(pointer - count_delete - count_insert,
1074
+ count_delete + count_insert, [DIFF_DELETE, text_delete]);
1075
+ } else {
1076
+ diffs.splice(pointer - count_delete - count_insert,
1077
+ count_delete + count_insert, [DIFF_DELETE, text_delete],
1078
+ [DIFF_INSERT, text_insert]);
1079
+ }
1080
+ pointer = pointer - count_delete - count_insert +
1081
+ (count_delete ? 1 : 0) + (count_insert ? 1 : 0) + 1;
1082
+ } else if (pointer !== 0 && diffs[pointer - 1][0] == DIFF_EQUAL) {
1083
+ // Merge this equality with the previous one.
1084
+ diffs[pointer - 1][1] += diffs[pointer][1];
1085
+ diffs.splice(pointer, 1);
1086
+ } else {
1087
+ pointer++;
1088
+ }
1089
+ count_insert = 0;
1090
+ count_delete = 0;
1091
+ text_delete = '';
1092
+ text_insert = '';
1093
+ break;
1094
+ }
1095
+ }
1096
+ if (diffs[diffs.length - 1][1] === '') {
1097
+ diffs.pop(); // Remove the dummy entry at the end.
1098
+ }
1099
+
1100
+ // Second pass: look for single edits surrounded on both sides by equalities
1101
+ // which can be shifted sideways to eliminate an equality.
1102
+ // e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
1103
+ var changes = false;
1104
+ pointer = 1;
1105
+ // Intentionally ignore the first and last element (don't need checking).
1106
+ while (pointer < diffs.length - 1) {
1107
+ if (diffs[pointer - 1][0] == DIFF_EQUAL &&
1108
+ diffs[pointer + 1][0] == DIFF_EQUAL) {
1109
+ // This is a single edit surrounded by equalities.
1110
+ if (diffs[pointer][1].substring(diffs[pointer][1].length -
1111
+ diffs[pointer - 1][1].length) == diffs[pointer - 1][1]) {
1112
+ // Shift the edit over the previous equality.
1113
+ diffs[pointer][1] = diffs[pointer - 1][1] +
1114
+ diffs[pointer][1].substring(0, diffs[pointer][1].length -
1115
+ diffs[pointer - 1][1].length);
1116
+ diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
1117
+ diffs.splice(pointer - 1, 1);
1118
+ changes = true;
1119
+ } else if (diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) ==
1120
+ diffs[pointer + 1][1]) {
1121
+ // Shift the edit over the next equality.
1122
+ diffs[pointer - 1][1] += diffs[pointer + 1][1];
1123
+ diffs[pointer][1] =
1124
+ diffs[pointer][1].substring(diffs[pointer + 1][1].length) +
1125
+ diffs[pointer + 1][1];
1126
+ diffs.splice(pointer + 1, 1);
1127
+ changes = true;
1128
+ }
1129
+ }
1130
+ pointer++;
1131
+ }
1132
+ // If shifts were made, the diff needs reordering and another shift sweep.
1133
+ if (changes) {
1134
+ this.diff_cleanupMerge(diffs);
1135
+ }
1136
+ };
1137
+
1138
+
1139
+ /**
1140
+ * loc is a location in text1, compute and return the equivalent location in
1141
+ * text2.
1142
+ * e.g. 'The cat' vs 'The big cat', 1->1, 5->8
1143
+ * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
1144
+ * @param {number} loc Location within text1.
1145
+ * @return {number} Location within text2.
1146
+ */
1147
+ diff_match_patch.prototype.diff_xIndex = function(diffs, loc) {
1148
+ var chars1 = 0;
1149
+ var chars2 = 0;
1150
+ var last_chars1 = 0;
1151
+ var last_chars2 = 0;
1152
+ var x;
1153
+ for (x = 0; x < diffs.length; x++) {
1154
+ if (diffs[x][0] !== DIFF_INSERT) { // Equality or deletion.
1155
+ chars1 += diffs[x][1].length;
1156
+ }
1157
+ if (diffs[x][0] !== DIFF_DELETE) { // Equality or insertion.
1158
+ chars2 += diffs[x][1].length;
1159
+ }
1160
+ if (chars1 > loc) { // Overshot the location.
1161
+ break;
1162
+ }
1163
+ last_chars1 = chars1;
1164
+ last_chars2 = chars2;
1165
+ }
1166
+ // Was the location was deleted?
1167
+ if (diffs.length != x && diffs[x][0] === DIFF_DELETE) {
1168
+ return last_chars2;
1169
+ }
1170
+ // Add the remaining character length.
1171
+ return last_chars2 + (loc - last_chars1);
1172
+ };
1173
+
1174
+
1175
+ /**
1176
+ * Convert a diff array into a pretty HTML report.
1177
+ * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
1178
+ * @return {string} HTML representation.
1179
+ */
1180
+ diff_match_patch.prototype.diff_prettyHtml = function(diffs) {
1181
+ var html = [];
1182
+ var i = 0;
1183
+ var pattern_amp = /&/g;
1184
+ var pattern_lt = /</g;
1185
+ var pattern_gt = />/g;
1186
+ var pattern_para = /\n/g;
1187
+ for (var x = 0; x < diffs.length; x++) {
1188
+ var op = diffs[x][0]; // Operation (insert, delete, equal)
1189
+ var data = diffs[x][1]; // Text of change.
1190
+ var text = data.replace(pattern_amp, '&amp;').replace(pattern_lt, '&lt;')
1191
+ .replace(pattern_gt, '&gt;').replace(pattern_para, '&para;<br>');
1192
+ switch (op) {
1193
+ case DIFF_INSERT:
1194
+ html[x] = '<ins style="background:#e6ffe6;">' + text + '</ins>';
1195
+ break;
1196
+ case DIFF_DELETE:
1197
+ html[x] = '<del style="background:#ffe6e6;">' + text + '</del>';
1198
+ break;
1199
+ case DIFF_EQUAL:
1200
+ html[x] = '<span>' + text + '</span>';
1201
+ break;
1202
+ }
1203
+ if (op !== DIFF_DELETE) {
1204
+ i += data.length;
1205
+ }
1206
+ }
1207
+ return html.join('');
1208
+ };
1209
+
1210
+
1211
+ /**
1212
+ * Compute and return the source text (all equalities and deletions).
1213
+ * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
1214
+ * @return {string} Source text.
1215
+ */
1216
+ diff_match_patch.prototype.diff_text1 = function(diffs) {
1217
+ var text = [];
1218
+ for (var x = 0; x < diffs.length; x++) {
1219
+ if (diffs[x][0] !== DIFF_INSERT) {
1220
+ text[x] = diffs[x][1];
1221
+ }
1222
+ }
1223
+ return text.join('');
1224
+ };
1225
+
1226
+
1227
+ /**
1228
+ * Compute and return the destination text (all equalities and insertions).
1229
+ * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
1230
+ * @return {string} Destination text.
1231
+ */
1232
+ diff_match_patch.prototype.diff_text2 = function(diffs) {
1233
+ var text = [];
1234
+ for (var x = 0; x < diffs.length; x++) {
1235
+ if (diffs[x][0] !== DIFF_DELETE) {
1236
+ text[x] = diffs[x][1];
1237
+ }
1238
+ }
1239
+ return text.join('');
1240
+ };
1241
+
1242
+
1243
+ /**
1244
+ * Compute the Levenshtein distance; the number of inserted, deleted or
1245
+ * substituted characters.
1246
+ * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
1247
+ * @return {number} Number of changes.
1248
+ */
1249
+ diff_match_patch.prototype.diff_levenshtein = function(diffs) {
1250
+ var levenshtein = 0;
1251
+ var insertions = 0;
1252
+ var deletions = 0;
1253
+ for (var x = 0; x < diffs.length; x++) {
1254
+ var op = diffs[x][0];
1255
+ var data = diffs[x][1];
1256
+ switch (op) {
1257
+ case DIFF_INSERT:
1258
+ insertions += data.length;
1259
+ break;
1260
+ case DIFF_DELETE:
1261
+ deletions += data.length;
1262
+ break;
1263
+ case DIFF_EQUAL:
1264
+ // A deletion and an insertion is one substitution.
1265
+ levenshtein += Math.max(insertions, deletions);
1266
+ insertions = 0;
1267
+ deletions = 0;
1268
+ break;
1269
+ }
1270
+ }
1271
+ levenshtein += Math.max(insertions, deletions);
1272
+ return levenshtein;
1273
+ };
1274
+
1275
+
1276
+ /**
1277
+ * Crush the diff into an encoded string which describes the operations
1278
+ * required to transform text1 into text2.
1279
+ * E.g. =3\t-2\t+ing -> Keep 3 chars, delete 2 chars, insert 'ing'.
1280
+ * Operations are tab-separated. Inserted text is escaped using %xx notation.
1281
+ * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
1282
+ * @return {string} Delta text.
1283
+ */
1284
+ diff_match_patch.prototype.diff_toDelta = function(diffs) {
1285
+ var text = [];
1286
+ for (var x = 0; x < diffs.length; x++) {
1287
+ switch (diffs[x][0]) {
1288
+ case DIFF_INSERT:
1289
+ text[x] = '+' + encodeURI(diffs[x][1]);
1290
+ break;
1291
+ case DIFF_DELETE:
1292
+ text[x] = '-' + diffs[x][1].length;
1293
+ break;
1294
+ case DIFF_EQUAL:
1295
+ text[x] = '=' + diffs[x][1].length;
1296
+ break;
1297
+ }
1298
+ }
1299
+ return text.join('\t').replace(/%20/g, ' ');
1300
+ };
1301
+
1302
+
1303
+ /**
1304
+ * Given the original text1, and an encoded string which describes the
1305
+ * operations required to transform text1 into text2, compute the full diff.
1306
+ * @param {string} text1 Source string for the diff.
1307
+ * @param {string} delta Delta text.
1308
+ * @return {!Array.<!diff_match_patch.Diff>} Array of diff tuples.
1309
+ * @throws {!Error} If invalid input.
1310
+ */
1311
+ diff_match_patch.prototype.diff_fromDelta = function(text1, delta) {
1312
+ var diffs = [];
1313
+ var diffsLength = 0; // Keeping our own length var is faster in JS.
1314
+ var pointer = 0; // Cursor in text1
1315
+ var tokens = delta.split(/\t/g);
1316
+ for (var x = 0; x < tokens.length; x++) {
1317
+ // Each token begins with a one character parameter which specifies the
1318
+ // operation of this token (delete, insert, equality).
1319
+ var param = tokens[x].substring(1);
1320
+ switch (tokens[x].charAt(0)) {
1321
+ case '+':
1322
+ try {
1323
+ diffs[diffsLength++] = [DIFF_INSERT, decodeURI(param)];
1324
+ } catch (ex) {
1325
+ // Malformed URI sequence.
1326
+ throw new Error('Illegal escape in diff_fromDelta: ' + param);
1327
+ }
1328
+ break;
1329
+ case '-':
1330
+ // Fall through.
1331
+ case '=':
1332
+ var n = parseInt(param, 10);
1333
+ if (isNaN(n) || n < 0) {
1334
+ throw new Error('Invalid number in diff_fromDelta: ' + param);
1335
+ }
1336
+ var text = text1.substring(pointer, pointer += n);
1337
+ if (tokens[x].charAt(0) == '=') {
1338
+ diffs[diffsLength++] = [DIFF_EQUAL, text];
1339
+ } else {
1340
+ diffs[diffsLength++] = [DIFF_DELETE, text];
1341
+ }
1342
+ break;
1343
+ default:
1344
+ // Blank tokens are ok (from a trailing \t).
1345
+ // Anything else is an error.
1346
+ if (tokens[x]) {
1347
+ throw new Error('Invalid diff operation in diff_fromDelta: ' +
1348
+ tokens[x]);
1349
+ }
1350
+ }
1351
+ }
1352
+ if (pointer != text1.length) {
1353
+ throw new Error('Delta length (' + pointer +
1354
+ ') does not equal source text length (' + text1.length + ').');
1355
+ }
1356
+ return diffs;
1357
+ };
1358
+
1359
+
1360
+ // MATCH FUNCTIONS
1361
+
1362
+
1363
+ /**
1364
+ * Locate the best instance of 'pattern' in 'text' near 'loc'.
1365
+ * @param {string} text The text to search.
1366
+ * @param {string} pattern The pattern to search for.
1367
+ * @param {number} loc The location to search around.
1368
+ * @return {number} Best match index or -1.
1369
+ */
1370
+ diff_match_patch.prototype.match_main = function(text, pattern, loc) {
1371
+ // Check for null inputs.
1372
+ if (text == null || pattern == null || loc == null) {
1373
+ throw new Error('Null input. (match_main)');
1374
+ }
1375
+
1376
+ loc = Math.max(0, Math.min(loc, text.length));
1377
+ if (text == pattern) {
1378
+ // Shortcut (potentially not guaranteed by the algorithm)
1379
+ return 0;
1380
+ } else if (!text.length) {
1381
+ // Nothing to match.
1382
+ return -1;
1383
+ } else if (text.substring(loc, loc + pattern.length) == pattern) {
1384
+ // Perfect match at the perfect spot! (Includes case of null pattern)
1385
+ return loc;
1386
+ } else {
1387
+ // Do a fuzzy compare.
1388
+ return this.match_bitap_(text, pattern, loc);
1389
+ }
1390
+ };
1391
+
1392
+
1393
+ /**
1394
+ * Locate the best instance of 'pattern' in 'text' near 'loc' using the
1395
+ * Bitap algorithm.
1396
+ * @param {string} text The text to search.
1397
+ * @param {string} pattern The pattern to search for.
1398
+ * @param {number} loc The location to search around.
1399
+ * @return {number} Best match index or -1.
1400
+ * @private
1401
+ */
1402
+ diff_match_patch.prototype.match_bitap_ = function(text, pattern, loc) {
1403
+ if (pattern.length > this.Match_MaxBits) {
1404
+ throw new Error('Pattern too long for this browser.');
1405
+ }
1406
+
1407
+ // Initialise the alphabet.
1408
+ var s = this.match_alphabet_(pattern);
1409
+
1410
+ var dmp = this; // 'this' becomes 'window' in a closure.
1411
+
1412
+ /**
1413
+ * Compute and return the score for a match with e errors and x location.
1414
+ * Accesses loc and pattern through being a closure.
1415
+ * @param {number} e Number of errors in match.
1416
+ * @param {number} x Location of match.
1417
+ * @return {number} Overall score for match (0.0 = good, 1.0 = bad).
1418
+ * @private
1419
+ */
1420
+ function match_bitapScore_(e, x) {
1421
+ var accuracy = e / pattern.length;
1422
+ var proximity = Math.abs(loc - x);
1423
+ if (!dmp.Match_Distance) {
1424
+ // Dodge divide by zero error.
1425
+ return proximity ? 1.0 : accuracy;
1426
+ }
1427
+ return accuracy + (proximity / dmp.Match_Distance);
1428
+ }
1429
+
1430
+ // Highest score beyond which we give up.
1431
+ var score_threshold = this.Match_Threshold;
1432
+ // Is there a nearby exact match? (speedup)
1433
+ var best_loc = text.indexOf(pattern, loc);
1434
+ if (best_loc != -1) {
1435
+ score_threshold = Math.min(match_bitapScore_(0, best_loc), score_threshold);
1436
+ // What about in the other direction? (speedup)
1437
+ best_loc = text.lastIndexOf(pattern, loc + pattern.length);
1438
+ if (best_loc != -1) {
1439
+ score_threshold =
1440
+ Math.min(match_bitapScore_(0, best_loc), score_threshold);
1441
+ }
1442
+ }
1443
+
1444
+ // Initialise the bit arrays.
1445
+ var matchmask = 1 << (pattern.length - 1);
1446
+ best_loc = -1;
1447
+
1448
+ var bin_min, bin_mid;
1449
+ var bin_max = pattern.length + text.length;
1450
+ var last_rd;
1451
+ for (var d = 0; d < pattern.length; d++) {
1452
+ // Scan for the best match; each iteration allows for one more error.
1453
+ // Run a binary search to determine how far from 'loc' we can stray at this
1454
+ // error level.
1455
+ bin_min = 0;
1456
+ bin_mid = bin_max;
1457
+ while (bin_min < bin_mid) {
1458
+ if (match_bitapScore_(d, loc + bin_mid) <= score_threshold) {
1459
+ bin_min = bin_mid;
1460
+ } else {
1461
+ bin_max = bin_mid;
1462
+ }
1463
+ bin_mid = Math.floor((bin_max - bin_min) / 2 + bin_min);
1464
+ }
1465
+ // Use the result from this iteration as the maximum for the next.
1466
+ bin_max = bin_mid;
1467
+ var start = Math.max(1, loc - bin_mid + 1);
1468
+ var finish = Math.min(loc + bin_mid, text.length) + pattern.length;
1469
+
1470
+ var rd = Array(finish + 2);
1471
+ rd[finish + 1] = (1 << d) - 1;
1472
+ for (var j = finish; j >= start; j--) {
1473
+ // The alphabet (s) is a sparse hash, so the following line generates
1474
+ // warnings.
1475
+ var charMatch = s[text.charAt(j - 1)];
1476
+ if (d === 0) { // First pass: exact match.
1477
+ rd[j] = ((rd[j + 1] << 1) | 1) & charMatch;
1478
+ } else { // Subsequent passes: fuzzy match.
1479
+ rd[j] = ((rd[j + 1] << 1) | 1) & charMatch |
1480
+ (((last_rd[j + 1] | last_rd[j]) << 1) | 1) |
1481
+ last_rd[j + 1];
1482
+ }
1483
+ if (rd[j] & matchmask) {
1484
+ var score = match_bitapScore_(d, j - 1);
1485
+ // This match will almost certainly be better than any existing match.
1486
+ // But check anyway.
1487
+ if (score <= score_threshold) {
1488
+ // Told you so.
1489
+ score_threshold = score;
1490
+ best_loc = j - 1;
1491
+ if (best_loc > loc) {
1492
+ // When passing loc, don't exceed our current distance from loc.
1493
+ start = Math.max(1, 2 * loc - best_loc);
1494
+ } else {
1495
+ // Already passed loc, downhill from here on in.
1496
+ break;
1497
+ }
1498
+ }
1499
+ }
1500
+ }
1501
+ // No hope for a (better) match at greater error levels.
1502
+ if (match_bitapScore_(d + 1, loc) > score_threshold) {
1503
+ break;
1504
+ }
1505
+ last_rd = rd;
1506
+ }
1507
+ return best_loc;
1508
+ };
1509
+
1510
+
1511
+ /**
1512
+ * Initialise the alphabet for the Bitap algorithm.
1513
+ * @param {string} pattern The text to encode.
1514
+ * @return {!Object} Hash of character locations.
1515
+ * @private
1516
+ */
1517
+ diff_match_patch.prototype.match_alphabet_ = function(pattern) {
1518
+ var s = {};
1519
+ for (var i = 0; i < pattern.length; i++) {
1520
+ s[pattern.charAt(i)] = 0;
1521
+ }
1522
+ for (var i = 0; i < pattern.length; i++) {
1523
+ s[pattern.charAt(i)] |= 1 << (pattern.length - i - 1);
1524
+ }
1525
+ return s;
1526
+ };
1527
+
1528
+
1529
+ // PATCH FUNCTIONS
1530
+
1531
+
1532
+ /**
1533
+ * Increase the context until it is unique,
1534
+ * but don't let the pattern expand beyond Match_MaxBits.
1535
+ * @param {!patch_obj} patch The patch to grow.
1536
+ * @param {string} text Source text.
1537
+ * @private
1538
+ */
1539
+ diff_match_patch.prototype.patch_addContext_ = function(patch, text) {
1540
+ if (text.length == 0) {
1541
+ return;
1542
+ }
1543
+ var pattern = text.substring(patch.start2, patch.start2 + patch.length1);
1544
+ var padding = 0;
1545
+
1546
+ // Look for the first and last matches of pattern in text. If two different
1547
+ // matches are found, increase the pattern length.
1548
+ while (text.indexOf(pattern) != text.lastIndexOf(pattern) &&
1549
+ pattern.length < this.Match_MaxBits - this.Patch_Margin -
1550
+ this.Patch_Margin) {
1551
+ padding += this.Patch_Margin;
1552
+ pattern = text.substring(patch.start2 - padding,
1553
+ patch.start2 + patch.length1 + padding);
1554
+ }
1555
+ // Add one chunk for good luck.
1556
+ padding += this.Patch_Margin;
1557
+
1558
+ // Add the prefix.
1559
+ var prefix = text.substring(patch.start2 - padding, patch.start2);
1560
+ if (prefix) {
1561
+ patch.diffs.unshift([DIFF_EQUAL, prefix]);
1562
+ }
1563
+ // Add the suffix.
1564
+ var suffix = text.substring(patch.start2 + patch.length1,
1565
+ patch.start2 + patch.length1 + padding);
1566
+ if (suffix) {
1567
+ patch.diffs.push([DIFF_EQUAL, suffix]);
1568
+ }
1569
+
1570
+ // Roll back the start points.
1571
+ patch.start1 -= prefix.length;
1572
+ patch.start2 -= prefix.length;
1573
+ // Extend the lengths.
1574
+ patch.length1 += prefix.length + suffix.length;
1575
+ patch.length2 += prefix.length + suffix.length;
1576
+ };
1577
+
1578
+
1579
+ /**
1580
+ * Compute a list of patches to turn text1 into text2.
1581
+ * Use diffs if provided, otherwise compute it ourselves.
1582
+ * There are four ways to call this function, depending on what data is
1583
+ * available to the caller:
1584
+ * Method 1:
1585
+ * a = text1, b = text2
1586
+ * Method 2:
1587
+ * a = diffs
1588
+ * Method 3 (optimal):
1589
+ * a = text1, b = diffs
1590
+ * Method 4 (deprecated, use method 3):
1591
+ * a = text1, b = text2, c = diffs
1592
+ *
1593
+ * @param {string|!Array.<!diff_match_patch.Diff>} a text1 (methods 1,3,4) or
1594
+ * Array of diff tuples for text1 to text2 (method 2).
1595
+ * @param {string|!Array.<!diff_match_patch.Diff>} opt_b text2 (methods 1,4) or
1596
+ * Array of diff tuples for text1 to text2 (method 3) or undefined (method 2).
1597
+ * @param {string|!Array.<!diff_match_patch.Diff>} opt_c Array of diff tuples
1598
+ * for text1 to text2 (method 4) or undefined (methods 1,2,3).
1599
+ * @return {!Array.<!patch_obj>} Array of patch objects.
1600
+ */
1601
+ diff_match_patch.prototype.patch_make = function(a, opt_b, opt_c) {
1602
+ var text1, diffs;
1603
+ if (typeof a == 'string' && typeof opt_b == 'string' &&
1604
+ typeof opt_c == 'undefined') {
1605
+ // Method 1: text1, text2
1606
+ // Compute diffs from text1 and text2.
1607
+ text1 = /** @type {string} */(a);
1608
+ diffs = this.diff_main(text1, /** @type {string} */(opt_b), true);
1609
+ if (diffs.length > 2) {
1610
+ this.diff_cleanupSemantic(diffs);
1611
+ this.diff_cleanupEfficiency(diffs);
1612
+ }
1613
+ } else if (a && typeof a == 'object' && typeof opt_b == 'undefined' &&
1614
+ typeof opt_c == 'undefined') {
1615
+ // Method 2: diffs
1616
+ // Compute text1 from diffs.
1617
+ diffs = /** @type {!Array.<!diff_match_patch.Diff>} */(a);
1618
+ text1 = this.diff_text1(diffs);
1619
+ } else if (typeof a == 'string' && opt_b && typeof opt_b == 'object' &&
1620
+ typeof opt_c == 'undefined') {
1621
+ // Method 3: text1, diffs
1622
+ text1 = /** @type {string} */(a);
1623
+ diffs = /** @type {!Array.<!diff_match_patch.Diff>} */(opt_b);
1624
+ } else if (typeof a == 'string' && typeof opt_b == 'string' &&
1625
+ opt_c && typeof opt_c == 'object') {
1626
+ // Method 4: text1, text2, diffs
1627
+ // text2 is not used.
1628
+ text1 = /** @type {string} */(a);
1629
+ diffs = /** @type {!Array.<!diff_match_patch.Diff>} */(opt_c);
1630
+ } else {
1631
+ throw new Error('Unknown call format to patch_make.');
1632
+ }
1633
+
1634
+ if (diffs.length === 0) {
1635
+ return []; // Get rid of the null case.
1636
+ }
1637
+ var patches = [];
1638
+ var patch = new patch_obj();
1639
+ var patchDiffLength = 0; // Keeping our own length var is faster in JS.
1640
+ var char_count1 = 0; // Number of characters into the text1 string.
1641
+ var char_count2 = 0; // Number of characters into the text2 string.
1642
+ // Start with text1 (prepatch_text) and apply the diffs until we arrive at
1643
+ // text2 (postpatch_text). We recreate the patches one by one to determine
1644
+ // context info.
1645
+ var prepatch_text = text1;
1646
+ var postpatch_text = text1;
1647
+ for (var x = 0; x < diffs.length; x++) {
1648
+ var diff_type = diffs[x][0];
1649
+ var diff_text = diffs[x][1];
1650
+
1651
+ if (!patchDiffLength && diff_type !== DIFF_EQUAL) {
1652
+ // A new patch starts here.
1653
+ patch.start1 = char_count1;
1654
+ patch.start2 = char_count2;
1655
+ }
1656
+
1657
+ switch (diff_type) {
1658
+ case DIFF_INSERT:
1659
+ patch.diffs[patchDiffLength++] = diffs[x];
1660
+ patch.length2 += diff_text.length;
1661
+ postpatch_text = postpatch_text.substring(0, char_count2) + diff_text +
1662
+ postpatch_text.substring(char_count2);
1663
+ break;
1664
+ case DIFF_DELETE:
1665
+ patch.length1 += diff_text.length;
1666
+ patch.diffs[patchDiffLength++] = diffs[x];
1667
+ postpatch_text = postpatch_text.substring(0, char_count2) +
1668
+ postpatch_text.substring(char_count2 +
1669
+ diff_text.length);
1670
+ break;
1671
+ case DIFF_EQUAL:
1672
+ if (diff_text.length <= 2 * this.Patch_Margin &&
1673
+ patchDiffLength && diffs.length != x + 1) {
1674
+ // Small equality inside a patch.
1675
+ patch.diffs[patchDiffLength++] = diffs[x];
1676
+ patch.length1 += diff_text.length;
1677
+ patch.length2 += diff_text.length;
1678
+ } else if (diff_text.length >= 2 * this.Patch_Margin) {
1679
+ // Time for a new patch.
1680
+ if (patchDiffLength) {
1681
+ this.patch_addContext_(patch, prepatch_text);
1682
+ patches.push(patch);
1683
+ patch = new patch_obj();
1684
+ patchDiffLength = 0;
1685
+ // Unlike Unidiff, our patch lists have a rolling context.
1686
+ // http://code.google.com/p/google-diff-match-patch/wiki/Unidiff
1687
+ // Update prepatch text & pos to reflect the application of the
1688
+ // just completed patch.
1689
+ prepatch_text = postpatch_text;
1690
+ char_count1 = char_count2;
1691
+ }
1692
+ }
1693
+ break;
1694
+ }
1695
+
1696
+ // Update the current character count.
1697
+ if (diff_type !== DIFF_INSERT) {
1698
+ char_count1 += diff_text.length;
1699
+ }
1700
+ if (diff_type !== DIFF_DELETE) {
1701
+ char_count2 += diff_text.length;
1702
+ }
1703
+ }
1704
+ // Pick up the leftover patch if not empty.
1705
+ if (patchDiffLength) {
1706
+ this.patch_addContext_(patch, prepatch_text);
1707
+ patches.push(patch);
1708
+ }
1709
+
1710
+ return patches;
1711
+ };
1712
+
1713
+
1714
+ /**
1715
+ * Given an array of patches, return another array that is identical.
1716
+ * @param {!Array.<!patch_obj>} patches Array of patch objects.
1717
+ * @return {!Array.<!patch_obj>} Array of patch objects.
1718
+ */
1719
+ diff_match_patch.prototype.patch_deepCopy = function(patches) {
1720
+ // Making deep copies is hard in JavaScript.
1721
+ var patchesCopy = [];
1722
+ for (var x = 0; x < patches.length; x++) {
1723
+ var patch = patches[x];
1724
+ var patchCopy = new patch_obj();
1725
+ patchCopy.diffs = [];
1726
+ for (var y = 0; y < patch.diffs.length; y++) {
1727
+ patchCopy.diffs[y] = patch.diffs[y].slice();
1728
+ }
1729
+ patchCopy.start1 = patch.start1;
1730
+ patchCopy.start2 = patch.start2;
1731
+ patchCopy.length1 = patch.length1;
1732
+ patchCopy.length2 = patch.length2;
1733
+ patchesCopy[x] = patchCopy;
1734
+ }
1735
+ return patchesCopy;
1736
+ };
1737
+
1738
+
1739
+ /**
1740
+ * Merge a set of patches onto the text. Return a patched text, as well
1741
+ * as a list of true/false values indicating which patches were applied.
1742
+ * @param {!Array.<!patch_obj>} patches Array of patch objects.
1743
+ * @param {string} text Old text.
1744
+ * @return {!Array.<string|!Array.<boolean>>} Two element Array, containing the
1745
+ * new text and an array of boolean values.
1746
+ */
1747
+ diff_match_patch.prototype.patch_apply = function(patches, text) {
1748
+ if (patches.length == 0) {
1749
+ return [text, []];
1750
+ }
1751
+
1752
+ // Deep copy the patches so that no changes are made to originals.
1753
+ patches = this.patch_deepCopy(patches);
1754
+
1755
+ var nullPadding = this.patch_addPadding(patches);
1756
+ text = nullPadding + text + nullPadding;
1757
+
1758
+ this.patch_splitMax(patches);
1759
+ // delta keeps track of the offset between the expected and actual location
1760
+ // of the previous patch. If there are patches expected at positions 10 and
1761
+ // 20, but the first patch was found at 12, delta is 2 and the second patch
1762
+ // has an effective expected position of 22.
1763
+ var delta = 0;
1764
+ var results = [];
1765
+ for (var x = 0; x < patches.length; x++) {
1766
+ var expected_loc = patches[x].start2 + delta;
1767
+ var text1 = this.diff_text1(patches[x].diffs);
1768
+ var start_loc;
1769
+ var end_loc = -1;
1770
+ if (text1.length > this.Match_MaxBits) {
1771
+ // patch_splitMax will only provide an oversized pattern in the case of
1772
+ // a monster delete.
1773
+ start_loc = this.match_main(text, text1.substring(0, this.Match_MaxBits),
1774
+ expected_loc);
1775
+ if (start_loc != -1) {
1776
+ end_loc = this.match_main(text,
1777
+ text1.substring(text1.length - this.Match_MaxBits),
1778
+ expected_loc + text1.length - this.Match_MaxBits);
1779
+ if (end_loc == -1 || start_loc >= end_loc) {
1780
+ // Can't find valid trailing context. Drop this patch.
1781
+ start_loc = -1;
1782
+ }
1783
+ }
1784
+ } else {
1785
+ start_loc = this.match_main(text, text1, expected_loc);
1786
+ }
1787
+ if (start_loc == -1) {
1788
+ // No match found. :(
1789
+ results[x] = false;
1790
+ // Subtract the delta for this failed patch from subsequent patches.
1791
+ delta -= patches[x].length2 - patches[x].length1;
1792
+ } else {
1793
+ // Found a match. :)
1794
+ results[x] = true;
1795
+ delta = start_loc - expected_loc;
1796
+ var text2;
1797
+ if (end_loc == -1) {
1798
+ text2 = text.substring(start_loc, start_loc + text1.length);
1799
+ } else {
1800
+ text2 = text.substring(start_loc, end_loc + this.Match_MaxBits);
1801
+ }
1802
+ if (text1 == text2) {
1803
+ // Perfect match, just shove the replacement text in.
1804
+ text = text.substring(0, start_loc) +
1805
+ this.diff_text2(patches[x].diffs) +
1806
+ text.substring(start_loc + text1.length);
1807
+ } else {
1808
+ // Imperfect match. Run a diff to get a framework of equivalent
1809
+ // indices.
1810
+ var diffs = this.diff_main(text1, text2, false);
1811
+ if (text1.length > this.Match_MaxBits &&
1812
+ this.diff_levenshtein(diffs) / text1.length >
1813
+ this.Patch_DeleteThreshold) {
1814
+ // The end points match, but the content is unacceptably bad.
1815
+ results[x] = false;
1816
+ } else {
1817
+ this.diff_cleanupSemanticLossless(diffs);
1818
+ var index1 = 0;
1819
+ var index2;
1820
+ for (var y = 0; y < patches[x].diffs.length; y++) {
1821
+ var mod = patches[x].diffs[y];
1822
+ if (mod[0] !== DIFF_EQUAL) {
1823
+ index2 = this.diff_xIndex(diffs, index1);
1824
+ }
1825
+ if (mod[0] === DIFF_INSERT) { // Insertion
1826
+ text = text.substring(0, start_loc + index2) + mod[1] +
1827
+ text.substring(start_loc + index2);
1828
+ } else if (mod[0] === DIFF_DELETE) { // Deletion
1829
+ text = text.substring(0, start_loc + index2) +
1830
+ text.substring(start_loc + this.diff_xIndex(diffs,
1831
+ index1 + mod[1].length));
1832
+ }
1833
+ if (mod[0] !== DIFF_DELETE) {
1834
+ index1 += mod[1].length;
1835
+ }
1836
+ }
1837
+ }
1838
+ }
1839
+ }
1840
+ }
1841
+ // Strip the padding off.
1842
+ text = text.substring(nullPadding.length, text.length - nullPadding.length);
1843
+ return [text, results];
1844
+ };
1845
+
1846
+
1847
+ /**
1848
+ * Add some padding on text start and end so that edges can match something.
1849
+ * Intended to be called only from within patch_apply.
1850
+ * @param {!Array.<!patch_obj>} patches Array of patch objects.
1851
+ * @return {string} The padding string added to each side.
1852
+ */
1853
+ diff_match_patch.prototype.patch_addPadding = function(patches) {
1854
+ var paddingLength = this.Patch_Margin;
1855
+ var nullPadding = '';
1856
+ for (var x = 1; x <= paddingLength; x++) {
1857
+ nullPadding += String.fromCharCode(x);
1858
+ }
1859
+
1860
+ // Bump all the patches forward.
1861
+ for (var x = 0; x < patches.length; x++) {
1862
+ patches[x].start1 += paddingLength;
1863
+ patches[x].start2 += paddingLength;
1864
+ }
1865
+
1866
+ // Add some padding on start of first diff.
1867
+ var patch = patches[0];
1868
+ var diffs = patch.diffs;
1869
+ if (diffs.length == 0 || diffs[0][0] != DIFF_EQUAL) {
1870
+ // Add nullPadding equality.
1871
+ diffs.unshift([DIFF_EQUAL, nullPadding]);
1872
+ patch.start1 -= paddingLength; // Should be 0.
1873
+ patch.start2 -= paddingLength; // Should be 0.
1874
+ patch.length1 += paddingLength;
1875
+ patch.length2 += paddingLength;
1876
+ } else if (paddingLength > diffs[0][1].length) {
1877
+ // Grow first equality.
1878
+ var extraLength = paddingLength - diffs[0][1].length;
1879
+ diffs[0][1] = nullPadding.substring(diffs[0][1].length) + diffs[0][1];
1880
+ patch.start1 -= extraLength;
1881
+ patch.start2 -= extraLength;
1882
+ patch.length1 += extraLength;
1883
+ patch.length2 += extraLength;
1884
+ }
1885
+
1886
+ // Add some padding on end of last diff.
1887
+ patch = patches[patches.length - 1];
1888
+ diffs = patch.diffs;
1889
+ if (diffs.length == 0 || diffs[diffs.length - 1][0] != DIFF_EQUAL) {
1890
+ // Add nullPadding equality.
1891
+ diffs.push([DIFF_EQUAL, nullPadding]);
1892
+ patch.length1 += paddingLength;
1893
+ patch.length2 += paddingLength;
1894
+ } else if (paddingLength > diffs[diffs.length - 1][1].length) {
1895
+ // Grow last equality.
1896
+ var extraLength = paddingLength - diffs[diffs.length - 1][1].length;
1897
+ diffs[diffs.length - 1][1] += nullPadding.substring(0, extraLength);
1898
+ patch.length1 += extraLength;
1899
+ patch.length2 += extraLength;
1900
+ }
1901
+
1902
+ return nullPadding;
1903
+ };
1904
+
1905
+
1906
+ /**
1907
+ * Look through the patches and break up any which are longer than the maximum
1908
+ * limit of the match algorithm.
1909
+ * Intended to be called only from within patch_apply.
1910
+ * @param {!Array.<!patch_obj>} patches Array of patch objects.
1911
+ */
1912
+ diff_match_patch.prototype.patch_splitMax = function(patches) {
1913
+ var patch_size = this.Match_MaxBits;
1914
+ for (var x = 0; x < patches.length; x++) {
1915
+ if (patches[x].length1 > patch_size) {
1916
+ var bigpatch = patches[x];
1917
+ // Remove the big old patch.
1918
+ patches.splice(x--, 1);
1919
+ var start1 = bigpatch.start1;
1920
+ var start2 = bigpatch.start2;
1921
+ var precontext = '';
1922
+ while (bigpatch.diffs.length !== 0) {
1923
+ // Create one of several smaller patches.
1924
+ var patch = new patch_obj();
1925
+ var empty = true;
1926
+ patch.start1 = start1 - precontext.length;
1927
+ patch.start2 = start2 - precontext.length;
1928
+ if (precontext !== '') {
1929
+ patch.length1 = patch.length2 = precontext.length;
1930
+ patch.diffs.push([DIFF_EQUAL, precontext]);
1931
+ }
1932
+ while (bigpatch.diffs.length !== 0 &&
1933
+ patch.length1 < patch_size - this.Patch_Margin) {
1934
+ var diff_type = bigpatch.diffs[0][0];
1935
+ var diff_text = bigpatch.diffs[0][1];
1936
+ if (diff_type === DIFF_INSERT) {
1937
+ // Insertions are harmless.
1938
+ patch.length2 += diff_text.length;
1939
+ start2 += diff_text.length;
1940
+ patch.diffs.push(bigpatch.diffs.shift());
1941
+ empty = false;
1942
+ } else if (diff_type === DIFF_DELETE && patch.diffs.length == 1 &&
1943
+ patch.diffs[0][0] == DIFF_EQUAL &&
1944
+ diff_text.length > 2 * patch_size) {
1945
+ // This is a large deletion. Let it pass in one chunk.
1946
+ patch.length1 += diff_text.length;
1947
+ start1 += diff_text.length;
1948
+ empty = false;
1949
+ patch.diffs.push([diff_type, diff_text]);
1950
+ bigpatch.diffs.shift();
1951
+ } else {
1952
+ // Deletion or equality. Only take as much as we can stomach.
1953
+ diff_text = diff_text.substring(0,
1954
+ patch_size - patch.length1 - this.Patch_Margin);
1955
+ patch.length1 += diff_text.length;
1956
+ start1 += diff_text.length;
1957
+ if (diff_type === DIFF_EQUAL) {
1958
+ patch.length2 += diff_text.length;
1959
+ start2 += diff_text.length;
1960
+ } else {
1961
+ empty = false;
1962
+ }
1963
+ patch.diffs.push([diff_type, diff_text]);
1964
+ if (diff_text == bigpatch.diffs[0][1]) {
1965
+ bigpatch.diffs.shift();
1966
+ } else {
1967
+ bigpatch.diffs[0][1] =
1968
+ bigpatch.diffs[0][1].substring(diff_text.length);
1969
+ }
1970
+ }
1971
+ }
1972
+ // Compute the head context for the next patch.
1973
+ precontext = this.diff_text2(patch.diffs);
1974
+ precontext =
1975
+ precontext.substring(precontext.length - this.Patch_Margin);
1976
+ // Append the end context for this patch.
1977
+ var postcontext = this.diff_text1(bigpatch.diffs)
1978
+ .substring(0, this.Patch_Margin);
1979
+ if (postcontext !== '') {
1980
+ patch.length1 += postcontext.length;
1981
+ patch.length2 += postcontext.length;
1982
+ if (patch.diffs.length !== 0 &&
1983
+ patch.diffs[patch.diffs.length - 1][0] === DIFF_EQUAL) {
1984
+ patch.diffs[patch.diffs.length - 1][1] += postcontext;
1985
+ } else {
1986
+ patch.diffs.push([DIFF_EQUAL, postcontext]);
1987
+ }
1988
+ }
1989
+ if (!empty) {
1990
+ patches.splice(++x, 0, patch);
1991
+ }
1992
+ }
1993
+ }
1994
+ }
1995
+ };
1996
+
1997
+
1998
+ /**
1999
+ * Take a list of patches and return a textual representation.
2000
+ * @param {!Array.<!patch_obj>} patches Array of patch objects.
2001
+ * @return {string} Text representation of patches.
2002
+ */
2003
+ diff_match_patch.prototype.patch_toText = function(patches) {
2004
+ var text = [];
2005
+ for (var x = 0; x < patches.length; x++) {
2006
+ text[x] = patches[x];
2007
+ }
2008
+ return text.join('');
2009
+ };
2010
+
2011
+
2012
+ /**
2013
+ * Parse a textual representation of patches and return a list of patch objects.
2014
+ * @param {string} textline Text representation of patches.
2015
+ * @return {!Array.<!patch_obj>} Array of patch objects.
2016
+ * @throws {!Error} If invalid input.
2017
+ */
2018
+ diff_match_patch.prototype.patch_fromText = function(textline) {
2019
+ var patches = [];
2020
+ if (!textline) {
2021
+ return patches;
2022
+ }
2023
+ var text = textline.split('\n');
2024
+ var textPointer = 0;
2025
+ var patchHeader = /^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;
2026
+ while (textPointer < text.length) {
2027
+ var m = text[textPointer].match(patchHeader);
2028
+ if (!m) {
2029
+ throw new Error('Invalid patch string: ' + text[textPointer]);
2030
+ }
2031
+ var patch = new patch_obj();
2032
+ patches.push(patch);
2033
+ patch.start1 = parseInt(m[1], 10);
2034
+ if (m[2] === '') {
2035
+ patch.start1--;
2036
+ patch.length1 = 1;
2037
+ } else if (m[2] == '0') {
2038
+ patch.length1 = 0;
2039
+ } else {
2040
+ patch.start1--;
2041
+ patch.length1 = parseInt(m[2], 10);
2042
+ }
2043
+
2044
+ patch.start2 = parseInt(m[3], 10);
2045
+ if (m[4] === '') {
2046
+ patch.start2--;
2047
+ patch.length2 = 1;
2048
+ } else if (m[4] == '0') {
2049
+ patch.length2 = 0;
2050
+ } else {
2051
+ patch.start2--;
2052
+ patch.length2 = parseInt(m[4], 10);
2053
+ }
2054
+ textPointer++;
2055
+
2056
+ while (textPointer < text.length) {
2057
+ var sign = text[textPointer].charAt(0);
2058
+ try {
2059
+ var line = decodeURI(text[textPointer].substring(1));
2060
+ } catch (ex) {
2061
+ // Malformed URI sequence.
2062
+ throw new Error('Illegal escape in patch_fromText: ' + line);
2063
+ }
2064
+ if (sign == '-') {
2065
+ // Deletion.
2066
+ patch.diffs.push([DIFF_DELETE, line]);
2067
+ } else if (sign == '+') {
2068
+ // Insertion.
2069
+ patch.diffs.push([DIFF_INSERT, line]);
2070
+ } else if (sign == ' ') {
2071
+ // Minor equality.
2072
+ patch.diffs.push([DIFF_EQUAL, line]);
2073
+ } else if (sign == '@') {
2074
+ // Start of next patch.
2075
+ break;
2076
+ } else if (sign === '') {
2077
+ // Blank line? Whatever.
2078
+ } else {
2079
+ // WTF?
2080
+ throw new Error('Invalid patch mode "' + sign + '" in: ' + line);
2081
+ }
2082
+ textPointer++;
2083
+ }
2084
+ }
2085
+ return patches;
2086
+ };
2087
+
2088
+
2089
+ /**
2090
+ * Class representing one patch operation.
2091
+ * @constructor
2092
+ */
2093
+ function patch_obj() {
2094
+ /** @type {!Array.<!diff_match_patch.Diff>} */
2095
+ this.diffs = [];
2096
+ /** @type {?number} */
2097
+ this.start1 = null;
2098
+ /** @type {?number} */
2099
+ this.start2 = null;
2100
+ /** @type {number} */
2101
+ this.length1 = 0;
2102
+ /** @type {number} */
2103
+ this.length2 = 0;
2104
+ }
2105
+
2106
+
2107
+ /**
2108
+ * Emmulate GNU diff's format.
2109
+ * Header: @@ -382,8 +481,9 @@
2110
+ * Indicies are printed as 1-based, not 0-based.
2111
+ * @return {string} The GNU diff string.
2112
+ */
2113
+ patch_obj.prototype.toString = function() {
2114
+ var coords1, coords2;
2115
+ if (this.length1 === 0) {
2116
+ coords1 = this.start1 + ',0';
2117
+ } else if (this.length1 == 1) {
2118
+ coords1 = this.start1 + 1;
2119
+ } else {
2120
+ coords1 = (this.start1 + 1) + ',' + this.length1;
2121
+ }
2122
+ if (this.length2 === 0) {
2123
+ coords2 = this.start2 + ',0';
2124
+ } else if (this.length2 == 1) {
2125
+ coords2 = this.start2 + 1;
2126
+ } else {
2127
+ coords2 = (this.start2 + 1) + ',' + this.length2;
2128
+ }
2129
+ var text = ['@@ -' + coords1 + ' +' + coords2 + ' @@\n'];
2130
+ var op;
2131
+ // Escape the body of the patch with %xx notation.
2132
+ for (var x = 0; x < this.diffs.length; x++) {
2133
+ switch (this.diffs[x][0]) {
2134
+ case DIFF_INSERT:
2135
+ op = '+';
2136
+ break;
2137
+ case DIFF_DELETE:
2138
+ op = '-';
2139
+ break;
2140
+ case DIFF_EQUAL:
2141
+ op = ' ';
2142
+ break;
2143
+ }
2144
+ text[x + 1] = op + encodeURI(this.diffs[x][1]) + '\n';
2145
+ }
2146
+ return text.join('').replace(/%20/g, ' ');
2147
+ };
2148
+
2149
+
2150
+ // Export these global variables so that they survive Google's JS compiler.
2151
+ window['diff_match_patch'] = diff_match_patch;
2152
+ window['patch_obj'] = patch_obj;
2153
+ window['DIFF_DELETE'] = DIFF_DELETE;
2154
+ window['DIFF_INSERT'] = DIFF_INSERT;
2155
+ window['DIFF_EQUAL'] = DIFF_EQUAL;