1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-19 16:24:51 +00:00
TiddlyWiki5/plugins/tiddlywiki/codemirror-autocomplete/files/addon/hint/xml-hint.js

4 lines
2.5 KiB
JavaScript
Raw Normal View History

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
2018-04-06 16:34:50 +00:00
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://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(H){"use strict";var R=H.Pos;function z(t,e,r){return r?0<=t.indexOf(e):0==t.lastIndexOf(e,0)}H.registerHelper("hint","xml",function(t,e){var r=e&&e.schemaInfo,n=e&&e.quoteChar||'"',s=e&&e.matchInMiddle;if(r){var i=t.getCursor(),o=t.getTokenAt(i);if(o.end>i.ch&&(o.end=i.ch,o.string=o.string.slice(0,i.ch-o.start)),(p=H.innerMode(t.getMode(),o.state)).mode.xmlCurrentTag){var a,l,g,c=[],f=!1,h=/\btag\b/.test(o.type)&&!/>$/.test(o.string),u=h&&/^\w/.test(o.string);u?(M=t.getLine(i.line).slice(Math.max(0,o.start-2),o.start),(g=/<\/$/.test(M)?"close":/<$/.test(M)?"open":null)&&(l=o.start-("close"==g?2:1))):h&&"<"==o.string?g="open":h&&"</"==o.string&&(g="close");var d=p.mode.xmlCurrentTag(p.state);if(!h&&!d||g){u&&(a=o.string),f=g;var p,m=p.mode.xmlCurrentContext?p.mode.xmlCurrentContext(p.state):[],v=(p=m.length&&m[m.length-1])&&r[p],y=p?v&&v.children:r["!top"];if(y&&"close"!=g)for(var x=0;x<y.length;++x)a&&!z(y[x],a,s)||c.push("<"+y[x]);else if("close"!=g)for(var C in r)!r.hasOwnProperty(C)||"!top"==C||"!attrs"==C||a&&!z(C,a,s)||c.push("<"+C);p&&(!a||"close"==g&&z(p,a,s))&&c.push("</"+p+">")}else{var b=(v=d&&r[d.name])&&v.attrs,O=r["!attrs"];if(!b&&!O)return;if(b){if(O){var w={};for(var A in O)O.hasOwnProperty(A)&&(w[A]=O[A]);for(var A in b)b.hasOwnProperty(A)&&(w[A]=b[A]);b=w}}else b=O;if("string"==o.type||"="==o.string){var M,P,$,I,T,j=(M=t.getRange(R(i.line,Math.max(0,i.ch-60)),R(i.line,"string"==o.type?o.start:o.end))).match(/([^\s\u00a0=<>\"\']+)=$/);if(!j||!b.hasOwnProperty(j[1])||!(P=b[j[1]]))return;"function"==typeof P&&(P=P.call(this,t)),"string"==o.type&&(a=o.string,$=0,/['"]/.test(o.string.charAt(0))&&(n=o.string.charAt(0),a=o.string.slice(1),$++),I=o.string.length,/['"]/.test(o.string.charAt(I-1))&&(n=o.string.charAt(I-1),a=o.string.substr($,I-2)),!$||(T=t.getLine(i.line)).length>o.end&&T.charAt(o.end)==n&&o.end++,f=!0);var q=function(t){if(t)for(var e=0;e<t.length;++e)a&&!z(t[e],a,s)||c.push(n+t[e]+n);return k()};return P&&P.then?P.then(q):q(P)}for(var L in"attribute"==o.type&&(a=o.string,f=!0),b)!b.hasOwnProperty(L)||a&&!z(L,a,s)||c.push(L)}return k()}}function k(){return{list:c,from:f?R(i.line,null==l?o.start:l):i,to:f?R(i.line,o.end):i}}})});