From 3d64d7d126f7daeef495e0f8ea7a9014190c5387 Mon Sep 17 00:00:00 2001 From: BurningTreeC Date: Fri, 6 Apr 2018 18:34:50 +0200 Subject: [PATCH] CodeMirror 5.36.0 modularized (#3184) * v5.35.1 * codemirror 5.35.1 * v5.35.1 * v5.35.1 * v5.35.1 * v5.35.1 * v5.35.1 * adding search&replace and autocomplete * update version number * add jump-to-line.js required for search&replace * adding show-hint.js required by autocomplete * adding basic autocomplete for any word * adding autocomplete css * adding new files to tiddlywiki.files * forgot adding search.js * minify 'em all * Delete vim.js * Delete sublime.js * Delete emacs.js * Delete anyword-hint.js * Delete show-hint.css * Delete show-hint.js * Update config.tid * Update tiddlywiki.files * Update tiddlywiki.files * Update config.tid * Update config.tid * Update config.tid * Delete dialog.js * Delete dialog.css * Delete jump-to-line.js * Delete search.js * Delete searchcursor.js * Update tiddlywiki.files * Update tiddlywiki.files * Update tiddlywiki.files * add search-and-replace cm-addon as plugin * add autocomplete cm-addon as plugin * add fullscreen-editing cm-addon as plugin * add keymaps as plugins + cleanup * add highlighting modes as plugins * small update on usage.tid * moved multiplex.js to htmlembedded mode - the only one using it * config/CodeMirror update * how to disable line numbers * how to change CM theme * add closebrackets and closetags addons * packaging a base-addon * move meta.js from codemirror to base addon * inputStyle: textarea -> prevents contenteditable on mobile browsers, keeps focus when clicking toolbar buttons, prevents import on paste * default config no line numbers * temporary add panel plugin for demo * put base-plugin back to codemirror editor * searchcursor to searchnreplace plugin * bad copypasta mistake * another typo * stripped down meta.js + moved matchbrackets to closebrackets plugin * remove panel * change module-type to codemirro and make init "require" dynamic. * make config handling dynamic with sensible defaults * make cm settings translateable * delete multids. they will be replaced * add auto-config tiddlers * dynamically create config structure for CM * fix filename * change typo * kitchensink config, plus change plugin description for better sorting. * add matchBrackets config tiddler * RIP codeblock * removed install instructions from readme - codemirror usage tiddler still todo * control panel settings for cm base * add setting for auto-close tags * adding fontfamily settings and theme settings * change tags for settings from $:/tags/ControlPanel/Settings to $:/tags/ControlPanel/Settings/CodeMirror * more usage info * more usage info * update to v5.36.0 * ugly hack enables highlighting and tag-closing for vnd.tiddlywiki and x-tiddlywiki * disable auto-indent for vnd.tiddlywiki & x-tiddlywiki and add some hidden settings * remove engine.js hack * meta.js -> tw-meta.js * codemirror settings tab * rename tiddler to tw-meta.js * make editor font monospace or sans-serif - dropdown select * make editor font monospace or sans-serif - dropdown select * now using correct tiddler for editor font setting * better usage doc * make markdown-mode require tw-meta * add more themes info * add active-line highlighting option * mini usage change * add integer type to engine.js config-getter * blink rate config type string * correct engine.js * license for base-plugin, usage link in settings tab * codemirrordemo hellothere update * codemirrordemo hellothere update * Update license.tid * codemirror demo sidebarlayout, license * license headers to addon files * license formatting & forgot what year we have * license formatting & forgot what year we have & codemirror demo sitetitle sitesubtitle * more informations 'try-this-style' for codemirrordemo hellothere * codemirror demo sitetitle & cm fontfamily * hellothere * font-family setting must be editor-font-family, not code-font-family * add basic keyboard shortcuts table * shortcuts change to not interfere with toolbar shortcuts - needs testing - vim and emacs todo * formatting * controlpanel change keymap - default keymap is default * ctrl-T becomes Alt-T in default keymap * adjustments for codemirror demo * demo: hellothere - hint for sidebar keymap cheatsheet * toolbar focus fix + remove console log * engine.js cleanup * formatting * reverting focus fix * indenting engine.js * hoping that indenting gets better --- .../tiddlers/DefaultSidebarTab.tid | 5 + .../codemirrordemo/tiddlers/HelloThere.tid | 40 +- editions/codemirrordemo/tiddlers/KeyMap.tid | 4 + .../tiddlers/KeymapCheatsheet.tid | 57 + .../codemirrordemo/tiddlers/SiteSubtitle.tid | 2 +- .../codemirrordemo/tiddlers/SiteTitle.tid | 2 +- .../codemirrordemo/tiddlers/lineNumbers.tid | 4 + .../codemirrordemo/tiddlers/sidebarlayout.tid | 3 + .../tiddlers/styleActiveLine.tid | 4 + editions/codemirrordemo/tiddlywiki.info | 13 +- .../config/autocomplete.tid | 7 + .../files/addon/hint/anyword-hint.js | 3 + .../files/addon/hint/css-hint.js | 3 + .../files/addon/hint/html-hint.js | 3 + .../files/addon/hint/javascript-hint.js | 3 + .../files/addon/hint/show-hint.css | 36 + .../files/addon/hint/show-hint.js | 3 + .../files/addon/hint/xml-hint.js | 3 + .../files/tiddlywiki.files | 54 + .../codemirror-autocomplete/plugin.info | 6 + .../codemirror-autocomplete/readme.tid | 8 + .../config/autoCloseBrackets.tid | 4 + .../config/matchBrackets.tid | 4 + .../files/addon/edit/closebrackets.js | 3 + .../files/addon/edit/matchbrackets.js | 3 + .../files/tiddlywiki.files | 19 + .../codemirror-closebrackets/plugin.info | 6 + .../codemirror-closebrackets/readme.tid | 7 + .../config-language.multids | 4 + .../config/autoCloseTags.tid | 4 + .../files/addon/edit/closetag.js | 3 + .../files/addon/fold/xml-fold.js | 3 + .../files/tiddlywiki.files | 19 + .../codemirror-closetag/plugin.info | 6 + .../tiddlywiki/codemirror-closetag/readme.tid | 5 + .../settings/autoCloseTags.tid | 9 + .../config/fullscreen-editing.tid | 7 + .../files/addon/fullscreen/fullscreen.css | 6 + .../files/addon/fullscreen/fullscreen.js | 3 + .../files/tiddlywiki.files | 19 + .../codemirror-fullscreen-editing/plugin.info | 6 + .../codemirror-fullscreen-editing/readme.tid | 6 + .../codemirror-keymap-emacs/config/keyMap.tid | 4 + .../files/keymap/emacs.js | 3 + .../files/tiddlywiki.files | 12 + .../codemirror-keymap-emacs/plugin.info | 6 + .../codemirror-keymap-emacs/readme.tid | 5 + .../config/extraKeysTW.tid | 24 + .../config/keyMap.tid | 4 + .../files/keymap/sublime.js | 3 + .../files/tiddlywiki.files | 12 + .../plugin.info | 6 + .../codemirror-keymap-sublime-text/readme.tid | 58 + .../codemirror-keymap-vim/config/keyMap.tid | 4 + .../codemirror-keymap-vim/files/keymap/vim.js | 3 + .../files/tiddlywiki.files | 12 + .../codemirror-keymap-vim/plugin.info | 6 + .../codemirror-keymap-vim/readme.tid | 5 + .../codemirror-mode-css/files/mode/css/css.js | 3 + .../files/tiddlywiki.files | 12 + .../codemirror-mode-css/plugin.info | 6 + .../tiddlywiki/codemirror-mode-css/readme.tid | 5 + .../files/addon/mode/multiplex.js | 3 + .../files/mode/htmlembedded/htmlembedded.js | 3 + .../files/tiddlywiki.files | 19 + .../codemirror-mode-htmlembedded/plugin.info | 6 + .../codemirror-mode-htmlembedded/readme.tid | 4 + .../files/mode/htmlmixed/htmlmixed.js | 3 + .../files/tiddlywiki.files | 12 + .../codemirror-mode-htmlmixed/plugin.info | 6 + .../codemirror-mode-htmlmixed/readme.tid | 4 + .../files/mode/javascript/javascript.js | 3 + .../files/tiddlywiki.files | 12 + .../codemirror-mode-javascript/plugin.info | 6 + .../codemirror-mode-javascript/readme.tid | 4 + .../files/mode/markdown/markdown.js | 3 + .../files/tiddlywiki.files | 12 + .../codemirror-mode-markdown/plugin.info | 6 + .../codemirror-mode-markdown/readme.tid | 4 + .../files/mode/tiddlywiki/tiddlywiki.css | 0 .../files/mode/tiddlywiki/tiddlywiki.js | 3 + .../files/tiddlywiki.files | 19 + .../codemirror-mode-x-tiddlywiki/plugin.info | 6 + .../codemirror-mode-x-tiddlywiki/readme.tid | 4 + .../codemirror-mode-xml/files/mode/xml/xml.js | 3 + .../files/tiddlywiki.files | 12 + .../codemirror-mode-xml/plugin.info | 6 + .../tiddlywiki/codemirror-mode-xml/readme.tid | 4 + .../files/addon/search/jump-to-line.js | 3 + .../files/addon/search/search.js | 3 + .../files/addon/search/searchcursor.js | 3 + .../files/tiddlywiki.files | 26 + .../codemirror-search-replace/plugin.info | 6 + .../codemirror-search-replace/readme.tid | 15 + .../codemirror/config-language.multids | 22 + plugins/tiddlywiki/codemirror/config.tid | 25 - .../codemirror/config/cursorBlinkRate.tid | 4 + .../codemirror/config/extraKeysTW.tid | 15 + .../codemirror/config/indentUnit.tid | 3 + .../codemirror/config/inputStyle.tid | 4 + .../tiddlywiki/codemirror/config/keyMap.tid | 4 + .../codemirror/config/lineNumbers.tid | 4 + .../codemirror/config/lineWrapping.tid | 4 + .../config/showCursorWhenSelecting.tid | 4 + .../codemirror/config/styleActiveLine.tid | 4 + .../tiddlywiki/codemirror/config/tabSize.tid | 3 + .../tiddlywiki/codemirror/config/theme.tid | 4 + plugins/tiddlywiki/codemirror/engine.js | 76 +- .../codemirror/files/addon/dialog/dialog.js | 158 +- .../files/addon/edit/matchbrackets.js | 120 - .../codemirror/files/addon/mode/multiplex.js | 123 - .../files/addon/search/searchcursor.js | 189 - .../files/addon/selection/activeline.js | 1 + .../codemirror/files/codemirror.css | 339 +- .../tiddlywiki/codemirror/files/codemirror.js | 8897 +---------------- .../codemirror/files/keymap/emacs.js | 412 - .../codemirror/files/keymap/sublime.js | 569 -- .../tiddlywiki/codemirror/files/keymap/vim.js | 5066 ---------- .../codemirror/files/mode/css/css.js | 825 -- .../files/mode/htmlembedded/htmlembedded.js | 28 - .../files/mode/htmlmixed/htmlmixed.js | 152 - .../files/mode/javascript/javascript.js | 742 -- .../files/mode/markdown/markdown.js | 807 -- .../tiddlywiki/codemirror/files/mode/meta.js | 203 - .../files/mode/tiddlywiki/tiddlywiki.js | 358 - .../codemirror/files/mode/tw-meta.js | 1 + .../codemirror/files/mode/xml/xml.js | 394 - .../codemirror/files/tiddlywiki.files | 107 +- plugins/tiddlywiki/codemirror/keyboard.tid | 107 + plugins/tiddlywiki/codemirror/license.tid | 10 + plugins/tiddlywiki/codemirror/plugin.info | 4 +- plugins/tiddlywiki/codemirror/readme.tid | 10 +- .../codemirror/settings/editorFont.tid | 7 + .../tiddlywiki/codemirror/settings/keyMap.tid | 15 + .../codemirror/settings/lineNumbers.tid | 9 + .../codemirror/settings/lineWrapping.tid | 9 + .../settings/showCursorWhenSelecting.tid | 9 + .../codemirror/settings/styleActiveLine.tid | 9 + .../tiddlywiki/codemirror/settings/theme.tid | 16 + plugins/tiddlywiki/codemirror/styles.tid | 2 +- .../codemirror/ui/controlpanel/codemirror.tid | 24 + .../codemirror/ui/controlpanel/settings.tid | 7 + .../codemirror/ui/controlpanel/tiddlywiki.tid | 19 + plugins/tiddlywiki/codemirror/usage.tid | 264 +- 144 files changed, 1263 insertions(+), 19750 deletions(-) create mode 100644 editions/codemirrordemo/tiddlers/DefaultSidebarTab.tid create mode 100644 editions/codemirrordemo/tiddlers/KeyMap.tid create mode 100644 editions/codemirrordemo/tiddlers/KeymapCheatsheet.tid create mode 100644 editions/codemirrordemo/tiddlers/lineNumbers.tid create mode 100644 editions/codemirrordemo/tiddlers/sidebarlayout.tid create mode 100644 editions/codemirrordemo/tiddlers/styleActiveLine.tid create mode 100644 plugins/tiddlywiki/codemirror-autocomplete/config/autocomplete.tid create mode 100644 plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/anyword-hint.js create mode 100644 plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/css-hint.js create mode 100644 plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/html-hint.js create mode 100644 plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/javascript-hint.js create mode 100644 plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/show-hint.css create mode 100644 plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/show-hint.js create mode 100644 plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/xml-hint.js create mode 100755 plugins/tiddlywiki/codemirror-autocomplete/files/tiddlywiki.files create mode 100755 plugins/tiddlywiki/codemirror-autocomplete/plugin.info create mode 100755 plugins/tiddlywiki/codemirror-autocomplete/readme.tid create mode 100644 plugins/tiddlywiki/codemirror-closebrackets/config/autoCloseBrackets.tid create mode 100644 plugins/tiddlywiki/codemirror-closebrackets/config/matchBrackets.tid create mode 100644 plugins/tiddlywiki/codemirror-closebrackets/files/addon/edit/closebrackets.js create mode 100755 plugins/tiddlywiki/codemirror-closebrackets/files/addon/edit/matchbrackets.js create mode 100755 plugins/tiddlywiki/codemirror-closebrackets/files/tiddlywiki.files create mode 100755 plugins/tiddlywiki/codemirror-closebrackets/plugin.info create mode 100755 plugins/tiddlywiki/codemirror-closebrackets/readme.tid create mode 100644 plugins/tiddlywiki/codemirror-closetag/config-language.multids create mode 100644 plugins/tiddlywiki/codemirror-closetag/config/autoCloseTags.tid create mode 100644 plugins/tiddlywiki/codemirror-closetag/files/addon/edit/closetag.js create mode 100644 plugins/tiddlywiki/codemirror-closetag/files/addon/fold/xml-fold.js create mode 100755 plugins/tiddlywiki/codemirror-closetag/files/tiddlywiki.files create mode 100755 plugins/tiddlywiki/codemirror-closetag/plugin.info create mode 100755 plugins/tiddlywiki/codemirror-closetag/readme.tid create mode 100644 plugins/tiddlywiki/codemirror-closetag/settings/autoCloseTags.tid create mode 100644 plugins/tiddlywiki/codemirror-fullscreen-editing/config/fullscreen-editing.tid create mode 100644 plugins/tiddlywiki/codemirror-fullscreen-editing/files/addon/fullscreen/fullscreen.css create mode 100644 plugins/tiddlywiki/codemirror-fullscreen-editing/files/addon/fullscreen/fullscreen.js create mode 100755 plugins/tiddlywiki/codemirror-fullscreen-editing/files/tiddlywiki.files create mode 100755 plugins/tiddlywiki/codemirror-fullscreen-editing/plugin.info create mode 100755 plugins/tiddlywiki/codemirror-fullscreen-editing/readme.tid create mode 100644 plugins/tiddlywiki/codemirror-keymap-emacs/config/keyMap.tid create mode 100755 plugins/tiddlywiki/codemirror-keymap-emacs/files/keymap/emacs.js create mode 100755 plugins/tiddlywiki/codemirror-keymap-emacs/files/tiddlywiki.files create mode 100755 plugins/tiddlywiki/codemirror-keymap-emacs/plugin.info create mode 100644 plugins/tiddlywiki/codemirror-keymap-emacs/readme.tid create mode 100644 plugins/tiddlywiki/codemirror-keymap-sublime-text/config/extraKeysTW.tid create mode 100644 plugins/tiddlywiki/codemirror-keymap-sublime-text/config/keyMap.tid create mode 100755 plugins/tiddlywiki/codemirror-keymap-sublime-text/files/keymap/sublime.js create mode 100755 plugins/tiddlywiki/codemirror-keymap-sublime-text/files/tiddlywiki.files create mode 100755 plugins/tiddlywiki/codemirror-keymap-sublime-text/plugin.info create mode 100644 plugins/tiddlywiki/codemirror-keymap-sublime-text/readme.tid create mode 100644 plugins/tiddlywiki/codemirror-keymap-vim/config/keyMap.tid create mode 100755 plugins/tiddlywiki/codemirror-keymap-vim/files/keymap/vim.js create mode 100755 plugins/tiddlywiki/codemirror-keymap-vim/files/tiddlywiki.files create mode 100755 plugins/tiddlywiki/codemirror-keymap-vim/plugin.info create mode 100644 plugins/tiddlywiki/codemirror-keymap-vim/readme.tid create mode 100755 plugins/tiddlywiki/codemirror-mode-css/files/mode/css/css.js create mode 100755 plugins/tiddlywiki/codemirror-mode-css/files/tiddlywiki.files create mode 100755 plugins/tiddlywiki/codemirror-mode-css/plugin.info create mode 100755 plugins/tiddlywiki/codemirror-mode-css/readme.tid create mode 100755 plugins/tiddlywiki/codemirror-mode-htmlembedded/files/addon/mode/multiplex.js create mode 100755 plugins/tiddlywiki/codemirror-mode-htmlembedded/files/mode/htmlembedded/htmlembedded.js create mode 100755 plugins/tiddlywiki/codemirror-mode-htmlembedded/files/tiddlywiki.files create mode 100755 plugins/tiddlywiki/codemirror-mode-htmlembedded/plugin.info create mode 100755 plugins/tiddlywiki/codemirror-mode-htmlembedded/readme.tid create mode 100755 plugins/tiddlywiki/codemirror-mode-htmlmixed/files/mode/htmlmixed/htmlmixed.js create mode 100755 plugins/tiddlywiki/codemirror-mode-htmlmixed/files/tiddlywiki.files create mode 100755 plugins/tiddlywiki/codemirror-mode-htmlmixed/plugin.info create mode 100755 plugins/tiddlywiki/codemirror-mode-htmlmixed/readme.tid create mode 100755 plugins/tiddlywiki/codemirror-mode-javascript/files/mode/javascript/javascript.js create mode 100755 plugins/tiddlywiki/codemirror-mode-javascript/files/tiddlywiki.files create mode 100755 plugins/tiddlywiki/codemirror-mode-javascript/plugin.info create mode 100755 plugins/tiddlywiki/codemirror-mode-javascript/readme.tid create mode 100755 plugins/tiddlywiki/codemirror-mode-markdown/files/mode/markdown/markdown.js create mode 100755 plugins/tiddlywiki/codemirror-mode-markdown/files/tiddlywiki.files create mode 100755 plugins/tiddlywiki/codemirror-mode-markdown/plugin.info create mode 100755 plugins/tiddlywiki/codemirror-mode-markdown/readme.tid rename plugins/tiddlywiki/{codemirror => codemirror-mode-x-tiddlywiki}/files/mode/tiddlywiki/tiddlywiki.css (100%) create mode 100755 plugins/tiddlywiki/codemirror-mode-x-tiddlywiki/files/mode/tiddlywiki/tiddlywiki.js create mode 100755 plugins/tiddlywiki/codemirror-mode-x-tiddlywiki/files/tiddlywiki.files create mode 100755 plugins/tiddlywiki/codemirror-mode-x-tiddlywiki/plugin.info create mode 100755 plugins/tiddlywiki/codemirror-mode-x-tiddlywiki/readme.tid create mode 100755 plugins/tiddlywiki/codemirror-mode-xml/files/mode/xml/xml.js create mode 100755 plugins/tiddlywiki/codemirror-mode-xml/files/tiddlywiki.files create mode 100755 plugins/tiddlywiki/codemirror-mode-xml/plugin.info create mode 100755 plugins/tiddlywiki/codemirror-mode-xml/readme.tid create mode 100644 plugins/tiddlywiki/codemirror-search-replace/files/addon/search/jump-to-line.js create mode 100644 plugins/tiddlywiki/codemirror-search-replace/files/addon/search/search.js create mode 100755 plugins/tiddlywiki/codemirror-search-replace/files/addon/search/searchcursor.js create mode 100755 plugins/tiddlywiki/codemirror-search-replace/files/tiddlywiki.files create mode 100755 plugins/tiddlywiki/codemirror-search-replace/plugin.info create mode 100755 plugins/tiddlywiki/codemirror-search-replace/readme.tid create mode 100644 plugins/tiddlywiki/codemirror/config-language.multids delete mode 100755 plugins/tiddlywiki/codemirror/config.tid create mode 100644 plugins/tiddlywiki/codemirror/config/cursorBlinkRate.tid create mode 100644 plugins/tiddlywiki/codemirror/config/extraKeysTW.tid create mode 100644 plugins/tiddlywiki/codemirror/config/indentUnit.tid create mode 100644 plugins/tiddlywiki/codemirror/config/inputStyle.tid create mode 100644 plugins/tiddlywiki/codemirror/config/keyMap.tid create mode 100644 plugins/tiddlywiki/codemirror/config/lineNumbers.tid create mode 100644 plugins/tiddlywiki/codemirror/config/lineWrapping.tid create mode 100644 plugins/tiddlywiki/codemirror/config/showCursorWhenSelecting.tid create mode 100644 plugins/tiddlywiki/codemirror/config/styleActiveLine.tid create mode 100644 plugins/tiddlywiki/codemirror/config/tabSize.tid create mode 100644 plugins/tiddlywiki/codemirror/config/theme.tid delete mode 100755 plugins/tiddlywiki/codemirror/files/addon/edit/matchbrackets.js delete mode 100755 plugins/tiddlywiki/codemirror/files/addon/mode/multiplex.js delete mode 100755 plugins/tiddlywiki/codemirror/files/addon/search/searchcursor.js create mode 100644 plugins/tiddlywiki/codemirror/files/addon/selection/activeline.js delete mode 100755 plugins/tiddlywiki/codemirror/files/keymap/emacs.js delete mode 100755 plugins/tiddlywiki/codemirror/files/keymap/sublime.js delete mode 100755 plugins/tiddlywiki/codemirror/files/keymap/vim.js delete mode 100755 plugins/tiddlywiki/codemirror/files/mode/css/css.js delete mode 100755 plugins/tiddlywiki/codemirror/files/mode/htmlembedded/htmlembedded.js delete mode 100755 plugins/tiddlywiki/codemirror/files/mode/htmlmixed/htmlmixed.js delete mode 100755 plugins/tiddlywiki/codemirror/files/mode/javascript/javascript.js delete mode 100755 plugins/tiddlywiki/codemirror/files/mode/markdown/markdown.js delete mode 100755 plugins/tiddlywiki/codemirror/files/mode/meta.js delete mode 100755 plugins/tiddlywiki/codemirror/files/mode/tiddlywiki/tiddlywiki.js create mode 100755 plugins/tiddlywiki/codemirror/files/mode/tw-meta.js delete mode 100755 plugins/tiddlywiki/codemirror/files/mode/xml/xml.js create mode 100755 plugins/tiddlywiki/codemirror/keyboard.tid create mode 100644 plugins/tiddlywiki/codemirror/license.tid create mode 100644 plugins/tiddlywiki/codemirror/settings/editorFont.tid create mode 100644 plugins/tiddlywiki/codemirror/settings/keyMap.tid create mode 100644 plugins/tiddlywiki/codemirror/settings/lineNumbers.tid create mode 100644 plugins/tiddlywiki/codemirror/settings/lineWrapping.tid create mode 100644 plugins/tiddlywiki/codemirror/settings/showCursorWhenSelecting.tid create mode 100644 plugins/tiddlywiki/codemirror/settings/styleActiveLine.tid create mode 100644 plugins/tiddlywiki/codemirror/settings/theme.tid create mode 100644 plugins/tiddlywiki/codemirror/ui/controlpanel/codemirror.tid create mode 100644 plugins/tiddlywiki/codemirror/ui/controlpanel/settings.tid create mode 100644 plugins/tiddlywiki/codemirror/ui/controlpanel/tiddlywiki.tid diff --git a/editions/codemirrordemo/tiddlers/DefaultSidebarTab.tid b/editions/codemirrordemo/tiddlers/DefaultSidebarTab.tid new file mode 100644 index 000000000..e28688819 --- /dev/null +++ b/editions/codemirrordemo/tiddlers/DefaultSidebarTab.tid @@ -0,0 +1,5 @@ +title: $:/config/DefaultSidebarTab + + +$:/codemirrordemo/sidebar/cheatsheet + diff --git a/editions/codemirrordemo/tiddlers/HelloThere.tid b/editions/codemirrordemo/tiddlers/HelloThere.tid index 75f3882d3..11ec8ce0e 100644 --- a/editions/codemirrordemo/tiddlers/HelloThere.tid +++ b/editions/codemirrordemo/tiddlers/HelloThere.tid @@ -1,11 +1,43 @@ title: HelloThere -This is a demo of TiddlyWiki5 incorporating a plugin for the [[CodeMirror|http://codemirror.net/]] text editor for the web. +This is a demo of [[TiddlyWiki5|https://tiddlywiki.com]] incorporating a plugin for the [[CodeMirror|http://codemirror.net/]] text editor for the web. -Try editing the tiddler LoremIpsum to try out the editor. +The ~CodeMirror plugin can be extended with ~AddOns for more functionality: -To add the plugin to your own TiddlyWiki5, just drag this link to the browser window: +* Search and Replace +* Text - Autocompletion +* Syntax highlighting +* Fullscreen editing +* Keymaps in the style of Emacs, Sublime Text or Vim +* Closing Brackets +* Closing Tags + +NOTE: This demo has the ''Sublime Text'' keymap installed. + +!!!Try editing the tiddler [[Draft of 'LoremIpsum']] to try out the editor. + +Some commands and functions to try: + +* Ctrl+F : Search panel to search for expressions +* Ctrl+H (sublime text shortcut, default is Ctrl+Shift+R) : Search and Replace +* Ctrl+Space : Triggers Autocompletion +* typing an opening bracket like `{` automatically creates the closing bracket `}` +* tiddlers with type `application/javascript`, `application/json`, `text/css`, `text/html`, `text/xml`, `text/x-markdown` and `text/x-tiddlywiki` have Syntax Highlighting +* tiddlers with type `text/html` automatically close tags like `
` when the closing `>` gets typed +* Multiple cursors: holding Ctrl pressed while selecting words results in multiple cursors. If you type, all selections will update + +This demo uses the ''Sublime Text Keymap'' - See the Sidebar Tab ''Keymap'' or the [[Sublime Text Keymap Readme|$:/plugins/tiddlywiki/codemirror-keymap-sublime-text/readme]] for all available keyboard shortcuts + +To add the base plugin to your own ~TiddlyWiki5, just drag this link to the browser window: [[$:/plugins/tiddlywiki/codemirror]] -{{$:/plugins/tiddlywiki/codemirror/readme}} +[[CodeMirror plugin Readme|$:/plugins/tiddlywiki/codemirror/readme]] + +[[CodeMirror plugin Usage|$:/plugins/tiddlywiki/codemirror/usage]] + +To add ~AddOns to your ~CodeMirror plugin, go to ~ControlPanel - Plugins and drag the desired ~AddOn to your wiki browser window + +The configuration for ~AddOns is done automatically, configuration for sensible settings can be done in ~ControlPanel - Settings - ~CodeMirror + + diff --git a/editions/codemirrordemo/tiddlers/KeyMap.tid b/editions/codemirrordemo/tiddlers/KeyMap.tid new file mode 100644 index 000000000..72febaa78 --- /dev/null +++ b/editions/codemirrordemo/tiddlers/KeyMap.tid @@ -0,0 +1,4 @@ +title: $:/config/codemirror/keyMap +type: string + +sublime diff --git a/editions/codemirrordemo/tiddlers/KeymapCheatsheet.tid b/editions/codemirrordemo/tiddlers/KeymapCheatsheet.tid new file mode 100644 index 000000000..4c8843b8f --- /dev/null +++ b/editions/codemirrordemo/tiddlers/KeymapCheatsheet.tid @@ -0,0 +1,57 @@ +caption: Keymap +tags: $:/tags/SideBar +title: $:/codemirrordemo/sidebar/cheatsheet + + +|Shortcut |Function |h +|Shift-Tab |indentLess | +|Shift-Ctrl-K |deleteLine | +|Alt-Q |wrapLines | +|Alt-T |transposeChars | +|Alt-Left |goSubwordLeft | +|Alt-Right |goSubwordRight | +|Ctrl-Up |scrollLineUp | +|Ctrl-Down |scrollLineDown | +|Alt-L |selectLine | +|Shift-Alt-L |splitSelectionByLine | +|Ctrl-Esc |singleSelectionTop | +|Shift-Enter |insertLineAfter | +|Shift-Ctrl-Enter |insertLineBefore | +|Ctrl-D |selectNextOccurrence | +|Shift-Ctrl-Space |selectScope | +|Shift-Ctrl-M |selectBetweenBrackets | +|Alt-M |goToBracket | +|Shift-Ctrl-Up |swapLineUp | +|Shift-Ctrl-Down |swapLineDown | +|Ctrl-/ |toggleCommentIndented | +|Ctrl-J |joinLines | +|Shift-Ctrl-D |duplicateLine | +|F9 |sortLines | +|Ctrl-F9 |sortLinesInsensitive | +|F2 |nextBookmark | +|Shift-F2 |prevBookmark | +|Ctrl-F2 |toggleBookmark | +|Shift-Ctrl-F2 |clearBookmarks | +|Alt-F2 |selectBookmarks | +|Backspace |smartBackspace | +|Ctrl-K Ctrl-K |delLineRight | +|Ctrl-K Alt-U |upcaseAtCursor | +|Ctrl-K Alt-L |downcaseAtCursor | +|Ctrl-K Ctrl-Space |setSublimeMark | +|Ctrl-K Ctrl-A |selectToSublimeMark | +|Ctrl-K Alt-D |deleteToSublimeMark | +|Ctrl-K Ctrl-X |swapWithSublimeMark | +|Ctrl-K Ctrl-Y |sublimeYank | +|Ctrl-K Ctrl-C |showInCenter | +|Ctrl-K Ctrl-G |clearBookmarks | +|Ctrl-K Ctrl-Backspace |delLineLeft | +|Ctrl-K Ctrl-0 |unfoldAll | +|Ctrl-K Ctrl-J |unfoldAll | +|Ctrl-Alt-Up |addCursorToPrevLine | +|Ctrl-Alt-Down |addCursorToNextLine | +|Ctrl-F3 |findUnder | +|Shift-Ctrl-F3 |findUnderPrevious | +|Shift-Ctrl-[ |fold | +|Shift-Ctrl-] |unfold | +|Ctrl-H |replace | + diff --git a/editions/codemirrordemo/tiddlers/SiteSubtitle.tid b/editions/codemirrordemo/tiddlers/SiteSubtitle.tid index a5556748c..7896f7fdb 100644 --- a/editions/codemirrordemo/tiddlers/SiteSubtitle.tid +++ b/editions/codemirrordemo/tiddlers/SiteSubtitle.tid @@ -1,3 +1,3 @@ title: $:/SiteSubtitle -a demo of the CodeMirror plugin for TiddlyWiki5 \ No newline at end of file +~CodeMirror plugins for ~TiddlyWiki diff --git a/editions/codemirrordemo/tiddlers/SiteTitle.tid b/editions/codemirrordemo/tiddlers/SiteTitle.tid index a32e85d40..ab6ef6881 100644 --- a/editions/codemirrordemo/tiddlers/SiteTitle.tid +++ b/editions/codemirrordemo/tiddlers/SiteTitle.tid @@ -1,3 +1,3 @@ title: $:/SiteTitle -codemirrordemo \ No newline at end of file +~CodeMirror Demo diff --git a/editions/codemirrordemo/tiddlers/lineNumbers.tid b/editions/codemirrordemo/tiddlers/lineNumbers.tid new file mode 100644 index 000000000..2fc5763b2 --- /dev/null +++ b/editions/codemirrordemo/tiddlers/lineNumbers.tid @@ -0,0 +1,4 @@ +title: $:/config/codemirror/lineNumbers +type: bool + +true diff --git a/editions/codemirrordemo/tiddlers/sidebarlayout.tid b/editions/codemirrordemo/tiddlers/sidebarlayout.tid new file mode 100644 index 000000000..2bfa95e13 --- /dev/null +++ b/editions/codemirrordemo/tiddlers/sidebarlayout.tid @@ -0,0 +1,3 @@ +title: $:/themes/tiddlywiki/vanilla/options/sidebarlayout + +fluid-fixed \ No newline at end of file diff --git a/editions/codemirrordemo/tiddlers/styleActiveLine.tid b/editions/codemirrordemo/tiddlers/styleActiveLine.tid new file mode 100644 index 000000000..2c3d4e439 --- /dev/null +++ b/editions/codemirrordemo/tiddlers/styleActiveLine.tid @@ -0,0 +1,4 @@ +title: $:/config/codemirror/styleActiveLine +type: bool + +true diff --git a/editions/codemirrordemo/tiddlywiki.info b/editions/codemirrordemo/tiddlywiki.info index bd07c052b..7baa8f5a0 100644 --- a/editions/codemirrordemo/tiddlywiki.info +++ b/editions/codemirrordemo/tiddlywiki.info @@ -1,7 +1,18 @@ { "description": "Demo of the CodeMirror plugin", "plugins": [ - "tiddlywiki/codemirror" + "tiddlywiki/codemirror", + "tiddlywiki/codemirror-closebrackets", + "tiddlywiki/codemirror-closetag", + "tiddlywiki/codemirror-autocomplete", + "tiddlywiki/codemirror-search-replace", + "tiddlywiki/codemirror-fullscreen-editing", + "tiddlywiki/codemirror-mode-xml", + "tiddlywiki/codemirror-mode-javascript", + "tiddlywiki/codemirror-mode-css", + "tiddlywiki/codemirror-mode-x-tiddlywiki", + "tiddlywiki/codemirror-mode-markdown", + "tiddlywiki/codemirror-keymap-sublime-text" ], "themes": [ "tiddlywiki/vanilla", diff --git a/plugins/tiddlywiki/codemirror-autocomplete/config/autocomplete.tid b/plugins/tiddlywiki/codemirror-autocomplete/config/autocomplete.tid new file mode 100644 index 000000000..5f76573dd --- /dev/null +++ b/plugins/tiddlywiki/codemirror-autocomplete/config/autocomplete.tid @@ -0,0 +1,7 @@ +title: $:/config/codemirror/autocomplete +extend: extraKeys +type: json + +{ + "Ctrl-Space": "autocomplete" +} \ No newline at end of file diff --git a/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/anyword-hint.js b/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/anyword-hint.js new file mode 100644 index 000000000..80b384a3e --- /dev/null +++ b/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/anyword-hint.js @@ -0,0 +1,3 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE +!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";var r=/[\w$]+/;e.registerHelper("hint","anyword",function(t,o){for(var i=o&&o.word||r,n=o&&o.range||500,f=t.getCursor(),s=t.getLine(f.line),a=f.ch,c=a;c&&i.test(s.charAt(c-1));)--c;for(var l=c!=a&&s.slice(c,a),d=o&&o.list||[],u={},p=new RegExp(i.source,"g"),g=-1;g<=1;g+=2)for(var h=f.line,m=Math.min(Math.max(h+g*n,t.firstLine()),t.lastLine())+g;h!=m;h+=g)for(var y,b=t.getLine(h);y=p.exec(b);)h==f.line&&y[0]===l||l&&0!=y[0].lastIndexOf(l,0)||Object.prototype.hasOwnProperty.call(u,y[0])||(u[y[0]]=!0,d.push(y[0]));return{list:d,from:e.Pos(f.line,c),to:e.Pos(f.line,a)}})}); \ No newline at end of file diff --git a/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/css-hint.js b/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/css-hint.js new file mode 100644 index 000000000..fadd84612 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/css-hint.js @@ -0,0 +1,3 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE +!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../../mode/css/css")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../../mode/css/css"],e):e(CodeMirror)}(function(e){"use strict";var r={link:1,visited:1,active:1,hover:1,focus:1,"first-letter":1,"first-line":1,"first-child":1,before:1,after:1,lang:1};e.registerHelper("hint","css",function(t){var o=t.getCursor(),s=t.getTokenAt(o),i=e.innerMode(t.getMode(),s.state);if("css"==i.mode.name){if("keyword"==s.type&&0=="!important".indexOf(s.string))return{list:["!important"],from:e.Pos(o.line,s.start),to:e.Pos(o.line,s.end)};var n=s.start,a=o.ch,d=s.string.slice(0,a-n);/[^\w$_-]/.test(d)&&(d="",n=a=o.ch);var c=e.resolveMode("text/css"),f=[],l=i.state.state;return"pseudo"==l||"variable-3"==s.type?p(r):"block"==l||"maybeprop"==l?p(c.propertyKeywords):"prop"==l||"parens"==l||"at"==l||"params"==l?(p(c.valueKeywords),p(c.colorKeywords)):"media"!=l&&"media_parens"!=l||(p(c.mediaTypes),p(c.mediaFeatures)),f.length?{list:f,from:e.Pos(o.line,n),to:e.Pos(o.line,a)}:void 0}function p(e){for(var r in e)d&&0!=r.lastIndexOf(d,0)||f.push(r)}})}); \ No newline at end of file diff --git a/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/html-hint.js b/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/html-hint.js new file mode 100644 index 000000000..e3215229a --- /dev/null +++ b/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/html-hint.js @@ -0,0 +1,3 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE +!function(l){"object"==typeof exports&&"object"==typeof module?l(require("../../lib/codemirror"),require("./xml-hint")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./xml-hint"],l):l(CodeMirror)}(function(l){"use strict";var t="ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl ka de el gn gu ht ha he hz hi ho hu ia id ie ga ig ik io is it iu ja jv kl kn kr ks kk km ki rw ky kv kg ko ku kj la lb lg li ln lo lt lu lv gv mk mg ms ml mt mi mr mh mn na nv nb nd ne ng nn no ii nr oc oj cu om or os pa pi fa pl ps pt qu rm rn ro ru sa sc sd se sm sg sr gd sn si sk sl so st es su sw ss sv ta te tg th ti bo tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa cy wo fy xh yi yo za zu".split(" "),e=["_blank","_self","_top","_parent"],a=["ascii","utf-8","utf-16","latin1","latin1"],n=["get","post","put","delete"],r=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],o=["all","screen","print","embossed","braille","handheld","print","projection","screen","tty","tv","speech","3d-glasses","resolution [>][<][=] [X]","device-aspect-ratio: X/Y","orientation:portrait","orientation:landscape","device-height: [X]","device-width: [X]"],s={attrs:{}},u={a:{attrs:{href:null,ping:null,type:null,media:o,target:e,hreflang:t}},abbr:s,acronym:s,address:s,applet:s,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:o,hreflang:t,type:null,shape:["default","rect","circle","poly"]}},article:s,aside:s,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["","autoplay"],loop:["","loop"],controls:["","controls"]}},b:s,base:{attrs:{href:null,target:e}},basefont:s,bdi:s,bdo:s,big:s,blockquote:{attrs:{cite:null}},body:s,br:s,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["","autofocus"],disabled:["","autofocus"],formenctype:r,formmethod:n,formnovalidate:["","novalidate"],formtarget:e,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:s,center:s,cite:s,code:s,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["","disabled"],checked:["","checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["","disabled"],multiple:["","multiple"]}},datalist:{attrs:{data:null}},dd:s,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["","open"]}},dfn:s,dir:s,div:s,dl:s,dt:s,em:s,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["","disabled"],form:null,name:null}},figcaption:s,figure:s,font:s,footer:s,form:{attrs:{action:null,name:null,"accept-charset":a,autocomplete:["on","off"],enctype:r,method:n,novalidate:["","novalidate"],target:e}},frame:s,frameset:s,h1:s,h2:s,h3:s,h4:s,h5:s,h6:s,head:{attrs:{},children:["title","base","link","style","meta","script","noscript","command"]},header:s,hgroup:s,hr:s,html:{attrs:{manifest:null},children:["head","body"]},i:s,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["","seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["","autofocus"],checked:["","checked"],disabled:["","disabled"],formenctype:r,formmethod:n,formnovalidate:["","novalidate"],formtarget:e,multiple:["","multiple"],readonly:["","readonly"],required:["","required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:s,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["","autofocus"],disabled:["","disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:s,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:t,media:o,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:s,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:a,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:s,noframes:s,noscript:s,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["","typemustmatch"]}},ol:{attrs:{reversed:["","reversed"],start:null,type:["1","a","A","i","I"]}},optgroup:{attrs:{disabled:["","disabled"],label:null}},option:{attrs:{disabled:["","disabled"],label:null,selected:["","selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:s,param:{attrs:{name:null,value:null}},pre:s,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:s,rt:s,ruby:s,s:s,samp:s,script:{attrs:{type:["text/javascript"],src:null,async:["","async"],defer:["","defer"],charset:a}},section:s,select:{attrs:{form:null,name:null,size:null,autofocus:["","autofocus"],disabled:["","disabled"],multiple:["","multiple"]}},small:s,source:{attrs:{src:null,type:null,media:null}},span:s,strike:s,strong:s,style:{attrs:{type:["text/css"],media:o,scoped:null}},sub:s,summary:s,sup:s,table:s,tbody:s,td:{attrs:{colspan:null,rowspan:null,headers:null}},textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["","autofocus"],disabled:["","disabled"],readonly:["","readonly"],required:["","required"],wrap:["soft","hard"]}},tfoot:s,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:s,time:{attrs:{datetime:null}},title:s,tr:s,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:t}},tt:s,u:s,ul:s,var:s,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["","autoplay"],mediagroup:["movie"],muted:["","muted"],controls:["","controls"]}},wbr:s},i={accesskey:["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"],class:null,contenteditable:["true","false"],contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["en","es"],spellcheck:["true","false"],style:null,tabindex:["1","2","3","4","5","6","7","8","9"],title:null,translate:["yes","no"],onclick:null,rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"]};function d(l){for(var t in i)i.hasOwnProperty(t)&&(l.attrs[t]=i[t])}for(var c in d(s),u)u.hasOwnProperty(c)&&u[c]!=s&&d(u[c]);l.htmlSchema=u,l.registerHelper("hint","html",function(t,e){var a={schemaInfo:u};if(e)for(var n in e)a[n]=e[n];return l.hint.xml(t,a)})}); \ No newline at end of file diff --git a/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/javascript-hint.js b/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/javascript-hint.js new file mode 100644 index 000000000..0e8cc6a6c --- /dev/null +++ b/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/javascript-hint.js @@ -0,0 +1,3 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE +!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){var e=t.Pos;function r(t,e){for(var r=0,n=t.length;rc.ch&&(p.end=c.ch,p.string=p.string.slice(0,c.ch-p.start)):p={start:c.ch,end:c.ch,string:"",state:p.state,type:"."==p.string?"property":null};for(var d=p;"property"==d.type;){if("."!=(d=l(n,e(c.line,d.start))).string)return;if(d=l(n,e(c.line,d.start)),!g)var g=[];g.push(d)}return{list:function(t,e,n,i){var l=[],f=t.string,c=i&&i.globalScope||window;function p(t){0!=t.lastIndexOf(f,0)||function(t,e){if(!Array.prototype.indexOf){for(var r=t.length;r--;)if(t[r]===e)return!0;return!1}return-1!=t.indexOf(e)}(l,t)||l.push(t)}function u(t){"string"==typeof t?r(o,p):t instanceof Array?r(s,p):t instanceof Function&&r(a,p),function(t,e){if(Object.getOwnPropertyNames&&Object.getPrototypeOf)for(var r=t;r;r=Object.getPrototypeOf(r))Object.getOwnPropertyNames(r).forEach(e);else for(var n in t)e(n)}(t,p)}if(e&&e.length){var d,g=e.pop();for(g.type&&0===g.type.indexOf("variable")?(i&&i.additionalContext&&(d=i.additionalContext[g.string]),i&&!1===i.useGlobalScope||(d=d||c[g.string])):"string"==g.type?d="":"atom"==g.type?d=1:"function"==g.type&&(null==c.jQuery||"$"!=g.string&&"jQuery"!=g.string||"function"!=typeof c.jQuery?null!=c._&&"_"==g.string&&"function"==typeof c._&&(d=c._()):d=c.jQuery());null!=d&&e.length;)d=d[e.pop().string];null!=d&&u(d)}else{for(var y=t.state.localVars;y;y=y.next)p(y.name);for(var y=t.state.globalVars;y;y=y.next)p(y.name);i&&!1===i.useGlobalScope||u(c),r(n,p)}return l}(p,g,i,f),from:e(c.line,p.start),to:e(c.line,p.end)}}}}function i(t,e){var r=t.getTokenAt(e);return e.ch==r.start+1&&"."==r.string.charAt(0)?(r.end=r.start,r.string=".",r.type="property"):/^\.[\w$_]*$/.test(r.string)&&(r.type="property",r.start++,r.string=r.string.replace(/\./,"")),r}t.registerHelper("hint","javascript",function(t,e){return n(t,l,function(t,e){return t.getTokenAt(e)},e)}),t.registerHelper("hint","coffeescript",function(t,e){return n(t,f,i,e)});var o="charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight toUpperCase toLowerCase split concat match replace search".split(" "),s="length concat join splice push pop shift unshift slice reverse sort indexOf lastIndexOf every some filter forEach map reduce reduceRight ".split(" "),a="prototype apply call bind".split(" "),l="break case catch class const continue debugger default delete do else export extends false finally for function if in import instanceof new null return super switch this throw true try typeof var void while with yield".split(" "),f="and break catch class continue delete do else extends false finally for if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes".split(" ")}); diff --git a/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/show-hint.css b/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/show-hint.css new file mode 100644 index 000000000..5617ccca2 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/show-hint.css @@ -0,0 +1,36 @@ +.CodeMirror-hints { + position: absolute; + z-index: 10; + overflow: hidden; + list-style: none; + + margin: 0; + padding: 2px; + + -webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2); + -moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2); + box-shadow: 2px 3px 5px rgba(0,0,0,.2); + border-radius: 3px; + border: 1px solid silver; + + background: white; + font-size: 90%; + font-family: monospace; + + max-height: 20em; + overflow-y: auto; +} + +.CodeMirror-hint { + margin: 0; + padding: 0 4px; + border-radius: 2px; + white-space: pre; + color: black; + cursor: pointer; +} + +li.CodeMirror-hint-active { + background: #08f; + color: white; +} diff --git a/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/show-hint.js b/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/show-hint.js new file mode 100644 index 000000000..8c58de461 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/show-hint.js @@ -0,0 +1,3 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE +!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";var i="CodeMirror-hint",e="CodeMirror-hint-active";function n(t,i){this.cm=t,this.options=i,this.widget=null,this.debounce=0,this.tick=0,this.startPos=this.cm.getCursor("start"),this.startLen=this.cm.getLine(this.startPos.line).length-this.cm.getSelection().length;var e=this;t.on("cursorActivity",this.activityFunc=function(){e.cursorActivity()})}t.showHint=function(t,i,e){if(!i)return t.showHint(e);e&&e.async&&(i.async=!0);var n={hint:i};if(e)for(var o in e)n[o]=e[o];return t.showHint(n)},t.defineExtension("showHint",function(i){i=function(t,i,e){var n=t.options.hintOptions,o={};for(var s in a)o[s]=a[s];if(n)for(var s in n)void 0!==n[s]&&(o[s]=n[s]);if(e)for(var s in e)void 0!==e[s]&&(o[s]=e[s]);o.hint.resolve&&(o.hint=o.hint.resolve(t,i));return o}(this,this.getCursor("start"),i);var e=this.listSelections();if(!(e.length>1)){if(this.somethingSelected()){if(!i.hint.supportsSelection)return;for(var o=0;ol.clientHeight+1,x=h.getScrollInfo();if(C>0){var A=k.bottom-k.top;if(m.top-(m.bottom-k.top)-A>0)l.style.top=(v=m.top-A)+"px",y=!1;else if(A>H){l.style.height=H-5+"px",l.style.top=(v=m.bottom-k.top)+"px";var S=h.getCursor();o.from.ch!=S.ch&&(m=h.cursorCoords(S),l.style.left=(g=m.left)+"px",k=l.getBoundingClientRect())}}var T,M=k.right-w;if(M>0&&(k.right-k.left>w&&(l.style.width=w-5+"px",M-=k.right-k.left-w),l.style.left=(g=m.left-M)+"px"),b)for(var N=l.firstChild;N;N=N.nextSibling)N.style.paddingRight=h.display.nativeBarWidth+"px";(h.addKeyMap(this.keyMap=function(t,i){var e={Up:function(){i.moveFocus(-1)},Down:function(){i.moveFocus(1)},PageUp:function(){i.moveFocus(1-i.menuSize(),!0)},PageDown:function(){i.moveFocus(i.menuSize()-1,!0)},Home:function(){i.setFocus(0)},End:function(){i.setFocus(i.length-1)},Enter:i.pick,Tab:i.pick,Esc:i.close},n=t.options.customKeys,o=n?{}:e;function s(t,n){var s;s="string"!=typeof n?function(t){return n(t,i)}:e.hasOwnProperty(n)?e[n]:n,o[t]=s}if(n)for(var c in n)n.hasOwnProperty(c)&&s(c,n[c]);var r=t.options.extraKeys;if(r)for(var c in r)r.hasOwnProperty(c)&&s(c,r[c]);return o}(n,{moveFocus:function(t,i){s.changeActive(s.selectedHint+t,i)},setFocus:function(t){s.changeActive(t)},menuSize:function(){return s.screenAmount()},length:a.length,close:function(){n.close()},pick:function(){s.pick()},data:o})),n.options.closeOnUnfocus)&&(h.on("blur",this.onBlur=function(){T=setTimeout(function(){n.close()},100)}),h.on("focus",this.onFocus=function(){clearTimeout(T)}));return h.on("scroll",this.onScroll=function(){var t=h.getScrollInfo(),i=h.getWrapperElement().getBoundingClientRect(),e=v+x.top-t.top,o=e-(window.pageYOffset||(document.documentElement||document.body).scrollTop);if(y||(o+=l.offsetHeight),o<=i.top||o>=i.bottom)return n.close();l.style.top=e+"px",l.style.left=g+x.left-t.left+"px"}),t.on(l,"dblclick",function(t){var i=r(l,t.target||t.srcElement);i&&null!=i.hintId&&(s.changeActive(i.hintId),s.pick())}),t.on(l,"click",function(t){var i=r(l,t.target||t.srcElement);i&&null!=i.hintId&&(s.changeActive(i.hintId),n.options.completeOnSingleClick&&s.pick())}),t.on(l,"mousedown",function(){setTimeout(function(){h.focus()},20)}),t.signal(o,"select",a[this.selectedHint],l.childNodes[this.selectedHint]),!0}function l(t,i,e,n){if(t.async)t(i,n,e);else{var o=t(i,e);o&&o.then?o.then(n):n(o)}}n.prototype={close:function(){this.active()&&(this.cm.state.completionActive=null,this.tick=null,this.cm.off("cursorActivity",this.activityFunc),this.widget&&this.data&&t.signal(this.data,"close"),this.widget&&this.widget.close(),t.signal(this.cm,"endCompletion",this.cm))},active:function(){return this.cm.state.completionActive==this},pick:function(i,e){var n=i.list[e];n.hint?n.hint(this.cm,i,n):this.cm.replaceRange(c(n),n.from||i.from,n.to||i.to,"complete"),t.signal(i,"pick",n),this.close()},cursorActivity:function(){this.debounce&&(s(this.debounce),this.debounce=0);var t=this.cm.getCursor(),i=this.cm.getLine(t.line);if(t.line!=this.startPos.line||i.length-t.ch!=this.startLen-this.startPos.ch||t.ch=this.data.list.length?i=n?this.data.list.length-1:0:i<0&&(i=n?0:this.data.list.length-1),this.selectedHint!=i){var o=this.hints.childNodes[this.selectedHint];o.className=o.className.replace(" "+e,""),(o=this.hints.childNodes[this.selectedHint=i]).className+=" "+e,o.offsetTopthis.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=o.offsetTop+o.offsetHeight-this.hints.clientHeight+3),t.signal(this.data,"select",this.data.list[this.selectedHint],o)}},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1}},t.registerHelper("hint","auto",{resolve:function(i,e){var n,o=i.getHelpers(e,"hint");if(o.length){var s=function(t,i,e){var n=function(t,i){if(!t.somethingSelected())return i;for(var e=[],n=0;n0?i(t):o(s+1)})}(0)};return s.async=!0,s.supportsSelection=!0,s}return(n=i.getHelper(i.getCursor(),"hintWords"))?function(i){return t.hint.fromList(i,{words:n})}:t.hint.anyword?function(i,e){return t.hint.anyword(i,e)}:function(){}}}),t.registerHelper("hint","fromList",function(i,e){var n,o=i.getCursor(),s=i.getTokenAt(o),c=t.Pos(o.line,s.start),r=o;s.start,]/,closeOnUnfocus:!0,completeOnSingleClick:!0,container:null,customKeys:null,extraKeys:null};t.defineOption("hintOptions",null)}); diff --git a/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/xml-hint.js b/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/xml-hint.js new file mode 100644 index 000000000..4b8190141 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/xml-hint.js @@ -0,0 +1,3 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE +!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";var e=t.Pos;t.registerHelper("hint","xml",function(r,s){var n=s&&s.schemaInfo,a=s&&s.quoteChar||'"';if(n){var i=r.getCursor(),o=r.getTokenAt(i);o.end>i.ch&&(o.end=i.ch,o.string=o.string.slice(0,i.ch-o.start));var l=t.innerMode(r.getMode(),o.state);if("xml"==l.mode.name){var f,g,c=[],h=!1,p=/\btag\b/.test(o.type)&&!/>$/.test(o.string),u=p&&/^\w/.test(o.string);if(u){var d=r.getLine(i.line).slice(Math.max(0,o.start-2),o.start),m=/<\/$/.test(d)?"close":/<$/.test(d)?"open":null;m&&(g=o.start-("close"==m?2:1))}else p&&"<"==o.string?m="open":p&&"")}else{var w=(y=n[l.state.tagName])&&y.attrs,I=n["!attrs"];if(!w&&!I)return;if(w){if(I){var P={};for(var A in I)I.hasOwnProperty(A)&&(P[A]=I[A]);for(var A in w)w.hasOwnProperty(A)&&(P[A]=w[A]);w=P}}else w=I;if("string"==o.type||"="==o.string){var M,N=(d=r.getRange(e(i.line,Math.max(0,i.ch-60)),e(i.line,"string"==o.type?o.start:o.end))).match(/([^\s\u00a0=<>\"\']+)=$/);if(!N||!w.hasOwnProperty(N[1])||!(M=w[N[1]]))return;if("function"==typeof M&&(M=M.call(this,r)),"string"==o.type){f=o.string;var $=0;/['"]/.test(o.string.charAt(0))&&(a=o.string.charAt(0),f=o.string.slice(1),$++);var C=o.string.length;/['"]/.test(o.string.charAt(C-1))&&(a=o.string.charAt(C-1),f=o.string.substr($,C-2)),h=!0}for(O=0;O=0;c--){var h=o[c].head;t.replaceRange("",r(h.line,h.ch-1),r(h.line,h.ch+1),"+delete")}},Enter:function(t){var r=s(t),i=r&&n(r,"explode");if(!i||t.getOption("disableInput"))return e.Pass;for(var a=t.listSelections(),o=0;o1&&f.indexOf(i)>=0&&t.getRange(r(m.line,m.ch-2),m)==i+i){if(m.ch>2&&/\bstring/.test(t.getTokenTypeAt(r(m.line,m.ch-2))))return e.Pass;p="addFour"}else if(h){var C=0==m.ch?" ":t.getRange(r(m.line,m.ch-1),m);if(e.isWordChar(b)||C==i||e.isWordChar(C))return e.Pass;p="both"}else{if(!u||!(t.getLine(m.line).length==m.ch||(x=b,P=o,void 0,k=P.lastIndexOf(x),k>-1&&k%2==1)||/\s/.test(b)))return e.Pass;p="both"}else p=!h||(S=m,void 0,O=(y=t).getTokenAt(r(S.line,S.ch+1)),!/\bstring/.test(O.type)||O.start!=S.ch||0!=S.ch&&/\bstring/.test(y.getTokenTypeAt(S)))?f.indexOf(i)>=0&&t.getRange(m,r(m.line,m.ch+3))==i+i+i?"skipThree":"skip":"both";if(c){if(c!=p)return e.Pass}else c=p}var x,P,k;var y,S,O;var R=l%2?o.charAt(l-1):i,A=l%2?i:o.charAt(l+1);t.operation(function(){if("skip"==c)t.execCommand("goCharRight");else if("skipThree"==c)for(var n=0;n<3;n++)t.execCommand("goCharRight");else if("surround"==c){for(var i=t.getSelections(),n=0;n0,{anchor:new r(a.anchor.line,a.anchor.ch+(o?-1:1)),head:new r(a.head.line,a.head.ch+(o?1:-1))});t.setSelections(i)}else"both"==c?(t.replaceSelection(R+A,null),t.triggerElectric(R+A),t.execCommand("goCharLeft")):"addFour"==c&&(t.replaceSelection(R+R+R+R,"before"),t.execCommand("goCharRight"));var a,o})}(i,t)}}function s(e){var t=e.state.closeBrackets;return!t||t.override?t:e.getModeAt(e.getCursor()).closeBrackets||t}function l(e,t){var n=e.getRange(r(t.line,t.ch-1),r(t.line,t.ch+1));return 2==n.length?n:null}a(t.pairs+"`")}); \ No newline at end of file diff --git a/plugins/tiddlywiki/codemirror-closebrackets/files/addon/edit/matchbrackets.js b/plugins/tiddlywiki/codemirror-closebrackets/files/addon/edit/matchbrackets.js new file mode 100755 index 000000000..8852ea42f --- /dev/null +++ b/plugins/tiddlywiki/codemirror-closebrackets/files/addon/edit/matchbrackets.js @@ -0,0 +1,3 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE +!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){var e=/MSIE \d/.test(navigator.userAgent)&&(null==document.documentMode||document.documentMode<8),n=t.Pos,r={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"};function i(t,e,i){var c=t.getLineHandle(e.line),o=e.ch-1,l=i&&i.afterCursor;null==l&&(l=/(^| )cm-fat-cursor($| )/.test(t.getWrapperElement().className));var h=!l&&o>=0&&r[c.text.charAt(o)]||r[c.text.charAt(++o)];if(!h)return null;var s=">"==h.charAt(1)?1:-1;if(i&&i.strict&&s>0!=(o==e.ch))return null;var u=t.getTokenTypeAt(n(e.line,o+1)),f=a(t,n(e.line,o+(s>0?1:0)),s,u||null,i);return null==f?null:{from:n(e.line,o),to:f&&f.pos,match:f&&f.ch==h.charAt(0),forward:s>0}}function a(t,e,i,a,c){for(var o=c&&c.maxScanLineLength||1e4,l=c&&c.maxScanLines||1e3,h=[],s=c&&c.bracketRegex?c.bracketRegex:/[(){}[\]]/,u=i>0?Math.min(e.line+l,t.lastLine()+1):Math.max(t.firstLine()-1,e.line-l),f=e.line;f!=u;f+=i){var m=t.getLine(f);if(m){var g=i>0?0:m.length-1,d=i>0?m.length:-1;if(!(m.length>o))for(f==e.line&&(g=e.ch-(i<0?1:0));g!=d;g+=i){var k=m.charAt(g);if(s.test(k)&&(void 0===a||t.getTokenTypeAt(n(f,g+1))==a))if(">"==r[k].charAt(1)==i>0)h.push(k);else{if(!h.length)return{pos:n(f,g),ch:k};h.pop()}}}}return f-i!=(i>0?t.lastLine():t.firstLine())&&null}function c(t,r,a){for(var c=t.state.matchBrackets.maxHighlightLineLength||1e3,o=[],l=t.listSelections(),h=0;h'"]=function(o){return function(o){if(o.getOption("disableInput"))return e.Pass;for(var i=o.listSelections(),s=[],l=o.getOption("autoCloseTags"),d=0;dc.ch&&(v=v.slice(0,v.length-f.end+c.ch));var b=v.toLowerCase();if(!v||"string"==f.type&&(f.end!=c.ch||!/[\"\']/.test(f.string.charAt(f.string.length-1))||1==f.string.length)||"tag"==f.type&&"closeTag"==u.type||f.string.indexOf("/")==f.string.length-1||h&&a(h,b)>-1||r(o,v,c,u,!0))return e.Pass;var y=p&&a(p,b)>-1;s[d]={indent:y,text:">"+(y?"\n\n":"")+"",newPos:y?e.Pos(c.line+1,0):e.Pos(c.line,c.ch+1)}}for(var x="object"==typeof l&&l.dontIndentOnAutoClose,d=i.length-1;d>=0;d--){var P=s[d];o.replaceRange(P.text,i[d].head,i[d].anchor,"+insert");var T=o.listSelections().slice(0);T[d]={head:P.newPos,anchor:P.newPos},o.setSelections(T),!x&&P.indent&&(o.indentLine(P.newPos.line,null,!0),o.indentLine(P.newPos.line+1,null,!0))}}(o)}),i.addKeyMap(d)}});var t=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],n=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];function o(t,n){for(var o=t.listSelections(),a=[],i=n?"/":""!=t.getLine(f.line).charAt(g.end)&&(c+=">"),a[d]=c}if(t.replaceSelections(a),o=t.listSelections(),!l)for(d=0;d=e.max))return e.ch=0,e.text=e.cm.getLine(++e.line),!0}function o(e){if(!(e.line<=e.min))return e.text=e.cm.getLine(--e.line),e.ch=e.text.length,!0}function l(e){for(;;){var n=e.text.indexOf(">",e.ch);if(-1==n){if(f(e))continue;return}if(u(e,n+1)){var t=e.text.lastIndexOf("/",n),i=t>-1&&!/\S/.test(e.text.slice(t+1,n));return e.ch=n+1,i?"selfClose":"regular"}e.ch=n+1}}function c(e){for(;;){var n=e.ch?e.text.lastIndexOf("<",e.ch-1):-1;if(-1==n){if(o(e))continue;return}if(u(e,n+1)){i.lastIndex=n,e.ch=n;var t=i.exec(e.text);if(t&&t.index==n)return t}else e.ch=n}}function a(e){for(;;){i.lastIndex=e.ch;var n=i.exec(e.text);if(!n){if(f(e))continue;return}if(u(e,n.index+1))return e.ch=n.index+n[0].length,n;e.ch=n.index+1}}function s(e){for(;;){var n=e.ch?e.text.lastIndexOf(">",e.ch-1):-1;if(-1==n){if(o(e))continue;return}if(u(e,n+1)){var t=e.text.lastIndexOf("/",n),i=t>-1&&!/\S/.test(e.text.slice(t+1,n));return e.ch=n+1,i?"selfClose":"regular"}e.ch=n}}function h(e,t){for(var i=[];;){var r,u=a(e),f=e.line,o=e.ch-(u?u[0].length:0);if(!u||!(r=l(e)))return;if("selfClose"!=r)if(u[1]){for(var c=i.length-1;c>=0;--c)if(i[c]==u[2]){i.length=c;break}if(c<0&&(!t||t==u[2]))return{tag:u[2],from:n(f,o),to:n(e.line,e.ch)}}else i.push(u[2])}}function F(e,t){for(var i=[];;){var r=s(e);if(!r)return;if("selfClose"!=r){var u=e.line,f=e.ch,o=c(e);if(!o)return;if(o[1])i.push(o[2]);else{for(var l=i.length-1;l>=0;--l)if(i[l]==o[2]){i.length=l;break}if(l<0&&(!t||t==o[2]))return{tag:o[2],from:n(e.line,e.ch),to:n(u,f)}}}else c(e)}}e.registerHelper("fold","xml",function(e,t){for(var i=new r(e,t.line,0);;){var u,f=a(i);if(!f||!(u=l(i))||i.line!=t.line)return;if(!f[1]&&"selfClose"!=u){var o=n(i.line,i.ch),c=h(i,f[2]);return c&&{from:o,to:c.from}}}}),e.findMatchingTag=function(e,t,i){var u=new r(e,t.line,t.ch,i);if(-1!=u.text.indexOf(">")||-1!=u.text.indexOf("<")){var f=l(u),o=f&&n(u.line,u.ch),a=f&&c(u);if(f&&a&&(x=t,!(((s=u).line-x.line||s.ch-x.ch)>0))){var s,x,g={from:n(u.line,u.ch),to:o,tag:a[2]};return"selfClose"==f?{open:g,close:null,at:"open"}:a[1]?{open:F(u,a[2]),close:g,at:"close"}:{open:g,close:h(u=new r(e,o.line,o.ch,i),a[2]),at:"open"}}}},e.findEnclosingTag=function(e,n,t,i){for(var u=new r(e,n.line,n.ch,t);;){var f=F(u,i);if(!f)break;var o=h(new r(e,n.line,n.ch,t),f.tag);if(o)return{open:f,close:o}}},e.scanForClosingTag=function(e,n,t,i){return h(new r(e,n.line,n.ch,i?{from:0,to:i}:null),t)}}); \ No newline at end of file diff --git a/plugins/tiddlywiki/codemirror-closetag/files/tiddlywiki.files b/plugins/tiddlywiki/codemirror-closetag/files/tiddlywiki.files new file mode 100755 index 000000000..7f077e1f9 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-closetag/files/tiddlywiki.files @@ -0,0 +1,19 @@ +{ + "tiddlers": [ + { + "file": "addon/fold/xml-fold.js", + "fields": { + "type": "application/javascript", + "title": "$:/plugins/tiddlywiki/codemirror/addon/fold/xml-fold.js", + "module-type": "codemirror" + } + },{ + "file": "addon/edit/closetag.js", + "fields": { + "type": "application/javascript", + "title": "$:/plugins/tiddlywiki/codemirror/addon/edit/closetag.js", + "module-type": "codemirror" + } + } + ] +} diff --git a/plugins/tiddlywiki/codemirror-closetag/plugin.info b/plugins/tiddlywiki/codemirror-closetag/plugin.info new file mode 100755 index 000000000..81d404892 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-closetag/plugin.info @@ -0,0 +1,6 @@ +{ + "title": "$:/plugins/tiddlywiki/codemirror-closetag", + "description": "CodeMirror AddOn: Auto-Close Tags", + "author": "JeremyRuston", + "list": "readme" +} diff --git a/plugins/tiddlywiki/codemirror-closetag/readme.tid b/plugins/tiddlywiki/codemirror-closetag/readme.tid new file mode 100755 index 000000000..86be5bef1 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-closetag/readme.tid @@ -0,0 +1,5 @@ +title: $:/plugins/tiddlywiki/codemirror-closetag/readme + +This plugin adds the ability to ''automatically close Tags''. It needs the latest [[CodeMirror plugin|$:/plugins/tiddlywiki/codemirror]] to be installed + + diff --git a/plugins/tiddlywiki/codemirror-closetag/settings/autoCloseTags.tid b/plugins/tiddlywiki/codemirror-closetag/settings/autoCloseTags.tid new file mode 100644 index 000000000..a3247c6ff --- /dev/null +++ b/plugins/tiddlywiki/codemirror-closetag/settings/autoCloseTags.tid @@ -0,0 +1,9 @@ +title: $:/core/ui/ControlPanel/Settings/codemirror/autoCloseTags +tags: $:/tags/ControlPanel/Settings/CodeMirror +caption: {{$:/language/codemirror/autoCloseTags/hint}} + +\define lingo-base() $:/language/codemirror/autoCloseTags/ +<> + +<$checkbox tiddler="$:/config/codemirror/autoCloseTags" field="text" checked="true" unchecked="false" default="true"> <$link to="$:/config/codemirror/autoCloseTags"><> + diff --git a/plugins/tiddlywiki/codemirror-fullscreen-editing/config/fullscreen-editing.tid b/plugins/tiddlywiki/codemirror-fullscreen-editing/config/fullscreen-editing.tid new file mode 100644 index 000000000..2e4e5c2da --- /dev/null +++ b/plugins/tiddlywiki/codemirror-fullscreen-editing/config/fullscreen-editing.tid @@ -0,0 +1,7 @@ +title: $:/config/codemirror/fullscreen +extend: extraKeys +type: json + +{ + "F11": "togglefullscreen" +} \ No newline at end of file diff --git a/plugins/tiddlywiki/codemirror-fullscreen-editing/files/addon/fullscreen/fullscreen.css b/plugins/tiddlywiki/codemirror-fullscreen-editing/files/addon/fullscreen/fullscreen.css new file mode 100644 index 000000000..437acd89b --- /dev/null +++ b/plugins/tiddlywiki/codemirror-fullscreen-editing/files/addon/fullscreen/fullscreen.css @@ -0,0 +1,6 @@ +.CodeMirror-fullscreen { + position: fixed; + top: 0; left: 0; right: 0; bottom: 0; + height: auto; + z-index: 9; +} diff --git a/plugins/tiddlywiki/codemirror-fullscreen-editing/files/addon/fullscreen/fullscreen.js b/plugins/tiddlywiki/codemirror-fullscreen-editing/files/addon/fullscreen/fullscreen.js new file mode 100644 index 000000000..a70760d4c --- /dev/null +++ b/plugins/tiddlywiki/codemirror-fullscreen-editing/files/addon/fullscreen/fullscreen.js @@ -0,0 +1,3 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE +!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.defineOption("fullScreen",!1,function(t,l,o){var r,n;(o==e.Init&&(o=!1),!o!=!l)&&(l?(n=(r=t).getWrapperElement(),r.state.fullScreenRestore={scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,width:n.style.width,height:n.style.height},n.style.width="",n.style.height="auto",n.className+=" CodeMirror-fullscreen",document.documentElement.style.overflow="hidden",r.refresh()):function(e){var t=e.getWrapperElement();t.className=t.className.replace(/\s*CodeMirror-fullscreen\b/,""),document.documentElement.style.overflow="";var l=e.state.fullScreenRestore;t.style.width=l.width,t.style.height=l.height,window.scrollTo(l.scrollLeft,l.scrollTop),e.refresh()}(t))}),e.toggleFullscreen=function(e){e.setOption("fullScreen",!e.getOption("fullScreen"))},e.commands.togglefullscreen=e.toggleFullscreen}); \ No newline at end of file diff --git a/plugins/tiddlywiki/codemirror-fullscreen-editing/files/tiddlywiki.files b/plugins/tiddlywiki/codemirror-fullscreen-editing/files/tiddlywiki.files new file mode 100755 index 000000000..b0835e8c9 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-fullscreen-editing/files/tiddlywiki.files @@ -0,0 +1,19 @@ +{ + "tiddlers": [ + { + "file": "addon/fullscreen/fullscreen.js", + "fields": { + "type": "application/javascript", + "title": "$:/plugins/tiddlywiki/codemirror/addon/fullscreen/fullscreen.js", + "module-type": "codemirror" + } + },{ + "file": "addon/fullscreen/fullscreen.css", + "fields": { + "type": "text/css", + "title": "$:/plugins/tiddlywiki/codemirror/addon/fullscreen/fullscreen.css", + "tags": "[[$:/tags/Stylesheet]]" + } + } + ] +} diff --git a/plugins/tiddlywiki/codemirror-fullscreen-editing/plugin.info b/plugins/tiddlywiki/codemirror-fullscreen-editing/plugin.info new file mode 100755 index 000000000..e95e5cc29 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-fullscreen-editing/plugin.info @@ -0,0 +1,6 @@ +{ + "title": "$:/plugins/tiddlywiki/codemirror-fullscreen", + "description": "CodeMirror AddOn: Fullscreen Editing", + "author": "JeremyRuston", + "list": "readme" +} diff --git a/plugins/tiddlywiki/codemirror-fullscreen-editing/readme.tid b/plugins/tiddlywiki/codemirror-fullscreen-editing/readme.tid new file mode 100755 index 000000000..8611b3aea --- /dev/null +++ b/plugins/tiddlywiki/codemirror-fullscreen-editing/readme.tid @@ -0,0 +1,6 @@ +title: $:/plugins/tiddlywiki/codemirror-fullscreen/readme + +This plugin adds a ''Fullscreen editing Mode'' to the [[CodeMirror|http://codemirror.net]] text editor. It needs the latest [[CodeMirror plugin|$:/plugins/tiddlywiki/codemirror]] to be installed + +Pressing ''F11'' with the focus within the editor-textarea will make the editor go fullscreen, pressing ''F11'' again leaves fullscreen-mode + diff --git a/plugins/tiddlywiki/codemirror-keymap-emacs/config/keyMap.tid b/plugins/tiddlywiki/codemirror-keymap-emacs/config/keyMap.tid new file mode 100644 index 000000000..70187148f --- /dev/null +++ b/plugins/tiddlywiki/codemirror-keymap-emacs/config/keyMap.tid @@ -0,0 +1,4 @@ +title: $:/plugins/tiddlywiki/codemirror/keymaps/emacs +module-type: codemirror-keymap + +emacs diff --git a/plugins/tiddlywiki/codemirror-keymap-emacs/files/keymap/emacs.js b/plugins/tiddlywiki/codemirror-keymap-emacs/files/keymap/emacs.js new file mode 100755 index 000000000..d37e0032f --- /dev/null +++ b/plugins/tiddlywiki/codemirror-keymap-emacs/files/keymap/emacs.js @@ -0,0 +1,3 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE +!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../lib/codemirror")):"function"==typeof define&&define.amd?define(["../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";var e=t.Pos;function n(t,e){return t.line==e.line&&t.ch==e.ch}var r=[];function o(t){r.push(t),r.length>50&&r.shift()}function i(t){return r[r.length-(t?Math.min(t,1):1)]||""}var l=null;function a(t,e,i,a,c){null==c&&(c=t.getRange(e,i)),"grow"==a&&l&&l.cm==t&&n(e,l.pos)&&t.isClean(l.gen)?function(t){if(!r.length)return o(t);r[r.length-1]+=t}(c):!1!==a&&o(c),t.replaceRange("",e,i,"+delete"),l="grow"==a?{cm:t,pos:e,gen:t.changeGeneration()}:null}function c(t,e,n){return t.findPosH(e,n,"char",!0)}function u(t,e,n){return t.findPosH(e,n,"word",!0)}function f(t,e,n){return t.findPosV(e,n,"line",t.doc.sel.goalColumn)}function s(t,e,n){return t.findPosV(e,n,"page",t.doc.sel.goalColumn)}function g(t,n,r){for(var o=n.line,i=t.getLine(o),l=/\S/.test(r<0?i.slice(0,n.ch):i.slice(n.ch)),a=t.firstLine(),c=t.lastLine();;){if((o+=r)c)return t.clipPos(e(o-r,r<0?0:null));if(i=t.getLine(o),/\S/.test(i))l=!0;else if(l)return e(o,0)}}function C(t,n,r){for(var o=n.line,i=n.ch,l=t.getLine(n.line),a=!1;;){var c=l.charAt(i+(r<0?-1:0));if(c){if(a&&/[!?.]/.test(c))return e(o,i+(r>0?1:0));a||(a=/\w/.test(c)),i+=r}else{if(o==(r<0?t.firstLine():t.lastLine()))return e(o,i);if(l=t.getLine(o+r),!/\S/.test(l))return e(o,i);o+=r,i=r<0?l.length:0}}}function d(t,r,o){var i;if(t.findMatchingBracket&&(i=t.findMatchingBracket(r,{strict:!0}))&&i.match&&(i.forward?1:-1)==o)return o>0?e(i.to.line,i.to.ch+1):i.to;for(var l=!0;;l=!1){var a=t.getTokenAt(r),c=e(r.line,o<0?a.start:a.end);if(!(l&&o>0&&a.end==r.ch)&&/\w/.test(a.string))return c;var u=t.findPosH(c,o,"char");if(n(c,u))return r;r=u}}function p(t,e){var n=t.state.emacsPrefix;return n?(L(t),"-"==n?-1:Number(n)):e?null:1}function h(t){var e="string"==typeof t?function(e){e.execCommand(t)}:t;return function(t){var n=p(t);e(t);for(var r=1;r1&&"+input"==e.origin){for(var r=e.text.join("\n"),o="",i=1;i1&&r.pop(),i()),"around","paste")},"Ctrl-Space":k,"Ctrl-Shift-2":k,"Ctrl-F":m(c,1),"Ctrl-B":m(c,-1),Right:m(c,1),Left:m(c,-1),"Ctrl-D":function(t){A(t,c,1,!1)},Delete:function(t){S(t,!1)||A(t,c,1,!1)},"Ctrl-H":function(t){A(t,c,-1,!1)},Backspace:function(t){S(t,!1)||A(t,c,-1,!1)},"Alt-F":m(u,1),"Alt-B":m(u,-1),"Alt-D":function(t){A(t,u,1,"grow")},"Alt-Backspace":function(t){A(t,u,-1,"grow")},"Ctrl-N":m(f,1),"Ctrl-P":m(f,-1),Down:m(f,1),Up:m(f,-1),"Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd",End:"goLineEnd",Home:"goLineStart","Alt-V":m(s,-1),"Ctrl-V":m(s,1),PageUp:m(s,-1),PageDown:m(s,1),"Ctrl-Up":m(g,-1),"Ctrl-Down":m(g,1),"Alt-A":m(C,-1),"Alt-E":m(C,1),"Alt-K":function(t){A(t,C,1,"grow")},"Ctrl-Alt-K":function(t){A(t,d,1,"grow")},"Ctrl-Alt-Backspace":function(t){A(t,d,-1,"grow")},"Ctrl-Alt-F":m(d,1),"Ctrl-Alt-B":m(d,-1),"Shift-Ctrl-Alt-2":function(t){var e=t.getCursor();t.setSelection(v(t,e,d,1),e)},"Ctrl-Alt-T":function(t){var e=d(t,t.getCursor(),-1),n=d(t,e,1),r=d(t,n,1),o=d(t,r,-1);t.replaceRange(t.getRange(o,r)+t.getRange(n,o)+t.getRange(e,n),e,r)},"Ctrl-Alt-U":h(function(t){for(var n=t.getCursor(),r=n.line,o=n.ch,i=[];r>=t.firstLine();){for(var l=t.getLine(r),a=null==o?l.length:o;a>0;)if(")"==(o=l.charAt(--a)))i.push("(");else if("]"==o)i.push("[");else if("}"==o)i.push("{");else if(/[\(\{\[]/.test(o)&&(!i.length||i.pop()!=o))return t.extendSelection(e(r,a));--r,o=null}}),"Alt-Space":function(t){for(var n=t.getCursor(),r=n.ch,o=n.ch,i=t.getLine(n.line);r&&/\s/.test(i.charAt(r-1));)--r;for(;o0)return t.setCursor(o-1);n="Goto line",r=function(e){var n;e&&!isNaN(n=Number(e))&&n==(0|n)&&n>0&&t.setCursor(n-1)},(e=t).openDialog?e.openDialog(n+': ',r,{bottom:!0}):r(prompt(n,""))},"Ctrl-X Tab":function(t){t.indentSelection(p(t,!0)||t.getOption("indentUnit"))},"Ctrl-X Ctrl-X":function(t){t.setSelection(t.getCursor("head"),t.getCursor("anchor"))},"Ctrl-X Ctrl-S":"save","Ctrl-X Ctrl-W":"save","Ctrl-X S":"saveAll","Ctrl-X F":"open","Ctrl-X U":h("undo"),"Ctrl-X K":"close","Ctrl-X Delete":function(t){a(t,t.getCursor(),C(t,t.getCursor(),1),"grow")},"Ctrl-X H":"selectAll","Ctrl-Q Tab":h("insertTab"),"Ctrl-U":function(t){t.state.emacsPrefixMap=!0,t.addKeyMap(D),t.on("keyHandled",y),t.on("inputRead",y)}}),D={"Ctrl-G":L};function E(t){D[t]=function(e){P(e,t)},X["Ctrl-"+t]=function(e){P(e,t)},w["Ctrl-"+t]=!0}for(var H=0;H<10;++H)E(String(H));E("-")}); \ No newline at end of file diff --git a/plugins/tiddlywiki/codemirror-keymap-emacs/files/tiddlywiki.files b/plugins/tiddlywiki/codemirror-keymap-emacs/files/tiddlywiki.files new file mode 100755 index 000000000..b54049eba --- /dev/null +++ b/plugins/tiddlywiki/codemirror-keymap-emacs/files/tiddlywiki.files @@ -0,0 +1,12 @@ +{ + "tiddlers": [ + { + "file": "keymap/emacs.js", + "fields": { + "type": "application/javascript", + "title": "$:/plugins/tiddlywiki/codemirror/keymap/emacs.js", + "module-type": "codemirror" + } + } + ] +} diff --git a/plugins/tiddlywiki/codemirror-keymap-emacs/plugin.info b/plugins/tiddlywiki/codemirror-keymap-emacs/plugin.info new file mode 100755 index 000000000..7844a4932 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-keymap-emacs/plugin.info @@ -0,0 +1,6 @@ +{ + "title": "$:/plugins/tiddlywiki/codemirror-keymap-emacs", + "description": "CodeMirror Keymap: Emacs", + "author": "JeremyRuston", + "list": "readme" +} diff --git a/plugins/tiddlywiki/codemirror-keymap-emacs/readme.tid b/plugins/tiddlywiki/codemirror-keymap-emacs/readme.tid new file mode 100644 index 000000000..7553ac1a5 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-keymap-emacs/readme.tid @@ -0,0 +1,5 @@ +title: $:/plugins/tiddlywiki/codemirror-keymap-emacs/readme + +This plugin adds a ''Keymap'' with some of the most important ''Emacs'' keyboard shortcuts + +For more information about available ''keyboard shortcuts'' see the [ext[CodeMirror emacs demo|https://codemirror.net/demo/emacs.html]] diff --git a/plugins/tiddlywiki/codemirror-keymap-sublime-text/config/extraKeysTW.tid b/plugins/tiddlywiki/codemirror-keymap-sublime-text/config/extraKeysTW.tid new file mode 100644 index 000000000..23aba1bde --- /dev/null +++ b/plugins/tiddlywiki/codemirror-keymap-sublime-text/config/extraKeysTW.tid @@ -0,0 +1,24 @@ +title: $:/config/codemirror/extraKeysTW +extend: extraKeys +type: json + +{ + "Ctrl-M": "", + "Alt-M": "goToBracket", + "Ctrl-Enter": "", + "Shift-Enter": "insertLineAfter", + "Esc": "", + "Ctrl-Esc": "singleSelectionTop", + "Ctrl-L": "", + "Shift-Ctrl-L": "", + "Alt-L": "selectLine", + "Shift-Alt-L": "splitSelectionByLine", + "Ctrl-T": "", + "Alt-T": "transposeChars", + "Ctrl-K Ctrl-U": "", + "Ctrl-K Ctrl-L": "", + "Ctrl-K Ctrl-W": "", + "Ctrl-K Alt-U": "upcaseAtCursor", + "Ctrl-K Alt-L": "downcaseAtCursor", + "Ctrl-K Alt-D": "deleteToSublimeMark" +} diff --git a/plugins/tiddlywiki/codemirror-keymap-sublime-text/config/keyMap.tid b/plugins/tiddlywiki/codemirror-keymap-sublime-text/config/keyMap.tid new file mode 100644 index 000000000..a65e1ef35 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-keymap-sublime-text/config/keyMap.tid @@ -0,0 +1,4 @@ +title: $:/plugins/tiddlywiki/codemirror/keymaps/sublime +module-type: codemirror-keymap + +sublime diff --git a/plugins/tiddlywiki/codemirror-keymap-sublime-text/files/keymap/sublime.js b/plugins/tiddlywiki/codemirror-keymap-sublime-text/files/keymap/sublime.js new file mode 100755 index 000000000..fca70db15 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-keymap-sublime-text/files/keymap/sublime.js @@ -0,0 +1,3 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE +!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../lib/codemirror"),require("../addon/search/searchcursor"),require("../addon/edit/matchbrackets")):"function"==typeof define&&define.amd?define(["../lib/codemirror","../addon/search/searchcursor","../addon/edit/matchbrackets"],e):e(CodeMirror)}(function(e){"use strict";var t=e.commands,n=e.Pos;function r(t,r){t.extendSelectionsBy(function(o){return t.display.shift||t.doc.extend||o.empty()?function(t,r,o){if(o<0&&0==r.ch)return t.clipPos(n(r.line-1));var i=t.getLine(r.line);if(o>0&&r.ch>=i.length)return t.clipPos(n(r.line+1,0));for(var l,a="start",s=r.ch,c=o<0?0:i.length,f=0;s!=c;s+=o,f++){var u=i.charAt(o<0?s-1:s),d="_"!=u&&e.isWordChar(u)?"w":"o";if("w"==d&&u.toUpperCase()==u&&(d="W"),"start"==a)"o"!=d&&(a="in",l=d);else if("in"==a&&l!=d){if("w"==l&&"W"==d&&o<0&&s--,"W"==l&&"w"==d&&o>0){l="w";continue}break}}return n(r.line,s)}(t.doc,o.head,r):r<0?o.from():o.to()})}function o(t,r){if(t.isReadOnly())return e.Pass;t.operation(function(){for(var e=t.listSelections().length,o=[],i=-1,l=0;l=n&&e.execCommand("goLineUp")}e.scrollTo(null,t.top-e.defaultTextHeight())},t.scrollLineDown=function(e){var t=e.getScrollInfo();if(!e.somethingSelected()){var n=e.lineAtHeight(t.top,"local")+1;e.getCursor().line<=n&&e.execCommand("goLineDown")}e.scrollTo(null,t.top+e.defaultTextHeight())},t.splitSelectionByLine=function(e){for(var t=e.listSelections(),r=[],o=0;oi.line&&a==l.line&&0==l.ch||r.push({anchor:a==i.line?i:n(a,0),head:a==l.line?l:n(a)});e.setSelections(r,0)},t.singleSelectionTop=function(e){var t=e.listSelections()[0];e.setSelection(t.anchor,t.head,{scroll:!1})},t.selectLine=function(e){for(var t=e.listSelections(),r=[],o=0;o=0;a--){var c=r[o[a]];if(!(s&&e.cmpPos(c.head,s)>0)){var f=i(t,c.head);s=f.from,t.replaceRange(n(f.word),f.from,f.to)}}})}function u(t){var n=t.getCursor("from"),r=t.getCursor("to");if(0==e.cmpPos(n,r)){var o=i(t,n);if(!o.word)return;n=o.from,r=o.to}return{from:n,to:r,query:t.getRange(n,r),word:o}}function d(e,t){var r=u(e);if(r){var o=r.query,i=e.getSearchCursor(o,t?r.to:r.from);(t?i.findNext():i.findPrevious())?e.setSelection(i.from(),i.to()):(i=e.getSearchCursor(o,t?n(e.firstLine(),0):e.clipPos(n(e.lastLine()))),(t?i.findNext():i.findPrevious())?e.setSelection(i.from(),i.to()):r.word&&e.setSelection(r.from,r.to))}}t.selectScope=function(e){s(e)||e.execCommand("selectAll")},t.selectBetweenBrackets=function(t){if(!s(t))return e.Pass},t.goToBracket=function(t){t.extendSelectionsBy(function(r){var o=t.scanForBracket(r.head,1);if(o&&0!=e.cmpPos(o.pos,r.head))return o.pos;var i=t.scanForBracket(r.head,-1);return i&&n(i.pos.line,i.pos.ch+1)||r.head})},t.swapLineUp=function(t){if(t.isReadOnly())return e.Pass;for(var r=t.listSelections(),o=[],i=t.firstLine()-1,l=[],a=0;ai?o.push(c,f):o.length&&(o[o.length-1]=f),i=f}t.operation(function(){for(var e=0;et.lastLine()?t.replaceRange("\n"+a,n(t.lastLine()),null,"+swapLine"):t.replaceRange(a+"\n",n(i,0),null,"+swapLine")}t.setSelections(l),t.scrollIntoView()})},t.swapLineDown=function(t){if(t.isReadOnly())return e.Pass;for(var r=t.listSelections(),o=[],i=t.lastLine()+1,l=r.length-1;l>=0;l--){var a=r[l],s=a.to().line+1,c=a.from().line;0!=a.to().ch||a.empty()||s--,s=0;e-=2){var r=o[e],i=o[e+1],l=t.getLine(r);r==t.lastLine()?t.replaceRange("",n(r-1),n(r),"+swapLine"):t.replaceRange("",n(r,0),n(r+1,0),"+swapLine"),t.replaceRange(l+"\n",n(i,0),null,"+swapLine")}t.scrollIntoView()})},t.toggleCommentIndented=function(e){e.toggleComment({indent:!0})},t.joinLines=function(e){for(var t=e.listSelections(),r=[],o=0;o=0;i--){var l=r[i].head,a=t.getRange({line:l.line,ch:0},l),s=e.countColumn(a,null,t.getOption("tabSize")),c=t.findPosH(l,-1,"char",!1);if(a&&!/\S/.test(a)&&s%o==0){var f=new n(l.line,e.findColumn(a,s-o,o));f.ch!=l.ch&&(c=f)}t.replaceRange("",c,l,"+delete")}})},t.delLineRight=function(e){e.operation(function(){for(var t=e.listSelections(),r=t.length-1;r>=0;r--)e.replaceRange("",t[r].anchor,n(t[r].to().line),"+delete");e.scrollIntoView()})},t.upcaseAtCursor=function(e){f(e,function(e){return e.toUpperCase()})},t.downcaseAtCursor=function(e){f(e,function(e){return e.toLowerCase()})},t.setSublimeMark=function(e){e.state.sublimeMark&&e.state.sublimeMark.clear(),e.state.sublimeMark=e.setBookmark(e.getCursor())},t.selectToSublimeMark=function(e){var t=e.state.sublimeMark&&e.state.sublimeMark.find();t&&e.setSelection(e.getCursor(),t)},t.deleteToSublimeMark=function(t){var n=t.state.sublimeMark&&t.state.sublimeMark.find();if(n){var r=t.getCursor(),o=n;if(e.cmpPos(r,o)>0){var i=o;o=r,r=i}t.state.sublimeKilled=t.getRange(r,o),t.replaceRange("",r,o)}},t.swapWithSublimeMark=function(e){var t=e.state.sublimeMark&&e.state.sublimeMark.find();t&&(e.state.sublimeMark.clear(),e.state.sublimeMark=e.setBookmark(e.getCursor()),e.setCursor(t))},t.sublimeYank=function(e){null!=e.state.sublimeKilled&&e.replaceSelection(e.state.sublimeKilled,null,"paste")},t.showInCenter=function(e){var t=e.cursorCoords(null,"local");e.scrollTo(null,(t.top+t.bottom)/2-e.getScrollInfo().clientHeight/2)},t.findUnder=function(e){d(e,!0)},t.findUnderPrevious=function(e){d(e,!1)},t.findAllUnder=function(e){var t=u(e);if(t){for(var n=e.getSearchCursor(t.query),r=[],o=-1;n.findNext();)r.push({anchor:n.from(),head:n.to()}),n.from().line<=t.from.line&&n.from().ch<=t.from.ch&&o++;e.setSelections(r,o)}};var m=e.keyMap;m.macSublime={"Cmd-Left":"goLineStartSmart","Shift-Tab":"indentLess","Shift-Ctrl-K":"deleteLine","Alt-Q":"wrapLines","Ctrl-Left":"goSubwordLeft","Ctrl-Right":"goSubwordRight","Ctrl-Alt-Up":"scrollLineUp","Ctrl-Alt-Down":"scrollLineDown","Cmd-L":"selectLine","Shift-Cmd-L":"splitSelectionByLine",Esc:"singleSelectionTop","Cmd-Enter":"insertLineAfter","Shift-Cmd-Enter":"insertLineBefore","Cmd-D":"selectNextOccurrence","Shift-Cmd-Space":"selectScope","Shift-Cmd-M":"selectBetweenBrackets","Cmd-M":"goToBracket","Cmd-Ctrl-Up":"swapLineUp","Cmd-Ctrl-Down":"swapLineDown","Cmd-/":"toggleCommentIndented","Cmd-J":"joinLines","Shift-Cmd-D":"duplicateLine",F9:"sortLines","Cmd-F9":"sortLinesInsensitive",F2:"nextBookmark","Shift-F2":"prevBookmark","Cmd-F2":"toggleBookmark","Shift-Cmd-F2":"clearBookmarks","Alt-F2":"selectBookmarks",Backspace:"smartBackspace","Cmd-K Cmd-K":"delLineRight","Cmd-K Cmd-U":"upcaseAtCursor","Cmd-K Cmd-L":"downcaseAtCursor","Cmd-K Cmd-Space":"setSublimeMark","Cmd-K Cmd-A":"selectToSublimeMark","Cmd-K Cmd-W":"deleteToSublimeMark","Cmd-K Cmd-X":"swapWithSublimeMark","Cmd-K Cmd-Y":"sublimeYank","Cmd-K Cmd-C":"showInCenter","Cmd-K Cmd-G":"clearBookmarks","Cmd-K Cmd-Backspace":"delLineLeft","Cmd-K Cmd-0":"unfoldAll","Cmd-K Cmd-J":"unfoldAll","Ctrl-Shift-Up":"addCursorToPrevLine","Ctrl-Shift-Down":"addCursorToNextLine","Cmd-F3":"findUnder","Shift-Cmd-F3":"findUnderPrevious","Alt-F3":"findAllUnder","Shift-Cmd-[":"fold","Shift-Cmd-]":"unfold","Cmd-I":"findIncremental","Shift-Cmd-I":"findIncrementalReverse","Cmd-H":"replace",F3:"findNext","Shift-F3":"findPrev",fallthrough:"macDefault"},e.normalizeKeyMap(m.macSublime),m.pcSublime={"Shift-Tab":"indentLess","Shift-Ctrl-K":"deleteLine","Alt-Q":"wrapLines","Ctrl-T":"transposeChars","Alt-Left":"goSubwordLeft","Alt-Right":"goSubwordRight","Ctrl-Up":"scrollLineUp","Ctrl-Down":"scrollLineDown","Ctrl-L":"selectLine","Shift-Ctrl-L":"splitSelectionByLine",Esc:"singleSelectionTop","Ctrl-Enter":"insertLineAfter","Shift-Ctrl-Enter":"insertLineBefore","Ctrl-D":"selectNextOccurrence","Shift-Ctrl-Space":"selectScope","Shift-Ctrl-M":"selectBetweenBrackets","Ctrl-M":"goToBracket","Shift-Ctrl-Up":"swapLineUp","Shift-Ctrl-Down":"swapLineDown","Ctrl-/":"toggleCommentIndented","Ctrl-J":"joinLines","Shift-Ctrl-D":"duplicateLine",F9:"sortLines","Ctrl-F9":"sortLinesInsensitive",F2:"nextBookmark","Shift-F2":"prevBookmark","Ctrl-F2":"toggleBookmark","Shift-Ctrl-F2":"clearBookmarks","Alt-F2":"selectBookmarks",Backspace:"smartBackspace","Ctrl-K Ctrl-K":"delLineRight","Ctrl-K Ctrl-U":"upcaseAtCursor","Ctrl-K Ctrl-L":"downcaseAtCursor","Ctrl-K Ctrl-Space":"setSublimeMark","Ctrl-K Ctrl-A":"selectToSublimeMark","Ctrl-K Ctrl-W":"deleteToSublimeMark","Ctrl-K Ctrl-X":"swapWithSublimeMark","Ctrl-K Ctrl-Y":"sublimeYank","Ctrl-K Ctrl-C":"showInCenter","Ctrl-K Ctrl-G":"clearBookmarks","Ctrl-K Ctrl-Backspace":"delLineLeft","Ctrl-K Ctrl-0":"unfoldAll","Ctrl-K Ctrl-J":"unfoldAll","Ctrl-Alt-Up":"addCursorToPrevLine","Ctrl-Alt-Down":"addCursorToNextLine","Ctrl-F3":"findUnder","Shift-Ctrl-F3":"findUnderPrevious","Alt-F3":"findAllUnder","Shift-Ctrl-[":"fold","Shift-Ctrl-]":"unfold","Ctrl-I":"findIncremental","Shift-Ctrl-I":"findIncrementalReverse","Ctrl-H":"replace",F3:"findNext","Shift-F3":"findPrev",fallthrough:"pcDefault"},e.normalizeKeyMap(m.pcSublime);var h=m.default==m.macDefault;m.sublime=h?m.macSublime:m.pcSublime}); \ No newline at end of file diff --git a/plugins/tiddlywiki/codemirror-keymap-sublime-text/files/tiddlywiki.files b/plugins/tiddlywiki/codemirror-keymap-sublime-text/files/tiddlywiki.files new file mode 100755 index 000000000..236899789 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-keymap-sublime-text/files/tiddlywiki.files @@ -0,0 +1,12 @@ +{ + "tiddlers": [ + { + "file": "keymap/sublime.js", + "fields": { + "type": "application/javascript", + "title": "$:/plugins/tiddlywiki/codemirror/keymap/sublime.js", + "module-type": "codemirror" + } + } + ] +} diff --git a/plugins/tiddlywiki/codemirror-keymap-sublime-text/plugin.info b/plugins/tiddlywiki/codemirror-keymap-sublime-text/plugin.info new file mode 100755 index 000000000..5be49fd36 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-keymap-sublime-text/plugin.info @@ -0,0 +1,6 @@ +{ + "title": "$:/plugins/tiddlywiki/codemirror-keymap-sublime-text", + "description": "CodeMirror Keymap: Sublime Text", + "author": "JeremyRuston", + "list": "readme" +} diff --git a/plugins/tiddlywiki/codemirror-keymap-sublime-text/readme.tid b/plugins/tiddlywiki/codemirror-keymap-sublime-text/readme.tid new file mode 100644 index 000000000..394a9f89b --- /dev/null +++ b/plugins/tiddlywiki/codemirror-keymap-sublime-text/readme.tid @@ -0,0 +1,58 @@ +title: $:/plugins/tiddlywiki/codemirror-keymap-sublime-text/readme + +This plugin adds a ''Keymap'' with the most important ''Sublime Text'' keyboard shortcuts + +Shortcuts that interfere with ~TiddlyWiki shortcuts differ from the original sublime shortcuts to preserve functionality + + +|Shortcut |Function |h +|Shift-Tab |indentLess | +|Shift-Ctrl-K |deleteLine | +|Alt-Q |wrapLines | +|Alt-T |transposeChars | +|Alt-Left |goSubwordLeft | +|Alt-Right |goSubwordRight | +|Ctrl-Up |scrollLineUp | +|Ctrl-Down |scrollLineDown | +|Alt-L |selectLine | +|Shift-Alt-L |splitSelectionByLine | +|Ctrl-Esc |singleSelectionTop | +|Shift-Enter |insertLineAfter | +|Shift-Ctrl-Enter |insertLineBefore | +|Ctrl-D |selectNextOccurrence | +|Shift-Ctrl-Space |selectScope | +|Shift-Ctrl-M |selectBetweenBrackets | +|Alt-M |goToBracket | +|Shift-Ctrl-Up |swapLineUp | +|Shift-Ctrl-Down |swapLineDown | +|Ctrl-/ |toggleCommentIndented | +|Ctrl-J |joinLines | +|Shift-Ctrl-D |duplicateLine | +|F9 |sortLines | +|Ctrl-F9 |sortLinesInsensitive | +|F2 |nextBookmark | +|Shift-F2 |prevBookmark | +|Ctrl-F2 |toggleBookmark | +|Shift-Ctrl-F2 |clearBookmarks | +|Alt-F2 |selectBookmarks | +|Backspace |smartBackspace | +|Ctrl-K Ctrl-K |delLineRight | +|Ctrl-K Alt-U |upcaseAtCursor | +|Ctrl-K Alt-L |downcaseAtCursor | +|Ctrl-K Ctrl-Space |setSublimeMark | +|Ctrl-K Ctrl-A |selectToSublimeMark | +|Ctrl-K Alt-D |deleteToSublimeMark | +|Ctrl-K Ctrl-X |swapWithSublimeMark | +|Ctrl-K Ctrl-Y |sublimeYank | +|Ctrl-K Ctrl-C |showInCenter | +|Ctrl-K Ctrl-G |clearBookmarks | +|Ctrl-K Ctrl-Backspace |delLineLeft | +|Ctrl-K Ctrl-0 |unfoldAll | +|Ctrl-K Ctrl-J |unfoldAll | +|Ctrl-Alt-Up |addCursorToPrevLine | +|Ctrl-Alt-Down |addCursorToNextLine | +|Ctrl-F3 |findUnder | +|Shift-Ctrl-F3 |findUnderPrevious | +|Shift-Ctrl-[ |fold | +|Shift-Ctrl-] |unfold | +|Ctrl-H |replace | diff --git a/plugins/tiddlywiki/codemirror-keymap-vim/config/keyMap.tid b/plugins/tiddlywiki/codemirror-keymap-vim/config/keyMap.tid new file mode 100644 index 000000000..4f545009a --- /dev/null +++ b/plugins/tiddlywiki/codemirror-keymap-vim/config/keyMap.tid @@ -0,0 +1,4 @@ +title: $:/plugins/tiddlywiki/codemirror/keymaps/vim +module-type: codemirror-keymap + +vim diff --git a/plugins/tiddlywiki/codemirror-keymap-vim/files/keymap/vim.js b/plugins/tiddlywiki/codemirror-keymap-vim/files/keymap/vim.js new file mode 100755 index 000000000..1c53fc7b2 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-keymap-vim/files/keymap/vim.js @@ -0,0 +1,3 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE +!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../lib/codemirror"),require("../addon/search/searchcursor"),require("../addon/dialog/dialog"),require("../addon/edit/matchbrackets.js")):"function"==typeof define&&define.amd?define(["../lib/codemirror","../addon/search/searchcursor","../addon/dialog/dialog","../addon/edit/matchbrackets"],e):e(CodeMirror)}(function(e){"use strict";var t=[{keys:"",type:"keyToKey",toKeys:"h"},{keys:"",type:"keyToKey",toKeys:"l"},{keys:"",type:"keyToKey",toKeys:"k"},{keys:"",type:"keyToKey",toKeys:"j"},{keys:"",type:"keyToKey",toKeys:"l"},{keys:"",type:"keyToKey",toKeys:"h",context:"normal"},{keys:"",type:"keyToKey",toKeys:"W"},{keys:"",type:"keyToKey",toKeys:"B",context:"normal"},{keys:"",type:"keyToKey",toKeys:"w"},{keys:"",type:"keyToKey",toKeys:"b",context:"normal"},{keys:"",type:"keyToKey",toKeys:"j"},{keys:"",type:"keyToKey",toKeys:"k"},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:"",context:"insert"},{keys:"",type:"keyToKey",toKeys:"",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"c",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"VdO",context:"visual"},{keys:"",type:"keyToKey",toKeys:"0"},{keys:"",type:"keyToKey",toKeys:"$"},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:""},{keys:"",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"",type:"action",action:"toggleOverwrite",context:"insert"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"expandToLine",motionArgs:{linewise:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r",type:"action",action:"replace",isEdit:!0},{keys:"@",type:"action",action:"replayMacro"},{keys:"q",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0}},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"",type:"action",action:"redo"},{keys:"m",type:"action",action:"setMark"},{keys:'"',type:"action",action:"setRegister"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"",type:"action",action:"indent",actionArgs:{indentRight:!0},context:"insert"},{keys:"",type:"action",action:"indent",actionArgs:{indentRight:!1},context:"insert"},{keys:"a",type:"motion",motion:"textObjectManipulation"},{keys:"i",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:":",type:"ex"}],r=[{name:"colorscheme",shortName:"colo"},{name:"map"},{name:"imap",shortName:"im"},{name:"nmap",shortName:"nm"},{name:"vmap",shortName:"vm"},{name:"unmap"},{name:"write",shortName:"w"},{name:"undo",shortName:"u"},{name:"redo",shortName:"red"},{name:"set",shortName:"se"},{name:"set",shortName:"se"},{name:"setlocal",shortName:"setl"},{name:"setglobal",shortName:"setg"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:!0},{name:"nohlsearch",shortName:"noh"},{name:"yank",shortName:"y"},{name:"delmarks",shortName:"delm"},{name:"registers",shortName:"reg",excludeFromCommandHistory:!0},{name:"global",shortName:"g"}],n=e.Pos;e.Vim=function(){function o(t,r){var n;this==e.keyMap.vim&&(e.rmClass(t.getWrapperElement(),"cm-fat-cursor"),"contenteditable"==t.getOption("inputStyle")&&null!=document.body.style.caretColor&&(function(e){var t=e.state.fatCursorMarks;if(t)for(var r=0;r")}(t);if(!n)return!1;var o=e.Vim.findKey(r,n);return"function"==typeof o&&e.signal(r,"vim-keypress",n),o}}e.defineOption("vimMode",!1,function(t,r,n){r&&"vim"!=t.getOption("keyMap")?t.setOption("keyMap","vim"):!r&&n!=e.Init&&/^vim/.test(t.getOption("keyMap"))&&t.setOption("keyMap","default")});var c={Shift:"S",Ctrl:"C",Alt:"A",Cmd:"D",Mod:"A"},u={Enter:"CR",Backspace:"BS",Delete:"Del",Insert:"Ins"};function h(e){var t=e.state.vim;return t.onPasteFn||(t.onPasteFn=function(){t.insertMode||(e.setCursor(Z(e.getCursor(),0,1)),q.enterInsertMode(e,{},t))}),t.onPasteFn}var p=/[\d]/,f=[e.isWordChar,function(t){return t&&!e.isWordChar(t)&&!/\s/.test(t)}],d=[function(e){return/\S/.test(e)}];function m(e,t){for(var r=[],n=e;n"]),C=[].concat(g,v,y,["-",'"',".",":","/"]);function w(e,t){return t>=e.firstLine()&&t<=e.lastLine()}function M(e){return/^[a-z]$/.test(e)}function x(e){return/^[A-Z]$/.test(e)}function S(e){return/^\s*$/.test(e)}function A(e,t){for(var r=0;rr?t=r:t0?1:-1,u=i.getCursor();do{if((s=o[(e+(t+=c))%e])&&(l=s.find())&&!ee(u,l))break}while(tn)}return s}}},B=function(e){return e?{changes:e.changes,expectCursorActivityForChange:e.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};function K(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=B()}function N(e){return e.state.vim||(e.state.vim={inputState:new H,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},fakeCursor:null,insertMode:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:null,sel:{},options:{}}),e.state.vim}function P(){for(var e in E={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:I(),macroModeState:new K,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new W({}),searchHistoryController:new V,exCommandHistoryController:new V},b){var t=b[e];t.value=t.defaultValue}}K.prototype={exitMacroRecordMode:function(){var e=E.macroModeState;e.onRecordingDone&&e.onRecordingDone(),e.onRecordingDone=void 0,e.isRecording=!1},enterMacroRecordMode:function(e,t){var r=E.registerController.getRegister(t);r&&(r.clear(),this.latestRegister=t,e.openDialog&&(this.onRecordingDone=e.openDialog("(recording)["+t+"]",null,{bottom:!0})),this.isRecording=!0)}};var j={buildKeyMap:function(){},getRegisterController:function(){return E.registerController},resetVimGlobalState_:P,getVimGlobalState_:function(){return E},maybeInitVimState_:N,suppressErrorLogging:!1,InsertModeKey:Qe,map:function(e,t,r){We.map(e,t,r)},unmap:function(e,t){We.unmap(e,t)},setOption:T,getOption:R,defineOption:L,defineEx:function(e,t,r){if(t){if(0!==e.indexOf(t))throw new Error('(Vim.defineEx) "'+t+'" is not a prefix of "'+e+'", command not registered')}else t=e;Fe[e]=r,We.commandMap_[t]={name:e,shortName:t,type:"api"}},handleKey:function(e,t,r){var n=this.findKey(e,t,r);if("function"==typeof n)return n()},findKey:function(r,n,o){var i,a=N(r);function s(){var e=E.macroModeState;if(e.isRecording){if("q"==n)return e.exitMacroRecordMode(),_(r),!0;"mapping"!=o&&function(e,t){if(!e.isPlaying){var r=e.latestRegister,n=E.registerController.getRegister(r);n&&n.pushText(t)}}(e,n)}}function l(){if(""==n)return _(r),a.visualMode?pe(r):a.insertMode&&Ve(r),!0}return!1===(i=a.insertMode?function(){if(l())return!0;for(var e=a.inputState.keyBuffer=a.inputState.keyBuffer+n,o=1==n.length,i=D.matchCommand(e,t,a.inputState,"insert");e.length>1&&"full"!=i.type;){e=a.inputState.keyBuffer=e.slice(1);var s=D.matchCommand(e,t,a.inputState,"insert");"none"!=s.type&&(i=s)}if("none"==i.type)return _(r),!1;if("partial"==i.type)return O&&window.clearTimeout(O),O=window.setTimeout(function(){a.insertMode&&a.inputState.keyBuffer&&_(r)},R("insertModeEscKeysTimeout")),!o;if(O&&window.clearTimeout(O),o){for(var c=r.listSelections(),u=0;u|<\w+>|./.exec(t),n=o[0],t=t.substring(o.index+n.length),e.Vim.handleKey(r,n,"mapping")}(i.toKeys):D.processCommand(r,a,i)}catch(t){throw r.state.vim=void 0,N(r),e.Vim.suppressErrorLogging||console.log(t),t}return!0})}},handleEx:function(e,t){We.processCommand(e,t)},defineMotion:function(e,t){U[e]=t},defineAction:function(e,t){q[e]=t},defineOperator:function(e,t){$[e]=t},mapCommand:function(e,t,r,n,o){var i={keys:e,type:t};for(var a in i[t]=r,i[t+"Args"]=n,o)i[a]=o[a];De(i)},_mapCommand:De,defineRegister:function(e,t){var r=E.registerController.registers;if(!e||1!=e.length)throw Error("Register name must be 1 character");if(r[e])throw Error("Register already defined "+e);r[e]=t,C.push(e)},exitVisualMode:pe,exitInsertMode:Ve};function H(){this.prefixRepeat=[],this.motionRepeat=[],this.operator=null,this.operatorArgs=null,this.motion=null,this.motionArgs=null,this.keyBuffer=[],this.registerName=null}function _(t,r){t.state.vim.inputState=new H,e.signal(t,"vim-command-done",r)}function F(e,t,r){this.clear(),this.keyBuffer=[e||""],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!!t,this.blockwise=!!r}function W(e){this.registers=e,this.unnamedRegister=e['"']=new F,e["."]=new F,e[":"]=new F,e["/"]=new F}function V(){this.historyBuffer=[],this.iterator=0,this.initialPrefix=null}H.prototype.pushRepeatDigit=function(e){this.operator?this.motionRepeat=this.motionRepeat.concat(e):this.prefixRepeat=this.prefixRepeat.concat(e)},H.prototype.getRepeat=function(){var e=0;return(this.prefixRepeat.length>0||this.motionRepeat.length>0)&&(e=1,this.prefixRepeat.length>0&&(e*=parseInt(this.prefixRepeat.join(""),10)),this.motionRepeat.length>0&&(e*=parseInt(this.motionRepeat.join(""),10))),e},F.prototype={setText:function(e,t,r){this.keyBuffer=[e||""],this.linewise=!!t,this.blockwise=!!r},pushText:function(e,t){t&&(this.linewise||this.keyBuffer.push("\n"),this.linewise=!0),this.keyBuffer.push(e)},pushInsertModeChanges:function(e){this.insertModeChanges.push(B(e))},pushSearchQuery:function(e){this.searchQueries.push(e)},clear:function(){this.keyBuffer=[],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!1},toString:function(){return this.keyBuffer.join("")}},W.prototype={pushText:function(e,t,r,n,o){n&&"\n"!==r.charAt(r.length-1)&&(r+="\n");var i=this.isValidRegister(e)?this.getRegister(e):null;if(i)x(e)?i.pushText(r,n):i.setText(r,n,o),this.unnamedRegister.setText(i.toString(),n);else{switch(t){case"yank":this.registers[0]=new F(r,n,o);break;case"delete":case"change":-1==r.indexOf("\n")?this.registers["-"]=new F(r,n):(this.shiftNumericRegisters_(),this.registers[1]=new F(r,n))}this.unnamedRegister.setText(r,n,o)}},getRegister:function(e){return this.isValidRegister(e)?(e=e.toLowerCase(),this.registers[e]||(this.registers[e]=new F),this.registers[e]):this.unnamedRegister},isValidRegister:function(e){return e&&A(e,C)},shiftNumericRegisters_:function(){for(var e=9;e>=2;e--)this.registers[e]=this.getRegister(""+(e-1))}},V.prototype={nextMatch:function(e,t){var r=this.historyBuffer,n=t?-1:1;null===this.initialPrefix&&(this.initialPrefix=e);for(var o=this.iterator+n;t?o>=0:o=r.length?(this.iterator=r.length,this.initialPrefix):o<0?e:void 0},pushInput:function(e){var t=this.historyBuffer.indexOf(e);t>-1&&this.historyBuffer.splice(t,1),e.length&&this.historyBuffer.push(e)},reset:function(){this.initialPrefix=null,this.iterator=this.historyBuffer.length}};var D={matchCommand:function(e,t,r,n){var o,i=function(e,t,r,n){for(var o,i=[],a=[],s=0;s"==o.keys.slice(-11)){var l=function(e){var t=/^.*(<[^>]+>)$/.exec(e),r=t?t[1]:e.slice(-1);if(r.length>1)switch(r){case"":r="\n";break;case"":r=" ";break;default:r=""}return r}(e);if(!l)return{type:"none"};r.selectedCharacter=l}return{type:"full",command:o}},processCommand:function(e,t,r){switch(t.inputState.repeatOverride=r.repeatOverride,r.type){case"motion":this.processMotion(e,t,r);break;case"operator":this.processOperator(e,t,r);break;case"operatorMotion":this.processOperatorMotion(e,t,r);break;case"action":this.processAction(e,t,r);break;case"search":this.processSearch(e,t,r);break;case"ex":case"keyToEx":this.processEx(e,t,r)}},processMotion:function(e,t,r){t.inputState.motion=r.motion,t.inputState.motionArgs=z(r.motionArgs),this.evalInput(e,t)},processOperator:function(e,t,r){var n=t.inputState;if(n.operator){if(n.operator==r.operator)return n.motion="expandToLine",n.motionArgs={linewise:!0},void this.evalInput(e,t);_(e)}n.operator=r.operator,n.operatorArgs=z(r.operatorArgs),t.visualMode&&this.evalInput(e,t)},processOperatorMotion:function(e,t,r){var n=t.visualMode,o=z(r.operatorMotionArgs);o&&n&&o.visualLine&&(t.visualLine=!0),this.processOperator(e,t,r),n||this.processMotion(e,t,r)},processAction:function(e,t,r){var n=t.inputState,o=n.getRepeat(),i=!!o,a=z(r.actionArgs)||{};n.selectedCharacter&&(a.selectedCharacter=n.selectedCharacter),r.operator&&this.processOperator(e,t,r),r.motion&&this.processMotion(e,t,r),(r.motion||r.operator)&&this.evalInput(e,t),a.repeat=o||1,a.repeatIsExplicit=i,a.registerName=n.registerName,_(e),t.lastMotion=null,r.isEdit&&this.recordLastEdit(t,n,r),q[r.action](e,a,t)},processSearch:function(t,r,n){if(t.getSearchCursor){var o=n.searchArgs.forward,i=n.searchArgs.wholeWordOnly;Se(t).setReversed(!o);var a=o?"/":"?",s=Se(t).getQuery(),l=t.getScrollInfo();switch(n.searchArgs.querySrc){case"prompt":var c=E.macroModeState;c.isPlaying?f(p=c.replaySearchQueries.shift(),!0,!1):Ie(t,{onClose:function(e){t.scrollTo(l.left,l.top),f(e,!0,!0);var r=E.macroModeState;r.isRecording&&function(e,t){if(!e.isPlaying){var r=e.latestRegister,n=E.registerController.getRegister(r);n&&n.pushSearchQuery&&n.pushSearchQuery(t)}}(r,e)},prefix:a,desc:Oe,onKeyUp:function(r,n,i){var a,s,c,u=e.keyName(r);"Up"==u||"Down"==u?(a="Up"==u,s=r.target?r.target.selectionEnd:0,i(n=E.searchHistoryController.nextMatch(n,a)||""),s&&r.target&&(r.target.selectionEnd=r.target.selectionStart=Math.min(s,r.target.value.length))):"Left"!=u&&"Right"!=u&&"Ctrl"!=u&&"Alt"!=u&&"Shift"!=u&&E.searchHistoryController.reset();try{c=Be(t,n,!0,!0)}catch(r){}c?t.scrollIntoView(Ne(t,!o,c),30):(Pe(t),t.scrollTo(l.left,l.top))},onKeyDown:function(r,n,o){var i=e.keyName(r);"Esc"==i||"Ctrl-C"==i||"Ctrl-["==i||"Backspace"==i&&""==n?(E.searchHistoryController.pushInput(n),E.searchHistoryController.reset(),Be(t,s),Pe(t),t.scrollTo(l.left,l.top),e.e_stop(r),_(t),o(),t.focus()):"Up"==i||"Down"==i?e.e_stop(r):"Ctrl-U"==i&&(e.e_stop(r),o(""))}});break;case"wordUnderCursor":var u=de(t,!1,0,!1,!0),h=!0;if(u||(u=de(t,!1,0,!1,!1),h=!1),!u)return;var p=t.getLine(u.start.line).substring(u.start.ch,u.end.ch);p=h&&i?"\\b"+p+"\\b":p.replace(/([.?*+$\[\]\/\\(){}|\-])/g,"\\$1"),E.jumpList.cachedCursor=t.getCursor(),t.setCursor(u.start),f(p,!0,!1)}}function f(e,o,i){E.searchHistoryController.pushInput(e),E.searchHistoryController.reset();try{Be(t,e,o,i)}catch(r){return Ee(t,"Invalid regex: "+e),void _(t)}D.processMotion(t,r,{type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:n.searchArgs.toJumplist}})}},processEx:function(t,r,n){function o(e){E.exCommandHistoryController.pushInput(e),E.exCommandHistoryController.reset(),We.processCommand(t,e)}function i(r,n,o){var i,a,s=e.keyName(r);("Esc"==s||"Ctrl-C"==s||"Ctrl-["==s||"Backspace"==s&&""==n)&&(E.exCommandHistoryController.pushInput(n),E.exCommandHistoryController.reset(),e.e_stop(r),_(t),o(),t.focus()),"Up"==s||"Down"==s?(e.e_stop(r),i="Up"==s,a=r.target?r.target.selectionEnd:0,o(n=E.exCommandHistoryController.nextMatch(n,i)||""),a&&r.target&&(r.target.selectionEnd=r.target.selectionStart=Math.min(a,r.target.value.length))):"Ctrl-U"==s?(e.e_stop(r),o("")):"Left"!=s&&"Right"!=s&&"Ctrl"!=s&&"Alt"!=s&&"Shift"!=s&&E.exCommandHistoryController.reset()}"keyToEx"==n.type?We.processCommand(t,n.exArgs.input):r.visualMode?Ie(t,{onClose:o,prefix:":",value:"'<,'>",onKeyDown:i,selectValueOnOpen:!1}):Ie(t,{onClose:o,prefix:":",onKeyDown:i})},evalInput:function(e,t){var r,o,i,a,s=t.inputState,l=s.motion,c=s.motionArgs||{},u=s.operator,h=s.operatorArgs||{},p=s.registerName,f=t.sel,d=Y(t.visualMode?Q(e,f.head):e.getCursor("head")),m=Y(t.visualMode?Q(e,f.anchor):e.getCursor("anchor")),g=Y(d),v=Y(m);if(u&&this.recordLastEdit(t,s),(i=void 0!==s.repeatOverride?s.repeatOverride:s.getRepeat())>0&&c.explicitRepeat?c.repeatIsExplicit=!0:(c.noRepeat||!c.explicitRepeat&&0===i)&&(i=1,c.repeatIsExplicit=!1),s.selectedCharacter&&(c.selectedCharacter=h.selectedCharacter=s.selectedCharacter),c.repeat=i,_(e),l){var y=U[l](e,d,c,t);if(t.lastMotion=U[l],!y)return;if(c.toJumplist){var k=E.jumpList,C=k.cachedCursor;C?(me(e,C,y),delete k.cachedCursor):me(e,d,y)}y instanceof Array?(o=y[0],r=y[1]):r=y,r||(r=Y(d)),t.visualMode?(t.visualBlock&&r.ch===1/0||(r=Q(e,r,t.visualBlock)),o&&(o=Q(e,o,!0)),o=o||v,f.anchor=o,f.head=r,ue(e),we(e,t,"<",te(o,r)?o:r),we(e,t,">",te(o,r)?r:o)):u||(r=Q(e,r),e.setCursor(r.line,r.ch))}if(u){if(h.lastSel){o=v;var w=h.lastSel,M=Math.abs(w.head.line-w.anchor.line),x=Math.abs(w.head.ch-w.anchor.ch);r=w.visualLine?n(v.line+M,v.ch):w.visualBlock?n(v.line+M,v.ch+x):w.head.line==w.anchor.line?n(v.line,v.ch+x):n(v.line+M,v.ch),t.visualMode=!0,t.visualLine=w.visualLine,t.visualBlock=w.visualBlock,f=t.sel={anchor:o,head:r},ue(e)}else t.visualMode&&(h.lastSel={anchor:Y(f.anchor),head:Y(f.head),visualBlock:t.visualBlock,visualLine:t.visualLine});var A,b,L,T,R;if(t.visualMode){if(A=re(f.head,f.anchor),b=ne(f.head,f.anchor),L=t.visualLine||h.linewise,R=he(e,{anchor:A,head:b},T=t.visualBlock?"block":L?"line":"char"),L){var O=R.ranges;if("block"==T)for(var I=0;I0&&i&&S(i);i=o.pop())r.line--,r.ch=0;i?(r.line--,r.ch=ie(e,r.line)):r.ch=0}}(e,A,b),R=he(e,{anchor:A,head:b},T="char",!c.inclusive||L)}e.setSelections(R.ranges,R.primary),t.lastMotion=null,h.repeat=i,h.registerName=p,h.linewise=L;var K=$[u](e,h,R.ranges,v,r);t.visualMode&&pe(e,null!=K),K&&e.setCursor(K)}},recordLastEdit:function(e,t,r){var n=E.macroModeState;n.isPlaying||(e.lastEditInputState=t,e.lastEditActionCommand=r,n.lastInsertModeChanges.changes=[],n.lastInsertModeChanges.expectCursorActivityForChange=!1)}},U={moveToTopLine:function(e,t,r){var o=je(e).top+r.repeat-1;return n(o,fe(e.getLine(o)))},moveToMiddleLine:function(e){var t=je(e),r=Math.floor(.5*(t.top+t.bottom));return n(r,fe(e.getLine(r)))},moveToBottomLine:function(e,t,r){var o=je(e).bottom-r.repeat+1;return n(o,fe(e.getLine(o)))},expandToLine:function(e,t,r){return n(t.line+r.repeat-1,1/0)},findNext:function(e,t,r){var n=Se(e),o=n.getQuery();if(o){var i=!r.forward;return i=n.isReversed()?!i:i,Ke(e,o),Ne(e,i,o,r.repeat)}},goToMark:function(e,t,r,n){var o=He(e,n,r.selectedCharacter);return o?r.linewise?{line:o.line,ch:fe(e.getLine(o.line))}:o:null},moveToOtherHighlightedEnd:function(e,t,r,o){if(o.visualBlock&&r.sameLine){var i=o.sel;return[Q(e,n(i.anchor.line,i.head.ch)),Q(e,n(i.head.line,i.anchor.ch))]}return[o.sel.head,o.sel.anchor]},jumpToMark:function(e,t,r,o){for(var i=t,a=0;au&&i.line==u?this.moveToEol(e,t,r,o):(r.toFirstChar&&(a=fe(e.getLine(l)),o.lastHPos=a),o.lastHSPos=e.charCoords(n(l,a),"div").left,n(l,a))},moveByDisplayLines:function(e,t,r,o){var i=t;switch(o.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:o.lastHSPos=e.charCoords(i,"div").left}var a=r.repeat;if((l=e.findPosV(i,r.forward?a:-a,"line",o.lastHSPos)).hitSide)if(r.forward)var s={top:e.charCoords(l,"div").top+8,left:o.lastHSPos},l=e.coordsChar(s,"div");else{var c=e.charCoords(n(e.firstLine(),0),"div");c.left=o.lastHSPos,l=e.coordsChar(c,"div")}return o.lastHPos=l.ch,l},moveByPage:function(e,t,r){var n=t,o=r.repeat;return e.findPosV(n,r.forward?o:-o,"page")},moveByParagraph:function(e,t,r){var n=r.forward?1:-1;return Me(e,t,r.repeat,n)},moveByScroll:function(e,t,r,n){var o=e.getScrollInfo(),i=null,a=r.repeat;a||(a=o.clientHeight/(2*e.defaultTextHeight()));var s=e.charCoords(t,"local");if(r.repeat=a,!(i=U.moveByDisplayLines(e,t,r,n)))return null;var l=e.charCoords(i,"local");return e.scrollTo(null,o.top+l.top-s.top),i},moveByWords:function(e,t,r){return function(e,t,r,o,i,a){var s=Y(t),l=[];(o&&!i||!o&&i)&&r++;for(var c=!(o&&i),u=0;u0)h.index=0;else{var m=h.lineText.length;h.index=m>0?m-1:0}h.nextCh=h.lineText.charAt(h.index)}d(h)&&(i.line=c,i.ch=h.index,t--)}return h.nextCh||h.curMoveThrough?n(c,h.index):i}(e,r.repeat,r.forward,r.selectedCharacter)||t},moveToColumn:function(e,t,r,o){var i,a,s,l=r.repeat;return o.lastHPos=l-1,o.lastHSPos=e.charCoords(t,"div").left,a=l,s=(i=e).getCursor().line,Q(i,n(s,a-1))},moveToEol:function(e,t,r,o){var i=t;o.lastHPos=1/0;var a=n(i.line+r.repeat-1,1/0),s=e.clipPos(a);return s.ch--,o.lastHSPos=e.charCoords(s,"div").left,a},moveToFirstNonWhiteSpaceCharacter:function(e,t){var r=t;return n(r.line,fe(e.getLine(r.line)))},moveToMatchedSymbol:function(e,t){for(var r,o=t,i=o.line,a=o.ch,s=e.getLine(i);aa.ch||i.line>a.line){var h=i;i=a,a=h}return o?a.ch+=1:i.ch+=1,{start:i,end:a}}(e,t,i,d);else if({"'":!0,'"':!0}[i])a=function(e,t,r,o){var i,a,s,l,c=Y(t),u=e.getLine(c.line).split(""),h=u.indexOf(r);if(c.ch-1&&!i;s--)u[s]==r&&(i=s+1);else i=c.ch+1;if(i&&!a)for(s=i,l=u.length;st.lastLine()&&r.linewise&&!d?t.replaceRange("",f,u):t.replaceRange("",c,u),r.linewise&&(d||(t.setCursor(f),e.commands.newlineAndIndent(t)),c.ch=Number.MAX_VALUE),i=c}E.registerController.pushText(r.registerName,"change",a,r.linewise,o.length>1),q.enterInsertMode(t,{head:i},t.state.vim)},delete:function(e,t,r){var o,i,a=e.state.vim;if(a.visualBlock){i=e.getSelection();var s=J("",r.length);e.replaceSelections(s),o=r[0].anchor}else{var l=r[0].anchor,c=r[0].head;t.linewise&&c.line!=e.firstLine()&&l.line==e.lastLine()&&l.line==c.line-1&&(l.line==e.firstLine()?l.ch=0:l=n(l.line-1,ie(e,l.line-1))),i=e.getRange(l,c),e.replaceRange("",l,c),o=l,t.linewise&&(o=U.moveToFirstNonWhiteSpaceCharacter(e,l))}return E.registerController.pushText(t.registerName,"delete",i,t.linewise,a.visualBlock),Q(e,o,a.insertMode)},indent:function(e,t,r){var n=e.state.vim,o=r[0].anchor.line,i=n.visualBlock?r[r.length-1].anchor.line:r[0].head.line,a=n.visualMode?t.repeat:1;t.linewise&&i--;for(var s=o;s<=i;s++)for(var l=0;lc.top?(l.line+=(s-c.top)/o,l.line=Math.ceil(l.line),e.setCursor(l),c=e.charCoords(l,"local"),e.scrollTo(null,c.top)):e.scrollTo(null,s);else{var u=s+e.getScrollInfo().clientHeight;u=a.anchor.line?Z(a.head,0,1):n(a.anchor.line,0);else if("inplace"==i&&o.visualMode)return;t.setOption("disableInput",!1),r&&r.replace?(t.toggleOverwrite(!0),t.setOption("keyMap","vim-replace"),e.signal(t,"vim-mode-change",{mode:"replace"})):(t.toggleOverwrite(!1),t.setOption("keyMap","vim-insert"),e.signal(t,"vim-mode-change",{mode:"insert"})),E.macroModeState.isPlaying||(t.on("change",Je),e.on(t.getInputField(),"keydown",ze)),o.visualMode&&pe(t),le(t,s,l)}},toggleVisualMode:function(t,r,o){var i,a=r.repeat,s=t.getCursor();o.visualMode?o.visualLine^r.linewise||o.visualBlock^r.blockwise?(o.visualLine=!!r.linewise,o.visualBlock=!!r.blockwise,e.signal(t,"vim-mode-change",{mode:"visual",subMode:o.visualLine?"linewise":o.visualBlock?"blockwise":""}),ue(t)):pe(t):(o.visualMode=!0,o.visualLine=!!r.linewise,o.visualBlock=!!r.blockwise,i=Q(t,n(s.line,s.ch+a-1),!0),o.sel={anchor:s,head:i},e.signal(t,"vim-mode-change",{mode:"visual",subMode:o.visualLine?"linewise":o.visualBlock?"blockwise":""}),ue(t),we(t,o,"<",re(s,i)),we(t,o,">",ne(s,i)))},reselectLastSelection:function(t,r,n){var o=n.lastSelection;if(n.visualMode&&ce(t,n),o){var i=o.anchorMark.find(),a=o.headMark.find();if(!i||!a)return;n.sel={anchor:i,head:a},n.visualMode=!0,n.visualLine=o.visualLine,n.visualBlock=o.visualBlock,ue(t),we(t,n,"<",re(i,a)),we(t,n,">",ne(i,a)),e.signal(t,"vim-mode-change",{mode:"visual",subMode:n.visualLine?"linewise":n.visualBlock?"blockwise":""})}},joinLines:function(e,t,r){var o,i;if(r.visualMode){if(o=e.getCursor("anchor"),te(i=e.getCursor("head"),o)){var a=i;i=o,o=a}i.ch=ie(e,i.line)-1}else{var s=Math.max(t.repeat,2);o=e.getCursor(),i=Q(e,n(o.line+s-1,1/0))}for(var l=0,c=o.line;c1&&(y=Array(t.repeat+1).join(y));var k,C,w,M,x,S,A,b,L,T,R=u.linewise,O=u.blockwise;if(R)r.visualMode?y=r.visualLine?y.slice(0,-1):"\n"+y.slice(0,y.length-1)+"\n":t.after?(y="\n"+y.slice(0,y.length-1),c.ch=ie(e,c.line)):c.ch=0;else{if(O){y=y.split("\n");for(var I=0;Ie.lastLine()&&e.replaceRange("\n",n(F,0)),ie(e,F)u.length&&(i=u.length),a=n(l.line,i)}if("\n"==s)o.visualMode||t.replaceRange("",l,a),(e.commands.newlineAndIndentContinueComment||e.commands.newlineAndIndent)(t);else{var h=t.getRange(l,a);if(h=h.replace(/[^\n]/g,s),o.visualBlock){var p=new Array(t.getOption("tabSize")+1).join(" ");h=(h=t.getSelection()).replace(/\t/g,p).replace(/[^\n]/g,s).split("\n"),t.replaceSelections(h)}else t.replaceRange(h,l,a);o.visualMode?(l=te(c[0].anchor,c[0].head)?c[0].anchor:c[0].head,t.setCursor(l),pe(t,!1)):t.setCursor(Z(a,0,-1))}},incrementNumberToken:function(e,t){for(var r,o,i,a,s=e.getCursor(),l=e.getLine(s.line),c=/(-?)(?:(0x)([\da-f]+)|(0b|0|)(\d+))/gi;null!==(r=c.exec(l))&&(i=(o=r.index)+r[0].length,!(s.ch"==t.slice(-11)){var r=t.length-11,n=e.slice(0,r),o=t.slice(0,r);return n==o&&e.length>r?"full":0==o.indexOf(n)&&"partial"}return e==t?"full":0==t.indexOf(e)&&"partial"}function X(e,t,r){return function(){for(var n=0;n2&&(t=re.apply(void 0,Array.prototype.slice.call(arguments,1))),te(e,t)?e:t}function ne(e,t){return arguments.length>2&&(t=ne.apply(void 0,Array.prototype.slice.call(arguments,1))),te(e,t)?t:e}function oe(e,t,r){var n=te(e,t),o=te(t,r);return n&&o}function ie(e,t){return e.getLine(t).length}function ae(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function se(e,t){var r=[],o=e.listSelections(),i=Y(e.clipPos(t)),a=!ee(t,i),s=function(e,t,r){for(var n=0;ns?c:0,h=o[u].anchor,p=Math.min(h.line,i.line),f=Math.max(h.line,i.line),d=h.ch,m=i.ch,g=o[u].head.ch-d,v=m-d;g>0&&v<=0?(d++,a||m--):g<0&&v>=0?(d--,l||m++):g<0&&-1==v&&(d--,m++);for(var y=p;y<=f;y++){var k={anchor:new n(y,d),head:new n(y,m)};r.push(k)}return e.setSelections(r),t.ch=m,h.ch=d,h}function le(e,t,r){for(var n=[],o=0;oc&&(i.line=c),i.ch=ie(e,i.line)}return{ranges:[{anchor:a,head:i}],primary:0}}if("block"==r){for(var u=Math.min(a.line,i.line),h=Math.min(a.ch,i.ch),p=Math.max(a.line,i.line),f=Math.max(a.ch,i.ch)+1,d=p-u+1,m=i.line==u?0:d-1,g=[],v=0;v=c.length)return null;o?h=d[0]:(h=f[0])(c.charAt(u))||(h=f[1]);for(var p=u,m=u;h(c.charAt(p))&&p=0;)m--;if(m++,t){for(var g=p;/\s/.test(c.charAt(p))&&p0;)m--;m||(m=v)}}return{start:n(l.line,m),end:n(l.line,p)}}function me(e,t,r){ee(t,r)||E.jumpList.add(e,t,r)}function ge(e,t){E.lastCharacterSearch.increment=e,E.lastCharacterSearch.forward=t.forward,E.lastCharacterSearch.selectedCharacter=t.selectedCharacter}var ve={"(":"bracket",")":"bracket","{":"bracket","}":"bracket","[":"section","]":"section","*":"comment","/":"comment",m:"method",M:"method","#":"preprocess"},ye={bracket:{isComplete:function(e){if(e.nextCh===e.symb){if(e.depth++,e.depth>=1)return!0}else e.nextCh===e.reverseSymb&&e.depth--;return!1}},section:{init:function(e){e.curMoveThrough=!0,e.symb=(e.forward?"]":"[")===e.symb?"{":"}"},isComplete:function(e){return 0===e.index&&e.nextCh===e.symb}},comment:{isComplete:function(e){var t="*"===e.lastCh&&"/"===e.nextCh;return e.lastCh=e.nextCh,t}},method:{init:function(e){e.symb="m"===e.symb?"{":"}",e.reverseSymb="{"===e.symb?"}":"{"},isComplete:function(e){return e.nextCh===e.symb}},preprocess:{init:function(e){e.index=0},isComplete:function(e){if("#"===e.nextCh){var t=e.lineText.match(/#(\w+)/)[1];if("endif"===t){if(e.forward&&0===e.depth)return!0;e.depth++}else if("if"===t){if(!e.forward&&0===e.depth)return!0;e.depth--}if("else"===t&&0===e.depth)return!0}return!1}}};function ke(e,t,r,n,o){var i=t.line,a=t.ch,s=e.getLine(i),l=r?1:-1,c=n?d:f;if(o&&""==s){if(i+=l,s=e.getLine(i),!w(e,i))return null;a=r?0:s.length}for(;;){if(o&&""==s)return{from:0,to:0,line:i};for(var u=l>0?s.length:-1,h=u,p=u;a!=u;){for(var m=!1,g=0;g0?0:s.length}}function Ce(e,t,r,o){for(var i,a=e.getCursor(),s=a.ch,l=0;l0;)p(u,o)&&r--,u+=o;return new n(u,0)}var f=e.state.vim;if(f.visualLine&&p(s,1,!0)){var d=f.sel.anchor;p(d.line,-1,!0)&&(i&&d.line==s||(s+=1))}var m=h(s);for(u=s;u<=c&&r;u++)p(u,1,!0)&&(i&&h(u)==m||r--);for(a=new n(u,0),u>c&&!m?m=!0:i=!1,u=s;u>l&&(i&&h(u)!=m&&u!=s||!p(u,-1,!0));u--);return{start:new n(u,0),end:a}}function xe(){}function Se(e){var t=e.state.vim;return t.searchState_||(t.searchState_=new xe)}function Ae(e,t){var r=be(e,t)||[];if(!r.length)return[];var n=[];if(0===r[0]){for(var o=0;o'+t+"",{bottom:!0,duration:5e3}):alert(t)}var Oe="(Javascript regexp)";function Ie(e,t){var r,n,o,i,a,s,l,c,u=(t.prefix||"")+" "+(t.desc||""),h=(r=t.prefix,n=t.desc,o=''+(r||"")+'',n&&(o+=' '+n+""),o);i=e,a=h,s=u,l=t.onClose,c=t,i.openDialog?i.openDialog(a,l,{bottom:!0,value:c.value,onKeyDown:c.onKeyDown,onKeyUp:c.onKeyUp,selectValueOnOpen:!1}):l(prompt(s,""))}function Be(e,t,r,n){if(t){var o=Se(e),i=Re(t,!!r,!!n);if(i)return Ke(e,i),function(e,t){if(e instanceof RegExp&&t instanceof RegExp){for(var r=["global","multiline","ignoreCase","source"],n=0;n0;t--){var r=e.substring(0,t);if(this.commandMap_[r]){var n=this.commandMap_[r];if(0===n.name.indexOf(e))return n}}return null},buildCommandMap_:function(){this.commandMap_={};for(var e=0;e
";if(r){r=r.join("");for(var i=0;i")}else for(var a in n){var s=n[a].toString();s.length&&(o+='"'+a+" "+s+"
")}Ee(e,o)},sort:function(t,r){var o,i,a,s,l,c=function(){if(r.argString){var t=new e.StringStream(r.argString);if(t.eat("!")&&(o=!0),t.eol())return;if(!t.eatSpace())return"Invalid arguments";var n=t.match(/([dinuox]+)?\s*(\/.+\/)?\s*/);if(!n&&!t.eol())return"Invalid arguments";if(n[1]){i=-1!=n[1].indexOf("i"),a=-1!=n[1].indexOf("u");var c=-1!=n[1].indexOf("d")||-1!=n[1].indexOf("n")&&1,u=-1!=n[1].indexOf("x")&&1,h=-1!=n[1].indexOf("o")&&1;if(c+u+h>1)return"Invalid arguments";s=(c?"decimal":u&&"hex")||h&&"octal"}n[2]&&(l=new RegExp(n[2].substr(1,n[2].length-2),i?"i":""))}}();if(c)Ee(t,c+": "+r.argString);else{var u=r.line||t.firstLine(),h=r.lineEnd||r.line||t.lastLine();if(u!=h){var p=n(u,0),f=n(h,ie(t,h)),d=t.getRange(p,f).split("\n"),m=l||("decimal"==s?/(-?)([\d]+)/:"hex"==s?/(-?)(?:0x)?([0-9a-f]+)/i:"octal"==s?/([0-7]+)/:null),g="decimal"==s?10:"hex"==s?16:"octal"==s?8:null,v=[],y=[];if(s||l)for(var k=0;k");if(n){var p=0,f=function(){if(p=r&&e<=s:e==r);)if(n||!h||a.from().line!=h.line)return t.scrollIntoView(a.from(),30),t.setSelection(a.from(),a.to()),h=a.from(),void(u=!1);var e,r,s;u=!0}function m(e){if(e&&e(),t.focus(),h){t.setCursor(h);var r=t.state.vim;r.exMode=!1,r.lastHPos=r.lastHSPos=h.ch}c&&c()}if(d(),!u)return r?void Ie(t,{prefix:"replace with "+l+" (y/n/a/q/l)",onKeyDown:function(r,n,o){switch(e.e_stop(r),e.keyName(r)){case"Y":f(),d();break;case"N":d();break;case"A":var i=c;c=void 0,t.operation(p),c=i;break;case"L":f();case"Q":case"Esc":case"Ctrl-C":case"Ctrl-[":m(o)}return u&&m(o),!0}}):(p(),void(c&&c()));Ee(t,"No matches for "+s.source)}(t,h,f,m,g,y,d,u,r.callback)}else Ee(t,"No previous substitute regular expression")},redo:e.commands.redo,undo:e.commands.undo,write:function(t){e.commands.save?e.commands.save(t):t.save&&t.save()},nohlsearch:function(e){Pe(e)},yank:function(e){var t=Y(e.getCursor()).line,r=e.getLine(t);E.registerController.pushText("0","yank",r,!0,!0)},delmarks:function(t,r){if(r.argString&&ae(r.argString))for(var n=t.state.vim,o=new e.StringStream(ae(r.argString));!o.eol();){o.eatSpace();var i=o.pos;if(!o.match(/[a-zA-Z]/,!1))return void Ee(t,"Invalid argument: "+r.argString.substring(i));var a=o.next();if(o.match("-",!0)){if(!o.match(/[a-zA-Z]/,!1))return void Ee(t,"Invalid argument: "+r.argString.substring(i));var s=a,l=o.next();if(!(M(s)&&M(l)||x(s)&&x(l)))return void Ee(t,"Invalid argument: "+s+"-");var c=s.charCodeAt(0),u=l.charCodeAt(0);if(c>=u)return void Ee(t,"Invalid argument: "+r.argString.substring(i));for(var h=0;h<=u-c;h++){var p=String.fromCharCode(c+h);delete n.marks[p]}}else delete n.marks[a]}else Ee(t,"Argument required")}},We=new _e;function Ve(t){var r=t.state.vim,n=E.macroModeState,o=E.registerController.getRegister("."),i=n.isPlaying,a=n.lastInsertModeChanges,s=[];if(!i){for(var l=a.inVisualBlock&&r.lastSelection?r.lastSelection.visualBlock.height:1,c=a.changes,u=(s=[],0);u1&&(Ze(t,r,r.insertModeRepeat-1,!0),r.lastEditInputState.repeatOverride=r.insertModeRepeat),delete r.insertModeRepeat,r.insertMode=!1,t.setCursor(t.getCursor().line,t.getCursor().ch-1),t.setOption("keyMap","vim"),t.setOption("disableInput",!0),t.toggleOverwrite(!1),o.setText(a.changes.join("")),e.signal(t,"vim-mode-change",{mode:"normal"}),n.isRecording&&function(e){if(!e.isPlaying){var t=e.latestRegister,r=E.registerController.getRegister(t);r&&r.pushInsertModeChanges&&r.pushInsertModeChanges(e.lastInsertModeChanges)}}(n)}function De(e){t.unshift(e)}function Ue(t,r,n,o){var i=E.registerController.getRegister(o);if(":"==o)return i.keyBuffer[0]&&We.processCommand(t,i.keyBuffer[0]),void(n.isPlaying=!1);var a=i.keyBuffer,s=0;n.isPlaying=!0,n.replaySearchQueries=i.searchQueries.slice(0);for(var l=0;l|<\w+>|./.exec(h))[0],h=h.substring(c.index+u.length),e.Vim.handleKey(t,u,"macro"),r.insertMode){var p=i.insertModeChanges[s++].changes;E.macroModeState.lastInsertModeChanges.changes=p,Ge(t,p,1),Ve(t)}n.isPlaying=!1}function Je(e,t){var r=E.macroModeState,n=r.lastInsertModeChanges;if(!r.isPlaying)for(;t;){if(n.expectCursorActivityForChange=!0,"+input"==t.origin||"paste"==t.origin||void 0===t.origin){var o=t.text.join("\n");n.maybeReset&&(n.changes=[],n.maybeReset=!1),e.state.overwrite&&!/\n/.test(o)?n.changes.push([o]):n.changes.push(o)}t=t.next}}function $e(t){var r=t.state.vim;if(r.insertMode){var n=E.macroModeState;if(n.isPlaying)return;var o=n.lastInsertModeChanges;o.expectCursorActivityForChange?o.expectCursorActivityForChange=!1:o.maybeReset=!0}else t.curOp.isVimOp||function(t,r){var n=t.getCursor("anchor"),o=t.getCursor("head");if(r.visualMode&&!t.somethingSelected()?pe(t,!1):r.visualMode||r.insertMode||!t.somethingSelected()||(r.visualMode=!0,r.visualLine=!1,e.signal(t,"vim-mode-change",{mode:"visual"})),r.visualMode){var i=te(o,n)?0:-1,a=te(o,n)?-1:0;o=Z(o,0,i),n=Z(n,0,a),r.sel={anchor:n,head:o},we(t,r,"<",re(o,n)),we(t,r,">",ne(o,n))}else r.insertMode||(r.lastHPos=t.getCursor().ch)}(t,r);r.visualMode&&qe(t)}function qe(e){var t=e.state.vim,r=Q(e,Y(t.sel.head)),n=Z(r,0,1);t.fakeCursor&&t.fakeCursor.clear(),t.fakeCursor=e.markText(r,n,{className:"cm-animate-fat-cursor"})}function Qe(e){this.keyName=e}function ze(t){var r=E.macroModeState.lastInsertModeChanges,n=e.keyName(t);n&&(-1==n.indexOf("Delete")&&-1==n.indexOf("Backspace")||e.lookupKey(n,"vim-insert",function(){return r.maybeReset&&(r.changes=[],r.maybeReset=!1),r.changes.push(new Qe(n)),!0}))}function Ze(e,t,r,n){var o=E.macroModeState;o.isPlaying=!0;var i=!!t.lastEditActionCommand,a=t.inputState;function s(){i?D.processAction(e,t,t.lastEditActionCommand):D.evalInput(e,t)}function l(r){if(o.lastInsertModeChanges.changes.length>0){r=t.lastEditActionCommand?r:1;var n=o.lastInsertModeChanges;Ge(e,n.changes,r)}}if(t.inputState=t.lastEditInputState,i&&t.lastEditActionCommand.interlaceInsertRepeat)for(var c=0;c0;i--)r.context=r.context.prev;return K(e,t,r)}function B(e){var t=e.current().toLowerCase();a=f.hasOwnProperty(t)?"atom":b.hasOwnProperty(t)?"keyword":"variable"}var T={top:function(e,t,r){if("{"==e)return q(r,t,"block");if("}"==e&&r.context.prev)return P(r);if(k&&/@component/i.test(e))return q(r,t,"atComponentBlock");if(/^@(-moz-)?document$/i.test(e))return q(r,t,"documentTypes");if(/^@(media|supports|(-moz-)?document|import)$/i.test(e))return q(r,t,"atBlock");if(/^@(font-face|counter-style)/i.test(e))return r.stateArg=e,"restricted_atBlock_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(e))return"keyframes";if(e&&"@"==e.charAt(0))return q(r,t,"at");if("hash"==e)a="builtin";else if("word"==e)a="tag";else{if("variable-definition"==e)return"maybeprop";if("interpolation"==e)return q(r,t,"interpolation");if(":"==e)return"pseudo";if(y&&"("==e)return q(r,t,"parens")}return r.context.type},block:function(e,t,r){if("word"==e){var o=t.current().toLowerCase();return u.hasOwnProperty(o)?(a="property","maybeprop"):m.hasOwnProperty(o)?(a="string-2","maybeprop"):y?(a=t.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block"):(a+=" error","maybeprop")}return"meta"==e?"block":y||"hash"!=e&&"qualifier"!=e?T.top(e,t,r):(a="error","block")},maybeprop:function(e,t,r){return":"==e?q(r,t,"prop"):K(e,t,r)},prop:function(e,t,r){if(";"==e)return P(r);if("{"==e&&y)return q(r,t,"propBlock");if("}"==e||"{"==e)return C(e,t,r);if("("==e)return q(r,t,"parens");if("hash"!=e||/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(t.current())){if("word"==e)B(t);else if("interpolation"==e)return q(r,t,"interpolation")}else a+=" error";return"prop"},propBlock:function(e,t,r){return"}"==e?P(r):"word"==e?(a="property","maybeprop"):r.context.type},parens:function(e,t,r){return"{"==e||"}"==e?C(e,t,r):")"==e?P(r):"("==e?q(r,t,"parens"):"interpolation"==e?q(r,t,"interpolation"):("word"==e&&B(t),"parens")},pseudo:function(e,t,r){return"meta"==e?"pseudo":"word"==e?(a="variable-3",r.context.type):K(e,t,r)},documentTypes:function(e,t,r){return"word"==e&&s.hasOwnProperty(t.current())?(a="tag",r.context.type):T.atBlock(e,t,r)},atBlock:function(e,t,r){if("("==e)return q(r,t,"atBlock_parens");if("}"==e||";"==e)return C(e,t,r);if("{"==e)return P(r)&&q(r,t,y?"block":"top");if("interpolation"==e)return q(r,t,"interpolation");if("word"==e){var o=t.current().toLowerCase();a="only"==o||"not"==o||"and"==o||"or"==o?"keyword":c.hasOwnProperty(o)?"attribute":d.hasOwnProperty(o)?"property":p.hasOwnProperty(o)?"keyword":u.hasOwnProperty(o)?"property":m.hasOwnProperty(o)?"string-2":f.hasOwnProperty(o)?"atom":b.hasOwnProperty(o)?"keyword":"error"}return r.context.type},atComponentBlock:function(e,t,r){return"}"==e?C(e,t,r):"{"==e?P(r)&&q(r,t,y?"block":"top",!1):("word"==e&&(a="error"),r.context.type)},atBlock_parens:function(e,t,r){return")"==e?P(r):"{"==e||"}"==e?C(e,t,r,2):T.atBlock(e,t,r)},restricted_atBlock_before:function(e,t,r){return"{"==e?q(r,t,"restricted_atBlock"):"word"==e&&"@counter-style"==r.stateArg?(a="variable","restricted_atBlock_before"):K(e,t,r)},restricted_atBlock:function(e,t,r){return"}"==e?(r.stateArg=null,P(r)):"word"==e?(a="@font-face"==r.stateArg&&!h.hasOwnProperty(t.current().toLowerCase())||"@counter-style"==r.stateArg&&!g.hasOwnProperty(t.current().toLowerCase())?"error":"property","maybeprop"):"restricted_atBlock"},keyframes:function(e,t,r){return"word"==e?(a="variable","keyframes"):"{"==e?q(r,t,"top"):K(e,t,r)},at:function(e,t,r){return";"==e?P(r):"{"==e||"}"==e?C(e,t,r):("word"==e?a="tag":"hash"==e&&(a="builtin"),"at")},interpolation:function(e,t,r){return"}"==e?P(r):"{"==e||";"==e?C(e,t,r):("word"==e?a="variable":"variable"!=e&&"("!=e&&")"!=e&&(a="error"),"interpolation")}};return{startState:function(e){return{tokenize:null,state:o?"block":"top",stateArg:null,context:new j(o?"block":"top",e||0,null)}},token:function(e,t){if(!t.tokenize&&e.eatSpace())return null;var r=(t.tokenize||function(e,t){var r=e.next();if(l[r]){var o=l[r](e,t);if(!1!==o)return o}return"@"==r?(e.eatWhile(/[\w\\\-]/),v("def",e.current())):"="==r||("~"==r||"|"==r)&&e.eat("=")?v(null,"compare"):'"'==r||"'"==r?(t.tokenize=x(r),t.tokenize(e,t)):"#"==r?(e.eatWhile(/[\w\\\-]/),v("atom","hash")):"!"==r?(e.match(/^\s*\w*/),v("keyword","important")):/\d/.test(r)||"."==r&&e.eat(/\d/)?(e.eatWhile(/[\w.%]/),v("number","unit")):"-"!==r?/[,+>*\/]/.test(r)?v(null,"select-op"):"."==r&&e.match(/^-?[_a-z][_a-z0-9-]*/i)?v("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(r)?v(null,r):("u"==r||"U"==r)&&e.match(/rl(-prefix)?\(/i)||("d"==r||"D"==r)&&e.match("omain(",!0,!0)||("r"==r||"R"==r)&&e.match("egexp(",!0,!0)?(e.backUp(1),t.tokenize=z,v("property","word")):/[\w\\\-]/.test(r)?(e.eatWhile(/[\w\\\-]/),v("property","word")):v(null,null):/[\d.]/.test(e.peek())?(e.eatWhile(/[\w.%]/),v("number","unit")):e.match(/^-[\w\\\-]+/)?(e.eatWhile(/[\w\\\-]/),e.match(/^\s*:/,!1)?v("variable-2","variable-definition"):v("variable-2","variable")):e.match(/^\w+-/)?v("meta","meta"):void 0})(e,t);return r&&"object"==typeof r&&(i=r[1],r=r[0]),a=r,"comment"!=i&&(t.state=T[t.state](i,e,t)),a},indent:function(e,t){var r=e.context,o=t&&t.charAt(0),i=r.indent;return"prop"!=r.type||"}"!=o&&")"!=o||(r=r.prev),r.prev&&("}"!=o||"block"!=r.type&&"top"!=r.type&&"interpolation"!=r.type&&"restricted_atBlock"!=r.type?(")"!=o||"parens"!=r.type&&"atBlock_parens"!=r.type)&&("{"!=o||"at"!=r.type&&"atBlock"!=r.type)||(i=Math.max(0,r.indent-n)):i=(r=r.prev).indent),i},electricChars:"}",blockCommentStart:"/*",blockCommentEnd:"*/",blockCommentContinue:" * ",lineComment:w,fold:"brace"}});var r=["domain","regexp","url","url-prefix"],o=t(r),i=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],a=t(i),n=["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid","orientation","device-pixel-ratio","min-device-pixel-ratio","max-device-pixel-ratio","pointer","any-pointer","hover","any-hover"],l=t(n),s=["landscape","portrait","none","coarse","fine","on-demand","hover","interlace","progressive"],c=t(s),d=["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-gap","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-gap","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","justify-content","justify-items","justify-self","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","place-content","place-items","place-self","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","user-select","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","will-change","word-break","word-spacing","word-wrap","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode"],p=t(d),u=["scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-3d-light-color","scrollbar-track-color","shape-inside","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","zoom"],m=t(u),h=t(["font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"]),g=t(["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"]),b=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],f=t(b),y=["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","contain","content","contents","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","devanagari","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","georgian","graytext","grid","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hard-light","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","hue","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","luminosity","malayalam","match","matrix","matrix3d","media-controls-background","media-current-time-display","media-fullscreen-button","media-mute-button","media-play-button","media-return-to-realtime-button","media-rewind-button","media-seek-back-button","media-seek-forward-button","media-slider","media-sliderthumb","media-time-remaining-display","media-volume-slider","media-volume-slider-container","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","multiply","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","opacity","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","self-start","self-end","semi-condensed","semi-expanded","separate","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","somali","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unset","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"],w=t(y),k=r.concat(i).concat(n).concat(s).concat(d).concat(u).concat(b).concat(y);function v(e,t){for(var r,o=!1;null!=(r=e.next());){if(o&&"/"==r){t.tokenize=null;break}o="*"==r}return["comment","comment"]}e.registerHelper("hintWords","css",k),e.defineMIME("text/css",{documentTypes:o,mediaTypes:a,mediaFeatures:l,mediaValueKeywords:c,propertyKeywords:p,nonStandardPropertyKeywords:m,fontProperties:h,counterDescriptors:g,colorKeywords:f,valueKeywords:w,tokenHooks:{"/":function(e,t){return!!e.eat("*")&&(t.tokenize=v,v(e,t))}},name:"css"}),e.defineMIME("text/x-scss",{mediaTypes:a,mediaFeatures:l,mediaValueKeywords:c,propertyKeywords:p,nonStandardPropertyKeywords:m,colorKeywords:f,valueKeywords:w,fontProperties:h,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(e,t){return e.eat("/")?(e.skipToEnd(),["comment","comment"]):e.eat("*")?(t.tokenize=v,v(e,t)):["operator","operator"]},":":function(e){return!!e.match(/\s*\{/,!1)&&[null,null]},$:function(e){return e.match(/^[\w-]+/),e.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"]},"#":function(e){return!!e.eat("{")&&[null,"interpolation"]}},name:"css",helperType:"scss"}),e.defineMIME("text/x-less",{mediaTypes:a,mediaFeatures:l,mediaValueKeywords:c,propertyKeywords:p,nonStandardPropertyKeywords:m,colorKeywords:f,valueKeywords:w,fontProperties:h,allowNested:!0,lineComment:"//",tokenHooks:{"/":function(e,t){return e.eat("/")?(e.skipToEnd(),["comment","comment"]):e.eat("*")?(t.tokenize=v,v(e,t)):["operator","operator"]},"@":function(e){return e.eat("{")?[null,"interpolation"]:!e.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/i,!1)&&(e.eatWhile(/[\w\\\-]/),e.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"])},"&":function(){return["atom","atom"]}},name:"css",helperType:"less"}),e.defineMIME("text/x-gss",{documentTypes:o,mediaTypes:a,mediaFeatures:l,propertyKeywords:p,nonStandardPropertyKeywords:m,fontProperties:h,counterDescriptors:g,colorKeywords:f,valueKeywords:w,supportsAtComponent:!0,tokenHooks:{"/":function(e,t){return!!e.eat("*")&&(t.tokenize=v,v(e,t))}},name:"css",helperType:"gss"})}); \ No newline at end of file diff --git a/plugins/tiddlywiki/codemirror-mode-css/files/tiddlywiki.files b/plugins/tiddlywiki/codemirror-mode-css/files/tiddlywiki.files new file mode 100755 index 000000000..e3522f770 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-css/files/tiddlywiki.files @@ -0,0 +1,12 @@ +{ + "tiddlers": [ +{ + "file": "mode/css/css.js", + "fields": { + "type": "application/javascript", + "title": "$:/plugins/tiddlywiki/codemirror/mode/css/css.js", + "module-type": "codemirror" + } + } + ] +} diff --git a/plugins/tiddlywiki/codemirror-mode-css/plugin.info b/plugins/tiddlywiki/codemirror-mode-css/plugin.info new file mode 100755 index 000000000..115afed8c --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-css/plugin.info @@ -0,0 +1,6 @@ +{ + "title": "$:/plugins/tiddlywiki/codemirror-mode-css", + "description": "CodeMirror Mode: CSS Highlighting", + "author": "JeremyRuston", + "list": "readme" +} diff --git a/plugins/tiddlywiki/codemirror-mode-css/readme.tid b/plugins/tiddlywiki/codemirror-mode-css/readme.tid new file mode 100755 index 000000000..4fd51fd6d --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-css/readme.tid @@ -0,0 +1,5 @@ +title: $:/plugins/tiddlywiki/codemirror-mode-css/readme + +This plugin adds Syntax Highlighting for CSS tiddlers (text/css) to the [[CodeMirror|http://codemirror.net]] text editor. It needs the latest [[CodeMirror plugin|$:/plugins/tiddlywiki/codemirror]] to be installed + + diff --git a/plugins/tiddlywiki/codemirror-mode-htmlembedded/files/addon/mode/multiplex.js b/plugins/tiddlywiki/codemirror-mode-htmlembedded/files/addon/mode/multiplex.js new file mode 100755 index 000000000..24cd9fc5d --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-htmlembedded/files/addon/mode/multiplex.js @@ -0,0 +1,3 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE +!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.multiplexingMode=function(n){var i=Array.prototype.slice.call(arguments,1);function t(e,n,i,t){if("string"==typeof n){var r=e.indexOf(n,i);return t&&r>-1?r+n.length:r}var o=n.exec(i?e.slice(i):e);return o?o.index+i+(t?o[0].length:0):-1}return{startState:function(){return{outer:e.startState(n),innerActive:null,inner:null}},copyState:function(i){return{outer:e.copyState(n,i.outer),innerActive:i.innerActive,inner:i.innerActive&&e.copyState(i.innerActive.mode,i.inner)}},token:function(r,o){if(o.innerActive){var c=o.innerActive;a=r.string;if(!c.close&&r.sol())return o.innerActive=o.inner=null,this.token(r,o);if((v=c.close?t(a,c.close,r.pos,c.parseDelimiters):-1)==r.pos&&!c.parseDelimiters)return r.match(c.close),o.innerActive=o.inner=null,c.delimStyle&&c.delimStyle+" "+c.delimStyle+"-close";v>-1&&(r.string=a.slice(0,v));var l=c.mode.token(r,o.inner);return v>-1&&(r.string=a),v==r.pos&&c.parseDelimiters&&(o.innerActive=o.inner=null),c.innerStyle&&(l=l?l+" "+c.innerStyle:c.innerStyle),l}for(var s=1/0,a=r.string,u=0;u";return e.multiplexingMode(e.getMode(i,"htmlmixed"),{open:t.openComment||"<%--",close:d,delimStyle:"comment",mode:{token:function(e){return e.skipTo(d)||e.skipToEnd(),"comment"}}},{open:t.open||t.scriptStartRegex||"<%",close:t.close||t.scriptEndRegex||"%>",mode:e.getMode(i,t.scriptingModeSpec)})},"htmlmixed"),e.defineMIME("application/x-ejs",{name:"htmlembedded",scriptingModeSpec:"javascript"}),e.defineMIME("application/x-aspx",{name:"htmlembedded",scriptingModeSpec:"text/x-csharp"}),e.defineMIME("application/x-jsp",{name:"htmlembedded",scriptingModeSpec:"text/x-java"}),e.defineMIME("application/x-erb",{name:"htmlembedded",scriptingModeSpec:"ruby"})}); \ No newline at end of file diff --git a/plugins/tiddlywiki/codemirror-mode-htmlembedded/files/tiddlywiki.files b/plugins/tiddlywiki/codemirror-mode-htmlembedded/files/tiddlywiki.files new file mode 100755 index 000000000..8086d2248 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-htmlembedded/files/tiddlywiki.files @@ -0,0 +1,19 @@ +{ + "tiddlers": [ + { + "file": "addon/mode/multiplex.js", + "fields": { + "type": "application/javascript", + "title": "$:/plugins/tiddlywiki/codemirror/addon/mode/multiplex.js", + "module-type": "codemirror" + } + },{ + "file": "mode/htmlembedded/htmlembedded.js", + "fields": { + "type": "application/javascript", + "title": "$:/plugins/tiddlywiki/codemirror/mode/htmlembedded/htmlembedded.js", + "module-type": "codemirror" + } + } + ] +} diff --git a/plugins/tiddlywiki/codemirror-mode-htmlembedded/plugin.info b/plugins/tiddlywiki/codemirror-mode-htmlembedded/plugin.info new file mode 100755 index 000000000..a7eef49c6 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-htmlembedded/plugin.info @@ -0,0 +1,6 @@ +{ + "title": "$:/plugins/tiddlywiki/codemirror-mode-htmlembedded", + "description": "CodeMirror Mode: Embedded-HTML Highlighting", + "author": "JeremyRuston", + "list": "readme" +} diff --git a/plugins/tiddlywiki/codemirror-mode-htmlembedded/readme.tid b/plugins/tiddlywiki/codemirror-mode-htmlembedded/readme.tid new file mode 100755 index 000000000..f7868e16c --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-htmlembedded/readme.tid @@ -0,0 +1,4 @@ +title: $:/plugins/tiddlywiki/codemirror-mode-htmlembedded/readme + +This plugin adds Syntax Highlighting for Embedded-HTML tiddlers (application/x-aspx, application/x-ejs, application/x-jsp and application/x-erb) to the [[CodeMirror|http://codemirror.net]] text editor. It needs the latest [[CodeMirror plugin|$:/plugins/tiddlywiki/codemirror]] to be installed + diff --git a/plugins/tiddlywiki/codemirror-mode-htmlmixed/files/mode/htmlmixed/htmlmixed.js b/plugins/tiddlywiki/codemirror-mode-htmlmixed/files/mode/htmlmixed/htmlmixed.js new file mode 100755 index 000000000..5fb1173b0 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-htmlmixed/files/mode/htmlmixed/htmlmixed.js @@ -0,0 +1,3 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE +!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror"),require("../xml/xml"),require("../javascript/javascript"),require("../css/css")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../javascript/javascript","../css/css"],t):t(CodeMirror)}(function(t){"use strict";var e={script:[["lang",/(javascript|babel)/i,"javascript"],["type",/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i,"javascript"],["type",/./,"text/plain"],[null,null,"javascript"]],style:[["lang",/^css$/i,"css"],["type",/^(text\/)?(x-)?(stylesheet|css)$/i,"css"],["type",/./,"text/plain"],[null,null,"css"]]};var a={};function n(t,e){var n,l=t.match(a[n=e]||(a[n]=new RegExp("\\s+"+n+"\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*")));return l?/^\s*(.*?)\s*$/.exec(l[2])[1]:""}function l(t,e){return new RegExp((e?"^":"")+"","i")}function r(t,e){for(var a in t)for(var n=e[a]||(e[a]=[]),l=t[a],r=l.length-1;r>=0;r--)n.unshift(l[r])}t.defineMode("htmlmixed",function(a,o){var c=t.getMode(a,{name:"xml",htmlMode:!0,multilineTagIndentFactor:o.multilineTagIndentFactor,multilineTagIndentPastTag:o.multilineTagIndentPastTag}),i={},s=o&&o.tags,u=o&&o.scriptTypes;if(r(e,i),s&&r(s,i),u)for(var m=u.length-1;m>=0;m--)i.script.unshift(["type",u[m].matches,u[m].mode]);function d(e,r){var o,s=c.token(e,r.htmlState),u=/\btag\b/.test(s);if(u&&!/[<>\s\/]/.test(e.current())&&(o=r.htmlState.tagName&&r.htmlState.tagName.toLowerCase())&&i.hasOwnProperty(o))r.inTag=o+" ";else if(r.inTag&&u&&/>$/.test(e.current())){var m=/^([\S]+) (.*)/.exec(r.inTag);r.inTag=null;var p=">"==e.current()&&function(t,e){for(var a=0;a-1?a.backUp(r.length-o):r.match(/<\/?$/)&&(a.backUp(r.length),a.match(n,!1)||a.match(r)),l);var a,n,l,r,o},r.localMode=f,r.localState=t.startState(f,c.indent(r.htmlState,""))}else r.inTag&&(r.inTag+=e.current(),e.eol()&&(r.inTag+=" "));return s}return{startState:function(){return{token:d,inTag:null,localMode:null,localState:null,htmlState:t.startState(c)}},copyState:function(e){var a;return e.localState&&(a=t.copyState(e.localMode,e.localState)),{token:e.token,inTag:e.inTag,localMode:e.localMode,localState:a,htmlState:t.copyState(c,e.htmlState)}},token:function(t,e){return e.token(t,e)},indent:function(e,a,n){return!e.localMode||/^\s*<\//.test(a)?c.indent(e.htmlState,a):e.localMode.indent?e.localMode.indent(e.localState,a,n):t.Pass},innerMode:function(t){return{state:t.localState||t.htmlState,mode:t.localMode||c}}}},"xml","javascript","css"),t.defineMIME("text/html","htmlmixed")}); \ No newline at end of file diff --git a/plugins/tiddlywiki/codemirror-mode-htmlmixed/files/tiddlywiki.files b/plugins/tiddlywiki/codemirror-mode-htmlmixed/files/tiddlywiki.files new file mode 100755 index 000000000..1f6c36595 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-htmlmixed/files/tiddlywiki.files @@ -0,0 +1,12 @@ +{ + "tiddlers": [ +{ + "file": "mode/htmlmixed/htmlmixed.js", + "fields": { + "type": "application/javascript", + "title": "$:/plugins/tiddlywiki/codemirror/mode/htmlmixed/htmlmixed.js", + "module-type": "codemirror" + } + } + ] +} diff --git a/plugins/tiddlywiki/codemirror-mode-htmlmixed/plugin.info b/plugins/tiddlywiki/codemirror-mode-htmlmixed/plugin.info new file mode 100755 index 000000000..99d12fde9 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-htmlmixed/plugin.info @@ -0,0 +1,6 @@ +{ + "title": "$:/plugins/tiddlywiki/codemirror-mode-htmlmixed", + "description": "CodeMirror Mode: HTML Highlighting", + "author": "JeremyRuston", + "list": "readme" +} diff --git a/plugins/tiddlywiki/codemirror-mode-htmlmixed/readme.tid b/plugins/tiddlywiki/codemirror-mode-htmlmixed/readme.tid new file mode 100755 index 000000000..21dc12a96 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-htmlmixed/readme.tid @@ -0,0 +1,4 @@ +title: $:/plugins/tiddlywiki/codemirror-mode-htmlmixed/readme + +This plugin adds Syntax Highlighting for HTML tiddlers (text/html) to the [[CodeMirror|http://codemirror.net]] text editor. It needs the latest [[CodeMirror plugin|$:/plugins/tiddlywiki/codemirror]] to be installed + diff --git a/plugins/tiddlywiki/codemirror-mode-javascript/files/mode/javascript/javascript.js b/plugins/tiddlywiki/codemirror-mode-javascript/files/mode/javascript/javascript.js new file mode 100755 index 000000000..3119133f1 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-javascript/files/mode/javascript/javascript.js @@ -0,0 +1,3 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE +!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.defineMode("javascript",function(t,r){var n,a,i=t.indentUnit,o=r.statementIndent,c=r.jsonld,u=r.json||c,s=r.typescript,f=r.wordCharacters||/[\w$\xa1-\uffff]/,l=function(){function e(e){return{type:e,style:"keyword"}}var t=e("keyword a"),r=e("keyword b"),n=e("keyword c"),a=e("keyword d"),i=e("operator"),o={type:"atom",style:"atom"};return{if:e("if"),while:t,with:t,else:r,do:r,try:r,finally:r,return:a,break:a,continue:a,new:e("new"),delete:n,void:n,throw:n,debugger:e("debugger"),var:e("var"),const:e("var"),let:e("var"),function:e("function"),catch:e("catch"),for:e("for"),switch:e("switch"),case:e("case"),default:e("default"),in:i,typeof:i,instanceof:i,true:o,false:o,null:o,undefined:o,NaN:o,Infinity:o,this:e("this"),class:e("class"),super:e("atom"),yield:n,export:e("export"),import:e("import"),extends:n,await:n}}(),d=/[+\-*&%=<>!?|~^@]/,p=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;function m(e,t,r){return n=e,a=r,t}function k(e,t){var r,n=e.next();if('"'==n||"'"==n)return t.tokenize=(r=n,function(e,t){var n,a=!1;if(c&&"@"==e.peek()&&e.match(p))return t.tokenize=k,m("jsonld-keyword","meta");for(;null!=(n=e.next())&&(n!=r||a);)a=!a&&"\\"==n;return a||(t.tokenize=k),m("string","string")}),t.tokenize(e,t);if("."==n&&e.match(/^\d+(?:[eE][+\-]?\d+)?/))return m("number","number");if("."==n&&e.match(".."))return m("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(n))return m(n);if("="==n&&e.eat(">"))return m("=>","operator");if("0"==n&&e.eat(/x/i))return e.eatWhile(/[\da-f]/i),m("number","number");if("0"==n&&e.eat(/o/i))return e.eatWhile(/[0-7]/i),m("number","number");if("0"==n&&e.eat(/b/i))return e.eatWhile(/[01]/i),m("number","number");if(/\d/.test(n))return e.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),m("number","number");if("/"==n)return e.eat("*")?(t.tokenize=v,v(e,t)):e.eat("/")?(e.skipToEnd(),m("comment","comment")):He(e,t,1)?(function(e){for(var t,r=!1,n=!1;null!=(t=e.next());){if(!r){if("/"==t&&!n)return;"["==t?n=!0:n&&"]"==t&&(n=!1)}r=!r&&"\\"==t}}(e),e.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/),m("regexp","string-2")):(e.eat("="),m("operator","operator",e.current()));if("`"==n)return t.tokenize=y,y(e,t);if("#"==n)return e.skipToEnd(),m("error","error");if(d.test(n))return">"==n&&t.lexical&&">"==t.lexical.type||(e.eat("=")?"!"!=n&&"="!=n||e.eat("="):/[<>*+\-]/.test(n)&&(e.eat(n),">"==n&&e.eat(n))),m("operator","operator",e.current());if(f.test(n)){e.eatWhile(f);var a=e.current();if("."!=t.lastType){if(l.propertyIsEnumerable(a)){var i=l[a];return m(i.type,i.style,a)}if("async"==a&&e.match(/^(\s|\/\*.*?\*\/)*[\(\w]/,!1))return m("async","keyword",a)}return m("variable","variable",a)}}function v(e,t){for(var r,n=!1;r=e.next();){if("/"==r&&n){t.tokenize=k;break}n="*"==r}return m("comment","comment")}function y(e,t){for(var r,n=!1;null!=(r=e.next());){if(!n&&("`"==r||"$"==r&&e.eat("{"))){t.tokenize=k;break}n=!n&&"\\"==r}return m("quasi","string-2",e.current())}var b="([{}])";function w(e,t){t.fatArrowAt&&(t.fatArrowAt=null);var r=e.string.indexOf("=>",e.start);if(!(r<0)){if(s){var n=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(e.string.slice(e.start,r));n&&(r=n.index)}for(var a=0,i=!1,o=r-1;o>=0;--o){var c=e.string.charAt(o),u=b.indexOf(c);if(u>=0&&u<3){if(!a){++o;break}if(0==--a){"("==c&&(i=!0);break}}else if(u>=3&&u<6)++a;else if(f.test(c))i=!0;else{if(/["'\/]/.test(c))return;if(i&&!a){++o;break}}}i&&!a&&(t.fatArrowAt=o)}}var x={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,this:!0,"jsonld-keyword":!0};function h(e,t,r,n,a,i){this.indented=e,this.column=t,this.type=r,this.prev=a,this.info=i,null!=n&&(this.align=n)}function g(e,t){for(var r=e.localVars;r;r=r.next)if(r.name==t)return!0;for(var n=e.context;n;n=n.prev)for(r=n.vars;r;r=r.next)if(r.name==t)return!0}var j={state:null,column:null,marked:null,cc:null};function M(){for(var e=arguments.length-1;e>=0;e--)j.cc.push(arguments[e])}function V(){return M.apply(null,arguments),!0}function A(e){function t(t){for(var r=t;r;r=r.next)if(r.name==e)return!0;return!1}var n=j.state;if(j.marked="def",n.context){if(t(n.localVars))return;n.localVars={name:e,next:n.localVars}}else{if(t(n.globalVars))return;r.globalVars&&(n.globalVars={name:e,next:n.globalVars})}}function E(e){return"public"==e||"private"==e||"protected"==e||"abstract"==e||"readonly"==e}var z={name:"this",next:{name:"arguments"}};function I(){j.state.context={prev:j.state.context,vars:j.state.localVars},j.state.localVars=z}function T(){j.state.localVars=j.state.context.vars,j.state.context=j.state.context.prev}function $(e,t){var r=function(){var r=j.state,n=r.indented;if("stat"==r.lexical.type)n=r.lexical.indented;else for(var a=r.lexical;a&&")"==a.type&&a.align;a=a.prev)n=a.indented;r.lexical=new h(n,j.stream.column(),e,null,r.lexical,t)};return r.lex=!0,r}function C(){var e=j.state;e.lexical.prev&&(")"==e.lexical.type&&(e.indented=e.lexical.indented),e.lexical=e.lexical.prev)}function q(e){return function t(r){return r==e?V():";"==e?M():V(t)}}function O(e,t){return"var"==e?V($("vardef",t.length),pe,q(";"),C):"keyword a"==e?V($("form"),W,O,C):"keyword b"==e?V($("form"),O,C):"keyword d"==e?j.stream.match(/^\s*$/,!1)?V():V($("stat"),U,q(";"),C):"debugger"==e?V(q(";")):"{"==e?V($("}"),te,C):";"==e?V():"if"==e?("else"==j.state.lexical.info&&j.state.cc[j.state.cc.length-1]==C&&j.state.cc.pop()(),V($("form"),W,O,C,be)):"function"==e?V(Me):"for"==e?V($("form"),we,O,C):"class"==e||s&&"interface"==t?(j.marked="keyword",V($("form"),Ee,C)):"variable"==e?s&&"declare"==t?(j.marked="keyword",V(O)):s&&("module"==t||"enum"==t||"type"==t)&&j.stream.match(/^\s*\w/,!1)?(j.marked="keyword","enum"==t?V(Ue):"type"==t?V(ie,q("operator"),ie,q(";")):V($("form"),me,q("{"),$("}"),te,C,C)):s&&"namespace"==t?(j.marked="keyword",V($("form"),P,te,C)):V($("stat"),Q):"switch"==e?V($("form"),W,q("{"),$("}","switch"),te,C,C):"case"==e?V(P,q(":")):"default"==e?V(q(":")):"catch"==e?V($("form"),I,q("("),Ve,q(")"),O,C,T):"export"==e?V($("stat"),$e,C):"import"==e?V($("stat"),qe,C):"async"==e?V(O):"@"==t?V(P,O):M($("stat"),P,q(";"),C)}function P(e,t){return N(e,t,!1)}function S(e,t){return N(e,t,!0)}function W(e){return"("!=e?M():V($(")"),P,q(")"),C)}function N(e,t,r){if(j.state.fatArrowAt==j.stream.start){var n=r?J:G;if("("==e)return V(I,$(")"),_(Ve,")"),C,q("=>"),n,T);if("variable"==e)return M(I,me,q("=>"),n,T)}var a,i=r?H:B;return x.hasOwnProperty(e)?V(i):"function"==e?V(Me,i):"class"==e||s&&"interface"==t?(j.marked="keyword",V($("form"),Ae,C)):"keyword c"==e||"async"==e?V(r?S:P):"("==e?V($(")"),U,q(")"),C,i):"operator"==e||"spread"==e?V(r?S:P):"["==e?V($("]"),Ne,C,i):"{"==e?ee(X,"}",null,i):"quasi"==e?M(D,i):"new"==e?V((a=r,function(e){return"."==e?V(a?L:K):"variable"==e&&s?V(fe,a?H:B):M(a?S:P)})):"import"==e?V(P):V()}function U(e){return e.match(/[;\}\)\],]/)?M():M(P)}function B(e,t){return","==e?V(P):H(e,t,!1)}function H(e,t,r){var n=0==r?B:H,a=0==r?P:S;return"=>"==e?V(I,r?J:G,T):"operator"==e?/\+\+|--/.test(t)||s&&"!"==t?V(n):s&&"<"==t&&j.stream.match(/^([^>]|<.*?>)*>\s*\(/,!1)?V($(">"),_(ie,">"),C,n):"?"==t?V(P,q(":"),a):V(a):"quasi"==e?M(D,n):";"!=e?"("==e?ee(S,")","call",n):"."==e?V(R,n):"["==e?V($("]"),U,q("]"),C,n):s&&"as"==t?(j.marked="keyword",V(ie,n)):"regexp"==e?(j.state.lastType=j.marked="operator",j.stream.backUp(j.stream.pos-j.stream.start-1),V(a)):void 0:void 0}function D(e,t){return"quasi"!=e?M():"${"!=t.slice(t.length-2)?V(D):V(P,F)}function F(e){if("}"==e)return j.marked="string-2",j.state.tokenize=y,V(D)}function G(e){return w(j.stream,j.state),M("{"==e?O:P)}function J(e){return w(j.stream,j.state),M("{"==e?O:S)}function K(e,t){if("target"==t)return j.marked="keyword",V(B)}function L(e,t){if("target"==t)return j.marked="keyword",V(H)}function Q(e){return":"==e?V(C,O):M(B,q(";"),C)}function R(e){if("variable"==e)return j.marked="property",V()}function X(e,t){if("async"==e)return j.marked="property",V(X);if("variable"==e||"keyword"==j.style){return j.marked="property","get"==t||"set"==t?V(Y):(s&&j.state.fatArrowAt==j.stream.start&&(r=j.stream.match(/^\s*:\s*/,!1))&&(j.state.fatArrowAt=j.stream.pos+r[0].length),V(Z));var r}else{if("number"==e||"string"==e)return j.marked=c?"property":j.style+" property",V(Z);if("jsonld-keyword"==e)return V(Z);if(s&&E(t))return j.marked="keyword",V(X);if("["==e)return V(P,re,q("]"),Z);if("spread"==e)return V(S,Z);if("*"==t)return j.marked="keyword",V(X);if(":"==e)return M(Z)}}function Y(e){return"variable"!=e?M(Z):(j.marked="property",V(Me))}function Z(e){return":"==e?V(S):"("==e?M(Me):void 0}function _(e,t,r){function n(a,i){if(r?r.indexOf(a)>-1:","==a){var o=j.state.lexical;return"call"==o.info&&(o.pos=(o.pos||0)+1),V(function(r,n){return r==t||n==t?M():M(e)},n)}return a==t||i==t?V():V(q(t))}return function(r,a){return r==t||a==t?V():M(e,n)}}function ee(e,t,r){for(var n=3;n"==e)return V(ie)}function ce(e,t){return"variable"==e||"keyword"==j.style?(j.marked="property",V(ce)):"?"==t?V(ce):":"==e?V(ie):"["==e?V(P,re,q("]"),ce):void 0}function ue(e){return"variable"==e?V(ue):":"==e?V(ie):void 0}function se(e,t){return"<"==t?V($(">"),_(ie,">"),C,se):"|"==t||"."==e||"&"==t?V(ie):"["==e?V(q("]"),se):"extends"==t||"implements"==t?(j.marked="keyword",V(ie)):void 0}function fe(e,t){if("<"==t)return V($(">"),_(ie,">"),C,se)}function le(){return M(ie,de)}function de(e,t){if("="==t)return V(ie)}function pe(e,t){return"enum"==t?(j.marked="keyword",V(Ue)):M(me,re,ve,ye)}function me(e,t){return s&&E(t)?(j.marked="keyword",V(me)):"variable"==e?(A(t),V()):"spread"==e?V(me):"["==e?ee(me,"]"):"{"==e?ee(ke,"}"):void 0}function ke(e,t){return"variable"!=e||j.stream.match(/^\s*:/,!1)?("variable"==e&&(j.marked="property"),"spread"==e?V(me):"}"==e?M():V(q(":"),me,ve)):(A(t),V(ve))}function ve(e,t){if("="==t)return V(S)}function ye(e){if(","==e)return V(pe)}function be(e,t){if("keyword b"==e&&"else"==t)return V($("form","else"),O,C)}function we(e,t){return"await"==t?V(we):"("==e?V($(")"),xe,q(")"),C):void 0}function xe(e){return"var"==e?V(pe,q(";"),ge):";"==e?V(ge):"variable"==e?V(he):M(P,q(";"),ge)}function he(e,t){return"in"==t||"of"==t?(j.marked="keyword",V(P)):V(B,ge)}function ge(e,t){return";"==e?V(je):"in"==t||"of"==t?(j.marked="keyword",V(P)):M(P,q(";"),je)}function je(e){")"!=e&&V(P)}function Me(e,t){return"*"==t?(j.marked="keyword",V(Me)):"variable"==e?(A(t),V(Me)):"("==e?V(I,$(")"),_(Ve,")"),C,ne,O,T):s&&"<"==t?V($(">"),_(le,">"),C,Me):void 0}function Ve(e,t){return"@"==t&&V(P,Ve),"spread"==e?V(Ve):s&&E(t)?(j.marked="keyword",V(Ve)):M(me,re,ve)}function Ae(e,t){return"variable"==e?Ee(e,t):ze(e,t)}function Ee(e,t){if("variable"==e)return A(t),V(ze)}function ze(e,t){return"<"==t?V($(">"),_(le,">"),C,ze):"extends"==t||"implements"==t||s&&","==e?("implements"==t&&(j.marked="keyword"),V(s?ie:P,ze)):"{"==e?V($("}"),Ie,C):void 0}function Ie(e,t){return"async"==e||"variable"==e&&("static"==t||"get"==t||"set"==t||s&&E(t))&&j.stream.match(/^\s+[\w$\xa1-\uffff]/,!1)?(j.marked="keyword",V(Ie)):"variable"==e||"keyword"==j.style?(j.marked="property",V(s?Te:Me,Ie)):"["==e?V(P,re,q("]"),s?Te:Me,Ie):"*"==t?(j.marked="keyword",V(Ie)):";"==e?V(Ie):"}"==e?V():"@"==t?V(P,Ie):void 0}function Te(e,t){return"?"==t?V(Te):":"==e?V(ie,ve):"="==t?V(S):M(Me)}function $e(e,t){return"*"==t?(j.marked="keyword",V(We,q(";"))):"default"==t?(j.marked="keyword",V(P,q(";"))):"{"==e?V(_(Ce,"}"),We,q(";")):M(O)}function Ce(e,t){return"as"==t?(j.marked="keyword",V(q("variable"))):"variable"==e?M(S,Ce):void 0}function qe(e){return"string"==e?V():"("==e?M(P):M(Oe,Pe,We)}function Oe(e,t){return"{"==e?ee(Oe,"}"):("variable"==e&&A(t),"*"==t&&(j.marked="keyword"),V(Se))}function Pe(e){if(","==e)return V(Oe,Pe)}function Se(e,t){if("as"==t)return j.marked="keyword",V(Oe)}function We(e,t){if("from"==t)return j.marked="keyword",V(P)}function Ne(e){return"]"==e?V():M(_(S,"]"))}function Ue(){return M($("form"),me,q("{"),$("}"),_(Be,"}"),C,C)}function Be(){return M(me,ve)}function He(e,t,r){return t.tokenize==k&&/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(t.lastType)||"quasi"==t.lastType&&/\{\s*$/.test(e.string.slice(0,e.pos-(r||0)))}return C.lex=!0,{startState:function(e){var t={tokenize:k,lastType:"sof",cc:[],lexical:new h((e||0)-i,0,"block",!1),localVars:r.localVars,context:r.localVars&&{vars:r.localVars},indented:e||0};return r.globalVars&&"object"==typeof r.globalVars&&(t.globalVars=r.globalVars),t},token:function(e,t){if(e.sol()&&(t.lexical.hasOwnProperty("align")||(t.lexical.align=!1),t.indented=e.indentation(),w(e,t)),t.tokenize!=v&&e.eatSpace())return null;var r=t.tokenize(e,t);return"comment"==n?r:(t.lastType="operator"!=n||"++"!=a&&"--"!=a?n:"incdec",function(e,t,r,n,a){var i=e.cc;for(j.state=e,j.stream=a,j.marked=null,j.cc=i,j.style=t,e.lexical.hasOwnProperty("align")||(e.lexical.align=!0);;)if((i.length?i.pop():u?P:O)(r,n)){for(;i.length&&i[i.length-1].lex;)i.pop()();return j.marked?j.marked:"variable"==r&&g(e,n)?"variable-2":t}}(t,r,n,a,e))},indent:function(t,n){if(t.tokenize==v)return e.Pass;if(t.tokenize!=k)return 0;var a,c=n&&n.charAt(0),u=t.lexical;if(!/^\s*else\b/.test(n))for(var s=t.cc.length-1;s>=0;--s){var f=t.cc[s];if(f==C)u=u.prev;else if(f!=be)break}for(;("stat"==u.type||"form"==u.type)&&("}"==c||(a=t.cc[t.cc.length-1])&&(a==B||a==H)&&!/^[,\.=+\-*:?[\(]/.test(n));)u=u.prev;o&&")"==u.type&&"stat"==u.prev.type&&(u=u.prev);var l,p,m=u.type,y=c==m;return"vardef"==m?u.indented+("operator"==t.lastType||","==t.lastType?u.info+1:0):"form"==m&&"{"==c?u.indented:"form"==m?u.indented+i:"stat"==m?u.indented+(p=n,"operator"==(l=t).lastType||","==l.lastType||d.test(p.charAt(0))||/[,.]/.test(p.charAt(0))?o||i:0):"switch"!=u.info||y||0==r.doubleIndentSwitch?u.align?u.column+(y?0:1):u.indented+(y?0:i):u.indented+(/^(?:case|default)\b/.test(n)?i:2*i)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:u?null:"/*",blockCommentEnd:u?null:"*/",blockCommentContinue:u?null:" * ",lineComment:u?null:"//",fold:"brace",closeBrackets:"()[]{}''\"\"``",helperType:u?"json":"javascript",jsonldMode:c,jsonMode:u,expressionAllowed:He,skipExpression:function(e){var t=e.cc[e.cc.length-1];t!=P&&t!=S||e.cc.pop()}}}),e.registerHelper("wordChars","javascript",/[\w$]/),e.defineMIME("text/javascript","javascript"),e.defineMIME("text/ecmascript","javascript"),e.defineMIME("application/javascript","javascript"),e.defineMIME("application/x-javascript","javascript"),e.defineMIME("application/ecmascript","javascript"),e.defineMIME("application/json",{name:"javascript",json:!0}),e.defineMIME("application/x-json",{name:"javascript",json:!0}),e.defineMIME("application/ld+json",{name:"javascript",jsonld:!0}),e.defineMIME("text/typescript",{name:"javascript",typescript:!0}),e.defineMIME("application/typescript",{name:"javascript",typescript:!0})}); diff --git a/plugins/tiddlywiki/codemirror-mode-javascript/files/tiddlywiki.files b/plugins/tiddlywiki/codemirror-mode-javascript/files/tiddlywiki.files new file mode 100755 index 000000000..7ca41b6ca --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-javascript/files/tiddlywiki.files @@ -0,0 +1,12 @@ +{ + "tiddlers": [ +{ + "file": "mode/javascript/javascript.js", + "fields": { + "type": "application/javascript", + "title": "$:/plugins/tiddlywiki/codemirror/mode/javascript/javascript.js", + "module-type": "codemirror" + } + } + ] +} diff --git a/plugins/tiddlywiki/codemirror-mode-javascript/plugin.info b/plugins/tiddlywiki/codemirror-mode-javascript/plugin.info new file mode 100755 index 000000000..6bbc03273 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-javascript/plugin.info @@ -0,0 +1,6 @@ +{ + "title": "$:/plugins/tiddlywiki/codemirror-mode-javascript", + "description": "CodeMirror Mode: Javascript Highlighting", + "author": "JeremyRuston", + "list": "readme" +} diff --git a/plugins/tiddlywiki/codemirror-mode-javascript/readme.tid b/plugins/tiddlywiki/codemirror-mode-javascript/readme.tid new file mode 100755 index 000000000..d381014c2 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-javascript/readme.tid @@ -0,0 +1,4 @@ +title: $:/plugins/tiddlywiki/codemirror-mode-javascript/readme + +This plugin adds Syntax Highlighting for Javascript tiddlers (application/javascript) to the [[CodeMirror|http://codemirror.net]] text editor. It needs the latest [[CodeMirror plugin|$:/plugins/tiddlywiki/codemirror]] to be installed + diff --git a/plugins/tiddlywiki/codemirror-mode-markdown/files/mode/markdown/markdown.js b/plugins/tiddlywiki/codemirror-mode-markdown/files/mode/markdown/markdown.js new file mode 100755 index 000000000..7813640df --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-markdown/files/mode/markdown/markdown.js @@ -0,0 +1,3 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE +!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror"),require("../xml/xml"),require("../tw-meta")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../meta"],t):t(CodeMirror)}(function(t){"use strict";t.defineMode("markdown",function(e,i){var n=t.getMode(e,"text/html"),r="null"==n.name;void 0===i.highlightFormatting&&(i.highlightFormatting=!1),void 0===i.maxBlockquoteDepth&&(i.maxBlockquoteDepth=0),void 0===i.taskLists&&(i.taskLists=!1),void 0===i.strikethrough&&(i.strikethrough=!1),void 0===i.emoji&&(i.emoji=!1),void 0===i.fencedCodeBlockHighlighting&&(i.fencedCodeBlockHighlighting=!0),void 0===i.xml&&(i.xml=!0),void 0===i.tokenTypeOverrides&&(i.tokenTypeOverrides={});var a={header:"header",code:"comment",quote:"quote",list1:"variable-2",list2:"variable-3",list3:"keyword",hr:"hr",image:"image",imageAltText:"image-alt-text",imageMarker:"image-marker",formatting:"formatting",linkInline:"link",linkEmail:"link",linkText:"link",linkHref:"string",em:"em",strong:"strong",strikethrough:"strikethrough",emoji:"builtin"};for(var l in a)a.hasOwnProperty(l)&&i.tokenTypeOverrides[l]&&(a[l]=i.tokenTypeOverrides[l]);var o=/^([*\-_])(?:\s*\1){2,}\s*$/,h=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,g=/^\[(x| )\](?=\s)/i,s=i.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,m=/^ *(?:\={1,}|-{1,})\s*$/,u=/^[^#!\[\]*_\\<>` "'(~:]+/,f=/^(~~~+|```+)[ \t]*([\w+#-]*)[^\n`]*$/,c=/^\s*\[[^\]]+?\]:.*$/,d=/[!\"#$%&\'()*+,\-\.\/:;<=>?@\[\\\]^_`{|}~—]/;function k(t,e,i){return e.f=e.inline=i,i(t,e)}function p(t,e,i){return e.f=e.block=i,i(t,e)}function x(t){return t.linkTitle=!1,t.linkHref=!1,t.linkText=!1,t.em=!1,t.strong=!1,t.strikethrough=!1,t.quote=0,t.indentedCode=!1,t.f==S&&(t.f=M,t.block=v),t.trailingSpace=0,t.trailingSpaceNewLine=!1,t.prevLine=t.thisLine,t.thisLine={stream:null},null}function v(n,r){var l,u=n.column()===r.indentation,d=!(l=r.prevLine.stream)||!/\S/.test(l.string),p=r.indentedCode,x=r.prevLine.hr,v=!1!==r.list,S=(r.listStack[r.listStack.length-1]||0)+3;r.indentedCode=!1;var q=r.indentation;if(null===r.indentationDiff&&(r.indentationDiff=r.indentation,v)){for(r.em=!1,r.strong=!1,r.code=!1,r.strikethrough=!1,r.list=null;q=4&&(p||r.prevLine.fencedCodeEnd||r.prevLine.header||d))return n.skipToEnd(),r.indentedCode=!0,a.code;if(n.eatSpace())return null;if(u&&r.indentation<=S&&(b=n.match(s))&&b[1].length<=6)return r.quote=0,r.header=b[1].length,r.thisLine.header=!0,i.highlightFormatting&&(r.formatting="header"),r.f=r.inline,T(r);if(r.indentation<=S&&n.eat(">"))return r.quote=u?1:r.quote+1,i.highlightFormatting&&(r.formatting="quote"),n.eatSpace(),T(r);if(!F&&!r.setext&&u&&r.indentation<=S&&(b=n.match(h))){var E=b[1]?"ol":"ul";return r.indentation=q+n.current().length,r.list=!0,r.quote=0,r.listStack.push(r.indentation),i.taskLists&&n.match(g,!1)&&(r.taskList=!0),r.f=r.inline,i.highlightFormatting&&(r.formatting=["list","list-"+E]),T(r)}return u&&r.indentation<=S&&(b=n.match(f,!0))?(r.quote=0,r.fencedEndRE=new RegExp(b[1]+"+ *$"),r.localMode=i.fencedCodeBlockHighlighting&&function(i){if(t.findModeByName){var n=t.findModeByName(i);n&&(i=n.mime||n.mimes[0])}var r=t.getMode(e,i);return"null"==r.name?null:r}(b[2]),r.localMode&&(r.localState=t.startState(r.localMode)),r.f=r.block=L,i.highlightFormatting&&(r.formatting="code-block"),r.code=-1,T(r)):r.setext||!(M&&v||r.quote||!1!==r.list||r.code||F||c.test(n.string))&&(b=n.lookAhead(1))&&(b=b.match(m))?(r.setext?(r.header=r.setext,r.setext=0,n.skipToEnd(),i.highlightFormatting&&(r.formatting="header")):(r.header="="==b[0].charAt(0)?1:2,r.setext=r.header),r.thisLine.header=!0,r.f=r.inline,T(r)):F?(n.skipToEnd(),r.hr=!0,r.thisLine.hr=!0,a.hr):"["===n.peek()?k(n,r,w):k(n,r,r.inline)}function S(e,i){var a=n.token(e,i.htmlState);if(!r){var l=t.innerMode(n,i.htmlState);("xml"==l.mode.name&&null===l.state.tagStart&&!l.state.context&&l.state.tokenize.isInText||i.md_inside&&e.current().indexOf(">")>-1)&&(i.f=M,i.block=v,i.htmlState=null)}return a}function L(t,e){var n,r=e.listStack[e.listStack.length-1]||0,l=e.indentation=t.quote?e.push(a.formatting+"-"+t.formatting[n]+"-"+t.quote):e.push("error"))}if(t.taskOpen)return e.push("meta"),e.length?e.join(" "):null;if(t.taskClosed)return e.push("property"),e.length?e.join(" "):null;if(t.linkHref?e.push(a.linkHref,"url"):(t.strong&&e.push(a.strong),t.em&&e.push(a.em),t.strikethrough&&e.push(a.strikethrough),t.emoji&&e.push(a.emoji),t.linkText&&e.push(a.linkText),t.code&&e.push(a.code),t.image&&e.push(a.image),t.imageAltText&&e.push(a.imageAltText,"link"),t.imageMarker&&e.push(a.imageMarker)),t.header&&e.push(a.header,a.header+"-"+t.header),t.quote&&(e.push(a.quote),!i.maxBlockquoteDepth||i.maxBlockquoteDepth>=t.quote?e.push(a.quote+"-"+t.quote):e.push(a.quote+"-"+i.maxBlockquoteDepth)),!1!==t.list){var r=(t.listStack.length-1)%3;r?1===r?e.push(a.list2):e.push(a.list3):e.push(a.list1)}return t.trailingSpaceNewLine?e.push("trailing-space-new-line"):t.trailingSpace&&e.push("trailing-space-"+(t.trailingSpace%2?"a":"b")),e.length?e.join(" "):null}function q(t,e){if(t.match(u,!0))return T(e)}function M(e,r){var l=r.text(e,r);if(void 0!==l)return l;if(r.list)return r.list=null,T(r);if(r.taskList)return" "===e.match(g,!0)[1]?r.taskOpen=!0:r.taskClosed=!0,i.highlightFormatting&&(r.formatting="task"),r.taskList=!1,T(r);if(r.taskOpen=!1,r.taskClosed=!1,r.header&&e.match(/^#+$/,!0))return i.highlightFormatting&&(r.formatting="header"),T(r);var o=e.next();if(r.linkTitle){r.linkTitle=!1;var h=o;"("===o&&(h=")");var s="^\\s*(?:[^"+(h=(h+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1"))+"\\\\]+|\\\\\\\\|\\\\.)"+h;if(e.match(new RegExp(s),!0))return a.linkHref}if("`"===o){var m=r.formatting;i.highlightFormatting&&(r.formatting="code"),e.eatWhile("`");var u=e.current().length;if(0!=r.code||r.quote&&1!=u){if(u==r.code){var f=T(r);return r.code=0,f}return r.formatting=m,T(r)}return r.code=u,T(r)}if(r.code)return T(r);if("\\"===o&&(e.next(),i.highlightFormatting)){var c=T(r),k=a.formatting+"-escape";return c?c+" "+k:k}if("!"===o&&e.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return r.imageMarker=!0,r.image=!0,i.highlightFormatting&&(r.formatting="image"),T(r);if("["===o&&r.imageMarker&&e.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return r.imageMarker=!1,r.imageAltText=!0,i.highlightFormatting&&(r.formatting="image"),T(r);if("]"===o&&r.imageAltText){i.highlightFormatting&&(r.formatting="image");var c=T(r);return r.imageAltText=!1,r.image=!1,r.inline=r.f=b,c}if("["===o&&!r.image)return r.linkText=!0,i.highlightFormatting&&(r.formatting="link"),T(r);if("]"===o&&r.linkText){i.highlightFormatting&&(r.formatting="link");var c=T(r);return r.linkText=!1,r.inline=r.f=e.match(/\(.*?\)| ?\[.*?\]/,!1)?b:M,c}if("<"===o&&e.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1))return r.f=r.inline=F,i.highlightFormatting&&(r.formatting="link"),(c=T(r))?c+=" ":c="",c+a.linkInline;if("<"===o&&e.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1))return r.f=r.inline=F,i.highlightFormatting&&(r.formatting="link"),(c=T(r))?c+=" ":c="",c+a.linkEmail;if(i.xml&&"<"===o&&e.match(/^(!--|[a-z]+(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*>)/i,!1)){var x=e.string.indexOf(">",e.pos);if(-1!=x){var v=e.string.substring(e.start,x);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(v)&&(r.md_inside=!0)}return e.backUp(1),r.htmlState=t.startState(n),p(e,r,S)}if(i.xml&&"<"===o&&e.match(/^\/\w*?>/))return r.md_inside=!1,"tag";if("*"===o||"_"===o){for(var L=1,q=1==e.pos?" ":e.string.charAt(e.pos-2);L<3&&e.eat(o);)L++;var E=e.peek()||" ",w=!/\s/.test(E)&&(!d.test(E)||/\s/.test(q)||d.test(q)),j=!/\s/.test(q)&&(!d.test(q)||/\s/.test(E)||d.test(E)),y=null,C=null;if(L%2&&(r.em||!w||"*"!==o&&j&&!d.test(q)?r.em!=o||!j||"*"!==o&&w&&!d.test(E)||(y=!1):y=!0),L>1&&(r.strong||!w||"*"!==o&&j&&!d.test(q)?r.strong!=o||!j||"*"!==o&&w&&!d.test(E)||(C=!1):C=!0),null!=C||null!=y){i.highlightFormatting&&(r.formatting=null==y?"strong":null==C?"em":"strong em"),!0===y&&(r.em=o),!0===C&&(r.strong=o);f=T(r);return!1===y&&(r.em=!1),!1===C&&(r.strong=!1),f}}else if(" "===o&&(e.eat("*")||e.eat("_"))){if(" "===e.peek())return T(r);e.backUp(1)}if(i.strikethrough)if("~"===o&&e.eatWhile(o)){if(r.strikethrough){i.highlightFormatting&&(r.formatting="strikethrough");f=T(r);return r.strikethrough=!1,f}if(e.match(/^[^\s]/,!1))return r.strikethrough=!0,i.highlightFormatting&&(r.formatting="strikethrough"),T(r)}else if(" "===o&&e.match(/^~~/,!0)){if(" "===e.peek())return T(r);e.backUp(2)}if(i.emoji&&":"===o&&e.match(/^[a-z_\d+-]+:/)){r.emoji=!0,i.highlightFormatting&&(r.formatting="emoji");var H=T(r);return r.emoji=!1,H}return" "===o&&(e.match(/ +$/,!1)?r.trailingSpace++:r.trailingSpace&&(r.trailingSpaceNewLine=!0)),T(r)}function F(t,e){if(">"===t.next()){e.f=e.inline=M,i.highlightFormatting&&(e.formatting="link");var n=T(e);return n?n+=" ":n="",n+a.linkInline}return t.match(/^[^>]+/,!0),a.linkInline}function b(t,e){if(t.eatSpace())return null;var n,r=t.next();return"("===r||"["===r?(e.f=e.inline=(n="("===r?")":"]",function(t,e){var r=t.next();if(r===n){e.f=e.inline=M,i.highlightFormatting&&(e.formatting="link-string");var a=T(e);return e.linkHref=!1,a}return t.match(E[n]),e.linkHref=!0,T(e)}),i.highlightFormatting&&(e.formatting="link-string"),e.linkHref=!0,T(e)):"error"}var E={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function w(t,e){return t.match(/^([^\]\\]|\\.)*\]:/,!1)?(e.f=j,t.next(),i.highlightFormatting&&(e.formatting="link"),e.linkText=!0,T(e)):k(t,e,M)}function j(t,e){if(t.match(/^\]:/,!0)){e.f=e.inline=y,i.highlightFormatting&&(e.formatting="link");var n=T(e);return e.linkText=!1,n}return t.match(/^([^\]\\]|\\.)+/,!0),a.linkText}function y(t,e){return t.eatSpace()?null:(t.match(/^[^\s]+/,!0),void 0===t.peek()?e.linkTitle=!0:t.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),e.f=e.inline=M,a.linkHref+" url")}var C={startState:function(){return{f:v,prevLine:{stream:null},thisLine:{stream:null},block:v,htmlState:null,indentation:0,inline:M,text:q,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,code:0,em:!1,strong:!1,header:0,setext:0,hr:!1,taskList:!1,list:!1,listStack:[],quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,emoji:!1,fencedEndRE:null}},copyState:function(e){return{f:e.f,prevLine:e.prevLine,thisLine:e.thisLine,block:e.block,htmlState:e.htmlState&&t.copyState(n,e.htmlState),indentation:e.indentation,localMode:e.localMode,localState:e.localMode?t.copyState(e.localMode,e.localState):null,inline:e.inline,text:e.text,formatting:!1,linkText:e.linkText,linkTitle:e.linkTitle,linkHref:e.linkHref,code:e.code,em:e.em,strong:e.strong,strikethrough:e.strikethrough,emoji:e.emoji,header:e.header,setext:e.setext,hr:e.hr,taskList:e.taskList,list:e.list,listStack:e.listStack.slice(0),quote:e.quote,indentedCode:e.indentedCode,trailingSpace:e.trailingSpace,trailingSpaceNewLine:e.trailingSpaceNewLine,md_inside:e.md_inside,fencedEndRE:e.fencedEndRE}},token:function(t,e){if(e.formatting=!1,t!=e.thisLine.stream){if(e.header=0,e.hr=!1,t.match(/^\s*$/,!0))return x(e),null;if(e.prevLine=e.thisLine,e.thisLine={stream:t},e.taskList=!1,e.trailingSpace=0,e.trailingSpaceNewLine=!1,!e.localState&&(e.f=e.block,e.f!=S)){var i=t.match(/^\s*/,!0)[0].replace(/\t/g," ").length;if(e.indentation=i,e.indentationDiff=null,i>0)return null}}return e.f(t,e)},innerMode:function(t){return t.block==S?{state:t.htmlState,mode:n}:t.localState?{state:t.localState,mode:t.localMode}:{state:t,mode:C}},indent:function(e,i,r){return e.block==S&&n.indent?n.indent(e.htmlState,i,r):e.localState&&e.localMode.indent?e.localMode.indent(e.localState,i,r):t.Pass},blankLine:x,getType:T,closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return C},"xml"),t.defineMIME("text/markdown","markdown"),t.defineMIME("text/x-markdown","markdown")}); diff --git a/plugins/tiddlywiki/codemirror-mode-markdown/files/tiddlywiki.files b/plugins/tiddlywiki/codemirror-mode-markdown/files/tiddlywiki.files new file mode 100755 index 000000000..ab2c87de0 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-markdown/files/tiddlywiki.files @@ -0,0 +1,12 @@ +{ + "tiddlers": [ +{ + "file": "mode/markdown/markdown.js", + "fields": { + "type": "application/javascript", + "title": "$:/plugins/tiddlywiki/codemirror/mode/markdown/markdown.js", + "module-type": "codemirror" + } + } + ] +} diff --git a/plugins/tiddlywiki/codemirror-mode-markdown/plugin.info b/plugins/tiddlywiki/codemirror-mode-markdown/plugin.info new file mode 100755 index 000000000..a9c8f1fd1 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-markdown/plugin.info @@ -0,0 +1,6 @@ +{ + "title": "$:/plugins/tiddlywiki/codemirror-mode-markdown", + "description": "CodeMirror Mode: Markdown Highlighting", + "author": "JeremyRuston", + "list": "readme" +} diff --git a/plugins/tiddlywiki/codemirror-mode-markdown/readme.tid b/plugins/tiddlywiki/codemirror-mode-markdown/readme.tid new file mode 100755 index 000000000..7ab96a54a --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-markdown/readme.tid @@ -0,0 +1,4 @@ +title: $:/plugins/tiddlywiki/codemirror-mode-markdown/readme + +This plugin adds Syntax Highlighting for Markdown tiddlers (text/x-markdown) to the [[CodeMirror|http://codemirror.net]] text editor. It needs the latest [[CodeMirror plugin|$:/plugins/tiddlywiki/codemirror]] to be installed + diff --git a/plugins/tiddlywiki/codemirror/files/mode/tiddlywiki/tiddlywiki.css b/plugins/tiddlywiki/codemirror-mode-x-tiddlywiki/files/mode/tiddlywiki/tiddlywiki.css similarity index 100% rename from plugins/tiddlywiki/codemirror/files/mode/tiddlywiki/tiddlywiki.css rename to plugins/tiddlywiki/codemirror-mode-x-tiddlywiki/files/mode/tiddlywiki/tiddlywiki.css diff --git a/plugins/tiddlywiki/codemirror-mode-x-tiddlywiki/files/mode/tiddlywiki/tiddlywiki.js b/plugins/tiddlywiki/codemirror-mode-x-tiddlywiki/files/mode/tiddlywiki/tiddlywiki.js new file mode 100755 index 000000000..9012bde9a --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-x-tiddlywiki/files/mode/tiddlywiki/tiddlywiki.js @@ -0,0 +1,3 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE +!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.defineMode("tiddlywiki",function(){var e={},t={allTags:!0,closeAll:!0,list:!0,newJournal:!0,newTiddler:!0,permaview:!0,saveChanges:!0,search:!0,slider:!0,tabs:!0,tag:!0,tagging:!0,tags:!0,tiddler:!0,timeline:!0,today:!0,version:!0,option:!0,with:!0,filter:!0},r=/[\w_\-]/i,n=/^\-\-\-\-+$/,i=/^\/\*\*\*$/,o=/^\*\*\*\/$/,u=/^<<<$/,a=/^\/\/\{\{\{$/,f=/^\/\/\}\}\}$/,c=/^$/,m=/^$/,l=/^\{\{\{$/,k=/^\}\}\}$/,d=/.*?\}\}\}/;function h(e,t,r){return t.tokenize=r,r(e,t)}function s(t,k){var d=t.sol(),s=t.peek();if(k.block=!1,d&&/[<\/\*{}\-]/.test(s)){if(t.match(l))return k.block=!0,h(t,k,$);if(t.match(u))return"quote";if(t.match(i)||t.match(o))return"comment";if(t.match(a)||t.match(f)||t.match(c)||t.match(m))return"comment";if(t.match(n))return"hr"}if(t.next(),d&&/[\/\*!#;:>|]/.test(s)){if("!"==s)return t.skipToEnd(),"header";if("*"==s)return t.eatWhile("*"),"comment";if("#"==s)return t.eatWhile("#"),"comment";if(";"==s)return t.eatWhile(";"),"comment";if(":"==s)return t.eatWhile(":"),"comment";if(">"==s)return t.eatWhile(">"),"quote";if("|"==s)return"header"}if("{"==s&&t.match(/\{\{/))return h(t,k,$);if(/[hf]/i.test(s)&&/[ti]/i.test(t.peek())&&t.match(/\b(ttps?|tp|ile):\/\/[\-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i))return"link";if('"'==s)return"string";if("~"==s)return"brace";if(/[\[\]]/.test(s)&&t.match(s))return"brace";if("@"==s)return t.eatWhile(r),"link";if(/\d/.test(s))return t.eatWhile(/\d/),"number";if("/"==s){if(t.eat("%"))return h(t,k,b);if(t.eat("/"))return h(t,k,v)}if("_"==s&&t.eat("_"))return h(t,k,w);if("-"==s&&t.eat("-")){if(" "!=t.peek())return h(t,k,x);if(" "==t.peek())return"brace"}return"'"==s&&t.eat("'")?h(t,k,p):"<"==s&&t.eat("<")?h(t,k,z):(t.eatWhile(/[\w\$_]/),e.propertyIsEnumerable(t.current())?"keyword":null)}function b(e,t){for(var r,n=!1;r=e.next();){if("/"==r&&n){t.tokenize=s;break}n="%"==r}return"comment"}function p(e,t){for(var r,n=!1;r=e.next();){if("'"==r&&n){t.tokenize=s;break}n="'"==r}return"strong"}function $(e,t){var r=t.block;return r&&e.current()?"comment":!r&&e.match(d)?(t.tokenize=s,"comment"):r&&e.sol()&&e.match(k)?(t.tokenize=s,"comment"):(e.next(),"comment")}function v(e,t){for(var r,n=!1;r=e.next();){if("/"==r&&n){t.tokenize=s;break}n="/"==r}return"em"}function w(e,t){for(var r,n=!1;r=e.next();){if("_"==r&&n){t.tokenize=s;break}n="_"==r}return"underlined"}function x(e,t){for(var r,n=!1;r=e.next();){if("-"==r&&n){t.tokenize=s;break}n="-"==r}return"strikethrough"}function z(e,r){if("<<"==e.current())return"macro";var n=e.next();return n?">"==n&&">"==e.peek()?(e.next(),r.tokenize=s,"macro"):(e.eatWhile(/[\w\$_]/),t.propertyIsEnumerable(e.current())?"keyword":null):(r.tokenize=s,null)}return{startState:function(){return{tokenize:s}},token:function(e,t){return e.eatSpace()?null:t.tokenize(e,t)}}}),e.defineMIME("text/x-tiddlywiki","tiddlywiki")}); \ No newline at end of file diff --git a/plugins/tiddlywiki/codemirror-mode-x-tiddlywiki/files/tiddlywiki.files b/plugins/tiddlywiki/codemirror-mode-x-tiddlywiki/files/tiddlywiki.files new file mode 100755 index 000000000..423cca80e --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-x-tiddlywiki/files/tiddlywiki.files @@ -0,0 +1,19 @@ +{ + "tiddlers": [ + { + "file": "mode/tiddlywiki/tiddlywiki.css", + "fields": { + "type": "text/css", + "title": "$:/plugins/tiddlywiki/codemirror/mode/tiddlywiki/tiddlywiki.css", + "tags": "[[$:/tags/Stylesheet]]" + } + },{ + "file": "mode/tiddlywiki/tiddlywiki.js", + "fields": { + "type": "application/javascript", + "title": "$:/plugins/tiddlywiki/codemirror/mode/tiddlywiki/tiddlywiki.js", + "module-type": "codemirror" + } + } + ] +} diff --git a/plugins/tiddlywiki/codemirror-mode-x-tiddlywiki/plugin.info b/plugins/tiddlywiki/codemirror-mode-x-tiddlywiki/plugin.info new file mode 100755 index 000000000..e58c0bab0 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-x-tiddlywiki/plugin.info @@ -0,0 +1,6 @@ +{ + "title": "$:/plugins/tiddlywiki/codemirror-mode-x-tiddlywiki", + "description": "CodeMirror Mode: Tiddlywiki Classic Highlighting", + "author": "JeremyRuston", + "list": "readme" +} diff --git a/plugins/tiddlywiki/codemirror-mode-x-tiddlywiki/readme.tid b/plugins/tiddlywiki/codemirror-mode-x-tiddlywiki/readme.tid new file mode 100755 index 000000000..a5730b1d6 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-x-tiddlywiki/readme.tid @@ -0,0 +1,4 @@ +title: $:/plugins/tiddlywiki/codemirror-mode-x-tiddlywiki/readme + +This plugin adds Syntax Highlighting for ~TiddlyWiki Classic tiddlers (text/x-tiddlywiki) to the [[CodeMirror|http://codemirror.net]] text editor. It needs the latest [[CodeMirror plugin|$:/plugins/tiddlywiki/codemirror]] to be installed + diff --git a/plugins/tiddlywiki/codemirror-mode-xml/files/mode/xml/xml.js b/plugins/tiddlywiki/codemirror-mode-xml/files/mode/xml/xml.js new file mode 100755 index 000000000..8e6c28829 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-xml/files/mode/xml/xml.js @@ -0,0 +1,3 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE +!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";var e={autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0},n={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,allowMissingTagName:!1,caseFold:!1};t.defineMode("xml",function(r,o){var a,i,l=r.indentUnit,u={},d=o.htmlMode?e:n;for(var c in d)u[c]=d[c];for(var c in o)u[c]=o[c];function s(t,e){function n(n){return e.tokenize=n,n(t,e)}var r=t.next();return"<"==r?t.eat("!")?t.eat("[")?t.match("CDATA[")?n(m("atom","]]>")):null:t.match("--")?n(m("comment","--\x3e")):t.match("DOCTYPE",!0,!0)?(t.eatWhile(/[\w\._\-]/),n(function t(e){return function(n,r){for(var o;null!=(o=n.next());){if("<"==o)return r.tokenize=t(e+1),r.tokenize(n,r);if(">"==o){if(1==e){r.tokenize=s;break}return r.tokenize=t(e-1),r.tokenize(n,r)}}return"meta"}}(1))):null:t.eat("?")?(t.eatWhile(/[\w\._\-]/),e.tokenize=m("meta","?>"),"meta"):(a=t.eat("/")?"closeTag":"openTag",e.tokenize=f,"tag bracket"):"&"==r?(t.eat("#")?t.eat("x")?t.eatWhile(/[a-fA-F\d]/)&&t.eat(";"):t.eatWhile(/[\d]/)&&t.eat(";"):t.eatWhile(/[\w\.\-:]/)&&t.eat(";"))?"atom":"error":(t.eatWhile(/[^&<]/),null)}function f(t,e){var n,r,o=t.next();if(">"==o||"/"==o&&t.eat(">"))return e.tokenize=s,a=">"==o?"endTag":"selfcloseTag","tag bracket";if("="==o)return a="equals",null;if("<"==o){e.tokenize=s,e.state=h,e.tagName=e.tagStart=null;var i=e.tokenize(t,e);return i?i+" tag error":"tag error"}return/[\'\"]/.test(o)?(e.tokenize=(n=o,(r=function(t,e){for(;!t.eol();)if(t.next()==n){e.tokenize=f;break}return"string"}).isInAttribute=!0,r),e.stringStartCol=t.column(),e.tokenize(t,e)):(t.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function m(t,e){return function(n,r){for(;!n.eol();){if(n.match(e)){r.tokenize=s;break}n.next()}return t}}function g(t){t.context&&(t.context=t.context.prev)}function p(t,e){for(var n;;){if(!t.context)return;if(n=t.context.tagName,!u.contextGrabbers.hasOwnProperty(n)||!u.contextGrabbers[n].hasOwnProperty(e))return;g(t)}}function h(t,e,n){return"openTag"==t?(n.tagStart=e.column(),x):"closeTag"==t?b:h}function x(t,e,n){return"word"==t?(n.tagName=e.current(),i="tag",v):u.allowMissingTagName&&"endTag"==t?(i="tag bracket",v(t,e,n)):(i="error",x)}function b(t,e,n){if("word"==t){var r=e.current();return n.context&&n.context.tagName!=r&&u.implicitlyClosed.hasOwnProperty(n.context.tagName)&&g(n),n.context&&n.context.tagName==r||!1===u.matchClosing?(i="tag",k):(i="tag error",w)}return u.allowMissingTagName&&"endTag"==t?(i="tag bracket",k(t,e,n)):(i="error",w)}function k(t,e,n){return"endTag"!=t?(i="error",k):(g(n),h)}function w(t,e,n){return i="error",k(t,0,n)}function v(t,e,n){if("word"==t)return i="attribute",T;if("endTag"==t||"selfcloseTag"==t){var r=n.tagName,o=n.tagStart;return n.tagName=n.tagStart=null,"selfcloseTag"==t||u.autoSelfClosers.hasOwnProperty(r)?p(n,r):(p(n,r),n.context=new function(t,e,n){this.prev=t.context,this.tagName=e,this.indent=t.indented,this.startOfLine=n,(u.doNotIndent.hasOwnProperty(e)||t.context&&t.context.noIndent)&&(this.noIndent=!0)}(n,r,o==n.indented)),h}return i="error",v}function T(t,e,n){return"equals"==t?y:(u.allowMissing||(i="error"),v(t,0,n))}function y(t,e,n){return"string"==t?N:"word"==t&&u.allowUnquoted?(i="string",v):(i="error",v(t,0,n))}function N(t,e,n){return"string"==t?N:v(t,0,n)}return s.isInText=!0,{startState:function(t){var e={tokenize:s,state:h,indented:t||0,tagName:null,tagStart:null,context:null};return null!=t&&(e.baseIndent=t),e},token:function(t,e){if(!e.tagName&&t.sol()&&(e.indented=t.indentation()),t.eatSpace())return null;a=null;var n=e.tokenize(t,e);return(n||a)&&"comment"!=n&&(i=null,e.state=e.state(a||n,t,e),i&&(n="error"==i?n+" error":i)),n},indent:function(e,n,r){var o=e.context;if(e.tokenize.isInAttribute)return e.tagStart==e.indented?e.stringStartCol+1:e.indented+l;if(o&&o.noIndent)return t.Pass;if(e.tokenize!=f&&e.tokenize!=s)return r?r.match(/^(\s*)/)[0].length:0;if(e.tagName)return!1!==u.multilineTagIndentPastTag?e.tagStart+e.tagName.length+2:e.tagStart+l*(u.multilineTagIndentFactor||1);if(u.alignCDATA&&/$/,blockCommentStart:"\x3c!--",blockCommentEnd:"--\x3e",configuration:u.htmlMode?"html":"xml",helperType:u.htmlMode?"html":"xml",skipAttribute:function(t){t.state==y&&(t.state=v)}}}),t.defineMIME("text/xml","xml"),t.defineMIME("application/xml","xml"),t.mimeModes.hasOwnProperty("text/html")||t.defineMIME("text/html",{name:"xml",htmlMode:!0})}); \ No newline at end of file diff --git a/plugins/tiddlywiki/codemirror-mode-xml/files/tiddlywiki.files b/plugins/tiddlywiki/codemirror-mode-xml/files/tiddlywiki.files new file mode 100755 index 000000000..1884e010e --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-xml/files/tiddlywiki.files @@ -0,0 +1,12 @@ +{ + "tiddlers": [ + { + "file": "mode/xml/xml.js", + "fields": { + "type": "application/javascript", + "title": "$:/plugins/tiddlywiki/codemirror/mode/xml/xml.js", + "module-type": "codemirror" + } + } + ] +} diff --git a/plugins/tiddlywiki/codemirror-mode-xml/plugin.info b/plugins/tiddlywiki/codemirror-mode-xml/plugin.info new file mode 100755 index 000000000..29ff6c7bc --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-xml/plugin.info @@ -0,0 +1,6 @@ +{ + "title": "$:/plugins/tiddlywiki/codemirror-mode-xml", + "description": "CodeMirror Mode: XML Highlighting", + "author": "JeremyRuston", + "list": "readme" +} diff --git a/plugins/tiddlywiki/codemirror-mode-xml/readme.tid b/plugins/tiddlywiki/codemirror-mode-xml/readme.tid new file mode 100755 index 000000000..70fa6f996 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-mode-xml/readme.tid @@ -0,0 +1,4 @@ +title: $:/plugins/tiddlywiki/codemirror-mode-xml/readme + +This plugin is a requirement for other Syntax-highlighting plugins and adds Highlighting for XML tiddlers (application/xml) to the [[CodeMirror|http://codemirror.net]] text editor. It needs the latest [[CodeMirror plugin|$:/plugins/tiddlywiki/codemirror]] to be installed + diff --git a/plugins/tiddlywiki/codemirror-search-replace/files/addon/search/jump-to-line.js b/plugins/tiddlywiki/codemirror-search-replace/files/addon/search/jump-to-line.js new file mode 100644 index 000000000..5c0e2d945 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-search-replace/files/addon/search/jump-to-line.js @@ -0,0 +1,3 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE +!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../dialog/dialog"],e):e(CodeMirror)}(function(e){"use strict";function o(e,o){var r=Number(o);return/^[-+]/.test(o)?e.getCursor().line+r:r-1}e.commands.jumpToLine=function(e){var r,i,t,s,n,l=e.getCursor();r=e,i='Jump to line: (Use line:column or scroll% syntax)',t="Jump to line:",s=l.line+1+":"+l.ch,n=function(r){var i;if(r)if(i=/^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(r))e.setCursor(o(e,i[1]),Number(i[2]));else if(i=/^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(r)){var t=Math.round(e.lineCount()*Number(i[1])/100);/^[-+]/.test(i[1])&&(t=l.line+t+1),e.setCursor(t-1,l.ch)}else(i=/^\s*\:?\s*([\+\-]?\d+)\s*/.exec(r))&&e.setCursor(o(e,i[1]),l.ch)},r.openDialog?r.openDialog(i,n,{value:s,selectValueOnOpen:!0}):n(prompt(t,s))},e.keyMap.default["Alt-G"]="jumpToLine"}); \ No newline at end of file diff --git a/plugins/tiddlywiki/codemirror-search-replace/files/addon/search/search.js b/plugins/tiddlywiki/codemirror-search-replace/files/addon/search/search.js new file mode 100644 index 000000000..f61ca05e5 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-search-replace/files/addon/search/search.js @@ -0,0 +1,3 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE +!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./searchcursor"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../dialog/dialog"],e):e(CodeMirror)}(function(e){"use strict";function o(e){return e.state.search||(e.state.search=new function(){this.posFrom=this.posTo=this.lastQuery=this.query=null,this.overlay=null})}function n(e){return"string"==typeof e&&e==e.toLowerCase()}function r(e,o,r){return e.getSearchCursor(o,r,{caseFold:n(o),multiline:!0})}function t(e,o,n,r,t){e.openDialog?e.openDialog(o,t,{value:r,selectValueOnOpen:!0}):t(prompt(n,r))}function i(e){return e.replace(/\\(.)/g,function(e,o){return"n"==o?"\n":"r"==o?"\r":o})}function a(e){var o=e.match(/^\/(.*)\/([a-z]*)$/);if(o)try{e=new RegExp(o[1],-1==o[2].indexOf("i")?"":"i")}catch(e){}else e=i(e);return("string"==typeof e?""==e:e.test(""))&&(e=/x^/),e}var s='Search: (Use /re/ syntax for regexp search)';function c(e,o,r){var t,i;o.queryText=r,o.query=a(r),e.removeOverlay(o.overlay,n(o.query)),o.overlay=(t=o.query,i=n(o.query),"string"==typeof t?t=new RegExp(t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),i?"gi":"g"):t.global||(t=new RegExp(t.source,t.ignoreCase?"gi":"g")),{token:function(e){t.lastIndex=e.pos;var o=t.exec(e.string);if(o&&o.index==e.pos)return e.pos+=o[0].length||1,"searching";o?e.pos=o.index:e.skipToEnd()}}),e.addOverlay(o.overlay),e.showMatchesOnScrollbar&&(o.annotate&&(o.annotate.clear(),o.annotate=null),o.annotate=e.showMatchesOnScrollbar(o.query,n(o.query)))}function l(n,r,i,a){var l=o(n);if(l.query)return u(n,r);var p,d,y,m,g,h=n.getSelection()||l.lastQuery;if(h instanceof RegExp&&"x^"==h.source&&(h=null),i&&n.openDialog){var v=null,x=function(o,r){e.e_stop(r),o&&(o!=l.queryText&&(c(n,l,o),l.posFrom=l.posTo=n.getCursor()),v&&(v.style.opacity=1),u(n,r.shiftKey,function(e,o){var r;o.line<3&&document.querySelector&&(r=n.display.wrapper.querySelector(".CodeMirror-dialog"))&&r.getBoundingClientRect().bottom-4>n.cursorCoords(o,"window").top&&((v=r).style.opacity=.4)}))};d=s,y=h,m=x,g=function(r,t){var i=e.keyName(r),a=n.getOption("extraKeys"),s=a&&a[i]||e.keyMap[n.getOption("keyMap")][i];"findNext"==s||"findPrev"==s||"findPersistentNext"==s||"findPersistentPrev"==s?(e.e_stop(r),c(n,o(n),t),n.execCommand(s)):"find"!=s&&"findPersistent"!=s||(e.e_stop(r),x(t,r))},(p=n).openDialog(d,m,{value:y,selectValueOnOpen:!0,closeOnEnter:!1,onClose:function(){f(p)},onKeyDown:g}),a&&h&&(c(n,l,h),u(n,r))}else t(n,s,"Search for:",h,function(e){e&&!l.query&&n.operation(function(){c(n,l,e),l.posFrom=l.posTo=n.getCursor(),u(n,r)})})}function u(n,t,i){n.operation(function(){var a=o(n),s=r(n,a.query,t?a.posFrom:a.posTo);(s.find(t)||(s=r(n,a.query,t?e.Pos(n.lastLine()):e.Pos(n.firstLine(),0))).find(t))&&(n.setSelection(s.from(),s.to()),n.scrollIntoView({from:s.from(),to:s.to()},20),a.posFrom=s.from(),a.posTo=s.to(),i&&i(s.from(),s.to()))})}function f(e){e.operation(function(){var n=o(e);n.lastQuery=n.query,n.query&&(n.query=n.queryText=null,e.removeOverlay(n.overlay),n.annotate&&(n.annotate.clear(),n.annotate=null))})}var p=' (Use /re/ syntax for regexp search)',d='With: ',y='Replace? ';function m(e,o,n){e.operation(function(){for(var t=r(e,o);t.findNext();)if("string"!=typeof o){var i=e.getRange(t.from(),t.to()).match(o);t.replace(n.replace(/\$(\d)/g,function(e,o){return i[o]}))}else t.replace(n)})}function g(e,n){if(!e.getOption("readOnly")){var s=e.getSelection()||o(e).lastQuery,c=''+(n?"Replace all:":"Replace:")+"";t(e,c+p,c,s,function(o){o&&(o=a(o),t(e,d,"Replace with:","",function(t){if(t=i(t),n)m(e,o,t);else{f(e);var a=r(e,o,e.getCursor("from")),s=function(){var n,i,l,u,f,p=a.from();!(n=a.findNext())&&(a=r(e,o),!(n=a.findNext())||p&&a.from().line==p.line&&a.from().ch==p.ch)||(e.setSelection(a.from(),a.to()),e.scrollIntoView({from:a.from(),to:a.to()}),l=y,u="Replace?",f=[function(){c(n)},s,function(){m(e,o,t)}],(i=e).openConfirm?i.openConfirm(l,f):confirm(u)&&f[0]())},c=function(e){a.replace("string"==typeof o?t:t.replace(/\$(\d)/g,function(o,n){return e[n]})),s()};s()}}))})}}e.commands.find=function(e){f(e),l(e)},e.commands.findPersistent=function(e){f(e),l(e,!1,!0)},e.commands.findPersistentNext=function(e){l(e,!1,!0,!0)},e.commands.findPersistentPrev=function(e){l(e,!0,!0,!0)},e.commands.findNext=l,e.commands.findPrev=function(e){l(e,!0)},e.commands.clearSearch=f,e.commands.replace=g,e.commands.replaceAll=function(e){g(e,!0)}}); \ No newline at end of file diff --git a/plugins/tiddlywiki/codemirror-search-replace/files/addon/search/searchcursor.js b/plugins/tiddlywiki/codemirror-search-replace/files/addon/search/searchcursor.js new file mode 100755 index 000000000..c10445711 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-search-replace/files/addon/search/searchcursor.js @@ -0,0 +1,3 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE +!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";var e,n,r=t.Pos;function i(t,e){for(var n,r,i=null!=(r=(n=t).flags)?r:(n.ignoreCase?"i":"")+(n.global?"g":"")+(n.multiline?"m":""),o=i,l=0;l>1,h=r(t.slice(0,l)).length;if(h==n)return l;h>n?o=l:i=l+1}}function s(t,s,c,f){var u;this.atOccurrence=!1,this.doc=t,c=c?t.clipPos(c):r(0,0),this.pos={from:c,to:c},"object"==typeof f?u=f.caseFold:(u=f,f=null),"string"==typeof s?(null==u&&(u=!1),this.matches=function(i,o){return(i?function(t,i,o,l){if(!i.length)return null;var s=l?e:n,c=s(i).split(/\r|\n\r?/);t:for(var f=o.line,u=o.ch,a=t.firstLine()-1+c.length;f>=a;f--,u=-1){var g=t.getLine(f);u>-1&&(g=g.slice(0,u));var m=s(g);if(1==c.length){var d=m.lastIndexOf(c[0]);if(-1==d)continue t;return{from:r(f,h(g,m,d,s)),to:r(f,h(g,m,d+c[0].length,s))}}var v=c[c.length-1];if(m.slice(0,v.length)==v){var p=1;for(o=f-c.length+1;p=s;o--,h=-1){var c=t.getLine(o);h>-1&&(c=c.slice(0,h));var f=l(c,e);if(f)return{from:r(o,f.index),to:r(o,f.index+f[0].length),match:f}}}:o)(t,s,n)}:this.matches=function(e,n){return(e?function(t,e,n){e=i(e,"gm");for(var o,h=1,s=n.line,c=t.firstLine();s>=c;){for(var f=0;fc);f++){var u=t.getLine(s++);l=null==l?u:l+"\n"+u}h*=2,e.lastIndex=n.ch;var a=e.exec(l);if(a){var g=l.slice(0,a.index).split("\n"),m=a[0].split("\n"),d=n.line+g.length-1,v=g[g.length-1].length;return{from:r(d,v),to:r(d+m.length-1,1==m.length?v+m[0].length:m[m.length-1].length),match:a}}}})(t,s,n)})}String.prototype.normalize?(e=function(t){return t.normalize("NFD").toLowerCase()},n=function(t){return t.normalize("NFD")}):(e=function(t){return t.toLowerCase()},n=function(t){return t}),s.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(e){for(var n=this.matches(e,this.doc.clipPos(e?this.pos.from:this.pos.to));n&&0==t.cmpPos(n.from,n.to);)e?n.from.ch?n.from=r(n.from.line,n.from.ch-1):n=n.from.line==this.doc.firstLine()?null:this.matches(e,this.doc.clipPos(r(n.from.line-1))):n.to.ch0);)r.push({anchor:i.from(),head:i.to()});r.length&&this.setSelections(r,0)})}); \ No newline at end of file diff --git a/plugins/tiddlywiki/codemirror-search-replace/files/tiddlywiki.files b/plugins/tiddlywiki/codemirror-search-replace/files/tiddlywiki.files new file mode 100755 index 000000000..23e05c04a --- /dev/null +++ b/plugins/tiddlywiki/codemirror-search-replace/files/tiddlywiki.files @@ -0,0 +1,26 @@ +{ + "tiddlers": [ + { + "file": "addon/search/search.js", + "fields": { + "type": "application/javascript", + "title": "$:/plugins/tiddlywiki/codemirror/addon/search/search.js", + "module-type": "codemirror" + } + },{ + "file": "addon/search/jump-to-line.js", + "fields": { + "type": "application/javascript", + "title": "$:/plugins/tiddlywiki/codemirror/addon/search/jump-to-line.js", + "module-type": "codemirror" + } + },{ + "file": "addon/search/searchcursor.js", + "fields": { + "type": "application/javascript", + "title": "$:/plugins/tiddlywiki/codemirror/addon/search/searchcursor.js", + "module-type": "codemirror" + } + } + ] +} diff --git a/plugins/tiddlywiki/codemirror-search-replace/plugin.info b/plugins/tiddlywiki/codemirror-search-replace/plugin.info new file mode 100755 index 000000000..6f31daa04 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-search-replace/plugin.info @@ -0,0 +1,6 @@ +{ + "title": "$:/plugins/tiddlywiki/codemirror-search-replace", + "description": "CodeMirror AddOn: Search and Replace", + "author": "JeremyRuston", + "list": "readme" +} diff --git a/plugins/tiddlywiki/codemirror-search-replace/readme.tid b/plugins/tiddlywiki/codemirror-search-replace/readme.tid new file mode 100755 index 000000000..4e39426f2 --- /dev/null +++ b/plugins/tiddlywiki/codemirror-search-replace/readme.tid @@ -0,0 +1,15 @@ +title: $:/plugins/tiddlywiki/codemirror-search-replace/readme + +This plugin enhances the [[CodeMirror|http://codemirror.net]] text editor with Search and Replace functionality. It needs the latest [[CodeMirror plugin|$:/plugins/tiddlywiki/codemirror]] to be installed + +It adds these Keyboard Shortcuts to ~CodeMirror: + +|Shortcut |Function |h +|Ctrl-F / Cmd-F |Start searching | +|Ctrl-G / Cmd-G / Shift-F3 |Find next | +|Shift-Ctrl-G / Shift-Cmd-G / F3 |Find previous | +|Shift-Ctrl-F / Cmd-Option-F |Replace | +|Shift-Ctrl-R / Shift-Cmd-Option-F |Replace all | +|Alt-F |Persistent search (dialog doesn't autoclose, enter to find next, Shift-Enter to find previous) | +|Alt-G |Jump to line | + diff --git a/plugins/tiddlywiki/codemirror/config-language.multids b/plugins/tiddlywiki/codemirror/config-language.multids new file mode 100644 index 000000000..13cd693d9 --- /dev/null +++ b/plugins/tiddlywiki/codemirror/config-language.multids @@ -0,0 +1,22 @@ +title: $:/language/codemirror/ + +homeUrl: http://codemirror.net +addOnUrl: http://codemirror.net/doc/manual.html#addons +configUrl: http://codemirror.net/doc/manual.html#config +controlPanel/hint: These settings let you customise the behaviour of [[CodeMirror|$:/plugins/tiddlywiki/codemirror]]. +controlPanel/usage: Usage information +editorFont/hint: Editor font family +editorFont/info: Set the font family for the ~CodeMirror text-editor +controlPanel/keyboard: Keyboard shortcuts +keyMap/hint: ~CodeMirror keymap +keyMap/info: ~The Keyboard KeyMap used within the ~CodeMirror text-editor +lineNumbers/hint: Enable line numbers +lineNumbers/info: Whether to show line numbers to the left of the editor. +lineWrapping/hint: Enable line wrapping +lineWrapping/info: Whether CodeMirror should scroll or wrap for long lines. Defaults to `false` (scroll). +showCursorWhenSelecting/hint: Show cursor, when selecting +showCursorWhenSelecting/info: Whether the cursor should be drawn when a selection is active. +styleActiveLine/hint: Highlight active line +styleActiveLine/info: Whether or not to highlight the active text-editor line +theme/hint: Select a theme +theme/info: Choose between ~CodeMirror themes diff --git a/plugins/tiddlywiki/codemirror/config.tid b/plugins/tiddlywiki/codemirror/config.tid deleted file mode 100755 index 03e2a73f7..000000000 --- a/plugins/tiddlywiki/codemirror/config.tid +++ /dev/null @@ -1,25 +0,0 @@ -title: $:/config/CodeMirror -type: application/json - -{ - "require": [ - "$:/plugins/tiddlywiki/codemirror/addon/dialog/dialog.js", - "$:/plugins/tiddlywiki/codemirror/addon/search/searchcursor.js", - "$:/plugins/tiddlywiki/codemirror/addon/edit/matchbrackets.js", - "$:/plugins/tiddlywiki/codemirror/addon/mode/multiplex.js", - "$:/plugins/tiddlywiki/codemirror/mode/css/css.js", - "$:/plugins/tiddlywiki/codemirror/mode/htmlembedded/htmlembedded.js", - "$:/plugins/tiddlywiki/codemirror/mode/htmlmixed/htmlmixed.js", - "$:/plugins/tiddlywiki/codemirror/mode/javascript/javascript.js", - "$:/plugins/tiddlywiki/codemirror/mode/markdown/markdown.js", - "$:/plugins/tiddlywiki/codemirror/mode/meta.js", - "$:/plugins/tiddlywiki/codemirror/mode/tiddlywiki/tiddlywiki.js", - "$:/plugins/tiddlywiki/codemirror/mode/xml/xml.js", - "$:/plugins/tiddlywiki/codemirror/keymap/vim.js", - "$:/plugins/tiddlywiki/codemirror/keymap/emacs.js" - ], - "configuration": { - "matchBrackets": true, - "showCursorWhenSelecting": true - } -} \ No newline at end of file diff --git a/plugins/tiddlywiki/codemirror/config/cursorBlinkRate.tid b/plugins/tiddlywiki/codemirror/config/cursorBlinkRate.tid new file mode 100644 index 000000000..1900bcd5a --- /dev/null +++ b/plugins/tiddlywiki/codemirror/config/cursorBlinkRate.tid @@ -0,0 +1,4 @@ +title: $:/config/codemirror/cursorBlinkRate +type: string + +530 diff --git a/plugins/tiddlywiki/codemirror/config/extraKeysTW.tid b/plugins/tiddlywiki/codemirror/config/extraKeysTW.tid new file mode 100644 index 000000000..1be220f75 --- /dev/null +++ b/plugins/tiddlywiki/codemirror/config/extraKeysTW.tid @@ -0,0 +1,15 @@ +title: $:/config/codemirror/extraKeysTW +extend: extraKeys +type: json + +{ + "Ctrl-Esc": "singleSelection", + "Esc": "", + "Ctrl-S": "", + "Ctrl-U": "", + "Ctrl-T": "", + "Alt-T": "transposeChars", + "Alt-U": "undoSelection", + "Shift-Alt-U": "redoSelection", + "Cmd-U": "" +} diff --git a/plugins/tiddlywiki/codemirror/config/indentUnit.tid b/plugins/tiddlywiki/codemirror/config/indentUnit.tid new file mode 100644 index 000000000..c1f88c4f3 --- /dev/null +++ b/plugins/tiddlywiki/codemirror/config/indentUnit.tid @@ -0,0 +1,3 @@ +title: $:/config/codemirror/indentUnit + +2 diff --git a/plugins/tiddlywiki/codemirror/config/inputStyle.tid b/plugins/tiddlywiki/codemirror/config/inputStyle.tid new file mode 100644 index 000000000..6f711e044 --- /dev/null +++ b/plugins/tiddlywiki/codemirror/config/inputStyle.tid @@ -0,0 +1,4 @@ +title: $:/config/codemirror/inputStyle +type: string + +textarea diff --git a/plugins/tiddlywiki/codemirror/config/keyMap.tid b/plugins/tiddlywiki/codemirror/config/keyMap.tid new file mode 100644 index 000000000..0d5645748 --- /dev/null +++ b/plugins/tiddlywiki/codemirror/config/keyMap.tid @@ -0,0 +1,4 @@ +title: $:/config/codemirror/keyMap +type: string + +default diff --git a/plugins/tiddlywiki/codemirror/config/lineNumbers.tid b/plugins/tiddlywiki/codemirror/config/lineNumbers.tid new file mode 100644 index 000000000..edd982e43 --- /dev/null +++ b/plugins/tiddlywiki/codemirror/config/lineNumbers.tid @@ -0,0 +1,4 @@ +title: $:/config/codemirror/lineNumbers +type: bool + +false diff --git a/plugins/tiddlywiki/codemirror/config/lineWrapping.tid b/plugins/tiddlywiki/codemirror/config/lineWrapping.tid new file mode 100644 index 000000000..c9ea61a21 --- /dev/null +++ b/plugins/tiddlywiki/codemirror/config/lineWrapping.tid @@ -0,0 +1,4 @@ +title: $:/config/codemirror/lineWrapping +type: bool + +true \ No newline at end of file diff --git a/plugins/tiddlywiki/codemirror/config/showCursorWhenSelecting.tid b/plugins/tiddlywiki/codemirror/config/showCursorWhenSelecting.tid new file mode 100644 index 000000000..b185e642d --- /dev/null +++ b/plugins/tiddlywiki/codemirror/config/showCursorWhenSelecting.tid @@ -0,0 +1,4 @@ +title: $:/config/codemirror/showCursorWhenSelecting +type: bool + +true diff --git a/plugins/tiddlywiki/codemirror/config/styleActiveLine.tid b/plugins/tiddlywiki/codemirror/config/styleActiveLine.tid new file mode 100644 index 000000000..e4c93af99 --- /dev/null +++ b/plugins/tiddlywiki/codemirror/config/styleActiveLine.tid @@ -0,0 +1,4 @@ +title: $:/config/codemirror/styleActiveLine +type: bool + +false diff --git a/plugins/tiddlywiki/codemirror/config/tabSize.tid b/plugins/tiddlywiki/codemirror/config/tabSize.tid new file mode 100644 index 000000000..d29034594 --- /dev/null +++ b/plugins/tiddlywiki/codemirror/config/tabSize.tid @@ -0,0 +1,3 @@ +title: $:/config/codemirror/tabSize + +4 diff --git a/plugins/tiddlywiki/codemirror/config/theme.tid b/plugins/tiddlywiki/codemirror/config/theme.tid new file mode 100644 index 000000000..a50ff6cc8 --- /dev/null +++ b/plugins/tiddlywiki/codemirror/config/theme.tid @@ -0,0 +1,4 @@ +title: $:/config/codemirror/theme +type: string + +default diff --git a/plugins/tiddlywiki/codemirror/engine.js b/plugins/tiddlywiki/codemirror/engine.js index bec85f5d5..5cfce1f36 100755 --- a/plugins/tiddlywiki/codemirror/engine.js +++ b/plugins/tiddlywiki/codemirror/engine.js @@ -13,14 +13,17 @@ Text editor engine based on a CodeMirror instance "use strict"; var CODEMIRROR_OPTIONS = "$:/config/CodeMirror", - HEIGHT_VALUE_TITLE = "$:/config/TextEditor/EditorHeight/Height" - +HEIGHT_VALUE_TITLE = "$:/config/TextEditor/EditorHeight/Height", +CONFIG_FILTER = "[all[shadows+tiddlers]prefix[$:/config/codemirror/]]" + // Install CodeMirror if($tw.browser && !window.CodeMirror) { + + var modules = $tw.modules.types["codemirror"]; + var req = Object.getOwnPropertyNames(modules); + window.CodeMirror = require("$:/plugins/tiddlywiki/codemirror/lib/codemirror.js"); // Install required CodeMirror plugins - var configOptions = $tw.wiki.getTiddlerData(CODEMIRROR_OPTIONS,{}), - req = configOptions.require; if(req) { if($tw.utils.isArray(req)) { for(var index=0; index 0) { var anchorPos = this.cm.indexFromPos(selections[0].anchor), - headPos = this.cm.indexFromPos(selections[0].head); + headPos = this.cm.indexFromPos(selections[0].head); } var operation = { text: this.cm.getValue(), diff --git a/plugins/tiddlywiki/codemirror/files/addon/dialog/dialog.js b/plugins/tiddlywiki/codemirror/files/addon/dialog/dialog.js index f10bb5bf1..99cbb0325 100755 --- a/plugins/tiddlywiki/codemirror/files/addon/dialog/dialog.js +++ b/plugins/tiddlywiki/codemirror/files/addon/dialog/dialog.js @@ -1,157 +1 @@ -// CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE - -// Open simple dialogs on top of an editor. Relies on dialog.css. - -(function(mod) { - if (typeof exports == "object" && typeof module == "object") // CommonJS - mod(require("../../lib/codemirror")); - else if (typeof define == "function" && define.amd) // AMD - define(["../../lib/codemirror"], mod); - else // Plain browser env - mod(CodeMirror); -})(function(CodeMirror) { - function dialogDiv(cm, template, bottom) { - var wrap = cm.getWrapperElement(); - var dialog; - dialog = wrap.appendChild(document.createElement("div")); - if (bottom) - dialog.className = "CodeMirror-dialog CodeMirror-dialog-bottom"; - else - dialog.className = "CodeMirror-dialog CodeMirror-dialog-top"; - - if (typeof template == "string") { - dialog.innerHTML = template; - } else { // Assuming it's a detached DOM element. - dialog.appendChild(template); - } - return dialog; - } - - function closeNotification(cm, newVal) { - if (cm.state.currentNotificationClose) - cm.state.currentNotificationClose(); - cm.state.currentNotificationClose = newVal; - } - - CodeMirror.defineExtension("openDialog", function(template, callback, options) { - if (!options) options = {}; - - closeNotification(this, null); - - var dialog = dialogDiv(this, template, options.bottom); - var closed = false, me = this; - function close(newVal) { - if (typeof newVal == 'string') { - inp.value = newVal; - } else { - if (closed) return; - closed = true; - dialog.parentNode.removeChild(dialog); - me.focus(); - - if (options.onClose) options.onClose(dialog); - } - } - - var inp = dialog.getElementsByTagName("input")[0], button; - if (inp) { - inp.focus(); - - if (options.value) { - inp.value = options.value; - if (options.selectValueOnOpen !== false) { - inp.select(); - } - } - - if (options.onInput) - CodeMirror.on(inp, "input", function(e) { options.onInput(e, inp.value, close);}); - if (options.onKeyUp) - CodeMirror.on(inp, "keyup", function(e) {options.onKeyUp(e, inp.value, close);}); - - CodeMirror.on(inp, "keydown", function(e) { - if (options && options.onKeyDown && options.onKeyDown(e, inp.value, close)) { return; } - if (e.keyCode == 27 || (options.closeOnEnter !== false && e.keyCode == 13)) { - inp.blur(); - CodeMirror.e_stop(e); - close(); - } - if (e.keyCode == 13) callback(inp.value, e); - }); - - if (options.closeOnBlur !== false) CodeMirror.on(inp, "blur", close); - } else if (button = dialog.getElementsByTagName("button")[0]) { - CodeMirror.on(button, "click", function() { - close(); - me.focus(); - }); - - if (options.closeOnBlur !== false) CodeMirror.on(button, "blur", close); - - button.focus(); - } - return close; - }); - - CodeMirror.defineExtension("openConfirm", function(template, callbacks, options) { - closeNotification(this, null); - var dialog = dialogDiv(this, template, options && options.bottom); - var buttons = dialog.getElementsByTagName("button"); - var closed = false, me = this, blurring = 1; - function close() { - if (closed) return; - closed = true; - dialog.parentNode.removeChild(dialog); - me.focus(); - } - buttons[0].focus(); - for (var i = 0; i < buttons.length; ++i) { - var b = buttons[i]; - (function(callback) { - CodeMirror.on(b, "click", function(e) { - CodeMirror.e_preventDefault(e); - close(); - if (callback) callback(me); - }); - })(callbacks[i]); - CodeMirror.on(b, "blur", function() { - --blurring; - setTimeout(function() { if (blurring <= 0) close(); }, 200); - }); - CodeMirror.on(b, "focus", function() { ++blurring; }); - } - }); - - /* - * openNotification - * Opens a notification, that can be closed with an optional timer - * (default 5000ms timer) and always closes on click. - * - * If a notification is opened while another is opened, it will close the - * currently opened one and open the new one immediately. - */ - CodeMirror.defineExtension("openNotification", function(template, options) { - closeNotification(this, close); - var dialog = dialogDiv(this, template, options && options.bottom); - var closed = false, doneTimer; - var duration = options && typeof options.duration !== "undefined" ? options.duration : 5000; - - function close() { - if (closed) return; - closed = true; - clearTimeout(doneTimer); - dialog.parentNode.removeChild(dialog); - } - - CodeMirror.on(dialog, 'click', function(e) { - CodeMirror.e_preventDefault(e); - close(); - }); - - if (duration) - doneTimer = setTimeout(close, duration); - - return close; - }); -}); +!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function o(e,o,n){var t;return(t=e.getWrapperElement().appendChild(document.createElement("div"))).className=n?"CodeMirror-dialog CodeMirror-dialog-bottom":"CodeMirror-dialog CodeMirror-dialog-top","string"==typeof o?t.innerHTML=o:t.appendChild(o),t}function n(e,o){e.state.currentNotificationClose&&e.state.currentNotificationClose(),e.state.currentNotificationClose=o}e.defineExtension("openDialog",function(t,i,r){r||(r={}),n(this,null);var u=o(this,t,r.bottom),l=!1,c=this;function a(e){if("string"==typeof e)s.value=e;else{if(l)return;l=!0,u.parentNode.removeChild(u),c.focus(),r.onClose&&r.onClose(u)}}var f,s=u.getElementsByTagName("input")[0];return s?(s.focus(),r.value&&(s.value=r.value,!1!==r.selectValueOnOpen&&s.select()),r.onInput&&e.on(s,"input",function(e){r.onInput(e,s.value,a)}),r.onKeyUp&&e.on(s,"keyup",function(e){r.onKeyUp(e,s.value,a)}),e.on(s,"keydown",function(o){r&&r.onKeyDown&&r.onKeyDown(o,s.value,a)||((27==o.keyCode||!1!==r.closeOnEnter&&13==o.keyCode)&&(s.blur(),e.e_stop(o),a()),13==o.keyCode&&i(s.value,o))}),!1!==r.closeOnBlur&&e.on(s,"blur",a)):(f=u.getElementsByTagName("button")[0])&&(e.on(f,"click",function(){a(),c.focus()}),!1!==r.closeOnBlur&&e.on(f,"blur",a),f.focus()),a}),e.defineExtension("openConfirm",function(t,i,r){n(this,null);var u=o(this,t,r&&r.bottom),l=u.getElementsByTagName("button"),c=!1,a=this,f=1;function s(){c||(c=!0,u.parentNode.removeChild(u),a.focus())}l[0].focus();for(var d=0;d", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<"}; - - function findMatchingBracket(cm, where, strict, config) { - var line = cm.getLineHandle(where.line), pos = where.ch - 1; - var match = (pos >= 0 && matching[line.text.charAt(pos)]) || matching[line.text.charAt(++pos)]; - if (!match) return null; - var dir = match.charAt(1) == ">" ? 1 : -1; - if (strict && (dir > 0) != (pos == where.ch)) return null; - var style = cm.getTokenTypeAt(Pos(where.line, pos + 1)); - - var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config); - if (found == null) return null; - return {from: Pos(where.line, pos), to: found && found.pos, - match: found && found.ch == match.charAt(0), forward: dir > 0}; - } - - // bracketRegex is used to specify which type of bracket to scan - // should be a regexp, e.g. /[[\]]/ - // - // Note: If "where" is on an open bracket, then this bracket is ignored. - // - // Returns false when no bracket was found, null when it reached - // maxScanLines and gave up - function scanForBracket(cm, where, dir, style, config) { - var maxScanLen = (config && config.maxScanLineLength) || 10000; - var maxScanLines = (config && config.maxScanLines) || 1000; - - var stack = []; - var re = config && config.bracketRegex ? config.bracketRegex : /[(){}[\]]/; - var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1) - : Math.max(cm.firstLine() - 1, where.line - maxScanLines); - for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) { - var line = cm.getLine(lineNo); - if (!line) continue; - var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length : -1; - if (line.length > maxScanLen) continue; - if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0); - for (; pos != end; pos += dir) { - var ch = line.charAt(pos); - if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) { - var match = matching[ch]; - if ((match.charAt(1) == ">") == (dir > 0)) stack.push(ch); - else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch}; - else stack.pop(); - } - } - } - return lineNo - dir == (dir > 0 ? cm.lastLine() : cm.firstLine()) ? false : null; - } - - function matchBrackets(cm, autoclear, config) { - // Disable brace matching in long lines, since it'll cause hugely slow updates - var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000; - var marks = [], ranges = cm.listSelections(); - for (var i = 0; i < ranges.length; i++) { - var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, false, config); - if (match && cm.getLine(match.from.line).length <= maxHighlightLen) { - var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket"; - marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style})); - if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen) - marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style})); - } - } - - if (marks.length) { - // Kludge to work around the IE bug from issue #1193, where text - // input stops going to the textare whever this fires. - if (ie_lt8 && cm.state.focused) cm.focus(); - - var clear = function() { - cm.operation(function() { - for (var i = 0; i < marks.length; i++) marks[i].clear(); - }); - }; - if (autoclear) setTimeout(clear, 800); - else return clear; - } - } - - var currentlyHighlighted = null; - function doMatchBrackets(cm) { - cm.operation(function() { - if (currentlyHighlighted) {currentlyHighlighted(); currentlyHighlighted = null;} - currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets); - }); - } - - CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) { - if (old && old != CodeMirror.Init) - cm.off("cursorActivity", doMatchBrackets); - if (val) { - cm.state.matchBrackets = typeof val == "object" ? val : {}; - cm.on("cursorActivity", doMatchBrackets); - } - }); - - CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);}); - CodeMirror.defineExtension("findMatchingBracket", function(pos, strict, config){ - return findMatchingBracket(this, pos, strict, config); - }); - CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config){ - return scanForBracket(this, pos, dir, style, config); - }); -}); diff --git a/plugins/tiddlywiki/codemirror/files/addon/mode/multiplex.js b/plugins/tiddlywiki/codemirror/files/addon/mode/multiplex.js deleted file mode 100755 index 3d8b34c45..000000000 --- a/plugins/tiddlywiki/codemirror/files/addon/mode/multiplex.js +++ /dev/null @@ -1,123 +0,0 @@ -// CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE - -(function(mod) { - if (typeof exports == "object" && typeof module == "object") // CommonJS - mod(require("../../lib/codemirror")); - else if (typeof define == "function" && define.amd) // AMD - define(["../../lib/codemirror"], mod); - else // Plain browser env - mod(CodeMirror); -})(function(CodeMirror) { -"use strict"; - -CodeMirror.multiplexingMode = function(outer /*, others */) { - // Others should be {open, close, mode [, delimStyle] [, innerStyle]} objects - var others = Array.prototype.slice.call(arguments, 1); - - function indexOf(string, pattern, from, returnEnd) { - if (typeof pattern == "string") { - var found = string.indexOf(pattern, from); - return returnEnd && found > -1 ? found + pattern.length : found; - } - var m = pattern.exec(from ? string.slice(from) : string); - return m ? m.index + from + (returnEnd ? m[0].length : 0) : -1; - } - - return { - startState: function() { - return { - outer: CodeMirror.startState(outer), - innerActive: null, - inner: null - }; - }, - - copyState: function(state) { - return { - outer: CodeMirror.copyState(outer, state.outer), - innerActive: state.innerActive, - inner: state.innerActive && CodeMirror.copyState(state.innerActive.mode, state.inner) - }; - }, - - token: function(stream, state) { - if (!state.innerActive) { - var cutOff = Infinity, oldContent = stream.string; - for (var i = 0; i < others.length; ++i) { - var other = others[i]; - var found = indexOf(oldContent, other.open, stream.pos); - if (found == stream.pos) { - if (!other.parseDelimiters) stream.match(other.open); - state.innerActive = other; - state.inner = CodeMirror.startState(other.mode, outer.indent ? outer.indent(state.outer, "") : 0); - return other.delimStyle && (other.delimStyle + " " + other.delimStyle + "-open"); - } else if (found != -1 && found < cutOff) { - cutOff = found; - } - } - if (cutOff != Infinity) stream.string = oldContent.slice(0, cutOff); - var outerToken = outer.token(stream, state.outer); - if (cutOff != Infinity) stream.string = oldContent; - return outerToken; - } else { - var curInner = state.innerActive, oldContent = stream.string; - if (!curInner.close && stream.sol()) { - state.innerActive = state.inner = null; - return this.token(stream, state); - } - var found = curInner.close ? indexOf(oldContent, curInner.close, stream.pos, curInner.parseDelimiters) : -1; - if (found == stream.pos && !curInner.parseDelimiters) { - stream.match(curInner.close); - state.innerActive = state.inner = null; - return curInner.delimStyle && (curInner.delimStyle + " " + curInner.delimStyle + "-close"); - } - if (found > -1) stream.string = oldContent.slice(0, found); - var innerToken = curInner.mode.token(stream, state.inner); - if (found > -1) stream.string = oldContent; - - if (found == stream.pos && curInner.parseDelimiters) - state.innerActive = state.inner = null; - - if (curInner.innerStyle) { - if (innerToken) innerToken = innerToken + " " + curInner.innerStyle; - else innerToken = curInner.innerStyle; - } - - return innerToken; - } - }, - - indent: function(state, textAfter) { - var mode = state.innerActive ? state.innerActive.mode : outer; - if (!mode.indent) return CodeMirror.Pass; - return mode.indent(state.innerActive ? state.inner : state.outer, textAfter); - }, - - blankLine: function(state) { - var mode = state.innerActive ? state.innerActive.mode : outer; - if (mode.blankLine) { - mode.blankLine(state.innerActive ? state.inner : state.outer); - } - if (!state.innerActive) { - for (var i = 0; i < others.length; ++i) { - var other = others[i]; - if (other.open === "\n") { - state.innerActive = other; - state.inner = CodeMirror.startState(other.mode, mode.indent ? mode.indent(state.outer, "") : 0); - } - } - } else if (state.innerActive.close === "\n") { - state.innerActive = state.inner = null; - } - }, - - electricChars: outer.electricChars, - - innerMode: function(state) { - return state.inner ? {state: state.inner, mode: state.innerActive.mode} : {state: state.outer, mode: outer}; - } - }; -}; - -}); diff --git a/plugins/tiddlywiki/codemirror/files/addon/search/searchcursor.js b/plugins/tiddlywiki/codemirror/files/addon/search/searchcursor.js deleted file mode 100755 index b70242ee4..000000000 --- a/plugins/tiddlywiki/codemirror/files/addon/search/searchcursor.js +++ /dev/null @@ -1,189 +0,0 @@ -// CodeMirror, copyright (c) by Marijn Haverbeke and others -// Distributed under an MIT license: http://codemirror.net/LICENSE - -(function(mod) { - if (typeof exports == "object" && typeof module == "object") // CommonJS - mod(require("../../lib/codemirror")); - else if (typeof define == "function" && define.amd) // AMD - define(["../../lib/codemirror"], mod); - else // Plain browser env - mod(CodeMirror); -})(function(CodeMirror) { - "use strict"; - var Pos = CodeMirror.Pos; - - function SearchCursor(doc, query, pos, caseFold) { - this.atOccurrence = false; this.doc = doc; - if (caseFold == null && typeof query == "string") caseFold = false; - - pos = pos ? doc.clipPos(pos) : Pos(0, 0); - this.pos = {from: pos, to: pos}; - - // The matches method is filled in based on the type of query. - // It takes a position and a direction, and returns an object - // describing the next occurrence of the query, or null if no - // more matches were found. - if (typeof query != "string") { // Regexp match - if (!query.global) query = new RegExp(query.source, query.ignoreCase ? "ig" : "g"); - this.matches = function(reverse, pos) { - if (reverse) { - query.lastIndex = 0; - var line = doc.getLine(pos.line).slice(0, pos.ch), cutOff = 0, match, start; - for (;;) { - query.lastIndex = cutOff; - var newMatch = query.exec(line); - if (!newMatch) break; - match = newMatch; - start = match.index; - cutOff = match.index + (match[0].length || 1); - if (cutOff == line.length) break; - } - var matchLen = (match && match[0].length) || 0; - if (!matchLen) { - if (start == 0 && line.length == 0) {match = undefined;} - else if (start != doc.getLine(pos.line).length) { - matchLen++; - } - } - } else { - query.lastIndex = pos.ch; - var line = doc.getLine(pos.line), match = query.exec(line); - var matchLen = (match && match[0].length) || 0; - var start = match && match.index; - if (start + matchLen != line.length && !matchLen) matchLen = 1; - } - if (match && matchLen) - return {from: Pos(pos.line, start), - to: Pos(pos.line, start + matchLen), - match: match}; - }; - } else { // String query - var origQuery = query; - if (caseFold) query = query.toLowerCase(); - var fold = caseFold ? function(str){return str.toLowerCase();} : function(str){return str;}; - var target = query.split("\n"); - // Different methods for single-line and multi-line queries - if (target.length == 1) { - if (!query.length) { - // Empty string would match anything and never progress, so - // we define it to match nothing instead. - this.matches = function() {}; - } else { - this.matches = function(reverse, pos) { - if (reverse) { - var orig = doc.getLine(pos.line).slice(0, pos.ch), line = fold(orig); - var match = line.lastIndexOf(query); - if (match > -1) { - match = adjustPos(orig, line, match); - return {from: Pos(pos.line, match), to: Pos(pos.line, match + origQuery.length)}; - } - } else { - var orig = doc.getLine(pos.line).slice(pos.ch), line = fold(orig); - var match = line.indexOf(query); - if (match > -1) { - match = adjustPos(orig, line, match) + pos.ch; - return {from: Pos(pos.line, match), to: Pos(pos.line, match + origQuery.length)}; - } - } - }; - } - } else { - var origTarget = origQuery.split("\n"); - this.matches = function(reverse, pos) { - var last = target.length - 1; - if (reverse) { - if (pos.line - (target.length - 1) < doc.firstLine()) return; - if (fold(doc.getLine(pos.line).slice(0, origTarget[last].length)) != target[target.length - 1]) return; - var to = Pos(pos.line, origTarget[last].length); - for (var ln = pos.line - 1, i = last - 1; i >= 1; --i, --ln) - if (target[i] != fold(doc.getLine(ln))) return; - var line = doc.getLine(ln), cut = line.length - origTarget[0].length; - if (fold(line.slice(cut)) != target[0]) return; - return {from: Pos(ln, cut), to: to}; - } else { - if (pos.line + (target.length - 1) > doc.lastLine()) return; - var line = doc.getLine(pos.line), cut = line.length - origTarget[0].length; - if (fold(line.slice(cut)) != target[0]) return; - var from = Pos(pos.line, cut); - for (var ln = pos.line + 1, i = 1; i < last; ++i, ++ln) - if (target[i] != fold(doc.getLine(ln))) return; - if (fold(doc.getLine(ln).slice(0, origTarget[last].length)) != target[last]) return; - return {from: from, to: Pos(ln, origTarget[last].length)}; - } - }; - } - } - } - - SearchCursor.prototype = { - findNext: function() {return this.find(false);}, - findPrevious: function() {return this.find(true);}, - - find: function(reverse) { - var self = this, pos = this.doc.clipPos(reverse ? this.pos.from : this.pos.to); - function savePosAndFail(line) { - var pos = Pos(line, 0); - self.pos = {from: pos, to: pos}; - self.atOccurrence = false; - return false; - } - - for (;;) { - if (this.pos = this.matches(reverse, pos)) { - this.atOccurrence = true; - return this.pos.match || true; - } - if (reverse) { - if (!pos.line) return savePosAndFail(0); - pos = Pos(pos.line-1, this.doc.getLine(pos.line-1).length); - } - else { - var maxLine = this.doc.lineCount(); - if (pos.line == maxLine - 1) return savePosAndFail(maxLine); - pos = Pos(pos.line + 1, 0); - } - } - }, - - from: function() {if (this.atOccurrence) return this.pos.from;}, - to: function() {if (this.atOccurrence) return this.pos.to;}, - - replace: function(newText, origin) { - if (!this.atOccurrence) return; - var lines = CodeMirror.splitLines(newText); - this.doc.replaceRange(lines, this.pos.from, this.pos.to, origin); - this.pos.to = Pos(this.pos.from.line + lines.length - 1, - lines[lines.length - 1].length + (lines.length == 1 ? this.pos.from.ch : 0)); - } - }; - - // Maps a position in a case-folded line back to a position in the original line - // (compensating for codepoints increasing in number during folding) - function adjustPos(orig, folded, pos) { - if (orig.length == folded.length) return pos; - for (var pos1 = Math.min(pos, orig.length);;) { - var len1 = orig.slice(0, pos1).toLowerCase().length; - if (len1 < pos) ++pos1; - else if (len1 > pos) --pos1; - else return pos1; - } - } - - CodeMirror.defineExtension("getSearchCursor", function(query, pos, caseFold) { - return new SearchCursor(this.doc, query, pos, caseFold); - }); - CodeMirror.defineDocExtension("getSearchCursor", function(query, pos, caseFold) { - return new SearchCursor(this, query, pos, caseFold); - }); - - CodeMirror.defineExtension("selectMatches", function(query, caseFold) { - var ranges = []; - var cur = this.getSearchCursor(query, this.getCursor("from"), caseFold); - while (cur.findNext()) { - if (CodeMirror.cmpPos(cur.to(), this.getCursor("to")) > 0) break; - ranges.push({anchor: cur.from(), head: cur.to()}); - } - if (ranges.length) - this.setSelections(ranges, 0); - }); -}); diff --git a/plugins/tiddlywiki/codemirror/files/addon/selection/activeline.js b/plugins/tiddlywiki/codemirror/files/addon/selection/activeline.js new file mode 100644 index 000000000..7b9555681 --- /dev/null +++ b/plugins/tiddlywiki/codemirror/files/addon/selection/activeline.js @@ -0,0 +1 @@ +!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";var t="CodeMirror-activeline",n="CodeMirror-activeline-background",i="CodeMirror-activeline-gutter";function r(e){for(var r=0;r