diff --git a/build.sh b/build.sh index 45538c23..7f40c87b 100755 --- a/build.sh +++ b/build.sh @@ -226,7 +226,6 @@ if ! [ -f _site/assets/editor-codemirror.js ] || ! [ -f _site/assets/editor-elm. editor/cm/addon/search/search.js \ editor/cm/addon/dialog/dialog.js \ editor/cm/lib/active-line.js \ - editor/cm/addon/dialog/dialog.js \ editor/cm/keymap/sublime.js \ | uglifyjs -o _site/assets/editor-codemirror.js @@ -234,7 +233,7 @@ if ! [ -f _site/assets/editor-codemirror.js ] || ! [ -f _site/assets/editor-elm. cat editor/code-editor.js editor/column-divider.js | uglifyjs -o _site/assets/editor-custom-elements.js # styles - cat editor/cm/lib/codemirror.css editor/editor.css > _site/assets/editor-styles.css + cat editor/cm/lib/codemirror.css editor/cm/addon/dialog/dialog.css editor/editor.css > _site/assets/editor-styles.css # elm (cd editor ; elm make src/Page/Editor.elm --optimize --output=elm.js) diff --git a/editor/cm/addon/dialog/dialog.css b/editor/cm/addon/dialog/dialog.css new file mode 100644 index 00000000..677c0783 --- /dev/null +++ b/editor/cm/addon/dialog/dialog.css @@ -0,0 +1,32 @@ +.CodeMirror-dialog { + position: absolute; + left: 0; right: 0; + background: inherit; + z-index: 15; + padding: .1em .8em; + overflow: hidden; + color: inherit; +} + +.CodeMirror-dialog-top { + border-bottom: 1px solid #eee; + top: 0; +} + +.CodeMirror-dialog-bottom { + border-top: 1px solid #eee; + bottom: 0; +} + +.CodeMirror-dialog input { + border: none; + outline: none; + background: transparent; + width: 20em; + color: inherit; + font-family: monospace; +} + +.CodeMirror-dialog button { + font-size: 70%; +} diff --git a/editor/code-editor.js b/editor/code-editor.js index fd7521ac..c40753e3 100644 --- a/editor/code-editor.js +++ b/editor/code-editor.js @@ -110,9 +110,15 @@ value: this._source, tabSize: 2, indentWithTabs: false, + // Increase off-screen lines CodeMirror puts in DOM, for browser's native search. + // Won't scale to huge files, hopefully fine for Elm examples. + viewportMargin: 500, extraKeys: { "Tab": handleTab, "Shift-Tab": handleUntab, + // "findPersistent" behavior is closer to browser's native search than "find". + "Cmd-F": "findPersistent", + "Ctrl-F": "findPersistent", "Cmd-S": function(cm) { sendSaveEvent(); }, "Ctrl-Enter": function(cm) { sendSaveEvent(); } } @@ -363,4 +369,4 @@ window.customElements.define('code-editor', CodeEditor); -})(); \ No newline at end of file +})();