Merge branch 'develop' into luke/fix-rte-tab-complete-after-join
This commit is contained in:
commit
f091d209b9
7 changed files with 143 additions and 88 deletions
|
@ -62,7 +62,6 @@
|
||||||
"glob": "^5.0.14",
|
"glob": "^5.0.14",
|
||||||
"highlight.js": "^8.9.1",
|
"highlight.js": "^8.9.1",
|
||||||
"isomorphic-fetch": "^2.2.1",
|
"isomorphic-fetch": "^2.2.1",
|
||||||
"liblevenshtein": "^2.0.4",
|
|
||||||
"linkifyjs": "^2.1.3",
|
"linkifyjs": "^2.1.3",
|
||||||
"lodash": "^4.13.1",
|
"lodash": "^4.13.1",
|
||||||
"matrix-js-sdk": "matrix-org/matrix-js-sdk#develop",
|
"matrix-js-sdk": "matrix-org/matrix-js-sdk#develop",
|
||||||
|
|
|
@ -1,4 +1,19 @@
|
||||||
//@flow
|
//@flow
|
||||||
|
/*
|
||||||
|
Copyright 2017 Aviral Dasgupta
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
import {ContentState} from 'draft-js';
|
import {ContentState} from 'draft-js';
|
||||||
import * as RichText from './RichText';
|
import * as RichText from './RichText';
|
||||||
|
|
|
@ -1,91 +1,107 @@
|
||||||
import Levenshtein from 'liblevenshtein';
|
/*
|
||||||
import _at from 'lodash/at';
|
Copyright 2017 Aviral Dasgupta
|
||||||
import _flatMap from 'lodash/flatMap';
|
|
||||||
import _sortBy from 'lodash/sortBy';
|
|
||||||
import _sortedUniq from 'lodash/sortedUniq';
|
|
||||||
import _keys from 'lodash/keys';
|
|
||||||
|
|
||||||
class KeyMap {
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
keys: Array<String>;
|
you may not use this file except in compliance with the License.
|
||||||
objectMap: {[String]: Array<Object>};
|
You may obtain a copy of the License at
|
||||||
priorityMap: {[String]: number}
|
|
||||||
}
|
|
||||||
|
|
||||||
const DEFAULT_RESULT_COUNT = 10;
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
const DEFAULT_DISTANCE = 5;
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//import Levenshtein from 'liblevenshtein';
|
||||||
|
//import _at from 'lodash/at';
|
||||||
|
//import _flatMap from 'lodash/flatMap';
|
||||||
|
//import _sortBy from 'lodash/sortBy';
|
||||||
|
//import _sortedUniq from 'lodash/sortedUniq';
|
||||||
|
//import _keys from 'lodash/keys';
|
||||||
|
//
|
||||||
|
//class KeyMap {
|
||||||
|
// keys: Array<String>;
|
||||||
|
// objectMap: {[String]: Array<Object>};
|
||||||
|
// priorityMap: {[String]: number}
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//const DEFAULT_RESULT_COUNT = 10;
|
||||||
|
//const DEFAULT_DISTANCE = 5;
|
||||||
|
|
||||||
// FIXME Until Fuzzy matching works better, we use prefix matching.
|
// FIXME Until Fuzzy matching works better, we use prefix matching.
|
||||||
|
|
||||||
import PrefixMatcher from './QueryMatcher';
|
import PrefixMatcher from './QueryMatcher';
|
||||||
export default PrefixMatcher;
|
export default PrefixMatcher;
|
||||||
|
|
||||||
class FuzzyMatcher { // eslint-disable-line no-unused-vars
|
//class FuzzyMatcher { // eslint-disable-line no-unused-vars
|
||||||
/**
|
// /**
|
||||||
* @param {object[]} objects the objects to perform a match on
|
// * @param {object[]} objects the objects to perform a match on
|
||||||
* @param {string[]} keys an array of keys within each object to match on
|
// * @param {string[]} keys an array of keys within each object to match on
|
||||||
* Keys can refer to object properties by name and as in JavaScript (for nested properties)
|
// * Keys can refer to object properties by name and as in JavaScript (for nested properties)
|
||||||
*
|
// *
|
||||||
* To use, simply presort objects by required criteria, run through this function and create a FuzzyMatcher with the
|
// * To use, simply presort objects by required criteria, run through this function and create a FuzzyMatcher with the
|
||||||
* resulting KeyMap.
|
// * resulting KeyMap.
|
||||||
*
|
// *
|
||||||
* TODO: Handle arrays and objects (Fuse did this, RoomProvider uses it)
|
// * TODO: Handle arrays and objects (Fuse did this, RoomProvider uses it)
|
||||||
* @return {KeyMap}
|
// * @return {KeyMap}
|
||||||
*/
|
// */
|
||||||
static valuesToKeyMap(objects: Array<Object>, keys: Array<String>): KeyMap {
|
// static valuesToKeyMap(objects: Array<Object>, keys: Array<String>): KeyMap {
|
||||||
const keyMap = new KeyMap();
|
// const keyMap = new KeyMap();
|
||||||
const map = {};
|
// const map = {};
|
||||||
const priorities = {};
|
// const priorities = {};
|
||||||
|
//
|
||||||
objects.forEach((object, i) => {
|
// objects.forEach((object, i) => {
|
||||||
const keyValues = _at(object, keys);
|
// const keyValues = _at(object, keys);
|
||||||
console.log(object, keyValues, keys);
|
// console.log(object, keyValues, keys);
|
||||||
for (const keyValue of keyValues) {
|
// for (const keyValue of keyValues) {
|
||||||
if (!map.hasOwnProperty(keyValue)) {
|
// if (!map.hasOwnProperty(keyValue)) {
|
||||||
map[keyValue] = [];
|
// map[keyValue] = [];
|
||||||
}
|
// }
|
||||||
map[keyValue].push(object);
|
// map[keyValue].push(object);
|
||||||
}
|
// }
|
||||||
priorities[object] = i;
|
// priorities[object] = i;
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
keyMap.objectMap = map;
|
// keyMap.objectMap = map;
|
||||||
keyMap.priorityMap = priorities;
|
// keyMap.priorityMap = priorities;
|
||||||
keyMap.keys = _sortBy(_keys(map), [(value) => priorities[value]]);
|
// keyMap.keys = _sortBy(_keys(map), [(value) => priorities[value]]);
|
||||||
return keyMap;
|
// return keyMap;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
constructor(objects: Array<Object>, options: {[Object]: Object} = {}) {
|
// constructor(objects: Array<Object>, options: {[Object]: Object} = {}) {
|
||||||
this.options = options;
|
// this.options = options;
|
||||||
this.keys = options.keys;
|
// this.keys = options.keys;
|
||||||
this.setObjects(objects);
|
// this.setObjects(objects);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
setObjects(objects: Array<Object>) {
|
// setObjects(objects: Array<Object>) {
|
||||||
this.keyMap = FuzzyMatcher.valuesToKeyMap(objects, this.keys);
|
// this.keyMap = FuzzyMatcher.valuesToKeyMap(objects, this.keys);
|
||||||
console.log(this.keyMap.keys);
|
// console.log(this.keyMap.keys);
|
||||||
this.matcher = new Levenshtein.Builder()
|
// this.matcher = new Levenshtein.Builder()
|
||||||
.dictionary(this.keyMap.keys, true)
|
// .dictionary(this.keyMap.keys, true)
|
||||||
.algorithm('transposition')
|
// .algorithm('transposition')
|
||||||
.sort_candidates(false)
|
// .sort_candidates(false)
|
||||||
.case_insensitive_sort(true)
|
// .case_insensitive_sort(true)
|
||||||
.include_distance(true)
|
// .include_distance(true)
|
||||||
.maximum_candidates(this.options.resultCount || DEFAULT_RESULT_COUNT) // result count 0 doesn't make much sense
|
// .maximum_candidates(this.options.resultCount || DEFAULT_RESULT_COUNT) // result count 0 doesn't make much sense
|
||||||
.build();
|
// .build();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
match(query: String): Array<Object> {
|
// match(query: String): Array<Object> {
|
||||||
const candidates = this.matcher.transduce(query, this.options.distance || DEFAULT_DISTANCE);
|
// const candidates = this.matcher.transduce(query, this.options.distance || DEFAULT_DISTANCE);
|
||||||
// TODO FIXME This is hideous. Clean up when possible.
|
// // TODO FIXME This is hideous. Clean up when possible.
|
||||||
const val = _sortedUniq(_sortBy(_flatMap(candidates, (candidate) => {
|
// const val = _sortedUniq(_sortBy(_flatMap(candidates, (candidate) => {
|
||||||
return this.keyMap.objectMap[candidate[0]].map((value) => {
|
// return this.keyMap.objectMap[candidate[0]].map((value) => {
|
||||||
return {
|
// return {
|
||||||
distance: candidate[1],
|
// distance: candidate[1],
|
||||||
...value,
|
// ...value,
|
||||||
};
|
// };
|
||||||
});
|
// });
|
||||||
}),
|
// }),
|
||||||
[(candidate) => candidate.distance, (candidate) => this.keyMap.priorityMap[candidate]]));
|
// [(candidate) => candidate.distance, (candidate) => this.keyMap.priorityMap[candidate]]));
|
||||||
console.log(val);
|
// console.log(val);
|
||||||
return val;
|
// return val;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,4 +1,19 @@
|
||||||
//@flow
|
//@flow
|
||||||
|
/*
|
||||||
|
Copyright 2017 Aviral Dasgupta
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
import _at from 'lodash/at';
|
import _at from 'lodash/at';
|
||||||
import _flatMap from 'lodash/flatMap';
|
import _flatMap from 'lodash/flatMap';
|
||||||
|
|
|
@ -656,7 +656,7 @@ module.exports = React.createClass({
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td><strong>Autocomplete Delay (ms): </strong></td>
|
<td><strong>{_t('Autocomplete Delay (ms):')}</strong></td>
|
||||||
<td>
|
<td>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
|
|
|
@ -69,12 +69,21 @@ class PasswordLogin extends React.Component {
|
||||||
|
|
||||||
onSubmitForm(ev) {
|
onSubmitForm(ev) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
|
if (this.state.loginType === PasswordLogin.LOGIN_FIELD_PHONE) {
|
||||||
this.props.onSubmit(
|
this.props.onSubmit(
|
||||||
this.state.username,
|
'', // XXX: Synapse breaks if you send null here:
|
||||||
this.state.phoneCountry,
|
this.state.phoneCountry,
|
||||||
this.state.phoneNumber,
|
this.state.phoneNumber,
|
||||||
this.state.password,
|
this.state.password,
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.props.onSubmit(
|
||||||
|
this.state.username,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
this.state.password,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onUsernameChanged(ev) {
|
onUsernameChanged(ev) {
|
||||||
|
|
|
@ -922,5 +922,6 @@
|
||||||
"Ignore request": "Ignore request",
|
"Ignore request": "Ignore request",
|
||||||
"You added a new device '%(displayName)s', which is requesting encryption keys.": "You added a new device '%(displayName)s', which is requesting encryption keys.",
|
"You added a new device '%(displayName)s', which is requesting encryption keys.": "You added a new device '%(displayName)s', which is requesting encryption keys.",
|
||||||
"Your unverified device '%(displayName)s' is requesting encryption keys.": "Your unverified device '%(displayName)s' is requesting encryption keys.",
|
"Your unverified device '%(displayName)s' is requesting encryption keys.": "Your unverified device '%(displayName)s' is requesting encryption keys.",
|
||||||
"Encryption key request": "Encryption key request"
|
"Encryption key request": "Encryption key request",
|
||||||
|
"Autocomplete Delay (ms):": "Autocomplete Delay (ms):"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue