diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee index d786dbb9ec..4d62a57e8e 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/CommandManager.coffee @@ -1,5 +1,5 @@ define [ - "./top_hundred_snippets" + "./snippets/TopHundredSnippets" ], (topHundred) -> class Parser 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 diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/top_hundred_snippets.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/snippets/TopHundredSnippets.coffee similarity index 100% rename from services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/top_hundred_snippets.coffee rename to services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/snippets/TopHundredSnippets.coffee diff --git a/services/web/public/coffee/ide/editor/directives/aceEditor/metadata/MetadataManager.coffee b/services/web/public/coffee/ide/editor/directives/aceEditor/metadata/MetadataManager.coffee index c9308626bc..196fae2a56 100644 --- a/services/web/public/coffee/ide/editor/directives/aceEditor/metadata/MetadataManager.coffee +++ b/services/web/public/coffee/ide/editor/directives/aceEditor/metadata/MetadataManager.coffee @@ -53,31 +53,12 @@ define [ lastCommandFragmentIsReqPack if linesContainMeta or lastCommandFragmentIsMeta - @scheduleLoadCurrentDocMetaFromServer() + @Metadata.scheduleLoadDocMetaFromServer @$scope.docId @editor.on "changeSession", (e) => e.oldSession.off "change", onChange e.session.on "change", onChange - - loadDocMetaFromServer: (docId) -> - @Metadata.loadDocMetaFromServer docId - - scheduleLoadCurrentDocMetaFromServer: () -> - # De-bounce loading labels with a timeout - currentDocId = @$scope.docId - existingTimeout = @debouncer[currentDocId] - if existingTimeout? - clearTimeout(existingTimeout) - delete @debouncer[currentDocId] - @debouncer[currentDocId] = setTimeout( - () => - @loadDocMetaFromServer currentDocId - delete @debouncer[currentDocId] - , 1000 - , this - ) - getAllLabels: () -> @Metadata.getAllLabels() diff --git a/services/web/public/coffee/ide/metadata/services/metadata.coffee b/services/web/public/coffee/ide/metadata/services/metadata.coffee index 009474b9f4..a431c54a50 100644 --- a/services/web/public/coffee/ide/metadata/services/metadata.coffee +++ b/services/web/public/coffee/ide/metadata/services/metadata.coffee @@ -3,6 +3,7 @@ define [ ], (App) -> App.factory 'metadata', ($http, ide) -> + debouncer = {} # DocId => Timeout state = {documents: {}} @@ -46,4 +47,19 @@ define [ {_csrf: window.csrfToken} ) + metadata.scheduleLoadDocMetaFromServer = (docId) -> + # De-bounce loading labels with a timeout + existingTimeout = debouncer[docId] + + if existingTimeout? + clearTimeout(existingTimeout) + delete debouncer[docId] + + debouncer[docId] = setTimeout( + () => + metadata.loadDocMetaFromServer docId + delete debouncer[docId] + , 1000 + ) + return metadata diff --git a/services/web/public/stylesheets/_style_includes.less b/services/web/public/stylesheets/_style_includes.less index 58aa7db70a..968304ba3d 100644 --- a/services/web/public/stylesheets/_style_includes.less +++ b/services/web/public/stylesheets/_style_includes.less @@ -91,4 +91,5 @@ @import "../js/libs/pdfListView/HighlightsLayer.css"; @import "../js/libs/select/select.css"; @import "vendor/codemirror.css"; -@import "vendor/codemirror-dialog.css"; \ No newline at end of file +@import "vendor/codemirror-dialog.css"; +@import "vendor/codemirror-show-hint.css"; diff --git a/services/web/public/stylesheets/vendor/codemirror-show-hint.css b/services/web/public/stylesheets/vendor/codemirror-show-hint.css new file mode 100644 index 0000000000..5617ccca2b --- /dev/null +++ b/services/web/public/stylesheets/vendor/codemirror-show-hint.css @@ -0,0 +1,36 @@ +.CodeMirror-hints { + position: absolute; + z-index: 10; + overflow: hidden; + list-style: none; + + margin: 0; + padding: 2px; + + -webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2); + -moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2); + box-shadow: 2px 3px 5px rgba(0,0,0,.2); + border-radius: 3px; + border: 1px solid silver; + + background: white; + font-size: 90%; + font-family: monospace; + + max-height: 20em; + overflow-y: auto; +} + +.CodeMirror-hint { + margin: 0; + padding: 0 4px; + border-radius: 2px; + white-space: pre; + color: black; + cursor: pointer; +} + +li.CodeMirror-hint-active { + background: #08f; + color: white; +}