Browse Source

Disable monaco-editor's context menu

pull/6/head
Menci 6 years ago
parent
commit
efa3d5a1c4
  1. 80
      static/self/monaco-editor.js

80
static/self/monaco-editor.js

@ -90,7 +90,7 @@ require(['vs/editor/editor.main'], function () {
end: new RegExp("^\\s*#pragma\\s+endregion\\b") end: new RegExp("^\\s*#pragma\\s+endregion\\b")
} }
} }
}); });
} }
var csharpAliases = ['csharp', 'cs', 'c#']; var csharpAliases = ['csharp', 'cs', 'c#'];
@ -133,7 +133,7 @@ require(['vs/editor/editor.main'], function () {
} }
}); });
} }
monaco.languages.register({ id: 'haskell' }); monaco.languages.register({ id: 'haskell' });
MonacoAceTokenizer.registerRulesForLanguage('haskell', new HaskellDefinition.default); MonacoAceTokenizer.registerRulesForLanguage('haskell', new HaskellDefinition.default);
monaco.languages.setLanguageConfiguration('haskell', { monaco.languages.setLanguageConfiguration('haskell', {
@ -203,7 +203,7 @@ require(['vs/editor/editor.main'], function () {
} }
} }
}); });
var javascriptAliases = ['javascript', 'js']; var javascriptAliases = ['javascript', 'js'];
for (var i in javascriptAliases) { for (var i in javascriptAliases) {
var alias = javascriptAliases[i]; var alias = javascriptAliases[i];
@ -258,7 +258,7 @@ require(['vs/editor/editor.main'], function () {
end: new RegExp("^\\s*//\\s*#?endregion\\b") end: new RegExp("^\\s*//\\s*#?endregion\\b")
} }
} }
}); });
} }
var pascalAliases = ['pascal', 'pas']; var pascalAliases = ['pascal', 'pas'];
@ -346,7 +346,7 @@ require(['vs/editor/editor.main'], function () {
end: new RegExp("^\\s*#endregion\\b") end: new RegExp("^\\s*#endregion\\b")
} }
} }
}); });
} }
monaco.languages.register({ id: 'ruby' }); monaco.languages.register({ id: 'ruby' });
@ -416,107 +416,107 @@ require(['vs/editor/editor.main'], function () {
monaco.languages.setMonarchTokensProvider(alias, { monaco.languages.setMonarchTokensProvider(alias, {
defaultToken: '', defaultToken: '',
tokenPostfix: '.md', tokenPostfix: '.md',
// escape codes // escape codes
control: /[\\`*_\[\]{}()#+\-\.!\$]/, control: /[\\`*_\[\]{}()#+\-\.!\$]/,
noncontrol: /[^\\`*_\[\]{}()#+\-\.!\$]/, noncontrol: /[^\\`*_\[\]{}()#+\-\.!\$]/,
escapes: /\\(?:@control)/, escapes: /\\(?:@control)/,
// escape codes for javascript/CSS strings // escape codes for javascript/CSS strings
jsescapes: /\\(?:[btnfr\\"']|[0-7][0-7]?|[0-3][0-7]{2})/, jsescapes: /\\(?:[btnfr\\"']|[0-7][0-7]?|[0-3][0-7]{2})/,
// non matched elements // non matched elements
empty: [ empty: [
'area', 'base', 'basefont', 'br', 'col', 'frame', 'area', 'base', 'basefont', 'br', 'col', 'frame',
'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param' 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param'
], ],
tokenizer: { tokenizer: {
root: [ root: [
// headers (with #) // headers (with #)
[/^(\s{0,3})(#+)((?:[^\\#]|@escapes)+)((?:#+)?)/, ['white', 'keyword', 'keyword', 'keyword']], [/^(\s{0,3})(#+)((?:[^\\#]|@escapes)+)((?:#+)?)/, ['white', 'keyword', 'keyword', 'keyword']],
// headers (with =) // headers (with =)
[/^\s*(=+|\-+)\s*$/, 'keyword'], [/^\s*(=+|\-+)\s*$/, 'keyword'],
// headers (with ***) // headers (with ***)
[/^\s*((\*[ ]?)+)\s*$/, 'meta.separator'], [/^\s*((\*[ ]?)+)\s*$/, 'meta.separator'],
// quote // quote
[/^\s*>+/, 'comment'], [/^\s*>+/, 'comment'],
// list (starting with * or number) // list (starting with * or number)
[/^\s*([\*\-+:]|\d+\.)\s/, 'keyword'], [/^\s*([\*\-+:]|\d+\.)\s/, 'keyword'],
// code block (4 spaces indent) // code block (4 spaces indent)
[/^(\t|[ ]{4})[^ ].*$/, 'string'], [/^(\t|[ ]{4})[^ ].*$/, 'string'],
// code block (3 tilde) // code block (3 tilde)
[/^\s*~~~\s*((?:\w|[\/\-#])+)?\s*$/, { token: 'string', next: '@codeblock' }], [/^\s*~~~\s*((?:\w|[\/\-#])+)?\s*$/, { token: 'string', next: '@codeblock' }],
// display math // display math
[/\$\$/, { token: 'string', next: '@displaymath' }], [/\$\$/, { token: 'string', next: '@displaymath' }],
// github style code blocks (with backticks and language) // github style code blocks (with backticks and language)
[/^\s*```\s*((?:\w|[\/\-#\+])+)\s*$/, { token: 'string', next: '@codeblockgh', nextEmbedded: '$1' }], [/^\s*```\s*((?:\w|[\/\-#\+])+)\s*$/, { token: 'string', next: '@codeblockgh', nextEmbedded: '$1' }],
// github style code blocks (with backticks but no language) // github style code blocks (with backticks but no language)
[/^\s*```\s*$/, { token: 'string', next: '@codeblock' }], [/^\s*```\s*$/, { token: 'string', next: '@codeblock' }],
// markup within lines // markup within lines
{ include: '@linecontent' }, { include: '@linecontent' },
], ],
displaymath: [ displaymath: [
[/\\\$/, 'variable.source'], [/\\\$/, 'variable.source'],
[/\$\$/, { token: 'string', next: '@pop' }], [/\$\$/, { token: 'string', next: '@pop' }],
[/./, 'variable.source'] [/./, 'variable.source']
], ],
codeblock: [ codeblock: [
[/^\s*~~~\s*$/, { token: 'string', next: '@pop' }], [/^\s*~~~\s*$/, { token: 'string', next: '@pop' }],
[/^\s*```\s*$/, { token: 'string', next: '@pop' }], [/^\s*```\s*$/, { token: 'string', next: '@pop' }],
[/.*$/, 'variable.source'], [/.*$/, 'variable.source'],
], ],
// github style code blocks // github style code blocks
codeblockgh: [ codeblockgh: [
[/```\s*$/, { token: 'variable.source', next: '@pop', nextEmbedded: '@pop' }], [/```\s*$/, { token: 'variable.source', next: '@pop', nextEmbedded: '@pop' }],
[/[^`]+/, 'variable.source'], [/[^`]+/, 'variable.source'],
], ],
linecontent: [ linecontent: [
// inline math // inline math
[/\$/, { token: 'string', next: '@inlinemath' }], [/\$/, { token: 'string', next: '@inlinemath' }],
// escapes // escapes
[/&\w+;/, 'string.escape'], [/&\w+;/, 'string.escape'],
[/@escapes/, 'escape'], [/@escapes/, 'escape'],
// various markup // various markup
[/\b__([^\\_]|@escapes|_(?!_))+__\b/, 'strong'], [/\b__([^\\_]|@escapes|_(?!_))+__\b/, 'strong'],
[/\*\*([^\\*]|@escapes|\*(?!\*))+\*\*/, 'strong'], [/\*\*([^\\*]|@escapes|\*(?!\*))+\*\*/, 'strong'],
[/\b_[^_]+_\b/, 'emphasis'], [/\b_[^_]+_\b/, 'emphasis'],
[/\*([^\\*]|@escapes)+\*/, 'emphasis'], [/\*([^\\*]|@escapes)+\*/, 'emphasis'],
[/`([^\\`]|@escapes)+`/, 'variable'], [/`([^\\`]|@escapes)+`/, 'variable'],
// links // links
[/\{+[^}]+\}+/, 'string.target'], [/\{+[^}]+\}+/, 'string.target'],
[/(!?\[)((?:[^\]\\]|@escapes)*)(\]\([^\)]+\))/, ['string.link', '', 'string.link']], [/(!?\[)((?:[^\]\\]|@escapes)*)(\]\([^\)]+\))/, ['string.link', '', 'string.link']],
[/(!?\[)((?:[^\]\\]|@escapes)*)(\])/, 'string.link'], [/(!?\[)((?:[^\]\\]|@escapes)*)(\])/, 'string.link'],
// or html // or html
{ include: 'html' }, { include: 'html' },
], ],
inlinemath: [ inlinemath: [
[/\\\$/, 'variable.source'], [/\\\$/, 'variable.source'],
[/\$/, { token: 'string', next: '@pop' }], [/\$/, { token: 'string', next: '@pop' }],
[/./, 'variable.source'] [/./, 'variable.source']
], ],
// Note: it is tempting to rather switch to the real HTML mode instead of building our own here // Note: it is tempting to rather switch to the real HTML mode instead of building our own here
// but currently there is a limitation in Monarch that prevents us from doing it: The opening // but currently there is a limitation in Monarch that prevents us from doing it: The opening
// '<' would start the HTML mode, however there is no way to jump 1 character back to let the // '<' would start the HTML mode, however there is no way to jump 1 character back to let the
@ -532,17 +532,17 @@ require(['vs/editor/editor.main'], function () {
} }
}], }],
[/<\/(\w+)\s*>/, { token: 'tag' }], [/<\/(\w+)\s*>/, { token: 'tag' }],
[/<!--/, 'comment', '@comment'] [/<!--/, 'comment', '@comment']
], ],
comment: [ comment: [
[/[^<\-]+/, 'comment.content'], [/[^<\-]+/, 'comment.content'],
[/-->/, 'comment', '@pop'], [/-->/, 'comment', '@pop'],
[/<!--/, 'comment.content.invalid'], [/<!--/, 'comment.content.invalid'],
[/[<\-]/, 'comment.content'] [/[<\-]/, 'comment.content']
], ],
// Almost full HTML tag matching, complete with embedded scripts & styles // Almost full HTML tag matching, complete with embedded scripts & styles
tag: [ tag: [
[/[ \t\r\n]+/, 'white'], [/[ \t\r\n]+/, 'white'],
@ -568,20 +568,20 @@ require(['vs/editor/editor.main'], function () {
} }
}], }],
], ],
embeddedStyle: [ embeddedStyle: [
[/[^<]+/, ''], [/[^<]+/, ''],
[/<\/style\s*>/, { token: '@rematch', next: '@pop', nextEmbedded: '@pop' }], [/<\/style\s*>/, { token: '@rematch', next: '@pop', nextEmbedded: '@pop' }],
[/</, ''] [/</, '']
], ],
embeddedScript: [ embeddedScript: [
[/[^<]+/, ''], [/[^<]+/, ''],
[/<\/script\s*>/, { token: '@rematch', next: '@pop', nextEmbedded: '@pop' }], [/<\/script\s*>/, { token: '@rematch', next: '@pop', nextEmbedded: '@pop' }],
[/</, ''] [/</, '']
], ],
} }
}); });
} }
$.getScript(window.pathSelfLib + "monaco-editor-tomorrow.js", function () { $.getScript(window.pathSelfLib + "monaco-editor-tomorrow.js", function () {
@ -605,7 +605,8 @@ require(['vs/editor/editor.main'], function () {
vertical: 'hidden' vertical: 'hidden'
}, },
overviewRulerBorder: false, overviewRulerBorder: false,
hideCursorInOverviewRuler: true hideCursorInOverviewRuler: true,
contextmenu: false
}); });
}; };
@ -644,7 +645,8 @@ require(['vs/editor/editor.main'], function () {
verticalScrollbarSize: 10 verticalScrollbarSize: 10
}, },
overviewRulerBorder: false, overviewRulerBorder: false,
hideCursorInOverviewRuler: true hideCursorInOverviewRuler: true,
contextmenu: false
}); });
input.form.addEventListener('submit', function () { input.form.addEventListener('submit', function () {

Loading…
Cancel
Save