diff --git a/template/wiki/plugins/Gk0Wk/codemirror-mode-tiddlywiki5/hint/hint-tiddlywiki5.js b/template/wiki/plugins/Gk0Wk/codemirror-mode-tiddlywiki5/hint/hint-tiddlywiki5.js new file mode 100644 index 00000000..a6de9ef9 --- /dev/null +++ b/template/wiki/plugins/Gk0Wk/codemirror-mode-tiddlywiki5/hint/hint-tiddlywiki5.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";e.defineInitHook(function(e){e.options.hintOptions={completeSingle:!1},e.on("change",function(e,i){e.state.completeActive||"function"!=typeof e.showHint||e.showHint()})}),e.registerHelper("hint","tiddlywiki5",function(i){for(var t=i.getCursor(),r=i.getLine(t.line),o=t.ch,n=t.ch,l=30,s=[".","]","}",">"],c=["[","{","|",'"'];o;){var f=r.charAt(o-1);if(n-o>l||s.includes(f))return null;if(c.includes(f))break;o--}if(0==o)return null;var d=o!==n&&r.slice(o,n);return"$"==r.charAt(o)?{list:$tw.wiki.filterTiddlers(`[all[tiddlers]search:title:literal[${d}]!prefix[$:/state]]`),from:e.Pos(t.line,o),to:e.Pos(t.line,n)}:{list:$tw.wiki.filterTiddlers(`[all[tiddlers]!is[system]!is[shadow]search:title:literal[${d}]!prefix[$:/state]]`),from:e.Pos(t.line,o),to:e.Pos(t.line,n)}})}); \ No newline at end of file diff --git a/template/wiki/plugins/Gk0Wk/codemirror-mode-tiddlywiki5/mode/tex.js b/template/wiki/plugins/Gk0Wk/codemirror-mode-tiddlywiki5/mode/tex.js new file mode 100644 index 00000000..105d0f34 --- /dev/null +++ b/template/wiki/plugins/Gk0Wk/codemirror-mode-tiddlywiki5/mode/tex.js @@ -0,0 +1 @@ +(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";t.defineMode("tex",function(t,e){function n(t,e){t.cmdState.push(e)}function r(t){return t.cmdState.length>0?t.cmdState[t.cmdState.length-1]:null}function i(t){var e=t.cmdState.pop();e&&e.closeBracket()}function a(t){for(var e=t.cmdState,n=e.length-1;n>=0;n--){var r=e[n];if("DEFAULT"!=r.name)return r}return{styleIdentifier:function(){return null}}}function c(t,e,n){return function(){this.name=t,this.bracketNo=0,this.style=e,this.styles=n,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}function o(t,e){t.f=e}function u(t,e){var i;if(t.match(/^\\[a-zA-Z@]+/)){var c=t.current().slice(1);return i=l.hasOwnProperty(c)?l[c]:l.DEFAULT,i=new i,n(e,i),o(e,m),i.style}if(t.match(/^\\[$&%#{}_]/))return"tag";if(t.match(/^\\[,;!\/\\]/))return"tag";if(t.match("\\["))return o(e,function(t,e){return f(t,e,"\\]")}),"keyword";if(t.match("\\("))return o(e,function(t,e){return f(t,e,"\\)")}),"keyword";if(t.match("$$"))return o(e,function(t,e){return f(t,e,"$$")}),"keyword";if(t.match("$"))return o(e,function(t,e){return f(t,e,"$")}),"keyword";var u=t.next();return"%"==u?(t.skipToEnd(),"comment"):"}"==u||"]"==u?(i=r(e),i?(i.closeBracket(u),o(e,m),"bracket"):"error"):"{"==u||"["==u?(i=l.DEFAULT,i=new i,n(e,i),"bracket"):/\d/.test(u)?(t.eatWhile(/[\w.%]/),"atom"):(t.eatWhile(/[\w\-_]/),i=a(e),"begin"==i.name&&(i.argument=t.current()),i.styleIdentifier())}function f(t,e,n){if(t.eatSpace())return null;if(n&&t.match(n))return o(e,u),"keyword";if(t.match(/^\\[a-zA-Z@]+/))return"tag";if(t.match(/^[a-zA-Z]+/))return"variable-2";if(t.match(/^\\[$&%#{}_]/))return"tag";if(t.match(/^\\[,;!\/]/))return"tag";if(t.match(/^[\^_&]/))return"tag";if(t.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(t.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var r=t.next();return"{"==r||"}"==r||"["==r||"]"==r||"("==r||")"==r?"bracket":"%"==r?(t.skipToEnd(),"comment"):"error"}function m(t,e){var n,a=t.peek();return"{"==a||"["==a?(n=r(e),n.openBracket(a),t.eat(a),o(e,u),"bracket"):/[ \t\r]/.test(a)?(t.eat(a),null):(o(e,u),i(e),u(t,e))}var l={};return l.importmodule=c("importmodule","tag",["string","builtin"]),l.documentclass=c("documentclass","tag",["","atom"]),l.usepackage=c("usepackage","tag",["atom"]),l.begin=c("begin","tag",["atom"]),l.end=c("end","tag",["atom"]),l.label=c("label","tag",["atom"]),l.ref=c("ref","tag",["atom"]),l.eqref=c("eqref","tag",["atom"]),l.cite=c("cite","tag",["atom"]),l.bibitem=c("bibitem","tag",["atom"]),l.Bibitem=c("Bibitem","tag",["atom"]),l.RBibitem=c("RBibitem","tag",["atom"]),l.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}},{startState:function(){var t=e.inMathMode?function(t,e){return f(t,e)}:u;return{cmdState:[],f:t}},copyState:function(t){return{cmdState:t.cmdState.slice(),f:t.f}},token:function(t,e){return e.f(t,e)},blankLine:function(t){t.f=u,t.cmdState.length=0},lineComment:"%"}}),t.defineMIME("text/x-stex","tex"),t.defineMIME("text/x-latex","tex")}); \ No newline at end of file diff --git a/template/wiki/plugins/Gk0Wk/codemirror-mode-tiddlywiki5/mode/tiddlywiki5.js b/template/wiki/plugins/Gk0Wk/codemirror-mode-tiddlywiki5/mode/tiddlywiki5.js new file mode 100644 index 00000000..e460bba9 --- /dev/null +++ b/template/wiki/plugins/Gk0Wk/codemirror-mode-tiddlywiki5/mode/tiddlywiki5.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";e.defineMode("tiddlywiki5",function(t,o){function n(o){if(e.findModeByName){var n=e.findModeByName(o);n&&(o=n.mime||n.mimes[0])}var i=e.getMode(t,o);return"null"==i.name?null:i}function i(e,t,o){return t.tokenize=o,o(e,t)}function r(e){e.line++,e.listLevel=0,e.boldLine=!1}function a(e,t){var o=e.sol(),n=l(o,e,t);return null==n&&(n=""),t.quoteLevel>0&&o&&(n+=" quote quote-"+t.quoteLevel),null!=t.codeBlockModeState&&(n+=" comment"),t.listLevel>0&&(n+=" list "+h.rainbow[t.listLevel%h.rainbow.length]),t.boldLine&&(n+=" strong"),n}function l(e,t,o){var n=t.peek();if(e&&/[<\/\*{}\-`]/.test(n)){if(t.match(x))return S(t,o);if(t.match(B))return"hr";var r=null;if(r=t.match(y,!1))return b(t,o,r)}var a=null;if(e&&(a=t.match(/^\s*([\/\*!#;:>|])/))){if(n=a[1],"!"===n){for(var l=1;t.eat("!");)l++;return t.skipToEnd(),"header h"+l}if(/[\*#;:]/.test(n)){for(var L=1,T=n;n=t.eat(/[\*#;:]/);)L++,T=n;return o.boldLine=";"===T,o.listLevel=L,"list "+h.rainbow[L%h.rainbow.length]+(";"===T?" strong":"")}if(">"===n)return t.eatWhile(">"),"quote";if("|"===n)return"header"}return t.next(),/[hf]/i.test(n)&&/[ti]/i.test(t.peek())&&t.match(/\b(ttps?|tp|ile):\/\/[\-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i,!0)?"externallink link":"$"==n&&t.match("$",!1)&&!t.match("$$",!1)?(t.next(),p(t,o)):"`"==n?i(t,o,c):"/"==n&&t.eat("/")?i(t,o,u):"{"==n&&t.eat("{")?i(t,o,f):"["==n&&t.eat("[")?i(t,o,k):"_"==n&&t.eat("_")?i(t,o,s):"^"==n&&t.eat("^")?i(t,o,v):","==n&&t.eat(",")?i(t,o,m):"~"==n&&t.eat("~")?i(t,o,M):"'"==n&&t.eat("'")?i(t,o,d):"<"==n&&t.eat("<")?i(t,o,g):null}function d(e,t){for(var o,n=!1;o=e.next();){if("'"==o&&n){t.tokenize=a;break}n="'"==o}return"strong"}function c(e,t){for(var o;o=e.next();)if("`"==o){t.tokenize=a;break}return"comment"}function u(e,t){for(var o,n=!1;o=e.next();){if("/"==o&&n){t.tokenize=a;break}n="/"==o}return"em"}function f(e,t){for(var o,n=!1;o=e.next();){if("}"==o&&n){t.tokenize=a;break}n="}"==o}return"builtin"}function k(e,t){if("[["==e.current())return t.pastDivider=!1,"link";if("]"==e.peek()&&(e.next(),"]"==e.next()))return t.tokenize=a,"link";for(var o,n=t.pastDivider;o=e.peek();){if(!n&&"|"==o)return e.next(),t.pastDivider=!0,"internallink link";if("]"==o&&"]"==e.peek())return"internallink link";if(o=e.next(),/[hf]/i.test(o)&&/[ti]/i.test(e.peek())&&e.match(/\b(ttps?|tp|ile):\/\/[\-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i,!0))return"externallink link";e.eatWhile(/[^|\]]/)}return null}function s(e,t){for(var o,n=!1;o=e.next();){if("_"==o&&n){t.tokenize=a;break}n="_"==o}return"underlined"}function m(e,t){for(var o,n=!1;o=e.next();){if(","==o&&n){t.tokenize=a;break}n=","==o}return"string subscript"}function v(e,t){for(var o,n=!1;o=e.next();){if("^"==o&&n){t.tokenize=a;break}n="^"==o}return"string superscript"}function M(e,t){for(var o,n=!1;o=e.next();){if("~"==o&&n){t.tokenize=a;break}n="~"==o}return"strikethrough"}function p(t,i){i.tokenize=a;var r=o.fencedCodeBlockHighlighting&&n("text/x-latex");return i.LaTeXModeState=r?{mode:r,state:e.startState(r)}:"unknown","comment"}function b(t,i,r){return i.tokenize=function(t,i){i.tokenize=a;var l=o.fencedCodeBlockHighlighting&&n(r[1]||o.fencedCodeBlockDefaultMode);return i.codeBlockModeState=l?{mode:l,state:e.startState(l)}:"unknown",r[1]?(t.skipToEnd(),"tag"):null},t.match("```"),"comment"}function S(e,t){for(var o=1;e.match(x);)o++;return t.quoteLevel==o?t.quoteLevel--:t.quoteLevel"==o&&">"==e.peek()?(e.next(),t.tokenize=a,"macro"):(e.eatWhile(/[\w\$_]/),L.propertyIsEnumerable(e.current())?"keyword":"macro"):(t.tokenize=a,null)}var h={rainbow:["keyword","variable-2","variable-3"]},L={changecount:!0,colour:!0,"colour-picker":!0,contrastcolour:!0,"copy-to-clipboard":!0,csvtiddlers:!0,datauri:!0,dumpvariables:!0,"image-picker":!0,jsontiddler:!0,jsontiddlers:!0,lingo:!0,"list-links":!0,"list-links-draggable":!0,"list-tagged-draggable":!0,"list-thumbnails":!0,makedatauri:!0,now:!0,qualify:!0,resolvepath:!0,"box-shadow":!0,filter:!0,transition:!0,"background-linear-gradient":!0,"transform-origin":!0,toc:!0,"toc-expandable":!0,"toc-selective-expandable":!0,"toc-tabbed-internal-nav":!0,"toc-tabbed-external-nav":!0,tabs:!0,tag:!0,"tag-picker":!0,"tag-pill":!0,thumbnail:!0,timeline:!0,tree:!0,unusedtitle:!0,version:!0};void 0===o.fencedCodeBlockHighlighting&&(o.fencedCodeBlockHighlighting=!0),void 0===o.fencedCodeBlockDefaultMode&&(o.fencedCodeBlockDefaultMode="text/plain");var B=/^\-\-\-+$/,x=/^<<