You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to follow the documentation on Creating or Extending an Edit Mode and was unsuccessful. I was simply trying to add a few keywords to the existing Ruby highligher. I'm in a Vue.js 2 project using webpack and this was how I got it to work:
<script>import*asacefrom'ace-builds'exportdefault{
...
mounted: function(){this.editor=ace.edit('editor')this.editor.setTheme('ace/theme/twilight')constopenC3Mode=this.buildOpenC3Mode()this.editor.session.setMode(newopenC3Mode())...}methods: {buildOpenC3Mode(){
var oop=ace.require('ace/lib/oop')varRubyHighlightRules=ace.require('ace/mode/ruby_highlight_rules').RubyHighlightRulesletapis=Object.getOwnPropertyNames(OpenC3Api.prototype).filter((a)=>a!=='constructor').filter((a)=>a!=='exec')// Create a RegExp with all our keywords like (cmd|tlm|...)letregex=newRegExp(`(${apis.join('|')})`)varOpenC3HighlightRules=function(){RubyHighlightRules.call(this)// add openc3 rules to the ruby rulesfor(varruleinthis.$rules){this.$rules[rule].unshift({regex: regex,token: 'support.function',})}}oop.inherits(OpenC3HighlightRules,RubyHighlightRules)varMatchingBraceOutdent=ace.require('ace/mode/matching_brace_outdent').MatchingBraceOutdentvarCstyleBehaviour=ace.require('ace/mode/behaviour/cstyle').CstyleBehaviourvarFoldMode=ace.require('ace/mode/folding/ruby').FoldModevarMode=function(){this.HighlightRules=OpenC3HighlightRulesthis.$outdent=newMatchingBraceOutdent()this.$behaviour=newCstyleBehaviour()this.foldingRules=newFoldMode()this.indentKeywords=this.foldingRules.indentKeywords}varRubyMode=ace.require('ace/mode/ruby').Modeoop.inherits(Mode,RubyMode);(function(){this.$id='ace/mode/openc3'}.call(Mode.prototype))returnMode},},}</script>
This discussion was converted from issue #4896 on September 13, 2022 14:18.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Describe the issue
I was trying to follow the documentation on Creating or Extending an Edit Mode and was unsuccessful. I was simply trying to add a few keywords to the existing Ruby highligher. I'm in a Vue.js 2 project using webpack and this was how I got it to work:
Links
https://github.com/ajaxorg/ace/wiki/Creating-or-Extending-an-Edit-Mode
Beta Was this translation helpful? Give feedback.
All reactions