glebtv-ckeditor 4.5.10.3 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/ckeditor/config.js.erb +1 -1
- data/lib/ckeditor.rb +1 -0
- data/lib/ckeditor/version.rb +2 -2
- data/lib/generators/ckeditor/templates/active_record/carrierwave/migration.rb +1 -1
- data/lib/generators/ckeditor/templates/active_record/dragonfly/migration.rb +1 -1
- data/lib/generators/ckeditor/templates/active_record/paperclip/migration.rb +1 -1
- data/lib/generators/ckeditor/templates/active_record/refile/migration.rb +1 -1
- data/vendor/assets/javascripts/ckeditor/LICENSE.md +2 -2
- data/vendor/assets/javascripts/ckeditor/adapters/jquery.js +1 -1
- data/vendor/assets/javascripts/ckeditor/build-config.js +26 -26
- data/vendor/assets/javascripts/ckeditor/ckeditor.js +605 -576
- data/vendor/assets/javascripts/ckeditor/lang/en.js +2 -2
- data/vendor/assets/javascripts/ckeditor/lang/ru.js +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/CKCss/css/styles.css +9 -0
- data/vendor/assets/javascripts/ckeditor/plugins/CKCss/dialogs/ckcss.js +2 -1
- data/vendor/assets/javascripts/ckeditor/plugins/CKCss/plugin.js +3 -1
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/a11yhelp.js +6 -6
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/en.js +3 -4
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/ru.js +4 -4
- data/vendor/assets/javascripts/ckeditor/plugins/about/dialogs/about.js +4 -3
- data/vendor/assets/javascripts/ckeditor/plugins/clipboard/dialogs/paste.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/LICENSE.md +21 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/css/codemirror.ckeditor.css +183 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/css/codemirror.css +341 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/css/codemirror.min.css +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/comment/comment.js +206 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/comment/continuecomment.js +85 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/dialog/dialog.css +32 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/dialog/dialog.js +157 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/edit/closebrackets.js +202 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/edit/closetag.js +169 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/edit/continuelist.js +51 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/edit/matchbrackets.js +122 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/edit/matchtags.js +66 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/edit/trailingspace.js +27 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/brace-fold.js +105 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/comment-fold.js +59 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/foldcode.js +150 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/foldgutter.css +20 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/foldgutter.js +146 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/indent-fold.js +44 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/markdown-fold.js +49 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/xml-fold.js +182 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/format/autoFormatAll.js +43 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/format/formatting.js +226 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/hint/anyword-hint.js +41 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/hint/css-hint.js +60 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/hint/html-hint.js +348 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/hint/javascript-hint.js +155 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/hint/show-hint.css +36 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/hint/show-hint.js +438 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/hint/sql-hint.js +271 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/hint/xml-hint.js +110 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/mode/loadmode.js +64 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/mode/multiplex.js +123 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/mode/multiplex_test.js +33 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/mode/overlay.js +85 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/mode/simple.js +213 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/search/jump-to-line.js +49 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/search/match-highlighter.js +165 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/search/matchesonscrollbar.css +8 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/search/matchesonscrollbar.js +97 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/search/search.js +252 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/search/searchcursor.js +189 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/selection/active-line.js +74 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/selection/mark-selection.js +118 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/selection/selection-pointer.js +98 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/beautify-html.js +952 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/beautify.js +2087 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.addons.min.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.addons.search.min.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.js +9109 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.min.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.mode.htmlmixed.min.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.mode.javascript.min.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/codemirror.mode.php.min.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/bbcode/bbcode.js +137 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/bbcode/index.html +73 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/bbcodemixed/bbcodemixed.js +161 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/bbcodemixed/index.html +128 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/clike/clike.js +785 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/clike/index.html +360 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/clike/scala.html +767 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/clike/test.js +55 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/css/css.js +825 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/css/gss.html +103 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/css/gss_test.js +17 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/css/index.html +75 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/css/less.html +152 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/css/less_test.js +54 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/css/scss.html +157 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/css/scss_test.js +110 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/css/test.js +200 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/htmlembedded/htmlembedded.js +28 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/htmlembedded/index.html +60 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/htmlmixed/htmlmixed.js +152 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/htmlmixed/index.html +89 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/javascript/index.html +114 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/javascript/javascript.js +784 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/javascript/json-ld.html +72 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/javascript/test.js +247 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/javascript/typescript.html +61 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/php/index.html +64 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/php/php.js +234 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/php/test.js +154 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/xml/index.html +61 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/xml/test.js +51 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/mode/xml/xml.js +394 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/plugin.js +30 -24
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/dracula.css +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/duotone-dark.css +35 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/duotone-light.css +36 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/panda-syntax.css +85 -0
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/pastel-on-dark.css +0 -1
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/theme/solarized.css +21 -15
- data/vendor/assets/javascripts/ckeditor/plugins/colordialog/dialogs/colordialog.css +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/colordialog/dialogs/colordialog.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/dialog/dialogDefinition.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/find/dialogs/find.js +9 -9
- data/vendor/assets/javascripts/ckeditor/plugins/flash/dialogs/flash.js +12 -12
- data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/button.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/checkbox.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/form.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/hiddenfield.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/radio.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/select.js +11 -11
- data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/textarea.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/forms/dialogs/textfield.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/icons.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/icons_hidpi.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/iframe/dialogs/iframe.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/iframedialog/plugin.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/image/dialogs/image.js +28 -28
- data/vendor/assets/javascripts/ckeditor/plugins/lineheight/LICENSE +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/lineheight/README.md +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/lineheight/lang/LANG.js +3 -0
- data/vendor/assets/javascripts/ckeditor/plugins/lineheight/lang/en.js +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/lineheight/lang/ru.js +3 -3
- data/vendor/assets/javascripts/ckeditor/plugins/lineheight/plugin.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/lineheight/readme.txt +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/link/dialogs/anchor.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/link/dialogs/link.js +25 -23
- data/vendor/assets/javascripts/ckeditor/plugins/link/images/anchor.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/link/images/hidpi/anchor.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/liststyle/dialogs/liststyle.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/notification/lang/en.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/notification/lang/ru.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/notification/plugin.js +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/pastefromword/filter/default.js +40 -29
- data/vendor/assets/javascripts/ckeditor/plugins/scayt/dialogs/options.js +19 -19
- data/vendor/assets/javascripts/ckeditor/plugins/scayt/skins/moono-lisa/scayt.css +20 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/dialogs/smiley.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/en.js +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/ru.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/specialchar.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/stylesheetparser/plugin.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/stylesheetparser/samples/assets/sample.css +70 -0
- data/vendor/assets/javascripts/ckeditor/plugins/stylesheetparser/samples/stylesheetparser.html +85 -0
- data/vendor/assets/javascripts/ckeditor/plugins/table/dialogs/table.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/tabletools/dialogs/tableCell.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/templates/dialogs/templates.css +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/templates/dialogs/templates.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/templates/templates/default.js +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/templates/templates/images/template1.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/templates/templates/images/template2.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/templates/templates/images/template3.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/wordcount/css/wordcount.css +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/wordcount/lang/en.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/wordcount/lang/ru.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/wordcount/plugin.js +60 -13
- data/vendor/assets/javascripts/ckeditor/plugins/wordcount/samples/wordcount.html +61 -0
- data/vendor/assets/javascripts/ckeditor/plugins/wordcount/samples/wordcountWithMaxCount.html +110 -0
- data/vendor/assets/javascripts/ckeditor/plugins/wsc/dialogs/wsc.js +9 -9
- data/vendor/assets/javascripts/ckeditor/plugins/wsc/skins/moono-lisa/wsc.css +43 -0
- data/vendor/assets/javascripts/ckeditor/plugins/youtube/LICENSE.md +15 -0
- data/vendor/assets/javascripts/ckeditor/plugins/youtube/images/icon.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/youtube/lang/en.js +3 -1
- data/vendor/assets/javascripts/ckeditor/plugins/youtube/lang/ru.js +1 -0
- data/vendor/assets/javascripts/ckeditor/plugins/youtube/plugin.js +448 -388
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dev/icons16.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dev/icons16.svg +175 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dev/icons32.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dev/icons32.svg +167 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dev/locations.json +145 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dialog.css +5 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dialog_ie.css +5 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dialog_ie8.css +5 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/dialog_iequirks.css +5 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/editor.css +5 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/editor_gecko.css +5 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/editor_ie.css +5 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/editor_ie8.css +5 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/editor_iequirks.css +5 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/images/arrow.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/images/close.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/images/hidpi/close.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/images/hidpi/lock-open.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/images/hidpi/lock.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/images/hidpi/refresh.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/images/lock-open.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/images/lock.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/images/refresh.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/images/spinner.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/readme.md +46 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono-lisa/skin.js +7 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono/dialog.css +1 -1
- data/vendor/assets/javascripts/ckeditor/skins/moono/dialog_ie.css +1 -1
- data/vendor/assets/javascripts/ckeditor/skins/moono/dialog_ie7.css +1 -1
- data/vendor/assets/javascripts/ckeditor/skins/moono/dialog_ie8.css +1 -1
- data/vendor/assets/javascripts/ckeditor/skins/moono/dialog_iequirks.css +1 -1
- data/vendor/assets/javascripts/ckeditor/skins/moono/editor.css +2 -2
- data/vendor/assets/javascripts/ckeditor/skins/moono/editor_gecko.css +2 -2
- data/vendor/assets/javascripts/ckeditor/skins/moono/editor_ie.css +2 -2
- data/vendor/assets/javascripts/ckeditor/skins/moono/editor_ie7.css +2 -2
- data/vendor/assets/javascripts/ckeditor/skins/moono/editor_ie8.css +2 -2
- data/vendor/assets/javascripts/ckeditor/skins/moono/editor_iequirks.css +2 -2
- data/vendor/assets/javascripts/ckeditor/skins/moono/icons.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono/icons_hidpi.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono/images/anchor.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono/images/close.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono/images/hidpi/anchor.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono/images/hidpi/close.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono/images/hidpi/lock-open.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono/images/hidpi/lock.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono/images/hidpi/refresh.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono/images/lock-open.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono/images/lock.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono/images/refresh.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono/readme.md +3 -3
- data/vendor/assets/javascripts/ckeditor/styles.js +42 -16
- metadata +161 -105
- data/app/assets/javascripts/ckeditor/config_orig.js +0 -58
- data/vendor/assets/javascripts/ckeditor/README.md +0 -39
- data/vendor/assets/javascripts/ckeditor/config.js +0 -10
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/af.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ar.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/bg.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/bn.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/bs.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ca.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/cs.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/cy.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/da.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/de.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/el.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/en-au.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/en-ca.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/en-gb.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/eo.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/es.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/et.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/eu.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/fa.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/fi.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/fo.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/fr-ca.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/fr.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/gl.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/gu.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/he.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/hi.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/hr.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/hu.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/is.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/it.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ja.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ka.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/km.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ko.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ku.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/lt.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/lv.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/mk.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/mn.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ms.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/nb.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/nl.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/no.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/pl.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/pt-br.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/pt.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ro.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/sk.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/sl.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/sr-latn.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/sr.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/sv.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/th.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/tr.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/ug.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/uk.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/vi.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/zh-cn.js +0 -12
- data/vendor/assets/javascripts/ckeditor/plugins/codemirror/lang/zh.js +0 -12
@@ -0,0 +1,74 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
// Because sometimes you need to style the cursor's line.
|
5
|
+
//
|
6
|
+
// Adds an option 'styleActiveLine' which, when enabled, gives the
|
7
|
+
// active line's wrapping <div> the CSS class "CodeMirror-activeline",
|
8
|
+
// and gives its background <div> the class "CodeMirror-activeline-background".
|
9
|
+
|
10
|
+
(function(mod) {
|
11
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
12
|
+
mod(require("../../lib/codemirror"));
|
13
|
+
else if (typeof define == "function" && define.amd) // AMD
|
14
|
+
define(["../../lib/codemirror"], mod);
|
15
|
+
else // Plain browser env
|
16
|
+
mod(CodeMirror);
|
17
|
+
})(function(CodeMirror) {
|
18
|
+
"use strict";
|
19
|
+
var WRAP_CLASS = "CodeMirror-activeline";
|
20
|
+
var BACK_CLASS = "CodeMirror-activeline-background";
|
21
|
+
var GUTT_CLASS = "CodeMirror-activeline-gutter";
|
22
|
+
|
23
|
+
CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
|
24
|
+
var prev = old && old != CodeMirror.Init;
|
25
|
+
if (val && !prev) {
|
26
|
+
cm.state.activeLines = [];
|
27
|
+
updateActiveLines(cm, cm.listSelections());
|
28
|
+
cm.on("beforeSelectionChange", selectionChange);
|
29
|
+
} else if (!val && prev) {
|
30
|
+
cm.off("beforeSelectionChange", selectionChange);
|
31
|
+
clearActiveLines(cm);
|
32
|
+
delete cm.state.activeLines;
|
33
|
+
}
|
34
|
+
});
|
35
|
+
|
36
|
+
function clearActiveLines(cm) {
|
37
|
+
for (var i = 0; i < cm.state.activeLines.length; i++) {
|
38
|
+
cm.removeLineClass(cm.state.activeLines[i], "wrap", WRAP_CLASS);
|
39
|
+
cm.removeLineClass(cm.state.activeLines[i], "background", BACK_CLASS);
|
40
|
+
cm.removeLineClass(cm.state.activeLines[i], "gutter", GUTT_CLASS);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
function sameArray(a, b) {
|
45
|
+
if (a.length != b.length) return false;
|
46
|
+
for (var i = 0; i < a.length; i++)
|
47
|
+
if (a[i] != b[i]) return false;
|
48
|
+
return true;
|
49
|
+
}
|
50
|
+
|
51
|
+
function updateActiveLines(cm, ranges) {
|
52
|
+
var active = [];
|
53
|
+
for (var i = 0; i < ranges.length; i++) {
|
54
|
+
var range = ranges[i];
|
55
|
+
if (!range.empty()) continue;
|
56
|
+
var line = cm.getLineHandleVisualStart(range.head.line);
|
57
|
+
if (active[active.length - 1] != line) active.push(line);
|
58
|
+
}
|
59
|
+
if (sameArray(cm.state.activeLines, active)) return;
|
60
|
+
cm.operation(function() {
|
61
|
+
clearActiveLines(cm);
|
62
|
+
for (var i = 0; i < active.length; i++) {
|
63
|
+
cm.addLineClass(active[i], "wrap", WRAP_CLASS);
|
64
|
+
cm.addLineClass(active[i], "background", BACK_CLASS);
|
65
|
+
cm.addLineClass(active[i], "gutter", GUTT_CLASS);
|
66
|
+
}
|
67
|
+
cm.state.activeLines = active;
|
68
|
+
});
|
69
|
+
}
|
70
|
+
|
71
|
+
function selectionChange(cm, sel) {
|
72
|
+
updateActiveLines(cm, sel.ranges);
|
73
|
+
}
|
74
|
+
});
|
data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/selection/mark-selection.js
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
// Because sometimes you need to mark the selected *text*.
|
5
|
+
//
|
6
|
+
// Adds an option 'styleSelectedText' which, when enabled, gives
|
7
|
+
// selected text the CSS class given as option value, or
|
8
|
+
// "CodeMirror-selectedtext" when the value is not a string.
|
9
|
+
|
10
|
+
(function(mod) {
|
11
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
12
|
+
mod(require("../../lib/codemirror"));
|
13
|
+
else if (typeof define == "function" && define.amd) // AMD
|
14
|
+
define(["../../lib/codemirror"], mod);
|
15
|
+
else // Plain browser env
|
16
|
+
mod(CodeMirror);
|
17
|
+
})(function(CodeMirror) {
|
18
|
+
"use strict";
|
19
|
+
|
20
|
+
CodeMirror.defineOption("styleSelectedText", false, function(cm, val, old) {
|
21
|
+
var prev = old && old != CodeMirror.Init;
|
22
|
+
if (val && !prev) {
|
23
|
+
cm.state.markedSelection = [];
|
24
|
+
cm.state.markedSelectionStyle = typeof val == "string" ? val : "CodeMirror-selectedtext";
|
25
|
+
reset(cm);
|
26
|
+
cm.on("cursorActivity", onCursorActivity);
|
27
|
+
cm.on("change", onChange);
|
28
|
+
} else if (!val && prev) {
|
29
|
+
cm.off("cursorActivity", onCursorActivity);
|
30
|
+
cm.off("change", onChange);
|
31
|
+
clear(cm);
|
32
|
+
cm.state.markedSelection = cm.state.markedSelectionStyle = null;
|
33
|
+
}
|
34
|
+
});
|
35
|
+
|
36
|
+
function onCursorActivity(cm) {
|
37
|
+
cm.operation(function() { update(cm); });
|
38
|
+
}
|
39
|
+
|
40
|
+
function onChange(cm) {
|
41
|
+
if (cm.state.markedSelection.length)
|
42
|
+
cm.operation(function() { clear(cm); });
|
43
|
+
}
|
44
|
+
|
45
|
+
var CHUNK_SIZE = 8;
|
46
|
+
var Pos = CodeMirror.Pos;
|
47
|
+
var cmp = CodeMirror.cmpPos;
|
48
|
+
|
49
|
+
function coverRange(cm, from, to, addAt) {
|
50
|
+
if (cmp(from, to) == 0) return;
|
51
|
+
var array = cm.state.markedSelection;
|
52
|
+
var cls = cm.state.markedSelectionStyle;
|
53
|
+
for (var line = from.line;;) {
|
54
|
+
var start = line == from.line ? from : Pos(line, 0);
|
55
|
+
var endLine = line + CHUNK_SIZE, atEnd = endLine >= to.line;
|
56
|
+
var end = atEnd ? to : Pos(endLine, 0);
|
57
|
+
var mark = cm.markText(start, end, {className: cls});
|
58
|
+
if (addAt == null) array.push(mark);
|
59
|
+
else array.splice(addAt++, 0, mark);
|
60
|
+
if (atEnd) break;
|
61
|
+
line = endLine;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
function clear(cm) {
|
66
|
+
var array = cm.state.markedSelection;
|
67
|
+
for (var i = 0; i < array.length; ++i) array[i].clear();
|
68
|
+
array.length = 0;
|
69
|
+
}
|
70
|
+
|
71
|
+
function reset(cm) {
|
72
|
+
clear(cm);
|
73
|
+
var ranges = cm.listSelections();
|
74
|
+
for (var i = 0; i < ranges.length; i++)
|
75
|
+
coverRange(cm, ranges[i].from(), ranges[i].to());
|
76
|
+
}
|
77
|
+
|
78
|
+
function update(cm) {
|
79
|
+
if (!cm.somethingSelected()) return clear(cm);
|
80
|
+
if (cm.listSelections().length > 1) return reset(cm);
|
81
|
+
|
82
|
+
var from = cm.getCursor("start"), to = cm.getCursor("end");
|
83
|
+
|
84
|
+
var array = cm.state.markedSelection;
|
85
|
+
if (!array.length) return coverRange(cm, from, to);
|
86
|
+
|
87
|
+
var coverStart = array[0].find(), coverEnd = array[array.length - 1].find();
|
88
|
+
if (!coverStart || !coverEnd || to.line - from.line < CHUNK_SIZE ||
|
89
|
+
cmp(from, coverEnd.to) >= 0 || cmp(to, coverStart.from) <= 0)
|
90
|
+
return reset(cm);
|
91
|
+
|
92
|
+
while (cmp(from, coverStart.from) > 0) {
|
93
|
+
array.shift().clear();
|
94
|
+
coverStart = array[0].find();
|
95
|
+
}
|
96
|
+
if (cmp(from, coverStart.from) < 0) {
|
97
|
+
if (coverStart.to.line - from.line < CHUNK_SIZE) {
|
98
|
+
array.shift().clear();
|
99
|
+
coverRange(cm, from, coverStart.to, 0);
|
100
|
+
} else {
|
101
|
+
coverRange(cm, from, coverStart.from, 0);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
while (cmp(to, coverEnd.to) < 0) {
|
106
|
+
array.pop().clear();
|
107
|
+
coverEnd = array[array.length - 1].find();
|
108
|
+
}
|
109
|
+
if (cmp(to, coverEnd.to) > 0) {
|
110
|
+
if (to.line - coverEnd.from.line < CHUNK_SIZE) {
|
111
|
+
array.pop().clear();
|
112
|
+
coverRange(cm, coverEnd.from, to);
|
113
|
+
} else {
|
114
|
+
coverRange(cm, coverEnd.to, to);
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
118
|
+
});
|
data/vendor/assets/javascripts/ckeditor/plugins/codemirror/js/addon/selection/selection-pointer.js
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
(function(mod) {
|
5
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6
|
+
mod(require("../../lib/codemirror"));
|
7
|
+
else if (typeof define == "function" && define.amd) // AMD
|
8
|
+
define(["../../lib/codemirror"], mod);
|
9
|
+
else // Plain browser env
|
10
|
+
mod(CodeMirror);
|
11
|
+
})(function(CodeMirror) {
|
12
|
+
"use strict";
|
13
|
+
|
14
|
+
CodeMirror.defineOption("selectionPointer", false, function(cm, val) {
|
15
|
+
var data = cm.state.selectionPointer;
|
16
|
+
if (data) {
|
17
|
+
CodeMirror.off(cm.getWrapperElement(), "mousemove", data.mousemove);
|
18
|
+
CodeMirror.off(cm.getWrapperElement(), "mouseout", data.mouseout);
|
19
|
+
CodeMirror.off(window, "scroll", data.windowScroll);
|
20
|
+
cm.off("cursorActivity", reset);
|
21
|
+
cm.off("scroll", reset);
|
22
|
+
cm.state.selectionPointer = null;
|
23
|
+
cm.display.lineDiv.style.cursor = "";
|
24
|
+
}
|
25
|
+
if (val) {
|
26
|
+
data = cm.state.selectionPointer = {
|
27
|
+
value: typeof val == "string" ? val : "default",
|
28
|
+
mousemove: function(event) { mousemove(cm, event); },
|
29
|
+
mouseout: function(event) { mouseout(cm, event); },
|
30
|
+
windowScroll: function() { reset(cm); },
|
31
|
+
rects: null,
|
32
|
+
mouseX: null, mouseY: null,
|
33
|
+
willUpdate: false
|
34
|
+
};
|
35
|
+
CodeMirror.on(cm.getWrapperElement(), "mousemove", data.mousemove);
|
36
|
+
CodeMirror.on(cm.getWrapperElement(), "mouseout", data.mouseout);
|
37
|
+
CodeMirror.on(window, "scroll", data.windowScroll);
|
38
|
+
cm.on("cursorActivity", reset);
|
39
|
+
cm.on("scroll", reset);
|
40
|
+
}
|
41
|
+
});
|
42
|
+
|
43
|
+
function mousemove(cm, event) {
|
44
|
+
var data = cm.state.selectionPointer;
|
45
|
+
if (event.buttons == null ? event.which : event.buttons) {
|
46
|
+
data.mouseX = data.mouseY = null;
|
47
|
+
} else {
|
48
|
+
data.mouseX = event.clientX;
|
49
|
+
data.mouseY = event.clientY;
|
50
|
+
}
|
51
|
+
scheduleUpdate(cm);
|
52
|
+
}
|
53
|
+
|
54
|
+
function mouseout(cm, event) {
|
55
|
+
if (!cm.getWrapperElement().contains(event.relatedTarget)) {
|
56
|
+
var data = cm.state.selectionPointer;
|
57
|
+
data.mouseX = data.mouseY = null;
|
58
|
+
scheduleUpdate(cm);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
function reset(cm) {
|
63
|
+
cm.state.selectionPointer.rects = null;
|
64
|
+
scheduleUpdate(cm);
|
65
|
+
}
|
66
|
+
|
67
|
+
function scheduleUpdate(cm) {
|
68
|
+
if (!cm.state.selectionPointer.willUpdate) {
|
69
|
+
cm.state.selectionPointer.willUpdate = true;
|
70
|
+
setTimeout(function() {
|
71
|
+
update(cm);
|
72
|
+
cm.state.selectionPointer.willUpdate = false;
|
73
|
+
}, 50);
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
function update(cm) {
|
78
|
+
var data = cm.state.selectionPointer;
|
79
|
+
if (!data) return;
|
80
|
+
if (data.rects == null && data.mouseX != null) {
|
81
|
+
data.rects = [];
|
82
|
+
if (cm.somethingSelected()) {
|
83
|
+
for (var sel = cm.display.selectionDiv.firstChild; sel; sel = sel.nextSibling)
|
84
|
+
data.rects.push(sel.getBoundingClientRect());
|
85
|
+
}
|
86
|
+
}
|
87
|
+
var inside = false;
|
88
|
+
if (data.mouseX != null) for (var i = 0; i < data.rects.length; i++) {
|
89
|
+
var rect = data.rects[i];
|
90
|
+
if (rect.left <= data.mouseX && rect.right >= data.mouseX &&
|
91
|
+
rect.top <= data.mouseY && rect.bottom >= data.mouseY)
|
92
|
+
inside = true;
|
93
|
+
}
|
94
|
+
var cursor = inside ? data.value : "";
|
95
|
+
if (cm.display.lineDiv.style.cursor != cursor)
|
96
|
+
cm.display.lineDiv.style.cursor = cursor;
|
97
|
+
}
|
98
|
+
});
|
@@ -0,0 +1,952 @@
|
|
1
|
+
/*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */
|
2
|
+
/*
|
3
|
+
|
4
|
+
The MIT License (MIT)
|
5
|
+
|
6
|
+
Copyright (c) 2007-2013 Einar Lielmanis and contributors.
|
7
|
+
|
8
|
+
Permission is hereby granted, free of charge, to any person
|
9
|
+
obtaining a copy of this software and associated documentation files
|
10
|
+
(the "Software"), to deal in the Software without restriction,
|
11
|
+
including without limitation the rights to use, copy, modify, merge,
|
12
|
+
publish, distribute, sublicense, and/or sell copies of the Software,
|
13
|
+
and to permit persons to whom the Software is furnished to do so,
|
14
|
+
subject to the following conditions:
|
15
|
+
|
16
|
+
The above copyright notice and this permission notice shall be
|
17
|
+
included in all copies or substantial portions of the Software.
|
18
|
+
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
20
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
22
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
23
|
+
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
24
|
+
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
25
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
26
|
+
SOFTWARE.
|
27
|
+
|
28
|
+
|
29
|
+
Style HTML
|
30
|
+
---------------
|
31
|
+
|
32
|
+
Written by Nochum Sossonko, (nsossonko@hotmail.com)
|
33
|
+
|
34
|
+
Based on code initially developed by: Einar Lielmanis, <einar@jsbeautifier.org>
|
35
|
+
http://jsbeautifier.org/
|
36
|
+
|
37
|
+
Usage:
|
38
|
+
style_html(html_source);
|
39
|
+
|
40
|
+
style_html(html_source, options);
|
41
|
+
|
42
|
+
The options are:
|
43
|
+
indent_inner_html (default false) — indent <head> and <body> sections,
|
44
|
+
indent_size (default 4) — indentation size,
|
45
|
+
indent_char (default space) — character to indent with,
|
46
|
+
wrap_line_length (default 250) - maximum amount of characters per line (0 = disable)
|
47
|
+
brace_style (default "collapse") - "collapse" | "expand" | "end-expand" | "none"
|
48
|
+
put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line, or attempt to keep them where they are.
|
49
|
+
unformatted (defaults to inline tags) - list of tags, that shouldn't be reformatted
|
50
|
+
indent_scripts (default normal) - "keep"|"separate"|"normal"
|
51
|
+
preserve_newlines (default true) - whether existing line breaks before elements should be preserved
|
52
|
+
Only works before elements, not inside tags or for text.
|
53
|
+
max_preserve_newlines (default unlimited) - maximum number of line breaks to be preserved in one chunk
|
54
|
+
indent_handlebars (default false) - format and indent {{#foo}} and {{/foo}}
|
55
|
+
end_with_newline (false) - end with a newline
|
56
|
+
extra_liners (default [head,body,/html]) -List of tags that should have an extra newline before them.
|
57
|
+
|
58
|
+
e.g.
|
59
|
+
|
60
|
+
style_html(html_source, {
|
61
|
+
'indent_inner_html': false,
|
62
|
+
'indent_size': 2,
|
63
|
+
'indent_char': ' ',
|
64
|
+
'wrap_line_length': 78,
|
65
|
+
'brace_style': 'expand',
|
66
|
+
'unformatted': ['a', 'sub', 'sup', 'b', 'i', 'u'],
|
67
|
+
'preserve_newlines': true,
|
68
|
+
'max_preserve_newlines': 5,
|
69
|
+
'indent_handlebars': false,
|
70
|
+
'extra_liners': ['/html']
|
71
|
+
});
|
72
|
+
*/
|
73
|
+
|
74
|
+
(function() {
|
75
|
+
|
76
|
+
function trim(s) {
|
77
|
+
return s.replace(/^\s+|\s+$/g, '');
|
78
|
+
}
|
79
|
+
|
80
|
+
function ltrim(s) {
|
81
|
+
return s.replace(/^\s+/g, '');
|
82
|
+
}
|
83
|
+
|
84
|
+
function rtrim(s) {
|
85
|
+
return s.replace(/\s+$/g,'');
|
86
|
+
}
|
87
|
+
|
88
|
+
function style_html(html_source, options, js_beautify, css_beautify) {
|
89
|
+
//Wrapper function to invoke all the necessary constructors and deal with the output.
|
90
|
+
|
91
|
+
var multi_parser,
|
92
|
+
indent_inner_html,
|
93
|
+
indent_size,
|
94
|
+
indent_character,
|
95
|
+
wrap_line_length,
|
96
|
+
brace_style,
|
97
|
+
unformatted,
|
98
|
+
preserve_newlines,
|
99
|
+
max_preserve_newlines,
|
100
|
+
indent_handlebars,
|
101
|
+
wrap_attributes,
|
102
|
+
wrap_attributes_indent_size,
|
103
|
+
end_with_newline,
|
104
|
+
extra_liners,
|
105
|
+
eol;
|
106
|
+
|
107
|
+
options = options || {};
|
108
|
+
|
109
|
+
// backwards compatibility to 1.3.4
|
110
|
+
if ((options.wrap_line_length === undefined || parseInt(options.wrap_line_length, 10) === 0) &&
|
111
|
+
(options.max_char !== undefined && parseInt(options.max_char, 10) !== 0)) {
|
112
|
+
options.wrap_line_length = options.max_char;
|
113
|
+
}
|
114
|
+
|
115
|
+
indent_inner_html = (options.indent_inner_html === undefined) ? false : options.indent_inner_html;
|
116
|
+
indent_size = (options.indent_size === undefined) ? 4 : parseInt(options.indent_size, 10);
|
117
|
+
indent_character = (options.indent_char === undefined) ? ' ' : options.indent_char;
|
118
|
+
brace_style = (options.brace_style === undefined) ? 'collapse' : options.brace_style;
|
119
|
+
wrap_line_length = parseInt(options.wrap_line_length, 10) === 0 ? 32786 : parseInt(options.wrap_line_length || 250, 10);
|
120
|
+
unformatted = options.unformatted || ['a', 'span', 'img', 'bdo', 'em', 'strong', 'dfn', 'code', 'samp', 'kbd',
|
121
|
+
'var', 'cite', 'abbr', 'acronym', 'q', 'sub', 'sup', 'tt', 'i', 'b', 'big', 'small', 'u', 's', 'strike',
|
122
|
+
'font', 'ins', 'del', 'pre', 'address', 'dt', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
123
|
+
preserve_newlines = (options.preserve_newlines === undefined) ? true : options.preserve_newlines;
|
124
|
+
max_preserve_newlines = preserve_newlines ?
|
125
|
+
(isNaN(parseInt(options.max_preserve_newlines, 10)) ? 32786 : parseInt(options.max_preserve_newlines, 10))
|
126
|
+
: 0;
|
127
|
+
indent_handlebars = (options.indent_handlebars === undefined) ? false : options.indent_handlebars;
|
128
|
+
wrap_attributes = (options.wrap_attributes === undefined) ? 'auto' : options.wrap_attributes;
|
129
|
+
wrap_attributes_indent_size = (options.wrap_attributes_indent_size === undefined) ? indent_size : parseInt(options.wrap_attributes_indent_size, 10) || indent_size;
|
130
|
+
end_with_newline = (options.end_with_newline === undefined) ? false : options.end_with_newline;
|
131
|
+
extra_liners = (typeof options.extra_liners == 'object') && options.extra_liners ?
|
132
|
+
options.extra_liners.concat() : (typeof options.extra_liners === 'string') ?
|
133
|
+
options.extra_liners.split(',') : 'head,body,/html'.split(',');
|
134
|
+
eol = options.eol ? options.eol : '\n';
|
135
|
+
|
136
|
+
if(options.indent_with_tabs){
|
137
|
+
indent_character = '\t';
|
138
|
+
indent_size = 1;
|
139
|
+
}
|
140
|
+
|
141
|
+
eol = eol.replace(/\\r/, '\r').replace(/\\n/, '\n')
|
142
|
+
|
143
|
+
function Parser() {
|
144
|
+
|
145
|
+
this.pos = 0; //Parser position
|
146
|
+
this.token = '';
|
147
|
+
this.current_mode = 'CONTENT'; //reflects the current Parser mode: TAG/CONTENT
|
148
|
+
this.tags = { //An object to hold tags, their position, and their parent-tags, initiated with default values
|
149
|
+
parent: 'parent1',
|
150
|
+
parentcount: 1,
|
151
|
+
parent1: ''
|
152
|
+
};
|
153
|
+
this.tag_type = '';
|
154
|
+
this.token_text = this.last_token = this.last_text = this.token_type = '';
|
155
|
+
this.newlines = 0;
|
156
|
+
this.indent_content = indent_inner_html;
|
157
|
+
|
158
|
+
this.Utils = { //Uilities made available to the various functions
|
159
|
+
whitespace: "\n\r\t ".split(''),
|
160
|
+
single_token: 'br,input,link,meta,source,!doctype,basefont,base,area,hr,wbr,param,img,isindex,embed'.split(','), //all the single tags for HTML
|
161
|
+
extra_liners: extra_liners, //for tags that need a line of whitespace before them
|
162
|
+
in_array: function(what, arr) {
|
163
|
+
for (var i = 0; i < arr.length; i++) {
|
164
|
+
if (what === arr[i]) {
|
165
|
+
return true;
|
166
|
+
}
|
167
|
+
}
|
168
|
+
return false;
|
169
|
+
}
|
170
|
+
};
|
171
|
+
|
172
|
+
// Return true if the given text is composed entirely of whitespace.
|
173
|
+
this.is_whitespace = function(text) {
|
174
|
+
for (var n = 0; n < text.length; text++) {
|
175
|
+
if (!this.Utils.in_array(text.charAt(n), this.Utils.whitespace)) {
|
176
|
+
return false;
|
177
|
+
}
|
178
|
+
}
|
179
|
+
return true;
|
180
|
+
};
|
181
|
+
|
182
|
+
this.traverse_whitespace = function() {
|
183
|
+
var input_char = '';
|
184
|
+
|
185
|
+
input_char = this.input.charAt(this.pos);
|
186
|
+
if (this.Utils.in_array(input_char, this.Utils.whitespace)) {
|
187
|
+
this.newlines = 0;
|
188
|
+
while (this.Utils.in_array(input_char, this.Utils.whitespace)) {
|
189
|
+
if (preserve_newlines && input_char === '\n' && this.newlines <= max_preserve_newlines) {
|
190
|
+
this.newlines += 1;
|
191
|
+
}
|
192
|
+
|
193
|
+
this.pos++;
|
194
|
+
input_char = this.input.charAt(this.pos);
|
195
|
+
}
|
196
|
+
return true;
|
197
|
+
}
|
198
|
+
return false;
|
199
|
+
};
|
200
|
+
|
201
|
+
// Append a space to the given content (string array) or, if we are
|
202
|
+
// at the wrap_line_length, append a newline/indentation.
|
203
|
+
this.space_or_wrap = function(content) {
|
204
|
+
if (this.line_char_count >= this.wrap_line_length) { //insert a line when the wrap_line_length is reached
|
205
|
+
this.print_newline(false, content);
|
206
|
+
this.print_indentation(content);
|
207
|
+
} else {
|
208
|
+
this.line_char_count++;
|
209
|
+
content.push(' ');
|
210
|
+
}
|
211
|
+
};
|
212
|
+
|
213
|
+
this.get_content = function() { //function to capture regular content between tags
|
214
|
+
var input_char = '',
|
215
|
+
content = [],
|
216
|
+
space = false; //if a space is needed
|
217
|
+
|
218
|
+
while (this.input.charAt(this.pos) !== '<') {
|
219
|
+
if (this.pos >= this.input.length) {
|
220
|
+
return content.length ? content.join('') : ['', 'TK_EOF'];
|
221
|
+
}
|
222
|
+
|
223
|
+
if (this.traverse_whitespace()) {
|
224
|
+
this.space_or_wrap(content);
|
225
|
+
continue;
|
226
|
+
}
|
227
|
+
|
228
|
+
if (indent_handlebars) {
|
229
|
+
// Handlebars parsing is complicated.
|
230
|
+
// {{#foo}} and {{/foo}} are formatted tags.
|
231
|
+
// {{something}} should get treated as content, except:
|
232
|
+
// {{else}} specifically behaves like {{#if}} and {{/if}}
|
233
|
+
var peek3 = this.input.substr(this.pos, 3);
|
234
|
+
if (peek3 === '{{#' || peek3 === '{{/') {
|
235
|
+
// These are tags and not content.
|
236
|
+
break;
|
237
|
+
} else if (peek3 === '{{!') {
|
238
|
+
return [this.get_tag(), 'TK_TAG_HANDLEBARS_COMMENT'];
|
239
|
+
} else if (this.input.substr(this.pos, 2) === '{{') {
|
240
|
+
if (this.get_tag(true) === '{{else}}') {
|
241
|
+
break;
|
242
|
+
}
|
243
|
+
}
|
244
|
+
}
|
245
|
+
|
246
|
+
input_char = this.input.charAt(this.pos);
|
247
|
+
this.pos++;
|
248
|
+
this.line_char_count++;
|
249
|
+
content.push(input_char); //letter at-a-time (or string) inserted to an array
|
250
|
+
}
|
251
|
+
return content.length ? content.join('') : '';
|
252
|
+
};
|
253
|
+
|
254
|
+
this.get_contents_to = function(name) { //get the full content of a script or style to pass to js_beautify
|
255
|
+
if (this.pos === this.input.length) {
|
256
|
+
return ['', 'TK_EOF'];
|
257
|
+
}
|
258
|
+
var input_char = '';
|
259
|
+
var content = '';
|
260
|
+
var reg_match = new RegExp('</' + name + '\\s*>', 'igm');
|
261
|
+
reg_match.lastIndex = this.pos;
|
262
|
+
var reg_array = reg_match.exec(this.input);
|
263
|
+
var end_script = reg_array ? reg_array.index : this.input.length; //absolute end of script
|
264
|
+
if (this.pos < end_script) { //get everything in between the script tags
|
265
|
+
content = this.input.substring(this.pos, end_script);
|
266
|
+
this.pos = end_script;
|
267
|
+
}
|
268
|
+
return content;
|
269
|
+
};
|
270
|
+
|
271
|
+
this.record_tag = function(tag) { //function to record a tag and its parent in this.tags Object
|
272
|
+
if (this.tags[tag + 'count']) { //check for the existence of this tag type
|
273
|
+
this.tags[tag + 'count']++;
|
274
|
+
this.tags[tag + this.tags[tag + 'count']] = this.indent_level; //and record the present indent level
|
275
|
+
} else { //otherwise initialize this tag type
|
276
|
+
this.tags[tag + 'count'] = 1;
|
277
|
+
this.tags[tag + this.tags[tag + 'count']] = this.indent_level; //and record the present indent level
|
278
|
+
}
|
279
|
+
this.tags[tag + this.tags[tag + 'count'] + 'parent'] = this.tags.parent; //set the parent (i.e. in the case of a div this.tags.div1parent)
|
280
|
+
this.tags.parent = tag + this.tags[tag + 'count']; //and make this the current parent (i.e. in the case of a div 'div1')
|
281
|
+
};
|
282
|
+
|
283
|
+
this.retrieve_tag = function(tag) { //function to retrieve the opening tag to the corresponding closer
|
284
|
+
if (this.tags[tag + 'count']) { //if the openener is not in the Object we ignore it
|
285
|
+
var temp_parent = this.tags.parent; //check to see if it's a closable tag.
|
286
|
+
while (temp_parent) { //till we reach '' (the initial value);
|
287
|
+
if (tag + this.tags[tag + 'count'] === temp_parent) { //if this is it use it
|
288
|
+
break;
|
289
|
+
}
|
290
|
+
temp_parent = this.tags[temp_parent + 'parent']; //otherwise keep on climbing up the DOM Tree
|
291
|
+
}
|
292
|
+
if (temp_parent) { //if we caught something
|
293
|
+
this.indent_level = this.tags[tag + this.tags[tag + 'count']]; //set the indent_level accordingly
|
294
|
+
this.tags.parent = this.tags[temp_parent + 'parent']; //and set the current parent
|
295
|
+
}
|
296
|
+
delete this.tags[tag + this.tags[tag + 'count'] + 'parent']; //delete the closed tags parent reference...
|
297
|
+
delete this.tags[tag + this.tags[tag + 'count']]; //...and the tag itself
|
298
|
+
if (this.tags[tag + 'count'] === 1) {
|
299
|
+
delete this.tags[tag + 'count'];
|
300
|
+
} else {
|
301
|
+
this.tags[tag + 'count']--;
|
302
|
+
}
|
303
|
+
}
|
304
|
+
};
|
305
|
+
|
306
|
+
this.indent_to_tag = function(tag) {
|
307
|
+
// Match the indentation level to the last use of this tag, but don't remove it.
|
308
|
+
if (!this.tags[tag + 'count']) {
|
309
|
+
return;
|
310
|
+
}
|
311
|
+
var temp_parent = this.tags.parent;
|
312
|
+
while (temp_parent) {
|
313
|
+
if (tag + this.tags[tag + 'count'] === temp_parent) {
|
314
|
+
break;
|
315
|
+
}
|
316
|
+
temp_parent = this.tags[temp_parent + 'parent'];
|
317
|
+
}
|
318
|
+
if (temp_parent) {
|
319
|
+
this.indent_level = this.tags[tag + this.tags[tag + 'count']];
|
320
|
+
}
|
321
|
+
};
|
322
|
+
|
323
|
+
this.get_tag = function(peek) { //function to get a full tag and parse its type
|
324
|
+
var input_char = '',
|
325
|
+
content = [],
|
326
|
+
comment = '',
|
327
|
+
space = false,
|
328
|
+
first_attr = true,
|
329
|
+
tag_start, tag_end,
|
330
|
+
tag_start_char,
|
331
|
+
orig_pos = this.pos,
|
332
|
+
orig_line_char_count = this.line_char_count;
|
333
|
+
|
334
|
+
peek = peek !== undefined ? peek : false;
|
335
|
+
|
336
|
+
do {
|
337
|
+
if (this.pos >= this.input.length) {
|
338
|
+
if (peek) {
|
339
|
+
this.pos = orig_pos;
|
340
|
+
this.line_char_count = orig_line_char_count;
|
341
|
+
}
|
342
|
+
return content.length ? content.join('') : ['', 'TK_EOF'];
|
343
|
+
}
|
344
|
+
|
345
|
+
input_char = this.input.charAt(this.pos);
|
346
|
+
this.pos++;
|
347
|
+
|
348
|
+
if (this.Utils.in_array(input_char, this.Utils.whitespace)) { //don't want to insert unnecessary space
|
349
|
+
space = true;
|
350
|
+
continue;
|
351
|
+
}
|
352
|
+
|
353
|
+
if (input_char === "'" || input_char === '"') {
|
354
|
+
input_char += this.get_unformatted(input_char);
|
355
|
+
space = true;
|
356
|
+
|
357
|
+
}
|
358
|
+
|
359
|
+
if (input_char === '=') { //no space before =
|
360
|
+
space = false;
|
361
|
+
}
|
362
|
+
|
363
|
+
if (content.length && content[content.length - 1] !== '=' && input_char !== '>' && space) {
|
364
|
+
//no space after = or before >
|
365
|
+
this.space_or_wrap(content);
|
366
|
+
space = false;
|
367
|
+
if (!first_attr && wrap_attributes === 'force' && input_char !== '/') {
|
368
|
+
this.print_newline(true, content);
|
369
|
+
this.print_indentation(content);
|
370
|
+
for (var count = 0; count < wrap_attributes_indent_size; count++) {
|
371
|
+
content.push(indent_character);
|
372
|
+
}
|
373
|
+
}
|
374
|
+
for (var i = 0; i < content.length; i++) {
|
375
|
+
if (content[i] === ' ') {
|
376
|
+
first_attr = false;
|
377
|
+
break;
|
378
|
+
}
|
379
|
+
}
|
380
|
+
}
|
381
|
+
|
382
|
+
if (indent_handlebars && tag_start_char === '<') {
|
383
|
+
// When inside an angle-bracket tag, put spaces around
|
384
|
+
// handlebars not inside of strings.
|
385
|
+
if ((input_char + this.input.charAt(this.pos)) === '{{') {
|
386
|
+
input_char += this.get_unformatted('}}');
|
387
|
+
if (content.length && content[content.length - 1] !== ' ' && content[content.length - 1] !== '<') {
|
388
|
+
input_char = ' ' + input_char;
|
389
|
+
}
|
390
|
+
space = true;
|
391
|
+
}
|
392
|
+
}
|
393
|
+
|
394
|
+
if (input_char === '<' && !tag_start_char) {
|
395
|
+
tag_start = this.pos - 1;
|
396
|
+
tag_start_char = '<';
|
397
|
+
}
|
398
|
+
|
399
|
+
if (indent_handlebars && !tag_start_char) {
|
400
|
+
if (content.length >= 2 && content[content.length - 1] === '{' && content[content.length - 2] === '{') {
|
401
|
+
if (input_char === '#' || input_char === '/' || input_char === '!') {
|
402
|
+
tag_start = this.pos - 3;
|
403
|
+
} else {
|
404
|
+
tag_start = this.pos - 2;
|
405
|
+
}
|
406
|
+
tag_start_char = '{';
|
407
|
+
}
|
408
|
+
}
|
409
|
+
|
410
|
+
this.line_char_count++;
|
411
|
+
content.push(input_char); //inserts character at-a-time (or string)
|
412
|
+
|
413
|
+
if (content[1] && (content[1] === '!' || content[1] === '?' || content[1] === '%')) { //if we're in a comment, do something special
|
414
|
+
// We treat all comments as literals, even more than preformatted tags
|
415
|
+
// we just look for the appropriate close tag
|
416
|
+
content = [this.get_comment(tag_start)];
|
417
|
+
break;
|
418
|
+
}
|
419
|
+
|
420
|
+
if (indent_handlebars && content[1] && content[1] === '{' && content[2] && content[2] === '!') { //if we're in a comment, do something special
|
421
|
+
// We treat all comments as literals, even more than preformatted tags
|
422
|
+
// we just look for the appropriate close tag
|
423
|
+
content = [this.get_comment(tag_start)];
|
424
|
+
break;
|
425
|
+
}
|
426
|
+
|
427
|
+
if (indent_handlebars && tag_start_char === '{' && content.length > 2 && content[content.length - 2] === '}' && content[content.length - 1] === '}') {
|
428
|
+
break;
|
429
|
+
}
|
430
|
+
} while (input_char !== '>');
|
431
|
+
|
432
|
+
var tag_complete = content.join('');
|
433
|
+
var tag_index;
|
434
|
+
var tag_offset;
|
435
|
+
|
436
|
+
if (tag_complete.indexOf(' ') !== -1) { //if there's whitespace, thats where the tag name ends
|
437
|
+
tag_index = tag_complete.indexOf(' ');
|
438
|
+
} else if (tag_complete.charAt(0) === '{') {
|
439
|
+
tag_index = tag_complete.indexOf('}');
|
440
|
+
} else { //otherwise go with the tag ending
|
441
|
+
tag_index = tag_complete.indexOf('>');
|
442
|
+
}
|
443
|
+
if (tag_complete.charAt(0) === '<' || !indent_handlebars) {
|
444
|
+
tag_offset = 1;
|
445
|
+
} else {
|
446
|
+
tag_offset = tag_complete.charAt(2) === '#' ? 3 : 2;
|
447
|
+
}
|
448
|
+
var tag_check = tag_complete.substring(tag_offset, tag_index).toLowerCase();
|
449
|
+
if (tag_complete.charAt(tag_complete.length - 2) === '/' ||
|
450
|
+
this.Utils.in_array(tag_check, this.Utils.single_token)) { //if this tag name is a single tag type (either in the list or has a closing /)
|
451
|
+
if (!peek) {
|
452
|
+
this.tag_type = 'SINGLE';
|
453
|
+
}
|
454
|
+
} else if (indent_handlebars && tag_complete.charAt(0) === '{' && tag_check === 'else') {
|
455
|
+
if (!peek) {
|
456
|
+
this.indent_to_tag('if');
|
457
|
+
this.tag_type = 'HANDLEBARS_ELSE';
|
458
|
+
this.indent_content = true;
|
459
|
+
this.traverse_whitespace();
|
460
|
+
}
|
461
|
+
} else if (this.is_unformatted(tag_check, unformatted)) { // do not reformat the "unformatted" tags
|
462
|
+
comment = this.get_unformatted('</' + tag_check + '>', tag_complete); //...delegate to get_unformatted function
|
463
|
+
content.push(comment);
|
464
|
+
tag_end = this.pos - 1;
|
465
|
+
this.tag_type = 'SINGLE';
|
466
|
+
} else if (tag_check === 'script' &&
|
467
|
+
(tag_complete.search('type') === -1 ||
|
468
|
+
(tag_complete.search('type') > -1 &&
|
469
|
+
tag_complete.search(/\b(text|application)\/(x-)?(javascript|ecmascript|jscript|livescript)/) > -1))) {
|
470
|
+
if (!peek) {
|
471
|
+
this.record_tag(tag_check);
|
472
|
+
this.tag_type = 'SCRIPT';
|
473
|
+
}
|
474
|
+
} else if (tag_check === 'style' &&
|
475
|
+
(tag_complete.search('type') === -1 ||
|
476
|
+
(tag_complete.search('type') > -1 && tag_complete.search('text/css') > -1))) {
|
477
|
+
if (!peek) {
|
478
|
+
this.record_tag(tag_check);
|
479
|
+
this.tag_type = 'STYLE';
|
480
|
+
}
|
481
|
+
} else if (tag_check.charAt(0) === '!') { //peek for <! comment
|
482
|
+
// for comments content is already correct.
|
483
|
+
if (!peek) {
|
484
|
+
this.tag_type = 'SINGLE';
|
485
|
+
this.traverse_whitespace();
|
486
|
+
}
|
487
|
+
} else if (!peek) {
|
488
|
+
if (tag_check.charAt(0) === '/') { //this tag is a double tag so check for tag-ending
|
489
|
+
this.retrieve_tag(tag_check.substring(1)); //remove it and all ancestors
|
490
|
+
this.tag_type = 'END';
|
491
|
+
} else { //otherwise it's a start-tag
|
492
|
+
this.record_tag(tag_check); //push it on the tag stack
|
493
|
+
if (tag_check.toLowerCase() !== 'html') {
|
494
|
+
this.indent_content = true;
|
495
|
+
}
|
496
|
+
this.tag_type = 'START';
|
497
|
+
}
|
498
|
+
|
499
|
+
// Allow preserving of newlines after a start or end tag
|
500
|
+
if (this.traverse_whitespace()) {
|
501
|
+
this.space_or_wrap(content);
|
502
|
+
}
|
503
|
+
|
504
|
+
if (this.Utils.in_array(tag_check, this.Utils.extra_liners)) { //check if this double needs an extra line
|
505
|
+
this.print_newline(false, this.output);
|
506
|
+
if (this.output.length && this.output[this.output.length - 2] !== '\n') {
|
507
|
+
this.print_newline(true, this.output);
|
508
|
+
}
|
509
|
+
}
|
510
|
+
}
|
511
|
+
|
512
|
+
if (peek) {
|
513
|
+
this.pos = orig_pos;
|
514
|
+
this.line_char_count = orig_line_char_count;
|
515
|
+
}
|
516
|
+
|
517
|
+
return content.join(''); //returns fully formatted tag
|
518
|
+
};
|
519
|
+
|
520
|
+
this.get_comment = function(start_pos) { //function to return comment content in its entirety
|
521
|
+
// this is will have very poor perf, but will work for now.
|
522
|
+
var comment = '',
|
523
|
+
delimiter = '>',
|
524
|
+
matched = false;
|
525
|
+
|
526
|
+
this.pos = start_pos;
|
527
|
+
input_char = this.input.charAt(this.pos);
|
528
|
+
this.pos++;
|
529
|
+
|
530
|
+
while (this.pos <= this.input.length) {
|
531
|
+
comment += input_char;
|
532
|
+
|
533
|
+
// only need to check for the delimiter if the last chars match
|
534
|
+
if (comment.charAt(comment.length - 1) === delimiter.charAt(delimiter.length - 1) &&
|
535
|
+
comment.indexOf(delimiter) !== -1) {
|
536
|
+
break;
|
537
|
+
}
|
538
|
+
|
539
|
+
// only need to search for custom delimiter for the first few characters
|
540
|
+
if (!matched && comment.length < 10) {
|
541
|
+
if (comment.indexOf('<![if') === 0) { //peek for <![if conditional comment
|
542
|
+
delimiter = '<![endif]>';
|
543
|
+
matched = true;
|
544
|
+
} else if (comment.indexOf('<![cdata[') === 0) { //if it's a <[cdata[ comment...
|
545
|
+
delimiter = ']]>';
|
546
|
+
matched = true;
|
547
|
+
} else if (comment.indexOf('<![') === 0) { // some other ![ comment? ...
|
548
|
+
delimiter = ']>';
|
549
|
+
matched = true;
|
550
|
+
} else if (comment.indexOf('<!--') === 0) { // <!-- comment ...
|
551
|
+
delimiter = '-->';
|
552
|
+
matched = true;
|
553
|
+
} else if (comment.indexOf('{{!') === 0) { // {{! handlebars comment
|
554
|
+
delimiter = '}}';
|
555
|
+
matched = true;
|
556
|
+
} else if (comment.indexOf('<?') === 0) { // {{! handlebars comment
|
557
|
+
delimiter = '?>';
|
558
|
+
matched = true;
|
559
|
+
} else if (comment.indexOf('<%') === 0) { // {{! handlebars comment
|
560
|
+
delimiter = '%>';
|
561
|
+
matched = true;
|
562
|
+
}
|
563
|
+
}
|
564
|
+
|
565
|
+
input_char = this.input.charAt(this.pos);
|
566
|
+
this.pos++;
|
567
|
+
}
|
568
|
+
|
569
|
+
return comment;
|
570
|
+
};
|
571
|
+
|
572
|
+
this.get_unformatted = function(delimiter, orig_tag) { //function to return unformatted content in its entirety
|
573
|
+
|
574
|
+
if (orig_tag && orig_tag.toLowerCase().indexOf(delimiter) !== -1) {
|
575
|
+
return '';
|
576
|
+
}
|
577
|
+
var input_char = '';
|
578
|
+
var content = '';
|
579
|
+
var min_index = 0;
|
580
|
+
var space = true;
|
581
|
+
do {
|
582
|
+
|
583
|
+
if (this.pos >= this.input.length) {
|
584
|
+
return content;
|
585
|
+
}
|
586
|
+
|
587
|
+
input_char = this.input.charAt(this.pos);
|
588
|
+
this.pos++;
|
589
|
+
|
590
|
+
if (this.Utils.in_array(input_char, this.Utils.whitespace)) {
|
591
|
+
if (!space) {
|
592
|
+
this.line_char_count--;
|
593
|
+
continue;
|
594
|
+
}
|
595
|
+
if (input_char === '\n' || input_char === '\r') {
|
596
|
+
content += '\n';
|
597
|
+
/* Don't change tab indention for unformatted blocks. If using code for html editing, this will greatly affect <pre> tags if they are specified in the 'unformatted array'
|
598
|
+
for (var i=0; i<this.indent_level; i++) {
|
599
|
+
content += this.indent_string;
|
600
|
+
}
|
601
|
+
space = false; //...and make sure other indentation is erased
|
602
|
+
*/
|
603
|
+
this.line_char_count = 0;
|
604
|
+
continue;
|
605
|
+
}
|
606
|
+
}
|
607
|
+
content += input_char;
|
608
|
+
this.line_char_count++;
|
609
|
+
space = true;
|
610
|
+
|
611
|
+
if (indent_handlebars && input_char === '{' && content.length && content.charAt(content.length - 2) === '{') {
|
612
|
+
// Handlebars expressions in strings should also be unformatted.
|
613
|
+
content += this.get_unformatted('}}');
|
614
|
+
// These expressions are opaque. Ignore delimiters found in them.
|
615
|
+
min_index = content.length;
|
616
|
+
}
|
617
|
+
} while (content.toLowerCase().indexOf(delimiter, min_index) === -1);
|
618
|
+
return content;
|
619
|
+
};
|
620
|
+
|
621
|
+
this.get_token = function() { //initial handler for token-retrieval
|
622
|
+
var token;
|
623
|
+
|
624
|
+
if (this.last_token === 'TK_TAG_SCRIPT' || this.last_token === 'TK_TAG_STYLE') { //check if we need to format javascript
|
625
|
+
var type = this.last_token.substr(7);
|
626
|
+
token = this.get_contents_to(type);
|
627
|
+
if (typeof token !== 'string') {
|
628
|
+
return token;
|
629
|
+
}
|
630
|
+
return [token, 'TK_' + type];
|
631
|
+
}
|
632
|
+
if (this.current_mode === 'CONTENT') {
|
633
|
+
token = this.get_content();
|
634
|
+
if (typeof token !== 'string') {
|
635
|
+
return token;
|
636
|
+
} else {
|
637
|
+
return [token, 'TK_CONTENT'];
|
638
|
+
}
|
639
|
+
}
|
640
|
+
|
641
|
+
if (this.current_mode === 'TAG') {
|
642
|
+
token = this.get_tag();
|
643
|
+
if (typeof token !== 'string') {
|
644
|
+
return token;
|
645
|
+
} else {
|
646
|
+
var tag_name_type = 'TK_TAG_' + this.tag_type;
|
647
|
+
return [token, tag_name_type];
|
648
|
+
}
|
649
|
+
}
|
650
|
+
};
|
651
|
+
|
652
|
+
this.get_full_indent = function(level) {
|
653
|
+
level = this.indent_level + level || 0;
|
654
|
+
if (level < 1) {
|
655
|
+
return '';
|
656
|
+
}
|
657
|
+
|
658
|
+
return Array(level + 1).join(this.indent_string);
|
659
|
+
};
|
660
|
+
|
661
|
+
this.is_unformatted = function(tag_check, unformatted) {
|
662
|
+
//is this an HTML5 block-level link?
|
663
|
+
if (!this.Utils.in_array(tag_check, unformatted)) {
|
664
|
+
return false;
|
665
|
+
}
|
666
|
+
|
667
|
+
if (tag_check.toLowerCase() !== 'a' || !this.Utils.in_array('a', unformatted)) {
|
668
|
+
return true;
|
669
|
+
}
|
670
|
+
|
671
|
+
//at this point we have an tag; is its first child something we want to remain
|
672
|
+
//unformatted?
|
673
|
+
var next_tag = this.get_tag(true /* peek. */ );
|
674
|
+
|
675
|
+
// test next_tag to see if it is just html tag (no external content)
|
676
|
+
var tag = (next_tag || "").match(/^\s*<\s*\/?([a-z]*)\s*[^>]*>\s*$/);
|
677
|
+
|
678
|
+
// if next_tag comes back but is not an isolated tag, then
|
679
|
+
// let's treat the 'a' tag as having content
|
680
|
+
// and respect the unformatted option
|
681
|
+
if (!tag || this.Utils.in_array(tag, unformatted)) {
|
682
|
+
return true;
|
683
|
+
} else {
|
684
|
+
return false;
|
685
|
+
}
|
686
|
+
};
|
687
|
+
|
688
|
+
this.printer = function(js_source, indent_character, indent_size, wrap_line_length, brace_style) { //handles input/output and some other printing functions
|
689
|
+
|
690
|
+
this.input = js_source || ''; //gets the input for the Parser
|
691
|
+
|
692
|
+
// HACK: newline parsing inconsistent. This brute force normalizes the input.
|
693
|
+
this.input = this.input.replace(/\r\n|[\r\u2028\u2029]/g, '\n')
|
694
|
+
|
695
|
+
this.output = [];
|
696
|
+
this.indent_character = indent_character;
|
697
|
+
this.indent_string = '';
|
698
|
+
this.indent_size = indent_size;
|
699
|
+
this.brace_style = brace_style;
|
700
|
+
this.indent_level = 0;
|
701
|
+
this.wrap_line_length = wrap_line_length;
|
702
|
+
this.line_char_count = 0; //count to see if wrap_line_length was exceeded
|
703
|
+
|
704
|
+
for (var i = 0; i < this.indent_size; i++) {
|
705
|
+
this.indent_string += this.indent_character;
|
706
|
+
}
|
707
|
+
|
708
|
+
this.print_newline = function(force, arr) {
|
709
|
+
this.line_char_count = 0;
|
710
|
+
if (!arr || !arr.length) {
|
711
|
+
return;
|
712
|
+
}
|
713
|
+
if (force || (arr[arr.length - 1] !== '\n')) { //we might want the extra line
|
714
|
+
if ((arr[arr.length - 1] !== '\n')) {
|
715
|
+
arr[arr.length - 1] = rtrim(arr[arr.length - 1]);
|
716
|
+
}
|
717
|
+
arr.push('\n');
|
718
|
+
}
|
719
|
+
};
|
720
|
+
|
721
|
+
this.print_indentation = function(arr) {
|
722
|
+
for (var i = 0; i < this.indent_level; i++) {
|
723
|
+
arr.push(this.indent_string);
|
724
|
+
this.line_char_count += this.indent_string.length;
|
725
|
+
}
|
726
|
+
};
|
727
|
+
|
728
|
+
this.print_token = function(text) {
|
729
|
+
// Avoid printing initial whitespace.
|
730
|
+
if (this.is_whitespace(text) && !this.output.length) {
|
731
|
+
return;
|
732
|
+
}
|
733
|
+
if (text || text !== '') {
|
734
|
+
if (this.output.length && this.output[this.output.length - 1] === '\n') {
|
735
|
+
this.print_indentation(this.output);
|
736
|
+
text = ltrim(text);
|
737
|
+
}
|
738
|
+
}
|
739
|
+
this.print_token_raw(text);
|
740
|
+
};
|
741
|
+
|
742
|
+
this.print_token_raw = function(text) {
|
743
|
+
// If we are going to print newlines, truncate trailing
|
744
|
+
// whitespace, as the newlines will represent the space.
|
745
|
+
if (this.newlines > 0) {
|
746
|
+
text = rtrim(text);
|
747
|
+
}
|
748
|
+
|
749
|
+
if (text && text !== '') {
|
750
|
+
if (text.length > 1 && text.charAt(text.length - 1) === '\n') {
|
751
|
+
// unformatted tags can grab newlines as their last character
|
752
|
+
this.output.push(text.slice(0, -1));
|
753
|
+
this.print_newline(false, this.output);
|
754
|
+
} else {
|
755
|
+
this.output.push(text);
|
756
|
+
}
|
757
|
+
}
|
758
|
+
|
759
|
+
for (var n = 0; n < this.newlines; n++) {
|
760
|
+
this.print_newline(n > 0, this.output);
|
761
|
+
}
|
762
|
+
this.newlines = 0;
|
763
|
+
};
|
764
|
+
|
765
|
+
this.indent = function() {
|
766
|
+
this.indent_level++;
|
767
|
+
};
|
768
|
+
|
769
|
+
this.unindent = function() {
|
770
|
+
if (this.indent_level > 0) {
|
771
|
+
this.indent_level--;
|
772
|
+
}
|
773
|
+
};
|
774
|
+
};
|
775
|
+
return this;
|
776
|
+
}
|
777
|
+
|
778
|
+
/*_____________________--------------------_____________________*/
|
779
|
+
|
780
|
+
multi_parser = new Parser(); //wrapping functions Parser
|
781
|
+
multi_parser.printer(html_source, indent_character, indent_size, wrap_line_length, brace_style); //initialize starting values
|
782
|
+
|
783
|
+
while (true) {
|
784
|
+
var t = multi_parser.get_token();
|
785
|
+
multi_parser.token_text = t[0];
|
786
|
+
multi_parser.token_type = t[1];
|
787
|
+
|
788
|
+
if (multi_parser.token_type === 'TK_EOF') {
|
789
|
+
break;
|
790
|
+
}
|
791
|
+
|
792
|
+
switch (multi_parser.token_type) {
|
793
|
+
case 'TK_TAG_START':
|
794
|
+
multi_parser.print_newline(false, multi_parser.output);
|
795
|
+
multi_parser.print_token(multi_parser.token_text);
|
796
|
+
if (multi_parser.indent_content) {
|
797
|
+
multi_parser.indent();
|
798
|
+
multi_parser.indent_content = false;
|
799
|
+
}
|
800
|
+
multi_parser.current_mode = 'CONTENT';
|
801
|
+
break;
|
802
|
+
case 'TK_TAG_STYLE':
|
803
|
+
case 'TK_TAG_SCRIPT':
|
804
|
+
multi_parser.print_newline(false, multi_parser.output);
|
805
|
+
multi_parser.print_token(multi_parser.token_text);
|
806
|
+
multi_parser.current_mode = 'CONTENT';
|
807
|
+
break;
|
808
|
+
case 'TK_TAG_END':
|
809
|
+
//Print new line only if the tag has no content and has child
|
810
|
+
if (multi_parser.last_token === 'TK_CONTENT' && multi_parser.last_text === '') {
|
811
|
+
var tag_name = multi_parser.token_text.match(/\w+/)[0];
|
812
|
+
var tag_extracted_from_last_output = null;
|
813
|
+
if (multi_parser.output.length) {
|
814
|
+
tag_extracted_from_last_output = multi_parser.output[multi_parser.output.length - 1].match(/(?:<|{{#)\s*(\w+)/);
|
815
|
+
}
|
816
|
+
if (tag_extracted_from_last_output === null ||
|
817
|
+
(tag_extracted_from_last_output[1] !== tag_name && !multi_parser.Utils.in_array(tag_extracted_from_last_output[1], unformatted))) {
|
818
|
+
multi_parser.print_newline(false, multi_parser.output);
|
819
|
+
}
|
820
|
+
}
|
821
|
+
multi_parser.print_token(multi_parser.token_text);
|
822
|
+
multi_parser.current_mode = 'CONTENT';
|
823
|
+
break;
|
824
|
+
case 'TK_TAG_SINGLE':
|
825
|
+
// Don't add a newline before elements that should remain unformatted.
|
826
|
+
var tag_check = multi_parser.token_text.match(/^\s*<([a-z-]+)/i);
|
827
|
+
if (!tag_check || !multi_parser.Utils.in_array(tag_check[1], unformatted)) {
|
828
|
+
multi_parser.print_newline(false, multi_parser.output);
|
829
|
+
}
|
830
|
+
multi_parser.print_token(multi_parser.token_text);
|
831
|
+
multi_parser.current_mode = 'CONTENT';
|
832
|
+
break;
|
833
|
+
case 'TK_TAG_HANDLEBARS_ELSE':
|
834
|
+
multi_parser.print_token(multi_parser.token_text);
|
835
|
+
if (multi_parser.indent_content) {
|
836
|
+
multi_parser.indent();
|
837
|
+
multi_parser.indent_content = false;
|
838
|
+
}
|
839
|
+
multi_parser.current_mode = 'CONTENT';
|
840
|
+
break;
|
841
|
+
case 'TK_TAG_HANDLEBARS_COMMENT':
|
842
|
+
multi_parser.print_token(multi_parser.token_text);
|
843
|
+
multi_parser.current_mode = 'TAG';
|
844
|
+
break;
|
845
|
+
case 'TK_CONTENT':
|
846
|
+
multi_parser.print_token(multi_parser.token_text);
|
847
|
+
multi_parser.current_mode = 'TAG';
|
848
|
+
break;
|
849
|
+
case 'TK_STYLE':
|
850
|
+
case 'TK_SCRIPT':
|
851
|
+
if (multi_parser.token_text !== '') {
|
852
|
+
multi_parser.print_newline(false, multi_parser.output);
|
853
|
+
var text = multi_parser.token_text,
|
854
|
+
_beautifier,
|
855
|
+
script_indent_level = 1;
|
856
|
+
if (multi_parser.token_type === 'TK_SCRIPT') {
|
857
|
+
_beautifier = typeof js_beautify === 'function' && js_beautify;
|
858
|
+
} else if (multi_parser.token_type === 'TK_STYLE') {
|
859
|
+
_beautifier = typeof css_beautify === 'function' && css_beautify;
|
860
|
+
}
|
861
|
+
|
862
|
+
if (options.indent_scripts === "keep") {
|
863
|
+
script_indent_level = 0;
|
864
|
+
} else if (options.indent_scripts === "separate") {
|
865
|
+
script_indent_level = -multi_parser.indent_level;
|
866
|
+
}
|
867
|
+
|
868
|
+
var indentation = multi_parser.get_full_indent(script_indent_level);
|
869
|
+
if (_beautifier) {
|
870
|
+
|
871
|
+
// call the Beautifier if avaliable
|
872
|
+
var Child_options = function() {
|
873
|
+
this.eol = '\n';
|
874
|
+
};
|
875
|
+
Child_options.prototype = options;
|
876
|
+
var child_options = new Child_options();
|
877
|
+
text = _beautifier(text.replace(/^\s*/, indentation), child_options);
|
878
|
+
} else {
|
879
|
+
// simply indent the string otherwise
|
880
|
+
var white = text.match(/^\s*/)[0];
|
881
|
+
var _level = white.match(/[^\n\r]*$/)[0].split(multi_parser.indent_string).length - 1;
|
882
|
+
var reindent = multi_parser.get_full_indent(script_indent_level - _level);
|
883
|
+
text = text.replace(/^\s*/, indentation)
|
884
|
+
.replace(/\r\n|\r|\n/g, '\n' + reindent)
|
885
|
+
.replace(/\s+$/, '');
|
886
|
+
}
|
887
|
+
if (text) {
|
888
|
+
multi_parser.print_token_raw(text);
|
889
|
+
multi_parser.print_newline(true, multi_parser.output);
|
890
|
+
}
|
891
|
+
}
|
892
|
+
multi_parser.current_mode = 'TAG';
|
893
|
+
break;
|
894
|
+
default:
|
895
|
+
// We should not be getting here but we don't want to drop input on the floor
|
896
|
+
// Just output the text and move on
|
897
|
+
if (multi_parser.token_text !== '') {
|
898
|
+
multi_parser.print_token(multi_parser.token_text);
|
899
|
+
}
|
900
|
+
break;
|
901
|
+
}
|
902
|
+
multi_parser.last_token = multi_parser.token_type;
|
903
|
+
multi_parser.last_text = multi_parser.token_text;
|
904
|
+
}
|
905
|
+
var sweet_code = multi_parser.output.join('').replace(/[\r\n\t ]+$/, '');
|
906
|
+
|
907
|
+
// establish end_with_newline
|
908
|
+
if (end_with_newline) {
|
909
|
+
sweet_code += '\n';
|
910
|
+
}
|
911
|
+
|
912
|
+
if (eol != '\n') {
|
913
|
+
sweet_code = sweet_code.replace(/[\n]/g, eol);
|
914
|
+
}
|
915
|
+
|
916
|
+
return sweet_code;
|
917
|
+
}
|
918
|
+
|
919
|
+
if (typeof define === "function" && define.amd) {
|
920
|
+
// Add support for AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- )
|
921
|
+
define(["require", "./beautify", "./beautify-css"], function(requireamd) {
|
922
|
+
var js_beautify = requireamd("./beautify");
|
923
|
+
var css_beautify = requireamd("./beautify-css");
|
924
|
+
|
925
|
+
return {
|
926
|
+
html_beautify: function(html_source, options) {
|
927
|
+
return style_html(html_source, options, js_beautify.js_beautify, css_beautify.css_beautify);
|
928
|
+
}
|
929
|
+
};
|
930
|
+
});
|
931
|
+
} else if (typeof exports !== "undefined") {
|
932
|
+
// Add support for CommonJS. Just put this file somewhere on your require.paths
|
933
|
+
// and you will be able to `var html_beautify = require("beautify").html_beautify`.
|
934
|
+
var js_beautify = require('./beautify.js');
|
935
|
+
var css_beautify = require('./beautify-css.js');
|
936
|
+
|
937
|
+
exports.html_beautify = function(html_source, options) {
|
938
|
+
return style_html(html_source, options, js_beautify.js_beautify, css_beautify.css_beautify);
|
939
|
+
};
|
940
|
+
} else if (typeof window !== "undefined") {
|
941
|
+
// If we're running a web page and don't have either of the above, add our one global
|
942
|
+
window.html_beautify = function(html_source, options) {
|
943
|
+
return style_html(html_source, options, window.js_beautify, window.css_beautify);
|
944
|
+
};
|
945
|
+
} else if (typeof global !== "undefined") {
|
946
|
+
// If we don't even have window, try global.
|
947
|
+
global.html_beautify = function(html_source, options) {
|
948
|
+
return style_html(html_source, options, global.js_beautify, global.css_beautify);
|
949
|
+
};
|
950
|
+
}
|
951
|
+
|
952
|
+
}());
|