Skip to content

Commit

Permalink
Merge branch 'flarum:2.x' into di/fix-post-mentions-formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideIadeluca authored Jan 10, 2024
2 parents 679a96f + f784f48 commit c0c152c
Show file tree
Hide file tree
Showing 182 changed files with 2,944 additions and 1,164 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ If you discover a security vulnerability within Flarum, please send an e-mail to
## License

Flarum is open-source software licensed under the [MIT License](https://github.com/flarum/flarum/blob/master/LICENSE).

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
"mockery/mockery": "^1.5",
"phpunit/phpunit": "^9.0",
"phpstan/phpstan": "^1.10.0",
"nunomaduro/larastan": "^2.6",
"larastan/larastan": "^2.7",
"symfony/var-dumper": "^6.3"
},
"config": {
Expand Down
2 changes: 1 addition & 1 deletion extensions/akismet/src/Akismet.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function sendRequest(string $type): ResponseInterface
$client = new Client();

return $client->request('POST', "$this->apiUrl/$type", [
'headers' => [
'headers' => [
'User-Agent' => "Flarum/$this->flarumVersion | Akismet/$this->extensionVersion",
],
'form_params' => $this->params,
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.

42 changes: 13 additions & 29 deletions extensions/emoji/js/src/forum/addComposerAutocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { extend } from 'flarum/common/extend';
import TextEditorButton from 'flarum/common/components/TextEditorButton';
import KeyboardNavigatable from 'flarum/common/utils/KeyboardNavigatable';
import Tooltip from 'flarum/common/components/Tooltip';
import AutocompleteReader from 'flarum/common/utils/AutocompleteReader';

import AutocompleteDropdown from './fragments/AutocompleteDropdown';
import getEmojiIconCode from './helpers/getEmojiIconCode';
Expand Down Expand Up @@ -40,15 +41,7 @@ export default function addComposerAutocomplete() {
extend('flarum/common/components/TextEditor', 'buildEditorParams', function (params) {
const emojiKeys = Object.keys(emojiMap);

let relEmojiStart;
let absEmojiStart;
let typed;

const applySuggestion = (replacement) => {
this.attrs.composer.editor.replaceBeforeCursor(absEmojiStart - 1, replacement + ' ');

this.emojiDropdown.hide();
};
const autocompleteReader = new AutocompleteReader(':');

params.inputListeners.push(() => {
const selection = this.attrs.composer.editor.getSelectionRange();
Expand All @@ -57,29 +50,20 @@ export default function addComposerAutocomplete() {

if (selection[1] - cursor > 0) return;

// Search backwards from the cursor for an ':' symbol. If we find
// one and followed by a whitespace, we will want to show the
// autocomplete dropdown!
const lastChunk = this.attrs.composer.editor.getLastNChars(15);
absEmojiStart = 0;
for (let i = lastChunk.length - 1; i >= 0; i--) {
const character = lastChunk.substr(i, 1);
// check what user typed, emoji names only contains alphanumeric,
// underline, '+' and '-'
if (!/[a-z0-9]|\+|\-|_|\:/.test(character)) break;
// make sure ':' preceded by a whitespace or newline
if (character === ':' && (i == 0 || /\s/.test(lastChunk.substr(i - 1, 1)))) {
relEmojiStart = i + 1;
absEmojiStart = cursor - lastChunk.length + i + 1;
break;
}
}
const autocompleting = autocompleteReader.check(lastChunk, cursor, /[a-z0-9]|\+|\-|_|\:/);

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

if (absEmojiStart) {
typed = lastChunk.substring(relEmojiStart).toLowerCase();
if (autocompleting) {
const typed = autocompleting.typed;
const emojiDropdown = this.emojiDropdown;

const applySuggestion = (replacement) => {
this.attrs.composer.editor.replaceBeforeCursor(autocompleting.absoluteStart - 1, replacement + ' ');
this.emojiDropdown.hide();
};

const makeSuggestion = function ({ emoji, name, code }) {
return (
Expand All @@ -88,7 +72,7 @@ export default function addComposerAutocomplete() {
key={emoji}
onclick={() => applySuggestion(emoji)}
onmouseenter={function () {
this.emojiDropdown.setIndex($(this).parent().index() - 1);
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 @@ -152,7 +136,7 @@ export default function addComposerAutocomplete() {
m.render(this.$('.ComposerBody-emojiDropdownContainer')[0], this.emojiDropdown.render());

this.emojiDropdown.show();
const coordinates = this.attrs.composer.editor.getCaretCoordinates(absEmojiStart);
const coordinates = this.attrs.composer.editor.getCaretCoordinates(autocompleting.absoluteStart);
const width = this.emojiDropdown.$().outerWidth();
const height = this.emojiDropdown.$().outerHeight();
const parent = this.emojiDropdown.$().offsetParent();
Expand Down
1 change: 1 addition & 0 deletions extensions/flags/src/AddCanFlagAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ protected function checkFlagOwnPostSetting(User $actor, Post $post): bool
// If $actor is the post author, check to see if the setting is enabled
return (bool) $this->settings->get('flarum-flags.can_flag_own');
}

// $actor is not the post author
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions extensions/flags/src/Api/Serializer/FlagSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ protected function getDefaultAttributes(object|array $model): array
}

return [
'type' => $model->type,
'reason' => $model->reason,
'type' => $model->type,
'reason' => $model->reason,
'reasonDetail' => $model->reason_detail,
'createdAt' => $this->formatDate($model->created_at),
'createdAt' => $this->formatDate($model->created_at),
];
}

Expand Down
2 changes: 1 addition & 1 deletion extensions/lock/js/dist/admin.js

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

2 changes: 1 addition & 1 deletion extensions/lock/js/dist/admin.js.map

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

Loading

0 comments on commit c0c152c

Please sign in to comment.