mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-30 00:55:00 +00:00
62ec9d92e2
Update: Switched to generic ve.ui.Toolbar and ve.ui.Tool for consistency with VE in general. Changed searchbox to floating and hidden by default. Call for search using shortcut key. Overriden ESC key. Node handler for <syntaxhighlight>'s Rdfa type. Embedded in VisualEditor.php with its own ResourceLoader module. Use $wgVisualEditorEnableExperimentalCode in LocalSettings.php to load the module. Supported languages (for testing): text, javascript Features: (1) Internal mechanisms: (1.1) Tokenizer. Tokenize input code string. (1.2) Highlighter. Highlight based on predefined rules. (1.3) Syntax checker. Validate based on predefined rules. (2) SimpleSurface: (2.1) Auto indenter. Works with (){}[] blocks. (2.2) Reformatter. Reformats spaces and remove trailing whitespaces. (2.3) Language selection dropdown. (2.4) Basic editing. Insert, deletion, selection. (2.5) Clipboard & edit history support. (2.5.1) Undo (Ctrl + Z), redo (Ctrl + Y) (2.5.2) Copy (Ctrl + C), cut (Ctrl + X), paste (Ctrl + V) (2.6) Search & replace. Ctrl + F to quickly move focus to search box. Bug 47742 Change-Id: I4adede9e05fd2236cee50ce03f597e8ff6b1914d
159 lines
4.8 KiB
JSON
159 lines
4.8 KiB
JSON
{
|
|
"highlighter" :
|
|
[
|
|
{
|
|
"match" : "/(\\+|-|\\*|\\/|%|\\!|@|&|\\||\\^|<|>|\\=|,|;|\\?|:|\\.)/g",
|
|
"style" : "ve-ce-mwSynHi-symbol"
|
|
},
|
|
{
|
|
"match" : "/[\\W|^]((break|case|catch|const|continue|default|delete|do|else|finally|for|function|get|goto|if|in|instanceof|new|prototype|return|set|static|switch|this|throw|try|typeof|var|void))(?!\\w)/gm",
|
|
"style" : "ve-ce-mwSynHi-keyword"
|
|
},
|
|
{
|
|
"match" : "/[\\W|^]((false|null|true|undefined|NaN|Infinity))(?!\\w)/g",
|
|
"style" : "ve-ce-mwSynHi-metaconstant"
|
|
},
|
|
{
|
|
"match" : "/[\\W|^]((__proto__|__defineGetter__|__defineSetter__|hasOwnProperty|hasProperty))(?!\\w)/g",
|
|
"style" : "ve-ce-mwSynHi-magicwords"
|
|
},
|
|
{
|
|
"match" : "/[\\W|^]((Object|Function|Date|Math|String|Number|Boolean|Array))(?!\\w)/g",
|
|
"style" : "ve-ce-mwSynHi-typeconstructor"
|
|
},
|
|
{
|
|
"match" : "/[\\W|^]((abstract|boolean|byte|char|class|debugger|double|enum|export|extends|final|float|implements|import|int|interface|long|native|short|super|synchronized|throws|transient|volatile))(?!\\w)/g",
|
|
"style" : "ve-ce-mwSynHi-reserved"
|
|
},
|
|
{
|
|
"match" : "/(\\\\)/g",
|
|
"style" : "ve-ce-mwSynHi-escape"
|
|
},
|
|
{
|
|
"match" : "/(\\(|\\)|\\[|\\]|\\{|\\})/g",
|
|
"style" : "ve-ce-mwSynHi-bracket"
|
|
},
|
|
{
|
|
"match" : "/(['\\\"][^]*?['\\\"])/g",
|
|
"style" : "ve-ce-mwSynHi-string"
|
|
},
|
|
{
|
|
"match" : "/\\W([0-9]+)(?!\\w)/g",
|
|
"style" : "ve-ce-mwSynHi-number"
|
|
},
|
|
{
|
|
"match" : "/(\\w*)\\(\\)/g",
|
|
"style" : "ve-ce-mwSynHi-method"
|
|
},
|
|
{
|
|
"match" : "/(\\/\\/.*$)/gm",
|
|
"style" : "ve-ce-mwSynHi-comment-single"
|
|
},
|
|
{
|
|
"match" : "/(\\/\\*[^]*?\\*\\/)/g",
|
|
"style" : "ve-ce-mwSynHi-comment-multi"
|
|
}
|
|
],
|
|
"validator" :
|
|
[
|
|
{
|
|
"match" : ["/[^\\=\\!](\\=\\=|\\!\\=)(?!\\=)/g"],
|
|
"except" : [],
|
|
"within" : [],
|
|
"outside" : ["/(\\/\\*[^]*?\\*\\/)/g", "/(\\/\\/.*$)/gm", "/(\\\"[^]*?\\\")/g", "/('[^]*?')/g"],
|
|
"decisionMaker" : "error",
|
|
"style" : "ve-ce-mwSynHi-suggestion",
|
|
"tip" : "Use strict comparison instead"
|
|
},
|
|
{
|
|
"match" : ["/([\\t ]+)$/gm"],
|
|
"except" : [],
|
|
"within" : [],
|
|
"outside" : [],
|
|
"decisionMaker" : "error",
|
|
"style" : "ve-ce-mwSynHi-error",
|
|
"tip" : "Trailing whitespace character"
|
|
},
|
|
{
|
|
"match" : ["/(\\+{3,}|-{3,}|<={2,}|>={2,}|={4,})/g"],
|
|
"except" : [],
|
|
"within" : [],
|
|
"outside" : ["/(\\/\\*[^]*?\\*\\/)/g", "/(\\/\\/.*$)/gm", "/(\\\"[^]*?\\\")/g", "/('[^]*?')/g"],
|
|
"decisionMaker" : "error",
|
|
"style" : "ve-ce-mwSynHi-error",
|
|
"tip" : "Unrecognized operator"
|
|
},
|
|
{
|
|
"match" : ["/[\\W|^]var\\s+([0-9]+[a-zA-Z]+)(?!\\w)/g"],
|
|
"except" : [],
|
|
"within" : [],
|
|
"outside" : ["/(\\/\\*[^]*?\\*\\/)/g", "/(\\/\\/.*$)/gm", "/(\\\"[^]*?\\\")/g", "/('[^]*?')/g"],
|
|
"decisionMaker" : "error",
|
|
"style" : "ve-ce-mwSynHi-error",
|
|
"tip" : "Illegal variable name"
|
|
},
|
|
{
|
|
"match" : ["/(\\\")/g"],
|
|
"except" : [],
|
|
"within" : [],
|
|
"outside" : ["/(\\/\\*[^]*?\\*\\/)/g", "/(\\/\\/.*$)/gm", "/('[^]*?')/g"],
|
|
"decisionMaker" : "balanceAA",
|
|
"style" : "ve-ce-mwSynHi-error",
|
|
"tip" : "Unmatched quote"
|
|
},
|
|
{
|
|
"match" : ["/(')/g"],
|
|
"except" : [],
|
|
"within" : [],
|
|
"outside" : ["/(\\/\\*[^]*?\\*\\/)/g", "/(\\/\\/.*$)/gm", "/(\\\"[^]*?\\\")/g"],
|
|
"decisionMaker" : "balanceAA",
|
|
"style" : "ve-ce-mwSynHi-error",
|
|
"tip" : "Unmatched quote"
|
|
},
|
|
{
|
|
"match" : ["/(\\()/","/(\\))/"],
|
|
"except" : [],
|
|
"within" : [],
|
|
"outside" : ["/(\\/\\*[^]*?\\*\\/)/g", "/(\\/\\/.*$)/gm", "/(\\\"[^]*?\\\")/g", "/('[^]*?')/g"],
|
|
"decisionMaker" : "balanceAB",
|
|
"style" : "ve-ce-mwSynHi-error",
|
|
"tip" : "Unmatched bracket"
|
|
},
|
|
{
|
|
"match" : ["/(\\[)/","/(\\])/"],
|
|
"except" : [],
|
|
"within" : [],
|
|
"outside" : ["/(\\/\\*[^]*?\\*\\/)/g", "/(\\/\\/.*$)/gm", "/(\\\"[^]*?\\\")/g", "/('[^]*?')/g"],
|
|
"decisionMaker" : "balanceAB",
|
|
"style" : "ve-ce-mwSynHi-error",
|
|
"tip" : "Unmatched bracket"
|
|
},
|
|
{
|
|
"match" : ["/(\\{)/","/(\\})/"],
|
|
"except" : [],
|
|
"within" : [],
|
|
"outside" : ["/(\\/\\*[^]*?\\*\\/)/g", "/(\\/\\/.*$)/gm", "/(\\\"[^]*?\\\")/g", "/('[^]*?')/g"],
|
|
"decisionMaker" : "balanceAB",
|
|
"style" : "ve-ce-mwSynHi-error",
|
|
"tip" : "Unmatched bracket"
|
|
},
|
|
{
|
|
"match" : ["/\\W(case)(?!\\w)/","/\\W(break)(?!\\w)/"],
|
|
"except" : [],
|
|
"within" : ["/\\Wswitch\\s*?\\(.*?\\)\\s*?\\{([^]*?)\\}/g"],
|
|
"outside" : ["/(\\/\\*[^]*?\\*\\/)/g", "/(\\/\\/.*$)/gm", "/(\\\"[^]*?\\\")/g", "/('[^]*?')/g"],
|
|
"decisionMaker" : "matchAB",
|
|
"style" : "ve-ce-mwSynHi-error",
|
|
"tip" : "Expecting break after case"
|
|
},
|
|
{
|
|
"match" : ["/(switch)(?!\\w)/","/\\W(default\\s*?:)(?!\\w)/"],
|
|
"except" : [],
|
|
"within" : ["/\\W(switch\\s*?\\(.*?\\)\\s*?\\{[^]*?)\\}/g"],
|
|
"outside" : ["/(\\/\\*[^]*?\\*\\/)/g", "/(\\/\\/.*$)/gm", "/(\\\"[^]*?\\\")/g", "/('[^]*?')/g"],
|
|
"decisionMaker" : "matchAB",
|
|
"style" : "ve-ce-mwSynHi-error",
|
|
"tip" : "Expecting a default case"
|
|
}
|
|
]
|
|
} |