mirror of https://github.com/vector-im/riot-web
Linting
parent
004d4828f8
commit
89afcfd897
|
@ -21,14 +21,14 @@ class HistoryItem {
|
|||
let {message} = this;
|
||||
if (format === 'markdown') {
|
||||
if (this.format === 'html') {
|
||||
message = _flow([RichText.HTMLtoContentState, RichText.stateToMarkdown])(message);
|
||||
message = _flow([RichText.htmlToContentState, RichText.stateToMarkdown])(message);
|
||||
}
|
||||
return ContentState.createFromText(message);
|
||||
} else {
|
||||
if (this.format === 'markdown') {
|
||||
message = new Markdown(message).toHTML();
|
||||
}
|
||||
return RichText.HTMLtoContentState(message);
|
||||
return RichText.htmlToContentState(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ export const contentStateToHTML = (contentState: ContentState) => {
|
|||
});
|
||||
};
|
||||
|
||||
export function HTMLtoContentState(html: string): ContentState {
|
||||
export function htmlToContentState(html: string): ContentState {
|
||||
return ContentState.createFromBlockArray(convertFromHTML(html));
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ const COMMANDS = [
|
|||
command: '/op',
|
||||
args: '<userId> [<power level>]',
|
||||
description: 'Define the power level of a user',
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
const COMMAND_RE = /(^\/\w*)/g;
|
||||
|
@ -96,7 +96,7 @@ export default class CommandProvider extends AutocompleteProvider {
|
|||
let completions = [];
|
||||
const {command, range} = this.getCurrentCommand(query, selection);
|
||||
if (command) {
|
||||
completions = this.matcher.match(command[0]).map(result => {
|
||||
completions = this.matcher.match(command[0]).map((result) => {
|
||||
return {
|
||||
completion: result.command + ' ',
|
||||
component: (<TextualCompletion
|
||||
|
|
|
@ -19,15 +19,17 @@ const DEFAULT_DISTANCE = 5;
|
|||
import PrefixMatcher from './QueryMatcher';
|
||||
export default PrefixMatcher;
|
||||
|
||||
class FuzzyMatcher {
|
||||
class FuzzyMatcher { // eslint-disable-line no-unused-vars
|
||||
/**
|
||||
* Given an array of objects and keys, returns a KeyMap
|
||||
* @param {object[]} objects the objects to perform a 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)
|
||||
*
|
||||
* To use, simply presort objects by required criteria, run through this function and create a FuzzyMatcher with the
|
||||
* resulting KeyMap.
|
||||
*
|
||||
* TODO: Handle arrays and objects (Fuse did this, RoomProvider uses it)
|
||||
* @return {KeyMap}
|
||||
*/
|
||||
static valuesToKeyMap(objects: Array<Object>, keys: Array<String>): KeyMap {
|
||||
const keyMap = new KeyMap();
|
||||
|
@ -48,7 +50,7 @@ class FuzzyMatcher {
|
|||
|
||||
keyMap.objectMap = map;
|
||||
keyMap.priorityMap = priorities;
|
||||
keyMap.keys = _sortBy(_keys(map), [value => priorities[value]]);
|
||||
keyMap.keys = _sortBy(_keys(map), [(value) => priorities[value]]);
|
||||
return keyMap;
|
||||
}
|
||||
|
||||
|
@ -74,15 +76,15 @@ class FuzzyMatcher {
|
|||
match(query: String): Array<Object> {
|
||||
const candidates = this.matcher.transduce(query, this.options.distance || DEFAULT_DISTANCE);
|
||||
// TODO FIXME This is hideous. Clean up when possible.
|
||||
const val = _sortedUniq(_sortBy(_flatMap(candidates, candidate => {
|
||||
return this.keyMap.objectMap[candidate[0]].map(value => {
|
||||
const val = _sortedUniq(_sortBy(_flatMap(candidates, (candidate) => {
|
||||
return this.keyMap.objectMap[candidate[0]].map((value) => {
|
||||
return {
|
||||
distance: candidate[1],
|
||||
...value,
|
||||
};
|
||||
});
|
||||
}),
|
||||
[candidate => candidate.distance, candidate => this.keyMap.priorityMap[candidate]]));
|
||||
[(candidate) => candidate.distance, (candidate) => this.keyMap.priorityMap[candidate]]));
|
||||
console.log(val);
|
||||
return val;
|
||||
}
|
||||
|
|
|
@ -14,13 +14,15 @@ class KeyMap {
|
|||
|
||||
export default class QueryMatcher {
|
||||
/**
|
||||
* Given an array of objects and keys, returns a KeyMap
|
||||
* @param {object[]} objects the objects to perform a 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)
|
||||
*
|
||||
* To use, simply presort objects by required criteria, run through this function and create a QueryMatcher with the
|
||||
* resulting KeyMap.
|
||||
*
|
||||
* TODO: Handle arrays and objects (Fuse did this, RoomProvider uses it)
|
||||
* @return {KeyMap}
|
||||
*/
|
||||
static valuesToKeyMap(objects: Array<Object>, keys: Array<String>): KeyMap {
|
||||
const keyMap = new KeyMap();
|
||||
|
|
|
@ -642,6 +642,10 @@ module.exports = React.createClass({
|
|||
},
|
||||
|
||||
_renderUserInterfaceSettings: function() {
|
||||
// TODO: this ought to be a separate component so that we don't need
|
||||
// to rebind the onChange each time we render
|
||||
const onChange = (e) =>
|
||||
UserSettingsStore.setLocalSetting('autocompleteDelay', + e.target.value);
|
||||
return (
|
||||
<div>
|
||||
<h3>{ _t("User Interface") }</h3>
|
||||
|
@ -657,9 +661,7 @@ module.exports = React.createClass({
|
|||
<input
|
||||
type="number"
|
||||
defaultValue={UserSettingsStore.getLocalSetting('autocompleteDelay', 200)}
|
||||
onChange={
|
||||
(e) => UserSettingsStore.setLocalSetting('autocompleteDelay', + e.target.value)
|
||||
}
|
||||
onChange={onChange}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -201,7 +201,7 @@ export default class MessageComposerInput extends React.Component {
|
|||
let {body, formatted_body} = payload.event.getContent();
|
||||
formatted_body = formatted_body || escape(body);
|
||||
if (formatted_body) {
|
||||
let content = RichText.HTMLtoContentState(`<blockquote>${formatted_body}</blockquote>`);
|
||||
let content = RichText.htmlToContentState(`<blockquote>${formatted_body}</blockquote>`);
|
||||
if (!this.state.isRichtextEnabled) {
|
||||
content = ContentState.createFromText(RichText.stateToMarkdown(content));
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ export default class MessageComposerInput extends React.Component {
|
|||
let contentState = null;
|
||||
if (enabled) {
|
||||
const md = new Markdown(this.state.editorState.getCurrentContent().getPlainText());
|
||||
contentState = RichText.HTMLtoContentState(md.toHTML());
|
||||
contentState = RichText.htmlToContentState(md.toHTML());
|
||||
} else {
|
||||
let markdown = RichText.stateToMarkdown(this.state.editorState.getCurrentContent());
|
||||
if (markdown[markdown.length - 1] === '\n') {
|
||||
|
|
Loading…
Reference in New Issue