Skip to content

Commit

Permalink
Merge branch '2.x' into sm/emoji-autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 authored Nov 11, 2023
2 parents 6dea293 + 60ffa78 commit 729802a
Show file tree
Hide file tree
Showing 147 changed files with 634 additions and 1,140 deletions.
2 changes: 1 addition & 1 deletion extensions/embed/less/forum.less
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
padding: 15px 15px;

.scrolled & {
.box-shadow(0 2px 6px var(--shadow-color));
box-shadow: 0 2px 6px var(--shadow-color);
}
}

Expand Down
2 changes: 1 addition & 1 deletion extensions/emoji/js/dist/forum.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion extensions/emoji/js/dist/forum.js.map

Large diffs are not rendered by default.

43 changes: 21 additions & 22 deletions extensions/emoji/js/src/forum/addComposerAutocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import getEmojiIconCode from './helpers/getEmojiIconCode';
import cdn from './cdn';

export default function addComposerAutocomplete() {
const $container = $('<div class="ComposerBody-emojiDropdownContainer"></div>');
const dropdown = new AutocompleteDropdown();
let emojiMap = null;

extend('flarum/common/components/TextEditor', 'oninit', function () {
Expand All @@ -24,18 +22,19 @@ export default function addComposerAutocomplete() {
});

extend('flarum/common/components/TextEditor', 'onbuild', function () {
this.emojiDropdown = new AutocompleteDropdown();
const $editor = this.$('.TextEditor-editor').wrap('<div class="ComposerBody-emojiWrapper"></div>');

this.navigator = new KeyboardNavigatable();
this.navigator
.when(() => dropdown.active)
.onUp(() => dropdown.navigate(-1))
.onDown(() => dropdown.navigate(1))
.onSelect(dropdown.complete.bind(dropdown))
.onCancel(dropdown.hide.bind(dropdown))
.when(() => this.emojiDropdown.active)
.onUp(() => this.emojiDropdown.navigate(-1))
.onDown(() => this.emojiDropdown.navigate(1))
.onSelect(this.emojiDropdown.complete.bind(this.emojiDropdown))
.onCancel(this.emojiDropdown.hide.bind(this.emojiDropdown))
.bindTo($editor);

$editor.after($container);
$editor.after($('<div class="ComposerBody-emojiDropdownContainer"></div>'));
});

extend('flarum/common/components/TextEditor', 'buildEditorParams', function (params) {
Expand All @@ -48,7 +47,7 @@ export default function addComposerAutocomplete() {
const applySuggestion = (replacement) => {
this.attrs.composer.editor.replaceBeforeCursor(absEmojiStart - 1, replacement + ' ');

dropdown.hide();
this.emojiDropdown.hide();
};

params.inputListeners.push(() => {
Expand Down Expand Up @@ -76,8 +75,8 @@ export default function addComposerAutocomplete() {
}
}

dropdown.hide();
dropdown.active = false;
this.emojiDropdown.hide();
this.emojiDropdown.active = false;

if (absEmojiStart) {
typed = lastChunk.substring(relEmojiStart).toLowerCase();
Expand All @@ -89,7 +88,7 @@ export default function addComposerAutocomplete() {
key={emoji}
onclick={() => applySuggestion(emoji)}
onmouseenter={function () {
dropdown.setIndex($(this).parent().index() - 1);
this.emojiDropdown.setIndex($(this).parent().index() - 1);
}}
>
<img alt={emoji} className="emoji" draggable="false" loading="lazy" src={`${cdn}72x72/${code}.png`} title={name} />
Expand Down Expand Up @@ -149,14 +148,14 @@ export default function addComposerAutocomplete() {
.map(makeSuggestion);

if (suggestions.length) {
dropdown.items = suggestions;
m.render($container[0], dropdown.render());
this.emojiDropdown.items = suggestions;
m.render(this.$('.ComposerBody-emojiDropdownContainer')[0], this.emojiDropdown.render());

dropdown.show();
this.emojiDropdown.show();
const coordinates = this.attrs.composer.editor.getCaretCoordinates(absEmojiStart);
const width = dropdown.$().outerWidth();
const height = dropdown.$().outerHeight();
const parent = dropdown.$().offsetParent();
const width = this.emojiDropdown.$().outerWidth();
const height = this.emojiDropdown.$().outerHeight();
const parent = this.emojiDropdown.$().offsetParent();
let left = coordinates.left;
let top = coordinates.top + 15;

Expand All @@ -172,15 +171,15 @@ export default function addComposerAutocomplete() {
top = Math.max(-(parent.offset().top - $(document).scrollTop()), top);
left = Math.max(-parent.offset().left, left);

dropdown.show(left, top);
this.emojiDropdown.show(left, top);
}
};

buildSuggestions();

dropdown.setIndex(0);
dropdown.$().scrollTop(0);
dropdown.active = true;
this.emojiDropdown.setIndex(0);
this.emojiDropdown.$().scrollTop(0);
this.emojiDropdown.active = true;
}
});
});
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion extensions/flags/js/dist/forum.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion extensions/flags/js/dist/forum.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion extensions/flags/js/src/forum/addFlagsToPosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default function () {

const controls = PostControls.destructiveControls(this.attrs.post);

Object.keys(controls.items).forEach((k) => {
Object.keys(controls.toObject()).forEach((k) => {
const attrs = controls.get(k).attrs;

attrs.className = 'Button';
Expand Down
4 changes: 2 additions & 2 deletions extensions/flags/js/src/forum/components/FlagPostModal.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import app from 'flarum/forum/app';
import Modal from 'flarum/common/components/Modal';
import FormModal from 'flarum/common/components/FormModal';
import Form from 'flarum/common/components/Form';
import Button from 'flarum/common/components/Button';

import Stream from 'flarum/common/utils/Stream';
import withAttr from 'flarum/common/utils/withAttr';
import ItemList from 'flarum/common/utils/ItemList';

export default class FlagPostModal extends Modal {
export default class FlagPostModal extends FormModal {
oninit(vnode) {
super.oninit(vnode);

Expand Down
4 changes: 0 additions & 4 deletions extensions/flags/src/Command/DeleteFlagsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
namespace Flarum\Flags\Command;

use Flarum\Flags\Event\Deleting;
use Flarum\Flags\Event\FlagsWillBeDeleted;
use Flarum\Post\Post;
use Flarum\Post\PostRepository;
use Illuminate\Events\Dispatcher;
Expand All @@ -31,9 +30,6 @@ public function handle(DeleteFlags $command): Post

$actor->assertCan('viewFlags', $post->discussion);

// Deprecated, removed v2.0
$this->events->dispatch(new FlagsWillBeDeleted($post, $actor, $command->data));

foreach ($post->flags as $flag) {
$this->events->dispatch(new Deleting($flag, $actor, $command->data));
}
Expand Down
27 changes: 0 additions & 27 deletions extensions/flags/src/Event/FlagsWillBeDeleted.php

This file was deleted.

2 changes: 1 addition & 1 deletion extensions/mentions/js/dist/forum.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion extensions/mentions/js/dist/forum.js.map

Large diffs are not rendered by default.

48 changes: 23 additions & 25 deletions extensions/mentions/js/src/forum/addComposerAutocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@ import AutocompleteDropdown from './fragments/AutocompleteDropdown';
import MentionableModels from './mentionables/MentionableModels';

export default function addComposerAutocomplete() {
const $container = $('<div class="ComposerBody-mentionsDropdownContainer"></div>');
const dropdown = new AutocompleteDropdown();

extend('flarum/common/components/TextEditor', 'onbuild', function () {
this.mentionsDropdown = new AutocompleteDropdown();
const $editor = this.$('.TextEditor-editor').wrap('<div class="ComposerBody-mentionsWrapper"></div>');

this.navigator = new KeyboardNavigatable();
this.navigator
.when(() => dropdown.active)
.onUp(() => dropdown.navigate(-1))
.onDown(() => dropdown.navigate(1))
.onSelect(dropdown.complete.bind(dropdown))
.onCancel(dropdown.hide.bind(dropdown))
.when(() => this.mentionsDropdown.active)
.onUp(() => this.mentionsDropdown.navigate(-1))
.onDown(() => this.mentionsDropdown.navigate(1))
.onSelect(this.mentionsDropdown.complete.bind(this.mentionsDropdown))
.onCancel(this.mentionsDropdown.hide.bind(this.mentionsDropdown))
.bindTo($editor);

$editor.after($container);
$editor.after($('<div class="ComposerBody-mentionsDropdownContainer"></div>'));
});

extend('flarum/common/components/TextEditor', 'buildEditorParams', function (params) {
Expand All @@ -32,12 +30,12 @@ export default function addComposerAutocomplete() {

let mentionables = new MentionableModels({
onmouseenter: function () {
dropdown.setIndex($(this).parent().index());
this.mentionsDropdown.setIndex($(this).parent().index());
},
onclick: (replacement) => {
this.attrs.composer.editor.replaceBeforeCursor(absMentionStart - 1, replacement + ' ');

dropdown.hide();
this.mentionsDropdown.hide();
},
});

Expand Down Expand Up @@ -66,8 +64,8 @@ export default function addComposerAutocomplete() {
}
}

dropdown.hide();
dropdown.active = false;
this.mentionsDropdown.hide();
this.mentionsDropdown.active = false;

if (absMentionStart) {
const typed = lastChunk.substring(relMentionStart).toLowerCase();
Expand All @@ -83,14 +81,14 @@ export default function addComposerAutocomplete() {
const suggestions = mentionables.buildSuggestions();

if (suggestions.length) {
dropdown.items = suggestions;
m.render($container[0], dropdown.render());
this.mentionsDropdown.items = suggestions;
m.render(this.$('.ComposerBody-mentionsDropdownContainer')[0], this.mentionsDropdown.render());

dropdown.show();
this.mentionsDropdown.show();
const coordinates = this.attrs.composer.editor.getCaretCoordinates(absMentionStart);
const width = dropdown.$().outerWidth();
const height = dropdown.$().outerHeight();
const parent = dropdown.$().offsetParent();
const width = this.mentionsDropdown.$().outerWidth();
const height = this.mentionsDropdown.$().outerHeight();
const parent = this.mentionsDropdown.$().offsetParent();
let left = coordinates.left;
let top = coordinates.top + 15;

Expand All @@ -106,19 +104,19 @@ export default function addComposerAutocomplete() {
top = Math.max(-(parent.offset().top - $(document).scrollTop()), top);
left = Math.max(-parent.offset().left, left);

dropdown.show(left, top);
this.mentionsDropdown.show(left, top);
} else {
dropdown.active = false;
dropdown.hide();
this.mentionsDropdown.active = false;
this.mentionsDropdown.hide();
}
};

dropdown.active = true;
this.mentionsDropdown.active = true;

buildSuggestions();

dropdown.setIndex(0);
dropdown.$().scrollTop(0);
this.mentionsDropdown.setIndex(0);
this.mentionsDropdown.$().scrollTop(0);

mentionables.search()?.then(buildSuggestions);
}
Expand Down
1 change: 0 additions & 1 deletion extensions/mentions/js/src/forum/forum.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import './components/UserMentionedNotification';
import './fragments/AutocompleteDropdown';
import './fragments/PostQuoteButton';
import './utils/getCleanDisplayName';
import './utils/getMentionText';
import './utils/reply';
import './utils/selectedText';
import './utils/textFormatter';
Expand Down
21 changes: 0 additions & 21 deletions extensions/mentions/js/src/forum/utils/getMentionText.js

This file was deleted.

3 changes: 2 additions & 1 deletion extensions/nicknames/extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
->default('flarum-nicknames.set_on_registration', true)
->default('flarum-nicknames.min', 1)
->default('flarum-nicknames.max', 150)
->serializeToForum('displayNameDriver', 'display_name_driver', null, 'username')
->default('display_name_driver', 'username')
->serializeToForum('displayNameDriver', 'display_name_driver')
->serializeToForum('setNicknameOnRegistration', 'flarum-nicknames.set_on_registration', 'boolval')
->serializeToForum('randomizeUsernameOnRegistration', 'flarum-nicknames.random_username', 'boolval'),

Expand Down
Loading

0 comments on commit 729802a

Please sign in to comment.