From 1f9c1ca6c6f1111536bfcf5c375948498d6dc76b Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Fri, 22 Jun 2018 16:00:12 +0100 Subject: [PATCH] Extracts envs to separate file so they can be exported to rich text --- .../auto-complete/EnvironmentManager.coffee | 34 +++---------------- .../snippets/Environments.coffee | 29 ++++++++++++++++ 2 files changed, 34 insertions(+), 29 deletions(-) create mode 100644 services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/snippets/Environments.coffee diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/EnvironmentManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/EnvironmentManager.coffee index 156389e73d..52ea7983f9 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/EnvironmentManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/EnvironmentManager.coffee @@ -1,31 +1,7 @@ -define () -> - environments = [ - "abstract", - "align", "align*", - "equation", "equation*", - "gather", "gather*", - "multline", "multline*", - "split", - "verbatim", - "quote", - "center" - ] - - snippetNames = [ - "array", - "figure", - "tabular", - "table", - "list", - "enumerate", - "itemize", - "frame", - "thebibliography" - ] - - environmentNames = snippetNames.concat(environments) - - staticSnippets = for env in environments +define [ + 'ide/editor/directives/aceEditor/auto-complete/snippets/Environments' +], (Environments) -> + staticSnippets = for env in Environments.withoutSnippets { caption: "\\begin{#{env}}..." snippet: """ @@ -151,7 +127,7 @@ define () -> result = [] iterations = 0 while match = re.exec(text) - if match[1] not in environmentNames and match[1] != "document" + if match[1] not in Environments.all and match[1] != "document" result.push {name: match[1], whitespace: match[2]} iterations += 1 if iterations >= 1000 diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/snippets/Environments.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/snippets/Environments.coffee new file mode 100644 index 0000000000..0c46c17f97 --- /dev/null +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/snippets/Environments.coffee @@ -0,0 +1,29 @@ +define () -> + envs = [ + "abstract", + "align", "align*", + "equation", "equation*", + "gather", "gather*", + "multline", "multline*", + "split", + "verbatim", + "quote", + "center" + ] + + envsWithSnippets = [ + "array", + "figure", + "tabular", + "table", + "list", + "enumerate", + "itemize", + "frame", + "thebibliography" + ] + + return { + all: envs.concat(envsWithSnippets) + withoutSnippets: envs + } \ No newline at end of file