Github user benkeen commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/204#discussion_r22274513
--- Diff: app/addons/documents/views-doceditor.js ---
@@ -529,13 +454,160 @@ function (app, FauxtonAPI, Components, Documents,
Databases, prettify) {
showHideEditDocString(event);
});
+ // place focus on the editor
+ editor.editor.focus();
+
}.bind(this));
+
+ // this sucks having to reference #dashboard, but when user clicks
in the region below the editor I want it
+ // to focus on the final line. It feels natural that way
+ $('.scrollable').on('click', function(e) {
+ var clickedInEditor = $(e.target).closest('#editor-container');
+ if (clickedInEditor.length === 0) {
+ editor.editor.focus();
+ var session = editor.editor.getSession();
+ var count = session.getLength();
+ editor.editor.gotoLine(count, session.getLine(count-1).length);
+ }
+ });
+ },
+
+ serialize: function () {
+ return {
+ doc: this.model,
+ attachments: this.getAttachments()
+ };
+ },
+
+ getAttachments: function () {
+ var attachments = this.model.get('_attachments');
+ if (!attachments) { return false; }
+
+ return _.map(attachments, function (att, key) {
+ return {
+ fileName: key,
+ size: att.length,
+ contentType: att.content_type,
+ url: this.model.url() + '/' + app.utils.safeURLName(key)
+ };
+ }, this);
+ },
+
+ determineStringEditMatch: function (event) {
+ var selStart = this.editor.getSelectionStart().row;
+ var selEnd = this.editor.getSelectionEnd().row;
+
+ // one JS(ON) string can't span more than one line - we edit one
string, so ensure we don't select several lines
+ if (selStart >=0 && selEnd >= 0 && selStart === selEnd &&
this.editor.isRowExpanded(selStart)) {
+ var editLine = this.editor.getLine(selStart),
+ editMatch = editLine.match(/^([ \t]*)(["|'][a-zA-Z0-9_]*["|']:
)?(["|'].*["|'],?[ \t]*)$/);
+
+ if (editMatch) {
+ return editMatch;
+ }
+ }
+ return null;
+ },
+
+ showHideEditDocString: function (event) {
--- End diff --
I'd removed the string editing code, then put it back in. Probably wasn't
in the same spot.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---