mirror of
https://github.com/flarum/core.git
synced 2025-07-29 12:40:40 +02:00
Mithril 2 Update (#52)
Update for Mithril 2 - Please note that PostQuoteButton and AutocompleteDropdown are not Fragments, not Components. Accordingly, they have been moved to the components folder. Co-authored-by: Matthew Kilgore <tankerkiller125@gmail.com> Co-authored-by: Franz Liedke <franz@develophp.org>
This commit is contained in:
committed by
GitHub
parent
a48a84fcd0
commit
ea56f39a53
@@ -11,14 +11,12 @@ import highlight from 'flarum/helpers/highlight';
|
||||
import KeyboardNavigatable from 'flarum/utils/KeyboardNavigatable';
|
||||
import { truncate } from 'flarum/utils/string';
|
||||
|
||||
import AutocompleteDropdown from './components/AutocompleteDropdown';
|
||||
import AutocompleteDropdown from './fragments/AutocompleteDropdown';
|
||||
|
||||
export default function addComposerAutocomplete() {
|
||||
extend(TextEditor.prototype, 'config', function(original, isInitialized) {
|
||||
if (isInitialized) return;
|
||||
|
||||
extend(TextEditor.prototype, 'oncreate', function () {
|
||||
const $container = $('<div class="ComposerBody-mentionsDropdownContainer"></div>');
|
||||
const dropdown = new AutocompleteDropdown({items: []});
|
||||
const dropdown = new AutocompleteDropdown();
|
||||
const $textarea = this.$('textarea').wrap('<div class="ComposerBody-mentionsWrapper"></div>');
|
||||
const searched = [];
|
||||
let mentionStart;
|
||||
@@ -77,7 +75,8 @@ export default function addComposerAutocomplete() {
|
||||
const makeSuggestion = function(user, replacement, content, className = '') {
|
||||
const username = usernameHelper(user);
|
||||
if (typed) {
|
||||
username.children[0] = highlight(username.children[0], typed);
|
||||
username.children = [highlight(username.text, typed)];
|
||||
delete username.text;
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -150,7 +149,7 @@ export default function addComposerAutocomplete() {
|
||||
}
|
||||
|
||||
if (suggestions.length) {
|
||||
dropdown.props.items = suggestions;
|
||||
dropdown.items = suggestions;
|
||||
m.render($container[0], dropdown.render());
|
||||
|
||||
dropdown.show();
|
||||
|
Reference in New Issue
Block a user