From 7f2ce89554e3675f553d2658fc0a04cd5facf088 Mon Sep 17 00:00:00 2001 From: Andrea Ulliana Date: Thu, 17 Jan 2019 12:12:54 +0000 Subject: [IMP] web: add JS-related lib files for ace editor In task handled in https://github.com/odoo/odoo/pull/29999, we will need support for javascript files in ace editor. This commit adds the related lib files. See https://ace.c9.io/#extending-highlighters: https://github.com/ajaxorg/ace/tree/master/lib/ace/mode 1. https://github.com/ajaxorg/ace/blob/master/lib/ace/mode/doc_comment_highlight_rules.js 2. https://github.com/ajaxorg/ace/blob/master/lib/ace/mode/javascript_highlight_rules.js 3. https://github.com/ajaxorg/ace/blob/master/lib/ace/mode/javascript.js task-1919350 --- .../static/lib/ace/javascript_highlight_rules.js | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 addons/web/static/lib/ace/javascript_highlight_rules.js (limited to 'addons/web/static/lib/ace/javascript_highlight_rules.js') diff --git a/addons/web/static/lib/ace/javascript_highlight_rules.js b/addons/web/static/lib/ace/javascript_highlight_rules.js new file mode 100644 index 00000000000..8a8675b5d85 --- /dev/null +++ b/addons/web/static/lib/ace/javascript_highlight_rules.js @@ -0,0 +1,48 @@ +define("ace/mode/doc_comment_highlight_rules",["require","exports","module"], function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, + DocCommentHighlightRules.getTagRule(), + { + defaultToken : "comment.doc", + caseInsensitive: true + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getTagRule = function(start) { + return { + token : "comment.doc.tag.storage.type", + regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b" + }; +}; + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + regex : "\\*\\/", + next : start + }; +}; + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); -- cgit v1.2.3